@tangle-network/sandbox 0.0.0-develop.20260514223840.b2abd84
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/LICENSE +11 -0
- package/README.md +736 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.js +1 -0
- package/dist/client-CO5cnRwn.js +1 -0
- package/dist/collaboration/index.d.ts +2 -0
- package/dist/collaboration/index.js +1 -0
- package/dist/collaboration-CRyb5e8F.js +1 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.js +1 -0
- package/dist/errors-CljiGR__.js +1 -0
- package/dist/errors-Cy5W2uYq.d.ts +1116 -0
- package/dist/index-CCsA3S0D.d.ts +136 -0
- package/dist/index-Cka6RuZB.d.ts +371 -0
- package/dist/index-Dpj1oB5i.d.ts +220 -0
- package/dist/index.d.ts +555 -0
- package/dist/index.js +1 -0
- package/dist/openai/index.d.ts +642 -0
- package/dist/openai/index.js +1 -0
- package/dist/platform-integrations.d.ts +2 -0
- package/dist/platform-integrations.js +1 -0
- package/dist/sandbox-193cSjQB.js +1 -0
- package/dist/sandbox-CTe9fN5m.d.ts +4857 -0
- package/dist/session-gateway/index.d.ts +448 -0
- package/dist/session-gateway/index.js +1 -0
- package/dist/tangle/index.d.ts +2 -0
- package/dist/tangle/index.js +1 -0
- package/dist/tangle-B4_UoyBS.js +1 -0
- package/package.json +105 -0
|
@@ -0,0 +1,1116 @@
|
|
|
1
|
+
import { $ as FleetExecDispatchOptions, $t as SandboxClientConfig, A as CreateIntelligenceReportOptions, An as SandboxInfo, C as BatchResult, Dn as SandboxFleetWorkspaceReconcileResult, Ft as PromptInputPart, G as ExecOptions, Gn as SecretsManager, Gt as PublishPublicTemplateVersionOptions, Ht as PublicTemplateInfo, It as PromptOptions, Jt as ReconcileSandboxFleetsOptions, K as ExecResult, Kt as ReapExpiredSandboxFleetsOptions, Lt as PromptResult, M as CreateSandboxFleetTokenOptions, N as CreateSandboxFleetWithCoordinatorOptions, On as SandboxFleetWorkspaceRestoreResult, P as CreateSandboxOptions, Q as FleetDispatchStreamOptions, S as BatchOptions, Tn as SandboxFleetUsage, Ut as PublicTemplateVersionInfo, Wt as PublishPublicTemplateOptions, X as FleetDispatchResultBuffer, Y as FleetDispatchCancelResult, Yt as ReconcileSandboxFleetsResult, Z as FleetDispatchResultBufferOptions, _t as ListSandboxFleetOptions, a as TraceExportSink, an as SandboxFleetCostEstimate, bn as SandboxFleetToken, cn as SandboxFleetDriverCapability, cr as TokenRefreshHandler, er as SubscriptionInfo, et as FleetExecDispatchResult, gn as SandboxFleetManifest, ht as IntelligenceReportBudget, i as TraceExportResult, in as SandboxFleetArtifactSpec, j as CreateSandboxFleetOptions, kn as SandboxFleetWorkspaceSnapshotResult, m as AttachSandboxFleetMachineOptions, mn as SandboxFleetMachineRecord, mt as IntelligenceReport, n as SandboxInstance, nt as FleetPromptDispatchOptions, pr as UsageInfo, qt as ReapExpiredSandboxFleetsResult, rn as SandboxFleetArtifact, rt as FleetPromptDispatchResult, sn as SandboxFleetDispatchResponse, t as HttpClient, tn as SandboxEnvironment, tt as FleetMachineId, un as SandboxFleetInfo, vn as SandboxFleetOperationsSummary, vt as ListSandboxOptions, w as BatchTask, wn as SandboxFleetTraceOptions, x as BatchEvent, xn as SandboxFleetTraceBundle } from "./sandbox-CTe9fN5m.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/sse-parser.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* SSE Stream Parser
|
|
6
|
+
*
|
|
7
|
+
* EventSource stream parsing for SDK consumers. Implements the
|
|
8
|
+
* subset of the SSE spec (§9.2.6) that the platform actually emits —
|
|
9
|
+
* LF and CRLF terminators, `event:` / `data:` / `id:` fields, and
|
|
10
|
+
* multi-line `data:` dispatch. Used by `SandboxClient.streamBatch`
|
|
11
|
+
* and by the web dashboard's batch page; exported so downstream
|
|
12
|
+
* surfaces don't maintain their own copies.
|
|
13
|
+
*
|
|
14
|
+
* Guarantees:
|
|
15
|
+
* - Correctly buffers frames that straddle chunk boundaries.
|
|
16
|
+
* - Accepts LF- and CRLF-terminated streams interchangeably.
|
|
17
|
+
* - Joins multi-line `data:` per the spec (dispatch joins with
|
|
18
|
+
* "\n" before JSON parse).
|
|
19
|
+
* - Defaults event type to `"message"` when a frame carries
|
|
20
|
+
* `data:` but no `event:` field (SSE spec §9.2.6 step 3).
|
|
21
|
+
* - Surfaces optional `id:` so callers can implement reconnection.
|
|
22
|
+
* - Flushes a dangling event when the stream closes without a
|
|
23
|
+
* terminating blank line (well-behaved servers emit `\n\n`, but
|
|
24
|
+
* some close early).
|
|
25
|
+
* - Throws `AbortError` when the caller-supplied signal fires, so
|
|
26
|
+
* consumers can distinguish "ran to completion" from "cancelled"
|
|
27
|
+
* without peeking at signal state.
|
|
28
|
+
* - Silently drops frames with malformed JSON — the stream remains
|
|
29
|
+
* usable and only the individual frame is lost.
|
|
30
|
+
*
|
|
31
|
+
* What it does NOT do:
|
|
32
|
+
* - CR-only (legacy Mac) line terminators. No known emitter uses
|
|
33
|
+
* them; supporting them would risk splitting payloads that
|
|
34
|
+
* legitimately contain CR.
|
|
35
|
+
* - Retry/reconnect (caller's responsibility).
|
|
36
|
+
* - Event-type filtering (caller's responsibility).
|
|
37
|
+
*/
|
|
38
|
+
interface ParsedSSEEvent {
|
|
39
|
+
/** Event type from the `event:` field, e.g. `task.completed`. */
|
|
40
|
+
type: string;
|
|
41
|
+
/** Parsed JSON payload from joined `data:` lines. */
|
|
42
|
+
data: Record<string, unknown>;
|
|
43
|
+
/** Optional `id:` field if the server emitted one. */
|
|
44
|
+
id?: string;
|
|
45
|
+
}
|
|
46
|
+
interface ParseSSEStreamOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Signal to abort the stream. When aborted, the generator throws
|
|
49
|
+
* `AbortError` — this is a deliberate departure from silent-return
|
|
50
|
+
* semantics so the consumer's for-await loop propagates the abort
|
|
51
|
+
* to its own catch block instead of looking like a clean finish.
|
|
52
|
+
*/
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse a streaming SSE response body into an async iterable of
|
|
57
|
+
* structured events.
|
|
58
|
+
*
|
|
59
|
+
* @throws `TypeError` when the response has no body.
|
|
60
|
+
* @throws `DOMException` with `name === "AbortError"` on cancellation.
|
|
61
|
+
*/
|
|
62
|
+
declare function parseSSEStream(body: ReadableStream<Uint8Array> | null | undefined, options?: ParseSSEStreamOptions): AsyncGenerator<ParsedSSEEvent>;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/fleet.d.ts
|
|
65
|
+
declare class SandboxFleet {
|
|
66
|
+
private readonly client;
|
|
67
|
+
readonly fleetId: string;
|
|
68
|
+
readonly machines: ReadonlyMap<FleetMachineId, SandboxInfo>;
|
|
69
|
+
constructor(client: SandboxClient, fleetId: string, machines: ReadonlyMap<FleetMachineId, SandboxInfo>);
|
|
70
|
+
get ids(): FleetMachineId[];
|
|
71
|
+
get(machineId: FleetMachineId): SandboxInfo;
|
|
72
|
+
sandbox(machineId: FleetMachineId): Promise<SandboxInstance>;
|
|
73
|
+
collectArtifacts(artifacts: readonly SandboxFleetArtifactSpec[]): Promise<SandboxFleetArtifact[]>;
|
|
74
|
+
exec(machineId: FleetMachineId, command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
75
|
+
dispatchExec(command: string, options?: FleetExecDispatchOptions): Promise<FleetExecDispatchResult[]>;
|
|
76
|
+
dispatchExecDetailed(command: string, options?: FleetExecDispatchOptions): Promise<SandboxFleetDispatchResponse<FleetExecDispatchResult>>;
|
|
77
|
+
dispatchExecWithInsights(command: string, options?: FleetExecDispatchOptions): Promise<SandboxFleetDispatchResponse<FleetExecDispatchResult>>;
|
|
78
|
+
prompt(machineId: FleetMachineId, message: string | PromptInputPart[], options?: PromptOptions): Promise<PromptResult>;
|
|
79
|
+
dispatchPrompt(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions): Promise<FleetPromptDispatchResult[]>;
|
|
80
|
+
dispatchPromptDetailed(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions): Promise<SandboxFleetDispatchResponse<FleetPromptDispatchResult>>;
|
|
81
|
+
dispatchPromptWithInsights(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions): Promise<SandboxFleetDispatchResponse<FleetPromptDispatchResult>>;
|
|
82
|
+
manifest(): Promise<SandboxFleetManifest>;
|
|
83
|
+
attachMachine(machine: AttachSandboxFleetMachineOptions): Promise<SandboxFleetMachineRecord>;
|
|
84
|
+
detachMachine(machineId: FleetMachineId): Promise<{
|
|
85
|
+
success: boolean;
|
|
86
|
+
}>;
|
|
87
|
+
dispatchResults<T = FleetExecDispatchResult | FleetPromptDispatchResult>(dispatchId: string, options?: FleetDispatchResultBufferOptions): Promise<FleetDispatchResultBuffer<T>>;
|
|
88
|
+
cancelDispatch(dispatchId: string, reason?: string): Promise<FleetDispatchCancelResult>;
|
|
89
|
+
createWorkspaceSnapshot(): Promise<SandboxFleetWorkspaceSnapshotResult>;
|
|
90
|
+
restoreWorkspaceSnapshot(snapshotId: string): Promise<SandboxFleetWorkspaceRestoreResult>;
|
|
91
|
+
reconcileWorkspace(): Promise<SandboxFleetWorkspaceReconcileResult>;
|
|
92
|
+
dispatchExecStream(command: string, options?: FleetExecDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent, any, any>;
|
|
93
|
+
dispatchPromptStream(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent, any, any>;
|
|
94
|
+
delete(options?: {
|
|
95
|
+
continueOnError?: boolean;
|
|
96
|
+
}): Promise<void>;
|
|
97
|
+
usage(): Promise<SandboxFleetUsage>;
|
|
98
|
+
trace(options?: SandboxFleetTraceOptions): Promise<SandboxFleetTraceBundle>;
|
|
99
|
+
intelligence(): Promise<NonNullable<SandboxFleetTraceBundle["intelligence"]>>;
|
|
100
|
+
createIntelligenceReport(options?: {
|
|
101
|
+
mode?: "deterministic" | "agentic";
|
|
102
|
+
acknowledgeCost?: boolean;
|
|
103
|
+
budget?: IntelligenceReportBudget;
|
|
104
|
+
metadata?: Record<string, unknown>;
|
|
105
|
+
}): Promise<IntelligenceReport>;
|
|
106
|
+
createAgenticIntelligenceReport(options: {
|
|
107
|
+
maxUsd: number;
|
|
108
|
+
metadata?: Record<string, unknown>;
|
|
109
|
+
}): Promise<IntelligenceReport>;
|
|
110
|
+
exportTrace(sink: TraceExportSink): Promise<TraceExportResult>;
|
|
111
|
+
cost(): Promise<SandboxFleetCostEstimate>;
|
|
112
|
+
createToken(options?: CreateSandboxFleetTokenOptions): Promise<SandboxFleetToken>;
|
|
113
|
+
private requireSandbox;
|
|
114
|
+
}
|
|
115
|
+
declare class SandboxFleetClient {
|
|
116
|
+
private readonly client;
|
|
117
|
+
constructor(client: SandboxClient);
|
|
118
|
+
capabilities(): Promise<{
|
|
119
|
+
drivers: SandboxFleetDriverCapability[];
|
|
120
|
+
}>;
|
|
121
|
+
operations(): Promise<SandboxFleetOperationsSummary>;
|
|
122
|
+
reconcile(options?: ReconcileSandboxFleetsOptions): Promise<ReconcileSandboxFleetsResult>;
|
|
123
|
+
estimateCost(options: Pick<CreateSandboxFleetOptions, "defaults" | "machines" | "policy" | "maxConcurrentCreates">): Promise<SandboxFleetCostEstimate>;
|
|
124
|
+
create(options: CreateSandboxFleetOptions): Promise<SandboxFleet>;
|
|
125
|
+
createWithCoordinator(options: CreateSandboxFleetWithCoordinatorOptions): Promise<SandboxFleet>;
|
|
126
|
+
private createMachine;
|
|
127
|
+
list(options: ListSandboxFleetOptions): Promise<SandboxFleet>;
|
|
128
|
+
delete(fleetId: string, options?: Omit<ListSandboxFleetOptions, "fleetId"> & {
|
|
129
|
+
continueOnError?: boolean;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
fromInfo(info: SandboxFleetInfo): SandboxFleet;
|
|
132
|
+
private persistFleet;
|
|
133
|
+
private getServerFleet;
|
|
134
|
+
deleteRecord(fleetId: string): Promise<void>;
|
|
135
|
+
usage(fleetId: string): Promise<SandboxFleetUsage>;
|
|
136
|
+
trace(fleetId: string, options?: SandboxFleetTraceOptions): Promise<SandboxFleetTraceBundle>;
|
|
137
|
+
intelligence(fleetId: string): Promise<NonNullable<SandboxFleetTraceBundle["intelligence"]>>;
|
|
138
|
+
createIntelligenceReport(fleetId: string, options?: {
|
|
139
|
+
mode?: "deterministic" | "agentic";
|
|
140
|
+
acknowledgeCost?: boolean;
|
|
141
|
+
budget?: IntelligenceReportBudget;
|
|
142
|
+
metadata?: Record<string, unknown>;
|
|
143
|
+
}): Promise<IntelligenceReport>;
|
|
144
|
+
createAgenticIntelligenceReport(fleetId: string, options: {
|
|
145
|
+
maxUsd: number;
|
|
146
|
+
metadata?: Record<string, unknown>;
|
|
147
|
+
}): Promise<IntelligenceReport>;
|
|
148
|
+
exportTrace(fleetId: string, sink: TraceExportSink): Promise<TraceExportResult>;
|
|
149
|
+
cost(fleetId: string): Promise<SandboxFleetCostEstimate>;
|
|
150
|
+
createToken(fleetId: string, options?: CreateSandboxFleetTokenOptions): Promise<SandboxFleetToken>;
|
|
151
|
+
manifest(fleetId: string): Promise<SandboxFleetManifest>;
|
|
152
|
+
attachMachine(fleetId: string, machine: AttachSandboxFleetMachineOptions): Promise<SandboxFleetMachineRecord>;
|
|
153
|
+
detachMachine(fleetId: string, machineId: FleetMachineId): Promise<{
|
|
154
|
+
success: boolean;
|
|
155
|
+
}>;
|
|
156
|
+
dispatchResults<T = FleetExecDispatchResult | FleetPromptDispatchResult>(fleetId: string, dispatchId: string, options?: FleetDispatchResultBufferOptions): Promise<FleetDispatchResultBuffer<T>>;
|
|
157
|
+
cancelDispatch(fleetId: string, dispatchId: string, reason?: string): Promise<FleetDispatchCancelResult>;
|
|
158
|
+
createWorkspaceSnapshot(fleetId: string): Promise<SandboxFleetWorkspaceSnapshotResult>;
|
|
159
|
+
restoreWorkspaceSnapshot(fleetId: string, snapshotId: string): Promise<SandboxFleetWorkspaceRestoreResult>;
|
|
160
|
+
reconcileWorkspace(fleetId: string): Promise<SandboxFleetWorkspaceReconcileResult>;
|
|
161
|
+
dispatchExecStream(fleetId: string, command: string, options?: FleetExecDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent>;
|
|
162
|
+
dispatchPromptStream(fleetId: string, message: string | PromptInputPart[], options?: FleetPromptDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent>;
|
|
163
|
+
reapExpired(options?: ReapExpiredSandboxFleetsOptions): Promise<ReapExpiredSandboxFleetsResult>;
|
|
164
|
+
private hydrateServerFleet;
|
|
165
|
+
private listBySandboxMetadata;
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/integrations.d.ts
|
|
169
|
+
type IntegrationPrincipalType = "customer" | "team";
|
|
170
|
+
type IntegrationProvider = "generic" | "github" | "generic_oauth2";
|
|
171
|
+
type IntegrationVerificationKind = "none" | "hmac_shared_secret" | "provider:github";
|
|
172
|
+
type IntegrationActionKind = "sandbox.create" | "sandbox.dispatch" | "sandbox.event" | "sandbox.respond_inline";
|
|
173
|
+
type IntegrationDeliveryStatus = "pending" | "delivered" | "failed" | "disabled";
|
|
174
|
+
/**
|
|
175
|
+
* Opaque JSON value flowing through an integration. Tied to whichever
|
|
176
|
+
* trigger/endpoint shape is on the wire — the SDK doesn't introspect
|
|
177
|
+
* it. Aliased instead of using bare `unknown` so call sites read as
|
|
178
|
+
* "this came from JSON" rather than "this is genuinely any type".
|
|
179
|
+
*/
|
|
180
|
+
type IntegrationJsonValue = unknown;
|
|
181
|
+
interface IntegrationAction {
|
|
182
|
+
kind: IntegrationActionKind;
|
|
183
|
+
config: IntegrationJsonValue;
|
|
184
|
+
mappings?: Record<string, string>;
|
|
185
|
+
}
|
|
186
|
+
interface IntegrationScope {
|
|
187
|
+
sandboxIds?: string[];
|
|
188
|
+
sessionIds?: string[];
|
|
189
|
+
teamId?: string;
|
|
190
|
+
}
|
|
191
|
+
interface ConnectionInfo {
|
|
192
|
+
id: string;
|
|
193
|
+
ownerType: IntegrationPrincipalType;
|
|
194
|
+
ownerId: string;
|
|
195
|
+
provider: IntegrationProvider;
|
|
196
|
+
externalId: string;
|
|
197
|
+
displayName: string | null;
|
|
198
|
+
authKind: "oauth2" | "api_key" | "signing_only";
|
|
199
|
+
metadata: Record<string, unknown> | null;
|
|
200
|
+
status: "active" | "revoked" | "error";
|
|
201
|
+
installedAt: string;
|
|
202
|
+
}
|
|
203
|
+
interface AutomationInfo {
|
|
204
|
+
id: string;
|
|
205
|
+
ownerType: IntegrationPrincipalType;
|
|
206
|
+
ownerId: string;
|
|
207
|
+
connectionId: string | null;
|
|
208
|
+
name: string;
|
|
209
|
+
description: string | null;
|
|
210
|
+
recipeId: string | null;
|
|
211
|
+
enabled: boolean;
|
|
212
|
+
createdAt: string;
|
|
213
|
+
updatedAt: string;
|
|
214
|
+
}
|
|
215
|
+
interface EndpointInfo {
|
|
216
|
+
id: string;
|
|
217
|
+
automationId: string | null;
|
|
218
|
+
ownerType: IntegrationPrincipalType;
|
|
219
|
+
ownerId: string;
|
|
220
|
+
connectionId: string | null;
|
|
221
|
+
url: string | null;
|
|
222
|
+
events: string[];
|
|
223
|
+
scope: IntegrationScope | null;
|
|
224
|
+
description: string | null;
|
|
225
|
+
enabled: boolean;
|
|
226
|
+
ephemeralForSandboxId: string | null;
|
|
227
|
+
consecutiveFailures: number;
|
|
228
|
+
disabledReason: string | null;
|
|
229
|
+
disabledAt: string | null;
|
|
230
|
+
createdAt: string;
|
|
231
|
+
updatedAt: string;
|
|
232
|
+
}
|
|
233
|
+
interface EndpointWithSecret extends EndpointInfo {
|
|
234
|
+
/** Returned only at create / rotate. Save it on your end. */
|
|
235
|
+
secret: string;
|
|
236
|
+
}
|
|
237
|
+
interface TriggerInfo {
|
|
238
|
+
id: string;
|
|
239
|
+
automationId: string | null;
|
|
240
|
+
ownerType: IntegrationPrincipalType;
|
|
241
|
+
ownerId: string;
|
|
242
|
+
connectionId: string | null;
|
|
243
|
+
urlToken: string;
|
|
244
|
+
/** Public URL the third party POSTs to. */
|
|
245
|
+
publicUrl: string;
|
|
246
|
+
verificationKind: IntegrationVerificationKind;
|
|
247
|
+
eventFilter: Record<string, unknown> | null;
|
|
248
|
+
action: IntegrationAction;
|
|
249
|
+
rateLimitRpm: number;
|
|
250
|
+
allowIps: string[] | null;
|
|
251
|
+
description: string | null;
|
|
252
|
+
enabled: boolean;
|
|
253
|
+
ephemeralForSandboxId: string | null;
|
|
254
|
+
createdAt: string;
|
|
255
|
+
updatedAt: string;
|
|
256
|
+
}
|
|
257
|
+
interface TriggerWithSecret extends TriggerInfo {
|
|
258
|
+
/** Returned only at create. Null when verificationKind === "none". */
|
|
259
|
+
secret: string | null;
|
|
260
|
+
}
|
|
261
|
+
interface DeliveryAttempt {
|
|
262
|
+
id: string;
|
|
263
|
+
endpointId: string;
|
|
264
|
+
automationId: string | null;
|
|
265
|
+
type: string;
|
|
266
|
+
payload: IntegrationJsonValue;
|
|
267
|
+
status: IntegrationDeliveryStatus;
|
|
268
|
+
attempts: number;
|
|
269
|
+
lastAttemptAt: string | null;
|
|
270
|
+
nextAttemptAt: string | null;
|
|
271
|
+
lastResponseStatus: number | null;
|
|
272
|
+
lastResponseBodyExcerpt: string | null;
|
|
273
|
+
createdAt: string;
|
|
274
|
+
deliveredAt: string | null;
|
|
275
|
+
}
|
|
276
|
+
interface TriggerRun {
|
|
277
|
+
id: string;
|
|
278
|
+
triggerId: string;
|
|
279
|
+
automationId: string | null;
|
|
280
|
+
requestId: string;
|
|
281
|
+
requestHeaders: Record<string, string>;
|
|
282
|
+
requestBody: string;
|
|
283
|
+
requestIp: string | null;
|
|
284
|
+
verificationStatus: "ok" | "bad_signature" | "expired" | "filtered_out" | "rate_limited";
|
|
285
|
+
actionStatus: "queued" | "running" | "succeeded" | "failed" | "rate_limited" | "skipped";
|
|
286
|
+
actionResult: Record<string, unknown> | null;
|
|
287
|
+
errorMessage: string | null;
|
|
288
|
+
createdAt: string;
|
|
289
|
+
completedAt: string | null;
|
|
290
|
+
}
|
|
291
|
+
interface RecipeManifest {
|
|
292
|
+
id: string;
|
|
293
|
+
title: string;
|
|
294
|
+
description: string;
|
|
295
|
+
icon?: string;
|
|
296
|
+
requiresConnection?: IntegrationProvider;
|
|
297
|
+
userInputs?: Array<{
|
|
298
|
+
key: string;
|
|
299
|
+
label: string;
|
|
300
|
+
type?: "text" | "select";
|
|
301
|
+
default?: string;
|
|
302
|
+
options?: string[];
|
|
303
|
+
required?: boolean;
|
|
304
|
+
}>;
|
|
305
|
+
automation: {
|
|
306
|
+
name: string;
|
|
307
|
+
description?: string;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
interface CreateAutomationInput {
|
|
311
|
+
teamId?: string;
|
|
312
|
+
name: string;
|
|
313
|
+
description?: string;
|
|
314
|
+
connectionId?: string;
|
|
315
|
+
recipeId?: string;
|
|
316
|
+
enabled?: boolean;
|
|
317
|
+
triggers?: Array<{
|
|
318
|
+
verificationKind: IntegrationVerificationKind;
|
|
319
|
+
connectionId?: string;
|
|
320
|
+
eventFilter?: Record<string, unknown>;
|
|
321
|
+
action: IntegrationAction;
|
|
322
|
+
rateLimitRpm?: number;
|
|
323
|
+
allowIps?: string[];
|
|
324
|
+
description?: string;
|
|
325
|
+
}>;
|
|
326
|
+
endpoints?: Array<{
|
|
327
|
+
url?: string;
|
|
328
|
+
connectionId?: string;
|
|
329
|
+
events: string[];
|
|
330
|
+
scope?: IntegrationScope;
|
|
331
|
+
description?: string;
|
|
332
|
+
}>;
|
|
333
|
+
}
|
|
334
|
+
interface CreateEndpointInput {
|
|
335
|
+
teamId?: string;
|
|
336
|
+
automationId?: string;
|
|
337
|
+
connectionId?: string;
|
|
338
|
+
url?: string;
|
|
339
|
+
events: string[];
|
|
340
|
+
scope?: IntegrationScope;
|
|
341
|
+
description?: string;
|
|
342
|
+
}
|
|
343
|
+
interface CreateTriggerInput {
|
|
344
|
+
teamId?: string;
|
|
345
|
+
automationId?: string;
|
|
346
|
+
connectionId?: string;
|
|
347
|
+
verificationKind: IntegrationVerificationKind;
|
|
348
|
+
eventFilter?: Record<string, unknown>;
|
|
349
|
+
action: IntegrationAction;
|
|
350
|
+
rateLimitRpm?: number;
|
|
351
|
+
allowIps?: string[];
|
|
352
|
+
description?: string;
|
|
353
|
+
}
|
|
354
|
+
interface InstallRecipeInput {
|
|
355
|
+
teamId?: string;
|
|
356
|
+
connectionId?: string;
|
|
357
|
+
inputs?: Record<string, string>;
|
|
358
|
+
}
|
|
359
|
+
declare class IntegrationsManager {
|
|
360
|
+
private readonly client;
|
|
361
|
+
constructor(client: HttpClient);
|
|
362
|
+
readonly automations: {
|
|
363
|
+
list: (opts?: {
|
|
364
|
+
teamId?: string;
|
|
365
|
+
}) => Promise<AutomationInfo[]>;
|
|
366
|
+
get: (id: string, opts?: {
|
|
367
|
+
teamId?: string;
|
|
368
|
+
}) => Promise<{
|
|
369
|
+
automation: AutomationInfo;
|
|
370
|
+
triggers: TriggerInfo[];
|
|
371
|
+
endpoints: EndpointInfo[];
|
|
372
|
+
}>;
|
|
373
|
+
create: (input: CreateAutomationInput) => Promise<{
|
|
374
|
+
automation: AutomationInfo;
|
|
375
|
+
triggers: TriggerInfo[];
|
|
376
|
+
endpoints: EndpointInfo[];
|
|
377
|
+
}>;
|
|
378
|
+
update: (id: string, patch: {
|
|
379
|
+
teamId?: string;
|
|
380
|
+
name?: string;
|
|
381
|
+
description?: string;
|
|
382
|
+
enabled?: boolean;
|
|
383
|
+
connectionId?: string | null;
|
|
384
|
+
}) => Promise<AutomationInfo>;
|
|
385
|
+
delete: (id: string, opts?: {
|
|
386
|
+
teamId?: string;
|
|
387
|
+
}) => Promise<void>;
|
|
388
|
+
/**
|
|
389
|
+
* Unified inbound + outbound timeline for an automation.
|
|
390
|
+
* Returns the most recent N rows (default 100). Pagination is
|
|
391
|
+
* by `since` ISO8601 timestamp.
|
|
392
|
+
*/
|
|
393
|
+
logs: (id: string, opts?: {
|
|
394
|
+
teamId?: string;
|
|
395
|
+
since?: string;
|
|
396
|
+
limit?: number;
|
|
397
|
+
}) => Promise<{
|
|
398
|
+
deliveries: DeliveryAttempt[];
|
|
399
|
+
runs: TriggerRun[];
|
|
400
|
+
}>;
|
|
401
|
+
/**
|
|
402
|
+
* Install an automation from a recipe manifest. The recipe defines
|
|
403
|
+
* what gets created (one Automation, plus underlying triggers /
|
|
404
|
+
* endpoints) and which inputs the user must supply.
|
|
405
|
+
*/
|
|
406
|
+
installFromRecipe: (recipeId: string, input?: InstallRecipeInput) => Promise<{
|
|
407
|
+
automation: AutomationInfo;
|
|
408
|
+
triggers: TriggerInfo[];
|
|
409
|
+
endpoints: EndpointInfo[];
|
|
410
|
+
}>;
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* Iterate all log entries for an automation, paging through
|
|
414
|
+
* deliveries+runs in 200-row batches. Use this to power export
|
|
415
|
+
* scripts or dashboards. Defined on the manager (not under
|
|
416
|
+
* .automations) because async generators can't reference an
|
|
417
|
+
* enclosing object literal's other methods through `this` cleanly.
|
|
418
|
+
*/
|
|
419
|
+
iterateAutomationLogs(id: string, opts?: {
|
|
420
|
+
teamId?: string;
|
|
421
|
+
since?: string;
|
|
422
|
+
}): AsyncGenerator<{
|
|
423
|
+
deliveries: DeliveryAttempt[];
|
|
424
|
+
runs: TriggerRun[];
|
|
425
|
+
}>;
|
|
426
|
+
readonly recipes: {
|
|
427
|
+
list: () => Promise<RecipeManifest[]>;
|
|
428
|
+
get: (id: string) => Promise<RecipeManifest>;
|
|
429
|
+
};
|
|
430
|
+
readonly connections: {
|
|
431
|
+
list: (opts?: {
|
|
432
|
+
teamId?: string;
|
|
433
|
+
}) => Promise<ConnectionInfo[]>;
|
|
434
|
+
delete: (id: string, opts?: {
|
|
435
|
+
teamId?: string;
|
|
436
|
+
}) => Promise<void>;
|
|
437
|
+
};
|
|
438
|
+
readonly endpoints: {
|
|
439
|
+
list: (opts?: {
|
|
440
|
+
teamId?: string;
|
|
441
|
+
}) => Promise<EndpointInfo[]>;
|
|
442
|
+
create: (input: CreateEndpointInput) => Promise<EndpointWithSecret>;
|
|
443
|
+
update: (id: string, patch: {
|
|
444
|
+
teamId?: string;
|
|
445
|
+
url?: string;
|
|
446
|
+
events?: string[];
|
|
447
|
+
scope?: IntegrationScope;
|
|
448
|
+
description?: string;
|
|
449
|
+
enabled?: boolean;
|
|
450
|
+
}) => Promise<EndpointInfo>;
|
|
451
|
+
delete: (id: string, opts?: {
|
|
452
|
+
teamId?: string;
|
|
453
|
+
}) => Promise<void>;
|
|
454
|
+
rotateSecret: (id: string, opts?: {
|
|
455
|
+
teamId?: string;
|
|
456
|
+
}) => Promise<EndpointWithSecret>;
|
|
457
|
+
listDeliveries: (id: string, opts?: {
|
|
458
|
+
teamId?: string;
|
|
459
|
+
since?: string;
|
|
460
|
+
status?: IntegrationDeliveryStatus;
|
|
461
|
+
limit?: number;
|
|
462
|
+
}) => Promise<DeliveryAttempt[]>;
|
|
463
|
+
};
|
|
464
|
+
readonly triggers: {
|
|
465
|
+
list: (opts?: {
|
|
466
|
+
teamId?: string;
|
|
467
|
+
}) => Promise<TriggerInfo[]>;
|
|
468
|
+
create: (input: CreateTriggerInput) => Promise<TriggerWithSecret>;
|
|
469
|
+
update: (id: string, patch: {
|
|
470
|
+
teamId?: string;
|
|
471
|
+
eventFilter?: Record<string, unknown> | null;
|
|
472
|
+
action?: IntegrationAction;
|
|
473
|
+
rateLimitRpm?: number;
|
|
474
|
+
allowIps?: string[] | null;
|
|
475
|
+
description?: string;
|
|
476
|
+
enabled?: boolean;
|
|
477
|
+
}) => Promise<TriggerInfo>;
|
|
478
|
+
delete: (id: string, opts?: {
|
|
479
|
+
teamId?: string;
|
|
480
|
+
}) => Promise<void>;
|
|
481
|
+
listRuns: (id: string, opts?: {
|
|
482
|
+
teamId?: string;
|
|
483
|
+
since?: string;
|
|
484
|
+
limit?: number;
|
|
485
|
+
}) => Promise<TriggerRun[]>;
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/client.d.ts
|
|
490
|
+
/**
|
|
491
|
+
* Client for the Tangle Sandbox platform.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```typescript
|
|
495
|
+
* import { Sandbox } from "@tangle-network/sandbox";
|
|
496
|
+
*
|
|
497
|
+
* const client = new Sandbox({
|
|
498
|
+
* apiKey: "sk_sandbox_...",
|
|
499
|
+
* baseUrl: "https://your-sandbox-api.example.com",
|
|
500
|
+
* });
|
|
501
|
+
*
|
|
502
|
+
* // Create a sandbox
|
|
503
|
+
* const box = await client.create({
|
|
504
|
+
* name: "my-project",
|
|
505
|
+
* sshEnabled: true,
|
|
506
|
+
* });
|
|
507
|
+
*
|
|
508
|
+
* // Execute commands
|
|
509
|
+
* const result = await box.exec("npm install");
|
|
510
|
+
*
|
|
511
|
+
* // Clean up
|
|
512
|
+
* await box.delete();
|
|
513
|
+
* ```
|
|
514
|
+
*/
|
|
515
|
+
declare class SandboxClient implements HttpClient {
|
|
516
|
+
private readonly baseUrl;
|
|
517
|
+
private readonly apiKey;
|
|
518
|
+
private readonly timeoutMs;
|
|
519
|
+
private readonly trustLocalCliAuth;
|
|
520
|
+
private _secrets;
|
|
521
|
+
private _integrations;
|
|
522
|
+
private _fleets;
|
|
523
|
+
private _intelligence;
|
|
524
|
+
constructor(config: SandboxClientConfig);
|
|
525
|
+
/**
|
|
526
|
+
* Fleet operations for agent-managed groups of sandboxes.
|
|
527
|
+
*
|
|
528
|
+
* Fleets are an SDK-level convenience over the existing sandbox lifecycle
|
|
529
|
+
* API. Each worker is a normal sandbox tagged with stable fleet metadata,
|
|
530
|
+
* so older clients and dashboards can still inspect and delete them.
|
|
531
|
+
*/
|
|
532
|
+
get fleets(): SandboxFleetClient;
|
|
533
|
+
get intelligence(): IntelligenceClient;
|
|
534
|
+
getApiKey(): string;
|
|
535
|
+
/**
|
|
536
|
+
* Access the secrets manager for storing and retrieving encrypted secrets.
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* ```typescript
|
|
540
|
+
* // Create a secret
|
|
541
|
+
* await client.secrets.create("HF_TOKEN", "hf_xxx");
|
|
542
|
+
*
|
|
543
|
+
* // List secrets (names only)
|
|
544
|
+
* const secrets = await client.secrets.list();
|
|
545
|
+
*
|
|
546
|
+
* // Get secret value
|
|
547
|
+
* const value = await client.secrets.get("HF_TOKEN");
|
|
548
|
+
*
|
|
549
|
+
* // Update secret
|
|
550
|
+
* await client.secrets.update("HF_TOKEN", "hf_new_value");
|
|
551
|
+
*
|
|
552
|
+
* // Delete secret
|
|
553
|
+
* await client.secrets.delete("HF_TOKEN");
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
556
|
+
get secrets(): SecretsManager;
|
|
557
|
+
/**
|
|
558
|
+
* Access the integrations manager — webhooks (inbound + outbound),
|
|
559
|
+
* automations, connections to managed connectors, and recipes.
|
|
560
|
+
*
|
|
561
|
+
* Spec: specs/sandbox-integrations.md.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```typescript
|
|
565
|
+
* // Outbound: get pinged when a sandbox fails
|
|
566
|
+
* const ep = await client.integrations.endpoints.create({
|
|
567
|
+
* url: "https://example.com/hook",
|
|
568
|
+
* events: ["sandbox.failed", "sandbox.permanently_dead"],
|
|
569
|
+
* });
|
|
570
|
+
* console.log(ep.secret); // shown once — store it
|
|
571
|
+
*
|
|
572
|
+
* // Inbound: a public URL that, when POSTed to, runs an action
|
|
573
|
+
* const trg = await client.integrations.triggers.create({
|
|
574
|
+
* verificationKind: "hmac_shared_secret",
|
|
575
|
+
* action: {
|
|
576
|
+
* kind: "sandbox.create",
|
|
577
|
+
* config: { template: "node-22", prompt: "Run: ${body.prompt}" },
|
|
578
|
+
* },
|
|
579
|
+
* });
|
|
580
|
+
* console.log(trg.publicUrl);
|
|
581
|
+
*
|
|
582
|
+
* // One-click recipe install
|
|
583
|
+
* const auto = await client.integrations.automations.installFromRecipe(
|
|
584
|
+
* "github.pr-review",
|
|
585
|
+
* { connectionId: "ic_…", inputs: { template: "node-22" } },
|
|
586
|
+
* );
|
|
587
|
+
* ```
|
|
588
|
+
*/
|
|
589
|
+
get integrations(): IntegrationsManager;
|
|
590
|
+
private _environments;
|
|
591
|
+
/**
|
|
592
|
+
* Access available development environments.
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```typescript
|
|
596
|
+
* const envs = await client.environments.list();
|
|
597
|
+
* // → [{ id: "universal", description: "Universal environment with all toolchains via Nix", ... }]
|
|
598
|
+
*
|
|
599
|
+
* const sandbox = await client.create({ environment: "universal" });
|
|
600
|
+
* ```
|
|
601
|
+
*/
|
|
602
|
+
get environments(): EnvironmentsClient;
|
|
603
|
+
private _teams;
|
|
604
|
+
private _publicTemplates;
|
|
605
|
+
/**
|
|
606
|
+
* Access team management (collaboration groups, invitations,
|
|
607
|
+
* member roles). Teams scope shared sandboxes — pass `teamId` to
|
|
608
|
+
* `client.create()` to create a sandbox accessible to a team's
|
|
609
|
+
* members.
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* const teams = await client.teams.list();
|
|
614
|
+
* const invite = await client.teams.invite(teams[0].id, {
|
|
615
|
+
* email: "alice@example.com",
|
|
616
|
+
* role: "member",
|
|
617
|
+
* });
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
get teams(): TeamsClient;
|
|
621
|
+
get publicTemplates(): PublicTemplatesClient;
|
|
622
|
+
/**
|
|
623
|
+
* Create a new sandbox.
|
|
624
|
+
*
|
|
625
|
+
* @param options - Configuration for the new sandbox
|
|
626
|
+
* @returns A SandboxInstance representing the created sandbox
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* ```typescript
|
|
630
|
+
* const box = await client.create({
|
|
631
|
+
* name: "my-project",
|
|
632
|
+
* environment: "universal",
|
|
633
|
+
* sshEnabled: true,
|
|
634
|
+
* env: { NODE_ENV: "development" },
|
|
635
|
+
* });
|
|
636
|
+
* ```
|
|
637
|
+
*/
|
|
638
|
+
create(options?: CreateSandboxOptions): Promise<SandboxInstance>;
|
|
639
|
+
/**
|
|
640
|
+
* List all sandboxes.
|
|
641
|
+
*
|
|
642
|
+
* @param options - Filtering and pagination options
|
|
643
|
+
* @returns Array of SandboxInstance objects
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* ```typescript
|
|
647
|
+
* // List all running sandboxes
|
|
648
|
+
* const running = await client.list({ status: "running" });
|
|
649
|
+
*
|
|
650
|
+
* // List with pagination
|
|
651
|
+
* const page = await client.list({ limit: 10, offset: 0 });
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
654
|
+
list(options?: ListSandboxOptions): Promise<SandboxInstance[]>;
|
|
655
|
+
/**
|
|
656
|
+
* Get a sandbox by ID.
|
|
657
|
+
*
|
|
658
|
+
* @param id - The sandbox ID
|
|
659
|
+
* @returns A SandboxInstance or null if not found
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```typescript
|
|
663
|
+
* const box = await client.get("sandbox_abc123");
|
|
664
|
+
* if (box) {
|
|
665
|
+
* console.log(box.status);
|
|
666
|
+
* }
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
669
|
+
get(id: string): Promise<SandboxInstance | null>;
|
|
670
|
+
/**
|
|
671
|
+
* Get usage information for the account.
|
|
672
|
+
*
|
|
673
|
+
* @returns Usage statistics for the current billing period
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* ```typescript
|
|
677
|
+
* const usage = await client.usage();
|
|
678
|
+
* console.log(`Active sandboxes: ${usage.activeSandboxes}`);
|
|
679
|
+
* console.log(`Compute minutes: ${usage.computeMinutes}`);
|
|
680
|
+
* ```
|
|
681
|
+
*/
|
|
682
|
+
usage(): Promise<UsageInfo>;
|
|
683
|
+
/**
|
|
684
|
+
* Get subscription and billing information for the account.
|
|
685
|
+
*
|
|
686
|
+
* @returns Subscription details including plan, credits, and limits
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* ```typescript
|
|
690
|
+
* const sub = await client.subscription();
|
|
691
|
+
* console.log(`Plan: ${sub.plan}`);
|
|
692
|
+
* console.log(`Credits: $${sub.creditsAvailableUsd.toFixed(2)}`);
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
695
|
+
subscription(): Promise<SubscriptionInfo>;
|
|
696
|
+
/**
|
|
697
|
+
* Check if the Sandbox API is available.
|
|
698
|
+
*
|
|
699
|
+
* @returns true if the API is healthy, false otherwise
|
|
700
|
+
*/
|
|
701
|
+
health(): Promise<boolean>;
|
|
702
|
+
/**
|
|
703
|
+
* Check if CRIU checkpointing is available on the platform.
|
|
704
|
+
*
|
|
705
|
+
* CRIU enables memory preservation for true pause/resume and fork operations.
|
|
706
|
+
* It requires specific host configuration.
|
|
707
|
+
*
|
|
708
|
+
* @returns CRIU availability status
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* ```typescript
|
|
712
|
+
* const status = await client.criuStatus();
|
|
713
|
+
* if (status.available) {
|
|
714
|
+
* console.log(`CRIU ${status.criuVersion} available`);
|
|
715
|
+
* } else {
|
|
716
|
+
* console.log(`CRIU not available: ${status.reason}`);
|
|
717
|
+
* }
|
|
718
|
+
* ```
|
|
719
|
+
*/
|
|
720
|
+
criuStatus(): Promise<{
|
|
721
|
+
available: boolean;
|
|
722
|
+
criuVersion?: string;
|
|
723
|
+
reason?: string;
|
|
724
|
+
requirements?: {
|
|
725
|
+
kernel: boolean;
|
|
726
|
+
criu: boolean;
|
|
727
|
+
storageDriver: boolean;
|
|
728
|
+
experimental: boolean;
|
|
729
|
+
};
|
|
730
|
+
}>;
|
|
731
|
+
/**
|
|
732
|
+
* Run multiple tasks in parallel across sandboxes.
|
|
733
|
+
* Returns the aggregated results after all tasks complete.
|
|
734
|
+
*
|
|
735
|
+
* @param tasks - Array of tasks to execute
|
|
736
|
+
* @param options - Batch execution options
|
|
737
|
+
* @returns Aggregated batch results
|
|
738
|
+
*
|
|
739
|
+
* @throws {@link TimeoutError} if the server hasn't begun responding
|
|
740
|
+
* before the deadline (pre-stream timeout).
|
|
741
|
+
* @throws {@link ValidationError} / {@link QuotaError} / other typed
|
|
742
|
+
* SDK errors if the server rejects the request before streaming.
|
|
743
|
+
* @throws `DOMException` with `name === "AbortError"` if
|
|
744
|
+
* `options.signal` fires OR the safety-valve deadline fires
|
|
745
|
+
* AFTER streaming has begun — parseSSEStream can't distinguish
|
|
746
|
+
* the source mid-stream. Callers that need to tell cancel from
|
|
747
|
+
* timeout should check `options.signal?.aborted` in their catch.
|
|
748
|
+
* @throws `Error` with the server message if the stream emits a
|
|
749
|
+
* `batch.failed` event.
|
|
750
|
+
*
|
|
751
|
+
* @example
|
|
752
|
+
* ```typescript
|
|
753
|
+
* const result = await client.runBatch([
|
|
754
|
+
* { id: "task-1", message: "Analyze this file" },
|
|
755
|
+
* { id: "task-2", message: "Generate a summary" },
|
|
756
|
+
* ]);
|
|
757
|
+
* console.log(`Success rate: ${result.successRate}%`);
|
|
758
|
+
* ```
|
|
759
|
+
*/
|
|
760
|
+
runBatch(tasks: BatchTask[], options?: BatchOptions): Promise<BatchResult>;
|
|
761
|
+
/**
|
|
762
|
+
* Stream events from a batch execution.
|
|
763
|
+
* Use this for real-time progress updates during batch processing.
|
|
764
|
+
*
|
|
765
|
+
* @param tasks - Array of tasks to execute
|
|
766
|
+
* @param options - Batch execution options
|
|
767
|
+
*
|
|
768
|
+
* @throws {@link TimeoutError} if the server hasn't begun responding
|
|
769
|
+
* before the deadline (pre-stream timeout).
|
|
770
|
+
* @throws {@link ValidationError} / {@link QuotaError} / other typed
|
|
771
|
+
* SDK errors if the server rejects the request before streaming.
|
|
772
|
+
* @throws `DOMException` with `name === "AbortError"` if
|
|
773
|
+
* `options.signal` fires OR the safety-valve deadline fires
|
|
774
|
+
* AFTER streaming has begun. Distinguish via
|
|
775
|
+
* `options.signal?.aborted` in the consumer's catch.
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* ```typescript
|
|
779
|
+
* for await (const event of client.streamBatch(tasks)) {
|
|
780
|
+
* if (event.type === "task.completed") {
|
|
781
|
+
* console.log(`Task ${event.data.taskId} completed`);
|
|
782
|
+
* }
|
|
783
|
+
* }
|
|
784
|
+
* ```
|
|
785
|
+
*/
|
|
786
|
+
streamBatch(tasks: BatchTask[], options?: BatchOptions): AsyncGenerator<BatchEvent>;
|
|
787
|
+
/**
|
|
788
|
+
* Make an authenticated HTTP request to the API.
|
|
789
|
+
* This is exposed for use by SandboxInstance.
|
|
790
|
+
*/
|
|
791
|
+
fetch(path: string, options?: RequestInit): Promise<Response>;
|
|
792
|
+
private parseInfo;
|
|
793
|
+
private readonly _tokenRefreshHandlers;
|
|
794
|
+
/**
|
|
795
|
+
* Register a handler invoked when the SDK transparently refreshes a
|
|
796
|
+
* sandbox bearer after a 401 retry. Returns a function that
|
|
797
|
+
* unregisters the handler when called.
|
|
798
|
+
*/
|
|
799
|
+
onTokenRefresh(handler: TokenRefreshHandler): () => void;
|
|
800
|
+
/** @internal — fired by the runtime-fetch retry path after a successful
|
|
801
|
+
* refresh. Errors thrown by handlers are caught and surfaced as
|
|
802
|
+
* console warnings so one bad subscriber does not poison the rest. */
|
|
803
|
+
_emitTokenRefresh(sandboxId: string, newToken: string): void;
|
|
804
|
+
}
|
|
805
|
+
declare class IntelligenceClient {
|
|
806
|
+
private readonly client;
|
|
807
|
+
constructor(client: SandboxClient);
|
|
808
|
+
createReport(options: CreateIntelligenceReportOptions): Promise<IntelligenceReport>;
|
|
809
|
+
createAgenticReport(options: {
|
|
810
|
+
subject: CreateIntelligenceReportOptions["subject"];
|
|
811
|
+
maxUsd: number;
|
|
812
|
+
metadata?: Record<string, unknown>;
|
|
813
|
+
}): Promise<IntelligenceReport>;
|
|
814
|
+
getReport(jobId: string): Promise<IntelligenceReport>;
|
|
815
|
+
listReports(options?: {
|
|
816
|
+
subjectType?: CreateIntelligenceReportOptions["subject"]["type"];
|
|
817
|
+
subjectId?: string;
|
|
818
|
+
limit?: number;
|
|
819
|
+
}): Promise<IntelligenceReport[]>;
|
|
820
|
+
waitForReport(jobId: string, options?: {
|
|
821
|
+
timeoutMs?: number;
|
|
822
|
+
pollMs?: number;
|
|
823
|
+
}): Promise<IntelligenceReport>;
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Client for browsing available development environments.
|
|
827
|
+
*/
|
|
828
|
+
declare class EnvironmentsClient {
|
|
829
|
+
private readonly client;
|
|
830
|
+
constructor(client: SandboxClient);
|
|
831
|
+
/**
|
|
832
|
+
* List available development environments.
|
|
833
|
+
*
|
|
834
|
+
* @returns Array of available environments with metadata
|
|
835
|
+
*
|
|
836
|
+
* @example
|
|
837
|
+
* ```typescript
|
|
838
|
+
* const envs = await client.environments.list();
|
|
839
|
+
* for (const env of envs) {
|
|
840
|
+
* console.log(`${env.id}: ${env.description}`);
|
|
841
|
+
* }
|
|
842
|
+
* ```
|
|
843
|
+
*/
|
|
844
|
+
list(): Promise<SandboxEnvironment[]>;
|
|
845
|
+
/**
|
|
846
|
+
* Get details for a specific environment.
|
|
847
|
+
*
|
|
848
|
+
* @param id - Environment identifier (e.g., "universal")
|
|
849
|
+
*/
|
|
850
|
+
get(id: string): Promise<SandboxEnvironment | null>;
|
|
851
|
+
}
|
|
852
|
+
declare class PublicTemplatesClient {
|
|
853
|
+
private readonly client;
|
|
854
|
+
constructor(client: SandboxClient);
|
|
855
|
+
list(options?: {
|
|
856
|
+
query?: string;
|
|
857
|
+
tag?: string;
|
|
858
|
+
featuredOnly?: boolean;
|
|
859
|
+
limit?: number;
|
|
860
|
+
offset?: number;
|
|
861
|
+
}): Promise<PublicTemplateInfo[]>;
|
|
862
|
+
featured(): Promise<PublicTemplateInfo[]>;
|
|
863
|
+
get(idOrSlug: string): Promise<PublicTemplateInfo>;
|
|
864
|
+
versions(idOrSlug: string): Promise<PublicTemplateVersionInfo[]>;
|
|
865
|
+
publish(options: PublishPublicTemplateOptions): Promise<PublicTemplateInfo>;
|
|
866
|
+
publishVersion(idOrSlug: string, options: PublishPublicTemplateVersionOptions): Promise<PublicTemplateVersionInfo>;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Team (collaboration group) record as returned from the API.
|
|
870
|
+
*/
|
|
871
|
+
interface Team {
|
|
872
|
+
id: string;
|
|
873
|
+
name: string;
|
|
874
|
+
ownerCustomerId: string;
|
|
875
|
+
orgId: string | null;
|
|
876
|
+
memberCount: number;
|
|
877
|
+
currentUserRole: "owner" | "admin" | "member" | "viewer";
|
|
878
|
+
createdAt: string;
|
|
879
|
+
updatedAt: string;
|
|
880
|
+
}
|
|
881
|
+
interface TeamMember {
|
|
882
|
+
id: string;
|
|
883
|
+
teamId: string;
|
|
884
|
+
customerId: string;
|
|
885
|
+
customerEmail: string;
|
|
886
|
+
customerName: string | null;
|
|
887
|
+
role: "owner" | "admin" | "member" | "viewer";
|
|
888
|
+
status: "active" | "pending" | "removed";
|
|
889
|
+
joinedAt: string | null;
|
|
890
|
+
createdAt: string;
|
|
891
|
+
}
|
|
892
|
+
interface TeamInvitation {
|
|
893
|
+
id: string;
|
|
894
|
+
teamId: string;
|
|
895
|
+
email: string;
|
|
896
|
+
invitedBy: string;
|
|
897
|
+
invitedByEmail: string | null;
|
|
898
|
+
role: "admin" | "member" | "viewer";
|
|
899
|
+
token: string;
|
|
900
|
+
status: "pending" | "accepted" | "expired" | "revoked";
|
|
901
|
+
expiresAt: string;
|
|
902
|
+
createdAt: string;
|
|
903
|
+
}
|
|
904
|
+
interface TeamInvitationPreview {
|
|
905
|
+
email: string;
|
|
906
|
+
role: "admin" | "member" | "viewer";
|
|
907
|
+
status: "pending" | "accepted" | "expired" | "revoked";
|
|
908
|
+
expiresAt: string;
|
|
909
|
+
teamName: string;
|
|
910
|
+
invitedByEmail: string | null;
|
|
911
|
+
}
|
|
912
|
+
interface TeamSecretRecord {
|
|
913
|
+
name: string;
|
|
914
|
+
updatedAt: string;
|
|
915
|
+
updatedBy: string;
|
|
916
|
+
}
|
|
917
|
+
interface TeamTemplateRecord {
|
|
918
|
+
id: string;
|
|
919
|
+
name: string;
|
|
920
|
+
description: string;
|
|
921
|
+
snapshotId: string;
|
|
922
|
+
environment: string;
|
|
923
|
+
config: Record<string, unknown>;
|
|
924
|
+
teamId: string | null;
|
|
925
|
+
createdAt: string;
|
|
926
|
+
updatedAt: string;
|
|
927
|
+
}
|
|
928
|
+
interface CreateTeamTemplateOptions {
|
|
929
|
+
name: string;
|
|
930
|
+
snapshotId: string;
|
|
931
|
+
description?: string;
|
|
932
|
+
environment?: string;
|
|
933
|
+
config?: Record<string, unknown>;
|
|
934
|
+
}
|
|
935
|
+
interface CreateTeamOptions {
|
|
936
|
+
name: string;
|
|
937
|
+
orgId?: string;
|
|
938
|
+
}
|
|
939
|
+
interface InviteTeamMemberOptions {
|
|
940
|
+
email: string;
|
|
941
|
+
role: "admin" | "member" | "viewer";
|
|
942
|
+
/** Lifetime of the invitation in hours (default 168 = 7 days). */
|
|
943
|
+
ttlHours?: number;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Client for managing teams and team-scoped sharing.
|
|
947
|
+
*
|
|
948
|
+
* Team resources are scoped to the authenticated user's membership —
|
|
949
|
+
* the client never needs to pass an org id explicitly.
|
|
950
|
+
*/
|
|
951
|
+
declare class TeamsClient {
|
|
952
|
+
private readonly client;
|
|
953
|
+
constructor(client: SandboxClient);
|
|
954
|
+
list(): Promise<Team[]>;
|
|
955
|
+
create(options: CreateTeamOptions): Promise<Team>;
|
|
956
|
+
get(teamId: string): Promise<Team>;
|
|
957
|
+
update(teamId: string, updates: {
|
|
958
|
+
name?: string;
|
|
959
|
+
}): Promise<Team>;
|
|
960
|
+
delete(teamId: string): Promise<void>;
|
|
961
|
+
leave(teamId: string): Promise<void>;
|
|
962
|
+
transferOwnership(teamId: string, newOwnerCustomerId: string): Promise<void>;
|
|
963
|
+
listMembers(teamId: string): Promise<TeamMember[]>;
|
|
964
|
+
updateMember(teamId: string, memberId: string, updates: {
|
|
965
|
+
role?: "admin" | "member" | "viewer";
|
|
966
|
+
status?: "active" | "removed";
|
|
967
|
+
}): Promise<TeamMember>;
|
|
968
|
+
removeMember(teamId: string, memberId: string): Promise<void>;
|
|
969
|
+
listInvitations(teamId: string): Promise<TeamInvitation[]>;
|
|
970
|
+
invite(teamId: string, options: InviteTeamMemberOptions): Promise<TeamInvitation>;
|
|
971
|
+
revokeInvitation(invitationId: string): Promise<void>;
|
|
972
|
+
acceptInvitation(token: string): Promise<TeamMember>;
|
|
973
|
+
getInvitation(token: string): Promise<TeamInvitationPreview>;
|
|
974
|
+
listSecrets(teamId: string): Promise<TeamSecretRecord[]>;
|
|
975
|
+
upsertSecret(teamId: string, name: string, value: string): Promise<TeamSecretRecord>;
|
|
976
|
+
deleteSecret(teamId: string, name: string): Promise<void>;
|
|
977
|
+
revealSecret(teamId: string, name: string): Promise<{
|
|
978
|
+
name: string;
|
|
979
|
+
value: string;
|
|
980
|
+
}>;
|
|
981
|
+
listTemplates(teamId: string): Promise<TeamTemplateRecord[]>;
|
|
982
|
+
createTemplate(teamId: string, options: CreateTeamTemplateOptions): Promise<TeamTemplateRecord>;
|
|
983
|
+
deleteTemplate(teamId: string, templateId: string): Promise<void>;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Alias for SandboxClient for cleaner imports.
|
|
987
|
+
*/
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region src/errors.d.ts
|
|
990
|
+
/**
|
|
991
|
+
* Sandbox SDK Errors
|
|
992
|
+
*
|
|
993
|
+
* Error classes for the Sandbox client SDK.
|
|
994
|
+
*/
|
|
995
|
+
/**
|
|
996
|
+
* Base error class for all Sandbox SDK errors.
|
|
997
|
+
*/
|
|
998
|
+
declare class SandboxError extends Error {
|
|
999
|
+
/** HTTP status code if applicable */
|
|
1000
|
+
readonly status?: number;
|
|
1001
|
+
/** Error code for programmatic handling */
|
|
1002
|
+
readonly code: string;
|
|
1003
|
+
/** Best-effort origin of the failing request */
|
|
1004
|
+
readonly origin?: SandboxErrorOrigin;
|
|
1005
|
+
/** Request path or endpoint when known */
|
|
1006
|
+
readonly endpoint?: string;
|
|
1007
|
+
/** Retry-after duration in ms when surfaced by the upstream */
|
|
1008
|
+
readonly retryAfterMs?: number;
|
|
1009
|
+
/** Sidecar version when the runtime emitted it */
|
|
1010
|
+
readonly sidecarVersion?: string;
|
|
1011
|
+
/** Sidecar image/tag/sha when the runtime emitted it */
|
|
1012
|
+
readonly containerImage?: string;
|
|
1013
|
+
constructor(message: string, code: string, status?: number, metadata?: SandboxErrorMetadata);
|
|
1014
|
+
}
|
|
1015
|
+
type SandboxErrorOrigin = "sidecar" | "sandbox-api" | "control-plane" | "runtime" | "unknown";
|
|
1016
|
+
interface SandboxErrorMetadata {
|
|
1017
|
+
origin?: SandboxErrorOrigin;
|
|
1018
|
+
endpoint?: string;
|
|
1019
|
+
retryAfterMs?: number;
|
|
1020
|
+
sidecarVersion?: string;
|
|
1021
|
+
containerImage?: string;
|
|
1022
|
+
}
|
|
1023
|
+
type SandboxErrorJson = string | number | boolean | null | {
|
|
1024
|
+
[key: string]: SandboxErrorJson;
|
|
1025
|
+
} | SandboxErrorJson[];
|
|
1026
|
+
type SandboxFailureDetail = {
|
|
1027
|
+
[key: string]: SandboxErrorJson;
|
|
1028
|
+
};
|
|
1029
|
+
/**
|
|
1030
|
+
* Authentication failed or API key is invalid.
|
|
1031
|
+
*/
|
|
1032
|
+
declare class AuthError extends SandboxError {
|
|
1033
|
+
constructor(message?: string, metadata?: SandboxErrorMetadata);
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* The requested resource was not found.
|
|
1037
|
+
*/
|
|
1038
|
+
declare class NotFoundError extends SandboxError {
|
|
1039
|
+
/** The resource type that was not found */
|
|
1040
|
+
readonly resourceType: string;
|
|
1041
|
+
/** The resource ID that was not found */
|
|
1042
|
+
readonly resourceId: string;
|
|
1043
|
+
constructor(resourceType: string, resourceId: string, metadata?: SandboxErrorMetadata);
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Account quota or rate limit exceeded.
|
|
1047
|
+
*/
|
|
1048
|
+
declare class QuotaError extends SandboxError {
|
|
1049
|
+
/** The type of quota that was exceeded */
|
|
1050
|
+
readonly quotaType: string;
|
|
1051
|
+
/** Current usage */
|
|
1052
|
+
readonly current?: number;
|
|
1053
|
+
/** Maximum allowed */
|
|
1054
|
+
readonly limit?: number;
|
|
1055
|
+
/** Suggested retry-after duration in ms */
|
|
1056
|
+
readonly retryAfterMs?: number;
|
|
1057
|
+
constructor(quotaType: string, message?: string, current?: number, limit?: number, metadata?: SandboxErrorMetadata, status?: number);
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* The requested capability is unavailable for the account, driver, or sandbox.
|
|
1061
|
+
*/
|
|
1062
|
+
declare class CapabilityError extends SandboxError {
|
|
1063
|
+
/** Capability or feature that was rejected when known */
|
|
1064
|
+
readonly capability?: string;
|
|
1065
|
+
constructor(message: string, code?: string, status?: number, metadata?: SandboxErrorMetadata, capability?: string);
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* A multi-resource operation failed for one or more branches.
|
|
1069
|
+
*/
|
|
1070
|
+
declare class PartialFailureError extends SandboxError {
|
|
1071
|
+
/** Per-resource failures returned by the API when available */
|
|
1072
|
+
readonly failures?: SandboxFailureDetail[];
|
|
1073
|
+
constructor(message: string, code?: string, status?: number, metadata?: SandboxErrorMetadata, failures?: SandboxFailureDetail[]);
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* The request was invalid or malformed.
|
|
1077
|
+
*/
|
|
1078
|
+
declare class ValidationError extends SandboxError {
|
|
1079
|
+
/** Field-level validation errors */
|
|
1080
|
+
readonly fields?: Record<string, string>;
|
|
1081
|
+
constructor(message: string, fields?: Record<string, string>, metadata?: SandboxErrorMetadata);
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* The sandbox is not in a valid state for the requested operation.
|
|
1085
|
+
*/
|
|
1086
|
+
declare class StateError extends SandboxError {
|
|
1087
|
+
/** Current state of the sandbox */
|
|
1088
|
+
readonly currentState: string;
|
|
1089
|
+
/** Required state for the operation */
|
|
1090
|
+
readonly requiredState?: string;
|
|
1091
|
+
constructor(message: string, currentState: string, requiredState?: string, metadata?: SandboxErrorMetadata);
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* The request timed out.
|
|
1095
|
+
*/
|
|
1096
|
+
declare class TimeoutError extends SandboxError {
|
|
1097
|
+
/** Timeout duration in milliseconds */
|
|
1098
|
+
readonly timeoutMs: number;
|
|
1099
|
+
constructor(timeoutMs: number, message?: string, metadata?: SandboxErrorMetadata);
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* A network or connection error occurred.
|
|
1103
|
+
*/
|
|
1104
|
+
declare class NetworkError extends SandboxError {
|
|
1105
|
+
/** The underlying error */
|
|
1106
|
+
readonly cause?: Error;
|
|
1107
|
+
constructor(message: string, causeOrMetadata?: Error | SandboxErrorMetadata, metadata?: SandboxErrorMetadata);
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* The server returned an unexpected error.
|
|
1111
|
+
*/
|
|
1112
|
+
declare class ServerError extends SandboxError {
|
|
1113
|
+
constructor(message: string, status?: number, metadata?: SandboxErrorMetadata);
|
|
1114
|
+
}
|
|
1115
|
+
//#endregion
|
|
1116
|
+
export { IntegrationActionKind as A, TriggerWithSecret as B, CreateEndpointInput as C, EndpointWithSecret as D, EndpointInfo as E, IntegrationVerificationKind as F, parseSSEStream as G, SandboxFleetClient as H, IntegrationsManager as I, RecipeManifest as L, IntegrationPrincipalType as M, IntegrationProvider as N, InstallRecipeInput as O, IntegrationScope as P, TriggerInfo as R, CreateAutomationInput as S, DeliveryAttempt as T, ParseSSEStreamOptions as U, SandboxFleet as V, ParsedSSEEvent as W, Team as _, PartialFailureError as a, AutomationInfo as b, SandboxErrorJson as c, StateError as d, TimeoutError as f, SandboxClient as g, InviteTeamMemberOptions as h, NotFoundError as i, IntegrationDeliveryStatus as j, IntegrationAction as k, SandboxFailureDetail as l, CreateTeamOptions as m, CapabilityError as n, QuotaError as o, ValidationError as p, NetworkError as r, SandboxError as s, AuthError as t, ServerError as u, TeamInvitation as v, CreateTriggerInput as w, ConnectionInfo as x, TeamMember as y, TriggerRun as z };
|