@tangle-network/agent-runtime 1.0.0 → 2.0.2
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/{activation-CFS31SWI.d.ts → activation-BuK2H7qx.d.ts} +2 -2
- package/dist/{activation-BwoSqHCc.js → activation-ZQWz04u8.js} +4 -4
- package/dist/{activation-BwoSqHCc.js.map → activation-ZQWz04u8.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +4 -3
- package/dist/agent.js.map +1 -1
- package/dist/{bundle-DeDkJbsr.js → bundle-PDYNXIEf.js} +2 -2
- package/dist/{bundle-DeDkJbsr.js.map → bundle-PDYNXIEf.js.map} +1 -1
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{coordination-manager-ewBF777W.js → coordination-manager-BZLp9qpE.js} +8 -363
- package/dist/coordination-manager-BZLp9qpE.js.map +1 -0
- package/dist/coordination-map-routing-CUvwHAtv.js +362 -0
- package/dist/coordination-map-routing-CUvwHAtv.js.map +1 -0
- package/dist/{delegate-BiuSfwBa.js → delegate-C-MUU6ML.js} +2 -2
- package/dist/{delegate-BiuSfwBa.js.map → delegate-C-MUU6ML.js.map} +1 -1
- package/dist/durable-file-CksURHlH.js +1 -0
- package/dist/durable-file-DstVeHcj.js +228 -0
- package/dist/durable-file-DstVeHcj.js.map +1 -0
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +10 -8
- package/dist/durable.js.map +1 -1
- package/dist/{graph-D6FL1xze.js → graph-CM-6CV_K.js} +6 -5
- package/dist/{graph-D6FL1xze.js.map → graph-CM-6CV_K.js.map} +1 -1
- package/dist/graph-registry-72DlMnUl.js +585 -0
- package/dist/graph-registry-72DlMnUl.js.map +1 -0
- package/dist/graph-registry-CAX15LO6.js +1 -0
- package/dist/{improve-SiKDcz5_.js → improve-BuZ-I8DP.js} +9 -8
- package/dist/{improve-SiKDcz5_.js.map → improve-BuZ-I8DP.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +7 -7
- package/dist/{journal-store-BJPMUydp.js → journal-store-BpCOCDoO.js} +208 -635
- package/dist/journal-store-BpCOCDoO.js.map +1 -0
- package/dist/jsonl-file-BBP9Dz9w.js +429 -0
- package/dist/jsonl-file-BBP9Dz9w.js.map +1 -0
- package/dist/kernel.d.ts +1 -1
- package/dist/kernel.js +13 -12
- package/dist/{loop-runner-CqlcC0i4.js → loop-runner-BWD6v1rd.js} +2 -2
- package/dist/{loop-runner-CqlcC0i4.js.map → loop-runner-BWD6v1rd.js.map} +1 -1
- package/dist/{loop-runner-D9rcTNf2.d.ts → loop-runner-BpLTU_J4.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +5 -5
- package/dist/{prepare-XWwsOh8O.js → prepare-Bv6X2Wnx.js} +4 -4
- package/dist/{prepare-XWwsOh8O.js.map → prepare-Bv6X2Wnx.js.map} +1 -1
- package/dist/{profile-C01SQZKa.js → profile-Dir2A1_2.js} +2 -2
- package/dist/{profile-C01SQZKa.js.map → profile-Dir2A1_2.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-DnwR0AyW.js → provision-supervisor-BWEeWag1.js} +8 -6
- package/dist/{provision-supervisor-DnwR0AyW.js.map → provision-supervisor-BWEeWag1.js.map} +1 -1
- package/dist/{run-cancellation-CoJRKvih.js → run-cancellation-Cpm-BIUu.js} +3 -2
- package/dist/{run-cancellation-CoJRKvih.js.map → run-cancellation-Cpm-BIUu.js.map} +1 -1
- package/dist/{runtime-DSYZeav8.js → runtime-Cnr3213E.js} +18 -15
- package/dist/{runtime-DSYZeav8.js.map → runtime-Cnr3213E.js.map} +1 -1
- package/dist/{sandbox-profile-compat-CXjozdWL.js → sandbox-profile-compat-DRiz9kME.js} +2 -2
- package/dist/{sandbox-profile-compat-CXjozdWL.js.map → sandbox-profile-compat-DRiz9kME.js.map} +1 -1
- package/dist/{search-executor-DcGAOrAh.js → search-executor-__X1VKnU.js} +5 -5
- package/dist/{search-executor-DcGAOrAh.js.map → search-executor-__X1VKnU.js.map} +1 -1
- package/dist/{server-SrPLb8w0.js → server-CntFSTpW.js} +4 -4
- package/dist/{server-SrPLb8w0.js.map → server-CntFSTpW.js.map} +1 -1
- package/dist/{structural-rollout-C_lg83-u.js → structural-rollout-s8W19Mws.js} +5 -5
- package/dist/{structural-rollout-C_lg83-u.js.map → structural-rollout-s8W19Mws.js.map} +1 -1
- package/dist/{supervise-BXw89Ajc.js → supervise-Cl0F57m9.js} +32 -647
- package/dist/supervise-Cl0F57m9.js.map +1 -0
- package/dist/{supervision-discovery-CewADdEs.js → supervision-discovery-C3t0Xw-T.js} +5 -158
- package/dist/supervision-discovery-C3t0Xw-T.js.map +1 -0
- package/dist/{supervisor-hHU3ZJnR.js → supervisor-L7u3pQ1j.js} +99 -150
- package/dist/supervisor-L7u3pQ1j.js.map +1 -0
- package/dist/task-queue-DbpZAp6C.js +49 -0
- package/dist/task-queue-DbpZAp6C.js.map +1 -0
- package/dist/task-queue.js +1 -49
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +13 -13
- package/dist/top-web-BXICdHgc.js +1121 -0
- package/dist/top-web-BXICdHgc.js.map +1 -0
- package/dist/tui/bin.js +4 -3
- package/dist/tui/bin.js.map +1 -1
- package/dist/tui/index.d.ts +22 -2
- package/dist/tui/index.js +3 -3
- package/dist/{types-DTHxh4X9.d.ts → types-BfnQq-_k.d.ts} +17 -21
- package/dist/{util-ebWMWzY0.js → util-BX20UJ9X.js} +2 -2
- package/dist/{util-ebWMWzY0.js.map → util-BX20UJ9X.js.map} +1 -1
- package/package.json +10 -10
- package/skills/agent-graphs/references/authoring.md +1 -0
- package/dist/coordination-manager-ewBF777W.js.map +0 -1
- package/dist/journal-store-BJPMUydp.js.map +0 -1
- package/dist/supervise-BXw89Ajc.js.map +0 -1
- package/dist/supervision-discovery-CewADdEs.js.map +0 -1
- package/dist/supervisor-hHU3ZJnR.js.map +0 -1
- package/dist/task-queue.js.map +0 -1
- package/dist/top-snapshot-DcV7VG4m.js +0 -520
- package/dist/top-snapshot-DcV7VG4m.js.map +0 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { L as runtimeGraphMetadataKey, Ln as isLiveNodeStatus, Q as resolveSpawnResourcePaths, Qn as CheckUnavailableError, Rn as isTerminalNodeStatus, S as workerTraceAnalysisStore, Sn as INBOX_RECEIPT_KEY, W as meterRuntimeOwnedAccounting, _ as withDriverExecutor, _t as createExecutorRegistry, cr as failedItems, gt as InMemorySpawnJournal, ht as InMemoryResultBlobStore, kn as createPeerMailbox, or as checkVerdictOf, x as parseWorkerToolTraceArtifact } from "./supervisor-L7u3pQ1j.js";
|
|
2
|
+
import { H as contentAddress, i as FileResultBlobStore, nt as assertValidBudget, r as spawnJournalRecordEvents, t as FileSpawnJournal, y as settlementFailureCause } from "./journal-store-BpCOCDoO.js";
|
|
3
|
+
import { b as resolveRedactor, m as errMessage, o as readCommittedJsonLines, t as appendCommittedJsonLine, u as detachedFrozen } from "./jsonl-file-BBP9Dz9w.js";
|
|
4
|
+
import { o as captureRunWriteContext } from "./durable-file-DstVeHcj.js";
|
|
5
|
+
import { C as writeWorkerCancellation, T as writeWorkerSteerAcknowledgement, c as writeRunCancellation, g as readWorkerSteerRequests, h as readWorkerSteerAcknowledgement, i as readRunCancellation, m as readWorkerCancellation, p as readWorkerCancelRequests, r as readRunCancelRequest, t as applyRunCancellation, u as claimWorkerSteerDelivery } from "./run-cancellation-Cpm-BIUu.js";
|
|
6
|
+
import { a as admitRuntimeSpawn, i as workerSettlement, n as resolveJsonPointer, o as safeJsonText, r as textBytes, t as createMapRouting } from "./coordination-map-routing-CUvwHAtv.js";
|
|
4
7
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest } from "@tangle-network/agent-interface";
|
|
5
8
|
import { argHash, errorStreakDetector, observeAll, repeatedActionDetector } from "@tangle-network/agent-eval";
|
|
6
9
|
import { registry } from "zod";
|
|
@@ -192,17 +195,6 @@ function createFileRunContext(dir, opts = {}) {
|
|
|
192
195
|
coordinationLog: new FileCoordinationLog(`${dir}/coordination-log.jsonl`)
|
|
193
196
|
};
|
|
194
197
|
}
|
|
195
|
-
// src/mcp/tools/coordination-json.ts
|
|
196
|
-
/** Stringify a findings payload for a routed delivery; never throws (a cyclic payload degrades to
|
|
197
|
-
* its String form rather than killing the settle path). */
|
|
198
|
-
function safeJsonText(value) {
|
|
199
|
-
if (typeof value === "string") return value;
|
|
200
|
-
try {
|
|
201
|
-
return JSON.stringify(value) ?? String(value);
|
|
202
|
-
} catch {
|
|
203
|
-
return String(value);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
198
|
// src/mcp/tools/coordination-events.ts
|
|
207
199
|
/** Default and maximum bounds for one {@link CoordinationTools} journal read. The defaults are
|
|
208
200
|
* sized for a driver turn (a page a model can read and still have room to act on); the maxima
|
|
@@ -2564,353 +2556,6 @@ async function awaitSettlement(env, workerIds, signal) {
|
|
|
2564
2556
|
})])) && settledIds().length === 0) return [];
|
|
2565
2557
|
}
|
|
2566
2558
|
}
|
|
2567
|
-
// src/mcp/tools/coordination-runtime-spawn.ts
|
|
2568
|
-
/**
|
|
2569
|
-
* Admit one keyed runtime spawn. A key whose prior worker is in doubt (started in a dead process
|
|
2570
|
-
* with no terminal receipt) is re-admitted once under `<key>#2`, the replacement key the
|
|
2571
|
-
* `spawn_worker` contract names; a replacement that is in doubt too is reported, never retried.
|
|
2572
|
-
*/
|
|
2573
|
-
async function admitRuntimeSpawn(admitSpawn, input) {
|
|
2574
|
-
for (const key of [input.key, `${input.key}#2`]) {
|
|
2575
|
-
let response;
|
|
2576
|
-
try {
|
|
2577
|
-
response = await admitSpawn({
|
|
2578
|
-
...input,
|
|
2579
|
-
key
|
|
2580
|
-
});
|
|
2581
|
-
} catch (error) {
|
|
2582
|
-
return { refused: errMessage(error) };
|
|
2583
|
-
}
|
|
2584
|
-
const started = response;
|
|
2585
|
-
if (typeof started.workerId === "string") return {
|
|
2586
|
-
workerId: started.workerId,
|
|
2587
|
-
committed: started.resumed === "completed"
|
|
2588
|
-
};
|
|
2589
|
-
if (started.error !== "in-doubt") return { refused: typeof started.reason === "string" ? started.reason : "spawn refused" };
|
|
2590
|
-
}
|
|
2591
|
-
return { inDoubt: true };
|
|
2592
|
-
}
|
|
2593
|
-
// src/mcp/tools/coordination-map-routing.ts
|
|
2594
|
-
function createMapRouting(deps) {
|
|
2595
|
-
const state = {
|
|
2596
|
-
...deps,
|
|
2597
|
-
mapRoutes: deps.opts.mapOnSettle ?? [],
|
|
2598
|
-
mapMembers: /* @__PURE__ */ new Map(),
|
|
2599
|
-
liveExpansions: /* @__PURE__ */ new Map()
|
|
2600
|
-
};
|
|
2601
|
-
return {
|
|
2602
|
-
isItem: (workerId) => state.mapMembers.get(workerId)?.role === "item",
|
|
2603
|
-
settleMapMember: settleMapMember.bind(null, state),
|
|
2604
|
-
expandMaps: expandMaps.bind(null, state),
|
|
2605
|
-
runMapStep: runMapStep.bind(null, state)
|
|
2606
|
-
};
|
|
2607
|
-
}
|
|
2608
|
-
const textBytes = (value) => Buffer.byteLength(safeJsonText(value), "utf8");
|
|
2609
|
-
async function publishMap({ bus }, event, wake = false) {
|
|
2610
|
-
const record = detachedFrozen({
|
|
2611
|
-
type: "map",
|
|
2612
|
-
map: event
|
|
2613
|
-
});
|
|
2614
|
-
if (wake) await bus.publish(record);
|
|
2615
|
-
else await bus.publish(record, { queue: false });
|
|
2616
|
-
}
|
|
2617
|
-
function workerSlotBound({ opts }) {
|
|
2618
|
-
const capacity = opts.scope.workerCapacity;
|
|
2619
|
-
if (capacity === void 0 || capacity.freeSlots === null) return void 0;
|
|
2620
|
-
return capacity.working + capacity.freeSlots;
|
|
2621
|
-
}
|
|
2622
|
-
async function startMapSpawn(state, expansion, role, profile, task, index) {
|
|
2623
|
-
const { opts } = state;
|
|
2624
|
-
const { route } = expansion;
|
|
2625
|
-
const name = typeof profile.name === "string" && profile.name.length > 0 ? profile.name : "worker";
|
|
2626
|
-
const spawned = await admitRuntimeSpawn(state.admitSpawn, {
|
|
2627
|
-
profile,
|
|
2628
|
-
args: {
|
|
2629
|
-
label: index === void 0 ? name : `${name}#${index}`,
|
|
2630
|
-
...role === "item" && route.itemBudget !== void 0 ? { budget: route.itemBudget } : {}
|
|
2631
|
-
},
|
|
2632
|
-
task,
|
|
2633
|
-
key: `map:${route.edge}#${expansion.expansion}:${index ?? "join"}`,
|
|
2634
|
-
continuity: { continuity: "fresh" },
|
|
2635
|
-
successorOf: void 0,
|
|
2636
|
-
preflightProfile: () => opts.resolveSpawnProfile ? detachedFrozen(opts.resolveSpawnProfile(profile)) : profile,
|
|
2637
|
-
resourcesFromPath: [],
|
|
2638
|
-
defaultLabel: name,
|
|
2639
|
-
map: Object.freeze({
|
|
2640
|
-
edge: route.edge,
|
|
2641
|
-
role,
|
|
2642
|
-
...index === void 0 ? {} : { index }
|
|
2643
|
-
})
|
|
2644
|
-
});
|
|
2645
|
-
if ("inDoubt" in spawned) {
|
|
2646
|
-
await state.endInDoubt(name, expansion.sourceWorker);
|
|
2647
|
-
return { refused: `in-doubt:${name}` };
|
|
2648
|
-
}
|
|
2649
|
-
if ("refused" in spawned) return spawned;
|
|
2650
|
-
state.mapMembers.set(spawned.workerId, {
|
|
2651
|
-
expansion,
|
|
2652
|
-
role,
|
|
2653
|
-
...index === void 0 ? {} : { index },
|
|
2654
|
-
bytes: textBytes(task)
|
|
2655
|
-
});
|
|
2656
|
-
if (role === "item") expansion.inFlight += 1;
|
|
2657
|
-
if (spawned.committed) await state.settleCommitted(spawned.workerId, name);
|
|
2658
|
-
return { workerId: spawned.workerId };
|
|
2659
|
-
}
|
|
2660
|
-
async function mapItemProfile({ opts }, route) {
|
|
2661
|
-
if ("profile" in route.item) return { profile: route.item.profile };
|
|
2662
|
-
if (!opts.graphs) return { refused: "a graph item starts through run_graph, which this manager does not serve" };
|
|
2663
|
-
const prepared = await opts.graphs.prepare({ graph: route.item.graph });
|
|
2664
|
-
return prepared.ok ? { profile: detachedFrozen(prepared.profile) } : { refused: prepared.reason };
|
|
2665
|
-
}
|
|
2666
|
-
/** Record an item that never ran, and tell the manager. */
|
|
2667
|
-
async function recordUnstartedItem(state, expansion, index, reason) {
|
|
2668
|
-
expansion.settlements[index] = {
|
|
2669
|
-
outcome: "unpropagated",
|
|
2670
|
-
reason
|
|
2671
|
-
};
|
|
2672
|
-
await publishMap(state, {
|
|
2673
|
-
edge: expansion.route.edge,
|
|
2674
|
-
phase: "item",
|
|
2675
|
-
outcome: "unpropagated",
|
|
2676
|
-
sourceWorker: expansion.sourceWorker,
|
|
2677
|
-
index,
|
|
2678
|
-
bytes: 0,
|
|
2679
|
-
reason
|
|
2680
|
-
});
|
|
2681
|
-
}
|
|
2682
|
-
async function startMapItem(state, expansion, index) {
|
|
2683
|
-
const { route } = expansion;
|
|
2684
|
-
const resolved = await mapItemProfile(state, route);
|
|
2685
|
-
const started = "refused" in resolved ? resolved : await startMapSpawn(state, expansion, "item", resolved.profile, expansion.items[index], index);
|
|
2686
|
-
if ("workerId" in started) return;
|
|
2687
|
-
if (route.onItemFailure === "all-or-refuse") expansion.stopped = true;
|
|
2688
|
-
await recordUnstartedItem(state, expansion, index, `item spawn refused: ${started.refused}`);
|
|
2689
|
-
}
|
|
2690
|
-
async function pumpMap(state, expansion) {
|
|
2691
|
-
const { route, items } = expansion;
|
|
2692
|
-
while (!expansion.stopped && expansion.inFlight < route.concurrency && expansion.next < items.length) {
|
|
2693
|
-
const index = expansion.next;
|
|
2694
|
-
expansion.next += 1;
|
|
2695
|
-
await startMapItem(state, expansion, index);
|
|
2696
|
-
}
|
|
2697
|
-
if (expansion.inFlight === 0) await finishMap(state, expansion);
|
|
2698
|
-
}
|
|
2699
|
-
async function finishMap(state, expansion, closed) {
|
|
2700
|
-
if (expansion.finished) return;
|
|
2701
|
-
expansion.finished = true;
|
|
2702
|
-
const { route, items, sourceWorker } = expansion;
|
|
2703
|
-
for (let index = expansion.next; index < items.length; index += 1) await recordUnstartedItem(state, expansion, index, closed ?? "not started: all-or-refuse stopped this map after an item failed");
|
|
2704
|
-
expansion.next = items.length;
|
|
2705
|
-
const { results, failures } = collectJoinInputs(expansion);
|
|
2706
|
-
const refusal = closed ?? (route.onItemFailure === "all-or-refuse" && failures.length > 0 ? `all-or-refuse: ${failures.length} of ${items.length} items did not deliver (${failures.map((failure) => `#${failure.index} ${failure.outcome}: ${failure.reason}`).join("; ")}); the join did not run` : void 0);
|
|
2707
|
-
if (refusal !== void 0) {
|
|
2708
|
-
await publishMap(state, {
|
|
2709
|
-
edge: route.edge,
|
|
2710
|
-
phase: "join",
|
|
2711
|
-
outcome: "unpropagated",
|
|
2712
|
-
sourceWorker,
|
|
2713
|
-
bytes: 0,
|
|
2714
|
-
reason: refusal
|
|
2715
|
-
}, closed === void 0);
|
|
2716
|
-
return;
|
|
2717
|
-
}
|
|
2718
|
-
const task = {
|
|
2719
|
-
map: route.edge,
|
|
2720
|
-
source: sourceWorker,
|
|
2721
|
-
items: items.length,
|
|
2722
|
-
results,
|
|
2723
|
-
failures
|
|
2724
|
-
};
|
|
2725
|
-
const started = await startMapSpawn(state, expansion, "join", route.join, task, void 0);
|
|
2726
|
-
if ("refused" in started) await publishMap(state, {
|
|
2727
|
-
edge: route.edge,
|
|
2728
|
-
phase: "join",
|
|
2729
|
-
outcome: "unpropagated",
|
|
2730
|
-
sourceWorker,
|
|
2731
|
-
bytes: 0,
|
|
2732
|
-
reason: `join spawn refused: ${started.refused}`
|
|
2733
|
-
}, true);
|
|
2734
|
-
}
|
|
2735
|
-
/** Split an expansion's settlements into the delivered results and the failures, in item order. */
|
|
2736
|
-
function collectJoinInputs(expansion) {
|
|
2737
|
-
const results = [];
|
|
2738
|
-
const failures = [];
|
|
2739
|
-
expansion.items.forEach((item, index) => {
|
|
2740
|
-
const settlement = expansion.settlements[index];
|
|
2741
|
-
if (settlement?.outcome === "delivered") results.push({
|
|
2742
|
-
index,
|
|
2743
|
-
item,
|
|
2744
|
-
result: settlement.result
|
|
2745
|
-
});
|
|
2746
|
-
else failures.push({
|
|
2747
|
-
index,
|
|
2748
|
-
item,
|
|
2749
|
-
outcome: settlement?.outcome ?? "unpropagated",
|
|
2750
|
-
reason: settlement?.reason ?? "never settled"
|
|
2751
|
-
});
|
|
2752
|
-
});
|
|
2753
|
-
return {
|
|
2754
|
-
results,
|
|
2755
|
-
failures
|
|
2756
|
-
};
|
|
2757
|
-
}
|
|
2758
|
-
async function settleMapMember(state, settled, worker, advance) {
|
|
2759
|
-
const member = state.mapMembers.get(worker.id);
|
|
2760
|
-
if (member === void 0) return;
|
|
2761
|
-
state.mapMembers.delete(worker.id);
|
|
2762
|
-
const { expansion, role, index, bytes } = member;
|
|
2763
|
-
const settlement = workerSettlement(settled, worker);
|
|
2764
|
-
await publishMap(state, {
|
|
2765
|
-
edge: expansion.route.edge,
|
|
2766
|
-
phase: role,
|
|
2767
|
-
outcome: settlement.outcome,
|
|
2768
|
-
sourceWorker: expansion.sourceWorker,
|
|
2769
|
-
...index === void 0 ? {} : { index },
|
|
2770
|
-
workerId: worker.id,
|
|
2771
|
-
bytes,
|
|
2772
|
-
...settlement.reason === void 0 ? {} : { reason: settlement.reason }
|
|
2773
|
-
});
|
|
2774
|
-
if (role === "join" || index === void 0) return;
|
|
2775
|
-
expansion.inFlight -= 1;
|
|
2776
|
-
expansion.settlements[index] = settlement;
|
|
2777
|
-
if (settlement.outcome !== "delivered" && expansion.route.onItemFailure === "all-or-refuse") expansion.stopped = true;
|
|
2778
|
-
if (advance) await pumpMap(state, expansion);
|
|
2779
|
-
else if (expansion.inFlight === 0) await finishMap(state, expansion, "not started: the manager stopped before this map finished");
|
|
2780
|
-
}
|
|
2781
|
-
function expansionOf(state, source, workerId) {
|
|
2782
|
-
const resume = state.opts.scope.resume;
|
|
2783
|
-
const labels = new Map(resume?.view.nodes.map((node) => [node.id, node.label]) ?? []);
|
|
2784
|
-
const prior = (resume?.settled ?? []).filter((s) => s.kind === "done" && labels.get(s.handle.id) === source).map((s) => s.handle.id);
|
|
2785
|
-
const rank = prior.indexOf(workerId);
|
|
2786
|
-
if (rank >= 0) return rank + 1;
|
|
2787
|
-
let journaled = 0;
|
|
2788
|
-
for (const route of state.mapRoutes) {
|
|
2789
|
-
if (route.from !== source) continue;
|
|
2790
|
-
const prefix = `key:map:${route.edge}#`;
|
|
2791
|
-
for (const node of resume?.view.nodes ?? []) {
|
|
2792
|
-
if (!node.assignmentId?.startsWith(prefix)) continue;
|
|
2793
|
-
const n = Number.parseInt(node.assignmentId.slice(prefix.length), 10);
|
|
2794
|
-
if (Number.isSafeInteger(n)) journaled = Math.max(journaled, n);
|
|
2795
|
-
}
|
|
2796
|
-
}
|
|
2797
|
-
const live = (state.liveExpansions.get(source) ?? 0) + 1;
|
|
2798
|
-
state.liveExpansions.set(source, live);
|
|
2799
|
-
return Math.max(prior.length, journaled) + live;
|
|
2800
|
-
}
|
|
2801
|
-
/** The list a map expands over, or the reason no item runs. */
|
|
2802
|
-
function resolveMapItems(state, out, route) {
|
|
2803
|
-
const selected = resolveJsonPointer(out, route.pointer);
|
|
2804
|
-
if (!selected.found) return { refusal: `pointer ${JSON.stringify(route.pointer)} does not resolve in the source result: ${selected.reason}; no item ran` };
|
|
2805
|
-
const items = selected.value;
|
|
2806
|
-
if (!Array.isArray(items)) return { refusal: `pointer ${JSON.stringify(route.pointer)} resolves to ${items === null ? "null" : typeof items}, not an array; no item ran` };
|
|
2807
|
-
if (items.length > route.maxItems) return { refusal: `max-items-exceeded: the list holds ${items.length} items and this map admits at most ${route.maxItems}; no item ran` };
|
|
2808
|
-
const slots = workerSlotBound(state);
|
|
2809
|
-
if (slots !== void 0 && route.concurrency > slots) return { refusal: `concurrency-unsatisfiable: concurrency ${route.concurrency} exceeds this run's ${slots} worker slots, so the cap could never be honored; no item ran` };
|
|
2810
|
-
return { items };
|
|
2811
|
-
}
|
|
2812
|
-
async function expandMaps(state, settled, worker) {
|
|
2813
|
-
const { mapRoutes } = state;
|
|
2814
|
-
if (settled.kind !== "done" || mapRoutes.length === 0) return;
|
|
2815
|
-
const name = state.nodeOf(worker.id);
|
|
2816
|
-
if (name === void 0 || !mapRoutes.some((route) => route.from === name)) return;
|
|
2817
|
-
const expansion = expansionOf(state, name, worker.id);
|
|
2818
|
-
for (const route of mapRoutes) {
|
|
2819
|
-
if (route.from !== name) continue;
|
|
2820
|
-
const resolved = resolveMapItems(state, settled.out, route);
|
|
2821
|
-
if ("refusal" in resolved) {
|
|
2822
|
-
await publishMap(state, {
|
|
2823
|
-
edge: route.edge,
|
|
2824
|
-
phase: "expand",
|
|
2825
|
-
outcome: "unpropagated",
|
|
2826
|
-
sourceWorker: worker.id,
|
|
2827
|
-
bytes: 0,
|
|
2828
|
-
reason: resolved.refusal
|
|
2829
|
-
}, true);
|
|
2830
|
-
continue;
|
|
2831
|
-
}
|
|
2832
|
-
const { items } = resolved;
|
|
2833
|
-
await publishMap(state, {
|
|
2834
|
-
edge: route.edge,
|
|
2835
|
-
phase: "expand",
|
|
2836
|
-
outcome: items.length === 0 ? "empty" : "delivered",
|
|
2837
|
-
sourceWorker: worker.id,
|
|
2838
|
-
bytes: textBytes(items),
|
|
2839
|
-
items: items.length,
|
|
2840
|
-
...items.length === 0 ? { reason: "the list is empty; the join runs with no results" } : {}
|
|
2841
|
-
});
|
|
2842
|
-
await pumpMap(state, {
|
|
2843
|
-
route,
|
|
2844
|
-
sourceWorker: worker.id,
|
|
2845
|
-
expansion,
|
|
2846
|
-
items: detachedFrozen(items),
|
|
2847
|
-
settlements: [],
|
|
2848
|
-
next: 0,
|
|
2849
|
-
inFlight: 0,
|
|
2850
|
-
stopped: false,
|
|
2851
|
-
finished: false
|
|
2852
|
-
});
|
|
2853
|
-
}
|
|
2854
|
-
}
|
|
2855
|
-
async function runMapStep({ opts }, step, worker) {
|
|
2856
|
-
try {
|
|
2857
|
-
await step();
|
|
2858
|
-
} catch (error) {
|
|
2859
|
-
console.error("Runtime map step failed", {
|
|
2860
|
-
managerId: opts.scope.view.root,
|
|
2861
|
-
worker: worker.id,
|
|
2862
|
-
error: errMessage(error)
|
|
2863
|
-
});
|
|
2864
|
-
}
|
|
2865
|
-
}
|
|
2866
|
-
function workerSettlement(settled, worker) {
|
|
2867
|
-
if (settled.kind !== "done" || worker.status !== "done") return {
|
|
2868
|
-
outcome: "failed",
|
|
2869
|
-
reason: worker.status === "down" ? worker.reason : "down"
|
|
2870
|
-
};
|
|
2871
|
-
if (worker.valid === false) return {
|
|
2872
|
-
outcome: "failed",
|
|
2873
|
-
reason: "its deliverable check rejected the result"
|
|
2874
|
-
};
|
|
2875
|
-
if (settled.out === void 0) return {
|
|
2876
|
-
outcome: "empty",
|
|
2877
|
-
reason: "it settled with no result"
|
|
2878
|
-
};
|
|
2879
|
-
return {
|
|
2880
|
-
outcome: "delivered",
|
|
2881
|
-
result: settled.out
|
|
2882
|
-
};
|
|
2883
|
-
}
|
|
2884
|
-
/** Resolve an RFC 6901 JSON pointer (`''` is the whole document). */
|
|
2885
|
-
function resolveJsonPointer(document, pointer) {
|
|
2886
|
-
if (pointer === "") return {
|
|
2887
|
-
found: true,
|
|
2888
|
-
value: document
|
|
2889
|
-
};
|
|
2890
|
-
if (!pointer.startsWith("/")) return {
|
|
2891
|
-
found: false,
|
|
2892
|
-
reason: "a JSON pointer is empty or starts with \"/\""
|
|
2893
|
-
};
|
|
2894
|
-
let value = document;
|
|
2895
|
-
for (const raw of pointer.slice(1).split("/")) {
|
|
2896
|
-
const token = raw.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
2897
|
-
if (Array.isArray(value)) {
|
|
2898
|
-
if (!/^(0|[1-9]\d*)$/.test(token) || Number(token) >= value.length) return {
|
|
2899
|
-
found: false,
|
|
2900
|
-
reason: `no index ${JSON.stringify(token)} in an array of ${value.length}`
|
|
2901
|
-
};
|
|
2902
|
-
value = value[Number(token)];
|
|
2903
|
-
} else if (typeof value === "object" && value !== null && Object.hasOwn(value, token)) value = value[token];
|
|
2904
|
-
else return {
|
|
2905
|
-
found: false,
|
|
2906
|
-
reason: `no member ${JSON.stringify(token)}`
|
|
2907
|
-
};
|
|
2908
|
-
}
|
|
2909
|
-
return {
|
|
2910
|
-
found: true,
|
|
2911
|
-
value
|
|
2912
|
-
};
|
|
2913
|
-
}
|
|
2914
2559
|
// src/mcp/tools/coordination-question-ledger.ts
|
|
2915
2560
|
function createQuestionLedger({ opts, bus }) {
|
|
2916
2561
|
let questionSeq = 0;
|
|
@@ -5580,6 +5225,6 @@ function createResumeReplay({ opts, bus, ledger, analysis, projectSettled }) {
|
|
|
5580
5225
|
return readyInFlight;
|
|
5581
5226
|
};
|
|
5582
5227
|
}
|
|
5583
|
-
export {
|
|
5228
|
+
export { downMessageRefusalReasons as a, createSteerAcknowledger as c, coordinationVerbNames as d, createFileRunContext as f, foldCoordinationRecords as g, FileCoordinationLog as h, watchTrace as i, budgetOverspendText as l, withRunContext as m, createCoordinationToolsForManager as n, createEventBus as o, createInMemoryRunContext as p, defaultToolDetectors as r, createCancelAcknowledger as s, createCoordinationTools as t, normalizeAnalyzeOnSettle as u };
|
|
5584
5229
|
|
|
5585
|
-
//# sourceMappingURL=coordination-manager-
|
|
5230
|
+
//# sourceMappingURL=coordination-manager-BZLp9qpE.js.map
|