@tangle-network/sandbox 1.0.266 → 1.0.268

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/agent/index.d.ts +4 -4
  2. package/dist/agent/index.js +4 -4
  3. package/dist/agent/preview.d.ts +1 -1
  4. package/dist/agent/preview.js +1 -1
  5. package/dist/{agent-run-outcome-DThM9ULE.d.ts → agent-run-outcome-e0Rtf3a3.d.ts} +1 -1
  6. package/dist/{api-request-gkPDymqn.js → api-request-nbgUMuWb.js} +1 -1
  7. package/dist/{browser-interactive-control-controller-S_Uo-Zy7.js → browser-interactive-control-controller-C9yza0IL.js} +1 -1
  8. package/dist/{client-BYGLoEiU.d.ts → client-D5GC6xYe.d.ts} +4 -4
  9. package/dist/{client-BWD7-uaL.js → client-HIMk1-m9.js} +3 -3
  10. package/dist/collaboration/index.js +1 -1
  11. package/dist/{collaboration-Bqk4jYQe.js → collaboration-pelVsLcr.js} +1 -1
  12. package/dist/core.d.ts +5 -5
  13. package/dist/core.js +3 -3
  14. package/dist/gpu-lease/index.js +1 -1
  15. package/dist/{index-DkB8WbjK.d.ts → index-DUEgpbVw.d.ts} +3 -3
  16. package/dist/index.d.ts +7 -7
  17. package/dist/index.js +8 -8
  18. package/dist/intelligence/index.js +1 -1
  19. package/dist/interactive-control.js +1 -1
  20. package/dist/{interactive-controller-DSYQTRwh.d.ts → interactive-controller-CmRtlTBj.d.ts} +1 -1
  21. package/dist/{interactive-controller-llj6EdlZ.js → interactive-controller-DOM8V0pP.js} +2 -2
  22. package/dist/{lines-D7lE49lV.d.ts → lines-b98DdVCn.d.ts} +1 -1
  23. package/dist/lines.d.ts +1 -1
  24. package/dist/{mcp-local-DVzsBlqX.js → mcp-local-BB-yoxeI.js} +2 -2
  25. package/dist/{preview-DsHoo8BC.d.ts → preview-CuMxpBA3.d.ts} +3 -3
  26. package/dist/{public-templates-DRqOkshE.d.ts → public-templates-DTzQu6C0.d.ts} +1 -1
  27. package/dist/public-templates.d.ts +1 -1
  28. package/dist/runtime.d.ts +3 -3
  29. package/dist/runtime.js +3 -3
  30. package/dist/{sandbox-C3PqmwfU.js → sandbox-D86jxPzC.js} +219 -221
  31. package/dist/{select-seat-Dc7cQ8To.js → select-seat-DWMZh9Mj.js} +2 -2
  32. package/dist/select-seat-command.d.ts +1 -1
  33. package/dist/select-seat-command.js +1 -1
  34. package/dist/session-gateway/index.js +1 -1
  35. package/dist/tangle/index.d.ts +1 -1
  36. package/dist/tangle/index.js +1 -1
  37. package/dist/{tangle-BP8F3ZN0.js → tangle-BBF4pV5c.js} +2 -2
  38. package/dist/{types-BikjtQi3.d.ts → types-Ct8kzcZC.d.ts} +362 -371
  39. package/package.json +4 -4
@@ -1,14 +1,14 @@
1
- import { A as requestedPublicProfileDigest, C as runtimeFilesystemPath, D as assertCurrentBackendType, E as applyRequestedModel, F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, O as mergeRuntimeBackendConfig, P as withoutRuntimeSecrets, S as encodeTextForWire, U as normalizeEffectiveBackend, _ as mintTraceId, a as assertScopedTokenActive, b as validateAcceptedDispatchRunRef, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as isTraceId, h as TRACE_ID_HEADER, i as terminalUpgradeHeadersSupported, j as requestedSecretProfilePublicDigest, k as normalizeRuntimeBackendConfig, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as resolveTraceId, w as canUseNodeHttp2, x as encodePromptForWire, y as resolveDispatchRunIdentity } from "./interactive-controller-llj6EdlZ.js";
1
+ import { A as requestedPublicProfileDigest, C as runtimeFilesystemPath, D as assertCurrentBackendType, E as applyRequestedModel, F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, O as mergeRuntimeBackendConfig, P as withoutRuntimeSecrets, S as encodeTextForWire, U as normalizeEffectiveBackend, _ as mintTraceId, a as assertScopedTokenActive, b as validateAcceptedDispatchRunRef, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as isTraceId, h as TRACE_ID_HEADER, i as terminalUpgradeHeadersSupported, j as requestedSecretProfilePublicDigest, k as normalizeRuntimeBackendConfig, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as resolveTraceId, w as canUseNodeHttp2, x as encodePromptForWire, y as resolveDispatchRunIdentity } from "./interactive-controller-DOM8V0pP.js";
2
2
  import { C as boundedIdentifierSchema$1, E as boundedStringSchema$1, g as sha256DigestSchema$1, o as canonicalCandidateDigest$1, s as canonicalCandidateJson$1 } from "./harness--g8UQ5TZ.js";
