@wonderwhy-er/desktop-commander 0.2.51 → 0.3.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 +14 -24
- package/dist/command-manager.d.ts +7 -2
- package/dist/command-manager.js +16 -11
- package/dist/config-manager.d.ts +55 -3
- package/dist/config-manager.js +329 -87
- package/dist/config-recovery.d.ts +28 -0
- package/dist/config-recovery.js +81 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +9 -0
- package/dist/handlers/filesystem-handlers.d.ts +1 -1
- package/dist/handlers/filesystem-handlers.js +26 -16
- package/dist/handlers/search-answers.d.ts +58 -0
- package/dist/handlers/search-answers.js +172 -0
- package/dist/handlers/search-handlers.js +4 -92
- package/dist/index.js +14 -7
- package/dist/npm-scripts/remote.js +47 -4
- package/dist/remote-device/desktop-commander-integration.d.ts +21 -0
- package/dist/remote-device/desktop-commander-integration.js +121 -40
- package/dist/remote-device/device-authenticator.d.ts +13 -1
- package/dist/remote-device/device-authenticator.js +87 -47
- package/dist/remote-device/device.d.ts +14 -0
- package/dist/remote-device/device.js +244 -51
- package/dist/remote-device/diagnostics/device-log.d.ts +63 -0
- package/dist/remote-device/diagnostics/device-log.js +219 -0
- package/dist/remote-device/diagnostics/redact.d.ts +1 -0
- package/dist/remote-device/diagnostics/redact.js +76 -0
- package/dist/remote-device/diagnostics/report.d.ts +118 -0
- package/dist/remote-device/diagnostics/report.js +748 -0
- package/dist/remote-device/diagnostics/upload.d.ts +11 -0
- package/dist/remote-device/diagnostics/upload.js +59 -0
- package/dist/remote-device/realtime-health-telemetry.d.ts +35 -0
- package/dist/remote-device/realtime-health-telemetry.js +110 -0
- package/dist/remote-device/remote-channel.d.ts +86 -5
- package/dist/remote-device/remote-channel.js +470 -68
- package/dist/remote-device/scripts/blocking-offline-update.js +108 -69
- package/dist/remote-device/transport-telemetry.d.ts +32 -0
- package/dist/remote-device/transport-telemetry.js +48 -0
- package/dist/search-manager.d.ts +239 -27
- package/dist/search-manager.js +746 -312
- package/dist/server.js +157 -303
- package/dist/terminal-manager.d.ts +138 -21
- package/dist/terminal-manager.js +300 -215
- package/dist/tools/config.d.ts +1 -1
- package/dist/tools/config.js +21 -70
- package/dist/tools/edit.js +12 -4
- package/dist/tools/filesystem.d.ts +30 -6
- package/dist/tools/filesystem.js +246 -140
- package/dist/tools/improved-process-tools.d.ts +9 -3
- package/dist/tools/improved-process-tools.js +171 -68
- package/dist/tools/pdf/extract-images.d.ts +2 -0
- package/dist/tools/pdf/extract-images.js +4 -1
- package/dist/tools/pdf/index.d.ts +5 -3
- package/dist/tools/pdf/index.js +4 -3
- package/dist/tools/pdf/lib/pdf2md.d.ts +8 -1
- package/dist/tools/pdf/lib/pdf2md.js +12 -5
- package/dist/tools/pdf/manipulations.d.ts +12 -1
- package/dist/tools/pdf/manipulations.js +17 -4
- package/dist/tools/pdf/markdown.d.ts +96 -0
- package/dist/tools/pdf/markdown.js +485 -20
- package/dist/tools/pdf/utils.d.ts +2 -2
- package/dist/tools/pdf/utils.js +4 -4
- package/dist/tools/process.js +8 -5
- package/dist/tools/schemas.d.ts +1 -11
- package/dist/tools/schemas.js +15 -14
- package/dist/types.d.ts +1 -1
- package/dist/ui/config-editor/config-editor-runtime.js +53 -53
- package/dist/ui/config-editor/src/app.js +2 -15
- package/dist/ui/file-preview/preview-runtime.js +190 -182
- package/dist/utils/ab-test.js +27 -9
- package/dist/utils/atomic-write.d.ts +14 -0
- package/dist/utils/atomic-write.js +80 -0
- package/dist/utils/capture.d.ts +17 -1
- package/dist/utils/capture.js +177 -68
- package/dist/utils/exit-process.d.ts +24 -0
- package/dist/utils/exit-process.js +31 -0
- package/dist/utils/feature-flags.js +2 -1
- package/dist/utils/files/base.d.ts +3 -1
- package/dist/utils/files/docx.d.ts +3 -0
- package/dist/utils/files/docx.js +24 -9
- package/dist/utils/files/excel.d.ts +10 -0
- package/dist/utils/files/excel.js +93 -33
- package/dist/utils/files/factory.d.ts +22 -1
- package/dist/utils/files/factory.js +59 -4
- package/dist/utils/files/image.d.ts +12 -4
- package/dist/utils/files/image.js +19 -8
- package/dist/utils/files/index.d.ts +5 -3
- package/dist/utils/files/index.js +4 -3
- package/dist/utils/files/pdf.js +18 -36
- package/dist/utils/files/text.d.ts +21 -5
- package/dist/utils/files/text.js +90 -86
- package/dist/utils/internal-facts.d.ts +3 -0
- package/dist/utils/internal-facts.js +23 -0
- package/dist/utils/lazy-package.d.ts +25 -0
- package/dist/utils/lazy-package.js +44 -0
- package/dist/utils/open-browser.js +2 -1
- package/dist/utils/process-detection.d.ts +24 -5
- package/dist/utils/process-detection.js +199 -89
- package/dist/utils/process-tree.d.ts +14 -0
- package/dist/utils/process-tree.js +223 -0
- package/dist/utils/rename.d.ts +9 -0
- package/dist/utils/rename.js +74 -0
- package/dist/utils/ripgrep-resolver.js +9 -14
- package/dist/utils/shell.d.ts +42 -0
- package/dist/utils/shell.js +187 -0
- package/dist/utils/system-info.d.ts +1 -0
- package/dist/utils/system-info.js +40 -25
- package/dist/utils/trackTools.js +2 -1
- package/dist/utils/usageTracker.d.ts +0 -39
- package/dist/utils/usageTracker.js +1 -161
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/node_modules/@desktop-commander/telemetry-contract/README.md +56 -0
- package/node_modules/@desktop-commander/telemetry-contract/package.json +32 -0
- package/node_modules/@desktop-commander/telemetry-contract/transport.d.ts +38 -0
- package/node_modules/@desktop-commander/telemetry-contract/transport.js +164 -0
- package/package.json +32 -16
- package/vendor/telemetry-contract/README.md +56 -0
- package/vendor/telemetry-contract/package.json +32 -0
- package/vendor/telemetry-contract/transport.d.ts +38 -0
- package/vendor/telemetry-contract/transport.js +164 -0
- package/vendor/telemetry-contract/transport.test.js +39 -0
|
@@ -1,20 +1,68 @@
|
|
|
1
1
|
import { TerminalSession, CommandExecutionResult, ActiveSession } from './types.js';
|
|
2
|
+
import { type ProcessState } from './utils/process-detection.js';
|
|
3
|
+
/** A child process's output pipes. */
|
|
4
|
+
type OutputStream = 'stdout' | 'stderr';
|
|
5
|
+
/** The end of one output pipe, kept for process-state detection (see getProcessState). */
|
|
6
|
+
interface StreamTail {
|
|
7
|
+
text: string;
|
|
8
|
+
chars: number;
|
|
9
|
+
turn: number;
|
|
10
|
+
}
|
|
11
|
+
type StreamTails = Record<OutputStream, StreamTail>;
|
|
12
|
+
/** An active session plus the per-stream tails that state detection reads. */
|
|
13
|
+
interface ManagedSession extends TerminalSession {
|
|
14
|
+
streams: StreamTails;
|
|
15
|
+
termination?: Promise<boolean>;
|
|
16
|
+
}
|
|
17
|
+
/** Outcome of forceTerminate */
|
|
18
|
+
export type TerminateOutcome = 'terminated' | 'failed' | 'not_found';
|
|
2
19
|
interface CompletedSession {
|
|
3
|
-
|
|
4
|
-
outputLines: string[];
|
|
20
|
+
session: ManagedSession;
|
|
5
21
|
exitCode: number | null;
|
|
6
|
-
|
|
22
|
+
signal: NodeJS.Signals | null;
|
|
7
23
|
endTime: Date;
|
|
8
|
-
|
|
9
|
-
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A position in a session's output, absolute since process start (evicted
|
|
27
|
+
* output included), so it stays valid while the buffer cap evicts lines.
|
|
28
|
+
*/
|
|
29
|
+
export interface OutputSnapshot {
|
|
30
|
+
totalChars: number;
|
|
31
|
+
lineCount: number;
|
|
32
|
+
streamChars: Record<OutputStream, number>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Ceiling for a single blocking process wait (start_process's initial wait,
|
|
36
|
+
* interact_with_process, read_process_output). The wait is otherwise bounded
|
|
37
|
+
* only by the caller's timeout_ms, and MCP clients abandon a tool call after
|
|
38
|
+
* ~4 minutes (Claude Desktop: "No result received ... after 4 minutes"), so a
|
|
39
|
+
* large timeout_ms on a long, prompt-less command used to outlive the client.
|
|
40
|
+
* The ceiling is MAX_PROCESS_WAIT_MS; callers other than the tools (tests) may
|
|
41
|
+
* pass a smaller one.
|
|
42
|
+
*/
|
|
43
|
+
export interface ProcessWaitLimit {
|
|
44
|
+
waitMs: number;
|
|
45
|
+
capMs: number;
|
|
46
|
+
capped: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The one place that turns a caller's timeout_ms into the time a process wait
|
|
50
|
+
* may actually block. When `capped`, the call returns at the ceiling with the
|
|
51
|
+
* process still running and the caller continues with read_process_output.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getProcessWaitLimit(timeoutMs: number, capMs?: number): ProcessWaitLimit;
|
|
54
|
+
/** executeCommand result: CommandExecutionResult plus the process state and whether the wait ceiling ended the wait. */
|
|
55
|
+
export interface ProcessStartResult extends CommandExecutionResult {
|
|
56
|
+
processState: ProcessState;
|
|
57
|
+
waitCappedAtMs?: number;
|
|
10
58
|
}
|
|
11
59
|
/**
|
|
12
60
|
* Output buffering caps. Without a cap, a process emitting enough output makes
|
|
13
61
|
* string concatenation throw "RangeError: Invalid string length" at V8's max
|
|
14
62
|
* string size (~536M chars) inside a stdout 'data' handler — an uncaught
|
|
15
63
|
* exception that kills the whole server (index.ts exits on uncaughtException).
|
|
16
|
-
* The cap also bounds the
|
|
17
|
-
*
|
|
64
|
+
* The cap also bounds the cost of the reads that are O(total output), such as
|
|
65
|
+
* since-start snapshot reads.
|
|
18
66
|
*/
|
|
19
67
|
export declare const MAX_BUFFERED_OUTPUT_CHARS: number;
|
|
20
68
|
export interface PaginatedOutputResult {
|
|
@@ -25,12 +73,15 @@ export interface PaginatedOutputResult {
|
|
|
25
73
|
remaining: number;
|
|
26
74
|
isComplete: boolean;
|
|
27
75
|
exitCode?: number | null;
|
|
76
|
+
signal?: NodeJS.Signals | null;
|
|
28
77
|
runtimeMs?: number;
|
|
29
78
|
evictedLines?: number;
|
|
30
79
|
}
|
|
31
80
|
export declare class TerminalManager {
|
|
32
81
|
private sessions;
|
|
33
82
|
private completedSessions;
|
|
83
|
+
private deliveryTurn;
|
|
84
|
+
private deliveryTurnOpen;
|
|
34
85
|
/**
|
|
35
86
|
* Send input to a running process
|
|
36
87
|
* @param pid Process ID
|
|
@@ -38,7 +89,23 @@ export declare class TerminalManager {
|
|
|
38
89
|
* @returns Whether input was successfully sent
|
|
39
90
|
*/
|
|
40
91
|
sendInputToProcess(pid: number, input: string): boolean;
|
|
41
|
-
executeCommand(command: string, timeoutMs?: number, shell?: string, collectTiming?: boolean): Promise<
|
|
92
|
+
executeCommand(command: string, timeoutMs?: number, shell?: string, collectTiming?: boolean, maxWaitMs?: number): Promise<ProcessStartResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Add a chunk of one stream's output to the session: to the merged line
|
|
95
|
+
* buffer, and to that stream's tail for state detection.
|
|
96
|
+
*/
|
|
97
|
+
private recordOutput;
|
|
98
|
+
/**
|
|
99
|
+
* Number of the event-loop turn now delivering output; every chunk
|
|
100
|
+
* dispatched before the next check phase (setImmediate) shares it.
|
|
101
|
+
*
|
|
102
|
+
* stdout and stderr are separate pipes. Each turn delivers what the OS had
|
|
103
|
+
* ready when the loop polled, so a chunk delivered in a later turn was
|
|
104
|
+
* written after the chunks of earlier turns. Within one turn the pipes come
|
|
105
|
+
* in either order: when python -i's final stdout newline and its stderr
|
|
106
|
+
* ">>> " prompt are both waiting, the prompt is often delivered first.
|
|
107
|
+
*/
|
|
108
|
+
private currentDeliveryTurn;
|
|
42
109
|
/**
|
|
43
110
|
* Append text to a session's line buffer
|
|
44
111
|
* Handles partial lines and newline splitting
|
|
@@ -53,7 +120,21 @@ export declare class TerminalManager {
|
|
|
53
120
|
*/
|
|
54
121
|
readOutputPaginated(pid: number, offset?: number, length?: number): PaginatedOutputResult | null;
|
|
55
122
|
/**
|
|
56
|
-
*
|
|
123
|
+
* Whether a default read (offset 0) has anything to return: complete lines
|
|
124
|
+
* past the read position, or an unfinished last line with text a read
|
|
125
|
+
* hasn't returned (see readFromLineBuffer). Line counts alone can't tell
|
|
126
|
+
* the second: text appended to that line adds no line.
|
|
127
|
+
*/
|
|
128
|
+
hasUnreadOutput(pid: number): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Whether the unfinished last line has text that a default read hasn't
|
|
131
|
+
* returned. Empty, it has nothing to return. Its text is compared with what
|
|
132
|
+
* a read last returned only while it is the line that read stopped at: a
|
|
133
|
+
* later line is new even when its text is the same (a REPL's next ">>> ").
|
|
134
|
+
*/
|
|
135
|
+
private static openLineHasNewText;
|
|
136
|
+
/**
|
|
137
|
+
* Internal helper to read from a session's line buffer with offset/length
|
|
57
138
|
*/
|
|
58
139
|
private readFromLineBuffer;
|
|
59
140
|
/**
|
|
@@ -71,23 +152,53 @@ export declare class TerminalManager {
|
|
|
71
152
|
* Capture a snapshot of current output state for interaction tracking.
|
|
72
153
|
* Used by interactWithProcess to know what output existed before sending input.
|
|
73
154
|
*/
|
|
74
|
-
captureOutputSnapshot(pid: number):
|
|
75
|
-
totalChars: number;
|
|
76
|
-
lineCount: number;
|
|
77
|
-
} | null;
|
|
155
|
+
captureOutputSnapshot(pid: number): OutputSnapshot | null;
|
|
78
156
|
/**
|
|
79
157
|
* Get output that appeared since a snapshot was taken.
|
|
80
158
|
* This handles the case where output is appended to the last line (REPL prompts).
|
|
81
159
|
* Also checks completed sessions in case process finished between snapshot and poll.
|
|
82
160
|
*/
|
|
83
|
-
getOutputSinceSnapshot(pid: number, snapshot:
|
|
84
|
-
totalChars: number;
|
|
85
|
-
lineCount: number;
|
|
86
|
-
}): string | null;
|
|
161
|
+
getOutputSinceSnapshot(pid: number, snapshot: OutputSnapshot): string | null;
|
|
87
162
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
163
|
+
* Output that appeared since `snapshot`, plus the snapshot at the current end
|
|
164
|
+
* of output. A poller passes `next` back in to read only the output that
|
|
165
|
+
* arrived since its previous poll. Costs O(output since snapshot), never
|
|
166
|
+
* O(whole buffer), so polling stays cheap however much history the session
|
|
167
|
+
* has retained. Also checks completed sessions in case the process finished
|
|
168
|
+
* between snapshot and poll.
|
|
169
|
+
*/
|
|
170
|
+
readOutputSince(pid: number, snapshot: OutputSnapshot): {
|
|
171
|
+
output: string;
|
|
172
|
+
next: OutputSnapshot;
|
|
173
|
+
} | null;
|
|
174
|
+
/**
|
|
175
|
+
* Snapshot at the current end of a buffer, in O(1): bufferedChars is the
|
|
176
|
+
* joined length of the retained lines, so nothing is joined here.
|
|
177
|
+
*/
|
|
178
|
+
private static endOfOutput;
|
|
179
|
+
/**
|
|
180
|
+
* The process's state: finished once it has exited, whatever its output
|
|
181
|
+
* says; otherwise waiting for input or running, judged from the end of the
|
|
182
|
+
* output it wrote since `since` (default: since it started). Reads only the
|
|
183
|
+
* per-stream tails, so it costs the same however much output the process
|
|
184
|
+
* has produced. The one place start_process, interact_with_process,
|
|
185
|
+
* read_process_output and list_sessions get the state from.
|
|
186
|
+
*/
|
|
187
|
+
getProcessState(pid: number, since?: OutputSnapshot): ProcessState | null;
|
|
188
|
+
/**
|
|
189
|
+
* The output since `since` of each stream that may have written last: the
|
|
190
|
+
* streams delivered in the latest turn that delivered anything since then.
|
|
191
|
+
* Their relative order within that turn is unknown (see
|
|
192
|
+
* currentDeliveryTurn), so each is judged on its own; streams last
|
|
193
|
+
* delivered in an earlier turn wrote before them and can't end the output.
|
|
194
|
+
*/
|
|
195
|
+
private static lastWrittenOutput;
|
|
196
|
+
/**
|
|
197
|
+
* New output since a snapshot, in absolute (since process start) offsets:
|
|
198
|
+
* the last (end - snapshot) chars of the joined buffer. Walks back from the
|
|
199
|
+
* newest line only until the snapshot position is covered and joins just
|
|
200
|
+
* those lines. If eviction dropped part of the unseen output, returns what
|
|
201
|
+
* the buffer still holds — the oldest unseen chars are lost to the cap.
|
|
91
202
|
*/
|
|
92
203
|
private static outputSinceSnapshot;
|
|
93
204
|
/**
|
|
@@ -96,7 +207,13 @@ export declare class TerminalManager {
|
|
|
96
207
|
* @returns The session or undefined if not found
|
|
97
208
|
*/
|
|
98
209
|
getSession(pid: number): TerminalSession | undefined;
|
|
99
|
-
|
|
210
|
+
/**
|
|
211
|
+
* End a session: its shell and every process the command started (see
|
|
212
|
+
* terminateProcessTree). Killing only the shell left the program running.
|
|
213
|
+
* Resolves once they are gone: 'terminated', or 'failed' if some could not
|
|
214
|
+
* be ended; 'not_found' when no session runs as `pid`. Never rejects.
|
|
215
|
+
*/
|
|
216
|
+
forceTerminate(pid: number): Promise<TerminateOutcome>;
|
|
100
217
|
listActiveSessions(): ActiveSession[];
|
|
101
218
|
listCompletedSessions(): CompletedSession[];
|
|
102
219
|
}
|