@tangle-network/sandbox 0.11.1 → 0.12.0-develop.20260724231304.911a687
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 +94 -16
- package/dist/agent/index.d.ts +3 -3
- package/dist/{client-D_67csnK.js → client-C_O7PFjl.js} +110 -19
- package/dist/{client-DBioX_CL.d.ts → client-CvZ4UdOC.d.ts} +9 -2
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-DDnuTcZd.js → collaboration-DdD_rFZQ.js} +1 -1
- package/dist/core.d.ts +5 -5
- package/dist/core.js +4 -4
- package/dist/{errors-ntvaf0_F.d.ts → errors-C8HMx78o.d.ts} +2 -2
- package/dist/{errors-Cbs78OlF.js → errors-D9fFOWX9.js} +12 -8
- package/dist/{index-Dj8LzvId.d.ts → index-BZgbJerm.d.ts} +2 -2
- package/dist/index.d.ts +24 -6
- package/dist/index.js +8 -8
- package/dist/intelligence/index.js +1 -1
- package/dist/{runtime-api-kukaWPtF.js → runtime-api-XhAv6YiH.js} +12 -5
- package/dist/runtime.d.ts +3 -2
- package/dist/runtime.js +2 -2
- package/dist/{sandbox-DaLPTCRA.js → sandbox-D77F7Yja.js} +988 -58
- package/dist/{sandbox-BRoxCvpS.d.ts → sandbox-Y-2JtJdp.d.ts} +275 -32
- package/dist/session-gateway/index.d.ts +77 -20
- package/dist/session-gateway/index.js +332 -156
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-DHOkbr5a.js → tangle-DpxmcNGp.js} +71 -22
- package/dist/{types-D2C72ySk.d.ts → types-BBocO2Ht.d.ts} +621 -182
- package/package.json +9 -6
|
@@ -1,5 +1,379 @@
|
|
|
1
|
-
import { AgentProfile, AgentProfileCapabilities, AgentProfileConfidential, AgentProfileConnection, AgentProfileFileMount, AgentProfileMcpServer, AgentProfileModelHints, AgentProfilePermissionValue, AgentProfilePrompt, AgentProfileResourceRef, AgentProfileResources, AgentProfileValidationIssue, AgentProfileValidationResult, AgentSubagentProfile, defineAgentProfile, defineGitHubResource, defineInlineResource, mergeAgentProfiles } from "@tangle-network/agent-interface";
|
|
1
|
+
import { AgentProfile as AgentProfile$1, AgentProfileCapabilities, AgentProfileConfidential, AgentProfileConnection, AgentProfileFileMount, AgentProfileMcpServer, AgentProfileModelHints, AgentProfilePermissionValue, AgentProfilePrompt, AgentProfileResourceRef, AgentProfileResources, AgentProfileSecurityPolicy, AgentProfileValidationIssue, AgentProfileValidationResult, AgentSubagentProfile, Capability, agentProfileSchema, capabilitySchema, defineAgentProfile, defineGitHubResource, defineInlineResource, mergeAgentProfiles, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
2
2
|
|
|
3
|
+
//#region src/terminal-stream.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* TerminalStream — typed client for the sandbox terminal WebSocket protocol.
|
|
6
|
+
*
|
|
7
|
+
* Drives a live PTY session (an interactive harness TUI or a plain shell)
|
|
8
|
+
* from the caller's own program: binary frames stream raw PTY output bytes,
|
|
9
|
+
* TEXT JSON frames carry the control protocol. The wire contract is defined
|
|
10
|
+
* by the sidecar in `apps/sidecar/src/terminal/websocket-protocol.ts` (the
|
|
11
|
+
* source of truth for these message shapes — its zod schemas cannot be
|
|
12
|
+
* imported here without pulling sidecar dependencies into the SDK bundle,
|
|
13
|
+
* so the types are mirrored locally):
|
|
14
|
+
*
|
|
15
|
+
* client → server (TEXT JSON):
|
|
16
|
+
* init {connectionId?, cols, rows, command?, cwd?, env?} — MUST be first
|
|
17
|
+
* input {data}
|
|
18
|
+
* resize {cols, rows}
|
|
19
|
+
* server → client (TEXT JSON):
|
|
20
|
+
* ready {connectionId, sessionId, restored, detachTimeoutMs}
|
|
21
|
+
* exit {exitCode?, exitSignal?}
|
|
22
|
+
* error {code, message}
|
|
23
|
+
* rec / rec.done — recording tee frames for the platform's session
|
|
24
|
+
* capture consumer; not part of the client surface
|
|
25
|
+
* server → client (BINARY): raw PTY output bytes
|
|
26
|
+
*
|
|
27
|
+
* Detach/reconnect: the server keeps the PTY alive for `detachTimeoutMs`
|
|
28
|
+
* (5 minutes today) after the socket closes; re-dialing with the SAME
|
|
29
|
+
* connectionId reattaches and replays the buffered output history, so a
|
|
30
|
+
* fresh client repaints the current screen.
|
|
31
|
+
*
|
|
32
|
+
* Browser-safe: uses the global `WebSocket` (browsers, Workers, Node >= 22)
|
|
33
|
+
* and never imports `ws` — the same environment contract as
|
|
34
|
+
* `session-gateway/client.ts`.
|
|
35
|
+
*/
|
|
36
|
+
/** Ready acknowledgement — the PTY is attached and history replay follows. */
|
|
37
|
+
interface TerminalReadyInfo {
|
|
38
|
+
connectionId: string;
|
|
39
|
+
sessionId: string;
|
|
40
|
+
/** True when an existing PTY was reattached (its history is replayed). */
|
|
41
|
+
restored: boolean;
|
|
42
|
+
/** How long (ms) the server keeps the PTY alive after this socket closes. */
|
|
43
|
+
detachTimeoutMs: number;
|
|
44
|
+
}
|
|
45
|
+
/** Terminal process exit notification. */
|
|
46
|
+
interface TerminalExitInfo {
|
|
47
|
+
exitCode?: number;
|
|
48
|
+
exitSignal?: string;
|
|
49
|
+
}
|
|
50
|
+
/** A protocol `error` control frame or a transport failure. */
|
|
51
|
+
declare class TerminalStreamError extends Error {
|
|
52
|
+
/** Protocol error code (e.g. `INIT_FAILED`) or `TRANSPORT` for socket faults. */
|
|
53
|
+
readonly code: string;
|
|
54
|
+
constructor(message: string, code: string);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Event callbacks, passed at construction (the same idiom as
|
|
58
|
+
* `SessionGatewayClient`'s `handlers` config). Registering them up front is
|
|
59
|
+
* load-bearing: the server replays PTY history immediately after `ready`, so
|
|
60
|
+
* a handler attached after connect would miss the replayed screen.
|
|
61
|
+
*/
|
|
62
|
+
interface TerminalStreamHandlers {
|
|
63
|
+
/** Raw PTY output bytes (both live output and reattach history replay). */
|
|
64
|
+
onData?: (data: Uint8Array) => void;
|
|
65
|
+
onReady?: (info: TerminalReadyInfo) => void;
|
|
66
|
+
onExit?: (info: TerminalExitInfo) => void;
|
|
67
|
+
/** Protocol `error` frames and post-connect transport failures. */
|
|
68
|
+
onError?: (error: TerminalStreamError) => void;
|
|
69
|
+
/** Socket closed — by the server, the network, or a local `close()`. */
|
|
70
|
+
onClose?: (code: number, reason: string) => void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Which WebSocket-subprotocol auth envelope to offer. A WebSocket client
|
|
74
|
+
* cannot set an Authorization header, so the bearer rides the
|
|
75
|
+
* `Sec-WebSocket-Protocol` offer — and the two dialable endpoints expect
|
|
76
|
+
* DIFFERENT envelopes:
|
|
77
|
+
*
|
|
78
|
+
* - `"edge"` (default): the public API proxy
|
|
79
|
+
* (`wss://<api>/v1/sidecar-proxy/{sidecarId}/terminals/{id}/ws`) expects
|
|
80
|
+
* `bearer.<base64url(token)>` — see `parseTerminalWsSubprotocolToken` in
|
|
81
|
+
* `products/sandbox/api/src/lib/terminal-websocket.ts`. The fixed
|
|
82
|
+
* `tangle.terminal.v1` marker is offered alongside the credential (see
|
|
83
|
+
* {@link TERMINAL_WS_ECHO_SUBPROTOCOL}).
|
|
84
|
+
* - `"sidecar-direct"`: the sidecar's own `/terminals/{id}/ws` route expects
|
|
85
|
+
* `tangle.bearer.<token>` plus the same `tangle.terminal.v1` echo marker —
|
|
86
|
+
* see `apps/sidecar/src/routes/ws-subprotocol-auth.ts`. Only
|
|
87
|
+
* platform-internal callers (and the composed integration tests) dial the
|
|
88
|
+
* sidecar directly.
|
|
89
|
+
*/
|
|
90
|
+
type TerminalStreamAuthFormat = "edge" | "sidecar-direct";
|
|
91
|
+
/**
|
|
92
|
+
* Bearer credential for the dial: a token string, or a provider invoked on
|
|
93
|
+
* EVERY dial (including {@link TerminalStream.reconnect}). Scoped terminal
|
|
94
|
+
* tokens are short-lived (the platform clamps them to <= 15 minutes), so a
|
|
95
|
+
* reconnect after the detach window with the original string would be
|
|
96
|
+
* rejected — a provider lets the SDK re-mint a fresh token per dial.
|
|
97
|
+
*/
|
|
98
|
+
type TerminalStreamToken = string | (() => Promise<string> | string);
|
|
99
|
+
interface TerminalStreamOptions {
|
|
100
|
+
/**
|
|
101
|
+
* Absolute URL of the terminal WebSocket endpoint. `http(s)` URLs are
|
|
102
|
+
* converted to `ws(s)` automatically.
|
|
103
|
+
*/
|
|
104
|
+
url: string;
|
|
105
|
+
/**
|
|
106
|
+
* Bearer token carried in the auth subprotocol (see `authFormat`) — a
|
|
107
|
+
* string, or a provider re-invoked on every dial so short-lived scoped
|
|
108
|
+
* tokens stay fresh across reconnects.
|
|
109
|
+
*/
|
|
110
|
+
token: TerminalStreamToken;
|
|
111
|
+
/**
|
|
112
|
+
* PTY connection id — also sent in the `init` frame; the server rejects a
|
|
113
|
+
* mismatch with the URL's id. Reusing an id reattaches the existing PTY.
|
|
114
|
+
*/
|
|
115
|
+
connectionId: string;
|
|
116
|
+
cols?: number;
|
|
117
|
+
rows?: number;
|
|
118
|
+
/** Command to run when the id has no live PTY (defaults to the shell). */
|
|
119
|
+
command?: string;
|
|
120
|
+
cwd?: string;
|
|
121
|
+
env?: Record<string, string>;
|
|
122
|
+
/** Auth subprotocol envelope. Default `"edge"`. */
|
|
123
|
+
authFormat?: TerminalStreamAuthFormat;
|
|
124
|
+
handlers?: TerminalStreamHandlers;
|
|
125
|
+
/** Reject `connect()` if `ready` has not arrived within this window. */
|
|
126
|
+
connectTimeoutMs?: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Fixed non-credential marker offered on EVERY dial (both auth formats),
|
|
130
|
+
* giving a spec-compliant server something safe to select into the 101's
|
|
131
|
+
* `Sec-WebSocket-Protocol`. Two reasons it exists:
|
|
132
|
+
*
|
|
133
|
+
* 1. RFC 6455 §4.1 says a client that offered subprotocols MUST fail the
|
|
134
|
+
* connection when the server selects none. Node's WebSocket (undici,
|
|
135
|
+
* per the WHATWG spec) enforces this strictly; browsers are lenient and
|
|
136
|
+
* tolerate a 101 with no selected subprotocol — which is why the
|
|
137
|
+
* browser-only reference client got away with offering just the
|
|
138
|
+
* credential.
|
|
139
|
+
* 2. The server must never echo the token-bearing offer back (that would
|
|
140
|
+
* leak the live credential into a response header) — so it needs a
|
|
141
|
+
* non-credential protocol it CAN select.
|
|
142
|
+
*/
|
|
143
|
+
declare const TERMINAL_WS_ECHO_SUBPROTOCOL = "tangle.terminal.v1";
|
|
144
|
+
/**
|
|
145
|
+
* Client for one terminal WebSocket connection. Construct via
|
|
146
|
+
* {@link TerminalStream.connect}, which resolves once the server
|
|
147
|
+
* acknowledges the attach with `ready` (history replay then streams through
|
|
148
|
+
* `handlers.onData`).
|
|
149
|
+
*/
|
|
150
|
+
declare class TerminalStream {
|
|
151
|
+
private readonly ws;
|
|
152
|
+
private readonly options;
|
|
153
|
+
private readonly handlers;
|
|
154
|
+
private readyInfo;
|
|
155
|
+
private closed;
|
|
156
|
+
private closeWaiters;
|
|
157
|
+
private readonly textDecoder;
|
|
158
|
+
/**
|
|
159
|
+
* Dial the endpoint, send `init` as the first frame, and resolve once the
|
|
160
|
+
* server responds `ready`. Rejects on a protocol `error` frame, a socket
|
|
161
|
+
* close/failure before `ready`, or the connect timeout — always with the
|
|
162
|
+
* reason the server gave. A token PROVIDER is awaited here, before the
|
|
163
|
+
* socket opens, so every dial (first connect and each reconnect) carries a
|
|
164
|
+
* fresh credential.
|
|
165
|
+
*/
|
|
166
|
+
static connect(options: TerminalStreamOptions): Promise<TerminalStream>;
|
|
167
|
+
private constructor();
|
|
168
|
+
private establish;
|
|
169
|
+
private handleMessage;
|
|
170
|
+
/** PTY connection id this stream is attached to. */
|
|
171
|
+
get connectionId(): string;
|
|
172
|
+
/** The server's `ready` acknowledgement. Set once `connect()` resolves. */
|
|
173
|
+
get ready(): TerminalReadyInfo;
|
|
174
|
+
/** True while the socket is open. */
|
|
175
|
+
get isOpen(): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Send input keystrokes to the PTY. `Uint8Array` input is decoded as
|
|
178
|
+
* UTF-8 (the wire protocol carries input as JSON text). Input larger than
|
|
179
|
+
* the server's 1 MiB frame cap is split across multiple `input` frames in
|
|
180
|
+
* order on the same socket, so delivery order is preserved.
|
|
181
|
+
*/
|
|
182
|
+
write(data: string | Uint8Array): void;
|
|
183
|
+
/** Resize the PTY. */
|
|
184
|
+
resize(cols: number, rows: number): void;
|
|
185
|
+
/**
|
|
186
|
+
* Detach cleanly: close the socket and resolve once the close completes.
|
|
187
|
+
* The PTY survives server-side for `ready.detachTimeoutMs` (5 minutes
|
|
188
|
+
* today) — reattach within that window via {@link reconnect} (or a fresh
|
|
189
|
+
* `connect()` with the same connectionId) to replay history and continue.
|
|
190
|
+
*/
|
|
191
|
+
close(): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Re-dial the same endpoint with the same connectionId on a fresh socket
|
|
194
|
+
* — the server reattaches the PTY and replays its buffered history. When
|
|
195
|
+
* the stream was constructed with a token PROVIDER, it is re-invoked for
|
|
196
|
+
* the new dial (scoped terminal tokens expire within minutes, so the
|
|
197
|
+
* original credential may be dead by reconnect time); with a plain string
|
|
198
|
+
* token, pass a fresh `token` override yourself when it may have expired.
|
|
199
|
+
* `handlers` rebinds callbacks for the new stream.
|
|
200
|
+
*/
|
|
201
|
+
reconnect(overrides?: {
|
|
202
|
+
token?: TerminalStreamToken;
|
|
203
|
+
handlers?: TerminalStreamHandlers;
|
|
204
|
+
cols?: number;
|
|
205
|
+
rows?: number;
|
|
206
|
+
}): Promise<TerminalStream>;
|
|
207
|
+
private assertOpen;
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region ../../../packages/runtime-contracts/dist/batch-events.d.ts
|
|
211
|
+
/** Token and tool usage emitted when one batch task completes. */
|
|
212
|
+
interface BatchTaskUsage {
|
|
213
|
+
inputTokens: number;
|
|
214
|
+
outputTokens: number;
|
|
215
|
+
cacheReadTokens?: number;
|
|
216
|
+
cacheWriteTokens?: number;
|
|
217
|
+
toolCallCount?: number;
|
|
218
|
+
reasoningTokens?: number;
|
|
219
|
+
cost?: number;
|
|
220
|
+
}
|
|
221
|
+
/** Per-backend aggregate emitted by `batch.completed`. */
|
|
222
|
+
interface BatchBackendStats {
|
|
223
|
+
backend: string;
|
|
224
|
+
backendLabel?: string;
|
|
225
|
+
backendModel?: string;
|
|
226
|
+
success: number;
|
|
227
|
+
failure: number;
|
|
228
|
+
retries: number;
|
|
229
|
+
successRate: number;
|
|
230
|
+
}
|
|
231
|
+
/** One sidecar allocated to a backend group. */
|
|
232
|
+
interface BatchSidecarGroup {
|
|
233
|
+
backend: string;
|
|
234
|
+
sidecarId: string;
|
|
235
|
+
variants: number;
|
|
236
|
+
}
|
|
237
|
+
interface BatchTaskEventIdentity {
|
|
238
|
+
taskId: string;
|
|
239
|
+
backend: string;
|
|
240
|
+
backendLabel?: string;
|
|
241
|
+
backendModel?: string;
|
|
242
|
+
}
|
|
243
|
+
/** Whether a streamed text value appends to or replaces prior text. */
|
|
244
|
+
type BatchTextValueMode = "delta" | "snapshot";
|
|
245
|
+
/** Data payloads keyed by the SSE event name emitted by `/batch/run`. */
|
|
246
|
+
interface BatchEventDataMap {
|
|
247
|
+
"batch.provisioning": {
|
|
248
|
+
desiredCapacity: number;
|
|
249
|
+
currentCapacity: number;
|
|
250
|
+
provisionTimeoutMs: number;
|
|
251
|
+
};
|
|
252
|
+
"batch.provisioned": {
|
|
253
|
+
capacity: number;
|
|
254
|
+
};
|
|
255
|
+
"batch.started": {
|
|
256
|
+
taskCount: number;
|
|
257
|
+
backendCount: number;
|
|
258
|
+
totalExecutions: number;
|
|
259
|
+
backends: string[];
|
|
260
|
+
backendGroups: number;
|
|
261
|
+
executionClass: string;
|
|
262
|
+
maxConcurrentPerSidecar: number;
|
|
263
|
+
maxSidecarsTotal: number;
|
|
264
|
+
driverCapacity: number;
|
|
265
|
+
policyMaxConcurrentPerSidecar: number | null;
|
|
266
|
+
policyMaxSidecarsPerHost: number | null;
|
|
267
|
+
};
|
|
268
|
+
"sidecars.allocated": {
|
|
269
|
+
count: number;
|
|
270
|
+
groups: BatchSidecarGroup[];
|
|
271
|
+
executionClass: string;
|
|
272
|
+
maxConcurrentPerSidecar: number;
|
|
273
|
+
maxSidecarsTotal: number;
|
|
274
|
+
driverCapacity: number;
|
|
275
|
+
policyMaxConcurrentPerSidecar: number | null;
|
|
276
|
+
policyMaxSidecarsPerHost: number | null;
|
|
277
|
+
};
|
|
278
|
+
"batch.completed": {
|
|
279
|
+
taskCount: number;
|
|
280
|
+
backendCount: number;
|
|
281
|
+
totalExecutions: number;
|
|
282
|
+
totalSuccess: number;
|
|
283
|
+
totalFailure: number;
|
|
284
|
+
totalRetries: number;
|
|
285
|
+
successRate: number;
|
|
286
|
+
byBackend: BatchBackendStats[];
|
|
287
|
+
};
|
|
288
|
+
"batch.failed": {
|
|
289
|
+
error: string;
|
|
290
|
+
backends?: string[];
|
|
291
|
+
};
|
|
292
|
+
"batch.persistent": {
|
|
293
|
+
message: string;
|
|
294
|
+
sidecarCount: number;
|
|
295
|
+
};
|
|
296
|
+
"batch.grace_period": {
|
|
297
|
+
message: string;
|
|
298
|
+
sidecarCount: number;
|
|
299
|
+
graceMs: number;
|
|
300
|
+
sidecarIds: string[];
|
|
301
|
+
};
|
|
302
|
+
"task.started": BatchTaskEventIdentity & {
|
|
303
|
+
index: number;
|
|
304
|
+
total: number;
|
|
305
|
+
attempt: number;
|
|
306
|
+
retries: number;
|
|
307
|
+
sidecarId: string;
|
|
308
|
+
projectRef?: string;
|
|
309
|
+
};
|
|
310
|
+
"task.message.delta": BatchTaskEventIdentity & {
|
|
311
|
+
sidecarId: string;
|
|
312
|
+
projectRef?: string;
|
|
313
|
+
value: string;
|
|
314
|
+
valueMode: BatchTextValueMode;
|
|
315
|
+
part: Record<string, unknown>;
|
|
316
|
+
};
|
|
317
|
+
"task.reasoning": BatchTaskEventIdentity & {
|
|
318
|
+
sidecarId: string;
|
|
319
|
+
projectRef?: string;
|
|
320
|
+
value: string;
|
|
321
|
+
valueMode: BatchTextValueMode;
|
|
322
|
+
part: Record<string, unknown>;
|
|
323
|
+
};
|
|
324
|
+
"task.tool.updated": BatchTaskEventIdentity & {
|
|
325
|
+
sidecarId: string;
|
|
326
|
+
projectRef?: string;
|
|
327
|
+
part: Record<string, unknown>;
|
|
328
|
+
};
|
|
329
|
+
"task.completed": BatchTaskEventIdentity & {
|
|
330
|
+
durationMs: number;
|
|
331
|
+
attempt: number;
|
|
332
|
+
retries: number;
|
|
333
|
+
sidecarId: string;
|
|
334
|
+
projectRef?: string;
|
|
335
|
+
resultSummary?: string;
|
|
336
|
+
sessionId?: string;
|
|
337
|
+
usage: BatchTaskUsage;
|
|
338
|
+
};
|
|
339
|
+
"task.failed": BatchTaskEventIdentity & {
|
|
340
|
+
durationMs: number;
|
|
341
|
+
attempt: number;
|
|
342
|
+
retries: number;
|
|
343
|
+
error: string;
|
|
344
|
+
sidecarId?: string;
|
|
345
|
+
projectRef?: string;
|
|
346
|
+
};
|
|
347
|
+
"task.retry": BatchTaskEventIdentity & {
|
|
348
|
+
attempt: number;
|
|
349
|
+
maxRetries: number;
|
|
350
|
+
error: string;
|
|
351
|
+
delayMs: number;
|
|
352
|
+
executionClass: string;
|
|
353
|
+
sidecarId: string;
|
|
354
|
+
projectRef?: string;
|
|
355
|
+
};
|
|
356
|
+
"backend.completed": {
|
|
357
|
+
backend: string;
|
|
358
|
+
backendLabel?: string;
|
|
359
|
+
backendModel?: string;
|
|
360
|
+
sidecarIds?: string[];
|
|
361
|
+
success: number;
|
|
362
|
+
failure: number;
|
|
363
|
+
retries: number;
|
|
364
|
+
successRate: number;
|
|
365
|
+
};
|
|
366
|
+
"sidecar.releasing": {
|
|
367
|
+
sidecarId: string;
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
/** Discriminated SSE event from a batch execution. */
|
|
371
|
+
type BatchEvent = { [K in keyof BatchEventDataMap]: {
|
|
372
|
+
type: K;
|
|
373
|
+
data: BatchEventDataMap[K]; /** Optional SSE id used by reconnecting consumers. */
|
|
374
|
+
id?: string;
|
|
375
|
+
} }[keyof BatchEventDataMap];
|
|
376
|
+
//#endregion
|
|
3
377
|
//#region src/types.d.ts
|
|
4
378
|
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
5
379
|
[key: string]: JsonValue;
|
|
@@ -343,6 +717,16 @@ interface CreateSandboxOptions {
|
|
|
343
717
|
* @default false
|
|
344
718
|
*/
|
|
345
719
|
bare?: boolean;
|
|
720
|
+
/**
|
|
721
|
+
* Start the managed sandbox runtime without configuring an AI agent.
|
|
722
|
+
*
|
|
723
|
+
* Files, exact process execution, lifecycle controls, and telemetry remain
|
|
724
|
+
* available. No model credentials or default backend are provisioned.
|
|
725
|
+
* Use this for CI jobs, evaluators, and other process-driven workloads.
|
|
726
|
+
*
|
|
727
|
+
* @default true
|
|
728
|
+
*/
|
|
729
|
+
agent?: boolean;
|
|
346
730
|
/**
|
|
347
731
|
* Provision a public preview URL for this sandbox (the default). Set to
|
|
348
732
|
* `false` for the fast lane: the server skips the public-edge tunnel
|
|
@@ -662,6 +1046,19 @@ interface CreateSandboxOptions {
|
|
|
662
1046
|
* timeout-driven retries.
|
|
663
1047
|
*/
|
|
664
1048
|
idempotencyKey?: string;
|
|
1049
|
+
/**
|
|
1050
|
+
* Platform user id whose wallet funds managed model usage for this sandbox.
|
|
1051
|
+
*
|
|
1052
|
+
* Use only from a trusted first-party service acting for an authenticated
|
|
1053
|
+
* user. The Sandbox API honors this field only when the caller's exact
|
|
1054
|
+
* verified API key ID is allow-listed; otherwise strict deployments reject
|
|
1055
|
+
* the create.
|
|
1056
|
+
* It never grants the caller permission to charge arbitrary users.
|
|
1057
|
+
*
|
|
1058
|
+
* This option applies to the HTTP Sandbox API client. Direct Tangle job
|
|
1059
|
+
* creation does not support delegated billing.
|
|
1060
|
+
*/
|
|
1061
|
+
billingOwnerId?: string;
|
|
665
1062
|
/**
|
|
666
1063
|
* Auto-split inline file mounts out of an inline `backend.profile` object
|
|
667
1064
|
* at create time, send the lean profile (mount refs stripped) in the
|
|
@@ -681,6 +1078,28 @@ interface CreateSandboxOptions {
|
|
|
681
1078
|
* @default true
|
|
682
1079
|
*/
|
|
683
1080
|
autoMaterializeProfileFiles?: boolean;
|
|
1081
|
+
/**
|
|
1082
|
+
* Auto-defer an inline `backend.profile`'s static corpus so it is delivered
|
|
1083
|
+
* once instead of on every turn. At create time the SDK strips inline
|
|
1084
|
+
* `resources.skills` from the create request (keeping the create body under
|
|
1085
|
+
* its wire cap), then primes the running sandbox with the full profile and
|
|
1086
|
+
* references it by hash (`backend.profileSha256`) on subsequent turns. The
|
|
1087
|
+
* handle still holds the full profile, so a cache miss transparently resends
|
|
1088
|
+
* it.
|
|
1089
|
+
*
|
|
1090
|
+
* When `false`, the full profile (skills included) rides the create request
|
|
1091
|
+
* and every turn — the legacy wire shape. Only applies to an inline
|
|
1092
|
+
* `AgentProfile` object on `backend.profile`, and is independent of
|
|
1093
|
+
* {@link autoMaterializeProfileFiles}.
|
|
1094
|
+
*
|
|
1095
|
+
* A turn only substitutes the hash reference when the outgoing profile's
|
|
1096
|
+
* content still matches what was primed: mutate the profile (or pass a
|
|
1097
|
+
* changed per-turn `backend.profile`) and that turn sends the full profile
|
|
1098
|
+
* inline again, so the runtime always runs the profile you passed.
|
|
1099
|
+
*
|
|
1100
|
+
* @default true
|
|
1101
|
+
*/
|
|
1102
|
+
autoDeferProfile?: boolean;
|
|
684
1103
|
}
|
|
685
1104
|
/**
|
|
686
1105
|
* Per-call overrides for {@link SandboxClient.create}.
|
|
@@ -783,6 +1202,12 @@ interface SandboxInfo {
|
|
|
783
1202
|
id: string;
|
|
784
1203
|
/** Human-readable name */
|
|
785
1204
|
name?: string;
|
|
1205
|
+
/** Control-plane identity of the currently published filesystem contents. */
|
|
1206
|
+
filesystemIncarnationId?: string;
|
|
1207
|
+
/** How the current filesystem contents were acquired. */
|
|
1208
|
+
filesystemIncarnationProvenance?: "fresh" | "restored" | "unknown";
|
|
1209
|
+
/** Whether this incarnation is safe for consumers to treat as authoritative. */
|
|
1210
|
+
filesystemIncarnationReadiness?: "transitioning" | "ready";
|
|
786
1211
|
/** Current status */
|
|
787
1212
|
status: SandboxStatus;
|
|
788
1213
|
/** Connection information */
|
|
@@ -890,6 +1315,33 @@ interface SandboxTerminalManager {
|
|
|
890
1315
|
list(): Promise<SandboxTerminalInfo[]>;
|
|
891
1316
|
get(sessionId: string): Promise<SandboxTerminalInfo | null>;
|
|
892
1317
|
}
|
|
1318
|
+
/** Options for `box.terminals.attach()`. */
|
|
1319
|
+
interface SandboxTerminalAttachOptions {
|
|
1320
|
+
/** Initial PTY geometry reported in the attach init frame. */
|
|
1321
|
+
cols?: number;
|
|
1322
|
+
rows?: number;
|
|
1323
|
+
/** Command to run when the connection id has no live PTY (default: shell). */
|
|
1324
|
+
command?: string;
|
|
1325
|
+
cwd?: string;
|
|
1326
|
+
env?: Record<string, string>;
|
|
1327
|
+
/**
|
|
1328
|
+
* Stream callbacks, bound before the socket opens. Register `onData` here:
|
|
1329
|
+
* a reattached PTY replays its buffered screen immediately after the
|
|
1330
|
+
* attach acknowledgement, so a handler added after `attach()` resolves
|
|
1331
|
+
* would miss the replayed frames.
|
|
1332
|
+
*/
|
|
1333
|
+
handlers?: TerminalStreamHandlers;
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* `box.terminals` — the REST terminal manager plus the live PTY attach
|
|
1337
|
+
* surface. `attach()` opens the terminal WebSocket (through the secured
|
|
1338
|
+
* sidecar proxy, with a short-lived scoped token minted per dial) as a
|
|
1339
|
+
* {@link TerminalStream}: reusing a connection id reattaches the existing
|
|
1340
|
+
* PTY and replays its history; a new id spawns a fresh shell (or `command`).
|
|
1341
|
+
*/
|
|
1342
|
+
interface SandboxTerminals extends SandboxTerminalManager {
|
|
1343
|
+
attach(connectionId: string, options?: SandboxTerminalAttachOptions): Promise<TerminalStream>;
|
|
1344
|
+
}
|
|
893
1345
|
/** Runtime-local agent profile. */
|
|
894
1346
|
interface SandboxRuntimeProfile {
|
|
895
1347
|
name: string;
|
|
@@ -1003,10 +1455,10 @@ interface ExecResult {
|
|
|
1003
1455
|
* Options for executing a command.
|
|
1004
1456
|
*/
|
|
1005
1457
|
interface ExecOptions {
|
|
1006
|
-
/** Working directory for the command.
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1458
|
+
/** Working directory for the command. It must resolve within the active
|
|
1459
|
+
* workspace; paths outside that boundary are rejected. When `sessionId`
|
|
1460
|
+
* is set, the runtime resolves the path against that task's isolated
|
|
1461
|
+
* workspace. */
|
|
1010
1462
|
cwd?: string;
|
|
1011
1463
|
/** Environment variables */
|
|
1012
1464
|
env?: Record<string, string>;
|
|
@@ -1223,6 +1675,15 @@ interface AgentQuestionRequest {
|
|
|
1223
1675
|
/** The questions payload the agent emitted (prompt + options per entry). */
|
|
1224
1676
|
questions: unknown;
|
|
1225
1677
|
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Token usage counts for a single agent run: prompt tokens in, completion
|
|
1680
|
+
* tokens out. Both are whole non-negative counts; a runtime that reports
|
|
1681
|
+
* only one side leaves the other at 0.
|
|
1682
|
+
*/
|
|
1683
|
+
interface TokenUsage {
|
|
1684
|
+
inputTokens: number;
|
|
1685
|
+
outputTokens: number;
|
|
1686
|
+
}
|
|
1226
1687
|
interface PromptResult {
|
|
1227
1688
|
/**
|
|
1228
1689
|
* Whether the run succeeded. Shorthand for `status === "success"`: true only
|
|
@@ -1252,10 +1713,7 @@ interface PromptResult {
|
|
|
1252
1713
|
/** Duration in milliseconds */
|
|
1253
1714
|
durationMs: number;
|
|
1254
1715
|
/** Token usage */
|
|
1255
|
-
usage?:
|
|
1256
|
-
inputTokens: number;
|
|
1257
|
-
outputTokens: number;
|
|
1258
|
-
};
|
|
1716
|
+
usage?: TokenUsage;
|
|
1259
1717
|
/** Provider-reported model cost in USD, when the runtime emitted it. */
|
|
1260
1718
|
costUsd?: number;
|
|
1261
1719
|
}
|
|
@@ -1589,6 +2047,15 @@ interface UsageInfo {
|
|
|
1589
2047
|
/** Period end date (next day UTC) */
|
|
1590
2048
|
periodEnd: Date;
|
|
1591
2049
|
}
|
|
2050
|
+
/** Identity observed by the public Sandbox API for the current credential. */
|
|
2051
|
+
interface SandboxIdentity {
|
|
2052
|
+
/** Sandbox customer id for the authenticated caller. */
|
|
2053
|
+
customerId: string;
|
|
2054
|
+
/** Platform account whose wallet Sandbox charges for this caller. */
|
|
2055
|
+
billingOwnerId: string;
|
|
2056
|
+
/** Verified Platform API key id, or null for session-based callers. */
|
|
2057
|
+
apiKeyId: string | null;
|
|
2058
|
+
}
|
|
1592
2059
|
/**
|
|
1593
2060
|
* Subscription and billing information for the account.
|
|
1594
2061
|
*/
|
|
@@ -1744,6 +2211,8 @@ interface SessionInfo {
|
|
|
1744
2211
|
parentId?: string;
|
|
1745
2212
|
/** Current lifecycle state. */
|
|
1746
2213
|
status: SessionStatus;
|
|
2214
|
+
/** Most recent execution id, retained after completion for event replay. */
|
|
2215
|
+
latestExecutionId?: string;
|
|
1747
2216
|
/** Backend identifier (e.g. provider name). */
|
|
1748
2217
|
backend?: string;
|
|
1749
2218
|
/** Model id the session was created with. */
|
|
@@ -1833,17 +2302,19 @@ interface SendSessionMessageOptions {
|
|
|
1833
2302
|
timeoutMs?: number;
|
|
1834
2303
|
signal?: AbortSignal;
|
|
1835
2304
|
}
|
|
1836
|
-
/**
|
|
2305
|
+
/** Receipt returned after a session message is accepted for processing. */
|
|
1837
2306
|
interface SentSessionMessage {
|
|
1838
2307
|
info: {
|
|
1839
2308
|
id: string;
|
|
1840
|
-
role: "
|
|
1841
|
-
timestamp
|
|
2309
|
+
role: "assistant";
|
|
2310
|
+
timestamp: string;
|
|
1842
2311
|
};
|
|
1843
|
-
parts:
|
|
2312
|
+
parts: [];
|
|
2313
|
+
userMessageId: string;
|
|
2314
|
+
processing: true;
|
|
1844
2315
|
}
|
|
1845
2316
|
/** Canonical portable profile attached to a task session. */
|
|
1846
|
-
type TaskSessionProfile = AgentProfile & {
|
|
2317
|
+
type TaskSessionProfile = AgentProfile$1 & {
|
|
1847
2318
|
name: string;
|
|
1848
2319
|
};
|
|
1849
2320
|
/** Options for creating an isolated background task session. */
|
|
@@ -2063,6 +2534,11 @@ type TurnDriveResult = {
|
|
|
2063
2534
|
state: "completed"; /** Final assistant text of the turn. */
|
|
2064
2535
|
text: string; /** The full turn payload (text, toolInvocations, tokenUsage, etc.). */
|
|
2065
2536
|
result: Record<string, unknown>;
|
|
2537
|
+
/**
|
|
2538
|
+
* Token usage the turn reported, when the payload carried it. Typed
|
|
2539
|
+
* access to the counts otherwise buried untyped inside `result`.
|
|
2540
|
+
*/
|
|
2541
|
+
usage?: TokenUsage;
|
|
2066
2542
|
} | {
|
|
2067
2543
|
state: "awaiting_plan_decision";
|
|
2068
2544
|
plan: DurablePlanSnapshot;
|
|
@@ -2081,21 +2557,24 @@ type TurnDriveResult = {
|
|
|
2081
2557
|
* capability tokens for browser-safe runtime access.
|
|
2082
2558
|
*/
|
|
2083
2559
|
type ScopedTokenScope = "session" | "session-runtime" | "project" | "read-only";
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
*/
|
|
2087
|
-
interface MintScopedTokenOptions {
|
|
2088
|
-
/** Scope to mint. `session` and `project` are for SessionGateway streams;
|
|
2089
|
-
* `session-runtime` permits typed files, messages, and terminals for one
|
|
2090
|
-
* session; `read-only` permits read-only runtime requests. */
|
|
2091
|
-
scope: ScopedTokenScope;
|
|
2092
|
-
/** Required when `scope` is `session` or `session-runtime`. */
|
|
2093
|
-
sessionId?: string;
|
|
2094
|
-
/** TTL in minutes. Default 5; clamped to [1, 15]. Browser-side
|
|
2095
|
-
* bearers must be short-lived; pair with `client.onTokenRefresh()`
|
|
2096
|
-
* for long-running consumers. */
|
|
2560
|
+
interface MintScopedTokenBase {
|
|
2561
|
+
/** TTL in minutes. Default 5; clamped to [1, 15]. */
|
|
2097
2562
|
ttlMinutes?: number;
|
|
2098
2563
|
}
|
|
2564
|
+
/** Options for `box.mintScopedToken()`, narrowed by consumer scope. */
|
|
2565
|
+
type MintScopedTokenOptions = (MintScopedTokenBase & {
|
|
2566
|
+
scope: "session"; /** Client-facing browser session ID. */
|
|
2567
|
+
sessionId: string; /** Actual runtime session ID used to filter the sandbox event stream. */
|
|
2568
|
+
runtimeSessionId: string;
|
|
2569
|
+
}) | (MintScopedTokenBase & {
|
|
2570
|
+
scope: "session-runtime";
|
|
2571
|
+
sessionId: string;
|
|
2572
|
+
runtimeSessionId?: never;
|
|
2573
|
+
}) | (MintScopedTokenBase & {
|
|
2574
|
+
scope: "project" | "read-only";
|
|
2575
|
+
sessionId?: never;
|
|
2576
|
+
runtimeSessionId?: never;
|
|
2577
|
+
});
|
|
2099
2578
|
/**
|
|
2100
2579
|
* Returned by `box.mintScopedToken()`. Use session/project tokens with
|
|
2101
2580
|
* `SessionGatewayClient`; use session-runtime/read-only tokens with
|
|
@@ -2294,145 +2773,6 @@ interface BatchResult {
|
|
|
2294
2773
|
/** Individual task results */
|
|
2295
2774
|
results: BatchTaskResult[];
|
|
2296
2775
|
}
|
|
2297
|
-
/** Token and tool usage emitted when one batch task completes. */
|
|
2298
|
-
interface BatchTaskUsage {
|
|
2299
|
-
inputTokens: number;
|
|
2300
|
-
outputTokens: number;
|
|
2301
|
-
cacheReadTokens?: number;
|
|
2302
|
-
cacheWriteTokens?: number;
|
|
2303
|
-
toolCallCount?: number;
|
|
2304
|
-
}
|
|
2305
|
-
/** Per-backend aggregate emitted by `batch.completed`. */
|
|
2306
|
-
interface BatchBackendStats {
|
|
2307
|
-
backend: string;
|
|
2308
|
-
backendLabel?: string;
|
|
2309
|
-
backendModel?: string;
|
|
2310
|
-
success: number;
|
|
2311
|
-
failure: number;
|
|
2312
|
-
retries: number;
|
|
2313
|
-
successRate: number;
|
|
2314
|
-
}
|
|
2315
|
-
/** Sidecars allocated to one backend configuration. */
|
|
2316
|
-
interface BatchSidecarGroup {
|
|
2317
|
-
backend: string;
|
|
2318
|
-
sidecarIds: string[];
|
|
2319
|
-
}
|
|
2320
|
-
interface BatchTaskEventIdentity {
|
|
2321
|
-
taskId: string;
|
|
2322
|
-
backend: string;
|
|
2323
|
-
backendLabel?: string;
|
|
2324
|
-
backendModel?: string;
|
|
2325
|
-
}
|
|
2326
|
-
/** Data payloads keyed by the SSE event name emitted by `/batch/run`. */
|
|
2327
|
-
interface BatchEventDataMap {
|
|
2328
|
-
"batch.provisioning": {
|
|
2329
|
-
desiredCapacity: number;
|
|
2330
|
-
currentCapacity: number;
|
|
2331
|
-
provisionTimeoutMs: number;
|
|
2332
|
-
};
|
|
2333
|
-
"batch.provisioned": {
|
|
2334
|
-
capacity: number;
|
|
2335
|
-
};
|
|
2336
|
-
"batch.started": {
|
|
2337
|
-
taskCount: number;
|
|
2338
|
-
backendCount: number;
|
|
2339
|
-
totalExecutions: number;
|
|
2340
|
-
maxConcurrent: number;
|
|
2341
|
-
scalingMode: string;
|
|
2342
|
-
backends: string[];
|
|
2343
|
-
};
|
|
2344
|
-
"sidecars.allocated": {
|
|
2345
|
-
count: number;
|
|
2346
|
-
groups: BatchSidecarGroup[];
|
|
2347
|
-
};
|
|
2348
|
-
"batch.completed": {
|
|
2349
|
-
taskCount: number;
|
|
2350
|
-
backendCount: number;
|
|
2351
|
-
totalExecutions: number;
|
|
2352
|
-
totalSuccess: number;
|
|
2353
|
-
totalFailure: number;
|
|
2354
|
-
totalRetries: number;
|
|
2355
|
-
successRate: number;
|
|
2356
|
-
byBackend: BatchBackendStats[];
|
|
2357
|
-
};
|
|
2358
|
-
"batch.failed": {
|
|
2359
|
-
error: string;
|
|
2360
|
-
backends?: string[];
|
|
2361
|
-
};
|
|
2362
|
-
"batch.persistent": {
|
|
2363
|
-
message: string;
|
|
2364
|
-
sidecarCount: number;
|
|
2365
|
-
};
|
|
2366
|
-
"batch.grace_period": {
|
|
2367
|
-
message: string;
|
|
2368
|
-
sidecarCount: number;
|
|
2369
|
-
graceMs: number;
|
|
2370
|
-
sidecarIds: string[];
|
|
2371
|
-
};
|
|
2372
|
-
"task.started": BatchTaskEventIdentity & {
|
|
2373
|
-
sidecarId: string;
|
|
2374
|
-
projectRef?: string;
|
|
2375
|
-
attempt: number;
|
|
2376
|
-
};
|
|
2377
|
-
"task.message.delta": BatchTaskEventIdentity & {
|
|
2378
|
-
sidecarId: string;
|
|
2379
|
-
projectRef?: string;
|
|
2380
|
-
value: string;
|
|
2381
|
-
part: Record<string, unknown>;
|
|
2382
|
-
};
|
|
2383
|
-
"task.reasoning": BatchTaskEventIdentity & {
|
|
2384
|
-
sidecarId: string;
|
|
2385
|
-
projectRef?: string;
|
|
2386
|
-
value: string;
|
|
2387
|
-
part: Record<string, unknown>;
|
|
2388
|
-
};
|
|
2389
|
-
"task.tool.updated": BatchTaskEventIdentity & {
|
|
2390
|
-
sidecarId: string;
|
|
2391
|
-
projectRef?: string;
|
|
2392
|
-
part: Record<string, unknown>;
|
|
2393
|
-
};
|
|
2394
|
-
"task.completed": BatchTaskEventIdentity & {
|
|
2395
|
-
durationMs: number;
|
|
2396
|
-
attempt: number;
|
|
2397
|
-
retries: number;
|
|
2398
|
-
sidecarId: string;
|
|
2399
|
-
projectRef?: string;
|
|
2400
|
-
resultSummary?: string;
|
|
2401
|
-
sessionId?: string;
|
|
2402
|
-
usage: BatchTaskUsage;
|
|
2403
|
-
};
|
|
2404
|
-
"task.failed": BatchTaskEventIdentity & {
|
|
2405
|
-
durationMs: number;
|
|
2406
|
-
attempt: number;
|
|
2407
|
-
retries: number;
|
|
2408
|
-
error: string;
|
|
2409
|
-
sidecarId?: string;
|
|
2410
|
-
};
|
|
2411
|
-
"task.retry": BatchTaskEventIdentity & {
|
|
2412
|
-
attempt: number;
|
|
2413
|
-
maxRetries: number;
|
|
2414
|
-
error: string;
|
|
2415
|
-
delayMs: number;
|
|
2416
|
-
};
|
|
2417
|
-
"backend.completed": {
|
|
2418
|
-
backend: string;
|
|
2419
|
-
backendLabel?: string;
|
|
2420
|
-
backendModel?: string;
|
|
2421
|
-
success: number;
|
|
2422
|
-
failure: number;
|
|
2423
|
-
retries: number;
|
|
2424
|
-
successRate: number;
|
|
2425
|
-
};
|
|
2426
|
-
"sidecar.releasing": {
|
|
2427
|
-
sidecarId: string;
|
|
2428
|
-
};
|
|
2429
|
-
}
|
|
2430
|
-
/** Discriminated SSE event from a batch execution. */
|
|
2431
|
-
type BatchEvent = { [K in keyof BatchEventDataMap]: {
|
|
2432
|
-
type: K;
|
|
2433
|
-
data: BatchEventDataMap[K]; /** Optional SSE id used by reconnecting consumers. */
|
|
2434
|
-
id?: string;
|
|
2435
|
-
} }[keyof BatchEventDataMap];
|
|
2436
2776
|
/**
|
|
2437
2777
|
* Stable worker identifier inside a sandbox fleet.
|
|
2438
2778
|
*
|
|
@@ -3377,7 +3717,7 @@ interface BackendConfig {
|
|
|
3377
3717
|
* Use a string for a named provider/backend profile, or an `AgentProfile`
|
|
3378
3718
|
* object for an inline provider-neutral profile definition.
|
|
3379
3719
|
*/
|
|
3380
|
-
profile?: string | AgentProfile;
|
|
3720
|
+
profile?: string | AgentProfile$1;
|
|
3381
3721
|
/**
|
|
3382
3722
|
* Model configuration override.
|
|
3383
3723
|
*/
|
|
@@ -3429,14 +3769,14 @@ interface BackendConfig {
|
|
|
3429
3769
|
/** Runtime session metadata used for attribution and workspace selection. */
|
|
3430
3770
|
metadata?: {
|
|
3431
3771
|
containerType?: string;
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3772
|
+
/**
|
|
3773
|
+
* Non-secret labels attached to execution traces.
|
|
3774
|
+
*
|
|
3775
|
+
* Maximum 32 entries; keys are at most 128 characters and values at most
|
|
3776
|
+
* 1024 characters. The Sandbox platform owns collector configuration and
|
|
3777
|
+
* credentials. Never put API keys, tokens, cookies, or user content here.
|
|
3778
|
+
*/
|
|
3779
|
+
traceAttributes?: Record<string, string>;
|
|
3440
3780
|
};
|
|
3441
3781
|
}
|
|
3442
3782
|
/**
|
|
@@ -3633,19 +3973,24 @@ interface EgressPolicy {
|
|
|
3633
3973
|
/** Egress mode */
|
|
3634
3974
|
mode: "open" | "strict" | "blocked";
|
|
3635
3975
|
/**
|
|
3636
|
-
*
|
|
3637
|
-
*
|
|
3976
|
+
* Allowed domains in strict mode. Platform defaults and credential-derived
|
|
3977
|
+
* domains are also included unless `includeImplicitDomains` is false.
|
|
3638
3978
|
* Ignored in `open` and `blocked` modes.
|
|
3639
3979
|
*/
|
|
3640
3980
|
allowDomains?: string[];
|
|
3981
|
+
/**
|
|
3982
|
+
* Include platform and credential-derived domains in strict mode.
|
|
3983
|
+
* Defaults to true. Set false when `allowDomains` must be the complete list.
|
|
3984
|
+
*/
|
|
3985
|
+
includeImplicitDomains?: boolean;
|
|
3641
3986
|
/**
|
|
3642
3987
|
* Denied domains. Only enforced when the proxy supports denylist transforms.
|
|
3643
|
-
* @deprecated
|
|
3988
|
+
* @deprecated Not supported by the current proxy.
|
|
3644
3989
|
*/
|
|
3645
3990
|
denyDomains?: string[];
|
|
3646
3991
|
/**
|
|
3647
3992
|
* Allowed CIDR ranges. Only enforced when the proxy supports CIDR passthrough.
|
|
3648
|
-
* @deprecated
|
|
3993
|
+
* @deprecated Not supported by the current proxy.
|
|
3649
3994
|
*/
|
|
3650
3995
|
allowCidrs?: string[];
|
|
3651
3996
|
}
|
|
@@ -3996,7 +4341,7 @@ interface BackendManager {
|
|
|
3996
4341
|
*
|
|
3997
4342
|
* Optional while backends adopt the public `AgentProfile` contract.
|
|
3998
4343
|
*/
|
|
3999
|
-
validateProfile?(profile: AgentProfile): Promise<AgentProfileValidationResult>;
|
|
4344
|
+
validateProfile?(profile: AgentProfile$1): Promise<AgentProfileValidationResult>;
|
|
4000
4345
|
/** Restart the backend agent */
|
|
4001
4346
|
restart(): Promise<void>;
|
|
4002
4347
|
}
|
|
@@ -4029,6 +4374,28 @@ interface ProcessSpawnOptions {
|
|
|
4029
4374
|
interface ExactProcessSpawnOptions extends ProcessSpawnOptions {
|
|
4030
4375
|
/** UTF-8 bytes written before stdin is closed. */
|
|
4031
4376
|
stdin?: string;
|
|
4377
|
+
/**
|
|
4378
|
+
* Whether to extend the sandbox runtime environment.
|
|
4379
|
+
* Set to `false` when every process input must be supplied explicitly.
|
|
4380
|
+
* The executable must then be absolute unless `env.PATH` is supplied.
|
|
4381
|
+
*
|
|
4382
|
+
* @default true
|
|
4383
|
+
*/
|
|
4384
|
+
inheritEnv?: boolean;
|
|
4385
|
+
/**
|
|
4386
|
+
* Opaque, non-secret launch identity.
|
|
4387
|
+
* Repeating it with the same exact launch returns the retained process record.
|
|
4388
|
+
*/
|
|
4389
|
+
idempotencyKey?: string;
|
|
4390
|
+
/**
|
|
4391
|
+
* Minimum terminal-record retention after exit.
|
|
4392
|
+
* Requires {@link idempotencyKey}; unsupported values fail before launch.
|
|
4393
|
+
*/
|
|
4394
|
+
retentionMs?: number;
|
|
4395
|
+
}
|
|
4396
|
+
/** Select retained process records by their exact-process launch identity. */
|
|
4397
|
+
interface ProcessListOptions {
|
|
4398
|
+
idempotencyKey?: string;
|
|
4032
4399
|
}
|
|
4033
4400
|
/**
|
|
4034
4401
|
* Options for running Python code.
|
|
@@ -4055,6 +4422,8 @@ interface RunCodeOptions {
|
|
|
4055
4422
|
interface ProcessStatus {
|
|
4056
4423
|
/** Process ID */
|
|
4057
4424
|
pid: number;
|
|
4425
|
+
/** Opaque exact-process launch identity when one was supplied. */
|
|
4426
|
+
idempotencyKey?: string;
|
|
4058
4427
|
/** Command that was executed */
|
|
4059
4428
|
command: string;
|
|
4060
4429
|
/** Working directory */
|
|
@@ -4077,6 +4446,33 @@ interface ProcessInfo extends ProcessStatus {
|
|
|
4077
4446
|
/** Environment variables used */
|
|
4078
4447
|
env?: Record<string, string>;
|
|
4079
4448
|
}
|
|
4449
|
+
/** A development server started and tracked by the sandbox runtime. */
|
|
4450
|
+
interface DevServerInfo {
|
|
4451
|
+
/** Supervisor process ID. */
|
|
4452
|
+
pid: number;
|
|
4453
|
+
/** Detected project family, such as node-npm or rust-cargo. */
|
|
4454
|
+
family: string;
|
|
4455
|
+
/** Command managed by the runtime. */
|
|
4456
|
+
command: string;
|
|
4457
|
+
/** Canonical workspace root used for project detection. */
|
|
4458
|
+
workspaceRoot: string;
|
|
4459
|
+
/** When the managed process started. */
|
|
4460
|
+
startedAt: Date;
|
|
4461
|
+
/** True when this call started the process; false when it reused one. */
|
|
4462
|
+
startedNow: boolean;
|
|
4463
|
+
/** True when dependency installation ran before startup. */
|
|
4464
|
+
installRan: boolean;
|
|
4465
|
+
/** Time spent installing dependencies during this call. */
|
|
4466
|
+
installDurationMs: number;
|
|
4467
|
+
/** Assigned listening port, once the server is ready. */
|
|
4468
|
+
port?: number;
|
|
4469
|
+
}
|
|
4470
|
+
interface EnsureDevServerOptions {
|
|
4471
|
+
/** Agent session whose isolated workspace contains the project. */
|
|
4472
|
+
sessionId?: string;
|
|
4473
|
+
/** Project directory inside the selected workspace. Defaults to the workspace root. */
|
|
4474
|
+
cwd?: string;
|
|
4475
|
+
}
|
|
4080
4476
|
/**
|
|
4081
4477
|
* A log entry from process stdout/stderr.
|
|
4082
4478
|
*/
|
|
@@ -4223,6 +4619,12 @@ interface Process {
|
|
|
4223
4619
|
* ```
|
|
4224
4620
|
*/
|
|
4225
4621
|
interface ProcessManager {
|
|
4622
|
+
/**
|
|
4623
|
+
* Detect the workspace project and idempotently start its development server.
|
|
4624
|
+
* The runtime owns installation, process tracking, port assignment, and
|
|
4625
|
+
* stale-Vite compatibility handling.
|
|
4626
|
+
*/
|
|
4627
|
+
ensureDevServer(options?: EnsureDevServerOptions): Promise<DevServerInfo>;
|
|
4226
4628
|
/**
|
|
4227
4629
|
* Spawn a process without blocking.
|
|
4228
4630
|
* Returns immediately with a Process handle.
|
|
@@ -4248,7 +4650,7 @@ interface ProcessManager {
|
|
|
4248
4650
|
*
|
|
4249
4651
|
* @returns Array of process status objects
|
|
4250
4652
|
*/
|
|
4251
|
-
list(): Promise<ProcessStatus[]>;
|
|
4653
|
+
list(options?: ProcessListOptions): Promise<ProcessStatus[]>;
|
|
4252
4654
|
/**
|
|
4253
4655
|
* Get a process by PID.
|
|
4254
4656
|
*
|
|
@@ -4442,6 +4844,36 @@ interface FileTreeResult {
|
|
|
4442
4844
|
truncated: boolean;
|
|
4443
4845
|
};
|
|
4444
4846
|
}
|
|
4847
|
+
/** Options for measuring aggregate workspace storage usage. */
|
|
4848
|
+
interface FileUsageOptions {
|
|
4849
|
+
/** Task session id for session-specific workspace isolation. */
|
|
4850
|
+
sessionId?: string;
|
|
4851
|
+
}
|
|
4852
|
+
/**
|
|
4853
|
+
* Aggregate apparent storage usage for a customer workspace.
|
|
4854
|
+
*
|
|
4855
|
+
* Hidden files, dependency trees, caches, and build output are included.
|
|
4856
|
+
* Runtime-owned `.sidecar` directories are excluded, and symlinks are counted
|
|
4857
|
+
* by their own metadata without following their targets.
|
|
4858
|
+
*/
|
|
4859
|
+
interface FileUsageResult {
|
|
4860
|
+
/** Scanned root, relative to the workspace when applicable. */
|
|
4861
|
+
root: string;
|
|
4862
|
+
/** Sum of regular-file and symlink apparent sizes. */
|
|
4863
|
+
sizeBytes: number;
|
|
4864
|
+
/** Number of regular files and symlinks. */
|
|
4865
|
+
fileCount: number;
|
|
4866
|
+
/** Number of customer-owned directories, excluding the root. */
|
|
4867
|
+
directoryCount: number;
|
|
4868
|
+
/** Latest observed modification time as Unix milliseconds. */
|
|
4869
|
+
lastModifiedMs: number;
|
|
4870
|
+
/** Time spent scanning the workspace. */
|
|
4871
|
+
scanDurationMs: number;
|
|
4872
|
+
/** False when limits or unreadable entries prevented a complete result. */
|
|
4873
|
+
complete: boolean;
|
|
4874
|
+
/** Entries skipped because their metadata could not be read. */
|
|
4875
|
+
skippedEntries: number;
|
|
4876
|
+
}
|
|
4445
4877
|
/** File content and metadata returned by a batch read. */
|
|
4446
4878
|
interface FileReadResult {
|
|
4447
4879
|
path: string;
|
|
@@ -4690,6 +5122,13 @@ interface FileSystem {
|
|
|
4690
5122
|
readBatch(paths: string[], options?: FileReadBatchOptions): Promise<FileReadBatchResult>;
|
|
4691
5123
|
/** Recursively scan the workspace and return file metadata. */
|
|
4692
5124
|
tree(path: string, options?: FileTreeOptions): Promise<FileTreeResult>;
|
|
5125
|
+
/**
|
|
5126
|
+
* Measure complete aggregate workspace usage without returning a file list.
|
|
5127
|
+
* Unlike {@link FileSystem.tree}, this includes hidden files, dependencies,
|
|
5128
|
+
* caches, and build output. Check `complete` before using the result for
|
|
5129
|
+
* accounting or quota decisions.
|
|
5130
|
+
*/
|
|
5131
|
+
usage(path: string, options?: FileUsageOptions): Promise<FileUsageResult>;
|
|
4693
5132
|
/**
|
|
4694
5133
|
* Write string content to a file.
|
|
4695
5134
|
* For binary files, use upload() instead.
|
|
@@ -5001,4 +5440,4 @@ interface CodeExecutionOptions {
|
|
|
5001
5440
|
idempotencyKey?: string;
|
|
5002
5441
|
}
|
|
5003
5442
|
//#endregion
|
|
5004
|
-
export {
|
|
5443
|
+
export { EventStreamOptions as $, TerminalStreamError as $i, SandboxFleetDispatchFailureClass as $n, SendSessionMessageOptions as $r, ListSandboxOptions as $t, CreateIntelligenceReportOptions as A, TokenRefreshHandler as Ai, ReapExpiredSandboxFleetsResult as An, SandboxResourceUsage as Ar, GitDiff as At, DirectoryPermission as B, WriteFileOptions as Bi, RolloutStartResult as Bn, SandboxTerminalRequestOptions as Br, GpuType as Bt, CodeExecutionResult as C, defineInlineResource as Ca, TaskSessionInfo as Ci, ProvisionStatus as Cn, SandboxIdentity as Cr, FleetPromptDispatchOptions as Ct, CommitTaskSessionOptions as D, TeeAttestationResponse as Di, PublishPublicTemplateOptions as Dn, SandboxPortBinding as Dr, GitBranch as Dt, CodeResultPart as E, TeeAttestationReport as Ei, PublicTemplateVersionInfo as En, SandboxPermissionsConfig as Er, GitAuth as Et, CreateSandboxOptions as F, UploadOptions as Fi, ResumeOptions as Fn, SandboxStatus as Fr, GpuLeaseExecOptions as Ft, DriveTurnOptions as G, BatchEventDataMap as Gi, SSHCredentials as Gn, SandboxTraceOptions as Gr, IntelligenceReportBudget as Gt, DispatchedSession as H, WriteManyOptions as Hi, RolloutTurnPart as Hn, SandboxTraceBundle as Hr, HostAgentRuntimeBackend as Ht, CreateSessionOptions as I, UploadProgress as Ii, Rollout as In, SandboxTerminalAttachOptions as Ir, GpuLeaseExecResult as It, DriverType as J, TERMINAL_WS_ECHO_SUBPROTOCOL as Ji, SandboxEnvironment as Jn, ScopedTokenScope as Jr, IntelligenceReportWindow as Jt, DriverConfig as K, BatchSidecarGroup as Ki, SandboxClientConfig as Kn, SandboxUser as Kr, IntelligenceReportCompareTo as Kt, CreateTaskSessionOptions as L, UsageInfo as Li, RolloutChildResult as Ln, SandboxTerminalCreateOptions as Lr, GpuLeaseManager as Lt, CreateSandboxFleetOptions as M, ToolsConfig as Mi, ReconcileSandboxFleetsResult as Mn, SandboxRuntimeHealth as Mr, GpuLease as Mt, CreateSandboxFleetTokenOptions as N, TurnDriveResult as Ni, RenameOptions as Nn, SandboxRuntimeProfile as Nr, GpuLeaseBilling as Nt, CompletedTurnResult as O, TeePublicKey as Oi, PublishPublicTemplateVersionOptions as On, SandboxPortPreviewLink as Or, GitCommit as Ot, CreateSandboxFleetWithCoordinatorOptions as P, UpdateUserOptions as Pi, RestoreSnapshotOptions as Pn, SandboxRuntimeProfileList as Pr, GpuLeaseCommandResult as Pt, EnsureDevServerOptions as Q, TerminalStreamAuthFormat as Qi, SandboxFleetCostEstimate as Qn, SecretsManager as Qr, ListSandboxFleetOptions as Qt, DeleteOptions as R, WaitForOptions as Ri, RolloutOptions as Rn, SandboxTerminalInfo as Rr, GpuLeaseProviderName as Rt, CodeExecutionOptions as S, defineGitHubResource as Sa, TaskSessionFileChange as Si, ProvisionResult as Sn, SandboxFleetWorkspaceSnapshotResult as Sr, FleetMachineId as St, CodeResult as T, validateAgentProfileSecurity as Ta, TeeAttestationOptions as Ti, PublicTemplateInfo as Tn, SandboxIntelligenceEnvelope as Tr, GPU_LEASE_PROVIDER_NAMES as Tt, DownloadOptions as U, BatchBackendStats as Ui, RunCodeOptions as Un, SandboxTraceEvent as Ur, InstalledTool as Ut, DispatchPromptOptions as V, WriteManyFile as Vi, RolloutStatus as Vn, SandboxTerminals as Vr, HostAgentDriverConfig as Vt, DownloadProgress as W, BatchEvent as Wi, SSHCommandDescriptor as Wn, SandboxTraceExport as Wr, IntelligenceReport as Wt, EgressManager as X, TerminalReadyInfo as Xi, SandboxFleetArtifact as Xn, SearchOptions as Xr, ListMessagesOptions as Xt, DurablePlan as Y, TerminalExitInfo as Yi, SandboxEvent as Yn, SearchMatch as Yr, JsonValue as Yt, EgressPolicy as Z, TerminalStream as Zi, SandboxFleetArtifactSpec as Zn, SecretInfo as Zr, ListOptions as Zt, BatchTask as _, AgentSubagentProfile as _a, SubscriptionInfo as _i, ProcessStatus as _n, SandboxFleetTraceOptions as _r, FleetDispatchResultBuffer as _t, AttachSandboxFleetMachineOptions as a, AgentProfileConfidential as aa, SessionInfo as ai, NonHostAgentDriverConfig as an, SandboxFleetMachine as ar, FileReadBatchResult as at, ChunkedUploadOptions as b, capabilitySchema as ba, TaskSessionChanges as bi, PromptResult as bn, SandboxFleetWorkspaceReconcileResult as br, FleetExecDispatchOptions as bt, BackendInfo as c, AgentProfileMcpServer as ca, SessionMessageInputPart as ci, PreviewLinkInfo as cn, SandboxFleetMachineSpec as cr, FileRenameResult as ct, BackendType as d, AgentProfilePrompt as da, SnapshotOptions as di, ProcessInfo as dn, SandboxFleetOperationsSummary as dr, FileTreeOptions as dt, TerminalStreamHandlers as ea, SendSessionMessageRequest as ei, McpServerConfig as en, SandboxFleetDispatchResponse as er, ExactProcessSpawnOptions as et, BatchBackend as f, AgentProfileResourceRef as fa, SnapshotResult as fi, ProcessListOptions as fn, SandboxFleetPolicy as fr, FileTreeResult as ft, BatchRunRequest as g, AgentProfileValidationResult as ga, StorageConfig as gi, ProcessSpawnOptions as gn, SandboxFleetTraceExport as gr, FleetDispatchCancelResult as gt, BatchRunOptions as h, AgentProfileValidationIssue as ha, StartupOperation as hi, ProcessSignal as hn, SandboxFleetTraceEvent as hr, FileWriteResult as ht, AttachGpuLeaseOptions as i, AgentProfileCapabilities as ia, SessionForkOptions as ii, NetworkManager as in, SandboxFleetIntelligenceEnvelope as ir, FileReadBatchOptions as it, CreateRequestOptions as j, TokenUsage as ji, ReconcileSandboxFleetsOptions as jn, SandboxResources as jr, GitStatus as jt, CreateGpuLeaseOptions as k, TeePublicKeyResponse as ki, ReapExpiredSandboxFleetsOptions as kn, SandboxProfileSummary as kr, GitConfig as kt, BackendManager as l, AgentProfileModelHints as la, SessionStatus as li, PreviewLinkManager as ln, SandboxFleetManifest as lr, FileSystem as lt, BatchResult as m, AgentProfileSecurityPolicy as ma, StartupDiagnostics as mi, ProcessManager as mn, SandboxFleetTraceBundle as mr, FileUsageResult as mt, AccessPolicyRule as n, TerminalStreamToken as na, SessionBackendCredentials as ni, MkdirOptions as nn, SandboxFleetDriverTimings as nr, ExecResult as nt, BackendCapabilities as o, AgentProfileConnection as oa, SessionListOptions as oi, PermissionLevel as on, SandboxFleetMachineMeteredUsage as or, FileReadError as ot, BatchOptions as p, AgentProfileResources as pa, SshKeysManager as pi, ProcessLogEntry as pn, SandboxFleetToken as pr, FileUsageOptions as pt, DriverInfo as q, BatchTaskUsage as qi, SandboxConnection as qn, ScopedToken as qr, IntelligenceReportSubjectType as qt, AddUserOptions as r, AgentProfile$1 as ra, SessionEventStreamOptions as ri, NetworkConfig as rn, SandboxFleetInfo as rr, FileInfo as rt, BackendConfig as s, AgentProfileFileMount as sa, SessionMessage as si, PermissionsManager as sn, SandboxFleetMachineRecord as sr, FileReadResult as st, AcceleratorKind as t, TerminalStreamOptions as ta, SentSessionMessage as ti, MintScopedTokenOptions as tn, SandboxFleetDriverCapability as tr, ExecOptions as tt, BackendStatus as u, AgentProfilePermissionValue as ua, SnapshotInfo as ui, Process as un, SandboxFleetManifestMachine as ur, FileTreeFile as ut, BatchTaskResult as v, Capability as va, TaskOptions as vi, PromptInputPart as vn, SandboxFleetUsage as vr, FleetDispatchResultBufferOptions as vt, CodeLanguage as w, mergeAgentProfiles as wa, TaskSessionProfile as wi, ProvisionStep as wn, SandboxInfo as wr, FleetPromptDispatchResult as wt, ChunkedUploadResult as x, defineAgentProfile as xa, TaskSessionCommitResult as xi, ProvisionEvent as xn, SandboxFleetWorkspaceRestoreResult as xr, FleetExecDispatchResult as xt, BranchOptions as y, agentProfileSchema as ya, TaskResult as yi, PromptOptions as yn, SandboxFleetWorkspace as yr, FleetDispatchStreamOptions as yt, DevServerInfo as z, WaitForRolloutOptions as zi, RolloutScorer as zn, SandboxTerminalManager as zr, GpuLeaseStatus as zt };
|