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.
Files changed (131) hide show
  1. package/dist/{activities-Bb-nAjwQ.d.ts → activities-BKhMtKDd.d.ts} +4 -2
  2. package/dist/{activities-vkI4_3CC.d.cts → activities-CDcwkRZs.d.cts} +4 -2
  3. package/dist/adapters/sandbox/bedrock/index.cjs +3 -3
  4. package/dist/adapters/sandbox/bedrock/index.cjs.map +1 -1
  5. package/dist/adapters/sandbox/bedrock/index.d.cts +6 -6
  6. package/dist/adapters/sandbox/bedrock/index.d.ts +6 -6
  7. package/dist/adapters/sandbox/bedrock/index.js +3 -3
  8. package/dist/adapters/sandbox/bedrock/index.js.map +1 -1
  9. package/dist/adapters/sandbox/bedrock/workflow.d.cts +2 -2
  10. package/dist/adapters/sandbox/bedrock/workflow.d.ts +2 -2
  11. package/dist/adapters/sandbox/daytona/index.cjs +3 -3
  12. package/dist/adapters/sandbox/daytona/index.cjs.map +1 -1
  13. package/dist/adapters/sandbox/daytona/index.d.cts +4 -4
  14. package/dist/adapters/sandbox/daytona/index.d.ts +4 -4
  15. package/dist/adapters/sandbox/daytona/index.js +3 -3
  16. package/dist/adapters/sandbox/daytona/index.js.map +1 -1
  17. package/dist/adapters/sandbox/daytona/workflow.d.cts +1 -1
  18. package/dist/adapters/sandbox/daytona/workflow.d.ts +1 -1
  19. package/dist/adapters/sandbox/e2b/index.cjs +26 -14
  20. package/dist/adapters/sandbox/e2b/index.cjs.map +1 -1
  21. package/dist/adapters/sandbox/e2b/index.d.cts +24 -4
  22. package/dist/adapters/sandbox/e2b/index.d.ts +24 -4
  23. package/dist/adapters/sandbox/e2b/index.js +26 -14
  24. package/dist/adapters/sandbox/e2b/index.js.map +1 -1
  25. package/dist/adapters/sandbox/e2b/workflow.d.cts +1 -1
  26. package/dist/adapters/sandbox/e2b/workflow.d.ts +1 -1
  27. package/dist/adapters/sandbox/inmemory/index.cjs +3 -3
  28. package/dist/adapters/sandbox/inmemory/index.cjs.map +1 -1
  29. package/dist/adapters/sandbox/inmemory/index.d.cts +4 -4
  30. package/dist/adapters/sandbox/inmemory/index.d.ts +4 -4
  31. package/dist/adapters/sandbox/inmemory/index.js +3 -3
  32. package/dist/adapters/sandbox/inmemory/index.js.map +1 -1
  33. package/dist/adapters/sandbox/inmemory/workflow.d.cts +1 -1
  34. package/dist/adapters/sandbox/inmemory/workflow.d.ts +1 -1
  35. package/dist/adapters/thread/anthropic/index.cjs +23 -3
  36. package/dist/adapters/thread/anthropic/index.cjs.map +1 -1
  37. package/dist/adapters/thread/anthropic/index.d.cts +5 -5
  38. package/dist/adapters/thread/anthropic/index.d.ts +5 -5
  39. package/dist/adapters/thread/anthropic/index.js +23 -3
  40. package/dist/adapters/thread/anthropic/index.js.map +1 -1
  41. package/dist/adapters/thread/anthropic/workflow.cjs +2 -1
  42. package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -1
  43. package/dist/adapters/thread/anthropic/workflow.d.cts +5 -5
  44. package/dist/adapters/thread/anthropic/workflow.d.ts +5 -5
  45. package/dist/adapters/thread/anthropic/workflow.js +2 -1
  46. package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
  47. package/dist/adapters/thread/google-genai/index.cjs +27 -3
  48. package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
  49. package/dist/adapters/thread/google-genai/index.d.cts +5 -5
  50. package/dist/adapters/thread/google-genai/index.d.ts +5 -5
  51. package/dist/adapters/thread/google-genai/index.js +27 -3
  52. package/dist/adapters/thread/google-genai/index.js.map +1 -1
  53. package/dist/adapters/thread/google-genai/workflow.cjs +2 -1
  54. package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
  55. package/dist/adapters/thread/google-genai/workflow.d.cts +5 -5
  56. package/dist/adapters/thread/google-genai/workflow.d.ts +5 -5
  57. package/dist/adapters/thread/google-genai/workflow.js +2 -1
  58. package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
  59. package/dist/adapters/thread/langchain/index.cjs +23 -3
  60. package/dist/adapters/thread/langchain/index.cjs.map +1 -1
  61. package/dist/adapters/thread/langchain/index.d.cts +5 -5
  62. package/dist/adapters/thread/langchain/index.d.ts +5 -5
  63. package/dist/adapters/thread/langchain/index.js +23 -3
  64. package/dist/adapters/thread/langchain/index.js.map +1 -1
  65. package/dist/adapters/thread/langchain/workflow.cjs +2 -1
  66. package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
  67. package/dist/adapters/thread/langchain/workflow.d.cts +5 -5
  68. package/dist/adapters/thread/langchain/workflow.d.ts +5 -5
  69. package/dist/adapters/thread/langchain/workflow.js +2 -1
  70. package/dist/adapters/thread/langchain/workflow.js.map +1 -1
  71. package/dist/index.cjs +120 -30
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.d.cts +11 -11
  74. package/dist/index.d.ts +11 -11
  75. package/dist/index.js +121 -31
  76. package/dist/index.js.map +1 -1
  77. package/dist/{proxy-0smGKvx8.d.ts → proxy-CUlKSvZS.d.ts} +1 -1
  78. package/dist/{proxy-DEtowJyd.d.cts → proxy-D_3x7RN4.d.cts} +1 -1
  79. package/dist/{thread-manager-C-C4pI2z.d.ts → thread-manager-CVu7o2cs.d.ts} +4 -2
  80. package/dist/{thread-manager-D4vgzYrh.d.cts → thread-manager-HSwyh28L.d.cts} +4 -2
  81. package/dist/{thread-manager-3fszQih4.d.ts → thread-manager-c1gPopAG.d.ts} +4 -2
  82. package/dist/{thread-manager-CzYln2OC.d.cts → thread-manager-wGi-LqIP.d.cts} +4 -2
  83. package/dist/{types-B37hKoWA.d.ts → types-BH_IRryz.d.ts} +10 -1
  84. package/dist/{types-D08CXPh8.d.cts → types-BaOw4hKI.d.cts} +10 -1
  85. package/dist/{types-CPKDl-y_.d.ts → types-C06FwR96.d.cts} +59 -4
  86. package/dist/{types-CNuWnvy9.d.ts → types-DAsQ21Rt.d.ts} +1 -1
  87. package/dist/{types-BO7Yju20.d.cts → types-DNr31FzL.d.ts} +59 -4
  88. package/dist/{types-DWEUmYAJ.d.cts → types-lm8tMNJQ.d.cts} +1 -1
  89. package/dist/{types-tQL9njTu.d.cts → types-yx0LzPGn.d.cts} +21 -7
  90. package/dist/{types-tQL9njTu.d.ts → types-yx0LzPGn.d.ts} +21 -7
  91. package/dist/{workflow-CjXHbZZc.d.ts → workflow-CSCkpwAL.d.ts} +2 -2
  92. package/dist/{workflow-Do_lzJpT.d.cts → workflow-DuvMZ8Vm.d.cts} +2 -2
  93. package/dist/workflow.cjs +94 -18
  94. package/dist/workflow.cjs.map +1 -1
  95. package/dist/workflow.d.cts +3 -3
  96. package/dist/workflow.d.ts +3 -3
  97. package/dist/workflow.js +95 -19
  98. package/dist/workflow.js.map +1 -1
  99. package/package.json +2 -2
  100. package/src/adapters/sandbox/bedrock/index.ts +12 -3
  101. package/src/adapters/sandbox/daytona/index.ts +12 -3
  102. package/src/adapters/sandbox/e2b/index.ts +36 -14
  103. package/src/adapters/sandbox/e2b/types.ts +16 -0
  104. package/src/adapters/sandbox/inmemory/index.ts +12 -3
  105. package/src/adapters/thread/anthropic/activities.ts +9 -0
  106. package/src/adapters/thread/anthropic/model-invoker.ts +3 -1
  107. package/src/adapters/thread/anthropic/thread-manager.ts +3 -0
  108. package/src/adapters/thread/google-genai/activities.ts +13 -0
  109. package/src/adapters/thread/google-genai/model-invoker.ts +3 -1
  110. package/src/adapters/thread/google-genai/thread-manager.ts +3 -0
  111. package/src/adapters/thread/langchain/activities.ts +9 -0
  112. package/src/adapters/thread/langchain/model-invoker.ts +2 -1
  113. package/src/adapters/thread/langchain/thread-manager.ts +3 -0
  114. package/src/lib/lifecycle.ts +11 -4
  115. package/src/lib/model/types.ts +10 -0
  116. package/src/lib/sandbox/manager.ts +26 -18
  117. package/src/lib/sandbox/types.ts +27 -7
  118. package/src/lib/session/session-edge-cases.integration.test.ts +265 -1
  119. package/src/lib/session/session.integration.test.ts +22 -1
  120. package/src/lib/session/session.ts +61 -7
  121. package/src/lib/session/types.ts +12 -0
  122. package/src/lib/subagent/subagent.integration.test.ts +100 -104
  123. package/src/lib/thread/manager.ts +18 -0
  124. package/src/lib/thread/proxy.ts +1 -0
  125. package/src/lib/thread/types.ts +9 -0
  126. package/src/lib/tool-router/index.ts +2 -0
  127. package/src/lib/tool-router/router-edge-cases.integration.test.ts +92 -0
  128. package/src/lib/tool-router/router.integration.test.ts +12 -0
  129. package/src/lib/tool-router/router.ts +89 -16
  130. package/src/lib/tool-router/types.ts +34 -1
  131. package/src/workflow.ts +2 -0
