@wonderwhy-er/desktop-commander 0.2.52 → 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/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 +17 -3
- package/dist/remote-device/desktop-commander-integration.d.ts +1 -0
- package/dist/remote-device/desktop-commander-integration.js +19 -25
- package/dist/remote-device/device.d.ts +14 -0
- package/dist/remote-device/device.js +137 -30
- 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 +36 -4
- package/dist/remote-device/remote-channel.js +230 -50
- 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 +124 -222
- 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
package/dist/server.js
CHANGED
|
@@ -7,21 +7,26 @@ import { getSystemInfo, getOSSpecificGuidance, getPathGuidance, getDevelopmentTo
|
|
|
7
7
|
const SYSTEM_INFO = getSystemInfo();
|
|
8
8
|
const OS_GUIDANCE = getOSSpecificGuidance(SYSTEM_INFO);
|
|
9
9
|
const DEV_TOOL_GUIDANCE = getDevelopmentToolGuidance(SYSTEM_INFO);
|
|
10
|
-
const PATH_GUIDANCE =
|
|
10
|
+
const PATH_GUIDANCE = `${getPathGuidance(SYSTEM_INFO)} Relative paths depend on the current working directory, and tilde paths (~/...) may not resolve in every context. Absolute paths are generally the most reliable.`;
|
|
11
11
|
const CMD_PREFIX_DESCRIPTION = `This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.`;
|
|
12
|
-
|
|
12
|
+
const SERVER_INSTRUCTIONS = `Desktop Commander provides tools for working with the user's authorized device.
|
|
13
|
+
- Filesystem tools handle direct file and directory operations within configured access boundaries.
|
|
14
|
+
- Terminal process tools support shell commands, REPLs, and long-running processes. start_process creates a process session; interact_with_process sends input; read_process_output reads later output; force_terminate ends a session.
|
|
15
|
+
- Search tools are session-based. start_search creates a search session; get_more_search_results reads its results; stop_search ends it early.
|
|
16
|
+
- Absolute paths are generally the most reliable because relative paths depend on the active working directory.
|
|
17
|
+
- allowedDirectories and each tool's schema, annotations, and documented constraints define the operational boundaries.`;
|
|
18
|
+
import { StartProcessArgsSchema, ReadProcessOutputArgsSchema, InteractWithProcessArgsSchema, ForceTerminateArgsSchema, ListSessionsArgsSchema, KillProcessArgsSchema, ReadFileArgsSchema, ReadMultipleFilesArgsSchema, WriteFileArgsSchema, CreateDirectoryArgsSchema, ListDirectoryArgsSchema, MoveFileArgsSchema, GetFileInfoArgsSchema, GetConfigArgsSchema, SetConfigValueArgsSchema, ListProcessesArgsSchema, EditBlockArgsSchema, GetUsageStatsArgsSchema, GiveFeedbackArgsSchema, StartSearchArgsSchema, GetMoreSearchResultsArgsSchema, StopSearchArgsSchema, ListSearchesArgsSchema, GetRecentToolCallsArgsSchema, WritePdfArgsSchema, toolArgSchemas, } from './tools/schemas.js';
|
|
13
19
|
import { detectUnsupportedParams, getSupportedParams, buildUnsupportedParamsWarning, } from './utils/unsupportedParams.js';
|
|
14
20
|
import { getConfig, setConfigValue } from './tools/config.js';
|
|
15
21
|
import { getUsageStats } from './tools/usage.js';
|
|
16
22
|
import { giveFeedbackToDesktopCommander } from './tools/feedback.js';
|
|
17
|
-
import { getPrompts } from './tools/prompts.js';
|
|
18
23
|
import { trackToolCall } from './utils/trackTools.js';
|
|
19
24
|
import { usageTracker } from './utils/usageTracker.js';
|
|
20
25
|
import { processDockerPrompt } from './utils/dockerPrompt.js';
|
|
21
26
|
import { toolHistory } from './utils/toolHistory.js';
|
|
22
27
|
import { handleWelcomePageOnboarding, skipWelcomePageOnboarding } from './utils/welcome-onboarding.js';
|
|
23
28
|
import { VERSION } from './version.js';
|
|
24
|
-
import { capture, capture_call_tool, runInUiOriginCallContext } from "./utils/capture.js";
|
|
29
|
+
import { addToolCallPaths, capture, capture_call_tool, runInUiOriginCallContext, runWithToolCallPaths } from "./utils/capture.js";
|
|
25
30
|
import { logToStderr, logger } from './utils/logger.js';
|
|
26
31
|
import { buildUiToolMeta, CONFIG_EDITOR_RESOURCE_URI, FILE_PREVIEW_RESOURCE_URI, } from './ui/contracts.js';
|
|
27
32
|
import { listUiResources, readUiResource } from './ui/resources.js';
|
|
@@ -190,6 +195,7 @@ server.setRequestHandler(InitializeRequestSchema, async (request) => {
|
|
|
190
195
|
name: "desktop-commander",
|
|
191
196
|
version: VERSION,
|
|
192
197
|
},
|
|
198
|
+
instructions: SERVER_INSTRUCTIONS,
|
|
193
199
|
};
|
|
194
200
|
}
|
|
195
201
|
catch (error) {
|
|
@@ -206,7 +212,7 @@ deferLog('info', 'Setting up request handlers...');
|
|
|
206
212
|
function shouldIncludeTool(toolName) {
|
|
207
213
|
// Exclude these tools for desktop-commander client (DC-specific meta-tools not useful when DC itself is the client)
|
|
208
214
|
if (currentClient?.name === 'desktop-commander-app') {
|
|
209
|
-
if (toolName === 'give_feedback_to_desktop_commander'
|
|
215
|
+
if (toolName === 'give_feedback_to_desktop_commander') {
|
|
210
216
|
return false;
|
|
211
217
|
}
|
|
212
218
|
}
|
|
@@ -241,6 +247,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
241
247
|
annotations: {
|
|
242
248
|
title: "Get Configuration",
|
|
243
249
|
readOnlyHint: true,
|
|
250
|
+
openWorldHint: false,
|
|
251
|
+
destructiveHint: false,
|
|
244
252
|
},
|
|
245
253
|
},
|
|
246
254
|
{
|
|
@@ -248,8 +256,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
248
256
|
description: `
|
|
249
257
|
Set a specific configuration value by key.
|
|
250
258
|
|
|
251
|
-
|
|
252
|
-
command
|
|
259
|
+
Security note: configuration changes affect later file and command behavior.
|
|
260
|
+
Isolating them from untrusted file or command content reduces the chance that external content influences configuration.
|
|
253
261
|
|
|
254
262
|
Config keys include:
|
|
255
263
|
- blockedCommands (array)
|
|
@@ -307,7 +315,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
307
315
|
- Text: Uses offset/length for line-based pagination
|
|
308
316
|
- Excel (.xlsx, .xls, .xlsm): Returns JSON 2D array
|
|
309
317
|
* sheet: "Sheet1" (name) or "0" (index as string, 0-based)
|
|
310
|
-
* range
|
|
318
|
+
* range uses FROM:TO format (e.g., "A1:D100", "C1:C1", "B2:B50")
|
|
311
319
|
* offset/length work as row pagination (optional fallback)
|
|
312
320
|
- Images (PNG, JPEG, GIF, WebP): Base64 encoded viewable content
|
|
313
321
|
- PDF: Extracts text content as markdown with page structure
|
|
@@ -319,13 +327,12 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
319
327
|
Each element shows its body index [0], [1], etc.
|
|
320
328
|
* WITH offset/length: Returns raw pretty-printed XML with line pagination.
|
|
321
329
|
Use this to drill into specific sections or see the actual XML for editing.
|
|
322
|
-
*
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
zipfile module to find/replace all <w:t> elements at once.
|
|
330
|
+
* Raw DOCX XML output is compatible with edit_block's XML find/replace mode using
|
|
331
|
+
XML fragments copied from the read output.
|
|
332
|
+
* Raw XML mode requires a non-zero offset (offset=1 starts from line 1).
|
|
333
|
+
offset=0 returns the outline regardless of length.
|
|
334
|
+
* Bulk transformations can be performed programmatically against the DOCX archive
|
|
335
|
+
when the task requires changes across many XML text nodes.
|
|
329
336
|
|
|
330
337
|
${PATH_GUIDANCE}
|
|
331
338
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
@@ -335,6 +342,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
335
342
|
title: "Read File or URL",
|
|
336
343
|
readOnlyHint: true,
|
|
337
344
|
openWorldHint: true,
|
|
345
|
+
destructiveHint: false,
|
|
338
346
|
},
|
|
339
347
|
},
|
|
340
348
|
{
|
|
@@ -355,6 +363,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
355
363
|
annotations: {
|
|
356
364
|
title: "Read Multiple Files",
|
|
357
365
|
readOnlyHint: true,
|
|
366
|
+
openWorldHint: false,
|
|
367
|
+
destructiveHint: false,
|
|
358
368
|
},
|
|
359
369
|
},
|
|
360
370
|
{
|
|
@@ -362,37 +372,20 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
362
372
|
description: `
|
|
363
373
|
Write or append to file contents.
|
|
364
374
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
To CREATE a new DOCX, use write_file with .docx extension — text content with markdown headings (#, ##, ###) is converted to styled DOCX paragraphs.
|
|
368
|
-
|
|
369
|
-
CHUNKING IS STANDARD PRACTICE: Always write files in chunks of 25-30 lines maximum.
|
|
370
|
-
This is the normal, recommended way to write files - not an emergency measure.
|
|
375
|
+
PDF creation is handled by the dedicated write_pdf tool.
|
|
376
|
+
Existing DOCX content can be edited with edit_block. New DOCX files can be created here; markdown headings (#, ##, ###) are converted to styled DOCX paragraphs.
|
|
371
377
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
ALWAYS CHUNK PROACTIVELY - don't wait for performance warnings!
|
|
378
|
-
|
|
379
|
-
WHEN TO CHUNK (always be proactive):
|
|
380
|
-
1. Any file expected to be longer than 25-30 lines
|
|
381
|
-
2. When writing multiple files in sequence
|
|
382
|
-
3. When creating documentation, code files, or configuration files
|
|
383
|
-
|
|
384
|
-
HANDLING CONTINUATION ("Continue" prompts):
|
|
385
|
-
If user asks to "Continue" after an incomplete operation:
|
|
386
|
-
1. Read the file to see what was successfully written
|
|
387
|
-
2. Continue writing ONLY the remaining content using {mode: 'append'}
|
|
388
|
-
3. Keep chunks to 25-30 lines each
|
|
378
|
+
CHUNKED WRITES:
|
|
379
|
+
- Repeated calls with mode='rewrite' followed by mode='append' are supported for longer files.
|
|
380
|
+
- Chunks of roughly 25-30 lines minimize latency when writing long text, multiple files, documentation, code, or configuration files.
|
|
381
|
+
- Files over 50 lines are still written successfully but may generate performance notes.
|
|
382
|
+
- For continuation after a partial write, the existing file state can be inspected before appending the remaining content.
|
|
389
383
|
|
|
390
384
|
FORMAT HANDLING (by extension):
|
|
391
385
|
- Text files: String content
|
|
392
386
|
- Excel (.xlsx, .xls, .xlsm): JSON 2D array or {"SheetName": [[...]]}
|
|
393
387
|
Example: '[["Name","Age"],["Alice",30]]'
|
|
394
388
|
|
|
395
|
-
Files over 50 lines will generate performance notes but are still written successfully.
|
|
396
389
|
Only works within allowed directories.
|
|
397
390
|
|
|
398
391
|
${PATH_GUIDANCE}
|
|
@@ -411,10 +404,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
411
404
|
description: `
|
|
412
405
|
Create a new PDF file or modify an existing one.
|
|
413
406
|
|
|
414
|
-
|
|
407
|
+
Dedicated PDF creation and modification tool.
|
|
415
408
|
|
|
416
|
-
|
|
417
|
-
-
|
|
409
|
+
OUTPUT FILES:
|
|
410
|
+
- Creating a PDF requires 'outputPath' with a new filename (e.g., "result_01.pdf", "analysis_2025_01.pdf", etc.).
|
|
418
411
|
|
|
419
412
|
MODES:
|
|
420
413
|
1. CREATE NEW PDF:
|
|
@@ -423,9 +416,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
423
416
|
|
|
424
417
|
2. MODIFY EXISTING PDF:
|
|
425
418
|
- Pass array of operations as 'content'.
|
|
426
|
-
-
|
|
427
|
-
-
|
|
428
|
-
- After modifying, show original file path and new file path to user.
|
|
419
|
+
- Modifications preserve the original PDF and require a different filename in 'outputPath'.
|
|
420
|
+
- The result includes the original and output paths for reference.
|
|
429
421
|
|
|
430
422
|
write_pdf(path="doc.pdf", content=[
|
|
431
423
|
{ type: "delete", pageIndexes: [0, 2] },
|
|
@@ -482,6 +474,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
482
474
|
annotations: {
|
|
483
475
|
title: "Create Directory",
|
|
484
476
|
readOnlyHint: false,
|
|
477
|
+
openWorldHint: false,
|
|
485
478
|
destructiveHint: false,
|
|
486
479
|
},
|
|
487
480
|
},
|
|
@@ -490,7 +483,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
490
483
|
description: `
|
|
491
484
|
Get a detailed listing of all files and directories in a specified path.
|
|
492
485
|
|
|
493
|
-
|
|
486
|
+
Returns a structured directory listing without starting a shell command.
|
|
494
487
|
Results distinguish between files and directories with [FILE] and [DIR] prefixes.
|
|
495
488
|
|
|
496
489
|
Supports recursive listing with the 'depth' parameter (default: 2):
|
|
@@ -523,6 +516,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
523
516
|
annotations: {
|
|
524
517
|
title: "List Directory Contents",
|
|
525
518
|
readOnlyHint: true,
|
|
519
|
+
openWorldHint: false,
|
|
520
|
+
destructiveHint: false,
|
|
526
521
|
},
|
|
527
522
|
},
|
|
528
523
|
{
|
|
@@ -564,13 +559,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
564
559
|
- Finding patterns in code: "console.log statements", "import statements"
|
|
565
560
|
- User describes functionality: "components that handle login", "files with database queries"
|
|
566
561
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
Example
|
|
571
|
-
|
|
572
|
-
2. Simultaneously start content search: searchType="content", pattern="authentication"
|
|
573
|
-
3. Present combined results: "Found 3 auth-related files and 8 files containing authentication code"
|
|
562
|
+
AMBIGUOUS SEARCHES:
|
|
563
|
+
Queries that could refer to either filenames or file contents can be covered with two
|
|
564
|
+
searches: one with searchType="files" and one with searchType="content".
|
|
565
|
+
Example: "find authentication stuff" can pair a filename search for "auth" with a
|
|
566
|
+
content search for "authentication".
|
|
574
567
|
|
|
575
568
|
SEARCH TYPES:
|
|
576
569
|
- searchType="files": Find files by name (pattern matches file names)
|
|
@@ -580,8 +573,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
580
573
|
- Default (literalSearch=false): Patterns are treated as regular expressions
|
|
581
574
|
- Literal (literalSearch=true): Patterns are treated as exact strings
|
|
582
575
|
|
|
583
|
-
|
|
584
|
-
Use literal search when searching for code patterns with special characters:
|
|
576
|
+
literalSearch=true is useful for code patterns with special characters:
|
|
585
577
|
- Function calls with parentheses and quotes
|
|
586
578
|
- Array access with brackets
|
|
587
579
|
- Object methods with dots and parentheses
|
|
@@ -612,12 +604,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
612
604
|
1. searchType="files", pattern="auth"
|
|
613
605
|
2. searchType="content", pattern="authentication"
|
|
614
606
|
|
|
615
|
-
|
|
616
|
-
run both searches concurrently and combine results for comprehensive coverage.
|
|
607
|
+
Ambiguous requests can combine file-name and content searches for broader coverage.
|
|
617
608
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
come in, and stop_search to stop the search early if needed.
|
|
609
|
+
This tool starts a background search process and returns immediately with a session ID.
|
|
610
|
+
Results are available through get_more_search_results, and stop_search can end the search early.
|
|
621
611
|
|
|
622
612
|
Perfect for large directories where you want to see results immediately and
|
|
623
613
|
have the option to cancel if the search takes too long or you find what you need.
|
|
@@ -628,6 +618,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
628
618
|
annotations: {
|
|
629
619
|
title: "Start Search",
|
|
630
620
|
readOnlyHint: true,
|
|
621
|
+
openWorldHint: false,
|
|
622
|
+
destructiveHint: false,
|
|
631
623
|
},
|
|
632
624
|
},
|
|
633
625
|
{
|
|
@@ -658,6 +650,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
658
650
|
annotations: {
|
|
659
651
|
title: "Get Search Results",
|
|
660
652
|
readOnlyHint: true,
|
|
653
|
+
openWorldHint: false,
|
|
654
|
+
destructiveHint: false,
|
|
661
655
|
},
|
|
662
656
|
},
|
|
663
657
|
{
|
|
@@ -677,6 +671,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
677
671
|
annotations: {
|
|
678
672
|
title: "Stop Search",
|
|
679
673
|
readOnlyHint: false,
|
|
674
|
+
openWorldHint: false,
|
|
680
675
|
destructiveHint: false,
|
|
681
676
|
},
|
|
682
677
|
},
|
|
@@ -694,6 +689,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
694
689
|
annotations: {
|
|
695
690
|
title: "List Active Searches",
|
|
696
691
|
readOnlyHint: true,
|
|
692
|
+
openWorldHint: false,
|
|
693
|
+
destructiveHint: false,
|
|
697
694
|
},
|
|
698
695
|
},
|
|
699
696
|
{
|
|
@@ -718,6 +715,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
718
715
|
annotations: {
|
|
719
716
|
title: "Get File Information",
|
|
720
717
|
readOnlyHint: true,
|
|
718
|
+
openWorldHint: false,
|
|
719
|
+
destructiveHint: false,
|
|
721
720
|
},
|
|
722
721
|
},
|
|
723
722
|
// Note: list_allowed_directories removed - use get_config to check allowedDirectories
|
|
@@ -727,16 +726,15 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
727
726
|
description: `
|
|
728
727
|
Apply surgical edits to files.
|
|
729
728
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
context to uniquely identify the text being modified.
|
|
729
|
+
Small, focused edits are easier to verify than large multi-purpose replacements.
|
|
730
|
+
old_string can include enough surrounding context to uniquely identify the intended text.
|
|
733
731
|
|
|
734
732
|
FORMAT HANDLING (by extension):
|
|
735
733
|
|
|
736
734
|
EXCEL FILES (.xlsx, .xls, .xlsm) - Range Update mode:
|
|
737
735
|
Takes:
|
|
738
736
|
- file_path: Path to the Excel file
|
|
739
|
-
- range
|
|
737
|
+
- range uses FROM:TO format - "SheetName!A1:C10" or "SheetName!C1:C1"
|
|
740
738
|
- content: 2D array, e.g., [["H1","H2"],["R1","R2"]]
|
|
741
739
|
|
|
742
740
|
TEXT FILES - Find/Replace mode:
|
|
@@ -875,6 +873,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
875
873
|
annotations: {
|
|
876
874
|
title: "Read Process Output",
|
|
877
875
|
readOnlyHint: true,
|
|
876
|
+
openWorldHint: false,
|
|
877
|
+
destructiveHint: false,
|
|
878
878
|
},
|
|
879
879
|
},
|
|
880
880
|
{
|
|
@@ -954,6 +954,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
954
954
|
annotations: {
|
|
955
955
|
title: "List Terminal Sessions",
|
|
956
956
|
readOnlyHint: true,
|
|
957
|
+
openWorldHint: false,
|
|
958
|
+
destructiveHint: false,
|
|
957
959
|
},
|
|
958
960
|
},
|
|
959
961
|
{
|
|
@@ -968,6 +970,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
968
970
|
annotations: {
|
|
969
971
|
title: "List Running Processes",
|
|
970
972
|
readOnlyHint: true,
|
|
973
|
+
openWorldHint: false,
|
|
974
|
+
destructiveHint: false,
|
|
971
975
|
},
|
|
972
976
|
},
|
|
973
977
|
{
|
|
@@ -998,6 +1002,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
998
1002
|
annotations: {
|
|
999
1003
|
title: "Get Usage Statistics",
|
|
1000
1004
|
readOnlyHint: true,
|
|
1005
|
+
openWorldHint: false,
|
|
1006
|
+
destructiveHint: false,
|
|
1001
1007
|
},
|
|
1002
1008
|
},
|
|
1003
1009
|
{
|
|
@@ -1021,6 +1027,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
1021
1027
|
annotations: {
|
|
1022
1028
|
title: "Get Recent Tool Calls",
|
|
1023
1029
|
readOnlyHint: true,
|
|
1030
|
+
openWorldHint: false,
|
|
1031
|
+
destructiveHint: false,
|
|
1024
1032
|
},
|
|
1025
1033
|
},
|
|
1026
1034
|
{
|
|
@@ -1028,34 +1036,14 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
1028
1036
|
description: `
|
|
1029
1037
|
Open feedback form in browser to provide feedback about Desktop Commander.
|
|
1030
1038
|
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
- days_using: How many days they've used Desktop Commander
|
|
1040
|
-
- platform: Their operating system (Mac/Windows/Linux)
|
|
1041
|
-
- client_id: Analytics identifier
|
|
1042
|
-
|
|
1043
|
-
All survey questions will be answered directly in the form:
|
|
1044
|
-
- Job title and technical comfort level
|
|
1045
|
-
- Company URL for industry context
|
|
1046
|
-
- Other AI tools they use
|
|
1047
|
-
- Desktop Commander's biggest advantage
|
|
1048
|
-
- How they typically use it
|
|
1049
|
-
- Recommendation likelihood (0-10)
|
|
1050
|
-
- User study participation interest
|
|
1051
|
-
- Email and any additional feedback
|
|
1052
|
-
|
|
1053
|
-
EXAMPLE INTERACTION:
|
|
1054
|
-
User: "sure, I'll give feedback"
|
|
1055
|
-
Claude: "Perfect! Let me open the feedback form for you."
|
|
1056
|
-
[calls tool immediately]
|
|
1057
|
-
|
|
1058
|
-
No parameters are needed - just call the tool to open the form.
|
|
1039
|
+
The form itself collects survey answers; this tool does not accept survey responses or
|
|
1040
|
+
pre-fill them. It automatically includes basic usage metadata:
|
|
1041
|
+
- tool_call_count: Number of commands made
|
|
1042
|
+
- days_using: Number of days Desktop Commander has been used
|
|
1043
|
+
- platform: Operating system (Mac/Windows/Linux)
|
|
1044
|
+
- client_id: Analytics identifier
|
|
1045
|
+
|
|
1046
|
+
No input parameters are required.
|
|
1059
1047
|
|
|
1060
1048
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
1061
1049
|
inputSchema: zodToJsonSchema(GiveFeedbackArgsSchema),
|
|
@@ -1063,39 +1051,9 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
1063
1051
|
title: "Give Feedback",
|
|
1064
1052
|
readOnlyHint: false,
|
|
1065
1053
|
openWorldHint: true,
|
|
1054
|
+
destructiveHint: false,
|
|
1066
1055
|
},
|
|
1067
1056
|
},
|
|
1068
|
-
{
|
|
1069
|
-
name: "get_prompts",
|
|
1070
|
-
description: `
|
|
1071
|
-
Retrieve a specific Desktop Commander onboarding prompt by ID and execute it.
|
|
1072
|
-
|
|
1073
|
-
SIMPLIFIED ONBOARDING V2: This tool only supports direct prompt retrieval.
|
|
1074
|
-
The onboarding system presents 5 options as a simple numbered list:
|
|
1075
|
-
|
|
1076
|
-
1. Organize my Downloads folder (promptId: 'onb2_01')
|
|
1077
|
-
2. Explain a codebase or repository (promptId: 'onb2_02')
|
|
1078
|
-
3. Create organized knowledge base (promptId: 'onb2_03')
|
|
1079
|
-
4. Analyze a data file (promptId: 'onb2_04')
|
|
1080
|
-
5. Check system health and resources (promptId: 'onb2_05')
|
|
1081
|
-
|
|
1082
|
-
USAGE:
|
|
1083
|
-
When user says "1", "2", "3", "4", or "5" from onboarding:
|
|
1084
|
-
- "1" → get_prompts(action='get_prompt', promptId='onb2_01')
|
|
1085
|
-
- "2" → get_prompts(action='get_prompt', promptId='onb2_02')
|
|
1086
|
-
- "3" → get_prompts(action='get_prompt', promptId='onb2_03')
|
|
1087
|
-
- "4" → get_prompts(action='get_prompt', promptId='onb2_04')
|
|
1088
|
-
- "5" → get_prompts(action='get_prompt', promptId='onb2_05')
|
|
1089
|
-
|
|
1090
|
-
The prompt content will be injected and execution begins immediately.
|
|
1091
|
-
|
|
1092
|
-
${CMD_PREFIX_DESCRIPTION}`,
|
|
1093
|
-
inputSchema: zodToJsonSchema(GetPromptsArgsSchema),
|
|
1094
|
-
annotations: {
|
|
1095
|
-
title: "Get Prompts",
|
|
1096
|
-
readOnlyHint: true,
|
|
1097
|
-
},
|
|
1098
|
-
}
|
|
1099
1057
|
];
|
|
1100
1058
|
// Filter tools based on current client
|
|
1101
1059
|
const filteredTools = allTools.filter(tool => shouldIncludeTool(tool.name));
|
|
@@ -1110,6 +1068,19 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
1110
1068
|
}
|
|
1111
1069
|
});
|
|
1112
1070
|
import * as handlers from './handlers/index.js';
|
|
1071
|
+
import { withoutInternalFacts } from './utils/internal-facts.js';
|
|
1072
|
+
import { stillLoadingError } from './utils/files/index.js';
|
|
1073
|
+
/**
|
|
1074
|
+
* A tool call on an Excel, DOCX or PDF file whose package is still loading
|
|
1075
|
+
* after initialize answers at once with this error (utils/files/factory.ts)
|
|
1076
|
+
* instead of loading it inside the call. Not sent to telemetry, unlike other
|
|
1077
|
+
* errors: it names the file. read_multiple_files answers per file;
|
|
1078
|
+
* get_file_info waits for the load, or loads it itself, and so does a search.
|
|
1079
|
+
*/
|
|
1080
|
+
function stillLoading(filePath, action, options) {
|
|
1081
|
+
const error = typeof filePath === 'string' ? stillLoadingError(filePath, action, options) : undefined;
|
|
1082
|
+
return error === undefined ? undefined : { content: [{ type: 'text', text: `Error: ${error}` }], isError: true };
|
|
1083
|
+
}
|
|
1113
1084
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
1114
1085
|
const args = request.params.arguments;
|
|
1115
1086
|
// Calls fired programmatically by the widget UIs (file preview, config
|
|
@@ -1119,11 +1090,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1119
1090
|
// (server_call_tool, server_read_file, server_edit_block, ...). Deliberate
|
|
1120
1091
|
// UI interactions are tracked separately via mcp_ui_event.
|
|
1121
1092
|
const isUiOriginCall = !!(args && typeof args === 'object' && args.origin === 'ui');
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1093
|
+
// Each call keeps the paths it works on, starting with its path arguments,
|
|
1094
|
+
// so telemetry can replace them whole in any error text the call produces
|
|
1095
|
+
return runWithToolCallPaths(() => {
|
|
1096
|
+
addToolCallPaths(...pathArguments(args));
|
|
1097
|
+
if (isUiOriginCall) {
|
|
1098
|
+
return runInUiOriginCallContext(() => handleCallToolRequest(request));
|
|
1099
|
+
}
|
|
1100
|
+
return handleCallToolRequest(request);
|
|
1101
|
+
});
|
|
1126
1102
|
});
|
|
1103
|
+
/** The values of the tool arguments that hold paths (path, paths, file_path, outputPath, source, destination, shell, ...). */
|
|
1104
|
+
function pathArguments(args) {
|
|
1105
|
+
if (!args || typeof args !== 'object')
|
|
1106
|
+
return [];
|
|
1107
|
+
return Object.entries(args)
|
|
1108
|
+
.filter(([key]) => /path/i.test(key) || key === 'source' || key === 'destination' || key === 'shell')
|
|
1109
|
+
.map(([, value]) => value);
|
|
1110
|
+
}
|
|
1127
1111
|
async function handleCallToolRequest(request) {
|
|
1128
1112
|
const { name, arguments: args } = request.params;
|
|
1129
1113
|
const startTime = Date.now();
|
|
@@ -1165,17 +1149,6 @@ async function handleCallToolRequest(request) {
|
|
|
1165
1149
|
if (name === 'set_config_value' && args && typeof args === 'object' && 'key' in args) {
|
|
1166
1150
|
telemetryData.set_config_value_key_name = args.key;
|
|
1167
1151
|
}
|
|
1168
|
-
if (name === 'get_prompts' && args && typeof args === 'object') {
|
|
1169
|
-
const promptArgs = args;
|
|
1170
|
-
telemetryData.action = promptArgs.action;
|
|
1171
|
-
if (promptArgs.category) {
|
|
1172
|
-
telemetryData.category = promptArgs.category;
|
|
1173
|
-
telemetryData.has_category_filter = true;
|
|
1174
|
-
}
|
|
1175
|
-
if (promptArgs.promptId) {
|
|
1176
|
-
telemetryData.prompt_id = promptArgs.promptId;
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
1152
|
// Track tool call
|
|
1180
1153
|
trackToolCall(name, args);
|
|
1181
1154
|
// Using a more structured approach with dedicated handlers
|
|
@@ -1218,50 +1191,6 @@ async function handleCallToolRequest(request) {
|
|
|
1218
1191
|
};
|
|
1219
1192
|
}
|
|
1220
1193
|
break;
|
|
1221
|
-
case "get_prompts":
|
|
1222
|
-
try {
|
|
1223
|
-
result = await getPrompts(args || {});
|
|
1224
|
-
// Capture detailed analytics for all successful get_prompts actions
|
|
1225
|
-
if (args && typeof args === 'object' && !result.isError) {
|
|
1226
|
-
const action = args.action;
|
|
1227
|
-
try {
|
|
1228
|
-
if (action === 'get_prompt' && args.promptId) {
|
|
1229
|
-
// Existing get_prompt analytics
|
|
1230
|
-
const { loadPromptsData } = await import('./tools/prompts.js');
|
|
1231
|
-
const promptsData = await loadPromptsData();
|
|
1232
|
-
const prompt = promptsData.prompts.find(p => p.id === args.promptId);
|
|
1233
|
-
if (prompt) {
|
|
1234
|
-
await capture('server_get_prompt', {
|
|
1235
|
-
prompt_id: prompt.id,
|
|
1236
|
-
prompt_title: prompt.title,
|
|
1237
|
-
category: prompt.categories[0] || 'uncategorized',
|
|
1238
|
-
author: prompt.author,
|
|
1239
|
-
verified: prompt.verified,
|
|
1240
|
-
// Temporarily disabled for privacy review - Dec 2025
|
|
1241
|
-
// anonymous_use_case: (args as any).anonymous_user_use_case || null
|
|
1242
|
-
});
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
catch (error) {
|
|
1247
|
-
// Don't fail the request if analytics fail
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
// Track if user used get_prompts after seeing onboarding invitation (for state management only)
|
|
1251
|
-
const onboardingState = await usageTracker.getOnboardingState();
|
|
1252
|
-
if (onboardingState.attemptsShown > 0 && !onboardingState.promptsUsed) {
|
|
1253
|
-
// Mark that they used prompts after seeing onboarding (stops future onboarding messages)
|
|
1254
|
-
await usageTracker.markOnboardingPromptsUsed();
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
catch (error) {
|
|
1258
|
-
capture('server_request_error', { message: `Error in get_prompts handler: ${error}` });
|
|
1259
|
-
result = {
|
|
1260
|
-
content: [{ type: "text", text: `Error: Failed to retrieve prompts` }],
|
|
1261
|
-
isError: true,
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
break;
|
|
1265
1194
|
case "get_recent_tool_calls":
|
|
1266
1195
|
try {
|
|
1267
1196
|
result = await handlers.handleGetRecentToolCalls(args);
|
|
@@ -1324,17 +1253,22 @@ async function handleCallToolRequest(request) {
|
|
|
1324
1253
|
// Note: REPL functionality removed in favor of using general terminal commands
|
|
1325
1254
|
// Filesystem tools
|
|
1326
1255
|
case "read_file":
|
|
1327
|
-
result = await handlers.handleReadFile(args);
|
|
1256
|
+
result = stillLoading(args?.path, 'read', { isUrl: args?.isUrl === true }) ?? await handlers.handleReadFile(args);
|
|
1328
1257
|
break;
|
|
1329
1258
|
case "read_multiple_files":
|
|
1330
|
-
result = await handlers.handleReadMultipleFiles(args);
|
|
1259
|
+
result = await handlers.handleReadMultipleFiles(args, (filePath) => stillLoadingError(filePath, 'read'));
|
|
1331
1260
|
break;
|
|
1332
1261
|
case "write_file":
|
|
1333
|
-
result = await handlers.handleWriteFile(args);
|
|
1262
|
+
result = stillLoading(args?.path, 'write') ?? await handlers.handleWriteFile(args);
|
|
1334
1263
|
break;
|
|
1335
|
-
case "write_pdf":
|
|
1336
|
-
|
|
1264
|
+
case "write_pdf": {
|
|
1265
|
+
// Markdown (a new PDF) or page edits, read as the tool reads them;
|
|
1266
|
+
// arguments the tool refuses get its own error
|
|
1267
|
+
const parsed = WritePdfArgsSchema.safeParse(args);
|
|
1268
|
+
const action = parsed.success && typeof parsed.data.content === 'string' ? 'write' : 'edit';
|
|
1269
|
+
result = (parsed.success ? stillLoading(parsed.data.path, action, { isPdf: true }) : undefined) ?? await handlers.handleWritePdf(args);
|
|
1337
1270
|
break;
|
|
1271
|
+
}
|
|
1338
1272
|
case "create_directory":
|
|
1339
1273
|
result = await handlers.handleCreateDirectory(args);
|
|
1340
1274
|
break;
|
|
@@ -1360,7 +1294,7 @@ async function handleCallToolRequest(request) {
|
|
|
1360
1294
|
result = await handlers.handleGetFileInfo(args);
|
|
1361
1295
|
break;
|
|
1362
1296
|
case "edit_block":
|
|
1363
|
-
result = await handlers.handleEditBlock(args);
|
|
1297
|
+
result = stillLoading(args?.file_path, 'edit') ?? await handlers.handleEditBlock(args);
|
|
1364
1298
|
break;
|
|
1365
1299
|
default:
|
|
1366
1300
|
capture('server_unknown_tool', { name });
|
|
@@ -1369,6 +1303,8 @@ async function handleCallToolRequest(request) {
|
|
|
1369
1303
|
isError: true,
|
|
1370
1304
|
};
|
|
1371
1305
|
}
|
|
1306
|
+
// What the client receives (and the history records): facts kept internal are dropped
|
|
1307
|
+
result = withoutInternalFacts(name, result);
|
|
1372
1308
|
// Add tool call to history (exclude only get_recent_tool_calls to prevent recursion)
|
|
1373
1309
|
const duration = Date.now() - startTime;
|
|
1374
1310
|
isError = !!result.isError;
|
|
@@ -1390,40 +1326,6 @@ async function handleCallToolRequest(request) {
|
|
|
1390
1326
|
else {
|
|
1391
1327
|
await usageTracker.trackSuccess(name);
|
|
1392
1328
|
console.log(`[FEEDBACK DEBUG] Tool ${name} succeeded, checking feedback...`);
|
|
1393
|
-
// Check if should show onboarding (before feedback - first-time users are priority)
|
|
1394
|
-
const shouldShowOnboarding = await usageTracker.shouldShowOnboarding();
|
|
1395
|
-
console.log(`[ONBOARDING DEBUG] Should show onboarding: ${shouldShowOnboarding}`);
|
|
1396
|
-
if (shouldShowOnboarding) {
|
|
1397
|
-
console.log(`[ONBOARDING DEBUG] Generating onboarding message...`);
|
|
1398
|
-
const onboardingResult = await usageTracker.getOnboardingMessage();
|
|
1399
|
-
console.log(`[ONBOARDING DEBUG] Generated variant: ${onboardingResult.variant}`);
|
|
1400
|
-
// Capture onboarding prompt injection event
|
|
1401
|
-
const stats = await usageTracker.getStats();
|
|
1402
|
-
await capture('server_onboarding_shown', {
|
|
1403
|
-
trigger_tool: name,
|
|
1404
|
-
total_calls: stats.totalToolCalls,
|
|
1405
|
-
successful_calls: stats.successfulCalls,
|
|
1406
|
-
days_since_first_use: Math.floor((Date.now() - stats.firstUsed) / (1000 * 60 * 60 * 24)),
|
|
1407
|
-
total_sessions: stats.totalSessions,
|
|
1408
|
-
message_variant: onboardingResult.variant
|
|
1409
|
-
});
|
|
1410
|
-
// Inject onboarding message for the LLM
|
|
1411
|
-
if (result.content && result.content.length > 0 && result.content[0].type === "text") {
|
|
1412
|
-
const currentContent = result.content[0].text || '';
|
|
1413
|
-
result.content[0].text = `${currentContent}${onboardingResult.message}`;
|
|
1414
|
-
}
|
|
1415
|
-
else {
|
|
1416
|
-
result.content = [
|
|
1417
|
-
...(result.content || []),
|
|
1418
|
-
{
|
|
1419
|
-
type: "text",
|
|
1420
|
-
text: onboardingResult.message
|
|
1421
|
-
}
|
|
1422
|
-
];
|
|
1423
|
-
}
|
|
1424
|
-
// Mark that we've shown onboarding (to prevent spam)
|
|
1425
|
-
await usageTracker.markOnboardingShown(onboardingResult.variant);
|
|
1426
|
-
}
|
|
1427
1329
|
// Check if should prompt for feedback (only on successful operations)
|
|
1428
1330
|
const shouldPrompt = await usageTracker.shouldPromptForFeedback();
|
|
1429
1331
|
console.log(`[FEEDBACK DEBUG] Should prompt for feedback: ${shouldPrompt}`);
|