zeitlich 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineQuery, proxyActivities, setHandler, workflowInfo, uuid4, executeChild } from '@temporalio/workflow';
2
- import z4, { z } from 'zod';
1
+ import { defineQuery, proxyActivities, setHandler, uuid4, workflowInfo, executeChild } from '@temporalio/workflow';
2
+ import z5, { z } from 'zod';
3
3
  import { SimplePlugin } from '@temporalio/plugin';
4
- import { mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages, AIMessage, SystemMessage, ToolMessage, HumanMessage } from '@langchain/core/messages';
4
+ import { SystemMessage, ToolMessage, AIMessage, HumanMessage, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages } from '@langchain/core/messages';
5
5
  import crypto from 'crypto';
6
6
  import { Context } from '@temporalio/activity';
7
7
  import { Bash } from 'just-bash';
@@ -39,10 +39,10 @@ function createTaskTool(subagents) {
39
39
  return {
40
40
  name: TASK_TOOL,
41
41
  description: buildTaskDescription(subagents),
42
- schema: z4.object({
43
- subagent: z4.enum(names).describe("The type of subagent to launch"),
44
- description: z4.string().describe("A short (3-5 word) description of the task"),
45
- prompt: z4.string().describe("The task for the agent to perform")
42
+ schema: z5.object({
43
+ subagent: z5.enum(names).describe("The type of subagent to launch"),
44
+ description: z5.string().describe("A short (3-5 word) description of the task"),
45
+ prompt: z5.string().describe("The task for the agent to perform")
46
46
  })
47
47
  };
48
48
  }
@@ -56,16 +56,21 @@ function createTaskHandler(subagents) {
56
56
  );
57
57
  }
58
58
  const childWorkflowId = `${parentWorkflowId}-${args.subagent}-${uuid4()}`;
59
- const childResult = await executeChild(config.workflowType, {
59
+ const input = {
60
+ prompt: args.prompt,
61
+ ...config.context && { context: config.context }
62
+ };
63
+ const childOpts = {
60
64
  workflowId: childWorkflowId,
61
- args: [{ prompt: args.prompt }],
65
+ args: [input],
62
66
  taskQueue: config.taskQueue ?? parentTaskQueue
63
- });
67
+ };
68
+ const childResult = typeof config.workflow === "string" ? await executeChild(config.workflow, childOpts) : await executeChild(config.workflow, childOpts);
64
69
  const validated = config.resultSchema ? config.resultSchema.parse(childResult) : childResult;
65
- const content = typeof validated === "string" ? validated : JSON.stringify(validated, null, 2);
70
+ const toolResponse = typeof validated === "string" ? validated : JSON.stringify(validated, null, 2);
66
71
  return {
67
- content,
68
- result: {
72
+ toolResponse,
73
+ data: {
69
74
  result: validated,
70
75
  childWorkflowId
71
76
  }
@@ -74,12 +79,28 @@ function createTaskHandler(subagents) {
74
79
  }
75
80
  var createBashToolDescription = ({
76
81
  fileTree
77
- }) => `tool to execute bash commands, the file tree is: ${fileTree}`;
82
+ }) => `Execute shell commands in a bash environment.
83
+
84
+ Use this tool to:
85
+ - Run shell commands (ls, cat, grep, find, etc.)
86
+ - Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
87
+ - Inspect files and directories
88
+
89
+ Current file tree:
90
+ ${fileTree}`;
78
91
  var bashTool = {
79
92
  name: "Bash",
80
- description: "tool to execute bash commands",
81
- schema: z4.object({
82
- command: z4.string().describe("stringified command to be executed inside the Bash")
93
+ description: `Execute shell commands in a sandboxed bash environment.
94
+
95
+ Use this tool to:
96
+ - Run shell commands (ls, cat, grep, find, etc.)
97
+ - Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
98
+ - Inspect files and directories
99
+ `,
100
+ schema: z5.object({
101
+ command: z5.string().describe(
102
+ "The bash command to execute. Can include pipes (|), redirects (>, >>), logical operators (&&, ||), and shell features like command substitution $(...)."
103
+ )
83
104
  }),
84
105
  strict: true
85
106
  };
@@ -124,17 +145,17 @@ var taskCreateTool = {
124
145
  - Include enough detail in the description for another agent to understand and complete the task
125
146
  - After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
126
147
  - Check TaskList first to avoid creating duplicate tasks`,
127
- schema: z4.object({
128
- subject: z4.string().describe(
148
+ schema: z5.object({
149
+ subject: z5.string().describe(
129
150
  'A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")'
130
151
  ),
131
- description: z4.string().describe(
152
+ description: z5.string().describe(
132
153
  "Detailed description of what needs to be done, including context and acceptance criteria"
133
154
  ),
134
- activeForm: z4.string().describe(
155
+ activeForm: z5.string().describe(
135
156
  '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.'
136
157
  ),
137
- metadata: z4.record(z4.string(), z4.string()).describe("Arbitrary key-value pairs for tracking")
158
+ metadata: z5.record(z5.string(), z5.string()).describe("Arbitrary key-value pairs for tracking")
138
159
  })
139
160
  };
140
161
 
@@ -158,9 +179,30 @@ function createToolRouter(options) {
158
179
  toolMap.set(tool.name, tool);
159
180
  }
160
181
  if (options.subagents) {
182
+ const subagentHooksMap = /* @__PURE__ */ new Map();
183
+ for (const s of options.subagents) {
184
+ if (s.hooks) subagentHooksMap.set(s.name, s.hooks);
185
+ }
186
+ const resolveSubagentName = (args) => args.subagent;
161
187
  toolMap.set("Task", {
162
188
  ...createTaskTool(options.subagents),
163
- handler: createTaskHandler(options.subagents)
189
+ handler: createTaskHandler(options.subagents),
190
+ ...subagentHooksMap.size > 0 && {
191
+ hooks: {
192
+ onPreToolUse: async (ctx) => {
193
+ const hooks = subagentHooksMap.get(resolveSubagentName(ctx.args));
194
+ return hooks?.onPreExecution?.(ctx) ?? {};
195
+ },
196
+ onPostToolUse: async (ctx) => {
197
+ const hooks = subagentHooksMap.get(resolveSubagentName(ctx.args));
198
+ await hooks?.onPostExecution?.(ctx);
199
+ },
200
+ onPostToolUseFailure: async (ctx) => {
201
+ const hooks = subagentHooksMap.get(resolveSubagentName(ctx.args));
202
+ return hooks?.onExecutionFailure?.(ctx) ?? {};
203
+ }
204
+ }
205
+ }
164
206
  });
165
207
  }
166
208
  if (options.buildInTools) {
@@ -183,6 +225,8 @@ function createToolRouter(options) {
183
225
  }
184
226
  async function processToolCall(toolCall, turn, handlerContext) {
185
227
  const startTime = Date.now();
228
+ const tool = toolMap.get(toolCall.name);
229
+ const toolHooks = tool?.hooks;
186
230
  let effectiveArgs = toolCall.args;
187
231
  if (options.hooks?.onPreToolUse) {
188
232
  const preResult = await options.hooks.onPreToolUse({
@@ -205,7 +249,27 @@ function createToolRouter(options) {
205
249
  effectiveArgs = preResult.modifiedArgs;
206
250
  }
207
251
  }
208
- const tool = toolMap.get(toolCall.name);
252
+ if (toolHooks?.onPreToolUse) {
253
+ const preResult = await toolHooks.onPreToolUse({
254
+ args: effectiveArgs,
255
+ threadId: options.threadId,
256
+ turn
257
+ });
258
+ if (preResult?.skip) {
259
+ await appendToolResult({
260
+ threadId: options.threadId,
261
+ toolCallId: toolCall.id,
262
+ content: JSON.stringify({
263
+ skipped: true,
264
+ reason: "Skipped by tool PreToolUse hook"
265
+ })
266
+ });
267
+ return null;
268
+ }
269
+ if (preResult?.modifiedArgs !== void 0) {
270
+ effectiveArgs = preResult.modifiedArgs;
271
+ }
272
+ }
209
273
  let result;
210
274
  let content;
211
275
  try {
@@ -214,30 +278,50 @@ function createToolRouter(options) {
214
278
  effectiveArgs,
215
279
  handlerContext ?? {}
216
280
  );
217
- result = response.result;
218
- content = response.content;
281
+ result = response.data;
282
+ content = response.toolResponse;
219
283
  } else {
220
284
  result = { error: `Unknown tool: ${toolCall.name}` };
221
285
  content = JSON.stringify(result, null, 2);
222
286
  }
223
287
  } catch (error) {
224
- if (options.hooks?.onPostToolUseFailure) {
288
+ const err = error instanceof Error ? error : new Error(String(error));
289
+ let recovered = false;
290
+ if (toolHooks?.onPostToolUseFailure) {
291
+ const failureResult = await toolHooks.onPostToolUseFailure({
292
+ args: effectiveArgs,
293
+ error: err,
294
+ threadId: options.threadId,
295
+ turn
296
+ });
297
+ if (failureResult?.fallbackContent !== void 0) {
298
+ content = failureResult.fallbackContent;
299
+ result = { error: String(error), recovered: true };
300
+ recovered = true;
301
+ } else if (failureResult?.suppress) {
302
+ content = JSON.stringify({ error: String(error), suppressed: true });
303
+ result = { error: String(error), suppressed: true };
304
+ recovered = true;
305
+ }
306
+ }
307
+ if (!recovered && options.hooks?.onPostToolUseFailure) {
225
308
  const failureResult = await options.hooks.onPostToolUseFailure({
226
309
  toolCall,
227
- error: error instanceof Error ? error : new Error(String(error)),
310
+ error: err,
228
311
  threadId: options.threadId,
229
312
  turn
230
313
  });
231
314
  if (failureResult?.fallbackContent !== void 0) {
232
315
  content = failureResult.fallbackContent;
233
316
  result = { error: String(error), recovered: true };
317
+ recovered = true;
234
318
  } else if (failureResult?.suppress) {
235
319
  content = JSON.stringify({ error: String(error), suppressed: true });
236
320
  result = { error: String(error), suppressed: true };
237
- } else {
238
- throw error;
321
+ recovered = true;
239
322
  }
240
- } else {
323
+ }
324
+ if (!recovered) {
241
325
  throw error;
242
326
  }
243
327
  }
@@ -249,10 +333,19 @@ function createToolRouter(options) {
249
333
  const toolResult = {
250
334
  toolCallId: toolCall.id,
251
335
  name: toolCall.name,
252
- result
336
+ data: result
253
337
  };
338
+ const durationMs = Date.now() - startTime;
339
+ if (toolHooks?.onPostToolUse) {
340
+ await toolHooks.onPostToolUse({
341
+ args: effectiveArgs,
342
+ result,
343
+ threadId: options.threadId,
344
+ turn,
345
+ durationMs
346
+ });
347
+ }
254
348
  if (options.hooks?.onPostToolUse) {
255
- const durationMs = Date.now() - startTime;
256
349
  await options.hooks.onPostToolUse({
257
350
  toolCall,
258
351
  result: toolResult,
@@ -333,12 +426,12 @@ function createToolRouter(options) {
333
426
  await appendToolResult({
334
427
  threadId: options.threadId,
335
428
  toolCallId: toolCall.id,
336
- content: response.content
429
+ content: response.toolResponse
337
430
  });
338
431
  return {
339
432
  toolCallId: toolCall.id,
340
433
  name: toolCall.name,
341
- result: response.result
434
+ data: response.data ?? null
342
435
  };
343
436
  };
344
437
  if (options.parallel) {
@@ -364,6 +457,12 @@ function createToolRouter(options) {
364
457
  }
365
458
  };
366
459
  }
460
+ function defineTool(tool) {
461
+ return tool;
462
+ }
463
+ function defineSubagent(config) {
464
+ return config;
465
+ }
367
466
  function hasNoOtherToolCalls(toolCalls, excludeName) {
368
467
  return toolCalls.filter((tc) => tc.name !== excludeName).length === 0;
369
468
  }
@@ -468,17 +567,47 @@ var createSession = async ({
468
567
  return message;
469
568
  }
470
569
  const rawToolCalls = await parseToolCalls(message);
471
- const parsedToolCalls = rawToolCalls.filter((tc) => tc.name !== "Task").map((tc) => toolRouter.parseToolCall(tc));
472
- const taskToolCalls = subagents && subagents.length > 0 ? rawToolCalls.filter((tc) => tc.name === "Task").map((tc) => {
473
- const parsedArgs = createTaskTool(subagents).schema.parse(
474
- tc.args
475
- );
476
- return {
477
- id: tc.id ?? "",
478
- name: tc.name,
479
- args: parsedArgs
480
- };
481
- }) : [];
570
+ const parsedToolCalls = [];
571
+ for (const tc of rawToolCalls.filter(
572
+ (tc2) => tc2.name !== "Task"
573
+ )) {
574
+ try {
575
+ parsedToolCalls.push(toolRouter.parseToolCall(tc));
576
+ } catch (error) {
577
+ await appendToolResult({
578
+ threadId,
579
+ toolCallId: tc.id ?? "",
580
+ content: JSON.stringify({
581
+ error: `Invalid tool call for "${tc.name}": ${error instanceof Error ? error.message : String(error)}`
582
+ })
583
+ });
584
+ }
585
+ }
586
+ const taskToolCalls = [];
587
+ if (subagents && subagents.length > 0) {
588
+ for (const tc of rawToolCalls.filter(
589
+ (tc2) => tc2.name === "Task"
590
+ )) {
591
+ try {
592
+ const parsedArgs = createTaskTool(subagents).schema.parse(
593
+ tc.args
594
+ );
595
+ taskToolCalls.push({
596
+ id: tc.id ?? "",
597
+ name: tc.name,
598
+ args: parsedArgs
599
+ });
600
+ } catch (error) {
601
+ await appendToolResult({
602
+ threadId,
603
+ toolCallId: tc.id ?? "",
604
+ content: JSON.stringify({
605
+ error: `Invalid tool call for "Task": ${error instanceof Error ? error.message : String(error)}`
606
+ })
607
+ });
608
+ }
609
+ }
610
+ }
482
611
  await toolRouter.processToolCalls(
483
612
  [...parsedToolCalls, ...taskToolCalls],
484
613
  {
@@ -508,8 +637,6 @@ var createSession = async ({
508
637
  function isTerminalStatus(status) {
509
638
  return status === "COMPLETED" || status === "FAILED" || status === "CANCELLED";
510
639
  }
511
-
512
- // src/lib/state-manager.ts
513
640
  var getStateQuery = defineQuery("getState");
514
641
  function createAgentStateManager(initialState) {
515
642
  let status = initialState?.status ?? "RUNNING";
@@ -604,7 +731,13 @@ function createAgentStateManager(initialState) {
604
731
  version++;
605
732
  },
606
733
  setTools(newTools) {
607
- tools = newTools;
734
+ tools = newTools.map((tool) => ({
735
+ name: tool.name,
736
+ description: tool.description,
737
+ schema: z.toJSONSchema(tool.schema),
738
+ strict: tool.strict,
739
+ max_uses: tool.max_uses
740
+ }));
608
741
  },
609
742
  deleteTask(id) {
610
743
  const deleted = tasks.delete(id);
@@ -635,18 +768,18 @@ Usage notes:
635
768
  * Use multiSelect: true to allow multiple answers to be selected for a question
636
769
  * If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
637
770
  `,
638
- schema: z4.object({
639
- questions: z4.array(
640
- z4.object({
641
- question: z4.string().describe("The full question text to display"),
642
- header: z4.string().describe("Short label for the question (max 12 characters)"),
643
- options: z4.array(
644
- z4.object({
645
- label: z4.string(),
646
- description: z4.string()
771
+ schema: z5.object({
772
+ questions: z5.array(
773
+ z5.object({
774
+ question: z5.string().describe("The full question text to display"),
775
+ header: z5.string().describe("Short label for the question (max 12 characters)"),
776
+ options: z5.array(
777
+ z5.object({
778
+ label: z5.string(),
779
+ description: z5.string()
647
780
  })
648
781
  ).min(0).max(4).describe("Array of 0-4 choices, each with label and description"),
649
- multiSelect: z4.boolean().describe("If true, users can select multiple options")
782
+ multiSelect: z5.boolean().describe("If true, users can select multiple options")
650
783
  })
651
784
  )
652
785
  }),
@@ -767,15 +900,10 @@ IMPORTANT:
767
900
  }),
768
901
  strict: true
769
902
  };
770
-
771
- // src/tools/task-create/handler.ts
772
- function createTaskCreateHandler({
773
- stateManager,
774
- idGenerator
775
- }) {
903
+ function createTaskCreateHandler(stateManager) {
776
904
  return (args) => {
777
905
  const task = {
778
- id: idGenerator(),
906
+ id: uuid4(),
779
907
  subject: args.subject,
780
908
  description: args.description,
781
909
  activeForm: args.activeForm,
@@ -786,16 +914,16 @@ function createTaskCreateHandler({
786
914
  };
787
915
  stateManager.setTask(task);
788
916
  return {
789
- content: JSON.stringify(task, null, 2),
790
- result: task
917
+ toolResponse: JSON.stringify(task, null, 2),
918
+ data: task
791
919
  };
792
920
  };
793
921
  }
794
922
  var taskGetTool = {
795
923
  name: "TaskGet",
796
924
  description: `Retrieve full task details including dependencies.`,
797
- schema: z4.object({
798
- taskId: z4.string().describe("The ID of the task to get")
925
+ schema: z5.object({
926
+ taskId: z5.string().describe("The ID of the task to get")
799
927
  })
800
928
  };
801
929
 
@@ -805,20 +933,20 @@ function createTaskGetHandler(stateManager) {
805
933
  const task = stateManager.getTask(args.taskId) ?? null;
806
934
  if (!task) {
807
935
  return {
808
- content: JSON.stringify({ error: `Task not found: ${args.taskId}` }),
809
- result: null
936
+ toolResponse: JSON.stringify({ error: `Task not found: ${args.taskId}` }),
937
+ data: null
810
938
  };
811
939
  }
812
940
  return {
813
- content: JSON.stringify(task, null, 2),
814
- result: task
941
+ toolResponse: JSON.stringify(task, null, 2),
942
+ data: task
815
943
  };
816
944
  };
817
945
  }
818
946
  var taskListTool = {
819
947
  name: "TaskList",
820
948
  description: `List all tasks with current state.`,
821
- schema: z4.object({})
949
+ schema: z5.object({})
822
950
  };
823
951
 
824
952
  // src/tools/task-list/handler.ts
@@ -826,19 +954,19 @@ function createTaskListHandler(stateManager) {
826
954
  return (_args) => {
827
955
  const taskList = stateManager.getTasks();
828
956
  return {
829
- content: JSON.stringify(taskList, null, 2),
830
- result: taskList
957
+ toolResponse: JSON.stringify(taskList, null, 2),
958
+ data: taskList
831
959
  };
832
960
  };
833
961
  }
834
962
  var taskUpdateTool = {
835
963
  name: "TaskUpdate",
836
964
  description: `Update status, add blockers, modify details.`,
837
- schema: z4.object({
838
- taskId: z4.string().describe("The ID of the task to get"),
839
- status: z4.enum(["pending", "in_progress", "completed"]).describe("The status of the task"),
840
- addBlockedBy: z4.array(z4.string()).describe("The IDs of the tasks that are blocking this task"),
841
- addBlocks: z4.array(z4.string()).describe("The IDs of the tasks that this task is blocking")
965
+ schema: z5.object({
966
+ taskId: z5.string().describe("The ID of the task to get"),
967
+ status: z5.enum(["pending", "in_progress", "completed"]).describe("The status of the task"),
968
+ addBlockedBy: z5.array(z5.string()).describe("The IDs of the tasks that are blocking this task"),
969
+ addBlocks: z5.array(z5.string()).describe("The IDs of the tasks that this task is blocking")
842
970
  })
843
971
  };
844
972
 
@@ -848,8 +976,8 @@ function createTaskUpdateHandler(stateManager) {
848
976
  const task = stateManager.getTask(args.taskId);
849
977
  if (!task) {
850
978
  return {
851
- content: JSON.stringify({ error: `Task not found: ${args.taskId}` }),
852
- result: null
979
+ toolResponse: JSON.stringify({ error: `Task not found: ${args.taskId}` }),
980
+ data: null
853
981
  };
854
982
  }
855
983
  if (args.status) {
@@ -881,8 +1009,8 @@ function createTaskUpdateHandler(stateManager) {
881
1009
  }
882
1010
  stateManager.setTask(task);
883
1011
  return {
884
- content: JSON.stringify(task, null, 2),
885
- result: task
1012
+ toolResponse: JSON.stringify(task, null, 2),
1013
+ data: task
886
1014
  };
887
1015
  };
888
1016
  }
@@ -1089,13 +1217,13 @@ var handleAskUserQuestionToolResult = async (args) => {
1089
1217
  }
1090
1218
  }).toDict()
1091
1219
  );
1092
- return { content: "Question submitted", result: { chatMessages: messages } };
1220
+ return { toolResponse: "Question submitted", data: { chatMessages: messages } };
1093
1221
  };
1094
1222
  async function globHandler(_args, fs) {
1095
1223
  new Bash({ fs });
1096
1224
  return Promise.resolve({
1097
- content: "Hello, world!",
1098
- result: { files: [] }
1225
+ toolResponse: "Hello, world!",
1226
+ data: { files: [] }
1099
1227
  });
1100
1228
  }
1101
1229
 
@@ -1107,8 +1235,8 @@ async function editHandler(args, fs) {
1107
1235
  const { file_path, old_string, new_string, replace_all = false } = args;
1108
1236
  if (old_string === new_string) {
1109
1237
  return {
1110
- content: `Error: old_string and new_string must be different.`,
1111
- result: {
1238
+ toolResponse: `Error: old_string and new_string must be different.`,
1239
+ data: {
1112
1240
  path: file_path,
1113
1241
  success: false,
1114
1242
  replacements: 0
@@ -1119,8 +1247,8 @@ async function editHandler(args, fs) {
1119
1247
  const exists = await fs.exists(file_path);
1120
1248
  if (!exists) {
1121
1249
  return {
1122
- content: `Error: File "${file_path}" does not exist.`,
1123
- result: {
1250
+ toolResponse: `Error: File "${file_path}" does not exist.`,
1251
+ data: {
1124
1252
  path: file_path,
1125
1253
  success: false,
1126
1254
  replacements: 0
@@ -1130,8 +1258,8 @@ async function editHandler(args, fs) {
1130
1258
  const content = await fs.readFile(file_path);
1131
1259
  if (!content.includes(old_string)) {
1132
1260
  return {
1133
- content: `Error: Could not find the specified text in "${file_path}". Make sure old_string matches exactly (whitespace-sensitive).`,
1134
- result: {
1261
+ toolResponse: `Error: Could not find the specified text in "${file_path}". Make sure old_string matches exactly (whitespace-sensitive).`,
1262
+ data: {
1135
1263
  path: file_path,
1136
1264
  success: false,
1137
1265
  replacements: 0
@@ -1143,8 +1271,8 @@ async function editHandler(args, fs) {
1143
1271
  const occurrences = (content.match(globalRegex) || []).length;
1144
1272
  if (!replace_all && occurrences > 1) {
1145
1273
  return {
1146
- content: `Error: old_string appears ${occurrences} times in "${file_path}". Either provide more context to make it unique, or use replace_all: true.`,
1147
- result: {
1274
+ toolResponse: `Error: old_string appears ${occurrences} times in "${file_path}". Either provide more context to make it unique, or use replace_all: true.`,
1275
+ data: {
1148
1276
  path: file_path,
1149
1277
  success: false,
1150
1278
  replacements: 0
@@ -1164,8 +1292,8 @@ async function editHandler(args, fs) {
1164
1292
  await fs.writeFile(file_path, newContent);
1165
1293
  const summary = replace_all ? `Replaced ${replacements} occurrence(s)` : `Replaced 1 occurrence`;
1166
1294
  return {
1167
- content: `${summary} in ${file_path}`,
1168
- result: {
1295
+ toolResponse: `${summary} in ${file_path}`,
1296
+ data: {
1169
1297
  path: file_path,
1170
1298
  success: true,
1171
1299
  replacements
@@ -1174,8 +1302,8 @@ async function editHandler(args, fs) {
1174
1302
  } catch (error) {
1175
1303
  const message = error instanceof Error ? error.message : "Unknown error";
1176
1304
  return {
1177
- content: `Error editing file "${file_path}": ${message}`,
1178
- result: {
1305
+ toolResponse: `Error editing file "${file_path}": ${message}`,
1306
+ data: {
1179
1307
  path: file_path,
1180
1308
  success: false,
1181
1309
  replacements: 0
@@ -1183,28 +1311,35 @@ async function editHandler(args, fs) {
1183
1311
  };
1184
1312
  }
1185
1313
  }
1186
- var handleBashTool = (fs) => async (args, _context) => {
1314
+ var handleBashTool = (bashOptions) => async (args, _context) => {
1187
1315
  const { command } = args;
1188
- const bashOptions = fs ? { fs } : {};
1189
- const bash = new Bash(bashOptions);
1316
+ const mergedOptions = {
1317
+ ...bashOptions,
1318
+ executionLimits: {
1319
+ maxStringLength: 52428800,
1320
+ // 50MB default
1321
+ ...bashOptions.executionLimits
1322
+ }
1323
+ };
1324
+ const bash = new Bash(mergedOptions);
1190
1325
  try {
1191
1326
  const { exitCode, stderr, stdout } = await bash.exec(command);
1192
1327
  const bashExecOut = { exitCode, stderr, stdout };
1193
1328
  return {
1194
- content: `Exit code: ${exitCode}
1329
+ toolResponse: `Exit code: ${exitCode}
1195
1330
 
1196
1331
  stdout:
1197
1332
  ${stdout}
1198
1333
 
1199
1334
  stderr:
1200
1335
  ${stderr}`,
1201
- result: bashExecOut
1336
+ data: bashExecOut
1202
1337
  };
1203
1338
  } catch (error) {
1204
1339
  const err = error instanceof Error ? error : new Error("Unknown error");
1205
1340
  return {
1206
- content: `Error executing bash command: ${err.message}`,
1207
- result: null
1341
+ toolResponse: `Error executing bash command: ${err.message}`,
1342
+ data: null
1208
1343
  };
1209
1344
  }
1210
1345
  };
@@ -1273,6 +1408,6 @@ var toTree = async (fs, opts = {}) => {
1273
1408
  return base + subtree;
1274
1409
  };
1275
1410
 
1276
- export { AGENT_HANDLER_NAMES, ZeitlichPlugin, askUserQuestionTool, bashTool, createAgentStateManager, createSession, createSharedActivities, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskTool, createTaskUpdateHandler, createToolRouter, editHandler, editTool, globHandler, globTool, grepTool, handleAskUserQuestionToolResult, handleBashTool, hasNoOtherToolCalls, invokeModel, isTerminalStatus, readTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, toTree, writeTool };
1411
+ export { AGENT_HANDLER_NAMES, ZeitlichPlugin, askUserQuestionTool, bashTool, createAgentStateManager, createSession, createSharedActivities, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskTool, createTaskUpdateHandler, createThreadManager, createToolRouter, defineSubagent, defineTool, editHandler, editTool, getStateQuery, globHandler, globTool, grepTool, handleAskUserQuestionToolResult, handleBashTool, hasNoOtherToolCalls, invokeModel, isTerminalStatus, readTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, toTree, writeTool };
1277
1412
  //# sourceMappingURL=index.js.map
1278
1413
  //# sourceMappingURL=index.js.map