@wonderwhy-er/desktop-commander 0.2.52 → 0.3.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/command-manager.d.ts +7 -2
  2. package/dist/command-manager.js +16 -11
  3. package/dist/config-manager.d.ts +49 -3
  4. package/dist/config-manager.js +329 -87
  5. package/dist/config-recovery.d.ts +28 -0
  6. package/dist/config-recovery.js +81 -0
  7. package/dist/config.d.ts +1 -0
  8. package/dist/config.js +9 -0
  9. package/dist/handlers/filesystem-handlers.d.ts +1 -1
  10. package/dist/handlers/filesystem-handlers.js +26 -16
  11. package/dist/handlers/search-answers.d.ts +58 -0
  12. package/dist/handlers/search-answers.js +172 -0
  13. package/dist/handlers/search-handlers.js +4 -92
  14. package/dist/index.js +14 -7
  15. package/dist/npm-scripts/remote.js +2 -3
  16. package/dist/remote-device/broadcast-analytics.d.ts +28 -0
  17. package/dist/remote-device/broadcast-analytics.js +41 -0
  18. package/dist/remote-device/desktop-commander-integration.js +19 -25
  19. package/dist/remote-device/device.d.ts +14 -0
  20. package/dist/remote-device/device.js +137 -30
  21. package/dist/remote-device/mqtt-enrollment.d.ts +16 -0
  22. package/dist/remote-device/mqtt-enrollment.js +162 -0
  23. package/dist/remote-device/mqtt-transport.d.ts +44 -0
  24. package/dist/remote-device/mqtt-transport.js +197 -0
  25. package/dist/remote-device/remote-channel.d.ts +12 -0
  26. package/dist/remote-device/remote-channel.js +55 -8
  27. package/dist/remote-device/scripts/blocking-offline-update.js +106 -69
  28. package/dist/remote-device/transport-analytics.d.ts +29 -0
  29. package/dist/remote-device/transport-analytics.js +44 -0
  30. package/dist/remote-device/transport-telemetry.d.ts +32 -0
  31. package/dist/remote-device/transport-telemetry.js +48 -0
  32. package/dist/search-manager.d.ts +239 -27
  33. package/dist/search-manager.js +746 -312
  34. package/dist/server.js +44 -11
  35. package/dist/terminal-manager.d.ts +138 -21
  36. package/dist/terminal-manager.js +300 -215
  37. package/dist/tools/config.d.ts +1 -1
  38. package/dist/tools/config.js +21 -70
  39. package/dist/tools/edit.js +12 -4
  40. package/dist/tools/filesystem.d.ts +30 -6
  41. package/dist/tools/filesystem.js +246 -140
  42. package/dist/tools/improved-process-tools.d.ts +9 -3
  43. package/dist/tools/improved-process-tools.js +171 -68
  44. package/dist/tools/pdf/extract-images.d.ts +2 -0
  45. package/dist/tools/pdf/extract-images.js +4 -1
  46. package/dist/tools/pdf/index.d.ts +5 -3
  47. package/dist/tools/pdf/index.js +4 -3
  48. package/dist/tools/pdf/lib/pdf2md.d.ts +8 -1
  49. package/dist/tools/pdf/lib/pdf2md.js +12 -5
  50. package/dist/tools/pdf/manipulations.d.ts +12 -1
  51. package/dist/tools/pdf/manipulations.js +17 -4
  52. package/dist/tools/pdf/markdown.d.ts +96 -0
  53. package/dist/tools/pdf/markdown.js +485 -20
  54. package/dist/tools/pdf/utils.d.ts +2 -2
  55. package/dist/tools/pdf/utils.js +4 -4
  56. package/dist/tools/process.js +8 -5
  57. package/dist/tools/schemas.d.ts +1 -1
  58. package/dist/tools/schemas.js +15 -6
  59. package/dist/tools/search.d.ts +32 -0
  60. package/dist/tools/search.js +202 -0
  61. package/dist/types.d.ts +1 -1
  62. package/dist/ui/config-editor/config-editor-runtime.js +6 -6
  63. package/dist/ui/config-editor/src/app.js +2 -15
  64. package/dist/utils/ab-test.js +27 -9
  65. package/dist/utils/atomic-write.d.ts +14 -0
  66. package/dist/utils/atomic-write.js +80 -0
  67. package/dist/utils/capture.d.ts +17 -1
  68. package/dist/utils/capture.js +177 -68
  69. package/dist/utils/exit-process.d.ts +24 -0
  70. package/dist/utils/exit-process.js +31 -0
  71. package/dist/utils/feature-flags.js +2 -1
  72. package/dist/utils/files/base.d.ts +3 -1
  73. package/dist/utils/files/docx.d.ts +3 -0
  74. package/dist/utils/files/docx.js +24 -9
  75. package/dist/utils/files/excel.d.ts +10 -0
  76. package/dist/utils/files/excel.js +93 -33
  77. package/dist/utils/files/factory.d.ts +22 -1
  78. package/dist/utils/files/factory.js +59 -4
  79. package/dist/utils/files/image.d.ts +12 -4
  80. package/dist/utils/files/image.js +19 -8
  81. package/dist/utils/files/index.d.ts +5 -3
  82. package/dist/utils/files/index.js +4 -3
  83. package/dist/utils/files/pdf.js +18 -36
  84. package/dist/utils/files/text.d.ts +21 -5
  85. package/dist/utils/files/text.js +90 -86
  86. package/dist/utils/internal-facts.d.ts +3 -0
  87. package/dist/utils/internal-facts.js +23 -0
  88. package/dist/utils/lazy-package.d.ts +23 -0
  89. package/dist/utils/lazy-package.js +42 -0
  90. package/dist/utils/open-browser.js +2 -1
  91. package/dist/utils/process-detection.d.ts +24 -5
  92. package/dist/utils/process-detection.js +199 -89
  93. package/dist/utils/process-tree.d.ts +14 -0
  94. package/dist/utils/process-tree.js +223 -0
  95. package/dist/utils/rename.d.ts +9 -0
  96. package/dist/utils/rename.js +74 -0
  97. package/dist/utils/ripgrep-resolver.js +9 -14
  98. package/dist/utils/shell.d.ts +42 -0
  99. package/dist/utils/shell.js +187 -0
  100. package/dist/utils/system-info.js +9 -7
  101. package/dist/utils/trackTools.js +2 -1
  102. package/dist/version.d.ts +1 -1
  103. package/dist/version.js +1 -1
  104. package/node_modules/@desktop-commander/telemetry-contract/README.md +56 -0
  105. package/node_modules/@desktop-commander/telemetry-contract/package.json +32 -0
  106. package/node_modules/@desktop-commander/telemetry-contract/transport.d.ts +38 -0
  107. package/node_modules/@desktop-commander/telemetry-contract/transport.js +164 -0
  108. package/package.json +8 -2
  109. package/vendor/telemetry-contract/README.md +56 -0
  110. package/vendor/telemetry-contract/package.json +32 -0
  111. package/vendor/telemetry-contract/transport.d.ts +38 -0
  112. package/vendor/telemetry-contract/transport.js +164 -0
  113. package/vendor/telemetry-contract/transport.test.js +39 -0
