zeitlich 0.2.9 → 0.2.11
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.cjs +346 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -3
- package/dist/index.d.ts +30 -3
- package/dist/index.js +319 -98
- package/dist/index.js.map +1 -1
- package/dist/{workflow-C2ShwjC7.d.cts → workflow-BhjsEQc1.d.cts} +115 -21
- package/dist/{workflow-C2ShwjC7.d.ts → workflow-BhjsEQc1.d.ts} +115 -21
- package/dist/workflow.cjs +247 -111
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +2 -1
- package/dist/workflow.d.ts +2 -1
- package/dist/workflow.js +220 -88
- package/dist/workflow.js.map +1 -1
- package/package.json +15 -15
- package/src/index.ts +3 -0
- package/src/lib/model-invoker.ts +2 -2
- package/src/lib/session.ts +14 -8
- package/src/lib/skills/fs-provider.ts +84 -0
- package/src/lib/skills/index.ts +3 -0
- package/src/lib/skills/parse.ts +117 -0
- package/src/lib/skills/types.ts +41 -0
- package/src/lib/state-manager.ts +42 -26
- package/src/lib/thread-manager.ts +61 -2
- package/src/lib/tool-router.ts +28 -5
- package/src/lib/types.ts +23 -6
- package/src/tools/read-skill/handler.ts +31 -0
- package/src/tools/read-skill/tool.ts +47 -0
- package/src/tools/subagent/handler.ts +21 -4
- package/src/tools/subagent/tool.ts +5 -20
- package/src/tools/task-create/tool.ts +1 -1
- package/src/workflow.ts +14 -5
package/dist/workflow.cjs
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var workflow = require('@temporalio/workflow');
|
|
4
|
-
var
|
|
4
|
+
var z14 = require('zod');
|
|
5
5
|
|
|
6
6
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var z14__default = /*#__PURE__*/_interopDefault(z14);
|
|
9
9
|
|
|
10
10
|
// src/lib/session.ts
|
|
11
11
|
var SUBAGENT_TOOL_NAME = "Subagent";
|
|
12
12
|
function buildSubagentDescription(subagents) {
|
|
13
|
-
const subagentList = subagents.map((s) =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
The ${SUBAGENT_TOOL_NAME} tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
|
|
17
|
-
|
|
18
|
-
Available agent types:
|
|
13
|
+
const subagentList = subagents.map((s) => `## ${s.agentName}
|
|
14
|
+
${s.description}`).join("\n\n");
|
|
15
|
+
return `The ${SUBAGENT_TOOL_NAME} tool launches specialized agents (subagents) that autonomously handle complex work. Each agent type has specific capabilities and tools available to it.
|
|
19
16
|
|
|
17
|
+
# Available subagents:
|
|
20
18
|
${subagentList}
|
|
21
|
-
|
|
22
|
-
When using the ${SUBAGENT_TOOL_NAME} tool, you must specify a subagent parameter to select which agent type to use.
|
|
23
|
-
|
|
24
|
-
Usage notes:
|
|
25
|
-
|
|
26
|
-
- Always include a short description (3-5 words) summarizing what the agent will do
|
|
27
|
-
- Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
|
|
28
|
-
- When the agent is done, it will return a single message back to you.
|
|
29
|
-
- Each invocation starts fresh - provide a detailed task description with all necessary context.
|
|
30
|
-
- Provide clear, detailed prompts so the agent can work autonomously and return exactly the information you need.
|
|
31
|
-
- The agent's outputs should generally be trusted
|
|
32
|
-
- Clearly tell the agent what type of work you expect since it is not aware of the user's intent
|
|
33
|
-
- If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.`;
|
|
19
|
+
`;
|
|
34
20
|
}
|
|
35
21
|
function createSubagentTool(subagents) {
|
|
36
22
|
if (subagents.length === 0) {
|
|
@@ -40,10 +26,10 @@ function createSubagentTool(subagents) {
|
|
|
40
26
|
return {
|
|
41
27
|
name: SUBAGENT_TOOL_NAME,
|
|
42
28
|
description: buildSubagentDescription(subagents),
|
|
43
|
-
schema:
|
|
44
|
-
subagent:
|
|
45
|
-
description:
|
|
46
|
-
prompt:
|
|
29
|
+
schema: z14__default.default.object({
|
|
30
|
+
subagent: z14__default.default.enum(names).describe("The type of subagent to launch"),
|
|
31
|
+
description: z14__default.default.string().describe("A short (3-5 word) description of the task"),
|
|
32
|
+
prompt: z14__default.default.string().describe("The task for the agent to perform")
|
|
47
33
|
})
|
|
48
34
|
};
|
|
49
35
|
}
|
|
@@ -67,23 +53,77 @@ function createSubagentHandler(subagents) {
|
|
|
67
53
|
taskQueue: config.taskQueue ?? parentTaskQueue
|
|
68
54
|
};
|
|
69
55
|
const { toolResponse, data, usage } = typeof config.workflow === "string" ? await workflow.executeChild(config.workflow, childOpts) : await workflow.executeChild(config.workflow, childOpts);
|
|
70
|
-
|
|
56
|
+
if (!toolResponse) {
|
|
57
|
+
return {
|
|
58
|
+
toolResponse: "Subagent workflow returned no response",
|
|
59
|
+
data: null,
|
|
60
|
+
...usage && { usage }
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const validated = config.resultSchema ? config.resultSchema.safeParse(data) : null;
|
|
64
|
+
if (validated && !validated.success) {
|
|
65
|
+
return {
|
|
66
|
+
toolResponse: `Subagent workflow returned invalid data: ${validated.error.message}`,
|
|
67
|
+
data: null,
|
|
68
|
+
...usage && { usage }
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
71
|
return {
|
|
72
72
|
toolResponse,
|
|
73
|
-
data: validated,
|
|
73
|
+
data: validated ? validated.data : data,
|
|
74
74
|
...usage && { usage }
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
+
var READ_SKILL_TOOL_NAME = "ReadSkill";
|
|
79
|
+
function buildReadSkillDescription(skills) {
|
|
80
|
+
const skillList = skills.map((s) => `- **${s.name}**: ${s.description}`).join("\n");
|
|
81
|
+
return `Load the full instructions for a skill. Read the skill before following its instructions.
|
|
82
|
+
|
|
83
|
+
# Available skills:
|
|
84
|
+
${skillList}
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
function createReadSkillTool(skills) {
|
|
88
|
+
if (skills.length === 0) {
|
|
89
|
+
throw new Error("createReadSkillTool requires at least one skill");
|
|
90
|
+
}
|
|
91
|
+
const names = skills.map((s) => s.name);
|
|
92
|
+
return {
|
|
93
|
+
name: READ_SKILL_TOOL_NAME,
|
|
94
|
+
description: buildReadSkillDescription(skills),
|
|
95
|
+
schema: z14__default.default.object({
|
|
96
|
+
skill_name: z14__default.default.enum(names).describe("The name of the skill to load")
|
|
97
|
+
})
|
|
98
|
+
};
|
|
99
|
+
}
|
|
78
100
|
|
|
79
|
-
// src/
|
|
101
|
+
// src/tools/read-skill/handler.ts
|
|
102
|
+
function createReadSkillHandler(skills) {
|
|
103
|
+
const skillMap = new Map(skills.map((s) => [s.name, s]));
|
|
104
|
+
return (args) => {
|
|
105
|
+
const skill = skillMap.get(args.skill_name);
|
|
106
|
+
if (!skill) {
|
|
107
|
+
return {
|
|
108
|
+
toolResponse: JSON.stringify({
|
|
109
|
+
error: `Skill "${args.skill_name}" not found`
|
|
110
|
+
}),
|
|
111
|
+
data: null
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
toolResponse: skill.instructions,
|
|
116
|
+
data: null
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
}
|
|
80
120
|
function createToolRouter(options) {
|
|
81
121
|
const { appendToolResult } = options;
|
|
82
122
|
const toolMap = /* @__PURE__ */ new Map();
|
|
83
123
|
for (const [_key, tool] of Object.entries(options.tools)) {
|
|
84
124
|
toolMap.set(tool.name, tool);
|
|
85
125
|
}
|
|
86
|
-
const isEnabled = (tool) => tool.enabled
|
|
126
|
+
const isEnabled = (tool) => tool.enabled ?? true;
|
|
87
127
|
if (options.subagents) {
|
|
88
128
|
if (options.subagents.length > 0) {
|
|
89
129
|
const subagentHooksMap = /* @__PURE__ */ new Map();
|
|
@@ -113,6 +153,12 @@ function createToolRouter(options) {
|
|
|
113
153
|
});
|
|
114
154
|
}
|
|
115
155
|
}
|
|
156
|
+
if (options.skills && options.skills.length > 0) {
|
|
157
|
+
toolMap.set(READ_SKILL_TOOL_NAME, {
|
|
158
|
+
...createReadSkillTool(options.skills),
|
|
159
|
+
handler: createReadSkillHandler(options.skills)
|
|
160
|
+
});
|
|
161
|
+
}
|
|
116
162
|
async function processToolCall(toolCall, turn, handlerContext) {
|
|
117
163
|
const startTime = Date.now();
|
|
118
164
|
const tool = toolMap.get(toolCall.name);
|
|
@@ -222,7 +268,9 @@ function createToolRouter(options) {
|
|
|
222
268
|
}
|
|
223
269
|
}
|
|
224
270
|
if (!recovered) {
|
|
225
|
-
throw error
|
|
271
|
+
throw workflow.ApplicationFailure.fromError(error, {
|
|
272
|
+
nonRetryable: true
|
|
273
|
+
});
|
|
226
274
|
}
|
|
227
275
|
}
|
|
228
276
|
if (!resultAppended) {
|
|
@@ -285,9 +333,10 @@ function createToolRouter(options) {
|
|
|
285
333
|
},
|
|
286
334
|
getToolDefinitions() {
|
|
287
335
|
const activeSubagents = options.subagents?.filter((subagent) => isEnabled(subagent)) ?? [];
|
|
336
|
+
const activeSkills = options.skills ?? [];
|
|
288
337
|
return [
|
|
289
338
|
...Array.from(toolMap).filter(
|
|
290
|
-
([, tool]) => isEnabled(tool) && tool.name !== SUBAGENT_TOOL_NAME
|
|
339
|
+
([, tool]) => isEnabled(tool) && tool.name !== SUBAGENT_TOOL_NAME && tool.name !== READ_SKILL_TOOL_NAME
|
|
291
340
|
).map(([name, tool]) => ({
|
|
292
341
|
name,
|
|
293
342
|
description: tool.description,
|
|
@@ -295,7 +344,8 @@ function createToolRouter(options) {
|
|
|
295
344
|
strict: tool.strict,
|
|
296
345
|
max_uses: tool.max_uses
|
|
297
346
|
})),
|
|
298
|
-
...activeSubagents.length > 0 ? [createSubagentTool(activeSubagents)] : []
|
|
347
|
+
...activeSubagents.length > 0 ? [createSubagentTool(activeSubagents)] : [],
|
|
348
|
+
...activeSkills.length > 0 ? [createReadSkillTool(activeSkills)] : []
|
|
299
349
|
];
|
|
300
350
|
},
|
|
301
351
|
// --- Methods for processing tool calls ---
|
|
@@ -390,18 +440,17 @@ function hasNoOtherToolCalls(toolCalls, excludeName) {
|
|
|
390
440
|
var createSession = async ({
|
|
391
441
|
threadId,
|
|
392
442
|
agentName,
|
|
393
|
-
description,
|
|
394
443
|
maxTurns = 50,
|
|
395
444
|
metadata = {},
|
|
396
445
|
runAgent,
|
|
397
446
|
threadOps,
|
|
398
447
|
buildContextMessage,
|
|
399
448
|
subagents,
|
|
449
|
+
skills,
|
|
400
450
|
tools = {},
|
|
401
451
|
processToolsInParallel = true,
|
|
402
452
|
hooks = {},
|
|
403
453
|
appendSystemPrompt = true,
|
|
404
|
-
systemPrompt,
|
|
405
454
|
waitForInputTimeout = "48h"
|
|
406
455
|
}) => {
|
|
407
456
|
const {
|
|
@@ -416,6 +465,7 @@ var createSession = async ({
|
|
|
416
465
|
threadId,
|
|
417
466
|
hooks,
|
|
418
467
|
subagents,
|
|
468
|
+
skills,
|
|
419
469
|
parallel: processToolsInParallel
|
|
420
470
|
});
|
|
421
471
|
const callSessionEnd = async (exitReason, turns) => {
|
|
@@ -459,8 +509,15 @@ var createSession = async ({
|
|
|
459
509
|
metadata
|
|
460
510
|
});
|
|
461
511
|
}
|
|
512
|
+
const systemPrompt = stateManager.getSystemPrompt();
|
|
462
513
|
await initializeThread(threadId);
|
|
463
|
-
if (appendSystemPrompt
|
|
514
|
+
if (appendSystemPrompt) {
|
|
515
|
+
if (!systemPrompt || systemPrompt.trim() === "") {
|
|
516
|
+
throw workflow.ApplicationFailure.create({
|
|
517
|
+
message: "No system prompt in state",
|
|
518
|
+
nonRetryable: true
|
|
519
|
+
});
|
|
520
|
+
}
|
|
464
521
|
await appendSystemMessage(threadId, systemPrompt);
|
|
465
522
|
}
|
|
466
523
|
await appendHumanMessage(threadId, await buildContextMessage());
|
|
@@ -473,9 +530,7 @@ var createSession = async ({
|
|
|
473
530
|
const { message, rawToolCalls, usage } = await runAgent({
|
|
474
531
|
threadId,
|
|
475
532
|
agentName,
|
|
476
|
-
metadata
|
|
477
|
-
systemPrompt,
|
|
478
|
-
description
|
|
533
|
+
metadata
|
|
479
534
|
});
|
|
480
535
|
if (usage) {
|
|
481
536
|
stateManager.updateUsage(usage);
|
|
@@ -532,7 +587,7 @@ var createSession = async ({
|
|
|
532
587
|
}
|
|
533
588
|
} catch (error) {
|
|
534
589
|
exitReason = "failed";
|
|
535
|
-
throw error;
|
|
590
|
+
throw workflow.ApplicationFailure.fromError(error);
|
|
536
591
|
} finally {
|
|
537
592
|
await callSessionEnd(exitReason, stateManager.getTurns());
|
|
538
593
|
}
|
|
@@ -547,14 +602,13 @@ var createSession = async ({
|
|
|
547
602
|
function proxyDefaultThreadOps(options) {
|
|
548
603
|
const activities = workflow.proxyActivities(
|
|
549
604
|
options ?? {
|
|
550
|
-
startToCloseTimeout: "
|
|
605
|
+
startToCloseTimeout: "10s",
|
|
551
606
|
retry: {
|
|
552
607
|
maximumAttempts: 6,
|
|
553
608
|
initialInterval: "5s",
|
|
554
609
|
maximumInterval: "15m",
|
|
555
610
|
backoffCoefficient: 4
|
|
556
|
-
}
|
|
557
|
-
heartbeatTimeout: "5m"
|
|
611
|
+
}
|
|
558
612
|
}
|
|
559
613
|
);
|
|
560
614
|
return {
|
|
@@ -566,12 +620,14 @@ function proxyDefaultThreadOps(options) {
|
|
|
566
620
|
}
|
|
567
621
|
|
|
568
622
|
// src/lib/types.ts
|
|
623
|
+
var agentQueryName = (agentName) => `get${agentName}State`;
|
|
624
|
+
var agentStateChangeUpdateName = (agentName) => `waitFor${agentName}StateChange`;
|
|
569
625
|
function isTerminalStatus(status) {
|
|
570
626
|
return status === "COMPLETED" || status === "FAILED" || status === "CANCELLED";
|
|
571
627
|
}
|
|
572
628
|
function createAgentStateManager({
|
|
573
629
|
initialState,
|
|
574
|
-
|
|
630
|
+
agentName
|
|
575
631
|
}) {
|
|
576
632
|
let status = initialState?.status ?? "RUNNING";
|
|
577
633
|
let version = initialState?.version ?? 0;
|
|
@@ -582,6 +638,7 @@ function createAgentStateManager({
|
|
|
582
638
|
let totalCachedWriteTokens = 0;
|
|
583
639
|
let totalCachedReadTokens = 0;
|
|
584
640
|
let totalReasonTokens = 0;
|
|
641
|
+
let systemPrompt = initialState?.systemPrompt;
|
|
585
642
|
const tasks = new Map(initialState?.tasks);
|
|
586
643
|
const {
|
|
587
644
|
status: _,
|
|
@@ -601,28 +658,32 @@ function createAgentStateManager({
|
|
|
601
658
|
...customState
|
|
602
659
|
};
|
|
603
660
|
}
|
|
604
|
-
workflow.
|
|
661
|
+
const stateQuery = workflow.defineQuery(
|
|
662
|
+
agentQueryName(agentName)
|
|
663
|
+
);
|
|
664
|
+
const stateChangeUpdate = workflow.defineUpdate(
|
|
665
|
+
agentStateChangeUpdateName(agentName)
|
|
666
|
+
);
|
|
667
|
+
workflow.setHandler(stateQuery, () => buildState());
|
|
668
|
+
workflow.setHandler(stateChangeUpdate, async (lastKnownVersion) => {
|
|
669
|
+
await workflow.condition(
|
|
670
|
+
() => version > lastKnownVersion || isTerminalStatus(status),
|
|
671
|
+
"55s"
|
|
672
|
+
);
|
|
605
673
|
return buildState();
|
|
606
674
|
});
|
|
607
|
-
workflow.setHandler(
|
|
608
|
-
workflow.defineUpdate(
|
|
609
|
-
`waitFor${agentConfig.agentName}StateChange`
|
|
610
|
-
),
|
|
611
|
-
async (lastKnownVersion) => {
|
|
612
|
-
await workflow.condition(
|
|
613
|
-
() => version > lastKnownVersion || isTerminalStatus(status),
|
|
614
|
-
"55s"
|
|
615
|
-
);
|
|
616
|
-
return buildState();
|
|
617
|
-
}
|
|
618
|
-
);
|
|
619
675
|
return {
|
|
676
|
+
stateQuery,
|
|
677
|
+
stateChangeUpdate,
|
|
620
678
|
getStatus() {
|
|
621
679
|
return status;
|
|
622
680
|
},
|
|
623
681
|
isRunning() {
|
|
624
682
|
return status === "RUNNING";
|
|
625
683
|
},
|
|
684
|
+
getSystemPrompt() {
|
|
685
|
+
return systemPrompt;
|
|
686
|
+
},
|
|
626
687
|
isTerminal() {
|
|
627
688
|
return isTerminalStatus(status);
|
|
628
689
|
},
|
|
@@ -685,11 +746,14 @@ function createAgentStateManager({
|
|
|
685
746
|
tools = newTools.map((tool) => ({
|
|
686
747
|
name: tool.name,
|
|
687
748
|
description: tool.description,
|
|
688
|
-
schema:
|
|
749
|
+
schema: z14.z.toJSONSchema(tool.schema),
|
|
689
750
|
strict: tool.strict,
|
|
690
751
|
max_uses: tool.max_uses
|
|
691
752
|
}));
|
|
692
753
|
},
|
|
754
|
+
setSystemPrompt(newSystemPrompt) {
|
|
755
|
+
systemPrompt = newSystemPrompt;
|
|
756
|
+
},
|
|
693
757
|
deleteTask(id) {
|
|
694
758
|
const deleted = tasks.delete(id);
|
|
695
759
|
if (deleted) {
|
|
@@ -716,11 +780,79 @@ function createAgentStateManager({
|
|
|
716
780
|
}
|
|
717
781
|
};
|
|
718
782
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
783
|
+
|
|
784
|
+
// src/lib/skills/parse.ts
|
|
785
|
+
function parseSkillFile(raw) {
|
|
786
|
+
const trimmed = raw.replace(/^\uFEFF/, "");
|
|
787
|
+
const match = trimmed.match(/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n?([\s\S]*)$/);
|
|
788
|
+
if (!match) {
|
|
789
|
+
throw new Error(
|
|
790
|
+
"SKILL.md must start with YAML frontmatter delimited by ---"
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
const [, yamlBlock, body] = match;
|
|
794
|
+
const frontmatter = parseSimpleYaml(yamlBlock);
|
|
795
|
+
if (!frontmatter.name || typeof frontmatter.name !== "string") {
|
|
796
|
+
throw new Error("SKILL.md frontmatter must include a 'name' field");
|
|
797
|
+
}
|
|
798
|
+
if (!frontmatter.description || typeof frontmatter.description !== "string") {
|
|
799
|
+
throw new Error("SKILL.md frontmatter must include a 'description' field");
|
|
800
|
+
}
|
|
801
|
+
const result = {
|
|
802
|
+
name: frontmatter.name,
|
|
803
|
+
description: frontmatter.description
|
|
804
|
+
};
|
|
805
|
+
if (frontmatter.license) result.license = String(frontmatter.license);
|
|
806
|
+
if (frontmatter.compatibility)
|
|
807
|
+
result.compatibility = String(frontmatter.compatibility);
|
|
808
|
+
if (frontmatter["allowed-tools"]) {
|
|
809
|
+
result.allowedTools = String(frontmatter["allowed-tools"]).split(/\s+/).filter(Boolean);
|
|
810
|
+
}
|
|
811
|
+
if (frontmatter.metadata && typeof frontmatter.metadata === "object" && !Array.isArray(frontmatter.metadata)) {
|
|
812
|
+
result.metadata = frontmatter.metadata;
|
|
813
|
+
}
|
|
814
|
+
return { frontmatter: result, body: body.trim() };
|
|
815
|
+
}
|
|
816
|
+
function parseSimpleYaml(yaml) {
|
|
817
|
+
const result = {};
|
|
818
|
+
const lines = yaml.split(/\r?\n/);
|
|
819
|
+
let currentMapKey = null;
|
|
820
|
+
let currentMap = null;
|
|
821
|
+
for (const line of lines) {
|
|
822
|
+
if (line.trim() === "" || line.trim().startsWith("#")) continue;
|
|
823
|
+
const nestedMatch = line.match(/^(\s{2,}|\t+)(\S+)\s*:\s*(.*)$/);
|
|
824
|
+
if (nestedMatch && currentMapKey && currentMap) {
|
|
825
|
+
const [, , key2, rawVal2] = nestedMatch;
|
|
826
|
+
currentMap[key2] = unquote(rawVal2.trim());
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
if (currentMapKey && currentMap) {
|
|
830
|
+
result[currentMapKey] = currentMap;
|
|
831
|
+
currentMapKey = null;
|
|
832
|
+
currentMap = null;
|
|
833
|
+
}
|
|
834
|
+
const topMatch = line.match(/^(\S+)\s*:\s*(.*)$/);
|
|
835
|
+
if (!topMatch) continue;
|
|
836
|
+
const [, key, rawVal] = topMatch;
|
|
837
|
+
const val = rawVal.trim();
|
|
838
|
+
if (val === "" || val === "|" || val === ">") {
|
|
839
|
+
currentMapKey = key;
|
|
840
|
+
currentMap = {};
|
|
841
|
+
} else {
|
|
842
|
+
result[key] = unquote(val);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
if (currentMapKey && currentMap) {
|
|
846
|
+
result[currentMapKey] = currentMap;
|
|
847
|
+
}
|
|
848
|
+
return result;
|
|
849
|
+
}
|
|
850
|
+
function unquote(s) {
|
|
851
|
+
if (s.startsWith('"') && s.endsWith('"') || s.startsWith("'") && s.endsWith("'")) {
|
|
852
|
+
return s.slice(1, -1);
|
|
853
|
+
}
|
|
854
|
+
return s;
|
|
855
|
+
}
|
|
724
856
|
var globTool = {
|
|
725
857
|
name: "Glob",
|
|
726
858
|
description: `Search for files matching a glob pattern within the available file system.
|
|
@@ -735,9 +867,9 @@ Examples:
|
|
|
735
867
|
- "**/*.test.ts" - Find all test files recursively
|
|
736
868
|
- "src/**/*.ts" - Find all TypeScript files in src directory
|
|
737
869
|
`,
|
|
738
|
-
schema:
|
|
739
|
-
pattern:
|
|
740
|
-
root:
|
|
870
|
+
schema: z14.z.object({
|
|
871
|
+
pattern: z14.z.string().describe("Glob pattern to match files against"),
|
|
872
|
+
root: z14.z.string().optional().describe("Optional root directory to search from")
|
|
741
873
|
}),
|
|
742
874
|
strict: true
|
|
743
875
|
};
|
|
@@ -755,13 +887,13 @@ Examples:
|
|
|
755
887
|
- Search for function definitions with "function.*handleClick"
|
|
756
888
|
- Search case-insensitively with ignoreCase: true
|
|
757
889
|
`,
|
|
758
|
-
schema:
|
|
759
|
-
pattern:
|
|
760
|
-
ignoreCase:
|
|
761
|
-
maxMatches:
|
|
762
|
-
includePatterns:
|
|
763
|
-
excludePatterns:
|
|
764
|
-
contextLines:
|
|
890
|
+
schema: z14.z.object({
|
|
891
|
+
pattern: z14.z.string().describe("Regex pattern to search for in file contents"),
|
|
892
|
+
ignoreCase: z14.z.boolean().optional().describe("Case-insensitive search (default: false)"),
|
|
893
|
+
maxMatches: z14.z.number().optional().describe("Maximum number of matches to return (default: 50)"),
|
|
894
|
+
includePatterns: z14.z.array(z14.z.string()).optional().describe("Glob patterns to include (e.g., ['*.ts', '*.js'])"),
|
|
895
|
+
excludePatterns: z14.z.array(z14.z.string()).optional().describe("Glob patterns to exclude (e.g., ['*.test.ts'])"),
|
|
896
|
+
contextLines: z14.z.number().optional().describe("Number of context lines to show around matches")
|
|
765
897
|
}),
|
|
766
898
|
strict: true
|
|
767
899
|
};
|
|
@@ -779,12 +911,12 @@ The tool returns the file content in an appropriate format:
|
|
|
779
911
|
- Images: Base64-encoded image data
|
|
780
912
|
- PDFs: Extracted text content
|
|
781
913
|
`,
|
|
782
|
-
schema:
|
|
783
|
-
path:
|
|
784
|
-
offset:
|
|
914
|
+
schema: z14.z.object({
|
|
915
|
+
path: z14.z.string().describe("Virtual path to the file to read"),
|
|
916
|
+
offset: z14.z.number().optional().describe(
|
|
785
917
|
"Line number to start reading from (1-indexed, for text files)"
|
|
786
918
|
),
|
|
787
|
-
limit:
|
|
919
|
+
limit: z14.z.number().optional().describe("Maximum number of lines to read (for text files)")
|
|
788
920
|
}),
|
|
789
921
|
strict: true
|
|
790
922
|
};
|
|
@@ -801,9 +933,9 @@ IMPORTANT:
|
|
|
801
933
|
- This is an atomic write operation - the entire file is replaced
|
|
802
934
|
- Path must be relative to the root of the file system (e.g., "docs/readme.md", not "/docs/readme.md")
|
|
803
935
|
`,
|
|
804
|
-
schema:
|
|
805
|
-
file_path:
|
|
806
|
-
content:
|
|
936
|
+
schema: z14.z.object({
|
|
937
|
+
file_path: z14.z.string().describe("The path to the file to write"),
|
|
938
|
+
content: z14.z.string().describe("The content to write to the file")
|
|
807
939
|
}),
|
|
808
940
|
strict: true
|
|
809
941
|
};
|
|
@@ -823,13 +955,13 @@ IMPORTANT:
|
|
|
823
955
|
- The operation fails if old_string is not found
|
|
824
956
|
- old_string and new_string must be different
|
|
825
957
|
`,
|
|
826
|
-
schema:
|
|
827
|
-
file_path:
|
|
828
|
-
old_string:
|
|
829
|
-
new_string:
|
|
958
|
+
schema: z14.z.object({
|
|
959
|
+
file_path: z14.z.string().describe("The absolute virtual path to the file to modify"),
|
|
960
|
+
old_string: z14.z.string().describe("The exact text to replace"),
|
|
961
|
+
new_string: z14.z.string().describe(
|
|
830
962
|
"The text to replace it with (must be different from old_string)"
|
|
831
963
|
),
|
|
832
|
-
replace_all:
|
|
964
|
+
replace_all: z14.z.boolean().optional().describe(
|
|
833
965
|
"If true, replace all occurrences of old_string (default: false)"
|
|
834
966
|
)
|
|
835
967
|
}),
|
|
@@ -837,7 +969,7 @@ IMPORTANT:
|
|
|
837
969
|
};
|
|
838
970
|
var taskCreateTool = {
|
|
839
971
|
name: "TaskCreate",
|
|
840
|
-
description: `Use this tool to create a structured task list
|
|
972
|
+
description: `Use this tool to create a structured task list. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
841
973
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
842
974
|
|
|
843
975
|
## When to Use This Tool
|
|
@@ -876,17 +1008,17 @@ var taskCreateTool = {
|
|
|
876
1008
|
- Include enough detail in the description for another agent to understand and complete the task
|
|
877
1009
|
- After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
|
|
878
1010
|
- Check TaskList first to avoid creating duplicate tasks`,
|
|
879
|
-
schema:
|
|
880
|
-
subject:
|
|
1011
|
+
schema: z14__default.default.object({
|
|
1012
|
+
subject: z14__default.default.string().describe(
|
|
881
1013
|
'A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")'
|
|
882
1014
|
),
|
|
883
|
-
description:
|
|
1015
|
+
description: z14__default.default.string().describe(
|
|
884
1016
|
"Detailed description of what needs to be done, including context and acceptance criteria"
|
|
885
1017
|
),
|
|
886
|
-
activeForm:
|
|
1018
|
+
activeForm: z14__default.default.string().describe(
|
|
887
1019
|
'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.'
|
|
888
1020
|
),
|
|
889
|
-
metadata:
|
|
1021
|
+
metadata: z14__default.default.record(z14__default.default.string(), z14__default.default.string()).describe("Arbitrary key-value pairs for tracking")
|
|
890
1022
|
})
|
|
891
1023
|
};
|
|
892
1024
|
function createTaskCreateHandler(stateManager) {
|
|
@@ -911,8 +1043,8 @@ function createTaskCreateHandler(stateManager) {
|
|
|
911
1043
|
var taskGetTool = {
|
|
912
1044
|
name: "TaskGet",
|
|
913
1045
|
description: `Retrieve full task details including dependencies.`,
|
|
914
|
-
schema:
|
|
915
|
-
taskId:
|
|
1046
|
+
schema: z14__default.default.object({
|
|
1047
|
+
taskId: z14__default.default.string().describe("The ID of the task to get")
|
|
916
1048
|
})
|
|
917
1049
|
};
|
|
918
1050
|
|
|
@@ -935,7 +1067,7 @@ function createTaskGetHandler(stateManager) {
|
|
|
935
1067
|
var taskListTool = {
|
|
936
1068
|
name: "TaskList",
|
|
937
1069
|
description: `List all tasks with current state.`,
|
|
938
|
-
schema:
|
|
1070
|
+
schema: z14__default.default.object({})
|
|
939
1071
|
};
|
|
940
1072
|
|
|
941
1073
|
// src/tools/task-list/handler.ts
|
|
@@ -951,11 +1083,11 @@ function createTaskListHandler(stateManager) {
|
|
|
951
1083
|
var taskUpdateTool = {
|
|
952
1084
|
name: "TaskUpdate",
|
|
953
1085
|
description: `Update status, add blockers, modify details.`,
|
|
954
|
-
schema:
|
|
955
|
-
taskId:
|
|
956
|
-
status:
|
|
957
|
-
addBlockedBy:
|
|
958
|
-
addBlocks:
|
|
1086
|
+
schema: z14__default.default.object({
|
|
1087
|
+
taskId: z14__default.default.string().describe("The ID of the task to get"),
|
|
1088
|
+
status: z14__default.default.enum(["pending", "in_progress", "completed"]).describe("The status of the task"),
|
|
1089
|
+
addBlockedBy: z14__default.default.array(z14__default.default.string()).describe("The IDs of the tasks that are blocking this task"),
|
|
1090
|
+
addBlocks: z14__default.default.array(z14__default.default.string()).describe("The IDs of the tasks that this task is blocking")
|
|
959
1091
|
})
|
|
960
1092
|
};
|
|
961
1093
|
|
|
@@ -1023,8 +1155,8 @@ Use this tool to:
|
|
|
1023
1155
|
- Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
|
|
1024
1156
|
- Inspect files and directories
|
|
1025
1157
|
`,
|
|
1026
|
-
schema:
|
|
1027
|
-
command:
|
|
1158
|
+
schema: z14__default.default.object({
|
|
1159
|
+
command: z14__default.default.string().describe(
|
|
1028
1160
|
"The bash command to execute. Can include pipes (|), redirects (>, >>), logical operators (&&, ||), and shell features like command substitution $(...)."
|
|
1029
1161
|
)
|
|
1030
1162
|
}),
|
|
@@ -1045,18 +1177,18 @@ Usage notes:
|
|
|
1045
1177
|
* Use multiSelect: true to allow multiple answers to be selected for a question
|
|
1046
1178
|
* If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
|
1047
1179
|
`,
|
|
1048
|
-
schema:
|
|
1049
|
-
questions:
|
|
1050
|
-
|
|
1051
|
-
question:
|
|
1052
|
-
header:
|
|
1053
|
-
options:
|
|
1054
|
-
|
|
1055
|
-
label:
|
|
1056
|
-
description:
|
|
1180
|
+
schema: z14__default.default.object({
|
|
1181
|
+
questions: z14__default.default.array(
|
|
1182
|
+
z14__default.default.object({
|
|
1183
|
+
question: z14__default.default.string().describe("The full question text to display"),
|
|
1184
|
+
header: z14__default.default.string().describe("Short label for the question (max 12 characters)"),
|
|
1185
|
+
options: z14__default.default.array(
|
|
1186
|
+
z14__default.default.object({
|
|
1187
|
+
label: z14__default.default.string(),
|
|
1188
|
+
description: z14__default.default.string()
|
|
1057
1189
|
})
|
|
1058
1190
|
).min(0).max(4).describe("Array of 0-4 choices, each with label and description"),
|
|
1059
|
-
multiSelect:
|
|
1191
|
+
multiSelect: z14__default.default.boolean().describe("If true, users can select multiple options")
|
|
1060
1192
|
})
|
|
1061
1193
|
)
|
|
1062
1194
|
}),
|
|
@@ -1071,12 +1203,15 @@ var createAskUserQuestionHandler = () => async (args) => {
|
|
|
1071
1203
|
};
|
|
1072
1204
|
};
|
|
1073
1205
|
|
|
1074
|
-
exports.
|
|
1206
|
+
exports.agentQueryName = agentQueryName;
|
|
1207
|
+
exports.agentStateChangeUpdateName = agentStateChangeUpdateName;
|
|
1075
1208
|
exports.askUserQuestionTool = askUserQuestionTool;
|
|
1076
1209
|
exports.bashTool = bashTool;
|
|
1077
1210
|
exports.createAgentStateManager = createAgentStateManager;
|
|
1078
1211
|
exports.createAskUserQuestionHandler = createAskUserQuestionHandler;
|
|
1079
1212
|
exports.createBashToolDescription = createBashToolDescription;
|
|
1213
|
+
exports.createReadSkillHandler = createReadSkillHandler;
|
|
1214
|
+
exports.createReadSkillTool = createReadSkillTool;
|
|
1080
1215
|
exports.createSession = createSession;
|
|
1081
1216
|
exports.createSubagentTool = createSubagentTool;
|
|
1082
1217
|
exports.createTaskCreateHandler = createTaskCreateHandler;
|
|
@@ -1091,6 +1226,7 @@ exports.globTool = globTool;
|
|
|
1091
1226
|
exports.grepTool = grepTool;
|
|
1092
1227
|
exports.hasNoOtherToolCalls = hasNoOtherToolCalls;
|
|
1093
1228
|
exports.isTerminalStatus = isTerminalStatus;
|
|
1229
|
+
exports.parseSkillFile = parseSkillFile;
|
|
1094
1230
|
exports.proxyDefaultThreadOps = proxyDefaultThreadOps;
|
|
1095
1231
|
exports.readFileTool = readFileTool;
|
|
1096
1232
|
exports.taskCreateTool = taskCreateTool;
|