shellpuppet 0.1.0 → 0.2.1

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.
Files changed (101) hide show
  1. package/README.md +210 -33
  2. package/dist/cli/desktopShortcut.d.ts +22 -0
  3. package/dist/cli/desktopShortcut.js +157 -0
  4. package/dist/cli/desktopShortcut.js.map +1 -0
  5. package/dist/cli/index.js +268 -59
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/client/http.d.ts +74 -3
  8. package/dist/client/http.js +560 -37
  9. package/dist/client/http.js.map +1 -1
  10. package/dist/core/dialogs.d.ts +20 -12
  11. package/dist/core/dialogs.js +31 -19
  12. package/dist/core/dialogs.js.map +1 -1
  13. package/dist/core/manager.d.ts +35 -5
  14. package/dist/core/manager.js +121 -8
  15. package/dist/core/manager.js.map +1 -1
  16. package/dist/core/nativePty.d.ts +9 -5
  17. package/dist/core/nativePty.js +11 -6
  18. package/dist/core/nativePty.js.map +1 -1
  19. package/dist/core/promptDetector.d.ts +37 -3
  20. package/dist/core/promptDetector.js +303 -12
  21. package/dist/core/promptDetector.js.map +1 -1
  22. package/dist/core/reasoning.d.ts +19 -6
  23. package/dist/core/reasoning.js +223 -30
  24. package/dist/core/reasoning.js.map +1 -1
  25. package/dist/core/regexBudget.d.ts +20 -0
  26. package/dist/core/regexBudget.js +25 -1
  27. package/dist/core/regexBudget.js.map +1 -1
  28. package/dist/core/renderer.d.ts +16 -1
  29. package/dist/core/renderer.js +97 -6
  30. package/dist/core/renderer.js.map +1 -1
  31. package/dist/core/selection.d.ts +6 -0
  32. package/dist/core/selection.js +48 -0
  33. package/dist/core/selection.js.map +1 -0
  34. package/dist/core/session.d.ts +267 -13
  35. package/dist/core/session.js +585 -101
  36. package/dist/core/session.js.map +1 -1
  37. package/dist/core/types.d.ts +53 -18
  38. package/dist/core/types.js +30 -6
  39. package/dist/core/types.js.map +1 -1
  40. package/dist/core/waiter.d.ts +12 -4
  41. package/dist/core/waiter.js +63 -70
  42. package/dist/core/waiter.js.map +1 -1
  43. package/dist/core/windowsConsoleHost.d.ts +147 -0
  44. package/dist/core/windowsConsoleHost.js +588 -0
  45. package/dist/core/windowsConsoleHost.js.map +1 -0
  46. package/dist/core/windowsPtyStart.d.ts +100 -29
  47. package/dist/core/windowsPtyStart.js +143 -36
  48. package/dist/core/windowsPtyStart.js.map +1 -1
  49. package/dist/daemon/auth.d.ts +72 -2
  50. package/dist/daemon/auth.js +128 -3
  51. package/dist/daemon/auth.js.map +1 -1
  52. package/dist/daemon/config.d.ts +44 -1
  53. package/dist/daemon/config.js +276 -9
  54. package/dist/daemon/config.js.map +1 -1
  55. package/dist/daemon/folderPicker.d.ts +27 -0
  56. package/dist/daemon/folderPicker.js +115 -0
  57. package/dist/daemon/folderPicker.js.map +1 -0
  58. package/dist/daemon/index.js +20 -19
  59. package/dist/daemon/index.js.map +1 -1
  60. package/dist/daemon/launchProfiles.d.ts +155 -0
  61. package/dist/daemon/launchProfiles.js +554 -0
  62. package/dist/daemon/launchProfiles.js.map +1 -0
  63. package/dist/daemon/liveness.d.ts +1 -1
  64. package/dist/daemon/liveness.js +2 -2
  65. package/dist/daemon/liveness.js.map +1 -1
  66. package/dist/daemon/paths.d.ts +4 -0
  67. package/dist/daemon/paths.js.map +1 -1
  68. package/dist/daemon/restartHold.d.ts +16 -0
  69. package/dist/daemon/restartHold.js +126 -0
  70. package/dist/daemon/restartHold.js.map +1 -0
  71. package/dist/daemon/screenshot.d.ts +58 -1
  72. package/dist/daemon/screenshot.js +172 -26
  73. package/dist/daemon/screenshot.js.map +1 -1
  74. package/dist/daemon/server.d.ts +220 -10
  75. package/dist/daemon/server.js +1975 -205
  76. package/dist/daemon/server.js.map +1 -1
  77. package/dist/daemon/sessionFeed.d.ts +48 -0
  78. package/dist/daemon/sessionFeed.js +101 -0
  79. package/dist/daemon/sessionFeed.js.map +1 -0
  80. package/dist/daemon/viewerLauncher.d.ts +100 -9
  81. package/dist/daemon/viewerLauncher.js +349 -67
  82. package/dist/daemon/viewerLauncher.js.map +1 -1
  83. package/dist/mcp/config.d.ts +7 -14
  84. package/dist/mcp/config.js +10 -21
  85. package/dist/mcp/config.js.map +1 -1
  86. package/dist/mcp/index.js +20 -11
  87. package/dist/mcp/index.js.map +1 -1
  88. package/dist/mcp/tools.d.ts +14 -7
  89. package/dist/mcp/tools.js +161 -60
  90. package/dist/mcp/tools.js.map +1 -1
  91. package/dist/viewer/dashboard-folders.js +20 -0
  92. package/dist/viewer/dashboard-layout.js +52 -0
  93. package/dist/viewer/dashboard.css +67 -0
  94. package/dist/viewer/dashboard.html +44 -0
  95. package/dist/viewer/dashboard.js +1523 -0
  96. package/dist/viewer/icon.ico +0 -0
  97. package/dist/viewer/index.html +12 -7
  98. package/dist/viewer/pane.js +736 -0
  99. package/dist/viewer/viewer.css +18 -7
  100. package/dist/viewer/viewer.js +47 -624
  101. package/package.json +13 -13