@@ -0,0 +1,32 @@
1
+ type TransportObservation = ({
2
+ stage: 'received';
3
+ payload: any;
4
+ deviceId: string | null;
5
+ userId: string | undefined;
6
+ } | {
7
+ stage: string;
8
+ callId: string;
9
+ deviceId: string | null | undefined;
10
+ toolName?: string;
11
+ operation?: string;
12
+ operationId?: string;
13
+ }) & {
14
+ transport?: 'broadcast' | 'mqtt';
15
+ };
16
+ /** Record a device transport checkpoint without affecting command handling. */
17
+ export declare function observeTransport(input: TransportObservation): {
18
+ observation_id: `${string}-${string}-${string}-${string}-${string}`;
19
+ source_process_id: `${string}-${string}-${string}-${string}-${string}`;
20
+ schema_version: number;
21
+ timestamp_utc: string;
22
+ operation_id?: string | undefined;
23
+ operation?: string | undefined;
24
+ tool_name?: string | undefined;
25
+ notification_id?: string | undefined;
26
+ attempt_number?: number | undefined;
27
+ transport?: "broadcast" | "mqtt" | undefined;
28
+ call_id: string;
29
+ device_id: string;
30
+ stage: string;
31
+ } | null;
32
+ export {};
@@ -0,0 +1,48 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { sanitizeTransportEvent } from '@desktop-commander/telemetry-contract/transport';
3
+ import { captureTransport } from '../utils/capture.js';
4
+ const ID = /^[A-Za-z0-9_-]{1,128}$/;
5
+ const PROCESS_ID = randomUUID();
6
+ /** Record a device transport checkpoint without affecting command handling. */
7
+ export function observeTransport(input) {
8
+ try {
9
+ const timestamp_utc = new Date().toISOString();
10
+ const receipt = 'payload' in input;
11
+ const callId = receipt ? input.payload?.call_id : input.callId;
12
+ const deviceId = input.deviceId;
13
+ if (typeof callId !== 'string' || !ID.test(callId) ||
14
+ typeof deviceId !== 'string' || !ID.test(deviceId))
15
+ return null;
16
+ if (receipt && (input.payload.device_id !== deviceId || !input.userId ||
17
+ (input.payload.user_id !== undefined && input.payload.user_id !== input.userId)))
18
+ return null;
19
+ const observationId = randomUUID();
20
+ let operationId;
21
+ if (!receipt) {
22
+ operationId = input.stage === 'operation_start' ? observationId : input.operationId;
23
+ }
24
+ const event = {
25
+ call_id: callId,
26
+ device_id: deviceId,
27
+ stage: input.stage,
28
+ ...(input.transport === 'broadcast' || input.transport === 'mqtt' ? { transport: input.transport } : {}),
29
+ ...(input.transport === 'broadcast' ? {
30
+ notification_id: `${callId}:broadcast:1`, attempt_number: 1,
31
+ } : {}),
32
+ ...(!receipt && typeof input.toolName === 'string' && input.toolName.length > 0 &&
33
+ input.toolName.length <= 128 ? { tool_name: input.toolName } : {}),
34
+ ...(!receipt && input.operation ? { operation: input.operation } : {}),
35
+ ...(operationId ? { operation_id: operationId } : {}),
36
+ observation_id: observationId,
37
+ source_process_id: PROCESS_ID,
38
+ schema_version: 1,
39
+ timestamp_utc,
40
+ };
41
+ void captureTransport(input.stage, sanitizeTransportEvent(input.stage, event));
42
+ return event;
43
+ }
44
+ catch {
45
+ // Telemetry must never affect command handling.
46
+ return null;
47
+ }
48
+ }
@@ -1,24 +1,85 @@
1
1
  import { ChildProcess } from 'child_process';
