@procedures/node 0.3.0 → 0.5.0
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/CHANGELOG.md +37 -0
- package/README.md +24 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +8 -4
- package/dist/module.js.map +1 -1
- package/dist/procedures/node/logs.d.ts +14 -3
- package/dist/procedures/node/logs.d.ts.map +1 -1
- package/dist/procedures/node/logs.js +55 -2
- package/dist/procedures/node/logs.js.map +1 -1
- package/dist/process-manager.d.ts +6 -0
- package/dist/process-manager.d.ts.map +1 -1
- package/dist/process-manager.js +7 -0
- package/dist/process-manager.js.map +1 -1
- package/dist/types.d.ts +32 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +23 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
- package/src/module.ts +11 -6
- package/src/procedures/node/logs.ts +56 -3
- package/src/process-manager.ts +9 -1
- package/src/types.ts +40 -1
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAoE,KAAK,eAAe,EAAuC,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAwHzL;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,eAMrB,CAAC;eAEU,UAAU;AAEzB;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,GAAE,iBAAsC,GAAG,IAAI,CAE7F"}
|
package/dist/module.js
CHANGED
|
@@ -76,20 +76,24 @@ const nodeStatusProcedure = createProcedure()
|
|
|
76
76
|
return nodeStatus(input);
|
|
77
77
|
})
|
|
78
78
|
.build();
|
|
79
|
-
// node.logs (roadmap R44)
|
|
79
|
+
// node.logs (roadmap R44). One value, or with follow one item for each line (a stream).
|
|
80
80
|
const nodeLogsProcedure = createProcedure()
|
|
81
81
|
.path(["node", "logs"])
|
|
82
82
|
.input(zodAdapter(NodeLogsInputSchema))
|
|
83
83
|
.output(zodAdapter(NodeLogsOutputSchema))
|
|
84
84
|
.meta({
|
|
85
|
-
description: "The output of a process of node.spawn: the last 64 KiB of stdout and stderr",
|
|
85
|
+
description: "The output of a process of node.spawn: the last 64 KiB of stdout and stderr, or with follow a stream of its lines",
|
|
86
86
|
args: ["processId"],
|
|
87
|
-
shorts: { lines: "n" },
|
|
87
|
+
shorts: { lines: "n", follow: "f" },
|
|
88
88
|
output: "json",
|
|
89
89
|
// It reads the output that the process registry keeps for a process of node.spawn
|
|
90
90
|
effects: { reads: ["jobs"], writes: [] },
|
|
91
|
+
// With follow, the stream runs as long as the process (roadmap R15)
|
|
92
|
+
stream: { unbounded: true },
|
|
91
93
|
})
|
|
92
|
-
|
|
94
|
+
// With follow, the promise gives a stream: invokeProcedure reads a returned async iterable as a
|
|
95
|
+
// stream, and the handler types of the core do not describe that case
|
|
96
|
+
.handler((input, ctx) => nodeLogs(input, ctx))
|
|
93
97
|
.build();
|
|
94
98
|
/**
|
|
95
99
|
* The module of this package, for `createRegistry()`: its procedures as data. Importing this
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAA+C,kBAAkB,EAAE,eAAe,EAA0B,MAAM,oBAAoB,CAAC;AACzL,OAAO,EAAE,OAAO,EAAE,MAA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gBAAgB;IAChB,kBAAkB;IAClB,iBAAiB;IACjB,mBAAmB;IACnB,iBAAiB;CAClB,CAAC,CAAC;AAEL,eAAe,UAAU,CAAC;AAE1B;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAQ,GAAsB,kBAAkB;IACrF,eAAe,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -5,12 +5,23 @@
|
|
|
5
5
|
* the output of each process and keeps its end: the last 64 KiB, stdout and stderr together.
|
|
6
6
|
* So the procedure gives that end, also after the process ended (the registry keeps the records
|
|
7
7
|
* of the last 50 ended processes). It knows only the processes of this host process.
|
|
8
|
+
*
|
|
9
|
+
* With `follow`, the procedure gives a stream: the kept output as `output` lines, then each new
|
|
10
|
+
* line of stdout and stderr, then one `exit` item at the end of the process. The stream ends at
|
|
11
|
+
* the end of the process, at an abort of the caller and when the reader stops. Each end removes
|
|
12
|
+
* the subscription of the stream from the process registry.
|
|
8
13
|
*/
|
|
9
|
-
import type { NodeLogsInput, NodeLogsOutput } from "../../types.js";
|
|
14
|
+
import type { NodeLogItem, NodeLogsInput, NodeLogsOutput } from "../../types.js";
|
|
10
15
|
/** The last `count` lines of a text. A line end at the end of the text does not count as a line. */
|
|
11
16
|
export declare function lastLines(text: string, count: number): string;
|
|
17
|
+
/** The lines of a text without their line ends (LF or CRLF). A line end at the end adds no line. */
|
|
18
|
+
export declare function splitLines(text: string): string[];
|
|
19
|
+
/** The context that node.logs reads: the abort of the caller. */
|
|
20
|
+
export interface NodeLogsContext {
|
|
21
|
+
signal?: AbortSignal | undefined;
|
|
22
|
+
}
|
|
12
23
|
/**
|
|
13
|
-
* The end of the output of a process of node.spawn
|
|
24
|
+
* The end of the output of a process of node.spawn, or with `follow` a stream of its lines
|
|
14
25
|
*/
|
|
15
|
-
export declare function nodeLogs(input: NodeLogsInput): Promise<NodeLogsOutput
|
|
26
|
+
export declare function nodeLogs(input: NodeLogsInput, ctx?: NodeLogsContext): Promise<NodeLogsOutput | AsyncGenerator<NodeLogItem, void, undefined>>;
|
|
16
27
|
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/procedures/node/logs.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/procedures/node/logs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMjF,oGAAoG;AACpG,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED,oGAAoG;AACpG,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAIjD;AAED,iEAAiE;AACjE,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAClC;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,GAAE,eAAoB,GAAG,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAYtJ"}
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* the output of each process and keeps its end: the last 64 KiB, stdout and stderr together.
|
|
6
6
|
* So the procedure gives that end, also after the process ended (the registry keeps the records
|
|
7
7
|
* of the last 50 ended processes). It knows only the processes of this host process.
|
|
8
|
+
*
|
|
9
|
+
* With `follow`, the procedure gives a stream: the kept output as `output` lines, then each new
|
|
10
|
+
* line of stdout and stderr, then one `exit` item at the end of the process. The stream ends at
|
|
11
|
+
* the end of the process, at an abort of the caller and when the reader stops. Each end removes
|
|
12
|
+
* the subscription of the stream from the process registry.
|
|
8
13
|
*/
|
|
9
14
|
import { processManager } from "../../process-manager.js";
|
|
10
15
|
// The CSI and OSC escape sequences of terminals (colors, styles, links), as client-shell removes them
|
|
@@ -17,14 +22,23 @@ export function lastLines(text, count) {
|
|
|
17
22
|
return text;
|
|
18
23
|
return lines.slice(-count).join("\n") + (text.endsWith("\n") ? "\n" : "");
|
|
19
24
|
}
|
|
25
|
+
/** The lines of a text without their line ends (LF or CRLF). A line end at the end adds no line. */
|
|
26
|
+
export function splitLines(text) {
|
|
27
|
+
if (text === "")
|
|
28
|
+
return [];
|
|
29
|
+
const lines = (text.endsWith("\n") ? text.slice(0, -1) : text).split("\n");
|
|
30
|
+
return lines.map((line) => (line.endsWith("\r") ? line.slice(0, -1) : line));
|
|
31
|
+
}
|
|
20
32
|
/**
|
|
21
|
-
* The end of the output of a process of node.spawn
|
|
33
|
+
* The end of the output of a process of node.spawn, or with `follow` a stream of its lines
|
|
22
34
|
*/
|
|
23
|
-
export async function nodeLogs(input) {
|
|
35
|
+
export async function nodeLogs(input, ctx = {}) {
|
|
24
36
|
const info = processManager.get(input.processId);
|
|
25
37
|
if (!info) {
|
|
26
38
|
throw new Error(`node.logs: no process ${input.processId}. node.status lists the processes of node.spawn on this host.`);
|
|
27
39
|
}
|
|
40
|
+
if (input.follow)
|
|
41
|
+
return followLogs(input, ctx.signal);
|
|
28
42
|
let output = processManager.output(input.processId);
|
|
29
43
|
if (input.stripAnsi)
|
|
30
44
|
output = output.replace(ANSI, "");
|
|
@@ -35,4 +49,43 @@ export async function nodeLogs(input) {
|
|
|
35
49
|
result.exitCode = info.exitCode;
|
|
36
50
|
return result;
|
|
37
51
|
}
|
|
52
|
+
/** The lines of a process: the kept output, the new lines and the exit. */
|
|
53
|
+
async function* followLogs(input, signal) {
|
|
54
|
+
const clean = (line) => (input.stripAnsi ? line.replace(ANSI, "") : line);
|
|
55
|
+
// The start of a line that has no line end yet, for each stream
|
|
56
|
+
const partial = { stdout: "", stderr: "" };
|
|
57
|
+
for await (const item of processManager.follow(input.processId, { backlog: true, signal })) {
|
|
58
|
+
switch (item.type) {
|
|
59
|
+
case "backlog": {
|
|
60
|
+
const kept = input.lines !== undefined ? lastLines(item.text, input.lines) : item.text;
|
|
61
|
+
for (const line of splitLines(kept))
|
|
62
|
+
yield { type: "output", line: clean(line) };
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case "output": {
|
|
66
|
+
const lines = (partial[item.stream] + item.text).split("\n");
|
|
67
|
+
partial[item.stream] = lines.pop() ?? "";
|
|
68
|
+
for (const line of lines)
|
|
69
|
+
yield { type: item.stream, line: clean(line.endsWith("\r") ? line.slice(0, -1) : line) };
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case "dropped":
|
|
73
|
+
yield { type: "dropped", bytes: item.bytes };
|
|
74
|
+
break;
|
|
75
|
+
case "end": {
|
|
76
|
+
for (const stream of ["stdout", "stderr"]) {
|
|
77
|
+
if (partial[stream] !== "")
|
|
78
|
+
yield { type: stream, line: clean(partial[stream]) };
|
|
79
|
+
}
|
|
80
|
+
const exit = { type: "exit", status: item.info.status === "error" ? "error" : "exited" };
|
|
81
|
+
if (item.info.exitCode !== undefined)
|
|
82
|
+
exit.exitCode = item.info.exitCode;
|
|
83
|
+
if (item.info.signal !== undefined)
|
|
84
|
+
exit.signal = item.info.signal;
|
|
85
|
+
yield exit;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
38
91
|
//# sourceMappingURL=logs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../src/procedures/node/logs.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../src/procedures/node/logs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,sGAAsG;AACtG,MAAM,IA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AAE,CAAC;gBACX,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAU,EAAE,CAAC;oBACnD,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE;wBAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;gBACnF,CAAC;gBACD,MAAM,IAAI,GAA2C,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACjI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS;oBAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBACzE,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS;oBAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;gBACnE,MAAM,IAAI,CAAC;gBACX,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - the processes end when the host ends (before, they were detached and kept running);
|
|
9
9
|
* - the registry removes old exit records, and `cleanup` removes the rest.
|
|
10
10
|
*/
|
|
11
|
+
import { type FollowOptions, type ProcessFollowItem } from "@procedures/shell/command";
|
|
11
12
|
import type { ProcessInfo } from "./types.js";
|
|
12
13
|
/** The group of the node processes in the process registry. */
|
|
13
14
|
export declare const NODE_GROUP = "node";
|
|
@@ -36,6 +37,11 @@ declare class ProcessManager {
|
|
|
36
37
|
* The end of the output of a process (the last 64 KiB)
|
|
37
38
|
*/
|
|
38
39
|
output(processId: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* The output of a process as a stream, until the process ends or the signal aborts: `follow`
|
|
42
|
+
* of the process registry. A process of another group gives an empty stream.
|
|
43
|
+
*/
|
|
44
|
+
follow(processId: string, options?: FollowOptions): AsyncGenerator<ProcessFollowItem, void, undefined>;
|
|
39
45
|
/**
|
|
40
46
|
* Get status of all or specific processes
|
|
41
47
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-manager.d.ts","sourceRoot":"","sources":["../src/process-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"process-manager.d.ts","sourceRoot":"","sources":["../src/process-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAa,KAAK,aAAa,EAA2B,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC3H,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,+DAA+D;AAC/D,eAAO,MAAM,UAAU,SAAS,CAAC;AAejC,cAAM,cAAc;IAClB;;OAEG;IACH,KAAK,CACH,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;KAAE,GAC3G,WAAW,CASb;IAED;;OAEG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAG9C;IAED;;OAEG;IACG,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,OAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAGlF;IAED;;OAEG;IACG,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7F;IAED;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhC;IAED;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,cAAc,CAAC,iBAAiB,EAAE,IAAI,EAAE,SAAS,CAAC,CAEzG;IAED;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAK3C;IAED;;OAEG;IACH,OAAO,IAAI,MAAM,CAMhB;CACF;AAGD,eAAO,MAAM,cAAc,EAAE,cAAqC,CAAC"}
|
package/dist/process-manager.js
CHANGED
|
@@ -66,6 +66,13 @@ class ProcessManager {
|
|
|
66
66
|
output(processId) {
|
|
67
67
|
return this.get(processId) ? processes.output(processId) : "";
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* The output of a process as a stream, until the process ends or the signal aborts: `follow`
|
|
71
|
+
* of the process registry. A process of another group gives an empty stream.
|
|
72
|
+
*/
|
|
73
|
+
follow(processId, options = {}) {
|
|
74
|
+
return this.get(processId) ? processes.follow(processId, options) : (async function* () { })();
|
|
75
|
+
}
|
|
69
76
|
/**
|
|
70
77
|
* Get status of all or specific processes
|
|
71
78
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-manager.js","sourceRoot":"","sources":["../src/process-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"process-manager.js","sourceRoot":"","sources":["../src/process-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAuE,MAAM,2BAA2B,CAAC;AAG3H,+DAA+D;AAC/D,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AAEjC,SAAS,aAAa,CAAC,IAAwB;IAC7C,MAAM,MAAM,GAAgB;QAC1B,SAAS,EAAE,IAAI,CAAC,EAAE;QAClB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,MAAM,EAA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E,CAAC;gBAAE,OAAO,EAAE,CAAC;QAC5D,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAED,qBAAqB;AACrB,MAAM,CAAC,MAAM,cAAc,GAAmB,IAAI,cAAc,EAAE,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -87,6 +87,11 @@ export interface NodeLogsInput {
|
|
|
87
87
|
lines?: number | undefined;
|
|
88
88
|
/** Remove the ANSI escape codes (colors) from the output */
|
|
89
89
|
stripAnsi?: boolean | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* True: the result is a stream. It gives the kept output, then each new line, until the process
|
|
92
|
+
* ends or the caller aborts. `lines` limits the kept output.
|
|
93
|
+
*/
|
|
94
|
+
follow?: boolean | undefined;
|
|
90
95
|
}
|
|
91
96
|
export interface NodeLogsOutput {
|
|
92
97
|
processId: string;
|
|
@@ -97,6 +102,32 @@ export interface NodeLogsOutput {
|
|
|
97
102
|
/** The end of the output (stdout and stderr together, the last 64 KiB) */
|
|
98
103
|
output: string;
|
|
99
104
|
}
|
|
105
|
+
/** One item of `node.logs` with `follow`. */
|
|
106
|
+
export type NodeLogItem =
|
|
107
|
+
/** A line of the output that the registry kept before the call: stdout and stderr together. */
|
|
108
|
+
{
|
|
109
|
+
type: "output";
|
|
110
|
+
line: string;
|
|
111
|
+
}
|
|
112
|
+
/** A new line of the process, without its line end. */
|
|
113
|
+
| {
|
|
114
|
+
type: "stdout" | "stderr";
|
|
115
|
+
line: string;
|
|
116
|
+
}
|
|
117
|
+
/** The reader was slow, and the stream dropped this many bytes of output. */
|
|
118
|
+
| {
|
|
119
|
+
type: "dropped";
|
|
120
|
+
bytes: number;
|
|
121
|
+
}
|
|
122
|
+
/** The end of the process: the last item. */
|
|
123
|
+
| {
|
|
124
|
+
type: "exit";
|
|
125
|
+
status: "exited" | "error";
|
|
126
|
+
exitCode?: number | undefined;
|
|
127
|
+
signal?: string | undefined;
|
|
128
|
+
};
|
|
100
129
|
export declare const NodeLogsInputSchema: z.ZodType<NodeLogsInput>;
|
|
101
|
-
export declare const
|
|
130
|
+
export declare const NodeLogsValueSchema: z.ZodType<NodeLogsOutput>;
|
|
131
|
+
/** node.logs: one result, or with follow a stream of lines and one last exit item. */
|
|
132
|
+
export declare const NodeLogsOutputSchema: z.ZodType<NodeLogsOutput | NodeLogItem>;
|
|
102
133
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,SAAS,CAAC;IAC3C,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC;IACpB,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7C,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAChC,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1D,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACpC,cAAc,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;CAC5C,CAaC,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,MAAM,EAAE,MAAM,C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package/dist/types.js
CHANGED
|
@@ -91,11 +91,33 @@ export const NodeLogsInputSchema = z.object({
|
|
|
91
91
|
processId: z.string().min(1).describe("Process ID returned from node.spawn"),
|
|
92
92
|
lines: z.number().int().min(1).optional().describe("Only the last lines of the output"),
|
|
93
93
|
stripAnsi: z.boolean().optional().describe("Remove the ANSI escape codes (colors) from the output"),
|
|
94
|
+
follow: z
|
|
95
|
+
.boolean()
|
|
96
|
+
.optional()
|
|
97
|
+
.describe("Give a stream: the kept output, then each new line, until the process ends or the caller aborts"),
|
|
94
98
|
});
|
|
95
|
-
export const
|
|
99
|
+
export const NodeLogsValueSchema = z.looseObject({
|
|
96
100
|
processId: z.string().describe("The id of the process"),
|
|
97
101
|
status: z.enum(["running", "exited", "error"]).describe("The state of the process"),
|
|
98
102
|
exitCode: z.number().optional().describe("The exit code, when the process exited"),
|
|
99
103
|
output: z.string().describe("The end of the output: stdout and stderr together, the last 64 KiB"),
|
|
100
104
|
});
|
|
105
|
+
/** node.logs: one result, or with follow a stream of lines and one last exit item. */
|
|
106
|
+
export const NodeLogsOutputSchema = z.union([
|
|
107
|
+
NodeLogsValueSchema,
|
|
108
|
+
z.looseObject({
|
|
109
|
+
type: z.enum(["output", "stdout", "stderr"]).describe("The stream of the line: output for a line that the registry kept"),
|
|
110
|
+
line: z.string().describe("One line of the output, without its line end"),
|
|
111
|
+
}),
|
|
112
|
+
z.looseObject({
|
|
113
|
+
type: z.literal("dropped").describe("A gap: the reader was slow"),
|
|
114
|
+
bytes: z.number().describe("The number of bytes that the stream dropped"),
|
|
115
|
+
}),
|
|
116
|
+
z.looseObject({
|
|
117
|
+
type: z.literal("exit").describe("The end of the process and of the stream"),
|
|
118
|
+
status: z.enum(["exited", "error"]).describe("The state of the process at its end"),
|
|
119
|
+
exitCode: z.number().optional().describe("The exit code, when the process exited"),
|
|
120
|
+
signal: z.string().optional().describe("The signal that ended the process"),
|
|
121
|
+
}),
|
|
122
|
+
]);
|
|
101
123
|
//# sourceMappingURL=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FAAsF;AACtF,MAAM,CAAC,MAAM,oBAAoB,GAA4C,CAAC,CAAC,KAAK,CAAC;IACnF,mBAAmB;IACnB,CAAC,CAAC,WAAW,CAAC;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,kEAAkE,CAAC;QACzH,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;KAC1E,CAAC;IACF,CAAC,CAAC,WAAW,CAAC;QACZ,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,4BAA4B,CAAC;QACjE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;KAC1E,CAAC;IACF,CAAC,CAAC,WAAW,CAAC;QACZ,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,0CAA0C,CAAC;QAC5E,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,qCAAqC,CAAC;QACnF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;QAClF,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;KAC5E,CAAC;CACH,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@procedures/node",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"description": "Node.js process procedures: run scripts, spawn and manage long-running processes and read their logs, with output caps and process-tree cleanup.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"node",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"provenance": true
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@procedures/client": "0.
|
|
61
|
-
"@procedures/shell": "0.
|
|
60
|
+
"@procedures/client": "0.5.0",
|
|
61
|
+
"@procedures/shell": "0.5.0",
|
|
62
62
|
"zod": "^4.6.5"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
package/src/module.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Procedure Registration for Node.js process management
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { createProcedure, zodAdapter, defineModule, type ProcedureModule, PROCEDURE_REGISTRY, registerModules, type ProcedureRegistry } from "@procedures/client";
|
|
7
|
+
import { createProcedure, zodAdapter, defineModule, type ProcedureContext, type ProcedureModule, PROCEDURE_REGISTRY, registerModules, type ProcedureRegistry } from "@procedures/client";
|
|
8
8
|
import { nodeRun } from "./procedures/node/run.js";
|
|
9
9
|
import { nodeSpawn } from "./procedures/node/spawn.js";
|
|
10
10
|
import { nodeKill } from "./procedures/node/kill.js";
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
type NodeStatusOutput,
|
|
27
27
|
type NodeLogsInput,
|
|
28
28
|
type NodeLogsOutput,
|
|
29
|
+
type NodeLogItem,
|
|
29
30
|
NodeRunOutputSchema,
|
|
30
31
|
NodeSpawnOutputSchema,
|
|
31
32
|
NodeKillOutputSchema,
|
|
@@ -103,20 +104,24 @@ const nodeStatusProcedure = createProcedure()
|
|
|
103
104
|
})
|
|
104
105
|
.build();
|
|
105
106
|
|
|
106
|
-
// node.logs (roadmap R44)
|
|
107
|
+
// node.logs (roadmap R44). One value, or with follow one item for each line (a stream).
|
|
107
108
|
const nodeLogsProcedure = createProcedure()
|
|
108
109
|
.path(["node", "logs"])
|
|
109
110
|
.input(zodAdapter<NodeLogsInput>(NodeLogsInputSchema))
|
|
110
|
-
.output(zodAdapter<NodeLogsOutput>(NodeLogsOutputSchema))
|
|
111
|
+
.output(zodAdapter<NodeLogsOutput | NodeLogItem>(NodeLogsOutputSchema))
|
|
111
112
|
.meta({
|
|
112
|
-
description: "The output of a process of node.spawn: the last 64 KiB of stdout and stderr",
|
|
113
|
+
description: "The output of a process of node.spawn: the last 64 KiB of stdout and stderr, or with follow a stream of its lines",
|
|
113
114
|
args: ["processId"],
|
|
114
|
-
shorts: { lines: "n" },
|
|
115
|
+
shorts: { lines: "n", follow: "f" },
|
|
115
116
|
output: "json",
|
|
116
117
|
// It reads the output that the process registry keeps for a process of node.spawn
|
|
117
118
|
effects: { reads: ["jobs"], writes: [] },
|
|
119
|
+
// With follow, the stream runs as long as the process (roadmap R15)
|
|
120
|
+
stream: { unbounded: true },
|
|
118
121
|
})
|
|
119
|
-
|
|
122
|
+
// With follow, the promise gives a stream: invokeProcedure reads a returned async iterable as a
|
|
123
|
+
// stream, and the handler types of the core do not describe that case
|
|
124
|
+
.handler((input: NodeLogsInput, ctx: ProcedureContext) => nodeLogs(input, ctx) as unknown as Promise<NodeLogsOutput | NodeLogItem>)
|
|
120
125
|
.build();
|
|
121
126
|
|
|
122
127
|
/**
|
|
@@ -5,9 +5,14 @@
|
|
|
5
5
|
* the output of each process and keeps its end: the last 64 KiB, stdout and stderr together.
|
|
6
6
|
* So the procedure gives that end, also after the process ended (the registry keeps the records
|
|
7
7
|
* of the last 50 ended processes). It knows only the processes of this host process.
|
|
8
|
+
*
|
|
9
|
+
* With `follow`, the procedure gives a stream: the kept output as `output` lines, then each new
|
|
10
|
+
* line of stdout and stderr, then one `exit` item at the end of the process. The stream ends at
|
|
11
|
+
* the end of the process, at an abort of the caller and when the reader stops. Each end removes
|
|
12
|
+
* the subscription of the stream from the process registry.
|
|
8
13
|
*/
|
|
9
14
|
|
|
10
|
-
import type { NodeLogsInput, NodeLogsOutput } from "../../types.js";
|
|
15
|
+
import type { NodeLogItem, NodeLogsInput, NodeLogsOutput } from "../../types.js";
|
|
11
16
|
import { processManager } from "../../process-manager.js";
|
|
12
17
|
|
|
13
18
|
// The CSI and OSC escape sequences of terminals (colors, styles, links), as client-shell removes them
|
|
@@ -21,14 +26,27 @@ export function lastLines(text: string, count: number): string {
|
|
|
21
26
|
return lines.slice(-count).join("\n") + (text.endsWith("\n") ? "\n" : "");
|
|
22
27
|
}
|
|
23
28
|
|
|
29
|
+
/** The lines of a text without their line ends (LF or CRLF). A line end at the end adds no line. */
|
|
30
|
+
export function splitLines(text: string): string[] {
|
|
31
|
+
if (text === "") return [];
|
|
32
|
+
const lines = (text.endsWith("\n") ? text.slice(0, -1) : text).split("\n");
|
|
33
|
+
return lines.map((line) => (line.endsWith("\r") ? line.slice(0, -1) : line));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The context that node.logs reads: the abort of the caller. */
|
|
37
|
+
export interface NodeLogsContext {
|
|
38
|
+
signal?: AbortSignal | undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
24
41
|
/**
|
|
25
|
-
* The end of the output of a process of node.spawn
|
|
42
|
+
* The end of the output of a process of node.spawn, or with `follow` a stream of its lines
|
|
26
43
|
*/
|
|
27
|
-
export async function nodeLogs(input: NodeLogsInput): Promise<NodeLogsOutput
|
|
44
|
+
export async function nodeLogs(input: NodeLogsInput, ctx: NodeLogsContext = {}): Promise<NodeLogsOutput | AsyncGenerator<NodeLogItem, void, undefined>> {
|
|
28
45
|
const info = processManager.get(input.processId);
|
|
29
46
|
if (!info) {
|
|
30
47
|
throw new Error(`node.logs: no process ${input.processId}. node.status lists the processes of node.spawn on this host.`);
|
|
31
48
|
}
|
|
49
|
+
if (input.follow) return followLogs(input, ctx.signal);
|
|
32
50
|
let output = processManager.output(input.processId);
|
|
33
51
|
if (input.stripAnsi) output = output.replace(ANSI, "");
|
|
34
52
|
if (input.lines !== undefined) output = lastLines(output, input.lines);
|
|
@@ -36,3 +54,38 @@ export async function nodeLogs(input: NodeLogsInput): Promise<NodeLogsOutput> {
|
|
|
36
54
|
if (info.exitCode !== undefined) result.exitCode = info.exitCode;
|
|
37
55
|
return result;
|
|
38
56
|
}
|
|
57
|
+
|
|
58
|
+
/** The lines of a process: the kept output, the new lines and the exit. */
|
|
59
|
+
async function* followLogs(input: NodeLogsInput, signal: AbortSignal | undefined): AsyncGenerator<NodeLogItem, void, undefined> {
|
|
60
|
+
const clean = (line: string): string => (input.stripAnsi ? line.replace(ANSI, "") : line);
|
|
61
|
+
// The start of a line that has no line end yet, for each stream
|
|
62
|
+
const partial = { stdout: "", stderr: "" };
|
|
63
|
+
for await (const item of processManager.follow(input.processId, { backlog: true, signal })) {
|
|
64
|
+
switch (item.type) {
|
|
65
|
+
case "backlog": {
|
|
66
|
+
const kept = input.lines !== undefined ? lastLines(item.text, input.lines) : item.text;
|
|
67
|
+
for (const line of splitLines(kept)) yield { type: "output", line: clean(line) };
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case "output": {
|
|
71
|
+
const lines = (partial[item.stream] + item.text).split("\n");
|
|
72
|
+
partial[item.stream] = lines.pop() ?? "";
|
|
73
|
+
for (const line of lines) yield { type: item.stream, line: clean(line.endsWith("\r") ? line.slice(0, -1) : line) };
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case "dropped":
|
|
77
|
+
yield { type: "dropped", bytes: item.bytes };
|
|
78
|
+
break;
|
|
79
|
+
case "end": {
|
|
80
|
+
for (const stream of ["stdout", "stderr"] as const) {
|
|
81
|
+
if (partial[stream] !== "") yield { type: stream, line: clean(partial[stream]) };
|
|
82
|
+
}
|
|
83
|
+
const exit: Extract<NodeLogItem, { type: "exit" }> = { type: "exit", status: item.info.status === "error" ? "error" : "exited" };
|
|
84
|
+
if (item.info.exitCode !== undefined) exit.exitCode = item.info.exitCode;
|
|
85
|
+
if (item.info.signal !== undefined) exit.signal = item.info.signal;
|
|
86
|
+
yield exit;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
package/src/process-manager.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - the registry removes old exit records, and `cleanup` removes the rest.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { processes, type ManagedProcessInfo } from "@procedures/shell/command";
|
|
12
|
+
import { processes, type FollowOptions, type ManagedProcessInfo, type ProcessFollowItem } from "@procedures/shell/command";
|
|
13
13
|
import type { ProcessInfo } from "./types.js";
|
|
14
14
|
|
|
15
15
|
/** The group of the node processes in the process registry. */
|
|
@@ -76,6 +76,14 @@ class ProcessManager {
|
|
|
76
76
|
return this.get(processId) ? processes.output(processId) : "";
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* The output of a process as a stream, until the process ends or the signal aborts: `follow`
|
|
81
|
+
* of the process registry. A process of another group gives an empty stream.
|
|
82
|
+
*/
|
|
83
|
+
follow(processId: string, options: FollowOptions = {}): AsyncGenerator<ProcessFollowItem, void, undefined> {
|
|
84
|
+
return this.get(processId) ? processes.follow(processId, options) : (async function* () {})();
|
|
85
|
+
}
|
|
86
|
+
|
|
79
87
|
/**
|
|
80
88
|
* Get status of all or specific processes
|
|
81
89
|
*/
|
package/src/types.ts
CHANGED
|
@@ -194,6 +194,11 @@ export interface NodeLogsInput {
|
|
|
194
194
|
lines?: number | undefined;
|
|
195
195
|
/** Remove the ANSI escape codes (colors) from the output */
|
|
196
196
|
stripAnsi?: boolean | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* True: the result is a stream. It gives the kept output, then each new line, until the process
|
|
199
|
+
* ends or the caller aborts. `lines` limits the kept output.
|
|
200
|
+
*/
|
|
201
|
+
follow?: boolean | undefined;
|
|
197
202
|
}
|
|
198
203
|
|
|
199
204
|
export interface NodeLogsOutput {
|
|
@@ -206,15 +211,49 @@ export interface NodeLogsOutput {
|
|
|
206
211
|
output: string;
|
|
207
212
|
}
|
|
208
213
|
|
|
214
|
+
/** One item of `node.logs` with `follow`. */
|
|
215
|
+
export type NodeLogItem =
|
|
216
|
+
/** A line of the output that the registry kept before the call: stdout and stderr together. */
|
|
217
|
+
| { type: "output"; line: string }
|
|
218
|
+
/** A new line of the process, without its line end. */
|
|
219
|
+
| { type: "stdout" | "stderr"; line: string }
|
|
220
|
+
/** The reader was slow, and the stream dropped this many bytes of output. */
|
|
221
|
+
| { type: "dropped"; bytes: number }
|
|
222
|
+
/** The end of the process: the last item. */
|
|
223
|
+
| { type: "exit"; status: "exited" | "error"; exitCode?: number | undefined; signal?: string | undefined };
|
|
224
|
+
|
|
209
225
|
export const NodeLogsInputSchema: z.ZodType<NodeLogsInput> = z.object({
|
|
210
226
|
processId: z.string().min(1).describe("Process ID returned from node.spawn"),
|
|
211
227
|
lines: z.number().int().min(1).optional().describe("Only the last lines of the output"),
|
|
212
228
|
stripAnsi: z.boolean().optional().describe("Remove the ANSI escape codes (colors) from the output"),
|
|
229
|
+
follow: z
|
|
230
|
+
.boolean()
|
|
231
|
+
.optional()
|
|
232
|
+
.describe("Give a stream: the kept output, then each new line, until the process ends or the caller aborts"),
|
|
213
233
|
});
|
|
214
234
|
|
|
215
|
-
export const
|
|
235
|
+
export const NodeLogsValueSchema: z.ZodType<NodeLogsOutput> = z.looseObject({
|
|
216
236
|
processId: z.string().describe("The id of the process"),
|
|
217
237
|
status: z.enum(["running", "exited", "error"]).describe("The state of the process"),
|
|
218
238
|
exitCode: z.number().optional().describe("The exit code, when the process exited"),
|
|
219
239
|
output: z.string().describe("The end of the output: stdout and stderr together, the last 64 KiB"),
|
|
220
240
|
});
|
|
241
|
+
|
|
242
|
+
/** node.logs: one result, or with follow a stream of lines and one last exit item. */
|
|
243
|
+
export const NodeLogsOutputSchema: z.ZodType<NodeLogsOutput | NodeLogItem> = z.union([
|
|
244
|
+
NodeLogsValueSchema,
|
|
245
|
+
z.looseObject({
|
|
246
|
+
type: z.enum(["output", "stdout", "stderr"]).describe("The stream of the line: output for a line that the registry kept"),
|
|
247
|
+
line: z.string().describe("One line of the output, without its line end"),
|
|
248
|
+
}),
|
|
249
|
+
z.looseObject({
|
|
250
|
+
type: z.literal("dropped").describe("A gap: the reader was slow"),
|
|
251
|
+
bytes: z.number().describe("The number of bytes that the stream dropped"),
|
|
252
|
+
}),
|
|
253
|
+
z.looseObject({
|
|
254
|
+
type: z.literal("exit").describe("The end of the process and of the stream"),
|
|
255
|
+
status: z.enum(["exited", "error"]).describe("The state of the process at its end"),
|
|
256
|
+
exitCode: z.number().optional().describe("The exit code, when the process exited"),
|
|
257
|
+
signal: z.string().optional().describe("The signal that ended the process"),
|
|
258
|
+
}),
|
|
259
|
+
]);
|