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.
Files changed (172) hide show
  1. package/README.md +18 -0
  2. package/dist/{activities-Bb-nAjwQ.d.ts → activities-Bmu7XnaG.d.ts} +4 -4
  3. package/dist/{activities-vkI4_3CC.d.cts → activities-ByBFLvm2.d.cts} +4 -4
  4. package/dist/adapter-id-BB-mmrts.d.cts +17 -0
  5. package/dist/adapter-id-BB-mmrts.d.ts +17 -0
  6. package/dist/adapter-id-CMwVrVqv.d.cts +17 -0
  7. package/dist/adapter-id-CMwVrVqv.d.ts +17 -0
  8. package/dist/adapter-id-CbY2zeSt.d.cts +17 -0
  9. package/dist/adapter-id-CbY2zeSt.d.ts +17 -0
  10. package/dist/adapters/sandbox/bedrock/index.cjs +3 -3
  11. package/dist/adapters/sandbox/bedrock/index.cjs.map +1 -1
  12. package/dist/adapters/sandbox/bedrock/index.d.cts +6 -6
  13. package/dist/adapters/sandbox/bedrock/index.d.ts +6 -6
  14. package/dist/adapters/sandbox/bedrock/index.js +3 -3
  15. package/dist/adapters/sandbox/bedrock/index.js.map +1 -1
  16. package/dist/adapters/sandbox/bedrock/workflow.d.cts +2 -2
  17. package/dist/adapters/sandbox/bedrock/workflow.d.ts +2 -2
  18. package/dist/adapters/sandbox/daytona/index.cjs +3 -3
  19. package/dist/adapters/sandbox/daytona/index.cjs.map +1 -1
  20. package/dist/adapters/sandbox/daytona/index.d.cts +4 -4
  21. package/dist/adapters/sandbox/daytona/index.d.ts +4 -4
  22. package/dist/adapters/sandbox/daytona/index.js +3 -3
  23. package/dist/adapters/sandbox/daytona/index.js.map +1 -1
  24. package/dist/adapters/sandbox/daytona/workflow.d.cts +1 -1
  25. package/dist/adapters/sandbox/daytona/workflow.d.ts +1 -1
  26. package/dist/adapters/sandbox/e2b/index.cjs +26 -14
  27. package/dist/adapters/sandbox/e2b/index.cjs.map +1 -1
  28. package/dist/adapters/sandbox/e2b/index.d.cts +24 -4
  29. package/dist/adapters/sandbox/e2b/index.d.ts +24 -4
  30. package/dist/adapters/sandbox/e2b/index.js +26 -14
  31. package/dist/adapters/sandbox/e2b/index.js.map +1 -1
  32. package/dist/adapters/sandbox/e2b/workflow.d.cts +1 -1
  33. package/dist/adapters/sandbox/e2b/workflow.d.ts +1 -1
  34. package/dist/adapters/sandbox/inmemory/index.cjs +3 -3
  35. package/dist/adapters/sandbox/inmemory/index.cjs.map +1 -1
  36. package/dist/adapters/sandbox/inmemory/index.d.cts +4 -4
  37. package/dist/adapters/sandbox/inmemory/index.d.ts +4 -4
  38. package/dist/adapters/sandbox/inmemory/index.js +3 -3
  39. package/dist/adapters/sandbox/inmemory/index.js.map +1 -1
  40. package/dist/adapters/sandbox/inmemory/workflow.d.cts +1 -1
  41. package/dist/adapters/sandbox/inmemory/workflow.d.ts +1 -1
  42. package/dist/adapters/thread/anthropic/index.cjs +150 -13
  43. package/dist/adapters/thread/anthropic/index.cjs.map +1 -1
  44. package/dist/adapters/thread/anthropic/index.d.cts +9 -8
  45. package/dist/adapters/thread/anthropic/index.d.ts +9 -8
  46. package/dist/adapters/thread/anthropic/index.js +150 -14
  47. package/dist/adapters/thread/anthropic/index.js.map +1 -1
  48. package/dist/adapters/thread/anthropic/workflow.cjs +9 -3
  49. package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -1
  50. package/dist/adapters/thread/anthropic/workflow.d.cts +6 -5
  51. package/dist/adapters/thread/anthropic/workflow.d.ts +6 -5
  52. package/dist/adapters/thread/anthropic/workflow.js +9 -4
  53. package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
  54. package/dist/adapters/thread/google-genai/index.cjs +154 -13
  55. package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
  56. package/dist/adapters/thread/google-genai/index.d.cts +6 -5
  57. package/dist/adapters/thread/google-genai/index.d.ts +6 -5
  58. package/dist/adapters/thread/google-genai/index.js +154 -14
  59. package/dist/adapters/thread/google-genai/index.js.map +1 -1
  60. package/dist/adapters/thread/google-genai/workflow.cjs +9 -3
  61. package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
  62. package/dist/adapters/thread/google-genai/workflow.d.cts +6 -5
  63. package/dist/adapters/thread/google-genai/workflow.d.ts +6 -5
  64. package/dist/adapters/thread/google-genai/workflow.js +9 -4
  65. package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
  66. package/dist/adapters/thread/index.cjs +16 -0
  67. package/dist/adapters/thread/index.cjs.map +1 -0
  68. package/dist/adapters/thread/index.d.cts +34 -0
  69. package/dist/adapters/thread/index.d.ts +34 -0
  70. package/dist/adapters/thread/index.js +12 -0
  71. package/dist/adapters/thread/index.js.map +1 -0
  72. package/dist/adapters/thread/langchain/index.cjs +149 -14
  73. package/dist/adapters/thread/langchain/index.cjs.map +1 -1
  74. package/dist/adapters/thread/langchain/index.d.cts +9 -8
  75. package/dist/adapters/thread/langchain/index.d.ts +9 -8
  76. package/dist/adapters/thread/langchain/index.js +149 -15
  77. package/dist/adapters/thread/langchain/index.js.map +1 -1
  78. package/dist/adapters/thread/langchain/workflow.cjs +9 -3
  79. package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
  80. package/dist/adapters/thread/langchain/workflow.d.cts +6 -5
  81. package/dist/adapters/thread/langchain/workflow.d.ts +6 -5
  82. package/dist/adapters/thread/langchain/workflow.js +9 -4
  83. package/dist/adapters/thread/langchain/workflow.js.map +1 -1
  84. package/dist/index.cjs +367 -59
  85. package/dist/index.cjs.map +1 -1
  86. package/dist/index.d.cts +11 -11
  87. package/dist/index.d.ts +11 -11
  88. package/dist/index.js +365 -61
  89. package/dist/index.js.map +1 -1
  90. package/dist/{proxy-DEtowJyd.d.cts → proxy-BAKzNGRq.d.cts} +1 -1
  91. package/dist/{proxy-0smGKvx8.d.ts → proxy-DO_MXbY4.d.ts} +1 -1
  92. package/dist/{thread-manager-C-C4pI2z.d.ts → thread-manager-CcRXasqs.d.ts} +2 -2
  93. package/dist/{thread-manager-D4vgzYrh.d.cts → thread-manager-ClwSaUnj.d.cts} +2 -2
  94. package/dist/{thread-manager-3fszQih4.d.ts → thread-manager-D-7lp1JK.d.ts} +2 -2
  95. package/dist/{thread-manager-CzYln2OC.d.cts → thread-manager-Y8Ucf0Tf.d.cts} +2 -2
  96. package/dist/{types-CPKDl-y_.d.ts → types-Bcbiq8iv.d.cts} +195 -22
  97. package/dist/{types-CNuWnvy9.d.ts → types-DAsQ21Rt.d.ts} +1 -1
  98. package/dist/{types-B37hKoWA.d.ts → types-DpHTX-iO.d.ts} +58 -1
  99. package/dist/{types-BO7Yju20.d.cts → types-Dt8-HBBT.d.ts} +195 -22
  100. package/dist/{types-D08CXPh8.d.cts → types-hFFi-Zd9.d.cts} +58 -1
  101. package/dist/{types-DWEUmYAJ.d.cts → types-lm8tMNJQ.d.cts} +1 -1
  102. package/dist/{types-tQL9njTu.d.cts → types-yx0LzPGn.d.cts} +21 -7
  103. package/dist/{types-tQL9njTu.d.ts → types-yx0LzPGn.d.ts} +21 -7
  104. package/dist/{workflow-CjXHbZZc.d.ts → workflow-Bmf9EtDW.d.ts} +83 -3
  105. package/dist/{workflow-Do_lzJpT.d.cts → workflow-Bx9utBwb.d.cts} +83 -3
  106. package/dist/workflow.cjs +266 -39
  107. package/dist/workflow.cjs.map +1 -1
  108. package/dist/workflow.d.cts +3 -3
  109. package/dist/workflow.d.ts +3 -3
  110. package/dist/workflow.js +264 -41
  111. package/dist/workflow.js.map +1 -1
  112. package/package.json +12 -2
  113. package/src/adapters/sandbox/bedrock/index.ts +12 -3
  114. package/src/adapters/sandbox/daytona/index.ts +12 -3
  115. package/src/adapters/sandbox/e2b/index.ts +36 -14
  116. package/src/adapters/sandbox/e2b/types.ts +16 -0
  117. package/src/adapters/sandbox/inmemory/index.ts +12 -3
  118. package/src/adapters/thread/adapter-id.test.ts +42 -0
  119. package/src/adapters/thread/anthropic/activities.ts +40 -5
  120. package/src/adapters/thread/anthropic/adapter-id.ts +16 -0
  121. package/src/adapters/thread/anthropic/fork-transform.test.ts +291 -0
  122. package/src/adapters/thread/anthropic/index.ts +3 -0
  123. package/src/adapters/thread/anthropic/model-invoker.ts +7 -1
  124. package/src/adapters/thread/anthropic/proxy.ts +3 -2
  125. package/src/adapters/thread/anthropic/thread-manager.ts +27 -1
  126. package/src/adapters/thread/google-genai/activities.ts +44 -5
  127. package/src/adapters/thread/google-genai/adapter-id.ts +16 -0
  128. package/src/adapters/thread/google-genai/fork-transform.test.ts +149 -0
  129. package/src/adapters/thread/google-genai/index.ts +3 -0
  130. package/src/adapters/thread/google-genai/model-invoker.ts +8 -2
  131. package/src/adapters/thread/google-genai/proxy.ts +3 -2
  132. package/src/adapters/thread/google-genai/thread-manager.ts +27 -1
  133. package/src/adapters/thread/index.ts +39 -0
  134. package/src/adapters/thread/langchain/activities.ts +40 -5
  135. package/src/adapters/thread/langchain/adapter-id.ts +16 -0
  136. package/src/adapters/thread/langchain/fork-transform.test.ts +142 -0
  137. package/src/adapters/thread/langchain/index.ts +3 -0
  138. package/src/adapters/thread/langchain/model-invoker.ts +7 -1
  139. package/src/adapters/thread/langchain/proxy.ts +3 -2
  140. package/src/adapters/thread/langchain/thread-manager.ts +27 -1
  141. package/src/lib/lifecycle.ts +14 -5
  142. package/src/lib/model/types.ts +7 -0
  143. package/src/lib/sandbox/manager.ts +26 -18
  144. package/src/lib/sandbox/types.ts +27 -7
  145. package/src/lib/session/session-edge-cases.integration.test.ts +336 -4
  146. package/src/lib/session/session.integration.test.ts +192 -2
  147. package/src/lib/session/session.ts +102 -8
  148. package/src/lib/session/types.ts +66 -3
  149. package/src/lib/state/index.ts +1 -0
  150. package/src/lib/state/manager.integration.test.ts +109 -0
  151. package/src/lib/state/manager.ts +38 -8
  152. package/src/lib/state/types.ts +25 -0
  153. package/src/lib/subagent/handler.ts +124 -11
  154. package/src/lib/subagent/index.ts +5 -1
  155. package/src/lib/subagent/subagent.integration.test.ts +628 -104
  156. package/src/lib/subagent/types.ts +63 -14
  157. package/src/lib/subagent/workflow.ts +29 -2
  158. package/src/lib/thread/index.ts +5 -0
  159. package/src/lib/thread/keys.test.ts +101 -0
  160. package/src/lib/thread/keys.ts +94 -0
  161. package/src/lib/thread/manager.test.ts +139 -0
  162. package/src/lib/thread/manager.ts +105 -9
  163. package/src/lib/thread/proxy.ts +3 -0
  164. package/src/lib/thread/types.ts +64 -1
  165. package/src/lib/tool-router/index.ts +2 -0
  166. package/src/lib/tool-router/router-edge-cases.integration.test.ts +92 -0
  167. package/src/lib/tool-router/router.integration.test.ts +12 -0
  168. package/src/lib/tool-router/router.ts +89 -16
  169. package/src/lib/tool-router/types.ts +42 -1
  170. package/src/lib/types.ts +12 -0
  171. package/src/workflow.ts +14 -1
  172. package/tsup.config.ts +1 -0
