@tangle-network/agent-runtime 0.79.4 → 0.80.1
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/README.md +6 -0
- package/dist/agent.js +3 -3
- package/dist/{chunk-AHZ3YBL6.js → chunk-3RAXZ6LB.js} +195 -64
- package/dist/chunk-3RAXZ6LB.js.map +1 -0
- package/dist/{chunk-44CX5JU6.js → chunk-3TAQW75Y.js} +53 -5
- package/dist/chunk-3TAQW75Y.js.map +1 -0
- package/dist/{chunk-NXZEVWKP.js → chunk-CR5MQUYO.js} +2 -2
- package/dist/{chunk-RUJZK6VH.js → chunk-KELG3Z5H.js} +2 -2
- package/dist/{chunk-U6AP535M.js → chunk-KNZ54YYO.js} +3 -3
- package/dist/{chunk-IPEQ3ERC.js → chunk-XRKP3XW3.js} +2 -2
- package/dist/{chunk-IPEQ3ERC.js.map → chunk-XRKP3XW3.js.map} +1 -1
- package/dist/{coordination-BFVtgRax.d.ts → coordination-BI9tpcmF.d.ts} +12 -3
- package/dist/environment-provider.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/intelligence.d.ts +1 -1
- package/dist/intelligence.js +1 -1
- package/dist/{loop-runner-bin-CTVja8e0.d.ts → loop-runner-bin-CBkLsyFg.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +4 -4
- package/dist/loop-runner-bin.js +4 -4
- package/dist/loops.d.ts +32 -12
- package/dist/loops.js +5 -3
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +6 -6
- package/dist/mcp/index.js +5 -5
- package/dist/{router-client-Ak2IGuXq.d.ts → router-client-D6Ocf4jG.d.ts} +19 -0
- package/dist/{types-DYW0tloU.d.ts → types-By9LXllv.d.ts} +7 -0
- package/dist/{worktree-fanout-DaUDwCA_.d.ts → worktree-fanout-D9Z2dMS9.d.ts} +2 -2
- package/dist/{worktree-harness-Dt6s_m3z.d.ts → worktree-harness-Dx8XULW3.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-44CX5JU6.js.map +0 -1
- package/dist/chunk-AHZ3YBL6.js.map +0 -1
- /package/dist/{chunk-NXZEVWKP.js.map → chunk-CR5MQUYO.js.map} +0 -0
- /package/dist/{chunk-RUJZK6VH.js.map → chunk-KELG3Z5H.js.map} +0 -0
- /package/dist/{chunk-U6AP535M.js.map → chunk-KNZ54YYO.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildLoopSpanNodes
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XRKP3XW3.js";
|
|
4
4
|
import {
|
|
5
5
|
addTokenUsage,
|
|
6
6
|
deleteBoxSafe,
|
|
@@ -1240,6 +1240,7 @@ function createScope(args) {
|
|
|
1240
1240
|
spent: zeroSpend(),
|
|
1241
1241
|
settled: void 0,
|
|
1242
1242
|
delivered: false,
|
|
1243
|
+
executorDone: false,
|
|
1243
1244
|
...executor.deliver ? { deliver: executor.deliver.bind(executor) } : {}
|
|
1244
1245
|
};
|
|
1245
1246
|
children.set(id, live);
|
|
@@ -1315,6 +1316,18 @@ function createScope(args) {
|
|
|
1315
1316
|
return finalizeSettlement(chosen, settlement, seq, args, now);
|
|
1316
1317
|
}
|
|
1317
1318
|
}
|
|
1319
|
+
async function nextResolved() {
|
|
1320
|
+
for (; ; ) {
|
|
1321
|
+
const candidates = [...children.values()].filter((c) => !c.delivered);
|
|
1322
|
+
const pick = candidates.find((c) => c.resolved !== void 0) ?? candidates.find((c) => c.executorDone);
|
|
1323
|
+
if (!pick) return null;
|
|
1324
|
+
const settlement = await pick.settled;
|
|
1325
|
+
if (pick.delivered) continue;
|
|
1326
|
+
pick.delivered = true;
|
|
1327
|
+
const seq = cursorSeq++;
|
|
1328
|
+
return finalizeSettlement(pick, settlement, seq, args, now);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1318
1331
|
function send(nodeId, msg) {
|
|
1319
1332
|
const child = children.get(nodeId);
|
|
1320
1333
|
if (!child || child.delivered || !child.deliver) return false;
|
|
@@ -1348,6 +1361,7 @@ function createScope(args) {
|
|
|
1348
1361
|
return {
|
|
1349
1362
|
spawn: spawn4,
|
|
1350
1363
|
next,
|
|
1364
|
+
nextResolved,
|
|
1351
1365
|
send,
|
|
1352
1366
|
signal: args.signal,
|
|
1353
1367
|
meter,
|
|
@@ -1488,6 +1502,7 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
|
|
|
1488
1502
|
artifact = terminal;
|
|
1489
1503
|
reconcileOnce(terminal.spent);
|
|
1490
1504
|
}
|
|
1505
|
+
live.executorDone = true;
|
|
1491
1506
|
const ownMetered = executor.metered?.();
|
|
1492
1507
|
if (childAbort.signal.aborted) {
|
|
1493
1508
|
await teardownSafe(executor, opts.shutdown ?? "brutalKill");
|
|
@@ -1505,6 +1520,7 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
|
|
|
1505
1520
|
...ownMetered ? { metered: ownMetered } : {}
|
|
1506
1521
|
};
|
|
1507
1522
|
} catch (err) {
|
|
1523
|
+
live.executorDone = true;
|
|
1508
1524
|
reconcileOnce(live.spent);
|
|
1509
1525
|
await teardownSafe(executor, "brutalKill");
|
|
1510
1526
|
const aborted = childAbort.signal.aborted || isAbortError2(err);
|
|
@@ -1802,7 +1818,8 @@ async function routerChatWithUsage(cfg, messages, opts) {
|
|
|
1802
1818
|
model: cfg.model,
|
|
1803
1819
|
messages,
|
|
1804
1820
|
temperature,
|
|
1805
|
-
max_tokens: opts?.maxTokens ?? 8192
|
|
1821
|
+
max_tokens: opts?.maxTokens ?? 8192,
|
|
1822
|
+
...opts?.reasoningEffort ? { reasoning_effort: opts.reasoningEffort } : {}
|
|
1806
1823
|
});
|
|
1807
1824
|
if (cfg.complete) return parseChatResult(await cfg.complete(body()), cfg.model);
|
|
1808
1825
|
let lastErr = "";
|
|
@@ -1832,12 +1849,29 @@ function parseChatResult(json, model) {
|
|
|
1832
1849
|
const u = data.usage;
|
|
1833
1850
|
const usage = u && typeof u.prompt_tokens === "number" && typeof u.completion_tokens === "number" ? { input: u.prompt_tokens, output: u.completion_tokens } : void 0;
|
|
1834
1851
|
const costUsd = usage && isModelPriced(model) ? estimateCost(usage.input, usage.output, model) : void 0;
|
|
1852
|
+
const msg = data.choices?.[0]?.message;
|
|
1853
|
+
const { content, reasoning } = splitReasoning(
|
|
1854
|
+
msg?.content ?? "",
|
|
1855
|
+
msg?.reasoning ?? msg?.reasoning_content
|
|
1856
|
+
);
|
|
1835
1857
|
return {
|
|
1836
|
-
content
|
|
1858
|
+
content,
|
|
1859
|
+
...reasoning ? { reasoning } : {},
|
|
1837
1860
|
...usage ? { usage } : {},
|
|
1838
1861
|
...costUsd !== void 0 ? { costUsd } : {}
|
|
1839
1862
|
};
|
|
1840
1863
|
}
|
|
1864
|
+
function splitReasoning(rawContent, fieldReasoning) {
|
|
1865
|
+
const open = rawContent.indexOf("<think>");
|
|
1866
|
+
if (open !== -1) {
|
|
1867
|
+
const close = rawContent.indexOf("</think>", open);
|
|
1868
|
+
const inline = close !== -1 ? rawContent.slice(open + 7, close) : rawContent.slice(open + 7);
|
|
1869
|
+
const rest = close !== -1 ? rawContent.slice(0, open) + rawContent.slice(close + 8) : rawContent.slice(0, open);
|
|
1870
|
+
const reasoning = [fieldReasoning, inline.trim()].filter(Boolean).join("\n");
|
|
1871
|
+
return { content: rest.trim(), ...reasoning ? { reasoning } : {} };
|
|
1872
|
+
}
|
|
1873
|
+
return { content: rawContent, ...fieldReasoning ? { reasoning: fieldReasoning } : {} };
|
|
1874
|
+
}
|
|
1841
1875
|
async function routerChatWithTools(cfg, messages, tools, opts) {
|
|
1842
1876
|
const body = {
|
|
1843
1877
|
model: cfg.model,
|
|
@@ -3820,6 +3854,16 @@ function createCoordinationTools(opts) {
|
|
|
3820
3854
|
}
|
|
3821
3855
|
return true;
|
|
3822
3856
|
};
|
|
3857
|
+
const drainResolved = async () => {
|
|
3858
|
+
let drained = 0;
|
|
3859
|
+
for (; ; ) {
|
|
3860
|
+
const s = await opts.scope.nextResolved();
|
|
3861
|
+
if (!s) return drained;
|
|
3862
|
+
const w = recordSettled(s);
|
|
3863
|
+
await bus.publish({ type: "settled", worker: w });
|
|
3864
|
+
drained += 1;
|
|
3865
|
+
}
|
|
3866
|
+
};
|
|
3823
3867
|
async function sendDown(type, down, questionId) {
|
|
3824
3868
|
await bus.publish(
|
|
3825
3869
|
type === "answer" ? { type, down, questionId: str(questionId, "questionId") } : { type, down },
|
|
@@ -4163,7 +4207,8 @@ function createCoordinationTools(opts) {
|
|
|
4163
4207
|
isStopped: () => stopped,
|
|
4164
4208
|
stopReason: () => reason,
|
|
4165
4209
|
settled: () => ledger,
|
|
4166
|
-
questions: () => questions
|
|
4210
|
+
questions: () => questions,
|
|
4211
|
+
drainResolved
|
|
4167
4212
|
};
|
|
4168
4213
|
}
|
|
4169
4214
|
|
|
@@ -4324,6 +4369,7 @@ Summary unavailable: ${errMessage2(e)}`;
|
|
|
4324
4369
|
stopBefore: () => coord.isStopped() || scope.signal.aborted || poolStarved(scope, opts.perWorker) || deadlinePassed(scope, now)
|
|
4325
4370
|
}
|
|
4326
4371
|
});
|
|
4372
|
+
await coord.drainResolved();
|
|
4327
4373
|
return finalize2(coord, opts.blobs);
|
|
4328
4374
|
}
|
|
4329
4375
|
};
|
|
@@ -6294,6 +6340,7 @@ async function serveCoordinationMcp(opts) {
|
|
|
6294
6340
|
url: `http://${host}:${port}/mcp`,
|
|
6295
6341
|
port,
|
|
6296
6342
|
settled: () => coord.settled(),
|
|
6343
|
+
drainResolved: () => coord.drainResolved(),
|
|
6297
6344
|
isStopped: () => coord.isStopped(),
|
|
6298
6345
|
history: () => coord.history(),
|
|
6299
6346
|
stats: () => coord.stats(),
|
|
@@ -6369,6 +6416,7 @@ function supervisorAgent(profile, deps) {
|
|
|
6369
6416
|
});
|
|
6370
6417
|
try {
|
|
6371
6418
|
await driveHarness({ profile, task, scope, coordinationMcpUrl: mcp.url });
|
|
6419
|
+
await mcp.drainResolved();
|
|
6372
6420
|
return await finalizeBestDelivered(mcp.settled(), deps.blobs);
|
|
6373
6421
|
} finally {
|
|
6374
6422
|
await mcp.close();
|
|
@@ -6479,4 +6527,4 @@ export {
|
|
|
6479
6527
|
createInProcessTransport,
|
|
6480
6528
|
serveCoordinationMcp
|
|
6481
6529
|
};
|
|
6482
|
-
//# sourceMappingURL=chunk-
|
|
6530
|
+
//# sourceMappingURL=chunk-3TAQW75Y.js.map
|