@wonderwhy-er/desktop-commander 0.2.42 → 0.2.44

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 (53) hide show
  1. package/dist/bootstrap.d.ts +1 -0
  2. package/dist/bootstrap.js +22 -0
  3. package/dist/config-manager.d.ts +30 -1
  4. package/dist/config-manager.js +55 -8
  5. package/dist/handlers/filesystem-handlers.js +86 -52
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +3 -0
  8. package/dist/remote-device/desktop-commander-integration.js +8 -2
  9. package/dist/remote-device/remote-channel.d.ts +15 -0
  10. package/dist/remote-device/remote-channel.js +136 -27
  11. package/dist/server.d.ts +5 -1
  12. package/dist/server.js +118 -27
  13. package/dist/terminal-manager.d.ts +18 -0
  14. package/dist/terminal-manager.js +84 -18
  15. package/dist/tools/edit.d.ts +1 -1
  16. package/dist/tools/edit.js +34 -26
  17. package/dist/tools/filesystem.d.ts +1 -0
  18. package/dist/tools/filesystem.js +23 -13
  19. package/dist/tools/fuzzySearch.d.ts +10 -20
  20. package/dist/tools/fuzzySearch.js +66 -105
  21. package/dist/tools/fuzzySearchCore.d.ts +52 -0
  22. package/dist/tools/fuzzySearchCore.js +125 -0
  23. package/dist/tools/improved-process-tools.js +8 -1
  24. package/dist/tools/schemas.d.ts +33 -1
  25. package/dist/tools/schemas.js +61 -3
  26. package/dist/types.d.ts +3 -1
  27. package/dist/ui/config-editor/config-editor-runtime.js +49 -49
  28. package/dist/ui/config-editor/src/app.js +2 -11
  29. package/dist/ui/file-preview/preview-runtime.js +147 -146
  30. package/dist/ui/file-preview/src/app.js +172 -53
  31. package/dist/ui/file-preview/src/directory-controller.js +4 -4
  32. package/dist/ui/file-preview/src/file-type-handlers.js +2 -2
  33. package/dist/ui/file-preview/src/markdown/controller.js +4 -1
  34. package/dist/ui/file-preview/src/panel-actions.js +4 -4
  35. package/dist/ui/file-preview/src/payload-utils.js +23 -7
  36. package/dist/utils/capture.d.ts +2 -0
  37. package/dist/utils/capture.js +32 -7
  38. package/dist/utils/files/base.d.ts +2 -0
  39. package/dist/utils/files/image.js +1 -1
  40. package/dist/utils/files/text.js +24 -19
  41. package/dist/utils/open-browser.d.ts +1 -1
  42. package/dist/utils/open-browser.js +5 -2
  43. package/dist/utils/unsupportedParams.d.ts +24 -0
  44. package/dist/utils/unsupportedParams.js +66 -0
  45. package/dist/utils/usageTracker.d.ts +5 -1
  46. package/dist/utils/usageTracker.js +14 -3
  47. package/dist/utils/welcome-onboarding.d.ts +1 -1
  48. package/dist/utils/welcome-onboarding.js +2 -2
  49. package/dist/utils/withTimeout.d.ts +17 -0
  50. package/dist/utils/withTimeout.js +33 -0
  51. package/dist/version.d.ts +1 -1
  52. package/dist/version.js +1 -1
  53. package/package.json +5 -1
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Pure fuzzy-search core, kept free of app imports on purpose: it runs inside
3
+ * the worker thread spawned by runFuzzySearchInWorker (fuzzySearch.ts), and
4
+ * anything imported here is loaded per worker. Telemetry is returned as data
5
+ * and captured on the main thread, which has the real client identity.
6
+ */
7
+ export interface FuzzyMatch {
8
+ start: number;
9
+ end: number;
10
+ value: string;
11
+ distance: number;
12
+ }
13
+ export interface FuzzySearchMetrics {
14
+ recursive: {
15
+ execution_time_ms: number;
16
+ text_length: number;
17
+ query_length: number;
18
+ result_distance: number;
19
+ };
20
+ iterative: {
21
+ execution_time_ms: number;
22
+ iterations: number;
23
+ segment_length: number;
24
+ query_length: number;
25
+ final_distance: number;
26
+ } | null;
27
+ }
28
+ /**
29
+ * Runs a full fuzzy search and returns the match together with the timing
30
+ * metrics that used to be captured inline.
31
+ */
32
+ export declare function runFuzzySearch(text: string, query: string): {
33
+ result: FuzzyMatch;
34
+ metrics: FuzzySearchMetrics;
35
+ };
36
+ /**
37
+ * Recursively finds the closest match to a query string within text using fuzzy matching
38
+ * @param text The text to search within
39
+ * @param query The query string to find
40
+ * @param start Start index in the text (default: 0)
41
+ * @param end End index in the text (default: text.length)
42
+ * @param parentDistance Best distance found so far (default: Infinity)
43
+ * @returns Object with start and end indices, matched value, and Levenshtein distance
44
+ */
45
+ export declare function recursiveFuzzyIndexOf(text: string, query: string, start?: number, end?: number | null, parentDistance?: number): FuzzyMatch;
46
+ /**
47
+ * Calculates the similarity ratio between two strings
48
+ * @param a First string
49
+ * @param b Second string
50
+ * @returns Similarity ratio (0-1)
51
+ */
52
+ export declare function getSimilarityRatio(a: string, b: string): number;
@@ -0,0 +1,125 @@
1
+ import { distance } from 'fastest-levenshtein';
2
+ // Set by iterativeReduction during a search (exactly one terminal call per
3
+ // search) and collected by runFuzzySearch. Single-threaded per context, so a
4
+ // module-level slot is safe.
5
+ let lastIterativeMetrics = null;
6
+ /**
7
+ * Runs a full fuzzy search and returns the match together with the timing
8
+ * metrics that used to be captured inline.
9
+ */
10
+ export function runFuzzySearch(text, query) {
11
+ const startTime = performance.now();
12
+ lastIterativeMetrics = null;
13
+ const result = recursiveFuzzyIndexOf(text, query);
14
+ return {
15
+ result,
16
+ metrics: {
17
+ recursive: {
18
+ execution_time_ms: performance.now() - startTime,
19
+ text_length: text.length,
20
+ query_length: query.length,
21
+ result_distance: result.distance
22
+ },
23
+ iterative: lastIterativeMetrics
24
+ }
25
+ };
26
+ }
27
+ /**
28
+ * Recursively finds the closest match to a query string within text using fuzzy matching
29
+ * @param text The text to search within
30
+ * @param query The query string to find
31
+ * @param start Start index in the text (default: 0)
32
+ * @param end End index in the text (default: text.length)
33
+ * @param parentDistance Best distance found so far (default: Infinity)
34
+ * @returns Object with start and end indices, matched value, and Levenshtein distance
35
+ */
36
+ export function recursiveFuzzyIndexOf(text, query, start = 0, end = null, parentDistance = Infinity) {
37
+ if (end === null)
38
+ end = text.length;
39
+ // For small text segments, use iterative approach
40
+ if (end - start <= 2 * query.length) {
41
+ return iterativeReduction(text, query, start, end, parentDistance);
42
+ }
43
+ let midPoint = start + Math.floor((end - start) / 2);
44
+ let leftEnd = Math.min(end, midPoint + query.length); // Include query length to cover overlaps
45
+ let rightStart = Math.max(start, midPoint - query.length); // Include query length to cover overlaps
46
+ // Calculate distance for current segments
47
+ let leftDistance = distance(text.substring(start, leftEnd), query);
48
+ let rightDistance = distance(text.substring(rightStart, end), query);
49
+ let bestDistance = Math.min(leftDistance, parentDistance, rightDistance);
50
+ // If parent distance is already the best, use iterative approach
51
+ if (parentDistance === bestDistance) {
52
+ return iterativeReduction(text, query, start, end, parentDistance);
53
+ }
54
+ // Recursively search the better half
55
+ if (leftDistance < rightDistance) {
56
+ return recursiveFuzzyIndexOf(text, query, start, leftEnd, bestDistance);
57
+ }
58
+ else {
59
+ return recursiveFuzzyIndexOf(text, query, rightStart, end, bestDistance);
60
+ }
61
+ }
62
+ /**
63
+ * Iteratively refines the best match by reducing the search area
64
+ * @param text The text to search within
65
+ * @param query The query string to find
66
+ * @param start Start index in the text
67
+ * @param end End index in the text
68
+ * @param parentDistance Best distance found so far
69
+ * @returns Object with start and end indices, matched value, and Levenshtein distance
70
+ */
71
+ function iterativeReduction(text, query, start, end, parentDistance) {
72
+ const startTime = performance.now();
73
+ let iterations = 0;
74
+ // Seed with the measured distance of this slice. For recursive callers
75
+ // this equals parentDistance (the parent measured exactly this slice), but
76
+ // a top-level call on text <= 2x query length arrives with Infinity, which
77
+ // made the first shrink unconditional and a position-0 match unreachable.
78
+ let bestDistance = distance(text.substring(start, end), query);
79
+ let bestStart = start;
80
+ let bestEnd = end;
81
+ // Improve start position
82
+ let nextDistance = distance(text.substring(bestStart + 1, bestEnd), query);
83
+ while (nextDistance < bestDistance) {
84
+ bestDistance = nextDistance;
85
+ bestStart++;
86
+ const smallerString = text.substring(bestStart + 1, bestEnd);
87
+ nextDistance = distance(smallerString, query);
88
+ iterations++;
89
+ }
90
+ // Improve end position
91
+ nextDistance = distance(text.substring(bestStart, bestEnd - 1), query);
92
+ while (nextDistance < bestDistance) {
93
+ bestDistance = nextDistance;
94
+ bestEnd--;
95
+ const smallerString = text.substring(bestStart, bestEnd - 1);
96
+ nextDistance = distance(smallerString, query);
97
+ iterations++;
98
+ }
99
+ lastIterativeMetrics = {
100
+ execution_time_ms: performance.now() - startTime,
101
+ iterations: iterations,
102
+ segment_length: end - start,
103
+ query_length: query.length,
104
+ final_distance: bestDistance
105
+ };
106
+ return {
107
+ start: bestStart,
108
+ end: bestEnd,
109
+ value: text.substring(bestStart, bestEnd),
110
+ distance: bestDistance
111
+ };
112
+ }
113
+ /**
114
+ * Calculates the similarity ratio between two strings
115
+ * @param a First string
116
+ * @param b Second string
117
+ * @returns Similarity ratio (0-1)
118
+ */
119
+ export function getSimilarityRatio(a, b) {
120
+ const maxLength = Math.max(a.length, b.length);
121
+ if (maxLength === 0)
122
+ return 1; // Both strings are empty
123
+ const levenshteinDistance = distance(a, b);
124
+ return 1 - (levenshteinDistance / maxLength);
125
+ }
@@ -1,4 +1,4 @@
1
- import { terminalManager } from '../terminal-manager.js';
1
+ import { terminalManager, MAX_BUFFERED_OUTPUT_CHARS } from '../terminal-manager.js';
2
2
  import { commandManager } from '../command-manager.js';
