@keska/sandbox 0.0.0-stage → 0.40.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/LICENSE +190 -0
- package/README.md +38 -2
- package/dist/index.d.ts +1801 -0
- package/dist/index.js +5666 -0
- package/package.json +40 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1801 @@
|
|
|
1
|
+
import { Interceptor } from '@connectrpc/connect';
|
|
2
|
+
import WebSocket from 'ws';
|
|
3
|
+
|
|
4
|
+
type CredentialsDict = {
|
|
5
|
+
type?: string;
|
|
6
|
+
client_id?: string;
|
|
7
|
+
clientId?: string;
|
|
8
|
+
client_secret?: string;
|
|
9
|
+
clientSecret?: string;
|
|
10
|
+
token_url?: string;
|
|
11
|
+
tokenUrl?: string;
|
|
12
|
+
api_url?: string;
|
|
13
|
+
apiUrl?: string;
|
|
14
|
+
scopes?: string[] | string;
|
|
15
|
+
token?: string;
|
|
16
|
+
access_token?: string;
|
|
17
|
+
};
|
|
18
|
+
type CredentialsInput = {
|
|
19
|
+
credentials?: CredentialsDict | TokenProvider;
|
|
20
|
+
credentialsFile?: string;
|
|
21
|
+
clientId?: string;
|
|
22
|
+
clientSecret?: string;
|
|
23
|
+
tokenUrl?: string;
|
|
24
|
+
token?: string;
|
|
25
|
+
};
|
|
26
|
+
/** Source of `Authorization: Bearer` for Connect-ES calls. */
|
|
27
|
+
type TokenProvider = {
|
|
28
|
+
apiUrl: string;
|
|
29
|
+
authorizationHeader(): Promise<Record<string, string>>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Typed records returned by the TypeScript SDK.
|
|
33
|
+
*
|
|
34
|
+
* Callers construct `HostBind` (and `CREDENTIAL`) when creating a
|
|
35
|
+
* CredentialPolicy. Everything else is returned by `Client` / `Sandbox`.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** Sandbox lifecycle. Deleted is not a status: the record is gone. */
|
|
39
|
+
type SandboxStatus$1 = "Pending" | "Ready" | "Sleeping" | "Finished" | "Deleting";
|
|
40
|
+
type ResourceUsage = {
|
|
41
|
+
memoryCurrentBytes: number;
|
|
42
|
+
cpuUsageUsec: number;
|
|
43
|
+
cpuMillicores: number;
|
|
44
|
+
};
|
|
45
|
+
/** Live sandbox record from create, open, get, or park. */
|
|
46
|
+
type SandboxInfo = {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
status: SandboxStatus$1;
|
|
50
|
+
image: string;
|
|
51
|
+
env: Record<string, string>;
|
|
52
|
+
workdir: string;
|
|
53
|
+
labels: Record<string, string>;
|
|
54
|
+
tags: string[];
|
|
55
|
+
/** How the sandbox reaches the network. */
|
|
56
|
+
net: string;
|
|
57
|
+
volumeId: string;
|
|
58
|
+
fromSnapshotId: string;
|
|
59
|
+
lifetimeRemainingSec: number | null;
|
|
60
|
+
idleTimeoutRemainingSec: number | null;
|
|
61
|
+
/** CPU given to the sandbox, in thousandths of a core. */
|
|
62
|
+
cpuMillicores: number;
|
|
63
|
+
/** Guest memory in bytes. */
|
|
64
|
+
memoryBytes: number;
|
|
65
|
+
/** Writable state on top of the image, in bytes. The image is not counted. */
|
|
66
|
+
diskBytes: number;
|
|
67
|
+
lifetimeSec: number;
|
|
68
|
+
idleTimeoutSec: number;
|
|
69
|
+
exitCode: number | null;
|
|
70
|
+
/** CPU and memory the sandbox has used. */
|
|
71
|
+
usage: ResourceUsage | null;
|
|
72
|
+
/** The worker holding this sandbox cannot be reached. The status stays the last recorded value. */
|
|
73
|
+
workerUnreachable: boolean;
|
|
74
|
+
};
|
|
75
|
+
/** One sandbox from `listSandboxes`. Not a live read of the sandbox. */
|
|
76
|
+
type SandboxSummary = {
|
|
77
|
+
id: string;
|
|
78
|
+
status: SandboxStatus$1;
|
|
79
|
+
image: string;
|
|
80
|
+
name: string;
|
|
81
|
+
labels: Record<string, string>;
|
|
82
|
+
tags: string[];
|
|
83
|
+
createdAt: string;
|
|
84
|
+
usage: ResourceUsage | null;
|
|
85
|
+
/** The worker holding this sandbox cannot be reached. The status stays the last recorded value. */
|
|
86
|
+
workerUnreachable: boolean;
|
|
87
|
+
};
|
|
88
|
+
type SandboxList = {
|
|
89
|
+
sandboxes: SandboxSummary[];
|
|
90
|
+
nextPageToken: string;
|
|
91
|
+
};
|
|
92
|
+
/** Outcome of `run`. stdout and stderr are text. A non-zero exit is still a result. */
|
|
93
|
+
type ExecResult = {
|
|
94
|
+
exitCode: number;
|
|
95
|
+
stdout: string;
|
|
96
|
+
stderr: string;
|
|
97
|
+
};
|
|
98
|
+
/** `run` with `text: false`. stdout and stderr are the raw guest bytes. */
|
|
99
|
+
type ExecBytesResult = {
|
|
100
|
+
exitCode: number;
|
|
101
|
+
stdout: Buffer;
|
|
102
|
+
stderr: Buffer;
|
|
103
|
+
};
|
|
104
|
+
/** Guest process record (`running` / `exited`). */
|
|
105
|
+
type Process = {
|
|
106
|
+
id: string;
|
|
107
|
+
sandboxId: string;
|
|
108
|
+
status: string;
|
|
109
|
+
serviceName: string;
|
|
110
|
+
exitCode: number | null;
|
|
111
|
+
};
|
|
112
|
+
type ProcessList = {
|
|
113
|
+
processes: Process[];
|
|
114
|
+
};
|
|
115
|
+
type LogStream$1 = "stdout" | "stderr" | "event";
|
|
116
|
+
type LogEntry = {
|
|
117
|
+
/** Lines already written carry a timestamp. Live lines do not. */
|
|
118
|
+
timestamp: string | null;
|
|
119
|
+
processId: string;
|
|
120
|
+
stream: LogStream$1;
|
|
121
|
+
line: string;
|
|
122
|
+
};
|
|
123
|
+
type LogPage = {
|
|
124
|
+
entries: LogEntry[];
|
|
125
|
+
nextPageToken: string;
|
|
126
|
+
};
|
|
127
|
+
/** Immutable pin of the writable layer (digest + optional labels). */
|
|
128
|
+
type Snapshot = {
|
|
129
|
+
id: string;
|
|
130
|
+
sourceSandboxId: string;
|
|
131
|
+
name: string;
|
|
132
|
+
labels: Record<string, string>;
|
|
133
|
+
digest: string;
|
|
134
|
+
sizeBytes: number;
|
|
135
|
+
image: string;
|
|
136
|
+
createdAt: string;
|
|
137
|
+
};
|
|
138
|
+
type SnapshotList = {
|
|
139
|
+
snapshots: Snapshot[];
|
|
140
|
+
nextPageToken: string;
|
|
141
|
+
};
|
|
142
|
+
/** Named disk bind-mounted at the sandbox workdir. Exclusive attach at create. */
|
|
143
|
+
type Volume = {
|
|
144
|
+
id: string;
|
|
145
|
+
attachedSandboxId: string;
|
|
146
|
+
name: string;
|
|
147
|
+
digest: string;
|
|
148
|
+
sizeBytes: number;
|
|
149
|
+
labels: Record<string, string>;
|
|
150
|
+
};
|
|
151
|
+
type VolumeList = {
|
|
152
|
+
volumes: Volume[];
|
|
153
|
+
nextPageToken: string;
|
|
154
|
+
};
|
|
155
|
+
/** One policy host. Guest dials `https://<host>/…`; the platform injects the secret. */
|
|
156
|
+
type HostBind = {
|
|
157
|
+
secret: string;
|
|
158
|
+
headers?: Record<string, string>;
|
|
159
|
+
query?: Record<string, string>;
|
|
160
|
+
};
|
|
161
|
+
/** Visitor credential for one guest HTTP port. token is set only on create. */
|
|
162
|
+
declare class HTTPGrant {
|
|
163
|
+
readonly id: string;
|
|
164
|
+
readonly sandboxId: string;
|
|
165
|
+
readonly port: number;
|
|
166
|
+
readonly expiresAt: string;
|
|
167
|
+
readonly token: string;
|
|
168
|
+
constructor(id: string, sandboxId: string, port: number, expiresAt: string, token: string);
|
|
169
|
+
/** Header for the guest URL. This grant opens one sandbox port. Empty when `token` is empty. */
|
|
170
|
+
getHeaders(): Record<string, string>;
|
|
171
|
+
}
|
|
172
|
+
/** Project secret metadata. Value is never returned. */
|
|
173
|
+
type Secret = {
|
|
174
|
+
name: string;
|
|
175
|
+
createdAt: string;
|
|
176
|
+
updatedAt: string;
|
|
177
|
+
};
|
|
178
|
+
type SecretList = {
|
|
179
|
+
secrets: Secret[];
|
|
180
|
+
nextPageToken: string;
|
|
181
|
+
};
|
|
182
|
+
/** Credential policy. The guest dials `https://<host>/…`, the platform injects the secret, and a tag attaches it. */
|
|
183
|
+
type CredentialPolicy = {
|
|
184
|
+
id: string;
|
|
185
|
+
name: string;
|
|
186
|
+
document: Record<string, unknown> | null;
|
|
187
|
+
hostCount: number;
|
|
188
|
+
referencedSecretNames: string[];
|
|
189
|
+
attachmentCount: number;
|
|
190
|
+
createdAt: string;
|
|
191
|
+
updatedAt: string;
|
|
192
|
+
};
|
|
193
|
+
/** A tag. Create it before passing its name to `create`. */
|
|
194
|
+
type Tag = {
|
|
195
|
+
id: string;
|
|
196
|
+
name: string;
|
|
197
|
+
policyId: string;
|
|
198
|
+
attachmentCount: number;
|
|
199
|
+
createdAt: string;
|
|
200
|
+
updatedAt: string;
|
|
201
|
+
};
|
|
202
|
+
type TagList = {
|
|
203
|
+
tags: Tag[];
|
|
204
|
+
nextPageToken: string;
|
|
205
|
+
};
|
|
206
|
+
type ImageKind = "platform" | "project" | "";
|
|
207
|
+
/** Catalog row. `name` is the customer name; registry URLs are never returned. */
|
|
208
|
+
type Image = {
|
|
209
|
+
name: string;
|
|
210
|
+
kind: ImageKind;
|
|
211
|
+
digest: string;
|
|
212
|
+
updatedAt: string;
|
|
213
|
+
};
|
|
214
|
+
type ImageList = {
|
|
215
|
+
images: Image[];
|
|
216
|
+
nextPageToken: string;
|
|
217
|
+
};
|
|
218
|
+
/** Falco/IDS source class. Public SDK names; wire is SECURITY_SOURCE_CLASS_*. */
|
|
219
|
+
declare const SecuritySourceClass: {
|
|
220
|
+
readonly unspecified: "unspecified";
|
|
221
|
+
readonly exec: "exec";
|
|
222
|
+
readonly filesystem: "filesystem";
|
|
223
|
+
readonly network: "network";
|
|
224
|
+
};
|
|
225
|
+
type SecuritySourceClassName = (typeof SecuritySourceClass)[keyof typeof SecuritySourceClass];
|
|
226
|
+
type AVPolicy = {
|
|
227
|
+
enabled: boolean;
|
|
228
|
+
scanners: string[];
|
|
229
|
+
skipDbUpdate: boolean;
|
|
230
|
+
workScanIntervalMs: number;
|
|
231
|
+
minSeverity: string[];
|
|
232
|
+
ignoreUnfixed: boolean;
|
|
233
|
+
};
|
|
234
|
+
/** IDS policy. allowedSources are alert groups. allowedRules filters Falco's own rule names and does not select a rules file. */
|
|
235
|
+
type IDSPolicy = {
|
|
236
|
+
enabled: boolean;
|
|
237
|
+
allowedSources: SecuritySourceClassName[];
|
|
238
|
+
allowedRules: string[];
|
|
239
|
+
blockedRules: string[];
|
|
240
|
+
minPriority: string;
|
|
241
|
+
};
|
|
242
|
+
type PolicyNodeAck = {
|
|
243
|
+
nodeId: string;
|
|
244
|
+
ackedAtUnix: number;
|
|
245
|
+
error: string;
|
|
246
|
+
};
|
|
247
|
+
type PolicyRollout = {
|
|
248
|
+
revision: number;
|
|
249
|
+
expectedNodes: string[];
|
|
250
|
+
missingNodes: string[];
|
|
251
|
+
acks: PolicyNodeAck[];
|
|
252
|
+
complete: boolean;
|
|
253
|
+
hubUnavailable: boolean;
|
|
254
|
+
};
|
|
255
|
+
/** Named AV+IDS document. Bind with Tag.securityPolicy. */
|
|
256
|
+
type SecurityPolicy = {
|
|
257
|
+
id: string;
|
|
258
|
+
name: string;
|
|
259
|
+
av: AVPolicy;
|
|
260
|
+
ids: IDSPolicy;
|
|
261
|
+
preset: string;
|
|
262
|
+
attachmentCount: number;
|
|
263
|
+
createdAt: string;
|
|
264
|
+
updatedAt: string;
|
|
265
|
+
};
|
|
266
|
+
type ResourcePolicy = {
|
|
267
|
+
id: string;
|
|
268
|
+
name: string;
|
|
269
|
+
cpuMillicores: number;
|
|
270
|
+
memoryBytes: number;
|
|
271
|
+
diskBytes: number;
|
|
272
|
+
createdAt: string;
|
|
273
|
+
updatedAt: string;
|
|
274
|
+
};
|
|
275
|
+
type PolicySection = {
|
|
276
|
+
kind: "credential" | "security" | "resource" | "";
|
|
277
|
+
ref: string;
|
|
278
|
+
};
|
|
279
|
+
type Policy = {
|
|
280
|
+
id: string;
|
|
281
|
+
name: string;
|
|
282
|
+
sections: PolicySection[];
|
|
283
|
+
attachmentCount: number;
|
|
284
|
+
credential: CredentialPolicy | null;
|
|
285
|
+
security: SecurityPolicy | null;
|
|
286
|
+
resources: ResourcePolicy | null;
|
|
287
|
+
createdAt: string;
|
|
288
|
+
updatedAt: string;
|
|
289
|
+
};
|
|
290
|
+
type PolicyList = {
|
|
291
|
+
policies: Policy[];
|
|
292
|
+
nextPageToken: string;
|
|
293
|
+
};
|
|
294
|
+
type PolicyMutation = {
|
|
295
|
+
policy: Policy;
|
|
296
|
+
avRollout: PolicyRollout;
|
|
297
|
+
idsRollout: PolicyRollout;
|
|
298
|
+
};
|
|
299
|
+
/** One file or directory from `ls` or `stat`. */
|
|
300
|
+
type FileInfo = {
|
|
301
|
+
name: string;
|
|
302
|
+
path: string;
|
|
303
|
+
type: string;
|
|
304
|
+
size: number;
|
|
305
|
+
mtimeMs: number;
|
|
306
|
+
};
|
|
307
|
+
type FileList = {
|
|
308
|
+
entries: FileInfo[];
|
|
309
|
+
};
|
|
310
|
+
type StreamChunk = {
|
|
311
|
+
stdout: Buffer;
|
|
312
|
+
stderr: Buffer;
|
|
313
|
+
exitCode: number | null;
|
|
314
|
+
};
|
|
315
|
+
type FileWrite = {
|
|
316
|
+
path: string;
|
|
317
|
+
content?: Buffer | string;
|
|
318
|
+
/** Permission bits. 0 or omitted stays 0644. Only the low 9 bits are applied. */
|
|
319
|
+
mode?: number;
|
|
320
|
+
};
|
|
321
|
+
type FileOp$1 = {
|
|
322
|
+
write: FileWrite;
|
|
323
|
+
recursive?: boolean;
|
|
324
|
+
} | {
|
|
325
|
+
remove: string;
|
|
326
|
+
recursive?: boolean;
|
|
327
|
+
} | {
|
|
328
|
+
mkdir: string;
|
|
329
|
+
};
|
|
330
|
+
type FileSpec = {
|
|
331
|
+
path: string;
|
|
332
|
+
content?: string | Buffer;
|
|
333
|
+
mode?: number;
|
|
334
|
+
};
|
|
335
|
+
type CallOpts = {
|
|
336
|
+
timeoutMs?: number;
|
|
337
|
+
signal?: AbortSignal;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
/** Product errors. Catch a named class. `SandboxError` is only the catch-all. */
|
|
341
|
+
type ErrorFields = {
|
|
342
|
+
code?: string;
|
|
343
|
+
reason?: string;
|
|
344
|
+
sandboxId?: string;
|
|
345
|
+
path?: string;
|
|
346
|
+
op?: string;
|
|
347
|
+
opIndex?: number;
|
|
348
|
+
processId?: string;
|
|
349
|
+
resource?: string;
|
|
350
|
+
requestId?: string;
|
|
351
|
+
status?: string;
|
|
352
|
+
exitCode?: number;
|
|
353
|
+
retryAfterSec?: number;
|
|
354
|
+
};
|
|
355
|
+
declare class SandboxError extends Error {
|
|
356
|
+
readonly code: string;
|
|
357
|
+
readonly reason: string;
|
|
358
|
+
readonly sandboxId?: string;
|
|
359
|
+
readonly path?: string;
|
|
360
|
+
readonly op?: string;
|
|
361
|
+
readonly opIndex?: number;
|
|
362
|
+
readonly processId?: string;
|
|
363
|
+
readonly resource?: string;
|
|
364
|
+
readonly requestId?: string;
|
|
365
|
+
readonly status?: string;
|
|
366
|
+
readonly retryAfterSec?: number;
|
|
367
|
+
exitCode?: number;
|
|
368
|
+
stdout: string | Uint8Array;
|
|
369
|
+
stderr: string | Uint8Array;
|
|
370
|
+
/** True when the call may be repeated. */
|
|
371
|
+
get retryable(): boolean;
|
|
372
|
+
/** Id that already holds a taken name. */
|
|
373
|
+
get existingId(): string | undefined;
|
|
374
|
+
constructor(message: string, fields?: ErrorFields);
|
|
375
|
+
/** One line with the server fields callers otherwise reassemble. */
|
|
376
|
+
format(): string;
|
|
377
|
+
}
|
|
378
|
+
declare class NotFoundError extends SandboxError {
|
|
379
|
+
}
|
|
380
|
+
declare class ConflictError extends SandboxError {
|
|
381
|
+
}
|
|
382
|
+
declare class PermissionDeniedError extends SandboxError {
|
|
383
|
+
}
|
|
384
|
+
declare class SandboxTimeoutError extends SandboxError {
|
|
385
|
+
}
|
|
386
|
+
declare class PageExhaustedError extends SandboxError {
|
|
387
|
+
constructor(message?: string);
|
|
388
|
+
}
|
|
389
|
+
declare class UnavailableError extends SandboxError {
|
|
390
|
+
}
|
|
391
|
+
declare class CommandFailedError extends SandboxError {
|
|
392
|
+
result?: ExecResult | ExecBytesResult;
|
|
393
|
+
}
|
|
394
|
+
declare class PathNotFoundError extends NotFoundError {
|
|
395
|
+
}
|
|
396
|
+
declare class FileNotFoundError extends PathNotFoundError {
|
|
397
|
+
}
|
|
398
|
+
declare class DirectoryNotEmptyError extends ConflictError {
|
|
399
|
+
}
|
|
400
|
+
declare class FileExistsError extends SandboxError {
|
|
401
|
+
}
|
|
402
|
+
declare class FileTooLargeError extends SandboxError {
|
|
403
|
+
}
|
|
404
|
+
declare class InvalidPathError extends SandboxError {
|
|
405
|
+
}
|
|
406
|
+
/** No sandbox, secret, snapshot, volume, image, or tag has that id or name. */
|
|
407
|
+
declare class SandboxNotFoundError extends NotFoundError {
|
|
408
|
+
}
|
|
409
|
+
declare class SandboxNotReadyError extends SandboxError {
|
|
410
|
+
}
|
|
411
|
+
declare class SandboxConflictError extends ConflictError {
|
|
412
|
+
}
|
|
413
|
+
/** That name is already in use. `existingId` is the id that has it. */
|
|
414
|
+
declare class NameTakenError extends ConflictError {
|
|
415
|
+
get existingId(): string;
|
|
416
|
+
}
|
|
417
|
+
declare class SandboxStateError extends SandboxError {
|
|
418
|
+
}
|
|
419
|
+
declare class ProcessNotFoundError extends NotFoundError {
|
|
420
|
+
}
|
|
421
|
+
declare class ExecutableNotFoundError extends NotFoundError {
|
|
422
|
+
}
|
|
423
|
+
declare class GuestRuntimeDeadError extends SandboxError {
|
|
424
|
+
}
|
|
425
|
+
declare class CapacityError extends SandboxError {
|
|
426
|
+
}
|
|
427
|
+
declare class AuthenticationError extends SandboxError {
|
|
428
|
+
}
|
|
429
|
+
declare class InvalidArgumentError extends SandboxError {
|
|
430
|
+
}
|
|
431
|
+
declare class CommandTooLargeError extends InvalidArgumentError {
|
|
432
|
+
}
|
|
433
|
+
declare class CommandTimeoutError extends SandboxTimeoutError {
|
|
434
|
+
}
|
|
435
|
+
/** Nothing is listening on the forwarded port. */
|
|
436
|
+
declare class PortNotOpenError extends SandboxError {
|
|
437
|
+
}
|
|
438
|
+
/** The sandbox is sleeping. Open it before an HTTP request. */
|
|
439
|
+
declare class SandboxSleepingError extends SandboxError {
|
|
440
|
+
}
|
|
441
|
+
declare class ProcessWaitTimeoutError extends SandboxTimeoutError {
|
|
442
|
+
}
|
|
443
|
+
declare class SandboxWaitTimeoutError extends SandboxTimeoutError {
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
declare function authInterceptor(auth: TokenProvider, runId?: string): Interceptor;
|
|
447
|
+
|
|
448
|
+
type CreateSandboxParams = {
|
|
449
|
+
/** Optional lookup. The server mints the id. */
|
|
450
|
+
name?: string;
|
|
451
|
+
/** Guest rootfs. Required. Platform aliases such as `numen/base` resolve on the control plane. */
|
|
452
|
+
image?: string;
|
|
453
|
+
net?: string;
|
|
454
|
+
env?: Record<string, string>;
|
|
455
|
+
workdir?: string;
|
|
456
|
+
lifetimeSec?: number;
|
|
457
|
+
idleTimeoutSec?: number;
|
|
458
|
+
/** Project tag names that must already exist. */
|
|
459
|
+
tags?: string[];
|
|
460
|
+
fromSnapshotId?: string;
|
|
461
|
+
volumeId?: string;
|
|
462
|
+
labels?: Record<string, string>;
|
|
463
|
+
cpuMillicores?: number;
|
|
464
|
+
memoryBytes?: number;
|
|
465
|
+
diskBytes?: number;
|
|
466
|
+
timeoutMs?: number;
|
|
467
|
+
signal?: AbortSignal;
|
|
468
|
+
};
|
|
469
|
+
type ExecStreamOpts = CallOpts & {
|
|
470
|
+
env?: Record<string, string>;
|
|
471
|
+
cwd?: string;
|
|
472
|
+
executionTimeoutSec?: number;
|
|
473
|
+
stdin?: Buffer | string | NodeJS.ReadableStream | ReadableStream<Uint8Array>;
|
|
474
|
+
};
|
|
475
|
+
type WriteFileOpts = CallOpts & {
|
|
476
|
+
content?: Buffer;
|
|
477
|
+
local?: string;
|
|
478
|
+
/** Permission bits. 0 or omitted stays 0644. */
|
|
479
|
+
mode?: number;
|
|
480
|
+
};
|
|
481
|
+
type ClientOpts = CredentialsInput & {
|
|
482
|
+
timeoutMs?: number;
|
|
483
|
+
runId?: string;
|
|
484
|
+
};
|
|
485
|
+
interface ConnectByteStream {
|
|
486
|
+
write(data: Buffer): boolean | void | Promise<void>;
|
|
487
|
+
end(): void;
|
|
488
|
+
close(): void;
|
|
489
|
+
on(event: "data", listener: (chunk: Buffer) => void | Promise<void>): void;
|
|
490
|
+
on(event: "end", listener: () => void): void;
|
|
491
|
+
on(event: "error", listener: (err: Error) => void): void;
|
|
492
|
+
}
|
|
493
|
+
declare class ForwardSession {
|
|
494
|
+
private readonly stream;
|
|
495
|
+
private slot;
|
|
496
|
+
private slotWait;
|
|
497
|
+
private readonly waiters;
|
|
498
|
+
private err;
|
|
499
|
+
private closed;
|
|
500
|
+
private ended;
|
|
501
|
+
private sendClosed;
|
|
502
|
+
constructor(stream: ConnectByteStream);
|
|
503
|
+
/** Hold one chunk. The returned promise resolves once that chunk is the only one buffered. */
|
|
504
|
+
private push;
|
|
505
|
+
private takeSlot;
|
|
506
|
+
send(data: Buffer): void | Promise<void>;
|
|
507
|
+
recv(opts?: {
|
|
508
|
+
timeoutMs?: number;
|
|
509
|
+
}): Promise<Buffer>;
|
|
510
|
+
/** Stop sending. `recv` still returns guest bytes. */
|
|
511
|
+
endSend(): void;
|
|
512
|
+
close(): void;
|
|
513
|
+
[Symbol.dispose](): void;
|
|
514
|
+
}
|
|
515
|
+
/** Connect-ES client for SandboxService.
|
|
516
|
+
*
|
|
517
|
+
* Use this for catalog, volumes, snapshots inventory, secrets, and
|
|
518
|
+
* credential policies. Pass the same instance into `Sandbox.create`.
|
|
519
|
+
* Omit `baseUrl` to use credentials `api_url`, then the Cloud Run CP. */
|
|
520
|
+
declare class Session {
|
|
521
|
+
readonly baseUrl: string;
|
|
522
|
+
readonly runId: string;
|
|
523
|
+
private readonly defaultTimeoutMs;
|
|
524
|
+
private readonly auth;
|
|
525
|
+
private readonly interceptors;
|
|
526
|
+
private readonly svc;
|
|
527
|
+
private readonly forwardClients;
|
|
528
|
+
constructor(baseUrl?: string, opts?: ClientOpts);
|
|
529
|
+
/** Shared dial for the unpublished admin package. Not a public SDK method. */
|
|
530
|
+
connectParts(): {
|
|
531
|
+
baseUrl: string;
|
|
532
|
+
interceptors: ReturnType<typeof authInterceptor>[];
|
|
533
|
+
};
|
|
534
|
+
extraHeaders(sandboxId?: string): Record<string, string> | undefined;
|
|
535
|
+
call(method: string, body: Record<string, unknown>, timeoutMs: number | undefined, signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
536
|
+
close(): void;
|
|
537
|
+
get forwardBaseUrl(): string;
|
|
538
|
+
/** Byte stream to a guest port. The call is gRPC on `sbx`.
|
|
539
|
+
* Park drops the VMM, so an open forward ends; close it and open a new one after `open()`. */
|
|
540
|
+
forward(sandboxId: string, port: number, opts?: CallOpts & {
|
|
541
|
+
baseUrl?: string;
|
|
542
|
+
}): Promise<ForwardSession>;
|
|
543
|
+
private forwardClient;
|
|
544
|
+
private forwardBase;
|
|
545
|
+
/** HTTP base URL for a guest port. No request is sent.
|
|
546
|
+
* Put the project access token or an HTTP grant on `X-Numen-Authorization`.
|
|
547
|
+
* `Authorization` is the guest's header. `wsUrl` is the same host, id, and port with scheme `wss`. */
|
|
548
|
+
httpUrl(sandboxId: string, port: number, opts?: {
|
|
549
|
+
baseUrl?: string;
|
|
550
|
+
}): string;
|
|
551
|
+
/** WebSocket base URL for a guest port. No socket is opened.
|
|
552
|
+
* Same host, sandbox id, and port as `httpUrl`. The caller appends the path
|
|
553
|
+
* and passes the header to their own WebSocket library. */
|
|
554
|
+
wsUrl(sandboxId: string, port: number, opts?: {
|
|
555
|
+
baseUrl?: string;
|
|
556
|
+
}): string;
|
|
557
|
+
/** Mint a visitor credential for one guest HTTP port. The token is returned once. */
|
|
558
|
+
createHttpGrant(sandboxId: string, port: number, opts?: CallOpts & {
|
|
559
|
+
ttlSec?: number;
|
|
560
|
+
}): Promise<HTTPGrant>;
|
|
561
|
+
/** List grants for one sandbox. The secret is not included. */
|
|
562
|
+
listHttpGrants(sandboxId: string, opts?: CallOpts): Promise<HTTPGrant[]>;
|
|
563
|
+
/** Delete one grant in the caller's project. */
|
|
564
|
+
deleteHttpGrant(id: string, opts?: CallOpts): Promise<void>;
|
|
565
|
+
/** Control-plane `Authorization` bearer. Guest URL callers use `getGuestHeaders`. */
|
|
566
|
+
authorizationHeader(): Promise<Record<string, string>>;
|
|
567
|
+
/** Guest URL header for this session's project token. Empty when no token is configured. */
|
|
568
|
+
getGuestHeaders(): Promise<Record<string, string>>;
|
|
569
|
+
/** CreateSandbox. The server mints the id. `name` is an optional lookup. */
|
|
570
|
+
createSandbox(params: CreateSandboxParams): Promise<SandboxInfo>;
|
|
571
|
+
/** OpenSandbox: wake by id or name. Does not create. */
|
|
572
|
+
openSandbox(sandboxId?: string, opts?: CallOpts & {
|
|
573
|
+
name?: string;
|
|
574
|
+
}): Promise<SandboxInfo>;
|
|
575
|
+
listLogArchives(opts?: CallOpts & {
|
|
576
|
+
pageSize?: number;
|
|
577
|
+
pageToken?: string;
|
|
578
|
+
}): Promise<{
|
|
579
|
+
archives: {
|
|
580
|
+
sandboxId: string;
|
|
581
|
+
deletedAt: string;
|
|
582
|
+
expiresAt: string;
|
|
583
|
+
name: string;
|
|
584
|
+
image: string;
|
|
585
|
+
labels: Record<string, string>;
|
|
586
|
+
tags: string[];
|
|
587
|
+
createdAt: string;
|
|
588
|
+
}[];
|
|
589
|
+
nextPageToken: string;
|
|
590
|
+
}>;
|
|
591
|
+
queryLogs(opts?: CallOpts & {
|
|
592
|
+
sandboxId?: string;
|
|
593
|
+
processId?: string;
|
|
594
|
+
stream?: LogStream$1 | "";
|
|
595
|
+
streams?: Array<LogStream$1 | "">;
|
|
596
|
+
contains?: string;
|
|
597
|
+
caseInsensitive?: boolean;
|
|
598
|
+
fields?: {
|
|
599
|
+
key: string;
|
|
600
|
+
value: string;
|
|
601
|
+
op?: "eq" | "ne" | "contains" | "startsWith";
|
|
602
|
+
}[];
|
|
603
|
+
direction?: "forward" | "backward" | "";
|
|
604
|
+
start?: string;
|
|
605
|
+
end?: string;
|
|
606
|
+
pageSize?: number;
|
|
607
|
+
pageToken?: string;
|
|
608
|
+
}): Promise<LogPage>;
|
|
609
|
+
getSandboxLogs(sandboxId: string, opts?: CallOpts & {
|
|
610
|
+
processId?: string;
|
|
611
|
+
pageSize?: number;
|
|
612
|
+
pageToken?: string;
|
|
613
|
+
stream?: LogStream$1 | "";
|
|
614
|
+
}): Promise<LogPage>;
|
|
615
|
+
getSandbox(sandboxId?: string, opts?: CallOpts & {
|
|
616
|
+
name?: string;
|
|
617
|
+
}): Promise<SandboxInfo>;
|
|
618
|
+
listSandboxes(opts?: CallOpts & {
|
|
619
|
+
labels?: Record<string, string>;
|
|
620
|
+
tags?: string[];
|
|
621
|
+
statuses?: Array<string | number>;
|
|
622
|
+
pageSize?: number;
|
|
623
|
+
pageToken?: string;
|
|
624
|
+
}): Promise<SandboxList>;
|
|
625
|
+
setSandboxLabels(sandboxId: string, labels: Record<string, string> | undefined, opts?: CallOpts): Promise<SandboxInfo>;
|
|
626
|
+
setSandboxSize(sandboxId: string, packing: {
|
|
627
|
+
cpuMillicores?: number;
|
|
628
|
+
memoryBytes?: number;
|
|
629
|
+
diskBytes?: number;
|
|
630
|
+
}, opts?: CallOpts): Promise<SandboxInfo>;
|
|
631
|
+
setSandboxTags(sandboxId: string, tags: string[] | undefined, opts?: CallOpts): Promise<SandboxInfo>;
|
|
632
|
+
/** DeleteSandbox. Idempotent if gone. Named volumes stay. */
|
|
633
|
+
deleteSandbox(sandboxId: string, opts?: CallOpts): Promise<void>;
|
|
634
|
+
/** ParkSandbox: reboot. Commit the writable layer, drop the VM, keep the id. */
|
|
635
|
+
parkSandbox(sandboxId: string, opts?: CallOpts): Promise<SandboxInfo>;
|
|
636
|
+
execStream(sandboxId: string, argv: string[], opts?: ExecStreamOpts): AsyncGenerator<StreamChunk, number | undefined>;
|
|
637
|
+
startProcess(sandboxId: string, argv: string[], opts?: CallOpts & {
|
|
638
|
+
env?: Record<string, string>;
|
|
639
|
+
cwd?: string;
|
|
640
|
+
executionTimeoutSec?: number;
|
|
641
|
+
serviceName?: string;
|
|
642
|
+
holdsIdle?: boolean;
|
|
643
|
+
endsSandbox?: boolean;
|
|
644
|
+
}): Promise<Process>;
|
|
645
|
+
getProcess(sandboxId: string, processId: string, opts?: CallOpts): Promise<Process>;
|
|
646
|
+
listProcesses(sandboxId: string, opts?: CallOpts): Promise<ProcessList>;
|
|
647
|
+
killProcess(sandboxId: string, processId: string, signal?: number, opts?: CallOpts): Promise<Process>;
|
|
648
|
+
waitSandbox(sandboxId: string, opts?: CallOpts & {
|
|
649
|
+
until?: string[];
|
|
650
|
+
untilDeleted?: boolean;
|
|
651
|
+
waitSec?: number;
|
|
652
|
+
}): Promise<{
|
|
653
|
+
sandbox: SandboxInfo | null;
|
|
654
|
+
deleted: boolean;
|
|
655
|
+
}>;
|
|
656
|
+
waitProcess(sandboxId: string, processId: string, opts?: CallOpts & {
|
|
657
|
+
waitSec?: number;
|
|
658
|
+
}): Promise<Process>;
|
|
659
|
+
followProcess(sandboxId: string, processId: string, opts?: CallOpts): AsyncGenerator<StreamChunk>;
|
|
660
|
+
writeProcessStdin(sandboxId: string, processId: string, data?: Buffer | string, opts?: CallOpts & {
|
|
661
|
+
eof?: boolean;
|
|
662
|
+
}): Promise<void>;
|
|
663
|
+
writeFiles(sandboxId: string, ops: Array<FileOp$1 | FileSpec | Record<string, unknown>>, opts?: CallOpts): Promise<void>;
|
|
664
|
+
writeFile(sandboxId: string, path: string, opts: WriteFileOpts): Promise<void>;
|
|
665
|
+
writeTree(sandboxId: string, path: string, frames: AsyncIterable<Uint8Array>, opts?: {
|
|
666
|
+
timeoutMs?: number;
|
|
667
|
+
signal?: AbortSignal;
|
|
668
|
+
replace?: boolean;
|
|
669
|
+
}): Promise<void>;
|
|
670
|
+
readFile(sandboxId: string, path: string, opts?: CallOpts): Promise<Buffer>;
|
|
671
|
+
readChunks(sandboxId: string, path: string, opts?: CallOpts): AsyncGenerator<Buffer>;
|
|
672
|
+
listFiles(sandboxId: string, path: string, opts?: CallOpts & {
|
|
673
|
+
maxDepth?: number;
|
|
674
|
+
}): Promise<FileList>;
|
|
675
|
+
exportPath(sandboxId: string, path: string, opts: {
|
|
676
|
+
dest: string;
|
|
677
|
+
gzip?: boolean;
|
|
678
|
+
timeoutMs?: number;
|
|
679
|
+
signal?: AbortSignal;
|
|
680
|
+
}): Promise<void>;
|
|
681
|
+
statFile(sandboxId: string, path: string, opts?: CallOpts): Promise<FileInfo>;
|
|
682
|
+
createSnapshot(sandboxId: string, opts?: CallOpts & {
|
|
683
|
+
name?: string;
|
|
684
|
+
labels?: Record<string, string>;
|
|
685
|
+
}): Promise<Snapshot>;
|
|
686
|
+
getSnapshot(snapshotId?: string, opts?: CallOpts & {
|
|
687
|
+
name?: string;
|
|
688
|
+
}): Promise<Snapshot>;
|
|
689
|
+
listSnapshots(opts?: CallOpts & {
|
|
690
|
+
labels?: Record<string, string>;
|
|
691
|
+
sourceSandboxId?: string;
|
|
692
|
+
pageSize?: number;
|
|
693
|
+
pageToken?: string;
|
|
694
|
+
}): Promise<SnapshotList>;
|
|
695
|
+
setSnapshotLabels(snapshotId: string, labels: Record<string, string> | undefined, opts?: CallOpts): Promise<Snapshot>;
|
|
696
|
+
deleteSnapshot(snapshotId: string, opts?: CallOpts): Promise<void>;
|
|
697
|
+
/** Named workdir disk that survives sandbox delete. Attach at Create. */
|
|
698
|
+
createVolume(opts?: CallOpts & {
|
|
699
|
+
name?: string;
|
|
700
|
+
labels?: Record<string, string>;
|
|
701
|
+
}): Promise<Volume>;
|
|
702
|
+
getVolume(volumeId?: string, opts?: CallOpts & {
|
|
703
|
+
name?: string;
|
|
704
|
+
}): Promise<Volume>;
|
|
705
|
+
listVolumes(opts?: CallOpts & {
|
|
706
|
+
labels?: Record<string, string>;
|
|
707
|
+
pageSize?: number;
|
|
708
|
+
pageToken?: string;
|
|
709
|
+
}): Promise<VolumeList>;
|
|
710
|
+
/** Store a project secret. Get/List never return the value. */
|
|
711
|
+
setSecret(name: string, value: string, opts?: CallOpts): Promise<Secret>;
|
|
712
|
+
/** Metadata only. Missing → not_found (including foreign project). */
|
|
713
|
+
getSecret(name: string, opts?: CallOpts): Promise<Secret>;
|
|
714
|
+
listProjectSecrets(opts?: CallOpts & {
|
|
715
|
+
pageSize?: number;
|
|
716
|
+
pageToken?: string;
|
|
717
|
+
}): Promise<SecretList>;
|
|
718
|
+
deleteSecret(name: string, opts?: CallOpts): Promise<void>;
|
|
719
|
+
listSecretReferences(name: string, opts?: CallOpts): Promise<string[]>;
|
|
720
|
+
createTag(name: string, opts?: CallOpts & {
|
|
721
|
+
policyId?: string;
|
|
722
|
+
}): Promise<Tag>;
|
|
723
|
+
getTag(tagId: string, opts?: CallOpts): Promise<Tag>;
|
|
724
|
+
listTags(opts?: CallOpts & {
|
|
725
|
+
pageSize?: number;
|
|
726
|
+
pageToken?: string;
|
|
727
|
+
}): Promise<TagList>;
|
|
728
|
+
updateTag(tagId: string, opts?: CallOpts & {
|
|
729
|
+
policyId?: string;
|
|
730
|
+
}): Promise<Tag>;
|
|
731
|
+
createPolicy(name: string, document: Record<string, HostBind | Record<string, unknown>>, opts?: CallOpts & {
|
|
732
|
+
av?: AVPolicy;
|
|
733
|
+
ids?: IDSPolicy;
|
|
734
|
+
preset?: string;
|
|
735
|
+
cpuMillicores?: number;
|
|
736
|
+
memoryBytes?: number;
|
|
737
|
+
diskBytes?: number;
|
|
738
|
+
}): Promise<PolicyMutation>;
|
|
739
|
+
getPolicy(policyId: string, opts?: CallOpts): Promise<Policy>;
|
|
740
|
+
listPolicies(opts?: CallOpts & {
|
|
741
|
+
pageSize?: number;
|
|
742
|
+
pageToken?: string;
|
|
743
|
+
}): Promise<PolicyList>;
|
|
744
|
+
updatePolicy(policyId: string, opts?: CallOpts & {
|
|
745
|
+
name?: string;
|
|
746
|
+
av?: AVPolicy;
|
|
747
|
+
ids?: IDSPolicy;
|
|
748
|
+
preset?: string;
|
|
749
|
+
document?: Record<string, HostBind | Record<string, unknown>>;
|
|
750
|
+
cpuMillicores?: number;
|
|
751
|
+
memoryBytes?: number;
|
|
752
|
+
diskBytes?: number;
|
|
753
|
+
}): Promise<PolicyMutation>;
|
|
754
|
+
deletePolicy(policyId: string, opts?: CallOpts): Promise<void>;
|
|
755
|
+
deleteTag(tagId: string, opts?: CallOpts): Promise<void>;
|
|
756
|
+
registerImage(name: string, opts: CallOpts & {
|
|
757
|
+
from: string;
|
|
758
|
+
waitUntilReady?: boolean;
|
|
759
|
+
waitSec?: number;
|
|
760
|
+
}): Promise<Image>;
|
|
761
|
+
buildImage(name: string, opts?: CallOpts & {
|
|
762
|
+
dockerfile?: string;
|
|
763
|
+
context?: string;
|
|
764
|
+
waitUntilReady?: boolean;
|
|
765
|
+
waitSec?: number;
|
|
766
|
+
}): Promise<Image>;
|
|
767
|
+
getImage(name: string, opts?: CallOpts): Promise<Image>;
|
|
768
|
+
listImages(opts?: CallOpts & {
|
|
769
|
+
pageSize?: number;
|
|
770
|
+
pageToken?: string;
|
|
771
|
+
}): Promise<ImageList>;
|
|
772
|
+
deleteImage(name: string, opts?: CallOpts): Promise<void>;
|
|
773
|
+
setVolumeLabels(volumeId: string, labels: Record<string, string> | undefined, opts?: CallOpts): Promise<Volume>;
|
|
774
|
+
deleteVolume(volumeId: string, opts?: CallOpts): Promise<void>;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/** Public catalog client. Guest calls live on `Sandbox`, not here. */
|
|
778
|
+
|
|
779
|
+
type TimeoutOpts = {
|
|
780
|
+
timeout?: number;
|
|
781
|
+
signal?: AbortSignal;
|
|
782
|
+
};
|
|
783
|
+
/** Named disks. Attach one by passing `volumeId` to `Sandbox.create`. */
|
|
784
|
+
declare class Volumes$1 {
|
|
785
|
+
private readonly wire;
|
|
786
|
+
/** Create the handle. */
|
|
787
|
+
constructor(wire: Session);
|
|
788
|
+
/** Create. */
|
|
789
|
+
create(params?: {
|
|
790
|
+
name?: string;
|
|
791
|
+
labels?: Record<string, string>;
|
|
792
|
+
} & TimeoutOpts): Promise<Volume>;
|
|
793
|
+
/** Get. */
|
|
794
|
+
get(id?: string, opts?: {
|
|
795
|
+
name?: string;
|
|
796
|
+
} & TimeoutOpts): Promise<Volume>;
|
|
797
|
+
/** List. */
|
|
798
|
+
list(opts?: {
|
|
799
|
+
labels?: Record<string, string>;
|
|
800
|
+
pageSize?: number;
|
|
801
|
+
pageToken?: string;
|
|
802
|
+
} & TimeoutOpts): Promise<VolumeList>;
|
|
803
|
+
/** Set Labels. */
|
|
804
|
+
setLabels(id: string, labels?: Record<string, string>, opts?: TimeoutOpts): Promise<Volume>;
|
|
805
|
+
/** Delete. */
|
|
806
|
+
delete(id: string, opts?: TimeoutOpts): Promise<void>;
|
|
807
|
+
}
|
|
808
|
+
/** Project secrets. Values are write-only after `set`. */
|
|
809
|
+
declare class Secrets$1 {
|
|
810
|
+
private readonly wire;
|
|
811
|
+
/** Create the handle. */
|
|
812
|
+
constructor(wire: Session);
|
|
813
|
+
/** Set. */
|
|
814
|
+
set(name: string, value: string, opts?: TimeoutOpts): Promise<Secret>;
|
|
815
|
+
/** Get. */
|
|
816
|
+
get(name: string, opts?: TimeoutOpts): Promise<Secret>;
|
|
817
|
+
/** List. */
|
|
818
|
+
list(opts?: {
|
|
819
|
+
pageSize?: number;
|
|
820
|
+
pageToken?: string;
|
|
821
|
+
} & TimeoutOpts): Promise<SecretList>;
|
|
822
|
+
/** Delete. */
|
|
823
|
+
delete(name: string, opts?: TimeoutOpts): Promise<void>;
|
|
824
|
+
/** List References. */
|
|
825
|
+
listReferences(name: string, opts?: TimeoutOpts): Promise<string[]>;
|
|
826
|
+
}
|
|
827
|
+
/** Platform names and project images. */
|
|
828
|
+
declare class Images$1 {
|
|
829
|
+
private readonly wire;
|
|
830
|
+
/** Create the handle. */
|
|
831
|
+
constructor(wire: Session);
|
|
832
|
+
/** Register. */
|
|
833
|
+
register(name: string, opts: {
|
|
834
|
+
from: string;
|
|
835
|
+
waitUntilReady?: boolean;
|
|
836
|
+
waitSec?: number;
|
|
837
|
+
} & TimeoutOpts): Promise<Image>;
|
|
838
|
+
/** Build. */
|
|
839
|
+
build(name: string, opts?: {
|
|
840
|
+
dockerfile?: string;
|
|
841
|
+
context?: string;
|
|
842
|
+
waitUntilReady?: boolean;
|
|
843
|
+
waitSec?: number;
|
|
844
|
+
} & TimeoutOpts): Promise<Image>;
|
|
845
|
+
/** Get. */
|
|
846
|
+
get(name: string, opts?: TimeoutOpts): Promise<Image>;
|
|
847
|
+
/** List. */
|
|
848
|
+
list(opts?: {
|
|
849
|
+
pageSize?: number;
|
|
850
|
+
pageToken?: string;
|
|
851
|
+
} & TimeoutOpts): Promise<ImageList>;
|
|
852
|
+
/** Delete. */
|
|
853
|
+
delete(name: string, opts?: TimeoutOpts): Promise<void>;
|
|
854
|
+
}
|
|
855
|
+
/** Pins of a sandbox filesystem. */
|
|
856
|
+
declare class Snapshots$1 {
|
|
857
|
+
private readonly wire;
|
|
858
|
+
/** Create the handle. */
|
|
859
|
+
constructor(wire: Session);
|
|
860
|
+
/** Get. */
|
|
861
|
+
get(id?: string, opts?: {
|
|
862
|
+
name?: string;
|
|
863
|
+
} & TimeoutOpts): Promise<Snapshot>;
|
|
864
|
+
/** List. */
|
|
865
|
+
list(opts?: {
|
|
866
|
+
labels?: Record<string, string>;
|
|
867
|
+
sourceSandboxId?: string;
|
|
868
|
+
pageSize?: number;
|
|
869
|
+
pageToken?: string;
|
|
870
|
+
} & TimeoutOpts): Promise<SnapshotList>;
|
|
871
|
+
/** Set Labels. */
|
|
872
|
+
setLabels(id: string, labels?: Record<string, string>, opts?: TimeoutOpts): Promise<Snapshot>;
|
|
873
|
+
/** Delete. */
|
|
874
|
+
delete(id: string, opts?: TimeoutOpts): Promise<void>;
|
|
875
|
+
}
|
|
876
|
+
/** Configurations. Each one points at a policy set created in the portal. */
|
|
877
|
+
declare class Tags$1 {
|
|
878
|
+
private readonly wire;
|
|
879
|
+
/** Create the handle. */
|
|
880
|
+
constructor(wire: Session);
|
|
881
|
+
/** Create. */
|
|
882
|
+
create(name: string, opts?: {
|
|
883
|
+
policyId?: string;
|
|
884
|
+
} & TimeoutOpts): Promise<Tag>;
|
|
885
|
+
/** Get. */
|
|
886
|
+
get(id: string, opts?: TimeoutOpts): Promise<Tag>;
|
|
887
|
+
/** List. */
|
|
888
|
+
list(opts?: {
|
|
889
|
+
pageSize?: number;
|
|
890
|
+
pageToken?: string;
|
|
891
|
+
} & TimeoutOpts): Promise<TagList>;
|
|
892
|
+
/** Update. */
|
|
893
|
+
update(id: string, opts?: {
|
|
894
|
+
policyId?: string;
|
|
895
|
+
} & TimeoutOpts): Promise<Tag>;
|
|
896
|
+
/** Delete. */
|
|
897
|
+
delete(id: string, opts?: TimeoutOpts): Promise<void>;
|
|
898
|
+
}
|
|
899
|
+
/** Images, volumes, secrets, tags, and snapshot inventory.
|
|
900
|
+
*
|
|
901
|
+
* Sandboxes are created with Sandbox.create. Policies are created in the portal.
|
|
902
|
+
*/
|
|
903
|
+
declare class Client$1 {
|
|
904
|
+
/** Base Url. */
|
|
905
|
+
readonly baseUrl: string;
|
|
906
|
+
/** Run Id. */
|
|
907
|
+
readonly runId: string;
|
|
908
|
+
/** Volumes. */
|
|
909
|
+
readonly volumes: Volumes$1;
|
|
910
|
+
/** Secrets. */
|
|
911
|
+
readonly secrets: Secrets$1;
|
|
912
|
+
/** Images. */
|
|
913
|
+
readonly images: Images$1;
|
|
914
|
+
/** Snapshots. */
|
|
915
|
+
readonly snapshots: Snapshots$1;
|
|
916
|
+
/** Tags. */
|
|
917
|
+
readonly tags: Tags$1;
|
|
918
|
+
/** Create the handle. */
|
|
919
|
+
constructor(baseUrl?: string | Session, opts?: ClientOpts);
|
|
920
|
+
/** Close. */
|
|
921
|
+
close(): void;
|
|
922
|
+
/** Header for the guest URL using this project's access token.
|
|
923
|
+
*
|
|
924
|
+
* For your own server. Do not send this value to a browser. `Sandbox.getHeaders` returns the same record.
|
|
925
|
+
* Empty when no token is configured.
|
|
926
|
+
*/
|
|
927
|
+
getGuestHeaders(): Promise<Record<string, string>>;
|
|
928
|
+
/** List Sandboxes. */
|
|
929
|
+
listSandboxes(opts?: {
|
|
930
|
+
labels?: Record<string, string>;
|
|
931
|
+
tags?: string[];
|
|
932
|
+
statuses?: SandboxStatus$1[];
|
|
933
|
+
pageSize?: number;
|
|
934
|
+
pageToken?: string;
|
|
935
|
+
} & TimeoutOpts): Promise<SandboxList>;
|
|
936
|
+
/** Yield every sandbox, walking pages. */
|
|
937
|
+
listSandboxesIter(opts?: Omit<NonNullable<Parameters<Client$1["listSandboxes"]>[0]>, "pageToken">): AsyncGenerator<SandboxSummary>;
|
|
938
|
+
/** Yield every image, walking pages. */
|
|
939
|
+
listImagesIter(opts?: Omit<NonNullable<Parameters<Images$1["list"]>[0]>, "pageToken">): AsyncGenerator<Image>;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/** Guest HTTP and WebSocket over the public URL. No request is sent until get, post, or websocket. */
|
|
943
|
+
|
|
944
|
+
/** Buffered guest body. `text`, `json`, and `bytes` are synchronous. */
|
|
945
|
+
declare class GuestResponse {
|
|
946
|
+
readonly statusCode: number;
|
|
947
|
+
readonly headers: Headers;
|
|
948
|
+
private readonly body;
|
|
949
|
+
constructor(statusCode: number, headers: Headers, body: Uint8Array);
|
|
950
|
+
text(): string;
|
|
951
|
+
json(): unknown;
|
|
952
|
+
bytes(): Uint8Array;
|
|
953
|
+
}
|
|
954
|
+
/** One guest port. `get` and `post` buffer the body before they return. */
|
|
955
|
+
declare class GuestHttp {
|
|
956
|
+
readonly baseUrl: string;
|
|
957
|
+
private readonly auth;
|
|
958
|
+
constructor(baseUrl: string, auth: Record<string, string>);
|
|
959
|
+
/** One GET. `path` is the guest route. */
|
|
960
|
+
get(path: string, init?: RequestInit): Promise<GuestResponse>;
|
|
961
|
+
/** One POST. `json` is sent as `application/json`. */
|
|
962
|
+
post(path: string, body?: {
|
|
963
|
+
json?: unknown;
|
|
964
|
+
headers?: HeadersInit;
|
|
965
|
+
}): Promise<GuestResponse>;
|
|
966
|
+
/** Dial one WebSocket. The promise resolves on open. The caller calls `close`. */
|
|
967
|
+
websocket(path?: string): Promise<WebSocket>;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
/** Arguments for `Sandbox.create`. Fields say what omit means. */
|
|
971
|
+
type SandboxCreateParams$1 = {
|
|
972
|
+
/** Guest rootfs. Required. Platform aliases such as `numen/base` resolve on the control plane. */
|
|
973
|
+
image: string;
|
|
974
|
+
/** Optional lookup. The server mints the id. */
|
|
975
|
+
name?: string;
|
|
976
|
+
/** Environment variables for the sandbox. Omit for an empty map. */
|
|
977
|
+
env?: Record<string, string>;
|
|
978
|
+
/** Guest working directory. Omit and commands start in the image working directory, or `/work`. */
|
|
979
|
+
workdir?: string;
|
|
980
|
+
/** Lifetime from create, seconds. 0/omit = none. Expiry deletes the box. */
|
|
981
|
+
lifetimeSec?: number;
|
|
982
|
+
/** Seconds of inactivity before park. Omit and the sandbox stays up. */
|
|
983
|
+
idleTimeoutSec?: number;
|
|
984
|
+
/** Project tag names that must already exist. */
|
|
985
|
+
tags?: string[];
|
|
986
|
+
/** Start from this snapshot. Omit to start from the image. */
|
|
987
|
+
fromSnapshotId?: string;
|
|
988
|
+
/** Named disk to attach. Omit for no volume. */
|
|
989
|
+
volumeId?: string;
|
|
990
|
+
/** Metadata map. Omit for no labels. */
|
|
991
|
+
labels?: Record<string, string>;
|
|
992
|
+
/** CPU in thousandths of a core. Omit it for 1000. */
|
|
993
|
+
cpuMillicores?: number;
|
|
994
|
+
/** Guest memory in bytes. Omit = 1 GiB. */
|
|
995
|
+
memoryBytes?: number;
|
|
996
|
+
/** Writable state on top of the image, in bytes. The image is not counted. Omit = 1 GiB. */
|
|
997
|
+
diskBytes?: number;
|
|
998
|
+
};
|
|
999
|
+
/** A sandbox id string, `{ id }`, or `{ name }`. A string is always an id. */
|
|
1000
|
+
type SandboxRef = string | {
|
|
1001
|
+
/** Sandbox id. */
|
|
1002
|
+
id: string;
|
|
1003
|
+
} | {
|
|
1004
|
+
/** Sandbox name. */
|
|
1005
|
+
name: string;
|
|
1006
|
+
};
|
|
1007
|
+
/** Disconnect-safe guest process (`StartProcess`). Park / Close / idle-park
|
|
1008
|
+
* reboot the guest: `poll` / `follow` then `not_found`. Harvested output:
|
|
1009
|
+
* `Sandbox.logs()`. Start again after `open()`. */
|
|
1010
|
+
declare class ProcessHandle$1 {
|
|
1011
|
+
private readonly wire;
|
|
1012
|
+
private readonly sandbox;
|
|
1013
|
+
private info;
|
|
1014
|
+
/** Create the handle. */
|
|
1015
|
+
constructor(sandbox: Sandbox$1, info: Process, wire: Session);
|
|
1016
|
+
/** Id. */
|
|
1017
|
+
get id(): string;
|
|
1018
|
+
/** Status. */
|
|
1019
|
+
get status(): string;
|
|
1020
|
+
/** Service Name. */
|
|
1021
|
+
get serviceName(): string;
|
|
1022
|
+
/** Exit Code. */
|
|
1023
|
+
get exitCode(): number | null;
|
|
1024
|
+
/** Refresh status from GetProcess. */
|
|
1025
|
+
poll(): Promise<Process>;
|
|
1026
|
+
/** Block until the process exits. Raises ProcessWaitTimeoutError if it is still running. */
|
|
1027
|
+
wait(opts?: {
|
|
1028
|
+
timeout?: number;
|
|
1029
|
+
}): Promise<Process>;
|
|
1030
|
+
/** Send a POSIX signal (default SIGKILL). */
|
|
1031
|
+
kill(signal?: number): Promise<Process>;
|
|
1032
|
+
/** Write stdin. `eof: true` closes it. Data larger than 1 MiB is split across calls. */
|
|
1033
|
+
writeStdin(data?: Buffer | string, opts?: {
|
|
1034
|
+
eof?: boolean;
|
|
1035
|
+
}): Promise<void>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Follow stdout and stderr. Hang-up does not kill the process.
|
|
1038
|
+
*
|
|
1039
|
+
* Text mode yields one line at a time (a partial line is held until its
|
|
1040
|
+
* newline, or until the stream ends). `text: false` yields raw byte chunks.
|
|
1041
|
+
* `timeout` is seconds; when it elapses the iteration stops and the process
|
|
1042
|
+
* keeps running. Omit it, or pass 0, to follow until the process exits.
|
|
1043
|
+
*/
|
|
1044
|
+
follow(opts: {
|
|
1045
|
+
timeout?: number;
|
|
1046
|
+
fromStart?: boolean;
|
|
1047
|
+
text: false;
|
|
1048
|
+
signal?: AbortSignal;
|
|
1049
|
+
}): AsyncGenerator<StreamChunk>;
|
|
1050
|
+
/** Follow. */
|
|
1051
|
+
follow(opts?: {
|
|
1052
|
+
timeout?: number;
|
|
1053
|
+
fromStart?: boolean;
|
|
1054
|
+
text?: true;
|
|
1055
|
+
signal?: AbortSignal;
|
|
1056
|
+
}): AsyncGenerator<LogEntry>;
|
|
1057
|
+
private harvest;
|
|
1058
|
+
private followLines;
|
|
1059
|
+
private followBytes;
|
|
1060
|
+
}
|
|
1061
|
+
type RunSink = {
|
|
1062
|
+
write(chunk: string | Uint8Array): void;
|
|
1063
|
+
};
|
|
1064
|
+
/** One sandbox: run commands, read and write the workdir, park/open, delete.
|
|
1065
|
+
*
|
|
1066
|
+
* `await using` / `delete()` delete the box. Omit them for a persistent
|
|
1067
|
+
* agent and reconnect with `Sandbox.open(client, id)`. */
|
|
1068
|
+
declare class Sandbox$1 {
|
|
1069
|
+
/** Catalog client that shares this box's connection. */
|
|
1070
|
+
readonly client: Client$1;
|
|
1071
|
+
private readonly wire;
|
|
1072
|
+
/** Last record returned by create, get, open, or park. */
|
|
1073
|
+
info: SandboxInfo;
|
|
1074
|
+
private deleted;
|
|
1075
|
+
/** Create the handle. */
|
|
1076
|
+
constructor(wire: Session, info: SandboxInfo, catalog?: Client$1);
|
|
1077
|
+
/** CreateSandbox. The server mints the id. `name` is an optional lookup. */
|
|
1078
|
+
static create(client: Client$1 | Session, params: SandboxCreateParams$1): Promise<Sandbox$1>;
|
|
1079
|
+
/** OpenSandbox: wake by id or name. Does not create. */
|
|
1080
|
+
static open(client: Client$1 | Session, ref: SandboxRef): Promise<Sandbox$1>;
|
|
1081
|
+
/** GetSandbox by id or name. Does not wake. */
|
|
1082
|
+
static get(client: Client$1 | Session, ref: SandboxRef): Promise<Sandbox$1>;
|
|
1083
|
+
/** Wake this box if Sleeping. Ready + alive is a no-op. */
|
|
1084
|
+
open(opts?: {
|
|
1085
|
+
signal?: AbortSignal;
|
|
1086
|
+
}): Promise<SandboxInfo>;
|
|
1087
|
+
/** GetSandbox: live report. Does not wake Sleeping. */
|
|
1088
|
+
get(opts?: {
|
|
1089
|
+
signal?: AbortSignal;
|
|
1090
|
+
}): Promise<SandboxInfo>;
|
|
1091
|
+
/** Id. */
|
|
1092
|
+
get id(): string;
|
|
1093
|
+
/** Status. */
|
|
1094
|
+
get status(): string;
|
|
1095
|
+
/** Name. */
|
|
1096
|
+
get name(): string;
|
|
1097
|
+
/** Image. */
|
|
1098
|
+
get image(): string;
|
|
1099
|
+
/** Env. */
|
|
1100
|
+
get env(): Record<string, string>;
|
|
1101
|
+
/** Workdir. */
|
|
1102
|
+
get workdir(): string;
|
|
1103
|
+
/** Labels. */
|
|
1104
|
+
get labels(): Record<string, string>;
|
|
1105
|
+
/** Tags. */
|
|
1106
|
+
get tags(): string[];
|
|
1107
|
+
/** Net. */
|
|
1108
|
+
get net(): string;
|
|
1109
|
+
/** Volume Id. */
|
|
1110
|
+
get volumeId(): string;
|
|
1111
|
+
/** From Snapshot Id. */
|
|
1112
|
+
get fromSnapshotId(): string;
|
|
1113
|
+
/** Lifetime Remaining Sec. */
|
|
1114
|
+
get lifetimeRemainingSec(): number | null;
|
|
1115
|
+
/** True when the placement's worker is not a control-plane peer. Status is unchanged. */
|
|
1116
|
+
get workerUnreachable(): boolean;
|
|
1117
|
+
/** Idle Timeout Remaining Sec. */
|
|
1118
|
+
get idleTimeoutRemainingSec(): number | null;
|
|
1119
|
+
/** CPU given to the sandbox, in thousandths of a core. */
|
|
1120
|
+
get cpuMillicores(): number;
|
|
1121
|
+
/** Guest memory in bytes. */
|
|
1122
|
+
get memoryBytes(): number;
|
|
1123
|
+
/** Writable state on top of the image, in bytes. The image is not counted. */
|
|
1124
|
+
get diskBytes(): number;
|
|
1125
|
+
/** Lifetime Sec. */
|
|
1126
|
+
get lifetimeSec(): number;
|
|
1127
|
+
/** Idle Timeout Sec. */
|
|
1128
|
+
get idleTimeoutSec(): number;
|
|
1129
|
+
/** Exit Code. */
|
|
1130
|
+
get exitCode(): number | null;
|
|
1131
|
+
/** History stored for this sandbox. Newest first. An omitted window is the last 24 hours. */
|
|
1132
|
+
queryLogs(opts?: {
|
|
1133
|
+
processId?: string;
|
|
1134
|
+
stream?: LogStream$1 | "";
|
|
1135
|
+
streams?: Array<LogStream$1 | "">;
|
|
1136
|
+
contains?: string;
|
|
1137
|
+
caseInsensitive?: boolean;
|
|
1138
|
+
direction?: "forward" | "backward" | "";
|
|
1139
|
+
start?: string;
|
|
1140
|
+
end?: string;
|
|
1141
|
+
pageSize?: number;
|
|
1142
|
+
pageToken?: string;
|
|
1143
|
+
signal?: AbortSignal;
|
|
1144
|
+
}): Promise<LogPage>;
|
|
1145
|
+
/** Stdout and stderr the sandbox has already written. The lines remain after park. */
|
|
1146
|
+
logs(opts?: {
|
|
1147
|
+
processId?: string;
|
|
1148
|
+
pageSize?: number;
|
|
1149
|
+
pageToken?: string;
|
|
1150
|
+
stream?: LogStream$1 | "";
|
|
1151
|
+
signal?: AbortSignal;
|
|
1152
|
+
}): Promise<LogPage>;
|
|
1153
|
+
/** Every page of stdout and stderr. `logs` returns one page. */
|
|
1154
|
+
logsAll(opts?: {
|
|
1155
|
+
processId?: string;
|
|
1156
|
+
pageSize?: number;
|
|
1157
|
+
stream?: LogStream$1 | "";
|
|
1158
|
+
signal?: AbortSignal;
|
|
1159
|
+
}): AsyncGenerator<LogEntry>;
|
|
1160
|
+
/** Replace the label map. Not part of the Ensure profile. */
|
|
1161
|
+
setLabels(labels: Record<string, string> | undefined, opts?: {
|
|
1162
|
+
signal?: AbortSignal;
|
|
1163
|
+
}): Promise<SandboxInfo>;
|
|
1164
|
+
/** Replace sandbox tags. Names must already exist. Part of the Ensure profile. */
|
|
1165
|
+
setTags(tags: string[] | undefined, opts?: {
|
|
1166
|
+
signal?: AbortSignal;
|
|
1167
|
+
}): Promise<SandboxInfo>;
|
|
1168
|
+
/** Run a command. Hang-up kills it. Output is text unless `text` is false. */
|
|
1169
|
+
run(argv: string[], opts: {
|
|
1170
|
+
env?: Record<string, string>;
|
|
1171
|
+
cwd?: string;
|
|
1172
|
+
timeout?: number;
|
|
1173
|
+
stdin?: Buffer | string | NodeJS.ReadableStream | ReadableStream<Uint8Array>;
|
|
1174
|
+
text: false;
|
|
1175
|
+
stdout?: RunSink;
|
|
1176
|
+
stderr?: RunSink;
|
|
1177
|
+
signal?: AbortSignal;
|
|
1178
|
+
}): Promise<ExecBytesResult>;
|
|
1179
|
+
/** Run. */
|
|
1180
|
+
run(argv: string[], opts?: {
|
|
1181
|
+
env?: Record<string, string>;
|
|
1182
|
+
cwd?: string;
|
|
1183
|
+
timeout?: number;
|
|
1184
|
+
stdin?: Buffer | string | NodeJS.ReadableStream | ReadableStream<Uint8Array>;
|
|
1185
|
+
text?: true;
|
|
1186
|
+
stdout?: RunSink;
|
|
1187
|
+
stderr?: RunSink;
|
|
1188
|
+
signal?: AbortSignal;
|
|
1189
|
+
}): Promise<ExecResult>;
|
|
1190
|
+
/** Start a process that survives hang-up. Omit `timeout` (or pass 0) for a resident process. */
|
|
1191
|
+
start(argv: string[], opts?: {
|
|
1192
|
+
env?: Record<string, string>;
|
|
1193
|
+
cwd?: string;
|
|
1194
|
+
timeout?: number;
|
|
1195
|
+
serviceName?: string;
|
|
1196
|
+
holdsIdle?: boolean;
|
|
1197
|
+
endsSandbox?: boolean;
|
|
1198
|
+
}): Promise<ProcessHandle$1>;
|
|
1199
|
+
/** Handle for a process that is already running. */
|
|
1200
|
+
process(processId: string): Promise<ProcessHandle$1>;
|
|
1201
|
+
/** ListProcesses on this sandbox. */
|
|
1202
|
+
processes(): Promise<ProcessHandle$1[]>;
|
|
1203
|
+
/** Read one file as bytes. A relative path joins the sandbox workdir. */
|
|
1204
|
+
read(path: string, opts?: {
|
|
1205
|
+
timeout?: number;
|
|
1206
|
+
signal?: AbortSignal;
|
|
1207
|
+
}): Promise<Buffer>;
|
|
1208
|
+
/** Write a guest file or directory onto the local disk. */
|
|
1209
|
+
download(path: string, dest: string, opts?: {
|
|
1210
|
+
timeout?: number;
|
|
1211
|
+
signal?: AbortSignal;
|
|
1212
|
+
}): Promise<void>;
|
|
1213
|
+
/** List on the session volume. maxDepth 1 is one directory. 0 is the whole tree. */
|
|
1214
|
+
ls(path: string, opts?: {
|
|
1215
|
+
maxDepth?: number;
|
|
1216
|
+
signal?: AbortSignal;
|
|
1217
|
+
timeout?: number;
|
|
1218
|
+
}): Promise<FileList>;
|
|
1219
|
+
/** Stream a tar (optionally gzip) of a subtree to a local path. */
|
|
1220
|
+
exportPath(path: string, opts: {
|
|
1221
|
+
dest: string;
|
|
1222
|
+
gzip?: boolean;
|
|
1223
|
+
timeout?: number;
|
|
1224
|
+
signal?: AbortSignal;
|
|
1225
|
+
}): Promise<void>;
|
|
1226
|
+
/** Stat a file or directory on the session volume. */
|
|
1227
|
+
stat(path: string, opts?: {
|
|
1228
|
+
signal?: AbortSignal;
|
|
1229
|
+
}): Promise<FileInfo>;
|
|
1230
|
+
/** mkdir and rm, plus file bodies as one stream each, in the order given. Never parks. */
|
|
1231
|
+
write(ops: Array<FileOp$1 | FileSpec | Record<string, unknown>>, opts?: {
|
|
1232
|
+
timeout?: number;
|
|
1233
|
+
signal?: AbortSignal;
|
|
1234
|
+
}): Promise<void>;
|
|
1235
|
+
/** Wait until status is in `until`, or deleted. Returns null if deleted. */
|
|
1236
|
+
wait(opts: {
|
|
1237
|
+
until: SandboxStatus$1[];
|
|
1238
|
+
untilDeleted?: false;
|
|
1239
|
+
timeout?: number;
|
|
1240
|
+
signal?: AbortSignal;
|
|
1241
|
+
}): Promise<SandboxInfo>;
|
|
1242
|
+
/** Wait. */
|
|
1243
|
+
wait(opts: {
|
|
1244
|
+
untilDeleted: true;
|
|
1245
|
+
until?: undefined;
|
|
1246
|
+
timeout?: number;
|
|
1247
|
+
signal?: AbortSignal;
|
|
1248
|
+
}): Promise<null>;
|
|
1249
|
+
/** Wait. */
|
|
1250
|
+
wait(opts?: {
|
|
1251
|
+
until?: SandboxStatus$1[];
|
|
1252
|
+
untilDeleted?: boolean;
|
|
1253
|
+
timeout?: number;
|
|
1254
|
+
signal?: AbortSignal;
|
|
1255
|
+
}): Promise<SandboxInfo | null>;
|
|
1256
|
+
/** HTTP client for this guest port.
|
|
1257
|
+
*
|
|
1258
|
+
* Nothing is dialed until `get`, `post`, or `websocket`. `baseUrl` is
|
|
1259
|
+
* `https://sbx…/{sandbox-id}/{port}` and `X-Numen-Authorization` is this
|
|
1260
|
+
* project's credential. `websocket(path)` returns a `ws` `WebSocket` that is
|
|
1261
|
+
* already open. Closing the client does not hide the port.
|
|
1262
|
+
* Throws nothing by itself. `get` and `websocket` throw when the guest or the hop fails.
|
|
1263
|
+
*/
|
|
1264
|
+
http(port: number, opts?: {
|
|
1265
|
+
baseUrl?: string;
|
|
1266
|
+
}): Promise<GuestHttp>;
|
|
1267
|
+
/** HTTPS base for this guest port. No request is sent and the port is not published.
|
|
1268
|
+
*
|
|
1269
|
+
* Append the guest path and pass `getHeaders`. Closing an HTTP client does not hide the port.
|
|
1270
|
+
*/
|
|
1271
|
+
getBaseUrl(port: number, opts?: {
|
|
1272
|
+
baseUrl?: string;
|
|
1273
|
+
}): string;
|
|
1274
|
+
/** Project credential for the guest URL.
|
|
1275
|
+
*
|
|
1276
|
+
* `X-Numen-Authorization` with the project token, or an empty object when no token is configured.
|
|
1277
|
+
*/
|
|
1278
|
+
getHeaders(): Promise<Record<string, string>>;
|
|
1279
|
+
/** Mint a visitor credential for this sandbox port. The token is returned once.
|
|
1280
|
+
*
|
|
1281
|
+
* Omit `ttlSec` for one hour. The maximum is seven days. `getBaseUrl` does not call this.
|
|
1282
|
+
*/
|
|
1283
|
+
createHttpGrant(port: number, opts?: {
|
|
1284
|
+
ttlSec?: number;
|
|
1285
|
+
signal?: AbortSignal;
|
|
1286
|
+
}): Promise<HTTPGrant>;
|
|
1287
|
+
/** List HTTP grants for this sandbox. The secret is not included. */
|
|
1288
|
+
listHttpGrants(opts?: {
|
|
1289
|
+
signal?: AbortSignal;
|
|
1290
|
+
}): Promise<HTTPGrant[]>;
|
|
1291
|
+
/** Delete one HTTP grant in this project.
|
|
1292
|
+
*
|
|
1293
|
+
* The next request with that token fails immediately. An open WebSocket closes on the next check.
|
|
1294
|
+
*/
|
|
1295
|
+
deleteHttpGrant(id: string, opts?: {
|
|
1296
|
+
signal?: AbortSignal;
|
|
1297
|
+
}): Promise<void>;
|
|
1298
|
+
/** Admin ParkSandbox: reboot. Commit the writable layer, drop the VM, keep the id.
|
|
1299
|
+
* Overlay upper stays on this worker.
|
|
1300
|
+
* An open guest HTTP connection ends with the VMM; dial again after `open()`. */
|
|
1301
|
+
park(opts?: {
|
|
1302
|
+
signal?: AbortSignal;
|
|
1303
|
+
}): Promise<SandboxInfo>;
|
|
1304
|
+
/** Set CPU, guest memory, and the writable-state allocation while the sandbox is sleeping.
|
|
1305
|
+
*
|
|
1306
|
+
* Pass 0 to keep the current value. A Ready sandbox must park first. */
|
|
1307
|
+
setSize(packing: {
|
|
1308
|
+
cpuMillicores?: number;
|
|
1309
|
+
memoryBytes?: number;
|
|
1310
|
+
diskBytes?: number;
|
|
1311
|
+
}, opts?: {
|
|
1312
|
+
signal?: AbortSignal;
|
|
1313
|
+
}): Promise<SandboxInfo>;
|
|
1314
|
+
/** Write a file or directory. A relative path joins the sandbox workdir. Bytes, or `{ local }` for a file or directory on disk.
|
|
1315
|
+
*
|
|
1316
|
+
* `overwrite` applies only to a directory. It defaults to true: that guest directory becomes the uploaded
|
|
1317
|
+
* tree, and names that are not in the upload are removed. A failure partway through can leave those deletes
|
|
1318
|
+
* and the files already written. `overwrite: false` updates only the paths in the upload.
|
|
1319
|
+
*/
|
|
1320
|
+
upload(path: string, source: Buffer | string, opts?: {
|
|
1321
|
+
timeout?: number;
|
|
1322
|
+
mode?: number;
|
|
1323
|
+
}): Promise<void>;
|
|
1324
|
+
/** Upload. */
|
|
1325
|
+
upload(path: string, source: {
|
|
1326
|
+
local: string;
|
|
1327
|
+
timeout?: number;
|
|
1328
|
+
mode?: number;
|
|
1329
|
+
overwrite?: boolean;
|
|
1330
|
+
}): Promise<void>;
|
|
1331
|
+
private uploadDir;
|
|
1332
|
+
/** Create a directory on the session volume, including missing parents. */
|
|
1333
|
+
mkdir(path: string, opts?: {
|
|
1334
|
+
signal?: AbortSignal;
|
|
1335
|
+
}): Promise<void>;
|
|
1336
|
+
/** Remove a path. A missing path is success unless `missingOk` is false. Refuses the workdir root. */
|
|
1337
|
+
rm(path: string, opts?: {
|
|
1338
|
+
recursive?: boolean;
|
|
1339
|
+
missingOk?: boolean;
|
|
1340
|
+
signal?: AbortSignal;
|
|
1341
|
+
}): Promise<void>;
|
|
1342
|
+
/** Named pin of the writable layer. Parks if Ready/Finished, pins, then opens. */
|
|
1343
|
+
snapshot(opts?: {
|
|
1344
|
+
name?: string;
|
|
1345
|
+
labels?: Record<string, string>;
|
|
1346
|
+
}): Promise<Snapshot>;
|
|
1347
|
+
/** SDK glue: guest snap + N Create({ fromSnapshotId }). Not CreateMany. */
|
|
1348
|
+
clone(n?: number, opts?: {
|
|
1349
|
+
concurrency?: number;
|
|
1350
|
+
}): Promise<Sandbox$1[]>;
|
|
1351
|
+
/** Delete the sandbox. Idempotent if already gone. */
|
|
1352
|
+
delete(): Promise<void>;
|
|
1353
|
+
/** Delete the sandbox when the `await using` block ends. */
|
|
1354
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
/** Public SDK. Options objects, no sentinel empty strings, one lookup method per name. */
|
|
1358
|
+
|
|
1359
|
+
/** No deadline, no expiry, or the full file tree. */
|
|
1360
|
+
declare const UNLIMITED: number;
|
|
1361
|
+
declare const LogStream: {
|
|
1362
|
+
readonly STDOUT: "stdout";
|
|
1363
|
+
readonly STDERR: "stderr";
|
|
1364
|
+
readonly EVENT: "event";
|
|
1365
|
+
};
|
|
1366
|
+
type LogStream = (typeof LogStream)[keyof typeof LogStream];
|
|
1367
|
+
declare const SandboxStatus: {
|
|
1368
|
+
readonly PENDING: "Pending";
|
|
1369
|
+
readonly READY: "Ready";
|
|
1370
|
+
readonly SLEEPING: "Sleeping";
|
|
1371
|
+
readonly FINISHED: "Finished";
|
|
1372
|
+
readonly DELETING: "Deleting";
|
|
1373
|
+
};
|
|
1374
|
+
type SandboxStatus = (typeof SandboxStatus)[keyof typeof SandboxStatus];
|
|
1375
|
+
type Resources = {
|
|
1376
|
+
cpu?: number | string;
|
|
1377
|
+
memory?: number | string;
|
|
1378
|
+
disk?: number | string;
|
|
1379
|
+
};
|
|
1380
|
+
type Timeout = number;
|
|
1381
|
+
/** One sandbox from `list`. `name` is `null` when the sandbox is unnamed. */
|
|
1382
|
+
type SandboxRow = Omit<SandboxSummary, "name"> & {
|
|
1383
|
+
name: string | null;
|
|
1384
|
+
};
|
|
1385
|
+
type PageFetch<T> = (token: string) => Promise<Page<T>>;
|
|
1386
|
+
/** One page. Iterating yields `items`. */
|
|
1387
|
+
declare class Page<T> {
|
|
1388
|
+
readonly items: readonly T[];
|
|
1389
|
+
readonly nextPageToken: string | undefined;
|
|
1390
|
+
private readonly fetchPage;
|
|
1391
|
+
constructor(items: readonly T[], nextPageToken: string | undefined, fetchPage: PageFetch<T>);
|
|
1392
|
+
get hasMore(): boolean;
|
|
1393
|
+
next(): Promise<Page<T>>;
|
|
1394
|
+
[Symbol.iterator](): Iterator<T>;
|
|
1395
|
+
}
|
|
1396
|
+
declare class Write {
|
|
1397
|
+
readonly path: string;
|
|
1398
|
+
readonly data: Buffer | string;
|
|
1399
|
+
readonly mode?: number | undefined;
|
|
1400
|
+
constructor(path: string, data: Buffer | string, mode?: number | undefined);
|
|
1401
|
+
}
|
|
1402
|
+
declare class Mkdir {
|
|
1403
|
+
readonly path: string;
|
|
1404
|
+
constructor(path: string);
|
|
1405
|
+
}
|
|
1406
|
+
declare class Remove {
|
|
1407
|
+
readonly path: string;
|
|
1408
|
+
readonly recursive: boolean;
|
|
1409
|
+
constructor(path: string, recursive?: boolean);
|
|
1410
|
+
}
|
|
1411
|
+
declare function write(path: string, data: Buffer | string, mode?: number): Write;
|
|
1412
|
+
declare function mkdir(path: string): Mkdir;
|
|
1413
|
+
declare function remove(path: string, recursive?: boolean): Remove;
|
|
1414
|
+
type FileOp = Write | Mkdir | Remove;
|
|
1415
|
+
type ClientOptions = {
|
|
1416
|
+
baseUrl?: string;
|
|
1417
|
+
credentialsFile?: string;
|
|
1418
|
+
clientId?: string;
|
|
1419
|
+
clientSecret?: string;
|
|
1420
|
+
token?: string;
|
|
1421
|
+
tokenUrl?: string;
|
|
1422
|
+
maxRetries?: number;
|
|
1423
|
+
timeout?: Timeout;
|
|
1424
|
+
};
|
|
1425
|
+
/** Catalog client. `await using` closes the connection. */
|
|
1426
|
+
declare class Client {
|
|
1427
|
+
readonly maxRetries: number;
|
|
1428
|
+
/** @internal */
|
|
1429
|
+
readonly wire: Client$1;
|
|
1430
|
+
readonly volumes: Volumes;
|
|
1431
|
+
readonly secrets: Secrets;
|
|
1432
|
+
readonly images: Images;
|
|
1433
|
+
readonly snapshots: Snapshots;
|
|
1434
|
+
readonly tags: Tags;
|
|
1435
|
+
readonly sandboxes: Sandboxes;
|
|
1436
|
+
constructor(opts?: ClientOptions);
|
|
1437
|
+
close(): void;
|
|
1438
|
+
[Symbol.dispose](): void;
|
|
1439
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
1440
|
+
}
|
|
1441
|
+
declare class Volumes {
|
|
1442
|
+
private readonly client;
|
|
1443
|
+
constructor(client: Client);
|
|
1444
|
+
create(opts?: {
|
|
1445
|
+
name?: string;
|
|
1446
|
+
labels?: Record<string, string>;
|
|
1447
|
+
timeout?: Timeout;
|
|
1448
|
+
}): Promise<Volume>;
|
|
1449
|
+
get(id: string, opts?: {
|
|
1450
|
+
timeout?: Timeout;
|
|
1451
|
+
}): ReturnType<Client$1["volumes"]["get"]>;
|
|
1452
|
+
getByName(name: string, opts?: {
|
|
1453
|
+
timeout?: Timeout;
|
|
1454
|
+
}): ReturnType<Client$1["volumes"]["get"]>;
|
|
1455
|
+
list(opts?: ListOpts & {
|
|
1456
|
+
labels?: Record<string, string>;
|
|
1457
|
+
}): Promise<Page<Volume>>;
|
|
1458
|
+
iter(opts?: Omit<ListOpts, "pageToken"> & {
|
|
1459
|
+
labels?: Record<string, string>;
|
|
1460
|
+
limit?: number;
|
|
1461
|
+
}): AsyncGenerator<Volume>;
|
|
1462
|
+
update(id: string, opts: {
|
|
1463
|
+
labels: Record<string, string>;
|
|
1464
|
+
timeout?: Timeout;
|
|
1465
|
+
}): Promise<Volume>;
|
|
1466
|
+
delete(id: string, opts?: {
|
|
1467
|
+
missingOk?: boolean;
|
|
1468
|
+
timeout?: Timeout;
|
|
1469
|
+
}): Promise<void>;
|
|
1470
|
+
}
|
|
1471
|
+
declare class Secrets {
|
|
1472
|
+
private readonly client;
|
|
1473
|
+
constructor(client: Client);
|
|
1474
|
+
set(name: string, value: string, opts?: {
|
|
1475
|
+
timeout?: Timeout;
|
|
1476
|
+
}): Promise<Secret>;
|
|
1477
|
+
get(name: string, opts?: {
|
|
1478
|
+
timeout?: Timeout;
|
|
1479
|
+
}): Promise<Secret>;
|
|
1480
|
+
list(opts?: ListOpts): Promise<Page<Secret>>;
|
|
1481
|
+
iter(opts?: Omit<ListOpts, "pageToken"> & {
|
|
1482
|
+
limit?: number;
|
|
1483
|
+
}): AsyncGenerator<Secret>;
|
|
1484
|
+
delete(name: string, opts?: {
|
|
1485
|
+
missingOk?: boolean;
|
|
1486
|
+
timeout?: Timeout;
|
|
1487
|
+
}): Promise<void>;
|
|
1488
|
+
}
|
|
1489
|
+
declare class Images {
|
|
1490
|
+
private readonly client;
|
|
1491
|
+
constructor(client: Client);
|
|
1492
|
+
register(name: string, opts: {
|
|
1493
|
+
source: string;
|
|
1494
|
+
timeout?: Timeout;
|
|
1495
|
+
waitUntilReady?: boolean;
|
|
1496
|
+
waitSec?: number;
|
|
1497
|
+
}): Promise<Image>;
|
|
1498
|
+
build(name: string, opts?: {
|
|
1499
|
+
dockerfile?: string;
|
|
1500
|
+
context?: string;
|
|
1501
|
+
timeout?: Timeout;
|
|
1502
|
+
waitUntilReady?: boolean;
|
|
1503
|
+
waitSec?: number;
|
|
1504
|
+
}): Promise<Image>;
|
|
1505
|
+
get(name: string, opts?: {
|
|
1506
|
+
timeout?: Timeout;
|
|
1507
|
+
}): Promise<Image>;
|
|
1508
|
+
list(opts?: ListOpts): Promise<Page<Image>>;
|
|
1509
|
+
iter(opts?: Omit<ListOpts, "pageToken"> & {
|
|
1510
|
+
limit?: number;
|
|
1511
|
+
}): AsyncGenerator<Image>;
|
|
1512
|
+
delete(name: string, opts?: {
|
|
1513
|
+
missingOk?: boolean;
|
|
1514
|
+
timeout?: Timeout;
|
|
1515
|
+
}): Promise<void>;
|
|
1516
|
+
}
|
|
1517
|
+
declare class Snapshots {
|
|
1518
|
+
private readonly client;
|
|
1519
|
+
constructor(client: Client);
|
|
1520
|
+
get(id: string, opts?: {
|
|
1521
|
+
timeout?: Timeout;
|
|
1522
|
+
}): Promise<Snapshot>;
|
|
1523
|
+
getByName(name: string, opts?: {
|
|
1524
|
+
timeout?: Timeout;
|
|
1525
|
+
}): Promise<Snapshot>;
|
|
1526
|
+
list(opts?: ListOpts & {
|
|
1527
|
+
labels?: Record<string, string>;
|
|
1528
|
+
}): Promise<Page<Snapshot>>;
|
|
1529
|
+
iter(opts?: Omit<ListOpts, "pageToken"> & {
|
|
1530
|
+
labels?: Record<string, string>;
|
|
1531
|
+
limit?: number;
|
|
1532
|
+
}): AsyncGenerator<Snapshot>;
|
|
1533
|
+
update(id: string, opts: {
|
|
1534
|
+
labels: Record<string, string>;
|
|
1535
|
+
timeout?: Timeout;
|
|
1536
|
+
}): Promise<Snapshot>;
|
|
1537
|
+
delete(id: string, opts?: {
|
|
1538
|
+
missingOk?: boolean;
|
|
1539
|
+
timeout?: Timeout;
|
|
1540
|
+
}): Promise<void>;
|
|
1541
|
+
}
|
|
1542
|
+
/** A project name bound to one policy set. */
|
|
1543
|
+
declare class Tags {
|
|
1544
|
+
private readonly client;
|
|
1545
|
+
constructor(client: Client);
|
|
1546
|
+
create(name: string, opts?: {
|
|
1547
|
+
policyId?: string;
|
|
1548
|
+
timeout?: Timeout;
|
|
1549
|
+
}): Promise<Tag>;
|
|
1550
|
+
get(id: string, opts?: {
|
|
1551
|
+
timeout?: Timeout;
|
|
1552
|
+
}): Promise<Tag>;
|
|
1553
|
+
/** Walks every page of `list`. */
|
|
1554
|
+
getByName(name: string, opts?: {
|
|
1555
|
+
timeout?: Timeout;
|
|
1556
|
+
}): Promise<Tag>;
|
|
1557
|
+
list(opts?: ListOpts): Promise<Page<Tag>>;
|
|
1558
|
+
iter(opts?: Omit<ListOpts, "pageToken"> & {
|
|
1559
|
+
limit?: number;
|
|
1560
|
+
}): AsyncGenerator<Tag>;
|
|
1561
|
+
update(id: string, opts: {
|
|
1562
|
+
policyId: string;
|
|
1563
|
+
timeout?: Timeout;
|
|
1564
|
+
}): Promise<Tag>;
|
|
1565
|
+
delete(id: string, opts?: {
|
|
1566
|
+
missingOk?: boolean;
|
|
1567
|
+
timeout?: Timeout;
|
|
1568
|
+
}): Promise<void>;
|
|
1569
|
+
}
|
|
1570
|
+
type ListOpts = {
|
|
1571
|
+
pageSize?: number;
|
|
1572
|
+
pageToken?: string;
|
|
1573
|
+
timeout?: Timeout;
|
|
1574
|
+
};
|
|
1575
|
+
type SandboxCreateParams = {
|
|
1576
|
+
image: string;
|
|
1577
|
+
name?: string;
|
|
1578
|
+
env?: Record<string, string>;
|
|
1579
|
+
workdir?: string;
|
|
1580
|
+
lifetime?: number;
|
|
1581
|
+
idleTimeout?: number;
|
|
1582
|
+
fromSnapshotId?: string;
|
|
1583
|
+
volumeId?: string;
|
|
1584
|
+
labels?: Record<string, string>;
|
|
1585
|
+
tags?: string[];
|
|
1586
|
+
resources?: Resources;
|
|
1587
|
+
deleteOnExit?: boolean;
|
|
1588
|
+
};
|
|
1589
|
+
declare class Sandboxes {
|
|
1590
|
+
private readonly client;
|
|
1591
|
+
constructor(client: Client);
|
|
1592
|
+
create(opts: SandboxCreateParams): Promise<Sandbox>;
|
|
1593
|
+
get(id: string): Promise<Sandbox>;
|
|
1594
|
+
getByName(name: string): Promise<Sandbox>;
|
|
1595
|
+
resume(id: string): Promise<Sandbox>;
|
|
1596
|
+
list(opts?: ListOpts & {
|
|
1597
|
+
labels?: Record<string, string>;
|
|
1598
|
+
tags?: string[];
|
|
1599
|
+
status?: SandboxStatus | readonly SandboxStatus[];
|
|
1600
|
+
}): Promise<Page<SandboxRow>>;
|
|
1601
|
+
iter(opts?: Omit<ListOpts, "pageToken"> & {
|
|
1602
|
+
labels?: Record<string, string>;
|
|
1603
|
+
tags?: string[];
|
|
1604
|
+
status?: SandboxStatus | readonly SandboxStatus[];
|
|
1605
|
+
limit?: number;
|
|
1606
|
+
}): AsyncGenerator<SandboxRow>;
|
|
1607
|
+
delete(id: string, opts?: {
|
|
1608
|
+
missingOk?: boolean;
|
|
1609
|
+
timeout?: Timeout;
|
|
1610
|
+
}): Promise<void>;
|
|
1611
|
+
}
|
|
1612
|
+
/** One sandbox. `info` is the last snapshot. `get` refreshes it and does not wake. */
|
|
1613
|
+
declare class Sandbox {
|
|
1614
|
+
readonly client: Client;
|
|
1615
|
+
/** @internal */
|
|
1616
|
+
readonly inner: Sandbox$1;
|
|
1617
|
+
readonly fs: Files;
|
|
1618
|
+
readonly logs: Logs;
|
|
1619
|
+
readonly processes: Processes;
|
|
1620
|
+
readonly httpGrants: HTTPGrants;
|
|
1621
|
+
deleteOnExit: boolean;
|
|
1622
|
+
constructor(client: Client,
|
|
1623
|
+
/** @internal */
|
|
1624
|
+
inner: Sandbox$1, deleteOnExit: boolean);
|
|
1625
|
+
get info(): ReturnType<Sandbox$1["get"]> extends Promise<infer T> ? T : never;
|
|
1626
|
+
get id(): string;
|
|
1627
|
+
get(): ReturnType<Sandbox$1["get"]>;
|
|
1628
|
+
wake(opts?: {
|
|
1629
|
+
wait?: boolean;
|
|
1630
|
+
timeout?: Timeout;
|
|
1631
|
+
}): ReturnType<Sandbox$1["open"]>;
|
|
1632
|
+
sleep(opts?: {
|
|
1633
|
+
wait?: boolean;
|
|
1634
|
+
timeout?: Timeout;
|
|
1635
|
+
}): ReturnType<Sandbox$1["park"]>;
|
|
1636
|
+
wait(opts: {
|
|
1637
|
+
until: SandboxStatus | readonly SandboxStatus[];
|
|
1638
|
+
timeout?: Timeout;
|
|
1639
|
+
}): ReturnType<Sandbox$1["wait"]>;
|
|
1640
|
+
waitDeleted(opts?: {
|
|
1641
|
+
timeout?: Timeout;
|
|
1642
|
+
}): Promise<null>;
|
|
1643
|
+
resize(opts: {
|
|
1644
|
+
cpu?: number | string;
|
|
1645
|
+
memory?: number | string;
|
|
1646
|
+
disk?: number | string;
|
|
1647
|
+
}): ReturnType<Sandbox$1["setSize"]>;
|
|
1648
|
+
update(opts: {
|
|
1649
|
+
labels?: Record<string, string>;
|
|
1650
|
+
tags?: string[];
|
|
1651
|
+
}): Promise<unknown>;
|
|
1652
|
+
run(argv: string[], opts?: {
|
|
1653
|
+
env?: Record<string, string>;
|
|
1654
|
+
cwd?: string;
|
|
1655
|
+
timeout?: Timeout;
|
|
1656
|
+
stdin?: Buffer | string;
|
|
1657
|
+
check?: boolean;
|
|
1658
|
+
onStdout?: (chunk: string | Uint8Array) => void;
|
|
1659
|
+
onStderr?: (chunk: string | Uint8Array) => void;
|
|
1660
|
+
signal?: AbortSignal;
|
|
1661
|
+
}): Promise<ExecResult>;
|
|
1662
|
+
runBytes(argv: string[], opts?: {
|
|
1663
|
+
env?: Record<string, string>;
|
|
1664
|
+
cwd?: string;
|
|
1665
|
+
timeout?: Timeout;
|
|
1666
|
+
stdin?: Buffer | string;
|
|
1667
|
+
check?: boolean;
|
|
1668
|
+
onStdout?: (chunk: string | Uint8Array) => void;
|
|
1669
|
+
onStderr?: (chunk: string | Uint8Array) => void;
|
|
1670
|
+
signal?: AbortSignal;
|
|
1671
|
+
}): Promise<ExecBytesResult>;
|
|
1672
|
+
private exec;
|
|
1673
|
+
sh(command: string, opts?: Parameters<Sandbox["run"]>[1]): Promise<ExecResult>;
|
|
1674
|
+
start(argv: string[], opts?: {
|
|
1675
|
+
env?: Record<string, string>;
|
|
1676
|
+
cwd?: string;
|
|
1677
|
+
timeout?: Timeout;
|
|
1678
|
+
name?: string;
|
|
1679
|
+
keepAlive?: boolean;
|
|
1680
|
+
endsSandbox?: boolean;
|
|
1681
|
+
}): Promise<ProcessHandle>;
|
|
1682
|
+
clone(opts?: {
|
|
1683
|
+
count?: number;
|
|
1684
|
+
concurrency?: number;
|
|
1685
|
+
}): Promise<Sandbox[]>;
|
|
1686
|
+
snapshot(opts?: {
|
|
1687
|
+
name?: string;
|
|
1688
|
+
labels?: Record<string, string>;
|
|
1689
|
+
}): ReturnType<Sandbox$1["snapshot"]>;
|
|
1690
|
+
http(port: number, opts?: {
|
|
1691
|
+
baseUrl?: string;
|
|
1692
|
+
}): Promise<GuestHttp>;
|
|
1693
|
+
delete(): Promise<void>;
|
|
1694
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
1695
|
+
}
|
|
1696
|
+
declare class Files {
|
|
1697
|
+
private readonly sandbox;
|
|
1698
|
+
constructor(sandbox: Sandbox);
|
|
1699
|
+
read(path: string, opts?: {
|
|
1700
|
+
timeout?: Timeout;
|
|
1701
|
+
}): Promise<Buffer>;
|
|
1702
|
+
readText(path: string, opts?: {
|
|
1703
|
+
timeout?: Timeout;
|
|
1704
|
+
}): Promise<string>;
|
|
1705
|
+
write(path: string, data: Buffer | string, opts?: {
|
|
1706
|
+
mode?: number;
|
|
1707
|
+
timeout?: Timeout;
|
|
1708
|
+
}): Promise<void>;
|
|
1709
|
+
upload(local: string, remote: string, opts?: {
|
|
1710
|
+
overwrite?: boolean;
|
|
1711
|
+
mode?: number;
|
|
1712
|
+
timeout?: Timeout;
|
|
1713
|
+
}): Promise<void>;
|
|
1714
|
+
download(remote: string, local: string, opts?: {
|
|
1715
|
+
timeout?: Timeout;
|
|
1716
|
+
}): Promise<void>;
|
|
1717
|
+
list(path: string, opts?: {
|
|
1718
|
+
depth?: number;
|
|
1719
|
+
timeout?: Timeout;
|
|
1720
|
+
}): ReturnType<Sandbox$1["ls"]>;
|
|
1721
|
+
stat(path: string): ReturnType<Sandbox$1["stat"]>;
|
|
1722
|
+
mkdir(path: string): Promise<void>;
|
|
1723
|
+
remove(path: string, opts?: {
|
|
1724
|
+
recursive?: boolean;
|
|
1725
|
+
missingOk?: boolean;
|
|
1726
|
+
}): Promise<void>;
|
|
1727
|
+
export(path: string, dest: string, opts?: {
|
|
1728
|
+
gzip?: boolean;
|
|
1729
|
+
timeout?: Timeout;
|
|
1730
|
+
}): Promise<void>;
|
|
1731
|
+
batch(ops: FileOp[], opts?: {
|
|
1732
|
+
timeout?: Timeout;
|
|
1733
|
+
}): Promise<void>;
|
|
1734
|
+
}
|
|
1735
|
+
declare class Logs {
|
|
1736
|
+
private readonly sandbox;
|
|
1737
|
+
private readonly processId?;
|
|
1738
|
+
constructor(sandbox: Sandbox, processId?: string | undefined);
|
|
1739
|
+
list(opts?: {
|
|
1740
|
+
processId?: string;
|
|
1741
|
+
stream?: "stdout" | "stderr" | "event";
|
|
1742
|
+
contains?: string;
|
|
1743
|
+
start?: Date;
|
|
1744
|
+
end?: Date;
|
|
1745
|
+
pageSize?: number;
|
|
1746
|
+
pageToken?: string;
|
|
1747
|
+
}): Promise<Page<LogEntry>>;
|
|
1748
|
+
iter(opts?: Parameters<Logs["list"]>[0] & {
|
|
1749
|
+
limit?: number;
|
|
1750
|
+
}): AsyncGenerator<LogEntry>;
|
|
1751
|
+
}
|
|
1752
|
+
declare class Processes {
|
|
1753
|
+
private readonly sandbox;
|
|
1754
|
+
constructor(sandbox: Sandbox);
|
|
1755
|
+
get(id: string): Promise<ProcessHandle>;
|
|
1756
|
+
list(): Promise<ProcessHandle[]>;
|
|
1757
|
+
}
|
|
1758
|
+
declare class HTTPGrants {
|
|
1759
|
+
private readonly sandbox;
|
|
1760
|
+
constructor(sandbox: Sandbox);
|
|
1761
|
+
create(port: number, opts?: {
|
|
1762
|
+
ttl?: number;
|
|
1763
|
+
}): ReturnType<Sandbox$1["createHttpGrant"]>;
|
|
1764
|
+
list(): Promise<HTTPGrant[]>;
|
|
1765
|
+
delete(id: string): Promise<void>;
|
|
1766
|
+
}
|
|
1767
|
+
/** One guest process. */
|
|
1768
|
+
declare class ProcessHandle {
|
|
1769
|
+
private readonly inner;
|
|
1770
|
+
readonly logs: Logs;
|
|
1771
|
+
constructor(sandbox: Sandbox, inner: ProcessHandle$1);
|
|
1772
|
+
get id(): string;
|
|
1773
|
+
get status(): string;
|
|
1774
|
+
get name(): string;
|
|
1775
|
+
get exitCode(): number | null;
|
|
1776
|
+
poll(): ReturnType<ProcessHandle$1["poll"]>;
|
|
1777
|
+
wait(opts?: {
|
|
1778
|
+
timeout?: Timeout;
|
|
1779
|
+
}): ReturnType<ProcessHandle$1["wait"]>;
|
|
1780
|
+
kill(signal?: number | string): ReturnType<ProcessHandle$1["kill"]>;
|
|
1781
|
+
writeStdin(data?: Buffer | string, opts?: {
|
|
1782
|
+
eof?: boolean;
|
|
1783
|
+
}): Promise<void>;
|
|
1784
|
+
closeStdin(): Promise<void>;
|
|
1785
|
+
follow(opts?: {
|
|
1786
|
+
timeout?: Timeout;
|
|
1787
|
+
fromStart?: boolean;
|
|
1788
|
+
signal?: AbortSignal;
|
|
1789
|
+
}): ReturnType<ProcessHandle$1["follow"]>;
|
|
1790
|
+
followBytes(opts?: {
|
|
1791
|
+
timeout?: Timeout;
|
|
1792
|
+
fromStart?: boolean;
|
|
1793
|
+
signal?: AbortSignal;
|
|
1794
|
+
}): AsyncGenerator<unknown>;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
/** TypeScript SDK for numen.sandbox.v1. */
|
|
1798
|
+
|
|
1799
|
+
declare const publicExports: readonly ["AuthenticationError", "CapacityError", "Client", "CommandFailedError", "CommandTimeoutError", "CommandTooLargeError", "ConflictError", "DirectoryNotEmptyError", "ExecutableNotFoundError", "FileExistsError", "FileNotFoundError", "FileTooLargeError", "GuestRuntimeDeadError", "InvalidArgumentError", "InvalidPathError", "Mkdir", "UNLIMITED", "NameTakenError", "NotFoundError", "Page", "PathNotFoundError", "PageExhaustedError", "PermissionDeniedError", "PortNotOpenError", "ProcessHandle", "ProcessNotFoundError", "ProcessWaitTimeoutError", "Remove", "Sandbox", "SandboxConflictError", "SandboxError", "SandboxNotFoundError", "SandboxNotReadyError", "SandboxSleepingError", "SandboxStateError", "LogStream", "SandboxStatus", "SandboxWaitTimeoutError", "SandboxTimeoutError", "UnavailableError", "Write", "mkdir", "publicExports", "remove", "write"];
|
|
1800
|
+
|
|
1801
|
+
export { AuthenticationError, CapacityError, Client, type ClientOptions, CommandFailedError, CommandTimeoutError, CommandTooLargeError, ConflictError, DirectoryNotEmptyError, type ExecBytesResult, type ExecResult, ExecutableNotFoundError, FileExistsError, FileNotFoundError, FileTooLargeError, GuestRuntimeDeadError, InvalidArgumentError, InvalidPathError, LogStream, Mkdir, NameTakenError, NotFoundError, Page, PageExhaustedError, PathNotFoundError, PermissionDeniedError, PortNotOpenError, ProcessHandle, ProcessNotFoundError, ProcessWaitTimeoutError, Remove, type Resources, Sandbox, SandboxConflictError, type SandboxCreateParams, SandboxError, SandboxNotFoundError, SandboxNotReadyError, SandboxSleepingError, SandboxStateError, SandboxStatus, SandboxTimeoutError, SandboxWaitTimeoutError, type StreamChunk, UNLIMITED, UnavailableError, Write, mkdir, publicExports, remove, write };
|