@tangle-network/agent-runtime 2.3.9 → 2.3.11

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 (93) hide show
  1. package/dist/{activation-Cks1h3Nw.d.ts → activation-B8dLwJj6.d.ts} +2 -2
  2. package/dist/{activation-FJt_hJl4.js → activation-BzNeFJDB.js} +4 -4
  3. package/dist/{activation-FJt_hJl4.js.map → activation-BzNeFJDB.js.map} +1 -1
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +3 -3
  6. package/dist/{bundle-PDYNXIEf.js → bundle-DhV73H6U.js} +2 -2
  7. package/dist/{bundle-PDYNXIEf.js.map → bundle-DhV73H6U.js.map} +1 -1
  8. package/dist/candidate-execution/index.js +4 -4
  9. package/dist/{coordination-manager-Cic5Tn_p.js → coordination-manager-BluavEgY.js} +42 -152
  10. package/dist/coordination-manager-BluavEgY.js.map +1 -0
  11. package/dist/{coordination-map-routing-CUvwHAtv.js → coordination-map-routing-BllzcZov.js} +5 -2
  12. package/dist/coordination-map-routing-BllzcZov.js.map +1 -0
  13. package/dist/{delegate-BNT22Zxt.js → delegate-CYWL0MrO.js} +2 -2
  14. package/dist/{delegate-BNT22Zxt.js.map → delegate-CYWL0MrO.js.map} +1 -1
  15. package/dist/durable-file-DstVeHcj.js.map +1 -1
  16. package/dist/durable.d.ts +1 -1
  17. package/dist/durable.js +42 -202
  18. package/dist/durable.js.map +1 -1
  19. package/dist/{graph-BWHLetIG.js → graph-ByNMeS0j.js} +6 -11
  20. package/dist/{graph-BWHLetIG.js.map → graph-ByNMeS0j.js.map} +1 -1
  21. package/dist/{graph-registry-72DlMnUl.js → graph-registry-D6y6zffC.js} +2 -2
  22. package/dist/{graph-registry-72DlMnUl.js.map → graph-registry-D6y6zffC.js.map} +1 -1
  23. package/dist/{graph-registry-CAX15LO6.js → graph-registry-rV9mwxQO.js} +1 -1
  24. package/dist/{improve-WzDZI5JJ.js → improve-D9A79N5a.js} +7 -7
  25. package/dist/{improve-WzDZI5JJ.js.map → improve-D9A79N5a.js.map} +1 -1
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.js +10 -11
  28. package/dist/index.js.map +1 -1
  29. package/dist/intelligence.d.ts +2 -2
  30. package/dist/intelligence.js +7 -6
  31. package/dist/intelligence.js.map +1 -1
  32. package/dist/kernel.d.ts +1 -1
  33. package/dist/kernel.js +12 -12
  34. package/dist/{loop-runner-Bkvx4Saw.d.ts → loop-runner-D9fuOb69.d.ts} +2 -2
  35. package/dist/{loop-runner-uri_jDFi.js → loop-runner-DiMfhI_z.js} +2 -2
  36. package/dist/{loop-runner-uri_jDFi.js.map → loop-runner-DiMfhI_z.js.map} +1 -1
  37. package/dist/loop-runner-bin.d.ts +1 -1
  38. package/dist/loop-runner-bin.js +1 -1
  39. package/dist/mcp/bin.js +3 -3
  40. package/dist/mcp/index.d.ts +1 -1
  41. package/dist/mcp/index.js +6 -5
  42. package/dist/mcp/index.js.map +1 -1
  43. package/dist/{prepare-Bv6X2Wnx.js → prepare-DrHOZFJy.js} +3 -4
  44. package/dist/{prepare-Bv6X2Wnx.js.map → prepare-DrHOZFJy.js.map} +1 -1
  45. package/dist/{profile-Dir2A1_2.js → profile-BzzmKuIX.js} +3 -2
  46. package/dist/{profile-Dir2A1_2.js.map → profile-BzzmKuIX.js.map} +1 -1
  47. package/dist/profiles.d.ts +1 -1
  48. package/dist/{provision-supervisor-3UqSabgq.js → provision-supervisor-DP5U58V4.js} +13 -5
  49. package/dist/provision-supervisor-DP5U58V4.js.map +1 -0
  50. package/dist/{run-cancellation-CzQZUlHr.js → run-cancellation-BxoFCpJ_.js} +208 -5
  51. package/dist/run-cancellation-BxoFCpJ_.js.map +1 -0
  52. package/dist/{runtime-BzRpHBnT.js → runtime-DS5AgACg.js} +15 -16
  53. package/dist/{runtime-BzRpHBnT.js.map → runtime-DS5AgACg.js.map} +1 -1
  54. package/dist/sandbox-profile-compat-DxegoIK5.js +65 -0
  55. package/dist/sandbox-profile-compat-DxegoIK5.js.map +1 -0
  56. package/dist/scope-DRaBilEX.js +16734 -0
  57. package/dist/scope-DRaBilEX.js.map +1 -0
  58. package/dist/{search-executor-xvPTNWcN.js → search-executor-DLo_9jUv.js} +4 -5
  59. package/dist/{search-executor-xvPTNWcN.js.map → search-executor-DLo_9jUv.js.map} +1 -1
  60. package/dist/{server-BiC_Js38.js → server-DfHV4ajw.js} +4 -4
  61. package/dist/{server-BiC_Js38.js.map → server-DfHV4ajw.js.map} +1 -1
  62. package/dist/{structural-rollout-CGBBxSAG.js → structural-rollout-BIjjZ_XX.js} +4 -5
  63. package/dist/{structural-rollout-CGBBxSAG.js.map → structural-rollout-BIjjZ_XX.js.map} +1 -1
  64. package/dist/{supervise-DDbwLfA2.js → supervise-6BCQ73Xa.js} +14 -106
  65. package/dist/supervise-6BCQ73Xa.js.map +1 -0
  66. package/dist/{supervision-discovery-DmDWHwLu.js → supervision-discovery-Da5zebY2.js} +130 -5
  67. package/dist/supervision-discovery-Da5zebY2.js.map +1 -0
  68. package/dist/{supervisor-Bs9ie39Q.js → supervisor-3JHXy3tz.js} +7336 -19654
  69. package/dist/supervisor-3JHXy3tz.js.map +1 -0
  70. package/dist/testing.d.ts +1 -1
  71. package/dist/testing.js +13 -13
  72. package/dist/{top-web-CUDlOKu0.js → top-web-DK6lTMHG.js} +89 -64
  73. package/dist/top-web-DK6lTMHG.js.map +1 -0
  74. package/dist/tui/bin.js +3 -3
  75. package/dist/tui/index.d.ts +14 -8
  76. package/dist/tui/index.js +2 -2
  77. package/dist/{types-DzS0kBeK.d.ts → types-S3RbyJ4x.d.ts} +51 -65
  78. package/dist/{sandbox-profile-compat-DRiz9kME.js → workspace-streams-Dep2L6XD.js} +617 -57
  79. package/dist/workspace-streams-Dep2L6XD.js.map +1 -0
  80. package/package.json +2 -2
  81. package/dist/coordination-manager-Cic5Tn_p.js.map +0 -1
  82. package/dist/coordination-map-routing-CUvwHAtv.js.map +0 -1
  83. package/dist/provision-supervisor-3UqSabgq.js.map +0 -1
  84. package/dist/root-stream-Bsh5WFcg.js +0 -4252
  85. package/dist/root-stream-Bsh5WFcg.js.map +0 -1
  86. package/dist/run-cancellation-CzQZUlHr.js.map +0 -1
  87. package/dist/sandbox-profile-compat-DRiz9kME.js.map +0 -1
  88. package/dist/supervise-DDbwLfA2.js.map +0 -1
  89. package/dist/supervision-discovery-DmDWHwLu.js.map +0 -1
  90. package/dist/supervisor-Bs9ie39Q.js.map +0 -1
  91. package/dist/top-web-CUDlOKu0.js.map +0 -1
  92. package/dist/util-BX20UJ9X.js +0 -624
  93. package/dist/util-BX20UJ9X.js.map +0 -1
