zeitlich 0.2.46 → 0.2.47

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 (83) hide show
  1. package/README.md +64 -6
  2. package/dist/{activities-CyeiqK_f.d.cts → activities-CPwKoUlD.d.cts} +3 -3
  3. package/dist/{activities-Bm4TLTid.d.ts → activities-DlaBxNID.d.ts} +3 -3
  4. package/dist/adapters/thread/anthropic/index.cjs +105 -6
  5. package/dist/adapters/thread/anthropic/index.cjs.map +1 -1
  6. package/dist/adapters/thread/anthropic/index.d.cts +48 -9
  7. package/dist/adapters/thread/anthropic/index.d.ts +48 -9
  8. package/dist/adapters/thread/anthropic/index.js +104 -7
  9. package/dist/adapters/thread/anthropic/index.js.map +1 -1
  10. package/dist/adapters/thread/anthropic/workflow.cjs +38 -22
  11. package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -1
  12. package/dist/adapters/thread/anthropic/workflow.d.cts +5 -4
  13. package/dist/adapters/thread/anthropic/workflow.d.ts +5 -4
  14. package/dist/adapters/thread/anthropic/workflow.js +38 -22
  15. package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
  16. package/dist/adapters/thread/google-genai/index.d.cts +6 -5
  17. package/dist/adapters/thread/google-genai/index.d.ts +6 -5
  18. package/dist/adapters/thread/google-genai/workflow.cjs +38 -22
  19. package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
  20. package/dist/adapters/thread/google-genai/workflow.d.cts +7 -5
  21. package/dist/adapters/thread/google-genai/workflow.d.ts +7 -5
  22. package/dist/adapters/thread/google-genai/workflow.js +38 -22
  23. package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
  24. package/dist/adapters/thread/langchain/index.d.cts +6 -5
  25. package/dist/adapters/thread/langchain/index.d.ts +6 -5
  26. package/dist/adapters/thread/langchain/workflow.cjs +38 -22
  27. package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
  28. package/dist/adapters/thread/langchain/workflow.d.cts +5 -4
  29. package/dist/adapters/thread/langchain/workflow.d.ts +5 -4
  30. package/dist/adapters/thread/langchain/workflow.js +38 -22
  31. package/dist/adapters/thread/langchain/workflow.js.map +1 -1
  32. package/dist/{cold-store-CFHwemBJ.d.ts → cold-store-BDgJpwLI.d.ts} +8 -11
  33. package/dist/{cold-store-BC5L5Z8A.d.cts → cold-store-Z2wvK2cV.d.cts} +8 -11
  34. package/dist/index.cjs +264 -90
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +21 -9
  37. package/dist/index.d.ts +21 -9
  38. package/dist/index.js +265 -93
  39. package/dist/index.js.map +1 -1
  40. package/dist/proxy-CDh3Rsa7.d.cts +40 -0
  41. package/dist/proxy-Du8ggERu.d.ts +40 -0
  42. package/dist/{thread-manager-D33SUmZa.d.cts → thread-manager-BjoYYXgd.d.cts} +2 -2
  43. package/dist/{thread-manager-9tezUcLW.d.cts → thread-manager-D8zKNFZ9.d.cts} +2 -2
  44. package/dist/{thread-manager-B-zy3xrs.d.ts → thread-manager-DtHYws2F.d.ts} +2 -2
  45. package/dist/{thread-manager-DduoSkvJ.d.ts → thread-manager-Dw96FKH1.d.ts} +2 -2
  46. package/dist/{types-oxt8GN97.d.cts → types-BMJrsHo0.d.cts} +1 -1
  47. package/dist/{types-L5bvbF-n.d.ts → types-CtdOquo3.d.ts} +1 -1
  48. package/dist/{types-CnuN9T6t.d.cts → types-DNEl5uxQ.d.cts} +16 -0
  49. package/dist/{types-CwN6_tAL.d.ts → types-qQVZfhoT.d.ts} +16 -0
  50. package/dist/{workflow-DIaIV7L2.d.cts → workflow-BH9ImDGq.d.cts} +17 -2
  51. package/dist/{workflow-B1TOcHbt.d.ts → workflow-Cdw3-RNB.d.ts} +17 -2
  52. package/dist/workflow.cjs +33 -3
  53. package/dist/workflow.cjs.map +1 -1
  54. package/dist/workflow.d.cts +2 -2
  55. package/dist/workflow.d.ts +2 -2
  56. package/dist/workflow.js +33 -4
  57. package/dist/workflow.js.map +1 -1
  58. package/package.json +9 -3
  59. package/src/adapters/thread/anthropic/activities.ts +18 -11
  60. package/src/adapters/thread/anthropic/index.ts +8 -0
  61. package/src/adapters/thread/anthropic/model-invoker.test.ts +110 -0
  62. package/src/adapters/thread/anthropic/model-invoker.ts +26 -5
  63. package/src/adapters/thread/anthropic/prompt-cache.test.ts +134 -0
  64. package/src/adapters/thread/anthropic/prompt-cache.ts +163 -0
  65. package/src/adapters/thread/anthropic/proxy.ts +1 -0
  66. package/src/adapters/thread/google-genai/proxy.ts +1 -0
  67. package/src/adapters/thread/langchain/proxy.ts +1 -0
  68. package/src/index.ts +1 -1
  69. package/src/lib/subagent/define.ts +1 -0
  70. package/src/lib/subagent/handler.ts +11 -2
  71. package/src/lib/subagent/subagent.integration.test.ts +139 -0
  72. package/src/lib/subagent/types.ts +16 -0
  73. package/src/lib/thread/cold-store.test.ts +33 -5
  74. package/src/lib/thread/cold-store.ts +50 -31
  75. package/src/lib/thread/proxy.ts +79 -29
  76. package/src/tools/edit/handler.test.ts +177 -0
  77. package/src/tools/edit/handler.ts +249 -47
  78. package/src/tools/edit/tool.ts +40 -0
  79. package/src/tools/task-create/handler.ts +1 -1
  80. package/src/tools/task-update/handler.ts +1 -1
  81. package/src/workflow.ts +2 -2
  82. package/dist/proxy-BxFyd6cg.d.cts +0 -24
  83. package/dist/proxy-Cskmj4Yx.d.ts +0 -24
