The best way to control Claude Code, Codex and more from any computer or phone
| 1 | diff --git a/dist/NodeChildProcessSpawner.d.ts b/dist/NodeChildProcessSpawner.d.ts |
| 2 | index 213be4fa2647d800b320fa483c9ede801366fd73..bb7a2bb97e976f85af4760a7299db39506318155 100644 |
| 3 | --- a/dist/NodeChildProcessSpawner.d.ts |
| 4 | +++ b/dist/NodeChildProcessSpawner.d.ts |
| 5 | @@ -31,6 +31,8 @@ |
| 6 | * @stability unstable |
| 7 | * @since 4.0.0 |
| 8 | */ |
| 9 | +import type * as NodeChildProcess from "node:child_process"; |
| 10 | +import type { Readable, Writable } from "node:stream"; |
| 11 | import type * as Arr from "effect/Array"; |
| 12 | import * as FileSystem from "effect/FileSystem"; |
| 13 | import * as Layer from "effect/Layer"; |
| 14 | @@ -45,6 +47,19 @@ import { ChildProcessSpawner } from "effect/process/ChildProcessSpawner"; |
| 15 | * @since 4.0.0 |
| 16 | */ |
| 17 | export declare const layer: Layer.Layer<ChildProcessSpawner, never, FileSystem.FileSystem | Path.Path>; |
| 18 | +export interface SpawnedChildProcess extends NodeJS.EventEmitter { |
| 19 | + readonly pid?: number | undefined; |
| 20 | + readonly exitCode: number | null; |
| 21 | + readonly signalCode: NodeJS.Signals | null; |
| 22 | + readonly stdin: Writable | null; |
| 23 | + readonly stdout: Readable | null; |
| 24 | + readonly stderr: Readable | null; |
| 25 | + readonly stdio: ReadonlyArray<Readable | Writable | null | undefined>; |
| 26 | + kill(signal?: NodeJS.Signals | number): boolean; |
| 27 | + ref(): void; |
| 28 | + unref(): void; |
| 29 | +} |
| 30 | +export declare const layerWithSpawn: (spawnProcess: (command: string, args: ReadonlyArray<string>, options: NodeChildProcess.SpawnOptions) => SpawnedChildProcess) => Layer.Layer<ChildProcessSpawner, never, FileSystem.FileSystem | Path.Path>; |
| 31 | /** |
| 32 | * Result of flattening a pipeline of commands. |
| 33 | * |
| 34 | diff --git a/dist/NodeChildProcessSpawner.js b/dist/NodeChildProcessSpawner.js |
| 35 | index 08d50b16dfe564551f1bffc7cae2d3b53805e172..fbecacc8b39a9eab7725a799aa5019c36bcc32ab 100644 |
| 36 | --- a/dist/NodeChildProcessSpawner.js |
| 37 | +++ b/dist/NodeChildProcessSpawner.js |
| 38 | @@ -81,16 +81,26 @@ const isProcessAlive = (command, childProcess) => { |
| 39 | return isUnsignallableProcessGroup(error); |
| 40 | } |
| 41 | }; |
| 42 | -const taskkill = (childProcess, onExit = () => {}) => { |
| 43 | - if (hasExited(childProcess)) { |
| 44 | - onExit(null); |
| 45 | - return; |
| 46 | - } |
| 47 | - NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { |
| 48 | - windowsHide: true |
| 49 | - }, onExit); |
| 50 | -}; |
| 51 | -const make = /*#__PURE__*/Effect.gen(function* () { |
| 52 | +const makeWithSpawn = spawnProcess => Effect.gen(function* () { |
| 53 | + // Starts taskkill through the injected spawner so it gets the same off-thread launch as commands. |
| 54 | + const taskkill = (childProcess, onExit = () => {}) => { |
| 55 | + if (hasExited(childProcess)) { |
| 56 | + onExit(null); |
| 57 | + return; |
| 58 | + } |
| 59 | + let done = false; |
| 60 | + const finish = error => { |
| 61 | + if (done) return; |
| 62 | + done = true; |
| 63 | + onExit(error); |
| 64 | + }; |
| 65 | + const killer = spawnProcess("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { |
| 66 | + stdio: "ignore", |
| 67 | + windowsHide: true |
| 68 | + }); |
| 69 | + killer.on("error", finish); |
| 70 | + killer.on("exit", code => finish(code === 0 ? null : new Error(`taskkill exited with code ${code}`))); |
| 71 | + }; |
| 72 | const fs = yield* FileSystem.FileSystem; |
| 73 | const path = yield* Path.Path; |
| 74 | const resolveWorkingDirectory = Effect.fnUntraced(function* (options) { |
| 75 | @@ -335,7 +345,7 @@ const make = /*#__PURE__*/Effect.gen(function* () { |
| 76 | }; |
| 77 | const spawn = (command, spawnOptions) => Effect.callback(resume => { |
| 78 | const deferred = Deferred.makeUnsafe(); |
| 79 | - const handle = NodeChildProcess.spawn(command.command, command.args.map(unwrap), spawnOptions); |
| 80 | + const handle = spawnProcess(command.command, command.args.map(unwrap), spawnOptions); |
| 81 | handle.on("error", error => { |
| 82 | // Node copies the arguments into `spawnargs`. |
| 83 | if (command.args.some(Redacted.isRedacted)) { |
| 84 | @@ -665,7 +675,8 @@ const make = /*#__PURE__*/Effect.gen(function* () { |
| 85 | * @category layers |
| 86 | * @since 4.0.0 |
| 87 | */ |
| 88 | -export const layer = /*#__PURE__*/Layer.effect(ChildProcessSpawner, make); |
| 89 | +export const layer = /*#__PURE__*/Layer.effect(ChildProcessSpawner, /*#__PURE__*/makeWithSpawn(NodeChildProcess.spawn)); |
| 90 | +export const layerWithSpawn = spawnProcess => Layer.effect(ChildProcessSpawner, makeWithSpawn(spawnProcess)); |
| 91 | /** |
| 92 | * Flattens a `Command` into an array of `StandardCommand`s along with pipe |
| 93 | * options for each connection. |