@@ -1,125 +1,14 @@
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-Bs9ie39Q.js";
2
- import { C as FileSpawnJournal, E as FileResultBlobStore, S as writeWorkerSteerAcknowledgement, T as spawnJournalRecordEvents, V as settlementFailureCause, b as writeWorkerCancellation, c as claimWorkerSteerDelivery, d as readWorkerCancelRequests, f as readWorkerCancellation, m as readWorkerSteerRequests, p as readWorkerSteerAcknowledgement, ut as contentAddress, wt as assertValidBudget } from "./root-stream-Bsh5WFcg.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 writeRunCancellation, i as readRunCancellation, r as readRunCancelRequest, t as applyRunCancellation } from "./run-cancellation-CzQZUlHr.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";
1
+ import { C as writeWorkerSteerAcknowledgement, Ct as resolveSpawnResourcePaths, L as FileSpawnJournal, O as parseWorkerToolTraceArtifact, Xr as settlementFailureCause, Y as runtimeGraphMetadataKey, f as readWorkerCancelRequests, h as readWorkerSteerRequests, ir as isTerminalNodeStatus, k as workerTraceAnalysisStore, l as claimWorkerSteerDelivery, m as readWorkerSteerAcknowledgement, ot as meterRuntimeOwnedAccounting, p as readWorkerCancellation, pi as contentAddress, qt as FileResultBlobStore, rr as isLiveNodeStatus, wi as assertValidBudget, x as writeWorkerCancellation, z as spawnJournalRecordEvents } from "./scope-DRaBilEX.js";
2
+ import { b as resolveRedactor, m as errMessage, u as detachedFrozen } from "./jsonl-file-BBP9Dz9w.js";
3
+ import { Ct as checkVerdictOf, Tt as failedItems, Y as INBOX_RECEIPT_KEY, _ as withDriverExecutor, b as createExecutorRegistry, ht as CheckUnavailableError, nt as createPeerMailbox, v as InMemoryResultBlobStore, y as InMemorySpawnJournal } from "./supervisor-3JHXy3tz.js";
4
+ import { c as writeRunCancellation, i as readRunCancellation, r as readRunCancelRequest, t as applyRunCancellation, v as FileCoordinationLog } from "./run-cancellation-BxoFCpJ_.js";
5
+ import { a as admitRuntimeSpawn, i as workerSettlement, n as resolveJsonPointer, o as safeJsonText, r as textBytes, t as createMapRouting } from "./coordination-map-routing-BllzcZov.js";
7
6
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest } from "@tangle-network/agent-interface";
8
7
  import { argHash, errorStreakDetector, observeAll, repeatedActionDetector } from "@tangle-network/agent-eval";