2
2
  export interface SearchResult {
3
+ context?: boolean;
3
4
  file: string;
4
5
  line?: number;
5
6
  match?: string;
6
7
  type: 'file' | 'content';
7
8
  }
9
+ /**
10
+ * How a search ended, once it is complete (#768): it searched everything
11
+ * (completed); its time limit, stop_search or maxResults stopped it; some files
12
+ * couldn't be searched (partial: see Unsearched); or it failed (see
13
+ * SearchFailure). The answers are built from it (handlers/search-answers.ts).
14
+ */
15
+ export type SearchOutcome = 'completed' | 'timed_out' | 'stopped' | 'max_results' | 'partial' | 'failed';
16
+ /** What a search couldn't search (outcome 'partial') */
17
+ export type UnsearchedKind = 'permissions' | 'ripgrep_error' | 'ripgrep_ended' | 'excel_search' | 'docx_search' | 'excel_file' | 'docx_file' | 'excel_folder' | 'docx_folder';
18
+ /** One kind of what a search couldn't search: how often, and the first met */
19
+ export interface Unsearched {
20
+ kind: UnsearchedKind;
21
+ count: number;
22
+ example: string;
23
+ }
24
+ /** Why a search failed: ripgrep's error output, or how ripgrep ended when it said nothing */
25
+ export type SearchFailure = {
26
+ error: string;
27
+ } | {
28
+ ripgrepEnded: string;
29
+ };
30
+ /** A session as answers report it (see handlers/search-answers.ts) */
31
+ export interface SearchState {
32
+ sessionId: string;
33
+ isComplete: boolean;
34
+ outcome?: SearchOutcome;
35
+ failure?: SearchFailure;
36
+ unsearched: Unsearched[];
37
+ timeLimitMs?: number;
38
+ maxResults?: number;
39
+ totalMatches: number;
40
+ totalResults: number;
41
+ runtime: number;
42
+ skippedLines: Array<{
43
+ file: string;
44
+ count: number;
45
+ }>;
46
+ }
8
47
  export interface SearchSession {
9
48
  id: string;
10
49
  process: ChildProcess;
11
50
  results: SearchResult[];
12
51
  isComplete: boolean;
13
- isError: boolean;
14
52
  error?: string;
15
53
  startTime: number;
16
54
  lastReadTime: number;
17
55
  options: SearchSessionOptions;
18
56
  buffer: string;
57
+ skippingLine?: boolean;
58
+ skippedLines: Map<string, number>;
19
59
  totalMatches: number;
20
60
  totalContextLines: number;
21
- wasIncomplete?: boolean;
61
+ trailingContext?: {
62
+ file: string;
63
+ lastLine: number;
64
+ };
65
+ pendingSources: Set<SearchSource>;
66
+ timeoutTimer?: NodeJS.Timeout;
67
+ filePatternIncludes?: {
68
+ root: string;
69
+ matchers: Array<(relativePath: string) => boolean>;
70
+ };
71
+ exitCode?: number | null;
72
+ printedOutput?: boolean;
73
+ stoppedRipgrep?: boolean;
74
+ timeLimitMs?: number;
75
+ stopReason?: 'timed_out' | 'stopped' | 'max_results';
76
+ unsearched: Map<UnsearchedKind, Unsearched>;
77
+ ripgrepTrouble?: string;
78
+ failure?: SearchFailure;
79
+ outcome?: SearchOutcome;
80
+ endTime?: number;
81
+ completed: Promise<void>;
82
+ markCompleted: () => void;
22
83
  }
