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.
- package/README.md +12 -1
- package/dist/{activities-Bmu7XnaG.d.ts → activities-D_g13S3y.d.ts} +2 -2
- package/dist/{activities-ByBFLvm2.d.cts → activities-qUflxmfS.d.cts} +2 -2
- package/dist/adapters/sandbox/e2b/index.cjs +12 -3
- package/dist/adapters/sandbox/e2b/index.cjs.map +1 -1
- package/dist/adapters/sandbox/e2b/index.d.cts +35 -2
- package/dist/adapters/sandbox/e2b/index.d.ts +35 -2
- package/dist/adapters/sandbox/e2b/index.js +13 -4
- package/dist/adapters/sandbox/e2b/index.js.map +1 -1
- package/dist/adapters/thread/anthropic/index.d.cts +5 -5
- package/dist/adapters/thread/anthropic/index.d.ts +5 -5
- package/dist/adapters/thread/anthropic/workflow.d.cts +5 -5
- package/dist/adapters/thread/anthropic/workflow.d.ts +5 -5
- package/dist/adapters/thread/google-genai/index.d.cts +5 -5
- package/dist/adapters/thread/google-genai/index.d.ts +5 -5
- package/dist/adapters/thread/google-genai/workflow.d.cts +5 -5
- package/dist/adapters/thread/google-genai/workflow.d.ts +5 -5
- package/dist/adapters/thread/langchain/index.d.cts +5 -5
- package/dist/adapters/thread/langchain/index.d.ts +5 -5
- package/dist/adapters/thread/langchain/workflow.d.cts +5 -5
- package/dist/adapters/thread/langchain/workflow.d.ts +5 -5
- package/dist/index.cjs +93 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -9
- package/dist/index.d.ts +35 -9
- package/dist/index.js +94 -50
- package/dist/index.js.map +1 -1
- package/dist/{proxy-DO_MXbY4.d.ts → proxy-BbcgoXg1.d.ts} +1 -1
- package/dist/{proxy-BAKzNGRq.d.cts → proxy-D7mvDEO6.d.cts} +1 -1
- package/dist/{thread-manager-D-7lp1JK.d.ts → thread-manager-CTXPCu9W.d.ts} +2 -2
- package/dist/{thread-manager-CcRXasqs.d.ts → thread-manager-Dqstsw4i.d.ts} +2 -2
- package/dist/{thread-manager-Y8Ucf0Tf.d.cts → thread-manager-DrWfVjlj.d.cts} +2 -2
- package/dist/{thread-manager-ClwSaUnj.d.cts → thread-manager-cLhDhRRc.d.cts} +2 -2
- package/dist/{types-Dt8-HBBT.d.ts → types-BqTmyH31.d.ts} +43 -3
- package/dist/{types-hFFi-Zd9.d.cts → types-CdvcmXb6.d.cts} +1 -1
- package/dist/{types-DpHTX-iO.d.ts → types-CjF1_Idx.d.ts} +1 -1
- package/dist/{types-Bcbiq8iv.d.cts → types-DjaQKUJx.d.cts} +43 -3
- package/dist/{workflow-Bx9utBwb.d.cts → workflow-CuqxgS6X.d.cts} +1 -1
- package/dist/{workflow-Bmf9EtDW.d.ts → workflow-N1MNDoul.d.ts} +1 -1
- package/dist/workflow.cjs +40 -31
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +3 -3
- package/dist/workflow.d.ts +3 -3
- package/dist/workflow.js +41 -32
- package/dist/workflow.js.map +1 -1
- package/package.json +15 -6
- package/src/adapters/sandbox/e2b/README.md +81 -0
- package/src/adapters/sandbox/e2b/index.ts +32 -5
- package/src/adapters/sandbox/e2b/keep-alive.test.ts +115 -0
- package/src/adapters/sandbox/e2b/types.ts +34 -2
- package/src/index.ts +1 -1
- package/src/lib/session/session.integration.test.ts +58 -0
- package/src/lib/session/session.ts +13 -15
- package/src/lib/session/types.ts +9 -3
- package/src/lib/subagent/subagent.integration.test.ts +2 -0
- package/src/lib/subagent/types.ts +8 -0
- package/src/lib/subagent/workflow.ts +11 -1
- package/src/lib/tool-router/auto-append-sandbox.integration.test.ts +158 -0
- package/src/lib/tool-router/index.ts +1 -1
- package/src/lib/tool-router/with-sandbox.ts +45 -2
- package/src/lib/virtual-fs/filesystem.ts +41 -16
- package/src/lib/virtual-fs/types.ts +19 -0
- package/src/lib/virtual-fs/virtual-fs.test.ts +204 -1
- package/src/tools/read-file/handler.test.ts +83 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
|
-
import { J as JsonValue } from './types-
|
|
2
|
+
import { J as JsonValue } from './types-BqTmyH31.js';
|
|
3
3
|
import { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
|
|
4
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
4
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-CjF1_Idx.js';
|
|
5
5
|
|
|
6
6
|
/** SDK-native content type for LangChain human messages */
|
|
7
7
|
type LangChainContent = string | MessageContent;
|
|
@@ -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-
|
|
4
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
3
|
+
import { J as JsonValue } from './types-BqTmyH31.js';
|
|
4
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-CjF1_Idx.js';
|
|
5
5
|
|
|
6
6
|
/** SDK-native content type for Anthropic human messages */
|
|
7
7
|
type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
|
-
import { J as JsonValue } from './types-
|
|
2
|
+
import { J as JsonValue } from './types-DjaQKUJx.cjs';
|
|
3
3
|
import { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
|
|
4
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
4
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-CdvcmXb6.cjs';
|
|
5
5
|
|
|
6
6
|
/** SDK-native content type for LangChain human messages */
|
|
7
7
|
type LangChainContent = string | MessageContent;
|
|
@@ -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-
|
|
4
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
3
|
+
import { J as JsonValue } from './types-DjaQKUJx.cjs';
|
|
4
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-CdvcmXb6.cjs';
|
|
5
5
|
|
|
6
6
|
/** SDK-native content type for Anthropic human messages */
|
|
7
7
|
type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Duration } from '@temporalio/common';
|
|
2
1
|
import { ActivityFunctionWithOptions, QueryDefinition, ChildWorkflowOptions, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
3
2
|
import { UpdateDefinition } from '@temporalio/common/lib/interfaces';
|
|
4
3
|
import { z } from 'zod';
|
|
@@ -544,6 +543,13 @@ declare class VirtualFileSystem<TCtx = unknown, TMeta = FileEntryMetadata> imple
|
|
|
544
543
|
getEntry(path: string): FileEntry<TMeta> | undefined;
|
|
545
544
|
readFile(path: string): Promise<string>;
|
|
546
545
|
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
546
|
+
/**
|
|
547
|
+
* Resolve the string content for an entry, preferring inline content
|
|
548
|
+
* carried on the entry itself before consulting the resolver. Used by
|
|
549
|
+
* `readFile`, `appendFile`, and `cp` so all read paths agree on the
|
|
550
|
+
* lookup precedence.
|
|
551
|
+
*/
|
|
552
|
+
private readEntryContent;
|
|
547
553
|
exists(path: string): Promise<boolean>;
|
|
548
554
|
stat(path: string): Promise<FileStat>;
|
|
549
555
|
readdir(path: string): Promise<string[]>;
|
|
@@ -577,6 +583,25 @@ interface FileEntry<TMeta = FileEntryMetadata> {
|
|
|
577
583
|
/** ISO-8601 date string (JSON-safe) */
|
|
578
584
|
mtime: string;
|
|
579
585
|
metadata: TMeta;
|
|
586
|
+
/**
|
|
587
|
+
* Optional inline content carried directly on the entry. When present the
|
|
588
|
+
* {@link VirtualFileSystem} returns this string from `readFile` /
|
|
589
|
+
* `readFileBuffer` (and uses it as the source for `cp` / `appendFile`)
|
|
590
|
+
* without consulting the resolver.
|
|
591
|
+
*
|
|
592
|
+
* Use this for files that exist purely in workflow state and have no
|
|
593
|
+
* backing in the consumer's data layer (e.g. skill resources bundled at
|
|
594
|
+
* session creation time). Because the content travels with the entry,
|
|
595
|
+
* any tool handler that constructs a `VirtualFileSystem` from `fileTree`
|
|
596
|
+
* sees the same content — no separate `inlineFiles` plumbing required.
|
|
597
|
+
*
|
|
598
|
+
* Read-only: entries with `inlineContent` reject in-place mutations
|
|
599
|
+
* (`writeFile`, `appendFile`, `rm`, `mv` of the entry, `cp` over the
|
|
600
|
+
* entry as destination). The resolver has no contract for the synthetic
|
|
601
|
+
* `id` these entries carry, so attempting a mutation throws an `EROFS`
|
|
602
|
+
* error instead of silently routing a doomed call through the resolver.
|
|
603
|
+
*/
|
|
604
|
+
inlineContent?: string;
|
|
580
605
|
}
|
|
581
606
|
/**
|
|
582
607
|
* Flat list of file entries.
|
|
@@ -1145,6 +1170,14 @@ interface SubagentSessionInput {
|
|
|
1145
1170
|
sandboxId?: string;
|
|
1146
1171
|
snapshot?: SandboxSnapshot;
|
|
1147
1172
|
threadId: string;
|
|
1173
|
+
usage: {
|
|
1174
|
+
totalInputTokens: number;
|
|
1175
|
+
totalOutputTokens: number;
|
|
1176
|
+
totalCachedWriteTokens: number;
|
|
1177
|
+
totalCachedReadTokens: number;
|
|
1178
|
+
totalReasonTokens: number;
|
|
1179
|
+
turns: number;
|
|
1180
|
+
};
|
|
1148
1181
|
}) => void;
|
|
1149
1182
|
}
|
|
1150
1183
|
|
|
@@ -1351,8 +1384,6 @@ interface SessionConfig<T extends ToolMap, M = unknown, TContent = string> {
|
|
|
1351
1384
|
* Returns SDK-native content for the initial human message.
|
|
1352
1385
|
*/
|
|
1353
1386
|
buildContextMessage: () => TContent | Promise<TContent>;
|
|
1354
|
-
/** How long to wait for input before cancelling the workflow */
|
|
1355
|
-
waitForInputTimeout?: Duration;
|
|
1356
1387
|
/**
|
|
1357
1388
|
* Thread initialization strategy (default: `{ mode: "new" }`).
|
|
1358
1389
|
*
|
|
@@ -1409,8 +1440,17 @@ interface SessionConfig<T extends ToolMap, M = unknown, TContent = string> {
|
|
|
1409
1440
|
* code to manually thread them through.
|
|
1410
1441
|
*/
|
|
1411
1442
|
onSessionExit?: (result: {
|
|
1443
|
+
threadId: string;
|
|
1412
1444
|
sandboxId?: string;
|
|
1413
1445
|
snapshot?: SandboxSnapshot;
|
|
1446
|
+
usage: {
|
|
1447
|
+
totalInputTokens: number;
|
|
1448
|
+
totalOutputTokens: number;
|
|
1449
|
+
totalCachedWriteTokens: number;
|
|
1450
|
+
totalCachedReadTokens: number;
|
|
1451
|
+
totalReasonTokens: number;
|
|
1452
|
+
turns: number;
|
|
1453
|
+
};
|
|
1414
1454
|
}) => void;
|
|
1415
1455
|
virtualFsOps?: VirtualFsOps;
|
|
1416
1456
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Duration } from '@temporalio/common';
|
|
2
1
|
import { ActivityFunctionWithOptions, QueryDefinition, ChildWorkflowOptions, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
3
2
|
import { UpdateDefinition } from '@temporalio/common/lib/interfaces';
|
|
4
3
|
import { z } from 'zod';
|
|
@@ -544,6 +543,13 @@ declare class VirtualFileSystem<TCtx = unknown, TMeta = FileEntryMetadata> imple
|
|
|
544
543
|
getEntry(path: string): FileEntry<TMeta> | undefined;
|
|
545
544
|
readFile(path: string): Promise<string>;
|
|
546
545
|
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
546
|
+
/**
|
|
547
|
+
* Resolve the string content for an entry, preferring inline content
|
|
548
|
+
* carried on the entry itself before consulting the resolver. Used by
|
|
549
|
+
* `readFile`, `appendFile`, and `cp` so all read paths agree on the
|
|
550
|
+
* lookup precedence.
|
|
551
|
+
*/
|
|
552
|
+
private readEntryContent;
|
|
547
553
|
exists(path: string): Promise<boolean>;
|
|
548
554
|
stat(path: string): Promise<FileStat>;
|
|
549
555
|
readdir(path: string): Promise<string[]>;
|
|
@@ -577,6 +583,25 @@ interface FileEntry<TMeta = FileEntryMetadata> {
|
|
|
577
583
|
/** ISO-8601 date string (JSON-safe) */
|
|
578
584
|
mtime: string;
|
|
579
585
|
metadata: TMeta;
|
|
586
|
+
/**
|
|
587
|
+
* Optional inline content carried directly on the entry. When present the
|
|
588
|
+
* {@link VirtualFileSystem} returns this string from `readFile` /
|
|
589
|
+
* `readFileBuffer` (and uses it as the source for `cp` / `appendFile`)
|
|
590
|
+
* without consulting the resolver.
|
|
591
|
+
*
|
|
592
|
+
* Use this for files that exist purely in workflow state and have no
|
|
593
|
+
* backing in the consumer's data layer (e.g. skill resources bundled at
|
|
594
|
+
* session creation time). Because the content travels with the entry,
|
|
595
|
+
* any tool handler that constructs a `VirtualFileSystem` from `fileTree`
|
|
596
|
+
* sees the same content — no separate `inlineFiles` plumbing required.
|
|
597
|
+
*
|
|
598
|
+
* Read-only: entries with `inlineContent` reject in-place mutations
|
|
599
|
+
* (`writeFile`, `appendFile`, `rm`, `mv` of the entry, `cp` over the
|
|
600
|
+
* entry as destination). The resolver has no contract for the synthetic
|
|
601
|
+
* `id` these entries carry, so attempting a mutation throws an `EROFS`
|
|
602
|
+
* error instead of silently routing a doomed call through the resolver.
|
|
603
|
+
*/
|
|
604
|
+
inlineContent?: string;
|
|
580
605
|
}
|
|
581
606
|
/**
|
|
582
607
|
* Flat list of file entries.
|
|
@@ -1145,6 +1170,14 @@ interface SubagentSessionInput {
|
|
|
1145
1170
|
sandboxId?: string;
|
|
1146
1171
|
snapshot?: SandboxSnapshot;
|
|
1147
1172
|
threadId: string;
|
|
1173
|
+
usage: {
|
|
1174
|
+
totalInputTokens: number;
|
|
1175
|
+
totalOutputTokens: number;
|
|
1176
|
+
totalCachedWriteTokens: number;
|
|
1177
|
+
totalCachedReadTokens: number;
|
|
1178
|
+
totalReasonTokens: number;
|
|
1179
|
+
turns: number;
|
|
1180
|
+
};
|
|
1148
1181
|
}) => void;
|
|
1149
1182
|
}
|
|
1150
1183
|
|
|
@@ -1351,8 +1384,6 @@ interface SessionConfig<T extends ToolMap, M = unknown, TContent = string> {
|
|
|
1351
1384
|
* Returns SDK-native content for the initial human message.
|
|
1352
1385
|
*/
|
|
1353
1386
|
buildContextMessage: () => TContent | Promise<TContent>;
|
|
1354
|
-
/** How long to wait for input before cancelling the workflow */
|
|
1355
|
-
waitForInputTimeout?: Duration;
|
|
1356
1387
|
/**
|
|
1357
1388
|
* Thread initialization strategy (default: `{ mode: "new" }`).
|
|
1358
1389
|
*
|
|
@@ -1409,8 +1440,17 @@ interface SessionConfig<T extends ToolMap, M = unknown, TContent = string> {
|
|
|
1409
1440
|
* code to manually thread them through.
|
|
1410
1441
|
*/
|
|
1411
1442
|
onSessionExit?: (result: {
|
|
1443
|
+
threadId: string;
|
|
1412
1444
|
sandboxId?: string;
|
|
1413
1445
|
snapshot?: SandboxSnapshot;
|
|
1446
|
+
usage: {
|
|
1447
|
+
totalInputTokens: number;
|
|
1448
|
+
totalOutputTokens: number;
|
|
1449
|
+
totalCachedWriteTokens: number;
|
|
1450
|
+
totalCachedReadTokens: number;
|
|
1451
|
+
totalReasonTokens: number;
|
|
1452
|
+
turns: number;
|
|
1453
|
+
};
|
|
1414
1454
|
}) => void;
|
|
1415
1455
|
virtualFsOps?: VirtualFsOps;
|
|
1416
1456
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { as as ToolMap, a1 as SessionConfig, aD as ZeitlichSession, $ as SandboxShutdown, ak as ThreadInit, _ as SandboxInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aF as ToolRouterOptions, av as ToolRouter, R as RouterContext, J as JsonValue, ax as ToolWithHandler, w as ParsedToolCallUnion, at as ToolNames, aa as SubagentDefinition, ad as SubagentHooks, ae as SubagentSandboxConfig, a9 as SubagentConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ab as SubagentFnResult, a6 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, al as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, az as VirtualFileTree, k as TreeMutation, s as FileEntry, aA as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, aq as ToolHandler, aC as WorkflowTask, d as ActivityToolHandler } from './types-
|
|
1
|
+
import { as as ToolMap, a1 as SessionConfig, aD as ZeitlichSession, $ as SandboxShutdown, ak as ThreadInit, _ as SandboxInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aF as ToolRouterOptions, av as ToolRouter, R as RouterContext, J as JsonValue, ax as ToolWithHandler, w as ParsedToolCallUnion, at as ToolNames, aa as SubagentDefinition, ad as SubagentHooks, ae as SubagentSandboxConfig, a9 as SubagentConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ab as SubagentFnResult, a6 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, al as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, az as VirtualFileTree, k as TreeMutation, s as FileEntry, aA as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, aq as ToolHandler, aC as WorkflowTask, d as ActivityToolHandler } from './types-DjaQKUJx.cjs';
|
|
2
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';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { as as ToolMap, a1 as SessionConfig, aD as ZeitlichSession, $ as SandboxShutdown, ak as ThreadInit, _ as SandboxInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aF as ToolRouterOptions, av as ToolRouter, R as RouterContext, J as JsonValue, ax as ToolWithHandler, w as ParsedToolCallUnion, at as ToolNames, aa as SubagentDefinition, ad as SubagentHooks, ae as SubagentSandboxConfig, a9 as SubagentConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ab as SubagentFnResult, a6 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, al as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, az as VirtualFileTree, k as TreeMutation, s as FileEntry, aA as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, aq as ToolHandler, aC as WorkflowTask, d as ActivityToolHandler } from './types-
|
|
1
|
+
import { as as ToolMap, a1 as SessionConfig, aD as ZeitlichSession, $ as SandboxShutdown, ak as ThreadInit, _ as SandboxInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aF as ToolRouterOptions, av as ToolRouter, R as RouterContext, J as JsonValue, ax as ToolWithHandler, w as ParsedToolCallUnion, at as ToolNames, aa as SubagentDefinition, ad as SubagentHooks, ae as SubagentSandboxConfig, a9 as SubagentConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ab as SubagentFnResult, a6 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, al as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, az as VirtualFileTree, k as TreeMutation, s as FileEntry, aA as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, aq as ToolHandler, aC as WorkflowTask, d as ActivityToolHandler } from './types-BqTmyH31.js';
|
|
2
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';
|
package/dist/workflow.cjs
CHANGED
|
@@ -953,7 +953,6 @@ async function createSession({
|
|
|
953
953
|
processToolsInParallel = true,
|
|
954
954
|
hooks = {},
|
|
955
955
|
appendSystemPrompt = true,
|
|
956
|
-
waitForInputTimeout = "48h",
|
|
957
956
|
threadKey,
|
|
958
957
|
sandboxOps,
|
|
959
958
|
thread: threadInit,
|
|
@@ -1136,12 +1135,23 @@ async function createSession({
|
|
|
1136
1135
|
path,
|
|
1137
1136
|
size: content.length,
|
|
1138
1137
|
mtime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1139
|
-
metadata: {}
|
|
1138
|
+
metadata: {},
|
|
1139
|
+
// Carry the content directly on the entry so any handler that
|
|
1140
|
+
// constructs a VirtualFileSystem from `fileTree` can read it
|
|
1141
|
+
// without needing to also wire up `inlineFiles` from state.
|
|
1142
|
+
inlineContent: content
|
|
1140
1143
|
}))
|
|
1141
1144
|
] : result.fileTree;
|
|
1142
1145
|
stateManager.mergeUpdate({
|
|
1143
1146
|
fileTree,
|
|
1144
1147
|
virtualFsCtx: virtualFsConfig.ctx,
|
|
1148
|
+
// `inlineFiles` is still the source of truth at read time:
|
|
1149
|
+
// VirtualFileSystem checks the inlineFiles map first and only
|
|
1150
|
+
// falls through to entry.inlineContent. Embedding the content on
|
|
1151
|
+
// the entry is the migration target so that handlers building a
|
|
1152
|
+
// VirtualFileSystem from `fileTree` alone (without forwarding
|
|
1153
|
+
// `inlineFiles` from state) can read skill resources. Until a
|
|
1154
|
+
// follow-up drops `inlineFiles`, both fields are populated.
|
|
1145
1155
|
...skillFiles && { inlineFiles: skillFiles }
|
|
1146
1156
|
});
|
|
1147
1157
|
}
|
|
@@ -1267,18 +1277,6 @@ async function createSession({
|
|
|
1267
1277
|
continue;
|
|
1268
1278
|
}
|
|
1269
1279
|
assistantId = void 0;
|
|
1270
|
-
if (stateManager.getStatus() === "WAITING_FOR_INPUT") {
|
|
1271
|
-
const conditionMet = await workflow.condition(
|
|
1272
|
-
() => stateManager.getStatus() === "RUNNING",
|
|
1273
|
-
waitForInputTimeout
|
|
1274
|
-
);
|
|
1275
|
-
if (!conditionMet) {
|
|
1276
|
-
stateManager.cancel();
|
|
1277
|
-
exitReason = "cancelled";
|
|
1278
|
-
await workflow.condition(() => false, "2s");
|
|
1279
|
-
break;
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
1280
|
}
|
|
1283
1281
|
if (stateManager.getTurns() >= maxTurns && stateManager.isRunning()) {
|
|
1284
1282
|
exitReason = "max_turns";
|
|
@@ -1351,7 +1349,9 @@ async function createSession({
|
|
|
1351
1349
|
if (onSessionExit) {
|
|
1352
1350
|
onSessionExit({
|
|
1353
1351
|
...sandboxId && { sandboxId },
|
|
1354
|
-
...exitSnapshot && { snapshot: exitSnapshot }
|
|
1352
|
+
...exitSnapshot && { snapshot: exitSnapshot },
|
|
1353
|
+
threadId,
|
|
1354
|
+
usage: stateManager.getTotalUsage()
|
|
1355
1355
|
});
|
|
1356
1356
|
}
|
|
1357
1357
|
return {
|
|
@@ -1572,6 +1572,20 @@ function createAgentStateManager({
|
|
|
1572
1572
|
}
|
|
1573
1573
|
};
|
|
1574
1574
|
}
|
|
1575
|
+
var SandboxNotSupportedError = class extends common.ApplicationFailure {
|
|
1576
|
+
constructor(operation) {
|
|
1577
|
+
super(
|
|
1578
|
+
`Sandbox does not support: ${operation}`,
|
|
1579
|
+
"SandboxNotSupportedError",
|
|
1580
|
+
true
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
};
|
|
1584
|
+
var SandboxNotFoundError = class extends common.ApplicationFailure {
|
|
1585
|
+
constructor(sandboxId) {
|
|
1586
|
+
super(`Sandbox not found: ${sandboxId}`, "SandboxNotFoundError", true);
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1575
1589
|
|
|
1576
1590
|
// src/lib/subagent/define.ts
|
|
1577
1591
|
function defineSubagent(definition, overrides) {
|
|
@@ -1600,6 +1614,7 @@ function defineSubagentWorkflow(config, fn) {
|
|
|
1600
1614
|
let capturedSnapshot;
|
|
1601
1615
|
let capturedBaseSnapshot;
|
|
1602
1616
|
let capturedThreadId;
|
|
1617
|
+
let capturedUsage;
|
|
1603
1618
|
const sessionInput = {
|
|
1604
1619
|
agentName: config.name,
|
|
1605
1620
|
sandboxShutdown: effectiveShutdown,
|
|
@@ -1616,10 +1631,17 @@ function defineSubagentWorkflow(config, fn) {
|
|
|
1616
1631
|
});
|
|
1617
1632
|
}
|
|
1618
1633
|
},
|
|
1619
|
-
onSessionExit: ({ sandboxId, snapshot, threadId }) => {
|
|
1634
|
+
onSessionExit: ({ sandboxId, snapshot, threadId, usage }) => {
|
|
1620
1635
|
capturedSandboxId = sandboxId;
|
|
1621
1636
|
capturedSnapshot = snapshot;
|
|
1622
1637
|
capturedThreadId = threadId;
|
|
1638
|
+
capturedUsage = {
|
|
1639
|
+
inputTokens: usage.totalInputTokens,
|
|
1640
|
+
outputTokens: usage.totalOutputTokens,
|
|
1641
|
+
cachedWriteTokens: usage.totalCachedWriteTokens,
|
|
1642
|
+
cachedReadTokens: usage.totalCachedReadTokens,
|
|
1643
|
+
reasonTokens: usage.totalReasonTokens
|
|
1644
|
+
};
|
|
1623
1645
|
}
|
|
1624
1646
|
};
|
|
1625
1647
|
const result = await fn(prompt, sessionInput, context ?? {});
|
|
@@ -1630,7 +1652,8 @@ function defineSubagentWorkflow(config, fn) {
|
|
|
1630
1652
|
...capturedSnapshot !== void 0 && { snapshot: capturedSnapshot },
|
|
1631
1653
|
...capturedBaseSnapshot !== void 0 && {
|
|
1632
1654
|
baseSnapshot: capturedBaseSnapshot
|
|
1633
|
-
}
|
|
1655
|
+
},
|
|
1656
|
+
...capturedUsage !== void 0 && { usage: capturedUsage }
|
|
1634
1657
|
};
|
|
1635
1658
|
};
|
|
1636
1659
|
Object.defineProperty(workflow$1, "name", { value: config.name });
|
|
@@ -1714,20 +1737,6 @@ function proxyRunAgent(scope, options) {
|
|
|
1714
1737
|
);
|
|
1715
1738
|
return acts[name];
|
|
1716
1739
|
}
|
|
1717
|
-
var SandboxNotSupportedError = class extends common.ApplicationFailure {
|
|
1718
|
-
constructor(operation) {
|
|
1719
|
-
super(
|
|
1720
|
-
`Sandbox does not support: ${operation}`,
|
|
1721
|
-
"SandboxNotSupportedError",
|
|
1722
|
-
true
|
|
1723
|
-
);
|
|
1724
|
-
}
|
|
1725
|
-
};
|
|
1726
|
-
var SandboxNotFoundError = class extends common.ApplicationFailure {
|
|
1727
|
-
constructor(sandboxId) {
|
|
1728
|
-
super(`Sandbox not found: ${sandboxId}`, "SandboxNotFoundError", true);
|
|
1729
|
-
}
|
|
1730
|
-
};
|
|
1731
1740
|
|
|
1732
1741
|
// src/lib/virtual-fs/mutations.ts
|
|
1733
1742
|
function applyVirtualTreeMutations(stateManager, mutations) {
|