@tangle-network/agent-runtime 10.0.18 → 10.0.20
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.
- package/CHANGELOG.md +8 -0
- package/dist/{activation-QvaQ62ub.js → activation-5TrUzeFd.js} +2 -2
- package/dist/{activation-QvaQ62ub.js.map → activation-5TrUzeFd.js.map} +1 -1
- package/dist/{activation-BrKEOt0o.d.ts → activation-B0arteLE.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +4 -4
- package/dist/{delegate-CeDlbkv1.js → delegate-DnW85VY0.js} +2 -2
- package/dist/{delegate-CeDlbkv1.js.map → delegate-DnW85VY0.js.map} +1 -1
- package/dist/{driver-control-acknowledgers-C6WDdngb.js → driver-control-acknowledgers-vgmZqgZ-.js} +8 -8
- package/dist/{driver-control-acknowledgers-C6WDdngb.js.map → driver-control-acknowledgers-vgmZqgZ-.js.map} +1 -1
- package/dist/durable-writer-thread.js +4 -4
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +17 -18
- package/dist/durable.js.map +1 -1
- package/dist/{graph-icQyDLuE.js → graph-DHNPE7kw.js} +8 -8
- package/dist/{graph-icQyDLuE.js.map → graph-DHNPE7kw.js.map} +1 -1
- package/dist/{graph-registry-aMRd94PD.js → graph-registry-DI8o9iCB.js} +1 -1
- package/dist/{graph-registry-SgsCxCTZ.js → graph-registry-qyaNDATw.js} +2 -3
- package/dist/{graph-registry-SgsCxCTZ.js.map → graph-registry-qyaNDATw.js.map} +1 -1
- package/dist/{improve-BkmELSLf.js → improve-BLFqeD3X.js} +6 -6
- package/dist/{improve-BkmELSLf.js.map → improve-BLFqeD3X.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -10
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +4 -4
- package/dist/{continuation-CDdjAkpk.js → jsonl-file-B2ESMrTh.js} +396 -4
- package/dist/jsonl-file-B2ESMrTh.js.map +1 -0
- package/dist/kernel.d.ts +1 -1
- package/dist/kernel.js +17 -18
- package/dist/{loop-runner-1JaJldwD.d.ts → loop-runner-BFC781pC.d.ts} +2 -2
- package/dist/{loop-runner-DA7j6lcP.js → loop-runner-CITvo-q1.js} +2 -2
- package/dist/{loop-runner-DA7j6lcP.js.map → loop-runner-CITvo-q1.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +6 -6
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-C9Hbntgv.js → provision-supervisor-CyUbiMz8.js} +6 -6
- package/dist/{provision-supervisor-C9Hbntgv.js.map → provision-supervisor-CyUbiMz8.js.map} +1 -1
- package/dist/{result-blob-store-Dke805sV.js → result-blob-store-CJjp44Mz.js} +3 -3
- package/dist/{result-blob-store-Dke805sV.js.map → result-blob-store-CJjp44Mz.js.map} +1 -1
- package/dist/{run-cancellation-ewCqEeaB.js → run-cancellation-BNBmsY3a.js} +2 -2
- package/dist/{run-cancellation-ewCqEeaB.js.map → run-cancellation-BNBmsY3a.js.map} +1 -1
- package/dist/{run-lock-BOg7BaXF.js → run-lock-Dcr79Wql.js} +2 -2
- package/dist/{run-lock-BOg7BaXF.js.map → run-lock-Dcr79Wql.js.map} +1 -1
- package/dist/{run-reopen-D0j0fxLA.js → run-reopen-Cr2SHmYa.js} +6 -6
- package/dist/{run-reopen-D0j0fxLA.js.map → run-reopen-Cr2SHmYa.js.map} +1 -1
- package/dist/{run-state-YgNw0e6m.js → run-state-AYXAe_lX.js} +7 -7
- package/dist/{run-state-YgNw0e6m.js.map → run-state-AYXAe_lX.js.map} +1 -1
- package/dist/{runtime-CvEV00cw.js → runtime-D-FpUoQg.js} +19 -20
- package/dist/{runtime-CvEV00cw.js.map → runtime-D-FpUoQg.js.map} +1 -1
- package/dist/{search-executor-obtQ1gad.js → search-executor-BHfb4p6C.js} +4 -4
- package/dist/{search-executor-obtQ1gad.js.map → search-executor-BHfb4p6C.js.map} +1 -1
- package/dist/{server-Cytht_rG.js → server-CAXzZHVz.js} +4 -4
- package/dist/{server-Cytht_rG.js.map → server-CAXzZHVz.js.map} +1 -1
- package/dist/{settle-record-wvANhoy8.js → settle-record-BlIw2MU1.js} +3 -3
- package/dist/{settle-record-wvANhoy8.js.map → settle-record-BlIw2MU1.js.map} +1 -1
- package/dist/{structural-rollout-srl_no2J.js → structural-rollout-BVuf5hFl.js} +4 -4
- package/dist/{structural-rollout-srl_no2J.js.map → structural-rollout-BVuf5hFl.js.map} +1 -1
- package/dist/{supervise-x-0LPDZh.js → supervise-Ci8wiyla.js} +13 -13
- package/dist/supervise-Ci8wiyla.js.map +1 -0
- package/dist/{supervise-identity-CAxifVzJ.js → supervise-identity-CtxWEk1I.js} +3 -3
- package/dist/{supervise-identity-CAxifVzJ.js.map → supervise-identity-CtxWEk1I.js.map} +1 -1
- package/dist/{supervision-discovery-CikJuonO.js → supervision-discovery-DKxqbnHf.js} +4 -4
- package/dist/{supervision-discovery-CikJuonO.js.map → supervision-discovery-DKxqbnHf.js.map} +1 -1
- package/dist/{supervisor-9_oKaGd_.js → supervisor-KcnH2hC4.js} +10 -592
- package/dist/supervisor-KcnH2hC4.js.map +1 -0
- package/dist/{supervisor-accounting-DLjKVPwf.js → supervisor-accounting-DlDUl58C.js} +617 -10
- package/dist/supervisor-accounting-DlDUl58C.js.map +1 -0
- package/dist/{supervisor-root-contract-BUrTzojJ.js → supervisor-root-contract-BCbu1A4n.js} +3 -3
- package/dist/{supervisor-root-contract-BUrTzojJ.js.map → supervisor-root-contract-BCbu1A4n.js.map} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/dist/{failure-cause-C96rzF-d.js → tool-server-n4XYpCok.js} +181 -2
- package/dist/tool-server-n4XYpCok.js.map +1 -0
- package/dist/{top-web-C_VALyaB.js → top-web-B-sHmI3g.js} +8 -8
- package/dist/{top-web-C_VALyaB.js.map → top-web-B-sHmI3g.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-eWuTelLM.d.ts → types-YXZL7Wxi.d.ts} +6 -4
- package/package.json +1 -1
- package/dist/continuation-CDdjAkpk.js.map +0 -1
- package/dist/failure-cause-C96rzF-d.js.map +0 -1
- package/dist/jsonl-file-B8xfYz9M.js +0 -397
- package/dist/jsonl-file-B8xfYz9M.js.map +0 -1
- package/dist/supervise-x-0LPDZh.js.map +0 -1
- package/dist/supervisor-9_oKaGd_.js.map +0 -1
- package/dist/supervisor-accounting-DLjKVPwf.js.map +0 -1
- package/dist/tool-server-BhsyVDj2.js +0 -174
- package/dist/tool-server-BhsyVDj2.js.map +0 -1
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { $ as appendTeardownConfirmation,
|
|
2
|
-
import { f as RuntimeRunStateError,
|
|
3
|
-
import {
|
|
4
|
-
import { a as ROOT_DEADLINE_REASON,
|
|
1
|
+
import { $ as appendTeardownConfirmation, At as RELEASE_DESTROY_MS, Bn as environmentGone, Br as CheckUnavailableError, Ci as RetainedRunProviderContractError, Cn as verifyWorkspaceMarker, Ct as unconfirmedTeardowns, Di as freezeControlRef, Dn as reconnectRetainedRun, Dr as classifyDriverFailure, Ei as exactSession, En as mintRetainedIdentity, Gn as mergeTraceEnv, Gr as attestRuntimeOwnedDeferredExecutor, Hn as workerTraceEnv, Hr as gateOnDeliverable, Kr as attestRuntimeOwnedExecutor, L as resolveWorkerSlots, Lt as finalizeScopeOwnerMaterialization, Oi as retainedSessionReplaced, On as recoverRetainedRun, Qr as inheritRuntimeOwnedExecutorAttestation, R as prepareScopeResume, Sn as stopRetainedNativeExecution, Sr as isLiveNodeStatus, St as startScopeRecoveries, Ti as awaitAbortable, Tn as assertRetainedRunReplayMaterial, Tr as HarnessTurnFailedError, U as nestedScopeSeamKey, Un as workerTraceHeaders, Vn as WORKER_TRACE_PROPAGATION, Xt as scopeRetainedOwnerSettled, Z as appendSpawnEvents, Zr as finalizeRuntimeOwnedPendingExecutor, _i as executableAgentProfileSnapshot, _n as executorObservation, _t as registerNestedTeardownScope, ai as recordRuntimeOwnedProviderDispatchNotStarted, an as owners, ar as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, br as describeToolArgs, bt as retryUnconfirmedTeardowns, ct as closeRetainedSlots, fn as attestNestedDriverTreeOwner, hn as SpawnEventIndex, ii as recordRuntimeOwnedProviderAttemptStart, in as bindScopeRetainedOwnerProvider, ji as promptOptionsFromAgentTurnInput, ki as sameControlCoordinates, kn as startRetainedRun, li as runtimeOwnedExecutorExecutionBinding, ln as loadSpawnForest, lr as harnessTranscriptFromLines, lt as closeScopeAdmission, mi as runtimeOwnedScopeOwnerRuntime, mn as nestedDriverTreeRoot, n as terminalAccounting, nn as scopeRetainedOwnerCheckpointing, nt as assertRecursiveReservationPolicy, oi as recordRuntimeOwnedProviderIdentityConflict, on as scopeOwnerLiabilities, pi as runtimeOwnedScopeOwnerControl, pn as driverRuntime, qr as attestRuntimeOwnedPendingExecutor, r as createScope, si as recordRuntimeOwnedProviderModel, sr as captureHarnessTranscript, st as boundRetainedReleases, t as isNonEmptySpend, ti as newExecutionAttemptId, ui as runtimeOwnedExecutorMaterialization, un as ownedTreeRootSpawn, ur as harnessTranscriptUnavailable, ut as hasRetriableTeardowns, vi as executableAgentSpecSnapshot, vt as releaseHeldEnvironments, wi as assertEventBinding, wn as RetainedMaterializationTimeoutError, wr as DriverAttemptsExhaustedError, wt as waitForScopeChildren, xn as describeRetainedNativeStops, xt as settleManagerWork, yn as observeModelRequest, yr as createActivityLog, yt as releaseRetainedEnvironments } from "./supervisor-accounting-DlDUl58C.js";
|
|
2
|
+
import { f as RuntimeRunStateError, m as ValidationError$1, r as BackendTransportError } from "./errors-DG8yufqX.js";
|
|
3
|
+
import { C as linkAbort, b as RunCancellationReason, h as checkVerdictOf, v as isFiniteNumber, w as runAbortable, x as abortReason, y as sha256 } from "./jsonl-file-B2ESMrTh.js";
|
|
4
|
+
import { a as ROOT_DEADLINE_REASON, l as isDeadlineAbortReason, o as armDeadlineTimer, t as ACCEPTED_RESULT_GRACE_MS } from "./deadline-CySmJ_0S.js";
|
|
5
5
|
import { C as unreportedSpend, D as addResourceSpend, E as zeroTokenUsage, S as unmeteredSpend, T as zeroSpend, _ as roundBoxMinutes, b as throwAbort, c as errorMessage, d as isAbortError, f as isAsyncIterable, g as randomUuid, h as randomSuffix, m as promptCacheTokenClasses, n as addSpend, o as cloneTokenUsage, p as mapWithConcurrency, r as addTokenUsage, s as deleteBoxSafe, v as sleep, w as withTimeout, x as throwIfAborted, y as stringifySafe } from "./util-qsH5cC9S.js";
|
|
6
6
|
import { t as runTaskQueue } from "./task-queue-DbpZAp6C.js";
|
|
7
|
-
import {
|
|
8
|
-
import { a as errMessage, f as defaultRedactor, i as causeChain, l as errorText, n as detachedSnapshot,
|
|
7
|
+
import { At as sandboxTerminalUsageField, Ct as createSandboxUsageLedger, D as cappedDoublingMs, Dt as sameModelId, Et as notifySandboxEventObserver, G as turnFailureOf, J as hashJson, M as unavailablePauseMs, N as unavailableResumeAt, Nt as parseCodexUsageRecord, Ot as sandboxEventProviderModels, P as unavailableSignalOfFailure, Pt as recordValue, R as contentAddress, St as createSandboxTurnEventCollector, Tt as isSandboxTerminalEvent, W as runtimeFailureRemediationSchema, X as isCredentialRefusal, bt as assertSandboxServedModel, d as RetainedExecutionPendingError, ht as sandboxProgressEvents, i as runtimeFailureCause, j as reportedResetAt, k as placementRefusal, kt as sandboxEventServedBackend, mt as sandboxOutputMarker, nt as createBudgetPool, o as runtimeProviderCode, pt as sandboxLeafOutputFromEvents, q as turnRemediationOf, r as reportedFailureCause, ut as createSandboxToolPartState, vt as extractTransportEventIdentity, x as retainedExecutorContext, xt as canonicalSandboxUsageMode, z as contentRef } from "./tool-server-n4XYpCok.js";
|
|
8
|
+
import { a as errMessage, f as defaultRedactor, i as causeChain, l as errorText, n as detachedSnapshot, s as errorProperty, t as detachedFrozen } from "./snapshot-BKLziJ5K.js";
|
|
9
9
|
import { _ as reportedServedModel, a as concreteProfileModel, c as profileModelExecutionSettings, d as assertRouterAutoDeclaration, f as assertRouterAutoResponse, g as observedModelMatchesDeclared, l as profileProviderModel, m as mergeObservedModelIdentity, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile, u as resolveRouterRetryPolicy, v as agentHarness } from "./model-policy-DFuhCC0-.js";
|
|
10
10
|
import { r as nativeSystemPrompt, t as assertSandboxProfileCompatibility } from "./sandbox-profile-compat-l-SLQnGb.js";
|
|
11
11
|
import { x as hasControlCharacter } from "./workspace-streams-C7PGLAUd.js";
|
|
12
|
-
import { i as checkVerdictOf, s as isFiniteNumber } from "./continuation-CDdjAkpk.js";
|
|
13
12
|
import { r as appendRunLines, u as writeAtomicDurableFile } from "./durable-file-pao7FijS.js";
|
|
14
|
-
import { t as PROTOCOL_VERSION } from "./tool-server-BhsyVDj2.js";
|
|
15
13
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
|
|
16
|
-
import { n as encodeResultBlob } from "./result-blob-store-
|
|
17
|
-
import { a as recordRootReentered, c as rootMaterializationReceipt, i as changesRootProfile, l as rootStartedAtMs, o as recordRootSegment, r as assertRootIdentity, s as rootExecutionBindingReceipt, t as assertResumeContract } from "./supervisor-root-contract-
|
|
14
|
+
import { n as encodeResultBlob } from "./result-blob-store-CJjp44Mz.js";
|
|
15
|
+
import { a as recordRootReentered, c as rootMaterializationReceipt, i as changesRootProfile, l as rootStartedAtMs, o as recordRootSegment, r as assertRootIdentity, s as rootExecutionBindingReceipt, t as assertResumeContract } from "./supervisor-root-contract-BCbu1A4n.js";
|
|
18
16
|
import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentExactRunControlRefSchema, AgentFileOutputPolicySchema, AgentRetainedFilePublicationSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, REASONING_EFFORTS, WorkspaceCheckpointRefSchema, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, harnessTypeSchema, mergeProxySecretBindings, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sameAgentRunControlRef, workspaceCwdPathForBase } from "@tangle-network/agent-interface";
|
|
19
17
|
import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
20
18
|
import { SDKError, generateIdempotencyKey, isRecord, withRetry } from "@tangle-network/agent-core";
|
|
@@ -4794,586 +4792,6 @@ var BridgeTurnSignals = class {
|
|
|
4794
4792
|
if (this.silenceTimer !== void 0) clearTimeout(this.silenceTimer);
|
|
4795
4793
|
}
|
|
4796
4794
|
};
|
|
4797
|
-
// src/runtime/supervise/completion-gate.ts
|
|
4798
|
-
/**
|
|
4799
|
-
* Wrap an `Executor` so its settlement `valid` reflects the deliverable check, not the
|
|
4800
|
-
* inner verdict. Handles both `execute` shapes (one-shot `Promise<ExecutorResult>` and
|
|
4801
|
-
* streaming `AsyncIterable<UsageEvent>` + `resultArtifact()`); the check runs once the inner
|
|
4802
|
-
* executor has produced its output. The inner `score` is preserved; only `valid` is gated.
|
|
4803
|
-
*/
|
|
4804
|
-
function gateOnDeliverable(inner, deliverable) {
|
|
4805
|
-
return wrapCompletionGate(inner, (result) => checkDeliverable(deliverable, result));
|
|
4806
|
-
}
|
|
4807
|
-
/** Build a worker with the same check on durable acceptance and normal completion. @internal */
|
|
4808
|
-
function gateFactoryOnDeliverable(factory, deliverable) {
|
|
4809
|
-
return (spec, ctx) => {
|
|
4810
|
-
const profile = detachedSnapshot(spec.profile, "completion check profile");
|
|
4811
|
-
const node = ctx.node === void 0 ? void 0 : detachedSnapshot(ctx.node, "completion check node");
|
|
4812
|
-
const retention = retainedExecutorContext(ctx);
|
|
4813
|
-
const verdicts = /* @__PURE__ */ new WeakMap();
|
|
4814
|
-
const check = (result) => {
|
|
4815
|
-
let verdict = verdicts.get(result);
|
|
4816
|
-
if (verdict === void 0) {
|
|
4817
|
-
verdict = checkDeliverable(deliverable, result, Object.freeze({
|
|
4818
|
-
profile,
|
|
4819
|
-
node,
|
|
4820
|
-
signal: ctx.signal,
|
|
4821
|
-
originalVerdict: result.verdict === void 0 ? void 0 : detachedSnapshot(result.verdict, "completion check original verdict")
|
|
4822
|
-
}));
|
|
4823
|
-
verdicts.set(result, verdict);
|
|
4824
|
-
}
|
|
4825
|
-
return verdict;
|
|
4826
|
-
};
|
|
4827
|
-
if (retention === void 0) return wrapCompletionGate(factory(spec, ctx), check);
|
|
4828
|
-
const checkedRetention = (source) => ({
|
|
4829
|
-
...source,
|
|
4830
|
-
onResult: async (result) => source.onResult({
|
|
4831
|
-
...result,
|
|
4832
|
-
verdict: await check(result)
|
|
4833
|
-
}),
|
|
4834
|
-
...source.continueInvocation === void 0 ? {} : { continueInvocation: async (task) => checkedRetention(await source.continueInvocation(task)) }
|
|
4835
|
-
});
|
|
4836
|
-
return wrapCompletionGate(factory(spec, {
|
|
4837
|
-
...ctx,
|
|
4838
|
-
seams: {
|
|
4839
|
-
...ctx.seams,
|
|
4840
|
-
[retainedExecutorSeamKey]: checkedRetention(retention)
|
|
4841
|
-
}
|
|
4842
|
-
}), check);
|
|
4843
|
-
};
|
|
4844
|
-
}
|
|
4845
|
-
async function checkDeliverable(deliverable, result, context) {
|
|
4846
|
-
let delivered;
|
|
4847
|
-
try {
|
|
4848
|
-
delivered = checkVerdictOf(await deliverable.check(result.out, context)).pass;
|
|
4849
|
-
} catch {
|
|
4850
|
-
delivered = false;
|
|
4851
|
-
}
|
|
4852
|
-
return {
|
|
4853
|
-
valid: delivered,
|
|
4854
|
-
score: result.verdict?.score ?? (delivered ? 1 : 0)
|
|
4855
|
-
};
|
|
4856
|
-
}
|
|
4857
|
-
function wrapCompletionGate(inner, check) {
|
|
4858
|
-
let gated;
|
|
4859
|
-
/**
|
|
4860
|
-
* Ask the delivery question once, from whatever the inner executor managed to produce.
|
|
4861
|
-
*
|
|
4862
|
-
* Fail-closed on the artifact being unavailable: an executor that never produced one delivered
|
|
4863
|
-
* nothing, and leaving `gated` unset keeps the existing invalid-by-default reading.
|
|
4864
|
-
*/
|
|
4865
|
-
const settleVerdict = async () => {
|
|
4866
|
-
let art;
|
|
4867
|
-
try {
|
|
4868
|
-
art = inner.resultArtifact();
|
|
4869
|
-
} catch {
|
|
4870
|
-
return;
|
|
4871
|
-
}
|
|
4872
|
-
gated = await check(art);
|
|
4873
|
-
};
|
|
4874
|
-
const gateExecution = (r) => {
|
|
4875
|
-
if (isAsyncIterable(r)) return (async function* () {
|
|
4876
|
-
try {
|
|
4877
|
-
for await (const ev of r) yield ev;
|
|
4878
|
-
} finally {
|
|
4879
|
-
await settleVerdict();
|
|
4880
|
-
}
|
|
4881
|
-
})();
|
|
4882
|
-
return (async () => {
|
|
4883
|
-
let res;
|
|
4884
|
-
try {
|
|
4885
|
-
res = await r;
|
|
4886
|
-
} catch (error) {
|
|
4887
|
-
await settleVerdict();
|
|
4888
|
-
throw error;
|
|
4889
|
-
}
|
|
4890
|
-
gated = await check(res);
|
|
4891
|
-
return {
|
|
4892
|
-
...res,
|
|
4893
|
-
verdict: gated
|
|
4894
|
-
};
|
|
4895
|
-
})();
|
|
4896
|
-
};
|
|
4897
|
-
const wrapped = {
|
|
4898
|
-
runtime: inner.runtime,
|
|
4899
|
-
...inner.budgetExempt !== void 0 ? { budgetExempt: inner.budgetExempt } : {},
|
|
4900
|
-
...inner.deliver ? { deliver: (m) => inner.deliver?.(m) } : {},
|
|
4901
|
-
...inner.cancel ? { cancel: (request) => inner.cancel(request) } : {},
|
|
4902
|
-
...inner.interactive ? { interactive: () => inner.interactive() } : {},
|
|
4903
|
-
...inner.interactiveReady ? { interactiveReady: () => inner.interactiveReady() } : {},
|
|
4904
|
-
...inner.progress ? { progress: () => inner.progress?.() } : {},
|
|
4905
|
-
...inner.traceSource ? { traceSource: () => inner.traceSource?.() } : {},
|
|
4906
|
-
...inner.metered ? { metered: () => inner.metered?.() } : {},
|
|
4907
|
-
...inner.accounting ? { accounting: () => inner.accounting?.() } : {},
|
|
4908
|
-
...inner.resultAccepted ? { resultAccepted: () => inner.resultAccepted?.() === true } : {},
|
|
4909
|
-
...inner.harnessTranscript ? { harnessTranscript: () => inner.harnessTranscript?.() } : {},
|
|
4910
|
-
...inner.harnessTranscriptSettled ? { harnessTranscriptSettled: () => inner.harnessTranscriptSettled?.() ?? Promise.resolve() } : {},
|
|
4911
|
-
execute: (task, signal) => gateExecution(inner.execute(task, signal)),
|
|
4912
|
-
...inner.recover ? { recover: (task, signal) => gateExecution(inner.recover(task, signal)) } : {},
|
|
4913
|
-
teardown: (grace) => inner.teardown(grace),
|
|
4914
|
-
...teardownSurfaces(inner),
|
|
4915
|
-
resultArtifact() {
|
|
4916
|
-
const art = inner.resultArtifact();
|
|
4917
|
-
return {
|
|
4918
|
-
...art,
|
|
4919
|
-
verdict: gated ?? art.verdict
|
|
4920
|
-
};
|
|
4921
|
-
}
|
|
4922
|
-
};
|
|
4923
|
-
return inheritRuntimeOwnedExecutorAttestation(inner, wrapped);
|
|
4924
|
-
}
|
|
4925
|
-
/**
|
|
4926
|
-
* Transform a Runtime executor's terminal artifact without losing its private
|
|
4927
|
-
* profile-materialization attestation or altering its measured spend. This is
|
|
4928
|
-
* the composition point for deterministic post-processing and grading; callers
|
|
4929
|
-
* must not rebuild an Executor around a model transport merely to change `out`.
|
|
4930
|
-
*/
|
|
4931
|
-
function mapExecutorResult(inner, map) {
|
|
4932
|
-
let mapped;
|
|
4933
|
-
const settle = async (result, task) => {
|
|
4934
|
-
const transformed = await map(result, task);
|
|
4935
|
-
mapped = {
|
|
4936
|
-
outRef: transformed.outRef,
|
|
4937
|
-
out: transformed.out,
|
|
4938
|
-
...transformed.verdict ? { verdict: transformed.verdict } : {},
|
|
4939
|
-
spent: result.spent
|
|
4940
|
-
};
|
|
4941
|
-
return mapped;
|
|
4942
|
-
};
|
|
4943
|
-
const mapExecution = (execution, task) => {
|
|
4944
|
-
if (isAsyncIterable(execution)) return (async function* () {
|
|
4945
|
-
for await (const event of execution) yield event;
|
|
4946
|
-
await settle(inner.resultArtifact(), task);
|
|
4947
|
-
})();
|
|
4948
|
-
return (async () => settle(await execution, task))();
|
|
4949
|
-
};
|
|
4950
|
-
const wrapped = {
|
|
4951
|
-
runtime: inner.runtime,
|
|
4952
|
-
...inner.budgetExempt !== void 0 ? { budgetExempt: inner.budgetExempt } : {},
|
|
4953
|
-
...inner.deliver ? { deliver: (message) => inner.deliver?.(message) } : {},
|
|
4954
|
-
...inner.cancel ? { cancel: (request) => inner.cancel(request) } : {},
|
|
4955
|
-
...inner.interactive ? { interactive: () => inner.interactive() } : {},
|
|
4956
|
-
...inner.interactiveReady ? { interactiveReady: () => inner.interactiveReady() } : {},
|
|
4957
|
-
...inner.progress ? { progress: () => inner.progress?.() } : {},
|
|
4958
|
-
...inner.traceSource ? { traceSource: () => inner.traceSource?.() } : {},
|
|
4959
|
-
...inner.accounting ? { accounting: () => inner.accounting?.() } : {},
|
|
4960
|
-
...inner.metered ? { metered: () => inner.metered?.() } : {},
|
|
4961
|
-
...inner.harnessTranscript ? { harnessTranscript: () => inner.harnessTranscript?.() } : {},
|
|
4962
|
-
...inner.harnessTranscriptSettled ? { harnessTranscriptSettled: () => inner.harnessTranscriptSettled?.() ?? Promise.resolve() } : {},
|
|
4963
|
-
execute: (task, signal) => mapExecution(inner.execute(task, signal), task),
|
|
4964
|
-
...inner.recover ? { recover: (task, signal) => mapExecution(inner.recover(task, signal), task) } : {},
|
|
4965
|
-
teardown: (grace) => inner.teardown(grace),
|
|
4966
|
-
...teardownSurfaces(inner),
|
|
4967
|
-
resultArtifact() {
|
|
4968
|
-
if (!mapped) throw new Error("mapExecutorResult: resultArtifact() read before execute()");
|
|
4969
|
-
return mapped;
|
|
4970
|
-
}
|
|
4971
|
-
};
|
|
4972
|
-
return inheritRuntimeOwnedExecutorAttestation(inner, wrapped);
|
|
4973
|
-
}
|
|
4974
|
-
/**
|
|
4975
|
-
* The check could not run: its box did not start, its judge's provider refused, its program
|
|
4976
|
-
* crashed. It is not a verdict on the result. Inside a run the loop pauses, as it does for an
|
|
4977
|
-
* unavailable upstream, and the refusal tells the director its result was not judged.
|
|
4978
|
-
*/
|
|
4979
|
-
var CheckUnavailableError = class extends Error {
|
|
4980
|
-
constructor(message, options) {
|
|
4981
|
-
super(message, options);
|
|
4982
|
-
this.name = "CheckUnavailableError";
|
|
4983
|
-
}
|
|
4984
|
-
};
|
|
4985
|
-
/**
|
|
4986
|
-
* Read an agent-eval `JudgeScore` from a check program into a verdict.
|
|
4987
|
-
*
|
|
4988
|
-
* Each dimension is a checked item. `notes` lines that start with `FAIL ` are the failures; the
|
|
4989
|
-
* remaining lines are the check's review. The verdict passes when `composite >= threshold` and the
|
|
4990
|
-
* score is not marked `failed`; a `failed` score means the judge itself did not run, which is
|
|
4991
|
-
* {@link CheckUnavailableError}, not a verdict.
|
|
4992
|
-
*/
|
|
4993
|
-
function verdictFromJudgeScore(score, threshold) {
|
|
4994
|
-
if (score.failed === true) throw new CheckUnavailableError(`the check's judge did not run: ${score.notes}`);
|
|
4995
|
-
const lines = score.notes.split("\n").map((line) => line.trimEnd());
|
|
4996
|
-
const failures = lines.filter((line) => line.startsWith("FAIL "));
|
|
4997
|
-
const review = lines.filter((line) => !line.startsWith("FAIL ") && line.trim() !== "").join("\n");
|
|
4998
|
-
return checkVerdictOf({
|
|
4999
|
-
pass: score.composite >= threshold,
|
|
5000
|
-
items: score.dimensions,
|
|
5001
|
-
composite: score.composite,
|
|
5002
|
-
threshold,
|
|
5003
|
-
failures,
|
|
5004
|
-
...review === "" ? {} : { review }
|
|
5005
|
-
});
|
|
5006
|
-
}
|
|
5007
|
-
// src/runtime/supervise/coordination-preflight.ts
|
|
5008
|
-
const MAX_RESPONSE_BYTES = 1048576;
|
|
5009
|
-
var CoordinationPreflightError = class extends ConfigError {
|
|
5010
|
-
constructor(reason) {
|
|
5011
|
-
super(`coordination public endpoint preflight failed: ${reason}`);
|
|
5012
|
-
}
|
|
5013
|
-
};
|
|
5014
|
-
/**
|
|
5015
|
-
* The route timed out, lost its socket, or answered 408, 429 or 5xx: it cannot serve now, so a
|
|
5016
|
-
* manager waits for it as for any unavailable upstream. magnetar-rust-sandbox-20261101b's :s2:s2
|
|
5017
|
-
* and :s1:s1 settled down on `timed out` while drew-gtr-pro, which serves the route, ran at load 25.
|
|
5018
|
-
*/
|
|
5019
|
-
var CoordinationUnreachableError = class extends Error {
|
|
5020
|
-
name = "CoordinationUnreachableError";
|
|
5021
|
-
};
|
|
5022
|
-
const unreachable = (reason) => new CoordinationUnreachableError(`coordination public endpoint preflight failed: ${reason}`);
|
|
5023
|
-
function record(value) {
|
|
5024
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5025
|
-
}
|
|
5026
|
-
/** Check the operator's route before it becomes a provider attachment. This does not prove cloud egress. */
|
|
5027
|
-
async function preflightPublicCoordination(input) {
|
|
5028
|
-
const deadline = new AbortController();
|
|
5029
|
-
const linked = linkAbort(input.signal, deadline.signal);
|
|
5030
|
-
const timer = setTimeout(() => deadline.abort(), input.requestTimeoutMs);
|
|
5031
|
-
timer.unref();
|
|
5032
|
-
const rpc = async (method, params) => {
|
|
5033
|
-
const response = await fetch(input.url, {
|
|
5034
|
-
method: "POST",
|
|
5035
|
-
headers: {
|
|
5036
|
-
...input.headers,
|
|
5037
|
-
"content-type": "application/json",
|
|
5038
|
-
accept: "application/json"
|
|
5039
|
-
},
|
|
5040
|
-
body: JSON.stringify({
|
|
5041
|
-
jsonrpc: "2.0",
|
|
5042
|
-
id: method,
|
|
5043
|
-
method,
|
|
5044
|
-
...params ? { params } : {}
|
|
5045
|
-
}),
|
|
5046
|
-
redirect: "manual",
|
|
5047
|
-
signal: linked.signal
|
|
5048
|
-
});
|
|
5049
|
-
if (response.status !== 200) {
|
|
5050
|
-
response.body?.cancel().catch(() => void 0);
|
|
5051
|
-
const { status } = response;
|
|
5052
|
-
if (status === 408 || status === 429 || status >= 500) throw unreachable(`HTTP ${status}`);
|
|
5053
|
-
throw new CoordinationPreflightError(`HTTP ${status}`);
|
|
5054
|
-
}
|
|
5055
|
-
const reader = response.body?.getReader();
|
|
5056
|
-
if (!reader) throw new CoordinationPreflightError("invalid MCP response");
|
|
5057
|
-
let size = 0;
|
|
5058
|
-
const chunks = [];
|
|
5059
|
-
try {
|
|
5060
|
-
for (;;) {
|
|
5061
|
-
const part = await reader.read();
|
|
5062
|
-
if (part.done) break;
|
|
5063
|
-
size += part.value.byteLength;
|
|
5064
|
-
if (size > MAX_RESPONSE_BYTES) {
|
|
5065
|
-
reader.cancel().catch(() => void 0);
|
|
5066
|
-
throw new CoordinationPreflightError("response too large");
|
|
5067
|
-
}
|
|
5068
|
-
chunks.push(part.value);
|
|
5069
|
-
}
|
|
5070
|
-
} finally {
|
|
5071
|
-
reader.releaseLock();
|
|
5072
|
-
}
|
|
5073
|
-
let body;
|
|
5074
|
-
try {
|
|
5075
|
-
body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks)));
|
|
5076
|
-
} catch {
|
|
5077
|
-
throw new CoordinationPreflightError("invalid MCP response");
|
|
5078
|
-
}
|
|
5079
|
-
if (!record(body) || body.jsonrpc !== "2.0" || body.id !== method || body.error || !record(body.result)) throw new CoordinationPreflightError("invalid MCP response");
|
|
5080
|
-
return body.result;
|
|
5081
|
-
};
|
|
5082
|
-
try {
|
|
5083
|
-
await runAbortable(async () => {
|
|
5084
|
-
const initialized = await rpc("initialize", {
|
|
5085
|
-
protocolVersion: PROTOCOL_VERSION,
|
|
5086
|
-
capabilities: {},
|
|
5087
|
-
clientInfo: {
|
|
5088
|
-
name: "agent-runtime-coordination-preflight",
|
|
5089
|
-
version: "1"
|
|
5090
|
-
}
|
|
5091
|
-
});
|
|
5092
|
-
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");
|
|
5093
|
-
const listing = await rpc("tools/list");
|
|
5094
|
-
if (!Array.isArray(listing.tools) || listing.tools.some((tool) => !record(tool) || typeof tool.name !== "string")) throw new CoordinationPreflightError("invalid MCP tool list");
|
|
5095
|
-
const names = listing.tools.map((tool) => tool.name).sort();
|
|
5096
|
-
if (JSON.stringify(names) !== JSON.stringify([...input.toolNames].sort())) throw new CoordinationPreflightError("coordination tool grants differ");
|
|
5097
|
-
}, linked.signal, "coordination public endpoint preflight cancelled");
|
|
5098
|
-
} catch (error) {
|
|
5099
|
-
if (input.signal.aborted) throw new CoordinationPreflightError("cancelled");
|
|
5100
|
-
if (deadline.signal.aborted) throw unreachable("timed out");
|
|
5101
|
-
if (error instanceof CoordinationPreflightError) throw error;
|
|
5102
|
-
if (error instanceof CoordinationUnreachableError) throw error;
|
|
5103
|
-
if (causeChain(error).some((cause) => TRANSPORT_ERROR_CODES.has(String(Object(cause).code)))) throw unreachable("transport unavailable");
|
|
5104
|
-
throw new CoordinationPreflightError("transport unavailable");
|
|
5105
|
-
} finally {
|
|
5106
|
-
clearTimeout(timer);
|
|
5107
|
-
linked.release();
|
|
5108
|
-
}
|
|
5109
|
-
}
|
|
5110
|
-
// src/runtime/supervise/driver-attempt-evidence.ts
|
|
5111
|
-
/** Sandbox's `PartialFailureError` on `error` or a cause, read by name: packages that hold their own
|
|
5112
|
-
* copy of the class would miss an `instanceof`. */
|
|
5113
|
-
const causedByPartialFailure = (error) => causeChain(error).some((cause) => cause instanceof Error && errorProperty(cause, "name") === "PartialFailureError");
|
|
5114
|
-
/** Abandon only `unobservable` or `nested-recovery`. Transport and capacity stay; a refused request and a contract violation do not start a second execution. */
|
|
5115
|
-
function abandonablePending(error) {
|
|
5116
|
-
return error instanceof RetainedExecutionPendingError && (error.pendingCause === "unobservable" || error.pendingCause === "nested-recovery") ? error : void 0;
|
|
5117
|
-
}
|
|
5118
|
-
/** Deterministic bridge refusals remain terminal even when transport omits HTTP status. */
|
|
5119
|
-
const DETERMINISTIC_BRIDGE_CODES = /* @__PURE__ */ new Set([
|
|
5120
|
-
"parse_error",
|
|
5121
|
-
"not_configured",
|
|
5122
|
-
"capability_denied",
|
|
5123
|
-
"MODEL_NOT_FOUND",
|
|
5124
|
-
"SEAT_NOT_LOGGED_IN"
|
|
5125
|
-
]);
|
|
5126
|
-
/** Content-filter text under `AGENT_EXECUTION_FAILED` stays transient; a streak of it stops for the parent to reword. */
|
|
5127
|
-
const CONTENT_FILTER_REASON = "refused by the model provider's content filter";
|
|
5128
|
-
const isContentFilterRefusal = (error) => causeChain(error).some((cause) => cause instanceof Error && /\bcontent was flagged for possible\b/iu.test(errorProperty(cause, "message") ?? ""));
|
|
5129
|
-
/** A completed failed turn enters retry with its producer classification and legacy metadata intact. */
|
|
5130
|
-
var HarnessTurnFailedError = class extends Error {
|
|
5131
|
-
runtime;
|
|
5132
|
-
/** The failure as the harness reported it, before this error's framing. */
|
|
5133
|
-
reported;
|
|
5134
|
-
errorCode;
|
|
5135
|
-
statusCode;
|
|
5136
|
-
/** The shared HTTP error reader also uses this status for persisted diagnostics. */
|
|
5137
|
-
status;
|
|
5138
|
-
failure;
|
|
5139
|
-
/** The producer's quota reset, which `reportedResetAt` holds a capacity pause to. */
|
|
5140
|
-
resetAt;
|
|
5141
|
-
constructor(runtime, failure) {
|
|
5142
|
-
super(`${runtime} harness turn ended with a failed outcome` + (failure.errorCode === void 0 ? "" : ` (${failure.errorCode})`) + `: ${failure.error}`);
|
|
5143
|
-
this.name = "HarnessTurnFailedError";
|
|
5144
|
-
this.runtime = runtime;
|
|
5145
|
-
this.reported = failure.error;
|
|
5146
|
-
if (failure.failure !== void 0) this.failure = failure.failure;
|
|
5147
|
-
if (failure.errorCode !== void 0) this.errorCode = failure.errorCode;
|
|
5148
|
-
if (failure.resetAt !== void 0) this.resetAt = failure.resetAt;
|
|
5149
|
-
if (failure.statusCode !== void 0) {
|
|
5150
|
-
this.statusCode = failure.statusCode;
|
|
5151
|
-
this.status = failure.statusCode;
|
|
5152
|
-
}
|
|
5153
|
-
}
|
|
5154
|
-
};
|
|
5155
|
-
/** Provider schemas and JSON bounds reject the request deterministically. */
|
|
5156
|
-
function isProviderSchemaRejection(error) {
|
|
5157
|
-
try {
|
|
5158
|
-
return error.name === "ValidationError" || isSchemaRejection(error);
|
|
5159
|
-
} catch {
|
|
5160
|
-
return false;
|
|
5161
|
-
}
|
|
5162
|
-
}
|
|
5163
|
-
/** Sandbox started nothing for the dispatch: another execution owns the session or turn. */
|
|
5164
|
-
function isDispatchNotAdmitted(error) {
|
|
5165
|
-
try {
|
|
5166
|
-
return Reflect.get(error, "code") === DISPATCH_NOT_ADMITTED_CODE;
|
|
5167
|
-
} catch {
|
|
5168
|
-
return false;
|
|
5169
|
-
}
|
|
5170
|
-
}
|
|
5171
|
-
/** Sandbox confirmed the dispatch but named a different execution: deterministic on every retry. */
|
|
5172
|
-
function isDispatchExecutionChanged(value) {
|
|
5173
|
-
try {
|
|
5174
|
-
return Reflect.get(value, "code") === DISPATCH_EXECUTION_CHANGED_CODE;
|
|
5175
|
-
} catch {
|
|
5176
|
-
return false;
|
|
5177
|
-
}
|
|
5178
|
-
}
|
|
5179
|
-
/** Read Runtime admission evidence before producer hints and legacy transport metadata. */
|
|
5180
|
-
function upstreamUnavailableSignal(error) {
|
|
5181
|
-
if (undispatchedCredentialExit(error) !== void 0) return "credential-unavailable";
|
|
5182
|
-
if (error instanceof CheckUnavailableError) return "check-unavailable";
|
|
5183
|
-
if (error instanceof CoordinationUnreachableError) return "coordination-unreachable";
|
|
5184
|
-
const typed = turnFailureOf(error);
|
|
5185
|
-
if (typed) return turnFailurePolicy(typed).classification === "unavailable" ? subscriptionUsageLimitSignal({
|
|
5186
|
-
error: "",
|
|
5187
|
-
errorCode: typed.code
|
|
5188
|
-
}) ?? typed.code : void 0;
|
|
5189
|
-
const refusal = retainedAdmissionCause(error) ?? reconciliationCapacityRefusal(error);
|
|
5190
|
-
if (refusal !== void 0) return upstreamUnavailableSignal(refusal);
|
|
5191
|
-
if (!(error instanceof Error)) return void 0;
|
|
5192
|
-
if (isCredentialRefusal(error)) return void 0;
|
|
5193
|
-
if (isProviderSchemaRejection(error)) return void 0;
|
|
5194
|
-
const transport = error instanceof BackendTransportError;
|
|
5195
|
-
if (error instanceof AgentEvalError && !transport) return void 0;
|
|
5196
|
-
const harness = error instanceof HarnessTurnFailedError;
|
|
5197
|
-
const failure = {
|
|
5198
|
-
error: errorProperty(error, "message") ?? "",
|
|
5199
|
-
errorCode: harness ? error.errorCode : transport ? error.upstreamCode : ownCode(error),
|
|
5200
|
-
statusCode: errorHttpStatus(error)
|
|
5201
|
-
};
|
|
5202
|
-
return (harness ? subscriptionUsageLimitSignal(failure) : void 0) ?? unavailableSignalOfFailure(failure);
|
|
5203
|
-
}
|
|
5204
|
-
function materializationTimedOut(error) {
|
|
5205
|
-
return causeChain(error).some((cause) => cause instanceof Error && errorProperty(cause, "name") === "RetainedMaterializationTimeoutError");
|
|
5206
|
-
}
|
|
5207
|
-
/** Capacity encountered while reconciling an admitted execution pauses that same execution. */
|
|
5208
|
-
function reconciliationCapacityRefusal(error) {
|
|
5209
|
-
if (!(error instanceof RetainedExecutionPendingError) || error.phase !== "execution") return void 0;
|
|
5210
|
-
if (error.pendingCause !== "unobservable" && error.pendingCause !== "transport") return void 0;
|
|
5211
|
-
return causeChain(error.cause).find((cause) => cause instanceof Error && (UNAVAILABLE_CODES.has(ownCode(cause)?.toLowerCase() ?? "") || errorHttpStatus(cause) === 429));
|
|
5212
|
-
}
|
|
5213
|
-
/** An error's own `code` field, read without trusting its getter: agent-provider-tangle's
|
|
5214
|
-
* `TangleCredentialCapacityError` carries the router's code even with no HTTP status. */
|
|
5215
|
-
function ownCode(error) {
|
|
5216
|
-
try {
|
|
5217
|
-
const code = Reflect.get(error, "code");
|
|
5218
|
-
return typeof code === "string" ? code : void 0;
|
|
5219
|
-
} catch {
|
|
5220
|
-
return;
|
|
5221
|
-
}
|
|
5222
|
-
}
|
|
5223
|
-
/** Runtime cancellation/contracts dominate producer policy; untyped foreign failures retain legacy rules. */
|
|
5224
|
-
function classifyDriverFailure(error, signal, stopSignal) {
|
|
5225
|
-
if (signal?.aborted) return "terminal";
|
|
5226
|
-
if (materializationTimedOut(error)) return "terminal";
|
|
5227
|
-
if (error instanceof CheckUnavailableError || error instanceof CoordinationUnreachableError) return "unavailable";
|
|
5228
|
-
if (error instanceof RetainedExecutionPendingError && (error.pendingCause === "provider-contract" || causeChain(error.cause).some((cause) => {
|
|
5229
|
-
try {
|
|
5230
|
-
return cause instanceof Error && !UNAVAILABLE_CODES.has(ownCode(cause)?.toLowerCase() ?? "") && (Reflect.get(cause, "retryable") === false || [401, 403].includes(errorHttpStatus(cause) ?? 0));
|
|
5231
|
-
} catch {
|
|
5232
|
-
return false;
|
|
5233
|
-
}
|
|
5234
|
-
}))) return "terminal";
|
|
5235
|
-
if (undispatchedCredentialExit(error) !== void 0) return "unavailable";
|
|
5236
|
-
const admission = retainedAdmissionCause(error);
|
|
5237
|
-
if (admission !== void 0 && isDispatchNotAdmitted(admission)) return "terminal";
|
|
5238
|
-
if (causeChain(error).some(isDispatchExecutionChanged)) return "terminal";
|
|
5239
|
-
if (admission !== void 0) return classifyDriverFailure(admission, signal, stopSignal);
|
|
5240
|
-
if (error instanceof Error && errorProperty(error, "name") === "AbortError") return stopSignal?.aborted === true ? "terminal" : "transient";
|
|
5241
|
-
if (error instanceof Error && isProviderSchemaRejection(error)) return "terminal";
|
|
5242
|
-
if (isCredentialRefusal(error)) return "terminal";
|
|
5243
|
-
if (causeChain(error).some(isProvisioningRefusal)) return "terminal";
|
|
5244
|
-
if (error instanceof AgentEvalError && !(error instanceof BackendTransportError)) return "terminal";
|
|
5245
|
-
const typed = turnFailureOf(error);
|
|
5246
|
-
if (typed) return turnFailurePolicy(typed).classification;
|
|
5247
|
-
if (error instanceof HarnessTurnFailedError) {
|
|
5248
|
-
if (error.errorCode !== void 0 && DETERMINISTIC_BRIDGE_CODES.has(error.errorCode)) return "terminal";
|
|
5249
|
-
if (upstreamUnavailableSignal(error) !== void 0) return "unavailable";
|
|
5250
|
-
return foreignHttpStatusVerdict(error) ?? "transient";
|
|
5251
|
-
}
|
|
5252
|
-
if (error instanceof BackendTransportError) {
|
|
5253
|
-
if (error.upstreamCode !== void 0 && DETERMINISTIC_BRIDGE_CODES.has(error.upstreamCode)) return "terminal";
|
|
5254
|
-
if (upstreamUnavailableSignal(error) !== void 0) return "unavailable";
|
|
5255
|
-
const status = error.status;
|
|
5256
|
-
return status === void 0 || status === 408 || status >= 500 ? "transient" : "terminal";
|
|
5257
|
-
}
|
|
5258
|
-
if (upstreamUnavailableSignal(error) !== void 0) return "unavailable";
|
|
5259
|
-
return foreignHttpStatusVerdict(error) ?? "transient";
|
|
5260
|
-
}
|
|
5261
|
-
/** The credential command's exit code when it failed before Runtime journaled a dispatch: no
|
|
5262
|
-
* provider execution id exists, so nothing ran ({@link credentialCommandExit}). */
|
|
5263
|
-
function undispatchedCredentialExit(error) {
|
|
5264
|
-
return error instanceof RetainedExecutionPendingError && error.phase === "admission" && error.pendingCause === "unobservable" ? credentialCommandExit(error.cause) : void 0;
|
|
5265
|
-
}
|
|
5266
|
-
/** Admission refusals keep the original HTTP rules without interpreting failures after execution starts. */
|
|
5267
|
-
function retainedAdmissionCause(error) {
|
|
5268
|
-
if (!(error instanceof RetainedExecutionPendingError) || error.phase !== "admission" || error.pendingCause !== "request-rejected" && error.pendingCause !== "transport") return void 0;
|
|
5269
|
-
const queue = [];
|
|
5270
|
-
try {
|
|
5271
|
-
queue.push(error.cause);
|
|
5272
|
-
} catch {
|
|
5273
|
-
return;
|
|
5274
|
-
}
|
|
5275
|
-
const seen = /* @__PURE__ */ new Set();
|
|
5276
|
-
for (let steps = 0; queue.length > 0 && steps < 12; steps += 1) {
|
|
5277
|
-
const value = queue.shift();
|
|
5278
|
-
try {
|
|
5279
|
-
if (!(value instanceof Error) || seen.has(value)) continue;
|
|
5280
|
-
seen.add(value);
|
|
5281
|
-
if (value instanceof RetainedExecutionPendingError) {
|
|
5282
|
-
if (value.phase !== "admission" || value.pendingCause !== "request-rejected" && value.pendingCause !== "transport") return void 0;
|
|
5283
|
-
queue.push(value.cause);
|
|
5284
|
-
continue;
|
|
5285
|
-
}
|
|
5286
|
-
if (errorProperty(value, "name") === "RetainedRunProviderContractError") return void 0;
|
|
5287
|
-
const status = errorHttpStatus(value);
|
|
5288
|
-
if (status !== void 0 && status >= 400) return error.pendingCause === "request-rejected" || UNAVAILABLE_STATUSES.has(status) ? value : void 0;
|
|
5289
|
-
if (error.pendingCause === "request-rejected" && (value instanceof AgentEvalError || isProviderSchemaRejection(value) || isDispatchNotAdmitted(value) || isCredentialRefusal(value) || UNAVAILABLE_CODES.has(ownCode(value)?.toLowerCase() ?? ""))) return value;
|
|
5290
|
-
const members = Reflect.get(value, "errors");
|
|
5291
|
-
if (Array.isArray(members)) queue.push(...members.slice(0, 12 - steps));
|
|
5292
|
-
queue.push(value.cause);
|
|
5293
|
-
} catch {
|
|
5294
|
-
return;
|
|
5295
|
-
}
|
|
5296
|
-
}
|
|
5297
|
-
}
|
|
5298
|
-
/** 408 and 5xx are transient. Any other 4xx fails identically, including a sandbox `CONFIG_ERROR`. Capacity was already classified. */
|
|
5299
|
-
function foreignHttpStatusVerdict(error) {
|
|
5300
|
-
if (!(error instanceof Error)) return void 0;
|
|
5301
|
-
const status = errorHttpStatus(error);
|
|
5302
|
-
if (status === void 0 || status < 400) return void 0;
|
|
5303
|
-
if (status === 408 || status >= 500) return "transient";
|
|
5304
|
-
return "terminal";
|
|
5305
|
-
}
|
|
5306
|
-
/** Transport errno codes and undici codes: the connection, not the request, failed. */
|
|
5307
|
-
const TRANSPORT_CODES = /* @__PURE__ */ new Set([
|
|
5308
|
-
"ECONNRESET",
|
|
5309
|
-
"ECONNREFUSED",
|
|
5310
|
-
"ECONNABORTED",
|
|
5311
|
-
"ETIMEDOUT",
|
|
5312
|
-
"EPIPE",
|
|
5313
|
-
"EAI_AGAIN",
|
|
5314
|
-
"ENETUNREACH",
|
|
5315
|
-
"EHOSTUNREACH"
|
|
5316
|
-
]);
|
|
5317
|
-
const TRANSPORT_NAMES = /* @__PURE__ */ new Set([
|
|
5318
|
-
"TimeoutError",
|
|
5319
|
-
"NetworkError",
|
|
5320
|
-
"AbortError",
|
|
5321
|
-
"RetainedStreamError"
|
|
5322
|
-
]);
|
|
5323
|
-
/** Producer infra earns the outage window; producer work earns only the bounded deterministic streak. */
|
|
5324
|
-
function transientFailureKind(error) {
|
|
5325
|
-
const typed = turnFailureOf(error);
|
|
5326
|
-
if (typed) return turnFailurePolicy(typed).failureKind;
|
|
5327
|
-
if (causedByPartialFailure(error)) return "deterministic";
|
|
5328
|
-
return causeChain(error).some((cause) => {
|
|
5329
|
-
if (!(cause instanceof Error)) return false;
|
|
5330
|
-
if (cause instanceof HarnessTurnFailedError && executorFailureInfra({
|
|
5331
|
-
error: cause.reported,
|
|
5332
|
-
...cause.errorCode === void 0 ? {} : { errorCode: cause.errorCode }
|
|
5333
|
-
})) return true;
|
|
5334
|
-
const status = cause instanceof HarnessTurnFailedError ? cause.statusCode ?? printedStatus(cause.message) : errorHttpStatus(cause);
|
|
5335
|
-
const code = ownCode(cause) ?? "";
|
|
5336
|
-
return status !== void 0 && (status === 408 || status >= 500) || TRANSPORT_CODES.has(code) || code.startsWith("UND_ERR_") || cause instanceof BackendTransportError || TRANSPORT_NAMES.has(errorProperty(cause, "name") ?? "");
|
|
5337
|
-
}) ? "infra" : "deterministic";
|
|
5338
|
-
}
|
|
5339
|
-
/** The error a give-up throws: the original cause, re-described with the attempt history so
|
|
5340
|
-
* `driver-failed` carries a diagnosable message instead of one backend's last words. */
|
|
5341
|
-
var DriverAttemptsExhaustedError = class extends RuntimeRunStateError {
|
|
5342
|
-
attempts;
|
|
5343
|
-
stop;
|
|
5344
|
-
constructor(cause, attempts, stop) {
|
|
5345
|
-
const last = attempts[attempts.length - 1];
|
|
5346
|
-
const causeText = cause instanceof Error ? `${errorProperty(cause, "name")}: ${errMessage(cause)}` : errMessage(cause);
|
|
5347
|
-
const firstFailure = attempts.find((attempt) => attempt.error !== void 0)?.error;
|
|
5348
|
-
const pauses = attempts.filter((attempt) => attempt.classification === "unavailable");
|
|
5349
|
-
const pausedMs = pauses.reduce((sum, attempt) => sum + (attempt.retryInMs ?? 0), 0);
|
|
5350
|
-
super(`supervisor driver failed after ${attempts.length} attempt(s) — stopped by ${stop}` + (stop === "repeated-failure" && isContentFilterRefusal(cause) ? `: ${CONTENT_FILTER_REASON}; ` : "; ") + (pauses.length === 0 ? "" : `${pauses.length} attempt(s) met an unavailable upstream and paused ${Math.round(pausedMs / 1e3)} s in total; `) + (firstFailure !== void 0 && firstFailure !== last?.error ? `first failure: ${errorText(firstFailure)}; ` : "") + `last cause: ${causeText}` + (last?.classification ? ` (classified ${last.classification})` : ""), { cause });
|
|
5351
|
-
this.attempts = Object.freeze([...attempts]);
|
|
5352
|
-
this.stop = stop;
|
|
5353
|
-
}
|
|
5354
|
-
};
|
|
5355
|
-
/** Count a loop's attempt records into its {@link DriverLoopRecord}. */
|
|
5356
|
-
function summarizeDriverAttempts(records) {
|
|
5357
|
-
let barren = 0;
|
|
5358
|
-
for (const record of records) if (record.madeProgress) barren = 0;
|
|
5359
|
-
else if (record.beforeModelEvent !== true && record.error === void 0 && record.reentry !== void 0 && record.reentry !== "wake" && record.contract === "unmet") barren += 1;
|
|
5360
|
-
const last = records.at(-1);
|
|
5361
|
-
const stopPauses = records.filter((record) => record.replacesStop !== void 0);
|
|
5362
|
-
const refused = records.filter((record) => record.classification === "unavailable" && record.replacesStop === void 0);
|
|
5363
|
-
return {
|
|
5364
|
-
attempts: new Set(records.map((record) => record.attempt)).size,
|
|
5365
|
-
reprompts: records.filter((record) => record.reprompted === true).length,
|
|
5366
|
-
failureRetries: records.filter((record) => record.error !== void 0 && record.retryInMs !== void 0 && record.classification !== "unavailable" && record.replacesStop === void 0).length,
|
|
5367
|
-
stopPauses: stopPauses.length,
|
|
5368
|
-
unavailablePauses: refused.filter((record) => record.retryInMs !== void 0).length,
|
|
5369
|
-
unavailableMs: refused.reduce((sum, record) => sum + (record.madeProgress ? 0 : record.durationMs) + (record.retryInMs ?? 0), 0),
|
|
5370
|
-
barrenReentries: barren,
|
|
5371
|
-
wakes: records.filter((record) => record.reentry === "wake").length,
|
|
5372
|
-
waitedMs: records.reduce((sum, record) => sum + (record.waitedMs ?? 0), 0),
|
|
5373
|
-
ended: last?.stop ?? "unrecorded",
|
|
5374
|
-
...last?.repromptRefusedBy === void 0 ? {} : { repromptRefusedBy: last.repromptRefusedBy }
|
|
5375
|
-
};
|
|
5376
|
-
}
|
|
5377
4795
|
// src/runtime/supervise/task-prompt.ts
|
|
5378
4796
|
/**
|
|
5379
4797
|
*
|
|
@@ -16649,6 +16067,6 @@ async function noWinner(settled, rejection) {
|
|
|
16649
16067
|
reason: "no-result-selected"
|
|
16650
16068
|
};
|
|
16651
16069
|
}
|
|
16652
|
-
export { failPendingAfter as $,
|
|
16070
|
+
export { failPendingAfter as $, readPromptOptions as A, defineProfileMaterializationContract as At, toolResultText as B, projectSandboxOutcome as Bt, captureReusableExecutorConfig as C, runWorktreeHarness as Ct, createSteerableSandboxSession as D, assertProfileMaterialization as Dt, DEFAULT_SANDBOX_STEERING_MAX_TURNS as E, terminateProcessTreeAndConfirm as Et, defaultSelectWinner as F, renderUnsupported as Ft, providerAsExecutor as G, routerBrain as H, codeModeArguments as I, sandboxActProfileMaterialization as It, providerAsSandboxClient as J, providerOutputOptions as K, codeModeModelOutput as L, sandboxProfileMaterialization as Lt, createSandboxLineage as M, profileMaterializationAxes$1 as Mt, acquireSandbox as N, promptControlProfileMaterialization as Nt, runAgentRounds as O, assertProfileMaterializes as Ot, TERMINAL_DECISIONS as P, promptModelProfileMaterialization as Pt, createInbox as Q, createCodeModeTools as R, unsupportedProfileDimensions as Rt, bindReusableExecutorExecutionId as S, runSettledCommand as St, snapshotExecutorConfig as T, harnessInvocation as Tt, createAgentEnvironmentProviderRegistry as U, createRouterTranscript as V, readSandboxOutcome as Vt, resolveAgentEnvironmentProvider as W, createInPlaceCliExecutor as X, createWorktreeCliExecutor as Y, INBOX_RECEIPT_KEY as Z, isDriverSpec as _, createPushTraceSource as _t, awaitRootWake as a, isPeerMailEnvelope as at, InMemorySpawnJournal as b, bridgeStopSignalKey as bt, readRunParking as c, taskToPrompt$1 as ct, bestDelivered as d, priceTokens as dt, AUTHORITY_MARKERS as et, runFinalizer as f, ROUTER_PRICE_SOURCE as ft, driverExecutorFactory as g, readCodexRolloutSession as gt, driverChild as h, harnessUsageIsEmpty as ht, assertRunParking as i, createPeerMailbox as it, createSandboxForSpec as j, fullProfileMaterialization as jt, assertBoxlessPromptOptions as k, controlProfileMaterialization as kt, sleepScopeWait as l, bridgeAdmissionRefusal as lt, createRootHandle as m, createCodexRolloutStoreReader as mt, createSupervisor as n, PEER_MAIL_WIRE_KEY as nt, bindScopeParkingDrain as o, peerMailTools as ot, runTree as p, addHarnessUsage as pt, LEAF_CONTINUATION_TASK as q, RunParkedError as r, claimsAuthority as rt, isRunParked as s, peerMailVerbNames as st, DEFAULT_MAX_DEPTH as t, DEFAULT_PEER_MAIL_LIMITS as tt, withRunParking as u, bridgeModelRouteRefusal as ut, withDriverExecutor as v, bridgeRuntimeAttachmentsKey as vt, createExecutor as w, LOCAL_HARNESSES as wt, createExecutorRegistry as x, defaultRunCommand as xt, InMemoryResultBlobStore as y, bridgeRuntimeEnvKey as yt, runCodeMode as z, worktreeCliProfileMaterialization as zt };
|
|
16653
16071
|
|
|
16654
|
-
//# sourceMappingURL=supervisor-
|
|
16072
|
+
//# sourceMappingURL=supervisor-KcnH2hC4.js.map
|