zeitlich 0.2.39 → 0.2.41

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 (64) hide show
  1. package/README.md +12 -1
  2. package/dist/{activities-Bmu7XnaG.d.ts → activities-D_g13S3y.d.ts} +2 -2
  3. package/dist/{activities-ByBFLvm2.d.cts → activities-qUflxmfS.d.cts} +2 -2
  4. package/dist/adapters/sandbox/e2b/index.cjs +12 -3
  5. package/dist/adapters/sandbox/e2b/index.cjs.map +1 -1
  6. package/dist/adapters/sandbox/e2b/index.d.cts +35 -2
  7. package/dist/adapters/sandbox/e2b/index.d.ts +35 -2
  8. package/dist/adapters/sandbox/e2b/index.js +13 -4
  9. package/dist/adapters/sandbox/e2b/index.js.map +1 -1
  10. package/dist/adapters/thread/anthropic/index.d.cts +5 -5
  11. package/dist/adapters/thread/anthropic/index.d.ts +5 -5
  12. package/dist/adapters/thread/anthropic/workflow.d.cts +5 -5
  13. package/dist/adapters/thread/anthropic/workflow.d.ts +5 -5
  14. package/dist/adapters/thread/google-genai/index.d.cts +5 -5
  15. package/dist/adapters/thread/google-genai/index.d.ts +5 -5
  16. package/dist/adapters/thread/google-genai/workflow.d.cts +5 -5
  17. package/dist/adapters/thread/google-genai/workflow.d.ts +5 -5
  18. package/dist/adapters/thread/langchain/index.d.cts +5 -5
  19. package/dist/adapters/thread/langchain/index.d.ts +5 -5
  20. package/dist/adapters/thread/langchain/workflow.d.cts +5 -5
  21. package/dist/adapters/thread/langchain/workflow.d.ts +5 -5
  22. package/dist/index.cjs +93 -49
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +35 -9
  25. package/dist/index.d.ts +35 -9
  26. package/dist/index.js +94 -50
  27. package/dist/index.js.map +1 -1
  28. package/dist/{proxy-DO_MXbY4.d.ts → proxy-BbcgoXg1.d.ts} +1 -1
  29. package/dist/{proxy-BAKzNGRq.d.cts → proxy-D7mvDEO6.d.cts} +1 -1
  30. package/dist/{thread-manager-D-7lp1JK.d.ts → thread-manager-CTXPCu9W.d.ts} +2 -2
  31. package/dist/{thread-manager-CcRXasqs.d.ts → thread-manager-Dqstsw4i.d.ts} +2 -2
  32. package/dist/{thread-manager-Y8Ucf0Tf.d.cts → thread-manager-DrWfVjlj.d.cts} +2 -2
  33. package/dist/{thread-manager-ClwSaUnj.d.cts → thread-manager-cLhDhRRc.d.cts} +2 -2
  34. package/dist/{types-Dt8-HBBT.d.ts → types-BqTmyH31.d.ts} +43 -3
  35. package/dist/{types-hFFi-Zd9.d.cts → types-CdvcmXb6.d.cts} +1 -1
  36. package/dist/{types-DpHTX-iO.d.ts → types-CjF1_Idx.d.ts} +1 -1
  37. package/dist/{types-Bcbiq8iv.d.cts → types-DjaQKUJx.d.cts} +43 -3
  38. package/dist/{workflow-Bx9utBwb.d.cts → workflow-CuqxgS6X.d.cts} +1 -1
  39. package/dist/{workflow-Bmf9EtDW.d.ts → workflow-N1MNDoul.d.ts} +1 -1
  40. package/dist/workflow.cjs +40 -31
  41. package/dist/workflow.cjs.map +1 -1
  42. package/dist/workflow.d.cts +3 -3
  43. package/dist/workflow.d.ts +3 -3
  44. package/dist/workflow.js +41 -32
  45. package/dist/workflow.js.map +1 -1
  46. package/package.json +15 -6
  47. package/src/adapters/sandbox/e2b/README.md +81 -0
  48. package/src/adapters/sandbox/e2b/index.ts +32 -5
  49. package/src/adapters/sandbox/e2b/keep-alive.test.ts +115 -0
  50. package/src/adapters/sandbox/e2b/types.ts +34 -2
  51. package/src/index.ts +1 -1
  52. package/src/lib/session/session.integration.test.ts +58 -0
  53. package/src/lib/session/session.ts +13 -15
  54. package/src/lib/session/types.ts +9 -3
  55. package/src/lib/subagent/subagent.integration.test.ts +2 -0
  56. package/src/lib/subagent/types.ts +8 -0
  57. package/src/lib/subagent/workflow.ts +11 -1
  58. package/src/lib/tool-router/auto-append-sandbox.integration.test.ts +158 -0
  59. package/src/lib/tool-router/index.ts +1 -1
  60. package/src/lib/tool-router/with-sandbox.ts +45 -2
  61. package/src/lib/virtual-fs/filesystem.ts +41 -16
  62. package/src/lib/virtual-fs/types.ts +19 -0
  63. package/src/lib/virtual-fs/virtual-fs.test.ts +204 -1
  64. package/src/tools/read-file/handler.test.ts +83 -0
