@tangle-network/sandbox 0.1.2 → 0.3.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.
Files changed (37) hide show
  1. package/README.md +561 -2
  2. package/dist/agent/index.d.ts +435 -0
  3. package/dist/agent/index.js +1 -0
  4. package/dist/auth/index.d.ts +2 -2
  5. package/dist/auth/index.js +1 -1
  6. package/dist/client-BuPZLOxS.d.ts +1050 -0
  7. package/dist/client-BwRV2Zun.js +1 -0
  8. package/dist/collaboration/index.d.ts +1 -1
  9. package/dist/collaboration/index.js +1 -1
  10. package/dist/collaboration-CRyb5e8F.js +1 -0
  11. package/dist/core.d.ts +4 -3
  12. package/dist/core.js +1 -1
  13. package/dist/errors-1Se5ATyZ.d.ts +128 -0
  14. package/dist/errors-CljiGR__.js +1 -0
  15. package/dist/{index-t7xkzv0U.d.ts → index-2gFsmmQs.d.ts} +3 -3
  16. package/dist/{index-gA-oRjOi.d.ts → index-D-2pH_70.d.ts} +35 -4
  17. package/dist/{index-BuS8nl3b.d.ts → index-D7bwmNs8.d.ts} +6 -1
  18. package/dist/index.d.ts +110 -62
  19. package/dist/index.js +1 -1
  20. package/dist/openai/index.d.ts +641 -0
  21. package/dist/openai/index.js +1 -0
  22. package/dist/platform-integrations.d.ts +2 -0
  23. package/dist/platform-integrations.js +1 -0
  24. package/dist/{sandbox-BvZ0-Iv7.d.ts → sandbox-CpK8etqP.d.ts} +1735 -41
  25. package/dist/sandbox-DTup2jzz.js +1 -0
  26. package/dist/session-gateway/index.js +1 -1
  27. package/dist/tangle/index.d.ts +1 -1
  28. package/dist/tangle/index.js +1 -1
  29. package/dist/tangle-CnYnTRi6.js +1 -0
  30. package/package.json +114 -34
  31. package/LICENSE +0 -11
  32. package/dist/client-CcRvqt85.js +0 -1
  33. package/dist/collaboration-CVvhPU8M.js +0 -1
  34. package/dist/errors-AIT8qikt.d.ts +0 -491
  35. package/dist/errors-CdMTv7uG.js +0 -1
  36. package/dist/sandbox-D1JnQIJx.js +0 -1
  37. package/dist/tangle-CSb9rjAh.js +0 -1
@@ -1,3 +1,5 @@
1
+ import { IntegrationActor, IntegrationManifest } from "@tangle-network/agent-integrations";
2
+
1
3
  //#region src/agent-profile.d.ts
2
4
  /**
3
5
  * Provider-neutral agent profile types for public SDK consumers.
@@ -10,6 +12,7 @@
10
12
  * Permission policy value for a capability.
11
13
  */
12
14
  type AgentProfilePermissionValue = "allow" | "ask" | "deny";
15
+ type AgentProfilePermission = AgentProfilePermissionValue | Record<string, AgentProfilePermissionValue>;
13
16
  /**
14
17
  * Generic resource reference that can be resolved into a file or instruction.
15
18
  */
@@ -19,6 +22,11 @@ type AgentProfileResourceRef = {
19
22
  content: string;
20
23
  } | {
21
24
  kind: "github";
25
+ /**
26
+ * Optional repository in "owner/repo" form. When omitted, providers may
27
+ * only resolve the path if they have an ambient repository context.
28
+ */
29
+ repository?: string;
22
30
  path: string;
23
31
  ref?: string;
24
32
  name?: string;
@@ -31,6 +39,7 @@ declare function defineInlineResource(name: string, content: string): AgentProfi
31
39
  * Helper for creating typed GitHub-backed resource refs.
32
40
  */
33
41
  declare function defineGitHubResource(path: string, options?: {
42
+ repository?: string;
34
43
  ref?: string;
35
44
  name?: string;
36
45
  }): AgentProfileResourceRef;
@@ -44,19 +53,38 @@ interface AgentProfileFileMount {
44
53
  }
45
54
  /**
46
55
  * Provider-neutral resource bundle.
47
- *
48
- * Provider-specific concepts such as "skills" or "commands" should be modeled
49
- * under `extensions` unless they become portable across multiple backends.
50
56
  */
51
57
  interface AgentProfileResources {
52
58
  /**
53
59
  * Generic files to materialize into the agent workspace before execution.
54
60
  */
55
61
  files?: AgentProfileFileMount[];
62
+ /**
63
+ * Provider-native tool files. Backends materialize these into their standard
64
+ * discovery location when they support file-based tools.
65
+ */
66
+ tools?: AgentProfileResourceRef[];
67
+ /**
68
+ * Agent Skills (`SKILL.md`) packages. Supported by Cursor, Claude Code,
69
+ * Codex-compatible layouts, OpenCode, and Hermes-style skill harnesses.
70
+ */
71
+ skills?: AgentProfileResourceRef[];
72
+ /**
73
+ * Provider-native subagent definition files.
74
+ */
75
+ agents?: AgentProfileResourceRef[];
76
+ /**
77
+ * Provider-native slash command files.
78
+ */
79
+ commands?: AgentProfileResourceRef[];
56
80
  /**
57
81
  * Additional instructions injected into the agent context.
58
82
  */
59
83
  instructions?: string | AgentProfileResourceRef;
84
+ /**
85
+ * Fail initialization when a provider cannot materialize a resource.
86
+ */
87
+ failOnError?: boolean;
60
88
  }
61
89
  /**
62
90
  * Model selection hints for backends.
@@ -100,10 +128,25 @@ interface AgentSubagentProfile {
100
128
  prompt?: string;
101
129
  model?: string;
102
130
  tools?: Record<string, boolean>;
103
- permissions?: Record<string, AgentProfilePermissionValue>;
131
+ permissions?: Record<string, AgentProfilePermission>;
104
132
  maxSteps?: number;
105
133
  metadata?: Record<string, unknown>;
106
134
  }
135
+ interface AgentProfileHookCommand {
136
+ command: string;
137
+ timeoutMs?: number;
138
+ blocking?: boolean;
139
+ matcher?: string;
140
+ env?: Record<string, string>;
141
+ }
142
+ interface AgentProfileMode {
143
+ description?: string;
144
+ model?: string;
145
+ prompt?: string;
146
+ tools?: Record<string, boolean>;
147
+ permissions?: Record<string, AgentProfilePermission>;
148
+ metadata?: Record<string, unknown>;
149
+ }
107
150
  /**
108
151
  * Confidential-execution options for sandbox backends.
109
152
  *
@@ -153,11 +196,13 @@ interface AgentProfile {
153
196
  tags?: string[];
154
197
  prompt?: AgentProfilePrompt;
155
198
  model?: AgentProfileModelHints;
156
- permissions?: Record<string, AgentProfilePermissionValue>;
199
+ permissions?: Record<string, AgentProfilePermission>;
157
200
  tools?: Record<string, boolean>;
158
201
  mcp?: Record<string, AgentProfileMcpServer>;
159
202
  subagents?: Record<string, AgentSubagentProfile>;
160
203
  resources?: AgentProfileResources;
204
+ hooks?: Record<string, AgentProfileHookCommand[]>;
205
+ modes?: Record<string, AgentProfileMode>;
161
206
  confidential?: AgentProfileConfidential;
162
207
  metadata?: Record<string, unknown>;
163
208
  /**
@@ -186,7 +231,13 @@ interface AgentProfileCapabilities {
186
231
  resources: {
187
232
  files: boolean;
188
233
  instructions: boolean;
234
+ tools?: boolean;
235
+ skills?: boolean;
236
+ agents?: boolean;
237
+ commands?: boolean;
189
238
  };
239
+ hooks?: boolean;
240
+ modes?: boolean;
190
241
  runtimeUpdate: boolean;
191
242
  validation: boolean;
192
243
  /**
@@ -219,6 +270,9 @@ interface AgentProfileValidationResult {
219
270
  declare function mergeAgentProfiles(base: AgentProfile | undefined, overlay: AgentProfile | undefined): AgentProfile | undefined;
220
271
  //#endregion
221
272
  //#region src/types.d.ts
273
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
274
+ [key: string]: JsonValue;
275
+ };
222
276
  /**
223
277
  * A development environment.
224
278
  *
@@ -235,6 +289,61 @@ interface SandboxEnvironment {
235
289
  base?: string;
236
290
  /** Environment version tag */
237
291
  version: string;
292
+ /** Public template identifier when this environment comes from a published template */
293
+ publicTemplateId?: string;
294
+ /** Snapshot identifier backing the environment when applicable */
295
+ snapshotId?: string;
296
+ }
297
+ interface PublicTemplateVersionInfo {
298
+ id: string;
299
+ templateId: string;
300
+ versionNumber: number;
301
+ snapshotId: string;
302
+ sourceSandboxId: string;
303
+ readmeMarkdown: string;
304
+ tags: string[];
305
+ releaseNotes: string;
306
+ createdByCustomerId: string;
307
+ createdAt: string;
308
+ }
309
+ interface PublicTemplateInfo {
310
+ id: string;
311
+ slug: string;
312
+ name: string;
313
+ description: string;
314
+ websiteUrl: string | null;
315
+ ownerCustomerId: string;
316
+ ownerTeamId: string | null;
317
+ forkedFromTemplateId: string | null;
318
+ latestVersionId: string | null;
319
+ isFeatured: boolean;
320
+ featuredRank: number | null;
321
+ forkCount: number;
322
+ sandboxCount: number;
323
+ createdAt: string;
324
+ updatedAt: string;
325
+ publishedAt: string;
326
+ latestVersion: PublicTemplateVersionInfo | null;
327
+ }
328
+ interface PublishPublicTemplateOptions {
329
+ name: string;
330
+ slug?: string;
331
+ description?: string;
332
+ websiteUrl?: string;
333
+ snapshotId: string;
334
+ sourceSandboxId: string;
335
+ teamId?: string;
336
+ readmeMarkdown?: string;
337
+ tags?: string[];
338
+ releaseNotes?: string;
339
+ forkedFromTemplateId?: string;
340
+ }
341
+ interface PublishPublicTemplateVersionOptions {
342
+ snapshotId: string;
343
+ sourceSandboxId: string;
344
+ readmeMarkdown?: string;
345
+ tags?: string[];
346
+ releaseNotes?: string;
238
347
  }
239
348
  /**
240
349
  * Git authentication configuration.
@@ -357,6 +466,21 @@ interface SandboxClientConfig {
357
466
  baseUrl: string;
358
467
  /** Request timeout in milliseconds. Defaults to 30000 (30 seconds) */
359
468
  timeoutMs?: number;
469
+ /**
470
+ * Permit the SDK to read CLI auth files from the host home directory
471
+ * (`~/.codex/auth.json`, `~/.claude/.credentials.json`,
472
+ * `~/.claude/settings.json`) and ship them to a `localhost` /
473
+ * `127.0.0.1` / `::1` `baseUrl` when creating a `codex` or
474
+ * `claude-code` backend without explicit credentials.
475
+ *
476
+ * Default `false`. Without this flag, any process bound to a
477
+ * localhost port (your sandbox-api or anything else) can impersonate
478
+ * the API and silently harvest those credentials. Set this to `true`
479
+ * only when the localhost endpoint is one you control. For non-local
480
+ * `baseUrl`s the flag is ignored — the SDK never reads home-dir auth
481
+ * files for remote endpoints.
482
+ */
483
+ trustLocalCliAuth?: boolean;
360
484
  }
361
485
  /**
362
486
  * Status of a sandbox instance.
@@ -381,7 +505,11 @@ interface SandboxResources {
381
505
  memoryMB?: number;
382
506
  /** Disk space in gigabytes */
383
507
  diskGB?: number;
508
+ /** Accelerator request for GPU-class workloads. */
509
+ accelerator?: SandboxAccelerator;
384
510
  }
511
+ /** @deprecated Use SandboxAccelerator.kind via SandboxResources.accelerator. */
512
+ type GpuType = string;
385
513
  /**
386
514
  * Configuration for creating a new sandbox.
387
515
  *
@@ -566,6 +694,37 @@ interface CreateSandboxOptions {
566
694
  resources?: SandboxResources;
567
695
  /** Environment variables injected into the sandbox */
568
696
  env?: Record<string, string>;
697
+ /**
698
+ * Integration requirements the sandbox app needs at launch.
699
+ *
700
+ * The sandbox API resolves this manifest through id.tangle.tools,
701
+ * creates owner-scoped grants, and injects only a short-lived
702
+ * `TANGLE_INTEGRATION_BUNDLE` capability payload. Raw provider OAuth
703
+ * tokens and API keys never enter the sandbox environment.
704
+ */
705
+ integrationManifest?: IntegrationManifest;
706
+ /**
707
+ * Existing platform grant ids to bind to this launch.
708
+ *
709
+ * Use this for installed templates or pre-consented apps where the
710
+ * installer owns the connection. The sandbox API still requires
711
+ * `integrationManifest` so platform can fail closed if a grant does not
712
+ * match the declared requirements.
713
+ */
714
+ integrationGrantIds?: string[];
715
+ /**
716
+ * Grant durability for `integrationManifest`.
717
+ *
718
+ * `preview` scopes consent to this sandbox preview/session,
719
+ * `durable-app` is for installed/generated app instances, and
720
+ * `one-shot` is for a single workflow run.
721
+ */
722
+ integrationGrantMode?: "preview" | "durable-app" | "one-shot";
723
+ /**
724
+ * Logical app/agent subject receiving the grant. When omitted, the
725
+ * sandbox itself is the grantee and runtime subject.
726
+ */
727
+ integrationSubject?: IntegrationActor;
569
728
  /**
570
729
  * Maximum lifetime in seconds.
571
730
  * Sandbox is automatically deleted after this time.
@@ -586,6 +745,10 @@ interface CreateSandboxOptions {
586
745
  sshEnabled?: boolean;
587
746
  /** Custom SSH public key for access (optional) */
