@orkestrel/process 0.0.10 → 0.0.12
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 +10 -21
- package/dist/src/core/index.cjs +18 -13
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +33 -20
- package/dist/src/core/index.d.ts +33 -20
- package/dist/src/core/index.js +18 -13
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +43 -19
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +74 -58
- package/dist/src/server/index.d.ts +74 -58
- package/dist/src/server/index.js +43 -19
- package/dist/src/server/index.js.map +1 -1
- package/package.json +13 -14
|
@@ -1,46 +1,39 @@
|
|
|
1
1
|
import { Buffer as Buffer_2 } from 'node:buffer';
|
|
2
|
-
import { DetachOptions } from '@orkestrel/process';
|
|
3
|
-
import { EmitterInterface } from '@orkestrel/emitter';
|
|
4
|
-
import { ExecutableOptions } from '@orkestrel/process';
|
|
5
|
-
import { ExecuteInput } from '@orkestrel/process';
|
|
6
|
-
import { ExecuteOptions } from '@orkestrel/process';
|
|
7
|
-
import { ExecuteResult } from '@orkestrel/process';
|
|
8
|
-
import { ExecuteSyncOptions } from '@orkestrel/process';
|
|
9
|
-
import { ProcessCommand } from '@orkestrel/process';
|
|
10
|
-
import { ProcessEventMap } from '@orkestrel/process';
|
|
11
|
-
import { ProcessExit } from '@orkestrel/process';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { Readable } from 'node:stream';
|
|
23
|
-
import { SessionEventMap } from '@orkestrel/process';
|
|
24
|
-
import { SessionInterface } from '@orkestrel/process';
|
|
25
|
-
import { SessionInterface as SessionInterface_2 } from '@orkestrel/process';
|
|
26
|
-
import { SessionOptions } from '@orkestrel/process';
|
|
27
|
-
import { SessionOptions as SessionOptions_2 } from '@orkestrel/process';
|
|
28
|
-
import { SpawnInput } from '@orkestrel/process';
|
|
2
|
+
import type { DetachOptions } from '@orkestrel/process';
|
|
3
|
+
import type { EmitterInterface } from '@orkestrel/emitter';
|
|
4
|
+
import type { ExecutableOptions } from '@orkestrel/process';
|
|
5
|
+
import type { ExecuteInput } from '@orkestrel/process';
|
|
6
|
+
import type { ExecuteOptions } from '@orkestrel/process';
|
|
7
|
+
import type { ExecuteResult } from '@orkestrel/process';
|
|
8
|
+
import type { ExecuteSyncOptions } from '@orkestrel/process';
|
|
9
|
+
import type { ProcessCommand } from '@orkestrel/process';
|
|
10
|
+
import type { ProcessEventMap } from '@orkestrel/process';
|
|
11
|
+
import type { ProcessExit } from '@orkestrel/process';
|
|
12
|
+
import type { ProcessInterface } from '@orkestrel/process';
|
|
13
|
+
import type { ProcessManagerEventMap } from '@orkestrel/process';
|
|
14
|
+
import type { ProcessManagerInterface } from '@orkestrel/process';
|
|
15
|
+
import type { ProcessManagerOptions } from '@orkestrel/process';
|
|
16
|
+
import type { ProcessOptions } from '@orkestrel/process';
|
|
17
|
+
import type { Readable } from 'node:stream';
|
|
18
|
+
import type { SessionEventMap } from '@orkestrel/process';
|
|
19
|
+
import type { SessionInterface } from '@orkestrel/process';
|
|
20
|
+
import type { SessionOptions } from '@orkestrel/process';
|
|
21
|
+
import type { SpawnInput } from '@orkestrel/process';
|
|
29
22
|
|
|
30
23
|
/**
|
|
31
24
|
* Builds the executable candidates an explicit platform would search.
|
|
32
25
|
*
|
|
33
26
|
* @remarks
|
|
34
27
|
* Windows alone needs this list: the host searches the working directory before `PATH` and applies
|
|
35
|
-
* `PATHEXT`, and Node reproduces neither for a direct spawn. Within each searched directory
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* `report.txt
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* `PATHEXT`
|
|
42
|
-
* treats as the same file. A non-Windows platform returns an empty list
|
|
43
|
-
* its own lookup.
|
|
28
|
+
* `PATHEXT`, and Node reproduces neither for a direct spawn. Within each searched directory,
|
|
29
|
+
* {@link buildExecutableCandidates} enumerates `PATHEXT` candidates for an extensionless name. For
|
|
30
|
+
* an extension-bearing name, it enumerates the literal path before `PATHEXT` candidates, so
|
|
31
|
+
* `report.txt` resolves to a `report.txt` file where one exists and to `report.txt.cmd` where none
|
|
32
|
+
* does. The lookup reads the child's effective environment, so an overridden `PATH` selects the
|
|
33
|
+
* executable the child would have found. A POSIX host resolves the file itself, so the candidate
|
|
34
|
+
* list there is empty. A `PATHEXT` candidate keeps the extension spelling from `PATHEXT`, which the
|
|
35
|
+
* case-insensitive host treats as the same file. A non-Windows platform returns an empty list
|
|
36
|
+
* because `execvp` performs its own lookup.
|
|
44
37
|
*
|
|
45
38
|
* @param file - The command executable name or path
|
|
46
39
|
* @param workspace - The directory searched first
|
|
@@ -114,6 +107,10 @@ export declare function buildPlatformSpawn(command: ProcessCommand, file: string
|
|
|
114
107
|
/**
|
|
115
108
|
* Builds the resolved spawn form of one command for the current host.
|
|
116
109
|
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* When executable lookup returns no regular-file candidate, {@link buildSpawn} preserves the
|
|
112
|
+
* command file as written for native spawning.
|
|
113
|
+
*
|
|
117
114
|
* @param command - The executable and its argument vector
|
|
118
115
|
* @param options - The directory searched first and the child's effective environment
|
|
119
116
|
* @returns The file, argument vector, and verbatim flag to spawn with
|
|
@@ -151,26 +148,37 @@ export declare function buildSpawn(command: ProcessCommand, options?: Executable
|
|
|
151
148
|
export declare function captureChunk(chunk: unknown, room: number): Buffer_2 | undefined;
|
|
152
149
|
|
|
153
150
|
/**
|
|
154
|
-
* Creates one supervised child process
|
|
151
|
+
* Creates one supervised child process and returns it as a {@link ProcessInterface}, so a caller
|
|
152
|
+
* holds the published contract rather than the `Process` class.
|
|
155
153
|
*
|
|
156
154
|
* @param options - Command, workspace, termination, evidence, stdin, and observation settings
|
|
157
155
|
* @returns The launched {@link ProcessInterface}
|
|
158
156
|
*
|
|
159
|
-
* @example
|
|
157
|
+
* @example Supervise a child and read its lines
|
|
160
158
|
* ```ts
|
|
161
159
|
* import { createProcess } from '@orkestrel/process/server'
|
|
162
160
|
*
|
|
163
161
|
* const child = createProcess({
|
|
164
|
-
* command: { file: 'node', arguments: ['
|
|
162
|
+
* command: { file: 'node', arguments: ['-e', 'console.log("ready"); console.log("done")'] },
|
|
165
163
|
* workspace: process.cwd(),
|
|
166
|
-
* grace:
|
|
164
|
+
* grace: 5_000, // POSIX only: the window between SIGTERM and SIGKILL
|
|
167
165
|
* })
|
|
166
|
+
*
|
|
167
|
+
* const lines: string[] = []
|
|
168
|
+
* for await (const line of child.lines) lines.push(line)
|
|
169
|
+
* lines // ['ready', 'done']
|
|
170
|
+
*
|
|
171
|
+
* const exit = await child.exit
|
|
172
|
+
* exit.code // 0
|
|
173
|
+
* await child.destroy()
|
|
168
174
|
* ```
|
|
169
175
|
*/
|
|
170
176
|
export declare function createProcess(options: ProcessOptions): ProcessInterface;
|
|
171
177
|
|
|
172
178
|
/**
|
|
173
|
-
* Creates one keyed registry of supervised child processes
|
|
179
|
+
* Creates one empty keyed registry of supervised child processes and returns it as a
|
|
180
|
+
* {@link ProcessManagerInterface}, so a caller holds the published contract rather than the
|
|
181
|
+
* `ProcessManager` class.
|
|
174
182
|
*
|
|
175
183
|
* @param options - Initial fleet-level observation hooks and listener-error handling
|
|
176
184
|
* @returns The {@link ProcessManagerInterface} registry
|
|
@@ -185,7 +193,8 @@ export declare function createProcess(options: ProcessOptions): ProcessInterface
|
|
|
185
193
|
export declare function createProcessManager(options?: ProcessManagerOptions): ProcessManagerInterface;
|
|
186
194
|
|
|
187
195
|
/**
|
|
188
|
-
* Creates one raw byte session over a supervised child process
|
|
196
|
+
* Creates one raw byte session over a supervised child process and returns it as a
|
|
197
|
+
* {@link SessionInterface}, so a caller holds the published contract rather than the `Session` class.
|
|
189
198
|
*
|
|
190
199
|
* @param options - Command, workspace, termination, evidence, stdin, and observation settings
|
|
191
200
|
* @returns The launched {@link SessionInterface}
|
|
@@ -416,7 +425,8 @@ export declare function mergeEnvironment(isolated: boolean, base?: Readonly<Reco
|
|
|
416
425
|
export declare function mergePlatformEnvironment(platform: NodeJS.Platform, parent: Readonly<Record<string, string | undefined>>, isolated: boolean, base?: Readonly<Record<string, string | undefined>>, override?: Readonly<Record<string, string | undefined>>): NodeJS.ProcessEnv;
|
|
417
426
|
|
|
418
427
|
/**
|
|
419
|
-
* Supervises one child
|
|
428
|
+
* Supervises one child, frames its standard output into lines under a bounded backlog, and keeps
|
|
429
|
+
* every observation channel aligned at termination.
|
|
420
430
|
*
|
|
421
431
|
* @remarks
|
|
422
432
|
* The child's ending and the supervision's ending are distinct. `pid`, `code`, and `signal` read
|
|
@@ -446,7 +456,7 @@ export declare function mergePlatformEnvironment(platform: NodeJS.Platform, pare
|
|
|
446
456
|
* await child.destroy()
|
|
447
457
|
* ```
|
|
448
458
|
*/
|
|
449
|
-
export declare class Process implements
|
|
459
|
+
export declare class Process implements ProcessInterface {
|
|
450
460
|
#private;
|
|
451
461
|
/**
|
|
452
462
|
* Spawns one child process and begins stream capture.
|
|
@@ -454,7 +464,7 @@ export declare class Process implements ProcessInterface_2 {
|
|
|
454
464
|
* @param options - Command, workspace, termination, capture, stdin, and observation settings
|
|
455
465
|
* @throws A {@link ProcessError} coded `invalid` when an option or command string is malformed
|
|
456
466
|
*/
|
|
457
|
-
constructor(options:
|
|
467
|
+
constructor(options: ProcessOptions);
|
|
458
468
|
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
459
469
|
get pid(): number | undefined;
|
|
460
470
|
/** Holds the exit code the host recorded, or `null` while the child has not exited and when a signal ended it. */
|
|
@@ -474,7 +484,7 @@ export declare class Process implements ProcessInterface_2 {
|
|
|
474
484
|
/** Reports whether termination began, including after the terminal moment. */
|
|
475
485
|
get stopping(): boolean;
|
|
476
486
|
/** Settles with the terminal child state, observed once after stream close or the drain cutoff. */
|
|
477
|
-
get exit(): Promise<
|
|
487
|
+
get exit(): Promise<ProcessExit>;
|
|
478
488
|
/**
|
|
479
489
|
* Writes one line to the open standard-input channel.
|
|
480
490
|
*
|
|
@@ -587,7 +597,8 @@ export declare interface ProcessChildInterface {
|
|
|
587
597
|
}
|
|
588
598
|
|
|
589
599
|
/**
|
|
590
|
-
*
|
|
600
|
+
* Launches supervised children under caller-chosen ids, evicts each one as it settles, and destroys
|
|
601
|
+
* every live child on teardown.
|
|
591
602
|
*
|
|
592
603
|
* @remarks
|
|
593
604
|
* A child launched under an id joins the registry and emits `launch`; when it settles it removes
|
|
@@ -615,14 +626,14 @@ export declare interface ProcessChildInterface {
|
|
|
615
626
|
* await manager.destroy()
|
|
616
627
|
* ```
|
|
617
628
|
*/
|
|
618
|
-
export declare class ProcessManager implements
|
|
629
|
+
export declare class ProcessManager implements ProcessManagerInterface {
|
|
619
630
|
#private;
|
|
620
631
|
/**
|
|
621
632
|
* Constructs a process registry.
|
|
622
633
|
*
|
|
623
634
|
* @param options - Initial fleet-level observation hooks and listener-error handling
|
|
624
635
|
*/
|
|
625
|
-
constructor(options?:
|
|
636
|
+
constructor(options?: ProcessManagerOptions);
|
|
626
637
|
/** Holds the typed fleet-level observation surface. */
|
|
627
638
|
get emitter(): EmitterInterface<ProcessManagerEventMap>;
|
|
628
639
|
/** Counts the live children. */
|
|
@@ -633,13 +644,13 @@ export declare class ProcessManager implements ProcessManagerInterface_2 {
|
|
|
633
644
|
* @param id - The registry key
|
|
634
645
|
* @returns The child, or `undefined`
|
|
635
646
|
*/
|
|
636
|
-
process(id: string):
|
|
647
|
+
process(id: string): ProcessInterface | undefined;
|
|
637
648
|
/**
|
|
638
649
|
* Returns a snapshot of every live child.
|
|
639
650
|
*
|
|
640
651
|
* @returns The live children in launch order
|
|
641
652
|
*/
|
|
642
|
-
processes(): readonly
|
|
653
|
+
processes(): readonly ProcessInterface[];
|
|
643
654
|
/**
|
|
644
655
|
* Spawns and registers one child under `id`.
|
|
645
656
|
*
|
|
@@ -657,7 +668,7 @@ export declare class ProcessManager implements ProcessManagerInterface_2 {
|
|
|
657
668
|
* @returns The launched child
|
|
658
669
|
* @throws A {@link ProcessError} coded `duplicate` when `id` is already live, `protocol` when the registry is being destroyed, or `invalid` when an option or command string is malformed
|
|
659
670
|
*/
|
|
660
|
-
launch(id: string, options:
|
|
671
|
+
launch(id: string, options: ProcessOptions): ProcessInterface;
|
|
661
672
|
/**
|
|
662
673
|
* Terminates the named children and awaits their exit.
|
|
663
674
|
*
|
|
@@ -745,7 +756,12 @@ export declare function readPlatformVariable(environment: Readonly<Record<string
|
|
|
745
756
|
export declare function readVariable(environment: Readonly<Record<string, string | undefined>>, name: string): string | undefined;
|
|
746
757
|
|
|
747
758
|
/**
|
|
748
|
-
* Resolves a command file to the executable path the host would launch
|
|
759
|
+
* Resolves a command file to the executable path the host would launch, or to `undefined` on a POSIX
|
|
760
|
+
* host, which performs its own lookup.
|
|
761
|
+
*
|
|
762
|
+
* @remarks
|
|
763
|
+
* A Windows lookup miss also returns `undefined`. {@link buildSpawn} preserves the command file as
|
|
764
|
+
* written for native spawning.
|
|
749
765
|
*
|
|
750
766
|
* @param file - The command executable name or path
|
|
751
767
|
* @param options - The directory searched first and the child's effective environment
|
|
@@ -789,7 +805,7 @@ export declare function resolveExecutable(file: string, options?: ExecutableOpti
|
|
|
789
805
|
* })
|
|
790
806
|
* ```
|
|
791
807
|
*/
|
|
792
|
-
export declare class Session implements
|
|
808
|
+
export declare class Session implements SessionInterface {
|
|
793
809
|
#private;
|
|
794
810
|
/**
|
|
795
811
|
* Spawns one child process and begins byte capture.
|
|
@@ -797,7 +813,7 @@ export declare class Session implements SessionInterface_2 {
|
|
|
797
813
|
* @param options - Command, workspace, termination, evidence, stdin, and observation settings
|
|
798
814
|
* @throws A {@link ProcessError} coded `invalid` when an option or command string is malformed
|
|
799
815
|
*/
|
|
800
|
-
constructor(options:
|
|
816
|
+
constructor(options: SessionOptions);
|
|
801
817
|
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
802
818
|
get pid(): number | undefined;
|
|
803
819
|
/** Holds the exit code the host recorded, or `null` while the child has not exited and when a signal ended it. */
|
|
@@ -815,7 +831,7 @@ export declare class Session implements SessionInterface_2 {
|
|
|
815
831
|
/** Settles at the child's own ending, awaited without the terminal moment's drain window. */
|
|
816
832
|
get ending(): Promise<void>;
|
|
817
833
|
/** Settles with the terminal child state, observed once after stream close or the drain cutoff. */
|
|
818
|
-
get exit(): Promise<
|
|
834
|
+
get exit(): Promise<ProcessExit>;
|
|
819
835
|
/**
|
|
820
836
|
* Writes raw bytes to the open standard-input channel.
|
|
821
837
|
*
|
|
@@ -972,7 +988,7 @@ export declare class Supervisor {
|
|
|
972
988
|
* @param face - The composing face's callbacks for each lifecycle moment
|
|
973
989
|
* @throws A {@link ProcessError} coded `invalid` when an option or command string is malformed
|
|
974
990
|
*/
|
|
975
|
-
constructor(options:
|
|
991
|
+
constructor(options: ProcessOptions, face: SupervisorFace);
|
|
976
992
|
/** Holds the child's standard-output stream, for the composing face to attach its own consumer to. */
|
|
977
993
|
get stdout(): Readable;
|
|
978
994
|
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
@@ -997,7 +1013,7 @@ export declare class Supervisor {
|
|
|
997
1013
|
*/
|
|
998
1014
|
get ending(): Promise<void>;
|
|
999
1015
|
/** Settles with the terminal child state, observed once after stream close or the drain cutoff. */
|
|
1000
|
-
get exit(): Promise<
|
|
1016
|
+
get exit(): Promise<ProcessExit>;
|
|
1001
1017
|
/**
|
|
1002
1018
|
* Writes raw bytes to the open standard-input channel.
|
|
1003
1019
|
*
|
|
@@ -1,46 +1,39 @@
|
|
|
1
1
|
import { Buffer as Buffer_2 } from 'node:buffer';
|
|
2
|
-
import { DetachOptions } from '@orkestrel/process';
|
|
3
|
-
import { EmitterInterface } from '@orkestrel/emitter';
|
|
4
|
-
import { ExecutableOptions } from '@orkestrel/process';
|
|
5
|
-
import { ExecuteInput } from '@orkestrel/process';
|
|
6
|
-
import { ExecuteOptions } from '@orkestrel/process';
|
|
7
|
-
import { ExecuteResult } from '@orkestrel/process';
|
|
8
|
-
import { ExecuteSyncOptions } from '@orkestrel/process';
|
|
9
|
-
import { ProcessCommand } from '@orkestrel/process';
|
|
10
|
-
import { ProcessEventMap } from '@orkestrel/process';
|
|
11
|
-
import { ProcessExit } from '@orkestrel/process';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { Readable } from 'node:stream';
|
|
23
|
-
import { SessionEventMap } from '@orkestrel/process';
|
|
24
|
-
import { SessionInterface } from '@orkestrel/process';
|
|
25
|
-
import { SessionInterface as SessionInterface_2 } from '@orkestrel/process';
|
|
26
|
-
import { SessionOptions } from '@orkestrel/process';
|
|
27
|
-
import { SessionOptions as SessionOptions_2 } from '@orkestrel/process';
|
|
28
|
-
import { SpawnInput } from '@orkestrel/process';
|
|
2
|
+
import type { DetachOptions } from '@orkestrel/process';
|
|
3
|
+
import type { EmitterInterface } from '@orkestrel/emitter';
|
|
4
|
+
import type { ExecutableOptions } from '@orkestrel/process';
|
|
5
|
+
import type { ExecuteInput } from '@orkestrel/process';
|
|
6
|
+
import type { ExecuteOptions } from '@orkestrel/process';
|
|
7
|
+
import type { ExecuteResult } from '@orkestrel/process';
|
|
8
|
+
import type { ExecuteSyncOptions } from '@orkestrel/process';
|
|
9
|
+
import type { ProcessCommand } from '@orkestrel/process';
|
|
10
|
+
import type { ProcessEventMap } from '@orkestrel/process';
|
|
11
|
+
import type { ProcessExit } from '@orkestrel/process';
|
|
12
|
+
import type { ProcessInterface } from '@orkestrel/process';
|
|
13
|
+
import type { ProcessManagerEventMap } from '@orkestrel/process';
|
|
14
|
+
import type { ProcessManagerInterface } from '@orkestrel/process';
|
|
15
|
+
import type { ProcessManagerOptions } from '@orkestrel/process';
|
|
16
|
+
import type { ProcessOptions } from '@orkestrel/process';
|
|
17
|
+
import type { Readable } from 'node:stream';
|
|
18
|
+
import type { SessionEventMap } from '@orkestrel/process';
|
|
19
|
+
import type { SessionInterface } from '@orkestrel/process';
|
|
20
|
+
import type { SessionOptions } from '@orkestrel/process';
|
|
21
|
+
import type { SpawnInput } from '@orkestrel/process';
|
|
29
22
|
|
|
30
23
|
/**
|
|
31
24
|
* Builds the executable candidates an explicit platform would search.
|
|
32
25
|
*
|
|
33
26
|
* @remarks
|
|
34
27
|
* Windows alone needs this list: the host searches the working directory before `PATH` and applies
|
|
35
|
-
* `PATHEXT`, and Node reproduces neither for a direct spawn. Within each searched directory
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* `report.txt
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* `PATHEXT`
|
|
42
|
-
* treats as the same file. A non-Windows platform returns an empty list
|
|
43
|
-
* its own lookup.
|
|
28
|
+
* `PATHEXT`, and Node reproduces neither for a direct spawn. Within each searched directory,
|
|
29
|
+
* {@link buildExecutableCandidates} enumerates `PATHEXT` candidates for an extensionless name. For
|
|
30
|
+
* an extension-bearing name, it enumerates the literal path before `PATHEXT` candidates, so
|
|
31
|
+
* `report.txt` resolves to a `report.txt` file where one exists and to `report.txt.cmd` where none
|
|
32
|
+
* does. The lookup reads the child's effective environment, so an overridden `PATH` selects the
|
|
33
|
+
* executable the child would have found. A POSIX host resolves the file itself, so the candidate
|
|
34
|
+
* list there is empty. A `PATHEXT` candidate keeps the extension spelling from `PATHEXT`, which the
|
|
35
|
+
* case-insensitive host treats as the same file. A non-Windows platform returns an empty list
|
|
36
|
+
* because `execvp` performs its own lookup.
|
|
44
37
|
*
|
|
45
38
|
* @param file - The command executable name or path
|
|
46
39
|
* @param workspace - The directory searched first
|
|
@@ -114,6 +107,10 @@ export declare function buildPlatformSpawn(command: ProcessCommand, file: string
|
|
|
114
107
|
/**
|
|
115
108
|
* Builds the resolved spawn form of one command for the current host.
|
|
116
109
|
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* When executable lookup returns no regular-file candidate, {@link buildSpawn} preserves the
|
|
112
|
+
* command file as written for native spawning.
|
|
113
|
+
*
|
|
117
114
|
* @param command - The executable and its argument vector
|
|
118
115
|
* @param options - The directory searched first and the child's effective environment
|
|
119
116
|
* @returns The file, argument vector, and verbatim flag to spawn with
|
|
@@ -151,26 +148,37 @@ export declare function buildSpawn(command: ProcessCommand, options?: Executable
|
|
|
151
148
|
export declare function captureChunk(chunk: unknown, room: number): Buffer_2 | undefined;
|
|
152
149
|
|
|
153
150
|
/**
|
|
154
|
-
* Creates one supervised child process
|
|
151
|
+
* Creates one supervised child process and returns it as a {@link ProcessInterface}, so a caller
|
|
152
|
+
* holds the published contract rather than the `Process` class.
|
|
155
153
|
*
|
|
156
154
|
* @param options - Command, workspace, termination, evidence, stdin, and observation settings
|
|
157
155
|
* @returns The launched {@link ProcessInterface}
|
|
158
156
|
*
|
|
159
|
-
* @example
|
|
157
|
+
* @example Supervise a child and read its lines
|
|
160
158
|
* ```ts
|
|
161
159
|
* import { createProcess } from '@orkestrel/process/server'
|
|
162
160
|
*
|
|
163
161
|
* const child = createProcess({
|
|
164
|
-
* command: { file: 'node', arguments: ['
|
|
162
|
+
* command: { file: 'node', arguments: ['-e', 'console.log("ready"); console.log("done")'] },
|
|
165
163
|
* workspace: process.cwd(),
|
|
166
|
-
* grace:
|
|
164
|
+
* grace: 5_000, // POSIX only: the window between SIGTERM and SIGKILL
|
|
167
165
|
* })
|
|
166
|
+
*
|
|
167
|
+
* const lines: string[] = []
|
|
168
|
+
* for await (const line of child.lines) lines.push(line)
|
|
169
|
+
* lines // ['ready', 'done']
|
|
170
|
+
*
|
|
171
|
+
* const exit = await child.exit
|
|
172
|
+
* exit.code // 0
|
|
173
|
+
* await child.destroy()
|
|
168
174
|
* ```
|
|
169
175
|
*/
|
|
170
176
|
export declare function createProcess(options: ProcessOptions): ProcessInterface;
|
|
171
177
|
|
|
172
178
|
/**
|
|
173
|
-
* Creates one keyed registry of supervised child processes
|
|
179
|
+
* Creates one empty keyed registry of supervised child processes and returns it as a
|
|
180
|
+
* {@link ProcessManagerInterface}, so a caller holds the published contract rather than the
|
|
181
|
+
* `ProcessManager` class.
|
|
174
182
|
*
|
|
175
183
|
* @param options - Initial fleet-level observation hooks and listener-error handling
|
|
176
184
|
* @returns The {@link ProcessManagerInterface} registry
|
|
@@ -185,7 +193,8 @@ export declare function createProcess(options: ProcessOptions): ProcessInterface
|
|
|
185
193
|
export declare function createProcessManager(options?: ProcessManagerOptions): ProcessManagerInterface;
|
|
186
194
|
|
|
187
195
|
/**
|
|
188
|
-
* Creates one raw byte session over a supervised child process
|
|
196
|
+
* Creates one raw byte session over a supervised child process and returns it as a
|
|
197
|
+
* {@link SessionInterface}, so a caller holds the published contract rather than the `Session` class.
|
|
189
198
|
*
|
|
190
199
|
* @param options - Command, workspace, termination, evidence, stdin, and observation settings
|
|
191
200
|
* @returns The launched {@link SessionInterface}
|
|
@@ -416,7 +425,8 @@ export declare function mergeEnvironment(isolated: boolean, base?: Readonly<Reco
|
|
|
416
425
|
export declare function mergePlatformEnvironment(platform: NodeJS.Platform, parent: Readonly<Record<string, string | undefined>>, isolated: boolean, base?: Readonly<Record<string, string | undefined>>, override?: Readonly<Record<string, string | undefined>>): NodeJS.ProcessEnv;
|
|
417
426
|
|
|
418
427
|
/**
|
|
419
|
-
* Supervises one child
|
|
428
|
+
* Supervises one child, frames its standard output into lines under a bounded backlog, and keeps
|
|
429
|
+
* every observation channel aligned at termination.
|
|
420
430
|
*
|
|
421
431
|
* @remarks
|
|
422
432
|
* The child's ending and the supervision's ending are distinct. `pid`, `code`, and `signal` read
|
|
@@ -446,7 +456,7 @@ export declare function mergePlatformEnvironment(platform: NodeJS.Platform, pare
|
|
|
446
456
|
* await child.destroy()
|
|
447
457
|
* ```
|
|
448
458
|
*/
|
|
449
|
-
export declare class Process implements
|
|
459
|
+
export declare class Process implements ProcessInterface {
|
|
450
460
|
#private;
|
|
451
461
|
/**
|
|
452
462
|
* Spawns one child process and begins stream capture.
|
|
@@ -454,7 +464,7 @@ export declare class Process implements ProcessInterface_2 {
|
|
|
454
464
|
* @param options - Command, workspace, termination, capture, stdin, and observation settings
|
|
455
465
|
* @throws A {@link ProcessError} coded `invalid` when an option or command string is malformed
|
|
456
466
|
*/
|
|
457
|
-
constructor(options:
|
|
467
|
+
constructor(options: ProcessOptions);
|
|
458
468
|
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
459
469
|
get pid(): number | undefined;
|
|
460
470
|
/** Holds the exit code the host recorded, or `null` while the child has not exited and when a signal ended it. */
|
|
@@ -474,7 +484,7 @@ export declare class Process implements ProcessInterface_2 {
|
|
|
474
484
|
/** Reports whether termination began, including after the terminal moment. */
|
|
475
485
|
get stopping(): boolean;
|
|
476
486
|
/** Settles with the terminal child state, observed once after stream close or the drain cutoff. */
|
|
477
|
-
get exit(): Promise<
|
|
487
|
+
get exit(): Promise<ProcessExit>;
|
|
478
488
|
/**
|
|
479
489
|
* Writes one line to the open standard-input channel.
|
|
480
490
|
*
|
|
@@ -587,7 +597,8 @@ export declare interface ProcessChildInterface {
|
|
|
587
597
|
}
|
|
588
598
|
|
|
589
599
|
/**
|
|
590
|
-
*
|
|
600
|
+
* Launches supervised children under caller-chosen ids, evicts each one as it settles, and destroys
|
|
601
|
+
* every live child on teardown.
|
|
591
602
|
*
|
|
592
603
|
* @remarks
|
|
593
604
|
* A child launched under an id joins the registry and emits `launch`; when it settles it removes
|
|
@@ -615,14 +626,14 @@ export declare interface ProcessChildInterface {
|
|
|
615
626
|
* await manager.destroy()
|
|
616
627
|
* ```
|
|
617
628
|
*/
|
|
618
|
-
export declare class ProcessManager implements
|
|
629
|
+
export declare class ProcessManager implements ProcessManagerInterface {
|
|
619
630
|
#private;
|
|
620
631
|
/**
|
|
621
632
|
* Constructs a process registry.
|
|
622
633
|
*
|
|
623
634
|
* @param options - Initial fleet-level observation hooks and listener-error handling
|
|
624
635
|
*/
|
|
625
|
-
constructor(options?:
|
|
636
|
+
constructor(options?: ProcessManagerOptions);
|
|
626
637
|
/** Holds the typed fleet-level observation surface. */
|
|
627
638
|
get emitter(): EmitterInterface<ProcessManagerEventMap>;
|
|
628
639
|
/** Counts the live children. */
|
|
@@ -633,13 +644,13 @@ export declare class ProcessManager implements ProcessManagerInterface_2 {
|
|
|
633
644
|
* @param id - The registry key
|
|
634
645
|
* @returns The child, or `undefined`
|
|
635
646
|
*/
|
|
636
|
-
process(id: string):
|
|
647
|
+
process(id: string): ProcessInterface | undefined;
|
|
637
648
|
/**
|
|
638
649
|
* Returns a snapshot of every live child.
|
|
639
650
|
*
|
|
640
651
|
* @returns The live children in launch order
|
|
641
652
|
*/
|
|
642
|
-
processes(): readonly
|
|
653
|
+
processes(): readonly ProcessInterface[];
|
|
643
654
|
/**
|
|
644
655
|
* Spawns and registers one child under `id`.
|
|
645
656
|
*
|
|
@@ -657,7 +668,7 @@ export declare class ProcessManager implements ProcessManagerInterface_2 {
|
|
|
657
668
|
* @returns The launched child
|
|
658
669
|
* @throws A {@link ProcessError} coded `duplicate` when `id` is already live, `protocol` when the registry is being destroyed, or `invalid` when an option or command string is malformed
|
|
659
670
|
*/
|
|
660
|
-
launch(id: string, options:
|
|
671
|
+
launch(id: string, options: ProcessOptions): ProcessInterface;
|
|
661
672
|
/**
|
|
662
673
|
* Terminates the named children and awaits their exit.
|
|
663
674
|
*
|
|
@@ -745,7 +756,12 @@ export declare function readPlatformVariable(environment: Readonly<Record<string
|
|
|
745
756
|
export declare function readVariable(environment: Readonly<Record<string, string | undefined>>, name: string): string | undefined;
|
|
746
757
|
|
|
747
758
|
/**
|
|
748
|
-
* Resolves a command file to the executable path the host would launch
|
|
759
|
+
* Resolves a command file to the executable path the host would launch, or to `undefined` on a POSIX
|
|
760
|
+
* host, which performs its own lookup.
|
|
761
|
+
*
|
|
762
|
+
* @remarks
|
|
763
|
+
* A Windows lookup miss also returns `undefined`. {@link buildSpawn} preserves the command file as
|
|
764
|
+
* written for native spawning.
|
|
749
765
|
*
|
|
750
766
|
* @param file - The command executable name or path
|
|
751
767
|
* @param options - The directory searched first and the child's effective environment
|
|
@@ -789,7 +805,7 @@ export declare function resolveExecutable(file: string, options?: ExecutableOpti
|
|
|
789
805
|
* })
|
|
790
806
|
* ```
|
|
791
807
|
*/
|
|
792
|
-
export declare class Session implements
|
|
808
|
+
export declare class Session implements SessionInterface {
|
|
793
809
|
#private;
|
|
794
810
|
/**
|
|
795
811
|
* Spawns one child process and begins byte capture.
|
|
@@ -797,7 +813,7 @@ export declare class Session implements SessionInterface_2 {
|
|
|
797
813
|
* @param options - Command, workspace, termination, evidence, stdin, and observation settings
|
|
798
814
|
* @throws A {@link ProcessError} coded `invalid` when an option or command string is malformed
|
|
799
815
|
*/
|
|
800
|
-
constructor(options:
|
|
816
|
+
constructor(options: SessionOptions);
|
|
801
817
|
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
802
818
|
get pid(): number | undefined;
|
|
803
819
|
/** Holds the exit code the host recorded, or `null` while the child has not exited and when a signal ended it. */
|
|
@@ -815,7 +831,7 @@ export declare class Session implements SessionInterface_2 {
|
|
|
815
831
|
/** Settles at the child's own ending, awaited without the terminal moment's drain window. */
|
|
816
832
|
get ending(): Promise<void>;
|
|
817
833
|
/** Settles with the terminal child state, observed once after stream close or the drain cutoff. */
|
|
818
|
-
get exit(): Promise<
|
|
834
|
+
get exit(): Promise<ProcessExit>;
|
|
819
835
|
/**
|
|
820
836
|
* Writes raw bytes to the open standard-input channel.
|
|
821
837
|
*
|
|
@@ -972,7 +988,7 @@ export declare class Supervisor {
|
|
|
972
988
|
* @param face - The composing face's callbacks for each lifecycle moment
|
|
973
989
|
* @throws A {@link ProcessError} coded `invalid` when an option or command string is malformed
|
|
974
990
|
*/
|
|
975
|
-
constructor(options:
|
|
991
|
+
constructor(options: ProcessOptions, face: SupervisorFace);
|
|
976
992
|
/** Holds the child's standard-output stream, for the composing face to attach its own consumer to. */
|
|
977
993
|
get stdout(): Readable;
|
|
978
994
|
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
@@ -997,7 +1013,7 @@ export declare class Supervisor {
|
|
|
997
1013
|
*/
|
|
998
1014
|
get ending(): Promise<void>;
|
|
999
1015
|
/** Settles with the terminal child state, observed once after stream close or the drain cutoff. */
|
|
1000
|
-
get exit(): Promise<
|
|
1016
|
+
get exit(): Promise<ProcessExit>;
|
|
1001
1017
|
/**
|
|
1002
1018
|
* Writes raw bytes to the open standard-input channel.
|
|
1003
1019
|
*
|