zeitlich 0.2.40 → 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-CULxRzJ1.d.ts → activities-D_g13S3y.d.ts} +2 -2
  3. package/dist/{activities-CvUrG3YG.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 +92 -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 +93 -50
  27. package/dist/index.js.map +1 -1
  28. package/dist/{proxy-wZufFfBh.d.ts → proxy-BbcgoXg1.d.ts} +1 -1
  29. package/dist/{proxy-5EbwzaY4.d.cts → proxy-D7mvDEO6.d.cts} +1 -1
  30. package/dist/{thread-manager-BqBAIsED.d.ts → thread-manager-CTXPCu9W.d.ts} +2 -2
  31. package/dist/{thread-manager-BNiIt5r8.d.ts → thread-manager-Dqstsw4i.d.ts} +2 -2
  32. package/dist/{thread-manager-BoN5DOvG.d.cts → thread-manager-DrWfVjlj.d.cts} +2 -2
  33. package/dist/{thread-manager-DF8WuCRs.d.cts → thread-manager-cLhDhRRc.d.cts} +2 -2
  34. package/dist/{types-DeQH84C_.d.ts → types-BqTmyH31.d.ts} +42 -3
  35. package/dist/{types-CuISs0Ub.d.cts → types-CdvcmXb6.d.cts} +1 -1
  36. package/dist/{types-C7OoY7h8.d.ts → types-CjF1_Idx.d.ts} +1 -1
  37. package/dist/{types-Cn2r3ol3.d.cts → types-DjaQKUJx.d.cts} +42 -3
  38. package/dist/{workflow-DhplIN65.d.cts → workflow-CuqxgS6X.d.cts} +1 -1
  39. package/dist/{workflow-C2MZZj5K.d.ts → workflow-N1MNDoul.d.ts} +1 -1
  40. package/dist/workflow.cjs +39 -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 +40 -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 +12 -15
  54. package/src/lib/session/types.ts +8 -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-DeQH84C_.js';
6
- import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-BNiIt5r8.js';
7
- export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-BNiIt5r8.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-C7OoY7h8.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-Cn2r3ol3.cjs';
3
- import { A as AnthropicContent } from '../../../thread-manager-DF8WuCRs.cjs';
4
- import { c as createThreadOpsProxy } from '../../../proxy-5EbwzaY4.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-CuISs0Ub.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-DeQH84C_.js';
3
- import { A as AnthropicContent } from '../../../thread-manager-BNiIt5r8.js';
4
- import { c as createThreadOpsProxy } from '../../../proxy-wZufFfBh.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-C7OoY7h8.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-CvUrG3YG.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-CvUrG3YG.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-Cn2r3ol3.cjs';
7
- import '../../../types-CuISs0Ub.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-CULxRzJ1.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-CULxRzJ1.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-DeQH84C_.js';
7
- import '../../../types-C7OoY7h8.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-Cn2r3ol3.cjs';
3
- import { c as GoogleGenAIContent } from '../../../activities-CvUrG3YG.cjs';
4
- import { c as createThreadOpsProxy } from '../../../proxy-5EbwzaY4.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-CuISs0Ub.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-DeQH84C_.js';
3
- import { c as GoogleGenAIContent } from '../../../activities-CULxRzJ1.js';
4
- import { c as createThreadOpsProxy } from '../../../proxy-wZufFfBh.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-C7OoY7h8.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-Cn2r3ol3.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-BoN5DOvG.cjs';
8
- export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-BoN5DOvG.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-CuISs0Ub.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-DeQH84C_.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-BqBAIsED.js';
8
- export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-BqBAIsED.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-C7OoY7h8.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-Cn2r3ol3.cjs';
3
- import { L as LangChainContent } from '../../../thread-manager-BoN5DOvG.cjs';
4
- import { c as createThreadOpsProxy } from '../../../proxy-5EbwzaY4.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-CuISs0Ub.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-DeQH84C_.js';
3
- import { L as LangChainContent } from '../../../thread-manager-BqBAIsED.js';
4
- import { c as createThreadOpsProxy } from '../../../proxy-wZufFfBh.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-C7OoY7h8.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";
@@ -1356,7 +1354,8 @@ async function createSession({
1356
1354
  onSessionExit({
1357
1355
  ...sandboxId && { sandboxId },
1358
1356
  ...exitSnapshot && { snapshot: exitSnapshot },
1359
- threadId
1357
+ threadId,
1358
+ usage: stateManager.getTotalUsage()
1360
1359
  });
1361
1360
  }
1362
1361
  return {
@@ -1644,9 +1643,24 @@ function withAutoAppend(threadHandler, handler) {
1644
1643
  };
1645
1644
  };
1646
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
+ };
1647
1660
 
1648
1661
  // src/lib/tool-router/with-sandbox.ts
1649
- function withSandbox(manager, handler) {
1662
+ function withSandbox(manager, handler, options) {
1663
+ const translateSandboxNotFound = options?.translateSandboxNotFound ?? false;
1650
1664
  return async (args, context) => {
1651
1665
  if (!context.sandboxId) {
1652
1666
  return {
@@ -1654,7 +1668,18 @@ function withSandbox(manager, handler) {
1654
1668
  data: null
1655
1669
  };
1656
1670
  }
1657
- 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
+ }
1658
1683
  return handler(args, { ...context, sandbox, sandboxId: context.sandboxId });
1659
1684
  };
1660
1685
  }
@@ -1686,6 +1711,7 @@ function defineSubagentWorkflow(config, fn) {
1686
1711
  let capturedSnapshot;
1687
1712
  let capturedBaseSnapshot;
1688
1713
  let capturedThreadId;
1714
+ let capturedUsage;
1689
1715
  const sessionInput = {
1690
1716
  agentName: config.name,
1691
1717
  sandboxShutdown: effectiveShutdown,
@@ -1702,10 +1728,17 @@ function defineSubagentWorkflow(config, fn) {
1702
1728
  });
1703
1729
  }
1704
1730
  },
1705
- onSessionExit: ({ sandboxId, snapshot, threadId }) => {
1731
+ onSessionExit: ({ sandboxId, snapshot, threadId, usage }) => {
1706
1732
  capturedSandboxId = sandboxId;
1707
1733
  capturedSnapshot = snapshot;
1708
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
+ };
1709
1742
  }
1710
1743
  };
