@tangle-network/sandbox 0.30.2-develop.20260820100122.dc85046 → 0.30.2-develop.20260820200640.75917

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +1 -0
  2. package/dist/abort-signal-si1WMfJb.js +31 -0
  3. package/dist/agent/index.d.ts +3 -3
  4. package/dist/agent/index.js +3 -3
  5. package/dist/{agent-run-outcome-TwIC-Ccd.d.ts → agent-run-outcome-CM7xD7Mg.d.ts} +1 -1
  6. package/dist/auth/index.d.ts +1 -1
  7. package/dist/browser-interactive-control-controller-B476gcui.d.ts +96 -0
  8. package/dist/browser-interactive-control-controller-wXQ7W5pT.js +276 -0
  9. package/dist/{client-CCKEVUaD.js → client-BfnJ44gF.js} +19 -6
  10. package/dist/{client-1OK1sjCh.d.ts → client-Do_HS671.d.ts} +20 -3
  11. package/dist/collaboration/index.d.ts +1 -1
  12. package/dist/collaboration/index.js +1 -1
  13. package/dist/core.d.ts +4 -4
  14. package/dist/core.js +2 -2
  15. package/dist/{index-DAxioMfr.d.ts → index-ebsVOlUc.d.ts} +2 -2
  16. package/dist/index.d.ts +11 -9
  17. package/dist/index.js +7 -6
  18. package/dist/interactive-control.d.ts +2 -0
  19. package/dist/interactive-control.js +2 -0
  20. package/dist/{runtime-api-TVLbV10b.js → runtime-api-B0tx7NJM.js} +2 -6
  21. package/dist/runtime.d.ts +3 -3
  22. package/dist/runtime.js +2 -1
  23. package/dist/{sandbox-DM-VD8ja.js → sandbox-AUHcCJe1.js} +1418 -565
  24. package/dist/{sandbox-Caev7isY.d.ts → sandbox-Cr-4qzaA.d.ts} +134 -187
  25. package/dist/tangle/index.d.ts +1 -1
  26. package/dist/tangle/index.js +1 -1
  27. package/dist/{tangle-lzUyvhKp.js → tangle-iDk_s8vt.js} +1 -1
  28. package/dist/terminal-stream-4KNJ6SmL.d.ts +256 -0
  29. package/dist/{types-D_ykdqn6.d.ts → types-BwYLVqxX.d.ts} +14 -250
  30. package/package.json +9 -4
  31. /package/dist/{collaboration-COCXdRrk.js → collaboration-DQD9kCdN.js} +0 -0
  32. /package/dist/{errors-Bdy5jXzc.d.ts → errors-CQOvGddH.d.ts} +0 -0
  33. /package/dist/{index-DtRFVx5U.d.ts → index-Bq_z_u6A.d.ts} +0 -0
  34. /package/dist/{index-Cp1KYanB.d.ts → index-CMLW3u5K.d.ts} +0 -0
  35. /package/dist/{local-cli-auth-D4u7fsnH.js → local-cli-auth-CJmSpTjk.js} +0 -0
