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.
Files changed (97) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +145 -0
  3. package/dist/generated/agentSessions.d.ts +218 -0
  4. package/dist/generated/agentSessions.js +154 -0
  5. package/dist/generated/agents.d.ts +193 -0
  6. package/dist/generated/agents.js +166 -0
  7. package/dist/generated/apps.d.ts +87 -28
  8. package/dist/generated/apps.js +153 -41
  9. package/dist/generated/audit.d.ts +2 -2
  10. package/dist/generated/audit.js +3 -3
  11. package/dist/generated/browsers.d.ts +87 -28
  12. package/dist/generated/browsers.js +153 -41
  13. package/dist/generated/builds.d.ts +87 -28
  14. package/dist/generated/builds.js +153 -41
  15. package/dist/generated/ci.d.ts +87 -28
  16. package/dist/generated/ci.js +153 -41
  17. package/dist/generated/containers.d.ts +87 -28
  18. package/dist/generated/containers.js +153 -41
  19. package/dist/generated/desktops.d.ts +89 -30
  20. package/dist/generated/desktops.js +155 -43
  21. package/dist/generated/domains.d.ts +52 -15
  22. package/dist/generated/domains.js +74 -14
  23. package/dist/generated/egressIps.d.ts +6 -6
  24. package/dist/generated/egressIps.js +4 -4
  25. package/dist/generated/events.d.ts +4 -2
  26. package/dist/generated/events.js +3 -3
  27. package/dist/generated/feedback.d.ts +1 -1
  28. package/dist/generated/feedback.js +3 -3
  29. package/dist/generated/functions.d.ts +87 -28
  30. package/dist/generated/functions.js +153 -41
  31. package/dist/generated/identities.d.ts +2 -2
  32. package/dist/generated/identities.js +5 -5
  33. package/dist/generated/images.d.ts +68 -14
  34. package/dist/generated/images.js +96 -15
  35. package/dist/generated/index.d.ts +9 -0
  36. package/dist/generated/index.js +12 -0
  37. package/dist/generated/jobRuns.d.ts +11 -4
  38. package/dist/generated/jobRuns.js +6 -6
  39. package/dist/generated/jobs.d.ts +58 -9
  40. package/dist/generated/jobs.js +98 -14
  41. package/dist/generated/keys.d.ts +8 -6
  42. package/dist/generated/keys.js +6 -6
  43. package/dist/generated/me.d.ts +2 -2
  44. package/dist/generated/me.js +3 -3
  45. package/dist/generated/messages.d.ts +67 -0
  46. package/dist/generated/messages.js +17 -0
  47. package/dist/generated/networks.d.ts +4 -4
  48. package/dist/generated/networks.js +4 -4
  49. package/dist/generated/notebooks.d.ts +87 -28
  50. package/dist/generated/notebooks.js +153 -41
  51. package/dist/generated/otel.d.ts +2 -2
  52. package/dist/generated/otel.js +5 -5
  53. package/dist/generated/ports.d.ts +11 -11
  54. package/dist/generated/ports.js +8 -8
  55. package/dist/generated/previews.d.ts +50 -15
  56. package/dist/generated/previews.js +70 -18
  57. package/dist/generated/projects.d.ts +30 -6
  58. package/dist/generated/projects.js +13 -9
  59. package/dist/generated/roles.d.ts +11 -2
  60. package/dist/generated/roles.js +9 -5
  61. package/dist/generated/routes.js +1 -1
  62. package/dist/generated/runtime.d.ts +15 -3
  63. package/dist/generated/runtime.js +31 -18
  64. package/dist/generated/sandboxes.d.ts +213 -66
  65. package/dist/generated/sandboxes.js +171 -43
  66. package/dist/generated/secrets.d.ts +45 -6
  67. package/dist/generated/secrets.js +69 -9
  68. package/dist/generated/sessions.d.ts +1 -1
  69. package/dist/generated/sessions.js +4 -4
  70. package/dist/generated/signing.js +3 -1
  71. package/dist/generated/sites.d.ts +87 -28
  72. package/dist/generated/sites.js +153 -41
  73. package/dist/generated/snapshots.d.ts +70 -5
  74. package/dist/generated/snapshots.js +107 -7
  75. package/dist/generated/tunnels.d.ts +8 -8
  76. package/dist/generated/tunnels.js +4 -4
  77. package/dist/generated/usage.d.ts +57 -6
  78. package/dist/generated/usage.js +4 -4
  79. package/dist/generated/volumes.d.ts +72 -7
  80. package/dist/generated/volumes.js +114 -10
  81. package/dist/generated/webhooks.d.ts +2 -2
  82. package/dist/generated/webhooks.js +5 -5
  83. package/dist/generated/workspaces.d.ts +87 -28
  84. package/dist/generated/workspaces.js +153 -41
  85. package/dist/v2/bin.d.ts +2 -0
  86. package/dist/v2/bin.js +15 -0
  87. package/dist/v2/cli.d.ts +15 -2
  88. package/dist/v2/cli.js +158 -53
  89. package/dist/v2/json.d.ts +9 -0
  90. package/dist/v2/json.js +5 -0
  91. package/dist/v2/mcp.js +14 -1
  92. package/dist/v2/openapi.json +7695 -4382
  93. package/dist/v2/shims/fly.js +49 -13
  94. package/dist/v2/shims/morph.js +1 -1
  95. package/dist/v2/table.d.ts +7 -4
  96. package/dist/v2/table.js +97 -34
  97. 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 workspace's files. */
