withruntime 1.1.2 → 1.4.58
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 +5 -2
- package/dist/generated/agentSessions.d.ts +2 -2
- package/dist/generated/agentSessions.js +2 -2
- package/dist/generated/agents.d.ts +2 -2
- package/dist/generated/agents.js +1 -1
- package/dist/generated/apps.d.ts +8 -6
- package/dist/generated/apps.js +10 -6
- package/dist/generated/browsers.d.ts +8 -6
- package/dist/generated/browsers.js +10 -6
- package/dist/generated/builds.d.ts +8 -6
- package/dist/generated/builds.js +10 -6
- package/dist/generated/ci.d.ts +106 -6
- package/dist/generated/ci.js +14 -6
- package/dist/generated/containers.d.ts +8 -6
- package/dist/generated/containers.js +10 -6
- package/dist/generated/desktops.d.ts +8 -6
- package/dist/generated/desktops.js +10 -6
- package/dist/generated/dropins/e2b.d.ts +180 -0
- package/dist/generated/dropins/e2b.js +342 -0
- package/dist/generated/dropins/e2b_code_interpreter.d.ts +180 -0
- package/dist/generated/dropins/e2b_code_interpreter.js +342 -0
- package/dist/generated/dropins/modal.d.ts +195 -0
- package/dist/generated/dropins/modal.js +375 -0
- package/dist/generated/dropins/runtime.d.ts +74 -0
- package/dist/generated/dropins/runtime.js +180 -0
- package/dist/generated/dropins/vercel.d.ts +78 -0
- package/dist/generated/dropins/vercel.js +154 -0
- package/dist/generated/egressIps.d.ts +2 -2
- package/dist/generated/egressIps.js +2 -2
- package/dist/generated/functions.d.ts +8 -6
- package/dist/generated/functions.js +10 -6
- package/dist/generated/identities.d.ts +42 -4
- package/dist/generated/identities.js +60 -0
- package/dist/generated/images.d.ts +3 -0
- package/dist/generated/images.js +4 -0
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/jobs.d.ts +2 -2
- package/dist/generated/jobs.js +1 -1
- package/dist/generated/keys.d.ts +28 -0
- package/dist/generated/keys.js +4 -0
- package/dist/generated/notebooks.d.ts +8 -6
- package/dist/generated/notebooks.js +10 -6
- package/dist/generated/ports.d.ts +2 -0
- package/dist/generated/projects.d.ts +49 -7
- package/dist/generated/projects.js +72 -3
- package/dist/generated/roles.d.ts +43 -5
- package/dist/generated/roles.js +61 -0
- package/dist/generated/routes.js +1 -1
- package/dist/generated/runtime.d.ts +49 -3
- package/dist/generated/runtime.js +235 -26
- package/dist/generated/sandboxes.d.ts +33 -14
- package/dist/generated/sandboxes.js +10 -6
- package/dist/generated/sites.d.ts +8 -6
- package/dist/generated/sites.js +10 -6
- package/dist/generated/snapshots.d.ts +7 -2
- package/dist/generated/snapshots.js +6 -2
- package/dist/generated/usage.d.ts +9 -3
- package/dist/generated/volumes.d.ts +30 -11
- package/dist/generated/volumes.js +19 -6
- package/dist/generated/workspaces.d.ts +8 -6
- package/dist/generated/workspaces.js +10 -6
- package/dist/v2/cli.d.ts +29 -0
- package/dist/v2/cli.js +156 -7
- package/dist/v2/login.d.ts +4 -0
- package/dist/v2/login.js +1 -1
- package/dist/v2/mcp.d.ts +4 -2
- package/dist/v2/mcp.js +69 -12
- package/dist/v2/openapi.json +2656 -1375
- package/dist/v2/shims/base.d.ts +0 -3
- package/dist/v2/shims/base.js +2 -7
- package/dist/v2/shims/blaxel.js +2 -1
- package/dist/v2/shims/daytona.js +3 -2
- package/dist/v2/shims/morph.js +3 -1
- package/dist/v2/shims/vercel.js +2 -1
- package/package.json +3 -2
- package/dist/v2/shims/e2b.d.ts +0 -142
- package/dist/v2/shims/e2b.js +0 -238
|
@@ -9,9 +9,11 @@ export interface ClientOptions {
|
|
|
9
9
|
project?: string;
|
|
10
10
|
/** Defaults to RUNTIME_API_URL, then https://api.withruntime.com. */
|
|
11
11
|
baseUrl?: string;
|
|
12
|
-
/** Retries of a retryable error,
|
|
13
|
-
* safe to send again. Default 3. */
|
|
12
|
+
/** Retries of a retryable error, of a lost connection on a call that is
|
|
13
|
+
* safe to send again, or of any call none of which was sent. Default 3. */
|
|
14
14
|
maxRetries?: number;
|
|
15
|
+
/** Sends every request. With the runtime's own (the default), a call none of which was sent is sent again to the
|
|
16
|
+
* host's next address. */
|
|
15
17
|
fetch?: Fetch;
|
|
16
18
|
}
|
|
17
19
|
/** What the client sends a request with: `fetch`, or any function of its
|
|
@@ -22,13 +24,15 @@ export interface RequestOptions {
|
|
|
22
24
|
idempotencyKey?: string;
|
|
23
25
|
signal?: AbortSignal;
|
|
24
26
|
}
|
|
25
|
-
/** The error body the API sends: `{"error": {code, message, requestId, hint, retryable, param?, details?}}`. */
|
|
27
|
+
/** The error body the API sends: `{"error": {code, message, requestId, hint, retryable, docUrl, param?, details?}}`. */
|
|
26
28
|
export interface ErrorBody {
|
|
27
29
|
code: string;
|
|
28
30
|
message: string;
|
|
29
31
|
requestId: string;
|
|
30
32
|
hint?: string;
|
|
31
33
|
retryable?: boolean;
|
|
34
|
+
/** Where the code is explained: its section of the errors guide. */
|
|
35
|
+
docUrl?: string;
|
|
32
36
|
param?: string;
|
|
33
37
|
details?: Record<string, unknown>;
|
|
34
38
|
}
|
|
@@ -72,6 +76,8 @@ export declare class RuntimeApiError extends Error {
|
|
|
72
76
|
readonly status: number;
|
|
73
77
|
readonly requestId: string;
|
|
74
78
|
readonly hint: string | undefined;
|
|
79
|
+
/** Where the code is explained: its section of the errors guide. */
|
|
80
|
+
readonly docUrl: string | undefined;
|
|
75
81
|
/** The request's field it is about. */
|
|
76
82
|
readonly param: string | undefined;
|
|
77
83
|
readonly details: Record<string, unknown> | undefined;
|
|
@@ -137,7 +143,47 @@ export declare function toBytes(data: Uint8Array | string): Uint8Array;
|
|
|
137
143
|
/** A value of an open enum: one of `known`, else "unknown". */
|
|
138
144
|
export declare function openEnum<T extends string>(known: readonly T[], value: unknown): T | "unknown";
|
|
139
145
|
type Query = Record<string, string | number | boolean | readonly string[] | undefined>;
|
|
146
|
+
/** The audience a GitHub Actions job asks its OpenID Connect token for, to assume a key. */
|
|
147
|
+
export declare const GITHUB_AUDIENCE = "withruntime.com";
|
|
148
|
+
/** In a GitHub Actions job, the key `RUNTIME_KEY_ID` names, which the job assumes with its OpenID Connect token:
|
|
149
|
+
* no secret is stored anywhere. Undefined outside such a job. */
|
|
150
|
+
export declare function jobKeyId(): string | undefined;
|
|
151
|
+
/** Key `keyId` assumed for this GitHub Actions job (`POST /v2/keys/{id}:assume` with the job's token for
|
|
152
|
+
* GITHUB_AUDIENCE, which needs `permissions: id-token: write`): a key of an hour, assumed again near its end. */
|
|
153
|
+
export declare function assumeJobKey(keyId: string, options?: Pick<ClientOptions, "baseUrl" | "fetch">): Promise<string>;
|
|
154
|
+
/** How long a call waits for its answer when it runs for no time its caller names. */
|
|
155
|
+
export declare const CALL_TIMEOUT_MS = 60000;
|
|
156
|
+
/** The longest an answer may be silent, its head and then each byte of its body: one quiet longer is a connection
|
|
157
|
+
* that stopped answering (a kept link whose path was lost), dropped as a lost one is. A call answers within it, and a
|
|
158
|
+
* run's answer sends a space at least every few seconds while it runs, so only a dead link is this quiet (24 Nov
|
|
159
|
+
* 2026: `runtime mcp` waited 30 minutes on a kept connection that answered nothing, and every tool call with it). */
|
|
160
|
+
export declare const SILENT_MS = 60000;
|
|
161
|
+
/** An answer that was silent past its limit ([`SILENT_MS`]): its connection was dropped. */
|
|
162
|
+
export declare class SilentError extends Error {
|
|
163
|
+
readonly silentMs: number;
|
|
164
|
+
constructor(ms: number);
|
|
165
|
+
}
|
|
166
|
+
/** A deadline on one request's silence: `signal` aborts with a [`SilentError`] once `ms` pass with nothing heard.
|
|
167
|
+
* Its head and each chunk of its body are heard (`within`, `read`), whatever the fetch does with the signal. */
|
|
168
|
+
export declare class Silence {
|
|
169
|
+
#private;
|
|
170
|
+
constructor(ms?: number);
|
|
171
|
+
get signal(): AbortSignal;
|
|
172
|
+
/** Whether it was silent past its limit. */
|
|
173
|
+
get silent(): boolean;
|
|
174
|
+
heard(): void;
|
|
175
|
+
/** Its timer stopped: the answer was read, or given up. */
|
|
176
|
+
done(): void;
|
|
177
|
+
/** `p` (the answer's head), heard when it comes. */
|
|
178
|
+
within<T>(p: Promise<T>): Promise<T>;
|
|
179
|
+
/** `res`'s body, whole, each chunk heard. */
|
|
180
|
+
read(res: Response): Promise<Uint8Array>;
|
|
181
|
+
}
|
|
140
182
|
/** HTTP, retries and errors, shared by every product's client. */
|
|
183
|
+
/** Whether a request failed before any of it was sent: its name did not resolve, its connection or its TLS handshake
|
|
184
|
+
* failed. Node's fetch says the connector's own code (an error once the request is on its socket is UND_ERR_SOCKET);
|
|
185
|
+
* Bun's says ConnectionRefused for all three, FailedToOpenSocket for no socket, and ECONNRESET once sent. */
|
|
186
|
+
export declare function notSent(e: unknown): boolean;
|
|
141
187
|
export declare class Transport {
|
|
142
188
|
#private;
|
|
143
189
|
readonly baseUrl: string;
|
|
@@ -92,6 +92,8 @@ export class RuntimeApiError extends Error {
|
|
|
92
92
|
status;
|
|
93
93
|
requestId;
|
|
94
94
|
hint;
|
|
95
|
+
/** Where the code is explained: its section of the errors guide. */
|
|
96
|
+
docUrl;
|
|
95
97
|
/** The request's field it is about. */
|
|
96
98
|
param;
|
|
97
99
|
details;
|
|
@@ -104,6 +106,7 @@ export class RuntimeApiError extends Error {
|
|
|
104
106
|
this.status = status;
|
|
105
107
|
this.requestId = body.requestId;
|
|
106
108
|
this.hint = body.hint;
|
|
109
|
+
this.docUrl = body.docUrl;
|
|
107
110
|
this.param = body.param;
|
|
108
111
|
this.details = body.details;
|
|
109
112
|
this.retryAfterMs = retryAfterMs;
|
|
@@ -196,6 +199,62 @@ export function openEnum(known, value) {
|
|
|
196
199
|
return known.includes(value) ? value : "unknown";
|
|
197
200
|
}
|
|
198
201
|
const env = (name) => globalThis.process?.env?.[name];
|
|
202
|
+
/** The key `npx withruntime login` saved for the API at `baseUrl`
|
|
203
|
+
* (`$XDG_CONFIG_HOME/runtime/key-<origin>`, `~/.config` when unset), read only where a file system is (Node.js,
|
|
204
|
+
* Bun) and only for an API it may go to: over https, or over http to this computer. */
|
|
205
|
+
function savedKey(baseUrl) {
|
|
206
|
+
const p = globalThis.process;
|
|
207
|
+
try {
|
|
208
|
+
const url = new URL(baseUrl);
|
|
209
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)))
|
|
210
|
+
return undefined;
|
|
211
|
+
const fs = p?.getBuiltinModule?.("node:fs");
|
|
212
|
+
const os = p?.getBuiltinModule?.("node:os");
|
|
213
|
+
if (!fs || !os)
|
|
214
|
+
return undefined;
|
|
215
|
+
const root = env("XDG_CONFIG_HOME") || `${os.homedir()}/.config`;
|
|
216
|
+
return fs.readFileSync(`${root}/runtime/key-${encodeURIComponent(url.origin)}`, "utf8").trim() || undefined;
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/** The API a client calls: `baseUrl`, else RUNTIME_API_URL, else https://api.withruntime.com. */
|
|
223
|
+
const apiUrl = (baseUrl) => (baseUrl ?? env("RUNTIME_API_URL") ?? "https://api.withruntime.com").replace(/\/$/, "");
|
|
224
|
+
/** The audience a GitHub Actions job asks its OpenID Connect token for, to assume a key. */
|
|
225
|
+
export const GITHUB_AUDIENCE = "withruntime.com";
|
|
226
|
+
/** An assumed key is assumed again this long before its end. */
|
|
227
|
+
const ASSUMED_MARGIN_MS = 300000;
|
|
228
|
+
/** Keys assumed in this process, by API and key ID, each used until ASSUMED_MARGIN_MS before its end. */
|
|
229
|
+
const assumedKeys = new Map();
|
|
230
|
+
/** In a GitHub Actions job, the key `RUNTIME_KEY_ID` names, which the job assumes with its OpenID Connect token:
|
|
231
|
+
* no secret is stored anywhere. Undefined outside such a job. */
|
|
232
|
+
export function jobKeyId() {
|
|
233
|
+
const id = env("RUNTIME_KEY_ID");
|
|
234
|
+
return id && env("ACTIONS_ID_TOKEN_REQUEST_URL") ? id : undefined;
|
|
235
|
+
}
|
|
236
|
+
/** Key `keyId` assumed for this GitHub Actions job (`POST /v2/keys/{id}:assume` with the job's token for
|
|
237
|
+
* GITHUB_AUDIENCE, which needs `permissions: id-token: write`): a key of an hour, assumed again near its end. */
|
|
238
|
+
export async function assumeJobKey(keyId, options = {}) {
|
|
239
|
+
const at = `${apiUrl(options.baseUrl)}\n${keyId}`;
|
|
240
|
+
const held = assumedKeys.get(at);
|
|
241
|
+
if (held && held.until - ASSUMED_MARGIN_MS > Date.now())
|
|
242
|
+
return held.key;
|
|
243
|
+
const asking = env("ACTIONS_ID_TOKEN_REQUEST_TOKEN");
|
|
244
|
+
const tokenUrl = env("ACTIONS_ID_TOKEN_REQUEST_URL");
|
|
245
|
+
if (!asking || !tokenUrl)
|
|
246
|
+
throw new Error("RUNTIME_KEY_ID is set, but this job cannot ask GitHub for its token: give the workflow or job `permissions: id-token: write`.");
|
|
247
|
+
const url = new URL(tokenUrl);
|
|
248
|
+
url.searchParams.set("audience", GITHUB_AUDIENCE);
|
|
249
|
+
const asked = await (options.fetch ?? fetch)(url, { headers: { authorization: `bearer ${asking}` } });
|
|
250
|
+
const { value } = (asked.ok ? await asked.json().catch(() => ({})) : {});
|
|
251
|
+
if (!value)
|
|
252
|
+
throw new Error(`GitHub did not give this job its token (${asked.status}): check \`permissions: id-token: write\`.`);
|
|
253
|
+
const job = new Transport({ ...options, apiKey: value });
|
|
254
|
+
const made = await job.request("POST", `/v2/keys/${encodeURIComponent(keyId)}:assume`);
|
|
255
|
+
assumedKeys.set(at, { key: made.secret, until: made.expiresAt ? Date.parse(made.expiresAt) : Date.now() + 3_600_000 });
|
|
256
|
+
return made.secret;
|
|
257
|
+
}
|
|
199
258
|
/** Waits `ms`, or until `signal` aborts: its reason then. */
|
|
200
259
|
const sleep = async (ms, signal) => {
|
|
201
260
|
signal?.throwIfAborted();
|
|
@@ -214,29 +273,172 @@ const sleep = async (ms, signal) => {
|
|
|
214
273
|
* thrown at once, with its retryAfterMs, for the caller to schedule. */
|
|
215
274
|
const LONGEST_WAIT_MS = 60000;
|
|
216
275
|
/** How long a call waits for its answer when it runs for no time its caller names. */
|
|
217
|
-
const CALL_TIMEOUT_MS = 60000;
|
|
276
|
+
export const CALL_TIMEOUT_MS = 60000;
|
|
218
277
|
/** What a call waits past the time its caller lets it run: the answer's way back. */
|
|
219
278
|
const WAIT_MARGIN_MS = 10000;
|
|
220
279
|
/** The reason a run's answer was cut while the run goes on: followed on under the same key. */
|
|
221
280
|
const RUN_GOES_ON = "run_goes_on";
|
|
281
|
+
/** The longest an answer may be silent, its head and then each byte of its body: one quiet longer is a connection
|
|
282
|
+
* that stopped answering (a kept link whose path was lost), dropped as a lost one is. A call answers within it, and a
|
|
283
|
+
* run's answer sends a space at least every few seconds while it runs, so only a dead link is this quiet (24 Nov
|
|
284
|
+
* 2026: `runtime mcp` waited 30 minutes on a kept connection that answered nothing, and every tool call with it). */
|
|
285
|
+
export const SILENT_MS = CALL_TIMEOUT_MS;
|
|
286
|
+
/** An answer that was silent past its limit ([`SILENT_MS`]): its connection was dropped. */
|
|
287
|
+
export class SilentError extends Error {
|
|
288
|
+
silentMs;
|
|
289
|
+
constructor(ms) {
|
|
290
|
+
super(`The API sent nothing for ${ms / 1000} s, so its connection was dropped.`);
|
|
291
|
+
this.name = "SilentError";
|
|
292
|
+
this.silentMs = ms;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/** A deadline on one request's silence: `signal` aborts with a [`SilentError`] once `ms` pass with nothing heard.
|
|
296
|
+
* Its head and each chunk of its body are heard (`within`, `read`), whatever the fetch does with the signal. */
|
|
297
|
+
export class Silence {
|
|
298
|
+
#abort = new AbortController();
|
|
299
|
+
#ms;
|
|
300
|
+
#timer;
|
|
301
|
+
#ended;
|
|
302
|
+
constructor(ms = SILENT_MS) {
|
|
303
|
+
this.#ms = ms;
|
|
304
|
+
this.#ended = new Promise((_, reject) => {
|
|
305
|
+
this.#abort.signal.addEventListener("abort", () => reject(this.#abort.signal.reason), { once: true });
|
|
306
|
+
});
|
|
307
|
+
this.#ended.catch(() => undefined);
|
|
308
|
+
this.heard();
|
|
309
|
+
}
|
|
310
|
+
get signal() {
|
|
311
|
+
return this.#abort.signal;
|
|
312
|
+
}
|
|
313
|
+
/** Whether it was silent past its limit. */
|
|
314
|
+
get silent() {
|
|
315
|
+
return this.#abort.signal.aborted;
|
|
316
|
+
}
|
|
317
|
+
heard() {
|
|
318
|
+
clearTimeout(this.#timer);
|
|
319
|
+
if (!this.silent)
|
|
320
|
+
this.#timer = setTimeout(() => this.#abort.abort(new SilentError(this.#ms)), this.#ms);
|
|
321
|
+
}
|
|
322
|
+
/** Its timer stopped: the answer was read, or given up. */
|
|
323
|
+
done() {
|
|
324
|
+
clearTimeout(this.#timer);
|
|
325
|
+
}
|
|
326
|
+
/** `p` (the answer's head), heard when it comes. */
|
|
327
|
+
async within(p) {
|
|
328
|
+
const v = await Promise.race([p, this.#ended]);
|
|
329
|
+
this.heard();
|
|
330
|
+
return v;
|
|
331
|
+
}
|
|
332
|
+
/** `res`'s body, whole, each chunk heard. */
|
|
333
|
+
async read(res) {
|
|
334
|
+
if (!res.body)
|
|
335
|
+
return new Uint8Array();
|
|
336
|
+
const reader = res.body.getReader();
|
|
337
|
+
const parts = [];
|
|
338
|
+
let size = 0;
|
|
339
|
+
try {
|
|
340
|
+
for (;;) {
|
|
341
|
+
const { done, value } = await Promise.race([reader.read(), this.#ended]);
|
|
342
|
+
if (done)
|
|
343
|
+
break;
|
|
344
|
+
this.heard();
|
|
345
|
+
parts.push(value);
|
|
346
|
+
size += value.length;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
catch (e) {
|
|
350
|
+
void reader.cancel(e).catch(() => undefined);
|
|
351
|
+
throw e;
|
|
352
|
+
}
|
|
353
|
+
const all = new Uint8Array(size);
|
|
354
|
+
let at = 0;
|
|
355
|
+
for (const p of parts) {
|
|
356
|
+
all.set(p, at);
|
|
357
|
+
at += p.length;
|
|
358
|
+
}
|
|
359
|
+
return all;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
222
362
|
/** Retry-After in milliseconds: its seconds, when it names a number. */
|
|
223
363
|
function retryAfter(res) {
|
|
224
364
|
const s = Number(res.headers.get("retry-after") ?? "x");
|
|
225
365
|
return Number.isFinite(s) && s >= 0 ? s * 1000 : undefined;
|
|
226
366
|
}
|
|
227
367
|
/** HTTP, retries and errors, shared by every product's client. */
|
|
368
|
+
/** Whether a request failed before any of it was sent: its name did not resolve, its connection or its TLS handshake
|
|
369
|
+
* failed. Node's fetch says the connector's own code (an error once the request is on its socket is UND_ERR_SOCKET);
|
|
370
|
+
* Bun's says ConnectionRefused for all three, FailedToOpenSocket for no socket, and ECONNRESET once sent. */
|
|
371
|
+
export function notSent(e) {
|
|
372
|
+
const c = e?.cause?.code ?? e?.code;
|
|
373
|
+
return typeof c === "string" && (NOT_SENT.includes(c) || c.startsWith("ERR_SSL_"));
|
|
374
|
+
}
|
|
375
|
+
const NOT_SENT = ["ECONNREFUSED", "ENOTFOUND", "EAI_AGAIN", "EHOSTUNREACH", "ENETUNREACH", "UND_ERR_CONNECT_TIMEOUT", "ConnectionRefused", "FailedToOpenSocket"];
|
|
376
|
+
/** A proxy's settings: with any, every request goes as the fetch sends it, never to an address of ours. */
|
|
377
|
+
const PROXIES = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"];
|
|
378
|
+
/** Where a call goes next after an attempt none of which was sent: the host's addresses each in turn, so an address
|
|
379
|
+
* that refuses (a server whose router has no certificate: 2 Dec 2026, one of api.withruntime.com's three for 3 min
|
|
380
|
+
* 25 s, while a resolver's cache kept handing it out first) is passed over. Only with the runtime's own fetch, over
|
|
381
|
+
* https, with no proxy: Bun's names the host in Host, which its TLS checks the certificate against, port and all (so
|
|
382
|
+
* only on https's own port); Node's in the TLS name of its own dispatcher when that is a plain Agent (never a proxy's
|
|
383
|
+
* or a mock's). Elsewhere, none. */
|
|
384
|
+
class Elsewhere {
|
|
385
|
+
#url;
|
|
386
|
+
#left;
|
|
387
|
+
constructor(url) {
|
|
388
|
+
this.#url = url;
|
|
389
|
+
}
|
|
390
|
+
/** The request to `url` sent to the next address not yet tried, or undefined when there is none. */
|
|
391
|
+
async next() {
|
|
392
|
+
const p = globalThis.process;
|
|
393
|
+
const bun = globalThis.Bun !== undefined;
|
|
394
|
+
const agent = globalThis[Symbol.for("undici.globalDispatcher.1")];
|
|
395
|
+
const node = !bun && agent?.constructor?.name === "Agent" && typeof agent.dispatch === "function";
|
|
396
|
+
if (this.#url.protocol !== "https:" || (bun && this.#url.port !== "") || (!bun && !node) || PROXIES.some((v) => env(v)))
|
|
397
|
+
return undefined;
|
|
398
|
+
const dns = p?.getBuiltinModule?.("node:dns");
|
|
399
|
+
if (!dns)
|
|
400
|
+
return undefined;
|
|
401
|
+
this.#left ??= dns.promises.lookup(this.#url.hostname, { all: true }).then((as) => as.map((a) => a.address), () => []);
|
|
402
|
+
const ip = (await this.#left).shift();
|
|
403
|
+
if (ip === undefined || ip === this.#url.hostname)
|
|
404
|
+
return undefined;
|
|
405
|
+
const url = new URL(this.#url);
|
|
406
|
+
url.hostname = ip.includes(":") ? `[${ip}]` : ip;
|
|
407
|
+
if (bun)
|
|
408
|
+
return { url, host: this.#url.host };
|
|
409
|
+
const host = this.#url.host;
|
|
410
|
+
const servername = this.#url.hostname;
|
|
411
|
+
return {
|
|
412
|
+
url,
|
|
413
|
+
dispatcher: {
|
|
414
|
+
dispatch(opts, handler) {
|
|
415
|
+
const h = opts.headers;
|
|
416
|
+
const headers = Array.isArray(h) ? ["host", host, ...h] : { host, ...h };
|
|
417
|
+
return agent.dispatch({ ...opts, servername, headers }, handler);
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
}
|
|
228
423
|
export class Transport {
|
|
229
424
|
baseUrl;
|
|
230
425
|
#apiKey;
|
|
426
|
+
/** In a GitHub Actions job with RUNTIME_KEY_ID set: the key assumed at the first call and again near its end. */
|
|
427
|
+
#keyId;
|
|
231
428
|
#project;
|
|
232
429
|
#maxRetries;
|
|
233
430
|
#fetch;
|
|
431
|
+
/** The runtime's own fetch sends, never one the caller gave. */
|
|
432
|
+
#ownFetch;
|
|
234
433
|
constructor(options = {}) {
|
|
235
|
-
this.baseUrl = (options.baseUrl
|
|
236
|
-
|
|
434
|
+
this.baseUrl = apiUrl(options.baseUrl);
|
|
435
|
+
const given = options.apiKey ?? env("RUNTIME_API_KEY");
|
|
436
|
+
this.#keyId = given === undefined || given === "" ? jobKeyId() : undefined;
|
|
437
|
+
this.#apiKey = given || (this.#keyId ? undefined : savedKey(this.baseUrl));
|
|
237
438
|
this.#project = options.project ?? env("RUNTIME_PROJECT");
|
|
238
439
|
this.#maxRetries = options.maxRetries ?? 3;
|
|
239
440
|
this.#fetch = options.fetch ?? fetch;
|
|
441
|
+
this.#ownFetch = options.fetch === undefined;
|
|
240
442
|
}
|
|
241
443
|
async request(method, path, init = {}) {
|
|
242
444
|
// A query also takes the request options, so a verb that gains its first query field keeps the call it had
|
|
@@ -259,7 +461,10 @@ export class Transport {
|
|
|
259
461
|
const headers = {
|
|
260
462
|
accept: init.raw ? "application/octet-stream" : "application/json",
|
|
261
463
|
"runtime-version": API_VERSION,
|
|
464
|
+
"x-runtime-client": "ts",
|
|
262
465
|
};
|
|
466
|
+
if (this.#keyId)
|
|
467
|
+
this.#apiKey = await assumeJobKey(this.#keyId, { baseUrl: this.baseUrl, fetch: this.#fetch });
|
|
263
468
|
// A malformed key pair's secret, or one with no project, is refused here.
|
|
264
469
|
if (this.#apiKey)
|
|
265
470
|
signingKeyFor(this.#apiKey, this.#project);
|
|
@@ -274,9 +479,14 @@ export class Transport {
|
|
|
274
479
|
body = JSON.stringify(init.body);
|
|
275
480
|
headers["content-type"] = "application/json";
|
|
276
481
|
}
|
|
482
|
+
const elsewhere = this.#ownFetch ? new Elsewhere(url) : undefined;
|
|
483
|
+
let to;
|
|
277
484
|
for (let attempt = 0;; attempt++) {
|
|
278
485
|
const backoff = Math.min(2000, 100 * 2 ** attempt);
|
|
279
486
|
let res;
|
|
487
|
+
let text;
|
|
488
|
+
let bytes;
|
|
489
|
+
const quiet = new Silence();
|
|
280
490
|
try {
|
|
281
491
|
// Each attempt authorized anew: a key pair signs it, as the server
|
|
282
492
|
// takes a nonce once.
|
|
@@ -290,37 +500,36 @@ export class Transport {
|
|
|
290
500
|
})
|
|
291
501
|
: {};
|
|
292
502
|
const timeout = timeoutMs === undefined ? undefined : AbortSignal.timeout(timeoutMs);
|
|
293
|
-
const signals = [signal, timeout].filter((s) => s !== undefined);
|
|
294
|
-
res = await this.#fetch(url, {
|
|
503
|
+
const signals = [signal, timeout, quiet.signal].filter((s) => s !== undefined);
|
|
504
|
+
res = await quiet.within(this.#fetch(to?.url ?? url, {
|
|
295
505
|
method,
|
|
296
|
-
headers: { ...headers, ...auth },
|
|
506
|
+
headers: { ...headers, ...auth, ...(to?.host ? { host: to.host } : {}) },
|
|
297
507
|
body: body,
|
|
298
|
-
signal:
|
|
299
|
-
|
|
508
|
+
signal: AbortSignal.any(signals),
|
|
509
|
+
...(to?.dispatcher ? { dispatcher: to.dispatcher } : {}),
|
|
510
|
+
}));
|
|
511
|
+
const all = await quiet.read(res);
|
|
512
|
+
bytes = res.ok && init.raw ? all : undefined;
|
|
513
|
+
text = bytes === undefined ? new TextDecoder().decode(all) : "";
|
|
300
514
|
}
|
|
301
515
|
catch (e) {
|
|
302
|
-
// A lost connection or a
|
|
303
|
-
// only when the verb is safe to (it reads, or dedupes)
|
|
304
|
-
|
|
305
|
-
|
|
516
|
+
// A lost connection, a timeout or a silence (its connection dropped), before its head or after it: the call
|
|
517
|
+
// may have run, so it is sent again only when the verb is safe to (it reads, or dedupes), or when none of it
|
|
518
|
+
// was sent: then to an address not yet tried, at once and spending no retry, while there is one (each is
|
|
519
|
+
// tried once a call, so a call makes at most its retries and its host's addresses more attempts).
|
|
520
|
+
const unsent = notSent(e);
|
|
521
|
+
if ((init.idempotent || unsent) && attempt < this.#maxRetries && !signal?.aborted) {
|
|
522
|
+
to = unsent ? await elsewhere?.next() : undefined;
|
|
523
|
+
if (to)
|
|
524
|
+
attempt--;
|
|
525
|
+
else
|
|
526
|
+
await sleep(backoff, signal);
|
|
306
527
|
continue;
|
|
307
528
|
}
|
|
308
529
|
throw e;
|
|
309
530
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
try {
|
|
313
|
-
if (res.ok && init.raw)
|
|
314
|
-
bytes = new Uint8Array(await res.arrayBuffer());
|
|
315
|
-
text = bytes === undefined ? await res.text() : "";
|
|
316
|
-
}
|
|
317
|
-
catch (e) {
|
|
318
|
-
// Cut after its head: a lost connection, sent again as one is.
|
|
319
|
-
if (init.idempotent && attempt < this.#maxRetries && !signal?.aborted) {
|
|
320
|
-
await sleep(backoff, signal);
|
|
321
|
-
continue;
|
|
322
|
-
}
|
|
323
|
-
throw e;
|
|
531
|
+
finally {
|
|
532
|
+
quiet.done();
|
|
324
533
|
}
|
|
325
534
|
if (bytes !== undefined)
|
|
326
535
|
return bytes;
|
|
@@ -3,7 +3,7 @@ import { Paginated, Transport, Stream } from "./runtime.js";
|
|
|
3
3
|
import { type Preview, type PreviewCreate, Previews } from "./previews.js";
|
|
4
4
|
/** A command a machine starts at every fresh boot. */
|
|
5
5
|
export interface MachineStart {
|
|
6
|
-
/** The command: text, run by `bash -lc
|
|
6
|
+
/** The command: text, run by `bash -lc` (`sh -lc` in an image without bash), or the program and its arguments as a list, run without a shell. */
|
|
7
7
|
cmd: string | string[];
|
|
8
8
|
/** The directory it runs in; the user's home when omitted. */
|
|
9
9
|
cwd?: string;
|
|
@@ -25,7 +25,7 @@ export interface VolumeMount {
|
|
|
25
25
|
}
|
|
26
26
|
/** A command a machine runs once it starts: when it ends, the machine stops. */
|
|
27
27
|
export interface SandboxRun {
|
|
28
|
-
/** The command: text, run by `bash -lc
|
|
28
|
+
/** The command: text, run by `bash -lc` (`sh -lc` in an image without bash), or the program and its arguments as a list, run without a shell. */
|
|
29
29
|
cmd: string | string[];
|
|
30
30
|
/** The directory it runs in; the user's home when omitted. */
|
|
31
31
|
cwd?: string;
|
|
@@ -43,7 +43,7 @@ export interface NetworkRules {
|
|
|
43
43
|
}
|
|
44
44
|
/** A machine's settings: what a create sets on it. */
|
|
45
45
|
export interface SandboxSettings {
|
|
46
|
-
/** Its vCPUs; its product's default when omitted. At least
|
|
46
|
+
/** Its vCPUs, at least every plan's least (a smaller number is taken as it); its product's default when omitted. At least 2. */
|
|
47
47
|
vcpu?: number;
|
|
48
48
|
/** Its memory in GB (1 GB is 1,024 MiB); a fraction is taken to the MiB (`1.5`). Its product's default when omitted. At least 1. */
|
|
49
49
|
memoryGB?: number;
|
|
@@ -51,7 +51,7 @@ export interface SandboxSettings {
|
|
|
51
51
|
diskGB?: number;
|
|
52
52
|
/** The image it boots, by name (its newest version), `name:version` or ID; Runtime's default image when omitted. */
|
|
53
53
|
image?: string;
|
|
54
|
-
/** The secrets it may get, by name, at most 64: only those of them whose scope admits it; [] none; every one whose scope admits it when omitted. A name with no secret yet takes effect once that secret is created.
|
|
54
|
+
/** The secrets it may get, by name, at most 64: only those of them whose scope admits it; [] none; every one whose scope admits it when omitted. A name with no secret yet takes effect once that secret is created. An update changes it; a fork or a copy of a snapshot keeps it. At most 64 items. */
|
|
55
55
|
secrets?: string[];
|
|
56
56
|
/** The command it starts at every fresh boot and keeps running, as a service: a web server, a runner, a desktop. A wake with its memory kept does not start it again. Its image's when omitted. */
|
|
57
57
|
start?: MachineStart;
|
|
@@ -86,6 +86,8 @@ export interface SandboxCreate extends SandboxSettings {
|
|
|
86
86
|
autoWake?: boolean;
|
|
87
87
|
/** Seconds until Runtime deletes it, as its delete does: final at once, its memory and disk gone and no longer billed; it can't be undone. 0 or omitted: kept until deleted. Its owner renews it with update; a copy, snapshot or image made from it sets its own. At least 0. At most 315360000. */
|
|
88
88
|
deleteAfterSeconds?: number;
|
|
89
|
+
/** Text files to write in it before it answers, each path to its text: absolute, or under its code's folder (`/app` for an app or a function, `/site` for a site, `/workspace` for the rest); at most 256 files, and its request at most 4 MiB. An app's or a function's server is then started again, once, on them, and it answers once its port serves again, or 409 `start_failed` when it does not within 60 seconds. Binary files and big trees go by files.write and uploadFolder. */
|
|
90
|
+
files?: Record<string, string>;
|
|
89
91
|
/** Whether its delete is refused (409 `delete_protected`) until an update turns this off; false when omitted. Not with `deleteAfterSeconds`. While true, its time limit pauses it instead of deleting it; only its organization's close deletes it. A copy, snapshot or image made from it sets its own. */
|
|
90
92
|
deleteProtection?: boolean;
|
|
91
93
|
}
|
|
@@ -128,6 +130,8 @@ export interface SandboxInfo extends SandboxSettings {
|
|
|
128
130
|
pausedAt?: string;
|
|
129
131
|
/** A create's answer alone, for a start with a ready check: how its wait went. */
|
|
130
132
|
ready?: MachineReady;
|
|
133
|
+
/** For a machine that serves a port of its own (an app, a site or a function on 8080, a container on its image's, a notebook on 8888, a workspace on 8080, a desktop on 6080, a browser's DevTools on 9222): a link that opens it, answered by its create, get and update, none for a key that may not share its ports. It works for 10 minutes; a browser that opens it is given a cookie for that address for a day and sent on to the address without it, so no history keeps a link that still opens it. Another port is shared with previews.create. */
|
|
134
|
+
url?: string;
|
|
131
135
|
/** When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted. */
|
|
132
136
|
deleteAt?: string;
|
|
133
137
|
/** Whether its delete is refused (409 `delete_protected`) until an update turns this off. */
|
|
@@ -142,7 +146,7 @@ export interface Terminal {
|
|
|
142
146
|
}
|
|
143
147
|
/** A command to run: to its end, or started and answered at once (`wait: false`). */
|
|
144
148
|
export interface ExecRequest {
|
|
145
|
-
/** The command: text, run by `bash -lc` (`"npm test"`), or a list, the program and its arguments run without a shell (`["npm", "test"]`). */
|
|
149
|
+
/** The command: text, run by `bash -lc` (`sh -lc` in an image without bash; `"npm test"`), or a list, the program and its arguments run without a shell (`["npm", "test"]`). */
|
|
146
150
|
cmd: string | string[];
|
|
147
151
|
/** The directory it runs in; the user's home when omitted. */
|
|
148
152
|
cwd?: string;
|
|
@@ -529,7 +533,7 @@ export interface MetricsBase {
|
|
|
529
533
|
memoryLimitBytes: number;
|
|
530
534
|
/** Its disk, in bytes. */
|
|
531
535
|
diskLimitBytes: number;
|
|
532
|
-
/** The reading taken now; none when it is not running or
|
|
536
|
+
/** The reading taken now, or where its host takes none on asking, its newest measured minute of the last 3 minutes; none when it is not running, or has no such minute (made or woken within about a minute). */
|
|
533
537
|
latest?: MetricPoint;
|
|
534
538
|
/** The window's steps, oldest first, each averaged over the time the machine ran in it. Steps in which it did not run are omitted. A minute appears about a minute after it ends; `latest` holds the current reading. */
|
|
535
539
|
points: MetricPoint[];
|
|
@@ -553,7 +557,7 @@ export interface ForkRequest {
|
|
|
553
557
|
maxCost?: string;
|
|
554
558
|
/** Seconds with nothing happening before each copy pauses, 60 to 86400; 0 never. When omitted, its source's, unless its source never pauses (0): then its product's default, 300 for a sandbox. At least 0. At most 86400. */
|
|
555
559
|
idlePauseSeconds?: number;
|
|
556
|
-
/** The vCPUs each copy
|
|
560
|
+
/** The vCPUs each copy runs, at most its source's; its source's when omitted. A copy with fewer has only this many CPUs online (the rest of its source's are taken offline, so `nproc` in it is this number) and is held to this many vCPUs of CPU time, which it is placed and billed by. Its memory is its source's. At least 2. */
|
|
557
561
|
vcpu?: number;
|
|
558
562
|
/** Seconds until Runtime deletes each copy, as its delete does: final, and it can't be undone. 0 or omitted: kept until deleted; a copy never takes its source's. At least 0. At most 315360000. */
|
|
559
563
|
deleteAfterSeconds?: number;
|
|
@@ -580,6 +584,13 @@ export interface SnapshotRequest {
|
|
|
580
584
|
/** Whether the snapshot's (or, with image, that image version's) delete is refused (409 `delete_protected`) until an update turns this off; false when omitted. Not with `deleteAfterSeconds`. */
|
|
581
585
|
deleteProtection?: boolean;
|
|
582
586
|
}
|
|
587
|
+
/** A volume's snapshots on a timer: one every `everySeconds`, each as `:snapshot` makes one, the newest `keep` of them kept and the oldest past that deleted as its delete does. Snapshots made otherwise are never counted or deleted. */
|
|
588
|
+
export interface SnapshotSchedule {
|
|
589
|
+
/** Seconds between its snapshots, 3600 (an hour) to 31536000 (a year); 0 in an update turns the schedule off. The first is this long after it is set. At least 0. At most 31536000. */
|
|
590
|
+
everySeconds: number;
|
|
591
|
+
/** How many of its newest scheduled snapshots are kept, 1 to 365. At least 1. At most 365. */
|
|
592
|
+
keep: number;
|
|
593
|
+
}
|
|
583
594
|
/** Stored data: a snapshot, an image or a volume. */
|
|
584
595
|
export interface Stored {
|
|
585
596
|
/** Its ID. */
|
|
@@ -616,6 +627,8 @@ export interface Stored {
|
|
|
616
627
|
deleteWaitsFor?: string;
|
|
617
628
|
/** Whether its delete is refused (409 `delete_protected`) until an update turns this off. */
|
|
618
629
|
deleteProtection?: boolean;
|
|
630
|
+
/** A volume's snapshot schedule; none: off. */
|
|
631
|
+
snapshotSchedule?: SnapshotSchedule;
|
|
619
632
|
}
|
|
620
633
|
/** A change to a machine's settings: each field left out stays as it is. */
|
|
621
634
|
export interface MachineUpdate {
|
|
@@ -625,7 +638,7 @@ export interface MachineUpdate {
|
|
|
625
638
|
labels?: Record<string, string>;
|
|
626
639
|
/** Seconds with nothing happening before it pauses, 60 to 86400; 0 never. Nothing happening means no call or command running, no traffic, almost no CPU, and no outbound connection it opened still open. */
|
|
627
640
|
idlePauseSeconds?: number;
|
|
628
|
-
/** Its vCPUs, grown while it runs; a running machine's vCPUs only grow. At least
|
|
641
|
+
/** Its vCPUs, grown while it runs; a running machine's vCPUs only grow. A number under every plan's least is taken as it. At least 2. */
|
|
629
642
|
vcpu?: number;
|
|
630
643
|
/** Its memory in GB (1 GB is 1,024 MiB), grown while it runs; a running machine's memory only grows. At least 1. */
|
|
631
644
|
memoryGB?: number;
|
|
@@ -643,8 +656,12 @@ export interface MachineUpdate {
|
|
|
643
656
|
autoWake?: boolean;
|
|
644
657
|
/** Seconds from now until Runtime deletes it, as its delete does: final, and it can't be undone. Sent again before then, it renews it; 0 takes its end off (kept until deleted). At least 0. At most 315360000. */
|
|
645
658
|
deleteAfterSeconds?: number;
|
|
659
|
+
/** Text files to write in it before it answers, over what is there, each path to its text: absolute, or under its code's folder (`/app` for an app or a function, `/site` for a site, `/workspace` for the rest); at most 256 files, and its request at most 4 MiB. An app's or a function's server is then started again, once, on them, and it answers once its port serves again, or 409 `start_failed` when it does not within 60 seconds. Binary files and big trees go by files.write and uploadFolder. */
|
|
660
|
+
files?: Record<string, string>;
|
|
646
661
|
/** true refuses its delete (409 `delete_protected`) until an update sends false; while true, its time limit pauses it instead of deleting it. Not while it has a `deleteAt`, unless the same update sends `deleteAfterSeconds` 0. */
|
|
647
662
|
deleteProtection?: boolean;
|
|
663
|
+
/** The secrets it may get, by name, at most 64, in place of its list: only those of them whose scope admits it; [] none. A running one holds the change within 5 seconds (about 3 today): a visible secret's file in `/run/secrets` appears or is removed, and the proxy puts in or leaves out a hidden one's value. At most 64 items. */
|
|
664
|
+
secrets?: string[];
|
|
648
665
|
}
|
|
649
666
|
/** One step of an act: a mouse move, click, drag or scroll, typed text, a key chord, or a wait. */
|
|
650
667
|
export interface Action {
|
|
@@ -885,7 +902,7 @@ export declare class SandboxFiles {
|
|
|
885
902
|
beginFolderUpload(path: string, input?: Omit<FolderUploadBegin, "path">, options?: RequestOptions): Promise<FolderUpload>;
|
|
886
903
|
/** Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order. */
|
|
887
904
|
writeFolderUpload(upload: string, data: Uint8Array | string, query?: SandboxWriteFolderUploadQuery & RequestOptions, options?: RequestOptions): Promise<FolderUploadReceived>;
|
|
888
|
-
/** Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said.
|
|
905
|
+
/** Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended. */
|
|
889
906
|
commitFolderUpload(upload: string, options?: RequestOptions): Promise<FolderUnpacked>;
|
|
890
907
|
/** Stops a folder upload's tar; what it unpacked so far stays. */
|
|
891
908
|
abortFolderUpload(upload: string, options?: RequestOptions): Promise<FolderUploadAborted>;
|
|
@@ -893,7 +910,7 @@ export declare class SandboxFiles {
|
|
|
893
910
|
mkdir(path: string, input?: Omit<FileMkdir, "path">, options?: RequestOptions): Promise<FileMade>;
|
|
894
911
|
/** Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes. */
|
|
895
912
|
rename(input: FileRename, options?: RequestOptions): Promise<FileRenamed>;
|
|
896
|
-
/** Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its sandbox. A paused sandbox is woken for it unless wake is false. */
|
|
913
|
+
/** Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its sandbox. A paused sandbox is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link. */
|
|
897
914
|
link(path: string, input?: Omit<FileLinkCreate, "path">, options?: RequestOptions): Promise<FileLink>;
|
|
898
915
|
/** Ends every file link made for a sandbox so far; links made after work. */
|
|
899
916
|
revokeLinks(options?: RequestOptions): Promise<FileLinksRevoked>;
|
|
@@ -941,7 +958,7 @@ export declare class Sandbox {
|
|
|
941
958
|
constructor(client: Sandboxes, info: SandboxInfo);
|
|
942
959
|
/** Its id. */
|
|
943
960
|
get id(): string;
|
|
944
|
-
/** Its vCPUs; its product's default when omitted. At least
|
|
961
|
+
/** Its vCPUs, at least every plan's least (a smaller number is taken as it); its product's default when omitted. At least 2. */
|
|
945
962
|
get vcpu(): number | undefined;
|
|
946
963
|
/** Its memory in GB (1 GB is 1,024 MiB); a fraction is taken to the MiB (`1.5`). Its product's default when omitted. At least 1. */
|
|
947
964
|
get memoryGB(): number | undefined;
|
|
@@ -949,7 +966,7 @@ export declare class Sandbox {
|
|
|
949
966
|
get diskGB(): number | undefined;
|
|
950
967
|
/** The image it boots, by name (its newest version), `name:version` or ID; Runtime's default image when omitted. */
|
|
951
968
|
get image(): string | undefined;
|
|
952
|
-
/** The secrets it may get, by name, at most 64: only those of them whose scope admits it; [] none; every one whose scope admits it when omitted. A name with no secret yet takes effect once that secret is created.
|
|
969
|
+
/** The secrets it may get, by name, at most 64: only those of them whose scope admits it; [] none; every one whose scope admits it when omitted. A name with no secret yet takes effect once that secret is created. An update changes it; a fork or a copy of a snapshot keeps it. At most 64 items. */
|
|
953
970
|
get secrets(): string[] | undefined;
|
|
954
971
|
/** The command it starts at every fresh boot and keeps running, as a service: a web server, a runner, a desktop. A wake with its memory kept does not start it again. Its image's when omitted. */
|
|
955
972
|
get start(): MachineStart | undefined;
|
|
@@ -983,6 +1000,8 @@ export declare class Sandbox {
|
|
|
983
1000
|
get pausedAt(): string | undefined;
|
|
984
1001
|
/** A create's answer alone, for a start with a ready check: how its wait went. */
|
|
985
1002
|
get ready(): MachineReady | undefined;
|
|
1003
|
+
/** For a machine that serves a port of its own (an app, a site or a function on 8080, a container on its image's, a notebook on 8888, a workspace on 8080, a desktop on 6080, a browser's DevTools on 9222): a link that opens it, answered by its create, get and update, none for a key that may not share its ports. It works for 10 minutes; a browser that opens it is given a cookie for that address for a day and sent on to the address without it, so no history keeps a link that still opens it. Another port is shared with previews.create. */
|
|
1004
|
+
get url(): string | undefined;
|
|
986
1005
|
/** When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted. */
|
|
987
1006
|
get deleteAt(): string | undefined;
|
|
988
1007
|
/** Whether its delete is refused (409 `delete_protected`) until an update turns this off. */
|
|
@@ -1066,7 +1085,7 @@ export declare class Sandboxes {
|
|
|
1066
1085
|
beginFolderUpload(id: string, input: FolderUploadBegin, options?: RequestOptions): Promise<FolderUpload>;
|
|
1067
1086
|
/** Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order. */
|
|
1068
1087
|
writeFolderUpload(id: string, upload: string, data: Uint8Array | string, query?: SandboxWriteFolderUploadQuery & RequestOptions, options?: RequestOptions): Promise<FolderUploadReceived>;
|
|
1069
|
-
/** Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said.
|
|
1088
|
+
/** Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended. */
|
|
1070
1089
|
commitFolderUpload(id: string, upload: string, options?: RequestOptions): Promise<FolderUnpacked>;
|
|
1071
1090
|
/** Stops a folder upload's tar; what it unpacked so far stays. */
|
|
1072
1091
|
abortFolderUpload(id: string, upload: string, options?: RequestOptions): Promise<FolderUploadAborted>;
|
|
@@ -1074,7 +1093,7 @@ export declare class Sandboxes {
|
|
|
1074
1093
|
mkdir(id: string, input: FileMkdir, options?: RequestOptions): Promise<FileMade>;
|
|
1075
1094
|
/** Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes. */
|
|
1076
1095
|
rename(id: string, input: FileRename, options?: RequestOptions): Promise<FileRenamed>;
|
|
1077
|
-
/** Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its sandbox. A paused sandbox is woken for it unless wake is false. */
|
|
1096
|
+
/** Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its sandbox. A paused sandbox is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link. */
|
|
1078
1097
|
link(id: string, input: FileLinkCreate, options?: RequestOptions): Promise<FileLink>;
|
|
1079
1098
|
/** Ends every file link made for a sandbox so far; links made after work. */
|
|
1080
1099
|
revokeLinks(id: string, options?: RequestOptions): Promise<FileLinksRevoked>;
|