@tangle-network/agent-runtime 2.3.14 → 3.0.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.
- package/dist/{activation-BzNeFJDB.js → activation-BE0duxMf.js} +4 -4
- package/dist/{activation-BzNeFJDB.js.map → activation-BE0duxMf.js.map} +1 -1
- package/dist/{activation-B8dLwJj6.d.ts → activation-kREPGozZ.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -3
- package/dist/{bundle-DhV73H6U.js → bundle-ZHO7QFZw.js} +2 -2
- package/dist/{bundle-DhV73H6U.js.map → bundle-ZHO7QFZw.js.map} +1 -1
- package/dist/candidate-execution/index.d.ts +3 -3
- package/dist/candidate-execution/index.js +5 -5
- package/dist/{coordination-manager-BluavEgY.js → coordination-manager-B9goecNC.js} +4 -4
- package/dist/{coordination-manager-BluavEgY.js.map → coordination-manager-B9goecNC.js.map} +1 -1
- package/dist/{delegate-Bzpvzgl_.js → delegate-C-wmgWCF.js} +2 -2
- package/dist/{delegate-Bzpvzgl_.js.map → delegate-C-wmgWCF.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +9 -9
- package/dist/{graph-DHjdkdcj.js → graph-C_564r0C.js} +7 -7
- package/dist/graph-C_564r0C.js.map +1 -0
- package/dist/{improve-D9A79N5a.js → improve-BZdFdcUC.js} +7 -7
- package/dist/{improve-D9A79N5a.js.map → improve-BZdFdcUC.js.map} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +10 -10
- package/dist/intelligence.d.ts +4 -4
- package/dist/intelligence.js +7 -7
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +12 -12
- package/dist/{loop-runner-D9fuOb69.d.ts → loop-runner-D8NZLPE5.d.ts} +2 -2
- package/dist/{loop-runner-DqvZtCe5.js → loop-runner-_9_GtzO5.js} +2 -2
- package/dist/{loop-runner-DqvZtCe5.js.map → loop-runner-_9_GtzO5.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/{prepare-DrHOZFJy.js → prepare-CU0LM1_X.js} +3 -3
- package/dist/{prepare-DrHOZFJy.js.map → prepare-CU0LM1_X.js.map} +1 -1
- package/dist/{profile-BzzmKuIX.js → profile-By6JkIQi.js} +2 -2
- package/dist/{profile-BzzmKuIX.js.map → profile-By6JkIQi.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{protected-model-port-IKqhTypD.d.ts → protected-model-port-BBsYuEY0.d.ts} +2 -2
- package/dist/{provision-supervisor-DP5U58V4.js → provision-supervisor-DX4fd6Ib.js} +5 -5
- package/dist/{provision-supervisor-DP5U58V4.js.map → provision-supervisor-DX4fd6Ib.js.map} +1 -1
- package/dist/{run-cancellation-BxoFCpJ_.js → run-cancellation-BTjyVpVW.js} +2 -2
- package/dist/{run-cancellation-BxoFCpJ_.js.map → run-cancellation-BTjyVpVW.js.map} +1 -1
- package/dist/{runtime-LY1ovtim.js → runtime-DsH0QnW0.js} +54 -30
- package/dist/runtime-DsH0QnW0.js.map +1 -0
- package/dist/{scope-DRaBilEX.js → scope-BeI3tmVX.js} +2550 -2487
- package/dist/scope-BeI3tmVX.js.map +1 -0
- package/dist/{search-executor-DLo_9jUv.js → search-executor-C-E-umcI.js} +4 -4
- package/dist/{search-executor-DLo_9jUv.js.map → search-executor-C-E-umcI.js.map} +1 -1
- package/dist/{server-CeQ2alK3.js → server-DAYqKU6o.js} +4 -4
- package/dist/{server-CeQ2alK3.js.map → server-DAYqKU6o.js.map} +1 -1
- package/dist/{structural-rollout-BIjjZ_XX.js → structural-rollout-DHdmB9MR.js} +4 -4
- package/dist/{structural-rollout-BIjjZ_XX.js.map → structural-rollout-DHdmB9MR.js.map} +1 -1
- package/dist/{supervise-BdAUXtjZ.js → supervise-QzwZc6K2.js} +6 -6
- package/dist/{supervise-BdAUXtjZ.js.map → supervise-QzwZc6K2.js.map} +1 -1
- package/dist/{supervision-discovery-Da5zebY2.js → supervision-discovery-CyvJVbTM.js} +3 -3
- package/dist/{supervision-discovery-Da5zebY2.js.map → supervision-discovery-CyvJVbTM.js.map} +1 -1
- package/dist/{supervisor-3JHXy3tz.js → supervisor-REUnT7iX.js} +222 -147
- package/dist/supervisor-REUnT7iX.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +13 -13
- package/dist/{top-web-DK6lTMHG.js → top-web-DRfER2jW.js} +551 -149
- package/dist/top-web-DRfER2jW.js.map +1 -0
- package/dist/tui/bin.js +4 -3
- package/dist/tui/bin.js.map +1 -1
- package/dist/tui/index.d.ts +203 -3
- package/dist/tui/index.js +3 -3
- package/dist/{types-S3RbyJ4x.d.ts → types-Bm4xC_e-.d.ts} +151 -21
- package/dist/{workspace-streams-Dep2L6XD.js → workspace-streams-BSEkDu3H.js} +69 -69
- package/dist/{workspace-streams-Dep2L6XD.js.map → workspace-streams-BSEkDu3H.js.map} +1 -1
- package/dist/{workspace-streams-Dq2Fzk3c.d.ts → workspace-streams-BdZsd12p.d.ts} +7 -2
- package/package.json +2 -1
- package/dist/graph-DHjdkdcj.js.map +0 -1
- package/dist/runtime-LY1ovtim.js.map +0 -1
- package/dist/scope-DRaBilEX.js.map +0 -1
- package/dist/supervisor-3JHXy3tz.js.map +0 -1
- package/dist/top-web-DK6lTMHG.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $r as
|
|
1
|
+
import { $i as awaitAbortable, $r as runtimeProviderCode, $t as describeRetainedNativeStops, A as nestedScopeSeamKey, At as scopeRetainedOwnerSettled, Bi as createSandboxTurnEventCollector, Ci as createBudgetPool, Cn as workspaceCaptureReceipt, Dn as WORKER_TRACE_PROPAGATION, Dr as knownExecutionBindingReceipt, En as resolveWorkerSlots, Er as inheritRuntimeOwnedExecutorAttestation, Fr as recordRuntimeOwnedProviderModel, Ft as scopeRetainedOwnerCheckpointing, Gi as sandboxEventServedBackend, Gn as HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS, Gr as executableAgentSpecSnapshot, Gt as driverRuntime, Hr as unknownExecutionBindingReceipt, Ht as ownedTreeRootSpawn, Jt as encodeResultBlob, Ki as sandboxTerminalUsageField, Kt as nestedDriverTreeRoot, Li as extractTransportEventIdentity, Lr as runtimeOwnedExecutorExecutionBinding, Mi as sandboxLeafOutputFromEvents, Mr as recordRuntimeOwnedProviderAttemptStart, Ni as sandboxOutputMarker, Nr as recordRuntimeOwnedProviderDispatchNotStarted, On as workerTraceEnv, Or as knownMaterializationReceipt, Pi as sandboxProgressEvents, Pr as recordRuntimeOwnedProviderIdentityConflict, Q as assertRecursiveReservationPolicy, Qi as assertEventBinding, Qr as runtimeFailureRemediationSchema, Qt as verifyWorkspaceMarker, R as appendSpawnEvents, Ri as assertSandboxServedModel, Rr as runtimeOwnedExecutorMaterialization, Rt as retainedOwnerWorkspaceRetentionSeamKey, Si as isCredentialRefusal, Sn as openNativeMirror, T as sumSpendFromEvents, Tr as finalizeRuntimeOwnedPendingExecutor, Ui as isSandboxTerminalEvent, Ur as unknownMaterializationReceipt, V as finalizeScopeOwnerMaterialization, Vi as createSandboxUsageLedger, Vr as runtimeOwnedScopeOwnerRuntime, Vt as loadSpawnForest, Wi as notifySandboxEventObserver, Wr as executableAgentProfileSnapshot, Wt as attestNestedDriverTreeOwner, X as reenteredWorkers, Xi as recordValue, Xn as harnessTranscriptUnavailable, Xr as runtimeFailureCause, Xt as closesCursorSlot, Yi as parseCodexUsageRecord, Yn as harnessTranscriptFromLines, Yr as reportedFailureCause, Yt as SpawnEventIndex, Zi as RetainedRunProviderContractError, _i as contentAddress, _r as runAbortable, _t as startScopeRecoveries, ai as retainedExecutorContext, an as startRetainedRun, ar as describeToolArgs, at as hasRetriableTeardowns, bi as hashJson, bn as captureProviderWorkspaceSnapshot, br as attestRuntimeOwnedExecutor, ci as UNAVAILABLE_STATUSES, di as unavailablePauseMs, dt as registerNestedTeardownScope, ea as exactSession, en as stopRetainedNativeExecution, ft as releaseHeldEnvironments, gn as environmentGone, gr as linkAbort, gt as settleManagerWork, hr as abortReason, ht as retryUnconfirmedTeardowns, ia as promptOptionsFromAgentTurnInput, in as recoverRetainedRun, ir as createActivityLog, it as closeScopeAdmission, jn as mergeTraceEnv, ki as createSandboxToolPartState, kn as workerTraceHeaders, kr as newExecutionAttemptId, mi as unavailableSignalOfFailure, mr as RunCancellationReason, mt as releaseRetainedEnvironments, na as sameControlCoordinates, ni as RetainedExecutionPendingError, nn as mintRetainedIdentity, nr as retainHarnessTranscript, oi as retainedExecutorSeamKey, pi as unavailableSignalInText, pr as subscriptionUsageLimitSignal, pt as releaseManagerEnvironment, qn as captureHarnessTranscript, ri as isProvisioningRefusal, rn as reconnectRetainedRun, rt as closeRetainedSlots, si as UNAVAILABLE_CODES, sr as isLiveNodeStatus, t as createScope, ta as freezeControlRef, ti as DISPATCH_NOT_ADMITTED_CODE, tn as assertRetainedRunReplayMaterial, vi as contentRef, vn as assertProviderWorkspaceRetentionPort, vt as unconfirmedTeardowns, w as prepareScopeResume, xi as credentialCommandExit, xn as nativeCopyDelayMs, xr as attestRuntimeOwnedPendingExecutor, yn as captureProviderLiveWorkspace, yr as attestRuntimeOwnedDeferredExecutor, yt as waitForScopeChildren, zi as canonicalSandboxUsageMode } from "./scope-BeI3tmVX.js";
|
|
2
2
|
import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError$1, r as BackendTransportError, t as AgentEvalError } from "./errors-AzSuGI23.js";
|
|
3
|
-
import { $ as
|
|
3
|
+
import { $ as isAsyncIterable, J as deleteBoxSafe, Ot as teardownSurfaces, Q as isAbortError, St as armDeadlineTimer, Tt as isDeadlineAbortReason, U as addSpend, V as hasControlCharacter, W as addTokenUsage, Y as errorMessage, _t as ACCEPTED_RESULT_GRACE_MS, at as sleep, ct as throwIfAborted, dt as zeroSpend, et as mapWithConcurrency, ft as zeroTokenUsage, gt as withBudgetResources, it as roundBoxMinutes, lt as unmeteredSpend, nt as randomSuffix, ot as stringifySafe, pt as addResourceSpend, q as cloneTokenUsage, rt as randomUuid, st as throwAbort, tt as promptCacheTokenClasses, ut as withTimeout, xt as ROOT_DEADLINE_REASON } from "./workspace-streams-BSEkDu3H.js";
|
|
4
4
|
import { t as runTaskQueue } from "./task-queue-DbpZAp6C.js";
|
|
5
5
|
import { _ as errorText, d as detachedSnapshot, g as errorProperty, h as errorHttpStatus, l as sha256, m as errMessage, p as causeChain, v as defaultRedactor } from "./jsonl-file-BBP9Dz9w.js";
|
|
6
6
|
import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, d as assertRouterAutoDeclaration, f as assertRouterAutoResponse, g as observedModelMatchesDeclared, h as observedModelHasSnapshot, l as profileProviderModel, m as mergeObservedModelIdentity, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile, u as resolveRouterRetryPolicy } from "./model-policy-C-RGAUW4.js";
|
|
@@ -10,6 +10,7 @@ import { i as notifyRuntimeHookEvent } from "./runtime-hooks-CsW2pfFk.js";
|
|
|
10
10
|
import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentExactRunControlRefSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, REASONING_EFFORTS, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, harnessTypeSchema, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sha256DigestSchema } from "@tangle-network/agent-interface";
|
|
11
11
|
import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
12
12
|
import { SDKError, generateIdempotencyKey, isRecord, withRetry } from "@tangle-network/agent-core";
|
|
13
|
+
import { collectAgentFinalMessageText, collectAgentResponseText, isToolBearingEvent } from "@tangle-network/sandbox";
|
|
13
14
|
import { z } from "zod";
|
|
14
15
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
15
16
|
import { appendFileSync, closeSync, constants, createReadStream, existsSync, openSync } from "node:fs";
|
|
@@ -6118,6 +6119,74 @@ function mergeBridgeObservedModel(current, next) {
|
|
|
6118
6119
|
if (merged === void 0) throw new ValidationError$1(`bridgeExecutor: bridge changed response model from ${JSON.stringify(current)} to ${JSON.stringify(next)}`);
|
|
6119
6120
|
return merged;
|
|
6120
6121
|
}
|
|
6122
|
+
// src/runtime/supervise/bridge-transcript.ts
|
|
6123
|
+
/** The existing executor transcript lifecycle; Scope alone persists the resulting capture. */
|
|
6124
|
+
function bridgeTranscript(seam, sessionId, profile, runs, node) {
|
|
6125
|
+
if (!seam.harnessTranscript) return {
|
|
6126
|
+
ports: {},
|
|
6127
|
+
settle: (source) => source
|
|
6128
|
+
};
|
|
6129
|
+
let capture = harnessTranscriptUnavailable("execution-never-started");
|
|
6130
|
+
let settled = Promise.resolve();
|
|
6131
|
+
const finish = async () => {
|
|
6132
|
+
if (!runs.size) {
|
|
6133
|
+
capture = harnessTranscriptUnavailable("execution-never-started");
|
|
6134
|
+
return;
|
|
6135
|
+
}
|
|
6136
|
+
const signal = AbortSignal.timeout(HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS);
|
|
6137
|
+
try {
|
|
6138
|
+
const work = async () => {
|
|
6139
|
+
const admitted = [...runs.values()].map((run) => {
|
|
6140
|
+
if (!run.requestDigest) throw new Error(`Bridge run ${run.id} has no authenticated request digest`);
|
|
6141
|
+
return {
|
|
6142
|
+
runId: run.id,
|
|
6143
|
+
requestDigest: run.requestDigest
|
|
6144
|
+
};
|
|
6145
|
+
});
|
|
6146
|
+
if (!(await Promise.all([...runs.values()].map((run) => cancelBridgeRunToTerminal(seam, run, 36e4, signal)))).every(Boolean)) throw new Error("Bridge native capture has no terminal proof for every admitted run");
|
|
6147
|
+
return seam.harnessTranscript({
|
|
6148
|
+
sessionId,
|
|
6149
|
+
harness: agentHarness(profile.harness),
|
|
6150
|
+
profileDigest: canonicalAgentProfileDigest(profile),
|
|
6151
|
+
...seam.cwd === void 0 ? {} : { cwd: seam.cwd },
|
|
6152
|
+
...node === void 0 ? {} : { node },
|
|
6153
|
+
runs: admitted,
|
|
6154
|
+
signal
|
|
6155
|
+
});
|
|
6156
|
+
};
|
|
6157
|
+
capture = await runAbortable(work, signal, "Bridge native capture stopped");
|
|
6158
|
+
} catch (error) {
|
|
6159
|
+
capture = {
|
|
6160
|
+
status: "unavailable",
|
|
6161
|
+
reason: "capture-failed",
|
|
6162
|
+
skipped: [{
|
|
6163
|
+
path: sessionId,
|
|
6164
|
+
reason: error instanceof Error ? error.message : "Bridge native capture failed"
|
|
6165
|
+
}]
|
|
6166
|
+
};
|
|
6167
|
+
}
|
|
6168
|
+
};
|
|
6169
|
+
return {
|
|
6170
|
+
ports: {
|
|
6171
|
+
harnessTranscript: () => capture,
|
|
6172
|
+
harnessTranscriptSettled: () => settled
|
|
6173
|
+
},
|
|
6174
|
+
async *settle(source) {
|
|
6175
|
+
const prior = settled;
|
|
6176
|
+
let done;
|
|
6177
|
+
settled = new Promise((resolve) => {
|
|
6178
|
+
done = resolve;
|
|
6179
|
+
});
|
|
6180
|
+
await prior;
|
|
6181
|
+
capture = harnessTranscriptUnavailable("capture-did-not-run");
|
|
6182
|
+
try {
|
|
6183
|
+
yield* source;
|
|
6184
|
+
} finally {
|
|
6185
|
+
finish().then(done);
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6188
|
+
};
|
|
6189
|
+
}
|
|
6121
6190
|
// src/runtime/supervise/peer-mail.ts
|
|
6122
6191
|
/**
|
|
6123
6192
|
*
|
|
@@ -6874,6 +6943,7 @@ const bridgeExecutor = (spec, ctx) => {
|
|
|
6874
6943
|
const inbox = createInbox();
|
|
6875
6944
|
let artifact;
|
|
6876
6945
|
const activeRuns = /* @__PURE__ */ new Map();
|
|
6946
|
+
const transcript = bridgeTranscript(seam, sessionId, effectiveProfile, activeRuns, ctx.node);
|
|
6877
6947
|
const observation = {
|
|
6878
6948
|
turns: 0,
|
|
6879
6949
|
note: "starting",
|
|
@@ -6923,8 +6993,10 @@ const bridgeExecutor = (spec, ctx) => {
|
|
|
6923
6993
|
}
|
|
6924
6994
|
};
|
|
6925
6995
|
let acknowledged;
|
|
6926
|
-
let executor
|
|
6996
|
+
let executor;
|
|
6997
|
+
executor = {
|
|
6927
6998
|
runtime: "cli",
|
|
6999
|
+
...transcript.ports,
|
|
6928
7000
|
deliver: (m) => inbox.deliver(m),
|
|
6929
7001
|
/**
|
|
6930
7002
|
* The LIVE read of this worker, answered entirely from local mirrors so it is synchronous
|
|
@@ -6994,7 +7066,7 @@ const bridgeExecutor = (spec, ctx) => {
|
|
|
6994
7066
|
}, plannedBinding);
|
|
6995
7067
|
}
|
|
6996
7068
|
});
|
|
6997
|
-
return failPendingAfter(inbox, session);
|
|
7069
|
+
return transcript.settle(failPendingAfter(inbox, session));
|
|
6998
7070
|
},
|
|
6999
7071
|
async cancel(request) {
|
|
7000
7072
|
const live = [...activeRuns.values()].filter((run) => !run.terminal);
|
|
@@ -8048,20 +8120,20 @@ function createProviderNativeControl(provider, retention, managerStop, state) {
|
|
|
8048
8120
|
* release records what it kept.
|
|
8049
8121
|
*/
|
|
8050
8122
|
const withoutRunningHarness = (release) => async (signal) => {
|
|
8051
|
-
const
|
|
8052
|
-
|
|
8053
|
-
const
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
return
|
|
8123
|
+
const stop = await awaitAbortable(stopNativeExecution(), signal).catch(() => void 0);
|
|
8124
|
+
const stopped = stop === void 0 ? "native stop unconfirmed: no exact dispatch or cleanup interrupted" : describeRetainedNativeStops([stop]);
|
|
8125
|
+
const environmentId = (state.retained?.controlRef ?? admittedControlRef(retention))?.environmentId ?? admittedEnvironmentId(retention);
|
|
8126
|
+
if (environmentId !== void 0 && !state.harnessStopped) {
|
|
8127
|
+
state.workspacePreservationRequired = true;
|
|
8128
|
+
return [{
|
|
8129
|
+
provider: provider.name,
|
|
8130
|
+
environmentId,
|
|
8131
|
+
destroyed: false,
|
|
8132
|
+
detail: stopped,
|
|
8133
|
+
permanent: true
|
|
8134
|
+
}];
|
|
8135
|
+
}
|
|
8136
|
+
return (await release(signal)).map((receipt) => receipt.destroyed ? receipt : {
|
|
8065
8137
|
...receipt,
|
|
8066
8138
|
detail: receipt.detail ? `${receipt.detail}; ${stopped}` : stopped
|
|
8067
8139
|
});
|
|
@@ -8326,6 +8398,13 @@ async function captureBeforeDestroy$1(scope, target, signal) {
|
|
|
8326
8398
|
await awaitAbortable(mirrors.captureNative(target, "interrupted", admitted === void 0 ? void 0 : freezeControlRef(admitted)), signal).catch(() => void 0);
|
|
8327
8399
|
}
|
|
8328
8400
|
}
|
|
8401
|
+
// src/runtime/environment-provider/provider-validation-error.ts
|
|
8402
|
+
var ValidationError = class extends Error {
|
|
8403
|
+
constructor(message, options) {
|
|
8404
|
+
super(message, options);
|
|
8405
|
+
this.name = "ValidationError";
|
|
8406
|
+
}
|
|
8407
|
+
};
|
|
8329
8408
|
// src/runtime/environment-provider/provider-event-projection.ts
|
|
8330
8409
|
function sandboxEventFromEnvironmentEvent(event) {
|
|
8331
8410
|
const normalized = event.normalized;
|
|
@@ -8473,13 +8552,12 @@ function createProviderFailureLedger() {
|
|
|
8473
8552
|
};
|
|
8474
8553
|
}
|
|
8475
8554
|
function failureDetail(value) {
|
|
8476
|
-
|
|
8477
|
-
const error = value.error;
|
|
8555
|
+
const error = value?.error;
|
|
8478
8556
|
if (typeof error === "string") return error;
|
|
8479
8557
|
const nestedError = recordValue(error);
|
|
8480
8558
|
if (typeof nestedError?.message === "string") return nestedError.message;
|
|
8481
|
-
if (typeof value
|
|
8482
|
-
return typeof value
|
|
8559
|
+
if (typeof value?.message === "string") return value.message;
|
|
8560
|
+
return typeof value?.detail === "string" ? value.detail : void 0;
|
|
8483
8561
|
}
|
|
8484
8562
|
/** Preserve the Sandbox outcome's numeric HTTP metadata across the provider adapter. */
|
|
8485
8563
|
function failureStatusCode(value) {
|
|
@@ -8487,9 +8565,8 @@ function failureStatusCode(value) {
|
|
|
8487
8565
|
return typeof statusCode === "number" && Number.isInteger(statusCode) && statusCode >= 400 && statusCode <= 599 ? statusCode : void 0;
|
|
8488
8566
|
}
|
|
8489
8567
|
function failureCode(value) {
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
return stringValue(value.errorCode) ?? stringValue(value.code) ?? stringValue(error?.errorCode) ?? stringValue(error?.code);
|
|
8568
|
+
const error = recordValue(value?.error);
|
|
8569
|
+
return stringValue(value?.errorCode) ?? stringValue(value?.code) ?? stringValue(error?.errorCode) ?? stringValue(error?.code);
|
|
8493
8570
|
}
|
|
8494
8571
|
function usageSandboxEvent(event) {
|
|
8495
8572
|
const type = event.normalized?.type ?? event.type;
|
|
@@ -8501,7 +8578,7 @@ function usageSandboxEvent(event) {
|
|
|
8501
8578
|
data: {
|
|
8502
8579
|
...event.data,
|
|
8503
8580
|
...usage,
|
|
8504
|
-
..."usageMode" in event ? { usageMode: event.usageMode } :
|
|
8581
|
+
..."usageMode" in event ? { usageMode: event.usageMode } : {}
|
|
8505
8582
|
},
|
|
8506
8583
|
...event.id ? { id: event.id } : {}
|
|
8507
8584
|
};
|
|
@@ -8586,8 +8663,30 @@ function resultFromEvents(events, fallbackText) {
|
|
|
8586
8663
|
events
|
|
8587
8664
|
};
|
|
8588
8665
|
}
|
|
8666
|
+
/** Decode only the final assistant message, keeping the unmodified stream as evidence. */
|
|
8667
|
+
function jsonResultFromEvents(events) {
|
|
8668
|
+
if (events.some((event) => event.type === "result" && event.data.eventStreamComplete === false)) throw new ValidationError("provider JSON output: complete native event observation is required");
|
|
8669
|
+
const projected = events.map(sandboxEventFromEnvironmentEvent);
|
|
8670
|
+
const text = collectAgentFinalMessageText(projected) ?? (projected.some(isToolBearingEvent) ? void 0 : collectAgentResponseText(projected));
|
|
8671
|
+
try {
|
|
8672
|
+
return { out: JSON.parse(text ?? "", (_key, value) => {
|
|
8673
|
+
if (typeof value === "number" && !Number.isFinite(value)) throw new SyntaxError("JSON number is not finite");
|
|
8674
|
+
return value;
|
|
8675
|
+
}) };
|
|
8676
|
+
} catch (error) {
|
|
8677
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
8678
|
+
return {
|
|
8679
|
+
out: null,
|
|
8680
|
+
outcome: {
|
|
8681
|
+
success: false,
|
|
8682
|
+
error: `provider JSON output: ${text === void 0 ? "missing final assistant message" : "invalid final assistant JSON"}; return only a JSON value after tool use`,
|
|
8683
|
+
errorCode: "RUNTIME_OUTPUT_FORMAT_INVALID"
|
|
8684
|
+
}
|
|
8685
|
+
};
|
|
8686
|
+
}
|
|
8687
|
+
}
|
|
8589
8688
|
function textFromEnvironmentEvent(event) {
|
|
8590
|
-
if (
|
|
8689
|
+
if (event.normalized?.type === "message.part.updated") return typeof event.normalized.delta === "string" ? event.normalized.delta : "";
|
|
8591
8690
|
const data = event.data;
|
|
8592
8691
|
for (const key of [
|
|
8593
8692
|
"delta",
|
|
@@ -8638,7 +8737,7 @@ const RETAINED_AWAITING_RESULT_AFTER_MS = 48e4;
|
|
|
8638
8737
|
const RETAINED_OBSERVATION_BATCH_EVENTS = 1024;
|
|
8639
8738
|
/**
|
|
8640
8739
|
* After its exact result, a stream that still owes its terminal frame keeps reading only while
|
|
8641
|
-
* each frame arrives within this long of the
|
|
8740
|
+
* each frame arrives within this long of the result or the last frame.
|
|
8642
8741
|
* A provider sends a turn's last frames and its result on two connections, and a burst that
|
|
8643
8742
|
* straddles the result is read whole.
|
|
8644
8743
|
*/
|
|
@@ -8660,7 +8759,6 @@ var RetainedObservation = class {
|
|
|
8660
8759
|
lastReplayPosition;
|
|
8661
8760
|
sawTerminal = false;
|
|
8662
8761
|
lastObservedAt = 0;
|
|
8663
|
-
lastFrameAt;
|
|
8664
8762
|
awaitingPublished = false;
|
|
8665
8763
|
exactResult;
|
|
8666
8764
|
exactResultSettled = false;
|
|
@@ -8726,6 +8824,7 @@ var RetainedObservation = class {
|
|
|
8726
8824
|
if (this.exactResult === void 0) {
|
|
8727
8825
|
this.exactResult = awaitAbortable(Promise.resolve().then(() => this.handle.result()), this.signal);
|
|
8728
8826
|
const settle = () => {
|
|
8827
|
+
if (this.observedFrames === 0) this.lastObservedAt = Date.now();
|
|
8729
8828
|
this.exactResultSettled = true;
|
|
8730
8829
|
};
|
|
8731
8830
|
this.exactResult.then(settle, settle);
|
|
@@ -8763,12 +8862,14 @@ var RetainedObservation = class {
|
|
|
8763
8862
|
const exactWake = new Promise((resolve) => {
|
|
8764
8863
|
wake = setImmediate(() => {
|
|
8765
8864
|
const close = () => {
|
|
8766
|
-
const flowing = this.sawTerminal
|
|
8865
|
+
const flowing = this.sawTerminal ? 0 : RETAINED_TAIL_FLOW_MS - (Date.now() - this.lastObservedAt);
|
|
8767
8866
|
if (flowing <= 0) {
|
|
8768
8867
|
resolve({ kind: "exact-result" });
|
|
8769
8868
|
return;
|
|
8770
8869
|
}
|
|
8771
|
-
grace = setTimeout(() =>
|
|
8870
|
+
grace = setTimeout(() => {
|
|
8871
|
+
wake = setImmediate(() => resolve({ kind: "exact-result" }));
|
|
8872
|
+
}, flowing);
|
|
8772
8873
|
if (typeof grace.unref === "function") grace.unref();
|
|
8773
8874
|
};
|
|
8774
8875
|
unwatch = this.onExactResult(close);
|
|
@@ -8822,7 +8923,6 @@ var RetainedObservation = class {
|
|
|
8822
8923
|
this.seenEvents.set(eventId, digest);
|
|
8823
8924
|
}
|
|
8824
8925
|
this.lastObservedAt = Date.now();
|
|
8825
|
-
this.lastFrameAt = this.lastObservedAt;
|
|
8826
8926
|
if (identity.cursor !== void 0) this.lastReplayPosition = identity.cursor;
|
|
8827
8927
|
else if (eventId !== void 0) this.lastReplayPosition = eventId;
|
|
8828
8928
|
if (isTerminalEnvironmentEvent(event)) this.sawTerminal = true;
|
|
@@ -8875,13 +8975,6 @@ var RetainedObservation = class {
|
|
|
8875
8975
|
return !failed;
|
|
8876
8976
|
}
|
|
8877
8977
|
};
|
|
8878
|
-
// src/runtime/environment-provider/provider-validation-error.ts
|
|
8879
|
-
var ValidationError = class extends Error {
|
|
8880
|
-
constructor(message, options) {
|
|
8881
|
-
super(message, options);
|
|
8882
|
-
this.name = "ValidationError";
|
|
8883
|
-
}
|
|
8884
|
-
};
|
|
8885
8978
|
// src/runtime/environment-provider/provider-turn-input.ts
|
|
8886
8979
|
/**
|
|
8887
8980
|
* Lower the seam's prompt options onto turn fields, through the one mapper this module already
|
|
@@ -9663,21 +9756,18 @@ var ProviderTurnSettlement = class {
|
|
|
9663
9756
|
}
|
|
9664
9757
|
/** Hand the workspace capture to the owner. Its receipt reaches the journal as evidence of this
|
|
9665
9758
|
* invocation; a capture that fails leaves none, and the owner's release then keeps the source. */
|
|
9666
|
-
handCaptureToOwner(reported, captureOutcome,
|
|
9759
|
+
handCaptureToOwner(reported, captureOutcome, settled) {
|
|
9667
9760
|
const { args, environment } = this;
|
|
9761
|
+
this.finalCopyTaken = true;
|
|
9668
9762
|
args.retention?.onEndOfTurnWork?.((async () => {
|
|
9669
|
-
const
|
|
9670
|
-
try {
|
|
9671
|
-
await beforeCapture?.();
|
|
9672
|
-
} catch {}
|
|
9673
|
-
})();
|
|
9763
|
+
const copy = settled ? args.scope.mirrors.finishNativeMirror(environment, "settled").catch(() => void 0) : Promise.resolve();
|
|
9674
9764
|
let snapshot;
|
|
9675
9765
|
try {
|
|
9676
9766
|
snapshot = await args.captureWorkspace(environment, captureOutcome);
|
|
9677
9767
|
} finally {
|
|
9678
|
-
await
|
|
9768
|
+
await copy;
|
|
9679
9769
|
}
|
|
9680
|
-
if (
|
|
9770
|
+
if (settled) args.onPublishedSnapshot(snapshot);
|
|
9681
9771
|
if (snapshot === void 0) return;
|
|
9682
9772
|
await args.retention?.onEvidence?.({
|
|
9683
9773
|
...reported,
|
|
@@ -9723,7 +9813,23 @@ var ProviderTurnSettlement = class {
|
|
|
9723
9813
|
signal: args.signal
|
|
9724
9814
|
});
|
|
9725
9815
|
const deferCapture = this.ownerTakesCapture();
|
|
9726
|
-
|
|
9816
|
+
/**
|
|
9817
|
+
* A capture that fails or exceeds its deadline after settlement is a fact about the evidence,
|
|
9818
|
+
* never the turn's outcome. On Runtime 0.295.4 a capture past its 1,200,000 ms
|
|
9819
|
+
* deadline behind a two-slot queue shared by 34 workers threw an AbortError, the driver
|
|
9820
|
+
* classified it terminal, and two research roots ended with 13 and 0 children settled. With no
|
|
9821
|
+
* receipt the source stays preserved and the owner reads a retention failure; the turn is not re-run.
|
|
9822
|
+
*/
|
|
9823
|
+
let retainedWorkspace;
|
|
9824
|
+
let workspaceCaptureFailure;
|
|
9825
|
+
if (!deferCapture) {
|
|
9826
|
+
try {
|
|
9827
|
+
retainedWorkspace = await args.captureWorkspace(this.environment, outcome);
|
|
9828
|
+
} catch (error) {
|
|
9829
|
+
workspaceCaptureFailure = `${errorText(error instanceof Error ? error.message : error)}; source environment preserved`;
|
|
9830
|
+
}
|
|
9831
|
+
args.onPublishedSnapshot(retainedWorkspace);
|
|
9832
|
+
}
|
|
9727
9833
|
const settledResult = {
|
|
9728
9834
|
...result,
|
|
9729
9835
|
...workspaceCaptureFailure === void 0 ? {} : { workspaceCaptureFailure },
|
|
@@ -9732,65 +9838,40 @@ var ProviderTurnSettlement = class {
|
|
|
9732
9838
|
workspaceCapture: this.captureReceipt(retainedWorkspace)
|
|
9733
9839
|
}
|
|
9734
9840
|
};
|
|
9735
|
-
const
|
|
9841
|
+
const jsonOutput = args.options.outputFormat === "json";
|
|
9842
|
+
if (jsonOutput) await args.retention?.onEvidence?.(settledResult);
|
|
9843
|
+
const output = jsonOutput && outcome?.status !== "failed" ? jsonResultFromEvents(result.events) : { out: settledResult };
|
|
9844
|
+
const statusCode = failureStatusCode(outcome);
|
|
9845
|
+
const nativeFailure = outcome?.status === "failed" ? {
|
|
9846
|
+
success: false,
|
|
9847
|
+
...outcome.error ? { error: outcome.error } : {},
|
|
9848
|
+
...outcome.errorCode ? { errorCode: outcome.errorCode } : {},
|
|
9849
|
+
...statusCode === void 0 ? {} : { statusCode }
|
|
9850
|
+
} : void 0;
|
|
9851
|
+
const settled = {
|
|
9852
|
+
...jsonOutput ? { outputFormat: "json" } : {},
|
|
9853
|
+
...nativeFailure ? { outcome: nativeFailure } : {},
|
|
9854
|
+
...output,
|
|
9855
|
+
outRef: contentRef(`provider:${args.provider.name}`, output.out),
|
|
9856
|
+
...verdict ? { verdict } : {},
|
|
9857
|
+
spent: executionSpent
|
|
9858
|
+
};
|
|
9736
9859
|
this.settled = settled;
|
|
9737
|
-
|
|
9860
|
+
if (args.mayContinue && this.retained && nativeFailure) {
|
|
9861
|
+
const signal = unavailableSignalOfFailure({
|
|
9862
|
+
...nativeFailure,
|
|
9863
|
+
error: nativeFailure.error ?? ""
|
|
9864
|
+
});
|
|
9865
|
+
if (signal !== void 0) this.unavailable = {
|
|
9866
|
+
signal,
|
|
9867
|
+
cause: errorText(nativeFailure.error ?? "")
|
|
9868
|
+
};
|
|
9869
|
+
}
|
|
9738
9870
|
if (this.retained) await args.retention?.onResult(settled);
|
|
9739
|
-
else if (retainedWorkspace !== void 0) await args.retention?.onEvidence?.(settledResult);
|
|
9871
|
+
else if (retainedWorkspace !== void 0 && !jsonOutput) await args.retention?.onEvidence?.(settledResult);
|
|
9740
9872
|
args.scope.state.pending = false;
|
|
9741
9873
|
args.scope.state.artifact = settled;
|
|
9742
|
-
if (deferCapture)
|
|
9743
|
-
this.finalCopyTaken = true;
|
|
9744
|
-
this.handCaptureToOwner(settledResult, outcome, true, () => args.scope.mirrors.finishNativeMirror(this.environment, "settled"));
|
|
9745
|
-
}
|
|
9746
|
-
}
|
|
9747
|
-
/**
|
|
9748
|
-
* A capture that fails or exceeds its deadline after settlement is a fact about the evidence,
|
|
9749
|
-
* never the turn's outcome. On Runtime 0.295.4 a capture past its 1,200,000 ms
|
|
9750
|
-
* deadline behind a two-slot queue shared by 34 workers threw an AbortError, the driver
|
|
9751
|
-
* classified it terminal, and two research roots ended with 13 and 0 children settled. With no
|
|
9752
|
-
* receipt the source stays preserved and the owner reads a retention failure; the turn is not re-run.
|
|
9753
|
-
*/
|
|
9754
|
-
async captureSettledWorkspace(outcome) {
|
|
9755
|
-
let retainedWorkspace;
|
|
9756
|
-
let workspaceCaptureFailure;
|
|
9757
|
-
try {
|
|
9758
|
-
retainedWorkspace = await this.args.captureWorkspace(this.environment, outcome);
|
|
9759
|
-
} catch (error) {
|
|
9760
|
-
workspaceCaptureFailure = `${errorText(error instanceof Error ? error.message : error)}; source environment preserved`;
|
|
9761
|
-
}
|
|
9762
|
-
this.args.onPublishedSnapshot(retainedWorkspace);
|
|
9763
|
-
return {
|
|
9764
|
-
retainedWorkspace,
|
|
9765
|
-
workspaceCaptureFailure
|
|
9766
|
-
};
|
|
9767
|
-
}
|
|
9768
|
-
settledArtifact(result, settledResult, verdict, spent) {
|
|
9769
|
-
return {
|
|
9770
|
-
...result.outcome?.status === "failed" ? { outcome: {
|
|
9771
|
-
success: false,
|
|
9772
|
-
...result.outcome.error ? { error: result.outcome.error } : {},
|
|
9773
|
-
...result.outcome.errorCode ? { errorCode: result.outcome.errorCode } : {},
|
|
9774
|
-
...failureStatusCode(result.outcome) === void 0 ? {} : { statusCode: failureStatusCode(result.outcome) }
|
|
9775
|
-
} } : {},
|
|
9776
|
-
outRef: contentRef(`provider:${this.args.provider.name}`, settledResult),
|
|
9777
|
-
out: settledResult,
|
|
9778
|
-
...verdict ? { verdict } : {},
|
|
9779
|
-
spent
|
|
9780
|
-
};
|
|
9781
|
-
}
|
|
9782
|
-
/** A retained turn the upstream refused for capacity ends with its environment kept. */
|
|
9783
|
-
refusalOf(result) {
|
|
9784
|
-
if (!this.args.mayContinue || !this.retained || result.outcome?.status !== "failed") return;
|
|
9785
|
-
const signal = unavailableSignalOfFailure({
|
|
9786
|
-
error: result.outcome.error ?? "",
|
|
9787
|
-
...result.outcome.errorCode ? { errorCode: result.outcome.errorCode } : {},
|
|
9788
|
-
...failureStatusCode(result.outcome) === void 0 ? {} : { statusCode: failureStatusCode(result.outcome) }
|
|
9789
|
-
});
|
|
9790
|
-
return signal === void 0 ? void 0 : {
|
|
9791
|
-
signal,
|
|
9792
|
-
cause: errorText(result.outcome.error ?? "")
|
|
9793
|
-
};
|
|
9874
|
+
if (deferCapture) this.handCaptureToOwner(settledResult, outcome, true);
|
|
9794
9875
|
}
|
|
9795
9876
|
/** Record the turn's failure, then capture what evidence its environment still holds. */
|
|
9796
9877
|
async *fail(error) {
|
|
@@ -9810,17 +9891,11 @@ var ProviderTurnSettlement = class {
|
|
|
9810
9891
|
args.scope.state.settleTranscript();
|
|
9811
9892
|
if (this.ownerTakesCapture()) {
|
|
9812
9893
|
if (!args.signal.aborted) await args.scope.mirrors.finishNativeMirror(environment, "failed");
|
|
9813
|
-
this.finalCopyTaken = true;
|
|
9814
9894
|
this.handCaptureToOwner({
|
|
9815
9895
|
...resultFromEvents(this.observer.archive.events(), this.observer.text),
|
|
9816
9896
|
outcome: failureOutcome
|
|
9817
9897
|
}, failureOutcome, false);
|
|
9818
|
-
} else
|
|
9819
|
-
await this.readLiveTranscript();
|
|
9820
|
-
}
|
|
9821
|
-
async captureFailedTurn(error, failureOutcome) {
|
|
9822
|
-
const { args } = this;
|
|
9823
|
-
try {
|
|
9898
|
+
} else try {
|
|
9824
9899
|
const retainedWorkspace = await args.captureWorkspace(this.environment, failureOutcome);
|
|
9825
9900
|
if (retainedWorkspace !== void 0 && args.retention?.onEvidence !== void 0) await args.retention.onEvidence({
|
|
9826
9901
|
...resultFromEvents(this.observer.archive.events(), this.observer.text),
|
|
@@ -9829,9 +9904,11 @@ var ProviderTurnSettlement = class {
|
|
|
9829
9904
|
workspaceCapture: this.captureReceipt(retainedWorkspace)
|
|
9830
9905
|
});
|
|
9831
9906
|
} catch (captureError) {
|
|
9832
|
-
if (captureError instanceof Error
|
|
9833
|
-
else this.failure = captureError;
|
|
9907
|
+
if (!(captureError instanceof Error) || captureError === error) this.failure = captureError;
|
|
9908
|
+
else if (captureError.cause === void 0) this.failure = Object.assign(captureError, { cause: this.failure });
|
|
9909
|
+
else this.failure = new AggregateError([captureError, this.failure], captureError.message, { cause: captureError });
|
|
9834
9910
|
}
|
|
9911
|
+
await this.readLiveTranscript();
|
|
9835
9912
|
}
|
|
9836
9913
|
/** Runs on every way the turn ends: the last session copy, then the environment's fate. */
|
|
9837
9914
|
async release() {
|
|
@@ -9840,24 +9917,23 @@ var ProviderTurnSettlement = class {
|
|
|
9840
9917
|
if (!this.finalCopyTaken) await args.scope.mirrors.finishNativeMirror(this.environment, this.failed ? "failed" : this.settled !== void 0 ? "settled" : "interrupted");
|
|
9841
9918
|
const held = this.retained && this.settled !== void 0 && !this.failed && this.unavailable === void 0 && args.retention?.preserveEnvironment !== true && args.retention?.holdOnSettle?.(this.settled.spent) === true;
|
|
9842
9919
|
if (held) args.scope.state.holdingForContinuation = true;
|
|
9843
|
-
if ((!this.retained || this.settled !== void 0 && !this.failed) && !(this.retained && args.retention?.preserveEnvironment) && !(this.unavailable !== void 0 && !this.failed) && !held && (args.options.destroyOnSettle ?? true))
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
this.failure
|
|
9859
|
-
|
|
9860
|
-
} else this.failure = this.failure instanceof Error ? Object.assign(this.failure, { cause: this.failure.cause ?? error }) : this.failure;
|
|
9920
|
+
if ((!this.retained || this.settled !== void 0 && !this.failed) && !(this.retained && args.retention?.preserveEnvironment) && !(this.unavailable !== void 0 && !this.failed) && !held && (args.options.destroyOnSettle ?? true)) {
|
|
9921
|
+
const cleanup = await destroyExecutorEnvironment(this.args.scope);
|
|
9922
|
+
if (cleanup.destroyed) return;
|
|
9923
|
+
const error = new Error(cleanup.detail ?? "provider environment teardown was not confirmed");
|
|
9924
|
+
if (this.settled !== void 0) this.args.scope.state.artifact = {
|
|
9925
|
+
...this.settled,
|
|
9926
|
+
teardown: {
|
|
9927
|
+
failed: true,
|
|
9928
|
+
error: error.message,
|
|
9929
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
9930
|
+
}
|
|
9931
|
+
};
|
|
9932
|
+
else if (!this.failed) {
|
|
9933
|
+
this.failure = error;
|
|
9934
|
+
this.failed = true;
|
|
9935
|
+
} else if (this.failure instanceof Error) Object.assign(this.failure, { cause: this.failure.cause ?? error });
|
|
9936
|
+
}
|
|
9861
9937
|
}
|
|
9862
9938
|
};
|
|
9863
9939
|
// src/runtime/environment-provider/provider-usage-account.ts
|
|
@@ -10321,6 +10397,7 @@ function providerMaterialization(provider, createProfile, node, executionId, ret
|
|
|
10321
10397
|
provider: provider.name,
|
|
10322
10398
|
destroyOnSettle: retention?.preserveEnvironment ? false : options.destroyOnSettle ?? true,
|
|
10323
10399
|
requireTerminalEvent: options.requireTerminalEvent ?? true,
|
|
10400
|
+
...options.outputFormat === void 0 ? {} : { outputFormat: options.outputFormat },
|
|
10324
10401
|
tokenLimits,
|
|
10325
10402
|
...placement ? { placement } : {}
|
|
10326
10403
|
}
|
|
@@ -10348,13 +10425,17 @@ function providerMaterialization(provider, createProfile, node, executionId, ret
|
|
|
10348
10425
|
// src/runtime/environment-provider/provider-executor-lifecycle.ts
|
|
10349
10426
|
function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
10350
10427
|
if (options.workspaceRetention !== void 0) assertProviderWorkspaceRetentionPort(options.workspaceRetention, `providerAsExecutor(${provider.name})`);
|
|
10351
|
-
const node =
|
|
10428
|
+
const node = detachedSnapshot(ctx.node, "provider executor node");
|
|
10352
10429
|
const retention = retainedExecutorContext(ctx);
|
|
10430
|
+
if (options.outputFormat !== void 0 && (options.outputFormat !== "json" || retention?.onEvidence === void 0 || options.requireTerminalEvent === false)) throw new ValidationError("providerAsExecutor: JSON output requires Runtime-owned durable evidence and a native terminal receipt");
|
|
10353
10431
|
const managerStop = readOptionalAbortSignal(ctx, bridgeStopSignalKey, "provider");
|
|
10354
10432
|
const createProfile = options.profileForCreate?.(profile) ?? profile;
|
|
10355
10433
|
if (placement && canonicalAgentProfileDigest(createProfile) !== canonicalAgentProfileDigest(profile)) throw new ValidationError("provider placement: profileForCreate cannot change the selected profile");
|
|
10356
10434
|
const executionId = retention?.executionId ?? node?.nodeId ?? `provider-run-${randomUUID()}`;
|
|
10357
10435
|
const state = new ProviderExecutorState(ctx.signal, executionId);
|
|
10436
|
+
state.pending = admittedEnvironmentId(retention) !== void 0;
|
|
10437
|
+
state.workspaceControlRef = admittedControlRef(retention);
|
|
10438
|
+
state.providerSessionId = state.workspaceControlRef?.sessionId ?? null;
|
|
10358
10439
|
let executor;
|
|
10359
10440
|
const scope = {
|
|
10360
10441
|
provider,
|
|
@@ -14990,6 +15071,7 @@ function snapshotExecutorConfig(config) {
|
|
|
14990
15071
|
});
|
|
14991
15072
|
}
|
|
14992
15073
|
case "provider": {
|
|
15074
|
+
if (config.outputFormat !== void 0 && config.steering !== void 0) throw new ValidationError$1("createExecutor(provider): JSON output is not supported with steering");
|
|
14993
15075
|
const { provider, registry, profileForCreate, taskToTurn, validator, workspaceRetention, shared, ...decisionData } = config;
|
|
14994
15076
|
if (shared !== void 0 && (decisionData.steering !== void 0 || decisionData.placements !== void 0 || workspaceRetention !== void 0)) throw new ValidationError$1("createExecutor(provider): shared placement cannot combine with steering, placements, or workspaceRetention");
|
|
14995
15077
|
const snapshot = detachedSnapshot(decisionData, "createExecutor provider config");
|
|
@@ -15054,6 +15136,7 @@ function snapshotExecutorConfig(config) {
|
|
|
15054
15136
|
"bridgeBearer",
|
|
15055
15137
|
"bridgeUrl",
|
|
15056
15138
|
"cwd",
|
|
15139
|
+
"harnessTranscript",
|
|
15057
15140
|
"maxReconnects",
|
|
15058
15141
|
"modelCredential",
|
|
15059
15142
|
"modelSilenceMs",
|
|
@@ -15061,12 +15144,14 @@ function snapshotExecutorConfig(config) {
|
|
|
15061
15144
|
"sessionId",
|
|
15062
15145
|
"timeoutMs"
|
|
15063
15146
|
]), "createExecutor bridge config");
|
|
15064
|
-
const { modelCredential, ...decisionData } = config;
|
|
15147
|
+
const { modelCredential, harnessTranscript, ...decisionData } = config;
|
|
15148
|
+
if (harnessTranscript !== void 0 && typeof harnessTranscript !== "function") throw new ValidationError$1("createExecutor bridge: harnessTranscript must be a capture function");
|
|
15065
15149
|
const snapshot = detachedSnapshot(decisionData, "createExecutor bridge config");
|
|
15066
15150
|
const capturedCredential = validateBridgeModelCredential(modelCredential, config.bridgeUrl, "createExecutor bridge config");
|
|
15067
15151
|
return Object.freeze({
|
|
15068
15152
|
...snapshot,
|
|
15069
|
-
...capturedCredential === void 0 ? {} : { modelCredential: capturedCredential }
|
|
15153
|
+
...capturedCredential === void 0 ? {} : { modelCredential: capturedCredential },
|
|
15154
|
+
...harnessTranscript === void 0 ? {} : { harnessTranscript }
|
|
15070
15155
|
});
|
|
15071
15156
|
}
|
|
15072
15157
|
case "cli": return detachedSnapshot(config, `createExecutor ${config.backend} config`);
|
|
@@ -16968,20 +17053,10 @@ async function openRunTree(opts, now) {
|
|
|
16968
17053
|
}
|
|
16969
17054
|
async function resumeRunTree(opts, prior, now, runStartedAt, rootAttemptId) {
|
|
16970
17055
|
const runEpochMs = rootStartedAtMs(assertResumeContract(prior, opts));
|
|
16971
|
-
const
|
|
16972
|
-
const
|
|
16973
|
-
if (opts.signal?.aborted) abortRecovery();
|
|
16974
|
-
else opts.signal?.addEventListener("abort", abortRecovery, { once: true });
|
|
16975
|
-
let restored;
|
|
16976
|
-
try {
|
|
16977
|
-
const cancelledAtEntry = opts.signal?.aborted === true && opts.signal.reason instanceof RunCancellationReason;
|
|
16978
|
-
restored = await prepareScopeResume(opts, prior, recoveryController.signal, now, opts.runId, cancelledAtEntry);
|
|
16979
|
-
} finally {
|
|
16980
|
-
opts.signal?.removeEventListener("abort", abortRecovery);
|
|
16981
|
-
}
|
|
16982
|
-
const resumeFrom = restored.resumeFrom;
|
|
17056
|
+
const cancelledAtEntry = opts.signal?.aborted === true && opts.signal.reason instanceof RunCancellationReason;
|
|
17057
|
+
const { resumeFrom, poolRestore } = await prepareScopeResume(opts, prior, opts.signal ?? new AbortController().signal, now, opts.runId, cancelledAtEntry);
|
|
16983
17058
|
const events = [...resumeFrom.events];
|
|
16984
|
-
const pool = createBudgetPool(opts.budget, runEpochMs,
|
|
17059
|
+
const pool = createBudgetPool(opts.budget, runEpochMs, poolRestore);
|
|
16985
17060
|
await recordRootSegment(opts, events, runStartedAt, false);
|
|
16986
17061
|
await recordRootReentered(opts, resumeFrom, runStartedAt);
|
|
16987
17062
|
return {
|
|
@@ -17343,4 +17418,4 @@ async function noWinner(settled, rejection) {
|
|
|
17343
17418
|
}
|
|
17344
17419
|
export { DEFAULT_PEER_MAIL_LIMITS as $, sandboxActProfileMaterialization as $t, createSandboxForSpec as A, ROUTER_PRICE_SOURCE as At, createRouterTranscript as B, runWorktreeHarness as Bt, createExecutor as C, checkVerdictOf as Ct, runAgentRounds as D, bridgeAdmissionRefusal as Dt, createSteerableSandboxSession as E, isFiniteNumber as Et, codeModeArguments as F, createPushTraceSource as Ft, LEAF_CONTINUATION_TASK as G, assertProfileMaterializes as Gt, createAgentEnvironmentProviderRegistry as H, harnessInvocation as Ht, codeModeModelOutput as I, bridgeRuntimeAttachmentsKey as It, createInPlaceCliExecutor as J, fullProfileMaterialization as Jt, providerAsSandboxClient as K, controlProfileMaterialization as Kt, createCodeModeTools as L, bridgeStopSignalKey as Lt, acquireSandbox as M, createCodexRolloutStoreReader as Mt, TERMINAL_DECISIONS as N, harnessUsageIsEmpty as Nt, assertBoxlessPromptOptions as O, bridgeModelRouteRefusal as Ot, defaultSelectWinner as P, readCodexRolloutSession as Pt, AUTHORITY_MARKERS as Q, renderUnsupported as Qt, runCodeMode as R, defaultRunCommand as Rt, captureReusableExecutorConfig as S, bestComposite as St, DEFAULT_SANDBOX_STEERING_MAX_TURNS as T, failedItems as Tt, resolveAgentEnvironmentProvider as U, terminateProcessTreeAndConfirm as Ut, routerBrain as V, LOCAL_HARNESSES as Vt, providerAsExecutor as W, assertProfileMaterialization as Wt, createInbox as X, promptControlProfileMaterialization as Xt, INBOX_RECEIPT_KEY as Y, profileMaterializationAxes$1 as Yt, failPendingAfter as Z, promptModelProfileMaterialization as Zt, withDriverExecutor as _, gateOnDeliverable as _t, assertRunParking as a, peerMailVerbNames as at, createExecutorRegistry as b, CONTINUATIONS_DIR as bt, sleepScopeWait as c, HarnessTurnFailedError as ct, runFinalizer as d, classifyDriverFailure as dt, sandboxProfileMaterialization as en, PEER_MAIL_WIRE_KEY as et, runTree as f, summarizeDriverAttempts as ft, isDriverSpec as g, gateFactoryOnDeliverable as gt, driverExecutorFactory as h, CheckUnavailableError as ht, RunParkedError as i, readSandboxOutcome as in, peerMailTools as it, createSandboxLineage as j, addHarnessUsage as jt, readPromptOptions as k, priceTokens as kt, withRunParking as l, abandonablePending as lt, driverChild as m, upstreamUnavailableSignal as mt, createSupervisor as n, worktreeCliProfileMaterialization as nn, createPeerMailbox as nt, bindScopeParkingDrain as o, taskToPrompt$1 as ot, createRootHandle as p, undispatchedCredentialExit as pt, createWorktreeCliExecutor as q, defineProfileMaterializationContract as qt, assertResumeLimits as r, projectSandboxOutcome as rn, isPeerMailEnvelope as rt, readRunParking as s, DriverAttemptsExhaustedError as st, DEFAULT_MAX_DEPTH as t, unsupportedProfileDimensions as tn, claimsAuthority as tt, bestDelivered as u, causedByPartialFailure as ut, InMemoryResultBlobStore as v, mapExecutorResult as vt, snapshotExecutorConfig as w, createContinuationKeeper as wt, bindReusableExecutorExecutionId as x, admitContinuationPolicy as xt, InMemorySpawnJournal as y, verdictFromJudgeScore as yt, toolResultText as z, runSettledCommand as zt };
|
|
17345
17420
|
|
|
17346
|
-
//# sourceMappingURL=supervisor-
|
|
17421
|
+
//# sourceMappingURL=supervisor-REUnT7iX.js.map
|