588
747
  sshPublicKey?: string;
748
+ /** Custom SSH public keys for access (optional) */
749
+ sshPublicKeys?: string[];
750
+ /** Stored SSH key IDs or names to authorize at creation time */
751
+ sshKeyIds?: string[];
589
752
  /**
590
753
  * Enable web terminal access.
591
754
  * Provides a browser-based terminal via websocket.
@@ -603,6 +766,35 @@ interface CreateSandboxOptions {
603
766
  fromSnapshot?: string;
604
767
  /** Source sandbox ID that owns the snapshot (required when fromSnapshot is set) */
605
768
  fromSandboxId?: string;
769
+ /**
770
+ * Apply a saved template at create time. Templates seed the
771
+ * sandbox with a snapshot, default environment, and config defaults
772
+ * so a team can publish a golden-path starting point once and have
773
+ * every member spin up the same baseline.
774
+ *
775
+ * The template must either be personal (owned by the caller) or
776
+ * belong to a team the caller is an active member of. Explicit
777
+ * fields on this call win over template defaults — so you can layer
778
+ * a one-off override on top of the golden path without forking the
779
+ * template itself.
780
+ *
781
+ * @example
782
+ * ```typescript
783
+ * const box = await client.create({
784
+ * templateId: "tpl_abc123",
785
+ * teamId: "team_...", // optional; sandbox is shared with the team
786
+ * });
787
+ * ```
788
+ */
789
+ templateId?: string;
790
+ /**
791
+ * Create from a published public template by id or slug.
792
+ * The API resolves the latest published version unless
793
+ * `publicTemplateVersionId` is also provided.
794
+ */
795
+ publicTemplateId?: string;
796
+ /** Pin sandbox creation to a specific published public-template version. */
797
+ publicTemplateVersionId?: string;
606
798
  /**
607
799
  * Names of secrets to inject as environment variables.
608
800
  *
@@ -634,17 +826,101 @@ interface CreateSandboxOptions {
634
826
  * (accessible only to the creator).
635
827
  */
636
828
  teamId?: string;
829
+ /**
830
+ * Sidecar capabilities to enable at boot. Each capability boots an
831
+ * additional subsystem inside the sandbox; absent capabilities incur
832
+ * zero startup cost.
833
+ *
834
+ * Currently supported:
835
+ * - `"computer_use"` — boots Xvfb, dbus, AT-SPI, and an MCP server
836
+ * exposing mouse/keyboard/screenshot via the Anthropic + OpenAI
837
+ * Responses computer-use surface. Required if you plan to call
838
+ * {@link SandboxInstance.getMcpAccessToken | `getMcpAccessToken`}
839
+ * with `capabilities: ["computer_use"]`.
840
+ *
841
+ * The capability is enforced at two layers:
842
+ * 1. The sidecar refuses to start if a capability's binaries are
843
+ * missing (computer_use needs the universal Nix profile, which
844
+ * Docker / host-agent / Firecracker drivers ship via the host
845
+ * bind-mount or the universal sidecar image variant; Firecracker
846
+ * host profiles built without the universal flake do not).
847
+ * 2. The MCP token endpoint refuses to mint a `cap: ["computer_use"]`
848
+ * JWT for a sandbox that wasn't created with that capability.
849
+ *
850
+ * **Sizing note:** `computer_use` boots an always-on Xvfb + dbus
851
+ * stack costing roughly **~100 MB resident memory** inside the
852
+ * container. Billing is by reserved capacity (not measured RSS), so
853
+ * this comes out of your sandbox's RAM envelope rather than adding
854
+ * a separate line item. On a 1 GB sandbox that is ~10% of your
855
+ * workload's headroom; bump `resources.memoryMb` to 1.5–2 GB if
856
+ * the agent will run anything memory-hungry alongside it.
857
+ *
858
+ * @example
859
+ * ```typescript
860
+ * const box = await client.create({
861
+ * environment: "universal",
862
+ * capabilities: ["computer_use"],
863
+ * });
864
+ * const { token } = await box.getMcpAccessToken({
865
+ * capabilities: ["computer_use"],
866
+ * });
867
+ * ```
868
+ */
869
+ capabilities?: ReadonlyArray<"computer_use">;
870
+ /**
871
+ * Privacy controls for the sandbox. Two independent layers:
872
+ *
873
+ * - **`egress`** — what happens when the sandbox sends a request to a
874
+ * model vendor (Anthropic, OpenAI, your own router, etc.):
875
+ * - `"redact"` — PII spans are masked before the request leaves
876
+ * the sandbox. Emails, JWTs, API keys, credit cards (Luhn-
877
+ * validated), SSNs, phone numbers, IPv4 addresses are caught
878
+ * today; names / postal addresses / DOBs land when the OPF
879
+ * model service is enabled. The agent receives normal
880
+ * responses; the vendor sees masked input.
881
+ * - `"block"` — PII presence fails the egress request closed.
882
+ * For high-compliance flows that prefer fail-closed to leak.
883
+ * - `"off"` — no egress filtering. Default for free tier; opt-in
884
+ * for tasks that genuinely need raw PII (form-filling,
885
+ * customer-support agents reading customer details).
886
+ *
887
+ * - **`logs`** — whether infrastructure logs / telemetry / Sentry
888
+ * redact PII before recording. This is OUR side, not the model
889
+ * vendor's, and there's basically never a reason to leak PII into
890
+ * our own logs. Default `"on"`.
891
+ *
892
+ * Note: privacy controls operate at the boundary between the
893
+ * sandbox and external systems. They do NOT redact contents inside
894
+ * the sandbox workspace itself — files / code / database fixtures
895
+ * the customer puts there are the customer's data and stay
896
+ * unmodified. Snapshots preserve those contents verbatim.
897
+ *
898
+ * @example
899
+ * ```typescript
900
+ * const box = await client.create({
901
+ * privacy: { egress: "redact", logs: "on" },
902
+ * });
903
+ * ```
904
+ */
905
+ privacy?: {
906
+ egress?: "redact" | "block" | "off";
907
+ logs?: "on" | "off";
908
+ };
637
909
  }
638
910
  /**
639
911
  * SSH connection credentials.
640
912
  */
641
913
  interface SSHCredentials {
642
- /** SSH server hostname */
643
- host: string;
644
- /** SSH server port */
645
- port: number;
646
914
  /** Username for SSH authentication */
647
915
  username: string;
916
+ /** SSH server port */
917
+ port: number;
918
+ /** ProxyCommand for sandbox API tunnel-based SSH. */
919
+ proxyCommand: string;
920
+ }
921
+ interface SSHCommandDescriptor {
922
+ command: string;
923
+ env: Record<string, string>;
648
924
  }
649
925
  /**
650
926
  * Connection information for a sandbox.
@@ -799,7 +1075,7 @@ interface ExecOptions {
799
1075
  *
800
1076
  * @example Search TypeScript files
801
1077
  * ```typescript
802
- * const matches = await box.search("TODO", {
1078
+ * const matches = await box.search("export function", {
803
1079
  * glob: "**\/*.ts",
804
1080
  * maxResults: 100,
805
1081
  * });
@@ -974,6 +1250,31 @@ interface PromptOptions {
974
1250
  context?: Record<string, unknown>;
975
1251
  /** AbortSignal for cancellation */
976
1252
  signal?: AbortSignal;
1253
+ /**
1254
+ * Stable execution id for cross-process reconnect. When passed, the same
1255
+ * id on a retry lands on the same substrate execution — the platform
1256
+ * replays its buffered event stream instead of spawning a duplicate run.
1257
+ * Forwarded as the `X-Execution-ID` header. Omit to let the SDK extract
1258
+ * one from the response stream's `execution.started` event (in-call
1259
+ * reconnect only).
1260
+ */
1261
+ executionId?: string;
1262
+ /**
1263
+ * Last event id the caller has already acknowledged. The substrate
1264
+ * replays strictly after this id on reconnect. Forwarded as the
1265
+ * `Last-Event-ID` header. Omit on first attempt.
1266
+ */
1267
+ lastEventId?: string;
1268
+ /**
1269
+ * Caller-supplied turn idempotency key. When set, a retry with the
1270
+ * same `turnId` on the same `sessionId` short-circuits to the cached
1271
+ * result instead of re-issuing the upstream LLM call. Generate a
1272
+ * fresh `turnId` per logical attempt (a different user message gets
1273
+ * a new id) and reuse it only for retries of the same intent
1274
+ * (Stripe-style idempotency). Combine with `box.findCompletedTurn`
1275
+ * to check completion before re-dispatching.
1276
+ */
1277
+ turnId?: string;
977
1278
  }
978
1279
  /**
979
1280
  * SSE event from sandbox streaming.
@@ -986,6 +1287,142 @@ interface SandboxEvent {
986
1287
  /** Event ID */
987
1288
  id?: string;
988
1289
  }
1290
+ interface SandboxTraceEvent {
1291
+ type: "sandbox.lifecycle.snapshot" | "sandbox.runtime.snapshot" | "sandbox.usage.snapshot" | "sandbox.insight.summary";
1292
+ timestamp: string;
1293
+ sandboxId: string;
1294
+ durationMs?: number;
1295
+ attributes: Record<string, unknown>;
1296
+ }
1297
+ interface SandboxTraceExport {
1298
+ schemaVersion: "sandbox.trace.v1";
1299
+ traceId: string;
1300
+ sandboxId: string;
1301
+ exportedAt: string;
1302
+ timings: {
1303
+ observedLifecycleMs: number;
1304
+ observedRuntimeMs: number;
1305
+ idleObservedMs: number;
1306
+ };
1307
+ criticalPath: {
1308
+ durationMs: number;
1309
+ phases: Array<{
1310
+ name: string;
1311
+ durationMs: number;
1312
+ }>;
1313
+ };
1314
+ events: SandboxTraceEvent[];
1315
+ }
1316
+ interface SandboxIntelligenceEnvelope {
1317
+ schemaVersion: "sandbox.intelligence.v1";
1318
+ source: "sandbox-api";
1319
+ subject: {
1320
+ type: "sandbox";
1321
+ sandboxId: string;
1322
+ };
1323
+ billing: {
1324
+ billable: false;
1325
+ billedTo: "platform";
1326
+ costUsd: 0;
1327
+ reason: "deterministic_platform_insight";
1328
+ };
1329
+ metrics: Record<string, number>;
1330
+ signals: Array<{
1331
+ name: string;
1332
+ value: string | number | boolean;
1333
+ severity: "info" | "warn" | "critical";
1334
+ rationale: string;
1335
+ }>;
1336
+ recommendedActions: string[];
1337
+ }
1338
+ interface SandboxTraceBundle {
1339
+ trace: SandboxTraceExport;
1340
+ intelligence?: SandboxIntelligenceEnvelope;
1341
+ }
1342
+ interface SandboxTraceOptions {
1343
+ /**
1344
+ * Include the platform-generated intelligence envelope. Defaults to false.
1345
+ * Set true when a customer wants generated insight with the raw trace export.
1346
+ */
1347
+ includeIntelligence?: boolean;
1348
+ }
1349
+ /**
1350
+ * Subject types for an Intelligence Report.
1351
+ *
1352
+ * - `sandbox`: one container's run.
1353
+ * - `fleet`: one managed grouping of sandboxes. Add `subject.dispatchId`
1354
+ * to narrow to a single coordinated command within the fleet
1355
+ * (previously a standalone `dispatch` subject type — now expressed
1356
+ * as a fleet refinement).
1357
+ */
1358
+ type IntelligenceReportSubjectType = "sandbox" | "fleet";
1359
+ interface IntelligenceReport {
1360
+ jobId: string;
1361
+ subject: {
1362
+ type: IntelligenceReportSubjectType;
1363
+ id: string; /** Present when the report was narrowed to a single fleet dispatch. */
1364
+ dispatchId?: string;
1365
+ };
1366
+ mode: "deterministic" | "agentic";
1367
+ status: "queued" | "running" | "completed" | "failed";
1368
+ billing: {
1369
+ billable: boolean;
1370
+ billedTo: "platform" | "customer";
1371
+ costUsd: number;
1372
+ reason: string;
1373
+ budgetMaxUsd?: number;
1374
+ };
1375
+ result: Record<string, unknown> | null;
1376
+ error?: string;
1377
+ createdAt: string;
1378
+ updatedAt: string;
1379
+ completedAt?: string;
1380
+ }
1381
+ interface IntelligenceReportBudget {
1382
+ maxUsd?: number;
1383
+ billTo?: "customer" | "platform";
1384
+ }
1385
+ /**
1386
+ * Time window for an intelligence report. Both bounds are millisecond
1387
+ * epochs. Omit `since` to mean "from the subject's first observation";
1388
+ * omit `until` to mean "now". `since` must be <= `until` when both are
1389
+ * set; the server enforces this at the schema layer.
1390
+ */
1391
+ interface IntelligenceReportWindow {
1392
+ since?: number;
1393
+ until?: number;
1394
+ }
1395
+ /**
1396
+ * Comparison baseline. When present, the report includes an explicit
1397
+ * delta between the primary subject and this baseline. Must be the
1398
+ * same `type` as the primary subject — the analyzer rejects mixed
1399
+ * subject-type comparisons because the delta would be meaningless.
1400
+ *
1401
+ * `dispatchId` is only valid when `type === "fleet"`.
1402
+ */
1403
+ interface IntelligenceReportCompareTo {
1404
+ type: IntelligenceReportSubjectType;
1405
+ id: string;
1406
+ /** Narrow the baseline to a single dispatch within the fleet. */
1407
+ dispatchId?: string;
1408
+ }
1409
+ interface CreateIntelligenceReportOptions {
1410
+ subject: {
1411
+ type: IntelligenceReportSubjectType;
1412
+ id: string;
1413
+ /**
1414
+ * Narrow the analysis to a single coordinated command within a
1415
+ * fleet. Only valid when `type === "fleet"`.
1416
+ */
1417
+ dispatchId?: string; /** Bound the analysis to a time window. */
1418
+ window?: IntelligenceReportWindow; /** Compare the primary subject against a same-type baseline. */
1419
+ compareTo?: IntelligenceReportCompareTo;
1420
+ };
1421
+ mode?: "deterministic" | "agentic";
1422
+ acknowledgeCost?: boolean;
1423
+ budget?: IntelligenceReportBudget;
1424
+ metadata?: Record<string, unknown>;
1425
+ }
989
1426
  /**
990
1427
  * Options for event streaming.
991
1428
  */
