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.
- package/README.md +34 -31
- package/dist/index.cjs +305 -361
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -43
- package/dist/index.d.ts +24 -43
- package/dist/index.js +277 -336
- package/dist/index.js.map +1 -1
- package/dist/{workflow-BQf5EfNN.d.cts → workflow-D-2vp4Pq.d.cts} +265 -241
- package/dist/{workflow-BQf5EfNN.d.ts → workflow-D-2vp4Pq.d.ts} +265 -241
- package/dist/workflow.cjs +206 -253
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +2 -3
- package/dist/workflow.d.ts +2 -3
- package/dist/workflow.js +182 -231
- package/dist/workflow.js.map +1 -1
- package/package.json +3 -2
- package/src/activities.ts +1 -14
- package/src/index.ts +14 -11
- package/src/lib/session.ts +56 -99
- package/src/lib/thread-manager.ts +45 -37
- package/src/lib/tool-router.ts +143 -103
- package/src/lib/types.ts +32 -25
- package/src/tools/ask-user-question/handler.ts +5 -5
- package/src/tools/ask-user-question/tool.ts +3 -2
- package/src/tools/bash/bash.test.ts +12 -12
- package/src/tools/bash/handler.ts +5 -5
- package/src/tools/bash/tool.ts +3 -2
- package/src/tools/edit/handler.ts +78 -123
- package/src/tools/edit/tool.ts +3 -2
- package/src/tools/glob/handler.ts +17 -48
- package/src/tools/glob/tool.ts +3 -2
- package/src/tools/grep/tool.ts +3 -2
- package/src/tools/{read → read-file}/tool.ts +3 -2
- package/src/tools/task/handler.ts +2 -2
- package/src/tools/task/tool.ts +2 -9
- package/src/tools/task-create/handler.ts +5 -11
- package/src/tools/task-create/tool.ts +3 -2
- package/src/tools/task-get/handler.ts +5 -10
- package/src/tools/task-get/tool.ts +3 -2
- package/src/tools/task-list/handler.ts +5 -10
- package/src/tools/task-list/tool.ts +3 -2
- package/src/tools/task-update/handler.ts +5 -12
- package/src/tools/task-update/tool.ts +3 -2
- package/src/tools/{write → write-file}/tool.ts +5 -6
- package/src/workflow.ts +23 -19
package/dist/workflow.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineQuery, proxyActivities, setHandler, uuid4, workflowInfo, executeChild } from '@temporalio/workflow';
|
|
2
|
-
import
|
|
2
|
+
import z3, { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
// src/lib/session.ts
|
|
5
5
|
var TASK_TOOL = "Task";
|
|
@@ -34,10 +34,10 @@ function createTaskTool(subagents) {
|
|
|
34
34
|
return {
|
|
35
35
|
name: TASK_TOOL,
|
|
36
36
|
description: buildTaskDescription(subagents),
|
|
37
|
-
schema:
|
|
38
|
-
subagent:
|
|
39
|
-
description:
|
|
40
|
-
prompt:
|
|
37
|
+
schema: z3.object({
|
|
38
|
+
subagent: z3.enum(names).describe("The type of subagent to launch"),
|
|
39
|
+
description: z3.string().describe("A short (3-5 word) description of the task"),
|
|
40
|
+
prompt: z3.string().describe("The task for the agent to perform")
|
|
41
41
|
})
|
|
42
42
|
};
|
|
43
43
|
}
|
|
@@ -72,107 +72,15 @@ function createTaskHandler(subagents) {
|
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
var createBashToolDescription = ({
|
|
76
|
-
fileTree
|
|
77
|
-
}) => `Execute shell commands in a bash environment.
|
|
78
|
-
|
|
79
|
-
Use this tool to:
|
|
80
|
-
- Run shell commands (ls, cat, grep, find, etc.)
|
|
81
|
-
- Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
|
|
82
|
-
- Inspect files and directories
|
|
83
|
-
|
|
84
|
-
Current file tree:
|
|
85
|
-
${fileTree}`;
|
|
86
|
-
var bashTool = {
|
|
87
|
-
name: "Bash",
|
|
88
|
-
description: `Execute shell commands in a sandboxed bash environment.
|
|
89
|
-
|
|
90
|
-
Use this tool to:
|
|
91
|
-
- Run shell commands (ls, cat, grep, find, etc.)
|
|
92
|
-
- Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
|
|
93
|
-
- Inspect files and directories
|
|
94
|
-
`,
|
|
95
|
-
schema: z5.object({
|
|
96
|
-
command: z5.string().describe(
|
|
97
|
-
"The bash command to execute. Can include pipes (|), redirects (>, >>), logical operators (&&, ||), and shell features like command substitution $(...)."
|
|
98
|
-
)
|
|
99
|
-
}),
|
|
100
|
-
strict: true
|
|
101
|
-
};
|
|
102
|
-
var taskCreateTool = {
|
|
103
|
-
name: "TaskCreate",
|
|
104
|
-
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.
|
|
105
|
-
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
106
|
-
|
|
107
|
-
## When to Use This Tool
|
|
108
|
-
|
|
109
|
-
Use this tool proactively in these scenarios:
|
|
110
|
-
|
|
111
|
-
- Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
|
|
112
|
-
- Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
|
|
113
|
-
- User explicitly requests todo list - When the user directly asks you to use the todo list
|
|
114
|
-
- User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
|
|
115
|
-
- After receiving new instructions - Immediately capture user requirements as tasks
|
|
116
|
-
- When you start working on a task - Mark it as in_progress BEFORE beginning work
|
|
117
|
-
- After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
|
|
118
|
-
|
|
119
|
-
## When NOT to Use This Tool
|
|
120
|
-
|
|
121
|
-
Skip using this tool when:
|
|
122
|
-
- There is only a single, straightforward task
|
|
123
|
-
- The task is trivial and tracking it provides no organizational benefit
|
|
124
|
-
- The task can be completed in less than 3 trivial steps
|
|
125
|
-
- The task is purely conversational or informational
|
|
126
|
-
|
|
127
|
-
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.
|
|
128
|
-
|
|
129
|
-
## Task Fields
|
|
130
|
-
|
|
131
|
-
- **subject**: A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")
|
|
132
|
-
- **description**: Detailed description of what needs to be done, including context and acceptance criteria
|
|
133
|
-
- **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.
|
|
134
|
-
|
|
135
|
-
**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\`.
|
|
136
|
-
|
|
137
|
-
## Tips
|
|
138
|
-
|
|
139
|
-
- Create tasks with clear, specific subjects that describe the outcome
|
|
140
|
-
- Include enough detail in the description for another agent to understand and complete the task
|
|
141
|
-
- After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
|
|
142
|
-
- Check TaskList first to avoid creating duplicate tasks`,
|
|
143
|
-
schema: z5.object({
|
|
144
|
-
subject: z5.string().describe(
|
|
145
|
-
'A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")'
|
|
146
|
-
),
|
|
147
|
-
description: z5.string().describe(
|
|
148
|
-
"Detailed description of what needs to be done, including context and acceptance criteria"
|
|
149
|
-
),
|
|
150
|
-
activeForm: z5.string().describe(
|
|
151
|
-
'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.'
|
|
152
|
-
),
|
|
153
|
-
metadata: z5.record(z5.string(), z5.string()).describe("Arbitrary key-value pairs for tracking")
|
|
154
|
-
})
|
|
155
|
-
};
|
|
156
75
|
|
|
157
76
|
// src/lib/tool-router.ts
|
|
158
|
-
var buildIntoolDefinitions = {
|
|
159
|
-
[bashTool.name]: bashTool,
|
|
160
|
-
[taskCreateTool.name]: taskCreateTool
|
|
161
|
-
};
|
|
162
77
|
function createToolRouter(options) {
|
|
163
|
-
const { appendToolResult } =
|
|
164
|
-
startToCloseTimeout: "2m",
|
|
165
|
-
retry: {
|
|
166
|
-
maximumAttempts: 3,
|
|
167
|
-
initialInterval: "5s",
|
|
168
|
-
maximumInterval: "15m",
|
|
169
|
-
backoffCoefficient: 4
|
|
170
|
-
}
|
|
171
|
-
});
|
|
78
|
+
const { appendToolResult } = options;
|
|
172
79
|
const toolMap = /* @__PURE__ */ new Map();
|
|
173
80
|
for (const [_key, tool] of Object.entries(options.tools)) {
|
|
174
81
|
toolMap.set(tool.name, tool);
|
|
175
82
|
}
|
|
83
|
+
const isEnabled = (tool) => tool.enabled !== false;
|
|
176
84
|
if (options.subagents) {
|
|
177
85
|
const subagentHooksMap = /* @__PURE__ */ new Map();
|
|
178
86
|
for (const s of options.subagents) {
|
|
@@ -200,24 +108,6 @@ function createToolRouter(options) {
|
|
|
200
108
|
}
|
|
201
109
|
});
|
|
202
110
|
}
|
|
203
|
-
if (options.buildInTools) {
|
|
204
|
-
for (const [key, value] of Object.entries(options.buildInTools)) {
|
|
205
|
-
if (key === bashTool.name) {
|
|
206
|
-
toolMap.set(key, {
|
|
207
|
-
...buildIntoolDefinitions[key],
|
|
208
|
-
description: createBashToolDescription({
|
|
209
|
-
fileTree: options.fileTree
|
|
210
|
-
}),
|
|
211
|
-
handler: value
|
|
212
|
-
});
|
|
213
|
-
} else {
|
|
214
|
-
toolMap.set(key, {
|
|
215
|
-
...buildIntoolDefinitions[key],
|
|
216
|
-
handler: value
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
111
|
async function processToolCall(toolCall, turn, handlerContext) {
|
|
222
112
|
const startTime = Date.now();
|
|
223
113
|
const tool = toolMap.get(toolCall.name);
|
|
@@ -233,6 +123,7 @@ function createToolRouter(options) {
|
|
|
233
123
|
await appendToolResult({
|
|
234
124
|
threadId: options.threadId,
|
|
235
125
|
toolCallId: toolCall.id,
|
|
126
|
+
toolName: toolCall.name,
|
|
236
127
|
content: JSON.stringify({
|
|
237
128
|
skipped: true,
|
|
238
129
|
reason: "Skipped by PreToolUse hook"
|
|
@@ -254,6 +145,7 @@ function createToolRouter(options) {
|
|
|
254
145
|
await appendToolResult({
|
|
255
146
|
threadId: options.threadId,
|
|
256
147
|
toolCallId: toolCall.id,
|
|
148
|
+
toolName: toolCall.name,
|
|
257
149
|
content: JSON.stringify({
|
|
258
150
|
skipped: true,
|
|
259
151
|
reason: "Skipped by tool PreToolUse hook"
|
|
@@ -267,14 +159,22 @@ function createToolRouter(options) {
|
|
|
267
159
|
}
|
|
268
160
|
let result;
|
|
269
161
|
let content;
|
|
162
|
+
let resultAppended = false;
|
|
270
163
|
try {
|
|
271
164
|
if (tool) {
|
|
165
|
+
const enrichedContext = {
|
|
166
|
+
...handlerContext ?? {},
|
|
167
|
+
threadId: options.threadId,
|
|
168
|
+
toolCallId: toolCall.id,
|
|
169
|
+
toolName: toolCall.name
|
|
170
|
+
};
|
|
272
171
|
const response = await tool.handler(
|
|
273
172
|
effectiveArgs,
|
|
274
|
-
|
|
173
|
+
enrichedContext
|
|
275
174
|
);
|
|
276
175
|
result = response.data;
|
|
277
176
|
content = response.toolResponse;
|
|
177
|
+
resultAppended = response.resultAppended === true;
|
|
278
178
|
} else {
|
|
279
179
|
result = { error: `Unknown tool: ${toolCall.name}` };
|
|
280
180
|
content = JSON.stringify(result, null, 2);
|
|
@@ -320,11 +220,14 @@ function createToolRouter(options) {
|
|
|
320
220
|
throw error;
|
|
321
221
|
}
|
|
322
222
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
223
|
+
if (!resultAppended) {
|
|
224
|
+
await appendToolResult({
|
|
225
|
+
threadId: options.threadId,
|
|
226
|
+
toolCallId: toolCall.id,
|
|
227
|
+
toolName: toolCall.name,
|
|
228
|
+
content
|
|
229
|
+
});
|
|
230
|
+
}
|
|
328
231
|
const toolResult = {
|
|
329
232
|
toolCallId: toolCall.id,
|
|
330
233
|
name: toolCall.name,
|
|
@@ -354,11 +257,11 @@ function createToolRouter(options) {
|
|
|
354
257
|
return {
|
|
355
258
|
// --- Methods from registry ---
|
|
356
259
|
hasTools() {
|
|
357
|
-
return toolMap.
|
|
260
|
+
return Array.from(toolMap.values()).some(isEnabled);
|
|
358
261
|
},
|
|
359
262
|
parseToolCall(toolCall) {
|
|
360
263
|
const tool = toolMap.get(toolCall.name);
|
|
361
|
-
if (!tool) {
|
|
264
|
+
if (!tool || !isEnabled(tool)) {
|
|
362
265
|
throw new Error(`Tool ${toolCall.name} not found`);
|
|
363
266
|
}
|
|
364
267
|
const parsedArgs = tool.schema.parse(toolCall.args);
|
|
@@ -369,13 +272,14 @@ function createToolRouter(options) {
|
|
|
369
272
|
};
|
|
370
273
|
},
|
|
371
274
|
hasTool(name) {
|
|
372
|
-
|
|
275
|
+
const tool = toolMap.get(name);
|
|
276
|
+
return tool !== void 0 && isEnabled(tool);
|
|
373
277
|
},
|
|
374
278
|
getToolNames() {
|
|
375
|
-
return Array.from(toolMap.
|
|
279
|
+
return Array.from(toolMap.entries()).filter(([, tool]) => isEnabled(tool)).map(([name]) => name);
|
|
376
280
|
},
|
|
377
281
|
getToolDefinitions() {
|
|
378
|
-
return Array.from(toolMap).map(([name, tool]) => ({
|
|
282
|
+
return Array.from(toolMap).filter(([, tool]) => isEnabled(tool)).map(([name, tool]) => ({
|
|
379
283
|
name,
|
|
380
284
|
description: tool.description,
|
|
381
285
|
schema: tool.schema,
|
|
@@ -414,19 +318,28 @@ function createToolRouter(options) {
|
|
|
414
318
|
}
|
|
415
319
|
const handlerContext = context?.handlerContext ?? {};
|
|
416
320
|
const processOne = async (toolCall) => {
|
|
321
|
+
const enrichedContext = {
|
|
322
|
+
...handlerContext ?? {},
|
|
323
|
+
threadId: options.threadId,
|
|
324
|
+
toolCallId: toolCall.id,
|
|
325
|
+
toolName: toolCall.name
|
|
326
|
+
};
|
|
417
327
|
const response = await handler(
|
|
418
328
|
toolCall.args,
|
|
419
|
-
|
|
329
|
+
enrichedContext
|
|
420
330
|
);
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
331
|
+
if (!response.resultAppended) {
|
|
332
|
+
await appendToolResult({
|
|
333
|
+
threadId: options.threadId,
|
|
334
|
+
toolCallId: toolCall.id,
|
|
335
|
+
toolName: toolCall.name,
|
|
336
|
+
content: response.toolResponse
|
|
337
|
+
});
|
|
338
|
+
}
|
|
426
339
|
return {
|
|
427
340
|
toolCallId: toolCall.id,
|
|
428
341
|
name: toolCall.name,
|
|
429
|
-
data: response.data
|
|
342
|
+
data: response.data
|
|
430
343
|
};
|
|
431
344
|
};
|
|
432
345
|
if (options.parallel) {
|
|
@@ -463,51 +376,24 @@ function hasNoOtherToolCalls(toolCalls, excludeName) {
|
|
|
463
376
|
}
|
|
464
377
|
|
|
465
378
|
// src/lib/session.ts
|
|
466
|
-
async function resolvePrompt(prompt) {
|
|
467
|
-
if (typeof prompt === "function") {
|
|
468
|
-
return prompt();
|
|
469
|
-
}
|
|
470
|
-
return prompt;
|
|
471
|
-
}
|
|
472
379
|
var createSession = async ({
|
|
473
380
|
threadId,
|
|
474
381
|
agentName,
|
|
475
382
|
maxTurns = 50,
|
|
476
383
|
metadata = {},
|
|
477
384
|
runAgent,
|
|
478
|
-
|
|
479
|
-
instructionsPrompt,
|
|
385
|
+
threadOps,
|
|
480
386
|
buildContextMessage,
|
|
481
|
-
buildFileTree = async () => "",
|
|
482
387
|
subagents,
|
|
483
388
|
tools = {},
|
|
484
389
|
processToolsInParallel = true,
|
|
485
|
-
buildInTools = {},
|
|
486
390
|
hooks = {}
|
|
487
391
|
}) => {
|
|
488
|
-
const {
|
|
489
|
-
initializeThread,
|
|
490
|
-
appendHumanMessage,
|
|
491
|
-
parseToolCalls,
|
|
492
|
-
appendToolResult,
|
|
493
|
-
appendSystemMessage
|
|
494
|
-
} = proxyActivities({
|
|
495
|
-
startToCloseTimeout: "30m",
|
|
496
|
-
retry: {
|
|
497
|
-
maximumAttempts: 6,
|
|
498
|
-
initialInterval: "5s",
|
|
499
|
-
maximumInterval: "15m",
|
|
500
|
-
backoffCoefficient: 4
|
|
501
|
-
},
|
|
502
|
-
heartbeatTimeout: "5m"
|
|
503
|
-
});
|
|
504
|
-
const fileTree = await buildFileTree();
|
|
505
392
|
const toolRouter = createToolRouter({
|
|
506
393
|
tools,
|
|
394
|
+
appendToolResult: threadOps.appendToolResult,
|
|
507
395
|
threadId,
|
|
508
396
|
hooks,
|
|
509
|
-
buildInTools,
|
|
510
|
-
fileTree,
|
|
511
397
|
subagents,
|
|
512
398
|
parallel: processToolsInParallel
|
|
513
399
|
});
|
|
@@ -532,15 +418,8 @@ var createSession = async ({
|
|
|
532
418
|
});
|
|
533
419
|
}
|
|
534
420
|
stateManager.setTools(toolRouter.getToolDefinitions());
|
|
535
|
-
await initializeThread(threadId);
|
|
536
|
-
await
|
|
537
|
-
threadId,
|
|
538
|
-
[
|
|
539
|
-
await resolvePrompt(baseSystemPrompt),
|
|
540
|
-
await resolvePrompt(instructionsPrompt)
|
|
541
|
-
].join("\n")
|
|
542
|
-
);
|
|
543
|
-
await appendHumanMessage(threadId, await buildContextMessage());
|
|
421
|
+
await threadOps.initializeThread(threadId);
|
|
422
|
+
await threadOps.appendHumanMessage(threadId, await buildContextMessage());
|
|
544
423
|
let exitReason = "completed";
|
|
545
424
|
try {
|
|
546
425
|
while (stateManager.isRunning() && !stateManager.isTerminal() && stateManager.getTurns() < maxTurns) {
|
|
@@ -561,54 +440,25 @@ var createSession = async ({
|
|
|
561
440
|
exitReason = "completed";
|
|
562
441
|
return message;
|
|
563
442
|
}
|
|
564
|
-
const rawToolCalls = await parseToolCalls(message);
|
|
443
|
+
const rawToolCalls = await threadOps.parseToolCalls(message);
|
|
565
444
|
const parsedToolCalls = [];
|
|
566
|
-
for (const tc of rawToolCalls
|
|
567
|
-
(tc2) => tc2.name !== "Task"
|
|
568
|
-
)) {
|
|
445
|
+
for (const tc of rawToolCalls) {
|
|
569
446
|
try {
|
|
570
447
|
parsedToolCalls.push(toolRouter.parseToolCall(tc));
|
|
571
448
|
} catch (error) {
|
|
572
|
-
await appendToolResult({
|
|
449
|
+
await threadOps.appendToolResult({
|
|
573
450
|
threadId,
|
|
574
451
|
toolCallId: tc.id ?? "",
|
|
452
|
+
toolName: tc.name,
|
|
575
453
|
content: JSON.stringify({
|
|
576
454
|
error: `Invalid tool call for "${tc.name}": ${error instanceof Error ? error.message : String(error)}`
|
|
577
455
|
})
|
|
578
456
|
});
|
|
579
457
|
}
|
|
580
458
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
(tc2) => tc2.name === "Task"
|
|
585
|
-
)) {
|
|
586
|
-
try {
|
|
587
|
-
const parsedArgs = createTaskTool(subagents).schema.parse(
|
|
588
|
-
tc.args
|
|
589
|
-
);
|
|
590
|
-
taskToolCalls.push({
|
|
591
|
-
id: tc.id ?? "",
|
|
592
|
-
name: tc.name,
|
|
593
|
-
args: parsedArgs
|
|
594
|
-
});
|
|
595
|
-
} catch (error) {
|
|
596
|
-
await appendToolResult({
|
|
597
|
-
threadId,
|
|
598
|
-
toolCallId: tc.id ?? "",
|
|
599
|
-
content: JSON.stringify({
|
|
600
|
-
error: `Invalid tool call for "Task": ${error instanceof Error ? error.message : String(error)}`
|
|
601
|
-
})
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
await toolRouter.processToolCalls(
|
|
607
|
-
[...parsedToolCalls, ...taskToolCalls],
|
|
608
|
-
{
|
|
609
|
-
turn: currentTurn
|
|
610
|
-
}
|
|
611
|
-
);
|
|
459
|
+
await toolRouter.processToolCalls(parsedToolCalls, {
|
|
460
|
+
turn: currentTurn
|
|
461
|
+
});
|
|
612
462
|
if (stateManager.getStatus() === "WAITING_FOR_INPUT") {
|
|
613
463
|
exitReason = "waiting_for_input";
|
|
614
464
|
break;
|
|
@@ -627,6 +477,26 @@ var createSession = async ({
|
|
|
627
477
|
}
|
|
628
478
|
};
|
|
629
479
|
};
|
|
480
|
+
function proxyDefaultThreadOps(options) {
|
|
481
|
+
const activities = proxyActivities(
|
|
482
|
+
options ?? {
|
|
483
|
+
startToCloseTimeout: "30m",
|
|
484
|
+
retry: {
|
|
485
|
+
maximumAttempts: 6,
|
|
486
|
+
initialInterval: "5s",
|
|
487
|
+
maximumInterval: "15m",
|
|
488
|
+
backoffCoefficient: 4
|
|
489
|
+
},
|
|
490
|
+
heartbeatTimeout: "5m"
|
|
491
|
+
}
|
|
492
|
+
);
|
|
493
|
+
return {
|
|
494
|
+
initializeThread: activities.initializeThread,
|
|
495
|
+
appendHumanMessage: activities.appendHumanMessage,
|
|
496
|
+
appendToolResult: activities.appendToolResult,
|
|
497
|
+
parseToolCalls: activities.parseToolCalls
|
|
498
|
+
};
|
|
499
|
+
}
|
|
630
500
|
|
|
631
501
|
// src/lib/types.ts
|
|
632
502
|
function isTerminalStatus(status) {
|
|
@@ -763,18 +633,18 @@ Usage notes:
|
|
|
763
633
|
* Use multiSelect: true to allow multiple answers to be selected for a question
|
|
764
634
|
* If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
|
765
635
|
`,
|
|
766
|
-
schema:
|
|
767
|
-
questions:
|
|
768
|
-
|
|
769
|
-
question:
|
|
770
|
-
header:
|
|
771
|
-
options:
|
|
772
|
-
|
|
773
|
-
label:
|
|
774
|
-
description:
|
|
636
|
+
schema: z3.object({
|
|
637
|
+
questions: z3.array(
|
|
638
|
+
z3.object({
|
|
639
|
+
question: z3.string().describe("The full question text to display"),
|
|
640
|
+
header: z3.string().describe("Short label for the question (max 12 characters)"),
|
|
641
|
+
options: z3.array(
|
|
642
|
+
z3.object({
|
|
643
|
+
label: z3.string(),
|
|
644
|
+
description: z3.string()
|
|
775
645
|
})
|
|
776
646
|
).min(0).max(4).describe("Array of 0-4 choices, each with label and description"),
|
|
777
|
-
multiSelect:
|
|
647
|
+
multiSelect: z3.boolean().describe("If true, users can select multiple options")
|
|
778
648
|
})
|
|
779
649
|
)
|
|
780
650
|
}),
|
|
@@ -852,7 +722,7 @@ var writeTool = {
|
|
|
852
722
|
description: `Create or overwrite a file with new content.
|
|
853
723
|
|
|
854
724
|
Usage:
|
|
855
|
-
- Provide the absolute
|
|
725
|
+
- Provide the absolute path to the file
|
|
856
726
|
- The file will be created if it doesn't exist
|
|
857
727
|
- If the file exists, it will be completely overwritten
|
|
858
728
|
|
|
@@ -862,7 +732,7 @@ IMPORTANT:
|
|
|
862
732
|
- Path must be absolute (e.g., "/docs/readme.md", not "docs/readme.md")
|
|
863
733
|
`,
|
|
864
734
|
schema: z.object({
|
|
865
|
-
file_path: z.string().describe("The absolute
|
|
735
|
+
file_path: z.string().describe("The absolute path to the file to write"),
|
|
866
736
|
content: z.string().describe("The content to write to the file")
|
|
867
737
|
}),
|
|
868
738
|
strict: true
|
|
@@ -895,6 +765,60 @@ IMPORTANT:
|
|
|
895
765
|
}),
|
|
896
766
|
strict: true
|
|
897
767
|
};
|
|
768
|
+
var taskCreateTool = {
|
|
769
|
+
name: "TaskCreate",
|
|
770
|
+
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.
|
|
771
|
+
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
772
|
+
|
|
773
|
+
## When to Use This Tool
|
|
774
|
+
|
|
775
|
+
Use this tool proactively in these scenarios:
|
|
776
|
+
|
|
777
|
+
- Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
|
|
778
|
+
- Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
|
|
779
|
+
- User explicitly requests todo list - When the user directly asks you to use the todo list
|
|
780
|
+
- User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
|
|
781
|
+
- After receiving new instructions - Immediately capture user requirements as tasks
|
|
782
|
+
- When you start working on a task - Mark it as in_progress BEFORE beginning work
|
|
783
|
+
- After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
|
|
784
|
+
|
|
785
|
+
## When NOT to Use This Tool
|
|
786
|
+
|
|
787
|
+
Skip using this tool when:
|
|
788
|
+
- There is only a single, straightforward task
|
|
789
|
+
- The task is trivial and tracking it provides no organizational benefit
|
|
790
|
+
- The task can be completed in less than 3 trivial steps
|
|
791
|
+
- The task is purely conversational or informational
|
|
792
|
+
|
|
793
|
+
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.
|
|
794
|
+
|
|
795
|
+
## Task Fields
|
|
796
|
+
|
|
797
|
+
- **subject**: A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")
|
|
798
|
+
- **description**: Detailed description of what needs to be done, including context and acceptance criteria
|
|
799
|
+
- **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.
|
|
800
|
+
|
|
801
|
+
**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\`.
|
|
802
|
+
|
|
803
|
+
## Tips
|
|
804
|
+
|
|
805
|
+
- Create tasks with clear, specific subjects that describe the outcome
|
|
806
|
+
- Include enough detail in the description for another agent to understand and complete the task
|
|
807
|
+
- After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
|
|
808
|
+
- Check TaskList first to avoid creating duplicate tasks`,
|
|
809
|
+
schema: z3.object({
|
|
810
|
+
subject: z3.string().describe(
|
|
811
|
+
'A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")'
|
|
812
|
+
),
|
|
813
|
+
description: z3.string().describe(
|
|
814
|
+
"Detailed description of what needs to be done, including context and acceptance criteria"
|
|
815
|
+
),
|
|
816
|
+
activeForm: z3.string().describe(
|
|
817
|
+
'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.'
|
|
818
|
+
),
|
|
819
|
+
metadata: z3.record(z3.string(), z3.string()).describe("Arbitrary key-value pairs for tracking")
|
|
820
|
+
})
|
|
821
|
+
};
|
|
898
822
|
function createTaskCreateHandler(stateManager) {
|
|
899
823
|
return (args) => {
|
|
900
824
|
const task = {
|
|
@@ -917,8 +841,8 @@ function createTaskCreateHandler(stateManager) {
|
|
|
917
841
|
var taskGetTool = {
|
|
918
842
|
name: "TaskGet",
|
|
919
843
|
description: `Retrieve full task details including dependencies.`,
|
|
920
|
-
schema:
|
|
921
|
-
taskId:
|
|
844
|
+
schema: z3.object({
|
|
845
|
+
taskId: z3.string().describe("The ID of the task to get")
|
|
922
846
|
})
|
|
923
847
|
};
|
|
924
848
|
|
|
@@ -941,12 +865,12 @@ function createTaskGetHandler(stateManager) {
|
|
|
941
865
|
var taskListTool = {
|
|
942
866
|
name: "TaskList",
|
|
943
867
|
description: `List all tasks with current state.`,
|
|
944
|
-
schema:
|
|
868
|
+
schema: z3.object({})
|
|
945
869
|
};
|
|
946
870
|
|
|
947
871
|
// src/tools/task-list/handler.ts
|
|
948
872
|
function createTaskListHandler(stateManager) {
|
|
949
|
-
return (
|
|
873
|
+
return () => {
|
|
950
874
|
const taskList = stateManager.getTasks();
|
|
951
875
|
return {
|
|
952
876
|
toolResponse: JSON.stringify(taskList, null, 2),
|
|
@@ -957,11 +881,11 @@ function createTaskListHandler(stateManager) {
|
|
|
957
881
|
var taskUpdateTool = {
|
|
958
882
|
name: "TaskUpdate",
|
|
959
883
|
description: `Update status, add blockers, modify details.`,
|
|
960
|
-
schema:
|
|
961
|
-
taskId:
|
|
962
|
-
status:
|
|
963
|
-
addBlockedBy:
|
|
964
|
-
addBlocks:
|
|
884
|
+
schema: z3.object({
|
|
885
|
+
taskId: z3.string().describe("The ID of the task to get"),
|
|
886
|
+
status: z3.enum(["pending", "in_progress", "completed"]).describe("The status of the task"),
|
|
887
|
+
addBlockedBy: z3.array(z3.string()).describe("The IDs of the tasks that are blocking this task"),
|
|
888
|
+
addBlocks: z3.array(z3.string()).describe("The IDs of the tasks that this task is blocking")
|
|
965
889
|
})
|
|
966
890
|
};
|
|
967
891
|
|
|
@@ -1009,7 +933,34 @@ function createTaskUpdateHandler(stateManager) {
|
|
|
1009
933
|
};
|
|
1010
934
|
};
|
|
1011
935
|
}
|
|
936
|
+
var createBashToolDescription = ({
|
|
937
|
+
fileTree
|
|
938
|
+
}) => `Execute shell commands in a bash environment.
|
|
939
|
+
|
|
940
|
+
Use this tool to:
|
|
941
|
+
- Run shell commands (ls, cat, grep, find, etc.)
|
|
942
|
+
- Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
|
|
943
|
+
- Inspect files and directories
|
|
944
|
+
|
|
945
|
+
Current file tree:
|
|
946
|
+
${fileTree}`;
|
|
947
|
+
var bashTool = {
|
|
948
|
+
name: "Bash",
|
|
949
|
+
description: `Execute shell commands in a sandboxed bash environment.
|
|
950
|
+
|
|
951
|
+
Use this tool to:
|
|
952
|
+
- Run shell commands (ls, cat, grep, find, etc.)
|
|
953
|
+
- Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
|
|
954
|
+
- Inspect files and directories
|
|
955
|
+
`,
|
|
956
|
+
schema: z3.object({
|
|
957
|
+
command: z3.string().describe(
|
|
958
|
+
"The bash command to execute. Can include pipes (|), redirects (>, >>), logical operators (&&, ||), and shell features like command substitution $(...)."
|
|
959
|
+
)
|
|
960
|
+
}),
|
|
961
|
+
strict: true
|
|
962
|
+
};
|
|
1012
963
|
|
|
1013
|
-
export { AGENT_HANDLER_NAMES, askUserQuestionTool, bashTool, createAgentStateManager, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskTool, createTaskUpdateHandler, createToolRouter, defineSubagent, defineTool, editTool, globTool, grepTool, hasNoOtherToolCalls, isTerminalStatus, readTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeTool };
|
|
964
|
+
export { AGENT_HANDLER_NAMES, askUserQuestionTool, bashTool, createAgentStateManager, createBashToolDescription, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskTool, createTaskUpdateHandler, createToolRouter, defineSubagent, defineTool, editTool, globTool, grepTool, hasNoOtherToolCalls, isTerminalStatus, proxyDefaultThreadOps, readTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeTool };
|
|
1014
965
|
//# sourceMappingURL=workflow.js.map
|
|
1015
966
|
//# sourceMappingURL=workflow.js.map
|