@@ -2,15 +2,15 @@ import { A as ADAPTER_ID } from '../../../adapter-id-CMwVrVqv.js';
2
2
  export { a as AdapterId } from '../../../adapter-id-CMwVrVqv.js';
3
3
  import Redis from 'ioredis';
4
4
  import Anthropic from '@anthropic-ai/sdk';
5
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-Dt8-HBBT.js';
6
- import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-CcRXasqs.js';
7
- export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-CcRXasqs.js';
8
- import '@temporalio/common';
5
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-BqTmyH31.js';
6
+ import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-Dqstsw4i.js';
7
+ export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-Dqstsw4i.js';
9
8
  import '@temporalio/workflow';
10
9
  import '@temporalio/common/lib/interfaces';
11
10
  import 'zod';
12
11
  import '../../../types-yx0LzPGn.js';
13
- import '../../../types-DpHTX-iO.js';
12
+ import '@temporalio/common';
13
+ import '../../../types-CjF1_Idx.js';
14
14
 
15
15
  type AnthropicThreadOps<TScope extends string = ""> = PrefixedThreadOps<ScopedPrefix<TScope, typeof ADAPTER_ID>, AnthropicContent>;
16
16
  interface AnthropicAdapterConfig {
@@ -1,15 +1,15 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-Bcbiq8iv.cjs';
3
- import { A as AnthropicContent } from '../../../thread-manager-ClwSaUnj.cjs';
4
- import { c as createThreadOpsProxy } from '../../../proxy-BAKzNGRq.cjs';
2
+ import { T as ThreadOps } from '../../../types-DjaQKUJx.cjs';
3
+ import { A as AnthropicContent } from '../../../thread-manager-cLhDhRRc.cjs';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-D7mvDEO6.cjs';
5
5
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-CMwVrVqv.cjs';
6
- import '@temporalio/common';
7
6
  import '@temporalio/common/lib/interfaces';
8
7
  import 'zod';
9
8
  import '../../../types-yx0LzPGn.cjs';
9
+ import '@temporalio/common';
10
10
  import 'ioredis';
11
11
  import '@anthropic-ai/sdk';
12
- import '../../../types-hFFi-Zd9.cjs';
12
+ import '../../../types-CdvcmXb6.cjs';
13
13
 
14
14
  /**
15
15
  * Workflow-safe proxy for Anthropic thread operations.
@@ -1,15 +1,15 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-Dt8-HBBT.js';
3
- import { A as AnthropicContent } from '../../../thread-manager-CcRXasqs.js';
4
- import { c as createThreadOpsProxy } from '../../../proxy-DO_MXbY4.js';
2
+ import { T as ThreadOps } from '../../../types-BqTmyH31.js';
3
+ import { A as AnthropicContent } from '../../../thread-manager-Dqstsw4i.js';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-BbcgoXg1.js';
5
5
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-CMwVrVqv.js';
6
- import '@temporalio/common';
7
6
  import '@temporalio/common/lib/interfaces';
8
7
  import 'zod';
9
8
  import '../../../types-yx0LzPGn.js';
9
+ import '@temporalio/common';
10
10
  import 'ioredis';
11
11
  import '@anthropic-ai/sdk';
12
- import '../../../types-DpHTX-iO.js';
12
+ import '../../../types-CjF1_Idx.js';
13
13
 
14
14
  /**
15
15
  * Workflow-safe proxy for Anthropic thread operations.
@@ -1,15 +1,15 @@
1
1
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-BB-mmrts.cjs';
2
- import { G as GoogleGenAIThreadManagerHooks } from '../../../activities-ByBFLvm2.cjs';
3
- export { a as GoogleGenAIAdapter, b as GoogleGenAIAdapterConfig, c as GoogleGenAIContent, d as GoogleGenAIInvocationPayload, e as GoogleGenAIThreadManager, f as GoogleGenAIThreadManagerConfig, g as GoogleGenAIThreadOps, h as GoogleGenAIToolResponse, S as StoredContent, i as createGoogleGenAIAdapter, j as createGoogleGenAIThreadManager } from '../../../activities-ByBFLvm2.cjs';
2
+ import { G as GoogleGenAIThreadManagerHooks } from '../../../activities-qUflxmfS.cjs';
3
+ export { a as GoogleGenAIAdapter, b as GoogleGenAIAdapterConfig, c as GoogleGenAIContent, d as GoogleGenAIInvocationPayload, e as GoogleGenAIThreadManager, f as GoogleGenAIThreadManagerConfig, g as GoogleGenAIThreadOps, h as GoogleGenAIToolResponse, S as StoredContent, i as createGoogleGenAIAdapter, j as createGoogleGenAIThreadManager } from '../../../activities-qUflxmfS.cjs';
4
4
  import Redis from 'ioredis';
5
5
  import { GoogleGenAI, Content } from '@google/genai';
6
- import { M as ModelInvokerConfig, A as AgentResponse } from '../../../types-Bcbiq8iv.cjs';
7
- import '../../../types-hFFi-Zd9.cjs';
8
- import '@temporalio/common';
6
+ import { M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DjaQKUJx.cjs';
7
+ import '../../../types-CdvcmXb6.cjs';
9
8
  import '@temporalio/workflow';
10
9
  import '@temporalio/common/lib/interfaces';
11
10
  import 'zod';
12
11
  import '../../../types-yx0LzPGn.cjs';
12
+ import '@temporalio/common';
13
13
 
14
14
  interface GoogleGenAIModelInvokerConfig {
15
15
  redis: Redis;
@@ -1,15 +1,15 @@
1
1
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-BB-mmrts.js';
2
- import { G as GoogleGenAIThreadManagerHooks } from '../../../activities-Bmu7XnaG.js';
3
- export { a as GoogleGenAIAdapter, b as GoogleGenAIAdapterConfig, c as GoogleGenAIContent, d as GoogleGenAIInvocationPayload, e as GoogleGenAIThreadManager, f as GoogleGenAIThreadManagerConfig, g as GoogleGenAIThreadOps, h as GoogleGenAIToolResponse, S as StoredContent, i as createGoogleGenAIAdapter, j as createGoogleGenAIThreadManager } from '../../../activities-Bmu7XnaG.js';
2
+ import { G as GoogleGenAIThreadManagerHooks } from '../../../activities-D_g13S3y.js';
3
+ export { a as GoogleGenAIAdapter, b as GoogleGenAIAdapterConfig, c as GoogleGenAIContent, d as GoogleGenAIInvocationPayload, e as GoogleGenAIThreadManager, f as GoogleGenAIThreadManagerConfig, g as GoogleGenAIThreadOps, h as GoogleGenAIToolResponse, S as StoredContent, i as createGoogleGenAIAdapter, j as createGoogleGenAIThreadManager } from '../../../activities-D_g13S3y.js';
4
4
  import Redis from 'ioredis';
5
5
  import { GoogleGenAI, Content } from '@google/genai';
6
- import { M as ModelInvokerConfig, A as AgentResponse } from '../../../types-Dt8-HBBT.js';
7
- import '../../../types-DpHTX-iO.js';
8
- import '@temporalio/common';
6
+ import { M as ModelInvokerConfig, A as AgentResponse } from '../../../types-BqTmyH31.js';
7
+ import '../../../types-CjF1_Idx.js';
9
8
  import '@temporalio/workflow';
10
9
  import '@temporalio/common/lib/interfaces';
11
10
  import 'zod';
12
11
  import '../../../types-yx0LzPGn.js';
12
+ import '@temporalio/common';
13
13
 
14
14
  interface GoogleGenAIModelInvokerConfig {
15
15
  redis: Redis;
@@ -1,15 +1,15 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-Bcbiq8iv.cjs';
3
- import { c as GoogleGenAIContent } from '../../../activities-ByBFLvm2.cjs';
4
- import { c as createThreadOpsProxy } from '../../../proxy-BAKzNGRq.cjs';
2
+ import { T as ThreadOps } from '../../../types-DjaQKUJx.cjs';
3
+ import { c as GoogleGenAIContent } from '../../../activities-qUflxmfS.cjs';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-D7mvDEO6.cjs';
5
5
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-BB-mmrts.cjs';
6
- import '@temporalio/common';
7
6
  import '@temporalio/common/lib/interfaces';
8
7
  import 'zod';
9
8
  import '../../../types-yx0LzPGn.cjs';
9
+ import '@temporalio/common';
10
10
  import 'ioredis';
11
11
  import '@google/genai';
12
- import '../../../types-hFFi-Zd9.cjs';
12
+ import '../../../types-CdvcmXb6.cjs';
13
13
 
14
14
  /**
15
15
  * Workflow-safe proxy for Google GenAI thread operations.
@@ -1,15 +1,15 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-Dt8-HBBT.js';
3
- import { c as GoogleGenAIContent } from '../../../activities-Bmu7XnaG.js';
4
- import { c as createThreadOpsProxy } from '../../../proxy-DO_MXbY4.js';
2
+ import { T as ThreadOps } from '../../../types-BqTmyH31.js';
3
+ import { c as GoogleGenAIContent } from '../../../activities-D_g13S3y.js';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-BbcgoXg1.js';
5
5
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-BB-mmrts.js';
6
- import '@temporalio/common';
7
6
  import '@temporalio/common/lib/interfaces';
8
7
  import 'zod';
9
8
  import '../../../types-yx0LzPGn.js';
9
+ import '@temporalio/common';
10
10
  import 'ioredis';
11
11
  import '@google/genai';
12
- import '../../../types-DpHTX-iO.js';
12
+ import '../../../types-CjF1_Idx.js';
13
13
 
14
14
  /**
15
15
  * Workflow-safe proxy for Google GenAI thread operations.
@@ -2,16 +2,16 @@ import { A as ADAPTER_ID } from '../../../adapter-id-CbY2zeSt.cjs';
2
2
  export { a as AdapterId } from '../../../adapter-id-CbY2zeSt.cjs';
3
3
  import Redis from 'ioredis';
4
4
  import { StoredMessage, MessageContent, BaseMessage } from '@langchain/core/messages';
5
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-Bcbiq8iv.cjs';
5
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DjaQKUJx.cjs';
6
6
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
7
- import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-Y8Ucf0Tf.cjs';
8
- export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-Y8Ucf0Tf.cjs';
9
- import '@temporalio/common';
7
+ import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-DrWfVjlj.cjs';
8
+ export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-DrWfVjlj.cjs';
10
9
  import '@temporalio/workflow';
11
10
  import '@temporalio/common/lib/interfaces';
12
11
  import 'zod';
13
12
  import '../../../types-yx0LzPGn.cjs';
14
- import '../../../types-hFFi-Zd9.cjs';
13
+ import '@temporalio/common';
14
+ import '../../../types-CdvcmXb6.cjs';
15
15
 
16
16
  type LangChainThreadOps<TScope extends string = ""> = PrefixedThreadOps<ScopedPrefix<TScope, typeof ADAPTER_ID>, LangChainContent>;
17
17
  interface LangChainAdapterConfig {
@@ -2,16 +2,16 @@ import { A as ADAPTER_ID } from '../../../adapter-id-CbY2zeSt.js';
2
2
  export { a as AdapterId } from '../../../adapter-id-CbY2zeSt.js';
3
3
  import Redis from 'ioredis';
4
4
  import { StoredMessage, MessageContent, BaseMessage } from '@langchain/core/messages';
5
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-Dt8-HBBT.js';
5
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-BqTmyH31.js';
6
6
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
7
- import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-D-7lp1JK.js';
8
- export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-D-7lp1JK.js';
9
- import '@temporalio/common';
7
+ import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-CTXPCu9W.js';
8
+ export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-CTXPCu9W.js';
10
9
  import '@temporalio/workflow';
11
10
  import '@temporalio/common/lib/interfaces';
12
11
  import 'zod';
13
12
  import '../../../types-yx0LzPGn.js';
14
- import '../../../types-DpHTX-iO.js';
13
+ import '@temporalio/common';
14
+ import '../../../types-CjF1_Idx.js';
15
15
 
16
16
  type LangChainThreadOps<TScope extends string = ""> = PrefixedThreadOps<ScopedPrefix<TScope, typeof ADAPTER_ID>, LangChainContent>;
17
17
  interface LangChainAdapterConfig {
@@ -1,15 +1,15 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-Bcbiq8iv.cjs';
3
- import { L as LangChainContent } from '../../../thread-manager-Y8Ucf0Tf.cjs';
4
- import { c as createThreadOpsProxy } from '../../../proxy-BAKzNGRq.cjs';
2
+ import { T as ThreadOps } from '../../../types-DjaQKUJx.cjs';
3
+ import { L as LangChainContent } from '../../../thread-manager-DrWfVjlj.cjs';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-D7mvDEO6.cjs';
5
5
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-CbY2zeSt.cjs';
6
- import '@temporalio/common';
7
6
  import '@temporalio/common/lib/interfaces';
8
7
  import 'zod';
9
8
  import '../../../types-yx0LzPGn.cjs';
9
+ import '@temporalio/common';
10
10
  import 'ioredis';
11
11
  import '@langchain/core/messages';
12
- import '../../../types-hFFi-Zd9.cjs';
12
+ import '../../../types-CdvcmXb6.cjs';
13
13
 
14
14
  /**
15
15
  * Workflow-safe proxy for LangChain thread operations.
@@ -1,15 +1,15 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-Dt8-HBBT.js';
3
- import { L as LangChainContent } from '../../../thread-manager-D-7lp1JK.js';
4
- import { c as createThreadOpsProxy } from '../../../proxy-DO_MXbY4.js';
2
+ import { T as ThreadOps } from '../../../types-BqTmyH31.js';
3
+ import { L as LangChainContent } from '../../../thread-manager-CTXPCu9W.js';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-BbcgoXg1.js';
5
5
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-CbY2zeSt.js';
6
- import '@temporalio/common';
7
6
  import '@temporalio/common/lib/interfaces';
8
7
  import 'zod';
9
8
  import '../../../types-yx0LzPGn.js';
9
+ import '@temporalio/common';
10
10
  import 'ioredis';
11
11
  import '@langchain/core/messages';
12
- import '../../../types-DpHTX-iO.js';
12
+ import '../../../types-CjF1_Idx.js';
13
13
 
14
14
  /**
15
15
  * Workflow-safe proxy for LangChain thread operations.
package/dist/index.cjs CHANGED
@@ -957,7 +957,6 @@ async function createSession({
957
957
  processToolsInParallel = true,
958
958
  hooks = {},
959
959
  appendSystemPrompt = true,
960
- waitForInputTimeout = "48h",
961
960
  threadKey,
962
961
  sandboxOps,
963
962
  thread: threadInit,
@@ -1140,12 +1139,23 @@ async function createSession({
1140
1139
  path,
1141
1140
  size: content.length,
1142
1141
  mtime: (/* @__PURE__ */ new Date()).toISOString(),
