zeitlich 0.2.2 → 0.2.3

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 (45) hide show
  1. package/README.md +34 -31
  2. package/dist/index.cjs +305 -361
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +24 -43
  5. package/dist/index.d.ts +24 -43
  6. package/dist/index.js +277 -336
  7. package/dist/index.js.map +1 -1
  8. package/dist/{workflow-BQf5EfNN.d.cts → workflow-D-2vp4Pq.d.cts} +265 -241
  9. package/dist/{workflow-BQf5EfNN.d.ts → workflow-D-2vp4Pq.d.ts} +265 -241
  10. package/dist/workflow.cjs +206 -253
  11. package/dist/workflow.cjs.map +1 -1
  12. package/dist/workflow.d.cts +2 -3
  13. package/dist/workflow.d.ts +2 -3
  14. package/dist/workflow.js +182 -231
  15. package/dist/workflow.js.map +1 -1
  16. package/package.json +3 -2
  17. package/src/activities.ts +1 -14
  18. package/src/index.ts +14 -11
  19. package/src/lib/session.ts +56 -99
  20. package/src/lib/thread-manager.ts +45 -37
  21. package/src/lib/tool-router.ts +143 -103
  22. package/src/lib/types.ts +32 -25
  23. package/src/tools/ask-user-question/handler.ts +5 -5
  24. package/src/tools/ask-user-question/tool.ts +3 -2
  25. package/src/tools/bash/bash.test.ts +12 -12
  26. package/src/tools/bash/handler.ts +5 -5
  27. package/src/tools/bash/tool.ts +3 -2
  28. package/src/tools/edit/handler.ts +78 -123
  29. package/src/tools/edit/tool.ts +3 -2
  30. package/src/tools/glob/handler.ts +17 -48
  31. package/src/tools/glob/tool.ts +3 -2
  32. package/src/tools/grep/tool.ts +3 -2
  33. package/src/tools/{read → read-file}/tool.ts +3 -2
  34. package/src/tools/task/handler.ts +2 -2
  35. package/src/tools/task/tool.ts +2 -9
  36. package/src/tools/task-create/handler.ts +5 -11
  37. package/src/tools/task-create/tool.ts +3 -2
  38. package/src/tools/task-get/handler.ts +5 -10
  39. package/src/tools/task-get/tool.ts +3 -2
  40. package/src/tools/task-list/handler.ts +5 -10
  41. package/src/tools/task-list/tool.ts +3 -2
  42. package/src/tools/task-update/handler.ts +5 -12
  43. package/src/tools/task-update/tool.ts +3 -2
  44. package/src/tools/{write → write-file}/tool.ts +5 -6
  45. package/src/workflow.ts +23 -19
package/dist/workflow.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var workflow = require('@temporalio/workflow');
4
- var z5 = require('zod');
4
+ var z3 = require('zod');
5
5
 
6
6
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
7
 
8
- var z5__default = /*#__PURE__*/_interopDefault(z5);
8
+ var z3__default = /*#__PURE__*/_interopDefault(z3);
9
9
 
10
10
  // src/lib/session.ts
11
11
  var TASK_TOOL = "Task";
@@ -40,10 +40,10 @@ function createTaskTool(subagents) {
40
40
  return {
41
41
  name: TASK_TOOL,
42
42
  description: buildTaskDescription(subagents),
43
- schema: z5__default.default.object({
44
- subagent: z5__default.default.enum(names).describe("The type of subagent to launch"),
45
- description: z5__default.default.string().describe("A short (3-5 word) description of the task"),
46
- prompt: z5__default.default.string().describe("The task for the agent to perform")
43
+ schema: z3__default.default.object({
44
+ subagent: z3__default.default.enum(names).describe("The type of subagent to launch"),
45
+ description: z3__default.default.string().describe("A short (3-5 word) description of the task"),
46
+ prompt: z3__default.default.string().describe("The task for the agent to perform")
47
47
  })
48
48
  };
49
49
  }
@@ -78,107 +78,15 @@ function createTaskHandler(subagents) {
78
78
  };
79
79
  };
80
80
  }
