zeitlich 0.2.19 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/sandbox/daytona/index.cjs +25 -10
- package/dist/adapters/sandbox/daytona/index.cjs.map +1 -1
- package/dist/adapters/sandbox/daytona/index.d.cts +4 -1
- package/dist/adapters/sandbox/daytona/index.d.ts +4 -1
- package/dist/adapters/sandbox/daytona/index.js +25 -10
- package/dist/adapters/sandbox/daytona/index.js.map +1 -1
- package/dist/adapters/sandbox/virtual/index.d.cts +4 -3
- package/dist/adapters/sandbox/virtual/index.d.ts +4 -3
- package/dist/adapters/thread/google-genai/index.cjs +69 -24
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +10 -10
- package/dist/adapters/thread/google-genai/index.d.ts +10 -10
- package/dist/adapters/thread/google-genai/index.js +69 -24
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/langchain/index.cjs +76 -69
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +11 -11
- package/dist/adapters/thread/langchain/index.d.ts +11 -11
- package/dist/adapters/thread/langchain/index.js +76 -69
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/index.cjs +198 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.js +198 -118
- package/dist/index.js.map +1 -1
- package/dist/{queries-D8T4pEeu.d.ts → queries-6Avfh74U.d.ts} +1 -1
- package/dist/{queries-D22uWTOb.d.cts → queries-CHa2iv_I.d.cts} +1 -1
- package/dist/{types-CxWLeJTB.d.ts → types-BkAYmc96.d.ts} +6 -6
- package/dist/{types-CCfJb5Jl.d.cts → types-CES_30qx.d.cts} +6 -6
- package/dist/{types-DjT78Sdp.d.cts → types-YbL7JpEA.d.cts} +4 -2
- package/dist/{types-DjT78Sdp.d.ts → types-YbL7JpEA.d.ts} +4 -2
- package/dist/workflow.cjs +68 -34
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +16 -12
- package/dist/workflow.d.ts +16 -12
- package/dist/workflow.js +68 -34
- package/dist/workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/sandbox/daytona/filesystem.ts +21 -12
- package/src/adapters/sandbox/daytona/index.ts +24 -23
- package/src/adapters/thread/google-genai/activities.ts +11 -9
- package/src/adapters/thread/google-genai/model-invoker.ts +6 -11
- package/src/adapters/thread/google-genai/thread-manager.ts +44 -29
- package/src/adapters/thread/langchain/activities.ts +6 -4
- package/src/adapters/thread/langchain/thread-manager.ts +55 -27
- package/src/lib/session/session-edge-cases.integration.test.ts +20 -2
- package/src/lib/session/session.integration.test.ts +16 -2
- package/src/lib/session/session.ts +7 -5
- package/src/lib/session/types.ts +9 -3
- package/src/lib/subagent/handler.ts +1 -1
- package/src/lib/subagent/subagent.integration.test.ts +5 -4
- package/src/lib/subagent/tool.ts +1 -1
- package/src/lib/thread/index.ts +0 -1
- package/src/lib/tool-router/auto-append-sandbox.integration.test.ts +20 -21
- package/src/lib/tool-router/auto-append.ts +3 -2
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +64 -23
- package/src/lib/tool-router/router.integration.test.ts +60 -23
- package/src/lib/tool-router/router.ts +58 -29
- package/src/lib/tool-router/types.ts +12 -7
- package/src/lib/workflow.test.ts +18 -6
- package/src/lib/workflow.ts +13 -3
- package/src/tools/task-create/handler.ts +3 -6
- package/src/workflow.ts +2 -2
package/dist/workflow.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { proxyActivities } from '@temporalio/workflow';
|
|
2
|
-
import { k as SessionConfig, Z as ZeitlichSession, T as ThreadOps, f as JsonSerializable, e as AgentStateManager, q as SubagentDefinition, s as SubagentHooks, p as SubagentConfig, t as SubagentSessionInput, r as SubagentHandlerResponse, b as SkillMetadata, c as Skill } from './types-
|
|
3
|
-
export { A as AgentResponse, d as AgentState, H as Hooks, J as JsonPrimitive, g as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, P as PostHumanMessageAppendHook, h as PostHumanMessageAppendHookContext, i as PreHumanMessageAppendHook, j as PreHumanMessageAppendHookContext, R as RunAgentActivity, l as SessionEndHook, m as SessionEndHookContext, n as SessionStartHook, o as SessionStartHookContext, S as SkillProvider, u as SubagentWorkflow, v as SubagentWorkflowInput } from './types-
|
|
1
|
+
import { proxyActivities, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
2
|
+
import { k as SessionConfig, Z as ZeitlichSession, T as ThreadOps, f as JsonSerializable, e as AgentStateManager, q as SubagentDefinition, s as SubagentHooks, p as SubagentConfig, t as SubagentSessionInput, r as SubagentHandlerResponse, b as SkillMetadata, c as Skill } from './types-CES_30qx.cjs';
|
|
3
|
+
export { A as AgentResponse, d as AgentState, H as Hooks, J as JsonPrimitive, g as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, P as PostHumanMessageAppendHook, h as PostHumanMessageAppendHookContext, i as PreHumanMessageAppendHook, j as PreHumanMessageAppendHookContext, R as RunAgentActivity, l as SessionEndHook, m as SessionEndHookContext, n as SessionStartHook, o as SessionStartHookContext, S as SkillProvider, u as SubagentWorkflow, v as SubagentWorkflowInput } from './types-CES_30qx.cjs';
|
|
4
4
|
import { g as SandboxOps } from './types-BMRzfELQ.cjs';
|
|
5
5
|
export { h as ExecOptions, E as ExecResult, S as Sandbox, c as SandboxCapabilities, d as SandboxCreateOptions, e as SandboxCreateResult, D as SandboxDirentEntry, F as SandboxFileStat, a as SandboxFileSystem, i as SandboxNotFoundError, j as SandboxNotSupportedError, b as SandboxProvider, f as SandboxSnapshot } from './types-BMRzfELQ.cjs';
|
|
6
|
-
import { a as ToolMap, B as BaseAgentState, N as ToolRouterOptions, J as ToolRouter, R as RouterContext, K as ToolWithHandler, p as ParsedToolCallUnion, G as ToolNames, c as ToolHandlerResponse, E as ToolHandler, W as WorkflowTask, A as ActivityToolHandler } from './types-
|
|
7
|
-
export { l as AgentConfig, m as AgentFile, h as AgentStatus, n as AppendToolResultFn, C as ContentPart, I as InferToolResults, M as MessageContent, o as ParsedToolCall, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, d as PostToolUseFailureHookResult, s as PostToolUseHook, t as PostToolUseHookContext, u as PreToolUseHook, v as PreToolUseHookContext, P as PreToolUseHookResult, w as ProcessToolCallsContext, e as RawToolCall, g as RunAgentConfig, x as SerializableToolDefinition, S as SessionExitReason, y as TaskStatus, f as TokenUsage, z as ToolArgs, D as ToolCallResult, k as ToolCallResultUnion, i as ToolDefinition, F as ToolHooks, T as ToolMessageContent, H as ToolResult, j as ToolResultConfig, b as ToolRouterHooks, L as isTerminalStatus } from './types-
|
|
6
|
+
import { a as ToolMap, B as BaseAgentState, N as ToolRouterOptions, J as ToolRouter, R as RouterContext, K as ToolWithHandler, p as ParsedToolCallUnion, G as ToolNames, c as ToolHandlerResponse, E as ToolHandler, W as WorkflowTask, A as ActivityToolHandler } from './types-YbL7JpEA.cjs';
|
|
7
|
+
export { l as AgentConfig, m as AgentFile, h as AgentStatus, n as AppendToolResultFn, C as ContentPart, I as InferToolResults, M as MessageContent, o as ParsedToolCall, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, d as PostToolUseFailureHookResult, s as PostToolUseHook, t as PostToolUseHookContext, u as PreToolUseHook, v as PreToolUseHookContext, P as PreToolUseHookResult, w as ProcessToolCallsContext, e as RawToolCall, g as RunAgentConfig, x as SerializableToolDefinition, S as SessionExitReason, y as TaskStatus, f as TokenUsage, z as ToolArgs, D as ToolCallResult, k as ToolCallResultUnion, i as ToolDefinition, F as ToolHooks, T as ToolMessageContent, H as ToolResult, j as ToolResultConfig, b as ToolRouterHooks, L as isTerminalStatus } from './types-YbL7JpEA.cjs';
|
|
8
8
|
import z$1, { z } from 'zod';
|
|
9
|
-
import { F as FileEntryMetadata, f as VirtualFileTree, T as TreeMutation, c as FileEntry } from './queries-
|
|
10
|
-
export { a as FileResolver, h as VirtualSandboxState, i as filesWithMimeType, j as hasDirectory, k as hasFileWithMimeType } from './queries-
|
|
9
|
+
import { F as FileEntryMetadata, f as VirtualFileTree, T as TreeMutation, c as FileEntry } from './queries-CHa2iv_I.cjs';
|
|
10
|
+
export { a as FileResolver, h as VirtualSandboxState, i as filesWithMimeType, j as hasDirectory, k as hasFileWithMimeType } from './queries-CHa2iv_I.cjs';
|
|
11
11
|
import '@temporalio/common';
|
|
12
12
|
import '@temporalio/common/lib/interfaces';
|
|
13
13
|
|
|
@@ -56,7 +56,7 @@ declare const createSession: <T extends ToolMap, M = unknown>({ threadId: provid
|
|
|
56
56
|
* });
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
declare function proxyDefaultThreadOps(options?: Parameters<typeof proxyActivities>[0]): ThreadOps
|
|
59
|
+
declare function proxyDefaultThreadOps(options?: Parameters<typeof proxyActivities>[0]): ActivityInterfaceFor<ThreadOps>;
|
|
60
60
|
/**
|
|
61
61
|
* Proxy sandbox lifecycle operations as Temporal activities.
|
|
62
62
|
* Call this in workflow code when the agent needs a sandbox.
|
|
@@ -90,17 +90,21 @@ interface WorkflowInput {
|
|
|
90
90
|
/** Optional sandbox ID to reuse */
|
|
91
91
|
sandboxId?: string;
|
|
92
92
|
}
|
|
93
|
+
interface WorkflowConfig {
|
|
94
|
+
/** Workflow name — used as the Temporal workflow function name */
|
|
95
|
+
name: string;
|
|
96
|
+
}
|
|
93
97
|
/**
|
|
94
98
|
* Wraps a main workflow function, translating workflow input fields into
|
|
95
99
|
* session-compatible fields that can be spread directly into `createSession`.
|
|
96
100
|
*
|
|
97
101
|
* The wrapper:
|
|
98
|
-
* - Accepts a
|
|
99
|
-
* - Accepts
|
|
102
|
+
* - Accepts a `config` with at least a `name` (used for Temporal workflow naming)
|
|
103
|
+
* - Accepts a handler `fn` receiving `(input, sessionInput)`
|
|
100
104
|
* - Derives `threadId` + `continueThread` from `workflowInput.previousThreadId`
|
|
101
105
|
* - Derives `sandboxId` from `workflowInput.sandboxId`
|
|
102
106
|
*/
|
|
103
|
-
declare function defineWorkflow<TInput, TResult>(fn: (input: TInput, sessionInput: WorkflowSessionInput) => Promise<TResult>): (input: TInput, workflowInput?: WorkflowInput) => Promise<TResult>;
|
|
107
|
+
declare function defineWorkflow<TInput, TResult>(config: WorkflowConfig, fn: (input: TInput, sessionInput: WorkflowSessionInput) => Promise<TResult>): (input: TInput, workflowInput?: WorkflowInput) => Promise<TResult>;
|
|
104
108
|
|
|
105
109
|
/**
|
|
106
110
|
* Generate a compact, workflow-deterministic identifier.
|
|
@@ -580,4 +584,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
|
|
|
580
584
|
}[];
|
|
581
585
|
}>;
|
|
582
586
|
|
|
583
|
-
export { ActivityToolHandler, AgentStateManager, type AskUserQuestionArgs, BaseAgentState, type BashArgs, type FileEditArgs, FileEntry, FileEntryMetadata, type FileReadArgs, type FileWriteArgs, type GlobArgs, type GrepArgs, JsonSerializable, ParsedToolCallUnion, type ReadSkillArgs, RouterContext, SandboxOps, SessionConfig, Skill, SkillMetadata, type SubagentArgs, SubagentConfig, SubagentDefinition, SubagentHandlerResponse, SubagentHooks, SubagentSessionInput, type TaskCreateArgs, type TaskGetArgs, type TaskListArgs, type TaskUpdateArgs, ThreadOps, ToolHandler, ToolHandlerResponse, ToolMap, ToolNames, ToolRouter, ToolWithHandler, TreeMutation, VirtualFileTree, type WorkflowInput, type WorkflowSessionInput, WorkflowTask, ZeitlichSession, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, formatVirtualFileTree, getShortId, globTool, grepTool, hasNoOtherToolCalls, parseSkillFile, proxyDefaultThreadOps, proxySandboxOps, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
|
587
|
+
export { ActivityToolHandler, AgentStateManager, type AskUserQuestionArgs, BaseAgentState, type BashArgs, type FileEditArgs, FileEntry, FileEntryMetadata, type FileReadArgs, type FileWriteArgs, type GlobArgs, type GrepArgs, JsonSerializable, ParsedToolCallUnion, type ReadSkillArgs, RouterContext, SandboxOps, SessionConfig, Skill, SkillMetadata, type SubagentArgs, SubagentConfig, SubagentDefinition, SubagentHandlerResponse, SubagentHooks, SubagentSessionInput, type TaskCreateArgs, type TaskGetArgs, type TaskListArgs, type TaskUpdateArgs, ThreadOps, ToolHandler, ToolHandlerResponse, ToolMap, ToolNames, ToolRouter, ToolWithHandler, TreeMutation, VirtualFileTree, type WorkflowConfig, type WorkflowInput, type WorkflowSessionInput, WorkflowTask, ZeitlichSession, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, formatVirtualFileTree, getShortId, globTool, grepTool, hasNoOtherToolCalls, parseSkillFile, proxyDefaultThreadOps, proxySandboxOps, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
package/dist/workflow.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { proxyActivities } from '@temporalio/workflow';
|
|
2
|
-
import { k as SessionConfig, Z as ZeitlichSession, T as ThreadOps, f as JsonSerializable, e as AgentStateManager, q as SubagentDefinition, s as SubagentHooks, p as SubagentConfig, t as SubagentSessionInput, r as SubagentHandlerResponse, b as SkillMetadata, c as Skill } from './types-
|
|
3
|
-
export { A as AgentResponse, d as AgentState, H as Hooks, J as JsonPrimitive, g as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, P as PostHumanMessageAppendHook, h as PostHumanMessageAppendHookContext, i as PreHumanMessageAppendHook, j as PreHumanMessageAppendHookContext, R as RunAgentActivity, l as SessionEndHook, m as SessionEndHookContext, n as SessionStartHook, o as SessionStartHookContext, S as SkillProvider, u as SubagentWorkflow, v as SubagentWorkflowInput } from './types-
|
|
1
|
+
import { proxyActivities, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
2
|
+
import { k as SessionConfig, Z as ZeitlichSession, T as ThreadOps, f as JsonSerializable, e as AgentStateManager, q as SubagentDefinition, s as SubagentHooks, p as SubagentConfig, t as SubagentSessionInput, r as SubagentHandlerResponse, b as SkillMetadata, c as Skill } from './types-BkAYmc96.js';
|
|
3
|
+
export { A as AgentResponse, d as AgentState, H as Hooks, J as JsonPrimitive, g as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, P as PostHumanMessageAppendHook, h as PostHumanMessageAppendHookContext, i as PreHumanMessageAppendHook, j as PreHumanMessageAppendHookContext, R as RunAgentActivity, l as SessionEndHook, m as SessionEndHookContext, n as SessionStartHook, o as SessionStartHookContext, S as SkillProvider, u as SubagentWorkflow, v as SubagentWorkflowInput } from './types-BkAYmc96.js';
|
|
4
4
|
import { g as SandboxOps } from './types-BMRzfELQ.js';
|
|
5
5
|
export { h as ExecOptions, E as ExecResult, S as Sandbox, c as SandboxCapabilities, d as SandboxCreateOptions, e as SandboxCreateResult, D as SandboxDirentEntry, F as SandboxFileStat, a as SandboxFileSystem, i as SandboxNotFoundError, j as SandboxNotSupportedError, b as SandboxProvider, f as SandboxSnapshot } from './types-BMRzfELQ.js';
|
|
6
|
-
import { a as ToolMap, B as BaseAgentState, N as ToolRouterOptions, J as ToolRouter, R as RouterContext, K as ToolWithHandler, p as ParsedToolCallUnion, G as ToolNames, c as ToolHandlerResponse, E as ToolHandler, W as WorkflowTask, A as ActivityToolHandler } from './types-
|
|
7
|
-
export { l as AgentConfig, m as AgentFile, h as AgentStatus, n as AppendToolResultFn, C as ContentPart, I as InferToolResults, M as MessageContent, o as ParsedToolCall, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, d as PostToolUseFailureHookResult, s as PostToolUseHook, t as PostToolUseHookContext, u as PreToolUseHook, v as PreToolUseHookContext, P as PreToolUseHookResult, w as ProcessToolCallsContext, e as RawToolCall, g as RunAgentConfig, x as SerializableToolDefinition, S as SessionExitReason, y as TaskStatus, f as TokenUsage, z as ToolArgs, D as ToolCallResult, k as ToolCallResultUnion, i as ToolDefinition, F as ToolHooks, T as ToolMessageContent, H as ToolResult, j as ToolResultConfig, b as ToolRouterHooks, L as isTerminalStatus } from './types-
|
|
6
|
+
import { a as ToolMap, B as BaseAgentState, N as ToolRouterOptions, J as ToolRouter, R as RouterContext, K as ToolWithHandler, p as ParsedToolCallUnion, G as ToolNames, c as ToolHandlerResponse, E as ToolHandler, W as WorkflowTask, A as ActivityToolHandler } from './types-YbL7JpEA.js';
|
|
7
|
+
export { l as AgentConfig, m as AgentFile, h as AgentStatus, n as AppendToolResultFn, C as ContentPart, I as InferToolResults, M as MessageContent, o as ParsedToolCall, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, d as PostToolUseFailureHookResult, s as PostToolUseHook, t as PostToolUseHookContext, u as PreToolUseHook, v as PreToolUseHookContext, P as PreToolUseHookResult, w as ProcessToolCallsContext, e as RawToolCall, g as RunAgentConfig, x as SerializableToolDefinition, S as SessionExitReason, y as TaskStatus, f as TokenUsage, z as ToolArgs, D as ToolCallResult, k as ToolCallResultUnion, i as ToolDefinition, F as ToolHooks, T as ToolMessageContent, H as ToolResult, j as ToolResultConfig, b as ToolRouterHooks, L as isTerminalStatus } from './types-YbL7JpEA.js';
|
|
8
8
|
import z$1, { z } from 'zod';
|
|
9
|
-
import { F as FileEntryMetadata, f as VirtualFileTree, T as TreeMutation, c as FileEntry } from './queries-
|
|
10
|
-
export { a as FileResolver, h as VirtualSandboxState, i as filesWithMimeType, j as hasDirectory, k as hasFileWithMimeType } from './queries-
|
|
9
|
+
import { F as FileEntryMetadata, f as VirtualFileTree, T as TreeMutation, c as FileEntry } from './queries-6Avfh74U.js';
|
|
10
|
+
export { a as FileResolver, h as VirtualSandboxState, i as filesWithMimeType, j as hasDirectory, k as hasFileWithMimeType } from './queries-6Avfh74U.js';
|
|
11
11
|
import '@temporalio/common';
|
|
12
12
|
import '@temporalio/common/lib/interfaces';
|
|
13
13
|
|
|
@@ -56,7 +56,7 @@ declare const createSession: <T extends ToolMap, M = unknown>({ threadId: provid
|
|
|
56
56
|
* });
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
declare function proxyDefaultThreadOps(options?: Parameters<typeof proxyActivities>[0]): ThreadOps
|
|
59
|
+
declare function proxyDefaultThreadOps(options?: Parameters<typeof proxyActivities>[0]): ActivityInterfaceFor<ThreadOps>;
|
|
60
60
|
/**
|
|
61
61
|
* Proxy sandbox lifecycle operations as Temporal activities.
|
|
62
62
|
* Call this in workflow code when the agent needs a sandbox.
|
|
@@ -90,17 +90,21 @@ interface WorkflowInput {
|
|
|
90
90
|
/** Optional sandbox ID to reuse */
|
|
91
91
|
sandboxId?: string;
|
|
92
92
|
}
|
|
93
|
+
interface WorkflowConfig {
|
|
94
|
+
/** Workflow name — used as the Temporal workflow function name */
|
|
95
|
+
name: string;
|
|
96
|
+
}
|
|
93
97
|
/**
|
|
94
98
|
* Wraps a main workflow function, translating workflow input fields into
|
|
95
99
|
* session-compatible fields that can be spread directly into `createSession`.
|
|
96
100
|
*
|
|
97
101
|
* The wrapper:
|
|
98
|
-
* - Accepts a
|
|
99
|
-
* - Accepts
|
|
102
|
+
* - Accepts a `config` with at least a `name` (used for Temporal workflow naming)
|
|
103
|
+
* - Accepts a handler `fn` receiving `(input, sessionInput)`
|
|
100
104
|
* - Derives `threadId` + `continueThread` from `workflowInput.previousThreadId`
|
|
101
105
|
* - Derives `sandboxId` from `workflowInput.sandboxId`
|
|
102
106
|
*/
|
|
103
|
-
declare function defineWorkflow<TInput, TResult>(fn: (input: TInput, sessionInput: WorkflowSessionInput) => Promise<TResult>): (input: TInput, workflowInput?: WorkflowInput) => Promise<TResult>;
|
|
107
|
+
declare function defineWorkflow<TInput, TResult>(config: WorkflowConfig, fn: (input: TInput, sessionInput: WorkflowSessionInput) => Promise<TResult>): (input: TInput, workflowInput?: WorkflowInput) => Promise<TResult>;
|
|
104
108
|
|
|
105
109
|
/**
|
|
106
110
|
* Generate a compact, workflow-deterministic identifier.
|
|
@@ -580,4 +584,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
|
|
|
580
584
|
}[];
|
|
581
585
|
}>;
|
|
582
586
|
|
|
583
|
-
export { ActivityToolHandler, AgentStateManager, type AskUserQuestionArgs, BaseAgentState, type BashArgs, type FileEditArgs, FileEntry, FileEntryMetadata, type FileReadArgs, type FileWriteArgs, type GlobArgs, type GrepArgs, JsonSerializable, ParsedToolCallUnion, type ReadSkillArgs, RouterContext, SandboxOps, SessionConfig, Skill, SkillMetadata, type SubagentArgs, SubagentConfig, SubagentDefinition, SubagentHandlerResponse, SubagentHooks, SubagentSessionInput, type TaskCreateArgs, type TaskGetArgs, type TaskListArgs, type TaskUpdateArgs, ThreadOps, ToolHandler, ToolHandlerResponse, ToolMap, ToolNames, ToolRouter, ToolWithHandler, TreeMutation, VirtualFileTree, type WorkflowInput, type WorkflowSessionInput, WorkflowTask, ZeitlichSession, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, formatVirtualFileTree, getShortId, globTool, grepTool, hasNoOtherToolCalls, parseSkillFile, proxyDefaultThreadOps, proxySandboxOps, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
|
587
|
+
export { ActivityToolHandler, AgentStateManager, type AskUserQuestionArgs, BaseAgentState, type BashArgs, type FileEditArgs, FileEntry, FileEntryMetadata, type FileReadArgs, type FileWriteArgs, type GlobArgs, type GrepArgs, JsonSerializable, ParsedToolCallUnion, type ReadSkillArgs, RouterContext, SandboxOps, SessionConfig, Skill, SkillMetadata, type SubagentArgs, SubagentConfig, SubagentDefinition, SubagentHandlerResponse, SubagentHooks, SubagentSessionInput, type TaskCreateArgs, type TaskGetArgs, type TaskListArgs, type TaskUpdateArgs, ThreadOps, ToolHandler, ToolHandlerResponse, ToolMap, ToolNames, ToolRouter, ToolWithHandler, TreeMutation, VirtualFileTree, type WorkflowConfig, type WorkflowInput, type WorkflowSessionInput, WorkflowTask, ZeitlichSession, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, formatVirtualFileTree, getShortId, globTool, grepTool, hasNoOtherToolCalls, parseSkillFile, proxyDefaultThreadOps, proxySandboxOps, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
package/dist/workflow.js
CHANGED
|
@@ -51,7 +51,10 @@ function createToolRouter(options) {
|
|
|
51
51
|
turn
|
|
52
52
|
});
|
|
53
53
|
if (r?.fallbackContent !== void 0)
|
|
54
|
-
return {
|
|
54
|
+
return {
|
|
55
|
+
content: r.fallbackContent,
|
|
56
|
+
result: { error: errorStr, recovered: true }
|
|
57
|
+
};
|
|
55
58
|
if (r?.suppress)
|
|
56
59
|
return {
|
|
57
60
|
content: JSON.stringify({ error: errorStr, suppressed: true }),
|
|
@@ -66,7 +69,10 @@ function createToolRouter(options) {
|
|
|
66
69
|
turn
|
|
67
70
|
});
|
|
68
71
|
if (r?.fallbackContent !== void 0)
|
|
69
|
-
return {
|
|
72
|
+
return {
|
|
73
|
+
content: r.fallbackContent,
|
|
74
|
+
result: { error: errorStr, recovered: true }
|
|
75
|
+
};
|
|
70
76
|
if (r?.suppress)
|
|
71
77
|
return {
|
|
72
78
|
content: JSON.stringify({ error: errorStr, suppressed: true }),
|
|
@@ -100,11 +106,14 @@ function createToolRouter(options) {
|
|
|
100
106
|
const tool = toolMap.get(toolCall.name);
|
|
101
107
|
const preResult = await runPreHooks(toolCall, tool, turn);
|
|
102
108
|
if (preResult.skip) {
|
|
103
|
-
await appendToolResult({
|
|
109
|
+
await appendToolResult(uuid4(), {
|
|
104
110
|
threadId: options.threadId,
|
|
105
111
|
toolCallId: toolCall.id,
|
|
106
112
|
toolName: toolCall.name,
|
|
107
|
-
content: JSON.stringify({
|
|
113
|
+
content: JSON.stringify({
|
|
114
|
+
skipped: true,
|
|
115
|
+
reason: "Skipped by PreToolUse hook"
|
|
116
|
+
})
|
|
108
117
|
});
|
|
109
118
|
return null;
|
|
110
119
|
}
|
|
@@ -132,24 +141,43 @@ function createToolRouter(options) {
|
|
|
132
141
|
content = JSON.stringify(result, null, 2);
|
|
133
142
|
}
|
|
134
143
|
} catch (error) {
|
|
135
|
-
const recovery = await runFailureHooks(
|
|
144
|
+
const recovery = await runFailureHooks(
|
|
145
|
+
toolCall,
|
|
146
|
+
tool,
|
|
147
|
+
error,
|
|
148
|
+
effectiveArgs,
|
|
149
|
+
turn
|
|
150
|
+
);
|
|
136
151
|
result = recovery.result;
|
|
137
152
|
content = recovery.content;
|
|
138
153
|
}
|
|
139
154
|
if (!resultAppended) {
|
|
140
|
-
|
|
155
|
+
const config = {
|
|
141
156
|
threadId: options.threadId,
|
|
142
157
|
toolCallId: toolCall.id,
|
|
143
158
|
toolName: toolCall.name,
|
|
144
159
|
content
|
|
145
|
-
}
|
|
160
|
+
};
|
|
161
|
+
await appendToolResult.executeWithOptions(
|
|
162
|
+
{
|
|
163
|
+
summary: `Append ${toolCall.name} result`
|
|
164
|
+
},
|
|
165
|
+
[uuid4(), config]
|
|
166
|
+
);
|
|
146
167
|
}
|
|
147
168
|
const toolResult = {
|
|
148
169
|
toolCallId: toolCall.id,
|
|
149
170
|
name: toolCall.name,
|
|
150
171
|
data: result
|
|
151
172
|
};
|
|
152
|
-
await runPostHooks(
|
|
173
|
+
await runPostHooks(
|
|
174
|
+
toolCall,
|
|
175
|
+
tool,
|
|
176
|
+
toolResult,
|
|
177
|
+
effectiveArgs,
|
|
178
|
+
turn,
|
|
179
|
+
Date.now() - startTime
|
|
180
|
+
);
|
|
153
181
|
return toolResult;
|
|
154
182
|
}
|
|
155
183
|
return {
|
|
@@ -192,9 +220,7 @@ function createToolRouter(options) {
|
|
|
192
220
|
const sandboxId = context?.sandboxId;
|
|
193
221
|
if (options.parallel) {
|
|
194
222
|
const results2 = await Promise.all(
|
|
195
|
-
toolCalls.map(
|
|
196
|
-
(tc) => processToolCall(tc, turn, sandboxId)
|
|
197
|
-
)
|
|
223
|
+
toolCalls.map((tc) => processToolCall(tc, turn, sandboxId))
|
|
198
224
|
);
|
|
199
225
|
return results2.filter(
|
|
200
226
|
(r) => r !== null
|
|
@@ -202,11 +228,7 @@ function createToolRouter(options) {
|
|
|
202
228
|
}
|
|
203
229
|
const results = [];
|
|
204
230
|
for (const toolCall of toolCalls) {
|
|
205
|
-
const result = await processToolCall(
|
|
206
|
-
toolCall,
|
|
207
|
-
turn,
|
|
208
|
-
sandboxId
|
|
209
|
-
);
|
|
231
|
+
const result = await processToolCall(toolCall, turn, sandboxId);
|
|
210
232
|
if (result !== null) {
|
|
211
233
|
results.push(result);
|
|
212
234
|
}
|
|
@@ -223,19 +245,29 @@ function createToolRouter(options) {
|
|
|
223
245
|
threadId: options.threadId,
|
|
224
246
|
toolCallId: toolCall.id,
|
|
225
247
|
toolName: toolCall.name,
|
|
226
|
-
...context?.sandboxId !== void 0 && {
|
|
248
|
+
...context?.sandboxId !== void 0 && {
|
|
249
|
+
sandboxId: context.sandboxId
|
|
250
|
+
}
|
|
227
251
|
};
|
|
228
252
|
const response = await handler(
|
|
229
253
|
toolCall.args,
|
|
230
254
|
routerContext
|
|
231
255
|
);
|
|
232
256
|
if (!response.resultAppended) {
|
|
233
|
-
await appendToolResult(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
257
|
+
await appendToolResult.executeWithOptions(
|
|
258
|
+
{
|
|
259
|
+
summary: `Append ${toolCall.name} result`
|
|
260
|
+
},
|
|
261
|
+
[
|
|
262
|
+
uuid4(),
|
|
263
|
+
{
|
|
264
|
+
threadId: options.threadId,
|
|
265
|
+
toolCallId: toolCall.id,
|
|
266
|
+
toolName: toolCall.name,
|
|
267
|
+
content: response.toolResponse
|
|
268
|
+
}
|
|
269
|
+
]
|
|
270
|
+
);
|
|
239
271
|
}
|
|
240
272
|
return {
|
|
241
273
|
toolCallId: toolCall.id,
|
|
@@ -310,7 +342,7 @@ function createSubagentTool(subagents) {
|
|
|
310
342
|
const schema = hasThreadContinuation ? z14.object({
|
|
311
343
|
...baseFields,
|
|
312
344
|
threadId: z14.string().nullable().describe(
|
|
313
|
-
"Thread ID to continue an existing conversation, or null to start a new one"
|
|
345
|
+
"Thread ID to continue an existing conversation from the same subagent, or null to start a new one"
|
|
314
346
|
)
|
|
315
347
|
}) : z14.object(baseFields);
|
|
316
348
|
return {
|
|
@@ -367,7 +399,7 @@ function createSubagentHandler(subagents) {
|
|
|
367
399
|
if (config.allowThreadContinuation && childThreadId) {
|
|
368
400
|
finalToolResponse = typeof toolResponse === "string" ? `${toolResponse}
|
|
369
401
|
|
|
370
|
-
[Thread ID: ${childThreadId}]` : toolResponse;
|
|
402
|
+
[${config.agentName} Thread ID: ${childThreadId}]` : toolResponse;
|
|
371
403
|
}
|
|
372
404
|
return {
|
|
373
405
|
toolResponse: finalToolResponse,
|
|
@@ -463,8 +495,6 @@ function buildSkillRegistration(skills) {
|
|
|
463
495
|
handler: createReadSkillHandler(skills)
|
|
464
496
|
};
|
|
465
497
|
}
|
|
466
|
-
|
|
467
|
-
// src/lib/session/session.ts
|
|
468
498
|
var createSession = async ({
|
|
469
499
|
threadId: providedThreadId,
|
|
470
500
|
agentName,
|
|
@@ -534,7 +564,7 @@ var createSession = async ({
|
|
|
534
564
|
threadId
|
|
535
565
|
});
|
|
536
566
|
}
|
|
537
|
-
await appendHumanMessage(threadId, message);
|
|
567
|
+
await appendHumanMessage(threadId, uuid4(), message);
|
|
538
568
|
if (hooks.onPostHumanMessageAppend) {
|
|
539
569
|
await hooks.onPostHumanMessageAppend({
|
|
540
570
|
message,
|
|
@@ -571,12 +601,12 @@ var createSession = async ({
|
|
|
571
601
|
nonRetryable: true
|
|
572
602
|
});
|
|
573
603
|
}
|
|
574
|
-
await appendSystemMessage(threadId, systemPrompt);
|
|
604
|
+
await appendSystemMessage(threadId, uuid4(), systemPrompt);
|
|
575
605
|
} else {
|
|
576
606
|
await initializeThread(threadId);
|
|
577
607
|
}
|
|
578
608
|
}
|
|
579
|
-
await appendHumanMessage(threadId, await buildContextMessage());
|
|
609
|
+
await appendHumanMessage(threadId, uuid4(), await buildContextMessage());
|
|
580
610
|
let exitReason = "completed";
|
|
581
611
|
try {
|
|
582
612
|
while (stateManager.isRunning() && !stateManager.isTerminal() && stateManager.getTurns() < maxTurns) {
|
|
@@ -606,7 +636,7 @@ var createSession = async ({
|
|
|
606
636
|
try {
|
|
607
637
|
parsedToolCalls.push(toolRouter.parseToolCall(tc));
|
|
608
638
|
} catch (error) {
|
|
609
|
-
await appendToolResult({
|
|
639
|
+
await appendToolResult(uuid4(), {
|
|
610
640
|
threadId,
|
|
611
641
|
toolCallId: tc.id ?? "",
|
|
612
642
|
toolName: tc.name,
|
|
@@ -690,8 +720,8 @@ function proxySandboxOps(options) {
|
|
|
690
720
|
}
|
|
691
721
|
|
|
692
722
|
// src/lib/workflow.ts
|
|
693
|
-
function defineWorkflow(fn) {
|
|
694
|
-
|
|
723
|
+
function defineWorkflow(config, fn) {
|
|
724
|
+
const workflow = async (input, workflowInput = {}) => {
|
|
695
725
|
const sessionInput = {
|
|
696
726
|
...workflowInput.previousThreadId && {
|
|
697
727
|
threadId: workflowInput.previousThreadId,
|
|
@@ -701,6 +731,8 @@ function defineWorkflow(fn) {
|
|
|
701
731
|
};
|
|
702
732
|
return fn(input, sessionInput);
|
|
703
733
|
};
|
|
734
|
+
Object.defineProperty(workflow, "name", { value: config.name });
|
|
735
|
+
return workflow;
|
|
704
736
|
}
|
|
705
737
|
|
|
706
738
|
// src/lib/types.ts
|
|
@@ -1267,10 +1299,12 @@ var taskCreateTool = {
|
|
|
1267
1299
|
metadata: z14.record(z14.string(), z14.string()).describe("Arbitrary key-value pairs for tracking")
|
|
1268
1300
|
})
|
|
1269
1301
|
};
|
|
1302
|
+
|
|
1303
|
+
// src/tools/task-create/handler.ts
|
|
1270
1304
|
function createTaskCreateHandler(stateManager) {
|
|
1271
1305
|
return (args) => {
|
|
1272
1306
|
const task = {
|
|
1273
|
-
id:
|
|
1307
|
+
id: getShortId(),
|
|
1274
1308
|
subject: args.subject,
|
|
1275
1309
|
description: args.description,
|
|
1276
1310
|
activeForm: args.activeForm,
|