@machinen/runtime 0.1.2 → 0.2.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/API.md CHANGED
@@ -1448,10 +1448,17 @@ Called with each stderr chunk as it arrives (pass-through tee).
1448
1448
 
1449
1449
  > **stdout**: `string`
1450
1450
 
1451
+ Concatenated stdout bytes, decoded as UTF-8. Always `""` when the
1452
+ caller passed `onStdout` — streaming callers already have the
1453
+ bytes and a parallel buffered copy would defeat the streaming
1454
+ (and at multi-GB volumes would crash with ERR_STRING_TOO_LONG).
1455
+
1451
1456
  ##### stderr
1452
1457
 
1453
1458
  > **stderr**: `string`
1454
1459
 
1460
+ Same shape as `stdout` for the stderr channel + `onStderr`.
1461
+
1455
1462
  ***
1456
1463
 
1457
1464
  ### VsockExecPtyOptions
package/dist/index.d.ts CHANGED
@@ -19,7 +19,14 @@ interface VsockExecOptions {
19
19
  }
20
20
  interface VsockExecResult {
21
21
  exitCode: number;
22
+ /**
23
+ * Concatenated stdout bytes, decoded as UTF-8. Always `""` when the
24
+ * caller passed `onStdout` — streaming callers already have the
25
+ * bytes and a parallel buffered copy would defeat the streaming
26
+ * (and at multi-GB volumes would crash with ERR_STRING_TOO_LONG).
27
+ */
22
28
  stdout: string;
29
+ /** Same shape as `stdout` for the stderr channel + `onStderr`. */
23
30
  stderr: string;
24
31
  }
25
32
  declare const VsockExec: {
package/dist/index.js CHANGED
@@ -877,11 +877,17 @@ async function runOnSocket(socket, cmd, opts) {
877
877
  buf = buf.subarray(take);
878
878
  awaitingBytes -= take;
879
879
  if (payloadTag === "O") {
880
- stdoutBufs.push(chunk);
881
- opts.onStdout?.(chunk);
880
+ if (opts.onStdout) {
881
+ opts.onStdout(chunk);
882
+ } else {
883
+ stdoutBufs.push(chunk);
884
+ }
882
885
  } else if (payloadTag === "E") {
883
- stderrBufs.push(chunk);
884
- opts.onStderr?.(chunk);
886
+ if (opts.onStderr) {
887
+ opts.onStderr(chunk);
888
+ } else {
889
+ stderrBufs.push(chunk);
890
+ }
885
891
  }
886
892
  if (awaitingBytes === 0) {
887
893
  payloadTag = null;