@tangle-network/agent-runtime 0.326.1 → 0.328.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.
Files changed (44) hide show
  1. package/dist/{activation-DKBSwzzM.d.ts → activation-CZRtcDPo.d.ts} +2 -2
  2. package/dist/agent.d.ts +1 -1
  3. package/dist/agent.js +1 -1
  4. package/dist/{coordination-driver-CwisRZNE.js → coordination-driver-B7Z9jgFr.js} +323 -11
  5. package/dist/coordination-driver-B7Z9jgFr.js.map +1 -0
  6. package/dist/{delegate-SNxVKolU.js → delegate-By9tikQT.js} +2 -2
  7. package/dist/{delegate-SNxVKolU.js.map → delegate-By9tikQT.js.map} +1 -1
  8. package/dist/durable.d.ts +1 -1
  9. package/dist/durable.js +2 -2
  10. package/dist/{graph-C4kRA087.js → graph-0iL-4gj2.js} +12 -5
  11. package/dist/graph-0iL-4gj2.js.map +1 -0
  12. package/dist/index.d.ts +4 -4
  13. package/dist/index.js +3 -3
  14. package/dist/intelligence.d.ts +2 -2
  15. package/dist/kernel.d.ts +2 -2
  16. package/dist/kernel.js +6 -6
  17. package/dist/{loop-runner-bin-7QRTmVT4.js → loop-runner-bin-CNmBGFAu.js} +2 -2
  18. package/dist/{loop-runner-bin-7QRTmVT4.js.map → loop-runner-bin-CNmBGFAu.js.map} +1 -1
  19. package/dist/{loop-runner-bin-CF57Yt4o.d.ts → loop-runner-bin-DDz4VTyE.d.ts} +2 -2
  20. package/dist/loop-runner-bin.d.ts +1 -1
  21. package/dist/loop-runner-bin.js +1 -1
  22. package/dist/mcp/bin.js +2 -2
  23. package/dist/mcp/index.d.ts +2 -2
  24. package/dist/mcp/index.js +3 -3
  25. package/dist/{openai-tools-DLcMbjQ1.d.ts → openai-tools-B3Z4i5_B.d.ts} +2 -2
  26. package/dist/profiles.d.ts +1 -1
  27. package/dist/{provision-supervisor-Dckc-egc.js → provision-supervisor-CCoerJyv.js} +2 -2
  28. package/dist/{provision-supervisor-Dckc-egc.js.map → provision-supervisor-CCoerJyv.js.map} +1 -1
  29. package/dist/{runtime-DtG9pERP.js → runtime-CYjHXjec.js} +6 -6
  30. package/dist/{runtime-DtG9pERP.js.map → runtime-CYjHXjec.js.map} +1 -1
  31. package/dist/{server-Bu-aEHwV.js → server-Czsqviqu.js} +2 -2
  32. package/dist/{server-Bu-aEHwV.js.map → server-Czsqviqu.js.map} +1 -1
  33. package/dist/{supervise-DZMOajvP.js → supervise-9WPjMFrH.js} +196 -27
  34. package/dist/supervise-9WPjMFrH.js.map +1 -0
  35. package/dist/testing.d.ts +1 -1
  36. package/dist/testing.js +11 -11
  37. package/dist/tui/index.d.ts +1 -1
  38. package/dist/tui/index.js +1 -1
  39. package/dist/{types-BFDS9hpV.d.ts → types-0czU5q4A.d.ts} +171 -8
  40. package/package.json +3 -3
  41. package/skills/agent-graphs/references/authoring.md +12 -1
  42. package/dist/coordination-driver-CwisRZNE.js.map +0 -1
  43. package/dist/graph-C4kRA087.js.map +0 -1
  44. package/dist/supervise-DZMOajvP.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { $s as AgentTurnUsage, Ih as ExecutorConfig, US as OtelExportConfig, Xg as SharedBoxPlacementOptions, Yg as SharedBoxPlacement, ec as CollectedAgentTurn, jw as BudgetPool, kw as WorkerSlots } from "./types-BFDS9hpV.js";
