The best way to control Claude Code, Codex and more from any computer or phone
| 1 | diff --git a/dist/src/connection/spawn.d.ts b/dist/src/connection/spawn.d.ts |
| 2 | index b67e690eae07748e6aee2c8ee59bbfef13b2eea8..581ef3e9184da89cde8471a8fe03c86209ac7c81 100644 |
| 3 | --- a/dist/src/connection/spawn.d.ts |
| 4 | +++ b/dist/src/connection/spawn.d.ts |
| 5 | @@ -20,6 +20,8 @@ export interface SpawnMspConnectionOptions { |
| 6 | readonly onStderr?: (chunk: string) => void; |
| 7 | /** See {@link MuseServeChildOptions.shutdownTimeoutMs}. */ |
| 8 | readonly shutdownTimeoutMs?: number; |
| 9 | + /** Raw process exit, before inherited stdio drains and `exited` settles. */ |
| 10 | + readonly onProcessExit?: (exit: ProcessExit) => void; |
| 11 | } |
| 12 | /** |
| 13 | * How the host process ended: its exit code, or the signal that ended it. |
| 14 | @@ -74,6 +76,8 @@ export interface MuseServeChildOptions { |
| 15 | * `0..2147483647`; anything else throws `RangeError` at spawn. |
| 16 | */ |
| 17 | readonly shutdownTimeoutMs?: number; |
| 18 | + /** Raw process exit, before inherited stdio drains and `exited` settles. */ |
| 19 | + readonly onProcessExit?: (exit: ProcessExit) => void; |
| 20 | /** |
| 21 | * Deterministic-test seam; production always uses `child_process.spawn`. |
| 22 | * A stub here observes the exact options the call site passes, so a |
| 23 | diff --git a/dist/src/connection/spawn.js b/dist/src/connection/spawn.js |
| 24 | index 28aeb6246ba937c5321f1393dc120eface0707f3..0c835bb9d45a73eacd6a35b5e589191f04104537 100644 |
| 25 | --- a/dist/src/connection/spawn.js |
| 26 | +++ b/dist/src/connection/spawn.js |
| 27 | @@ -390,7 +390,10 @@ export class MuseServeChild { |
| 28 | detached: ownsProcessGroup, |
| 29 | }); |
| 30 | const spawnChild = options.spawnFn ?? spawn; |
| 31 | - return new MuseServeChild(spawnChild(options.museBin, [...(options.args ?? [])], spawnOptions), options.onStderr, options.shutdownTimeoutMs, ownsProcessGroup); |
| 32 | + const child = spawnChild(options.museBin, [...(options.args ?? [])], spawnOptions); |
| 33 | + if (options.onProcessExit !== undefined) |
| 34 | + child.once("exit", (code, signal) => options.onProcessExit({ code, signal })); |
| 35 | + return new MuseServeChild(child, options.onStderr, options.shutdownTimeoutMs, ownsProcessGroup); |
| 36 | } |
| 37 | get stderrTail() { |
| 38 | return this.#tail.lines(); |
| 39 | @@ -414,6 +417,7 @@ export class MspHandshake { |
| 40 | constructor(options) { |
| 41 | this.child = MuseServeChild.spawn({ |
| 42 | museBin: options.command, |
| 43 | + ...(options.onProcessExit === undefined ? {} : { onProcessExit: options.onProcessExit }), |
| 44 | ...(options.args === undefined ? {} : { args: options.args }), |
| 45 | ...(options.cwd === undefined ? {} : { cwd: options.cwd }), |
| 46 | ...(options.env === undefined ? {} : { env: options.env }), |