@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.
Files changed (121) hide show
  1. package/README.md +14 -24
  2. package/dist/command-manager.d.ts +7 -2
  3. package/dist/command-manager.js +16 -11
  4. package/dist/config-manager.d.ts +55 -3
  5. package/dist/config-manager.js +329 -87
  6. package/dist/config-recovery.d.ts +28 -0
  7. package/dist/config-recovery.js +81 -0
  8. package/dist/config.d.ts +1 -0
  9. package/dist/config.js +9 -0
  10. package/dist/handlers/filesystem-handlers.d.ts +1 -1
  11. package/dist/handlers/filesystem-handlers.js +26 -16
  12. package/dist/handlers/search-answers.d.ts +58 -0
  13. package/dist/handlers/search-answers.js +172 -0
  14. package/dist/handlers/search-handlers.js +4 -92
  15. package/dist/index.js +14 -7
  16. package/dist/npm-scripts/remote.js +47 -4
  17. package/dist/remote-device/desktop-commander-integration.d.ts +21 -0
  18. package/dist/remote-device/desktop-commander-integration.js +121 -40
  19. package/dist/remote-device/device-authenticator.d.ts +13 -1
  20. package/dist/remote-device/device-authenticator.js +87 -47
  21. package/dist/remote-device/device.d.ts +14 -0
  22. package/dist/remote-device/device.js +244 -51
  23. package/dist/remote-device/diagnostics/device-log.d.ts +63 -0
  24. package/dist/remote-device/diagnostics/device-log.js +219 -0
  25. package/dist/remote-device/diagnostics/redact.d.ts +1 -0
  26. package/dist/remote-device/diagnostics/redact.js +76 -0
  27. package/dist/remote-device/diagnostics/report.d.ts +118 -0
  28. package/dist/remote-device/diagnostics/report.js +748 -0
  29. package/dist/remote-device/diagnostics/upload.d.ts +11 -0
  30. package/dist/remote-device/diagnostics/upload.js +59 -0
  31. package/dist/remote-device/realtime-health-telemetry.d.ts +35 -0
  32. package/dist/remote-device/realtime-health-telemetry.js +110 -0
  33. package/dist/remote-device/remote-channel.d.ts +86 -5
  34. package/dist/remote-device/remote-channel.js +470 -68
  35. package/dist/remote-device/scripts/blocking-offline-update.js +108 -69
  36. package/dist/remote-device/transport-telemetry.d.ts +32 -0
  37. package/dist/remote-device/transport-telemetry.js +48 -0
  38. package/dist/search-manager.d.ts +239 -27
  39. package/dist/search-manager.js +746 -312
  40. package/dist/server.js +157 -303
  41. package/dist/terminal-manager.d.ts +138 -21
  42. package/dist/terminal-manager.js +300 -215
  43. package/dist/tools/config.d.ts +1 -1
  44. package/dist/tools/config.js +21 -70
  45. package/dist/tools/edit.js +12 -4
  46. package/dist/tools/filesystem.d.ts +30 -6
  47. package/dist/tools/filesystem.js +246 -140
  48. package/dist/tools/improved-process-tools.d.ts +9 -3
  49. package/dist/tools/improved-process-tools.js +171 -68
  50. package/dist/tools/pdf/extract-images.d.ts +2 -0
  51. package/dist/tools/pdf/extract-images.js +4 -1
  52. package/dist/tools/pdf/index.d.ts +5 -3
  53. package/dist/tools/pdf/index.js +4 -3
  54. package/dist/tools/pdf/lib/pdf2md.d.ts +8 -1
  55. package/dist/tools/pdf/lib/pdf2md.js +12 -5
  56. package/dist/tools/pdf/manipulations.d.ts +12 -1
  57. package/dist/tools/pdf/manipulations.js +17 -4
  58. package/dist/tools/pdf/markdown.d.ts +96 -0
  59. package/dist/tools/pdf/markdown.js +485 -20
  60. package/dist/tools/pdf/utils.d.ts +2 -2
  61. package/dist/tools/pdf/utils.js +4 -4
  62. package/dist/tools/process.js +8 -5
  63. package/dist/tools/schemas.d.ts +1 -11
  64. package/dist/tools/schemas.js +15 -14
  65. package/dist/types.d.ts +1 -1
  66. package/dist/ui/config-editor/config-editor-runtime.js +53 -53
  67. package/dist/ui/config-editor/src/app.js +2 -15
  68. package/dist/ui/file-preview/preview-runtime.js +190 -182
  69. package/dist/utils/ab-test.js +27 -9
  70. package/dist/utils/atomic-write.d.ts +14 -0
  71. package/dist/utils/atomic-write.js +80 -0
  72. package/dist/utils/capture.d.ts +17 -1
  73. package/dist/utils/capture.js +177 -68
  74. package/dist/utils/exit-process.d.ts +24 -0
  75. package/dist/utils/exit-process.js +31 -0
  76. package/dist/utils/feature-flags.js +2 -1
  77. package/dist/utils/files/base.d.ts +3 -1
  78. package/dist/utils/files/docx.d.ts +3 -0
  79. package/dist/utils/files/docx.js +24 -9
  80. package/dist/utils/files/excel.d.ts +10 -0
  81. package/dist/utils/files/excel.js +93 -33
  82. package/dist/utils/files/factory.d.ts +22 -1
  83. package/dist/utils/files/factory.js +59 -4
  84. package/dist/utils/files/image.d.ts +12 -4
  85. package/dist/utils/files/image.js +19 -8
  86. package/dist/utils/files/index.d.ts +5 -3
  87. package/dist/utils/files/index.js +4 -3
  88. package/dist/utils/files/pdf.js +18 -36
  89. package/dist/utils/files/text.d.ts +21 -5
  90. package/dist/utils/files/text.js +90 -86
  91. package/dist/utils/internal-facts.d.ts +3 -0
  92. package/dist/utils/internal-facts.js +23 -0
  93. package/dist/utils/lazy-package.d.ts +25 -0
  94. package/dist/utils/lazy-package.js +44 -0
  95. package/dist/utils/open-browser.js +2 -1
  96. package/dist/utils/process-detection.d.ts +24 -5
  97. package/dist/utils/process-detection.js +199 -89
  98. package/dist/utils/process-tree.d.ts +14 -0
  99. package/dist/utils/process-tree.js +223 -0
  100. package/dist/utils/rename.d.ts +9 -0
  101. package/dist/utils/rename.js +74 -0
  102. package/dist/utils/ripgrep-resolver.js +9 -14
  103. package/dist/utils/shell.d.ts +42 -0
  104. package/dist/utils/shell.js +187 -0
  105. package/dist/utils/system-info.d.ts +1 -0
  106. package/dist/utils/system-info.js +40 -25
  107. package/dist/utils/trackTools.js +2 -1
  108. package/dist/utils/usageTracker.d.ts +0 -39
  109. package/dist/utils/usageTracker.js +1 -161
  110. package/dist/version.d.ts +1 -1
  111. package/dist/version.js +1 -1
  112. package/node_modules/@desktop-commander/telemetry-contract/README.md +56 -0
  113. package/node_modules/@desktop-commander/telemetry-contract/package.json +32 -0
  114. package/node_modules/@desktop-commander/telemetry-contract/transport.d.ts +38 -0
  115. package/node_modules/@desktop-commander/telemetry-contract/transport.js +164 -0
  116. package/package.json +32 -16
  117. package/vendor/telemetry-contract/README.md +56 -0
  118. package/vendor/telemetry-contract/package.json +32 -0
  119. package/vendor/telemetry-contract/transport.d.ts +38 -0
  120. package/vendor/telemetry-contract/transport.js +164 -0
  121. package/vendor/telemetry-contract/transport.test.js +39 -0