3
3
  import { a as ProxySecretReceiptSchema$1, r as agentProfileSchema$1 } from "./profile-schema-B11dRfGB.js";
4
4
  import { t as sha256$1 } from "./sha2-BIoWepwn.js";
5
- 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-S_Uo-Zy7.js";
5
+ 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-C9yza0IL.js";
6
6
  import { t as canonicalAgentProfileDigest } from "./agent-execution-preparation-N1ksNIIJ.js";
7
7
  import { C as SandboxError, D as TimeoutError, E as StreamInterruptedError, O as ValidationError, T as StateError, _ as NetworkError, a as readResponseJson, b as ProfileFileMountPathError, c as AuthError, f as EdgeNotReadyError, i as parseResponseError, n as isTransientWrite, o as responseMetadata, r as parseErrorResponse, s as retryWhen, t as TerminalStreamError, u as CapabilityError, v as NotFoundError, w as ServerError, y as PartialFailureError } from "./errors-D44qyFpy.js";
8
8
  import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-BZbs5rig.js";
9
9
  import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-BsriwJ8L.js";
10
10
  import { a as backoffDelayMs, o as isUndelivered, r as abortableSleep } from "./retry-policy-oW3_ljoc.js";
11
- import { a as isReplayableBody, i as fetchSandboxApi, n as SDK_TIMEOUTS, o as rewrapResponse, t as IDEMPOTENT_METHODS } from "./api-request-gkPDymqn.js";
11
+ import { a as isReplayableBody, i as fetchSandboxApi, n as SDK_TIMEOUTS, o as rewrapResponse, t as IDEMPOTENT_METHODS } from "./api-request-nbgUMuWb.js";
12
12
  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-DOSTbUSR.js";
13
13
  import { c as awaitSdkResend, l as takeSdkTurn, s as uploadChunked } from "./chunked-upload-ChZB-dYE.js";
14
14
  import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-sGVP8skk.js";
@@ -3056,6 +3056,194 @@ async function isRefusedBearer(response) {
3056
3056
  }
3057
3057
  }
3058
3058
  //#endregion
