@tangle-network/sandbox 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +561 -2
- package/dist/agent/index.d.ts +435 -0
- package/dist/agent/index.js +1 -0
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/client-BuPZLOxS.d.ts +1050 -0
- package/dist/client-BwRV2Zun.js +1 -0
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/collaboration-CRyb5e8F.js +1 -0
- package/dist/core.d.ts +4 -3
- package/dist/core.js +1 -1
- package/dist/errors-1Se5ATyZ.d.ts +128 -0
- package/dist/errors-CljiGR__.js +1 -0
- package/dist/{index-t7xkzv0U.d.ts → index-2gFsmmQs.d.ts} +3 -3
- package/dist/{index-gA-oRjOi.d.ts → index-D-2pH_70.d.ts} +35 -4
- package/dist/{index-BuS8nl3b.d.ts → index-D7bwmNs8.d.ts} +6 -1
- package/dist/index.d.ts +110 -62
- package/dist/index.js +1 -1
- package/dist/openai/index.d.ts +641 -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-BvZ0-Iv7.d.ts → sandbox-CpK8etqP.d.ts} +1735 -41
- package/dist/sandbox-DTup2jzz.js +1 -0
- package/dist/session-gateway/index.js +1 -1
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/tangle-CnYnTRi6.js +1 -0
- package/package.json +114 -34
- package/LICENSE +0 -11
- package/dist/client-CcRvqt85.js +0 -1
- package/dist/collaboration-CVvhPU8M.js +0 -1
- package/dist/errors-AIT8qikt.d.ts +0 -491
- package/dist/errors-CdMTv7uG.js +0 -1
- package/dist/sandbox-D1JnQIJx.js +0 -1
- package/dist/tangle-CSb9rjAh.js +0 -1
|
@@ -0,0 +1,1050 @@
|
|
|
1
|
+
import { A as BatchTask, Ar as UsageInfo, Bn as SandboxFleetUsage, Cn as SandboxFleetDriverCapability, D as BatchEvent, Dt as IntelligenceReportCompareTo, Et as IntelligenceReportBudget, Fn as SandboxFleetToken, G as CreateSandboxOptions, Gn as SandboxInfo, H as CreateSandboxFleetOptions, Hn as SandboxFleetWorkspaceReconcileResult, In as SandboxFleetTraceBundle, Mt as ListSandboxFleetOptions, Nn as SandboxFleetOperationsSummary, Nt as ListSandboxOptions, O as BatchOptions, Qt as PromptResult, Sn as SandboxFleetDispatchResponse, Tn as SandboxFleetInfo, Tr as TokenRefreshHandler, Tt as IntelligenceReport, U as CreateSandboxFleetTokenOptions, Un as SandboxFleetWorkspaceRestoreResult, V as CreateIntelligenceReportOptions, W as CreateSandboxFleetWithCoordinatorOptions, Wn as SandboxFleetWorkspaceSnapshotResult, Xt as PromptInputPart, Zt as PromptOptions, _r as SubscriptionInfo, a as TraceExportSink, an as PublishPublicTemplateOptions, b as AttachSandboxFleetMachineOptions, bn as SandboxFleetCostEstimate, cn as ReapExpiredSandboxFleetsResult, ct as FleetDispatchResultBufferOptions, dt as FleetExecDispatchResult, ft as FleetMachineId, gn as SandboxEnvironment, hr as SshKeysManager, i as TraceExportResult, in as PublicTemplateVersionInfo, jn as SandboxFleetManifest, k as BatchResult, kn as SandboxFleetMachineRecord, kt as IntelligenceReportWindow, ln as ReconcileSandboxFleetsOptions, lt as FleetDispatchStreamOptions, mn as SandboxClientConfig, mt as FleetPromptDispatchResult, n as SandboxInstance, nt as ExecOptions, on as PublishPublicTemplateVersionOptions, or as SecretsManager, ot as FleetDispatchCancelResult, pt as FleetPromptDispatchOptions, rn as PublicTemplateInfo, rt as ExecResult, sn as ReapExpiredSandboxFleetsOptions, st as FleetDispatchResultBuffer, t as HttpClient, un as ReconcileSandboxFleetsResult, ut as FleetExecDispatchOptions, vn as SandboxFleetArtifact, yn as SandboxFleetArtifactSpec, zn as SandboxFleetTraceOptions } from "./sandbox-CpK8etqP.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
|
+
/**
|
|
66
|
+
* The subset of `SandboxClient` the fleet classes drive. Declared here
|
|
67
|
+
* rather than importing the concrete class so `fleet.ts` stays a leaf of
|
|
68
|
+
* `client.ts` — `client.ts` constructs `SandboxFleetClient`, so the reverse
|
|
69
|
+
* import would form a cycle. `SandboxClient` satisfies this structurally.
|
|
70
|
+
*/
|
|
71
|
+
interface FleetClientHost {
|
|
72
|
+
create(options?: CreateSandboxOptions): Promise<SandboxInstance>;
|
|
73
|
+
list(options?: ListSandboxOptions): Promise<SandboxInstance[]>;
|
|
74
|
+
get(id: string): Promise<SandboxInstance | null>;
|
|
75
|
+
fetch(path: string, options?: RequestInit): Promise<Response>;
|
|
76
|
+
readonly fleets: SandboxFleetClient;
|
|
77
|
+
readonly intelligence: {
|
|
78
|
+
createReport(options: CreateIntelligenceReportOptions): Promise<IntelligenceReport>;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
declare class SandboxFleet {
|
|
82
|
+
private readonly client;
|
|
83
|
+
readonly fleetId: string;
|
|
84
|
+
readonly machines: ReadonlyMap<FleetMachineId, SandboxInfo>;
|
|
85
|
+
constructor(client: FleetClientHost, fleetId: string, machines: ReadonlyMap<FleetMachineId, SandboxInfo>);
|
|
86
|
+
get ids(): FleetMachineId[];
|
|
87
|
+
get(machineId: FleetMachineId): SandboxInfo;
|
|
88
|
+
sandbox(machineId: FleetMachineId): Promise<SandboxInstance>;
|
|
89
|
+
collectArtifacts(artifacts: readonly SandboxFleetArtifactSpec[]): Promise<SandboxFleetArtifact[]>;
|
|
90
|
+
exec(machineId: FleetMachineId, command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
91
|
+
dispatchExec(command: string, options?: FleetExecDispatchOptions): Promise<FleetExecDispatchResult[]>;
|
|
92
|
+
dispatchExecDetailed(command: string, options?: FleetExecDispatchOptions): Promise<SandboxFleetDispatchResponse<FleetExecDispatchResult>>;
|
|
93
|
+
prompt(machineId: FleetMachineId, message: string | PromptInputPart[], options?: PromptOptions): Promise<PromptResult>;
|
|
94
|
+
dispatchPrompt(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions): Promise<FleetPromptDispatchResult[]>;
|
|
95
|
+
dispatchPromptDetailed(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions): Promise<SandboxFleetDispatchResponse<FleetPromptDispatchResult>>;
|
|
96
|
+
manifest(): Promise<SandboxFleetManifest>;
|
|
97
|
+
attachMachine(machine: AttachSandboxFleetMachineOptions): Promise<SandboxFleetMachineRecord>;
|
|
98
|
+
detachMachine(machineId: FleetMachineId): Promise<{
|
|
99
|
+
success: boolean;
|
|
100
|
+
}>;
|
|
101
|
+
dispatchResults<T = FleetExecDispatchResult | FleetPromptDispatchResult>(dispatchId: string, options?: FleetDispatchResultBufferOptions): Promise<FleetDispatchResultBuffer<T>>;
|
|
102
|
+
cancelDispatch(dispatchId: string, reason?: string): Promise<FleetDispatchCancelResult>;
|
|
103
|
+
createWorkspaceSnapshot(): Promise<SandboxFleetWorkspaceSnapshotResult>;
|
|
104
|
+
restoreWorkspaceSnapshot(snapshotId: string): Promise<SandboxFleetWorkspaceRestoreResult>;
|
|
105
|
+
reconcileWorkspace(): Promise<SandboxFleetWorkspaceReconcileResult>;
|
|
106
|
+
dispatchExecStream(command: string, options?: FleetExecDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent, any, any>;
|
|
107
|
+
dispatchPromptStream(message: string | PromptInputPart[], options?: FleetPromptDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent, any, any>;
|
|
108
|
+
delete(options?: {
|
|
109
|
+
continueOnError?: boolean;
|
|
110
|
+
}): Promise<void>;
|
|
111
|
+
usage(): Promise<SandboxFleetUsage>;
|
|
112
|
+
trace(options?: SandboxFleetTraceOptions): Promise<SandboxFleetTraceBundle>;
|
|
113
|
+
intelligence(): Promise<NonNullable<SandboxFleetTraceBundle["intelligence"]>>;
|
|
114
|
+
createIntelligenceReport(options?: {
|
|
115
|
+
mode?: "deterministic" | "agentic";
|
|
116
|
+
acknowledgeCost?: boolean;
|
|
117
|
+
budget?: IntelligenceReportBudget;
|
|
118
|
+
metadata?: Record<string, unknown>; /** Narrow the analysis to a single dispatch within this fleet. */
|
|
119
|
+
dispatchId?: string; /** Bound the analysis to a time window. */
|
|
120
|
+
window?: IntelligenceReportWindow; /** Compare this fleet against a same-type baseline fleet. */
|
|
121
|
+
compareTo?: IntelligenceReportCompareTo;
|
|
122
|
+
}): Promise<IntelligenceReport>;
|
|
123
|
+
createAgenticIntelligenceReport(options: {
|
|
124
|
+
maxUsd: number;
|
|
125
|
+
metadata?: Record<string, unknown>;
|
|
126
|
+
dispatchId?: string;
|
|
127
|
+
window?: IntelligenceReportWindow;
|
|
128
|
+
compareTo?: IntelligenceReportCompareTo;
|
|
129
|
+
}): Promise<IntelligenceReport>;
|
|
130
|
+
exportTrace(sink: TraceExportSink): Promise<TraceExportResult>;
|
|
131
|
+
cost(): Promise<SandboxFleetCostEstimate>;
|
|
132
|
+
createToken(options?: CreateSandboxFleetTokenOptions): Promise<SandboxFleetToken>;
|
|
133
|
+
private requireSandbox;
|
|
134
|
+
}
|
|
135
|
+
declare class SandboxFleetClient {
|
|
136
|
+
private readonly client;
|
|
137
|
+
constructor(client: FleetClientHost);
|
|
138
|
+
capabilities(): Promise<{
|
|
139
|
+
drivers: SandboxFleetDriverCapability[];
|
|
140
|
+
}>;
|
|
141
|
+
operations(): Promise<SandboxFleetOperationsSummary>;
|
|
142
|
+
reconcile(options?: ReconcileSandboxFleetsOptions): Promise<ReconcileSandboxFleetsResult>;
|
|
143
|
+
estimateCost(options: Pick<CreateSandboxFleetOptions, "defaults" | "machines" | "policy" | "maxConcurrentCreates">): Promise<SandboxFleetCostEstimate>;
|
|
144
|
+
create(options: CreateSandboxFleetOptions): Promise<SandboxFleet>;
|
|
145
|
+
createWithCoordinator(options: CreateSandboxFleetWithCoordinatorOptions): Promise<SandboxFleet>;
|
|
146
|
+
private createMachine;
|
|
147
|
+
list(options: ListSandboxFleetOptions): Promise<SandboxFleet>;
|
|
148
|
+
delete(fleetId: string, options?: Omit<ListSandboxFleetOptions, "fleetId"> & {
|
|
149
|
+
continueOnError?: boolean;
|
|
150
|
+
}): Promise<void>;
|
|
151
|
+
fromInfo(info: SandboxFleetInfo): SandboxFleet;
|
|
152
|
+
private persistFleet;
|
|
153
|
+
private getServerFleet;
|
|
154
|
+
deleteRecord(fleetId: string): Promise<void>;
|
|
155
|
+
usage(fleetId: string): Promise<SandboxFleetUsage>;
|
|
156
|
+
trace(fleetId: string, options?: SandboxFleetTraceOptions): Promise<SandboxFleetTraceBundle>;
|
|
157
|
+
intelligence(fleetId: string): Promise<NonNullable<SandboxFleetTraceBundle["intelligence"]>>;
|
|
158
|
+
createIntelligenceReport(fleetId: string, options?: {
|
|
159
|
+
mode?: "deterministic" | "agentic";
|
|
160
|
+
acknowledgeCost?: boolean;
|
|
161
|
+
budget?: IntelligenceReportBudget;
|
|
162
|
+
metadata?: Record<string, unknown>;
|
|
163
|
+
}): Promise<IntelligenceReport>;
|
|
164
|
+
createAgenticIntelligenceReport(fleetId: string, options: {
|
|
165
|
+
maxUsd: number;
|
|
166
|
+
metadata?: Record<string, unknown>;
|
|
167
|
+
}): Promise<IntelligenceReport>;
|
|
168
|
+
exportTrace(fleetId: string, sink: TraceExportSink): Promise<TraceExportResult>;
|
|
169
|
+
cost(fleetId: string): Promise<SandboxFleetCostEstimate>;
|
|
170
|
+
createToken(fleetId: string, options?: CreateSandboxFleetTokenOptions): Promise<SandboxFleetToken>;
|
|
171
|
+
manifest(fleetId: string): Promise<SandboxFleetManifest>;
|
|
172
|
+
attachMachine(fleetId: string, machine: AttachSandboxFleetMachineOptions): Promise<SandboxFleetMachineRecord>;
|
|
173
|
+
detachMachine(fleetId: string, machineId: FleetMachineId): Promise<{
|
|
174
|
+
success: boolean;
|
|
175
|
+
}>;
|
|
176
|
+
dispatchResults<T = FleetExecDispatchResult | FleetPromptDispatchResult>(fleetId: string, dispatchId: string, options?: FleetDispatchResultBufferOptions): Promise<FleetDispatchResultBuffer<T>>;
|
|
177
|
+
cancelDispatch(fleetId: string, dispatchId: string, reason?: string): Promise<FleetDispatchCancelResult>;
|
|
178
|
+
createWorkspaceSnapshot(fleetId: string): Promise<SandboxFleetWorkspaceSnapshotResult>;
|
|
179
|
+
restoreWorkspaceSnapshot(fleetId: string, snapshotId: string): Promise<SandboxFleetWorkspaceRestoreResult>;
|
|
180
|
+
reconcileWorkspace(fleetId: string): Promise<SandboxFleetWorkspaceReconcileResult>;
|
|
181
|
+
dispatchExecStream(fleetId: string, command: string, options?: FleetExecDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent>;
|
|
182
|
+
dispatchPromptStream(fleetId: string, message: string | PromptInputPart[], options?: FleetPromptDispatchOptions & FleetDispatchStreamOptions): AsyncGenerator<ParsedSSEEvent>;
|
|
183
|
+
reapExpired(options?: ReapExpiredSandboxFleetsOptions): Promise<ReapExpiredSandboxFleetsResult>;
|
|
184
|
+
private hydrateServerFleet;
|
|
185
|
+
private listBySandboxMetadata;
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/integrations.d.ts
|
|
189
|
+
type IntegrationPrincipalType = "customer" | "team";
|
|
190
|
+
type IntegrationProvider = "generic" | "github" | "generic_oauth2";
|
|
191
|
+
type IntegrationVerificationKind = "none" | "hmac_shared_secret" | "provider:github";
|
|
192
|
+
type IntegrationActionKind = "sandbox.create" | "sandbox.dispatch" | "sandbox.event" | "sandbox.respond_inline";
|
|
193
|
+
type IntegrationDeliveryStatus = "pending" | "delivered" | "failed" | "disabled";
|
|
194
|
+
/**
|
|
195
|
+
* Opaque JSON value flowing through an integration. Tied to whichever
|
|
196
|
+
* trigger/endpoint shape is on the wire — the SDK doesn't introspect
|
|
197
|
+
* it. Aliased instead of using bare `unknown` so call sites read as
|
|
198
|
+
* "this came from JSON" rather than "this is genuinely any type".
|
|
199
|
+
*/
|
|
200
|
+
type IntegrationJsonValue = unknown;
|
|
201
|
+
interface IntegrationAction {
|
|
202
|
+
kind: IntegrationActionKind;
|
|
203
|
+
config: IntegrationJsonValue;
|
|
204
|
+
mappings?: Record<string, string>;
|
|
205
|
+
}
|
|
206
|
+
interface IntegrationScope {
|
|
207
|
+
sandboxIds?: string[];
|
|
208
|
+
sessionIds?: string[];
|
|
209
|
+
teamId?: string;
|
|
210
|
+
}
|
|
211
|
+
interface ConnectionInfo {
|
|
212
|
+
id: string;
|
|
213
|
+
ownerType: IntegrationPrincipalType;
|
|
214
|
+
ownerId: string;
|
|
215
|
+
provider: IntegrationProvider;
|
|
216
|
+
externalId: string;
|
|
217
|
+
displayName: string | null;
|
|
218
|
+
authKind: "oauth2" | "api_key" | "signing_only";
|
|
219
|
+
metadata: Record<string, unknown> | null;
|
|
220
|
+
status: "active" | "revoked" | "error";
|
|
221
|
+
installedAt: string;
|
|
222
|
+
}
|
|
223
|
+
interface AutomationInfo {
|
|
224
|
+
id: string;
|
|
225
|
+
ownerType: IntegrationPrincipalType;
|
|
226
|
+
ownerId: string;
|
|
227
|
+
connectionId: string | null;
|
|
228
|
+
name: string;
|
|
229
|
+
description: string | null;
|
|
230
|
+
recipeId: string | null;
|
|
231
|
+
enabled: boolean;
|
|
232
|
+
createdAt: string;
|
|
233
|
+
updatedAt: string;
|
|
234
|
+
}
|
|
235
|
+
interface EndpointInfo {
|
|
236
|
+
id: string;
|
|
237
|
+
automationId: string | null;
|
|
238
|
+
ownerType: IntegrationPrincipalType;
|
|
239
|
+
ownerId: string;
|
|
240
|
+
connectionId: string | null;
|
|
241
|
+
url: string | null;
|
|
242
|
+
events: string[];
|
|
243
|
+
scope: IntegrationScope | null;
|
|
244
|
+
description: string | null;
|
|
245
|
+
enabled: boolean;
|
|
246
|
+
ephemeralForSandboxId: string | null;
|
|
247
|
+
consecutiveFailures: number;
|
|
248
|
+
disabledReason: string | null;
|
|
249
|
+
disabledAt: string | null;
|
|
250
|
+
createdAt: string;
|
|
251
|
+
updatedAt: string;
|
|
252
|
+
}
|
|
253
|
+
interface EndpointWithSecret extends EndpointInfo {
|
|
254
|
+
/** Returned only at create / rotate. Save it on your end. */
|
|
255
|
+
secret: string;
|
|
256
|
+
}
|
|
257
|
+
interface TriggerInfo {
|
|
258
|
+
id: string;
|
|
259
|
+
automationId: string | null;
|
|
260
|
+
ownerType: IntegrationPrincipalType;
|
|
261
|
+
ownerId: string;
|
|
262
|
+
connectionId: string | null;
|
|
263
|
+
urlToken: string;
|
|
264
|
+
/** Public URL the third party POSTs to. */
|
|
265
|
+
publicUrl: string;
|
|
266
|
+
verificationKind: IntegrationVerificationKind;
|
|
267
|
+
eventFilter: Record<string, unknown> | null;
|
|
268
|
+
action: IntegrationAction;
|
|
269
|
+
rateLimitRpm: number;
|
|
270
|
+
allowIps: string[] | null;
|
|
271
|
+
description: string | null;
|
|
272
|
+
enabled: boolean;
|
|
273
|
+
ephemeralForSandboxId: string | null;
|
|
274
|
+
createdAt: string;
|
|
275
|
+
updatedAt: string;
|
|
276
|
+
}
|
|
277
|
+
interface TriggerWithSecret extends TriggerInfo {
|
|
278
|
+
/** Returned only at create. Null when verificationKind === "none". */
|
|
279
|
+
secret: string | null;
|
|
280
|
+
}
|
|
281
|
+
interface DeliveryAttempt {
|
|
282
|
+
id: string;
|
|
283
|
+
endpointId: string;
|
|
284
|
+
automationId: string | null;
|
|
285
|
+
type: string;
|
|
286
|
+
payload: IntegrationJsonValue;
|
|
287
|
+
status: IntegrationDeliveryStatus;
|
|
288
|
+
attempts: number;
|
|
289
|
+
lastAttemptAt: string | null;
|
|
290
|
+
nextAttemptAt: string | null;
|
|
291
|
+
lastResponseStatus: number | null;
|
|
292
|
+
lastResponseBodyExcerpt: string | null;
|
|
293
|
+
createdAt: string;
|
|
294
|
+
deliveredAt: string | null;
|
|
295
|
+
}
|
|
296
|
+
interface TriggerRun {
|
|
297
|
+
id: string;
|
|
298
|
+
triggerId: string;
|
|
299
|
+
automationId: string | null;
|
|
300
|
+
requestId: string;
|
|
301
|
+
requestHeaders: Record<string, string>;
|
|
302
|
+
requestBody: string;
|
|
303
|
+
requestIp: string | null;
|
|
304
|
+
verificationStatus: "ok" | "bad_signature" | "expired" | "filtered_out" | "rate_limited";
|
|
305
|
+
actionStatus: "queued" | "running" | "succeeded" | "failed" | "rate_limited" | "skipped";
|
|
306
|
+
actionResult: Record<string, unknown> | null;
|
|
307
|
+
errorMessage: string | null;
|
|
308
|
+
createdAt: string;
|
|
309
|
+
completedAt: string | null;
|
|
310
|
+
}
|
|
311
|
+
interface RecipeManifest {
|
|
312
|
+
id: string;
|
|
313
|
+
title: string;
|
|
314
|
+
description: string;
|
|
315
|
+
icon?: string;
|
|
316
|
+
requiresConnection?: IntegrationProvider;
|
|
317
|
+
userInputs?: Array<{
|
|
318
|
+
key: string;
|
|
319
|
+
label: string;
|
|
320
|
+
type?: "text" | "select";
|
|
321
|
+
default?: string;
|
|
322
|
+
options?: string[];
|
|
323
|
+
required?: boolean;
|
|
324
|
+
}>;
|
|
325
|
+
automation: {
|
|
326
|
+
name: string;
|
|
327
|
+
description?: string;
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
interface CreateAutomationInput {
|
|
331
|
+
teamId?: string;
|
|
332
|
+
name: string;
|
|
333
|
+
description?: string;
|
|
334
|
+
connectionId?: string;
|
|
335
|
+
recipeId?: string;
|
|
336
|
+
enabled?: boolean;
|
|
337
|
+
triggers?: Array<{
|
|
338
|
+
verificationKind: IntegrationVerificationKind;
|
|
339
|
+
connectionId?: string;
|
|
340
|
+
eventFilter?: Record<string, unknown>;
|
|
341
|
+
action: IntegrationAction;
|
|
342
|
+
rateLimitRpm?: number;
|
|
343
|
+
allowIps?: string[];
|
|
344
|
+
description?: string;
|
|
345
|
+
}>;
|
|
346
|
+
endpoints?: Array<{
|
|
347
|
+
url?: string;
|
|
348
|
+
connectionId?: string;
|
|
349
|
+
events: string[];
|
|
350
|
+
scope?: IntegrationScope;
|
|
351
|
+
description?: string;
|
|
352
|
+
}>;
|
|
353
|
+
}
|
|
354
|
+
interface CreateEndpointInput {
|
|
355
|
+
teamId?: string;
|
|
356
|
+
automationId?: string;
|
|
357
|
+
connectionId?: string;
|
|
358
|
+
url?: string;
|
|
359
|
+
events: string[];
|
|
360
|
+
scope?: IntegrationScope;
|
|
361
|
+
description?: string;
|
|
362
|
+
}
|
|
363
|
+
interface CreateTriggerInput {
|
|
364
|
+
teamId?: string;
|
|
365
|
+
automationId?: string;
|
|
366
|
+
connectionId?: string;
|
|
367
|
+
verificationKind: IntegrationVerificationKind;
|
|
368
|
+
eventFilter?: Record<string, unknown>;
|
|
369
|
+
action: IntegrationAction;
|
|
370
|
+
rateLimitRpm?: number;
|
|
371
|
+
allowIps?: string[];
|
|
372
|
+
description?: string;
|
|
373
|
+
}
|
|
374
|
+
interface InstallRecipeInput {
|
|
375
|
+
teamId?: string;
|
|
376
|
+
connectionId?: string;
|
|
377
|
+
inputs?: Record<string, string>;
|
|
378
|
+
}
|
|
379
|
+
declare class IntegrationsManager {
|
|
380
|
+
private readonly client;
|
|
381
|
+
constructor(client: HttpClient);
|
|
382
|
+
readonly automations: {
|
|
383
|
+
list: (opts?: {
|
|
384
|
+
teamId?: string;
|
|
385
|
+
}) => Promise<AutomationInfo[]>;
|
|
386
|
+
get: (id: string, opts?: {
|
|
387
|
+
teamId?: string;
|
|
388
|
+
}) => Promise<{
|
|
389
|
+
automation: AutomationInfo;
|
|
390
|
+
triggers: TriggerInfo[];
|
|
391
|
+
endpoints: EndpointInfo[];
|
|
392
|
+
}>;
|
|
393
|
+
create: (input: CreateAutomationInput) => Promise<{
|
|
394
|
+
automation: AutomationInfo;
|
|
395
|
+
triggers: TriggerInfo[];
|
|
396
|
+
endpoints: EndpointInfo[];
|
|
397
|
+
}>;
|
|
398
|
+
update: (id: string, patch: {
|
|
399
|
+
teamId?: string;
|
|
400
|
+
name?: string;
|
|
401
|
+
description?: string;
|
|
402
|
+
enabled?: boolean;
|
|
403
|
+
connectionId?: string | null;
|
|
404
|
+
}) => Promise<AutomationInfo>;
|
|
405
|
+
delete: (id: string, opts?: {
|
|
406
|
+
teamId?: string;
|
|
407
|
+
}) => Promise<void>;
|
|
408
|
+
/**
|
|
409
|
+
* Unified inbound + outbound timeline for an automation.
|
|
410
|
+
* Returns the most recent N rows (default 100). Pagination is
|
|
411
|
+
* by `since` ISO8601 timestamp.
|
|
412
|
+
*/
|
|
413
|
+
logs: (id: string, opts?: {
|
|
414
|
+
teamId?: string;
|
|
415
|
+
since?: string;
|
|
416
|
+
limit?: number;
|
|
417
|
+
}) => Promise<{
|
|
418
|
+
deliveries: DeliveryAttempt[];
|
|
419
|
+
runs: TriggerRun[];
|
|
420
|
+
}>;
|
|
421
|
+
/**
|
|
422
|
+
* Install an automation from a recipe manifest. The recipe defines
|
|
423
|
+
* what gets created (one Automation, plus underlying triggers /
|
|
424
|
+
* endpoints) and which inputs the user must supply.
|
|
425
|
+
*/
|
|
426
|
+
installFromRecipe: (recipeId: string, input?: InstallRecipeInput) => Promise<{
|
|
427
|
+
automation: AutomationInfo;
|
|
428
|
+
triggers: TriggerInfo[];
|
|
429
|
+
endpoints: EndpointInfo[];
|
|
430
|
+
}>;
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Iterate all log entries for an automation, paging through
|
|
434
|
+
* deliveries+runs in 200-row batches. Use this to power export
|
|
435
|
+
* scripts or dashboards. Defined on the manager (not under
|
|
436
|
+
* .automations) because async generators can't reference an
|
|
437
|
+
* enclosing object literal's other methods through `this` cleanly.
|
|
438
|
+
*/
|
|
439
|
+
iterateAutomationLogs(id: string, opts?: {
|
|
440
|
+
teamId?: string;
|
|
441
|
+
since?: string;
|
|
442
|
+
}): AsyncGenerator<{
|
|
443
|
+
deliveries: DeliveryAttempt[];
|
|
444
|
+
runs: TriggerRun[];
|
|
445
|
+
}>;
|
|
446
|
+
readonly recipes: {
|
|
447
|
+
list: () => Promise<RecipeManifest[]>;
|
|
448
|
+
get: (id: string) => Promise<RecipeManifest>;
|
|
449
|
+
};
|
|
450
|
+
readonly connections: {
|
|
451
|
+
list: (opts?: {
|
|
452
|
+
teamId?: string;
|
|
453
|
+
}) => Promise<ConnectionInfo[]>;
|
|
454
|
+
delete: (id: string, opts?: {
|
|
455
|
+
teamId?: string;
|
|
456
|
+
}) => Promise<void>;
|
|
457
|
+
};
|
|
458
|
+
readonly endpoints: {
|
|
459
|
+
list: (opts?: {
|
|
460
|
+
teamId?: string;
|
|
461
|
+
}) => Promise<EndpointInfo[]>;
|
|
462
|
+
create: (input: CreateEndpointInput) => Promise<EndpointWithSecret>;
|
|
463
|
+
update: (id: string, patch: {
|
|
464
|
+
teamId?: string;
|
|
465
|
+
url?: string;
|
|
466
|
+
events?: string[];
|
|
467
|
+
scope?: IntegrationScope;
|
|
468
|
+
description?: string;
|
|
469
|
+
enabled?: boolean;
|
|
470
|
+
}) => Promise<EndpointInfo>;
|
|
471
|
+
delete: (id: string, opts?: {
|
|
472
|
+
teamId?: string;
|
|
473
|
+
}) => Promise<void>;
|
|
474
|
+
rotateSecret: (id: string, opts?: {
|
|
475
|
+
teamId?: string;
|
|
476
|
+
}) => Promise<EndpointWithSecret>;
|
|
477
|
+
listDeliveries: (id: string, opts?: {
|
|
478
|
+
teamId?: string;
|
|
479
|
+
since?: string;
|
|
480
|
+
status?: IntegrationDeliveryStatus;
|
|
481
|
+
limit?: number;
|
|
482
|
+
}) => Promise<DeliveryAttempt[]>;
|
|
483
|
+
};
|
|
484
|
+
readonly triggers: {
|
|
485
|
+
list: (opts?: {
|
|
486
|
+
teamId?: string;
|
|
487
|
+
}) => Promise<TriggerInfo[]>;
|
|
488
|
+
create: (input: CreateTriggerInput) => Promise<TriggerWithSecret>;
|
|
489
|
+
update: (id: string, patch: {
|
|
490
|
+
teamId?: string;
|
|
491
|
+
eventFilter?: Record<string, unknown> | null;
|
|
492
|
+
action?: IntegrationAction;
|
|
493
|
+
rateLimitRpm?: number;
|
|
494
|
+
allowIps?: string[] | null;
|
|
495
|
+
description?: string;
|
|
496
|
+
enabled?: boolean;
|
|
497
|
+
}) => Promise<TriggerInfo>;
|
|
498
|
+
delete: (id: string, opts?: {
|
|
499
|
+
teamId?: string;
|
|
500
|
+
}) => Promise<void>;
|
|
501
|
+
listRuns: (id: string, opts?: {
|
|
502
|
+
teamId?: string;
|
|
503
|
+
since?: string;
|
|
504
|
+
limit?: number;
|
|
505
|
+
}) => Promise<TriggerRun[]>;
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/client.d.ts
|
|
510
|
+
/**
|
|
511
|
+
* Client for the Tangle Sandbox platform.
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* ```typescript
|
|
515
|
+
* import { Sandbox } from "@tangle-network/sandbox";
|
|
516
|
+
*
|
|
517
|
+
* const client = new Sandbox({
|
|
518
|
+
* apiKey: "sk_sandbox_...",
|
|
519
|
+
* baseUrl: "https://your-sandbox-api.example.com",
|
|
520
|
+
* });
|
|
521
|
+
*
|
|
522
|
+
* // Create a sandbox
|
|
523
|
+
* const box = await client.create({
|
|
524
|
+
* name: "my-project",
|
|
525
|
+
* sshEnabled: true,
|
|
526
|
+
* });
|
|
527
|
+
*
|
|
528
|
+
* // Execute commands
|
|
529
|
+
* const result = await box.exec("npm install");
|
|
530
|
+
*
|
|
531
|
+
* // Clean up
|
|
532
|
+
* await box.delete();
|
|
533
|
+
* ```
|
|
534
|
+
*/
|
|
535
|
+
declare class SandboxClient implements HttpClient {
|
|
536
|
+
private readonly baseUrl;
|
|
537
|
+
private readonly apiKey;
|
|
538
|
+
private readonly timeoutMs;
|
|
539
|
+
private readonly trustLocalCliAuth;
|
|
540
|
+
private _secrets;
|
|
541
|
+
private _sshKeys;
|
|
542
|
+
private _integrations;
|
|
543
|
+
private _fleets;
|
|
544
|
+
private _intelligence;
|
|
545
|
+
constructor(config: SandboxClientConfig);
|
|
546
|
+
/**
|
|
547
|
+
* Fleet operations for agent-managed groups of sandboxes.
|
|
548
|
+
*
|
|
549
|
+
* Fleets are an SDK-level convenience over the existing sandbox lifecycle
|
|
550
|
+
* API. Each worker is a normal sandbox tagged with stable fleet metadata,
|
|
551
|
+
* so older clients and dashboards can still inspect and delete them.
|
|
552
|
+
*/
|
|
553
|
+
get fleets(): SandboxFleetClient;
|
|
554
|
+
get intelligence(): IntelligenceClient;
|
|
555
|
+
getApiKey(): string;
|
|
556
|
+
/**
|
|
557
|
+
* Access the secrets manager for storing and retrieving encrypted secrets.
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* ```typescript
|
|
561
|
+
* // Create a secret
|
|
562
|
+
* await client.secrets.create("HF_TOKEN", "hf_xxx");
|
|
563
|
+
*
|
|
564
|
+
* // List secrets (names only)
|
|
565
|
+
* const secrets = await client.secrets.list();
|
|
566
|
+
*
|
|
567
|
+
* // Get secret value
|
|
568
|
+
* const value = await client.secrets.get("HF_TOKEN");
|
|
569
|
+
*
|
|
570
|
+
* // Update secret
|
|
571
|
+
* await client.secrets.update("HF_TOKEN", "hf_new_value");
|
|
572
|
+
*
|
|
573
|
+
* // Delete secret
|
|
574
|
+
* await client.secrets.delete("HF_TOKEN");
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
get secrets(): SecretsManager;
|
|
578
|
+
get sshKeys(): SshKeysManager;
|
|
579
|
+
/**
|
|
580
|
+
* Access the integrations manager — webhooks (inbound + outbound),
|
|
581
|
+
* automations, connections to managed connectors, and recipes.
|
|
582
|
+
*
|
|
583
|
+
* Spec: specs/sandbox-integrations.md.
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```typescript
|
|
587
|
+
* // Outbound: get pinged when a sandbox fails
|
|
588
|
+
* const ep = await client.integrations.endpoints.create({
|
|
589
|
+
* url: "https://example.com/hook",
|
|
590
|
+
* events: ["sandbox.failed", "sandbox.permanently_dead"],
|
|
591
|
+
* });
|
|
592
|
+
* console.log(ep.secret); // shown once — store it
|
|
593
|
+
*
|
|
594
|
+
* // Inbound: a public URL that, when POSTed to, runs an action
|
|
595
|
+
* const trg = await client.integrations.triggers.create({
|
|
596
|
+
* verificationKind: "hmac_shared_secret",
|
|
597
|
+
* action: {
|
|
598
|
+
* kind: "sandbox.create",
|
|
599
|
+
* config: { template: "node-22", prompt: "Run: ${body.prompt}" },
|
|
600
|
+
* },
|
|
601
|
+
* });
|
|
602
|
+
* console.log(trg.publicUrl);
|
|
603
|
+
*
|
|
604
|
+
* // One-click recipe install
|
|
605
|
+
* const auto = await client.integrations.automations.installFromRecipe(
|
|
606
|
+
* "github.pr-review",
|
|
607
|
+
* { connectionId: "ic_…", inputs: { template: "node-22" } },
|
|
608
|
+
* );
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
get integrations(): IntegrationsManager;
|
|
612
|
+
private _environments;
|
|
613
|
+
/**
|
|
614
|
+
* Access available development environments.
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```typescript
|
|
618
|
+
* const envs = await client.environments.list();
|
|
619
|
+
* // → [{ id: "universal", description: "Universal environment with all toolchains via Nix", ... }]
|
|
620
|
+
*
|
|
621
|
+
* const sandbox = await client.create({ environment: "universal" });
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
get environments(): EnvironmentsClient;
|
|
625
|
+
private _teams;
|
|
626
|
+
private _publicTemplates;
|
|
627
|
+
/**
|
|
628
|
+
* Access team management (collaboration groups, invitations,
|
|
629
|
+
* member roles). Teams scope shared sandboxes — pass `teamId` to
|
|
630
|
+
* `client.create()` to create a sandbox accessible to a team's
|
|
631
|
+
* members.
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* const teams = await client.teams.list();
|
|
636
|
+
* const invite = await client.teams.invite(teams[0].id, {
|
|
637
|
+
* email: "alice@example.com",
|
|
638
|
+
* role: "member",
|
|
639
|
+
* });
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
get teams(): TeamsClient;
|
|
643
|
+
get publicTemplates(): PublicTemplatesClient;
|
|
644
|
+
/**
|
|
645
|
+
* Create a new sandbox.
|
|
646
|
+
*
|
|
647
|
+
* @param options - Configuration for the new sandbox
|
|
648
|
+
* @returns A SandboxInstance representing the created sandbox
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* ```typescript
|
|
652
|
+
* const box = await client.create({
|
|
653
|
+
* name: "my-project",
|
|
654
|
+
* environment: "universal",
|
|
655
|
+
* sshEnabled: true,
|
|
656
|
+
* env: { NODE_ENV: "development" },
|
|
657
|
+
* });
|
|
658
|
+
* ```
|
|
659
|
+
*/
|
|
660
|
+
create(options?: CreateSandboxOptions): Promise<SandboxInstance>;
|
|
661
|
+
/**
|
|
662
|
+
* List all sandboxes.
|
|
663
|
+
*
|
|
664
|
+
* @param options - Filtering and pagination options
|
|
665
|
+
* @returns Array of SandboxInstance objects
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* ```typescript
|
|
669
|
+
* // List all running sandboxes
|
|
670
|
+
* const running = await client.list({ status: "running" });
|
|
671
|
+
*
|
|
672
|
+
* // List with pagination
|
|
673
|
+
* const page = await client.list({ limit: 10, offset: 0 });
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
676
|
+
list(options?: ListSandboxOptions): Promise<SandboxInstance[]>;
|
|
677
|
+
/**
|
|
678
|
+
* Get a sandbox by ID.
|
|
679
|
+
*
|
|
680
|
+
* @param id - The sandbox ID
|
|
681
|
+
* @returns A SandboxInstance or null if not found
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```typescript
|
|
685
|
+
* const box = await client.get("sandbox_abc123");
|
|
686
|
+
* if (box) {
|
|
687
|
+
* console.log(box.status);
|
|
688
|
+
* }
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
get(id: string): Promise<SandboxInstance | null>;
|
|
692
|
+
/**
|
|
693
|
+
* Get usage information for the account.
|
|
694
|
+
*
|
|
695
|
+
* @returns Usage statistics for the current billing period
|
|
696
|
+
*
|
|
697
|
+
* @example
|
|
698
|
+
* ```typescript
|
|
699
|
+
* const usage = await client.usage();
|
|
700
|
+
* console.log(`Active sandboxes: ${usage.activeSandboxes}`);
|
|
701
|
+
* console.log(`Compute minutes: ${usage.computeMinutes}`);
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
704
|
+
usage(): Promise<UsageInfo>;
|
|
705
|
+
/**
|
|
706
|
+
* Get subscription and billing information for the account.
|
|
707
|
+
*
|
|
708
|
+
* @returns Subscription details including plan, credits, and limits
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* ```typescript
|
|
712
|
+
* const sub = await client.subscription();
|
|
713
|
+
* console.log(`Plan: ${sub.plan}`);
|
|
714
|
+
* console.log(`Credits: $${sub.creditsAvailableUsd.toFixed(2)}`);
|
|
715
|
+
* ```
|
|
716
|
+
*/
|
|
717
|
+
subscription(): Promise<SubscriptionInfo>;
|
|
718
|
+
/**
|
|
719
|
+
* Check if the Sandbox API is available.
|
|
720
|
+
*
|
|
721
|
+
* @returns true if the API is healthy, false otherwise
|
|
722
|
+
*/
|
|
723
|
+
health(): Promise<boolean>;
|
|
724
|
+
/**
|
|
725
|
+
* Check if CRIU checkpointing is available on the platform.
|
|
726
|
+
*
|
|
727
|
+
* CRIU enables memory preservation for true pause/resume and fork operations.
|
|
728
|
+
* It requires specific host configuration.
|
|
729
|
+
*
|
|
730
|
+
* @returns CRIU availability status
|
|
731
|
+
*
|
|
732
|
+
* @example
|
|
733
|
+
* ```typescript
|
|
734
|
+
* const status = await client.criuStatus();
|
|
735
|
+
* if (status.available) {
|
|
736
|
+
* console.log(`CRIU ${status.criuVersion} available`);
|
|
737
|
+
* } else {
|
|
738
|
+
* console.log(`CRIU not available: ${status.reason}`);
|
|
739
|
+
* }
|
|
740
|
+
* ```
|
|
741
|
+
*/
|
|
742
|
+
criuStatus(): Promise<{
|
|
743
|
+
available: boolean;
|
|
744
|
+
criuVersion?: string;
|
|
745
|
+
reason?: string;
|
|
746
|
+
requirements?: {
|
|
747
|
+
kernel: boolean;
|
|
748
|
+
criu: boolean;
|
|
749
|
+
storageDriver: boolean;
|
|
750
|
+
experimental: boolean;
|
|
751
|
+
};
|
|
752
|
+
}>;
|
|
753
|
+
/**
|
|
754
|
+
* Run multiple tasks in parallel across sandboxes.
|
|
755
|
+
* Returns the aggregated results after all tasks complete.
|
|
756
|
+
*
|
|
757
|
+
* @param tasks - Array of tasks to execute
|
|
758
|
+
* @param options - Batch execution options
|
|
759
|
+
* @returns Aggregated batch results
|
|
760
|
+
*
|
|
761
|
+
* @throws {@link TimeoutError} if the server hasn't begun responding
|
|
762
|
+
* before the deadline (pre-stream timeout).
|
|
763
|
+
* @throws {@link ValidationError} / {@link QuotaError} / other typed
|
|
764
|
+
* SDK errors if the server rejects the request before streaming.
|
|
765
|
+
* @throws `DOMException` with `name === "AbortError"` if
|
|
766
|
+
* `options.signal` fires OR the safety-valve deadline fires
|
|
767
|
+
* AFTER streaming has begun — parseSSEStream can't distinguish
|
|
768
|
+
* the source mid-stream. Callers that need to tell cancel from
|
|
769
|
+
* timeout should check `options.signal?.aborted` in their catch.
|
|
770
|
+
* @throws `Error` with the server message if the stream emits a
|
|
771
|
+
* `batch.failed` event.
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
* ```typescript
|
|
775
|
+
* const result = await client.runBatch([
|
|
776
|
+
* { id: "task-1", message: "Analyze this file" },
|
|
777
|
+
* { id: "task-2", message: "Generate a summary" },
|
|
778
|
+
* ]);
|
|
779
|
+
* console.log(`Success rate: ${result.successRate}%`);
|
|
780
|
+
* ```
|
|
781
|
+
*/
|
|
782
|
+
runBatch(tasks: BatchTask[], options?: BatchOptions): Promise<BatchResult>;
|
|
783
|
+
/**
|
|
784
|
+
* Stream events from a batch execution.
|
|
785
|
+
* Use this for real-time progress updates during batch processing.
|
|
786
|
+
*
|
|
787
|
+
* @param tasks - Array of tasks to execute
|
|
788
|
+
* @param options - Batch execution options
|
|
789
|
+
*
|
|
790
|
+
* @throws {@link TimeoutError} if the server hasn't begun responding
|
|
791
|
+
* before the deadline (pre-stream timeout).
|
|
792
|
+
* @throws {@link ValidationError} / {@link QuotaError} / other typed
|
|
793
|
+
* SDK errors if the server rejects the request before streaming.
|
|
794
|
+
* @throws `DOMException` with `name === "AbortError"` if
|
|
795
|
+
* `options.signal` fires OR the safety-valve deadline fires
|
|
796
|
+
* AFTER streaming has begun. Distinguish via
|
|
797
|
+
* `options.signal?.aborted` in the consumer's catch.
|
|
798
|
+
*
|
|
799
|
+
* @example
|
|
800
|
+
* ```typescript
|
|
801
|
+
* for await (const event of client.streamBatch(tasks)) {
|
|
802
|
+
* if (event.type === "task.completed") {
|
|
803
|
+
* console.log(`Task ${event.data.taskId} completed`);
|
|
804
|
+
* }
|
|
805
|
+
* }
|
|
806
|
+
* ```
|
|
807
|
+
*/
|
|
808
|
+
streamBatch(tasks: BatchTask[], options?: BatchOptions): AsyncGenerator<BatchEvent>;
|
|
809
|
+
/**
|
|
810
|
+
* Make an authenticated HTTP request to the API.
|
|
811
|
+
* This is exposed for use by SandboxInstance.
|
|
812
|
+
*/
|
|
813
|
+
fetch(path: string, options?: RequestInit): Promise<Response>;
|
|
814
|
+
private parseInfo;
|
|
815
|
+
private readonly _tokenRefreshHandlers;
|
|
816
|
+
/**
|
|
817
|
+
* Register a handler invoked when the SDK transparently refreshes a
|
|
818
|
+
* sandbox bearer after a 401 retry. Returns a function that
|
|
819
|
+
* unregisters the handler when called.
|
|
820
|
+
*/
|
|
821
|
+
onTokenRefresh(handler: TokenRefreshHandler): () => void;
|
|
822
|
+
/** @internal — fired by the runtime-fetch retry path after a successful
|
|
823
|
+
* refresh. Errors thrown by handlers are caught and surfaced as
|
|
824
|
+
* console warnings so one bad subscriber does not poison the rest. */
|
|
825
|
+
_emitTokenRefresh(sandboxId: string, newToken: string): void;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Client for the Intelligence Reports API.
|
|
829
|
+
*
|
|
830
|
+
* Two analysis modes:
|
|
831
|
+
*
|
|
832
|
+
* - `deterministic` (default): free, rule-based platform analysis over
|
|
833
|
+
* the subject's trace evidence. Returns immediately.
|
|
834
|
+
* - `agentic`: routes to the **Tangle Trace Analyst**, an LLM-driven
|
|
835
|
+
* reasoning loop that reads OTLP-shaped trace evidence and emits
|
|
836
|
+
* findings, evidence references, recommended actions, and a
|
|
837
|
+
* validation plan. Billed against `budget.maxUsd`; the platform
|
|
838
|
+
* never spends past the budget the caller sets.
|
|
839
|
+
*
|
|
840
|
+
* Subjects: `sandbox` or `fleet`. A fleet subject can be narrowed to
|
|
841
|
+
* a single coordinated command via `subject.dispatchId`.
|
|
842
|
+
*/
|
|
843
|
+
declare class IntelligenceClient {
|
|
844
|
+
private readonly client;
|
|
845
|
+
constructor(client: SandboxClient);
|
|
846
|
+
/**
|
|
847
|
+
* Create an intelligence report over the given subject.
|
|
848
|
+
*
|
|
849
|
+
* Use `mode: "agentic"` to engage the **Tangle Trace Analyst** with a
|
|
850
|
+
* spending budget. The budget is enforced server-side before billing
|
|
851
|
+
* fires — a request whose computed cost exceeds `budget.maxUsd`
|
|
852
|
+
* returns 402 without charging the customer.
|
|
853
|
+
*/
|
|
854
|
+
createReport(options: CreateIntelligenceReportOptions): Promise<IntelligenceReport>;
|
|
855
|
+
createAgenticReport(options: {
|
|
856
|
+
subject: CreateIntelligenceReportOptions["subject"];
|
|
857
|
+
maxUsd: number;
|
|
858
|
+
metadata?: Record<string, unknown>;
|
|
859
|
+
}): Promise<IntelligenceReport>;
|
|
860
|
+
/**
|
|
861
|
+
* Estimate the cost of a prospective report without creating one.
|
|
862
|
+
* Verifies subject ownership the same way `createReport` does, so it
|
|
863
|
+
* never becomes an existence oracle for foreign subjects.
|
|
864
|
+
*/
|
|
865
|
+
estimateReport(options: Pick<CreateIntelligenceReportOptions, "subject"> & {
|
|
866
|
+
mode?: "deterministic" | "agentic";
|
|
867
|
+
metadata?: Record<string, unknown>;
|
|
868
|
+
}): Promise<{
|
|
869
|
+
mode: "deterministic" | "agentic";
|
|
870
|
+
costUsd: number;
|
|
871
|
+
billable: boolean;
|
|
872
|
+
billedTo: "platform" | "customer";
|
|
873
|
+
reason: string;
|
|
874
|
+
}>;
|
|
875
|
+
getReport(jobId: string): Promise<IntelligenceReport>;
|
|
876
|
+
listReports(options?: {
|
|
877
|
+
subjectType?: CreateIntelligenceReportOptions["subject"]["type"];
|
|
878
|
+
subjectId?: string;
|
|
879
|
+
limit?: number;
|
|
880
|
+
}): Promise<IntelligenceReport[]>;
|
|
881
|
+
waitForReport(jobId: string, options?: {
|
|
882
|
+
timeoutMs?: number;
|
|
883
|
+
pollMs?: number;
|
|
884
|
+
}): Promise<IntelligenceReport>;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Client for browsing available development environments.
|
|
888
|
+
*/
|
|
889
|
+
declare class EnvironmentsClient {
|
|
890
|
+
private readonly client;
|
|
891
|
+
constructor(client: SandboxClient);
|
|
892
|
+
/**
|
|
893
|
+
* List available development environments.
|
|
894
|
+
*
|
|
895
|
+
* @returns Array of available environments with metadata
|
|
896
|
+
*
|
|
897
|
+
* @example
|
|
898
|
+
* ```typescript
|
|
899
|
+
* const envs = await client.environments.list();
|
|
900
|
+
* for (const env of envs) {
|
|
901
|
+
* console.log(`${env.id}: ${env.description}`);
|
|
902
|
+
* }
|
|
903
|
+
* ```
|
|
904
|
+
*/
|
|
905
|
+
list(): Promise<SandboxEnvironment[]>;
|
|
906
|
+
/**
|
|
907
|
+
* Get details for a specific environment.
|
|
908
|
+
*
|
|
909
|
+
* @param id - Environment identifier (e.g., "universal")
|
|
910
|
+
*/
|
|
911
|
+
get(id: string): Promise<SandboxEnvironment | null>;
|
|
912
|
+
}
|
|
913
|
+
declare class PublicTemplatesClient {
|
|
914
|
+
private readonly client;
|
|
915
|
+
constructor(client: SandboxClient);
|
|
916
|
+
list(options?: {
|
|
917
|
+
query?: string;
|
|
918
|
+
tag?: string;
|
|
919
|
+
featuredOnly?: boolean;
|
|
920
|
+
limit?: number;
|
|
921
|
+
offset?: number;
|
|
922
|
+
}): Promise<PublicTemplateInfo[]>;
|
|
923
|
+
featured(): Promise<PublicTemplateInfo[]>;
|
|
924
|
+
get(idOrSlug: string): Promise<PublicTemplateInfo>;
|
|
925
|
+
versions(idOrSlug: string): Promise<PublicTemplateVersionInfo[]>;
|
|
926
|
+
publish(options: PublishPublicTemplateOptions): Promise<PublicTemplateInfo>;
|
|
927
|
+
publishVersion(idOrSlug: string, options: PublishPublicTemplateVersionOptions): Promise<PublicTemplateVersionInfo>;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Team (collaboration group) record as returned from the API.
|
|
931
|
+
*/
|
|
932
|
+
interface Team {
|
|
933
|
+
id: string;
|
|
934
|
+
name: string;
|
|
935
|
+
ownerCustomerId: string;
|
|
936
|
+
orgId: string | null;
|
|
937
|
+
memberCount: number;
|
|
938
|
+
currentUserRole: "owner" | "admin" | "member" | "viewer";
|
|
939
|
+
createdAt: string;
|
|
940
|
+
updatedAt: string;
|
|
941
|
+
}
|
|
942
|
+
interface TeamMember {
|
|
943
|
+
id: string;
|
|
944
|
+
teamId: string;
|
|
945
|
+
customerId: string;
|
|
946
|
+
customerEmail: string;
|
|
947
|
+
customerName: string | null;
|
|
948
|
+
role: "owner" | "admin" | "member" | "viewer";
|
|
949
|
+
status: "active" | "pending" | "removed";
|
|
950
|
+
joinedAt: string | null;
|
|
951
|
+
createdAt: string;
|
|
952
|
+
}
|
|
953
|
+
interface TeamInvitation {
|
|
954
|
+
id: string;
|
|
955
|
+
teamId: string;
|
|
956
|
+
email: string;
|
|
957
|
+
invitedBy: string;
|
|
958
|
+
invitedByEmail: string | null;
|
|
959
|
+
role: "admin" | "member" | "viewer";
|
|
960
|
+
token: string;
|
|
961
|
+
status: "pending" | "accepted" | "expired" | "revoked";
|
|
962
|
+
expiresAt: string;
|
|
963
|
+
createdAt: string;
|
|
964
|
+
}
|
|
965
|
+
interface TeamInvitationPreview {
|
|
966
|
+
email: string;
|
|
967
|
+
role: "admin" | "member" | "viewer";
|
|
968
|
+
status: "pending" | "accepted" | "expired" | "revoked";
|
|
969
|
+
expiresAt: string;
|
|
970
|
+
teamName: string;
|
|
971
|
+
invitedByEmail: string | null;
|
|
972
|
+
}
|
|
973
|
+
interface TeamSecretRecord {
|
|
974
|
+
name: string;
|
|
975
|
+
updatedAt: string;
|
|
976
|
+
updatedBy: string;
|
|
977
|
+
}
|
|
978
|
+
interface TeamTemplateRecord {
|
|
979
|
+
id: string;
|
|
980
|
+
name: string;
|
|
981
|
+
description: string;
|
|
982
|
+
snapshotId: string;
|
|
983
|
+
environment: string;
|
|
984
|
+
config: Record<string, unknown>;
|
|
985
|
+
teamId: string | null;
|
|
986
|
+
createdAt: string;
|
|
987
|
+
updatedAt: string;
|
|
988
|
+
}
|
|
989
|
+
interface CreateTeamTemplateOptions {
|
|
990
|
+
name: string;
|
|
991
|
+
snapshotId: string;
|
|
992
|
+
description?: string;
|
|
993
|
+
environment?: string;
|
|
994
|
+
config?: Record<string, unknown>;
|
|
995
|
+
}
|
|
996
|
+
interface CreateTeamOptions {
|
|
997
|
+
name: string;
|
|
998
|
+
orgId?: string;
|
|
999
|
+
}
|
|
1000
|
+
interface InviteTeamMemberOptions {
|
|
1001
|
+
email: string;
|
|
1002
|
+
role: "admin" | "member" | "viewer";
|
|
1003
|
+
/** Lifetime of the invitation in hours (default 168 = 7 days). */
|
|
1004
|
+
ttlHours?: number;
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Client for managing teams and team-scoped sharing.
|
|
1008
|
+
*
|
|
1009
|
+
* Team resources are scoped to the authenticated user's membership —
|
|
1010
|
+
* the client never needs to pass an org id explicitly.
|
|
1011
|
+
*/
|
|
1012
|
+
declare class TeamsClient {
|
|
1013
|
+
private readonly client;
|
|
1014
|
+
constructor(client: SandboxClient);
|
|
1015
|
+
list(): Promise<Team[]>;
|
|
1016
|
+
create(options: CreateTeamOptions): Promise<Team>;
|
|
1017
|
+
get(teamId: string): Promise<Team>;
|
|
1018
|
+
update(teamId: string, updates: {
|
|
1019
|
+
name?: string;
|
|
1020
|
+
}): Promise<Team>;
|
|
1021
|
+
delete(teamId: string): Promise<void>;
|
|
1022
|
+
leave(teamId: string): Promise<void>;
|
|
1023
|
+
transferOwnership(teamId: string, newOwnerCustomerId: string): Promise<void>;
|
|
1024
|
+
listMembers(teamId: string): Promise<TeamMember[]>;
|
|
1025
|
+
updateMember(teamId: string, memberId: string, updates: {
|
|
1026
|
+
role?: "admin" | "member" | "viewer";
|
|
1027
|
+
status?: "active" | "removed";
|
|
1028
|
+
}): Promise<TeamMember>;
|
|
1029
|
+
removeMember(teamId: string, memberId: string): Promise<void>;
|
|
1030
|
+
listInvitations(teamId: string): Promise<TeamInvitation[]>;
|
|
1031
|
+
invite(teamId: string, options: InviteTeamMemberOptions): Promise<TeamInvitation>;
|
|
1032
|
+
revokeInvitation(invitationId: string): Promise<void>;
|
|
1033
|
+
acceptInvitation(token: string): Promise<TeamMember>;
|
|
1034
|
+
getInvitation(token: string): Promise<TeamInvitationPreview>;
|
|
1035
|
+
listSecrets(teamId: string): Promise<TeamSecretRecord[]>;
|
|
1036
|
+
upsertSecret(teamId: string, name: string, value: string): Promise<TeamSecretRecord>;
|
|
1037
|
+
deleteSecret(teamId: string, name: string): Promise<void>;
|
|
1038
|
+
revealSecret(teamId: string, name: string): Promise<{
|
|
1039
|
+
name: string;
|
|
1040
|
+
value: string;
|
|
1041
|
+
}>;
|
|
1042
|
+
listTemplates(teamId: string): Promise<TeamTemplateRecord[]>;
|
|
1043
|
+
createTemplate(teamId: string, options: CreateTeamTemplateOptions): Promise<TeamTemplateRecord>;
|
|
1044
|
+
deleteTemplate(teamId: string, templateId: string): Promise<void>;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Alias for SandboxClient for cleaner imports.
|
|
1048
|
+
*/
|
|
1049
|
+
//#endregion
|
|
1050
|
+
export { SandboxFleetClient as A, IntegrationVerificationKind as C, TriggerRun as D, TriggerInfo as E, ParsedSSEEvent as M, parseSSEStream as N, TriggerWithSecret as O, IntegrationScope as S, RecipeManifest as T, IntegrationAction as _, Team as a, IntegrationPrincipalType as b, AutomationInfo as c, CreateEndpointInput as d, CreateTriggerInput as f, InstallRecipeInput as g, EndpointWithSecret as h, SandboxClient as i, ParseSSEStreamOptions as j, SandboxFleet as k, ConnectionInfo as l, EndpointInfo as m, IntelligenceClient as n, TeamInvitation as o, DeliveryAttempt as p, InviteTeamMemberOptions as r, TeamMember as s, CreateTeamOptions as t, CreateAutomationInput as u, IntegrationActionKind as v, IntegrationsManager as w, IntegrationProvider as x, IntegrationDeliveryStatus as y };
|