@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.
- package/LICENSE +201 -0
- package/README.md +126 -0
- package/dist/app.d.ts +23 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +40 -0
- package/dist/app.js.map +1 -0
- package/dist/client.d.ts +119 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +291 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +15 -0
- package/dist/config.js.map +1 -0
- package/dist/default-client.d.ts +13 -0
- package/dist/default-client.d.ts.map +1 -0
- package/dist/default-client.js +22 -0
- package/dist/default-client.js.map +1 -0
- package/dist/errors.d.ts +88 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +201 -0
- package/dist/errors.js.map +1 -0
- package/dist/exec-process.d.ts +56 -0
- package/dist/exec-process.d.ts.map +1 -0
- package/dist/exec-process.js +105 -0
- package/dist/exec-process.js.map +1 -0
- package/dist/exec-stream.d.ts +21 -0
- package/dist/exec-stream.d.ts.map +1 -0
- package/dist/exec-stream.js +47 -0
- package/dist/exec-stream.js.map +1 -0
- package/dist/file-stream.d.ts +41 -0
- package/dist/file-stream.d.ts.map +1 -0
- package/dist/file-stream.js +86 -0
- package/dist/file-stream.js.map +1 -0
- package/dist/image.d.ts +90 -0
- package/dist/image.d.ts.map +1 -0
- package/dist/image.js +193 -0
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/native.d.ts +10 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +24 -0
- package/dist/native.js.map +1 -0
- package/dist/sailbox.d.ts +210 -0
- package/dist/sailbox.d.ts.map +1 -0
- package/dist/sailbox.js +339 -0
- package/dist/sailbox.js.map +1 -0
- package/dist/ssh.d.ts +16 -0
- package/dist/ssh.d.ts.map +1 -0
- package/dist/ssh.js +3 -0
- package/dist/ssh.js.map +1 -0
- package/dist/types/config.d.ts +21 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +4 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/exec.d.ts +41 -0
- package/dist/types/exec.d.ts.map +1 -0
- package/dist/types/exec.js +4 -0
- package/dist/types/exec.js.map +1 -0
- package/dist/types/image.d.ts +50 -0
- package/dist/types/image.d.ts.map +1 -0
- package/dist/types/image.js +12 -0
- package/dist/types/image.js.map +1 -0
- package/dist/types/listener.d.ts +38 -0
- package/dist/types/listener.d.ts.map +1 -0
- package/dist/types/listener.js +21 -0
- package/dist/types/listener.js.map +1 -0
- package/dist/types/sailbox.d.ts +62 -0
- package/dist/types/sailbox.d.ts.map +1 -0
- package/dist/types/sailbox.js +19 -0
- package/dist/types/sailbox.js.map +1 -0
- package/dist/util.d.ts +3 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +10 -0
- package/dist/util.js.map +1 -0
- package/dist/validate.d.ts +35 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +87 -0
- package/dist/validate.js.map +1 -0
- package/dist/volume.d.ts +42 -0
- package/dist/volume.d.ts.map +1 -0
- package/dist/volume.js +72 -0
- package/dist/volume.js.map +1 -0
- package/native/index.d.ts +733 -0
- package/native/index.js +601 -0
- package/package.json +77 -0
package/dist/client.js
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Client = void 0;
|
|
4
|
+
const native_js_1 = require("./native.js");
|
|
5
|
+
const errors_js_1 = require("./errors.js");
|
|
6
|
+
const validate_js_1 = require("./validate.js");
|
|
7
|
+
const exec_process_js_1 = require("./exec-process.js");
|
|
8
|
+
const file_stream_js_1 = require("./file-stream.js");
|
|
9
|
+
const listener_js_1 = require("./types/listener.js");
|
|
10
|
+
const sailbox_js_1 = require("./types/sailbox.js");
|
|
11
|
+
/**
|
|
12
|
+
* A configured Sail client: the low-level surface over the native core (one
|
|
13
|
+
* config snapshot; env vars are read at construction). Every control-plane
|
|
14
|
+
* operation is here. The object-model API ({@link Sailbox}, {@link App},
|
|
15
|
+
* {@link Volume}) is built on top of it.
|
|
16
|
+
*
|
|
17
|
+
* Construct with {@link Client.fromEnv} or {@link Client.fromConfig}.
|
|
18
|
+
*/
|
|
19
|
+
class Client {
|
|
20
|
+
native;
|
|
21
|
+
constructor(native) {
|
|
22
|
+
this.native = native;
|
|
23
|
+
}
|
|
24
|
+
/** Build a client from the environment (`SAIL_API_KEY`, `SAIL_MODE`, ...). */
|
|
25
|
+
static fromEnv() {
|
|
26
|
+
return (0, errors_js_1.guardSync)(() => new Client(native_js_1.CoreClient.fromEnv()));
|
|
27
|
+
}
|
|
28
|
+
/** Build a client from an explicit {@link ClientConfig}. */
|
|
29
|
+
static fromConfig(config) {
|
|
30
|
+
return (0, errors_js_1.guardSync)(() => new Client(native_js_1.CoreClient.fromConfig(config)));
|
|
31
|
+
}
|
|
32
|
+
// --- lifecycle ---
|
|
33
|
+
/** Create a sailbox. `timeoutSeconds` bounds each create attempt (default
|
|
34
|
+
* 600s); pass `0` for no client-side timeout. Timed-out attempts are retried,
|
|
35
|
+
* reattaching to the same box, so when the overall budget is exhausted the
|
|
36
|
+
* box may still be coming up server-side: find or terminate it by `name`.
|
|
37
|
+
* `image` defaults to a plain Debian base. */
|
|
38
|
+
async createSailbox(req, timeoutSeconds = 600) {
|
|
39
|
+
(0, validate_js_1.validateCreateNumbers)(req);
|
|
40
|
+
(0, validate_js_1.validateCreateTimeout)(timeoutSeconds);
|
|
41
|
+
(0, validate_js_1.validateIngressPorts)(req.ingressPorts);
|
|
42
|
+
return (0, errors_js_1.guard)(() => this.native.createSailbox(req, timeoutSeconds));
|
|
43
|
+
}
|
|
44
|
+
/** Fetch one sailbox by id. */
|
|
45
|
+
getSailbox(sailboxId) {
|
|
46
|
+
return (0, errors_js_1.guard)(() => this.native.getSailbox(sailboxId));
|
|
47
|
+
}
|
|
48
|
+
/** List one page of sailboxes in the current org. */
|
|
49
|
+
async listSailboxes(params = {}) {
|
|
50
|
+
// Fractional values would truncate at the native i64 boundary and page
|
|
51
|
+
// differently than the caller wrote.
|
|
52
|
+
for (const [name, value, min] of [
|
|
53
|
+
["limit", params.limit, 1],
|
|
54
|
+
["offset", params.offset, 0],
|
|
55
|
+
["maxGuestSchemaVersion", params.maxGuestSchemaVersion, 0],
|
|
56
|
+
]) {
|
|
57
|
+
if (value !== undefined && (!Number.isInteger(value) || value < min)) {
|
|
58
|
+
throw new errors_js_1.InvalidArgumentError(`${name} must be an integer >= ${min}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return (0, errors_js_1.guard)(() => this.native.listSailboxes(params));
|
|
62
|
+
}
|
|
63
|
+
/** Terminate a sailbox (idempotent). */
|
|
64
|
+
terminateSailbox(sailboxId) {
|
|
65
|
+
return (0, errors_js_1.guard)(() => this.native.terminateSailbox(sailboxId));
|
|
66
|
+
}
|
|
67
|
+
/** Pause a sailbox in memory. */
|
|
68
|
+
pauseSailbox(sailboxId) {
|
|
69
|
+
return (0, errors_js_1.guard)(() => this.native.pauseSailbox(sailboxId));
|
|
70
|
+
}
|
|
71
|
+
/** Sleep a sailbox to disk (wakes on traffic). */
|
|
72
|
+
sleepSailbox(sailboxId) {
|
|
73
|
+
return (0, errors_js_1.guard)(() => this.native.sleepSailbox(sailboxId));
|
|
74
|
+
}
|
|
75
|
+
/** Resume a paused or sleeping sailbox. */
|
|
76
|
+
resumeSailbox(sailboxId) {
|
|
77
|
+
return (0, errors_js_1.guard)(() => this.native.resumeSailbox(sailboxId));
|
|
78
|
+
}
|
|
79
|
+
/** Take a checkpoint of a sailbox. `name` sets the handle's display name;
|
|
80
|
+
* `ttlSeconds`, when given, overrides the server's default retention
|
|
81
|
+
* window. */
|
|
82
|
+
async checkpointSailbox(sailboxId, options = {}) {
|
|
83
|
+
const { name, ttlSeconds } = options;
|
|
84
|
+
if (ttlSeconds !== undefined) {
|
|
85
|
+
// The core takes whole seconds (i64) and rejects <= 0; validate here so
|
|
86
|
+
// NaN or a fraction cannot cross the boundary.
|
|
87
|
+
if (!Number.isInteger(ttlSeconds) || ttlSeconds <= 0) {
|
|
88
|
+
throw new errors_js_1.InvalidArgumentError("ttlSeconds must be a positive integer");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return (0, errors_js_1.guard)(async () => (0, sailbox_js_1.toCheckpoint)(await this.native.checkpointSailbox(sailboxId, name, ttlSeconds)));
|
|
92
|
+
}
|
|
93
|
+
/** Create a new sailbox from a checkpoint. */
|
|
94
|
+
async createFromCheckpoint(params) {
|
|
95
|
+
// The core requires a positive whole-second timeout; check here so a
|
|
96
|
+
// non-finite value fails loudly instead of crossing the boundary as
|
|
97
|
+
// undefined and silently dropping the intended bound.
|
|
98
|
+
if (params.timeoutSeconds !== undefined &&
|
|
99
|
+
(!Number.isInteger(params.timeoutSeconds) || params.timeoutSeconds <= 0)) {
|
|
100
|
+
throw new errors_js_1.InvalidArgumentError("timeoutSeconds must be a positive integer");
|
|
101
|
+
}
|
|
102
|
+
return (0, errors_js_1.guard)(() => this.native.createFromCheckpoint(params));
|
|
103
|
+
}
|
|
104
|
+
/** Upgrade a sailbox's in-guest agent (now if running, else at next wake). */
|
|
105
|
+
upgradeSailbox(sailboxId) {
|
|
106
|
+
return (0, errors_js_1.guard)(() => this.native.upgradeSailbox(sailboxId));
|
|
107
|
+
}
|
|
108
|
+
// --- listeners ---
|
|
109
|
+
/** Expose a guest port at runtime (route status starts "unspecified"; the
|
|
110
|
+
* response confirms configuration, not reachability). */
|
|
111
|
+
async exposeListener(sailboxId, guestPort, protocol = "http", allowlist = []) {
|
|
112
|
+
// Integer/range, reserved ports, and allowlist rules come from the shared
|
|
113
|
+
// validator.
|
|
114
|
+
(0, validate_js_1.validateIngressPorts)([{ guestPort, protocol, allowlist }]);
|
|
115
|
+
return (0, errors_js_1.guard)(async () => (0, listener_js_1.toListener)(await this.native.exposeListener(sailboxId, guestPort, protocol, allowlist)));
|
|
116
|
+
}
|
|
117
|
+
/** Remove a runtime ingress port. */
|
|
118
|
+
async unexposeListener(sailboxId, guestPort) {
|
|
119
|
+
validateGuestPort(guestPort);
|
|
120
|
+
return (0, errors_js_1.guard)(() => this.native.unexposeListener(sailboxId, guestPort));
|
|
121
|
+
}
|
|
122
|
+
/** List a sailbox's listeners without waking it. */
|
|
123
|
+
listListeners(sailboxId) {
|
|
124
|
+
return (0, errors_js_1.guard)(async () => (await this.native.listListeners(sailboxId)).map(listener_js_1.toListener));
|
|
125
|
+
}
|
|
126
|
+
/** Fetch one listener by guest port without waking the box. */
|
|
127
|
+
async getListener(sailboxId, guestPort) {
|
|
128
|
+
validateGuestPort(guestPort);
|
|
129
|
+
return (0, errors_js_1.guard)(async () => (0, listener_js_1.toListener)(await this.native.getListener(sailboxId, guestPort)));
|
|
130
|
+
}
|
|
131
|
+
/** Block until the listener on `guestPort` is reachable end to end — route
|
|
132
|
+
* ACTIVE and its endpoint accepting (HTTP GET / raw-TCP connect) — and
|
|
133
|
+
* return it, throwing {@link TimeoutError} after `timeoutSeconds`. */
|
|
134
|
+
async waitForListener(sailboxId, guestPort, timeoutSeconds, pollIntervalSeconds) {
|
|
135
|
+
validateGuestPort(guestPort);
|
|
136
|
+
// NaN or non-positive values would cross the boundary as a zero wait
|
|
137
|
+
// (instant timeout) or a zero poll interval (a tight retry loop).
|
|
138
|
+
// `Infinity` waits indefinitely, like enableSsh.
|
|
139
|
+
if (Number.isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
140
|
+
throw new errors_js_1.InvalidArgumentError("timeoutSeconds must be a positive number");
|
|
141
|
+
}
|
|
142
|
+
if (!Number.isFinite(pollIntervalSeconds) || pollIntervalSeconds <= 0) {
|
|
143
|
+
throw new errors_js_1.InvalidArgumentError("pollIntervalSeconds must be a positive number");
|
|
144
|
+
}
|
|
145
|
+
return (0, errors_js_1.guard)(async () => (0, listener_js_1.toListener)(await this.native.waitForListener(sailboxId, guestPort, timeoutSeconds, pollIntervalSeconds)));
|
|
146
|
+
}
|
|
147
|
+
/** Ingress-identity headers for this sailbox, as a name→value map. */
|
|
148
|
+
ingressAuthHeaders(sailboxId) {
|
|
149
|
+
return (0, errors_js_1.guard)(() => this.native.ingressAuthHeaders(sailboxId));
|
|
150
|
+
}
|
|
151
|
+
// --- volumes ---
|
|
152
|
+
/** Look up (optionally minting) an NFS volume by name. */
|
|
153
|
+
getVolume(name, mintIfMissing = false) {
|
|
154
|
+
return (0, errors_js_1.guard)(() => this.native.getVolume(name, mintIfMissing));
|
|
155
|
+
}
|
|
156
|
+
/** List NFS volumes in the current org. */
|
|
157
|
+
async listVolumes(maxObjects) {
|
|
158
|
+
if (maxObjects !== undefined &&
|
|
159
|
+
(!Number.isInteger(maxObjects) || maxObjects < 1)) {
|
|
160
|
+
throw new errors_js_1.InvalidArgumentError("maxObjects must be a positive integer");
|
|
161
|
+
}
|
|
162
|
+
return (0, errors_js_1.guard)(() => this.native.listVolumes(maxObjects));
|
|
163
|
+
}
|
|
164
|
+
/** Delete a volume by id. Resolves `null` when `allowMissing` and it's gone. */
|
|
165
|
+
deleteVolume(volumeId, allowMissing = false) {
|
|
166
|
+
return (0, errors_js_1.guard)(() => this.native.deleteVolume(volumeId, allowMissing));
|
|
167
|
+
}
|
|
168
|
+
// --- apps (central API) ---
|
|
169
|
+
/** Find an app by name, optionally minting it. */
|
|
170
|
+
findApp(name, mintIfMissing = false) {
|
|
171
|
+
return (0, errors_js_1.guard)(() => this.native.findApp(name, mintIfMissing));
|
|
172
|
+
}
|
|
173
|
+
/** Every app the current org owns, newest first. */
|
|
174
|
+
listApps() {
|
|
175
|
+
return (0, errors_js_1.guard)(() => this.native.listApps());
|
|
176
|
+
}
|
|
177
|
+
// --- exec and files (wake the box) ---
|
|
178
|
+
/** Run a command in a sailbox and return a handle to the live process. A
|
|
179
|
+
* `string` command is run via `/bin/sh -lc`; a `string[]` is exec'd directly.
|
|
180
|
+
* `cwd`/`background` apply to string commands (see {@link ExecOptions}). */
|
|
181
|
+
async exec(sailboxId, command, options = {}) {
|
|
182
|
+
if (options.timeoutSeconds !== undefined &&
|
|
183
|
+
(!Number.isFinite(options.timeoutSeconds) || options.timeoutSeconds <= 0)) {
|
|
184
|
+
throw new errors_js_1.InvalidArgumentError("timeoutSeconds must be a positive number");
|
|
185
|
+
}
|
|
186
|
+
(0, validate_js_1.validateRetryBudget)(options.retryTimeoutSeconds);
|
|
187
|
+
// Fractional or negative pty dimensions would coerce at the native u32
|
|
188
|
+
// boundary; 0 means "use the default size".
|
|
189
|
+
for (const [name, value] of [
|
|
190
|
+
["cols", options.cols],
|
|
191
|
+
["rows", options.rows],
|
|
192
|
+
]) {
|
|
193
|
+
if (value !== undefined && (!Number.isInteger(value) || value < 0)) {
|
|
194
|
+
throw new errors_js_1.InvalidArgumentError(`${name} must be a non-negative integer`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Shell wrapping, quoting, and cwd/background validation live in the core.
|
|
198
|
+
return (0, errors_js_1.guard)(async () => new exec_process_js_1.ExecProcess(typeof command === "string"
|
|
199
|
+
? await this.native.execShell(sailboxId, command, options)
|
|
200
|
+
: await this.native.exec(sailboxId, command, options)));
|
|
201
|
+
}
|
|
202
|
+
/** Open an interactive pty session on a sailbox, bridged to the local
|
|
203
|
+
* terminal: raw keystrokes reach the remote process, output renders
|
|
204
|
+
* locally, and resizes propagate. Resolves with the remote process's exit
|
|
205
|
+
* code. Requires an interactive terminal (stdin and stdout TTYs). */
|
|
206
|
+
async shell(sailboxId, command, options = {}) {
|
|
207
|
+
if (options.timeoutSeconds !== undefined &&
|
|
208
|
+
(!Number.isFinite(options.timeoutSeconds) || options.timeoutSeconds <= 0)) {
|
|
209
|
+
throw new errors_js_1.InvalidArgumentError("timeoutSeconds must be a positive number");
|
|
210
|
+
}
|
|
211
|
+
return (0, errors_js_1.guard)(() => this.native.shell(sailboxId, command, options.shell, options.term, options.cwd, options.timeoutSeconds));
|
|
212
|
+
}
|
|
213
|
+
/** Open a streaming read of a guest file. */
|
|
214
|
+
readStream(sailboxId, path) {
|
|
215
|
+
return (0, errors_js_1.guard)(async () => new file_stream_js_1.FileStream(await this.native.readStream(sailboxId, path)));
|
|
216
|
+
}
|
|
217
|
+
/** Open a streaming upload to a guest file. */
|
|
218
|
+
async writeStream(sailboxId, path, options = {}) {
|
|
219
|
+
if (options.mode !== undefined &&
|
|
220
|
+
(!Number.isInteger(options.mode) ||
|
|
221
|
+
options.mode < 0 ||
|
|
222
|
+
options.mode > 0o777)) {
|
|
223
|
+
throw new errors_js_1.InvalidArgumentError("mode must be between 0 and 0o777");
|
|
224
|
+
}
|
|
225
|
+
return (0, errors_js_1.guard)(async () => new file_stream_js_1.FileWriter(await this.native.writeStream(sailboxId, path, options.createParents ?? true, options.mode)));
|
|
226
|
+
}
|
|
227
|
+
/** Whether a spec is a bare builtin base the backend ships prebuilt (no
|
|
228
|
+
* build needed). */
|
|
229
|
+
isBuiltinBaseSpec(spec) {
|
|
230
|
+
return (0, errors_js_1.guardSync)(() => this.native.isBuiltinBaseSpec(spec));
|
|
231
|
+
}
|
|
232
|
+
/** Resolve an image definition into a content-addressed {@link ImageSpec}:
|
|
233
|
+
* the core walks local directories (gitignore-style `ignore`), hashes every
|
|
234
|
+
* file, and uploads content the server does not already have. */
|
|
235
|
+
resolveImage(def) {
|
|
236
|
+
return (0, errors_js_1.guard)(async () =>
|
|
237
|
+
// Enum-ish spec fields cross as plain strings; the closed unions hold
|
|
238
|
+
// because the core emits only known values.
|
|
239
|
+
(await this.native.resolveImageDefinition(def)));
|
|
240
|
+
}
|
|
241
|
+
/** Resolve an image definition and build it to ready, returning the
|
|
242
|
+
* content-addressed {@link ImageSpec} to create sailboxes from. A bare
|
|
243
|
+
* builtin base skips the build; `timeoutSeconds` bounds the whole pipeline
|
|
244
|
+
* (hashing, uploads, and the build). */
|
|
245
|
+
async buildImageDefinition(def, timeoutSeconds) {
|
|
246
|
+
validateBuildTimeout(timeoutSeconds);
|
|
247
|
+
return (0, errors_js_1.guard)(async () => (await this.native.buildImageDefinition(def, timeoutSeconds)));
|
|
248
|
+
}
|
|
249
|
+
/** Build an already-resolved spec to ready (submit + poll), bounded by
|
|
250
|
+
* `timeoutSeconds`. */
|
|
251
|
+
async buildSpecToReady(spec, timeoutSeconds) {
|
|
252
|
+
validateBuildTimeout(timeoutSeconds);
|
|
253
|
+
return (0, errors_js_1.guard)(async () => (await this.native.buildSpecToReady(spec, timeoutSeconds)));
|
|
254
|
+
}
|
|
255
|
+
/** Enable SSH on a sailbox: trust the org SSH CA, start `sshd`, and expose
|
|
256
|
+
* guest port 22 as TCP once the CA-only daemon owns it. A non-empty
|
|
257
|
+
* `allowlist` restricts port 22 to those source CIDRs, replacing any
|
|
258
|
+
* existing restriction. With `wait` (the default), polls until the endpoint
|
|
259
|
+
* is reachable and returns it, throwing {@link TimeoutError} if it is not
|
|
260
|
+
* within `timeoutSeconds`; with `wait: false`, skips the probe and resolves
|
|
261
|
+
* `null`. */
|
|
262
|
+
async enableSsh(sailboxId, options = {}) {
|
|
263
|
+
// NaN/negative would cross the boundary clamped to a zero wait and time
|
|
264
|
+
// out instantly; `Infinity` deliberately waits indefinitely.
|
|
265
|
+
if (Number.isNaN(options.timeoutSeconds) ||
|
|
266
|
+
(options.timeoutSeconds ?? 0) < 0) {
|
|
267
|
+
throw new errors_js_1.InvalidArgumentError("timeoutSeconds must be a non-negative number");
|
|
268
|
+
}
|
|
269
|
+
return (0, errors_js_1.guard)(() => this.native.enableSsh(sailboxId, options.allowlist ?? [], options.wait ?? true, options.timeoutSeconds ?? 60));
|
|
270
|
+
}
|
|
271
|
+
/** Fetch (creating on first use) the org SSH certificate authority public key.
|
|
272
|
+
* Used to preflight SSH before a box is provisioned. */
|
|
273
|
+
orgSshCaPublicKey() {
|
|
274
|
+
return (0, errors_js_1.guard)(() => this.native.orgSshCaPublicKey());
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
exports.Client = Client;
|
|
278
|
+
/** A fractional port would silently truncate at the native u32 boundary and
|
|
279
|
+
* address a different listener. */
|
|
280
|
+
function validateGuestPort(guestPort) {
|
|
281
|
+
if (!Number.isInteger(guestPort) || guestPort < 1 || guestPort > 65535) {
|
|
282
|
+
throw new errors_js_1.InvalidArgumentError("guestPort must be an integer between 1 and 65535");
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/** An unbounded or non-positive image build "timeout" would wait forever. */
|
|
286
|
+
function validateBuildTimeout(timeoutSeconds) {
|
|
287
|
+
if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
288
|
+
throw new errors_js_1.InvalidArgumentError("image build timeout must be a positive number");
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AACxE,2CAAqE;AACrE,+CAKuB;AACvB,uDAAgD;AAChD,qDAA0D;AAQ1D,qDAI6B;AAC7B,mDAU4B;AAE5B;;;;;;;GAOG;AACH,MAAa,MAAM;IACoB;IAArC,YAAqC,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE3D,8EAA8E;IAC9E,MAAM,CAAC,OAAO;QACZ,OAAO,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,sBAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,4DAA4D;IAC5D,MAAM,CAAC,UAAU,CAAC,MAAoB;QACpC,OAAO,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,sBAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;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AA8C,CAC/C,CAAC;QACJ,CAAC;QACD,OAAO,IAAA,iBAAK,EAAC,GAAG,EAAE,CAChB,IAAI,CAAC,MAAM,CAAC,SAAS,CACnB,SAAS,EACT,OAAO,CAAC,SAAS,IAAI,EAAE,EACvB,OAAO,CAAC,IAAI,IAAI,IAAI,EACpB,OAAO,CAAC,cAAc,IAAI,EAAE,CAC7B,CACF,CAAC;IACJ,CAAC;IAED;4DACwD;IACxD,iBAAiB;QACf,OAAO,IAAA,iBAAK,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACtD,CAAC;CACF;AAhbD,wBAgbC;AAED;mCACmC;AACnC,SAAS,iBAAiB,CAAC,SAAiB;IAC1C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC,IAAI,SAAS,GAAG,KAAK,EAAE,CAAC;QACvE,MAAM,IAAI,gCAAoB,CAC5B,kDAAkD,CACnD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,SAAS,oBAAoB,CAAC,cAAsB;IAClD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,cAAc,IAAI,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,gCAAoB,CAC5B,+CAA+C,CAChD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "./types/config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the SDK config from the environment (`SAIL_API_KEY`, `SAIL_MODE`,
|
|
4
|
+
* `SAIL_API_URL`, `SAILBOX_API_URL`, ...) and `~/.sail`, without requiring an
|
|
5
|
+
* API key. The core is the single source of truth for endpoint/mode resolution.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveConfig(): ResolvedConfig;
|
|
8
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,cAAc,CAG9C"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveConfig = resolveConfig;
|
|
4
|
+
const native_js_1 = require("./native.js");
|
|
5
|
+
const errors_js_1 = require("./errors.js");
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the SDK config from the environment (`SAIL_API_KEY`, `SAIL_MODE`,
|
|
8
|
+
* `SAIL_API_URL`, `SAILBOX_API_URL`, ...) and `~/.sail`, without requiring an
|
|
9
|
+
* API key. The core is the single source of truth for endpoint/mode resolution.
|
|
10
|
+
*/
|
|
11
|
+
function resolveConfig() {
|
|
12
|
+
// The bridge emits exactly `path` or `subdomain`, so the closed union holds.
|
|
13
|
+
return (0, errors_js_1.guardSync)(() => (0, native_js_1.resolvedConfig)());
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AASA,sCAGC;AAZD,2CAAqE;AACrE,2CAAwC;AAGxC;;;;GAIG;AACH,SAAgB,aAAa;IAC3B,6EAA6E;IAC7E,OAAO,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,IAAA,0BAAoB,GAAoB,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client } from "./client.js";
|
|
2
|
+
/**
|
|
3
|
+
* The process-wide client used by the object-model statics ({@link Sailbox},
|
|
4
|
+
* {@link App}, {@link Volume}) when no explicit `client` is passed. Created
|
|
5
|
+
* lazily from the environment on first use.
|
|
6
|
+
*/
|
|
7
|
+
export declare function defaultClient(): Client;
|
|
8
|
+
/**
|
|
9
|
+
* Override (or clear, with `undefined`) the process-wide default client. Useful
|
|
10
|
+
* for tests or to point the object-model API at an explicitly configured client.
|
|
11
|
+
*/
|
|
12
|
+
export declare function setDefaultClient(client: Client | undefined): void;
|
|
13
|
+
//# sourceMappingURL=default-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-client.d.ts","sourceRoot":"","sources":["../src/default-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAEjE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultClient = defaultClient;
|
|
4
|
+
exports.setDefaultClient = setDefaultClient;
|
|
5
|
+
const client_js_1 = require("./client.js");
|
|
6
|
+
let cached;
|
|
7
|
+
/**
|
|
8
|
+
* The process-wide client used by the object-model statics ({@link Sailbox},
|
|
9
|
+
* {@link App}, {@link Volume}) when no explicit `client` is passed. Created
|
|
10
|
+
* lazily from the environment on first use.
|
|
11
|
+
*/
|
|
12
|
+
function defaultClient() {
|
|
13
|
+
return (cached ??= client_js_1.Client.fromEnv());
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Override (or clear, with `undefined`) the process-wide default client. Useful
|
|
17
|
+
* for tests or to point the object-model API at an explicitly configured client.
|
|
18
|
+
*/
|
|
19
|
+
function setDefaultClient(client) {
|
|
20
|
+
cached = client;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=default-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-client.js","sourceRoot":"","sources":["../src/default-client.ts"],"names":[],"mappings":";;AASA,sCAEC;AAMD,4CAEC;AAnBD,2CAAqC;AAErC,IAAI,MAA0B,CAAC;AAE/B;;;;GAIG;AACH,SAAgB,aAAa;IAC3B,OAAO,CAAC,MAAM,KAAK,kBAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,MAA0B;IACzD,MAAM,GAAG,MAAM,CAAC;AAClB,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error taxonomy. The native addon throws errors whose `message` is a JSON
|
|
3
|
+
* envelope `{ sailErrorCode, message }` produced by the Rust core's canonical
|
|
4
|
+
* `SailError`; {@link rethrow} maps that code to one of the classes below so
|
|
5
|
+
* consumers can `catch (e) { if (e instanceof SailError) ... }` or match a
|
|
6
|
+
* specific subclass. Every error the core and bridge raise carries this
|
|
7
|
+
* envelope and maps to a `SailError` subclass; a truly unexpected native error
|
|
8
|
+
* (outside the taxonomy) surfaces unchanged.
|
|
9
|
+
*/
|
|
10
|
+
/** Base class for every error surfaced by the SDK. */
|
|
11
|
+
export declare class SailError extends Error {
|
|
12
|
+
/** Stable, language-neutral error code from the core (e.g. `"NotFound"`). */
|
|
13
|
+
readonly code: string;
|
|
14
|
+
constructor(message: string, code?: string);
|
|
15
|
+
}
|
|
16
|
+
/** Invalid arguments or configuration (bad request, missing/invalid API key). */
|
|
17
|
+
export declare class InvalidArgumentError extends SailError {
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
20
|
+
/** An unexpected internal SDK/core failure. */
|
|
21
|
+
export declare class InternalError extends SailError {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
/** The sailbox, volume, or other resource does not exist (or is another org's). */
|
|
25
|
+
export declare class NotFoundError extends SailError {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
/** The credential is not permitted to perform the operation. */
|
|
29
|
+
export declare class PermissionDeniedError extends SailError {
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
32
|
+
/** A remote file path does not exist. */
|
|
33
|
+
export declare class FileNotFoundError extends SailError {
|
|
34
|
+
constructor(message: string);
|
|
35
|
+
}
|
|
36
|
+
/** A stream (e.g. exec stdin) was closed and can no longer be written. */
|
|
37
|
+
export declare class BrokenPipeError extends SailError {
|
|
38
|
+
constructor(message: string);
|
|
39
|
+
}
|
|
40
|
+
/** A request exceeded its timeout. */
|
|
41
|
+
export declare class TimeoutError extends SailError {
|
|
42
|
+
constructor(message: string);
|
|
43
|
+
}
|
|
44
|
+
/** A network/connection transport failure. */
|
|
45
|
+
export declare class TransportError extends SailError {
|
|
46
|
+
constructor(message: string);
|
|
47
|
+
}
|
|
48
|
+
/** A transient, retryable server-side API failure. */
|
|
49
|
+
export declare class ApiError extends SailError {
|
|
50
|
+
constructor(message: string);
|
|
51
|
+
}
|
|
52
|
+
/** A sailbox could not be created (provisioning failed). */
|
|
53
|
+
export declare class SailboxCreationError extends SailError {
|
|
54
|
+
constructor(message: string);
|
|
55
|
+
}
|
|
56
|
+
/** A custom image could not be built or its local content could not be uploaded. */
|
|
57
|
+
export declare class ImageBuildError extends SailError {
|
|
58
|
+
constructor(message: string);
|
|
59
|
+
}
|
|
60
|
+
/** Base class for failures during an exec. */
|
|
61
|
+
export declare class SailboxExecutionError extends SailError {
|
|
62
|
+
constructor(message: string, code?: string);
|
|
63
|
+
}
|
|
64
|
+
/** The sailbox was terminated while an exec was in flight. */
|
|
65
|
+
export declare class SailboxTerminatedError extends SailboxExecutionError {
|
|
66
|
+
constructor(message: string);
|
|
67
|
+
}
|
|
68
|
+
/** The exec request could not be found on the worker (e.g. after a move). */
|
|
69
|
+
export declare class SailboxExecRequestNotFoundError extends SailboxExecutionError {
|
|
70
|
+
constructor(message: string);
|
|
71
|
+
}
|
|
72
|
+
/** The hosting worker was lost while an exec was in flight. */
|
|
73
|
+
export declare class SailboxWorkerLostError extends SailboxExecutionError {
|
|
74
|
+
constructor(message: string);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Rethrow an error raised at the native boundary as the matching typed
|
|
78
|
+
* {@link SailError}. If it is not a recognized core error, the original is
|
|
79
|
+
* rethrown unchanged. Every SDK method funnels its native calls through this.
|
|
80
|
+
*/
|
|
81
|
+
export declare function rethrow(err: unknown): never;
|
|
82
|
+
/** Run an async native call, mapping any boundary error to a typed
|
|
83
|
+
* {@link SailError} via {@link rethrow}. The standard wrapper for a method whose
|
|
84
|
+
* body is a single native call. */
|
|
85
|
+
export declare function guard<T>(fn: () => Promise<T>): Promise<T>;
|
|
86
|
+
/** Synchronous {@link guard} for a native call that returns a value directly. */
|
|
87
|
+
export declare function guardSync<T>(fn: () => T): T;
|
|
88
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,sDAAsD;AACtD,qBAAa,SAAU,SAAQ,KAAK;IAClC,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,OAAO,EAAE,MAAM,EAAE,IAAI,SAAc;CAKhD;AAED,iFAAiF;AACjF,qBAAa,oBAAqB,SAAQ,SAAS;gBACrC,OAAO,EAAE,MAAM;CAG5B;AAED,+CAA+C;AAC/C,qBAAa,aAAc,SAAQ,SAAS;gBAC9B,OAAO,EAAE,MAAM;CAG5B;AAED,mFAAmF;AACnF,qBAAa,aAAc,SAAQ,SAAS;gBAC9B,OAAO,EAAE,MAAM;CAG5B;AAED,gEAAgE;AAChE,qBAAa,qBAAsB,SAAQ,SAAS;gBACtC,OAAO,EAAE,MAAM;CAG5B;AAED,yCAAyC;AACzC,qBAAa,iBAAkB,SAA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