3059
+ //#region src/operation.ts
3060
+ /** Durable lifecycle operations and their client waits. */
3061
+ const FIRST_POLL_MS = 250;
3062
+ const MAX_POLL_MS = 2e3;
3063
+ /** An accepted operation ended in failure. `code` names why. */
3064
+ var SandboxOperationFailedError = class extends SandboxError {
3065
+ operation;
3066
+ constructor(operation) {
3067
+ super(operation.error?.message ?? `Sandbox ${operation.kind} operation ${operation.id} failed`, { code: operation.error?.code ?? "OPERATION_FAILED" });
3068
+ this.operation = operation;
3069
+ }
3070
+ };
3071
+ function isRecord$1(value) {
3072
+ return value !== null && typeof value === "object" && !Array.isArray(value);
3073
+ }
3074
+ const KINDS = [
3075
+ "stop",
3076
+ "snapshot",
3077
+ "delete"
3078
+ ];
3079
+ const STATES = [
3080
+ "accepted",
3081
+ "running",
3082
+ "succeeded",
3083
+ "failed"
3084
+ ];
3085
+ function parseSnapshot(value) {
3086
+ if (!isRecord$1(value) || typeof value.snapshotId !== "string") return;
3087
+ return {
3088
+ snapshotId: value.snapshotId,
3089
+ createdAt: new Date(typeof value.createdAt === "string" ? value.createdAt : Date.now()),
3090
+ ...typeof value.sizeBytes === "number" ? { sizeBytes: value.sizeBytes } : {},
3091
+ tags: Array.isArray(value.tags) ? value.tags.filter((tag) => typeof tag === "string") : []
3092
+ };
3093
+ }
3094
+ /** A keyed create's acknowledgement; anything else (an older API) is unknown. */
3095
+ function parseIdempotencyAcknowledgement(value) {
3096
+ return isRecord$1(value) && (value.outcome === "created" || value.outcome === "replayed") && typeof value.requestDigest === "string" ? {
3097
+ outcome: value.outcome,
3098
+ requestDigest: value.requestDigest
3099
+ } : void 0;
3100
+ }
3101
+ function contractViolation(message) {
3102
+ return new SandboxError(message, {
3103
+ code: "UPSTREAM_CONTRACT_VIOLATION",
3104
+ status: 502
3105
+ });
3106
+ }
3107
+ /** Parse a wire operation without changing the expected identity. */
3108
+ function parseSandboxOperation(value, expected) {
3109
+ const info = parseOperationBody(value);
3110
+ if (expected && (expected.kind !== void 0 && info.kind !== expected.kind || info.sandboxId !== expected.sandboxId || expected.id !== void 0 && info.id !== expected.id)) throw contractViolation(`The API answered ${info.kind} operation ${info.id} on ${info.sandboxId} for ${expected.kind ?? "an"} operation ${expected.id ?? "(new)"} on ${expected.sandboxId}`);
3111
+ return info;
3112
+ }
3113
+ function parseOperationBody(value) {
3114
+ if (!isRecord$1(value) || typeof value.id !== "string" || typeof value.sandboxId !== "string" || typeof value.statusUrl !== "string" || typeof value.acceptedAt !== "string" || !KINDS.includes(value.kind) || !STATES.includes(value.state)) throw contractViolation(`The API answered an operation that does not match the contract: ${JSON.stringify(value).slice(0, 200)}`);
3115
+ const result = isRecord$1(value.result) ? value.result : void 0;
3116
+ const snapshot = parseSnapshot(result?.snapshot);
3117
+ const durability = result?.durability === "local" || result?.durability === "remote" ? result.durability : void 0;
3118
+ const error = isRecord$1(value.error) ? value.error : void 0;
3119
+ return {
3120
+ id: value.id,
3121
+ kind: value.kind,
3122
+ sandboxId: value.sandboxId,
3123
+ state: value.state,
3124
+ ...typeof value.phase === "string" ? { phase: value.phase } : {},
3125
+ acceptedAt: new Date(value.acceptedAt),
3126
+ ...typeof value.completedAt === "string" ? { completedAt: new Date(value.completedAt) } : {},
3127
+ statusUrl: value.statusUrl,
3128
+ ...result ? { result: {
3129
+ ...durability ? { durability } : {},
3130
+ ...snapshot ? { snapshot } : {},
3131
+ ...isRecord$1(result.sandbox) ? { sandbox: result.sandbox } : {},
3132
+ ...result.deleted === true ? { deleted: true } : {},
3133
+ ...result.removal === "pending" || result.removal === "complete" ? { removal: result.removal } : {}
3134
+ } } : {},
3135
+ ...error && typeof error.code === "string" && typeof error.message === "string" ? { error: {
3136
+ code: error.code,
3137
+ message: error.message
3138
+ } } : {}
3139
+ };
3140
+ }
3141
+ function isTerminalOperation(info) {
3142
+ return info.state === "succeeded" || info.state === "failed";
3143
+ }
3144
+ var SandboxOperation = class SandboxOperation {
3145
+ #info;
3146
+ #client;
3147
+ #onSettled;
3148
+ #settled = false;
3149
+ constructor(info, client, onSettled) {
3150
+ this.#info = info;
3151
+ this.#client = client;
3152
+ this.#onSettled = onSettled;
3153
+ }
3154
+ static completed(kind, sandboxId, result) {
3155
+ const now = /* @__PURE__ */ new Date();
3156
+ return new SandboxOperation({
3157
+ id: "",
3158
+ kind,
3159
+ sandboxId,
3160
+ state: "succeeded",
3161
+ acceptedAt: now,
3162
+ completedAt: now,
3163
+ statusUrl: "",
3164
+ ...result ? { result } : {}
3165
+ }, null);
3166
+ }
3167
+ get id() {
3168
+ return this.#info.id;
3169
+ }
3170
+ get state() {
3171
+ return this.#info.state;
3172
+ }
3173
+ /** The last state read. */
3174
+ get info() {
3175
+ return this.#info;
3176
+ }
3177
+ /** Read the operation's current state. */
3178
+ async refresh({ signal, waitMs = 0 } = {}) {
3179
+ signal?.throwIfAborted();
3180
+ if (!this.#client || isTerminalOperation(this.#info)) {
3181
+ await this.#settle();
3182
+ signal?.throwIfAborted();
3183
+ return this.#info;
3184
+ }
3185
+ const query = this.#info.kind === "delete" && new URLSearchParams(this.#info.statusUrl.split("?")[1]).get("until") === "removed" ? "?until=removed" : waitMs ? `?waitMs=${waitMs}` : "";
3186
+ const response = await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.#info.sandboxId)}/operations/${encodeURIComponent(this.#info.id)}${query}`, { signal });
3187
+ if (!response.ok) throw await parseResponseError(response);
3188
+ this.#info = parseSandboxOperation(await response.json(), {
3189
+ kind: this.#info.kind,
3190
+ sandboxId: this.#info.sandboxId,
3191
+ id: this.#info.id
3192
+ });
3193
+ await this.#settle();
3194
+ signal?.throwIfAborted();
3195
+ return this.#info;
3196
+ }
3197
+ async #settle() {
3198
+ if (this.#settled || this.#info.state !== "succeeded") return;
3199
+ this.#settled = true;
3200
+ await this.#onSettled?.(this.#info);
3201
+ }
3202
+ /** Wait through held snapshot reads or paced polls; retain retry budgets and identity. */
3203
+ async wait(options = {}) {
3204
+ const timeoutMs = options.timeoutMs ?? SDK_TIMEOUTS.operationWait;
3205
+ const startedAt = Date.now();
3206
+ const { signal } = options;
3207
+ let [delayMs, capMs, failedReads] = [
3208
+ 0,
3209
+ 0,
3210
+ 0
3211
+ ];
3212
+ let info;
3213
+ const timedOut = (cause) => new TimeoutError(`Timed out waiting for ${this.#info.kind} operation ${this.#info.id} (last state ${this.#info.state})`, {
3214
+ timeoutMs,
3215
+ cause
3216
+ });
3217
+ while (!info || !isTerminalOperation(info)) {
3218
+ if (Date.now() - startedAt + delayMs > timeoutMs) throw timedOut();
3219
+ await abortableSleep(delayMs, signal);
3220
+ capMs = Math.min(Math.max(capMs * 2, FIRST_POLL_MS), MAX_POLL_MS);
3221
+ try {
3222
+ const readStartedAt = Date.now();
3223
+ info = await this.refresh({
3224
+ signal,
3225
+ waitMs: this.#info.kind === "snapshot" ? Math.max(0, Math.min(1e4, startedAt + timeoutMs - Date.now())) : 0
3226
+ });
3227
+ delayMs = this.#info.kind === "snapshot" ? Math.max(0, capMs - (Date.now() - readStartedAt)) : capMs;
3228
+ failedReads = 0;
3229
+ } catch (error) {
3230
+ if (!retryWhen(error) || error.code === "UPSTREAM_CONTRACT_VIOLATION") throw error;
3231
+ const deadlineAt = startedAt + timeoutMs;
3232
+ const pacing = {
3233
+ retryAfterMs: error.retryAfterMs,
3234
+ signal,
3235
+ deadlineAt
3236
+ };
3237
+ if (!await awaitSdkResend(++failedReads, pacing)) throw timedOut(error);
3238
+ delayMs = 0;
3239
+ }
3240
+ }
3241
+ signal?.throwIfAborted();
3242
+ if (info.state === "failed") throw new SandboxOperationFailedError(info);
3243
+ return info;
3244
+ }
3245
+ };
3246
+ //#endregion
3059
3247
  //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.11/node_modules/@tangle-network/agent-interface/dist/provider-config.js