1143
- metadata: {}
1142
+ metadata: {},
1143
+ // Carry the content directly on the entry so any handler that
1144
+ // constructs a VirtualFileSystem from `fileTree` can read it
1145
+ // without needing to also wire up `inlineFiles` from state.
1146
+ inlineContent: content
1144
1147
  }))
1145
1148
  ] : result.fileTree;
1146
1149
  stateManager.mergeUpdate({
1147
1150
  fileTree,
1148
1151
  virtualFsCtx: virtualFsConfig.ctx,
1152
+ // `inlineFiles` is still the source of truth at read time:
1153
+ // VirtualFileSystem checks the inlineFiles map first and only
1154
+ // falls through to entry.inlineContent. Embedding the content on
1155
+ // the entry is the migration target so that handlers building a
1156
+ // VirtualFileSystem from `fileTree` alone (without forwarding
1157
+ // `inlineFiles` from state) can read skill resources. Until a
1158
+ // follow-up drops `inlineFiles`, both fields are populated.
1149
1159
  ...skillFiles && { inlineFiles: skillFiles }
1150
1160
  });
1151
1161
  }
@@ -1271,18 +1281,6 @@ async function createSession({
1271
1281
  continue;
1272
1282
  }
1273
1283
  assistantId = void 0;
1274
- if (stateManager.getStatus() === "WAITING_FOR_INPUT") {
1275
- const conditionMet = await workflow.condition(
1276
- () => stateManager.getStatus() === "RUNNING",
1277
- waitForInputTimeout
1278
- );
1279
- if (!conditionMet) {
1280
- stateManager.cancel();
1281
- exitReason = "cancelled";
1282
- await workflow.condition(() => false, "2s");
1283
- break;
1284
- }
1285
- }
1286
1284
  }
