@tangle-network/sandbox 0.15.3-develop.20260731071553.b437581 → 0.17.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,4 +1,4 @@
1
- import { a as uploadChunked, c as combineAbortSignals, d as applyRequestedModel, f as assertCurrentBackendType, i as sessionHeaders, l as encodePromptForWire, n as normalizeSessionInfo, p as normalizeRuntimeBackendConfig, r as appendSessionIdQuery, t as SandboxRuntimeApi } from "./runtime-api-BWC3U-qO.js";
1
+ import { a as uploadChunked, c as combineAbortSignals, d as applyRequestedModel, f as assertCurrentBackendType, i as sessionHeaders, l as encodePromptForWire, n as normalizeSessionInfo, p as normalizeRuntimeBackendConfig, r as appendSessionIdQuery, t as SandboxRuntimeApi } from "./runtime-api-O5VW0tcU.js";
2
2
  import { a as NetworkError, c as QuotaError, d as StateError, f as TimeoutError, l as SandboxError, m as parseErrorResponse, n as CapabilityError, o as NotFoundError, p as ValidationError, t as AuthError, u as ServerError } from "./errors-Bf-A-4SA.js";
3
3
  import { readTokenCostUsd, readTokenUsage } from "@tangle-network/agent-core";
4
4
  //#region src/lib/sse-parser.ts
