@tangle-network/agent-runtime 3.0.21 → 3.0.23

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 (49) hide show
  1. package/dist/{activation-B4wO-9b4.js → activation-Dpu4VMIv.js} +2 -2
  2. package/dist/{activation-B4wO-9b4.js.map → activation-Dpu4VMIv.js.map} +1 -1
  3. package/dist/agent.js +3 -3
  4. package/dist/{coordination-manager-DlEk08FJ.js → coordination-manager-2WKCgKK1.js} +4 -4
  5. package/dist/{coordination-manager-DlEk08FJ.js.map → coordination-manager-2WKCgKK1.js.map} +1 -1
  6. package/dist/{delegate-BIQ-c7nF.js → delegate-Ck-bVGH9.js} +2 -2
  7. package/dist/{delegate-BIQ-c7nF.js.map → delegate-Ck-bVGH9.js.map} +1 -1
  8. package/dist/durable.js +6 -6
  9. package/dist/{graph-DBJi0DKS.js → graph-kUav_dxo.js} +5 -5
  10. package/dist/{graph-DBJi0DKS.js.map → graph-kUav_dxo.js.map} +1 -1
  11. package/dist/{improve-C0pULC3g.js → improve-DB37lfR0.js} +6 -6
  12. package/dist/{improve-C0pULC3g.js.map → improve-DB37lfR0.js.map} +1 -1
  13. package/dist/index.js +8 -8
  14. package/dist/intelligence.js +4 -4
  15. package/dist/kernel.js +11 -11
  16. package/dist/{loop-runner-_eBc40PI.js → loop-runner-HT5aeX5L.js} +2 -2
  17. package/dist/{loop-runner-_eBc40PI.js.map → loop-runner-HT5aeX5L.js.map} +1 -1
  18. package/dist/loop-runner-bin.js +1 -1
  19. package/dist/mcp/bin.js +3 -3
  20. package/dist/mcp/index.js +5 -5
  21. package/dist/{provision-supervisor-btvnftdf.js → provision-supervisor-IZesCN4c.js} +4 -4
  22. package/dist/{provision-supervisor-btvnftdf.js.map → provision-supervisor-IZesCN4c.js.map} +1 -1
  23. package/dist/{run-cancellation-Hs7AFuX0.js → run-cancellation-Gzo6qxlB.js} +2 -2
  24. package/dist/{run-cancellation-Hs7AFuX0.js.map → run-cancellation-Gzo6qxlB.js.map} +1 -1
  25. package/dist/{runtime-CVUjetvL.js → runtime-D3Qd5KYv.js} +12 -12
  26. package/dist/{runtime-CVUjetvL.js.map → runtime-D3Qd5KYv.js.map} +1 -1
  27. package/dist/{scope-CB1FZOkK.js → scope-DdPWlFO4.js} +163 -199
  28. package/dist/scope-DdPWlFO4.js.map +1 -0
  29. package/dist/{search-executor-BZQRGTTw.js → search-executor-DLrVQJ4D.js} +3 -3
  30. package/dist/{search-executor-BZQRGTTw.js.map → search-executor-DLrVQJ4D.js.map} +1 -1
  31. package/dist/{server-BdqXdrJd.js → server-D2XdPLsz.js} +3 -3
  32. package/dist/{server-BdqXdrJd.js.map → server-D2XdPLsz.js.map} +1 -1
  33. package/dist/{structural-rollout-DE5ymCg4.js → structural-rollout-CfibXs4m.js} +3 -3
  34. package/dist/{structural-rollout-DE5ymCg4.js.map → structural-rollout-CfibXs4m.js.map} +1 -1
  35. package/dist/{supervise-9MPkgG8f.js → supervise-CRukjvni.js} +36 -112
  36. package/dist/supervise-CRukjvni.js.map +1 -0
  37. package/dist/{supervision-discovery-BIEJSD-c.js → supervision-discovery-B1TLSbWa.js} +2 -2
  38. package/dist/{supervision-discovery-BIEJSD-c.js.map → supervision-discovery-B1TLSbWa.js.map} +1 -1
  39. package/dist/{supervisor-OHBlhBoh.js → supervisor-NnjJHuaL.js} +127 -36
  40. package/dist/supervisor-NnjJHuaL.js.map +1 -0
  41. package/dist/testing.js +11 -11
  42. package/dist/{top-web-BYNStdNM.js → top-web-BIlf2fbe.js} +4 -4
  43. package/dist/{top-web-BYNStdNM.js.map → top-web-BIlf2fbe.js.map} +1 -1
  44. package/dist/tui/bin.js +3 -3
  45. package/dist/tui/index.js +2 -2
  46. package/package.json +1 -1
  47. package/dist/scope-CB1FZOkK.js.map +0 -1
  48. package/dist/supervise-9MPkgG8f.js.map +0 -1
  49. package/dist/supervisor-OHBlhBoh.js.map +0 -1
