@tangle-network/sandbox 1.0.208 → 1.0.210
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/README.md +1 -1
- package/dist/abort-signal-BbJTt2QJ.js +31 -0
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +4 -4
- package/dist/agent/preview.d.ts +1 -1
- package/dist/agent/preview.js +1 -1
- package/dist/{agent-run-outcome-1NHcTtoo.d.ts → agent-run-outcome-CP2N40aT.d.ts} +1 -1
- package/dist/api-request-CUIrVFhJ.js +173 -0
- package/dist/{browser-interactive-control-controller-BYbNLahH.js → browser-interactive-control-controller-BiP6TJFP.js} +1 -1
- package/dist/{chunked-upload-BTdDxWFj.js → chunked-upload-D6ZCQ-iN.js} +15 -11
- package/dist/{chunked-upload-file-5GlXGjhY.js → chunked-upload-file-D3YxQdAl.js} +2 -2
- package/dist/{client-Bp3Gqf0e.d.ts → client-DiLd0XGB.d.ts} +4 -4
- package/dist/{client-DN4Ug-ub.js → client-DyKdtYDZ.js} +24 -29
- package/dist/{core-7rGEb0lF.js → core-DDgUWBS7.js} +2 -2
- package/dist/core.d.ts +5 -5
- package/dist/core.js +3 -3
- package/dist/{direct-http2-Bqtn2jg3.js → direct-http2-DU2SK2Wo.js} +1 -1
- package/dist/{index-BVEpMspL.d.ts → index-DyFU9hy7.d.ts} +5 -6
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -7
- package/dist/intelligence/index.js +1 -1
- package/dist/interactive-control.js +1 -1
- package/dist/{interactive-controller-DuyS5n9z.d.ts → interactive-controller-BzObb8aT.d.ts} +1 -1
- package/dist/{interactive-controller-B09YfFqP.js → interactive-controller-C-CuPVMA.js} +8 -6
- package/dist/lib/prepared-evidence.js +1 -1
- package/dist/lib/prepared-process.js +1 -1
- package/dist/{lines-DGke3URt.d.ts → lines-D0dHQ3X5.d.ts} +1 -1
- package/dist/lines.d.ts +1 -1
- package/dist/{mcp-local-BHCdMtdh.js → mcp-local-BW6W0Vh8.js} +3 -3
- package/dist/{prepared-evidence-4prvV0YK.js → prepared-evidence--rjwnXGD.js} +2 -12
- package/dist/{prepared-process-BSpZXDDw.js → prepared-process-N-y0xr9S.js} +2 -14
- package/dist/{preview-Din4zRB-.d.ts → preview-CrXG9Y8a.d.ts} +3 -3
- package/dist/{public-templates-k5rHh7Up.d.ts → public-templates-Ba-DTf2O.d.ts} +1 -1
- package/dist/public-templates.d.ts +1 -1
- package/dist/{raw-evidence-archive-C5H8BaHr.js → raw-evidence-archive-DrgeV9_0.js} +1 -1
- package/dist/retry-policy-0_NCh5OB.js +88 -0
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +4 -4
- package/dist/{sandbox-BQ_u_Fjy.js → sandbox-DRZ1nTd3.js} +123 -156
- package/dist/select-seat-command.d.ts +1 -1
- package/dist/session-gateway/index.js +3 -3
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-B-Sv_5XW.js → tangle-BPDYjDpX.js} +1 -1
- package/dist/{types-BVcWpKvF.d.ts → types-BE70nj5h.d.ts} +2 -2
- package/package.json +5 -5
- package/dist/abort-signal-Cu4F2VVz.js +0 -62
- package/dist/api-request-BBNFh7Zx.js +0 -92
- package/dist/response-rewrap-Cjoxh2wZ.js +0 -28
- /package/dist/{file-transfer-Cr9Ossea.js → file-transfer-BSe4ayU9.js} +0 -0
- /package/dist/{keep-alive-fetch-C2lFwrMA.js → keep-alive-fetch-BIaDMUtu.js} +0 -0
- /package/dist/{sidecar-proxy-error-DTJbOAWL.js → sidecar-proxy-error-DpBLxIof.js} +0 -0
- /package/dist/{sse-parser-DXRUx6gh.js → sse-parser-DOCszo1K.js} +0 -0
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { A as normalizeRuntimeBackendConfig, C as encodeTextForWire, D as applyRequestedModel, F as withoutRuntimeSecrets, I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, O as assertCurrentBackendType, S as encodePromptForWire, T as canUseNodeHttp2, W as normalizeEffectiveBackend, _ as isTraceId, a as assertScopedTokenActive, b as resolveDispatchRunIdentity, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as TRACE_ID_HEADER, h as isRetryableCredentialRefusal, i as terminalUpgradeHeadersSupported, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as mintTraceId, w as runtimeFilesystemPath, x as validateAcceptedDispatchRunRef, y as resolveTraceId } from "./interactive-controller-
|
|
1
|
+
import { A as normalizeRuntimeBackendConfig, C as encodeTextForWire, D as applyRequestedModel, F as withoutRuntimeSecrets, I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, O as assertCurrentBackendType, S as encodePromptForWire, T as canUseNodeHttp2, W as normalizeEffectiveBackend, _ as isTraceId, a as assertScopedTokenActive, b as resolveDispatchRunIdentity, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as TRACE_ID_HEADER, h as isRetryableCredentialRefusal, i as terminalUpgradeHeadersSupported, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as mintTraceId, w as runtimeFilesystemPath, x as validateAcceptedDispatchRunRef, y as resolveTraceId } from "./interactive-controller-C-CuPVMA.js";
|
|
2
2
|
import { C as boundedIdentifierSchema, E as boundedStringSchema, g as sha256DigestSchema$1, o as canonicalCandidateDigest$1, s as canonicalCandidateJson$1, u as isCanonicalJsonValue$1 } from "./harness-DMaNgn0S.js";
|
|
3
3
|
import { t as sha256 } from "./sha2-vu4U-x2L.js";
|
|
4
|
-
import { A as agentInteractiveSessionStatusMatchesRef, B as PlanContinuationSchema, C as AgentInteractiveSessionStopAcknowledgementSchema, D as agentInteractiveSessionControlClaimMatchesRef, E as agentInteractiveSessionControlClaimIsNewer, F as AgentRunCancellationAcknowledgementSchema, G as InteractionResponseSchema, H as InteractionBindingSchema, I as AgentRunCancellationRequestSchema, L as agentRunCancellationAcknowledgementMatchesRequest, M as agentInteractiveDimensionSchema, N as sameAgentExactRun, O as agentInteractiveSessionPromptAcknowledgementMatchesCommand, P as AgentExactRunControlRefSchema, S as AgentInteractiveSessionStatusSchema, T as agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, U as InteractionRequestSchema, V as InteractionAcknowledgementSchema, W as InteractionResponseCommandSchema, _ as AgentInteractiveSessionControlClaimRequestSchema, b as AgentInteractiveSessionPromptCommandSchema, d as interactiveSessionControlClaimResponseSchema, f as interactiveSessionControlReleaseResponseSchema, g as AgentInteractiveSessionControlClaimAcknowledgementSchema, h as AgentInteractiveSessionAttachSchema, j as agentInteractiveSessionStopAcknowledgementMatchesCommand, l as createInteractiveControlHolderId, m as interactiveSessionStatusResponseSchema, p as interactiveSessionControlValidationResponseSchema, v as AgentInteractiveSessionControlClaimSchema, w as AgentInteractiveSessionStopCommandSchema, x as AgentInteractiveSessionRefSchema, y as AgentInteractiveSessionPromptAcknowledgementSchema } from "./browser-interactive-control-controller-
|
|
4
|
+
import { A as agentInteractiveSessionStatusMatchesRef, B as PlanContinuationSchema, C as AgentInteractiveSessionStopAcknowledgementSchema, D as agentInteractiveSessionControlClaimMatchesRef, E as agentInteractiveSessionControlClaimIsNewer, F as AgentRunCancellationAcknowledgementSchema, G as InteractionResponseSchema, H as InteractionBindingSchema, I as AgentRunCancellationRequestSchema, L as agentRunCancellationAcknowledgementMatchesRequest, M as agentInteractiveDimensionSchema, N as sameAgentExactRun, O as agentInteractiveSessionPromptAcknowledgementMatchesCommand, P as AgentExactRunControlRefSchema, S as AgentInteractiveSessionStatusSchema, T as agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, U as InteractionRequestSchema, V as InteractionAcknowledgementSchema, W as InteractionResponseCommandSchema, _ as AgentInteractiveSessionControlClaimRequestSchema, b as AgentInteractiveSessionPromptCommandSchema, d as interactiveSessionControlClaimResponseSchema, f as interactiveSessionControlReleaseResponseSchema, g as AgentInteractiveSessionControlClaimAcknowledgementSchema, h as AgentInteractiveSessionAttachSchema, j as agentInteractiveSessionStopAcknowledgementMatchesCommand, l as createInteractiveControlHolderId, m as interactiveSessionStatusResponseSchema, p as interactiveSessionControlValidationResponseSchema, v as AgentInteractiveSessionControlClaimSchema, w as AgentInteractiveSessionStopCommandSchema, x as AgentInteractiveSessionRefSchema, y as AgentInteractiveSessionPromptAcknowledgementSchema } from "./browser-interactive-control-controller-BiP6TJFP.js";
|
|
5
5
|
import { a as ProxySecretReceiptSchema, o as canonicalAgentProfileValue, r as agentProfileSchema } from "./profile-schema-C1KpT-wS.js";
|
|
6
6
|
import { C as ServerError, D as ValidationError, E as TimeoutError, S as SandboxError, T as StreamInterruptedError, _ as NotFoundError, a as readResponseJson, d as EdgeNotReadyError, g as NetworkError, i as parseResponseError, l as CapabilityError, n as isTransientWrite, o as retryWhen, r as parseErrorResponse, s as AuthError, t as TerminalStreamError, w as StateError, y as ProfileFileMountPathError } from "./errors-CNszZUZ2.js";
|
|
7
|
-
import {
|
|
8
|
-
import { a as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { t as
|
|
12
|
-
import { t as
|
|
13
|
-
import {
|
|
14
|
-
import { t as
|
|
7
|
+
import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-BbJTt2QJ.js";
|
|
8
|
+
import { a as backoffDelayMs, r as abortableSleep } from "./retry-policy-0_NCh5OB.js";
|
|
9
|
+
import { a as SANDBOX_PROXY_REQUEST_MAX_BYTES, c as PROFILE_FILE_MOUNT_OUTSIDE_ROOTS_CODE, d as isProfileFileMountOutsideRoots, f as profileFileMountOutsideRootsMessage, l as SANDBOX_AGENT_HOME, o as FILE_OPERATION_LIMITS, u as SANDBOX_FILE_API_ABSOLUTE_ROOTS } from "./file-transfer-BSe4ayU9.js";
|
|
10
|
+
import { c as awaitSdkResend, l as countSdkRequest, s as uploadChunked, u as takeSdkTurn } from "./chunked-upload-D6ZCQ-iN.js";
|
|
11
|
+
import { a as rewrapResponse, i as isReplayableBody, t as IDEMPOTENT_METHODS } from "./api-request-CUIrVFhJ.js";
|
|
12
|
+
import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-BIaDMUtu.js";
|
|
13
|
+
import { t as SIDECAR_PROXY_ERROR_HEADER } from "./sidecar-proxy-error-DpBLxIof.js";
|
|
14
|
+
import { t as parseSSEStream } from "./sse-parser-DOCszo1K.js";
|
|
15
|
+
import { t as runPreparedProcess } from "./prepared-process-N-y0xr9S.js";
|
|
15
16
|
import { a as isBackendType, r as cliAuthReferenceSchema } from "./cli-auth-bundle-C6DtK7GX-BbbiAn-Z.js";
|
|
16
17
|
import "./cli-auth-bundle-CMJWI99l.js";
|
|
17
18
|
import { n as SandboxLines } from "./lines-DHOIUO-t.js";
|
|
@@ -261,13 +262,9 @@ const DEFAULT_CREATE_TIMEOUT_MS = 12e4;
|
|
|
261
262
|
const DEFAULT_GPU_CREATE_TIMEOUT_MS = 900 * 1e3;
|
|
262
263
|
const CREATE_RETRY_MAX_DELAY_MS = 4e3;
|
|
263
264
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* internal owner paced behind customers. Re-POSTing is safe: the idempotency
|
|
268
|
-
* key joins whichever provision did start. `SANDBOX_CREATE_RECONCILING` is
|
|
269
|
-
* deliberately absent: it follows a retained real failure and outlasts any
|
|
270
|
-
* budget here.
|
|
265
|
+
* 503s that mean "the cell cannot place this now, ask again"; re-POSTing is
|
|
266
|
+
* safe because the key joins any provision that did start.
|
|
267
|
+
* `SANDBOX_CREATE_RECONCILING` is absent: it outlasts any budget here.
|
|
271
268
|
*/
|
|
272
269
|
const DEPLOY_WINDOW_RETRY_CODES = new Set([
|
|
273
270
|
"INTERNAL_CREATE_PACED",
|
|
@@ -311,32 +308,28 @@ function isDeployWindowCreateError(cause) {
|
|
|
311
308
|
}
|
|
312
309
|
/** A no-room refusal allocated nothing, so a create giving up on one reports this typed 503. */
|
|
313
310
|
const isCapacityShortageCreateError = (cause) => isDeployWindowCreateError(cause) && (cause.code === "CAPACITY_EXHAUSTED" || cause.code === "HOST_PRESSURE");
|
|
314
|
-
/**
|
|
315
|
-
* The plan rate limiter's 429 (a quota 429 is final). Answered right after a
|
|
316
|
-
* capacity refusal on the same key it is part of that pacing: retried on its
|
|
317
|
-
* own `Retry-After` on the time budget, spending none of the attempt budget.
|
|
318
|
-
*/
|
|
311
|
+
/** The plan limiter's 429 (a quota 429 is final), paced on its own `Retry-After` within the time budget. */
|
|
319
312
|
function isRateLimitCreateError(cause) {
|
|
320
313
|
return retryWhen(cause) && cause.status === 429;
|
|
321
314
|
}
|
|
322
|
-
/**
|
|
323
|
-
* Create retries what the catalog marks retryable (a 524 is a `TIMEOUT`, so a
|
|
324
|
-
* key that a proxy cut off is joined), except a 409, which create never
|
|
325
|
-
* retried, and a customer-floor hold: the cell keeps that room for customers
|
|
326
|
-
* and a re-POST meets the same hold.
|
|
327
|
-
*/
|
|
315
|
+
/** Create retries what the catalog marks retryable (a 524 `TIMEOUT` joins its key), except a 409 and a customer-floor hold. */
|
|
328
316
|
function isRetryableCreateError(cause) {
|
|
329
317
|
return retryWhen(cause) && cause.status !== 409 && !cause.capacityHold;
|
|
330
318
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Longest wait on an `IDEMPOTENT_CREATE_PROBE_FAILED` `Retry-After`: the
|
|
333
|
-
* probe answers again within seconds, and an upstream 11.8 s hint ended a
|
|
334
|
-
* create on 10-26 instead of re-probing.
|
|
335
|
-
*/
|
|
319
|
+
/** Longest wait on an `IDEMPOTENT_CREATE_PROBE_FAILED` `Retry-After`: the probe answers again within seconds. */
|
|
336
320
|
const PROBE_FAILED_MAX_DELAY_MS = 5e3;
|
|
321
|
+
function createRetryAfterMs(cause) {
|
|
322
|
+
if (!(cause instanceof SandboxError) || cause.retryAfterMs === void 0) return void 0;
|
|
323
|
+
return cause.code === "IDEMPOTENT_CREATE_PROBE_FAILED" ? Math.min(cause.retryAfterMs, PROBE_FAILED_MAX_DELAY_MS) : cause.retryAfterMs;
|
|
324
|
+
}
|
|
337
325
|
function createRetryDelayMs(cause, failedAttempt) {
|
|
338
|
-
|
|
339
|
-
|
|
326
|
+
return backoffDelayMs(failedAttempt, createRetryAfterMs(cause), CREATE_RETRY_MAX_DELAY_MS);
|
|
327
|
+
}
|
|
328
|
+
/** Wait `delayMs`, and a re-send the server did not pace also its budget turn; throws when that falls past `deadline`. */
|
|
329
|
+
async function awaitCreateResend(delayMs, deadline, signal, cause) {
|
|
330
|
+
const turnMs = createRetryAfterMs(cause) !== void 0 ? 0 : takeSdkTurn(deadline - Date.now() - delayMs);
|
|
331
|
+
if (turnMs === void 0) throw new Error("No retry turn before deadline");
|
|
332
|
+
await abortableSleep(Math.max(delayMs, turnMs), signal);
|
|
340
333
|
}
|
|
341
334
|
function generateIdempotencyKey() {
|
|
342
335
|
const c = globalThis.crypto;
|
|
@@ -347,21 +340,21 @@ function generateIdempotencyKey() {
|
|
|
347
340
|
}
|
|
348
341
|
throw new Error("idempotency key generation requires global crypto");
|
|
349
342
|
}
|
|
350
|
-
const FORK_OUTAGE_CODES = new Set(["UNAVAILABLE", "STORAGE_UNAVAILABLE"]);
|
|
351
343
|
/**
|
|
352
|
-
* A fork re-POSTs the refusals a create waits out
|
|
353
|
-
*
|
|
354
|
-
*
|
|
344
|
+
* A fork re-POSTs the refusals a create waits out: none started a fan-out,
|
|
345
|
+
* and the keyed re-POST joins one that did. The transport already resends
|
|
346
|
+
* the keyed POST through a gateway 502, 503 or 504.
|
|
355
347
|
*/
|
|
356
348
|
async function retryForkRefusal(post) {
|
|
357
|
-
const
|
|
349
|
+
const deadlineAt = Date.now() + DEPLOY_WINDOW_RETRY_MS;
|
|
358
350
|
for (let failed = 1;; failed++) try {
|
|
359
351
|
return await post();
|
|
360
352
|
} catch (cause) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
353
|
+
if (!isDeployWindowCreateError(cause) || !await awaitSdkResend(failed, {
|
|
354
|
+
retryAfterMs: createRetryAfterMs(cause),
|
|
355
|
+
deadlineAt,
|
|
356
|
+
capMs: 4e3
|
|
357
|
+
})) throw cause;
|
|
365
358
|
}
|
|
366
359
|
}
|
|
367
360
|
//#endregion
|
|
@@ -2789,14 +2782,6 @@ const READ_METHODS = new Set([
|
|
|
2789
2782
|
function apiOwnedRuntimeRoute(method, path) {
|
|
2790
2783
|
return !READ_METHODS.has(method) && /^(?:agents|session)(?:\/|$)/.test(path);
|
|
2791
2784
|
}
|
|
2792
|
-
/** RFC 9110 idempotent methods: applying one twice leaves what once did. */
|
|
2793
|
-
const IDEMPOTENT_METHODS = new Set([
|
|
2794
|
-
"GET",
|
|
2795
|
-
"HEAD",
|
|
2796
|
-
"OPTIONS",
|
|
2797
|
-
"PUT",
|
|
2798
|
-
"DELETE"
|
|
2799
|
-
]);
|
|
2800
2785
|
/** POST routes that only read: the body carries the query, not a change. */
|
|
2801
2786
|
const READ_ONLY_POSTS = new Set([
|
|
2802
2787
|
"files/read",
|
|
@@ -2807,12 +2792,6 @@ const READ_ONLY_POSTS = new Set([
|
|
|
2807
2792
|
function isReplaySafe(method, path) {
|
|
2808
2793
|
return IDEMPOTENT_METHODS.has(method) || method === "POST" && READ_ONLY_POSTS.has(path);
|
|
2809
2794
|
}
|
|
2810
|
-
/** Whether fetch can send this body twice. A stream is read once. */
|
|
2811
|
-
function isReplayableBody(body) {
|
|
2812
|
-
if (body === void 0 || body === null || typeof body === "string") return true;
|
|
2813
|
-
if (typeof ReadableStream !== "undefined" && body instanceof ReadableStream) return false;
|
|
2814
|
-
return !(Symbol.asyncIterator in body);
|
|
2815
|
-
}
|
|
2816
2795
|
/**
|
|
2817
2796
|
* Host-agent refusals written before it forwards anything to the sidecar
|
|
2818
2797
|
* (apps/host-agent/src/routes/runtime-sidecar-proxy-request.ts): the box is
|
|
@@ -3071,8 +3050,9 @@ var DirectRuntimeHttpClient = class {
|
|
|
3071
3050
|
path
|
|
3072
3051
|
};
|
|
3073
3052
|
if (!route) throw new NetworkError("Direct runtime route was withdrawn");
|
|
3053
|
+
countSdkRequest();
|
|
3074
3054
|
if ((route.useHost || route.useExec) && canUseNodeHttp2()) {
|
|
3075
|
-
const { fetchDirectHttp2 } = await import("./direct-http2-
|
|
3055
|
+
const { fetchDirectHttp2 } = await import("./direct-http2-DU2SK2Wo.js");
|
|
3076
3056
|
return fetchDirectHttp2(route.url, request, timing);
|
|
3077
3057
|
}
|
|
3078
3058
|
return fetchWithKeepAlive(route.url, request, timing);
|
|
@@ -3405,16 +3385,14 @@ function profileFileBundleKey(mounts) {
|
|
|
3405
3385
|
files: profileBundleFileTable(mounts)
|
|
3406
3386
|
});
|
|
3407
3387
|
}
|
|
3388
|
+
//#endregion
|
|
3389
|
+
//#region src/profile-file-failure.ts
|
|
3408
3390
|
const PROFILE_FILE_MOUNT_RETRY_MAX_MS = 2e3;
|
|
3409
3391
|
/**
|
|
3410
|
-
* Wall-clock ceiling for
|
|
3411
|
-
*
|
|
3412
|
-
* 3 s key-verification budget, so this admits about three such attempts: it
|
|
3413
|
-
* rides out a stall of a few seconds without holding create() through a
|
|
3414
|
-
* platform restart, which the caller is better told about.
|
|
3392
|
+
* Wall-clock ceiling for re-sending one undecided file API batch write: it
|
|
3393
|
+
* rides a stall of a few seconds, not a platform restart the caller should hear of.
|
|
3415
3394
|
*/
|
|
3416
3395
|
const PROFILE_FILE_MOUNT_WRITE_RETRY_BUDGET_MS = 1e4;
|
|
3417
|
-
const waitForProfileFileMount = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
3418
3396
|
var ProfileFileMountExecTimeoutError = class extends Error {
|
|
3419
3397
|
constructor(timeoutMs) {
|
|
3420
3398
|
super(`exec exceeded ${timeoutMs}ms`);
|
|
@@ -3581,10 +3559,11 @@ async function writeBatchRidingOutUndecided(write, maxRetries) {
|
|
|
3581
3559
|
await write();
|
|
3582
3560
|
return;
|
|
3583
3561
|
} catch (err) {
|
|
3584
|
-
if (!(retryWhen(err) && (err instanceof NetworkError || err.status >= 502 && !(err instanceof TimeoutError))) || attempt >= maxRetries
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3562
|
+
if (!(retryWhen(err) && (err instanceof NetworkError || err.status >= 502 && !(err instanceof TimeoutError))) || attempt >= maxRetries || !await awaitSdkResend(attempt + 1, {
|
|
3563
|
+
retryAfterMs: retryAfterMs(err),
|
|
3564
|
+
deadlineAt: startedAt + PROFILE_FILE_MOUNT_WRITE_RETRY_BUDGET_MS,
|
|
3565
|
+
capMs: 2e3
|
|
3566
|
+
})) throw err;
|
|
3588
3567
|
}
|
|
3589
3568
|
}
|
|
3590
3569
|
//#endregion
|
|
@@ -3776,7 +3755,7 @@ function isFileApiRootOnlyError(error) {
|
|
|
3776
3755
|
//#endregion
|
|
3777
3756
|
//#region src/profile-file-mounts.ts
|
|
3778
3757
|
const PROFILE_FILE_MOUNT_B64_CHUNK_CHARS = 3e3;
|
|
3779
|
-
const PROFILE_FILE_MOUNT_MAX_RETRIES =
|
|
3758
|
+
const PROFILE_FILE_MOUNT_MAX_RETRIES = 6;
|
|
3780
3759
|
const PROFILE_FILE_MOUNT_EXEC_TIMEOUT_MS = 3e4;
|
|
3781
3760
|
async function execProfileFileMount(box, mount, content, options, execState) {
|
|
3782
3761
|
const maxRetries = options.maxRetries ?? PROFILE_FILE_MOUNT_MAX_RETRIES;
|
|
@@ -3794,17 +3773,17 @@ async function execProfileFileMount(box, mount, content, options, execState) {
|
|
|
3794
3773
|
const homeGuard = path.startsWith("~/") ? `[ -n "$HOME" ] || { echo ${shellSingleQuote(`materializeProfileFileMounts: HOME is unset for ${path}`)} >&2; exit 1; }; ` : "";
|
|
3795
3774
|
const run = async (cmd) => {
|
|
3796
3775
|
for (let attempt = 0;; attempt++) {
|
|
3797
|
-
if (execState.started && options.paceMs > 0) await
|
|
3776
|
+
if (execState.started && options.paceMs > 0) await abortableSleep(options.paceMs);
|
|
3798
3777
|
execState.started = true;
|
|
3799
3778
|
try {
|
|
3800
3779
|
return await execWithTimeout(box, cmd, options.execTimeoutMs);
|
|
3801
3780
|
} catch (err) {
|
|
3802
3781
|
const { retryable, retryAfterMs: retryAfter } = transientExecError(err);
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
}
|
|
3782
|
+
const capMs = PROFILE_FILE_MOUNT_RETRY_MAX_MS;
|
|
3783
|
+
if (retryable && attempt < maxRetries && await awaitSdkResend(attempt + 1, {
|
|
3784
|
+
retryAfterMs: retryAfter === void 0 ? void 0 : Math.min(retryAfter, capMs),
|
|
3785
|
+
capMs
|
|
3786
|
+
})) continue;
|
|
3808
3787
|
throw new ProfileFileMaterializeError(`materializeProfileFileMounts: exec failed for ${path}`, { cause: err });
|
|
3809
3788
|
}
|
|
3810
3789
|
}
|
|
@@ -4378,26 +4357,40 @@ var SandboxOperation = class SandboxOperation {
|
|
|
4378
4357
|
* with a succeeded operation; throws {@link SandboxOperationFailedError} on
|
|
4379
4358
|
* a failed one and {@link TimeoutError} past `timeoutMs` (default 10 min).
|
|
4380
4359
|
* The verb was accepted, so a read that was lost, timed out or refused
|
|
4381
|
-
* retryably says nothing about it: read again
|
|
4382
|
-
*
|
|
4360
|
+
* retryably says nothing about it: read again on the shared retry pacing
|
|
4361
|
+
* (the server's Retry-After, else full jitter, and the client's retry budget).
|
|
4383
4362
|
*/
|
|
4384
4363
|
async wait(options = {}) {
|
|
4385
4364
|
const timeoutMs = options.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
|
|
4386
4365
|
const startedAt = Date.now();
|
|
4387
4366
|
const { signal } = options;
|
|
4388
|
-
let [delayMs, capMs] = [
|
|
4367
|
+
let [delayMs, capMs, failedReads] = [
|
|
4368
|
+
0,
|
|
4369
|
+
0,
|
|
4370
|
+
0
|
|
4371
|
+
];
|
|
4389
4372
|
let info;
|
|
4373
|
+
const timedOut = (cause) => new TimeoutError(`Timed out waiting for ${this.#info.kind} operation ${this.#info.id} (last state ${this.#info.state})`, {
|
|
4374
|
+
timeoutMs,
|
|
4375
|
+
cause
|
|
4376
|
+
});
|
|
4390
4377
|
while (!info || !isTerminalOperation(info)) {
|
|
4391
|
-
if (Date.now() - startedAt + delayMs > timeoutMs) throw
|
|
4392
|
-
signal
|
|
4393
|
-
if (delayMs > 0) await delayUntilAborted(delayMs, signal);
|
|
4378
|
+
if (Date.now() - startedAt + delayMs > timeoutMs) throw timedOut();
|
|
4379
|
+
await abortableSleep(delayMs, signal);
|
|
4394
4380
|
capMs = Math.min(Math.max(capMs * 2, FIRST_POLL_MS), MAX_POLL_MS);
|
|
4395
4381
|
try {
|
|
4396
4382
|
info = await this.refresh({ signal });
|
|
4397
|
-
delayMs = capMs;
|
|
4383
|
+
[delayMs, failedReads] = [capMs, 0];
|
|
4398
4384
|
} catch (error) {
|
|
4399
4385
|
if (!retryWhen(error) || error.code === "UPSTREAM_CONTRACT_VIOLATION") throw error;
|
|
4400
|
-
|
|
4386
|
+
const deadlineAt = startedAt + timeoutMs;
|
|
4387
|
+
const pacing = {
|
|
4388
|
+
retryAfterMs: error.retryAfterMs,
|
|
4389
|
+
signal,
|
|
4390
|
+
deadlineAt
|
|
4391
|
+
};
|
|
4392
|
+
if (!await awaitSdkResend(++failedReads, pacing)) throw timedOut(error);
|
|
4393
|
+
delayMs = 0;
|
|
4401
4394
|
}
|
|
4402
4395
|
}
|
|
4403
4396
|
signal?.throwIfAborted();
|
|
@@ -5202,7 +5195,7 @@ var SandboxPreviewCapabilities = class extends SandboxGpuCapabilities {
|
|
|
5202
5195
|
endpoint
|
|
5203
5196
|
});
|
|
5204
5197
|
try {
|
|
5205
|
-
await
|
|
5198
|
+
await abortableSleep(Math.min(pollIntervalMs, remainingAfterCheckMs), options?.signal);
|
|
5206
5199
|
} catch {
|
|
5207
5200
|
throw new TimeoutError("Aborted", {
|
|
5208
5201
|
timeoutMs: 0,
|
|
@@ -5388,7 +5381,7 @@ var SandboxLifecycleEventsCapabilities = class extends SandboxPreviewCapabilitie
|
|
|
5388
5381
|
if (this.hasReachedWaitTarget(statuses)) return;
|
|
5389
5382
|
if (this.status === "failed") throw new StateError(this.error ?? "Sandbox failed", { currentState: this.status });
|
|
5390
5383
|
if (Date.now() - startTime > timeoutMs) throw new TimeoutError(`Timed out waiting for sandbox to reach ${statuses.join(" or ")}`, { timeoutMs });
|
|
5391
|
-
await
|
|
5384
|
+
await abortableSleep(pollIntervalMs, signal).catch(rethrowWaitError);
|
|
5392
5385
|
}
|
|
5393
5386
|
}
|
|
5394
5387
|
/**
|
|
@@ -5464,9 +5457,6 @@ var SandboxLifecycleEventsCapabilities = class extends SandboxPreviewCapabilitie
|
|
|
5464
5457
|
});
|
|
5465
5458
|
return connection?.edgeStatus !== "pending" && Boolean(connection?.hostUrl || connection?.execHost || connection?.runtimeUrl);
|
|
5466
5459
|
}
|
|
5467
|
-
sleep(ms) {
|
|
5468
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5469
|
-
}
|
|
5470
5460
|
};
|
|
5471
5461
|
//#endregion
|
|
5472
5462
|
//#region src/sandbox-lifecycle.ts
|
|
@@ -5552,7 +5542,10 @@ var SandboxLifecycleCapabilities = class extends SandboxLifecycleEventsCapabilit
|
|
|
5552
5542
|
response = await withLifecycleConflictRetry(() => state(this).client.fetch(path, {
|
|
5553
5543
|
method: "DELETE",
|
|
5554
5544
|
...options?.signal ? { signal: options.signal } : {},
|
|
5555
|
-
|
|
5545
|
+
headers: {
|
|
5546
|
+
"x-no-retry": "1",
|
|
5547
|
+
...options?.wait === false && options.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : {}
|
|
5548
|
+
}
|
|
5556
5549
|
}), options, (error) => {
|
|
5557
5550
|
const retry = isDeleteRetry(error);
|
|
5558
5551
|
retried ||= retry;
|
|
@@ -5596,19 +5589,13 @@ var SandboxLifecycleCapabilities = class extends SandboxLifecycleEventsCapabilit
|
|
|
5596
5589
|
}
|
|
5597
5590
|
};
|
|
5598
5591
|
/**
|
|
5599
|
-
* How long a lifecycle call re-attempts a refusal that only asks it to wait
|
|
5600
|
-
* `resume`, `stop` and `delete` share one lease per sandbox,
|
|
5601
|
-
*
|
|
5602
|
-
*
|
|
5603
|
-
*
|
|
5604
|
-
* provider-seam runs (agent-sdk#280) lost a completed turn to it. A
|
|
5605
|
-
* lease-store or storage outage answers 503 (us1 2026-11-01: 16/16 child
|
|
5606
|
-
* deletes failed through a Platform deploy that had removed every child). The
|
|
5607
|
-
* ceiling (~11 s) is short: a longer conflict is a real concurrent operation.
|
|
5592
|
+
* How long a lifecycle call re-attempts a refusal that only asks it to wait:
|
|
5593
|
+
* `resume`, `stop` and `delete` share one lease per sandbox, held past a
|
|
5594
|
+
* response while its deferred cleanup runs, and a lease-store outage answers
|
|
5595
|
+
* 503. 15 s of the SDK's own waits rides a release roll, however long the
|
|
5596
|
+
* server held each attempt; a longer conflict is a real operation.
|
|
5608
5597
|
*/
|
|
5609
|
-
const
|
|
5610
|
-
const LIFECYCLE_CONFLICT_BASE_DELAY_MS = 500;
|
|
5611
|
-
const LIFECYCLE_CONFLICT_MAX_DELAY_MS = 4e3;
|
|
5598
|
+
const LIFECYCLE_CONFLICT_WINDOW_MS = 15e3;
|
|
5612
5599
|
/** A lease-store or storage outage the API answers 503 before or after its effect: a retry is safe. */
|
|
5613
5600
|
const LIFECYCLE_OUTAGE_CODES = new Set(["SANDBOX_LIFECYCLE_COORDINATION_UNAVAILABLE", "STORAGE_UNAVAILABLE"]);
|
|
5614
5601
|
function isLifecycleConflict(cause) {
|
|
@@ -5618,10 +5605,6 @@ function isLifecycleConflict(cause) {
|
|
|
5618
5605
|
function isDeleteRetry(cause) {
|
|
5619
5606
|
return isLifecycleConflict(cause) || cause instanceof NetworkError || cause instanceof SandboxError && [502, 503].includes(cause.status);
|
|
5620
5607
|
}
|
|
5621
|
-
function lifecycleConflictDelayMs(cause, failedAttempt) {
|
|
5622
|
-
if (cause instanceof SandboxError && cause.retryAfterMs !== void 0) return cause.retryAfterMs;
|
|
5623
|
-
return Math.min(LIFECYCLE_CONFLICT_BASE_DELAY_MS * 2 ** Math.max(0, failedAttempt - 1), LIFECYCLE_CONFLICT_MAX_DELAY_MS);
|
|
5624
|
-
}
|
|
5625
5608
|
/**
|
|
5626
5609
|
* Run one lifecycle mutation, re-attempting only the failures `retry` names
|
|
5627
5610
|
* (by default the lifecycle refusals above).
|
|
@@ -5630,13 +5613,18 @@ function lifecycleConflictDelayMs(cause, failedAttempt) {
|
|
|
5630
5613
|
* error class, and a caller abort ends the wait immediately.
|
|
5631
5614
|
*/
|
|
5632
5615
|
async function withLifecycleConflictRetry(run, options, retry = isLifecycleConflict) {
|
|
5633
|
-
|
|
5616
|
+
let windowMs = LIFECYCLE_CONFLICT_WINDOW_MS;
|
|
5617
|
+
for (let resend = 1;; resend += 1) try {
|
|
5634
5618
|
const response = await run();
|
|
5635
5619
|
if (!response.ok) throw await parseResponseError(response);
|
|
5636
5620
|
return response;
|
|
5637
5621
|
} catch (error) {
|
|
5638
|
-
if (!retry(error) ||
|
|
5639
|
-
|
|
5622
|
+
if (!retry(error) || options?.signal?.aborted || !await awaitSdkResend(resend, {
|
|
5623
|
+
retryAfterMs: error instanceof SandboxError ? error.retryAfterMs : void 0,
|
|
5624
|
+
deadlineAt: Date.now() + windowMs,
|
|
5625
|
+
signal: options?.signal,
|
|
5626
|
+
spent: (waitedMs) => windowMs -= waitedMs
|
|
5627
|
+
})) throw error;
|
|
5640
5628
|
}
|
|
5641
5629
|
}
|
|
5642
5630
|
/** The largest delay `setTimeout` holds: past this it overflows its 32-bit
|
|
@@ -7132,7 +7120,7 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
|
|
|
7132
7120
|
async writeManySequential(files, paceMs, maxRetries) {
|
|
7133
7121
|
let started = false;
|
|
7134
7122
|
for (const file of files) for (let attempt = 0;; attempt++) {
|
|
7135
|
-
if (started && paceMs > 0) await
|
|
7123
|
+
if (started && paceMs > 0) await abortableSleep(paceMs);
|
|
7136
7124
|
started = true;
|
|
7137
7125
|
try {
|
|
7138
7126
|
await this.writeFileRequest(file.path, file.content, {
|
|
@@ -7143,11 +7131,10 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
|
|
|
7143
7131
|
});
|
|
7144
7132
|
break;
|
|
7145
7133
|
} catch (err) {
|
|
7146
|
-
if (isTransientWrite(err) && attempt < maxRetries
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
}
|
|
7134
|
+
if (isTransientWrite(err) && attempt < maxRetries && await awaitSdkResend(attempt + 1, {
|
|
7135
|
+
retryAfterMs: err instanceof SandboxError ? err.retryAfterMs : void 0,
|
|
7136
|
+
capMs: WRITE_MANY_RETRY_MAX_MS
|
|
7137
|
+
})) continue;
|
|
7151
7138
|
throw err;
|
|
7152
7139
|
}
|
|
7153
7140
|
}
|
|
@@ -7167,7 +7154,7 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
|
|
|
7167
7154
|
}
|
|
7168
7155
|
const batches = splitWriteManyBatches(files.map(toWriteManyWireFile));
|
|
7169
7156
|
for (const [index, batch] of batches.entries()) {
|
|
7170
|
-
if (index > 0 && paceMs > 0) await
|
|
7157
|
+
if (index > 0 && paceMs > 0) await abortableSleep(paceMs);
|
|
7171
7158
|
await this.writeBatchRequest(batch.files, batch.body);
|
|
7172
7159
|
}
|
|
7173
7160
|
}
|
|
@@ -7205,8 +7192,7 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
|
|
|
7205
7192
|
}
|
|
7206
7193
|
};
|
|
7207
7194
|
const WRITE_MANY_DEFAULT_PACE_MS = 0;
|
|
7208
|
-
const WRITE_MANY_DEFAULT_MAX_RETRIES =
|
|
7209
|
-
const WRITE_MANY_RETRY_BASE_MS = 250;
|
|
7195
|
+
const WRITE_MANY_DEFAULT_MAX_RETRIES = 6;
|
|
7210
7196
|
const WRITE_MANY_RETRY_MAX_MS = 2e3;
|
|
7211
7197
|
const WRITE_MANY_BATCH_WIRE_BUDGET_BYTES = SANDBOX_PROXY_REQUEST_MAX_BYTES - 8 * 1024;
|
|
7212
7198
|
function toWriteManyWireFile(file) {
|
|
@@ -7247,7 +7233,6 @@ function splitWriteManyBatches(files) {
|
|
|
7247
7233
|
function hasDuplicateWriteManyPaths(files) {
|
|
7248
7234
|
return new Set(files.map((file) => file.path)).size !== files.length;
|
|
7249
7235
|
}
|
|
7250
|
-
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7251
7236
|
//#endregion
|
|
7252
7237
|
//#region src/sandbox-profile.ts
|
|
7253
7238
|
function isProfileNotCachedError(err) {
|
|
@@ -7633,24 +7618,6 @@ function numericEventId(eventId) {
|
|
|
7633
7618
|
if (!/^\d{1,15}$/u.test(eventId)) return void 0;
|
|
7634
7619
|
return Number(eventId);
|
|
7635
7620
|
}
|
|
7636
|
-
/** Resolve after `ms`, or as soon as the signal aborts; the caller checks it. */
|
|
7637
|
-
function waitForReconnect(ms, signal) {
|
|
7638
|
-
return new Promise((resolve) => {
|
|
7639
|
-
if (signal?.aborted) {
|
|
7640
|
-
resolve();
|
|
7641
|
-
return;
|
|
7642
|
-
}
|
|
7643
|
-
const timer = setTimeout(() => {
|
|
7644
|
-
signal?.removeEventListener("abort", onAbort);
|
|
7645
|
-
resolve();
|
|
7646
|
-
}, ms);
|
|
7647
|
-
const onAbort = () => {
|
|
7648
|
-
clearTimeout(timer);
|
|
7649
|
-
resolve();
|
|
7650
|
-
};
|
|
7651
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
7652
|
-
});
|
|
7653
|
-
}
|
|
7654
7621
|
//#endregion
|
|
7655
7622
|
//#region ../../../packages/runtime-contracts/dist/interaction-response.js
|
|
7656
7623
|
/** Durable states reported for a recorded interaction response. */
|
|
@@ -8194,7 +8161,7 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
|
|
|
8194
8161
|
requestEndpoint: explicitReplay ? `/agents/run/${encodeURIComponent(options?.executionId ?? "")}/events?${replaySearch}` : `/agents/run/stream?${PART_TEXT}=${PART_TEXT_SUFFIX}`,
|
|
8195
8162
|
traceHeaders: options?.traceId ? { [TRACE_ID_HEADER]: options.traceId } : {},
|
|
8196
8163
|
lastEventId: options?.lastEventId,
|
|
8197
|
-
executionId: options?.executionId
|
|
8164
|
+
executionId: options?.executionId ?? `exec-${crypto.randomUUID()}`,
|
|
8198
8165
|
sessionId: options?.sessionId,
|
|
8199
8166
|
receivedTerminal: false,
|
|
8200
8167
|
reconnectWindowMs: resolveReconnectWindowMs(options?.reconnectWindowMs),
|
|
@@ -8209,7 +8176,8 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
|
|
|
8209
8176
|
path: `/v1/sandboxes/${encodeURIComponent(this.id)}/runtime${state.requestEndpoint}`
|
|
8210
8177
|
}, response.headers);
|
|
8211
8178
|
if (!isProfileNotCachedError(responseError)) await state.reconcileRuntimeRefusal(response.status);
|
|
8212
|
-
|
|
8179
|
+
const landed = !state.options?.executionId && responseError.code === "EXECUTION_ALREADY_EXISTS";
|
|
8180
|
+
if (!state.explicitReplay && !landed) throw responseError;
|
|
8213
8181
|
state.lastReplayStatus = response.status;
|
|
8214
8182
|
} else try {
|
|
8215
8183
|
yield* this.readPromptStream(response, state, false);
|
|
@@ -8238,7 +8206,8 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
|
|
|
8238
8206
|
signal: state.streamSignal,
|
|
8239
8207
|
headers: {
|
|
8240
8208
|
...state.traceHeaders,
|
|
8241
|
-
|
|
8209
|
+
"X-Execution-ID": state.executionId,
|
|
8210
|
+
...state.options?.executionId ? {} : { "Idempotency-Key": state.executionId },
|
|
8242
8211
|
...state.options?.detach ? { "x-agent-detach": "true" } : {}
|
|
8243
8212
|
},
|
|
8244
8213
|
body: JSON.stringify({
|
|
@@ -8267,8 +8236,10 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
|
|
|
8267
8236
|
method: request.method,
|
|
8268
8237
|
path: `/v1/sandboxes/${encodeURIComponent(this.id)}/runtime${state.requestEndpoint}`
|
|
8269
8238
|
}, response.headers);
|
|
8270
|
-
if (!isRetryableCredentialRefusal(refusal)
|
|
8271
|
-
|
|
8239
|
+
if (!isRetryableCredentialRefusal(refusal) || !await awaitSdkResend(attempt, {
|
|
8240
|
+
retryAfterMs: refusal.retryAfterMs ?? 1e3,
|
|
8241
|
+
signal: state.streamSignal
|
|
8242
|
+
})) break;
|
|
8272
8243
|
response = await this.runtimeFetch(state.requestEndpoint, request, state.internal?.forceFullProfile ? { skipProfileReference: true } : void 0);
|
|
8273
8244
|
}
|
|
8274
8245
|
} catch (err) {
|
|
@@ -8283,7 +8254,7 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
|
|
|
8283
8254
|
type: "done",
|
|
8284
8255
|
data: {
|
|
8285
8256
|
...state.sessionId ? { sessionId: state.sessionId } : {},
|
|
8286
|
-
|
|
8257
|
+
executionId: state.executionId,
|
|
8287
8258
|
status: end.status,
|
|
8288
8259
|
...end.status === "completed" ? { outcome: { type: "completed" } } : {},
|
|
8289
8260
|
...end.code ? { code: end.code } : {},
|
|
@@ -8313,10 +8284,6 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
|
|
|
8313
8284
|
}
|
|
8314
8285
|
}
|
|
8315
8286
|
async *rejoinPromptStream(state) {
|
|
8316
|
-
if (!state.executionId) throw new NetworkError("Prompt stream dropped before execution.started; cannot reconnect", {
|
|
8317
|
-
endpoint: "/agents/run/stream",
|
|
8318
|
-
origin: "runtime"
|
|
8319
|
-
});
|
|
8320
8287
|
const resumeExecutionId = state.executionId;
|
|
8321
8288
|
const interrupted = (reason, detail, cause) => {
|
|
8322
8289
|
return new StreamInterruptedError(`Prompt stream for execution ${resumeExecutionId} ended before a terminal event and could not be rejoined (${detail}); the execution's outcome is unknown${state.lastReplayStatus !== void 0 ? `; last replay status ${state.lastReplayStatus}` : ""}${state.lastExecutionStatus ? `; last known execution status ${state.lastExecutionStatus}` : ""}`, {
|
|
@@ -8340,7 +8307,7 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
|
|
|
8340
8307
|
const outageMs = Date.now() - outageStartedAt;
|
|
8341
8308
|
if (outageMs >= state.reconnectWindowMs) throw interrupted("reconnect-window-elapsed", `unreachable for ${outageMs}ms of a ${state.reconnectWindowMs}ms reconnect window`);
|
|
8342
8309
|
consecutiveFailures += 1;
|
|
8343
|
-
await
|
|
8310
|
+
await abortableSleep(Math.min(reconnectDelayMs(consecutiveFailures), state.reconnectWindowMs - outageMs), state.streamSignal).catch(() => {});
|
|
8344
8311
|
state.throwIfTimedOut();
|
|
8345
8312
|
if (state.options?.signal?.aborted || state.streamSignal?.aborted) return;
|
|
8346
8313
|
let connectedAt;
|
|
@@ -8860,7 +8827,7 @@ var SandboxInteractiveCapabilities = class extends SandboxPromptCapabilities {
|
|
|
8860
8827
|
var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabilities {
|
|
8861
8828
|
/** @internal — invoked before the sandbox is deleted. */
|
|
8862
8829
|
async _sessionExportRawEvidence(id, destination, options) {
|
|
8863
|
-
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-
|
|
8830
|
+
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-DrgeV9_0.js");
|
|
8864
8831
|
await this.ensureRunning();
|
|
8865
8832
|
await this.refresh();
|
|
8866
8833
|
return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/sessions/${encodeURIComponent(id)}/raw-evidence/archive?${new URLSearchParams([
|
|
@@ -8891,7 +8858,7 @@ var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabil
|
|
|
8891
8858
|
* and the byte and file bounds are verified before the directory appears.
|
|
8892
8859
|
*/
|
|
8893
8860
|
async exportRawEvidence(destination, options) {
|
|
8894
|
-
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-
|
|
8861
|
+
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-DrgeV9_0.js");
|
|
8895
8862
|
await this.ensureRunning();
|
|
8896
8863
|
await this.refresh();
|
|
8897
8864
|
return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/raw-evidence/archive?${new URLSearchParams({
|
|
@@ -10057,7 +10024,7 @@ var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
|
|
|
10057
10024
|
const error = await parseResponseError(response);
|
|
10058
10025
|
const remainingMs = budgetMs - (Date.now() - started);
|
|
10059
10026
|
if (!isRetainedHold(error, reason) || remainingMs <= 0) throw error;
|
|
10060
|
-
await
|
|
10027
|
+
await abortableSleep(Math.min(error.retryAfterMs ?? SNAPSHOT_DELETE_RETAINED_RETRY_MS, CREATE_RETRY_MAX_DELAY_MS, remainingMs));
|
|
10061
10028
|
heldUntil = Date.now();
|
|
10062
10029
|
}
|
|
10063
10030
|
const body = await response.json().catch(() => ({}));
|
|
@@ -10133,7 +10100,7 @@ var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
|
|
|
10133
10100
|
return await this.waitForSnapshotVisible(snapshotId, status.completedAt ? { createdAt: new Date(status.completedAt) } : void 0);
|
|
10134
10101
|
}
|
|
10135
10102
|
const heldMs = Date.now() - polledAt;
|
|
10136
|
-
if (heldMs < SNAPSHOT_RESTORE_POLL_FLOOR_MS) await
|
|
10103
|
+
if (heldMs < SNAPSHOT_RESTORE_POLL_FLOOR_MS) await abortableSleep(SNAPSHOT_RESTORE_POLL_FLOOR_MS - heldMs);
|
|
10137
10104
|
polledAt = Date.now();
|
|
10138
10105
|
status = await readResponseJson(await state(this).client.fetch(`/v1/sandboxes/${this.id}/snapshots/jobs/${encodeURIComponent(accepted.jobId)}?waitMs=${SNAPSHOT_RESTORE_HOLD_MS}`));
|
|
10139
10106
|
}
|
|
@@ -10156,7 +10123,7 @@ var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
|
|
|
10156
10123
|
if (!isTransientSnapshotVisibilityError(error)) throw error;
|
|
10157
10124
|
lastError = error;
|
|
10158
10125
|
}
|
|
10159
|
-
await
|
|
10126
|
+
await abortableSleep(SNAPSHOT_VISIBILITY_POLL_INTERVAL_MS);
|
|
10160
10127
|
}
|
|
10161
10128
|
if (fallback) return {
|
|
10162
10129
|
snapshotId,
|
|
@@ -10308,7 +10275,7 @@ var SandboxBranchCapabilities = class extends SandboxSnapshotCapabilities {
|
|
|
10308
10275
|
const record = await this.getRollout(rolloutId);
|
|
10309
10276
|
if (record.status !== "running") return record;
|
|
10310
10277
|
if (Date.now() - startTime > timeoutMs) throw new TimeoutError(`Timed out waiting for rollout ${rolloutId} to settle`, { timeoutMs });
|
|
10311
|
-
await
|
|
10278
|
+
await abortableSleep(pollIntervalMs);
|
|
10312
10279
|
}
|
|
10313
10280
|
}
|
|
10314
10281
|
};
|
|
@@ -11023,7 +10990,7 @@ var SandboxFilesystemOperations = class extends DeclaredFilesystemOperations {
|
|
|
11023
10990
|
totalBytes: size,
|
|
11024
10991
|
percentage: 0
|
|
11025
10992
|
});
|
|
11026
|
-
const { uploadChunkedFromFile } = await import("./chunked-upload-file-
|
|
10993
|
+
const { uploadChunkedFromFile } = await import("./chunked-upload-file-D3YxQdAl.js");
|
|
11027
10994
|
await uploadChunkedFromFile({ fetch: (path, init) => this.host.runtimeFetch(path, init) }, remotePath, localPath, {
|
|
11028
10995
|
mode: options?.permissions,
|
|
11029
10996
|
onProgress: options?.onProgress ? (progress) => {
|
|
@@ -11931,4 +11898,4 @@ var SandboxInstance = class SandboxInstance extends SandboxEgressCapabilities {
|
|
|
11931
11898
|
}
|
|
11932
11899
|
};
|
|
11933
11900
|
//#endregion
|
|
11934
|
-
export { normalizeSandboxCreateReceipt as A, CAPACITY_ETA_WAIT_MAX_MS as B, SandboxOperationFailedError as C, validateDeferredProfileFileMounts as D, splitInlineProfileSkills as E, normalizeConnection as F,
|
|
11901
|
+
export { normalizeSandboxCreateReceipt as A, CAPACITY_ETA_WAIT_MAX_MS as B, SandboxOperationFailedError as C, validateDeferredProfileFileMounts as D, splitInlineProfileSkills as E, normalizeConnection as F, createRetryDelayMs as G, DEFAULT_GPU_CREATE_TIMEOUT_MS as H, normalizeEgressPolicyFields as I, isCapacityShortageCreateError as J, extendableDeadline as K, normalizeProxySecretReceipt as L, readFilesystemIncarnationTuple as M, dateOf as N, isRetryableProfileFileMaterializeFailure as O, parseLifecycleTimes as P, canonicalAgentProfileDigest as Q, normalizeSandboxShape as R, SandboxOperation as S, splitInlineProfileFileMounts as T, DEPLOY_WINDOW_RETRY_MS as U, DEFAULT_CREATE_TIMEOUT_MS as V, awaitCreateResend as W, isRateLimitCreateError as X, isDeployWindowCreateError as Y, isRetryableCreateError as Z, collectAgentFinalMessageText as _, buildTraceExportPayload as a, isToolBearingEvent as b, toOtelJson as c, sandboxLedgerUsd as d, InteractiveSessionHandle as f, applySandboxEventText as g, createInteractiveTerminalSession as h, MAX_EGRESS_DENIALS_LIMIT as i, normalizeStartupDiagnostics as j, normalizeCaptureProof as k, SandboxTaskSession as l, createInteractiveTerminalCapture as m, createSandboxInstanceFromResponse as n, exportTraceBundle as o, InteractiveTerminalFrameLog as p, generateIdempotencyKey as q, WorkspaceImages as r, otelTraceIdForTangleTrace as s, SandboxInstance as t, SandboxSession as u, collectAgentResponseText as v, materializeProfileFileMounts as w, ManagedProcessClient as x, getSandboxEventText as y, CAPACITY_ETA_MARGIN_MS as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../sidecar-proxy-error-
|
|
3
|
-
import { t as parseSSEStream } from "../sse-parser-
|
|
1
|
+
import { n as combineAbortSignals } from "../abort-signal-BbJTt2QJ.js";
|
|
2
|
+
import "../sidecar-proxy-error-DpBLxIof.js";
|
|
3
|
+
import { t as parseSSEStream } from "../sse-parser-DOCszo1K.js";
|
|
4
4
|
import { PART_TEXT, PART_TEXT_SUFFIX } from "@tangle-network/agent-core/sse";
|
|
5
5
|
//#region ../../../packages/runtime-contracts/dist/session-gateway.js
|
|
6
6
|
/**
|
package/dist/tangle/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as JOB_SANDBOX_DELETE, T as SandboxCreateResponseParamTypes, _ as TANGLE_CHAIN_ID, a as fetchQuote, b as AgentSandboxBlueprintAbi, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as BlueprintSandboxClientConfig, h as BlueprintSandboxClient, i as SignedQuote, l as validateQuote, m as SignMessage, n as QuoteDomain, o as inputsHashOf, p as OperatorSessionToken, r as QuoteError, s as jobQuoteDigest, t as JobQuoteDetails, u as OperatorChallenge, v as TANGLE_JOBS_CONTRACT, w as SandboxCreateParamTypes, x as JOB_SANDBOX_CREATE, y as ITangleJobsAbi } from "../index-
|
|
1
|
+
import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as JOB_SANDBOX_DELETE, T as SandboxCreateResponseParamTypes, _ as TANGLE_CHAIN_ID, a as fetchQuote, b as AgentSandboxBlueprintAbi, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as BlueprintSandboxClientConfig, h as BlueprintSandboxClient, i as SignedQuote, l as validateQuote, m as SignMessage, n as QuoteDomain, o as inputsHashOf, p as OperatorSessionToken, r as QuoteError, s as jobQuoteDigest, t as JobQuoteDetails, u as OperatorChallenge, v as TANGLE_JOBS_CONTRACT, w as SandboxCreateParamTypes, x as JOB_SANDBOX_CREATE, y as ITangleJobsAbi } from "../index-DyFU9hy7.js";
|
|
2
2
|
export { AgentSandboxBlueprintAbi, BlueprintSandboxClient, BlueprintSandboxClientConfig, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JobQuoteDetails, JsonResponseParamTypes, OperatorChallenge, OperatorSession, OperatorSessionError, OperatorSessionToken, QuoteDomain, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, SignMessage, SignedQuote, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
|
package/dist/tangle/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as ITangleJobsAbi, g as JsonResponseParamTypes, h as JOB_SANDBOX_DELETE, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_CREATE, n as fetchQuote, o as validateQuote, p as AgentSandboxBlueprintAbi, r as inputsHashOf, s as BlueprintSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-
|
|
1
|
+
import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as ITangleJobsAbi, g as JsonResponseParamTypes, h as JOB_SANDBOX_DELETE, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_CREATE, n as fetchQuote, o as validateQuote, p as AgentSandboxBlueprintAbi, r as inputsHashOf, s as BlueprintSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-BPDYjDpX.js";
|
|
2
2
|
export { AgentSandboxBlueprintAbi, BlueprintSandboxClient, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, OperatorSession, OperatorSessionError, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
|