shellpuppet 0.0.1 → 0.2.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/LICENSE +202 -0
- package/NOTICE +31 -0
- package/README.md +499 -8
- package/dist/cli/desktopShortcut.d.ts +22 -0
- package/dist/cli/desktopShortcut.js +157 -0
- package/dist/cli/desktopShortcut.js.map +1 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.js +846 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client/http.d.ts +143 -0
- package/dist/client/http.js +581 -0
- package/dist/client/http.js.map +1 -0
- package/dist/core/dialogs.d.ts +96 -0
- package/dist/core/dialogs.js +226 -0
- package/dist/core/dialogs.js.map +1 -0
- package/dist/core/echo.d.ts +71 -0
- package/dist/core/echo.js +249 -0
- package/dist/core/echo.js.map +1 -0
- package/dist/core/find.d.ts +34 -0
- package/dist/core/find.js +41 -0
- package/dist/core/find.js.map +1 -0
- package/dist/core/keys.d.ts +22 -0
- package/dist/core/keys.js +80 -0
- package/dist/core/keys.js.map +1 -0
- package/dist/core/manager.d.ts +96 -0
- package/dist/core/manager.js +271 -0
- package/dist/core/manager.js.map +1 -0
- package/dist/core/nativePty.d.ts +73 -0
- package/dist/core/nativePty.js +161 -0
- package/dist/core/nativePty.js.map +1 -0
- package/dist/core/policy.d.ts +61 -0
- package/dist/core/policy.js +143 -0
- package/dist/core/policy.js.map +1 -0
- package/dist/core/promptDetector.d.ts +109 -0
- package/dist/core/promptDetector.js +897 -0
- package/dist/core/promptDetector.js.map +1 -0
- package/dist/core/reasoning.d.ts +265 -0
- package/dist/core/reasoning.js +933 -0
- package/dist/core/reasoning.js.map +1 -0
- package/dist/core/regexBudget.d.ts +64 -0
- package/dist/core/regexBudget.js +103 -0
- package/dist/core/regexBudget.js.map +1 -0
- package/dist/core/renderer.d.ts +127 -0
- package/dist/core/renderer.js +316 -0
- package/dist/core/renderer.js.map +1 -0
- package/dist/core/selection.d.ts +6 -0
- package/dist/core/selection.js +48 -0
- package/dist/core/selection.js.map +1 -0
- package/dist/core/session.d.ts +565 -0
- package/dist/core/session.js +1450 -0
- package/dist/core/session.js.map +1 -0
- package/dist/core/types.d.ts +316 -0
- package/dist/core/types.js +71 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/waiter.d.ts +94 -0
- package/dist/core/waiter.js +310 -0
- package/dist/core/waiter.js.map +1 -0
- package/dist/core/windowsConsoleHost.d.ts +147 -0
- package/dist/core/windowsConsoleHost.js +588 -0
- package/dist/core/windowsConsoleHost.js.map +1 -0
- package/dist/core/windowsPtyStart.d.ts +161 -0
- package/dist/core/windowsPtyStart.js +236 -0
- package/dist/core/windowsPtyStart.js.map +1 -0
- package/dist/daemon/audit.d.ts +23 -0
- package/dist/daemon/audit.js +51 -0
- package/dist/daemon/audit.js.map +1 -0
- package/dist/daemon/auth.d.ts +197 -0
- package/dist/daemon/auth.js +366 -0
- package/dist/daemon/auth.js.map +1 -0
- package/dist/daemon/config.d.ts +119 -0
- package/dist/daemon/config.js +568 -0
- package/dist/daemon/config.js.map +1 -0
- package/dist/daemon/folderPicker.d.ts +27 -0
- package/dist/daemon/folderPicker.js +115 -0
- package/dist/daemon/folderPicker.js.map +1 -0
- package/dist/daemon/index.d.ts +7 -0
- package/dist/daemon/index.js +88 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/launchProfiles.d.ts +155 -0
- package/dist/daemon/launchProfiles.js +554 -0
- package/dist/daemon/launchProfiles.js.map +1 -0
- package/dist/daemon/liveness.d.ts +36 -0
- package/dist/daemon/liveness.js +71 -0
- package/dist/daemon/liveness.js.map +1 -0
- package/dist/daemon/logger.d.ts +7 -0
- package/dist/daemon/logger.js +29 -0
- package/dist/daemon/logger.js.map +1 -0
- package/dist/daemon/meta.d.ts +9 -0
- package/dist/daemon/meta.js +24 -0
- package/dist/daemon/meta.js.map +1 -0
- package/dist/daemon/paths.d.ts +85 -0
- package/dist/daemon/paths.js +154 -0
- package/dist/daemon/paths.js.map +1 -0
- package/dist/daemon/screenshot.d.ts +144 -0
- package/dist/daemon/screenshot.js +402 -0
- package/dist/daemon/screenshot.js.map +1 -0
- package/dist/daemon/server.d.ts +453 -0
- package/dist/daemon/server.js +3954 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/sessionFeed.d.ts +48 -0
- package/dist/daemon/sessionFeed.js +101 -0
- package/dist/daemon/sessionFeed.js.map +1 -0
- package/dist/daemon/terminalReports.d.ts +38 -0
- package/dist/daemon/terminalReports.js +84 -0
- package/dist/daemon/terminalReports.js.map +1 -0
- package/dist/daemon/viewerLauncher.d.ts +226 -0
- package/dist/daemon/viewerLauncher.js +562 -0
- package/dist/daemon/viewerLauncher.js.map +1 -0
- package/dist/daemon/viewerSync.d.ts +38 -0
- package/dist/daemon/viewerSync.js +83 -0
- package/dist/daemon/viewerSync.js.map +1 -0
- package/dist/mcp/config.d.ts +50 -0
- package/dist/mcp/config.js +95 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +10 -0
- package/dist/mcp/index.js +78 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/tools.d.ts +66 -0
- package/dist/mcp/tools.js +638 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/viewer/dashboard-folders.js +20 -0
- package/dist/viewer/dashboard-layout.js +52 -0
- package/dist/viewer/dashboard.css +67 -0
- package/dist/viewer/dashboard.html +44 -0
- package/dist/viewer/dashboard.js +1518 -0
- package/dist/viewer/icon-16.png +0 -0
- package/dist/viewer/icon-180.png +0 -0
- package/dist/viewer/icon-32.png +0 -0
- package/dist/viewer/icon-512.png +0 -0
- package/dist/viewer/icon.ico +0 -0
- package/dist/viewer/icon.svg +66 -0
- package/dist/viewer/index.html +61 -0
- package/dist/viewer/pane.js +736 -0
- package/dist/viewer/viewer.css +95 -0
- package/dist/viewer/viewer.js +84 -0
- package/package.json +66 -7
- package/index.js +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
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+
export interface FindMatch {
|
|
6
|
+
/** 1-based line number on the screen as rendered. */
|
|
7
|
+
line: number;
|
|
8
|
+
/** The full text of the matching line, right-trimmed. */
|
|
9
|
+
text: string;
|
|
10
|
+
/** The exact matched substring. */
|
|
11
|
+
match: string;
|
|
12
|
+
}
|
|
13
|
+
export interface FindResult {
|
|
14
|
+
matches: FindMatch[];
|
|
15
|
+
/** True when results were cut off at the cap. */
|
|
16
|
+
truncated: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What the CLI and the MCP tool both say when nothing matched: one fixed line
|
|
20
|
+
* that never repeats the pattern, so a watcher that searches the output for
|
|
21
|
+
* its own pattern cannot mistake the absence line for a hit.
|
|
22
|
+
*/
|
|
23
|
+
export declare const NO_MATCHES = "No matches.";
|
|
24
|
+
/**
|
|
25
|
+
* Case-insensitive by default, like the waiter. Throws `SyntaxError` on an
|
|
26
|
+
* invalid pattern, and `RegexBudgetError` on one that will not finish.
|
|
27
|
+
* Callers map both to a client error.
|
|
28
|
+
*
|
|
29
|
+
* The whole search runs under ONE budget rather than one per line: a pattern
|
|
30
|
+
* that backtracks on a screenful of text would otherwise be given the budget
|
|
31
|
+
* again for every row, and a hundred and fifty rows is not a bound worth
|
|
32
|
+
* having (`regexBudget.ts`).
|
|
33
|
+
*/
|
|
34
|
+
export declare function findOnScreen(lines: string[], pattern: string): FindResult;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regex search over a rendered screen, with line numbers (`terminal_find`).
|
|
3
|
+
* Pure function: the daemon feeds it snapshot lines.
|
|
4
|
+
*/
|
|
5
|
+
import { withRegexBudget } from './regexBudget.js';
|
|
6
|
+
/** Bound the response size: a pathological pattern can match every line. */
|
|
7
|
+
const MAX_MATCHES = 100;
|
|
8
|
+
/**
|
|
9
|
+
* What the CLI and the MCP tool both say when nothing matched: one fixed line
|
|
10
|
+
* that never repeats the pattern, so a watcher that searches the output for
|
|
11
|
+
* its own pattern cannot mistake the absence line for a hit.
|
|
12
|
+
*/
|
|
13
|
+
export const NO_MATCHES = 'No matches.';
|
|
14
|
+
/**
|
|
15
|
+
* Case-insensitive by default, like the waiter. Throws `SyntaxError` on an
|
|
16
|
+
* invalid pattern, and `RegexBudgetError` on one that will not finish.
|
|
17
|
+
* Callers map both to a client error.
|
|
18
|
+
*
|
|
19
|
+
* The whole search runs under ONE budget rather than one per line: a pattern
|
|
20
|
+
* that backtracks on a screenful of text would otherwise be given the budget
|
|
21
|
+
* again for every row, and a hundred and fifty rows is not a bound worth
|
|
22
|
+
* having (`regexBudget.ts`).
|
|
23
|
+
*/
|
|
24
|
+
export function findOnScreen(lines, pattern) {
|
|
25
|
+
const regex = new RegExp(pattern, 'i');
|
|
26
|
+
return withRegexBudget(pattern, () => {
|
|
27
|
+
const matches = [];
|
|
28
|
+
for (let i = 0; i < lines.length; i++) {
|
|
29
|
+
const text = lines[i] ?? '';
|
|
30
|
+
const found = regex.exec(text);
|
|
31
|
+
if (found !== null) {
|
|
32
|
+
matches.push({ line: i + 1, text, match: found[0] });
|
|
33
|
+
if (matches.length >= MAX_MATCHES) {
|
|
34
|
+
return { matches, truncated: i < lines.length - 1 };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { matches, truncated: false };
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=find.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/core/find.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAiBnD,4EAA4E;AAC5E,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC;AAExC;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,KAAe,EAAE,OAAe;IAC3D,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACvC,OAAO,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE;QACnC,MAAM,OAAO,GAAgB,EAAE,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACrD,IAAI,OAAO,CAAC,MAAM,IAAI,WAAW,EAAE,CAAC;oBAClC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtD,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic key names → terminal escape sequences.
|
|
3
|
+
*
|
|
4
|
+
* Agents are bad at raw escape sequences, so the tool surface exposes readable
|
|
5
|
+
* names (`enter`, `escape`, `ctrl+c`, `f5`…), mapped to the sequences xterm
|
|
6
|
+
* sends. `shift+tab` (backtab) is included because TUI focus navigation needs
|
|
7
|
+
* it.
|
|
8
|
+
*
|
|
9
|
+
* Pure data + lookup. No I/O.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Translate a semantic key name to the byte sequence to write to the PTY.
|
|
13
|
+
* Names are case-insensitive and surrounding whitespace is ignored.
|
|
14
|
+
* Returns `null` for names that are not recognised, and callers turn that into
|
|
15
|
+
* a clear client error rather than writing garbage into the session.
|
|
16
|
+
*/
|
|
17
|
+
export declare function keyToBytes(key: string): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Every accepted key name, for tool schemas and error messages. The patterned
|
|
20
|
+
* forms are described rather than enumerated.
|
|
21
|
+
*/
|
|
22
|
+
export declare function knownKeys(): string[];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic key names → terminal escape sequences.
|
|
3
|
+
*
|
|
4
|
+
* Agents are bad at raw escape sequences, so the tool surface exposes readable
|
|
5
|
+
* names (`enter`, `escape`, `ctrl+c`, `f5`…), mapped to the sequences xterm
|
|
6
|
+
* sends. `shift+tab` (backtab) is included because TUI focus navigation needs
|
|
7
|
+
* it.
|
|
8
|
+
*
|
|
9
|
+
* Pure data + lookup. No I/O.
|
|
10
|
+
*/
|
|
11
|
+
const NAMED_KEYS = {
|
|
12
|
+
enter: '\r',
|
|
13
|
+
tab: '\t',
|
|
14
|
+
'shift+tab': '\x1b[Z',
|
|
15
|
+
escape: '\x1b',
|
|
16
|
+
esc: '\x1b',
|
|
17
|
+
backspace: '\x7f',
|
|
18
|
+
delete: '\x1b[3~',
|
|
19
|
+
space: ' ',
|
|
20
|
+
up: '\x1b[A',
|
|
21
|
+
down: '\x1b[B',
|
|
22
|
+
right: '\x1b[C',
|
|
23
|
+
left: '\x1b[D',
|
|
24
|
+
arrow_up: '\x1b[A',
|
|
25
|
+
arrow_down: '\x1b[B',
|
|
26
|
+
arrow_right: '\x1b[C',
|
|
27
|
+
arrow_left: '\x1b[D',
|
|
28
|
+
home: '\x1b[H',
|
|
29
|
+
end: '\x1b[F',
|
|
30
|
+
pageup: '\x1b[5~',
|
|
31
|
+
pagedown: '\x1b[6~',
|
|
32
|
+
};
|
|
33
|
+
/** F1 to F4 use SS3 codes; F5+ use CSI codes, as xterm does. */
|
|
34
|
+
const FUNCTION_KEYS = {
|
|
35
|
+
1: '\x1bOP',
|
|
36
|
+
2: '\x1bOQ',
|
|
37
|
+
3: '\x1bOR',
|
|
38
|
+
4: '\x1bOS',
|
|
39
|
+
5: '\x1b[15~',
|
|
40
|
+
6: '\x1b[17~',
|
|
41
|
+
7: '\x1b[18~',
|
|
42
|
+
8: '\x1b[19~',
|
|
43
|
+
9: '\x1b[20~',
|
|
44
|
+
10: '\x1b[21~',
|
|
45
|
+
11: '\x1b[23~',
|
|
46
|
+
12: '\x1b[24~',
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Translate a semantic key name to the byte sequence to write to the PTY.
|
|
50
|
+
* Names are case-insensitive and surrounding whitespace is ignored.
|
|
51
|
+
* Returns `null` for names that are not recognised, and callers turn that into
|
|
52
|
+
* a clear client error rather than writing garbage into the session.
|
|
53
|
+
*/
|
|
54
|
+
export function keyToBytes(key) {
|
|
55
|
+
const name = key.toLowerCase().trim();
|
|
56
|
+
const named = NAMED_KEYS[name];
|
|
57
|
+
if (named !== undefined)
|
|
58
|
+
return named;
|
|
59
|
+
// ctrl+a … ctrl+z → 0x01 … 0x1a
|
|
60
|
+
const ctrl = /^ctrl\+([a-z])$/.exec(name);
|
|
61
|
+
if (ctrl !== null && ctrl[1] !== undefined) {
|
|
62
|
+
return String.fromCharCode(ctrl[1].charCodeAt(0) - 96);
|
|
63
|
+
}
|
|
64
|
+
// f1 … f12
|
|
65
|
+
const fn = /^f(\d{1,2})$/.exec(name);
|
|
66
|
+
if (fn !== null && fn[1] !== undefined) {
|
|
67
|
+
const sequence = FUNCTION_KEYS[Number(fn[1])];
|
|
68
|
+
if (sequence !== undefined)
|
|
69
|
+
return sequence;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Every accepted key name, for tool schemas and error messages. The patterned
|
|
75
|
+
* forms are described rather than enumerated.
|
|
76
|
+
*/
|
|
77
|
+
export function knownKeys() {
|
|
78
|
+
return [...Object.keys(NAMED_KEYS), 'ctrl+<a-z>', 'f1-f12'];
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/core/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,UAAU,GAAqC;IACnD,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,IAAI;IACT,WAAW,EAAE,QAAQ;IACrB,MAAM,EAAE,MAAM;IACd,GAAG,EAAE,MAAM;IACX,SAAS,EAAE,MAAM;IACjB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,GAAG;IACV,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,QAAQ;IACpB,WAAW,EAAE,QAAQ;IACrB,UAAU,EAAE,QAAQ;IACpB,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,QAAQ;IACb,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,SAAS;CACpB,CAAC;AAEF,gEAAgE;AAChE,MAAM,aAAa,GAAqC;IACtD,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,UAAU;IACb,EAAE,EAAE,UAAU;IACd,EAAE,EAAE,UAAU;IACd,EAAE,EAAE,UAAU;CACf,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAEtC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAEtC,gCAAgC;IAChC,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC3C,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,WAAW;IACX,MAAM,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;IAC9C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session registry: ids, policy enforcement, cleanup (design §2.4).
|
|
3
|
+
*
|
|
4
|
+
* The manager is where policy meets the pre-wrap command (design §4.3): it
|
|
5
|
+
* evaluates `command args…` exactly as the caller passed them, and only then
|
|
6
|
+
* hands off to `Session`, which applies the platform shell wrapper at spawn.
|
|
7
|
+
*/
|
|
8
|
+
import { Session } from './session.js';
|
|
9
|
+
import type { SessionDeps } from './session.js';
|
|
10
|
+
import type { CompiledPolicy } from './policy.js';
|
|
11
|
+
import type { Logger, SessionOptions, SessionSummary } from './types.js';
|
|
12
|
+
export declare class PolicyViolationError extends Error {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class SessionStartError extends Error {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
/** node-pty 1.2.0-beta.18's lib/windowsConoutConnection.js waits this long in dispose before terminating its worker. */
|
|
19
|
+
export declare const CONPTY_WORKER_DISPOSAL_MS = 1000;
|
|
20
|
+
/** Margin for the scheduled termination and a short pause before another start. */
|
|
21
|
+
export declare const CONPTY_START_RETRY_DELAY_MS = 100;
|
|
22
|
+
export declare class SessionManager {
|
|
23
|
+
private readonly onRemoved;
|
|
24
|
+
private readonly sessions;
|
|
25
|
+
private readonly logger;
|
|
26
|
+
private readonly sessionDeps;
|
|
27
|
+
private policy;
|
|
28
|
+
private seq;
|
|
29
|
+
private readonly starting;
|
|
30
|
+
private readonly cancelledStarts;
|
|
31
|
+
constructor(policy: CompiledPolicy, logger?: Logger, deps?: SessionDeps, onRemoved?: (id: string) => void);
|
|
32
|
+
/** Replace the policy. */
|
|
33
|
+
setPolicy(policy: CompiledPolicy): void;
|
|
34
|
+
/**
|
|
35
|
+
* Policy-check and start a session. Throws `PolicyViolationError` with the
|
|
36
|
+
* policy's reason when refused. Callers map it to a 403.
|
|
37
|
+
*/
|
|
38
|
+
create(options: SessionOptions): Session;
|
|
39
|
+
/** Finish the deferred Windows start contract, retrying one proven worker
|
|
40
|
+
* connection timeout under the same id after the failed attempt is ended.
|
|
41
|
+
* The starting reservation remains in the capacity count throughout.
|
|
42
|
+
*/
|
|
43
|
+
finishStart(session: Session, options: SessionOptions): Promise<Session>;
|
|
44
|
+
get(id: string): Session | undefined;
|
|
45
|
+
list(): SessionSummary[];
|
|
46
|
+
/** Live sessions, including an exited first attempt holding a retry slot. */
|
|
47
|
+
liveCount(): number;
|
|
48
|
+
size(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Reap sessions whose process exited more than `graceMs` ago, so a natural
|
|
51
|
+
* exit releases the renderer and its scrollback just as a kill does,
|
|
52
|
+
* rather than holding them until daemon shutdown. Agents legitimately read the
|
|
53
|
+
* final screen after exit, so exited sessions stay readable during the
|
|
54
|
+
* grace and their resources are released after it. Returns the
|
|
55
|
+
* reaped ids so the daemon layer can revoke their viewer grants and
|
|
56
|
+
* credentials and close their watcher sockets. Kill (`DELETE`) is immediate.
|
|
57
|
+
*/
|
|
58
|
+
reapExited(graceMs: number): Promise<string[]>;
|
|
59
|
+
/** Tree-kill one session and drop it from the registry. */
|
|
60
|
+
kill(id: string): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Tree-kill everything at daemon shutdown (design §2.3). The daemon must
|
|
63
|
+
* never exit and strand running agent CLIs.
|
|
64
|
+
*
|
|
65
|
+
* On Windows every live session's tree is killed first, in one `taskkill`
|
|
66
|
+
* run (`taskkillTrees` says why), so each session's own kill then finds its
|
|
67
|
+
* root gone and only has its terminal left to release. That run is bounded
|
|
68
|
+
* by its own cap (`TREE_KILL_TIMEOUT_MS`), not by `timeoutMs`: a shorter
|
|
69
|
+
* bound would cut short the very run it exists for.
|
|
70
|
+
*
|
|
71
|
+
* Before any of that, every session's program is waited for
|
|
72
|
+
* (`Session.startedProgramPid`): node-pty creates a Windows terminal's
|
|
73
|
+
* program only after its output worker connects, so a session started in
|
|
74
|
+
* the moment of shutdown has no pid yet. That wait has its own bound (above
|
|
75
|
+
* node-pty's five-second connection limit) and sits outside `timeoutMs`, so
|
|
76
|
+
* the per-session teardown budget is spent on teardown, not on waiting, and
|
|
77
|
+
* each kill is still awaited and verified.
|
|
78
|
+
*
|
|
79
|
+
* So shutdown takes at most the program wait (`PROGRAM_PID_WAIT_MS`), plus
|
|
80
|
+
* the tree kill's cap, plus `timeoutMs`. A session whose program wait ran
|
|
81
|
+
* out is not waited for again by its own kill.
|
|
82
|
+
*
|
|
83
|
+
* Each kill is bounded so shutdown ALWAYS completes. An unbounded teardown
|
|
84
|
+
* that wedges leaves the daemon alive but undiscoverable. That is worse than
|
|
85
|
+
* a best-effort kill, because the user can then only end it via Task
|
|
86
|
+
* Manager, and every future client sees a stale state file. A kill that
|
|
87
|
+
* overruns is logged and abandoned.
|
|
88
|
+
*/
|
|
89
|
+
killAll(timeoutMs?: number): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Windows only: kill, in one `taskkill` run, the tree of every session
|
|
92
|
+
* whose program has not been seen to end, including one whose session
|
|
93
|
+
* ended without it (`Session.programEnded`).
|
|
94
|
+
*/
|
|
95
|
+
private killTreesInOneRun;
|
|
96
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session registry: ids, policy enforcement, cleanup (design §2.4).
|
|
3
|
+
*
|
|
4
|
+
* The manager is where policy meets the pre-wrap command (design §4.3): it
|
|
5
|
+
* evaluates `command args…` exactly as the caller passed them, and only then
|
|
6
|
+
* hands off to `Session`, which applies the platform shell wrapper at spawn.
|
|
7
|
+
*/
|
|
8
|
+
import { Session, TREE_KILL_TIMEOUT_MS, taskkillTrees } from './session.js';
|
|
9
|
+
import { whenConsoleHostBatchSettled } from './windowsConsoleHost.js';
|
|
10
|
+
import { checkSessionCapacity, evaluateCommand } from './policy.js';
|
|
11
|
+
import { NULL_LOGGER } from './types.js';
|
|
12
|
+
export class PolicyViolationError extends Error {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'PolicyViolationError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class SessionStartError extends Error {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'SessionStartError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** node-pty 1.2.0-beta.18's lib/windowsConoutConnection.js waits this long in dispose before terminating its worker. */
|
|
25
|
+
export const CONPTY_WORKER_DISPOSAL_MS = 1_000;
|
|
26
|
+
/** Margin for the scheduled termination and a short pause before another start. */
|
|
27
|
+
export const CONPTY_START_RETRY_DELAY_MS = 100;
|
|
28
|
+
export class SessionManager {
|
|
29
|
+
onRemoved;
|
|
30
|
+
sessions = new Map();
|
|
31
|
+
logger;
|
|
32
|
+
sessionDeps;
|
|
33
|
+
policy;
|
|
34
|
+
seq = 0;
|
|
35
|
+
starting = new Set();
|
|
36
|
+
cancelledStarts = new Set();
|
|
37
|
+
constructor(policy, logger = NULL_LOGGER, deps = {}, onRemoved = () => undefined) {
|
|
38
|
+
this.onRemoved = onRemoved;
|
|
39
|
+
this.policy = policy;
|
|
40
|
+
this.logger = logger;
|
|
41
|
+
this.sessionDeps = { logger, ...deps };
|
|
42
|
+
}
|
|
43
|
+
/** Replace the policy. */
|
|
44
|
+
setPolicy(policy) {
|
|
45
|
+
this.policy = policy;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Policy-check and start a session. Throws `PolicyViolationError` with the
|
|
49
|
+
* policy's reason when refused. Callers map it to a 403.
|
|
50
|
+
*/
|
|
51
|
+
create(options) {
|
|
52
|
+
const decision = evaluateCommand(this.policy, options.command, options.args ?? []);
|
|
53
|
+
if (!decision.allowed) {
|
|
54
|
+
this.logger.warn('session refused by policy', {
|
|
55
|
+
command: options.command,
|
|
56
|
+
reason: decision.reason,
|
|
57
|
+
});
|
|
58
|
+
throw new PolicyViolationError(decision.reason ?? 'Command refused by policy.');
|
|
59
|
+
}
|
|
60
|
+
const capacity = checkSessionCapacity(this.policy, this.liveCount());
|
|
61
|
+
if (!capacity.allowed) {
|
|
62
|
+
throw new PolicyViolationError(capacity.reason ?? 'Session limit reached.');
|
|
63
|
+
}
|
|
64
|
+
const id = `s${String(++this.seq)}`;
|
|
65
|
+
const session = new Session(id, options, this.sessionDeps);
|
|
66
|
+
this.sessions.set(id, session);
|
|
67
|
+
return session;
|
|
68
|
+
}
|
|
69
|
+
/** Finish the deferred Windows start contract, retrying one proven worker
|
|
70
|
+
* connection timeout under the same id after the failed attempt is ended.
|
|
71
|
+
* The starting reservation remains in the capacity count throughout.
|
|
72
|
+
*/
|
|
73
|
+
async finishStart(session, options) {
|
|
74
|
+
this.starting.add(session.id);
|
|
75
|
+
let current = session;
|
|
76
|
+
const registered = (allowOwnKill = false) => this.sessions.get(session.id) === current &&
|
|
77
|
+
!this.cancelledStarts.has(session.id) &&
|
|
78
|
+
(allowOwnKill || !current.isKilled);
|
|
79
|
+
const discard = () => {
|
|
80
|
+
if (this.sessions.get(session.id) !== current)
|
|
81
|
+
return;
|
|
82
|
+
this.sessions.delete(session.id);
|
|
83
|
+
this.onRemoved(session.id);
|
|
84
|
+
};
|
|
85
|
+
try {
|
|
86
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
87
|
+
const pid = await current.startedProgramPid();
|
|
88
|
+
if (!registered()) {
|
|
89
|
+
await current.kill();
|
|
90
|
+
discard();
|
|
91
|
+
throw new SessionStartError('Session start was cancelled.');
|
|
92
|
+
}
|
|
93
|
+
if (pid !== null)
|
|
94
|
+
return current;
|
|
95
|
+
const retry = attempt === 0 && current.conptyConnectionTimedOut;
|
|
96
|
+
const failure = current.startFailure();
|
|
97
|
+
await current.kill();
|
|
98
|
+
if (!retry) {
|
|
99
|
+
discard();
|
|
100
|
+
throw new SessionStartError(failure);
|
|
101
|
+
}
|
|
102
|
+
// The first attempt's host must be ended before the id is reused.
|
|
103
|
+
// The queue can settle after exhausting its attempts without ending it.
|
|
104
|
+
const hostEnded = await current.whenConsoleHostSettled();
|
|
105
|
+
await whenConsoleHostBatchSettled();
|
|
106
|
+
if (!hostEnded) {
|
|
107
|
+
discard();
|
|
108
|
+
throw new SessionStartError(failure);
|
|
109
|
+
}
|
|
110
|
+
if (!registered(true))
|
|
111
|
+
throw new SessionStartError('Session start was cancelled.');
|
|
112
|
+
await new Promise((resolve) => setTimeout(resolve, CONPTY_WORKER_DISPOSAL_MS + CONPTY_START_RETRY_DELAY_MS));
|
|
113
|
+
if (!registered(true))
|
|
114
|
+
throw new SessionStartError('Session start was cancelled.');
|
|
115
|
+
this.logger.warn('session ConPTY start retry', { id: session.id, delayMs: CONPTY_START_RETRY_DELAY_MS });
|
|
116
|
+
try {
|
|
117
|
+
current = new Session(session.id, options, { ...this.sessionDeps, retryAttempt: true });
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
discard();
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
this.sessions.set(session.id, current);
|
|
124
|
+
}
|
|
125
|
+
throw new Error('unreachable start attempt');
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
this.starting.delete(session.id);
|
|
129
|
+
this.cancelledStarts.delete(session.id);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
get(id) {
|
|
133
|
+
return this.sessions.get(id);
|
|
134
|
+
}
|
|
135
|
+
list() {
|
|
136
|
+
return [...this.sessions.values()].map((s) => s.summary());
|
|
137
|
+
}
|
|
138
|
+
/** Live sessions, including an exited first attempt holding a retry slot. */
|
|
139
|
+
liveCount() {
|
|
140
|
+
return [...this.sessions.values()].filter((s) => !s.exited || this.starting.has(s.id)).length;
|
|
141
|
+
}
|
|
142
|
+
size() {
|
|
143
|
+
return this.sessions.size;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Reap sessions whose process exited more than `graceMs` ago, so a natural
|
|
147
|
+
* exit releases the renderer and its scrollback just as a kill does,
|
|
148
|
+
* rather than holding them until daemon shutdown. Agents legitimately read the
|
|
149
|
+
* final screen after exit, so exited sessions stay readable during the
|
|
150
|
+
* grace and their resources are released after it. Returns the
|
|
151
|
+
* reaped ids so the daemon layer can revoke their viewer grants and
|
|
152
|
+
* credentials and close their watcher sockets. Kill (`DELETE`) is immediate.
|
|
153
|
+
*/
|
|
154
|
+
async reapExited(graceMs) {
|
|
155
|
+
const now = Date.now();
|
|
156
|
+
const reaped = [];
|
|
157
|
+
for (const [id, session] of [...this.sessions]) {
|
|
158
|
+
if (!session.exited || session.exitedAt === null)
|
|
159
|
+
continue;
|
|
160
|
+
if (now - session.exitedAt < graceMs)
|
|
161
|
+
continue;
|
|
162
|
+
this.sessions.delete(id);
|
|
163
|
+
this.onRemoved(id);
|
|
164
|
+
// The process is already dead; kill() just releases the PTY handles
|
|
165
|
+
// and disposes the renderer. It deliberately does NOT tree-kill: the
|
|
166
|
+
// root has been gone for the whole grace period, so there is nothing
|
|
167
|
+
// to walk the tree from and the process group id may have been
|
|
168
|
+
// recycled. A grandchild that outlived its parent is left
|
|
169
|
+
// running, which is a residual risk stated in
|
|
170
|
+
// `docs/reference/security-model.md` rather than a case to guess at.
|
|
171
|
+
// The one exception is a session that ended without its program being
|
|
172
|
+
// seen to end (`Session.programEnded`): the session ends that program
|
|
173
|
+
// at once, and kill() waits for it, or walks the tree if it has not.
|
|
174
|
+
await session.kill();
|
|
175
|
+
reaped.push(id);
|
|
176
|
+
}
|
|
177
|
+
return reaped;
|
|
178
|
+
}
|
|
179
|
+
/** Tree-kill one session and drop it from the registry. */
|
|
180
|
+
async kill(id) {
|
|
181
|
+
const session = this.sessions.get(id);
|
|
182
|
+
if (session === undefined)
|
|
183
|
+
return false;
|
|
184
|
+
if (this.starting.has(id))
|
|
185
|
+
this.cancelledStarts.add(id);
|
|
186
|
+
await session.kill();
|
|
187
|
+
this.sessions.delete(id);
|
|
188
|
+
this.onRemoved(id);
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Tree-kill everything at daemon shutdown (design §2.3). The daemon must
|
|
193
|
+
* never exit and strand running agent CLIs.
|
|
194
|
+
*
|
|
195
|
+
* On Windows every live session's tree is killed first, in one `taskkill`
|
|
196
|
+
* run (`taskkillTrees` says why), so each session's own kill then finds its
|
|
197
|
+
* root gone and only has its terminal left to release. That run is bounded
|
|
198
|
+
* by its own cap (`TREE_KILL_TIMEOUT_MS`), not by `timeoutMs`: a shorter
|
|
199
|
+
* bound would cut short the very run it exists for.
|
|
200
|
+
*
|
|
201
|
+
* Before any of that, every session's program is waited for
|
|
202
|
+
* (`Session.startedProgramPid`): node-pty creates a Windows terminal's
|
|
203
|
+
* program only after its output worker connects, so a session started in
|
|
204
|
+
* the moment of shutdown has no pid yet. That wait has its own bound (above
|
|
205
|
+
* node-pty's five-second connection limit) and sits outside `timeoutMs`, so
|
|
206
|
+
* the per-session teardown budget is spent on teardown, not on waiting, and
|
|
207
|
+
* each kill is still awaited and verified.
|
|
208
|
+
*
|
|
209
|
+
* So shutdown takes at most the program wait (`PROGRAM_PID_WAIT_MS`), plus
|
|
210
|
+
* the tree kill's cap, plus `timeoutMs`. A session whose program wait ran
|
|
211
|
+
* out is not waited for again by its own kill.
|
|
212
|
+
*
|
|
213
|
+
* Each kill is bounded so shutdown ALWAYS completes. An unbounded teardown
|
|
214
|
+
* that wedges leaves the daemon alive but undiscoverable. That is worse than
|
|
215
|
+
* a best-effort kill, because the user can then only end it via Task
|
|
216
|
+
* Manager, and every future client sees a stale state file. A kill that
|
|
217
|
+
* overruns is logged and abandoned.
|
|
218
|
+
*/
|
|
219
|
+
async killAll(timeoutMs = 10_000) {
|
|
220
|
+
const all = [...this.sessions.values()];
|
|
221
|
+
for (const session of all) {
|
|
222
|
+
if (this.starting.has(session.id))
|
|
223
|
+
this.cancelledStarts.add(session.id);
|
|
224
|
+
this.sessions.delete(session.id);
|
|
225
|
+
this.onRemoved(session.id);
|
|
226
|
+
}
|
|
227
|
+
await Promise.all(all.map(async (session) => {
|
|
228
|
+
await session.startedProgramPid();
|
|
229
|
+
}));
|
|
230
|
+
await this.killTreesInOneRun(all);
|
|
231
|
+
await Promise.all(all.map(async (session) => {
|
|
232
|
+
let timer;
|
|
233
|
+
const bound = new Promise((resolve) => {
|
|
234
|
+
timer = setTimeout(() => resolve('timeout'), timeoutMs);
|
|
235
|
+
});
|
|
236
|
+
const outcome = await Promise.race([session.kill(), bound]);
|
|
237
|
+
if (timer !== undefined)
|
|
238
|
+
clearTimeout(timer);
|
|
239
|
+
if (outcome === 'timeout') {
|
|
240
|
+
this.logger.warn('session teardown exceeded its budget, abandoning it', {
|
|
241
|
+
id: session.id,
|
|
242
|
+
timeoutMs,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Windows only: kill, in one `taskkill` run, the tree of every session
|
|
249
|
+
* whose program has not been seen to end, including one whose session
|
|
250
|
+
* ended without it (`Session.programEnded`).
|
|
251
|
+
*/
|
|
252
|
+
async killTreesInOneRun(sessions) {
|
|
253
|
+
if ((this.sessionDeps.platform ?? process.platform) !== 'win32')
|
|
254
|
+
return;
|
|
255
|
+
// A pid of 0 is a program node-pty has not created yet (its deferred
|
|
256
|
+
// connection); such a session's own kill waits for the pid and then walks
|
|
257
|
+
// its tree, and a start whose connection failed has nothing to walk.
|
|
258
|
+
const pids = sessions
|
|
259
|
+
.filter((session) => !session.programEnded && session.pid > 0)
|
|
260
|
+
.map((session) => session.pid);
|
|
261
|
+
if (pids.length === 0)
|
|
262
|
+
return;
|
|
263
|
+
const failure = await (this.sessionDeps.treeKiller ?? taskkillTrees)(pids);
|
|
264
|
+
if (failure !== null) {
|
|
265
|
+
this.logger.warn(failure.timedOut
|
|
266
|
+
? 'shutdown tree kill timed out; each session still running is killed on its own'
|
|
267
|
+
: 'shutdown taskkill exited non-zero (usually descendants that vanished mid-walk)', { sessions: pids.length, ...failure, timeoutMs: TREE_KILL_TIMEOUT_MS });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/core/manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CA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