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.
Files changed (95) hide show
  1. package/README.md +191 -32
  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 +205 -52
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/client/http.d.ts +62 -1
  8. package/dist/client/http.js +388 -32
  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 +266 -12
  35. package/dist/core/session.js +583 -99
  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/paths.d.ts +2 -0
  64. package/dist/daemon/paths.js.map +1 -1
  65. package/dist/daemon/screenshot.d.ts +58 -1
  66. package/dist/daemon/screenshot.js +172 -26
  67. package/dist/daemon/screenshot.js.map +1 -1
  68. package/dist/daemon/server.d.ts +219 -10
  69. package/dist/daemon/server.js +1970 -203
  70. package/dist/daemon/server.js.map +1 -1
  71. package/dist/daemon/sessionFeed.d.ts +48 -0
  72. package/dist/daemon/sessionFeed.js +101 -0
  73. package/dist/daemon/sessionFeed.js.map +1 -0
  74. package/dist/daemon/viewerLauncher.d.ts +100 -9
  75. package/dist/daemon/viewerLauncher.js +349 -67
  76. package/dist/daemon/viewerLauncher.js.map +1 -1
  77. package/dist/mcp/config.d.ts +7 -14
  78. package/dist/mcp/config.js +10 -21
  79. package/dist/mcp/config.js.map +1 -1
  80. package/dist/mcp/index.js +20 -11
  81. package/dist/mcp/index.js.map +1 -1
  82. package/dist/mcp/tools.d.ts +14 -7
  83. package/dist/mcp/tools.js +161 -60
  84. package/dist/mcp/tools.js.map +1 -1
  85. package/dist/viewer/dashboard-folders.js +20 -0
  86. package/dist/viewer/dashboard-layout.js +52 -0
  87. package/dist/viewer/dashboard.css +67 -0
  88. package/dist/viewer/dashboard.html +44 -0
  89. package/dist/viewer/dashboard.js +1518 -0
  90. package/dist/viewer/icon.ico +0 -0
  91. package/dist/viewer/index.html +12 -7
  92. package/dist/viewer/pane.js +736 -0
  93. package/dist/viewer/viewer.css +18 -7
  94. package/dist/viewer/viewer.js +47 -624
  95. package/package.json +13 -13
