@keska/sandbox 0.42.0 → 0.44.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +266 -72
  2. package/dist/index.js +300 -58
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Interceptor } from '@connectrpc/connect';
2
1
  import WebSocket from 'ws';
2
+ import { Interceptor } from '@connectrpc/connect';
3
3
 
4
4
  type CredentialsDict = {
5
5
  type?: string;
@@ -151,7 +151,7 @@ type VolumeList = {
151
151
  nextPageToken: string;
152
152
  };
153
153
  /** Visitor credential for one guest HTTP port. token is set only on create. */
154
- declare class HTTPGrant {
154
+ declare class HTTPGrant$1 {
155
155
  readonly id: string;
156
156
  readonly sandboxId: string;
157
157
  readonly port: number;
@@ -379,71 +379,99 @@ declare class SandboxError extends Error {
379
379
  /** One line with the server fields callers otherwise reassemble. */
380
380
  format(): string;
381
381
  }
382
+ /** A sandbox, path, or other named object does not exist. */
382
383
  declare class NotFoundError extends SandboxError {
383
384
  }
385
+ /** The object already exists or is in use. */
384
386
  declare class ConflictError extends SandboxError {
385
387
  }
388
+ /** The caller is not allowed to perform this call. */
386
389
  declare class PermissionDeniedError extends SandboxError {
387
390
  }
388
- declare class SandboxTimeoutError extends SandboxError {
391
+ /** The call exceeded its deadline. Pass a larger `timeout` on that call. */
392
+ declare class TimeoutError extends SandboxError {
393
+ }
394
+ /** An image build or register exceeded its deadline. Pass a larger `timeout` or `waitSec`. */
395
+ declare class ImageTimeoutError extends TimeoutError {
396
+ }
397
+ /** A sandbox call exceeded its deadline. Pass a larger `timeout` on that call. */
398
+ declare class SandboxTimeoutError extends TimeoutError {
389
399
  }
390
400
  declare class PageExhaustedError extends SandboxError {
391
401
  constructor(message?: string);
392
402
  }
403
+ /** The service could not be reached. */
393
404
  declare class UnavailableError extends SandboxError {
394
405
  }
406
+ /** `run` or `sh` exited non-zero and `check` was true. */
395
407
  declare class CommandFailedError extends SandboxError {
396
408
  result?: ExecResult | ExecBytesResult;
397
409
  }
410
+ /** The guest path does not exist. */
398
411
  declare class PathNotFoundError extends NotFoundError {
399
412
  }
400
- declare class FileNotFoundError extends PathNotFoundError {
401
- }
413
+ /** A directory remove needs `recursive` because the directory is not empty. */
402
414
  declare class DirectoryNotEmptyError extends ConflictError {
403
415
  }
416
+ /** The guest path already exists. */
404
417
  declare class FileExistsError extends SandboxError {
405
418
  }
419
+ /** The file or export is over the size limit. */
406
420
  declare class FileTooLargeError extends SandboxError {
407
421
  }
422
+ /** The path is not allowed. A symlink upload is refused. */
408
423
  declare class InvalidPathError extends SandboxError {
409
424
  }
410
- /** No sandbox, secret, snapshot, volume, image, or tag has that id or name. */
425
+ /** No sandbox has that id or name. */
411
426
  declare class SandboxNotFoundError extends NotFoundError {
412
427
  }
428
+ /** The sandbox is not in the state this call requires. */
413
429
  declare class SandboxNotReadyError extends SandboxError {
414
430
  }
431
+ /** The sandbox is already in use for this operation. */
415
432
  declare class SandboxConflictError extends ConflictError {
416
433
  }
417
434
  /** That name is already in use. `existingId` is the id that has it. */
418
435
  declare class NameTakenError extends ConflictError {
419
436
  get existingId(): string;
420
437
  }
438
+ /** The sandbox status does not allow this call. */
421
439
  declare class SandboxStateError extends SandboxError {
422
440
  }
441
+ /** No process has that id on the sandbox. */
423
442
  declare class ProcessNotFoundError extends NotFoundError {
424
443
  }
444
+ /** The command executable is not on the guest. */
425
445
  declare class ExecutableNotFoundError extends NotFoundError {
426
446
  }
447
+ /** The guest runtime is not accepting calls. */
427
448
  declare class GuestRuntimeDeadError extends SandboxError {
428
449
  }
450
+ /** The project has no room for another sandbox of this size. */
429
451
  declare class CapacityError extends SandboxError {
430
452
  }
453
+ /** The credentials were rejected. */
431
454
  declare class AuthenticationError extends SandboxError {
432
455
  }
456
+ /** A call argument is missing or not allowed. */
433
457
  declare class InvalidArgumentError extends SandboxError {
434
458
  }
459
+ /** argv, env, and cwd together exceed the command limit. */
435
460
  declare class CommandTooLargeError extends InvalidArgumentError {
436
461
  }
462
+ /** The command was killed because `timeout` elapsed. Pass a larger `timeout`. */
437
463
  declare class CommandTimeoutError extends SandboxTimeoutError {
438
464
  }
439
465
  /** Nothing is listening on the forwarded port. */
440
466
  declare class PortNotOpenError extends SandboxError {
441
467
  }
442
- /** The sandbox is sleeping. Open it before an HTTP request. */
468
+ /** The sandbox is sleeping. Wake it before an HTTP request. */
443
469
  declare class SandboxSleepingError extends SandboxError {
444
470
  }
471
+ /** `wait` ended before the process exited. Pass a larger `timeout`. */
445
472
  declare class ProcessWaitTimeoutError extends SandboxTimeoutError {
446
473
  }
474
+ /** `wait` ended before the sandbox reached the requested state. Pass a larger `timeout`. */
447
475
  declare class SandboxWaitTimeoutError extends SandboxTimeoutError {
448
476
  }
449
477
 
@@ -565,9 +593,9 @@ declare class Session {
565
593
  /** Mint a visitor credential for one guest HTTP port. The token is returned once. */
566
594
  createHttpGrant(sandboxId: string, port: number, opts?: CallOpts & {
567
595
  ttlSec?: number;
568
- }): Promise<HTTPGrant>;
596
+ }): Promise<HTTPGrant$1>;
569
597
  /** List grants for one sandbox. The secret is not included. */
570
- listHttpGrants(sandboxId: string, opts?: CallOpts): Promise<HTTPGrant[]>;
598
+ listHttpGrants(sandboxId: string, opts?: CallOpts): Promise<HTTPGrant$1[]>;
571
599
  /** Delete one grant in the caller's project. */
572
600
  deleteHttpGrant(id: string, opts?: CallOpts): Promise<void>;
573
601
  /** Control-plane `Authorization` bearer. Guest URL callers use `getGuestHeaders`. */
@@ -792,6 +820,34 @@ declare class Session {
792
820
  deleteVolume(volumeId: string, opts?: CallOpts): Promise<void>;
793
821
  }
794
822
 
823
+ /** Guest HTTP and WebSocket over the public URL. No request is sent until get, post, or websocket. */
824
+
825
+ /** Buffered guest body. `text`, `json`, and `bytes` are synchronous. */
826
+ declare class GuestResponse$1 {
827
+ readonly statusCode: number;
828
+ readonly headers: Headers;
829
+ private readonly body;
830
+ constructor(statusCode: number, headers: Headers, body: Uint8Array);
831
+ text(): string;
832
+ json(): unknown;
833
+ bytes(): Uint8Array;
834
+ }
835
+ /** One guest port. `get` and `post` buffer the body before they return. */
836
+ declare class GuestHttp$1 {
837
+ readonly baseUrl: string;
838
+ private readonly auth;
839
+ constructor(baseUrl: string, auth: Record<string, string>);
840
+ /** One GET. `path` is the guest route. */
841
+ get(path: string, init?: RequestInit): Promise<GuestResponse$1>;
842
+ /** One POST. `json` is sent as `application/json`. */
843
+ post(path: string, body?: {
844
+ json?: unknown;
845
+ headers?: HeadersInit;
846
+ }): Promise<GuestResponse$1>;
847
+ /** Dial one WebSocket. The promise resolves on open. The caller calls `close`. */
848
+ websocket(path?: string): Promise<WebSocket>;
849
+ }
850
+
795
851
  /** Public catalog client. Guest calls live on `Sandbox`, not here. */
796
852
 
797
853
  type TimeoutOpts = {
@@ -984,34 +1040,6 @@ declare class Client$1 {
984
1040
  listImagesIter(opts?: Omit<NonNullable<Parameters<Images$1["list"]>[0]>, "pageToken">): AsyncGenerator<Image>;
985
1041
  }
986
1042
 
987
- /** Guest HTTP and WebSocket over the public URL. No request is sent until get, post, or websocket. */
988
-
989
- /** Buffered guest body. `text`, `json`, and `bytes` are synchronous. */
990
- declare class GuestResponse {
991
- readonly statusCode: number;
992
- readonly headers: Headers;
993
- private readonly body;
994
- constructor(statusCode: number, headers: Headers, body: Uint8Array);
995
- text(): string;
996
- json(): unknown;
997
- bytes(): Uint8Array;
998
- }
999
- /** One guest port. `get` and `post` buffer the body before they return. */
1000
- declare class GuestHttp {
1001
- readonly baseUrl: string;
1002
- private readonly auth;
1003
- constructor(baseUrl: string, auth: Record<string, string>);
1004
- /** One GET. `path` is the guest route. */
1005
- get(path: string, init?: RequestInit): Promise<GuestResponse>;
1006
- /** One POST. `json` is sent as `application/json`. */
1007
- post(path: string, body?: {
1008
- json?: unknown;
1009
- headers?: HeadersInit;
1010
- }): Promise<GuestResponse>;
1011
- /** Dial one WebSocket. The promise resolves on open. The caller calls `close`. */
1012
- websocket(path?: string): Promise<WebSocket>;
1013
- }
1014
-
1015
1043
  /** Arguments for `Sandbox.create`. Fields say what omit means. */
1016
1044
  type SandboxCreateParams$1 = {
1017
1045
  /** Guest rootfs. Required. Platform aliases such as `numen/base` resolve on the control plane. */
@@ -1044,6 +1072,8 @@ type SandboxCreateParams$1 = {
1044
1072
  memoryBytes?: number;
1045
1073
  /** Writable state on top of the image, in bytes. The image is not counted. Omit = 1 GiB. */
1046
1074
  diskBytes?: number;
1075
+ /** RPC deadline in milliseconds. Omit for 10s. 0 means no deadline. */
1076
+ timeoutMs?: number;
1047
1077
  };
1048
1078
  /** A sandbox id string, `{ id }`, or `{ name }`. A string is always an id. */
1049
1079
  type SandboxRef = string | {
@@ -1314,7 +1344,7 @@ declare class Sandbox$1 {
1314
1344
  */
1315
1345
  http(port: number, opts?: {
1316
1346
  baseUrl?: string;
1317
- }): Promise<GuestHttp>;
1347
+ }): Promise<GuestHttp$1>;
1318
1348
  /** HTTPS base for this guest port. No request is sent and the port is not published.
1319
1349
  *
1320
1350
  * Append the guest path and pass `getHeaders`. Closing an HTTP client does not hide the port.
@@ -1334,11 +1364,11 @@ declare class Sandbox$1 {
1334
1364
  createHttpGrant(port: number, opts?: {
1335
1365
  ttlSec?: number;
1336
1366
  signal?: AbortSignal;
1337
- }): Promise<HTTPGrant>;
1367
+ }): Promise<HTTPGrant$1>;
1338
1368
  /** List HTTP grants for this sandbox. The secret is not included. */
1339
1369
  listHttpGrants(opts?: {
1340
1370
  signal?: AbortSignal;
1341
- }): Promise<HTTPGrant[]>;
1371
+ }): Promise<HTTPGrant$1[]>;
1342
1372
  /** Delete one HTTP grant in this project.
1343
1373
  *
1344
1374
  * The next request with that token fails immediately. An open WebSocket closes on the next check.
@@ -1409,69 +1439,126 @@ declare class Sandbox$1 {
1409
1439
 
1410
1440
  /** No deadline, no expiry, or the full file tree. */
1411
1441
  declare const UNLIMITED: number;
1442
+ /** Which log stream a line came from. */
1412
1443
  declare const LogStream: {
1444
+ /** Guest stdout. */
1413
1445
  readonly STDOUT: "stdout";
1446
+ /** Guest stderr. */
1414
1447
  readonly STDERR: "stderr";
1448
+ /** A platform event, not guest output. */
1415
1449
  readonly EVENT: "event";
1416
1450
  };
1451
+ /** A value of {@link LogStream}. */
1417
1452
  type LogStream = (typeof LogStream)[keyof typeof LogStream];
1453
+ /** Sandbox lifecycle states returned by the API. */
1418
1454
  declare const SandboxStatus: {
1455
+ /** The sandbox is being created. */
1419
1456
  readonly PENDING: "Pending";
1457
+ /** The guest is up and accepts calls. */
1420
1458
  readonly READY: "Ready";
1459
+ /** The VM is stopped and the disk is kept. */
1421
1460
  readonly SLEEPING: "Sleeping";
1461
+ /** The sandbox has exited and will be deleted. */
1422
1462
  readonly FINISHED: "Finished";
1463
+ /** A delete is in progress. */
1423
1464
  readonly DELETING: "Deleting";
1424
1465
  };
1466
+ /** A value of {@link SandboxStatus}. */
1425
1467
  type SandboxStatus = (typeof SandboxStatus)[keyof typeof SandboxStatus];
1468
+ /** CPU, memory, and disk for create or resize. Strings accept units such as `1Gi`. */
1426
1469
  type Resources = {
1470
+ /** Cores. `1` is one core. `"500m"` is half a core. */
1427
1471
  cpu?: number | string;
1472
+ /** Guest memory. A number is bytes. `"1Gi"` is accepted. */
1428
1473
  memory?: number | string;
1474
+ /** Writable state on top of the image. A number is bytes. */
1429
1475
  disk?: number | string;
1430
1476
  };
1477
+ /**
1478
+ * RPC deadline in seconds.
1479
+ * `UNLIMITED` means no deadline. Each call has its own default when this is omitted.
1480
+ */
1431
1481
  type Timeout = number;
1432
1482
  /** One sandbox from `list`. `name` is `null` when the sandbox is unnamed. */
1433
1483
  type SandboxRow = Omit<SandboxSummary, "name"> & {
1484
+ /** `null` when the sandbox was created without a name. */
1434
1485
  name: string | null;
1435
1486
  };
1436
1487
  type PageFetch<T> = (token: string) => Promise<Page<T>>;
1437
1488
  /** One page. Iterating yields `items`. */
1438
1489
  declare class Page<T> {
1490
+ /** Rows on this page. */
1439
1491
  readonly items: readonly T[];
1492
+ /** Pass this to the next `list` call. Absent on the last page. */
1440
1493
  readonly nextPageToken: string | undefined;
1441
1494
  private readonly fetchPage;
1442
- constructor(items: readonly T[], nextPageToken: string | undefined, fetchPage: PageFetch<T>);
1495
+ constructor(
1496
+ /** Rows on this page. */
1497
+ items: readonly T[],
1498
+ /** Pass this to the next `list` call. Absent on the last page. */
1499
+ nextPageToken: string | undefined, fetchPage: PageFetch<T>);
1500
+ /** True when `next` will fetch another page. */
1443
1501
  get hasMore(): boolean;
1502
+ /** Fetch the following page. Throws `PageExhaustedError` on the last page. */
1444
1503
  next(): Promise<Page<T>>;
1504
+ /** Iterate the rows on this page. */
1445
1505
  [Symbol.iterator](): Iterator<T>;
1446
1506
  }
1507
+ /** A file write passed to `fs.write`. */
1447
1508
  declare class Write {
1509
+ /** Guest path. */
1448
1510
  readonly path: string;
1511
+ /** File contents. */
1449
1512
  readonly data: Buffer | string;
1513
+ /** Unix mode. Omit to keep the default. */
1450
1514
  readonly mode?: number | undefined;
1451
- constructor(path: string, data: Buffer | string, mode?: number | undefined);
1452
- }
1515
+ constructor(
1516
+ /** Guest path. */
1517
+ path: string,
1518
+ /** File contents. */
1519
+ data: Buffer | string,
1520
+ /** Unix mode. Omit to keep the default. */
1521
+ mode?: number | undefined);
1522
+ }
1523
+ /** A directory create passed to `fs.write`. */
1453
1524
  declare class Mkdir {
1525
+ /** Guest path. */
1454
1526
  readonly path: string;
1455
- constructor(path: string);
1527
+ constructor(
1528
+ /** Guest path. */
1529
+ path: string);
1456
1530
  }
1531
+ /** A path delete passed to `fs.write`. */
1457
1532
  declare class Remove {
1533
+ /** Guest path. */
1458
1534
  readonly path: string;
1535
+ /** Delete a non-empty directory. */
1459
1536
  readonly recursive: boolean;
1460
- constructor(path: string, recursive?: boolean);
1537
+ constructor(
1538
+ /** Guest path. */
1539
+ path: string,
1540
+ /** Delete a non-empty directory. */
1541
+ recursive?: boolean);
1461
1542
  }
1543
+ /** Build a `Write` op for `fs.write`. */
1462
1544
  declare function write(path: string, data: Buffer | string, mode?: number): Write;
1545
+ /** Build a `Mkdir` op for `fs.write`. */
1463
1546
  declare function mkdir(path: string): Mkdir;
1547
+ /** Build a `Remove` op for `fs.write`. `recursive` is required for a non-empty directory. */
1464
1548
  declare function remove(path: string, recursive?: boolean): Remove;
1465
1549
  type FileOp = Write | Mkdir | Remove;
1466
1550
  /** One agent. `matrixUserId` is who you invite. One sandbox. Sleep stops the process you started. */
1467
1551
  declare class Agent {
1468
1552
  private readonly client;
1553
+ /** Agent id. */
1469
1554
  readonly id: string;
1555
+ /** Agent name. */
1470
1556
  name: string;
1471
1557
  /** Matrix user id to invite from your Matrix client. */
1472
1558
  matrixUserId: string;
1473
1559
  /** Env name to secret name. Values are not included. */
1474
1560
  secretEnv: Record<string, string>;
1561
+ /** When the agent was created. */
1475
1562
  createdAt: string;
1476
1563
  constructor(client: Client, info: Agent$1);
1477
1564
  private take;
@@ -1514,31 +1601,49 @@ declare class Agents {
1514
1601
  timeout?: Timeout;
1515
1602
  }): Promise<void>;
1516
1603
  }
1604
+ /** Where to connect. */
1517
1605
  type ClientOptions = {
1606
+ /** Control plane URL. Omit to use credentials, then the default cloud URL. */
1518
1607
  baseUrl?: string;
1608
+ /** Path to `credentials.json`. `~` is expanded. */
1519
1609
  credentialsFile?: string;
1610
+ /** OAuth client id. With `clientSecret`, this wins over the credentials file. */
1520
1611
  clientId?: string;
1612
+ /** OAuth client secret. */
1521
1613
  clientSecret?: string;
1614
+ /** Static bearer token. */
1522
1615
  token?: string;
1616
+ /** Token endpoint. Omit to use the one in the credentials file. */
1523
1617
  tokenUrl?: string;
1618
+ /** Retries for get, list, label replace, and delete. Default 3. `0` turns retries off. */
1524
1619
  maxRetries?: number;
1525
- timeout?: Timeout;
1526
1620
  };
1527
- /** Catalog client. `await using` closes the connection. */
1621
+ /** Client for one project. `await using` closes the connection. */
1528
1622
  declare class Client {
1623
+ /** Retries after the first try. Default 3. `0` is one attempt. */
1529
1624
  readonly maxRetries: number;
1530
1625
  /** @internal */
1531
1626
  readonly wire: Client$1;
1627
+ /** Named disks. */
1532
1628
  readonly volumes: Volumes;
1629
+ /** Project secrets. Values cannot be read back. */
1533
1630
  readonly secrets: Secrets;
1631
+ /** Matrix agents. */
1534
1632
  readonly agents: Agents;
1633
+ /** Platform and project images. */
1535
1634
  readonly images: Images;
1635
+ /** Filesystem snapshots. */
1536
1636
  readonly snapshots: Snapshots;
1637
+ /** Names bound to a policy set. */
1537
1638
  readonly tags: Tags;
1639
+ /** Create, list, and open sandboxes. */
1538
1640
  readonly sandboxes: Sandboxes;
1539
1641
  constructor(opts?: ClientOptions);
1642
+ /** Close the connection. */
1540
1643
  close(): void;
1644
+ /** `using` calls this. */
1541
1645
  [Symbol.dispose](): void;
1646
+ /** `await using` calls this. */
1542
1647
  [Symbol.asyncDispose](): Promise<void>;
1543
1648
  }
1544
1649
  declare class Volumes {
@@ -1551,10 +1656,10 @@ declare class Volumes {
1551
1656
  }): Promise<Volume>;
1552
1657
  get(id: string, opts?: {
1553
1658
  timeout?: Timeout;
1554
- }): ReturnType<Client$1["volumes"]["get"]>;
1659
+ }): Promise<Volume>;
1555
1660
  getByName(name: string, opts?: {
1556
1661
  timeout?: Timeout;
1557
- }): ReturnType<Client$1["volumes"]["get"]>;
1662
+ }): Promise<Volume>;
1558
1663
  list(opts?: ListOpts & {
1559
1664
  labels?: Record<string, string>;
1560
1665
  }): Promise<Page<Volume>>;
