@tangle-network/agent-runtime 0.322.1 → 0.323.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 (55) hide show
  1. package/dist/{activation-CZGz2kuu.d.ts → activation-D4hHi27J.d.ts} +2 -2
  2. package/dist/{activation-CBv_0LUh.js → activation-DpipXGti.js} +2 -2
  3. package/dist/{activation-CBv_0LUh.js.map → activation-DpipXGti.js.map} +1 -1
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-C2Zm5lU4.js → coordination-driver-COSL19sL.js} +31 -4
  7. package/dist/coordination-driver-COSL19sL.js.map +1 -0
  8. package/dist/{delegate-BV7AVmbB.js → delegate-silSKPSB.js} +2 -2
  9. package/dist/{delegate-BV7AVmbB.js.map → delegate-silSKPSB.js.map} +1 -1
  10. package/dist/durable.d.ts +1 -1
  11. package/dist/durable.js +2 -2
  12. package/dist/{graph-CH3YiPog.js → graph-DbQ-BXKr.js} +6 -4
  13. package/dist/graph-DbQ-BXKr.js.map +1 -0
  14. package/dist/{improvement-cycle-CD1h5GSM.js → improvement-cycle-BeN9wahG.js} +3 -3
  15. package/dist/{improvement-cycle-CD1h5GSM.js.map → improvement-cycle-BeN9wahG.js.map} +1 -1
  16. package/dist/{index-CGNQWpge.d.ts → index-7h7-L6Tk.d.ts} +37 -17
  17. package/dist/index.d.ts +4 -4
  18. package/dist/index.js +7 -7
  19. package/dist/intelligence.d.ts +2 -2
  20. package/dist/intelligence.js +22 -6
  21. package/dist/intelligence.js.map +1 -1
  22. package/dist/kernel.d.ts +2 -2
  23. package/dist/kernel.js +9 -9
  24. package/dist/{loop-runner-bin-C_jaLCUO.d.ts → loop-runner-bin-Bsux_MGx.d.ts} +2 -2
  25. package/dist/{loop-runner-bin-CFxE376A.js → loop-runner-bin-DkhIbFBp.js} +3 -3
  26. package/dist/{loop-runner-bin-CFxE376A.js.map → loop-runner-bin-DkhIbFBp.js.map} +1 -1
  27. package/dist/loop-runner-bin.d.ts +1 -1
  28. package/dist/loop-runner-bin.js +1 -1
  29. package/dist/mcp/bin.js +3 -3
  30. package/dist/mcp/index.d.ts +3 -3
  31. package/dist/mcp/index.js +4 -4
  32. package/dist/{openai-tools-D1PDoBOz.d.ts → openai-tools-e02ABKl0.d.ts} +2 -2
  33. package/dist/profiles.d.ts +1 -1
  34. package/dist/{provision-supervisor-ftJZhqBU.js → provision-supervisor-DdWu6mqu.js} +3 -3
  35. package/dist/{provision-supervisor-ftJZhqBU.js.map → provision-supervisor-DdWu6mqu.js.map} +1 -1
  36. package/dist/{runtime-EiTCboO2.js → runtime-DhPIc7XV.js} +8 -8
  37. package/dist/{runtime-EiTCboO2.js.map → runtime-DhPIc7XV.js.map} +1 -1
  38. package/dist/{search-executor-ECJ2TmC-.js → search-executor-BS-WJpti.js} +2 -2
  39. package/dist/{search-executor-ECJ2TmC-.js.map → search-executor-BS-WJpti.js.map} +1 -1
  40. package/dist/{server-C2k5wX4k.js → server-CEDOUOdz.js} +3 -3
  41. package/dist/{server-C2k5wX4k.js.map → server-CEDOUOdz.js.map} +1 -1
  42. package/dist/{supervise-BjrRk-AN.js → supervise-CwWI7kIk.js} +88 -15
  43. package/dist/supervise-CwWI7kIk.js.map +1 -0
  44. package/dist/{supervisor-BMMdI4T-.js → supervisor-CSKkm-e1.js} +53 -31
  45. package/dist/supervisor-CSKkm-e1.js.map +1 -0
  46. package/dist/testing.d.ts +1 -1
  47. package/dist/testing.js +12 -12
  48. package/dist/tui/index.d.ts +1 -1
  49. package/dist/tui/index.js +1 -1
  50. package/package.json +2 -2
  51. package/skills/profile-authoring/SKILL.md +3 -3
  52. package/dist/coordination-driver-C2Zm5lU4.js.map +0 -1
  53. package/dist/graph-CH3YiPog.js.map +0 -1
  54. package/dist/supervise-BjrRk-AN.js.map +0 -1
  55. package/dist/supervisor-BMMdI4T-.js.map +0 -1
