clanka 0.24.3 → 0.24.4
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/Agent.d.ts.map +1 -1
- package/dist/Agent.js +23 -10
- package/dist/Agent.js.map +1 -1
- package/dist/Agent.test.js +137 -0
- package/dist/Agent.test.js.map +1 -1
- package/dist/OutputFormatter.d.ts +1 -1
- package/dist/OutputFormatter.d.ts.map +1 -1
- package/dist/OutputFormatter.js +42 -2
- package/dist/OutputFormatter.js.map +1 -1
- package/dist/OutputFormatter.test.d.ts +2 -0
- package/dist/OutputFormatter.test.d.ts.map +1 -0
- package/dist/OutputFormatter.test.js +93 -0
- package/dist/OutputFormatter.test.js.map +1 -0
- package/dist/bin/{Stream-C51usiew.mjs → AiError-fiHIiGOy.mjs} +469 -34
- package/dist/bin/{Latch-BnrpWMd1.mjs → Latch-D1909CI6.mjs} +1 -1
- package/dist/bin/{McpClient-DoPNaNzW.mjs → McpClient-CXwyRd_3.mjs} +2 -3
- package/dist/bin/{OutputFormatter-U02YKTfy.mjs → OutputFormatter-B8yF7iiq.mjs} +40 -4
- package/dist/bin/{Schema-Box_9VZG.mjs → Schema-D629S5yu.mjs} +5459 -278
- package/dist/bin/{SemanticSearch-CH125AHH.mjs → SemanticSearch-BlcfFvPr.mjs} +14 -15
- package/dist/bin/cli.mjs +392 -819
- package/dist/bin/{upgrade-HMRGSqq8.mjs → upgrade-E_f-q2h8.mjs} +3 -4
- package/package.json +1 -1
- package/src/Agent.test.ts +198 -0
- package/src/Agent.ts +27 -10
- package/src/OutputFormatter.test.ts +158 -0
- package/src/OutputFormatter.ts +56 -1
- package/dist/bin/Effect-5XYMLOiB.mjs +0 -5183
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { c as StreamableHTTPClientTransport, l as Client } from "./cli.mjs";
|
|
1
|
+
import { Bi as fn, K as TaggedError, Xi as gen, eo as tryPromise, ni as acquireRelease, p as Defect, qa as sync, su as Service, wa as promise, ws as effect } from "./Schema-D629S5yu.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 {
|
|
2
|
-
import {
|
|
1
|
+
import { Dd as isTagged, Ki as forkIn, La as scope, Ld as identity, Vi as fnUntraced, Xi as gen, co as void_, di as asVoid, is as fail, su as Service, va as onExit, ws as effect, ys as pretty$1 } from "./Schema-D629S5yu.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-fiHIiGOy.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":
|