@@ -1592,12 +1697,14 @@ declare class Secrets {
1592
1697
  declare class Images {
1593
1698
  private readonly client;
1594
1699
  constructor(client: Client);
1700
+ /** Copy a public image into the project. Omit `timeout` to wait up to 600 seconds. */
1595
1701
  register(name: string, opts: {
1596
1702
  source: string;
1597
1703
  timeout?: Timeout;
1598
1704
  waitUntilReady?: boolean;
1599
1705
  waitSec?: number;
1600
1706
  }): Promise<Image>;
1707
+ /** Build a Dockerfile. Omit `timeout` to wait up to 600 seconds. Pass `timeout` or `waitSec` to replace that. */
1601
1708
  build(name: string, opts?: {
1602
1709
  dockerfile?: string;
1603
1710
  context?: string;
@@ -1675,27 +1782,43 @@ type ListOpts = {
1675
1782
  pageToken?: string;
1676
1783
  timeout?: Timeout;
1677
1784
  };
1785
+ /** Arguments for `sandboxes.create`. Omit `timeout` for a 10 second deadline. */
1678
1786
  type SandboxCreateParams = {
1787
+ /** Platform name or a project image. Required. */
1679
1788
  image: string;
1789
+ /** Optional lookup. A second create with the same name fails with `NameTakenError`. */
1680
1790
  name?: string;
1791
+ /** Environment variables. Omit for an empty map. */
1681
1792
  env?: Record<string, string>;
1682
1793
  /** Env name to secret name. The value is not returned. */
1683
1794
  secretEnv?: Record<string, string>;
1684
1795
  /** Set by `Agent.newSandbox`. Pass an agent id only when creating through `sandboxes.create`. */
1685
1796
  agentId?: string;
1797
+ /** Guest working directory. Omit and commands start in the image `WORKDIR`, or `/work`. */
1686
1798
  workdir?: string;
1799
+ /** Seconds until the sandbox is deleted. Omit for no expiry. */
1687
1800
  lifetime?: number;
1801
+ /** Seconds of inactivity before sleep. Omit and the sandbox stays up. */
1688
1802
  idleTimeout?: number;
1803
+ /** Start from this snapshot instead of the image. */
1689
1804
  fromSnapshotId?: string;
1805
+ /** Named disk to attach at the working directory. */
1690
1806
  volumeId?: string;
1807
+ /** Your metadata. Labels do not change how the sandbox runs. */
1691
1808
  labels?: Record<string, string>;
1809
+ /** Tag names that must already exist. */
1692
1810
  tags?: string[];
1811
+ /** Size. Omit for 1 core, 1 GiB of memory, and 1 GiB of writable disk. */
1693
1812
  resources?: Resources;
1813
+ /** `await using` deletes the sandbox when this is true, the default. */
1694
1814
  deleteOnExit?: boolean;
1815
+ /** RPC deadline in seconds. Omit for 10 seconds. `UNLIMITED` means no deadline. */
1816
+ timeout?: Timeout;
1695
1817
  };
1696
1818
  declare class Sandboxes {
1697
1819
  private readonly client;
1698
1820
  constructor(client: Client);
1821
+ /** Create a sandbox. Omit `timeout` for a 10 second deadline. */
1699
1822
  create(opts: SandboxCreateParams): Promise<Sandbox>;
1700
1823
  get(id: string): Promise<Sandbox>;
1701
1824
  getByName(name: string): Promise<Sandbox>;
@@ -1716,46 +1839,64 @@ declare class Sandboxes {
1716
1839
  timeout?: Timeout;
1717
1840
  }): Promise<void>;
1718
1841
  }
1719
- /** One sandbox. `info` is the last snapshot. `get` refreshes it and does not wake. */
1842
+ /** One sandbox. `info` is the last record for this sandbox. `get` refreshes it and does not wake. */
1720
1843
  declare class Sandbox {
1844
+ /** Client that created or opened this sandbox. */
1721
1845
  readonly client: Client;
1722
1846
  /** @internal */
1723
1847
  readonly inner: Sandbox$1;
1848
+ /** Files on the guest. */
1724
1849
  readonly fs: Files;
1850
+ /** Logs from this sandbox. */
1725
1851
  readonly logs: Logs;
1852
+ /** Processes started with `start`. */
1726
1853
  readonly processes: Processes;
1854
+ /** Credentials that let a caller reach one guest port. */
1727
1855
  readonly httpGrants: HTTPGrants;
1856
+ /** When true, disposing the sandbox deletes it. */
1728
1857
  deleteOnExit: boolean;
1729
- constructor(client: Client,
1858
+ constructor(
1859
+ /** Client that created or opened this sandbox. */
1860
+ client: Client,
1730
1861
  /** @internal */
1731
1862
  inner: Sandbox$1, deleteOnExit: boolean);
1732
- get info(): ReturnType<Sandbox$1["get"]> extends Promise<infer T> ? T : never;
1863
+ /** Last record from create, get, wake, or sleep. */
1864
+ get info(): SandboxInfo;
1865
+ /** Sandbox id. */
1733
1866
  get id(): string;
1734
- get(): ReturnType<Sandbox$1["get"]>;
1867
+ /** Refresh `info`. Does not wake a sleeping sandbox. */
1868
+ get(): Promise<SandboxInfo>;
1869
+ /** Wake a sleeping sandbox. Omit `timeout` for no RPC deadline. */
1735
1870
  wake(opts?: {
1736
1871
  wait?: boolean;
1737
1872
  timeout?: Timeout;
1738
- }): ReturnType<Sandbox$1["open"]>;
1873
+ }): Promise<SandboxInfo>;
1874
+ /** Stop the VM and keep the disk. Omit `timeout` for no RPC deadline. */
1739
1875
  sleep(opts?: {
1740
1876
  wait?: boolean;
1741
1877
  timeout?: Timeout;
1742
- }): ReturnType<Sandbox$1["park"]>;
1878
+ }): Promise<SandboxInfo>;
1879
+ /** Block until the sandbox is in one of `until`. Omit `timeout` for no RPC deadline. */
1743
1880
  wait(opts: {
1744
1881
  until: SandboxStatus | readonly SandboxStatus[];
1745
1882
  timeout?: Timeout;
1746
- }): ReturnType<Sandbox$1["wait"]>;
1883
+ }): Promise<SandboxInfo>;
1884
+ /** Block until the sandbox is gone. Omit `timeout` for no RPC deadline. */
1747
1885
  waitDeleted(opts?: {
1748
1886
  timeout?: Timeout;
1749
1887
  }): Promise<null>;
