zeitlich 0.2.18 → 0.2.20
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 +0 -2
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +2 -2
- package/dist/adapters/thread/google-genai/index.d.ts +2 -2
- package/dist/adapters/thread/google-genai/index.js +0 -2
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/langchain/index.cjs +3 -1
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +3 -3
- package/dist/adapters/thread/langchain/index.d.ts +3 -3
- package/dist/adapters/thread/langchain/index.js +3 -1
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/index.cjs +153 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +153 -123
- package/dist/index.js.map +1 -1
- package/dist/{queries-TwukRZ8b.d.ts → queries-KHj5Otv7.d.ts} +1 -1
- package/dist/{queries-DnX72m_Y.d.cts → queries-nIdzTCDS.d.cts} +1 -1
- package/dist/{types-CdB2D5Sq.d.ts → types-By80IE1x.d.ts} +3 -3
- package/dist/{types-CmOSypVk.d.ts → types-Ct2igz9y.d.cts} +6 -4
- package/dist/{types-CmOSypVk.d.cts → types-Ct2igz9y.d.ts} +6 -4
- package/dist/{types-DRvq2miV.d.cts → types-DZ7BkA3-.d.cts} +3 -3
- package/dist/workflow.cjs +70 -40
- 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 +70 -40
- 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/langchain/thread-manager.ts +11 -7
- 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 +2 -1
- package/src/lib/session/types.ts +2 -1
- package/src/lib/subagent/handler.ts +1 -1
- package/src/lib/subagent/register.ts +3 -9
- package/src/lib/subagent/subagent.integration.test.ts +10 -9
- package/src/lib/subagent/tool.ts +1 -1
- package/src/lib/thread/index.ts +0 -1
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +8 -3
- package/src/lib/tool-router/router.integration.test.ts +8 -3
- package/src/lib/tool-router/router.ts +61 -31
- package/src/lib/tool-router/types.ts +14 -9
- 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-DZ7BkA3-.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-DZ7BkA3-.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-Ct2igz9y.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-Ct2igz9y.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-nIdzTCDS.cjs';
|
|
10
|
+
export { a as FileResolver, h as VirtualSandboxState, i as filesWithMimeType, j as hasDirectory, k as hasFileWithMimeType } from './queries-nIdzTCDS.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-By80IE1x.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-By80IE1x.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-Ct2igz9y.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-Ct2igz9y.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-KHj5Otv7.js';
|
|
10
|
+
export { a as FileResolver, h as VirtualSandboxState, i as filesWithMimeType, j as hasDirectory, k as hasFileWithMimeType } from './queries-KHj5Otv7.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
|
@@ -9,7 +9,8 @@ function createToolRouter(options) {
|
|
|
9
9
|
for (const [_key, tool] of Object.entries(options.tools)) {
|
|
10
10
|
toolMap.set(tool.name, tool);
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const resolve = (v) => typeof v === "function" ? v() : v;
|
|
13
|
+
const isEnabled = (tool) => resolve(tool.enabled) ?? true;
|
|
13
14
|
if (options.plugins) {
|
|
14
15
|
for (const plugin of options.plugins) {
|
|
15
16
|
toolMap.set(plugin.name, plugin);
|
|
@@ -50,7 +51,10 @@ function createToolRouter(options) {
|
|
|
50
51
|
turn
|
|
51
52
|
});
|
|
52
53
|
if (r?.fallbackContent !== void 0)
|
|
53
|
-
return {
|
|
54
|
+
return {
|
|
55
|
+
content: r.fallbackContent,
|
|
56
|
+
result: { error: errorStr, recovered: true }
|
|
57
|
+
};
|
|
54
58
|
if (r?.suppress)
|
|
55
59
|
return {
|
|
56
60
|
content: JSON.stringify({ error: errorStr, suppressed: true }),
|
|
@@ -65,7 +69,10 @@ function createToolRouter(options) {
|
|
|
65
69
|
turn
|
|
66
70
|
});
|
|
67
71
|
if (r?.fallbackContent !== void 0)
|
|
68
|
-
return {
|
|
72
|
+
return {
|
|
73
|
+
content: r.fallbackContent,
|
|
74
|
+
result: { error: errorStr, recovered: true }
|
|
75
|
+
};
|
|
69
76
|
if (r?.suppress)
|
|
70
77
|
return {
|
|
71
78
|
content: JSON.stringify({ error: errorStr, suppressed: true }),
|
|
@@ -103,7 +110,10 @@ function createToolRouter(options) {
|
|
|
103
110
|
threadId: options.threadId,
|
|
104
111
|
toolCallId: toolCall.id,
|
|
105
112
|
toolName: toolCall.name,
|
|
106
|
-
content: JSON.stringify({
|
|
113
|
+
content: JSON.stringify({
|
|
114
|
+
skipped: true,
|
|
115
|
+
reason: "Skipped by PreToolUse hook"
|
|
116
|
+
})
|
|
107
117
|
});
|
|
108
118
|
return null;
|
|
109
119
|
}
|
|
@@ -131,24 +141,43 @@ function createToolRouter(options) {
|
|
|
131
141
|
content = JSON.stringify(result, null, 2);
|
|
132
142
|
}
|
|
133
143
|
} catch (error) {
|
|
134
|
-
const recovery = await runFailureHooks(
|
|
144
|
+
const recovery = await runFailureHooks(
|
|
145
|
+
toolCall,
|
|
146
|
+
tool,
|
|
147
|
+
error,
|
|
148
|
+
effectiveArgs,
|
|
149
|
+
turn
|
|
150
|
+
);
|
|
135
151
|
result = recovery.result;
|
|
136
152
|
content = recovery.content;
|
|
137
153
|
}
|
|
138
154
|
if (!resultAppended) {
|
|
139
|
-
|
|
155
|
+
const config = {
|
|
140
156
|
threadId: options.threadId,
|
|
141
157
|
toolCallId: toolCall.id,
|
|
142
158
|
toolName: toolCall.name,
|
|
143
159
|
content
|
|
144
|
-
}
|
|
160
|
+
};
|
|
161
|
+
await appendToolResult.executeWithOptions(
|
|
162
|
+
{
|
|
163
|
+
summary: `Append ${toolCall.name} result`
|
|
164
|
+
},
|
|
165
|
+
[config]
|
|
166
|
+
);
|
|
145
167
|
}
|
|
146
168
|
const toolResult = {
|
|
147
169
|
toolCallId: toolCall.id,
|
|
148
170
|
name: toolCall.name,
|
|
149
171
|
data: result
|
|
150
172
|
};
|
|
151
|
-
await runPostHooks(
|
|
173
|
+
await runPostHooks(
|
|
174
|
+
toolCall,
|
|
175
|
+
tool,
|
|
176
|
+
toolResult,
|
|
177
|
+
effectiveArgs,
|
|
178
|
+
turn,
|
|
179
|
+
Date.now() - startTime
|
|
180
|
+
);
|
|
152
181
|
return toolResult;
|
|
153
182
|
}
|
|
154
183
|
return {
|
|
@@ -160,7 +189,7 @@ function createToolRouter(options) {
|
|
|
160
189
|
if (!tool || !isEnabled(tool)) {
|
|
161
190
|
throw new Error(`Tool ${toolCall.name} not found`);
|
|
162
191
|
}
|
|
163
|
-
const parsedArgs = tool.schema.parse(toolCall.args);
|
|
192
|
+
const parsedArgs = resolve(tool.schema).parse(toolCall.args);
|
|
164
193
|
return {
|
|
165
194
|
id: toolCall.id ?? "",
|
|
166
195
|
name: toolCall.name,
|
|
@@ -177,8 +206,8 @@ function createToolRouter(options) {
|
|
|
177
206
|
getToolDefinitions() {
|
|
178
207
|
return Array.from(toolMap).filter(([, tool]) => isEnabled(tool)).map(([name, tool]) => ({
|
|
179
208
|
name,
|
|
180
|
-
description: tool.description,
|
|
181
|
-
schema: tool.schema,
|
|
209
|
+
description: resolve(tool.description),
|
|
210
|
+
schema: resolve(tool.schema),
|
|
182
211
|
strict: tool.strict,
|
|
183
212
|
max_uses: tool.max_uses
|
|
184
213
|
}));
|
|
@@ -191,9 +220,7 @@ function createToolRouter(options) {
|
|
|
191
220
|
const sandboxId = context?.sandboxId;
|
|
192
221
|
if (options.parallel) {
|
|
193
222
|
const results2 = await Promise.all(
|
|
194
|
-
toolCalls.map(
|
|
195
|
-
(tc) => processToolCall(tc, turn, sandboxId)
|
|
196
|
-
)
|
|
223
|
+
toolCalls.map((tc) => processToolCall(tc, turn, sandboxId))
|
|
197
224
|
);
|
|
198
225
|
return results2.filter(
|
|
199
226
|
(r) => r !== null
|
|
@@ -201,11 +228,7 @@ function createToolRouter(options) {
|
|
|
201
228
|
}
|
|
202
229
|
const results = [];
|
|
203
230
|
for (const toolCall of toolCalls) {
|
|
204
|
-
const result = await processToolCall(
|
|
205
|
-
toolCall,
|
|
206
|
-
turn,
|
|
207
|
-
sandboxId
|
|
208
|
-
);
|
|
231
|
+
const result = await processToolCall(toolCall, turn, sandboxId);
|
|
209
232
|
if (result !== null) {
|
|
210
233
|
results.push(result);
|
|
211
234
|
}
|
|
@@ -222,19 +245,28 @@ function createToolRouter(options) {
|
|
|
222
245
|
threadId: options.threadId,
|
|
223
246
|
toolCallId: toolCall.id,
|
|
224
247
|
toolName: toolCall.name,
|
|
225
|
-
...context?.sandboxId !== void 0 && {
|
|
248
|
+
...context?.sandboxId !== void 0 && {
|
|
249
|
+
sandboxId: context.sandboxId
|
|
250
|
+
}
|
|
226
251
|
};
|
|
227
252
|
const response = await handler(
|
|
228
253
|
toolCall.args,
|
|
229
254
|
routerContext
|
|
230
255
|
);
|
|
231
256
|
if (!response.resultAppended) {
|
|
232
|
-
await appendToolResult(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
257
|
+
await appendToolResult.executeWithOptions(
|
|
258
|
+
{
|
|
259
|
+
summary: `Append ${toolCall.name} result`
|
|
260
|
+
},
|
|
261
|
+
[
|
|
262
|
+
{
|
|
263
|
+
threadId: options.threadId,
|
|
264
|
+
toolCallId: toolCall.id,
|
|
265
|
+
toolName: toolCall.name,
|
|
266
|
+
content: response.toolResponse
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
);
|
|
238
270
|
}
|
|
239
271
|
return {
|
|
240
272
|
toolCallId: toolCall.id,
|
|
@@ -309,7 +341,7 @@ function createSubagentTool(subagents) {
|
|
|
309
341
|
const schema = hasThreadContinuation ? z14.object({
|
|
310
342
|
...baseFields,
|
|
311
343
|
threadId: z14.string().nullable().describe(
|
|
312
|
-
"Thread ID to continue an existing conversation, or null to start a new one"
|
|
344
|
+
"Thread ID to continue an existing conversation from the same subagent, or null to start a new one"
|
|
313
345
|
)
|
|
314
346
|
}) : z14.object(baseFields);
|
|
315
347
|
return {
|
|
@@ -366,7 +398,7 @@ function createSubagentHandler(subagents) {
|
|
|
366
398
|
if (config.allowThreadContinuation && childThreadId) {
|
|
367
399
|
finalToolResponse = typeof toolResponse === "string" ? `${toolResponse}
|
|
368
400
|
|
|
369
|
-
[Thread ID: ${childThreadId}]` : toolResponse;
|
|
401
|
+
[${config.agentName} Thread ID: ${childThreadId}]` : toolResponse;
|
|
370
402
|
}
|
|
371
403
|
return {
|
|
372
404
|
toolResponse: finalToolResponse,
|
|
@@ -389,15 +421,9 @@ function buildSubagentRegistration(subagents) {
|
|
|
389
421
|
const resolveSubagentName = (args) => args.subagent;
|
|
390
422
|
return {
|
|
391
423
|
name: SUBAGENT_TOOL_NAME,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
get description() {
|
|
396
|
-
return createSubagentTool(getEnabled()).description;
|
|
397
|
-
},
|
|
398
|
-
get schema() {
|
|
399
|
-
return createSubagentTool(getEnabled()).schema;
|
|
400
|
-
},
|
|
424
|
+
enabled: () => getEnabled().length > 0,
|
|
425
|
+
description: () => createSubagentTool(getEnabled()).description,
|
|
426
|
+
schema: () => createSubagentTool(getEnabled()).schema,
|
|
401
427
|
handler: createSubagentHandler(subagents),
|
|
402
428
|
...subagentHooksMap.size > 0 && {
|
|
403
429
|
hooks: {
|
|
@@ -695,8 +721,8 @@ function proxySandboxOps(options) {
|
|
|
695
721
|
}
|
|
696
722
|
|
|
697
723
|
// src/lib/workflow.ts
|
|
698
|
-
function defineWorkflow(fn) {
|
|
699
|
-
|
|
724
|
+
function defineWorkflow(config, fn) {
|
|
725
|
+
const workflow = async (input, workflowInput = {}) => {
|
|
700
726
|
const sessionInput = {
|
|
701
727
|
...workflowInput.previousThreadId && {
|
|
702
728
|
threadId: workflowInput.previousThreadId,
|
|
@@ -706,6 +732,8 @@ function defineWorkflow(fn) {
|
|
|
706
732
|
};
|
|
707
733
|
return fn(input, sessionInput);
|
|
708
734
|
};
|
|
735
|
+
Object.defineProperty(workflow, "name", { value: config.name });
|
|
736
|
+
return workflow;
|
|
709
737
|
}
|
|
710
738
|
|
|
711
739
|
// src/lib/types.ts
|
|
@@ -1272,10 +1300,12 @@ var taskCreateTool = {
|
|
|
1272
1300
|
metadata: z14.record(z14.string(), z14.string()).describe("Arbitrary key-value pairs for tracking")
|
|
1273
1301
|
})
|
|
1274
1302
|
};
|
|
1303
|
+
|
|
1304
|
+
// src/tools/task-create/handler.ts
|
|
1275
1305
|
function createTaskCreateHandler(stateManager) {
|
|
1276
1306
|
return (args) => {
|
|
1277
1307
|
const task = {
|
|
1278
|
-
id:
|
|
1308
|
+
id: getShortId(),
|
|
1279
1309
|
subject: args.subject,
|
|
1280
1310
|
description: args.description,
|
|
1281
1311
|
activeForm: args.activeForm,
|