3060
3248
  const nativeWebSearchKeys = new Set(["websearch"]);
3061
3249
  const nativeWebFetchKeys = new Set(["webfetch", "fetch"]);
@@ -7420,187 +7608,6 @@ var ProfileFileDelivery = class {
7420
7608
  }
7421
7609
  };
7422
7610
  //#endregion
7423
- //#region src/operation.ts
7424
- /** Durable lifecycle operations and their client waits. */
7425
- const FIRST_POLL_MS = 250;
7426
- const MAX_POLL_MS = 2e3;
7427
- /** An accepted operation ended in failure. `code` names why. */
7428
- var SandboxOperationFailedError = class extends SandboxError {
7429
- operation;
7430
- constructor(operation) {
7431
- super(operation.error?.message ?? `Sandbox ${operation.kind} operation ${operation.id} failed`, { code: operation.error?.code ?? "OPERATION_FAILED" });
7432
- this.operation = operation;
7433
- }
7434
- };
7435
- function isRecord$1(value) {
7436
- return value !== null && typeof value === "object" && !Array.isArray(value);
7437
- }
7438
- const KINDS = [
7439
- "stop",
7440
- "snapshot",
7441
- "delete"
7442
- ];
7443
- const STATES = [
7444
- "accepted",
7445
- "running",
7446
- "succeeded",
7447
- "failed"
7448
- ];
7449
- function parseSnapshot(value) {
7450
- if (!isRecord$1(value) || typeof value.snapshotId !== "string") return;
7451
- return {
7452
- snapshotId: value.snapshotId,
7453
- createdAt: new Date(typeof value.createdAt === "string" ? value.createdAt : Date.now()),
7454
- ...typeof value.sizeBytes === "number" ? { sizeBytes: value.sizeBytes } : {},
7455
- tags: Array.isArray(value.tags) ? value.tags.filter((tag) => typeof tag === "string") : []
7456
- };
7457
- }
7458
- function contractViolation(message) {
7459
- return new SandboxError(message, {
7460
- code: "UPSTREAM_CONTRACT_VIOLATION",
7461
- status: 502
7462
- });
7463
- }
7464
- /** Parse a wire operation without changing the expected identity. */
7465
- function parseSandboxOperation(value, expected) {
7466
- const info = parseOperationBody(value);
7467
- if (expected && (expected.kind !== void 0 && info.kind !== expected.kind || info.sandboxId !== expected.sandboxId || expected.id !== void 0 && info.id !== expected.id)) throw contractViolation(`The API answered ${info.kind} operation ${info.id} on ${info.sandboxId} for ${expected.kind ?? "an"} operation ${expected.id ?? "(new)"} on ${expected.sandboxId}`);
7468
- return info;
7469
- }
7470
- function parseOperationBody(value) {
7471
- if (!isRecord$1(value) || typeof value.id !== "string" || typeof value.sandboxId !== "string" || typeof value.statusUrl !== "string" || typeof value.acceptedAt !== "string" || !KINDS.includes(value.kind) || !STATES.includes(value.state)) throw contractViolation(`The API answered an operation that does not match the contract: ${JSON.stringify(value).slice(0, 200)}`);
7472
- const result = isRecord$1(value.result) ? value.result : void 0;
7473
- const snapshot = parseSnapshot(result?.snapshot);
7474
- const durability = result?.durability === "local" || result?.durability === "remote" ? result.durability : void 0;
7475
- const error = isRecord$1(value.error) ? value.error : void 0;
7476
- return {
7477
- id: value.id,
7478
- kind: value.kind,
7479
- sandboxId: value.sandboxId,
7480
- state: value.state,
7481
- ...typeof value.phase === "string" ? { phase: value.phase } : {},
7482
- acceptedAt: new Date(value.acceptedAt),
7483
- ...typeof value.completedAt === "string" ? { completedAt: new Date(value.completedAt) } : {},
7484
- statusUrl: value.statusUrl,
7485
- ...result ? { result: {
7486
- ...durability ? { durability } : {},
7487
- ...snapshot ? { snapshot } : {},
7488
- ...isRecord$1(result.sandbox) ? { sandbox: result.sandbox } : {},
7489
- ...result.deleted === true ? { deleted: true } : {},
7490
- ...result.removal === "pending" || result.removal === "complete" ? { removal: result.removal } : {}
7491
- } } : {},
7492
- ...error && typeof error.code === "string" && typeof error.message === "string" ? { error: {
7493
- code: error.code,
7494
- message: error.message
7495
- } } : {}
7496
- };
7497
- }
7498
- function isTerminalOperation(info) {
7499
- return info.state === "succeeded" || info.state === "failed";
7500
- }
7501
- var SandboxOperation = class SandboxOperation {
7502
- #info;
7503
- #client;
7504
- #onSettled;
7505
- #settled = false;
7506
- constructor(info, client, onSettled) {
7507
- this.#info = info;
7508
- this.#client = client;
7509
- this.#onSettled = onSettled;
7510
- }
7511
- static completed(kind, sandboxId, result) {
7512
- const now = /* @__PURE__ */ new Date();
7513
- return new SandboxOperation({
7514
- id: "",
7515
- kind,
7516
- sandboxId,
7517
- state: "succeeded",
7518
- acceptedAt: now,
7519
- completedAt: now,
7520
- statusUrl: "",
7521
- ...result ? { result } : {}
7522
- }, null);
7523
- }
7524
- get id() {
7525
- return this.#info.id;
7526
- }
7527
- get state() {
7528
- return this.#info.state;
7529
- }
7530
- /** The last state read. */
7531
- get info() {
7532
- return this.#info;
7533
- }
7534
- /** Read the operation's current state. */
7535
- async refresh({ signal, waitMs = 0 } = {}) {
7536
- signal?.throwIfAborted();
7537
- if (!this.#client || isTerminalOperation(this.#info)) {
7538
- await this.#settle();
7539
- signal?.throwIfAborted();
7540
- return this.#info;
7541
- }
7542
- const query = this.#info.kind === "delete" && new URLSearchParams(this.#info.statusUrl.split("?")[1]).get("until") === "removed" ? "?until=removed" : waitMs ? `?waitMs=${waitMs}` : "";
7543
- const response = await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.#info.sandboxId)}/operations/${encodeURIComponent(this.#info.id)}${query}`, { signal });
7544
- if (!response.ok) throw await parseResponseError(response);
7545
- this.#info = parseSandboxOperation(await response.json(), {
7546
- kind: this.#info.kind,
7547
- sandboxId: this.#info.sandboxId,
7548
- id: this.#info.id
7549
- });
7550
- await this.#settle();
7551
- signal?.throwIfAborted();
7552
- return this.#info;
7553
- }
7554
- async #settle() {
7555
- if (this.#settled || this.#info.state !== "succeeded") return;
7556
- this.#settled = true;
7557
- await this.#onSettled?.(this.#info);
7558
- }
7559
- /** Wait through held snapshot reads or paced polls; retain retry budgets and identity. */
7560
- async wait(options = {}) {
7561
- const timeoutMs = options.timeoutMs ?? SDK_TIMEOUTS.operationWait;
7562
- const startedAt = Date.now();
7563
- const { signal } = options;
7564
- let [delayMs, capMs, failedReads] = [
7565
- 0,
7566
- 0,
7567
- 0
7568
- ];
7569
- let info;
7570
- const timedOut = (cause) => new TimeoutError(`Timed out waiting for ${this.#info.kind} operation ${this.#info.id} (last state ${this.#info.state})`, {
7571
- timeoutMs,
7572
- cause
7573
- });
7574
- while (!info || !isTerminalOperation(info)) {
7575
- if (Date.now() - startedAt + delayMs > timeoutMs) throw timedOut();
7576
- await abortableSleep(delayMs, signal);
7577
- capMs = Math.min(Math.max(capMs * 2, FIRST_POLL_MS), MAX_POLL_MS);
7578
- try {
7579
- const readStartedAt = Date.now();
7580
- info = await this.refresh({
7581
- signal,
7582
- waitMs: this.#info.kind === "snapshot" ? Math.max(0, Math.min(1e4, startedAt + timeoutMs - Date.now())) : 0
7583
- });
7584
- delayMs = this.#info.kind === "snapshot" ? Math.max(0, capMs - (Date.now() - readStartedAt)) : capMs;
7585
- failedReads = 0;
7586
- } catch (error) {
7587
- if (!retryWhen(error) || error.code === "UPSTREAM_CONTRACT_VIOLATION") throw error;
7588
- const deadlineAt = startedAt + timeoutMs;
7589
- const pacing = {
7590
- retryAfterMs: error.retryAfterMs,
7591
- signal,
7592
- deadlineAt
7593
- };
7594
- if (!await awaitSdkResend(++failedReads, pacing)) throw timedOut(error);
7595
- delayMs = 0;
7596
- }
7597
- }
7598
- signal?.throwIfAborted();
7599
- if (info.state === "failed") throw new SandboxOperationFailedError(info);
7600
- return info;
7601
- }
7602
- };
7603
- //#endregion
7604
7611
  //#region src/lib/sandbox-command.ts
