@insforge/instabox-sdk 0.5.3 → 0.6.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 +59 -40
- package/dist/index.cjs +783 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +227 -40
- package/dist/index.d.ts +227 -40
- package/dist/index.js +783 -82
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/instabox/SKILL.md +21 -25
package/dist/index.d.cts
CHANGED
|
@@ -19,15 +19,36 @@ declare class InstaboxError extends Error {
|
|
|
19
19
|
readonly operationId?: string | null;
|
|
20
20
|
constructor(message: string, init?: InstaboxErrorInit);
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* 401 / 403 that is not a plan limit: invalid, expired or revoked API key, a missing scope, or no
|
|
24
|
+
* access (`permission_denied`). Also no API key at all (`missing_api_key`, status 0).
|
|
25
|
+
*/
|
|
23
26
|
declare class InstaboxAuthError extends InstaboxError {
|
|
24
27
|
}
|
|
25
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* A quota, plan or billing limit, the CLI's exit code 5: any code in `LIMIT_CODES` whatever the
|
|
30
|
+
* status (for example 403 `template_not_allowed`, 400 `spec_not_allowed`, 402 `credit_exhausted`,
|
|
31
|
+
* 429 `quota_exceeded`), and any other 402 or 429. A new key will not help; the plan, the account's
|
|
32
|
+
* usage or (for `rate_limited` and `concurrency_limit`) waiting will.
|
|
33
|
+
*/
|
|
26
34
|
declare class InstaboxQuotaError extends InstaboxError {
|
|
27
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* API error codes of a quota, plan or billing limit, as the instabox CLI classes them (exit code 5).
|
|
38
|
+
* They throw `InstaboxQuotaError` whatever the HTTP status.
|
|
39
|
+
*/
|
|
40
|
+
declare const LIMIT_CODES: readonly string[];
|
|
41
|
+
/** True for a quota, plan or billing limit code (`LIMIT_CODES`). */
|
|
42
|
+
declare function isLimitCode(code: string | undefined): boolean;
|
|
28
43
|
/** A request or an operation did not finish in time. */
|
|
29
44
|
declare class InstaboxTimeoutError extends InstaboxError {
|
|
30
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* `files.read` in the default text format met bytes that are not valid UTF-8 (`not_utf8`, status 0).
|
|
48
|
+
* Read the file with `{ format: 'bytes' }` instead; text reads never return U+FFFD for bad bytes.
|
|
49
|
+
*/
|
|
50
|
+
declare class InstaboxNotUtf8Error extends InstaboxError {
|
|
51
|
+
}
|
|
31
52
|
/** Result of a finished command. */
|
|
32
53
|
interface CommandResult {
|
|
33
54
|
stdout: string;
|
|
@@ -92,10 +113,7 @@ interface Machine {
|
|
|
92
113
|
processesPreserved?: boolean;
|
|
93
114
|
};
|
|
94
115
|
lastError?: ApiError;
|
|
95
|
-
/** When the server pauses or deletes the machine (see `onTimeout`); null for no timeout. */
|
|
96
|
-
timeoutAt?: string | null;
|
|
97
116
|
archiveAt?: string | null;
|
|
98
|
-
onTimeout?: OnTimeout;
|
|
99
117
|
/** Idle seconds after which the server pauses the running machine; null when it never does. */
|
|
100
118
|
autoSuspendAfterSeconds?: number | null;
|
|
101
119
|
/** When the server paused it for idleness; cleared by the next explicit operation. */
|
|
@@ -149,8 +167,6 @@ interface MachineVault {
|
|
|
149
167
|
/** The last write into the machine; null before one. */
|
|
150
168
|
applied: VaultApplied | null;
|
|
151
169
|
}
|
|
152
|
-
/** What happens at `timeoutAt`: `pause` suspends the machine, `kill` deletes it. */
|
|
153
|
-
type OnTimeout = 'pause' | 'kill';
|
|
154
170
|
interface MachineList {
|
|
155
171
|
machines: Machine[];
|
|
156
172
|
nextCursor: string | null;
|
|
@@ -263,6 +279,58 @@ interface UsageLimits {
|
|
|
263
279
|
maxBytes: number;
|
|
264
280
|
};
|
|
265
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* `Usage.cost`: the workspace's usage this calendar month (UTC) in USD, as the hourly rating priced
|
|
284
|
+
* it, with its allowance and credit balance. The same figures as `GET /v1/orgs/{id}` `usage`.
|
|
285
|
+
*/
|
|
286
|
+
interface UsageCost {
|
|
287
|
+
periodStart: string;
|
|
288
|
+
periodEnd: string;
|
|
289
|
+
/** Live sandboxes; `freeMachines` of them are free (never billed). */
|
|
290
|
+
machines: number;
|
|
291
|
+
freeMachines: number;
|
|
292
|
+
/** Wall-clock running hours of the free sandboxes this month (not vCPU-weighted). */
|
|
293
|
+
freeSandboxHours: number;
|
|
294
|
+
snapshots: number;
|
|
295
|
+
vcpuHours: number;
|
|
296
|
+
memGiBHours: number;
|
|
297
|
+
/** Allocated /data of paid sandboxes beyond the free amount each, summed over the hours. */
|
|
298
|
+
storageGiBHours: number;
|
|
299
|
+
/** Egress beyond the free amount. */
|
|
300
|
+
egressGiB: number;
|
|
301
|
+
runtimeUSD: number;
|
|
302
|
+
storageUSD: number;
|
|
303
|
+
egressUSD: number;
|
|
304
|
+
/** The month's usage so far. */
|
|
305
|
+
costUSD: number;
|
|
306
|
+
/** What the month includes: the free credit, or what the subscription paid for. */
|
|
307
|
+
allowanceUSD: number;
|
|
308
|
+
/** The allowance left. */
|
|
309
|
+
creditRemainingUSD: number;
|
|
310
|
+
/** Usage beyond the allowance (billed at month end on a paid plan). */
|
|
311
|
+
overageUSD: number;
|
|
312
|
+
/** What may still be used before the workspace's sandboxes are stopped. */
|
|
313
|
+
remainingUSD: number;
|
|
314
|
+
/** The rating covers usage up to this time. */
|
|
315
|
+
ratedUntil: string;
|
|
316
|
+
/** The /data being billed now: paid sandboxes' disk beyond `freeDiskGiBPerSandbox`. */
|
|
317
|
+
billableDiskGiB: number;
|
|
318
|
+
/** Absent from servers before per-sandbox disk billing. */
|
|
319
|
+
freeDiskGiBPerSandbox?: number;
|
|
320
|
+
/** The /data of all live sandboxes, free ones included. */
|
|
321
|
+
allocatedDiskGiB: number;
|
|
322
|
+
/** @deprecated always null; read `billableDiskGiB`. */
|
|
323
|
+
storedBytes: number | null;
|
|
324
|
+
/** @deprecated always null. */
|
|
325
|
+
storageComputedAt: string | null;
|
|
326
|
+
/** What the unexpired credits have left; `creditsExpireAt` is when the earliest expires. */
|
|
327
|
+
creditsUSD: number;
|
|
328
|
+
creditsExpireAt?: string;
|
|
329
|
+
/** What credits paid this month. */
|
|
330
|
+
creditsUsedUSD: number;
|
|
331
|
+
/** Usage beyond the allowance already charged this month (threshold billing). */
|
|
332
|
+
chargedUSD?: number;
|
|
333
|
+
}
|
|
266
334
|
/** Response of `GET /v1/usage`: your counts, stored bytes (measured about hourly) and limits. */
|
|
267
335
|
interface Usage {
|
|
268
336
|
/** When the byte figures were measured; null before your first measurement. */
|
|
@@ -277,6 +345,8 @@ interface Usage {
|
|
|
277
345
|
limits: UsageLimits;
|
|
278
346
|
/** `storedBytes` by sandbox. Absent before your first measurement. */
|
|
279
347
|
storage?: UsageStorage;
|
|
348
|
+
/** This month's cost, allowance and credits. Absent from older servers. */
|
|
349
|
+
cost?: UsageCost;
|
|
280
350
|
}
|
|
281
351
|
/** Response of `POST /v1/machines/{id}/exec`. */
|
|
282
352
|
interface ExecResponse {
|
|
@@ -309,24 +379,55 @@ interface ConnectionOptions {
|
|
|
309
379
|
interface RequestOptions {
|
|
310
380
|
timeoutMs?: number;
|
|
311
381
|
body?: unknown;
|
|
382
|
+
/** A raw request body, sent as `application/octet-stream` instead of JSON. */
|
|
383
|
+
rawBody?: Uint8Array;
|
|
312
384
|
query?: Record<string, string | number | string[] | undefined>;
|
|
313
385
|
/** Retry on 502/503/504 and network errors. Default: true for GET and for requests carrying an Idempotency-Key. */
|
|
314
386
|
retry?: boolean;
|
|
315
387
|
/** Send an Idempotency-Key. Default: true for every method other than GET/HEAD. */
|
|
316
388
|
idempotent?: boolean;
|
|
389
|
+
/** Extra request headers (for example X-Confirm-Delete). */
|
|
390
|
+
headers?: Record<string, string>;
|
|
391
|
+
/** Value of the Accept header. Default `application/json`. */
|
|
392
|
+
accept?: string;
|
|
393
|
+
/**
|
|
394
|
+
* Aborts the request, and the reading of its response body after `send` returned. An abort before
|
|
395
|
+
* the response arrived throws `InstaboxError` with code `aborted`.
|
|
396
|
+
*/
|
|
397
|
+
signal?: AbortSignal;
|
|
317
398
|
}
|
|
318
399
|
declare class HttpClient {
|
|
400
|
+
#private;
|
|
319
401
|
readonly apiUrl: string;
|
|
320
402
|
readonly operationTimeoutMs: number;
|
|
321
|
-
private readonly apiKey;
|
|
322
403
|
private readonly requestTimeoutMs?;
|
|
323
404
|
private readonly fetchImpl;
|
|
324
405
|
readonly pollIntervalMs: number;
|
|
325
406
|
private readonly retryDelayMs;
|
|
407
|
+
/** Removes the caller's abort listener of a response `send` returned; see `release`. */
|
|
408
|
+
private readonly releases;
|
|
326
409
|
constructor(opts?: ConnectionOptions);
|
|
327
410
|
request<T>(method: string, path: string, opts?: RequestOptions): Promise<T>;
|
|
411
|
+
/**
|
|
412
|
+
* Unwires the caller's `signal` from a response `send` returned, once its body is read or dropped.
|
|
413
|
+
* Until then an abort still ends the body; after it the signal holds no listener of this request,
|
|
414
|
+
* so a signal shared by many requests (a long `wait()`) does not collect one per request.
|
|
415
|
+
*/
|
|
416
|
+
release(res: Response): void;
|
|
328
417
|
/** Performs the request with retries; returns a 2xx response or throws an InstaboxError. */
|
|
329
418
|
send(method: string, path: string, opts?: RequestOptions): Promise<Response>;
|
|
419
|
+
/** The deadline of one request: `requestTimeoutMs` when set, else `defaultMs`. */
|
|
420
|
+
requestTimeout(defaultMs: number): number;
|
|
421
|
+
/**
|
|
422
|
+
* The error for an API error envelope found in a 2xx response body (a streamed exec's `error`
|
|
423
|
+
* event), with the API key redacted as for an error response.
|
|
424
|
+
*/
|
|
425
|
+
errorFromBody(status: number, text: string, fallbackMessage: string): InstaboxError;
|
|
426
|
+
/** JSON form, without the API key. */
|
|
427
|
+
toJSON(): {
|
|
428
|
+
apiUrl: string;
|
|
429
|
+
apiKey: string;
|
|
430
|
+
};
|
|
330
431
|
private backoff;
|
|
331
432
|
/** Polls an operation until it is `succeeded` (returns it) or `failed` (throws). */
|
|
332
433
|
waitForOperation(op: Operation, timeoutMs?: number): Promise<Operation>;
|
|
@@ -339,27 +440,72 @@ interface CommandOptions {
|
|
|
339
440
|
cwd?: string;
|
|
340
441
|
/** Extra environment variables, merged over the sandbox-level `envs` from `Sandbox.create`. */
|
|
341
442
|
envs?: Record<string, string>;
|
|
342
|
-
/**
|
|
443
|
+
/**
|
|
444
|
+
* Command timeout in ms (sent as whole seconds), at most 600 000. Default: the server's default (60 s).
|
|
445
|
+
* For a longer command use `background: true` and `wait()` on the handle.
|
|
446
|
+
*/
|
|
343
447
|
timeoutMs?: number;
|
|
344
448
|
/** Text sent to the command's standard input, at most 1 MiB (UTF-8). */
|
|
345
449
|
stdin?: string;
|
|
346
450
|
/**
|
|
347
|
-
* Called with stdout
|
|
348
|
-
* the
|
|
451
|
+
* Called with each chunk of stdout as the command writes it. With `onStdout` or `onStderr` set, the
|
|
452
|
+
* output is streamed and not capped: the result still carries the whole stdout and stderr.
|
|
453
|
+
* A returned promise is awaited before the next chunk is delivered. Not allowed with `background: true`
|
|
454
|
+
* (throws `bad_request`): pass `onStdout` to `wait()` on the handle instead.
|
|
349
455
|
*/
|
|
350
456
|
onStdout?: (data: string) => unknown;
|
|
351
457
|
/** Like `onStdout`, for stderr. */
|
|
352
458
|
onStderr?: (data: string) => unknown;
|
|
353
|
-
/**
|
|
459
|
+
/**
|
|
460
|
+
* Start the command detached, as a job in its own session, and return right away with a handle.
|
|
461
|
+
* Its output is kept in the sandbox; `wait()` on the handle follows it. Not limited to 10 minutes.
|
|
462
|
+
* Needs bash, util-linux `setsid` and GNU coreutils in the sandbox; without them it throws
|
|
463
|
+
* `InstaboxError` with code `background_unsupported`, naming what is missing.
|
|
464
|
+
*/
|
|
354
465
|
background?: boolean;
|
|
466
|
+
/**
|
|
467
|
+
* Stops the command: the request is closed, which kills the command in the sandbox, and `run` throws
|
|
468
|
+
* `InstaboxError` with code `aborted`. With `background: true` it only aborts the start.
|
|
469
|
+
*/
|
|
470
|
+
signal?: AbortSignal;
|
|
471
|
+
}
|
|
472
|
+
/** Options of `CommandHandle.wait`. */
|
|
473
|
+
interface CommandWaitOptions {
|
|
474
|
+
/**
|
|
475
|
+
* Called with each chunk of the job's output as it is written, from the start. A background command's
|
|
476
|
+
* stdout and stderr go to one log, so both arrive here.
|
|
477
|
+
*/
|
|
478
|
+
onStdout?: (data: string) => unknown;
|
|
479
|
+
/** Give up after this long: throws `InstaboxTimeoutError` with code `job_wait_timeout`; the job keeps running. */
|
|
480
|
+
timeoutMs?: number;
|
|
481
|
+
/** Stops waiting: throws `InstaboxError` with code `aborted`; the job keeps running. */
|
|
482
|
+
signal?: AbortSignal;
|
|
355
483
|
}
|
|
356
484
|
/** A command started with `background: true`. */
|
|
357
485
|
interface CommandHandle {
|
|
358
486
|
/** PID of the command's shell, which leads the process group of everything it started. */
|
|
359
487
|
pid: number;
|
|
488
|
+
/**
|
|
489
|
+
* The job's ID. The CLI sees the same job: `instabox jobs logs <sandbox> <jobId> -f`,
|
|
490
|
+
* `instabox jobs wait`, `instabox jobs ls`.
|
|
491
|
+
*/
|
|
492
|
+
jobId: string;
|
|
360
493
|
/** Sends SIGTERM to the command and every process it started. Returns false if they had all exited. */
|
|
361
494
|
kill(): Promise<boolean>;
|
|
362
|
-
|
|
495
|
+
/**
|
|
496
|
+
* Waits for the command to end, calling `onStdout` with its output as it is written. Resolves with
|
|
497
|
+
* `{ stdout, stderr: '', exitCode, timedOut: false, truncated: false }`, `stdout` holding the whole
|
|
498
|
+
* log (stdout and stderr together); throws `CommandExitError` on a non-zero exit, and `InstaboxError`
|
|
499
|
+
* with code `job_lost` when the job ended without an exit code (the sandbox restarted).
|
|
500
|
+
*/
|
|
501
|
+
wait(opts?: CommandWaitOptions): Promise<CommandResult>;
|
|
502
|
+
}
|
|
503
|
+
type ExecOptions = Pick<CommandOptions, 'cwd' | 'envs' | 'timeoutMs' | 'stdin' | 'signal'> & {
|
|
504
|
+
/** Leave the command out of the sandbox's history (job polls). */
|
|
505
|
+
noHistory?: boolean;
|
|
506
|
+
/** How the command appears in the sandbox's history. */
|
|
507
|
+
historyCommand?: string;
|
|
508
|
+
};
|
|
363
509
|
declare class Commands {
|
|
364
510
|
private readonly http;
|
|
365
511
|
private readonly sandboxId;
|
|
@@ -367,7 +513,8 @@ declare class Commands {
|
|
|
367
513
|
/** @internal */
|
|
368
514
|
constructor(http: HttpClient, sandboxId: string, defaultEnvs: Record<string, string>);
|
|
369
515
|
/**
|
|
370
|
-
* Runs a shell command in the sandbox and waits for it to finish.
|
|
516
|
+
* Runs a shell command in the sandbox and waits for it to finish. With `onStdout` or `onStderr` the
|
|
517
|
+
* output is streamed to them as the command writes it.
|
|
371
518
|
* Throws `CommandExitError` (carrying stdout, stderr and exitCode) when it exits non-zero.
|
|
372
519
|
*/
|
|
373
520
|
run(cmd: string, opts: CommandOptions & {
|
|
@@ -377,11 +524,33 @@ declare class Commands {
|
|
|
377
524
|
background?: false;
|
|
378
525
|
}): Promise<CommandResult>;
|
|
379
526
|
run(cmd: string, opts?: CommandOptions): Promise<CommandResult | CommandHandle>;
|
|
527
|
+
private get execPath();
|
|
528
|
+
private execBody;
|
|
529
|
+
/** The request deadline of an exec: its command timeout plus 30 s, unless `requestTimeoutMs` is set. */
|
|
530
|
+
private execDeadline;
|
|
380
531
|
/** @internal Raw exec: never throws on a non-zero exit code. */
|
|
381
|
-
exec(cmd: string, opts?:
|
|
532
|
+
exec(cmd: string, opts?: ExecOptions): Promise<CommandResult>;
|
|
533
|
+
/**
|
|
534
|
+
* Exec with the output streamed (`Accept: text/event-stream`): each `stdout`/`stderr` event goes to its
|
|
535
|
+
* callback as it arrives, and the result carries all of it. A server that does not stream answers with
|
|
536
|
+
* the whole result, whose output is passed to the callbacks then.
|
|
537
|
+
*/
|
|
538
|
+
private execStream;
|
|
539
|
+
/** Reads a streamed exec's server-sent events until its `exit` or `error` event. */
|
|
540
|
+
private readEvents;
|
|
541
|
+
/** Handles one event: output goes to its callback, `exit` is the result, `error` is thrown. */
|
|
542
|
+
private dispatch;
|
|
543
|
+
/** Starts a background job the CLI's way and returns its handle. */
|
|
544
|
+
private startJob;
|
|
545
|
+
/** One read of a job: its status and up to `max` bytes of output from `off`, waiting up to `w` seconds. */
|
|
546
|
+
private readJob;
|
|
547
|
+
/** `readJob` for the wait loop. Reads change nothing, so a transient error is retried for up to 2 minutes. */
|
|
548
|
+
private pollJob;
|
|
549
|
+
/** Follows a job's output until it ends. */
|
|
550
|
+
private waitJob;
|
|
382
551
|
}
|
|
383
552
|
|
|
384
|
-
/** Largest file `files.read` / `files.write` move
|
|
553
|
+
/** Largest file `files.read` / `files.write` move. */
|
|
385
554
|
declare const MAX_FILE_BYTES: number;
|
|
386
555
|
interface EntryInfo {
|
|
387
556
|
name: string;
|
|
@@ -392,14 +561,25 @@ interface WriteInfo {
|
|
|
392
561
|
path: string;
|
|
393
562
|
}
|
|
394
563
|
/**
|
|
395
|
-
* File access inside the sandbox
|
|
396
|
-
*
|
|
564
|
+
* File access inside the sandbox, capped at 10 MiB per file. `read` and `write` stream the bytes
|
|
565
|
+
* over the file routes (`GET /v1/machines/{id}/files/content`, `PUT /v1/machines/{id}/files`), as
|
|
566
|
+
* the CLI's `cp` does; a server without them gets base64 chunks over exec. `list`, `exists` and
|
|
567
|
+
* `remove` run over exec.
|
|
397
568
|
*/
|
|
398
569
|
declare class Files {
|
|
399
570
|
private readonly commands;
|
|
571
|
+
private readonly http?;
|
|
572
|
+
private readonly sandboxId?;
|
|
573
|
+
private home?;
|
|
574
|
+
/** False once a server answered that it has no file routes. */
|
|
575
|
+
private routes;
|
|
400
576
|
/** @internal */
|
|
401
|
-
constructor(commands: Commands);
|
|
402
|
-
/**
|
|
577
|
+
constructor(commands: Commands, http?: HttpClient | undefined, sandboxId?: string | undefined);
|
|
578
|
+
/**
|
|
579
|
+
* Reads a file. Returns text (UTF-8) by default, or bytes with `{ format: 'bytes' }`. A text read
|
|
580
|
+
* of a file that is not valid UTF-8 throws `InstaboxNotUtf8Error` (code `not_utf8`) rather than
|
|
581
|
+
* returning U+FFFD in place of the bad bytes.
|
|
582
|
+
*/
|
|
403
583
|
read(path: string, opts?: {
|
|
404
584
|
format?: 'text';
|
|
405
585
|
}): Promise<string>;
|
|
@@ -407,11 +587,22 @@ declare class Files {
|
|
|
407
587
|
format: 'bytes'; /** @internal */
|
|
408
588
|
maxBytes?: number;
|
|
409
589
|
}): Promise<Uint8Array>;
|
|
590
|
+
/** Reads over `GET .../files/content`; undefined when the server has no such route. */
|
|
591
|
+
private readStream;
|
|
592
|
+
private readExec;
|
|
410
593
|
/**
|
|
411
594
|
* Writes a file, creating parent directories. Replaces the file atomically (temp file + rename).
|
|
412
595
|
* Throws `is_a_directory` when `path` is a directory.
|
|
413
596
|
*/
|
|
414
597
|
write(path: string, data: string | Uint8Array): Promise<WriteInfo>;
|
|
598
|
+
/**
|
|
599
|
+
* Writes over `PUT .../files?parents=true`, which writes a temp file beside the target and renames
|
|
600
|
+
* it into place once every byte arrived. False when the server has no such route.
|
|
601
|
+
*/
|
|
602
|
+
private writeStream;
|
|
603
|
+
private writeExec;
|
|
604
|
+
/** The file routes take absolute paths; a relative one is relative to exec's working directory (HOME). */
|
|
605
|
+
private absolute;
|
|
415
606
|
/** Lists the entries of a directory (not recursive). */
|
|
416
607
|
list(path: string): Promise<EntryInfo[]>;
|
|
417
608
|
/** Removes a file or a directory (recursively). Missing paths are fine. */
|
|
@@ -516,14 +707,7 @@ interface SandboxOpts extends ConnectionOptions {
|
|
|
516
707
|
metadata?: Record<string, string>;
|
|
517
708
|
/** Environment variables applied to every `commands.run` of this Sandbox object (client-side). */
|
|
518
709
|
envs?: Record<string, string>;
|
|
519
|
-
/**
|
|
520
|
-
* The server pauses (or with `onTimeout: 'kill'` deletes) the sandbox this long after creation.
|
|
521
|
-
* Sent as whole seconds, 60 s to 24 h. Default: no timeout. Change it with `setTimeout()`.
|
|
522
|
-
*/
|
|
523
|
-
timeoutMs?: number;
|
|
524
|
-
/** What happens at the timeout: `pause` (default) or `kill`. */
|
|
525
|
-
onTimeout?: OnTimeout;
|
|
526
|
-
/** Stop and archive after this many milliseconds, independent of the pause/kill timeout. */
|
|
710
|
+
/** Stop and archive after this many milliseconds. */
|
|
527
711
|
archiveMs?: number;
|
|
528
712
|
/**
|
|
529
713
|
* The server pauses the sandbox once it has been idle this long (no agent working, no terminal use,
|
|
@@ -547,6 +731,13 @@ interface SandboxOpts extends ConnectionOptions {
|
|
|
547
731
|
* Default: the sandbox gets them. Cannot be turned on again later.
|
|
548
732
|
*/
|
|
549
733
|
vault?: boolean;
|
|
734
|
+
/**
|
|
735
|
+
* @deprecated Removed in 0.6.0: sandboxes have no lifetime timeout since 2026-10-20. Passing it throws
|
|
736
|
+
* `InstaboxError` (`code: 'retired_option'`); use `autoSuspendMs`, `archiveMs` or `kill()` instead.
|
|
737
|
+
*/
|
|
738
|
+
timeoutMs?: never;
|
|
739
|
+
/** @deprecated Removed in 0.6.0 with `timeoutMs`; passing it throws. */
|
|
740
|
+
onTimeout?: never;
|
|
550
741
|
}
|
|
551
742
|
interface SandboxConnectOpts extends ConnectionOptions {
|
|
552
743
|
/** Resume the sandbox if it is paused (suspended) or stopped. Default true. */
|
|
@@ -570,10 +761,7 @@ interface SandboxInfo {
|
|
|
570
761
|
vault: boolean;
|
|
571
762
|
/** Creation time of the machine. */
|
|
572
763
|
startedAt: Date;
|
|
573
|
-
/** When the server pauses or kills the sandbox (see `onTimeout`); undefined for no timeout. */
|
|
574
|
-
endAt?: Date;
|
|
575
764
|
archiveAt?: Date;
|
|
576
|
-
onTimeout: OnTimeout;
|
|
577
765
|
/** Idle time after which the server pauses the sandbox; undefined when it never does. */
|
|
578
766
|
autoSuspendMs?: number;
|
|
579
767
|
state: MachineState;
|
|
@@ -688,18 +876,17 @@ declare class Sandbox {
|
|
|
688
876
|
getUsage(opts?: SandboxUsageOpts): Promise<SandboxUsage>;
|
|
689
877
|
/** Fetches the current state of the sandbox. */
|
|
690
878
|
getInfo(): Promise<SandboxInfo>;
|
|
691
|
-
/**
|
|
692
|
-
* Sets the timeout to `timeoutMs` from now (whole seconds, 60 s to 24 h); 0 clears it.
|
|
693
|
-
* `onTimeout` changes what happens then (`pause` or `kill`).
|
|
694
|
-
*/
|
|
695
|
-
setTimeout(timeoutMs: number, opts?: {
|
|
696
|
-
onTimeout?: OnTimeout;
|
|
697
|
-
}): Promise<void>;
|
|
698
879
|
/**
|
|
699
880
|
* Pauses the sandbox once it has been idle `idleMs` (whole seconds, 2 min to 24 h); 0 turns the idle
|
|
700
|
-
* pause off.
|
|
881
|
+
* pause off. The setting stays across pause and resume.
|
|
701
882
|
*/
|
|
702
883
|
setAutoSuspend(idleMs: number): Promise<void>;
|
|
884
|
+
/**
|
|
885
|
+
* @deprecated Removed in 0.6.0: sandboxes have no lifetime timeout since 2026-10-20. Always rejects with
|
|
886
|
+
* `InstaboxError` (`code: 'retired_option'`) naming the replacements (`setAutoSuspend()`, `kill()`), and
|
|
887
|
+
* sends no request.
|
|
888
|
+
*/
|
|
889
|
+
setTimeout(..._args: unknown[]): Promise<never>;
|
|
703
890
|
/** Replaces the sandbox's metadata (`{}` clears it). */
|
|
704
891
|
setMetadata(metadata: Record<string, string>): Promise<void>;
|
|
705
892
|
/**
|
|
@@ -755,4 +942,4 @@ declare class Sandbox {
|
|
|
755
942
|
private mutate;
|
|
756
943
|
}
|
|
757
944
|
|
|
758
|
-
export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, Commands, type Connection, type ConnectionOptions, type CreateSnapshotOpts, DEFAULT_API_URL, DEFAULT_TEMPLATE, DESKTOP_DISPLAY, Desktop, type DesktopStatus, type DesktopStream, type EntryInfo, type ExecResponse, FALLBACK_TEMPLATE, Files, type HostTrust, InstaboxAuthError, InstaboxError, type InstaboxErrorInit, InstaboxQuotaError, InstaboxTimeoutError, MAX_FILE_BYTES, MAX_STDIN_BYTES, type Machine, type MachineList, type MachineMetric, type MachineMetrics, type MachineSpec, type MachineState, type MachineUsage, type MachineVault, type MachineVaultItem, type MouseButton, type
|
|
945
|
+
export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, type CommandWaitOptions, Commands, type Connection, type ConnectionOptions, type CreateSnapshotOpts, DEFAULT_API_URL, DEFAULT_TEMPLATE, DESKTOP_DISPLAY, Desktop, type DesktopStatus, type DesktopStream, type EntryInfo, type ExecResponse, FALLBACK_TEMPLATE, Files, type HostTrust, InstaboxAuthError, InstaboxError, type InstaboxErrorInit, InstaboxNotUtf8Error, InstaboxQuotaError, InstaboxTimeoutError, LIMIT_CODES, MAX_FILE_BYTES, MAX_STDIN_BYTES, type Machine, type MachineList, type MachineMetric, type MachineMetrics, type MachineSpec, type MachineState, type MachineUsage, type MachineVault, type MachineVaultItem, type MouseButton, type Operation, Sandbox, type SandboxConnectOpts, type SandboxInfo, type SandboxListOpts, type SandboxMetrics, type SandboxMetricsOpts, type SandboxOpts, type SandboxUsage, type SandboxUsageOpts, type ScrollDirection, type Snapshot, type SnapshotList, type SshCredentials, type Template, type TemplateRef, type Usage, type UsageCost, type UsageLimits, type UsageMachineStorage, type UsageStorage, type VaultApplied, type VaultFile, type VaultKept, type WriteInfo, isLimitCode };
|