@@ -1,29 +1,53 @@
1
1
  /**
2
2
  * A Windows start that fails part-way releases what node-pty had built.
3
3
  *
4
- * node-pty 1.1.0 builds a Windows terminal in steps (`lib/windowsPtyAgent.js`):
5
- * it creates the pseudoconsole, which is a `conhost.exe` and two pipes; it
6
- * starts a worker thread that connects to the output pipe; it opens the input
7
- * pipe; and only then does it create the process. When either of the last two
8
- * steps throws, the constructor gives up without undoing the others. Opening
9
- * the input pipe fails on every start under a sandbox that denies pipe access;
10
- * creating the process fails for a file Windows cannot run, such as a script
11
- * started with `shell: false`. The console host keeps running, and when the
12
- * worker's own connect fails too, nothing listens for the worker's error, so
13
- * it would reach the daemon as an uncaught exception.
4
+ * node-pty 1.2.0-beta.18 builds a Windows terminal in steps
5
+ * (`lib/windowsPtyAgent.js`): it creates the pseudoconsole, which is a
6
+ * `conhost.exe` and two pipes; it starts a worker thread that connects to the
7
+ * output pipe; it arms a five-second timer and records a pending connection;
8
+ * and only then does it open the input pipe. Creating the *program* is
9
+ * deferred: `conptyNative.connect()` runs from the worker's 'ready' callback,
10
+ * so `ConnectNamedPipe` never blocks the event loop (upstream #763), and a
11
+ * connect that fails, late, no longer throws out of the constructor: the
12
+ * agent records an exit code, releases everything it built and reports the
13
+ * failure through `onError`, which the terminal turns into an 'exit' with
14
+ * that code (upstream #934, #935). A worker that errors or exits before it
15
+ * connects is heard the same way.
14
16
  *
15
- * `releaseFailedStarts` wraps node-pty's Windows agent so that a failed start
16
- * listens for the worker's error, ends the worker, destroys both sockets and,
17
- * under ConPTY, closes the pseudoconsole, before the error reaches the caller.
18
- * Windows builds before 18309 get winpty instead, which has no pseudoconsole
19
- * and whose native kill takes other arguments, so there only that step is
20
- * skipped. The wrapper reads node-pty's private fields, so it wraps version
21
- * 1.1.0 only and leaves any other alone. The two pipe handles node-pty keeps
22
- * for the pseudoconsole stay open: its native kill does not close them.
17
+ * What can still throw inside the constructor is the input pipe's open, which
18
+ * fails on every start under a sandbox that denies pipe access, after the
19
+ * worker has started and the deferred connection has been armed. Left alone,
20
+ * a worker that becomes ready afterwards would run the deferred `connect` and
21
+ * spawn the program of a start whose caller was told it failed, and the
22
+ * connection's own failure paths would then reach sockets that were never
23
+ * built. So `releaseFailedStarts` wraps node-pty's Windows agent so that a
24
+ * failed start cancels the deferred connection, gives the worker's error a
25
+ * listener, ends the worker, destroys both sockets and closes the
26
+ * pseudoconsole, before the error reaches the caller. The wrapper reads
27
+ * node-pty's private fields, so it wraps version 1.2.0-beta.18 only and
28
+ * leaves any other alone.
29
+ *
30
+ * The same wrapper makes a kill end no process of its own
31
+ * (`listNothingToKill`): node-pty would look them up by a pid the program may
32
+ * no longer hold. It drops a resize that arrives once node-pty has seen the
33
+ * program end, where node-pty would throw `Cannot resize a pty that has
34
+ * already exited`. node-pty holds a resize asked for before the terminal's
35
+ * first output and runs it from the output socket's first 'data' event, so
36
+ * when the program has ended by then, as it can on a busy daemon, that throw
37
+ * reaches no caller and would be an uncaught exception. Once the program has
38
+ * ended a resize changes nothing the session shows, so dropping the call
39
+ * loses nothing; a resize asked for after the end is refused by `Session.resize`
40
+ * instead, to its caller. Through `listenForTerminalErrors` it hears the
41
+ * errors node-pty leaves unheard on a live terminal's streams: the input
42
+ * socket, which nothing listens to at all, and the output socket, whose own
43
+ * handler rethrows any error but EIO while it is the socket's only 'error'
44
+ * listener. The worker's own errors node-pty now takes itself before it
45
+ * connects; after that they are swallowed, and the listener here keeps them
46
+ * recorded. `recordedExitCode` reads whether node-pty has seen a terminal's
47
+ * program end, where `canReadExitCode` says it can.
23
48
  */
