zeitlich 0.2.1 → 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/README.md +2 -2
- package/dist/index.cjs +240 -124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +216 -104
- package/dist/index.js.map +1 -1
- package/dist/{workflow-CCoHnc3B.d.cts → workflow-BQf5EfNN.d.cts} +232 -53
- package/dist/{workflow-CCoHnc3B.d.ts → workflow-BQf5EfNN.d.ts} +232 -53
- package/dist/workflow.cjs +219 -105
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +4 -2
- package/dist/workflow.d.ts +4 -2
- package/dist/workflow.js +196 -84
- package/dist/workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/lib/session.ts +50 -24
- package/src/lib/state-manager.ts +9 -2
- package/src/lib/tool-router.ts +205 -23
- package/src/lib/types.ts +79 -4
- package/src/tools/ask-user-question/handler.ts +1 -1
- package/src/tools/bash/bash.test.ts +31 -31
- package/src/tools/bash/handler.ts +4 -4
- package/src/tools/edit/handler.ts +14 -14
- package/src/tools/glob/handler.ts +4 -4
- package/src/tools/task/handler.ts +17 -7
- package/src/tools/task/tool.ts +1 -1
- package/src/tools/task-create/handler.ts +7 -10
- package/src/tools/task-get/handler.ts +4 -4
- package/src/tools/task-list/handler.ts +2 -2
- package/src/tools/task-update/handler.ts +4 -4
- package/src/workflow.ts +3 -1
package/dist/workflow.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var workflow = require('@temporalio/workflow');
|
|
4
|
-
var
|
|
4
|
+
var z5 = require('zod');
|
|
5
5
|
|
|
6
6
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var z5__default = /*#__PURE__*/_interopDefault(z5);
|
|
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:
|
|
44
|
-
subagent:
|
|
45
|
-
description:
|
|
46
|
-
prompt:
|
|
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")
|
|
47
47
|
})
|
|
48
48
|
};
|
|
49
49
|
}
|
|
@@ -57,16 +57,21 @@ function createTaskHandler(subagents) {
|
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
const childWorkflowId = `${parentWorkflowId}-${args.subagent}-${workflow.uuid4()}`;
|
|
60
|
-
const
|
|
60
|
+
const input = {
|
|
61
|
+
prompt: args.prompt,
|
|
62
|
+
...config.context && { context: config.context }
|
|
63
|
+
};
|
|
64
|
+
const childOpts = {
|
|
61
65
|
workflowId: childWorkflowId,
|
|
62
|
-
args: [
|
|
66
|
+
args: [input],
|
|
63
67
|
taskQueue: config.taskQueue ?? parentTaskQueue
|
|
64
|
-
}
|
|
68
|
+
};
|
|
69
|
+
const childResult = typeof config.workflow === "string" ? await workflow.executeChild(config.workflow, childOpts) : await workflow.executeChild(config.workflow, childOpts);
|
|
65
70
|
const validated = config.resultSchema ? config.resultSchema.parse(childResult) : childResult;
|
|
66
|
-
const
|
|
71
|
+
const toolResponse = typeof validated === "string" ? validated : JSON.stringify(validated, null, 2);
|
|
67
72
|
return {
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
toolResponse,
|
|
74
|
+
data: {
|
|
70
75
|
result: validated,
|
|
71
76
|
childWorkflowId
|
|
72
77
|
}
|
|
@@ -93,8 +98,8 @@ Use this tool to:
|
|
|
93
98
|
- Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
|
|
94
99
|
- Inspect files and directories
|
|
95
100
|
`,
|
|
96
|
-
schema:
|
|
97
|
-
command:
|
|
101
|
+
schema: z5__default.default.object({
|
|
102
|
+
command: z5__default.default.string().describe(
|
|
98
103
|
"The bash command to execute. Can include pipes (|), redirects (>, >>), logical operators (&&, ||), and shell features like command substitution $(...)."
|
|
99
104
|
)
|
|
100
105
|
}),
|
|
@@ -141,17 +146,17 @@ var taskCreateTool = {
|
|
|
141
146
|
- Include enough detail in the description for another agent to understand and complete the task
|
|
142
147
|
- After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
|
|
143
148
|
- Check TaskList first to avoid creating duplicate tasks`,
|
|
144
|
-
schema:
|
|
145
|
-
subject:
|
|
149
|
+
schema: z5__default.default.object({
|
|
150
|
+
subject: z5__default.default.string().describe(
|
|
146
151
|
'A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")'
|
|
147
152
|
),
|
|
148
|
-
description:
|
|
153
|
+
description: z5__default.default.string().describe(
|
|
149
154
|
"Detailed description of what needs to be done, including context and acceptance criteria"
|
|
150
155
|
),
|
|
151
|
-
activeForm:
|
|
156
|
+
activeForm: z5__default.default.string().describe(
|
|
152
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.'
|
|
153
158
|
),
|
|
154
|
-
metadata:
|
|
159
|
+
metadata: z5__default.default.record(z5__default.default.string(), z5__default.default.string()).describe("Arbitrary key-value pairs for tracking")
|
|
155
160
|
})
|
|
156
161
|
};
|
|
157
162
|
|
|
@@ -175,9 +180,30 @@ function createToolRouter(options) {
|
|
|
175
180
|
toolMap.set(tool.name, tool);
|
|
176
181
|
}
|
|
177
182
|
if (options.subagents) {
|
|
183
|
+
const subagentHooksMap = /* @__PURE__ */ new Map();
|
|
184
|
+
for (const s of options.subagents) {
|
|
185
|
+
if (s.hooks) subagentHooksMap.set(s.name, s.hooks);
|
|
186
|
+
}
|
|
187
|
+
const resolveSubagentName = (args) => args.subagent;
|
|
178
188
|
toolMap.set("Task", {
|
|
179
189
|
...createTaskTool(options.subagents),
|
|
180
|
-
handler: createTaskHandler(options.subagents)
|
|
190
|
+
handler: createTaskHandler(options.subagents),
|
|
191
|
+
...subagentHooksMap.size > 0 && {
|
|
192
|
+
hooks: {
|
|
193
|
+
onPreToolUse: async (ctx) => {
|
|
194
|
+
const hooks = subagentHooksMap.get(resolveSubagentName(ctx.args));
|
|
195
|
+
return hooks?.onPreExecution?.(ctx) ?? {};
|
|
196
|
+
},
|
|
197
|
+
onPostToolUse: async (ctx) => {
|
|
198
|
+
const hooks = subagentHooksMap.get(resolveSubagentName(ctx.args));
|
|
199
|
+
await hooks?.onPostExecution?.(ctx);
|
|
200
|
+
},
|
|
201
|
+
onPostToolUseFailure: async (ctx) => {
|
|
202
|
+
const hooks = subagentHooksMap.get(resolveSubagentName(ctx.args));
|
|
203
|
+
return hooks?.onExecutionFailure?.(ctx) ?? {};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
181
207
|
});
|
|
182
208
|
}
|
|
183
209
|
if (options.buildInTools) {
|
|
@@ -200,6 +226,8 @@ function createToolRouter(options) {
|
|
|
200
226
|
}
|
|
201
227
|
async function processToolCall(toolCall, turn, handlerContext) {
|
|
202
228
|
const startTime = Date.now();
|
|
229
|
+
const tool = toolMap.get(toolCall.name);
|
|
230
|
+
const toolHooks = tool?.hooks;
|
|
203
231
|
let effectiveArgs = toolCall.args;
|
|
204
232
|
if (options.hooks?.onPreToolUse) {
|
|
205
233
|
const preResult = await options.hooks.onPreToolUse({
|
|
@@ -222,7 +250,27 @@ function createToolRouter(options) {
|
|
|
222
250
|
effectiveArgs = preResult.modifiedArgs;
|
|
223
251
|
}
|
|
224
252
|
}
|
|
225
|
-
|
|
253
|
+
if (toolHooks?.onPreToolUse) {
|
|
254
|
+
const preResult = await toolHooks.onPreToolUse({
|
|
255
|
+
args: effectiveArgs,
|
|
256
|
+
threadId: options.threadId,
|
|
257
|
+
turn
|
|
258
|
+
});
|
|
259
|
+
if (preResult?.skip) {
|
|
260
|
+
await appendToolResult({
|
|
261
|
+
threadId: options.threadId,
|
|
262
|
+
toolCallId: toolCall.id,
|
|
263
|
+
content: JSON.stringify({
|
|
264
|
+
skipped: true,
|
|
265
|
+
reason: "Skipped by tool PreToolUse hook"
|
|
266
|
+
})
|
|
267
|
+
});
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
if (preResult?.modifiedArgs !== void 0) {
|
|
271
|
+
effectiveArgs = preResult.modifiedArgs;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
226
274
|
let result;
|
|
227
275
|
let content;
|
|
228
276
|
try {
|
|
@@ -231,30 +279,50 @@ function createToolRouter(options) {
|
|
|
231
279
|
effectiveArgs,
|
|
232
280
|
handlerContext ?? {}
|
|
233
281
|
);
|
|
234
|
-
result = response.
|
|
235
|
-
content = response.
|
|
282
|
+
result = response.data;
|
|
283
|
+
content = response.toolResponse;
|
|
236
284
|
} else {
|
|
237
285
|
result = { error: `Unknown tool: ${toolCall.name}` };
|
|
238
286
|
content = JSON.stringify(result, null, 2);
|
|
239
287
|
}
|
|
240
288
|
} catch (error) {
|
|
241
|
-
|
|
289
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
290
|
+
let recovered = false;
|
|
291
|
+
if (toolHooks?.onPostToolUseFailure) {
|
|
292
|
+
const failureResult = await toolHooks.onPostToolUseFailure({
|
|
293
|
+
args: effectiveArgs,
|
|
294
|
+
error: err,
|
|
295
|
+
threadId: options.threadId,
|
|
296
|
+
turn
|
|
297
|
+
});
|
|
298
|
+
if (failureResult?.fallbackContent !== void 0) {
|
|
299
|
+
content = failureResult.fallbackContent;
|
|
300
|
+
result = { error: String(error), recovered: true };
|
|
301
|
+
recovered = true;
|
|
302
|
+
} else if (failureResult?.suppress) {
|
|
303
|
+
content = JSON.stringify({ error: String(error), suppressed: true });
|
|
304
|
+
result = { error: String(error), suppressed: true };
|
|
305
|
+
recovered = true;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (!recovered && options.hooks?.onPostToolUseFailure) {
|
|
242
309
|
const failureResult = await options.hooks.onPostToolUseFailure({
|
|
243
310
|
toolCall,
|
|
244
|
-
error:
|
|
311
|
+
error: err,
|
|
245
312
|
threadId: options.threadId,
|
|
246
313
|
turn
|
|
247
314
|
});
|
|
248
315
|
if (failureResult?.fallbackContent !== void 0) {
|
|
249
316
|
content = failureResult.fallbackContent;
|
|
250
317
|
result = { error: String(error), recovered: true };
|
|
318
|
+
recovered = true;
|
|
251
319
|
} else if (failureResult?.suppress) {
|
|
252
320
|
content = JSON.stringify({ error: String(error), suppressed: true });
|
|
253
321
|
result = { error: String(error), suppressed: true };
|
|
254
|
-
|
|
255
|
-
throw error;
|
|
322
|
+
recovered = true;
|
|
256
323
|
}
|
|
257
|
-
}
|
|
324
|
+
}
|
|
325
|
+
if (!recovered) {
|
|
258
326
|
throw error;
|
|
259
327
|
}
|
|
260
328
|
}
|
|
@@ -266,10 +334,19 @@ function createToolRouter(options) {
|
|
|
266
334
|
const toolResult = {
|
|
267
335
|
toolCallId: toolCall.id,
|
|
268
336
|
name: toolCall.name,
|
|
269
|
-
result
|
|
337
|
+
data: result
|
|
270
338
|
};
|
|
339
|
+
const durationMs = Date.now() - startTime;
|
|
340
|
+
if (toolHooks?.onPostToolUse) {
|
|
341
|
+
await toolHooks.onPostToolUse({
|
|
342
|
+
args: effectiveArgs,
|
|
343
|
+
result,
|
|
344
|
+
threadId: options.threadId,
|
|
345
|
+
turn,
|
|
346
|
+
durationMs
|
|
347
|
+
});
|
|
348
|
+
}
|
|
271
349
|
if (options.hooks?.onPostToolUse) {
|
|
272
|
-
const durationMs = Date.now() - startTime;
|
|
273
350
|
await options.hooks.onPostToolUse({
|
|
274
351
|
toolCall,
|
|
275
352
|
result: toolResult,
|
|
@@ -350,12 +427,12 @@ function createToolRouter(options) {
|
|
|
350
427
|
await appendToolResult({
|
|
351
428
|
threadId: options.threadId,
|
|
352
429
|
toolCallId: toolCall.id,
|
|
353
|
-
content: response.
|
|
430
|
+
content: response.toolResponse
|
|
354
431
|
});
|
|
355
432
|
return {
|
|
356
433
|
toolCallId: toolCall.id,
|
|
357
434
|
name: toolCall.name,
|
|
358
|
-
|
|
435
|
+
data: response.data ?? null
|
|
359
436
|
};
|
|
360
437
|
};
|
|
361
438
|
if (options.parallel) {
|
|
@@ -381,6 +458,12 @@ function createToolRouter(options) {
|
|
|
381
458
|
}
|
|
382
459
|
};
|
|
383
460
|
}
|
|
461
|
+
function defineTool(tool) {
|
|
462
|
+
return tool;
|
|
463
|
+
}
|
|
464
|
+
function defineSubagent(config) {
|
|
465
|
+
return config;
|
|
466
|
+
}
|
|
384
467
|
function hasNoOtherToolCalls(toolCalls, excludeName) {
|
|
385
468
|
return toolCalls.filter((tc) => tc.name !== excludeName).length === 0;
|
|
386
469
|
}
|
|
@@ -485,17 +568,47 @@ var createSession = async ({
|
|
|
485
568
|
return message;
|
|
486
569
|
}
|
|
487
570
|
const rawToolCalls = await parseToolCalls(message);
|
|
488
|
-
const parsedToolCalls =
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
571
|
+
const parsedToolCalls = [];
|
|
572
|
+
for (const tc of rawToolCalls.filter(
|
|
573
|
+
(tc2) => tc2.name !== "Task"
|
|
574
|
+
)) {
|
|
575
|
+
try {
|
|
576
|
+
parsedToolCalls.push(toolRouter.parseToolCall(tc));
|
|
577
|
+
} catch (error) {
|
|
578
|
+
await appendToolResult({
|
|
579
|
+
threadId,
|
|
580
|
+
toolCallId: tc.id ?? "",
|
|
581
|
+
content: JSON.stringify({
|
|
582
|
+
error: `Invalid tool call for "${tc.name}": ${error instanceof Error ? error.message : String(error)}`
|
|
583
|
+
})
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
}
|
|
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
|
+
}
|
|
499
612
|
await toolRouter.processToolCalls(
|
|
500
613
|
[...parsedToolCalls, ...taskToolCalls],
|
|
501
614
|
{
|
|
@@ -525,8 +638,6 @@ var createSession = async ({
|
|
|
525
638
|
function isTerminalStatus(status) {
|
|
526
639
|
return status === "COMPLETED" || status === "FAILED" || status === "CANCELLED";
|
|
527
640
|
}
|
|
528
|
-
|
|
529
|
-
// src/lib/state-manager.ts
|
|
530
641
|
var getStateQuery = workflow.defineQuery("getState");
|
|
531
642
|
function createAgentStateManager(initialState) {
|
|
532
643
|
let status = initialState?.status ?? "RUNNING";
|
|
@@ -621,7 +732,13 @@ function createAgentStateManager(initialState) {
|
|
|
621
732
|
version++;
|
|
622
733
|
},
|
|
623
734
|
setTools(newTools) {
|
|
624
|
-
tools = newTools
|
|
735
|
+
tools = newTools.map((tool) => ({
|
|
736
|
+
name: tool.name,
|
|
737
|
+
description: tool.description,
|
|
738
|
+
schema: z5.z.toJSONSchema(tool.schema),
|
|
739
|
+
strict: tool.strict,
|
|
740
|
+
max_uses: tool.max_uses
|
|
741
|
+
}));
|
|
625
742
|
},
|
|
626
743
|
deleteTask(id) {
|
|
627
744
|
const deleted = tasks.delete(id);
|
|
@@ -652,18 +769,18 @@ Usage notes:
|
|
|
652
769
|
* Use multiSelect: true to allow multiple answers to be selected for a question
|
|
653
770
|
* If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
|
654
771
|
`,
|
|
655
|
-
schema:
|
|
656
|
-
questions:
|
|
657
|
-
|
|
658
|
-
question:
|
|
659
|
-
header:
|
|
660
|
-
options:
|
|
661
|
-
|
|
662
|
-
label:
|
|
663
|
-
description:
|
|
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()
|
|
664
781
|
})
|
|
665
782
|
).min(0).max(4).describe("Array of 0-4 choices, each with label and description"),
|
|
666
|
-
multiSelect:
|
|
783
|
+
multiSelect: z5__default.default.boolean().describe("If true, users can select multiple options")
|
|
667
784
|
})
|
|
668
785
|
)
|
|
669
786
|
}),
|
|
@@ -683,9 +800,9 @@ Examples:
|
|
|
683
800
|
- "**/*.test.ts" - Find all test files recursively
|
|
684
801
|
- "src/**/*.ts" - Find all TypeScript files in src directory
|
|
685
802
|
`,
|
|
686
|
-
schema:
|
|
687
|
-
pattern:
|
|
688
|
-
root:
|
|
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")
|
|
689
806
|
}),
|
|
690
807
|
strict: true
|
|
691
808
|
};
|
|
@@ -703,13 +820,13 @@ Examples:
|
|
|
703
820
|
- Search for function definitions with "function.*handleClick"
|
|
704
821
|
- Search case-insensitively with ignoreCase: true
|
|
705
822
|
`,
|
|
706
|
-
schema:
|
|
707
|
-
pattern:
|
|
708
|
-
ignoreCase:
|
|
709
|
-
maxMatches:
|
|
710
|
-
includePatterns:
|
|
711
|
-
excludePatterns:
|
|
712
|
-
contextLines:
|
|
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")
|
|
713
830
|
}),
|
|
714
831
|
strict: true
|
|
715
832
|
};
|
|
@@ -727,12 +844,12 @@ The tool returns the file content in an appropriate format:
|
|
|
727
844
|
- Images: Base64-encoded image data
|
|
728
845
|
- PDFs: Extracted text content
|
|
729
846
|
`,
|
|
730
|
-
schema:
|
|
731
|
-
path:
|
|
732
|
-
offset:
|
|
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(
|
|
733
850
|
"Line number to start reading from (1-indexed, for text files)"
|
|
734
851
|
),
|
|
735
|
-
limit:
|
|
852
|
+
limit: z5.z.number().optional().describe("Maximum number of lines to read (for text files)")
|
|
736
853
|
}),
|
|
737
854
|
strict: true
|
|
738
855
|
};
|
|
@@ -750,9 +867,9 @@ IMPORTANT:
|
|
|
750
867
|
- This is an atomic write operation - the entire file is replaced
|
|
751
868
|
- Path must be absolute (e.g., "/docs/readme.md", not "docs/readme.md")
|
|
752
869
|
`,
|
|
753
|
-
schema:
|
|
754
|
-
file_path:
|
|
755
|
-
content:
|
|
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")
|
|
756
873
|
}),
|
|
757
874
|
strict: true
|
|
758
875
|
};
|
|
@@ -772,27 +889,22 @@ IMPORTANT:
|
|
|
772
889
|
- The operation fails if old_string is not found
|
|
773
890
|
- old_string and new_string must be different
|
|
774
891
|
`,
|
|
775
|
-
schema:
|
|
776
|
-
file_path:
|
|
777
|
-
old_string:
|
|
778
|
-
new_string:
|
|
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(
|
|
779
896
|
"The text to replace it with (must be different from old_string)"
|
|
780
897
|
),
|
|
781
|
-
replace_all:
|
|
898
|
+
replace_all: z5.z.boolean().optional().describe(
|
|
782
899
|
"If true, replace all occurrences of old_string (default: false)"
|
|
783
900
|
)
|
|
784
901
|
}),
|
|
785
902
|
strict: true
|
|
786
903
|
};
|
|
787
|
-
|
|
788
|
-
// src/tools/task-create/handler.ts
|
|
789
|
-
function createTaskCreateHandler({
|
|
790
|
-
stateManager,
|
|
791
|
-
idGenerator
|
|
792
|
-
}) {
|
|
904
|
+
function createTaskCreateHandler(stateManager) {
|
|
793
905
|
return (args) => {
|
|
794
906
|
const task = {
|
|
795
|
-
id:
|
|
907
|
+
id: workflow.uuid4(),
|
|
796
908
|
subject: args.subject,
|
|
797
909
|
description: args.description,
|
|
798
910
|
activeForm: args.activeForm,
|
|
@@ -803,16 +915,16 @@ function createTaskCreateHandler({
|
|
|
803
915
|
};
|
|
804
916
|
stateManager.setTask(task);
|
|
805
917
|
return {
|
|
806
|
-
|
|
807
|
-
|
|
918
|
+
toolResponse: JSON.stringify(task, null, 2),
|
|
919
|
+
data: task
|
|
808
920
|
};
|
|
809
921
|
};
|
|
810
922
|
}
|
|
811
923
|
var taskGetTool = {
|
|
812
924
|
name: "TaskGet",
|
|
813
925
|
description: `Retrieve full task details including dependencies.`,
|
|
814
|
-
schema:
|
|
815
|
-
taskId:
|
|
926
|
+
schema: z5__default.default.object({
|
|
927
|
+
taskId: z5__default.default.string().describe("The ID of the task to get")
|
|
816
928
|
})
|
|
817
929
|
};
|
|
818
930
|
|
|
@@ -822,20 +934,20 @@ function createTaskGetHandler(stateManager) {
|
|
|
822
934
|
const task = stateManager.getTask(args.taskId) ?? null;
|
|
823
935
|
if (!task) {
|
|
824
936
|
return {
|
|
825
|
-
|
|
826
|
-
|
|
937
|
+
toolResponse: JSON.stringify({ error: `Task not found: ${args.taskId}` }),
|
|
938
|
+
data: null
|
|
827
939
|
};
|
|
828
940
|
}
|
|
829
941
|
return {
|
|
830
|
-
|
|
831
|
-
|
|
942
|
+
toolResponse: JSON.stringify(task, null, 2),
|
|
943
|
+
data: task
|
|
832
944
|
};
|
|
833
945
|
};
|
|
834
946
|
}
|
|
835
947
|
var taskListTool = {
|
|
836
948
|
name: "TaskList",
|
|
837
949
|
description: `List all tasks with current state.`,
|
|
838
|
-
schema:
|
|
950
|
+
schema: z5__default.default.object({})
|
|
839
951
|
};
|
|
840
952
|
|
|
841
953
|
// src/tools/task-list/handler.ts
|
|
@@ -843,19 +955,19 @@ function createTaskListHandler(stateManager) {
|
|
|
843
955
|
return (_args) => {
|
|
844
956
|
const taskList = stateManager.getTasks();
|
|
845
957
|
return {
|
|
846
|
-
|
|
847
|
-
|
|
958
|
+
toolResponse: JSON.stringify(taskList, null, 2),
|
|
959
|
+
data: taskList
|
|
848
960
|
};
|
|
849
961
|
};
|
|
850
962
|
}
|
|
851
963
|
var taskUpdateTool = {
|
|
852
964
|
name: "TaskUpdate",
|
|
853
965
|
description: `Update status, add blockers, modify details.`,
|
|
854
|
-
schema:
|
|
855
|
-
taskId:
|
|
856
|
-
status:
|
|
857
|
-
addBlockedBy:
|
|
858
|
-
addBlocks:
|
|
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")
|
|
859
971
|
})
|
|
860
972
|
};
|
|
861
973
|
|
|
@@ -865,8 +977,8 @@ function createTaskUpdateHandler(stateManager) {
|
|
|
865
977
|
const task = stateManager.getTask(args.taskId);
|
|
866
978
|
if (!task) {
|
|
867
979
|
return {
|
|
868
|
-
|
|
869
|
-
|
|
980
|
+
toolResponse: JSON.stringify({ error: `Task not found: ${args.taskId}` }),
|
|
981
|
+
data: null
|
|
870
982
|
};
|
|
871
983
|
}
|
|
872
984
|
if (args.status) {
|
|
@@ -898,8 +1010,8 @@ function createTaskUpdateHandler(stateManager) {
|
|
|
898
1010
|
}
|
|
899
1011
|
stateManager.setTask(task);
|
|
900
1012
|
return {
|
|
901
|
-
|
|
902
|
-
|
|
1013
|
+
toolResponse: JSON.stringify(task, null, 2),
|
|
1014
|
+
data: task
|
|
903
1015
|
};
|
|
904
1016
|
};
|
|
905
1017
|
}
|
|
@@ -915,6 +1027,8 @@ exports.createTaskListHandler = createTaskListHandler;
|
|
|
915
1027
|
exports.createTaskTool = createTaskTool;
|
|
916
1028
|
exports.createTaskUpdateHandler = createTaskUpdateHandler;
|
|
917
1029
|
exports.createToolRouter = createToolRouter;
|
|
1030
|
+
exports.defineSubagent = defineSubagent;
|
|
1031
|
+
exports.defineTool = defineTool;
|
|
918
1032
|
exports.editTool = editTool;
|
|
919
1033
|
exports.globTool = globTool;
|
|
920
1034
|
exports.grepTool = grepTool;
|