clanka 0.24.3 → 0.24.5

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 (36) hide show
  1. package/dist/Agent.d.ts.map +1 -1
  2. package/dist/Agent.js +24 -11
  3. package/dist/Agent.js.map +1 -1
  4. package/dist/Agent.test.js +137 -0
  5. package/dist/Agent.test.js.map +1 -1
  6. package/dist/AgentTools.d.ts +88 -88
  7. package/dist/AgentTools.d.ts.map +1 -1
  8. package/dist/OutputFormatter.d.ts +1 -1
  9. package/dist/OutputFormatter.d.ts.map +1 -1
  10. package/dist/OutputFormatter.js +42 -2
  11. package/dist/OutputFormatter.js.map +1 -1
  12. package/dist/OutputFormatter.test.d.ts +2 -0
  13. package/dist/OutputFormatter.test.d.ts.map +1 -0
  14. package/dist/OutputFormatter.test.js +93 -0
  15. package/dist/OutputFormatter.test.js.map +1 -0
  16. package/dist/bin/{Stream-C51usiew.mjs → AiError-CsvdOsKR.mjs} +533 -74
  17. package/dist/bin/Latch-B3e9629m.mjs +5 -0
  18. package/dist/bin/{McpClient-DoPNaNzW.mjs → McpClient-BCxZZgnA.mjs} +2 -3
  19. package/dist/bin/{OutputFormatter-U02YKTfy.mjs → OutputFormatter-ByMjyBhe.mjs} +40 -4
  20. package/dist/bin/{Schema-Box_9VZG.mjs → Schema-BfUmMefy.mjs} +5602 -360
  21. package/dist/bin/{SemanticSearch-CH125AHH.mjs → SemanticSearch-DMzIsoZb.mjs} +80 -68
  22. package/dist/bin/cli.mjs +849 -1163
  23. package/dist/bin/{helpers-CljL9OKa.mjs → helpers-Bb68A2Sv.mjs} +2 -2
  24. package/dist/bin/{index.min-ClUfQ5ji.mjs → index.min-CuA3AuA-.mjs} +1448 -1348
  25. package/dist/bin/{rolldown-runtime-5zChB7MF.mjs → rolldown-runtime-CXhmmSW5.mjs} +4 -4
  26. package/dist/bin/{server-HlLriZxF.mjs → server-D4nrvZHH.mjs} +2 -2
  27. package/dist/bin/{turndown.cjs-C2WBxeA-.mjs → turndown.cjs-CwE2EFNQ.mjs} +15 -10
  28. package/dist/bin/{types-LcwjLVkt.mjs → types-N9Z-HYP0.mjs} +1 -1
  29. package/dist/bin/{upgrade-HMRGSqq8.mjs → upgrade-t590zYhO.mjs} +5 -6
  30. package/package.json +15 -15
  31. package/src/Agent.test.ts +198 -0
  32. package/src/Agent.ts +28 -11
  33. package/src/OutputFormatter.test.ts +158 -0
  34. package/src/OutputFormatter.ts +56 -1
  35. package/dist/bin/Effect-5XYMLOiB.mjs +0 -5183
  36. package/dist/bin/Latch-BnrpWMd1.mjs +0 -5
@@ -0,0 +1,5 @@
1
+ import { Uc as makeLatch, Wc as makeLatchUnsafe } from "./Schema-BfUmMefy.mjs";
2
+ // node_modules/.pnpm/effect@4.1.3/node_modules/effect/dist/Latch.js
3
+ const makeUnsafe = makeLatchUnsafe;
4
+ const make = makeLatch;
5
+ export { makeUnsafe as n, make as t };
@@ -1,6 +1,5 @@
1
- import { B as fn, Dr as effect, Et as promise, Xt as sync, Z as gen, bo as Service, rn as tryPromise, t as acquireRelease } from "./Effect-5XYMLOiB.mjs";
2
- import { K as TaggedError, p as Defect } from "./Schema-Box_9VZG.mjs";
3
- import { c as StreamableHTTPClientTransport, l as Client } from "./cli.mjs";
1
+ import { Ds as effect, Ea as promise, Hi as fn, K as TaggedError, Qi as gen, Xa as sync, du as Service, ii as acquireRelease, p as Defect, ro as tryPromise } from "./Schema-BfUmMefy.mjs";
2
+ import { d as Client, u as StreamableHTTPClientTransport } from "./cli.mjs";
4
3
  // src/McpClient.ts
5
4
  var McpClient = class extends Service()("clanka/McpClient") {};