@@ -1089,7 +1526,9 @@ interface SubscriptionInfo {
1089
1526
  *
1090
1527
  * **May be negative** for overage-enabled plans (pro/enterprise):
1091
1528
  * overage charges can push the stored balance below zero. Free-tier
1092
- * plans cap at 0 at the charge path (`capAtZero: true`).
1529
+ * plans floor at 0 at the charge path free users top up their
1530
+ * prepaid balance via Stripe Checkout (`POST /v1/billing/topup`,
1531
+ * issue #874) when they hit zero rather than going into the red.
1093
1532
  *
1094
1533
  * Freshness semantics differ by deployment backend: the
1095
1534
  * Cloudflare/D1 backend includes real-time projected cost of
@@ -1193,6 +1632,181 @@ interface TaskResult extends PromptResult {
1193
1632
  /** Session ID for the task (can be used to continue) */
1194
1633
  sessionId: string;
1195
1634
  }
1635
+ /**
1636
+ * Lifecycle state of an agent session inside a sandbox.
1637
+ */
1638
+ type SessionStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
1639
+ /**
1640
+ * Snapshot of a session's state at the moment it was queried. Returned
1641
+ * by `box.session(id).status()` and `box.sessions()`.
1642
+ */
1643
+ interface SessionInfo {
1644
+ /** Stable session id assigned by the sandbox runtime. */
1645
+ id: string;
1646
+ /** Current lifecycle state. */
1647
+ status: SessionStatus;
1648
+ /** Backend identifier (e.g. provider name). */
1649
+ backend?: string;
1650
+ /** Model id the session was created with. */
1651
+ model?: string;
1652
+ /** Number of prompts the session has processed. */
1653
+ promptCount?: number;
1654
+ /** When the session was created in the sandbox. */
1655
+ createdAt?: Date;
1656
+ /** When the session began executing. */
1657
+ startedAt?: Date;
1658
+ /** When the session reached a terminal state. */
1659
+ endedAt?: Date;
1660
+ /** Raw payload from the sidecar — stable subset above; this carries
1661
+ * everything else for forward-compatibility. */
1662
+ raw?: Record<string, unknown>;
1663
+ }
1664
+ /**
1665
+ * Options for `box.sessions()` listing.
1666
+ */
1667
+ interface SessionListOptions {
1668
+ /** Filter by status. */
1669
+ status?: SessionStatus;
1670
+ /** Filter by backend identifier. */
1671
+ backend?: string;
1672
+ }
1673
+ /**
1674
+ * Options for `SandboxSession.events()` streaming.
1675
+ */
1676
+ interface SessionEventStreamOptions {
1677
+ /** Replay starting from this event id (inclusive). Omit to start at
1678
+ * the live tail. Useful for reconnect-after-disconnect flows. */
1679
+ since?: string;
1680
+ /** Cancel the stream by aborting this signal. */
1681
+ signal?: AbortSignal;
1682
+ }
1683
+ /**
1684
+ * Options for `box.dispatchPrompt()` — fire-and-detach prompt semantics.
1685
+ */
1686
+ interface DispatchPromptOptions extends PromptOptions {
1687
+ /** Client-supplied session id for idempotency. Re-dispatching with
1688
+ * the same id while the session is running is a lookup, not a
1689
+ * re-create. Lets queue retries and reconnect-after-restart be safe
1690
+ * by construction. */
1691
+ sessionId?: string;
1692
+ }
1693
+ /**
1694
+ * Options for `box.messages()` — list messages on a session including
1695
+ * mid-turn partial assistant content.
1696
+ */
1697
+ interface ListMessagesOptions {
1698
+ /** Session id whose messages to return (required). */
1699
+ sessionId: string;
1700
+ /** Max entries, default 100. Server caps at 1000. */
1701
+ limit?: number;
1702
+ /** Skip this many entries from the start. */
1703
+ offset?: number;
1704
+ /** Only return messages newer than this Unix-ms timestamp. */
1705
+ since?: number;
1706
+ }
1707
+ /**
1708
+ * One message on a session — user, assistant, or system. The metadata
1709
+ * field carries the durability marker set by the sidecar:
1710
+ * - `status: "streaming"` and no `completed`/`interrupted` flag → turn
1711
+ * is in flight, OR the sidecar died before stamping a marker
1712
+ * (SIGKILL, OOM). The partial parts are the partial assistant
1713
+ * content the recorder flushed before death.
1714
+ * - `completed: true` + `completedAt` → turn finished normally. If a
1715
+ * `turnId` was supplied, its result is cached for idempotent retry.
1716
+ * - `interrupted: true` + `interruptedAt` + `interruptReason` → graceful
1717
+ * abort, timeout, or upstream error. Partial content is preserved
1718
+ * but not billable as a completion.
1719
+ */
1720
+ interface SessionMessage {
1721
+ id: string;
1722
+ role: "user" | "assistant" | "system";
1723
+ /** ISO timestamp string. */
1724
+ timestamp: string;
1725
+ /** Message parts (text, tool calls, reasoning, files). Same shape as
1726
+ * events emitted by `streamPrompt`. */
1727
+ parts: unknown[];
1728
+ /** Durability + idempotency metadata. See class doc above. */
1729
+ metadata?: {
1730
+ status?: "streaming" | "completed" | "interrupted";
1731
+ completed?: boolean;
1732
+ completedAt?: string;
1733
+ interrupted?: boolean;
1734
+ interruptedAt?: string;
1735
+ interruptReason?: string;
1736
+ turnId?: string;
1737
+ startedAt?: string;
1738
+ [extra: string]: unknown;
1739
+ };
1740
+ }
1741
+ /**
1742
+ * Returned by `box.findCompletedTurn()` — the cached result of a
1743
+ * previously-completed turn, keyed on the caller's `turnId`.
1744
+ */
1745
+ interface CompletedTurnResult {
1746
+ turnId: string;
1747
+ sessionId: string;
1748
+ /** ISO timestamp when the turn finished. */
1749
+ completedAt: string;
1750
+ /** The cached AgentExecutionResult-shape payload (text, toolInvocations,
1751
+ * sessionId, tokenUsage, etc.). */
1752
+ result: Record<string, unknown>;
1753
+ }
1754
+ /**
1755
+ * Returned by `box.dispatchPrompt()` — minimum the caller needs to track
1756
+ * the session afterward. The sandbox keeps running the prompt; use
1757
+ * `box.session(sessionId)` to follow it.
1758
+ */
1759
+ interface DispatchedSession {
1760
+ /** Session id (either the one the caller supplied or one the sandbox
1761
+ * minted). */
1762
+ sessionId: string;
1763
+ /** Lifecycle state at the moment dispatch returned. */
1764
+ status: SessionStatus;
1765
+ /** True when an existing session with the supplied id was found and
1766
+ * dispatch was a no-op (idempotency). */
1767
+ alreadyExisted: boolean;
1768
+ }
1769
+ /**
1770
+ * Scope of a `box.mintScopedToken()` request. Each value narrows the
1771
+ * token's authority compared to the full sandbox bearer.
1772
+ */
1773
+ type ScopedTokenScope = "session" | "project" | "read-only";
1774
+ /**
1775
+ * Options for `box.mintScopedToken()`.
1776
+ */
1777
+ interface MintScopedTokenOptions {
1778
+ /** Scope to mint. `session` narrows to a single session id; `project`
1779
+ * grants read access to the whole sandbox; `read-only` is a project
1780
+ * scope without prompt-dispatch capabilities. */
1781
+ scope: ScopedTokenScope;
1782
+ /** Required when `scope === "session"`. */
1783
+ sessionId?: string;
1784
+ /** TTL in minutes. Default 5; clamped to [1, 15]. Browser-side
1785
+ * bearers must be short-lived; pair with `client.onTokenRefresh()`
1786
+ * for long-running consumers. */
1787
+ ttlMinutes?: number;
1788
+ }
1789
+ /**
1790
+ * Returned by `box.mintScopedToken()`. The token verifies against the
1791
+ * same sidecar middleware that already gates ProductTokenIssuer-issued
1792
+ * JWTs — no new sidecar surface.
1793
+ */
1794
+ interface ScopedToken {
1795
+ /** Bearer token (JWT). Send as `Authorization: Bearer <token>` or
1796
+ * via the `EventSource` URL with token query param. */
1797
+ token: string;
1798
+ /** When the token expires. */
1799
+ expiresAt: Date;
1800
+ /** Echo of the requested scope. */
1801
+ scope: ScopedTokenScope;
1802
+ }
1803
+ /**
1804
+ * Callback invoked when the SDK refreshes a sandbox bearer transparently
1805
+ * (e.g. after a 401 retry against the runtime endpoint). Lets long-
1806
+ * running consumers propagate the new token to dependents (live
1807
+ * `EventSource` connections, browser-side caches, etc.).
1808
+ */
1809
+ type TokenRefreshHandler = (sandboxId: string, newToken: string) => void;
1196
1810
  /**
1197
1811
  * Options for creating a snapshot.
1198
1812
  */
@@ -1268,6 +1882,8 @@ interface BatchOptions {
1268
1882
  backend?: Partial<BackendConfig>;
1269
1883
  /** Keep sandboxes alive after completion (default: false) */
1270
1884
  persistent?: boolean;
1885
+ /** Milliseconds to keep non-persistent batch sandboxes alive after completion. */
1886
+ graceMs?: number;
1271
1887
  /**
1272
1888
  * AbortSignal to cancel the batch mid-stream. When aborted, the HTTP
1273
1889
  * request to `/batch/run` is torn down; the SSE generator stops
@@ -1332,6 +1948,524 @@ interface BatchEvent {
1332
1948
  */
1333
1949
  id?: string;
1334
1950
  }
1951
+ /**
1952
+ * Stable worker identifier inside a sandbox fleet.
1953
+ *
1954
+ * Machine IDs are intentionally narrower than sandbox names so agents
1955
+ * can route work without smuggling shell metacharacters or path-like
1956
+ * values through tool calls.
1957
+ */
1958
+ type FleetMachineId = string;
1959
+ type SandboxFleetMachineRole = "coordinator" | "worker";
1960
+ /**
1961
+ * Resource policy for a single fleet create call.
1962
+ *
1963
+ * These caps are enforced client-side before any sandbox is created.
1964
+ * Server-side plan quotas still apply and remain the source of truth.
1965
+ */
1966
+ interface SandboxFleetPolicy {
1967
+ /** Maximum number of machines in this create call. Defaults to machines.length. */
1968
+ maxMachines?: number;
1969
+ /** Maximum sandbox create fanout allowed for this fleet request. */
1970
+ maxConcurrentCreates?: number;
1971
+ /** Maximum total requested CPU cores across machines with explicit resources. */
1972
+ maxTotalCpu?: number;
1973
+ /** Maximum total requested memory across machines with explicit resources. */
1974
+ maxTotalMemoryMb?: number;
1975
+ /** Maximum total requested storage across machines with explicit resources. */
1976
+ maxTotalStorageMb?: number;
1977
+ /** Maximum total requested accelerator devices across machines. */
1978
+ maxTotalAccelerators?: number;
1979
+ /** Maximum lifetime in seconds for any machine in this fleet. */
1980
+ maxLifetimeSeconds?: number;
1981
+ /** Maximum estimated USD spend for the fleet's configured lifetime. */
1982
+ maxSpendUsd?: number;
1983
+ /** Allowed infrastructure drivers for fleet machines. */
1984
+ allowedDrivers?: DriverType[];
1985
+ /** Allowed images/environments for fleet machines. */
1986
+ allowedImages?: string[];
1987
+ /** Allowed personal or public template identifiers for fleet machines. */
1988
+ allowedTemplateIds?: string[];
1989
+ /** Whether machines may request accelerator devices. Defaults to allowed. */
1990
+ allowAccelerators?: boolean;
1991
+ }
1992
+ interface SandboxFleetWorkspace {
1993
+ mode: "isolated" | "shared";
1994
+ id?: string;
1995
+ quotaMb?: number;
1996
+ mountPath?: string;
1997
+ snapshotId?: string;
1998
+ }
1999
+ /**
2000
+ * Per-machine create spec for a sandbox fleet.
2001
+ */
2002
+ interface SandboxFleetMachineSpec extends Omit<CreateSandboxOptions, "metadata" | "name"> {
2003
+ /** Stable agent-facing machine id, e.g. "coordinator" or "worker-1". */
2004
+ machineId: FleetMachineId;
2005
+ /** Optional display name. Defaults to `${fleetId}-${machineId}`. */
2006
+ name?: string;
2007
+ /** Machine-specific metadata. Fleet tags are added automatically. */
2008
+ metadata?: Record<string, unknown>;
2009
+ /** Optional orchestration role. Defaults to worker. */
2010
+ role?: SandboxFleetMachineRole;
2011
+ }
2012
+ /**
2013
+ * Create a named set of sandboxes for one workload.
2014
+ */
2015
+ interface CreateSandboxFleetOptions {
2016
+ /** Stable fleet id. Generated when omitted. */
2017
+ fleetId?: string;
2018
+ /** Shared defaults applied to every machine before per-machine overrides. */
2019
+ defaults?: Omit<CreateSandboxOptions, "metadata" | "name">;
2020
+ /** Machines to create. */
2021
+ machines: SandboxFleetMachineSpec[];
2022
+ /** Fleet-level metadata copied to each sandbox under stable tags. */
2023
+ metadata?: Record<string, unknown>;
2024
+ /** Workspace policy for isolated or driver-supported shared mounts. */
2025
+ workspace?: SandboxFleetWorkspace;
2026
+ /**
2027
+ * Client-side safety caps for this create call. These do not replace
2028
+ * server-side quota enforcement.
2029
+ */
2030
+ policy?: SandboxFleetPolicy;
2031
+ /**
2032
+ * Delete already-created machines if a later machine fails to create.
2033
+ * Defaults to true so partial fleets do not silently burn quota.
2034
+ */
2035
+ cleanupOnFailure?: boolean;
2036
+ /**
2037
+ * Maximum concurrent sandbox creates for this fleet request.
2038
+ * Defaults to 4 to avoid accidental control-plane stampedes while still
2039
+ * provisioning worker fleets faster than serial creation.
2040
+ */
2041
+ maxConcurrentCreates?: number;
2042
+ /**
2043
+ * Idempotency key for the server-backed fleet record. Defaults to fleetId.
2044
+ */
2045
+ idempotencyKey?: string;
2046
+ }
2047
+ interface CreateSandboxFleetWithCoordinatorOptions extends Omit<CreateSandboxFleetOptions, "machines"> {
2048
+ /** Coordinator machine. Defaults to machineId "coordinator". */
2049
+ coordinator?: Omit<SandboxFleetMachineSpec, "machineId" | "role"> & {
2050
+ machineId?: FleetMachineId;
2051
+ };
2052
+ /** Worker machines attached to the same fleet. */
2053
+ workers: SandboxFleetMachineSpec[];
2054
+ }
2055
+ /**
2056
+ * A sandbox with its fleet-local machine id.
2057
+ */
2058
+ interface SandboxFleetMachine {
2059
+ machineId: FleetMachineId;
2060
+ sandbox: SandboxInfo;
2061
+ role?: SandboxFleetMachineRole;
2062
+ }
2063
+ /**
2064
+ * Fleet create/list result.
2065
+ */
2066
+ interface SandboxFleetInfo {
2067
+ fleetId: string;
2068
+ machines: SandboxFleetMachine[];
2069
+ }
2070
+ interface FleetExecDispatchOptions extends Pick<ExecOptions, "cwd" | "env" | "timeoutMs"> {
2071
+ machines?: FleetMachineId[];
2072
+ maxConcurrent?: number;
2073
+ retry?: {
2074
+ attempts?: number;
2075
+ };
2076
+ /** Caller-supplied dispatch id for idempotency/result lookup when supported by the API. */
2077
+ dispatchId?: string;
2078
+ /** Ask the API to retain branch results for later `dispatchResults` calls. */
2079
+ bufferResults?: boolean;
2080
+ }
2081
+ interface FleetExecDispatchResult {
2082
+ machineId: FleetMachineId;
2083
+ sandboxId: string;
2084
+ ok: boolean;
2085
+ durationMs: number;
2086
+ attempts?: number;
2087
+ result?: ExecResult;
2088
+ error?: {
2089
+ message: string;
2090
+ status?: number;
2091
+ failureClass?: SandboxFleetDispatchFailureClass;
2092
+ };
2093
+ }
2094
+ interface FleetPromptDispatchOptions extends Pick<PromptOptions, "sessionId" | "model" | "backend" | "timeoutMs" | "context"> {
2095
+ machines?: FleetMachineId[];
2096
+ maxConcurrent?: number;
2097
+ retry?: {
2098
+ attempts?: number;
2099
+ };
2100
+ /** Caller-supplied dispatch id for idempotency/result lookup when supported by the API. */
2101
+ dispatchId?: string;
2102
+ /** Ask the API to retain branch results for later `dispatchResults` calls. */
2103
+ bufferResults?: boolean;
2104
+ }
2105
+ interface FleetPromptDispatchResult {
2106
+ machineId: FleetMachineId;
2107
+ sandboxId: string;
2108
+ ok: boolean;
2109
+ durationMs: number;
2110
+ attempts?: number;
2111
+ prompt?: PromptResult & {
2112
+ metadata?: Record<string, unknown>;
2113
+ };
2114
+ error?: {
2115
+ message: string;
2116
+ status?: number;
2117
+ failureClass?: SandboxFleetDispatchFailureClass;
2118
+ };
2119
+ }
2120
+ type SandboxFleetDispatchFailureClass = "oom" | "timeout" | "dependency" | "infra" | "model" | "user_code";
2121
+ interface FleetDispatchStreamOptions {
2122
+ signal?: AbortSignal;
2123
+ }
2124
+ interface FleetDispatchResultBufferOptions {
2125
+ cursor?: string;
2126
+ limit?: number;
2127
+ machines?: FleetMachineId[];
2128
+ }
2129
+ interface FleetDispatchResultBuffer<T = FleetExecDispatchResult | FleetPromptDispatchResult> {
2130
+ fleetId: string;
2131
+ dispatchId: string;
2132
+ results: T[];
2133
+ cursor?: string;
2134
+ nextCursor?: string;
2135
+ done?: boolean;
2136
+ truncated?: boolean;
2137
+ trace?: SandboxFleetTraceExport;
2138
+ intelligence?: SandboxFleetIntelligenceEnvelope;
2139
+ }
2140
+ interface FleetDispatchCancelResult {
2141
+ fleetId: string;
2142
+ dispatchId: string;
2143
+ cancelled: boolean;
2144
+ status?: string;
2145
+ }
2146
+ interface SandboxFleetArtifactSpec {
2147
+ machineId: FleetMachineId;
2148
+ /**
2149
+ * Absolute path under /workspace. Fleet artifact collection intentionally
2150
+ * rejects host/system paths so caller-provided manifests cannot turn artifact
2151
+ * collection into arbitrary sandbox file reads.
2152
+ */
2153
+ path: string;
2154
+ label?: string;
2155
+ /** Maximum allowed artifact content size in bytes. Defaults to 5 MiB. */
2156
+ maxBytes?: number;
2157
+ }
2158
+ interface SandboxFleetArtifact extends SandboxFleetArtifactSpec {
2159
+ sandboxId: string;
2160
+ content: string;
2161
+ }
2162
+ interface SandboxFleetDriverTimings {
2163
+ queueMs?: number;
2164
+ placementMs?: number;
2165
+ provisionMs?: number;
2166
+ startupMs?: number;
2167
+ cleanupMs?: number;
2168
+ }
2169
+ interface SandboxFleetMachineMeteredUsage {
2170
+ runtimeMs: number;
2171
+ updatedAt: string;
2172
+ }
2173
+ interface AttachSandboxFleetMachineOptions {
2174
+ machineId: FleetMachineId;
2175
+ sandboxId: string;
2176
+ status?: string;
2177
+ role?: SandboxFleetMachineRole;
2178
+ driverType?: DriverType;
2179
+ image?: string;
2180
+ environment?: string;
2181
+ templateId?: string;
2182
+ publicTemplateId?: string;
2183
+ acceleratorCount?: number;
2184
+ driverTimings?: SandboxFleetDriverTimings;
2185
+ }
2186
+ interface SandboxFleetMachineRecord extends AttachSandboxFleetMachineOptions {
2187
+ workspaceMountPath?: string;
2188
+ meteredUsage?: SandboxFleetMachineMeteredUsage;
2189
+ createdAt?: string;
2190
+ updatedAt?: string;
2191
+ }
2192
+ interface SandboxFleetManifestMachine {
2193
+ machineId: FleetMachineId;
2194
+ sandboxId: string;
2195
+ role?: SandboxFleetMachineRole;
2196
+ status?: string;
2197
+ driverType?: DriverType;
2198
+ image?: string;
2199
+ environment?: string;
2200
+ templateId?: string;
2201
+ publicTemplateId?: string;
2202
+ acceleratorCount?: number;
2203
+ workspaceMountPath?: string;
2204
+ driverTimings?: SandboxFleetDriverTimings;
2205
+ meteredUsage?: SandboxFleetMachineMeteredUsage;
2206
+ createdAt?: string;
2207
+ updatedAt?: string;
2208
+ }
2209
+ interface SandboxFleetManifest {
2210
+ fleetId?: string;
2211
+ id?: string;
2212
+ metadata?: Record<string, unknown>;
2213
+ policy?: SandboxFleetPolicy;
2214
+ resources?: Record<string, unknown>;
2215
+ workspace?: SandboxFleetWorkspace & {
2216
+ status?: string;
2217
+ createdAt?: string;
2218
+ updatedAt?: string;
2219
+ deletedAt?: string;
2220
+ };
2221
+ machines: SandboxFleetManifestMachine[];
2222
+ createdAt?: string;
2223
+ updatedAt?: string;
2224
+ }
2225
+ interface SandboxFleetDispatchResponse<T = FleetExecDispatchResult | FleetPromptDispatchResult> {
2226
+ fleetId: string;
2227
+ dispatchId: string;
2228
+ type: "exec" | "prompt";
2229
+ results: T[];
2230
+ durationMs: number;
2231
+ trace?: SandboxFleetTraceExport;
2232
+ intelligence?: SandboxFleetIntelligenceEnvelope;
2233
+ }
2234
+ interface SandboxFleetWorkspaceSnapshotResult {
2235
+ snapshotId?: string;
2236
+ id?: string;
2237
+ status?: string;
2238
+ createdAt?: string;
2239
+ [key: string]: JsonValue | undefined;
2240
+ }
2241
+ interface SandboxFleetWorkspaceRestoreResult {
2242
+ restored?: boolean;
2243
+ snapshotId?: string;
2244
+ status?: string;
2245
+ [key: string]: JsonValue | undefined;
2246
+ }
2247
+ interface SandboxFleetWorkspaceReconcileResult {
2248
+ fleetId: string;
2249
+ workspaceId?: string;
2250
+ checked: number;
2251
+ orphanedMounts: number;
2252
+ machines: Array<{
2253
+ machineId: string;
2254
+ sandboxId: string;
2255
+ mounted: boolean;
2256
+ }>;
2257
+ }
2258
+ interface SandboxFleetDriverCapability {
2259
+ driverType: DriverType;
2260
+ sharedWorkspace: boolean;
2261
+ accelerators: boolean;
2262
+ queueTimings: boolean;
2263
+ }
2264
+ interface SandboxFleetOperationsSummary {
2265
+ capacity: {
2266
+ fleets: number;
2267
+ machines: number;
2268
+ runningMachines: number;
2269
+ failedMachines: number;
2270
+ requestedCpu: number;
2271
+ requestedMemoryMb: number;
2272
+ requestedStorageMb: number;
2273
+ requestedAccelerators: number;
2274
+ };
2275
+ alerts: Array<{
2276
+ name: string;
2277
+ severity: "info" | "warn" | "critical";
2278
+ fleetId?: string;
2279
+ machineId?: string;
2280
+ message: string;
2281
+ runbook: string[];
2282
+ }>;
2283
+ }
2284
+ interface ReconcileSandboxFleetsOptions {
2285
+ dryRun?: boolean;
2286
+ }
2287
+ interface ReconcileSandboxFleetsResult {
2288
+ dryRun: boolean;
2289
+ checked: number;
2290
+ orphaned: number;
2291
+ removed: number;
2292
+ machines: Array<{
2293
+ fleetId: string;
2294
+ machineId: string;
2295
+ sandboxId: string;
2296
+ removed: boolean;
2297
+ status?: number;
2298
+ error?: string;
2299
+ }>;
2300
+ }
2301
+ interface SandboxFleetUsage {
2302
+ usage: {
2303
+ fleetId: string;
2304
+ status: string;
2305
+ machineCount: number;
2306
+ coordinatorCount: number;
2307
+ workerCount: number;
2308
+ runningMachines: number;
2309
+ failedMachines: number;
2310
+ resources?: {
2311
+ machines: number;
2312
+ totalCpu: number;
2313
+ totalMemoryMb: number;
2314
+ totalStorageMb: number;
2315
+ totalAccelerators: number;
2316
+ maxLifetimeSeconds?: number;
2317
+ };
2318
+ meteredUsage?: {
2319
+ runtimeMs: number;
2320
+ machineRuntimeMs: Record<string, number>;
2321
+ updatedAt: string;
2322
+ };
2323
+ createdAt: string;
2324
+ updatedAt: string;
2325
+ };
2326
+ insights: {
2327
+ reliabilityScore: number;
2328
+ parallelismEfficiencyScore: number;
2329
+ failureRate: number;
2330
+ recommendedActions: string[];
2331
+ };
2332
+ trace: SandboxFleetTraceExport;
2333
+ intelligence: SandboxFleetIntelligenceEnvelope;
2334
+ }
2335
+ interface SandboxFleetTraceEvent {
2336
+ type: "fleet.lifecycle.snapshot" | "fleet.machine.lifecycle.snapshot" | "fleet.workspace.lifecycle.snapshot" | "fleet.usage.snapshot" | "fleet.dispatch.result" | "fleet.insight.summary";
2337
+ timestamp: string;
2338
+ fleetId: string;
2339
+ machineId?: string;
2340
+ durationMs?: number;
2341
+ attributes: Record<string, unknown>;
2342
+ }
2343
+ interface SandboxFleetTraceExport {
2344
+ schemaVersion: "fleet.trace.v1";
2345
+ traceId: string;
2346
+ fleetId: string;
2347
+ exportedAt: string;
2348
+ timings: {
2349
+ observedLifecycleMs: number;
2350
+ machineObservedLifecycleMs: number;
2351
+ dispatchFanoutMs: number;
2352
+ dispatchRuntimeMs: number;
2353
+ cleanupObservedMs: number;
2354
+ driverQueueMs: number;
2355
+ driverPlacementMs: number;
2356
+ driverProvisionMs: number;
2357
+ driverStartupMs: number;
2358
+ driverCleanupMs: number;
2359
+ };
2360
+ criticalPath: {
2361
+ durationMs: number;
2362
+ phases: Array<{
2363
+ name: string;
2364
+ durationMs: number;
2365
+ machineId?: string;
2366
+ }>;
2367
+ };
2368
+ events: SandboxFleetTraceEvent[];
2369
+ }
2370
+ interface SandboxFleetIntelligenceEnvelope {
2371
+ schemaVersion: "fleet.intelligence.v1";
2372
+ source: "sandbox-api";
2373
+ subject: {
2374
+ type: "sandbox_fleet";
2375
+ fleetId: string;
2376
+ };
2377
+ billing: {
2378
+ billable: false;
2379
+ billedTo: "platform";
2380
+ costUsd: 0;
2381
+ reason: "deterministic_platform_insight";
2382
+ };
2383
+ metrics: Record<string, number>;
2384
+ signals: Array<{
2385
+ name: string;
2386
+ value: string | number | boolean;
2387
+ severity: "info" | "warn" | "critical";
2388
+ rationale: string;
2389
+ }>;
2390
+ recommendedActions: string[];
2391
+ }
2392
+ interface SandboxFleetTraceBundle {
2393
+ trace: SandboxFleetTraceExport;
2394
+ intelligence?: SandboxFleetIntelligenceEnvelope;
2395
+ }
2396
+ interface SandboxFleetTraceOptions {
2397
+ /**
2398
+ * Include the platform-generated intelligence envelope. Defaults to false.
2399
+ * Set true when a customer wants generated insight with the raw trace export.
2400
+ */
2401
+ includeIntelligence?: boolean;
2402
+ }
2403
+ interface SandboxFleetCostEstimate {
2404
+ plan: "free" | "pro" | "enterprise";
2405
+ currency: "USD";
2406
+ hourlyUsd: number;
2407
+ maxLifetimeSeconds: number;
2408
+ estimatedMaxLifetimeUsd: number;
2409
+ requestedResources: {
2410
+ machines: number;
2411
+ totalCpu: number;
2412
+ totalMemoryMb: number;
2413
+ totalStorageMb: number;
2414
+ totalAccelerators: number;
2415
+ maxLifetimeSeconds?: number;
2416
+ };
2417
+ rates: {
2418
+ cpuPerHr: number;
2419
+ ramPerGbHr: number;
2420
+ diskPerGbHr: number;
2421
+ acceleratorPerDeviceHr: number;
2422
+ minChargePerHr: number;
2423
+ entDiscount: number;
2424
+ };
2425
+ }
2426
+ type SandboxFleetTokenAction = "list" | "create" | "delete" | "exec" | "prompt" | "read" | "write";
2427
+ interface CreateSandboxFleetTokenOptions {
2428
+ /** Allowed fleet actions. Defaults to read/list/exec. */
2429
+ actions?: SandboxFleetTokenAction[];
2430
+ /** Optional token-side policy caps enforced by the Sandbox API. */
2431
+ policy?: SandboxFleetPolicy;
2432
+ /** Token lifetime in minutes. API clamps to its server-side maximum. */
2433
+ ttlMinutes?: number;
2434
+ }
2435
+ interface SandboxFleetToken {
2436
+ token: string;
2437
+ expiresAt: number;
2438
+ fleetId: string;
2439
+ actions: SandboxFleetTokenAction[];
2440
+ policy?: SandboxFleetPolicy;
2441
+ }
2442
+ interface ReapExpiredSandboxFleetsOptions {
2443
+ dryRun?: boolean;
2444
+ }
2445
+ interface ReapExpiredSandboxFleetsResult {
2446
+ dryRun: boolean;
2447
+ expired: number;
2448
+ deleted: number;
2449
+ fleets: Array<{
2450
+ fleetId: string;
2451
+ expiredAt: string;
2452
+ deleted: boolean;
2453
+ machines: Array<{
2454
+ machineId: string;
2455
+ sandboxId: string;
2456
+ ok: boolean;
2457
+ status?: number;
2458
+ error?: string;
2459
+ }>;
2460
+ }>;
2461
+ }
2462
+ /**
2463
+ * Options for listing fleet machines.
2464
+ */
2465
+ interface ListSandboxFleetOptions extends ListSandboxOptions {
2466
+ /** Fleet id to filter by. */
2467
+ fleetId: string;
2468
+ }
1335
2469
  /**
1336
2470
  * Options for creating a checkpoint.
1337
2471
  */
@@ -1408,9 +2542,29 @@ interface ForkResult {
1408
2542
  */
1409
2543
  type DriverType = "docker" | "firecracker" | "host-agent" | "tangle";
1410
2544
  /**
1411
- * Accelerator class for GPU-enabled sandboxes.
2545
+ * Accelerator class for GPU-class workloads.
2546
+ *
2547
+ * Examples: `nvidia-h100`, `nvidia-l4`, `nvidia-rtx-4090`, `amd-mi300x`.
2548
+ * Providers can introduce new SKU labels without requiring an SDK release.
1412
2549
  */
1413
- type GpuType = "nvidia-a100" | "nvidia-h100" | "nvidia-l4" | "amd-mi250";
2550
+ type AcceleratorKind = string;
2551
+ /**
2552
+ * Compute accelerator request.
2553
+ *
2554
+ * Accelerators are requested as resources because they are part of workload
2555
+ * shape and billing, not a driver option.
2556
+ */
2557
+ interface SandboxAccelerator {
2558
+ /** Accelerator class required by the workload. */
2559
+ kind: AcceleratorKind;
2560
+ /**
2561
+ * Number of accelerator devices required.
2562
+ * @default 1
2563
+ */
2564
+ count?: number;
2565
+ /** Minimum device memory in megabytes when the exact GPU class is flexible. */
2566
+ memoryMB?: number;
2567
+ }
1414
2568
  /**
1415
2569
  * Infrastructure driver configuration.
1416
2570
  *
@@ -1424,12 +2578,10 @@ type GpuType = "nvidia-a100" | "nvidia-h100" | "nvidia-l4" | "amd-mi250";
1424
2578
  * driver: { type: "firecracker", enableCriu: true }
1425
2579
  * ```
1426
2580
  *
1427
- * @example GPU-enabled sandbox
2581
+ * @example Accelerator-backed sandbox
1428
2582
  * ```typescript
1429
- * driver: {
1430
- * type: "host-agent",
1431
- * gpuRequired: true,
1432
- * gpuType: "nvidia-a100",
2583
+ * resources: {
2584
+ * accelerator: { kind: "nvidia-a100", count: 1 },
1433
2585
  * }
1434
2586
  * ```
1435
2587
  */
@@ -1444,20 +2596,23 @@ interface DriverConfig {
1444
2596
  * Support depends on the selected driver.
1445
2597
  */
1446
2598
  enableCriu?: boolean;
1447
- /** Require a GPU for this sandbox. */
1448
- gpuRequired?: boolean;
1449
- /** Accelerator class preference. */
1450
- gpuType?: GpuType;
1451
- /**
1452
- * Number of GPUs required.
1453
- * @default 1 (when gpuRequired is true)
1454
- */
1455
- gpuCount?: number;
1456
2599
  /**
1457
2600
  * Preferred placement region.
1458
2601
  * e.g., "us-east-1", "eu-west-1".
1459
2602
  */
1460
2603
  preferredRegion?: string;
2604
+ /**
2605
+ * @deprecated Use `resources.accelerator` on sandbox or fleet machine specs.
2606
+ */
2607
+ gpuRequired?: boolean;
2608
+ /**
2609
+ * @deprecated Use `resources.accelerator.kind`.
2610
+ */
2611
+ gpuType?: GpuType;
2612
+ /**
2613
+ * @deprecated Use `resources.accelerator.count`.
2614
+ */
2615
+ gpuCount?: number;
1461
2616
  }
1462
2617
  /**
1463
2618
  * Driver capabilities and status.
@@ -1482,6 +2637,11 @@ interface DriverInfo {
1482
2637
  available: number;
1483
2638
  total: number;
1484
2639
  };
2640
+ acceleratorCapacity?: {
2641
+ available: number;
2642
+ total: number;
2643
+ kinds: AcceleratorKind[];
2644
+ };
1485
2645
  }
1486
2646
  /**
1487
2647
  * Backend type identifier. Controls which AI agent runtime runs inside the sandbox.
@@ -1508,9 +2668,10 @@ interface DriverInfo {
1508
2668
  * - `"acp"` — Agent Client Protocol bridge — fronts any ACP-compliant
1509
2669
  * agent binary (claude-agent-acp, codex-acp, gemini, openclaw acp).
1510
2670
  * Pick the backing agent via config.subAgent.
2671
+ * - `"cursor"` — Cursor Agent SDK local/cloud backend.
1511
2672
  * - `"cli-base"` — Minimal CLI-only (no AI agent).
1512
2673
  */
1513
- type BackendType = "opencode" | "claude-code" | "kimi-code" | "codex" | "amp" | "factory-droids" | "pi" | "hermes" | "forge" | "openclaw" | "acp" | "cli-base";
2674
+ type BackendType = "opencode" | "claude-code" | "kimi-code" | "codex" | "amp" | "factory-droids" | "pi" | "hermes" | "forge" | "openclaw" | "acp" | "cursor" | "cli-base";
1514
2675
  /**
1515
2676
  * MCP (Model Context Protocol) server configuration.
1516
2677
  */
@@ -1643,6 +2804,60 @@ interface BackendInfo {
1643
2804
  tags?: string[];
1644
2805
  }>;
1645
2806
  }
2807
+ interface BackendListOptions {
2808
+ limit?: number;
2809
+ cursor?: string;
2810
+ }
2811
+ interface BackendListResult<TItem> {
2812
+ items: TItem[];
2813
+ nextCursor?: string;
2814
+ }
2815
+ interface BackendAccount {
2816
+ apiKeyName?: string;
2817
+ userId?: number;
2818
+ userEmail?: string;
2819
+ userFirstName?: string;
2820
+ userLastName?: string;
2821
+ createdAt?: string;
2822
+ metadata?: Record<string, unknown>;
2823
+ }
2824
+ interface BackendModel {
2825
+ id: string;
2826
+ displayName?: string;
2827
+ description?: string;
2828
+ parameters?: Array<Record<string, unknown>>;
2829
+ variants?: Array<Record<string, unknown>>;
2830
+ }
2831
+ interface BackendRepository {
2832
+ url: string;
2833
+ }
2834
+ interface BackendAgent {
2835
+ agentId: string;
2836
+ name?: string;
2837
+ summary?: string;
2838
+ lastModified?: number;
2839
+ status?: "running" | "finished" | "error";
2840
+ createdAt?: number;
2841
+ archived?: boolean;
2842
+ runtime?: "local" | "cloud";
2843
+ cwd?: string;
2844
+ env?: Record<string, unknown>;
2845
+ repos?: string[];
2846
+ }
2847
+ interface BackendRun {
2848
+ id: string;
2849
+ agentId?: string;
2850
+ status?: "running" | "finished" | "cancelled" | "error";
2851
+ result?: string;
2852
+ durationMs?: number;
2853
+ model?: Record<string, unknown>;
2854
+ git?: Record<string, unknown>;
2855
+ }
2856
+ interface BackendArtifact {
2857
+ path: string;
2858
+ sizeBytes?: number;
2859
+ updatedAt?: string;
2860
+ }
1646
2861
  /**
1647
2862
  * Network configuration for sandbox network isolation.
1648
2863
  *
@@ -1981,6 +3196,34 @@ interface BackendManager {
1981
3196
  }>>;
1982
3197
  /** Update backend configuration */
1983
3198
  updateConfig(config: Partial<BackendConfig>): Promise<void>;
3199
+ /** Provider account metadata, when exposed by the backend SDK */
3200
+ account(): Promise<BackendAccount>;
3201
+ /** Provider model catalog, when exposed by the backend SDK */
3202
+ models(): Promise<BackendModel[]>;
3203
+ /** Provider repository catalog, when exposed by the backend SDK */
3204
+ repositories(): Promise<BackendRepository[]>;
3205
+ /** Provider-native agent list */
3206
+ agents(options?: BackendListOptions): Promise<BackendListResult<BackendAgent>>;
3207
+ /** Provider-native agent lookup */
3208
+ agent(agentId: string): Promise<BackendAgent>;
3209
+ /** Archive provider-native agent */
3210
+ archiveAgent(agentId: string): Promise<void>;
3211
+ /** Unarchive provider-native agent */
3212
+ unarchiveAgent(agentId: string): Promise<void>;
3213
+ /** Delete provider-native agent */
3214
+ deleteAgent(agentId: string): Promise<void>;
3215
+ /** Provider-native runs for an agent */
3216
+ runs(agentId: string, options?: BackendListOptions): Promise<BackendListResult<BackendRun>>;
3217
+ /** Provider-native run lookup */
3218
+ run(runId: string, options?: {
3219
+ agentId?: string;
3220
+ }): Promise<BackendRun>;
3221
+ /** Provider-native agent messages */
3222
+ agentMessages(agentId: string, options?: BackendListOptions): Promise<unknown>;
3223
+ /** Artifacts for an active backend session */
3224
+ artifacts(sessionId: string): Promise<BackendArtifact[]>;
3225
+ /** Download an artifact from an active backend session */
3226
+ downloadArtifact(sessionId: string, path: string): Promise<Uint8Array>;
1984
3227
  /**
1985
3228
  * Validate a provider-neutral profile against the active backend.
1986
3229
  *
@@ -2248,6 +3491,20 @@ interface SecretInfo {
2248
3491
  /** When the secret was last updated */
2249
3492
  updatedAt: Date;
2250
3493
  }
3494
+ interface SshKeyInfo {
3495
+ id: string;
3496
+ name: string;
3497
+ publicKey: string;
3498
+ fingerprint: string;
3499
+ keyType: string;
3500
+ createdAt: Date;
3501
+ updatedAt: Date;
3502
+ }
3503
+ interface SshKeysManager {
3504
+ create(name: string, publicKey: string): Promise<SshKeyInfo>;
3505
+ list(): Promise<SshKeyInfo[]>;
3506
+ delete(id: string): Promise<void>;
3507
+ }
2251
3508
  /**
2252
3509
  * Secrets manager for storing and retrieving encrypted secrets.
2253
3510
  * Access via `client.secrets`.
@@ -2452,12 +3709,10 @@ interface DeleteOptions {
2452
3709
  recursive?: boolean;
2453
3710
  }
2454
3711
  /**
2455
- * Enhanced file system operations for sandboxes.
2456
- * Access via `sandbox.fs`.
3712
+ * File system operations for sandboxes. Access via `sandbox.fs`.
2457
3713
  *
2458
- * Provides comprehensive file operations beyond basic read/write,
2459
- * including binary file upload/download, directory operations,
2460
- * and progress reporting for large files.
3714
+ * Beyond basic read/write: binary upload/download, directory operations,
3715
+ * progress reporting for large files.
2461
3716
  *
2462
3717
  * @example Upload and download files
2463
3718
  * ```typescript
@@ -2672,6 +3927,262 @@ interface FileSystem {
2672
3927
  */
2673
3928
  exists(path: string): Promise<boolean>;
2674
3929
  }