1
+ import { Iw as BudgetPool, JS as OtelExportConfig, Pw as WorkerSlots, Vh as ExecutorConfig, e_ as SharedBoxPlacement, ic as CollectedAgentTurn, rc as AgentTurnUsage, t_ as SharedBoxPlacementOptions } from "./types-0czU5q4A.js";
2
2
  import { AgentCandidateBundle, AgentImprovementActivation, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementActivationTarget, AgentImprovementProposal, AgentImprovementReview, AgentImprovementSurface, AgentProfile, AgentProfileImprovementChange, AgentProfileImprovementExperiment, AgentTrainingReceipt, AgentTrainingTask, HarnessType, ReasoningEffort, Sha256Digest } from "@tangle-network/agent-interface";
3
3
  import { CostLedgerHandle, CostReceiptInput, MaximumCharge, PairedPromotionDecision, PendingCostCallView, ProposalFinding, RunRecord } from "@tangle-network/agent-eval";
4
4
  import { CampaignCellResult, CampaignScenarioIdentity, CampaignStorage, CompareOptimizationMethodsOptions, OptimizationMethod, OptimizationMethodComparison, Scenario, SearchAllocator, SearchCellResult, SearchCellStage, SearchClaim, SearchClaimVerification, SearchHistoryReceipt, SearchLane, SearchModelIdentity, SearchPolicy, SearchSourceRef, SearchSplit, SearchStateView, SurfaceProposer, WorktreeAdapter } from "@tangle-network/agent-eval/campaign";
