@wonderwhy-er/desktop-commander 0.2.22 → 0.2.24

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 (60) hide show
  1. package/README.md +14 -55
  2. package/dist/custom-stdio.d.ts +1 -0
  3. package/dist/custom-stdio.js +19 -0
  4. package/dist/handlers/filesystem-handlers.d.ts +4 -0
  5. package/dist/handlers/filesystem-handlers.js +120 -14
  6. package/dist/handlers/node-handlers.d.ts +6 -0
  7. package/dist/handlers/node-handlers.js +73 -0
  8. package/dist/index.js +5 -3
  9. package/dist/search-manager.d.ts +25 -0
  10. package/dist/search-manager.js +212 -0
  11. package/dist/server.js +161 -107
  12. package/dist/terminal-manager.d.ts +56 -2
  13. package/dist/terminal-manager.js +169 -13
  14. package/dist/tools/edit.d.ts +28 -4
  15. package/dist/tools/edit.js +87 -4
  16. package/dist/tools/filesystem.d.ts +23 -12
  17. package/dist/tools/filesystem.js +201 -416
  18. package/dist/tools/improved-process-tools.d.ts +2 -2
  19. package/dist/tools/improved-process-tools.js +244 -214
  20. package/dist/tools/mime-types.d.ts +1 -0
  21. package/dist/tools/mime-types.js +7 -0
  22. package/dist/tools/pdf/extract-images.d.ts +34 -0
  23. package/dist/tools/pdf/extract-images.js +132 -0
  24. package/dist/tools/pdf/index.d.ts +6 -0
  25. package/dist/tools/pdf/index.js +3 -0
  26. package/dist/tools/pdf/lib/pdf2md.d.ts +36 -0
  27. package/dist/tools/pdf/lib/pdf2md.js +76 -0
  28. package/dist/tools/pdf/manipulations.d.ts +13 -0
  29. package/dist/tools/pdf/manipulations.js +96 -0
  30. package/dist/tools/pdf/markdown.d.ts +7 -0
  31. package/dist/tools/pdf/markdown.js +37 -0
  32. package/dist/tools/pdf/utils.d.ts +12 -0
  33. package/dist/tools/pdf/utils.js +34 -0
  34. package/dist/tools/prompts.js +0 -10
  35. package/dist/tools/schemas.d.ts +167 -12
  36. package/dist/tools/schemas.js +54 -5
  37. package/dist/types.d.ts +2 -1
  38. package/dist/utils/feature-flags.js +7 -4
  39. package/dist/utils/files/base.d.ts +167 -0
  40. package/dist/utils/files/base.js +5 -0
  41. package/dist/utils/files/binary.d.ts +21 -0
  42. package/dist/utils/files/binary.js +65 -0
  43. package/dist/utils/files/excel.d.ts +24 -0
  44. package/dist/utils/files/excel.js +416 -0
  45. package/dist/utils/files/factory.d.ts +40 -0
  46. package/dist/utils/files/factory.js +101 -0
  47. package/dist/utils/files/image.d.ts +21 -0
  48. package/dist/utils/files/image.js +78 -0
  49. package/dist/utils/files/index.d.ts +10 -0
  50. package/dist/utils/files/index.js +13 -0
  51. package/dist/utils/files/pdf.d.ts +32 -0
  52. package/dist/utils/files/pdf.js +142 -0
  53. package/dist/utils/files/text.d.ts +63 -0
  54. package/dist/utils/files/text.js +357 -0
  55. package/dist/utils/ripgrep-resolver.js +3 -2
  56. package/dist/utils/system-info.d.ts +5 -0
  57. package/dist/utils/system-info.js +71 -3
  58. package/dist/version.d.ts +1 -1
  59. package/dist/version.js +1 -1
  60. package/package.json +14 -3
package/dist/server.js CHANGED
@@ -8,7 +8,7 @@ const OS_GUIDANCE = getOSSpecificGuidance(SYSTEM_INFO);
8
8
  const DEV_TOOL_GUIDANCE = getDevelopmentToolGuidance(SYSTEM_INFO);
9
9
  const PATH_GUIDANCE = `IMPORTANT: ${getPathGuidance(SYSTEM_INFO)} Relative paths may fail as they depend on the current working directory. Tilde paths (~/...) might not work in all contexts. Unless the user explicitly asks for relative paths, use absolute paths.`;