@@ -0,0 +1,40 @@
1
+ import { ActivityOptions, ActivityInterfaceFor } from '@temporalio/workflow';
2
+ import { T as ThreadOps } from './types-DNEl5uxQ.cjs';
3
+
4
+ /**
5
+ * Shared proxy helper for thread operations.
6
+ *
7
+ * Each adapter re-exports a thin wrapper that supplies its prefix and
8
+ * casts the return type to carry the adapter's native content type.
9
+ */
10
+
11
+ type OpName = keyof ThreadOps;
12
+ /**
13
+ * `perOp[op]` layers shallow-rightmost over `defaults` and the
14
+ * built-in cold-tier overlay (`hydrateThread` / `flushThread`).
15
+ * A bare {@link ActivityOptions} is also accepted (treated as `{ defaults }`).
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * proxyAnthropicThreadOps(undefined, {
20
+ * defaults: { startToCloseTimeout: "5s" },
21
+ * perOp: {
22
+ * flushThread: { startToCloseTimeout: "180s" }, // heartbeatTimeout still inherited
23
+ * },
24
+ * });
25
+ * ```
26
+ */
27
+ interface ThreadOpsProxyOptions {
28
+ defaults?: ActivityOptions;
29
+ perOp?: Partial<Record<OpName, ActivityOptions>>;
30
+ }
31
+ /**
32
+ * Creates a workflow-safe Temporal activity proxy for {@link ThreadOps}.
33
+ *
34
+ * @param adapterPrefix - Adapter identifier (e.g. "anthropic", "googleGenAI", "langChain")
35
+ * @param scope - Workflow scope. Defaults to `workflowInfo().workflowType`.
36
+ * @param options - {@link ThreadOpsProxyOptions} or a bare {@link ActivityOptions}.
37
+ */
38
+ declare function createThreadOpsProxy(adapterPrefix: string, scope?: string, options?: ActivityOptions | ThreadOpsProxyOptions): ActivityInterfaceFor<ThreadOps>;
39
+
40
+ export { type ThreadOpsProxyOptions as T, createThreadOpsProxy as c };
@@ -0,0 +1,40 @@
1
+ import { ActivityOptions, ActivityInterfaceFor } from '@temporalio/workflow';
2
+ import { T as ThreadOps } from './types-qQVZfhoT.js';
3
+
4
+ /**
5
+ * Shared proxy helper for thread operations.
6
+ *
7
+ * Each adapter re-exports a thin wrapper that supplies its prefix and
8
+ * casts the return type to carry the adapter's native content type.
9
+ */
10
+
11
+ type OpName = keyof ThreadOps;
12
+ /**
13
+ * `perOp[op]` layers shallow-rightmost over `defaults` and the
14
+ * built-in cold-tier overlay (`hydrateThread` / `flushThread`).
15
+ * A bare {@link ActivityOptions} is also accepted (treated as `{ defaults }`).
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * proxyAnthropicThreadOps(undefined, {
20
+ * defaults: { startToCloseTimeout: "5s" },
21
+ * perOp: {
22
+ * flushThread: { startToCloseTimeout: "180s" }, // heartbeatTimeout still inherited
23
+ * },
24
+ * });
25
+ * ```
26
+ */
27
+ interface ThreadOpsProxyOptions {
28
+ defaults?: ActivityOptions;
29
+ perOp?: Partial<Record<OpName, ActivityOptions>>;
30
+ }
31
+ /**
32
+ * Creates a workflow-safe Temporal activity proxy for {@link ThreadOps}.
33
+ *
34
+ * @param adapterPrefix - Adapter identifier (e.g. "anthropic", "googleGenAI", "langChain")
35
+ * @param scope - Workflow scope. Defaults to `workflowInfo().workflowType`.
36
+ * @param options - {@link ThreadOpsProxyOptions} or a bare {@link ActivityOptions}.
37
+ */
38
+ declare function createThreadOpsProxy(adapterPrefix: string, scope?: string, options?: ActivityOptions | ThreadOpsProxyOptions): ActivityInterfaceFor<ThreadOps>;
39
+
40
+ export { type ThreadOpsProxyOptions as T, createThreadOpsProxy as c };
@@ -1,7 +1,7 @@
1
1
  import Redis from 'ioredis';