3930
+ /** Languages supported by the persistent code kernel. */
3931
+ type CodeLanguage = "python" | "node" | "typescript" | "bash";
3932
+ /**
3933
+ * One structured result produced by a runCode() call. The kernel emits these
3934
+ * alongside stdout — matplotlib figures arrive as `image`, pandas DataFrames
3935
+ * as `dataframe`, explicit `display(value)` calls as `json` or `html`, and
3936
+ * uncaught exceptions as `error` plus an `error` field on the result.
3937
+ */
3938
+ type CodeResultPart = {
3939
+ type: "text";
3940
+ value: string;
3941
+ } | {
3942
+ type: "json";
3943
+ value: unknown;
3944
+ } | {
3945
+ type: "image";
3946
+ format: "png" | "jpeg" | "svg"; /** base64-encoded image bytes (no `data:` prefix). */
3947
+ data: string;
3948
+ } | {
3949
+ type: "html";
3950
+ value: string;
3951
+ } | {
3952
+ type: "dataframe";
3953
+ columns: {
3954
+ name: string;
3955
+ dtype: string;
3956
+ }[];
3957
+ rows: unknown[][];
3958
+ truncated: boolean;
3959
+ } | {
3960
+ type: "error";
3961
+ name: string;
3962
+ message: string;
3963
+ traceback?: string;
3964
+ };
3965
+ /**
3966
+ * Outcome of a single runCode() call.
3967
+ *
3968
+ * `stdout`/`stderr` are the user-visible streams with frame markers stripped.
3969
+ * `results` is the structured-result list. `error` is set when user code
3970
+ * raised; the kernel itself stays alive and the next call reuses its state.
3971
+ */
3972
+ interface CodeExecutionResult {
3973
+ exitCode: number;
3974
+ stdout: string;
3975
+ stderr: string;
3976
+ durationMs: number;
3977
+ results: CodeResultPart[];
3978
+ error?: {
3979
+ name: string;
3980
+ message: string;
3981
+ traceback?: string;
3982
+ };
3983
+ }
3984
+ /** Options for `box.runCode()`. */
3985
+ interface CodeExecutionOptions {
3986
+ /** Session scope: kernels persist variables across calls with the same id. */
3987
+ sessionId?: string;
3988
+ /** Per-call timeout in ms. 0 disables. Default 60_000. */
3989
+ timeoutMs?: number;
3990
+ /** Extra env vars merged in for this call only. */
3991
+ env?: Record<string, string>;
3992
+ /** Working directory override (honored on kernel creation only). */
3993
+ cwd?: string;
3994
+ /**
3995
+ * Caller-supplied dedup key. Two `runCode` calls with the same key and
3996
+ * the same `sessionId` within a 15-minute window return the same result
3997
+ * without re-executing — including the case where the second call arrives
3998
+ * while the first is still running (it awaits the in-flight result).
3999
+ *
4000
+ * Scoped per `sessionId` so two sessions reusing the same key stay
4001
+ * isolated. A failed execution is not cached; a retry with the same key
4002
+ * gets a fresh attempt.
4003
+ *
4004
+ * For exactly-once across an outer agent loop (multi-turn tool use), pair
4005
+ * with `box.dispatchPrompt({ sessionId, turnId })` — the agent layer
4006
+ * dedups the whole loop, this one dedups a single code-exec call.
4007
+ */
4008
+ idempotencyKey?: string;
4009
+ }
4010
+ //#endregion
4011
+ //#region src/mcp.d.ts
4012
+ /**
4013
+ * MCP (Model Context Protocol) helpers for sandbox capabilities.
4014
+ *
4015
+ * The sandbox exposes capabilities (currently `computer_use`, more
4016
+ * later) as MCP tools over Streamable HTTP. Any MCP-capable client —
4017
+ * Claude Desktop, Cursor, claude-code, codex, opencode, raw
4018
+ * `@modelcontextprotocol/sdk` apps — can consume this surface by
4019
+ * pasting the JSON returned from `Sandbox#getMcpEndpoint()` (or
4020
+ * `buildSandboxMcpConfig` if you already have the URL + token) into
4021
+ * the client's MCP config.
4022
+ *
4023
+ * Security model:
4024
+ * - Tokens are capability-scoped JWTs (claim `cap: ["computer_use"]`).
4025
+ * - Full sandbox runtime tokens are rejected on `/mcp`; only
4026
+ * capability-scoped tokens work there.
4027
+ * - A scoped token cannot pivot to admin endpoints (`/exec`, `/files`,
4028
+ * etc.) — those routes reject scoped tokens.
4029
+ * - Tokens are short-lived. Rotate via `Sandbox#getMcpEndpoint()`,
4030
+ * which mints a fresh token each call.
4031
+ */
4032
+ /** Default name of the MCP server entry — surfaces in the host UI. */
4033
+ declare const SANDBOX_MCP_SERVER_NAME = "tangle-sandbox";
4034
+ /**
4035
+ * MCP HTTP server entry — matches the Anthropic MCP HTTP transport
4036
+ * schema (`type: "http"`, `url`, optional `headers`). Compatible with
4037
+ * every MCP host that implements the spec.
4038
+ */
4039
+ interface SandboxMcpServerEntry {
4040
+ type: "http";
4041
+ url: string;
4042
+ headers: Record<string, string>;
4043
+ }
4044
+ /**
4045
+ * `.mcp.json`-shaped config any MCP host accepts. Drop the contents of
4046
+ * `mcpServers` into your host's `mcpServers` block (Claude Desktop,
4047
+ * Cursor, claude-code's `--mcp-config`, etc.) — no host-specific
4048
+ * fields, no provider lock-in.
4049
+ */
4050
+ interface SandboxMcpConfig {
4051
+ mcpServers: Record<string, SandboxMcpServerEntry>;
4052
+ }
4053
+ /**
4054
+ * Endpoint payload returned by `GET /v1/sandboxes/:id/mcp`. Includes
4055
+ * the canonical config plus token expiry so callers can plan
4056
+ * refreshes.
4057
+ */
4058
+ interface SandboxMcpEndpoint {
4059
+ /** MCP host config — paste this into Cursor/Claude Desktop/etc. */
4060
+ config: SandboxMcpConfig;
4061
+ /** Server entry name used inside `config.mcpServers`. */
4062
+ serverName: string;
4063
+ /** Reachable URL for the MCP HTTP transport. */
4064
+ url: string;
4065
+ /** Bearer token sent by the MCP host on every request. */
4066
+ authToken: string;
4067
+ /** ISO-8601 expiry — the host should refresh before this. */
4068
+ expiresAt: string;
4069
+ /** Capabilities the token is scoped to. */
4070
+ capabilities: ReadonlyArray<"computer_use">;
4071
+ }
4072
+ interface BuildSandboxMcpConfigOptions {
4073
+ /** Public sandbox URL where `/mcp` is reachable. No trailing slash. */
4074
+ sandboxUrl: string;
4075
+ /** Capability-scoped JWT minted by the Sandbox API. */
4076
+ authToken: string;
4077
+ /** Override the entry name. Defaults to SANDBOX_MCP_SERVER_NAME. */
4078
+ serverName?: string;
4079
+ }
4080
+ /**
4081
+ * Build the canonical `mcpServers` config for a sandbox MCP endpoint.
4082
+ * Pure function — no I/O, no crypto. Use this when you already have a
4083
+ * `{ url, authToken }` pair from the API and just want the JSON shape
4084
+ * to paste into a host. Most callers should use
4085
+ * `Sandbox#getMcpEndpoint()` instead, which fetches a freshly-minted
4086
+ * token from the API.
4087
+ */
4088
+ declare function buildSandboxMcpConfig(options: BuildSandboxMcpConfigOptions): {
4089
+ serverName: string;
4090
+ config: SandboxMcpConfig;
4091
+ };
4092
+ //#endregion
4093
+ //#region src/session.d.ts
4094
+ /**
4095
+ * The subset of `SandboxInstance` a `SandboxSession` drives. Declared here
4096
+ * (rather than importing the concrete class) so `session.ts` stays a leaf
4097
+ * of `sandbox.ts` — `sandbox.ts` constructs `SandboxSession`, so the reverse
4098
+ * import would form a cycle. `SandboxInstance` satisfies this structurally.
4099
+ */
4100
+ interface SandboxSessionHost {
4101
+ prompt(message: string | PromptInputPart[], options?: PromptOptions): Promise<PromptResult>;
4102
+ _sessionStatus(id: string): Promise<SessionInfo | null>;
4103
+ _sessionEvents(id: string, opts?: SessionEventStreamOptions): AsyncGenerator<SandboxEvent>;
4104
+ _sessionResult(id: string): Promise<PromptResult>;
4105
+ _sessionCancel(id: string): Promise<void>;
4106
+ }
4107
+ /**
4108
+ * A single agent session inside a sandbox. Created via
4109
+ * `box.session(id)` — does not hit the network until a method is called.
4110
+ */
4111
+ declare class SandboxSession {
4112
+ private readonly box;
4113
+ /** Stable session id assigned by the sandbox runtime. */
4114
+ readonly id: string;
4115
+ /**
4116
+ * @internal SDK-internal constructor — apps should call `box.session(id)`.
4117
+ */
4118
+ constructor(box: SandboxSessionHost, /** Stable session id assigned by the sandbox runtime. */
4119
+
4120
+ id: string);
4121
+ /**
4122
+ * Fetch the current session state from the sandbox. Includes status,
4123
+ * model, prompt count, token usage if known, and timing metadata.
4124
+ *
4125
+ * Throws on transport error; returns `null` if the session id is not
4126
+ * known to the sandbox (e.g. it ended and was reaped, or the id is
4127
+ * invalid).
4128
+ */
4129
+ status(): Promise<SessionInfo | null>;
4130
+ /**
4131
+ * Stream events from this session as they arrive. With no `since`,
4132
+ * starts at the live tail; with `since`, replays from that event id
4133
+ * forward — useful for reconnect-after-disconnect flows.
4134
+ *
4135
+ * The async iterator terminates when the session reaches a terminal
4136
+ * state (`completed`, `failed`, `cancelled`) and the corresponding
4137
+ * terminal event has been yielded, OR when the caller's signal aborts.
4138
+ */
4139
+ events(opts?: SessionEventStreamOptions): AsyncGenerator<SandboxEvent>;
4140
+ /**
4141
+ * Await the session's terminal result. Polls status + drains events
4142
+ * until the session reaches a terminal state, then returns the
4143
+ * aggregated `PromptResult`.
4144
+ *
4145
+ * Use this to wait for a session that was started by another caller
4146
+ * (e.g. `dispatchPrompt`).
4147
+ */
4148
+ result(): Promise<PromptResult>;
4149
+ /**
4150
+ * Continue this session with an additional prompt. Equivalent to
4151
+ * `box.prompt(message, { ...opts, sessionId: this.id })` but reads
4152
+ * naturally on a Session reference.
4153
+ */
4154
+ prompt(message: string | PromptInputPart[], opts?: PromptOptions): Promise<PromptResult>;
4155
+ /**
4156
+ * Cancel the session. Best-effort: an in-flight LLM call may still
4157
+ * complete one more token before the abort takes effect. Idempotent —
4158
+ * cancelling a completed session is a no-op.
4159
+ */
4160
+ cancel(): Promise<void>;
4161
+ }
4162
+ //#endregion
4163
+ //#region src/trace-exporter.d.ts
4164
+ type JsonObject = {
4165
+ [key: string]: JsonValue;
4166
+ };
4167
+ type TraceExportFormat = "tangle" | "otel-json";
4168
+ type TraceExportBundle = SandboxTraceBundle | SandboxFleetTraceBundle;
4169
+ interface TraceExportSink {
4170
+ url: string;
4171
+ headers?: Record<string, string>;
4172
+ format?: TraceExportFormat;
4173
+ serviceName?: string;
4174
+ timeoutMs?: number;
4175
+ fetch?: typeof fetch;
4176
+ }
4177
+ interface TraceExportResult {
4178
+ status: number;
4179
+ ok: boolean;
4180
+ body: string;
4181
+ }
4182
+ declare function buildTraceExportPayload(bundle: TraceExportBundle, format?: TraceExportFormat, serviceName?: string): TraceExportBundle | JsonObject;
4183
+ declare function exportTraceBundle(bundle: TraceExportBundle, sink: TraceExportSink): Promise<TraceExportResult>;
4184
+ declare function toOtelJson(bundle: TraceExportBundle, serviceName?: string): JsonObject;
4185
+ declare function otelTraceIdForTangleTrace(traceId: string): string;
2675
4186
  //#endregion
