@tangle-network/agent-runtime 0.220.0 → 0.220.1

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 (37) hide show
  1. package/dist/{activation-C-8VqFSN.js → activation-D3yrSA_b.js} +2 -2
  2. package/dist/{activation-C-8VqFSN.js.map → activation-D3yrSA_b.js.map} +1 -1
  3. package/dist/agent.js +2 -2
  4. package/dist/{coordination-driver-DwgDZ6nf.js → coordination-driver-BxGh-Tnj.js} +2 -2
  5. package/dist/{coordination-driver-DwgDZ6nf.js.map → coordination-driver-BxGh-Tnj.js.map} +1 -1
  6. package/dist/{delegate-BYMK7jGe.js → delegate-CiGfF17V.js} +2 -2
  7. package/dist/{delegate-BYMK7jGe.js.map → delegate-CiGfF17V.js.map} +1 -1
  8. package/dist/durable.js +2 -2
  9. package/dist/{graph-DHx2fTiH.js → graph-D9tSg6Vd.js} +3 -3
  10. package/dist/{graph-DHx2fTiH.js.map → graph-D9tSg6Vd.js.map} +1 -1
  11. package/dist/{improvement-cycle-BIAKVZ3B.js → improvement-cycle-BZ_KfBap.js} +3 -3
  12. package/dist/{improvement-cycle-BIAKVZ3B.js.map → improvement-cycle-BZ_KfBap.js.map} +1 -1
  13. package/dist/index.js +7 -7
  14. package/dist/intelligence.js +3 -3
  15. package/dist/kernel.js +8 -8
  16. package/dist/{loop-runner-bin-eB3kQCi8.js → loop-runner-bin-DkU6vtuc.js} +3 -3
  17. package/dist/{loop-runner-bin-eB3kQCi8.js.map → loop-runner-bin-DkU6vtuc.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 +4 -4
  21. package/dist/{provision-supervisor-CJ8EkREK.js → provision-supervisor-Cg3fETK-.js} +3 -3
  22. package/dist/{provision-supervisor-CJ8EkREK.js.map → provision-supervisor-Cg3fETK-.js.map} +1 -1
  23. package/dist/{runtime-DMRwKO-Y.js → runtime-DZcPHLwa.js} +8 -8
  24. package/dist/{runtime-DMRwKO-Y.js.map → runtime-DZcPHLwa.js.map} +1 -1
  25. package/dist/{server-1WLTlddl.js → server-BgPZIHRd.js} +3 -3
  26. package/dist/{server-1WLTlddl.js.map → server-BgPZIHRd.js.map} +1 -1
  27. package/dist/{structural-rollout-BAr61WjX.js → structural-rollout-iCePfrcK.js} +2 -2
  28. package/dist/{structural-rollout-BAr61WjX.js.map → structural-rollout-iCePfrcK.js.map} +1 -1
  29. package/dist/{supervise-DRDPNM81.js → supervise-CSYu0BeH.js} +5 -309
  30. package/dist/supervise-CSYu0BeH.js.map +1 -0
  31. package/dist/{supervisor-WRrw0nlk.js → supervisor-n8DDNGli.js} +368 -31
  32. package/dist/supervisor-n8DDNGli.js.map +1 -0
  33. package/dist/testing.js +12 -12
  34. package/dist/tui/index.js +1 -1
  35. package/package.json +1 -1
  36. package/dist/supervise-DRDPNM81.js.map +0 -1
  37. package/dist/supervisor-WRrw0nlk.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { $ as createExecutor, $r as attestRuntimeOwnedScopeOwner, A as scopeRetainedOwnerPriorSpend, An as unmeteredSpend, Bn as retainedExecutorSeamKey, Ct as spendFromUsageEvents, D as consumeScopeRetainedOwnerResult, Fn as withBudgetResources, Fr as defineProfileMaterializationContract, Gr as unsupportedProfileDimensions, Gt as bridgeModelRouteRefusal, Ir as fullProfileMaterialization, J as teardownExecutor, Lr as profileMaterializationAxes$1, Mn as zeroSpend, Nn as addResourceSpend, Nr as assertProfileMaterialization, Nt as createInbox, O as prepareScopeRetainedOwnerTask, Pn as resourceTelemetry, Pr as controlProfileMaterialization, Rr as promptControlProfileMaterialization, Ur as renderUnsupported, Vn as RunCancellationReason, Wn as runAbortable, Wt as bridgeAdmissionRefusal, X as captureReusableExecutorConfig, Xt as bridgeRuntimeAttachmentsKey, Y as bindReusableExecutorExecutionId, Zt as bridgeStopSignalKey, _ as recordScopeOwnerMaterialization, bt as contentAddress, c as driverChild, ci as runtimeOwnedDriveHarnessProviderEvidence, cn as routerBrain, cr as createOtelExporter, di as runtimeOwnedExecutorProviderEvidence, dr as generateSpanId, f as beginScopeOwnerAttempt, fi as runtimeOwnedPendingExecutorMaterialization, g as meterRuntimeOwnedProviderAttempt, gn as resolveAgentEnvironmentProvider, h as meterRuntimeOwnedAccounting, hr as toOtelAttributes, j as scopeRetainedOwnerResult, jn as withTimeout, k as scopeRetainedOwnerContext, l as driverExecutorFactory, li as runtimeOwnedExecutorExecutionBinding, m as deriveNodeExecutionIdentity, n as createSupervisor, ni as inheritRuntimeOwnedExecutorAttestation, o as runFinalizer, oi as providerAttemptEvidence, pi as runtimeOwnedScopeOwnerRuntime, q as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, qr as worktreeCliProfileMaterialization, r as bestDelivered, s as runTree, si as recordRuntimeOwnedDriveHarnessProviderEvidence, t as createRootHandle, tt as snapshotExecutorConfig, u as isDriverSpec, ui as runtimeOwnedExecutorMaterialization, v as restoreScopeOwnerAcceptedExecution, vn as addSpend, wt as WORKER_TRACE_PROPAGATION, xt as assertValidBudget, y as scopeOwnerExecutorNodeContext, yi as detachedSnapshot, zn as registerRetainedExecutorPreparation, zr as promptModelProfileMaterialization } from "./supervisor-WRrw0nlk.js";
2
- import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError, r as BackendTransportError, t as AgentEvalError } from "./errors-DodWX-cb.js";
1
+ import { $ as bindReusableExecutorExecutionId, Br as fullProfileMaterialization, C as scopeOwnerExecutorNodeContext, Ci as detachedSnapshot, Dt as spendFromUsageEvents, F as scopeRetainedOwnerResult, Fn as withTimeout, Gn as RunCancellationReason, Hr as promptControlProfileMaterialization, In as zeroSpend, Jn as runAbortable, Jt as bridgeAdmissionRefusal, Ln as addResourceSpend, Lr as assertProfileMaterialization, Lt as createInbox, M as prepareScopeRetainedOwnerTask, N as scopeRetainedOwnerContext, Ot as WORKER_TRACE_PROPAGATION, P as scopeRetainedOwnerPriorSpend, Pn as unmeteredSpend, Q as teardownExecutor, Rn as resourceTelemetry, Rr as controlProfileMaterialization, S as restoreScopeOwnerAcceptedExecution, Sn as addSpend, Tt as assertValidBudget, Un as registerRetainedExecutorPreparation, Ur as promptModelProfileMaterialization, Vr as profileMaterializationAxes$1, Wn as retainedExecutorSeamKey, Yr as unsupportedProfileDimensions, Yt as bridgeModelRouteRefusal, Z as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Zr as worktreeCliProfileMaterialization, _i as runtimeOwnedScopeOwnerRuntime, at as snapshotExecutorConfig, b as meterRuntimeOwnedProviderAttempt, bn as resolveAgentEnvironmentProvider, d as runDriverWithRetry, di as recordRuntimeOwnedDriveHarnessProviderEvidence, en as bridgeRuntimeAttachmentsKey, et as captureReusableExecutorConfig, f as driverChild, fi as runtimeOwnedDriveHarnessProviderEvidence, fn as routerBrain, fr as createOtelExporter, g as beginScopeOwnerAttempt, gi as runtimeOwnedPendingExecutorMaterialization, hi as runtimeOwnedExecutorProviderEvidence, hr as generateSpanId, j as consumeScopeRetainedOwnerResult, m as isDriverSpec, mi as runtimeOwnedExecutorMaterialization, n as createSupervisor, o as runFinalizer, oi as inheritRuntimeOwnedExecutorAttestation, p as driverExecutorFactory, pi as runtimeOwnedExecutorExecutionBinding, qr as renderUnsupported, r as bestDelivered, ri as attestRuntimeOwnedScopeOwner, rt as createExecutor, s as runTree, t as createRootHandle, tn as bridgeStopSignalKey, u as defaultUnmetContractSteer, ui as providerAttemptEvidence, v as deriveNodeExecutionIdentity, wt as contentAddress, x as recordScopeOwnerMaterialization, y as meterRuntimeOwnedAccounting, yr as toOtelAttributes, zn as withBudgetResources, zr as defineProfileMaterializationContract } from "./supervisor-n8DDNGli.js";
2
+ import { i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
3
3
  import { a as concreteProfileModel, c as profileModelExecutionSettings, d as agentHarness, f as harnessRunsAgent, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile } from "./model-policy-DKDyr-fc.js";
4
4
  import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
5
5
  import { t as createStdioToolServer } from "./tool-server-BJbCPhoW.js";
6
- import { D as coordinationVerbNames, O as createCoordinationTools, S as watchRunCancellation, c as createProgressTracker, d as progressStop, r as driverAgent, v as createFileRunContext, w as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, x as applyRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-DwgDZ6nf.js";
6
+ import { D as coordinationVerbNames, O as createCoordinationTools, S as watchRunCancellation, c as createProgressTracker, d as progressStop, r as driverAgent, v as createFileRunContext, w as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, x as applyRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-BxGh-Tnj.js";
7
7
  import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-hZREkcfu.js";
8
8
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
9
9
  import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
@@ -1079,310 +1079,6 @@ function truncate(value) {
1079
1079
  return value.length > MAX_DETAIL_CHARS ? `${value.slice(0, MAX_DETAIL_CHARS)}…` : value;
1080
1080
  }
1081
1081
  //#endregion
1082
- //#region src/runtime/supervise/driver-retry.ts
1083
- /**
1084
- * Root-driver retry — the root gets the same second chance a worker's transport already has.
1085
- *
1086
- * A spawned child that dies is typed into a `down` settlement and the driver may re-spawn it. The
1087
- * ROOT had no such path: one dropped connection, one SIGKILLed harness process, one upstream 5xx
1088
- * ended a run of arbitrary length with `reason: 'driver-failed'`, and every live child was torn
1089
- * down with it (#741). The driver's budget and deadline were usually almost untouched.
1090
- *
1091
- * This module supplies the missing arm: run the driver again, on the SAME scope, the SAME
1092
- * coordination server and the SAME live children, until the budget or the deadline says stop.
1093
- * Nothing here restarts children or replays work — it re-enters the driver, and the bridge backend
1094
- * reattaches the harness session because the execution id is bound durably per node.
1095
- *
1096
- * Two classifications decide everything, and both are conservative:
1097
- *
1098
- * - TERMINAL failures are Runtime's own refusals: a `ValidationError`/`ConfigError` guard, an
1099
- * exhausted budget, an abort, a client-side transport status (401/404/422). Runtime meant them,
1100
- * so retrying re-runs a decision rather than recovering from an accident. They fail immediately.
1101
- * - TRANSIENT failures are everything foreign: a harness process that exited without a reason, a
1102
- * stream that cut mid-turn, a 5xx, a socket reset. Those are accidents, and they are exactly
1103
- * what a retry exists for.
1104
- *
1105
- * The one loop the budget alone cannot bound is a driver that dies INSTANTLY and repeatedly — a
1106
- * dead-on-arrival credential, a harness that refuses to start. Spending nothing, it would retry
1107
- * until the deadline hours later. So progress is measured between attempts, and a run of attempts
1108
- * that changes nothing stops at `maxConsecutiveFailures`. A failure that made progress resets that
1109
- * counter: a long run may be rescued many times, a hopeless one gives up in seconds.
1110
- *
1111
- * WHAT COUNTS AS PROGRESS is the part this module got wrong first, and the correction is measured.
1112
- * The original mark read metered spend, settled children, and an accepted submission — the
1113
- * filesystem and the meter, never the goal. Across 1,422 settled discovery-lab runs (2026-09-01)
1114
- * that reading retried the runs that had produced NOTHING 629 of 827 times (76.1%) while retrying
1115
- * the runs that HAD left an artifact 21 of 399 times (5.3%): the loop spent its second chances on
1116
- * the hopeless runs and measured persistence by burn rate. So when the caller declares a completion
1117
- * check, spend and settlements alone are NOT progress while that check is unmet; only a delivery —
1118
- * an accepted submission, a child that passed the check, or the contract turning met — resets the
1119
- * barren counter. A caller that declares no check reports `contract: 'none'` and keeps the exact
1120
- * historical reading.
1121
- *
1122
- * THE SECOND HALF of the same defect: `budgetStop` used to be consulted only after a failure, and a
1123
- * driver that RETURNED with the contract unmet ended the run silently — 376 of 376 winning lab runs
1124
- * ended on this loop's own `stop: 'completed'`, with the completion gate left to label the result
1125
- * rather than to change it. A completed drive whose contract is unmet is now a first-class moment:
1126
- * `reprompt.maxReprompts` re-enters the SAME live session with the unmet items, and every re-entry
1127
- * crosses the same budget, deadline, abort, and attempt bounds a retry crosses.
1128
- */
1129
- /**
1130
- * The instruction a completed-but-undelivered drive is re-entered with when the caller supplies no
1131
- * `onUnmetContract`. It states the verdict, names what is owed, reports the ledger, and gives the
1132
- * three steps — the same shape `depthStrategy` re-prompts a resumed session with, said in the
1133
- * driver's own terms.
1134
- */
1135
- function defaultUnmetContractSteer(context) {
1136
- const owed = context.describe?.trim();
1137
- return [
1138
- "The completion check has not passed. This run has delivered nothing yet.",
1139
- owed === void 0 || owed.length === 0 ? "The deliverable this run owes is still missing." : `The deliverable this run owes: ${owed}`,
1140
- `Workers settled: ${context.progress.settledCount}. Workers that passed the check: ${context.progress.deliveredCount ?? 0}.`,
1141
- "Do the unfinished work with the tools.",
1142
- "Verify that the check passes.",
1143
- "Then submit the result.",
1144
- "Do not restate work you already did."
1145
- ].join("\n");
1146
- }
1147
- const DEFAULT_MAX_CONSECUTIVE_FAILURES = 3;
1148
- const DEFAULT_MAX_ATTEMPTS = 8;
1149
- const DEFAULT_INITIAL_BACKOFF_MS$1 = 2e3;
1150
- const DEFAULT_MAX_BACKOFF_MS$1 = 3e4;
1151
- /**
1152
- * Bridge error classes the bridge itself never retries: a request that fails identically on
1153
- * every attempt, mapped below 5xx on its HTTP path (`parse_error` 400, the other two 501). On the
1154
- * stream path the same failure arrives with no status at all — a profile that cannot materialize
1155
- * is a `parse_error` — and the status split alone read it as a bad moment and re-drove it to the
1156
- * attempt ceiling.
1157
- */
1158
- const DETERMINISTIC_BRIDGE_CODES = /* @__PURE__ */ new Set([
1159
- "parse_error",
1160
- "not_configured",
1161
- "capability_denied"
1162
- ]);
1163
- /**
1164
- * Classify one driver failure. Runtime's own typed refusals are decisions and stay terminal;
1165
- * anything foreign is an accident and is retryable. A `BackendTransportError` is split by status
1166
- * because the taxonomy already promises consumers may branch on it: a 5xx/429/408 is the upstream
1167
- * having a bad moment, while a 401/404/422 is a request that will fail identically forever. The
1168
- * bridge's own never-retry classes are terminal whether or not a status rides with them.
1169
- */
1170
- function classifyDriverFailure(error, signal) {
1171
- if (signal?.aborted) return "terminal";
1172
- if (error instanceof Error && error.name === "AbortError") return "terminal";
1173
- if (error instanceof BackendTransportError) {
1174
- if (error.upstreamCode !== void 0 && DETERMINISTIC_BRIDGE_CODES.has(error.upstreamCode)) return "terminal";
1175
- const status = error.status;
1176
- if (status === void 0) return "transient";
1177
- if (status === 408 || status === 429 || status >= 500) return "transient";
1178
- return "terminal";
1179
- }
1180
- if (error instanceof ValidationError || error instanceof ConfigError || error instanceof RuntimeRunStateError) return "terminal";
1181
- if (error instanceof AgentEvalError) return "terminal";
1182
- return "transient";
1183
- }
1184
- /** The budget's own verdict on whether another attempt may run at all. */
1185
- function budgetStop(budget, atMs) {
1186
- if (budget.deadlineMs > 0 && atMs >= budget.deadlineMs) return "deadline";
1187
- if (budget.tokensLeft <= 0 || budget.iterationsLeft <= 0) return "budget-exhausted";
1188
- if (budget.usdCapped && budget.usdLeft <= 0) return "budget-exhausted";
1189
- if (budget.usdCapped && budget.usdKnown === false) return "budget-exhausted";
1190
- if (Object.values(budget.resources ?? {}).some((resource) => !resource.known || resource.remaining <= 0)) return "budget-exhausted";
1191
- }
1192
- function contractOf(mark) {
1193
- return mark.contract ?? "none";
1194
- }
1195
- /**
1196
- * Did this attempt move the run toward its DELIVERABLE?
1197
- *
1198
- * A delivery always counts: an accepted submission, one more child that passed the check, or the
1199
- * contract turning met. Spend and settlements count only while no declared check is outstanding —
1200
- * with a check unmet they are the burn-rate reading this module's header measures and rejects.
1201
- */
1202
- function madeProgress(before, after) {
1203
- if (after.submitted && !before.submitted) return true;
1204
- if ((after.deliveredCount ?? 0) > (before.deliveredCount ?? 0)) return true;
1205
- if (contractOf(before) !== "met" && contractOf(after) === "met") return true;
1206
- if (contractOf(after) === "unmet") return false;
1207
- return after.poolTokensSpent > before.poolTokensSpent || after.settledCount > before.settledCount;
1208
- }
1209
- /** The error a give-up throws: the original cause, re-described with the attempt history so
1210
- * `driver-failed` carries a diagnosable message instead of one backend's last words. */
1211
- var DriverAttemptsExhaustedError = class extends RuntimeRunStateError {
1212
- attempts;
1213
- stop;
1214
- constructor(cause, attempts, stop) {
1215
- const last = attempts[attempts.length - 1];
1216
- const causeText = cause instanceof Error ? `${cause.name}: ${cause.message}` : describeUnknown(cause);
1217
- super(`supervisor driver failed after ${attempts.length} attempt(s) — stopped by ${stop}; last cause: ${causeText}` + (last?.classification ? ` (classified ${last.classification})` : ""), { cause });
1218
- this.attempts = Object.freeze([...attempts]);
1219
- this.stop = stop;
1220
- }
1221
- };
1222
- function describeUnknown(value) {
1223
- if (typeof value === "string") return value;
1224
- try {
1225
- return JSON.stringify(value) ?? String(value);
1226
- } catch {
1227
- return String(value);
1228
- }
1229
- }
1230
- async function defaultSleep$1(ms, signal) {
1231
- if (ms <= 0 || signal.aborted) return;
1232
- await new Promise((resolve) => {
1233
- const done = () => {
1234
- clearTimeout(timer);
1235
- signal.removeEventListener("abort", done);
1236
- resolve();
1237
- };
1238
- const timer = setTimeout(done, ms);
1239
- if (typeof timer === "object" && timer !== null && "unref" in timer) timer.unref();
1240
- signal.addEventListener("abort", done, { once: true });
1241
- });
1242
- }
1243
- /**
1244
- * Run the driver until it completes WITH ITS CONTRACT MET, or until the budget, the deadline, an
1245
- * abort, a terminal error, or a ceiling stops it. Transient failures are retried. A drive that
1246
- * returns with its completion check unmet is re-entered on the same live session with the unmet
1247
- * items, up to `reprompt.maxReprompts`. Throws `DriverAttemptsExhaustedError` (cause = the last
1248
- * real failure) when a FAILURE ends the loop; a completed drive returns, met contract or not,
1249
- * because deciding what an undelivered run is worth belongs to the finalizer, not to this loop.
1250
- */
1251
- async function runDriverWithRetry(run) {
1252
- const now = run.now ?? Date.now;
1253
- const sleep = run.sleep ?? defaultSleep$1;
1254
- const policy = run.policy ?? {};
1255
- const retryEnabled = policy.enabled !== false;
1256
- const maxConsecutive = Math.max(0, policy.maxConsecutiveFailures ?? DEFAULT_MAX_CONSECUTIVE_FAILURES);
1257
- const maxAttempts = Math.max(1, policy.maxAttempts ?? DEFAULT_MAX_ATTEMPTS);
1258
- const initialBackoff = Math.max(0, policy.initialBackoffMs ?? DEFAULT_INITIAL_BACKOFF_MS$1);
1259
- const maxBackoff = Math.max(initialBackoff, policy.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS$1);
1260
- const maxReprompts = Math.max(0, run.reprompt?.maxReprompts ?? 0);
1261
- const attempts = [];
1262
- let consecutiveBarren = 0;
1263
- let reprompts = 0;
1264
- let reentry;
1265
- const emit = async (record) => {
1266
- attempts.push(record);
1267
- await run.onAttempt?.(record);
1268
- };
1269
- /**
1270
- * Decide what a completed-but-undelivered drive does next. Every bound the FAILURE path applies
1271
- * is applied here too — that is the fix for `budgetStop` having lived only in the catch arm — and
1272
- * the caller's hook is consulted last, so no hook can talk the loop past a deadline.
1273
- */
1274
- const decideReprompt = async (attempt, after) => {
1275
- if (reprompts >= maxReprompts) return { refusedBy: "reprompts-exhausted" };
1276
- if (run.signal.aborted) return { refusedBy: "aborted" };
1277
- const byBudget = budgetStop(run.budget(), now());
1278
- if (byBudget === "deadline" || byBudget === "budget-exhausted") return { refusedBy: byBudget };
1279
- if (attempt >= maxAttempts) return { refusedBy: "max-attempts" };
1280
- const context = {
1281
- attempt,
1282
- reprompts,
1283
- maxReprompts,
1284
- progress: after,
1285
- budget: run.budget(),
1286
- ...run.reprompt?.describe === void 0 ? {} : { describe: run.reprompt.describe }
1287
- };
1288
- const decision = await run.reprompt?.onUnmetContract?.(context) ?? { steer: defaultUnmetContractSteer(context) };
1289
- if (decision === "stop") return { refusedBy: "caller-stop" };
1290
- const steer = typeof decision.steer === "string" ? decision.steer.trim() : "";
1291
- if (steer.length === 0) throw new ValidationError("runDriverWithRetry: onUnmetContract returned an empty steer — return a non-empty instruction or 'stop'");
1292
- return { steer };
1293
- };
1294
- for (let attempt = 1;; attempt += 1) {
1295
- const before = run.progress();
1296
- const startedAt = now();
1297
- try {
1298
- await run.drive(attempt, reentry);
1299
- } catch (error) {
1300
- const durationMs = now() - startedAt;
1301
- const classification = classifyDriverFailure(error, run.signal);
1302
- const progressed = madeProgress(before, run.progress());
1303
- const stop = (() => {
1304
- if (classification === "terminal") return "terminal-error";
1305
- if (!retryEnabled) return "retry-disabled";
1306
- if (run.signal.aborted) return "aborted";
1307
- const byBudget = budgetStop(run.budget(), now());
1308
- if (byBudget) return byBudget;
1309
- if (attempt >= maxAttempts) return "max-attempts";
1310
- if (progressed) return void 0;
1311
- return consecutiveBarren + 1 >= maxConsecutive ? "no-progress" : void 0;
1312
- })();
1313
- if (stop !== void 0) {
1314
- await emit({
1315
- attempt,
1316
- durationMs,
1317
- error: error instanceof Error ? error.message : describeUnknown(error),
1318
- classification,
1319
- madeProgress: progressed,
1320
- stop
1321
- });
1322
- throw new DriverAttemptsExhaustedError(error, attempts, stop);
1323
- }
1324
- consecutiveBarren = progressed ? 0 : consecutiveBarren + 1;
1325
- reentry = void 0;
1326
- const backoff = Math.min(maxBackoff, initialBackoff * 2 ** Math.max(0, consecutiveBarren - 1));
1327
- await emit({
1328
- attempt,
1329
- durationMs,
1330
- error: error instanceof Error ? error.message : describeUnknown(error),
1331
- classification,
1332
- madeProgress: progressed,
1333
- retryInMs: backoff
1334
- });
1335
- await sleep(backoff, run.signal);
1336
- if (run.signal.aborted) throw new DriverAttemptsExhaustedError(error, attempts, "aborted");
1337
- const afterWait = budgetStop(run.budget(), now());
1338
- if (afterWait) throw new DriverAttemptsExhaustedError(error, attempts, afterWait);
1339
- continue;
1340
- }
1341
- const durationMs = now() - startedAt;
1342
- const after = run.progress();
1343
- const progressed = madeProgress(before, after);
1344
- const contract = contractOf(after);
1345
- const contractField = contract === "none" ? {} : { contract };
1346
- if (contract === "unmet" && maxReprompts > 0) {
1347
- const decision = await decideReprompt(attempt, after);
1348
- if ("steer" in decision) {
1349
- reprompts += 1;
1350
- reentry = {
1351
- reason: "unmet-contract",
1352
- steer: decision.steer,
1353
- reprompt: reprompts
1354
- };
1355
- await emit({
1356
- attempt,
1357
- durationMs,
1358
- madeProgress: progressed,
1359
- ...contractField,
1360
- reprompted: true,
1361
- retryInMs: 0
1362
- });
1363
- continue;
1364
- }
1365
- await emit({
1366
- attempt,
1367
- durationMs,
1368
- madeProgress: progressed,
1369
- ...contractField,
1370
- repromptRefusedBy: decision.refusedBy,
1371
- stop: "completed"
1372
- });
1373
- return;
1374
- }
1375
- await emit({
1376
- attempt,
1377
- durationMs,
1378
- madeProgress: progressed,
1379
- ...contractField,
1380
- stop: "completed"
1381
- });
1382
- return;
1383
- }
1384
- }
1385
- //#endregion
1386
1082
  //#region src/runtime/supervise/supervisor-agent.ts
1387
1083
  /**
1388
1084
  * `supervisorAgent` — build a supervisor `Agent` FROM its profile. The brain is resolved from
@@ -3675,6 +3371,6 @@ function rootProviderModelEvidenceFromExecution(evidence) {
3675
3371
  return evidence ?? rootProviderModelEvidence([]);
3676
3372
  }
3677
3373
  //#endregion
3678
- export { createSupervisorSpanRecorder as _, isPreSpawnExecutorFailure as a, mapExecutorResult as b, withWorkerSpawnRetry as c, resolveSupervisorProfile as d, supervisorAgent as f, defaultUnmetContractSteer as g, classifyDriverFailure as h, workerFromBackend as i, assertCoordinationBinding as l, DriverAttemptsExhaustedError as m, supervise as n, resolveWorkerSpawnRetry as o, supervisorAgentWithTestBrain as p, superviseWithTestBrain as r, retryPreSpawnRefusals as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, coordinationProfileToolPrefix as u, serveCoordinationMcp as v, gateOnDeliverable as y };
3374
+ export { mapExecutorResult as _, isPreSpawnExecutorFailure as a, withWorkerSpawnRetry as c, resolveSupervisorProfile as d, supervisorAgent as f, gateOnDeliverable as g, serveCoordinationMcp as h, workerFromBackend as i, assertCoordinationBinding as l, createSupervisorSpanRecorder as m, supervise as n, resolveWorkerSpawnRetry as o, supervisorAgentWithTestBrain as p, superviseWithTestBrain as r, retryPreSpawnRefusals as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, coordinationProfileToolPrefix as u };
3679
3375
 
3680
- //# sourceMappingURL=supervise-DRDPNM81.js.map
3376
+ //# sourceMappingURL=supervise-CSYu0BeH.js.map