24
49
  /** The fields of node-pty's `WindowsPtyAgent` that a failed start leaves set. */
25
50
  export interface HalfBuiltAgent {
26
- _useConpty?: boolean;
27
51
  _pty?: number;
28
52
  _useConptyDll?: boolean;
29
53
  _ptyNative?: {
@@ -42,9 +66,24 @@ export interface HalfBuiltAgent {
42
66
  terminate(): unknown;
43
67
  };
44
68
  };
69
+ /** node-pty's deferred `connect`; undefined once it has run, failed or been cancelled. */
70
+ _pendingPtyInfo?: unknown;
71
+ /** The timer that fails the connection when the output worker never connects. */
72
+ _connectionTimeout?: ReturnType<typeof setTimeout> | undefined;
73
+ }
74
+ /** The fields of node-pty's agent that its resize reads. */
75
+ interface ResizingAgent {
76
+ /** Set by node-pty's exit thread as it sees the terminal's program end. */
77
+ _exitCode?: number;
78
+ }
79
+ /** The methods of node-pty's agent that the wrapper replaces. */
80
+ interface AgentPrototype {
81
+ /** Where a kill takes its list of pids from. */
82
+ _getConsoleProcessList?: () => Promise<number[]>;
83
+ resize?: (this: ResizingAgent, cols: number, rows: number) => void;
45
84
  }
46
85
  type AgentConstructor = ((this: HalfBuiltAgent, ...args: unknown[]) => void) & {
47
- prototype: object;
86
+ prototype: AgentPrototype;
48
87
  releasesFailedStarts?: true;
49
88
  };
50
89
  /** The shape of node-pty's `lib/windowsPtyAgent.js` exports that matter here. */
@@ -53,8 +92,10 @@ export interface AgentModule {
53
92
  }
54
93
  /**
55
94
  * Replace the module's `WindowsPtyAgent` with one that releases a failed
56
- * start. node-pty looks the constructor up on this module object each time it
57
- * builds a terminal, so the replacement takes effect for every later start.
95
+ * start, whose kill ends no process of its own (`listNothingToKill`) and whose
96
+ * resize is dropped once node-pty has seen the program end. node-pty looks the
97
+ * constructor up on this module object each time it builds a terminal, so the
98
+ * replacement takes effect for every later start.
58
99
  */
59
100
  export declare function wrapWindowsPtyAgent(agents: AgentModule): void;
60
101
  /**
@@ -63,23 +104,53 @@ export declare function wrapWindowsPtyAgent(agents: AgentModule): void;
63
104
  */
64
105
  export declare function releaseFailedStarts(): boolean;
65
106
  /**
66
- * Take the errors of the two streams of a live Windows terminal that node-pty
67
- * 1.1.0 listens for nowhere, each of which would otherwise be an uncaught
107
+ * Take the errors of the streams of a live Windows terminal that node-pty
108
+ * 1.2.0-beta.18 leaves unheard, each of which would otherwise be an uncaught
68
109
  * exception, on which the daemon shuts down with every session.
69
110
  *
70
111
  * - `input`: input reaches the pseudoconsole through a socket on its input
71
- * pipe (`lib/windowsPtyAgent.js`). Once the console host has closed its end,
72
- * a write the pipe refuses (`write EAGAIN`) is emitted as an 'error'; a
73
- * viewer's focus report racing the session's exit does it.
112
+ * pipe (`lib/windowsPtyAgent.js`), and nothing listens for its errors.
113
+ * Once the console host has closed its end, a write the pipe refuses
114
+ * (`write EAGAIN`) is emitted as an 'error'; a viewer's focus report racing
115
+ * the session's exit does it.
74
116
  * - `output`: a worker thread copies the output pipe to a local socket
75
117
  * (`lib/worker/conoutSocketWorker.js`), and an error thrown there becomes
76
- * the worker's 'error'.
118
+ * the worker's 'error'. node-pty's own listener takes it only while the
119
+ * worker has not yet connected; after that it is swallowed, so the listener
120
+ * here is what records it. The terminal reads that socket, and listens on
121
+ * it only once it has connected; its handler then throws any error but EIO
122
+ * while it is the socket's only 'error' listener (`lib/windowsTerminal.js`).
123
+ * The terminal's own `on('error')`, which its typings leave out, adds the
124
+ * second.
77
125
  *
78
126
  * With the listener the stream fails as before and the daemon and its other
79
127
  * sessions carry on. False when the installed node-pty is not the wrapped
80
- * version or the terminal has neither stream.
128
+ * version or the terminal has none of these.
81
129
  */