2676
4187
  //#region src/sandbox.d.ts
2677
4188
  /**
@@ -2679,6 +4190,7 @@ interface FileSystem {
2679
4190
  */
2680
4191
  interface HttpClient {
2681
4192
  fetch(path: string, options?: RequestInit): Promise<Response>;
4193
+ getApiKey?(): string | undefined;
2682
4194
  }
2683
4195
  /**
2684
4196
  * Git capability for repository operations.
@@ -2755,9 +4267,26 @@ declare class SandboxInstance {
2755
4267
  /** Web terminal URL for browser-based access */
2756
4268
  get url(): string | undefined;
2757
4269
  /**
2758
- * Serialize to the public sandbox shape for CLI JSON output.
4270
+ * Serialize to the public sandbox shape for logs and structured
4271
+ * output. Secrets in `connection` (currently `authToken`) are
4272
+ * redacted so that `JSON.stringify(box)` is safe to ship to log
4273
+ * sinks. Use {@link toDebugJSON} when the bearer is required (e.g.
4274
+ * one-off CLI commands that print credentials to the user).
2759
4275
  */
2760
4276
  toJSON(): SandboxInfo;
4277
+ /**
4278
+ * Serialize the sandbox **including secrets** when `includeSecrets`
4279
+ * is true. The default behavior matches {@link toJSON} and redacts
4280
+ * `connection.authToken`.
4281
+ *
4282
+ * Use only when the caller has an explicit need for the bearer
4283
+ * (e.g. presenting it once to the human operator). Never wire the
4284
+ * result of `toDebugJSON({ includeSecrets: true })` into a structured
4285
+ * logger — the bearer will land in any log sink consuming that output.
4286
+ */
4287
+ toDebugJSON(options?: {
4288
+ includeSecrets?: boolean;
4289
+ }): SandboxInfo;
2761
4290
  /**
2762
4291
  * Create an advanced direct-runtime view of this sandbox.
2763
4292
  *
@@ -2766,6 +4295,30 @@ declare class SandboxInstance {
2766
4295
  * Lifecycle methods still go through the parent SDK client.
2767
4296
  */