23
84
  export interface SearchSessionOptions {
24
85
  rootPath: string;
@@ -33,44 +94,71 @@ export interface SearchSessionOptions {
33
94
  earlyTermination?: boolean;
34
95
  literalSearch?: boolean;
35
96
  }
97
+ /** What a session waits for: ripgrep, and the Excel and DOCX searches alongside it */
98
+ type SearchSource = 'ripgrep' | 'excel' | 'docx';
99
+ /** Answers show this many characters of a result's text, then '...' if there is more */
100
+ export declare const SHOWN_TEXT_CHARS = 100;
101
+ /**
102
+ * The longest line of ripgrep output the server assembles, in characters: a
103
+ * match or context line in its JSON. Half of V8's longest string (2^29 - 24
104
+ * characters in Node 24), past which the append throws and the server exits:
105
+ * only a longer line is skipped, and answers name its file. Any shorter line is
106
+ * processed whole.
107
+ */
108
+ export declare const MAX_OUTPUT_LINE_CHARS: number;
36
109
  /**
37
110
  * Search Session Manager - handles ripgrep processes like terminal sessions
38
111
  * Supports both file search and content search with progressive results
39
112
  */ export declare class SearchManager {
40
113
  private sessions;
41
114
  private sessionCounter;
115
+ private cleanupTimer;
42
116
  /**
43
117
  * Start a new search session (like start_process)
44
118
  * Returns immediately with initial state and results
45
119
  */
46
- startSearch(options: SearchSessionOptions): Promise<{
47
- sessionId: string;
48
- isComplete: boolean;
49
- isError: boolean;
120
+ startSearch(options: SearchSessionOptions): Promise<SearchState & {
50
121
  results: SearchResult[];
51
- totalResults: number;
52
- runtime: number;
53
122
  }>;
54
123
  /**
55
124
  * Read search results with offset-based pagination (like read_file)
56
125
  * Supports both range reading and tail behavior
57
126
  */
58
- readSearchResults(sessionId: string, offset?: number, length?: number): {
127
+ readSearchResults(sessionId: string, offset?: number, length?: number): SearchState & {
59
128
  results: SearchResult[];
60
129
  returnedCount: number;
61
- totalResults: number;
62
- totalMatches: number;
63
- isComplete: boolean;
64
- isError: boolean;
65
- error?: string;
66
130
  hasMoreResults: boolean;
67
- runtime: number;
68
- wasIncomplete?: boolean;
69
131
  };
132
+ /** What answers say about a session (see handlers/search-answers.ts) */
133
+ private stateOf;
134
+ private skippedLinesOf;
135
+ /**
136
+ * Keeps ripgrep's error output for the answer (shown when a search fails
137
+ * without results), each piece once and up to MAX_KEPT_ERROR_CHARS: a search
138
+ * over folders it can't read can print an error per entry, and the session
139
+ * keeps this until it is cleaned up. What comes first is kept.
140
+ */
141
+ private keepErrorOutput;
142
+ /**
143
+ * Resolves with all of a session's results once it is complete: every source
144
+ * has finished, or the search was stopped.
145
+ */
146
+ waitForCompletion(sessionId: string): Promise<SearchResult[]>;
70
147
  /**
71
148
  * Terminate a search session (like force_terminate)
72
149
  */
73
150
  terminateSearch(sessionId: string): boolean;
151
+ /**
152
+ * Stop every running search and drop all sessions and the cleanup timer.
153
+ * For owners that tear the search manager down (shutdown, tests); a later
154
+ * startSearch() starts afresh.
155
+ */
156
+ dispose(): void;
157
+ /**
158
+ * Start the periodic cleanup of old sessions. It is housekeeping only, so it
159
+ * is unref'd: it must never keep the process alive on its own.
160
+ */
161
+ private startCleanupIfNeeded;
74
162
  /**
75
163
  * Get list of active search sessions (like list_sessions)
76
164
  */
@@ -83,6 +171,12 @@ export interface SearchSessionOptions {
83
171
  runtime: number;
84
172
  totalResults: number;
85
173
  }>;
174
+ /**
175
+ * Run an Excel or DOCX search as one of the session's sources: its matches are
176
+ * collected as it finds them, until it has searched every file or the session
177
+ * stops it (stop_search, timeout, maxResults).
178
+ */
179
+ private startOfficeSource;
86
180
  /**
87
181
  * Search Excel files for content matches
88
182
  * Called during content search to include Excel files alongside text files
@@ -94,20 +188,48 @@ export interface SearchSessionOptions {
94
188
  */
95
189
  private searchExcelFiles;
96
190
  /**
97
- * Find all Excel files in a directory recursively
191
+ * Whether the Excel/DOCX search walks into a folder: never node_modules, and a
192
+ * hidden one (a name starting with '.') only with includeHidden, as ripgrep
193
+ * enters hidden folders only with --hidden.
194
+ */
195
+ private officeWalkEnters;
196
+ /**
197
+ * Find all Excel files in a directory recursively. Stops walking once the
198
+ * search is stopped; a folder it can't list is reported to the sink.
98
199
  */
99
200
  private findExcelFiles;
100
201
  /**
101
- * Determine if DOCX search should be included based on context
202
+ * The Excel/DOCX files a filePattern selects, as ripgrep's globs select text
203
+ * files (ripgrepGlobMatcher), ignoring case: one of its alternatives matches
204
+ * the file (any file, when all of them are "!" alternatives), and none of its
205
+ * "!" alternatives leaves it out (see officeFileExcluded). A search path that
206
+ * is itself a file is searched whatever the pattern says, as ripgrep searches
207
+ * a file it is given.
208
+ */
209
+ private filterOfficeFiles;
210
+ /**
211
+ * Whether a "!" alternative of a filePattern (given without its "!") leaves an
212
+ * Excel/DOCX file out - as it leaves text files out of ripgrep's search: when
213
+ * it matches the file, or a directory between the search path and the file;
214
+ * ending in '/', only directories.
215
+ */
216
+ private officeFileExcluded;
217
+ /**
218
+ * Whether a content search runs the Excel or DOCX search, the one for files
219
+ * with these extensions. Only when contextually relevant: the rootPath is
220
+ * such a file, or a filePattern alternative targets them ("*.xlsx",
221
+ * "budget.xlsx") - which one that leaves files out ("!*.xlsx") does not.
222
+ * Each alternative is checked on its own, so "report.xlsx|memo.docx" runs both.
102
223
  */
103
- private shouldIncludeDocxSearch;
224
+ private targetsOfficeFiles;
104
225
  /**
105
226
  * Search DOCX files for content matches
106
227
  * Extracts <w:t> text from document.xml and searches it
107
228
  */
108
229
  private searchDocxFiles;
109
230
  /**
110
- * Find all DOCX files in a directory recursively
231
+ * Find all DOCX files in a directory recursively. Stops walking once the
232
+ * search is stopped; a folder it can't list is reported to the sink.
111
233
  */
112
234
  private findDocxFiles;
113
235
  /**
@@ -123,9 +245,14 @@ export interface SearchSessionOptions {
123
245
  * Get total number of active sessions (excluding completed ones)
124
246
  */
125
247
  getActiveSessionCount(): number;
248
+ /**
249
+ * A file search for one exact filename ("package.json"): a lookup of a known
250
+ * file, unlike a content search for that same text
251
+ */
252
+ private isExactFilenameSearch;
126
253
  /**
127
254
  * Detect if pattern looks like an exact filename
128
- * (has file extension and no glob wildcards)
255
+ * (has file extension and no glob wildcards; a literal pattern has none)
129
256
  */
130
257
  private isExactFilename;
131
258
  /**
@@ -133,15 +260,100 @@ export interface SearchSessionOptions {
133
260
  */
134
261
  private isGlobPattern;
135
262
  /**
136
- * Determine if Excel search should be included based on context
137
- * Only searches Excel files when:
138
- * - filePattern explicitly targets Excel files (*.xlsx, *.xls, *.xlsm, *.xlsb)
139
- * - or the rootPath itself is an Excel file
263
+ * A file search's filePattern alternatives other than "!", which a file it
264
+ * finds must match one of (see filePatternSelects); undefined when there are none
265
+ */
266
+ private filePatternIncludes;
267
+ /**
268
+ * Whether a file a file search found is one its filePattern selects: ripgrep
269
+ * checked the "!" alternatives (see buildRipgrepArgs), one of the others must
270
+ * match it. ripgrep can't check those itself: with the pattern's glob in the
271
+ * same list, any glob that matches lets a file in.
140
272
  */
141
- private shouldIncludeExcelSearch;
273
+ private filePatternSelects;
142
274
  private buildRipgrepArgs;
275
+ /**
276
+ * Resolves once ripgrep has started; else logs why it could not start (not
277
+ * found, not executable...) and rejects with the error start_search always
278
+ * reported. 'spawn' or 'error' comes on the next tick, before any I/O, so
279
+ * the caller still sets up its handlers in time.
280
+ */
281
+ private whenStarted;
143
282
  private setupProcessHandlers;
144
- private processBufferedOutput;
283
+ /**
284
+ * ripgrep searched, and ended with exit code 2: some paths couldn't be
285
+ * searched, each named on stderr ("rg: <path>: <why> (os error N)"). Those it
286
+ * may not read are about permissions; any other error is trouble, which fails
287
+ * a search that found nothing (see outcomeOf).
288
+ */
289
+ private noteRipgrepErrors;
290
+ /** Something the search couldn't search: counted by kind, the first one kept as the example */
291
+ private noteUnsearched;
292
+ /**
293
+ * The session's one outcome, once every source is done. A failure first:
294
+ * ripgrep couldn't search at all, or had trouble and nothing was found. Then
295
+ * what stopped the search, if anything did; then what couldn't be searched.
296
+ */
297
+ private outcomeOf;
298
+ /**
299
+ * A source has ended, or was stopped. This is the one place a session
300
+ * completes: when its last source is done, whatever the order they end in.
301
+ */
302
+ private finishSource;
303
+ /**
304
+ * Stop every source still running (stop_search, timeout, dispose); the
305
+ * session completes once ripgrep has exited.
306
+ */
307
+ private stopSources;
308
+ /**
309
+ * The Excel/DOCX searches are done as of now. They can't be interrupted
310
+ * mid-file: each stops at its next check, and anything it still finds is dropped.
311
+ */
312
+ private stopOfficeSources;
313
+ private stopRipgrep;
314
+ /**
315
+ * Split ripgrep's output into lines as it arrives. Only the new text is split,
316
+ * its first piece joined to the line pending from earlier chunks, so a line
317
+ * costs time linear in its length (splitting the whole pending line again for
318
+ * every chunk made a long line quadratic). With isFinal, the pending line is
319
+ * complete as it is.
320
+ */
321
+ private processOutput;
322
+ /**
323
+ * Add text to the line being received, unless that makes it longer than
324
+ * MAX_OUTPUT_LINE_CHARS: then the line is skipped, noted by its file, and
325
+ * the rest of it dropped as it arrives.
326
+ */
327
+ private appendToLine;
328
+ /** The line being received, now complete; undefined if it was skipped */
329
+ private takeLine;
330
+ /**
331
+ * The file a line of ripgrep's --json output is about, read from the line's
332
+ * start: {"type":"match","data":{"path":{"text":"..."},... (a path that is
333
+ * not valid UTF-8 comes as "bytes" and is not read)
334
+ */
335
+ private fileOfOutputLine;
336
+ private processLines;
337
+ /**
338
+ * Collect one line of ripgrep output. Once maxResults matches are in, only the
339
+ * last match's trailing context is still collected - a matching line inside it
340
+ * is kept as context, like grep -m - and ripgrep is stopped when it ends.
341
+ */
342
+ private collectRipgrepLine;
343
+ /**
344
+ * The one place a session counts a match - from ripgrep, Excel or DOCX alike -
345
+ * so maxResults caps the TOTAL number of matches a search returns.
346
+ */
347
+ private collectMatch;
348
+ /** Whether options.maxResults matches are in: later ones are dropped */
349
+ private atMaxResults;
350
+ /**
351
+ * Once maxResults matches are in, stop the sources that cannot contribute
352
+ * anything more: the Excel/DOCX searches at once, ripgrep when the last
353
+ * match's trailing context is complete.
354
+ */
355
+ private stopAtMaxResults;
145
356
  private parseLine;
146
357
  }
147
358
  export declare const searchManager: SearchManager;
359
+ export {};