81
- var createBashToolDescription = ({
82
- fileTree
83
- }) => `Execute shell commands in a bash environment.
84
-
85
- Use this tool to:
86
- - Run shell commands (ls, cat, grep, find, etc.)
87
- - Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
88
- - Inspect files and directories
89
-
90
- Current file tree:
91
- ${fileTree}`;
92
- var bashTool = {
93
- name: "Bash",
94
- description: `Execute shell commands in a sandboxed bash environment.
95
-
96
- Use this tool to:
97
- - Run shell commands (ls, cat, grep, find, etc.)
98
- - Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
99
- - Inspect files and directories
100
- `,
101
- schema: z5__default.default.object({
102
- command: z5__default.default.string().describe(
103
- "The bash command to execute. Can include pipes (|), redirects (>, >>), logical operators (&&, ||), and shell features like command substitution $(...)."
104
- )
105
- }),
106
- strict: true
107
- };
108
- var taskCreateTool = {
109
- name: "TaskCreate",
110
- description: `Use this tool to create a structured task list for the control test. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
111
- It also helps the user understand the progress of the task and overall progress of their requests.
112
-
113
- ## When to Use This Tool
114
-
115
- Use this tool proactively in these scenarios:
116
-
117
- - Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
118
- - Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
119
- - User explicitly requests todo list - When the user directly asks you to use the todo list
120
- - User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
121
- - After receiving new instructions - Immediately capture user requirements as tasks
122
- - When you start working on a task - Mark it as in_progress BEFORE beginning work
123
- - After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
124
-
125
- ## When NOT to Use This Tool
126
-
127
- Skip using this tool when:
128
- - There is only a single, straightforward task
129
- - The task is trivial and tracking it provides no organizational benefit
130
- - The task can be completed in less than 3 trivial steps
131
- - The task is purely conversational or informational
132
-
133
- NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
134
-
135
- ## Task Fields
136
-
137
- - **subject**: A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")
138
- - **description**: Detailed description of what needs to be done, including context and acceptance criteria
139
- - **activeForm**: Present continuous form shown in spinner when task is in_progress (e.g., "Fixing authentication bug"). This is displayed to the user while you work on the task.
140
-
141
- **IMPORTANT**: Always provide activeForm when creating tasks. The subject should be imperative ("Run tests") while activeForm should be present continuous ("Running tests"). All tasks are created with status \`pending\`.
142
-
143
- ## Tips
144
-
145
- - Create tasks with clear, specific subjects that describe the outcome
146
- - Include enough detail in the description for another agent to understand and complete the task
147
- - After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
148
- - Check TaskList first to avoid creating duplicate tasks`,
149
- schema: z5__default.default.object({
150
- subject: z5__default.default.string().describe(
151
- 'A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")'
152
- ),
153
- description: z5__default.default.string().describe(
154
- "Detailed description of what needs to be done, including context and acceptance criteria"
155
- ),
156
- activeForm: z5__default.default.string().describe(
157
- 'Present continuous form shown in spinner when task is in_progress (e.g., "Fixing authentication bug"). This is displayed to the user while you work on the task.'
158
- ),
159
- metadata: z5__default.default.record(z5__default.default.string(), z5__default.default.string()).describe("Arbitrary key-value pairs for tracking")
160
- })
161
- };
162
81
 
163
82
  // src/lib/tool-router.ts
164
- var buildIntoolDefinitions = {
165
- [bashTool.name]: bashTool,
166
- [taskCreateTool.name]: taskCreateTool
167
- };
168
83
  function createToolRouter(options) {
169
- const { appendToolResult } = workflow.proxyActivities({
170
- startToCloseTimeout: "2m",
171
- retry: {
172
- maximumAttempts: 3,
173
- initialInterval: "5s",
174
- maximumInterval: "15m",
175
- backoffCoefficient: 4
176
- }
177
- });
84
+ const { appendToolResult } = options;
178
85
  const toolMap = /* @__PURE__ */ new Map();
179
86
  for (const [_key, tool] of Object.entries(options.tools)) {
180
87
  toolMap.set(tool.name, tool);
181
88
  }
89
+ const isEnabled = (tool) => tool.enabled !== false;
182
90
  if (options.subagents) {
183
91
  const subagentHooksMap = /* @__PURE__ */ new Map();
184
92
  for (const s of options.subagents) {
@@ -206,24 +114,6 @@ function createToolRouter(options) {
206
114
  }
207
115
  });
208
116
  }
