@orkestrel/process 0.0.9 → 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 +134 -89
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +292 -77
- package/dist/src/server/index.d.ts +292 -77
- package/dist/src/server/index.js +134 -90
- package/dist/src/server/index.js.map +1 -1
- package/package.json +10 -10
package/dist/src/server/index.js
CHANGED
|
@@ -8,6 +8,42 @@ import { PROCESS_BACKLOG, PROCESS_CONFIRMATION, PROCESS_DRAIN, PROCESS_EVIDENCE,
|
|
|
8
8
|
import { createInterface } from "node:readline";
|
|
9
9
|
import { Emitter } from "@orkestrel/emitter";
|
|
10
10
|
import { StringDecoder } from "node:string_decoder";
|
|
11
|
+
//#region src/server/cloners.ts
|
|
12
|
+
/**
|
|
13
|
+
* Takes one owned frozen snapshot of a caller's command.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Every public entry point snapshots before it validates, so the object validated is the object
|
|
17
|
+
* spawned. Each property is read exactly once, because reading one runs the caller's own getter: a
|
|
18
|
+
* command whose `file` changes between reads would otherwise validate one executable and spawn
|
|
19
|
+
* another. The argument vector and the environment record are copied and frozen, so a caller
|
|
20
|
+
* mutating either after the call cannot reach the spawn. An absent optional stays absent rather than
|
|
21
|
+
* becoming an explicit `undefined`.
|
|
22
|
+
*
|
|
23
|
+
* @param command - The caller's command, whose properties may be getters
|
|
24
|
+
* @returns A frozen command carrying the values read at this instant
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* snapshotCommand({ file: 'git', arguments: ['status'] }) // { file: 'git', arguments: ['status'] }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function snapshotCommand(command) {
|
|
32
|
+
const file = command.file;
|
|
33
|
+
const argumentsList = Object.freeze([...command.arguments]);
|
|
34
|
+
const sourceEnvironment = command.environment;
|
|
35
|
+
const environment = sourceEnvironment === void 0 ? void 0 : Object.freeze({ ...sourceEnvironment });
|
|
36
|
+
const input = command.input;
|
|
37
|
+
const isolated = command.isolated;
|
|
38
|
+
return Object.freeze({
|
|
39
|
+
file,
|
|
40
|
+
arguments: argumentsList,
|
|
41
|
+
...environment === void 0 ? {} : { environment },
|
|
42
|
+
...input === void 0 ? {} : { input },
|
|
43
|
+
...isolated === void 0 ? {} : { isolated }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
11
47
|
//#region src/server/helpers.ts
|
|
12
48
|
/**
|
|
13
49
|
* Trims a buffer to at most `limit` trailing bytes without splitting a UTF-8 sequence.
|
|
@@ -106,40 +142,6 @@ function captureChunk(chunk, room) {
|
|
|
106
142
|
return Buffer.from(chunk.subarray(0, room));
|
|
107
143
|
}
|
|
108
144
|
/**
|
|
109
|
-
* Takes one owned frozen snapshot of a caller's command.
|
|
110
|
-
*
|
|
111
|
-
* @remarks
|
|
112
|
-
* Every public entry point snapshots before it validates, so the object validated is the object
|
|
113
|
-
* spawned. Each property is read exactly once, because reading one runs the caller's own getter: a
|
|
114
|
-
* command whose `file` changes between reads would otherwise validate one executable and spawn
|
|
115
|
-
* another. The argument vector and the environment record are copied and frozen, so a caller
|
|
116
|
-
* mutating either after the call cannot reach the spawn. An absent optional stays absent rather than
|
|
117
|
-
* becoming an explicit `undefined`.
|
|
118
|
-
*
|
|
119
|
-
* @param command - The caller's command, whose properties may be getters
|
|
120
|
-
* @returns A frozen command carrying the values read at this instant
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```ts
|
|
124
|
-
* snapshotCommand({ file: 'git', arguments: ['status'] }) // { file: 'git', arguments: ['status'] }
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
function snapshotCommand(command) {
|
|
128
|
-
const file = command.file;
|
|
129
|
-
const argumentsList = Object.freeze([...command.arguments]);
|
|
130
|
-
const sourceEnvironment = command.environment;
|
|
131
|
-
const environment = sourceEnvironment === void 0 ? void 0 : Object.freeze({ ...sourceEnvironment });
|
|
132
|
-
const input = command.input;
|
|
133
|
-
const isolated = command.isolated;
|
|
134
|
-
return Object.freeze({
|
|
135
|
-
file,
|
|
136
|
-
arguments: argumentsList,
|
|
137
|
-
...environment === void 0 ? {} : { environment },
|
|
138
|
-
...input === void 0 ? {} : { input },
|
|
139
|
-
...isolated === void 0 ? {} : { isolated }
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
145
|
* Renders one command into its diagnostic command line.
|
|
144
146
|
*
|
|
145
147
|
* @param command - The executable and its argument vector
|
|
@@ -256,7 +258,7 @@ function mergeEnvironment(isolated, base, override) {
|
|
|
256
258
|
* command. An unreadable or malformed path reports `false` rather than throwing.
|
|
257
259
|
*
|
|
258
260
|
* @param target - The absolute or relative path to inspect
|
|
259
|
-
* @returns True
|
|
261
|
+
* @returns True if the path resolves to a regular file; false otherwise
|
|
260
262
|
*
|
|
261
263
|
* @example
|
|
262
264
|
* ```ts
|
|
@@ -529,7 +531,7 @@ function validateWorkspace(workspace) {
|
|
|
529
531
|
* initiated against a pid the host may have reused.
|
|
530
532
|
*
|
|
531
533
|
* @param child - The child boundary
|
|
532
|
-
* @returns True
|
|
534
|
+
* @returns True if the process has exited; false otherwise
|
|
533
535
|
*
|
|
534
536
|
* @example
|
|
535
537
|
* ```ts
|
|
@@ -585,7 +587,7 @@ function killProcess(child, signal) {
|
|
|
585
587
|
*
|
|
586
588
|
* @param pid - The root process id of the tree to end
|
|
587
589
|
* @param timeout - The milliseconds the utility is given before it is killed
|
|
588
|
-
* @returns True
|
|
590
|
+
* @returns True if the utility reported success; false otherwise (it failed, was unavailable, or was cut off)
|
|
589
591
|
*
|
|
590
592
|
* @example
|
|
591
593
|
* ```ts
|
|
@@ -636,7 +638,7 @@ function waitForExit(child, timeout) {
|
|
|
636
638
|
*
|
|
637
639
|
* @param child - The child boundary
|
|
638
640
|
* @param timeout - The milliseconds to wait before giving up
|
|
639
|
-
* @returns True
|
|
641
|
+
* @returns True if the host close arrived inside the deadline; false otherwise
|
|
640
642
|
*
|
|
641
643
|
* @example
|
|
642
644
|
* ```ts
|
|
@@ -671,7 +673,7 @@ function waitForClose(child, timeout) {
|
|
|
671
673
|
* @param child - The child boundary
|
|
672
674
|
* @param grace - The cooperative POSIX window in milliseconds between `SIGTERM` and `SIGKILL`
|
|
673
675
|
* @param confirm - The milliseconds the native exit is awaited after the final kill
|
|
674
|
-
* @returns True
|
|
676
|
+
* @returns True if the native exit was observed; false otherwise (`confirm` elapsed without it)
|
|
675
677
|
*
|
|
676
678
|
* @example
|
|
677
679
|
* ```ts
|
|
@@ -1029,7 +1031,7 @@ function detach(command, options) {
|
|
|
1029
1031
|
child.unref();
|
|
1030
1032
|
}
|
|
1031
1033
|
//#endregion
|
|
1032
|
-
//#region src/server/Supervisor.ts
|
|
1034
|
+
//#region src/server/processes/Supervisor.ts
|
|
1033
1035
|
/**
|
|
1034
1036
|
* Supervises one child process and reports each lifecycle moment to the face composing it.
|
|
1035
1037
|
*
|
|
@@ -1058,6 +1060,25 @@ function detach(command, options) {
|
|
|
1058
1060
|
* termination completes. `relieve` is optional because a face that never pauses the child's output
|
|
1059
1061
|
* holds no backpressure to release, and a face with nothing to do there would otherwise declare an
|
|
1060
1062
|
* empty method to say so.
|
|
1063
|
+
*
|
|
1064
|
+
* @example
|
|
1065
|
+
* ```ts
|
|
1066
|
+
* import { Supervisor } from '@orkestrel/process/server'
|
|
1067
|
+
*
|
|
1068
|
+
* const engine = new Supervisor(
|
|
1069
|
+
* { command: { file: 'node', arguments: ['--version'] }, workspace: process.cwd() },
|
|
1070
|
+
* {
|
|
1071
|
+
* chunk: () => undefined,
|
|
1072
|
+
* fault: () => undefined,
|
|
1073
|
+
* close: () => undefined,
|
|
1074
|
+
* terminal: () => undefined,
|
|
1075
|
+
* teardown: () => undefined,
|
|
1076
|
+
* },
|
|
1077
|
+
* )
|
|
1078
|
+
* const exit = await engine.exit
|
|
1079
|
+
* exit.code // 0
|
|
1080
|
+
* await engine.destroy()
|
|
1081
|
+
* ```
|
|
1061
1082
|
*/
|
|
1062
1083
|
var Supervisor = class {
|
|
1063
1084
|
#chunk;
|
|
@@ -1087,7 +1108,7 @@ var Supervisor = class {
|
|
|
1087
1108
|
#termination;
|
|
1088
1109
|
#destruction;
|
|
1089
1110
|
/**
|
|
1090
|
-
*
|
|
1111
|
+
* Spawns one child process and begins standard-error capture.
|
|
1091
1112
|
*
|
|
1092
1113
|
* @remarks
|
|
1093
1114
|
* The face's callbacks are captured before anything is read or spawned, so the first moment the
|
|
@@ -1164,36 +1185,36 @@ var Supervisor = class {
|
|
|
1164
1185
|
if (signal.aborted) this.stop();
|
|
1165
1186
|
}
|
|
1166
1187
|
}
|
|
1167
|
-
/**
|
|
1188
|
+
/** Holds the child's standard-output stream, for the composing face to attach its own consumer to. */
|
|
1168
1189
|
get stdout() {
|
|
1169
1190
|
return this.#child.stdout;
|
|
1170
1191
|
}
|
|
1171
|
-
/**
|
|
1192
|
+
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
1172
1193
|
get pid() {
|
|
1173
1194
|
return this.#child.pid;
|
|
1174
1195
|
}
|
|
1175
|
-
/**
|
|
1196
|
+
/** Holds the exit code the host recorded, or `null` while the child has not exited and when a signal ended it. */
|
|
1176
1197
|
get code() {
|
|
1177
1198
|
return this.#child.exitCode;
|
|
1178
1199
|
}
|
|
1179
|
-
/**
|
|
1200
|
+
/** Holds the terminating signal name the host recorded, or `null` while the child has not exited and when it exited on its own. */
|
|
1180
1201
|
get signal() {
|
|
1181
1202
|
return this.#child.signalCode;
|
|
1182
1203
|
}
|
|
1183
|
-
/**
|
|
1204
|
+
/** Holds the decoded byte-bounded stderr tail, frozen at the terminal moment. */
|
|
1184
1205
|
get evidence() {
|
|
1185
1206
|
return this.#tail.toString("utf8");
|
|
1186
1207
|
}
|
|
1187
|
-
/**
|
|
1208
|
+
/** Reports whether the terminal moment arrived and `exit` settled. */
|
|
1188
1209
|
get settled() {
|
|
1189
1210
|
return this.#settled;
|
|
1190
1211
|
}
|
|
1191
|
-
/**
|
|
1212
|
+
/** Reports whether termination began, including after the terminal moment. */
|
|
1192
1213
|
get stopping() {
|
|
1193
1214
|
return this.#stopping;
|
|
1194
1215
|
}
|
|
1195
1216
|
/**
|
|
1196
|
-
*
|
|
1217
|
+
* Settles at the child's own ending, awaited without the terminal moment's drain window.
|
|
1197
1218
|
*
|
|
1198
1219
|
* @remarks
|
|
1199
1220
|
* Never rejects, and resolves no value: `code` and `signal` carry the terminal facts as soon as
|
|
@@ -1203,7 +1224,7 @@ var Supervisor = class {
|
|
|
1203
1224
|
get ending() {
|
|
1204
1225
|
return this.#ending.promise;
|
|
1205
1226
|
}
|
|
1206
|
-
/**
|
|
1227
|
+
/** Settles with the terminal child state, observed once after stream close or the drain cutoff. */
|
|
1207
1228
|
get exit() {
|
|
1208
1229
|
return this.#exit.promise;
|
|
1209
1230
|
}
|
|
@@ -1220,7 +1241,30 @@ var Supervisor = class {
|
|
|
1220
1241
|
* discard.
|
|
1221
1242
|
*
|
|
1222
1243
|
* @param bytes - The payload to write, already framed by the caller
|
|
1223
|
-
* @returns True
|
|
1244
|
+
* @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`)
|
|
1245
|
+
*
|
|
1246
|
+
* @example
|
|
1247
|
+
* ```ts
|
|
1248
|
+
* import { Supervisor } from '@orkestrel/process/server'
|
|
1249
|
+
*
|
|
1250
|
+
* const engine = new Supervisor(
|
|
1251
|
+
* {
|
|
1252
|
+
* command: { file: 'node', arguments: ['-e', 'process.stdin.pipe(process.stdout)'] },
|
|
1253
|
+
* workspace: process.cwd(),
|
|
1254
|
+
* writable: true,
|
|
1255
|
+
* },
|
|
1256
|
+
* {
|
|
1257
|
+
* chunk: () => undefined,
|
|
1258
|
+
* fault: () => undefined,
|
|
1259
|
+
* close: () => undefined,
|
|
1260
|
+
* terminal: () => undefined,
|
|
1261
|
+
* teardown: () => undefined,
|
|
1262
|
+
* },
|
|
1263
|
+
* )
|
|
1264
|
+
* const accepted = await engine.deliver(new TextEncoder().encode('ping\n'))
|
|
1265
|
+
* accepted // true
|
|
1266
|
+
* await engine.destroy()
|
|
1267
|
+
* ```
|
|
1224
1268
|
*/
|
|
1225
1269
|
deliver(bytes) {
|
|
1226
1270
|
const stdin = this.#child.stdin;
|
|
@@ -1271,7 +1315,7 @@ var Supervisor = class {
|
|
|
1271
1315
|
* and settles `exit` when they remain open. A cutoff reached before the native exit reports the
|
|
1272
1316
|
* `code` and `signal` the host had recorded by then, which is `null` for a child still running.
|
|
1273
1317
|
*
|
|
1274
|
-
* @returns True
|
|
1318
|
+
* @returns True if the child's native exit was observed; false otherwise (the confirmation deadline elapsed without it)
|
|
1275
1319
|
*/
|
|
1276
1320
|
stop() {
|
|
1277
1321
|
if (this.#termination !== void 0) return this.#termination;
|
|
@@ -1399,7 +1443,7 @@ var Supervisor = class {
|
|
|
1399
1443
|
}
|
|
1400
1444
|
};
|
|
1401
1445
|
//#endregion
|
|
1402
|
-
//#region src/server/Process.ts
|
|
1446
|
+
//#region src/server/processes/Process.ts
|
|
1403
1447
|
/**
|
|
1404
1448
|
* Supervises one child while keeping every observation channel aligned at termination.
|
|
1405
1449
|
*
|
|
@@ -1446,7 +1490,7 @@ var Process = class {
|
|
|
1446
1490
|
#truncated = false;
|
|
1447
1491
|
#ended = false;
|
|
1448
1492
|
/**
|
|
1449
|
-
*
|
|
1493
|
+
* Spawns one child process and begins stream capture.
|
|
1450
1494
|
*
|
|
1451
1495
|
* @param options - Command, workspace, termination, capture, stdin, and observation settings
|
|
1452
1496
|
* @throws A {@link ProcessError} coded `invalid` when an option or command string is malformed
|
|
@@ -1501,48 +1545,48 @@ var Process = class {
|
|
|
1501
1545
|
this.#reader.on("line", this.#push.bind(this));
|
|
1502
1546
|
this.#reader.once("close", this.#finish.bind(this));
|
|
1503
1547
|
}
|
|
1504
|
-
/**
|
|
1548
|
+
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
1505
1549
|
get pid() {
|
|
1506
1550
|
return this.#engine.pid;
|
|
1507
1551
|
}
|
|
1508
|
-
/**
|
|
1552
|
+
/** Holds the exit code the host recorded, or `null` while the child has not exited and when a signal ended it. */
|
|
1509
1553
|
get code() {
|
|
1510
1554
|
return this.#engine.code;
|
|
1511
1555
|
}
|
|
1512
|
-
/**
|
|
1556
|
+
/** Holds the terminating signal name the host recorded, or `null` while the child has not exited and when it exited on its own. */
|
|
1513
1557
|
get signal() {
|
|
1514
1558
|
return this.#engine.signal;
|
|
1515
1559
|
}
|
|
1516
|
-
/**
|
|
1560
|
+
/** Holds the typed lifecycle observation surface. */
|
|
1517
1561
|
get emitter() {
|
|
1518
1562
|
return this.#emitter;
|
|
1519
1563
|
}
|
|
1520
|
-
/**
|
|
1564
|
+
/** Yields the captured stdout lines, in arrival order, ending after queued lines at the terminal moment. */
|
|
1521
1565
|
get lines() {
|
|
1522
1566
|
return this.#lines;
|
|
1523
1567
|
}
|
|
1524
|
-
/**
|
|
1568
|
+
/** Holds the decoded byte-bounded stderr tail, frozen at the terminal moment. */
|
|
1525
1569
|
get evidence() {
|
|
1526
1570
|
return this.#engine.evidence;
|
|
1527
1571
|
}
|
|
1528
|
-
/**
|
|
1572
|
+
/** Reports whether the `lines` stream omitted output after a retention bound was reached. */
|
|
1529
1573
|
get truncated() {
|
|
1530
1574
|
return this.#truncated;
|
|
1531
1575
|
}
|
|
1532
|
-
/**
|
|
1576
|
+
/** Reports whether the terminal moment arrived and `exit` settled. */
|
|
1533
1577
|
get settled() {
|
|
1534
1578
|
return this.#engine.settled;
|
|
1535
1579
|
}
|
|
1536
|
-
/**
|
|
1580
|
+
/** Reports whether termination began, including after the terminal moment. */
|
|
1537
1581
|
get stopping() {
|
|
1538
1582
|
return this.#engine.stopping;
|
|
1539
1583
|
}
|
|
1540
|
-
/**
|
|
1584
|
+
/** Settles with the terminal child state, observed once after stream close or the drain cutoff. */
|
|
1541
1585
|
get exit() {
|
|
1542
1586
|
return this.#engine.exit;
|
|
1543
1587
|
}
|
|
1544
1588
|
/**
|
|
1545
|
-
*
|
|
1589
|
+
* Writes one line to the open standard-input channel.
|
|
1546
1590
|
*
|
|
1547
1591
|
* @remarks
|
|
1548
1592
|
* Never rejects. `true` means the host accepted the bytes without reporting a fault; it does not
|
|
@@ -1556,7 +1600,7 @@ var Process = class {
|
|
|
1556
1600
|
* for bytes the package is about to discard.
|
|
1557
1601
|
*
|
|
1558
1602
|
* @param text - The line text without its trailing newline
|
|
1559
|
-
* @returns True
|
|
1603
|
+
* @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`)
|
|
1560
1604
|
*/
|
|
1561
1605
|
send(text) {
|
|
1562
1606
|
return this.#engine.deliver(Buffer.from(`${text}\n`, "utf8"));
|
|
@@ -1570,7 +1614,7 @@ var Process = class {
|
|
|
1570
1614
|
* and settles `exit` when they remain open. A cutoff reached before the native exit reports the
|
|
1571
1615
|
* `code` and `signal` the host had recorded by then, which is `null` for a child still running.
|
|
1572
1616
|
*
|
|
1573
|
-
* @returns True
|
|
1617
|
+
* @returns True if the child's native exit was observed; false otherwise (the confirmation deadline elapsed without it)
|
|
1574
1618
|
*/
|
|
1575
1619
|
stop() {
|
|
1576
1620
|
return this.#engine.stop();
|
|
@@ -1688,9 +1732,9 @@ var Process = class {
|
|
|
1688
1732
|
}
|
|
1689
1733
|
};
|
|
1690
1734
|
//#endregion
|
|
1691
|
-
//#region src/server/ProcessManager.ts
|
|
1735
|
+
//#region src/server/processes/ProcessManager.ts
|
|
1692
1736
|
/**
|
|
1693
|
-
*
|
|
1737
|
+
* Represents a keyed registry of live supervised child processes.
|
|
1694
1738
|
*
|
|
1695
1739
|
* @remarks
|
|
1696
1740
|
* A child launched under an id joins the registry and emits `launch`; when it settles it removes
|
|
@@ -1726,7 +1770,7 @@ var ProcessManager = class {
|
|
|
1726
1770
|
#destroying = false;
|
|
1727
1771
|
#ending;
|
|
1728
1772
|
/**
|
|
1729
|
-
*
|
|
1773
|
+
* Constructs a process registry.
|
|
1730
1774
|
*
|
|
1731
1775
|
* @param options - Initial fleet-level observation hooks and listener-error handling
|
|
1732
1776
|
*/
|
|
@@ -1738,16 +1782,16 @@ var ProcessManager = class {
|
|
|
1738
1782
|
...error === void 0 ? {} : { error }
|
|
1739
1783
|
});
|
|
1740
1784
|
}
|
|
1741
|
-
/**
|
|
1785
|
+
/** Holds the typed fleet-level observation surface. */
|
|
1742
1786
|
get emitter() {
|
|
1743
1787
|
return this.#emitter;
|
|
1744
1788
|
}
|
|
1745
|
-
/**
|
|
1789
|
+
/** Counts the live children. */
|
|
1746
1790
|
get count() {
|
|
1747
1791
|
return this.#children.size;
|
|
1748
1792
|
}
|
|
1749
1793
|
/**
|
|
1750
|
-
*
|
|
1794
|
+
* Returns the live child under `id`, or `undefined` when none is.
|
|
1751
1795
|
*
|
|
1752
1796
|
* @param id - The registry key
|
|
1753
1797
|
* @returns The child, or `undefined`
|
|
@@ -1756,7 +1800,7 @@ var ProcessManager = class {
|
|
|
1756
1800
|
return this.#children.get(id);
|
|
1757
1801
|
}
|
|
1758
1802
|
/**
|
|
1759
|
-
*
|
|
1803
|
+
* Returns a snapshot of every live child.
|
|
1760
1804
|
*
|
|
1761
1805
|
* @returns The live children in launch order
|
|
1762
1806
|
*/
|
|
@@ -1764,7 +1808,7 @@ var ProcessManager = class {
|
|
|
1764
1808
|
return [...this.#children.values()];
|
|
1765
1809
|
}
|
|
1766
1810
|
/**
|
|
1767
|
-
*
|
|
1811
|
+
* Spawns and registers one child under `id`.
|
|
1768
1812
|
*
|
|
1769
1813
|
* @remarks
|
|
1770
1814
|
* {@link Process} reads every option before it spawns, so a caller's own option getter runs while
|
|
@@ -1802,7 +1846,7 @@ var ProcessManager = class {
|
|
|
1802
1846
|
return this.#stopMany(target);
|
|
1803
1847
|
}
|
|
1804
1848
|
/**
|
|
1805
|
-
*
|
|
1849
|
+
* Stops every child, then destroys the registry emitter last.
|
|
1806
1850
|
*
|
|
1807
1851
|
* @remarks
|
|
1808
1852
|
* Always resolves, and refuses a later `launch` with a {@link createProtocolError}. Each child is
|
|
@@ -1855,7 +1899,7 @@ var ProcessManager = class {
|
|
|
1855
1899
|
}
|
|
1856
1900
|
};
|
|
1857
1901
|
//#endregion
|
|
1858
|
-
//#region src/server/Session.ts
|
|
1902
|
+
//#region src/server/processes/Session.ts
|
|
1859
1903
|
/**
|
|
1860
1904
|
* Supervises one child and publishes its standard output as raw bytes.
|
|
1861
1905
|
*
|
|
@@ -1892,7 +1936,7 @@ var Session = class {
|
|
|
1892
1936
|
#engine;
|
|
1893
1937
|
#output;
|
|
1894
1938
|
/**
|
|
1895
|
-
*
|
|
1939
|
+
* Spawns one child process and begins byte capture.
|
|
1896
1940
|
*
|
|
1897
1941
|
* @param options - Command, workspace, termination, evidence, stdin, and observation settings
|
|
1898
1942
|
* @throws A {@link ProcessError} coded `invalid` when an option or command string is malformed
|
|
@@ -1930,39 +1974,39 @@ var Session = class {
|
|
|
1930
1974
|
});
|
|
1931
1975
|
this.#engine.stdout.on("data", this.#output);
|
|
1932
1976
|
}
|
|
1933
|
-
/**
|
|
1977
|
+
/** Holds the host process id, fixed when construction returns, or `undefined` when the spawn produced none. */
|
|
1934
1978
|
get pid() {
|
|
1935
1979
|
return this.#engine.pid;
|
|
1936
1980
|
}
|
|
1937
|
-
/**
|
|
1981
|
+
/** Holds the exit code the host recorded, or `null` while the child has not exited and when a signal ended it. */
|
|
1938
1982
|
get code() {
|
|
1939
1983
|
return this.#engine.code;
|
|
1940
1984
|
}
|
|
1941
|
-
/**
|
|
1985
|
+
/** Holds the terminating signal name the host recorded, or `null` while the child has not exited and when it exited on its own. */
|
|
1942
1986
|
get signal() {
|
|
1943
1987
|
return this.#engine.signal;
|
|
1944
1988
|
}
|
|
1945
|
-
/**
|
|
1989
|
+
/** Holds the typed lifecycle observation surface. */
|
|
1946
1990
|
get emitter() {
|
|
1947
1991
|
return this.#emitter;
|
|
1948
1992
|
}
|
|
1949
|
-
/**
|
|
1993
|
+
/** Holds the decoded byte-bounded stderr tail, frozen at the terminal moment. */
|
|
1950
1994
|
get evidence() {
|
|
1951
1995
|
return this.#engine.evidence;
|
|
1952
1996
|
}
|
|
1953
|
-
/**
|
|
1997
|
+
/** Reports whether the terminal moment arrived and `exit` settled. */
|
|
1954
1998
|
get settled() {
|
|
1955
1999
|
return this.#engine.settled;
|
|
1956
2000
|
}
|
|
1957
|
-
/**
|
|
2001
|
+
/** Reports whether termination began, including after the terminal moment. `end` never turns it true. */
|
|
1958
2002
|
get stopping() {
|
|
1959
2003
|
return this.#engine.stopping;
|
|
1960
2004
|
}
|
|
1961
|
-
/**
|
|
2005
|
+
/** Settles at the child's own ending, awaited without the terminal moment's drain window. */
|
|
1962
2006
|
get ending() {
|
|
1963
2007
|
return this.#engine.ending;
|
|
1964
2008
|
}
|
|
1965
|
-
/**
|
|
2009
|
+
/** Settles with the terminal child state, observed once after stream close or the drain cutoff. */
|
|
1966
2010
|
get exit() {
|
|
1967
2011
|
return this.#engine.exit;
|
|
1968
2012
|
}
|
|
@@ -1976,7 +2020,7 @@ var Session = class {
|
|
|
1976
2020
|
* returned promise settles.
|
|
1977
2021
|
*
|
|
1978
2022
|
* @param bytes - The payload to write, already framed by the caller
|
|
1979
|
-
* @returns True
|
|
2023
|
+
* @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`)
|
|
1980
2024
|
*/
|
|
1981
2025
|
write(bytes) {
|
|
1982
2026
|
return this.#engine.deliver(bytes);
|
|
@@ -2000,7 +2044,7 @@ var Session = class {
|
|
|
2000
2044
|
* @remarks
|
|
2001
2045
|
* Never rejects, and every call shares one termination bounded by `grace` and `drain`.
|
|
2002
2046
|
*
|
|
2003
|
-
* @returns True
|
|
2047
|
+
* @returns True if the child's native exit was observed; false otherwise (the confirmation deadline elapsed without it)
|
|
2004
2048
|
*/
|
|
2005
2049
|
stop() {
|
|
2006
2050
|
return this.#engine.stop();
|
|
@@ -2092,6 +2136,6 @@ function createProcessManager(options) {
|
|
|
2092
2136
|
return new ProcessManager(options);
|
|
2093
2137
|
}
|
|
2094
2138
|
//#endregion
|
|
2095
|
-
export { Process, ProcessManager, Session, buildExecutableCandidates, buildExecuteResult, buildPlatformSpawn, buildSpawn, captureChunk, createProcess, createProcessManager, createSession, detach, execute, executeSync, formatCommand, isExited, isFile, killProcess, killTree, mergeEnvironment, mergePlatformEnvironment, quoteArgument, readPlatformVariable, readVariable, resolveExecutable, snapshotCommand, stopChild, trimHead, trimTail, validateBytes, validateCommand, validateEnvironment, validateText, validateTimer, validateWorkspace, waitForClose, waitForExit };
|
|
2139
|
+
export { Process, ProcessManager, Session, Supervisor, buildExecutableCandidates, buildExecuteResult, buildPlatformSpawn, buildSpawn, captureChunk, createProcess, createProcessManager, createSession, detach, execute, executeSync, formatCommand, isExited, isFile, killProcess, killTree, mergeEnvironment, mergePlatformEnvironment, quoteArgument, readPlatformVariable, readVariable, resolveExecutable, snapshotCommand, stopChild, trimHead, trimTail, validateBytes, validateCommand, validateEnvironment, validateText, validateTimer, validateWorkspace, waitForClose, waitForExit };
|
|
2096
2140
|
|
|
2097
2141
|
//# sourceMappingURL=index.js.map
|