@tangle-network/agent-runtime 0.80.0 → 0.81.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/agent.js +3 -3
- package/dist/{chunk-DH72UOYR.js → chunk-5GCTCLKP.js} +3 -3
- package/dist/{chunk-LLJRUTE7.js → chunk-CA43KLZW.js} +2 -2
- package/dist/{chunk-3X53HYRW.js → chunk-HUT4RXDJ.js} +2 -2
- package/dist/{chunk-3X53HYRW.js.map → chunk-HUT4RXDJ.js.map} +1 -1
- package/dist/{chunk-TPII5AU7.js → chunk-QWLUOITV.js} +78 -14
- package/dist/chunk-QWLUOITV.js.map +1 -0
- package/dist/{chunk-QSO2TVDS.js → chunk-SN3XBTTH.js} +65 -146
- package/dist/chunk-SN3XBTTH.js.map +1 -0
- package/dist/{chunk-M3Y362RW.js → chunk-Y47PMSZ7.js} +2 -2
- package/dist/index.js +5 -5
- package/dist/intelligence.js +1 -1
- package/dist/loop-runner-bin.js +4 -4
- package/dist/loops.d.ts +2 -19
- package/dist/loops.js +3 -5
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-QSO2TVDS.js.map +0 -1
- package/dist/chunk-TPII5AU7.js.map +0 -1
- /package/dist/{chunk-DH72UOYR.js.map → chunk-5GCTCLKP.js.map} +0 -0
- /package/dist/{chunk-LLJRUTE7.js.map → chunk-CA43KLZW.js.map} +0 -0
- /package/dist/{chunk-M3Y362RW.js.map → chunk-Y47PMSZ7.js.map} +0 -0
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
settledToIteration,
|
|
15
15
|
supervise,
|
|
16
16
|
withDriverExecutor
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-QWLUOITV.js";
|
|
18
18
|
import {
|
|
19
19
|
addTokenUsage,
|
|
20
20
|
isAbortError,
|
|
@@ -555,146 +555,6 @@ ${rows}
|
|
|
555
555
|
</body></html>`;
|
|
556
556
|
}
|
|
557
557
|
|
|
558
|
-
// src/runtime/inline-sandbox-client.ts
|
|
559
|
-
function isAsyncIterable(v) {
|
|
560
|
-
return typeof v === "object" && v !== null && Symbol.asyncIterator in v;
|
|
561
|
-
}
|
|
562
|
-
async function settle(exec, task, signal) {
|
|
563
|
-
const r = exec.execute(task, signal);
|
|
564
|
-
if (isAsyncIterable(r)) {
|
|
565
|
-
for await (const _ of r) {
|
|
566
|
-
}
|
|
567
|
-
return exec.resultArtifact();
|
|
568
|
-
}
|
|
569
|
-
return r;
|
|
570
|
-
}
|
|
571
|
-
function inlineSandboxClient(factory) {
|
|
572
|
-
let seq = 0;
|
|
573
|
-
return {
|
|
574
|
-
async create(options) {
|
|
575
|
-
const id = `inline-${seq++}`;
|
|
576
|
-
const createOptions = options;
|
|
577
|
-
return {
|
|
578
|
-
id,
|
|
579
|
-
async *streamPrompt(message) {
|
|
580
|
-
const controller = new AbortController();
|
|
581
|
-
const spec = { profile: { name: id }, harness: null };
|
|
582
|
-
const exec = factory(spec, { signal: controller.signal, seams: { createOptions } });
|
|
583
|
-
try {
|
|
584
|
-
const artifact = await settle(exec, message, controller.signal);
|
|
585
|
-
const out = artifact.out;
|
|
586
|
-
const tokensIn = artifact.spent.tokens.input;
|
|
587
|
-
const tokensOut = artifact.spent.tokens.output;
|
|
588
|
-
const costUsd = artifact.spent.usd;
|
|
589
|
-
if (tokensIn || tokensOut || costUsd) {
|
|
590
|
-
yield {
|
|
591
|
-
type: "llm_call",
|
|
592
|
-
data: { tokensIn, tokensOut, costUsd }
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
yield {
|
|
596
|
-
type: "result",
|
|
597
|
-
data: {
|
|
598
|
-
finalText: out?.content ?? "",
|
|
599
|
-
tokenUsage: {
|
|
600
|
-
inputTokens: tokensIn,
|
|
601
|
-
outputTokens: tokensOut
|
|
602
|
-
},
|
|
603
|
-
costUsd
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
} finally {
|
|
607
|
-
await exec.teardown("brutalKill").catch(() => {
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
},
|
|
611
|
-
async delete() {
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
// src/runtime/cli-bridge-sandbox-client.ts
|
|
619
|
-
var DEFAULT_BRIDGE_URL = "http://127.0.0.1:3355";
|
|
620
|
-
var BRIDGE_TIMEOUT_MS = 9e5;
|
|
621
|
-
function bridgeModelId(harness, model) {
|
|
622
|
-
return model.startsWith(`${harness}/`) ? model : `${harness}/${model}`;
|
|
623
|
-
}
|
|
624
|
-
function resolveTarget(cfg, createOptions) {
|
|
625
|
-
const backend = createOptions?.backend;
|
|
626
|
-
const harness = backend?.type ?? cfg.harness;
|
|
627
|
-
const model = backend?.model?.model ?? cfg.model;
|
|
628
|
-
if (!harness)
|
|
629
|
-
throw new Error(
|
|
630
|
-
"cliBridgeSandboxClient: no harness (set cfg.harness or create({ backend: { type } }))"
|
|
631
|
-
);
|
|
632
|
-
if (!model)
|
|
633
|
-
throw new Error(
|
|
634
|
-
"cliBridgeSandboxClient: no model (set cfg.model or create({ backend: { model: { model } } }))"
|
|
635
|
-
);
|
|
636
|
-
return { harness, model };
|
|
637
|
-
}
|
|
638
|
-
async function bridgePost(url, bearer, bridgeModel, prompt, signal) {
|
|
639
|
-
const res = await fetch(`${url}/v1/chat/completions`, {
|
|
640
|
-
method: "POST",
|
|
641
|
-
headers: { "content-type": "application/json", authorization: `Bearer ${bearer}` },
|
|
642
|
-
body: JSON.stringify({ model: bridgeModel, messages: [{ role: "user", content: prompt }] }),
|
|
643
|
-
signal
|
|
644
|
-
});
|
|
645
|
-
if (!res.ok) {
|
|
646
|
-
throw new Error(
|
|
647
|
-
`cli-bridge ${bridgeModel}: HTTP ${res.status} ${(await res.text()).slice(0, 300)}`
|
|
648
|
-
);
|
|
649
|
-
}
|
|
650
|
-
const j = await res.json();
|
|
651
|
-
if (j.error) throw new Error(`cli-bridge ${bridgeModel}: ${j.error.message}`);
|
|
652
|
-
return {
|
|
653
|
-
content: j.choices?.[0]?.message?.content ?? "",
|
|
654
|
-
input: j.usage?.prompt_tokens ?? 0,
|
|
655
|
-
output: j.usage?.completion_tokens ?? 0
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
function cliBridgeSandboxClient(cfg) {
|
|
659
|
-
if (!cfg.bearer) throw new Error("cliBridgeSandboxClient: bearer is required");
|
|
660
|
-
const url = cfg.url ?? DEFAULT_BRIDGE_URL;
|
|
661
|
-
let seq = 0;
|
|
662
|
-
const factory = (_spec, ctx) => {
|
|
663
|
-
const id = `cli-bridge-${seq++}`;
|
|
664
|
-
const createOptions = ctx.seams.createOptions;
|
|
665
|
-
const { harness, model } = resolveTarget(cfg, createOptions);
|
|
666
|
-
const bridgeModel = bridgeModelId(harness, model);
|
|
667
|
-
let artifact;
|
|
668
|
-
return {
|
|
669
|
-
runtime: "cli",
|
|
670
|
-
async execute(task, signal) {
|
|
671
|
-
const started = Date.now();
|
|
672
|
-
const timeout = AbortSignal.timeout(BRIDGE_TIMEOUT_MS);
|
|
673
|
-
const composed = AbortSignal.any([signal, timeout]);
|
|
674
|
-
const r = await bridgePost(url, cfg.bearer, bridgeModel, String(task), composed);
|
|
675
|
-
artifact = {
|
|
676
|
-
outRef: `cli-bridge:${id}`,
|
|
677
|
-
out: { content: r.content },
|
|
678
|
-
spent: {
|
|
679
|
-
iterations: 1,
|
|
680
|
-
tokens: { input: r.input, output: r.output },
|
|
681
|
-
usd: 0,
|
|
682
|
-
ms: Date.now() - started
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
return artifact;
|
|
686
|
-
},
|
|
687
|
-
teardown: () => Promise.resolve({ destroyed: true }),
|
|
688
|
-
resultArtifact() {
|
|
689
|
-
if (!artifact)
|
|
690
|
-
throw new Error("cliBridgeSandboxClient: resultArtifact() read before execute()");
|
|
691
|
-
return artifact;
|
|
692
|
-
}
|
|
693
|
-
};
|
|
694
|
-
};
|
|
695
|
-
return inlineSandboxClient(factory);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
558
|
// src/runtime/completion.ts
|
|
699
559
|
function completionAuthorizes(v, policy) {
|
|
700
560
|
if (!v?.done) return false;
|
|
@@ -956,7 +816,7 @@ import { mkdtempSync, rmSync } from "fs";
|
|
|
956
816
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
957
817
|
import { tmpdir } from "os";
|
|
958
818
|
import { dirname, join } from "path";
|
|
959
|
-
function
|
|
819
|
+
function isAsyncIterable(v) {
|
|
960
820
|
return typeof v === "object" && v !== null && Symbol.asyncIterator in v;
|
|
961
821
|
}
|
|
962
822
|
function inProcessSandboxClient(options) {
|
|
@@ -1007,7 +867,7 @@ function inProcessSandboxClient(options) {
|
|
|
1007
867
|
const ctx = { round, workdir: boxWorkdir, signal };
|
|
1008
868
|
round += 1;
|
|
1009
869
|
const produced = await onPrompt(prompt, ctx);
|
|
1010
|
-
if (
|
|
870
|
+
if (isAsyncIterable(produced)) {
|
|
1011
871
|
for await (const ev of produced) yield ev;
|
|
1012
872
|
} else {
|
|
1013
873
|
for (const ev of produced) yield ev;
|
|
@@ -1023,6 +883,66 @@ function inProcessSandboxClient(options) {
|
|
|
1023
883
|
};
|
|
1024
884
|
}
|
|
1025
885
|
|
|
886
|
+
// src/runtime/inline-sandbox-client.ts
|
|
887
|
+
function isAsyncIterable2(v) {
|
|
888
|
+
return typeof v === "object" && v !== null && Symbol.asyncIterator in v;
|
|
889
|
+
}
|
|
890
|
+
async function settle(exec, task, signal) {
|
|
891
|
+
const r = exec.execute(task, signal);
|
|
892
|
+
if (isAsyncIterable2(r)) {
|
|
893
|
+
for await (const _ of r) {
|
|
894
|
+
}
|
|
895
|
+
return exec.resultArtifact();
|
|
896
|
+
}
|
|
897
|
+
return r;
|
|
898
|
+
}
|
|
899
|
+
function inlineSandboxClient(factory) {
|
|
900
|
+
let seq = 0;
|
|
901
|
+
return {
|
|
902
|
+
async create(options) {
|
|
903
|
+
const id = `inline-${seq++}`;
|
|
904
|
+
const createOptions = options;
|
|
905
|
+
return {
|
|
906
|
+
id,
|
|
907
|
+
async *streamPrompt(message) {
|
|
908
|
+
const controller = new AbortController();
|
|
909
|
+
const spec = { profile: { name: id }, harness: null };
|
|
910
|
+
const exec = factory(spec, { signal: controller.signal, seams: { createOptions } });
|
|
911
|
+
try {
|
|
912
|
+
const artifact = await settle(exec, message, controller.signal);
|
|
913
|
+
const out = artifact.out;
|
|
914
|
+
const tokensIn = artifact.spent.tokens.input;
|
|
915
|
+
const tokensOut = artifact.spent.tokens.output;
|
|
916
|
+
const costUsd = artifact.spent.usd;
|
|
917
|
+
if (tokensIn || tokensOut || costUsd) {
|
|
918
|
+
yield {
|
|
919
|
+
type: "llm_call",
|
|
920
|
+
data: { tokensIn, tokensOut, costUsd }
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
yield {
|
|
924
|
+
type: "result",
|
|
925
|
+
data: {
|
|
926
|
+
finalText: out?.content ?? "",
|
|
927
|
+
tokenUsage: {
|
|
928
|
+
inputTokens: tokensIn,
|
|
929
|
+
outputTokens: tokensOut
|
|
930
|
+
},
|
|
931
|
+
costUsd
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
} finally {
|
|
935
|
+
await exec.teardown("brutalKill").catch(() => {
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
async delete() {
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
|
|
1026
946
|
// src/runtime/report-usage.ts
|
|
1027
947
|
function reportLoopUsage(cost, result, source = "loop") {
|
|
1028
948
|
cost.observe(result.costUsd, source);
|
|
@@ -4706,8 +4626,6 @@ export {
|
|
|
4706
4626
|
renderPairwiseMarkdown,
|
|
4707
4627
|
renderLeaderboardSvg,
|
|
4708
4628
|
renderLeaderboardHtml,
|
|
4709
|
-
inlineSandboxClient,
|
|
4710
|
-
cliBridgeSandboxClient,
|
|
4711
4629
|
completionAuthorizes,
|
|
4712
4630
|
stopSentinel,
|
|
4713
4631
|
sentinelCompletion,
|
|
@@ -4717,6 +4635,7 @@ export {
|
|
|
4717
4635
|
renderReport,
|
|
4718
4636
|
harvestCorpus,
|
|
4719
4637
|
inProcessSandboxClient,
|
|
4638
|
+
inlineSandboxClient,
|
|
4720
4639
|
reportLoopUsage,
|
|
4721
4640
|
loopCampaignDispatch,
|
|
4722
4641
|
loopDispatch,
|
|
@@ -4785,4 +4704,4 @@ export {
|
|
|
4785
4704
|
computeFindingId,
|
|
4786
4705
|
makeFinding2 as makeFinding
|
|
4787
4706
|
};
|
|
4788
|
-
//# sourceMappingURL=chunk-
|
|
4707
|
+
//# sourceMappingURL=chunk-SN3XBTTH.js.map
|