@wonderwhy-er/desktop-commander 0.2.51 → 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.
- package/README.md +14 -24
- package/dist/command-manager.d.ts +7 -2
- package/dist/command-manager.js +16 -11
- package/dist/config-manager.d.ts +49 -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 +32 -4
- package/dist/remote-device/broadcast-analytics.d.ts +28 -0
- package/dist/remote-device/broadcast-analytics.js +41 -0
- package/dist/remote-device/desktop-commander-integration.d.ts +20 -0
- package/dist/remote-device/desktop-commander-integration.js +121 -40
- package/dist/remote-device/device-authenticator.d.ts +13 -1
- package/dist/remote-device/device-authenticator.js +87 -47
- package/dist/remote-device/device.d.ts +14 -0
- package/dist/remote-device/device.js +244 -51
- package/dist/remote-device/mqtt-enrollment.d.ts +16 -0
- package/dist/remote-device/mqtt-enrollment.js +162 -0
- package/dist/remote-device/mqtt-transport.d.ts +44 -0
- package/dist/remote-device/mqtt-transport.js +197 -0
- package/dist/remote-device/remote-channel.d.ts +64 -3
- package/dist/remote-device/remote-channel.js +317 -48
- package/dist/remote-device/scripts/blocking-offline-update.js +106 -69
- package/dist/remote-device/transport-analytics.d.ts +29 -0
- package/dist/remote-device/transport-analytics.js +44 -0
- 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 +77 -92
- 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 -1
- package/dist/tools/schemas.js +15 -6
- package/dist/tools/search.d.ts +32 -0
- package/dist/tools/search.js +202 -0
- package/dist/types.d.ts +1 -1
- package/dist/ui/config-editor/config-editor-runtime.js +6 -6
- package/dist/ui/config-editor/src/app.js +2 -15
- 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 +23 -0
- package/dist/utils/lazy-package.js +42 -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.js +9 -7
- package/dist/utils/trackTools.js +2 -1
- 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 +8 -2
- 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
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
+
import { LazyPackage } from '../../utils/lazy-package.js';
|
|
3
4
|
import { normalizePageIndexes } from './utils.js';
|
|
4
5
|
import { parseMarkdownToPdf } from './markdown.js';
|
|
5
6
|
// Use createRequire to load pdf-lib as CJS (works around Node 25 ESM resolution issues)
|
|
6
7
|
const require = createRequire(import.meta.url);
|
|
7
|
-
const
|
|
8
|
+
export const pdfLibPackage = new LazyPackage('pdf-lib', 'PDF editing support', () => require('pdf-lib'));
|
|
8
9
|
async function loadPdfDocumentFromBuffer(filePathOrBuffer) {
|
|
10
|
+
const { PDFDocument } = pdfLibPackage.load();
|
|
9
11
|
const buffer = typeof filePathOrBuffer === 'string' ? await fs.readFile(filePathOrBuffer) : filePathOrBuffer;
|
|
10
12
|
const pdfBytes = new Uint8Array(buffer);
|
|
11
13
|
return await PDFDocument.load(pdfBytes);
|
|
12
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* The render options for an inserted page's markdown: the call's options, with
|
|
17
|
+
* the page size and margins of the original first page (pageLayout), then the
|
|
18
|
+
* call's pdf_options, then the insert's own pdfOptions, each over the one before.
|
|
19
|
+
*/
|
|
20
|
+
export function insertRenderOptions(op, options = {}, pageLayout) {
|
|
21
|
+
return { ...options, pdf_options: { ...pageLayout, ...options.pdf_options, ...op.pdfOptions } };
|
|
22
|
+
}
|
|
13
23
|
/**
|
|
14
24
|
* Delete pages from a PDF document
|
|
15
25
|
* @param pdfDoc PDF document to delete pages from
|
|
@@ -17,6 +27,10 @@ async function loadPdfDocumentFromBuffer(filePathOrBuffer) {
|
|
|
17
27
|
*/
|
|
18
28
|
function deletePages(pdfDoc, pageIndexes) {
|
|
19
29
|
const pageCount = pdfDoc.getPageCount();
|
|
30
|
+
// A page that doesn't exist is an error, as for an insert: nothing is deleted
|
|
31
|
+
if (pageIndexes.some(idx => !Number.isInteger(idx) || idx >= pageCount || idx < -pageCount)) {
|
|
32
|
+
throw new Error('Invalid page index');
|
|
33
|
+
}
|
|
20
34
|
// Transform negative indices to absolute and filter valid ones
|
|
21
35
|
const normalizedIndexes = normalizePageIndexes(pageIndexes, pageCount).sort((a, b) => b - a);
|
|
22
36
|
for (const pageIndex of normalizedIndexes) {
|
|
@@ -71,7 +85,7 @@ async function insertPages(destPdfDocument, pageIndex, sourcePdfDocument) {
|
|
|
71
85
|
* @param operations List of operations to perform
|
|
72
86
|
* @returns The modified PDF as a Uint8Array
|
|
73
87
|
*/
|
|
74
|
-
export async function editPdf(pdfPath, operations) {
|
|
88
|
+
export async function editPdf(pdfPath, operations, options = {}) {
|
|
75
89
|
const pdfDoc = await loadPdfDocumentFromBuffer(pdfPath);
|
|
76
90
|
// Get page layout from the ORIGINAL first page
|
|
77
91
|
const pageLayout = pdfDoc.getPageCount() > 0 ? getPageLayout(pdfDoc.getPage(0)) : undefined;
|
|
@@ -82,8 +96,7 @@ export async function editPdf(pdfPath, operations) {
|
|
|
82
96
|
else if (op.type == 'insert') {
|
|
83
97
|
let sourcePdfDocument;
|
|
84
98
|
if (op.markdown !== undefined) {
|
|
85
|
-
const
|
|
86
|
-
const pdfBuffer = await parseMarkdownToPdf(op.markdown, pdfOptions);
|
|
99
|
+
const pdfBuffer = await parseMarkdownToPdf(op.markdown, insertRenderOptions(op, options, pageLayout));
|
|
87
100
|
sourcePdfDocument = await loadPdfDocumentFromBuffer(pdfBuffer);
|
|
88
101
|
}
|
|
89
102
|
else if (op.sourcePdfPath) {
|
|
@@ -1,5 +1,80 @@
|
|
|
1
|
+
import { type IncomingMessage, type ServerResponse } from 'http';
|
|
2
|
+
import type { Browser, PuppeteerNode } from 'puppeteer';
|
|
3
|
+
import type { Config as MdToPdfConfig } from 'md-to-pdf/dist/lib/config.js';
|
|
1
4
|
import type { PageRange } from './lib/pdf2md.js';
|
|
2
5
|
import { PdfParseResult } from './lib/pdf2md.js';
|
|
6
|
+
import { LazyPackage } from '../../utils/lazy-package.js';
|
|
7
|
+
export declare const mdToPdfPackage: LazyPackage<{
|
|
8
|
+
convertMdToPdf: (input: {
|
|
9
|
+
path: string;
|
|
10
|
+
} | {
|
|
11
|
+
content: string;
|
|
12
|
+
}, config: MdToPdfConfig, { args, browser, }?: {
|
|
13
|
+
args?: import("arg").Result<{
|
|
14
|
+
"--help": BooleanConstructor;
|
|
15
|
+
"--version": BooleanConstructor;
|
|
16
|
+
"--basedir": StringConstructor;
|
|
17
|
+
"--watch": BooleanConstructor;
|
|
18
|
+
"--watch-options": StringConstructor;
|
|
19
|
+
"--stylesheet": [StringConstructor];
|
|
20
|
+
"--css": StringConstructor;
|
|
21
|
+
"--document-title": StringConstructor;
|
|
22
|
+
"--body-class": [StringConstructor];
|
|
23
|
+
"--page-media-type": StringConstructor;
|
|
24
|
+
"--highlight-style": StringConstructor;
|
|
25
|
+
"--marked-options": StringConstructor;
|
|
26
|
+
"--html-pdf-options": StringConstructor;
|
|
27
|
+
"--pdf-options": StringConstructor;
|
|
28
|
+
"--launch-options": StringConstructor;
|
|
29
|
+
"--gray-matter-options": StringConstructor;
|
|
30
|
+
"--port": NumberConstructor;
|
|
31
|
+
"--md-file-encoding": StringConstructor;
|
|
32
|
+
"--stylesheet-encoding": StringConstructor;
|
|
33
|
+
"--as-html": BooleanConstructor;
|
|
34
|
+
"--config-file": StringConstructor;
|
|
35
|
+
"--devtools": BooleanConstructor;
|
|
36
|
+
"-h": string;
|
|
37
|
+
"-v": string;
|
|
38
|
+
"-w": string;
|
|
39
|
+
}> | undefined;
|
|
40
|
+
browser?: Browser | undefined;
|
|
41
|
+
}) => Promise<import("md-to-pdf/dist/lib/generate-output.js").Output>;
|
|
42
|
+
defaultConfig: MdToPdfConfig;
|
|
43
|
+
puppeteer: PuppeteerNode;
|
|
44
|
+
serveHandler: (request: IncomingMessage, response: ServerResponse, config: {
|
|
45
|
+
public: string;
|
|
46
|
+
directoryListing: boolean;
|
|
47
|
+
cleanUrls: boolean;
|
|
48
|
+
}) => Promise<void>;
|
|
49
|
+
grayMatter: (input: string, options: unknown) => {
|
|
50
|
+
content: string;
|
|
51
|
+
data: unknown;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
/** An option Desktop Commander ignored from write_pdf's options or the markdown's front matter */
|
|
55
|
+
export interface IgnoredRenderOption {
|
|
56
|
+
/** Dotted option name, e.g. "pdf_options.path" */
|
|
57
|
+
option: string;
|
|
58
|
+
/** Why Desktop Commander ignores it */
|
|
59
|
+
reason: string;
|
|
60
|
+
}
|
|
61
|
+
interface ResolvedRender {
|
|
62
|
+
/** The markdown body, with the front matter removed */
|
|
63
|
+
body: string;
|
|
64
|
+
/** write_pdf's options merged with the front matter (front matter wins), minus the ignored options */
|
|
65
|
+
options: Record<string, unknown>;
|
|
66
|
+
/** The options that were present and ignored */
|
|
67
|
+
ignoredOptions: IgnoredRenderOption[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The single place write_pdf's `options` and the markdown's front matter are
|
|
71
|
+
* merged. Front matter wins (as in md-to-pdf), pdf_options is merged key by
|
|
72
|
+
* key, and the options Desktop Commander ignores are removed from the merged
|
|
73
|
+
* result AFTER the merge, so neither source can re-add them. Returns the
|
|
74
|
+
* markdown body without its front matter, so the caller can render it without
|
|
75
|
+
* md-to-pdf merging the front matter a second time.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveRender(markdown: string, options?: unknown): ResolvedRender;
|
|
3
78
|
interface CachedPuppeteerChrome {
|
|
4
79
|
executablePath: string;
|
|
5
80
|
}
|
|
@@ -12,6 +87,11 @@ export declare function findPuppeteerChrome(cacheDir?: string): CachedPuppeteerC
|
|
|
12
87
|
* Remove stale Puppeteer Chrome builds while preserving the active build.
|
|
13
88
|
*/
|
|
14
89
|
export declare function pruneOldPuppeteerChromeBuilds(activeExecutablePath: string, cacheDir?: string): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Find system-installed Chrome/Chromium browser
|
|
92
|
+
* Returns the executable path if found, undefined otherwise
|
|
93
|
+
*/
|
|
94
|
+
export declare function findSystemChrome(): string | undefined;
|
|
15
95
|
/**
|
|
16
96
|
* Preemptively ensure Chrome is available for PDF generation.
|
|
17
97
|
* Call this at server startup to trigger download in background if needed.
|
|
@@ -22,5 +102,21 @@ export declare function ensureChromeAvailable(): void;
|
|
|
22
102
|
* Convert PDF to Markdown using @opendocsg/pdf2md
|
|
23
103
|
*/
|
|
24
104
|
export declare function parsePdfToMarkdown(source: string, pageNumbers?: number[] | PageRange): Promise<PdfParseResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Render markdown to PDF with md-to-pdf's converter in a Chrome of our own.
|
|
107
|
+
*
|
|
108
|
+
* md-to-pdf's mdToPdf() starts its web server and Chrome and stops them only
|
|
109
|
+
* after a successful render. So each render starts its own Chrome profile,
|
|
110
|
+
* web server (startRenderServer) and Chrome here, hands the converter the
|
|
111
|
+
* browser, and releases all of them on every path: when this returns or
|
|
112
|
+
* throws, the server is closed and Chrome, with the page it rendered, has
|
|
113
|
+
* exited.
|
|
114
|
+
*
|
|
115
|
+
* Options are md-to-pdf's, from `options` and the markdown's front matter
|
|
116
|
+
* (resolveRender merges them and drops the few Desktop Commander ignores).
|
|
117
|
+
* The PDF is only returned: Desktop Commander writes it, so the config forces
|
|
118
|
+
* dest to '' (md-to-pdf would otherwise write it to dest, or to stdout - the
|
|
119
|
+
* MCP connection - when dest is undefined).
|
|
120
|
+
*/
|
|
25
121
|
export declare function parseMarkdownToPdf(markdown: string, options?: any): Promise<Buffer>;
|
|
26
122
|
export {};
|