@@ -1013,4 +1013,4 @@ declare function verifyAgentImprovementActivationResult(input: {
1013
1013
  declare function executeAgentImprovementActivation(input: ExecuteAgentImprovementActivationInput, options: ExecuteAgentImprovementActivationOptions): Promise<AgentImprovementActivationResult>;
1014
1014
  //#endregion
1015
1015
  export { ImproveScenarioPartitions as $, createCommandProfileTrainer as A, AgenticGeneratorShotReceipt as At, ImproveMethodContext as B, ControlledTrainingCommand as C, subscriptionLane as Ct, ProfileTrainerRequest as D, AgenticGeneratorOptions as Dt, ProfileTrainer as E, AgenticGeneratorExecutorForWorktree as Et, ImproveCodeResult as F, defaultBuildPrompt as Ft, ImproveMethodSource as G, ImproveMethodLineage as H, ImproveCodeRunOptions as I, CandidateGenerator as It, ImproveProfileAgent as J, ImproveOptimizationRunOptions as K, ImproveCost as L, ImproveCandidateValidator as M, VerifyResult as Mt, ImproveCodeBaseOptions as N, agenticGenerator as Nt, TrainingBoundaryResult as O, AgenticGeneratorShotDisposition as Ot, ImproveCodeOptions as P, commandVerifier as Pt, ImproveRuntimeCodeGeneratorOptions as Q, ImproveCustomCodeGeneratorOptions as R, CheckpointServingPort as S, sharedBoxLane as St, ImproveTrainingResult as T, ReadonlyAgentProfile as Tt, ImproveMethodOptions as U, ImproveMethodFactory as V, ImproveMethodResult as W, ImproveProfileSurface as X, ImproveProfileComponents as Y, ImproveResult as Z, SearchMethodOptions as _, SearchTraceOptions as _t, AgentImprovementActivationTransitionInput as a, ImproveSkillsOptions as at, SearchImprovementDecision as b, isSearchEnvironmentFault as bt, CreateAgentImprovementActivationResultOptions as c, ImprovementCodeCandidate as ct, ProfileImprovementActivationTransitionInput as d, SearchPromotion as dt, ImproveSearchAgent as et, SealedCandidateActivationTransitionInput as f, SearchCellContext as ft, improve as g, SearchLaneOptions as gt, verifyAgentImprovementActivationResult as h, SearchLaneKind as ht, AgentImprovementActivationTransition as i, ImproveSearchResult as it, ImproveCandidateValidationInput as j, Verifier as jt, TrainingDatasetDocument as k, AgenticGeneratorShotExecution as kt, ExecuteAgentImprovementActivationInput as l, ImprovementProfileCandidate as lt, executeAgentImprovementActivation as m, SearchLane$1 as mt, AgentImprovementActivationResultStore as n, ImproveSearchMethod as nt, AgentProfileImprovementActivationOperation as o, ImproveSurface as ot, createAgentImprovementActivationResult as p, SearchEnvironmentFault as pt, ImproveOptions as q, AgentImprovementActivationTargetPlan as r, ImproveSearchOptions as rt, AgentProfileImprovementActivationTargetPlan as s, ImprovementCandidate as st, AgentImprovementActivationReconciliation as t, ImproveSearchIdentity as tt, ExecuteAgentImprovementActivationOptions as u, SearchDispatchContext as ut, searchMethod as v, SharedBoxSearchLane as vt, ImproveTrainingOptions as w, DeepReadonly as wt, decideSearchImprovement as x, routerLane as xt, DecideSearchImprovementOptions as y, dedicatedLane as yt, ImproveLineage as z };
1016
- //# sourceMappingURL=activation-DKBSwzzM.d.ts.map
1016
+ //# sourceMappingURL=activation-CZRtcDPo.d.ts.map
package/dist/agent.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Kw as AgentRunSpec, S as RuntimeStreamEvent, _T as SandboxClient, hT as OutputAdapter } from "./types-BFDS9hpV.js";
1
+ import { S as RuntimeStreamEvent, ST as SandboxClient, Zw as AgentRunSpec, bT as OutputAdapter } from "./types-0czU5q4A.js";
2
2
  import { C as worktreeCliProfileMaterialization, S as validateProfileMaterialization, _ as promptModelProfileMaterialization, a as DefineProfileMaterializationContractOptions, b as renderProfileMaterializationIssues, c as ProfileMaterializationIssue, d as assertProfileMaterializes, f as controlProfileMaterialization, g as promptControlProfileMaterialization, h as profileMaterializationAxes, i as CanonicalAgentProfileMaterializationAxis, l as ValidateProfileMaterializationOptions, m as fullProfileMaterialization, n as AgentProfileMaterializationAxis, o as KnownAgentProfileMaterializationAxis, p as defineProfileMaterializationContract, r as AssertProfileMaterializationOptions, s as ProfileMaterializationContract, t as AGENT_PROFILE_MATERIALIZATION_AXES, u as assertProfileMaterialization, v as promptOnlyProfileMaterialization, x as sandboxActProfileMaterialization, y as promptResourceProfileMaterialization } from "./profile-materialization-BnoEf1co.js";
3
3
  import { a as createSurfaceImprovementProposer, c as SurfaceValidationIssue, d as validateSurfaces, i as SurfaceImprovementEdit, l as renderSurfaceIssues, n as DraftPatchInput, o as AgentSurfaces, r as DraftPatchOutput, s as ResolvedSurface, t as CreateSurfaceImprovementProposerOptions, u as resolveSubjectPath } from "./improvement-adapter-D5gwwoXQ.js";
4
4
  import { AgentProfile, AgentProfileFileMount, AgentProfileMcpServer } from "@tangle-network/agent-interface";
package/dist/agent.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Gr as defineProfileMaterializationContract, Hr as assertProfileMaterialization, Jr as promptControlProfileMaterialization, Kr as fullProfileMaterialization, Qr as renderProfileMaterializationIssues, Ur as assertProfileMaterializes, Vr as AGENT_PROFILE_MATERIALIZATION_AXES, Wi as mapSandboxEvent, Wr as controlProfileMaterialization, Xr as promptOnlyProfileMaterialization, Yr as promptModelProfileMaterialization, Zr as promptResourceProfileMaterialization, ei as sandboxActProfileMaterialization, hn as createSandboxForSpec, ii as worktreeCliProfileMaterialization, qr as profileMaterializationAxes, ri as validateProfileMaterialization } from "./supervisor-hIpqcCJr.js";
2
- import "./runtime-DtG9pERP.js";
2
+ import "./runtime-CYjHXjec.js";
3
3
  import { createHash } from "node:crypto";
4
4
  import { existsSync, readFileSync, statSync } from "node:fs";
5
5
  import { isAbsolute, join, relative, resolve, sep } from "node:path";
@@ -521,7 +521,8 @@ const journalEventKinds = [
521
521
  "analyst-assignment",
522
522
  "acknowledgement",
523
523
  "tool-outcome",
524
- "lead-message"
524
+ "lead-message",
525
+ "map"
525
526
  ];
