@orkestrel/process 0.0.8 → 0.0.10
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 +13 -7
- package/dist/src/core/index.cjs +24 -13
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +155 -141
- package/dist/src/core/index.d.ts +155 -141
- package/dist/src/core/index.js +24 -13
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +833 -788
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +328 -128
- package/dist/src/server/index.d.ts +328 -128
- package/dist/src/server/index.js +832 -788
- package/dist/src/server/index.js.map +1 -1
- package/package.json +11 -11
package/dist/src/core/index.d.ts
CHANGED
|
@@ -47,33 +47,33 @@ export declare function createInvalidError(subject: string, value: unknown): Pro
|
|
|
47
47
|
export declare function createProtocolError(id: string): ProcessError;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Configures a detached fire-and-forget spawn.
|
|
51
51
|
*
|
|
52
52
|
* @remarks
|
|
53
53
|
* A detached child owns no stdio and is never awaited, so the contract carries only the directory it
|
|
54
54
|
* starts in. Its environment comes from the command's own `environment` and `isolated`.
|
|
55
55
|
*/
|
|
56
56
|
export declare interface DetachOptions {
|
|
57
|
-
/**
|
|
57
|
+
/** Names the working directory. Default: the current working directory. */
|
|
58
58
|
readonly workspace?: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Supplies the lookup inputs for resolving a command file to an executable path.
|
|
63
63
|
*
|
|
64
64
|
* @remarks
|
|
65
65
|
* `workspace` is searched before `PATH`, matching Windows command semantics. `environment` is the
|
|
66
66
|
* child's effective environment, so the lookup reads the same `PATH` and `PATHEXT` the child will.
|
|
67
67
|
*/
|
|
68
68
|
export declare interface ExecutableOptions {
|
|
69
|
-
/**
|
|
69
|
+
/** Names the directory searched first. Default: the current working directory. */
|
|
70
70
|
readonly workspace?: string;
|
|
71
|
-
/**
|
|
71
|
+
/** Holds the child's effective environment. Default: the parent process environment. */
|
|
72
72
|
readonly environment?: Readonly<Record<string, string | undefined>>;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* Represents the captured bytes and terminal facts one settled {@link ExecuteResult} is built from.
|
|
77
77
|
*
|
|
78
78
|
* @remarks
|
|
79
79
|
* Each byte field is trimmed to `limit` on a code-point boundary when the result is built, so a
|
|
@@ -81,13 +81,15 @@ export declare interface ExecutableOptions {
|
|
|
81
81
|
* that ended the run, when one did; its presence alone marks the run failed.
|
|
82
82
|
*/
|
|
83
83
|
export declare interface ExecuteInput {
|
|
84
|
-
/**
|
|
84
|
+
/** Holds the diagnostic command line. */
|
|
85
85
|
readonly command: string;
|
|
86
|
-
/**
|
|
86
|
+
/** Holds the retained standard-output bytes. */
|
|
87
87
|
readonly stdout: Uint8Array;
|
|
88
|
-
/**
|
|
88
|
+
/** Holds the retained standard-error bytes. */
|
|
89
89
|
readonly stderr: Uint8Array;
|
|
90
|
+
/** Holds the exit code. A spawn fault reports the host's negative errno for `execute` and `null` for `executeSync`. */
|
|
90
91
|
readonly code: number | null;
|
|
92
|
+
/** Holds the terminating signal name, or `null` when the process exited on its own. */
|
|
91
93
|
readonly signal: string | null;
|
|
92
94
|
/** If `true`, the run's own timeout elapsed; if `false`, it did not. */
|
|
93
95
|
readonly expired: boolean;
|
|
@@ -95,14 +97,14 @@ export declare interface ExecuteInput {
|
|
|
95
97
|
readonly aborted: boolean;
|
|
96
98
|
/** If `true`, a stream exceeded `limit`; if `false`, neither did. */
|
|
97
99
|
readonly truncated: boolean;
|
|
98
|
-
/**
|
|
100
|
+
/** Sets the maximum retained bytes for each stream. */
|
|
99
101
|
readonly limit: number;
|
|
100
|
-
/**
|
|
102
|
+
/** Carries the host fault that ended the run, when one did. */
|
|
101
103
|
readonly cause?: unknown;
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
/**
|
|
105
|
-
*
|
|
107
|
+
* Configures a one-shot run.
|
|
106
108
|
*
|
|
107
109
|
* @remarks
|
|
108
110
|
* A run is a fire-and-collect function, not a lifecycle entity, so it carries no emitter. `strict`
|
|
@@ -117,26 +119,26 @@ export declare interface ExecuteInput {
|
|
|
117
119
|
* that throws strands no process.
|
|
118
120
|
*/
|
|
119
121
|
export declare interface ExecuteOptions {
|
|
120
|
-
/**
|
|
122
|
+
/** Names the working directory. Default: the current working directory. */
|
|
121
123
|
readonly workspace?: string;
|
|
122
|
-
/**
|
|
124
|
+
/** Holds environment overrides merged over the parent environment; an `undefined` value unsets a key. */
|
|
123
125
|
readonly environment?: Readonly<Record<string, string | undefined>>;
|
|
124
|
-
/**
|
|
126
|
+
/** Holds the standard-input payload written to the child, including any NUL characters. */
|
|
125
127
|
readonly input?: string;
|
|
126
|
-
/**
|
|
128
|
+
/** Sets the milliseconds before the child is terminated. `0` or omitted disables the timeout. */
|
|
127
129
|
readonly timeout?: number;
|
|
128
|
-
/**
|
|
130
|
+
/** Sets the cooperative POSIX window between `SIGTERM` and `SIGKILL` when terminating. Default: {@link PROCESS_GRACE}. */
|
|
129
131
|
readonly grace?: number;
|
|
130
|
-
/**
|
|
132
|
+
/** Terminates the run and reports `aborted` when this signal aborts. */
|
|
131
133
|
readonly signal?: AbortSignal;
|
|
132
|
-
/** If `false`, resolve with the result
|
|
134
|
+
/** If `true`, reject on failure; if `false`, resolve with the result instead. Default: `true`. */
|
|
133
135
|
readonly strict?: boolean;
|
|
134
|
-
/**
|
|
136
|
+
/** Sets the maximum captured bytes for stdout and for stderr, each. Default: {@link PROCESS_OUTPUT}. */
|
|
135
137
|
readonly limit?: number;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
/**
|
|
139
|
-
*
|
|
141
|
+
* Represents the settled outcome of a one-shot run: the buffered output and the terminal state.
|
|
140
142
|
*
|
|
141
143
|
* @remarks
|
|
142
144
|
* `failed` is `true` when the run timed out, was aborted, ended on a host fault, was ended by a
|
|
@@ -150,27 +152,28 @@ export declare interface ExecuteOptions {
|
|
|
150
152
|
* the host's negative errno for `execute`. A spawn fault reports `null` for `executeSync`.
|
|
151
153
|
*/
|
|
152
154
|
export declare interface ExecuteResult {
|
|
153
|
-
/**
|
|
155
|
+
/** Holds the command line that was run, for diagnostics. */
|
|
154
156
|
readonly command: string;
|
|
155
|
-
/**
|
|
157
|
+
/** Holds the captured standard output, byte-bounded by `limit`. */
|
|
156
158
|
readonly stdout: string;
|
|
157
|
-
/**
|
|
159
|
+
/** Holds the captured standard error, byte-bounded by `limit`. */
|
|
158
160
|
readonly stderr: string;
|
|
159
|
-
/**
|
|
161
|
+
/** Holds the exit code. A spawn fault reports the host's negative errno for `execute` and `null` for `executeSync`. */
|
|
160
162
|
readonly code: number | null;
|
|
163
|
+
/** Holds the terminating signal name, or `null` when the process exited on its own. */
|
|
161
164
|
readonly signal: string | null;
|
|
162
|
-
/**
|
|
165
|
+
/** Reports whether the run failed to complete successfully. */
|
|
163
166
|
readonly failed: boolean;
|
|
164
|
-
/**
|
|
167
|
+
/** Reports whether the run's `timeout` elapsed before completion. */
|
|
165
168
|
readonly expired: boolean;
|
|
166
|
-
/**
|
|
169
|
+
/** Reports whether the caller's `signal` aborted the run before completion. */
|
|
167
170
|
readonly aborted: boolean;
|
|
168
|
-
/**
|
|
171
|
+
/** Reports whether either captured stream omitted output because it exceeded `limit`. */
|
|
169
172
|
readonly truncated: boolean;
|
|
170
173
|
}
|
|
171
174
|
|
|
172
175
|
/**
|
|
173
|
-
*
|
|
176
|
+
* Configures a synchronous one-shot run.
|
|
174
177
|
*
|
|
175
178
|
* @remarks
|
|
176
179
|
* The synchronous host offers neither a cooperative termination window nor in-flight cancellation,
|
|
@@ -181,17 +184,17 @@ export declare interface ExecuteResult {
|
|
|
181
184
|
* `input` is standard-input payload and carries no NUL restriction.
|
|
182
185
|
*/
|
|
183
186
|
export declare interface ExecuteSyncOptions {
|
|
184
|
-
/**
|
|
187
|
+
/** Names the working directory. Default: the current working directory. */
|
|
185
188
|
readonly workspace?: string;
|
|
186
|
-
/**
|
|
189
|
+
/** Holds environment overrides merged over the parent environment; an `undefined` value unsets a key. */
|
|
187
190
|
readonly environment?: Readonly<Record<string, string | undefined>>;
|
|
188
|
-
/**
|
|
191
|
+
/** Holds the standard-input payload written to the child, including any NUL characters. */
|
|
189
192
|
readonly input?: string;
|
|
190
|
-
/**
|
|
193
|
+
/** Sets the milliseconds before the host kills the root process alone. `0` or omitted disables the timeout. */
|
|
191
194
|
readonly timeout?: number;
|
|
192
|
-
/** If `false`, return the result
|
|
195
|
+
/** If `true`, throw on failure; if `false`, return the result instead. Default: `true`. */
|
|
193
196
|
readonly strict?: boolean;
|
|
194
|
-
/**
|
|
197
|
+
/** Sets the maximum captured bytes for stdout and for stderr, each. Default: {@link PROCESS_OUTPUT}. */
|
|
195
198
|
readonly limit?: number;
|
|
196
199
|
}
|
|
197
200
|
|
|
@@ -206,7 +209,7 @@ export declare interface ExecuteSyncOptions {
|
|
|
206
209
|
* plain or property-only lookalike.
|
|
207
210
|
*
|
|
208
211
|
* @param value - The value to inspect
|
|
209
|
-
* @returns True
|
|
212
|
+
* @returns True if the value is a `ProcessError` instance; false otherwise
|
|
210
213
|
*
|
|
211
214
|
* @example
|
|
212
215
|
* ```ts
|
|
@@ -216,14 +219,14 @@ export declare interface ExecuteSyncOptions {
|
|
|
216
219
|
*/
|
|
217
220
|
export declare function isProcessError(value: unknown): value is ProcessError;
|
|
218
221
|
|
|
219
|
-
/**
|
|
222
|
+
/** Names the default soft high-water mark in bytes for a supervised {@link ProcessInterface} line backlog. */
|
|
220
223
|
export declare const PROCESS_BACKLOG = 10485760;
|
|
221
224
|
|
|
222
|
-
/**
|
|
225
|
+
/** Names the window in milliseconds a termination waits for the child's native exit after the final kill. */
|
|
223
226
|
export declare const PROCESS_CONFIRMATION = 5000;
|
|
224
227
|
|
|
225
228
|
/**
|
|
226
|
-
*
|
|
229
|
+
* Names the default window in milliseconds the package waits for the child's read ends to close after
|
|
227
230
|
* the child's native exit or after a termination this package initiated, before cutting them off.
|
|
228
231
|
*
|
|
229
232
|
* @remarks
|
|
@@ -239,26 +242,26 @@ export declare const PROCESS_CONFIRMATION = 5000;
|
|
|
239
242
|
*/
|
|
240
243
|
export declare const PROCESS_DRAIN = 1000;
|
|
241
244
|
|
|
242
|
-
/**
|
|
245
|
+
/** Lists the machine-readable failure categories a {@link ProcessError} carries, in declaration order. */
|
|
243
246
|
export declare const PROCESS_ERROR_CODES: readonly ["spawn", "timeout", "input", "duplicate", "protocol", "invalid"];
|
|
244
247
|
|
|
245
|
-
/**
|
|
248
|
+
/** Names the default maximum retained stderr tail in bytes for a supervised {@link ProcessInterface}. */
|
|
246
249
|
export declare const PROCESS_EVIDENCE = 2048;
|
|
247
250
|
|
|
248
|
-
/**
|
|
251
|
+
/** Names the default cooperative POSIX window in milliseconds between `SIGTERM` and `SIGKILL` during termination. */
|
|
249
252
|
export declare const PROCESS_GRACE = 5000;
|
|
250
253
|
|
|
251
|
-
/**
|
|
254
|
+
/** Names the default maximum captured bytes for a one-shot run's stdout and stderr, each. */
|
|
252
255
|
export declare const PROCESS_OUTPUT = 10485760;
|
|
253
256
|
|
|
254
|
-
/**
|
|
257
|
+
/** Lists the executable extensions a Windows lookup applies when the environment declares no `PATHEXT`. */
|
|
255
258
|
export declare const PROCESS_PATHEXT = ".COM;.EXE;.BAT;.CMD";
|
|
256
259
|
|
|
257
|
-
/**
|
|
260
|
+
/** Names the largest timer delay in milliseconds the host schedules without truncating it to one. */
|
|
258
261
|
export declare const PROCESS_TIMER = 2147483647;
|
|
259
262
|
|
|
260
263
|
/**
|
|
261
|
-
*
|
|
264
|
+
* Declares the public contracts for `@orkestrel/process`: a typed child-process toolkit.
|
|
262
265
|
*
|
|
263
266
|
* @remarks
|
|
264
267
|
* The tiers divide by lifetime:
|
|
@@ -280,7 +283,7 @@ export declare const PROCESS_TIMER = 2147483647;
|
|
|
280
283
|
* and plain `string` signal names). The Node implementations live in `@orkestrel/process/server`.
|
|
281
284
|
*/
|
|
282
285
|
/**
|
|
283
|
-
*
|
|
286
|
+
* Represents one spawnable command: the executable, its argument vector, and optional environment overrides
|
|
284
287
|
* and initial standard input.
|
|
285
288
|
*
|
|
286
289
|
* @remarks
|
|
@@ -298,19 +301,30 @@ export declare interface ProcessCommand {
|
|
|
298
301
|
readonly arguments: readonly string[];
|
|
299
302
|
readonly environment?: Readonly<Record<string, string | undefined>>;
|
|
300
303
|
readonly input?: string;
|
|
301
|
-
/** If `true`, exclude the parent environment;
|
|
304
|
+
/** If `true`, exclude the parent environment; if `false` or omitted, the overrides layer over it. On POSIX `true` leaves no `PATH`, while Windows libuv still injects a host set. */
|
|
302
305
|
readonly isolated?: boolean;
|
|
303
306
|
}
|
|
304
307
|
|
|
305
|
-
/**
|
|
308
|
+
/**
|
|
309
|
+
* Represents a child-process failure with a stable machine-readable category.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```ts
|
|
313
|
+
* const error = new ProcessError('git status refused', {
|
|
314
|
+
* code: 'invalid',
|
|
315
|
+
* context: { command: 'git status' },
|
|
316
|
+
* })
|
|
317
|
+
* error.code // 'invalid'
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
306
320
|
export declare class ProcessError extends Error {
|
|
307
321
|
readonly name = "ProcessError";
|
|
308
322
|
readonly code: ProcessErrorCode;
|
|
309
323
|
readonly context?: ProcessErrorContext;
|
|
310
|
-
/**
|
|
324
|
+
/** Carries the buffered run outcome, present when a one-shot run produced the failure. */
|
|
311
325
|
readonly result?: ExecuteResult;
|
|
312
326
|
/**
|
|
313
|
-
*
|
|
327
|
+
* Creates a process error.
|
|
314
328
|
*
|
|
315
329
|
* @param message - Human-readable failure description
|
|
316
330
|
* @param options - Machine-readable category, optional context, optional cause, and optional run result
|
|
@@ -318,37 +332,37 @@ export declare class ProcessError extends Error {
|
|
|
318
332
|
constructor(message: string, options: ProcessErrorOptions);
|
|
319
333
|
}
|
|
320
334
|
|
|
321
|
-
/**
|
|
335
|
+
/** Names the machine-readable {@link ProcessError} categories, derived from {@link PROCESS_ERROR_CODES}. */
|
|
322
336
|
export declare type ProcessErrorCode = (typeof PROCESS_ERROR_CODES)[number];
|
|
323
337
|
|
|
324
|
-
/**
|
|
338
|
+
/** Represents structured context carried by a {@link ProcessError}. */
|
|
325
339
|
export declare interface ProcessErrorContext {
|
|
326
|
-
/**
|
|
340
|
+
/** Names the registry id involved, for a manager failure. */
|
|
327
341
|
readonly id?: string;
|
|
328
|
-
/**
|
|
342
|
+
/** Names the command line involved, for a run or spawn failure. */
|
|
329
343
|
readonly command?: string;
|
|
330
|
-
/**
|
|
344
|
+
/** Holds the child's exit code, when one was observed. */
|
|
331
345
|
readonly code?: number | null;
|
|
332
|
-
/**
|
|
346
|
+
/** Names the terminating signal, when one ended the child. */
|
|
333
347
|
readonly signal?: string | null;
|
|
334
|
-
/**
|
|
348
|
+
/** Carries the rejected public input, for an input-validation failure. */
|
|
335
349
|
readonly value?: unknown;
|
|
336
350
|
}
|
|
337
351
|
|
|
338
|
-
/**
|
|
352
|
+
/** Configures a {@link ProcessError}. */
|
|
339
353
|
export declare interface ProcessErrorOptions {
|
|
340
|
-
/**
|
|
354
|
+
/** Names the stable machine-readable category. */
|
|
341
355
|
readonly code: ProcessErrorCode;
|
|
342
|
-
/**
|
|
356
|
+
/** Carries structured detail about the failure. */
|
|
343
357
|
readonly context?: ProcessErrorContext;
|
|
344
|
-
/**
|
|
358
|
+
/** Carries the underlying cause, when one exists. */
|
|
345
359
|
readonly cause?: unknown;
|
|
346
|
-
/**
|
|
360
|
+
/** Carries the buffered run outcome, present when an {@link ExecuteResult} produced the failure. */
|
|
347
361
|
readonly result?: ExecuteResult;
|
|
348
362
|
}
|
|
349
363
|
|
|
350
364
|
/**
|
|
351
|
-
*
|
|
365
|
+
* Represents the push observation surface of a {@link ProcessInterface} — the moments a fire-and-forget
|
|
352
366
|
* observer subscribes to, alongside the `lines` stream and the `exit` promise.
|
|
353
367
|
*
|
|
354
368
|
* @remarks
|
|
@@ -362,16 +376,16 @@ export declare interface ProcessErrorOptions {
|
|
|
362
376
|
* routed to that handler, never emitted as this `error` event.
|
|
363
377
|
*/
|
|
364
378
|
export declare type ProcessEventMap = {
|
|
365
|
-
/**
|
|
379
|
+
/** Reports a decoded standard-error chunk arrived. */
|
|
366
380
|
readonly stderr: readonly [chunk: string];
|
|
367
|
-
/**
|
|
381
|
+
/** Reports a fault from the child or its open standard-input channel, carrying the host cause directly or through a `protocol` {@link ProcessError}. */
|
|
368
382
|
readonly error: readonly [error: unknown];
|
|
369
|
-
/**
|
|
383
|
+
/** Reports the child settled — its terminal state, delivered once. */
|
|
370
384
|
readonly exit: readonly [exit: ProcessExit];
|
|
371
385
|
};
|
|
372
386
|
|
|
373
387
|
/**
|
|
374
|
-
*
|
|
388
|
+
* Represents the observed terminal state of a child process: its exit code or the signal that ended it, and
|
|
375
389
|
* how its observation ended.
|
|
376
390
|
*
|
|
377
391
|
* @remarks
|
|
@@ -382,16 +396,16 @@ export declare type ProcessEventMap = {
|
|
|
382
396
|
* dropped lines and the drain bound cut stderr off.
|
|
383
397
|
*/
|
|
384
398
|
export declare interface ProcessExit {
|
|
385
|
-
/**
|
|
399
|
+
/** Holds the exit code, or `null` when a signal ended the process. A spawn fault reports the host's negative errno for `Process` and `execute`. */
|
|
386
400
|
readonly code: number | null;
|
|
387
|
-
/**
|
|
401
|
+
/** Holds the terminating signal name, or `null` when the process exited on its own. */
|
|
388
402
|
readonly signal: string | null;
|
|
389
|
-
/**
|
|
403
|
+
/** Reports how the terminal moment arrived: true when the child's streams closed; false when the `drain` bound elapsed first and later diagnostics may have existed. */
|
|
390
404
|
readonly drained: boolean;
|
|
391
405
|
}
|
|
392
406
|
|
|
393
407
|
/**
|
|
394
|
-
*
|
|
408
|
+
* Represents one supervised child process with framed output, a bounded backlog, and bounded termination.
|
|
395
409
|
*
|
|
396
410
|
* @remarks
|
|
397
411
|
* `lines` is pumped as soon as the child writes, and it is a single-consumer stream: each line goes
|
|
@@ -426,16 +440,16 @@ export declare interface ProcessExit {
|
|
|
426
440
|
* supervisor inside that window reads the terminal state here.
|
|
427
441
|
*/
|
|
428
442
|
export declare interface ProcessInterface {
|
|
429
|
-
/**
|
|
443
|
+
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
430
444
|
readonly pid: number | undefined;
|
|
431
|
-
/**
|
|
445
|
+
/** Holds the exit code the host recorded, or `null` while the child has not exited and when a signal ended it. A spawn fault reports the host's negative errno. */
|
|
432
446
|
readonly code: number | null;
|
|
433
|
-
/**
|
|
447
|
+
/** Holds the terminating signal name the host recorded, or `null` while the child has not exited and when it exited on its own. */
|
|
434
448
|
readonly signal: string | null;
|
|
435
|
-
/**
|
|
449
|
+
/** Holds the typed lifecycle observation surface. */
|
|
436
450
|
readonly emitter: EmitterInterface<ProcessEventMap>;
|
|
437
451
|
/**
|
|
438
|
-
*
|
|
452
|
+
* Yields the captured stdout lines, in arrival order, for one consumer, ending at the terminal moment.
|
|
439
453
|
*
|
|
440
454
|
* @remarks
|
|
441
455
|
* A line feed, a CRLF pair, and a bare carriage return each terminate a line, and a CRLF split
|
|
@@ -455,7 +469,7 @@ export declare interface ProcessInterface {
|
|
|
455
469
|
*/
|
|
456
470
|
readonly lines: AsyncIterable<string>;
|
|
457
471
|
/**
|
|
458
|
-
*
|
|
472
|
+
* Holds the decoded byte-bounded stderr tail.
|
|
459
473
|
*
|
|
460
474
|
* @remarks
|
|
461
475
|
* The live tail before the terminal moment and the frozen value after it, on every path — a
|
|
@@ -465,10 +479,10 @@ export declare interface ProcessInterface {
|
|
|
465
479
|
* the tail as of the cutoff, and later diagnostics may have existed.
|
|
466
480
|
*/
|
|
467
481
|
readonly evidence: string;
|
|
468
|
-
/**
|
|
482
|
+
/** Reports whether the `lines` stream omitted output because a retention bound was reached. */
|
|
469
483
|
readonly truncated: boolean;
|
|
470
484
|
/**
|
|
471
|
-
*
|
|
485
|
+
* Reports whether the `exit` promise settled.
|
|
472
486
|
*
|
|
473
487
|
* @remarks
|
|
474
488
|
* The terminal moment has arrived: `evidence` is frozen, `lines` has ended, and the
|
|
@@ -477,7 +491,7 @@ export declare interface ProcessInterface {
|
|
|
477
491
|
*/
|
|
478
492
|
readonly settled: boolean;
|
|
479
493
|
/**
|
|
480
|
-
*
|
|
494
|
+
* Reports whether a termination began.
|
|
481
495
|
*
|
|
482
496
|
* @remarks
|
|
483
497
|
* Monotonic. It turns true when `stop`, `destroy`, or an abort of the `signal` option begins a
|
|
@@ -488,7 +502,7 @@ export declare interface ProcessInterface {
|
|
|
488
502
|
*/
|
|
489
503
|
readonly stopping: boolean;
|
|
490
504
|
/**
|
|
491
|
-
*
|
|
505
|
+
* Settles with the terminal child state, delivered once.
|
|
492
506
|
*
|
|
493
507
|
* @remarks
|
|
494
508
|
* Never rejects. It settles at the terminal moment: when the child's streams close, or when the
|
|
@@ -497,7 +511,7 @@ export declare interface ProcessInterface {
|
|
|
497
511
|
*/
|
|
498
512
|
readonly exit: Promise<ProcessExit>;
|
|
499
513
|
/**
|
|
500
|
-
*
|
|
514
|
+
* Writes one line to the open standard-input channel.
|
|
501
515
|
*
|
|
502
516
|
* @remarks
|
|
503
517
|
* Never rejects. `true` means the host accepted the bytes without reporting a fault; it does not
|
|
@@ -511,11 +525,11 @@ export declare interface ProcessInterface {
|
|
|
511
525
|
* for bytes the package is about to discard.
|
|
512
526
|
*
|
|
513
527
|
* @param text - The line text without its trailing newline
|
|
514
|
-
* @returns True
|
|
528
|
+
* @returns True if the host accepted the bytes without reporting a fault; false otherwise (the channel was closed, destroyed, ended, failed, or the write remained unconfirmed through `delivery`)
|
|
515
529
|
*/
|
|
516
530
|
send(text: string): Promise<boolean>;
|
|
517
531
|
/**
|
|
518
|
-
*
|
|
532
|
+
* Terminates the child process tree, awaits its observed exit, and reaches the terminal moment.
|
|
519
533
|
*
|
|
520
534
|
* @remarks
|
|
521
535
|
* Never rejects. On Windows the whole tree is killed immediately through `taskkill`, with a
|
|
@@ -528,11 +542,11 @@ export declare interface ProcessInterface {
|
|
|
528
542
|
* reaches the end of the stream instead of waiting on a child it already ended, and needs no
|
|
529
543
|
* second call to release it.
|
|
530
544
|
*
|
|
531
|
-
* @returns True
|
|
545
|
+
* @returns True if the child's native exit was observed; false otherwise (the confirmation deadline elapsed without it)
|
|
532
546
|
*/
|
|
533
547
|
stop(): Promise<boolean>;
|
|
534
548
|
/**
|
|
535
|
-
*
|
|
549
|
+
* Stops the child, closes its standard-input channel, reaches the terminal moment, and destroys the
|
|
536
550
|
* observation emitter.
|
|
537
551
|
*
|
|
538
552
|
* @remarks
|
|
@@ -549,21 +563,21 @@ export declare interface ProcessInterface {
|
|
|
549
563
|
}
|
|
550
564
|
|
|
551
565
|
/**
|
|
552
|
-
*
|
|
566
|
+
* Represents the push observation surface of a {@link ProcessManagerInterface} — the fleet-level moments a
|
|
553
567
|
* fire-and-forget observer subscribes to.
|
|
554
568
|
*
|
|
555
569
|
* @remarks
|
|
556
570
|
* Declared as a `type` alias so it satisfies the emitter's `EventMap` constraint structurally.
|
|
557
571
|
*/
|
|
558
572
|
export declare type ProcessManagerEventMap = {
|
|
559
|
-
/**
|
|
573
|
+
/** Reports a child launched under its id. */
|
|
560
574
|
readonly launch: readonly [id: string];
|
|
561
|
-
/**
|
|
575
|
+
/** Reports a child settled and left the registry — its id and terminal state. */
|
|
562
576
|
readonly exit: readonly [id: string, exit: ProcessExit];
|
|
563
577
|
};
|
|
564
578
|
|
|
565
579
|
/**
|
|
566
|
-
*
|
|
580
|
+
* Represents a keyed registry of live supervised child processes.
|
|
567
581
|
*
|
|
568
582
|
* @remarks
|
|
569
583
|
* A child that settles removes itself from the registry, so `count` and `processes` reflect only
|
|
@@ -575,25 +589,25 @@ export declare type ProcessManagerEventMap = {
|
|
|
575
589
|
* the `launch` and `exit` moments across every child.
|
|
576
590
|
*/
|
|
577
591
|
export declare interface ProcessManagerInterface {
|
|
578
|
-
/**
|
|
592
|
+
/** Holds the typed fleet-level observation surface. */
|
|
579
593
|
readonly emitter: EmitterInterface<ProcessManagerEventMap>;
|
|
580
|
-
/**
|
|
594
|
+
/** Counts the live children. */
|
|
581
595
|
readonly count: number;
|
|
582
596
|
/**
|
|
583
|
-
*
|
|
597
|
+
* Returns the live child under `id`, or `undefined` when none is.
|
|
584
598
|
*
|
|
585
599
|
* @param id - The registry key
|
|
586
600
|
* @returns The child, or `undefined`
|
|
587
601
|
*/
|
|
588
602
|
process(id: string): ProcessInterface | undefined;
|
|
589
603
|
/**
|
|
590
|
-
*
|
|
604
|
+
* Returns a snapshot of every live child.
|
|
591
605
|
*
|
|
592
606
|
* @returns The live children in launch order
|
|
593
607
|
*/
|
|
594
608
|
processes(): readonly ProcessInterface[];
|
|
595
609
|
/**
|
|
596
|
-
*
|
|
610
|
+
* Spawns and registers one child under `id`.
|
|
597
611
|
*
|
|
598
612
|
* @remarks
|
|
599
613
|
* Every option is read before the child is spawned, so a caller's own option getter runs while
|
|
@@ -611,27 +625,27 @@ export declare interface ProcessManagerInterface {
|
|
|
611
625
|
*/
|
|
612
626
|
launch(id: string, options: ProcessOptions): ProcessInterface;
|
|
613
627
|
/**
|
|
614
|
-
*
|
|
628
|
+
* Terminates the named children and awaits their exit.
|
|
615
629
|
*
|
|
616
630
|
* @param ids - The registry keys to stop
|
|
617
|
-
* @returns True
|
|
631
|
+
* @returns True if every named child was live and its exit was confirmed; false otherwise
|
|
618
632
|
*/
|
|
619
633
|
stop(ids: readonly string[]): Promise<boolean>;
|
|
620
634
|
/**
|
|
621
|
-
*
|
|
635
|
+
* Terminates one child and awaits its exit.
|
|
622
636
|
*
|
|
623
637
|
* @param id - The registry key to stop
|
|
624
|
-
* @returns True
|
|
638
|
+
* @returns True if the child was live and its exit was confirmed; false otherwise (the id was not live, or the confirmation deadline elapsed)
|
|
625
639
|
*/
|
|
626
640
|
stop(id: string): Promise<boolean>;
|
|
627
641
|
/**
|
|
628
|
-
*
|
|
642
|
+
* Terminates every live child and awaits their exit.
|
|
629
643
|
*
|
|
630
644
|
* @returns A promise that resolves after every child stops
|
|
631
645
|
*/
|
|
632
646
|
stop(): Promise<void>;
|
|
633
647
|
/**
|
|
634
|
-
*
|
|
648
|
+
* Stops every child, then destroys the registry emitter last.
|
|
635
649
|
*
|
|
636
650
|
* @remarks
|
|
637
651
|
* Always resolves, and refuses a later `launch` with a {@link ProcessError} coded `protocol`.
|
|
@@ -645,7 +659,7 @@ export declare interface ProcessManagerInterface {
|
|
|
645
659
|
}
|
|
646
660
|
|
|
647
661
|
/**
|
|
648
|
-
*
|
|
662
|
+
* Configures a {@link ProcessManagerInterface}.
|
|
649
663
|
*
|
|
650
664
|
* @remarks
|
|
651
665
|
* `on` installs initial {@link ProcessManagerEventMap} listeners and `error` receives isolated
|
|
@@ -657,7 +671,7 @@ export declare interface ProcessManagerOptions {
|
|
|
657
671
|
}
|
|
658
672
|
|
|
659
673
|
/**
|
|
660
|
-
*
|
|
674
|
+
* Configures one supervised child process.
|
|
661
675
|
*
|
|
662
676
|
* @remarks
|
|
663
677
|
* `grace` is the cooperative window between `SIGTERM` and `SIGKILL` on a POSIX host; Windows has no
|
|
@@ -685,26 +699,26 @@ export declare interface ProcessOptions {
|
|
|
685
699
|
readonly on?: EmitterHooks<ProcessEventMap>;
|
|
686
700
|
readonly error?: EmitterErrorHandler;
|
|
687
701
|
readonly command: ProcessCommand;
|
|
688
|
-
/**
|
|
702
|
+
/** Names the working directory the child runs in. */
|
|
689
703
|
readonly workspace: string;
|
|
690
|
-
/**
|
|
704
|
+
/** Sets the cooperative POSIX window in milliseconds between `SIGTERM` and `SIGKILL`. Default: {@link PROCESS_GRACE}. */
|
|
691
705
|
readonly grace?: number;
|
|
692
|
-
/**
|
|
706
|
+
/** Sets the milliseconds the package waits for the child's read ends to close after the native exit or an initiated termination, before cutting them off; `0` cuts them off as soon as the bound is armed. Default: {@link PROCESS_DRAIN}. */
|
|
693
707
|
readonly drain?: number;
|
|
694
|
-
/**
|
|
708
|
+
/** Sets the maximum retained stderr tail in bytes. Default: {@link PROCESS_EVIDENCE}. */
|
|
695
709
|
readonly evidence?: number;
|
|
696
|
-
/**
|
|
710
|
+
/** Sets the soft high-water mark in bytes for the unconsumed `lines` backlog; termination retains at most twice this value. Default: {@link PROCESS_BACKLOG}. */
|
|
697
711
|
readonly backlog?: number;
|
|
698
|
-
/**
|
|
712
|
+
/** Sets the milliseconds an unconfirmed {@link ProcessInterface.send} waits before resolving `false`. `0` or omitted disables the bound. */
|
|
699
713
|
readonly delivery?: number;
|
|
700
714
|
/** If `true`, stdin stays open for {@link ProcessInterface.send}; if `false` or omitted, stdin closes after any initial `input`. */
|
|
701
715
|
readonly writable?: boolean;
|
|
702
|
-
/**
|
|
716
|
+
/** Terminates the child through the same bounded `stop` when this signal aborts. */
|
|
703
717
|
readonly signal?: AbortSignal;
|
|
704
718
|
}
|
|
705
719
|
|
|
706
720
|
/**
|
|
707
|
-
*
|
|
721
|
+
* Represents the push observation surface of a {@link SessionInterface} — the moments a byte-oriented observer
|
|
708
722
|
* subscribes to, alongside the `ending` and `exit` promises.
|
|
709
723
|
*
|
|
710
724
|
* @remarks
|
|
@@ -727,18 +741,18 @@ export declare interface ProcessOptions {
|
|
|
727
741
|
* `error` event.
|
|
728
742
|
*/
|
|
729
743
|
export declare type SessionEventMap = {
|
|
730
|
-
/**
|
|
744
|
+
/** Reports a standard-output chunk arrived, as an owned `Uint8Array` the consumer may keep and mutate. */
|
|
731
745
|
readonly stdout: readonly [chunk: Uint8Array];
|
|
732
|
-
/**
|
|
746
|
+
/** Reports a decoded standard-error chunk arrived. */
|
|
733
747
|
readonly stderr: readonly [chunk: string];
|
|
734
|
-
/**
|
|
748
|
+
/** Reports a fault from the child or its open standard-input channel, carrying the host cause directly or through a `protocol` {@link ProcessError}. */
|
|
735
749
|
readonly error: readonly [error: unknown];
|
|
736
|
-
/**
|
|
750
|
+
/** Reports the child settled — its terminal state, delivered once. */
|
|
737
751
|
readonly exit: readonly [exit: ProcessExit];
|
|
738
752
|
};
|
|
739
753
|
|
|
740
754
|
/**
|
|
741
|
-
*
|
|
755
|
+
* Represents one supervised child process read as raw bytes, with an open standard-input channel and bounded
|
|
742
756
|
* termination.
|
|
743
757
|
*
|
|
744
758
|
* @remarks
|
|
@@ -770,16 +784,16 @@ export declare type SessionEventMap = {
|
|
|
770
784
|
* the id.
|
|
771
785
|
*/
|
|
772
786
|
export declare interface SessionInterface {
|
|
773
|
-
/**
|
|
787
|
+
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
774
788
|
readonly pid: number | undefined;
|
|
775
|
-
/**
|
|
789
|
+
/** Holds the exit code the host recorded, or `null` while the child has not exited and when a signal ended it. A spawn fault reports the host's negative errno. */
|
|
776
790
|
readonly code: number | null;
|
|
777
|
-
/**
|
|
791
|
+
/** Holds the terminating signal name the host recorded, or `null` while the child has not exited and when it exited on its own. */
|
|
778
792
|
readonly signal: string | null;
|
|
779
|
-
/**
|
|
793
|
+
/** Holds the typed lifecycle observation surface. */
|
|
780
794
|
readonly emitter: EmitterInterface<SessionEventMap>;
|
|
781
795
|
/**
|
|
782
|
-
*
|
|
796
|
+
* Holds the decoded byte-bounded stderr tail.
|
|
783
797
|
*
|
|
784
798
|
* @remarks
|
|
785
799
|
* The live tail before the terminal moment and the frozen value after it, on every path — a
|
|
@@ -789,7 +803,7 @@ export declare interface SessionInterface {
|
|
|
789
803
|
*/
|
|
790
804
|
readonly evidence: string;
|
|
791
805
|
/**
|
|
792
|
-
*
|
|
806
|
+
* Reports whether the `exit` promise settled.
|
|
793
807
|
*
|
|
794
808
|
* @remarks
|
|
795
809
|
* The terminal moment has arrived: `evidence` is frozen, no further `stdout` or `stderr` event
|
|
@@ -798,7 +812,7 @@ export declare interface SessionInterface {
|
|
|
798
812
|
*/
|
|
799
813
|
readonly settled: boolean;
|
|
800
814
|
/**
|
|
801
|
-
*
|
|
815
|
+
* Reports whether a termination began.
|
|
802
816
|
*
|
|
803
817
|
* @remarks
|
|
804
818
|
* Monotonic. It turns true when `stop`, `destroy`, or an abort of the `signal` option begins a
|
|
@@ -808,7 +822,7 @@ export declare interface SessionInterface {
|
|
|
808
822
|
*/
|
|
809
823
|
readonly stopping: boolean;
|
|
810
824
|
/**
|
|
811
|
-
*
|
|
825
|
+
* Settles at the child's own ending, awaited without the terminal moment's drain window.
|
|
812
826
|
*
|
|
813
827
|
* @remarks
|
|
814
828
|
* Never rejects, and resolves no value: `code` and `signal` carry the terminal facts as soon as
|
|
@@ -821,7 +835,7 @@ export declare interface SessionInterface {
|
|
|
821
835
|
*/
|
|
822
836
|
readonly ending: Promise<void>;
|
|
823
837
|
/**
|
|
824
|
-
*
|
|
838
|
+
* Settles with the terminal child state, delivered once.
|
|
825
839
|
*
|
|
826
840
|
* @remarks
|
|
827
841
|
* Never rejects. It settles at the terminal moment: when the child's streams close, or when the
|
|
@@ -830,7 +844,7 @@ export declare interface SessionInterface {
|
|
|
830
844
|
*/
|
|
831
845
|
readonly exit: Promise<ProcessExit>;
|
|
832
846
|
/**
|
|
833
|
-
*
|
|
847
|
+
* Writes raw bytes to the open standard-input channel.
|
|
834
848
|
*
|
|
835
849
|
* @remarks
|
|
836
850
|
* Never rejects, and adds no framing: the bytes reach the child exactly as given, with no
|
|
@@ -847,11 +861,11 @@ export declare interface SessionInterface {
|
|
|
847
861
|
* promise settles: bytes mutated inside that window are the bytes the child receives.
|
|
848
862
|
*
|
|
849
863
|
* @param bytes - The payload to write, already framed by the caller
|
|
850
|
-
* @returns True
|
|
864
|
+
* @returns True if the host accepted the bytes without reporting a fault; false otherwise (the channel was closed, destroyed, ended, failed, or the write remained unconfirmed through `delivery`)
|
|
851
865
|
*/
|
|
852
866
|
write(bytes: Uint8Array): Promise<boolean>;
|
|
853
867
|
/**
|
|
854
|
-
*
|
|
868
|
+
* Closes the standard-input channel and leaves the child running.
|
|
855
869
|
*
|
|
856
870
|
* @remarks
|
|
857
871
|
* Never rejects, and terminates nothing: `stopping` stays false, no signal is sent, no drain
|
|
@@ -872,7 +886,7 @@ export declare interface SessionInterface {
|
|
|
872
886
|
*/
|
|
873
887
|
end(): Promise<void>;
|
|
874
888
|
/**
|
|
875
|
-
*
|
|
889
|
+
* Terminates the child process tree, awaits its observed exit, and reaches the terminal moment.
|
|
876
890
|
*
|
|
877
891
|
* @remarks
|
|
878
892
|
* Never rejects. On Windows the whole tree is killed immediately through `taskkill`, with a
|
|
@@ -883,11 +897,11 @@ export declare interface SessionInterface {
|
|
|
883
897
|
* `stdout` and `stderr` events stop, and `exit` settles. A caller that stops a child and keeps
|
|
884
898
|
* listening therefore reaches the end of the stream and needs no second call to release it.
|
|
885
899
|
*
|
|
886
|
-
* @returns True
|
|
900
|
+
* @returns True if the child's native exit was observed; false otherwise (the confirmation deadline elapsed without it)
|
|
887
901
|
*/
|
|
888
902
|
stop(): Promise<boolean>;
|
|
889
903
|
/**
|
|
890
|
-
*
|
|
904
|
+
* Stops the child, closes its standard-input channel, reaches the terminal moment, and destroys the
|
|
891
905
|
* observation emitter.
|
|
892
906
|
*
|
|
893
907
|
* @remarks
|
|
@@ -904,7 +918,7 @@ export declare interface SessionInterface {
|
|
|
904
918
|
}
|
|
905
919
|
|
|
906
920
|
/**
|
|
907
|
-
*
|
|
921
|
+
* Configures one raw byte session over a supervised child.
|
|
908
922
|
*
|
|
909
923
|
* @remarks
|
|
910
924
|
* This is {@link ProcessOptions} without `backlog` and without `writable`. A session frames nothing
|
|
@@ -924,22 +938,22 @@ export declare interface SessionOptions {
|
|
|
924
938
|
readonly on?: EmitterHooks<SessionEventMap>;
|
|
925
939
|
readonly error?: EmitterErrorHandler;
|
|
926
940
|
readonly command: ProcessCommand;
|
|
927
|
-
/**
|
|
941
|
+
/** Names the working directory the child runs in. */
|
|
928
942
|
readonly workspace: string;
|
|
929
|
-
/**
|
|
943
|
+
/** Sets the cooperative POSIX window in milliseconds between `SIGTERM` and `SIGKILL`. Default: {@link PROCESS_GRACE}. */
|
|
930
944
|
readonly grace?: number;
|
|
931
|
-
/**
|
|
945
|
+
/** Sets the milliseconds the package waits for the child's read ends to close after the native exit or an initiated termination, before cutting them off; `0` cuts them off as soon as the bound is armed. Default: {@link PROCESS_DRAIN}. */
|
|
932
946
|
readonly drain?: number;
|
|
933
|
-
/**
|
|
947
|
+
/** Sets the maximum retained stderr tail in bytes. Default: {@link PROCESS_EVIDENCE}. */
|
|
934
948
|
readonly evidence?: number;
|
|
935
|
-
/**
|
|
949
|
+
/** Sets the milliseconds an unconfirmed {@link SessionInterface.write} waits before resolving `false`. `0` or omitted disables the bound. */
|
|
936
950
|
readonly delivery?: number;
|
|
937
|
-
/**
|
|
951
|
+
/** Terminates the child through the same bounded `stop` when this signal aborts. */
|
|
938
952
|
readonly signal?: AbortSignal;
|
|
939
953
|
}
|
|
940
954
|
|
|
941
955
|
/**
|
|
942
|
-
*
|
|
956
|
+
* Represents the resolved spawn form of one command: the executable to launch, the argument vector to pass,
|
|
943
957
|
* and whether the host receives that vector verbatim.
|
|
944
958
|
*
|
|
945
959
|
* @remarks
|