zeitlich 0.2.21 → 0.2.22
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 +70 -55
- package/dist/adapters/sandbox/daytona/index.cjs +3 -0
- package/dist/adapters/sandbox/daytona/index.cjs.map +1 -1
- package/dist/adapters/sandbox/daytona/index.d.cts +2 -1
- package/dist/adapters/sandbox/daytona/index.d.ts +2 -1
- package/dist/adapters/sandbox/daytona/index.js +3 -0
- package/dist/adapters/sandbox/daytona/index.js.map +1 -1
- package/dist/adapters/sandbox/daytona/workflow.cjs +32 -0
- package/dist/adapters/sandbox/daytona/workflow.cjs.map +1 -0
- package/dist/adapters/sandbox/daytona/workflow.d.cts +27 -0
- package/dist/adapters/sandbox/daytona/workflow.d.ts +27 -0
- package/dist/adapters/sandbox/daytona/workflow.js +30 -0
- package/dist/adapters/sandbox/daytona/workflow.js.map +1 -0
- package/dist/adapters/sandbox/inmemory/index.cjs +4 -1
- package/dist/adapters/sandbox/inmemory/index.cjs.map +1 -1
- package/dist/adapters/sandbox/inmemory/index.d.cts +3 -2
- package/dist/adapters/sandbox/inmemory/index.d.ts +3 -2
- package/dist/adapters/sandbox/inmemory/index.js +4 -1
- package/dist/adapters/sandbox/inmemory/index.js.map +1 -1
- package/dist/adapters/sandbox/inmemory/workflow.cjs +32 -0
- package/dist/adapters/sandbox/inmemory/workflow.cjs.map +1 -0
- package/dist/adapters/sandbox/inmemory/workflow.d.cts +25 -0
- package/dist/adapters/sandbox/inmemory/workflow.d.ts +25 -0
- package/dist/adapters/sandbox/inmemory/workflow.js +30 -0
- package/dist/adapters/sandbox/inmemory/workflow.js.map +1 -0
- package/dist/adapters/sandbox/virtual/index.cjs +3 -0
- package/dist/adapters/sandbox/virtual/index.cjs.map +1 -1
- package/dist/adapters/sandbox/virtual/index.d.cts +6 -4
- package/dist/adapters/sandbox/virtual/index.d.ts +6 -4
- package/dist/adapters/sandbox/virtual/index.js +3 -0
- package/dist/adapters/sandbox/virtual/index.js.map +1 -1
- package/dist/adapters/sandbox/virtual/workflow.cjs +32 -0
- package/dist/adapters/sandbox/virtual/workflow.cjs.map +1 -0
- package/dist/adapters/sandbox/virtual/workflow.d.cts +27 -0
- package/dist/adapters/sandbox/virtual/workflow.d.ts +27 -0
- package/dist/adapters/sandbox/virtual/workflow.js +30 -0
- package/dist/adapters/sandbox/virtual/workflow.js.map +1 -0
- package/dist/adapters/thread/google-genai/index.cjs +9 -1
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +30 -18
- package/dist/adapters/thread/google-genai/index.d.ts +30 -18
- package/dist/adapters/thread/google-genai/index.js +9 -1
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.cjs +33 -0
- package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -0
- package/dist/adapters/thread/google-genai/workflow.d.cts +32 -0
- package/dist/adapters/thread/google-genai/workflow.d.ts +32 -0
- package/dist/adapters/thread/google-genai/workflow.js +31 -0
- package/dist/adapters/thread/google-genai/workflow.js.map +1 -0
- package/dist/adapters/thread/langchain/index.cjs +9 -1
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +26 -15
- package/dist/adapters/thread/langchain/index.d.ts +26 -15
- package/dist/adapters/thread/langchain/index.js +9 -1
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/adapters/thread/langchain/workflow.cjs +33 -0
- package/dist/adapters/thread/langchain/workflow.cjs.map +1 -0
- package/dist/adapters/thread/langchain/workflow.d.cts +32 -0
- package/dist/adapters/thread/langchain/workflow.d.ts +32 -0
- package/dist/adapters/thread/langchain/workflow.js +31 -0
- package/dist/adapters/thread/langchain/workflow.js.map +1 -0
- package/dist/index.cjs +36 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -14
- package/dist/index.d.ts +35 -14
- package/dist/index.js +38 -34
- package/dist/index.js.map +1 -1
- package/dist/queries-Bw6WEPMw.d.cts +44 -0
- package/dist/queries-C27raDaB.d.ts +44 -0
- package/dist/{queries-CHa2iv_I.d.cts → types-BJ8itUAl.d.cts} +2 -43
- package/dist/{types-BkAYmc96.d.ts → types-C5bkx6kQ.d.ts} +33 -5
- package/dist/{types-CES_30qx.d.cts → types-ClsHhtwL.d.cts} +33 -5
- package/dist/{queries-6Avfh74U.d.ts → types-ENYCKFBk.d.ts} +2 -43
- package/dist/{types-BMRzfELQ.d.cts → types-HBosetv3.d.cts} +15 -1
- package/dist/{types-BMRzfELQ.d.ts → types-HBosetv3.d.ts} +15 -1
- package/dist/workflow.cjs +4 -30
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +13 -41
- package/dist/workflow.d.ts +13 -41
- package/dist/workflow.js +6 -30
- package/dist/workflow.js.map +1 -1
- package/package.json +53 -1
- package/src/adapters/sandbox/daytona/index.ts +4 -0
- package/src/adapters/sandbox/daytona/proxy.ts +55 -0
- package/src/adapters/sandbox/e2b/filesystem.ts +147 -0
- package/src/adapters/sandbox/e2b/index.ts +159 -0
- package/src/adapters/sandbox/e2b/types.ts +23 -0
- package/src/adapters/sandbox/inmemory/index.ts +5 -1
- package/src/adapters/sandbox/inmemory/proxy.ts +53 -0
- package/src/adapters/sandbox/virtual/provider.ts +5 -1
- package/src/adapters/sandbox/virtual/proxy.ts +52 -0
- package/src/adapters/thread/google-genai/activities.ts +51 -17
- package/src/adapters/thread/google-genai/index.ts +1 -0
- package/src/adapters/thread/google-genai/proxy.ts +61 -0
- package/src/adapters/thread/langchain/activities.ts +47 -14
- package/src/adapters/thread/langchain/index.ts +1 -0
- package/src/adapters/thread/langchain/proxy.ts +61 -0
- package/src/lib/sandbox/manager.ts +40 -6
- package/src/lib/sandbox/sandbox.test.ts +12 -11
- package/src/lib/sandbox/types.ts +18 -0
- package/src/lib/session/index.ts +3 -5
- package/src/lib/session/session-edge-cases.integration.test.ts +45 -34
- package/src/lib/session/session.integration.test.ts +40 -48
- package/src/lib/session/session.ts +4 -66
- package/src/lib/session/types.ts +32 -1
- package/src/lib/subagent/define.ts +1 -1
- package/src/lib/subagent/handler.ts +9 -2
- package/src/lib/subagent/index.ts +1 -0
- package/src/lib/subagent/subagent.integration.test.ts +62 -0
- package/src/lib/subagent/types.ts +7 -2
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +4 -1
- package/src/lib/tool-router/router.integration.test.ts +4 -1
- package/src/lib/workflow.test.ts +19 -10
- package/src/lib/workflow.ts +4 -1
- package/src/tools/bash/bash.test.ts +16 -7
- package/src/workflow.ts +6 -14
- package/tsup.config.ts +6 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { F as FileEntry } from './types-BJ8itUAl.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Structural constraint: accepts any `AgentStateManager<T>` whose custom
|
|
5
|
+
* state includes `fileTree: FileEntry<TMeta>[]`.
|
|
6
|
+
*/
|
|
7
|
+
interface FileTreeAccessor<TMeta> {
|
|
8
|
+
get(key: "fileTree"): FileEntry<TMeta>[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check whether any file in the tree has a `metadata.mimeType` that matches
|
|
12
|
+
* the given pattern.
|
|
13
|
+
*
|
|
14
|
+
* Patterns:
|
|
15
|
+
* - Exact: `"application/pdf"`
|
|
16
|
+
* - Wildcard type: `"image/*"`
|
|
17
|
+
*
|
|
18
|
+
* Useful for conditionally enabling tools:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* { enabled: hasFileWithMimeType(stateManager, "image/*") }
|
|
22
|
+
* { enabled: hasFileWithMimeType(stateManager, ["image/*", "application/pdf"]) }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function hasFileWithMimeType<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string | string[]): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Return all entries whose `metadata.mimeType` matches the given pattern.
|
|
28
|
+
*/
|
|
29
|
+
declare function filesWithMimeType<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string): FileEntry<TMeta>[];
|
|
30
|
+
/**
|
|
31
|
+
* Check whether the tree contains a directory whose name matches the given
|
|
32
|
+
* pattern. Directories are inferred from file paths.
|
|
33
|
+
*
|
|
34
|
+
* Patterns:
|
|
35
|
+
* - Exact: `"src"`
|
|
36
|
+
* - Glob with `*` wildcard: `"test*"`, `"*.generated"`
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* { enabled: hasDirectory(stateManager, "test*") }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare function hasDirectory<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string): boolean;
|
|
43
|
+
|
|
44
|
+
export { type FileTreeAccessor as F, hasFileWithMimeType as a, filesWithMimeType as f, hasDirectory as h };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { F as FileEntry } from './types-ENYCKFBk.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Structural constraint: accepts any `AgentStateManager<T>` whose custom
|
|
5
|
+
* state includes `fileTree: FileEntry<TMeta>[]`.
|
|
6
|
+
*/
|
|
7
|
+
interface FileTreeAccessor<TMeta> {
|
|
8
|
+
get(key: "fileTree"): FileEntry<TMeta>[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check whether any file in the tree has a `metadata.mimeType` that matches
|
|
12
|
+
* the given pattern.
|
|
13
|
+
*
|
|
14
|
+
* Patterns:
|
|
15
|
+
* - Exact: `"application/pdf"`
|
|
16
|
+
* - Wildcard type: `"image/*"`
|
|
17
|
+
*
|
|
18
|
+
* Useful for conditionally enabling tools:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* { enabled: hasFileWithMimeType(stateManager, "image/*") }
|
|
22
|
+
* { enabled: hasFileWithMimeType(stateManager, ["image/*", "application/pdf"]) }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function hasFileWithMimeType<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string | string[]): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Return all entries whose `metadata.mimeType` matches the given pattern.
|
|
28
|
+
*/
|
|
29
|
+
declare function filesWithMimeType<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string): FileEntry<TMeta>[];
|
|
30
|
+
/**
|
|
31
|
+
* Check whether the tree contains a directory whose name matches the given
|
|
32
|
+
* pattern. Directories are inferred from file paths.
|
|
33
|
+
*
|
|
34
|
+
* Patterns:
|
|
35
|
+
* - Exact: `"src"`
|
|
36
|
+
* - Glob with `*` wildcard: `"test*"`, `"*.generated"`
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* { enabled: hasDirectory(stateManager, "test*") }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare function hasDirectory<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string): boolean;
|
|
43
|
+
|
|
44
|
+
export { type FileTreeAccessor as F, hasFileWithMimeType as a, filesWithMimeType as f, hasDirectory as h };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-
|
|
1
|
+
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-HBosetv3.cjs';
|
|
2
2
|
import { R as RouterContext } from './types-YbL7JpEA.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -122,45 +122,4 @@ interface VirtualSandboxContext<TCtx = unknown, TMeta = FileEntryMetadata> exten
|
|
|
122
122
|
sandbox: VirtualSandbox<TCtx, TMeta>;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
* Structural constraint: accepts any `AgentStateManager<T>` whose custom
|
|
127
|
-
* state includes `fileTree: FileEntry<TMeta>[]`.
|
|
128
|
-
*/
|
|
129
|
-
interface FileTreeAccessor<TMeta> {
|
|
130
|
-
get(key: "fileTree"): FileEntry<TMeta>[];
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Check whether any file in the tree has a `metadata.mimeType` that matches
|
|
134
|
-
* the given pattern.
|
|
135
|
-
*
|
|
136
|
-
* Patterns:
|
|
137
|
-
* - Exact: `"application/pdf"`
|
|
138
|
-
* - Wildcard type: `"image/*"`
|
|
139
|
-
*
|
|
140
|
-
* Useful for conditionally enabling tools:
|
|
141
|
-
*
|
|
142
|
-
* ```ts
|
|
143
|
-
* { enabled: hasFileWithMimeType(stateManager, "image/*") }
|
|
144
|
-
* { enabled: hasFileWithMimeType(stateManager, ["image/*", "application/pdf"]) }
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
declare function hasFileWithMimeType<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string | string[]): boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Return all entries whose `metadata.mimeType` matches the given pattern.
|
|
150
|
-
*/
|
|
151
|
-
declare function filesWithMimeType<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string): FileEntry<TMeta>[];
|
|
152
|
-
/**
|
|
153
|
-
* Check whether the tree contains a directory whose name matches the given
|
|
154
|
-
* pattern. Directories are inferred from file paths.
|
|
155
|
-
*
|
|
156
|
-
* Patterns:
|
|
157
|
-
* - Exact: `"src"`
|
|
158
|
-
* - Glob with `*` wildcard: `"test*"`, `"*.generated"`
|
|
159
|
-
*
|
|
160
|
-
* ```ts
|
|
161
|
-
* { enabled: hasDirectory(stateManager, "test*") }
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
declare function hasDirectory<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string): boolean;
|
|
165
|
-
|
|
166
|
-
export { type FileEntryMetadata as F, type TreeMutation as T, type VirtualSandboxCreateOptions as V, type FileResolver as a, type VirtualSandboxContext as b, type FileEntry as c, type VirtualSandbox as d, type FileTreeAccessor as e, type VirtualFileTree as f, VirtualSandboxFileSystem as g, type VirtualSandboxState as h, filesWithMimeType as i, hasDirectory as j, hasFileWithMimeType as k };
|
|
125
|
+
export { type FileEntry as F, type TreeMutation as T, type VirtualSandboxCreateOptions as V, type FileEntryMetadata as a, type FileResolver as b, type VirtualSandboxContext as c, type VirtualSandbox as d, type VirtualFileTree as e, VirtualSandboxFileSystem as f, type VirtualSandboxState as g };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Duration } from '@temporalio/common';
|
|
2
2
|
import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-YbL7JpEA.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { g as SandboxOps } from './types-
|
|
4
|
+
import { g as SandboxOps } from './types-HBosetv3.js';
|
|
5
5
|
import { QueryDefinition, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
6
6
|
import { UpdateDefinition } from '@temporalio/common/lib/interfaces';
|
|
7
7
|
|
|
@@ -93,6 +93,8 @@ type SubagentDefinition<TResult extends z.ZodType = z.ZodType, TContext extends
|
|
|
93
93
|
readonly description: string;
|
|
94
94
|
readonly resultSchema?: TResult;
|
|
95
95
|
};
|
|
96
|
+
/** Context value or factory — resolved at invocation time when a function is provided */
|
|
97
|
+
type SubagentContext = Record<string, unknown> | (() => Record<string, unknown>);
|
|
96
98
|
/**
|
|
97
99
|
* Configuration for a subagent that can be spawned by the parent workflow.
|
|
98
100
|
*
|
|
@@ -111,8 +113,8 @@ interface SubagentConfig<TResult extends z.ZodType = z.ZodType> {
|
|
|
111
113
|
taskQueue?: string;
|
|
112
114
|
/** Optional Zod schema to validate the child workflow's result. If omitted, result is passed through as-is. */
|
|
113
115
|
resultSchema?: TResult;
|
|
114
|
-
/** Optional
|
|
115
|
-
context?:
|
|
116
|
+
/** Optional context passed to the subagent — a static object or a function evaluated at invocation time */
|
|
117
|
+
context?: SubagentContext;
|
|
116
118
|
/** Allow the parent agent to pass a threadId for this subagent to continue (default: false) */
|
|
117
119
|
allowThreadContinuation?: boolean;
|
|
118
120
|
/** Per-subagent lifecycle hooks */
|
|
@@ -350,6 +352,32 @@ interface ThreadOps {
|
|
|
350
352
|
/** Copy all messages from sourceThreadId into a new thread at targetThreadId */
|
|
351
353
|
forkThread(sourceThreadId: string, targetThreadId: string): Promise<void>;
|
|
352
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Composes an adapter prefix + workflow scope for activity naming.
|
|
357
|
+
*
|
|
358
|
+
* The adapter prefix stays first (camelCase); the workflow scope is
|
|
359
|
+
* capitalised and appended. When `TScope` is empty the adapter prefix
|
|
360
|
+
* is used as-is.
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```typescript
|
|
364
|
+
* ScopedPrefix<"codingAgent", "googleGenAI"> // "googleGenAICodingAgent"
|
|
365
|
+
* ScopedPrefix<"", "googleGenAI"> // "googleGenAI"
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
type ScopedPrefix<TScope extends string, TAdapter extends string> = TScope extends "" ? TAdapter : `${TAdapter}${Capitalize<TScope>}`;
|
|
369
|
+
/**
|
|
370
|
+
* Maps generic {@link ThreadOps} method names to adapter-prefixed names.
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```typescript
|
|
374
|
+
* type GoogleOps = PrefixedThreadOps<"googleGenAI">;
|
|
375
|
+
* // → { googleGenAIInitializeThread, googleGenAIAppendHumanMessage, … }
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
type PrefixedThreadOps<TPrefix extends string> = {
|
|
379
|
+
[K in keyof ThreadOps as `${TPrefix}${Capitalize<K & string>}`]: ThreadOps[K];
|
|
380
|
+
};
|
|
353
381
|
/**
|
|
354
382
|
* Configuration for a Zeitlich agent session
|
|
355
383
|
*/
|
|
@@ -367,7 +395,7 @@ interface SessionConfig<T extends ToolMap, M = unknown> {
|
|
|
367
395
|
/** Workflow-specific runAgent activity (with tools pre-bound) */
|
|
368
396
|
runAgent: RunAgentActivity<M>;
|
|
369
397
|
/** Thread operations (initialize, append messages, parse tool calls) */
|
|
370
|
-
threadOps
|
|
398
|
+
threadOps: ActivityInterfaceFor<ThreadOps>;
|
|
371
399
|
/** Tool router for processing tool calls (optional if agent has no tools) */
|
|
372
400
|
tools?: T;
|
|
373
401
|
/** Subagent configurations */
|
|
@@ -407,4 +435,4 @@ interface ZeitlichSession<M = unknown> {
|
|
|
407
435
|
}>;
|
|
408
436
|
}
|
|
409
437
|
|
|
410
|
-
export type { AgentResponse as A, Hooks as H, JsonPrimitive as J, ModelInvoker as M,
|
|
438
|
+
export type { AgentResponse as A, Hooks as H, JsonPrimitive as J, ModelInvoker as M, PrefixedThreadOps as P, RunAgentActivity as R, ScopedPrefix as S, ThreadOps as T, ZeitlichSession as Z, ModelInvokerConfig as a, SkillProvider as b, SkillMetadata as c, Skill as d, AgentState as e, AgentStateManager as f, JsonSerializable as g, JsonValue as h, PostHumanMessageAppendHook as i, PostHumanMessageAppendHookContext as j, PreHumanMessageAppendHook as k, PreHumanMessageAppendHookContext as l, SessionConfig as m, SessionEndHook as n, SessionEndHookContext as o, SessionStartHook as p, SessionStartHookContext as q, SubagentConfig as r, SubagentDefinition as s, SubagentHandlerResponse as t, SubagentHooks as u, SubagentSessionInput as v, SubagentWorkflow as w, SubagentWorkflowInput as x };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Duration } from '@temporalio/common';
|
|
2
2
|
import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-YbL7JpEA.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { g as SandboxOps } from './types-
|
|
4
|
+
import { g as SandboxOps } from './types-HBosetv3.cjs';
|
|
5
5
|
import { QueryDefinition, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
6
6
|
import { UpdateDefinition } from '@temporalio/common/lib/interfaces';
|
|
7
7
|
|
|
@@ -93,6 +93,8 @@ type SubagentDefinition<TResult extends z.ZodType = z.ZodType, TContext extends
|
|
|
93
93
|
readonly description: string;
|
|
94
94
|
readonly resultSchema?: TResult;
|
|
95
95
|
};
|
|
96
|
+
/** Context value or factory — resolved at invocation time when a function is provided */
|
|
97
|
+
type SubagentContext = Record<string, unknown> | (() => Record<string, unknown>);
|
|
96
98
|
/**
|
|
97
99
|
* Configuration for a subagent that can be spawned by the parent workflow.
|
|
98
100
|
*
|
|
@@ -111,8 +113,8 @@ interface SubagentConfig<TResult extends z.ZodType = z.ZodType> {
|
|
|
111
113
|
taskQueue?: string;
|
|
112
114
|
/** Optional Zod schema to validate the child workflow's result. If omitted, result is passed through as-is. */
|
|
113
115
|
resultSchema?: TResult;
|
|
114
|
-
/** Optional
|
|
115
|
-
context?:
|
|
116
|
+
/** Optional context passed to the subagent — a static object or a function evaluated at invocation time */
|
|
117
|
+
context?: SubagentContext;
|
|
116
118
|
/** Allow the parent agent to pass a threadId for this subagent to continue (default: false) */
|
|
117
119
|
allowThreadContinuation?: boolean;
|
|
118
120
|
/** Per-subagent lifecycle hooks */
|
|
@@ -350,6 +352,32 @@ interface ThreadOps {
|
|
|
350
352
|
/** Copy all messages from sourceThreadId into a new thread at targetThreadId */
|
|
351
353
|
forkThread(sourceThreadId: string, targetThreadId: string): Promise<void>;
|
|
352
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Composes an adapter prefix + workflow scope for activity naming.
|
|
357
|
+
*
|
|
358
|
+
* The adapter prefix stays first (camelCase); the workflow scope is
|
|
359
|
+
* capitalised and appended. When `TScope` is empty the adapter prefix
|
|
360
|
+
* is used as-is.
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```typescript
|
|
364
|
+
* ScopedPrefix<"codingAgent", "googleGenAI"> // "googleGenAICodingAgent"
|
|
365
|
+
* ScopedPrefix<"", "googleGenAI"> // "googleGenAI"
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
type ScopedPrefix<TScope extends string, TAdapter extends string> = TScope extends "" ? TAdapter : `${TAdapter}${Capitalize<TScope>}`;
|
|
369
|
+
/**
|
|
370
|
+
* Maps generic {@link ThreadOps} method names to adapter-prefixed names.
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```typescript
|
|
374
|
+
* type GoogleOps = PrefixedThreadOps<"googleGenAI">;
|
|
375
|
+
* // → { googleGenAIInitializeThread, googleGenAIAppendHumanMessage, … }
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
type PrefixedThreadOps<TPrefix extends string> = {
|
|
379
|
+
[K in keyof ThreadOps as `${TPrefix}${Capitalize<K & string>}`]: ThreadOps[K];
|
|
380
|
+
};
|
|
353
381
|
/**
|
|
354
382
|
* Configuration for a Zeitlich agent session
|
|
355
383
|
*/
|
|
@@ -367,7 +395,7 @@ interface SessionConfig<T extends ToolMap, M = unknown> {
|
|
|
367
395
|
/** Workflow-specific runAgent activity (with tools pre-bound) */
|
|
368
396
|
runAgent: RunAgentActivity<M>;
|
|
369
397
|
/** Thread operations (initialize, append messages, parse tool calls) */
|
|
370
|
-
threadOps
|
|
398
|
+
threadOps: ActivityInterfaceFor<ThreadOps>;
|
|
371
399
|
/** Tool router for processing tool calls (optional if agent has no tools) */
|
|
372
400
|
tools?: T;
|
|
373
401
|
/** Subagent configurations */
|
|
@@ -407,4 +435,4 @@ interface ZeitlichSession<M = unknown> {
|
|
|
407
435
|
}>;
|
|
408
436
|
}
|
|
409
437
|
|
|
410
|
-
export type { AgentResponse as A, Hooks as H, JsonPrimitive as J, ModelInvoker as M,
|
|
438
|
+
export type { AgentResponse as A, Hooks as H, JsonPrimitive as J, ModelInvoker as M, PrefixedThreadOps as P, RunAgentActivity as R, ScopedPrefix as S, ThreadOps as T, ZeitlichSession as Z, ModelInvokerConfig as a, SkillProvider as b, SkillMetadata as c, Skill as d, AgentState as e, AgentStateManager as f, JsonSerializable as g, JsonValue as h, PostHumanMessageAppendHook as i, PostHumanMessageAppendHookContext as j, PreHumanMessageAppendHook as k, PreHumanMessageAppendHookContext as l, SessionConfig as m, SessionEndHook as n, SessionEndHookContext as o, SessionStartHook as p, SessionStartHookContext as q, SubagentConfig as r, SubagentDefinition as s, SubagentHandlerResponse as t, SubagentHooks as u, SubagentSessionInput as v, SubagentWorkflow as w, SubagentWorkflowInput as x };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-
|
|
1
|
+
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-HBosetv3.js';
|
|
2
2
|
import { R as RouterContext } from './types-YbL7JpEA.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -122,45 +122,4 @@ interface VirtualSandboxContext<TCtx = unknown, TMeta = FileEntryMetadata> exten
|
|
|
122
122
|
sandbox: VirtualSandbox<TCtx, TMeta>;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
* Structural constraint: accepts any `AgentStateManager<T>` whose custom
|
|
127
|
-
* state includes `fileTree: FileEntry<TMeta>[]`.
|
|
128
|
-
*/
|
|
129
|
-
interface FileTreeAccessor<TMeta> {
|
|
130
|
-
get(key: "fileTree"): FileEntry<TMeta>[];
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Check whether any file in the tree has a `metadata.mimeType` that matches
|
|
134
|
-
* the given pattern.
|
|
135
|
-
*
|
|
136
|
-
* Patterns:
|
|
137
|
-
* - Exact: `"application/pdf"`
|
|
138
|
-
* - Wildcard type: `"image/*"`
|
|
139
|
-
*
|
|
140
|
-
* Useful for conditionally enabling tools:
|
|
141
|
-
*
|
|
142
|
-
* ```ts
|
|
143
|
-
* { enabled: hasFileWithMimeType(stateManager, "image/*") }
|
|
144
|
-
* { enabled: hasFileWithMimeType(stateManager, ["image/*", "application/pdf"]) }
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
declare function hasFileWithMimeType<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string | string[]): boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Return all entries whose `metadata.mimeType` matches the given pattern.
|
|
150
|
-
*/
|
|
151
|
-
declare function filesWithMimeType<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string): FileEntry<TMeta>[];
|
|
152
|
-
/**
|
|
153
|
-
* Check whether the tree contains a directory whose name matches the given
|
|
154
|
-
* pattern. Directories are inferred from file paths.
|
|
155
|
-
*
|
|
156
|
-
* Patterns:
|
|
157
|
-
* - Exact: `"src"`
|
|
158
|
-
* - Glob with `*` wildcard: `"test*"`, `"*.generated"`
|
|
159
|
-
*
|
|
160
|
-
* ```ts
|
|
161
|
-
* { enabled: hasDirectory(stateManager, "test*") }
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
declare function hasDirectory<TMeta>(stateManager: FileTreeAccessor<TMeta>, pattern: string): boolean;
|
|
165
|
-
|
|
166
|
-
export { type FileEntryMetadata as F, type TreeMutation as T, type VirtualSandboxCreateOptions as V, type FileResolver as a, type VirtualSandboxContext as b, type FileEntry as c, type VirtualSandbox as d, type FileTreeAccessor as e, type VirtualFileTree as f, VirtualSandboxFileSystem as g, type VirtualSandboxState as h, filesWithMimeType as i, hasDirectory as j, hasFileWithMimeType as k };
|
|
125
|
+
export { type FileEntry as F, type TreeMutation as T, type VirtualSandboxCreateOptions as V, type FileEntryMetadata as a, type FileResolver as b, type VirtualSandboxContext as c, type VirtualSandbox as d, type VirtualFileTree as e, VirtualSandboxFileSystem as f, type VirtualSandboxState as g };
|
|
@@ -97,6 +97,7 @@ interface SandboxProvider<TOptions extends SandboxCreateOptions = SandboxCreateO
|
|
|
97
97
|
destroy(sandboxId: string): Promise<void>;
|
|
98
98
|
snapshot(sandboxId: string): Promise<SandboxSnapshot>;
|
|
99
99
|
restore(snapshot: SandboxSnapshot): Promise<Sandbox>;
|
|
100
|
+
fork(sandboxId: string): Promise<Sandbox>;
|
|
100
101
|
}
|
|
101
102
|
interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOptions> {
|
|
102
103
|
createSandbox(options?: TOptions): Promise<{
|
|
@@ -105,7 +106,20 @@ interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOption
|
|
|
105
106
|
}>;
|
|
106
107
|
destroySandbox(sandboxId: string): Promise<void>;
|
|
107
108
|
snapshotSandbox(sandboxId: string): Promise<SandboxSnapshot>;
|
|
109
|
+
forkSandbox(sandboxId: string): Promise<string>;
|
|
108
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Maps generic {@link SandboxOps} method names to adapter-prefixed names.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* type InMemOps = PrefixedSandboxOps<"inMemory">;
|
|
117
|
+
* // → { inMemoryCreateSandbox, inMemoryDestroySandbox, inMemorySnapshotSandbox }
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
type PrefixedSandboxOps<TPrefix extends string, TOptions extends SandboxCreateOptions = SandboxCreateOptions> = {
|
|
121
|
+
[K in keyof SandboxOps<TOptions> as `${TPrefix}${Capitalize<K & string>}`]: SandboxOps<TOptions>[K];
|
|
122
|
+
};
|
|
109
123
|
|
|
110
124
|
declare class SandboxNotSupportedError extends ApplicationFailure {
|
|
111
125
|
constructor(operation: string);
|
|
@@ -114,4 +128,4 @@ declare class SandboxNotFoundError extends ApplicationFailure {
|
|
|
114
128
|
constructor(sandboxId: string);
|
|
115
129
|
}
|
|
116
130
|
|
|
117
|
-
export { type DirentEntry as D, type ExecResult as E, type FileStat as F, type Sandbox as S, type SandboxFileSystem as a, type SandboxProvider as b, type SandboxCapabilities as c, type SandboxCreateOptions as d, type SandboxCreateResult as e, type SandboxSnapshot as f, type SandboxOps as g, type ExecOptions as h, SandboxNotFoundError as i, SandboxNotSupportedError as j };
|
|
131
|
+
export { type DirentEntry as D, type ExecResult as E, type FileStat as F, type PrefixedSandboxOps as P, type Sandbox as S, type SandboxFileSystem as a, type SandboxProvider as b, type SandboxCapabilities as c, type SandboxCreateOptions as d, type SandboxCreateResult as e, type SandboxSnapshot as f, type SandboxOps as g, type ExecOptions as h, SandboxNotFoundError as i, SandboxNotSupportedError as j };
|
|
@@ -97,6 +97,7 @@ interface SandboxProvider<TOptions extends SandboxCreateOptions = SandboxCreateO
|
|
|
97
97
|
destroy(sandboxId: string): Promise<void>;
|
|
98
98
|
snapshot(sandboxId: string): Promise<SandboxSnapshot>;
|
|
99
99
|
restore(snapshot: SandboxSnapshot): Promise<Sandbox>;
|
|
100
|
+
fork(sandboxId: string): Promise<Sandbox>;
|
|
100
101
|
}
|
|
101
102
|
interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOptions> {
|
|
102
103
|
createSandbox(options?: TOptions): Promise<{
|
|
@@ -105,7 +106,20 @@ interface SandboxOps<TOptions extends SandboxCreateOptions = SandboxCreateOption
|
|
|
105
106
|
}>;
|
|
106
107
|
destroySandbox(sandboxId: string): Promise<void>;
|
|
107
108
|
snapshotSandbox(sandboxId: string): Promise<SandboxSnapshot>;
|
|
109
|
+
forkSandbox(sandboxId: string): Promise<string>;
|
|
108
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Maps generic {@link SandboxOps} method names to adapter-prefixed names.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* type InMemOps = PrefixedSandboxOps<"inMemory">;
|
|
117
|
+
* // → { inMemoryCreateSandbox, inMemoryDestroySandbox, inMemorySnapshotSandbox }
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
type PrefixedSandboxOps<TPrefix extends string, TOptions extends SandboxCreateOptions = SandboxCreateOptions> = {
|
|
121
|
+
[K in keyof SandboxOps<TOptions> as `${TPrefix}${Capitalize<K & string>}`]: SandboxOps<TOptions>[K];
|
|
122
|
+
};
|
|
109
123
|
|
|
110
124
|
declare class SandboxNotSupportedError extends ApplicationFailure {
|
|
111
125
|
constructor(operation: string);
|
|
@@ -114,4 +128,4 @@ declare class SandboxNotFoundError extends ApplicationFailure {
|
|
|
114
128
|
constructor(sandboxId: string);
|
|
115
129
|
}
|
|
116
130
|
|
|
117
|
-
export { type DirentEntry as D, type ExecResult as E, type FileStat as F, type Sandbox as S, type SandboxFileSystem as a, type SandboxProvider as b, type SandboxCapabilities as c, type SandboxCreateOptions as d, type SandboxCreateResult as e, type SandboxSnapshot as f, type SandboxOps as g, type ExecOptions as h, SandboxNotFoundError as i, SandboxNotSupportedError as j };
|
|
131
|
+
export { type DirentEntry as D, type ExecResult as E, type FileStat as F, type PrefixedSandboxOps as P, type Sandbox as S, type SandboxFileSystem as a, type SandboxProvider as b, type SandboxCapabilities as c, type SandboxCreateOptions as d, type SandboxCreateResult as e, type SandboxSnapshot as f, type SandboxOps as g, type ExecOptions as h, SandboxNotFoundError as i, SandboxNotSupportedError as j };
|
package/dist/workflow.cjs
CHANGED
|
@@ -375,9 +375,10 @@ function createSubagentHandler(subagents) {
|
|
|
375
375
|
},
|
|
376
376
|
...inheritSandbox && { sandboxId: parentSandboxId }
|
|
377
377
|
};
|
|
378
|
+
const resolvedContext = config.context === void 0 ? void 0 : typeof config.context === "function" ? config.context() : config.context;
|
|
378
379
|
const childOpts = {
|
|
379
380
|
workflowId: childWorkflowId,
|
|
380
|
-
args:
|
|
381
|
+
args: resolvedContext === void 0 ? [args.prompt, workflowInput] : [args.prompt, workflowInput, resolvedContext],
|
|
381
382
|
taskQueue: config.taskQueue ?? parentTaskQueue
|
|
382
383
|
};
|
|
383
384
|
const {
|
|
@@ -528,7 +529,7 @@ var createSession = async ({
|
|
|
528
529
|
initializeThread,
|
|
529
530
|
appendSystemMessage,
|
|
530
531
|
forkThread
|
|
531
|
-
} = threadOps
|
|
532
|
+
} = threadOps;
|
|
532
533
|
const plugins = [];
|
|
533
534
|
if (subagents) {
|
|
534
535
|
const reg = buildSubagentRegistration(subagents);
|
|
@@ -698,37 +699,12 @@ var createSession = async ({
|
|
|
698
699
|
}
|
|
699
700
|
};
|
|
700
701
|
};
|
|
701
|
-
function proxyDefaultThreadOps(options) {
|
|
702
|
-
return workflow.proxyActivities(
|
|
703
|
-
options ?? {
|
|
704
|
-
startToCloseTimeout: "10s",
|
|
705
|
-
retry: {
|
|
706
|
-
maximumAttempts: 6,
|
|
707
|
-
initialInterval: "5s",
|
|
708
|
-
maximumInterval: "15m",
|
|
709
|
-
backoffCoefficient: 4
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
);
|
|
713
|
-
}
|
|
714
|
-
function proxySandboxOps(options) {
|
|
715
|
-
return workflow.proxyActivities(
|
|
716
|
-
options ?? {
|
|
717
|
-
startToCloseTimeout: "30s",
|
|
718
|
-
retry: {
|
|
719
|
-
maximumAttempts: 3,
|
|
720
|
-
initialInterval: "2s",
|
|
721
|
-
maximumInterval: "30s",
|
|
722
|
-
backoffCoefficient: 2
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
);
|
|
726
|
-
}
|
|
727
702
|
|
|
728
703
|
// src/lib/workflow.ts
|
|
729
704
|
function defineWorkflow(config, fn) {
|
|
730
705
|
const workflow = async (input, workflowInput = {}) => {
|
|
731
706
|
const sessionInput = {
|
|
707
|
+
agentName: config.name,
|
|
732
708
|
...workflowInput.previousThreadId && {
|
|
733
709
|
threadId: workflowInput.previousThreadId,
|
|
734
710
|
continueThread: true
|
|
@@ -1520,8 +1496,6 @@ exports.hasFileWithMimeType = hasFileWithMimeType;
|
|
|
1520
1496
|
exports.hasNoOtherToolCalls = hasNoOtherToolCalls;
|
|
1521
1497
|
exports.isTerminalStatus = isTerminalStatus;
|
|
1522
1498
|
exports.parseSkillFile = parseSkillFile;
|
|
1523
|
-
exports.proxyDefaultThreadOps = proxyDefaultThreadOps;
|
|
1524
|
-
exports.proxySandboxOps = proxySandboxOps;
|
|
1525
1499
|
exports.readFileTool = readFileTool;
|
|
1526
1500
|
exports.taskCreateTool = taskCreateTool;
|
|
1527
1501
|
exports.taskGetTool = taskGetTool;
|