526
527
  /** The reserved coordination verb names — the complete set `createCoordinationTools` can emit
527
528
  * (the analyst pair is conditional but still reserved). A driver's extra WORK tools must not
@@ -564,7 +565,8 @@ const wakeEventKinds = [
564
565
  "settled",
565
566
  "finding",
566
567
  "tool-outcome",
567
- "lead-message"
568
+ "lead-message",
569
+ "map"
568
570
  ];
569
571
  const idArg = {
570
572
  type: "string",
@@ -1023,7 +1025,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
1023
1025
  checkReads.push(entry);
1024
1026
  return entry;
1025
1027
  };
1026
- const eventWorker = (event) => event.type === "settled" ? event.worker.id : event.type === "finding" ? event.finding.fromWorker : event.type === "question" ? event.question.from : void 0;
1028
+ const eventWorker = (event) => event.type === "settled" ? event.worker.id : event.type === "finding" ? event.finding.fromWorker : event.type === "question" ? event.question.from : event.type === "map" ? event.map.sourceWorker : void 0;
1027
1029
  const acknowledge = async (targets, by) => {
1028
1030
  const fresh = targets.filter((delivery) => !delivery.acknowledged);
1029
1031
  if (fresh.length === 0) return [];
@@ -1343,6 +1345,271 @@ function createCoordinationToolsForManager(opts, lifetime) {
1343
1345
  analyst: kind,
1344
1346
  sourceWorker
1345
1347
  }, { alreadySpent: true }) });
1348
+ const mapRoutes = opts.mapOnSettle ?? [];
1349
+ const mapMembers = /* @__PURE__ */ new Map();
1350
+ const textBytes = (value) => Buffer.byteLength(safeJsonText(value), "utf8");
1351
+ const publishMap = async (event, wake = false) => {
1352
+ const record = detachedFrozen({
1353
+ type: "map",
1354
+ map: event
1355
+ });
1356
+ if (wake) await bus.publish(record);
1357
+ else await bus.publish(record, { queue: false });
1358
+ };
1359
+ const workerSlotBound = () => {
1360
+ const capacity = opts.scope.workerCapacity;
1361
+ if (capacity === void 0 || capacity.freeSlots === null) return void 0;
1362
+ return capacity.working + capacity.freeSlots;
1363
+ };
1364
+ const mapSettlement = (settled, worker) => {
1365
+ if (settled.kind !== "done" || worker.status !== "done") return {
1366
+ outcome: "failed",
1367
+ reason: worker.status === "down" ? worker.reason : "down"
1368
+ };
1369
+ if (worker.valid === false) return {
1370
+ outcome: "failed",
1371
+ reason: "its deliverable check rejected the result"
1372
+ };
1373
+ if (settled.out === void 0) return {
1374
+ outcome: "empty",
1375
+ reason: "it settled with no result"
1376
+ };
1377
+ return {
1378
+ outcome: "delivered",
1379
+ result: settled.out
1380
+ };
1381
+ };
1382
+ const startMapSpawn = async (expansion, role, profile, task, index) => {
1383
+ const { route } = expansion;
1384
+ const name = typeof profile.name === "string" && profile.name.length > 0 ? profile.name : "worker";
1385
+ let response;
1386
+ try {
1387
+ response = await admitSpawn({
1388
+ profile,
1389
+ args: {
1390
+ label: index === void 0 ? name : `${name}#${index}`,
1391
+ ...role === "item" && route.itemBudget !== void 0 ? { budget: route.itemBudget } : {}
1392
+ },
1393
+ task,
1394
+ key: void 0,
1395
+ continuity: { continuity: "fresh" },
1396
+ successorOf: void 0,
1397
+ preflightProfile: () => opts.resolveSpawnProfile ? detachedFrozen(opts.resolveSpawnProfile(profile)) : profile,
1398
+ resourcesFromPath: [],
1399
+ defaultLabel: name,
1400
+ map: Object.freeze({
1401
+ edge: route.edge,
1402
+ role,
1403
+ ...index === void 0 ? {} : { index }
1404
+ })
1405
+ });
1406
+ } catch (error) {
1407
+ return { refused: errMessage(error) };
1408
+ }
1409
+ const started = response;
1410
+ if (typeof started.workerId === "string") {
1411
+ mapMembers.set(started.workerId, {
1412
+ expansion,
1413
+ role,
1414
+ ...index === void 0 ? {} : { index },
1415
+ bytes: textBytes(task)
1416
+ });
1417
+ return { workerId: started.workerId };
1418
+ }
1419
+ return { refused: typeof started.reason === "string" ? started.reason : "spawn refused" };
1420
+ };
1421
+ const mapItemProfile = async (route) => {
1422
+ if ("profile" in route.item) return { profile: route.item.profile };
1423
+ if (!opts.graphs) return { refused: "a graph item starts through run_graph, which this manager does not serve" };
1424
+ const prepared = await opts.graphs.prepare({ graph: route.item.graph });
1425
+ return prepared.ok ? { profile: detachedFrozen(prepared.profile) } : { refused: prepared.reason };
1426
+ };
1427
+ const startMapItem = async (expansion, index) => {
1428
+ const { route } = expansion;
1429
+ const resolved = await mapItemProfile(route);
1430
+ const started = "refused" in resolved ? resolved : await startMapSpawn(expansion, "item", resolved.profile, expansion.items[index], index);
1431
+ if ("workerId" in started) {
1432
+ expansion.inFlight += 1;
1433
+ return;
1434
+ }
1435
+ const reason = `item spawn refused: ${started.refused}`;
1436
+ expansion.settlements[index] = {
1437
+ outcome: "unpropagated",
1438
+ reason
1439
+ };
1440
+ if (route.onItemFailure === "all-or-refuse") expansion.stopped = true;
1441
+ await publishMap({
1442
+ edge: route.edge,
1443
+ phase: "item",
1444
+ outcome: "unpropagated",
1445
+ sourceWorker: expansion.sourceWorker,
1446
+ index,
1447
+ bytes: 0,
1448
+ reason
1449
+ });
1450
+ };
1451
+ const pumpMap = async (expansion) => {
1452
+ const { route, items } = expansion;
1453
+ while (!expansion.stopped && expansion.inFlight < route.concurrency && expansion.next < items.length) {
1454
+ const index = expansion.next;
1455
+ expansion.next += 1;
1456
+ await startMapItem(expansion, index);
1457
+ }
1458
+ if (expansion.inFlight === 0) await finishMap(expansion);
1459
+ };
1460
+ const finishMap = async (expansion, closed) => {
1461
+ if (expansion.finished) return;
1462
+ expansion.finished = true;
1463
+ const { route, items, sourceWorker } = expansion;
1464
+ for (let index = expansion.next; index < items.length; index += 1) {
1465
+ const reason = closed ?? "not started: all-or-refuse stopped this map after an item failed";
1466
+ expansion.settlements[index] = {
1467
+ outcome: "unpropagated",
1468
+ reason
1469
+ };
1470
+ await publishMap({
1471
+ edge: route.edge,
1472
+ phase: "item",
1473
+ outcome: "unpropagated",
1474
+ sourceWorker,
1475
+ index,
1476
+ bytes: 0,
1477
+ reason
1478
+ });
1479
+ }
1480
+ expansion.next = items.length;
1481
+ const results = [];
1482
+ const failures = [];
1483
+ items.forEach((item, index) => {
1484
+ const settlement = expansion.settlements[index];
1485
+ if (settlement?.outcome === "delivered") results.push({
1486
+ index,
1487
+ item,
1488
+ result: settlement.result
1489
+ });
1490
+ else failures.push({
1491
+ index,
1492
+ item,
1493
+ outcome: settlement?.outcome ?? "unpropagated",
1494
+ reason: settlement?.reason ?? "never settled"
1495
+ });
1496
+ });
1497
+ 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);
1498
+ if (refusal !== void 0) {
1499
+ await publishMap({
1500
+ edge: route.edge,
1501
+ phase: "join",
1502
+ outcome: "unpropagated",
1503
+ sourceWorker,
1504
+ bytes: 0,
1505
+ reason: refusal
1506
+ }, closed === void 0);
1507
+ return;
1508
+ }
1509
+ const task = {
1510
+ map: route.edge,
1511
+ source: sourceWorker,
1512
+ items: items.length,
1513
+ results,
1514
+ failures
1515
+ };
1516
+ const started = await startMapSpawn(expansion, "join", route.join, task, void 0);
1517
+ if ("refused" in started) await publishMap({
1518
+ edge: route.edge,
1519
+ phase: "join",
1520
+ outcome: "unpropagated",
1521
+ sourceWorker,
1522
+ bytes: 0,
1523
+ reason: `join spawn refused: ${started.refused}`
1524
+ }, true);
1525
+ };
1526
+ const settleMapMember = async (settled, worker, advance) => {
1527
+ const member = mapMembers.get(worker.id);
1528
+ if (member === void 0) return;
1529
+ mapMembers.delete(worker.id);
1530
+ const { expansion, role, index, bytes } = member;
1531
+ const settlement = mapSettlement(settled, worker);
1532
+ await publishMap({
1533
+ edge: expansion.route.edge,
1534
+ phase: role,
1535
+ outcome: settlement.outcome,
1536
+ sourceWorker: expansion.sourceWorker,
1537
+ ...index === void 0 ? {} : { index },
1538
+ workerId: worker.id,
1539
+ bytes,
1540
+ ...settlement.reason === void 0 ? {} : { reason: settlement.reason }
1541
+ });
1542
+ if (role === "join" || index === void 0) return;
1543
+ expansion.inFlight -= 1;
1544
+ expansion.settlements[index] = settlement;
1545
+ if (settlement.outcome !== "delivered" && expansion.route.onItemFailure === "all-or-refuse") expansion.stopped = true;
1546
+ if (advance) await pumpMap(expansion);
1547
+ else if (expansion.inFlight === 0) await finishMap(expansion, "not started: the manager stopped before this map finished");
1548
+ };
1549
+ const expandMaps = async (settled, worker) => {
1550
+ if (settled.kind !== "done" || mapRoutes.length === 0) return;
1551
+ const name = profileNameByWorker.get(worker.id);
1552
+ for (const route of mapRoutes) {
1553
+ if (route.from !== name) continue;
1554
+ const refuse = (reason) => publishMap({
1555
+ edge: route.edge,
1556
+ phase: "expand",
1557
+ outcome: "unpropagated",
1558
+ sourceWorker: worker.id,
1559
+ bytes: 0,
1560
+ reason
1561
+ }, true);
1562
+ const selected = resolveJsonPointer(settled.out, route.pointer);
1563
+ if (!selected.found) {
1564
+ await refuse(`pointer ${JSON.stringify(route.pointer)} does not resolve in the source result: ${selected.reason}; no item ran`);
1565
+ continue;
1566
+ }
1567
+ const items = selected.value;
1568
+ if (!Array.isArray(items)) {
1569
+ await refuse(`pointer ${JSON.stringify(route.pointer)} resolves to ${items === null ? "null" : typeof items}, not an array; no item ran`);
1570
+ continue;
1571
+ }
1572
+ if (items.length > route.maxItems) {
1573
+ await refuse(`max-items-exceeded: the list holds ${items.length} items and this map admits at most ${route.maxItems}; no item ran`);
1574
+ continue;
1575
+ }
1576
+ const slots = workerSlotBound();
1577
+ if (slots !== void 0 && route.concurrency > slots) {
1578
+ await refuse(`concurrency-unsatisfiable: concurrency ${route.concurrency} exceeds this run's ${slots} worker slots, so the cap could never be honored; no item ran`);
1579
+ continue;
1580
+ }
1581
+ await publishMap({
1582
+ edge: route.edge,
1583
+ phase: "expand",
1584
+ outcome: items.length === 0 ? "empty" : "delivered",
1585
+ sourceWorker: worker.id,
1586
+ bytes: textBytes(items),
1587
+ items: items.length,
1588
+ ...items.length === 0 ? { reason: "the list is empty; the join runs with no results" } : {}
1589
+ });
1590
+ await pumpMap({
1591
+ route,
1592
+ sourceWorker: worker.id,
1593
+ items: detachedFrozen(items),
1594
+ settlements: [],
1595
+ next: 0,
1596
+ inFlight: 0,
1597
+ stopped: false,
1598
+ finished: false
1599
+ });
1600
+ }
1601
+ };
1602
+ const runMapStep = async (step, worker) => {
1603
+ try {
1604
+ await step();
1605
+ } catch (error) {
1606
+ console.error("Runtime map step failed", {
1607
+ managerId: opts.scope.view.root,
1608
+ worker: worker.id,
1609
+ error: errMessage(error)
1610
+ });
1611
+ }
1612
+ };
1346
1613
  let flushing = 0;