@@ -1,5 +1,5 @@
1
1
  import { proxyActivities, ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from './types-CPKDl-y_.js';
2
+ import { T as ThreadOps } from './types-DNr31FzL.js';
3
3
 
4
4
  /**
5
5
  * Shared proxy helper for thread operations.
@@ -1,5 +1,5 @@
1
1
  import { proxyActivities, ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from './types-BO7Yju20.cjs';
2
+ import { T as ThreadOps } from './types-C06FwR96.cjs';
3
3
 
4
4
  /**
5
5
  * Shared proxy helper for thread operations.
@@ -1,7 +1,7 @@
1
1
  import Redis from 'ioredis';
2
2
  import Anthropic from '@anthropic-ai/sdk';
3
- import { J as JsonValue } from './types-CPKDl-y_.js';
4
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-B37hKoWA.js';
3
+ import { J as JsonValue } from './types-DNr31FzL.js';
4
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BH_IRryz.js';
5
5
 
6
6
  /** SDK-native content type for Anthropic human messages */
7
7
  type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
@@ -26,6 +26,8 @@ interface AnthropicThreadManagerConfig {
26
26
  interface AnthropicInvocationPayload {
27
27
  messages: Anthropic.Messages.MessageParam[];
28
28
  system?: string | Anthropic.Messages.TextBlockParam[];
29
+ /** Number of stored messages loaded from Redis before preparation. */
30
+ storedLength: number;
29
31
  }
30
32
  /** Thread manager with Anthropic MessageParam convenience helpers */
31
33
  interface AnthropicThreadManager extends ProviderThreadManager<StoredMessage, AnthropicContent, JsonValue, AnthropicSystemContent> {
@@ -1,7 +1,7 @@
1
1
  import Redis from 'ioredis';
2
2
  import Anthropic from '@anthropic-ai/sdk';
3
- import { J as JsonValue } from './types-BO7Yju20.cjs';
4
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-D08CXPh8.cjs';
3
+ import { J as JsonValue } from './types-C06FwR96.cjs';
4
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BaOw4hKI.cjs';
5
5
 
6
6
  /** SDK-native content type for Anthropic human messages */
7
7
  type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
@@ -26,6 +26,8 @@ interface AnthropicThreadManagerConfig {
26
26
  interface AnthropicInvocationPayload {
27
27
  messages: Anthropic.Messages.MessageParam[];
28
28
  system?: string | Anthropic.Messages.TextBlockParam[];
29
+ /** Number of stored messages loaded from Redis before preparation. */
30
+ storedLength: number;
29
31
  }
30
32
  /** Thread manager with Anthropic MessageParam convenience helpers */
31
33
  interface AnthropicThreadManager extends ProviderThreadManager<StoredMessage, AnthropicContent, JsonValue, AnthropicSystemContent> {
@@ -1,7 +1,7 @@
1
1
  import Redis from 'ioredis';
2
- import { J as JsonValue } from './types-CPKDl-y_.js';
2
+ import { J as JsonValue } from './types-DNr31FzL.js';
3
3
  import { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
4
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-B37hKoWA.js';
4
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BH_IRryz.js';
5
5
 
6
6
  /** SDK-native content type for LangChain human messages */
7
7
  type LangChainContent = string | MessageContent;
@@ -18,6 +18,8 @@ interface LangChainThreadManagerConfig {
18
18
  /** Prepared payload ready to send to a LangChain chat model */
19
19
  interface LangChainInvocationPayload {
20
20
  messages: BaseMessage[];
21
+ /** Number of stored messages loaded from Redis before preparation. */
22
+ storedLength: number;
21
23
  }
22
24
  /** Thread manager with LangChain StoredMessage convenience helpers */
23
25
  interface LangChainThreadManager extends ProviderThreadManager<StoredMessage, LangChainContent, JsonValue, LangChainSystemContent> {
@@ -1,7 +1,7 @@
1
1
  import Redis from 'ioredis';
2
- import { J as JsonValue } from './types-BO7Yju20.cjs';
2
+ import { J as JsonValue } from './types-C06FwR96.cjs';
3
3
  import { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
4
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-D08CXPh8.cjs';
4
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BaOw4hKI.cjs';
5
5
 
6
6
  /** SDK-native content type for LangChain human messages */
7
7
  type LangChainContent = string | MessageContent;
@@ -18,6 +18,8 @@ interface LangChainThreadManagerConfig {
18
18
  /** Prepared payload ready to send to a LangChain chat model */
19
19
  interface LangChainInvocationPayload {
20
20
  messages: BaseMessage[];
21
+ /** Number of stored messages loaded from Redis before preparation. */
22
+ storedLength: number;
21
23
  }
22
24
  /** Thread manager with LangChain StoredMessage convenience helpers */
23
25
  interface LangChainThreadManager extends ProviderThreadManager<StoredMessage, LangChainContent, JsonValue, LangChainSystemContent> {
@@ -1,5 +1,5 @@
1
1
  import Redis from 'ioredis';
2
- import { J as JsonValue } from './types-CPKDl-y_.js';
2
+ import { J as JsonValue } from './types-DNr31FzL.js';
3
3
 
4
4
  interface ThreadManagerConfig<T> {
5
5
  redis: Redis;
@@ -36,6 +36,15 @@ interface BaseThreadManager<T> {
36
36
  fork(newThreadId: string): Promise<BaseThreadManager<T>>;
37
37
  /** Delete the thread */
38
38
  delete(): Promise<void>;
39
+ /** Get the number of stored messages currently in the thread */
40
+ length(): Promise<number>;
41
+ /**
42
+ * Truncate the thread to the given length (inclusive). Any messages
43
+ * beyond `length` are removed. When `length` is 0 the thread ends up
44
+ * empty (but still exists). Also clears any dedup markers so that
45
+ * subsequent appends with the same ids replay correctly.
46
+ */
47
+ truncate(length: number): Promise<void>;
39
48
  }
40
49
  /**
41
50
  * Shared contract for provider-specific thread managers.
@@ -1,5 +1,5 @@
1
1
  import Redis from 'ioredis';
2
- import { J as JsonValue } from './types-BO7Yju20.cjs';
2
+ import { J as JsonValue } from './types-C06FwR96.cjs';
3
3
 
4
4
  interface ThreadManagerConfig<T> {
5
5
  redis: Redis;
@@ -36,6 +36,15 @@ interface BaseThreadManager<T> {
36
36
  fork(newThreadId: string): Promise<BaseThreadManager<T>>;
37
37
  /** Delete the thread */
38
38
  delete(): Promise<void>;
39
+ /** Get the number of stored messages currently in the thread */
40
+ length(): Promise<number>;
41
+ /**
42
+ * Truncate the thread to the given length (inclusive). Any messages
43
+ * beyond `length` are removed. When `length` is 0 the thread ends up
44
+ * empty (but still exists). Also clears any dedup markers so that
45
+ * subsequent appends with the same ids replay correctly.
46
+ */
47
+ truncate(length: number): Promise<void>;
39
48
  }
40
49
  /**
41
50
  * Shared contract for provider-specific thread managers.
@@ -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, f as SandboxSnapshot, g as SandboxOps } from './types-tQL9njTu.js';
5
+ import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, d as SandboxCreateOptions, f as SandboxSnapshot, g as SandboxOps } from './types-yx0LzPGn.cjs';
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<ToolCallResultUnion<InferToolResults<T>>[]>;
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.
@@ -808,9 +840,12 @@ type ThreadInit = {
808
840
  * Paused sandboxes are automatically resumed. The shutdown policy applies
809
841
  * on exit.
810
842
  * - `"fork"` — fork from an existing (or paused) sandbox; a new sandbox is
811
- * 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.
812
845
  * - `"from-snapshot"` — restore a fresh sandbox from a previously captured
813
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.
814
849
  * - `"inherit"` — use a sandbox owned by someone else (e.g. a parent agent).
815
850
  * The session will **not** manage its lifecycle on exit.
816
851
  */
@@ -823,9 +858,11 @@ type SandboxInit = {
823
858
  } | {
824
859
  mode: "fork";
825
860
  sandboxId: string;
861
+ options?: SandboxCreateOptions;
826
862
  } | {
827
863
  mode: "from-snapshot";
828
864
  snapshot: SandboxSnapshot;
865
+ options?: SandboxCreateOptions;
829
866
  } | {
830
867
  mode: "inherit";
831
868
  sandboxId: string;
@@ -1083,6 +1120,16 @@ interface AgentResponse<M = unknown> {
1083
1120
  message: M;
1084
1121
  rawToolCalls: RawToolCall[];
1085
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;
1086
1133
  }
1087
1134
  /**
1088
1135
  * Type signature for workflow-specific runAgent activity
@@ -1133,6 +1180,14 @@ interface ThreadOps<TContent = string> {
1133
1180
  appendSystemMessage(threadId: string, id: string, content: unknown, threadKey?: string): Promise<void>;
1134
1181
  /** Copy all messages from sourceThreadId into a new thread at targetThreadId */
1135
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>;
1136
1191
  }
1137
1192
  /**
1138
1193
  * Composes an adapter prefix + workflow scope for activity naming.
@@ -1281,4 +1336,4 @@ interface ZeitlichSession<M = unknown, HasSandbox extends boolean = boolean> {
1281
1336
  }): Promise<SessionResult<M, T, HasSandbox>>;
1282
1337
  }
1283
1338
 
1284
- export { type SessionEndHook 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 RawToolCall as U, type VirtualFsContext as V, type RunAgentActivity as W, type SandboxInit as X, type SandboxShutdown as Y, type SerializableToolDefinition as Z, type SessionConfig as _, type ModelInvoker as a, type SessionEndHookContext as a0, type SessionExitReason as a1, type SessionResult as a2, type SessionStartHook as a3, type SessionStartHookContext as a4, type SubagentConfig as a5, type SubagentDefinition as a6, type SubagentFnResult as a7, type SubagentHandlerResponse as a8, type SubagentHooks as a9, isTerminalStatus as aA, type ToolRouterOptions as aB, type SubagentSandboxConfig as aa, type SubagentSandboxShutdown as ab, type SubagentSessionInput as ac, type SubagentWorkflow as ad, type SubagentWorkflowInput as ae, type TaskStatus as af, type ThreadInit as ag, type TokenUsage as ah, type ToolArgs as ai, type ToolCallResult as aj, type ToolCallResultUnion as ak, type ToolDefinition as al, type ToolHandler as am, type ToolHooks as an, type ToolMap as ao, type ToolNames as ap, type ToolResult as aq, type ToolRouter as ar, type ToolRouterHooks as as, type ToolWithHandler as at, VirtualFileSystem as au, type VirtualFileTree as av, type VirtualFsOps as aw, type VirtualFsState as ax, type WorkflowTask as ay, type ZeitlichSession 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 };
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-tQL9njTu.js';
1
+ import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-yx0LzPGn.js';
2
2
  import { BedrockAgentCoreClient, BedrockAgentCoreClientConfig } from '@aws-sdk/client-bedrock-agentcore';
3
3
 
4
4
  /**
@@ -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, f as SandboxSnapshot, g as SandboxOps } from './types-tQL9njTu.cjs';
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<ToolCallResultUnion<InferToolResults<T>>[]>;
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.
@@ -808,9 +840,12 @@ type ThreadInit = {
808
840
  * Paused sandboxes are automatically resumed. The shutdown policy applies
809
841
  * on exit.
810
842
  * - `"fork"` — fork from an existing (or paused) sandbox; a new sandbox is
811
- * 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.
812
845
  * - `"from-snapshot"` — restore a fresh sandbox from a previously captured
813
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.
814
849
  * - `"inherit"` — use a sandbox owned by someone else (e.g. a parent agent).
815
850
  * The session will **not** manage its lifecycle on exit.
816
851
  */
@@ -823,9 +858,11 @@ type SandboxInit = {
823
858
  } | {
824
859
  mode: "fork";
825
860
  sandboxId: string;
861
+ options?: SandboxCreateOptions;
826
862
  } | {
827
863
  mode: "from-snapshot";
828
864
  snapshot: SandboxSnapshot;
865
+ options?: SandboxCreateOptions;
829
866
  } | {
830
867
  mode: "inherit";
831
868
  sandboxId: string;
@@ -1083,6 +1120,16 @@ interface AgentResponse<M = unknown> {
1083
1120
  message: M;
1084
1121
  rawToolCalls: RawToolCall[];
1085
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;
1086
1133
  }
1087
1134
  /**
1088
1135
  * Type signature for workflow-specific runAgent activity
@@ -1133,6 +1180,14 @@ interface ThreadOps<TContent = string> {
1133
1180
  appendSystemMessage(threadId: string, id: string, content: unknown, threadKey?: string): Promise<void>;
1134
1181
  /** Copy all messages from sourceThreadId into a new thread at targetThreadId */
1135
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>;
1136
1191
  }
1137
1192
  /**
1138
1193
  * Composes an adapter prefix + workflow scope for activity naming.
@@ -1281,4 +1336,4 @@ interface ZeitlichSession<M = unknown, HasSandbox extends boolean = boolean> {
1281
1336
  }): Promise<SessionResult<M, T, HasSandbox>>;
1282
1337
  }
1283
1338
 
1284
- export { type SessionEndHook 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 RawToolCall as U, type VirtualFsContext as V, type RunAgentActivity as W, type SandboxInit as X, type SandboxShutdown as Y, type SerializableToolDefinition as Z, type SessionConfig as _, type ModelInvoker as a, type SessionEndHookContext as a0, type SessionExitReason as a1, type SessionResult as a2, type SessionStartHook as a3, type SessionStartHookContext as a4, type SubagentConfig as a5, type SubagentDefinition as a6, type SubagentFnResult as a7, type SubagentHandlerResponse as a8, type SubagentHooks as a9, isTerminalStatus as aA, type ToolRouterOptions as aB, type SubagentSandboxConfig as aa, type SubagentSandboxShutdown as ab, type SubagentSessionInput as ac, type SubagentWorkflow as ad, type SubagentWorkflowInput as ae, type TaskStatus as af, type ThreadInit as ag, type TokenUsage as ah, type ToolArgs as ai, type ToolCallResult as aj, type ToolCallResultUnion as ak, type ToolDefinition as al, type ToolHandler as am, type ToolHooks as an, type ToolMap as ao, type ToolNames as ap, type ToolResult as aq, type ToolRouter as ar, type ToolRouterHooks as as, type ToolWithHandler as at, VirtualFileSystem as au, type VirtualFileTree as av, type VirtualFsOps as aw, type VirtualFsState as ax, type WorkflowTask as ay, type ZeitlichSession 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 };
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-tQL9njTu.cjs';
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
  /**
@@ -115,11 +115,23 @@ interface SandboxProvider<TOptions extends SandboxCreateOptions = SandboxCreateO
115
115
  pause(sandboxId: string, ttlSeconds?: number): Promise<void>;
116
116
  /** Resume a paused sandbox. No-op if already running. */
117
117
  resume(sandboxId: string): Promise<void>;
118
- snapshot(sandboxId: string): Promise<SandboxSnapshot>;
119
- restore(snapshot: SandboxSnapshot): Promise<Sandbox>;
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>;
120
128
  /** Delete a previously captured snapshot. No-op if already deleted. */
121
129
  deleteSnapshot(snapshot: SandboxSnapshot): Promise<void>;
122
- fork(sandboxId: string): Promise<Sandbox>;
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>;
123
135
  }
124
136
  interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOptions, TCtx = unknown> {
125
137
  createSandbox(options?: TOptions, ctx?: TCtx): Promise<{
@@ -129,12 +141,14 @@ interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOption
129
141
  pauseSandbox(sandboxId: string): Promise<void>;
130
142
  /** Resume a paused sandbox. No-op if already running. */
131
143
  resumeSandbox(sandboxId: string): Promise<void>;
132
- snapshotSandbox(sandboxId: string): Promise<SandboxSnapshot>;
133
- /** Create a fresh sandbox from a previously captured snapshot. */
134
- restoreSandbox(snapshot: SandboxSnapshot): Promise<string>;
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>;
135
148
  /** Delete a previously captured snapshot. No-op if already deleted. */
136
149
  deleteSandboxSnapshot(snapshot: SandboxSnapshot): Promise<void>;
137
- forkSandbox(sandboxId: string): Promise<string>;
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>;
138
152
  }
139
153
  /**
140
154
  * Maps generic {@link SandboxOps} method names to adapter-prefixed names.
@@ -115,11 +115,23 @@ interface SandboxProvider<TOptions extends SandboxCreateOptions = SandboxCreateO
115
115
  pause(sandboxId: string, ttlSeconds?: number): Promise<void>;
116
116
  /** Resume a paused sandbox. No-op if already running. */
117
117
  resume(sandboxId: string): Promise<void>;
118
- snapshot(sandboxId: string): Promise<SandboxSnapshot>;
119
- restore(snapshot: SandboxSnapshot): Promise<Sandbox>;
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>;
120
128
  /** Delete a previously captured snapshot. No-op if already deleted. */
121
129
  deleteSnapshot(snapshot: SandboxSnapshot): Promise<void>;
122
- fork(sandboxId: string): Promise<Sandbox>;
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>;
123
135
  }
124
136
  interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOptions, TCtx = unknown> {
125
137
  createSandbox(options?: TOptions, ctx?: TCtx): Promise<{
@@ -129,12 +141,14 @@ interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOption
129
141
  pauseSandbox(sandboxId: string): Promise<void>;
130
142
  /** Resume a paused sandbox. No-op if already running. */
131
143
  resumeSandbox(sandboxId: string): Promise<void>;
132
- snapshotSandbox(sandboxId: string): Promise<SandboxSnapshot>;
133
- /** Create a fresh sandbox from a previously captured snapshot. */
134
- restoreSandbox(snapshot: SandboxSnapshot): Promise<string>;
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>;
135
148
  /** Delete a previously captured snapshot. No-op if already deleted. */
136
149
  deleteSandboxSnapshot(snapshot: SandboxSnapshot): Promise<void>;
137
- forkSandbox(sandboxId: string): Promise<string>;
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>;
138
152
  }
139
153
  /**
140
154
  * Maps generic {@link SandboxOps} method names to adapter-prefixed names.
@@ -1,5 +1,5 @@
1
- import { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, e as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-CPKDl-y_.js';
2
- import { g as SandboxOps } from './types-tQL9njTu.js';
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 { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, e as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-BO7Yju20.cjs';
2
- import { g as SandboxOps } from './types-tQL9njTu.cjs';
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