@@ -1,5 +1,7 @@
1
- import { $n as RolloutStartResult, Ai as SnapshotOptions, Ar as SandboxFleetTraceBundle, Bi as TaskSessionInfo, Br as SandboxInfo, Bt as GitCommit, Dn as ProcessManager, E as CodeLanguage, Ei as SnapshotDeleteAcknowledgement, Fn as ProvisionResult, Ft as ForkIdempotency, H as DispatchPromptOptions, Hi as TeeAttestationOptions, Hr as SandboxPortBinding, Ht as GitDiff, It as ForkLookupOptions, J as DriverInfo, Jn as ResumeOptions, Jr as SandboxStatus, K as DriveTurnOptions, Ki as TeePublicKeyResponse, Kr as SandboxRuntimeCapabilities, L as CreateSessionOptions, Li as TaskSessionChanges, Mn as PromptOptions, Ni as StartupDiagnostics, Nn as PromptResult, O as CommitTaskSessionOptions, Pn as ProvisionEvent, Pt as ForkCounts, R as CreateTaskSessionOptions, Ri as TaskSessionCommitResult, Si as SessionMessage, St as FileWriteResult, T as CodeExecutionResult, U as DispatchedSession, Ut as GitStatus, Wi as TeeAttestationResponse, Wr as SandboxResourceUsage, Wt as GpuLease, X as DurablePlan, Yi as TurnDriveResult, Yn as Rollout, Yr as SandboxTerminalAttachOptions, Yt as GpuLeaseManager, Z as DurablePlanDecisionResult, Zn as RolloutOptions, _a as TerminalStream, aa as WriteManyOptions, an as IntelligenceReportWindow, ar as SandboxConnection, ba as TerminalStreamHandlers, bi as SessionInterruptOptions, ci as SearchMatch, cr as SandboxDeleteAcknowledgement, ct as ExecOptions, d as BackendConfig, dr as SandboxEvent, ea as WaitForOptions, ei as SandboxTerminals, en as InstalledTool, fa as BackendType, fi as SendSessionMessageOptions, gi as SessionEventStreamOptions, gn as NetworkManager, gt as FileSystem, ia as WriteManyFile, ii as SandboxTraceOptions, ji as SnapshotResult, jn as PromptInputPart, k as CompletedTurnResult, ki as SnapshotInfo, li as SearchOptions, lt as ExecResult, mi as SentSessionMessage, na as WorkspaceOperationLookup, nn as IntelligenceReportBudget, nr as SSHCommandDescriptor, oi as ScopedToken, on as JsonValue, ot as EventStreamOptions, p as BackendManager, pi as SendSessionMessageRequest, pn as MintScopedTokenOptions, qn as RestoreSnapshotOptions, qr as SandboxRuntimeHealth, ra as WriteFileOptions, rn as IntelligenceReportCompareTo, rr as SSHCredentials, rt as EgressManager, sn as ListMessagesOptions, sr as SandboxCreateReceipt, ta as WaitForRolloutOptions, ti as SandboxTraceBundle, tn as IntelligenceReport, vi as SessionForkOptions, w as CodeExecutionOptions, wi as SessionResultOptions, x as BranchOptions, xi as SessionListOptions, xn as PreviewLinkManager, yi as SessionInfo, yn as PermissionsManager, zt as GitBranch } from "./types-D_ykdqn6.js";
2
- import { AgentProfile, AgentRunCancellationAcknowledgement, AgentRunCancellationRequest, InteractionAcknowledgement, InteractionData, InteractionRequest, InteractionResponseCommand } from "@tangle-network/agent-interface";
1
+ import { a as TerminalStreamReconnectAuthority, c as MintScopedTokenOptions, l as ScopedToken, t as TerminalStream } from "./terminal-stream-4KNJ6SmL.js";
2
+ import { a as InteractiveSessionControlController, c as InteractiveSessionIdentity, d as InteractiveAttachOptions, f as InteractiveControlClaimAcknowledgement, h as InteractiveSessionStatus, m as InteractiveRequestOptions, n as BrowserInteractiveSessionControlControllerOptions, o as InteractiveSessionControlControllerOptions, p as InteractiveControlClaimOptions, s as InteractiveSessionControlTransport } from "./browser-interactive-control-controller-B476gcui.js";
3
+ import { $i as WorkspaceOperationLookup, $r as SandboxTerminals, Ai as StartupDiagnostics, An as PromptInputPart, Bt as GitCommit, Ci as SnapshotDeleteAcknowledgement, Di as SnapshotOptions, E as CodeLanguage, Ei as SnapshotInfo, En as ProcessManager, Fi as TaskSessionCommitResult, Ft as ForkIdempotency, Gr as SandboxRuntimeCapabilities, H as DispatchPromptOptions, Ht as GitDiff, It as ForkLookupOptions, J as DriverInfo, Jn as Rollout, Jr as SandboxTerminalAttachOptions, K as DriveTurnOptions, Ki as TurnDriveResult, Kn as RestoreSnapshotOptions, Kr as SandboxRuntimeHealth, L as CreateSessionOptions, Li as TaskSessionInfo, Mn as PromptResult, Nn as ProvisionEvent, O as CommitTaskSessionOptions, Oi as SnapshotResult, Pi as TaskSessionChanges, Pn as ProvisionResult, Pt as ForkCounts, Qi as WaitForRolloutOptions, Qn as RolloutStartResult, R as CreateTaskSessionOptions, St as FileWriteResult, T as CodeExecutionResult, U as DispatchedSession, Ui as TeePublicKeyResponse, Ur as SandboxResourceUsage, Ut as GitStatus, Vi as TeeAttestationResponse, Vr as SandboxPortBinding, Wt as GpuLease, X as DurablePlan, Xn as RolloutOptions, Yt as GpuLeaseManager, Z as DurablePlanDecisionResult, Zi as WaitForOptions, _i as SessionInterruptOptions, ai as SearchMatch, an as IntelligenceReportWindow, bn as PreviewLinkManager, ct as ExecOptions, d as BackendConfig, di as SentSessionMessage, ea as WriteFileOptions, ei as SandboxTraceBundle, en as InstalledTool, gi as SessionInfo, gt as FileSystem, hi as SessionForkOptions, hn as NetworkManager, ir as SandboxConnection, jn as PromptOptions, k as CompletedTurnResult, kr as SandboxFleetTraceBundle, li as SendSessionMessageOptions, lt as ExecResult, na as WriteManyOptions, nn as IntelligenceReportBudget, nr as SSHCredentials, oi as SearchOptions, on as JsonValue, or as SandboxCreateReceipt, ot as EventStreamOptions, p as BackendManager, pi as SessionEventStreamOptions, qn as ResumeOptions, qr as SandboxStatus, ri as SandboxTraceOptions, rn as IntelligenceReportCompareTo, rt as EgressManager, sn as ListMessagesOptions, sr as SandboxDeleteAcknowledgement, ta as WriteManyFile, tn as IntelligenceReport, tr as SSHCommandDescriptor, ui as SendSessionMessageRequest, ur as SandboxEvent, vi as SessionListOptions, vn as PermissionsManager, w as CodeExecutionOptions, x as BranchOptions, xi as SessionResultOptions, yi as SessionMessage, zi as TeeAttestationOptions, zr as SandboxInfo, zt as GitBranch } from "./types-BwYLVqxX.js";
4
+ import { AgentInteractiveSessionControlClaim, AgentInteractiveSessionControlClaimAcknowledgement, AgentInteractiveSessionControlClaimRequest, AgentInteractiveSessionPromptAcknowledgement, AgentInteractiveSessionPromptCommand, AgentInteractiveSessionRef, AgentInteractiveSessionStart, AgentInteractiveSessionStopAcknowledgement, AgentInteractiveSessionStopCommand, AgentRunCancellationAcknowledgement, AgentRunCancellationRequest, InteractionAcknowledgement, InteractionData, InteractionRequest, InteractionResponseCommand, agentInteractiveSessionPromptRequestDigest } from "@tangle-network/agent-interface";
3
5
  import { z } from "zod";
