disk 1.14.0 → 1.15.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 CHANGED
@@ -12,63 +12,136 @@ npm install disk
12
12
 
13
13
  ## CLI
14
14
 
15
+ The `archil` command manages disks and sandboxes. Run it with `npx archil`, or install
16
+ it with `npm install -g archil`:
17
+
15
18
  ```bash
16
- # Authenticate
17
- export ARCHIL_API_KEY=key-...
18
- export ARCHIL_REGION=aws-us-east-1
19
+ npx archil login # sign in through your browser
20
+ npx archil sandbox create dev
21
+ npx archil sandbox ssh dev # real SSH, no ports opened
22
+ npx archil sandbox forward dev 3000 # http://localhost:3000, privately
23
+ npx archil disk list
24
+ ```
19
25
 
20
- # Create a disk — the response includes a one-time disk token you'll need to mount it
21
- npx disk create my-disk
26
+ `archil login` opens the Archil console, where you approve access for this machine. The
27
+ console creates an API key named "CLI on <hostname>" and hands it back to the CLI, which
28
+ saves it as the default profile. `archil whoami` shows which account and profile commands
29
+ use, and `archil logout` removes the saved key. To revoke the key itself, delete it under
30
+ API Keys in the console. In CI or on machines without a browser, set `ARCHIL_API_KEY` and
31
+ `ARCHIL_REGION`, or save a key with `archil profile create`.
22
32
 
