@tangle-network/sandbox 0.10.5-develop.20260715163306.7ca6a55 → 0.11.0

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.
@@ -1,6 +1,6 @@
1
- import { D as CodeExecutionOptions, O as CodeExecutionResult, j as CodeResultPart, k as CodeLanguage } from "../types-LNLeU9Ub.js";
2
- import { n as SandboxInstance } from "../sandbox-B9P4tyt4.js";
3
- import { i as SandboxClient } from "../client-CSaBJ8wD.js";
1
+ import { D as CodeExecutionOptions, O as CodeExecutionResult, j as CodeResultPart, k as CodeLanguage } from "../types-C4dFf5eL.js";
2
+ import { n as SandboxInstance } from "../sandbox-BSsCz6nP.js";
3
+ import { i as SandboxClient } from "../client-B2YYIsdw.js";
4
4
  import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
5
5
 
6
6
  //#region src/agent/tools/_specs.d.ts
@@ -1,5 +1,5 @@
1
- import { $n as SandboxFleetDriverCapability, An as ReconcileSandboxFleetsResult, B as CreateSandboxOptions, Cn as PublicTemplateInfo, Ct as FleetPromptDispatchResult, Dn as ReapExpiredSandboxFleetsOptions, En as PublishPublicTemplateVersionOptions, Er as SandboxProfileSummary, F as CreateIntelligenceReportOptions, Gt as IntelligenceReportCompareTo, I as CreateRequestOptions, Jn as SandboxFleetArtifact, Kn as SandboxEnvironment, L as CreateSandboxFleetOptions, On as ReapExpiredSandboxFleetsResult, Qn as SandboxFleetDispatchResponse, Qt as ListSandboxOptions, R as CreateSandboxFleetTokenOptions, St as FleetPromptDispatchOptions, Ti as TokenRefreshHandler, Tn as PublishPublicTemplateOptions, Ut as IntelligenceReport, Wn as SandboxClientConfig, Wt as IntelligenceReportBudget, Xn as SandboxFleetCostEstimate, Yn as SandboxFleetArtifactSpec, Zt as ListSandboxFleetOptions, _ as BatchResult, _n as PromptOptions, _t as FleetDispatchResultBufferOptions, a as AttachSandboxFleetMachineOptions, ar as SandboxFleetMachineRecord, br as SandboxFleetWorkspaceSnapshotResult, bt as FleetExecDispatchResult, ci as SshKeysManager, dr as SandboxFleetToken, fi as SubscriptionInfo, fr as SandboxFleetTraceBundle, g as BatchOptions, gn as PromptInputPart, gr as SandboxFleetUsage, gt as FleetDispatchResultBuffer, hr as SandboxFleetTraceOptions, ht as FleetDispatchCancelResult, ji as UsageInfo, kn as ReconcileSandboxFleetsOptions, lr as SandboxFleetOperationsSummary, m as BatchEvent, nt as ExecOptions, qr as SecretsManager, qt as IntelligenceReportWindow, rt as ExecResult, sr as SandboxFleetManifest, tr as SandboxFleetInfo, v as BatchRunOptions, vn as PromptResult, vr as SandboxFleetWorkspaceReconcileResult, vt as FleetDispatchStreamOptions, wn as PublicTemplateVersionInfo, x as BatchTask, xr as SandboxInfo, xt as FleetMachineId, y as BatchRunRequest, yr as SandboxFleetWorkspaceRestoreResult, yt as FleetExecDispatchOptions, z as CreateSandboxFleetWithCoordinatorOptions } from "./types-LNLeU9Ub.js";
2
- import { a as TraceExportSink, i as TraceExportResult, n as SandboxInstance, t as HttpClient } from "./sandbox-B9P4tyt4.js";
1
+ import { $n as SandboxFleetDispatchResponse, $t as ListSandboxOptions, An as ReconcileSandboxFleetsOptions, B as CreateSandboxOptions, Ct as FleetPromptDispatchOptions, Dn as PublishPublicTemplateVersionOptions, Dr as SandboxProfileSummary, Ei as TokenRefreshHandler, En as PublishPublicTemplateOptions, F as CreateIntelligenceReportOptions, Gn as SandboxClientConfig, Gt as IntelligenceReportBudget, I as CreateRequestOptions, Jr as SecretsManager, Jt as IntelligenceReportWindow, Kt as IntelligenceReportCompareTo, L as CreateSandboxFleetOptions, Mi as UsageInfo, On as ReapExpiredSandboxFleetsOptions, Qt as ListSandboxFleetOptions, R as CreateSandboxFleetTokenOptions, Sr as SandboxInfo, St as FleetMachineId, Tn as PublicTemplateVersionInfo, Wt as IntelligenceReport, Xn as SandboxFleetArtifactSpec, Yn as SandboxFleetArtifact, Zn as SandboxFleetCostEstimate, _ as BatchResult, _n as PromptInputPart, _r as SandboxFleetUsage, _t as FleetDispatchResultBuffer, a as AttachSandboxFleetMachineOptions, br as SandboxFleetWorkspaceRestoreResult, bt as FleetExecDispatchOptions, cr as SandboxFleetManifest, er as SandboxFleetDriverCapability, fr as SandboxFleetToken, g as BatchOptions, gr as SandboxFleetTraceOptions, gt as FleetDispatchCancelResult, it as ExecResult, jn as ReconcileSandboxFleetsResult, kn as ReapExpiredSandboxFleetsResult, li as SshKeysManager, m as BatchEvent, nr as SandboxFleetInfo, or as SandboxFleetMachineRecord, pi as SubscriptionInfo, pr as SandboxFleetTraceBundle, qn as SandboxEnvironment, rt as ExecOptions, ur as SandboxFleetOperationsSummary, v as BatchRunOptions, vn as PromptOptions, vt as FleetDispatchResultBufferOptions, wn as PublicTemplateInfo, wt as FleetPromptDispatchResult, x as BatchTask, xr as SandboxFleetWorkspaceSnapshotResult, xt as FleetExecDispatchResult, y as BatchRunRequest, yn as PromptResult, yr as SandboxFleetWorkspaceReconcileResult, yt as FleetDispatchStreamOptions, z as CreateSandboxFleetWithCoordinatorOptions } from "./types-C4dFf5eL.js";
2
+ import { a as TraceExportSink, i as TraceExportResult, n as SandboxInstance, t as HttpClient } from "./sandbox-BSsCz6nP.js";
3
3
 
4
4
  //#region src/lib/sse-parser.d.ts
5
5
  /**
@@ -1,6 +1,6 @@
1
- import { i as SANDBOX_PROXY_REQUEST_MAX_BYTES } from "./runtime-api-DDOueAzd.js";
2
- import { a as NotFoundError, c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, o as PartialFailureError, p as parseErrorResponse, t as AuthError } from "./errors-wd266B9Q.js";
3
- import { d as exportTraceBundle, g as parseSSEStream, h as encodeTextForWire, l as normalizeConnection, m as encodePromptForWire, n as normalizeStartupDiagnostics, t as SandboxInstance } from "./sandbox-C8qQicxF.js";
1
+ import { c as encodeTextForWire, i as SANDBOX_PROXY_REQUEST_MAX_BYTES, o as combineAbortSignals, s as encodePromptForWire } from "./runtime-api-kukaWPtF.js";
2
+ import { a as NotFoundError, c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, o as PartialFailureError, p as parseErrorResponse, t as AuthError } from "./errors-Cbs78OlF.js";
3
+ import { d as exportTraceBundle, l as normalizeConnection, m as parseSSEStream, n as normalizeStartupDiagnostics, t as SandboxInstance } from "./sandbox-r2Lxbw8z.js";
4
4
  //#region src/resources.ts
5
5
  /**
6
6
  * Compute tiers, ordered smallest → largest. Defined HERE (not imported from
@@ -1672,7 +1672,7 @@ var SandboxClient = class {
1672
1672
  }
1673
1673
  const resources = normalizeSandboxResources(options?.resources, options?.driver);
1674
1674
  const postDeadline = AbortSignal.timeout(timeoutMs);
1675
- const postSignal = requestOptions?.signal ? AbortSignal.any([requestOptions.signal, postDeadline]) : postDeadline;
1675
+ const postSignal = requestOptions?.signal ? combineAbortSignals([requestOptions.signal, postDeadline]) : postDeadline;
1676
1676
  const createRequestBody = JSON.stringify({
1677
1677
  name: options?.name,
1678
1678
  ...resolvedEnvironment !== void 0 ? {
@@ -2037,7 +2037,7 @@ var SandboxClient = class {
2037
2037
  graceMs: request.graceMs ?? 0
2038
2038
  });
2039
2039
  const deadline = AbortSignal.timeout(resolvedTimeoutMs + CLIENT_DEADLINE_GRACE_MS);
2040
- const combinedSignal = userSignal ? AbortSignal.any([userSignal, deadline]) : deadline;
2040
+ const combinedSignal = userSignal ? combineAbortSignals([userSignal, deadline]) : deadline;
2041
2041
  let response;
2042
2042
  try {
2043
2043
  response = await globalThis.fetch(url, {
@@ -1,2 +1,2 @@
1
- import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "../collaboration-CcZE2xMl.js";
1
+ import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "../collaboration-DDnuTcZd.js";
2
2
  export { CollaborationClient, CollaborationFileBridge, buildCollaborationDocumentId, normalizeCollaborationPath, parseCollaborationDocumentId };
@@ -1,4 +1,4 @@
1
- import { d as TimeoutError, i as NetworkError, p as parseErrorResponse } from "./errors-wd266B9Q.js";
1
+ import { d as TimeoutError, i as NetworkError, p as parseErrorResponse } from "./errors-Cbs78OlF.js";
2
2
  //#region src/collaboration/client.ts
3
3
  const DEFAULT_TIMEOUT_MS = 3e4;
4
4
  function normalizeBaseUrl(url) {
package/dist/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as CreateSandboxOptions, Mr as SandboxStatus, Wn as SandboxClientConfig, cn as PreviewLinkManager, nn as NetworkConfig, nt as ExecOptions, rt as ExecResult, sn as PreviewLinkInfo, xr as SandboxInfo } from "./types-LNLeU9Ub.js";
2
- import { n as SandboxInstance } from "./sandbox-B9P4tyt4.js";
3
- import { i as SandboxClient } from "./client-CSaBJ8wD.js";
4
- import { a as NotFoundError, c as SandboxError, d as ServerError, f as StateError, i as NetworkError, l as SandboxErrorJson, m as ValidationError, n as CapabilityError, o as PartialFailureError, p as TimeoutError, s as QuotaError, t as AuthError, u as SandboxFailureDetail } from "./errors-CNCz3Ms9.js";
1
+ import { B as CreateSandboxOptions, Gn as SandboxClientConfig, Nr as SandboxStatus, Sr as SandboxInfo, cn as PreviewLinkInfo, it as ExecResult, ln as PreviewLinkManager, rn as NetworkConfig, rt as ExecOptions } from "./types-C4dFf5eL.js";
2
+ import { n as SandboxInstance } from "./sandbox-BSsCz6nP.js";
3
+ import { i as SandboxClient } from "./client-B2YYIsdw.js";
4
+ import { a as NotFoundError, c as SandboxError, d as ServerError, f as StateError, i as NetworkError, l as SandboxErrorJson, m as ValidationError, n as CapabilityError, o as PartialFailureError, p as TimeoutError, s as QuotaError, t as AuthError, u as SandboxFailureDetail } from "./errors-ntvaf0_F.js";
5
5
  export { AuthError, CapabilityError, type CreateSandboxOptions, type ExecOptions, type ExecResult, type NetworkConfig, NetworkError, NotFoundError, PartialFailureError, type PreviewLinkInfo, type PreviewLinkManager, QuotaError, SandboxClient as Sandbox, SandboxClient, type SandboxClientConfig, SandboxError, type SandboxErrorJson, type SandboxFailureDetail, type SandboxInfo, SandboxInstance, type SandboxStatus, ServerError, StateError, TimeoutError, ValidationError };
package/dist/core.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as NotFoundError, c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, n as CapabilityError, o as PartialFailureError, s as QuotaError, t as AuthError, u as StateError } from "./errors-wd266B9Q.js";
2
- import { t as SandboxInstance } from "./sandbox-C8qQicxF.js";
3
- import { n as SandboxClient } from "./client-0Zp62AKL.js";
1
+ import { a as NotFoundError, c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, n as CapabilityError, o as PartialFailureError, s as QuotaError, t as AuthError, u as StateError } from "./errors-Cbs78OlF.js";
2
+ import { t as SandboxInstance } from "./sandbox-r2Lxbw8z.js";
3
+ import { n as SandboxClient } from "./client-C2yRj_dB.js";
4
4
  export { AuthError, CapabilityError, NetworkError, NotFoundError, PartialFailureError, QuotaError, SandboxClient as Sandbox, SandboxClient, SandboxError, SandboxInstance, ServerError, StateError, TimeoutError, ValidationError };
@@ -123,8 +123,8 @@ var StateError = class extends SandboxError {
123
123
  currentState;
124
124
  /** Required state for the operation */
125
125
  requiredState;