9
8
  import { registry } from "zod";
10
9
  import { randomUUID } from "node:crypto";
11
10
  import { readFileSync } from "node:fs";
12
11
  import { join } from "node:path";
13
- // src/runtime/supervise/coordination-log.ts
14
- /**
15
- * Durable side-log for coordination evidence the spawn journal does not own: questions, analyst
16
- * findings, answer decisions, authorized continuation receipts, delivery-attempt markers, and
17
- * delivery outcomes. A durable run
18
- * (`supervise({ runDir })`) appends them as they publish and loads them on resume, so a restarted
19
- * coordinator retains the exact evidence produced by prior processes.
20
- *
21
- * Answer down-events also fold status on load: a question answered before the crash reloads as
22
- * `answered`, not as a re-blocking `open`. Settled events are skipped (the spawn journal is their
23
- * ledger). A receipt followed by an attempt but no outcome proves the process died in the delivery
24
- * window; that outcome remains unknown and no prior instruction is auto-delivered.
25
- *
26
- * JSONL, one fsynced record per event, keyed by `runId` — several runs may share one log file
27
- * exactly as they share one spawn-journal file.
28
- *
29
- * @experimental
30
- */
31
- /** Persist prior context plus exact continuation authorization, attempt, and result evidence.
32
- * Settlements have their own journal. */
33
- function persisted(event) {
34
- return event.type !== "settled";
35
- }
36
- /** FS-backed `CoordinationLog`: append-only JSONL, fsynced per record. */
37
- var FileCoordinationLog = class {
38
- path;
39
- writeContext = captureRunWriteContext();
40
- appendTail = Promise.resolve();
41
- constructor(path) {
42
- this.path = path;
43
- }
44
- async append(runId, record, ownerId) {
45
- if (!persisted(record.event)) return;
46
- const append = this.appendTail.then(() => this.writeContext(() => this.appendRecord(runId, record, ownerId)));
47
- this.appendTail = append.catch(() => void 0);
48
- return append;
49
- }
50
- async appendRecord(runId, busRecord, ownerId) {
51
- const fs = await import("node:fs/promises");
52
- const { dirname } = await import("node:path");
53
- await fs.mkdir(dirname(this.path), { recursive: true });
54
- const record = {
55
- runId,
56
- ...ownerId !== void 0 ? { ownerId } : {},
57
- ...busRecord
58
- };
59
- await appendCommittedJsonLine(this.path, record);
60
- }
61
- async load(runId, ownerId) {
62
- return foldCoordinationRecords(readCommittedJsonLines(this.path, { allowMissing: true }), runId, ownerId);
63
- }
64
- };
65
- /** @internal Shared replay semantics for file and SQL coordination evidence. */
66
- async function foldCoordinationRecords(source, runId, ownerId) {
67
- const byId = /* @__PURE__ */ new Map();
68
- const findings = [];
69
- const escalations = [];
70
- const analystDefinitions = [];
71
- const continuations = [];
72
- const deliveryEvidence = [];
73
- const mail = [];
74
- const records = [];
75
- let legacySeq = 0;
76
- for await (const stored of source) {
77
- if (stored.runId !== runId) continue;
78
- if (ownerId !== void 0 && stored.ownerId !== ownerId) continue;
79
- const record = "seq" in stored ? {
80
- seq: stored.seq,
81
- at: stored.at,
82
- priority: stored.priority,
83
- event: stored.event
84
- } : {
85
- seq: legacySeq++,
86
- at: Date.parse(stored.at),
87
- priority: 0,
88
- event: stored.event
89
- };
90
- records.push(record);
91
- const ev = record.event;
92
- if (ev.type === "delivery-attempt" || ev.type === "steer" || ev.type === "answer") deliveryEvidence.push(ev);
93
- if (ev.type === "question") byId.set(ev.question.id, ev.question);
94
- else if (ev.type === "finding") findings.push(ev.finding);
95
- else if (ev.type === "answer") {
96
- const prior = byId.get(ev.questionId);
97
- if (prior && ev.down.delivered) byId.set(ev.questionId, {
98
- ...prior,
99
- status: "answered",
100
- decision: {
101
- kind: "answer",
102
- answer: ev.down.instruction,
103
- by: "prior-run"
104
- }
105
- });
106
- } else if (ev.type === "instruction") continuations.push(ev.instruction);
107
- else if (ev.type === "mail") mail.push(ev.mail);
108
- else if (ev.type === "escalation") escalations.push(ev.escalation);
109
- else if (ev.type === "analyst-defined") analystDefinitions.push(ev.analyst);
110
- }
111
- return {
112
- ...ownerId !== void 0 ? { ownerId } : {},
113
- questions: [...byId.values()],
114
- findings,
115
- escalations,
116
- analystDefinitions,
117
- continuations,
118
- deliveryEvidence,
119
- mail,
120
- records
121
- };
122
- }
123
12
  // src/runtime/supervise/run-context.ts