10
10
  const CMD_PREFIX_DESCRIPTION = `This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.`;
11
- import { StartProcessArgsSchema, ReadProcessOutputArgsSchema, InteractWithProcessArgsSchema, ForceTerminateArgsSchema, ListSessionsArgsSchema, KillProcessArgsSchema, ReadFileArgsSchema, ReadMultipleFilesArgsSchema, WriteFileArgsSchema, CreateDirectoryArgsSchema, ListDirectoryArgsSchema, MoveFileArgsSchema, GetFileInfoArgsSchema, GetConfigArgsSchema, SetConfigValueArgsSchema, ListProcessesArgsSchema, EditBlockArgsSchema, GetUsageStatsArgsSchema, GiveFeedbackArgsSchema, StartSearchArgsSchema, GetMoreSearchResultsArgsSchema, StopSearchArgsSchema, ListSearchesArgsSchema, GetPromptsArgsSchema, GetRecentToolCallsArgsSchema, } from './tools/schemas.js';
11
+ import { StartProcessArgsSchema, ReadProcessOutputArgsSchema, InteractWithProcessArgsSchema, ForceTerminateArgsSchema, ListSessionsArgsSchema, KillProcessArgsSchema, ReadFileArgsSchema, ReadMultipleFilesArgsSchema, WriteFileArgsSchema, CreateDirectoryArgsSchema, ListDirectoryArgsSchema, MoveFileArgsSchema, GetFileInfoArgsSchema, GetConfigArgsSchema, SetConfigValueArgsSchema, ListProcessesArgsSchema, EditBlockArgsSchema, GetUsageStatsArgsSchema, GiveFeedbackArgsSchema, StartSearchArgsSchema, GetMoreSearchResultsArgsSchema, StopSearchArgsSchema, ListSearchesArgsSchema, GetPromptsArgsSchema, GetRecentToolCallsArgsSchema, WritePdfArgsSchema, } from './tools/schemas.js';
12
12
  import { getConfig, setConfigValue } from './tools/config.js';
13
13
  import { getUsageStats } from './tools/usage.js';
14
14
  import { giveFeedbackToDesktopCommander } from './tools/feedback.js';
@@ -173,7 +173,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
173
173
  {
174
174
  name: "read_file",
175
175
  description: `
176
- Read the contents of a file from the file system or a URL with optional offset and length parameters.
176
+ Read contents from files and URLs.
177
+ Read PDF files and extract content as markdown and images.
177
178
 
178
179
  Prefer this over 'execute_command' with cat/type for viewing files.
179
180
 
@@ -200,9 +201,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
200
201
  Can fetch content from URLs when isUrl parameter is set to true
201
202
  (URLs are always read in full regardless of offset/length).
202
203
 
203
- Handles text files normally and image files are returned as viewable images.
204
- Recognized image types: PNG, JPEG, GIF, WebP.
205
-
204
+ FORMAT HANDLING (by extension):
205
+ - Text: Uses offset/length for line-based pagination
206
+ - Excel (.xlsx, .xls, .xlsm): Returns JSON 2D array
207
+ * sheet: "Sheet1" (name) or "0" (index as string, 0-based)
208
+ * range: ALWAYS use FROM:TO format (e.g., "A1:D100", "C1:C1", "B2:B50")
209
+ * offset/length work as row pagination (optional fallback)
210
+ - Images (PNG, JPEG, GIF, WebP): Base64 encoded viewable content
211
+ - PDF: Extracts text content as markdown with page structure
212
+ * offset/length work as page pagination (0-based)
213
+ * Includes embedded images when available
214
+
206
215
  ${PATH_GUIDANCE}
207
216
  ${CMD_PREFIX_DESCRIPTION}`,
208
217
  inputSchema: zodToJsonSchema(ReadFileArgsSchema),
@@ -235,7 +244,9 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
235
244
  {
236
245
  name: "write_file",
237
246
  description: `
238
- Write or append to file contents.
247
+ Write or append to file contents.
248
+
249
+ IMPORTANT: DO NOT use this tool to create PDF files. Use 'write_pdf' for all PDF creation tasks.
239
250
 
240
251
  CHUNKING IS STANDARD PRACTICE: Always write files in chunks of 25-30 lines maximum.
241
252
  This is the normal, recommended way to write files - not an emergency measure.
@@ -251,16 +262,21 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
251
262
  1. Any file expected to be longer than 25-30 lines
252
263
  2. When writing multiple files in sequence
253
264
  3. When creating documentation, code files, or configuration files
254
-
265
+
255
266
  HANDLING CONTINUATION ("Continue" prompts):
256
267
  If user asks to "Continue" after an incomplete operation:
257
268
  1. Read the file to see what was successfully written
258
269
  2. Continue writing ONLY the remaining content using {mode: 'append'}
259
270
  3. Keep chunks to 25-30 lines each
260
-
271
+
272
+ FORMAT HANDLING (by extension):
273
+ - Text files: String content
274
+ - Excel (.xlsx, .xls, .xlsm): JSON 2D array or {"SheetName": [[...]]}
275
+ Example: '[["Name","Age"],["Alice",30]]'
276
+
261
277
  Files over 50 lines will generate performance notes but are still written successfully.
262
278
  Only works within allowed directories.
263
-
279
+
264
280
  ${PATH_GUIDANCE}
265
281
  ${CMD_PREFIX_DESCRIPTION}`,
266
282
  inputSchema: zodToJsonSchema(WriteFileArgsSchema),
@@ -271,6 +287,68 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
271
287
  openWorldHint: false,
272
288
  },
273
289
  },