2768
4297
  direct(): SandboxInstance;
4298
+ /**
4299
+ * Get an MCP endpoint for this sandbox. Returns a paste-able config
4300
+ * for any MCP-capable host (Claude Desktop, Cursor, claude-code,
4301
+ * codex, opencode, …) plus a freshly-minted, capability-scoped JWT.
4302
+ *
4303
+ * The token is short-lived and limited to the requested capabilities
4304
+ * — it cannot be used against admin endpoints (`/exec`, `/files`,
4305
+ * etc.) on the sandbox. Call `getMcpEndpoint()` again to rotate.
4306
+ *
4307
+ * Requires the sandbox to have been created with `capabilities`
4308
+ * including the requested capability (default: `computer_use`).
4309
+ *
4310
+ * @example
4311
+ * ```typescript
4312
+ * const ep = await box.getMcpEndpoint();
4313
+ * // Save ep.config to your IDE's mcp.json — that's it.
4314
+ * fs.writeFileSync("mcp.json", JSON.stringify(ep.config, null, 2));
4315
+ * ```
4316
+ */
4317
+ getMcpEndpoint(options?: {
4318
+ capabilities?: ReadonlyArray<"computer_use">; /** Override server entry name (default: "tangle-sandbox"). */
4319
+ serverName?: string; /** Token TTL in minutes (server clamps to its policy). */
4320
+ ttlMinutes?: number;
4321
+ }): Promise<SandboxMcpEndpoint>;
2769
4322
  /**
2770
4323
  * Refresh sandbox information from the server.
2771
4324
  */