1287
1285
  if (stateManager.getTurns() >= maxTurns && stateManager.isRunning()) {
1288
1286
  exitReason = "max_turns";
@@ -1355,7 +1353,9 @@ async function createSession({
1355
1353
  if (onSessionExit) {
1356
1354
  onSessionExit({
1357
1355
  ...sandboxId && { sandboxId },
1358
- ...exitSnapshot && { snapshot: exitSnapshot }
1356
+ ...exitSnapshot && { snapshot: exitSnapshot },
1357
+ threadId,
1358
+ usage: stateManager.getTotalUsage()
1359
1359
  });
1360
1360
  }
1361
1361
  return {
@@ -1643,9 +1643,24 @@ function withAutoAppend(threadHandler, handler) {
1643
1643
  };
1644
1644
  };
1645
1645
  }
1646
+ var SandboxNotSupportedError = class extends common.ApplicationFailure {
1647
+ constructor(operation) {
1648
+ super(
1649
+ `Sandbox does not support: ${operation}`,
1650
+ "SandboxNotSupportedError",
1651
+ true
1652
+ );
1653
+ }
1654
+ };
1655
+ var SandboxNotFoundError = class extends common.ApplicationFailure {
1656
+ constructor(sandboxId) {
1657
+ super(`Sandbox not found: ${sandboxId}`, "SandboxNotFoundError", true);
1658
+ }
1659
+ };
1646
1660
 
1647
1661
  // src/lib/tool-router/with-sandbox.ts
1648
- function withSandbox(manager, handler) {
1662
+ function withSandbox(manager, handler, options) {
1663
+ const translateSandboxNotFound = options?.translateSandboxNotFound ?? false;
1649
1664
  return async (args, context) => {
1650
1665
  if (!context.sandboxId) {
1651
1666
  return {
@@ -1653,7 +1668,18 @@ function withSandbox(manager, handler) {
1653
1668
  data: null
1654
1669
  };
1655
1670
  }
1656
- const sandbox = await manager.getSandbox(context.sandboxId);
1671
+ let sandbox;
1672
+ try {
1673
+ sandbox = await manager.getSandbox(context.sandboxId);
1674
+ } catch (err) {
1675
+ if (translateSandboxNotFound && err instanceof SandboxNotFoundError) {
1676
+ return {
1677
+ toolResponse: options?.sandboxNotFoundToolResponse ?? `Error: the execution environment for the ${context.toolName} tool is no longer available, so this tool call could not be completed.`,
1678
+ data: null
1679
+ };
1680
+ }
1681
+ throw err;
1682
+ }
1657
1683
  return handler(args, { ...context, sandbox, sandboxId: context.sandboxId });
1658
1684
  };
1659
1685
  }
@@ -1685,6 +1711,7 @@ function defineSubagentWorkflow(config, fn) {
1685
1711
  let capturedSnapshot;
1686
1712
  let capturedBaseSnapshot;
1687
1713
  let capturedThreadId;
1714
+ let capturedUsage;
1688
1715
  const sessionInput = {
1689
1716
  agentName: config.name,
1690
1717
  sandboxShutdown: effectiveShutdown,
@@ -1701,10 +1728,17 @@ function defineSubagentWorkflow(config, fn) {
1701
1728
  });
1702
1729
  }
1703
1730
  },
1704
- onSessionExit: ({ sandboxId, snapshot, threadId }) => {
1731
+ onSessionExit: ({ sandboxId, snapshot, threadId, usage }) => {
1705
1732
  capturedSandboxId = sandboxId;
1706
1733
  capturedSnapshot = snapshot;
1707
1734
  capturedThreadId = threadId;
1735
+ capturedUsage = {
1736
+ inputTokens: usage.totalInputTokens,
1737
+ outputTokens: usage.totalOutputTokens,
1738
+ cachedWriteTokens: usage.totalCachedWriteTokens,
1739
+ cachedReadTokens: usage.totalCachedReadTokens,
1740
+ reasonTokens: usage.totalReasonTokens
1741
+ };
1708
1742
  }
1709
1743
  };
1710
1744
  const result = await fn(prompt, sessionInput, context ?? {});
@@ -1715,7 +1749,8 @@ function defineSubagentWorkflow(config, fn) {
1715
1749
  ...capturedSnapshot !== void 0 && { snapshot: capturedSnapshot },
1716
1750
  ...capturedBaseSnapshot !== void 0 && {
1717
1751
  baseSnapshot: capturedBaseSnapshot
1718
- }
1752
+ },
1753
+ ...capturedUsage !== void 0 && { usage: capturedUsage }
1719
1754
  };
1720
1755
  };
1721
1756
  Object.defineProperty(workflow$1, "name", { value: config.name });
@@ -1799,20 +1834,6 @@ function proxyRunAgent(scope, options) {
1799
1834
  );
1800
1835
  return acts[name];
1801
1836
  }