1347
1614
  const flushPendingSettlement = async () => {
1348
1615
  flushing += 1;
@@ -1355,7 +1622,8 @@ function createCoordinationToolsForManager(opts, lifetime) {
1355
1622
  const flushPendingSettlementOnce = async () => {
1356
1623
  const pending = pendingSettlement;
1357
1624
  if (!pending) return false;
1358
- await bus.publish(pending.event);
1625
+ if (mapMembers.get(pending.worker.id)?.role === "item") await bus.publish(pending.event, { queue: false });
1626
+ else await bus.publish(pending.event);
1359
1627
  if (pending.analystRun) {
1360
1628
  analystRuns.delete(pending.worker.id);
1361
1629
  flushedAnalystRuns.add(pending.worker.id);
@@ -1370,6 +1638,8 @@ function createCoordinationToolsForManager(opts, lifetime) {
1370
1638
  }
1371
1639
  commitSettled(pending.worker);
1372
1640
  pendingSettlement = void 0;
1641
+ const advance = pending.analyze && !finishingAnalysis;
1642
+ await runMapStep(() => settleMapMember(pending.settled, pending.worker, advance), pending.worker);
1373
1643
  if (pending.analyze && !finishingAnalysis && analysisRoutes.length) {
1374
1644
  const sourceNames = workerRouteNames(pending.worker.id);
1375
1645
  const applicable = analysisRoutes.filter((route) => route.at !== "manager-end" && (route.statuses ?? ["done"]).includes(pending.worker.status) && (route.over === void 0 || route.over.some((name) => sourceNames.has(name))));
@@ -1404,6 +1674,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
1404
1674
  }
1405
1675
  for (const route of agentRoutes) await spawnAnalystRun(route, pending.worker);
1406
1676
  }
1677
+ if (advance) await runMapStep(() => expandMaps(pending.settled, pending.worker), pending.worker);
1407
1678
  return true;
1408
1679
  };
1409
1680
  const drainSettlement = async (source = "next") => {
@@ -1638,6 +1909,10 @@ function createCoordinationToolsForManager(opts, lifetime) {
1638
1909
  type: "lead-message",
1639
1910
  ...ev.message
1640
1911
  };
1912
+ if (ev.type === "map") return {
1913
+ type: "map",
1914
+ ...ev.map
1915
+ };
1641
1916
  return {
1642
1917
  type: ev.type,
1643
1918
  ...ev.down
@@ -1945,7 +2220,8 @@ function createCoordinationToolsForManager(opts, lifetime) {
1945
2220
  queued: bus.queued([
1946
2221
  "settled",
1947
2222
  "finding",
1948
- "lead-message"
2223
+ "lead-message",
2224
+ "map"
1949
2225
  ])
1950
2226
  };
1951
2227
  };
@@ -2214,7 +2490,8 @@ function createCoordinationToolsForManager(opts, lifetime) {
2214
2490
  continuity: continuity.continuity,
2215
2491
  ...continuity.continuity === "resume" ? { resume: continuity.resume } : {},
2216
2492
  ...successorOf !== void 0 ? { successorOf } : {},
2217
- ...peerMailUrl !== void 0 ? { peerMailUrl } : {}
2493
+ ...peerMailUrl !== void 0 ? { peerMailUrl } : {},
2494
+ ...input.map !== void 0 ? { map: input.map } : {}
2218
2495
  });
2219
2496
  const res = opts.scope.spawn(() => opts.makeWorkerAgent(profile, context), task, {
2220
2497
  budget,
@@ -2290,7 +2567,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
2290
2567
  task: { description: "The task the worker should perform." },
2291
2568
  label: {
2292
2569
  type: "string",
2293
- description: "Optional trace label."
2570
+ description: "Optional trace label; defaults to the profile name."
2294
2571
  },
2295
2572
  key: {
2296
2573
  type: "string",
@@ -2389,7 +2666,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
2389
2666
  successorOf,
2390
2667
  preflightProfile: () => opts.resolveSpawnProfile ? detachedFrozen(opts.resolveSpawnProfile(profile)) : profile,
2391
2668
  resourcesFromPath: resourcePaths.resolved,
2392
- defaultLabel: "worker"
2669
+ defaultLabel: typeof profile.name === "string" && profile.name.length > 0 ? profile.name : "worker"
2393
2670
  });
2394
2671
  }
2395
2672
  },
@@ -3411,11 +3688,15 @@ function createCoordinationToolsForManager(opts, lifetime) {
3411
3688
  type: "settled",
3412
3689
  worker: node.id
3413
3690
  }))],