4
6
 
5
7
  //#region src/mcp.d.ts
@@ -113,12 +115,9 @@ declare function buildControlPlaneMcpConfig(options: BuildControlPlaneMcpConfigO
113
115
  config: SandboxMcpConfig;
114
116
  };
115
117
  //#endregion
116
- //#region src/interaction-response.d.ts
117
- declare const REFUSED_INTERACTION_STATUS: z.ZodEnum<{
118
- already_resolved_different: "already_resolved_different";
119
- binding_mismatch: "binding_mismatch";
120
- }>;
121
- declare const InteractionResolutionSchema: z.ZodObject<{
118
+ //#region ../../../packages/runtime-contracts/dist/interaction-response.d.ts
119
+ /** Canonical result returned after a response is recorded by Sidecar. */
120
+ declare const interactionResolutionAcknowledgementSchema: z.ZodObject<{
122
121
  status: z.ZodEnum<{
123
122
  accepted: "accepted";
124
123
  already_resolved_same: "already_resolved_same";
@@ -132,6 +131,14 @@ declare const InteractionResolutionSchema: z.ZodObject<{
132
131
  declined: "declined";
133
132
  cancelled: "cancelled";
134
133
  }>;
134
+ deliveryState: z.ZodEnum<{
135
+ pending: "pending";
136
+ delivering: "delivering";
137
+ delivered: "delivered";
138
+ delivery_failed: "delivery_failed";
139
+ backend_lost: "backend_lost";
140
+ effect_unknown: "effect_unknown";
141
+ }>;
135
142
  delivered: z.ZodBoolean;
136
143
  resolvedAt: z.ZodString;
137
144
  binding: z.ZodOptional<z.ZodObject<{
@@ -144,7 +151,14 @@ declare const InteractionResolutionSchema: z.ZodObject<{
144
151
  interactionId: z.ZodString;
145
152
  }, z.core.$strict>>;
146
153
  }, z.core.$strict>;
147
- type SandboxInteractionResolution = z.infer<typeof InteractionResolutionSchema>;
154
+ type InteractionResolutionAcknowledgement = z.infer<typeof interactionResolutionAcknowledgementSchema>;
155
+ //#endregion
156
+ //#region src/interaction-response.d.ts
157
+ declare const REFUSED_INTERACTION_STATUS: z.ZodEnum<{
158
+ already_resolved_different: "already_resolved_different";
159
+ binding_mismatch: "binding_mismatch";
160
+ }>;
161
+ type SandboxInteractionResolution = InteractionResolutionAcknowledgement;
148
162
  type SandboxInteractionConflict = {
149
163
  status: z.infer<typeof REFUSED_INTERACTION_STATUS>;
150
164
  message: string;
@@ -159,177 +173,121 @@ interface SandboxInteractionCommandResult {
159
173
  serverResult?: SandboxInteractionResult;
160
174
  }
161
175
  //#endregion
162
- //#region src/interactive.d.ts
163
- /** CLI auth file materialized into the harness's auth home before launch. */
164
- interface InteractiveAuthFile {
165
- path: string;
166
- content: string;
167
- mode?: number;
176
+ //#region src/interactive-controller.d.ts
177
+ /** The request fields supplied by an attach caller before control is claimed. */
178
+ type InteractiveAttachRequest = Omit<InteractiveAttachOptions, "control">;
179
+ /** Transport used by the status → claim → WebSocket controller. */
180
+ interface InteractiveSessionControllerTransport extends InteractiveSessionControlTransport {
181
+ attach(sessionId: string, ref: AgentInteractiveSessionRef, request: InteractiveAttachOptions, options?: InteractiveRequestOptions, reconnectAuthority?: TerminalStreamReconnectAuthority): Promise<TerminalStream>;
168
182
  }
169
- interface StartInteractiveOptions {
170
- /**
171
- * Harness with a native interactive TUI (bare binary launches it): e.g.
172
- * "claude-code", "codex", "opencode", "kimi-code", "factory-droids",
173
- * "pi", "amp", "hermes". The sidecar's runner registry is the authority
174
- * and rejects values without a TUI entrypoint.
175
- */
176
- harness: BackendType;
177
- model?: string;
178
- apiKey?: string;
179
- authMode?: string;
180
- baseUrl?: string;
181
- /** Working directory; defaults to the sandbox workspace root. */
182
- cwd?: string;
183
- cols?: number;
184
- rows?: number;
185
- authFiles?: InteractiveAuthFile[];
186
- /**
187
- * Canonical agent profile (persona, skills, tool policy, MCP). When set, the
188
- * sidecar materializes it into `cwd` before spawning the TUI, so the
189
- * interactive session runs AS the configured agent rather than a bare harness.
190
- * Omit to launch the harness's default TUI.
191
- */
192
- profile?: AgentProfile;
193
- /**
194
- * Opening message the TUI submits on its own once ready (via the harness's
195
- * prompt launch arg). Use this to start the agent working immediately instead
196
- * of writing keystrokes after start — a TUI drops input sent before it is
197
- * ready to read. Omit for a session that opens idle.
198
- */
199
- initialPrompt?: string;
200
- }
201
- interface InteractiveSessionInfo {
202
- sessionId: string;
203
- harness: BackendType;
204
- /** ISO timestamp of when the harness process was spawned. */
205
- startedAt: string;
183
+ interface InteractiveSessionControllerOptions extends InteractiveSessionControlControllerOptions {}
184
+ /**
185
+ * Attach-capable controller for one exact interactive process.
186
+ *
187
+ * Control ownership lives in the dependency-light base controller. This layer
188
+ * adds only the terminal attach operation after that ownership is resolved.
189
+ */
190
+ declare class InteractiveSessionController extends InteractiveSessionControlController {
191
+ private readonly attachTransport;
192
+ private attachInFlight?;
193
+ constructor(attachTransport: InteractiveSessionControllerTransport, options: InteractiveSessionControllerOptions);
194
+ attach(request: InteractiveAttachRequest, requestOptions?: InteractiveRequestOptions): Promise<TerminalStream>;
206
195
  /**
207
- * Sandbox-relative WebSocket path that streams the live framebuffer and
208
- * accepts keystrokes (the mTLS- + capability-gated terminal socket).
196
+ * Open a stream for a claim returned by this controller's `resolve()`.
197
+ * The controller releases that claim when the stream cannot be opened.
209
198
  */
210
- streamUrl: string;
199
+ attachWithIdentity(identity: InteractiveSessionIdentity, request: InteractiveAttachRequest, requestOptions?: InteractiveRequestOptions): Promise<TerminalStream>;
211
200
  }
212
- /**
213
- * Snapshot of an interactive session's lifecycle: still running, or exited
214
- * with its exit code (served from the sidecar's bounded exit tombstone).
215
- * `status()` returns `null` when the sidecar no longer knows the id — never
216
- * started, tombstone evicted, or superseded by a restart under the same id.
217
- */
218
- type InteractiveSessionStatus = {
201
+ /** Browser transport options for the attach-capable controller. */
202
+ interface BrowserInteractiveSessionControllerOptions extends InteractiveSessionControllerOptions, BrowserInteractiveSessionControlControllerOptions {
203
+ /** Mint a future session-runtime token for every browser terminal dial. */
204
+ terminalTokenProvider?: (signal?: AbortSignal) => Promise<ScopedToken>;
205
+ }
206
+ /** Concrete controller for browser deep links and terminal attachment. */
207
+ declare class BrowserInteractiveSessionController extends InteractiveSessionController {
208
+ constructor(options: BrowserInteractiveSessionControllerOptions);
209
+ }
210
+ //#endregion
211
+ //#region src/interactive.d.ts
212
+ /** Exact start request sent to the Sandbox runtime. */
213
+ type InteractiveSessionStartOptions = AgentInteractiveSessionStart;
214
+ /** Exact identity of one admitted interactive process. */
215
+ type InteractiveSessionRef = AgentInteractiveSessionRef;
216
+ /** Incarnation identifier carried by an exact interactive reference. */
217
+ type InteractiveSessionIncarnationId = AgentInteractiveSessionRef["incarnationId"];
218
+ /** Write authority for one exact interactive process. */
219
+ type InteractiveSessionControlClaim = AgentInteractiveSessionControlClaim;
220
+ /** Published Interface prompt command. */
221
+ type InteractivePromptCommand = AgentInteractiveSessionPromptCommand;
222
+ /** Published Interface stop command. */
223
+ type InteractiveStopCommand = AgentInteractiveSessionStopCommand;
224
+ /** Published Interface control-claim request. */
225
+ type InteractiveControlClaimRequest = AgentInteractiveSessionControlClaimRequest;
226
+ interface InteractiveSessionInfo {
219
227
  state: "running";
220
- sessionId: string;
221
- harness: BackendType;
222
- startedAt: string;
228
+ ref: AgentInteractiveSessionRef;
229
+ control: AgentInteractiveSessionControlClaim;
223
230
  streamUrl: string;
224
- } | {
231
+ }
232
+ interface InteractiveSessionExitInfo {
225
233
  state: "exited";
226
- sessionId: string;
227
- harness: BackendType;
228
- startedAt: string;
234
+ ref: AgentInteractiveSessionRef;
235
+ control: AgentInteractiveSessionControlClaim;
229
236
  endedAt: string;
230
237
  exitCode?: number;
231
238
  exitSignal?: string;
232
- /**
233
- * "exited" = the process ended on its own; "stopped" = explicit stop();
234
- * "lost" = the session was interrupted by a sidecar restart mid-run (its
235
- * PTY died with the process) and re-hydrated as a durable tombstone rather
236
- * than reported as a 404/null. A "lost" session is a failed run.
237
- */
238
239
  reason: "exited" | "stopped" | "lost";
239
- };
240
- /** Options for `InteractiveSessionHandle.attach()`. */
241
- interface InteractiveAttachOptions {
242
- /** Initial PTY geometry reported in the attach init frame. */
243
- cols?: number;
244
- rows?: number;
245
- /**
246
- * Stream callbacks, bound before the socket opens. Register `onData` here:
247
- * the server replays the session's buffered screen immediately after the
248
- * attach acknowledgement, so a handler added after `attach()` resolves
249
- * would miss the replayed frames.
250
- */
251
- handlers?: TerminalStreamHandlers;
240
+ }
241
+ type InteractiveSessionStartResult = InteractiveSessionInfo | InteractiveSessionExitInfo;
242
+ /** Identity required to reconstruct a handle after a process boundary. */
243
+ interface InteractiveSessionHandleOptions {
244
+ ref?: AgentInteractiveSessionRef;
245
+ control?: AgentInteractiveSessionControlClaim;
252
246
  }
253
247
  /** Decision passed to `respondToPermission`. */
254
248
  interface RespondToPermissionOptions {
255
- /** The human's decision for the awaiting permission interaction. */
256
249
  response: "allow" | "deny";
257
250
  signal?: AbortSignal;
258
251
  }
259
252
  /** Result of `interrupt`. */
260
253
  interface InterruptResult {
261
- /**
262
- * True iff an execution was actively running and the abort signal reached
263
- * it. `false` means there was nothing in flight to cancel — surfaced
264
- * explicitly rather than as a silent success so callers can distinguish a
265
- * real interruption from a no-op.
266
- */
267
254
  cancelled: boolean;
268
255
  }
269
- /**
270
- * Host hooks the SDK box implements to drive interactive sessions. Kept
271
- * separate from the prompt/session-event host so the interactive surface is an
272
- * explicit, independently-mockable contract.
273
- */
256
+ /** Host hooks implemented by the Sandbox client. */
274
257
  interface InteractiveSessionHost {
275
- _startInteractive(id: string, options: StartInteractiveOptions): Promise<InteractiveSessionInfo>;
276
- _sendInteractivePrompt(id: string, prompt: string): Promise<void>;
277
- _stopInteractive(id: string): Promise<void>;
278
- /**
279
- * Optional so adding it does not break existing implementers of this exported
280
- * interface (a required addition is a breaking change; this is additive). A
281
- * host that omits it makes `InteractiveSessionHandle.status()` reject with a
282
- * clear "not supported" error instead of failing to compile downstream.
283
- */
284
- _interactiveStatus?(id: string): Promise<InteractiveSessionStatus | null>;
285
- /**
286
- * Optional for the same additive-change reason as `_interactiveStatus`. A
287
- * host that omits it makes `InteractiveSessionHandle.attach()` reject with
288
- * a clear "not supported" error.
289
- */
290
- _attachInteractive?(id: string, options?: InteractiveAttachOptions): Promise<TerminalStream>;
258
+ _startInteractive(id: string, options: InteractiveSessionStartOptions, requestOptions?: InteractiveRequestOptions): Promise<InteractiveSessionStartResult>;
259
+ _sendInteractivePrompt(id: string, command: InteractivePromptCommand, options?: InteractiveRequestOptions): Promise<AgentInteractiveSessionPromptAcknowledgement>;
260
+ _stopInteractive(id: string, command: InteractiveStopCommand, options?: InteractiveRequestOptions): Promise<AgentInteractiveSessionStopAcknowledgement>;
261
+ _stopInteractiveLifecycle(id: string, ref: AgentInteractiveSessionRef, options?: InteractiveRequestOptions): Promise<AgentInteractiveSessionStopAcknowledgement>;
262
+ _claimInteractiveControl(id: string, request: InteractiveControlClaimRequest, options?: InteractiveControlClaimOptions): Promise<InteractiveControlClaimAcknowledgement>;
263
+ _releaseInteractiveControl(id: string, ref: AgentInteractiveSessionRef, control: AgentInteractiveSessionControlClaim, options?: InteractiveRequestOptions): Promise<void>;
264
+ _interactiveStatus(id: string, incarnationId: string, options?: InteractiveRequestOptions): Promise<InteractiveSessionStatus | null>;
265
+ _attachInteractive(id: string, ref: AgentInteractiveSessionRef, request: InteractiveAttachOptions, options?: InteractiveRequestOptions, reconnectAuthority?: TerminalStreamReconnectAuthority): Promise<TerminalStream>;
291
266
  }
292
267
  /**
293
- * Handle for one session's interactive harness. Obtained via
294
- * `box.session(id).interactive()`; does not hit the network until a method is
295
- * called.
268
+ * Handle for one exact interactive harness session.
269
+ *
270
+ * `start()` binds the returned ref and control for prompt and stop commands.
271
+ * Attach always observes and claims a fresh control before opening its stream.
296
272
  */
297
273
  declare class InteractiveSessionHandle {
298
274
  private readonly host;
299
275
  private readonly sessionId;
300
- constructor(host: InteractiveSessionHost, sessionId: string);
301
- /**
302
- * Spawn the harness's interactive TUI for this session. Returns the
303
- * `streamUrl` of the live framebuffer — open it programmatically with
304
- * `attach()`, or hand it to a terminal frontend. Throws if the harness has
305
- * no interactive entrypoint (e.g. cursor, which is SDK-only), the binary is
306
- * not installed, or a session is already running for this id.
307
- */
308
- start(options: StartInteractiveOptions): Promise<InteractiveSessionInfo>;
309
- /** Inject a prompt as keystrokes into the live harness (submitted on send). */
310
- sendPrompt(prompt: string): Promise<void>;
311
- /**
312
- * Attach to the live harness PTY as a {@link TerminalStream}: the same PTY
313
- * the interactive TUI runs in (the sidecar keys it by this session id), so
314
- * the stream sees the harness's screen and its keystrokes drive the
315
- * harness — never a fresh shell. The host mints a short-lived scoped
316
- * terminal token and dials the session's `streamUrl` through the secured
317
- * sidecar proxy; resolves once the server acknowledges the attach (the
318
- * buffered screen then replays through `handlers.onData`).
319
- *
320
- * Throws when no interactive session is running for this id — attach after
321
- * `start()`, or to a session another caller started.
322
- */
323
- attach(options?: InteractiveAttachOptions): Promise<TerminalStream>;
324
- /**
325
- * Observe the session: running, exited (with its exit code), or `null`
326
- * when the sidecar no longer knows the id. Poll this to detect completion —
327
- * an interactive session has no structured result stream, so the exit
328
- * tombstone is the completion signal.
329
- */
330
- status(): Promise<InteractiveSessionStatus | null>;
331
- /** Stop the interactive harness and reap its PTY. */
332
- stop(): Promise<void>;
276
+ private ref?;
277
+ private control?;
278
+ private readonly attachHolderId;
279
+ private attachController?;
280
+ private attachInFlight?;
281
+ constructor(host: InteractiveSessionHost, sessionId: string, options?: InteractiveSessionHandleOptions);
282
+ start(options: InteractiveSessionStartOptions, requestOptions?: InteractiveRequestOptions): Promise<InteractiveSessionStartResult>;
283
+ private requireBinding;
284
+ private requireRef;
285
+ sendPrompt(command: InteractivePromptCommand, options?: InteractiveRequestOptions): Promise<AgentInteractiveSessionPromptAcknowledgement>;
286
+ attach(request?: InteractiveAttachRequest, options?: InteractiveRequestOptions): Promise<TerminalStream>;
287
+ status(options?: InteractiveRequestOptions): Promise<InteractiveSessionStatus | null>;
288
+ claimControl(request: InteractiveControlClaimRequest, options?: InteractiveControlClaimOptions): Promise<InteractiveControlClaimAcknowledgement>;
289
+ stop(command: InteractiveStopCommand, options?: InteractiveRequestOptions): Promise<AgentInteractiveSessionStopAcknowledgement>;
290
+ stopLifecycle(options?: InteractiveRequestOptions): Promise<AgentInteractiveSessionStopAcknowledgement>;
333
291
  }
334
292
  //#endregion
335
293
  //#region src/session.d.ts
@@ -447,7 +405,7 @@ declare class SandboxSession {
447
405
  * from the headless `prompt()`/`events()` surface above. Lazy — does not hit
448
406
  * the network until a handle method is called.
449
407
  */
450
- interactive(): InteractiveSessionHandle;
408
+ interactive(options?: InteractiveSessionHandleOptions): InteractiveSessionHandle;
451
409
  /**
452
410
  * Resolve a pending permission interaction the agent raised mid-turn,
453
411
  * forwarding `allow`/`deny` to the blocked agent through the unified
@@ -681,6 +639,10 @@ declare class SandboxInstance {
681
639
  private readonly defaultRuntimeBackend?;
682
640
  private readonly runtime;
683
641
  private readonly workspaceImages;
642
+ private readonly interactiveOperations;
643
+ private readonly interactiveTerminalOperations;
644
+ /** @internal Test seam for terminal attach unit tests. */
645
+ private _terminalStreamConnect;
684
646
  /**
685
647
  * A profile the runtime has cached (create-time priming), letting turns
686
648
  * send `backend.profileSha256` instead of re-shipping the profile's static
@@ -814,7 +776,7 @@ declare class SandboxInstance {
814
776
  /**
815
777
  * Refresh sandbox information from the server.
816
778
  */
817
- refresh(): Promise<void>;
779
+ refresh(signal?: AbortSignal): Promise<void>;
818
780
  private refreshInfo;
819
781
  /**
820
782
  * Fetch fresh TEE attestation evidence for this sandbox.
@@ -1898,39 +1860,24 @@ declare class SandboxInstance {
1898
1860
  private _executionEvents;
1899
1861
  /** @internal — invoked by SandboxSession.result(). */
1900
1862
  _sessionResult(id: string, options?: SessionResultOptions, knownSession?: SessionInfo): Promise<PromptResult>;
1901
- /** @internal — invoked by InteractiveSessionHandle.start(). */
1902
- _startInteractive(id: string, options: StartInteractiveOptions): Promise<InteractiveSessionInfo>;
1903
- /** @internal — invoked by InteractiveSessionHandle.sendPrompt(). */
1904
- _sendInteractivePrompt(id: string, prompt: string): Promise<void>;
1905
- /** @internal — invoked by InteractiveSessionHandle.status(). */
1906
- _interactiveStatus(id: string): Promise<InteractiveSessionStatus | null>;
1907
- /**
1908
- * @internal Test seam: unit tests replace this to intercept terminal
1909
- * WebSocket dials without opening a real socket. Production paths always
1910
- * go through `TerminalStream.connect`.
1911
- */
1912
- private _terminalStreamConnect;
1913
- /**
1914
- * Resolve a sandbox-relative terminal stream path against the browser-safe
1915
- * sidecar proxy base returned by the scoped-token mint. Concatenation, not
1916
- * URL resolution: the proxy base carries a path prefix
1917
- * (`/v1/sidecar-proxy/{id}`) that `new URL(absolutePath, base)` would drop.
1918
- */
1919
- private resolveTerminalStreamUrl;
1920
- /** @internal — invoked by InteractiveSessionHandle.attach(). */
1921
- _attachInteractive(id: string, options?: InteractiveAttachOptions): Promise<TerminalStream>;
1922
- /**
1923
- * Per-dial credential for a terminal attach. The first dial consumes the
1924
- * token minted alongside the proxy URL (no second mint); every later dial
1925
- * (a `reconnect()` after the socket dropped or the detach window) re-mints,
1926
- * because scoped terminal tokens are clamped to a <= 15-minute TTL and the
1927
- * original is likely dead by then.
1928
- */
1929
- private terminalTokenProvider;
1930
- /** @internal — invoked by `box.terminals.attach()`. */
1863
+ /** @internal — delegated to the native interactive operations module. */
1864
+ _startInteractive(id: string, options: InteractiveSessionStartOptions, requestOptions?: InteractiveRequestOptions): Promise<InteractiveSessionStartResult>;
1865
+ /** @internal — delegated to the native interactive operations module. */
1866
+ _sendInteractivePrompt(id: string, command: InteractivePromptCommand, options?: InteractiveRequestOptions): Promise<AgentInteractiveSessionPromptAcknowledgement>;
1867
+ /** @internal — delegated to the native interactive operations module. */
1868
+ _claimInteractiveControl(id: string, request: AgentInteractiveSessionControlClaimRequest, options?: InteractiveControlClaimOptions): Promise<AgentInteractiveSessionControlClaimAcknowledgement>;
1869
+ /** @internal — delegated to the native interactive operations module. */
1870
+ _releaseInteractiveControl(id: string, ref: AgentInteractiveSessionRef, control: AgentInteractiveSessionControlClaim, options?: InteractiveRequestOptions): Promise<void>;
1871
+ /** @internal — delegated to the native interactive operations module. */
1872
+ _interactiveStatus(id: string, incarnationId: string, options?: InteractiveRequestOptions): Promise<InteractiveSessionStatus | null>;
1873
+ /** @internal — delegated to the native interactive operations module. */
1874
+ _attachInteractive(id: string, ref: AgentInteractiveSessionRef, request: InteractiveAttachOptions, options?: InteractiveRequestOptions, reconnectAuthority?: TerminalStreamReconnectAuthority): Promise<TerminalStream>;
1875
+ /** @internal — delegated to the native interactive operations module. */
1931
1876
  _attachTerminal(connectionId: string, options?: SandboxTerminalAttachOptions): Promise<TerminalStream>;
1932
- /** @internal — invoked by InteractiveSessionHandle.stop(). */
1933
- _stopInteractive(id: string): Promise<void>;
1877
+ /** @internal — delegated to the native interactive operations module. */
1878
+ _stopInteractive(id: string, command: InteractiveStopCommand, options?: InteractiveRequestOptions): Promise<AgentInteractiveSessionStopAcknowledgement>;
1879
+ /** @internal — delegated to the native interactive operations module. */
1880
+ _stopInteractiveLifecycle(id: string, ref: AgentInteractiveSessionRef, options?: InteractiveRequestOptions): Promise<AgentInteractiveSessionStopAcknowledgement>;
1934
1881
  private interactionTransport;
1935
1882
  /** @internal — invoked by SandboxSession.interactions(). */
1936
1883
  _listInteractions(id: string, options?: {
@@ -1963,4 +1910,4 @@ declare class SandboxInstance {
1963
1910
  }): Promise<DurablePlanDecisionResult>;
1964
1911
  }
1965
1912
  //#endregion
1966
- export { BuildControlPlaneMcpConfigOptions as A, InterruptResult as C, SandboxInteractionConflict as D, SandboxInteractionCommandResult as E, SandboxMcpEndpoint as F, SandboxMcpServerEntry as I, buildControlPlaneMcpConfig as L, CONTROL_PLANE_MCP_SERVER_NAME as M, SANDBOX_MCP_SERVER_NAME as N, SandboxInteractionResolution as O, SandboxMcpConfig as P, buildSandboxMcpConfig as R, InteractiveSessionStatus as S, StartInteractiveOptions as T, InteractiveAttachOptions as _, WorkspaceImagePublishRequestOptions as a, InteractiveSessionHost as b, TraceExportFormat as c, buildTraceExportPayload as d, exportTraceBundle as f, SandboxSession as g, SandboxTaskSession as h, WorkspaceImagePublishInput as i, BuildSandboxMcpConfigOptions as j, SandboxInteractionResult as k, TraceExportResult as l, toOtelJson as m, HttpClient as n, WorkspaceImagePublishResult as o, otelTraceIdForTangleTrace as p, SandboxInstance as r, WorkspaceImages as s, ForkAcknowledgement as t, TraceExportSink as u, InteractiveAuthFile as v, RespondToPermissionOptions as w, InteractiveSessionInfo as x, InteractiveSessionHandle as y };
1913
+ export { RespondToPermissionOptions as A, SandboxInteractionResolution as B, InteractiveSessionIncarnationId as C, InteractiveSessionStartResult as D, InteractiveSessionStartOptions as E, InteractiveSessionController as F, SANDBOX_MCP_SERVER_NAME as G, BuildControlPlaneMcpConfigOptions as H, InteractiveSessionControllerOptions as I, SandboxMcpServerEntry as J, SandboxMcpConfig as K, InteractiveSessionControllerTransport as L, BrowserInteractiveSessionController as M, BrowserInteractiveSessionControllerOptions as N, InteractiveStopCommand as O, InteractiveAttachRequest as P, SandboxInteractionCommandResult as R, InteractiveSessionHost as S, InteractiveSessionRef as T, BuildSandboxMcpConfigOptions as U, SandboxInteractionResult as V, CONTROL_PLANE_MCP_SERVER_NAME as W, buildSandboxMcpConfig as X, buildControlPlaneMcpConfig as Y, InteractiveControlClaimRequest as _, WorkspaceImagePublishRequestOptions as a, InteractiveSessionHandle as b, TraceExportFormat as c, buildTraceExportPayload as d, exportTraceBundle as f, SandboxSession as g, SandboxTaskSession as h, WorkspaceImagePublishInput as i, agentInteractiveSessionPromptRequestDigest as j, InterruptResult as k, TraceExportResult as l, toOtelJson as m, HttpClient as n, WorkspaceImagePublishResult as o, otelTraceIdForTangleTrace as p, SandboxMcpEndpoint as q, SandboxInstance as r, WorkspaceImages as s, ForkAcknowledgement as t, TraceExportSink as u, InteractivePromptCommand as v, InteractiveSessionInfo as w, InteractiveSessionHandleOptions as x, InteractiveSessionControlClaim as y, SandboxInteractionConflict as z };
@@ -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-DAxioMfr.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-ebsVOlUc.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-lzUyvhKp.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-iDk_s8vt.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
1
  import { m as parseErrorResponse } from "./errors-C6kn-3zt.js";
2
- import { n as createSandboxInstanceFromResponse } from "./sandbox-DM-VD8ja.js";
2
+ import { n as createSandboxInstanceFromResponse } from "./sandbox-AUHcCJe1.js";
3
3
  //#region src/tangle/abi.ts
4
4
  /**
5
5
  * Tangle Contract ABI Definitions