zeitlich 0.2.37 → 0.2.38
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-Bb-nAjwQ.d.ts → activities-BKhMtKDd.d.ts} +4 -2
- package/dist/{activities-vkI4_3CC.d.cts → activities-CDcwkRZs.d.cts} +4 -2
- package/dist/adapters/sandbox/bedrock/index.cjs +3 -3
- package/dist/adapters/sandbox/bedrock/index.cjs.map +1 -1
- package/dist/adapters/sandbox/bedrock/index.d.cts +6 -6
- package/dist/adapters/sandbox/bedrock/index.d.ts +6 -6
- package/dist/adapters/sandbox/bedrock/index.js +3 -3
- package/dist/adapters/sandbox/bedrock/index.js.map +1 -1
- package/dist/adapters/sandbox/bedrock/workflow.d.cts +2 -2
- package/dist/adapters/sandbox/bedrock/workflow.d.ts +2 -2
- package/dist/adapters/sandbox/daytona/index.cjs +3 -3
- package/dist/adapters/sandbox/daytona/index.cjs.map +1 -1
- package/dist/adapters/sandbox/daytona/index.d.cts +4 -4
- package/dist/adapters/sandbox/daytona/index.d.ts +4 -4
- package/dist/adapters/sandbox/daytona/index.js +3 -3
- package/dist/adapters/sandbox/daytona/index.js.map +1 -1
- package/dist/adapters/sandbox/daytona/workflow.d.cts +1 -1
- package/dist/adapters/sandbox/daytona/workflow.d.ts +1 -1
- package/dist/adapters/sandbox/e2b/index.cjs +26 -14
- package/dist/adapters/sandbox/e2b/index.cjs.map +1 -1
- package/dist/adapters/sandbox/e2b/index.d.cts +24 -4
- package/dist/adapters/sandbox/e2b/index.d.ts +24 -4
- package/dist/adapters/sandbox/e2b/index.js +26 -14
- package/dist/adapters/sandbox/e2b/index.js.map +1 -1
- package/dist/adapters/sandbox/e2b/workflow.d.cts +1 -1
- package/dist/adapters/sandbox/e2b/workflow.d.ts +1 -1
- package/dist/adapters/sandbox/inmemory/index.cjs +3 -3
- package/dist/adapters/sandbox/inmemory/index.cjs.map +1 -1
- package/dist/adapters/sandbox/inmemory/index.d.cts +4 -4
- package/dist/adapters/sandbox/inmemory/index.d.ts +4 -4
- package/dist/adapters/sandbox/inmemory/index.js +3 -3
- package/dist/adapters/sandbox/inmemory/index.js.map +1 -1
- package/dist/adapters/sandbox/inmemory/workflow.d.cts +1 -1
- package/dist/adapters/sandbox/inmemory/workflow.d.ts +1 -1
- package/dist/adapters/thread/anthropic/index.cjs +23 -3
- package/dist/adapters/thread/anthropic/index.cjs.map +1 -1
- package/dist/adapters/thread/anthropic/index.d.cts +5 -5
- package/dist/adapters/thread/anthropic/index.d.ts +5 -5
- package/dist/adapters/thread/anthropic/index.js +23 -3
- package/dist/adapters/thread/anthropic/index.js.map +1 -1
- package/dist/adapters/thread/anthropic/workflow.cjs +2 -1
- package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -1
- package/dist/adapters/thread/anthropic/workflow.d.cts +5 -5
- package/dist/adapters/thread/anthropic/workflow.d.ts +5 -5
- package/dist/adapters/thread/anthropic/workflow.js +2 -1
- package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
- package/dist/adapters/thread/google-genai/index.cjs +27 -3
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +5 -5
- package/dist/adapters/thread/google-genai/index.d.ts +5 -5
- package/dist/adapters/thread/google-genai/index.js +27 -3
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.cjs +2 -1
- package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.d.cts +5 -5
- package/dist/adapters/thread/google-genai/workflow.d.ts +5 -5
- package/dist/adapters/thread/google-genai/workflow.js +2 -1
- package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
- package/dist/adapters/thread/langchain/index.cjs +23 -3
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +5 -5
- package/dist/adapters/thread/langchain/index.d.ts +5 -5
- package/dist/adapters/thread/langchain/index.js +23 -3
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/adapters/thread/langchain/workflow.cjs +2 -1
- package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
- package/dist/adapters/thread/langchain/workflow.d.cts +5 -5
- package/dist/adapters/thread/langchain/workflow.d.ts +5 -5
- package/dist/adapters/thread/langchain/workflow.js +2 -1
- package/dist/adapters/thread/langchain/workflow.js.map +1 -1
- package/dist/index.cjs +120 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +121 -31
- package/dist/index.js.map +1 -1
- package/dist/{proxy-0smGKvx8.d.ts → proxy-CUlKSvZS.d.ts} +1 -1
- package/dist/{proxy-DEtowJyd.d.cts → proxy-D_3x7RN4.d.cts} +1 -1
- package/dist/{thread-manager-C-C4pI2z.d.ts → thread-manager-CVu7o2cs.d.ts} +4 -2
- package/dist/{thread-manager-D4vgzYrh.d.cts → thread-manager-HSwyh28L.d.cts} +4 -2
- package/dist/{thread-manager-3fszQih4.d.ts → thread-manager-c1gPopAG.d.ts} +4 -2
- package/dist/{thread-manager-CzYln2OC.d.cts → thread-manager-wGi-LqIP.d.cts} +4 -2
- package/dist/{types-B37hKoWA.d.ts → types-BH_IRryz.d.ts} +10 -1
- package/dist/{types-D08CXPh8.d.cts → types-BaOw4hKI.d.cts} +10 -1
- package/dist/{types-CPKDl-y_.d.ts → types-C06FwR96.d.cts} +59 -4
- package/dist/{types-CNuWnvy9.d.ts → types-DAsQ21Rt.d.ts} +1 -1
- package/dist/{types-BO7Yju20.d.cts → types-DNr31FzL.d.ts} +59 -4
- package/dist/{types-DWEUmYAJ.d.cts → types-lm8tMNJQ.d.cts} +1 -1
- package/dist/{types-tQL9njTu.d.cts → types-yx0LzPGn.d.cts} +21 -7
- package/dist/{types-tQL9njTu.d.ts → types-yx0LzPGn.d.ts} +21 -7
- package/dist/{workflow-CjXHbZZc.d.ts → workflow-CSCkpwAL.d.ts} +2 -2
- package/dist/{workflow-Do_lzJpT.d.cts → workflow-DuvMZ8Vm.d.cts} +2 -2
- package/dist/workflow.cjs +94 -18
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +3 -3
- package/dist/workflow.d.ts +3 -3
- package/dist/workflow.js +95 -19
- package/dist/workflow.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/sandbox/bedrock/index.ts +12 -3
- package/src/adapters/sandbox/daytona/index.ts +12 -3
- package/src/adapters/sandbox/e2b/index.ts +36 -14
- package/src/adapters/sandbox/e2b/types.ts +16 -0
- package/src/adapters/sandbox/inmemory/index.ts +12 -3
- package/src/adapters/thread/anthropic/activities.ts +9 -0
- package/src/adapters/thread/anthropic/model-invoker.ts +3 -1
- package/src/adapters/thread/anthropic/thread-manager.ts +3 -0
- package/src/adapters/thread/google-genai/activities.ts +13 -0
- package/src/adapters/thread/google-genai/model-invoker.ts +3 -1
- package/src/adapters/thread/google-genai/thread-manager.ts +3 -0
- package/src/adapters/thread/langchain/activities.ts +9 -0
- package/src/adapters/thread/langchain/model-invoker.ts +2 -1
- package/src/adapters/thread/langchain/thread-manager.ts +3 -0
- package/src/lib/lifecycle.ts +11 -4
- package/src/lib/model/types.ts +10 -0
- package/src/lib/sandbox/manager.ts +26 -18
- package/src/lib/sandbox/types.ts +27 -7
- package/src/lib/session/session-edge-cases.integration.test.ts +265 -1
- package/src/lib/session/session.integration.test.ts +22 -1
- package/src/lib/session/session.ts +61 -7
- package/src/lib/session/types.ts +12 -0
- package/src/lib/subagent/subagent.integration.test.ts +100 -104
- package/src/lib/thread/manager.ts +18 -0
- package/src/lib/thread/proxy.ts +1 -0
- package/src/lib/thread/types.ts +9 -0
- package/src/lib/tool-router/index.ts +2 -0
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +92 -0
- package/src/lib/tool-router/router.integration.test.ts +12 -0
- package/src/lib/tool-router/router.ts +89 -16
- package/src/lib/tool-router/types.ts +34 -1
- package/src/workflow.ts +2 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { B as BashArgs, F as FileEditArgs, G as GlobArgs, a as FileReadArgs, b as FileWriteArgs } from './workflow-
|
|
2
|
-
export { A as AskUserQuestionArgs, c as FileTreeAccessor, d as GrepArgs, O as ObservabilityHooks, R as ReadSkillArgs, S as SessionEndedEvent, e as SessionStartedEvent, f as SubagentArgs, T as TaskCreateArgs, g as TaskGetArgs, h as TaskListArgs, i as TaskUpdateArgs, j as ToolExecutedEvent, k as TurnCompletedEvent, W as WorkflowConfig, l as WorkflowInput, m as WorkflowSessionInput, Z as ZeitlichObservabilitySinks, n as applyVirtualTreeMutations, o as askUserQuestionTool, p as bashTool, q as composeHooks, r as createAgentStateManager, s as createAskUserQuestionHandler, t as createBashToolDescription, u as createObservabilityHooks, v as createReadSkillHandler, w as createReadSkillTool, x as createSession, y as createTaskCreateHandler, z as createTaskGetHandler, C as createTaskListHandler, D as createTaskUpdateHandler, E as createToolRouter, H as defineSubagent, I as defineSubagentWorkflow, J as defineTool, K as defineWorkflow, L as editTool, M as filesWithMimeType, N as formatVirtualFileTree, P as getShortId, Q as globTool, U as grepTool, V as hasDirectory, X as hasFileWithMimeType, Y as hasNoOtherToolCalls, _ as parseSkillFile, $ as proxyRunAgent, a0 as proxyVirtualFsOps, a1 as readFileTool, a2 as taskCreateTool, a3 as taskGetTool, a4 as taskListTool, a5 as taskUpdateTool, a6 as writeFileTool } from './workflow-
|
|
3
|
-
import { R as RouterContext, d as ToolResultConfig, c as ActivityToolHandler, J as JsonValue, b as ToolHandlerResponse, B as BaseAgentState, e as RunAgentConfig, f as SkillProvider, g as SkillMetadata, h as Skill, F as FileEntryMetadata, i as FileResolver, V as VirtualFsContext, j as TreeMutation, k as PrefixedVirtualFsOps } from './types-
|
|
4
|
-
export { l as AgentConfig, m as AgentFile, A as AgentResponse, n as AgentState, o as AgentStateManager, p as AgentStatus, q as AppendToolResultFn, r as FileEntry, H as Hooks, I as InferToolResults, s as JsonPrimitive, t as JsonSerializable, a as ModelInvoker, M as ModelInvokerConfig, u as ParsedToolCall, v as ParsedToolCallUnion, w as PostHumanMessageAppendHook, x as PostHumanMessageAppendHookContext, y as PostToolUseFailureHook, z as PostToolUseFailureHookContext, C as PostToolUseFailureHookResult, D as PostToolUseHook, E as PostToolUseHookContext, G as PreHumanMessageAppendHook, K as PreHumanMessageAppendHookContext, L as PreToolUseHook, N as PreToolUseHookContext, O as PreToolUseHookResult, P as PrefixedThreadOps, Q as ProcessToolCallsContext, U as
|
|
5
|
-
import { S as Sandbox, a as SandboxFileSystem, d as SandboxCreateOptions, b as SandboxProvider, f as SandboxSnapshot, P as PrefixedSandboxOps, F as FileStat, D as DirentEntry, E as ExecResult } from './types-
|
|
6
|
-
export { h as ExecOptions, c as SandboxCapabilities, e as SandboxCreateResult, i as SandboxNotFoundError, j as SandboxNotSupportedError, g as SandboxOps } from './types-
|
|
1
|
+
import { B as BashArgs, F as FileEditArgs, G as GlobArgs, a as FileReadArgs, b as FileWriteArgs } from './workflow-DuvMZ8Vm.cjs';
|
|
2
|
+
export { A as AskUserQuestionArgs, c as FileTreeAccessor, d as GrepArgs, O as ObservabilityHooks, R as ReadSkillArgs, S as SessionEndedEvent, e as SessionStartedEvent, f as SubagentArgs, T as TaskCreateArgs, g as TaskGetArgs, h as TaskListArgs, i as TaskUpdateArgs, j as ToolExecutedEvent, k as TurnCompletedEvent, W as WorkflowConfig, l as WorkflowInput, m as WorkflowSessionInput, Z as ZeitlichObservabilitySinks, n as applyVirtualTreeMutations, o as askUserQuestionTool, p as bashTool, q as composeHooks, r as createAgentStateManager, s as createAskUserQuestionHandler, t as createBashToolDescription, u as createObservabilityHooks, v as createReadSkillHandler, w as createReadSkillTool, x as createSession, y as createTaskCreateHandler, z as createTaskGetHandler, C as createTaskListHandler, D as createTaskUpdateHandler, E as createToolRouter, H as defineSubagent, I as defineSubagentWorkflow, J as defineTool, K as defineWorkflow, L as editTool, M as filesWithMimeType, N as formatVirtualFileTree, P as getShortId, Q as globTool, U as grepTool, V as hasDirectory, X as hasFileWithMimeType, Y as hasNoOtherToolCalls, _ as parseSkillFile, $ as proxyRunAgent, a0 as proxyVirtualFsOps, a1 as readFileTool, a2 as taskCreateTool, a3 as taskGetTool, a4 as taskListTool, a5 as taskUpdateTool, a6 as writeFileTool } from './workflow-DuvMZ8Vm.cjs';
|
|
3
|
+
import { R as RouterContext, d as ToolResultConfig, c as ActivityToolHandler, J as JsonValue, b as ToolHandlerResponse, B as BaseAgentState, e as RunAgentConfig, f as SkillProvider, g as SkillMetadata, h as Skill, F as FileEntryMetadata, i as FileResolver, V as VirtualFsContext, j as TreeMutation, k as PrefixedVirtualFsOps } from './types-C06FwR96.cjs';
|
|
4
|
+
export { l as AgentConfig, m as AgentFile, A as AgentResponse, n as AgentState, o as AgentStateManager, p as AgentStatus, q as AppendToolResultFn, r as FileEntry, H as Hooks, I as InferToolResults, s as JsonPrimitive, t as JsonSerializable, a as ModelInvoker, M as ModelInvokerConfig, u as ParsedToolCall, v as ParsedToolCallUnion, w as PostHumanMessageAppendHook, x as PostHumanMessageAppendHookContext, y as PostToolUseFailureHook, z as PostToolUseFailureHookContext, C as PostToolUseFailureHookResult, D as PostToolUseHook, E as PostToolUseHookContext, G as PreHumanMessageAppendHook, K as PreHumanMessageAppendHookContext, L as PreToolUseHook, N as PreToolUseHookContext, O as PreToolUseHookResult, P as PrefixedThreadOps, Q as ProcessToolCallsContext, U as ProcessToolCallsResult, W as RawToolCall, X as RewindSignal, Y as RunAgentActivity, Z as SandboxInit, _ as SandboxShutdown, S as ScopedPrefix, $ as SerializableToolDefinition, a0 as SessionConfig, a1 as SessionEndHook, a2 as SessionEndHookContext, a3 as SessionExitReason, a4 as SessionResult, a5 as SessionStartHook, a6 as SessionStartHookContext, a7 as SubagentConfig, a8 as SubagentDefinition, a9 as SubagentFnResult, aa as SubagentHandlerResponse, ab as SubagentHooks, ac as SubagentSandboxConfig, ad as SubagentSandboxShutdown, ae as SubagentSessionInput, af as SubagentWorkflow, ag as SubagentWorkflowInput, ah as TaskStatus, ai as ThreadInit, T as ThreadOps, aj as TokenUsage, ak as ToolArgs, al as ToolCallResult, am as ToolCallResultUnion, an as ToolDefinition, ao as ToolHandler, ap as ToolHooks, aq as ToolMap, ar as ToolNames, as as ToolResult, at as ToolRouter, au as ToolRouterHooks, av as ToolWithHandler, aw as VirtualFileSystem, ax as VirtualFileTree, ay as VirtualFsOps, az as VirtualFsState, aA as WorkflowTask, aB as ZeitlichSession, aC as isTerminalStatus } from './types-C06FwR96.cjs';
|
|
5
|
+
import { S as Sandbox, a as SandboxFileSystem, d as SandboxCreateOptions, b as SandboxProvider, f as SandboxSnapshot, P as PrefixedSandboxOps, F as FileStat, D as DirentEntry, E as ExecResult } from './types-yx0LzPGn.cjs';
|
|
6
|
+
export { h as ExecOptions, c as SandboxCapabilities, e as SandboxCreateResult, i as SandboxNotFoundError, j as SandboxNotSupportedError, g as SandboxOps } from './types-yx0LzPGn.cjs';
|
|
7
7
|
import { WorkflowClient } from '@temporalio/client';
|
|
8
|
-
import { a as ThreadManagerConfig, B as BaseThreadManager } from './types-
|
|
9
|
-
export { P as ProviderThreadManager } from './types-
|
|
8
|
+
import { a as ThreadManagerConfig, B as BaseThreadManager } from './types-BaOw4hKI.cjs';
|
|
9
|
+
export { P as ProviderThreadManager } from './types-BaOw4hKI.cjs';
|
|
10
10
|
import 'zod';
|
|
11
11
|
import '@temporalio/workflow';
|
|
12
12
|
import '@temporalio/common';
|
|
@@ -303,10 +303,10 @@ declare class SandboxManager<TOptions extends SandboxCreateOptions = SandboxCrea
|
|
|
303
303
|
destroy(id: string): Promise<void>;
|
|
304
304
|
pause(id: string, ttlSeconds?: number): Promise<void>;
|
|
305
305
|
resume(id: string): Promise<void>;
|
|
306
|
-
snapshot(id: string): Promise<SandboxSnapshot>;
|
|
307
|
-
restore(snapshot: SandboxSnapshot): Promise<string>;
|
|
306
|
+
snapshot(id: string, options?: TOptions): Promise<SandboxSnapshot>;
|
|
307
|
+
restore(snapshot: SandboxSnapshot, options?: TOptions): Promise<string>;
|
|
308
308
|
deleteSnapshot(snapshot: SandboxSnapshot): Promise<void>;
|
|
309
|
-
fork(sandboxId: string): Promise<string>;
|
|
309
|
+
fork(sandboxId: string, options?: TOptions): Promise<string>;
|
|
310
310
|
/**
|
|
311
311
|
* Returns Temporal activity functions with prefixed names.
|
|
312
312
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { B as BashArgs, F as FileEditArgs, G as GlobArgs, a as FileReadArgs, b as FileWriteArgs } from './workflow-
|
|
2
|
-
export { A as AskUserQuestionArgs, c as FileTreeAccessor, d as GrepArgs, O as ObservabilityHooks, R as ReadSkillArgs, S as SessionEndedEvent, e as SessionStartedEvent, f as SubagentArgs, T as TaskCreateArgs, g as TaskGetArgs, h as TaskListArgs, i as TaskUpdateArgs, j as ToolExecutedEvent, k as TurnCompletedEvent, W as WorkflowConfig, l as WorkflowInput, m as WorkflowSessionInput, Z as ZeitlichObservabilitySinks, n as applyVirtualTreeMutations, o as askUserQuestionTool, p as bashTool, q as composeHooks, r as createAgentStateManager, s as createAskUserQuestionHandler, t as createBashToolDescription, u as createObservabilityHooks, v as createReadSkillHandler, w as createReadSkillTool, x as createSession, y as createTaskCreateHandler, z as createTaskGetHandler, C as createTaskListHandler, D as createTaskUpdateHandler, E as createToolRouter, H as defineSubagent, I as defineSubagentWorkflow, J as defineTool, K as defineWorkflow, L as editTool, M as filesWithMimeType, N as formatVirtualFileTree, P as getShortId, Q as globTool, U as grepTool, V as hasDirectory, X as hasFileWithMimeType, Y as hasNoOtherToolCalls, _ as parseSkillFile, $ as proxyRunAgent, a0 as proxyVirtualFsOps, a1 as readFileTool, a2 as taskCreateTool, a3 as taskGetTool, a4 as taskListTool, a5 as taskUpdateTool, a6 as writeFileTool } from './workflow-
|
|
3
|
-
import { R as RouterContext, d as ToolResultConfig, c as ActivityToolHandler, J as JsonValue, b as ToolHandlerResponse, B as BaseAgentState, e as RunAgentConfig, f as SkillProvider, g as SkillMetadata, h as Skill, F as FileEntryMetadata, i as FileResolver, V as VirtualFsContext, j as TreeMutation, k as PrefixedVirtualFsOps } from './types-
|
|
4
|
-
export { l as AgentConfig, m as AgentFile, A as AgentResponse, n as AgentState, o as AgentStateManager, p as AgentStatus, q as AppendToolResultFn, r as FileEntry, H as Hooks, I as InferToolResults, s as JsonPrimitive, t as JsonSerializable, a as ModelInvoker, M as ModelInvokerConfig, u as ParsedToolCall, v as ParsedToolCallUnion, w as PostHumanMessageAppendHook, x as PostHumanMessageAppendHookContext, y as PostToolUseFailureHook, z as PostToolUseFailureHookContext, C as PostToolUseFailureHookResult, D as PostToolUseHook, E as PostToolUseHookContext, G as PreHumanMessageAppendHook, K as PreHumanMessageAppendHookContext, L as PreToolUseHook, N as PreToolUseHookContext, O as PreToolUseHookResult, P as PrefixedThreadOps, Q as ProcessToolCallsContext, U as
|
|
5
|
-
import { S as Sandbox, a as SandboxFileSystem, d as SandboxCreateOptions, b as SandboxProvider, f as SandboxSnapshot, P as PrefixedSandboxOps, F as FileStat, D as DirentEntry, E as ExecResult } from './types-
|
|
6
|
-
export { h as ExecOptions, c as SandboxCapabilities, e as SandboxCreateResult, i as SandboxNotFoundError, j as SandboxNotSupportedError, g as SandboxOps } from './types-
|
|
1
|
+
import { B as BashArgs, F as FileEditArgs, G as GlobArgs, a as FileReadArgs, b as FileWriteArgs } from './workflow-CSCkpwAL.js';
|
|
2
|
+
export { A as AskUserQuestionArgs, c as FileTreeAccessor, d as GrepArgs, O as ObservabilityHooks, R as ReadSkillArgs, S as SessionEndedEvent, e as SessionStartedEvent, f as SubagentArgs, T as TaskCreateArgs, g as TaskGetArgs, h as TaskListArgs, i as TaskUpdateArgs, j as ToolExecutedEvent, k as TurnCompletedEvent, W as WorkflowConfig, l as WorkflowInput, m as WorkflowSessionInput, Z as ZeitlichObservabilitySinks, n as applyVirtualTreeMutations, o as askUserQuestionTool, p as bashTool, q as composeHooks, r as createAgentStateManager, s as createAskUserQuestionHandler, t as createBashToolDescription, u as createObservabilityHooks, v as createReadSkillHandler, w as createReadSkillTool, x as createSession, y as createTaskCreateHandler, z as createTaskGetHandler, C as createTaskListHandler, D as createTaskUpdateHandler, E as createToolRouter, H as defineSubagent, I as defineSubagentWorkflow, J as defineTool, K as defineWorkflow, L as editTool, M as filesWithMimeType, N as formatVirtualFileTree, P as getShortId, Q as globTool, U as grepTool, V as hasDirectory, X as hasFileWithMimeType, Y as hasNoOtherToolCalls, _ as parseSkillFile, $ as proxyRunAgent, a0 as proxyVirtualFsOps, a1 as readFileTool, a2 as taskCreateTool, a3 as taskGetTool, a4 as taskListTool, a5 as taskUpdateTool, a6 as writeFileTool } from './workflow-CSCkpwAL.js';
|
|
3
|
+
import { R as RouterContext, d as ToolResultConfig, c as ActivityToolHandler, J as JsonValue, b as ToolHandlerResponse, B as BaseAgentState, e as RunAgentConfig, f as SkillProvider, g as SkillMetadata, h as Skill, F as FileEntryMetadata, i as FileResolver, V as VirtualFsContext, j as TreeMutation, k as PrefixedVirtualFsOps } from './types-DNr31FzL.js';
|
|
4
|
+
export { l as AgentConfig, m as AgentFile, A as AgentResponse, n as AgentState, o as AgentStateManager, p as AgentStatus, q as AppendToolResultFn, r as FileEntry, H as Hooks, I as InferToolResults, s as JsonPrimitive, t as JsonSerializable, a as ModelInvoker, M as ModelInvokerConfig, u as ParsedToolCall, v as ParsedToolCallUnion, w as PostHumanMessageAppendHook, x as PostHumanMessageAppendHookContext, y as PostToolUseFailureHook, z as PostToolUseFailureHookContext, C as PostToolUseFailureHookResult, D as PostToolUseHook, E as PostToolUseHookContext, G as PreHumanMessageAppendHook, K as PreHumanMessageAppendHookContext, L as PreToolUseHook, N as PreToolUseHookContext, O as PreToolUseHookResult, P as PrefixedThreadOps, Q as ProcessToolCallsContext, U as ProcessToolCallsResult, W as RawToolCall, X as RewindSignal, Y as RunAgentActivity, Z as SandboxInit, _ as SandboxShutdown, S as ScopedPrefix, $ as SerializableToolDefinition, a0 as SessionConfig, a1 as SessionEndHook, a2 as SessionEndHookContext, a3 as SessionExitReason, a4 as SessionResult, a5 as SessionStartHook, a6 as SessionStartHookContext, a7 as SubagentConfig, a8 as SubagentDefinition, a9 as SubagentFnResult, aa as SubagentHandlerResponse, ab as SubagentHooks, ac as SubagentSandboxConfig, ad as SubagentSandboxShutdown, ae as SubagentSessionInput, af as SubagentWorkflow, ag as SubagentWorkflowInput, ah as TaskStatus, ai as ThreadInit, T as ThreadOps, aj as TokenUsage, ak as ToolArgs, al as ToolCallResult, am as ToolCallResultUnion, an as ToolDefinition, ao as ToolHandler, ap as ToolHooks, aq as ToolMap, ar as ToolNames, as as ToolResult, at as ToolRouter, au as ToolRouterHooks, av as ToolWithHandler, aw as VirtualFileSystem, ax as VirtualFileTree, ay as VirtualFsOps, az as VirtualFsState, aA as WorkflowTask, aB as ZeitlichSession, aC as isTerminalStatus } from './types-DNr31FzL.js';
|
|
5
|
+
import { S as Sandbox, a as SandboxFileSystem, d as SandboxCreateOptions, b as SandboxProvider, f as SandboxSnapshot, P as PrefixedSandboxOps, F as FileStat, D as DirentEntry, E as ExecResult } from './types-yx0LzPGn.js';
|
|
6
|
+
export { h as ExecOptions, c as SandboxCapabilities, e as SandboxCreateResult, i as SandboxNotFoundError, j as SandboxNotSupportedError, g as SandboxOps } from './types-yx0LzPGn.js';
|
|
7
7
|
import { WorkflowClient } from '@temporalio/client';
|
|
8
|
-
import { a as ThreadManagerConfig, B as BaseThreadManager } from './types-
|
|
9
|
-
export { P as ProviderThreadManager } from './types-
|
|
8
|
+
import { a as ThreadManagerConfig, B as BaseThreadManager } from './types-BH_IRryz.js';
|
|
9
|
+
export { P as ProviderThreadManager } from './types-BH_IRryz.js';
|
|
10
10
|
import 'zod';
|
|
11
11
|
import '@temporalio/workflow';
|
|
12
12
|
import '@temporalio/common';
|
|
@@ -303,10 +303,10 @@ declare class SandboxManager<TOptions extends SandboxCreateOptions = SandboxCrea
|
|
|
303
303
|
destroy(id: string): Promise<void>;
|
|
304
304
|
pause(id: string, ttlSeconds?: number): Promise<void>;
|
|
305
305
|
resume(id: string): Promise<void>;
|
|
306
|
-
snapshot(id: string): Promise<SandboxSnapshot>;
|
|
307
|
-
restore(snapshot: SandboxSnapshot): Promise<string>;
|
|
306
|
+
snapshot(id: string, options?: TOptions): Promise<SandboxSnapshot>;
|
|
307
|
+
restore(snapshot: SandboxSnapshot, options?: TOptions): Promise<string>;
|
|
308
308
|
deleteSnapshot(snapshot: SandboxSnapshot): Promise<void>;
|
|
309
|
-
fork(sandboxId: string): Promise<string>;
|
|
309
|
+
fork(sandboxId: string, options?: TOptions): Promise<string>;
|
|
310
310
|
/**
|
|
311
311
|
* Returns Temporal activity functions with prefixed names.
|
|
312
312
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineSignal, uuid4, setHandler, defineUpdate, ApplicationFailure, log, condition, defineQuery, proxySinks, workflowInfo, proxyActivities, getExternalWorkflowHandle, executeChild } from '@temporalio/workflow';
|
|
1
|
+
import { defineSignal, CancellationScope, isCancellation, uuid4, setHandler, defineUpdate, ApplicationFailure, log, condition, defineQuery, proxySinks, workflowInfo, proxyActivities, getExternalWorkflowHandle, executeChild } from '@temporalio/workflow';
|
|
2
2
|
import z14, { z } from 'zod';
|
|
3
3
|
import { randomUUID, randomFillSync } from 'crypto';
|
|
4
4
|
import { ApplicationFailure as ApplicationFailure$1 } from '@temporalio/common';
|
|
@@ -111,7 +111,7 @@ function createToolRouter(options) {
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
async function processToolCall(toolCall, turn, sandboxId) {
|
|
114
|
+
async function processToolCall(toolCall, turn, sandboxId, onRewindRequested) {
|
|
115
115
|
const startTime = Date.now();
|
|
116
116
|
const tool = toolMap.get(toolCall.name);
|
|
117
117
|
const preResult = await runPreHooks(toolCall, tool, turn);
|
|
@@ -126,7 +126,7 @@ function createToolRouter(options) {
|
|
|
126
126
|
reason: "Skipped by PreToolUse hook"
|
|
127
127
|
})
|
|
128
128
|
});
|
|
129
|
-
return
|
|
129
|
+
return { kind: "skipped" };
|
|
130
130
|
}
|
|
131
131
|
const effectiveArgs = preResult.args;
|
|
132
132
|
log.debug("tool call dispatched", {
|
|
@@ -138,6 +138,7 @@ function createToolRouter(options) {
|
|
|
138
138
|
let content;
|
|
139
139
|
let resultAppended = false;
|
|
140
140
|
let metadata;
|
|
141
|
+
let rewindRequested = false;
|
|
141
142
|
try {
|
|
142
143
|
if (tool) {
|
|
143
144
|
const routerContext = {
|
|
@@ -155,11 +156,15 @@ function createToolRouter(options) {
|
|
|
155
156
|
content = response.toolResponse;
|
|
156
157
|
resultAppended = response.resultAppended === true;
|
|
157
158
|
metadata = response.metadata;
|
|
159
|
+
rewindRequested = response.rewind === true;
|
|
158
160
|
} else {
|
|
159
161
|
result = { error: `Unknown tool: ${toolCall.name}` };
|
|
160
162
|
content = JSON.stringify(result, null, 2);
|
|
161
163
|
}
|
|
162
164
|
} catch (error) {
|
|
165
|
+
if (isCancellation(error)) {
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
163
168
|
log.warn("tool call failed", {
|
|
164
169
|
toolName: toolCall.name,
|
|
165
170
|
toolCallId: toolCall.id,
|
|
@@ -177,6 +182,15 @@ function createToolRouter(options) {
|
|
|
177
182
|
result = recovery.result;
|
|
178
183
|
content = recovery.content;
|
|
179
184
|
}
|
|
185
|
+
if (rewindRequested) {
|
|
186
|
+
const signal = {
|
|
187
|
+
toolCallId: toolCall.id,
|
|
188
|
+
toolName: toolCall.name
|
|
189
|
+
};
|
|
190
|
+
log.info("tool requested rewind", { ...signal });
|
|
191
|
+
onRewindRequested?.(signal);
|
|
192
|
+
return { kind: "rewind", signal };
|
|
193
|
+
}
|
|
180
194
|
if (!resultAppended) {
|
|
181
195
|
const config = {
|
|
182
196
|
threadId: options.threadId,
|
|
@@ -213,7 +227,7 @@ function createToolRouter(options) {
|
|
|
213
227
|
turn,
|
|
214
228
|
durationMs
|
|
215
229
|
);
|
|
216
|
-
return toolResult;
|
|
230
|
+
return { kind: "result", value: toolResult };
|
|
217
231
|
}
|
|
218
232
|
return {
|
|
219
233
|
hasTools() {
|
|
@@ -248,27 +262,59 @@ function createToolRouter(options) {
|
|
|
248
262
|
}));
|
|
249
263
|
},
|
|
250
264
|
async processToolCalls(toolCalls, context) {
|
|
265
|
+
const attachRewind = (arr, rewind) => {
|
|
266
|
+
if (rewind) {
|
|
267
|
+
arr.rewind = rewind;
|
|
268
|
+
}
|
|
269
|
+
return arr;
|
|
270
|
+
};
|
|
251
271
|
if (toolCalls.length === 0) {
|
|
252
|
-
return [];
|
|
272
|
+
return attachRewind([], void 0);
|
|
253
273
|
}
|
|
254
274
|
const turn = context?.turn ?? 0;
|
|
255
275
|
const sandboxId = context?.sandboxId;
|
|
276
|
+
let rewindSignal;
|
|
256
277
|
if (options.parallel) {
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
278
|
+
const scope = new CancellationScope({ cancellable: true });
|
|
279
|
+
const onRewindRequested = (signal) => {
|
|
280
|
+
if (!rewindSignal) {
|
|
281
|
+
rewindSignal = signal;
|
|
282
|
+
scope.cancel();
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
const outcomes = await scope.run(
|
|
286
|
+
async () => Promise.allSettled(
|
|
287
|
+
toolCalls.map(
|
|
288
|
+
(tc) => processToolCall(tc, turn, sandboxId, onRewindRequested)
|
|
289
|
+
)
|
|
290
|
+
)
|
|
262
291
|
);
|
|
292
|
+
const results2 = [];
|
|
293
|
+
for (const outcome of outcomes) {
|
|
294
|
+
if (outcome.status === "rejected") {
|
|
295
|
+
if (isCancellation(outcome.reason)) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
throw outcome.reason;
|
|
299
|
+
}
|
|
300
|
+
if (outcome.value.kind === "result") {
|
|
301
|
+
results2.push(outcome.value.value);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return attachRewind(results2, rewindSignal);
|
|
263
305
|
}
|
|
264
306
|
const results = [];
|
|
265
307
|
for (const toolCall of toolCalls) {
|
|
266
|
-
const
|
|
267
|
-
if (
|
|
268
|
-
|
|
308
|
+
const outcome = await processToolCall(toolCall, turn, sandboxId);
|
|
309
|
+
if (outcome.kind === "rewind") {
|
|
310
|
+
rewindSignal = outcome.signal;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
if (outcome.kind === "result") {
|
|
314
|
+
results.push(outcome.value);
|
|
269
315
|
}
|
|
270
316
|
}
|
|
271
|
-
return results;
|
|
317
|
+
return attachRewind(results, rewindSignal);
|
|
272
318
|
},
|
|
273
319
|
async processToolCallsByName(toolCalls, toolName, handler, context) {
|
|
274
320
|
const matchingCalls = toolCalls.filter((tc) => tc.name === toolName);
|
|
@@ -865,7 +911,8 @@ async function createSession({
|
|
|
865
911
|
initializeThread,
|
|
866
912
|
appendSystemMessage,
|
|
867
913
|
appendAgentMessage,
|
|
868
|
-
forkThread
|
|
914
|
+
forkThread,
|
|
915
|
+
truncateThread
|
|
869
916
|
} = threadOps;
|
|
870
917
|
const plugins = [];
|
|
871
918
|
let destroySubagentSandboxes;
|
|
@@ -959,8 +1006,10 @@ async function createSession({
|
|
|
959
1006
|
nonRetryable: true
|
|
960
1007
|
});
|
|
961
1008
|
}
|
|
1009
|
+
const forkInit = sandboxInit;
|
|
962
1010
|
sandboxId = await sandboxOps.forkSandbox(
|
|
963
|
-
|
|
1011
|
+
forkInit.sandboxId,
|
|
1012
|
+
forkInit.options
|
|
964
1013
|
);
|
|
965
1014
|
sandboxOwned = true;
|
|
966
1015
|
} else if (sandboxMode === "from-snapshot") {
|
|
@@ -970,8 +1019,11 @@ async function createSession({
|
|
|
970
1019
|
nonRetryable: true
|
|
971
1020
|
});
|
|
972
1021
|
}
|
|
973
|
-
const
|
|
974
|
-
sandboxId = await sandboxOps.restoreSandbox(
|
|
1022
|
+
const restoreInit = sandboxInit;
|
|
1023
|
+
sandboxId = await sandboxOps.restoreSandbox(
|
|
1024
|
+
restoreInit.snapshot,
|
|
1025
|
+
restoreInit.options
|
|
1026
|
+
);
|
|
975
1027
|
sandboxOwned = true;
|
|
976
1028
|
} else if (sandboxOps) {
|
|
977
1029
|
const skillFiles = skills ? collectSkillFiles(skills) : void 0;
|
|
@@ -1060,12 +1112,18 @@ async function createSession({
|
|
|
1060
1112
|
const currentTurn = stateManager.getTurns();
|
|
1061
1113
|
log.debug("turn started", { agentName, threadId, turn: currentTurn });
|
|
1062
1114
|
stateManager.setTools(toolRouter.getToolDefinitions());
|
|
1063
|
-
const {
|
|
1115
|
+
const {
|
|
1116
|
+
message,
|
|
1117
|
+
rawToolCalls,
|
|
1118
|
+
usage,
|
|
1119
|
+
threadLengthAtCall
|
|
1120
|
+
} = await runAgent({
|
|
1064
1121
|
threadId,
|
|
1065
1122
|
threadKey,
|
|
1066
1123
|
agentName,
|
|
1067
1124
|
metadata
|
|
1068
1125
|
});
|
|
1126
|
+
const preAssistantLength = threadLengthAtCall;
|
|
1069
1127
|
await appendAgentMessage(threadId, uuid4(), message, threadKey);
|
|
1070
1128
|
if (usage) {
|
|
1071
1129
|
stateManager.updateUsage(usage);
|
|
@@ -1111,6 +1169,24 @@ async function createSession({
|
|
|
1111
1169
|
stateManager.updateUsage(result.usage);
|
|
1112
1170
|
}
|
|
1113
1171
|
}
|
|
1172
|
+
const rewind = toolCallResults.rewind;
|
|
1173
|
+
if (rewind) {
|
|
1174
|
+
log.info("rewinding turn", {
|
|
1175
|
+
agentName,
|
|
1176
|
+
threadId,
|
|
1177
|
+
turn: currentTurn,
|
|
1178
|
+
toolCallId: rewind.toolCallId,
|
|
1179
|
+
toolName: rewind.toolName
|
|
1180
|
+
});
|
|
1181
|
+
if (preAssistantLength === void 0) {
|
|
1182
|
+
throw ApplicationFailure.create({
|
|
1183
|
+
message: "Rewind requested but runAgent did not report `threadLengthAtCall`; the adapter must populate it to support rewinds.",
|
|
1184
|
+
nonRetryable: true
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
await truncateThread(threadId, preAssistantLength, threadKey);
|
|
1188
|
+
continue;
|
|
1189
|
+
}
|
|
1114
1190
|
if (stateManager.getStatus() === "WAITING_FOR_INPUT") {
|
|
1115
1191
|
const conditionMet = await condition(
|
|
1116
1192
|
() => stateManager.getStatus() === "RUNNING",
|
|
@@ -2332,6 +2408,20 @@ function createThreadManager(config) {
|
|
|
2332
2408
|
},
|
|
2333
2409
|
async delete() {
|
|
2334
2410
|
await redis.del(redisKey, metaKey);
|
|
2411
|
+
},
|
|
2412
|
+
async length() {
|
|
2413
|
+
await assertThreadExists();
|
|
2414
|
+
return redis.llen(redisKey);
|
|
2415
|
+
},
|
|
2416
|
+
async truncate(length) {
|
|
2417
|
+
await assertThreadExists();
|
|
2418
|
+
if (length <= 0) {
|
|
2419
|
+
await redis.del(redisKey);
|
|
2420
|
+
await redis.expire(metaKey, THREAD_TTL_SECONDS);
|
|
2421
|
+
} else {
|
|
2422
|
+
await redis.ltrim(redisKey, 0, length - 1);
|
|
2423
|
+
await redis.expire(redisKey, THREAD_TTL_SECONDS);
|
|
2424
|
+
}
|
|
2335
2425
|
}
|
|
2336
2426
|
};
|
|
2337
2427
|
}
|
|
@@ -2418,18 +2508,18 @@ var SandboxManager = class {
|
|
|
2418
2508
|
async resume(id) {
|
|
2419
2509
|
await this.provider.resume(id);
|
|
2420
2510
|
}
|
|
2421
|
-
async snapshot(id) {
|
|
2422
|
-
return this.provider.snapshot(id);
|
|
2511
|
+
async snapshot(id, options) {
|
|
2512
|
+
return this.provider.snapshot(id, options);
|
|
2423
2513
|
}
|
|
2424
|
-
async restore(snapshot) {
|
|
2425
|
-
const sandbox = await this.provider.restore(snapshot);
|
|
2514
|
+
async restore(snapshot, options) {
|
|
2515
|
+
const sandbox = await this.provider.restore(snapshot, options);
|
|
2426
2516
|
return sandbox.id;
|
|
2427
2517
|
}
|
|
2428
2518
|
async deleteSnapshot(snapshot) {
|
|
2429
2519
|
await this.provider.deleteSnapshot(snapshot);
|
|
2430
2520
|
}
|
|
2431
|
-
async fork(sandboxId) {
|
|
2432
|
-
const sandbox = await this.provider.fork(sandboxId);
|
|
2521
|
+
async fork(sandboxId, options) {
|
|
2522
|
+
const sandbox = await this.provider.fork(sandboxId, options);
|
|
2433
2523
|
return sandbox.id;
|
|
2434
2524
|
}
|
|
2435
2525
|
/**
|
|
@@ -2467,17 +2557,17 @@ var SandboxManager = class {
|
|
|
2467
2557
|
resumeSandbox: async (sandboxId) => {
|
|
2468
2558
|
await this.resume(sandboxId);
|
|
2469
2559
|
},
|
|
2470
|
-
snapshotSandbox: async (sandboxId) => {
|
|
2471
|
-
return this.snapshot(sandboxId);
|
|
2560
|
+
snapshotSandbox: async (sandboxId, options) => {
|
|
2561
|
+
return this.snapshot(sandboxId, options);
|
|
2472
2562
|
},
|
|
2473
|
-
restoreSandbox: async (snapshot) => {
|
|
2474
|
-
return this.restore(snapshot);
|
|
2563
|
+
restoreSandbox: async (snapshot, options) => {
|
|
2564
|
+
return this.restore(snapshot, options);
|
|
2475
2565
|
},
|
|
2476
2566
|
deleteSandboxSnapshot: async (snapshot) => {
|
|
2477
2567
|
await this.deleteSnapshot(snapshot);
|
|
2478
2568
|
},
|
|
2479
|
-
forkSandbox: async (sandboxId) => {
|
|
2480
|
-
return this.fork(sandboxId);
|
|
2569
|
+
forkSandbox: async (sandboxId, options) => {
|
|
2570
|
+
return this.fork(sandboxId, options);
|
|
2481
2571
|
}
|
|
2482
2572
|
};
|
|
2483
2573
|
const cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|