mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-27 09:26:23 +02:00
set up basic workflow execution
This commit is contained in:
parent
7758139893
commit
c004bc5eb6
24 changed files with 794 additions and 298 deletions
|
|
@ -1,7 +1,34 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const BaseAgentTool = z.object({
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
export const BuiltinAgentTool = BaseAgentTool.extend({
|
||||
type: z.literal("builtin"),
|
||||
});
|
||||
|
||||
export const McpAgentTool = BaseAgentTool.extend({
|
||||
type: z.literal("mcp"),
|
||||
description: z.string(),
|
||||
inputSchema: z.any(),
|
||||
mcpServerName: z.string(),
|
||||
});
|
||||
|
||||
export const WorkflowAgentTool = BaseAgentTool.extend({
|
||||
type: z.literal("workflow"),
|
||||
});
|
||||
|
||||
export const AgentTool = z.discriminatedUnion("type", [
|
||||
BuiltinAgentTool,
|
||||
McpAgentTool,
|
||||
WorkflowAgentTool,
|
||||
]);
|
||||
|
||||
export const Agent = z.object({
|
||||
name: z.string(),
|
||||
model: z.string(),
|
||||
description: z.string(),
|
||||
instructions: z.string(),
|
||||
tools: z.record(z.string(), AgentTool).optional(),
|
||||
});
|
||||
|
|
|
|||
56
apps/cli/src/application/entities/llm-step-event.ts
Normal file
56
apps/cli/src/application/entities/llm-step-event.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const LlmStepStreamReasoningStartEvent = z.object({
|
||||
type: z.literal("reasoning-start"),
|
||||
});
|
||||
|
||||
export const LlmStepStreamReasoningDeltaEvent = z.object({
|
||||
type: z.literal("reasoning-delta"),
|
||||
delta: z.string(),
|
||||
});
|
||||
|
||||
export const LlmStepStreamReasoningEndEvent = z.object({
|
||||
type: z.literal("reasoning-end"),
|
||||
});
|
||||
|
||||
export const LlmStepStreamTextStartEvent = z.object({
|
||||
type: z.literal("text-start"),
|
||||
});
|
||||
|
||||
export const LlmStepStreamTextDeltaEvent = z.object({
|
||||
type: z.literal("text-delta"),
|
||||
delta: z.string(),
|
||||
});
|
||||
|
||||
export const LlmStepStreamTextEndEvent = z.object({
|
||||
type: z.literal("text-end"),
|
||||
});
|
||||
|
||||
export const LlmStepStreamToolCallEvent = z.object({
|
||||
type: z.literal("tool-call"),
|
||||
toolCallId: z.string(),
|
||||
toolName: z.string(),
|
||||
input: z.any(),
|
||||
});
|
||||
|
||||
export const LlmStepStreamUsageEvent = z.object({
|
||||
type: z.literal("usage"),
|
||||
usage: z.object({
|
||||
inputTokens: z.number().optional(),
|
||||
outputTokens: z.number().optional(),
|
||||
totalTokens: z.number().optional(),
|
||||
reasoningTokens: z.number().optional(),
|
||||
cachedInputTokens: z.number().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const LlmStepStreamEvent = z.union([
|
||||
LlmStepStreamReasoningStartEvent,
|
||||
LlmStepStreamReasoningDeltaEvent,
|
||||
LlmStepStreamReasoningEndEvent,
|
||||
LlmStepStreamTextStartEvent,
|
||||
LlmStepStreamTextDeltaEvent,
|
||||
LlmStepStreamTextEndEvent,
|
||||
LlmStepStreamToolCallEvent,
|
||||
LlmStepStreamUsageEvent,
|
||||
]);
|
||||
|
|
@ -1,8 +1,16 @@
|
|||
import z from "zod";
|
||||
|
||||
const StdioMcpServerConfig = z.object({
|
||||
command: z.string(),
|
||||
args: z.array(z.string()).optional(),
|
||||
env: z.record(z.string(), z.string()).optional(),
|
||||
});
|
||||
|
||||
const HttpMcpServerConfig = z.object({
|
||||
url: z.string(),
|
||||
headers: z.record(z.string(), z.string()).optional(),
|
||||
});
|
||||
|
||||
export const McpServerConfig = z.object({
|
||||
mcpServers: z.array(z.object({
|
||||
name: z.string(),
|
||||
url: z.string(),
|
||||
})),
|
||||
mcpServers: z.record(z.string(), z.union([StdioMcpServerConfig, HttpMcpServerConfig])),
|
||||
});
|
||||
|
|
@ -14,7 +14,7 @@ export const ToolCallPart = z.object({
|
|||
type: z.literal("tool-call"),
|
||||
toolCallId: z.string(),
|
||||
toolName: z.string(),
|
||||
arguments: z.string(),
|
||||
arguments: z.any(),
|
||||
});
|
||||
|
||||
export const AssistantContentPart = z.union([
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const ReasoningStartEvent = z.object({
|
||||
type: z.literal("reasoning-start"),
|
||||
});
|
||||
|
||||
export const ReasoningDeltaEvent = z.object({
|
||||
type: z.literal("reasoning-delta"),
|
||||
delta: z.string(),
|
||||
});
|
||||
|
||||
export const ReasoningEndEvent = z.object({
|
||||
type: z.literal("reasoning-end"),
|
||||
});
|
||||
|
||||
export const TextStartEvent = z.object({
|
||||
type: z.literal("text-start"),
|
||||
});
|
||||
|
||||
export const TextDeltaEvent = z.object({
|
||||
type: z.literal("text-delta"),
|
||||
delta: z.string(),
|
||||
});
|
||||
|
||||
export const TextEndEvent = z.object({
|
||||
type: z.literal("text-end"),
|
||||
});
|
||||
|
||||
export const ToolCallEvent = z.object({
|
||||
type: z.literal("tool-call"),
|
||||
toolCallId: z.string(),
|
||||
toolName: z.string(),
|
||||
input: z.any(),
|
||||
});
|
||||
|
||||
export const UsageEvent = z.object({
|
||||
type: z.literal("usage"),
|
||||
usage: z.object({
|
||||
inputTokens: z.number().optional(),
|
||||
outputTokens: z.number().optional(),
|
||||
totalTokens: z.number().optional(),
|
||||
reasoningTokens: z.number().optional(),
|
||||
cachedInputTokens: z.number().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const StreamEvent = z.union([
|
||||
ReasoningStartEvent,
|
||||
ReasoningDeltaEvent,
|
||||
ReasoningEndEvent,
|
||||
TextStartEvent,
|
||||
TextDeltaEvent,
|
||||
TextEndEvent,
|
||||
ToolCallEvent,
|
||||
UsageEvent,
|
||||
]);
|
||||
69
apps/cli/src/application/entities/workflow-event.ts
Normal file
69
apps/cli/src/application/entities/workflow-event.ts
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import { z } from "zod";
|
||||
import { LlmStepStreamEvent } from "./llm-step-event.js";
|
||||
import { Workflow } from "./workflow.js";
|
||||
import { Message } from "./message.js";
|
||||
|
||||
export const WorkflowStreamStartEvent = z.object({
|
||||
type: z.literal("workflow-start"),
|
||||
workflowId: z.string(),
|
||||
workflow: Workflow,
|
||||
background: z.boolean(),
|
||||
});
|
||||
|
||||
export const WorkflowStreamStepStartEvent = z.object({
|
||||
type: z.literal("workflow-step-start"),
|
||||
stepId: z.string(),
|
||||
stepType: z.enum(["agent", "function"]),
|
||||
});
|
||||
|
||||
export const WorkflowStreamStepStreamEventEvent = z.object({
|
||||
type: z.literal("workflow-step-stream-event"),
|
||||
stepId: z.string(),
|
||||
event: LlmStepStreamEvent,
|
||||
});
|
||||
|
||||
export const WorkflowStreamStepMessageEvent = z.object({
|
||||
type: z.literal("workflow-step-message"),
|
||||
stepId: z.string(),
|
||||
message: Message,
|
||||
});
|
||||
|
||||
export const WorkflowStreamStepToolInvocationEvent = z.object({
|
||||
type: z.literal("workflow-step-tool-invocation"),
|
||||
stepId: z.string(),
|
||||
toolName: z.string(),
|
||||
input: z.string(),
|
||||
});
|
||||
|
||||
export const WorkflowStreamStepToolResultEvent = z.object({
|
||||
type: z.literal("workflow-step-tool-result"),
|
||||
stepId: z.string(),
|
||||
toolName: z.string(),
|
||||
result: z.any(),
|
||||
});
|
||||
|
||||
export const WorkflowStreamStepEndEvent = z.object({
|
||||
type: z.literal("workflow-step-end"),
|
||||
stepId: z.string(),
|
||||
});
|
||||
|
||||
export const WorkflowStreamEndEvent = z.object({
|
||||
type: z.literal("workflow-end"),
|
||||
});
|
||||
|
||||
export const WorkflowStreamErrorEvent = z.object({
|
||||
type: z.literal("workflow-error"),
|
||||
error: z.string(),
|
||||
});
|
||||
|
||||
export const WorkflowStreamEvent = z.union([
|
||||
WorkflowStreamStartEvent,
|
||||
WorkflowStreamStepStartEvent,
|
||||
WorkflowStreamStepStreamEventEvent,
|
||||
WorkflowStreamStepMessageEvent,
|
||||
WorkflowStreamStepToolInvocationEvent,
|
||||
WorkflowStreamStepToolResultEvent,
|
||||
WorkflowStreamStepEndEvent,
|
||||
WorkflowStreamEndEvent,
|
||||
WorkflowStreamErrorEvent,
|
||||
]);
|
||||
|
|
@ -10,7 +10,7 @@ const FunctionStep = z.object({
|
|||
id: z.string(),
|
||||
});
|
||||
|
||||
const Step = z.discriminatedUnion("type", [AgentStep, FunctionStep]);
|
||||
export const Step = z.discriminatedUnion("type", [AgentStep, FunctionStep]);
|
||||
|
||||
export const Workflow = z.object({
|
||||
name: z.string(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue