zeitlich 0.2.37 → 0.2.39
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-Bb-nAjwQ.d.ts → activities-Bmu7XnaG.d.ts} +4 -4
- package/dist/{activities-vkI4_3CC.d.cts → activities-ByBFLvm2.d.cts} +4 -4
- 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/sandbox/bedrock/index.cjs +3 -3
- package/dist/adapters/sandbox/bedrock/index.cjs.map +1 -1
- package/dist/adapters/sandbox/bedrock/index.d.cts +6 -6
- package/dist/adapters/sandbox/bedrock/index.d.ts +6 -6
- package/dist/adapters/sandbox/bedrock/index.js +3 -3
- package/dist/adapters/sandbox/bedrock/index.js.map +1 -1
- package/dist/adapters/sandbox/bedrock/workflow.d.cts +2 -2
- package/dist/adapters/sandbox/bedrock/workflow.d.ts +2 -2
- package/dist/adapters/sandbox/daytona/index.cjs +3 -3
- package/dist/adapters/sandbox/daytona/index.cjs.map +1 -1
- package/dist/adapters/sandbox/daytona/index.d.cts +4 -4
- package/dist/adapters/sandbox/daytona/index.d.ts +4 -4
- package/dist/adapters/sandbox/daytona/index.js +3 -3
- package/dist/adapters/sandbox/daytona/index.js.map +1 -1
- package/dist/adapters/sandbox/daytona/workflow.d.cts +1 -1
- package/dist/adapters/sandbox/daytona/workflow.d.ts +1 -1
- package/dist/adapters/sandbox/e2b/index.cjs +26 -14
- package/dist/adapters/sandbox/e2b/index.cjs.map +1 -1
- package/dist/adapters/sandbox/e2b/index.d.cts +24 -4
- package/dist/adapters/sandbox/e2b/index.d.ts +24 -4
- package/dist/adapters/sandbox/e2b/index.js +26 -14
- package/dist/adapters/sandbox/e2b/index.js.map +1 -1
- package/dist/adapters/sandbox/e2b/workflow.d.cts +1 -1
- package/dist/adapters/sandbox/e2b/workflow.d.ts +1 -1
- package/dist/adapters/sandbox/inmemory/index.cjs +3 -3
- package/dist/adapters/sandbox/inmemory/index.cjs.map +1 -1
- package/dist/adapters/sandbox/inmemory/index.d.cts +4 -4
- package/dist/adapters/sandbox/inmemory/index.d.ts +4 -4
- package/dist/adapters/sandbox/inmemory/index.js +3 -3
- package/dist/adapters/sandbox/inmemory/index.js.map +1 -1
- package/dist/adapters/sandbox/inmemory/workflow.d.cts +1 -1
- package/dist/adapters/sandbox/inmemory/workflow.d.ts +1 -1
- package/dist/adapters/thread/anthropic/index.cjs +150 -13
- package/dist/adapters/thread/anthropic/index.cjs.map +1 -1
- package/dist/adapters/thread/anthropic/index.d.cts +9 -8
- package/dist/adapters/thread/anthropic/index.d.ts +9 -8
- package/dist/adapters/thread/anthropic/index.js +150 -14
- package/dist/adapters/thread/anthropic/index.js.map +1 -1
- package/dist/adapters/thread/anthropic/workflow.cjs +9 -3
- package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -1
- package/dist/adapters/thread/anthropic/workflow.d.cts +6 -5
- package/dist/adapters/thread/anthropic/workflow.d.ts +6 -5
- package/dist/adapters/thread/anthropic/workflow.js +9 -4
- package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
- package/dist/adapters/thread/google-genai/index.cjs +154 -13
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +6 -5
- package/dist/adapters/thread/google-genai/index.d.ts +6 -5
- package/dist/adapters/thread/google-genai/index.js +154 -14
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.cjs +9 -3
- package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.d.cts +6 -5
- package/dist/adapters/thread/google-genai/workflow.d.ts +6 -5
- package/dist/adapters/thread/google-genai/workflow.js +9 -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 +149 -14
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +9 -8
- package/dist/adapters/thread/langchain/index.d.ts +9 -8
- package/dist/adapters/thread/langchain/index.js +149 -15
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/adapters/thread/langchain/workflow.cjs +9 -3
- package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
- package/dist/adapters/thread/langchain/workflow.d.cts +6 -5
- package/dist/adapters/thread/langchain/workflow.d.ts +6 -5
- package/dist/adapters/thread/langchain/workflow.js +9 -4
- package/dist/adapters/thread/langchain/workflow.js.map +1 -1
- package/dist/index.cjs +367 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +365 -61
- package/dist/index.js.map +1 -1
- package/dist/{proxy-DEtowJyd.d.cts → proxy-BAKzNGRq.d.cts} +1 -1
- package/dist/{proxy-0smGKvx8.d.ts → proxy-DO_MXbY4.d.ts} +1 -1
- package/dist/{thread-manager-C-C4pI2z.d.ts → thread-manager-CcRXasqs.d.ts} +2 -2
- package/dist/{thread-manager-D4vgzYrh.d.cts → thread-manager-ClwSaUnj.d.cts} +2 -2
- package/dist/{thread-manager-3fszQih4.d.ts → thread-manager-D-7lp1JK.d.ts} +2 -2
- package/dist/{thread-manager-CzYln2OC.d.cts → thread-manager-Y8Ucf0Tf.d.cts} +2 -2
- package/dist/{types-CPKDl-y_.d.ts → types-Bcbiq8iv.d.cts} +195 -22
- package/dist/{types-CNuWnvy9.d.ts → types-DAsQ21Rt.d.ts} +1 -1
- package/dist/{types-B37hKoWA.d.ts → types-DpHTX-iO.d.ts} +58 -1
- package/dist/{types-BO7Yju20.d.cts → types-Dt8-HBBT.d.ts} +195 -22
- package/dist/{types-D08CXPh8.d.cts → types-hFFi-Zd9.d.cts} +58 -1
- package/dist/{types-DWEUmYAJ.d.cts → types-lm8tMNJQ.d.cts} +1 -1
- package/dist/{types-tQL9njTu.d.cts → types-yx0LzPGn.d.cts} +21 -7
- package/dist/{types-tQL9njTu.d.ts → types-yx0LzPGn.d.ts} +21 -7
- package/dist/{workflow-CjXHbZZc.d.ts → workflow-Bmf9EtDW.d.ts} +83 -3
- package/dist/{workflow-Do_lzJpT.d.cts → workflow-Bx9utBwb.d.cts} +83 -3
- package/dist/workflow.cjs +266 -39
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +3 -3
- package/dist/workflow.d.ts +3 -3
- package/dist/workflow.js +264 -41
- package/dist/workflow.js.map +1 -1
- package/package.json +12 -2
- package/src/adapters/sandbox/bedrock/index.ts +12 -3
- package/src/adapters/sandbox/daytona/index.ts +12 -3
- package/src/adapters/sandbox/e2b/index.ts +36 -14
- package/src/adapters/sandbox/e2b/types.ts +16 -0
- package/src/adapters/sandbox/inmemory/index.ts +12 -3
- package/src/adapters/thread/adapter-id.test.ts +42 -0
- package/src/adapters/thread/anthropic/activities.ts +40 -5
- 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 +7 -1
- package/src/adapters/thread/anthropic/proxy.ts +3 -2
- package/src/adapters/thread/anthropic/thread-manager.ts +27 -1
- package/src/adapters/thread/google-genai/activities.ts +44 -5
- 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 +8 -2
- package/src/adapters/thread/google-genai/proxy.ts +3 -2
- package/src/adapters/thread/google-genai/thread-manager.ts +27 -1
- package/src/adapters/thread/index.ts +39 -0
- package/src/adapters/thread/langchain/activities.ts +40 -5
- 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 +7 -1
- package/src/adapters/thread/langchain/proxy.ts +3 -2
- package/src/adapters/thread/langchain/thread-manager.ts +27 -1
- package/src/lib/lifecycle.ts +14 -5
- package/src/lib/model/types.ts +7 -0
- package/src/lib/sandbox/manager.ts +26 -18
- package/src/lib/sandbox/types.ts +27 -7
- package/src/lib/session/session-edge-cases.integration.test.ts +336 -4
- package/src/lib/session/session.integration.test.ts +192 -2
- package/src/lib/session/session.ts +102 -8
- package/src/lib/session/types.ts +66 -3
- 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 +628 -104
- 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 +105 -9
- package/src/lib/thread/proxy.ts +3 -0
- package/src/lib/thread/types.ts +64 -1
- package/src/lib/tool-router/index.ts +2 -0
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +92 -0
- package/src/lib/tool-router/router.integration.test.ts +12 -0
- package/src/lib/tool-router/router.ts +89 -16
- package/src/lib/tool-router/types.ts +42 -1
- package/src/lib/types.ts +12 -0
- package/src/workflow.ts +14 -1
- package/tsup.config.ts +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { g as SandboxOps } from './types-
|
|
1
|
+
import { as as ToolMap, a1 as SessionConfig, aD as ZeitlichSession, $ as SandboxShutdown, ak as ThreadInit, _ as SandboxInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aF as ToolRouterOptions, av as ToolRouter, R as RouterContext, J as JsonValue, ax as ToolWithHandler, w as ParsedToolCallUnion, at as ToolNames, aa as SubagentDefinition, ad as SubagentHooks, ae as SubagentSandboxConfig, a9 as SubagentConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ab as SubagentFnResult, a6 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, al as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, az as VirtualFileTree, k as TreeMutation, s as FileEntry, aA as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, aq as ToolHandler, aC as WorkflowTask, d as ActivityToolHandler } from './types-Dt8-HBBT.js';
|
|
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';
|
|
5
5
|
|
|
@@ -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,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { g as SandboxOps } from './types-
|
|
1
|
+
import { as as ToolMap, a1 as SessionConfig, aD as ZeitlichSession, $ as SandboxShutdown, ak as ThreadInit, _ as SandboxInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aF as ToolRouterOptions, av as ToolRouter, R as RouterContext, J as JsonValue, ax as ToolWithHandler, w as ParsedToolCallUnion, at as ToolNames, aa as SubagentDefinition, ad as SubagentHooks, ae as SubagentSandboxConfig, a9 as SubagentConfig, af as SubagentSandboxShutdown, ag as SubagentSessionInput, ab as SubagentFnResult, a6 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, al as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, az as VirtualFileTree, k as TreeMutation, s as FileEntry, aA as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, aq as ToolHandler, aC as WorkflowTask, d as ActivityToolHandler } from './types-Bcbiq8iv.cjs';
|
|
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';
|
|
5
5
|
|
|
@@ -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 };
|