package/README.md CHANGED
@@ -17,19 +17,6 @@ Work with code and text, run processes, and automate tasks, going far beyond oth
17
17
  <img width="380" height="200" src="https://glama.ai/mcp/servers/zempur9oh4/badge" alt="Desktop Commander MCP" />
18
18
  </a>
19
19
 
20
- ## 🖥️ Try the Desktop Commander App (Beta)
21
-
22
- **Want a better experience?** The Desktop Commander App gives you everything the MCP server does, plus:
23
-
24
- - **Use any AI model** — Claude, GPT-4.5, Gemini 2.5, or any model you prefer
25
- - **See file changes live** — visual file previews as AI edits your files
26
- - **Add custom MCPs and context** — extend with your own tools, no config files
27
- - **Coming soon** — skills system, dictation, background scheduled tasks, and more
28
-
29
- **👉 [Download the App](https://desktopcommander.app/#download)** (macOS & Windows)
30
-
31
- > The MCP server below still works great with Claude Desktop and other MCP clients — the app is for those who want a dedicated, polished experience.
32
-
33
20
  ## Table of Contents
34
21
  - [Features](#features)
35
22
  - [How to install](#how-to-install)
@@ -470,21 +457,24 @@ Or add to `.qwen/settings.json` (project) or `~/.qwen/settings.json` (global). S
470
457
  <details>
471
458
  <summary><b>ChatGPT / Claude Web (Remote MCP)</b></summary>
472
459
 
473
- Use Desktop Commander from **ChatGPT**, **Claude web**, and other AI services via Remote MCP — no desktop app required.
460
+ Use Desktop Commander from **ChatGPT**, **Claude web**, and other AI services while commands still execute on your computer.
461
+
462
+ Start the Remote Device:
463
+
464
+ ```bash
465
+ npx @wonderwhy-er/desktop-commander@latest remote
466
+ ```
474
467
 
475
- **👉 [Get started at mcp.desktopcommander.app](https://mcp.desktopcommander.app)**
468
+ On first run, complete browser authentication, then connect your AI at **[mcp.desktopcommander.app](https://mcp.desktopcommander.app)**.
476
469
 
477
- How it works:
478
- 1. You run a lightweight **Remote Device** on your computer
479
- 2. It connects securely to the cloud Remote MCP service
480
- 3. Your AI sends commands through the cloud to your device
481
- 4. Commands execute locally, results return to your AI
482
- 5. **You stay in control** — stop anytime with `Ctrl+C`
470
+ - Stop the local device temporarily with `Ctrl+C`
471
+ - See available CLI options with `npx @wonderwhy-er/desktop-commander@latest remote --help`
472
+ - See **[Remote MCP setup, logout/revocation, CLI reference, and troubleshooting](src/remote-device/README.md)**
483
473
 
484
474
  ### Security
485
475
 
486
- - ✅ Device only runs when you start it
487
- - ✅ Commands execute under your user permissions
476
+ - ✅ The Remote Device only accepts commands while it is running
477
+ - ✅ Commands execute locally under your user permissions
488
478
  - ✅ Secure OAuth authentication and encrypted communication channel
489
479
 
490
480
  </details>
@@ -823,7 +813,7 @@ Locations:
823
813
 
824
814
  ### Remote calls and server-side retention
825
815
 
826
- Calls executed through Remote Desktop Commander are still handled by the local MCP server and use the same local history files above. The Remote Desktop Commander service does **not currently retain command arguments or command results as a historical server-side audit trail after execution is complete**.
816
+ Calls executed through Remote Desktop Commander are still handled by the local MCP server and use the same local history files above. The Remote Desktop Commander service temporarily stores tool arguments and results in `mcp_remote_calls` so calls can be routed and completed. Terminal rows are automatically swept shortly after completion (eligible for deletion after one minute, with a one-hour creation-time backstop), so they are not kept as a long-term historical server-side audit trail.
827
817
 
828
818
  These local history files are also separate from Desktop Commander's optional telemetry. The files themselves are not uploaded as telemetry. See [Data Collection & Privacy](#data-collection--privacy) and [PRIVACY.md](PRIVACY.md) for telemetry details.
829
819
 
@@ -1,7 +1,12 @@
1
1
  declare class CommandManager {
2
2
  getBaseCommand(command: string): string;
3
- extractCommands(commandString: string): string[];
4
- extractBaseCommand(commandStr: string): string | null;
3
+ /**
4
+ * The command name of each command in a command line (chained, piped, in $(), ...).
5
+ * asTyped: each first word as typed instead of its base name, for telemetry,
6
+ * which then replaces a path whole (a base name alone can't be told from one).
7
+ */
8
+ extractCommands(commandString: string, asTyped?: boolean): string[];
9
+ extractBaseCommand(commandStr: string, asTyped?: boolean): string | null;
5
10
  validateCommand(command: string): Promise<boolean>;
6
11
  }
7
12
  export declare const commandManager: CommandManager;
@@ -5,7 +5,12 @@ class CommandManager {
5
5
  getBaseCommand(command) {
6
6
  return command.split(' ')[0].toLowerCase().trim();
7
7
  }
8
- extractCommands(commandString) {
8
+ /**
9
+ * The command name of each command in a command line (chained, piped, in $(), ...).
10
+ * asTyped: each first word as typed instead of its base name, for telemetry,
11
+ * which then replaces a path whole (a base name alone can't be told from one).
12
+ */
13
+ extractCommands(commandString, asTyped = false) {
9
14
  try {
10
15
  // Trim any leading/trailing whitespace
11
16
  commandString = commandString.trim();
@@ -59,7 +64,7 @@ class CommandManager {
59
64
  }
60
65
  if (j <= commandString.length && openParens === 0) {
61
66
  const subContent = commandString.substring(i + 2, j - 1);
62
- const subCommands = this.extractCommands(subContent);
67
+ const subCommands = this.extractCommands(subContent, asTyped);
63
68
  commands.push(...subCommands);
64
69
  i = j - 1;
65
70
  if (!inQuote) {
@@ -80,7 +85,7 @@ class CommandManager {
80
85
  }
81
86
  if (j < commandString.length) {
82
87
  const subContent = commandString.substring(i + 1, j);
83
- const subCommands = this.extractCommands(subContent);
88
+ const subCommands = this.extractCommands(subContent, asTyped);
84
89
  commands.push(...subCommands);
85
90
  i = j;
86
91
  if (!inQuote) {
@@ -113,7 +118,7 @@ class CommandManager {
113
118
  if (j <= commandString.length && openParens === 0) {
114
119
  const subshellContent = commandString.substring(i + 1, j - 1);
115
120
  // Recursively extract commands from the subshell
116
- const subCommands = this.extractCommands(subshellContent);
121
+ const subCommands = this.extractCommands(subshellContent, asTyped);
117
122
  commands.push(...subCommands);
118
123
  // Move position past the subshell
119
124
  i = j - 1;
@@ -126,7 +131,7 @@ class CommandManager {
126
131
  if (commandString.startsWith(separator, i)) {
127
132
  // We found a separator - extract the command before it
128
133
  if (currentCmd.trim()) {
129
- const baseCommand = this.extractBaseCommand(currentCmd.trim());
134
+ const baseCommand = this.extractBaseCommand(currentCmd.trim(), asTyped);
130
135
  if (baseCommand)
131
136
  commands.push(baseCommand);
132
137
  }
@@ -143,7 +148,7 @@ class CommandManager {
143
148
  }
144
149
  // Don't forget to add the last command
145
150
  if (currentCmd.trim()) {
146
- const baseCommand = this.extractBaseCommand(currentCmd.trim());
151
+ const baseCommand = this.extractBaseCommand(currentCmd.trim(), asTyped);
147
152
  if (baseCommand)
148
153
  commands.push(baseCommand);
149
154
  }
@@ -155,12 +160,12 @@ class CommandManager {
155
160
  capture('server_request_error', {
156
161
  error: 'Error extracting commands'
157
162
  });
158
- const baseCmd = this.extractBaseCommand(commandString);
163
+ const baseCmd = this.extractBaseCommand(commandString, asTyped);
159
164
  return baseCmd ? [baseCmd] : [];
160
165
  }
161
166
  }
162
- // This extracts the actual command name from a command string
163
- extractBaseCommand(commandStr) {
167
+ // This extracts the actual command name from a command string (asTyped: see extractCommands)
168
+ extractBaseCommand(commandStr, asTyped = false) {
164
169
  try {
165
170
  // Remove environment variables (patterns like KEY=value)
166
171
  const withoutEnvVars = commandStr.replace(/\w+=\S+\s*/g, '').trim();
@@ -193,12 +198,12 @@ class CommandManager {
193
198
  const inner = firstToken.slice(2, -1).trim();
194
199
  if (inner) {
195
200
  const innerTokens = inner.split(/\s+/);
196
- return path.basename(innerTokens[0]).toLowerCase();
201
+ return (asTyped ? innerTokens[0] : path.basename(innerTokens[0])).toLowerCase();
197
202
  }
198
203
  return null;
199
204
  }
200
205
  // strip path prefix so /usr/bin/sudo gets caught as "sudo"
201
- const baseName = path.basename(firstToken);
206
+ const baseName = asTyped ? firstToken : path.basename(firstToken);
202
207
  return baseName.toLowerCase();
203
208
  }
204
209
  catch (error) {
@@ -15,6 +15,12 @@ export interface ClientInfo {
15
15
  }
16
16
  export declare function normalizeTelemetryEnabledValue(value: unknown): unknown;
17
17
  export declare function isTelemetryDisabledValue(value: unknown): boolean;
18
+ /**
19
+ * Parses config.json's text. Editors saving "UTF-8 with BOM" (Notepad,
20
+ * PowerShell 5's Set-Content -Encoding UTF8) put U+FEFF first, which
21
+ * JSON.parse rejects although the config is complete.
22
+ */
23
+ export declare function parseConfig(text: string): ServerConfig;
18
24
  /**
19
25
  * Singleton config manager for the server
20
26
  */
@@ -28,6 +34,9 @@ declare class ConfigManager {
28
34
  private pendingMutations;
29
35
  private watcher;
30
36
  private reloadTimer;
37
+ private failedSaves;
38
+ private saveRetry;
39
+ private heldRecoveryEvents;
31
40
  constructor();
32
41
  /**
33
42
  * Initialize configuration - load from disk or create default.
@@ -35,6 +44,18 @@ declare class ConfigManager {
35
44
  * normal writes so two processes starting together cannot clobber each other.
36
45
  */
37
46
  init(): Promise<void>;
47
+ /**
48
+ * Reads config.json at start. A missing one is created (a first run), a corrupt
49
+ * one is recovered, and one written before the welcome page existed is marked
50
+ * as an existing install. If it can't be read, recovered or saved, the session
51
+ * starts without saving it.
52
+ */
53
+ private loadStartupConfig;
54
+ /**
55
+ * Starts the session on `config` and leaves config.json as it is. `warning`
56
+ * tells the user why; saves are tried again every HELD_SAVE_RETRY_MS.
57
+ */
58
+ private startWithoutSaving;
38
59
  /**
39
60
  * Alias for init() to maintain backward compatibility
40
61
  */
@@ -44,12 +65,33 @@ declare class ConfigManager {
44
65
  */
45
66
  private getDefaultConfig;
46
67
  private readConfigFromDisk;
68
+ /**
69
+ * Recovers a corrupt config.json; the caller holds the config lock. It is backed
70
+ * up once, then rewritten as buildRecoveredConfig(). Returns the config now on disk.
71
+ */
72
+ private recoverCorruptConfig;
73
+ /** Sends a recovery event. Telemetry reads the config, so events from before init() is done wait for it. */
74
+ private reportRecovery;
75
+ private emitCorruptConfigTelemetry;
47
76
  private writeConfigAtomically;
77
+ /** config.json's text, or null when there is none */
78
+ private readConfigText;
48
79
  private acquireConfigLock;
80
+ /** Runs `fn` holding the config lock; `lockLost()` tells whether the lock was lost meanwhile. */
81
+ private withConfigLock;
82
+ /**
83
+ * Read config.json, apply `mutate`, write it back, all under the cross-process
84
+ * lock. If the lock was lost, or config.json changed, before the write
85
+ * committed, nothing was written: it runs again under a new lock, so the
86
+ * change lands on what the other process saved.
87
+ */
49
88
  private performConfigMutation;
89
+ private mutateLockedConfig;
50
90
  private queueMutation;
51
91
  /** Non-blocking, coalesced persistence for high-frequency state updates. */
52
92
  scheduleSave(): void;
93
+ /** Saves the queued changes in `ms`; until then scheduleSave() waits for it */
94
+ private retrySaves;
53
95
  private startConfigWatcher;
54
96
  private reloadConfigFromDisk;
55
97
  /**
@@ -60,9 +102,19 @@ declare class ConfigManager {
60
102
  * Get a specific configuration value
61
103
  */
62
104
  getValue(key: string): Promise<any>;
63
- /** Set a specific configuration value and wait for durable persistence. */
64
- setValue(key: string, value: any): Promise<void>;
65
- /** Update one value under the cross-process lock and return the durable value. */
105
+ /**
106
+ * Set a specific configuration value and wait until it is saved: the data is
107
+ * flushed to disk before the rename; the folder flush after it is best effort.
108
+ * With holdIfNotSaved, a value whose save fails is still in effect, and is
109
+ * queued to be saved with later writes (the call still rejects).
110
+ */
111
+ setValue(key: string, value: any, options?: {
112
+ holdIfNotSaved?: boolean;
113
+ }): Promise<void>;
114
+ /**
115
+ * Update one value under the cross-process lock and return it once saved: the
116
+ * data is flushed to disk before the rename; the folder flush after it is best effort.
117
+ */
66
118
  updateValue(key: string, updater: (current: any) => any): Promise<any>;
67
119
  /**
68
120
  * Set a value without waiting on disk. The queued operation is applied to the