290
+ {
291
+ name: "write_pdf",
292
+ description: `
293
+ Create a new PDF file or modify an existing one.
294
+
295
+ THIS IS THE ONLY TOOL FOR CREATING AND MODIFYING PDF FILES.
296
+
297
+ RULES ABOUT FILENAMES:
298
+ - When creating a new PDF, 'outputPath' MUST be provided and MUST use a new unique filename (e.g., "result_01.pdf", "analysis_2025_01.pdf", etc.).
299
+
300
+ MODES:
301
+ 1. CREATE NEW PDF:
302
+ - Pass a markdown string as 'content'.
303
+ write_pdf(path="doc.pdf", content="# Title\\n\\nBody text...")
304
+
305
+ 2. MODIFY EXISTING PDF:
306
+ - Pass array of operations as 'content'.
307
+ - NEVER overwrite the original file.
308
+ - ALWAYS provide a new filename in 'outputPath'.
309
+ - After modifying, show original file path and new file path to user.
310
+
311
+ write_pdf(path="doc.pdf", content=[
312
+ { type: "delete", pageIndexes: [0, 2] },
313
+ { type: "insert", pageIndex: 1, markdown: "# New Page" }
314
+ ])
315
+
316
+ OPERATIONS:
317
+ - delete: Remove pages by 0-based index.
318
+ { type: "delete", pageIndexes: [0, 1, 5] }
319
+
320
+ - insert: Add pages at a specific 0-based index.
321
+ { type: "insert", pageIndex: 0, markdown: "..." }
322
+ { type: "insert", pageIndex: 5, sourcePdfPath: "/path/to/source.pdf" }
323
+
324
+ PAGE BREAKS:
325
+ To force a page break, use this HTML element:
326
+ <div style="page-break-before: always;"></div>
327
+
328
+ Example:
329
+ "# Page 1\\n\\n<div style=\\"page-break-before: always;\\"></div>\\n\\n# Page 2"
330
+
331
+ ADVANCED STYLING:
332
+ HTML/CSS and inline SVG are supported for:
333
+ - Text styling: colors, sizes, alignment, highlights
334
+ - Boxes: borders, backgrounds, padding, rounded corners
335
+ - SVG graphics: charts, diagrams, icons, shapes
336
+ - Images: <img src="/absolute/path/image.jpg" width="300" /> or ![alt](/path/image.jpg)
337
+
338
+ Supports standard markdown features including headers, lists, code blocks, tables, and basic formatting.
339
+
340
+ Only works within allowed directories.
341
+
342
+ ${PATH_GUIDANCE}
343
+ ${CMD_PREFIX_DESCRIPTION}`,
344
+ inputSchema: zodToJsonSchema(WritePdfArgsSchema),
345
+ annotations: {
346
+ title: "Write/Modify PDF",
347
+ readOnlyHint: false,
348
+ destructiveHint: true,
349
+ openWorldHint: false,
350
+ },
351
+ },
274
352
  {
275
353
  name: "create_directory",
276
354
  description: `
@@ -489,13 +567,14 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
489
567
  Retrieve detailed metadata about a file or directory including:
490
568
  - size
491
569
  - creation time
492
- - last modified time
570
+ - last modified time
493
571
  - permissions
494
572
  - type
495
573
  - lineCount (for text files)
496
574
  - lastLine (zero-indexed number of last line, for text files)
497
575
  - appendPosition (line number for appending, for text files)
498
-
576
+ - sheets (for Excel files - array of {name, rowCount, colCount})
577
+
499
578
  Only works within allowed directories.
500
579
 
501
580
  ${PATH_GUIDANCE}
@@ -507,45 +586,54 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
507
586
  },
508
587
  },
509
588
  // Note: list_allowed_directories removed - use get_config to check allowedDirectories
510
- // Text editing tools
589
+ // Editing tools
511
590
  {
512
591
  name: "edit_block",
513
592
  description: `
514
- Apply surgical text replacements to files.
515
-
593
+ Apply surgical edits to files.
594
+
516
595
  BEST PRACTICE: Make multiple small, focused edits rather than one large edit.
517
- Each edit_block call should change only what needs to be changed - include just enough
596
+ Each edit_block call should change only what needs to be changed - include just enough
518
597
  context to uniquely identify the text being modified.
519
-
598
+
599
+ FORMAT HANDLING (by extension):
600
+
601
+ EXCEL FILES (.xlsx, .xls, .xlsm) - Range Update mode:
602
+ Takes:
603
+ - file_path: Path to the Excel file
604
+ - range: ALWAYS use FROM:TO format - "SheetName!A1:C10" or "SheetName!C1:C1"
605
+ - content: 2D array, e.g., [["H1","H2"],["R1","R2"]]
606
+
607
+ TEXT FILES - Find/Replace mode:
520
608
  Takes:
521
609
  - file_path: Path to the file to edit
522
610
  - old_string: Text to replace
523
611
  - new_string: Replacement text
524
- - expected_replacements: Optional parameter for number of replacements
525
-
612
+ - expected_replacements: Optional number of replacements (default: 1)
613
+
526
614
  By default, replaces only ONE occurrence of the search text.
527
- To replace multiple occurrences, provide the expected_replacements parameter with
615
+ To replace multiple occurrences, provide expected_replacements with
528
616
  the exact number of matches expected.
529
-
617
+
530
618
  UNIQUENESS REQUIREMENT: When expected_replacements=1 (default), include the minimal
531
619
  amount of context necessary (typically 1-3 lines) before and after the change point,
532
620
  with exact whitespace and indentation.
533
-
621
+
534
622
  When editing multiple sections, make separate edit_block calls for each distinct change
535
623
  rather than one large replacement.
536
-
624
+
537
625
  When a close but non-exact match is found, a character-level diff is shown in the format:
538
626
  common_prefix{-removed-}{+added+}common_suffix to help you identify what's different.
539
-
627
+
540
628
  Similar to write_file, there is a configurable line limit (fileWriteLineLimit) that warns
541
629
  if the edited file exceeds this limit. If this happens, consider breaking your edits into
542
630
  smaller, more focused changes.
543
-
631
+
544
632
  ${PATH_GUIDANCE}
545
633
  ${CMD_PREFIX_DESCRIPTION}`,
546
634
  inputSchema: zodToJsonSchema(EditBlockArgsSchema),
547
635
  annotations: {
548
- title: "Edit Text Block",
636
+ title: "Edit Block",
549
637
  readOnlyHint: false,
550
638
  destructiveHint: true,
551
639
  openWorldHint: false,
@@ -574,7 +662,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
574
662
 
575
663
  COMMON FILE ANALYSIS PATTERNS:
576
664
  • start_process("python3 -i") → Python REPL for data analysis (RECOMMENDED)
577
- • start_process("node -i") → Node.js for JSON processing
665
+ • start_process("node -i") → Node.js REPL for JSON processing
666
+ • start_process("node:local") → Node.js on MCP server (stateless, ES imports, all code in one call)
578
667
  • start_process("cut -d',' -f1 file.csv | sort | uniq -c") → Quick CSV analysis
579
668
  • start_process("wc -l /path/file.csv") → Line counting
580
669
  • start_process("head -10 /path/file.csv") → File preview
@@ -583,12 +672,15 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
583
672
  For PDF, Excel, Word, archives, databases, and other binary formats, use process tools with appropriate libraries or command-line utilities.
584
673
 
585
674
  INTERACTIVE PROCESSES FOR DATA ANALYSIS:
586
- 1. start_process("python3 -i") - Start Python REPL for data work
587
- 2. start_process("node -i") - Start Node.js REPL for JSON/JS
588
- 3. start_process("bash") - Start interactive bash shell
675
+ For code/calculations, use in this priority order:
676
+ 1. start_process("python3 -i") - Python REPL (preferred)
677
+ 2. start_process("node -i") - Node.js REPL (when Python unavailable)
678
+ 3. start_process("node:local") - Node.js fallback (when node -i fails)
589
679
  4. Use interact_with_process() to send commands
590
680
  5. Use read_process_output() to get responses
591
-
681
+ When Python is unavailable, prefer Node.js over shell for calculations.
682
+ Node.js: Always use ES import syntax (import x from 'y'), not require().
683
+
592
684
  SMART DETECTION:
593
685
  - Detects REPL prompts (>>>, >, $, etc.)
594
686
  - Identifies when process is waiting for input
@@ -624,35 +716,37 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
624
716
  {
625
717
  name: "read_process_output",
626
718
  description: `
627
- Read output from a running process with intelligent completion detection.
719
+ Read output from a running process with file-like pagination support.
628
720
 
629
- Automatically detects when process is ready for more input instead of timing out.
721
+ Supports partial output reading with offset and length parameters (like read_file):
722
+ - 'offset' (start line, default: 0)
723
+ * offset=0: Read NEW output since last read (default, like old behavior)
724
+ * Positive: Read from absolute line position
725
+ * Negative: Read last N lines from end (tail behavior)
726
+ - 'length' (max lines to read, default: configurable via 'fileReadLineLimit' setting)
630
727
 
631
- SMART FEATURES:
632
- - Early exit when REPL shows prompt (>>>, >, etc.)
633
- - Detects process completion vs still running
634
- - Prevents hanging on interactive prompts
635
- - Clear status messages about process state
728
+ Examples:
729
+ - offset: 0, length: 100 → First 100 NEW lines since last read
730
+ - offset: 0 → All new lines (respects config limit)
731
+ - offset: 500, length: 50 → Lines 500-549 (absolute position)
732
+ - offset: -20 → Last 20 lines (tail)
733
+ - offset: -50, length: 10 → Start 50 from end, read 10 lines
636
734
 
637
- REPL USAGE:
638
- - Stops immediately when REPL prompt detected
639
- - Shows clear status: waiting for input vs finished
640
- - Shorter timeouts needed due to smart detection
641
- - Works with Python, Node.js, R, Julia, etc.
735
+ OUTPUT PROTECTION:
736
+ - Uses same fileReadLineLimit as read_file (default: 1000 lines)
737
+ - Returns status like: [Reading 100 lines from line 0 (total: 5000 lines, 4900 remaining)]
738
+ - Prevents context overflow from verbose processes
739
+
740
+ SMART FEATURES:
741
+ - For offset=0, waits up to timeout_ms for new output to arrive
742
+ - Detects REPL prompts and process completion
743
+ - Shows process state (waiting for input, finished, etc.)
642
744
 
643
745
  DETECTION STATES:
644
746
  Process waiting for input (ready for interact_with_process)
645
747
  Process finished execution
646
748
  Timeout reached (may still be running)
647
749
 
648
- PERFORMANCE DEBUGGING (verbose_timing parameter):
649
- Set verbose_timing: true to get detailed timing information including:
650
- - Exit reason (early_exit_quick_pattern, early_exit_periodic_check, process_finished, timeout)
651
- - Total duration and time to first output
652
- - Complete timeline of all output events with timestamps
653
- - Which detection mechanism triggered early exit
654
- Use this to identify when timeouts could be reduced or detection patterns improved.
655
-
656
750
  ${CMD_PREFIX_DESCRIPTION}`,
657
751
  inputSchema: zodToJsonSchema(ReadProcessOutputArgsSchema),
658
752
  annotations: {
@@ -692,7 +786,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
692
786
 
693
787
  SUPPORTED REPLs:
694
788
  - Python: python3 -i (RECOMMENDED for data analysis)
695
- - Node.js: node -i
789
+ - Node.js: node -i
696
790
  - R: R
697
791
  - Julia: julia
698
792
  - Shell: bash, zsh
@@ -781,9 +875,9 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
781
875
  name: "kill_process",
782
876
  description: `
783
877
  Terminate a running process by PID.
784
-
878
+
785
879
  Use with caution as this will forcefully terminate the specified process.
786
-
880
+
787
881
  ${CMD_PREFIX_DESCRIPTION}`,
788
882
  inputSchema: zodToJsonSchema(KillProcessArgsSchema),
789
883
  annotations: {
@@ -881,27 +975,14 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
881
975
 
882
976
  USAGE:
883
977
  When user says "1", "2", "3", "4", or "5" from onboarding:
884
- - "1" → get_prompts(action='get_prompt', promptId='onb2_01', anonymous_user_use_case='...')
885
- - "2" → get_prompts(action='get_prompt', promptId='onb2_02', anonymous_user_use_case='...')
886
- - "3" → get_prompts(action='get_prompt', promptId='onb2_03', anonymous_user_use_case='...')
887
- - "4" → get_prompts(action='get_prompt', promptId='onb2_04', anonymous_user_use_case='...')
888
- - "5" → get_prompts(action='get_prompt', promptId='onb2_05', anonymous_user_use_case='...')
889
-
890
- ANONYMOUS USE CASE (REQUIRED):
891
- Infer what GOAL or PROBLEM the user is trying to solve from conversation history.
892
- Focus on the job-to-be-done, not just what they were doing.
893
-
894
- GOOD (problem/goal focused):
895
- "automating backup workflow", "converting PDFs to CSV", "debugging test failures",
896
- "organizing project files", "monitoring server logs", "extracting data from documents"
897
-
898
- BAD (too vague or contains PII):
899
- "using Desktop Commander", "working on John's project", "fixing acme-corp bug"
900
-
901
- If unclear from context, use: "exploring tool capabilities"
978
+ - "1" → get_prompts(action='get_prompt', promptId='onb2_01')
979
+ - "2" → get_prompts(action='get_prompt', promptId='onb2_02')
980
+ - "3" → get_prompts(action='get_prompt', promptId='onb2_03')
981
+ - "4" → get_prompts(action='get_prompt', promptId='onb2_04')
982
+ - "5" → get_prompts(action='get_prompt', promptId='onb2_05')
902
983
 
903
984
  The prompt content will be injected and execution begins immediately.
904
-
985
+
905
986
  ${CMD_PREFIX_DESCRIPTION}`,
906
987
  inputSchema: zodToJsonSchema(GetPromptsArgsSchema),
907
988
  }
