@tangle-network/sandbox 0.63.19 → 0.63.21

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 (65) hide show
  1. package/dist/agent/index.d.ts +4 -4
  2. package/dist/agent/index.js +5 -5
  3. package/dist/agent/preview.d.ts +1 -1
  4. package/dist/agent/preview.js +2 -2
  5. package/dist/{agent-run-outcome-DlYhZnhD.d.ts → agent-run-outcome-C-VR-L0I.d.ts} +1 -1
  6. package/dist/auth/index.d.ts +2 -2
  7. package/dist/auth/index.js +1 -1
  8. package/dist/{backend-types-D6bYbvMB.js → backend-types-zuUBEJO1.js} +35 -1
  9. package/dist/{browser-interactive-control-controller-B6sySQFu.d.ts → browser-interactive-control-controller-CvObO_Kf.d.ts} +1 -1
  10. package/dist/{browser-interactive-control-controller-BJf0P_J4.js → browser-interactive-control-controller-DHx53yre.js} +16 -1
  11. package/dist/{chunked-upload-KJyRCAiC.js → chunked-upload-DN2twsUu.js} +1 -1
  12. package/dist/{chunked-upload-file-DfiGzqaR.js → chunked-upload-file-Dpv1YsoA.js} +2 -2
  13. package/dist/{cli-auth-bundle-CMgB8Ec3.js → cli-auth-bundle-AvhkWJHX.js} +1 -1
  14. package/dist/{client-Dl22CVOz.js → client-5yqzAcFJ.js} +3271 -3271
  15. package/dist/client-CqpKC6n3.d.ts +6066 -0
  16. package/dist/collaboration/index.d.ts +1 -1
  17. package/dist/collaboration/index.js +1 -1
  18. package/dist/{collaboration-XHg5BEUI.js → collaboration-g_HzXa6f.js} +1 -1
  19. package/dist/core.d.ts +6 -7
  20. package/dist/core.js +5 -5
  21. package/dist/{direct-http2-Dq7tq6jV.js → direct-http2-CoGVOqVR.js} +1 -1
  22. package/dist/{errors-AB5BD3FM.js → errors-BfbOP_rx.js} +19 -1
  23. package/dist/{sandbox-DDdPhk2j.d.ts → index-D4OBUP5M.d.ts} +2105 -1461
  24. package/dist/index.d.ts +12 -4747
  25. package/dist/index.js +15 -11
  26. package/dist/intelligence/index.js +1 -1
  27. package/dist/interactive-control.d.ts +1 -1
  28. package/dist/interactive-control.js +1 -1
  29. package/dist/{interactive-controller-BSWoA0YE.d.ts → interactive-controller-BBwB_5QQ.d.ts} +3 -2
  30. package/dist/{interactive-controller-zE6hwv3C.js → interactive-controller-D4N4zqmu.js} +578 -610
  31. package/dist/{lines-hsXVdk60.d.ts → lines-5m11CEj-.d.ts} +21 -17
  32. package/dist/lines-C5ER4aN_.js +298 -0
  33. package/dist/lines.d.ts +1 -1
  34. package/dist/lines.js +1 -295
  35. package/dist/{local-cli-auth-C4QcPdZt.js → local-cli-auth-CSnvjLAP.js} +1 -1
  36. package/dist/{mcp-local-BYHcA72Z.js → mcp-local-BjLG7VHY.js} +1 -1
  37. package/dist/{preview-D8UAF7F9.d.ts → preview-CcJBQSjB.d.ts} +3 -3
  38. package/dist/{public-templates-BP3sTaSb.d.ts → public-templates-nv4AFFVc.d.ts} +2 -2
  39. package/dist/public-templates.d.ts +1 -1
  40. package/dist/public-templates.js +1 -1
  41. package/dist/runtime.d.ts +47 -40
  42. package/dist/runtime.js +4 -4
  43. package/dist/{sandbox-BJkpVtLN.js → sandbox-BGIam_wK.js} +9256 -9215
  44. package/dist/{secp256k1-DoWlH6ff.js → secp256k1-CmLpsmWl.js} +1 -1
  45. package/dist/session-gateway/index.d.ts +16 -17
  46. package/dist/session-gateway/index.js +20 -23
  47. package/dist/tangle/index.d.ts +1 -1
  48. package/dist/tangle/index.js +1 -1
  49. package/dist/{tangle-BBpguPfj.js → tangle--i0MX6UC.js} +144 -138
  50. package/dist/terminal-stream-types-ClZCArRg.d.ts +662 -0
  51. package/dist/{types-BxZX2EVj.d.ts → types-BjyQe_CI.d.ts} +393 -315
  52. package/package.json +5 -5
  53. package/dist/client-DraGbXEP.d.ts +0 -1249
  54. package/dist/error-classes-BWS1a9HO.d.ts +0 -321
  55. package/dist/index-xS3mRl69.d.ts +0 -578
  56. package/dist/managed-process-B-pXdMLC.d.ts +0 -15
  57. package/dist/terminal-stream-DgD7GlFi.d.ts +0 -388
  58. /package/dist/{cli-auth-bundle-BKsrsbxy.d.ts → cli-auth-bundle-Dyw3hCGx.d.ts} +0 -0
  59. /package/dist/{index-DfA_usrZ.d.ts → index-C8VSFtWl.d.ts} +0 -0
  60. /package/dist/{index-CWUW8pqr.d.ts → index-CVjTnRWP.d.ts} +0 -0
  61. /package/dist/{keep-alive-fetch-CXvfSczd.js → keep-alive-fetch-CuwGi7gz.js} +0 -0
  62. /package/dist/{line-application-UtPFP0o4.js → line-application-DY9ZTdgF.js} +0 -0
  63. /package/dist/{preview-operations-Bvo5YcIq.js → preview-operations-Ca02vPDJ.js} +0 -0
  64. /package/dist/{raw-evidence-archive-Bxk6fUjS.js → raw-evidence-archive-CDYDqHNv.js} +0 -0
  65. /package/dist/{utils-B6gap92T.js → utils-BGvM02yJ.js} +0 -0