1888
+ /** Change size. The sandbox must be sleeping. */
1750
1889
  resize(opts: {
1751
1890
  cpu?: number | string;
1752
1891
  memory?: number | string;
1753
1892
  disk?: number | string;
1754
- }): ReturnType<Sandbox$1["setSize"]>;
1893
+ }): Promise<SandboxInfo>;
1894
+ /** Replace labels, tags, or both. */
1755
1895
  update(opts: {
1756
1896
  labels?: Record<string, string>;
1757
1897
  tags?: string[];
1758
- }): Promise<unknown>;
1898
+ }): Promise<SandboxInfo>;
1899
+ /** Run a command and wait for it. Omit `timeout` for no RPC deadline. */
1759
1900
  run(argv: string[], opts?: {
1760
1901
  env?: Record<string, string>;
1761
1902
  cwd?: string;
@@ -1766,6 +1907,7 @@ declare class Sandbox {
1766
1907
  onStderr?: (chunk: string | Uint8Array) => void;
1767
1908
  signal?: AbortSignal;
1768
1909
  }): Promise<ExecResult>;
1910
+ /** `run` with binary stdout and stderr. */
1769
1911
  runBytes(argv: string[], opts?: {
1770
1912
  env?: Record<string, string>;
1771
1913
  cwd?: string;
@@ -1777,7 +1919,9 @@ declare class Sandbox {
1777
1919
  signal?: AbortSignal;
1778
1920
  }): Promise<ExecBytesResult>;
1779
1921
  private exec;
1922
+ /** Run one shell string with `/bin/sh -c`. */
1780
1923
  sh(command: string, opts?: Parameters<Sandbox["run"]>[1]): Promise<ExecResult>;
1924
+ /** Start a command and return its handle. Omit `timeout` for no RPC deadline. */
1781
1925
  start(argv: string[], opts?: {
1782
1926
  env?: Record<string, string>;
1783
1927
  cwd?: string;
@@ -1786,55 +1930,77 @@ declare class Sandbox {
1786
1930
  keepAlive?: boolean;
1787
1931
  endsSandbox?: boolean;
1788
1932
  }): Promise<ProcessHandle>;
1933
+ /** Copy this sandbox's writable layer into new sandboxes. */
1789
1934
  clone(opts?: {
1790
1935
  count?: number;
1791
1936
  concurrency?: number;
1792
1937
  }): Promise<Sandbox[]>;
1938
+ /** Freeze the writable layer. Start later sandboxes from the snapshot. */
1793
1939
  snapshot(opts?: {
1794
1940
  name?: string;
1795
1941
  labels?: Record<string, string>;
1796
- }): ReturnType<Sandbox$1["snapshot"]>;
1942
+ }): Promise<Snapshot>;
1943
+ /** Client for a server listening inside the sandbox. */
1797
1944
  http(port: number, opts?: {
1798
1945
  baseUrl?: string;
1799
- }): Promise<GuestHttp>;
1946
+ }): Promise<GuestHttp$1>;
1947
+ /** Delete the sandbox. */
1800
1948
  delete(): Promise<void>;