7605
7612
  const SANDBOX_COMMAND_SHELL = "/bin/sh";
7606
7613
  function sandboxShellCommandArgs(command) {
@@ -13059,18 +13066,22 @@ var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
13059
13066
  tags: options.tags
13060
13067
  })
13061
13068
  }));
13062
- return {
13063
- snapshotId: data.snapshot?.id ?? data.snapshotId,
13064
- createdAt: new Date(data.snapshot?.createdAt ?? data.createdAt ?? Date.now()),
13065
- sizeBytes: data.snapshot?.sizeBytes ?? data.sizeBytes,
13066
- tags: data.snapshot?.tags ?? data.tags ?? []
13067
- };
13069
+ const { snapshot = {} } = data;
13070
+ return toSnapshotResult({
13071
+ ...data,
13072
+ ...snapshot,
13073
+ snapshotId: snapshot.id ?? data.snapshotId,
13074
+ createdAt: snapshot.createdAt ?? data.createdAt ?? Date.now()
13075
+ });
13068
13076
  }
13069
- const operation = await this.#snapshotNoWait(options ?? {});
13077
+ const [operation, idempotency] = await this.#snapshotNoWait(options ?? {});
13070
13078
  if (options?.wait === false) return operation;
13071
13079
  const done = await operation.wait({ timeoutMs: SDK_TIMEOUTS.snapshot });