@@ -1,10 +1,10 @@
1
- import { $i as runtimeOwnedExecutorProviderEvidence, A as scopeOwnerExecutorNodeContext, Ai as promptControlProfileMaterialization, An as resolveAgentEnvironmentProvider, Ar as persistHarnessTranscript, At as captureReusableExecutorConfig, B as consumeScopeRetainedOwnerResult, C as deriveNodeExecutionIdentity, Ct as createContinuationKeeper, D as recordScopeOwnerMaterialization, Di as defineProfileMaterializationContract, Dr as runAbortable, E as recordScopeOwnerDriverAttempt, Ei as controlProfileMaterialization, Er as linkAbort, F as seatExecutionProfile, Fi as renderUnsupported, Fn as retainedExecutorSeamKey, Ft as snapshotExecutorConfig, G as scopeRetainedOwnerContext, H as prepareScopeRetainedOwnerSeatSwitch, I as abandonScopeRetainedOwnerInvocation, J as scopeRetainedOwnerResourceReader, Ji as providerAttemptEvidence, Jn as isNoEntError, Jt as createActivityLog, K as scopeRetainedOwnerJournalRoot, L as beginScopeRetainedOwnerDrive, Li as unsupportedProfileDimensions, M as SeatChain, N as SeatChainExhaustedError, Nt as createExecutor, O as recordScopeOwnerPause, Oi as fullProfileMaterialization, P as authoredSeatStages, Pn as registerRetainedExecutorPreparation, Pr as contentAddress, Qi as runtimeOwnedExecutorMaterialization, Qr as createOtelExporter, R as bindScopeRetainedOwnerEnvironmentId, St as checkVerdictOf, T as meterRuntimeOwnedProviderAttempt, U as prepareScopeRetainedOwnerTask, V as noteScopeRetainedOwnerCoordination, Vi as attestRuntimeOwnedScopeOwner, Vt as WORKER_TRACE_PROPAGATION, W as reconcileScopeRetainedOwnerEnvironment, Wi as inheritRuntimeOwnedExecutorAttestation, X as scopeRetainedOwnerResult, Xi as runtimeOwnedDriveHarnessProviderEvidence, Xn as readCommittedJsonLines, Xt as createInbox, Y as scopeRetainedOwnerRestorePoint, Yi as recordRuntimeOwnedDriveHarnessProviderEvidence, Yn as prepareJsonlAppend, Z as scopeRetainedOwnerTurnEnded, Zi as runtimeOwnedExecutorExecutionBinding, _ as isDriverSpec, an as isLiveNodeStatus, b as assertRecursiveReservationPolicy, c as runTree, cn as bridgeModelRouteRefusal, cr as meterUsageEvent, dr as spendFromUsageTotals, ea as runtimeOwnedPendingExecutorMaterialization, ei as generateSpanId, f as runDriverWithRetry, fr as bridgeRuntimeAttachmentsKey, g as driverExecutorFactory, gt as CONTINUATIONS_DIR, h as driverChild, i as bestDelivered, ii as toOtelAttributes, it as providerVisibleProfile, ji as promptModelProfileMaterialization, jr as readHarnessTranscript, k as restoreScopeOwnerAcceptedExecution, ki as profileMaterializationAxes$1, kt as bindReusableExecutorExecutionId, lr as newUsageTotals, mr as errMessage, mt as gateOnDeliverable, n as createRootHandle, nt as coordinationMcpAlias, or as assertValidBudget, p as summarizeDriverAttempts, pr as bridgeStopSignalKey, q as scopeRetainedOwnerPriorSpend, r as createSupervisor, rr as executorFailure, rt as coordinationProfileToolPrefix, s as runFinalizer, sa as detachedSnapshot, sn as bridgeAdmissionRefusal, ta as runtimeOwnedScopeOwnerRuntime, tr as parseWorkerToolTraceArtifact, u as HarnessTurnFailedError, vt as CheckUnavailableError, w as meterRuntimeOwnedAccounting, wi as assertProfileMaterialization, wn as routerBrain, wr as RunCancellationReason, x as beginScopeOwnerAttempt, xt as bestComposite, yt as admitContinuationPolicy, z as bindScopeRetainedOwnerProvider, zi as worktreeCliProfileMaterialization, zt as createRouterTranscript } from "./supervisor-BMMdI4T-.js";
1
+ import { $i as runtimeOwnedExecutorMaterialization, $t as PEER_MAIL_WIRE_KEY, A as scopeOwnerExecutorNodeContext, Ai as promptControlProfileMaterialization, An as resolveAgentEnvironmentProvider, Ar as persistHarnessTranscript, At as captureReusableExecutorConfig, B as consumeScopeRetainedOwnerResult, C as deriveNodeExecutionIdentity, Ct as createContinuationKeeper, D as recordScopeOwnerMaterialization, Di as defineProfileMaterializationContract, Dr as runAbortable, E as recordScopeOwnerDriverAttempt, Ei as controlProfileMaterialization, Er as linkAbort, F as seatExecutionProfile, Fi as renderUnsupported, Fn as retainedExecutorSeamKey, Ft as snapshotExecutorConfig, G as scopeRetainedOwnerContext, Gi as inheritRuntimeOwnedExecutorAttestation, H as prepareScopeRetainedOwnerSeatSwitch, Hi as authoredAgentIdentity, I as abandonScopeRetainedOwnerInvocation, J as scopeRetainedOwnerResourceReader, Jn as isNoEntError, Jt as createActivityLog, K as scopeRetainedOwnerJournalRoot, L as beginScopeRetainedOwnerDrive, Li as unsupportedProfileDimensions, M as SeatChain, N as SeatChainExhaustedError, Nt as createExecutor, O as recordScopeOwnerPause, Oi as fullProfileMaterialization, P as authoredSeatStages, Pn as registerRetainedExecutorPreparation, Pr as contentAddress, Qi as runtimeOwnedExecutorExecutionBinding, Qr as createOtelExporter, R as bindScopeRetainedOwnerEnvironmentId, St as checkVerdictOf, T as meterRuntimeOwnedProviderAttempt, U as prepareScopeRetainedOwnerTask, V as noteScopeRetainedOwnerCoordination, Vi as attestRuntimeOwnedScopeOwner, Vt as WORKER_TRACE_PROPAGATION, W as reconcileScopeRetainedOwnerEnvironment, X as scopeRetainedOwnerResult, Xi as recordRuntimeOwnedDriveHarnessProviderEvidence, Xn as readCommittedJsonLines, Xt as createInbox, Y as scopeRetainedOwnerRestorePoint, Yi as providerAttemptEvidence, Yn as prepareJsonlAppend, Z as scopeRetainedOwnerTurnEnded, Zi as runtimeOwnedDriveHarnessProviderEvidence, _ as isDriverSpec, an as isLiveNodeStatus, b as assertRecursiveReservationPolicy, c as runTree, ca as detachedSnapshot, cn as bridgeModelRouteRefusal, cr as meterUsageEvent, dr as spendFromUsageTotals, ea as runtimeOwnedExecutorProviderEvidence, ei as generateSpanId, f as runDriverWithRetry, fr as bridgeRuntimeAttachmentsKey, g as driverExecutorFactory, gt as CONTINUATIONS_DIR, h as driverChild, i as bestDelivered, ii as toOtelAttributes, it as providerVisibleProfile, ji as promptModelProfileMaterialization, jr as readHarnessTranscript, k as restoreScopeOwnerAcceptedExecution, ki as profileMaterializationAxes$1, kt as bindReusableExecutorExecutionId, lr as newUsageTotals, mr as errMessage, mt as gateOnDeliverable, n as createRootHandle, na as runtimeOwnedScopeOwnerRuntime, nn as isPeerMailEnvelope, nt as coordinationMcpAlias, or as assertValidBudget, p as summarizeDriverAttempts, pr as bridgeStopSignalKey, q as scopeRetainedOwnerPriorSpend, r as createSupervisor, rr as executorFailure, rt as coordinationProfileToolPrefix, s as runFinalizer, sn as bridgeAdmissionRefusal, ta as runtimeOwnedPendingExecutorMaterialization, tr as parseWorkerToolTraceArtifact, u as HarnessTurnFailedError, vt as CheckUnavailableError, w as meterRuntimeOwnedAccounting, wi as assertProfileMaterialization, wn as routerBrain, wr as RunCancellationReason, x as beginScopeOwnerAttempt, xt as bestComposite, yt as admitContinuationPolicy, z as bindScopeRetainedOwnerProvider, zi as worktreeCliProfileMaterialization, zt as createRouterTranscript } from "./supervisor-CSKkm-e1.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
3
3
  import { Dt as teardownSurfaces, Et as teardownExecutor, V as addSpend, Z as isAsyncIterable$1, ct as withTimeout, dt as addResourceSpend, lt as zeroSpend, mt as withBudgetResources, pt as resourceTelemetry, q as errorMessage, rt as sleep, st as unmeteredSpend, yt as DEFAULT_SUCCESSFUL_SHUTDOWN_MS } from "./workspace-streams-DFAhW7hF.js";
