@tangle-network/agent-runtime 0.103.1 → 0.105.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/README.md +177 -39
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +5 -5
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/candidate-execution/index.d.ts +2 -2
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{chunk-TUSOOIDV.js → chunk-C5RTIBNZ.js} +2 -2
- package/dist/{chunk-SNSMRT6H.js → chunk-CTRA64LY.js} +3 -3
- package/dist/{chunk-ZXICDSAK.js → chunk-H5QPIZNX.js} +2 -2
- package/dist/{chunk-6WZZXQV5.js → chunk-HLKC4UYB.js} +1 -13
- package/dist/chunk-HLKC4UYB.js.map +1 -0
- package/dist/{chunk-AAN2MB2X.js → chunk-HNP72PNU.js} +3 -10
- package/dist/chunk-HNP72PNU.js.map +1 -0
- package/dist/{chunk-M6MD6JBS.js → chunk-KRBFHMV6.js} +429 -1
- package/dist/chunk-KRBFHMV6.js.map +1 -0
- package/dist/chunk-OPVWXJ2H.js +75 -0
- package/dist/chunk-OPVWXJ2H.js.map +1 -0
- package/dist/{chunk-AYU35OTU.js → chunk-PZZKQVQV.js} +1 -1
- package/dist/chunk-PZZKQVQV.js.map +1 -0
- package/dist/{chunk-B7K7V22Y.js → chunk-RDOAVVHY.js} +2 -2
- package/dist/{chunk-L5DST3QC.js → chunk-SMQXZGLZ.js} +1 -1
- package/dist/chunk-SMQXZGLZ.js.map +1 -0
- package/dist/{chunk-LFM4JBRW.js → chunk-UHEZW5BU.js} +1084 -527
- package/dist/chunk-UHEZW5BU.js.map +1 -0
- package/dist/{chunk-5AITUUHO.js → chunk-VISA6CI3.js} +3 -3
- package/dist/{chunk-ZOYN3JR5.js → chunk-WMTCUOQL.js} +5 -5
- package/dist/{chunk-3LJF5XSE.js → chunk-WRTOVNN4.js} +6 -6
- package/dist/chunk-WRTOVNN4.js.map +1 -0
- package/dist/{chunk-SBTWKPVR.js → chunk-WSTRQZYQ.js} +1 -1
- package/dist/chunk-WSTRQZYQ.js.map +1 -0
- package/dist/{chunk-EAQ5YRRY.js → chunk-XBG2W2VW.js} +50 -23
- package/dist/chunk-XBG2W2VW.js.map +1 -0
- package/dist/{chunk-QYCKIV6C.js → chunk-YJZA2BIK.js} +2 -2
- package/dist/{chunk-QYCKIV6C.js.map → chunk-YJZA2BIK.js.map} +1 -1
- package/dist/{completion-gate-DLINnrkM.d.ts → completion-gate-BMy5LGoP.d.ts} +3 -3
- package/dist/{coordination-DTehA977.d.ts → coordination-BZZSVYpZ.d.ts} +28 -28
- package/dist/environment-provider.d.ts +18 -7
- package/dist/environment-provider.js +3 -1
- package/dist/index.d.ts +106 -182
- package/dist/index.js +374 -236
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +93 -47
- package/dist/intelligence.js +127 -73
- package/dist/intelligence.js.map +1 -1
- package/dist/knowledge.d.ts +6 -6
- package/dist/knowledge.js +9 -9
- package/dist/{local-harness-CtK9dSny.d.ts → local-harness-BDNcl6jI.d.ts} +1 -1
- package/dist/{loop-runner-bin-DhIXsLAd.d.ts → loop-runner-bin-68aoM9-7.d.ts} +5 -13
- package/dist/loop-runner-bin.d.ts +6 -8
- package/dist/loop-runner-bin.js +6 -6
- package/dist/loops.d.ts +67 -42
- package/dist/loops.js +10 -6
- package/dist/mcp/bin.js +4 -4
- package/dist/mcp/index.d.ts +9 -10
- package/dist/mcp/index.js +11 -11
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/primeintellect/index.d.ts +3 -4
- package/dist/primeintellect/index.js +5 -6
- package/dist/primeintellect/index.js.map +1 -1
- package/dist/profiles.d.ts +6 -6
- package/dist/profiles.js.map +1 -1
- package/dist/{protected-model-port-DzkUY3HQ.d.ts → protected-model-port-B4t-OQjL.d.ts} +1 -1
- package/dist/{improve-B40dRu0X.d.ts → redact-BuFjxBUJ.d.ts} +201 -154
- package/dist/{structural-rollout-BFPIy3iw.d.ts → structural-rollout-DEh6CEsa.d.ts} +4 -4
- package/dist/{supervise-Cp8bNcJi.d.ts → supervise-4_48wwvy.d.ts} +3 -3
- package/dist/testing.js +9 -9
- package/dist/testing.js.map +1 -1
- package/dist/{types-DK11_O4L.d.ts → types-BCoemcXU.d.ts} +4 -4
- package/dist/{types-lZTE_LBd.d.ts → types-CvNwMzQt.d.ts} +4 -4
- package/dist/{worktree-fanout-DiiJWjJO.d.ts → worktree-fanout-DxhAWr5Z.d.ts} +6 -6
- package/package.json +8 -7
- package/skills/build-with-agent-runtime/SKILL.md +15 -9
- package/skills/loop-writer/SKILL.md +1 -1
- package/dist/chunk-3LJF5XSE.js.map +0 -1
- package/dist/chunk-6WZZXQV5.js.map +0 -1
- package/dist/chunk-AAN2MB2X.js.map +0 -1
- package/dist/chunk-AYU35OTU.js.map +0 -1
- package/dist/chunk-EAQ5YRRY.js.map +0 -1
- package/dist/chunk-L5DST3QC.js.map +0 -1
- package/dist/chunk-LFM4JBRW.js.map +0 -1
- package/dist/chunk-M6MD6JBS.js.map +0 -1
- package/dist/chunk-SBTWKPVR.js.map +0 -1
- /package/dist/{chunk-TUSOOIDV.js.map → chunk-C5RTIBNZ.js.map} +0 -0
- /package/dist/{chunk-SNSMRT6H.js.map → chunk-CTRA64LY.js.map} +0 -0
- /package/dist/{chunk-ZXICDSAK.js.map → chunk-H5QPIZNX.js.map} +0 -0
- /package/dist/{chunk-B7K7V22Y.js.map → chunk-RDOAVVHY.js.map} +0 -0
- /package/dist/{chunk-5AITUUHO.js.map → chunk-VISA6CI3.js.map} +0 -0
- /package/dist/{chunk-ZOYN3JR5.js.map → chunk-WMTCUOQL.js.map} +0 -0
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
buildLoopSpanNodes
|
|
6
6
|
} from "./chunk-2VZYRB55.js";
|
|
7
7
|
import {
|
|
8
|
-
assertModelAllowed,
|
|
9
8
|
captureWorktreeDiff,
|
|
10
9
|
createActivityLog,
|
|
11
10
|
createSupervisor,
|
|
@@ -18,7 +17,7 @@ import {
|
|
|
18
17
|
runWorktreeChecks,
|
|
19
18
|
runWorktreeHarness,
|
|
20
19
|
withDriverExecutor
|
|
21
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-HLKC4UYB.js";
|
|
22
21
|
import {
|
|
23
22
|
FileResultBlobStore,
|
|
24
23
|
FileSpawnJournal,
|
|
@@ -29,7 +28,7 @@ import {
|
|
|
29
28
|
import {
|
|
30
29
|
providerAsExecutor,
|
|
31
30
|
resolveAgentEnvironmentProvider
|
|
32
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-KRBFHMV6.js";
|
|
33
32
|
import {
|
|
34
33
|
addTokenUsage,
|
|
35
34
|
deleteBoxSafe,
|
|
@@ -69,6 +68,17 @@ function gateOnDeliverable(inner, deliverable) {
|
|
|
69
68
|
runtime: inner.runtime,
|
|
70
69
|
...inner.budgetExempt !== void 0 ? { budgetExempt: inner.budgetExempt } : {},
|
|
71
70
|
...inner.deliver ? { deliver: (m) => inner.deliver?.(m) } : {},
|
|
71
|
+
// Forward the OPTIONAL live-observation surfaces so a gated worker stays supervisable
|
|
72
|
+
// mid-flight. The scope captures `progress`/`traceSource` at spawn and only if the executor
|
|
73
|
+
// exposes them; a gate that drops them makes `observe_agent` read `recentActivity:[]` and
|
|
74
|
+
// loses online detection for a running worker (it saw the tokens/turns the fold derives, but
|
|
75
|
+
// none of the harness's own turn count or tool activity). `metered` is a driver-executor's
|
|
76
|
+
// OWN-inference subtree total, re-homed by the parent on settle — dropping it would leak a
|
|
77
|
+
// gated sub-driver's inference out of the journal. Preserve the "undefined ⟺ not implemented"
|
|
78
|
+
// contract: only expose a method the inner executor actually implements.
|
|
79
|
+
...inner.progress ? { progress: () => inner.progress?.() } : {},
|
|
80
|
+
...inner.traceSource ? { traceSource: () => inner.traceSource?.() } : {},
|
|
81
|
+
...inner.metered ? { metered: () => inner.metered?.() } : {},
|
|
72
82
|
execute(task, signal) {
|
|
73
83
|
const r = inner.execute(task, signal);
|
|
74
84
|
if (isAsyncIterable(r)) {
|
|
@@ -95,6 +105,16 @@ function isAsyncIterable(v) {
|
|
|
95
105
|
return v != null && typeof v[Symbol.asyncIterator] === "function";
|
|
96
106
|
}
|
|
97
107
|
|
|
108
|
+
// src/runtime/supervise/model-policy.ts
|
|
109
|
+
function assertModelAllowed(model, allowed) {
|
|
110
|
+
if (!allowed || model === void 0) return;
|
|
111
|
+
if (!allowed.includes(model)) {
|
|
112
|
+
throw new ConfigError(
|
|
113
|
+
`model ${JSON.stringify(model)} is not in the allowed set ${JSON.stringify([...allowed])}`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
98
118
|
// src/runtime/sandbox-acquire.ts
|
|
99
119
|
var RETRYABLE_HTTP = /* @__PURE__ */ new Set([502, 503, 504, 522, 524, 408, 425, 429]);
|
|
100
120
|
var TERMINAL_STATUS = /* @__PURE__ */ new Set(["failed", "expired", "stopped"]);
|
|
@@ -369,19 +389,19 @@ async function destroyBounded(box) {
|
|
|
369
389
|
// src/runtime/run-loop.ts
|
|
370
390
|
var DEFAULT_MAX_ITERATIONS = 10;
|
|
371
391
|
var DEFAULT_MAX_CONCURRENCY = 4;
|
|
372
|
-
async function
|
|
392
|
+
async function runAgentRounds(options) {
|
|
373
393
|
const specs = resolveAgentRuns(options);
|
|
374
394
|
const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
375
395
|
if (!Number.isFinite(maxIterations) || maxIterations <= 0) {
|
|
376
|
-
throw new ValidationError("
|
|
396
|
+
throw new ValidationError("runAgentRounds: maxIterations must be > 0");
|
|
377
397
|
}
|
|
378
398
|
const maxConcurrency = options.maxConcurrency ?? DEFAULT_MAX_CONCURRENCY;
|
|
379
399
|
if (!Number.isFinite(maxConcurrency) || maxConcurrency <= 0) {
|
|
380
|
-
throw new ValidationError("
|
|
400
|
+
throw new ValidationError("runAgentRounds: maxConcurrency must be > 0");
|
|
381
401
|
}
|
|
382
402
|
const sandboxStreaming = options.lineage?.streaming ?? "sse";
|
|
383
403
|
if (!options.ctx?.sandboxClient || typeof options.ctx.sandboxClient.create !== "function") {
|
|
384
|
-
throw new ValidationError("
|
|
404
|
+
throw new ValidationError("runAgentRounds: ctx.sandboxClient.create is required");
|
|
385
405
|
}
|
|
386
406
|
const now = options.now ?? Date.now;
|
|
387
407
|
const runId = options.runId ?? `loop-${randomSuffix()}`;
|
|
@@ -559,12 +579,13 @@ async function runLoop(options) {
|
|
|
559
579
|
if (lineageState) await lineageState.lineage.teardown();
|
|
560
580
|
}
|
|
561
581
|
}
|
|
582
|
+
var runLoop = runAgentRounds;
|
|
562
583
|
async function setUpLineage(options, maxConcurrency, recordMount) {
|
|
563
584
|
const lineageOpts = options.lineage;
|
|
564
585
|
if (!lineageOpts || !lineageOpts.sessionContinuity && !lineageOpts.forkFanout) return void 0;
|
|
565
586
|
if (options.onWorkerBox) {
|
|
566
587
|
throw new ValidationError(
|
|
567
|
-
"
|
|
588
|
+
"runAgentRounds: `lineage` and `onWorkerBox` both own worker boxes \u2014 pass only one"
|
|
568
589
|
);
|
|
569
590
|
}
|
|
570
591
|
const capabilities = await probeSandboxCapabilities(options.ctx.sandboxClient);
|
|
@@ -584,12 +605,14 @@ function planLineageRound(state, specs, slice, parentIndex, signal) {
|
|
|
584
605
|
const parent = parentIndex !== void 0 ? state.handles.get(parentIndex) : void 0;
|
|
585
606
|
const promptFor = (offset) => {
|
|
586
607
|
const spec = specs[offset % specs.length];
|
|
587
|
-
if (!spec)
|
|
608
|
+
if (!spec)
|
|
609
|
+
throw new ValidationError("runAgentRounds: no AgentRunSpec available for lineage iteration");
|
|
588
610
|
return spec.taskToPrompt(slice[offset]);
|
|
589
611
|
};
|
|
590
612
|
const specAt = (offset) => {
|
|
591
613
|
const spec = specs[offset % specs.length];
|
|
592
|
-
if (!spec)
|
|
614
|
+
if (!spec)
|
|
615
|
+
throw new ValidationError("runAgentRounds: no AgentRunSpec available for lineage iteration");
|
|
593
616
|
return spec;
|
|
594
617
|
};
|
|
595
618
|
if (slice.length === 1 && parent && state.options.sessionContinuity) {
|
|
@@ -615,7 +638,7 @@ function planLineageRound(state, specs, slice, parentIndex, signal) {
|
|
|
615
638
|
const branches = await ensureForked();
|
|
616
639
|
const branch = branches[offset];
|
|
617
640
|
if (!branch)
|
|
618
|
-
throw new ValidationError("
|
|
641
|
+
throw new ValidationError("runAgentRounds: lineage fork produced no branch for offset");
|
|
619
642
|
return branch;
|
|
620
643
|
}
|
|
621
644
|
}));
|
|
@@ -673,9 +696,9 @@ async function runBatch(args) {
|
|
|
673
696
|
async function executeIteration(args) {
|
|
674
697
|
const slot = args.iterations[args.item.index];
|
|
675
698
|
if (!slot)
|
|
676
|
-
throw new ValidationError(`
|
|
699
|
+
throw new ValidationError(`runAgentRounds: missing iteration slot at index ${args.item.index}`);
|
|
677
700
|
const spec = args.specs[args.item.index % args.specs.length];
|
|
678
|
-
if (!spec) throw new ValidationError("
|
|
701
|
+
if (!spec) throw new ValidationError("runAgentRounds: no AgentRunSpec available for iteration");
|
|
679
702
|
slot.startedAt = args.now();
|
|
680
703
|
slot.agentRunName = spec.name ?? spec.profile.name ?? "agent";
|
|
681
704
|
await emitTrace(args.ctx.traceEmitter, {
|
|
@@ -986,11 +1009,11 @@ function defaultSelectWinner(iterations) {
|
|
|
986
1009
|
}
|
|
987
1010
|
function resolveAgentRuns(options) {
|
|
988
1011
|
if (options.agentRun && options.agentRuns) {
|
|
989
|
-
throw new ValidationError("
|
|
1012
|
+
throw new ValidationError("runAgentRounds: pass exactly one of `agentRun` or `agentRuns`");
|
|
990
1013
|
}
|
|
991
1014
|
if (options.agentRun) return [options.agentRun];
|
|
992
1015
|
if (options.agentRuns && options.agentRuns.length > 0) return options.agentRuns;
|
|
993
|
-
throw new ValidationError("
|
|
1016
|
+
throw new ValidationError("runAgentRounds: `agentRun` or non-empty `agentRuns` is required");
|
|
994
1017
|
}
|
|
995
1018
|
function isTerminalDecision(decision) {
|
|
996
1019
|
return decision === "stop" || decision === "pick-winner" || decision === "fail" || decision === "done";
|
|
@@ -1301,9 +1324,9 @@ var piExecutor = (spec, ctx) => {
|
|
|
1301
1324
|
};
|
|
1302
1325
|
return {
|
|
1303
1326
|
runtime: PI_RUNTIME,
|
|
1304
|
-
// pi owns the queue; `deliver` only routes
|
|
1305
|
-
//
|
|
1306
|
-
//
|
|
1327
|
+
// pi owns the queue; `deliver` only routes through its state-safe `prompt` command. Its
|
|
1328
|
+
// streaming behavior chooses steer versus follow-up atomically in pi, rather than trusting
|
|
1329
|
+
// this adapter's delayed view of whether the current run has already ended.
|
|
1307
1330
|
deliver: (m) => inbox.deliver(m),
|
|
1308
1331
|
progress: () => ({
|
|
1309
1332
|
turns: state.turns,
|
|
@@ -1361,6 +1384,7 @@ async function* streamPiSession(args) {
|
|
|
1361
1384
|
};
|
|
1362
1385
|
const stdoutLines = readJsonLines(proc, (value) => {
|
|
1363
1386
|
const ev = value;
|
|
1387
|
+
if (ev.type === "agent_start") idle = false;
|
|
1364
1388
|
if (ev.type === "agent_end") idle = true;
|
|
1365
1389
|
events.push(ev);
|
|
1366
1390
|
notify();
|
|
@@ -1396,7 +1420,7 @@ ${taskText(args.task)}` : taskText(args.task);
|
|
|
1396
1420
|
sendCommand(proc, { type: "prompt", message: opening });
|
|
1397
1421
|
state.note = "turn 0";
|
|
1398
1422
|
for (; ; ) {
|
|
1399
|
-
forwardPending(proc, inbox, activity);
|
|
1423
|
+
if (!idle) forwardPending(proc, inbox, activity);
|
|
1400
1424
|
while (events.length > 0) {
|
|
1401
1425
|
const ev = events.shift();
|
|
1402
1426
|
for (const usage of projectPiEvent(ev, args, tokens)) {
|
|
@@ -1445,8 +1469,9 @@ function forwardPending(proc, inbox, activity) {
|
|
|
1445
1469
|
const pending = inbox.drain();
|
|
1446
1470
|
for (const m of pending) {
|
|
1447
1471
|
sendCommand(proc, {
|
|
1448
|
-
type:
|
|
1449
|
-
message: renderOne(m)
|
|
1472
|
+
type: "prompt",
|
|
1473
|
+
message: renderOne(m),
|
|
1474
|
+
streamingBehavior: m.interrupt ? "steer" : "followUp"
|
|
1450
1475
|
});
|
|
1451
1476
|
activity.push({
|
|
1452
1477
|
at: Date.now(),
|
|
@@ -2299,7 +2324,7 @@ async function* streamSandboxLeaf(args) {
|
|
|
2299
2324
|
...args.seam.lineage !== void 0 ? { lineage: args.seam.lineage } : {}
|
|
2300
2325
|
};
|
|
2301
2326
|
try {
|
|
2302
|
-
const result = await
|
|
2327
|
+
const result = await runAgentRounds(loopOptions);
|
|
2303
2328
|
const out = result.winner?.output ?? { events: [] };
|
|
2304
2329
|
const verdict = result.winner?.verdict;
|
|
2305
2330
|
const spent = {
|
|
@@ -6307,9 +6332,11 @@ async function delegate(intent, opts = {}) {
|
|
|
6307
6332
|
|
|
6308
6333
|
export {
|
|
6309
6334
|
gateOnDeliverable,
|
|
6335
|
+
assertModelAllowed,
|
|
6310
6336
|
acquireSandbox,
|
|
6311
6337
|
probeSandboxCapabilities,
|
|
6312
6338
|
createSandboxLineage,
|
|
6339
|
+
runAgentRounds,
|
|
6313
6340
|
runLoop,
|
|
6314
6341
|
createSandboxForSpec,
|
|
6315
6342
|
defaultSelectWinner,
|
|
@@ -6404,4 +6431,4 @@ export {
|
|
|
6404
6431
|
workerFromBackend,
|
|
6405
6432
|
supervise
|
|
6406
6433
|
};
|
|
6407
|
-
//# sourceMappingURL=chunk-
|
|
6434
|
+
//# sourceMappingURL=chunk-XBG2W2VW.js.map
|