13072
13080
  if (!done.result?.snapshot) throw new ServerError(`Snapshot operation ${operation.id} succeeded without a snapshot`);
13073
- return done.result.snapshot;
13081
+ return {
13082
+ ...done.result.snapshot,
13083
+ ...idempotency && { idempotency }
13084
+ };
13074
13085
  }
13075
13086
  /** Asynchronous acceptance returns an operation; synchronous capture returns a succeeded operation. */
13076
13087
  async #snapshotNoWait(options) {
@@ -13081,37 +13092,29 @@ var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
13081
13092
  body: JSON.stringify({ tags: options.tags })
13082
13093
  }, { timeoutMs: SDK_TIMEOUTS.snapshot });
13083
13094
  const body = await readResponseJson(response);
13084
- if (response.status === 202) return new SandboxOperation(parseSandboxOperation(body.operation, {
13095
+ const idempotency = parseIdempotencyAcknowledgement(body.idempotency);
13096
+ if (response.status === 202) return [new SandboxOperation(parseSandboxOperation(body.operation, {
13085
13097
  kind: "snapshot",
13086
13098
  sandboxId: this.id
13087
- }), state(this).client);
13099
+ }), state(this).client), idempotency];
13088
13100
  const snapshotId = body.snapshotId ?? body.id;
13089
13101
  if (typeof snapshotId !== "string" || snapshotId.length === 0) throw new ServerError(`Snapshot create returned ${response.status} but body had no snapshot ID: ${JSON.stringify(body).slice(0, 200)}`, { status: response.status });
13090
- return SandboxOperation.completed("snapshot", this.id, { snapshot: toSnapshotResult({
13102
+ const snapshot = toSnapshotResult({
13091
13103
  ...body,
13092
13104
  createdAt: body.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
13093
- }) });
13105
+ });
13106
+ return [SandboxOperation.completed("snapshot", this.id, { snapshot }), idempotency];
13094
13107
  }
13095
13108
  /** List snapshots; storage selects the direct customer-S3 path. */