1711
1744
  const result = await fn(prompt, sessionInput, context ?? {});
@@ -1716,7 +1749,8 @@ function defineSubagentWorkflow(config, fn) {
1716
1749
  ...capturedSnapshot !== void 0 && { snapshot: capturedSnapshot },
1717
1750
  ...capturedBaseSnapshot !== void 0 && {
1718
1751
  baseSnapshot: capturedBaseSnapshot
1719
- }
1752
+ },
1753
+ ...capturedUsage !== void 0 && { usage: capturedUsage }
1720
1754
  };
1721
1755
  };
1722
1756
  Object.defineProperty(workflow$1, "name", { value: config.name });
@@ -1800,20 +1834,6 @@ function proxyRunAgent(scope, options) {
1800
1834
  );
1801
1835
  return acts[name];
1802
1836
  }
1803
- var SandboxNotSupportedError = class extends common.ApplicationFailure {
1804
- constructor(operation) {
1805
- super(
1806
- `Sandbox does not support: ${operation}`,
1807
- "SandboxNotSupportedError",
1808
- true
1809
- );
1810
- }
1811
- };
1812
- var SandboxNotFoundError = class extends common.ApplicationFailure {
1813
- constructor(sandboxId) {
1814
- super(`Sandbox not found: ${sandboxId}`, "SandboxNotFoundError", true);
1815
- }
1816
- };
1817
1837
 
1818
1838
  // src/lib/virtual-fs/mutations.ts
