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,588 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows console hosts that node-pty leaves behind.
|
|
3
|
+
*
|
|
4
|
+
* ConPTY creates the host while `spawn` runs, and that call returns only
|
|
5
|
+
* after the host exists. The session stores the time immediately before and
|
|
6
|
+
* after it. Nothing is listed then, and a start does not wait.
|
|
7
|
+
*
|
|
8
|
+
* After the session ends, it is queued. One short-lived PowerShell runs
|
|
9
|
+
* `Get-CimInstance` for every session queued within a few hundred
|
|
10
|
+
* milliseconds and asks for the daemon's children. The host that is ended is
|
|
11
|
+
* the one `conhost.exe` or `OpenConsole.exe` whose parent is the daemon and
|
|
12
|
+
* whose creation time falls in that exact window. Candidates are assigned
|
|
13
|
+
* across the batch and other known session windows before any host is ended.
|
|
14
|
+
* A host near another known window outside the batch is protected by a
|
|
15
|
+
* 16 ms guard. Ambiguous and failed items are retried up to three times;
|
|
16
|
+
* a work cap or exhausted retry budget leaves the host running and logs why.
|
|
17
|
+
*
|
|
18
|
+
* The list is not on any path a caller waits on. It compiles nothing: no
|
|
19
|
+
* `Add-Type`, no P/Invoke. Production tracking is on only for Windows.
|
|
20
|
+
* POSIX never queues.
|
|
21
|
+
*
|
|
22
|
+
* Ending the host reclaims the process. Windows PowerShell 5.1's Get-Process
|
|
23
|
+
* holds no handle, and Process.Kill opens its own by pid. The end reads the
|
|
24
|
+
* process handle first, which opens and caches it; a failure to open is the
|
|
25
|
+
* host gone. It then checks the name and the listed creation time, and kills
|
|
26
|
+
* through that cached handle only when both match. The open handle keeps
|
|
27
|
+
* Windows from reusing the pid until the script releases it. A call with no
|
|
28
|
+
* creation time is refused before any process is opened. Every host in the
|
|
29
|
+
* batch is ended by one PowerShell, started asynchronously, so the daemon
|
|
30
|
+
* keeps answering while it runs. The queue settles only after that call
|
|
31
|
+
* finishes. The daemon's own pseudoconsole handle stays open until the
|
|
32
|
+
* daemon exits, and the host is given no CTRL_CLOSE_EVENT.
|
|
33
|
+
*/
|
|
34
|
+
import { execFile } from 'node:child_process';
|
|
35
|
+
/** Windows only. Sessions queue a console host only when this is set. */
|
|
36
|
+
export const TRACK_WINDOWS_CONSOLE_HOST = process.platform === 'win32';
|
|
37
|
+
/** Sessions that end within this of each other share one process list. */
|
|
38
|
+
export const CONSOLE_HOST_COALESCE_MS = 300;
|
|
39
|
+
/**
|
|
40
|
+
* How long one list may take. A CIM query of one parent's children takes
|
|
41
|
+
* about ten seconds on this machine, cold or warm.
|
|
42
|
+
*/
|
|
43
|
+
export const CONSOLE_HOST_QUERY_TIMEOUT_MS = 45_000;
|
|
44
|
+
/** A Windows clock tick can be 15.625 ms; protect neighbouring live windows. */
|
|
45
|
+
export const CONSOLE_HOST_GUARD_MS = 16;
|
|
46
|
+
/** Limits synchronous matching even when a daemon has many sessions. */
|
|
47
|
+
export const CONSOLE_HOST_MAX_CANDIDATES = 1024;
|
|
48
|
+
export const CONSOLE_HOST_MAX_WINDOWS = 256;
|
|
49
|
+
export const CONSOLE_HOST_MAX_ATTEMPTS = 3;
|
|
50
|
+
const CONSOLE_HOST_NAMES = new Set(['conhost.exe', 'openconsole.exe']);
|
|
51
|
+
function isConsoleHostName(name) {
|
|
52
|
+
return CONSOLE_HOST_NAMES.has(name.toLowerCase());
|
|
53
|
+
}
|
|
54
|
+
function errorText(error) {
|
|
55
|
+
if (error instanceof Error)
|
|
56
|
+
return error.message;
|
|
57
|
+
if (typeof error === 'string')
|
|
58
|
+
return error;
|
|
59
|
+
return 'unknown failure';
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A list timed out when the child was killed or a signal was delivered.
|
|
63
|
+
* The message text is not consulted: a failure that merely mentions a
|
|
64
|
+
* timeout is still a failed list.
|
|
65
|
+
*/
|
|
66
|
+
function queryTimedOut(error) {
|
|
67
|
+
if (typeof error !== 'object' || error === null)
|
|
68
|
+
return false;
|
|
69
|
+
if ('killed' in error && error.killed === true)
|
|
70
|
+
return true;
|
|
71
|
+
if ('signal' in error && typeof error.signal === 'string' && error.signal !== '')
|
|
72
|
+
return true;
|
|
73
|
+
if ('cause' in error && error.cause !== error)
|
|
74
|
+
return queryTimedOut(error.cause);
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
/** Why a list could not be used. A timeout is its own reason. */
|
|
78
|
+
export function queryFailureReason(error) {
|
|
79
|
+
if (queryTimedOut(error))
|
|
80
|
+
return 'console host query timed out';
|
|
81
|
+
return `console host query failed: ${errorText(error)}`;
|
|
82
|
+
}
|
|
83
|
+
function matchingHosts(window, hosts, parentPid) {
|
|
84
|
+
return hosts.filter((host) => host.parentPid === parentPid &&
|
|
85
|
+
isConsoleHostName(host.name) &&
|
|
86
|
+
host.creationTime >= window.t0 &&
|
|
87
|
+
host.creationTime <= window.t1);
|
|
88
|
+
}
|
|
89
|
+
function unmatchedReason(count) {
|
|
90
|
+
// "Found", not "created": a start that failed part-way created its host and
|
|
91
|
+
// had it released already (node-pty does that itself), so what is true of
|
|
92
|
+
// every case is that no host of this session was left to find.
|
|
93
|
+
if (count === 0)
|
|
94
|
+
return 'no console host was found in the session window';
|
|
95
|
+
if (count === 1)
|
|
96
|
+
return 'console host belongs to more than one session window';
|
|
97
|
+
return `${String(count)} console hosts were created in the session window`;
|
|
98
|
+
}
|
|
99
|
+
/** Find a one-to-one assignment, optionally excluding one proposed pair. */
|
|
100
|
+
function matchWindows(windows, excluded) {
|
|
101
|
+
const owner = new Map();
|
|
102
|
+
const visit = (window, seen) => {
|
|
103
|
+
for (const host of window.candidates) {
|
|
104
|
+
if (excluded?.id === window.id && excluded.pid === host.pid)
|
|
105
|
+
continue;
|
|
106
|
+
if (seen.has(host.pid))
|
|
107
|
+
continue;
|
|
108
|
+
seen.add(host.pid);
|
|
109
|
+
const previous = owner.get(host.pid);
|
|
110
|
+
if (previous === undefined || visit(previous, seen)) {
|
|
111
|
+
owner.set(host.pid, window);
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
};
|
|
117
|
+
for (const window of windows) {
|
|
118
|
+
visit(window, new Set());
|
|
119
|
+
}
|
|
120
|
+
return new Map([...owner].map(([pid, window]) => [window.id, pid]));
|
|
121
|
+
}
|
|
122
|
+
/** Claim only pairs present in every largest one-to-one assignment. */
|
|
123
|
+
function assignUnambiguousHosts(assignments) {
|
|
124
|
+
const candidates = assignments.filter((assignment) => assignment.candidates.length > 0);
|
|
125
|
+
const matching = matchWindows(candidates);
|
|
126
|
+
for (const assignment of candidates) {
|
|
127
|
+
const pid = matching.get(assignment.id);
|
|
128
|
+
if (pid === undefined || matchWindows(candidates, { id: assignment.id, pid }).size === matching.size)
|
|
129
|
+
continue;
|
|
130
|
+
assignment.match = assignment.candidates.find((host) => host.pid === pid) ?? null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Queue ended sessions and list once for each batch. A host is ended only
|
|
135
|
+
* after one-to-one attribution has chosen that process. The queue settles
|
|
136
|
+
* only once those ends have finished.
|
|
137
|
+
*/
|
|
138
|
+
export function createConsoleHostQueue(options) {
|
|
139
|
+
if (options.endBatch === undefined && options.endProcess === undefined) {
|
|
140
|
+
throw new Error('console host queue has no way to end a process');
|
|
141
|
+
}
|
|
142
|
+
const coalesceMs = options.coalesceMs ?? CONSOLE_HOST_COALESCE_MS;
|
|
143
|
+
const pending = [];
|
|
144
|
+
const attempts = new Map();
|
|
145
|
+
const waiters = [];
|
|
146
|
+
let timer = null;
|
|
147
|
+
let running = 0;
|
|
148
|
+
const idle = () => timer === null && running === 0 && pending.length === 0;
|
|
149
|
+
const notify = () => {
|
|
150
|
+
if (!idle())
|
|
151
|
+
return;
|
|
152
|
+
const ready = waiters.splice(0);
|
|
153
|
+
for (const resolve of ready)
|
|
154
|
+
resolve();
|
|
155
|
+
};
|
|
156
|
+
const schedule = () => {
|
|
157
|
+
if (timer !== null)
|
|
158
|
+
return;
|
|
159
|
+
timer = setTimeout(() => {
|
|
160
|
+
timer = null;
|
|
161
|
+
const batch = pending.splice(0);
|
|
162
|
+
if (batch.length > 0)
|
|
163
|
+
run(batch);
|
|
164
|
+
else
|
|
165
|
+
notify();
|
|
166
|
+
}, coalesceMs);
|
|
167
|
+
timer.unref();
|
|
168
|
+
};
|
|
169
|
+
const finish = (item, ended) => {
|
|
170
|
+
attempts.delete(item.id);
|
|
171
|
+
options.resolved?.(item.id);
|
|
172
|
+
item.onSettled?.(ended);
|
|
173
|
+
};
|
|
174
|
+
const retry = (item) => {
|
|
175
|
+
const count = (attempts.get(item.id) ?? 0) + 1;
|
|
176
|
+
if (count >= CONSOLE_HOST_MAX_ATTEMPTS) {
|
|
177
|
+
item.log('warn', 'console host not ended', { id: item.id, reason: 'retry limit reached' });
|
|
178
|
+
finish(item, false);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
attempts.set(item.id, count);
|
|
182
|
+
pending.push(item);
|
|
183
|
+
schedule();
|
|
184
|
+
};
|
|
185
|
+
const noteEndFailure = (item, pid, error) => {
|
|
186
|
+
const code = error.code;
|
|
187
|
+
if (code === 'ESRCH') {
|
|
188
|
+
finish(item, true);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
item.log('warn', 'console host not ended', {
|
|
192
|
+
id: item.id,
|
|
193
|
+
pid,
|
|
194
|
+
reason: `console host could not be ended: ${errorText(error)}`,
|
|
195
|
+
});
|
|
196
|
+
retry(item);
|
|
197
|
+
};
|
|
198
|
+
const noteEnded = (item, pid) => {
|
|
199
|
+
finish(item, true);
|
|
200
|
+
item.log('info', 'console host ended', { id: item.id, pid });
|
|
201
|
+
};
|
|
202
|
+
const endAll = async (items) => {
|
|
203
|
+
if (items.length === 0)
|
|
204
|
+
return;
|
|
205
|
+
if (options.endBatch) {
|
|
206
|
+
let results;
|
|
207
|
+
try {
|
|
208
|
+
results = await options.endBatch(items.map(({ pid, match }) => ({ pid, host: match })));
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
for (const { item, pid } of items)
|
|
212
|
+
noteEndFailure(item, pid, error);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const byPid = new Map(results.map((result) => [result.pid, result]));
|
|
216
|
+
for (const { item, pid } of items) {
|
|
217
|
+
const result = byPid.get(pid);
|
|
218
|
+
if (result === undefined) {
|
|
219
|
+
noteEndFailure(item, pid, new Error('console host end did not report a result'));
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (result.error === null)
|
|
223
|
+
noteEnded(item, pid);
|
|
224
|
+
else
|
|
225
|
+
noteEndFailure(item, pid, result.error);
|
|
226
|
+
}
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const endProcess = options.endProcess;
|
|
230
|
+
if (endProcess === undefined)
|
|
231
|
+
return;
|
|
232
|
+
// Together, so one slow host does not hold the others behind it. The
|
|
233
|
+
// queue still settles only once every one of them has finished.
|
|
234
|
+
await Promise.all(items.map(async ({ item, pid, match }) => {
|
|
235
|
+
try {
|
|
236
|
+
await endProcess(pid, match);
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
noteEndFailure(item, pid, error);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
noteEnded(item, pid);
|
|
243
|
+
}));
|
|
244
|
+
};
|
|
245
|
+
const run = (batch) => {
|
|
246
|
+
running += 1;
|
|
247
|
+
void options.list(options.parentPid).then(async (hosts) => {
|
|
248
|
+
const batchIds = new Set(batch.map((item) => item.id));
|
|
249
|
+
const others = (options.knownWindows?.() ?? []).filter((known) => !batchIds.has(known.id));
|
|
250
|
+
const windows = [...batch, ...others];
|
|
251
|
+
if (windows.length > CONSOLE_HOST_MAX_WINDOWS) {
|
|
252
|
+
for (const item of batch) {
|
|
253
|
+
item.log('warn', 'console host not ended', { id: item.id, reason: 'window cap exceeded' });
|
|
254
|
+
retry(item);
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const assignments = windows.map((known) => ({
|
|
259
|
+
id: known.id,
|
|
260
|
+
candidates: matchingHosts(known.window, hosts, options.parentPid),
|
|
261
|
+
match: null,
|
|
262
|
+
}));
|
|
263
|
+
const candidateCount = assignments.reduce((count, assignment) => count + assignment.candidates.length, 0);
|
|
264
|
+
if (candidateCount > CONSOLE_HOST_MAX_CANDIDATES) {
|
|
265
|
+
for (const item of batch) {
|
|
266
|
+
item.log('warn', 'console host not ended', { id: item.id, reason: 'candidate cap exceeded' });
|
|
267
|
+
retry(item);
|
|
268
|
+
}
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
assignUnambiguousHosts(assignments);
|
|
272
|
+
const toEnd = [];
|
|
273
|
+
for (const item of batch) {
|
|
274
|
+
const assignment = assignments.find((entry) => entry.id === item.id);
|
|
275
|
+
if (assignment === undefined || assignment.match === null) {
|
|
276
|
+
const count = assignment?.candidates.length ?? 0;
|
|
277
|
+
const reason = unmatchedReason(count);
|
|
278
|
+
// A host can disappear after a kill before this asynchronous list
|
|
279
|
+
// runs. A missing host alone does not establish a leak.
|
|
280
|
+
item.log(count === 0 ? 'info' : 'warn', 'console host not ended', { id: item.id, reason });
|
|
281
|
+
if (count === 0)
|
|
282
|
+
finish(item, true);
|
|
283
|
+
else
|
|
284
|
+
retry(item);
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const pid = assignment.match.pid;
|
|
288
|
+
if (others.some((known) => assignment.match !== null &&
|
|
289
|
+
assignment.match.creationTime >= known.window.t0 - CONSOLE_HOST_GUARD_MS &&
|
|
290
|
+
assignment.match.creationTime <= known.window.t1 + CONSOLE_HOST_GUARD_MS)) {
|
|
291
|
+
item.log('warn', 'console host not ended', { id: item.id, pid, reason: 'host near another session window' });
|
|
292
|
+
retry(item);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
toEnd.push({ item, pid, match: assignment.match });
|
|
296
|
+
}
|
|
297
|
+
// Settling waits for this. A promise returned by the end is part of
|
|
298
|
+
// the batch, not work that happens after the queue has gone idle.
|
|
299
|
+
await endAll(toEnd);
|
|
300
|
+
}, (error) => {
|
|
301
|
+
const reason = queryFailureReason(error);
|
|
302
|
+
for (const item of batch) {
|
|
303
|
+
item.log('warn', 'console host not ended', { id: item.id, reason });
|
|
304
|
+
retry(item);
|
|
305
|
+
}
|
|
306
|
+
}).finally(() => {
|
|
307
|
+
running -= 1;
|
|
308
|
+
notify();
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
return {
|
|
312
|
+
push(item) {
|
|
313
|
+
pending.push(item);
|
|
314
|
+
schedule();
|
|
315
|
+
},
|
|
316
|
+
whenSettled() {
|
|
317
|
+
if (idle())
|
|
318
|
+
return Promise.resolve();
|
|
319
|
+
return new Promise((resolve) => {
|
|
320
|
+
waiters.push(resolve);
|
|
321
|
+
});
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
function parseHostLines(stdout) {
|
|
326
|
+
const lines = stdout
|
|
327
|
+
.split(/\r?\n/)
|
|
328
|
+
.map((line) => line.trim())
|
|
329
|
+
.filter((line) => line !== '');
|
|
330
|
+
return lines.map((line) => {
|
|
331
|
+
const parts = line.split(' ');
|
|
332
|
+
if (parts.length !== 4) {
|
|
333
|
+
throw new Error('console host query failed: a process line was incomplete');
|
|
334
|
+
}
|
|
335
|
+
const pid = Number(parts[0]);
|
|
336
|
+
const parentPid = Number(parts[1]);
|
|
337
|
+
const name = parts[2] ?? '';
|
|
338
|
+
const creationTime = Number(parts[3]);
|
|
339
|
+
if (!Number.isInteger(pid) ||
|
|
340
|
+
!Number.isInteger(parentPid) ||
|
|
341
|
+
name === '' ||
|
|
342
|
+
!Number.isInteger(creationTime)) {
|
|
343
|
+
throw new Error('console host query failed: a process line was incomplete');
|
|
344
|
+
}
|
|
345
|
+
return { pid, parentPid, name, creationTime };
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/** One CIM query: console hosts whose parent is `parentPid`. No compiled code. */
|
|
349
|
+
export function listConsoleHosts(parentPid, timeoutMs = CONSOLE_HOST_QUERY_TIMEOUT_MS) {
|
|
350
|
+
if (!Number.isInteger(parentPid) || parentPid <= 0) {
|
|
351
|
+
return Promise.reject(new Error('console host query failed: parent pid is not a process id'));
|
|
352
|
+
}
|
|
353
|
+
const script = [
|
|
354
|
+
"$ProgressPreference = 'SilentlyContinue'",
|
|
355
|
+
`Get-CimInstance Win32_Process -Filter "ParentProcessId=${String(parentPid)}" |`,
|
|
356
|
+
"Where-Object { $_.Name -eq 'conhost.exe' -or $_.Name -eq 'OpenConsole.exe' } |",
|
|
357
|
+
'ForEach-Object {',
|
|
358
|
+
' $unix = [DateTimeOffset]::new($_.CreationDate.ToUniversalTime()).ToUnixTimeMilliseconds()',
|
|
359
|
+
" '{0} {1} {2} {3}' -f [int]$_.ProcessId, [int]$_.ParentProcessId, $_.Name, $unix",
|
|
360
|
+
'}',
|
|
361
|
+
].join('\n');
|
|
362
|
+
return new Promise((resolve, reject) => {
|
|
363
|
+
const child = execFile('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script], { windowsHide: true, timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 }, (error, stdout) => {
|
|
364
|
+
if (error) {
|
|
365
|
+
reject(error instanceof Error ? error : new Error(errorText(error), { cause: error }));
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
try {
|
|
369
|
+
resolve(parseHostLines(stdout));
|
|
370
|
+
}
|
|
371
|
+
catch (parseError) {
|
|
372
|
+
reject(parseError instanceof Error ? parseError : new Error('console host query failed'));
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
child.unref();
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
/** How close a process start time must be to the listed creation time. */
|
|
379
|
+
const HOST_IDENTITY_MS = 50;
|
|
380
|
+
/** One end for a batch. PowerShell can take seconds to start; do not block on it. */
|
|
381
|
+
const HOST_END_TIMEOUT_MS = 20_000;
|
|
382
|
+
function expectedCreationTime(pid, creationTime) {
|
|
383
|
+
if (!Number.isInteger(pid) || pid <= 0) {
|
|
384
|
+
throw Object.assign(new Error('console host pid is not a process id'), { code: 'ESRCH' });
|
|
385
|
+
}
|
|
386
|
+
// Name alone is not an identity. Callers have the time the list recorded.
|
|
387
|
+
if (creationTime === undefined) {
|
|
388
|
+
throw Object.assign(new Error('console host creation time is required'), { code: 'ESRCH' });
|
|
389
|
+
}
|
|
390
|
+
if (!Number.isInteger(creationTime)) {
|
|
391
|
+
throw Object.assign(new Error('console host creation time is not a time'), { code: 'ESRCH' });
|
|
392
|
+
}
|
|
393
|
+
return creationTime;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* The check and the handle kill, once per host, in one process. `$PID` is
|
|
397
|
+
* PowerShell's own process, so the target id has another name. Get-Process
|
|
398
|
+
* holds no handle on Windows PowerShell 5.1: the handle is opened by reading
|
|
399
|
+
* it, and Kill then uses that cached handle rather than opening another by
|
|
400
|
+
* pid. A throw, or a handle that comes back empty, is the host gone (2), not
|
|
401
|
+
* a retry. Stdout codes are
|
|
402
|
+
* 0 ended, 2 gone, 3 not that host. A throw is 1, so one host's failure does
|
|
403
|
+
* not skip the rest of the batch. The start time is always compared: there is
|
|
404
|
+
* no sentinel that skips it.
|
|
405
|
+
*/
|
|
406
|
+
function endScript(targets) {
|
|
407
|
+
const hosts = targets.map(({ pid, expected }) => [
|
|
408
|
+
`$targetId = ${String(pid)}`,
|
|
409
|
+
`$expected = ${String(expected)}`,
|
|
410
|
+
'try {',
|
|
411
|
+
' $proc = Get-Process -Id $targetId -ErrorAction SilentlyContinue',
|
|
412
|
+
' if ($null -eq $proc) { Write-Output "$targetId 2" }',
|
|
413
|
+
' else {',
|
|
414
|
+
' $opened = $true',
|
|
415
|
+
' try {',
|
|
416
|
+
' $openedHandle = $proc.Handle',
|
|
417
|
+
' if ($null -eq $openedHandle -or $openedHandle -eq [IntPtr]::Zero) { $opened = $false }',
|
|
418
|
+
' } catch { $opened = $false }',
|
|
419
|
+
' if (-not $opened) { Write-Output "$targetId 2" }',
|
|
420
|
+
' else {',
|
|
421
|
+
' $image = $proc.ProcessName',
|
|
422
|
+
' $code = 0',
|
|
423
|
+
" if ($image -ne 'conhost' -and $image -ne 'OpenConsole') { $code = 3 }",
|
|
424
|
+
' else {',
|
|
425
|
+
' $start = [DateTimeOffset]::new($proc.StartTime.ToUniversalTime()).ToUnixTimeMilliseconds()',
|
|
426
|
+
` if ([Math]::Abs($start - $expected) -gt ${String(HOST_IDENTITY_MS)}) { $code = 3 }`,
|
|
427
|
+
' }',
|
|
428
|
+
' if ($code -eq 0) { $proc.Kill() }',
|
|
429
|
+
' Write-Output "$targetId $code"',
|
|
430
|
+
' }',
|
|
431
|
+
' }',
|
|
432
|
+
'} catch {',
|
|
433
|
+
" $detail = ($_.Exception.Message -replace '\\s+', ' ').Trim()",
|
|
434
|
+
' Write-Output "$targetId 1 $detail"',
|
|
435
|
+
'}',
|
|
436
|
+
].join('\n'));
|
|
437
|
+
return [
|
|
438
|
+
"$ProgressPreference = 'SilentlyContinue'",
|
|
439
|
+
"$ErrorActionPreference = 'Stop'",
|
|
440
|
+
...hosts,
|
|
441
|
+
'exit 0',
|
|
442
|
+
].join('\n');
|
|
443
|
+
}
|
|
444
|
+
function parseEndReport(stdout) {
|
|
445
|
+
const reported = new Map();
|
|
446
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
447
|
+
const match = /^(\d+) (\d+)(?: (.*))?$/.exec(line.trim());
|
|
448
|
+
if (match === null)
|
|
449
|
+
continue;
|
|
450
|
+
const pid = Number(match[1]);
|
|
451
|
+
const status = Number(match[2]);
|
|
452
|
+
if (!Number.isInteger(pid) || !Number.isInteger(status))
|
|
453
|
+
continue;
|
|
454
|
+
reported.set(pid, { status, message: match[3] ?? '' });
|
|
455
|
+
}
|
|
456
|
+
return reported;
|
|
457
|
+
}
|
|
458
|
+
function gone() {
|
|
459
|
+
return Object.assign(new Error('console host is gone'), { code: 'ESRCH' });
|
|
460
|
+
}
|
|
461
|
+
function failureCode(error) {
|
|
462
|
+
if (typeof error !== 'object' || error === null || !('code' in error))
|
|
463
|
+
return undefined;
|
|
464
|
+
return error.code;
|
|
465
|
+
}
|
|
466
|
+
function resultsFromReport(runnable, stdout, fallback) {
|
|
467
|
+
const reported = parseEndReport(stdout);
|
|
468
|
+
const fallbackCode = failureCode(fallback);
|
|
469
|
+
return runnable.map(({ pid }) => {
|
|
470
|
+
const line = reported.get(pid);
|
|
471
|
+
if (line === undefined) {
|
|
472
|
+
if (fallbackCode === 'ESRCH')
|
|
473
|
+
return { pid, error: gone() };
|
|
474
|
+
if (fallback instanceof Error)
|
|
475
|
+
return { pid, error: fallback };
|
|
476
|
+
return { pid, error: new Error('console host end did not report a result') };
|
|
477
|
+
}
|
|
478
|
+
if (line.status === 0)
|
|
479
|
+
return { pid, error: null };
|
|
480
|
+
// 2: the pid is gone. 3: it is no longer the listed host. Either way the
|
|
481
|
+
// host we meant has gone, and the process that has the pid is not ours.
|
|
482
|
+
if (line.status === 2 || line.status === 3)
|
|
483
|
+
return { pid, error: gone() };
|
|
484
|
+
const message = line.message.trim();
|
|
485
|
+
return { pid, error: new Error(message === '' ? 'console host could not be ended' : message) };
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
function runEndScript(script) {
|
|
489
|
+
return new Promise((resolve, reject) => {
|
|
490
|
+
const child = execFile('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script], { windowsHide: true, timeout: HOST_END_TIMEOUT_MS, maxBuffer: 1024 * 1024 }, (error, stdout) => {
|
|
491
|
+
const text = typeof stdout === 'string' ? stdout : '';
|
|
492
|
+
if (error) {
|
|
493
|
+
// The script always exits 0. A host's own result is a stdout code,
|
|
494
|
+
// so a non-zero status here is PowerShell failing, not "gone".
|
|
495
|
+
const wrapped = error instanceof Error ? error : new Error(errorText(error), { cause: error });
|
|
496
|
+
reject(Object.assign(wrapped, { stdout: text }));
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
resolve(text);
|
|
500
|
+
});
|
|
501
|
+
child.unref();
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* End every listed host in one asynchronous PowerShell. Each pid was read
|
|
506
|
+
* from a process list, so by the time this runs Windows may have given it to
|
|
507
|
+
* another process. A bare `process.kill` would then reach that process,
|
|
508
|
+
* including one on another console.
|
|
509
|
+
*/
|
|
510
|
+
export function endConsoleHostProcesses(targets) {
|
|
511
|
+
const results = [];
|
|
512
|
+
const runnable = [];
|
|
513
|
+
for (const target of targets) {
|
|
514
|
+
try {
|
|
515
|
+
runnable.push({
|
|
516
|
+
pid: target.pid,
|
|
517
|
+
expected: expectedCreationTime(target.pid, target.creationTime),
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
catch (error) {
|
|
521
|
+
results.push({ pid: target.pid, error });
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (runnable.length === 0)
|
|
525
|
+
return Promise.resolve(results);
|
|
526
|
+
return runEndScript(endScript(runnable)).then((stdout) => results.concat(resultsFromReport(runnable, stdout, null)), (error) => {
|
|
527
|
+
const stdout = error.stdout;
|
|
528
|
+
const text = typeof stdout === 'string' ? stdout : '';
|
|
529
|
+
return results.concat(resultsFromReport(runnable, text, error));
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* End `pid` only when it is still the console host listed at `creationTime`.
|
|
534
|
+
* The time is required: without it the call is refused and nothing is opened.
|
|
535
|
+
* Reads that process's handle first, which opens and caches it, then checks
|
|
536
|
+
* the name and the start time, and kills through the cached handle. A pid
|
|
537
|
+
* reused after the open is not the one killed, and the open handle keeps
|
|
538
|
+
* Windows from reusing the pid until it is closed. Rejects with `ESRCH` when
|
|
539
|
+
* the pid is gone, the handle cannot be opened, or the process is no longer
|
|
540
|
+
* that host, and the caller leaves that process running. The PowerShell is
|
|
541
|
+
* asynchronous.
|
|
542
|
+
*/
|
|
543
|
+
export function endConsoleHostProcess(pid, creationTime) {
|
|
544
|
+
return endConsoleHostProcesses([{ pid, creationTime }]).then((ended) => {
|
|
545
|
+
const result = ended.find((entry) => entry.pid === pid);
|
|
546
|
+
if (result === undefined)
|
|
547
|
+
throw gone();
|
|
548
|
+
if (result.error === null)
|
|
549
|
+
return;
|
|
550
|
+
if (result.error instanceof Error)
|
|
551
|
+
throw result.error;
|
|
552
|
+
throw new Error(errorText(result.error));
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
let daemonQueue = null;
|
|
556
|
+
const knownConsoleHostWindows = new Map();
|
|
557
|
+
/** Keep live and unresolved windows available while another batch lists. */
|
|
558
|
+
export function registerConsoleHostWindow(id, window, platform = process.platform) {
|
|
559
|
+
if (platform === 'win32')
|
|
560
|
+
knownConsoleHostWindows.set(id, window);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Resolves when the daemon's queue has finished the batches already pushed.
|
|
564
|
+
* Nothing is listed at the call. Tests wait here instead of polling; the
|
|
565
|
+
* daemon does not.
|
|
566
|
+
*/
|
|
567
|
+
export function whenConsoleHostBatchSettled() {
|
|
568
|
+
if (daemonQueue === null)
|
|
569
|
+
return Promise.resolve();
|
|
570
|
+
return daemonQueue.whenSettled();
|
|
571
|
+
}
|
|
572
|
+
/** Queue one ended session. The list runs later, off the caller's stack. */
|
|
573
|
+
export function queueConsoleHostEnd(item) {
|
|
574
|
+
if (!TRACK_WINDOWS_CONSOLE_HOST)
|
|
575
|
+
return;
|
|
576
|
+
daemonQueue ??= createConsoleHostQueue({
|
|
577
|
+
parentPid: process.pid,
|
|
578
|
+
list: (parentPid) => listConsoleHosts(parentPid),
|
|
579
|
+
endBatch: (items) => endConsoleHostProcesses(items.map((item) => ({
|
|
580
|
+
pid: item.pid,
|
|
581
|
+
creationTime: item.host.creationTime,
|
|
582
|
+
}))),
|
|
583
|
+
knownWindows: () => [...knownConsoleHostWindows].map(([id, window]) => ({ id, window })),
|
|
584
|
+
resolved: (id) => { knownConsoleHostWindows.delete(id); },
|
|
585
|
+
});
|
|
586
|
+
daemonQueue.push(item);
|
|
587
|
+
}
|
|
588
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