6
5
  var McpClientError = class extends TaggedError()("McpClientError", { cause: Defect() }) {};
@@ -1,5 +1,6 @@
1
- import { Bt as scope, Cc as isTagged, Dr as effect, Pc as identity, Sr as pretty$1, V as fnUntraced, Z as gen, ar as fail, bo as Service, bt as onExit, dn as void_, q as forkIn, u as asVoid } from "./Effect-5XYMLOiB.mjs";
2
- import { N as map, O as fromPubSub, Pt as unbounded, Q as runIntoPubSub, _t as makeUnsafe, i as catchIf, nt as succeed, st as tap, u as die } from "./Stream-C51usiew.mjs";
1
+ import { Ad as isTagged, Ba as scope, Bd as identity, Ds as effect, Ji as forkIn, Qi as gen, Ss as pretty$1, Ui as fnUntraced, ba as onExit, do as void_, du as Service, pi as asVoid, ss as fail } from "./Schema-BfUmMefy.mjs";
2
+ import { $ as fromPubSub, B as failCause, Ct as runIntoPubSub, D as catchCause, Dt as succeed, Ht as makeUnsafe, K as flattenIterable, M as concat, Mt as tap, O as catchIf, Ot as suspend, P as die, Q as fromIterable, an as unbounded, it as map } from "./AiError-CsvdOsKR.mjs";
3
+ import { c as ReasoningEnd, l as ScriptEnd } from "./cli.mjs";
3
4
  import os from "node:os";
4
5
  import process from "node:process";
5
6
  import tty from "node:tty";
@@ -482,7 +483,7 @@ const pretty = (options) => {
482
483
  if (lines.length > maxLines) return lines.slice(0, maxLines).join("\n") + `\n... (truncated, total ${lines.length} lines)`;
483
484
  return text;
484
485
  } : identity;
485
- return (stream) => stream.pipe(map((output) => {
486
+ return (stream) => stream.pipe(deferBlockOutput, map((output) => {
486
487
  let prefix = "";
487
488
  if (output._tag === "SubagentPart") {
488
489
  prefix = chalk.magenta(`Subagent #${output.id}:`) + " ";
@@ -528,6 +529,41 @@ ${chalk.dim(output.summary)}\n\n`;
528
529
  }
529
530
  }), catchIf((e) => isTagged(e, "AgentFinished"), (finished) => succeed(`\n${chalk.bold.green(`${doneIcon} Task complete:`)}\n\n${finished.summary}`), (e) => die(e)));
530
531
  };
532
+ const deferBlockOutput = (stream) => suspend(() => {
533
+ let end;
534
+ let pending = [];
535
+ const flush = () => {
536
+ const parts = pending;
537
+ pending = [];
538
+ return parts;
539
+ };
540
+ const finish = () => {
541
+ const parts = pending.length > 0 && end ? [end, ...flush()] : flush();
542
+ end = void 0;
543
+ return fromIterable(parts);
544
+ };
545
+ return stream.pipe(map((output) => {
546
+ switch ((output._tag === "SubagentPart" ? output.part : output)._tag) {
547
+ case "ReasoningStart":
548
+ end = new ReasoningEnd();
549
+ break;
550
+ case "ScriptStart":
551
+ end = new ScriptEnd();
552
+ break;
553
+ case "ReasoningEnd":
554
+ case "ScriptEnd":
555
+ end = void 0;
556
+ return [output, ...flush()];
557
+ case "ReasoningDelta":
558
+ case "ScriptDelta": break;
559
+ default: if (end) {
560
+ pending.push(output);
561
+ return [];
562
+ }
563
+ }
564
+ return [output];
565
+ }), flattenIterable, catchCause((cause) => finish().pipe(concat(failCause(cause)))), concat(suspend(finish)));
566
+ });
531
567
  const promptToString = (prompt) => {
532
568
  let textParts = [];
533
569
  for (const message of prompt.content) {
@@ -561,7 +597,7 @@ const layerMuxer = (formatter) => effect(Muxer, gen(function* () {
561
597
  return Muxer.of({
562
598
  add(stream) {
563
599
  const id = ++agentCount;
564
- return stream.pipe(tap(fnUntraced(function* (part_) {
600
+ return stream.pipe(deferBlockOutput, tap(fnUntraced(function* (part_) {
565
601
  if (currentAgentId === null || id !== currentAgentId) yield* semaphore.take(1);
566
602
  switch ((part_._tag === "SubagentPart" ? part_.part : part_)._tag) {
567
603
  case "ReasoningStart":