82
130
  export declare function listenForTerminalErrors(pty: unknown, listener: (error: Error, stream: 'input' | 'output') => void): boolean;
131
+ /**
132
+ * Whether node-pty records when this Windows terminal's program ends, so that
133
+ * `recordedExitCode` can say: node-pty 1.2.0-beta.18, which is ConPTY only
134
+ * and whose exit thread records the program's code as it sees the program
135
+ * end. Not with another node-pty version.
136
+ */
137
+ export declare function canReadExitCode(pty: unknown): boolean;
138
+ /**
139
+ * The exit code node-pty has recorded for a Windows terminal's program, or
140
+ * undefined while it has recorded none: while the program runs, and wherever
141
+ * `canReadExitCode` is false. node-pty holds the program's handle while the
142
+ * program runs and closes it as it sees the program end, a moment before the
143
+ * code is recorded here (`src/win/conpty.cc`). A kill in that moment can reach
144
+ * a pid just freed: the same kind of race every kill has while `taskkill`
145
+ * enumerates the processes. A connection that failed records a code too, with
146
+ * nothing ever spawned: no pid is walked for it.
147
+ */
148
+ export declare function recordedExitCode(pty: unknown): number | undefined;
149
+ /** node-pty exposes no error code for this bound in beta.18. Its agent's
150
+ * error event is the only way to distinguish it from other pid-zero exits.
151
+ * The exact text is pinned to the installed release, not a public API.
152
+ */
153
+ export declare function observeConptyStartError(pty: unknown, listener: (error: Error) => void): void;
83
154
  /**
84
155
  * Wrap the agent module only for the node-pty version whose private fields
85
156
  * `release` reads. Another version is left alone and its module not loaded:
@@ -1,33 +1,60 @@
1
1
  /**
2
2
  * A Windows start that fails part-way releases what node-pty had built.
3
3
  *
4
- * node-pty 1.1.0 builds a Windows terminal in steps (`lib/windowsPtyAgent.js`):
5
- * it creates the pseudoconsole, which is a `conhost.exe` and two pipes; it
6
- * starts a worker thread that connects to the output pipe; it opens the input
7
- * pipe; and only then does it create the process. When either of the last two
8
- * steps throws, the constructor gives up without undoing the others. Opening
9
- * the input pipe fails on every start under a sandbox that denies pipe access;
10
- * creating the process fails for a file Windows cannot run, such as a script
11
- * started with `shell: false`. The console host keeps running, and when the
12
- * worker's own connect fails too, nothing listens for the worker's error, so
13
- * it would reach the daemon as an uncaught exception.
4
+ * node-pty 1.2.0-beta.18 builds a Windows terminal in steps
5
+ * (`lib/windowsPtyAgent.js`): it creates the pseudoconsole, which is a
6
+ * `conhost.exe` and two pipes; it starts a worker thread that connects to the
7
+ * output pipe; it arms a five-second timer and records a pending connection;
8
+ * and only then does it open the input pipe. Creating the *program* is
9
+ * deferred: `conptyNative.connect()` runs from the worker's 'ready' callback,
10
+ * so `ConnectNamedPipe` never blocks the event loop (upstream #763), and a
11
+ * connect that fails, late, no longer throws out of the constructor: the
12
+ * agent records an exit code, releases everything it built and reports the
13
+ * failure through `onError`, which the terminal turns into an 'exit' with
14
+ * that code (upstream #934, #935). A worker that errors or exits before it
15
+ * connects is heard the same way.
14
16
  *
15
- * `releaseFailedStarts` wraps node-pty's Windows agent so that a failed start
16
- * listens for the worker's error, ends the worker, destroys both sockets and,
17
- * under ConPTY, closes the pseudoconsole, before the error reaches the caller.
18
- * Windows builds before 18309 get winpty instead, which has no pseudoconsole
19
- * and whose native kill takes other arguments, so there only that step is
20
- * skipped. The wrapper reads node-pty's private fields, so it wraps version
21
- * 1.1.0 only and leaves any other alone. The two pipe handles node-pty keeps
22
- * for the pseudoconsole stay open: its native kill does not close them.
17
+ * What can still throw inside the constructor is the input pipe's open, which
18
+ * fails on every start under a sandbox that denies pipe access, after the
19
+ * worker has started and the deferred connection has been armed. Left alone,
20
+ * a worker that becomes ready afterwards would run the deferred `connect` and
21
+ * spawn the program of a start whose caller was told it failed, and the
22
+ * connection's own failure paths would then reach sockets that were never
23
+ * built. So `releaseFailedStarts` wraps node-pty's Windows agent so that a
24
+ * failed start cancels the deferred connection, gives the worker's error a
25
+ * listener, ends the worker, destroys both sockets and closes the
26
+ * pseudoconsole, before the error reaches the caller. The wrapper reads
27
+ * node-pty's private fields, so it wraps version 1.2.0-beta.18 only and
28
+ * leaves any other alone.
29
+ *
30
+ * The same wrapper makes a kill end no process of its own
31
+ * (`listNothingToKill`): node-pty would look them up by a pid the program may
32
+ * no longer hold. It drops a resize that arrives once node-pty has seen the
33
+ * program end, where node-pty would throw `Cannot resize a pty that has
34
+ * already exited`. node-pty holds a resize asked for before the terminal's
35
+ * first output and runs it from the output socket's first 'data' event, so
36
+ * when the program has ended by then, as it can on a busy daemon, that throw
37
+ * reaches no caller and would be an uncaught exception. Once the program has
38
+ * ended a resize changes nothing the session shows, so dropping the call
39
+ * loses nothing; a resize asked for after the end is refused by `Session.resize`
40
+ * instead, to its caller. Through `listenForTerminalErrors` it hears the
41
+ * errors node-pty leaves unheard on a live terminal's streams: the input
42
+ * socket, which nothing listens to at all, and the output socket, whose own
43
+ * handler rethrows any error but EIO while it is the socket's only 'error'
44
+ * listener. The worker's own errors node-pty now takes itself before it
45
+ * connects; after that they are swallowed, and the listener here keeps them
46
+ * recorded. `recordedExitCode` reads whether node-pty has seen a terminal's
47
+ * program end, where `canReadExitCode` says it can.
23
48
  */