124
13
  /**
125
14
  *
@@ -3120,21 +3009,41 @@ async function end(state, event, reason) {
3120
3009
  await publish(state, event);
3121
3010
  state.stop(reason);
3122
3011
  }
3123
- async function spawnNode(state, marker, profile, task, key, continuity) {
3124
- const { opts } = state;
3125
- const spawned = await admitRuntimeSpawn(state.admitSpawn, {
3012
+ async function spawnNode(state, marker, profile, task, key, continuity, traversal, source) {
3013
+ const spawned = "error" in continuity ? { refused: `${continuity.error}: ${continuity.hint}` } : await admitRuntimeSpawn(state.admitSpawn, {
3126
3014
  profile,
3127
3015
  args: { label: marker.node },
3128
3016
  task,
3129
3017
  key,
3130
3018
  continuity,
3131
3019
  successorOf: state.settledWorker.get(marker.node),
3132
- preflightProfile: () => opts.resolveSpawnProfile ? detachedFrozen(opts.resolveSpawnProfile(profile)) : profile,
3020
+ preflightProfile: () => state.opts.resolveSpawnProfile ? detachedFrozen(state.opts.resolveSpawnProfile(profile)) : profile,
3133
3021
  resourcesFromPath: [],
3134
3022
  defaultLabel: marker.node,
3135
3023
  route: Object.freeze({ ...marker })
3136
3024
  });
3025
+ if ("inDoubt" in spawned) {
3026
+ await endInDoubt(state, marker.node, source);
3027
+ return spawned;
3028
+ }
3137
3029
  if ("workerId" in spawned && !spawned.committed) setLive(state, marker.node, spawned.workerId);
3030
+ await publish(state, {
3031
+ kind: "traversal",
3032
+ edge: marker.edge,
3033
+ to: marker.node,
3034
+ ...traversal,
3035
+ outcome: "workerId" in spawned ? "delivered" : "unpropagated",
3036
+ bytes: "workerId" in spawned ? textBytes(task) : 0,
3037
+ ..."workerId" in spawned ? { workerId: spawned.workerId } : { reason: spawned.refused }
3038
+ });
3039
+ if ("refused" in spawned) await end(state, {
3040
+ kind: "stopped",
3041
+ edge: marker.edge,
3042
+ at: marker.node,
3043
+ workerId: source,
3044
+ reason: spawned.refused,
3045
+ ..."code" in spawned ? { code: spawned.code } : {}
3046
+ }, `flow spawn refused: ${spawned.refused}`);
3138
3047
  return spawned;
3139
3048
  }
3140
3049
  async function endInDoubt(state, node, source) {
@@ -3146,7 +3055,6 @@ async function endInDoubt(state, node, source) {
3146
3055
  reason: `in-doubt:${node}`
3147
3056
  }, `flow in-doubt:${node}`);
3148
3057
  }
3149
- const refusal = (spawned) => "refused" in spawned ? spawned.refused : "in-doubt";
3150
3058
  /** Settle the committed steps a spawn loop collected, stopping once the flow has ended. */