@@ -0,0 +1,147 @@
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
+ /** Windows only. Sessions queue a console host only when this is set. */
35
+ export declare const TRACK_WINDOWS_CONSOLE_HOST: boolean;
36
+ /** Sessions that end within this of each other share one process list. */
37
+ export declare const CONSOLE_HOST_COALESCE_MS = 300;
38
+ /**
39
+ * How long one list may take. A CIM query of one parent's children takes
40
+ * about ten seconds on this machine, cold or warm.
41
+ */
42
+ export declare const CONSOLE_HOST_QUERY_TIMEOUT_MS = 45000;
43
+ /** A Windows clock tick can be 15.625 ms; protect neighbouring live windows. */
44
+ export declare const CONSOLE_HOST_GUARD_MS = 16;
45
+ /** Limits synchronous matching even when a daemon has many sessions. */
46
+ export declare const CONSOLE_HOST_MAX_CANDIDATES = 1024;
47
+ export declare const CONSOLE_HOST_MAX_WINDOWS = 256;
48
+ export declare const CONSOLE_HOST_MAX_ATTEMPTS = 3;
49
+ /** A console host as one list returned it. Creation time is Unix milliseconds. */
50
+ export interface ConsoleHostProcess {
51
+ pid: number;
52
+ parentPid: number;
53
+ name: string;
54
+ creationTime: number;
55
+ }
56
+ /** Times taken immediately before and after the synchronous spawn. */
57
+ export interface SpawnWindow {
58
+ t0: number;
59
+ t1: number;
60
+ }
61
+ export interface KnownConsoleHostWindow {
62
+ id: string;
63
+ window: SpawnWindow;
64
+ }
65
+ /** What one ended session asks the shared list to do. */
66
+ export interface QueuedConsoleHost {
67
+ id: string;
68
+ window: SpawnWindow;
69
+ log: (level: 'info' | 'warn', message: string, meta: Record<string, unknown>) => void;
70
+ /** True once this host was ended or found gone; false if the queue gave up. */
71
+ onSettled?: (ended: boolean) => void;
72
+ }
73
+ export interface ConsoleHostQueue {
74
+ push(item: QueuedConsoleHost): void;
75
+ /** Resolves when every queued batch has listed and its ends have finished. */
76
+ whenSettled(): Promise<void>;
77
+ }
78
+ /** Why a list could not be used. A timeout is its own reason. */
79
+ export declare function queryFailureReason(error: unknown): string;
80
+ /** One attributed host handed to a batch end. `error === null` means it was ended. */
81
+ export interface ConsoleHostEndResult {
82
+ pid: number;
83
+ error: unknown;
84
+ }
85
+ export interface ConsoleHostQueueOptions {
86
+ parentPid: number;
87
+ list: (parentPid: number) => Promise<readonly ConsoleHostProcess[]>;
88
+ /**
89
+ * End one attributed host. May return a promise: the queue settles only
90
+ * after it finishes. Not called when `endBatch` is set.
91
+ */
92
+ endProcess?: (pid: number, host?: ConsoleHostProcess) => void | Promise<void>;
93
+ /**
94
+ * End every host this batch attributed, in one call. The queue settles
95
+ * only after the promise finishes. `ESRCH` finishes that item; any other
96
+ * error retries it.
97
+ */
98
+ endBatch?: (items: readonly {
99
+ pid: number;
100
+ host: ConsoleHostProcess;
101
+ }[]) => Promise<readonly ConsoleHostEndResult[]>;
102
+ coalesceMs?: number;
103
+ /** Includes live sessions and ended sessions awaiting a retry. */
104
+ knownWindows?: () => readonly KnownConsoleHostWindow[];
105
+ /** Called when an ended session is finished, including a bounded leak. */
106
+ resolved?: (id: string) => void;
107
+ }
108
+ /**
109
+ * Queue ended sessions and list once for each batch. A host is ended only
110
+ * after one-to-one attribution has chosen that process. The queue settles
111
+ * only once those ends have finished.
112
+ */
113
+ export declare function createConsoleHostQueue(options: ConsoleHostQueueOptions): ConsoleHostQueue;
114
+ /** One CIM query: console hosts whose parent is `parentPid`. No compiled code. */
115
+ export declare function listConsoleHosts(parentPid: number, timeoutMs?: number): Promise<ConsoleHostProcess[]>;
116
+ /**
117
+ * End every listed host in one asynchronous PowerShell. Each pid was read
118
+ * from a process list, so by the time this runs Windows may have given it to
119
+ * another process. A bare `process.kill` would then reach that process,
120
+ * including one on another console.
121
+ */
122
+ export declare function endConsoleHostProcesses(targets: readonly {
123
+ pid: number;
124
+ creationTime?: number;
125
+ }[]): Promise<readonly ConsoleHostEndResult[]>;
126
+ /**
127
+ * End `pid` only when it is still the console host listed at `creationTime`.
128
+ * The time is required: without it the call is refused and nothing is opened.
129
+ * Reads that process's handle first, which opens and caches it, then checks
130
+ * the name and the start time, and kills through the cached handle. A pid
131
+ * reused after the open is not the one killed, and the open handle keeps
132
+ * Windows from reusing the pid until it is closed. Rejects with `ESRCH` when
133
+ * the pid is gone, the handle cannot be opened, or the process is no longer
134
+ * that host, and the caller leaves that process running. The PowerShell is
135
+ * asynchronous.
136
+ */
137
+ export declare function endConsoleHostProcess(pid: number, creationTime?: number): Promise<void>;
138
+ /** Keep live and unresolved windows available while another batch lists. */
139
+ export declare function registerConsoleHostWindow(id: string, window: SpawnWindow, platform?: NodeJS.Platform): void;
140
+ /**
141
+ * Resolves when the daemon's queue has finished the batches already pushed.
142
+ * Nothing is listed at the call. Tests wait here instead of polling; the
143
+ * daemon does not.
144
+ */
145
+ export declare function whenConsoleHostBatchSettled(): Promise<void>;
146
+ /** Queue one ended session. The list runs later, off the caller's stack. */
147
+ export declare function queueConsoleHostEnd(item: QueuedConsoleHost): void;