@@ -940,6 +1021,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
940
1021
  }
941
1022
  }
942
1023
  capture_call_tool('server_call_tool', telemetryData);
1024
+ // Log every tool request name
1025
+ // logger.info(`Tool request: ${name}`, { toolName: name, timestamp: new Date().toISOString() });
943
1026
  // Track tool call
944
1027
  trackToolCall(name, args);
945
1028
  // Using a more structured approach with dedicated handlers
@@ -1000,44 +1083,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1000
1083
  prompt_title: prompt.title,
1001
1084
  category: prompt.categories[0] || 'uncategorized',
1002
1085
  author: prompt.author,
1003
- verified: prompt.verified
1086
+ verified: prompt.verified,
1087
+ // Temporarily disabled for privacy review - Dec 2025
1088
+ // anonymous_use_case: (args as any).anonymous_user_use_case || null
1004
1089
  });
1005
1090
  }
1006
1091
  }
1007
- else if (action === 'list_categories') {
1008
- // New analytics for category browsing
1009
- const { loadPromptsData } = await import('./tools/prompts.js');
1010
- const promptsData = await loadPromptsData();
1011
- // Extract unique categories and count prompts in each
1012
- const categoryMap = new Map();
1013
- promptsData.prompts.forEach(prompt => {
1014
- prompt.categories.forEach(category => {
1015
- categoryMap.set(category, (categoryMap.get(category) || 0) + 1);
1016
- });
1017
- });
1018
- await capture('server_list_prompt_categories', {
1019
- total_categories: categoryMap.size,
1020
- total_prompts: promptsData.prompts.length,
1021
- categories_available: Array.from(categoryMap.keys())
1022
- });
1023
- }
1024
- else if (action === 'list_prompts') {
1025
- // New analytics for prompt list browsing
1026
- const { loadPromptsData } = await import('./tools/prompts.js');
1027
- const promptsData = await loadPromptsData();
1028
- const category = args.category;
1029
- let filteredPrompts = promptsData.prompts;
1030
- if (category) {
1031
- filteredPrompts = promptsData.prompts.filter(prompt => prompt.categories.includes(category));
1032
- }
1033
- await capture('server_list_category_prompts', {
1034
- category_filter: category || 'all',
1035
- has_category_filter: !!category,
1036
- prompts_shown: filteredPrompts.length,
1037
- total_prompts_available: promptsData.prompts.length,
1038
- prompt_ids_shown: filteredPrompts.map(p => p.id)
1039
- });
1040
- }
1041
1092
  }
