shellpuppet 0.1.0 → 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/README.md +191 -32
- 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.js +205 -52
- package/dist/cli/index.js.map +1 -1
- package/dist/client/http.d.ts +62 -1
- package/dist/client/http.js +388 -32
- package/dist/client/http.js.map +1 -1
- package/dist/core/dialogs.d.ts +20 -12
- package/dist/core/dialogs.js +31 -19
- package/dist/core/dialogs.js.map +1 -1
- package/dist/core/manager.d.ts +35 -5
- package/dist/core/manager.js +121 -8
- package/dist/core/manager.js.map +1 -1
- package/dist/core/nativePty.d.ts +9 -5
- package/dist/core/nativePty.js +11 -6
- package/dist/core/nativePty.js.map +1 -1
- package/dist/core/promptDetector.d.ts +37 -3
- package/dist/core/promptDetector.js +303 -12
- package/dist/core/promptDetector.js.map +1 -1
- package/dist/core/reasoning.d.ts +19 -6
- package/dist/core/reasoning.js +223 -30
- package/dist/core/reasoning.js.map +1 -1
- package/dist/core/regexBudget.d.ts +20 -0
- package/dist/core/regexBudget.js +25 -1
- package/dist/core/regexBudget.js.map +1 -1
- package/dist/core/renderer.d.ts +16 -1
- package/dist/core/renderer.js +97 -6
- package/dist/core/renderer.js.map +1 -1
- 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 +266 -12
- package/dist/core/session.js +583 -99
- package/dist/core/session.js.map +1 -1
- package/dist/core/types.d.ts +53 -18
- package/dist/core/types.js +30 -6
- package/dist/core/types.js.map +1 -1
- package/dist/core/waiter.d.ts +12 -4
- package/dist/core/waiter.js +63 -70
- package/dist/core/waiter.js.map +1 -1
- 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 +100 -29
- package/dist/core/windowsPtyStart.js +143 -36
- package/dist/core/windowsPtyStart.js.map +1 -1
- package/dist/daemon/auth.d.ts +72 -2
- package/dist/daemon/auth.js +128 -3
- package/dist/daemon/auth.js.map +1 -1
- package/dist/daemon/config.d.ts +44 -1
- package/dist/daemon/config.js +276 -9
- package/dist/daemon/config.js.map +1 -1
- 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.js +20 -19
- package/dist/daemon/index.js.map +1 -1
- 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/paths.d.ts +2 -0
- package/dist/daemon/paths.js.map +1 -1
- package/dist/daemon/screenshot.d.ts +58 -1
- package/dist/daemon/screenshot.js +172 -26
- package/dist/daemon/screenshot.js.map +1 -1
- package/dist/daemon/server.d.ts +219 -10
- package/dist/daemon/server.js +1970 -203
- package/dist/daemon/server.js.map +1 -1
- 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/viewerLauncher.d.ts +100 -9
- package/dist/daemon/viewerLauncher.js +349 -67
- package/dist/daemon/viewerLauncher.js.map +1 -1
- package/dist/mcp/config.d.ts +7 -14
- package/dist/mcp/config.js +10 -21
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp/index.js +20 -11
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +161 -60
- package/dist/mcp/tools.js.map +1 -1
- 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.ico +0 -0
- package/dist/viewer/index.html +12 -7
- package/dist/viewer/pane.js +736 -0
- package/dist/viewer/viewer.css +18 -7
- package/dist/viewer/viewer.js +47 -624
- package/package.json +13 -13
package/dist/core/session.d.ts
CHANGED
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
*
|
|
14
14
|
* No stdout/stderr: logging via the injected Logger only (lint-enforced).
|
|
15
15
|
*/
|
|
16
|
+
import type { IPty } from 'node-pty';
|
|
17
|
+
import type { QueuedConsoleHost, SpawnWindow } from './windowsConsoleHost.js';
|
|
16
18
|
import type { SerializeOptions, StyledLine } from './renderer.js';
|
|
19
|
+
import { detectPrompt } from './promptDetector.js';
|
|
20
|
+
import type { WaiterInternals } from './waiter.js';
|
|
17
21
|
import type { WaitTarget } from './waiter.js';
|
|
18
22
|
import type { Logger, ScreenSnapshot, SessionEnvMode, SessionOptions, SessionSummary, WaitCondition, WaitOptions, WaitResult } from './types.js';
|
|
19
23
|
/**
|
|
@@ -30,6 +34,8 @@ import type { Logger, ScreenSnapshot, SessionEnvMode, SessionOptions, SessionSum
|
|
|
30
34
|
* case.
|
|
31
35
|
*/
|
|
32
36
|
export declare const TREE_KILL_TIMEOUT_MS = 30000;
|
|
37
|
+
/** Quote one literal argument for the Windows C runtime's argv parser. */
|
|
38
|
+
export declare function windowsArgument(arg: string): string;
|
|
33
39
|
/** What a `taskkill` run reported when it did not simply succeed. */
|
|
34
40
|
export interface TreeKillFailure {
|
|
35
41
|
/** Our timeout fired and `taskkill` was terminated mid-walk. */
|
|
@@ -51,6 +57,8 @@ export type TreeKiller = (pids: readonly number[]) => Promise<TreeKillFailure |
|
|
|
51
57
|
* shutdown kills every tree in one run (`SessionManager.killAll`).
|
|
52
58
|
*/
|
|
53
59
|
export declare const taskkillTrees: TreeKiller;
|
|
60
|
+
/** Muse needs a short pause after text before its submitting Enter. */
|
|
61
|
+
export declare const MUSE_SUBMIT_DELAY_MS = 400;
|
|
54
62
|
/**
|
|
55
63
|
* Whether the cursor is hidden after this chunk of program output, given
|
|
56
64
|
* whether it was before. The LAST transition in the chunk wins (a TUI
|
|
@@ -72,18 +80,117 @@ export declare function cursorHiddenAfter(scan: string, current: boolean): boole
|
|
|
72
80
|
* every redraw.
|
|
73
81
|
*/
|
|
74
82
|
export declare function bracketedPasteAfter(scan: string, current: boolean): boolean;
|
|
75
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* A command that cannot be started as given: a bare name not on PATH, a path
|
|
85
|
+
* that is not an executable file, or on Windows a script started without the
|
|
86
|
+
* shell. A caller error, mapped to 400.
|
|
87
|
+
*/
|
|
76
88
|
export declare class CommandNotFoundError extends Error {
|
|
77
89
|
constructor(message: string);
|
|
78
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* The Windows build number of an `os.release()` string (`10.0.19045` → 19045),
|
|
93
|
+
* or 0 when the string names none.
|
|
94
|
+
*/
|
|
95
|
+
export declare function windowsBuildNumber(release: string): number;
|
|
96
|
+
/**
|
|
97
|
+
* The first Windows build with ConPTY, as node-pty's own README states:
|
|
98
|
+
* Windows 10 version 1809, build 18309. node-pty 1.2.0 removed its winpty
|
|
99
|
+
* fallback, so a session cannot start on a build below this.
|
|
100
|
+
*/
|
|
101
|
+
export declare const CONPTY_MINIMUM_BUILD = 18309;
|
|
102
|
+
/**
|
|
103
|
+
* A start on a Windows build with no ConPTY, which node-pty 1.2.0 cannot run
|
|
104
|
+
* a terminal on (it removed the winpty fallback). A caller error, mapped to
|
|
105
|
+
* 400: nothing about the daemon is wrong, and the message names the floor.
|
|
106
|
+
*/
|
|
107
|
+
export declare class WindowsWithoutConPTYError extends Error {
|
|
108
|
+
constructor(build: number);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Input for a session whose input pipe has failed (Windows): refused, because
|
|
112
|
+
* written it would be lost. The daemon answers it with a 409.
|
|
113
|
+
*/
|
|
114
|
+
export declare class SessionInputFailedError extends Error {
|
|
115
|
+
constructor(id: string, cause: Error);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A resize of a session whose program node-pty has seen end: refused, as there
|
|
119
|
+
* is no terminal left to resize. It can be asked for in the moment between that
|
|
120
|
+
* end and the session's exit, which follows once node-pty has flushed the last
|
|
121
|
+
* output. The daemon answers it with the 409 a session that has exited gets.
|
|
122
|
+
*/
|
|
123
|
+
export declare class SessionProgramEndedError extends Error {
|
|
124
|
+
readonly sessionId: string;
|
|
125
|
+
readonly exitCode: number;
|
|
126
|
+
constructor(sessionId: string, exitCode: number);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Resolve a command to a concrete executable path before spawning directly
|
|
130
|
+
* (`shell: false`). Necessary on **every** platform, for different reasons:
|
|
131
|
+
*
|
|
132
|
+
* - **Windows:** node-pty does not search PATH at all, and fails with a bare
|
|
133
|
+
* `File not found:` naming nothing.
|
|
134
|
+
* - **POSIX:** this is worse, because `pty.spawn` of a nonexistent command
|
|
135
|
+
* *succeeds*. execvp fails inside the forked child, the parent never learns
|
|
136
|
+
* and the caller gets a healthy-looking session that is silently dead. An
|
|
137
|
+
* agent would then wait out its full timeout for output that can never
|
|
138
|
+
* arrive.
|
|
139
|
+
*
|
|
140
|
+
* Resolving up front turns both into an immediate, actionable error.
|
|
141
|
+
*
|
|
142
|
+
* On Windows the file found must be a program Windows starts as one: an
|
|
143
|
+
* `.exe` or a `.com`. A batch file (`.bat`, `.cmd`) is refused, because
|
|
144
|
+
* Windows would hand it to cmd.exe with the arguments quoted for a program's
|
|
145
|
+
* parser, which cmd reads by different rules. A `.ps1` or an extensionless
|
|
146
|
+
* script is refused too. A path whose file name contains `:` names an
|
|
147
|
+
* alternate data stream and is refused before anything is opened. A command
|
|
148
|
+
* that contains a path separator and is not absolute is resolved from the
|
|
149
|
+
* session's working directory, and that absolute path is what is checked and
|
|
150
|
+
* what is started.
|
|
151
|
+
*/
|
|
152
|
+
/**
|
|
153
|
+
* Whether a Windows path's file name names an alternate data stream.
|
|
154
|
+
* The last path component holds the stream (`run.cmd:payload.exe`). A drive
|
|
155
|
+
* prefix (`C:`) is never in that component, so `C:\dir\app.exe` and the
|
|
156
|
+
* drive-relative `C:app.exe` are false. Strings only: nothing is opened.
|
|
157
|
+
*/
|
|
158
|
+
export declare function windowsCandidateNamesStream(candidate: string): boolean;
|
|
79
159
|
export interface SessionDeps {
|
|
80
160
|
logger?: Logger;
|
|
81
161
|
/** Platform override, for tests only. Defaults to `process.platform`. */
|
|
82
162
|
platform?: NodeJS.Platform;
|
|
163
|
+
/**
|
|
164
|
+
* Windows release override (`os.release()`), for tests only. Defaults to
|
|
165
|
+
* the real one, whose build number decides the ConPTY floor.
|
|
166
|
+
*/
|
|
167
|
+
osRelease?: string;
|
|
168
|
+
/**
|
|
169
|
+
* How long a kill waits for the deferred program's pid, for tests only.
|
|
170
|
+
* Defaults to `PROGRAM_PID_WAIT_MS`.
|
|
171
|
+
*/
|
|
172
|
+
pidWaitMs?: number;
|
|
83
173
|
/** Environment hygiene mode (design §4.6). Defaults to `DEFAULT_SESSION_ENV`. */
|
|
84
174
|
sessionEnv?: SessionEnvMode;
|
|
85
175
|
/** Windows tree killer override, for tests only. Defaults to `taskkillTrees`. */
|
|
86
176
|
treeKiller?: TreeKiller;
|
|
177
|
+
/**
|
|
178
|
+
* Console-host queue, for tests only. Defaults to the real queue.
|
|
179
|
+
* A session calls it only when `platform` is Windows.
|
|
180
|
+
*/
|
|
181
|
+
queueConsoleHostEnd?: (item: QueuedConsoleHost) => void;
|
|
182
|
+
/** Window registration override, for tests only. */
|
|
183
|
+
registerConsoleHostWindow?: (id: string, window: SpawnWindow, platform: NodeJS.Platform) => void;
|
|
184
|
+
/** Internal second attempt: the retry log already names this session. */
|
|
185
|
+
retryAttempt?: boolean;
|
|
186
|
+
/** PTY spawn, for tests only. Defaults to node-pty. No process is started. */
|
|
187
|
+
spawn?: (file: string, args: string[] | string, options: {
|
|
188
|
+
name: string;
|
|
189
|
+
cols: number;
|
|
190
|
+
rows: number;
|
|
191
|
+
cwd: string;
|
|
192
|
+
env: Record<string, string | undefined>;
|
|
193
|
+
}) => IPty;
|
|
87
194
|
}
|
|
88
195
|
/**
|
|
89
196
|
* A session gets the clean baseline unless the configuration says otherwise
|
|
@@ -111,8 +218,14 @@ export declare function credentialShapedNames(source?: NodeJS.ProcessEnv): strin
|
|
|
111
218
|
* (`SessionOptions.env`), set on top of whatever the mode gave. On Windows a
|
|
112
219
|
* passed name replaces the inherited variable of the same name in any case,
|
|
113
220
|
* rather than sitting beside it as a second copy.
|
|
221
|
+
*
|
|
222
|
+
* A name reserved for a connected feature's credential (ADR-007) is never
|
|
223
|
+
* carried, whichever mode is in force: `passthrough` copies the daemon's
|
|
224
|
+
* environment and a list mode can name anything, so the filter has to sit
|
|
225
|
+
* here rather than in one caller. A session's own `passed` value is not the
|
|
226
|
+
* daemon's copy and is left alone.
|
|
114
227
|
*/
|
|
115
|
-
export declare function buildSessionEnv(mode: SessionEnvMode, platform: NodeJS.Platform, source?: NodeJS.ProcessEnv, passed?: Record<string, string>): Record<string, string>;
|
|
228
|
+
export declare function buildSessionEnv(mode: SessionEnvMode, platform: NodeJS.Platform, source?: NodeJS.ProcessEnv, passed?: Record<string, string>, reserved?: ReadonlySet<string>): Record<string, string>;
|
|
116
229
|
export declare class Session implements WaitTarget {
|
|
117
230
|
readonly id: string;
|
|
118
231
|
readonly label: string;
|
|
@@ -130,7 +243,14 @@ export declare class Session implements WaitTarget {
|
|
|
130
243
|
private readonly renderer;
|
|
131
244
|
private readonly logger;
|
|
132
245
|
private readonly platform;
|
|
246
|
+
private readonly endConsoleHost;
|
|
247
|
+
private readonly registerConsoleHost;
|
|
248
|
+
private readonly spawnPty;
|
|
133
249
|
private readonly treeKiller;
|
|
250
|
+
/** How long a kill waits for the deferred program's pid (a test seam). */
|
|
251
|
+
private readonly pidWaitMs;
|
|
252
|
+
/** Set once a wait for the program's pid has run out (`programPid`). */
|
|
253
|
+
private programWaitExpired;
|
|
134
254
|
/** Whether the program has bracketed paste (DEC 2004) enabled. See PASTE_START. */
|
|
135
255
|
private bracketedPaste;
|
|
136
256
|
/**
|
|
@@ -145,10 +265,15 @@ export declare class Session implements WaitTarget {
|
|
|
145
265
|
private modeScanTail;
|
|
146
266
|
private readonly dataListeners;
|
|
147
267
|
private readonly exitListeners;
|
|
268
|
+
private readonly readyListeners;
|
|
148
269
|
/** Whether the program has hidden the cursor (DECTCEM off), carried to viewers. */
|
|
149
270
|
private cursorHidden;
|
|
150
271
|
/** Serialises write() so chunked writes cannot interleave. See write(). */
|
|
151
272
|
private writeChain;
|
|
273
|
+
private museSubmissionsQueued;
|
|
274
|
+
private readonly musePromptSettler;
|
|
275
|
+
/** Why the input pipe failed (Windows), once it has: input is refused from then on. */
|
|
276
|
+
private inputFailure;
|
|
152
277
|
private lastChange;
|
|
153
278
|
/** Sticky: the rendered screen has shown something at least once. */
|
|
154
279
|
private painted;
|
|
@@ -163,10 +288,21 @@ export declare class Session implements WaitTarget {
|
|
|
163
288
|
private exitedFlag;
|
|
164
289
|
private exitedAtValue;
|
|
165
290
|
private exitCodeValue;
|
|
291
|
+
private conptyStartError;
|
|
292
|
+
/** The tree kill under way for a program whose session ended with no exit code. */
|
|
293
|
+
private endingProgram;
|
|
166
294
|
private readyFlag;
|
|
167
295
|
private readyReasonValue;
|
|
168
296
|
private geometryHeldFlag;
|
|
169
|
-
private
|
|
297
|
+
private killPromise;
|
|
298
|
+
private consoleHostSettlement;
|
|
299
|
+
/**
|
|
300
|
+
* Times taken immediately before and after the spawn, on Windows. ConPTY
|
|
301
|
+
* creates the console host during that call. Null on any other platform.
|
|
302
|
+
*/
|
|
303
|
+
private consoleHostWindow;
|
|
304
|
+
/** The end has been queued once. A kill and an exit must not queue it twice. */
|
|
305
|
+
private consoleHostQueued;
|
|
170
306
|
constructor(id: string, options: SessionOptions, deps?: SessionDeps);
|
|
171
307
|
/**
|
|
172
308
|
* Windows default: wrap in `cmd.exe` (§7: direct ConPTY spawns of
|
|
@@ -197,7 +333,25 @@ export declare class Session implements WaitTarget {
|
|
|
197
333
|
get exited(): boolean;
|
|
198
334
|
/** Epoch ms of process exit: the manager's reap grace counts from here. */
|
|
199
335
|
get exitedAt(): number | null;
|
|
336
|
+
/**
|
|
337
|
+
* The program's exit code once the session has ended. Null while it runs,
|
|
338
|
+
* and for a session that ended with no code because its output failed: the
|
|
339
|
+
* code node-pty records for its program afterwards is not reported
|
|
340
|
+
* (`howSessionEnded`).
|
|
341
|
+
*/
|
|
200
342
|
get exitCode(): number | null;
|
|
343
|
+
/**
|
|
344
|
+
* Whether the session's program is known to have ended: node-pty has
|
|
345
|
+
* recorded its exit code, or its exit came with a code. Until then its
|
|
346
|
+
* tree is walked. The recorded code is enough on its own, before this
|
|
347
|
+
* session's exit event: node-pty closes the process handle first, so the
|
|
348
|
+
* pid is already free. Where node-pty records none (`canReadExitCode`),
|
|
349
|
+
* an exit with no code counts as the end: a pid nothing vouches for is
|
|
350
|
+
* never walked.
|
|
351
|
+
*/
|
|
352
|
+
get programEnded(): boolean;
|
|
353
|
+
/** Whether the input pipe has failed (Windows): input is refused from then on. */
|
|
354
|
+
get inputFailed(): boolean;
|
|
201
355
|
get watchers(): number;
|
|
202
356
|
getScreen(): string;
|
|
203
357
|
lastChangeAt(): number;
|
|
@@ -226,9 +380,16 @@ export declare class Session implements WaitTarget {
|
|
|
226
380
|
* Resolves with the screen as it was rendered just before this input went
|
|
227
381
|
* in, taken in the queue, so an earlier write still going in cannot be
|
|
228
382
|
* mistaken for this one's effect (`terminal_type`'s verify compares with it).
|
|
383
|
+
*
|
|
384
|
+
* Rejects with `SessionInputFailedError` once the input pipe has failed,
|
|
385
|
+
* including for the rest of a chunked write it fails part-way through.
|
|
229
386
|
*/
|
|
230
387
|
write(data: string): Promise<string>;
|
|
231
388
|
private writeInput;
|
|
389
|
+
private writeData;
|
|
390
|
+
/** Input written after the input pipe has failed would be lost: refuse it. */
|
|
391
|
+
private refuseIfInputFailed;
|
|
392
|
+
private refuseIfEnded;
|
|
232
393
|
/**
|
|
233
394
|
* Resize the PTY.
|
|
234
395
|
*
|
|
@@ -239,13 +400,25 @@ export declare class Session implements WaitTarget {
|
|
|
239
400
|
* than inferred from who is calling. Omitting `hold` leaves the current
|
|
240
401
|
* setting alone, so a viewport following a window cannot quietly release a
|
|
241
402
|
* hold that a scripted run is relying on.
|
|
403
|
+
*
|
|
404
|
+
* Throws `SessionProgramEndedError` once node-pty has seen the program end,
|
|
405
|
+
* where it records that (`recordedExitCode`): there is no terminal left to
|
|
406
|
+
* resize, and node-pty itself throws for that on a Windows terminal that has
|
|
407
|
+
* drawn.
|
|
408
|
+
* On Windows a resize asked for before the terminal's first output is held
|
|
409
|
+
* by node-pty and run later; one that finds the program ended by then is
|
|
410
|
+
* dropped (`windowsPtyStart.ts`).
|
|
242
411
|
*/
|
|
243
412
|
resize(cols: number, rows: number, options?: {
|
|
244
413
|
hold?: boolean;
|
|
245
|
-
}): void
|
|
414
|
+
}): void | Promise<void>;
|
|
415
|
+
private resizeNow;
|
|
416
|
+
answerablePrompt(screen: string, now?: number): ReturnType<typeof detectPrompt>;
|
|
246
417
|
/** Live raw-stream subscription (viewer mirroring). Returns unsubscribe. */
|
|
247
418
|
onData(listener: (data: string) => void): () => void;
|
|
248
|
-
onExit(listener: (exitCode: number) => void): () => void;
|
|
419
|
+
onExit(listener: (exitCode: number | null) => void): () => void;
|
|
420
|
+
/** Notify the daemon when the readiness condition settles. */
|
|
421
|
+
onReady(listener: () => void): () => void;
|
|
249
422
|
/**
|
|
250
423
|
* The rendered terminal as bytes that rebuild it in a fresh terminal of the
|
|
251
424
|
* same size (design §5): what a viewer receives on connect and after every
|
|
@@ -257,6 +430,16 @@ export declare class Session implements WaitTarget {
|
|
|
257
430
|
* nothing received after it.
|
|
258
431
|
*/
|
|
259
432
|
viewerState(options?: SerializeOptions): Promise<string>;
|
|
433
|
+
/** The filter's styled rows and the viewer replay from one rendered frame. */
|
|
434
|
+
captureViewerScreen(above: number, scrollback: number): Promise<{
|
|
435
|
+
view: {
|
|
436
|
+
lines: StyledLine[];
|
|
437
|
+
firstVisible: number;
|
|
438
|
+
};
|
|
439
|
+
state: string;
|
|
440
|
+
cols: number;
|
|
441
|
+
rows: number;
|
|
442
|
+
}>;
|
|
260
443
|
snapshot(): Promise<ScreenSnapshot>;
|
|
261
444
|
/** Last N lines including scrollback (design §3). */
|
|
262
445
|
lastLines(count: number): Promise<string[]>;
|
|
@@ -270,6 +453,11 @@ export declare class Session implements WaitTarget {
|
|
|
270
453
|
lines: StyledLine[];
|
|
271
454
|
firstVisible: number;
|
|
272
455
|
}>;
|
|
456
|
+
/** Current rendered rows for a waiter evaluation, which already reads synchronously. */
|
|
457
|
+
styledScreenNow(above?: number): {
|
|
458
|
+
lines: StyledLine[];
|
|
459
|
+
firstVisible: number;
|
|
460
|
+
};
|
|
273
461
|
/**
|
|
274
462
|
* The last `count` lines, scrollback included, as drawn, with up to
|
|
275
463
|
* `context` more lines over them; `firstVisible` is where the `count` begin.
|
|
@@ -278,18 +466,27 @@ export declare class Session implements WaitTarget {
|
|
|
278
466
|
lines: StyledLine[];
|
|
279
467
|
firstVisible: number;
|
|
280
468
|
}>;
|
|
281
|
-
waitFor(condition: WaitCondition, options?: WaitOptions): Promise<WaitResult>;
|
|
469
|
+
waitFor(condition: WaitCondition, options?: WaitOptions & WaiterInternals): Promise<WaitResult>;
|
|
282
470
|
summary(): SessionSummary;
|
|
283
471
|
/**
|
|
284
472
|
* Kill the whole process tree (design §3.1). Commands are shell-wrapped, so
|
|
285
473
|
* killing only the direct child (`cmd.exe`) strands the real application,
|
|
286
474
|
* and orphaned agent CLIs keep running and keep spending paid API tokens.
|
|
287
475
|
*
|
|
288
|
-
* Windows: `taskkill /T /F` walks and kills the tree
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* console-
|
|
476
|
+
* Windows: `taskkill /T /F` walks and kills the tree, then `pty.kill()` runs.
|
|
477
|
+
* node-pty's kill ends no process of its own
|
|
478
|
+
* (`listNothingToKill` in `windowsPtyStart.ts`), and it closes the
|
|
479
|
+
* pseudoconsole, which sends CTRL_CLOSE_EVENT to the processes on the
|
|
480
|
+
* console, only while node-pty still holds the terminal: while the program
|
|
481
|
+
* runs. After a tree kill that ended the program, its kill closes nothing,
|
|
482
|
+
* so a process on the session's console outside the killed tree gets no
|
|
483
|
+
* close event. The console host is not in that tree. After this returns, a
|
|
484
|
+
* later list ends the one host created during this spawn's window. This does
|
|
485
|
+
* not wait for that list. The daemon's pseudoconsole handle stays open, and
|
|
486
|
+
* the host is given no CTRL_CLOSE_EVENT. (The design's Job
|
|
487
|
+
* Object hardening needs a native module and is
|
|
488
|
+
* deferred. If the daemon itself dies, its pseudoconsole handles close,
|
|
489
|
+
* which gives console-attached descendants a close signal.)
|
|
293
490
|
*
|
|
294
491
|
* POSIX: the PTY child is the session leader of its own process group, so
|
|
295
492
|
* signalling the negated pid takes the group down.
|
|
@@ -300,9 +497,66 @@ export declare class Session implements WaitTarget {
|
|
|
300
497
|
* could take down something unrelated; on Windows `taskkill` cannot walk a
|
|
301
498
|
* tree from a dead root either. So a grandchild that outlived its parent is
|
|
302
499
|
* left alone rather than guessed at, a residual risk stated in
|
|
303
|
-
* `docs/reference/security-model.md`.
|
|
500
|
+
* `docs/reference/security-model.md`. A session whose program has not been
|
|
501
|
+
* seen to end (`programEnded`) is walked, whether or not the session has
|
|
502
|
+
* ended. node-pty holds such a program's handle while it runs and closes it
|
|
503
|
+
* as it sees the program end, a moment before the code is recorded, so a
|
|
504
|
+
* kill in that moment can reach a pid just freed: the same kind of race
|
|
505
|
+
* every kill has while `taskkill` enumerates the processes. Once the code
|
|
506
|
+
* is recorded the pid is not walked.
|
|
304
507
|
*/
|
|
305
508
|
kill(): Promise<void>;
|
|
509
|
+
/** True from the moment a kill begins, including while it waits for a pid. */
|
|
510
|
+
get isKilled(): boolean;
|
|
511
|
+
private killOnce;
|
|
512
|
+
/**
|
|
513
|
+
* Queue an end of this session's console host, once. The list runs later
|
|
514
|
+
* and is not awaited. With no window there is nothing to end. On any
|
|
515
|
+
* platform but Windows the queue does nothing.
|
|
516
|
+
*/
|
|
517
|
+
private queueConsoleHost;
|
|
518
|
+
/** The failed attempt's own console-host result, after it has been queued. */
|
|
519
|
+
whenConsoleHostSettled(): Promise<boolean>;
|
|
520
|
+
/**
|
|
521
|
+
* The program's pid, waiting for node-pty's deferred program creation:
|
|
522
|
+
* on Windows the pid is 0 from the spawn until the output worker has
|
|
523
|
+
* connected and the program exists, and a start whose connection fails
|
|
524
|
+
* reports an exit instead of a pid, which ends the wait. POSIX reports the
|
|
525
|
+
* pid at the spawn, so nothing is waited for there.
|
|
526
|
+
*/
|
|
527
|
+
private programPid;
|
|
528
|
+
/**
|
|
529
|
+
* The program's pid once node-pty has created it, or null when the session
|
|
530
|
+
* ended before any program existed: a start whose ConPTY output worker
|
|
531
|
+
* never connected, or one Windows refused the program of. The start
|
|
532
|
+
* contract waits here: a session is reported as started only once its
|
|
533
|
+
* program exists, as node-pty 1.1.0's synchronous spawn guaranteed.
|
|
534
|
+
*/
|
|
535
|
+
startedProgramPid(): Promise<number | null>;
|
|
536
|
+
/** Only the pinned node-pty timeout, before a program exists, can be retried. */
|
|
537
|
+
get conptyConnectionTimedOut(): boolean;
|
|
538
|
+
/**
|
|
539
|
+
* What went wrong, for a start that ended before any program existed
|
|
540
|
+
* (`startedProgramPid` returned null): node-pty 1.1.0's own words for a
|
|
541
|
+
* program Windows would not create, with Windows' code; for the connection
|
|
542
|
+
* bound, which 1.1.0 did not have, what actually ran out.
|
|
543
|
+
*/
|
|
544
|
+
startFailure(): string;
|
|
545
|
+
/**
|
|
546
|
+
* End the program of a session that ended with no exit code: node-pty
|
|
547
|
+
* closed its terminal when its output failed, and the program would run on
|
|
548
|
+
* where nobody can read or type into it, for an agent CLI still acting and
|
|
549
|
+
* spending. The same tree kill a kill uses. It runs only after the exit, so
|
|
550
|
+
* the pid is never waited for here; a pid of 0 (no program was created) is
|
|
551
|
+
* skipped by the tree kill. Never rejects.
|
|
552
|
+
*/
|
|
553
|
+
private endProgram;
|
|
554
|
+
/**
|
|
555
|
+
* The OS tree kill of `kill()`, for a program that may still be running:
|
|
556
|
+
* `taskkill /T /F` from a live root on Windows, the process group on POSIX.
|
|
557
|
+
* Never rejects.
|
|
558
|
+
*/
|
|
559
|
+
private killTree;
|
|
306
560
|
/**
|
|
307
561
|
* Cheap liveness probe: signal 0 performs the permission and existence
|
|
308
562
|
* checks without delivering a signal, on Windows as well as POSIX.
|