5
5
  export class WorkspaceFiles {
6
6
  #c;
@@ -90,6 +90,10 @@ export class WorkspaceProcesses {
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 workspace'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 Workspace {
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().workspaces.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 Workspaces(new Transport(options)).create(input, options);
233
+ }
134
234
  /** Returns a workspace. */
135
235
  async refresh(query = {}, options) {
136
- this.info = await (await this.#c.get(this.id, query, options)).info;
236
+ this.info = (await this.#c.get(this.id, query, options)).info;
137
237
  return this;
138
238
  }
139
239
  /** Deletes a workspace, its memory and its disk. */
@@ -166,7 +266,7 @@ export class Workspace {
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; a smaller size, or a sandbox that is not running, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. */
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 Workspace {
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 development environment: a machine running VS Code in the browser (code-server) on port 8080 over /workspace, reached at its private preview, as Codespaces and Gitpod give one. It pauses after 30 minutes with nothing happening, its memory kept. */
188
296
  export class Workspaces {
189
- #t;
297
+ transport;
190
298
  constructor(transport) {
191
- this.#t = transport;
299
+ this.transport = transport;
192
300
  }
193
301
  /** Creates a workspace. Asked again with the same Idempotency-Key, it returns the same workspace. */
194
302
  async create(input = {}, options) {
195
- return new Workspace(this, await this.#t.request("POST", `/v2/workspaces`, { body: input, options, idempotent: true }));
303
+ return new Workspace(this, await this.transport.request("POST", `/v2/workspaces`, { body: input, options, idempotent: true }));
196
304
  }
197
305
  /** Returns a workspace. */
198
306
  async get(id, query = {}, options) {
199
- return new Workspace(this, await this.#t.request("GET", `/v2/workspaces/${encodeURIComponent(id)}`, { query: { ...query }, options, idempotent: true }));
307
+ return new Workspace(this, await this.transport.request("GET", `/v2/workspaces/${encodeURIComponent(id)}`, { query: { ...query }, options, idempotent: true }));
200
308
  }
201
309
  /** Lists the project's workspaces, newest first. */
202
310
  list(query = {}, options) {
203
- return new Paginated((cursor) => this.#t.request("GET", `/v2/workspaces`, { query: { ...query, cursor }, options, idempotent: true }));
311
+ return new Paginated((cursor) => this.transport.request("GET", `/v2/workspaces`, { query: { ...query, cursor }, options, idempotent: true }));
204
312
  }
205
313
  /** Deletes a workspace, its memory and its disk. */
206
314
  delete(id, options) {
207
- return this.#t.request("DELETE", `/v2/workspaces/${encodeURIComponent(id)}`, { options });
315
+ return this.transport.request("DELETE", `/v2/workspaces/${encodeURIComponent(id)}`, { options });
208
316
  }
209
317
  /** Pauses a workspace with its memory and disk kept. A call to it resumes it. */
210
318
  pause(id, options) {
211
- return this.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:pause`, { options });
319
+ return this.transport.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:pause`, { options });
212
320
  }
213
321
  /** Resumes a paused workspace where it was, its memory and processes as they were. */
214
322
  resume(id, options) {
215
- return this.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:resume`, { options });
323
+ return this.transport.request("POST", `/v2/workspaces/${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 workspace 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.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:exec`, { body: input, options, idempotent: true, runs: true, runsSeconds: input.timeoutSeconds });
327
+ return this.transport.request("POST", `/v2/workspaces/${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.#t.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/files`, { query: { ...query }, raw: true, options, idempotent: true });
331
+ return this.transport.request("GET", `/v2/workspaces/${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.#t.request("PUT", `/v2/workspaces/${encodeURIComponent(id)}/files`, { data: toBytes(data), query: { ...query }, options });
335
+ return this.transport.request("PUT", `/v2/workspaces/${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.#t.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}/output`, { query: { ...query }, options, idempotent: true });
339
+ return this.transport.request("GET", `/v2/workspaces/${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.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}:write`, { body: input, options });
343
+ return this.transport.request("POST", `/v2/workspaces/${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.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}:signal`, { body: input, options, idempotent: true });
347
+ return this.transport.request("POST", `/v2/workspaces/${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/workspaces/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}:resize`, { body: input, options, idempotent: true });
240
352
  }
241
353
  /** Lists a workspace's processes, newest first: those running and those that ended lately. */
242
354
  listProcesses(id, options) {
243
- return this.#t.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/processes`, { options, idempotent: true });
355
+ return this.transport.request("GET", `/v2/workspaces/${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.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/files:remove`, { body: input, options });
359
+ return this.transport.request("POST", `/v2/workspaces/${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.#t.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/files/stat`, { query: { ...query }, options, idempotent: true });
363
+ return this.transport.request("GET", `/v2/workspaces/${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.#t.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/files/list`, { query: { ...query }, options, idempotent: true });
367
+ return this.transport.request("GET", `/v2/workspaces/${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 workspace 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 workspace. A paused workspace is woken first. */
258
370
  downloadFolder(id, query, options) {
259
- return this.#t.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/files/archive`, { query: { ...query }, raw: true, options, idempotent: true });
371
+ return this.transport.request("GET", `/v2/workspaces/${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 workspace 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 workspace is woken first. */
262
374
  uploadFolder(id, data, query, options) {
263
- return this.#t.request("PUT", `/v2/workspaces/${encodeURIComponent(id)}/files/archive`, { data: toBytes(data), query: { ...query }, options, idempotent: true });
375
+ return this.transport.request("PUT", `/v2/workspaces/${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 workspace, 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 workspace is woken first. */
266
378
  beginFolderUpload(id, input, options) {
267
- return this.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/files/archive/uploads`, { body: input, options });
379
+ return this.transport.request("POST", `/v2/workspaces/${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.#t.request("PUT", `/v2/workspaces/${encodeURIComponent(id)}/files/archive/uploads/${encodeURIComponent(upload)}`, { data: toBytes(data), query: { ...query }, options, idempotent: true });
383
+ return this.transport.request("PUT", `/v2/workspaces/${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.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/files/archive/uploads/${encodeURIComponent(upload)}:commit`, { options, idempotent: true });
387
+ return this.transport.request("POST", `/v2/workspaces/${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.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/files/archive/uploads/${encodeURIComponent(upload)}:abort`, { options, idempotent: true });
391
+ return this.transport.request("POST", `/v2/workspaces/${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.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/files:mkdir`, { body: input, options, idempotent: true });
395
+ return this.transport.request("POST", `/v2/workspaces/${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.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/files:rename`, { body: input, options });
399
+ return this.transport.request("POST", `/v2/workspaces/${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 workspace. A paused workspace is woken for it unless wake is false. */
290
402
  link(id, input, options) {
291
- return this.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/files:link`, { body: input, options });
403
+ return this.transport.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/files:link`, { body: input, options });
292
404
  }
293
405
  /** Ends every file link made for a workspace so far; links made after work. */
294
406
  revokeLinks(id, options) {
295
- return this.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/files:revokeLinks`, { options });
407
+ return this.transport.request("POST", `/v2/workspaces/${encodeURIComponent(id)}/files:revokeLinks`, { options });
296
408
  }
297
409
  /** Returns where a workspace may connect out. */
298
410
  getNetwork(id, options) {
299
- return this.#t.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/network`, { options, idempotent: true });
411
+ return this.transport.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/network`, { options, idempotent: true });
300
412
  }
301
413
  /** Returns a workspace's CPU, memory, disks and pressure, as its host reads them from the workspace's own cgroup over a fifth of a second: never a call into the workspace, 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.#t.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/metrics`, { query: { ...query }, options, idempotent: true });
415
+ return this.transport.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/metrics`, { query: { ...query }, options, idempotent: true });
304
416
  }
305
417
  /** Replaces where a workspace 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.#t.request("PUT", `/v2/workspaces/${encodeURIComponent(id)}/network`, { body: input, options });
419
+ return this.transport.request("PUT", `/v2/workspaces/${encodeURIComponent(id)}/network`, { body: input, options });
308
420
  }
309
421
  /** Copies a workspace 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.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:fork`, { body: input, options, idempotent: true });
423
+ return this.transport.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:fork`, { body: input, options, idempotent: true });
312
424
  }
313
425
  /** Keeps a workspace's memory and disk as they are now, a snapshot to start workspaces from; with `image`, its disk alone as that image's next version. The workspace runs on. Asked again with the same Idempotency-Key, it returns the same snapshot. */
314
426
  snapshot(id, input = {}, options) {
315
- return this.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:snapshot`, { body: input, options, idempotent: true });
427
+ return this.transport.request("POST", `/v2/workspaces/${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; a smaller size, or a sandbox that is not running, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. */
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.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:update`, { body: input, options });
431
+ return this.transport.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:update`, { body: input, options });
320
432
  }
321
433
  /** Returns what a workspace'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 workspace is resumed first. */
322
434
  screenshot(id, query = {}, options) {
323
- return this.#t.request("GET", `/v2/workspaces/${encodeURIComponent(id)}/screenshot`, { query: { ...query }, raw: true, options, idempotent: true });
435
+ return this.transport.request("GET", `/v2/workspaces/${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 workspace'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 workspace is resumed first. */
326
438
  act(id, input, options) {
327
- return this.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:act`, { body: input, options });
439
+ return this.transport.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:act`, { body: input, options });
328
440
  }
329
441
  /** Runs a cell of Python in a workspace 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 workspace is resumed first. */
330
442
  runCode(id, input, options) {
331
- return this.#t.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:runCode`, { body: input, options });
443
+ return this.transport.request("POST", `/v2/workspaces/${encodeURIComponent(id)}:runCode`, { body: input, options });
332
444
  }
333
445
  }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/v2/bin.js ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /* The `runtime` and `withruntime` commands. This file only runs the CLI: npx starts it by a link named for the
3
+ command (node_modules/.bin/withruntime), so cli.ts never guesses from its own name whether it was started
4
+ (1.0.0's guard matched /runtime and /cli.js, and `npx withruntime ...` did nothing at all). */
5
+ import { main } from "./cli.js";
6
+ // exitCode, never exit(): a pipe's stdout on macOS is written after the call returns, and exit() cut --help at 64 KiB.
7
+ // A reader that closed its end (`runtime ... | head`) has all it wanted.
8
+ process.stdout.on("error", (e) => {
9
+ if (e.code !== "EPIPE")
10
+ throw e;
11
+ process.exit(process.exitCode ?? 0);
12
+ });
13
+ void main(process.argv.slice(2)).then((code) => {
14
+ process.exitCode = code;
15
+ });
package/dist/v2/cli.d.ts CHANGED
@@ -1,7 +1,20 @@
1
- #!/usr/bin/env node
2
- import { type Command } from "./table.js";
1
+ import { type Command, type Flag } from "./table.js";
2
+ /** One flag's text as its field's type in the API's description, refused here, before anything is sent, when it is
3
+ * not one. 18 Nov 2026: a number went as its text (`--memory-gb 4` as "4"), and the API refused it. */
4
+ export declare function value(f: Flag, raw: string): unknown;
5
+ /** A command's secret field, from --from-file's file, or else standard input when it is piped in: one trailing
6
+ * newline dropped (what `echo` and editors add). Left out when neither gives one, as a set that keeps the value. */
7
+ export declare function readSecret(c: Command, args: Record<string, unknown>, stdin: () => string | undefined): void;
3
8
  /** argv after the command as its arguments by wire name: positionals its
4
9
  * path's parts, flags its fields, and after `--`, its command (`cmd`) when
5
10
  * it takes one. */
6
11
  export declare function parse(c: Command, argv: string[]): Record<string, unknown>;
12
+ /** The commands this file serves itself, ahead of the API's: each by its name, given the API's URL and what follows. */
13
+ export declare const own: Record<string, (baseUrl: string, rest: string[]) => number | Promise<number>>;
14
+ /** The API's command argv names (a shortcut by its name, a verb by its product and verb), and what follows it; an
15
+ * argv that names none is refused, with the verbs its product has. */
16
+ export declare function find(commands: Command[], argv: string[]): {
17
+ c: Command;
18
+ rest: string[];
19
+ };
7
20
  export declare function main(argv: string[]): Promise<number>;