@@ -1,1249 +0,0 @@
1
- import { c as TraceExportResult, l as TraceExportSink, n as SandboxInstance } from "./sandbox-DDdPhk2j.js";
2
- import { $t as FleetAgentResult, An as SandboxFleetMachineRecord, Bn as SandboxFleetToken, Cn as SandboxFleetDispatchResponse, D as SshKeysManager, E as SecretsManager, En as SandboxFleetInfo, F as UsageInfo, Fn as SandboxFleetParent, Gn as SandboxFleetUsage, Ia as IntelligenceReportWindow, Jn as SandboxFleetWorkspaceRestoreResult, Jt as CreateSandboxFleetOptions, La as PromptInputPart, Ln as SandboxFleetPolicy, Ma as IntelligenceReport, Mn as SandboxFleetManifest, N as SandboxIdentity, Na as IntelligenceReportBudget, P as SubscriptionInfo, Pa as IntelligenceReportCompareTo, Pn as SandboxFleetOperationsSummary, Ra as PromptOptions, Ta as CreateIntelligenceReportOptions, Vn as SandboxFleetTraceBundle, Wn as SandboxFleetTraceOptions, Xn as ListSandboxOptions, Xt as CreateSandboxFleetWithCoordinatorOptions, Ya as BackendConfig, Yn as SandboxFleetWorkspaceSnapshotResult, Yt as CreateSandboxFleetTokenOptions, Zt as FleetAgentId, _a as BatchRunOptions, _n as SandboxFleetAgent, a as DeleteMatchingSandboxesOptions, an as FleetExecDispatchOptions, bi as SandboxEnvironment, bn as SandboxFleetArtifactSpec, br as SandboxConfig, cn as FleetPromptDispatchOptions, dn as FleetRunOptions, dt as TokenRefreshHandler, ea as HttpClient, er as SandboxInfo, fn as ListSandboxFleetOptions, ga as BatchResult, gn as ReconcileSandboxFleetsResult, gt as ConversationTurnResult, hi as ExecResult, hn as ReconcileSandboxFleetsOptions, ht as ConversationTurnOptions, i as DeleteMatchingSandboxesFilter, in as FleetDispatchStreamOptions, jn as SandboxFleetMachineSpec, ln as FleetPromptDispatchResult, lt as FleetDriveTurnOutcome, mi as ExecOptions, mn as ReapExpiredSandboxFleetsResult, na as SdkTimingHook, nn as FleetDispatchResultBuffer, o as DeleteMatchingSandboxesResult, on as FleetExecDispatchResult, pn as ReapExpiredSandboxFleetsOptions, qn as SandboxFleetWorkspaceReconcileResult, qt as AttachSandboxFleetMachineOptions, rn as FleetDispatchResultBufferOptions, rr as SandboxRunGeneration, sn as FleetMachineId, tn as FleetDispatchCancelResult, un as FleetRunEvent, ut as FleetDriveTurnRequest, va as BatchRunRequest, vr as CreateRequestOptions, wn as SandboxFleetDriverCapability, wo as BatchEvent, wr as SandboxShapesInfo, xn as SandboxFleetCostEstimate, yn as SandboxFleetArtifact, yr as CreateSandboxOptions, za as PromptResult, zn as SandboxFleetSpend } from "./types-BxZX2EVj.js";
3
- import { d as MintInteractiveSessionTokenOptions, p as ScopedToken } from "./terminal-stream-DgD7GlFi.js";
4
- import { L as LinesClient } from "./lines-hsXVdk60.js";
5
- import { g as SandboxError } from "./error-classes-BWS1a9HO.js";
6
- import { a as PublicTemplatesClient } from "./public-templates-BP3sTaSb.js";
7
- import { z } from "zod";
8
- import { AgentInteractiveSessionRef, AgentProfile } from "@tangle-network/agent-interface";
9
-
10
- //#region src/backend-registry.d.ts
11
- /** Interaction kinds a backend can originate when the caller enables them. */
12
- declare const backendRegistryInteractionKindSchema: z.ZodEnum<{
13
- permission: "permission";
14
- question: "question";
15
- plan: "plan";
16
- }>;
17
- type BackendRegistryInteractionKind = z.infer<typeof backendRegistryInteractionKindSchema>;
18
- /** True when an advertised interaction kind is understood by this SDK. */
19
- declare function isBackendRegistryInteractionKind(value: string): value is BackendRegistryInteractionKind;
20
- /** Static capabilities advertised by one registered agent backend. */
21
- declare const backendRegistryCapabilitiesSchema: z.ZodObject<{
22
- streaming: z.ZodBoolean;
23
- toolUse: z.ZodBoolean;
24
- reasoning: z.ZodBoolean;
25
- multimodal: z.ZodBoolean;
26
- imageInput: z.ZodBoolean;
27
- contextWindow: z.ZodNumber;
28
- mcp: z.ZodBoolean;
29
- runtimeAttachments: z.ZodOptional<z.ZodObject<{
30
- mcp: z.ZodLiteral<true>;
31
- }, z.core.$strip>>;
32
- sessions: z.ZodBoolean;
33
- configurable: z.ZodBoolean;
34
- interactions: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("permission" | "question" | "plan")[], string[]>>;
35
- }, z.core.$strip>;
36
- /** One backend entry returned by the Sandbox API registry. */
37
- declare const backendRegistryEntrySchema: z.ZodObject<{
38
- type: z.ZodString;
39
- name: z.ZodString;
40
- description: z.ZodString;
41
- capabilities: z.ZodObject<{
42
- streaming: z.ZodBoolean;
43
- toolUse: z.ZodBoolean;
44
- reasoning: z.ZodBoolean;
45
- multimodal: z.ZodBoolean;
46
- imageInput: z.ZodBoolean;
47
- contextWindow: z.ZodNumber;
48
- mcp: z.ZodBoolean;
49
- runtimeAttachments: z.ZodOptional<z.ZodObject<{
50
- mcp: z.ZodLiteral<true>;
51
- }, z.core.$strip>>;
52
- sessions: z.ZodBoolean;
53
- configurable: z.ZodBoolean;
54
- interactions: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("permission" | "question" | "plan")[], string[]>>;
55
- }, z.core.$strip>;
56
- callerCredentialOnly: z.ZodOptional<z.ZodBoolean>;
57
- }, z.core.$strip>;
58
- /** The exact response returned by authenticated `GET /v1/backends`. */
59
- declare const backendRegistryResponseSchema: z.ZodObject<{
60
- backends: z.ZodArray<z.ZodObject<{
61
- type: z.ZodString;
62
- name: z.ZodString;
63
- description: z.ZodString;
64
- capabilities: z.ZodObject<{
65
- streaming: z.ZodBoolean;
66
- toolUse: z.ZodBoolean;
67
- reasoning: z.ZodBoolean;
68
- multimodal: z.ZodBoolean;
69
- imageInput: z.ZodBoolean;
70
- contextWindow: z.ZodNumber;
71
- mcp: z.ZodBoolean;
72
- runtimeAttachments: z.ZodOptional<z.ZodObject<{
73
- mcp: z.ZodLiteral<true>;
74
- }, z.core.$strip>>;
75
- sessions: z.ZodBoolean;
76
- configurable: z.ZodBoolean;
77
- interactions: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("permission" | "question" | "plan")[], string[]>>;
78
- }, z.core.$strip>;
79
- callerCredentialOnly: z.ZodOptional<z.ZodBoolean>;
80
- }, z.core.$strip>>;
81
- timestamp: z.ZodString;
82
- }, z.core.$strip>;
83
- type BackendRegistryCapabilities = z.infer<typeof backendRegistryCapabilitiesSchema>;
84
- type BackendRegistryEntry = z.infer<typeof backendRegistryEntrySchema>;
85
- type BackendRegistryResponse = z.infer<typeof backendRegistryResponseSchema>;
86
- /**
87
- * Validate required registry fields and ignore fields from newer API versions.
88
- * Unknown runners remain visible. Unknown interaction kinds remain disabled.
89
- */
90
- declare function parseBackendRegistryResponse(value: unknown): BackendRegistryResponse;
91
- /** Parse and validate the JSON body returned by `GET /v1/backends`. */
92
- declare function parseBackendRegistryResponseBody(body: string): BackendRegistryResponse;
93
- //#endregion
94
- //#region src/lib/sse-parser.d.ts
95
- /**
96
- * SSE Stream Parser
97
- *
98
- * EventSource stream parsing for SDK consumers. Framing — buffering
99
- * chunk-straddling frames, LF/CRLF terminators, multi-line `data:` joins,
100
- * comment heartbeats, BOM — lives in `@tangle-network/sse-core`, the one
101
- * wire-format implementation shared across the repo (bundled into this
102
- * package's dist, so the SDK stays dependency-free at runtime). This
103
- * module owns the SDK's payload contract on top of it: JSON parsing, the
104
- * `"message"` default event type, and the malformed-frame policy. Used by
105
- * `Sandbox.streamBatch` and by the web dashboard's batch page; exported
106
- * so downstream surfaces don't maintain their own copies.
107
- *
108
- * Guarantees:
109
- * - Correctly buffers frames that straddle chunk boundaries.
110
- * - Accepts LF- and CRLF-terminated streams interchangeably.
111
- * - Joins multi-line `data:` per the spec (dispatch joins with
112
- * "\n" before JSON parse).
113
- * - Defaults event type to `"message"` when a frame carries
114
- * `data:` but no `event:` field (SSE spec §9.2.6 step 3).
115
- * - Surfaces optional `id:` so callers can implement reconnection.
116
- * - Flushes a dangling event when the stream closes without a
117
- * terminating blank line (well-behaved servers emit `\n\n`, but
118
- * some close early).
119
- * - Throws `AbortError` when the caller-supplied signal fires, so
120
- * consumers can distinguish "ran to completion" from "cancelled"
121
- * without peeking at signal state.
122
- * - Rejects malformed JSON by default. Callers handling recoverable output
123
- * streams can explicitly warn and skip one invalid frame.
124
- *
125
- * What it does NOT do:
126
- * - CR-only (legacy Mac) line terminators. No known emitter uses
127
- * them; supporting them would risk splitting payloads that
128
- * legitimately contain CR.
129
- * - Retry/reconnect (caller's responsibility).
130
- * - Event-type filtering (caller's responsibility).
131
- */
132
- interface ParsedSSEEvent {
133
- /** Event type from the `event:` field, e.g. `task.completed`. */
134
- type: string;
135
- /** Parsed JSON payload from joined `data:` lines. */
136
- data: Record<string, unknown>;
137
- /** Optional `id:` field if the server emitted one. */
138
- id?: string;
139
- }
140
- interface ParseSSEStreamOptions {
141
- /**
142
- * Signal to abort the stream. When aborted, the generator throws
143
- * `AbortError` — this is a deliberate departure from silent-return
144
- * semantics so the consumer's for-await loop propagates the abort
145
- * to its own catch block instead of looking like a clean finish.
146
- */
147
- signal?: AbortSignal;
148
- /**
149
- * How to handle malformed JSON and non-object payloads. Stateful protocols
150
- * should keep the default `throw`; output streams may opt into recovery.
151
- */
152
- invalidEvent?: "throw" | "warn-and-skip";
153
- /**
154
- * The longest silence the stream may keep, read before each chunk read;
155
- * see `@tangle-network/sse-core`. A longer one throws
156
- * `SSEStreamSilentError`.
157
- */
158
- idleMs?: () => number | undefined;
159
- }
160
- /**
161
- * Parse a streaming SSE response body into an async iterable of
162
- * structured events.
163
- *
164
- * @throws `TypeError` when the response has no body.
165
- * @throws `DOMException` with `name === "AbortError"` on cancellation.
166
- */
167
- declare function parseSSEStream(body: ReadableStream<Uint8Array> | null | undefined, options?: ParseSSEStreamOptions): AsyncGenerator<ParsedSSEEvent>;
168
- //#endregion
169
- //#region src/fleet.d.ts
170
- /**
171
- * The subset of `Sandbox` the fleet classes drive. Declared here
172
- * rather than importing the concrete class so `fleet.ts` stays a leaf of
173
- * `client.ts` — `client.ts` constructs `SandboxFleetClient`, so the reverse
174
- * import would form a cycle. `Sandbox` satisfies this structurally.
175
- */
176
- interface FleetClientHost {
177
- create(options?: CreateSandboxOptions): Promise<SandboxInstance>;
178
- list(options?: ListSandboxOptions): Promise<SandboxInstance[]>;
179
- get(id: string): Promise<SandboxInstance | null>;
180
- fetch(path: string, options?: RequestInit): Promise<Response>;
181
- /** Fetch from the Platform API (agent-profile catalog, keys) with the same key. */
182
- platformFetch(path: string, options?: RequestInit): Promise<Response>;
183
- /** A host with the same settings that authenticates with `apiKey`. */
184
- withApiKey(apiKey: string): FleetClientHost;
185
- readonly fleets: SandboxFleetClient;
186
- readonly intelligence: {
187
- createReport(options: CreateIntelligenceReportOptions): Promise<IntelligenceReport>;
188
- };
189
- }
190
- declare class SandboxFleet {
191
- private readonly client;
192
- readonly fleetId: string;
193
- readonly machines: ReadonlyMap<FleetMachineId, SandboxInfo>;
194
- private readonly record;
195
- private readonly boxes;
196
- private readonly activeRuns;
197
- private readonly warmAgents;
198
- private readonly coldStarts;
199
- constructor(client: FleetClientHost, fleetId: string, machines: ReadonlyMap<FleetMachineId, SandboxInfo>, record?: Omit<SandboxFleetInfo, "fleetId" | "machines">);
200
- get policy(): SandboxFleetPolicy | undefined;
201
- get parent(): SandboxFleetParent | undefined;
202
- /** Id of the Platform key the fleet's sandboxes charge; set when the fleet has a cap. */
203
- get keyId(): string | undefined;
204
- /** Every agent of the fleet, in machine order. */
205
- get agents(): SandboxFleetAgent[];
206
- agent(agentId: FleetAgentId): SandboxFleetAgent;
207
- private agentSpecs;
208
- /** The model of agents that set none: the fleet's `defaults.backend.model`. */
209
- get model(): string | undefined;
210
- get ids(): FleetMachineId[];
211
- get(machineId: FleetMachineId): SandboxInfo;
212
- sandbox(machineId: FleetMachineId): Promise<SandboxInstance>;
213
- collectArtifacts(artifacts: readonly SandboxFleetArtifactSpec[]): Promise<SandboxFleetArtifact[]>;
214
- exec(machineId: FleetMachineId, command: string, options?: ExecOptions): Promise<ExecResult>;
215
- dispatchExec(command: string, options?: FleetExecDispatchOptions): Promise<FleetExecDispatchResult[]>;
216
- dispatchExecDetailed(command: string, options?: FleetExecDispatchOptions): Promise<SandboxFleetDispatchResponse<FleetExecDispatchResult>>;
217
- /**
218
- * Run one prompt on one machine's default agent through the API's fleet
219
- * dispatch. For agent fleets, `run()` and `runAll()` run each agent in its
220
- * own session through the sandbox runtime path.
221
- */
222
- prompt(machineId: FleetMachineId, message: string | PromptInputPart[], options?: PromptOptions): Promise<PromptResult>;
223
- dispatchPrompt(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions): Promise<FleetPromptDispatchResult[]>;
224
- dispatchPromptDetailed(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions): Promise<SandboxFleetDispatchResponse<FleetPromptDispatchResult>>;
225
- /**
226
- * Run one turn on each selected agent, all at once, and yield each agent's
227
- * start and result as they happen. Every turn goes through the same
228
- * per-sandbox runtime path as `box.prompt()`: the managed model
229
- * credential, access audit, metering and trace id all apply per agent.
230
- *
231
- * A fleet created with `budgetUsd` drives every turn with its budgeted
232
- * key, so the Platform refuses each charge past the budget; such a turn
233
- * ends `budget_exhausted`. Turns already running are not aborted: each is
234
- * refused at its own next charge.
235
- */
236
- run(message?: string | PromptInputPart[] | ((agent: SandboxFleetAgent) => string | PromptInputPart[]), options?: FleetRunOptions): AsyncGenerator<FleetRunEvent>;
237
- /** Run one turn on each selected agent and return every agent's result. */
238
- runAll(message?: string | PromptInputPart[] | ((agent: SandboxFleetAgent) => string | PromptInputPart[]), options?: FleetRunOptions): Promise<FleetAgentResult[]>;
239
- /**
240
- * Stop the fleet's work: abort the runs this handle started, interrupt every
241
- * agent's session on its sandbox (so turns started by another process stop
242
- * too), and cancel every child fleet. One unreachable sandbox or child does
243
- * not stop the rest; each failure is reported. Sandboxes keep running;
244
- * `delete()` removes them.
245
- */
246
- cancel(): Promise<{
247
- interrupted: number;
248
- children: number;
249
- failures: string[];
250
- }>;
251
- /** Fleets whose `parent.fleetId` is this fleet. */
252
- children(): Promise<SandboxFleet[]>;
253
- /**
254
- * The fleet's spend as the Platform metered it on the fleet's budgeted key:
255
- * every router call and compute charge of its sandboxes, from any process.
256
- * Only a capped fleet has a key; an uncapped fleet has nothing to meter.
257
- */
258
- spend(): Promise<SandboxFleetSpend>;
259
- /**
260
- * Drive one settle → poll → dispatch pass across agents — the fleet
261
- * counterpart of `box.driveTurn()` for tick-based callers (Workflows steps,
262
- * queue consumers, crons) that re-invoke on their own schedule. One
263
- * invocation never loops, never sleeps, and never holds a connection: each
264
- * agent gets exactly one pass in its own session, and a per-agent failure is
265
- * captured in that agent's outcome instead of failing the batch. At most
266
- * `concurrency` passes run at once, and an agent's first turn waits on the
267
- * same per-sandbox cold-start limit as `run()`.
268
- */
269
- driveTurns(turns: readonly FleetDriveTurnRequest[], options?: {
270
- concurrency?: number;
271
- }): Promise<FleetDriveTurnOutcome[]>;
272
- manifest(): Promise<SandboxFleetManifest>;
273
- attachMachine(machine: AttachSandboxFleetMachineOptions): Promise<SandboxFleetMachineRecord>;
274
- detachMachine(machineId: FleetMachineId): Promise<{
275
- success: boolean;
276
- }>;
277
- dispatchResults<T = FleetExecDispatchResult>(dispatchId: string, options?: FleetDispatchResultBufferOptions): Promise<FleetDispatchResultBuffer<T>>;
278
- cancelDispatch(dispatchId: string, reason?: string): Promise<FleetDispatchCancelResult>;
279
- createWorkspaceSnapshot(): Promise<SandboxFleetWorkspaceSnapshotResult>;
280
- restoreWorkspaceSnapshot(snapshotId: string): Promise<SandboxFleetWorkspaceRestoreResult>;
281
- reconcileWorkspace(): Promise<SandboxFleetWorkspaceReconcileResult>;
282
- dispatchExecStream(command: string, options?: FleetExecDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent, any, any>;
283
- dispatchPromptStream(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent, any, any>;
284
- /**
285
- * Delete the fleet with its child fleets. The API deprovisions children
286
- * first, then this fleet's sandboxes, and keeps a fleet's record while any
287
- * machine of it or its descendants remains, so nothing is left billing
288
- * without an owner. A failed delete is retried; after the tree is gone the
289
- * fleet's budgeted key is revoked. Revoking returns only unspent budget: a
290
- * child's spend stays counted against its parent.
291
- */
292
- delete(options?: {
293
- continueOnError?: boolean;
294
- }): Promise<void>;
295
- usage(): Promise<SandboxFleetUsage>;
296
- trace(options?: SandboxFleetTraceOptions): Promise<SandboxFleetTraceBundle>;
297
- intelligence(): Promise<NonNullable<SandboxFleetTraceBundle["intelligence"]>>;
298
- createIntelligenceReport(options?: {
299
- mode?: "deterministic" | "agentic";
300
- acknowledgeCost?: boolean;
301
- budget?: IntelligenceReportBudget;
302
- metadata?: Record<string, unknown>; /** Narrow the analysis to a single dispatch within this fleet. */
303
- dispatchId?: string; /** Bound the analysis to a time window. */
304
- window?: IntelligenceReportWindow; /** Compare this fleet against a same-type baseline fleet. */
305
- compareTo?: IntelligenceReportCompareTo;
306
- }): Promise<IntelligenceReport>;
307
- createAgenticIntelligenceReport(options: {
308
- maxUsd: number;
309
- metadata?: Record<string, unknown>;
310
- dispatchId?: string;
311
- window?: IntelligenceReportWindow;
312
- compareTo?: IntelligenceReportCompareTo;
313
- }): Promise<IntelligenceReport>;
314
- exportTrace(sink: TraceExportSink): Promise<TraceExportResult>;
315
- cost(): Promise<SandboxFleetCostEstimate>;
316
- createToken(options?: CreateSandboxFleetTokenOptions): Promise<SandboxFleetToken>;
317
- /**
318
- * The API's prompt dispatch bills the calling key, so a budgeted fleet
319
- * refuses it: its turns run through `run()`, `runAll()` or `prompt()`.
320
- */
321
- private assertUnbudgetedDispatch;
322
- /** @internal */
323
- coldStartGate(machineId: FleetMachineId): Semaphore;
324
- private sandboxFor;
325
- }
326
- declare class SandboxFleetClient {
327
- #private;
328
- private readonly client;
329
- constructor(client: FleetClientHost);
330
- /** Mint the key a capped fleet's sandboxes charge, under `issuerKey`. */
331
- private mintFleetKey;
332
- /**
333
- * @internal The host that authenticates as a capped fleet's budgeted key.
334
- * Only the client that created the fleet holds the key; any other caller
335
- * would spend outside the cap, so it is refused.
336
- */
337
- hostFor(fleetId: string): FleetClientHost;
338
- /** The budgeted key id a fleet's sandboxes carry, read from one of them. */
339
- private budgetKeyIdOf;
340
- /** @internal Revoke a fleet's budgeted key; an absent key is already revoked. */
341
- revokeKey(keyId: string): Promise<void>;
342
- /** @internal Read a fleet key's metered spend from the Platform. */
343
- keySpend(keyId: string): Promise<SandboxFleetSpend>;
344
- /**
345
- * @internal Delete a fleet and its children through the API, retrying a
346
- * transient failure. A fleet with no server record is deleted machine by
347
- * machine from the caller's handle.
348
- */
349
- deleteTree(fleetId: string, machines: readonly SandboxInfo[]): Promise<void>;
350
- private descendantKeyIds;
351
- private deleteTreeOnce;
352
- private deleteMachines;
353
- capabilities(): Promise<{
354
- drivers: SandboxFleetDriverCapability[];
355
- }>;
356
- operations(): Promise<SandboxFleetOperationsSummary>;
357
- reconcile(options?: ReconcileSandboxFleetsOptions): Promise<ReconcileSandboxFleetsResult>;
358
- estimateCost(options: Pick<CreateSandboxFleetOptions, "defaults" | "policy" | "maxConcurrentCreates"> & {
359
- machines: SandboxFleetMachineSpec[];
360
- }): Promise<SandboxFleetCostEstimate>;
361
- create(input: CreateSandboxFleetOptions): Promise<SandboxFleet>;
362
- /**
363
- * Turn `agents`/`placement` into machine specs, or pass explicit machines
364
- * through. Each agent's harness, model and profile resolve from its spec,
365
- * then its profile, then `defaults.backend`; saved profiles are fetched from
366
- * the Platform catalog here, before any sandbox exists.
367
- */
368
- private resolveFleetMachines;
369
- /** Read a saved profile's definition from the Platform catalog. */
370
- private savedProfile;
371
- createWithCoordinator(options: CreateSandboxFleetWithCoordinatorOptions): Promise<SandboxFleet>;
372
- private createMachine;
373
- list(options: ListSandboxFleetOptions): Promise<SandboxFleet>;
374
- delete(fleetId: string, options?: Omit<ListSandboxFleetOptions, "fleetId"> & {
375
- continueOnError?: boolean;
376
- }): Promise<void>;
377
- fromInfo(info: SandboxFleetInfo): SandboxFleet;
378
- /** Fleets spawned by `fleetId`, from the API's `parent` lineage. */
379
- children(fleetId: string): Promise<SandboxFleet[]>;
380
- private persistFleet;
381
- private getServerFleet;
382
- deleteRecord(fleetId: string): Promise<void>;
383
- usage(fleetId: string): Promise<SandboxFleetUsage>;
384
- trace(fleetId: string, options?: SandboxFleetTraceOptions): Promise<SandboxFleetTraceBundle>;
385
- intelligence(fleetId: string): Promise<NonNullable<SandboxFleetTraceBundle["intelligence"]>>;
386
- createIntelligenceReport(fleetId: string, options?: {
387
- mode?: "deterministic" | "agentic";
388
- acknowledgeCost?: boolean;
389
- budget?: IntelligenceReportBudget;
390
- metadata?: Record<string, unknown>;
391
- }): Promise<IntelligenceReport>;
392
- createAgenticIntelligenceReport(fleetId: string, options: {
393
- maxUsd: number;
394
- metadata?: Record<string, unknown>;
395
- }): Promise<IntelligenceReport>;
396
- exportTrace(fleetId: string, sink: TraceExportSink): Promise<TraceExportResult>;
397
- cost(fleetId: string): Promise<SandboxFleetCostEstimate>;
398
- createToken(fleetId: string, options?: CreateSandboxFleetTokenOptions): Promise<SandboxFleetToken>;
399
- manifest(fleetId: string): Promise<SandboxFleetManifest>;
400
- attachMachine(fleetId: string, machine: AttachSandboxFleetMachineOptions): Promise<SandboxFleetMachineRecord>;
401
- detachMachine(fleetId: string, machineId: FleetMachineId): Promise<{
402
- success: boolean;
403
- }>;
404
- dispatchResults<T = FleetExecDispatchResult>(fleetId: string, dispatchId: string, options?: FleetDispatchResultBufferOptions): Promise<FleetDispatchResultBuffer<T>>;
405
- cancelDispatch(fleetId: string, dispatchId: string, reason?: string): Promise<FleetDispatchCancelResult>;
406
- createWorkspaceSnapshot(fleetId: string): Promise<SandboxFleetWorkspaceSnapshotResult>;
407
- restoreWorkspaceSnapshot(fleetId: string, snapshotId: string): Promise<SandboxFleetWorkspaceRestoreResult>;
408
- reconcileWorkspace(fleetId: string): Promise<SandboxFleetWorkspaceReconcileResult>;
409
- dispatchExecStream(fleetId: string, command: string, options?: FleetExecDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent>;
410
- dispatchPromptStream(fleetId: string, message: string | PromptInputPart[], options?: FleetPromptDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent>;
411
- reapExpired(options?: ReapExpiredSandboxFleetsOptions): Promise<ReapExpiredSandboxFleetsResult>;
412
- private hydrateServerFleet;
413
- private listBySandboxMetadata;
414
- }
415
- /** Counting semaphore whose waiters leave the queue when their signal aborts. */
416
- declare class Semaphore {
417
- private available;
418
- private readonly waiters;
419
- constructor(available: number);
420
- acquire(signal: AbortSignal): Promise<void>;
421
- release(): void;
422
- }
423
- //#endregion
424
- //#region src/instances.d.ts
425
- /** The profile version that new sessions of an instance bind to. */
426
- interface InstanceProfile {
427
- /** Your identifier for this profile version, such as a release id. */
428
- version: string;
429
- /** The backend a new session is created from. */
430
- backend: BackendConfig;
431
- }
432
- /** The platform's record of one named instance. */
433
- interface InstanceRecord {
434
- key: string;
435
- /** Counts the key's sandboxes; a replacement moves to the next one. */
436
- generation: number;
437
- sandboxId: string | null;
438
- profileVersion: string | null;
439
- /** Epoch ms of the current sandbox's first failed start, or null. */
440
- unstartableSince: number | null;
441
- createdAt: number;
442
- updatedAt: number;
443
- }
444
- interface EnsureInstanceOptions {
445
- /** Your tenant key: 1-200 letters, digits and `. _ : @ -`. */
446
- key: string;
447
- /** The profile version new sessions bind to. */
448
- profile?: InstanceProfile;
449
- /**
450
- * How a new sandbox is created. The sandbox is always isolated from your
451
- * own account's context; the SDK sets its idempotency key and adds
452
- * `instanceKey` and `instanceGeneration` to its metadata.
453
- */
454
- create: Omit<CreateSandboxOptions, "ownerContext" | "idempotencyKey" | "backend">;
455
- /**
456
- * How long a sandbox may keep failing to start before a fresh sandbox
457
- * replaces it. The replaced sandbox is not deleted; its own retention
458
- * deletes it. Default 60 s.
459
- */
460
- restartAfterMs?: number;
461
- /**
462
- * A sandbox you created before using instances, to adopt for a key that
463
- * has no instance yet. Ignored once the key has one.
464
- */
465
- adopt?: string;
466
- }
467
- /**
468
- * The sandbox cannot start yet. `ensure()` replaces it once it has kept
469
- * failing for `restartAfterMs`; retry after `retryAfterMs`.
470
- */
471
- declare class InstanceRestartingError extends SandboxError {
472
- readonly instance: InstanceRecord;
473
- /** The start failure that was recorded. */
474
- readonly failure: Error;
475
- constructor(message: string, instance: InstanceRecord, /** The start failure that was recorded. */
476
-
477
- failure: Error, retryAfterMs: number);
478
- }
479
- /** The part of the SDK client that instances use. */
480
- interface InstancesHttpClient {
481
- fetch(path: string, options?: RequestInit): Promise<Response>;
482
- get(id: string): Promise<SandboxInstance | null>;
483
- createIsolated(options: Omit<CreateSandboxOptions, "ownerContext">): Promise<SandboxInstance>;
484
- }
485
- /** One running instance: its sandbox and the profile version it binds. */
486
- /**
487
- * What `ensure` did to hand back a running sandbox: it was already running,
488
- * it resumed a stopped one, or it created the key's sandbox. A caller that
489
- * reports turn latency names the box state from it.
490
- */
491
- type InstanceStart = "running" | "resumed" | "created";
492
- declare class HostedInstance {
493
- readonly record: InstanceRecord;
494
- readonly box: SandboxInstance;
495
- readonly profile?: InstanceProfile | undefined;
496
- readonly started: InstanceStart;
497
- constructor(record: InstanceRecord, box: SandboxInstance, profile?: InstanceProfile | undefined, started?: InstanceStart);
498
- get key(): string;
499
- get generation(): number;
500
- get sandboxId(): string;
501
- get profileVersion(): string | null;
502
- /**
503
- * The session a thread's turns run in on the current profile version:
504
- * `<thread>-<version>`. Without a profile version it is the thread itself.
505
- */
506
- sessionId(thread: string): string;
507
- /**
508
- * Run one turn in the thread's session. The session is created from the
509
- * profile version's backend the first time; retrying with the same
510
- * `turnId` settles the same turn.
511
- */
512
- turn(message: string | PromptInputPart[], options: Omit<ConversationTurnOptions, "sessionId" | "backend"> & {
513
- thread: string;
514
- }): Promise<ConversationTurnResult>;
515
- }
516
- /** `client.instances`: one isolated sandbox per tenant key. */
517
- declare class InstancesClient {
518
- private readonly client;
519
- private readonly now;
520
- constructor(client: InstancesHttpClient, now?: () => number);
521
- /** The platform's record for `key`, or null when it has none. */
522
- get(key: string): Promise<InstanceRecord | null>;
523
- /** Forget `key`. Its sandbox is left as it is. */
524
- release(key: string): Promise<boolean>;
525
- /**
526
- * The key's sandbox, running. Creates the first sandbox, resumes a stopped
527
- * one, replaces one that was deleted or has kept failing to start, and
528
- * moves the key to `profile.version` without replacing the sandbox.
529
- */
530
- ensure(options: EnsureInstanceOptions): Promise<HostedInstance>;
531
- private create;
532
- private start;
533
- /**
534
- * Record a failed start. The sandbox is replaced once starts have failed
535
- * for `restartAfterMs`; until then the caller is told to retry.
536
- */
537
- private failedStart;
538
- private replace;
539
- private update;
540
- /** A write the platform refused as stale answers `ok: false`. */
541
- private write;
542
- }
543
- //#endregion
544
- //#region src/runs.d.ts
545
- /** Where a run executes. */
546
- type RunPlacement = "auto" | "inference" | "worker" | "sandbox";
547
- interface RunOptions {
548
- /** The agent: an inline AgentProfile, or a built-in or catalog profile id. */
549
- profile: AgentProfile | string;
550
- /** What to do in this run. */
551
- prompt: string;
552
- /** Default `auto`. */
553
- placement?: RunPlacement;
554
- /** A Router model id, when the profile names none. */
555
- model?: string;
556
- /** Hub providers the run may use, by name (`slack`, `github`, …). */
557
- connections?: string[];
558
- /** Owner-object prefixes and mode the run may use (worker only). */
559
- objects?: {
560
- prefixes: string[];
561
- mode: "read" | "readwrite";
562
- };
563
- /** Public HTTPS hosts the run may GET (worker only). */
564
- http?: {
565
- hosts: string[];
566
- };
567
- /** The run's own wall-clock budget, a duration (`"5m"`) or milliseconds. */
568
- timeout?: string | number;
569
- }
570
- interface RunWaitOptions {
571
- /** How long to wait for the run to settle. Default 10 minutes. */
572
- timeoutMs?: number;
573
- /** Poll interval. Default 1 second. */
574
- pollIntervalMs?: number;
575
- signal?: AbortSignal;
576
- }
577
- /** Where the run went and why, as Platform recorded it. */
578
- interface RunPlacementRecord {
579
- chosen: Exclude<RunPlacement, "auto">;
580
- policy: string;
581
- reason: string;
582
- rejected: Array<{
583
- placement: Exclude<RunPlacement, "auto">;
584
- reason: string;
585
- }>;
586
- }
587
- interface RunRecord {
588
- id: string;
589
- /** `queued`, `running`, `waiting`, `succeeded`, `failed` or `cancelled`. */
590
- status: string;
591
- placement: RunPlacementRecord | null;
592
- text: string | null;
593
- model: string | null;
594
- usage: {
595
- inputTokens?: number;
596
- outputTokens?: number;
597
- } | null;
598
- /**
599
- * The model spend Platform booked for the run: the Router's charge, or
600
- * Platform's estimate when no charge was read. Sandbox time is billed
601
- * separately and is not included. `null` when nothing was measured.
602
- */
603
- costUsd: number | null;
604
- error: string | null;
605
- createdAt: string;
606
- startedAt: string | null;
607
- completedAt: string | null;
608
- }
609
- interface RunsHttpClient {
610
- platformFetch(path: string, options?: RequestInit): Promise<Response>;
611
- }
612
- /** `client.runs`: start a run, read it, wait for it. */
613
- declare class RunsClient {
614
- private readonly http;
615
- constructor(http: RunsHttpClient);
616
- /** Start a run. Returns at once with its id; it executes on Platform. */
617
- create(options: RunOptions): Promise<{
618
- id: string;
619
- status: string;
620
- }>;
621
- /** Read a run: its status, placement, answer, cost and error. */
622
- get(id: string, options?: {
623
- signal?: AbortSignal;
624
- }): Promise<RunRecord>;
625
- /** Stop a run. A queued run is cancelled at once (`cancelled`). An
626
- * executing one is signalled (`cancelling`) and settles `cancelled` when the
627
- * worker holding it stops; read the run to see the final status. */
628
- cancel(id: string): Promise<{
629
- id: string;
630
- status: string;
631
- }>;
632
- /** Poll a run until it settles. */
633
- wait(id: string, options?: RunWaitOptions): Promise<RunRecord>;
634
- /** Start a run and wait for it to settle. */
635
- run(options: RunOptions, wait?: RunWaitOptions): Promise<RunRecord>;
636
- }
637
- //#endregion
638
- //#region src/scoped-token.d.ts
639
- interface ScopedTokenHttpClient {
640
- fetch(path: string, options?: RequestInit, fetchOptions?: {
641
- timeoutMs?: number;
642
- }): Promise<Response>;
643
- }
644
- //#endregion
645
- //#region src/session-events.d.ts
646
- /** Event delivered to a product session through the Sandbox session gateway. */
647
- interface SessionBroadcastEvent {
648
- type: string;
649
- id?: string;
650
- data?: unknown;
651
- channel?: string;
652
- }
653
- /**
654
- * Result returned after Sandbox accepts or rejects a session event.
655
- * For a session that has not connected yet, `success: true` means the event
656
- * was durably queued for the authenticated owner.
657
- */
658
- interface SessionBroadcastResult {
659
- success: boolean;
660
- sessionId: string;
661
- }
662
- //#endregion
663
- //#region src/client.d.ts
664
- declare class Sandbox implements HttpClient, ScopedTokenHttpClient {
665
- #private;
666
- private readonly baseUrl;
667
- private readonly platformUrl;
668
- private readonly timeoutMs;
669
- private readonly trustLocalCliAuth;
670
- /** Receives the SDK's timing spans; see `SandboxConfig.onTiming`. */
671
- readonly onTiming: SdkTimingHook | undefined;
672
- /** See `SandboxConfig.directExec`. */
673
- readonly directExec: boolean;
674
- private _secrets;
675
- private _sshKeys;
676
- private _fleets;
677
- private _instances;
678
- private _intelligence;
679
- private _lines;
680
- private _runs;
681
- constructor(config: SandboxConfig);
682
- /**
683
- * Fleet operations for agent-managed groups of sandboxes.
684
- *
685
- * Fleets are an SDK-level convenience over the existing sandbox lifecycle
686
- * API. Each worker is a normal sandbox tagged with stable fleet metadata,
687
- * so older clients and dashboards can still inspect and delete them.
688
- */
689
- /**
690
- * Named instances: one isolated sandbox per tenant key, kept by the
691
- * platform. `ensure()` creates, resumes or replaces the key's sandbox and
692
- * binds new sessions to a profile version.
693
- */
694
- get instances(): InstancesClient;
695
- get fleets(): SandboxFleetClient;
696
- /**
697
- * Lines: phone numbers and messaging addresses that Tangle Hub receives on.
698
- * Create a line from a connected Inkbox identity, then attach it to a
699
- * sandbox with `sandbox.lines.attach()`.
700
- */
701
- get lines(): LinesClient;
702
- /**
703
- * Runs: run an AgentProfile on a prompt in the environment its needs
704
- * require — one inference call, Tangle's sandbox-free agent loop, or a
705
- * sandbox. `placement: "auto"` (the default) chooses and records why.
706
- */
707
- get runs(): RunsClient;
708
- /**
709
- * Run an AgentProfile on a prompt and wait for the result.
710
- *
711
- * @example
712
- * ```ts
713
- * const result = await client.run({
714
- * profile: { name: "support", prompt: { systemPrompt: "Answer billing questions." } },
715
- * prompt: "Which plan am I on?",
716
- * });
717
- * console.log(result.placement?.chosen, result.text, result.costUsd);
718
- * ```
719
- */
720
- run(options: RunOptions, wait?: RunWaitOptions): Promise<RunRecord>;
721
- get intelligence(): IntelligenceClient;
722
- getApiKey(): string;
723
- /** The Sandbox API this client talks to, without a trailing slash. */
724
- getBaseUrl(): string;
725
- /** A client with this one's settings that authenticates with `apiKey`. */
726
- withApiKey(apiKey: string): Sandbox;
727
- /** Fetch a Platform API path (e.g. the agent-profile catalog) with this key. */
728
- platformFetch(path: string, options?: RequestInit): Promise<Response>;
729
- /**
730
- * Access the secrets manager for storing and retrieving encrypted secrets.
731
- *
732
- * @example
733
- * ```typescript
734
- * // Create a secret
735
- * await client.secrets.create("HF_TOKEN", "hf_xxx");
736
- *
737
- * // List secrets (names only)
738
- * const secrets = await client.secrets.list();
739
- *
740
- * // Delete secret
741
- * await client.secrets.delete("HF_TOKEN");
742
- * ```
743
- */
744
- get secrets(): SecretsManager;
745
- get sshKeys(): SshKeysManager;
746
- /** Deliver a server-originated event to a mapped product session. */
747
- broadcastSessionEvent(sessionId: string, event: SessionBroadcastEvent): Promise<SessionBroadcastResult>;
748
- /** Deliver a product payload through SessionGateway's `onAgentEvent`. */
749
- broadcastSessionAgentEvent<T>(sessionId: string, event: T): Promise<SessionBroadcastResult>;
750
- private _environments;
751
- /**
752
- * Access available development environments.
753
- *
754
- * @example
755
- * ```typescript
756
- * const envs = await client.environments.list();
757
- * // → [{ id: "universal", description: "Universal environment with all toolchains via Nix", ... }]
758
- *
759
- * const sandbox = await client.create({ environment: "universal" });
760
- * ```
761
- */
762
- get environments(): EnvironmentsClient;
763
- private _teams;
764
- private _publicTemplates;
765
- /**
766
- * Access team management (collaboration groups, invitations,
767
- * member roles). Teams scope shared sandboxes — pass `teamId` to
768
- * `client.create()` to create a sandbox accessible to a team's
769
- * members.
770
- *
771
- * @example
772
- * ```typescript
773
- * const teams = await client.teams.list();
774
- * const invite = await client.teams.invite(teams[0].id, {
775
- * email: "alice@example.com",
776
- * role: "member",
777
- * });
778
- * ```
779
- */
780
- get teams(): TeamsClient;
781
- get publicTemplates(): PublicTemplatesClient;
782
- /**
783
- * Create a new sandbox.
784
- *
785
- * @param options - Configuration for the new sandbox
786
- * @returns A SandboxInstance representing the created sandbox
787
- *
788
- * @example
789
- * ```typescript
790
- * const box = await client.create({
791
- * name: "my-project",
792
- * sshEnabled: true,
793
- * env: { NODE_ENV: "development" },
794
- * });
795
- * ```
796
- */
797
- /** Fresh execution with no ambient owner context. Old hosts reject this
798
- * explicit field before provisioning; no best-effort security downgrade. */
799
- createIsolated(options: Omit<CreateSandboxOptions, "ownerContext">, requestOptions?: CreateRequestOptions): Promise<SandboxInstance>;
800
- create(inputOptions?: CreateSandboxOptions, requestOptions?: CreateRequestOptions): Promise<SandboxInstance>;
801
- /**
802
- * Poll a sandbox to `running` by id. Surfaces a real provision failure
803
- * as a {@link StateError} (carrying the sandbox's error message) rather
804
- * than an opaque timeout, and throws {@link NotFoundError} if the id is
805
- * unknown. Use after a {@link create} that timed out client-side but may
806
- * have continued provisioning server-side under its idempotency key.
807
- */
808
- waitForRunning(id: string, options?: {
809
- timeoutMs?: number;
810
- signal?: AbortSignal;
811
- }): Promise<SandboxInstance>;
812
- /**
813
- * List the agent backends registered by the Sandbox platform.
814
- *
815
- * The response contains static capabilities. A specific session can expose
816
- * fewer interaction kinds after its configuration is applied.
817
- */
818
- listBackends(): Promise<BackendRegistryResponse>;
819
- /**
820
- * Get one registered agent backend by its canonical type.
821
- *
822
- * An absent entry means the authenticated Sandbox deployment does not
823
- * advertise that backend. The lookup uses the same typed catalog as
824
- * {@link listBackends}; it does not maintain a second registry.
825
- */
826
- getBackend(type: string): Promise<BackendRegistryEntry | undefined>;
827
- /**
828
- * List all sandboxes.
829
- *
830
- * @param options - Filtering and pagination options
831
- * @returns Array of SandboxInstance objects
832
- *
833
- * @example
834
- * ```typescript
835
- * // List all running sandboxes
836
- * const running = await client.list({ status: "running" });
837
- *
838
- * // List with pagination
839
- * const page = await client.list({ limit: 10, offset: 0 });
840
- * ```
841
- */
842
- list(options?: ListSandboxOptions): Promise<SandboxInstance[]>;
843
- /**
844
- * Every compute generation of every sandbox created for a caller run
845
- * (`metadata.run`), deleted sandboxes included, oldest first. Reads every
846
- * page of `GET /v1/sandboxes/runs/{run}`.
847
- *
848
- * @example
849
- * ```typescript
850
- * const generations = await client.runGenerations("my-run-1");
851
- * ```
852
- */
853
- runGenerations(run: string): Promise<SandboxRunGeneration[]>;
854
- /**
855
- * Get a sandbox by ID.
856
- *
857
- * @param id - The sandbox ID
858
- * @returns A SandboxInstance or null if not found
859
- *
860
- * @example
861
- * ```typescript
862
- * const box = await client.get("sandbox_abc123");
863
- * if (box) {
864
- * console.log(box.status);
865
- * }
866
- * ```
867
- */
868
- get(id: string): Promise<SandboxInstance | null>;
869
- /**
870
- * Delete every sandbox this caller owns whose metadata matches, and report
871
- * which ones are confirmed gone.
872
- *
873
- * Each sandbox goes through the same delete as {@link SandboxInstance.delete}.
874
- * The API deletes a bounded batch per request in ID order; this method
875
- * follows its cursor, so one call attempts every match once and a refused
876
- * delete never holds back the matches after it. Calling it again is safe: a
877
- * sandbox confirmed gone no longer matches.
878
- *
879
- * `complete` is the teardown verdict. When it is false, `sandboxes` names
880
- * each refused delete with its status and code, and `listingComplete` or
881
- * `remaining` says whether a match may not have been attempted.
882
- *
883
- * `complete` covers the sandboxes this call listed. Stop creating
884
- * sandboxes that match before calling, and call again once in-flight
885
- * creates have settled; a create that registers after the listing, or that
886
- * retries with the same idempotency key, can leave a match behind.
887
- *
888
- * @example
889
- * ```typescript
890
- * // Remove every sandbox one Agent Runtime run created.
891
- * const result = await client.deleteMatching({
892
- * metadataPrefix: { retainedIdempotencyKey: `runtime:${runId}:` },
893
- * });
894
- * if (!result.complete) {
895
- * console.warn(result.sandboxes.filter((s) => !s.confirmed));
896
- * }
897
- * ```
898
- */
899
- deleteMatching(filter: DeleteMatchingSandboxesFilter, options?: DeleteMatchingSandboxesOptions): Promise<DeleteMatchingSandboxesResult>;
900
- /**
901
- * Mint the terminal-capable token for one exact interactive session.
902
- *
903
- * This is a server-side operation. It validates the complete session
904
- * reference, derives the sandbox and runtime session IDs from that reference,
905
- * and makes one scoped-token request without loading the sandbox first.
906
- */
907
- mintInteractiveSessionToken(ref: AgentInteractiveSessionRef, options?: MintInteractiveSessionTokenOptions): Promise<ScopedToken>;
908
- /**
909
- * The named sandbox sizes, which one is the platform's default, and the
910
- * largest shape this account can be granted on the serving deployment.
911
- *
912
- * The platform owns these numbers; a client that sizes a request from
913
- * `ceiling` is never refused with `RESOURCES_EXCEED_LIMIT`, and
914
- * {@link sandboxResourcesForSize} accepts `presets` so a named tier expands
915
- * to what this deployment actually sells.
916
- *
917
- * @example
918
- * ```typescript
919
- * const shapes = await client.shapes();
920
- * const box = await client.create({
921
- * resources: sandboxResourcesForSize("medium", shapes.presets),
922
- * });
923
- * ```
924
- */
925
- shapes(): Promise<SandboxShapesInfo>;
926
- /**
927
- * Return the identity the public Sandbox API observed for this credential.
928
- *
929
- * This is useful for deployment checks that must confirm which account and
930
- * API key a service credential resolves to without exposing the key itself.
931
- */
932
- getIdentity(): Promise<SandboxIdentity>;
933
- /**
934
- * Get usage information for the account.
935
- *
936
- * @returns Usage statistics for the current billing period
937
- *
938
- * @example
939
- * ```typescript
940
- * const usage = await client.usage();
941
- * console.log(`Active sandboxes: ${usage.activeSandboxes}`);
942
- * console.log(`Compute minutes: ${usage.computeMinutes}`);
943
- * ```
944
- */
945
- usage(): Promise<UsageInfo>;
946
- /**
947
- * Get subscription and billing information for the account.
948
- *
949
- * @returns Subscription details including plan, credits, and limits
950
- *
951
- * @example
952
- * ```typescript
953
- * const sub = await client.subscription();
954
- * console.log(`Plan: ${sub.plan}`);
955
- * console.log(`Credits: $${sub.creditsAvailableUsd.toFixed(2)}`);
956
- * ```
957
- */
958
- subscription(): Promise<SubscriptionInfo>;
959
- /**
960
- * Check if the Sandbox API is available.
961
- *
962
- * @returns true if the API is healthy, false otherwise
963
- */
964
- health(): Promise<boolean>;
965
- /**
966
- * Run multiple tasks in parallel across sandboxes.
967
- * Returns the aggregated results after all tasks complete.
968
- *
969
- * @param request - Complete batch request
970
- * @param options - Batch execution options
971
- * @returns Aggregated batch results
972
- *
973
- * @throws {@link ValidationError} / {@link QuotaError} / other typed
974
- * SDK errors if the server rejects the request before streaming.
975
- * @throws `DOMException` with `name === "AbortError"` if
976
- * `options.signal` fires.
977
- * @throws `Error` with the server message if the stream emits a
978
- * `batch.failed` event.
979
- *
980
- * @example
981
- * ```typescript
982
- * const result = await client.runBatch({
983
- * tasks: [
984
- * { id: "task-1", message: "Analyze this file" },
985
- * { id: "task-2", message: "Generate a summary" },
986
- * ],
987
- * backends: [{ id: "primary", type: "opencode" }],
988
- * });
989
- * console.log(`Success rate: ${result.successRate}%`);
990
- * ```
991
- */
992
- runBatch(request: BatchRunRequest, options?: BatchRunOptions): Promise<BatchResult>;
993
- /**
994
- * Stream events from a batch execution.
995
- * Use this for real-time progress updates during batch processing.
996
- *
997
- * @param request - Complete batch request
998
- * @param options - Per-call controls
999
- *
1000
- * @throws {@link ValidationError} / {@link QuotaError} / other typed
1001
- * SDK errors if the server rejects the request before streaming.
1002
- * @throws `DOMException` with `name === "AbortError"` when
1003
- * `options.signal` fires.
1004
- *
1005
- * @example
1006
- * ```typescript
1007
- * for await (const event of client.streamBatch({
1008
- * tasks,
1009
- * backends: [{ id: "primary", type: "opencode" }],
1010
- * })) {
1011
- * if (event.type === "task.completed") {
1012
- * console.log(`Task ${event.data.taskId} completed`);
1013
- * }
1014
- * }
1015
- * ```
1016
- */
1017
- streamBatch(request: BatchRunRequest, options?: BatchRunOptions): AsyncGenerator<BatchEvent, BatchResult>;
1018
- /**
1019
- * Make an authenticated HTTP request to the API.
1020
- * This is exposed for use by SandboxInstance.
1021
- *
1022
- * `fetchOptions.timeoutMs` overrides the client-wide `this.timeoutMs`
1023
- * for a single request. Slow data-plane operations (snapshot create
1024
- * blocks the server up to 600s while the host-agent compresses and
1025
- * uploads the rootfs) must pass a higher ceiling, otherwise the
1026
- * default client timeout aborts mid-operation with a `TimeoutError`
1027
- * even though the server is still working.
1028
- */
1029
- fetch(path: string, options?: RequestInit, fetchOptions?: {
1030
- timeoutMs?: number;
1031
- }): Promise<Response>;
1032
- private parseInfo;
1033
- private readonly _tokenRefreshHandlers;
1034
- /**
1035
- * Register a handler invoked when the SDK transparently refreshes a
1036
- * sandbox bearer after a 401 retry. Returns a function that
1037
- * unregisters the handler when called.
1038
- */
1039
- onTokenRefresh(handler: TokenRefreshHandler): () => void;
1040
- /** @internal — fired by the runtime-fetch retry path after a successful
1041
- * refresh. Errors thrown by handlers are caught and surfaced as
1042
- * console warnings so one bad subscriber does not poison the rest. */
1043
- _emitTokenRefresh(sandboxId: string, newToken: string): void;
1044
- }
1045
- /**
1046
- * Client for the Intelligence Reports API.
1047
- *
1048
- * Two analysis modes:
1049
- *
1050
- * - `deterministic` (default): free, rule-based platform analysis over
1051
- * the subject's trace evidence. Returns immediately.
1052
- * - `agentic`: routes to the **Tangle Trace Analyst**, an LLM-driven
1053
- * reasoning loop that reads OTLP-shaped trace evidence and emits
1054
- * findings, evidence references, recommended actions, and a
1055
- * validation plan. Billed against `budget.maxUsd`; the platform
1056
- * never spends past the budget the caller sets.
1057
- *
1058
- * Subjects: `sandbox` or `fleet`. A fleet subject can be narrowed to
1059
- * a single coordinated command via `subject.dispatchId`.
1060
- */
1061
- declare class IntelligenceClient {
1062
- private readonly client;
1063
- constructor(client: Sandbox);
1064
- /**
1065
- * Create an intelligence report over the given subject.
1066
- *
1067
- * Use `mode: "agentic"` to engage the **Tangle Trace Analyst** with a
1068
- * spending budget. The budget is enforced server-side before billing
1069
- * fires — a request whose computed cost exceeds `budget.maxUsd`
1070
- * returns 402 without charging the customer.
1071
- */
1072
- createReport(options: CreateIntelligenceReportOptions): Promise<IntelligenceReport>;
1073
- createAgenticReport(options: {
1074
- subject: CreateIntelligenceReportOptions["subject"];
1075
- maxUsd: number;
1076
- metadata?: Record<string, unknown>;
1077
- }): Promise<IntelligenceReport>;
1078
- /**
1079
- * Estimate the cost of a prospective report without creating one.
1080
- * Verifies subject ownership the same way `createReport` does, so it
1081
- * never becomes an existence oracle for foreign subjects.
1082
- */
1083
- estimateReport(options: Pick<CreateIntelligenceReportOptions, "subject"> & {
1084
- mode?: "deterministic" | "agentic";
1085
- metadata?: Record<string, unknown>;
1086
- }): Promise<{
1087
- mode: "deterministic" | "agentic";
1088
- costUsd: number;
1089
- billable: boolean;
1090
- billedTo: "platform" | "customer";
1091
- reason: string;
1092
- }>;
1093
- getReport(jobId: string): Promise<IntelligenceReport>;
1094
- listReports(options?: {
1095
- subjectType?: CreateIntelligenceReportOptions["subject"]["type"];
1096
- subjectId?: string;
1097
- limit?: number;
1098
- }): Promise<IntelligenceReport[]>;
1099
- waitForReport(jobId: string, options?: {
1100
- timeoutMs?: number;
1101
- pollMs?: number;
1102
- }): Promise<IntelligenceReport>;
1103
- }
1104
- /**
1105
- * Client for browsing available development environments.
1106
- */
1107
- declare class EnvironmentsClient {
1108
- private readonly client;
1109
- constructor(client: Sandbox);
1110
- /**
1111
- * List available development environments.
1112
- *
1113
- * @returns Array of available environments with metadata
1114
- *
1115
- * @example
1116
- * ```typescript
1117
- * const envs = await client.environments.list();
1118
- * for (const env of envs) {
1119
- * console.log(`${env.id}: ${env.description}`);
1120
- * }
1121
- * ```
1122
- */
1123
- list(): Promise<SandboxEnvironment[]>;
1124
- /**
1125
- * Get details for a specific environment.
1126
- *
1127
- * @param id - Environment identifier (e.g., "universal")
1128
- */
1129
- get(id: string): Promise<SandboxEnvironment | null>;
1130
- }
1131
- /**
1132
- * Team (collaboration group) record as returned from the API.
1133
- */
1134
- interface Team {
1135
- id: string;
1136
- name: string;
1137
- ownerCustomerId: string;
1138
- orgId: string | null;
1139
- memberCount: number;
1140
- currentUserRole: "owner" | "admin" | "member" | "viewer";
1141
- createdAt: string;
1142
- updatedAt: string;
1143
- }
1144
- interface TeamMember {
1145
- id: string;
1146
- teamId: string;
1147
- customerId: string;
1148
- customerEmail: string;
1149
- customerName: string | null;
1150
- role: "owner" | "admin" | "member" | "viewer";
1151
- status: "active" | "pending" | "removed";
1152
- joinedAt: string | null;
1153
- createdAt: string;
1154
- }
1155
- interface TeamInvitation {
1156
- id: string;
1157
- teamId: string;
1158
- email: string;
1159
- invitedBy: string;
1160
- invitedByEmail: string | null;
1161
- role: "admin" | "member" | "viewer";
1162
- token: string;
1163
- status: "pending" | "accepted" | "expired" | "revoked";
1164
- expiresAt: string;
1165
- createdAt: string;
1166
- }
1167
- interface TeamInvitationPreview {
1168
- email: string;
1169
- role: "admin" | "member" | "viewer";
1170
- status: "pending" | "accepted" | "expired" | "revoked";
1171
- expiresAt: string;
1172
- teamName: string;
1173
- invitedByEmail: string | null;
1174
- }
1175
- interface TeamSecretRecord {
1176
- name: string;
1177
- updatedAt: string;
1178
- updatedBy: string;
1179
- }
1180
- interface TeamTemplateRecord {
1181
- id: string;
1182
- name: string;
1183
- description: string;
1184
- snapshotId: string;
1185
- environment: string;
1186
- config: Record<string, unknown>;
1187
- teamId: string | null;
1188
- createdAt: string;
1189
- updatedAt: string;
1190
- }
1191
- interface CreateTeamTemplateOptions {
1192
- name: string;
1193
- snapshotId: string;
1194
- description?: string;
1195
- environment?: string;
1196
- config?: Record<string, unknown>;
1197
- }
1198
- interface CreateTeamOptions {
1199
- name: string;
1200
- orgId?: string;
1201
- }
1202
- interface InviteTeamMemberOptions {
1203
- email: string;
1204
- role: "admin" | "member" | "viewer";
1205
- /** Lifetime of the invitation in hours (default 168 = 7 days). */
1206
- ttlHours?: number;
1207
- }
1208
- /**
1209
- * Client for managing teams and team-scoped sharing.
1210
- *
1211
- * Team resources are scoped to the authenticated user's membership —
1212
- * the client never needs to pass an org id explicitly.
1213
- */
1214
- declare class TeamsClient {
1215
- private readonly client;
1216
- constructor(client: Sandbox);
1217
- list(): Promise<Team[]>;
1218
- create(options: CreateTeamOptions): Promise<Team>;
1219
- get(teamId: string): Promise<Team>;
1220
- update(teamId: string, updates: {
1221
- name?: string;
1222
- }): Promise<Team>;
1223
- delete(teamId: string): Promise<void>;
1224
- leave(teamId: string): Promise<void>;
1225
- transferOwnership(teamId: string, newOwnerCustomerId: string): Promise<void>;
1226
- listMembers(teamId: string): Promise<TeamMember[]>;
1227
- updateMember(teamId: string, memberId: string, updates: {
1228
- role?: "admin" | "member" | "viewer";
1229
- status?: "active" | "removed";
1230
- }): Promise<TeamMember>;
1231
- removeMember(teamId: string, memberId: string): Promise<void>;
1232
- listInvitations(teamId: string): Promise<TeamInvitation[]>;
1233
- invite(teamId: string, options: InviteTeamMemberOptions): Promise<TeamInvitation>;
1234
- revokeInvitation(invitationId: string): Promise<void>;
1235
- acceptInvitation(token: string): Promise<TeamMember>;
1236
- getInvitation(token: string): Promise<TeamInvitationPreview>;
1237
- listSecrets(teamId: string): Promise<TeamSecretRecord[]>;
1238
- upsertSecret(teamId: string, name: string, value: string): Promise<TeamSecretRecord>;
1239
- deleteSecret(teamId: string, name: string): Promise<void>;
1240
- revealSecret(teamId: string, name: string): Promise<{
1241
- name: string;
1242
- value: string;
1243
- }>;
1244
- listTemplates(teamId: string): Promise<TeamTemplateRecord[]>;
1245
- createTemplate(teamId: string, options: CreateTeamTemplateOptions): Promise<TeamTemplateRecord>;
1246
- deleteTemplate(teamId: string, templateId: string): Promise<void>;
1247
- }
1248
- //#endregion
1249
- export { BackendRegistryEntry as A, InstancesClient as C, ParsedSSEEvent as D, ParseSSEStreamOptions as E, backendRegistryInteractionKindSchema as F, backendRegistryResponseSchema as I, isBackendRegistryInteractionKind as L, BackendRegistryResponse as M, backendRegistryCapabilitiesSchema as N, parseSSEStream as O, backendRegistryEntrySchema as P, parseBackendRegistryResponse as R, InstanceStart as S, SandboxFleetClient as T, EnsureInstanceOptions as _, Team as a, InstanceRecord as b, SessionBroadcastEvent as c, RunPlacement as d, RunPlacementRecord as f, RunsHttpClient as g, RunsClient as h, Sandbox as i, BackendRegistryInteractionKind as j, BackendRegistryCapabilities as k, SessionBroadcastResult as l, RunWaitOptions as m, IntelligenceClient as n, TeamInvitation as o, RunRecord as p, InviteTeamMemberOptions as r, TeamMember as s, CreateTeamOptions as t, RunOptions as u, HostedInstance as v, SandboxFleet as w, InstanceRestartingError as x, InstanceProfile as y, parseBackendRegistryResponseBody as z };