@tangle-network/sandbox 0.60.74 → 0.60.77-develop.20261016231633.b9943d8

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 (34) hide show
  1. package/README.md +46 -0
  2. package/dist/agent/index.d.ts +4 -4
  3. package/dist/agent/index.js +4 -4
  4. package/dist/agent/preview.d.ts +1 -1
  5. package/dist/{agent-run-outcome-eZF8RuUN.d.ts → agent-run-outcome-CTEpjCEZ.d.ts} +1 -1
  6. package/dist/{chunked-upload-CDrLMO8N.js → chunked-upload-DtIvkKNo.js} +1 -1
  7. package/dist/{chunked-upload-file-BwbqHWUX.js → chunked-upload-file-DnsHEjg0.js} +1 -1
  8. package/dist/{client-C7Y6waVg.js → client-CRkHfByN.js} +4 -3
  9. package/dist/{client-BujziOIc.d.ts → client-Lhxo82x1.d.ts} +4 -4
  10. package/dist/collaboration/index.js +1 -1
  11. package/dist/{collaboration-CTbq2OYh.js → collaboration-DaJU5O0E.js} +1 -1
  12. package/dist/core.d.ts +6 -6
  13. package/dist/core.js +3 -3
  14. package/dist/{errors-C8YcR1BL.js → errors-DSJBKmGZ.js} +31 -2
  15. package/dist/{errors-Bj5DL2ge.d.ts → errors-mPL-qvgF.d.ts} +20 -2
  16. package/dist/{index-CP9a77KP.d.ts → index-DRto9Ijb.d.ts} +2 -2
  17. package/dist/index.d.ts +14 -11
  18. package/dist/index.js +7 -7
  19. package/dist/intelligence/index.js +1 -1
  20. package/dist/{interactive-controller-BFbCkMq4.js → interactive-controller-CJ24g8Va.js} +27 -7
  21. package/dist/{lines-_rRdwxof.d.ts → lines-DodQslsf.d.ts} +1 -1
  22. package/dist/lines.d.ts +1 -1
  23. package/dist/lines.js +1 -1
  24. package/dist/{managed-process-CPHeQONO.d.ts → managed-process-B7WfqKmi.d.ts} +1 -1
  25. package/dist/{preview-n41aOXde.d.ts → preview-wpGGk0bu.d.ts} +3 -3
  26. package/dist/runtime.d.ts +3 -3
  27. package/dist/runtime.js +3 -3
  28. package/dist/{sandbox-DfSqEr3f.d.ts → sandbox-CoIGxzm_.d.ts} +11 -10
  29. package/dist/{sandbox-DGoQMthD.js → sandbox-DzSEprto.js} +59 -15
  30. package/dist/tangle/index.d.ts +1 -1
  31. package/dist/tangle/index.js +1 -1
  32. package/dist/{tangle-vyeLQFFg.js → tangle-DHFKq9sn.js} +2 -2
  33. package/dist/{types-Mi83KD0D.d.ts → types-B_QF-iHm.d.ts} +89 -9
  34. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- import { b as parseErrorResponse, l as NetworkError, v as TimeoutError } from "../errors-C8YcR1BL.js";
1
+ import { u as NetworkError, x as parseErrorResponse, y as TimeoutError } from "../errors-DSJBKmGZ.js";
2
2
  //#region src/intelligence/index.ts
3
3
  /**
4
4
  * `@tangle-network/sandbox/intelligence` — browser-safe typed client for the
@@ -1,9 +1,9 @@
1
1
  import { r as backendTypeSchema } from "./backend-types-D6bYbvMB.js";
2
- import { h as ServerError, l as NetworkError, m as SandboxError, r as CapabilityError, x as parseResponseError, y as ValidationError } from "./errors-C8YcR1BL.js";
2
+ import { S as parseResponseError, b as ValidationError, g as ServerError, h as SandboxError, r as CapabilityError, u as NetworkError } from "./errors-DSJBKmGZ.js";
3
3
  import { c as assertInteractiveSessionRef, d as awaitWithAbort, f as combineAbortSignals, i as createBrowserInteractiveSessionControlTransport, o as InteractiveSessionControlController, r as browserInteractiveTerminalEndpoint } from "./browser-interactive-control-controller-BJf0P_J4.js";
4
- import { s as uploadChunked } from "./chunked-upload-CDrLMO8N.js";
4
+ import { s as uploadChunked } from "./chunked-upload-DtIvkKNo.js";
5
5
  import { z } from "zod";
6
- import { AgentExactRunControlRefSchema, AgentExecutionOutcomeSchema, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionRefSchema, AgentRuntimeAttachmentsSchema, DurablePlanSchema, InteractionRequestSchema, agentInteractiveSessionControlClaimMatchesRef, agentProfileSchema, canonicalCandidateDigest } from "@tangle-network/agent-interface";
6
+ import { AgentExactRunControlRefSchema, AgentExecutionOutcomeSchema, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionRefSchema, AgentRuntimeAttachmentsSchema, DurablePlanSchema, InteractionRequestSchema, PlanContinuationSchema, agentInteractiveSessionControlClaimMatchesRef, agentProfileSchema, canonicalCandidateDigest } from "@tangle-network/agent-interface";
7
7
  //#region src/agent-run-outcome-inspection.ts
8
8
  const HUB_APPROVAL_REQUIRED = "HUB_APPROVAL_REQUIRED";
9
9
  const MAX_SERIALIZED_TOOL_VALUE_BYTES = 4 * 1024 * 1024;
@@ -678,6 +678,9 @@ function withoutRuntimeSecrets(backend) {
678
678
  function normalizeRuntimeBackendConfig(backendInput, options = {}) {
679
679
  const backend = foldModelRoutingFields(backendInput);
680
680
  if (!backend) return void 0;
681
+ const continuation = backendInput?.planContinuation;
682
+ if (continuation !== void 0 && !options.allowPlanContinuation) throw new ValidationError("backend.planContinuation is turn-only; session creation and persistence cannot carry it");
683
+ if (continuation !== void 0 && !PlanContinuationSchema.safeParse(continuation).success) throw new ValidationError("backend.planContinuation is invalid");
681
684
  if (backend.runtimeSecrets !== void 0) {
682
685
  if (!options.allowRuntimeSecrets) throw new ValidationError("[sandbox-sdk] backend.runtimeSecrets is turn-scoped credential delivery: send it on a turn request (streamPrompt / driveConversationTurn / sendMessage), not on sandbox or session creation");
683
686
  assertRuntimeSecrets(backend.runtimeSecrets);
@@ -694,6 +697,7 @@ function normalizeRuntimeBackendConfig(backendInput, options = {}) {
694
697
  if (backend.type !== void 0) assertCurrentBackendType(backend.type);
695
698
  if (backend.profile !== void 0 && !agentProfileSchema.safeParse(backend.profile).success) throw new Error("[sandbox-sdk] backend.profile must be an AgentProfile object");
696
699
  return {
700
+ ...continuation !== void 0 ? { planContinuation: structuredClone(continuation) } : {},
697
701
  ...backend?.type ? { type: backend.type } : {},
698
702
  ...backend?.profile !== void 0 ? { profile: backend.profile } : {},
699
703
  ...backend.runtimeAttachments !== void 0 ? { runtimeAttachments: structuredClone(backend.runtimeAttachments) } : {},
@@ -706,11 +710,17 @@ function normalizeRuntimeBackendConfig(backendInput, options = {}) {
706
710
  }
707
711
  /** Digest the exact public backend payload the SDK sends for a profile turn. */
