zeitlich 0.2.38 → 0.2.40
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 +18 -0
- package/dist/{activities-BKhMtKDd.d.ts → activities-CULxRzJ1.d.ts} +4 -6
- package/dist/{activities-CDcwkRZs.d.cts → activities-CvUrG3YG.d.cts} +4 -6
- package/dist/adapter-id-BB-mmrts.d.cts +17 -0
- package/dist/adapter-id-BB-mmrts.d.ts +17 -0
- package/dist/adapter-id-CMwVrVqv.d.cts +17 -0
- package/dist/adapter-id-CMwVrVqv.d.ts +17 -0
- package/dist/adapter-id-CbY2zeSt.d.cts +17 -0
- package/dist/adapter-id-CbY2zeSt.d.ts +17 -0
- package/dist/adapters/thread/anthropic/index.cjs +140 -23
- package/dist/adapters/thread/anthropic/index.cjs.map +1 -1
- package/dist/adapters/thread/anthropic/index.d.cts +8 -7
- package/dist/adapters/thread/anthropic/index.d.ts +8 -7
- package/dist/adapters/thread/anthropic/index.js +140 -24
- package/dist/adapters/thread/anthropic/index.js.map +1 -1
- package/dist/adapters/thread/anthropic/workflow.cjs +8 -3
- package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -1
- package/dist/adapters/thread/anthropic/workflow.d.cts +5 -4
- package/dist/adapters/thread/anthropic/workflow.d.ts +5 -4
- package/dist/adapters/thread/anthropic/workflow.js +8 -4
- package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
- package/dist/adapters/thread/google-genai/index.cjs +140 -23
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +5 -4
- package/dist/adapters/thread/google-genai/index.d.ts +5 -4
- package/dist/adapters/thread/google-genai/index.js +140 -24
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.cjs +8 -3
- package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.d.cts +5 -4
- package/dist/adapters/thread/google-genai/workflow.d.ts +5 -4
- package/dist/adapters/thread/google-genai/workflow.js +8 -4
- package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
- package/dist/adapters/thread/index.cjs +16 -0
- package/dist/adapters/thread/index.cjs.map +1 -0
- package/dist/adapters/thread/index.d.cts +34 -0
- package/dist/adapters/thread/index.d.ts +34 -0
- package/dist/adapters/thread/index.js +12 -0
- package/dist/adapters/thread/index.js.map +1 -0
- package/dist/adapters/thread/langchain/index.cjs +139 -24
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +8 -7
- package/dist/adapters/thread/langchain/index.d.ts +8 -7
- package/dist/adapters/thread/langchain/index.js +139 -25
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/adapters/thread/langchain/workflow.cjs +8 -3
- package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
- package/dist/adapters/thread/langchain/workflow.d.cts +5 -4
- package/dist/adapters/thread/langchain/workflow.d.ts +5 -4
- package/dist/adapters/thread/langchain/workflow.js +8 -4
- package/dist/adapters/thread/langchain/workflow.js.map +1 -1
- package/dist/index.cjs +267 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +264 -49
- package/dist/index.js.map +1 -1
- package/dist/{proxy-D_3x7RN4.d.cts → proxy-5EbwzaY4.d.cts} +1 -1
- package/dist/{proxy-CUlKSvZS.d.ts → proxy-wZufFfBh.d.ts} +1 -1
- package/dist/{thread-manager-CVu7o2cs.d.ts → thread-manager-BNiIt5r8.d.ts} +2 -4
- package/dist/{thread-manager-c1gPopAG.d.ts → thread-manager-BoN5DOvG.d.cts} +2 -4
- package/dist/{thread-manager-wGi-LqIP.d.cts → thread-manager-BqBAIsED.d.ts} +2 -4
- package/dist/{thread-manager-HSwyh28L.d.cts → thread-manager-DF8WuCRs.d.cts} +2 -4
- package/dist/{types-BH_IRryz.d.ts → types-C7OoY7h8.d.ts} +54 -6
- package/dist/{types-C06FwR96.d.cts → types-Cn2r3ol3.d.cts} +163 -44
- package/dist/{types-BaOw4hKI.d.cts → types-CuISs0Ub.d.cts} +54 -6
- package/dist/{types-DNr31FzL.d.ts → types-DeQH84C_.d.ts} +163 -44
- package/dist/{workflow-CSCkpwAL.d.ts → workflow-C2MZZj5K.d.ts} +82 -2
- package/dist/{workflow-DuvMZ8Vm.d.cts → workflow-DhplIN65.d.cts} +82 -2
- package/dist/workflow.cjs +189 -37
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +2 -2
- package/dist/workflow.d.ts +2 -2
- package/dist/workflow.js +186 -38
- package/dist/workflow.js.map +1 -1
- package/package.json +11 -1
- package/src/adapters/thread/adapter-id.test.ts +42 -0
- package/src/adapters/thread/anthropic/activities.ts +33 -7
- package/src/adapters/thread/anthropic/adapter-id.ts +16 -0
- package/src/adapters/thread/anthropic/fork-transform.test.ts +291 -0
- package/src/adapters/thread/anthropic/index.ts +3 -0
- package/src/adapters/thread/anthropic/model-invoker.ts +8 -4
- package/src/adapters/thread/anthropic/proxy.ts +3 -2
- package/src/adapters/thread/anthropic/thread-manager.ts +27 -4
- package/src/adapters/thread/google-genai/activities.ts +33 -7
- package/src/adapters/thread/google-genai/adapter-id.ts +16 -0
- package/src/adapters/thread/google-genai/fork-transform.test.ts +149 -0
- package/src/adapters/thread/google-genai/index.ts +3 -0
- package/src/adapters/thread/google-genai/model-invoker.ts +7 -3
- package/src/adapters/thread/google-genai/proxy.ts +3 -2
- package/src/adapters/thread/google-genai/thread-manager.ts +27 -4
- package/src/adapters/thread/index.ts +39 -0
- package/src/adapters/thread/langchain/activities.ts +33 -7
- package/src/adapters/thread/langchain/adapter-id.ts +16 -0
- package/src/adapters/thread/langchain/fork-transform.test.ts +142 -0
- package/src/adapters/thread/langchain/index.ts +3 -0
- package/src/adapters/thread/langchain/model-invoker.ts +8 -3
- package/src/adapters/thread/langchain/proxy.ts +3 -2
- package/src/adapters/thread/langchain/thread-manager.ts +27 -4
- package/src/lib/lifecycle.ts +3 -1
- package/src/lib/model/types.ts +7 -10
- package/src/lib/session/session-edge-cases.integration.test.ts +131 -63
- package/src/lib/session/session.integration.test.ts +174 -5
- package/src/lib/session/session.ts +69 -28
- package/src/lib/session/types.ts +61 -9
- package/src/lib/state/index.ts +1 -0
- package/src/lib/state/manager.integration.test.ts +109 -0
- package/src/lib/state/manager.ts +38 -8
- package/src/lib/state/types.ts +25 -0
- package/src/lib/subagent/handler.ts +124 -11
- package/src/lib/subagent/index.ts +5 -1
- package/src/lib/subagent/subagent.integration.test.ts +528 -0
- package/src/lib/subagent/types.ts +63 -14
- package/src/lib/subagent/workflow.ts +29 -2
- package/src/lib/thread/index.ts +5 -0
- package/src/lib/thread/keys.test.ts +101 -0
- package/src/lib/thread/keys.ts +94 -0
- package/src/lib/thread/manager.test.ts +139 -0
- package/src/lib/thread/manager.ts +92 -14
- package/src/lib/thread/proxy.ts +2 -0
- package/src/lib/thread/types.ts +60 -6
- package/src/lib/tool-router/types.ts +16 -8
- package/src/lib/types.ts +12 -0
- package/src/workflow.ts +12 -1
- package/tsup.config.ts +1 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Duration } from '@temporalio/common';
|
|
2
|
-
import { ActivityFunctionWithOptions, QueryDefinition, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
2
|
+
import { ActivityFunctionWithOptions, QueryDefinition, ChildWorkflowOptions, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
3
3
|
import { UpdateDefinition } from '@temporalio/common/lib/interfaces';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, d as SandboxCreateOptions,
|
|
5
|
+
import { f as SandboxSnapshot, a as SandboxFileSystem, F as FileStat, D as DirentEntry, d as SandboxCreateOptions, g as SandboxOps } from './types-yx0LzPGn.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* A tool definition with a name, description, and Zod schema for arguments.
|
|
@@ -99,14 +99,16 @@ interface ToolHandlerResponse<TResult = null, TToolResponse = JsonValue> {
|
|
|
99
99
|
*/
|
|
100
100
|
resultAppended?: boolean;
|
|
101
101
|
/**
|
|
102
|
-
* When true, the session will rewind: any in-flight parallel tool
|
|
103
|
-
* are cancelled
|
|
104
|
-
*
|
|
105
|
-
*
|
|
102
|
+
* When true, the session will rewind: any in-flight parallel tool
|
|
103
|
+
* calls are cancelled and the LLM call is retried. The session reuses
|
|
104
|
+
* the same `assistantMessageId` for the retry; the next `runAgent`
|
|
105
|
+
* activity truncates the thread from that id on entry, wiping the
|
|
106
|
+
* triggering assistant message and any tool results already appended
|
|
107
|
+
* before re-invoking the LLM.
|
|
106
108
|
*
|
|
107
109
|
* The `toolResponse` for a rewinding tool call is ignored (never
|
|
108
|
-
* appended) since the
|
|
109
|
-
*
|
|
110
|
+
* appended) since the thread is rewound back to the pre-assistant
|
|
111
|
+
* state on the next invocation.
|
|
110
112
|
*/
|
|
111
113
|
rewind?: boolean;
|
|
112
114
|
/** Token usage from the tool execution (e.g. child agent invocations) */
|
|
@@ -115,6 +117,10 @@ interface ToolHandlerResponse<TResult = null, TToolResponse = JsonValue> {
|
|
|
115
117
|
threadId?: string;
|
|
116
118
|
/** Sandbox ID created or used by the handler (e.g. child agent sandbox) */
|
|
117
119
|
sandboxId?: string;
|
|
120
|
+
/** Snapshot captured on exit when `sandboxShutdown === "snapshot"`. */
|
|
121
|
+
snapshot?: SandboxSnapshot;
|
|
122
|
+
/** Snapshot captured immediately after sandbox seeding (before the agent loop starts) when `sandbox.mode === "new"` and `sandboxShutdown === "snapshot"`. Intended as a reusable "base" for new threads that want to skip re-seeding. */
|
|
123
|
+
baseSnapshot?: SandboxSnapshot;
|
|
118
124
|
/** Unvalidated metadata passthrough from handler to hooks (e.g. infrastructure state) */
|
|
119
125
|
metadata?: Record<string, unknown>;
|
|
120
126
|
}
|
|
@@ -199,8 +205,9 @@ interface ProcessToolCallsContext {
|
|
|
199
205
|
}
|
|
200
206
|
/**
|
|
201
207
|
* Signal that a tool handler requested a rewind. Attached to the
|
|
202
|
-
* {@link ProcessToolCallsResult} so the session can
|
|
203
|
-
*
|
|
208
|
+
* {@link ProcessToolCallsResult} so the session can reuse the same
|
|
209
|
+
* `assistantMessageId` for the retry; the next `runAgent` activity
|
|
210
|
+
* then truncates the thread from that id on entry.
|
|
204
211
|
*/
|
|
205
212
|
interface RewindSignal {
|
|
206
213
|
toolCallId: string;
|
|
@@ -420,6 +427,22 @@ type JsonSerializable<T> = {
|
|
|
420
427
|
* Full state type combining base state with custom state
|
|
421
428
|
*/
|
|
422
429
|
type AgentState<TCustom extends JsonSerializable<TCustom>> = BaseAgentState & TCustom;
|
|
430
|
+
/**
|
|
431
|
+
* The slice of agent state that is persisted alongside the thread in the
|
|
432
|
+
* thread store (e.g. Redis) so that a workflow can terminate, store its
|
|
433
|
+
* state, and be continued or forked later with that state rehydrated.
|
|
434
|
+
*
|
|
435
|
+
* Only fields that make sense to carry across workflow runs belong here.
|
|
436
|
+
* Runtime bookkeeping like status, version, turns, tools, fileTree, token
|
|
437
|
+
* counters, and the system prompt is intentionally NOT persisted — each run
|
|
438
|
+
* rebuilds those from scratch.
|
|
439
|
+
*/
|
|
440
|
+
interface PersistedThreadState {
|
|
441
|
+
/** Task map serialized as entries so it round-trips through JSON. */
|
|
442
|
+
tasks: [string, WorkflowTask][];
|
|
443
|
+
/** All custom state fields declared by the caller. */
|
|
444
|
+
custom: Record<string, JsonValue>;
|
|
445
|
+
}
|
|
423
446
|
/**
|
|
424
447
|
* Agent state manager interface
|
|
425
448
|
* Note: Temporal handlers must be set up in the workflow file due to
|
|
@@ -479,6 +502,13 @@ interface AgentStateManager<TCustom extends JsonSerializable<TCustom>> {
|
|
|
479
502
|
deleteTask(id: string): boolean;
|
|
480
503
|
/** Set the tools (converts Zod schemas to JSON Schema for serialization) */
|
|
481
504
|
setTools(newTools: ToolDefinition[]): void;
|
|
505
|
+
/**
|
|
506
|
+
* Snapshot the fields that should survive across workflow runs
|
|
507
|
+
* (tasks + all custom state). Safe to pass directly to
|
|
508
|
+
* {@link ThreadOps.saveThreadState}. Rehydrate on the next run with
|
|
509
|
+
* `mergeUpdate({ tasks: new Map(slice.tasks), ...slice.custom })`.
|
|
510
|
+
*/
|
|
511
|
+
getPersistedSlice(): PersistedThreadState;
|
|
482
512
|
/** Update the usage */
|
|
483
513
|
updateUsage(usage: TokenUsage): void;
|
|
484
514
|
/** Get the total usage */
|
|
@@ -699,6 +729,18 @@ interface RunAgentConfig extends AgentConfig {
|
|
|
699
729
|
threadKey?: string;
|
|
700
730
|
/** Metadata for the session */
|
|
701
731
|
metadata?: Record<string, unknown>;
|
|
732
|
+
/**
|
|
733
|
+
* The id under which the assistant message produced by this call will
|
|
734
|
+
* be appended. The activity truncates the thread from this id on
|
|
735
|
+
* entry (no-op on the first attempt) so that:
|
|
736
|
+
*
|
|
737
|
+
* - Rewind retries can reuse the same id and the previous (bad)
|
|
738
|
+
* assistant + its tool results are wiped before the retry LLM call.
|
|
739
|
+
* - Resetting the Temporal workflow to this activity restores the
|
|
740
|
+
* pre-call thread state: replay re-truncates, re-invokes, and
|
|
741
|
+
* appends under the same id.
|
|
742
|
+
*/
|
|
743
|
+
assistantMessageId: string;
|
|
702
744
|
}
|
|
703
745
|
/**
|
|
704
746
|
* Configuration for appending a tool result
|
|
@@ -817,7 +859,9 @@ interface Hooks<T extends ToolMap, TResult = unknown, TContent = unknown> extend
|
|
|
817
859
|
* - `"new"` — start a fresh thread (optionally specify its ID).
|
|
818
860
|
* - `"continue"` — append directly to an existing thread in-place.
|
|
819
861
|
* - `"fork"` — copy all messages from an existing thread into a new one and
|
|
820
|
-
* continue there.
|
|
862
|
+
* continue there. When the adapter has `onForkPrepareThread` and/or
|
|
863
|
+
* `onForkTransform` hooks configured, they are applied once to the forked
|
|
864
|
+
* thread before the session starts.
|
|
821
865
|
*/
|
|
822
866
|
type ThreadInit = {
|
|
823
867
|
mode: "new";
|
|
@@ -889,19 +933,20 @@ type SandboxShutdown = "destroy" | "pause" | "keep" | "snapshot";
|
|
|
889
933
|
*/
|
|
890
934
|
type SubagentSandboxShutdown = SandboxShutdown | "pause-until-parent-close" | "keep-until-parent-close";
|
|
891
935
|
|
|
936
|
+
/**
|
|
937
|
+
* Subset of {@link ChildWorkflowOptions} that callers may override when a
|
|
938
|
+
* subagent is invoked. `workflowId`, `taskQueue`, and `args` are managed by
|
|
939
|
+
* the subagent handler itself and therefore cannot be set here.
|
|
940
|
+
*
|
|
941
|
+
* Configuring `workflowRunTimeout` (or `workflowExecutionTimeout`) is strongly
|
|
942
|
+
* recommended: it is the only reliable way to guarantee that a child workflow
|
|
943
|
+
* which fails during initialization or repeatedly fails workflow tasks will
|
|
944
|
+
* eventually be terminated, allowing the parent's `Subagent` tool call to fail
|
|
945
|
+
* deterministically instead of hanging forever waiting for a result.
|
|
946
|
+
*/
|
|
947
|
+
type SubagentChildWorkflowOptions = Omit<ChildWorkflowOptions, "workflowId" | "taskQueue" | "args">;
|
|
892
948
|
/** ToolHandlerResponse with threadId required (subagents must always surface their thread) */
|
|
893
|
-
type SubagentHandlerResponse<TResult = null, TToolResponse = JsonValue> = ToolHandlerResponse<TResult, TToolResponse
|
|
894
|
-
threadId: string;
|
|
895
|
-
sandboxId?: string;
|
|
896
|
-
/** Snapshot captured on session exit when `sandboxShutdown === "snapshot"`. */
|
|
897
|
-
snapshot?: SandboxSnapshot;
|
|
898
|
-
/**
|
|
899
|
-
* Snapshot captured immediately after the sandbox was seeded (before the
|
|
900
|
-
* first agent turn) when `continuation === "snapshot"`. Only set on the
|
|
901
|
-
* first call that actually created the sandbox.
|
|
902
|
-
*/
|
|
903
|
-
baseSnapshot?: SandboxSnapshot;
|
|
904
|
-
};
|
|
949
|
+
type SubagentHandlerResponse<TResult = null, TToolResponse = JsonValue> = ToolHandlerResponse<TResult, TToolResponse>;
|
|
905
950
|
/**
|
|
906
951
|
* Raw workflow input fields passed from parent to child workflow.
|
|
907
952
|
* `defineSubagentWorkflow` maps this into `SubagentSessionInput`.
|
|
@@ -972,6 +1017,24 @@ interface SubagentConfig<TResult extends z.ZodType = z.ZodType> {
|
|
|
972
1017
|
workflow: SubagentWorkflow<TResult>;
|
|
973
1018
|
/** Optional task queue - defaults to parent's queue if not specified */
|
|
974
1019
|
taskQueue?: string;
|
|
1020
|
+
/**
|
|
1021
|
+
* Optional child workflow options forwarded to `executeChild` when the
|
|
1022
|
+
* subagent is spawned. Use this to configure timeouts, retry policies, or
|
|
1023
|
+
* parent-close behavior for the child workflow.
|
|
1024
|
+
*
|
|
1025
|
+
* **Recommended:** configure a `workflowRunTimeout` (or
|
|
1026
|
+
* `workflowExecutionTimeout`) so that a child workflow that fails to
|
|
1027
|
+
* initialize — or repeatedly fails workflow tasks without ever reaching a
|
|
1028
|
+
* terminal state — is eventually terminated by the Temporal server. Without
|
|
1029
|
+
* such a timeout, the parent's `Subagent` tool call can hang indefinitely
|
|
1030
|
+
* waiting for the child to finish. When Temporal terminates the child, the
|
|
1031
|
+
* tool call fails with a structured `ChildWorkflowFailure` that the router's
|
|
1032
|
+
* failure hooks can handle just like any other tool error.
|
|
1033
|
+
*
|
|
1034
|
+
* `workflowId`, `taskQueue`, and `args` are managed by the subagent handler
|
|
1035
|
+
* and cannot be overridden here.
|
|
1036
|
+
*/
|
|
1037
|
+
workflowOptions?: SubagentChildWorkflowOptions;
|
|
975
1038
|
/** Optional Zod schema to validate the child workflow's result. If omitted, result is passed through as-is. */
|
|
976
1039
|
resultSchema?: TResult;
|
|
977
1040
|
/** Optional context passed to the subagent — a static object or a function evaluated at invocation time */
|
|
@@ -1063,8 +1126,26 @@ interface SubagentSessionInput {
|
|
|
1063
1126
|
sandbox?: SandboxInit;
|
|
1064
1127
|
/** Sandbox shutdown policy (default: "destroy") */
|
|
1065
1128
|
sandboxShutdown?: SubagentSandboxShutdown;
|
|
1066
|
-
/**
|
|
1067
|
-
|
|
1129
|
+
/**
|
|
1130
|
+
* Called by the session as soon as the sandbox is created, before the
|
|
1131
|
+
* agent loop starts. `baseSnapshot` is populated only when the session
|
|
1132
|
+
* captured a seed snapshot (fresh creation + `sandboxShutdown === "snapshot"`).
|
|
1133
|
+
*/
|
|
1134
|
+
onSandboxReady?: (args: {
|
|
1135
|
+
sandboxId: string;
|
|
1136
|
+
baseSnapshot?: SandboxSnapshot;
|
|
1137
|
+
}) => void;
|
|
1138
|
+
/**
|
|
1139
|
+
* Called by the session right before `runSession` returns. Installed by
|
|
1140
|
+
* `defineSubagentWorkflow` to capture sandbox outputs and auto-forward
|
|
1141
|
+
* them to the subagent's final result so user code never has to thread
|
|
1142
|
+
* `sandboxId` / `snapshot` manually.
|
|
1143
|
+
*/
|
|
1144
|
+
onSessionExit?: (result: {
|
|
1145
|
+
sandboxId?: string;
|
|
1146
|
+
snapshot?: SandboxSnapshot;
|
|
1147
|
+
threadId: string;
|
|
1148
|
+
}) => void;
|
|
1068
1149
|
}
|
|
1069
1150
|
|
|
1070
1151
|
/**
|
|
@@ -1120,16 +1201,6 @@ interface AgentResponse<M = unknown> {
|
|
|
1120
1201
|
message: M;
|
|
1121
1202
|
rawToolCalls: RawToolCall[];
|
|
1122
1203
|
usage?: TokenUsage;
|
|
1123
|
-
/**
|
|
1124
|
-
* Number of stored messages in the thread at the moment the LLM was
|
|
1125
|
-
* invoked — i.e. *before* the assistant message is appended. The
|
|
1126
|
-
* session uses this as a rewind snapshot so it can roll the thread
|
|
1127
|
-
* back to this exact state if a tool requests a rewind.
|
|
1128
|
-
*
|
|
1129
|
-
* Adapters compute this for free from the array of stored messages
|
|
1130
|
-
* they load when preparing the payload.
|
|
1131
|
-
*/
|
|
1132
|
-
threadLengthAtCall?: number;
|
|
1133
1204
|
}
|
|
1134
1205
|
/**
|
|
1135
1206
|
* Type signature for workflow-specific runAgent activity
|
|
@@ -1147,6 +1218,13 @@ interface ModelInvokerConfig {
|
|
|
1147
1218
|
agentName: string;
|
|
1148
1219
|
state: BaseAgentState;
|
|
1149
1220
|
metadata?: Record<string, unknown>;
|
|
1221
|
+
/**
|
|
1222
|
+
* The id the assistant message produced by this call will be stored
|
|
1223
|
+
* under. Invokers truncate the thread from this id on entry so that
|
|
1224
|
+
* rewind retries and Temporal workflow resets restore the pre-call
|
|
1225
|
+
* state before re-invoking the LLM. See {@link RunAgentConfig}.
|
|
1226
|
+
*/
|
|
1227
|
+
assistantMessageId: string;
|
|
1150
1228
|
}
|
|
1151
1229
|
/**
|
|
1152
1230
|
* Generic model invocation contract.
|
|
@@ -1178,16 +1256,39 @@ interface ThreadOps<TContent = string> {
|
|
|
1178
1256
|
appendAgentMessage(threadId: string, id: string, message: unknown, threadKey?: string): Promise<void>;
|
|
1179
1257
|
/** Append a system message to the thread */
|
|
1180
1258
|
appendSystemMessage(threadId: string, id: string, content: unknown, threadKey?: string): Promise<void>;
|
|
1181
|
-
/**
|
|
1259
|
+
/**
|
|
1260
|
+
* Copy all messages AND the persisted state slice (tasks + custom
|
|
1261
|
+
* state) from `sourceThreadId` into a new thread at `targetThreadId`.
|
|
1262
|
+
* Adapters that have `onForkPrepareThread` and/or `onForkTransform`
|
|
1263
|
+
* hooks configured apply them once to the new thread's messages
|
|
1264
|
+
* before returning.
|
|
1265
|
+
*/
|
|
1182
1266
|
forkThread(sourceThreadId: string, targetThreadId: string, threadKey?: string): Promise<void>;
|
|
1183
1267
|
/**
|
|
1184
|
-
* Truncate the thread
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1268
|
+
* Truncate the thread starting at `messageId`: that message and every
|
|
1269
|
+
* message after it are removed. If `messageId` is not present the call
|
|
1270
|
+
* is a no-op.
|
|
1271
|
+
*
|
|
1272
|
+
* The `runAgent` activity invokes this on entry with the pre-generated
|
|
1273
|
+
* `assistantMessageId`. On the happy path the id is not yet in the
|
|
1274
|
+
* thread and the call is a no-op. On a rewind retry (same assistant
|
|
1275
|
+
* id reused) or a Temporal workflow reset-to-this-activity the id is
|
|
1276
|
+
* present, so the bad assistant + any tool results it produced are
|
|
1277
|
+
* wiped and the call is then replayable.
|
|
1278
|
+
*/
|
|
1279
|
+
truncateThread(threadId: string, messageId: string, threadKey?: string): Promise<void>;
|
|
1280
|
+
/**
|
|
1281
|
+
* Load the persisted state slice (tasks + custom state) associated with
|
|
1282
|
+
* the thread, or `null` if none has been saved yet. Called on session
|
|
1283
|
+
* start for `continue`/`fork` threads to rehydrate {@link AgentStateManager}.
|
|
1189
1284
|
*/
|
|
1190
|
-
|
|
1285
|
+
loadThreadState(threadId: string, threadKey?: string): Promise<PersistedThreadState | null>;
|
|
1286
|
+
/**
|
|
1287
|
+
* Overwrite the persisted state slice for the thread. Called once from
|
|
1288
|
+
* the session's `finally` block on every exit path so that "finish,
|
|
1289
|
+
* store, continue later" works regardless of exit reason.
|
|
1290
|
+
*/
|
|
1291
|
+
saveThreadState(threadId: string, state: PersistedThreadState, threadKey?: string): Promise<void>;
|
|
1191
1292
|
}
|
|
1192
1293
|
/**
|
|
1193
1294
|
* Composes an adapter prefix + workflow scope for activity naming.
|
|
@@ -1292,8 +1393,26 @@ interface SessionConfig<T extends ToolMap, M = unknown, TContent = string> {
|
|
|
1292
1393
|
/**
|
|
1293
1394
|
* Called as soon as the sandbox is created (or resumed/forked), before the
|
|
1294
1395
|
* agent loop starts. Useful for signalling sandbox readiness to a parent.
|
|
1396
|
+
*
|
|
1397
|
+
* `baseSnapshot` is only populated when the sandbox was freshly created
|
|
1398
|
+
* this run and `sandboxShutdown === "snapshot"` — i.e. when the session
|
|
1399
|
+
* captured a seed snapshot intended for reuse.
|
|
1295
1400
|
*/
|
|
1296
|
-
onSandboxReady?: (
|
|
1401
|
+
onSandboxReady?: (args: {
|
|
1402
|
+
sandboxId: string;
|
|
1403
|
+
baseSnapshot?: SandboxSnapshot;
|
|
1404
|
+
}) => void;
|
|
1405
|
+
/**
|
|
1406
|
+
* Called right before `runSession` returns, with the session's sandbox
|
|
1407
|
+
* outputs. Useful for callers (e.g. `defineSubagentWorkflow`) that want to
|
|
1408
|
+
* forward these fields to their own return value without requiring user
|
|
1409
|
+
* code to manually thread them through.
|
|
1410
|
+
*/
|
|
1411
|
+
onSessionExit?: (result: {
|
|
1412
|
+
threadId: string;
|
|
1413
|
+
sandboxId?: string;
|
|
1414
|
+
snapshot?: SandboxSnapshot;
|
|
1415
|
+
}) => void;
|
|
1297
1416
|
virtualFsOps?: VirtualFsOps;
|
|
1298
1417
|
/**
|
|
1299
1418
|
* Virtual filesystem configuration (optional — independent of sandbox).
|
|
@@ -1336,4 +1455,4 @@ interface ZeitlichSession<M = unknown, HasSandbox extends boolean = boolean> {
|
|
|
1336
1455
|
}): Promise<SessionResult<M, T, HasSandbox>>;
|
|
1337
1456
|
}
|
|
1338
1457
|
|
|
1339
|
-
export { type
|
|
1458
|
+
export { type SandboxShutdown as $, type AgentResponse as A, type BaseAgentState as B, type PostToolUseFailureHookContext as C, type PostToolUseFailureHookResult as D, type PostToolUseHook as E, type FileEntryMetadata as F, type PostToolUseHookContext as G, type Hooks as H, type InferToolResults as I, type JsonValue as J, type PreHumanMessageAppendHook as K, type PreHumanMessageAppendHookContext as L, type ModelInvokerConfig as M, type PreToolUseHook as N, type PreToolUseHookContext as O, type PersistedThreadState as P, type PreToolUseHookResult as Q, type RouterContext as R, type ScopedPrefix as S, type ThreadOps as T, type ProcessToolCallsContext as U, type VirtualFsContext as V, type ProcessToolCallsResult as W, type RawToolCall as X, type RewindSignal as Y, type RunAgentActivity as Z, type SandboxInit as _, type ModelInvoker as a, type SerializableToolDefinition as a0, type SessionConfig as a1, type SessionEndHook as a2, type SessionEndHookContext as a3, type SessionExitReason as a4, type SessionResult as a5, type SessionStartHook as a6, type SessionStartHookContext as a7, type SubagentChildWorkflowOptions as a8, type SubagentConfig as a9, type VirtualFsOps as aA, type VirtualFsState as aB, type WorkflowTask as aC, type ZeitlichSession as aD, isTerminalStatus as aE, type ToolRouterOptions as aF, type SubagentDefinition as aa, type SubagentFnResult as ab, type SubagentHandlerResponse as ac, type SubagentHooks as ad, type SubagentSandboxConfig as ae, type SubagentSandboxShutdown as af, type SubagentSessionInput as ag, type SubagentWorkflow as ah, type SubagentWorkflowInput as ai, type TaskStatus as aj, type ThreadInit as ak, type TokenUsage as al, type ToolArgs as am, type ToolCallResult as an, type ToolCallResultUnion as ao, type ToolDefinition as ap, type ToolHandler as aq, type ToolHooks as ar, type ToolMap as as, type ToolNames as at, type ToolResult as au, type ToolRouter as av, type ToolRouterHooks as aw, type ToolWithHandler as ax, VirtualFileSystem as ay, type VirtualFileTree as az, type PrefixedThreadOps as b, type ToolHandlerResponse as c, type ActivityToolHandler as d, type ToolResultConfig as e, type RunAgentConfig as f, type SkillProvider as g, type SkillMetadata as h, type Skill as i, type FileResolver as j, type TreeMutation as k, type PrefixedVirtualFsOps as l, type AgentConfig as m, type AgentFile as n, type AgentState as o, type AgentStateManager as p, type AgentStatus as q, type AppendToolResultFn as r, type FileEntry as s, type JsonPrimitive as t, type JsonSerializable as u, type ParsedToolCall as v, type ParsedToolCallUnion as w, type PostHumanMessageAppendHook as x, type PostHumanMessageAppendHookContext as y, type PostToolUseFailureHook as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { as as ToolMap, a1 as SessionConfig, aD as ZeitlichSession, $ as SandboxShutdown, ak as ThreadInit, _ as SandboxInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aF as ToolRouterOptions, av as ToolRouter, R as RouterContext, J as JsonValue, ax as ToolWithHandler, w as ParsedToolCallUnion, at as ToolNames, aa as SubagentDefinition, ad as SubagentHooks, ae as SubagentSandboxConfig, a9 as SubagentConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ab as SubagentFnResult, a6 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, al as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, az as VirtualFileTree, k as TreeMutation, s as FileEntry, aA as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, aq as ToolHandler, aC as WorkflowTask, d as ActivityToolHandler } from './types-DeQH84C_.js';
|
|
2
2
|
import { g as SandboxOps } from './types-yx0LzPGn.js';
|
|
3
3
|
import z$1, { z } from 'zod';
|
|
4
4
|
import { Sinks, proxyActivities } from '@temporalio/workflow';
|
|
@@ -97,6 +97,68 @@ declare function defineWorkflow<TInput, TResult>(config: WorkflowConfig, fn: (in
|
|
|
97
97
|
*/
|
|
98
98
|
declare function getShortId(length?: number): string;
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Public helpers for zeitlich's Redis thread storage layout.
|
|
102
|
+
*
|
|
103
|
+
* These are the exact string-building primitives zeitlich's internal thread
|
|
104
|
+
* manager uses for every adapter. Downstream consumers that need to read a
|
|
105
|
+
* persisted thread (for evaluation, observability, admin tooling, etc.)
|
|
106
|
+
* should use these helpers rather than reconstructing the key layout by
|
|
107
|
+
* hand — the layout is versioned with this module, so upgrading zeitlich
|
|
108
|
+
* keeps the consumer in sync.
|
|
109
|
+
*
|
|
110
|
+
* The layout is adapter-agnostic: every thread adapter stores messages the
|
|
111
|
+
* same way.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* import {
|
|
116
|
+
* getThreadListKey,
|
|
117
|
+
* getThreadMetaKey,
|
|
118
|
+
* THREAD_TTL_SECONDS,
|
|
119
|
+
* } from 'zeitlich';
|
|
120
|
+
*
|
|
121
|
+
* const listKey = getThreadListKey('messages', threadId);
|
|
122
|
+
* const metaKey = getThreadMetaKey('messages', threadId);
|
|
123
|
+
* const ttl = await redis.ttl(listKey); // <= THREAD_TTL_SECONDS
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* TTL (in seconds) applied to every thread list and thread meta key that
|
|
128
|
+
* zeitlich's {@link createThreadManager} writes. Exposed so downstream
|
|
129
|
+
* consumers can size their Redis retention / query windows to match.
|
|
130
|
+
*
|
|
131
|
+
* Current value: 90 days.
|
|
132
|
+
*/
|
|
133
|
+
declare const THREAD_TTL_SECONDS: number;
|
|
134
|
+
/**
|
|
135
|
+
* Build the Redis list key that holds a thread's serialized messages.
|
|
136
|
+
*
|
|
137
|
+
* Mirrors the exact key used internally by zeitlich's thread manager,
|
|
138
|
+
* so a consumer calling `redis.lrange(getThreadListKey(key, id), 0, -1)`
|
|
139
|
+
* sees the same data the writer wrote.
|
|
140
|
+
*
|
|
141
|
+
* @param threadKey - Thread key (defaults to `"messages"` inside the
|
|
142
|
+
* thread manager, but downstream adapters may pass
|
|
143
|
+
* their own value).
|
|
144
|
+
* @param threadId - Thread id as provided to the thread manager.
|
|
145
|
+
*/
|
|
146
|
+
declare function getThreadListKey(threadKey: string, threadId: string): string;
|
|
147
|
+
/**
|
|
148
|
+
* Build the Redis key that stores a thread's existence marker / metadata.
|
|
149
|
+
*
|
|
150
|
+
* Zeitlich treats the presence of this key as "thread has been
|
|
151
|
+
* initialized"; append/load/fork/truncate operations fail when it is
|
|
152
|
+
* missing. Consumers can use it as a cheap existence probe without
|
|
153
|
+
* scanning the message list.
|
|
154
|
+
*
|
|
155
|
+
* @param threadKey - Thread key (defaults to `"messages"` inside the
|
|
156
|
+
* thread manager, but downstream adapters may pass
|
|
157
|
+
* their own value).
|
|
158
|
+
* @param threadId - Thread id as provided to the thread manager.
|
|
159
|
+
*/
|
|
160
|
+
declare function getThreadMetaKey(threadKey: string, threadId: string): string;
|
|
161
|
+
|
|
100
162
|
/**
|
|
101
163
|
* Creates an agent state manager for tracking workflow state.
|
|
102
164
|
* Automatically registers Temporal query and update handlers for the agent.
|
|
@@ -194,6 +256,22 @@ type SubagentArgs = {
|
|
|
194
256
|
threadId?: string | null;
|
|
195
257
|
};
|
|
196
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Default `workflowRunTimeout` applied to every subagent child workflow
|
|
261
|
+
* unless overridden via `SubagentConfig.workflowOptions.workflowRunTimeout`.
|
|
262
|
+
*
|
|
263
|
+
* Chosen as a safety bound: Temporal retries failing workflow tasks forever
|
|
264
|
+
* by default, so a child that fails to initialize (e.g. missing workflow
|
|
265
|
+
* export) or is otherwise broken will never reach a terminal state on its
|
|
266
|
+
* own and the parent's `Subagent` tool call would hang indefinitely. A
|
|
267
|
+
* bounded run timeout guarantees the child is eventually terminated and the
|
|
268
|
+
* parent receives a structured `ChildWorkflowFailure` it can surface to the
|
|
269
|
+
* agent. One hour is generous enough for realistic agent sessions while
|
|
270
|
+
* still catching hangs; agents that legitimately need longer should set an
|
|
271
|
+
* explicit `workflowOptions.workflowRunTimeout`.
|
|
272
|
+
*/
|
|
273
|
+
declare const DEFAULT_SUBAGENT_WORKFLOW_RUN_TIMEOUT = "1h";
|
|
274
|
+
|
|
197
275
|
/**
|
|
198
276
|
* Creates a `SubagentConfig` from a `SubagentDefinition` (returned by `defineSubagentWorkflow`).
|
|
199
277
|
* Metadata (name, description, resultSchema) is read from the definition — only configure
|
|
@@ -264,6 +342,8 @@ declare function defineSubagent<TResult extends z.ZodType = z.ZodType, TContext
|
|
|
264
342
|
* });
|
|
265
343
|
*
|
|
266
344
|
* const { finalMessage, threadId } = await session.runSession({ stateManager });
|
|
345
|
+
* // `sandboxId`, `snapshot`, and `baseSnapshot` are auto-forwarded
|
|
346
|
+
* // from the session — no need to thread them through manually.
|
|
267
347
|
* return { toolResponse: finalMessage ?? "No response", data: null, threadId };
|
|
268
348
|
* },
|
|
269
349
|
* );
|
|
@@ -775,4 +855,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
|
|
|
775
855
|
}[];
|
|
776
856
|
}>;
|
|
777
857
|
|
|
778
|
-
export {
|
|
858
|
+
export { hasDirectory as $, type AskUserQuestionArgs as A, type BashArgs as B, createTaskGetHandler as C, DEFAULT_SUBAGENT_WORKFLOW_RUN_TIMEOUT as D, createTaskListHandler as E, type FileEditArgs as F, type GlobArgs as G, createTaskUpdateHandler as H, createToolRouter as I, defineSubagent as J, defineSubagentWorkflow as K, defineTool as L, defineWorkflow as M, editTool as N, type ObservabilityHooks as O, filesWithMimeType as P, formatVirtualFileTree as Q, type ReadSkillArgs as R, type SessionEndedEvent as S, THREAD_TTL_SECONDS as T, getShortId as U, getThreadListKey as V, type WorkflowConfig as W, getThreadMetaKey as X, globTool as Y, type ZeitlichObservabilitySinks as Z, grepTool as _, type FileReadArgs as a, hasFileWithMimeType as a0, hasNoOtherToolCalls as a1, parseSkillFile as a2, proxyRunAgent as a3, proxyVirtualFsOps as a4, readFileTool as a5, taskCreateTool as a6, taskGetTool as a7, taskListTool as a8, taskUpdateTool as a9, writeFileTool as aa, type FileWriteArgs as b, type FileTreeAccessor as c, type GrepArgs as d, type SessionStartedEvent as e, type SubagentArgs as f, type TaskCreateArgs as g, type TaskGetArgs as h, type TaskListArgs as i, type TaskUpdateArgs as j, type ToolExecutedEvent as k, type TurnCompletedEvent as l, type WorkflowInput as m, type WorkflowSessionInput as n, applyVirtualTreeMutations as o, askUserQuestionTool as p, bashTool as q, composeHooks as r, createAgentStateManager as s, createAskUserQuestionHandler as t, createBashToolDescription as u, createObservabilityHooks as v, createReadSkillHandler as w, createReadSkillTool as x, createSession as y, createTaskCreateHandler as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { as as ToolMap, a1 as SessionConfig, aD as ZeitlichSession, $ as SandboxShutdown, ak as ThreadInit, _ as SandboxInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aF as ToolRouterOptions, av as ToolRouter, R as RouterContext, J as JsonValue, ax as ToolWithHandler, w as ParsedToolCallUnion, at as ToolNames, aa as SubagentDefinition, ad as SubagentHooks, ae as SubagentSandboxConfig, a9 as SubagentConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ab as SubagentFnResult, a6 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, al as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, az as VirtualFileTree, k as TreeMutation, s as FileEntry, aA as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, aq as ToolHandler, aC as WorkflowTask, d as ActivityToolHandler } from './types-Cn2r3ol3.cjs';
|
|
2
2
|
import { g as SandboxOps } from './types-yx0LzPGn.cjs';
|
|
3
3
|
import z$1, { z } from 'zod';
|
|
4
4
|
import { Sinks, proxyActivities } from '@temporalio/workflow';
|
|
@@ -97,6 +97,68 @@ declare function defineWorkflow<TInput, TResult>(config: WorkflowConfig, fn: (in
|
|
|
97
97
|
*/
|
|
98
98
|
declare function getShortId(length?: number): string;
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Public helpers for zeitlich's Redis thread storage layout.
|
|
102
|
+
*
|
|
103
|
+
* These are the exact string-building primitives zeitlich's internal thread
|
|
104
|
+
* manager uses for every adapter. Downstream consumers that need to read a
|
|
105
|
+
* persisted thread (for evaluation, observability, admin tooling, etc.)
|
|
106
|
+
* should use these helpers rather than reconstructing the key layout by
|
|
107
|
+
* hand — the layout is versioned with this module, so upgrading zeitlich
|
|
108
|
+
* keeps the consumer in sync.
|
|
109
|
+
*
|
|
110
|
+
* The layout is adapter-agnostic: every thread adapter stores messages the
|
|
111
|
+
* same way.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* import {
|
|
116
|
+
* getThreadListKey,
|
|
117
|
+
* getThreadMetaKey,
|
|
118
|
+
* THREAD_TTL_SECONDS,
|
|
119
|
+
* } from 'zeitlich';
|
|
120
|
+
*
|
|
121
|
+
* const listKey = getThreadListKey('messages', threadId);
|
|
122
|
+
* const metaKey = getThreadMetaKey('messages', threadId);
|
|
123
|
+
* const ttl = await redis.ttl(listKey); // <= THREAD_TTL_SECONDS
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* TTL (in seconds) applied to every thread list and thread meta key that
|
|
128
|
+
* zeitlich's {@link createThreadManager} writes. Exposed so downstream
|
|
129
|
+
* consumers can size their Redis retention / query windows to match.
|
|
130
|
+
*
|
|
131
|
+
* Current value: 90 days.
|
|
132
|
+
*/
|
|
133
|
+
declare const THREAD_TTL_SECONDS: number;
|
|
134
|
+
/**
|
|
135
|
+
* Build the Redis list key that holds a thread's serialized messages.
|
|
136
|
+
*
|
|
137
|
+
* Mirrors the exact key used internally by zeitlich's thread manager,
|
|
138
|
+
* so a consumer calling `redis.lrange(getThreadListKey(key, id), 0, -1)`
|
|
139
|
+
* sees the same data the writer wrote.
|
|
140
|
+
*
|
|
141
|
+
* @param threadKey - Thread key (defaults to `"messages"` inside the
|
|
142
|
+
* thread manager, but downstream adapters may pass
|
|
143
|
+
* their own value).
|
|
144
|
+
* @param threadId - Thread id as provided to the thread manager.
|
|
145
|
+
*/
|
|
146
|
+
declare function getThreadListKey(threadKey: string, threadId: string): string;
|
|
147
|
+
/**
|
|
148
|
+
* Build the Redis key that stores a thread's existence marker / metadata.
|
|
149
|
+
*
|
|
150
|
+
* Zeitlich treats the presence of this key as "thread has been
|
|
151
|
+
* initialized"; append/load/fork/truncate operations fail when it is
|
|
152
|
+
* missing. Consumers can use it as a cheap existence probe without
|
|
153
|
+
* scanning the message list.
|
|
154
|
+
*
|
|
155
|
+
* @param threadKey - Thread key (defaults to `"messages"` inside the
|
|
156
|
+
* thread manager, but downstream adapters may pass
|
|
157
|
+
* their own value).
|
|
158
|
+
* @param threadId - Thread id as provided to the thread manager.
|
|
159
|
+
*/
|
|
160
|
+
declare function getThreadMetaKey(threadKey: string, threadId: string): string;
|
|
161
|
+
|
|
100
162
|
/**
|
|
101
163
|
* Creates an agent state manager for tracking workflow state.
|
|
102
164
|
* Automatically registers Temporal query and update handlers for the agent.
|
|
@@ -194,6 +256,22 @@ type SubagentArgs = {
|
|
|
194
256
|
threadId?: string | null;
|
|
195
257
|
};
|
|
196
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Default `workflowRunTimeout` applied to every subagent child workflow
|
|
261
|
+
* unless overridden via `SubagentConfig.workflowOptions.workflowRunTimeout`.
|
|
262
|
+
*
|
|
263
|
+
* Chosen as a safety bound: Temporal retries failing workflow tasks forever
|
|
264
|
+
* by default, so a child that fails to initialize (e.g. missing workflow
|
|
265
|
+
* export) or is otherwise broken will never reach a terminal state on its
|
|
266
|
+
* own and the parent's `Subagent` tool call would hang indefinitely. A
|
|
267
|
+
* bounded run timeout guarantees the child is eventually terminated and the
|
|
268
|
+
* parent receives a structured `ChildWorkflowFailure` it can surface to the
|
|
269
|
+
* agent. One hour is generous enough for realistic agent sessions while
|
|
270
|
+
* still catching hangs; agents that legitimately need longer should set an
|
|
271
|
+
* explicit `workflowOptions.workflowRunTimeout`.
|
|
272
|
+
*/
|
|
273
|
+
declare const DEFAULT_SUBAGENT_WORKFLOW_RUN_TIMEOUT = "1h";
|
|
274
|
+
|
|
197
275
|
/**
|
|
198
276
|
* Creates a `SubagentConfig` from a `SubagentDefinition` (returned by `defineSubagentWorkflow`).
|
|
199
277
|
* Metadata (name, description, resultSchema) is read from the definition — only configure
|
|
@@ -264,6 +342,8 @@ declare function defineSubagent<TResult extends z.ZodType = z.ZodType, TContext
|
|
|
264
342
|
* });
|
|
265
343
|
*
|
|
266
344
|
* const { finalMessage, threadId } = await session.runSession({ stateManager });
|
|
345
|
+
* // `sandboxId`, `snapshot`, and `baseSnapshot` are auto-forwarded
|
|
346
|
+
* // from the session — no need to thread them through manually.
|
|
267
347
|
* return { toolResponse: finalMessage ?? "No response", data: null, threadId };
|
|
268
348
|
* },
|
|
269
349
|
* );
|
|
@@ -775,4 +855,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
|
|
|
775
855
|
}[];
|
|
776
856
|
}>;
|
|
777
857
|
|
|
778
|
-
export {
|
|
858
|
+
export { hasDirectory as $, type AskUserQuestionArgs as A, type BashArgs as B, createTaskGetHandler as C, DEFAULT_SUBAGENT_WORKFLOW_RUN_TIMEOUT as D, createTaskListHandler as E, type FileEditArgs as F, type GlobArgs as G, createTaskUpdateHandler as H, createToolRouter as I, defineSubagent as J, defineSubagentWorkflow as K, defineTool as L, defineWorkflow as M, editTool as N, type ObservabilityHooks as O, filesWithMimeType as P, formatVirtualFileTree as Q, type ReadSkillArgs as R, type SessionEndedEvent as S, THREAD_TTL_SECONDS as T, getShortId as U, getThreadListKey as V, type WorkflowConfig as W, getThreadMetaKey as X, globTool as Y, type ZeitlichObservabilitySinks as Z, grepTool as _, type FileReadArgs as a, hasFileWithMimeType as a0, hasNoOtherToolCalls as a1, parseSkillFile as a2, proxyRunAgent as a3, proxyVirtualFsOps as a4, readFileTool as a5, taskCreateTool as a6, taskGetTool as a7, taskListTool as a8, taskUpdateTool as a9, writeFileTool as aa, type FileWriteArgs as b, type FileTreeAccessor as c, type GrepArgs as d, type SessionStartedEvent as e, type SubagentArgs as f, type TaskCreateArgs as g, type TaskGetArgs as h, type TaskListArgs as i, type TaskUpdateArgs as j, type ToolExecutedEvent as k, type TurnCompletedEvent as l, type WorkflowInput as m, type WorkflowSessionInput as n, applyVirtualTreeMutations as o, askUserQuestionTool as p, bashTool as q, composeHooks as r, createAgentStateManager as s, createAskUserQuestionHandler as t, createBashToolDescription as u, createObservabilityHooks as v, createReadSkillHandler as w, createReadSkillTool as x, createSession as y, createTaskCreateHandler as z };
|