@@ -1,14 +1,14 @@
1
- import { $n as persistHarnessTranscript, Ai as spendFromUsageTotals, At as beginScopeRetainedOwnerDrive, B as beginScopeOwnerAttempt, Br as runtimeOwnedExecutorMaterialization, Di as meterUsageEvent, Dt as prepareScopeRetainedOwnerTask, Et as consumeScopeRetainedOwnerResult, Ft as scopeRetainedOwnerRestorePoint, G as scopeOwnerExecutorNodeContext, H as noteScopeOwnerPlannedExecution, Hr as runtimeOwnedPendingExecutorMaterialization, Ht as scopeRetainedOwnerJournalRoot, It as noteScopeRetainedOwnerCoordination, J as providerVisibleProfile, Jr as isRuntimeFlowBrain, K as coordinationMcpAlias, Mr as providerAttemptEvidence, Mt as scopeRetainedOwnerTurnEnded, Nr as recordRuntimeOwnedDriveHarnessProviderEvidence, Nt as assertRetainedOwnerCoordinationRekey, O as parseWorkerToolTraceArtifact, Oi as newUsageTotals, Or as inheritRuntimeOwnedExecutorAttestation, Ot as scopeRetainedOwnerPriorSpend, Pt as reconcileScopeRetainedOwnerEnvironment, Q as assertRecursiveReservationPolicy, Rr as runtimeOwnedDriveHarnessProviderEvidence, Rt as bindScopeRetainedOwnerEnvironmentId, Si as executorFailure, St as scopeRetainedOwnerResourceReader, Tr as authoredAgentIdentity, Tt as abandonScopeRetainedOwnerInvocation, U as recordScopeOwnerMaterialization, Ur as runtimeOwnedScopeOwnerRuntime, Vn as generateSpanId, Vr as runtimeOwnedExecutorProviderEvidence, Vt as scopeRetainedOwnerContext, W as restoreScopeOwnerAcceptedExecution, Xr as runtimeFlowBrain, Y as runtimeGraphMetadataKey, Yr as runtimeFlowAgent, a as readRootStream, bi as contentAddress, bt as prepareScopeRetainedOwnerSeatSwitch, ct as recordScopeOwnerBarrenPause, dr as SeatChain, ea as recordValue, er as readHarnessTranscript, fi as cappedDoublingMs, fr as SeatChainExhaustedError, gr as RunCancellationReason, hi as unavailableResumeAt, ii as RetainedExecutionPendingError, ji as assertValidBudget, kn as WORKER_TRACE_PROPAGATION, kt as scopeRetainedOwnerResult, li as retainedExecutorSeamKey, lr as isLiveNodeStatus, lt as recordScopeOwnerDriverAttempt, mi as unavailablePauseMs, mr as seatExecutionProfile, n as ROOT_STREAM_FILE, or as createActivityLog, ot as meterRuntimeOwnedAccounting, pi as jitteredMs, pr as authoredSeatStages, q as coordinationProfileToolPrefix, r as createRootStreamSink, si as registerRetainedExecutorPreparation, st as meterRuntimeOwnedProviderAttempt, ur as isTerminalNodeStatus, ut as recordScopeOwnerPause, vr as linkAbort, wr as attestRuntimeOwnedScopeOwner, xt as releaseScopeRetainedOwnerForSeatPause, yr as runAbortable, zn as createOtelExporter, zr as runtimeOwnedExecutorExecutionBinding, zt as bindScopeRetainedOwnerProvider } from "./scope-CB1FZOkK.js";
1
+ import { $n as persistHarnessTranscript, $r as RetainedExecutionPendingError, At as beginScopeRetainedOwnerDrive, B as beginScopeOwnerAttempt, Ci as newUsageTotals, Cr as inheritRuntimeOwnedExecutorAttestation, Dr as providerAttemptEvidence, Dt as prepareScopeRetainedOwnerTask, Ei as assertValidBudget, Et as consumeScopeRetainedOwnerResult, Fr as runtimeOwnedExecutorMaterialization, Ft as scopeRetainedOwnerRestorePoint, G as scopeOwnerExecutorNodeContext, Gr as runtimeFlowBrain, H as noteScopeOwnerPlannedExecution, Ht as scopeRetainedOwnerJournalRoot, Ir as runtimeOwnedExecutorProviderEvidence, It as noteScopeRetainedOwnerCoordination, J as providerVisibleProfile, K as coordinationMcpAlias, Lr as runtimeOwnedPendingExecutorMaterialization, Mt as scopeRetainedOwnerTurnEnded, Nr as runtimeOwnedDriveHarnessProviderEvidence, Nt as assertRetainedOwnerCoordinationRekey, O as parseWorkerToolTraceArtifact, Or as recordRuntimeOwnedDriveHarnessProviderEvidence, Ot as scopeRetainedOwnerPriorSpend, Pr as runtimeOwnedExecutorExecutionBinding, Pt as reconcileScopeRetainedOwnerEnvironment, Q as assertRecursiveReservationPolicy, Rr as runtimeOwnedScopeOwnerRuntime, Rt as bindScopeRetainedOwnerEnvironmentId, Si as meterUsageEvent, St as scopeRetainedOwnerResourceReader, Ti as spendFromUsageTotals, Tt as abandonScopeRetainedOwnerInvocation, U as recordScopeOwnerMaterialization, Ur as isRuntimeFlowBrain, Vn as generateSpanId, Vt as scopeRetainedOwnerContext, W as restoreScopeOwnerAcceptedExecution, Wr as runtimeFlowAgent, Y as runtimeGraphMetadataKey, Yi as recordValue, _i as executorFailure, a as readRootStream, aa as runAbortable, ai as retainedExecutorSeamKey, br as authoredAgentIdentity, bt as prepareScopeRetainedOwnerSeatSwitch, ci as cappedDoublingMs, ct as recordScopeOwnerBarrenPause, di as unavailableResumeAt, dr as SeatChain, er as readHarnessTranscript, fr as SeatChainExhaustedError, hi as contentAddress, ia as linkAbort, kn as WORKER_TRACE_PROPAGATION, kt as scopeRetainedOwnerResult, li as jitteredMs, lr as isLiveNodeStatus, lt as recordScopeOwnerDriverAttempt, mr as seatExecutionProfile, n as ROOT_STREAM_FILE, na as RunCancellationReason, or as createActivityLog, ot as meterRuntimeOwnedAccounting, pr as authoredSeatStages, q as coordinationProfileToolPrefix, r as createRootStreamSink, ri as registerRetainedExecutorPreparation, st as meterRuntimeOwnedProviderAttempt, ui as unavailablePauseMs, ur as isTerminalNodeStatus, ut as recordScopeOwnerPause, xt as releaseScopeRetainedOwnerForSeatPause, yr as attestRuntimeOwnedScopeOwner, zn as createOtelExporter, zt as bindScopeRetainedOwnerProvider } from "./scope-DdPWlFO4.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-AzSuGI23.js";
3
3
  import { $ as isAsyncIterable, Dt as teardownExecutor, G as chargedTokens, Ot as teardownSurfaces, St as armDeadlineTimer, Tt as isDeadlineAbortReason, U as addSpend, Y as errorMessage, at as sleep, bt as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, dt as zeroSpend, gt as withBudgetResources, ht as resourceTelemetry, lt as unmeteredSpend, pt as addResourceSpend, tt as promptCacheTokenClasses, ut as withTimeout } from "./workspace-streams-8ALHaZzx.js";
