@tangle-network/sandbox 0.11.1 → 0.12.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 +94 -16
- package/dist/agent/index.d.ts +3 -3
- package/dist/{client-D_67csnK.js → client-BCNrDjvA.js} +82 -18
- package/dist/{client-DBioX_CL.d.ts → client-iZbD-9Ks.d.ts} +2 -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-Bhx4EQca.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-CWeFm9Hj.js} +978 -57
- package/dist/{sandbox-BRoxCvpS.d.ts → sandbox-hbYwu_Ot.d.ts} +268 -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-C8CaT3tE.js} +70 -22
- package/dist/{types-D2C72ySk.d.ts → types-C67osezQ.d.ts} +584 -178
- 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
|
|
@@ -681,6 +1065,28 @@ interface CreateSandboxOptions {
|
|
|
681
1065
|
* @default true
|
|
682
1066
|
*/
|
|
683
1067
|
autoMaterializeProfileFiles?: boolean;
|
|
1068
|
+
/**
|
|
1069
|
+
* Auto-defer an inline `backend.profile`'s static corpus so it is delivered
|
|
1070
|
+
* once instead of on every turn. At create time the SDK strips inline
|
|
1071
|
+
* `resources.skills` from the create request (keeping the create body under
|
|
1072
|
+
* its wire cap), then primes the running sandbox with the full profile and
|
|
1073
|
+
* references it by hash (`backend.profileSha256`) on subsequent turns. The
|
|
1074
|
+
* handle still holds the full profile, so a cache miss transparently resends
|
|
1075
|
+
* it.
|
|
1076
|
+
*
|
|
1077
|
+
* When `false`, the full profile (skills included) rides the create request
|
|
1078
|
+
* and every turn — the legacy wire shape. Only applies to an inline
|
|
1079
|
+
* `AgentProfile` object on `backend.profile`, and is independent of
|
|
1080
|
+
* {@link autoMaterializeProfileFiles}.
|
|
1081
|
+
*
|
|
1082
|
+
* A turn only substitutes the hash reference when the outgoing profile's
|
|
1083
|
+
* content still matches what was primed: mutate the profile (or pass a
|
|
1084
|
+
* changed per-turn `backend.profile`) and that turn sends the full profile
|
|
1085
|
+
* inline again, so the runtime always runs the profile you passed.
|
|
1086
|
+
*
|
|
1087
|
+
* @default true
|
|
1088
|
+
*/
|
|
1089
|
+
autoDeferProfile?: boolean;
|
|
684
1090
|
}
|
|
685
1091
|
/**
|
|
686
1092
|
* Per-call overrides for {@link SandboxClient.create}.
|
|
@@ -783,6 +1189,12 @@ interface SandboxInfo {
|
|
|
783
1189
|
id: string;
|
|
784
1190
|
/** Human-readable name */
|
|
785
1191
|
name?: string;
|
|
1192
|
+
/** Control-plane identity of the currently published filesystem contents. */
|
|
1193
|
+
filesystemIncarnationId?: string;
|
|
1194
|
+
/** How the current filesystem contents were acquired. */
|
|
1195
|
+
filesystemIncarnationProvenance?: "fresh" | "restored" | "unknown";
|
|
1196
|
+
/** Whether this incarnation is safe for consumers to treat as authoritative. */
|
|
1197
|
+
filesystemIncarnationReadiness?: "transitioning" | "ready";
|
|
786
1198
|
/** Current status */
|
|
787
1199
|
status: SandboxStatus;
|
|
788
1200
|
/** Connection information */
|
|
@@ -890,6 +1302,33 @@ interface SandboxTerminalManager {
|
|
|
890
1302
|
list(): Promise<SandboxTerminalInfo[]>;
|
|
891
1303
|
get(sessionId: string): Promise<SandboxTerminalInfo | null>;
|
|
892
1304
|
}
|
|
1305
|
+
/** Options for `box.terminals.attach()`. */
|
|
1306
|
+
interface SandboxTerminalAttachOptions {
|
|
1307
|
+
/** Initial PTY geometry reported in the attach init frame. */
|
|
1308
|
+
cols?: number;
|
|
1309
|
+
rows?: number;
|
|
1310
|
+
/** Command to run when the connection id has no live PTY (default: shell). */
|
|
1311
|
+
command?: string;
|
|
1312
|
+
cwd?: string;
|
|
1313
|
+
env?: Record<string, string>;
|
|
1314
|
+
/**
|
|
1315
|
+
* Stream callbacks, bound before the socket opens. Register `onData` here:
|
|
1316
|
+
* a reattached PTY replays its buffered screen immediately after the
|
|
1317
|
+
* attach acknowledgement, so a handler added after `attach()` resolves
|
|
1318
|
+
* would miss the replayed frames.
|
|
1319
|
+
*/
|
|
1320
|
+
handlers?: TerminalStreamHandlers;
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* `box.terminals` — the REST terminal manager plus the live PTY attach
|
|
1324
|
+
* surface. `attach()` opens the terminal WebSocket (through the secured
|
|
1325
|
+
* sidecar proxy, with a short-lived scoped token minted per dial) as a
|
|
1326
|
+
* {@link TerminalStream}: reusing a connection id reattaches the existing
|
|
1327
|
+
* PTY and replays its history; a new id spawns a fresh shell (or `command`).
|
|
1328
|
+
*/
|
|
1329
|
+
interface SandboxTerminals extends SandboxTerminalManager {
|
|
1330
|
+
attach(connectionId: string, options?: SandboxTerminalAttachOptions): Promise<TerminalStream>;
|
|
1331
|
+
}
|
|
893
1332
|
/** Runtime-local agent profile. */
|
|
894
1333
|
interface SandboxRuntimeProfile {
|
|
895
1334
|
name: string;
|
|
@@ -1003,10 +1442,10 @@ interface ExecResult {
|
|
|
1003
1442
|
* Options for executing a command.
|
|
1004
1443
|
*/
|
|
1005
1444
|
interface ExecOptions {
|
|
1006
|
-
/** Working directory for the command.
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1445
|
+
/** Working directory for the command. It must resolve within the active
|
|
1446
|
+
* workspace; paths outside that boundary are rejected. When `sessionId`
|
|
1447
|
+
* is set, the runtime resolves the path against that task's isolated
|
|
1448
|
+
* workspace. */
|
|
1010
1449
|
cwd?: string;
|
|
1011
1450
|
/** Environment variables */
|
|
1012
1451
|
env?: Record<string, string>;
|
|
@@ -1744,6 +2183,8 @@ interface SessionInfo {
|
|
|
1744
2183
|
parentId?: string;
|
|
1745
2184
|
/** Current lifecycle state. */
|
|
1746
2185
|
status: SessionStatus;
|
|
2186
|
+
/** Most recent execution id, retained after completion for event replay. */
|
|
2187
|
+
latestExecutionId?: string;
|
|
1747
2188
|
/** Backend identifier (e.g. provider name). */
|
|
1748
2189
|
backend?: string;
|
|
1749
2190
|
/** Model id the session was created with. */
|
|
@@ -1833,17 +2274,19 @@ interface SendSessionMessageOptions {
|
|
|
1833
2274
|
timeoutMs?: number;
|
|
1834
2275
|
signal?: AbortSignal;
|
|
1835
2276
|
}
|
|
1836
|
-
/**
|
|
2277
|
+
/** Receipt returned after a session message is accepted for processing. */
|
|
1837
2278
|
interface SentSessionMessage {
|
|
1838
2279
|
info: {
|
|
1839
2280
|
id: string;
|
|
1840
|
-
role: "
|
|
1841
|
-
timestamp
|
|
2281
|
+
role: "assistant";
|
|
2282
|
+
timestamp: string;
|
|
1842
2283
|
};
|
|
1843
|
-
parts:
|
|
2284
|
+
parts: [];
|
|
2285
|
+
userMessageId: string;
|
|
2286
|
+
processing: true;
|
|
1844
2287
|
}
|
|
1845
2288
|
/** Canonical portable profile attached to a task session. */
|
|
1846
|
-
type TaskSessionProfile = AgentProfile & {
|
|
2289
|
+
type TaskSessionProfile = AgentProfile$1 & {
|
|
1847
2290
|
name: string;
|
|
1848
2291
|
};
|
|
1849
2292
|
/** Options for creating an isolated background task session. */
|
|
@@ -2081,21 +2524,24 @@ type TurnDriveResult = {
|
|
|
2081
2524
|
* capability tokens for browser-safe runtime access.
|
|
2082
2525
|
*/
|
|
2083
2526
|
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. */
|
|
2527
|
+
interface MintScopedTokenBase {
|
|
2528
|
+
/** TTL in minutes. Default 5; clamped to [1, 15]. */
|
|
2097
2529
|
ttlMinutes?: number;
|
|
2098
2530
|
}
|
|
2531
|
+
/** Options for `box.mintScopedToken()`, narrowed by consumer scope. */
|
|
2532
|
+
type MintScopedTokenOptions = (MintScopedTokenBase & {
|
|
2533
|
+
scope: "session"; /** Client-facing browser session ID. */
|
|
2534
|
+
sessionId: string; /** Actual runtime session ID used to filter the sandbox event stream. */
|
|
2535
|
+
runtimeSessionId: string;
|
|
2536
|
+
}) | (MintScopedTokenBase & {
|
|
2537
|
+
scope: "session-runtime";
|
|
2538
|
+
sessionId: string;
|
|
2539
|
+
runtimeSessionId?: never;
|
|
2540
|
+
}) | (MintScopedTokenBase & {
|
|
2541
|
+
scope: "project" | "read-only";
|
|
2542
|
+
sessionId?: never;
|
|
2543
|
+
runtimeSessionId?: never;
|
|
2544
|
+
});
|
|
2099
2545
|
/**
|
|
2100
2546
|
* Returned by `box.mintScopedToken()`. Use session/project tokens with
|
|
2101
2547
|
* `SessionGatewayClient`; use session-runtime/read-only tokens with
|
|
@@ -2294,145 +2740,6 @@ interface BatchResult {
|
|
|
2294
2740
|
/** Individual task results */
|
|
2295
2741
|
results: BatchTaskResult[];
|
|
2296
2742
|
}
|
|
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
2743
|
/**
|
|
2437
2744
|
* Stable worker identifier inside a sandbox fleet.
|
|
2438
2745
|
*
|
|
@@ -3377,7 +3684,7 @@ interface BackendConfig {
|
|
|
3377
3684
|
* Use a string for a named provider/backend profile, or an `AgentProfile`
|
|
3378
3685
|
* object for an inline provider-neutral profile definition.
|
|
3379
3686
|
*/
|
|
3380
|
-
profile?: string | AgentProfile;
|
|
3687
|
+
profile?: string | AgentProfile$1;
|
|
3381
3688
|
/**
|
|
3382
3689
|
* Model configuration override.
|
|
3383
3690
|
*/
|
|
@@ -3429,14 +3736,14 @@ interface BackendConfig {
|
|
|
3429
3736
|
/** Runtime session metadata used for attribution and workspace selection. */
|
|
3430
3737
|
metadata?: {
|
|
3431
3738
|
containerType?: string;
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3739
|
+
/**
|
|
3740
|
+
* Non-secret labels attached to execution traces.
|
|
3741
|
+
*
|
|
3742
|
+
* Maximum 32 entries; keys are at most 128 characters and values at most
|
|
3743
|
+
* 1024 characters. The Sandbox platform owns collector configuration and
|
|
3744
|
+
* credentials. Never put API keys, tokens, cookies, or user content here.
|
|
3745
|
+
*/
|
|
3746
|
+
traceAttributes?: Record<string, string>;
|
|
3440
3747
|
};
|
|
3441
3748
|
}
|
|
3442
3749
|
/**
|
|
@@ -3633,19 +3940,24 @@ interface EgressPolicy {
|
|
|
3633
3940
|
/** Egress mode */
|
|
3634
3941
|
mode: "open" | "strict" | "blocked";
|
|
3635
3942
|
/**
|
|
3636
|
-
*
|
|
3637
|
-
*
|
|
3943
|
+
* Allowed domains in strict mode. Platform defaults and credential-derived
|
|
3944
|
+
* domains are also included unless `includeImplicitDomains` is false.
|
|
3638
3945
|
* Ignored in `open` and `blocked` modes.
|
|
3639
3946
|
*/
|
|
3640
3947
|
allowDomains?: string[];
|
|
3948
|
+
/**
|
|
3949
|
+
* Include platform and credential-derived domains in strict mode.
|
|
3950
|
+
* Defaults to true. Set false when `allowDomains` must be the complete list.
|
|
3951
|
+
*/
|
|
3952
|
+
includeImplicitDomains?: boolean;
|
|
3641
3953
|
/**
|
|
3642
3954
|
* Denied domains. Only enforced when the proxy supports denylist transforms.
|
|
3643
|
-
* @deprecated
|
|
3955
|
+
* @deprecated Not supported by the current proxy.
|
|
3644
3956
|
*/
|
|
3645
3957
|
denyDomains?: string[];
|
|
3646
3958
|
/**
|
|
3647
3959
|
* Allowed CIDR ranges. Only enforced when the proxy supports CIDR passthrough.
|
|
3648
|
-
* @deprecated
|
|
3960
|
+
* @deprecated Not supported by the current proxy.
|
|
3649
3961
|
*/
|
|
3650
3962
|
allowCidrs?: string[];
|
|
3651
3963
|
}
|
|
@@ -3996,7 +4308,7 @@ interface BackendManager {
|
|
|
3996
4308
|
*
|
|
3997
4309
|
* Optional while backends adopt the public `AgentProfile` contract.
|
|
3998
4310
|
*/
|
|
3999
|
-
validateProfile?(profile: AgentProfile): Promise<AgentProfileValidationResult>;
|
|
4311
|
+
validateProfile?(profile: AgentProfile$1): Promise<AgentProfileValidationResult>;
|
|
4000
4312
|
/** Restart the backend agent */
|
|
4001
4313
|
restart(): Promise<void>;
|
|
4002
4314
|
}
|
|
@@ -4029,6 +4341,28 @@ interface ProcessSpawnOptions {
|
|
|
4029
4341
|
interface ExactProcessSpawnOptions extends ProcessSpawnOptions {
|
|
4030
4342
|
/** UTF-8 bytes written before stdin is closed. */
|
|
4031
4343
|
stdin?: string;
|
|
4344
|
+
/**
|
|
4345
|
+
* Whether to extend the sandbox runtime environment.
|
|
4346
|
+
* Set to `false` when every process input must be supplied explicitly.
|
|
4347
|
+
* The executable must then be absolute unless `env.PATH` is supplied.
|
|
4348
|
+
*
|
|
4349
|
+
* @default true
|
|
4350
|
+
*/
|
|
4351
|
+
inheritEnv?: boolean;
|
|
4352
|
+
/**
|
|
4353
|
+
* Opaque, non-secret launch identity.
|
|
4354
|
+
* Repeating it with the same exact launch returns the retained process record.
|
|
4355
|
+
*/
|
|
4356
|
+
idempotencyKey?: string;
|
|
4357
|
+
/**
|
|
4358
|
+
* Minimum terminal-record retention after exit.
|
|
4359
|
+
* Requires {@link idempotencyKey}; unsupported values fail before launch.
|
|
4360
|
+
*/
|
|
4361
|
+
retentionMs?: number;
|
|
4362
|
+
}
|
|
4363
|
+
/** Select retained process records by their exact-process launch identity. */
|
|
4364
|
+
interface ProcessListOptions {
|
|
4365
|
+
idempotencyKey?: string;
|
|
4032
4366
|
}
|
|
4033
4367
|
/**
|
|
4034
4368
|
* Options for running Python code.
|
|
@@ -4055,6 +4389,8 @@ interface RunCodeOptions {
|
|
|
4055
4389
|
interface ProcessStatus {
|
|
4056
4390
|
/** Process ID */
|
|
4057
4391
|
pid: number;
|
|
4392
|
+
/** Opaque exact-process launch identity when one was supplied. */
|
|
4393
|
+
idempotencyKey?: string;
|
|
4058
4394
|
/** Command that was executed */
|
|
4059
4395
|
command: string;
|
|
4060
4396
|
/** Working directory */
|
|
@@ -4077,6 +4413,33 @@ interface ProcessInfo extends ProcessStatus {
|
|
|
4077
4413
|
/** Environment variables used */
|
|
4078
4414
|
env?: Record<string, string>;
|
|
4079
4415
|
}
|
|
4416
|
+
/** A development server started and tracked by the sandbox runtime. */
|
|
4417
|
+
interface DevServerInfo {
|
|
4418
|
+
/** Supervisor process ID. */
|
|
4419
|
+
pid: number;
|
|
4420
|
+
/** Detected project family, such as node-npm or rust-cargo. */
|
|
4421
|
+
family: string;
|
|
4422
|
+
/** Command managed by the runtime. */
|
|
4423
|
+
command: string;
|
|
4424
|
+
/** Canonical workspace root used for project detection. */
|
|
4425
|
+
workspaceRoot: string;
|
|
4426
|
+
/** When the managed process started. */
|
|
4427
|
+
startedAt: Date;
|
|
4428
|
+
/** True when this call started the process; false when it reused one. */
|
|
4429
|
+
startedNow: boolean;
|
|
4430
|
+
/** True when dependency installation ran before startup. */
|
|
4431
|
+
installRan: boolean;
|
|
4432
|
+
/** Time spent installing dependencies during this call. */
|
|
4433
|
+
installDurationMs: number;
|
|
4434
|
+
/** Assigned listening port, once the server is ready. */
|
|
4435
|
+
port?: number;
|
|
4436
|
+
}
|
|
4437
|
+
interface EnsureDevServerOptions {
|
|
4438
|
+
/** Agent session whose isolated workspace contains the project. */
|
|
4439
|
+
sessionId?: string;
|
|
4440
|
+
/** Project directory inside the selected workspace. Defaults to the workspace root. */
|
|
4441
|
+
cwd?: string;
|
|
4442
|
+
}
|
|
4080
4443
|
/**
|
|
4081
4444
|
* A log entry from process stdout/stderr.
|
|
4082
4445
|
*/
|
|
@@ -4223,6 +4586,12 @@ interface Process {
|
|
|
4223
4586
|
* ```
|
|
4224
4587
|
*/
|
|
4225
4588
|
interface ProcessManager {
|
|
4589
|
+
/**
|
|
4590
|
+
* Detect the workspace project and idempotently start its development server.
|
|
4591
|
+
* The runtime owns installation, process tracking, port assignment, and
|
|
4592
|
+
* stale-Vite compatibility handling.
|
|
4593
|
+
*/
|
|
4594
|
+
ensureDevServer(options?: EnsureDevServerOptions): Promise<DevServerInfo>;
|
|
4226
4595
|
/**
|
|
4227
4596
|
* Spawn a process without blocking.
|
|
4228
4597
|
* Returns immediately with a Process handle.
|
|
@@ -4248,7 +4617,7 @@ interface ProcessManager {
|
|
|
4248
4617
|
*
|
|
4249
4618
|
* @returns Array of process status objects
|
|
4250
4619
|
*/
|
|
4251
|
-
list(): Promise<ProcessStatus[]>;
|
|
4620
|
+
list(options?: ProcessListOptions): Promise<ProcessStatus[]>;
|
|
4252
4621
|
/**
|
|
4253
4622
|
* Get a process by PID.
|
|
4254
4623
|
*
|
|
@@ -4442,6 +4811,36 @@ interface FileTreeResult {
|
|
|
4442
4811
|
truncated: boolean;
|
|
4443
4812
|
};
|
|
4444
4813
|
}
|
|
4814
|
+
/** Options for measuring aggregate workspace storage usage. */
|
|
4815
|
+
interface FileUsageOptions {
|
|
4816
|
+
/** Task session id for session-specific workspace isolation. */
|
|
4817
|
+
sessionId?: string;
|
|
4818
|
+
}
|
|
4819
|
+
/**
|
|
4820
|
+
* Aggregate apparent storage usage for a customer workspace.
|
|
4821
|
+
*
|
|
4822
|
+
* Hidden files, dependency trees, caches, and build output are included.
|
|
4823
|
+
* Runtime-owned `.sidecar` directories are excluded, and symlinks are counted
|
|
4824
|
+
* by their own metadata without following their targets.
|
|
4825
|
+
*/
|
|
4826
|
+
interface FileUsageResult {
|
|
4827
|
+
/** Scanned root, relative to the workspace when applicable. */
|
|
4828
|
+
root: string;
|
|
4829
|
+
/** Sum of regular-file and symlink apparent sizes. */
|
|
4830
|
+
sizeBytes: number;
|
|
4831
|
+
/** Number of regular files and symlinks. */
|
|
4832
|
+
fileCount: number;
|
|
4833
|
+
/** Number of customer-owned directories, excluding the root. */
|
|
4834
|
+
directoryCount: number;
|
|
4835
|
+
/** Latest observed modification time as Unix milliseconds. */
|
|
4836
|
+
lastModifiedMs: number;
|
|
4837
|
+
/** Time spent scanning the workspace. */
|
|
4838
|
+
scanDurationMs: number;
|
|
4839
|
+
/** False when limits or unreadable entries prevented a complete result. */
|
|
4840
|
+
complete: boolean;
|
|
4841
|
+
/** Entries skipped because their metadata could not be read. */
|
|
4842
|
+
skippedEntries: number;
|
|
4843
|
+
}
|
|
4445
4844
|
/** File content and metadata returned by a batch read. */
|
|
4446
4845
|
interface FileReadResult {
|
|
4447
4846
|
path: string;
|
|
@@ -4690,6 +5089,13 @@ interface FileSystem {
|
|
|
4690
5089
|
readBatch(paths: string[], options?: FileReadBatchOptions): Promise<FileReadBatchResult>;
|
|
4691
5090
|
/** Recursively scan the workspace and return file metadata. */
|
|
4692
5091
|
tree(path: string, options?: FileTreeOptions): Promise<FileTreeResult>;
|
|
5092
|
+
/**
|
|
5093
|
+
* Measure complete aggregate workspace usage without returning a file list.
|
|
5094
|
+
* Unlike {@link FileSystem.tree}, this includes hidden files, dependencies,
|
|
5095
|
+
* caches, and build output. Check `complete` before using the result for
|
|
5096
|
+
* accounting or quota decisions.
|
|
5097
|
+
*/
|
|
5098
|
+
usage(path: string, options?: FileUsageOptions): Promise<FileUsageResult>;
|
|
4693
5099
|
/**
|
|
4694
5100
|
* Write string content to a file.
|
|
4695
5101
|
* For binary files, use upload() instead.
|
|
@@ -5001,4 +5407,4 @@ interface CodeExecutionOptions {
|
|
|
5001
5407
|
idempotencyKey?: string;
|
|
5002
5408
|
}
|
|
5003
5409
|
//#endregion
|
|
5004
|
-
export {
|
|
5410
|
+
export { EventStreamOptions as $, TerminalStreamOptions as $i, SandboxFleetDispatchFailureClass as $n, SendSessionMessageRequest as $r, ListSandboxOptions as $t, CreateIntelligenceReportOptions as A, ToolsConfig as Ai, ReapExpiredSandboxFleetsResult as An, SandboxResources as Ar, GitDiff as At, DirectoryPermission as B, WriteManyOptions as Bi, RolloutStartResult as Bn, SandboxTerminals as Br, GpuType as Bt, CodeExecutionResult as C, validateAgentProfileSecurity as Ca, TaskSessionProfile as Ci, ProvisionStatus as Cn, SandboxInfo as Cr, FleetPromptDispatchOptions as Ct, CommitTaskSessionOptions as D, TeePublicKey as Di, PublishPublicTemplateOptions as Dn, SandboxPortPreviewLink as Dr, GitBranch as Dt, CodeResultPart as E, TeeAttestationResponse as Ei, PublicTemplateVersionInfo as En, SandboxPortBinding as Er, GitAuth as Et, CreateSandboxOptions as F, UsageInfo as Fi, ResumeOptions as Fn, SandboxTerminalAttachOptions as Fr, GpuLeaseExecOptions as Ft, DriveTurnOptions as G, BatchTaskUsage as Gi, SSHCredentials as Gn, SandboxUser as Gr, IntelligenceReportBudget as Gt, DispatchedSession as H, BatchEvent as Hi, RolloutTurnPart as Hn, SandboxTraceEvent as Hr, HostAgentRuntimeBackend as Ht, CreateSessionOptions as I, WaitForOptions as Ii, Rollout as In, SandboxTerminalCreateOptions as Ir, GpuLeaseExecResult as It, DriverType as J, TerminalReadyInfo as Ji, SandboxEnvironment as Jn, SearchMatch as Jr, IntelligenceReportWindow as Jt, DriverConfig as K, TERMINAL_WS_ECHO_SUBPROTOCOL as Ki, SandboxClientConfig as Kn, ScopedToken as Kr, IntelligenceReportCompareTo as Kt, CreateTaskSessionOptions as L, WaitForRolloutOptions as Li, RolloutChildResult as Ln, SandboxTerminalInfo as Lr, GpuLeaseManager as Lt, CreateSandboxFleetOptions as M, UpdateUserOptions as Mi, ReconcileSandboxFleetsResult as Mn, SandboxRuntimeProfile as Mr, GpuLease as Mt, CreateSandboxFleetTokenOptions as N, UploadOptions as Ni, RenameOptions as Nn, SandboxRuntimeProfileList as Nr, GpuLeaseBilling as Nt, CompletedTurnResult as O, TeePublicKeyResponse as Oi, PublishPublicTemplateVersionOptions as On, SandboxProfileSummary as Or, GitCommit as Ot, CreateSandboxFleetWithCoordinatorOptions as P, UploadProgress as Pi, RestoreSnapshotOptions as Pn, SandboxStatus as Pr, GpuLeaseCommandResult as Pt, EnsureDevServerOptions as Q, TerminalStreamHandlers as Qi, SandboxFleetCostEstimate as Qn, SendSessionMessageOptions as Qr, ListSandboxFleetOptions as Qt, DeleteOptions as R, WriteFileOptions as Ri, RolloutOptions as Rn, SandboxTerminalManager as Rr, GpuLeaseProviderName as Rt, CodeExecutionOptions as S, mergeAgentProfiles as Sa, TaskSessionInfo as Si, ProvisionResult as Sn, SandboxFleetWorkspaceSnapshotResult as Sr, FleetMachineId as St, CodeResult as T, TeeAttestationReport as Ti, PublicTemplateInfo as Tn, SandboxPermissionsConfig as Tr, GPU_LEASE_PROVIDER_NAMES as Tt, DownloadOptions as U, BatchEventDataMap as Ui, RunCodeOptions as Un, SandboxTraceExport as Ur, InstalledTool as Ut, DispatchPromptOptions as V, BatchBackendStats as Vi, RolloutStatus as Vn, SandboxTraceBundle as Vr, HostAgentDriverConfig as Vt, DownloadProgress as W, BatchSidecarGroup as Wi, SSHCommandDescriptor as Wn, SandboxTraceOptions as Wr, IntelligenceReport as Wt, EgressManager as X, TerminalStreamAuthFormat as Xi, SandboxFleetArtifact as Xn, SecretInfo as Xr, ListMessagesOptions as Xt, DurablePlan as Y, TerminalStream as Yi, SandboxEvent as Yn, SearchOptions as Yr, JsonValue as Yt, EgressPolicy as Z, TerminalStreamError as Zi, SandboxFleetArtifactSpec as Zn, SecretsManager as Zr, ListOptions as Zt, BatchTask as _, agentProfileSchema as _a, TaskOptions as _i, ProcessStatus as _n, SandboxFleetTraceOptions as _r, FleetDispatchResultBuffer as _t, AttachSandboxFleetMachineOptions as a, AgentProfileFileMount as aa, SessionListOptions as ai, NonHostAgentDriverConfig as an, SandboxFleetMachine as ar, FileReadBatchResult as at, ChunkedUploadOptions as b, defineGitHubResource as ba, TaskSessionCommitResult as bi, PromptResult as bn, SandboxFleetWorkspaceReconcileResult as br, FleetExecDispatchOptions as bt, BackendInfo as c, AgentProfilePermissionValue as ca, SessionStatus as ci, PreviewLinkInfo as cn, SandboxFleetMachineSpec as cr, FileRenameResult as ct, BackendType as d, AgentProfileResources as da, SnapshotResult as di, ProcessInfo as dn, SandboxFleetOperationsSummary as dr, FileTreeOptions as dt, TerminalStreamToken as ea, SentSessionMessage as ei, McpServerConfig as en, SandboxFleetDispatchResponse as er, ExactProcessSpawnOptions as et, BatchBackend as f, AgentProfileSecurityPolicy as fa, SshKeysManager as fi, ProcessListOptions as fn, SandboxFleetPolicy as fr, FileTreeResult as ft, BatchRunRequest as g, Capability as ga, SubscriptionInfo as gi, ProcessSpawnOptions as gn, SandboxFleetTraceExport as gr, FleetDispatchCancelResult as gt, BatchRunOptions as h, AgentSubagentProfile as ha, StorageConfig as hi, ProcessSignal as hn, SandboxFleetTraceEvent as hr, FileWriteResult as ht, AttachGpuLeaseOptions as i, AgentProfileConnection as ia, SessionInfo as ii, NetworkManager as in, SandboxFleetIntelligenceEnvelope as ir, FileReadBatchOptions as it, CreateRequestOptions as j, TurnDriveResult as ji, ReconcileSandboxFleetsOptions as jn, SandboxRuntimeHealth as jr, GitStatus as jt, CreateGpuLeaseOptions as k, TokenRefreshHandler as ki, ReapExpiredSandboxFleetsOptions as kn, SandboxResourceUsage as kr, GitConfig as kt, BackendManager as l, AgentProfilePrompt as la, SnapshotInfo as li, PreviewLinkManager as ln, SandboxFleetManifest as lr, FileSystem as lt, BatchResult as m, AgentProfileValidationResult as ma, StartupOperation as mi, ProcessManager as mn, SandboxFleetTraceBundle as mr, FileUsageResult as mt, AccessPolicyRule as n, AgentProfileCapabilities as na, SessionEventStreamOptions as ni, MkdirOptions as nn, SandboxFleetDriverTimings as nr, ExecResult as nt, BackendCapabilities as o, AgentProfileMcpServer as oa, SessionMessage as oi, PermissionLevel as on, SandboxFleetMachineMeteredUsage as or, FileReadError as ot, BatchOptions as p, AgentProfileValidationIssue as pa, StartupDiagnostics as pi, ProcessLogEntry as pn, SandboxFleetToken as pr, FileUsageOptions as pt, DriverInfo as q, TerminalExitInfo as qi, SandboxConnection as qn, ScopedTokenScope as qr, IntelligenceReportSubjectType as qt, AddUserOptions as r, AgentProfileConfidential as ra, SessionForkOptions as ri, NetworkConfig as rn, SandboxFleetInfo as rr, FileInfo as rt, BackendConfig as s, AgentProfileModelHints as sa, SessionMessageInputPart as si, PermissionsManager as sn, SandboxFleetMachineRecord as sr, FileReadResult as st, AcceleratorKind as t, AgentProfile$1 as ta, SessionBackendCredentials as ti, MintScopedTokenOptions as tn, SandboxFleetDriverCapability as tr, ExecOptions as tt, BackendStatus as u, AgentProfileResourceRef as ua, SnapshotOptions as ui, Process as un, SandboxFleetManifestMachine as ur, FileTreeFile as ut, BatchTaskResult as v, capabilitySchema as va, TaskResult as vi, PromptInputPart as vn, SandboxFleetUsage as vr, FleetDispatchResultBufferOptions as vt, CodeLanguage as w, TeeAttestationOptions as wi, ProvisionStep as wn, SandboxIntelligenceEnvelope as wr, FleetPromptDispatchResult as wt, ChunkedUploadResult as x, defineInlineResource as xa, TaskSessionFileChange as xi, ProvisionEvent as xn, SandboxFleetWorkspaceRestoreResult as xr, FleetExecDispatchResult as xt, BranchOptions as y, defineAgentProfile as ya, TaskSessionChanges as yi, PromptOptions as yn, SandboxFleetWorkspace as yr, FleetDispatchStreamOptions as yt, DevServerInfo as z, WriteManyFile as zi, RolloutScorer as zn, SandboxTerminalRequestOptions as zr, GpuLeaseStatus as zt };
|