@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/tools/config.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare function getConfig(): Promise<{
|
|
|
65
65
|
availableShells: string[];
|
|
66
66
|
};
|
|
67
67
|
entries: {
|
|
68
|
-
key: "
|
|
68
|
+
key: "blockedCommands" | "defaultShell" | "allowedDirectories" | "telemetryEnabled" | "fileWriteLineLimit" | "fileReadLineLimit";
|
|
69
69
|
value: unknown;
|
|
70
70
|
valueType: "string" | "number" | "boolean" | "array";
|
|
71
71
|
editable: boolean;
|
package/dist/tools/config.js
CHANGED
|
@@ -1,76 +1,11 @@
|
|
|
1
1
|
import { configManager } from '../config-manager.js';
|
|
2
2
|
import { SetConfigValueArgsSchema } from './schemas.js';
|
|
3
3
|
import { getSystemInfo } from '../utils/system-info.js';
|
|
4
|
+
import { detectAvailableShells } from '../utils/shell.js';
|
|
4
5
|
import { currentClient } from '../server.js';
|
|
5
6
|
import { featureFlagManager } from '../utils/feature-flags.js';
|
|
6
|
-
import { access, readFile } from 'node:fs/promises';
|
|
7
|
-
import { constants as fsConstants } from 'node:fs';
|
|
8
7
|
import { CONFIG_FIELD_DEFINITIONS, CONFIG_FIELD_KEYS, isConfigFieldKey, } from '../config-field-definitions.js';
|
|
9
8
|
const ALLOWED_CONFIG_KEYS = new Set(CONFIG_FIELD_KEYS);
|
|
10
|
-
async function pathExists(pathValue) {
|
|
11
|
-
try {
|
|
12
|
-
await access(pathValue, fsConstants.X_OK);
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
async function detectAvailableShells(systemInfo) {
|
|
20
|
-
const detected = new Set();
|
|
21
|
-
const add = (shell) => {
|
|
22
|
-
if (shell.trim().length > 0) {
|
|
23
|
-
detected.add(shell.trim());
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
add(systemInfo.defaultShell);
|
|
27
|
-
if (systemInfo.isWindows) {
|
|
28
|
-
add(process.env.ComSpec ?? '');
|
|
29
|
-
const systemRoot = process.env.SystemRoot ?? 'C:\\Windows';
|
|
30
|
-
const candidates = [
|
|
31
|
-
`${systemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,
|
|
32
|
-
`${systemRoot}\\System32\\cmd.exe`,
|
|
33
|
-
`${systemRoot}\\System32\\bash.exe`,
|
|
34
|
-
'powershell.exe',
|
|
35
|
-
'pwsh.exe',
|
|
36
|
-
'cmd.exe',
|
|
37
|
-
'bash.exe',
|
|
38
|
-
];
|
|
39
|
-
for (const shell of candidates) {
|
|
40
|
-
if (shell.includes('\\')) {
|
|
41
|
-
if (await pathExists(shell)) {
|
|
42
|
-
add(shell);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
add(shell);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return [...detected];
|
|
50
|
-
}
|
|
51
|
-
add(process.env.SHELL ?? '');
|
|
52
|
-
const shellFiles = ['/etc/shells'];
|
|
53
|
-
for (const shellFile of shellFiles) {
|
|
54
|
-
try {
|
|
55
|
-
const content = await readFile(shellFile, 'utf8');
|
|
56
|
-
content
|
|
57
|
-
.split(/\r?\n/)
|
|
58
|
-
.map((line) => line.trim())
|
|
59
|
-
.filter((line) => line.length > 0 && !line.startsWith('#'))
|
|
60
|
-
.forEach(add);
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
// Best-effort discovery only.
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const fallbackCandidates = ['/bin/zsh', '/bin/bash', '/bin/sh', '/usr/bin/fish'];
|
|
67
|
-
for (const shell of fallbackCandidates) {
|
|
68
|
-
if (await pathExists(shell)) {
|
|
69
|
-
add(shell);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return [...detected];
|
|
73
|
-
}
|
|
74
9
|
/**
|
|
75
10
|
* Get the entire config including system information
|
|
76
11
|
*/
|
|
@@ -98,7 +33,7 @@ export async function getConfig() {
|
|
|
98
33
|
memory
|
|
99
34
|
}
|
|
100
35
|
};
|
|
101
|
-
const availableShells =
|
|
36
|
+
const availableShells = detectAvailableShells();
|
|
102
37
|
console.error(`getConfig result: ${JSON.stringify(configWithSystemInfo, null, 2)}`);
|
|
103
38
|
return {
|
|
104
39
|
content: [{
|
|
@@ -196,8 +131,9 @@ export async function setConfigValue(args) {
|
|
|
196
131
|
// If not a string or array (and not null), convert to an array with one item
|
|
197
132
|
valueToStore = [String(valueToStore)];
|
|
198
133
|
}
|
|
199
|
-
// Ensure the value is an array after all our conversions
|
|
200
|
-
|
|
134
|
+
// Ensure the value is an array after all our conversions; null stays
|
|
135
|
+
// null and clears the value back to its default, as for number fields
|
|
136
|
+
if (valueToStore !== null && !Array.isArray(valueToStore)) {
|
|
201
137
|
console.error(`Value for ${parsed.data.key} is still not an array, converting to array`);
|
|
202
138
|
valueToStore = [String(valueToStore)];
|
|
203
139
|
}
|
|
@@ -223,7 +159,22 @@ export async function setConfigValue(args) {
|
|
|
223
159
|
};
|
|
224
160
|
}
|
|
225
161
|
}
|
|
226
|
-
|
|
162
|
+
// Numbers may arrive as strings ("5000"); null clears the value back to its default.
|
|
163
|
+
if (fieldDefinition.valueType === 'number' && valueToStore !== null) {
|
|
164
|
+
const numeric = typeof valueToStore === 'string' && valueToStore.trim() !== '' ? Number(valueToStore) : valueToStore;
|
|
165
|
+
if (typeof numeric !== 'number' || !Number.isFinite(numeric)) {
|
|
166
|
+
return {
|
|
167
|
+
content: [{
|
|
168
|
+
type: "text",
|
|
169
|
+
text: `Value for ${parsed.data.key} must be a number.`
|
|
170
|
+
}],
|
|
171
|
+
isError: true
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
valueToStore = numeric;
|
|
175
|
+
}
|
|
176
|
+
// Not saved: in effect all the same, as the answer below says, and saved with the held changes
|
|
177
|
+
await configManager.setValue(parsed.data.key, valueToStore, { holdIfNotSaved: true });
|
|
227
178
|
// Get the updated configuration to show the user
|
|
228
179
|
const updatedConfig = await configManager.getConfig();
|
|
229
180
|
console.error(`setConfigValue: Successfully set ${parsed.data.key} to ${JSON.stringify(valueToStore)}`);
|
package/dist/tools/edit.js
CHANGED
|
@@ -124,9 +124,11 @@ export async function performSearchReplace(filePath, block, expectedReplacements
|
|
|
124
124
|
let tempContent = content;
|
|
125
125
|
let count = 0;
|
|
126
126
|
let pos = tempContent.indexOf(normalizedSearch);
|
|
127
|
+
// Count the matches a replacement changes: they can't overlap, so the next
|
|
128
|
+
// search starts after this match (split/join below replaces the same ones)
|
|
127
129
|
while (pos !== -1) {
|
|
128
130
|
count++;
|
|
129
|
-
pos = tempContent.indexOf(normalizedSearch, pos +
|
|
131
|
+
pos = tempContent.indexOf(normalizedSearch, pos + normalizedSearch.length);
|
|
130
132
|
}
|
|
131
133
|
// If exact match found and count matches expected replacements, proceed with exact replacement
|
|
132
134
|
if (count > 0 && count === expectedReplacements) {
|
|
@@ -330,6 +332,10 @@ function highlightDifferences(expected, actual) {
|
|
|
330
332
|
// Format the output as a character-level diff
|
|
331
333
|
return `${commonPrefix}{-${expectedDiff}-}{+${actualDiff}+}${commonSuffix}`;
|
|
332
334
|
}
|
|
335
|
+
/** Why a file handler's edit failed, as edit_block reports it */
|
|
336
|
+
function editFailure(result) {
|
|
337
|
+
return result.errors?.map(e => e.error).join('; ') || 'Unknown error';
|
|
338
|
+
}
|
|
333
339
|
/**
|
|
334
340
|
* Handle edit_block command
|
|
335
341
|
*
|
|
@@ -377,7 +383,10 @@ export async function handleEditBlock(args) {
|
|
|
377
383
|
if (hasEditRange) {
|
|
378
384
|
try {
|
|
379
385
|
// parsed.range is guaranteed non-empty string by hasRange check above
|
|
380
|
-
await handler.editRange(validatedPath, parsed.range, content, parsed.options);
|
|
386
|
+
const result = await handler.editRange(validatedPath, parsed.range, content, parsed.options);
|
|
387
|
+
if (!result.success) {
|
|
388
|
+
return createErrorResponse(editFailure(result));
|
|
389
|
+
}
|
|
381
390
|
const resolvedRangePath = resolveAbsolutePath(parsed.file_path);
|
|
382
391
|
return {
|
|
383
392
|
content: [{
|
|
@@ -432,8 +441,7 @@ export async function handleEditBlock(args) {
|
|
|
432
441
|
} : {}),
|
|
433
442
|
};
|
|
434
443
|
}
|
|
435
|
-
|
|
436
|
-
return createErrorResponse(errorMsg);
|
|
444
|
+
return createErrorResponse(editFailure(result));
|
|
437
445
|
}
|
|
438
446
|
catch (error) {
|
|
439
447
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import type { ReadOptions, FileResult, PdfPageItem } from '../utils/files/base.js';
|
|
2
|
-
import { PdfOperations, PdfMetadata } from './pdf/index.js';
|
|
2
|
+
import { PdfOperations, PdfMetadata, IgnoredRenderOption } from './pdf/index.js';
|
|
3
3
|
export declare const READ_OPERATION_TIMEOUT_MS: number;
|
|
4
4
|
/**
|
|
5
5
|
* Validates a path to ensure it can be accessed or created.
|
|
6
6
|
* For existing paths, returns the real path (resolving symlinks).
|
|
7
|
-
* For non-existent paths,
|
|
7
|
+
* For non-existent paths, returns where they would be created (resolving the
|
|
8
|
+
* existing ancestors and any dangling link), and validates parent directories.
|
|
9
|
+
*
|
|
10
|
+
* With `entry`, the path names an entry to rename (move_file): links are
|
|
11
|
+
* followed up to its folder, and its own name is kept as written, so a link
|
|
12
|
+
* is renamed as a link and a change of letter case is kept. A rename only
|
|
13
|
+
* ever touches that entry, never what a link at that name points to.
|
|
8
14
|
*
|
|
9
15
|
* @param requestedPath The path to validate
|
|
10
16
|
* @returns Promise<string> The validated path
|
|
11
17
|
* @throws Error if the path or its parent directories don't exist or if the path is not allowed
|
|
12
18
|
*/
|
|
13
|
-
export declare function validatePath(requestedPath: string
|
|
19
|
+
export declare function validatePath(requestedPath: string, { entry }?: {
|
|
20
|
+
entry?: boolean;
|
|
21
|
+
}): Promise<string>;
|
|
14
22
|
export type { FileResult } from '../utils/files/base.js';
|
|
15
23
|
type PdfPayload = {
|
|
16
24
|
metadata: PdfMetadata;
|
|
@@ -20,9 +28,10 @@ type FileResultPayloads = PdfPayload;
|
|
|
20
28
|
/**
|
|
21
29
|
* Read file content from a URL
|
|
22
30
|
* @param url URL to fetch content from
|
|
31
|
+
* @param svgAsImage An SVG is answered as an image, for the file preview widget; otherwise as text
|
|
23
32
|
* @returns File content or file result with metadata
|
|
24
33
|
*/
|
|
25
|
-
export declare function readFileFromUrl(url: string): Promise<FileResult>;
|
|
34
|
+
export declare function readFileFromUrl(url: string, svgAsImage?: boolean): Promise<FileResult>;
|
|
26
35
|
/**
|
|
27
36
|
* Read file content from the local filesystem
|
|
28
37
|
* @param filePath Path to the file
|
|
@@ -57,12 +66,26 @@ export interface MultiFileResult {
|
|
|
57
66
|
isPdf?: boolean;
|
|
58
67
|
payload?: FileResultPayloads;
|
|
59
68
|
}
|
|
60
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Reads each file; a failure is that file's `error`. `stillLoadingError` (the
|
|
71
|
+
* server's) gives the error for a file whose package is still loading, which
|
|
72
|
+
* is then not read (utils/files/factory.ts).
|
|
73
|
+
*/
|
|
74
|
+
export declare function readMultipleFiles(paths: string[], stillLoadingError?: (filePath: string) => string | undefined): Promise<MultiFileResult[]>;
|
|
61
75
|
export declare function createDirectory(dirPath: string): Promise<void>;
|
|
62
76
|
export declare function listDirectory(dirPath: string, depth?: number): Promise<string[]>;
|
|
63
77
|
export declare function moveFile(sourcePath: string, destinationPath: string): Promise<void>;
|
|
64
78
|
export declare function searchFiles(rootPath: string, pattern: string): Promise<string[]>;
|
|
65
79
|
export declare function getFileInfo(filePath: string): Promise<Record<string, any>>;
|
|
80
|
+
/**
|
|
81
|
+
* Validate the paths a PDF's page operations use besides the PDF itself: the
|
|
82
|
+
* output path and each inserted PDF. write_pdf and edit_block both modify PDFs,
|
|
83
|
+
* so both check here. An inserted PDF's path is replaced by its validated path.
|
|
84
|
+
*
|
|
85
|
+
* @param validPath The PDF the operations apply to, already validated
|
|
86
|
+
* @returns Where to write the result: outputPath if provided, otherwise the PDF itself
|
|
87
|
+
*/
|
|
88
|
+
export declare function validatePdfOperationPaths(validPath: string, operations: PdfOperations[], outputPath?: string): Promise<string>;
|
|
66
89
|
/**
|
|
67
90
|
* Write content to a PDF file.
|
|
68
91
|
* Can create a new PDF from Markdown string, or modify an existing PDF using operations.
|
|
@@ -70,8 +93,9 @@ export declare function getFileInfo(filePath: string): Promise<Record<string, an
|
|
|
70
93
|
* @param filePath Path to the output PDF file
|
|
71
94
|
* @param content Markdown string (for creation) or array of operations (for modification)
|
|
72
95
|
* @param options Options for PDF generation or modification. For modification, can include `sourcePdf`.
|
|
96
|
+
* @returns The render options Desktop Commander ignored (see resolveRender), so the caller can report them.
|
|
73
97
|
*/
|
|
74
|
-
export declare function writePdf(filePath: string, content: string | PdfOperations[], outputPath?: string, options?: any): Promise<
|
|
98
|
+
export declare function writePdf(filePath: string, content: string | PdfOperations[], outputPath?: string, options?: any): Promise<IgnoredRenderOption[]>;
|
|
75
99
|
type DefaultEditorMetadata = {
|
|
76
100
|
defaultEditorName?: string;
|
|
77
101
|
defaultEditorPath?: string;
|