zeitlich 0.2.8 → 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 +366 -136
- 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 +338 -112
- package/dist/index.js.map +1 -1
- package/dist/{workflow-BdAuMMjY.d.cts → workflow-BhjsEQc1.d.cts} +120 -26
- package/dist/{workflow-BdAuMMjY.d.ts → workflow-BhjsEQc1.d.ts} +120 -26
- package/dist/workflow.cjs +267 -126
- 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 +239 -102
- 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 +49 -16
- package/src/lib/types.ts +23 -6
- package/src/tools/ask-user-question/handler.ts +3 -3
- package/src/tools/read-file/tool.ts +2 -2
- 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 +7 -22
- package/src/tools/task-create/tool.ts +1 -1
- package/src/tools/write-file/tool.ts +4 -5
- package/src/workflow.ts +16 -7
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
|
-
var
|
|
11
|
+
var SUBAGENT_TOOL_NAME = "Subagent";
|
|
12
12
|
function buildSubagentDescription(subagents) {
|
|
13
|
-
const subagentList = subagents.map((s) =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
The ${SUBAGENT_TOOL} 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} 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) {
|
|
@@ -38,12 +24,12 @@ function createSubagentTool(subagents) {
|
|
|
38
24
|
}
|
|
39
25
|
const names = subagents.map((s) => s.agentName);
|
|
40
26
|
return {
|
|
41
|
-
name:
|
|
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();
|
|
@@ -91,7 +131,7 @@ function createToolRouter(options) {
|
|
|
91
131
|
if (s.hooks) subagentHooksMap.set(s.agentName, s.hooks);
|
|
92
132
|
}
|
|
93
133
|
const resolveSubagentName = (args) => args.subagent;
|
|
94
|
-
toolMap.set(
|
|
134
|
+
toolMap.set(SUBAGENT_TOOL_NAME, {
|
|
95
135
|
...createSubagentTool(options.subagents),
|
|
96
136
|
handler: createSubagentHandler(options.subagents),
|
|
97
137
|
...subagentHooksMap.size > 0 && {
|
|
@@ -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) {
|
|
@@ -284,13 +332,21 @@ function createToolRouter(options) {
|
|
|
284
332
|
return Array.from(toolMap.entries()).filter(([, tool]) => isEnabled(tool)).map(([name]) => name);
|
|
285
333
|
},
|
|
286
334
|
getToolDefinitions() {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
335
|
+
const activeSubagents = options.subagents?.filter((subagent) => isEnabled(subagent)) ?? [];
|
|
336
|
+
const activeSkills = options.skills ?? [];
|
|
337
|
+
return [
|
|
338
|
+
...Array.from(toolMap).filter(
|
|
339
|
+
([, tool]) => isEnabled(tool) && tool.name !== SUBAGENT_TOOL_NAME && tool.name !== READ_SKILL_TOOL_NAME
|
|
340
|
+
).map(([name, tool]) => ({
|
|
341
|
+
name,
|
|
342
|
+
description: tool.description,
|
|
343
|
+
schema: tool.schema,
|
|
344
|
+
strict: tool.strict,
|
|
345
|
+
max_uses: tool.max_uses
|
|
346
|
+
})),
|
|
347
|
+
...activeSubagents.length > 0 ? [createSubagentTool(activeSubagents)] : [],
|
|
348
|
+
...activeSkills.length > 0 ? [createReadSkillTool(activeSkills)] : []
|
|
349
|
+
];
|
|
294
350
|
},
|
|
295
351
|
// --- Methods for processing tool calls ---
|
|
296
352
|
async processToolCalls(toolCalls, context) {
|
|
@@ -384,18 +440,17 @@ function hasNoOtherToolCalls(toolCalls, excludeName) {
|
|
|
384
440
|
var createSession = async ({
|
|
385
441
|
threadId,
|
|
386
442
|
agentName,
|
|
387
|
-
description,
|
|
388
443
|
maxTurns = 50,
|
|
389
444
|
metadata = {},
|
|
390
445
|
runAgent,
|
|
391
446
|
threadOps,
|
|
392
447
|
buildContextMessage,
|
|
393
448
|
subagents,
|
|
449
|
+
skills,
|
|
394
450
|
tools = {},
|
|
395
451
|
processToolsInParallel = true,
|
|
396
452
|
hooks = {},
|
|
397
453
|
appendSystemPrompt = true,
|
|
398
|
-
systemPrompt,
|
|
399
454
|
waitForInputTimeout = "48h"
|
|
400
455
|
}) => {
|
|
401
456
|
const {
|
|
@@ -410,6 +465,7 @@ var createSession = async ({
|
|
|
410
465
|
threadId,
|
|
411
466
|
hooks,
|
|
412
467
|
subagents,
|
|
468
|
+
skills,
|
|
413
469
|
parallel: processToolsInParallel
|
|
414
470
|
});
|
|
415
471
|
const callSessionEnd = async (exitReason, turns) => {
|
|
@@ -453,8 +509,15 @@ var createSession = async ({
|
|
|
453
509
|
metadata
|
|
454
510
|
});
|
|
455
511
|
}
|
|
512
|
+
const systemPrompt = stateManager.getSystemPrompt();
|
|
456
513
|
await initializeThread(threadId);
|
|
457
|
-
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
|
+
}
|
|
458
521
|
await appendSystemMessage(threadId, systemPrompt);
|
|
459
522
|
}
|
|
460
523
|
await appendHumanMessage(threadId, await buildContextMessage());
|
|
@@ -467,9 +530,7 @@ var createSession = async ({
|
|
|
467
530
|
const { message, rawToolCalls, usage } = await runAgent({
|
|
468
531
|
threadId,
|
|
469
532
|
agentName,
|
|
470
|
-
metadata
|
|
471
|
-
systemPrompt,
|
|
472
|
-
description
|
|
533
|
+
metadata
|
|
473
534
|
});
|
|
474
535
|
if (usage) {
|
|
475
536
|
stateManager.updateUsage(usage);
|
|
@@ -526,7 +587,7 @@ var createSession = async ({
|
|
|
526
587
|
}
|
|
527
588
|
} catch (error) {
|
|
528
589
|
exitReason = "failed";
|
|
529
|
-
throw error;
|
|
590
|
+
throw workflow.ApplicationFailure.fromError(error);
|
|
530
591
|
} finally {
|
|
531
592
|
await callSessionEnd(exitReason, stateManager.getTurns());
|
|
532
593
|
}
|
|
@@ -541,14 +602,13 @@ var createSession = async ({
|
|
|
541
602
|
function proxyDefaultThreadOps(options) {
|
|
542
603
|
const activities = workflow.proxyActivities(
|
|
543
604
|
options ?? {
|
|
544
|
-
startToCloseTimeout: "
|
|
605
|
+
startToCloseTimeout: "10s",
|
|
545
606
|
retry: {
|
|
546
607
|
maximumAttempts: 6,
|
|
547
608
|
initialInterval: "5s",
|
|
548
609
|
maximumInterval: "15m",
|
|
549
610
|
backoffCoefficient: 4
|
|
550
|
-
}
|
|
551
|
-
heartbeatTimeout: "5m"
|
|
611
|
+
}
|
|
552
612
|
}
|
|
553
613
|
);
|
|
554
614
|
return {
|
|
@@ -560,12 +620,14 @@ function proxyDefaultThreadOps(options) {
|
|
|
560
620
|
}
|
|
561
621
|
|
|
562
622
|
// src/lib/types.ts
|
|
623
|
+
var agentQueryName = (agentName) => `get${agentName}State`;
|
|
624
|
+
var agentStateChangeUpdateName = (agentName) => `waitFor${agentName}StateChange`;
|
|
563
625
|
function isTerminalStatus(status) {
|
|
564
626
|
return status === "COMPLETED" || status === "FAILED" || status === "CANCELLED";
|
|
565
627
|
}
|
|
566
628
|
function createAgentStateManager({
|
|
567
629
|
initialState,
|
|
568
|
-
|
|
630
|
+
agentName
|
|
569
631
|
}) {
|
|
570
632
|
let status = initialState?.status ?? "RUNNING";
|
|
571
633
|
let version = initialState?.version ?? 0;
|
|
@@ -576,6 +638,7 @@ function createAgentStateManager({
|
|
|
576
638
|
let totalCachedWriteTokens = 0;
|
|
577
639
|
let totalCachedReadTokens = 0;
|
|
578
640
|
let totalReasonTokens = 0;
|
|
641
|
+
let systemPrompt = initialState?.systemPrompt;
|
|
579
642
|
const tasks = new Map(initialState?.tasks);
|
|
580
643
|
const {
|
|
581
644
|
status: _,
|
|
@@ -595,28 +658,32 @@ function createAgentStateManager({
|
|
|
595
658
|
...customState
|
|
596
659
|
};
|
|
597
660
|
}
|
|
598
|
-
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
|
+
);
|
|
599
673
|
return buildState();
|
|
600
674
|
});
|
|
601
|
-
workflow.setHandler(
|
|
602
|
-
workflow.defineUpdate(
|
|
603
|
-
`waitFor${agentConfig.agentName}StateChange`
|
|
604
|
-
),
|
|
605
|
-
async (lastKnownVersion) => {
|
|
606
|
-
await workflow.condition(
|
|
607
|
-
() => version > lastKnownVersion || isTerminalStatus(status),
|
|
608
|
-
"55s"
|
|
609
|
-
);
|
|
610
|
-
return buildState();
|
|
611
|
-
}
|
|
612
|
-
);
|
|
613
675
|
return {
|
|
676
|
+
stateQuery,
|
|
677
|
+
stateChangeUpdate,
|
|
614
678
|
getStatus() {
|
|
615
679
|
return status;
|
|
616
680
|
},
|
|
617
681
|
isRunning() {
|
|
618
682
|
return status === "RUNNING";
|
|
619
683
|
},
|
|
684
|
+
getSystemPrompt() {
|
|
685
|
+
return systemPrompt;
|
|
686
|
+
},
|
|
620
687
|
isTerminal() {
|
|
621
688
|
return isTerminalStatus(status);
|
|
622
689
|
},
|
|
@@ -679,11 +746,14 @@ function createAgentStateManager({
|
|
|
679
746
|
tools = newTools.map((tool) => ({
|
|
680
747
|
name: tool.name,
|
|
681
748
|
description: tool.description,
|
|
682
|
-
schema:
|
|
749
|
+
schema: z14.z.toJSONSchema(tool.schema),
|
|
683
750
|
strict: tool.strict,
|
|
684
751
|
max_uses: tool.max_uses
|
|
685
752
|
}));
|
|
686
753
|
},
|
|
754
|
+
setSystemPrompt(newSystemPrompt) {
|
|
755
|
+
systemPrompt = newSystemPrompt;
|
|
756
|
+
},
|
|
687
757
|
deleteTask(id) {
|
|
688
758
|
const deleted = tasks.delete(id);
|
|
689
759
|
if (deleted) {
|
|
@@ -710,11 +780,79 @@ function createAgentStateManager({
|
|
|
710
780
|
}
|
|
711
781
|
};
|
|
712
782
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
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
|
+
}
|
|
718
856
|
var globTool = {
|
|
719
857
|
name: "Glob",
|
|
720
858
|
description: `Search for files matching a glob pattern within the available file system.
|
|
@@ -729,9 +867,9 @@ Examples:
|
|
|
729
867
|
- "**/*.test.ts" - Find all test files recursively
|
|
730
868
|
- "src/**/*.ts" - Find all TypeScript files in src directory
|
|
731
869
|
`,
|
|
732
|
-
schema:
|
|
733
|
-
pattern:
|
|
734
|
-
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")
|
|
735
873
|
}),
|
|
736
874
|
strict: true
|
|
737
875
|
};
|
|
@@ -749,17 +887,17 @@ Examples:
|
|
|
749
887
|
- Search for function definitions with "function.*handleClick"
|
|
750
888
|
- Search case-insensitively with ignoreCase: true
|
|
751
889
|
`,
|
|
752
|
-
schema:
|
|
753
|
-
pattern:
|
|
754
|
-
ignoreCase:
|
|
755
|
-
maxMatches:
|
|
756
|
-
includePatterns:
|
|
757
|
-
excludePatterns:
|
|
758
|
-
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")
|
|
759
897
|
}),
|
|
760
898
|
strict: true
|
|
761
899
|
};
|
|
762
|
-
var
|
|
900
|
+
var readFileTool = {
|
|
763
901
|
name: "FileRead",
|
|
764
902
|
description: `Read file contents with optional pagination.
|
|
765
903
|
|
|
@@ -773,32 +911,31 @@ The tool returns the file content in an appropriate format:
|
|
|
773
911
|
- Images: Base64-encoded image data
|
|
774
912
|
- PDFs: Extracted text content
|
|
775
913
|
`,
|
|
776
|
-
schema:
|
|
777
|
-
path:
|
|
778
|
-
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(
|
|
779
917
|
"Line number to start reading from (1-indexed, for text files)"
|
|
780
918
|
),
|
|
781
|
-
limit:
|
|
919
|
+
limit: z14.z.number().optional().describe("Maximum number of lines to read (for text files)")
|
|
782
920
|
}),
|
|
783
921
|
strict: true
|
|
784
922
|
};
|
|
785
|
-
var
|
|
923
|
+
var writeFileTool = {
|
|
786
924
|
name: "FileWrite",
|
|
787
925
|
description: `Create or overwrite a file with new content.
|
|
788
926
|
|
|
789
927
|
Usage:
|
|
790
|
-
- Provide the absolute path to the file
|
|
791
928
|
- The file will be created if it doesn't exist
|
|
792
929
|
- If the file exists, it will be completely overwritten
|
|
793
930
|
|
|
794
931
|
IMPORTANT:
|
|
795
932
|
- You must read the file first (in this session) before writing to it
|
|
796
933
|
- This is an atomic write operation - the entire file is replaced
|
|
797
|
-
- Path must be
|
|
934
|
+
- Path must be relative to the root of the file system (e.g., "docs/readme.md", not "/docs/readme.md")
|
|
798
935
|
`,
|
|
799
|
-
schema:
|
|
800
|
-
file_path:
|
|
801
|
-
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")
|
|
802
939
|
}),
|
|
803
940
|
strict: true
|
|
804
941
|
};
|
|
@@ -818,13 +955,13 @@ IMPORTANT:
|
|
|
818
955
|
- The operation fails if old_string is not found
|
|
819
956
|
- old_string and new_string must be different
|
|
820
957
|
`,
|
|
821
|
-
schema:
|
|
822
|
-
file_path:
|
|
823
|
-
old_string:
|
|
824
|
-
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(
|
|
825
962
|
"The text to replace it with (must be different from old_string)"
|
|
826
963
|
),
|
|
827
|
-
replace_all:
|
|
964
|
+
replace_all: z14.z.boolean().optional().describe(
|
|
828
965
|
"If true, replace all occurrences of old_string (default: false)"
|
|
829
966
|
)
|
|
830
967
|
}),
|
|
@@ -832,7 +969,7 @@ IMPORTANT:
|
|
|
832
969
|
};
|
|
833
970
|
var taskCreateTool = {
|
|
834
971
|
name: "TaskCreate",
|
|
835
|
-
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.
|
|
836
973
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
837
974
|
|
|
838
975
|
## When to Use This Tool
|
|
@@ -871,17 +1008,17 @@ var taskCreateTool = {
|
|
|
871
1008
|
- Include enough detail in the description for another agent to understand and complete the task
|
|
872
1009
|
- After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
|
|
873
1010
|
- Check TaskList first to avoid creating duplicate tasks`,
|
|
874
|
-
schema:
|
|
875
|
-
subject:
|
|
1011
|
+
schema: z14__default.default.object({
|
|
1012
|
+
subject: z14__default.default.string().describe(
|
|
876
1013
|
'A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")'
|
|
877
1014
|
),
|
|
878
|
-
description:
|
|
1015
|
+
description: z14__default.default.string().describe(
|
|
879
1016
|
"Detailed description of what needs to be done, including context and acceptance criteria"
|
|
880
1017
|
),
|
|
881
|
-
activeForm:
|
|
1018
|
+
activeForm: z14__default.default.string().describe(
|
|
882
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.'
|
|
883
1020
|
),
|
|
884
|
-
metadata:
|
|
1021
|
+
metadata: z14__default.default.record(z14__default.default.string(), z14__default.default.string()).describe("Arbitrary key-value pairs for tracking")
|
|
885
1022
|
})
|
|
886
1023
|
};
|
|
887
1024
|
function createTaskCreateHandler(stateManager) {
|
|
@@ -906,8 +1043,8 @@ function createTaskCreateHandler(stateManager) {
|
|
|
906
1043
|
var taskGetTool = {
|
|
907
1044
|
name: "TaskGet",
|
|
908
1045
|
description: `Retrieve full task details including dependencies.`,
|
|
909
|
-
schema:
|
|
910
|
-
taskId:
|
|
1046
|
+
schema: z14__default.default.object({
|
|
1047
|
+
taskId: z14__default.default.string().describe("The ID of the task to get")
|
|
911
1048
|
})
|
|
912
1049
|
};
|
|
913
1050
|
|
|
@@ -930,7 +1067,7 @@ function createTaskGetHandler(stateManager) {
|
|
|
930
1067
|
var taskListTool = {
|
|
931
1068
|
name: "TaskList",
|
|
932
1069
|
description: `List all tasks with current state.`,
|
|
933
|
-
schema:
|
|
1070
|
+
schema: z14__default.default.object({})
|
|
934
1071
|
};
|
|
935
1072
|
|
|
936
1073
|
// src/tools/task-list/handler.ts
|
|
@@ -946,11 +1083,11 @@ function createTaskListHandler(stateManager) {
|
|
|
946
1083
|
var taskUpdateTool = {
|
|
947
1084
|
name: "TaskUpdate",
|
|
948
1085
|
description: `Update status, add blockers, modify details.`,
|
|
949
|
-
schema:
|
|
950
|
-
taskId:
|
|
951
|
-
status:
|
|
952
|
-
addBlockedBy:
|
|
953
|
-
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")
|
|
954
1091
|
})
|
|
955
1092
|
};
|
|
956
1093
|
|
|
@@ -1018,8 +1155,8 @@ Use this tool to:
|
|
|
1018
1155
|
- Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
|
|
1019
1156
|
- Inspect files and directories
|
|
1020
1157
|
`,
|
|
1021
|
-
schema:
|
|
1022
|
-
command:
|
|
1158
|
+
schema: z14__default.default.object({
|
|
1159
|
+
command: z14__default.default.string().describe(
|
|
1023
1160
|
"The bash command to execute. Can include pipes (|), redirects (>, >>), logical operators (&&, ||), and shell features like command substitution $(...)."
|
|
1024
1161
|
)
|
|
1025
1162
|
}),
|
|
@@ -1040,18 +1177,18 @@ Usage notes:
|
|
|
1040
1177
|
* Use multiSelect: true to allow multiple answers to be selected for a question
|
|
1041
1178
|
* If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
|
1042
1179
|
`,
|
|
1043
|
-
schema:
|
|
1044
|
-
questions:
|
|
1045
|
-
|
|
1046
|
-
question:
|
|
1047
|
-
header:
|
|
1048
|
-
options:
|
|
1049
|
-
|
|
1050
|
-
label:
|
|
1051
|
-
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()
|
|
1052
1189
|
})
|
|
1053
1190
|
).min(0).max(4).describe("Array of 0-4 choices, each with label and description"),
|
|
1054
|
-
multiSelect:
|
|
1191
|
+
multiSelect: z14__default.default.boolean().describe("If true, users can select multiple options")
|
|
1055
1192
|
})
|
|
1056
1193
|
)
|
|
1057
1194
|
}),
|
|
@@ -1059,19 +1196,22 @@ Usage notes:
|
|
|
1059
1196
|
};
|
|
1060
1197
|
|
|
1061
1198
|
// src/tools/ask-user-question/handler.ts
|
|
1062
|
-
var createAskUserQuestionHandler = () => (args) => {
|
|
1199
|
+
var createAskUserQuestionHandler = () => async (args) => {
|
|
1063
1200
|
return {
|
|
1064
1201
|
toolResponse: "Question submitted",
|
|
1065
1202
|
data: { questions: args.questions }
|
|
1066
1203
|
};
|
|
1067
1204
|
};
|
|
1068
1205
|
|
|
1069
|
-
exports.
|
|
1206
|
+
exports.agentQueryName = agentQueryName;
|
|
1207
|
+
exports.agentStateChangeUpdateName = agentStateChangeUpdateName;
|
|
1070
1208
|
exports.askUserQuestionTool = askUserQuestionTool;
|
|
1071
1209
|
exports.bashTool = bashTool;
|
|
1072
1210
|
exports.createAgentStateManager = createAgentStateManager;
|
|
1073
1211
|
exports.createAskUserQuestionHandler = createAskUserQuestionHandler;
|
|
1074
1212
|
exports.createBashToolDescription = createBashToolDescription;
|
|
1213
|
+
exports.createReadSkillHandler = createReadSkillHandler;
|
|
1214
|
+
exports.createReadSkillTool = createReadSkillTool;
|
|
1075
1215
|
exports.createSession = createSession;
|
|
1076
1216
|
exports.createSubagentTool = createSubagentTool;
|
|
1077
1217
|
exports.createTaskCreateHandler = createTaskCreateHandler;
|
|
@@ -1086,12 +1226,13 @@ exports.globTool = globTool;
|
|
|
1086
1226
|
exports.grepTool = grepTool;
|
|
1087
1227
|
exports.hasNoOtherToolCalls = hasNoOtherToolCalls;
|
|
1088
1228
|
exports.isTerminalStatus = isTerminalStatus;
|
|
1229
|
+
exports.parseSkillFile = parseSkillFile;
|
|
1089
1230
|
exports.proxyDefaultThreadOps = proxyDefaultThreadOps;
|
|
1090
|
-
exports.
|
|
1231
|
+
exports.readFileTool = readFileTool;
|
|
1091
1232
|
exports.taskCreateTool = taskCreateTool;
|
|
1092
1233
|
exports.taskGetTool = taskGetTool;
|
|
1093
1234
|
exports.taskListTool = taskListTool;
|
|
1094
1235
|
exports.taskUpdateTool = taskUpdateTool;
|
|
1095
|
-
exports.
|
|
1236
|
+
exports.writeFileTool = writeFileTool;
|
|
1096
1237
|
//# sourceMappingURL=workflow.cjs.map
|
|
1097
1238
|
//# sourceMappingURL=workflow.cjs.map
|