1949
+ /** Delete when `deleteOnExit` is true. */
1801
1950
  [Symbol.asyncDispose](): Promise<void>;
1802
1951
  }
1803
1952
  declare class Files {
1804
1953
  private readonly sandbox;
1805
1954
  constructor(sandbox: Sandbox);
1955
+ /** Read a guest file as bytes. Omit `timeout` for 60 seconds. */
1806
1956
  read(path: string, opts?: {
1807
1957
  timeout?: Timeout;
1808
1958
  }): Promise<Buffer>;
1959
+ /** Read a guest file as a UTF-8 string. Omit `timeout` for 60 seconds. */
1809
1960
  readText(path: string, opts?: {
1810
1961
  timeout?: Timeout;
1811
1962
  }): Promise<string>;
1963
+ /**
1964
+ * Write one file from memory. Replaces it if it exists.
1965
+ * @param timeout Omit for 60 seconds.
1966
+ */
1812
1967
  write(path: string, data: Buffer | string, opts?: {
1813
1968
  mode?: number;
1814
1969
  timeout?: Timeout;
1815
1970
  }): Promise<void>;
1971
+ /**
1972
+ * Upload a local file or directory. An existing target raises unless `overwrite` is set.
1973
+ * @param timeout Omit for 60 seconds.
1974
+ */
1816
1975
  upload(local: string, remote: string, opts?: {
1817
1976
  overwrite?: boolean;
1818
1977
  mode?: number;
1819
1978
  timeout?: Timeout;
1820
1979
  }): Promise<void>;
1980
+ /** Download a guest path to a local path. Omit `timeout` for 60 seconds. */
1821
1981
  download(remote: string, local: string, opts?: {
1822
1982
  timeout?: Timeout;
1823
1983
  }): Promise<void>;
1984
+ /** List a guest directory. Depth defaults to 1. Omit `timeout` for 60 seconds. */
1824
1985
  list(path: string, opts?: {
1825
1986
  depth?: number;
1826
1987
  timeout?: Timeout;
1827
- }): ReturnType<Sandbox$1["ls"]>;
1828
- stat(path: string): ReturnType<Sandbox$1["stat"]>;
1988
+ }): Promise<FileList>;
1989
+ /** One guest path's type and size. */
1990
+ stat(path: string): Promise<FileInfo>;
1991
+ /** Create a guest directory, including missing parents. */
1829
1992
  mkdir(path: string): Promise<void>;