2
- import { J as JsonValue } from './types-CnuN9T6t.cjs';
2
+ import { J as JsonValue } from './types-DNEl5uxQ.cjs';
3
3
  import { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
4
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-oxt8GN97.cjs';
4
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BMJrsHo0.cjs';
5
5
 
6
6
  /** SDK-native content type for LangChain human messages */
7
7
  type LangChainContent = string | MessageContent;
@@ -1,7 +1,7 @@
1
1
  import Redis from 'ioredis';
2
2
  import Anthropic from '@anthropic-ai/sdk';
3
- import { J as JsonValue } from './types-CnuN9T6t.cjs';
4
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-oxt8GN97.cjs';
3
+ import { J as JsonValue } from './types-DNEl5uxQ.cjs';
4
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BMJrsHo0.cjs';
5
5
 
6
6
  /** SDK-native content type for Anthropic human messages */
7
7
  type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
@@ -1,7 +1,7 @@
1
1
  import Redis from 'ioredis';
2
2
  import Anthropic from '@anthropic-ai/sdk';
3
- import { J as JsonValue } from './types-CwN6_tAL.js';
4
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-L5bvbF-n.js';
3
+ import { J as JsonValue } from './types-qQVZfhoT.js';
4
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-CtdOquo3.js';
5
5
 
6
6
  /** SDK-native content type for Anthropic human messages */
7
7
  type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
@@ -1,7 +1,7 @@
1
1
  import Redis from 'ioredis';
2
- import { J as JsonValue } from './types-CwN6_tAL.js';
2
+ import { J as JsonValue } from './types-qQVZfhoT.js';
3
3
  import { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
4
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-L5bvbF-n.js';
4
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-CtdOquo3.js';
5
5
 
6
6
  /** SDK-native content type for LangChain human messages */
7
7
  type LangChainContent = string | MessageContent;
@@ -1,5 +1,5 @@
1
1
  import Redis from 'ioredis';
2
- import { P as PersistedThreadState, J as JsonValue } from './types-CnuN9T6t.cjs';
2
+ import { P as PersistedThreadState, J as JsonValue } from './types-DNEl5uxQ.cjs';
3
3
 
4
4
  interface ThreadManagerConfig<T> {
5
5
  redis: Redis;
@@ -1,5 +1,5 @@
1
1
  import Redis from 'ioredis';
2
- import { P as PersistedThreadState, J as JsonValue } from './types-CwN6_tAL.js';
2
+ import { P as PersistedThreadState, J as JsonValue } from './types-qQVZfhoT.js';
3
3
 
4
4
  interface ThreadManagerConfig<T> {
5
5
  redis: Redis;
@@ -1283,6 +1283,22 @@ interface SubagentConfig<TResult extends z.ZodType = z.ZodType> {
1283
1283
  * directly to the existing thread in-place.
1284
1284
  */
1285
1285
  thread?: "new" | "fork" | "continue";
1286
+ /**
1287
+ * Where the subagent's thread comes from when the parent's tool call
1288
+ * omits `threadId`. Only meaningful in combination with
1289
+ * `thread: "fork"` or `"continue"`.
1290
+ *
1291
+ * - `"new"` (default) — start a fresh thread (the prior behavior).
1292
+ * - `"from-parent"` — use the parent's own `threadId` (from
1293
+ * `RouterContext`). With `thread: "fork"` the parent's conversation
1294
+ * is copied into a new thread; with `thread: "continue"` the
1295
+ * subagent appends to the parent's thread in-place.
1296
+ *
1297
+ * Has no effect when `thread` is `"new"` (or omitted). A `threadId`
1298
+ * supplied by the parent agent always wins — `newThreadSource` only
1299
+ * applies when none is provided.
1300
+ */
1301
+ newThreadSource?: "new" | "from-parent";
1286
1302
  /**
1287
1303
  * Sandbox strategy for this subagent.
1288
1304
  *
@@ -1283,6 +1283,22 @@ interface SubagentConfig<TResult extends z.ZodType = z.ZodType> {
1283
1283
  * directly to the existing thread in-place.
1284
1284
  */
1285
1285
  thread?: "new" | "fork" | "continue";
1286
+ /**
1287
+ * Where the subagent's thread comes from when the parent's tool call
1288
+ * omits `threadId`. Only meaningful in combination with
1289
+ * `thread: "fork"` or `"continue"`.
1290
+ *
1291
+ * - `"new"` (default) — start a fresh thread (the prior behavior).
1292
+ * - `"from-parent"` — use the parent's own `threadId` (from
1293
+ * `RouterContext`). With `thread: "fork"` the parent's conversation
1294
+ * is copied into a new thread; with `thread: "continue"` the
1295
+ * subagent appends to the parent's thread in-place.
1296
+ *
1297
+ * Has no effect when `thread` is `"new"` (or omitted). A `threadId`
1298
+ * supplied by the parent agent always wins — `newThreadSource` only
1299
+ * applies when none is provided.
1300
+ */
1301
+ newThreadSource?: "new" | "from-parent";
1286
1302
  /**
1287
1303
  * Sandbox strategy for this subagent.
1288
1304
  *
@@ -1,4 +1,4 @@
1
- import { au as ToolMap, _ as SandboxInit, ah as SubagentSandboxShutdown, a1 as SessionConfig, aF as ZeitlichSession, $ as SandboxShutdown, am as ThreadInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aH as ToolRouterOptions, ax as ToolRouter, R as RouterContext, J as JsonValue, az as ToolWithHandler, w as ParsedToolCallUnion, av as ToolNames, ac as SubagentDefinition, af as SubagentHooks, ag as SubagentSandboxConfig, aa as SubagentConfig, ai as SubagentSessionInput, ad as SubagentFnResult, a7 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, an as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, aB as VirtualFileTree, k as TreeMutation, s as FileEntry, aC as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, as as ToolHandler, aE as WorkflowTask, d as ActivityToolHandler } from './types-CnuN9T6t.cjs';
1
+ import { au as ToolMap, _ as SandboxInit, ah as SubagentSandboxShutdown, a1 as SessionConfig, aF as ZeitlichSession, $ as SandboxShutdown, am as ThreadInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aH as ToolRouterOptions, ax as ToolRouter, R as RouterContext, J as JsonValue, az as ToolWithHandler, w as ParsedToolCallUnion, av as ToolNames, ac as SubagentDefinition, af as SubagentHooks, ag as SubagentSandboxConfig, aa as SubagentConfig, ai as SubagentSessionInput, ad as SubagentFnResult, a7 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, an as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, aB as VirtualFileTree, k as TreeMutation, s as FileEntry, aC as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, as as ToolHandler, aE as WorkflowTask, d as ActivityToolHandler } from './types-DNEl5uxQ.cjs';
2
2
  import z$1, { z } from 'zod';
3
3
  import './types-CJ7tCdl6.cjs';
4
4
  import { Duration } from '@temporalio/common';
@@ -335,6 +335,7 @@ declare function defineSubagent<TResult extends z.ZodType = z.ZodType, TContext
335
335
  enabled?: boolean | (() => boolean);
336
336
  taskQueue?: string;
337
337
  thread?: "new" | "fork" | "continue";
338
+ newThreadSource?: "new" | "from-parent";
338
339
  sandbox?: SubagentSandboxConfig;
339
340
  }): SubagentConfig<TResult>;
340
341
 
@@ -740,6 +741,20 @@ declare const editTool: {
740
741
  strict: true;
741
742
  };
742
743
  type FileEditArgs = z.infer<typeof editTool.schema>;
744
+ declare const multiEditTool: {
745
+ name: "FileMultiEdit";
746
+ description: string;
747
+ schema: z.ZodObject<{
748
+ file_path: z.ZodString;
749
+ edits: z.ZodArray<z.ZodObject<{
750
+ old_string: z.ZodString;
751
+ new_string: z.ZodString;
752
+ replace_all: z.ZodOptional<z.ZodBoolean>;
753
+ }, z.core.$strip>>;
754
+ }, z.core.$strip>;
755
+ strict: true;
756
+ };
757
+ type FileMultiEditArgs = z.infer<typeof multiEditTool.schema>;
743
758
 
744
759
  declare const taskCreateTool: {
745
760
  name: "TaskCreate";
@@ -887,4 +902,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
887
902
  }[];
888
903
  }>;
889
904
 
890
- export { globTool 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, getThreadDedupKey as V, type WorkflowConfig as W, getThreadListKey as X, getThreadMetaKey as Y, type ZeitlichObservabilitySinks as Z, getThreadStateKey as _, type FileReadArgs as a, grepTool as a0, hasDirectory as a1, hasFileWithMimeType as a2, hasNoOtherToolCalls as a3, parseSkillFile as a4, proxyRunAgent as a5, proxyVirtualFsOps as a6, readFileTool as a7, taskCreateTool as a8, taskGetTool as a9, taskListTool as aa, taskUpdateTool as ab, writeFileTool as ac, 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 };
905
+ export { getThreadStateKey as $, type AskUserQuestionArgs as A, type BashArgs as B, createTaskCreateHandler as C, DEFAULT_SUBAGENT_WORKFLOW_RUN_TIMEOUT as D, createTaskGetHandler as E, type FileEditArgs as F, type GlobArgs as G, createTaskListHandler as H, createTaskUpdateHandler as I, createToolRouter as J, defineSubagent as K, defineSubagentWorkflow as L, defineTool as M, defineWorkflow as N, type ObservabilityHooks as O, editTool as P, filesWithMimeType as Q, type ReadSkillArgs as R, type SessionEndedEvent as S, THREAD_TTL_SECONDS as T, formatVirtualFileTree as U, getShortId as V, type WorkflowConfig as W, getThreadDedupKey as X, getThreadListKey as Y, type ZeitlichObservabilitySinks as Z, getThreadMetaKey as _, type FileMultiEditArgs as a, globTool as a0, grepTool as a1, hasDirectory as a2, hasFileWithMimeType as a3, hasNoOtherToolCalls as a4, multiEditTool as a5, parseSkillFile as a6, proxyRunAgent as a7, proxyVirtualFsOps as a8, readFileTool as a9, taskCreateTool as aa, taskGetTool as ab, taskListTool as ac, taskUpdateTool as ad, writeFileTool as ae, type FileReadArgs as b, type FileWriteArgs as c, type FileTreeAccessor as d, type GrepArgs as e, type SessionStartedEvent as f, type SubagentArgs as g, type TaskCreateArgs as h, type TaskGetArgs as i, type TaskListArgs as j, type TaskUpdateArgs as k, type ToolExecutedEvent as l, type TurnCompletedEvent as m, type WorkflowInput as n, type WorkflowSessionInput as o, applyVirtualTreeMutations as p, askUserQuestionTool as q, bashTool as r, composeHooks as s, createAgentStateManager as t, createAskUserQuestionHandler as u, createBashToolDescription as v, createObservabilityHooks as w, createReadSkillHandler as x, createReadSkillTool as y, createSession as z };
@@ -1,4 +1,4 @@
1
- import { au as ToolMap, _ as SandboxInit, ah as SubagentSandboxShutdown, a1 as SessionConfig, aF as ZeitlichSession, $ as SandboxShutdown, am as ThreadInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aH as ToolRouterOptions, ax as ToolRouter, R as RouterContext, J as JsonValue, az as ToolWithHandler, w as ParsedToolCallUnion, av as ToolNames, ac as SubagentDefinition, af as SubagentHooks, ag as SubagentSandboxConfig, aa as SubagentConfig, ai as SubagentSessionInput, ad as SubagentFnResult, a7 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, an as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, aB as VirtualFileTree, k as TreeMutation, s as FileEntry, aC as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, as as ToolHandler, aE as WorkflowTask, d as ActivityToolHandler } from './types-CwN6_tAL.js';
1
+ import { au as ToolMap, _ as SandboxInit, ah as SubagentSandboxShutdown, a1 as SessionConfig, aF as ZeitlichSession, $ as SandboxShutdown, am as ThreadInit, u as JsonSerializable, B as BaseAgentState, p as AgentStateManager, aH as ToolRouterOptions, ax as ToolRouter, R as RouterContext, J as JsonValue, az as ToolWithHandler, w as ParsedToolCallUnion, av as ToolNames, ac as SubagentDefinition, af as SubagentHooks, ag as SubagentSandboxConfig, aa as SubagentConfig, ai as SubagentSessionInput, ad as SubagentFnResult, a7 as SessionStartHook, a2 as SessionEndHook, E as PostToolUseHook, z as PostToolUseFailureHook, a4 as SessionExitReason, an as TokenUsage, f as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, aB as VirtualFileTree, k as TreeMutation, s as FileEntry, aC as VirtualFsOps, h as SkillMetadata, i as Skill, c as ToolHandlerResponse, as as ToolHandler, aE as WorkflowTask, d as ActivityToolHandler } from './types-qQVZfhoT.js';
2
2
  import z$1, { z } from 'zod';
3
3
  import './types-CJ7tCdl6.js';
4
4
  import { Duration } from '@temporalio/common';
@@ -335,6 +335,7 @@ declare function defineSubagent<TResult extends z.ZodType = z.ZodType, TContext
335
335
  enabled?: boolean | (() => boolean);
336
336
  taskQueue?: string;
337
337
  thread?: "new" | "fork" | "continue";
338
+ newThreadSource?: "new" | "from-parent";
338
339
  sandbox?: SubagentSandboxConfig;
339
340
  }): SubagentConfig<TResult>;
340
341
 
@@ -740,6 +741,20 @@ declare const editTool: {
740
741
  strict: true;
741
742
  };
742
743
  type FileEditArgs = z.infer<typeof editTool.schema>;
744
+ declare const multiEditTool: {
745
+ name: "FileMultiEdit";
746
+ description: string;
747
+ schema: z.ZodObject<{
748
+ file_path: z.ZodString;
749
+ edits: z.ZodArray<z.ZodObject<{
750
+ old_string: z.ZodString;
751
+ new_string: z.ZodString;
752
+ replace_all: z.ZodOptional<z.ZodBoolean>;
753
+ }, z.core.$strip>>;
754
+ }, z.core.$strip>;
755
+ strict: true;
756
+ };
757
+ type FileMultiEditArgs = z.infer<typeof multiEditTool.schema>;
743
758
 
744
759
  declare const taskCreateTool: {
745
760
  name: "TaskCreate";
@@ -887,4 +902,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
887
902
  }[];
888
903
  }>;
889
904
 
890
- export { globTool 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, getThreadDedupKey as V, type WorkflowConfig as W, getThreadListKey as X, getThreadMetaKey as Y, type ZeitlichObservabilitySinks as Z, getThreadStateKey as _, type FileReadArgs as a, grepTool as a0, hasDirectory as a1, hasFileWithMimeType as a2, hasNoOtherToolCalls as a3, parseSkillFile as a4, proxyRunAgent as a5, proxyVirtualFsOps as a6, readFileTool as a7, taskCreateTool as a8, taskGetTool as a9, taskListTool as aa, taskUpdateTool as ab, writeFileTool as ac, 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 };
905
+ export { getThreadStateKey as $, type AskUserQuestionArgs as A, type BashArgs as B, createTaskCreateHandler as C, DEFAULT_SUBAGENT_WORKFLOW_RUN_TIMEOUT as D, createTaskGetHandler as E, type FileEditArgs as F, type GlobArgs as G, createTaskListHandler as H, createTaskUpdateHandler as I, createToolRouter as J, defineSubagent as K, defineSubagentWorkflow as L, defineTool as M, defineWorkflow as N, type ObservabilityHooks as O, editTool as P, filesWithMimeType as Q, type ReadSkillArgs as R, type SessionEndedEvent as S, THREAD_TTL_SECONDS as T, formatVirtualFileTree as U, getShortId as V, type WorkflowConfig as W, getThreadDedupKey as X, getThreadListKey as Y, type ZeitlichObservabilitySinks as Z, getThreadMetaKey as _, type FileMultiEditArgs as a, globTool as a0, grepTool as a1, hasDirectory as a2, hasFileWithMimeType as a3, hasNoOtherToolCalls as a4, multiEditTool as a5, parseSkillFile as a6, proxyRunAgent as a7, proxyVirtualFsOps as a8, readFileTool as a9, taskCreateTool as aa, taskGetTool as ab, taskListTool as ac, taskUpdateTool as ad, writeFileTool as ae, type FileReadArgs as b, type FileWriteArgs as c, type FileTreeAccessor as d, type GrepArgs as e, type SessionStartedEvent as f, type SubagentArgs as g, type TaskCreateArgs as h, type TaskGetArgs as i, type TaskListArgs as j, type TaskUpdateArgs as k, type ToolExecutedEvent as l, type TurnCompletedEvent as m, type WorkflowInput as n, type WorkflowSessionInput as o, applyVirtualTreeMutations as p, askUserQuestionTool as q, bashTool as r, composeHooks as s, createAgentStateManager as t, createAskUserQuestionHandler as u, createBashToolDescription as v, createObservabilityHooks as w, createReadSkillHandler as x, createReadSkillTool as y, createSession as z };
package/dist/workflow.cjs CHANGED
@@ -566,7 +566,8 @@ function createSubagentHandler(subagents) {
566
566
  }
567
567
  const threadMode = config.thread ?? "new";
568
568
  const allowsContinuation = threadMode !== "new";
569
- const continuationThreadId = args.threadId && allowsContinuation ? args.threadId : void 0;
569
+ const newThreadSource = config.newThreadSource ?? "new";
570
+ const continuationThreadId = !allowsContinuation ? void 0 : args.threadId ?? (newThreadSource === "from-parent" ? context.threadId : void 0);
570
571
  let thread;
571
572
  if (continuationThreadId) {
572
573
  thread = {
@@ -2118,6 +2119,13 @@ IMPORTANT:
2118
2119
  }),
2119
2120
  strict: true
2120
2121
  };
2122
+ var textEditSchema = z14.z.object({
2123
+ old_string: z14.z.string().describe("The exact text to replace"),
2124
+ new_string: z14.z.string().describe("The text to replace it with"),
2125
+ replace_all: z14.z.boolean().optional().describe(
2126
+ "If true, replace all occurrences of old_string for this edit (default: false)"
2127
+ )
2128
+ });
2121
2129
  var editTool = {
2122
2130
  name: "FileEdit",
2123
2131
  description: `Edit specific sections of a file by replacing text.
@@ -2146,6 +2154,27 @@ IMPORTANT:
2146
2154
  }),
2147
2155
  strict: true
2148
2156
  };
2157
+ var multiEditTool = {
2158
+ name: "FileMultiEdit",
2159
+ description: `Apply multiple exact text replacements to one file in order.
2160
+
2161
+ Usage:
2162
+ - Use this when a task needs several related edits in the same file
2163
+ - Each edit is applied to the file content produced by the prior edit
2164
+ - The operation is atomic: if any edit fails, the file is left unchanged
2165
+
2166
+ IMPORTANT:
2167
+ - You must read the file first (in this session) before editing it
2168
+ - Each old_string must match exactly (whitespace-sensitive)
2169
+ - Each old_string must be unique unless that edit uses replace_all: true
2170
+ - old_string and new_string must be different for every edit
2171
+ `,
2172
+ schema: z14.z.object({
2173
+ file_path: z14.z.string().describe("The absolute virtual path to the file to modify"),
2174
+ edits: z14.z.array(textEditSchema).min(1).describe("Exact replacements to apply sequentially to the file")
2175
+ }),
2176
+ strict: true
2177
+ };
2149
2178
  var taskCreateTool = {
2150
2179
  name: "TaskCreate",
2151
2180
  description: `Use this tool to create a structured task list. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
@@ -2216,7 +2245,7 @@ function createTaskCreateHandler(stateManager) {
2216
2245
  };
2217
2246
  stateManager.setTask(task);
2218
2247
  return {
2219
- toolResponse: JSON.stringify(task, null, 2),
2248
+ toolResponse: `Task ${task.id} created`,
2220
2249
  data: task
2221
2250
  };
2222
2251
  };
@@ -2315,7 +2344,7 @@ function createTaskUpdateHandler(stateManager) {
2315
2344
  }
2316
2345
  stateManager.setTask(task);
2317
2346
  return {
2318
- toolResponse: JSON.stringify(task, null, 2),
2347
+ toolResponse: `Task ${task.id} updated`,
2319
2348
  data: task
2320
2349
  };
2321
2350
  };
@@ -2424,6 +2453,7 @@ exports.hasDirectory = hasDirectory;
2424
2453
  exports.hasFileWithMimeType = hasFileWithMimeType;
2425
2454
  exports.hasNoOtherToolCalls = hasNoOtherToolCalls;
2426
2455
  exports.isTerminalStatus = isTerminalStatus;
2456
+ exports.multiEditTool = multiEditTool;
2427
2457
  exports.parseSkillFile = parseSkillFile;
2428
2458
  exports.proxyRunAgent = proxyRunAgent;
2429
2459
  exports.proxyVirtualFsOps = proxyVirtualFsOps;