clanka 0.21.0 → 0.22.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.
Files changed (45) hide show
  1. package/dist/Acp.test.js +19 -7
  2. package/dist/Acp.test.js.map +1 -1
  3. package/dist/Agent.d.ts +4 -4
  4. package/dist/Agent.d.ts.map +1 -1
  5. package/dist/Agent.js +140 -99
  6. package/dist/Agent.js.map +1 -1
  7. package/dist/Agent.test.js +5 -4
  8. package/dist/Agent.test.js.map +1 -1
  9. package/dist/AgentBashJobs.test.js +47 -32
  10. package/dist/AgentBashJobs.test.js.map +1 -1
  11. package/dist/AgentCallerConfig.test.js +26 -7
  12. package/dist/AgentCallerConfig.test.js.map +1 -1
  13. package/dist/AgentExecutor.d.ts +71 -41
  14. package/dist/AgentExecutor.d.ts.map +1 -1
  15. package/dist/AgentExecutor.js +86 -79
  16. package/dist/AgentExecutor.js.map +1 -1
  17. package/dist/AgentExecutor.test.js +108 -83
  18. package/dist/AgentExecutor.test.js.map +1 -1
  19. package/dist/AgentExecutorImage.test.js +2 -2
  20. package/dist/AgentExecutorImage.test.js.map +1 -1
  21. package/dist/AgentImage.test.js +3 -2
  22. package/dist/AgentImage.test.js.map +1 -1
  23. package/dist/AgentSubagents.test.js +218 -29
  24. package/dist/AgentSubagents.test.js.map +1 -1
  25. package/dist/AgentTools.d.ts +318 -290
  26. package/dist/AgentTools.d.ts.map +1 -1
  27. package/dist/AgentTools.js +218 -199
  28. package/dist/AgentTools.js.map +1 -1
  29. package/dist/AgentTools.test.js +2 -2
  30. package/dist/AgentTools.test.js.map +1 -1
  31. package/dist/bin/cli.mjs +308 -289
  32. package/dist/bin/cli.mjs.map +1 -1
  33. package/package.json +1 -1
  34. package/src/Acp.test.ts +31 -10
  35. package/src/Agent.test.ts +5 -4
  36. package/src/Agent.ts +175 -140
  37. package/src/AgentBashJobs.test.ts +70 -38
  38. package/src/AgentCallerConfig.test.ts +39 -7
  39. package/src/AgentExecutor.test.ts +132 -91
  40. package/src/AgentExecutor.ts +120 -105
  41. package/src/AgentExecutorImage.test.ts +2 -2
  42. package/src/AgentImage.test.ts +4 -3
  43. package/src/AgentSubagents.test.ts +825 -562
  44. package/src/AgentTools.test.ts +2 -2
  45. package/src/AgentTools.ts +331 -288
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "clanka",
3
3
  "type": "module",