4
4
  import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-CNe257pB.js";
5
5
  import { n as assertNoSymlinkDescendant } from "./durable-file-DWQA4ooo.js";
6
6
  import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
7
- import { C as createFileRunContext, F as createCoordinationToolsForManager, N as coordinationVerbNames, O as applyRunCancellation, T as withRunContext, c as refreshedWake, g as progressStop, h as plateau, k as watchRunCancellation, l as resolveWakePolicy, n as createSteerAcknowledger, o as composeWakeInput, p as createProgressTracker, r as driverAgent, s as deadlineWarningAt, t as createCancelAcknowledger, w as createInMemoryRunContext } from "./coordination-driver-C2Zm5lU4.js";
7
+ import { C as createFileRunContext, F as createCoordinationToolsForManager, N as coordinationVerbNames, O as applyRunCancellation, T as withRunContext, c as refreshedWake, g as progressStop, h as plateau, k as watchRunCancellation, l as resolveWakePolicy, n as createSteerAcknowledger, o as composeWakeInput, p as createProgressTracker, r as driverAgent, s as deadlineWarningAt, t as createCancelAcknowledger, w as createInMemoryRunContext } from "./coordination-driver-COSL19sL.js";
8
8
  import { r as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-Dqer2M4_.js";
9
9
  import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-DSCWdbX2.js";
10
10
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
@@ -14,7 +14,7 @@ import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
14
14
  import { dirname, resolve } from "node:path";
15
15
  import { mkdir } from "node:fs/promises";
16
16
  import { isMaterializerHarness } from "@tangle-network/agent-profile-materialize";
17
- import { ATTR } from "@tangle-network/agent-trace-contract";
17
+ import { ATTR, agentIdentityAttributes } from "@tangle-network/agent-trace-contract";
18
18
  import { createServer } from "node:http";
19
19
  import { withProfileKb } from "@tangle-network/agent-interface/profile-kb";
20
20
  //#region src/mcp/tools/coordination-request-context.ts
@@ -648,6 +648,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
648
648
  ...opts.analysts ? { analysts: opts.analysts } : {},
649
649
  ...opts.analyzeOnSettle ? { analyzeOnSettle: opts.analyzeOnSettle } : {},
650
650
  ...opts.sourceEvidenceRefs ? { sourceEvidenceRefs: opts.sourceEvidenceRefs } : {},
651
+ ...opts.peerAudit ? { peerAudit: opts.peerAudit } : {},
651
652
  ...opts.watchWorkers ? { watchWorkers: opts.watchWorkers } : {},
652
653
  ...opts.stallAfterMs !== void 0 ? { stallAfterMs: opts.stallAfterMs } : {},
653
654
  ...opts.continuityByProfile ? { continuityByProfile: opts.continuityByProfile } : {},
@@ -967,6 +968,8 @@ function createSupervisorSpanRecorder(opts) {
967
968
  "tangle.sessionId": opts.runId,
968
969
  ...opts.attributes ?? {}
969
970
  };
971
+ const rootIdentity = agentIdentityAttributes(opts.agentIdentity);
972
+ const identityOf = /* @__PURE__ */ new Map([[opts.runId, rootIdentity]]);
970
973
  /** Node id → its open span. Seeded with the run id ⇒ the root span, because a depth-0 spawn's
971
974
  * `parentId` is the run id itself and every deeper spawn's is a real node id. */
972
975
  const open = /* @__PURE__ */ new Map();
@@ -1022,6 +1025,9 @@ function createSupervisorSpanRecorder(opts) {
1022
1025
  "tangle.supervise.node.kind": "agent",
1023
1026
  "tangle.supervise.tree.root": event.runId
1024
1027
  };
1028
+ const identity = agentIdentityAttributes(record(p.agent));
1029
+ identityOf.set(childId, identity);
1030
+ Object.assign(attrs, identity);
1025
1031
  if (event.parentId) attrs["tangle.supervise.node.parent_id"] = event.parentId;
1026
1032
  if (runtime) attrs["tangle.supervise.node.runtime"] = runtime;
1027
1033
  if (typeof p.depth === "number") attrs["tangle.supervise.node.depth"] = p.depth;
@@ -1084,6 +1090,7 @@ function createSupervisorSpanRecorder(opts) {
1084
1090
  const parentSpanId = parent.spanId;
1085
1091
  const attrs = {
1086
1092
  ...base,
1093
+ ...identityOf.get(parentId ?? opts.runId) ?? {},
1087
1094
  [ATTR.parentConfidence]: parent.confidence,
1088
1095
  [ATTR.spanKind]: "LLM",
1089
1096
  "inference.observation_kind": "LLM",
@@ -1145,6 +1152,7 @@ function createSupervisorSpanRecorder(opts) {
1145
1152
  open.clear();
1146
1153
  emit(span(rootSpanId, opts.parentSpanId, "supervisor.run", rootStartMs, endMs, {
1147
1154
  ...rootAttrs(base, opts.agentName ?? "supervisor", outcome),
1155
+ ...rootIdentity,
1148
1156
  ...opts.parentSpanId ? { [ATTR.parentConfidence]: "explicit" } : {}
1149
1157
  }, rootStatus(outcome), rootMessage(outcome)));
1150
1158
  } catch {}
@@ -1945,6 +1953,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1945
1953
  ...deps.analysts ? { analysts: deps.analysts } : {},
1946
1954
  ...deps.analyzeOnSettle ? { analyzeOnSettle: deps.analyzeOnSettle } : {},
1947
1955
  ...deps.sourceEvidenceRefs ? { sourceEvidenceRefs: deps.sourceEvidenceRefs } : {},
1956
+ ...deps.peerAudit ? { peerAudit: deps.peerAudit } : {},
1948
1957
  ...deps.escalateQuestion ? { escalateQuestion: deps.escalateQuestion } : {},
1949
1958
  ...deps.watchWorkers ? { watchWorkers: deps.watchWorkers } : {},
1950
1959
  ...deps.stallAfterMs !== void 0 ? { stallAfterMs: deps.stallAfterMs } : {},
@@ -2019,6 +2028,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2019
2028
  const context = nodeContextSeed ? supervisorNodeContext(nodeContextSeed, stableProfile, task, scope) : void 0;
2020
2029
  const priorCoordination = deps.loadPriorCoordination ? await deps.loadPriorCoordination() : deps.priorCoordination;
2021
2030
  const slot = createVerbSlot();
2031
+ const peerInbox = createInbox();
2022
2032
  const nodeTools = resolveTools && context ? await bindSupervisorTools(resolveTools, context, scope.signal, slot) : void 0;
2023
2033
  const nodeObserver = bindSupervisorNodeObserver(context, observeNodeEvent, deps.onEvent);
2024
2034
  const stopController = new AbortController();
@@ -2061,6 +2071,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2061
2071
  ...deps.analysts ? { analysts: deps.analysts } : {},
2062
2072
  ...deps.analyzeOnSettle ? { analyzeOnSettle: deps.analyzeOnSettle } : {},
2063
2073
  ...deps.sourceEvidenceRefs ? { sourceEvidenceRefs: deps.sourceEvidenceRefs } : {},
2074
+ ...deps.peerAudit ? { peerAudit: deps.peerAudit } : {},
2064
2075
  ...deps.escalateQuestion ? { escalateQuestion: deps.escalateQuestion } : {},
2065
2076
  ...deps.watchWorkers ? { watchWorkers: deps.watchWorkers } : {},
2066
2077
  ...deps.stallAfterMs !== void 0 ? { stallAfterMs: deps.stallAfterMs } : {},
@@ -2093,6 +2104,8 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2093
2104
  liveCoordinator = mcp;
2094
2105
  managerInbox = (message) => {
2095
2106
  if (deliver !== void 0 && harnessInvocationActive && (deliverReady === void 0 || deliverReady()) && deliver(message)) return true;
2107
+ const envelope = message !== null && typeof message === "object" ? message[PEER_MAIL_WIRE_KEY] : void 0;
2108
+ if (deps.peerMailUrl && isPeerMailEnvelope(envelope)) return peerInbox.deliver({ [PEER_MAIL_WIRE_KEY]: envelope });
2096
2109
  return controls.receiveLeadMessage(message);
2097
2110
  };
2098
2111
  const coordinationTools = slot.descriptors();
@@ -2284,6 +2297,9 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2284
2297
  state: controls.reentryState(),
2285
2298
  attempt
2286
2299
  });
2300
+ const peerMessages = peerInbox.drain();
2301
+ const peerText = peerMessages.length === 0 ? void 0 : peerInbox.fold(peerMessages);
2302
+ const withPeerMail = (input) => peerText === void 0 ? input : `${typeof input === "string" ? input : JSON.stringify(input) ?? String(input)}\n\n${peerText}`;
2287
2303
  harnessInvocationActive = true;
2288
2304
  let completed = false;
2289
2305
  try {
@@ -2293,10 +2309,10 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2293
2309
  ...registeredProfile === stableProfile ? {} : { registeredProfile },
2294
2310
  ...profilePrompt !== void 0 ? { systemPrompt: profilePrompt } : {},
2295
2311
  ...session === void 0 ? {} : { session },
2296
- task: compose === void 0 ? task : compose(UNPROVEN_CONTINUITY),
2312
+ task: withPeerMail(compose === void 0 ? task : compose(UNPROVEN_CONTINUITY)),
2297
2313
  ...compose === void 0 ? {} : { reentry: {
2298
2314
  reason: reentry,
2299
- compose,
2315
+ compose: (continuity) => withPeerMail(compose(continuity)),
2300
2316
  ...refresh === void 0 ? {} : { refresh },
2301
2317
  onContinuity: (continuity) => {
2302
2318
  if (continuity.environment === "replaced") environmentReplacements += 1;
@@ -2306,6 +2322,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2306
2322
  scope,
2307
2323
  coordinationMcpUrl: mcp.url,
2308
2324
  coordinationMcpHeaders: mcp.headers,
2325
+ ...deps.peerMailUrl ? { peerMailUrl: deps.peerMailUrl } : {},
2309
2326
  stopSignal: stopController.signal,
2310
2327
  coordinationTools
2311
2328
  });
@@ -2339,6 +2356,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2339
2356
  attempt: nextAttempt,
2340
2357
  signal: AbortSignal.any([scope.signal, stopController.signal]),
2341
2358
  heartbeatMs: wakePolicy.heartbeatMs,
2359
+ ...deps.peerMailUrl ? { alsoWakeOn: peerInbox.pending() > 0 ? Promise.resolve() : peerInbox.nextDelivery() } : {},
2342
2360
  debounceMs: wakePolicy.debounceMs,
2343
2361
  ...warnAt === void 0 ? {} : { deadlineAt: warnAt }
2344
2362
  });
@@ -3263,7 +3281,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
3263
3281
  let seatChain;
3264
3282
  let activeSeat;
3265
3283
  let switchedProviderCheckpointAt;
3266
- const drive = async ({ profile, authoredProfile, registeredProfile, task, scope, coordinationMcpUrl, coordinationMcpHeaders, stopSignal, coordinationTools, reentry, session }) => {
3284
+ const drive = async ({ profile, authoredProfile, registeredProfile, task, scope, coordinationMcpUrl, coordinationMcpHeaders, peerMailUrl, stopSignal, coordinationTools, reentry, session }) => {
3267
3285
  const priorCommittedArtifact = managerArtifact;
3268
3286
  managerArtifact = void 0;
3269
3287
  switchedProviderCheckpointAt = void 0;
@@ -3385,6 +3403,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
3385
3403
  };
3386
3404
  const turnStop = turnCap > 0 ? new AbortController() : void 0;
3387
3405
  const effectiveStopSignal = turnStop === void 0 ? stopSignal : stopSignal === void 0 ? turnStop.signal : AbortSignal.any([stopSignal, turnStop.signal]);
3406
+ const peerMailAttachment = peerMailRuntimeAttachment(authoredProfile, boundBackend, { peerMailUrl });
3388
3407
  const attachment = {
3389
3408
  transport: "http",
3390
3409
  url: coordinationMcpUrl,
@@ -3401,6 +3420,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
3401
3420
  if (!authorization?.startsWith("Bearer ")) throw new ValidationError("driveHarnessFromBackend: provider coordination requires a bearer credential");
3402
3421
  if (Object.hasOwn(boundBackend.defaults?.env ?? {}, credentialName)) throw new ValidationError("driveHarnessFromBackend: provider defaults contain the reserved coordination credential name");
3403
3422
  if (Object.hasOwn(boundBackend.defaults?.runtimeAttachments?.mcp ?? {}, "agent-runtime-coordination")) throw new ValidationError("driveHarnessFromBackend: provider defaults contain the reserved coordination attachment alias");
3423
+ if (peerMailUrl && Object.hasOwn(boundBackend.defaults?.runtimeAttachments?.mcp ?? {}, peerMailMcpAlias)) throw new ValidationError("driveHarnessFromBackend: provider defaults contain the reserved peer-mail attachment alias");
3404
3424
  if (!await providerAcceptsCoordinationAttachments(boundBackend)) throw new ValidationError("driveHarnessFromBackend: provider does not advertise create.runtimeAttachments.mcp; no environment was created");
3405
3425
  factory = createExecutor({
3406
3426
  ...boundBackend,
@@ -3413,6 +3433,10 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
3413
3433
  },
3414
3434
  runtimeAttachments: { mcp: {
3415
3435
  ...boundBackend.defaults?.runtimeAttachments?.mcp ?? {},
3436
+ ...peerMailUrl ? { [peerMailMcpAlias]: {
3437
+ transport: "http",
3438
+ url: peerMailUrl
3439
+ } } : {},
3416
3440
  [coordinationMcpAlias]: {
3417
3441
  transport: "http",
3418
3442
  url: coordinationMcpUrl,
@@ -3436,7 +3460,10 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
3436
3460
  onResult: async (result) => commitOwnerResult(result)
3437
3461
  } } : {},
3438
3462
  ...effectiveStopSignal === void 0 ? {} : { [bridgeStopSignalKey]: effectiveStopSignal },
3439
- [bridgeRuntimeAttachmentsKey]: { [coordinationMcpAlias]: attachment }
3463
+ [bridgeRuntimeAttachmentsKey]: {
3464
+ ...peerMailAttachment ?? {},
3465
+ [coordinationMcpAlias]: attachment
3466
+ }
3440
3467
  }
3441
3468
  });
3442
3469
  keepTranscript(lastExecutor?.harnessTranscript?.());
@@ -3869,6 +3896,11 @@ async function verifyProfilePromotions(table) {
3869
3896
  const { verifySealedExperiment } = await import("@tangle-network/agent-eval/experiment");
3870
3897
  for (const [name, entry] of promoted) if (!await verifySealedExperiment(entry.promotion.experiment)) throw new ValidationError(`supervise: opts.registry.profiles ${JSON.stringify(name)} cites a sealed play whose digest does not match its spec`);
3871
3898
  }
3899
+ /** Capabilities a data-only consumer may require before building an opted-in run. */
3900
+ const superviseFleetCapabilities = Object.freeze({
3901
+ peerAudit: true,
3902
+ traceTools: true
3903
+ });
3872
3904
  const superviseOptionKeySet = /* @__PURE__ */ new Set([
3873
3905
  "allowedModels",
3874
3906
  "analysts",
@@ -3908,6 +3940,8 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
3908
3940
  "onProgressStop",
3909
3941
  "otel",
3910
3942
  "peerMail",
3943
+ "peerAudit",
3944
+ "traceTools",
3911
3945
  "perWorker",
3912
3946
  "reservationPolicy",
3913
3947
  "deadlineCheckIn",
@@ -4391,8 +4425,36 @@ function superviseInternal(profile, task, opts, testBrain) {
4391
4425
  if (options.backend?.backend !== "provider" || options.makeWorkerAgent || options.makeLeafAgent) throw new ValidationError("supervise: SQL runContext requires backend-derived retained provider workers");
4392
4426
  }
4393
4427
  assertValidBudget(options.budget, "supervise budget");
4394
- const composeSpawnProfile = profileGuidanceComposer(options.profileGuidance);
4395
- const registeredProfile = superviseRootProfile(profile, options.profileGuidance);
4428
+ const guidanceComposer = profileGuidanceComposer(options.profileGuidance);
4429
+ const applyTraceTools = (profile) => {
4430
+ if (options.traceTools !== false || profile.tools === void 0) return profile;
4431
+ const tools = Object.fromEntries(Object.entries(profile.tools).filter(([name]) => name !== `${coordinationProfileToolPrefix}observe_agent` && name !== `${coordinationProfileToolPrefix}read_journal`));
4432
+ return agentProfileSchema.parse({
4433
+ ...profile,
4434
+ tools
4435
+ });
4436
+ };
4437
+ const composeSpawnProfile = options.traceTools === false ? (profile) => applyTraceTools(guidanceComposer?.(profile) ?? profile) : guidanceComposer;
4438
+ const auditPeers = /* @__PURE__ */ new Map();
4439
+ const peerAuditFor = (parent) => options.peerAudit ? {
4440
+ register: (nodeId, tools) => {
4441
+ auditPeers.set(nodeId, {
4442
+ parent,
4443
+ tools
4444
+ });
4445
+ },
4446
+ read: async (peerId, name, args) => {
4447
+ const peer = auditPeers.get(peerId);
4448
+ if (peer?.parent !== parent) return { error: "unknown-peer" };
4449
+ const rootRead = name === "observe_agent" && args.tree !== true && args.outRef === void 0 && (args.workerId === void 0 || args.workerId === peerId);
4450
+ const tool = (rootRead ? auditPeers.get(parent)?.tools : peer.tools)?.find((tool) => tool.name === name);
4451
+ return tool ? tool.handler(rootRead ? {
4452
+ ...args,
4453
+ workerId: peerId
4454
+ } : args) : { error: "peer-tool-unavailable" };
4455
+ }
4456
+ } : void 0;
4457
+ const registeredProfile = applyTraceTools(superviseRootProfile(profile, options.profileGuidance));
4396
4458
  if (options.segment !== void 0) admitSegment(options.segment);
4397
4459
  const canonicalProfile = options.segment === void 0 ? registeredProfile : withRootSegment(registeredProfile, options.segment);
4398
4460
  assertExecutableAgentProfile(canonicalProfile, "supervise root");
@@ -4547,7 +4609,7 @@ function superviseInternal(profile, task, opts, testBrain) {
4547
4609
  const withRetry = (make) => withWorkerSpawnRetry(make, options.workerRetry, { ...options.onWorkerRetry ? { onRetry: options.onWorkerRetry } : {} });
4548
4610
  const makeLeaf = withRetry(options.makeLeafAgent ?? workerFromBackend(options.backend, deliverable));
4549
4611
  const securityPolicy = options.profileSecurity ?? DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY;
4550
- const makeRecursiveWorkerFor = (parent, parentIdentity, depth, parentOwnerId, analystLineage = false) => {
4612
+ const makeRecursiveWorkerFor = (parent, parentIdentity, depth, parentOwnerId, analystLineage = false, peerRootOwnerId) => {
4551
4613
  const makeRecursiveWorker = (authoredProfile, spawnContext, recovering = false) => {
4552
4614
  if (!spawnContext) throw new ValidationError("supervise: backend-derived workers require spawn context");
4553
4615
  const input = freezeDetachedProfile(authoredProfile);
@@ -4570,7 +4632,7 @@ function superviseInternal(profile, task, opts, testBrain) {
4570
4632
  ...spawnContext.execution ? { execution: spawnContext.execution } : {}
4571
4633
  });
4572
4634
  if (typeof decision !== "object" || decision === null || Array.isArray(decision)) throw new ValidationError("supervise: authorizeSpawn must return an AuthorizedSpawn");
4573
- const authorized = freezeDetachedProfile(decision.profile);
4635
+ const authorized = freezeDetachedProfile(applyTraceTools(decision.profile));
4574
4636
  const childExecution = canonicalExecution(authorized, spawnContext.task, decision.execution, `supervise spawn ${JSON.stringify(spawnContext.label)}`);
4575
4637
  const authorizedContext = Object.freeze({
4576
4638
  ...spawnContext,
@@ -4616,12 +4678,16 @@ function superviseInternal(profile, task, opts, testBrain) {
4616
4678
  if (isExternalSupervisor(authorized) && !nestedDriveHarness) throw new ValidationError(`supervise: authored external supervisor profile.harness=${JSON.stringify(authorized.harness)} requires a local bridge, a provider with authenticated coordination.publicUrl and runtime MCP attachments, or an explicit driveHarness with reachable coordination transport`);
4617
4679
  assertProfileContract(authorized, isExternalSupervisor(authorized) ? driverMaterialization : promptModelProfileMaterialization, `supervise driver ${JSON.stringify(spawnContext.label)}`, true);
4618
4680
  if (managerBackend) assertBridgeProfileMaterializes(profileWithoutDeclaredRuntimeCoordinationTools(authorized), managerBackend, `supervise driver ${JSON.stringify(spawnContext.label)}`);
4619
- const childFactory = makeRecursiveWorkerFor(authorized, childExecution.identity, depth + 1, ownerId, analystLineage || spawnContext.analyst !== void 0 || spawnContext.assignmentId.startsWith("analyst:"));
4681
+ const rootPeerOwner = options.peerAudit ? depth === 1 ? ownerId : peerRootOwnerId : void 0;
4682
+ const childFactory = makeRecursiveWorkerFor(authorized, childExecution.identity, depth + 1, ownerId, analystLineage || spawnContext.analyst !== void 0 || spawnContext.assignmentId.startsWith("analyst:"), rootPeerOwner);
4620
4683
  const nestedPerWorker = defaultPerWorker(spawnContext.budget, ownerShare);
4621
4684
  const authorizeNestedMessage = authorizeDownFor(authorized, depth + 1);
4622
4685
  let acceptedSubmission = false;
4623
4686
  let unassessedOutput = false;
4687
+ const peerAudit = depth === 1 ? peerAuditFor(spawnContext.parentNodeId) : void 0;
4624
4688
  return driverChild(authorized, supervisorAgent(authorized, {
4689
+ ...spawnContext.peerMailUrl ? { peerMailUrl: spawnContext.peerMailUrl } : {},
4690
+ ...peerAudit ? { peerAudit } : {},
4625
4691
  blobs,
4626
4692
  onUnassessedOutput: () => {
4627
4693
  unassessedOutput = true;
@@ -4641,7 +4707,8 @@ function superviseInternal(profile, task, opts, testBrain) {
4641
4707
  ownerId,
4642
4708
  depth,
4643
4709
  identity: childExecution.identity,
4644
- assignmentId: spawnContext.assignmentId
4710
+ assignmentId: spawnContext.assignmentId,
4711
+ ...rootPeerOwner ? { peerRootOwnerId: rootPeerOwner } : {}
4645
4712
  },
4646
4713
  ...options.resolveSupervisorTools ? { resolveSupervisorTools: options.resolveSupervisorTools } : {},
4647
4714
  ...observeNodeEvent ? {
@@ -4732,7 +4799,9 @@ function superviseInternal(profile, task, opts, testBrain) {
4732
4799
  await verifyProfilePromotions(profileTable);
4733
4800
  const priorCoordination = log ? await log.load(runId, rootOwnerId) : void 0;
4734
4801
  const authorizeRootMessage = authorizeDownFor(canonicalProfile, 1);
4802
+ const rootPeerAudit = peerAuditFor("");
4735
4803
  const agentDeps = {
4804
+ ...rootPeerAudit ? { peerAudit: rootPeerAudit } : {},
4736
4805
  blobs,
4737
4806
  makeWorkerAgent: workerFactory,
4738
4807
  ...authorizeRootMessage ? { authorizeDownMessage: authorizeRootMessage } : {},
@@ -4806,6 +4875,10 @@ function superviseInternal(profile, task, opts, testBrain) {
4806
4875
  runId,
4807
4876
  namespace: runNamespace,
4808
4877
  ...options.otel,
4878
+ agentIdentity: {
4879
+ ...options.otel.agentIdentity,
4880
+ ...authoredAgentIdentity(canonicalProfile, rootExecution.identity.profileDigest)
4881
+ },
4809
4882
  now
4810
4883
  }) : void 0;
4811
4884
  const recorder = spans;
@@ -4925,6 +4998,6 @@ function rootProviderModelEvidenceFromExecution(evidence) {
4925
4998
  return evidence ?? rootProviderModelEvidence([]);
4926
4999
  }
4927
5000
  //#endregion
4928
- export { readRootStreamReceipt as _, superviseWithTestBrain as a, createSupervisorSpanRecorder as b, resolveWorkerSpawnRetry as c, assertCoordinationBinding as d, resolveSupervisorProfile as f, readRootStream as g, ROOT_STREAM_FILE as h, superviseRootProfile as i, retryPreSpawnRefusals as l, supervisorAgentWithTestBrain as m, profileGuidanceComposer as n, workerFromBackend as o, supervisorAgent as p, supervise as r, isPreSpawnExecutorFailure as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, withWorkerSpawnRetry as u, UNPROVEN_CONTINUITY as v, serveCoordinationMcp as x, composeReentryTask as y };
5001
+ export { serveCoordinationMcp as S, readRootStream as _, superviseRootProfile as a, composeReentryTask as b, isPreSpawnExecutorFailure as c, withWorkerSpawnRetry as d, assertCoordinationBinding as f, ROOT_STREAM_FILE as g, supervisorAgentWithTestBrain as h, superviseFleetCapabilities as i, resolveWorkerSpawnRetry as l, supervisorAgent as m, profileGuidanceComposer as n, superviseWithTestBrain as o, resolveSupervisorProfile as p, supervise as r, workerFromBackend as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, retryPreSpawnRefusals as u, readRootStreamReceipt as v, createSupervisorSpanRecorder as x, UNPROVEN_CONTINUITY as y };
4929
5002
 
4930
- //# sourceMappingURL=supervise-BjrRk-AN.js.map
5003
+ //# sourceMappingURL=supervise-CwWI7kIk.js.map