1819
1839
  function applyVirtualTreeMutations(stateManager, mutations) {
@@ -2926,7 +2946,7 @@ var VirtualFileSystem = class {
2926
2946
  if (inline !== void 0) return inline;
2927
2947
  const entry = this.entries.get(norm);
2928
2948
  if (!entry) throw new Error(`ENOENT: no such file: ${path}`);
2929
- return this.resolver.readFile(entry.id, this.ctx, entry.metadata);
2949
+ return this.readEntryContent(entry);
2930
2950
  }
2931
2951
  async readFileBuffer(path) {
2932
2952
  const norm = normalisePath(path, this.workspaceBase);
@@ -2934,8 +2954,23 @@ var VirtualFileSystem = class {
2934
2954
  if (inline !== void 0) return new TextEncoder().encode(inline);
2935
2955
  const entry = this.entries.get(norm);
2936
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
+ }
2937
2960
  return this.resolver.readFileBuffer(entry.id, this.ctx, entry.metadata);
2938
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
+ }
2939
2974
  // --------------------------------------------------------------------------
2940
2975
  // Metadata operations — pure, resolved from the tree
2941
2976
  // --------------------------------------------------------------------------
@@ -3007,6 +3042,11 @@ var VirtualFileSystem = class {
3007
3042
  const norm = normalisePath(path, this.workspaceBase);
3008
3043
  const existing = this.entries.get(norm);
3009
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
+ }
3010
3050
  await this.resolver.writeFile(
3011
3051
  existing.id,
3012
3052
  content,
@@ -3035,11 +3075,12 @@ var VirtualFileSystem = class {
3035
3075
  if (!existing) {
3036
3076
  return this.writeFile(path, content);
3037
3077
  }
3038
- const current = await this.resolver.readFile(
3039
- existing.id,
3040
- this.ctx,
3041
- existing.metadata
3042
- );
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);
3043
3084
  const appended = typeof content === "string" ? current + content : current + new TextDecoder().decode(content);
3044
3085
  await this.resolver.writeFile(
3045
3086
  existing.id,
@@ -3074,6 +3115,11 @@ var VirtualFileSystem = class {
3074
3115
  const norm = normalisePath(path, this.workspaceBase);
3075
3116
  const entry = this.entries.get(norm);
3076
3117
  if (entry) {
3118
+ if (entry.inlineContent !== void 0) {
3119
+ throw new Error(
3120
+ `EROFS: cannot remove inline (read-only) entry: ${path}`
3121
+ );
3122
+ }
3077
3123
  await this.resolver.deleteFile(entry.id, this.ctx, entry.metadata);
3078
3124
  this.entries.delete(norm);
3079
3125
  this.mutations.push({ type: "remove", path: norm });
@@ -3086,6 +3132,11 @@ var VirtualFileSystem = class {
3086
3132
  const prefix = norm === "/" ? "/" : norm + "/";
3087
3133
  for (const [p, e] of this.entries) {
3088
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
+ }
3089
3140
  await this.resolver.deleteFile(e.id, this.ctx, e.metadata);
3090
3141
  this.entries.delete(p);
3091
3142
  this.mutations.push({ type: "remove", path: p });
@@ -3106,11 +3157,7 @@ var VirtualFileSystem = class {
3106
3157
  const normDest = normalisePath(dest, this.workspaceBase);
3107
3158
  const entry = this.entries.get(normSrc);
3108
3159
  if (entry) {
3109
- const content = await this.resolver.readFile(
3110
- entry.id,
3111
- this.ctx,
3112
- entry.metadata
3113
- );
3160
+ const content = await this.readEntryContent(entry);
3114
3161
  await this.writeFile(normDest, content);
3115
3162
  return;
3116
3163
  }
@@ -3124,11 +3171,7 @@ var VirtualFileSystem = class {
3124
3171
  for (const [p, e] of this.entries) {
3125
3172
  if (p.startsWith(prefix)) {
3126
3173
  const relative = p.slice(normSrc.length);
3127
- const content = await this.resolver.readFile(
3128
- e.id,
3129
- this.ctx,
3130
- e.metadata
3131
- );
3174
+ const content = await this.readEntryContent(e);
3132
3175
  await this.writeFile(normDest + relative, content);
3133
3176
  }
3134
3177
  }