4
- "version": "0.21.0",
4
+ "version": "0.22.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
package/src/Acp.test.ts CHANGED
@@ -536,13 +536,16 @@ describe("Acp", () => {
536
536
  Effect.gen(function* () {
537
537
  const server = yield* makeServer(runsScript("bash()"), {
538
538
  ...executor,
539
- execute: ({ onJob }) =>
539
+ execute: ({ onTask }) =>
540
540
  Stream.fromEffect(
541
- onJob!({
541
+ onTask!({
542
542
  id: "7",
543
+ kind: "bash",
543
544
  await: Effect.succeed({
544
545
  id: "7",
546
+ kind: "bash",
545
547
  status: "failed",
548
+ description: "make",
546
549
  exitCode: 3,
547
550
  output: "boom\n",
548
551
  }),
@@ -591,14 +594,17 @@ describe("Acp", () => {
591
594
  const ended = yield* Deferred.make<void>()
592
595
  const server = yield* makeServer(runsScript("bash()"), {
593
596
  ...executor,
594
- execute: ({ onJob }) =>
597
+ execute: ({ onTask }) =>
595
598
  Stream.fromEffect(
596
- onJob!({
599
+ onTask!({
597
600
  id: "7",
601
+ kind: "bash",
598
602
  await: Deferred.await(ended).pipe(
599
603
  Effect.as({
600
604
  id: "7",
605
+ kind: "bash" as const,
601
606
  status: "completed" as const,
607
+ description: "make",
602
608
  exitCode: 0,
603
609
  output: "built\n",
604
610
  }),
@@ -660,9 +666,10 @@ describe("Acp", () => {
660
666
  : assistantSays(summary),
661
667
  {
662
668
  ...executor,
663
- execute: ({ subagents, environment }) =>
669
+ execute: ({ agentTasks, environment }) =>
664
670
  Stream.fromEffect(
665
- subagents.delegate({
671
+ agentTasks.delegate({
672
+ id: "1",
666
673
  prompt,
667
674
  background: false,
668
675
  environment: new AgentExecutor.EnvironmentUpdate({
@@ -671,7 +678,7 @@ describe("Acp", () => {
671
678
  }),
672
679
  }),
673
680
  ).pipe(
674
- Stream.map((result) => result.output ?? ""),
681
+ Stream.map((task) => task.output),
675
682
  Stream.orDie,
676
683
  ),
677
684
  },
@@ -752,11 +759,12 @@ describe("Acp", () => {
752
759
  ...executor,
753
760
  // The first script starts a background child; the second
754
761
  // resumes it once its first result has been delivered.
755
- execute: ({ subagents, environment }) =>
762
+ execute: ({ agentTasks, environment }) =>
756
763
  Stream.fromEffect(
757
764
  executions++ === 0
758
- ? subagents
765
+ ? agentTasks
759
766
  .delegate({
767
+ id: "1",
760
768
  prompt: "TASK-CHILD",
761
769
  background: true,
762
770
  environment: new AgentExecutor.EnvironmentUpdate({
@@ -770,7 +778,7 @@ describe("Acp", () => {
770
778
  return "started"
771
779
  }),
772
780
  )
773
- : subagents
781
+ : agentTasks
774
782
  .messageAgent({ id: childId!, message: "FOLLOW-UP" })
775
783
  .pipe(Effect.as("resumed")),
776
784
  ).pipe(Stream.orDie),
@@ -1084,10 +1092,23 @@ await changeDirectory("sub")`),
1084
1092
  "user",
1085
1093
  "<environment-update>\nPKG-RULES\n</environment-update>",
1086
1094
  ),
1095
+ message(
1096
+ "user",
1097
+ '<task id="2" kind="agent" status="completed">\nCHILD-RESULT\n</task>',
1098
+ ),
1099
+ message(
1100
+ "user",
1101
+ '<task id="3" kind="bash" status="completed" exitCode="0">\nBUILT\n</task>',
1102
+ ),
1103
+ // Stored by versions before tasks.
1087
1104
  message(
1088
1105
  "user",
1089
1106
  '<subagent id="1" status="completed">\nCHILD-RESULT\n</subagent>',
1090
1107
  ),
1108
+ message(
1109
+ "user",
1110
+ '<job id="1" status="completed" exitCode="0">\nBUILT\n</job>',
1111
+ ),
1091
1112
  message("assistant", "Reply"),
1092
1113
  ]),
1093
1114
  }),
package/src/Agent.test.ts CHANGED
@@ -18,7 +18,7 @@ import type * as Response from "effect/ai/Response"
18
18
  import * as ResponseIdTracker from "effect/ai/ResponseIdTracker"
19
19
  import * as Agent from "./Agent.ts"
20
20
  import * as AgentExecutor from "./AgentExecutor.ts"
21
- import { subagentsUnavailable } from "./AgentTools.ts"
21
+ import { agentTasksUnavailable } from "./AgentTools.ts"
22
22
  import * as AgentOutput from "./AgentOutput.ts"
23
23
  import * as Compaction from "./Compaction.ts"
24
24
 
@@ -175,11 +175,12 @@ describe("Agent", () => {
175
175
  )
176
176
  // The root delegates once in the foreground, then every agent finishes.
177
177
  const executor = makeExecutor(
178
- ({ script, environment, subagents, onTaskComplete }) =>
178
+ ({ script, environment, agentTasks, onTaskComplete }) =>
179
179
  Stream.fromEffect(
180
180
  (script === "done"
181
181
  ? onTaskComplete("done")
182
- : subagents.delegate({
182
+ : agentTasks.delegate({
183
+ id: "1",
183
184
  prompt: "TASK-CHILD",
184
185
  background: false,
185
186
  environment: new AgentExecutor.EnvironmentUpdate({
@@ -560,7 +561,7 @@ it.layer(localExecutorLayer, { excludeTestServices: true })(
560
561
  Effect.sync(() => {
561
562
  summaries.push(summary)
562
563
  }),
563
- subagents: subagentsUnavailable,
564
+ agentTasks: agentTasksUnavailable,
564
565
  onImage: () => Effect.void,
565
566
  })
566
567
  .pipe(Stream.mkString)