disk 1.15.1 → 1.16.0

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 CHANGED
@@ -186,6 +186,37 @@ await d.removeUser("token", user.identifier!);
186
186
  await d.delete();
187
187
  ```
188
188
 
189
+ ### Streaming an exec (Node.js)
190
+
191
+ With `stream: true`, `archil.exec()` streams the command's input and output
192
+ while it runs, instead of returning them when it exits. It takes the same
193
+ options as a waiting exec, plus the process options `sandbox.run()` takes, and
194
+ resolves once the command has started with the same handle `sandbox.run()`
195
+ returns:
196
+
197
+ ```ts
198
+ const proc = await archil.exec({
199
+ stream: true,
200
+ command: "python3 train.py",
201
+ disks: { data: d }, // mounted at /mnt/archil/data, as for a waiting exec
202
+ baseImage: "python:3.12-slim",
203
+ vcpuCount: 4,
204
+ memSizeMib: 8192,
205
+ timeoutSeconds: 3600,
206
+ });
207
+ for await (const chunk of proc.output) {
208
+ process.stdout.write(chunk.data);
209
+ }
210
+ const { exitCode } = await proc.wait();
211
+ ```
212
+
213
+ Send input with `sendInput()` and end it with `closeStdin()`. Streamed execs
214
+ share connections: up to 32 run at once on one, and later ones reuse it, so an
215
+ exec after the first skips connection setup. `kill()` and `disconnect()` both
216
+ stop the command and its VM. `disks` may be empty for a command that needs no
217
+ disk, which takes the `workspace:exec` permission. Streaming needs Node.js or
218
+ Bun, because a browser WebSocket cannot send the API key.
219
+
189
220
  ### Private certificate authorities (Node.js)
190
221
 
191
222
  For BYOC endpoints signed by a private CA, configure trust on the client:
@@ -513,8 +544,8 @@ replay buffered output from the beginning, or pass `{ offset: process.cursor }`
513
544
  to continue where the previous connection stopped. Iterating `output` yields
514
545
  raw bytes with their stream and absolute offset; one iterator may consume each
515
546
  handle. Call `closeStdin()` to deliver EOF
516
- to a non-terminal process. `sendInput()` streams large input as 1 MiB WebSocket
517
- frames. Set `collectOutput: false` to stream through `output` without
547
+ to a non-terminal process. `sendInput()` resolves once the runtime has
548
+ accepted the input, waiting while the process is not reading it. Set `collectOutput: false` to stream through `output` without
518
549
  retaining decoded output in the process handle or result. The `onOutput`
519
550
  option is deprecated; iterate `output` instead. Resize and kill use
520
551
  separate one-shot process controls, so they do not wait behind stdin.