zeitlich 0.2.36 → 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/README.md +146 -92
- package/dist/{activities-BVI2lTwr.d.ts → activities-BKhMtKDd.d.ts} +4 -2
- package/dist/{activities-hd4aNnZE.d.cts → activities-CDcwkRZs.d.cts} +4 -2
- package/dist/adapters/sandbox/bedrock/index.cjs +17 -14
- package/dist/adapters/sandbox/bedrock/index.cjs.map +1 -1
- package/dist/adapters/sandbox/bedrock/index.d.cts +7 -6
- package/dist/adapters/sandbox/bedrock/index.d.ts +7 -6
- package/dist/adapters/sandbox/bedrock/index.js +17 -14
- package/dist/adapters/sandbox/bedrock/index.js.map +1 -1
- package/dist/adapters/sandbox/bedrock/workflow.cjs +2 -0
- package/dist/adapters/sandbox/bedrock/workflow.cjs.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/bedrock/workflow.js +2 -0
- package/dist/adapters/sandbox/bedrock/workflow.js.map +1 -1
- package/dist/adapters/sandbox/daytona/index.cjs +11 -3
- package/dist/adapters/sandbox/daytona/index.cjs.map +1 -1
- package/dist/adapters/sandbox/daytona/index.d.cts +5 -4
- package/dist/adapters/sandbox/daytona/index.d.ts +5 -4
- package/dist/adapters/sandbox/daytona/index.js +11 -3
- package/dist/adapters/sandbox/daytona/index.js.map +1 -1
- package/dist/adapters/sandbox/daytona/workflow.cjs +2 -0
- package/dist/adapters/sandbox/daytona/workflow.cjs.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/daytona/workflow.js +2 -0
- package/dist/adapters/sandbox/daytona/workflow.js.map +1 -1
- package/dist/adapters/sandbox/e2b/index.cjs +73 -12
- package/dist/adapters/sandbox/e2b/index.cjs.map +1 -1
- package/dist/adapters/sandbox/e2b/index.d.cts +26 -4
- package/dist/adapters/sandbox/e2b/index.d.ts +26 -4
- package/dist/adapters/sandbox/e2b/index.js +73 -12
- package/dist/adapters/sandbox/e2b/index.js.map +1 -1
- package/dist/adapters/sandbox/e2b/workflow.cjs +2 -0
- package/dist/adapters/sandbox/e2b/workflow.cjs.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/e2b/workflow.js +2 -0
- package/dist/adapters/sandbox/e2b/workflow.js.map +1 -1
- package/dist/adapters/sandbox/inmemory/index.cjs +8 -3
- package/dist/adapters/sandbox/inmemory/index.cjs.map +1 -1
- package/dist/adapters/sandbox/inmemory/index.d.cts +5 -4
- package/dist/adapters/sandbox/inmemory/index.d.ts +5 -4
- package/dist/adapters/sandbox/inmemory/index.js +8 -3
- package/dist/adapters/sandbox/inmemory/index.js.map +1 -1
- package/dist/adapters/sandbox/inmemory/workflow.cjs +2 -0
- package/dist/adapters/sandbox/inmemory/workflow.cjs.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/sandbox/inmemory/workflow.js +2 -0
- package/dist/adapters/sandbox/inmemory/workflow.js.map +1 -1
- package/dist/adapters/thread/anthropic/index.cjs +94 -39
- 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 +94 -39
- package/dist/adapters/thread/anthropic/index.js.map +1 -1
- package/dist/adapters/thread/anthropic/workflow.cjs +7 -2
- 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 +7 -2
- package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
- package/dist/adapters/thread/google-genai/index.cjs +77 -28
- 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 +77 -28
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.cjs +7 -2
- 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 +7 -2
- package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
- package/dist/adapters/thread/langchain/index.cjs +57 -10
- 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 +57 -10
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/adapters/thread/langchain/workflow.cjs +7 -2
- 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 +7 -2
- package/dist/adapters/thread/langchain/workflow.js.map +1 -1
- package/dist/index.cjs +322 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -14
- package/dist/index.d.ts +20 -14
- package/dist/index.js +323 -147
- package/dist/index.js.map +1 -1
- package/dist/{proxy-BjdFGPTm.d.ts → proxy-CUlKSvZS.d.ts} +1 -1
- package/dist/{proxy-7RnVaPdJ.d.cts → proxy-D_3x7RN4.d.cts} +1 -1
- package/dist/{thread-manager-CbpiGq1L.d.ts → thread-manager-CVu7o2cs.d.ts} +4 -2
- package/dist/{thread-manager-DzXm9eeI.d.cts → thread-manager-HSwyh28L.d.cts} +4 -2
- package/dist/{thread-manager-BBzNgQWH.d.cts → thread-manager-c1gPopAG.d.ts} +4 -2
- package/dist/{thread-manager-DjN5JYul.d.ts → thread-manager-wGi-LqIP.d.cts} +4 -2
- package/dist/{types-Mc_4BCfT.d.cts → types-BH_IRryz.d.ts} +10 -1
- package/dist/{types-yiXmqedU.d.ts → types-BaOw4hKI.d.cts} +10 -1
- package/dist/{types-DQ1l_gXL.d.cts → types-C06FwR96.d.cts} +121 -17
- package/dist/{types-wiGLvxWf.d.ts → types-DAsQ21Rt.d.ts} +1 -1
- package/dist/{types-CADc5V_P.d.ts → types-DNr31FzL.d.ts} +121 -17
- package/dist/{types-CBH54cwr.d.cts → types-lm8tMNJQ.d.cts} +1 -1
- package/dist/{types-DxCpFNv_.d.cts → types-yx0LzPGn.d.cts} +44 -5
- package/dist/{types-DxCpFNv_.d.ts → types-yx0LzPGn.d.ts} +44 -5
- package/dist/{workflow-DhtWRovz.d.cts → workflow-CSCkpwAL.d.ts} +2 -2
- package/dist/{workflow-P2pTSfKu.d.ts → workflow-DuvMZ8Vm.d.cts} +2 -2
- package/dist/workflow.cjs +274 -130
- 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 +275 -131
- package/dist/workflow.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/sandbox/bedrock/filesystem.ts +6 -12
- package/src/adapters/sandbox/bedrock/index.ts +22 -11
- package/src/adapters/sandbox/bedrock/proxy.ts +2 -0
- package/src/adapters/sandbox/daytona/index.ts +18 -3
- package/src/adapters/sandbox/daytona/proxy.ts +2 -0
- package/src/adapters/sandbox/e2b/filesystem.ts +5 -4
- package/src/adapters/sandbox/e2b/index.ts +87 -14
- package/src/adapters/sandbox/e2b/proxy.ts +2 -0
- package/src/adapters/sandbox/e2b/types.ts +16 -0
- package/src/adapters/sandbox/inmemory/index.ts +17 -3
- package/src/adapters/sandbox/inmemory/proxy.ts +2 -0
- package/src/adapters/thread/anthropic/activities.ts +58 -26
- package/src/adapters/thread/anthropic/model-invoker.ts +18 -7
- package/src/adapters/thread/anthropic/proxy.ts +6 -2
- package/src/adapters/thread/anthropic/thread-manager.test.ts +26 -7
- package/src/adapters/thread/anthropic/thread-manager.ts +63 -46
- package/src/adapters/thread/google-genai/activities.ts +20 -2
- package/src/adapters/thread/google-genai/model-invoker.ts +27 -7
- package/src/adapters/thread/google-genai/proxy.ts +6 -2
- package/src/adapters/thread/google-genai/thread-manager.test.ts +13 -3
- package/src/adapters/thread/google-genai/thread-manager.ts +57 -33
- package/src/adapters/thread/langchain/activities.ts +55 -24
- package/src/adapters/thread/langchain/hooks.test.ts +36 -49
- package/src/adapters/thread/langchain/hooks.ts +18 -5
- package/src/adapters/thread/langchain/model-invoker.ts +5 -4
- package/src/adapters/thread/langchain/proxy.ts +6 -2
- package/src/adapters/thread/langchain/thread-manager.test.ts +5 -1
- package/src/adapters/thread/langchain/thread-manager.ts +23 -9
- package/src/index.ts +4 -1
- package/src/lib/activity.ts +16 -6
- package/src/lib/hooks/types.ts +6 -6
- package/src/lib/lifecycle.ts +18 -3
- package/src/lib/model/proxy.ts +2 -2
- package/src/lib/model/types.ts +10 -0
- package/src/lib/observability/hooks.ts +4 -5
- package/src/lib/observability/index.ts +1 -4
- package/src/lib/sandbox/manager.ts +45 -20
- package/src/lib/sandbox/node-fs.ts +3 -6
- package/src/lib/sandbox/sandbox.test.ts +36 -3
- package/src/lib/sandbox/tree.integration.test.ts +10 -3
- package/src/lib/sandbox/types.ts +60 -6
- package/src/lib/session/session-edge-cases.integration.test.ts +316 -14
- package/src/lib/session/session.integration.test.ts +161 -1
- package/src/lib/session/session.ts +106 -21
- package/src/lib/session/types.ts +25 -5
- package/src/lib/skills/fs-provider.ts +12 -8
- package/src/lib/skills/handler.ts +1 -1
- package/src/lib/skills/parse.ts +3 -1
- package/src/lib/skills/register.ts +1 -3
- package/src/lib/skills/skills.integration.test.ts +25 -15
- package/src/lib/state/manager.integration.test.ts +12 -2
- package/src/lib/subagent/define.ts +1 -1
- package/src/lib/subagent/handler.ts +186 -71
- package/src/lib/subagent/index.ts +1 -5
- package/src/lib/subagent/register.ts +3 -2
- package/src/lib/subagent/signals.ts +1 -10
- package/src/lib/subagent/subagent.integration.test.ts +526 -248
- package/src/lib/subagent/tool.ts +4 -3
- package/src/lib/subagent/types.ts +50 -20
- package/src/lib/subagent/workflow.ts +9 -49
- package/src/lib/thread/id.test.ts +1 -1
- package/src/lib/thread/id.ts +1 -2
- package/src/lib/thread/manager.ts +18 -0
- package/src/lib/thread/proxy.ts +4 -4
- package/src/lib/thread/types.ts +20 -3
- package/src/lib/tool-router/index.ts +3 -5
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +93 -1
- package/src/lib/tool-router/router.integration.test.ts +12 -0
- package/src/lib/tool-router/router.ts +90 -16
- package/src/lib/tool-router/types.ts +45 -4
- package/src/lib/tool-router/with-sandbox.ts +19 -5
- package/src/lib/virtual-fs/filesystem.ts +1 -1
- package/src/lib/virtual-fs/index.ts +5 -1
- package/src/lib/virtual-fs/mutations.ts +2 -4
- package/src/lib/virtual-fs/queries.ts +9 -5
- package/src/lib/virtual-fs/types.ts +4 -1
- package/src/lib/virtual-fs/virtual-fs.test.ts +9 -11
- package/src/lib/workflow.test.ts +7 -4
- package/src/lib/workflow.ts +1 -5
- package/src/tools/ask-user-question/tool.ts +1 -3
- package/src/tools/glob/handler.ts +1 -4
- package/src/tools/task-get/handler.ts +4 -5
- package/src/tools/task-list/handler.ts +1 -4
- package/src/tools/task-update/handler.ts +4 -5
- package/src/workflow.ts +22 -7
- package/tsup.config.ts +9 -6
- package/src/lib/.env +0 -1
- package/src/tools/bash/.env +0 -1
|
@@ -2,7 +2,7 @@ import { Duration } from '@temporalio/common';
|
|
|
2
2
|
import { ActivityFunctionWithOptions, QueryDefinition, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
3
3
|
import { UpdateDefinition } from '@temporalio/common/lib/interfaces';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, g as SandboxOps } from './types-
|
|
5
|
+
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, d as SandboxCreateOptions, f as SandboxSnapshot, g as SandboxOps } from './types-yx0LzPGn.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* A tool definition with a name, description, and Zod schema for arguments.
|
|
@@ -98,6 +98,17 @@ interface ToolHandlerResponse<TResult = null, TToolResponse = JsonValue> {
|
|
|
98
98
|
* payloads through Temporal's activity payload limit.
|
|
99
99
|
*/
|
|
100
100
|
resultAppended?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* When true, the session will rewind: any in-flight parallel tool calls
|
|
103
|
+
* are cancelled, previously appended tool results and the triggering
|
|
104
|
+
* assistant message are removed from the thread, and the LLM call that
|
|
105
|
+
* produced the tool calls is retried.
|
|
106
|
+
*
|
|
107
|
+
* The `toolResponse` for a rewinding tool call is ignored (never
|
|
108
|
+
* appended) since the session truncates the thread back to the
|
|
109
|
+
* pre-invocation state.
|
|
110
|
+
*/
|
|
111
|
+
rewind?: boolean;
|
|
101
112
|
/** Token usage from the tool execution (e.g. child agent invocations) */
|
|
102
113
|
usage?: TokenUsage;
|
|
103
114
|
/** Thread ID used by the handler (surfaced to the LLM for subagent thread continuation) */
|
|
@@ -186,6 +197,27 @@ interface ProcessToolCallsContext {
|
|
|
186
197
|
/** Active sandbox ID (when a sandbox is configured for this session) */
|
|
187
198
|
sandboxId?: string;
|
|
188
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Signal that a tool handler requested a rewind. Attached to the
|
|
202
|
+
* {@link ProcessToolCallsResult} so the session can roll the thread
|
|
203
|
+
* back to the pre-invocation snapshot and retry the LLM call.
|
|
204
|
+
*/
|
|
205
|
+
interface RewindSignal {
|
|
206
|
+
toolCallId: string;
|
|
207
|
+
toolName: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Result returned by {@link ToolRouter.processToolCalls}.
|
|
211
|
+
*
|
|
212
|
+
* The object is a standard array of tool call results for successful
|
|
213
|
+
* tool calls (cancelled or rewinding siblings are omitted), extended
|
|
214
|
+
* with a `rewind` property when any tool in the batch requested a
|
|
215
|
+
* rewind. Using an array-with-property lets existing code that treats
|
|
216
|
+
* the return value as `ToolCallResultUnion[]` continue to work.
|
|
217
|
+
*/
|
|
218
|
+
type ProcessToolCallsResult<TResults extends Record<string, unknown>> = ToolCallResultUnion<TResults>[] & {
|
|
219
|
+
rewind?: RewindSignal;
|
|
220
|
+
};
|
|
189
221
|
/**
|
|
190
222
|
* Result from PreToolUse hook - can block or modify execution
|
|
191
223
|
*/
|
|
@@ -344,7 +376,7 @@ interface ToolRouter<T extends ToolMap> {
|
|
|
344
376
|
* @param toolCalls - Array of parsed tool calls to process
|
|
345
377
|
* @param context - Optional context including turn number for hooks
|
|
346
378
|
*/
|
|
347
|
-
processToolCalls(toolCalls: ParsedToolCallUnion<T>[], context?: ProcessToolCallsContext): Promise<
|
|
379
|
+
processToolCalls(toolCalls: ParsedToolCallUnion<T>[], context?: ProcessToolCallsContext): Promise<ProcessToolCallsResult<InferToolResults<T>>>;
|
|
348
380
|
/**
|
|
349
381
|
* Process tool calls matching a specific name with a custom handler.
|
|
350
382
|
* Useful for overriding the default handler for specific cases.
|
|
@@ -797,6 +829,7 @@ type ThreadInit = {
|
|
|
797
829
|
mode: "fork";
|
|
798
830
|
threadId: string;
|
|
799
831
|
};
|
|
832
|
+
|
|
800
833
|
/**
|
|
801
834
|
* Sandbox initialization strategy.
|
|
802
835
|
*
|
|
@@ -807,7 +840,12 @@ type ThreadInit = {
|
|
|
807
840
|
* Paused sandboxes are automatically resumed. The shutdown policy applies
|
|
808
841
|
* on exit.
|
|
809
842
|
* - `"fork"` — fork from an existing (or paused) sandbox; a new sandbox is
|
|
810
|
-
* created and owned by this session.
|
|
843
|
+
* created and owned by this session. `options` is an optional per-call
|
|
844
|
+
* override merged on top of the provider's static defaults.
|
|
845
|
+
* - `"from-snapshot"` — restore a fresh sandbox from a previously captured
|
|
846
|
+
* {@link SandboxSnapshot}. The new sandbox is owned by this session.
|
|
847
|
+
* `options` is an optional per-call override merged on top of the
|
|
848
|
+
* provider's static defaults.
|
|
811
849
|
* - `"inherit"` — use a sandbox owned by someone else (e.g. a parent agent).
|
|
812
850
|
* The session will **not** manage its lifecycle on exit.
|
|
813
851
|
*/
|
|
@@ -820,6 +858,11 @@ type SandboxInit = {
|
|
|
820
858
|
} | {
|
|
821
859
|
mode: "fork";
|
|
822
860
|
sandboxId: string;
|
|
861
|
+
options?: SandboxCreateOptions;
|
|
862
|
+
} | {
|
|
863
|
+
mode: "from-snapshot";
|
|
864
|
+
snapshot: SandboxSnapshot;
|
|
865
|
+
options?: SandboxCreateOptions;
|
|
823
866
|
} | {
|
|
824
867
|
mode: "inherit";
|
|
825
868
|
sandboxId: string;
|
|
@@ -830,8 +873,11 @@ type SandboxInit = {
|
|
|
830
873
|
* - `"destroy"` — tear down the sandbox entirely.
|
|
831
874
|
* - `"pause"` — pause the sandbox so it can be resumed later.
|
|
832
875
|
* - `"keep"` — leave the sandbox running (no-op on exit).
|
|
876
|
+
* - `"snapshot"` — capture a snapshot then destroy the sandbox. The snapshot
|
|
877
|
+
* is surfaced on the session result so the caller can reuse it to spawn
|
|
878
|
+
* future sandboxes.
|
|
833
879
|
*/
|
|
834
|
-
type SandboxShutdown = "destroy" | "pause" | "keep";
|
|
880
|
+
type SandboxShutdown = "destroy" | "pause" | "keep" | "snapshot";
|
|
835
881
|
/**
|
|
836
882
|
* Extended shutdown options available to subagent workflows.
|
|
837
883
|
*
|
|
@@ -847,6 +893,14 @@ type SubagentSandboxShutdown = SandboxShutdown | "pause-until-parent-close" | "k
|
|
|
847
893
|
type SubagentHandlerResponse<TResult = null, TToolResponse = JsonValue> = ToolHandlerResponse<TResult, TToolResponse> & {
|
|
848
894
|
threadId: string;
|
|
849
895
|
sandboxId?: string;
|
|
896
|
+
/** Snapshot captured on session exit when `sandboxShutdown === "snapshot"`. */
|
|
897
|
+
snapshot?: SandboxSnapshot;
|
|
898
|
+
/**
|
|
899
|
+
* Snapshot captured immediately after the sandbox was seeded (before the
|
|
900
|
+
* first agent turn) when `continuation === "snapshot"`. Only set on the
|
|
901
|
+
* first call that actually created the sandbox.
|
|
902
|
+
*/
|
|
903
|
+
baseSnapshot?: SandboxSnapshot;
|
|
850
904
|
};
|
|
851
905
|
/**
|
|
852
906
|
* Raw workflow input fields passed from parent to child workflow.
|
|
@@ -876,23 +930,31 @@ type SubagentContext = Record<string, unknown> | (() => Record<string, unknown>)
|
|
|
876
930
|
* Sandbox configuration for a subagent.
|
|
877
931
|
*
|
|
878
932
|
* - `"none"` — no sandbox (default).
|
|
879
|
-
* - `{ source: "inherit", continuation }` — reuse the parent's sandbox.
|
|
933
|
+
* - `{ source: "inherit", continuation, proxy }` — reuse the parent's sandbox.
|
|
880
934
|
* `continuation: "continue"` shares the parent sandbox directly;
|
|
881
935
|
* `continuation: "fork"` forks from the parent on every call.
|
|
882
|
-
* - `{ source: "own", init?, continuation }` — the child gets its own
|
|
883
|
-
* `init: "per-call"` (default) creates fresh each call (thread
|
|
884
|
-
* uses the previous sandbox). `init: "once"` creates on the
|
|
885
|
-
* stores it for all subsequent calls.
|
|
936
|
+
* - `{ source: "own", init?, continuation, proxy }` — the child gets its own
|
|
937
|
+
* sandbox. `init: "per-call"` (default) creates fresh each call (thread
|
|
938
|
+
* continuation uses the previous sandbox). `init: "once"` creates on the
|
|
939
|
+
* first call and stores it for all subsequent calls.
|
|
940
|
+
*
|
|
941
|
+
* `proxy` is a factory that returns workflow-safe sandbox ops matching the
|
|
942
|
+
* subagent's own activities. Called once inside `createSubagentHandler` with
|
|
943
|
+
* `scope = agentName`, so the returned proxy resolves to the same activity
|
|
944
|
+
* prefix the child session uses. The parent uses it to destroy lingering
|
|
945
|
+
* sandboxes and delete stored snapshots at shutdown.
|
|
886
946
|
*/
|
|
887
947
|
type SubagentSandboxConfig = "none" | {
|
|
888
948
|
source: "inherit";
|
|
889
949
|
continuation: "continue" | "fork";
|
|
890
950
|
shutdown?: SubagentSandboxShutdown;
|
|
951
|
+
proxy: (scope: string) => SandboxOps;
|
|
891
952
|
} | {
|
|
892
953
|
source: "own";
|
|
893
954
|
init?: "per-call" | "once";
|
|
894
|
-
continuation: "continue" | "fork";
|
|
955
|
+
continuation: "continue" | "fork" | "snapshot";
|
|
895
956
|
shutdown?: SubagentSandboxShutdown;
|
|
957
|
+
proxy: (scope: string) => SandboxOps;
|
|
896
958
|
};
|
|
897
959
|
/**
|
|
898
960
|
* Configuration for a subagent that can be spawned by the parent workflow.
|
|
@@ -930,6 +992,21 @@ interface SubagentConfig<TResult extends z.ZodType = z.ZodType> {
|
|
|
930
992
|
* Sandbox strategy for this subagent.
|
|
931
993
|
*
|
|
932
994
|
* @see {@link SubagentSandboxConfig}
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* ```ts
|
|
998
|
+
* import { proxyDaytonaSandboxOps } from "zeitlich/adapters/sandbox/daytona/workflow";
|
|
999
|
+
*
|
|
1000
|
+
* const researcher: SubagentConfig = {
|
|
1001
|
+
* agentName: "researcher",
|
|
1002
|
+
* workflow: researcherWorkflow,
|
|
1003
|
+
* sandbox: {
|
|
1004
|
+
* source: "own",
|
|
1005
|
+
* continuation: "snapshot",
|
|
1006
|
+
* proxy: proxyDaytonaSandboxOps,
|
|
1007
|
+
* },
|
|
1008
|
+
* };
|
|
1009
|
+
* ```
|
|
933
1010
|
*/
|
|
934
1011
|
sandbox?: SubagentSandboxConfig;
|
|
935
1012
|
}
|
|
@@ -963,18 +1040,16 @@ interface SubagentHooks<TArgs = unknown, TResult = unknown> {
|
|
|
963
1040
|
}) => PostToolUseFailureHookResult | Promise<PostToolUseFailureHookResult>;
|
|
964
1041
|
}
|
|
965
1042
|
/**
|
|
966
|
-
*
|
|
967
|
-
* stripped before signaling the parent.
|
|
1043
|
+
* Response returned from a subagent workflow `fn`.
|
|
968
1044
|
*
|
|
969
1045
|
* When `TSandboxShutdown` is `"pause-until-parent-close"` or
|
|
970
|
-
* `"keep-until-parent-close"`,
|
|
971
|
-
*
|
|
1046
|
+
* `"keep-until-parent-close"`, the parent needs the `sandboxId` to destroy
|
|
1047
|
+
* the sandbox at its own shutdown, so the field becomes required.
|
|
972
1048
|
*/
|
|
973
1049
|
type SubagentFnResult<TResult = null, TSandboxShutdown extends SubagentSandboxShutdown = SubagentSandboxShutdown> = SubagentHandlerResponse<TResult> & (TSandboxShutdown extends "pause-until-parent-close" | "keep-until-parent-close" ? {
|
|
974
|
-
destroySandbox: () => Promise<void>;
|
|
975
1050
|
sandboxId: string;
|
|
976
1051
|
} : {
|
|
977
|
-
|
|
1052
|
+
sandboxId?: string;
|
|
978
1053
|
});
|
|
979
1054
|
/**
|
|
980
1055
|
* Session config fields passed from parent to child workflow.
|
|
@@ -1045,6 +1120,16 @@ interface AgentResponse<M = unknown> {
|
|
|
1045
1120
|
message: M;
|
|
1046
1121
|
rawToolCalls: RawToolCall[];
|
|
1047
1122
|
usage?: TokenUsage;
|
|
1123
|
+
/**
|
|
1124
|
+
* Number of stored messages in the thread at the moment the LLM was
|
|
1125
|
+
* invoked — i.e. *before* the assistant message is appended. The
|
|
1126
|
+
* session uses this as a rewind snapshot so it can roll the thread
|
|
1127
|
+
* back to this exact state if a tool requests a rewind.
|
|
1128
|
+
*
|
|
1129
|
+
* Adapters compute this for free from the array of stored messages
|
|
1130
|
+
* they load when preparing the payload.
|
|
1131
|
+
*/
|
|
1132
|
+
threadLengthAtCall?: number;
|
|
1048
1133
|
}
|
|
1049
1134
|
/**
|
|
1050
1135
|
* Type signature for workflow-specific runAgent activity
|
|
@@ -1095,6 +1180,14 @@ interface ThreadOps<TContent = string> {
|
|
|
1095
1180
|
appendSystemMessage(threadId: string, id: string, content: unknown, threadKey?: string): Promise<void>;
|
|
1096
1181
|
/** Copy all messages from sourceThreadId into a new thread at targetThreadId */
|
|
1097
1182
|
forkThread(sourceThreadId: string, targetThreadId: string, threadKey?: string): Promise<void>;
|
|
1183
|
+
/**
|
|
1184
|
+
* Truncate the thread back to `length` messages. Used by the session's
|
|
1185
|
+
* rewind flow to roll the thread back before retrying a turn. The
|
|
1186
|
+
* session obtains `length` from `AgentResponse.threadLengthAtCall`,
|
|
1187
|
+
* which the model invoker computes for free from the messages it
|
|
1188
|
+
* loaded before invoking the LLM.
|
|
1189
|
+
*/
|
|
1190
|
+
truncateThread(threadId: string, length: number, threadKey?: string): Promise<void>;
|
|
1098
1191
|
}
|
|
1099
1192
|
/**
|
|
1100
1193
|
* Composes an adapter prefix + workflow scope for activity naming.
|
|
@@ -1221,6 +1314,17 @@ type SessionResult<M, TState extends JsonSerializable<TState>, HasSandbox extend
|
|
|
1221
1314
|
finalMessage: M | null;
|
|
1222
1315
|
exitReason: SessionExitReason;
|
|
1223
1316
|
usage: ReturnType<AgentStateManager<TState>["getTotalUsage"]>;
|
|
1317
|
+
/**
|
|
1318
|
+
* Snapshot captured on exit when `sandboxShutdown === "snapshot"`.
|
|
1319
|
+
*/
|
|
1320
|
+
snapshot?: SandboxSnapshot;
|
|
1321
|
+
/**
|
|
1322
|
+
* Snapshot captured immediately after sandbox seeding (before the agent
|
|
1323
|
+
* loop starts) when `sandbox.mode === "new"` and
|
|
1324
|
+
* `sandboxShutdown === "snapshot"`. Intended as a reusable "base" for new
|
|
1325
|
+
* threads that want to skip re-seeding.
|
|
1326
|
+
*/
|
|
1327
|
+
baseSnapshot?: SandboxSnapshot;
|
|
1224
1328
|
} & (HasSandbox extends true ? {
|
|
1225
1329
|
sandboxId: string;
|
|
1226
1330
|
} : {
|
|
@@ -1232,4 +1336,4 @@ interface ZeitlichSession<M = unknown, HasSandbox extends boolean = boolean> {
|
|
|
1232
1336
|
}): Promise<SessionResult<M, T, HasSandbox>>;
|
|
1233
1337
|
}
|
|
1234
1338
|
|
|
1235
|
-
export { type
|
|
1339
|
+
export { type SerializableToolDefinition as $, type AgentResponse as A, type BaseAgentState as B, type PostToolUseFailureHookResult as C, type PostToolUseHook as D, type PostToolUseHookContext as E, type FileEntryMetadata as F, type PreHumanMessageAppendHook as G, type Hooks as H, type InferToolResults as I, type JsonValue as J, type PreHumanMessageAppendHookContext as K, type PreToolUseHook as L, type ModelInvokerConfig as M, type PreToolUseHookContext as N, type PreToolUseHookResult as O, type PrefixedThreadOps as P, type ProcessToolCallsContext as Q, type RouterContext as R, type ScopedPrefix as S, type ThreadOps as T, type ProcessToolCallsResult as U, type VirtualFsContext as V, type RawToolCall as W, type RewindSignal as X, type RunAgentActivity as Y, type SandboxInit as Z, type SandboxShutdown as _, type ModelInvoker as a, type SessionConfig as a0, type SessionEndHook as a1, type SessionEndHookContext as a2, type SessionExitReason as a3, type SessionResult as a4, type SessionStartHook as a5, type SessionStartHookContext as a6, type SubagentConfig as a7, type SubagentDefinition as a8, type SubagentFnResult as a9, type WorkflowTask as aA, type ZeitlichSession as aB, isTerminalStatus as aC, type ToolRouterOptions as aD, type SubagentHandlerResponse as aa, type SubagentHooks as ab, type SubagentSandboxConfig as ac, type SubagentSandboxShutdown as ad, type SubagentSessionInput as ae, type SubagentWorkflow as af, type SubagentWorkflowInput as ag, type TaskStatus as ah, type ThreadInit as ai, type TokenUsage as aj, type ToolArgs as ak, type ToolCallResult as al, type ToolCallResultUnion as am, type ToolDefinition as an, type ToolHandler as ao, type ToolHooks as ap, type ToolMap as aq, type ToolNames as ar, type ToolResult as as, type ToolRouter as at, type ToolRouterHooks as au, type ToolWithHandler as av, VirtualFileSystem as aw, type VirtualFileTree as ax, type VirtualFsOps as ay, type VirtualFsState as az, type ToolHandlerResponse as b, type ActivityToolHandler as c, type ToolResultConfig as d, type RunAgentConfig as e, type SkillProvider as f, type SkillMetadata as g, type Skill as h, type FileResolver as i, type TreeMutation as j, type PrefixedVirtualFsOps as k, type AgentConfig as l, type AgentFile as m, type AgentState as n, type AgentStateManager as o, type AgentStatus as p, type AppendToolResultFn as q, type FileEntry as r, type JsonPrimitive as s, type JsonSerializable as t, type ParsedToolCall as u, type ParsedToolCallUnion as v, type PostHumanMessageAppendHook as w, type PostHumanMessageAppendHookContext as x, type PostToolUseFailureHook as y, type PostToolUseFailureHookContext as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-
|
|
1
|
+
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-yx0LzPGn.cjs';
|
|
2
2
|
import { BedrockAgentCoreClient, BedrockAgentCoreClientConfig } from '@aws-sdk/client-bedrock-agentcore';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -13,6 +13,15 @@ interface FileStat {
|
|
|
13
13
|
size: number;
|
|
14
14
|
mtime: Date;
|
|
15
15
|
}
|
|
16
|
+
interface SandboxNetworkConfig {
|
|
17
|
+
allowOut?: string[];
|
|
18
|
+
denyOut?: string[];
|
|
19
|
+
allowPublicTraffic?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface SandboxLifecycleConfig {
|
|
22
|
+
onTimeout: "kill" | "pause";
|
|
23
|
+
autoResume?: boolean;
|
|
24
|
+
}
|
|
16
25
|
/**
|
|
17
26
|
* Provider-agnostic filesystem interface.
|
|
18
27
|
*
|
|
@@ -83,6 +92,16 @@ interface SandboxCreateOptions {
|
|
|
83
92
|
initialFiles?: Record<string, string | Uint8Array>;
|
|
84
93
|
/** Environment variables available inside the sandbox */
|
|
85
94
|
env?: Record<string, string>;
|
|
95
|
+
/** Key-value metadata surfaced via provider list/query APIs */
|
|
96
|
+
metadata?: Record<string, string>;
|
|
97
|
+
/** Sandbox idle timeout in milliseconds */
|
|
98
|
+
timeoutMs?: number;
|
|
99
|
+
/** Enable or disable outbound internet access */
|
|
100
|
+
allowInternetAccess?: boolean;
|
|
101
|
+
/** Outbound network allow/deny rules */
|
|
102
|
+
network?: SandboxNetworkConfig;
|
|
103
|
+
/** Sandbox timeout behaviour */
|
|
104
|
+
lifecycle?: SandboxLifecycleConfig;
|
|
86
105
|
}
|
|
87
106
|
interface SandboxCreateResult {
|
|
88
107
|
sandbox: Sandbox;
|
|
@@ -96,9 +115,23 @@ interface SandboxProvider<TOptions extends SandboxCreateOptions = SandboxCreateO
|
|
|
96
115
|
pause(sandboxId: string, ttlSeconds?: number): Promise<void>;
|
|
97
116
|
/** Resume a paused sandbox. No-op if already running. */
|
|
98
117
|
resume(sandboxId: string): Promise<void>;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Capture a snapshot of a running sandbox. `options` is a per-call override
|
|
120
|
+
* merged on top of the provider's static defaults.
|
|
121
|
+
*/
|
|
122
|
+
snapshot(sandboxId: string, options?: TOptions): Promise<SandboxSnapshot>;
|
|
123
|
+
/**
|
|
124
|
+
* Restore a sandbox from a snapshot. `options` is a per-call override
|
|
125
|
+
* merged on top of the provider's static defaults.
|
|
126
|
+
*/
|
|
127
|
+
restore(snapshot: SandboxSnapshot, options?: TOptions): Promise<Sandbox>;
|
|
128
|
+
/** Delete a previously captured snapshot. No-op if already deleted. */
|
|
129
|
+
deleteSnapshot(snapshot: SandboxSnapshot): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Fork a running sandbox into a new one. `options` is a per-call override
|
|
132
|
+
* merged on top of the provider's static defaults.
|
|
133
|
+
*/
|
|
134
|
+
fork(sandboxId: string, options?: TOptions): Promise<Sandbox>;
|
|
102
135
|
}
|
|
103
136
|
interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOptions, TCtx = unknown> {
|
|
104
137
|
createSandbox(options?: TOptions, ctx?: TCtx): Promise<{
|
|
@@ -108,8 +141,14 @@ interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOption
|
|
|
108
141
|
pauseSandbox(sandboxId: string): Promise<void>;
|
|
109
142
|
/** Resume a paused sandbox. No-op if already running. */
|
|
110
143
|
resumeSandbox(sandboxId: string): Promise<void>;
|
|
111
|
-
|
|
112
|
-
|
|
144
|
+
/** Capture a snapshot. `options` is a per-call override merged on top of provider defaults. */
|
|
145
|
+
snapshotSandbox(sandboxId: string, options?: TOptions): Promise<SandboxSnapshot>;
|
|
146
|
+
/** Create a fresh sandbox from a snapshot. `options` is a per-call override merged on top of provider defaults. */
|
|
147
|
+
restoreSandbox(snapshot: SandboxSnapshot, options?: TOptions): Promise<string>;
|
|
148
|
+
/** Delete a previously captured snapshot. No-op if already deleted. */
|
|
149
|
+
deleteSandboxSnapshot(snapshot: SandboxSnapshot): Promise<void>;
|
|
150
|
+
/** Fork a running sandbox. `options` is a per-call override merged on top of provider defaults. */
|
|
151
|
+
forkSandbox(sandboxId: string, options?: TOptions): Promise<string>;
|
|
113
152
|
}
|
|
114
153
|
/**
|
|
115
154
|
* Maps generic {@link SandboxOps} method names to adapter-prefixed names.
|
|
@@ -13,6 +13,15 @@ interface FileStat {
|
|
|
13
13
|
size: number;
|
|
14
14
|
mtime: Date;
|
|
15
15
|
}
|
|
16
|
+
interface SandboxNetworkConfig {
|
|
17
|
+
allowOut?: string[];
|
|
18
|
+
denyOut?: string[];
|
|
19
|
+
allowPublicTraffic?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface SandboxLifecycleConfig {
|
|
22
|
+
onTimeout: "kill" | "pause";
|
|
23
|
+
autoResume?: boolean;
|
|
24
|
+
}
|
|
16
25
|
/**
|
|
17
26
|
* Provider-agnostic filesystem interface.
|
|
18
27
|
*
|
|
@@ -83,6 +92,16 @@ interface SandboxCreateOptions {
|
|
|
83
92
|
initialFiles?: Record<string, string | Uint8Array>;
|
|
84
93
|
/** Environment variables available inside the sandbox */
|
|
85
94
|
env?: Record<string, string>;
|
|
95
|
+
/** Key-value metadata surfaced via provider list/query APIs */
|
|
96
|
+
metadata?: Record<string, string>;
|
|
97
|
+
/** Sandbox idle timeout in milliseconds */
|
|
98
|
+
timeoutMs?: number;
|
|
99
|
+
/** Enable or disable outbound internet access */
|
|
100
|
+
allowInternetAccess?: boolean;
|
|
101
|
+
/** Outbound network allow/deny rules */
|
|
102
|
+
network?: SandboxNetworkConfig;
|
|
103
|
+
/** Sandbox timeout behaviour */
|
|
104
|
+
lifecycle?: SandboxLifecycleConfig;
|
|
86
105
|
}
|
|
87
106
|
interface SandboxCreateResult {
|
|
88
107
|
sandbox: Sandbox;
|
|
@@ -96,9 +115,23 @@ interface SandboxProvider<TOptions extends SandboxCreateOptions = SandboxCreateO
|
|
|
96
115
|
pause(sandboxId: string, ttlSeconds?: number): Promise<void>;
|
|
97
116
|
/** Resume a paused sandbox. No-op if already running. */
|
|
98
117
|
resume(sandboxId: string): Promise<void>;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Capture a snapshot of a running sandbox. `options` is a per-call override
|
|
120
|
+
* merged on top of the provider's static defaults.
|
|
121
|
+
*/
|
|
122
|
+
snapshot(sandboxId: string, options?: TOptions): Promise<SandboxSnapshot>;
|
|
123
|
+
/**
|
|
124
|
+
* Restore a sandbox from a snapshot. `options` is a per-call override
|
|
125
|
+
* merged on top of the provider's static defaults.
|
|
126
|
+
*/
|
|
127
|
+
restore(snapshot: SandboxSnapshot, options?: TOptions): Promise<Sandbox>;
|
|
128
|
+
/** Delete a previously captured snapshot. No-op if already deleted. */
|
|
129
|
+
deleteSnapshot(snapshot: SandboxSnapshot): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Fork a running sandbox into a new one. `options` is a per-call override
|
|
132
|
+
* merged on top of the provider's static defaults.
|
|
133
|
+
*/
|
|
134
|
+
fork(sandboxId: string, options?: TOptions): Promise<Sandbox>;
|
|
102
135
|
}
|
|
103
136
|
interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOptions, TCtx = unknown> {
|
|
104
137
|
createSandbox(options?: TOptions, ctx?: TCtx): Promise<{
|
|
@@ -108,8 +141,14 @@ interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOption
|
|
|
108
141
|
pauseSandbox(sandboxId: string): Promise<void>;
|
|
109
142
|
/** Resume a paused sandbox. No-op if already running. */
|
|
110
143
|
resumeSandbox(sandboxId: string): Promise<void>;
|
|
111
|
-
|
|
112
|
-
|
|
144
|
+
/** Capture a snapshot. `options` is a per-call override merged on top of provider defaults. */
|
|
145
|
+
snapshotSandbox(sandboxId: string, options?: TOptions): Promise<SandboxSnapshot>;
|
|
146
|
+
/** Create a fresh sandbox from a snapshot. `options` is a per-call override merged on top of provider defaults. */
|
|
147
|
+
restoreSandbox(snapshot: SandboxSnapshot, options?: TOptions): Promise<string>;
|
|
148
|
+
/** Delete a previously captured snapshot. No-op if already deleted. */
|
|
149
|
+
deleteSandboxSnapshot(snapshot: SandboxSnapshot): Promise<void>;
|
|
150
|
+
/** Fork a running sandbox. `options` is a per-call override merged on top of provider defaults. */
|
|
151
|
+
forkSandbox(sandboxId: string, options?: TOptions): Promise<string>;
|
|
113
152
|
}
|
|
114
153
|
/**
|
|
115
154
|
* Maps generic {@link SandboxOps} method names to adapter-prefixed names.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { g as SandboxOps } from './types-
|
|
1
|
+
import { aq as ToolMap, a0 as SessionConfig, aB as ZeitlichSession, _ as SandboxShutdown, ai as ThreadInit, Z as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aD as ToolRouterOptions, at as ToolRouter, R as RouterContext, J as JsonValue, av as ToolWithHandler, v as ParsedToolCallUnion, ar as ToolNames, a8 as SubagentDefinition, ab as SubagentHooks, ac as SubagentSandboxConfig, a7 as SubagentConfig, ad as SubagentSandboxShutdown, ae as SubagentSessionInput, a9 as SubagentFnResult, a5 as SessionStartHook, a1 as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a3 as SessionExitReason, aj as TokenUsage, e as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, ax as VirtualFileTree, j as TreeMutation, r as FileEntry, ay as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, ao as ToolHandler, aA as WorkflowTask, c as ActivityToolHandler } from './types-DNr31FzL.js';
|
|
2
|
+
import { g as SandboxOps } from './types-yx0LzPGn.js';
|
|
3
3
|
import z$1, { z } from 'zod';
|
|
4
4
|
import { Sinks, proxyActivities } from '@temporalio/workflow';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { g as SandboxOps } from './types-
|
|
1
|
+
import { aq as ToolMap, a0 as SessionConfig, aB as ZeitlichSession, _ as SandboxShutdown, ai as ThreadInit, Z as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aD as ToolRouterOptions, at as ToolRouter, R as RouterContext, J as JsonValue, av as ToolWithHandler, v as ParsedToolCallUnion, ar as ToolNames, a8 as SubagentDefinition, ab as SubagentHooks, ac as SubagentSandboxConfig, a7 as SubagentConfig, ad as SubagentSandboxShutdown, ae as SubagentSessionInput, a9 as SubagentFnResult, a5 as SessionStartHook, a1 as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a3 as SessionExitReason, aj as TokenUsage, e as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, ax as VirtualFileTree, j as TreeMutation, r as FileEntry, ay as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, ao as ToolHandler, aA as WorkflowTask, c as ActivityToolHandler } from './types-C06FwR96.cjs';
|
|
2
|
+
import { g as SandboxOps } from './types-yx0LzPGn.cjs';
|
|
3
3
|
import z$1, { z } from 'zod';
|
|
4
4
|
import { Sinks, proxyActivities } from '@temporalio/workflow';
|
|
5
5
|
|