24
49
  import { createRequire } from 'node:module';
25
50
  /** The node-pty version whose private fields this relies on. */
26
- const WRAPPED_VERSION = '1.1.0';
51
+ const WRAPPED_VERSION = '1.2.0-beta.18';
27
52
  /**
28
53
  * Replace the module's `WindowsPtyAgent` with one that releases a failed
29
- * start. node-pty looks the constructor up on this module object each time it
30
- * builds a terminal, so the replacement takes effect for every later start.
54
+ * start, whose kill ends no process of its own (`listNothingToKill`) and whose
55
+ * resize is dropped once node-pty has seen the program end. node-pty looks the
56
+ * constructor up on this module object each time it builds a terminal, so the
57
+ * replacement takes effect for every later start.
31
58
  */
32
59
  export function wrapWindowsPtyAgent(agents) {
33
60
  const Original = agents.WindowsPtyAgent;
@@ -47,9 +74,52 @@ export function wrapWindowsPtyAgent(agents) {
47
74
  Wrapped.prototype = Original.prototype;
48
75
  Wrapped.releasesFailedStarts = true;
49
76
  agents.WindowsPtyAgent = Wrapped;
77
+ // node-pty's kill and resize look their methods up on the prototype, which
78
+ // the wrapped constructor shares, so every terminal from here on uses these.
79
+ if (typeof Original.prototype._getConsoleProcessList === 'function') {
80
+ Original.prototype._getConsoleProcessList = listNothingToKill;
81
+ }
82
+ const resize = Original.prototype.resize;
83
+ if (typeof resize === 'function') {
84
+ Original.prototype.resize = function resizeWhileRunning(cols, rows) {
85
+ if (this._exitCode !== undefined)
86
+ return;
87
+ resize.call(this, cols, rows);
88
+ };
89
+ }
90
+ }
91
+ /**
92
+ * The pids node-pty 1.2.0-beta.18's kill ends one by one
93
+ * (`lib/windowsPtyAgent.js`): none, found without starting anything.
94
+ *
95
+ * node-pty forks a helper that attaches to the console of whichever process
96
+ * now holds the program's pid and lists the processes on it, and with no
97
+ * answer waits five seconds and returns that pid itself; it then kills every
98
+ * pid in the list. It lists nothing while the deferred connection has not
99
+ * run, but once the program has started and ended, Windows is free to give
100
+ * its pid to another process, so either way the kill can end processes that
101
+ * are not the session's, as many as a whole console of them.
102
+ *
103
+ * A session's processes are ended by its tree kill instead (`session.ts`):
104
+ * every kill of a session whose program has not been seen to end runs
105
+ * `taskkill /T /F` from the program's pid, before node-pty's kill, and a
106
+ * program that has ended has nothing left for the helper to find. This
107
+ * replaces `_getConsoleProcessList` only, which the kill calls. node-pty's
108
+ * kill still closes the pseudoconsole while it holds the terminal, which it
109
+ * does until the program ends, so a program a tree kill left running is sent
110
+ * CTRL_CLOSE_EVENT with the rest of its console.
111
+ */
112
+ function listNothingToKill() {
113
+ return Promise.resolve([]);
50
114
  }
51
115
  /** Undo what a failed start built, as far as node-pty lets us. */
52
116
  function release(agent) {
117
+ // Cancel the deferred connection first, so a worker that becomes ready after
118
+ // this cannot run it and spawn the program of a start that already failed,
119
+ // and the five-second timer cannot fire into a half-built terminal either.
120
+ agent._pendingPtyInfo = undefined;
121
+ if (agent._connectionTimeout !== undefined)
122
+ clearTimeout(agent._connectionTimeout);
53
123
  const worker = agent._conoutSocketWorker?._worker;
54
124
  if (worker !== undefined) {
55
125
  // The worker's connect may still fail after this, and an 'error' with no
@@ -57,15 +127,14 @@ function release(agent) {
57
127
  worker.on('error', () => undefined);
58
128
  void worker.terminate();
59
129
  }
60
- // The input socket exists only when the process could not be created.
130
+ // The input socket exists only when the input pipe could be opened.
61
131
  agent._inSocket?.destroy();
62
132
  // A 'ready' from the worker arriving after this would reconnect the output
63
133
  // socket (connecting revives a destroyed socket), and its error would have
64
134
  // no listener either.
65
135
  agent._outSocket?.on('error', () => undefined);
66
136
  agent._outSocket?.destroy();
67
- // Only ConPTY has a pseudoconsole to close; winpty's kill takes a pid.
68
- if (agent._useConpty === true && agent._pty !== undefined && agent._ptyNative !== undefined) {
137
+ if (agent._pty !== undefined && agent._ptyNative !== undefined) {
69
138
  try {
70
139
  agent._ptyNative.kill(agent._pty, agent._useConptyDll ?? false);
71
140
  }
@@ -88,31 +157,69 @@ export function releaseFailedStarts() {
88
157
  return wrapped;
89
158
  }
90
159
  /**
91
- * Take the errors of the two streams of a live Windows terminal that node-pty
92
- * 1.1.0 listens for nowhere, each of which would otherwise be an uncaught
160
+ * Take the errors of the streams of a live Windows terminal that node-pty
161
+ * 1.2.0-beta.18 leaves unheard, each of which would otherwise be an uncaught
93
162
  * exception, on which the daemon shuts down with every session.
94
163
  *
95
164
  * - `input`: input reaches the pseudoconsole through a socket on its input
96
- * pipe (`lib/windowsPtyAgent.js`). Once the console host has closed its end,
97
- * a write the pipe refuses (`write EAGAIN`) is emitted as an 'error'; a
98
- * viewer's focus report racing the session's exit does it.
165
+ * pipe (`lib/windowsPtyAgent.js`), and nothing listens for its errors.
166
+ * Once the console host has closed its end, a write the pipe refuses
167
+ * (`write EAGAIN`) is emitted as an 'error'; a viewer's focus report racing
168
+ * the session's exit does it.
99
169
  * - `output`: a worker thread copies the output pipe to a local socket
100
170
  * (`lib/worker/conoutSocketWorker.js`), and an error thrown there becomes
101
- * the worker's 'error'.
171
+ * the worker's 'error'. node-pty's own listener takes it only while the
172
+ * worker has not yet connected; after that it is swallowed, so the listener
173
+ * here is what records it. The terminal reads that socket, and listens on
174
+ * it only once it has connected; its handler then throws any error but EIO
175
+ * while it is the socket's only 'error' listener (`lib/windowsTerminal.js`).
176
+ * The terminal's own `on('error')`, which its typings leave out, adds the
177
+ * second.
102
178
  *
103
179
  * With the listener the stream fails as before and the daemon and its other
104
180
  * sessions carry on. False when the installed node-pty is not the wrapped
105
- * version or the terminal has neither stream.
181
+ * version or the terminal has none of these.
106
182
  */
107
183
  export function listenForTerminalErrors(pty, listener) {
108
184
  if (!wrapped)
109
185
  return false;
110
- const agent = pty._agent;
111
- const input = agent?.inSocket;
112
- const output = agent?._conoutSocketWorker?._worker;
186
+ const terminal = pty;
187
+ const input = terminal._agent?.inSocket;
188
+ const worker = terminal._agent?._conoutSocketWorker?._worker;
113
189
  input?.on('error', (error) => listener(error, 'input'));
114
- output?.on('error', (error) => listener(error, 'output'));
115
- return input !== undefined || output !== undefined;
190
+ worker?.on('error', (error) => listener(error, 'output'));
191
+ terminal.on?.('error', (error) => listener(error, 'output'));
192
+ return input !== undefined || worker !== undefined || terminal.on !== undefined;
193
+ }
194
+ /**
195
+ * Whether node-pty records when this Windows terminal's program ends, so that
196
+ * `recordedExitCode` can say: node-pty 1.2.0-beta.18, which is ConPTY only
197
+ * and whose exit thread records the program's code as it sees the program
198
+ * end. Not with another node-pty version.
199
+ */
200
+ export function canReadExitCode(pty) {
201
+ return wrapped && pty._agent !== undefined;
202
+ }
203
+ /**
204
+ * The exit code node-pty has recorded for a Windows terminal's program, or
205
+ * undefined while it has recorded none: while the program runs, and wherever
206
+ * `canReadExitCode` is false. node-pty holds the program's handle while the
207
+ * program runs and closes it as it sees the program end, a moment before the
208
+ * code is recorded here (`src/win/conpty.cc`). A kill in that moment can reach
209
+ * a pid just freed: the same kind of race every kill has while `taskkill`
210
+ * enumerates the processes. A connection that failed records a code too, with
211
+ * nothing ever spawned: no pid is walked for it.
212
+ */
213
+ export function recordedExitCode(pty) {
214
+ return canReadExitCode(pty) ? pty._agent?.exitCode : undefined;
215
+ }
216
+ /** node-pty exposes no error code for this bound in beta.18. Its agent's
217
+ * error event is the only way to distinguish it from other pid-zero exits.
218
+ * The exact text is pinned to the installed release, not a public API.
219
+ */
220
+ export function observeConptyStartError(pty, listener) {
221
+ const agent = pty._agent;
222
+ agent?.onError?.(listener);
116
223
  }
117
224
  /**
118
225
  * Wrap the agent module only for the node-pty version whose private fields
@@ -1 +1 @@
1
- {"version":3,"file":"windowsPtyStart.js","sourceRoot":"","sources":["../../src/core/windowsPtyStart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,gEAAgE;AAChE,MAAM,eAAe,GAAG,OAAO,CAAC;AAyBhC;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAmB;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,eAAe,CAAC;IACxC,IAAI,QAAQ,CAAC,oBAAoB,KAAK,IAAI;QAAE,OAAO;IAEnD,MAAM,OAAO,GAAG,SAAS,eAAe,CAAgB,GAAG,IAAe;QACxE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAmB,CAAC;QAClE,IAAI,CAAC;YACH,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAgC,CAAC;IACjC,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;IACvC,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IACpC,MAAM,CAAC,eAAe,GAAG,OAAO,CAAC;AACnC,CAAC;AAED,kEAAkE;AAClE,SAAS,OAAO,CAAC,KAAqB;IACpC,MAAM,MAAM,GAAG,KAAK,CAAC,mBAAmB,EAAE,OAAO,CAAC;IAClD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,yEAAyE;Q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AE,QAAgC;IACpF,MAAM,KAAK,GAAI,GAAgF,CAAC,MAAM,CAAC;IACvG,KAAK,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe,EAAE,IAAuB;IACzE,IAAI,OAAO,KAAK,eAAe;QAAE,OAAO,KAAK,CAAC;IAC9C,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Token generation and verification (design §4.1).
3
3
  *
4
- * Three credentials, deliberately different in kind:
4
+ * Five credentials, deliberately different in kind:
5
5
  *
6
6
  * - **Client token**: full API access; generated per daemon run, written to
7
7
  * `daemon.json`, read by same-user clients. Rotates on restart. Travels in an
@@ -25,6 +25,15 @@
25
25
  * becomes: it is enforced by the daemon, not by the viewer page. The page's
26
26
  * own toggle stops that tab sending keystrokes and is a convenience; a
27
27
  * read-only credential means the daemon will not accept them.
28
+ * - **Dashboard grant**: the `dt` in a dashboard URL. One use, short life,
29
+ * not a session credential, and it cannot open a stream. Its only use is
30
+ * to be exchanged, once, at `GET /dashboard` for the cookie below. The
31
+ * daemon mints it and never returns it to the caller.
32
+ * - **Dashboard credential**: what that grant becomes. One `HttpOnly` cookie
33
+ * for the whole dashboard, plus a ring of the eight newest per-document
34
+ * proofs. A second redemption replaces the credential and drops its proofs.
35
+ * The cookie opens a session stream when the upgrade carries a live proof
36
+ * as the `sp-csrf` subprotocol. A viewer cookie is not this credential.
28
37
  */
29
38
  export type AuthResult = {
30
39
  kind: 'client';
@@ -43,6 +52,8 @@ export type AuthResult = {
43
52
  * transcript is inert. Expired is not a dead end: mint another.
44
53
  */
45
54
  export declare const VIEWER_GRANT_TTL_MS: number;
55
+ /** How many per-document proofs the current dashboard credential keeps. */
56
+ export declare const DASHBOARD_PROOF_RING = 8;
46
57
  export interface RedeemedGrant {
47
58
  /** The value to put in the viewer's cookie. */
48
59
  streamToken: string;
@@ -50,10 +61,15 @@ export interface RedeemedGrant {
50
61
  readOnly: boolean;
51
62
  }
52
63
  export declare function generateToken(): string;
64
+ /** Constant-time comparison over sha256 digests, so length never leaks. */
65
+ export declare function tokensEqual(a: string, b: string): boolean;
53
66
  export declare class TokenStore {
54
67
  private readonly clientToken;
55
68
  private readonly grants;
56
69
  private readonly streams;
70
+ private readonly dashboardGrants;
71
+ /** The one live dashboard credential. A new redemption replaces it. */
72
+ private dashboardCredential;
57
73
  constructor(clientToken?: string);
58
74
  get token(): string;
59
75
  /**
@@ -88,13 +104,51 @@ export declare class TokenStore {
88
104
  revokeViewerGrant(grant: string): void;
89
105
  /** Drop every viewer grant and credential scoped to a session (on kill/exit cleanup). */
90
106
  revokeViewerTokens(sessionId: string): void;
107
+ /**
108
+ * Mint a one-use dashboard grant. It is not a session credential. The HTTP
109
+ * client cannot choose its lifetime: only a test passes `ttlMs`.
110
+ */
111
+ mintDashboardGrant(options?: {
112
+ ttlMs?: number;
113
+ now?: number;
114
+ }): string;
115
+ /**
116
+ * Exchange a dashboard grant for the one dashboard credential, consuming
117
+ * the grant. Returns null for an unknown, already-redeemed or expired
118
+ * grant. The three cases are deliberately indistinguishable. A successful
119
+ * redemption replaces whatever credential was current and drops its proofs.
120
+ * A failed redemption leaves the current credential alone.
121
+ */
122
+ redeemDashboardGrant(presented: string | undefined | null, now?: number): {
123
+ token: string;
124
+ } | null;
125
+ /** The dashboard cookie value, or false when nothing current matches. */
126
+ verifyDashboardToken(presented: string | undefined | null): boolean;
127
+ /**
128
+ * Take back a dashboard grant and the credential it became. An unspent
129
+ * grant is deleted. A spent one drops the credential and its proofs.
130
+ */
131
+ revokeDashboardGrant(grant: string): void;
132
+ /**
133
+ * A fresh proof for the current credential, or null when there is none.
134
+ * The ninth proof drops the oldest.
135
+ */
136
+ issueDashboardProof(): string | null;
137
+ /**
138
+ * Whether `presented` is one of the proofs still in the ring. The compare
139
+ * hashes both strings, so a wrong proof of the same length takes the same
140
+ * path as a right one.
141
+ */
142
+ acceptsDashboardProof(presented: string | undefined | null): boolean;
91
143
  /**
92
144
  * Verify a bearer token. Only the client token authenticates this way:
93
145
  * viewer credentials are cookie-borne and session-scoped, and are checked
94
- * with `verifyStreamToken`.
146
+ * with `verifyStreamToken`. The dashboard cookie is checked with
147
+ * `verifyDashboardToken`.
95
148
  */
96
149
  verify(presented: string | undefined | null): AuthResult;
97
150
  private pruneExpired;
151
+ private pruneExpiredDashboard;
98
152
  }
99
153
  /** Extract a bearer token from an Authorization header value. */
100
154
  export declare function bearerToken(header: string | undefined): string | null;
@@ -125,3 +179,19 @@ export declare function cookieValue(header: string | undefined, name: string): s
125
179
  * `Secure` cookie would simply never be stored.
126
180
  */
127
181
  export declare function viewerCookie(sessionId: string, streamToken: string): string;
182
+ /**
183
+ * The dashboard's cookie name. One credential for the dashboard, so one
184
+ * path: `/`. Cookies ignore ports, and `cookieValues` tries every value.
185
+ */
186
+ export declare const DASHBOARD_COOKIE = "sp_dash";
187
+ /**
188
+ * The `Set-Cookie` value delivering the dashboard credential.
189
+ *
190
+ * `HttpOnly` keeps it out of `document.cookie`. `SameSite=Strict` stops any
191
+ * other site's navigation carrying it. No `Max-Age`: it dies with the
192
+ * browsing session. No `Secure`: the daemon is loopback-only http, and a
193
+ * `Secure` cookie would never be stored. No `Domain`: it stays host-only.
194
+ */
195
+ export declare function dashboardCookie(token: string): string;
196
+ /** The proof inside `sp-csrf.<64 hex>`, or null when the protocol is not that. */
197
+ export declare function dashboardProofFromProtocol(protocol: string): string | null;