23
- # List and inspect
24
- npx disk list
25
- npx disk get dsk-abc123
33
+ ```bash
34
+ # Disks. `create` prints a one-time disk token you'll need to mount the disk.
35
+ npx archil disk create my-disk
36
+ npx archil disk get dsk-abc123
37
+ npx archil disk dsk-abc123 exec "ls -la /mnt" # runs in a container with the disk mounted
38
+ npx archil disk delete dsk-abc123
39
+ npx archil disk api-keys create ci-bot
40
+
41
+ # Sandboxes
42
+ npx archil sandbox create dev --vcpu-count 4 --mem-size-mib 8192 --env NODE_ENV=development
43
+ npx archil sandbox list
44
+ npx archil sandbox shell dev
45
+ npx archil sandbox run dev -- sh -c 'echo "$NODE_ENV"'
46
+ npx archil sandbox pause dev
47
+ npx archil sandbox fork dev agent-task
48
+ npx archil sandbox delete dev
49
+ ```
50
+
51
+ In a terminal, commands show progress and print tables. When stdout is piped, `list`,
52
+ `get`, `create`, and the lifecycle commands print JSON instead; pass `-o table` or
53
+ `-o json` to choose. Sandbox commands accept an exact ID or a unique name. Lifecycle
54
+ commands wait by default; use `--no-wait` to return once accepted. Starting a paused
55
+ sandbox discards its memory snapshot and prompts unless `--yes` is passed. In a shell,
56
+ `Ctrl+]` is the emergency escape. `NO_COLOR` turns colors off.
57
+
58
+ Mount commands (`archil mount`, `archil unmount`, ...) belong to the native
59
+ [Archil client](https://docs.archil.com) (`curl https://archil.com/install | sh`), which is
60
+ also called `archil`. This CLI passes any command it doesn't own through to that client.
61
+ When the client comes first on your `PATH`, run `npx archil disk ...` and
62
+ `npx archil sandbox ...` instead.
63
+
64
+ The `disk` and `sandbox` executables in this package still work and take the same
65
+ commands as `archil disk` and `archil sandbox`. Note that `npx sandbox` runs an unrelated
66
+ npm package, so use `npx archil sandbox`.
67
+
68
+ ### SSH
69
+
70
+ `archil sandbox ssh` is real OpenSSH. The connection runs over the Archil API instead of an
71
+ open port: ssh's `ProxyCommand` runs `archil sandbox ssh-proxy`. That command wakes the
72
+ sandbox if it's paused and installs `openssh-server` the first time if the image doesn't
73
+ have it. It authorizes the CLI's own key (`~/.ssh/archil_ed25519`) and pins the sandbox's
74
+ host key, which it fetches over the API, so there's no trust-on-first-use prompt.
26
75
 
27
- # Run a command against the disk's contents — Archil spins up a container with the disk
28
- # mounted, runs the command, and returns stdout/stderr/exit code.
29
- npx disk dsk-abc123 exec "ls -la /mnt"
76
+ ```bash
77
+ npx archil sandbox ssh dev
78
+ npx archil sandbox ssh dev -- uname -a
79
+ npx archil sandbox ssh dev -- -L 5432:localhost:5432 # any ssh option
80
+ ```
30
81
 
31
- # Delete
32
- npx disk delete dsk-abc123
82
+ To use scp, rsync, and editor remotes, add the `*.archil` hosts to `~/.ssh/config` once:
33
83
 
34
- # Manage account-level API keys
35
- npx disk api-keys list
36
- npx disk api-keys create ci-bot
37
- npx disk api-keys delete key-abc123
84
+ ```bash
85
+ archil sandbox ssh-config --install
86
+ ssh dev.archil
87
+ scp ./data.csv dev.archil:/root/
88
+ rsync -a ./src/ dev.archil:/root/src/
38
89
  ```
39
90
 
40
- `list` and `get` pretty-print tables by default; pass `-o json` to pipe into `jq`. Credentials come from `ARCHIL_API_KEY` / `ARCHIL_REGION`, or `--api-key` / `--region` / `--base-url` flags.
91
+ In VS Code or Cursor, choose **Remote-SSH: Connect to Host...** and enter `dev.archil`.
92
+ The config runs the installed CLI by its full path, so install it globally first
93
+ (`npm install -g archil`).
41
94
 
42
- ### Profiles
95
+ ### Forwarding ports
96
+
97
+ `archil sandbox forward dev 3000` serves the sandbox's port 3000 on
98
+ `http://localhost:3000` until you press Ctrl-C. The port stays private: the tunnel
99
+ authenticates with a short-lived port token, and nothing is exposed publicly. It carries
100
+ HTTP and WebSockets. For other protocols, such as databases, use `ssh -L`.
43
101
 
44
- `disk` and `sandbox` share named profiles:
102
+ ### Shell completion
45
103
 
46
104
  ```bash
47
- npx disk profile create --profile test-yellow --region aws-us-east-1
48
- npx sandbox profile use test-yellow
49
- npx sandbox list
105
+ source <(archil completion zsh) # in ~/.zshrc; also bash and fish
50
106
  ```
51
107
 
52
- `profile create` securely prompts for the API key. Flags override environment variables, which override the selected profile. The library API does not read profiles.
108
+ Completion covers commands, options, profile names, and your sandbox names.
53
109
 
54
- ### Sandbox CLI
110
+ ### Desktops
55
111
 
56
- The `sandbox` executable manages persistent sandboxes:
112
+ A sandbox can run a full Linux desktop (Ubuntu with XFCE and Firefox) that you open in your
113
+ browser:
57
114
 
58
115
  ```bash
59
- npx sandbox list
60
- npx sandbox create dev --vcpu-count 4 --mem-size-mib 8192 --env NODE_ENV=development
61
- npx sandbox pause dev
62
- npx sandbox resume dev --no-wait
63
- npx sandbox wait dev --status running --timeout 60
64
- npx sandbox fork dev agent-task
65
- npx sandbox run dev -- sh -c 'echo "$NODE_ENV"'
66
- npx sandbox shell dev
67
- npx sandbox stop dev
68
- npx sandbox delete dev
116
+ npx archil sandbox create my-desk --desktop
117
+ npx archil sandbox desktop my-desk # opens it in your browser, privately
118
+ npx archil sandbox desktop my-desk --share # prints a public link instead
119
+ npx archil sandbox desktop my-desk --unshare # invalidates links and disconnects viewers
69
120
  ```
70
121
 
71
- Commands accept an exact ID or unique name. Lifecycle commands wait by default; use `--no-wait` to return once accepted. Use `-o json` for structured output. Starting a paused sandbox discards its memory snapshot and prompts unless `--yes` is passed. In a shell, `Ctrl+]` is the emergency escape.
122
+ `desktop` resumes the sandbox if it's paused or stopped. By default it keeps the desktop
123
+ private: it gets a short-lived port token and serves the desktop on `localhost` until you
124
+ press Ctrl-C. `--share` exposes it on a public HTTPS hostname. Anyone with that link can see
125
+ and control the desktop until you run `--unshare`.
126
+
127
+ `--desktop` starts from `ghcr.io/archil-data/sandbox-desktop` with 2 vCPUs and 4 GiB, and turns off the idle
128
+ timeout, because viewer traffic doesn't count as sandbox activity. Sessions are capped at
129
+ 4 hours instead; override that with `--max-ttl-seconds`. To add your own software, build
130
+ an image `FROM` that one and pass it with `--base-image`. See
131
+ [archil-data/sandbox-desktop](https://github.com/archil-data/sandbox-desktop).
132
+
133
+ ### Profiles
134
+
135
+ `archil login` saves a profile for you. To manage profiles by hand:
136
+
137
+ ```bash
138
+ npx archil profile create --profile test-yellow --region aws-us-east-1
139
+ npx archil profile use test-yellow
140
+ npx archil sandbox list
141
+ ```
142
+
143
+ `profile create` securely prompts for the API key. Flags override environment variables,
144
+ which override the selected profile. The library API does not read profiles.
72
145
 
73
146
  ## Library
74
147
 
@@ -282,6 +355,45 @@ a duration up to `"8760h"` (365 days). `listPortTokens` follows all pages (its
282
355
  Public ports bypass token authentication. Revocation and expiry deny new
283
356
  connections with HTTP 401; existing connections remain open.
284
357
 
358
+ Sandboxes can run a full Linux desktop (Ubuntu with XFCE and Firefox). Create one with
359
+ `desktop: true`, which picks the desktop image, 2 vCPUs, 4 GiB, no idle expiry (viewer
360
+ traffic doesn't count as activity), and a 4-hour session cap unless you set them:
361
+
362
+ ```ts
363
+ const desk = await client.sandboxes.create({ name: "agent-desk", desktop: true });
364
+ await desk.desktop.start(); // idempotent; returns { token }
365
+
366
+ const link = await desk.desktop.share(); // public viewer URL; anyone with it controls the desktop
367
+ await desk.desktop.unshare(); // revokes every link and disconnects viewers
368
+
369
+ // Drive it like a computer-use agent
370
+ const png = await desk.desktop.screenshot(); // Uint8Array (PNG)
371
+ const { width, height } = await desk.desktop.size();
372
+ await desk.desktop.launch(["firefox", "https://example.com"]);
373
+ await desk.desktop.click(640, 400); // { button: "right", double: true } also work
374
+ await desk.desktop.type("hello");
375
+ await desk.desktop.key("ctrl+l"); // xdotool key names: Return, ctrl+shift+t, alt+F4
376
+ await desk.desktop.scroll("down", 5);
377
+ ```
378
+
379
+ Each call runs one command in the sandbox, so it works wherever the SDK does. A fork shares
380
+ its parent's viewer token; call `fork.desktop.token({ rotate: true })` before sharing it.
381
+
382
+ To view a desktop privately, or reach any HTTP port without exposing it, use `disk/tunnel`
383
+ (Node.js only). It serves the port on localhost with a short-lived access token that renews
384
+ itself, and keeps the sandbox awake until you close it:
385
+
386
+ ```ts
387
+ import { forwardPort, openDesktopTunnel } from "disk/tunnel";
388
+
389
+ const viewer = await openDesktopTunnel(desk); // localhost:6080, or any free port
390
+ console.log(viewer.viewerUrl); // open in a browser on this machine
391
+ await viewer.close();
392
+
393
+ const app = await forwardPort(desk, 3000); // http://localhost:3000 → port 3000 in the sandbox
394
+ await app.close();
395
+ ```
396
+
285
397
  Archil disks can be mounted inside the sandbox at creation. They are mounted on every
286
398
  boot and persist across stop/start and pause/resume. A sandbox with mounts must be stopped
287
399
  before it is forked; the fork inherits them:
@@ -1,6 +1,6 @@
1
+ import { ClientFrame, ServerFrame } from "@archildata/api-types/process";
1
2
  import { ConnectionOptions } from "node:tls";
2
3
  import { components, paths } from "@archildata/api-types";
3
- import { ClientFrame, ServerFrame } from "@archildata/api-types/process";
4
4
 
5
5
  //#region src/api-fetch.d.ts
6
6
  type HttpMethod = "get" | "put" | "post" | "delete" | "patch";
@@ -81,6 +81,82 @@ interface ArchilTlsOptions {
81
81
  ca?: ConnectionOptions["ca"];
82
82
  }
83
83
  //#endregion
84
+ //#region src/sandbox-desktop.d.ts
85
+ /**
86
+ * Sandbox desktops: a Linux desktop (Ubuntu, XFCE, Firefox) served over VNC
87
+ * through noVNC on {@link DESKTOP_PORT}, from the image at
88
+ * {@link DESKTOP_IMAGE} (github.com/archil-data/sandbox-desktop). Inside the
89
+ * sandbox, `desktopctl` runs the desktop as supervised services; the noVNC
90
+ * server only connects a viewer that presents the desktop's token.
91
+ *
92
+ * Everything here runs commands through the sandbox process API, so it works
93
+ * wherever the SDK does. To view a private desktop from Node, see
94
+ * `openDesktopTunnel` in `disk/tunnel`.
95
+ */
96
+ declare const DESKTOP_IMAGE = "ghcr.io/archil-data/sandbox-desktop:latest";
97
+ declare const DESKTOP_PORT = 6080;
98
+ /** A browser on the desktop is sluggish with less. */
99
+ declare const DESKTOP_VCPUS = 2;
100
+ declare const DESKTOP_MEMORY_MIB = 4096;
101
+ /**
102
+ * Session cap for desktops. Viewer traffic doesn't count as sandbox activity,
103
+ * so desktops run with idle expiry off and this cap instead.
104
+ */
105
+ declare const DESKTOP_MAX_TTL_SECONDS: number;
106
+ type DesktopMouseButton = "left" | "middle" | "right";
107
+ type DesktopScrollDirection = "up" | "down" | "left" | "right";
108
+ /** Path on the desktop's noVNC server that opens the viewer and connects with `token`. */
109
+ declare function desktopViewerPath(token: string): string;
110
+ declare class DesktopNotInstalledError extends Error {
111
+ constructor(sandboxName: string);
112
+ }
113
+ /** The desktop of one sandbox: `sandbox.desktop`. */
114
+ declare class SandboxDesktop {
115
+ private readonly sandbox;
116
+ /** @internal */
117
+ constructor(sandbox: Sandbox);
118
+ /**
119
+ * Starts the desktop if it isn't running (safe to call repeatedly) and
120
+ * returns the viewer token. Anyone holding the token can view and control
121
+ * the desktop through a link to its port.
122
+ */
123
+ start(): Promise<{
124
+ token: string;
125
+ }>;
126
+ /** The current viewer token. `rotate` replaces it first; a fork should rotate so it doesn't share its parent's. */
127
+ token(options?: {
128
+ rotate?: boolean;
129
+ }): Promise<string>;
130
+ /**
131
+ * Publishes the desktop on a public HTTPS hostname and returns a viewer
132
+ * link. Anyone with the link can see and control the desktop until
133
+ * {@link unshare}.
134
+ */
135
+ share(): Promise<string>;
136
+ /** Removes the public hostname, invalidates every existing link, and disconnects current viewers. */
137
+ unshare(): Promise<void>;
138
+ /** A PNG of the whole screen. */
139
+ screenshot(): Promise<Uint8Array>;
140
+ /** The screen size in pixels. */
141
+ size(): Promise<{
142
+ width: number;
143
+ height: number;
144
+ }>;
145
+ moveMouse(x: number, y: number): Promise<void>;
146
+ click(x: number, y: number, options?: {
147
+ button?: DesktopMouseButton;
148
+ double?: boolean;
149
+ }): Promise<void>;
150
+ scroll(direction: DesktopScrollDirection, amount?: number): Promise<void>;
151
+ /** Types `text` into the focused window. */
152
+ type(text: string): Promise<void>;
153
+ /** Presses a key or chord in xdotool's syntax, e.g. "Return", "ctrl+l", "ctrl+shift+t". */
154
+ key(keys: string): Promise<void>;
155
+ /** Starts a program on the desktop as its user, e.g. `["firefox", "https://archil.com"]`. It keeps running after this returns. */
156
+ launch(argv: string[]): Promise<void>;
157
+ private run;
158
+ }
159
+ //#endregion
84
160
  //#region src/process-output-buffer.d.ts
85
161
  /**
86
162
  * Output each process has received but its iterator has not taken yet.
@@ -488,6 +564,8 @@ declare class Sandbox {
488
564
  /** @deprecated Use run() and attach(). Removed in the next version. */
489
565
  readonly processes: SandboxProcesses;
490
566
  readonly files: SandboxFiles;
567
+ /** The sandbox's Linux desktop, for sandboxes created with `desktop: true`. */
568
+ readonly desktop: SandboxDesktop;
491
569
  /** @internal */
492
570
  private readonly _client;
493
571
  private readonly _processConnection;
@@ -1490,6 +1568,12 @@ interface CreateSandboxRequest {
1490
1568
  baseImage?: string;
1491
1569
  /** Ready image from `images.build()`. Cannot be combined with `baseImage`. */
1492
1570
  imageId?: string;
1571
+ /**
1572
+ * Create a desktop sandbox: unless set here, uses the desktop image, 2 vCPUs,
1573
+ * 4 GiB, no idle expiry (viewer traffic doesn't count as activity), and a
1574
+ * 4-hour session cap. Start it with `sandbox.desktop.start()`.
1575
+ */
1576
+ desktop?: boolean;
1493
1577
  env?: Record<string, string>;
1494
1578
  maxTtlSeconds?: number;
1495
1579
  /** Seconds without a direct process connection before pausing. Omitted or zero disables idle expiry. */
@@ -1733,4 +1817,4 @@ declare class Archil {
1733
1817
  workspace(mounts: Record<string, ExecMount>): Workspace;
1734
1818
  }
1735
1819
  //#endregion
1736
- export { ApiTokenResponse as $, SandboxFileUploadOptions as $t, DiskMultipart as A, ExecVmOptions as At, MultipartUploadListing as B, SandboxMount as Bt, AppendObjectOptions as C, RootAttrs as Ct, DeleteObjectsOptions as D, TokenUser as Dt, DeleteObjectsError as E, S3User as Et, ListObjectsOptions as F, SandboxEgressPolicy as Ft, PosixCreateAttrs as G, SandboxPortTokenPage as Gt, ObjectMetadata as H, SandboxNetwork as Ht, ListObjectsResult as I, SandboxEgressRule as It, S3Object as J, SandboxStatus as Jt, PutObjectOptions as K, SandboxResponse as Kt, ListPartsOptions as L, SandboxEgressTransform as Lt, GrepOptions as M, CreatedSandboxPortToken as Mt, GrepResult as N, ListSandboxPortTokensOptions as Nt, DeleteObjectsResult as O, FileSystem as Ot, ListMultipartUploadsOptions as P, Sandbox as Pt, effectiveUploadPartSize as Q, SandboxFileSource as Qt, MountOptions as R, SandboxEndpoint as Rt, ListDisksOptions as S, R2Mount as St, CreateBranchOptions as T, S3Mount as Tt, PartInfo as U, SandboxNetworkAction as Ut, MultipartUploadSummary as V, SandboxMountSpec as Vt, PartListing as W, SandboxPortToken as Wt, ShareUrlResult as X, SandboxTimeoutOptions as Xt, ShareUrlOptions as Y, SandboxTimeoutAction as Yt, UploadPart as Z, SandboxWaitOptions as Zt, Images as _, GrepMatch as _t, ExecOptions as a, SandboxProcessOutputHandler as an, CreateApiTokenRequest as at, DiskListPage as b, MountConfigResponse as bt, Tokens as c, SandboxProcessStatus as cn, DiskMetrics as ct, Sandboxes as d, SandboxTerminalOptions as dn, DiskUser as dt, SandboxFileWriter as en, AuthorizedUser as et, BuildImageOptions as f, ArchilTlsOptions as fn, ExecDiskResult as ft, ImageStatus as g, GrepGroupLine as gt, ImageFailureReason as h, GrepGroup as ht, ExecMountSpec as i, SandboxProcessOutput as in, ConnectedClient as it, ExecResult as j, CreateSandboxPortTokenOptions as jt, Disk as k, ExecNetwork as kt, CreateSandboxRequest as l, SandboxProcessStream as ln, DiskResponse as lt, Image as m, GCSMount as mt, ArchilOptions as n, SandboxProcess as nn, AzureBlobMount as nt, Workspace as o, SandboxProcessResult as on, CreateDiskRequest as ot, BuildImageRequest as p, ExecRequest as pt, PutObjectResult as q, SandboxStartOptions as qt, ExecMount as r, SandboxProcessConnectOptions as rn, Branch as rt, ListTokensOptions as s, SandboxProcessStartOptions as sn, Delegation as st, Archil as t, SandboxFiles as tn, AwsStsUser as tt, ListSandboxesOptions as u, SandboxProcesses as un, DiskStatus as ut, RegistryAuth as v, GrepStoppedReason as vt, CompletedMultipartUpload as w, S3CompatibleMount as wt, Disks as x, MountResponse as xt, CreateDiskResult as y, MountConfig as yt, MultipartUpload as z, SandboxForkOptions as zt };
1820
+ export { ApiTokenResponse as $, SandboxFileUploadOptions as $t, DiskMultipart as A, ExecVmOptions as At, MultipartUploadListing as B, SandboxMount as Bt, AppendObjectOptions as C, RootAttrs as Ct, DeleteObjectsOptions as D, TokenUser as Dt, DeleteObjectsError as E, S3User as Et, ListObjectsOptions as F, SandboxEgressPolicy as Ft, PosixCreateAttrs as G, SandboxPortTokenPage as Gt, ObjectMetadata as H, SandboxNetwork as Ht, ListObjectsResult as I, SandboxEgressRule as It, S3Object as J, SandboxStatus as Jt, PutObjectOptions as K, SandboxResponse as Kt, ListPartsOptions as L, SandboxEgressTransform as Lt, GrepOptions as M, CreatedSandboxPortToken as Mt, GrepResult as N, ListSandboxPortTokensOptions as Nt, DeleteObjectsResult as O, FileSystem as Ot, ListMultipartUploadsOptions as P, Sandbox as Pt, effectiveUploadPartSize as Q, SandboxFileSource as Qt, MountOptions as R, SandboxEndpoint as Rt, ListDisksOptions as S, ArchilTlsOptions as Sn, R2Mount as St, CreateBranchOptions as T, S3Mount as Tt, PartInfo as U, SandboxNetworkAction as Ut, MultipartUploadSummary as V, SandboxMountSpec as Vt, PartListing as W, SandboxPortToken as Wt, ShareUrlResult as X, SandboxTimeoutOptions as Xt, ShareUrlOptions as Y, SandboxTimeoutAction as Yt, UploadPart as Z, SandboxWaitOptions as Zt, Images as _, DesktopMouseButton as _n, GrepMatch as _t, ExecOptions as a, SandboxProcessOutputHandler as an, CreateApiTokenRequest as at, DiskListPage as b, SandboxDesktop as bn, MountConfigResponse as bt, Tokens as c, SandboxProcessStatus as cn, DiskMetrics as ct, Sandboxes as d, SandboxTerminalOptions as dn, DiskUser as dt, SandboxFileWriter as en, AuthorizedUser as et, BuildImageOptions as f, DESKTOP_IMAGE as fn, ExecDiskResult as ft, ImageStatus as g, DESKTOP_VCPUS as gn, GrepGroupLine as gt, ImageFailureReason as h, DESKTOP_PORT as hn, GrepGroup as ht, ExecMountSpec as i, SandboxProcessOutput as in, ConnectedClient as it, ExecResult as j, CreateSandboxPortTokenOptions as jt, Disk as k, ExecNetwork as kt, CreateSandboxRequest as l, SandboxProcessStream as ln, DiskResponse as lt, Image as m, DESKTOP_MEMORY_MIB as mn, GCSMount as mt, ArchilOptions as n, SandboxProcess as nn, AzureBlobMount as nt, Workspace as o, SandboxProcessResult as on, CreateDiskRequest as ot, BuildImageRequest as p, DESKTOP_MAX_TTL_SECONDS as pn, ExecRequest as pt, PutObjectResult as q, SandboxStartOptions as qt, ExecMount as r, SandboxProcessConnectOptions as rn, Branch as rt, ListTokensOptions as s, SandboxProcessStartOptions as sn, Delegation as st, Archil as t, SandboxFiles as tn, AwsStsUser as tt, ListSandboxesOptions as u, SandboxProcesses as un, DiskStatus as ut, RegistryAuth as v, DesktopNotInstalledError as vn, GrepStoppedReason as vt, CompletedMultipartUpload as w, S3CompatibleMount as wt, Disks as x, desktopViewerPath as xn, MountResponse as xt, CreateDiskResult as y, DesktopScrollDirection as yn, MountConfig as yt, MultipartUpload as z, SandboxForkOptions as zt };
@@ -1,6 +1,6 @@
1
- import { ClientFrame, ServerFrame } from "@archildata/api-types/process";
2
1
  import { ConnectionOptions } from "node:tls";
3
2
  import { components, paths } from "@archildata/api-types";
3
+ import { ClientFrame, ServerFrame } from "@archildata/api-types/process";
4
4
 
5
5
  //#region src/api-fetch.d.ts
6
6
  type HttpMethod = "get" | "put" | "post" | "delete" | "patch";
@@ -81,6 +81,82 @@ interface ArchilTlsOptions {
81
81
  ca?: ConnectionOptions["ca"];
82
82
  }
83
83
  //#endregion
84
+ //#region src/sandbox-desktop.d.ts
85
+ /**
86
+ * Sandbox desktops: a Linux desktop (Ubuntu, XFCE, Firefox) served over VNC
87
+ * through noVNC on {@link DESKTOP_PORT}, from the image at
88
+ * {@link DESKTOP_IMAGE} (github.com/archil-data/sandbox-desktop). Inside the
89
+ * sandbox, `desktopctl` runs the desktop as supervised services; the noVNC
90
+ * server only connects a viewer that presents the desktop's token.
91
+ *
92
+ * Everything here runs commands through the sandbox process API, so it works
93
+ * wherever the SDK does. To view a private desktop from Node, see
94
+ * `openDesktopTunnel` in `disk/tunnel`.
95
+ */
96
+ declare const DESKTOP_IMAGE = "ghcr.io/archil-data/sandbox-desktop:latest";
97
+ declare const DESKTOP_PORT = 6080;
98
+ /** A browser on the desktop is sluggish with less. */
99
+ declare const DESKTOP_VCPUS = 2;
100
+ declare const DESKTOP_MEMORY_MIB = 4096;
101
+ /**
102
+ * Session cap for desktops. Viewer traffic doesn't count as sandbox activity,
103
+ * so desktops run with idle expiry off and this cap instead.
104
+ */
105
+ declare const DESKTOP_MAX_TTL_SECONDS: number;
106
+ type DesktopMouseButton = "left" | "middle" | "right";
107
+ type DesktopScrollDirection = "up" | "down" | "left" | "right";
108
+ /** Path on the desktop's noVNC server that opens the viewer and connects with `token`. */
109
+ declare function desktopViewerPath(token: string): string;
110
+ declare class DesktopNotInstalledError extends Error {
111
+ constructor(sandboxName: string);
112
+ }
113
+ /** The desktop of one sandbox: `sandbox.desktop`. */
114
+ declare class SandboxDesktop {
115
+ private readonly sandbox;
116
+ /** @internal */
117
+ constructor(sandbox: Sandbox);
118
+ /**
119
+ * Starts the desktop if it isn't running (safe to call repeatedly) and
120
+ * returns the viewer token. Anyone holding the token can view and control
121
+ * the desktop through a link to its port.
122
+ */
123
+ start(): Promise<{
124
+ token: string;
125
+ }>;
126
+ /** The current viewer token. `rotate` replaces it first; a fork should rotate so it doesn't share its parent's. */
127
+ token(options?: {
128
+ rotate?: boolean;
129
+ }): Promise<string>;
130
+ /**
131
+ * Publishes the desktop on a public HTTPS hostname and returns a viewer
132
+ * link. Anyone with the link can see and control the desktop until
133
+ * {@link unshare}.
134
+ */
135
+ share(): Promise<string>;
136
+ /** Removes the public hostname, invalidates every existing link, and disconnects current viewers. */
137
+ unshare(): Promise<void>;
138
+ /** A PNG of the whole screen. */
139
+ screenshot(): Promise<Uint8Array>;
140
+ /** The screen size in pixels. */
141
+ size(): Promise<{
142
+ width: number;
143
+ height: number;
144
+ }>;
145
+ moveMouse(x: number, y: number): Promise<void>;
146
+ click(x: number, y: number, options?: {
147
+ button?: DesktopMouseButton;
148
+ double?: boolean;
149
+ }): Promise<void>;
150
+ scroll(direction: DesktopScrollDirection, amount?: number): Promise<void>;
151
+ /** Types `text` into the focused window. */
152
+ type(text: string): Promise<void>;
153
+ /** Presses a key or chord in xdotool's syntax, e.g. "Return", "ctrl+l", "ctrl+shift+t". */
154
+ key(keys: string): Promise<void>;
155
+ /** Starts a program on the desktop as its user, e.g. `["firefox", "https://archil.com"]`. It keeps running after this returns. */
156
+ launch(argv: string[]): Promise<void>;
157
+ private run;
158
+ }
159
+ //#endregion
84
160
  //#region src/process-output-buffer.d.ts
85
161
  /**
86
162
  * Output each process has received but its iterator has not taken yet.
@@ -488,6 +564,8 @@ declare class Sandbox {
488
564
  /** @deprecated Use run() and attach(). Removed in the next version. */
489
565
  readonly processes: SandboxProcesses;
490
566
  readonly files: SandboxFiles;
567
+ /** The sandbox's Linux desktop, for sandboxes created with `desktop: true`. */
568
+ readonly desktop: SandboxDesktop;
491
569
  /** @internal */
492
570
  private readonly _client;
493
571
  private readonly _processConnection;
@@ -1490,6 +1568,12 @@ interface CreateSandboxRequest {
1490
1568
  baseImage?: string;
1491
1569
  /** Ready image from `images.build()`. Cannot be combined with `baseImage`. */
1492
1570
  imageId?: string;
1571
+ /**
1572
+ * Create a desktop sandbox: unless set here, uses the desktop image, 2 vCPUs,
1573
+ * 4 GiB, no idle expiry (viewer traffic doesn't count as activity), and a
1574
+ * 4-hour session cap. Start it with `sandbox.desktop.start()`.
1575
+ */
1576
+ desktop?: boolean;
1493
1577
  env?: Record<string, string>;
1494
1578
  maxTtlSeconds?: number;
1495
1579
  /** Seconds without a direct process connection before pausing. Omitted or zero disables idle expiry. */
@@ -1733,4 +1817,4 @@ declare class Archil {
1733
1817
  workspace(mounts: Record<string, ExecMount>): Workspace;
1734
1818
  }
1735
1819
  //#endregion
1736
- export { ApiTokenResponse as $, SandboxFileUploadOptions as $t, DiskMultipart as A, ExecVmOptions as At, MultipartUploadListing as B, SandboxMount as Bt, AppendObjectOptions as C, RootAttrs as Ct, DeleteObjectsOptions as D, TokenUser as Dt, DeleteObjectsError as E, S3User as Et, ListObjectsOptions as F, SandboxEgressPolicy as Ft, PosixCreateAttrs as G, SandboxPortTokenPage as Gt, ObjectMetadata as H, SandboxNetwork as Ht, ListObjectsResult as I, SandboxEgressRule as It, S3Object as J, SandboxStatus as Jt, PutObjectOptions as K, SandboxResponse as Kt, ListPartsOptions as L, SandboxEgressTransform as Lt, GrepOptions as M, CreatedSandboxPortToken as Mt, GrepResult as N, ListSandboxPortTokensOptions as Nt, DeleteObjectsResult as O, FileSystem as Ot, ListMultipartUploadsOptions as P, Sandbox as Pt, effectiveUploadPartSize as Q, SandboxFileSource as Qt, MountOptions as R, SandboxEndpoint as Rt, ListDisksOptions as S, R2Mount as St, CreateBranchOptions as T, S3Mount as Tt, PartInfo as U, SandboxNetworkAction as Ut, MultipartUploadSummary as V, SandboxMountSpec as Vt, PartListing as W, SandboxPortToken as Wt, ShareUrlResult as X, SandboxTimeoutOptions as Xt, ShareUrlOptions as Y, SandboxTimeoutAction as Yt, UploadPart as Z, SandboxWaitOptions as Zt, Images as _, GrepMatch as _t, ExecOptions as a, SandboxProcessOutputHandler as an, CreateApiTokenRequest as at, DiskListPage as b, MountConfigResponse as bt, Tokens as c, SandboxProcessStatus as cn, DiskMetrics as ct, Sandboxes as d, SandboxTerminalOptions as dn, DiskUser as dt, SandboxFileWriter as en, AuthorizedUser as et, BuildImageOptions as f, ArchilTlsOptions as fn, ExecDiskResult as ft, ImageStatus as g, GrepGroupLine as gt, ImageFailureReason as h, GrepGroup as ht, ExecMountSpec as i, SandboxProcessOutput as in, ConnectedClient as it, ExecResult as j, CreateSandboxPortTokenOptions as jt, Disk as k, ExecNetwork as kt, CreateSandboxRequest as l, SandboxProcessStream as ln, DiskResponse as lt, Image as m, GCSMount as mt, ArchilOptions as n, SandboxProcess as nn, AzureBlobMount as nt, Workspace as o, SandboxProcessResult as on, CreateDiskRequest as ot, BuildImageRequest as p, ExecRequest as pt, PutObjectResult as q, SandboxStartOptions as qt, ExecMount as r, SandboxProcessConnectOptions as rn, Branch as rt, ListTokensOptions as s, SandboxProcessStartOptions as sn, Delegation as st, Archil as t, SandboxFiles as tn, AwsStsUser as tt, ListSandboxesOptions as u, SandboxProcesses as un, DiskStatus as ut, RegistryAuth as v, GrepStoppedReason as vt, CompletedMultipartUpload as w, S3CompatibleMount as wt, Disks as x, MountResponse as xt, CreateDiskResult as y, MountConfig as yt, MultipartUpload as z, SandboxForkOptions as zt };
1820
+ export { ApiTokenResponse as $, SandboxFileUploadOptions as $t, DiskMultipart as A, ExecVmOptions as At, MultipartUploadListing as B, SandboxMount as Bt, AppendObjectOptions as C, RootAttrs as Ct, DeleteObjectsOptions as D, TokenUser as Dt, DeleteObjectsError as E, S3User as Et, ListObjectsOptions as F, SandboxEgressPolicy as Ft, PosixCreateAttrs as G, SandboxPortTokenPage as Gt, ObjectMetadata as H, SandboxNetwork as Ht, ListObjectsResult as I, SandboxEgressRule as It, S3Object as J, SandboxStatus as Jt, PutObjectOptions as K, SandboxResponse as Kt, ListPartsOptions as L, SandboxEgressTransform as Lt, GrepOptions as M, CreatedSandboxPortToken as Mt, GrepResult as N, ListSandboxPortTokensOptions as Nt, DeleteObjectsResult as O, FileSystem as Ot, ListMultipartUploadsOptions as P, Sandbox as Pt, effectiveUploadPartSize as Q, SandboxFileSource as Qt, MountOptions as R, SandboxEndpoint as Rt, ListDisksOptions as S, ArchilTlsOptions as Sn, R2Mount as St, CreateBranchOptions as T, S3Mount as Tt, PartInfo as U, SandboxNetworkAction as Ut, MultipartUploadSummary as V, SandboxMountSpec as Vt, PartListing as W, SandboxPortToken as Wt, ShareUrlResult as X, SandboxTimeoutOptions as Xt, ShareUrlOptions as Y, SandboxTimeoutAction as Yt, UploadPart as Z, SandboxWaitOptions as Zt, Images as _, DesktopMouseButton as _n, GrepMatch as _t, ExecOptions as a, SandboxProcessOutputHandler as an, CreateApiTokenRequest as at, DiskListPage as b, SandboxDesktop as bn, MountConfigResponse as bt, Tokens as c, SandboxProcessStatus as cn, DiskMetrics as ct, Sandboxes as d, SandboxTerminalOptions as dn, DiskUser as dt, SandboxFileWriter as en, AuthorizedUser as et, BuildImageOptions as f, DESKTOP_IMAGE as fn, ExecDiskResult as ft, ImageStatus as g, DESKTOP_VCPUS as gn, GrepGroupLine as gt, ImageFailureReason as h, DESKTOP_PORT as hn, GrepGroup as ht, ExecMountSpec as i, SandboxProcessOutput as in, ConnectedClient as it, ExecResult as j, CreateSandboxPortTokenOptions as jt, Disk as k, ExecNetwork as kt, CreateSandboxRequest as l, SandboxProcessStream as ln, DiskResponse as lt, Image as m, DESKTOP_MEMORY_MIB as mn, GCSMount as mt, ArchilOptions as n, SandboxProcess as nn, AzureBlobMount as nt, Workspace as o, SandboxProcessResult as on, CreateDiskRequest as ot, BuildImageRequest as p, DESKTOP_MAX_TTL_SECONDS as pn, ExecRequest as pt, PutObjectResult as q, SandboxStartOptions as qt, ExecMount as r, SandboxProcessConnectOptions as rn, Branch as rt, ListTokensOptions as s, SandboxProcessStartOptions as sn, Delegation as st, Archil as t, SandboxFiles as tn, AwsStsUser as tt, ListSandboxesOptions as u, SandboxProcesses as un, DiskStatus as ut, RegistryAuth as v, DesktopNotInstalledError as vn, GrepStoppedReason as vt, CompletedMultipartUpload as w, S3CompatibleMount as wt, Disks as x, desktopViewerPath as xn, MountResponse as xt, CreateDiskResult as y, DesktopScrollDirection as yn, MountConfig as yt, MultipartUpload as z, SandboxForkOptions as zt };