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
package/dist/index.d.cts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { B as BashArgs, F as FileEditArgs, G as GlobArgs, a as FileReadArgs, b as FileWriteArgs } from './workflow-
|
|
2
|
-
export { A as AskUserQuestionArgs, D as DEFAULT_SUBAGENT_WORKFLOW_RUN_TIMEOUT, c as FileTreeAccessor, d as GrepArgs, O as ObservabilityHooks, R as ReadSkillArgs, S as SessionEndedEvent, e as SessionStartedEvent, f as SubagentArgs, T as THREAD_TTL_SECONDS, g as TaskCreateArgs, h as TaskGetArgs, i as TaskListArgs, j as TaskUpdateArgs, k as ToolExecutedEvent, l as TurnCompletedEvent, W as WorkflowConfig, m as WorkflowInput, n as WorkflowSessionInput, Z as ZeitlichObservabilitySinks, o as applyVirtualTreeMutations, p as askUserQuestionTool, q as bashTool, r as composeHooks, s as createAgentStateManager, t as createAskUserQuestionHandler, u as createBashToolDescription, v as createObservabilityHooks, w as createReadSkillHandler, x as createReadSkillTool, y as createSession, z as createTaskCreateHandler, C as createTaskGetHandler, E as createTaskListHandler, H as createTaskUpdateHandler, I as createToolRouter, J as defineSubagent, K as defineSubagentWorkflow, L as defineTool, M as defineWorkflow, N as editTool, P as filesWithMimeType, Q as formatVirtualFileTree, U as getShortId, V as getThreadListKey, X as getThreadMetaKey, Y as globTool, _ as grepTool, $ as hasDirectory, a0 as hasFileWithMimeType, a1 as hasNoOtherToolCalls, a2 as parseSkillFile, a3 as proxyRunAgent, a4 as proxyVirtualFsOps, a5 as readFileTool, a6 as taskCreateTool, a7 as taskGetTool, a8 as taskListTool, a9 as taskUpdateTool, aa as writeFileTool } from './workflow-
|
|
3
|
-
import { R as RouterContext, e as ToolResultConfig, d as ActivityToolHandler, J as JsonValue, c as ToolHandlerResponse, B as BaseAgentState, f as RunAgentConfig, g as SkillProvider, h as SkillMetadata, i as Skill, F as FileEntryMetadata, j as FileResolver, V as VirtualFsContext, k as TreeMutation, l as PrefixedVirtualFsOps } from './types-
|
|
4
|
-
export { m as AgentConfig, n as AgentFile, A as AgentResponse, o as AgentState, p as AgentStateManager, q as AgentStatus, r as AppendToolResultFn, s as FileEntry, H as Hooks, I as InferToolResults, t as JsonPrimitive, u as JsonSerializable, a as ModelInvoker, M as ModelInvokerConfig, v as ParsedToolCall, w as ParsedToolCallUnion, P as PersistedThreadState, x as PostHumanMessageAppendHook, y as PostHumanMessageAppendHookContext, z as PostToolUseFailureHook, C as PostToolUseFailureHookContext, D as PostToolUseFailureHookResult, E as PostToolUseHook, G as PostToolUseHookContext, K as PreHumanMessageAppendHook, L as PreHumanMessageAppendHookContext, N as PreToolUseHook, O as PreToolUseHookContext, Q as PreToolUseHookResult, b as PrefixedThreadOps, U as ProcessToolCallsContext, W as ProcessToolCallsResult, X as RawToolCall, Y as RewindSignal, Z as RunAgentActivity, _ as SandboxInit, $ as SandboxShutdown, S as ScopedPrefix, a0 as SerializableToolDefinition, a1 as SessionConfig, a2 as SessionEndHook, a3 as SessionEndHookContext, a4 as SessionExitReason, a5 as SessionResult, a6 as SessionStartHook, a7 as SessionStartHookContext, a8 as SubagentChildWorkflowOptions, a9 as SubagentConfig, aa as SubagentDefinition, ab as SubagentFnResult, ac as SubagentHandlerResponse, ad as SubagentHooks, ae as SubagentSandboxConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ah as SubagentWorkflow, ai as SubagentWorkflowInput, aj as TaskStatus, ak as ThreadInit, T as ThreadOps, al as TokenUsage, am as ToolArgs, an as ToolCallResult, ao as ToolCallResultUnion, ap as ToolDefinition, aq as ToolHandler, ar as ToolHooks, as as ToolMap, at as ToolNames, au as ToolResult, av as ToolRouter, aw as ToolRouterHooks, ax as ToolWithHandler, ay as VirtualFileSystem, az as VirtualFileTree, aA as VirtualFsOps, aB as VirtualFsState, aC as WorkflowTask, aD as ZeitlichSession, aE as isTerminalStatus } from './types-
|
|
1
|
+
import { B as BashArgs, F as FileEditArgs, G as GlobArgs, a as FileReadArgs, b as FileWriteArgs } from './workflow-CuqxgS6X.cjs';
|
|
2
|
+
export { A as AskUserQuestionArgs, D as DEFAULT_SUBAGENT_WORKFLOW_RUN_TIMEOUT, c as FileTreeAccessor, d as GrepArgs, O as ObservabilityHooks, R as ReadSkillArgs, S as SessionEndedEvent, e as SessionStartedEvent, f as SubagentArgs, T as THREAD_TTL_SECONDS, g as TaskCreateArgs, h as TaskGetArgs, i as TaskListArgs, j as TaskUpdateArgs, k as ToolExecutedEvent, l as TurnCompletedEvent, W as WorkflowConfig, m as WorkflowInput, n as WorkflowSessionInput, Z as ZeitlichObservabilitySinks, o as applyVirtualTreeMutations, p as askUserQuestionTool, q as bashTool, r as composeHooks, s as createAgentStateManager, t as createAskUserQuestionHandler, u as createBashToolDescription, v as createObservabilityHooks, w as createReadSkillHandler, x as createReadSkillTool, y as createSession, z as createTaskCreateHandler, C as createTaskGetHandler, E as createTaskListHandler, H as createTaskUpdateHandler, I as createToolRouter, J as defineSubagent, K as defineSubagentWorkflow, L as defineTool, M as defineWorkflow, N as editTool, P as filesWithMimeType, Q as formatVirtualFileTree, U as getShortId, V as getThreadListKey, X as getThreadMetaKey, Y as globTool, _ as grepTool, $ as hasDirectory, a0 as hasFileWithMimeType, a1 as hasNoOtherToolCalls, a2 as parseSkillFile, a3 as proxyRunAgent, a4 as proxyVirtualFsOps, a5 as readFileTool, a6 as taskCreateTool, a7 as taskGetTool, a8 as taskListTool, a9 as taskUpdateTool, aa as writeFileTool } from './workflow-CuqxgS6X.cjs';
|
|
3
|
+
import { R as RouterContext, e as ToolResultConfig, d as ActivityToolHandler, J as JsonValue, c as ToolHandlerResponse, B as BaseAgentState, f as RunAgentConfig, g as SkillProvider, h as SkillMetadata, i as Skill, F as FileEntryMetadata, j as FileResolver, V as VirtualFsContext, k as TreeMutation, l as PrefixedVirtualFsOps } from './types-DjaQKUJx.cjs';
|
|
4
|
+
export { m as AgentConfig, n as AgentFile, A as AgentResponse, o as AgentState, p as AgentStateManager, q as AgentStatus, r as AppendToolResultFn, s as FileEntry, H as Hooks, I as InferToolResults, t as JsonPrimitive, u as JsonSerializable, a as ModelInvoker, M as ModelInvokerConfig, v as ParsedToolCall, w as ParsedToolCallUnion, P as PersistedThreadState, x as PostHumanMessageAppendHook, y as PostHumanMessageAppendHookContext, z as PostToolUseFailureHook, C as PostToolUseFailureHookContext, D as PostToolUseFailureHookResult, E as PostToolUseHook, G as PostToolUseHookContext, K as PreHumanMessageAppendHook, L as PreHumanMessageAppendHookContext, N as PreToolUseHook, O as PreToolUseHookContext, Q as PreToolUseHookResult, b as PrefixedThreadOps, U as ProcessToolCallsContext, W as ProcessToolCallsResult, X as RawToolCall, Y as RewindSignal, Z as RunAgentActivity, _ as SandboxInit, $ as SandboxShutdown, S as ScopedPrefix, a0 as SerializableToolDefinition, a1 as SessionConfig, a2 as SessionEndHook, a3 as SessionEndHookContext, a4 as SessionExitReason, a5 as SessionResult, a6 as SessionStartHook, a7 as SessionStartHookContext, a8 as SubagentChildWorkflowOptions, a9 as SubagentConfig, aa as SubagentDefinition, ab as SubagentFnResult, ac as SubagentHandlerResponse, ad as SubagentHooks, ae as SubagentSandboxConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ah as SubagentWorkflow, ai as SubagentWorkflowInput, aj as TaskStatus, ak as ThreadInit, T as ThreadOps, al as TokenUsage, am as ToolArgs, an as ToolCallResult, ao as ToolCallResultUnion, ap as ToolDefinition, aq as ToolHandler, ar as ToolHooks, as as ToolMap, at as ToolNames, au as ToolResult, av as ToolRouter, aw as ToolRouterHooks, ax as ToolWithHandler, ay as VirtualFileSystem, az as VirtualFileTree, aA as VirtualFsOps, aB as VirtualFsState, aC as WorkflowTask, aD as ZeitlichSession, aE as isTerminalStatus } from './types-DjaQKUJx.cjs';
|
|
5
5
|
import { S as Sandbox, a as SandboxFileSystem, d as SandboxCreateOptions, b as SandboxProvider, f as SandboxSnapshot, P as PrefixedSandboxOps, F as FileStat, D as DirentEntry, E as ExecResult } from './types-yx0LzPGn.cjs';
|
|
6
6
|
export { h as ExecOptions, c as SandboxCapabilities, e as SandboxCreateResult, i as SandboxNotFoundError, j as SandboxNotSupportedError, g as SandboxOps } from './types-yx0LzPGn.cjs';
|
|
7
7
|
import { WorkflowClient } from '@temporalio/client';
|
|
8
|
-
import { a as ThreadManagerConfig, B as BaseThreadManager } from './types-
|
|
9
|
-
export { P as ProviderThreadManager } from './types-
|
|
8
|
+
import { a as ThreadManagerConfig, B as BaseThreadManager } from './types-CdvcmXb6.cjs';
|
|
9
|
+
export { P as ProviderThreadManager } from './types-CdvcmXb6.cjs';
|
|
10
10
|
import 'zod';
|
|
11
11
|
import '@temporalio/workflow';
|
|
12
|
-
import '@temporalio/common';
|
|
13
12
|
import '@temporalio/common/lib/interfaces';
|
|
13
|
+
import '@temporalio/common';
|
|
14
14
|
import 'ioredis';
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -42,6 +42,32 @@ import 'ioredis';
|
|
|
42
42
|
*/
|
|
43
43
|
declare function withAutoAppend<TArgs, TResult, TContext extends RouterContext = RouterContext, TToolResponse = unknown>(threadHandler: (id: string, config: ToolResultConfig) => Promise<void>, handler: ActivityToolHandler<TArgs, TResult, TContext, TToolResponse>): ActivityToolHandler<TArgs, TResult, TContext>;
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Options for {@link withSandbox}.
|
|
47
|
+
*/
|
|
48
|
+
interface WithSandboxOptions {
|
|
49
|
+
/**
|
|
50
|
+
* If `true`, a {@link SandboxNotFoundError} thrown by `manager.getSandbox`
|
|
51
|
+
* is translated into a structured tool-handler response (instead of
|
|
52
|
+
* propagating). This lets the agent return a graceful error to the model
|
|
53
|
+
* rather than crashing the workflow when the backing sandbox has been
|
|
54
|
+
* killed mid-run (e.g. because the E2B `timeoutMs` lifetime elapsed).
|
|
55
|
+
*
|
|
56
|
+
* Off by default to preserve the existing contract for callers that rely
|
|
57
|
+
* on the error bubbling out. New callers should generally enable this in
|
|
58
|
+
* combination with the E2B `keepAliveMs` provider option.
|
|
59
|
+
*
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
translateSandboxNotFound?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Custom tool response returned to the agent when the backing sandbox
|
|
65
|
+
* is not found and `translateSandboxNotFound` is `true`. Defaults to a
|
|
66
|
+
* generic English message. Use this to localize, match agent persona,
|
|
67
|
+
* or give the model more specific recovery instructions.
|
|
68
|
+
*/
|
|
69
|
+
sandboxNotFoundToolResponse?: string;
|
|
70
|
+
}
|
|
45
71
|
/**
|
|
46
72
|
* Extended router context with a resolved {@link Sandbox} instance.
|
|
47
73
|
*
|
|
@@ -95,7 +121,7 @@ declare function withSandbox<TArgs, TResult, TSandbox extends Sandbox = Sandbox,
|
|
|
95
121
|
}, handler: (args: TArgs, context: RouterContext & {
|
|
96
122
|
sandbox: TSandbox;
|
|
97
123
|
sandboxId: string;
|
|
98
|
-
}) => Promise<ToolHandlerResponse<TResult, TToolResponse
|
|
124
|
+
}) => Promise<ToolHandlerResponse<TResult, TToolResponse>>, options?: WithSandboxOptions): ActivityToolHandler<TArgs, TResult | null, RouterContext, TToolResponse | string>;
|
|
99
125
|
|
|
100
126
|
/**
|
|
101
127
|
* Safely retrieve Temporal activity heartbeat and cancellation signal.
|
|
@@ -518,4 +544,4 @@ declare const toTree: (fs: SandboxFileSystem, opts?: {
|
|
|
518
544
|
sort?: boolean;
|
|
519
545
|
}) => Promise<string>;
|
|
520
546
|
|
|
521
|
-
export { ActivityToolHandler, type AgentStateContext, BaseAgentState, BaseThreadManager, BashArgs, ExecResult, FileEditArgs, FileEntryMetadata, FileReadArgs, FileResolver, FileSystemSkillProvider, FileWriteArgs, GlobArgs, JsonValue, NodeFsSandboxFileSystem, type PreCreateHookResult, PrefixedSandboxOps, PrefixedVirtualFsOps, RouterContext, RunAgentConfig, Sandbox, type SandboxContext, SandboxCreateOptions, DirentEntry as SandboxDirentEntry, FileStat as SandboxFileStat, SandboxFileSystem, SandboxManager, type SandboxManagerHooks, SandboxProvider, SandboxSnapshot, Skill, SkillMetadata, SkillProvider, ThreadManagerConfig, ToolHandlerResponse, ToolResultConfig, TreeMutation, VirtualFsContext, bashHandler, createRunAgentActivity, createThreadManager, createVirtualFsActivities, editHandler, getActivityContext, globHandler, queryParentWorkflowState, readFileHandler, toTree, withAutoAppend, withParentWorkflowState, withSandbox, withVirtualFs, writeFileHandler };
|
|
547
|
+
export { ActivityToolHandler, type AgentStateContext, BaseAgentState, BaseThreadManager, BashArgs, ExecResult, FileEditArgs, FileEntryMetadata, FileReadArgs, FileResolver, FileSystemSkillProvider, FileWriteArgs, GlobArgs, JsonValue, NodeFsSandboxFileSystem, type PreCreateHookResult, PrefixedSandboxOps, PrefixedVirtualFsOps, RouterContext, RunAgentConfig, Sandbox, type SandboxContext, SandboxCreateOptions, DirentEntry as SandboxDirentEntry, FileStat as SandboxFileStat, SandboxFileSystem, SandboxManager, type SandboxManagerHooks, SandboxProvider, SandboxSnapshot, Skill, SkillMetadata, SkillProvider, ThreadManagerConfig, ToolHandlerResponse, ToolResultConfig, TreeMutation, VirtualFsContext, type WithSandboxOptions, bashHandler, createRunAgentActivity, createThreadManager, createVirtualFsActivities, editHandler, getActivityContext, globHandler, queryParentWorkflowState, readFileHandler, toTree, withAutoAppend, withParentWorkflowState, withSandbox, withVirtualFs, writeFileHandler };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { B as BashArgs, F as FileEditArgs, G as GlobArgs, a as FileReadArgs, b as FileWriteArgs } from './workflow-
|
|
2
|
-
export { A as AskUserQuestionArgs, D as DEFAULT_SUBAGENT_WORKFLOW_RUN_TIMEOUT, c as FileTreeAccessor, d as GrepArgs, O as ObservabilityHooks, R as ReadSkillArgs, S as SessionEndedEvent, e as SessionStartedEvent, f as SubagentArgs, T as THREAD_TTL_SECONDS, g as TaskCreateArgs, h as TaskGetArgs, i as TaskListArgs, j as TaskUpdateArgs, k as ToolExecutedEvent, l as TurnCompletedEvent, W as WorkflowConfig, m as WorkflowInput, n as WorkflowSessionInput, Z as ZeitlichObservabilitySinks, o as applyVirtualTreeMutations, p as askUserQuestionTool, q as bashTool, r as composeHooks, s as createAgentStateManager, t as createAskUserQuestionHandler, u as createBashToolDescription, v as createObservabilityHooks, w as createReadSkillHandler, x as createReadSkillTool, y as createSession, z as createTaskCreateHandler, C as createTaskGetHandler, E as createTaskListHandler, H as createTaskUpdateHandler, I as createToolRouter, J as defineSubagent, K as defineSubagentWorkflow, L as defineTool, M as defineWorkflow, N as editTool, P as filesWithMimeType, Q as formatVirtualFileTree, U as getShortId, V as getThreadListKey, X as getThreadMetaKey, Y as globTool, _ as grepTool, $ as hasDirectory, a0 as hasFileWithMimeType, a1 as hasNoOtherToolCalls, a2 as parseSkillFile, a3 as proxyRunAgent, a4 as proxyVirtualFsOps, a5 as readFileTool, a6 as taskCreateTool, a7 as taskGetTool, a8 as taskListTool, a9 as taskUpdateTool, aa as writeFileTool } from './workflow-
|
|
3
|
-
import { R as RouterContext, e as ToolResultConfig, d as ActivityToolHandler, J as JsonValue, c as ToolHandlerResponse, B as BaseAgentState, f as RunAgentConfig, g as SkillProvider, h as SkillMetadata, i as Skill, F as FileEntryMetadata, j as FileResolver, V as VirtualFsContext, k as TreeMutation, l as PrefixedVirtualFsOps } from './types-
|
|
4
|
-
export { m as AgentConfig, n as AgentFile, A as AgentResponse, o as AgentState, p as AgentStateManager, q as AgentStatus, r as AppendToolResultFn, s as FileEntry, H as Hooks, I as InferToolResults, t as JsonPrimitive, u as JsonSerializable, a as ModelInvoker, M as ModelInvokerConfig, v as ParsedToolCall, w as ParsedToolCallUnion, P as PersistedThreadState, x as PostHumanMessageAppendHook, y as PostHumanMessageAppendHookContext, z as PostToolUseFailureHook, C as PostToolUseFailureHookContext, D as PostToolUseFailureHookResult, E as PostToolUseHook, G as PostToolUseHookContext, K as PreHumanMessageAppendHook, L as PreHumanMessageAppendHookContext, N as PreToolUseHook, O as PreToolUseHookContext, Q as PreToolUseHookResult, b as PrefixedThreadOps, U as ProcessToolCallsContext, W as ProcessToolCallsResult, X as RawToolCall, Y as RewindSignal, Z as RunAgentActivity, _ as SandboxInit, $ as SandboxShutdown, S as ScopedPrefix, a0 as SerializableToolDefinition, a1 as SessionConfig, a2 as SessionEndHook, a3 as SessionEndHookContext, a4 as SessionExitReason, a5 as SessionResult, a6 as SessionStartHook, a7 as SessionStartHookContext, a8 as SubagentChildWorkflowOptions, a9 as SubagentConfig, aa as SubagentDefinition, ab as SubagentFnResult, ac as SubagentHandlerResponse, ad as SubagentHooks, ae as SubagentSandboxConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ah as SubagentWorkflow, ai as SubagentWorkflowInput, aj as TaskStatus, ak as ThreadInit, T as ThreadOps, al as TokenUsage, am as ToolArgs, an as ToolCallResult, ao as ToolCallResultUnion, ap as ToolDefinition, aq as ToolHandler, ar as ToolHooks, as as ToolMap, at as ToolNames, au as ToolResult, av as ToolRouter, aw as ToolRouterHooks, ax as ToolWithHandler, ay as VirtualFileSystem, az as VirtualFileTree, aA as VirtualFsOps, aB as VirtualFsState, aC as WorkflowTask, aD as ZeitlichSession, aE as isTerminalStatus } from './types-
|
|
1
|
+
import { B as BashArgs, F as FileEditArgs, G as GlobArgs, a as FileReadArgs, b as FileWriteArgs } from './workflow-N1MNDoul.js';
|
|
2
|
+
export { A as AskUserQuestionArgs, D as DEFAULT_SUBAGENT_WORKFLOW_RUN_TIMEOUT, c as FileTreeAccessor, d as GrepArgs, O as ObservabilityHooks, R as ReadSkillArgs, S as SessionEndedEvent, e as SessionStartedEvent, f as SubagentArgs, T as THREAD_TTL_SECONDS, g as TaskCreateArgs, h as TaskGetArgs, i as TaskListArgs, j as TaskUpdateArgs, k as ToolExecutedEvent, l as TurnCompletedEvent, W as WorkflowConfig, m as WorkflowInput, n as WorkflowSessionInput, Z as ZeitlichObservabilitySinks, o as applyVirtualTreeMutations, p as askUserQuestionTool, q as bashTool, r as composeHooks, s as createAgentStateManager, t as createAskUserQuestionHandler, u as createBashToolDescription, v as createObservabilityHooks, w as createReadSkillHandler, x as createReadSkillTool, y as createSession, z as createTaskCreateHandler, C as createTaskGetHandler, E as createTaskListHandler, H as createTaskUpdateHandler, I as createToolRouter, J as defineSubagent, K as defineSubagentWorkflow, L as defineTool, M as defineWorkflow, N as editTool, P as filesWithMimeType, Q as formatVirtualFileTree, U as getShortId, V as getThreadListKey, X as getThreadMetaKey, Y as globTool, _ as grepTool, $ as hasDirectory, a0 as hasFileWithMimeType, a1 as hasNoOtherToolCalls, a2 as parseSkillFile, a3 as proxyRunAgent, a4 as proxyVirtualFsOps, a5 as readFileTool, a6 as taskCreateTool, a7 as taskGetTool, a8 as taskListTool, a9 as taskUpdateTool, aa as writeFileTool } from './workflow-N1MNDoul.js';
|
|
3
|
+
import { R as RouterContext, e as ToolResultConfig, d as ActivityToolHandler, J as JsonValue, c as ToolHandlerResponse, B as BaseAgentState, f as RunAgentConfig, g as SkillProvider, h as SkillMetadata, i as Skill, F as FileEntryMetadata, j as FileResolver, V as VirtualFsContext, k as TreeMutation, l as PrefixedVirtualFsOps } from './types-BqTmyH31.js';
|
|
4
|
+
export { m as AgentConfig, n as AgentFile, A as AgentResponse, o as AgentState, p as AgentStateManager, q as AgentStatus, r as AppendToolResultFn, s as FileEntry, H as Hooks, I as InferToolResults, t as JsonPrimitive, u as JsonSerializable, a as ModelInvoker, M as ModelInvokerConfig, v as ParsedToolCall, w as ParsedToolCallUnion, P as PersistedThreadState, x as PostHumanMessageAppendHook, y as PostHumanMessageAppendHookContext, z as PostToolUseFailureHook, C as PostToolUseFailureHookContext, D as PostToolUseFailureHookResult, E as PostToolUseHook, G as PostToolUseHookContext, K as PreHumanMessageAppendHook, L as PreHumanMessageAppendHookContext, N as PreToolUseHook, O as PreToolUseHookContext, Q as PreToolUseHookResult, b as PrefixedThreadOps, U as ProcessToolCallsContext, W as ProcessToolCallsResult, X as RawToolCall, Y as RewindSignal, Z as RunAgentActivity, _ as SandboxInit, $ as SandboxShutdown, S as ScopedPrefix, a0 as SerializableToolDefinition, a1 as SessionConfig, a2 as SessionEndHook, a3 as SessionEndHookContext, a4 as SessionExitReason, a5 as SessionResult, a6 as SessionStartHook, a7 as SessionStartHookContext, a8 as SubagentChildWorkflowOptions, a9 as SubagentConfig, aa as SubagentDefinition, ab as SubagentFnResult, ac as SubagentHandlerResponse, ad as SubagentHooks, ae as SubagentSandboxConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ah as SubagentWorkflow, ai as SubagentWorkflowInput, aj as TaskStatus, ak as ThreadInit, T as ThreadOps, al as TokenUsage, am as ToolArgs, an as ToolCallResult, ao as ToolCallResultUnion, ap as ToolDefinition, aq as ToolHandler, ar as ToolHooks, as as ToolMap, at as ToolNames, au as ToolResult, av as ToolRouter, aw as ToolRouterHooks, ax as ToolWithHandler, ay as VirtualFileSystem, az as VirtualFileTree, aA as VirtualFsOps, aB as VirtualFsState, aC as WorkflowTask, aD as ZeitlichSession, aE as isTerminalStatus } from './types-BqTmyH31.js';
|
|
5
5
|
import { S as Sandbox, a as SandboxFileSystem, d as SandboxCreateOptions, b as SandboxProvider, f as SandboxSnapshot, P as PrefixedSandboxOps, F as FileStat, D as DirentEntry, E as ExecResult } from './types-yx0LzPGn.js';
|
|
6
6
|
export { h as ExecOptions, c as SandboxCapabilities, e as SandboxCreateResult, i as SandboxNotFoundError, j as SandboxNotSupportedError, g as SandboxOps } from './types-yx0LzPGn.js';
|
|
7
7
|
import { WorkflowClient } from '@temporalio/client';
|
|
8
|
-
import { a as ThreadManagerConfig, B as BaseThreadManager } from './types-
|
|
9
|
-
export { P as ProviderThreadManager } from './types-
|
|
8
|
+
import { a as ThreadManagerConfig, B as BaseThreadManager } from './types-CjF1_Idx.js';
|
|
9
|
+
export { P as ProviderThreadManager } from './types-CjF1_Idx.js';
|
|
10
10
|
import 'zod';
|
|
11
11
|
import '@temporalio/workflow';
|
|
12
|
-
import '@temporalio/common';
|
|
13
12
|
import '@temporalio/common/lib/interfaces';
|
|
13
|
+
import '@temporalio/common';
|
|
14
14
|
import 'ioredis';
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -42,6 +42,32 @@ import 'ioredis';
|
|
|
42
42
|
*/
|
|
43
43
|
declare function withAutoAppend<TArgs, TResult, TContext extends RouterContext = RouterContext, TToolResponse = unknown>(threadHandler: (id: string, config: ToolResultConfig) => Promise<void>, handler: ActivityToolHandler<TArgs, TResult, TContext, TToolResponse>): ActivityToolHandler<TArgs, TResult, TContext>;
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Options for {@link withSandbox}.
|
|
47
|
+
*/
|
|
48
|
+
interface WithSandboxOptions {
|
|
49
|
+
/**
|
|
50
|
+
* If `true`, a {@link SandboxNotFoundError} thrown by `manager.getSandbox`
|
|
51
|
+
* is translated into a structured tool-handler response (instead of
|
|
52
|
+
* propagating). This lets the agent return a graceful error to the model
|
|
53
|
+
* rather than crashing the workflow when the backing sandbox has been
|
|
54
|
+
* killed mid-run (e.g. because the E2B `timeoutMs` lifetime elapsed).
|
|
55
|
+
*
|
|
56
|
+
* Off by default to preserve the existing contract for callers that rely
|
|
57
|
+
* on the error bubbling out. New callers should generally enable this in
|
|
58
|
+
* combination with the E2B `keepAliveMs` provider option.
|
|
59
|
+
*
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
translateSandboxNotFound?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Custom tool response returned to the agent when the backing sandbox
|
|
65
|
+
* is not found and `translateSandboxNotFound` is `true`. Defaults to a
|
|
66
|
+
* generic English message. Use this to localize, match agent persona,
|
|
67
|
+
* or give the model more specific recovery instructions.
|
|
68
|
+
*/
|
|
69
|
+
sandboxNotFoundToolResponse?: string;
|
|
70
|
+
}
|
|
45
71
|
/**
|
|
46
72
|
* Extended router context with a resolved {@link Sandbox} instance.
|
|
47
73
|
*
|
|
@@ -95,7 +121,7 @@ declare function withSandbox<TArgs, TResult, TSandbox extends Sandbox = Sandbox,
|
|
|
95
121
|
}, handler: (args: TArgs, context: RouterContext & {
|
|
96
122
|
sandbox: TSandbox;
|
|
97
123
|
sandboxId: string;
|
|
98
|
-
}) => Promise<ToolHandlerResponse<TResult, TToolResponse
|
|
124
|
+
}) => Promise<ToolHandlerResponse<TResult, TToolResponse>>, options?: WithSandboxOptions): ActivityToolHandler<TArgs, TResult | null, RouterContext, TToolResponse | string>;
|
|
99
125
|
|
|
100
126
|
/**
|
|
101
127
|
* Safely retrieve Temporal activity heartbeat and cancellation signal.
|
|
@@ -518,4 +544,4 @@ declare const toTree: (fs: SandboxFileSystem, opts?: {
|
|
|
518
544
|
sort?: boolean;
|
|
519
545
|
}) => Promise<string>;
|
|
520
546
|
|
|
521
|
-
export { ActivityToolHandler, type AgentStateContext, BaseAgentState, BaseThreadManager, BashArgs, ExecResult, FileEditArgs, FileEntryMetadata, FileReadArgs, FileResolver, FileSystemSkillProvider, FileWriteArgs, GlobArgs, JsonValue, NodeFsSandboxFileSystem, type PreCreateHookResult, PrefixedSandboxOps, PrefixedVirtualFsOps, RouterContext, RunAgentConfig, Sandbox, type SandboxContext, SandboxCreateOptions, DirentEntry as SandboxDirentEntry, FileStat as SandboxFileStat, SandboxFileSystem, SandboxManager, type SandboxManagerHooks, SandboxProvider, SandboxSnapshot, Skill, SkillMetadata, SkillProvider, ThreadManagerConfig, ToolHandlerResponse, ToolResultConfig, TreeMutation, VirtualFsContext, bashHandler, createRunAgentActivity, createThreadManager, createVirtualFsActivities, editHandler, getActivityContext, globHandler, queryParentWorkflowState, readFileHandler, toTree, withAutoAppend, withParentWorkflowState, withSandbox, withVirtualFs, writeFileHandler };
|
|
547
|
+
export { ActivityToolHandler, type AgentStateContext, BaseAgentState, BaseThreadManager, BashArgs, ExecResult, FileEditArgs, FileEntryMetadata, FileReadArgs, FileResolver, FileSystemSkillProvider, FileWriteArgs, GlobArgs, JsonValue, NodeFsSandboxFileSystem, type PreCreateHookResult, PrefixedSandboxOps, PrefixedVirtualFsOps, RouterContext, RunAgentConfig, Sandbox, type SandboxContext, SandboxCreateOptions, DirentEntry as SandboxDirentEntry, FileStat as SandboxFileStat, SandboxFileSystem, SandboxManager, type SandboxManagerHooks, SandboxProvider, SandboxSnapshot, Skill, SkillMetadata, SkillProvider, ThreadManagerConfig, ToolHandlerResponse, ToolResultConfig, TreeMutation, VirtualFsContext, type WithSandboxOptions, bashHandler, createRunAgentActivity, createThreadManager, createVirtualFsActivities, editHandler, getActivityContext, globHandler, queryParentWorkflowState, readFileHandler, toTree, withAutoAppend, withParentWorkflowState, withSandbox, withVirtualFs, writeFileHandler };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineSignal, CancellationScope, isCancellation, uuid4, setHandler, defineUpdate, ApplicationFailure, log,
|
|
1
|
+
import { defineSignal, CancellationScope, isCancellation, uuid4, setHandler, defineUpdate, ApplicationFailure, log, defineQuery, condition, proxySinks, workflowInfo, proxyActivities, getExternalWorkflowHandle, executeChild } from '@temporalio/workflow';
|
|
2
2
|
import z14, { z } from 'zod';
|
|
3
3
|
import { randomUUID, randomFillSync } from 'crypto';
|
|
4
4
|
import { ApplicationFailure as ApplicationFailure$1 } from '@temporalio/common';
|
|
@@ -951,7 +951,6 @@ async function createSession({
|
|
|
951
951
|
processToolsInParallel = true,
|
|
952
952
|
hooks = {},
|
|
953
953
|
appendSystemPrompt = true,
|
|
954
|
-
waitForInputTimeout = "48h",
|
|
955
954
|
threadKey,
|
|
956
955
|
sandboxOps,
|
|
957
956
|
thread: threadInit,
|
|
@@ -1134,12 +1133,23 @@ async function createSession({
|
|
|
1134
1133
|
path,
|
|
1135
1134
|
size: content.length,
|
|
1136
1135
|
mtime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1137
|
-
metadata: {}
|
|
1136
|
+
metadata: {},
|
|
1137
|
+
// Carry the content directly on the entry so any handler that
|
|
1138
|
+
// constructs a VirtualFileSystem from `fileTree` can read it
|
|
1139
|
+
// without needing to also wire up `inlineFiles` from state.
|
|
1140
|
+
inlineContent: content
|
|
1138
1141
|
}))
|
|
1139
1142
|
] : result.fileTree;
|
|
1140
1143
|
stateManager.mergeUpdate({
|
|
1141
1144
|
fileTree,
|
|
1142
1145
|
virtualFsCtx: virtualFsConfig.ctx,
|
|
1146
|
+
// `inlineFiles` is still the source of truth at read time:
|
|
1147
|
+
// VirtualFileSystem checks the inlineFiles map first and only
|
|
1148
|
+
// falls through to entry.inlineContent. Embedding the content on
|
|
1149
|
+
// the entry is the migration target so that handlers building a
|
|
1150
|
+
// VirtualFileSystem from `fileTree` alone (without forwarding
|
|
1151
|
+
// `inlineFiles` from state) can read skill resources. Until a
|
|
1152
|
+
// follow-up drops `inlineFiles`, both fields are populated.
|
|
1143
1153
|
...skillFiles && { inlineFiles: skillFiles }
|
|
1144
1154
|
});
|
|
1145
1155
|
}
|
|
@@ -1265,18 +1275,6 @@ async function createSession({
|
|
|
1265
1275
|
continue;
|
|
1266
1276
|
}
|
|
1267
1277
|
assistantId = void 0;
|
|
1268
|
-
if (stateManager.getStatus() === "WAITING_FOR_INPUT") {
|
|
1269
|
-
const conditionMet = await condition(
|
|
1270
|
-
() => stateManager.getStatus() === "RUNNING",
|
|
1271
|
-
waitForInputTimeout
|
|
1272
|
-
);
|
|
1273
|
-
if (!conditionMet) {
|
|
1274
|
-
stateManager.cancel();
|
|
1275
|
-
exitReason = "cancelled";
|
|
1276
|
-
await condition(() => false, "2s");
|
|
1277
|
-
break;
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
1278
|
}
|
|
1281
1279
|
if (stateManager.getTurns() >= maxTurns && stateManager.isRunning()) {
|
|
1282
1280
|
exitReason = "max_turns";
|
|
@@ -1349,7 +1347,9 @@ async function createSession({
|
|
|
1349
1347
|
if (onSessionExit) {
|
|
1350
1348
|
onSessionExit({
|
|
1351
1349
|
...sandboxId && { sandboxId },
|
|
1352
|
-
...exitSnapshot && { snapshot: exitSnapshot }
|
|
1350
|
+
...exitSnapshot && { snapshot: exitSnapshot },
|
|
1351
|
+
threadId,
|
|
1352
|
+
usage: stateManager.getTotalUsage()
|
|
1353
1353
|
});
|
|
1354
1354
|
}
|
|
1355
1355
|
return {
|
|
@@ -1637,9 +1637,24 @@ function withAutoAppend(threadHandler, handler) {
|
|
|
1637
1637
|
};
|
|
1638
1638
|
};
|
|
1639
1639
|
}
|
|
1640
|
+
var SandboxNotSupportedError = class extends ApplicationFailure$1 {
|
|
1641
|
+
constructor(operation) {
|
|
1642
|
+
super(
|
|
1643
|
+
`Sandbox does not support: ${operation}`,
|
|
1644
|
+
"SandboxNotSupportedError",
|
|
1645
|
+
true
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
var SandboxNotFoundError = class extends ApplicationFailure$1 {
|
|
1650
|
+
constructor(sandboxId) {
|
|
1651
|
+
super(`Sandbox not found: ${sandboxId}`, "SandboxNotFoundError", true);
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1640
1654
|
|
|
1641
1655
|
// src/lib/tool-router/with-sandbox.ts
|
|
1642
|
-
function withSandbox(manager, handler) {
|
|
1656
|
+
function withSandbox(manager, handler, options) {
|
|
1657
|
+
const translateSandboxNotFound = options?.translateSandboxNotFound ?? false;
|
|
1643
1658
|
return async (args, context) => {
|
|
1644
1659
|
if (!context.sandboxId) {
|
|
1645
1660
|
return {
|
|
@@ -1647,7 +1662,18 @@ function withSandbox(manager, handler) {
|
|
|
1647
1662
|
data: null
|
|
1648
1663
|
};
|
|
1649
1664
|
}
|
|
1650
|
-
|
|
1665
|
+
let sandbox;
|
|
1666
|
+
try {
|
|
1667
|
+
sandbox = await manager.getSandbox(context.sandboxId);
|
|
1668
|
+
} catch (err) {
|
|
1669
|
+
if (translateSandboxNotFound && err instanceof SandboxNotFoundError) {
|
|
1670
|
+
return {
|
|
1671
|
+
toolResponse: options?.sandboxNotFoundToolResponse ?? `Error: the execution environment for the ${context.toolName} tool is no longer available, so this tool call could not be completed.`,
|
|
1672
|
+
data: null
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
throw err;
|
|
1676
|
+
}
|
|
1651
1677
|
return handler(args, { ...context, sandbox, sandboxId: context.sandboxId });
|
|
1652
1678
|
};
|
|
1653
1679
|
}
|
|
@@ -1679,6 +1705,7 @@ function defineSubagentWorkflow(config, fn) {
|
|
|
1679
1705
|
let capturedSnapshot;
|
|
1680
1706
|
let capturedBaseSnapshot;
|
|
1681
1707
|
let capturedThreadId;
|
|
1708
|
+
let capturedUsage;
|
|
1682
1709
|
const sessionInput = {
|
|
1683
1710
|
agentName: config.name,
|
|
1684
1711
|
sandboxShutdown: effectiveShutdown,
|
|
@@ -1695,10 +1722,17 @@ function defineSubagentWorkflow(config, fn) {
|
|
|
1695
1722
|
});
|
|
1696
1723
|
}
|
|
1697
1724
|
},
|
|
1698
|
-
onSessionExit: ({ sandboxId, snapshot, threadId }) => {
|
|
1725
|
+
onSessionExit: ({ sandboxId, snapshot, threadId, usage }) => {
|
|
1699
1726
|
capturedSandboxId = sandboxId;
|
|
1700
1727
|
capturedSnapshot = snapshot;
|
|
1701
1728
|
capturedThreadId = threadId;
|
|
1729
|
+
capturedUsage = {
|
|
1730
|
+
inputTokens: usage.totalInputTokens,
|
|
1731
|
+
outputTokens: usage.totalOutputTokens,
|
|
1732
|
+
cachedWriteTokens: usage.totalCachedWriteTokens,
|
|
1733
|
+
cachedReadTokens: usage.totalCachedReadTokens,
|
|
1734
|
+
reasonTokens: usage.totalReasonTokens
|
|
1735
|
+
};
|
|
1702
1736
|
}
|
|
1703
1737
|
};
|
|
1704
1738
|
const result = await fn(prompt, sessionInput, context ?? {});
|
|
@@ -1709,7 +1743,8 @@ function defineSubagentWorkflow(config, fn) {
|
|
|
1709
1743
|
...capturedSnapshot !== void 0 && { snapshot: capturedSnapshot },
|
|
1710
1744
|
...capturedBaseSnapshot !== void 0 && {
|
|
1711
1745
|
baseSnapshot: capturedBaseSnapshot
|
|
1712
|
-
}
|
|
1746
|
+
},
|
|
1747
|
+
...capturedUsage !== void 0 && { usage: capturedUsage }
|
|
1713
1748
|
};
|
|
1714
1749
|
};
|
|
1715
1750
|
Object.defineProperty(workflow, "name", { value: config.name });
|
|
@@ -1793,20 +1828,6 @@ function proxyRunAgent(scope, options) {
|
|
|
1793
1828
|
);
|
|
1794
1829
|
return acts[name];
|
|
1795
1830
|
}
|
|
1796
|
-
var SandboxNotSupportedError = class extends ApplicationFailure$1 {
|
|
1797
|
-
constructor(operation) {
|
|
1798
|
-
super(
|
|
1799
|
-
`Sandbox does not support: ${operation}`,
|
|
1800
|
-
"SandboxNotSupportedError",
|
|
1801
|
-
true
|
|
1802
|
-
);
|
|
1803
|
-
}
|
|
1804
|
-
};
|
|
1805
|
-
var SandboxNotFoundError = class extends ApplicationFailure$1 {
|
|
1806
|
-
constructor(sandboxId) {
|
|
1807
|
-
super(`Sandbox not found: ${sandboxId}`, "SandboxNotFoundError", true);
|
|
1808
|
-
}
|
|
1809
|
-
};
|
|
1810
1831
|
|
|
1811
1832
|
// src/lib/virtual-fs/mutations.ts
|
|
1812
1833
|
function applyVirtualTreeMutations(stateManager, mutations) {
|
|
@@ -2919,7 +2940,7 @@ var VirtualFileSystem = class {
|
|
|
2919
2940
|
if (inline !== void 0) return inline;
|
|
2920
2941
|
const entry = this.entries.get(norm);
|
|
2921
2942
|
if (!entry) throw new Error(`ENOENT: no such file: ${path}`);
|
|
2922
|
-
return this.
|
|
2943
|
+
return this.readEntryContent(entry);
|
|
2923
2944
|
}
|
|
2924
2945
|
async readFileBuffer(path) {
|
|
2925
2946
|
const norm = normalisePath(path, this.workspaceBase);
|
|
@@ -2927,8 +2948,23 @@ var VirtualFileSystem = class {
|
|
|
2927
2948
|
if (inline !== void 0) return new TextEncoder().encode(inline);
|
|
2928
2949
|
const entry = this.entries.get(norm);
|
|
2929
2950
|
if (!entry) throw new Error(`ENOENT: no such file: ${path}`);
|
|
2951
|
+
if (entry.inlineContent !== void 0) {
|
|
2952
|
+
return new TextEncoder().encode(entry.inlineContent);
|
|
2953
|
+
}
|
|
2930
2954
|
return this.resolver.readFileBuffer(entry.id, this.ctx, entry.metadata);
|
|
2931
2955
|
}
|
|
2956
|
+
/**
|
|
2957
|
+
* Resolve the string content for an entry, preferring inline content
|
|
2958
|
+
* carried on the entry itself before consulting the resolver. Used by
|
|
2959
|
+
* `readFile`, `appendFile`, and `cp` so all read paths agree on the
|
|
2960
|
+
* lookup precedence.
|
|
2961
|
+
*/
|
|
2962
|
+
readEntryContent(entry) {
|
|
2963
|
+
if (entry.inlineContent !== void 0) {
|
|
2964
|
+
return Promise.resolve(entry.inlineContent);
|
|
2965
|
+
}
|
|
2966
|
+
return this.resolver.readFile(entry.id, this.ctx, entry.metadata);
|
|
2967
|
+
}
|
|
2932
2968
|
// --------------------------------------------------------------------------
|
|
2933
2969
|
// Metadata operations — pure, resolved from the tree
|
|
2934
2970
|
// --------------------------------------------------------------------------
|
|
@@ -3000,6 +3036,11 @@ var VirtualFileSystem = class {
|
|
|
3000
3036
|
const norm = normalisePath(path, this.workspaceBase);
|
|
3001
3037
|
const existing = this.entries.get(norm);
|
|
3002
3038
|
if (existing) {
|
|
3039
|
+
if (existing.inlineContent !== void 0) {
|
|
3040
|
+
throw new Error(
|
|
3041
|
+
`EROFS: cannot write to inline (read-only) entry: ${path}`
|
|
3042
|
+
);
|
|
3043
|
+
}
|
|
3003
3044
|
await this.resolver.writeFile(
|
|
3004
3045
|
existing.id,
|
|
3005
3046
|
content,
|
|
@@ -3028,11 +3069,12 @@ var VirtualFileSystem = class {
|
|
|
3028
3069
|
if (!existing) {
|
|
3029
3070
|
return this.writeFile(path, content);
|
|
3030
3071
|
}
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3072
|
+
if (existing.inlineContent !== void 0) {
|
|
3073
|
+
throw new Error(
|
|
3074
|
+
`EROFS: cannot append to inline (read-only) entry: ${path}`
|
|
3075
|
+
);
|
|
3076
|
+
}
|
|
3077
|
+
const current = await this.readEntryContent(existing);
|
|
3036
3078
|
const appended = typeof content === "string" ? current + content : current + new TextDecoder().decode(content);
|
|
3037
3079
|
await this.resolver.writeFile(
|
|
3038
3080
|
existing.id,
|
|
@@ -3067,6 +3109,11 @@ var VirtualFileSystem = class {
|
|
|
3067
3109
|
const norm = normalisePath(path, this.workspaceBase);
|
|
3068
3110
|
const entry = this.entries.get(norm);
|
|
3069
3111
|
if (entry) {
|
|
3112
|
+
if (entry.inlineContent !== void 0) {
|
|
3113
|
+
throw new Error(
|
|
3114
|
+
`EROFS: cannot remove inline (read-only) entry: ${path}`
|
|
3115
|
+
);
|
|
3116
|
+
}
|
|
3070
3117
|
await this.resolver.deleteFile(entry.id, this.ctx, entry.metadata);
|
|
3071
3118
|
this.entries.delete(norm);
|
|
3072
3119
|
this.mutations.push({ type: "remove", path: norm });
|
|
@@ -3079,6 +3126,11 @@ var VirtualFileSystem = class {
|
|
|
3079
3126
|
const prefix = norm === "/" ? "/" : norm + "/";
|
|
3080
3127
|
for (const [p, e] of this.entries) {
|
|
3081
3128
|
if (p.startsWith(prefix)) {
|
|
3129
|
+
if (e.inlineContent !== void 0) {
|
|
3130
|
+
throw new Error(
|
|
3131
|
+
`EROFS: cannot remove inline (read-only) entry: ${p}`
|
|
3132
|
+
);
|
|
3133
|
+
}
|
|
3082
3134
|
await this.resolver.deleteFile(e.id, this.ctx, e.metadata);
|
|
3083
3135
|
this.entries.delete(p);
|
|
3084
3136
|
this.mutations.push({ type: "remove", path: p });
|
|
@@ -3099,11 +3151,7 @@ var VirtualFileSystem = class {
|
|
|
3099
3151
|
const normDest = normalisePath(dest, this.workspaceBase);
|
|
3100
3152
|
const entry = this.entries.get(normSrc);
|
|
3101
3153
|
if (entry) {
|
|
3102
|
-
const content = await this.
|
|
3103
|
-
entry.id,
|
|
3104
|
-
this.ctx,
|
|
3105
|
-
entry.metadata
|
|
3106
|
-
);
|
|
3154
|
+
const content = await this.readEntryContent(entry);
|
|
3107
3155
|
await this.writeFile(normDest, content);
|
|
3108
3156
|
return;
|
|
3109
3157
|
}
|
|
@@ -3117,11 +3165,7 @@ var VirtualFileSystem = class {
|
|
|
3117
3165
|
for (const [p, e] of this.entries) {
|
|
3118
3166
|
if (p.startsWith(prefix)) {
|
|
3119
3167
|
const relative = p.slice(normSrc.length);
|
|
3120
|
-
const content = await this.
|
|
3121
|
-
e.id,
|
|
3122
|
-
this.ctx,
|
|
3123
|
-
e.metadata
|
|
3124
|
-
);
|
|
3168
|
+
const content = await this.readEntryContent(e);
|
|
3125
3169
|
await this.writeFile(normDest + relative, content);
|
|
3126
3170
|
}
|
|
3127
3171
|
}
|