3414
- unacknowledged: deliveries.filter((delivery) => !delivery.acknowledged).map((delivery) => ({
3691
+ unacknowledged: deliveries.filter((delivery) => !delivery.acknowledged && delivery.attempt !== driverAttempt).map((delivery) => ({
3415
3692
  seq: delivery.record.seq,
3416
3693
  type: delivery.record.event.type,
3417
3694
  ...eventWorker(delivery.record.event) === void 0 ? {} : { worker: eventWorker(delivery.record.event) },
3418
- ...delivery.attempt === void 0 ? {} : { attempt: delivery.attempt }
3695
+ ...delivery.attempt === void 0 ? {} : { attempt: delivery.attempt },
3696
+ event: {
3697
+ ...projectEvent(delivery.record.event),
3698
+ eventSeq: delivery.record.seq
3699
+ }
3419
3700
  })),
3420
3701
  ...lastRejection === void 0 ? {} : { lastRejection }
3421
3702
  });
@@ -3482,6 +3763,36 @@ function nextUnkeyedAssignmentOrdinal(scope) {
3482
3763
  if (!Number.isSafeInteger(next)) throw new Error("coordination: durable assignment ordinal space is exhausted");
3483
3764
  return next;
3484
3765
  }
3766
+ /** Resolve an RFC 6901 JSON pointer (`''` is the whole document). */
3767
+ function resolveJsonPointer(document, pointer) {
3768
+ if (pointer === "") return {
3769
+ found: true,
3770
+ value: document
3771
+ };
3772
+ if (!pointer.startsWith("/")) return {
3773
+ found: false,
3774
+ reason: "a JSON pointer is empty or starts with \"/\""
3775
+ };
3776
+ let value = document;
3777
+ for (const raw of pointer.slice(1).split("/")) {
3778
+ const token = raw.replaceAll("~1", "/").replaceAll("~0", "~");
3779
+ if (Array.isArray(value)) {
3780
+ if (!/^(0|[1-9]\d*)$/.test(token) || Number(token) >= value.length) return {
3781
+ found: false,
3782
+ reason: `no index ${JSON.stringify(token)} in an array of ${value.length}`
3783
+ };
3784
+ value = value[Number(token)];
3785
+ } else if (typeof value === "object" && value !== null && Object.hasOwn(value, token)) value = value[token];
3786
+ else return {
3787
+ found: false,
3788
+ reason: `no member ${JSON.stringify(token)}`
3789
+ };
3790
+ }
3791
+ return {
3792
+ found: true,
3793
+ value
3794
+ };
3795
+ }
3485
3796
  /** Stringify a findings payload for a routed delivery; never throws (a cyclic payload degrades to
3486
3797
  * its String form rather than killing the settle path). */
3487
3798
  function safeJsonText(value) {
@@ -4715,6 +5026,7 @@ function driverAgent(opts) {
4715
5026
  ...opts.deliverable ? { deliverable: opts.deliverable } : {},
4716
5027
  ...opts.analysts ? { analysts: opts.analysts } : {},
4717
5028
  ...opts.analyzeOnSettle ? { analyzeOnSettle: opts.analyzeOnSettle } : {},
5029
+ ...opts.mapOnSettle ? { mapOnSettle: opts.mapOnSettle } : {},
4718
5030
  ...opts.sourceEvidenceRefs ? { sourceEvidenceRefs: opts.sourceEvidenceRefs } : {},
4719
5031
  ...opts.peerAudit ? { peerAudit: opts.peerAudit } : {},
4720
5032
  ...opts.watchWorkers ? { watchWorkers: opts.watchWorkers } : {},
@@ -5118,4 +5430,4 @@ function safeJson(v) {
5118
5430
  //#endregion
5119
5431
  export { ANALYST_DEFINITION_BOUNDS as A, createEventBus as B, createFileRunContext as C, foldCoordinationRecords as D, FileCoordinationLog as E, createCoordinationToolsForManager as F, watchTrace as H, downMessageRefusalReasons as I, normalizeAnalyzeOnSettle as L, canonicalFindingEvent as M, coordinationVerbNames as N, applyRunCancellation as O, createCoordinationTools as P, parseAuthoredAnalystDefinition as R, renderAnytimeTable as S, withRunContext as T, defaultToolDetectors as V, sampleFromSettled as _, DEFAULT_DEADLINE_WARNING_MS as a, bestSoFar as b, refreshedWake as c, allWorkersStalled as d, anyOf as f, progressStop as g, plateau as h, finalizeBestDelivered as i, analystToolGroupNames as j, watchRunCancellation as k, resolveWakePolicy as l, noProgressFor as m, createSteerAcknowledger as n, composeWakeInput as o, createProgressTracker as p, driverAgent as r, deadlineWarningAt as s, createCancelAcknowledger as t, allOf as u, anytimeReport as v, createInMemoryRunContext as w, plateauLength as x, areaUnderCurve as y, questionEscalationTargets as z };
5120
5432
 
5121
- //# sourceMappingURL=coordination-driver-CwisRZNE.js.map
5433
+ //# sourceMappingURL=coordination-driver-B7Z9jgFr.js.map