126
- constructor(message, currentState, requiredState, metadata) {
127
- super(message, "INVALID_STATE", 409, metadata);
126
+ constructor(message, currentState, requiredState, metadata, code = "INVALID_STATE") {
127
+ super(message, code, 409, metadata);
128
128
  this.name = "StateError";
129
129
  this.currentState = currentState;
130
130
  this.requiredState = requiredState;
@@ -259,7 +259,7 @@ function parseErrorResponse(status, body, context, headers) {
259
259
  case 401: return new AuthError(message, metadata);
260
260
  case 404: return new NotFoundError(data.resourceType || "Resource", data.resourceId || "unknown", metadata);
261
261
  case 408: return new TimeoutError(data.timeoutMs || 3e4, message, metadata);
262
- case 409: return new StateError(message, data.currentState || "unknown", data.requiredState, metadata);
262
+ case 409: return new StateError(message, data.currentState || "unknown", data.requiredState, metadata, code);
263
263
  case 429: return new QuotaError(data.quotaType || "rate_limit", message, data.current, data.limit, metadata);
264
264
  case 501: return new SandboxError(message, code || "NOT_IMPLEMENTED", status, metadata);
265
265
  default:
@@ -100,7 +100,7 @@ declare class StateError extends SandboxError {
100
100
  readonly currentState: string;
101
101
  /** Required state for the operation */
102
102
  readonly requiredState?: string;
103
- constructor(message: string, currentState: string, requiredState?: string, metadata?: SandboxErrorMetadata);
103
+ constructor(message: string, currentState: string, requiredState?: string, metadata?: SandboxErrorMetadata, code?: string);
104
104
  }
105
105
  declare class EgressProxyRecoveryError extends SandboxError {
106
106
  readonly phase: "egress_proxy_recovery";
@@ -1,5 +1,5 @@
1
- import { B as CreateSandboxOptions } from "./types-LNLeU9Ub.js";
2
- import { n as SandboxInstance, t as HttpClient } from "./sandbox-B9P4tyt4.js";
1
+ import { B as CreateSandboxOptions } from "./types-C4dFf5eL.js";
2
+ import { n as SandboxInstance, t as HttpClient } from "./sandbox-BSsCz6nP.js";
3
3
 
4
4
  //#region src/tangle/abi.d.ts
5
5
  /**
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { $ as EgressManager, $i as defineInlineResource, $n as SandboxFleetDriverCapability, $r as SessionForkOptions, $t as McpServerConfig, A as CodeResult, Ai as UploadProgress, An as ReconcileSandboxFleetsResult, Ar as SandboxRuntimeProfile, At as GitStatus, B as CreateSandboxOptions, Bi as AgentProfileConnection, Bn as RolloutTurnPart, Br as SandboxTraceOptions, Bt as HostAgentDriverConfig, C as BatchTaskUsage, Ci as TeePublicKey, Cn as PublicTemplateInfo, Cr as SandboxPermissionsConfig, Di as TurnDriveResult, Dn as ReapExpiredSandboxFleetsOptions, Dr as SandboxResourceUsage, Dt as GitCommit, E as ChunkedUploadResult, Ei as ToolsConfig, En as PublishPublicTemplateVersionOptions, Er as SandboxProfileSummary, Et as GitBranch, F as CreateIntelligenceReportOptions, Fi as WriteManyFile, Fn as RolloutChildResult, Fr as SandboxTerminalManager, Ft as GpuLeaseExecResult, G as DispatchPromptOptions, Gi as AgentProfilePrompt, Gn as SandboxConnection, Gr as SearchOptions, Gt as IntelligenceReportCompareTo, H as CreateTaskSessionOptions, Hi as AgentProfileMcpServer, Hn as SSHCommandDescriptor, Hr as ScopedToken, Ht as InstalledTool, I as CreateRequestOptions, Ii as WriteManyOptions, In as RolloutOptions, Ir as SandboxTerminalRequestOptions, It as GpuLeaseManager, J as DownloadProgress, Ji as AgentProfileValidationIssue, Jn as SandboxFleetArtifact, Jr as SendSessionMessageOptions, K as DispatchedSession, Ki as AgentProfileResourceRef, Kn as SandboxEnvironment, Kr as SecretInfo, Kt as IntelligenceReportSubjectType, L as CreateSandboxFleetOptions, Li as AgentProfile, Ln as RolloutScorer, Lr as SandboxTraceBundle, Lt as GpuLeaseProviderName, M as CommitTaskSessionOptions, Mi as WaitForOptions, Mr as SandboxStatus, Mt as GpuLeaseBilling, N as CompletedTurnResult, Ni as WaitForRolloutOptions, Nr as SandboxTerminalCreateOptions, Nt as GpuLeaseCommandResult, Oi as UpdateUserOptions, On as ReapExpiredSandboxFleetsResult, Or as SandboxResources, Ot as GitConfig, P as CreateGpuLeaseOptions, Pi as WriteFileOptions, Pn as Rollout, Pr as SandboxTerminalInfo, Pt as GpuLeaseExecOptions, Q as DriverType, Qi as defineGitHubResource, Qn as SandboxFleetDispatchResponse, Qr as SessionEventStreamOptions, Qt as ListSandboxOptions, Ri as AgentProfileCapabilities, Rn as RolloutStartResult, Rr as SandboxTraceEvent, Rt as GpuLeaseStatus, S as BatchTaskResult, Si as TeeAttestationResponse, Sn as ProvisionStep, Sr as SandboxIntelligenceEnvelope, St as FleetPromptDispatchOptions, T as ChunkedUploadOptions, Ti as TokenRefreshHandler, Tn as PublishPublicTemplateOptions, Tr as SandboxPortPreviewLink, Tt as GitAuth, U as DeleteOptions, Ui as AgentProfileModelHints, Un as SSHCredentials, Ur as ScopedTokenScope, Ut as IntelligenceReport, V as CreateSessionOptions, Vi as AgentProfileFileMount, Vn as RunCodeOptions, Vr as SandboxUser, Vt as HostAgentRuntimeBackend, W as DirectoryPermission, Wi as AgentProfilePermissionValue, Wn as SandboxClientConfig, Wr as SearchMatch, Wt as IntelligenceReportBudget, X as DriverConfig, Xi as AgentSubagentProfile, Xn as SandboxFleetCostEstimate, Xr as SentSessionMessage, Xt as ListOptions, Y as DriveTurnOptions, Yi as AgentProfileValidationResult, Yn as SandboxFleetArtifactSpec, Yr as SendSessionMessageRequest, Yt as ListMessagesOptions, Z as DriverInfo, Zi as defineAgentProfile, Zn as SandboxFleetDispatchFailureClass, Zr as SessionBackendCredentials, Zt as ListSandboxFleetOptions, _ as BatchResult, _i as TaskSessionFileChange, _n as PromptOptions, _r as SandboxFleetWorkspace, _t as FleetDispatchResultBufferOptions, a as AttachSandboxFleetMachineOptions, ai as SnapshotInfo, an as PermissionLevel, ar as SandboxFleetMachineRecord, at as FileReadBatchOptions, b as BatchSidecarGroup, bi as TeeAttestationOptions, bn as ProvisionResult, br as SandboxFleetWorkspaceSnapshotResult, c as BackendInfo, cn as PreviewLinkManager, cr as SandboxFleetManifestMachine, ct as FileReadResult, d as BackendType, di as StorageConfig, dn as ProcessLogEntry, dr as SandboxFleetToken, dt as FileTreeFile, ea as mergeAgentProfiles, ei as SessionInfo, en as MintScopedTokenOptions, er as SandboxFleetDriverTimings, et as EgressPolicy, f as BatchBackend, fi as SubscriptionInfo, fn as ProcessManager, fr as SandboxFleetTraceBundle, ft as FileTreeOptions, g as BatchOptions, gi as TaskSessionCommitResult, gr as SandboxFleetUsage, gt as FleetDispatchResultBuffer, h as BatchEventDataMap, hi as TaskSessionChanges, hn as ProcessStatus, hr as SandboxFleetTraceOptions, ht as FleetDispatchCancelResult, i as AttachGpuLeaseOptions, ii as SessionStatus, in as NonHostAgentDriverConfig, ir as SandboxFleetMachineMeteredUsage, it as FileInfo, ji as UsageInfo, jn as RenameOptions, jr as SandboxRuntimeProfileList, jt as GpuLease, ki as UploadOptions, kn as ReconcileSandboxFleetsOptions, kr as SandboxRuntimeHealth, kt as GitDiff, l as BackendManager, li as StartupDiagnostics, ln as Process, lr as SandboxFleetOperationsSummary, lt as FileRenameResult, m as BatchEvent, mi as TaskResult, mn as ProcessSpawnOptions, mr as SandboxFleetTraceExport, mt as FileWriteResult, n as AccessPolicyRule, ni as SessionMessage, nn as NetworkConfig, nr as SandboxFleetIntelligenceEnvelope, nt as ExecOptions, o as BackendCapabilities, oi as SnapshotOptions, on as PermissionsManager, or as SandboxFleetMachineSpec, ot as FileReadBatchResult, p as BatchBackendStats, pi as TaskOptions, pn as ProcessSignal, pr as SandboxFleetTraceEvent, pt as FileTreeResult, q as DownloadOptions, qi as AgentProfileResources, qn as SandboxEvent, qr as SecretsManager, qt as IntelligenceReportWindow, r as AddUserOptions, ri as SessionMessageInputPart, rn as NetworkManager, rr as SandboxFleetMachine, rt as ExecResult, s as BackendConfig, si as SnapshotResult, sn as PreviewLinkInfo, sr as SandboxFleetManifest, st as FileReadError, t as AcceleratorKind, ti as SessionListOptions, tn as MkdirOptions, tr as SandboxFleetInfo, tt as EventStreamOptions, u as BackendStatus, ui as StartupOperation, un as ProcessInfo, ur as SandboxFleetPolicy, ut as FileSystem, v as BatchRunOptions, vi as TaskSessionInfo, vn as PromptResult, vr as SandboxFleetWorkspaceReconcileResult, vt as FleetDispatchStreamOptions, w as BranchOptions, wi as TeePublicKeyResponse, wn as PublicTemplateVersionInfo, wr as SandboxPortBinding, wt as GPU_LEASE_PROVIDER_NAMES, x as BatchTask, xi as TeeAttestationReport, xn as ProvisionStatus, xr as SandboxInfo, xt as FleetMachineId, y as BatchRunRequest, yi as TaskSessionProfile, yn as ProvisionEvent, yr as SandboxFleetWorkspaceRestoreResult, yt as FleetExecDispatchOptions, z as CreateSandboxFleetWithCoordinatorOptions, zi as AgentProfileConfidential, zn as RolloutStatus, zr as SandboxTraceExport, zt as GpuType } from "./types-LNLeU9Ub.js";
2
- import { C as SandboxMcpConfig, D as buildSandboxMcpConfig, E as buildControlPlaneMcpConfig, S as SANDBOX_MCP_SERVER_NAME, T as SandboxMcpServerEntry, _ as RespondToPermissionOptions, a as TraceExportSink, b as BuildSandboxMcpConfigOptions, c as otelTraceIdForTangleTrace, d as SandboxSession, f as InteractiveAuthFile, g as InterruptResult, h as InteractiveSessionInfo, i as TraceExportResult, l as toOtelJson, m as InteractiveSessionHost, n as SandboxInstance, o as buildTraceExportPayload, p as InteractiveSessionHandle, r as TraceExportFormat, s as exportTraceBundle, u as SandboxTaskSession, v as StartInteractiveOptions, w as SandboxMcpEndpoint, x as CONTROL_PLANE_MCP_SERVER_NAME, y as BuildControlPlaneMcpConfigOptions } from "./sandbox-B9P4tyt4.js";
3
- import { a as Team, c as SessionBroadcastEvent, d as SandboxFleetClient, f as ParseSSEStreamOptions, i as SandboxClient, l as SessionBroadcastResult, m as parseSSEStream, n as IntelligenceClient, o as TeamInvitation, p as ParsedSSEEvent, r as InviteTeamMemberOptions, s as TeamMember, t as CreateTeamOptions, u as SandboxFleet } from "./client-CSaBJ8wD.js";
1
+ import { $i as defineGitHubResource, $n as SandboxFleetDispatchResponse, $r as SessionEventStreamOptions, $t as ListSandboxOptions, A as CodeResult, Ai as UploadOptions, An as ReconcileSandboxFleetsOptions, Ar as SandboxRuntimeHealth, At as GitDiff, B as CreateSandboxOptions, Bi as AgentProfileConfidential, Bn as RolloutStatus, Br as SandboxTraceExport, Bt as GpuType, C as BatchTaskUsage, Ci as TeeAttestationResponse, Cn as ProvisionStep, Cr as SandboxIntelligenceEnvelope, Ct as FleetPromptDispatchOptions, Di as ToolsConfig, Dn as PublishPublicTemplateVersionOptions, Dr as SandboxProfileSummary, Dt as GitBranch, E as ChunkedUploadResult, Ei as TokenRefreshHandler, En as PublishPublicTemplateOptions, Er as SandboxPortPreviewLink, Et as GitAuth, F as CreateIntelligenceReportOptions, Fi as WriteFileOptions, Fn as Rollout, Fr as SandboxTerminalInfo, Ft as GpuLeaseExecOptions, G as DispatchPromptOptions, Gi as AgentProfilePermissionValue, Gn as SandboxClientConfig, Gr as SearchMatch, Gt as IntelligenceReportBudget, H as CreateTaskSessionOptions, Hi as AgentProfileFileMount, Hn as RunCodeOptions, Hr as SandboxUser, Ht as HostAgentRuntimeBackend, I as CreateRequestOptions, Ii as WriteManyFile, In as RolloutChildResult, Ir as SandboxTerminalManager, It as GpuLeaseExecResult, J as DownloadProgress, Ji as AgentProfileResources, Jn as SandboxEvent, Jr as SecretsManager, Jt as IntelligenceReportWindow, K as DispatchedSession, Ki as AgentProfilePrompt, Kn as SandboxConnection, Kr as SearchOptions, Kt as IntelligenceReportCompareTo, L as CreateSandboxFleetOptions, Li as WriteManyOptions, Ln as RolloutOptions, Lr as SandboxTerminalRequestOptions, Lt as GpuLeaseManager, M as CommitTaskSessionOptions, Mi as UsageInfo, Mn as RenameOptions, Mr as SandboxRuntimeProfileList, Mt as GpuLease, N as CompletedTurnResult, Ni as WaitForOptions, Nr as SandboxStatus, Nt as GpuLeaseBilling, Oi as TurnDriveResult, On as ReapExpiredSandboxFleetsOptions, Or as SandboxResourceUsage, Ot as GitCommit, P as CreateGpuLeaseOptions, Pi as WaitForRolloutOptions, Pr as SandboxTerminalCreateOptions, Pt as GpuLeaseCommandResult, Q as DriverType, Qi as defineAgentProfile, Qn as SandboxFleetDispatchFailureClass, Qr as SessionBackendCredentials, Qt as ListSandboxFleetOptions, Ri as AgentProfile, Rn as RolloutScorer, Rr as SandboxTraceBundle, Rt as GpuLeaseProviderName, S as BatchTaskResult, Si as TeeAttestationReport, Sn as ProvisionStatus, Sr as SandboxInfo, St as FleetMachineId, T as ChunkedUploadOptions, Ti as TeePublicKeyResponse, Tn as PublicTemplateVersionInfo, Tr as SandboxPortBinding, Tt as GPU_LEASE_PROVIDER_NAMES, U as DeleteOptions, Ui as AgentProfileMcpServer, Un as SSHCommandDescriptor, Ur as ScopedToken, Ut as InstalledTool, V as CreateSessionOptions, Vi as AgentProfileConnection, Vn as RolloutTurnPart, Vr as SandboxTraceOptions, Vt as HostAgentDriverConfig, W as DirectoryPermission, Wi as AgentProfileModelHints, Wn as SSHCredentials, Wr as ScopedTokenScope, Wt as IntelligenceReport, X as DriverConfig, Xi as AgentProfileValidationResult, Xn as SandboxFleetArtifactSpec, Xr as SendSessionMessageRequest, Xt as ListMessagesOptions, Y as DriveTurnOptions, Yi as AgentProfileValidationIssue, Yn as SandboxFleetArtifact, Yr as SendSessionMessageOptions, Z as DriverInfo, Zi as AgentSubagentProfile, Zn as SandboxFleetCostEstimate, Zr as SentSessionMessage, Zt as ListOptions, _ as BatchResult, _i as TaskSessionCommitResult, _r as SandboxFleetUsage, _t as FleetDispatchResultBuffer, a as AttachSandboxFleetMachineOptions, ai as SessionStatus, an as NonHostAgentDriverConfig, ar as SandboxFleetMachineMeteredUsage, at as FileInfo, b as BatchSidecarGroup, bi as TaskSessionProfile, bn as ProvisionEvent, br as SandboxFleetWorkspaceRestoreResult, bt as FleetExecDispatchOptions, c as BackendInfo, ci as SnapshotResult, cn as PreviewLinkInfo, cr as SandboxFleetManifest, ct as FileReadError, d as BackendType, di as StartupOperation, dn as ProcessInfo, dr as SandboxFleetPolicy, dt as FileSystem, ea as defineInlineResource, ei as SessionForkOptions, en as McpServerConfig, er as SandboxFleetDriverCapability, et as EgressManager, f as BatchBackend, fi as StorageConfig, fn as ProcessLogEntry, fr as SandboxFleetToken, ft as FileTreeFile, g as BatchOptions, gi as TaskSessionChanges, gn as ProcessStatus, gr as SandboxFleetTraceOptions, gt as FleetDispatchCancelResult, h as BatchEventDataMap, hi as TaskResult, hn as ProcessSpawnOptions, hr as SandboxFleetTraceExport, ht as FileWriteResult, i as AttachGpuLeaseOptions, ii as SessionMessageInputPart, in as NetworkManager, ir as SandboxFleetMachine, it as ExecResult, ji as UploadProgress, jn as ReconcileSandboxFleetsResult, jr as SandboxRuntimeProfile, jt as GitStatus, ki as UpdateUserOptions, kn as ReapExpiredSandboxFleetsResult, kr as SandboxResources, kt as GitConfig, l as BackendManager, ln as PreviewLinkManager, lr as SandboxFleetManifestMachine, lt as FileReadResult, m as BatchEvent, mi as TaskOptions, mn as ProcessSignal, mr as SandboxFleetTraceEvent, mt as FileTreeResult, n as AccessPolicyRule, ni as SessionListOptions, nn as MkdirOptions, nr as SandboxFleetInfo, nt as EventStreamOptions, o as BackendCapabilities, oi as SnapshotInfo, on as PermissionLevel, or as SandboxFleetMachineRecord, ot as FileReadBatchOptions, p as BatchBackendStats, pi as SubscriptionInfo, pn as ProcessManager, pr as SandboxFleetTraceBundle, pt as FileTreeOptions, q as DownloadOptions, qi as AgentProfileResourceRef, qn as SandboxEnvironment, qr as SecretInfo, qt as IntelligenceReportSubjectType, r as AddUserOptions, ri as SessionMessage, rn as NetworkConfig, rr as SandboxFleetIntelligenceEnvelope, rt as ExecOptions, s as BackendConfig, si as SnapshotOptions, sn as PermissionsManager, sr as SandboxFleetMachineSpec, st as FileReadBatchResult, t as AcceleratorKind, ta as mergeAgentProfiles, ti as SessionInfo, tn as MintScopedTokenOptions, tr as SandboxFleetDriverTimings, tt as EgressPolicy, u as BackendStatus, ui as StartupDiagnostics, un as Process, ur as SandboxFleetOperationsSummary, ut as FileRenameResult, v as BatchRunOptions, vi as TaskSessionFileChange, vn as PromptOptions, vr as SandboxFleetWorkspace, vt as FleetDispatchResultBufferOptions, w as BranchOptions, wi as TeePublicKey, wn as PublicTemplateInfo, wr as SandboxPermissionsConfig, x as BatchTask, xi as TeeAttestationOptions, xn as ProvisionResult, xr as SandboxFleetWorkspaceSnapshotResult, y as BatchRunRequest, yi as TaskSessionInfo, yn as PromptResult, yr as SandboxFleetWorkspaceReconcileResult, yt as FleetDispatchStreamOptions, z as CreateSandboxFleetWithCoordinatorOptions, zi as AgentProfileCapabilities, zn as RolloutStartResult, zr as SandboxTraceEvent, zt as GpuLeaseStatus } from "./types-C4dFf5eL.js";
2
+ import { C as SandboxMcpConfig, D as buildSandboxMcpConfig, E as buildControlPlaneMcpConfig, S as SANDBOX_MCP_SERVER_NAME, T as SandboxMcpServerEntry, _ as RespondToPermissionOptions, a as TraceExportSink, b as BuildSandboxMcpConfigOptions, c as otelTraceIdForTangleTrace, d as SandboxSession, f as InteractiveAuthFile, g as InterruptResult, h as InteractiveSessionInfo, i as TraceExportResult, l as toOtelJson, m as InteractiveSessionHost, n as SandboxInstance, o as buildTraceExportPayload, p as InteractiveSessionHandle, r as TraceExportFormat, s as exportTraceBundle, u as SandboxTaskSession, v as StartInteractiveOptions, w as SandboxMcpEndpoint, x as CONTROL_PLANE_MCP_SERVER_NAME, y as BuildControlPlaneMcpConfigOptions } from "./sandbox-BSsCz6nP.js";
3
+ import { a as Team, c as SessionBroadcastEvent, d as SandboxFleetClient, f as ParseSSEStreamOptions, i as SandboxClient, l as SessionBroadcastResult, m as parseSSEStream, n as IntelligenceClient, o as TeamInvitation, p as ParsedSSEEvent, r as InviteTeamMemberOptions, s as TeamMember, t as CreateTeamOptions, u as SandboxFleet } from "./client-B2YYIsdw.js";
4
4
  import { d as AnyTokenPayload, h as IssueCollaborationTokenOptions, m as CollaborationTokenPayload, p as CollaborationAccess } from "./index-CyHojkuA.js";
5
5
  import { _ as CollaborationTransportConfig, a as CollaborationClient, c as CollaborationClientConfig, d as CollaborationDocumentRef, f as CollaborationFileBridgeOptions, g as CollaborationTokenRefreshResponse, h as CollaborationTokenRefreshRequest, i as parseCollaborationDocumentId, l as CollaborationDocumentAdapter, m as CollaborationPermissions, n as buildCollaborationDocumentId, o as CollaborationBootstrapRequest, p as CollaborationFileEvent, r as normalizeCollaborationPath, s as CollaborationBootstrapResponse, t as CollaborationFileBridge, u as CollaborationDocumentChange, v as SaveCollaborationSnapshotRequest, y as SaveCollaborationSnapshotResponse } from "./index-DKzapw-9.js";
6
- import { a as NotFoundError, c as SandboxError, d as ServerError, f as StateError, i as NetworkError, l as SandboxErrorJson, m as ValidationError, n as CapabilityError, o as PartialFailureError, p as TimeoutError, r as EgressProxyRecoveryError, s as QuotaError, t as AuthError, u as SandboxFailureDetail } from "./errors-CNCz3Ms9.js";
7
- import { s as TangleSandboxClientConfig, t as TangleSandboxClient } from "./index-CEZaPvfX.js";
6
+ import { a as NotFoundError, c as SandboxError, d as ServerError, f as StateError, i as NetworkError, l as SandboxErrorJson, m as ValidationError, n as CapabilityError, o as PartialFailureError, p as TimeoutError, r as EgressProxyRecoveryError, s as QuotaError, t as AuthError, u as SandboxFailureDetail } from "./errors-ntvaf0_F.js";
7
+ import { s as TangleSandboxClientConfig, t as TangleSandboxClient } from "./index-V2vjBfHU.js";
8
8
 
9
9
  //#region src/attestation-heartbeat.d.ts
10
10
  interface TeeAttestationHeartbeatSample {
@@ -49,21 +49,15 @@ declare function startTeeAttestationHeartbeat(sandbox: Pick<SandboxInstance, "ge
49
49
  /**
50
50
  * Normalize runtime backend config for the wire format.
51
51
  *
52
- * Callers set `backend.profile` (named string or portable AgentProfile).
53
- * This function generates the native `inlineProfile` shim automatically.
52
+ * Canonical profile objects are already accepted by the sidecar and are
53
+ * forwarded without translation.
54
54
  */
55
55
  declare function normalizeRuntimeBackendConfig(backend: Partial<BackendConfig> | undefined, options?: {
56
56
  model?: string;
57
57
  }): Record<string, unknown> | undefined;
58
58
  /**
59
- * Serialize a portable AgentProfile into the sidecar's canonical inline-profile
60
- * wire shape (validated by inlineProfileSchema in
61
- * apps/sidecar/src/schemas/agent-profile-schema.ts).
62
- *
63
- * Single choke point every product shares: streamPrompt →
64
- * normalizeRuntimeBackendConfig → toBackendProfile. Exported so callers and the
65
- * drift-guard test target one contract — the test parses this output with the
66
- * sidecar's own schema, so any future schema tightening fails here first.
59
+ * @deprecated Canonical profile objects can be sent directly as
60
+ * `backend.profile`; this compatibility export now preserves that object.
67
61
  */
68
62
  declare function serializeForSidecar(profile: Exclude<BackendConfig["profile"], string | undefined>): Record<string, unknown>;
69
63
  //#endregion
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { o as normalizeRuntimeBackendConfig, s as serializeForSidecar } from "./runtime-api-DDOueAzd.js";
2
- import { a as NotFoundError, c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, n as CapabilityError, o as PartialFailureError, r as EgressProxyRecoveryError, s as QuotaError, t as AuthError, u as StateError } from "./errors-wd266B9Q.js";
3
- import { a as InteractiveSessionHandle, c as getSandboxEventText, d as exportTraceBundle, f as otelTraceIdForTangleTrace, g as parseSSEStream, i as SandboxSession, o as applySandboxEventText, p as toOtelJson, r as SandboxTaskSession, s as collectAgentResponseText, t as SandboxInstance, u as buildTraceExportPayload } from "./sandbox-C8qQicxF.js";
4
- import { a as validateDeferredProfileFileMounts, c as DEFAULT_SANDBOX_SIZE, d as resolveSandboxResources, f as sandboxResourcesForSize, i as splitInlineProfileFileMounts, l as SANDBOX_SIZE_PRESETS, n as SandboxClient, o as SandboxFleet, r as materializeProfileFileMounts, s as SandboxFleetClient, t as IntelligenceClient, u as SANDBOX_SIZE_PRESET_NAMES } from "./client-0Zp62AKL.js";
5
- import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "./collaboration-CcZE2xMl.js";
6
- import { t as TangleSandboxClient } from "./tangle-Bx0V6Nt5.js";
1
+ import { l as normalizeRuntimeBackendConfig, u as serializeForSidecar } from "./runtime-api-kukaWPtF.js";
2
+ import { a as NotFoundError, c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, n as CapabilityError, o as PartialFailureError, r as EgressProxyRecoveryError, s as QuotaError, t as AuthError, u as StateError } from "./errors-Cbs78OlF.js";
3
+ import { a as InteractiveSessionHandle, c as getSandboxEventText, d as exportTraceBundle, f as otelTraceIdForTangleTrace, i as SandboxSession, m as parseSSEStream, o as applySandboxEventText, p as toOtelJson, r as SandboxTaskSession, s as collectAgentResponseText, t as SandboxInstance, u as buildTraceExportPayload } from "./sandbox-r2Lxbw8z.js";
4
+ import { a as validateDeferredProfileFileMounts, c as DEFAULT_SANDBOX_SIZE, d as resolveSandboxResources, f as sandboxResourcesForSize, i as splitInlineProfileFileMounts, l as SANDBOX_SIZE_PRESETS, n as SandboxClient, o as SandboxFleet, r as materializeProfileFileMounts, s as SandboxFleetClient, t as IntelligenceClient, u as SANDBOX_SIZE_PRESET_NAMES } from "./client-C2yRj_dB.js";
5
+ import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "./collaboration-DDnuTcZd.js";
6
+ import { t as TangleSandboxClient } from "./tangle-051CtV2b.js";
7
7
  import { defineAgentProfile, defineGitHubResource, defineInlineResource, mergeAgentProfiles } from "@tangle-network/agent-interface";
8
8
  //#region src/confidential.ts
9
9
  function generateAttestationNonce(bytes = 32) {
@@ -1237,11 +1237,10 @@ function buildSandboxBackend(options) {
1237
1237
  network: "allow",
1238
1238
  mcp: "allow"
1239
1239
  },
1240
- mcp: { tangle_web_search: {
1240
+ mcp: { tangle_web_search: searchProvider === "off" ? { enabled: false } : {
1241
1241
  transport: "http",
1242
1242
  url: options.config.mcp.streamable_http_url,
1243
- headers: options.config.mcp.headers,
1244
- enabled: searchProvider !== "off"
1243
+ headers: options.config.mcp.headers
1245
1244
  } },
1246
1245
  metadata: {
1247
1246
  tangleRouterSearchProvider: searchProvider,
@@ -1,4 +1,4 @@
1
- import { d as TimeoutError, i as NetworkError, p as parseErrorResponse } from "../errors-wd266B9Q.js";
1
+ import { d as TimeoutError, i as NetworkError, p as parseErrorResponse } from "../errors-Cbs78OlF.js";
2
2
  //#region src/intelligence/index.ts
3
3
  /**
4
4
  * `@tangle-network/sandbox/intelligence` — browser-safe typed client for the
@@ -1,4 +1,4 @@
1
- import { c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, p as parseErrorResponse, s as QuotaError } from "./errors-wd266B9Q.js";
1
+ import { c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, p as parseErrorResponse, s as QuotaError } from "./errors-Cbs78OlF.js";
2
2
  //#region src/backend-config.ts
3
3
  const LEGACY_QUESTION_ALIAS_KEY = ["question", "Channel"].join("");
4
4
  function parseModelString(model) {
@@ -12,24 +12,18 @@ function parseModelString(model) {
12
12
  /**
13
13
  * Normalize runtime backend config for the wire format.
14
14
  *
15
- * Callers set `backend.profile` (named string or portable AgentProfile).
16
- * This function generates the native `inlineProfile` shim automatically.
15
+ * Canonical profile objects are already accepted by the sidecar and are
16
+ * forwarded without translation.
17
17
  */
18
18
  function normalizeRuntimeBackendConfig(backend, options = {}) {
19
19
  if (!backend && !options.model) return void 0;
20
20
  if (backend && LEGACY_QUESTION_ALIAS_KEY in backend) throw new Error(`[sandbox-sdk] backend.${LEGACY_QUESTION_ALIAS_KEY} was removed. Use backend.interactions.question instead.`);
21
- const portableProfile = backend?.profile && typeof backend.profile !== "string" ? backend.profile : void 0;
22
- const inlineProfile = portableProfile ? toBackendProfile(portableProfile) : void 0;
23
21
  const callerInlineProfile = backend?.inlineProfile;
24
- if (callerInlineProfile && !inlineProfile) console.warn("[sandbox-sdk] backend.inlineProfile is deprecated. Use backend.profile (AgentPortableProfile) instead.");
25
- if (inlineProfile && portableProfile) {
26
- const reasoningEffort = portableProfile.model?.reasoningEffort ?? portableProfile.extensions?.[backend?.type ?? ""]?.reasoningEffort;
27
- if (typeof reasoningEffort === "string" && reasoningEffort !== "auto" && reasoningEffort !== "none") inlineProfile.reasoningEffort = reasoningEffort;
28
- }
22
+ if (callerInlineProfile !== void 0) console.warn("[sandbox-sdk] backend.inlineProfile is deprecated. Use backend.profile (AgentProfile) instead.");
29
23
  return {
30
24
  ...backend?.type ? { type: backend.type } : {},
31
- ...typeof backend?.profile === "string" ? { profile: backend.profile } : {},
32
- ...inlineProfile ? { inlineProfile } : callerInlineProfile ? { inlineProfile: callerInlineProfile } : {},
25
+ ...backend?.profile !== void 0 ? { profile: backend.profile } : {},
26
+ ...callerInlineProfile !== void 0 ? { inlineProfile: callerInlineProfile } : {},
33
27
  ...backend?.model ? { model: backend.model } : options.model ? { model: parseModelString(options.model) } : {},
34
28
  ...backend?.server ? { server: backend.server } : {},
35
29
  ...backend?.interactions !== void 0 ? { interactions: backend.interactions } : {},
@@ -37,120 +31,45 @@ function normalizeRuntimeBackendConfig(backend, options = {}) {
37
31
  };
38
32
  }
39
33
  /**
40
- * Permission keys the sidecar's strict `permission` schema accepts
41
- * (apps/sidecar/src/schemas/agent-profile-schema.ts permissionConfigSchema).
42
- * Any other portable-permission key is a per-tool gate, not a permission, and
43
- * is routed into `tools` instead of passed through — the sidecar's `.strict()`
44
- * schema rejects unknown permission keys with `unrecognized_keys`.
45
- *
46
- * Name must not carry an UPPERCASE `SIDECAR_`/`ORCHESTRATOR_`-style prefix:
47
- * obfuscate.sh runs `--rename-globals false`, so a module-global identifier
48
- * ships verbatim in dist/, and verify-dist.sh bans those prefixes as
49
- * closed-source leaks.
34
+ * @deprecated Canonical profile objects can be sent directly as
35
+ * `backend.profile`; this compatibility export now preserves that object.
50
36
  */
51
- const CANONICAL_PERMISSION_KEYS = new Set([
52
- "edit",
53
- "bash",
54
- "webfetch",
55
- "mcp",
56
- "doom_loop",
57
- "external_directory"
58
- ]);
59
- function hasAnyProfileResource(resources) {
60
- return !!(resources.files?.length || resources.tools?.length || resources.skills?.length || resources.agents?.length || resources.commands?.length || resources.instructions);
61
- }
62
- function validateProfileResources(profile) {
63
- if (profile.resources !== void 0 && (profile.resources === null || typeof profile.resources !== "object" || Array.isArray(profile.resources))) throw new Error("backend.profile.resources must be an object when provided");
64
- if (profile.resources?.plugins?.length) throw new Error("backend.profile.resources.plugins is not supported by the sandbox SDK profile contract; use backend-specific provider profiles for OpenCode plugin resources");
37
+ function serializeForSidecar(profile) {
38
+ return profile;
65
39
  }
66
- function toBackendProfile(profile) {
67
- validateProfileResources(profile);
68
- const permission = {};
69
- const derivedTools = {};
70
- for (const [rawKey, value] of Object.entries(profile.permissions ?? {})) {
71
- const key = rawKey === "network" ? "webfetch" : rawKey;
72
- if (CANONICAL_PERMISSION_KEYS.has(key)) permission[key] = value;
73
- else if (typeof value === "string") derivedTools[key] = value !== "deny";
74
- else console.warn(`[sandbox-sdk] dropping unsupported permission key "${rawKey}": not a canonical sidecar permission and not a string tool gate`);
75
- }
76
- const tools = {
77
- ...derivedTools,
78
- ...profile.tools ?? {}
79
- };
80
- const mcp = profile.mcp ? Object.fromEntries(Object.entries(profile.mcp).map(([name, config]) => {
81
- const c = config;
82
- const transport = c.transport;
83
- const command = c.command;
84
- const hasCommand = Array.isArray(command) ? command.length > 0 : typeof command === "string" && command.trim().length > 0;
85
- const isRemote = transport === "http" || transport === "sse" || typeof c.url === "string" && !hasCommand;
86
- const enabled = c.enabled;
87
- const timeout = c.timeout;
88
- if (isRemote) return [name, {
89
- type: "remote",
90
- url: c.url,
91
- ...c.headers ? { headers: c.headers } : {},
92
- ...enabled !== void 0 ? { enabled } : {},
93
- ...timeout !== void 0 ? { timeout } : {}
94
- }];
95
- return [name, {
96
- type: "local",
97
- command: [...Array.isArray(command) ? command : typeof command === "string" ? command.trim().split(/\s+/).filter(Boolean) : [], ...c.args ?? []],
98
- ...c.env ? { environment: c.env } : {},
99
- ...enabled !== void 0 ? { enabled } : {},
100
- ...timeout !== void 0 ? { timeout } : {}
101
- }];
102
- })) : void 0;
103
- const openCodeExtension = profile.extensions?.opencode;
104
- const plugins = openCodeExtension?.plugins;
105
- if (plugins !== void 0 && (!Array.isArray(plugins) || plugins.some((plugin) => typeof plugin !== "string" || !plugin.trim()))) throw new Error("backend.profile.extensions.opencode.plugins must be an array of non-empty package names");
106
- const commands = openCodeExtension?.commands;
107
- if (commands !== void 0 && (commands === null || typeof commands !== "object" || Array.isArray(commands))) throw new Error("backend.profile.extensions.opencode.commands must be an object");
108
- const profileExtends = openCodeExtension?.extends;
109
- if (profileExtends !== void 0 && typeof profileExtends !== "string" && (!Array.isArray(profileExtends) || profileExtends.some((entry) => typeof entry !== "string" || !entry.trim()))) throw new Error("backend.profile.extensions.opencode.extends must be a profile name or array of profile names");
110
- const agents = profile.subagents ? Object.fromEntries(Object.entries(profile.subagents).map(([name, subagent]) => [name, {
111
- description: subagent.description,
112
- prompt: subagent.prompt,
113
- model: subagent.model,
114
- tools: subagent.tools,
115
- permission: subagent.permissions,
116
- maxSteps: subagent.maxSteps,
117
- ...subagent.metadata ?? {}
118
- }])) : void 0;
119
- return {
120
- name: profile.name,
121
- description: profile.description,
122
- version: profile.version,
123
- tags: profile.tags,
124
- ...profileExtends ? { extends: profileExtends } : {},
125
- model: profile.model?.default,
126
- small_model: profile.model?.small,
127
- ...profile.prompt?.systemPrompt ? { systemPrompt: profile.prompt.systemPrompt } : {},
128
- ...Object.keys(tools).length > 0 ? { tools } : {},
129
- ...profile.prompt?.instructions?.length ? { instructions: profile.prompt.instructions } : {},
130
- ...Object.keys(permission).length > 0 ? { permission } : {},
131
- ...mcp ? { mcp } : {},
132
- ...profile.connections?.length ? { connections: profile.connections } : {},
133
- ...agents ? { agent: agents } : {},
134
- ...profile.resources && hasAnyProfileResource(profile.resources) ? { resources: profile.resources } : {},
135
- ...profile.hooks ? { hooks: profile.hooks } : {},
136
- ...profile.modes ? { modes: profile.modes } : {},
137
- ...commands ? { command: commands } : {},
138
- ...plugins?.length ? { plugin: plugins } : {},
139
- ...profile.extensions ? { extensions: profile.extensions } : {}
140
- };
40
+ //#endregion
41
+ //#region src/lib/wire-encoding.ts
42
+ /**
43
+ * Encode a prompt text part for the wire. Server decodes at the route
44
+ * boundary; the LLM only ever sees the original UTF-8. Done
45
+ * unconditionally because readable bodies false-positive on ingress WAF
46
+ * rules that pattern-match shell-injection-shaped substrings (which
47
+ * legitimate prompts routinely contain e.g. Step-0 dev-server
48
+ * bootstrap).
49
+ */
50
+ function encodeTextForWire(text) {
51
+ if (typeof Buffer !== "undefined") return Buffer.from(text, "utf8").toString("base64");
52
+ if (typeof btoa === "function") return btoa(encodeURIComponent(text).replace(/%([0-9A-F]{2})/g, (_, h) => String.fromCharCode(Number.parseInt(h, 16))));
53
+ throw new Error("encodeTextForWire: no base64 encoder available (Buffer and btoa both undefined)");
141
54
  }
142
55
  /**
143
- * Serialize a portable AgentProfile into the sidecar's canonical inline-profile
144
- * wire shape (validated by inlineProfileSchema in
145
- * apps/sidecar/src/schemas/agent-profile-schema.ts).
146
- *
147
- * Single choke point every product shares: streamPrompt →
148
- * normalizeRuntimeBackendConfig → toBackendProfile. Exported so callers and the
149
- * drift-guard test target one contract — the test parses this output with the
150
- * sidecar's own schema, so any future schema tightening fails here first.
56
+ * Convert a caller-supplied prompt (string or parts array) into the
57
+ * wire-format parts array. Every text part is base64-encoded; non-text
58
+ * parts pass through. A bare string is wrapped in a single text part.
151
59
  */
152
- function serializeForSidecar(profile) {
153
- return toBackendProfile(profile);
60
+ function encodePromptForWire(message) {
61
+ return (typeof message === "string" ? [{
62
+ type: "text",
63
+ text: message
64
+ }] : message).map((part) => part.type === "text" ? {
65
+ type: "text",
66
+ text: encodeTextForWire(part.text)
67
+ } : part);
68
+ }
69
+ //#endregion
70
+ //#region src/lib/abort-signal.ts
71
+ function combineAbortSignals(signals) {
72
+ return AbortSignal.any(signals);
154
73
  }
155
74
  //#endregion
156
75
  //#region ../../../packages/runtime-contracts/dist/file-limits.js
@@ -646,14 +565,17 @@ var SandboxRuntimeApi = class {
646
565
  if (options.credentials?.apiKey) headers.set("X-Backend-Api-Key", options.credentials.apiKey);
647
566
  if (options.credentials?.baseUrl) headers.set("X-Backend-Base-Url", options.credentials.baseUrl);
648
567
  const timeoutSignal = options.timeoutMs !== void 0 ? AbortSignal.timeout(options.timeoutMs) : void 0;
649
- const signal = options.signal && timeoutSignal ? AbortSignal.any([options.signal, timeoutSignal]) : options.signal ?? timeoutSignal;
568
+ const signal = options.signal && timeoutSignal ? combineAbortSignals([options.signal, timeoutSignal]) : options.signal ?? timeoutSignal;
650
569
  return this.json(`/agents/sessions/${encodeURIComponent(id)}/messages`, {
651
570
  method: "POST",
652
571
  headers,
653
572
  signal,
654
573
  body: JSON.stringify({
655
574
  ...request.messageId !== void 0 ? { messageID: request.messageId } : {},
656
- parts: request.parts,
575
+ parts: request.parts.map((part) => part.type === "text" ? {
576
+ ...part,
577
+ text: encodeTextForWire(part.text)
578
+ } : part),
657
579
  ...request.system !== void 0 ? { system: request.system } : {},
658
580
  ...request.agent !== void 0 ? { agent: request.agent } : {},
659
581
  ...request.model !== void 0 ? { model: {
@@ -753,4 +675,4 @@ function normalizeSessionInfo(raw) {
753
675
  };
754
676
  }
755
677
  //#endregion
756
- export { FILE_DECODED_WRITE_MAX_BYTES as a, SANDBOX_PROXY_REQUEST_MAX_BYTES as i, normalizeSessionInfo as n, normalizeRuntimeBackendConfig as o, uploadChunked as r, serializeForSidecar as s, SandboxRuntimeApi as t };
678
+ export { FILE_DECODED_WRITE_MAX_BYTES as a, encodeTextForWire as c, SANDBOX_PROXY_REQUEST_MAX_BYTES as i, normalizeRuntimeBackendConfig as l, normalizeSessionInfo as n, combineAbortSignals as o, uploadChunked as r, encodePromptForWire as s, SandboxRuntimeApi as t, serializeForSidecar as u };
package/dist/runtime.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Ai as UploadProgress, E as ChunkedUploadResult, Fr as SandboxTerminalManager, H as CreateTaskSessionOptions, Ir as SandboxTerminalRequestOptions, Jr as SendSessionMessageOptions, M as CommitTaskSessionOptions, Nr as SandboxTerminalCreateOptions, Pi as WriteFileOptions, Pr as SandboxTerminalInfo, T as ChunkedUploadOptions, V as CreateSessionOptions, Xr as SentSessionMessage, Yr as SendSessionMessageRequest, Yt as ListMessagesOptions, at as FileReadBatchOptions, ei as SessionInfo, ft as FileTreeOptions, gi as TaskSessionCommitResult, hi as TaskSessionChanges, jn as RenameOptions, jr as SandboxRuntimeProfileList, kr as SandboxRuntimeHealth, lt as FileRenameResult, mt as FileWriteResult, ni as SessionMessage, ot as FileReadBatchResult, pt as FileTreeResult, vi as TaskSessionInfo, wr as SandboxPortBinding } from "./types-LNLeU9Ub.js";
2
- import { a as NotFoundError, c as SandboxError, d as ServerError, f as StateError, i as NetworkError, l as SandboxErrorJson, m as ValidationError, n as CapabilityError, o as PartialFailureError, p as TimeoutError, s as QuotaError, t as AuthError, u as SandboxFailureDetail } from "./errors-CNCz3Ms9.js";
1
+ import { Ar as SandboxRuntimeHealth, E as ChunkedUploadResult, Fi as WriteFileOptions, Fr as SandboxTerminalInfo, H as CreateTaskSessionOptions, Ir as SandboxTerminalManager, Lr as SandboxTerminalRequestOptions, M as CommitTaskSessionOptions, Mn as RenameOptions, Mr as SandboxRuntimeProfileList, Pr as SandboxTerminalCreateOptions, T as ChunkedUploadOptions, Tr as SandboxPortBinding, V as CreateSessionOptions, Xr as SendSessionMessageRequest, Xt as ListMessagesOptions, Yr as SendSessionMessageOptions, Zr as SentSessionMessage, _i as TaskSessionCommitResult, gi as TaskSessionChanges, ht as FileWriteResult, ji as UploadProgress, mt as FileTreeResult, ot as FileReadBatchOptions, pt as FileTreeOptions, ri as SessionMessage, st as FileReadBatchResult, ti as SessionInfo, ut as FileRenameResult, yi as TaskSessionInfo } from "./types-C4dFf5eL.js";
2
+ import { a as NotFoundError, c as SandboxError, d as ServerError, f as StateError, i as NetworkError, l as SandboxErrorJson, m as ValidationError, n as CapabilityError, o as PartialFailureError, p as TimeoutError, s as QuotaError, t as AuthError, u as SandboxFailureDetail } from "./errors-ntvaf0_F.js";
3
3
 
4
4
  //#region src/lib/chunked-upload.d.ts
5
5
  /** The transport a caller wires this module to — {@link SandboxInstance.runtimeFetch}
package/dist/runtime.js CHANGED
@@ -1,5 +1,5 @@
1
- import { r as uploadChunked, t as SandboxRuntimeApi } from "./runtime-api-DDOueAzd.js";
2
- import { a as NotFoundError, c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, n as CapabilityError, o as PartialFailureError, s as QuotaError, t as AuthError, u as StateError } from "./errors-wd266B9Q.js";
1
+ import { o as combineAbortSignals, r as uploadChunked, t as SandboxRuntimeApi } from "./runtime-api-kukaWPtF.js";
2
+ import { a as NotFoundError, c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, n as CapabilityError, o as PartialFailureError, s as QuotaError, t as AuthError, u as StateError } from "./errors-Cbs78OlF.js";
3
3
  //#region src/runtime-client.ts
4
4
  const DEFAULT_RUNTIME_TIMEOUT_MS = 3e4;
5
5
  function requireToken(token) {
@@ -49,7 +49,7 @@ var SandboxRuntimeClient = class extends SandboxRuntimeApi {
49
49
  const isFormData = typeof FormData !== "undefined" && init.body instanceof FormData;
50
50
  if (init.body !== void 0 && !isFormData && !headers.has("Content-Type")) headers.set("Content-Type", "application/json");
51
51
  const timeoutSignal = AbortSignal.timeout(timeoutMs);
52
- const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
52
+ const signal = init.signal ? combineAbortSignals([init.signal, timeoutSignal]) : timeoutSignal;
53
53
  try {
54
54
  return await fetchImpl(`${baseUrl}${path}`, {
55
55
  ...init,
@@ -1,4 +1,4 @@
1
- import { $ as EgressManager, $r as SessionForkOptions, At as GitStatus, Br as SandboxTraceOptions, D as CodeExecutionOptions, Di as TurnDriveResult, Dr as SandboxResourceUsage, Dt as GitCommit, Et as GitBranch, Fi as WriteManyFile, Fr as SandboxTerminalManager, G as DispatchPromptOptions, Gn as SandboxConnection, Gr as SearchOptions, Gt as IntelligenceReportCompareTo, H as CreateTaskSessionOptions, Hn as SSHCommandDescriptor, Hr as ScopedToken, Ht as InstalledTool, Ii as WriteManyOptions, In as RolloutOptions, It as GpuLeaseManager, Jr as SendSessionMessageOptions, Jt as JsonValue, K as DispatchedSession, Lr as SandboxTraceBundle, M as CommitTaskSessionOptions, Mi as WaitForOptions, Mn as RestoreSnapshotOptions, Mr as SandboxStatus, N as CompletedTurnResult, Ni as WaitForRolloutOptions, Nn as ResumeOptions, O as CodeExecutionResult, Pi as WriteFileOptions, Pn as Rollout, Qr as SessionEventStreamOptions, Rn as RolloutStartResult, Si as TeeAttestationResponse, Un as SSHCredentials, Ut as IntelligenceReport, V as CreateSessionOptions, Wr as SearchMatch, Wt as IntelligenceReportBudget, Xr as SentSessionMessage, Y as DriveTurnOptions, Yr as SendSessionMessageRequest, Yt as ListMessagesOptions, Z as DriverInfo, _n as PromptOptions, ai as SnapshotInfo, bi as TeeAttestationOptions, bn as ProvisionResult, cn as PreviewLinkManager, ei as SessionInfo, en as MintScopedTokenOptions, fn as ProcessManager, fr as SandboxFleetTraceBundle, gi as TaskSessionCommitResult, gn as PromptInputPart, hi as TaskSessionChanges, jr as SandboxRuntimeProfileList, jt as GpuLease, k as CodeLanguage, kr as SandboxRuntimeHealth, kt as GitDiff, l as BackendManager, li as StartupDiagnostics, mi as TaskResult, mt as FileWriteResult, ni as SessionMessage, nt as ExecOptions, oi as SnapshotOptions, on as PermissionsManager, pi as TaskOptions, qn as SandboxEvent, qt as IntelligenceReportWindow, rn as NetworkManager, rt as ExecResult, s as BackendConfig, si as SnapshotResult, ti as SessionListOptions, tt as EventStreamOptions, ut as FileSystem, vi as TaskSessionInfo, vn as PromptResult, w as BranchOptions, wi as TeePublicKeyResponse, wr as SandboxPortBinding, xr as SandboxInfo, yn as ProvisionEvent } from "./types-LNLeU9Ub.js";
1
+ import { $ as DurablePlan, $r as SessionEventStreamOptions, Ar as SandboxRuntimeHealth, At as GitDiff, Ci as TeeAttestationResponse, D as CodeExecutionOptions, Dt as GitBranch, Fi as WriteFileOptions, Fn as Rollout, G as DispatchPromptOptions, Gr as SearchMatch, Gt as IntelligenceReportBudget, H as CreateTaskSessionOptions, Ii as WriteManyFile, Ir as SandboxTerminalManager, Jn as SandboxEvent, Jt as IntelligenceReportWindow, K as DispatchedSession, Kn as SandboxConnection, Kr as SearchOptions, Kt as IntelligenceReportCompareTo, Li as WriteManyOptions, Ln as RolloutOptions, Lt as GpuLeaseManager, M as CommitTaskSessionOptions, Mr as SandboxRuntimeProfileList, Mt as GpuLease, N as CompletedTurnResult, Ni as WaitForOptions, Nn as RestoreSnapshotOptions, Nr as SandboxStatus, O as CodeExecutionResult, Oi as TurnDriveResult, Or as SandboxResourceUsage, Ot as GitCommit, Pi as WaitForRolloutOptions, Pn as ResumeOptions, Rr as SandboxTraceBundle, Sr as SandboxInfo, Ti as TeePublicKeyResponse, Tr as SandboxPortBinding, Un as SSHCommandDescriptor, Ur as ScopedToken, Ut as InstalledTool, V as CreateSessionOptions, Vr as SandboxTraceOptions, Wn as SSHCredentials, Wt as IntelligenceReport, Xr as SendSessionMessageRequest, Xt as ListMessagesOptions, Y as DriveTurnOptions, Yr as SendSessionMessageOptions, Yt as JsonValue, Z as DriverInfo, Zr as SentSessionMessage, _i as TaskSessionCommitResult, _n as PromptInputPart, bn as ProvisionEvent, ci as SnapshotResult, dt as FileSystem, ei as SessionForkOptions, et as EgressManager, gi as TaskSessionChanges, hi as TaskResult, ht as FileWriteResult, in as NetworkManager, it as ExecResult, jt as GitStatus, k as CodeLanguage, l as BackendManager, ln as PreviewLinkManager, mi as TaskOptions, ni as SessionListOptions, nt as EventStreamOptions, oi as SnapshotInfo, pn as ProcessManager, pr as SandboxFleetTraceBundle, ri as SessionMessage, rt as ExecOptions, s as BackendConfig, si as SnapshotOptions, sn as PermissionsManager, ti as SessionInfo, tn as MintScopedTokenOptions, ui as StartupDiagnostics, vn as PromptOptions, w as BranchOptions, xi as TeeAttestationOptions, xn as ProvisionResult, yi as TaskSessionInfo, yn as PromptResult, zn as RolloutStartResult } from "./types-C4dFf5eL.js";
2
2
 
3
3
  //#region src/mcp.d.ts
4
4
  /**
@@ -221,6 +221,13 @@ interface SandboxSessionHost extends InteractiveSessionHost {
221
221
  _respondToPermission(id: string, permissionID: string, options: RespondToPermissionOptions): Promise<void>;
222
222
  _interrupt(id: string): Promise<InterruptResult>;
223
223
  _answerQuestion(id: string, answers: Record<string, string[]>): Promise<void>;
224
+ _currentPlan(id: string): Promise<DurablePlan | null>;
225
+ _decidePlan(id: string, planId: string, decision: {
226
+ outcome: "approved";
227
+ } | {
228
+ outcome: "rejected";
229
+ feedback: string;
230
+ }): Promise<DurablePlan>;
224
231
  }
225
232
  /**
226
233
  * A single agent session inside a sandbox. Created via
@@ -327,6 +334,13 @@ declare class SandboxSession {
327
334
  * enabled. Backends with no question support reject loudly.
328
335
  */
329
336
  answer(answers: Record<string, string[]>): Promise<void>;
337
+ /** Return the newest plan awaiting a decision for this session. */
338
+ plan(): Promise<DurablePlan | null>;
339
+ /** Approve a durable plan and enqueue its separate execution turn. */
340
+ approvePlan(planId?: string): Promise<DurablePlan>;
341
+ /** Reject a durable plan with required feedback and enqueue a revision turn. */
342
+ rejectPlan(feedback: string, planId?: string): Promise<DurablePlan>;
343
+ private requireCurrentPlan;
330
344
  }
331
345
  //#endregion
332
346
  //#region src/task-session.d.ts
@@ -1513,7 +1527,7 @@ declare class SandboxInstance {
1513
1527
  /** @internal — invoked by SandboxSession.status(). */
1514
1528
  _sessionStatus(id: string): Promise<SessionInfo | null>;
1515
1529
  /** @internal — invoked by SandboxSession.events(). */
1516
- _sessionEvents(id: string, opts?: SessionEventStreamOptions): AsyncGenerator<SandboxEvent>;
1530
+ _sessionEvents(id: string, opts?: SessionEventStreamOptions, stopOnTurnTerminal?: boolean): AsyncGenerator<SandboxEvent>;
1517
1531
  /** @internal — invoked by SandboxSession.result(). */
1518
1532
  _sessionResult(id: string): Promise<PromptResult>;
1519
1533
  /**
@@ -1541,6 +1555,15 @@ declare class SandboxInstance {
1541
1555
  * question's `answerSpec` fields in order.
1542
1556
  */
1543
1557
  _answerQuestion(id: string, answers: Record<string, string[]>): Promise<void>;
1558
+ /** @internal — invoked by SandboxSession.plan(). */
1559
+ _currentPlan(sessionId: string): Promise<DurablePlan | null>;
1560
+ /** @internal — invoked by SandboxSession.approvePlan()/rejectPlan(). */
1561
+ _decidePlan(sessionId: string, planId: string, decision: {
1562
+ outcome: "approved";
1563
+ } | {
1564
+ outcome: "rejected";
1565
+ feedback: string;
1566
+ }): Promise<DurablePlan>;
1544
1567
  }
1545
1568
  //#endregion
1546
1569
  export { SandboxMcpConfig as C, buildSandboxMcpConfig as D, buildControlPlaneMcpConfig as E, SANDBOX_MCP_SERVER_NAME as S, SandboxMcpServerEntry as T, RespondToPermissionOptions as _, TraceExportSink as a, BuildSandboxMcpConfigOptions as b, otelTraceIdForTangleTrace as c, SandboxSession as d, InteractiveAuthFile as f, InterruptResult as g, InteractiveSessionInfo as h, TraceExportResult as i, toOtelJson as l, InteractiveSessionHost as m, SandboxInstance as n, buildTraceExportPayload as o, InteractiveSessionHandle as p, TraceExportFormat as r, exportTraceBundle as s, HttpClient as t, SandboxTaskSession as u, StartInteractiveOptions as v, SandboxMcpEndpoint as w, CONTROL_PLANE_MCP_SERVER_NAME as x, BuildControlPlaneMcpConfigOptions as y };
@@ -1,5 +1,5 @@
1
- import { n as normalizeSessionInfo, o as normalizeRuntimeBackendConfig, r as uploadChunked, t as SandboxRuntimeApi } from "./runtime-api-DDOueAzd.js";
2
- import { c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, n as CapabilityError, p as parseErrorResponse, s as QuotaError, t as AuthError, u as StateError } from "./errors-wd266B9Q.js";
1
+ import { l as normalizeRuntimeBackendConfig, n as normalizeSessionInfo, o as combineAbortSignals, r as uploadChunked, s as encodePromptForWire, t as SandboxRuntimeApi } from "./runtime-api-kukaWPtF.js";
2
+ import { c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, n as CapabilityError, p as parseErrorResponse, s as QuotaError, t as AuthError, u as StateError } from "./errors-Cbs78OlF.js";
3
3
  import { addTokenUsage, readTokenCostUsd, readTokenUsage } from "@tangle-network/agent-core";
4
4
  //#region src/lib/sse-parser.ts
5
5
  /**
@@ -18,6 +18,7 @@ async function* parseSSEStream(body, options) {
18
18
  let currentEvent = "";
19
19
  let dataLines = [];
20
20
  let currentId = "";
21
+ let completed = false;
21
22
  const flush = function* () {
22
23
  if (dataLines.length === 0) {
23
24
  currentEvent = "";
@@ -61,40 +62,13 @@ async function* parseSSEStream(body, options) {
61
62
  buffer += decoder.decode();
62
63
  if (buffer.length > 0) processLine(buffer);
63
64
  yield* flush();
65
+ completed = true;
64
66
  } finally {
67
+ if (!completed) await reader.cancel().catch(() => void 0);
65
68
  reader.releaseLock();
66
69
  }
67
70
  }
68
71
  //#endregion
69
- //#region src/lib/wire-encoding.ts
70
- /**
71
- * Encode a prompt text part for the wire. Server decodes at the route
72
- * boundary; the LLM only ever sees the original UTF-8. Done
73
- * unconditionally because readable bodies false-positive on ingress WAF
74
- * rules that pattern-match shell-injection-shaped substrings (which
75
- * legitimate prompts routinely contain — e.g. Step-0 dev-server
76
- * bootstrap).
77
- */
78
- function encodeTextForWire(text) {
79
- if (typeof Buffer !== "undefined") return Buffer.from(text, "utf8").toString("base64");
80
- if (typeof btoa === "function") return btoa(encodeURIComponent(text).replace(/%([0-9A-F]{2})/g, (_, h) => String.fromCharCode(Number.parseInt(h, 16))));
81
- throw new Error("encodeTextForWire: no base64 encoder available (Buffer and btoa both undefined)");
82
- }
83
- /**
84
- * Convert a caller-supplied prompt (string or parts array) into the
85
- * wire-format parts array. Every text part is base64-encoded; non-text
86
- * parts pass through. A bare string is wrapped in a single text part.
87
- */
88
- function encodePromptForWire(message) {
89
- return (typeof message === "string" ? [{
90
- type: "text",
91
- text: message
92
- }] : message).map((part) => part.type === "text" ? {
93
- type: "text",
94
- text: encodeTextForWire(part.text)
95
- } : part);
96
- }
97
- //#endregion
98
72
  //#region src/trace-exporter.ts
99
73
  function buildTraceExportPayload(bundle, format = "tangle", serviceName = "tangle-sandbox") {
100
74
  if (format === "tangle") return bundle;
@@ -635,6 +609,29 @@ var SandboxSession = class SandboxSession {
635
609
  async answer(answers) {
636
610
  return this.box._answerQuestion(this.id, answers);
637
611
  }
612
+ /** Return the newest plan awaiting a decision for this session. */
613
+ async plan() {
614
+ return this.box._currentPlan(this.id);
615
+ }
616
+ /** Approve a durable plan and enqueue its separate execution turn. */
617
+ async approvePlan(planId) {
618
+ const id = planId ?? (await this.requireCurrentPlan()).id;
619
+ return this.box._decidePlan(this.id, id, { outcome: "approved" });
620
+ }
621
+ /** Reject a durable plan with required feedback and enqueue a revision turn. */
622
+ async rejectPlan(feedback, planId) {
623
+ if (!feedback.trim()) throw new Error("Plan rejection feedback is required");
624
+ const id = planId ?? (await this.requireCurrentPlan()).id;
625
+ return this.box._decidePlan(this.id, id, {
626
+ outcome: "rejected",
627
+ feedback: feedback.trim()
628
+ });
629
+ }
630
+ async requireCurrentPlan() {
631
+ const plan = await this.plan();
632
+ if (!plan) throw new Error("No durable plan is awaiting a decision");
633
+ return plan;
634
+ }
638
635
  };
639
636
  //#endregion
640
637
  //#region src/task-session.ts
@@ -767,6 +764,11 @@ function runtimeFilesystemPath(endpoint, path) {
767
764
  * requirements; a turn whose tool failed (even if narrated around) fails.
768
765
  */
769
766
  function deriveOutcome(inputs) {
767
+ if (inputs.plan) return {
768
+ status: "awaiting_plan_decision",
769
+ success: false,
770
+ error: "Agent is awaiting a durable plan decision"
771
+ };
770
772
  if (inputs.question) return {
771
773
  status: "awaiting_question",
772
774
  success: false,
@@ -799,6 +801,18 @@ function deriveOutcome(inputs) {
799
801
  success: true
800
802
  };
801
803
  }
804
+ function readAwaitingPlan(data) {
805
+ const direct = data.plan;
806
+ const outcome = data.outcome;
807
+ const candidate = direct && typeof direct === "object" ? direct : outcome && typeof outcome === "object" && outcome.type === "awaiting_plan_decision" ? outcome.plan : void 0;
808
+ if (!candidate || typeof candidate !== "object") return void 0;
809
+ const plan = candidate;
810
+ if (typeof plan.id !== "string" || typeof plan.revision !== "number" || typeof plan.body !== "string" || typeof plan.submittedAt !== "string") return;
811
+ return plan;
812
+ }
813
+ function readPlanFromEvent(event) {
814
+ return event.type === "result" || event.type === "done" || event.type === "plan.submitted" ? readAwaitingPlan(event.data) : void 0;
815
+ }
802
816
  /** Read tool invocations off a `result` event payload. */
803
817
  function readToolInvocations(data) {
804
818
  const raw = data.toolInvocations;
@@ -1441,10 +1455,11 @@ var SandboxInstance = class SandboxInstance {
1441
1455
  let costUsd;
1442
1456
  let toolInvocations;
1443
1457
  let question;
1458
+ let plan;
1444
1459
  let terminalReached = false;
1445
1460
  const controller = new AbortController();
1446
1461
  try {
1447
- const signal = options?.signal ? AbortSignal.any([options.signal, controller.signal]) : controller.signal;
1462
+ const signal = options?.signal ? combineAbortSignals([options.signal, controller.signal]) : controller.signal;
1448
1463
  for await (const event of this.streamPrompt(message, {
1449
1464
  ...options,
1450
1465
  signal
@@ -1454,6 +1469,7 @@ var SandboxInstance = class SandboxInstance {
1454
1469
  usage = readTokenUsage(event.data) ?? usage;
1455
1470
  costUsd = readTokenCostUsd(event.data) ?? costUsd;
1456
1471
  }
1472
+ plan = readPlanFromEvent(event) ?? plan;
1457
1473
  if (event.type === "result") toolInvocations = readToolInvocations(event.data) ?? toolInvocations;
1458
1474
  if (event.type === "result" || event.type === "done") terminalReached = true;
1459
1475
  if (event.type === "interaction") question = readQuestionEvent(event.data) ?? question;
@@ -1470,7 +1486,8 @@ var SandboxInstance = class SandboxInstance {
1470
1486
  runErrorCode,
1471
1487
  toolInvocations,
1472
1488
  approval,
1473
- question
1489
+ question,
1490
+ plan
1474
1491
  });
1475
1492
  return {
1476
1493
  success: outcome.success,
@@ -1481,6 +1498,7 @@ var SandboxInstance = class SandboxInstance {
1481
1498
  toolInvocations,
1482
1499
  approval,
1483
1500
  question,
1501
+ plan,
1484
1502
  traceId,
1485
1503
  durationMs: Date.now() - startTime,
1486
1504
  usage,
@@ -1569,7 +1587,7 @@ var SandboxInstance = class SandboxInstance {
1569
1587
  await this.ensureRunning();
1570
1588
  const timeoutMs = typeof options?.timeoutMs === "number" && options.timeoutMs > 0 ? options.timeoutMs : void 0;
1571
1589
  const timeoutSignal = timeoutMs ? AbortSignal.timeout(timeoutMs) : void 0;
1572
- const streamSignal = timeoutSignal ? options?.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal : options?.signal;
1590
+ const streamSignal = timeoutSignal ? options?.signal ? combineAbortSignals([options.signal, timeoutSignal]) : timeoutSignal : options?.signal;
1573
1591
  const throwIfTimedOut = () => {
1574
1592
  if (!timeoutSignal?.aborted || !timeoutMs) return;
1575
1593
  throw new TimeoutError(timeoutMs, `Prompt stream timed out after ${timeoutMs}ms`, {
@@ -1958,6 +1976,7 @@ var SandboxInstance = class SandboxInstance {
1958
1976
  let costUsd;
1959
1977
  let toolInvocations;
1960
1978
  let question;
1979
+ let plan;
1961
1980
  let terminalReached = false;
1962
1981
  try {
1963
1982
  for await (const event of this.streamPrompt(prompt, {
@@ -1974,6 +1993,7 @@ var SandboxInstance = class SandboxInstance {
1974
1993
  }
1975
1994
  if (event.type === "done" && costUsd === void 0) costUsd = readTokenCostUsd(event.data);
1976
1995
  if (event.type === "result" || event.type === "done") terminalReached = true;
1996
+ plan = readPlanFromEvent(event) ?? plan;
1977
1997
  if (event.type === "interaction") question = readQuestionEvent(event.data) ?? question;
1978
1998
  if (event.type === "trace.id") traceId = event.data.traceId;
1979
1999
  if (event.type === "error") {
@@ -1988,7 +2008,8 @@ var SandboxInstance = class SandboxInstance {
1988
2008
  runErrorCode,
1989
2009
  toolInvocations,
1990
2010
  approval,
1991
- question
2011
+ question,
2012
+ plan
1992
2013
  });
1993
2014
  return {
1994
2015
  success: outcome.success,
@@ -1999,6 +2020,7 @@ var SandboxInstance = class SandboxInstance {
1999
2020
  toolInvocations,
2000
2021
  approval,
2001
2022
  question,
2023
+ plan,
2002
2024
  traceId,
2003
2025
  durationMs: Date.now() - startTime,
2004
2026
  usage,
@@ -3888,7 +3910,7 @@ var SandboxInstance = class SandboxInstance {
3888
3910
  async resume(options = {}) {
3889
3911
  if (options.timeoutMs !== void 0 && (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0)) throw new ValidationError("resume timeoutMs must be a positive number");
3890
3912
  const timeoutSignal = options.timeoutMs ? AbortSignal.timeout(options.timeoutMs) : void 0;
3891
- const signal = timeoutSignal ? options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal : options.signal;
3913
+ const signal = timeoutSignal ? options.signal ? combineAbortSignals([options.signal, timeoutSignal]) : timeoutSignal : options.signal;
3892
3914
  const response = await this.client.fetch(`/v1/sandboxes/${this.id}/resume`, {
3893
3915
  method: "POST",
3894
3916
  ...signal ? { signal } : {}
@@ -4361,24 +4383,8 @@ var SandboxInstance = class SandboxInstance {
4361
4383
  * abort stamps `interrupted: true` explicitly.
4362
4384
  */
4363
4385
  async messages(opts) {
4364
- await this.ensureRunning();
4365
- const params = new URLSearchParams();
4366
- if (opts.limit !== void 0) params.set("limit", String(opts.limit));
4367
- if (opts.offset !== void 0) params.set("offset", String(opts.offset));
4368
- if (opts.since !== void 0) params.set("since", String(opts.since));
4369
- const query = params.toString() ? `?${params.toString()}` : "";
4370
- const response = await this.client.fetch(`/v1/sessions/${encodeURIComponent(opts.sessionId)}/messages${query}`, { method: "GET" });
4371
- if (!response.ok) {
4372
- const body = await response.text();
4373
- throw parseErrorResponse(response.status, body, void 0, response.headers);
4374
- }
4375
- return (await response.json()).map((m) => ({
4376
- id: m.info.id,
4377
- role: m.info.role,
4378
- timestamp: m.info.timestamp,
4379
- parts: m.parts,
4380
- metadata: m.info.metadata
4381
- }));
4386
+ const { sessionId, ...options } = opts;
4387
+ return this.runtime.messages(sessionId, options);
4382
4388
  }
4383
4389
  /** @internal — invoked by SandboxSession.sendMessage(). */
4384
4390
  async _sessionSendMessage(id, request, options = {}) {
@@ -4487,11 +4493,13 @@ var SandboxInstance = class SandboxInstance {
4487
4493
  }
4488
4494
  if (info) {
4489
4495
  const result = await this._sessionResult(opts.sessionId);
4496
+ const settled = settleTurnDrive({ ...result });
4497
+ if (settled.state === "awaiting_plan_decision") return settled;
4490
4498
  if (!result.success) return {
4491
4499
  state: "failed",
4492
4500
  error: `session ${opts.sessionId} ${info.status}: ${result.error ?? "no error detail"}`
4493
4501
  };
4494
- return settleTurnDrive({ ...result });
4502
+ return settled;
4495
4503
  }
4496
4504
  await this.dispatchPrompt(message, {
4497
4505
  ...opts,
@@ -4542,17 +4550,22 @@ var SandboxInstance = class SandboxInstance {
4542
4550
  return normalizeSessionInfo(await response.json());
4543
4551
  }
4544
4552
  /** @internal — invoked by SandboxSession.events(). */
4545
- async *_sessionEvents(id, opts) {
4553
+ async *_sessionEvents(id, opts, stopOnTurnTerminal = false) {
4546
4554
  await this.ensureRunning();
4547
4555
  const search = new URLSearchParams();
4548
4556
  search.set("sessionId", id);
4549
4557
  if (opts?.since) search.set("since", opts.since);
4558
+ if (opts?.executionId) search.set("executionId", opts.executionId);
4550
4559
  const response = await this.runtimeFetch(`/agents/events?${search.toString()}`, { signal: opts?.signal });
4551
4560
  if (!response.ok) {
4552
4561
  const body = await response.text();
4553
4562
  throw parseErrorResponse(response.status, body, void 0, response.headers);
4554
4563
  }
4555
- yield* this.parseSSEStream(response, opts?.signal);
4564
+ for await (const event of this.parseSSEStream(response, opts?.signal)) {
4565
+ yield event;
4566
+ const turnTerminal = event.type === "result" || event.type === "done" || event.type === "error";
4567
+ if ((stopOnTurnTerminal || opts?.executionId !== void 0) && turnTerminal) return;
4568
+ }
4556
4569
  }
4557
4570
  /** @internal — invoked by SandboxSession.result(). */
4558
4571
  async _sessionResult(id) {
@@ -4565,14 +4578,16 @@ var SandboxInstance = class SandboxInstance {
4565
4578
  let costUsd;
4566
4579
  let toolInvocations;
4567
4580
  let question;
4581
+ let plan;
4568
4582
  let terminalReached = false;
4569
- for await (const event of this._sessionEvents(id)) {
4583
+ for await (const event of this._sessionEvents(id, void 0, true)) {
4570
4584
  response = applySandboxEventText(response, event);
4571
4585
  if (event.type === "result" || event.type === "done") {
4572
4586
  const data = event.data;
4573
4587
  usage = readTokenUsage(data) ?? usage;
4574
4588
  costUsd = readTokenCostUsd(data) ?? costUsd;
4575
4589
  }
4590
+ plan = readPlanFromEvent(event) ?? plan;
4576
4591
  if (event.type === "result") {
4577
4592
  const data = event.data;
4578
4593
  toolInvocations = readToolInvocations(data) ?? toolInvocations;
@@ -4596,7 +4611,8 @@ var SandboxInstance = class SandboxInstance {
4596
4611
  runErrorCode,
4597
4612
  toolInvocations,
4598
4613
  approval,
4599
- question
4614
+ question,
4615
+ plan
4600
4616
  });
4601
4617
  return {
4602
4618
  success: outcome.success,
@@ -4607,6 +4623,7 @@ var SandboxInstance = class SandboxInstance {
4607
4623
  toolInvocations,
4608
4624
  approval,
4609
4625
  question,
4626
+ plan,
4610
4627
  traceId,
4611
4628
  durationMs: Date.now() - startTime,
4612
4629
  usage,
@@ -4738,8 +4755,48 @@ var SandboxInstance = class SandboxInstance {
4738
4755
  throw parseErrorResponse(response.status, body, void 0, response.headers);
4739
4756
  }
4740
4757
  }
4758
+ /** @internal — invoked by SandboxSession.plan(). */
4759
+ async _currentPlan(sessionId) {
4760
+ const path = `/v1/sandboxes/${encodeURIComponent(this.id)}/agent-sessions/${encodeURIComponent(sessionId)}/plans/current`;
4761
+ const response = await this.client.fetch(path);
4762
+ if (response.status === 404) return null;
4763
+ if (!response.ok) {
4764
+ const body = await response.text();
4765
+ throw parseErrorResponse(response.status, body, void 0, response.headers);
4766
+ }
4767
+ const decoded = await response.json();
4768
+ if (!decoded.plan) throw new ServerError("Durable plan response is missing plan", 502, {
4769
+ endpoint: path,
4770
+ origin: "control-plane"
4771
+ });
4772
+ return decoded.plan;
4773
+ }
4774
+ /** @internal — invoked by SandboxSession.approvePlan()/rejectPlan(). */
4775
+ async _decidePlan(sessionId, planId, decision) {
4776
+ const path = `/v1/sandboxes/${encodeURIComponent(this.id)}/agent-sessions/${encodeURIComponent(sessionId)}/plans/${encodeURIComponent(planId)}/decision`;
4777
+ const response = await this.client.fetch(path, {
4778
+ method: "POST",
4779
+ body: JSON.stringify(decision)
4780
+ });
4781
+ if (!response.ok) {
4782
+ const body = await response.text();
4783
+ throw parseErrorResponse(response.status, body, void 0, response.headers);
4784
+ }
4785
+ const decoded = await response.json();
4786
+ if (!decoded.plan) throw new ServerError("Plan decision response is missing plan", 502, {
4787
+ endpoint: path,
4788
+ origin: "control-plane"
4789
+ });
4790
+ return decoded.plan;
4791
+ }
4741
4792
  };
4742
4793
  function settleTurnDrive(result) {
4794
+ const plan = readAwaitingPlan(result);
4795
+ if (plan) return {
4796
+ state: "awaiting_plan_decision",
4797
+ plan,
4798
+ result
4799
+ };
4743
4800
  const text = typeof result.text === "string" ? result.text : typeof result.response === "string" ? result.response : void 0;
4744
4801
  const status = typeof result.status === "string" ? result.status : deriveOutcome({
4745
4802
  terminalReached: true,
@@ -4822,4 +4879,4 @@ function quoteForShell(value) {
4822
4879
  return `'${value.replace(/'/g, "'\\''")}'`;
4823
4880
  }
4824
4881
  //#endregion
4825
- export { InteractiveSessionHandle as a, getSandboxEventText as c, exportTraceBundle as d, otelTraceIdForTangleTrace as f, parseSSEStream as g, encodeTextForWire as h, SandboxSession as i, normalizeConnection as l, encodePromptForWire as m, normalizeStartupDiagnostics as n, applySandboxEventText as o, toOtelJson as p, SandboxTaskSession as r, collectAgentResponseText as s, SandboxInstance as t, buildTraceExportPayload as u };
4882
+ export { InteractiveSessionHandle as a, getSandboxEventText as c, exportTraceBundle as d, otelTraceIdForTangleTrace as f, SandboxSession as i, normalizeConnection as l, parseSSEStream as m, normalizeStartupDiagnostics as n, applySandboxEventText as o, toOtelJson as p, SandboxTaskSession as r, collectAgentResponseText as s, SandboxInstance as t, buildTraceExportPayload as u };
@@ -1,2 +1,2 @@
1
- import { a as TANGLE_JOBS_CONTRACT, c as AgentSandboxBlueprintAbi, d as SandboxCreateParamTypes, f as SandboxCreateResponseParamTypes, i as TANGLE_CHAIN_ID, l as ITangleJobsAbi, n as JOB_SANDBOX_CREATE, o as TANGLE_MAINNET_RPC, p as SandboxIdParamTypes, r as JOB_SANDBOX_DELETE, s as TangleSandboxClientConfig, t as TangleSandboxClient, u as JsonResponseParamTypes } from "../index-CEZaPvfX.js";
1
+ import { a as TANGLE_JOBS_CONTRACT, c as AgentSandboxBlueprintAbi, d as SandboxCreateParamTypes, f as SandboxCreateResponseParamTypes, i as TANGLE_CHAIN_ID, l as ITangleJobsAbi, n as JOB_SANDBOX_CREATE, o as TANGLE_MAINNET_RPC, p as SandboxIdParamTypes, r as JOB_SANDBOX_DELETE, s as TangleSandboxClientConfig, t as TangleSandboxClient, u as JsonResponseParamTypes } from "../index-V2vjBfHU.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TANGLE_MAINNET_RPC, TangleSandboxClient, TangleSandboxClientConfig };
@@ -1,2 +1,2 @@
1
- import { a as TANGLE_JOBS_CONTRACT, c as ITangleJobsAbi, d as SandboxCreateResponseParamTypes, f as SandboxIdParamTypes, i as TANGLE_CHAIN_ID, l as JsonResponseParamTypes, n as JOB_SANDBOX_CREATE, o as TANGLE_MAINNET_RPC, r as JOB_SANDBOX_DELETE, s as AgentSandboxBlueprintAbi, t as TangleSandboxClient, u as SandboxCreateParamTypes } from "../tangle-Bx0V6Nt5.js";
1
+ import { a as TANGLE_JOBS_CONTRACT, c as ITangleJobsAbi, d as SandboxCreateResponseParamTypes, f as SandboxIdParamTypes, i as TANGLE_CHAIN_ID, l as JsonResponseParamTypes, n as JOB_SANDBOX_CREATE, o as TANGLE_MAINNET_RPC, r as JOB_SANDBOX_DELETE, s as AgentSandboxBlueprintAbi, t as TangleSandboxClient, u as SandboxCreateParamTypes } from "../tangle-051CtV2b.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TANGLE_MAINNET_RPC, TangleSandboxClient };
@@ -1,5 +1,5 @@
1
- import { p as parseErrorResponse } from "./errors-wd266B9Q.js";
2
- import { t as SandboxInstance } from "./sandbox-C8qQicxF.js";
1
+ import { p as parseErrorResponse } from "./errors-Cbs78OlF.js";
2
+ import { t as SandboxInstance } from "./sandbox-r2Lxbw8z.js";
3
3
  //#region src/tangle/abi.ts
4
4
  /**
5
5
  * Tangle Contract ABI Definitions
@@ -1158,7 +1158,32 @@ interface InstalledTool {
1158
1158
  * - `awaiting_question` — the agent asked a question and the turn ended without
1159
1159
  * an answer. See {@link AgentQuestionRequest}.
1160
1160
  */
1161
- type AgentRunStatus = "success" | "failed" | "blocked_on_approval" | "awaiting_question";
1161
+ type AgentRunStatus = "success" | "failed" | "blocked_on_approval" | "awaiting_question" | "awaiting_plan_decision";
1162
+ interface DurablePlanSnapshot {
1163
+ id: string;
1164
+ revision: number;
1165
+ title?: string;
1166
+ body: string;
1167
+ submittedAt: string;
1168
+ }
1169
+ type DurablePlan = DurablePlanSnapshot & ({
1170
+ status: "pending";
1171
+ } | {
1172
+ status: "approved";
1173
+ decidedAt: string;
1174
+ } | {
1175
+ status: "rejected";
1176
+ decidedAt: string;
1177
+ feedback: string;
1178
+ } | {
1179
+ status: "superseded";
1180
+ supersededAt: string;
1181
+ supersededByPlanId: string;
1182
+ } | {
1183
+ status: "withdrawn";
1184
+ withdrawnAt: string;
1185
+ reason: string;
1186
+ });
1162
1187
  /**
1163
1188
  * A tool the agent invoked during a run. `isError` flags a failed call
1164
1189
  * (errored, timed out, or rejected — e.g. a hub approval gate). Failed tools
@@ -1220,6 +1245,8 @@ interface PromptResult {
1220
1245
  approval?: AgentApprovalRequirement;
1221
1246
  /** Set when `status === "awaiting_question"`. */
1222
1247
  question?: AgentQuestionRequest;
1248
+ /** Set when `status === "awaiting_plan_decision"`. */
1249
+ plan?: DurablePlanSnapshot;
1223
1250
  /** Trace ID for debugging */
1224
1251
  traceId?: string;
1225
1252
  /** Duration in milliseconds */
@@ -1883,6 +1910,9 @@ interface SessionEventStreamOptions {
1883
1910
  /** Replay starting from this event id (inclusive). Omit to start at
1884
1911
  * the live tail. Useful for reconnect-after-disconnect flows. */
1885
1912
  since?: string;
1913
+ /** Restrict replay to one execution within the session. Required with
1914
+ * `since` when attaching after a server-dispatched turn has already begun. */
1915
+ executionId?: string;
1886
1916
  /** Cancel the stream by aborting this signal. */
1887
1917
  signal?: AbortSignal;
1888
1918
  }
@@ -2033,6 +2063,10 @@ type TurnDriveResult = {
2033
2063
  state: "completed"; /** Final assistant text of the turn. */
2034
2064
  text: string; /** The full turn payload (text, toolInvocations, tokenUsage, etc.). */
2035
2065
  result: Record<string, unknown>;
2066
+ } | {
2067
+ state: "awaiting_plan_decision";
2068
+ plan: DurablePlanSnapshot;
2069
+ result: Record<string, unknown>;
2036
2070
  } | {
2037
2071
  state: "running"; /** When the session began executing, if the runtime reported it. */
2038
2072
  startedAt?: Date; /** Milliseconds since `startedAt` at the moment of the poll. */
@@ -4960,4 +4994,4 @@ interface CodeExecutionOptions {
4960
4994
  idempotencyKey?: string;
4961
4995
  }
4962
4996
  //#endregion
4963
- export { EgressManager as $, defineInlineResource as $i, SandboxFleetDriverCapability as $n, SessionForkOptions as $r, McpServerConfig as $t, CodeResult as A, UploadProgress as Ai, ReconcileSandboxFleetsResult as An, SandboxRuntimeProfile as Ar, GitStatus as At, CreateSandboxOptions as B, AgentProfileConnection as Bi, RolloutTurnPart as Bn, SandboxTraceOptions as Br, HostAgentDriverConfig as Bt, BatchTaskUsage as C, TeePublicKey as Ci, PublicTemplateInfo as Cn, SandboxPermissionsConfig as Cr, FleetPromptDispatchResult as Ct, CodeExecutionOptions as D, TurnDriveResult as Di, ReapExpiredSandboxFleetsOptions as Dn, SandboxResourceUsage as Dr, GitCommit as Dt, ChunkedUploadResult as E, ToolsConfig as Ei, PublishPublicTemplateVersionOptions as En, SandboxProfileSummary as Er, GitBranch as Et, CreateIntelligenceReportOptions as F, WriteManyFile as Fi, RolloutChildResult as Fn, SandboxTerminalManager as Fr, GpuLeaseExecResult as Ft, DispatchPromptOptions as G, AgentProfilePrompt as Gi, SandboxConnection as Gn, SearchOptions as Gr, IntelligenceReportCompareTo as Gt, CreateTaskSessionOptions as H, AgentProfileMcpServer as Hi, SSHCommandDescriptor as Hn, ScopedToken as Hr, InstalledTool as Ht, CreateRequestOptions as I, WriteManyOptions as Ii, RolloutOptions as In, SandboxTerminalRequestOptions as Ir, GpuLeaseManager as It, DownloadProgress as J, AgentProfileValidationIssue as Ji, SandboxFleetArtifact as Jn, SendSessionMessageOptions as Jr, JsonValue as Jt, DispatchedSession as K, AgentProfileResourceRef as Ki, SandboxEnvironment as Kn, SecretInfo as Kr, IntelligenceReportSubjectType as Kt, CreateSandboxFleetOptions as L, AgentProfile as Li, RolloutScorer as Ln, SandboxTraceBundle as Lr, GpuLeaseProviderName as Lt, CommitTaskSessionOptions as M, WaitForOptions as Mi, RestoreSnapshotOptions as Mn, SandboxStatus as Mr, GpuLeaseBilling as Mt, CompletedTurnResult as N, WaitForRolloutOptions as Ni, ResumeOptions as Nn, SandboxTerminalCreateOptions as Nr, GpuLeaseCommandResult as Nt, CodeExecutionResult as O, UpdateUserOptions as Oi, ReapExpiredSandboxFleetsResult as On, SandboxResources as Or, GitConfig as Ot, CreateGpuLeaseOptions as P, WriteFileOptions as Pi, Rollout as Pn, SandboxTerminalInfo as Pr, GpuLeaseExecOptions as Pt, DriverType as Q, defineGitHubResource as Qi, SandboxFleetDispatchResponse as Qn, SessionEventStreamOptions as Qr, ListSandboxOptions as Qt, CreateSandboxFleetTokenOptions as R, AgentProfileCapabilities as Ri, RolloutStartResult as Rn, SandboxTraceEvent as Rr, GpuLeaseStatus as Rt, BatchTaskResult as S, TeeAttestationResponse as Si, ProvisionStep as Sn, SandboxIntelligenceEnvelope as Sr, FleetPromptDispatchOptions as St, ChunkedUploadOptions as T, TokenRefreshHandler as Ti, PublishPublicTemplateOptions as Tn, SandboxPortPreviewLink as Tr, GitAuth as Tt, DeleteOptions as U, AgentProfileModelHints as Ui, SSHCredentials as Un, ScopedTokenScope as Ur, IntelligenceReport as Ut, CreateSessionOptions as V, AgentProfileFileMount as Vi, RunCodeOptions as Vn, SandboxUser as Vr, HostAgentRuntimeBackend as Vt, DirectoryPermission as W, AgentProfilePermissionValue as Wi, SandboxClientConfig as Wn, SearchMatch as Wr, IntelligenceReportBudget as Wt, DriverConfig as X, AgentSubagentProfile as Xi, SandboxFleetCostEstimate as Xn, SentSessionMessage as Xr, ListOptions as Xt, DriveTurnOptions as Y, AgentProfileValidationResult as Yi, SandboxFleetArtifactSpec as Yn, SendSessionMessageRequest as Yr, ListMessagesOptions as Yt, DriverInfo as Z, defineAgentProfile as Zi, SandboxFleetDispatchFailureClass as Zn, SessionBackendCredentials as Zr, ListSandboxFleetOptions as Zt, BatchResult as _, TaskSessionFileChange as _i, PromptOptions as _n, SandboxFleetWorkspace as _r, FleetDispatchResultBufferOptions as _t, AttachSandboxFleetMachineOptions as a, SnapshotInfo as ai, PermissionLevel as an, SandboxFleetMachineRecord as ar, FileReadBatchOptions as at, BatchSidecarGroup as b, TeeAttestationOptions as bi, ProvisionResult as bn, SandboxFleetWorkspaceSnapshotResult as br, FleetExecDispatchResult as bt, BackendInfo as c, SshKeysManager as ci, PreviewLinkManager as cn, SandboxFleetManifestMachine as cr, FileReadResult as ct, BackendType as d, StorageConfig as di, ProcessLogEntry as dn, SandboxFleetToken as dr, FileTreeFile as dt, mergeAgentProfiles as ea, SessionInfo as ei, MintScopedTokenOptions as en, SandboxFleetDriverTimings as er, EgressPolicy as et, BatchBackend as f, SubscriptionInfo as fi, ProcessManager as fn, SandboxFleetTraceBundle as fr, FileTreeOptions as ft, BatchOptions as g, TaskSessionCommitResult as gi, PromptInputPart as gn, SandboxFleetUsage as gr, FleetDispatchResultBuffer as gt, BatchEventDataMap as h, TaskSessionChanges as hi, ProcessStatus as hn, SandboxFleetTraceOptions as hr, FleetDispatchCancelResult as ht, AttachGpuLeaseOptions as i, SessionStatus as ii, NonHostAgentDriverConfig as in, SandboxFleetMachineMeteredUsage as ir, FileInfo as it, CodeResultPart as j, UsageInfo as ji, RenameOptions as jn, SandboxRuntimeProfileList as jr, GpuLease as jt, CodeLanguage as k, UploadOptions as ki, ReconcileSandboxFleetsOptions as kn, SandboxRuntimeHealth as kr, GitDiff as kt, BackendManager as l, StartupDiagnostics as li, Process as ln, SandboxFleetOperationsSummary as lr, FileRenameResult as lt, BatchEvent as m, TaskResult as mi, ProcessSpawnOptions as mn, SandboxFleetTraceExport as mr, FileWriteResult as mt, AccessPolicyRule as n, SessionMessage as ni, NetworkConfig as nn, SandboxFleetIntelligenceEnvelope as nr, ExecOptions as nt, BackendCapabilities as o, SnapshotOptions as oi, PermissionsManager as on, SandboxFleetMachineSpec as or, FileReadBatchResult as ot, BatchBackendStats as p, TaskOptions as pi, ProcessSignal as pn, SandboxFleetTraceEvent as pr, FileTreeResult as pt, DownloadOptions as q, AgentProfileResources as qi, SandboxEvent as qn, SecretsManager as qr, IntelligenceReportWindow as qt, AddUserOptions as r, SessionMessageInputPart as ri, NetworkManager as rn, SandboxFleetMachine as rr, ExecResult as rt, BackendConfig as s, SnapshotResult as si, PreviewLinkInfo as sn, SandboxFleetManifest as sr, FileReadError as st, AcceleratorKind as t, SessionListOptions as ti, MkdirOptions as tn, SandboxFleetInfo as tr, EventStreamOptions as tt, BackendStatus as u, StartupOperation as ui, ProcessInfo as un, SandboxFleetPolicy as ur, FileSystem as ut, BatchRunOptions as v, TaskSessionInfo as vi, PromptResult as vn, SandboxFleetWorkspaceReconcileResult as vr, FleetDispatchStreamOptions as vt, BranchOptions as w, TeePublicKeyResponse as wi, PublicTemplateVersionInfo as wn, SandboxPortBinding as wr, GPU_LEASE_PROVIDER_NAMES as wt, BatchTask as x, TeeAttestationReport as xi, ProvisionStatus as xn, SandboxInfo as xr, FleetMachineId as xt, BatchRunRequest as y, TaskSessionProfile as yi, ProvisionEvent as yn, SandboxFleetWorkspaceRestoreResult as yr, FleetExecDispatchOptions as yt, CreateSandboxFleetWithCoordinatorOptions as z, AgentProfileConfidential as zi, RolloutStatus as zn, SandboxTraceExport as zr, GpuType as zt };
4997
+ export { DurablePlan as $, defineGitHubResource as $i, SandboxFleetDispatchResponse as $n, SessionEventStreamOptions as $r, ListSandboxOptions as $t, CodeResult as A, UploadOptions as Ai, ReconcileSandboxFleetsOptions as An, SandboxRuntimeHealth as Ar, GitDiff as At, CreateSandboxOptions as B, AgentProfileConfidential as Bi, RolloutStatus as Bn, SandboxTraceExport as Br, GpuType as Bt, BatchTaskUsage as C, TeeAttestationResponse as Ci, ProvisionStep as Cn, SandboxIntelligenceEnvelope as Cr, FleetPromptDispatchOptions as Ct, CodeExecutionOptions as D, ToolsConfig as Di, PublishPublicTemplateVersionOptions as Dn, SandboxProfileSummary as Dr, GitBranch as Dt, ChunkedUploadResult as E, TokenRefreshHandler as Ei, PublishPublicTemplateOptions as En, SandboxPortPreviewLink as Er, GitAuth as Et, CreateIntelligenceReportOptions as F, WriteFileOptions as Fi, Rollout as Fn, SandboxTerminalInfo as Fr, GpuLeaseExecOptions as Ft, DispatchPromptOptions as G, AgentProfilePermissionValue as Gi, SandboxClientConfig as Gn, SearchMatch as Gr, IntelligenceReportBudget as Gt, CreateTaskSessionOptions as H, AgentProfileFileMount as Hi, RunCodeOptions as Hn, SandboxUser as Hr, HostAgentRuntimeBackend as Ht, CreateRequestOptions as I, WriteManyFile as Ii, RolloutChildResult as In, SandboxTerminalManager as Ir, GpuLeaseExecResult as It, DownloadProgress as J, AgentProfileResources as Ji, SandboxEvent as Jn, SecretsManager as Jr, IntelligenceReportWindow as Jt, DispatchedSession as K, AgentProfilePrompt as Ki, SandboxConnection as Kn, SearchOptions as Kr, IntelligenceReportCompareTo as Kt, CreateSandboxFleetOptions as L, WriteManyOptions as Li, RolloutOptions as Ln, SandboxTerminalRequestOptions as Lr, GpuLeaseManager as Lt, CommitTaskSessionOptions as M, UsageInfo as Mi, RenameOptions as Mn, SandboxRuntimeProfileList as Mr, GpuLease as Mt, CompletedTurnResult as N, WaitForOptions as Ni, RestoreSnapshotOptions as Nn, SandboxStatus as Nr, GpuLeaseBilling as Nt, CodeExecutionResult as O, TurnDriveResult as Oi, ReapExpiredSandboxFleetsOptions as On, SandboxResourceUsage as Or, GitCommit as Ot, CreateGpuLeaseOptions as P, WaitForRolloutOptions as Pi, ResumeOptions as Pn, SandboxTerminalCreateOptions as Pr, GpuLeaseCommandResult as Pt, DriverType as Q, defineAgentProfile as Qi, SandboxFleetDispatchFailureClass as Qn, SessionBackendCredentials as Qr, ListSandboxFleetOptions as Qt, CreateSandboxFleetTokenOptions as R, AgentProfile as Ri, RolloutScorer as Rn, SandboxTraceBundle as Rr, GpuLeaseProviderName as Rt, BatchTaskResult as S, TeeAttestationReport as Si, ProvisionStatus as Sn, SandboxInfo as Sr, FleetMachineId as St, ChunkedUploadOptions as T, TeePublicKeyResponse as Ti, PublicTemplateVersionInfo as Tn, SandboxPortBinding as Tr, GPU_LEASE_PROVIDER_NAMES as Tt, DeleteOptions as U, AgentProfileMcpServer as Ui, SSHCommandDescriptor as Un, ScopedToken as Ur, InstalledTool as Ut, CreateSessionOptions as V, AgentProfileConnection as Vi, RolloutTurnPart as Vn, SandboxTraceOptions as Vr, HostAgentDriverConfig as Vt, DirectoryPermission as W, AgentProfileModelHints as Wi, SSHCredentials as Wn, ScopedTokenScope as Wr, IntelligenceReport as Wt, DriverConfig as X, AgentProfileValidationResult as Xi, SandboxFleetArtifactSpec as Xn, SendSessionMessageRequest as Xr, ListMessagesOptions as Xt, DriveTurnOptions as Y, AgentProfileValidationIssue as Yi, SandboxFleetArtifact as Yn, SendSessionMessageOptions as Yr, JsonValue as Yt, DriverInfo as Z, AgentSubagentProfile as Zi, SandboxFleetCostEstimate as Zn, SentSessionMessage as Zr, ListOptions as Zt, BatchResult as _, TaskSessionCommitResult as _i, PromptInputPart as _n, SandboxFleetUsage as _r, FleetDispatchResultBuffer as _t, AttachSandboxFleetMachineOptions as a, SessionStatus as ai, NonHostAgentDriverConfig as an, SandboxFleetMachineMeteredUsage as ar, FileInfo as at, BatchSidecarGroup as b, TaskSessionProfile as bi, ProvisionEvent as bn, SandboxFleetWorkspaceRestoreResult as br, FleetExecDispatchOptions as bt, BackendInfo as c, SnapshotResult as ci, PreviewLinkInfo as cn, SandboxFleetManifest as cr, FileReadError as ct, BackendType as d, StartupOperation as di, ProcessInfo as dn, SandboxFleetPolicy as dr, FileSystem as dt, defineInlineResource as ea, SessionForkOptions as ei, McpServerConfig as en, SandboxFleetDriverCapability as er, EgressManager as et, BatchBackend as f, StorageConfig as fi, ProcessLogEntry as fn, SandboxFleetToken as fr, FileTreeFile as ft, BatchOptions as g, TaskSessionChanges as gi, ProcessStatus as gn, SandboxFleetTraceOptions as gr, FleetDispatchCancelResult as gt, BatchEventDataMap as h, TaskResult as hi, ProcessSpawnOptions as hn, SandboxFleetTraceExport as hr, FileWriteResult as ht, AttachGpuLeaseOptions as i, SessionMessageInputPart as ii, NetworkManager as in, SandboxFleetMachine as ir, ExecResult as it, CodeResultPart as j, UploadProgress as ji, ReconcileSandboxFleetsResult as jn, SandboxRuntimeProfile as jr, GitStatus as jt, CodeLanguage as k, UpdateUserOptions as ki, ReapExpiredSandboxFleetsResult as kn, SandboxResources as kr, GitConfig as kt, BackendManager as l, SshKeysManager as li, PreviewLinkManager as ln, SandboxFleetManifestMachine as lr, FileReadResult as lt, BatchEvent as m, TaskOptions as mi, ProcessSignal as mn, SandboxFleetTraceEvent as mr, FileTreeResult as mt, AccessPolicyRule as n, SessionListOptions as ni, MkdirOptions as nn, SandboxFleetInfo as nr, EventStreamOptions as nt, BackendCapabilities as o, SnapshotInfo as oi, PermissionLevel as on, SandboxFleetMachineRecord as or, FileReadBatchOptions as ot, BatchBackendStats as p, SubscriptionInfo as pi, ProcessManager as pn, SandboxFleetTraceBundle as pr, FileTreeOptions as pt, DownloadOptions as q, AgentProfileResourceRef as qi, SandboxEnvironment as qn, SecretInfo as qr, IntelligenceReportSubjectType as qt, AddUserOptions as r, SessionMessage as ri, NetworkConfig as rn, SandboxFleetIntelligenceEnvelope as rr, ExecOptions as rt, BackendConfig as s, SnapshotOptions as si, PermissionsManager as sn, SandboxFleetMachineSpec as sr, FileReadBatchResult as st, AcceleratorKind as t, mergeAgentProfiles as ta, SessionInfo as ti, MintScopedTokenOptions as tn, SandboxFleetDriverTimings as tr, EgressPolicy as tt, BackendStatus as u, StartupDiagnostics as ui, Process as un, SandboxFleetOperationsSummary as ur, FileRenameResult as ut, BatchRunOptions as v, TaskSessionFileChange as vi, PromptOptions as vn, SandboxFleetWorkspace as vr, FleetDispatchResultBufferOptions as vt, BranchOptions as w, TeePublicKey as wi, PublicTemplateInfo as wn, SandboxPermissionsConfig as wr, FleetPromptDispatchResult as wt, BatchTask as x, TeeAttestationOptions as xi, ProvisionResult as xn, SandboxFleetWorkspaceSnapshotResult as xr, FleetExecDispatchResult as xt, BatchRunRequest as y, TaskSessionInfo as yi, PromptResult as yn, SandboxFleetWorkspaceReconcileResult as yr, FleetDispatchStreamOptions as yt, CreateSandboxFleetWithCoordinatorOptions as z, AgentProfileCapabilities as zi, RolloutStartResult as zn, SandboxTraceEvent as zr, GpuLeaseStatus as zt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox",
3
- "version": "0.10.5-develop.20260715163306.7ca6a55",
3
+ "version": "0.11.0",
4
4
  "description": "Client SDK for the Tangle Sandbox platform - build AI agent applications with dev containers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "dependencies": {
90
90
  "@tangle-network/agent-core": "^0.4.0",
91
- "@tangle-network/agent-interface": "^0.21.0"
91
+ "@tangle-network/agent-interface": "0.30.0"
92
92
  },
93
93
  "peerDependencies": {
94
94
  "@mastra/core": "^1.36.0",