withruntime 1.0.0 → 1.1.1
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/CHANGELOG.md +76 -0
- package/README.md +145 -0
- package/dist/generated/agentSessions.d.ts +218 -0
- package/dist/generated/agentSessions.js +154 -0
- package/dist/generated/agents.d.ts +193 -0
- package/dist/generated/agents.js +166 -0
- package/dist/generated/apps.d.ts +87 -28
- package/dist/generated/apps.js +153 -41
- package/dist/generated/audit.d.ts +2 -2
- package/dist/generated/audit.js +3 -3
- package/dist/generated/browsers.d.ts +87 -28
- package/dist/generated/browsers.js +153 -41
- package/dist/generated/builds.d.ts +87 -28
- package/dist/generated/builds.js +153 -41
- package/dist/generated/ci.d.ts +87 -28
- package/dist/generated/ci.js +153 -41
- package/dist/generated/containers.d.ts +87 -28
- package/dist/generated/containers.js +153 -41
- package/dist/generated/desktops.d.ts +89 -30
- package/dist/generated/desktops.js +155 -43
- package/dist/generated/domains.d.ts +52 -15
- package/dist/generated/domains.js +74 -14
- package/dist/generated/egressIps.d.ts +6 -6
- package/dist/generated/egressIps.js +4 -4
- package/dist/generated/events.d.ts +4 -2
- package/dist/generated/events.js +3 -3
- package/dist/generated/feedback.d.ts +1 -1
- package/dist/generated/feedback.js +3 -3
- package/dist/generated/functions.d.ts +87 -28
- package/dist/generated/functions.js +153 -41
- package/dist/generated/identities.d.ts +2 -2
- package/dist/generated/identities.js +5 -5
- package/dist/generated/images.d.ts +68 -14
- package/dist/generated/images.js +96 -15
- package/dist/generated/index.d.ts +9 -0
- package/dist/generated/index.js +12 -0
- package/dist/generated/jobRuns.d.ts +11 -4
- package/dist/generated/jobRuns.js +6 -6
- package/dist/generated/jobs.d.ts +58 -9
- package/dist/generated/jobs.js +98 -14
- package/dist/generated/keys.d.ts +8 -6
- package/dist/generated/keys.js +6 -6
- package/dist/generated/me.d.ts +2 -2
- package/dist/generated/me.js +3 -3
- package/dist/generated/messages.d.ts +67 -0
- package/dist/generated/messages.js +17 -0
- package/dist/generated/networks.d.ts +4 -4
- package/dist/generated/networks.js +4 -4
- package/dist/generated/notebooks.d.ts +87 -28
- package/dist/generated/notebooks.js +153 -41
- package/dist/generated/otel.d.ts +2 -2
- package/dist/generated/otel.js +5 -5
- package/dist/generated/ports.d.ts +11 -11
- package/dist/generated/ports.js +8 -8
- package/dist/generated/previews.d.ts +50 -15
- package/dist/generated/previews.js +70 -18
- package/dist/generated/projects.d.ts +30 -6
- package/dist/generated/projects.js +13 -9
- package/dist/generated/roles.d.ts +11 -2
- package/dist/generated/roles.js +9 -5
- package/dist/generated/routes.js +1 -1
- package/dist/generated/runtime.d.ts +15 -3
- package/dist/generated/runtime.js +31 -18
- package/dist/generated/sandboxes.d.ts +213 -66
- package/dist/generated/sandboxes.js +171 -43
- package/dist/generated/secrets.d.ts +45 -6
- package/dist/generated/secrets.js +69 -9
- package/dist/generated/sessions.d.ts +1 -1
- package/dist/generated/sessions.js +4 -4
- package/dist/generated/signing.js +3 -1
- package/dist/generated/sites.d.ts +87 -28
- package/dist/generated/sites.js +153 -41
- package/dist/generated/snapshots.d.ts +70 -5
- package/dist/generated/snapshots.js +107 -7
- package/dist/generated/tunnels.d.ts +8 -8
- package/dist/generated/tunnels.js +4 -4
- package/dist/generated/usage.d.ts +57 -6
- package/dist/generated/usage.js +4 -4
- package/dist/generated/volumes.d.ts +72 -7
- package/dist/generated/volumes.js +114 -10
- package/dist/generated/webhooks.d.ts +2 -2
- package/dist/generated/webhooks.js +5 -5
- package/dist/generated/workspaces.d.ts +87 -28
- package/dist/generated/workspaces.js +153 -41
- package/dist/v2/bin.d.ts +2 -0
- package/dist/v2/bin.js +15 -0
- package/dist/v2/cli.d.ts +15 -2
- package/dist/v2/cli.js +158 -53
- package/dist/v2/json.d.ts +9 -0
- package/dist/v2/json.js +5 -0
- package/dist/v2/mcp.js +14 -1
- package/dist/v2/openapi.json +7695 -4382
- package/dist/v2/shims/fly.js +49 -13
- package/dist/v2/shims/morph.js +1 -1
- package/dist/v2/table.d.ts +7 -4
- package/dist/v2/table.js +97 -34
- package/package.json +7 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by spec-gen from engines/front/crates/spec. Do not edit:
|
|
2
2
|
// change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
|
|
3
|
-
import { Paginated, toBytes } from "./runtime.js";
|
|
3
|
+
import { Paginated, Transport, toBytes } from "./runtime.js";
|
|
4
4
|
/** A functionmachine's files. */
|
|
5
5
|
export class FunctionMachineFiles {
|
|
6
6
|
#c;
|
|
@@ -90,6 +90,10 @@ export class FunctionMachineProcesses {
|
|
|
90
90
|
signal(process, input = {}, options) {
|
|
91
91
|
return this.#c.signalProcess(this.#id, process, input, options);
|
|
92
92
|
}
|
|
93
|
+
/** Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe. */
|
|
94
|
+
resize(process, input, options) {
|
|
95
|
+
return this.#c.resizeProcess(this.#id, process, input, options);
|
|
96
|
+
}
|
|
93
97
|
/** Lists a function's processes, newest first: those running and those that ended lately. */
|
|
94
98
|
list(options) {
|
|
95
99
|
return this.#c.listProcesses(this.#id, options);
|
|
@@ -131,9 +135,105 @@ export class FunctionMachine {
|
|
|
131
135
|
get id() {
|
|
132
136
|
return this.info.id;
|
|
133
137
|
}
|
|
138
|
+
/** Its vCPUs; its product's default when omitted. At least 1. */
|
|
139
|
+
get vcpu() {
|
|
140
|
+
return this.info.vcpu;
|
|
141
|
+
}
|
|
142
|
+
/** 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. */
|
|
143
|
+
get memoryGB() {
|
|
144
|
+
return this.info.memoryGB;
|
|
145
|
+
}
|
|
146
|
+
/** Its disk in GB (1 GB is 1,024 MiB), to the MiB. When omitted, its product's default or its image's size, whichever is larger. At least 1. */
|
|
147
|
+
get diskGB() {
|
|
148
|
+
return this.info.diskGB;
|
|
149
|
+
}
|
|
150
|
+
/** The image it boots, by name (its newest version), `name:version` or ID; Runtime's default image when omitted. */
|
|
151
|
+
get image() {
|
|
152
|
+
return this.info.image;
|
|
153
|
+
}
|
|
154
|
+
/** 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. Fixed for its life: a fork or a copy of a snapshot keeps it. At most 64 items. */
|
|
155
|
+
get secrets() {
|
|
156
|
+
return this.info.secrets;
|
|
157
|
+
}
|
|
158
|
+
/** 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. */
|
|
159
|
+
get start() {
|
|
160
|
+
return this.info.start;
|
|
161
|
+
}
|
|
162
|
+
/** Who every command, process, terminal and code run in it runs as when the call names no `user`: `runtime` (uid 1000, with passwordless sudo) or `root`. Its image's when omitted, else `runtime`. */
|
|
163
|
+
get user() {
|
|
164
|
+
return this.info.user;
|
|
165
|
+
}
|
|
166
|
+
/** Its product's kind: `sandbox` for a sandbox, `app` for an app, and so on. */
|
|
167
|
+
get object() {
|
|
168
|
+
return this.info.object;
|
|
169
|
+
}
|
|
170
|
+
/** Its name, unique in its project. */
|
|
171
|
+
get name() {
|
|
172
|
+
return this.info.name;
|
|
173
|
+
}
|
|
174
|
+
/** Where it is. */
|
|
175
|
+
get state() {
|
|
176
|
+
return this.info.state;
|
|
177
|
+
}
|
|
178
|
+
/** Its labels. */
|
|
179
|
+
get labels() {
|
|
180
|
+
return this.info.labels;
|
|
181
|
+
}
|
|
182
|
+
/** When it was created. */
|
|
183
|
+
get createdAt() {
|
|
184
|
+
return this.info.createdAt;
|
|
185
|
+
}
|
|
186
|
+
/** When it was deleted: a delete's answer alone. */
|
|
187
|
+
get deletedAt() {
|
|
188
|
+
return this.info.deletedAt;
|
|
189
|
+
}
|
|
190
|
+
/** Its revision, changed by every change to it: what an update's If-Match names. */
|
|
191
|
+
get revision() {
|
|
192
|
+
return this.info.revision;
|
|
193
|
+
}
|
|
194
|
+
/** Seconds with nothing happening before it pauses; 0 never. Default: 300. */
|
|
195
|
+
get idlePauseSeconds() {
|
|
196
|
+
return this.info.idlePauseSeconds;
|
|
197
|
+
}
|
|
198
|
+
/** The most it may cost in all, in US dollars; none when it has no such cap. */
|
|
199
|
+
get maxCost() {
|
|
200
|
+
return this.info.maxCost;
|
|
201
|
+
}
|
|
202
|
+
/** Whether a call that reaches it paused resumes it; false: only its own resume does, and such a call answers 409 sandbox_paused. Default: true. */
|
|
203
|
+
get autoWake() {
|
|
204
|
+
return this.info.autoWake;
|
|
205
|
+
}
|
|
206
|
+
/** Its run's exit code, once its run ended; none for one a signal or its timeout ended. */
|
|
207
|
+
get exitCode() {
|
|
208
|
+
return this.info.exitCode;
|
|
209
|
+
}
|
|
210
|
+
/** When its run ended. */
|
|
211
|
+
get endedAt() {
|
|
212
|
+
return this.info.endedAt;
|
|
213
|
+
}
|
|
214
|
+
/** When its pause began (or its run ended), while it is paused. */
|
|
215
|
+
get pausedAt() {
|
|
216
|
+
return this.info.pausedAt;
|
|
217
|
+
}
|
|
218
|
+
/** A create's answer alone, for a start with a ready check: how its wait went. */
|
|
219
|
+
get ready() {
|
|
220
|
+
return this.info.ready;
|
|
221
|
+
}
|
|
222
|
+
/** When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted. */
|
|
223
|
+
get deleteAt() {
|
|
224
|
+
return this.info.deleteAt;
|
|
225
|
+
}
|
|
226
|
+
/** Whether its delete is refused (409 `delete_protected`) until an update turns this off. */
|
|
227
|
+
get deleteProtection() {
|
|
228
|
+
return this.info.deleteProtection;
|
|
229
|
+
}
|
|
230
|
+
/** Makes one and returns it, as `new Runtime().functions.create()` does, with a client of its own: `RUNTIME_API_KEY`, or the key `options` names. */
|
|
231
|
+
static async create(input = {}, options = {}) {
|
|
232
|
+
return new Functions(new Transport(options)).create(input, options);
|
|
233
|
+
}
|
|
134
234
|
/** Returns a function. */
|
|
135
235
|
async refresh(query = {}, options) {
|
|
136
|
-
this.info =
|
|
236
|
+
this.info = (await this.#c.get(this.id, query, options)).info;
|
|
137
237
|
return this;
|
|
138
238
|
}
|
|
139
239
|
/** Deletes a function, its memory and its disk. */
|
|
@@ -166,7 +266,7 @@ export class FunctionMachine {
|
|
|
166
266
|
snapshot(input = {}, options) {
|
|
167
267
|
return this.#c.snapshot(this.id, input, options);
|
|
168
268
|
}
|
|
169
|
-
/** Changes its name, labels, idle pause, maxCost, environment or sizes; each field left out stays as it is. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on
|
|
269
|
+
/** Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused. */
|
|
170
270
|
async update(input = {}, options) {
|
|
171
271
|
this.info = await this.#c.update(this.id, input, options);
|
|
172
272
|
return this;
|
|
@@ -183,151 +283,163 @@ export class FunctionMachine {
|
|
|
183
283
|
runCode(code, input = {}, options) {
|
|
184
284
|
return this.#c.runCode(this.id, { ...input, code: code }, options);
|
|
185
285
|
}
|
|
286
|
+
/** Starts a command and returns its process at once, while the command runs on. Its output is read with `processes.output` and it is stopped with `processes.signal`. */
|
|
287
|
+
spawn(cmd, input = {}, options) {
|
|
288
|
+
return this.exec(cmd, { ...input, wait: false }, options);
|
|
289
|
+
}
|
|
290
|
+
/** Deletes it when the `await using` block that holds it ends. */
|
|
291
|
+
async [Symbol.asyncDispose]() {
|
|
292
|
+
await this.delete();
|
|
293
|
+
}
|
|
186
294
|
}
|
|
187
295
|
/** A machine that answers HTTP with a handler in /app/index.ts (`export default { fetch(request) }`, as Cloudflare Workers and Vercel take one) on port 8080, reached at its preview. It pauses after 60 seconds with nothing happening, its memory kept, and a request resumes it. */
|
|
188
296
|
export class Functions {
|
|
189
|
-
|
|
297
|
+
transport;
|
|
190
298
|
constructor(transport) {
|
|
191
|
-
this
|
|
299
|
+
this.transport = transport;
|
|
192
300
|
}
|
|
193
301
|
/** Creates a function. Asked again with the same Idempotency-Key, it returns the same function. */
|
|
194
302
|
async create(input = {}, options) {
|
|
195
|
-
return new FunctionMachine(this, await this
|
|
303
|
+
return new FunctionMachine(this, await this.transport.request("POST", `/v2/functions`, { body: input, options, idempotent: true }));
|
|
196
304
|
}
|
|
197
305
|
/** Returns a function. */
|
|
198
306
|
async get(id, query = {}, options) {
|
|
199
|
-
return new FunctionMachine(this, await this
|
|
307
|
+
return new FunctionMachine(this, await this.transport.request("GET", `/v2/functions/${encodeURIComponent(id)}`, { query: { ...query }, options, idempotent: true }));
|
|
200
308
|
}
|
|
201
309
|
/** Lists the project's functions, newest first. */
|
|
202
310
|
list(query = {}, options) {
|
|
203
|
-
return new Paginated((cursor) => this
|
|
311
|
+
return new Paginated((cursor) => this.transport.request("GET", `/v2/functions`, { query: { ...query, cursor }, options, idempotent: true }));
|
|
204
312
|
}
|
|
205
313
|
/** Deletes a function, its memory and its disk. */
|
|
206
314
|
delete(id, options) {
|
|
207
|
-
return this
|
|
315
|
+
return this.transport.request("DELETE", `/v2/functions/${encodeURIComponent(id)}`, { options });
|
|
208
316
|
}
|
|
209
317
|
/** Pauses a function with its memory and disk kept. A call to it resumes it. */
|
|
210
318
|
pause(id, options) {
|
|
211
|
-
return this
|
|
319
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}:pause`, { options });
|
|
212
320
|
}
|
|
213
321
|
/** Resumes a paused function where it was, its memory and processes as they were. */
|
|
214
322
|
resume(id, options) {
|
|
215
|
-
return this
|
|
323
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}:resume`, { options });
|
|
216
324
|
}
|
|
217
325
|
/** Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused function is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs. */
|
|
218
326
|
exec(id, input, options) {
|
|
219
|
-
return this
|
|
327
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}:exec`, { body: input, options, idempotent: true, runs: true, runsSeconds: input.timeoutSeconds });
|
|
220
328
|
}
|
|
221
329
|
/** Returns a file's bytes. */
|
|
222
330
|
read(id, query, options) {
|
|
223
|
-
return this
|
|
331
|
+
return this.transport.request("GET", `/v2/functions/${encodeURIComponent(id)}/files`, { query: { ...query }, raw: true, options, idempotent: true });
|
|
224
332
|
}
|
|
225
333
|
/** Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place. */
|
|
226
334
|
write(id, data, query, options) {
|
|
227
|
-
return this
|
|
335
|
+
return this.transport.request("PUT", `/v2/functions/${encodeURIComponent(id)}/files`, { data: toBytes(data), query: { ...query }, options });
|
|
228
336
|
}
|
|
229
337
|
/** Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind. */
|
|
230
338
|
processOutput(id, process, query = {}, options) {
|
|
231
|
-
return this
|
|
339
|
+
return this.transport.request("GET", `/v2/functions/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}/output`, { query: { ...query }, options, idempotent: true });
|
|
232
340
|
}
|
|
233
341
|
/** Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken. */
|
|
234
342
|
writeProcess(id, process, input = {}, options) {
|
|
235
|
-
return this
|
|
343
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}:write`, { body: input, options });
|
|
236
344
|
}
|
|
237
345
|
/** Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe. */
|
|
238
346
|
signalProcess(id, process, input = {}, options) {
|
|
239
|
-
return this
|
|
347
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}:signal`, { body: input, options, idempotent: true });
|
|
348
|
+
}
|
|
349
|
+
/** Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe. */
|
|
350
|
+
resizeProcess(id, process, input, options) {
|
|
351
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}:resize`, { body: input, options, idempotent: true });
|
|
240
352
|
}
|
|
241
353
|
/** Lists a function's processes, newest first: those running and those that ended lately. */
|
|
242
354
|
listProcesses(id, options) {
|
|
243
|
-
return this
|
|
355
|
+
return this.transport.request("GET", `/v2/functions/${encodeURIComponent(id)}/processes`, { options, idempotent: true });
|
|
244
356
|
}
|
|
245
357
|
/** Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false. */
|
|
246
358
|
remove(id, input, options) {
|
|
247
|
-
return this
|
|
359
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/files:remove`, { body: input, options });
|
|
248
360
|
}
|
|
249
361
|
/** Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too. */
|
|
250
362
|
stat(id, query, options) {
|
|
251
|
-
return this
|
|
363
|
+
return this.transport.request("GET", `/v2/functions/${encodeURIComponent(id)}/files/stat`, { query: { ...query }, options, idempotent: true });
|
|
252
364
|
}
|
|
253
365
|
/** Lists a directory's entries in path order, to a depth. */
|
|
254
366
|
listFiles(id, query = {}, options) {
|
|
255
|
-
return this
|
|
367
|
+
return this.transport.request("GET", `/v2/functions/${encodeURIComponent(id)}/files/list`, { query: { ...query }, options, idempotent: true });
|
|
256
368
|
}
|
|
257
369
|
/** Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the function as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a function. A paused function is woken first. */
|
|
258
370
|
downloadFolder(id, query, options) {
|
|
259
|
-
return this
|
|
371
|
+
return this.transport.request("GET", `/v2/functions/${encodeURIComponent(id)}/files/archive`, { query: { ...query }, raw: true, options, idempotent: true });
|
|
260
372
|
}
|
|
261
373
|
/** Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the function as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused function is woken first. */
|
|
262
374
|
uploadFolder(id, data, query, options) {
|
|
263
|
-
return this
|
|
375
|
+
return this.transport.request("PUT", `/v2/functions/${encodeURIComponent(id)}/files/archive`, { data: toBytes(data), query: { ...query }, options, idempotent: true });
|
|
264
376
|
}
|
|
265
377
|
/** Begins a folder's upload in parts: tar starts in the function, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused function is woken first. */
|
|
266
378
|
beginFolderUpload(id, input, options) {
|
|
267
|
-
return this
|
|
379
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/files/archive/uploads`, { body: input, options });
|
|
268
380
|
}
|
|
269
381
|
/** 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. */
|
|
270
382
|
writeFolderUpload(id, upload, data, query = {}, options) {
|
|
271
|
-
return this
|
|
383
|
+
return this.transport.request("PUT", `/v2/functions/${encodeURIComponent(id)}/files/archive/uploads/${encodeURIComponent(upload)}`, { data: toBytes(data), query: { ...query }, options, idempotent: true });
|
|
272
384
|
}
|
|
273
385
|
/** 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. A front that restarts meanwhile returns 503 `run_goes_on`; sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended. */
|
|
274
386
|
commitFolderUpload(id, upload, options) {
|
|
275
|
-
return this
|
|
387
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/files/archive/uploads/${encodeURIComponent(upload)}:commit`, { options, idempotent: true });
|
|
276
388
|
}
|
|
277
389
|
/** Stops a folder upload's tar; what it unpacked so far stays. */
|
|
278
390
|
abortFolderUpload(id, upload, options) {
|
|
279
|
-
return this
|
|
391
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/files/archive/uploads/${encodeURIComponent(upload)}:abort`, { options, idempotent: true });
|
|
280
392
|
}
|
|
281
393
|
/** Makes a directory, and its parents unless parents is false. One there already is success, created false. */
|
|
282
394
|
mkdir(id, input, options) {
|
|
283
|
-
return this
|
|
395
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/files:mkdir`, { body: input, options, idempotent: true });
|
|
284
396
|
}
|
|
285
397
|
/** 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. */
|
|
286
398
|
rename(id, input, options) {
|
|
287
|
-
return this
|
|
399
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/files:rename`, { body: input, options });
|
|
288
400
|
}
|
|
289
401
|
/** 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 function. A paused function is woken for it unless wake is false. */
|
|
290
402
|
link(id, input, options) {
|
|
291
|
-
return this
|
|
403
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/files:link`, { body: input, options });
|
|
292
404
|
}
|
|
293
405
|
/** Ends every file link made for a function so far; links made after work. */
|
|
294
406
|
revokeLinks(id, options) {
|
|
295
|
-
return this
|
|
407
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}/files:revokeLinks`, { options });
|
|
296
408
|
}
|
|
297
409
|
/** Returns where a function may connect out. */
|
|
298
410
|
getNetwork(id, options) {
|
|
299
|
-
return this
|
|
411
|
+
return this.transport.request("GET", `/v2/functions/${encodeURIComponent(id)}/network`, { options, idempotent: true });
|
|
300
412
|
}
|
|
301
413
|
/** Returns a function's CPU, memory, disks and pressure, as its host reads them from the function's own cgroup over a fifth of a second: never a call into the function, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading. */
|
|
302
414
|
metrics(id, query = {}, options) {
|
|
303
|
-
return this
|
|
415
|
+
return this.transport.request("GET", `/v2/functions/${encodeURIComponent(id)}/metrics`, { query: { ...query }, options, idempotent: true });
|
|
304
416
|
}
|
|
305
417
|
/** Replaces where a function may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut. */
|
|
306
418
|
setNetwork(id, input = {}, options) {
|
|
307
|
-
return this
|
|
419
|
+
return this.transport.request("PUT", `/v2/functions/${encodeURIComponent(id)}/network`, { body: input, options });
|
|
308
420
|
}
|
|
309
421
|
/** Copies a function as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies. */
|
|
310
422
|
fork(id, input = {}, options) {
|
|
311
|
-
return this
|
|
423
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}:fork`, { body: input, options, idempotent: true });
|
|
312
424
|
}
|
|
313
425
|
/** Keeps a function's memory and disk as they are now, a snapshot to start functions from; with `image`, its disk alone as that image's next version. The function runs on. Asked again with the same Idempotency-Key, it returns the same snapshot. */
|
|
314
426
|
snapshot(id, input = {}, options) {
|
|
315
|
-
return this
|
|
427
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}:snapshot`, { body: input, options, idempotent: true });
|
|
316
428
|
}
|
|
317
|
-
/** Changes its name, labels, idle pause, maxCost, environment or sizes; each field left out stays as it is. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on
|
|
429
|
+
/** Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused. */
|
|
318
430
|
update(id, input = {}, options) {
|
|
319
|
-
return this
|
|
431
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}:update`, { body: input, options });
|
|
320
432
|
}
|
|
321
433
|
/** Returns what a function's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused function is resumed first. */
|
|
322
434
|
screenshot(id, query = {}, options) {
|
|
323
|
-
return this
|
|
435
|
+
return this.transport.request("GET", `/v2/functions/${encodeURIComponent(id)}/screenshot`, { query: { ...query }, raw: true, options, idempotent: true });
|
|
324
436
|
}
|
|
325
437
|
/** Moves, clicks, drags and scrolls the mouse and types on the keyboard of a function's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused function is resumed first. */
|
|
326
438
|
act(id, input, options) {
|
|
327
|
-
return this
|
|
439
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}:act`, { body: input, options });
|
|
328
440
|
}
|
|
329
441
|
/** Runs a cell of Python in a function as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused function is resumed first. */
|
|
330
442
|
runCode(id, input, options) {
|
|
331
|
-
return this
|
|
443
|
+
return this.transport.request("POST", `/v2/functions/${encodeURIComponent(id)}:runCode`, { body: input, options });
|
|
332
444
|
}
|
|
333
445
|
}
|
|
@@ -25,10 +25,10 @@ export type IdentityListQuery = {
|
|
|
25
25
|
};
|
|
26
26
|
/** An agent or CI pipeline: who a key acts as besides a person, holding grants of its own. */
|
|
27
27
|
export declare class Identities {
|
|
28
|
-
|
|
28
|
+
readonly transport: Transport;
|
|
29
29
|
constructor(transport: Transport);
|
|
30
30
|
/** Lists the organization's agents and CI pipelines, by name. */
|
|
31
|
-
list(query?: IdentityListQuery, options?: RequestOptions): Paginated<Identity>;
|
|
31
|
+
list(query?: IdentityListQuery & RequestOptions, options?: RequestOptions): Paginated<Identity>;
|
|
32
32
|
/** Renames an agent or CI pipeline; its keys and grants stay as they are. A name another of its kind has returns 409. */
|
|
33
33
|
update(id: string, input: Rename, options?: RequestOptions): Promise<Identity>;
|
|
34
34
|
/** Deletes an agent or CI pipeline and frees its name, with its grants and keys: refused from their next call. The caller needs `grants:delete` as well, as the grants go with it. What it made stays. Deleted again, it returns 404. */
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
import { Paginated } from "./runtime.js";
|
|
4
4
|
/** An agent or CI pipeline: who a key acts as besides a person, holding grants of its own. */
|
|
5
5
|
export class Identities {
|
|
6
|
-
|
|
6
|
+
transport;
|
|
7
7
|
constructor(transport) {
|
|
8
|
-
this
|
|
8
|
+
this.transport = transport;
|
|
9
9
|
}
|
|
10
10
|
/** Lists the organization's agents and CI pipelines, by name. */
|
|
11
11
|
list(query = {}, options) {
|
|
12
|
-
return new Paginated((cursor) => this
|
|
12
|
+
return new Paginated((cursor) => this.transport.request("GET", `/v2/identities`, { query: { ...query, cursor }, options, idempotent: true }));
|
|
13
13
|
}
|
|
14
14
|
/** Renames an agent or CI pipeline; its keys and grants stay as they are. A name another of its kind has returns 409. */
|
|
15
15
|
update(id, input, options) {
|
|
16
|
-
return this
|
|
16
|
+
return this.transport.request("POST", `/v2/identities/${encodeURIComponent(id)}:update`, { body: input, options, idempotent: true });
|
|
17
17
|
}
|
|
18
18
|
/** Deletes an agent or CI pipeline and frees its name, with its grants and keys: refused from their next call. The caller needs `grants:delete` as well, as the grants go with it. What it made stays. Deleted again, it returns 404. */
|
|
19
19
|
delete(id, options) {
|
|
20
|
-
return this
|
|
20
|
+
return this.transport.request("DELETE", `/v2/identities/${encodeURIComponent(id)}`, { options, idempotent: true });
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { RequestOptions,
|
|
2
|
-
import { Paginated } from "./runtime.js";
|
|
1
|
+
import type { RequestOptions, ClientOptions } from "./runtime.js";
|
|
2
|
+
import { Paginated, Transport } from "./runtime.js";
|
|
3
3
|
import type { Stored } from "./sandboxes.js";
|
|
4
4
|
import type { MachineStart } from "./sandboxes.js";
|
|
5
|
+
import type { StoredUpdate } from "./snapshots.js";
|
|
5
6
|
/** Chunks of a build's context, by their SHA-256. */
|
|
6
7
|
export interface ContextAsked {
|
|
7
8
|
/** At most 10,000 SHA-256 digests, each 64 lowercase hex digits. */
|
|
@@ -80,11 +81,11 @@ export interface ImageContext {
|
|
|
80
81
|
}
|
|
81
82
|
/** What an image's build runs on: a machine of its own, deleted once the build ends. */
|
|
82
83
|
export interface ImageBuild {
|
|
83
|
-
/** Its vCPUs. At least 1. At most 8.
|
|
84
|
+
/** Its vCPUs; a build machine's default when omitted. At least 1. At most 8. */
|
|
84
85
|
vcpu?: number;
|
|
85
|
-
/** Its memory in GB. At least 1. At most 16.
|
|
86
|
+
/** Its memory in GB; a build machine's default when omitted. At least 1. At most 16. */
|
|
86
87
|
memoryGB?: number;
|
|
87
|
-
/** Its disk in GB: the base image, the earlier stages and the context. At least 4. At most 32.
|
|
88
|
+
/** Its disk in GB: the base image, the earlier stages and the context. A build machine's default when omitted, at least its image's size. At least 4. At most 32. */
|
|
88
89
|
diskGB?: number;
|
|
89
90
|
/** Seconds the build may run before it fails. At least 60. At most 3600. Default: 1800. */
|
|
90
91
|
timeoutSeconds?: number;
|
|
@@ -97,8 +98,10 @@ export interface ImageCreate {
|
|
|
97
98
|
labels?: Record<string, string>;
|
|
98
99
|
/** Tags its name takes for it once it is ready; `latest` when it has a name and none is given. At most 16 items. */
|
|
99
100
|
tags?: string[];
|
|
100
|
-
/** An OCI image to use as it is
|
|
101
|
+
/** An OCI image to use as it is: `python:3.12-slim`, `ghcr.io/org/app:1`. A private one is named by its digest, `repo@sha256:<64 hex digits>`, with `pullSecret`. */
|
|
101
102
|
image?: string;
|
|
103
|
+
/** The secret holding the registry login that pulls a private `image`: a hidden secret with header `Authorization`, format `Basic {value}`, its value the base64 of `username:token`, as its hosts the registry's token service (`auth.docker.io` for Docker Hub, the registry's own name for `ghcr.io`, `quay.io` and others), and as its scope `{"none": true}`, so no machine's requests carry it. Runtime's egress proxy signs in with it for this import's build machine alone, which never holds the login or a token. The caller needs the `secrets:use` permission. */
|
|
104
|
+
pullSecret?: string;
|
|
102
105
|
/** A Dockerfile: multi-stage builds, `ARG`, `COPY --from`, heredocs. `COPY` reads `files`. */
|
|
103
106
|
dockerfile?: string;
|
|
104
107
|
/** Packages, files and commands, rendered into a Dockerfile. Not with `files` or `context`. */
|
|
@@ -119,6 +122,10 @@ export interface ImageCreate {
|
|
|
119
122
|
start?: MachineStart;
|
|
120
123
|
/** What its build runs on. */
|
|
121
124
|
build?: ImageBuild;
|
|
125
|
+
/** Seconds until Runtime deletes this version, as its delete does: final, and it can't be undone; one an App boots is deleted once none does. 0 or omitted: kept until deleted. At least 0. At most 315360000. */
|
|
126
|
+
deleteAfterSeconds?: number;
|
|
127
|
+
/** Whether this version's delete is refused (409 `delete_protected`) until an update turns this off; false when omitted. Not with `deleteAfterSeconds`. */
|
|
128
|
+
deleteProtection?: boolean;
|
|
122
129
|
}
|
|
123
130
|
/** One line of an image's build log. */
|
|
124
131
|
export interface ImageLogLine {
|
|
@@ -144,6 +151,13 @@ export interface ImageLogs {
|
|
|
144
151
|
/** Whether the build has ended: no line comes after these. */
|
|
145
152
|
done: boolean;
|
|
146
153
|
}
|
|
154
|
+
/** What get takes in its query. */
|
|
155
|
+
export type ImageGetQuery = {
|
|
156
|
+
/** Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60. */
|
|
157
|
+
wait?: number;
|
|
158
|
+
/** The state the caller last read, which `wait` waits for it to leave. */
|
|
159
|
+
ifState?: string;
|
|
160
|
+
};
|
|
147
161
|
/** What list takes in its query. */
|
|
148
162
|
export type ImageListQuery = {
|
|
149
163
|
/** Only those of this name. */
|
|
@@ -172,29 +186,69 @@ export declare class Image {
|
|
|
172
186
|
constructor(client: Images, info: Stored);
|
|
173
187
|
/** Its id. */
|
|
174
188
|
get id(): string;
|
|
189
|
+
/** Its kind: `snapshot`, `image` or `volume`. */
|
|
190
|
+
get object(): "snapshot" | "image" | "volume" | (string & {});
|
|
191
|
+
/** Its name, unique in its project among its kind. */
|
|
192
|
+
get name(): string | undefined;
|
|
193
|
+
/** Where it is. */
|
|
194
|
+
get state(): "making" | "ready" | "failed" | "deleted" | (string & {});
|
|
195
|
+
/** Its labels. */
|
|
196
|
+
get labels(): Record<string, string>;
|
|
197
|
+
/** What it was made to hold, in bytes. */
|
|
198
|
+
get sizeBytes(): number;
|
|
199
|
+
/** What it holds now, in bytes. */
|
|
200
|
+
get storedBytes(): number;
|
|
201
|
+
/** What it was made from (a snapshot's machine, an image's base), if anything. */
|
|
202
|
+
get parentId(): string | undefined;
|
|
203
|
+
/** The machine it is attached to now, if any. */
|
|
204
|
+
get attachedTo(): string | undefined;
|
|
205
|
+
/** When it was made. */
|
|
206
|
+
get createdAt(): string | undefined;
|
|
207
|
+
/** An image's version of its name: each build or keep of a name is its next. */
|
|
208
|
+
get version(): number | undefined;
|
|
209
|
+
/** An image's tags, each `name:tag`. */
|
|
210
|
+
get tags(): string[] | undefined;
|
|
211
|
+
/** Why an image's build failed. */
|
|
212
|
+
get error(): string | undefined;
|
|
213
|
+
/** When it was deleted: a delete's answer, its state `deleted`. */
|
|
214
|
+
get deletedAt(): string | undefined;
|
|
215
|
+
/** When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted. */
|
|
216
|
+
get deleteAt(): string | undefined;
|
|
217
|
+
/** Once `deleteAt` has passed, what its delete waits for: the App that boots this image, or the machine this volume is attached to, by its ID. It is deleted as soon as that one no longer does. */
|
|
218
|
+
get deleteWaitsFor(): string | undefined;
|
|
219
|
+
/** Whether its delete is refused (409 `delete_protected`) until an update turns this off. */
|
|
220
|
+
get deleteProtection(): boolean | undefined;
|
|
221
|
+
/** Makes one and returns it, as `new Runtime().images.create()` does, with a client of its own: `RUNTIME_API_KEY`, or the key `options` names. */
|
|
222
|
+
static create(input?: ImageCreate, options?: ClientOptions & RequestOptions): Promise<Image>;
|
|
175
223
|
/** Returns an image, by its ID, its name (its newest version) or one of its tags (`name:tag`). */
|
|
176
|
-
refresh(options?: RequestOptions): Promise<this>;
|
|
177
|
-
/** Deletes an image version.
|
|
224
|
+
refresh(query?: ImageGetQuery & RequestOptions, options?: RequestOptions): Promise<this>;
|
|
225
|
+
/** Deletes an image version. Machines already started from it keep running. One an App boots from is refused with image_in_use (409) naming the App. */
|
|
178
226
|
delete(options?: RequestOptions): Promise<Stored>;
|
|
179
227
|
/** Returns an image's build log after a line, as the build writes it and once it has ended. */
|
|
180
|
-
logs(query?: ImageLogsQuery, options?: RequestOptions): Promise<ImageLogs>;
|
|
228
|
+
logs(query?: ImageLogsQuery & RequestOptions, options?: RequestOptions): Promise<ImageLogs>;
|
|
229
|
+
/** Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is. */
|
|
230
|
+
update(input?: StoredUpdate, options?: RequestOptions): Promise<this>;
|
|
231
|
+
/** Deletes it when the `await using` block that holds it ends. */
|
|
232
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
181
233
|
}
|
|
182
234
|
/** What a machine boots: a root filesystem, its environment and its start. */
|
|
183
235
|
export declare class Images {
|
|
184
|
-
|
|
236
|
+
readonly transport: Transport;
|
|
185
237
|
constructor(transport: Transport);
|
|
186
238
|
/** Returns an image, by its ID, its name (its newest version) or one of its tags (`name:tag`). */
|
|
187
|
-
get(id: string, options?: RequestOptions): Promise<Image>;
|
|
239
|
+
get(id: string, query?: ImageGetQuery & RequestOptions, options?: RequestOptions): Promise<Image>;
|
|
188
240
|
/** Lists the project's images, newest first. */
|
|
189
|
-
list(query?: ImageListQuery, options?: RequestOptions): Paginated<Stored>;
|
|
241
|
+
list(query?: ImageListQuery & RequestOptions, options?: RequestOptions): Paginated<Stored>;
|
|
190
242
|
/** Returns which chunks of a build context still need uploading. The chunks it holds count as used, so they are kept for the build that names them: a chunk is kept 24 hours after its last use, and an organization's build context holds at most 200 MiB. */
|
|
191
243
|
missing(input: ContextAsked, options?: RequestOptions): Promise<ContextMissing>;
|
|
192
244
|
/** Uploads one chunk of a build context: the request's bytes, 1 byte to 1 MiB, named by their SHA-256. Asked again, it stores nothing more. */
|
|
193
245
|
put(digest: string, data: Uint8Array | string, options?: RequestOptions): Promise<ChunkStored>;
|
|
194
|
-
/** Deletes an image version.
|
|
246
|
+
/** Deletes an image version. Machines already started from it keep running. One an App boots from is refused with image_in_use (409) naming the App. */
|
|
195
247
|
delete(id: string, options?: RequestOptions): Promise<Stored>;
|
|
196
248
|
/** Builds an image from an OCI image or a Dockerfile on a machine of its own, and returns it at once, `making`: `ready` once built, else `failed` with `error`. Each build of a name is its next version. Asked again with the same Idempotency-Key, it returns the same one. */
|
|
197
249
|
create(input?: ImageCreate, options?: RequestOptions): Promise<Image>;
|
|
198
250
|
/** Returns an image's build log after a line, as the build writes it and once it has ended. */
|
|
199
|
-
logs(id: string, query?: ImageLogsQuery, options?: RequestOptions): Promise<ImageLogs>;
|
|
251
|
+
logs(id: string, query?: ImageLogsQuery & RequestOptions, options?: RequestOptions): Promise<ImageLogs>;
|
|
252
|
+
/** Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is. */
|
|
253
|
+
update(id: string, input?: StoredUpdate, options?: RequestOptions): Promise<Stored>;
|
|
200
254
|
}
|