708
712
  function requestedPublicProfileDigest(backend) {
709
- return publicProfileRequestDigest(normalizeRuntimeBackendConfig(backend, { allowRuntimeSecrets: true }) ?? {});
713
+ return publicProfileRequestDigest(normalizeRuntimeBackendConfig(backend, {
714
+ allowRuntimeSecrets: true,
715
+ allowPlanContinuation: true
716
+ }) ?? {});
710
717
  }
711
718
  /** Digest public profile controls while private turn fields remain on wire. */
712
719
  function requestedSecretProfilePublicDigest(backend) {
713
- return secretProfilePublicRequestDigest(normalizeRuntimeBackendConfig(backend, { allowRuntimeSecrets: true }) ?? {});
720
+ return secretProfilePublicRequestDigest(normalizeRuntimeBackendConfig(backend, {
721
+ allowRuntimeSecrets: true,
722
+ allowPlanContinuation: true
723
+ }) ?? {});
714
724
  }
715
725
  //#endregion
716
726
  //#region ../../../packages/sse-core/dist/index.js
@@ -1397,6 +1407,11 @@ var SandboxRuntimeApi = class {
1397
1407
  "content-type": "application/json",
1398
1408
  "x-no-retry": "true"
1399
1409
  });
1410
+ if (options.planFollowUp) {
1411
+ if (!request.backend?.planContinuation || !request.expectedPublicProfileRequestDigest || !request.expectedSecretProfileReceipt || !Number.isFinite(Date.parse(options.planFollowUp.expiresAt)) || Date.parse(options.planFollowUp.expiresAt) <= Date.now()) throw new ValidationError("Caller plan follow-up requires current admission and both fresh profile pins");
1412
+ headers.set("x-tangle-plan-followup-credential", options.planFollowUp.credential);
1413
+ headers.set("x-tangle-plan-followup-callback", options.planFollowUp.callbackUrl);
1414
+ }
1400
1415
  if (options.credentials?.apiKey) headers.set("X-Backend-Api-Key", options.credentials.apiKey);
1401
1416
  if (options.credentials?.baseUrl) headers.set("X-Backend-Base-Url", options.credentials.baseUrl);
1402
1417
  if (options.traceId !== void 0) headers.set(TRACE_ID_HEADER, resolveTraceId(options.traceId));