@@ -2828,10 +4381,39 @@ declare class SandboxInstance {
2828
4381
  * Throws if SSH is not enabled or sandbox is not running.
2829
4382
  */
2830
4383
  ssh(): Promise<SSHCredentials>;
4384
+ sshCommand(): Promise<SSHCommandDescriptor>;
2831
4385
  /**
2832
4386
  * Execute a command in the sandbox.
2833
4387
  */
2834
4388
  exec(command: string, options?: ExecOptions): Promise<ExecResult>;
4389
+ /**
4390
+ * Run code in a persistent language kernel.
4391
+ *
4392
+ * Each `(sessionId, language)` pair gets its own long-lived kernel that
4393
+ * keeps variable state across calls — like Jupyter cells. Without a
4394
+ * `sessionId`, calls share a process-wide kernel per language.
4395
+ *
4396
+ * Returns typed results: stdout/stderr text plus a `results` array of
4397
+ * structured outputs (matplotlib images as base64 PNG, pandas DataFrames,
4398
+ * explicit `display(value)` calls as JSON/HTML, errors with traceback).
4399
+ *
4400
+ * @example Persistent Python session
4401
+ * ```ts
4402
+ * await box.runCode("python", "import pandas as pd; df = pd.DataFrame({'x': range(5)})", { sessionId: "s1" });
4403
+ * const r = await box.runCode("python", "df.describe()", { sessionId: "s1" });
4404
+ * // r.results[0] is a `dataframe` part with columns + rows from the describe()
4405
+ * ```
4406
+ *
4407
+ * @example Matplotlib chart
4408
+ * ```ts
4409
+ * const r = await box.runCode("python",
4410
+ * "import matplotlib.pyplot as plt; plt.plot([1,2,3,4]); plt.show()",
4411
+ * { sessionId: "s1" });
4412
+ * const png = r.results.find(p => p.type === "image");
4413
+ * // png.data is a base64 PNG ready to render or hand back to an LLM
4414
+ * ```
4415
+ */
4416
+ runCode(language: CodeLanguage, source: string, options?: CodeExecutionOptions): Promise<CodeExecutionResult>;
2835
4417
  /**
2836
4418
  * Read a file from the sandbox.
2837
4419
  *
@@ -2881,6 +4463,21 @@ declare class SandboxInstance {
2881
4463
  * Stream sandbox lifecycle and activity events.
2882
4464
  */
2883
4465
  events(options?: EventStreamOptions): AsyncGenerator<SandboxEvent>;
4466
+ trace(options?: SandboxTraceOptions): Promise<SandboxTraceBundle>;
4467
+ intelligence(): Promise<NonNullable<SandboxTraceBundle["intelligence"]>>;
4468
+ createIntelligenceReport(options?: {
4469
+ mode?: "deterministic" | "agentic";
4470
+ acknowledgeCost?: boolean;
4471
+ budget?: IntelligenceReportBudget;
4472
+ metadata?: Record<string, unknown>; /** Bound the analysis to a time window. */
4473
+ window?: IntelligenceReportWindow; /** Compare this sandbox against a same-type baseline sandbox. */
4474
+ compareTo?: IntelligenceReportCompareTo;
4475
+ }): Promise<IntelligenceReport>;
4476
+ createAgenticIntelligenceReport(options: {
4477
+ maxUsd: number;
4478
+ metadata?: Record<string, unknown>;
4479
+ }): Promise<IntelligenceReport>;
4480
+ exportTrace(sink: TraceExportSink): Promise<TraceExportResult>;
2884
4481
  /**
2885
4482
  * Stream real-time provisioning progress events.
2886
4483
  *
@@ -2999,12 +4596,10 @@ declare class SandboxInstance {
2999
4596
  */
3000
4597
  get tools(): ToolsCapability;
3001
4598
  /**
3002
- * Enhanced file system operations.
3003
- *
3004
- * Provides comprehensive file operations beyond basic read/write:
3005
- * - Binary file upload/download
3006
- * - Directory operations (uploadDir, downloadDir, list, mkdir)
3007
- * - File metadata (stat, exists)
4599
+ * File system operations beyond basic read/write:
4600
+ * - Binary upload/download
4601
+ * - Directory ops (uploadDir, downloadDir, list, mkdir)
4602
+ * - Metadata (stat, exists)
3008
4603
  * - Progress reporting for large files
3009
4604
  *
3010
4605
  * @example Upload and download
@@ -3084,6 +4679,13 @@ declare class SandboxInstance {
3084
4679
  * args: ["-y", "@anthropic/web-search"],
3085
4680
  * });
3086
4681
  * ```
4682
+ *
4683
+ * @example Read provider-native Cursor metadata
4684
+ * ```typescript
4685
+ * const models = await box.backend.models();
4686
+ * const agents = await box.backend.agents({ limit: 20 });
4687
+ * const runs = await box.backend.runs(agents.items[0].agentId);
4688
+ * ```
3087
4689
  */
3088
4690
  get backend(): BackendManager;
3089
4691
  private backendStatus;
@@ -3091,6 +4693,22 @@ declare class SandboxInstance {
3091
4693
  private backendAddMcp;
3092
4694
  private backendGetMcpStatus;
3093
4695
  private backendUpdateConfig;
4696
+ private backendControlData;
4697
+ private backendControlAction;
4698
+ private backendListSearch;
4699
+ private backendAccount;
4700
+ private backendModels;
4701
+ private backendRepositories;
4702
+ private backendAgents;
4703
+ private backendAgent;
4704
+ private backendArchiveAgent;
4705
+ private backendUnarchiveAgent;
4706
+ private backendDeleteAgent;
4707
+ private backendRuns;
4708
+ private backendRun;
4709
+ private backendAgentMessages;
4710
+ private backendArtifacts;
4711
+ private backendDownloadArtifact;
3094
4712
  private backendRestart;
3095
4713
  /**
3096
4714
  * Process manager for spawning and controlling processes.
@@ -3454,6 +5072,82 @@ declare class SandboxInstance {
3454
5072
  }): Promise<void>;
3455
5073
  private parseInfo;
3456
5074
  private sleep;
5075
+ /**
5076
+ * Get a session reference bound to this sandbox. Lazy: does not hit the
5077
+ * network until you call a method on the returned `SandboxSession`.
5078
+ * Use {@link sessions} to discover existing session ids.
5079
+ */
5080
+ session(id: string): SandboxSession;
5081
+ /**
5082
+ * List sessions on this sandbox, optionally filtering by status. Returns
5083
+ * `SandboxSession` instances paired with their last-known
5084
+ * {@link SessionInfo} so callers can avoid an extra round-trip per
5085
+ * session for status.
5086
+ */
5087
+ sessions(opts?: SessionListOptions): Promise<Array<{
5088
+ session: SandboxSession;
5089
+ info: SessionInfo;
5090
+ }>>;
5091
+ /**
5092
+ * Dispatch a prompt and return immediately with the session id (Issue
5093
+ * #913 Gap 2). The sandbox keeps running the prompt after this call
5094
+ * returns; reconnect via `box.session(id).events()` or wait for
5095
+ * completion with `box.session(id).result()`.
5096
+ *
5097
+ * Idempotent on `opts.sessionId`: re-dispatching with the same id when
5098
+ * the session is already running is a lookup, not a re-create. This
5099
+ * lets queue retries and reconnect-after-Worker-restart be safe by
5100
+ * construction.
5101
+ */
5102
+ dispatchPrompt(message: string | PromptInputPart[], opts?: DispatchPromptOptions): Promise<DispatchedSession>;
5103
+ /**
5104
+ * List messages for a session, including in-flight assistant content
5105
+ * the agent is still streaming. Each entry's `metadata` carries the
5106
+ * durability marker — `status: "streaming" | "completed" | "interrupted"`,
5107
+ * `completed/interrupted` booleans, and the caller-supplied `turnId`
5108
+ * when one was set. See `SessionMessage` for the full contract.
5109
+ *
5110
+ * Polling this is the right way to detect "did the sidecar die mid-
5111
+ * turn?" — a SIGKILL leaves the assistant message with `status:
5112
+ * "streaming"` and no `completed`/`interrupted` marker; a graceful
5113
+ * abort stamps `interrupted: true` explicitly.
5114
+ */
5115
+ messages(opts: ListMessagesOptions): Promise<SessionMessage[]>;
5116
+ /**
5117
+ * Look up a cached turn result by idempotency key. Returns the cached
5118
+ * payload if a turn with this `turnId` previously completed on the
5119
+ * given session; returns `null` if no such turn has finished yet
5120
+ * (either it never started, or it interrupted before completion).
5121
+ *
5122
+ * Call this before re-issuing a `streamPrompt` / `prompt` / `task`
5123
+ * that you might be retrying — a non-null result means the original
5124
+ * attempt finished and you can return that to your caller instead of
5125
+ * running the agent a second time. Only turns that reach the
5126
+ * `completed` terminal state are cached; interrupted turns are not.
5127
+ */
5128
+ findCompletedTurn(turnId: string, opts: {
5129
+ sessionId: string;
5130
+ }): Promise<CompletedTurnResult | null>;
5131
+ /**
5132
+ * Mint a scoped, time-bounded JWT for direct browser access to this
5133
+ * sandbox (Issue #913 Gap 1). Authority is the caller's
5134
+ * `TANGLE_API_KEY` (sk-tan-*) — the Sandbox API mints the token;
5135
+ * signing secrets stay server-side.
5136
+ *
5137
+ * Use this to give a browser direct read access to the sandbox without
5138
+ * leaking the full bearer (`box.connection.authToken`). The returned
5139
+ * token verifies against the same sidecar middleware that already
5140
+ * gates ProductTokenIssuer-issued JWTs — no new sidecar surface.
5141
+ */
5142
+ mintScopedToken(opts: MintScopedTokenOptions): Promise<ScopedToken>;
5143
+ /** @internal — invoked by SandboxSession.status(). */
5144
+ _sessionStatus(id: string): Promise<SessionInfo | null>;
5145
+ /** @internal — invoked by SandboxSession.events(). */
5146
+ _sessionEvents(id: string, opts?: SessionEventStreamOptions): AsyncGenerator<SandboxEvent>;
5147
+ /** @internal — invoked by SandboxSession.result(). */
5148
+ _sessionResult(id: string): Promise<PromptResult>;
5149
+ /** @internal — invoked by SandboxSession.cancel(). */
5150
+ _sessionCancel(id: string): Promise<void>;
3457
5151
  }
3458
5152
  //#endregion
3459
- export { Process as $, AgentProfileResourceRef as $t, ExecResult as A, StorageConfig as At, GitStatus as B, UpdateUserOptions as Bt, DownloadOptions as C, SearchMatch as Ct, DriverType as D, SnapshotInfo as Dt, DriverInfo as E, SecretsManager as Et, GitAuth as F, TeeAttestationReport as Ft, McpServerConfig as G, AgentProfile as Gt, InstalledTool as H, UploadProgress as Ht, GitBranch as I, TeeAttestationResponse as It, NetworkManager as J, AgentProfileFileMount as Jt, MkdirOptions as K, AgentProfileCapabilities as Kt, GitCommit as L, TeePublicKey as Lt, FileSystem as M, TaskOptions as Mt, ForkOptions as N, TaskResult as Nt, EventStreamOptions as O, SnapshotOptions as Ot, ForkResult as P, TeeAttestationOptions as Pt, PreviewLinkManager as Q, AgentProfilePrompt as Qt, GitConfig as R, TeePublicKeyResponse as Rt, DirectoryPermission as S, SandboxUser as St, DriverConfig as T, SecretInfo as Tt, ListOptions as U, UsageInfo as Ut, GpuType as V, UploadOptions as Vt, ListSandboxOptions as W, WaitForOptions as Wt, PermissionsManager as X, AgentProfileModelHints as Xt, PermissionLevel as Y, AgentProfileMcpServer as Yt, PreviewLinkInfo as Z, AgentProfilePermissionValue as Zt, CheckpointOptions as _, SandboxEvent as _t, BackendCapabilities as a, defineGitHubResource as an, ProcessStatus as at, CreateSandboxOptions as b, SandboxResources as bt, BackendManager as c, ProvisionEvent as ct, BatchEvent as d, ProvisionStep as dt, AgentProfileResources as en, ProcessInfo as et, BatchOptions as f, RunCodeOptions as ft, CheckpointInfo as g, SandboxEnvironment as gt, BatchTaskResult as h, SandboxConnection as ht, AddUserOptions as i, defineAgentProfile as in, ProcessSpawnOptions as it, FileInfo as j, SubscriptionInfo as jt, ExecOptions as k, SnapshotResult as kt, BackendStatus as l, ProvisionResult as lt, BatchTask as m, SandboxClientConfig as mt, SandboxInstance as n, AgentProfileValidationResult as nn, ProcessManager as nt, BackendConfig as o, defineInlineResource as on, PromptOptions as ot, BatchResult as p, SSHCredentials as pt, NetworkConfig as q, AgentProfileConfidential as qt, AccessPolicyRule as r, AgentSubagentProfile as rn, ProcessSignal as rt, BackendInfo as s, mergeAgentProfiles as sn, PromptResult as st, HttpClient as t, AgentProfileValidationIssue as tn, ProcessLogEntry as tt, BackendType as u, ProvisionStatus as ut, CheckpointResult as v, SandboxInfo as vt, DownloadProgress as w, SearchOptions as wt, DeleteOptions as x, SandboxStatus as xt, CodeResult as y, SandboxPermissionsConfig as yt, GitDiff as z, ToolsConfig as zt };
5153
+ export { DriverInfo as $, SandboxTraceOptions as $n, ProvisionEvent as $t, BatchTask as A, SandboxFleetMachineSpec as An, UsageInfo as Ar, ListMessagesOptions as At, CompletedTurnResult as B, SandboxFleetUsage as Bn, AgentProfileResourceRef as Br, PermissionsManager as Bt, BackendInfo as C, SandboxFleetDriverCapability as Cn, TeePublicKey as Cr, GpuType as Ct, BatchEvent as D, SandboxFleetMachine as Dn, UpdateUserOptions as Dr, IntelligenceReportCompareTo as Dt, BackendType as E, SandboxFleetIntelligenceEnvelope as En, ToolsConfig as Er, IntelligenceReportBudget as Et, CodeExecutionOptions as F, SandboxFleetToken as Fn, AgentProfileFileMount as Fr, MintScopedTokenOptions as Ft, CreateSandboxOptions as G, SandboxInfo as Gn, defineAgentProfile as Gr, ProcessLogEntry as Gt, CreateSandboxFleetOptions as H, SandboxFleetWorkspaceReconcileResult as Hn, AgentProfileValidationIssue as Hr, PreviewLinkManager as Ht, CodeExecutionResult as I, SandboxFleetTraceBundle as In, AgentProfileMcpServer as Ir, MkdirOptions as It, DispatchPromptOptions as J, SandboxResources as Jn, mergeAgentProfiles as Jr, ProcessSpawnOptions as Jt, DeleteOptions as K, SandboxIntelligenceEnvelope as Kn, defineGitHubResource as Kr, ProcessManager as Kt, CodeLanguage as L, SandboxFleetTraceEvent as Ln, AgentProfileModelHints as Lr, NetworkConfig as Lt, CheckpointInfo as M, SandboxFleetManifestMachine as Mn, AgentProfile as Mr, ListSandboxFleetOptions as Mt, CheckpointOptions as N, SandboxFleetOperationsSummary as Nn, AgentProfileCapabilities as Nr, ListSandboxOptions as Nt, BatchOptions as O, SandboxFleetMachineMeteredUsage as On, UploadOptions as Or, IntelligenceReportSubjectType as Ot, CheckpointResult as P, SandboxFleetPolicy as Pn, AgentProfileConfidential as Pr, McpServerConfig as Pt, DriverConfig as Q, SandboxTraceExport as Qn, PromptResult as Qt, CodeResult as R, SandboxFleetTraceExport as Rn, AgentProfilePermissionValue as Rr, NetworkManager as Rt, BackendConfig as S, SandboxFleetDispatchResponse as Sn, TeeAttestationResponse as Sr, GitStatus as St, BackendStatus as T, SandboxFleetInfo as Tn, TokenRefreshHandler as Tr, IntelligenceReport as Tt, CreateSandboxFleetTokenOptions as U, SandboxFleetWorkspaceRestoreResult as Un, AgentProfileValidationResult as Ur, Process as Ut, CreateIntelligenceReportOptions as V, SandboxFleetWorkspace as Vn, AgentProfileResources as Vr, PreviewLinkInfo as Vt, CreateSandboxFleetWithCoordinatorOptions as W, SandboxFleetWorkspaceSnapshotResult as Wn, AgentSubagentProfile as Wr, ProcessInfo as Wt, DownloadOptions as X, SandboxTraceBundle as Xn, PromptInputPart as Xt, DispatchedSession as Y, SandboxStatus as Yn, ProcessStatus as Yt, DownloadProgress as Z, SandboxTraceEvent as Zn, PromptOptions as Zt, AcceleratorKind as _, SandboxEvent as _n, SubscriptionInfo as _r, GitAuth as _t, TraceExportSink as a, PublishPublicTemplateOptions as an, SecretInfo as ar, FileSystem as at, AttachSandboxFleetMachineOptions as b, SandboxFleetCostEstimate as bn, TeeAttestationOptions as br, GitConfig as bt, otelTraceIdForTangleTrace as c, ReapExpiredSandboxFleetsResult as cn, SessionInfo as cr, FleetDispatchResultBufferOptions as ct, BuildSandboxMcpConfigOptions as d, RunCodeOptions as dn, SessionStatus as dr, FleetExecDispatchResult as dt, ProvisionResult as en, SandboxUser as er, DriverType as et, SANDBOX_MCP_SERVER_NAME as f, SSHCommandDescriptor as fn, SnapshotInfo as fr, FleetMachineId as ft, buildSandboxMcpConfig as g, SandboxEnvironment as gn, StorageConfig as gr, ForkResult as gt, SandboxMcpServerEntry as h, SandboxConnection as hn, SshKeysManager as hr, ForkOptions as ht, TraceExportResult as i, PublicTemplateVersionInfo as in, SearchOptions as ir, FileInfo as it, BatchTaskResult as j, SandboxFleetManifest as jn, WaitForOptions as jr, ListOptions as jt, BatchResult as k, SandboxFleetMachineRecord as kn, UploadProgress as kr, IntelligenceReportWindow as kt, toOtelJson as l, ReconcileSandboxFleetsOptions as ln, SessionListOptions as lr, FleetDispatchStreamOptions as lt, SandboxMcpEndpoint as m, SandboxClientConfig as mn, SnapshotResult as mr, FleetPromptDispatchResult as mt, SandboxInstance as n, ProvisionStep as nn, ScopedTokenScope as nr, ExecOptions as nt, buildTraceExportPayload as o, PublishPublicTemplateVersionOptions as on, SecretsManager as or, FleetDispatchCancelResult as ot, SandboxMcpConfig as p, SSHCredentials as pn, SnapshotOptions as pr, FleetPromptDispatchOptions as pt, DirectoryPermission as q, SandboxPermissionsConfig as qn, defineInlineResource as qr, ProcessSignal as qt, TraceExportFormat as r, PublicTemplateInfo as rn, SearchMatch as rr, ExecResult as rt, exportTraceBundle as s, ReapExpiredSandboxFleetsOptions as sn, SessionEventStreamOptions as sr, FleetDispatchResultBuffer as st, HttpClient as t, ProvisionStatus as tn, ScopedToken as tr, EventStreamOptions as tt, SandboxSession as u, ReconcileSandboxFleetsResult as un, SessionMessage as ur, FleetExecDispatchOptions as ut, AccessPolicyRule as v, SandboxFleetArtifact as vn, TaskOptions as vr, GitBranch as vt, BackendManager as w, SandboxFleetDriverTimings as wn, TeePublicKeyResponse as wr, InstalledTool as wt, BackendCapabilities as x, SandboxFleetDispatchFailureClass as xn, TeeAttestationReport as xr, GitDiff as xt, AddUserOptions as y, SandboxFleetArtifactSpec as yn, TaskResult as yr, GitCommit as yt, CodeResultPart as z, SandboxFleetTraceOptions as zn, AgentProfilePrompt as zr, PermissionLevel as zt };