1042
1093
  catch (error) {
1043
1094
  // Don't fail the request if analytics fail
@@ -1116,6 +1167,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1116
1167
  case "write_file":
1117
1168
  result = await handlers.handleWriteFile(args);
1118
1169
  break;
1170
+ case "write_pdf":
1171
+ result = await handlers.handleWritePdf(args);
1172
+ break;
1119
1173
  case "create_directory":
1120
1174
  result = await handlers.handleCreateDirectory(args);
1121
1175
  break;
@@ -1,11 +1,21 @@
1
1
  import { TerminalSession, CommandExecutionResult, ActiveSession } from './types.js';
2
2
  interface CompletedSession {
3
3
  pid: number;
4
- output: string;
4
+ outputLines: string[];
5
5
  exitCode: number | null;
6
6
  startTime: Date;
7
7
  endTime: Date;
8
8
  }
9
+ export interface PaginatedOutputResult {
10
+ lines: string[];
11
+ totalLines: number;
12
+ readFrom: number;
13
+ readCount: number;
14
+ remaining: number;
15
+ isComplete: boolean;
16
+ exitCode?: number | null;
17
+ runtimeMs?: number;
18
+ }
9
19
  export declare class TerminalManager {
10
20
  private sessions;
11
21
  private completedSessions;
@@ -17,7 +27,51 @@ export declare class TerminalManager {
17
27
  */
18
28
  sendInputToProcess(pid: number, input: string): boolean;
19
29
  executeCommand(command: string, timeoutMs?: number, shell?: string, collectTiming?: boolean): Promise<CommandExecutionResult>;
20
- getNewOutput(pid: number): string | null;
30
+ /**
31
+ * Append text to a session's line buffer
32
+ * Handles partial lines and newline splitting
33
+ */
34
+ private appendToLineBuffer;
35
+ /**
36
+ * Read process output with pagination (like file reading)
37
+ * @param pid Process ID
38
+ * @param offset Line offset: 0=from lastReadIndex, positive=absolute, negative=tail
39
+ * @param length Max lines to return
40
+ * @param updateReadIndex Whether to update lastReadIndex (default: true for offset=0)
41
+ */
42
+ readOutputPaginated(pid: number, offset?: number, length?: number): PaginatedOutputResult | null;
43
+ /**
44
+ * Internal helper to read from a line buffer with offset/length
45
+ */
46
+ private readFromLineBuffer;
47
+ /**
48
+ * Get total line count for a process
49
+ */
50
+ getOutputLineCount(pid: number): number | null;
51
+ /**
52
+ * Legacy method for backward compatibility
53
+ * Returns all new output since last read
54
+ * @param maxLines Maximum lines to return (default: 1000 for context protection)
55
+ * @deprecated Use readOutputPaginated instead
56
+ */
57
+ getNewOutput(pid: number, maxLines?: number): string | null;
58
+ /**
59
+ * Capture a snapshot of current output state for interaction tracking.
60
+ * Used by interactWithProcess to know what output existed before sending input.
61
+ */
62
+ captureOutputSnapshot(pid: number): {
63
+ totalChars: number;
64
+ lineCount: number;
65
+ } | null;
66
+ /**
67
+ * Get output that appeared since a snapshot was taken.
68
+ * This handles the case where output is appended to the last line (REPL prompts).
69
+ * Also checks completed sessions in case process finished between snapshot and poll.
70
+ */
71
+ getOutputSinceSnapshot(pid: number, snapshot: {
72
+ totalChars: number;
73
+ lineCount: number;
74
+ }): string | null;
21
75
  /**
22
76
  * Get a session by PID
23
77
  * @param pid Process ID