3151
3059
  async function settleCommittedSteps(state, committed) {
3152
3060
  for (const step of committed) {
@@ -3161,25 +3069,15 @@ function start(state) {
3161
3069
  const spawned = await spawnNode(state, {
3162
3070
  edge: entry.edge,
3163
3071
  node: entry.node
3164
- }, entry.profile, entry.task, entry.key, { continuity: "fresh" });
3165
- if ("inDoubt" in spawned) {
3166
- await endInDoubt(state, entry.node, "entry");
3167
- return;
3168
- }
3072
+ }, entry.profile, entry.task, entry.key, { continuity: "fresh" }, {
3073
+ from: "entry",
3074
+ continuity: "fresh"
3075
+ }, "entry");
3076
+ if (state.ended) return;
3169
3077
  if ("workerId" in spawned && spawned.committed) committed.push({
3170
3078
  workerId: spawned.workerId,
3171
3079
  node: entry.node
3172
3080
  });
3173
- await publish(state, {
3174
- kind: "traversal",
3175
- edge: entry.edge,
3176
- from: "entry",
3177
- to: entry.node,
3178
- outcome: "workerId" in spawned ? "delivered" : "unpropagated",
3179
- continuity: "fresh",
3180
- bytes: "workerId" in spawned ? textBytes(entry.task) : 0,
3181
- ..."workerId" in spawned ? { workerId: spawned.workerId } : { reason: `entry spawn refused: ${refusal(spawned)}` }
3182
- });
3183
3081
  }
3184
3082
  await settleCommittedSteps(state, committed);
3185
3083
  })();
@@ -3294,26 +3192,18 @@ async function fireNodes(state, edge, { node, source, result }, targets, travers
3294
3192
  for (const target of targets) {
3295
3193
  const resolved = edge.continuity === "resume" ? state.resolveContinuity("resume", target.node, void 0) : { continuity: "fresh" };
3296
3194
  const continuity = "error" in resolved && resolved.error === "resume-no-prior" ? { continuity: "fresh" } : resolved;
3297
- const spawned = "error" in continuity ? { refused: `${continuity.error}: ${continuity.hint}` } : await spawnNode(state, {
3195
+ const spawned = await spawnNode(state, {
3298
3196
  edge: edge.edge,
3299
3197
  node: target.node
3300
- }, target.profile, task, fork ? `route:${edge.edge}#${traversal}:${target.node}` : `route:${edge.edge}#${traversal}`, continuity);
3301
- if ("inDoubt" in spawned) {
3302
- await endInDoubt(state, target.node, source);
3303
- return;
3304
- }
3198
+ }, target.profile, task, fork ? `route:${edge.edge}#${traversal}:${target.node}` : `route:${edge.edge}#${traversal}`, continuity, {
3199
+ ...row,
3200
+ continuity: "continuity" in continuity ? continuity.continuity : edge.continuity
3201
+ }, source);
3202
+ if (state.ended) return;
3305
3203
  if ("workerId" in spawned && spawned.committed) committed.push({
3306
3204
  workerId: spawned.workerId,
3307
3205
  node: target.node
3308
3206
  });
3309
- await publish(state, {
3310
- ...row,
3311
- to: target.node,
3312
- outcome: "workerId" in spawned ? "delivered" : "unpropagated",
3313
- continuity: "continuity" in continuity ? continuity.continuity : edge.continuity,
3314
- bytes: "workerId" in spawned ? textBytes(task) : 0,
3315
- ..."workerId" in spawned ? { workerId: spawned.workerId } : { reason: `route spawn refused: ${refusal(spawned)}` }
3316
- });
3317
3207
  }
3318
3208
  await settleCommittedSteps(state, committed);
3319
3209
  }
@@ -5229,6 +5119,6 @@ function createResumeReplay({ opts, bus, ledger, analysis, projectSettled }) {
5229
5119
  return readyInFlight;
5230
5120
  };
5231
5121
  }
5232
- 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 };
5122
+ export { downMessageRefusalReasons as a, createSteerAcknowledger as c, coordinationVerbNames as d, createFileRunContext as f, 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 };
5233
5123
 
5234
- //# sourceMappingURL=coordination-manager-Cic5Tn_p.js.map
5124
+ //# sourceMappingURL=coordination-manager-BluavEgY.js.map