209
- if (options.buildInTools) {
210
- for (const [key, value] of Object.entries(options.buildInTools)) {
211
- if (key === bashTool.name) {
212
- toolMap.set(key, {
213
- ...buildIntoolDefinitions[key],
214
- description: createBashToolDescription({
215
- fileTree: options.fileTree
216
- }),
217
- handler: value
218
- });
219
- } else {
220
- toolMap.set(key, {
221
- ...buildIntoolDefinitions[key],
222
- handler: value
223
- });
224
- }
225
- }
226
- }
227
117
  async function processToolCall(toolCall, turn, handlerContext) {
228
118
  const startTime = Date.now();
229
119
  const tool = toolMap.get(toolCall.name);
@@ -239,6 +129,7 @@ function createToolRouter(options) {
239
129
  await appendToolResult({
240
130
  threadId: options.threadId,
241
131
  toolCallId: toolCall.id,
132
+ toolName: toolCall.name,
242
133
  content: JSON.stringify({
243
134
  skipped: true,
244
135
  reason: "Skipped by PreToolUse hook"
@@ -260,6 +151,7 @@ function createToolRouter(options) {
260
151
  await appendToolResult({
261
152
  threadId: options.threadId,
262
153
  toolCallId: toolCall.id,
154
+ toolName: toolCall.name,
263
155
  content: JSON.stringify({
264
156
  skipped: true,
265
157
  reason: "Skipped by tool PreToolUse hook"
@@ -273,14 +165,22 @@ function createToolRouter(options) {
273
165
  }
274
166
  let result;
275
167
  let content;
168
+ let resultAppended = false;
276
169
  try {
277
170
  if (tool) {
171
+ const enrichedContext = {
172
+ ...handlerContext ?? {},
173
+ threadId: options.threadId,
174
+ toolCallId: toolCall.id,
175
+ toolName: toolCall.name
176
+ };
278
177
  const response = await tool.handler(
279
178
  effectiveArgs,
280
- handlerContext ?? {}
179
+ enrichedContext
281
180
  );
282
181
  result = response.data;
283
182
  content = response.toolResponse;
183
+ resultAppended = response.resultAppended === true;
284
184
  } else {
285
185
  result = { error: `Unknown tool: ${toolCall.name}` };
286
186
  content = JSON.stringify(result, null, 2);
@@ -326,11 +226,14 @@ function createToolRouter(options) {
326
226
  throw error;
327
227
  }
328
228
  }
329
- await appendToolResult({
330
- threadId: options.threadId,
331
- toolCallId: toolCall.id,
332
- content
333
- });
229
+ if (!resultAppended) {
230
+ await appendToolResult({
231
+ threadId: options.threadId,
232
+ toolCallId: toolCall.id,
233
+ toolName: toolCall.name,
234
+ content
235
+ });
236
+ }
334
237
  const toolResult = {
335
238
  toolCallId: toolCall.id,
336
239
  name: toolCall.name,
@@ -360,11 +263,11 @@ function createToolRouter(options) {
360
263
  return {
361
264
  // --- Methods from registry ---
362
265
  hasTools() {
363
- return toolMap.size > 0;
266
+ return Array.from(toolMap.values()).some(isEnabled);
364
267
  },
365
268
  parseToolCall(toolCall) {
366
269
  const tool = toolMap.get(toolCall.name);
367
- if (!tool) {
270
+ if (!tool || !isEnabled(tool)) {
368
271
  throw new Error(`Tool ${toolCall.name} not found`);
369
272
  }
370
273
  const parsedArgs = tool.schema.parse(toolCall.args);
@@ -375,13 +278,14 @@ function createToolRouter(options) {
375
278
  };
376
279
  },
377
280
  hasTool(name) {
378
- return toolMap.has(name);
281
+ const tool = toolMap.get(name);
282
+ return tool !== void 0 && isEnabled(tool);
379
283
  },
380
284
  getToolNames() {
381
- return Array.from(toolMap.keys());
285
+ return Array.from(toolMap.entries()).filter(([, tool]) => isEnabled(tool)).map(([name]) => name);
382
286
  },
383
287
  getToolDefinitions() {
384
- return Array.from(toolMap).map(([name, tool]) => ({
288
+ return Array.from(toolMap).filter(([, tool]) => isEnabled(tool)).map(([name, tool]) => ({
385
289
  name,
386
290
  description: tool.description,
387
291
  schema: tool.schema,
@@ -420,19 +324,28 @@ function createToolRouter(options) {
420
324
  }
421
325
  const handlerContext = context?.handlerContext ?? {};
422
326
  const processOne = async (toolCall) => {
327
+ const enrichedContext = {
328
+ ...handlerContext ?? {},
329
+ threadId: options.threadId,
330
+ toolCallId: toolCall.id,
331
+ toolName: toolCall.name
332
+ };
423
333
  const response = await handler(
424
334
  toolCall.args,
425
- handlerContext
335
+ enrichedContext
426
336
  );
427
- await appendToolResult({
428
- threadId: options.threadId,
429
- toolCallId: toolCall.id,
430
- content: response.toolResponse
431
- });
337
+ if (!response.resultAppended) {
338
+ await appendToolResult({
339
+ threadId: options.threadId,
340
+ toolCallId: toolCall.id,
341
+ toolName: toolCall.name,
342
+ content: response.toolResponse
343
+ });
344
+ }
432
345
  return {
433
346
  toolCallId: toolCall.id,
434
347
  name: toolCall.name,
435
- data: response.data ?? null
348
+ data: response.data
436
349
  };
437
350
  };
438
351
  if (options.parallel) {
@@ -469,51 +382,24 @@ function hasNoOtherToolCalls(toolCalls, excludeName) {
469
382
  }
470
383
 
471
384
  // src/lib/session.ts
472
- async function resolvePrompt(prompt) {
473
- if (typeof prompt === "function") {
474
- return prompt();
475
- }
476
- return prompt;
477
- }
478
385
  var createSession = async ({
479
386
  threadId,
480
387
  agentName,
481
388
  maxTurns = 50,
482
389
  metadata = {},
483
390
  runAgent,
484
- baseSystemPrompt,
485
- instructionsPrompt,
391
+ threadOps,
486
392
  buildContextMessage,
487
- buildFileTree = async () => "",
488
393
  subagents,
489
394
  tools = {},
490
395
  processToolsInParallel = true,
491
- buildInTools = {},
492
396
  hooks = {}
493
397
  }) => {
494
- const {
495
- initializeThread,
496
- appendHumanMessage,
497
- parseToolCalls,
498
- appendToolResult,
499
- appendSystemMessage
500
- } = workflow.proxyActivities({
501
- startToCloseTimeout: "30m",
502
- retry: {
503
- maximumAttempts: 6,
504
- initialInterval: "5s",
505
- maximumInterval: "15m",
506
- backoffCoefficient: 4
507
- },
508
- heartbeatTimeout: "5m"
509
- });
510
- const fileTree = await buildFileTree();
511
398
  const toolRouter = createToolRouter({
512
399
  tools,
400
+ appendToolResult: threadOps.appendToolResult,
513
401
  threadId,
514
402
  hooks,
515
- buildInTools,
516
- fileTree,
517
403
  subagents,
518
404
  parallel: processToolsInParallel
519
405
  });
@@ -538,15 +424,8 @@ var createSession = async ({
538
424
  });
539
425
  }
540
426
  stateManager.setTools(toolRouter.getToolDefinitions());
541
- await initializeThread(threadId);
542
- await appendSystemMessage(
543
- threadId,
544
- [
545
- await resolvePrompt(baseSystemPrompt),
546
- await resolvePrompt(instructionsPrompt)
547
- ].join("\n")
548
- );
549
- await appendHumanMessage(threadId, await buildContextMessage());
427
+ await threadOps.initializeThread(threadId);
428
+ await threadOps.appendHumanMessage(threadId, await buildContextMessage());
550
429
  let exitReason = "completed";
551
430
  try {
552
431
  while (stateManager.isRunning() && !stateManager.isTerminal() && stateManager.getTurns() < maxTurns) {
@@ -567,54 +446,25 @@ var createSession = async ({
567
446
  exitReason = "completed";
568
447
  return message;
569
448
  }
570
- const rawToolCalls = await parseToolCalls(message);
449
+ const rawToolCalls = await threadOps.parseToolCalls(message);
571
450
  const parsedToolCalls = [];
572
- for (const tc of rawToolCalls.filter(
573
- (tc2) => tc2.name !== "Task"
574
- )) {
451
+ for (const tc of rawToolCalls) {
575
452
  try {
576
453
  parsedToolCalls.push(toolRouter.parseToolCall(tc));
577
454
  } catch (error) {
578
- await appendToolResult({
455
+ await threadOps.appendToolResult({
579
456
  threadId,
580
457
  toolCallId: tc.id ?? "",
458
+ toolName: tc.name,
581
459
  content: JSON.stringify({
582
460
  error: `Invalid tool call for "${tc.name}": ${error instanceof Error ? error.message : String(error)}`
583
461
  })
584
462
  });
585
463
  }
586
464
  }
587
- const taskToolCalls = [];
588
- if (subagents && subagents.length > 0) {
589
- for (const tc of rawToolCalls.filter(
590
- (tc2) => tc2.name === "Task"
591
- )) {
592
- try {
593
- const parsedArgs = createTaskTool(subagents).schema.parse(
594
- tc.args
595
- );
596
- taskToolCalls.push({
597
- id: tc.id ?? "",
598
- name: tc.name,
599
- args: parsedArgs
600
- });
601
- } catch (error) {
602
- await appendToolResult({
603
- threadId,
604
- toolCallId: tc.id ?? "",
605
- content: JSON.stringify({
606
- error: `Invalid tool call for "Task": ${error instanceof Error ? error.message : String(error)}`
607
- })
608
- });
609
- }
610
- }
611
- }
612
- await toolRouter.processToolCalls(
613
- [...parsedToolCalls, ...taskToolCalls],
614
- {
615
- turn: currentTurn
616
- }
617
- );
465
+ await toolRouter.processToolCalls(parsedToolCalls, {
466
+ turn: currentTurn
467
+ });
618
468
  if (stateManager.getStatus() === "WAITING_FOR_INPUT") {
619
469
  exitReason = "waiting_for_input";
620
470
  break;
@@ -633,6 +483,26 @@ var createSession = async ({
633
483
  }
634
484
  };
635
485
  };
486
+ function proxyDefaultThreadOps(options) {
487
+ const activities = workflow.proxyActivities(
488
+ options ?? {
489
+ startToCloseTimeout: "30m",
490
+ retry: {
491
+ maximumAttempts: 6,
492
+ initialInterval: "5s",
493
+ maximumInterval: "15m",
494
+ backoffCoefficient: 4
495
+ },
496
+ heartbeatTimeout: "5m"
497
+ }
498
+ );
499
+ return {
500
+ initializeThread: activities.initializeThread,
501
+ appendHumanMessage: activities.appendHumanMessage,
502
+ appendToolResult: activities.appendToolResult,
503
+ parseToolCalls: activities.parseToolCalls
504
+ };
505
+ }
636
506
 
637
507
  // src/lib/types.ts
638
508
  function isTerminalStatus(status) {
@@ -735,7 +605,7 @@ function createAgentStateManager(initialState) {
735
605
  tools = newTools.map((tool) => ({
736
606
  name: tool.name,
737
607
  description: tool.description,
738
- schema: z5.z.toJSONSchema(tool.schema),
608
+ schema: z3.z.toJSONSchema(tool.schema),
739
609
  strict: tool.strict,
740
610
  max_uses: tool.max_uses
741
611
  }));
@@ -769,18 +639,18 @@ Usage notes:
769
639
  * Use multiSelect: true to allow multiple answers to be selected for a question
770
640
  * If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
771
641
  `,
772
- schema: z5__default.default.object({
773
- questions: z5__default.default.array(
774
- z5__default.default.object({
775
- question: z5__default.default.string().describe("The full question text to display"),
776
- header: z5__default.default.string().describe("Short label for the question (max 12 characters)"),
777
- options: z5__default.default.array(
778
- z5__default.default.object({
779
- label: z5__default.default.string(),
780
- description: z5__default.default.string()
642
+ schema: z3__default.default.object({
643
+ questions: z3__default.default.array(
644
+ z3__default.default.object({
645
+ question: z3__default.default.string().describe("The full question text to display"),
646
+ header: z3__default.default.string().describe("Short label for the question (max 12 characters)"),
647
+ options: z3__default.default.array(
648
+ z3__default.default.object({
649
+ label: z3__default.default.string(),
650
+ description: z3__default.default.string()
781
651
  })
782
652
  ).min(0).max(4).describe("Array of 0-4 choices, each with label and description"),
783
- multiSelect: z5__default.default.boolean().describe("If true, users can select multiple options")
653
+ multiSelect: z3__default.default.boolean().describe("If true, users can select multiple options")
784
654
  })
785
655
  )
786
656
  }),
@@ -800,9 +670,9 @@ Examples:
800
670
  - "**/*.test.ts" - Find all test files recursively
801
671
  - "src/**/*.ts" - Find all TypeScript files in src directory
802
672
  `,
803
- schema: z5.z.object({
804
- pattern: z5.z.string().describe("Glob pattern to match files against"),
805
- root: z5.z.string().optional().describe("Optional root directory to search from")
673
+ schema: z3.z.object({
674
+ pattern: z3.z.string().describe("Glob pattern to match files against"),
675
+ root: z3.z.string().optional().describe("Optional root directory to search from")
806
676
  }),
807
677
  strict: true
808
678
  };
@@ -820,13 +690,13 @@ Examples:
820
690
  - Search for function definitions with "function.*handleClick"
821
691
  - Search case-insensitively with ignoreCase: true
822
692
  `,
823
- schema: z5.z.object({
824
- pattern: z5.z.string().describe("Regex pattern to search for in file contents"),
825
- ignoreCase: z5.z.boolean().optional().describe("Case-insensitive search (default: false)"),
826
- maxMatches: z5.z.number().optional().describe("Maximum number of matches to return (default: 50)"),
827
- includePatterns: z5.z.array(z5.z.string()).optional().describe("Glob patterns to include (e.g., ['*.ts', '*.js'])"),
828
- excludePatterns: z5.z.array(z5.z.string()).optional().describe("Glob patterns to exclude (e.g., ['*.test.ts'])"),
829
- contextLines: z5.z.number().optional().describe("Number of context lines to show around matches")
693
+ schema: z3.z.object({
694
+ pattern: z3.z.string().describe("Regex pattern to search for in file contents"),
695
+ ignoreCase: z3.z.boolean().optional().describe("Case-insensitive search (default: false)"),
696
+ maxMatches: z3.z.number().optional().describe("Maximum number of matches to return (default: 50)"),
697
+ includePatterns: z3.z.array(z3.z.string()).optional().describe("Glob patterns to include (e.g., ['*.ts', '*.js'])"),
698
+ excludePatterns: z3.z.array(z3.z.string()).optional().describe("Glob patterns to exclude (e.g., ['*.test.ts'])"),
699
+ contextLines: z3.z.number().optional().describe("Number of context lines to show around matches")
830
700
  }),
831
701
  strict: true
832
702
  };
@@ -844,12 +714,12 @@ The tool returns the file content in an appropriate format:
844
714
  - Images: Base64-encoded image data
845
715
  - PDFs: Extracted text content
846
716
  `,
847
- schema: z5.z.object({
848
- path: z5.z.string().describe("Virtual path to the file to read"),
849
- offset: z5.z.number().optional().describe(
717
+ schema: z3.z.object({
718
+ path: z3.z.string().describe("Virtual path to the file to read"),
719
+ offset: z3.z.number().optional().describe(
850
720
  "Line number to start reading from (1-indexed, for text files)"
851
721
  ),
852
- limit: z5.z.number().optional().describe("Maximum number of lines to read (for text files)")
722
+ limit: z3.z.number().optional().describe("Maximum number of lines to read (for text files)")
853
723
  }),
854
724
  strict: true
855
725
  };
@@ -858,7 +728,7 @@ var writeTool = {
858
728
  description: `Create or overwrite a file with new content.
859
729
 
860
730
  Usage:
861
- - Provide the absolute virtual path to the file
731
+ - Provide the absolute path to the file
862
732
  - The file will be created if it doesn't exist
863
733
  - If the file exists, it will be completely overwritten
864
734
 
@@ -867,9 +737,9 @@ IMPORTANT:
867
737
  - This is an atomic write operation - the entire file is replaced
868
738
  - Path must be absolute (e.g., "/docs/readme.md", not "docs/readme.md")
869
739
  `,
870
- schema: z5.z.object({
871
- file_path: z5.z.string().describe("The absolute virtual path to the file to write"),
872
- content: z5.z.string().describe("The content to write to the file")
740
+ schema: z3.z.object({
741
+ file_path: z3.z.string().describe("The absolute path to the file to write"),
742
+ content: z3.z.string().describe("The content to write to the file")
873
743
  }),
874
744
  strict: true
875
745
  };
@@ -889,18 +759,72 @@ IMPORTANT:
889
759
  - The operation fails if old_string is not found
890
760
  - old_string and new_string must be different
891
761
  `,
892
- schema: z5.z.object({
893
- file_path: z5.z.string().describe("The absolute virtual path to the file to modify"),
894
- old_string: z5.z.string().describe("The exact text to replace"),
895
- new_string: z5.z.string().describe(
762
+ schema: z3.z.object({
763
+ file_path: z3.z.string().describe("The absolute virtual path to the file to modify"),
764
+ old_string: z3.z.string().describe("The exact text to replace"),
765
+ new_string: z3.z.string().describe(
896
766
  "The text to replace it with (must be different from old_string)"
897
767
  ),
898
- replace_all: z5.z.boolean().optional().describe(
768
+ replace_all: z3.z.boolean().optional().describe(
899
769
  "If true, replace all occurrences of old_string (default: false)"
900
770
  )
901
771
  }),
902
772
  strict: true
903
773
  };
774
+ var taskCreateTool = {
775
+ name: "TaskCreate",
776
+ description: `Use this tool to create a structured task list for the control test. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
777
+ It also helps the user understand the progress of the task and overall progress of their requests.
778
+
779
+ ## When to Use This Tool
780
+
781
+ Use this tool proactively in these scenarios:
782
+
783
+ - Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
784
+ - Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
785
+ - User explicitly requests todo list - When the user directly asks you to use the todo list
786
+ - User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
787
+ - After receiving new instructions - Immediately capture user requirements as tasks
788
+ - When you start working on a task - Mark it as in_progress BEFORE beginning work
789
+ - After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
790
+
791
+ ## When NOT to Use This Tool
792
+
793
+ Skip using this tool when:
794
+ - There is only a single, straightforward task
795
+ - The task is trivial and tracking it provides no organizational benefit
796
+ - The task can be completed in less than 3 trivial steps
797
+ - The task is purely conversational or informational
798
+
799
+ NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
800
+
801
+ ## Task Fields
802
+
803
+ - **subject**: A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")
804
+ - **description**: Detailed description of what needs to be done, including context and acceptance criteria
805
+ - **activeForm**: Present continuous form shown in spinner when task is in_progress (e.g., "Fixing authentication bug"). This is displayed to the user while you work on the task.
806
+
807
+ **IMPORTANT**: Always provide activeForm when creating tasks. The subject should be imperative ("Run tests") while activeForm should be present continuous ("Running tests"). All tasks are created with status \`pending\`.
808
+
809
+ ## Tips
810
+
811
+ - Create tasks with clear, specific subjects that describe the outcome
812
+ - Include enough detail in the description for another agent to understand and complete the task
813
+ - After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
814
+ - Check TaskList first to avoid creating duplicate tasks`,
815
+ schema: z3__default.default.object({
816
+ subject: z3__default.default.string().describe(
817
+ 'A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")'
818
+ ),
819
+ description: z3__default.default.string().describe(
820
+ "Detailed description of what needs to be done, including context and acceptance criteria"
821
+ ),
822
+ activeForm: z3__default.default.string().describe(
823
+ 'Present continuous form shown in spinner when task is in_progress (e.g., "Fixing authentication bug"). This is displayed to the user while you work on the task.'
824
+ ),
825
+ metadata: z3__default.default.record(z3__default.default.string(), z3__default.default.string()).describe("Arbitrary key-value pairs for tracking")
826
+ })
827
+ };
904
828
  function createTaskCreateHandler(stateManager) {
905
829
  return (args) => {
906
830
  const task = {
@@ -923,8 +847,8 @@ function createTaskCreateHandler(stateManager) {
923
847
  var taskGetTool = {
924
848
  name: "TaskGet",
925
849
  description: `Retrieve full task details including dependencies.`,
926
- schema: z5__default.default.object({
927
- taskId: z5__default.default.string().describe("The ID of the task to get")
850
+ schema: z3__default.default.object({
851
+ taskId: z3__default.default.string().describe("The ID of the task to get")
928
852
  })
929
853
  };
930
854
 
@@ -947,12 +871,12 @@ function createTaskGetHandler(stateManager) {
947
871
  var taskListTool = {
948
872
  name: "TaskList",
949
873
  description: `List all tasks with current state.`,
950
- schema: z5__default.default.object({})
874
+ schema: z3__default.default.object({})
951
875
  };
952
876
 
953
877
  // src/tools/task-list/handler.ts
954
878
  function createTaskListHandler(stateManager) {
955
- return (_args) => {
879
+ return () => {
956
880
  const taskList = stateManager.getTasks();
957
881
  return {
958
882
  toolResponse: JSON.stringify(taskList, null, 2),
@@ -963,11 +887,11 @@ function createTaskListHandler(stateManager) {
963
887
  var taskUpdateTool = {
964
888
  name: "TaskUpdate",
965
889
  description: `Update status, add blockers, modify details.`,
966
- schema: z5__default.default.object({
967
- taskId: z5__default.default.string().describe("The ID of the task to get"),
968
- status: z5__default.default.enum(["pending", "in_progress", "completed"]).describe("The status of the task"),
969
- addBlockedBy: z5__default.default.array(z5__default.default.string()).describe("The IDs of the tasks that are blocking this task"),
970
- addBlocks: z5__default.default.array(z5__default.default.string()).describe("The IDs of the tasks that this task is blocking")
890
+ schema: z3__default.default.object({
891
+ taskId: z3__default.default.string().describe("The ID of the task to get"),
892
+ status: z3__default.default.enum(["pending", "in_progress", "completed"]).describe("The status of the task"),
893
+ addBlockedBy: z3__default.default.array(z3__default.default.string()).describe("The IDs of the tasks that are blocking this task"),
894
+ addBlocks: z3__default.default.array(z3__default.default.string()).describe("The IDs of the tasks that this task is blocking")
971
895
  })
972
896
  };
973
897
 
@@ -1015,11 +939,39 @@ function createTaskUpdateHandler(stateManager) {
1015
939
  };
1016
940
  };
1017
941
  }
942
+ var createBashToolDescription = ({
943
+ fileTree
944
+ }) => `Execute shell commands in a bash environment.
945
+
946
+ Use this tool to:
947
+ - Run shell commands (ls, cat, grep, find, etc.)
948
+ - Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
949
+ - Inspect files and directories
950
+
951
+ Current file tree:
952
+ ${fileTree}`;
953
+ var bashTool = {
954
+ name: "Bash",
955
+ description: `Execute shell commands in a sandboxed bash environment.
956
+
957
+ Use this tool to:
958
+ - Run shell commands (ls, cat, grep, find, etc.)
959
+ - Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
960
+ - Inspect files and directories
961
+ `,
962
+ schema: z3__default.default.object({
963
+ command: z3__default.default.string().describe(
964
+ "The bash command to execute. Can include pipes (|), redirects (>, >>), logical operators (&&, ||), and shell features like command substitution $(...)."
965
+ )
966
+ }),
967
+ strict: true
968
+ };
1018
969
 
1019
970
  exports.AGENT_HANDLER_NAMES = AGENT_HANDLER_NAMES;
1020
971
  exports.askUserQuestionTool = askUserQuestionTool;
1021
972
  exports.bashTool = bashTool;
1022
973
  exports.createAgentStateManager = createAgentStateManager;
974
+ exports.createBashToolDescription = createBashToolDescription;
1023
975
  exports.createSession = createSession;
1024
976
  exports.createTaskCreateHandler = createTaskCreateHandler;
1025
977
  exports.createTaskGetHandler = createTaskGetHandler;
@@ -1034,6 +986,7 @@ exports.globTool = globTool;
1034
986
  exports.grepTool = grepTool;
1035
987
  exports.hasNoOtherToolCalls = hasNoOtherToolCalls;
1036
988
  exports.isTerminalStatus = isTerminalStatus;
989
+ exports.proxyDefaultThreadOps = proxyDefaultThreadOps;
1037
990
  exports.readTool = readTool;
1038
991
  exports.taskCreateTool = taskCreateTool;
1039
992
  exports.taskGetTool = taskGetTool;