1993
+ /** Remove a guest path. A missing path succeeds unless `missingOk` is false. A non-empty directory needs `recursive`. */
1830
1994
  remove(path: string, opts?: {
1831
1995
  recursive?: boolean;
1832
1996
  missingOk?: boolean;
1833
1997
  }): Promise<void>;
1998
+ /** Download a guest directory as a tar file. Omit `timeout` for 60 seconds. */
1834
1999
  export(path: string, dest: string, opts?: {
1835
2000
  gzip?: boolean;
1836
2001
  timeout?: Timeout;
1837
2002
  }): Promise<void>;
2003
+ /** Apply several file changes in one call. Omit `timeout` for 60 seconds. */
1838
2004
  batch(ops: FileOp[], opts?: {
1839
2005
  timeout?: Timeout;
1840
2006
  }): Promise<void>;
@@ -1843,6 +2009,7 @@ declare class Logs {
1843
2009
  private readonly sandbox;
1844
2010
  private readonly processId?;
1845
2011
  constructor(sandbox: Sandbox, processId?: string | undefined);
2012
+ /** One page of logs. Pass `pageToken` from the previous page to continue. */
1846
2013
  list(opts?: {
1847
2014
  processId?: string;
1848
2015
  stream?: "stdout" | "stderr" | "event";
@@ -1852,6 +2019,7 @@ declare class Logs {
1852
2019
  pageSize?: number;
1853
2020
  pageToken?: string;
1854
2021
  }): Promise<Page<LogEntry>>;
2022
+ /** Yield log entries, following pages until `limit`. */
1855
2023
  iter(opts?: Parameters<Logs["list"]>[0] & {
1856
2024
  limit?: number;
1857
2025
  }): AsyncGenerator<LogEntry>;
@@ -1859,50 +2027,76 @@ declare class Logs {
1859
2027
  declare class Processes {
1860
2028
  private readonly sandbox;
1861
2029
  constructor(sandbox: Sandbox);
2030
+ /** Look up one guest process by id. */
1862
2031
  get(id: string): Promise<ProcessHandle>;
2032
+ /** Guest processes for this sandbox. */
1863
2033
  list(): Promise<ProcessHandle[]>;
1864
2034
  }
1865
2035
  declare class HTTPGrants {
1866
2036
  private readonly sandbox;
1867
2037
  constructor(sandbox: Sandbox);
2038
+ /** Mint a grant for a guest port. The token is set only on this call. */
1868
2039
  create(port: number, opts?: {
1869
2040
  ttl?: number;
1870
- }): ReturnType<Sandbox$1["createHttpGrant"]>;
1871
- list(): Promise<HTTPGrant[]>;
1872
- delete(id: string): Promise<void>;
2041
+ }): Promise<HTTPGrant$1>;
2042
+ /** Grants for this sandbox. Tokens are not included. */
2043
+ list(): Promise<HTTPGrant$1[]>;
2044
+ /** Delete a grant. A missing grant raises unless `missingOk` is set. */
2045
+ delete(id: string, opts?: {
2046
+ missingOk?: boolean;
2047
+ }): Promise<void>;
1873
2048
  }
1874
2049
  /** One guest process. */
1875
2050
  declare class ProcessHandle {
1876
2051
  private readonly inner;
2052
+ /** Logs for this process. */
1877
2053
  readonly logs: Logs;
1878
2054
  constructor(sandbox: Sandbox, inner: ProcessHandle$1);
2055
+ /** Process id. */
1879
2056
  get id(): string;
2057
+ /** Last known status. */
1880
2058
  get status(): string;
2059
+ /** Name passed to `start`, or empty. */
1881
2060
  get name(): string;
2061
+ /** Exit code once the process has finished. */
1882
2062
  get exitCode(): number | null;
1883
- poll(): ReturnType<ProcessHandle$1["poll"]>;
2063
+ /** Refresh status without waiting. */
2064
+ poll(): Promise<Process>;
2065
+ /** Block until the process exits. Omit `timeout` for no RPC deadline. */
1884
2066
  wait(opts?: {
1885
2067
  timeout?: Timeout;
1886
- }): ReturnType<ProcessHandle$1["wait"]>;
1887
- kill(signal?: number | string): ReturnType<ProcessHandle$1["kill"]>;
2068
+ }): Promise<Process>;
2069
+ /** Send a signal. The default is `SIGTERM`. */
2070
+ kill(signal?: number | string): Promise<Process>;
2071
+ /** Write to the process stdin. */
1888
2072
  writeStdin(data?: Buffer | string, opts?: {
1889
2073
  eof?: boolean;
1890
2074
  }): Promise<void>;