@@ -512,8 +512,9 @@ var InteractiveSessionHandle = class {
512
512
  * routes: `status` reads `GET /agents/sessions/{id}`, `events` opens an
513
513
  * SSE stream against `/agents/events?sessionId=...` (with `since` for
514
514
  * replay), `prompt` continues the session via `/agents/run/stream`,
515
- * `interrupt` calls `/agents/sessions/{id}/abort`. No new sidecar surface
516
- * is required — every endpoint already exists.
515
+ * `interrupt` calls `/agents/sessions/{id}/abort` by default or the
516
+ * execution-scoped cancel route when an execution id is supplied. No new
517
+ * sidecar surface is required — every endpoint already exists.
517
518
  *
518
519
  * Construction is private to the SDK: get a Session from
519
520
  * `box.session(id)` (lazy reference, no network) or `box.sessions(...)`
@@ -555,16 +556,15 @@ var SandboxSession = class SandboxSession {
555
556
  return this.box._sessionEvents(this.id, opts);
556
557
  }
557
558
  /**
558
- * Await the session's terminal result. Reads status and drains events
559
- * from the latest execution until the session reaches a terminal state,
560
- * then returns the aggregated `PromptResult`. Event replay makes this safe
561
- * to call after the execution has already finished.
559
+ * Await a terminal result. With `executionId`, drains only that execution;
560
+ * without it, reads status and selects the latest execution. Event replay
561
+ * makes either form safe after the execution has already finished.
562
562
  *
563
563
  * Use this to wait for a session that was started by another caller
564
564
  * (e.g. `dispatchPrompt`).
565
565
  */
566
- async result() {
567
- return this.box._sessionResult(this.id);
566
+ async result(options) {
567
+ return options ? this.box._sessionResult(this.id, options) : this.box._sessionResult(this.id);
568
568
  }
569
569
  /**
570
570
  * List persisted messages for this session, including in-flight assistant
@@ -630,12 +630,13 @@ var SandboxSession = class SandboxSession {
630
630
  return this.box._respondToPermission(this.id, permissionID, options);
631
631
  }
632
632
  /**
633
- * Interrupt the session's current execution without deleting it. Returns
634
- * `{ cancelled: false }` when nothing was running — the no-op is reported
635
- * explicitly rather than masked as success.
633
+ * Interrupt an execution without deleting the session. Pass `executionId`
634
+ * to make the cancellation exact: a newer run on the same session is never
635
+ * touched. Without it, the current execution is selected. Returns
636
+ * `{ cancelled: false }` when the selected execution is not running.
636
637
  */
637
- async interrupt() {
638
- return this.box._interrupt(this.id);
638
+ async interrupt(options) {
639
+ return options ? this.box._interrupt(this.id, options) : this.box._interrupt(this.id);
639
640
  }
640
641
  /**
641
642
  * Answer a question the agent asked via a question tool invocation. `answers`
@@ -2164,6 +2165,7 @@ var SandboxInstance = class SandboxInstance {
2164
2165
  let responseText;
2165
2166
  let runError;
2166
2167
  let runErrorCode;
2168
+ let executionId = options?.lastEventId ? options.executionId : void 0;
2167
2169
  let traceId;
2168
2170
  let usage;
2169
2171
  let costUsd;
@@ -2179,6 +2181,8 @@ var SandboxInstance = class SandboxInstance {
2179
2181
  signal
2180
2182
  })) {
2181
2183
  responseText = applySandboxEventText(responseText, event);
2184
+ const eventExecutionId = event.data.executionId;
2185
+ if (typeof eventExecutionId === "string" && eventExecutionId.length > 0) executionId = eventExecutionId;
2182
2186
  if (event.type === "result" || event.type === "done") {
2183
2187
  usage = readTokenUsage(event.data) ?? usage;
2184
2188
  costUsd = readTokenCostUsd(event.data) ?? costUsd;
@@ -2206,6 +2210,7 @@ var SandboxInstance = class SandboxInstance {
2206
2210
  return {
2207
2211
  success: outcome.success,
2208
2212
  status: outcome.status,
2213
+ ...executionId ? { executionId } : {},
2209
2214
  response: responseText,
2210
2215
  error: outcome.error,
2211
2216
  errorCode: outcome.errorCode,
@@ -2222,6 +2227,7 @@ var SandboxInstance = class SandboxInstance {
2222
2227
  return {
2223
2228
  success: false,
2224
2229
  status: "failed",
2230
+ ...executionId ? { executionId } : {},
2225
2231
  error: err instanceof Error ? err.message : String(err),
2226
2232
  durationMs: Date.now() - startTime
2227
2233
  };
@@ -2323,7 +2329,7 @@ var SandboxInstance = class SandboxInstance {
2323
2329
  const isCallerAbort = () => options?.signal?.aborted === true;
2324
2330
  let receivedTerminal = false;
2325
2331
  let sessionId = options?.sessionId;
2326
- let executionId = options?.executionId;
2332
+ let executionId = options?.lastEventId ? options.executionId : void 0;
2327
2333
  let profileResendAttempted = false;
2328
2334
  try {
2329
2335
  for (;;) {
@@ -3887,24 +3893,22 @@ var SandboxInstance = class SandboxInstance {
3887
3893
  }
3888
3894
  }
3889
3895
  /**
3890
- * Network manager for runtime network configuration.
3891
- *
3892
- * @example Update network restrictions
3893
- * ```typescript
3894
- * // Block all outbound traffic
3895
- * await box.network.update({ blockOutbound: true });
3896
+ * Port exposure and runtime network state.
3896
3897
  *
3897
- * // Or switch to allowlist mode
3898
- * await box.network.update({
3899
- * allowList: ["192.168.1.0/24", "8.8.8.8/32"]
3900
- * });
3901
- * ```
3898
+ * Outbound restrictions are on {@link SandboxInstance.egress}: `update()`
3899
+ * here rejects every policy field rather than recording one nothing
3900
+ * enforces.
3902
3901
  *
3903
3902
  * @example Expose ports dynamically
3904
3903
  * ```typescript
3905
3904
  * const url = await box.network.exposePort(8000);
3906
3905
  * console.log(`Service available at: ${url}`);
3907
3906
  * ```
3907
+ *
3908
+ * @example Restrict outbound traffic
3909
+ * ```typescript
3910
+ * await box.egress.update({ mode: "blocked" });
3911
+ * ```
3908
3912
  */
3909
3913
  get network() {
3910
3914
  return {
@@ -3925,6 +3929,7 @@ var SandboxInstance = class SandboxInstance {
3925
3929
  *
3926
3930
  * @example Update egress policy at runtime
3927
3931
  * ```typescript
3932
+ * // strict reaches these plus the sandbox's own model endpoint, nothing else.
3928
3933
  * await box.egress.update({ mode: "strict", allowDomains: ["api.github.com"] });
3929
3934
  * ```
3930
3935
  */
@@ -5119,14 +5124,14 @@ var SandboxInstance = class SandboxInstance {
5119
5124
  * already in flight or already finished — never on the mere existence
5120
5125
  * of a session with the same id:
5121
5126
  *
5122
- * 1. The session is in flight — `running`, or `queued` with a
5123
- * `latestExecutionId` — → a second dispatch would run two agents
5124
- * against one session, so return the live status with
5125
- * `dispatched: false`.
5126
- * 2. `opts.turnId` is set and the completed-turn cache has it → the
5127
+ * 1. `opts.turnId` is set and the completed-turn cache has it → the
5127
5128
  * turn already finished; return `dispatched: false`. This is the
5128
5129
  * only durable idempotency key, and it outlives the session (the
5129
5130
  * cache survives session eviction, see `findCompletedTurn`).
5131
+ * 2. Otherwise, the session is in flight — `running`, or `queued` with a
5132
+ * `latestExecutionId` — → a second dispatch would run two agents
5133
+ * against one session, so return the live status with
5134
+ * `dispatched: false`.
5130
5135
  *
5131
5136
  * Anything else dispatches. Two cases in particular:
5132
5137
  *
@@ -5150,17 +5155,26 @@ var SandboxInstance = class SandboxInstance {
5150
5155
  let existing = null;
5151
5156
  if (opts?.sessionId) {
5152
5157
  existing = await this._sessionStatus(opts.sessionId);
5153
- if (existing && isSessionInFlight(existing)) return {
5154
- sessionId: existing.id,
5155
- status: existing.status,
5156
- alreadyExisted: true,
5157
- dispatched: false
5158
- };
5159
5158
  if (opts.turnId) {
5160
- if (await this.findCompletedTurn(opts.turnId, { sessionId: opts.sessionId })) return {
5161
- sessionId: existing?.id ?? opts.sessionId,
5162
- status: existing?.status ?? "completed",
5163
- alreadyExisted: existing !== null,
5159
+ const cached = await this.findCompletedTurn(opts.turnId, { sessionId: opts.sessionId });
5160
+ if (cached) {
5161
+ const cachedExecutionId = typeof cached.result.executionId === "string" && cached.result.executionId.length > 0 ? cached.result.executionId : void 0;
5162
+ return {
5163
+ sessionId: existing?.id ?? opts.sessionId,
5164
+ ...cachedExecutionId ? { executionId: cachedExecutionId } : {},
5165
+ status: existing?.status ?? "completed",
5166
+ alreadyExisted: existing !== null,
5167
+ dispatched: false
5168
+ };
5169
+ }
5170
+ }
5171
+ if (existing && isSessionInFlight(existing)) {
5172
+ const existingExecutionId = existing.activeExecutionId ?? existing.latestExecutionId;
5173
+ return {
5174
+ sessionId: existing.id,
5175
+ ...existingExecutionId ? { executionId: existingExecutionId } : {},
5176
+ status: existing.status,
5177
+ alreadyExisted: true,
5164
5178
  dispatched: false
5165
5179
  };
5166
5180
  }
@@ -5172,20 +5186,29 @@ var SandboxInstance = class SandboxInstance {
5172
5186
  signal: ctrl.signal
5173
5187
  });
5174
5188
  let resolvedSessionId = opts?.sessionId;
5189
+ let resolvedExecutionId;
5190
+ let admissionObserved = false;
5191
+ let dispatchError;
5175
5192
  try {
5176
5193
  for await (const event of stream) {
5177
- const id = event.data?.sessionId;
5178
- if (typeof id === "string" && id.length > 0) {
5179
- resolvedSessionId = id;
5180
- break;
5194
+ const data = event.data;
5195
+ if (event.type === "error") dispatchError = typeof data?.message === "string" ? data.message : "sandbox rejected the prompt before admission";
5196
+ if (event.type === "execution.started") {
5197
+ const id = data?.sessionId;
5198
+ const executionId = data?.executionId;
5199
+ if (typeof executionId === "string" && executionId.length > 0) resolvedExecutionId = executionId;
5200
+ if (typeof id === "string" && id.length > 0) resolvedSessionId = id;
5201
+ admissionObserved = Boolean(resolvedSessionId && resolvedExecutionId);
5181
5202
  }
5203
+ if (admissionObserved || event.type === "result" || event.type === "done") break;
5182
5204
  }
5183
5205
  } finally {
5184
5206
  ctrl.abort();
5185
5207
  }
5186
- if (!resolvedSessionId) throw new ServerError("dispatchPrompt did not receive a session id from the sandbox");
5208
+ if (!admissionObserved || !resolvedSessionId || !resolvedExecutionId) throw new ServerError(dispatchError ?? "dispatchPrompt did not receive an execution admission from the sandbox");
5187
5209
  return {
5188
5210
  sessionId: resolvedSessionId,
5211
+ ...resolvedExecutionId ? { executionId: resolvedExecutionId } : {},
5189
5212
  status: "running",
5190
5213
  alreadyExisted: existing !== null,
5191
5214
  dispatched: true
@@ -5305,7 +5328,7 @@ var SandboxInstance = class SandboxInstance {
5305
5328
  const startedAt = info.startedAt ?? info.createdAt;
5306
5329
  const elapsedMs = startedAt ? Date.now() - startedAt.getTime() : void 0;
5307
5330
  if (opts.wallCapMs !== void 0 && elapsedMs !== void 0 && elapsedMs > opts.wallCapMs) {
5308
- await this._interrupt(opts.sessionId);
5331
+ await this._interrupt(opts.sessionId, info.activeExecutionId ? { executionId: info.activeExecutionId } : void 0);
5309
5332
  return {
5310
5333
  state: "failed",
5311
5334
  error: `session ${opts.sessionId} exceeded the ${opts.wallCapMs}ms wall-clock cap and was cancelled`
@@ -5322,7 +5345,7 @@ var SandboxInstance = class SandboxInstance {
5322
5345
  state: "failed",
5323
5346
  error: `session ${opts.sessionId} ${info.status}: no execution result is available`
5324
5347
  };
5325
- const result = await this._sessionResult(opts.sessionId, info);
5348
+ const result = await this._sessionResult(opts.sessionId, { executionId: info.latestExecutionId }, info);
5326
5349
  const settled = settleTurnDrive({ ...result });
5327
5350
  if (settled.state === "awaiting_plan_decision") return settled;
5328
5351
  if (!result.success) return {
@@ -5399,18 +5422,42 @@ var SandboxInstance = class SandboxInstance {
5399
5422
  if ((stopOnTurnTerminal || opts?.executionId !== void 0) && turnTerminal) return;
5400
5423
  }
5401
5424
  }
5425
+ /** Replay one execution without subscribing to other runs on its session. */
5426
+ async *_executionEvents(sessionId, executionId) {
5427
+ await this.ensureRunning();
5428
+ const search = new URLSearchParams({
5429
+ lastEventId: "0",
5430
+ format: "sse",
5431
+ sessionId
5432
+ });
5433
+ const response = await this.runtimeFetch(`/agents/run/${encodeURIComponent(executionId)}/events?${search.toString()}`);
5434
+ if (!response.ok) {
5435
+ const body = await response.text();
5436
+ throw parseErrorResponse(response.status, body, void 0, response.headers);
5437
+ }
5438
+ for await (const event of this.parseSSEStream(response)) {
5439
+ yield event;
5440
+ if (event.type === "result" || event.type === "done" || event.type === "error") return;
5441
+ }
5442
+ }
5402
5443
  /** @internal — invoked by SandboxSession.result(). */
5403
- async _sessionResult(id, knownSession) {
5444
+ async _sessionResult(id, options, knownSession) {
5445
+ if (options?.executionId !== void 0 && !options.executionId) throw new ValidationError("executionId must not be empty", { executionId: "Expected a non-empty runtime execution id" });
5404
5446
  const startTime = Date.now();
5405
- const session = knownSession ?? await this._sessionStatus(id);
5406
- if (!session) throw new NotFoundError("Session", id, {
5407
- origin: "runtime",
5408
- endpoint: `/agents/sessions/${encodeURIComponent(id)}`
5409
- });
5410
- if (!session.latestExecutionId) throw new StateError(`Session ${id} has no execution result to await`, session.status, "session with an admitted execution", {
5411
- origin: "runtime",
5412
- endpoint: `/agents/sessions/${encodeURIComponent(id)}`
5413
- }, "SESSION_EXECUTION_MISSING");
5447
+ let executionId = options?.executionId;
5448
+ if (!executionId) {
5449
+ const session = knownSession ?? await this._sessionStatus(id);
5450
+ if (!session) throw new NotFoundError("Session", id, {
5451
+ origin: "runtime",
5452
+ endpoint: `/agents/sessions/${encodeURIComponent(id)}`
5453
+ });
5454
+ if (!session.latestExecutionId) throw new StateError(`Session ${id} has no execution result to await`, session.status, "session with an admitted execution", {
5455
+ origin: "runtime",
5456
+ endpoint: `/agents/sessions/${encodeURIComponent(id)}`
5457
+ }, "SESSION_EXECUTION_MISSING");
5458
+ executionId = session.latestExecutionId;
5459
+ }
5460
+ let resultExecutionId = executionId;
5414
5461
  let response;
5415
5462
  let runError;
5416
5463
  let runErrorCode;
@@ -5421,13 +5468,15 @@ var SandboxInstance = class SandboxInstance {
5421
5468
  let question;
5422
5469
  let plan;
5423
5470
  let terminalReached = false;
5424
- for await (const event of this._sessionEvents(id, {
5471
+ const events = options?.executionId ? this._executionEvents(id, executionId) : this._sessionEvents(id, {
5425
5472
  since: "0",
5426
- executionId: session.latestExecutionId
5427
- }, true)) {
5473
+ executionId
5474
+ }, true);
5475
+ for await (const event of events) {
5428
5476
  response = applySandboxEventText(response, event);
5429
5477
  if (event.type === "result" || event.type === "done") {
5430
5478
  const data = event.data;
5479
+ if (typeof data.executionId === "string" && data.executionId) resultExecutionId = data.executionId;
5431
5480
  usage = readTokenUsage(data) ?? usage;
5432
5481
  costUsd = readTokenCostUsd(data) ?? costUsd;
5433
5482
  }
@@ -5461,6 +5510,7 @@ var SandboxInstance = class SandboxInstance {
5461
5510
  return {
5462
5511
  success: outcome.success,
5463
5512
  status: outcome.status,
5513
+ executionId: resultExecutionId,
5464
5514
  response,
5465
5515
  error: outcome.error,
5466
5516
  errorCode: outcome.errorCode,
@@ -5631,15 +5681,24 @@ var SandboxInstance = class SandboxInstance {
5631
5681
  }
5632
5682
  }
5633
5683
  /** @internal — invoked by SandboxSession.interrupt(). */
5634
- async _interrupt(id) {
5684
+ async _interrupt(id, options) {
5685
+ if (options?.executionId !== void 0 && !options.executionId) throw new ValidationError("executionId must not be empty", { executionId: "Expected a non-empty runtime execution id" });
5635
5686
  await this.ensureRunning();
5636
- const response = await this.runtimeFetch(`/agents/sessions/${encodeURIComponent(id)}/abort`, { method: "POST" });
5687
+ const response = options?.executionId ? await this.runtimeFetch("/agents/run/cancel", {
5688
+ method: "POST",
5689
+ headers: { "content-type": "application/json" },
5690
+ body: JSON.stringify({
5691
+ executionId: options.executionId,
5692
+ sessionId: id
5693
+ })
5694
+ }) : await this.runtimeFetch(`/agents/sessions/${encodeURIComponent(id)}/abort`, { method: "POST" });
5637
5695
  if (response.status === 404) return { cancelled: false };
5638
5696
  if (!response.ok) {
5639
5697
  const body = await response.text();
5640
5698
  throw parseErrorResponse(response.status, body, void 0, response.headers);
5641
5699
  }
5642
- return { cancelled: (await response.json()).data?.cancelled === true };
5700
+ const json = await response.json();
5701
+ return { cancelled: options?.executionId ? json.success === true : json.data?.cancelled === true };
5643
5702
  }
5644
5703
  /**
5645
5704
  * @internal — invoked by SandboxSession.answer(). Resolves the session's
@@ -1,4 +1,4 @@
1
- import { $ as EventStreamOptions, At as GitCommit, Bi as TerminalStream, Bn as RolloutOptions, Cn as ProvisionEvent, Di as TurnDriveResult, Dr as SandboxPortBinding, Fi as WriteManyFile, Gn as SSHCommandDescriptor, Gt as IntelligenceReport, H as DriveTurnOptions, Hn as RolloutStartResult, Hr as SandboxTraceOptions, Ii as WriteManyOptions, In as RestoreSnapshotOptions, Jn as SandboxConnection, K as DurablePlan, Kn as SSHCredentials, Kr as SearchMatch, Kt as IntelligenceReportBudget, Ln as ResumeOptions, Mi as WaitForOptions, Mr as SandboxStatus, Mt as GitDiff, N as CreateSessionOptions, Ni as WaitForRolloutOptions, Nr as SandboxTerminalAttachOptions, Nt as GitStatus, P as CreateTaskSessionOptions, Pi as WriteFileOptions, Pt as GpuLease, Qi as BackendType, Qr as SentSessionMessage, R as DispatchPromptOptions, Rn as Rollout, Rr as SandboxTerminals, S as CodeLanguage, Si as TeeAttestationResponse, Sn as PromptResult, T as CompletedTurnResult, Tr as SandboxInfo, Ui as TerminalStreamHandlers, W as DriverInfo, Wr as ScopedToken, Wt as InstalledTool, X as EgressManager, Xn as SandboxEvent, Xr as SendSessionMessageOptions, Xt as JsonValue, Yt as IntelligenceReportWindow, Zr as SendSessionMessageRequest, Zt as ListMessagesOptions, _ as BranchOptions, an as NetworkManager, b as CodeExecutionOptions, bi as TeeAttestationOptions, bn as PromptInputPart, ci as SnapshotOptions, cn as PermissionsManager, di as StartupDiagnostics, ei as SessionEventStreamOptions, gi as TaskSessionCommitResult, gn as ProcessManager, hi as TaskSessionChanges, hr as SandboxFleetTraceBundle, ht as FileWriteResult, ii as SessionMessage, jr as SandboxRuntimeHealth, kr as SandboxResourceUsage, kt as GitBranch, l as BackendManager, li as SnapshotResult, lt as FileSystem, ni as SessionInfo, nn as MintScopedTokenOptions, nt as ExecResult, qr as SearchOptions, qt as IntelligenceReportCompareTo, ri as SessionListOptions, s as BackendConfig, si as SnapshotInfo, ti as SessionForkOptions, tt as ExecOptions, un as PreviewLinkManager, vi as TaskSessionInfo, w as CommitTaskSessionOptions, wi as TeePublicKeyResponse, wn as ProvisionResult, x as CodeExecutionResult, xn as PromptOptions, z as DispatchedSession, zr as SandboxTraceBundle, zt as GpuLeaseManager } from "./types-DDZCJUWe.js";
1
+ import { $ as EventStreamOptions, At as GitCommit, Bn as RolloutOptions, Cn as ProvisionEvent, Dr as SandboxPortBinding, Ei as TeePublicKeyResponse, Fi as WaitForRolloutOptions, Gi as TerminalStreamHandlers, Gn as SSHCommandDescriptor, Gt as IntelligenceReport, H as DriveTurnOptions, Hi as TerminalStream, Hn as RolloutStartResult, Hr as SandboxTraceOptions, Ii as WriteFileOptions, In as RestoreSnapshotOptions, Jn as SandboxConnection, K as DurablePlan, Kn as SSHCredentials, Kr as SearchMatch, Kt as IntelligenceReportBudget, Li as WriteManyFile, Ln as ResumeOptions, Mr as SandboxStatus, Mt as GitDiff, N as CreateSessionOptions, Nr as SandboxTerminalAttachOptions, Nt as GitStatus, P as CreateTaskSessionOptions, Pi as WaitForOptions, Pt as GpuLease, Qr as SentSessionMessage, R as DispatchPromptOptions, Ri as WriteManyOptions, Rn as Rollout, Rr as SandboxTerminals, S as CodeLanguage, Si as TeeAttestationOptions, Sn as PromptResult, T as CompletedTurnResult, Tr as SandboxInfo, W as DriverInfo, Wr as ScopedToken, Wt as InstalledTool, X as EgressManager, Xn as SandboxEvent, Xr as SendSessionMessageOptions, Xt as JsonValue, Yt as IntelligenceReportWindow, Zr as SendSessionMessageRequest, Zt as ListMessagesOptions, _ as BranchOptions, _i as TaskSessionChanges, ai as SessionMessage, an as NetworkManager, b as CodeExecutionOptions, bi as TaskSessionInfo, bn as PromptInputPart, cn as PermissionsManager, di as SnapshotResult, ea as BackendType, ei as SessionEventStreamOptions, gn as ProcessManager, hr as SandboxFleetTraceBundle, ht as FileWriteResult, ii as SessionListOptions, jr as SandboxRuntimeHealth, ki as TurnDriveResult, kr as SandboxResourceUsage, kt as GitBranch, l as BackendManager, li as SnapshotInfo, lt as FileSystem, ni as SessionInfo, nn as MintScopedTokenOptions, nt as ExecResult, pi as StartupDiagnostics, qr as SearchOptions, qt as IntelligenceReportCompareTo, ri as SessionInterruptOptions, s as BackendConfig, si as SessionResultOptions, ti as SessionForkOptions, tt as ExecOptions, ui as SnapshotOptions, un as PreviewLinkManager, vi as TaskSessionCommitResult, w as CommitTaskSessionOptions, wi as TeeAttestationResponse, wn as ProvisionResult, x as CodeExecutionResult, xn as PromptOptions, z as DispatchedSession, zr as SandboxTraceBundle, zt as GpuLeaseManager } from "./types-C_Hdq6RK.js";
2
2
  import { AgentProfile } from "@tangle-network/agent-interface";
3
3
 
4
4
  //#region src/mcp.d.ts
@@ -295,13 +295,13 @@ interface SandboxSessionHost extends InteractiveSessionHost {
295
295
  prompt(message: string | PromptInputPart[], options?: PromptOptions): Promise<PromptResult>;
296
296
  _sessionStatus(id: string): Promise<SessionInfo | null>;
297
297
  _sessionEvents(id: string, opts?: SessionEventStreamOptions): AsyncGenerator<SandboxEvent>;
298
- _sessionResult(id: string, session?: SessionInfo): Promise<PromptResult>;
298
+ _sessionResult(id: string, options?: SessionResultOptions, session?: SessionInfo): Promise<PromptResult>;
299
299
  _sessionDelete(id: string): Promise<void>;
300
300
  _sessionSendMessage(id: string, request: SendSessionMessageRequest, options?: SendSessionMessageOptions): Promise<SentSessionMessage>;
301
301
  messages(opts: ListMessagesOptions): Promise<SessionMessage[]>;
302
302
  _sessionFork(id: string, opts?: SessionForkOptions): Promise<SessionInfo>;
303
303
  _respondToPermission(id: string, permissionID: string, options: RespondToPermissionOptions): Promise<void>;
304
- _interrupt(id: string): Promise<InterruptResult>;
304
+ _interrupt(id: string, options?: SessionInterruptOptions): Promise<InterruptResult>;
305
305
  _answerQuestion(id: string, answers: Record<string, string[]>): Promise<void>;
306
306
  _currentPlan(id: string): Promise<DurablePlan | null>;
307
307
  _decidePlan(id: string, planId: string, decision: {
@@ -345,15 +345,14 @@ declare class SandboxSession {
345
345
  */
346
346
  events(opts?: SessionEventStreamOptions): AsyncGenerator<SandboxEvent>;
347
347
  /**
348
- * Await the session's terminal result. Reads status and drains events
349
- * from the latest execution until the session reaches a terminal state,
350
- * then returns the aggregated `PromptResult`. Event replay makes this safe
351
- * to call after the execution has already finished.
348
+ * Await a terminal result. With `executionId`, drains only that execution;
349
+ * without it, reads status and selects the latest execution. Event replay
350
+ * makes either form safe after the execution has already finished.
352
351
  *
353
352
  * Use this to wait for a session that was started by another caller
354
353
  * (e.g. `dispatchPrompt`).
355
354
  */
356
- result(): Promise<PromptResult>;
355
+ result(options?: SessionResultOptions): Promise<PromptResult>;
357
356
  /**
358
357
  * List persisted messages for this session, including in-flight assistant
359
358
  * content when the runtime has flushed partial output.
@@ -397,11 +396,12 @@ declare class SandboxSession {
397
396
  */
398
397
  respondToPermission(permissionID: string, options: RespondToPermissionOptions): Promise<void>;
399
398
  /**
400
- * Interrupt the session's current execution without deleting it. Returns
401
- * `{ cancelled: false }` when nothing was running — the no-op is reported
402
- * explicitly rather than masked as success.
399
+ * Interrupt an execution without deleting the session. Pass `executionId`
400
+ * to make the cancellation exact: a newer run on the same session is never
401
+ * touched. Without it, the current execution is selected. Returns
402
+ * `{ cancelled: false }` when the selected execution is not running.
403
403
  */
404
- interrupt(): Promise<InterruptResult>;
404
+ interrupt(options?: SessionInterruptOptions): Promise<InterruptResult>;
405
405
  /**
406
406
  * Answer a question the agent asked via a question tool invocation. `answers`
407
407
  * maps each question id to the selected option(s). Backend-agnostic: works
@@ -1206,24 +1206,22 @@ declare class SandboxInstance {
1206
1206
  private createProcessHandle;
1207
1207
  private parseProcessLogStream;
1208
1208
  /**
1209
- * Network manager for runtime network configuration.
1209
+ * Port exposure and runtime network state.
1210
1210
  *
1211
- * @example Update network restrictions
1212
- * ```typescript
1213
- * // Block all outbound traffic
1214
- * await box.network.update({ blockOutbound: true });
1215
- *
1216
- * // Or switch to allowlist mode
1217
- * await box.network.update({
1218
- * allowList: ["192.168.1.0/24", "8.8.8.8/32"]
1219
- * });
1220
- * ```
1211
+ * Outbound restrictions are on {@link SandboxInstance.egress}: `update()`
1212
+ * here rejects every policy field rather than recording one nothing
1213
+ * enforces.
1221
1214
  *
1222
1215
  * @example Expose ports dynamically
1223
1216
  * ```typescript
1224
1217
  * const url = await box.network.exposePort(8000);
1225
1218
  * console.log(`Service available at: ${url}`);
1226
1219
  * ```
1220
+ *
1221
+ * @example Restrict outbound traffic
1222
+ * ```typescript
1223
+ * await box.egress.update({ mode: "blocked" });
1224
+ * ```
1227
1225
  */
1228
1226
  get network(): NetworkManager;
1229
1227
  /**
@@ -1237,6 +1235,7 @@ declare class SandboxInstance {
1237
1235
  *
1238
1236
  * @example Update egress policy at runtime
1239
1237
  * ```typescript
1238
+ * // strict reaches these plus the sandbox's own model endpoint, nothing else.
1240
1239
  * await box.egress.update({ mode: "strict", allowDomains: ["api.github.com"] });
1241
1240
  * ```
1242
1241
  */
@@ -1598,14 +1597,14 @@ declare class SandboxInstance {
1598
1597
  * already in flight or already finished — never on the mere existence
1599
1598
  * of a session with the same id:
1600
1599
  *
1601
- * 1. The session is in flight — `running`, or `queued` with a
1602
- * `latestExecutionId` — → a second dispatch would run two agents
1603
- * against one session, so return the live status with
1604
- * `dispatched: false`.
1605
- * 2. `opts.turnId` is set and the completed-turn cache has it → the
1600
+ * 1. `opts.turnId` is set and the completed-turn cache has it → the
1606
1601
  * turn already finished; return `dispatched: false`. This is the
1607
1602
  * only durable idempotency key, and it outlives the session (the
1608
1603
  * cache survives session eviction, see `findCompletedTurn`).
1604
+ * 2. Otherwise, the session is in flight — `running`, or `queued` with a
1605
+ * `latestExecutionId` — → a second dispatch would run two agents
1606
+ * against one session, so return the live status with
1607
+ * `dispatched: false`.
1609
1608
  *
1610
1609
  * Anything else dispatches. Two cases in particular:
1611
1610
  *
@@ -1699,8 +1698,10 @@ declare class SandboxInstance {
1699
1698
  _sessionStatus(id: string): Promise<SessionInfo | null>;
1700
1699
  /** @internal — invoked by SandboxSession.events(). */
1701
1700
  _sessionEvents(id: string, opts?: SessionEventStreamOptions, stopOnTurnTerminal?: boolean): AsyncGenerator<SandboxEvent>;
1701
+ /** Replay one execution without subscribing to other runs on its session. */
1702
+ private _executionEvents;
1702
1703
  /** @internal — invoked by SandboxSession.result(). */
1703
- _sessionResult(id: string, knownSession?: SessionInfo): Promise<PromptResult>;
1704
+ _sessionResult(id: string, options?: SessionResultOptions, knownSession?: SessionInfo): Promise<PromptResult>;
1704
1705
  /** @internal — invoked by InteractiveSessionHandle.start(). */
1705
1706
  _startInteractive(id: string, options: StartInteractiveOptions): Promise<InteractiveSessionInfo>;
1706
1707
  /** @internal — invoked by InteractiveSessionHandle.sendPrompt(). */
@@ -1737,7 +1738,7 @@ declare class SandboxInstance {
1737
1738
  /** @internal — invoked by SandboxSession.respondToPermission(). */
1738
1739
  _respondToPermission(id: string, permissionID: string, options: RespondToPermissionOptions): Promise<void>;
1739
1740
  /** @internal — invoked by SandboxSession.interrupt(). */
1740
- _interrupt(id: string): Promise<InterruptResult>;
1741
+ _interrupt(id: string, options?: SessionInterruptOptions): Promise<InterruptResult>;
1741
1742
  /**
1742
1743
  * @internal — invoked by SandboxSession.answer(). Resolves the session's
1743
1744
  * outstanding question interaction and posts the answer through the
@@ -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-Om3UH1DJ.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-1b5v8Xeo.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-DiReWa8T.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-Dy4tv_Sm.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-Bf-A-4SA.js";
2
- import { n as createSandboxInstanceFromResponse } from "./sandbox-CfScdY7m.js";
2
+ import { n as createSandboxInstanceFromResponse } from "./sandbox-BnHquSkr.js";
3
3
  //#region src/tangle/abi.ts
4
4
  /**
5
5
  * Tangle Contract ABI Definitions