clanka 0.22.6 → 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.js +6 -6
- 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.js +9 -9
- package/dist/AgentExecutor.test.js +13 -13
- package/dist/AgentImage.test.js +4 -4
- package/dist/AgentSubagents.test.js +11 -11
- package/dist/AgentTools.d.ts +78 -78
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +8 -8
- package/dist/McpServers.test.js +1 -1
- package/dist/bin/cli.mjs +19 -19
- 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 +6 -6
- package/src/AgentCallerConfig.test.ts +14 -10
- package/src/AgentEnvironment.test.ts +2 -2
- package/src/AgentExecutor.test.ts +13 -13
- package/src/AgentExecutor.ts +16 -16
- package/src/AgentImage.test.ts +4 -4
- package/src/AgentSubagents.test.ts +12 -12
- package/src/AgentTools.ts +11 -11
- package/src/McpServers.test.ts +1 -1
|
@@ -85,7 +85,7 @@ const invalidRequest = AiError.make({
|
|
|
85
85
|
}),
|
|
86
86
|
});
|
|
87
87
|
const complete = (output) => Stream.make(toolCall("complete", `await taskComplete(${JSON.stringify(output)})`));
|
|
88
|
-
const spawnBackground = (task) => toolCall(`spawn-${task}`, `const result = await
|
|
88
|
+
const spawnBackground = (task) => toolCall(`spawn-${task}`, `const result = await subagent({ prompt: "${task}", background: true })
|
|
89
89
|
console.log(JSON.stringify(result))`);
|
|
90
90
|
const toolResultTexts = (prompt) => prompt.content.flatMap((message) => message.role === "tool"
|
|
91
91
|
? message.content.flatMap((part) => part.type === "tool-result" ? [String(part.result)] : [])
|
|
@@ -265,7 +265,7 @@ for (const [executorName, executorLayer] of executors) {
|
|
|
265
265
|
}
|
|
266
266
|
switch (call.index) {
|
|
267
267
|
case 0:
|
|
268
|
-
return Stream.make(toolCall("too-early", `await
|
|
268
|
+
return Stream.make(toolCall("too-early", `await subagent({ prompt: "TASK-CHILD", background: true })
|
|
269
269
|
try {
|
|
270
270
|
await taskComplete("too early")
|
|
271
271
|
console.log("ACCEPTED")
|
|
@@ -467,7 +467,7 @@ console.log("MESSAGE-VOID:", result === undefined)`));
|
|
|
467
467
|
switch (call.index) {
|
|
468
468
|
case 0:
|
|
469
469
|
// Foreground: blocks until the child is done.
|
|
470
|
-
return Stream.make(toolCall("foreground", `const result = await
|
|
470
|
+
return Stream.make(toolCall("foreground", `const result = await subagent({ prompt: "TASK-CHILD" })
|
|
471
471
|
console.log(JSON.stringify(result))`));
|
|
472
472
|
case 1:
|
|
473
473
|
return Stream.fromIterable(text("root done"));
|
|
@@ -512,8 +512,8 @@ await taskComplete("${name.toUpperCase()}:" + pwd.output.trim())`))));
|
|
|
512
512
|
case 0:
|
|
513
513
|
return Stream.make(toolCall("spawn", `await bash({ command: "mkdir -p a/one a/two" })
|
|
514
514
|
await changeDirectory("a")
|
|
515
|
-
const one = await
|
|
516
|
-
const two = await
|
|
515
|
+
const one = await subagent({ prompt: "TASK-CHILD-ONE", background: true })
|
|
516
|
+
const two = await subagent({ prompt: "TASK-CHILD-TWO", background: true })
|
|
517
517
|
console.log(JSON.stringify(await waitTasks({ ids: [one.id, two.id] })))
|
|
518
518
|
console.log("ROOT:" + (await bash({ command: "pwd" })).output.trim())`));
|
|
519
519
|
case 1:
|
|
@@ -539,7 +539,7 @@ console.log("ROOT:" + (await bash({ command: "pwd" })).output.trim())`));
|
|
|
539
539
|
switch (call.index) {
|
|
540
540
|
case 0:
|
|
541
541
|
return Stream.make(toolCall("mixed", `const bashTask = await bash({ command: "echo BASH-OUT", background: true })
|
|
542
|
-
const agentTask = await
|
|
542
|
+
const agentTask = await subagent({ prompt: "TASK-CHILD", background: true })
|
|
543
543
|
const ended = await waitTasks({ ids: [bashTask.id, agentTask.id] })
|
|
544
544
|
console.log(JSON.stringify(ended.map(({ kind, status, output }) => ({ kind, status, output: output.trim() }))))`));
|
|
545
545
|
case 1:
|
|
@@ -580,7 +580,7 @@ await taskComplete(JSON.stringify({ seen, attempts }))`));
|
|
|
580
580
|
switch (call.index) {
|
|
581
581
|
case 0:
|
|
582
582
|
return Stream.make(toolCall("spawn", `const server = await bash({ command: "sleep 30", background: true })
|
|
583
|
-
const child = await
|
|
583
|
+
const child = await subagent({ prompt: "TASK-CHILD BASH-ID:" + server.id })
|
|
584
584
|
console.log("CHILD:" + child.output)
|
|
585
585
|
const mine = await listTasks()
|
|
586
586
|
console.log("ROOT:" + JSON.stringify(mine.map((task) => task.kind + ":" + task.status).sort()))`));
|
|
@@ -615,7 +615,7 @@ console.log("ROOT:" + JSON.stringify(mine.map((task) => task.kind + ":" + task.s
|
|
|
615
615
|
}
|
|
616
616
|
switch (call.index) {
|
|
617
617
|
case 0:
|
|
618
|
-
return Stream.make(toolCall("wait", `const child = await
|
|
618
|
+
return Stream.make(toolCall("wait", `const child = await subagent({ prompt: "TASK-CHILD", background: true })
|
|
619
619
|
const [task] = await waitTasks({ ids: [child.id], timeoutMs: 200 })
|
|
620
620
|
console.log("WAITED:" + task.status)`));
|
|
621
621
|
case 1:
|
|
@@ -647,7 +647,7 @@ console.log("WAITED:" + task.status)`));
|
|
|
647
647
|
switch (call.index) {
|
|
648
648
|
case 0:
|
|
649
649
|
return Stream.make(toolCall("wait", `const quick = await bash({ command: "echo BASH-OUT", background: true })
|
|
650
|
-
const child = await
|
|
650
|
+
const child = await subagent({ prompt: "TASK-CHILD", background: true })
|
|
651
651
|
const slow = await bash({ command: "sleep 30", background: true })
|
|
652
652
|
await waitTasks({ ids: [quick.id, child.id, slow.id] })
|
|
653
653
|
console.log("RETURNED")`));
|
|
@@ -701,8 +701,8 @@ describe("agent tasks (rpc executor, slow callbacks)", () => {
|
|
|
701
701
|
}
|
|
702
702
|
switch (call.index) {
|
|
703
703
|
case 0:
|
|
704
|
-
return Stream.make(toolCall("wait", `const a = await
|
|
705
|
-
const b = await
|
|
704
|
+
return Stream.make(toolCall("wait", `const a = await subagent({ prompt: "TASK-CHILD-A", background: true })
|
|
705
|
+
const b = await subagent({ prompt: "TASK-CHILD-B", background: true })
|
|
706
706
|
const ended = await waitTasks({ ids: [a.id, b.id] })
|
|
707
707
|
console.log(ended.map((task) => task.output).join(" "))`));
|
|
708
708
|
case 1:
|
package/dist/AgentTools.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare class TaskCompleter extends TaskCompleter_base {
|
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* What a task is: a background `bash` command or a sub-agent started with
|
|
39
|
-
* `
|
|
39
|
+
* `subagent`.
|
|
40
40
|
*
|
|
41
41
|
* @since 1.0.0
|
|
42
42
|
* @category Models
|
|
@@ -94,7 +94,7 @@ export interface AgentTasks {
|
|
|
94
94
|
* it resolves once the agent has finished, and dies if the agent failed.
|
|
95
95
|
* In the background it resolves straight away with `status: "running"`.
|
|
96
96
|
*/
|
|
97
|
-
readonly
|
|
97
|
+
readonly subagent: (options: {
|
|
98
98
|
readonly id: string;
|
|
99
99
|
readonly prompt: string;
|
|
100
100
|
readonly background: boolean;
|
|
@@ -304,25 +304,6 @@ export declare const AgentTools: Toolkit.Toolkit<{
|
|
|
304
304
|
readonly failure: Schema.Never;
|
|
305
305
|
readonly failureMode: "error";
|
|
306
306
|
}, DirectoryChanger>;
|
|
307
|
-
readonly delegate: Tool.Tool<"delegate", {
|
|
308
|
-
readonly parameters: Schema.Struct<{
|
|
309
|
-
readonly prompt: Schema.String;
|
|
310
|
-
readonly background: Schema.optional<Schema.Boolean>;
|
|
311
|
-
}>;
|
|
312
|
-
readonly success: Schema.Struct<{
|
|
313
|
-
readonly id: Schema.String;
|
|
314
|
-
readonly kind: Schema.Literals<readonly ["bash", "agent"]>;
|
|
315
|
-
readonly status: Schema.Literals<readonly ["running", "completed", "failed", "stopped"]>;
|
|
316
|
-
/** The bash command, or the sub-agent's prompt. */
|
|
317
|
-
readonly description: Schema.String;
|
|
318
|
-
/** Output so far while running; the final output, or the error, once ended. */
|
|
319
|
-
readonly output: Schema.String;
|
|
320
|
-
/** bash only: set when the command exited on its own. */
|
|
321
|
-
readonly exitCode: Schema.optional<Schema.Number>;
|
|
322
|
-
}>;
|
|
323
|
-
readonly failure: Schema.String;
|
|
324
|
-
readonly failureMode: "error";
|
|
325
|
-
}, AgentTaskExecutor>;
|
|
326
307
|
readonly fetchMarkdown: Tool.Tool<"fetchMarkdown", {
|
|
327
308
|
readonly parameters: Schema.String;
|
|
328
309
|
readonly success: Schema.String;
|
|
@@ -421,6 +402,25 @@ export declare const AgentTools: Toolkit.Toolkit<{
|
|
|
421
402
|
readonly failure: Schema.String;
|
|
422
403
|
readonly failureMode: "error";
|
|
423
404
|
}, AgentTaskExecutor>;
|
|
405
|
+
readonly subagent: Tool.Tool<"subagent", {
|
|
406
|
+
readonly parameters: Schema.Struct<{
|
|
407
|
+
readonly prompt: Schema.String;
|
|
408
|
+
readonly background: Schema.optional<Schema.Boolean>;
|
|
409
|
+
}>;
|
|
410
|
+
readonly success: Schema.Struct<{
|
|
411
|
+
readonly id: Schema.String;
|
|
412
|
+
readonly kind: Schema.Literals<readonly ["bash", "agent"]>;
|
|
413
|
+
readonly status: Schema.Literals<readonly ["running", "completed", "failed", "stopped"]>;
|
|
414
|
+
/** The bash command, or the sub-agent's prompt. */
|
|
415
|
+
readonly description: Schema.String;
|
|
416
|
+
/** Output so far while running; the final output, or the error, once ended. */
|
|
417
|
+
readonly output: Schema.String;
|
|
418
|
+
/** bash only: set when the command exited on its own. */
|
|
419
|
+
readonly exitCode: Schema.optional<Schema.Number>;
|
|
420
|
+
}>;
|
|
421
|
+
readonly failure: Schema.String;
|
|
422
|
+
readonly failureMode: "error";
|
|
423
|
+
}, AgentTaskExecutor>;
|
|
424
424
|
readonly taskComplete: Tool.Tool<"taskComplete", {
|
|
425
425
|
readonly parameters: Schema.String;
|
|
426
426
|
readonly success: Schema.Void;
|
|
@@ -518,25 +518,6 @@ export declare const AgentToolsWithSearch: Toolkit.Toolkit<{
|
|
|
518
518
|
readonly failure: Schema.Never;
|
|
519
519
|
readonly failureMode: "error";
|
|
520
520
|
}, DirectoryChanger>;
|
|
521
|
-
readonly delegate: Tool.Tool<"delegate", {
|
|
522
|
-
readonly parameters: Schema.Struct<{
|
|
523
|
-
readonly prompt: Schema.String;
|
|
524
|
-
readonly background: Schema.optional<Schema.Boolean>;
|
|
525
|
-
}>;
|
|
526
|
-
readonly success: Schema.Struct<{
|
|
527
|
-
readonly id: Schema.String;
|
|
528
|
-
readonly kind: Schema.Literals<readonly ["bash", "agent"]>;
|
|
529
|
-
readonly status: Schema.Literals<readonly ["running", "completed", "failed", "stopped"]>;
|
|
530
|
-
/** The bash command, or the sub-agent's prompt. */
|
|
531
|
-
readonly description: Schema.String;
|
|
532
|
-
/** Output so far while running; the final output, or the error, once ended. */
|
|
533
|
-
readonly output: Schema.String;
|
|
534
|
-
/** bash only: set when the command exited on its own. */
|
|
535
|
-
readonly exitCode: Schema.optional<Schema.Number>;
|
|
536
|
-
}>;
|
|
537
|
-
readonly failure: Schema.String;
|
|
538
|
-
readonly failureMode: "error";
|
|
539
|
-
}, AgentTaskExecutor>;
|
|
540
521
|
readonly fetchMarkdown: Tool.Tool<"fetchMarkdown", {
|
|
541
522
|
readonly parameters: Schema.String;
|
|
542
523
|
readonly success: Schema.String;
|
|
@@ -641,6 +622,25 @@ export declare const AgentToolsWithSearch: Toolkit.Toolkit<{
|
|
|
641
622
|
readonly failure: Schema.String;
|
|
642
623
|
readonly failureMode: "error";
|
|
643
624
|
}, AgentTaskExecutor>;
|
|
625
|
+
readonly subagent: Tool.Tool<"subagent", {
|
|
626
|
+
readonly parameters: Schema.Struct<{
|
|
627
|
+
readonly prompt: Schema.String;
|
|
628
|
+
readonly background: Schema.optional<Schema.Boolean>;
|
|
629
|
+
}>;
|
|
630
|
+
readonly success: Schema.Struct<{
|
|
631
|
+
readonly id: Schema.String;
|
|
632
|
+
readonly kind: Schema.Literals<readonly ["bash", "agent"]>;
|
|
633
|
+
readonly status: Schema.Literals<readonly ["running", "completed", "failed", "stopped"]>;
|
|
634
|
+
/** The bash command, or the sub-agent's prompt. */
|
|
635
|
+
readonly description: Schema.String;
|
|
636
|
+
/** Output so far while running; the final output, or the error, once ended. */
|
|
637
|
+
readonly output: Schema.String;
|
|
638
|
+
/** bash only: set when the command exited on its own. */
|
|
639
|
+
readonly exitCode: Schema.optional<Schema.Number>;
|
|
640
|
+
}>;
|
|
641
|
+
readonly failure: Schema.String;
|
|
642
|
+
readonly failureMode: "error";
|
|
643
|
+
}, AgentTaskExecutor>;
|
|
644
644
|
readonly taskComplete: Tool.Tool<"taskComplete", {
|
|
645
645
|
readonly parameters: Schema.String;
|
|
646
646
|
readonly success: Schema.Void;
|
|
@@ -745,25 +745,6 @@ export declare const AgentToolHandlersNoDeps: Layer.Layer<Tool.HandlersFor<{
|
|
|
745
745
|
readonly failure: Schema.Never;
|
|
746
746
|
readonly failureMode: "error";
|
|
747
747
|
}, DirectoryChanger>;
|
|
748
|
-
readonly delegate: Tool.Tool<"delegate", {
|
|
749
|
-
readonly parameters: Schema.Struct<{
|
|
750
|
-
readonly prompt: Schema.String;
|
|
751
|
-
readonly background: Schema.optional<Schema.Boolean>;
|
|
752
|
-
}>;
|
|
753
|
-
readonly success: Schema.Struct<{
|
|
754
|
-
readonly id: Schema.String;
|
|
755
|
-
readonly kind: Schema.Literals<readonly ["bash", "agent"]>;
|
|
756
|
-
readonly status: Schema.Literals<readonly ["running", "completed", "failed", "stopped"]>;
|
|
757
|
-
/** The bash command, or the sub-agent's prompt. */
|
|
758
|
-
readonly description: Schema.String;
|
|
759
|
-
/** Output so far while running; the final output, or the error, once ended. */
|
|
760
|
-
readonly output: Schema.String;
|
|
761
|
-
/** bash only: set when the command exited on its own. */
|
|
762
|
-
readonly exitCode: Schema.optional<Schema.Number>;
|
|
763
|
-
}>;
|
|
764
|
-
readonly failure: Schema.String;
|
|
765
|
-
readonly failureMode: "error";
|
|
766
|
-
}, AgentTaskExecutor>;
|
|
767
748
|
readonly fetchMarkdown: Tool.Tool<"fetchMarkdown", {
|
|
768
749
|
readonly parameters: Schema.String;
|
|
769
750
|
readonly success: Schema.String;
|
|
@@ -868,6 +849,25 @@ export declare const AgentToolHandlersNoDeps: Layer.Layer<Tool.HandlersFor<{
|
|
|
868
849
|
readonly failure: Schema.String;
|
|
869
850
|
readonly failureMode: "error";
|
|
870
851
|
}, AgentTaskExecutor>;
|
|
852
|
+
readonly subagent: Tool.Tool<"subagent", {
|
|
853
|
+
readonly parameters: Schema.Struct<{
|
|
854
|
+
readonly prompt: Schema.String;
|
|
855
|
+
readonly background: Schema.optional<Schema.Boolean>;
|
|
856
|
+
}>;
|
|
857
|
+
readonly success: Schema.Struct<{
|
|
858
|
+
readonly id: Schema.String;
|
|
859
|
+
readonly kind: Schema.Literals<readonly ["bash", "agent"]>;
|
|
860
|
+
readonly status: Schema.Literals<readonly ["running", "completed", "failed", "stopped"]>;
|
|
861
|
+
/** The bash command, or the sub-agent's prompt. */
|
|
862
|
+
readonly description: Schema.String;
|
|
863
|
+
/** Output so far while running; the final output, or the error, once ended. */
|
|
864
|
+
readonly output: Schema.String;
|
|
865
|
+
/** bash only: set when the command exited on its own. */
|
|
866
|
+
readonly exitCode: Schema.optional<Schema.Number>;
|
|
867
|
+
}>;
|
|
868
|
+
readonly failure: Schema.String;
|
|
869
|
+
readonly failureMode: "error";
|
|
870
|
+
}, AgentTaskExecutor>;
|
|
871
871
|
readonly taskComplete: Tool.Tool<"taskComplete", {
|
|
872
872
|
readonly parameters: Schema.String;
|
|
873
873
|
readonly success: Schema.Void;
|
|
@@ -970,25 +970,6 @@ export declare const AgentToolHandlersTest: Layer.Layer<Tool.HandlersFor<{
|
|
|
970
970
|
readonly failure: Schema.Never;
|
|
971
971
|
readonly failureMode: "error";
|
|
972
972
|
}, DirectoryChanger>;
|
|
973
|
-
readonly delegate: Tool.Tool<"delegate", {
|
|
974
|
-
readonly parameters: Schema.Struct<{
|
|
975
|
-
readonly prompt: Schema.String;
|
|
976
|
-
readonly background: Schema.optional<Schema.Boolean>;
|
|
977
|
-
}>;
|
|
978
|
-
readonly success: Schema.Struct<{
|
|
979
|
-
readonly id: Schema.String;
|
|
980
|
-
readonly kind: Schema.Literals<readonly ["bash", "agent"]>;
|
|
981
|
-
readonly status: Schema.Literals<readonly ["running", "completed", "failed", "stopped"]>;
|
|
982
|
-
/** The bash command, or the sub-agent's prompt. */
|
|
983
|
-
readonly description: Schema.String;
|
|
984
|
-
/** Output so far while running; the final output, or the error, once ended. */
|
|
985
|
-
readonly output: Schema.String;
|
|
986
|
-
/** bash only: set when the command exited on its own. */
|
|
987
|
-
readonly exitCode: Schema.optional<Schema.Number>;
|
|
988
|
-
}>;
|
|
989
|
-
readonly failure: Schema.String;
|
|
990
|
-
readonly failureMode: "error";
|
|
991
|
-
}, AgentTaskExecutor>;
|
|
992
973
|
readonly fetchMarkdown: Tool.Tool<"fetchMarkdown", {
|
|
993
974
|
readonly parameters: Schema.String;
|
|
994
975
|
readonly success: Schema.String;
|
|
@@ -1093,6 +1074,25 @@ export declare const AgentToolHandlersTest: Layer.Layer<Tool.HandlersFor<{
|
|
|
1093
1074
|
readonly failure: Schema.String;
|
|
1094
1075
|
readonly failureMode: "error";
|
|
1095
1076
|
}, AgentTaskExecutor>;
|
|
1077
|
+
readonly subagent: Tool.Tool<"subagent", {
|
|
1078
|
+
readonly parameters: Schema.Struct<{
|
|
1079
|
+
readonly prompt: Schema.String;
|
|
1080
|
+
readonly background: Schema.optional<Schema.Boolean>;
|
|
1081
|
+
}>;
|
|
1082
|
+
readonly success: Schema.Struct<{
|
|
1083
|
+
readonly id: Schema.String;
|
|
1084
|
+
readonly kind: Schema.Literals<readonly ["bash", "agent"]>;
|
|
1085
|
+
readonly status: Schema.Literals<readonly ["running", "completed", "failed", "stopped"]>;
|
|
1086
|
+
/** The bash command, or the sub-agent's prompt. */
|
|
1087
|
+
readonly description: Schema.String;
|
|
1088
|
+
/** Output so far while running; the final output, or the error, once ended. */
|
|
1089
|
+
readonly output: Schema.String;
|
|
1090
|
+
/** bash only: set when the command exited on its own. */
|
|
1091
|
+
readonly exitCode: Schema.optional<Schema.Number>;
|
|
1092
|
+
}>;
|
|
1093
|
+
readonly failure: Schema.String;
|
|
1094
|
+
readonly failureMode: "error";
|
|
1095
|
+
}, AgentTaskExecutor>;
|
|
1096
1096
|
readonly taskComplete: Tool.Tool<"taskComplete", {
|
|
1097
1097
|
readonly parameters: Schema.String;
|
|
1098
1098
|
readonly success: Schema.Void;
|
package/dist/AgentTools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentTools.d.ts","sourceRoot":"","sources":["../src/AgentTools.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAA;AAGzD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAA;AACzE,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,IAAI,MAAM,aAAa,C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;;;;;;;;;;;;;;;;;;YAJzD,mDAAmD;;YAEnD,+EAA+E;;YAE/E,yDAAyD;;;;;;;;;;;;;;;YAJzD,mDAAmD;;YAEnD,+EAA+E;;YAE/E,yDAAyD;;;;;;;;;;;;;;;;;;;;;;;;uFA4mC1D,CAAA"}
|
package/dist/AgentTools.js
CHANGED
|
@@ -47,7 +47,7 @@ export class TaskCompleter extends Context.Service()("clanka/AgentTools/TaskComp
|
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* What a task is: a background `bash` command or a sub-agent started with
|
|
50
|
-
* `
|
|
50
|
+
* `subagent`.
|
|
51
51
|
*
|
|
52
52
|
* @since 1.0.0
|
|
53
53
|
* @category Models
|
|
@@ -96,7 +96,7 @@ export class AgentTaskExecutor extends Context.Service()("clanka/AgentTools/Agen
|
|
|
96
96
|
* @category Context
|
|
97
97
|
*/
|
|
98
98
|
export const agentTasksUnavailable = {
|
|
99
|
-
|
|
99
|
+
subagent: () => Effect.die(new Error("Sub-agents are not available here")),
|
|
100
100
|
taskOutput: () => Effect.fail("Sub-agents are not available here"),
|
|
101
101
|
waitTasks: () => Effect.fail("Sub-agents are not available here"),
|
|
102
102
|
messageAgent: () => Effect.fail("Sub-agents are not available here"),
|
|
@@ -228,7 +228,7 @@ export const AgentTools = Toolkit.make(Tool.make("changeDirectory", {
|
|
|
228
228
|
}),
|
|
229
229
|
success: Schema.String,
|
|
230
230
|
dependencies: [CurrentDirectory],
|
|
231
|
-
}), Tool.make("
|
|
231
|
+
}), Tool.make("subagent", {
|
|
232
232
|
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.",
|
|
233
233
|
parameters: Schema.Struct({
|
|
234
234
|
prompt: Schema.String,
|
|
@@ -803,12 +803,12 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(Effect.gen(f
|
|
|
803
803
|
}
|
|
804
804
|
return `Success. Updated the following files:\n${out.join("\n")}`;
|
|
805
805
|
}, Effect.orDie),
|
|
806
|
-
|
|
807
|
-
const { prompt, background = false } = yield*
|
|
808
|
-
yield* Effect.logInfo(`Calling "
|
|
806
|
+
subagent: Effect.fn("AgentTools.subagent")(function* (options) {
|
|
807
|
+
const { prompt, background = false } = yield* decodeSubagent(options);
|
|
808
|
+
yield* Effect.logInfo(`Calling "subagent"`).pipe(Effect.annotateLogs({ background }));
|
|
809
809
|
const id = yield* registerAgentTask();
|
|
810
810
|
const agentTasks = yield* AgentTaskExecutor;
|
|
811
|
-
return yield* agentTasks.
|
|
811
|
+
return yield* agentTasks.subagent({ id, prompt, background });
|
|
812
812
|
}),
|
|
813
813
|
messageAgent: Effect.fn("AgentTools.messageAgent")(function* (input) {
|
|
814
814
|
const options = yield* decodeMessageAgent(input);
|
|
@@ -848,7 +848,7 @@ const decodeParams = (schema, usage) => {
|
|
|
848
848
|
const decode = Schema.decodeUnknownEffect(schema);
|
|
849
849
|
return (input) => Effect.mapError(decode(input), () => usage);
|
|
850
850
|
};
|
|
851
|
-
const
|
|
851
|
+
const decodeSubagent = decodeParams(AgentTools.tools.subagent.parametersSchema, 'subagent requires an options object, for example: subagent({ prompt: "..." }) or subagent({ prompt: "...", background: true }).');
|
|
852
852
|
const decodeMessageAgent = decodeParams(AgentTools.tools.messageAgent.parametersSchema, 'messageAgent requires an options object, for example: messageAgent({ id: "3", message: "..." }).');
|
|
853
853
|
const decodeTaskOutput = decodeParams(AgentTools.tools.taskOutput.parametersSchema, 'taskOutput requires a task id, for example: taskOutput("1").');
|
|
854
854
|
const decodeWaitTasks = decodeParams(AgentTools.tools.waitTasks.parametersSchema, 'waitTasks requires an options object, for example: waitTasks({ ids: ["3", "4"] }) or waitTasks({ ids: ["3"], timeoutMs: 60000 }).');
|
package/dist/McpServers.test.js
CHANGED
|
@@ -588,7 +588,7 @@ await taskComplete(JSON.stringify({ crashed, after: await attempt(mcp.fake.echo(
|
|
|
588
588
|
return "await taskComplete(await mcp.fake.ping({}))";
|
|
589
589
|
}
|
|
590
590
|
return call.index === 0
|
|
591
|
-
? `const child = await
|
|
591
|
+
? `const child = await subagent({ prompt: "TASK-CHILD" })
|
|
592
592
|
console.log(JSON.stringify(child))
|
|
593
593
|
console.log(await mcp.fake.screenshot({}))`
|
|
594
594
|
: 'await taskComplete("done")';
|
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,
|
|
@@ -12062,11 +12062,11 @@ const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(gen(function* () {
|
|
|
12062
12062
|
}
|
|
12063
12063
|
return `Success. Updated the following files:\n${out.join("\n")}`;
|
|
12064
12064
|
}, orDie),
|
|
12065
|
-
|
|
12066
|
-
const { prompt, background = false } = yield*
|
|
12067
|
-
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 }));
|
|
12068
12068
|
const id = yield* registerAgentTask();
|
|
12069
|
-
return yield* (yield* AgentTaskExecutor).
|
|
12069
|
+
return yield* (yield* AgentTaskExecutor).subagent({
|
|
12070
12070
|
id,
|
|
12071
12071
|
prompt,
|
|
12072
12072
|
background
|
|
@@ -12091,7 +12091,7 @@ const decodeParams$1 = (schema, usage) => {
|
|
|
12091
12091
|
const decode = decodeUnknownEffect$1(schema);
|
|
12092
12092
|
return (input) => mapError(decode(input), () => usage);
|
|
12093
12093
|
};
|
|
12094
|
-
const
|
|
12094
|
+
const decodeSubagent = decodeParams$1(AgentTools.tools.subagent.parametersSchema, "subagent requires an options object, for example: subagent({ prompt: \"...\" }) or subagent({ prompt: \"...\", background: true }).");
|
|
12095
12095
|
const decodeMessageAgent = decodeParams$1(AgentTools.tools.messageAgent.parametersSchema, "messageAgent requires an options object, for example: messageAgent({ id: \"3\", message: \"...\" }).");
|
|
12096
12096
|
const decodeTaskOutput = decodeParams$1(AgentTools.tools.taskOutput.parametersSchema, "taskOutput requires a task id, for example: taskOutput(\"1\").");
|
|
12097
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 }).");
|
|
@@ -14248,7 +14248,7 @@ const makeLocalWith = fnUntraced(function* (options) {
|
|
|
14248
14248
|
}));
|
|
14249
14249
|
const taskServices = empty$5().pipe(add(TaskCompleter, opts.onTaskComplete), add(DirectoryChanger, changeDirectory), add(AgentTaskExecutor, {
|
|
14250
14250
|
...opts.agentTasks,
|
|
14251
|
-
|
|
14251
|
+
subagent: (options) => renderEnvironment(currentEnvironment(), { reset: true }).pipe(flatMap$1((environment) => opts.agentTasks.subagent({
|
|
14252
14252
|
...options,
|
|
14253
14253
|
environment
|
|
14254
14254
|
})))
|
|
@@ -14420,7 +14420,7 @@ const layerLocal$1 = (options) => effect(AgentExecutor, withBuiltInHandlers(make
|
|
|
14420
14420
|
const layerRpc = effect(AgentExecutor, makeRpc);
|
|
14421
14421
|
const AgentRequest = TaggedUnion({
|
|
14422
14422
|
TaskComplete: { summary: String$7 },
|
|
14423
|
-
|
|
14423
|
+
Subagent: {
|
|
14424
14424
|
id: String$7,
|
|
14425
14425
|
prompt: String$7,
|
|
14426
14426
|
background: Boolean$4,
|
|
@@ -14523,7 +14523,7 @@ const encodeRpcParams = (tool, params) => {
|
|
|
14523
14523
|
const handleRequest = (opts, request) => {
|
|
14524
14524
|
switch (request._tag) {
|
|
14525
14525
|
case "TaskComplete": return opts.onTaskComplete(request.summary);
|
|
14526
|
-
case "
|
|
14526
|
+
case "Subagent": return opts.agentTasks.subagent(request);
|
|
14527
14527
|
case "TaskOutput": return opts.agentTasks.taskOutput(request.id);
|
|
14528
14528
|
case "WaitTasks": return opts.agentTasks.waitTasks(request.ids, request);
|
|
14529
14529
|
case "MessageAgent": return opts.agentTasks.messageAgent(request);
|
|
@@ -14550,7 +14550,7 @@ const exitToResponse = (exit) => {
|
|
|
14550
14550
|
const errorMessage$2 = (error) => typeof error === "string" ? error : error instanceof Error ? error.message : String(error);
|
|
14551
14551
|
const excludedToolNames = (excludeTools) => {
|
|
14552
14552
|
const names = new Set(excludeTools);
|
|
14553
|
-
if (names.has("
|
|
14553
|
+
if (names.has("subagent")) {
|
|
14554
14554
|
names.add("messageAgent");
|
|
14555
14555
|
if (names.has("bash")) for (const name of [
|
|
14556
14556
|
"taskOutput",
|
|
@@ -20810,7 +20810,7 @@ const makeWith$1 = fnUntraced(function* (options) {
|
|
|
20810
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.`);
|
|
20811
20811
|
});
|
|
20812
20812
|
const agentTasks = {
|
|
20813
|
-
|
|
20813
|
+
subagent: fnUntraced(function* ({ id, prompt, background, environment }) {
|
|
20814
20814
|
const child = {
|
|
20815
20815
|
id: Number(id),
|
|
20816
20816
|
taskOwner: crypto.randomUUID(),
|
|
@@ -20825,7 +20825,7 @@ const makeWith$1 = fnUntraced(function* (options) {
|
|
|
20825
20825
|
yield* startTurn({
|
|
20826
20826
|
child,
|
|
20827
20827
|
label: prompt,
|
|
20828
|
-
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:
|
|
20829
20829
|
|
|
20830
20830
|
${prompt}`,
|
|
20831
20831
|
environmentUpdate: getOrUndefined(environment.update),
|
|
@@ -21454,8 +21454,8 @@ ${options.agentsMd}
|
|
|
21454
21454
|
const when = (condition, text) => condition ? text : "";
|
|
21455
21455
|
const taskInstructions = (tools) => {
|
|
21456
21456
|
const bash = tools.offers("bash");
|
|
21457
|
-
const
|
|
21458
|
-
if (!bash && !
|
|
21457
|
+
const subagent = tools.offers("subagent");
|
|
21458
|
+
if (!bash && !subagent) return "";
|
|
21459
21459
|
const functions = [
|
|
21460
21460
|
["taskOutput", `"taskOutput" reads one`],
|
|
21461
21461
|
["waitTasks", `"waitTasks" waits for a list of them and returns any still running at its timeout as "running"`],
|
|
@@ -21463,7 +21463,7 @@ const taskInstructions = (tools) => {
|
|
|
21463
21463
|
["listTasks", `"listTasks" lists yours`]
|
|
21464
21464
|
].filter(([name]) => tools.offers(name)).map(([, text]) => text);
|
|
21465
21465
|
return `
|
|
21466
|
-
- ${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".` : ""}`;
|
|
21467
21467
|
};
|
|
21468
21468
|
const generateSystemTools = (tools, conversationMode) => `YOU ONLY HAVE ONE TOOL AVAILABLE: "execute", to run javascript code to do your work.
|
|
21469
21469
|
|
|
@@ -21476,7 +21476,7 @@ const generateSystemTools = (tools, conversationMode) => `YOU ONLY HAVE ONE TOOL
|
|
|
21476
21476
|
- Do not use \`require\`, \`import\`, \`process\`, or any other Node.js apis.${taskInstructions(tools)}${when(!conversationMode, `
|
|
21477
21477
|
|
|
21478
21478
|
When you have fully completed your task, call the "taskComplete" function with the final output.
|
|
21479
|
-
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"), `
|
|
21480
21480
|
Any sub-agents you started must finish first: "taskComplete" fails while they are running.`)}`)}${when(tools.offers("readFile") && tools.offers("ls"), example)}
|
|
21481
21481
|
|
|
21482
21482
|
These are the functions available to you:
|
|
@@ -22065,7 +22065,7 @@ const make$7 = fnUntraced(function* (options) {
|
|
|
22065
22065
|
return update(session.id, {
|
|
22066
22066
|
sessionUpdate: announced ? "tool_call_update" : "tool_call",
|
|
22067
22067
|
toolCallId: `subagent-${part.id}`,
|
|
22068
|
-
title: `
|
|
22068
|
+
title: `subagent: ${part.prompt.replace(/\s+/g, " ").trim().slice(0, 120)}`,
|
|
22069
22069
|
kind: "think",
|
|
22070
22070
|
status: "in_progress",
|
|
22071
22071
|
rawInput: { prompt: part.prompt }
|
|
@@ -28616,7 +28616,7 @@ const transformToolCallParams$1 = fnUntraced(function* (options, toolName, toolP
|
|
|
28616
28616
|
return yield* decodeEffect(codec)(toolParams).pipe(flatMap$1((decoded) => encodeUnknownEffect(tool.parametersSchema)(decoded)), orElseSucceed(() => toolParams));
|
|
28617
28617
|
});
|
|
28618
28618
|
// package.json
|
|
28619
|
-
var version$1 = "0.
|
|
28619
|
+
var version$1 = "0.23.0";
|
|
28620
28620
|
// src/ClaudeAgent.ts
|
|
28621
28621
|
const minimumClaudeCodeVersion = "2.1.248";
|
|
28622
28622
|
const serverName = "clanka";
|