1802
- var SandboxNotSupportedError = class extends common.ApplicationFailure {
1803
- constructor(operation) {
1804
- super(
1805
- `Sandbox does not support: ${operation}`,
1806
- "SandboxNotSupportedError",
1807
- true
1808
- );
1809
- }
1810
- };
1811
- var SandboxNotFoundError = class extends common.ApplicationFailure {
1812
- constructor(sandboxId) {
1813
- super(`Sandbox not found: ${sandboxId}`, "SandboxNotFoundError", true);
1814
- }
1815
- };
1816
1837
 
1817
1838
  // src/lib/virtual-fs/mutations.ts
1818
1839
  function applyVirtualTreeMutations(stateManager, mutations) {
@@ -2925,7 +2946,7 @@ var VirtualFileSystem = class {
2925
2946
  if (inline !== void 0) return inline;
2926
2947
  const entry = this.entries.get(norm);
2927
2948
  if (!entry) throw new Error(`ENOENT: no such file: ${path}`);
2928
- return this.resolver.readFile(entry.id, this.ctx, entry.metadata);
2949
+ return this.readEntryContent(entry);
2929
2950
  }
2930
2951
  async readFileBuffer(path) {
2931
2952
  const norm = normalisePath(path, this.workspaceBase);
@@ -2933,8 +2954,23 @@ var VirtualFileSystem = class {
2933
2954
  if (inline !== void 0) return new TextEncoder().encode(inline);
2934
2955
  const entry = this.entries.get(norm);
2935
2956
  if (!entry) throw new Error(`ENOENT: no such file: ${path}`);
2957
+ if (entry.inlineContent !== void 0) {
2958
+ return new TextEncoder().encode(entry.inlineContent);
2959
+ }
2936
2960
  return this.resolver.readFileBuffer(entry.id, this.ctx, entry.metadata);
2937
2961
  }
2962
+ /**
2963
+ * Resolve the string content for an entry, preferring inline content
2964
+ * carried on the entry itself before consulting the resolver. Used by
2965
+ * `readFile`, `appendFile`, and `cp` so all read paths agree on the
2966
+ * lookup precedence.
2967
+ */
2968
+ readEntryContent(entry) {
2969
+ if (entry.inlineContent !== void 0) {
2970
+ return Promise.resolve(entry.inlineContent);
2971
+ }
2972
+ return this.resolver.readFile(entry.id, this.ctx, entry.metadata);
2973
+ }
2938
2974
  // --------------------------------------------------------------------------
2939
2975
  // Metadata operations — pure, resolved from the tree
2940
2976
  // --------------------------------------------------------------------------
@@ -3006,6 +3042,11 @@ var VirtualFileSystem = class {
3006
3042
  const norm = normalisePath(path, this.workspaceBase);
3007
3043
  const existing = this.entries.get(norm);
3008
3044
  if (existing) {
3045
+ if (existing.inlineContent !== void 0) {
3046
+ throw new Error(
3047
+ `EROFS: cannot write to inline (read-only) entry: ${path}`
3048
+ );
3049
+ }
3009
3050
  await this.resolver.writeFile(
3010
3051
  existing.id,
3011
3052
  content,
@@ -3034,11 +3075,12 @@ var VirtualFileSystem = class {
3034
3075
  if (!existing) {
3035
3076
  return this.writeFile(path, content);
3036
3077
  }
3037
- const current = await this.resolver.readFile(
3038
- existing.id,
3039
- this.ctx,
3040
- existing.metadata
3041
- );
3078
+ if (existing.inlineContent !== void 0) {
3079
+ throw new Error(
3080
+ `EROFS: cannot append to inline (read-only) entry: ${path}`
3081
+ );
3082
+ }
3083
+ const current = await this.readEntryContent(existing);
3042
3084
  const appended = typeof content === "string" ? current + content : current + new TextDecoder().decode(content);
3043
3085
  await this.resolver.writeFile(
3044
3086
  existing.id,
@@ -3073,6 +3115,11 @@ var VirtualFileSystem = class {
3073
3115
  const norm = normalisePath(path, this.workspaceBase);
3074
3116
  const entry = this.entries.get(norm);
3075
3117
  if (entry) {
3118
+ if (entry.inlineContent !== void 0) {
3119
+ throw new Error(
3120
+ `EROFS: cannot remove inline (read-only) entry: ${path}`
3121
+ );
3122
+ }
3076
3123
  await this.resolver.deleteFile(entry.id, this.ctx, entry.metadata);
3077
3124
  this.entries.delete(norm);
3078
3125
  this.mutations.push({ type: "remove", path: norm });
@@ -3085,6 +3132,11 @@ var VirtualFileSystem = class {
3085
3132
  const prefix = norm === "/" ? "/" : norm + "/";
3086
3133
  for (const [p, e] of this.entries) {
3087
3134
  if (p.startsWith(prefix)) {
3135
+ if (e.inlineContent !== void 0) {
3136
+ throw new Error(
3137
+ `EROFS: cannot remove inline (read-only) entry: ${p}`
3138
+ );
3139
+ }
3088
3140
  await this.resolver.deleteFile(e.id, this.ctx, e.metadata);
3089
3141
  this.entries.delete(p);
3090
3142
  this.mutations.push({ type: "remove", path: p });
@@ -3105,11 +3157,7 @@ var VirtualFileSystem = class {
3105
3157
  const normDest = normalisePath(dest, this.workspaceBase);
3106
3158
  const entry = this.entries.get(normSrc);
3107
3159
  if (entry) {
3108
- const content = await this.resolver.readFile(
3109
- entry.id,
3110
- this.ctx,
3111
- entry.metadata
3112
- );
3160
+ const content = await this.readEntryContent(entry);
3113
3161
  await this.writeFile(normDest, content);
3114
3162
  return;
3115
3163
  }
@@ -3123,11 +3171,7 @@ var VirtualFileSystem = class {
3123
3171
  for (const [p, e] of this.entries) {
3124
3172
  if (p.startsWith(prefix)) {
3125
3173
  const relative = p.slice(normSrc.length);
3126
- const content = await this.resolver.readFile(
3127
- e.id,
3128
- this.ctx,
3129
- e.metadata
3130
- );
3174
+ const content = await this.readEntryContent(e);
3131
3175
  await this.writeFile(normDest + relative, content);
3132
3176
  }
3133
3177
  }