4
4
  import { d as detachedSnapshot, h as errorHttpStatus, m as errMessage } from "./jsonl-file-BBP9Dz9w.js";
5
- import { $t as renderUnsupported, B as createRouterTranscript, C as createExecutor, Ct as bestComposite, F as codeModeArguments, Gt as assertProfileMaterialization, I as codeModeModelOutput, Jt as defineProfileMaterializationContract, L as createCodeModeTools, Lt as bridgeRuntimeAttachmentsKey, Ot as bridgeAdmissionRefusal, Qt as promptModelProfileMaterialization, Rt as bridgeStopSignalKey, S as captureReusableExecutorConfig, St as admitContinuationPolicy, Tt as createContinuationKeeper, U as resolveAgentEnvironmentProvider, V as routerBrain, X as createInbox, Xt as profileMaterializationAxes$1, Y as INBOX_RECEIPT_KEY, Yt as fullProfileMaterialization, Zt as promptControlProfileMaterialization, _t as gateFactoryOnDeliverable, a as assertRunParking, c as sleepScopeWait, ct as HarnessTurnFailedError, d as runFinalizer, dt as classifyDriverFailure, et as PEER_MAIL_WIRE_KEY, f as runTree, ft as isContentFilterRefusal, g as isDriverSpec, gt as CheckUnavailableError, h as driverExecutorFactory, ht as upstreamUnavailableSignal, i as RunParkedError, kt as bridgeModelRouteRefusal, l as withRunParking, lt as abandonablePending, m as driverChild, mt as undispatchedCredentialExit, n as createSupervisor, nn as unsupportedProfileDimensions, o as bindScopeParkingDrain, p as createRootHandle, pt as summarizeDriverAttempts, qt as controlProfileMaterialization, rn as worktreeCliProfileMaterialization, rt as isPeerMailEnvelope, st as DriverAttemptsExhaustedError, tn as sandboxProfileMaterialization, u as bestDelivered, ut as causedByPartialFailure, w as snapshotExecutorConfig, wt as checkVerdictOf, x as bindReusableExecutorExecutionId, xt as CONTINUATIONS_DIR, z as toolResultText } from "./supervisor-OHBlhBoh.js";
5
+ import { $t as promptModelProfileMaterialization, At as bridgeModelRouteRefusal, B as createRouterTranscript, C as createExecutor, Ct as admitContinuationPolicy, Et as createContinuationKeeper, F as codeModeArguments, I as codeModeModelOutput, Jt as controlProfileMaterialization, Kt as assertProfileMaterialization, L as createCodeModeTools, Qt as promptControlProfileMaterialization, Rt as bridgeRuntimeAttachmentsKey, S as captureReusableExecutorConfig, St as CONTINUATIONS_DIR, Tt as checkVerdictOf, U as resolveAgentEnvironmentProvider, V as routerBrain, X as createInbox, Xt as fullProfileMaterialization, Y as INBOX_RECEIPT_KEY, Yt as defineProfileMaterializationContract, Zt as profileMaterializationAxes$1, _t as CheckUnavailableError, a as assertRunParking, c as sleepScopeWait, ct as HarnessTurnFailedError, d as runFinalizer, dt as classifyDriverFailure, en as renderUnsupported, et as PEER_MAIL_WIRE_KEY, f as runTree, ft as isContentFilterRefusal, g as isDriverSpec, gt as preflightPublicCoordination, h as driverExecutorFactory, ht as upstreamUnavailableSignal, i as RunParkedError, in as worktreeCliProfileMaterialization, kt as bridgeAdmissionRefusal, l as withRunParking, lt as abandonablePending, m as driverChild, mt as undispatchedCredentialExit, n as createSupervisor, nn as sandboxProfileMaterialization, o as bindScopeParkingDrain, p as createRootHandle, pt as summarizeDriverAttempts, rn as unsupportedProfileDimensions, rt as isPeerMailEnvelope, st as DriverAttemptsExhaustedError, u as bestDelivered, ut as causedByPartialFailure, vt as gateFactoryOnDeliverable, w as snapshotExecutorConfig, wt as bestComposite, x as bindReusableExecutorExecutionId, z as toolResultText, zt as bridgeStopSignalKey } from "./supervisor-NnjJHuaL.js";
6
6
  import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, l as profileProviderModel, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-C-RGAUW4.js";
