zeitlich 0.2.25 → 0.2.27
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/activities-DE3_q9yq.d.ts +140 -0
- package/dist/activities-p8PDlRIK.d.cts +140 -0
- package/dist/adapters/sandbox/virtual/index.cjs.map +1 -1
- package/dist/adapters/sandbox/virtual/index.d.cts +8 -7
- package/dist/adapters/sandbox/virtual/index.d.ts +8 -7
- package/dist/adapters/sandbox/virtual/index.js.map +1 -1
- package/dist/adapters/sandbox/virtual/workflow.d.cts +3 -2
- package/dist/adapters/sandbox/virtual/workflow.d.ts +3 -2
- package/dist/adapters/thread/anthropic/index.cjs +363 -0
- package/dist/adapters/thread/anthropic/index.cjs.map +1 -0
- package/dist/adapters/thread/anthropic/index.d.cts +151 -0
- package/dist/adapters/thread/anthropic/index.d.ts +151 -0
- package/dist/adapters/thread/anthropic/index.js +358 -0
- package/dist/adapters/thread/anthropic/index.js.map +1 -0
- package/dist/adapters/thread/anthropic/workflow.cjs +38 -0
- package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -0
- package/dist/adapters/thread/anthropic/workflow.d.cts +37 -0
- package/dist/adapters/thread/anthropic/workflow.d.ts +37 -0
- package/dist/adapters/thread/anthropic/workflow.js +36 -0
- package/dist/adapters/thread/anthropic/workflow.js.map +1 -0
- package/dist/adapters/thread/google-genai/index.cjs +102 -99
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +14 -113
- package/dist/adapters/thread/google-genai/index.d.ts +14 -113
- package/dist/adapters/thread/google-genai/index.js +103 -99
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.cjs +9 -4
- package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.d.cts +10 -5
- package/dist/adapters/thread/google-genai/workflow.d.ts +10 -5
- package/dist/adapters/thread/google-genai/workflow.js +9 -4
- package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
- package/dist/adapters/thread/langchain/index.cjs +73 -63
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +39 -40
- package/dist/adapters/thread/langchain/index.d.ts +39 -40
- package/dist/adapters/thread/langchain/index.js +73 -64
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/adapters/thread/langchain/workflow.cjs +9 -4
- package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
- package/dist/adapters/thread/langchain/workflow.d.cts +10 -5
- package/dist/adapters/thread/langchain/workflow.d.ts +10 -5
- package/dist/adapters/thread/langchain/workflow.js +9 -4
- package/dist/adapters/thread/langchain/workflow.js.map +1 -1
- package/dist/index.cjs +27 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +28 -11
- package/dist/index.js.map +1 -1
- package/dist/proxy-BK1ydQt0.d.ts +24 -0
- package/dist/proxy-BMAsMHdp.d.cts +24 -0
- package/dist/{queries-DwBe2CAA.d.ts → queries-BCgJ9Sr5.d.ts} +1 -1
- package/dist/{queries-BYGBImeC.d.cts → queries-DwnE2bu3.d.cts} +1 -1
- package/dist/thread-manager-Bh9x847n.d.ts +31 -0
- package/dist/thread-manager-BlHua5_v.d.cts +39 -0
- package/dist/thread-manager-Bz8txKKj.d.cts +31 -0
- package/dist/thread-manager-dzaJHQEA.d.ts +39 -0
- package/dist/types-BfIQABzu.d.cts +73 -0
- package/dist/types-CIkYBoF8.d.ts +73 -0
- package/dist/{types-hmferhc2.d.ts → types-CvJyXDYt.d.ts} +44 -123
- package/dist/{types-LVKmCNds.d.ts → types-DFUNSYbj.d.ts} +1 -1
- package/dist/{types-Bf8KV0Ci.d.cts → types-DRnz-OZp.d.cts} +1 -1
- package/dist/{types-7PeMi1bD.d.cts → types-DSOefLpY.d.cts} +44 -123
- package/dist/{types-D_igp10o.d.cts → types-mCVxKIZb.d.cts} +233 -137
- package/dist/{types-D_igp10o.d.ts → types-mCVxKIZb.d.ts} +233 -137
- package/dist/workflow.cjs +25 -9
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +11 -11
- package/dist/workflow.d.ts +11 -11
- package/dist/workflow.js +26 -10
- package/dist/workflow.js.map +1 -1
- package/package.json +26 -1
- package/src/adapters/sandbox/virtual/with-virtual-sandbox.ts +8 -3
- package/src/adapters/thread/anthropic/activities.ts +226 -0
- package/src/adapters/thread/anthropic/index.ts +44 -0
- package/src/adapters/thread/anthropic/model-invoker.ts +129 -0
- package/src/adapters/thread/anthropic/proxy.ts +33 -0
- package/src/adapters/thread/anthropic/thread-manager.test.ts +137 -0
- package/src/adapters/thread/anthropic/thread-manager.ts +202 -0
- package/src/adapters/thread/google-genai/activities.ts +110 -33
- package/src/adapters/thread/google-genai/index.ts +3 -1
- package/src/adapters/thread/google-genai/model-invoker.ts +13 -42
- package/src/adapters/thread/google-genai/proxy.ts +6 -34
- package/src/adapters/thread/google-genai/thread-manager.test.ts +159 -0
- package/src/adapters/thread/google-genai/thread-manager.ts +96 -105
- package/src/adapters/thread/langchain/activities.ts +56 -21
- package/src/adapters/thread/langchain/hooks.ts +37 -0
- package/src/adapters/thread/langchain/index.ts +6 -1
- package/src/adapters/thread/langchain/model-invoker.ts +13 -12
- package/src/adapters/thread/langchain/proxy.ts +6 -34
- package/src/adapters/thread/langchain/thread-manager.test.ts +144 -0
- package/src/adapters/thread/langchain/thread-manager.ts +55 -98
- package/src/index.ts +5 -1
- package/src/lib/activity.ts +4 -3
- package/src/lib/hooks/types.ts +12 -12
- package/src/lib/model/types.ts +2 -0
- package/src/lib/session/session-edge-cases.integration.test.ts +24 -6
- package/src/lib/session/session.ts +18 -14
- package/src/lib/session/types.ts +31 -14
- package/src/lib/subagent/handler.ts +15 -8
- package/src/lib/subagent/types.ts +3 -2
- package/src/lib/thread/index.ts +3 -0
- package/src/lib/thread/manager.ts +4 -7
- package/src/lib/thread/proxy.ts +57 -0
- package/src/lib/thread/types.ts +44 -0
- package/src/lib/tool-router/auto-append-sandbox.integration.test.ts +54 -0
- package/src/lib/tool-router/auto-append.ts +5 -2
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +9 -5
- package/src/lib/tool-router/router.ts +13 -7
- package/src/lib/tool-router/types.ts +20 -13
- package/src/lib/tool-router/with-sandbox.ts +4 -3
- package/src/lib/types.ts +7 -14
- package/src/workflow.ts +0 -4
- package/tsup.config.ts +5 -0
- package/dist/types-35POpVfa.d.cts +0 -40
- package/dist/types-35POpVfa.d.ts +0 -40
package/dist/workflow.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AgentResponse,
|
|
1
|
+
import { k as SessionConfig, Z as ZeitlichSession, j as SandboxShutdown, B as ThreadInit, i as SandboxInit, r as SubagentDefinition, u as SubagentHooks, v as SubagentSandboxConfig, q as SubagentConfig, w as SubagentSandboxShutdown, x as SubagentSessionInput, s as SubagentFnResult, c as SkillMetadata, d as Skill } from './types-DSOefLpY.cjs';
|
|
2
|
+
export { A as AgentResponse, H as Hooks, a as ModelInvoker, M as ModelInvokerConfig, e as PostHumanMessageAppendHook, f as PostHumanMessageAppendHookContext, g as PreHumanMessageAppendHook, h as PreHumanMessageAppendHookContext, P as PrefixedThreadOps, R as RunAgentActivity, S as ScopedPrefix, l as SessionEndHook, m as SessionEndHookContext, n as SessionResult, o as SessionStartHook, p as SessionStartHookContext, b as SkillProvider, t as SubagentHandlerResponse, y as SubagentWorkflow, z as SubagentWorkflowInput, T as ThreadOps } from './types-DSOefLpY.cjs';
|
|
3
3
|
import { g as SandboxOps } from './types-ChAMwU3q.cjs';
|
|
4
4
|
export { h as ExecOptions, E as ExecResult, P as PrefixedSandboxOps, 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-ChAMwU3q.cjs';
|
|
5
|
-
import { a as ToolMap, B as BaseAgentState,
|
|
6
|
-
export {
|
|
5
|
+
import { a as ToolMap, i as JsonSerializable, B as BaseAgentState, j as AgentStateManager, Q as ToolRouterOptions, M as ToolRouter, R as RouterContext, J as JsonValue, N as ToolWithHandler, r as ParsedToolCallUnion, K as ToolNames, T as ToolHandlerResponse, G as ToolHandler, W as WorkflowTask, A as ActivityToolHandler } from './types-mCVxKIZb.cjs';
|
|
6
|
+
export { k as AgentConfig, l as AgentFile, m as AgentState, n as AgentStatus, o as AppendToolResultFn, I as InferToolResults, p as JsonPrimitive, q as ParsedToolCall, s as PostToolUseFailureHook, t as PostToolUseFailureHookContext, c as PostToolUseFailureHookResult, u as PostToolUseHook, v as PostToolUseHookContext, w as PreToolUseHook, x as PreToolUseHookContext, P as PreToolUseHookResult, y as ProcessToolCallsContext, d as RawToolCall, f as RunAgentConfig, z as SerializableToolDefinition, S as SessionExitReason, C as TaskStatus, e as TokenUsage, D as ToolArgs, E as ToolCallResult, h as ToolCallResultUnion, F as ToolDefinition, H as ToolHooks, L as ToolResult, g as ToolResultConfig, b as ToolRouterHooks, O as isTerminalStatus } from './types-mCVxKIZb.cjs';
|
|
7
7
|
import z$1, { z } from 'zod';
|
|
8
|
-
import { a as FileEntryMetadata, e as VirtualFileTree, T as TreeMutation, F as FileEntry } from './types-
|
|
9
|
-
export { b as FileResolver, g as VirtualSandboxState } from './types-
|
|
10
|
-
export { f as filesWithMimeType, h as hasDirectory, a as hasFileWithMimeType } from './queries-
|
|
8
|
+
import { a as FileEntryMetadata, e as VirtualFileTree, T as TreeMutation, F as FileEntry } from './types-DRnz-OZp.cjs';
|
|
9
|
+
export { b as FileResolver, g as VirtualSandboxState } from './types-DRnz-OZp.cjs';
|
|
10
|
+
export { f as filesWithMimeType, h as hasDirectory, a as hasFileWithMimeType } from './queries-DwnE2bu3.cjs';
|
|
11
11
|
import '@temporalio/common';
|
|
12
12
|
import '@temporalio/workflow';
|
|
13
13
|
import '@temporalio/common/lib/interfaces';
|
|
@@ -43,10 +43,10 @@ import '@temporalio/common/lib/interfaces';
|
|
|
43
43
|
* const { finalMessage, exitReason } = await session.runSession({ stateManager });
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
declare function createSession<T extends ToolMap, M = unknown>(config: SessionConfig<T, M> & {
|
|
46
|
+
declare function createSession<T extends ToolMap, M = unknown, TContent = string>(config: SessionConfig<T, M, TContent> & {
|
|
47
47
|
sandboxOps: SandboxOps;
|
|
48
48
|
}): Promise<ZeitlichSession<M, true>>;
|
|
49
|
-
declare function createSession<T extends ToolMap, M = unknown>(config: SessionConfig<T, M>): Promise<ZeitlichSession<M, false>>;
|
|
49
|
+
declare function createSession<T extends ToolMap, M = unknown, TContent = string>(config: SessionConfig<T, M, TContent>): Promise<ZeitlichSession<M, false>>;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Session config fields derived from a main workflow input, ready to spread
|
|
@@ -187,7 +187,7 @@ declare function createToolRouter<T extends ToolMap>(options: ToolRouterOptions<
|
|
|
187
187
|
* }
|
|
188
188
|
* ```
|
|
189
189
|
*/
|
|
190
|
-
declare function defineTool<TName extends string, TSchema extends z.ZodType, TResult, TContext extends RouterContext = RouterContext>(tool: ToolWithHandler<TName, TSchema, TResult, TContext>): ToolWithHandler<TName, TSchema, TResult, TContext>;
|
|
190
|
+
declare function defineTool<TName extends string, TSchema extends z.ZodType, TResult, TContext extends RouterContext = RouterContext, TToolResponse = JsonValue>(tool: ToolWithHandler<TName, TSchema, TResult, TContext, TToolResponse>): ToolWithHandler<TName, TSchema, TResult, TContext, TToolResponse>;
|
|
191
191
|
/**
|
|
192
192
|
* Utility to check if there were no tool calls besides a specific one
|
|
193
193
|
*/
|
|
@@ -578,4 +578,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
|
|
|
578
578
|
}[];
|
|
579
579
|
}>;
|
|
580
580
|
|
|
581
|
-
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, SandboxInit, SandboxOps, SandboxShutdown, SessionConfig, Skill, SkillMetadata, type SubagentArgs, SubagentConfig, SubagentDefinition, SubagentFnResult, SubagentHooks, SubagentSandboxConfig, SubagentSandboxShutdown, SubagentSessionInput, type TaskCreateArgs, type TaskGetArgs, type TaskListArgs, type TaskUpdateArgs, ThreadInit, 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, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
|
581
|
+
export { ActivityToolHandler, AgentStateManager, type AskUserQuestionArgs, BaseAgentState, type BashArgs, type FileEditArgs, FileEntry, FileEntryMetadata, type FileReadArgs, type FileWriteArgs, type GlobArgs, type GrepArgs, JsonSerializable, JsonValue, ParsedToolCallUnion, type ReadSkillArgs, RouterContext, SandboxInit, SandboxOps, SandboxShutdown, SessionConfig, Skill, SkillMetadata, type SubagentArgs, SubagentConfig, SubagentDefinition, SubagentFnResult, SubagentHooks, SubagentSandboxConfig, SubagentSandboxShutdown, SubagentSessionInput, type TaskCreateArgs, type TaskGetArgs, type TaskListArgs, type TaskUpdateArgs, ThreadInit, 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, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
package/dist/workflow.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AgentResponse,
|
|
1
|
+
import { k as SessionConfig, Z as ZeitlichSession, j as SandboxShutdown, B as ThreadInit, i as SandboxInit, r as SubagentDefinition, u as SubagentHooks, v as SubagentSandboxConfig, q as SubagentConfig, w as SubagentSandboxShutdown, x as SubagentSessionInput, s as SubagentFnResult, c as SkillMetadata, d as Skill } from './types-CvJyXDYt.js';
|
|
2
|
+
export { A as AgentResponse, H as Hooks, a as ModelInvoker, M as ModelInvokerConfig, e as PostHumanMessageAppendHook, f as PostHumanMessageAppendHookContext, g as PreHumanMessageAppendHook, h as PreHumanMessageAppendHookContext, P as PrefixedThreadOps, R as RunAgentActivity, S as ScopedPrefix, l as SessionEndHook, m as SessionEndHookContext, n as SessionResult, o as SessionStartHook, p as SessionStartHookContext, b as SkillProvider, t as SubagentHandlerResponse, y as SubagentWorkflow, z as SubagentWorkflowInput, T as ThreadOps } from './types-CvJyXDYt.js';
|
|
3
3
|
import { g as SandboxOps } from './types-ChAMwU3q.js';
|
|
4
4
|
export { h as ExecOptions, E as ExecResult, P as PrefixedSandboxOps, 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-ChAMwU3q.js';
|
|
5
|
-
import { a as ToolMap, B as BaseAgentState,
|
|
6
|
-
export {
|
|
5
|
+
import { a as ToolMap, i as JsonSerializable, B as BaseAgentState, j as AgentStateManager, Q as ToolRouterOptions, M as ToolRouter, R as RouterContext, J as JsonValue, N as ToolWithHandler, r as ParsedToolCallUnion, K as ToolNames, T as ToolHandlerResponse, G as ToolHandler, W as WorkflowTask, A as ActivityToolHandler } from './types-mCVxKIZb.js';
|
|
6
|
+
export { k as AgentConfig, l as AgentFile, m as AgentState, n as AgentStatus, o as AppendToolResultFn, I as InferToolResults, p as JsonPrimitive, q as ParsedToolCall, s as PostToolUseFailureHook, t as PostToolUseFailureHookContext, c as PostToolUseFailureHookResult, u as PostToolUseHook, v as PostToolUseHookContext, w as PreToolUseHook, x as PreToolUseHookContext, P as PreToolUseHookResult, y as ProcessToolCallsContext, d as RawToolCall, f as RunAgentConfig, z as SerializableToolDefinition, S as SessionExitReason, C as TaskStatus, e as TokenUsage, D as ToolArgs, E as ToolCallResult, h as ToolCallResultUnion, F as ToolDefinition, H as ToolHooks, L as ToolResult, g as ToolResultConfig, b as ToolRouterHooks, O as isTerminalStatus } from './types-mCVxKIZb.js';
|
|
7
7
|
import z$1, { z } from 'zod';
|
|
8
|
-
import { a as FileEntryMetadata, e as VirtualFileTree, T as TreeMutation, F as FileEntry } from './types-
|
|
9
|
-
export { b as FileResolver, g as VirtualSandboxState } from './types-
|
|
10
|
-
export { f as filesWithMimeType, h as hasDirectory, a as hasFileWithMimeType } from './queries-
|
|
8
|
+
import { a as FileEntryMetadata, e as VirtualFileTree, T as TreeMutation, F as FileEntry } from './types-DFUNSYbj.js';
|
|
9
|
+
export { b as FileResolver, g as VirtualSandboxState } from './types-DFUNSYbj.js';
|
|
10
|
+
export { f as filesWithMimeType, h as hasDirectory, a as hasFileWithMimeType } from './queries-BCgJ9Sr5.js';
|
|
11
11
|
import '@temporalio/common';
|
|
12
12
|
import '@temporalio/workflow';
|
|
13
13
|
import '@temporalio/common/lib/interfaces';
|
|
@@ -43,10 +43,10 @@ import '@temporalio/common/lib/interfaces';
|
|
|
43
43
|
* const { finalMessage, exitReason } = await session.runSession({ stateManager });
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
declare function createSession<T extends ToolMap, M = unknown>(config: SessionConfig<T, M> & {
|
|
46
|
+
declare function createSession<T extends ToolMap, M = unknown, TContent = string>(config: SessionConfig<T, M, TContent> & {
|
|
47
47
|
sandboxOps: SandboxOps;
|
|
48
48
|
}): Promise<ZeitlichSession<M, true>>;
|
|
49
|
-
declare function createSession<T extends ToolMap, M = unknown>(config: SessionConfig<T, M>): Promise<ZeitlichSession<M, false>>;
|
|
49
|
+
declare function createSession<T extends ToolMap, M = unknown, TContent = string>(config: SessionConfig<T, M, TContent>): Promise<ZeitlichSession<M, false>>;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Session config fields derived from a main workflow input, ready to spread
|
|
@@ -187,7 +187,7 @@ declare function createToolRouter<T extends ToolMap>(options: ToolRouterOptions<
|
|
|
187
187
|
* }
|
|
188
188
|
* ```
|
|
189
189
|
*/
|
|
190
|
-
declare function defineTool<TName extends string, TSchema extends z.ZodType, TResult, TContext extends RouterContext = RouterContext>(tool: ToolWithHandler<TName, TSchema, TResult, TContext>): ToolWithHandler<TName, TSchema, TResult, TContext>;
|
|
190
|
+
declare function defineTool<TName extends string, TSchema extends z.ZodType, TResult, TContext extends RouterContext = RouterContext, TToolResponse = JsonValue>(tool: ToolWithHandler<TName, TSchema, TResult, TContext, TToolResponse>): ToolWithHandler<TName, TSchema, TResult, TContext, TToolResponse>;
|
|
191
191
|
/**
|
|
192
192
|
* Utility to check if there were no tool calls besides a specific one
|
|
193
193
|
*/
|
|
@@ -578,4 +578,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
|
|
|
578
578
|
}[];
|
|
579
579
|
}>;
|
|
580
580
|
|
|
581
|
-
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, SandboxInit, SandboxOps, SandboxShutdown, SessionConfig, Skill, SkillMetadata, type SubagentArgs, SubagentConfig, SubagentDefinition, SubagentFnResult, SubagentHooks, SubagentSandboxConfig, SubagentSandboxShutdown, SubagentSessionInput, type TaskCreateArgs, type TaskGetArgs, type TaskListArgs, type TaskUpdateArgs, ThreadInit, 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, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
|
581
|
+
export { ActivityToolHandler, AgentStateManager, type AskUserQuestionArgs, BaseAgentState, type BashArgs, type FileEditArgs, FileEntry, FileEntryMetadata, type FileReadArgs, type FileWriteArgs, type GlobArgs, type GrepArgs, JsonSerializable, JsonValue, ParsedToolCallUnion, type ReadSkillArgs, RouterContext, SandboxInit, SandboxOps, SandboxShutdown, SessionConfig, Skill, SkillMetadata, type SubagentArgs, SubagentConfig, SubagentDefinition, SubagentFnResult, SubagentHooks, SubagentSandboxConfig, SubagentSandboxShutdown, SubagentSessionInput, type TaskCreateArgs, type TaskGetArgs, type TaskListArgs, type TaskUpdateArgs, ThreadInit, 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, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
package/dist/workflow.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineSignal, uuid4, setHandler, defineUpdate, ApplicationFailure, condition, defineQuery, workflowInfo, getExternalWorkflowHandle, startChild } from '@temporalio/workflow';
|
|
1
|
+
import { defineSignal, uuid4, setHandler, defineUpdate, ApplicationFailure, condition, defineQuery, workflowInfo, getExternalWorkflowHandle, log, startChild } from '@temporalio/workflow';
|
|
2
2
|
import z14, { z } from 'zod';
|
|
3
3
|
import { ApplicationFailure as ApplicationFailure$1 } from '@temporalio/common';
|
|
4
4
|
|
|
@@ -114,6 +114,7 @@ function createToolRouter(options) {
|
|
|
114
114
|
if (preResult.skip) {
|
|
115
115
|
await appendToolResult(uuid4(), {
|
|
116
116
|
threadId: options.threadId,
|
|
117
|
+
threadKey: options.threadKey,
|
|
117
118
|
toolCallId: toolCall.id,
|
|
118
119
|
toolName: toolCall.name,
|
|
119
120
|
content: JSON.stringify({
|
|
@@ -132,6 +133,7 @@ function createToolRouter(options) {
|
|
|
132
133
|
if (tool) {
|
|
133
134
|
const routerContext = {
|
|
134
135
|
threadId: options.threadId,
|
|
136
|
+
...options.threadKey && { threadKey: options.threadKey },
|
|
135
137
|
toolCallId: toolCall.id,
|
|
136
138
|
toolName: toolCall.name,
|
|
137
139
|
...sandboxId !== void 0 && { sandboxId },
|
|
@@ -163,6 +165,7 @@ function createToolRouter(options) {
|
|
|
163
165
|
if (!resultAppended) {
|
|
164
166
|
const config = {
|
|
165
167
|
threadId: options.threadId,
|
|
168
|
+
threadKey: options.threadKey,
|
|
166
169
|
toolCallId: toolCall.id,
|
|
167
170
|
toolName: toolCall.name,
|
|
168
171
|
content
|
|
@@ -254,6 +257,7 @@ function createToolRouter(options) {
|
|
|
254
257
|
const processOne = async (toolCall) => {
|
|
255
258
|
const routerContext = {
|
|
256
259
|
threadId: options.threadId,
|
|
260
|
+
...options.threadKey && { threadKey: options.threadKey },
|
|
257
261
|
toolCallId: toolCall.id,
|
|
258
262
|
toolName: toolCall.name,
|
|
259
263
|
...context?.sandboxId !== void 0 && {
|
|
@@ -273,6 +277,7 @@ function createToolRouter(options) {
|
|
|
273
277
|
uuid4(),
|
|
274
278
|
{
|
|
275
279
|
threadId: options.threadId,
|
|
280
|
+
threadKey: options.threadKey,
|
|
276
281
|
toolCallId: toolCall.id,
|
|
277
282
|
toolName: toolCall.name,
|
|
278
283
|
content: response.toolResponse
|
|
@@ -480,9 +485,10 @@ function createSubagentHandler(subagents) {
|
|
|
480
485
|
}
|
|
481
486
|
let finalToolResponse = toolResponse;
|
|
482
487
|
if (allowsContinuation && childThreadId) {
|
|
483
|
-
|
|
488
|
+
const responseStr = typeof toolResponse === "string" ? toolResponse : JSON.stringify(toolResponse);
|
|
489
|
+
finalToolResponse = `${responseStr}
|
|
484
490
|
|
|
485
|
-
[${config.agentName} Thread ID: ${childThreadId}]
|
|
491
|
+
[${config.agentName} Thread ID: ${childThreadId}]`;
|
|
486
492
|
}
|
|
487
493
|
return {
|
|
488
494
|
toolResponse: finalToolResponse,
|
|
@@ -497,8 +503,14 @@ function createSubagentHandler(subagents) {
|
|
|
497
503
|
pendingDestroys.clear();
|
|
498
504
|
await Promise.all(
|
|
499
505
|
handles.map(async (handle) => {
|
|
500
|
-
|
|
501
|
-
|
|
506
|
+
try {
|
|
507
|
+
await handle.signal(destroySandboxSignal);
|
|
508
|
+
await handle.result();
|
|
509
|
+
} catch (err) {
|
|
510
|
+
log.warn("Failed to signal destroySandbox to child workflow", {
|
|
511
|
+
error: err
|
|
512
|
+
});
|
|
513
|
+
}
|
|
502
514
|
})
|
|
503
515
|
);
|
|
504
516
|
};
|
|
@@ -651,6 +663,7 @@ async function createSession({
|
|
|
651
663
|
hooks = {},
|
|
652
664
|
appendSystemPrompt = true,
|
|
653
665
|
waitForInputTimeout = "48h",
|
|
666
|
+
threadKey,
|
|
654
667
|
sandboxOps,
|
|
655
668
|
thread: threadInit,
|
|
656
669
|
sandbox: sandboxInit,
|
|
@@ -695,6 +708,7 @@ async function createSession({
|
|
|
695
708
|
tools,
|
|
696
709
|
appendToolResult,
|
|
697
710
|
threadId,
|
|
711
|
+
threadKey,
|
|
698
712
|
hooks,
|
|
699
713
|
plugins,
|
|
700
714
|
parallel: processToolsInParallel
|
|
@@ -723,7 +737,7 @@ async function createSession({
|
|
|
723
737
|
threadId
|
|
724
738
|
});
|
|
725
739
|
}
|
|
726
|
-
await appendHumanMessage(threadId, uuid4(), message);
|
|
740
|
+
await appendHumanMessage(threadId, uuid4(), message, threadKey);
|
|
727
741
|
if (hooks.onPostHumanMessageAppend) {
|
|
728
742
|
await hooks.onPostHumanMessageAppend({
|
|
729
743
|
message,
|
|
@@ -791,7 +805,7 @@ async function createSession({
|
|
|
791
805
|
}
|
|
792
806
|
const systemPrompt = stateManager.getSystemPrompt();
|
|
793
807
|
if (threadMode === "fork" && sourceThreadId) {
|
|
794
|
-
await forkThread(sourceThreadId, threadId);
|
|
808
|
+
await forkThread(sourceThreadId, threadId, threadKey);
|
|
795
809
|
} else if (threadMode === "continue") ; else {
|
|
796
810
|
if (appendSystemPrompt) {
|
|
797
811
|
if (!systemPrompt || systemPrompt.trim() === "") {
|
|
@@ -800,12 +814,12 @@ async function createSession({
|
|
|
800
814
|
nonRetryable: true
|
|
801
815
|
});
|
|
802
816
|
}
|
|
803
|
-
await appendSystemMessage(threadId, uuid4(), systemPrompt);
|
|
817
|
+
await appendSystemMessage(threadId, uuid4(), systemPrompt, threadKey);
|
|
804
818
|
} else {
|
|
805
|
-
await initializeThread(threadId);
|
|
819
|
+
await initializeThread(threadId, threadKey);
|
|
806
820
|
}
|
|
807
821
|
}
|
|
808
|
-
await appendHumanMessage(threadId, uuid4(), await buildContextMessage());
|
|
822
|
+
await appendHumanMessage(threadId, uuid4(), await buildContextMessage(), threadKey);
|
|
809
823
|
let exitReason = "completed";
|
|
810
824
|
try {
|
|
811
825
|
while (stateManager.isRunning() && !stateManager.isTerminal() && stateManager.getTurns() < maxTurns) {
|
|
@@ -814,6 +828,7 @@ async function createSession({
|
|
|
814
828
|
stateManager.setTools(toolRouter.getToolDefinitions());
|
|
815
829
|
const { message, rawToolCalls, usage } = await runAgent({
|
|
816
830
|
threadId,
|
|
831
|
+
threadKey,
|
|
817
832
|
agentName,
|
|
818
833
|
metadata
|
|
819
834
|
});
|
|
@@ -838,6 +853,7 @@ async function createSession({
|
|
|
838
853
|
} catch (error) {
|
|
839
854
|
await appendToolResult(uuid4(), {
|
|
840
855
|
threadId,
|
|
856
|
+
threadKey,
|
|
841
857
|
toolCallId: tc.id ?? "",
|
|
842
858
|
toolName: tc.name,
|
|
843
859
|
content: JSON.stringify({
|