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
package/dist/workflow.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { A as AgentResponse, d as AgentState, H as Hooks, J as JsonPrimitive, g as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, P as PostHumanMessageAppendHook, h as PostHumanMessageAppendHookContext, i as PreHumanMessageAppendHook, j as PreHumanMessageAppendHookContext, R as RunAgentActivity, l as SessionEndHook, m as SessionEndHookContext, n as SessionStartHook, o as SessionStartHookContext, S as SkillProvider, u as SubagentWorkflow, v as SubagentWorkflowInput } from './types-CES_30qx.cjs';
|
|
4
|
-
import { g as SandboxOps } from './types-BMRzfELQ.cjs';
|
|
5
|
-
export { h as ExecOptions, E as ExecResult, S as Sandbox, c as SandboxCapabilities, d as SandboxCreateOptions, e as SandboxCreateResult, D as SandboxDirentEntry, F as SandboxFileStat, a as SandboxFileSystem, i as SandboxNotFoundError, j as SandboxNotSupportedError, b as SandboxProvider, f as SandboxSnapshot } from './types-BMRzfELQ.cjs';
|
|
1
|
+
import { m as SessionConfig, Z as ZeitlichSession, g as JsonSerializable, f as AgentStateManager, s as SubagentDefinition, u as SubagentHooks, r as SubagentConfig, v as SubagentSessionInput, t as SubagentHandlerResponse, c as SkillMetadata, d as Skill } from './types-ClsHhtwL.cjs';
|
|
2
|
+
export { A as AgentResponse, e as AgentState, H as Hooks, J as JsonPrimitive, h as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, i as PostHumanMessageAppendHook, j as PostHumanMessageAppendHookContext, k as PreHumanMessageAppendHook, l as PreHumanMessageAppendHookContext, P as PrefixedThreadOps, R as RunAgentActivity, S as ScopedPrefix, n as SessionEndHook, o as SessionEndHookContext, p as SessionStartHook, q as SessionStartHookContext, b as SkillProvider, w as SubagentWorkflow, x as SubagentWorkflowInput, T as ThreadOps } from './types-ClsHhtwL.cjs';
|
|
6
3
|
import { a as ToolMap, B as BaseAgentState, N as ToolRouterOptions, J as ToolRouter, R as RouterContext, K as ToolWithHandler, p as ParsedToolCallUnion, G as ToolNames, c as ToolHandlerResponse, E as ToolHandler, W as WorkflowTask, A as ActivityToolHandler } from './types-YbL7JpEA.cjs';
|
|
7
4
|
export { l as AgentConfig, m as AgentFile, h as AgentStatus, n as AppendToolResultFn, C as ContentPart, I as InferToolResults, M as MessageContent, o as ParsedToolCall, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, d as PostToolUseFailureHookResult, s as PostToolUseHook, t as PostToolUseHookContext, u as PreToolUseHook, v as PreToolUseHookContext, P as PreToolUseHookResult, w as ProcessToolCallsContext, e as RawToolCall, g as RunAgentConfig, x as SerializableToolDefinition, S as SessionExitReason, y as TaskStatus, f as TokenUsage, z as ToolArgs, D as ToolCallResult, k as ToolCallResultUnion, i as ToolDefinition, F as ToolHooks, T as ToolMessageContent, H as ToolResult, j as ToolResultConfig, b as ToolRouterHooks, L as isTerminalStatus } from './types-YbL7JpEA.cjs';
|
|
8
5
|
import z$1, { z } from 'zod';
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export { h as ExecOptions, E as ExecResult, P as PrefixedSandboxOps, S as Sandbox, c as SandboxCapabilities, d as SandboxCreateOptions, e as SandboxCreateResult, D as SandboxDirentEntry, F as SandboxFileStat, a as SandboxFileSystem, i as SandboxNotFoundError, j as SandboxNotSupportedError, g as SandboxOps, b as SandboxProvider, f as SandboxSnapshot } from './types-HBosetv3.cjs';
|
|
7
|
+
import { a as FileEntryMetadata, e as VirtualFileTree, T as TreeMutation, F as FileEntry } from './types-BJ8itUAl.cjs';
|
|
8
|
+
export { b as FileResolver, g as VirtualSandboxState } from './types-BJ8itUAl.cjs';
|
|
9
|
+
export { f as filesWithMimeType, h as hasDirectory, a as hasFileWithMimeType } from './queries-Bw6WEPMw.cjs';
|
|
11
10
|
import '@temporalio/common';
|
|
11
|
+
import '@temporalio/workflow';
|
|
12
12
|
import '@temporalio/common/lib/interfaces';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -21,16 +21,13 @@ import '@temporalio/common/lib/interfaces';
|
|
|
21
21
|
* @example
|
|
22
22
|
* ```typescript
|
|
23
23
|
* import { createSession, createAgentStateManager, defineTool, bashTool } from 'zeitlich/workflow';
|
|
24
|
-
*
|
|
25
|
-
* const stateManager = createAgentStateManager({
|
|
26
|
-
* initialState: { systemPrompt: "You are a helpful assistant." },
|
|
27
|
-
* agentName: "my-agent",
|
|
28
|
-
* });
|
|
24
|
+
* import { proxyGoogleGenAIThreadOps } from 'zeitlich/adapters/thread/google-genai/workflow';
|
|
29
25
|
*
|
|
30
26
|
* const session = await createSession({
|
|
31
27
|
* agentName: "my-agent",
|
|
32
28
|
* maxTurns: 20,
|
|
33
29
|
* threadId: runId,
|
|
30
|
+
* threadOps: proxyGoogleGenAIThreadOps(), // auto-scoped to current workflow
|
|
34
31
|
* runAgent: runAgentActivity,
|
|
35
32
|
* buildContextMessage: () => [{ type: "text", text: prompt }],
|
|
36
33
|
* subagents: [researcherSubagent],
|
|
@@ -43,39 +40,14 @@ import '@temporalio/common/lib/interfaces';
|
|
|
43
40
|
* ```
|
|
44
41
|
*/
|
|
45
42
|
declare const createSession: <T extends ToolMap, M = unknown>({ threadId: providedThreadId, agentName, maxTurns, metadata, runAgent, threadOps, buildContextMessage, subagents, skills, tools, processToolsInParallel, hooks, appendSystemPrompt, continueThread, waitForInputTimeout, sandbox: sandboxOps, sandboxId: inheritedSandboxId, }: SessionConfig<T, M>) => Promise<ZeitlichSession<M>>;
|
|
46
|
-
/**
|
|
47
|
-
* Proxy the adapter's thread operations as Temporal activities.
|
|
48
|
-
* Call this in workflow code to delegate thread operations to the
|
|
49
|
-
* adapter-provided activities registered on the worker.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* const session = await createSession({
|
|
54
|
-
* threadOps: proxyDefaultThreadOps(),
|
|
55
|
-
* // ...
|
|
56
|
-
* });
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare function proxyDefaultThreadOps(options?: Parameters<typeof proxyActivities>[0]): ActivityInterfaceFor<ThreadOps>;
|
|
60
|
-
/**
|
|
61
|
-
* Proxy sandbox lifecycle operations as Temporal activities.
|
|
62
|
-
* Call this in workflow code when the agent needs a sandbox.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* const session = await createSession({
|
|
67
|
-
* sandbox: proxySandboxOps(),
|
|
68
|
-
* // ...
|
|
69
|
-
* });
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
declare function proxySandboxOps(options?: Parameters<typeof proxyActivities>[0]): SandboxOps;
|
|
73
43
|
|
|
74
44
|
/**
|
|
75
45
|
* Session config fields derived from a main workflow input, ready to spread
|
|
76
46
|
* into `createSession`.
|
|
77
47
|
*/
|
|
78
48
|
interface WorkflowSessionInput {
|
|
49
|
+
/** Agent name — spread directly into `createSession` */
|
|
50
|
+
agentName: string;
|
|
79
51
|
/** Thread ID to continue (set from `input.previousThreadId`) */
|
|
80
52
|
threadId?: string;
|
|
81
53
|
/** Whether to continue an existing thread (true when `previousThreadId` is present) */
|
|
@@ -242,7 +214,7 @@ type SubagentArgs = {
|
|
|
242
214
|
* ```
|
|
243
215
|
*/
|
|
244
216
|
declare function defineSubagent<TResult extends z.ZodType = z.ZodType, TContext extends Record<string, unknown> = Record<string, unknown>>(definition: SubagentDefinition<TResult, TContext>, overrides?: {
|
|
245
|
-
context?: TContext;
|
|
217
|
+
context?: TContext | (() => TContext);
|
|
246
218
|
hooks?: SubagentHooks<SubagentArgs, z.infer<TResult>>;
|
|
247
219
|
enabled?: boolean | (() => boolean);
|
|
248
220
|
taskQueue?: string;
|
|
@@ -584,4 +556,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
|
|
|
584
556
|
}[];
|
|
585
557
|
}>;
|
|
586
558
|
|
|
587
|
-
export { ActivityToolHandler, AgentStateManager, type AskUserQuestionArgs, BaseAgentState, type BashArgs, type FileEditArgs, FileEntry, FileEntryMetadata, type FileReadArgs, type FileWriteArgs, type GlobArgs, type GrepArgs, JsonSerializable, ParsedToolCallUnion, type ReadSkillArgs, RouterContext,
|
|
559
|
+
export { ActivityToolHandler, AgentStateManager, type AskUserQuestionArgs, BaseAgentState, type BashArgs, type FileEditArgs, FileEntry, FileEntryMetadata, type FileReadArgs, type FileWriteArgs, type GlobArgs, type GrepArgs, JsonSerializable, ParsedToolCallUnion, type ReadSkillArgs, RouterContext, SessionConfig, Skill, SkillMetadata, type SubagentArgs, SubagentConfig, SubagentDefinition, SubagentHandlerResponse, SubagentHooks, SubagentSessionInput, type TaskCreateArgs, type TaskGetArgs, type TaskListArgs, type TaskUpdateArgs, ToolHandler, ToolHandlerResponse, ToolMap, ToolNames, ToolRouter, ToolWithHandler, TreeMutation, VirtualFileTree, type WorkflowConfig, type WorkflowInput, type WorkflowSessionInput, WorkflowTask, ZeitlichSession, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, formatVirtualFileTree, getShortId, globTool, grepTool, hasNoOtherToolCalls, parseSkillFile, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
package/dist/workflow.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { A as AgentResponse, d as AgentState, H as Hooks, J as JsonPrimitive, g as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, P as PostHumanMessageAppendHook, h as PostHumanMessageAppendHookContext, i as PreHumanMessageAppendHook, j as PreHumanMessageAppendHookContext, R as RunAgentActivity, l as SessionEndHook, m as SessionEndHookContext, n as SessionStartHook, o as SessionStartHookContext, S as SkillProvider, u as SubagentWorkflow, v as SubagentWorkflowInput } from './types-BkAYmc96.js';
|
|
4
|
-
import { g as SandboxOps } from './types-BMRzfELQ.js';
|
|
5
|
-
export { h as ExecOptions, E as ExecResult, S as Sandbox, c as SandboxCapabilities, d as SandboxCreateOptions, e as SandboxCreateResult, D as SandboxDirentEntry, F as SandboxFileStat, a as SandboxFileSystem, i as SandboxNotFoundError, j as SandboxNotSupportedError, b as SandboxProvider, f as SandboxSnapshot } from './types-BMRzfELQ.js';
|
|
1
|
+
import { m as SessionConfig, Z as ZeitlichSession, g as JsonSerializable, f as AgentStateManager, s as SubagentDefinition, u as SubagentHooks, r as SubagentConfig, v as SubagentSessionInput, t as SubagentHandlerResponse, c as SkillMetadata, d as Skill } from './types-C5bkx6kQ.js';
|
|
2
|
+
export { A as AgentResponse, e as AgentState, H as Hooks, J as JsonPrimitive, h as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, i as PostHumanMessageAppendHook, j as PostHumanMessageAppendHookContext, k as PreHumanMessageAppendHook, l as PreHumanMessageAppendHookContext, P as PrefixedThreadOps, R as RunAgentActivity, S as ScopedPrefix, n as SessionEndHook, o as SessionEndHookContext, p as SessionStartHook, q as SessionStartHookContext, b as SkillProvider, w as SubagentWorkflow, x as SubagentWorkflowInput, T as ThreadOps } from './types-C5bkx6kQ.js';
|
|
6
3
|
import { a as ToolMap, B as BaseAgentState, N as ToolRouterOptions, J as ToolRouter, R as RouterContext, K as ToolWithHandler, p as ParsedToolCallUnion, G as ToolNames, c as ToolHandlerResponse, E as ToolHandler, W as WorkflowTask, A as ActivityToolHandler } from './types-YbL7JpEA.js';
|
|
7
4
|
export { l as AgentConfig, m as AgentFile, h as AgentStatus, n as AppendToolResultFn, C as ContentPart, I as InferToolResults, M as MessageContent, o as ParsedToolCall, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, d as PostToolUseFailureHookResult, s as PostToolUseHook, t as PostToolUseHookContext, u as PreToolUseHook, v as PreToolUseHookContext, P as PreToolUseHookResult, w as ProcessToolCallsContext, e as RawToolCall, g as RunAgentConfig, x as SerializableToolDefinition, S as SessionExitReason, y as TaskStatus, f as TokenUsage, z as ToolArgs, D as ToolCallResult, k as ToolCallResultUnion, i as ToolDefinition, F as ToolHooks, T as ToolMessageContent, H as ToolResult, j as ToolResultConfig, b as ToolRouterHooks, L as isTerminalStatus } from './types-YbL7JpEA.js';
|
|
8
5
|
import z$1, { z } from 'zod';
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export { h as ExecOptions, E as ExecResult, P as PrefixedSandboxOps, S as Sandbox, c as SandboxCapabilities, d as SandboxCreateOptions, e as SandboxCreateResult, D as SandboxDirentEntry, F as SandboxFileStat, a as SandboxFileSystem, i as SandboxNotFoundError, j as SandboxNotSupportedError, g as SandboxOps, b as SandboxProvider, f as SandboxSnapshot } from './types-HBosetv3.js';
|
|
7
|
+
import { a as FileEntryMetadata, e as VirtualFileTree, T as TreeMutation, F as FileEntry } from './types-ENYCKFBk.js';
|
|
8
|
+
export { b as FileResolver, g as VirtualSandboxState } from './types-ENYCKFBk.js';
|
|
9
|
+
export { f as filesWithMimeType, h as hasDirectory, a as hasFileWithMimeType } from './queries-C27raDaB.js';
|
|
11
10
|
import '@temporalio/common';
|
|
11
|
+
import '@temporalio/workflow';
|
|
12
12
|
import '@temporalio/common/lib/interfaces';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -21,16 +21,13 @@ import '@temporalio/common/lib/interfaces';
|
|
|
21
21
|
* @example
|
|
22
22
|
* ```typescript
|
|
23
23
|
* import { createSession, createAgentStateManager, defineTool, bashTool } from 'zeitlich/workflow';
|
|
24
|
-
*
|
|
25
|
-
* const stateManager = createAgentStateManager({
|
|
26
|
-
* initialState: { systemPrompt: "You are a helpful assistant." },
|
|
27
|
-
* agentName: "my-agent",
|
|
28
|
-
* });
|
|
24
|
+
* import { proxyGoogleGenAIThreadOps } from 'zeitlich/adapters/thread/google-genai/workflow';
|
|
29
25
|
*
|
|
30
26
|
* const session = await createSession({
|
|
31
27
|
* agentName: "my-agent",
|
|
32
28
|
* maxTurns: 20,
|
|
33
29
|
* threadId: runId,
|
|
30
|
+
* threadOps: proxyGoogleGenAIThreadOps(), // auto-scoped to current workflow
|
|
34
31
|
* runAgent: runAgentActivity,
|
|
35
32
|
* buildContextMessage: () => [{ type: "text", text: prompt }],
|
|
36
33
|
* subagents: [researcherSubagent],
|
|
@@ -43,39 +40,14 @@ import '@temporalio/common/lib/interfaces';
|
|
|
43
40
|
* ```
|
|
44
41
|
*/
|
|
45
42
|
declare const createSession: <T extends ToolMap, M = unknown>({ threadId: providedThreadId, agentName, maxTurns, metadata, runAgent, threadOps, buildContextMessage, subagents, skills, tools, processToolsInParallel, hooks, appendSystemPrompt, continueThread, waitForInputTimeout, sandbox: sandboxOps, sandboxId: inheritedSandboxId, }: SessionConfig<T, M>) => Promise<ZeitlichSession<M>>;
|
|
46
|
-
/**
|
|
47
|
-
* Proxy the adapter's thread operations as Temporal activities.
|
|
48
|
-
* Call this in workflow code to delegate thread operations to the
|
|
49
|
-
* adapter-provided activities registered on the worker.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* const session = await createSession({
|
|
54
|
-
* threadOps: proxyDefaultThreadOps(),
|
|
55
|
-
* // ...
|
|
56
|
-
* });
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare function proxyDefaultThreadOps(options?: Parameters<typeof proxyActivities>[0]): ActivityInterfaceFor<ThreadOps>;
|
|
60
|
-
/**
|
|
61
|
-
* Proxy sandbox lifecycle operations as Temporal activities.
|
|
62
|
-
* Call this in workflow code when the agent needs a sandbox.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* const session = await createSession({
|
|
67
|
-
* sandbox: proxySandboxOps(),
|
|
68
|
-
* // ...
|
|
69
|
-
* });
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
declare function proxySandboxOps(options?: Parameters<typeof proxyActivities>[0]): SandboxOps;
|
|
73
43
|
|
|
74
44
|
/**
|
|
75
45
|
* Session config fields derived from a main workflow input, ready to spread
|
|
76
46
|
* into `createSession`.
|
|
77
47
|
*/
|
|
78
48
|
interface WorkflowSessionInput {
|
|
49
|
+
/** Agent name — spread directly into `createSession` */
|
|
50
|
+
agentName: string;
|
|
79
51
|
/** Thread ID to continue (set from `input.previousThreadId`) */
|
|
80
52
|
threadId?: string;
|
|
81
53
|
/** Whether to continue an existing thread (true when `previousThreadId` is present) */
|
|
@@ -242,7 +214,7 @@ type SubagentArgs = {
|
|
|
242
214
|
* ```
|
|
243
215
|
*/
|
|
244
216
|
declare function defineSubagent<TResult extends z.ZodType = z.ZodType, TContext extends Record<string, unknown> = Record<string, unknown>>(definition: SubagentDefinition<TResult, TContext>, overrides?: {
|
|
245
|
-
context?: TContext;
|
|
217
|
+
context?: TContext | (() => TContext);
|
|
246
218
|
hooks?: SubagentHooks<SubagentArgs, z.infer<TResult>>;
|
|
247
219
|
enabled?: boolean | (() => boolean);
|
|
248
220
|
taskQueue?: string;
|
|
@@ -584,4 +556,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
|
|
|
584
556
|
}[];
|
|
585
557
|
}>;
|
|
586
558
|
|
|
587
|
-
export { ActivityToolHandler, AgentStateManager, type AskUserQuestionArgs, BaseAgentState, type BashArgs, type FileEditArgs, FileEntry, FileEntryMetadata, type FileReadArgs, type FileWriteArgs, type GlobArgs, type GrepArgs, JsonSerializable, ParsedToolCallUnion, type ReadSkillArgs, RouterContext,
|
|
559
|
+
export { ActivityToolHandler, AgentStateManager, type AskUserQuestionArgs, BaseAgentState, type BashArgs, type FileEditArgs, FileEntry, FileEntryMetadata, type FileReadArgs, type FileWriteArgs, type GlobArgs, type GrepArgs, JsonSerializable, ParsedToolCallUnion, type ReadSkillArgs, RouterContext, SessionConfig, Skill, SkillMetadata, type SubagentArgs, SubagentConfig, SubagentDefinition, SubagentHandlerResponse, SubagentHooks, SubagentSessionInput, type TaskCreateArgs, type TaskGetArgs, type TaskListArgs, type TaskUpdateArgs, ToolHandler, ToolHandlerResponse, ToolMap, ToolNames, ToolRouter, ToolWithHandler, TreeMutation, VirtualFileTree, type WorkflowConfig, type WorkflowInput, type WorkflowSessionInput, WorkflowTask, ZeitlichSession, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, formatVirtualFileTree, getShortId, globTool, grepTool, hasNoOtherToolCalls, parseSkillFile, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
package/dist/workflow.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { uuid4, setHandler, defineUpdate, ApplicationFailure, condition,
|
|
1
|
+
import { uuid4, setHandler, defineUpdate, ApplicationFailure, condition, defineQuery, workflowInfo, executeChild } from '@temporalio/workflow';
|
|
2
2
|
import z14, { z } from 'zod';
|
|
3
3
|
import { ApplicationFailure as ApplicationFailure$1 } from '@temporalio/common';
|
|
4
4
|
|
|
@@ -369,9 +369,10 @@ function createSubagentHandler(subagents) {
|
|
|
369
369
|
},
|
|
370
370
|
...inheritSandbox && { sandboxId: parentSandboxId }
|
|
371
371
|
};
|
|
372
|
+
const resolvedContext = config.context === void 0 ? void 0 : typeof config.context === "function" ? config.context() : config.context;
|
|
372
373
|
const childOpts = {
|
|
373
374
|
workflowId: childWorkflowId,
|
|
374
|
-
args:
|
|
375
|
+
args: resolvedContext === void 0 ? [args.prompt, workflowInput] : [args.prompt, workflowInput, resolvedContext],
|
|
375
376
|
taskQueue: config.taskQueue ?? parentTaskQueue
|
|
376
377
|
};
|
|
377
378
|
const {
|
|
@@ -522,7 +523,7 @@ var createSession = async ({
|
|
|
522
523
|
initializeThread,
|
|
523
524
|
appendSystemMessage,
|
|
524
525
|
forkThread
|
|
525
|
-
} = threadOps
|
|
526
|
+
} = threadOps;
|
|
526
527
|
const plugins = [];
|
|
527
528
|
if (subagents) {
|
|
528
529
|
const reg = buildSubagentRegistration(subagents);
|
|
@@ -692,37 +693,12 @@ var createSession = async ({
|
|
|
692
693
|
}
|
|
693
694
|
};
|
|
694
695
|
};
|
|
695
|
-
function proxyDefaultThreadOps(options) {
|
|
696
|
-
return proxyActivities(
|
|
697
|
-
options ?? {
|
|
698
|
-
startToCloseTimeout: "10s",
|
|
699
|
-
retry: {
|
|
700
|
-
maximumAttempts: 6,
|
|
701
|
-
initialInterval: "5s",
|
|
702
|
-
maximumInterval: "15m",
|
|
703
|
-
backoffCoefficient: 4
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
);
|
|
707
|
-
}
|
|
708
|
-
function proxySandboxOps(options) {
|
|
709
|
-
return proxyActivities(
|
|
710
|
-
options ?? {
|
|
711
|
-
startToCloseTimeout: "30s",
|
|
712
|
-
retry: {
|
|
713
|
-
maximumAttempts: 3,
|
|
714
|
-
initialInterval: "2s",
|
|
715
|
-
maximumInterval: "30s",
|
|
716
|
-
backoffCoefficient: 2
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
);
|
|
720
|
-
}
|
|
721
696
|
|
|
722
697
|
// src/lib/workflow.ts
|
|
723
698
|
function defineWorkflow(config, fn) {
|
|
724
699
|
const workflow = async (input, workflowInput = {}) => {
|
|
725
700
|
const sessionInput = {
|
|
701
|
+
agentName: config.name,
|
|
726
702
|
...workflowInput.previousThreadId && {
|
|
727
703
|
threadId: workflowInput.previousThreadId,
|
|
728
704
|
continueThread: true
|
|
@@ -1483,6 +1459,6 @@ var createAskUserQuestionHandler = () => async (args) => {
|
|
|
1483
1459
|
};
|
|
1484
1460
|
};
|
|
1485
1461
|
|
|
1486
|
-
export { SandboxNotFoundError, SandboxNotSupportedError, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, filesWithMimeType, formatVirtualFileTree, getShortId, globTool, grepTool, hasDirectory, hasFileWithMimeType, hasNoOtherToolCalls, isTerminalStatus, parseSkillFile,
|
|
1462
|
+
export { SandboxNotFoundError, SandboxNotSupportedError, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, filesWithMimeType, formatVirtualFileTree, getShortId, globTool, grepTool, hasDirectory, hasFileWithMimeType, hasNoOtherToolCalls, isTerminalStatus, parseSkillFile, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool };
|
|
1487
1463
|
//# sourceMappingURL=workflow.js.map
|
|
1488
1464
|
//# sourceMappingURL=workflow.js.map
|