7
+ import { n as createStdioToolServer } from "./tool-server-CZWd_Opp.js";
7
8
  import { t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
8
- import { _ as workerAssignmentNamespace, c as writeRunCancellation, d as coordinationEventId, f as externalExecutionId, g as supervisionRunNamespace, h as rootCoordinationOwner, i as readRunCancellation, l as canonicalExecution, m as freezeDetachedProfile, p as freezeDetached, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation, u as childCoordinationOwner } from "./run-cancellation-Hs7AFuX0.js";
9
- import { c as createSteerAcknowledger, d as coordinationVerbNames, f as createFileRunContext, l as budgetOverspendText, m as withRunContext, n as createCoordinationToolsForManager, p as createInMemoryRunContext, s as createCancelAcknowledger, t as createCoordinationTools, u as normalizeAnalyzeOnSettle } from "./coordination-manager-DlEk08FJ.js";
9
+ import { _ as workerAssignmentNamespace, c as writeRunCancellation, d as coordinationEventId, f as externalExecutionId, g as supervisionRunNamespace, h as rootCoordinationOwner, i as readRunCancellation, l as canonicalExecution, m as freezeDetachedProfile, p as freezeDetached, r as readRunCancelRequest, s as watchRunCancellation, t as applyRunCancellation, u as childCoordinationOwner } from "./run-cancellation-Gzo6qxlB.js";
10
+ import { c as createSteerAcknowledger, d as coordinationVerbNames, f as createFileRunContext, l as budgetOverspendText, m as withRunContext, n as createCoordinationToolsForManager, p as createInMemoryRunContext, s as createCancelAcknowledger, t as createCoordinationTools, u as normalizeAnalyzeOnSettle } from "./coordination-manager-2WKCgKK1.js";
10
11
  import { o as safeJsonText } from "./coordination-map-routing-BllzcZov.js";
11
- import { n as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-CZWd_Opp.js";
12
12
  import { a as graphRegistry, c as loadGraph } from "./graph-registry-D6y6zffC.js";
13
13
  import { ATTR, agentIdentityAttributes } from "@tangle-network/agent-trace-contract";
14
14
  import { ProxySecretScopeSchema, ProxySecretsSchema, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, mergeProxySecretBindings, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
@@ -331,10 +331,10 @@ function parentSpan(t, parentId) {
331
331
  };
332
332
  }
333
333
  function openNode(t, event) {
334
- const p = record$1(event.payload);
334
+ const p = record(event.payload);
335
335
  const childId = str(p.childId);
336
336
  if (!childId) return;
337
- const identity = agentIdentityAttributes(record$1(p.agent));
337
+ const identity = agentIdentityAttributes(record(p.agent));
338
338
  t.identityOf.set(childId, identity);
339
339
  const attrs = spawnAttributes(t.base, event, identity);
340
340
  const parent = parentSpan(t, event.parentId);
@@ -350,7 +350,7 @@ function openNode(t, event) {
350
350
  });
351
351
  }
352
352
  function settleNode(t, event) {
353
- const p = record$1(event.payload);
353
+ const p = record(event.payload);
354
354
  const childId = str(p.childId);
355
355
  if (!childId) return void 0;
356
356
  const node = t.open.get(childId);
@@ -383,7 +383,7 @@ function turnSpan(t, event) {
383
383
  "tangle.supervise.node.kind": "inference"
384
384
  };
385
385
  if (parentId) attrs["tangle.supervise.node.id"] = parentId;
386
- const p = record$1(event.payload);
386
+ const p = record(event.payload);
387
387
  assignTurnDetail(attrs, p);
388
388
  const spend = assignSpend(attrs, p.spend);
389
389
  return otelSpan(t.traceId, {
@@ -502,7 +502,7 @@ function createSupervisorSpanRecorder(opts) {
502
502
  }
503
503
  /** The attributes of a node span at `agent.spawn`, before its parent span is known. */
504
504
  function spawnAttributes(base, event, identity) {
505
- const p = record$1(event.payload);
505
+ const p = record(event.payload);
506
506
  const label = str(p.label) ?? "node";
507
507
  const runtime = str(p.runtime);
508
508
  const attrs = {
@@ -531,7 +531,7 @@ function spawnAttributes(base, event, identity) {
531
531
  }
532
532
  /** A node span's attributes at `agent.child`: the spawn-time ones plus how it settled. */
533
533
  function settledAttributes(opened, event) {
534
- const p = record$1(event.payload);
534
+ const p = record(event.payload);
535
535
  const status = str(p.status);
536
536
  const attrs = {
537
537
  ...opened,
@@ -547,7 +547,7 @@ function settledAttributes(opened, event) {
547
547
  if (reason) attrs["error.message"] = truncate(reason);
548
548
  if (typeof p.infra === "boolean") attrs["tangle.supervise.node.infra"] = p.infra;
549
549
  }
550
- const wokeBy = str(record$1(p.wait).settled);
550
+ const wokeBy = str(record(p.wait).settled);
551
551
  if (wokeBy) attrs["tangle.supervise.wait.settled"] = wokeBy;
552
552
  assignSpend(attrs, p.spent);
553
553
  return attrs;
@@ -655,7 +655,7 @@ function normalizeTraceId(traceId, runId, namespace) {
655
655
  const source = traceId ?? (namespace === void 0 ? runId : `${namespace}\u0000${runId}`);
656
656
  return contentAddress(source).slice(7, 39);
657
657
  }
658
- function record$1(value) {
658
+ function record(value) {
659
659
  return isRecord(value) ? value : {};
660
660
  }
661
661
  function str(value) {
@@ -4250,96 +4250,6 @@ function bindServedTools(opts, coord, fenceMs) {
4250
4250
  background: () => nodeTools.background() + fencedVerbs.background()
4251
4251
  };
4252
4252
  }
4253
- // src/runtime/supervise/coordination-preflight.ts
4254
- const MAX_RESPONSE_BYTES = 1048576;
4255
- var CoordinationPreflightError = class extends ConfigError {
4256
- constructor(reason) {
4257
- super(`coordination public endpoint preflight failed: ${reason}`);
4258
- }
4259
- };
4260
- function record(value) {
4261
- return typeof value === "object" && value !== null && !Array.isArray(value);
4262
- }
4263
- /** Check the operator's route before it becomes a provider attachment. This does not prove cloud egress. */
4264
- async function preflightPublicCoordination(input) {
4265
- const deadline = new AbortController();
4266
- const linked = linkAbort(input.signal, deadline.signal);
4267
- const timer = setTimeout(() => deadline.abort(), Math.min(input.requestTimeoutMs, 1e4));
4268
- timer.unref();
4269
- const rpc = async (method, params) => {
4270
- const response = await fetch(input.url, {
4271
- method: "POST",
4272
- headers: {
4273
- ...input.headers,
4274
- "content-type": "application/json",
4275
- accept: "application/json"
4276
- },
4277
- body: JSON.stringify({
4278
- jsonrpc: "2.0",
4279
- id: method,
4280
- method,
4281
- ...params ? { params } : {}
4282
- }),
4283
- redirect: "manual",
4284
- signal: linked.signal
4285
- });
4286
- if (response.status !== 200) {
4287
- response.body?.cancel().catch(() => void 0);
4288
- throw new CoordinationPreflightError(`HTTP ${response.status}`);
4289
- }
4290
- const reader = response.body?.getReader();
4291
- if (!reader) throw new CoordinationPreflightError("invalid MCP response");
4292
- let size = 0;
4293
- const chunks = [];
4294
- try {
4295
- for (;;) {
4296
- const part = await reader.read();
4297
- if (part.done) break;
4298
- size += part.value.byteLength;
4299
- if (size > MAX_RESPONSE_BYTES) {
4300
- reader.cancel().catch(() => void 0);
4301
- throw new CoordinationPreflightError("response too large");
4302
- }
4303
- chunks.push(part.value);
4304
- }
4305
- } finally {
4306
- reader.releaseLock();
4307
- }
4308
- let body;
4309
- try {
4310
- body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks)));
4311
- } catch {
4312
- throw new CoordinationPreflightError("invalid MCP response");
4313
- }
4314
- if (!record(body) || body.jsonrpc !== "2.0" || body.id !== method || body.error || !record(body.result)) throw new CoordinationPreflightError("invalid MCP response");
4315
- return body.result;
4316
- };
4317
- try {
4318
- await runAbortable(async () => {
4319
- const initialized = await rpc("initialize", {
4320
- protocolVersion: PROTOCOL_VERSION,
4321
- capabilities: {},
4322
- clientInfo: {
4323
- name: "agent-runtime-coordination-preflight",
4324
- version: "1"
4325
- }
4326
- });
4327
- if (initialized.protocolVersion !== "2024-11-05" || !record(initialized.serverInfo) || initialized.serverInfo.name !== "coordination" || !record(initialized.capabilities) || !record(initialized.capabilities.tools)) throw new CoordinationPreflightError("invalid MCP initialization");
4328
- const listing = await rpc("tools/list");
4329
- if (!Array.isArray(listing.tools) || listing.tools.some((tool) => !record(tool) || typeof tool.name !== "string")) throw new CoordinationPreflightError("invalid MCP tool list");
4330
- const names = listing.tools.map((tool) => tool.name).sort();
4331
- if (JSON.stringify(names) !== JSON.stringify([...input.toolNames].sort())) throw new CoordinationPreflightError("coordination tool grants differ");
4332
- }, linked.signal, "coordination public endpoint preflight cancelled");
4333
- } catch (error) {
4334
- if (input.signal.aborted) throw new CoordinationPreflightError("cancelled");
4335
- if (deadline.signal.aborted) throw new CoordinationPreflightError("timed out");
4336
- if (error instanceof CoordinationPreflightError) throw error;
4337
- throw new CoordinationPreflightError("transport unavailable");
4338
- } finally {
4339
- clearTimeout(timer);
4340
- linked.release();
4341
- }
4342
- }
4343
4253
  // src/runtime/supervise/coordination-mcp.ts
4344
4254
  /** Serve Runtime coordination as bounded HTTP MCP over one live scope. @experimental */
4345
4255
  /** Recognizable loopback spellings; other hostnames require authenticated remote transport. */
@@ -4375,7 +4285,7 @@ function coordinationResponseFenceMs(requestTimeoutMs) {
4375
4285
  async function serveCoordinationMcp(opts) {
4376
4286
  return (await serveCoordinationMcpForManager(opts)).handle;
4377
4287
  }
4378
- /** Bind the advertised address, credential audience and paths, then prove public reachability. */
4288
+ /** Bind the advertised address, credential audience and paths, and say how to prove the route. */
4379
4289
  async function bindCoordinationAddress(ctx, port, addressSignal) {
4380
4290
  const { opts, host, identity, state } = ctx;
4381
4291
  const localUrl = `http://${host.includes(":") && !host.startsWith("[") ? `[${host}]` : host}:${port}/mcp`;
@@ -4401,14 +4311,17 @@ async function bindCoordinationAddress(ctx, port, addressSignal) {
4401
4311
  state.controlPaths.add(`${path.replace(/\/$/, "")}/control`);
4402
4312
  state.mailPaths.add(`${path.replace(/\/$/, "")}/mail`);
4403
4313
  }
4404
- if (configured !== void 0) await preflightPublicCoordination({
4314
+ const prove = () => preflightPublicCoordination({
4405
4315
  url,
4406
4316
  headers: ctx.credentials.headers,
4407
4317
  signal: opts.scope.signal,
4408
4318
  requestTimeoutMs: ctx.requestTimeoutMs,
4409
4319
  toolNames: opts.toolNames
4410
4320
  });
4411
- return url;
4321
+ return {
4322
+ url,
4323
+ prove: configured === void 0 ? async () => {} : prove
4324
+ };
4412
4325
  }
4413
4326
  /** Runtime-only binding: operator controls stay off the public MCP handle and tool grants. */
4414
4327
  async function serveCoordinationMcpForManager(opts, lifetime) {
@@ -4481,9 +4394,10 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
4481
4394
  opts.scope.signal.removeEventListener("abort", abortAddress);
4482
4395
  if (!addressLifetime.signal.aborted) addressLifetime.abort(/* @__PURE__ */ new Error("coordination listener closed"));
4483
4396
  };
4484
- let url;
4397
+ let bound;
4485
4398
  try {
4486
- url = await bindCoordinationAddress(ctx, port, addressLifetime.signal);
4399
+ bound = await bindCoordinationAddress(ctx, port, addressLifetime.signal);
4400
+ if (lifetime === void 0) await bound.prove();
4487
4401
  } catch (error) {
4488
4402
  releaseAddress();
4489
4403
  state.closed = true;
@@ -4493,6 +4407,12 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
4493
4407
  });
4494
4408
  throw error;
4495
4409
  }
4410
+ const { url } = bound;
4411
+ let proven = lifetime === void 0;
4412
+ const reachable = async () => {
4413
+ if (!proven) await bound.prove();
4414
+ proven = true;
4415
+ };
4496
4416
  let stopCredentialBinding;
4497
4417
  let refreshBoundCredential;
4498
4418
  const bindCredential = async (install) => {
@@ -4593,7 +4513,8 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
4593
4513
  }
4594
4514
  return {
4595
4515
  handle,
4596
- controls: coord
4516
+ controls: coord,
4517
+ reachable
4597
4518
  };
4598
4519
  }
4599
4520
  function coordinationBindingHost({ hostname }) {
@@ -4795,14 +4716,16 @@ async function openManagerSession(config, task, scope) {
4795
4716
  ledger: void 0,
4796
4717
  keeper: void 0
4797
4718
  };
4798
- const { handle: mcp, controls } = await serveManagerCoordination(config, state, context, priorCoordination, nodeTools, progressStopObserver(deps, state, nodeObserver));
4719
+ const served = await serveManagerCoordination(config, state, context, priorCoordination, nodeTools, progressStopObserver(deps, state, nodeObserver));
4720
+ const { handle: mcp, controls } = served;
4799
4721
  state.ledger = mcp;
4800
4722
  config.live.coordinator = mcp;
4801
4723
  config.live.inbox = managerInboxRoute(config, state, controls);
4802
4724
  return {
4803
4725
  state,
4804
4726
  mcp,
4805
- controls
4727
+ controls,
4728
+ reachable: served.reachable
4806
4729
  };
4807
4730
  }
4808
4731
  /**
@@ -5979,6 +5902,7 @@ async function driveManagerTurns(inputs) {
5979
5902
  drive: async (attempt, reentry) => {
5980
5903
  let handedOff = false;
5981
5904
  try {
5905
+ await session.reachable();
5982
5906
  await driveManagerTurn(loop, attempt, reentry);
5983
5907
  } catch (error) {
5984
5908
  handedOff = error instanceof RunParkedError && error.runId === scope.view.root;
@@ -9501,4 +9425,4 @@ function superviseWithContext(profile, task, opts, brain) {
9501
9425
  }
9502
9426
  export { analyzesFindingsReportPrompt as A, anyOf as B, flowRootProfile as C, defaultEdgeTraversalCap as D, validateFlowGraph as E, formatPromptHandle as F, bestSoFar as G, plateau as H, kernelPromptRegistry as I, createSupervisorSpanRecorder as J, plateauLength as K, naiveContinuationPrompt as L, delegatesWorkerBriefPrompt as M, dumbContinuationFailPrompt as N, graphRootProfile as O, dumbContinuationPassPrompt as P, promptHandle as R, createFlowRun as S, routeFlowOf as T, anytimeReport as U, noProgressFor as V, areaUnderCurve as W, coordinationControlToolNames as _, superviseRootProfile as a, createGraphOverlay as b, retryPreSpawnRefusals as c, supervisorAgent as d, supervisorAgentWithTestBrain as f, serveCoordinationMcp as g, composeReentryTask as h, profileGuidanceComposer as i, createPromptRegistry as j, validateGraphTopology as k, withWorkerSpawnRetry as l, UNPROVEN_CONTINUITY as m, superviseFleetCapabilities as n, isPreSpawnExecutorFailure as o, runToolSpans as p, renderAnytimeTable as q, superviseWithTestBrain as r, resolveWorkerSpawnRetry as s, supervise as t, workerFromBackend as u, driverAgent as v, journaledGateDecider as w, GraphRouteError as x, runBrainLoop as y, allWorkersStalled as z };
9503
9427
 
9504
- //# sourceMappingURL=supervise-9MPkgG8f.js.map
9428
+ //# sourceMappingURL=supervise-CRukjvni.js.map