3
3
  import { StartProcessArgsSchema, ReadProcessOutputArgsSchema, InteractWithProcessArgsSchema, ForceTerminateArgsSchema } from './schemas.js';
4
4
  import { capture } from "../utils/capture.js";
@@ -293,6 +293,13 @@ export async function readProcessOutput(args) {
293
293
  // Absolute position read
294
294
  statusMessage = `[Reading ${result.readCount} lines from line ${result.readFrom} (total: ${result.totalLines} lines, ${result.remaining} remaining)]`;
295
295
  }
296
+ // Surface buffer-cap eviction so the model knows the retained output is not
297
+ // the full output and that line numbers shifted (matches the truncation
298
+ // markers used by other tools).
299
+ if (result.evictedLines && result.evictedLines > 0) {
300
+ const capMB = Math.round(MAX_BUFFERED_OUTPUT_CHARS / 1024 / 1024);
301
+ statusMessage += `\n[WARNING: output exceeded the ${capMB}MB buffer cap; the ${result.evictedLines} earliest lines were evicted and cannot be read. Line numbers and totals refer to the retained buffer only]`;
302
+ }
296
303
  // Add process state info
297
304
  let processStateMessage = '';
298
305
  if (result.isComplete) {
@@ -1,5 +1,11 @@
1
1
  import { z } from "zod";
2
- export declare const GetConfigArgsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
2
+ export declare const GetConfigArgsSchema: z.ZodObject<{
3
+ origin: z.ZodOptional<z.ZodEnum<["ui", "llm"]>>;
4
+ }, "strip", z.ZodTypeAny, {
5
+ origin?: "ui" | "llm" | undefined;
6
+ }, {
7
+ origin?: "ui" | "llm" | undefined;
8
+ }>;
3
9
  export declare const SetConfigValueArgsSchema: z.ZodObject<{
4
10
  key: z.ZodString;
5
11
  value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString, "many">, z.ZodNull]>;
@@ -19,14 +25,17 @@ export declare const StartProcessArgsSchema: z.ZodObject<{
19
25
  timeout_ms: z.ZodNumber;
20
26
  shell: z.ZodOptional<z.ZodString>;
21
27
  verbose_timing: z.ZodOptional<z.ZodBoolean>;
28
+ origin: z.ZodOptional<z.ZodEnum<["ui", "llm"]>>;
22
29
  }, "strip", z.ZodTypeAny, {
23
30
  command: string;
24
31
  timeout_ms: number;
32
+ origin?: "ui" | "llm" | undefined;
25
33
  shell?: string | undefined;
26
34
  verbose_timing?: boolean | undefined;
27
35
  }, {
28
36
  command: string;
29
37
  timeout_ms: number;
38
+ origin?: "ui" | "llm" | undefined;
30
39
  shell?: string | undefined;
31
40
  verbose_timing?: boolean | undefined;
32
41
  }>;
@@ -72,17 +81,20 @@ export declare const ReadFileArgsSchema: z.ZodObject<{
72
81
  sheet: z.ZodOptional<z.ZodString>;
73
82
  range: z.ZodOptional<z.ZodString>;
74
83
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
84
+ origin: z.ZodOptional<z.ZodEnum<["ui", "llm"]>>;
75
85
  }, "strip", z.ZodTypeAny, {
76
86
  length: number;
77
87
  path: string;
78
88
  offset: number;
79
89
  isUrl: boolean;
90
+ origin?: "ui" | "llm" | undefined;
80
91
  options?: Record<string, any> | undefined;
81
92
  sheet?: string | undefined;
82
93
  range?: string | undefined;
83
94
  }, {
84
95
  path: string;
85
96
  length?: number | undefined;
97
+ origin?: "ui" | "llm" | undefined;
86
98
  options?: Record<string, any> | undefined;
87
99
  offset?: number | undefined;
88
100
  isUrl?: boolean | undefined;
@@ -100,13 +112,16 @@ export declare const WriteFileArgsSchema: z.ZodObject<{
100
112
  path: z.ZodString;
101
113
  content: z.ZodString;
102
114
  mode: z.ZodDefault<z.ZodEnum<["rewrite", "append"]>>;
115
+ origin: z.ZodOptional<z.ZodEnum<["ui", "llm"]>>;
103
116
  }, "strip", z.ZodTypeAny, {
104
117
  path: string;
105
118
  content: string;
106
119
  mode: "rewrite" | "append";
120
+ origin?: "ui" | "llm" | undefined;
107
121
  }, {
108
122
  path: string;
109
123
  content: string;
124
+ origin?: "ui" | "llm" | undefined;
110
125
  mode?: "rewrite" | "append" | undefined;
111
126
  }>;
112
127
  export declare const PdfInsertOperationSchema: z.ZodObject<{
@@ -237,11 +252,14 @@ export declare const CreateDirectoryArgsSchema: z.ZodObject<{
237
252
  export declare const ListDirectoryArgsSchema: z.ZodObject<{
238
253
  path: z.ZodString;
239
254
  depth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
255
+ origin: z.ZodOptional<z.ZodEnum<["ui", "llm"]>>;
240
256
  }, "strip", z.ZodTypeAny, {
241
257
  path: string;
242
258
  depth: number;
259
+ origin?: "ui" | "llm" | undefined;
243
260
  }, {
244
261
  path: string;
262
+ origin?: "ui" | "llm" | undefined;
245
263
  depth?: number | undefined;
246
264
  }>;
247
265
  export declare const MoveFileArgsSchema: z.ZodObject<{
@@ -269,9 +287,11 @@ export declare const EditBlockArgsSchema: z.ZodEffects<z.ZodObject<{
269
287
  range: z.ZodOptional<z.ZodString>;
270
288
  content: z.ZodOptional<z.ZodAny>;
271
289
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
290
+ origin: z.ZodOptional<z.ZodEnum<["ui", "llm"]>>;
272
291
  }, "strip", z.ZodTypeAny, {
273
292
  file_path: string;
274
293
  expected_replacements: number;
294
+ origin?: "ui" | "llm" | undefined;
275
295
  options?: Record<string, any> | undefined;
276
296
  range?: string | undefined;
277
297
  content?: any;
@@ -279,6 +299,7 @@ export declare const EditBlockArgsSchema: z.ZodEffects<z.ZodObject<{
279
299
  new_string?: string | undefined;
280
300
  }, {
281
301
  file_path: string;
302
+ origin?: "ui" | "llm" | undefined;
282
303
  options?: Record<string, any> | undefined;
283
304
  range?: string | undefined;
284
305
  content?: any;
@@ -288,6 +309,7 @@ export declare const EditBlockArgsSchema: z.ZodEffects<z.ZodObject<{
288
309
  }>, {
289
310
  file_path: string;
290
311
  expected_replacements: number;
312
+ origin?: "ui" | "llm" | undefined;
291
313
  options?: Record<string, any> | undefined;
292
314
  range?: string | undefined;
293
315
  content?: any;
@@ -295,6 +317,7 @@ export declare const EditBlockArgsSchema: z.ZodEffects<z.ZodObject<{
295
317
  new_string?: string | undefined;
296
318
  }, {
297
319
  file_path: string;
320
+ origin?: "ui" | "llm" | undefined;
298
321
  options?: Record<string, any> | undefined;
299
322
  range?: string | undefined;
300
323
  content?: any;
@@ -335,6 +358,7 @@ export declare const StartSearchArgsSchema: z.ZodObject<{
335
358
  timeout_ms: z.ZodOptional<z.ZodNumber>;
336
359
  earlyTermination: z.ZodOptional<z.ZodBoolean>;
337
360
  literalSearch: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
361
+ origin: z.ZodOptional<z.ZodEnum<["ui", "llm"]>>;
338
362
  }, "strip", z.ZodTypeAny, {
339
363
  path: string;
340
364
  pattern: string;
@@ -343,6 +367,7 @@ export declare const StartSearchArgsSchema: z.ZodObject<{
343
367
  includeHidden: boolean;
344
368
  contextLines: number;
345
369
  literalSearch: boolean;
370
+ origin?: "ui" | "llm" | undefined;
346
371
  timeout_ms?: number | undefined;
347
372
  filePattern?: string | undefined;
348
373
  maxResults?: number | undefined;
@@ -350,6 +375,7 @@ export declare const StartSearchArgsSchema: z.ZodObject<{
350
375
  }, {
351
376
  path: string;
352
377
  pattern: string;
378
+ origin?: "ui" | "llm" | undefined;
353
379
  timeout_ms?: number | undefined;
354
380
  searchType?: "content" | "files" | undefined;
355
381
  filePattern?: string | undefined;
@@ -417,3 +443,9 @@ export declare const TrackUiEventArgsSchema: z.ZodObject<{
417
443
  params?: Record<string, string | number | boolean | null> | undefined;
418
444
  component?: string | undefined;
419
445
  }>;
446
+ /**
447
+ * Map of tool name -> argument schema, used by the dispatcher to detect and warn
448
+ * about parameters a caller sent that the tool does not support. Keep in sync
449
+ * with the tool definitions in server.ts.
450
+ */
451
+ export declare const toolArgSchemas: Record<string, z.ZodTypeAny>;
@@ -1,6 +1,10 @@
1
1
  import { z } from "zod";
2
2
  // Config tools schemas
3
- export const GetConfigArgsSchema = z.object({});
3
+ export const GetConfigArgsSchema = z.object({
4
+ // 'ui' marks calls the config-editor widget fires programmatically; they are
5
+ // excluded from tool-call telemetry (see isUiOriginCall in server.ts).
6
+ origin: z.enum(['ui', 'llm']).optional(),
7
+ });
4
8
  export const SetConfigValueArgsSchema = z.object({
5
9
  key: z.string(),
6
10
  value: z.union([
@@ -10,6 +14,7 @@ export const SetConfigValueArgsSchema = z.object({
10
14
  z.array(z.string()),
11
15
  z.null(),
12
16
  ]),
17
+ // 'ui' marks widget-fired calls; excluded from tool-call telemetry.
13
18
  origin: z.enum(['ui', 'llm']).optional(),
14
19
  });
15
20
  // Empty schemas
@@ -20,6 +25,9 @@ export const StartProcessArgsSchema = z.object({
20
25
  timeout_ms: z.number(),
21
26
  shell: z.string().optional(),
22
27
  verbose_timing: z.boolean().optional(),
28
+ // 'ui' marks widget-fired calls (e.g. open-in-folder/editor buttons);
29
+ // excluded from tool-call telemetry (see isUiOriginCall in server.ts).
30
+ origin: z.enum(['ui', 'llm']).optional(),
23
31
  });
24
32
  export const ReadProcessOutputArgsSchema = z.object({
25
33
  pid: z.number(),
@@ -43,7 +51,11 @@ export const ReadFileArgsSchema = z.object({
43
51
  length: z.number().optional().default(1000),
44
52
  sheet: z.string().optional(), // String only for MCP client compatibility (Cursor doesn't support union types in JSON Schema)
45
53
  range: z.string().optional(),
46
- options: z.record(z.any()).optional()
54
+ options: z.record(z.any()).optional(),
55
+ // Whether the call came from the file-preview UI (refresh/navigation) or the
56
+ // LLM. 'ui' calls are excluded from tool-call telemetry; see isUiOriginCall
57
+ // in server.ts.
58
+ origin: z.enum(['ui', 'llm']).optional(),
47
59
  });
48
60
  export const ReadMultipleFilesArgsSchema = z.object({
49
61
  paths: z.array(z.string()),
@@ -52,6 +64,9 @@ export const WriteFileArgsSchema = z.object({
52
64
  path: z.string(),
53
65
  content: z.string(),
54
66
  mode: z.enum(['rewrite', 'append']).default('rewrite'),
67
+ // 'ui' when fired by the file-preview UI, else 'llm'. 'ui' calls are
68
+ // excluded from tool-call telemetry; see isUiOriginCall in server.ts.
69
+ origin: z.enum(['ui', 'llm']).optional(),
55
70
  });
56
71
  // PDF modification schemas - exported for reuse
57
72
  export const PdfInsertOperationSchema = z.object({
@@ -92,6 +107,9 @@ export const CreateDirectoryArgsSchema = z.object({
92
107
  export const ListDirectoryArgsSchema = z.object({
93
108
  path: z.string(),
94
109
  depth: z.number().optional().default(2),
110
+ // 'ui' when fired by the file-preview UI, else 'llm'. 'ui' calls are
111
+ // excluded from tool-call telemetry; see isUiOriginCall in server.ts.
112
+ origin: z.enum(['ui', 'llm']).optional(),
95
113
  });
96
114
  export const MoveFileArgsSchema = z.object({
97
115
  source: z.string(),
@@ -114,7 +132,10 @@ export const EditBlockArgsSchema = z.object({
114
132
  // Structured file range rewrite (Excel, etc.)
115
133
  range: z.string().optional(),
116
134
  content: z.any().optional(),
117
- options: z.record(z.any()).optional()
135
+ options: z.record(z.any()).optional(),
136
+ // 'ui' when fired by the file-preview UI, else 'llm'. 'ui' calls are
137
+ // excluded from tool-call telemetry; see isUiOriginCall in server.ts.
138
+ origin: z.enum(['ui', 'llm']).optional(),
118
139
  }).refine(data => {
119
140
  // Helper to check if value is actually provided (not undefined, not empty string)
120
141
  const hasValue = (v) => v !== undefined && v !== '';
@@ -153,6 +174,9 @@ export const StartSearchArgsSchema = z.object({
153
174
  timeout_ms: z.number().optional(), // Match process naming convention
154
175
  earlyTermination: z.boolean().optional(), // Stop search early when exact filename match is found (default: true for files, false for content)
155
176
  literalSearch: z.boolean().optional().default(false), // Force literal string matching (-F flag) instead of regex
177
+ // 'ui' marks widget-fired calls (e.g. markdown link-target search);
178
+ // excluded from tool-call telemetry (see isUiOriginCall in server.ts).
179
+ origin: z.enum(['ui', 'llm']).optional(),
156
180
  });
157
181
  export const GetMoreSearchResultsArgsSchema = z.object({
158
182
  sessionId: z.string(),
@@ -181,3 +205,37 @@ export const TrackUiEventArgsSchema = z.object({
181
205
  component: z.string().optional().default('file_preview'),
182
206
  params: z.record(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional().default({}),
183
207
  });
208
+ /**
209
+ * Map of tool name -> argument schema, used by the dispatcher to detect and warn
210
+ * about parameters a caller sent that the tool does not support. Keep in sync
211
+ * with the tool definitions in server.ts.
212
+ */
213
+ export const toolArgSchemas = {
214
+ get_config: GetConfigArgsSchema,
215
+ set_config_value: SetConfigValueArgsSchema,
216
+ read_file: ReadFileArgsSchema,
217
+ read_multiple_files: ReadMultipleFilesArgsSchema,
218
+ write_file: WriteFileArgsSchema,
219
+ write_pdf: WritePdfArgsSchema,
220
+ create_directory: CreateDirectoryArgsSchema,
221
+ list_directory: ListDirectoryArgsSchema,
222
+ move_file: MoveFileArgsSchema,
223
+ start_search: StartSearchArgsSchema,
224
+ get_more_search_results: GetMoreSearchResultsArgsSchema,
225
+ stop_search: StopSearchArgsSchema,
226
+ list_searches: ListSearchesArgsSchema,
227
+ get_file_info: GetFileInfoArgsSchema,
228
+ edit_block: EditBlockArgsSchema,
229
+ start_process: StartProcessArgsSchema,
230
+ read_process_output: ReadProcessOutputArgsSchema,
231
+ interact_with_process: InteractWithProcessArgsSchema,
232
+ force_terminate: ForceTerminateArgsSchema,
233
+ list_sessions: ListSessionsArgsSchema,
234
+ list_processes: ListProcessesArgsSchema,
235
+ kill_process: KillProcessArgsSchema,
236
+ get_usage_stats: GetUsageStatsArgsSchema,
237
+ get_recent_tool_calls: GetRecentToolCallsArgsSchema,
238
+ give_feedback_to_desktop_commander: GiveFeedbackArgsSchema,
239
+ get_prompts: GetPromptsArgsSchema,
240
+ track_ui_event: TrackUiEventArgsSchema,
241
+ };
package/dist/types.d.ts CHANGED
@@ -18,6 +18,9 @@ export interface TerminalSession {
18
18
  lastReadIndex: number;
19
19
  isBlocked: boolean;
20
20
  startTime: Date;
21
+ bufferedChars: number;
22
+ evictedLines: number;
23
+ evictedChars: number;
21
24
  }
22
25
  export interface CommandExecutionResult {
23
26
  pid: number;
@@ -69,7 +72,6 @@ export interface FilePreviewStructuredContent {
69
72
  defaultEditorName?: string;
70
73
  defaultEditorPath?: string;
71
74
  content?: string;
72
- imageData?: string;
73
75
  mimeType?: string;
74
76
  }
75
77
  export interface ServerResult {