2075
+ /** Close stdin. */
1891
2076
  closeStdin(): Promise<void>;
2077
+ /** Stream stdout and stderr as text. Omit `timeout` for no RPC deadline. */
1892
2078
  follow(opts?: {
1893
2079
  timeout?: Timeout;
1894
2080
  fromStart?: boolean;
1895
2081
  signal?: AbortSignal;
1896
- }): ReturnType<ProcessHandle$1["follow"]>;
2082
+ }): AsyncGenerator<LogEntry>;
2083
+ /** Stream stdout and stderr as bytes. */
1897
2084
  followBytes(opts?: {
1898
2085
  timeout?: Timeout;
1899
2086
  fromStart?: boolean;
1900
2087
  signal?: AbortSignal;
1901
- }): AsyncGenerator<unknown>;
2088
+ }): AsyncGenerator<StreamChunk>;
1902
2089
  }
1903
2090
 
1904
2091
  /** TypeScript SDK for numen.sandbox.v1. */
1905
2092
 
1906
- declare const publicExports: readonly ["Agent", "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"];
2093
+ /** Grant returned by `httpGrants.create`. The token is set only on create. */
2094
+ type HTTPGrant = HTTPGrant$1;
2095
+ /** Client returned by `sandbox.http`. */
2096
+ type GuestHttp = GuestHttp$1;
2097
+ /** Body returned by `GuestHttp.get` and `GuestHttp.post`. */
2098
+ type GuestResponse = GuestResponse$1;
2099
+
2100
+ declare const publicExports: readonly ["Agent", "AuthenticationError", "CapacityError", "Client", "CommandFailedError", "CommandTimeoutError", "CommandTooLargeError", "ConflictError", "DirectoryNotEmptyError", "ExecutableNotFoundError", "FileExistsError", "FileTooLargeError", "GuestRuntimeDeadError", "ImageTimeoutError", "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", "TimeoutError", "UnavailableError", "Write", "mkdir", "publicExports", "remove", "write"];
1907
2101
 
