clanka 0.22.5 → 0.23.0
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/Acp.js +1 -1
- package/dist/Acp.test.js +7 -7
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +10 -19
- package/dist/Agent.js.map +1 -1
- package/dist/Agent.test.js +1 -1
- package/dist/AgentCallerConfig.test.js +11 -10
- package/dist/AgentCallerConfig.test.js.map +1 -1
- package/dist/AgentEnvironment.test.js +2 -2
- package/dist/AgentExecutor.d.ts +25 -25
- package/dist/AgentExecutor.d.ts.map +1 -1
- package/dist/AgentExecutor.js +12 -12
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentExecutor.test.js +16 -14
- package/dist/AgentExecutor.test.js.map +1 -1
- package/dist/AgentImage.test.js +4 -4
- package/dist/AgentSubagents.test.js +45 -16
- package/dist/AgentSubagents.test.js.map +1 -1
- package/dist/AgentTools.d.ts +39 -79
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +9 -10
- package/dist/AgentTools.js.map +1 -1
- package/dist/McpServers.test.js +1 -1
- package/dist/bin/cli.mjs +25 -36
- package/dist/bin/cli.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Acp.test.ts +7 -7
- package/src/Acp.ts +1 -1
- package/src/Agent.test.ts +1 -1
- package/src/Agent.ts +9 -30
- package/src/AgentCallerConfig.test.ts +14 -10
- package/src/AgentEnvironment.test.ts +2 -2
- package/src/AgentExecutor.test.ts +16 -14
- package/src/AgentExecutor.ts +24 -21
- package/src/AgentImage.test.ts +4 -4
- package/src/AgentSubagents.test.ts +62 -21
- package/src/AgentTools.ts +13 -14
- package/src/McpServers.test.ts +1 -1
package/dist/bin/cli.mjs
CHANGED
|
@@ -11556,7 +11556,7 @@ const Task = Struct({
|
|
|
11556
11556
|
});
|
|
11557
11557
|
var AgentTaskExecutor = class extends Service()("clanka/AgentTools/AgentTaskExecutor") {};
|
|
11558
11558
|
const agentTasksUnavailable = {
|
|
11559
|
-
|
|
11559
|
+
subagent: () => die(new Error("Sub-agents are not available here")),
|
|
11560
11560
|
taskOutput: () => fail$1("Sub-agents are not available here"),
|
|
11561
11561
|
waitTasks: () => fail$1("Sub-agents are not available here"),
|
|
11562
11562
|
messageAgent: () => fail$1("Sub-agents are not available here"),
|
|
@@ -11608,7 +11608,7 @@ const AgentTools = make$16(make$17("changeDirectory", {
|
|
|
11608
11608
|
}),
|
|
11609
11609
|
success: String$7,
|
|
11610
11610
|
dependencies: [CurrentDirectory]
|
|
11611
|
-
}), make$17("
|
|
11611
|
+
}), make$17("subagent", {
|
|
11612
11612
|
description: "Delegate a task to another software engineer / sub-agent. With `background: true` the sub-agent works in the background, and its result is sent to you when it finishes.",
|
|
11613
11613
|
parameters: Struct({
|
|
11614
11614
|
prompt: String$7,
|
|
@@ -11653,7 +11653,6 @@ const AgentTools = make$16(make$17("changeDirectory", {
|
|
|
11653
11653
|
}), make$17("stopTask", {
|
|
11654
11654
|
description: "Stop one of your tasks.",
|
|
11655
11655
|
parameters: String$7.annotate({ identifier: "id" }),
|
|
11656
|
-
success: Task,
|
|
11657
11656
|
failure: String$7,
|
|
11658
11657
|
dependencies: [AgentTaskExecutor]
|
|
11659
11658
|
}), make$17("listTasks", {
|
|
@@ -11935,7 +11934,7 @@ const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(gen(function* () {
|
|
|
11935
11934
|
const entry = yield* findTask(id);
|
|
11936
11935
|
if (entry.kind === "agent") return yield* (yield* AgentTaskExecutor).stopTask(id);
|
|
11937
11936
|
yield* interrupt$2(entry.command.fiber);
|
|
11938
|
-
|
|
11937
|
+
entry.command.reported = true;
|
|
11939
11938
|
}),
|
|
11940
11939
|
listTasks: fn("AgentTools.listTasks")(function* () {
|
|
11941
11940
|
yield* logInfo(`Calling "listTasks"`);
|
|
@@ -12063,11 +12062,11 @@ const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(gen(function* () {
|
|
|
12063
12062
|
}
|
|
12064
12063
|
return `Success. Updated the following files:\n${out.join("\n")}`;
|
|
12065
12064
|
}, orDie),
|
|
12066
|
-
|
|
12067
|
-
const { prompt, background = false } = yield*
|
|
12068
|
-
yield* logInfo(`Calling "
|
|
12065
|
+
subagent: fn("AgentTools.subagent")(function* (options) {
|
|
12066
|
+
const { prompt, background = false } = yield* decodeSubagent(options);
|
|
12067
|
+
yield* logInfo(`Calling "subagent"`).pipe(annotateLogs({ background }));
|
|
12069
12068
|
const id = yield* registerAgentTask();
|
|
12070
|
-
return yield* (yield* AgentTaskExecutor).
|
|
12069
|
+
return yield* (yield* AgentTaskExecutor).subagent({
|
|
12071
12070
|
id,
|
|
12072
12071
|
prompt,
|
|
12073
12072
|
background
|
|
@@ -12092,7 +12091,7 @@ const decodeParams$1 = (schema, usage) => {
|
|
|
12092
12091
|
const decode = decodeUnknownEffect$1(schema);
|
|
12093
12092
|
return (input) => mapError(decode(input), () => usage);
|
|
12094
12093
|
};
|
|
12095
|
-
const
|
|
12094
|
+
const decodeSubagent = decodeParams$1(AgentTools.tools.subagent.parametersSchema, "subagent requires an options object, for example: subagent({ prompt: \"...\" }) or subagent({ prompt: \"...\", background: true }).");
|
|
12096
12095
|
const decodeMessageAgent = decodeParams$1(AgentTools.tools.messageAgent.parametersSchema, "messageAgent requires an options object, for example: messageAgent({ id: \"3\", message: \"...\" }).");
|
|
12097
12096
|
const decodeTaskOutput = decodeParams$1(AgentTools.tools.taskOutput.parametersSchema, "taskOutput requires a task id, for example: taskOutput(\"1\").");
|
|
12098
12097
|
const decodeWaitTasks = decodeParams$1(AgentTools.tools.waitTasks.parametersSchema, "waitTasks requires an options object, for example: waitTasks({ ids: [\"3\", \"4\"] }) or waitTasks({ ids: [\"3\"], timeoutMs: 60000 }).");
|
|
@@ -14249,7 +14248,7 @@ const makeLocalWith = fnUntraced(function* (options) {
|
|
|
14249
14248
|
}));
|
|
14250
14249
|
const taskServices = empty$5().pipe(add(TaskCompleter, opts.onTaskComplete), add(DirectoryChanger, changeDirectory), add(AgentTaskExecutor, {
|
|
14251
14250
|
...opts.agentTasks,
|
|
14252
|
-
|
|
14251
|
+
subagent: (options) => renderEnvironment(currentEnvironment(), { reset: true }).pipe(flatMap$1((environment) => opts.agentTasks.subagent({
|
|
14253
14252
|
...options,
|
|
14254
14253
|
environment
|
|
14255
14254
|
})))
|
|
@@ -14421,7 +14420,7 @@ const layerLocal$1 = (options) => effect(AgentExecutor, withBuiltInHandlers(make
|
|
|
14421
14420
|
const layerRpc = effect(AgentExecutor, makeRpc);
|
|
14422
14421
|
const AgentRequest = TaggedUnion({
|
|
14423
14422
|
TaskComplete: { summary: String$7 },
|
|
14424
|
-
|
|
14423
|
+
Subagent: {
|
|
14425
14424
|
id: String$7,
|
|
14426
14425
|
prompt: String$7,
|
|
14427
14426
|
background: Boolean$4,
|
|
@@ -14524,7 +14523,7 @@ const encodeRpcParams = (tool, params) => {
|
|
|
14524
14523
|
const handleRequest = (opts, request) => {
|
|
14525
14524
|
switch (request._tag) {
|
|
14526
14525
|
case "TaskComplete": return opts.onTaskComplete(request.summary);
|
|
14527
|
-
case "
|
|
14526
|
+
case "Subagent": return opts.agentTasks.subagent(request);
|
|
14528
14527
|
case "TaskOutput": return opts.agentTasks.taskOutput(request.id);
|
|
14529
14528
|
case "WaitTasks": return opts.agentTasks.waitTasks(request.ids, request);
|
|
14530
14529
|
case "MessageAgent": return opts.agentTasks.messageAgent(request);
|
|
@@ -14551,7 +14550,7 @@ const exitToResponse = (exit) => {
|
|
|
14551
14550
|
const errorMessage$2 = (error) => typeof error === "string" ? error : error instanceof Error ? error.message : String(error);
|
|
14552
14551
|
const excludedToolNames = (excludeTools) => {
|
|
14553
14552
|
const names = new Set(excludeTools);
|
|
14554
|
-
if (names.has("
|
|
14553
|
+
if (names.has("subagent")) {
|
|
14555
14554
|
names.add("messageAgent");
|
|
14556
14555
|
if (names.has("bash")) for (const name of [
|
|
14557
14556
|
"taskOutput",
|
|
@@ -20811,7 +20810,7 @@ const makeWith$1 = fnUntraced(function* (options) {
|
|
|
20811
20810
|
return child ? succeed$1(child) : fail$1(`No task with id ${JSON.stringify(id)}. You can only address tasks you started; call listTasks() to see them.`);
|
|
20812
20811
|
});
|
|
20813
20812
|
const agentTasks = {
|
|
20814
|
-
|
|
20813
|
+
subagent: fnUntraced(function* ({ id, prompt, background, environment }) {
|
|
20815
20814
|
const child = {
|
|
20816
20815
|
id: Number(id),
|
|
20817
20816
|
taskOwner: crypto.randomUUID(),
|
|
@@ -20826,7 +20825,7 @@ const makeWith$1 = fnUntraced(function* (options) {
|
|
|
20826
20825
|
yield* startTurn({
|
|
20827
20826
|
child,
|
|
20828
20827
|
label: prompt,
|
|
20829
|
-
prompt: `You have been asked using the "
|
|
20828
|
+
prompt: `You have been asked using the "subagent" function to complete the following task. Try to avoid using the "subagent" function yourself unless strictly necessary:
|
|
20830
20829
|
|
|
20831
20830
|
${prompt}`,
|
|
20832
20831
|
environmentUpdate: getOrUndefined(environment.update),
|
|
@@ -20857,7 +20856,7 @@ ${prompt}`,
|
|
|
20857
20856
|
resume: () => {}
|
|
20858
20857
|
});
|
|
20859
20858
|
child.mailbox.notify();
|
|
20860
|
-
return
|
|
20859
|
+
return;
|
|
20861
20860
|
}
|
|
20862
20861
|
child.turn = makeTurn(true);
|
|
20863
20862
|
yield* startTurn({
|
|
@@ -20866,14 +20865,11 @@ ${prompt}`,
|
|
|
20866
20865
|
label: message,
|
|
20867
20866
|
background: true
|
|
20868
20867
|
});
|
|
20869
|
-
return childTask(child);
|
|
20870
20868
|
}),
|
|
20871
20869
|
stopTask: fnUntraced(function* (id) {
|
|
20872
|
-
const
|
|
20873
|
-
const turn = child.turn;
|
|
20870
|
+
const turn = (yield* lookupChild(id)).turn;
|
|
20874
20871
|
turn.reported = true;
|
|
20875
20872
|
if (turn.status === "running") yield* interrupt$2(turn.fiber);
|
|
20876
|
-
return childTask(child);
|
|
20877
20873
|
}),
|
|
20878
20874
|
listTasks: sync(() => Array$1.from(children.values(), childTask))
|
|
20879
20875
|
};
|
|
@@ -21458,8 +21454,8 @@ ${options.agentsMd}
|
|
|
21458
21454
|
const when = (condition, text) => condition ? text : "";
|
|
21459
21455
|
const taskInstructions = (tools) => {
|
|
21460
21456
|
const bash = tools.offers("bash");
|
|
21461
|
-
const
|
|
21462
|
-
if (!bash && !
|
|
21457
|
+
const subagent = tools.offers("subagent");
|
|
21458
|
+
if (!bash && !subagent) return "";
|
|
21463
21459
|
const functions = [
|
|
21464
21460
|
["taskOutput", `"taskOutput" reads one`],
|
|
21465
21461
|
["waitTasks", `"waitTasks" waits for a list of them and returns any still running at its timeout as "running"`],
|
|
@@ -21467,22 +21463,20 @@ const taskInstructions = (tools) => {
|
|
|
21467
21463
|
["listTasks", `"listTasks" lists yours`]
|
|
21468
21464
|
].filter(([name]) => tools.offers(name)).map(([, text]) => text);
|
|
21469
21465
|
return `
|
|
21470
|
-
- ${bash &&
|
|
21466
|
+
- ${bash && subagent ? "Background commands and sub-agents are" : bash ? "Background commands are" : "Sub-agents are"} tasks with ids.${functions.length === 0 ? "" : ` ${functions.length === 1 ? functions[0] : `${functions.slice(0, -1).join(", ")} and ${functions.at(-1)}`}.`}${tools.taskPushes ? ` When a task ends, its status and output are sent to you as a \`<task id="..." kind="..." status="...">\` message, unless a task function already gave you its final status, so you do not need to poll.` : bash && tools.offers("taskOutput") ? ` Background commands are not sent to you when they end: check them with "taskOutput".` : ""}`;
|
|
21471
21467
|
};
|
|
21472
21468
|
const generateSystemTools = (tools, conversationMode) => `YOU ONLY HAVE ONE TOOL AVAILABLE: "execute", to run javascript code to do your work.
|
|
21473
21469
|
|
|
21474
21470
|
- Use \`console.log\` to print any output you need.
|
|
21475
21471
|
- Print only what you need, as everything printed stays in your context.${when(tools.offers("readFile"), ` Read line ranges with "startLine" / "endLine" instead of whole files.`)} Slice or filter large results before printing them.
|
|
21476
21472
|
- Use top level await.${when(tools.offers("search") && tools.offers("rg"), `
|
|
21477
|
-
- Prefer using the "search" function over "rg", unless you are targeting specific files or patterns.`)}${when(tools.offers("
|
|
21478
|
-
- You can add / update / remove multiple files in one go with "applyPatch".${when(tools.offers("writeFile"), ` Prefer it over "writeFile" to update existing files.`)}`)}${when(tools.offers("bash"), `
|
|
21473
|
+
- Prefer using the "search" function over "rg", unless you are targeting specific files or patterns.`)}${when(tools.offers("bash"), `
|
|
21479
21474
|
- Avoid passing scripts into the "bash" function, and instead write javascript.`)}
|
|
21480
21475
|
- Variables are not shared between executions.
|
|
21481
|
-
- Do not use \`require\`, \`import\`, \`process\`, or any other Node.js apis.${
|
|
21482
|
-
- "delegate" runs a sub-agent and waits for it. Pass \`background: true\` to keep working while it runs: it returns an agent task straight away, and the agent's result is sent to you when it ends.${when(tools.offers("messageAgent"), ` Use "messageAgent" to send a message to a sub-agent.`)}`)}${taskInstructions(tools)}${when(!conversationMode, `
|
|
21476
|
+
- Do not use \`require\`, \`import\`, \`process\`, or any other Node.js apis.${taskInstructions(tools)}${when(!conversationMode, `
|
|
21483
21477
|
|
|
21484
21478
|
When you have fully completed your task, call the "taskComplete" function with the final output.
|
|
21485
|
-
Make sure every detail of the task is done before calling "taskComplete".${when(tools.offers("
|
|
21479
|
+
Make sure every detail of the task is done before calling "taskComplete".${when(tools.offers("subagent"), `
|
|
21486
21480
|
Any sub-agents you started must finish first: "taskComplete" fails while they are running.`)}`)}${when(tools.offers("readFile") && tools.offers("ls"), example)}
|
|
21487
21481
|
|
|
21488
21482
|
These are the functions available to you:
|
|
@@ -21504,12 +21498,7 @@ Here is how you would read a file and list a directory:
|
|
|
21504
21498
|
\`\`\`
|
|
21505
21499
|
const [files, content] = await Promise.all([
|
|
21506
21500
|
ls("."),
|
|
21507
|
-
readFile({
|
|
21508
|
-
path: "package.json",
|
|
21509
|
-
startLine: 1,
|
|
21510
|
-
endLine: 10,
|
|
21511
|
-
lineNumbers: false,
|
|
21512
|
-
})
|
|
21501
|
+
readFile({ path: "package.json", startLine: 1, endLine: 10 })
|
|
21513
21502
|
])
|
|
21514
21503
|
console.log("files:", files)
|
|
21515
21504
|
console.log("package.json:", JSON.parse(content))
|
|
@@ -22076,7 +22065,7 @@ const make$7 = fnUntraced(function* (options) {
|
|
|
22076
22065
|
return update(session.id, {
|
|
22077
22066
|
sessionUpdate: announced ? "tool_call_update" : "tool_call",
|
|
22078
22067
|
toolCallId: `subagent-${part.id}`,
|
|
22079
|
-
title: `
|
|
22068
|
+
title: `subagent: ${part.prompt.replace(/\s+/g, " ").trim().slice(0, 120)}`,
|
|
22080
22069
|
kind: "think",
|
|
22081
22070
|
status: "in_progress",
|
|
22082
22071
|
rawInput: { prompt: part.prompt }
|
|
@@ -28627,7 +28616,7 @@ const transformToolCallParams$1 = fnUntraced(function* (options, toolName, toolP
|
|
|
28627
28616
|
return yield* decodeEffect(codec)(toolParams).pipe(flatMap$1((decoded) => encodeUnknownEffect(tool.parametersSchema)(decoded)), orElseSucceed(() => toolParams));
|
|
28628
28617
|
});
|
|
28629
28618
|
// package.json
|
|
28630
|
-
var version$1 = "0.
|
|
28619
|
+
var version$1 = "0.23.0";
|
|
28631
28620
|
// src/ClaudeAgent.ts
|
|
28632
28621
|
const minimumClaudeCodeVersion = "2.1.248";
|
|
28633
28622
|
const serverName = "clanka";
|