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