@sailresearch/sdk 0.2.14

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 (89) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +126 -0
  3. package/dist/app.d.ts +23 -0
  4. package/dist/app.d.ts.map +1 -0
  5. package/dist/app.js +40 -0
  6. package/dist/app.js.map +1 -0
  7. package/dist/client.d.ts +119 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +291 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/config.d.ts +8 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +15 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/default-client.d.ts +13 -0
  16. package/dist/default-client.d.ts.map +1 -0
  17. package/dist/default-client.js +22 -0
  18. package/dist/default-client.js.map +1 -0
  19. package/dist/errors.d.ts +88 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +201 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/exec-process.d.ts +56 -0
  24. package/dist/exec-process.d.ts.map +1 -0
  25. package/dist/exec-process.js +105 -0
  26. package/dist/exec-process.js.map +1 -0
  27. package/dist/exec-stream.d.ts +21 -0
  28. package/dist/exec-stream.d.ts.map +1 -0
  29. package/dist/exec-stream.js +47 -0
  30. package/dist/exec-stream.js.map +1 -0
  31. package/dist/file-stream.d.ts +41 -0
  32. package/dist/file-stream.d.ts.map +1 -0
  33. package/dist/file-stream.js +86 -0
  34. package/dist/file-stream.js.map +1 -0
  35. package/dist/image.d.ts +90 -0
  36. package/dist/image.d.ts.map +1 -0
  37. package/dist/image.js +193 -0
  38. package/dist/image.js.map +1 -0
  39. package/dist/index.d.ts +31 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +55 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/native.d.ts +10 -0
  44. package/dist/native.d.ts.map +1 -0
  45. package/dist/native.js +24 -0
  46. package/dist/native.js.map +1 -0
  47. package/dist/sailbox.d.ts +210 -0
  48. package/dist/sailbox.d.ts.map +1 -0
  49. package/dist/sailbox.js +339 -0
  50. package/dist/sailbox.js.map +1 -0
  51. package/dist/ssh.d.ts +16 -0
  52. package/dist/ssh.d.ts.map +1 -0
  53. package/dist/ssh.js +3 -0
  54. package/dist/ssh.js.map +1 -0
  55. package/dist/types/config.d.ts +21 -0
  56. package/dist/types/config.d.ts.map +1 -0
  57. package/dist/types/config.js +4 -0
  58. package/dist/types/config.js.map +1 -0
  59. package/dist/types/exec.d.ts +41 -0
  60. package/dist/types/exec.d.ts.map +1 -0
  61. package/dist/types/exec.js +4 -0
  62. package/dist/types/exec.js.map +1 -0
  63. package/dist/types/image.d.ts +50 -0
  64. package/dist/types/image.d.ts.map +1 -0
  65. package/dist/types/image.js +12 -0
  66. package/dist/types/image.js.map +1 -0
  67. package/dist/types/listener.d.ts +38 -0
  68. package/dist/types/listener.d.ts.map +1 -0
  69. package/dist/types/listener.js +21 -0
  70. package/dist/types/listener.js.map +1 -0
  71. package/dist/types/sailbox.d.ts +62 -0
  72. package/dist/types/sailbox.d.ts.map +1 -0
  73. package/dist/types/sailbox.js +19 -0
  74. package/dist/types/sailbox.js.map +1 -0
  75. package/dist/util.d.ts +3 -0
  76. package/dist/util.d.ts.map +1 -0
  77. package/dist/util.js +10 -0
  78. package/dist/util.js.map +1 -0
  79. package/dist/validate.d.ts +35 -0
  80. package/dist/validate.d.ts.map +1 -0
  81. package/dist/validate.js +87 -0
  82. package/dist/validate.js.map +1 -0
  83. package/dist/volume.d.ts +42 -0
  84. package/dist/volume.d.ts.map +1 -0
  85. package/dist/volume.js +72 -0
  86. package/dist/volume.js.map +1 -0
  87. package/native/index.d.ts +733 -0
  88. package/native/index.js +601 -0
  89. package/package.json +77 -0