1908
- export { Agent, 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, type Token, type TokenStatus, UNLIMITED, UnavailableError, Write, mkdir, publicExports, remove, write };
2102
+ export { Agent, AuthenticationError, CapacityError, Client, type ClientOptions, CommandFailedError, CommandTimeoutError, CommandTooLargeError, ConflictError, DirectoryNotEmptyError, type ExecBytesResult, type ExecResult, ExecutableNotFoundError, FileExistsError, type FileInfo, type FileList, FileTooLargeError, type GuestHttp, type GuestResponse, GuestRuntimeDeadError, type HTTPGrant, type Image, type ImageKind, ImageTimeoutError, InvalidArgumentError, InvalidPathError, type LogEntry, LogStream, Mkdir, NameTakenError, NotFoundError, Page, PageExhaustedError, PathNotFoundError, PermissionDeniedError, PortNotOpenError, type Process, ProcessHandle, ProcessNotFoundError, ProcessWaitTimeoutError, Remove, type Resources, Sandbox, SandboxConflictError, type SandboxCreateParams, SandboxError, type SandboxInfo, SandboxNotFoundError, SandboxNotReadyError, type SandboxRow, SandboxSleepingError, SandboxStateError, SandboxStatus, SandboxTimeoutError, SandboxWaitTimeoutError, type Secret, type Snapshot, type StreamChunk, type Tag, TimeoutError, type Token, type TokenStatus, UNLIMITED, UnavailableError, type Volume, Write, mkdir, publicExports, remove, write };