@@ -1,5 +1,5 @@
1
- import { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, e as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-CPKDl-y_.js';
2
- import { g as SandboxOps } from './types-tQL9njTu.js';
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 { proxyRunAgent as $, type AskUserQuestionArgs as A, type BashArgs as B, createTaskListHandler as C, createTaskUpdateHandler as D, createToolRouter as E, type FileEditArgs as F, type GlobArgs as G, defineSubagent as H, defineSubagentWorkflow as I, defineTool as J, defineWorkflow as K, editTool as L, filesWithMimeType as M, formatVirtualFileTree as N, type ObservabilityHooks as O, getShortId as P, globTool as Q, type ReadSkillArgs as R, type SessionEndedEvent as S, type TaskCreateArgs as T, grepTool as U, hasDirectory as V, type WorkflowConfig as W, hasFileWithMimeType as X, hasNoOtherToolCalls as Y, type ZeitlichObservabilitySinks as Z, parseSkillFile as _, type FileReadArgs as a, proxyVirtualFsOps as a0, readFileTool as a1, taskCreateTool as a2, taskGetTool as a3, taskListTool as a4, taskUpdateTool as a5, writeFileTool as a6, type FileWriteArgs as b, type FileTreeAccessor as c, type GrepArgs as d, type SessionStartedEvent as e, type SubagentArgs as f, type TaskGetArgs as g, type TaskListArgs as h, type TaskUpdateArgs as i, type ToolExecutedEvent as j, type TurnCompletedEvent as k, type WorkflowInput as l, type WorkflowSessionInput as m, applyVirtualTreeMutations as n, askUserQuestionTool as o, bashTool as p, composeHooks as q, createAgentStateManager as r, createAskUserQuestionHandler as s, createBashToolDescription as t, createObservabilityHooks as u, createReadSkillHandler as v, createReadSkillTool as w, createSession as x, createTaskCreateHandler as y, createTaskGetHandler as z };
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 { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, e as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-BO7Yju20.cjs';
2
- import { g as SandboxOps } from './types-tQL9njTu.cjs';
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 { proxyRunAgent as $, type AskUserQuestionArgs as A, type BashArgs as B, createTaskListHandler as C, createTaskUpdateHandler as D, createToolRouter as E, type FileEditArgs as F, type GlobArgs as G, defineSubagent as H, defineSubagentWorkflow as I, defineTool as J, defineWorkflow as K, editTool as L, filesWithMimeType as M, formatVirtualFileTree as N, type ObservabilityHooks as O, getShortId as P, globTool as Q, type ReadSkillArgs as R, type SessionEndedEvent as S, type TaskCreateArgs as T, grepTool as U, hasDirectory as V, type WorkflowConfig as W, hasFileWithMimeType as X, hasNoOtherToolCalls as Y, type ZeitlichObservabilitySinks as Z, parseSkillFile as _, type FileReadArgs as a, proxyVirtualFsOps as a0, readFileTool as a1, taskCreateTool as a2, taskGetTool as a3, taskListTool as a4, taskUpdateTool as a5, writeFileTool as a6, type FileWriteArgs as b, type FileTreeAccessor as c, type GrepArgs as d, type SessionStartedEvent as e, type SubagentArgs as f, type TaskGetArgs as g, type TaskListArgs as h, type TaskUpdateArgs as i, type ToolExecutedEvent as j, type TurnCompletedEvent as k, type WorkflowInput as l, type WorkflowSessionInput as m, applyVirtualTreeMutations as n, askUserQuestionTool as o, bashTool as p, composeHooks as q, createAgentStateManager as r, createAskUserQuestionHandler as s, createBashToolDescription as t, createObservabilityHooks as u, createReadSkillHandler as v, createReadSkillTool as w, createSession as x, createTaskCreateHandler as y, createTaskGetHandler as z };
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 };