@@ -0,0 +1,210 @@
1
+ import type { Client } from "./client.js";
2
+ import type { EnableSshOptions, SshEndpoint } from "./ssh.js";
3
+ import { Image } from "./image.js";
4
+ import type { ImageSpec } from "./types/image.js";
5
+ import type { ExecProcess } from "./exec-process.js";
6
+ import type { FileStream, FileWriter } from "./file-stream.js";
7
+ import type { IngressProtocol, Listener } from "./types/listener.js";
8
+ import type { ExecOptions, ShellOptions, WriteOptions } from "./types/exec.js";
9
+ import type { CreateSailboxRequest, FromCheckpointRequest, ListSailboxesQuery, SailboxCheckpoint, SailboxInfoPage, SailboxStatus, UpgradeResult } from "./types/sailbox.js";
10
+ import type { ClientOptions } from "./types/config.js";
11
+ import type { IngressPortInput } from "./types/sailbox.js";
12
+ import type { App } from "./app.js";
13
+ import type { Volume } from "./volume.js";
14
+ /**
15
+ * Options for {@link Sailbox.create}: the create request plus a per-attempt
16
+ * timeout and an optional explicit client. `image` defaults to a Debian base.
17
+ */
18
+ export interface CreateSailboxOptions extends Omit<CreateSailboxRequest, "image" | "appId" | "volumeMounts" | "ingressPorts">, ClientOptions {
19
+ /** The owning app, or its id. */
20
+ app: App | string;
21
+ /** Image spec, or an {@link Image} builder (built and resolved at create).
22
+ * Defaults to a plain Debian base. */
23
+ image?: ImageSpec | Image;
24
+ /** Guest ports to expose: a bare number is HTTP shorthand. */
25
+ ingressPorts?: (number | IngressPortInput)[];
26
+ /** Shared volumes to mount, mapping an absolute guest path to a
27
+ * {@link Volume} or volume id. */
28
+ volumes?: Record<string, Volume | string>;
29
+ /** Bounds each create attempt (default 600s); pass `0` for no client-side
30
+ * timeout. Timed-out attempts are retried, reattaching to the same box, so
31
+ * when the overall budget is exhausted the box may still be coming up
32
+ * server-side: find or terminate it by `name`. */
33
+ timeoutSeconds?: number;
34
+ /** Timeout in seconds for building a custom `Image` before create (1800). */
35
+ imageBuildTimeoutSeconds?: number;
36
+ /** Enable SSH on the new sailbox after create: trust the org SSH CA, start
37
+ * `sshd`, and expose guest port 22 as TCP once the CA-only daemon owns it
38
+ * (an explicit port-22 ingress entry contributes just its allowlist).
39
+ * Equivalent to calling {@link Sailbox.enableSsh} after create. */
40
+ ssh?: boolean;
41
+ }
42
+ /** Options for {@link Sailbox.fromCheckpoint}. */
43
+ export interface FromCheckpointOptions extends FromCheckpointRequest, ClientOptions {
44
+ }
45
+ /** Options for {@link Sailbox.checkpoint}. */
46
+ export interface CheckpointOptions {
47
+ /** Display name for the checkpoint handle. */
48
+ name?: string;
49
+ /** Retention override in whole seconds (must be positive). Set it when you
50
+ * keep a checkpoint to reuse as a template, so the handle does not expire
51
+ * while you still need it; omitted uses the server default. */
52
+ ttlSeconds?: number;
53
+ }
54
+ /** One page of {@link Sailbox} instances plus the pagination envelope. */
55
+ export interface SailboxPage extends Omit<SailboxInfoPage, "items"> {
56
+ items: Sailbox[];
57
+ }
58
+ /** Options for {@link Sailbox.waitForListener}. */
59
+ export interface WaitForListenerOptions {
60
+ /** Give up waiting after this many seconds (default 60; `Infinity` waits
61
+ * indefinitely). */
62
+ timeoutSeconds?: number;
63
+ /** Re-check cadence in seconds (default 1). */
64
+ pollIntervalSeconds?: number;
65
+ }
66
+ /**
67
+ * A sandbox (sailbox): the primary object agent harnesses work with. Create one
68
+ * with {@link Sailbox.create}, run commands with {@link exec}, move files with
69
+ * {@link writeStream}/{@link readStream}, expose ports with {@link expose}, and
70
+ * manage its lifecycle. The statics use a default env-configured client unless
71
+ * you pass one.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * import { App, Sailbox } from "@sailresearch/sdk";
76
+ *
77
+ * const app = await App.find("example-app", { mintIfMissing: true });
78
+ * const box = await Sailbox.create({ app, name: "worker-1" });
79
+ * const proc = await box.exec(["bash", "-lc", "echo hello"]);
80
+ * console.log(await proc.stdout.text());
81
+ * await box.terminate();
82
+ * ```
83
+ */
84
+ export declare class Sailbox {
85
+ #private;
86
+ private constructor();
87
+ private static fromInfo;
88
+ private static fromHandle;
89
+ /** Create a new sailbox. */
90
+ static create(options: CreateSailboxOptions): Promise<Sailbox>;
91
+ /** Create a new sailbox from a checkpoint. */
92
+ static fromCheckpoint(options: FromCheckpointOptions): Promise<Sailbox>;
93
+ /** Fetch an existing sailbox by id. */
94
+ static get(sailboxId: string, options?: ClientOptions): Promise<Sailbox>;
95
+ /** List one page of sailboxes as {@link Sailbox} instances. */
96
+ static list(params?: ListSailboxesQuery, options?: ClientOptions): Promise<Sailbox[]>;
97
+ /** Like {@link list} but also returns the pagination envelope
98
+ * (`total`/`hasMore`) for paging through large result sets. */
99
+ static listPage(params?: ListSailboxesQuery, options?: ClientOptions): Promise<SailboxPage>;
100
+ /** The sailbox's stable identifier. */
101
+ get sailboxId(): string;
102
+ /** The sailbox name. */
103
+ get name(): string;
104
+ /** The lifecycle status as of the call that produced this handle (updated
105
+ * by lifecycle calls on this instance). Use {@link Sailbox.get} for a fresh
106
+ * snapshot. */
107
+ get status(): SailboxStatus;
108
+ /** Identifier of the owning app. */
109
+ get appId(): string | undefined;
110
+ /** Name of the owning app. */
111
+ get appName(): string | undefined;
112
+ /** Identifier of the image the sailbox was created from. */
113
+ get imageId(): string | undefined;
114
+ /** Configured memory, in MiB. */
115
+ get memoryMib(): number | undefined;
116
+ /** Configured number of vCPUs. */
117
+ get vcpuCount(): number | undefined;
118
+ /** Configured state-disk size, in GiB. */
119
+ get stateDiskSizeGib(): number | undefined;
120
+ /** Requested CPU, in vCPUs. */
121
+ get cpuRequestedVcpu(): number | undefined;
122
+ /** Current CPU usage, in vCPUs, as of the snapshot. */
123
+ get cpuUsedVcpu(): number | undefined;
124
+ /** Requested memory, in bytes. */
125
+ get memoryRequestedBytes(): number | undefined;
126
+ /** Current memory usage, in bytes, as of the snapshot. */
127
+ get memoryUsedBytes(): number | undefined;
128
+ /** Requested disk, in bytes. */
129
+ get diskRequestedBytes(): number | undefined;
130
+ /** Current disk usage, in bytes, as of the snapshot. */
131
+ get diskUsedBytes(): number | undefined;
132
+ /** CPU architecture (for example `arm64`). */
133
+ get architecture(): string | undefined;
134
+ /** In-guest agent schema version the sailbox last booted with. */
135
+ get guestSchemaVersion(): number | undefined;
136
+ /** Failure detail when the status is `failed`. */
137
+ get errorMessage(): string | undefined;
138
+ /** Checkpoint generation counter as of the snapshot. */
139
+ get checkpointGeneration(): number | undefined;
140
+ /** When the current boot started (RFC 3339). */
141
+ get startedAt(): Date | undefined;
142
+ /** When the most recent checkpoint was taken. */
143
+ get lastCheckpointedAt(): Date | undefined;
144
+ /** When the sailbox was created. */
145
+ get createdAt(): Date | undefined;
146
+ /** When the sailbox last changed. */
147
+ get updatedAt(): Date | undefined;
148
+ /** The underlying {@link Client}. */
149
+ get client(): Client;
150
+ /** Run a command and return a handle to the live process. A `string` command
151
+ * is run via `/bin/sh -lc`; a `string[]` is exec'd directly. `options` can set
152
+ * a working directory or detach the command (see {@link ExecOptions}). */
153
+ exec(command: string | string[], options?: ExecOptions): Promise<ExecProcess>;
154
+ /** Open an interactive pty session on this sailbox, bridged to the local
155
+ * terminal. With no `command`, runs a login shell; pass a command to run
156
+ * that under a pty instead (e.g. a REPL or an editor). Blocks until the
157
+ * remote process exits and resolves with its exit code. Requires an
158
+ * interactive terminal (stdin and stdout TTYs). */
159
+ shell(command?: string, options?: ShellOptions): Promise<number>;
160
+ /** Open a streaming read of a guest file. */
161
+ readStream(path: string): Promise<FileStream>;
162
+ /** Open a streaming upload to a guest file. */
163
+ writeStream(path: string, options?: WriteOptions): Promise<FileWriter>;
164
+ /** Read a guest file fully into memory (convenience over {@link readStream}). */
165
+ read(path: string): Promise<Buffer>;
166
+ /** Write bytes (a `string` is encoded as UTF-8) to a guest file, creating it
167
+ * and any missing parent directories (convenience over {@link writeStream};
168
+ * pass `createParents: false` to opt out). */
169
+ write(path: string, data: Buffer | Uint8Array | string, options?: WriteOptions): Promise<void>;
170
+ /** Expose a guest port at runtime. The returned listener carries the
171
+ * resolved endpoint but an `"unspecified"` route status: the response
172
+ * confirms configuration, not reachability — {@link waitForListener}
173
+ * confirms the route is live. */
174
+ expose(guestPort: number, protocol?: IngressProtocol, allowlist?: string[]): Promise<Listener>;
175
+ /** Remove a runtime ingress port. */
176
+ unexpose(guestPort: number): Promise<void>;
177
+ /** List this sailbox's listeners without waking it. */
178
+ listeners(): Promise<Listener[]>;
179
+ /** Fetch one listener by guest port without waking the box. */
180
+ listener(guestPort: number): Promise<Listener>;
181
+ /** Poll until the listener on `guestPort` is reachable end to end — route
182
+ * status ACTIVE and its endpoint accepts (HTTP GET / raw-TCP connect) — and
183
+ * return it, or throw {@link TimeoutError} after `timeoutSeconds`. The wait loop
184
+ * and reachability probes run in the core, shared by every SDK. */
185
+ waitForListener(guestPort: number, options?: WaitForListenerOptions): Promise<Listener>;
186
+ /** Ingress-identity headers for this sailbox, as a name→value map. */
187
+ ingressAuthHeaders(): Promise<Record<string, string>>;
188
+ /** Enable SSH on this sailbox: trust the org SSH CA, start `sshd`, and
189
+ * expose guest port 22 as TCP once the CA-only daemon owns it. Org members
190
+ * connect with a short-lived certificate (fetched by the `sail box ssh`
191
+ * CLI). Safe to re-run. With `wait` (the default), polls until the endpoint
192
+ * is reachable and returns it, throwing {@link TimeoutError} if it is not
193
+ * within `timeoutSeconds`; with `wait: false`, skips the probe and resolves
194
+ * `null`. */
195
+ enableSsh(options?: EnableSshOptions): Promise<SshEndpoint | null>;
196
+ /** Terminate (delete) this sailbox (updates {@link status}). */
197
+ terminate(): Promise<void>;
198
+ /** Pause this sailbox in memory. */
199
+ pause(): Promise<void>;
200
+ /** Sleep this sailbox to disk (wakes on traffic). */
201
+ sleep(): Promise<void>;
202
+ /** Resume this sailbox (updates {@link status}). */
203
+ resume(): Promise<void>;
204
+ /** Take a checkpoint of this sailbox. The returned handle carries
205
+ * `expiresAt`, when it becomes eligible for garbage collection. */
206
+ checkpoint(options?: CheckpointOptions): Promise<SailboxCheckpoint>;
207
+ /** Upgrade this sailbox's in-guest agent. */
208
+ upgrade(): Promise<UpgradeResult>;
209
+ }
210
+ //# sourceMappingURL=sailbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sailbox.d.ts","sourceRoot":"","sources":["../src/sailbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM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AG,OAAO,CAAC,IAAI,CAAC;IAI1C,uDAAuD;IACvD,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIhC,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI9C;;;uEAGmE;IAC7D,eAAe,CACnB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,QAAQ,CAAC;IAWpB,sEAAsE;IACtE,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIrD;;;;;;iBAMa;IACP,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAM5E,gEAAgE;IAC1D,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAKhC,oCAAoC;IAC9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B,qDAAqD;IAC/C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B,oDAAoD;IAC9C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAK7B;uEACmE;IAC7D,UAAU,CACd,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,iBAAiB,CAAC;IAM7B,6CAA6C;IACvC,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;CAKxC"}
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Sailbox = void 0;
4
+ const default_client_js_1 = require("./default-client.js");
5
+ const validate_js_1 = require("./validate.js");
6
+ const errors_js_1 = require("./errors.js");
7
+ const image_js_1 = require("./image.js");
8
+ /**
9
+ * A sandbox (sailbox): the primary object agent harnesses work with. Create one
10
+ * with {@link Sailbox.create}, run commands with {@link exec}, move files with
11
+ * {@link writeStream}/{@link readStream}, expose ports with {@link expose}, and
12
+ * manage its lifecycle. The statics use a default env-configured client unless
13
+ * you pass one.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { App, Sailbox } from "@sailresearch/sdk";
18
+ *
19
+ * const app = await App.find("example-app", { mintIfMissing: true });
20
+ * const box = await Sailbox.create({ app, name: "worker-1" });
21
+ * const proc = await box.exec(["bash", "-lc", "echo hello"]);
22
+ * console.log(await proc.stdout.text());
23
+ * await box.terminate();
24
+ * ```
25
+ */
26
+ class Sailbox {
27
+ #client;
28
+ #id;
29
+ #name;
30
+ #status;
31
+ #snapshot;
32
+ constructor(client, id, name, status, snapshot) {
33
+ this.#client = client;
34
+ this.#id = id;
35
+ this.#name = name;
36
+ this.#status = status;
37
+ this.#snapshot = snapshot;
38
+ }
39
+ static fromInfo(client, info) {
40
+ return new Sailbox(client, info.sailboxId, info.name, info.status, info);
41
+ }
42
+ static fromHandle(client, handle) {
43
+ return new Sailbox(client, handle.sailboxId, handle.name, handle.status);
44
+ }
45
+ /** Create a new sailbox. */
46
+ static async create(options) {
47
+ const { client: explicit, timeoutSeconds, image, imageBuildTimeoutSeconds, ssh, app, ingressPorts, volumes, ...rest } = options;
48
+ const client = explicit ?? (0, default_client_js_1.defaultClient)();
49
+ const request = {
50
+ ...rest,
51
+ appId: typeof app === "string" ? app : app.id,
52
+ // A bare number is the HTTP shorthand for a guest port.
53
+ ingressPorts: ingressPorts?.map((port) => typeof port === "number"
54
+ ? { guestPort: port, protocol: "http" }
55
+ : port),
56
+ volumeMounts: volumes === undefined
57
+ ? undefined
58
+ : Object.entries(volumes).map(([mountPath, volume]) => ({
59
+ mountPath,
60
+ volumeId: typeof volume === "string" ? volume : volume.id,
61
+ })),
62
+ };
63
+ // SSH access is org-scoped (the box trusts the org CA and members connect
64
+ // with signed certificates), so there is no per-key form. From untyped JS,
65
+ // a pasted key string or "false" is truthy and would silently enable org
66
+ // access, so reject any non-boolean loudly.
67
+ if (ssh !== undefined && typeof ssh !== "boolean") {
68
+ throw new errors_js_1.InvalidArgumentError("ssh must be a boolean; SSH access is org-scoped via your org's " +
69
+ "certificate authority, so there is no per-key argument");
70
+ }
71
+ // Preflight all options (resources, timeout, ingress ports, volume mounts)
72
+ // against the shared validators before the (possibly slow) image build.
73
+ (0, validate_js_1.validateCreateNumbers)(request);
74
+ (0, validate_js_1.validateCreateTimeout)(timeoutSeconds);
75
+ (0, validate_js_1.validateIngressPorts)(request.ingressPorts);
76
+ (0, validate_js_1.validateVolumeMounts)(request.volumeMounts);
77
+ // A custom image (Image builder or a non-builtin plain spec) is built
78
+ // before create, since the backend serves the content-addressed built
79
+ // image. A missing image and `timeoutSeconds` default in the client. The
80
+ // ssh orchestration (CA preflight, port-22 handling, enable after create)
81
+ // lives in the core.
82
+ if (ssh && image !== undefined && (0, image_js_1.willBuild)(image, client)) {
83
+ // SSH setup is org-scoped; check the CA now so an outage fails before
84
+ // the image build spends its timeout (the core preflights again at
85
+ // create, which is cheap and idempotent).
86
+ await client.orgSshCaPublicKey();
87
+ }
88
+ const resolvedImage = image !== undefined
89
+ ? await (0, image_js_1.resolveImageForCreate)(client, image, imageBuildTimeoutSeconds ?? 1800)
90
+ : undefined;
91
+ const handle = await client.createSailbox({ ...request, image: resolvedImage, ssh }, timeoutSeconds);
92
+ return Sailbox.fromHandle(client, handle);
93
+ }
94
+ /** Create a new sailbox from a checkpoint. */
95
+ static async fromCheckpoint(options) {
96
+ const { client: explicit, ...params } = options;
97
+ const client = explicit ?? (0, default_client_js_1.defaultClient)();
98
+ return Sailbox.fromHandle(client, await client.createFromCheckpoint(params));
99
+ }
100
+ /** Fetch an existing sailbox by id. */
101
+ static async get(sailboxId, options = {}) {
102
+ const client = options.client ?? (0, default_client_js_1.defaultClient)();
103
+ return Sailbox.fromInfo(client, await client.getSailbox(sailboxId));
104
+ }
105
+ /** List one page of sailboxes as {@link Sailbox} instances. */
106
+ static async list(params = {}, options = {}) {
107
+ return (await Sailbox.listPage(params, options)).items;
108
+ }
109
+ /** Like {@link list} but also returns the pagination envelope
110
+ * (`total`/`hasMore`) for paging through large result sets. */
111
+ static async listPage(params = {}, options = {}) {
112
+ const client = options.client ?? (0, default_client_js_1.defaultClient)();
113
+ const page = await client.listSailboxes(params);
114
+ return {
115
+ ...page,
116
+ items: page.items.map((info) => Sailbox.fromInfo(client, info)),
117
+ };
118
+ }
119
+ /** The sailbox's stable identifier. */
120
+ get sailboxId() {
121
+ return this.#id;
122
+ }
123
+ /** The sailbox name. */
124
+ get name() {
125
+ return this.#name;
126
+ }
127
+ /** The lifecycle status as of the call that produced this handle (updated
128
+ * by lifecycle calls on this instance). Use {@link Sailbox.get} for a fresh
129
+ * snapshot. */
130
+ get status() {
131
+ return this.#status;
132
+ }
133
+ // The monitoring snapshot from the fetch that produced this handle. All of
134
+ // these are `undefined` for a handle born from {@link Sailbox.create},
135
+ // whose response carries only the basics; use {@link Sailbox.get} for a
136
+ // fresh snapshot.
137
+ /** Identifier of the owning app. */
138
+ get appId() {
139
+ return this.#snapshot?.appId;
140
+ }
141
+ /** Name of the owning app. */
142
+ get appName() {
143
+ return this.#snapshot?.appName;
144
+ }
145
+ /** Identifier of the image the sailbox was created from. */
146
+ get imageId() {
147
+ return this.#snapshot?.imageId;
148
+ }
149
+ /** Configured memory, in MiB. */
150
+ get memoryMib() {
151
+ return this.#snapshot?.memoryMib;
152
+ }
153
+ /** Configured number of vCPUs. */
154
+ get vcpuCount() {
155
+ return this.#snapshot?.vcpuCount;
156
+ }
157
+ /** Configured state-disk size, in GiB. */
158
+ get stateDiskSizeGib() {
159
+ return this.#snapshot?.stateDiskSizeGib;
160
+ }
161
+ /** Requested CPU, in vCPUs. */
162
+ get cpuRequestedVcpu() {
163
+ return this.#snapshot?.cpuRequestedVcpu;
164
+ }
165
+ /** Current CPU usage, in vCPUs, as of the snapshot. */
166
+ get cpuUsedVcpu() {
167
+ return this.#snapshot?.cpuUsedVcpu;
168
+ }
169
+ /** Requested memory, in bytes. */
170
+ get memoryRequestedBytes() {
171
+ return this.#snapshot?.memoryRequestedBytes;
172
+ }
173
+ /** Current memory usage, in bytes, as of the snapshot. */
174
+ get memoryUsedBytes() {
175
+ return this.#snapshot?.memoryUsedBytes;
176
+ }
177
+ /** Requested disk, in bytes. */
178
+ get diskRequestedBytes() {
179
+ return this.#snapshot?.diskRequestedBytes;
180
+ }
181
+ /** Current disk usage, in bytes, as of the snapshot. */
182
+ get diskUsedBytes() {
183
+ return this.#snapshot?.diskUsedBytes;
184
+ }
185
+ /** CPU architecture (for example `arm64`). */
186
+ get architecture() {
187
+ return this.#snapshot?.architecture;
188
+ }
189
+ /** In-guest agent schema version the sailbox last booted with. */
190
+ get guestSchemaVersion() {
191
+ return this.#snapshot?.guestSchemaVersion ?? undefined;
192
+ }
193
+ /** Failure detail when the status is `failed`. */
194
+ get errorMessage() {
195
+ return this.#snapshot?.errorMessage ?? undefined;
196
+ }
197
+ /** Checkpoint generation counter as of the snapshot. */
198
+ get checkpointGeneration() {
199
+ return this.#snapshot?.checkpointGeneration;
200
+ }
201
+ /** When the current boot started (RFC 3339). */
202
+ get startedAt() {
203
+ const raw = this.#snapshot?.startedAt;
204
+ return raw ? new Date(raw) : undefined;
205
+ }
206
+ /** When the most recent checkpoint was taken. */
207
+ get lastCheckpointedAt() {
208
+ const raw = this.#snapshot?.lastCheckpointedAt;
209
+ return raw ? new Date(raw) : undefined;
210
+ }
211
+ /** When the sailbox was created. */
212
+ get createdAt() {
213
+ const raw = this.#snapshot?.createdAt;
214
+ return raw ? new Date(raw) : undefined;
215
+ }
216
+ /** When the sailbox last changed. */
217
+ get updatedAt() {
218
+ const raw = this.#snapshot?.updatedAt;
219
+ return raw ? new Date(raw) : undefined;
220
+ }
221
+ /** The underlying {@link Client}. */
222
+ get client() {
223
+ return this.#client;
224
+ }
225
+ // --- exec and files ---
226
+ /** Run a command and return a handle to the live process. A `string` command
227
+ * is run via `/bin/sh -lc`; a `string[]` is exec'd directly. `options` can set
228
+ * a working directory or detach the command (see {@link ExecOptions}). */
229
+ async exec(command, options) {
230
+ return this.#client.exec(this.#id, command, options);
231
+ }
232
+ /** Open an interactive pty session on this sailbox, bridged to the local
233
+ * terminal. With no `command`, runs a login shell; pass a command to run
234
+ * that under a pty instead (e.g. a REPL or an editor). Blocks until the
235
+ * remote process exits and resolves with its exit code. Requires an
236
+ * interactive terminal (stdin and stdout TTYs). */
237
+ shell(command, options) {
238
+ return this.#client.shell(this.#id, command, options);
239
+ }
240
+ /** Open a streaming read of a guest file. */
241
+ readStream(path) {
242
+ return this.#client.readStream(this.#id, path);
243
+ }
244
+ /** Open a streaming upload to a guest file. */
245
+ writeStream(path, options) {
246
+ return this.#client.writeStream(this.#id, path, options);
247
+ }
248
+ /** Read a guest file fully into memory (convenience over {@link readStream}). */
249
+ async read(path) {
250
+ return (await this.readStream(path)).bytes();
251
+ }
252
+ /** Write bytes (a `string` is encoded as UTF-8) to a guest file, creating it
253
+ * and any missing parent directories (convenience over {@link writeStream};
254
+ * pass `createParents: false` to opt out). */
255
+ async write(path, data, options) {
256
+ const writer = await this.writeStream(path, options);
257
+ await writer.write(data);
258
+ await writer.finish();
259
+ }
260
+ // --- listeners ---
261
+ /** Expose a guest port at runtime. The returned listener carries the
262
+ * resolved endpoint but an `"unspecified"` route status: the response
263
+ * confirms configuration, not reachability — {@link waitForListener}
264
+ * confirms the route is live. */
265
+ expose(guestPort, protocol = "http", allowlist = []) {
266
+ return this.#client.exposeListener(this.#id, guestPort, protocol, allowlist);
267
+ }
268
+ /** Remove a runtime ingress port. */
269
+ unexpose(guestPort) {
270
+ return this.#client.unexposeListener(this.#id, guestPort);
271
+ }
272
+ /** List this sailbox's listeners without waking it. */
273
+ listeners() {
274
+ return this.#client.listListeners(this.#id);
275
+ }
276
+ /** Fetch one listener by guest port without waking the box. */
277
+ listener(guestPort) {
278
+ return this.#client.getListener(this.#id, guestPort);
279
+ }
280
+ /** Poll until the listener on `guestPort` is reachable end to end — route
281
+ * status ACTIVE and its endpoint accepts (HTTP GET / raw-TCP connect) — and
282
+ * return it, or throw {@link TimeoutError} after `timeoutSeconds`. The wait loop
283
+ * and reachability probes run in the core, shared by every SDK. */
284
+ async waitForListener(guestPort, options = {}) {
285
+ const timeoutSeconds = options.timeoutSeconds ?? 60;
286
+ const pollIntervalSeconds = options.pollIntervalSeconds ?? 1;
287
+ return this.#client.waitForListener(this.#id, guestPort, timeoutSeconds, pollIntervalSeconds);
288
+ }
289
+ /** Ingress-identity headers for this sailbox, as a name→value map. */
290
+ ingressAuthHeaders() {
291
+ return this.#client.ingressAuthHeaders(this.#id);
292
+ }
293
+ /** Enable SSH on this sailbox: trust the org SSH CA, start `sshd`, and
294
+ * expose guest port 22 as TCP once the CA-only daemon owns it. Org members
295
+ * connect with a short-lived certificate (fetched by the `sail box ssh`
296
+ * CLI). Safe to re-run. With `wait` (the default), polls until the endpoint
297
+ * is reachable and returns it, throwing {@link TimeoutError} if it is not
298
+ * within `timeoutSeconds`; with `wait: false`, skips the probe and resolves
299
+ * `null`. */
300
+ async enableSsh(options = {}) {
301
+ return this.#client.enableSsh(this.#id, options);
302
+ }
303
+ // --- lifecycle ---
304
+ /** Terminate (delete) this sailbox (updates {@link status}). */
305
+ async terminate() {
306
+ await this.#client.terminateSailbox(this.#id);
307
+ this.#status = "terminated";
308
+ }
309
+ /** Pause this sailbox in memory. */
310
+ async pause() {
311
+ await this.#client.pauseSailbox(this.#id);
312
+ this.#status = "paused";
313
+ }
314
+ /** Sleep this sailbox to disk (wakes on traffic). */
315
+ async sleep() {
316
+ await this.#client.sleepSailbox(this.#id);
317
+ this.#status = "sleeping";
318
+ }
319
+ /** Resume this sailbox (updates {@link status}). */
320
+ async resume() {
321
+ const handle = await this.#client.resumeSailbox(this.#id);
322
+ this.#status = handle.status;
323
+ }
324
+ /** Take a checkpoint of this sailbox. The returned handle carries
325
+ * `expiresAt`, when it becomes eligible for garbage collection. */
326
+ async checkpoint(options = {}) {
327
+ const checkpoint = await this.#client.checkpointSailbox(this.#id, options);
328
+ this.#status = checkpoint.status;
329
+ return checkpoint;
330
+ }
331
+ /** Upgrade this sailbox's in-guest agent. */
332
+ async upgrade() {
333
+ const outcome = await this.#client.upgradeSailbox(this.#id);
334
+ this.#status = outcome.status;
335
+ return outcome;
336
+ }
337
+ }
338
+ exports.Sailbox = Sailbox;
339
+ //# sourceMappingURL=sailbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sailbox.js","sourceRoot":"","sources":["../src/sailbox.ts"],"names":[],"mappings":";;;AACA,2DAAoD;AACpD,+CAKuB;AACvB,2CAAiE;AAEjE,yCAAqE;AAsFrE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,OAAO;IAClB,OAAO,CAAS;IAChB,GAAG,CAAS;IACZ,KAAK,CAAS;IACd,OAAO,CAAgB;IACvB,SAAS,CAAe;IAExB,YACE,MAAc,EACd,EAAU,EACV,IAAY,EACZ,MAAqB,EACrB,QAAsB;QAEtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,MAAc,EAAE,IAAiB;QACvD,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;IAEO,MAAM,CAAC,UAAU,CAAC,MAAc,EAAE,MAAqB;QAC7D,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3E,CAAC;IAED,4BAA4B;IAC5B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAA6B;QAC/C,MAAM,EACJ,MAAM,EAAE,QAAQ,EAChB,cAAc,E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;QACT,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;IAC5B,CAAC;IAED,oDAAoD;IACpD,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED;uEACmE;IACnE,KAAK,CAAC,UAAU,CACd,UAA6B,EAAE;QAE/B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC3E,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC;QACjC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,6CAA6C;IAC7C,KAAK,CAAC,OAAO;QACX,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAnbD,0BAmbC"}
package/dist/ssh.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import type * as native from "./native.js";
2
+ /** The public TCP endpoint a sailbox's SSH listener is reachable at. */
3
+ export type SshEndpoint = native.SshEndpoint;
4
+ /** Options for enabling SSH on a sailbox. */
5
+ export interface EnableSshOptions {
6
+ /** Source CIDRs allowed to reach port 22, replacing any existing
7
+ * restriction. Left empty, a first enable opens the port to any source, and
8
+ * a re-enable leaves an existing restriction unchanged. */
9
+ allowlist?: string[];
10
+ /** Poll until the SSH route is ready (default true). */
11
+ wait?: boolean;
12
+ /** Give up waiting after this many seconds (default 60; `Infinity` waits
13
+ * indefinitely). */
14
+ timeoutSeconds?: number;
15
+ }
16
+ //# sourceMappingURL=ssh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssh.d.ts","sourceRoot":"","sources":["../src/ssh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAC;AAE3C,wEAAwE;AACxE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AAE7C,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAC/B;;+DAE2D;IAC3D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,wDAAwD;IACxD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;wBACoB;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
package/dist/ssh.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ssh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssh.js","sourceRoot":"","sources":["../src/ssh.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ /** Client configuration types, generated from the native core. */
2
+ import type * as native from "../native.js";
3
+ /** Deployment target for endpoint defaults. */
4
+ export type SailMode = "prod" | "dev" | "staging" | "local" | (string & {});
5
+ /** Explicit client configuration (an alternative to environment resolution). */
6
+ export interface ClientConfig extends Omit<native.ClientConfig, "mode"> {
7
+ /** Named environment selecting endpoint defaults. */
8
+ mode?: SailMode;
9
+ }
10
+ /** How a listener's URL is addressed under `ingressBase`. */
11
+ export type IngressScheme = "path" | "subdomain";
12
+ /** The config resolved from the environment and `~/.sail`. */
13
+ export interface ResolvedConfig extends Omit<native.ResolvedConfig, "ingressScheme"> {
14
+ ingressScheme: IngressScheme;
15
+ }
16
+ /** Options for statics that select which {@link Client} to use. */
17
+ export interface ClientOptions {
18
+ /** Use a specific client instead of the default (env) one. */
19
+ client?: import("../client.js").Client;
20
+ }
21
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAC;AAE5C,+CAA+C;AAC/C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE5E,gFAAgF;AAChF,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC;IACrE,qDAAqD;IACrD,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED,6DAA6D;AAC7D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,CAAC;AAEjD,8DAA8D;AAC9D,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,MAAM,CAAC,cAAc,EACrB,eAAe,CAChB;IACC,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,mEAAmE;AACnE,MAAM,WAAW,aAAa;IAC5B,8DAA8D;IAC9D,MAAM,CAAC,EAAE,OAAO,cAAc,EAAE,MAAM,CAAC;CACxC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /** Client configuration types, generated from the native core. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":";AAAA,kEAAkE"}