@@ -1413,7 +1428,7 @@ var SandboxRuntimeApi = class {
1413
1428
  try {
1414
1429
  receipt = await this.json(path, init);
1415
1430
  } catch (error) {
1416
- if (!isRetryableCredentialRefusal(error)) throw error;
1431
+ if (options.planFollowUp || !isRetryableCredentialRefusal(error)) throw error;
1417
1432
  await waitForRetryAfter(error.retryAfterMs ?? 1e3, signal);
1418
1433
  receipt = await this.json(path, init);
1419
1434
  }
@@ -1589,6 +1604,7 @@ function normalizeSessionInfo(raw) {
1589
1604
  }
1590
1605
  /** The admission check must hash the same wire request as dispatch. */
1591
1606
  function sessionMessageRequestBody(request) {
1607
+ if (request.ttlMs !== void 0 && (!Number.isInteger(request.ttlMs) || request.ttlMs <= 0)) throw new ValidationError("ttlMs must be a positive integer of milliseconds");
1592
1608
  if (request.admissionDeadline !== void 0) {
1593
1609
  if (!request.turnId) throw new ValidationError("admissionDeadline requires turnId");
1594
1610
  const deadline = request.admissionDeadline;
@@ -1603,13 +1619,17 @@ function sessionMessageRequestBody(request) {
1603
1619
  if (request.expectedPublicProfileRevision !== void 0 && request.expectedPublicProfileRequestDigest === void 0) throw new ValidationError("Native public profile plan pin requires a public request pin");
1604
1620
  if (request.expectedSecretProfileReceipt !== void 0 && (request.expectedPublicProfileRequestDigest === void 0 || request.expectedPublicProfileRevision !== void 0 || !/^hmac-sha256:[a-f0-9]{64}$/.test(request.expectedSecretProfileReceipt))) throw new ValidationError("Secret native profile receipt requires a public request pin and no public native receipt");
1605
1621
  return {
1606
- ...request.backend !== void 0 ? { backend: normalizeRuntimeBackendConfig(request.backend, { allowRuntimeSecrets: true }) } : {},
1622
+ ...request.backend !== void 0 ? { backend: normalizeRuntimeBackendConfig(request.backend, {
1623
+ allowRuntimeSecrets: true,
1624
+ allowPlanContinuation: true
1625
+ }) } : {},
1607
1626
  ...request.managedQuoteVersion !== void 0 ? { managedQuoteVersion: request.managedQuoteVersion } : {},
1608
1627
  ...request.expectedPublicProfileRequestDigest !== void 0 ? { expectedPublicProfileRequestDigest: request.expectedPublicProfileRequestDigest } : {},
1609
1628
  ...request.expectedPublicProfileRevision !== void 0 ? { expectedPublicProfileRevision: request.expectedPublicProfileRevision } : {},
1610
1629
  ...request.expectedSecretProfileReceipt !== void 0 ? { expectedSecretProfileReceipt: request.expectedSecretProfileReceipt } : {},
1611
1630
  ...request.managedModelCredential === true ? { managedModelCredential: true } : {},
1612
1631
  ...request.runControlRef !== void 0 ? { runControlRef: AgentExactRunControlRefSchema.parse(request.runControlRef) } : {},
1632
+ ...request.ttlMs !== void 0 ? { ttlMs: request.ttlMs } : {},
1613
1633
  ...request.admissionDeadline !== void 0 ? { admissionDeadline: request.admissionDeadline } : {},
1614
1634
  ...request.messageId !== void 0 ? { messageID: request.messageId } : {},
1615
1635
  parts: request.parts.map((part) => part.type === "text" ? {
@@ -1,4 +1,4 @@
1
- import { B as CreateSandboxOptions, d as BackendConfig } from "./types-Mi83KD0D.js";
1
+ import { B as CreateSandboxOptions, d as BackendConfig } from "./types-B_QF-iHm.js";
2
2
 
3
3
  //#region src/line-application.d.ts
4
4
  /** Bounded callback request bytes after canonicalization, including JSON framing. */
package/dist/lines.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as LineSendReceipt, B as lineInstanceKey, C as LineReplyCode, D as LineRespondView, E as LineRespondAgent, F as LineVoice, I as LineVoiceOptions, L as LinesClient, M as LineSenderVerificationStart, N as LineThread, O as LineRole, P as LineTransport, R as LinesHttpClient, S as LineReminderPreferences, T as LineReplyGate, V as profileChannelReference, _ as LineMemberPatch, a as LineApplicationAttachOptions, b as LineNumberInventory, c as LineAttachmentReauthorization, d as LineImage, f as LineInstanceAttachOptions, g as LineMemberInstance, h as LineMember, i as LineAllowanceSubject, j as LineSenderVerification, k as LineSendInput, l as LineExecutionKey, m as LineLimits, n as LineAgentRolePolicy, o as LineAttachOptions, p as LineInstanceCreate, r as LineAllowance, s as LineAttachment, t as Line, u as LineFromConnectionInput, v as LineMemberSpec, w as LineReplyCodeInput, x as LineProvider, y as LineMessage, z as SandboxLines } from "./lines-_rRdwxof.js";
1
+ import { A as LineSendReceipt, B as lineInstanceKey, C as LineReplyCode, D as LineRespondView, E as LineRespondAgent, F as LineVoice, I as LineVoiceOptions, L as LinesClient, M as LineSenderVerificationStart, N as LineThread, O as LineRole, P as LineTransport, R as LinesHttpClient, S as LineReminderPreferences, T as LineReplyGate, V as profileChannelReference, _ as LineMemberPatch, a as LineApplicationAttachOptions, b as LineNumberInventory, c as LineAttachmentReauthorization, d as LineImage, f as LineInstanceAttachOptions, g as LineMemberInstance, h as LineMember, i as LineAllowanceSubject, j as LineSenderVerification, k as LineSendInput, l as LineExecutionKey, m as LineLimits, n as LineAgentRolePolicy, o as LineAttachOptions, p as LineInstanceCreate, r as LineAllowance, s as LineAttachment, t as Line, u as LineFromConnectionInput, v as LineMemberSpec, w as LineReplyCodeInput, x as LineProvider, y as LineMessage, z as SandboxLines } from "./lines-DodQslsf.js";
2
2
  export { Line, LineAgentRolePolicy, LineAllowance, LineAllowanceSubject, LineApplicationAttachOptions, LineAttachOptions, LineAttachment, LineAttachmentReauthorization, LineExecutionKey, LineFromConnectionInput, LineImage, LineInstanceAttachOptions, LineInstanceCreate, LineLimits, LineMember, LineMemberInstance, LineMemberPatch, LineMemberSpec, LineMessage, LineNumberInventory, LineProvider, LineReminderPreferences, LineReplyCode, LineReplyCodeInput, LineReplyGate, LineRespondAgent, LineRespondView, LineRole, LineSendInput, LineSendReceipt, LineSenderVerification, LineSenderVerificationStart, LineThread, LineTransport, LineVoice, LineVoiceOptions, LinesClient, LinesHttpClient, SandboxLines, lineInstanceKey, profileChannelReference };
package/dist/lines.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b as parseErrorResponse, y as ValidationError } from "./errors-C8YcR1BL.js";
1
+ import { b as ValidationError, x as parseErrorResponse } from "./errors-DSJBKmGZ.js";
2
2
  //#region src/lines.ts
3
3
  /**
4
4
  * Lines: give a sandbox a phone number or messaging address.
@@ -1,4 +1,4 @@
1
- import { An as ManagedProcessOptions, Mn as ManagedProcessResumeOptions, Nn as ManagedProcessSpec, jn as ManagedProcessRecord, kn as ManagedProcessJobs } from "./types-Mi83KD0D.js";
1
+ import { Fn as ManagedProcessJobs, In as ManagedProcessOptions, Ln as ManagedProcessRecord, Rn as ManagedProcessResumeOptions, zn as ManagedProcessSpec } from "./types-B_QF-iHm.js";
2
2
 
3
3
  //#region src/managed-process.d.ts
4
4
  declare class ManagedProcessClient implements ManagedProcessJobs {
@@ -1,6 +1,6 @@
1
- import { n as SandboxInstance } from "./sandbox-DfSqEr3f.js";
2
- import { Hn as PreviewLinkInfo, ht as EnsureDevServerOptions } from "./types-Mi83KD0D.js";
3
- import { i as Sandbox } from "./client-BujziOIc.js";
1
+ import { n as SandboxInstance } from "./sandbox-CoIGxzm_.js";
2
+ import { Jn as PreviewLinkInfo, _t as EnsureDevServerOptions } from "./types-B_QF-iHm.js";
3
+ import { i as Sandbox } from "./client-Lhxo82x1.js";
4
4
 
5
5
  //#region src/agent/preview-operations.d.ts
6
6
  type AgentPreviewOptions = Pick<EnsureDevServerOptions, "sessionId" | "cwd"> & {
package/dist/runtime.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { $i as SessionExecutionStatus, A as CommitTaskSessionOptions, At as FileUsageOptions, Da as TaskSessionInfo, Di as SandboxRuntimeHealth, Fi as SandboxTerminalManager, H as CreateTaskSessionOptions, Ii as SandboxTerminalRequestOptions, Ji as SendSessionMessageRequest, Mt as FileWriteResult, Ni as SandboxTerminalCreateOptions, Ot as FileTreeOptions, Pi as SandboxTerminalInfo, Pr as SandboxEvent, Qi as SessionExecutionInfo, St as FileReadBatchResult, T as ChunkedUploadResult, Ta as TaskSessionCommitResult, Tt as FileRenameResult, V as CreateSessionOptions, Wa as WriteFileOptions, Yi as SentSessionMessage, Zi as SessionEventStreamOptions, aa as SessionMessage, bi as SandboxPortBinding, hr as RenameOptions, jt as FileUsageResult, kt as FileTreeResult, na as SessionInfo, oa as SessionMessageAdmission, qi as SendSessionMessageOptions, w as ChunkedUploadOptions, wa as TaskSessionChanges, wn as ListMessagesOptions, xt as FileReadBatchOptions, za as UploadProgress } from "./types-Mi83KD0D.js";
1
+ import { $i as SendSessionMessageOptions, A as CommitTaskSessionOptions, Aa as TaskSessionChanges, An as ListMessagesOptions, At as FileTreeOptions, Bi as SandboxTerminalInfo, Br as SandboxEvent, Ct as FileReadBatchOptions, Dt as FileRenameResult, Ei as SandboxPortBinding, H as CreateTaskSessionOptions, Hi as SandboxTerminalRequestOptions, Ka as UploadProgress, Mt as FileUsageOptions, Na as TaskSessionInfo, Ni as SandboxRuntimeHealth, Nt as FileUsageResult, Pt as FileWriteResult, T as ChunkedUploadResult, V as CreateSessionOptions, Vi as SandboxTerminalManager, Za as WriteFileOptions, aa as SessionExecutionStatus, ca as SessionInfo, da as SessionMessage, ea as SendSessionMessageRequest, fa as SessionMessageAdmission, ia as SessionExecutionInfo, ja as TaskSessionCommitResult, jt as FileTreeResult, ra as SessionEventStreamOptions, ta as SentSessionMessage, w as ChunkedUploadOptions, wt as FileReadBatchResult, xr as RenameOptions, zi as SandboxTerminalCreateOptions } from "./types-B_QF-iHm.js";
2
2
  import { n as TerminalStream, p as ScopedToken } from "./terminal-stream-jdYomM1m.js";
3
3
  import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-rpTbyvAS.js";
4
- import { S as BrowserInteractiveSessionController, _ as StateError, b as TimeoutError, c as NetworkError, d as QuotaError, g as ServerError, h as SandboxFailureDetail, l as NotFoundError, m as SandboxErrorJson, o as FileWriteConflictError, p as SandboxError, r as CapabilityError, t as AuthError, u as PartialFailureError, x as ValidationError } from "./errors-Bj5DL2ge.js";
5
- import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-eZF8RuUN.js";
4
+ import { C as ValidationError, S as TimeoutError, _ as SandboxFailureDetail, d as NotFoundError, f as PartialFailureError, g as SandboxErrorJson, h as SandboxError, o as FileWriteConflictError, p as QuotaError, r as CapabilityError, t as AuthError, u as NetworkError, v as ServerError, w as BrowserInteractiveSessionController, y as StateError } from "./errors-mPL-qvgF.js";
5
+ import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-CTEpjCEZ.js";
6
6
 
7
7
  //#region src/lib/chunked-upload.d.ts
8
8
  /** The transport a caller wires this module to — {@link SandboxInstance.runtimeFetch}
package/dist/runtime.js CHANGED
@@ -1,7 +1,7 @@
1
- import { F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, L as deriveAgentRunOutcome, R as projectAgentTerminalRecord, t as BrowserInteractiveSessionController, u as SandboxRuntimeApi } from "./interactive-controller-BFbCkMq4.js";
2
- import { d as PartialFailureError, f as QuotaError, g as StateError, h as ServerError, l as NetworkError, m as SandboxError, o as FileWriteConflictError, r as CapabilityError, t as AuthError, u as NotFoundError, v as TimeoutError, y as ValidationError } from "./errors-C8YcR1BL.js";
1
+ import { F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, L as deriveAgentRunOutcome, R as projectAgentTerminalRecord, t as BrowserInteractiveSessionController, u as SandboxRuntimeApi } from "./interactive-controller-CJ24g8Va.js";
2
+ import { _ as StateError, b as ValidationError, d as NotFoundError, f as PartialFailureError, g as ServerError, h as SandboxError, o as FileWriteConflictError, p as QuotaError, r as CapabilityError, t as AuthError, u as NetworkError, y as TimeoutError } from "./errors-DSJBKmGZ.js";
3
3
  import { f as combineAbortSignals, n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError } from "./browser-interactive-control-controller-BJf0P_J4.js";
4
- import { s as uploadChunked } from "./chunked-upload-CDrLMO8N.js";
4
+ import { s as uploadChunked } from "./chunked-upload-DtIvkKNo.js";
5
5
  //#region src/runtime-client.ts
6
6
  const DEFAULT_RUNTIME_TIMEOUT_MS = 3e4;
7
7
  function requireToken(token) {
@@ -1,9 +1,9 @@
1
1
  import { t as CliAuthReference } from "./cli-auth-bundle-ODe06Ts7.js";
2
- import { $a as RawEvidenceDirectoryExport, $n as PromptInputPart, A as CommitTaskSessionOptions, Ar as SandboxDeleteOptions, C as BranchOptions, Ci as SandboxResourceUsage, Cn as JsonValue, D as CodeExecutionResult, Da as TaskSessionInfo, Di as SandboxRuntimeHealth, E as CodeExecutionOptions, Ei as SandboxRuntimeCapabilities, Er as SSHCredentials, Et as FileSystem, Ga as WriteManyFile, H as CreateTaskSessionOptions, Ha as WaitForRolloutOptions, Ia as TurnDriveResult, Ji as SendSessionMessageRequest, Ka as WriteManyOptions, Li as SandboxTerminals, M as ConversationTurnOptions, Mi as SandboxTerminalAttachOptions, Mt as FileWriteResult, N as ConversationTurnResult, Na as TeePublicKeyResponse, O as CodeLanguage, Oi as SandboxShape, Or as SandboxConnection, Pr as SandboxEvent, Q as DispatchedSession, Qi as SessionExecutionInfo, Qt as ForkLookupOptions, Ri as SandboxTraceBundle, Rn as NetworkManager, Sn as IntelligenceReportWindow, Sr as RolloutStartResult, Ta as TaskSessionCommitResult, Tr as SSHCommandDescriptor, Ua as WorkspaceOperationLookup, Ui as SearchMatch, Un as PreviewLinkManager, V as CreateSessionOptions, Va as WaitForOptions, Vi as SandboxTraceOptions, Vn as PermissionsManager, Wa as WriteFileOptions, Wi as SearchOptions, Xa as SandboxEnvRecovery, Xt as ForkCounts, Ya as SandboxCreateReceipt, Yi as SentSessionMessage, Yn as ProcessManager, Z as DispatchPromptOptions, Za as SandboxEnvRecoveryView, Zi as SessionEventStreamOptions, Zt as ForkIdempotency, _a as SnapshotResult, _i as SandboxOperationInfo, _n as InstalledTool, _r as ResumeOptions, aa as SessionMessage, ai as SandboxFleetTraceBundle, an as GitStatus, ao as InteractionResolutionAcknowledgement, bi as SandboxPortBinding, bn as IntelligenceReportCompareTo, br as RolloutOptions, ca as SessionResultOptions, d as BackendConfig, dn as GpuLeaseManager, eo as RawEvidenceExportOptions, er as PromptOptions, gn as HttpClient, gr as RestoreSnapshotOptions, gt as EventStreamOptions, ha as SnapshotProvenance, hi as SandboxInfo, ia as SessionListOptions, in as GitDiff, io as WorkspaceImagePublishResult$1, it as DriverInfo, j as CompletedTurnResult, ja as TeeAttestationResponse, ji as SandboxStatus, ka as TeeAttestationOptions, kr as SandboxDeleteAcknowledgement, ma as SnapshotOptions, na as SessionInfo, nn as GitCommit, nr as ProvisionEvent, nt as DriveTurnOptions, oa as SessionMessageAdmission, on as GpuLease, or as PublicProfileConflict, ot as DurablePlan, p as BackendManager, pa as SnapshotInfo, pt as EgressManager, qi as SendSessionMessageOptions, ra as SessionInterruptOptions, rr as ProvisionResult, st as DurablePlanDecisionResult, ta as SessionForkOptions, tn as GitBranch, tr as PromptResult, ua as SnapshotDeleteAcknowledgement, vi as SandboxOperationKind, vn as IntelligenceReport, vr as Rollout, vt as ExecOptions, wa as TaskSessionChanges, wn as ListMessagesOptions, xa as StopOptions, ya as StartupDiagnostics, yi as SandboxOperationState, yn as IntelligenceReportBudget, yt as ExecResult } from "./types-Mi83KD0D.js";
2
+ import { $a as WriteManyOptions, $i as SendSessionMessageOptions, $t as ForkIdempotency, A as CommitTaskSessionOptions, Aa as TaskSessionChanges, An as ListMessagesOptions, Br as SandboxEvent, C as BranchOptions, Ca as SnapshotResult, Ci as SandboxOperationInfo, Cn as InstalledTool, Cr as ResumeOptions, D as CodeExecutionResult, Da as StopOptions, E as CodeExecutionOptions, Ei as SandboxPortBinding, En as IntelligenceReportCompareTo, Er as RolloutOptions, Fa as TeeAttestationOptions, Fr as SandboxDeleteAcknowledgement, H as CreateTaskSessionOptions, Ha as TurnBackendConfig, Ir as SandboxDeleteOptions, Ja as WaitForOptions, La as TeeAttestationResponse, Li as SandboxStatus, M as ConversationTurnOptions, Mi as SandboxRuntimeCapabilities, Mr as SSHCredentials, N as ConversationTurnResult, Na as TaskSessionInfo, Ni as SandboxRuntimeHealth, O as CodeLanguage, On as IntelligenceReportWindow, Or as RolloutStartResult, Ot as FileSystem, Pi as SandboxShape, Pr as SandboxConnection, Pt as FileWriteResult, Q as DispatchedSession, Qa as WriteManyFile, Qt as ForkCounts, Ri as SandboxTerminalAttachOptions, Sn as HttpClient, Sr as RestoreSnapshotOptions, Ta as StartupDiagnostics, Ti as SandboxOperationState, Tn as IntelligenceReportBudget, Ua as TurnDriveResult, Ui as SandboxTerminals, V as CreateSessionOptions, Wi as SandboxTraceBundle, Wn as NetworkManager, Xa as WorkspaceOperationLookup, Xi as SearchOptions, Ya as WaitForRolloutOptions, Yi as SearchMatch, Yn as PreviewLinkManager, Z as DispatchPromptOptions, Za as WriteFileOptions, ar as PromptInputPart, ba as SnapshotOptions, bt as ExecOptions, ca as SessionInfo, cn as GpuLease, cr as ProvisionEvent, ct as DurablePlanDecisionResult, d as BackendConfig, da as SessionMessage, di as SandboxFleetTraceBundle, do as WorkspaceImagePublishResult$1, ea as SendSessionMessageRequest, en as ForkLookupOptions, fa as SessionMessageAdmission, fo as InteractionResolutionAcknowledgement, fr as PublicProfileConflict, ga as SnapshotDeleteAcknowledgement, ht as EgressManager, ia as SessionExecutionInfo, in as GitCommit, io as SandboxEnvRecoveryView, it as DriverInfo, j as CompletedTurnResult, ja as TaskSessionCommitResult, jr as SSHCommandDescriptor, ki as SandboxResourceUsage, kn as JsonValue, la as SessionInterruptOptions, lr as ProvisionResult, ma as SessionResultOptions, no as SandboxCreateReceipt, nt as DriveTurnOptions, on as GitDiff, oo as RawEvidenceDirectoryExport, or as PromptOptions, ot as DurablePlan, p as BackendManager, pn as GpuLeaseManager, qi as SandboxTraceOptions, qn as PermissionsManager, ra as SessionEventStreamOptions, rn as GitBranch, ro as SandboxEnvRecovery, sa as SessionForkOptions, sn as GitStatus, so as RawEvidenceExportOptions, sr as PromptResult, st as DurablePlanDecisionOptions, ta as SentSessionMessage, tr as ProcessManager, ua as SessionListOptions, vt as EventStreamOptions, wi as SandboxOperationKind, wn as IntelligenceReport, wr as Rollout, xa as SnapshotProvenance, xi as SandboxInfo, xt as ExecResult, ya as SnapshotInfo, za as TeePublicKeyResponse } from "./types-B_QF-iHm.js";
3
3
  import { c as TerminalStreamReconnectAuthority, f as MintScopedTokenOptions, n as TerminalStream, o as TerminalStreamHandlers, p as ScopedToken, y as TerminalReadyInfo } from "./terminal-stream-jdYomM1m.js";
4
4
  import { f as InteractiveAttachOptions, g as InteractiveSessionStatus, h as InteractiveRequestOptions, m as InteractiveControlClaimOptions, p as InteractiveControlClaimAcknowledgement } from "./browser-interactive-control-controller-rpTbyvAS.js";
5
- import { p as SandboxError, w as InteractiveAttachRequest } from "./errors-Bj5DL2ge.js";
6
- import { z as SandboxLines } from "./lines-_rRdwxof.js";
5
+ import { E as InteractiveAttachRequest, h as SandboxError } from "./errors-mPL-qvgF.js";
6
+ import { z as SandboxLines } from "./lines-DodQslsf.js";
7
7
  import { z } from "zod";
8
8
  import { AgentInteractiveSessionAttach, AgentInteractiveSessionControlClaim, AgentInteractiveSessionControlClaimAcknowledgement, AgentInteractiveSessionControlClaimRequest, AgentInteractiveSessionPromptAcknowledgement, AgentInteractiveSessionPromptCommand, AgentInteractiveSessionRef, AgentInteractiveSessionStart, AgentInteractiveSessionStopAcknowledgement, AgentInteractiveSessionStopCommand, AgentInteractiveTerminalSession, AgentInteractiveTerminalSession as AgentInteractiveTerminalSession$1, AgentProfile, AgentProfileFileMount, AgentRunCancellationAcknowledgement, AgentRunCancellationRequest, InteractionAcknowledgement, InteractionData, InteractionRequest, InteractionResponseCommand, TerminalOutputEvent, TerminalReplayWindow, agentInteractiveSessionPromptRequestDigest } from "@tangle-network/agent-interface";
9
9
 
@@ -579,7 +579,7 @@ interface SandboxSessionHost extends InteractiveSessionHost {
579
579
  } | {
580
580
  outcome: "rejected";
581
581
  feedback: string;
582
- }): Promise<DurablePlanDecisionResult>;
582
+ }, options?: DurablePlanDecisionOptions): Promise<DurablePlanDecisionResult>;
583
583
  }
584
584
  /**
585
585
  * A single agent session inside a sandbox. Created via
@@ -711,10 +711,10 @@ declare class SandboxSession {
711
711
  }): Promise<SandboxInteractionResult>;
712
712
  /** Return the newest plan awaiting a decision for this session. */
713
713
  plan(): Promise<DurablePlan | null>;
714
- /** Approve a durable plan and enqueue its separate execution turn. */
715
- approvePlan(planId?: string): Promise<DurablePlanDecisionResult>;
716
- /** Reject a durable plan with required feedback and enqueue a revision turn. */
717
- rejectPlan(feedback: string, planId?: string): Promise<DurablePlanDecisionResult>;
714
+ /** Approve a durable plan; caller mode returns admission for fresh preparation. */
715
+ approvePlan(planId?: string, options?: DurablePlanDecisionOptions): Promise<DurablePlanDecisionResult>;
716
+ /** Reject a durable plan with feedback; caller mode prepares the revision turn. */
717
+ rejectPlan(feedback: string, planId?: string, options?: DurablePlanDecisionOptions): Promise<DurablePlanDecisionResult>;
718
718
  private requireCurrentPlan;
719
719
  }
720
720
  //#endregion
@@ -1674,6 +1674,7 @@ declare class SandboxInstance {
1674
1674
  * from a broken response would manufacture the very proof it came for.
1675
1675
  */
1676
1676
  private egressActivity;
1677
+ private gpuProviders;
1677
1678
  private gpuAttach;
1678
1679
  private gpuList;
1679
1680
  private gpuExec;
@@ -2305,7 +2306,7 @@ declare class SandboxInstance {
2305
2306
  /** Prepare a secret-bearing native revision without starting a model turn. */
2306
2307
  prepareSecretProfileRevision(opts: {
2307
2308
  sessionId: string;
2308
- backend: Partial<BackendConfig>;
2309
+ backend: TurnBackendConfig;
2309
2310
  model?: ConversationTurnOptions["model"];
2310
2311
  }): Promise<{
2311
2312
  expectedPublicProfileRequestDigest: `sha256:${string}`;
@@ -2397,7 +2398,7 @@ declare class SandboxInstance {
2397
2398
  } | {
2398
2399
  outcome: "rejected";
2399
2400
  feedback: string;
2400
- }): Promise<DurablePlanDecisionResult>;
2401
+ }, options?: DurablePlanDecisionOptions): Promise<DurablePlanDecisionResult>;
2401
2402
  }
2402
2403
  //#endregion
2403
2404
  export { BuildControlPlaneMcpConfigOptions as $, InteractivePromptCommand as A, InteractiveStopCommand as B, splitInlineProfileFileMounts as C, SandboxOperationFailedError as D, SandboxOperation as E, InteractiveSessionIncarnationId as F, InteractiveTerminalFrameLog as G, RespondToPermissionOptions as H, InteractiveSessionInfo as I, createInteractiveTerminalSession as J, InteractiveTerminalMetadata as K, InteractiveSessionRef as L, InteractiveSessionHandle as M, InteractiveSessionHandleOptions as N, AgentInteractiveTerminalSession$1 as O, InteractiveSessionHost as P, SandboxInteractionResult as Q, InteractiveSessionStartOptions as R, materializeProfileFileMounts as S, validateDeferredProfileFileMounts as T, agentInteractiveSessionPromptRequestDigest as U, InterruptResult as V, InteractiveTerminalCapture as W, SandboxInteractionConflict as X, SandboxInteractionCommandResult as Y, SandboxInteractionResolution as Z, ProfileFileDeliveryReport as _, WorkspaceImagePublishResult as a, SandboxMcpServerEntry as at, SplitInlineProfileFileMountsResult as b, TraceExportResult as c, exportTraceBundle as d, BuildSandboxMcpConfigOptions as et, otelTraceIdForTangleTrace as f, SandboxSession as g, RawEvidenceExport as h, WorkspaceImagePublishRequestOptions as i, SandboxMcpEndpoint as it, InteractiveSessionControlClaim as j, InteractiveControlClaimRequest as k, TraceExportSink as l, SandboxTaskSession as m, SandboxInstance as n, SANDBOX_MCP_SERVER_NAME as nt, WorkspaceImages as o, buildControlPlaneMcpConfig as ot, toOtelJson as p, createInteractiveTerminalCapture as q, WorkspaceImagePublishInput as r, SandboxMcpConfig as rt, TraceExportFormat as s, buildSandboxMcpConfig as st, ForkAcknowledgement as t, CONTROL_PLANE_MCP_SERVER_NAME as tt, buildTraceExportPayload as u, MaterializeProfileFileMountsOptions as v, splitInlineProfileSkills as w, SplitInlineProfileSkillsResult as x, MaterializeProfileFileMountsResult as y, InteractiveSessionStartResult as z };
@@ -1,12 +1,12 @@
1
1
  import { r as backendTypeSchema } from "./backend-types-D6bYbvMB.js";
2
- import { A as normalizeRuntimeBackendConfig, C as encodePromptForWire, D as assertCurrentBackendType, E as applyRequestedModel, F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, P as withoutRuntimeSecrets, S as validateAcceptedDispatchRunRef, T as parseSSEStream, _ as mintTraceId, a as terminalUpgradeHeadersSupported, b as sessionHeaders, d as isRetryableCredentialRefusal, f as normalizeSessionInfo, g as isTraceId, h as TRACE_ID_HEADER, i as TerminalStreamError, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as requestScopedToken, m as waitForRetryAfter, n as InteractiveSessionController, p as sessionMessageRequestBody, r as TerminalStream, s as assertScopedTokenActive, u as SandboxRuntimeApi, v as resolveTraceId, w as encodeTextForWire, x as resolveDispatchRunIdentity, y as appendSessionIdQuery } from "./interactive-controller-BFbCkMq4.js";
3
- import { S as readResponseJson, _ as StreamInterruptedError, b as parseErrorResponse, f as QuotaError, g as StateError, h as ServerError, i as EdgeNotReadyError, l as NetworkError, m as SandboxError, r as CapabilityError, t as AuthError, u as NotFoundError, v as TimeoutError, x as parseResponseError, y as ValidationError } from "./errors-C8YcR1BL.js";
2
+ import { A as normalizeRuntimeBackendConfig, C as encodePromptForWire, D as assertCurrentBackendType, E as applyRequestedModel, F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, P as withoutRuntimeSecrets, S as validateAcceptedDispatchRunRef, T as parseSSEStream, _ as mintTraceId, a as terminalUpgradeHeadersSupported, b as sessionHeaders, d as isRetryableCredentialRefusal, f as normalizeSessionInfo, g as isTraceId, h as TRACE_ID_HEADER, i as TerminalStreamError, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as requestScopedToken, m as waitForRetryAfter, n as InteractiveSessionController, p as sessionMessageRequestBody, r as TerminalStream, s as assertScopedTokenActive, u as SandboxRuntimeApi, v as resolveTraceId, w as encodeTextForWire, x as resolveDispatchRunIdentity, y as appendSessionIdQuery } from "./interactive-controller-CJ24g8Va.js";
3
+ import { C as readResponseJson, S as parseResponseError, _ as StateError, b as ValidationError, d as NotFoundError, g as ServerError, h as SandboxError, i as EdgeNotReadyError, p as QuotaError, r as CapabilityError, t as AuthError, u as NetworkError, v as StreamInterruptedError, x as parseErrorResponse, y as TimeoutError } from "./errors-DSJBKmGZ.js";
4
4
  import { d as awaitWithAbort, f as combineAbortSignals, g as interactiveSessionStatusResponseSchema, h as interactiveSessionControlValidationResponseSchema, l as createInteractiveControlHolderId, m as interactiveSessionControlReleaseResponseSchema, p as interactiveSessionControlClaimResponseSchema } from "./browser-interactive-control-controller-BJf0P_J4.js";
5
5
  import { SandboxLines } from "./lines.js";
6
- import { l as SANDBOX_PROXY_REQUEST_MAX_BYTES, s as uploadChunked } from "./chunked-upload-CDrLMO8N.js";
6
+ import { l as SANDBOX_PROXY_REQUEST_MAX_BYTES, s as uploadChunked } from "./chunked-upload-DtIvkKNo.js";
7
7
  import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-cSJjPeFF.js";
8
8
  import { z } from "zod";
9
- import { AgentExactRunControlRefSchema, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, InteractionAcknowledgementSchema, InteractionBindingSchema, InteractionRequestSchema, InteractionResponseCommandSchema, InteractionResponseSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, canonicalCandidateDigest, canonicalCandidateJson, exactAgentInteractiveSessionStart, sha256DigestSchema, terminalSessionUsable } from "@tangle-network/agent-interface";
9
+ import { AgentExactRunControlRefSchema, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, InteractionAcknowledgementSchema, InteractionBindingSchema, InteractionRequestSchema, InteractionResponseCommandSchema, InteractionResponseSchema, PlanContinuationSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, canonicalCandidateDigest, canonicalCandidateJson, exactAgentInteractiveSessionStart, sha256DigestSchema, terminalSessionUsable } from "@tangle-network/agent-interface";
10
10
  import { AgentInteractiveSessionControlClaimSchema as AgentInteractiveSessionControlClaimSchema$1, AgentInteractiveSessionPromptAcknowledgementSchema as AgentInteractiveSessionPromptAcknowledgementSchema$1, AgentInteractiveSessionRefSchema as AgentInteractiveSessionRefSchema$1, AgentInteractiveSessionStatusSchema, AgentInteractiveSessionStopAcknowledgementSchema as AgentInteractiveSessionStopAcknowledgementSchema$1 } from "@tangle-network/agent-interface/environment-interactive-control";
11
11
  import { readTokenCostUsd, readTokenUsage } from "@tangle-network/agent-core";
12
12
  import { createHash } from "node:crypto";
@@ -4072,19 +4072,19 @@ var SandboxSession = class SandboxSession {
4072
4072
  async plan() {
4073
4073
  return this.box._currentPlan(this.id);
4074
4074
  }
4075
- /** Approve a durable plan and enqueue its separate execution turn. */
4076
- async approvePlan(planId) {
4075
+ /** Approve a durable plan; caller mode returns admission for fresh preparation. */
4076
+ async approvePlan(planId, options) {
4077
4077
  const id = planId ?? (await this.requireCurrentPlan()).id;
4078
- return this.box._decidePlan(this.id, id, { outcome: "approved" });
4078
+ return this.box._decidePlan(this.id, id, { outcome: "approved" }, options);
4079
4079
  }
4080
- /** Reject a durable plan with required feedback and enqueue a revision turn. */
4081
- async rejectPlan(feedback, planId) {
4080
+ /** Reject a durable plan with feedback; caller mode prepares the revision turn. */
4081
+ async rejectPlan(feedback, planId, options) {
4082
4082
  if (!feedback.trim()) throw new Error("Plan rejection feedback is required");
4083
4083
  const id = planId ?? (await this.requireCurrentPlan()).id;
4084
4084
  return this.box._decidePlan(this.id, id, {
4085
4085
  outcome: "rejected",
4086
4086
  feedback: feedback.trim()
4087
- });
4087
+ }, options);
4088
4088
  }
4089
4089
  async requireCurrentPlan() {
4090
4090
  const plan = await this.plan();
@@ -4153,7 +4153,8 @@ const GPU_LEASE_PROVIDER_NAMES = [
4153
4153
  "gcp",
4154
4154
  "azure",
4155
4155
  "crusoe",
4156
- "fluidstack"
4156
+ "fluidstack",
4157
+ "modal"
4157
4158
  ];
4158
4159
  /** Largest `limit` the denials route accepts; it rejects anything above. */
4159
4160
  const MAX_EGRESS_DENIALS_LIMIT = 50;
@@ -6752,7 +6753,7 @@ var SandboxInstance = class SandboxInstance {
6752
6753
  totalBytes: size,
6753
6754
  percentage: 0
6754
6755
  });
6755
- const { uploadChunkedFromFile } = await import("./chunked-upload-file-BwbqHWUX.js");
6756
+ const { uploadChunkedFromFile } = await import("./chunked-upload-file-DnsHEjg0.js");
6756
6757
  await uploadChunkedFromFile({ fetch: (path, init) => this.runtimeFetch(path, init) }, remotePath, localPath, {
6757
6758
  mode: options?.permissions,
6758
6759
  onProgress: options?.onProgress ? (progress) => {
@@ -7432,6 +7433,7 @@ var SandboxInstance = class SandboxInstance {
7432
7433
  */
7433
7434
  get gpu() {
7434
7435
  return {
7436
+ providers: (options) => this.gpuProviders(options),
7435
7437
  attach: (options) => this.gpuAttach(options),
7436
7438
  list: () => this.gpuList(),
7437
7439
  exec: (leaseId, options) => this.gpuExec(leaseId, options),
@@ -7620,6 +7622,21 @@ var SandboxInstance = class SandboxInstance {
7620
7622
  incompleteReasons: record.incompleteReasons
7621
7623
  };
7622
7624
  }
7625
+ async gpuProviders(options = {}) {
7626
+ const query = new URLSearchParams();
7627
+ const accelerator = options.accelerator;
7628
+ if (accelerator) {
7629
+ query.set("acceleratorKind", accelerator.kind);
7630
+ if (accelerator.count !== void 0) query.set("acceleratorCount", String(accelerator.count));
7631
+ if (accelerator.memoryMB !== void 0) query.set("acceleratorMemoryMB", String(accelerator.memoryMB));
7632
+ }
7633
+ const suffix = query.size > 0 ? `?${query.toString()}` : "";
7634
+ const data = await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/providers${suffix}`));
7635
+ return {
7636
+ usable: data.providers ?? [],
7637
+ statuses: data.statuses ?? []
7638
+ };
7639
+ }
7623
7640
  async gpuAttach(options) {
7624
7641
  return (await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases`, {
7625
7642
  method: "POST",
@@ -9808,21 +9825,25 @@ var SandboxInstance = class SandboxInstance {
9808
9825
  const response = await this.client.fetch(path);
9809
9826
  if (response.status === 404) return null;
9810
9827
  const decoded = await readResponseJson(response);
9811
- if (!decoded.plan) throw new ServerError("Durable plan response is missing plan", 502, {
9828
+ if (!decoded.plan || typeof decoded.plan.sourceTurnId !== "string" || !decoded.plan.sourceTurnId.trim()) throw new ServerError("Durable plan response is missing plan or original sourceTurnId", 502, {
9812
9829
  endpoint: path,
9813
9830
  origin: "control-plane"
9814
9831
  });
9815
9832
  return decoded.plan;
9816
9833
  }
9817
9834
  /** @internal — invoked by SandboxSession.approvePlan()/rejectPlan(). */
9818
- async _decidePlan(sessionId, planId, decision) {
9835
+ async _decidePlan(sessionId, planId, decision, options = {}) {
9819
9836
  const path = `/v1/sandboxes/${encodeURIComponent(this.id)}/agent-sessions/${encodeURIComponent(sessionId)}/plans/${encodeURIComponent(planId)}/decision`;
9820
9837
  const decoded = await readResponseJson(await this.client.fetch(path, {
9821
9838
  method: "POST",
9822
- body: JSON.stringify(decision)
9839
+ body: JSON.stringify({
9840
+ ...decision,
9841
+ ...options
9842
+ })
9823
9843
  }));
9824
9844
  const followUpState = decoded.followUp?.state;
9825
9845
  if (!decoded.plan || typeof decoded.followUp?.turnId !== "string" || ![
9846
+ "awaiting_caller",
9826
9847
  "queued",
9827
9848
  "leased",
9828
9849
  "started",
@@ -9832,10 +9853,33 @@ var SandboxInstance = class SandboxInstance {
9832
9853
  endpoint: path,
9833
9854
  origin: "control-plane"
9834
9855
  });
9856
+ if (options.followUp && decoded.followUp.mode !== "caller") throw new ServerError("Server did not acknowledge caller-owned plan follow-up", 502, {
9857
+ endpoint: path,
9858
+ origin: "control-plane"
9859
+ });
9860
+ let resume;
9861
+ if (decoded.followUp.resume !== void 0) {
9862
+ const candidate = decoded.followUp.resume;
9863
+ const continuation = PlanContinuationSchema.safeParse(candidate?.continuation);
9864
+ if (!continuation.success || typeof candidate.sourceTurnId !== "string" || !candidate.sourceTurnId || typeof candidate.credential !== "string" || !candidate.credential || typeof candidate.callbackUrl !== "string" || !/^https?:\/\//.test(candidate.callbackUrl) || typeof candidate.expiresAt !== "string" || !Number.isFinite(Date.parse(candidate.expiresAt))) throw new ServerError("Caller plan admission response is invalid", 502, {
9865
+ endpoint: path,
9866
+ origin: "control-plane"
9867
+ });
9868
+ resume = {
9869
+ sourceTurnId: candidate.sourceTurnId,
9870
+ continuation: continuation.data,
9871
+ credential: candidate.credential,
9872
+ callbackUrl: candidate.callbackUrl,
9873
+ expiresAt: candidate.expiresAt
9874
+ };
9875
+ }
9835
9876
  return {
9836
9877
  plan: decoded.plan,
9837
9878
  followUp: {
9838
9879
  turnId: decoded.followUp.turnId,
9880
+ ...decoded.followUp.mode === "caller" ? { mode: "caller" } : {},
9881
+ ...typeof decoded.followUp.executionId === "string" ? { executionId: decoded.followUp.executionId } : {},
9882
+ ...resume ? { resume } : {},
9839
9883
  state: followUpState
9840
9884
  },
9841
9885
  idempotent: decoded.idempotent
@@ -1,2 +1,2 @@
1
- import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as ITangleJobsAbi, T as SandboxCreateResponseParamTypes, _ as JOB_SANDBOX_DELETE, a as fetchQuote, b as TangleSandboxClientConfig, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as JOB_SANDBOX_CREATE, h as TangleSandboxClient, 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_CHAIN_ID, w as SandboxCreateParamTypes, x as AgentSandboxBlueprintAbi, y as TANGLE_JOBS_CONTRACT } from "../index-CP9a77KP.js";
1
+ import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as ITangleJobsAbi, T as SandboxCreateResponseParamTypes, _ as JOB_SANDBOX_DELETE, a as fetchQuote, b as TangleSandboxClientConfig, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as JOB_SANDBOX_CREATE, h as TangleSandboxClient, 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_CHAIN_ID, w as SandboxCreateParamTypes, x as AgentSandboxBlueprintAbi, y as TANGLE_JOBS_CONTRACT } from "../index-DRto9Ijb.js";
2
2
  export { AgentSandboxBlueprintAbi, 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, TangleSandboxClient, TangleSandboxClientConfig, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,2 +1,2 @@
1
- import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as JOB_SANDBOX_DELETE, f as TANGLE_CHAIN_ID, g as JsonResponseParamTypes, h as ITangleJobsAbi, i as jobQuoteDigest, l as OperatorSessionError, m as AgentSandboxBlueprintAbi, n as fetchQuote, o as validateQuote, p as TANGLE_JOBS_CONTRACT, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as JOB_SANDBOX_CREATE, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-vyeLQFFg.js";
1
+ import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as JOB_SANDBOX_DELETE, f as TANGLE_CHAIN_ID, g as JsonResponseParamTypes, h as ITangleJobsAbi, i as jobQuoteDigest, l as OperatorSessionError, m as AgentSandboxBlueprintAbi, n as fetchQuote, o as validateQuote, p as TANGLE_JOBS_CONTRACT, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as JOB_SANDBOX_CREATE, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-DHFKq9sn.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, OperatorSession, OperatorSessionError, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,5 +1,5 @@
1
- import { S as readResponseJson } from "./errors-C8YcR1BL.js";
2
- import { n as createSandboxInstanceFromResponse } from "./sandbox-DGoQMthD.js";
1
+ import { C as readResponseJson } from "./errors-DSJBKmGZ.js";
2
+ import { n as createSandboxInstanceFromResponse } from "./sandbox-DzSEprto.js";
3
3
  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-B7_9Hl_z.js";
4
4
  //#region src/tangle/abi.ts
5
5
  /**