13096
13109
  async listSnapshots(storage) {
13097
- if (storage) {
13098
- await this.ensureRunning();
13099
- return ((await readResponseJson(await this.runtimeFetch("/snapshots/list", {
13100
- method: "POST",
13101
- body: JSON.stringify({
13102
- projectId: this.id,
13103
- storage
13104
- })
13105
- }))).snapshots ?? []).map((s) => ({
13106
- snapshotId: s.id ?? s.snapshotId,
13107
- sandboxId: this.id,
13108
- createdAt: new Date(s.createdAt),
13109
- tags: s.tags ?? [],
13110
- paths: [],
13111
- sizeBytes: s.sizeBytes
13112
- }));
13113
- }
13114
- const data = await readResponseJson(await state(this).client.fetch(`/v1/sandboxes/${this.id}/snapshots`));
13110
+ if (storage) await this.ensureRunning();
13111
+ const data = await readResponseJson(storage ? await this.runtimeFetch("/snapshots/list", {
13112
+ method: "POST",
13113
+ body: JSON.stringify({
13114
+ projectId: this.id,
13115
+ storage
13116
+ })
13117
+ }) : await state(this).client.fetch(`/v1/sandboxes/${this.id}/snapshots`));
13115
13118
  return (Array.isArray(data) ? data : data.snapshots ?? []).map((s) => {
13116
13119
  const remoteSync = toSnapshotRemoteSync(s.remoteSync);
13117
13120
  return {
@@ -14950,12 +14953,7 @@ var SandboxInstance = class SandboxInstance extends SandboxEgressCapabilities {
14950
14953
  const children = (data.children ?? []).map((child) => createSandboxInstanceFromResponse(local.client, this.parseInfo(child), local.defaultRuntimeBackend));
14951
14954
  const materializedCount = children.length;
14952
14955
  const requestedCount = typeof data.fork?.requestedCount === "number" ? data.fork.requestedCount : count;
14953
- const reportedOutcome = data.idempotency?.outcome;
14954
- const reportedDigest = data.idempotency?.requestDigest;
14955
- const idempotency = (reportedOutcome === "created" || reportedOutcome === "replayed") && typeof reportedDigest === "string" ? {
14956
- outcome: reportedOutcome,
14957
- requestDigest: reportedDigest
14958
- } : void 0;
14956
+ const idempotency = parseIdempotencyAcknowledgement(data.idempotency);
14959
14957
  return {
14960
14958
  children,
14961
14959
  requestedCount,
@@ -15008,4 +15006,4 @@ var SandboxInstance = class SandboxInstance extends SandboxEgressCapabilities {
15008
15006
  }
15009
15007
  };
15010
15008
  //#endregion
15011
- export { isRateLimitCreateError as $, ProfileUnsupportedError as A, normalizeConnection as B, SandboxOperation as C, splitInlineProfileSkills as D, splitInlineProfileFileMounts as E, normalizeSandboxCreateReceipt as F, CAPACITY_ETA_WAIT_MAX_MS as G, normalizeProxySecretReceipt as H, normalizeStartupDiagnostics as I, createRetryDelayMs as J, DEPLOY_WINDOW_RETRY_MS as K, readFilesystemIncarnationTuple as L, isMaterializerHarness as M, materializeProfile as N, validateDeferredProfileFileMounts as O, normalizeCaptureProof as P, isDeployWindowCreateError as Q, dateOf as R, ManagedProcessClient as S, materializeProfileFileMounts as T, normalizeSandboxShape as U, normalizeEgressPolicyFields as V, CAPACITY_ETA_MARGIN_MS as W, generateIdempotencyKey as X, extendableDeadline as Y, isCapacityShortageCreateError as Z, collectAgentFinalMessageText as _, buildTraceExportPayload as a, isToolBearingEvent as b, toOtelJson as c, sandboxLedgerUsd as d, isRetryableCreateError as et, InteractiveSessionHandle as f, applySandboxEventText as g, createInteractiveTerminalSession as h, MAX_EGRESS_DENIALS_LIMIT as i, enforceWorkspacePlanSupport as j, HARNESS_LAUNCH_MATERIALIZE_OPTIONS as k, SandboxTaskSession as l, createInteractiveTerminalCapture as m, createSandboxInstanceFromResponse as n, exportTraceBundle as o, InteractiveTerminalFrameLog as p, awaitCreateResend as q, WorkspaceImages as r, otelTraceIdForTangleTrace as s, SandboxInstance as t, SandboxSession as u, collectAgentResponseText as v, SandboxOperationFailedError as w, deleteSandbox as x, getSandboxEventText as y, parseLifecycleTimes as z };
15009
+ export { isRateLimitCreateError as $, isMaterializerHarness as A, normalizeConnection as B, materializeProfileFileMounts as C, HARNESS_LAUNCH_MATERIALIZE_OPTIONS as D, validateDeferredProfileFileMounts as E, normalizeSandboxCreateReceipt as F, CAPACITY_ETA_WAIT_MAX_MS as G, normalizeProxySecretReceipt as H, normalizeStartupDiagnostics as I, createRetryDelayMs as J, DEPLOY_WINDOW_RETRY_MS as K, readFilesystemIncarnationTuple as L, SandboxOperation as M, SandboxOperationFailedError as N, ProfileUnsupportedError as O, normalizeCaptureProof as P, isDeployWindowCreateError as Q, dateOf as R, ManagedProcessClient as S, splitInlineProfileSkills as T, normalizeSandboxShape as U, normalizeEgressPolicyFields as V, CAPACITY_ETA_MARGIN_MS as W, generateIdempotencyKey as X, extendableDeadline as Y, isCapacityShortageCreateError as Z, collectAgentFinalMessageText as _, buildTraceExportPayload as a, isToolBearingEvent as b, toOtelJson as c, sandboxLedgerUsd as d, isRetryableCreateError as et, InteractiveSessionHandle as f, applySandboxEventText as g, createInteractiveTerminalSession as h, MAX_EGRESS_DENIALS_LIMIT as i, materializeProfile as j, enforceWorkspacePlanSupport as k, SandboxTaskSession as l, createInteractiveTerminalCapture as m, createSandboxInstanceFromResponse as n, exportTraceBundle as o, InteractiveTerminalFrameLog as p, awaitCreateResend as q, WorkspaceImages as r, otelTraceIdForTangleTrace as s, SandboxInstance as t, SandboxSession as u, collectAgentResponseText as v, splitInlineProfileFileMounts as w, deleteSandbox as x, getSandboxEventText as y, parseLifecycleTimes as z };
@@ -21,8 +21,8 @@ const seatProviderOriginSchema = z.url().refine((value) => {
21
21
  return url.protocol === "https:" && !url.username && !url.password && !url.search && !url.hash;
22
22
  });
23
23
  const seatSecretNameSchema = z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}$/);
24
- /** Classified account-owner refusal; only these fields ever leave the gateway. */
25
- const seatSelectionRefusalSchema = z.strictObject({ error: z.strictObject({
24
+ /** Classified account-owner refusal; parsing keeps only these fields and drops envelope extras (`nextStep`). */
25
+ const seatSelectionRefusalSchema = z.object({ error: z.object({
26
26
  code: z.enum([
27
27
  "provider_quota_exhausted",
28
28
  "upstream_unavailable",
@@ -1,5 +1,5 @@
1
1
  import { R as SandboxError } from "./terminal-stream-types-Cdz3xrux.js";
2
- import { _t as SeatOwnerTransport, bt as SeatSelectionRequest, ft as SEAT_COMMAND_TIMEOUT_MS } from "./client-BYGLoEiU.js";
2
+ import { _t as SeatOwnerTransport, bt as SeatSelectionRequest, ft as SEAT_COMMAND_TIMEOUT_MS } from "./client-D5GC6xYe.js";
3
3
 
4
4
  //#region src/select-seat-command.d.ts
5
5
  /** Public reply bound; the owner prints one metadata object. */
@@ -1,5 +1,5 @@
1
1
  import { C as SandboxError, O as ValidationError } from "./errors-D44qyFpy.js";
2
- import { r as SEAT_OWNER_MAX_RESPONSE_BYTES, s as seatOwnerTimeoutMs, t as SEAT_COMMAND_TIMEOUT_MS } from "./select-seat-Dc7cQ8To.js";
2
+ import { r as SEAT_OWNER_MAX_RESPONSE_BYTES, s as seatOwnerTimeoutMs, t as SEAT_COMMAND_TIMEOUT_MS } from "./select-seat-DWMZh9Mj.js";
3
3
  import { spawn } from "node:child_process";
4
4
  //#region src/select-seat-command.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { n as combineAbortSignals } from "../abort-signal-BsriwJ8L.js";
2
- import { i as fetchSandboxApi } from "../api-request-gkPDymqn.js";
2
+ import { i as fetchSandboxApi } from "../api-request-nbgUMuWb.js";
3
3
  import "../sidecar-proxy-error-DTdbCbUM.js";
4
4
  import { t as parseSSEStream } from "../sse-parser-BCG3iL9j.js";
5
5
  import { PART_TEXT, PART_TEXT_SUFFIX } from "@tangle-network/agent-core/sse";
@@ -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-DkB8WbjK.js";
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-DUEgpbVw.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 };
@@ -1,3 +1,3 @@
1
- import { _ as SandboxCreateResponseParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as AgentSandboxBlueprintAbi, g as SandboxCreateParamTypes, h as JsonResponseParamTypes, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_DELETE, n as fetchQuote, o as validateQuote, p as JOB_SANDBOX_CREATE, r as inputsHashOf, s as BlueprintSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxIdParamTypes } from "../tangle-BP8F3ZN0.js";
1
+ import { _ as SandboxCreateResponseParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as AgentSandboxBlueprintAbi, g as SandboxCreateParamTypes, h as JsonResponseParamTypes, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_DELETE, n as fetchQuote, o as validateQuote, p as JOB_SANDBOX_CREATE, r as inputsHashOf, s as BlueprintSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxIdParamTypes } from "../tangle-BBF4pV5c.js";
2
2
  import { t as ITangleJobsAbi } from "../abi-pcDt2Adp.js";
3
3
  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 };
@@ -1,6 +1,6 @@
1
- import { L as readFilesystemIncarnationTuple, n as createSandboxInstanceFromResponse } from "./sandbox-C3PqmwfU.js";
1
+ import { L as readFilesystemIncarnationTuple, n as createSandboxInstanceFromResponse } from "./sandbox-D86jxPzC.js";
2
2
  import { a as readResponseJson } from "./errors-D44qyFpy.js";
3
- import { i as fetchSandboxApi } from "./api-request-gkPDymqn.js";
3
+ import { i as fetchSandboxApi } from "./api-request-nbgUMuWb.js";
4
4
  import { t as ITangleJobsAbi } from "./abi-pcDt2Adp.js";
5
5
  import { _ as rotlBH, a as anumber, b as rotlSL, d as createXOFer, g as u32, h as toBytes$1, l as createHasher, m as swap32IfBE, n as abytes, o as aoutput, r as aexists, s as clean, t as Hash, v as rotlBL, x as split, y as rotlSH } from "./utils-BvN0Mk3j.js";
6
6
  //#region ../../../packages/runtime-contracts/dist/tangle-blueprint-abi.js