@documonster/mcp 0.14.0 → 0.15.0-canary.sha.5c2f87ca
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 +60 -1
- package/dist/config.d.ts +25 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -3
- package/dist/config.js.map +1 -1
- package/dist/sandbox.d.ts +16 -3
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +79 -9
- package/dist/sandbox.js.map +1 -1
- package/dist/tools/diagram-markdown.d.ts +38 -3
- package/dist/tools/diagram-markdown.d.ts.map +1 -1
- package/dist/tools/diagram-markdown.js +247 -31
- package/dist/tools/diagram-markdown.js.map +1 -1
- package/dist/tools/diagram-render.d.ts.map +1 -1
- package/dist/tools/diagram-render.js +9 -1
- package/dist/tools/diagram-render.js.map +1 -1
- package/dist/tools/diagram-slice.d.ts +45 -0
- package/dist/tools/diagram-slice.d.ts.map +1 -0
- package/dist/tools/diagram-slice.js +225 -0
- package/dist/tools/diagram-slice.js.map +1 -0
- package/dist/tools/diagram.d.ts +25 -2
- package/dist/tools/diagram.d.ts.map +1 -1
- package/dist/tools/diagram.js +17 -5
- package/dist/tools/diagram.js.map +1 -1
- package/dist/tools/doc-convert.d.ts.map +1 -1
- package/dist/tools/doc-convert.js +8 -6
- package/dist/tools/doc-convert.js.map +1 -1
- package/dist/tools/doc-write.d.ts.map +1 -1
- package/dist/tools/doc-write.js +5 -4
- package/dist/tools/doc-write.js.map +1 -1
- package/dist/tools/help.d.ts +13 -0
- package/dist/tools/help.d.ts.map +1 -1
- package/dist/tools/help.js +13 -0
- package/dist/tools/help.js.map +1 -1
- package/dist/tools/pdf-edit.d.ts.map +1 -1
- package/dist/tools/pdf-edit.js +12 -0
- package/dist/tools/pdf-edit.js.map +1 -1
- package/dist/tools/pdf-fonts.d.ts +59 -4
- package/dist/tools/pdf-fonts.d.ts.map +1 -1
- package/dist/tools/pdf-fonts.js +128 -14
- package/dist/tools/pdf-fonts.js.map +1 -1
- package/dist/tools/sheet-write.js +6 -1
- package/dist/tools/sheet-write.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -71,7 +71,8 @@ No install needed — point your MCP client at `npx`.
|
|
|
71
71
|
| `--enable <groups>` | all | Comma-separated tool groups: `core`, `excel`, `word`, `pdf`, `forms`, `archive`, `diagram`. `core` is always on. |
|
|
72
72
|
| `--max-file-size <bytes>` | 67108864 | Reject larger input documents. |
|
|
73
73
|
| `--max-output-chars <n>` | 40000 | Truncate tool output — a token budget in disguise. |
|
|
74
|
-
| `--pdf-font <file
|
|
74
|
+
| `--pdf-font <file>[#i]` | none | TrueType face embedded in every PDF and diagram written. See [PDF fonts](#pdf-fonts). |
|
|
75
|
+
| `--pdf-font-fallback <f>` | none | Faces tried, in order, for characters the primary lacks. Repeatable, or comma-separated. |
|
|
75
76
|
|
|
76
77
|
### PDF fonts
|
|
77
78
|
|
|
@@ -102,6 +103,58 @@ Naming a font removes the host from the answer:
|
|
|
102
103
|
}
|
|
103
104
|
```
|
|
104
105
|
|
|
106
|
+
#### Selecting a face inside a `.ttc`
|
|
107
|
+
|
|
108
|
+
A collection holds several faces and the first is rarely the one wanted: on macOS
|
|
109
|
+
`Songti.ttc` opens at **weight 900**, so naming the file alone sets Chinese body text
|
|
110
|
+
in the heaviest weight the family ships. Append the index to choose:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
--pdf-font /System/Library/Fonts/Supplemental/Songti.ttc#6
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The order inside a collection is arbitrary and not worth guessing — that file happens to
|
|
117
|
+
run Black, Bold, TC-Bold, Light, STSong, TC-Light, **Regular**, TC-Regular, so Regular is
|
|
118
|
+
face 6 and face 3 is Light. Check the file rather than assuming, and confirm what was
|
|
119
|
+
embedded by looking for `/BaseFont` in the PDF: `STSongti-SC-Regular-Subset` is the
|
|
120
|
+
answer you want, `-Light-` or `-Black-` means the index was wrong.
|
|
121
|
+
|
|
122
|
+
An index on a file that holds one face is rejected at startup rather than ignored.
|
|
123
|
+
|
|
124
|
+
#### More than one face
|
|
125
|
+
|
|
126
|
+
One face cannot serve a document that mixes scripts. A Chinese face has no Arabic, so a
|
|
127
|
+
page of Chinese prose quoting an Arabic phrase either loses the phrase to `.notdef` boxes
|
|
128
|
+
or — if you reach for a pan-Unicode face to cover both — has _all_ of its Han drawn by a
|
|
129
|
+
face whose glyphs follow Japanese conventions. Give the regional face first and let the
|
|
130
|
+
rest fall back:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
--pdf-font Songti.ttc#6 --pdf-font-fallback ArialUnicode.ttf,Symbols.ttf
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### What the fonts cover
|
|
137
|
+
|
|
138
|
+
Every place this server draws text of its own: converted documents, diagrams rendered
|
|
139
|
+
to PNG or PDF, diagrams embedded in a `.docx`, and `pdf_edit`'s watermarks, stamps and
|
|
140
|
+
page numbers. Configuring a font also switches the host's own fonts **off** for these
|
|
141
|
+
renders, which is the point — the output then depends on the files you named and not on
|
|
142
|
+
the machine.
|
|
143
|
+
|
|
144
|
+
Only `pdf_edit` cannot honour a `#index`: its overlay API takes bytes, so a `.ttc` there
|
|
145
|
+
embeds the collection's first face.
|
|
146
|
+
|
|
147
|
+
#### Choosing the regional hand
|
|
148
|
+
|
|
149
|
+
`textLanguage` is a per-call parameter on `doc_write` and `doc_convert`, not a server
|
|
150
|
+
flag, because it is a property of the document — one session legitimately converts a
|
|
151
|
+
Chinese file and then a Japanese one. Han characters are shared between the three
|
|
152
|
+
languages and drawn differently, so a font picked purely by coverage can be correct and
|
|
153
|
+
still look wrong. Omitted, the library infers it from the text, which falls back to
|
|
154
|
+
Chinese for characters common to all three.
|
|
155
|
+
|
|
156
|
+
#### Requirements
|
|
157
|
+
|
|
105
158
|
It must be a TrueType font — `.ttf` or `.ttc` with `glyf` outlines. A
|
|
106
159
|
CFF-flavoured `.otf` is rejected at startup rather than at conversion time,
|
|
107
160
|
because the subsetting embedder cannot use CFF outlines: that rules out macOS
|
|
@@ -118,6 +171,12 @@ symbol blocks are drawn from built-in outlines and never trigger it; CJK, and an
|
|
|
118
171
|
script this library has no glyphs for, needs `--pdf-font`. Pass
|
|
119
172
|
`allowMissingGlyphs: true` on the call to accept the boxes on purpose.
|
|
120
173
|
|
|
174
|
+
**A diagram cannot fail this way, so it is reported instead.** A rasteriser has no
|
|
175
|
+
`.notdef` to draw — an uncovered character paints _nothing_ — so `diagram_render`, and any
|
|
176
|
+
tool embedding a `mermaid` fence, names the code points it could not draw and says the
|
|
177
|
+
labels are blank. There is no equivalent refusal because the image is not terminal: it
|
|
178
|
+
sits inside a document you can regenerate.
|
|
179
|
+
|
|
121
180
|
## Security
|
|
122
181
|
|
|
123
182
|
An MCP server hands a model the ability to name files, so the boundaries are
|
package/dist/config.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface ServerConfig {
|
|
|
39
39
|
/** Truncate tool output beyond this many characters. */
|
|
40
40
|
readonly maxOutputChars: number;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* The TrueType face every PDF this server writes embeds.
|
|
43
43
|
*
|
|
44
44
|
* Unset, PDF text outside WinAnsi — CJK, Cyrillic, Greek — depends on the host
|
|
45
45
|
* having a usable face installed, and a host that has none renders `.notdef`
|
|
@@ -47,7 +47,30 @@ export interface ServerConfig {
|
|
|
47
47
|
* Markdown produces a readable PDF on a laptop and a boxed one in a container.
|
|
48
48
|
* Naming a font here removes the host from the answer.
|
|
49
49
|
*/
|
|
50
|
-
readonly pdfFont?:
|
|
50
|
+
readonly pdfFont?: PdfFontRef;
|
|
51
|
+
/**
|
|
52
|
+
* Faces consulted, in order, for characters {@link pdfFont} has no glyph for.
|
|
53
|
+
*
|
|
54
|
+
* One face is not enough for a document that mixes scripts, and the failure is not
|
|
55
|
+
* hypothetical: a Chinese face carries no Arabic, so a page of Chinese prose quoting one
|
|
56
|
+
* Arabic phrase either loses the phrase to `.notdef` boxes or — if the operator picks a
|
|
57
|
+
* pan-Unicode face to cover both — has all of its Han drawn by a face whose glyphs follow
|
|
58
|
+
* Japanese conventions. A chain lets the primary face be the regional one.
|
|
59
|
+
*/
|
|
60
|
+
readonly pdfFontFallbacks?: readonly PdfFontRef[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* One face, and which face inside the file when the file is a collection.
|
|
64
|
+
*
|
|
65
|
+
* `collectionIndex` exists because a `.ttc` holds several faces and the first one is not
|
|
66
|
+
* usually the one wanted: on macOS, `Songti.ttc` opens at weight 900, so naming that file
|
|
67
|
+
* and taking face 0 — which is what this server did — set every paragraph of Chinese body
|
|
68
|
+
* text in the heaviest weight the family ships. Its order is Black, Bold, TC-Bold, Light,
|
|
69
|
+
* STSong, TC-Light, Regular, TC-Regular, so the one wanted for body text is face 6.
|
|
70
|
+
*/
|
|
71
|
+
export interface PdfFontRef {
|
|
72
|
+
readonly path: string;
|
|
73
|
+
readonly collectionIndex?: number;
|
|
51
74
|
}
|
|
52
75
|
export declare class ConfigError extends Error {
|
|
53
76
|
readonly name = "ConfigError";
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,YAAI,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAEpG,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAuBrD,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,YAA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AAC,EAAE,SAAS,UAAU,EAAE,CAAC;CACnD;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAkB,IAAI,iBAAiB;CACxC;AAED,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,oBAAyB,GACjC,YAAY,CAkFd;AA8DD,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAK1F;AA2CD,+BAA+B;AAC/B,wBAAgB,KAAK,IAAI,MAAM,CAuC9B"}
|
package/dist/config.js
CHANGED
|
@@ -62,6 +62,7 @@ export function resolveConfig(argv, options = {}) {
|
|
|
62
62
|
"max-file-size": { type: "string" },
|
|
63
63
|
"max-output-chars": { type: "string" },
|
|
64
64
|
"pdf-font": { type: "string" },
|
|
65
|
+
"pdf-font-fallback": { type: "string", multiple: true },
|
|
65
66
|
help: { type: "boolean", short: "h", default: false },
|
|
66
67
|
version: { type: "boolean", short: "v", default: false }
|
|
67
68
|
},
|
|
@@ -105,6 +106,11 @@ export function resolveConfig(argv, options = {}) {
|
|
|
105
106
|
throw new ConfigError("--output-root must be disjoint from --root (neither may contain the other)");
|
|
106
107
|
}
|
|
107
108
|
const pdfFont = resolvePdfFont(values["pdf-font"], cwd);
|
|
109
|
+
const pdfFontFallbacks = (values["pdf-font-fallback"] ?? [])
|
|
110
|
+
.flatMap(entry => entry.split(","))
|
|
111
|
+
.map(entry => entry.trim())
|
|
112
|
+
.filter(entry => entry.length > 0)
|
|
113
|
+
.map(entry => resolvePdfFont(entry, cwd));
|
|
108
114
|
return {
|
|
109
115
|
root,
|
|
110
116
|
outputRoot,
|
|
@@ -113,7 +119,8 @@ export function resolveConfig(argv, options = {}) {
|
|
|
113
119
|
groups: parseGroups(values.enable),
|
|
114
120
|
maxFileSize: parseByteCount(values["max-file-size"], "--max-file-size", DEFAULT_MAX_FILE_SIZE),
|
|
115
121
|
maxOutputChars: parseByteCount(values["max-output-chars"], "--max-output-chars", DEFAULT_MAX_OUTPUT_CHARS),
|
|
116
|
-
...(pdfFont === undefined ? {} : { pdfFont })
|
|
122
|
+
...(pdfFont === undefined ? {} : { pdfFont }),
|
|
123
|
+
...(pdfFontFallbacks.length === 0 ? {} : { pdfFontFallbacks })
|
|
117
124
|
};
|
|
118
125
|
}
|
|
119
126
|
/**
|
|
@@ -131,7 +138,15 @@ function resolvePdfFont(input, cwd) {
|
|
|
131
138
|
if (input === undefined) {
|
|
132
139
|
return undefined;
|
|
133
140
|
}
|
|
134
|
-
|
|
141
|
+
// `path#index` selects a face inside a collection. Split from the right so a directory
|
|
142
|
+
// containing a `#` does not break, and only when what follows is entirely digits — a bare
|
|
143
|
+
// `#` in a filename is then left alone rather than read as a malformed index.
|
|
144
|
+
const hash = input.lastIndexOf("#");
|
|
145
|
+
const suffix = hash < 0 ? "" : input.slice(hash + 1);
|
|
146
|
+
const indexed = hash > 0 && /^\d+$/.test(suffix);
|
|
147
|
+
const file = indexed ? input.slice(0, hash) : input;
|
|
148
|
+
const collectionIndex = indexed ? Number(suffix) : undefined;
|
|
149
|
+
const absolute = path.resolve(cwd, file);
|
|
135
150
|
let head;
|
|
136
151
|
try {
|
|
137
152
|
head = readFileSync(absolute).subarray(0, 4);
|
|
@@ -148,7 +163,11 @@ function resolvePdfFont(input, cwd) {
|
|
|
148
163
|
if (version !== 0x00010000 && magic !== "true" && magic !== "ttcf") {
|
|
149
164
|
throw new ConfigError(`--pdf-font is not a TrueType font: ${input}. Expected a .ttf or .ttc file.`);
|
|
150
165
|
}
|
|
151
|
-
|
|
166
|
+
if (collectionIndex !== undefined && magic !== "ttcf") {
|
|
167
|
+
throw new ConfigError(`--pdf-font names face ${collectionIndex} of ${file}, which is not a font collection. ` +
|
|
168
|
+
`Drop the "#${suffix}" — a .ttf holds one face.`);
|
|
169
|
+
}
|
|
170
|
+
return collectionIndex === undefined ? { path: absolute } : { path: absolute, collectionIndex };
|
|
152
171
|
}
|
|
153
172
|
function containsPath(parent, child) {
|
|
154
173
|
const relative = path.relative(parent, child);
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAIpG,iDAAiD;AACjD,MAAM,cAAc,GAAyB;IAC3C,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,OAAO;IACP,SAAS;IACT,SAAS;CACV,CAAC;AAEF,sEAAsE;AACtE,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/C;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAA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M,GAAG,IAAI,GAAG,CAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;QAC9B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,WAAW,CACnB,4BAA4B,KAAK,aAAa,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACxE,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAQ,WAAiC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,cAAc,CAAC,GAAuB,EAAE,IAAY,EAAE,QAAgB;IAC7E,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,WAAW,CAAC,GAAG,IAAI,qCAAqC,GAAG,GAAG,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,+BAA+B;AAC/B,MAAM,UAAU,KAAK;IACnB,OAAO;;;;;;;;;;;;;;;uCAe8B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;;wEAEW,qBAAqB;+DAC9B,wBAAwB;;;;;;;;;;;;;;;;;;;CAmBtF,CAAC;AACF,CAAC"}
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -29,9 +29,9 @@ export interface ResolveOptions {
|
|
|
29
29
|
* Turn a model-supplied path into an absolute path guaranteed to sit inside
|
|
30
30
|
* `config.root`.
|
|
31
31
|
*
|
|
32
|
-
* @throws {McpToolError} `invalid_input` for a URL
|
|
33
|
-
* `not_found` when `mustExist` is set and
|
|
34
|
-
* `outside_root` for anything that escapes the sandbox.
|
|
32
|
+
* @throws {McpToolError} `invalid_input` for a URL, an empty string, a NUL byte
|
|
33
|
+
* or a reserved Windows device name, `not_found` when `mustExist` is set and
|
|
34
|
+
* it is not there, and `outside_root` for anything that escapes the sandbox.
|
|
35
35
|
*/
|
|
36
36
|
export declare function resolveInRoot(config: ServerConfig, userPath: string, options?: ResolveOptions): Promise<string>;
|
|
37
37
|
/**
|
|
@@ -46,6 +46,19 @@ export declare function resolveWriteTarget(config: ServerConfig, userPath: strin
|
|
|
46
46
|
}): Promise<WriteTarget>;
|
|
47
47
|
/** Resolve a write destination inside the disjoint output root. */
|
|
48
48
|
export declare function resolveOutputPath(config: ServerConfig, userPath: string): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* The first path segment that names a Win32 device, or undefined.
|
|
51
|
+
*
|
|
52
|
+
* Exported for tests: the guard above only fires on Windows, so this is the
|
|
53
|
+
* only way to assert the matching rules on any host.
|
|
54
|
+
*
|
|
55
|
+
* A segment is cut at its first `.` or `:` before matching, because Windows
|
|
56
|
+
* resolves both `NUL.txt` and `NUL:stream` to the device — the extension and
|
|
57
|
+
* the stream suffix are not part of the name it looks up. Surrounding blanks go
|
|
58
|
+
* too, since the parser ignores them. `NULL` and `CONSOLE` survive all of that
|
|
59
|
+
* and stay ordinary files.
|
|
60
|
+
*/
|
|
61
|
+
export declare function reservedDeviceSegment(userPath: string): string | undefined;
|
|
49
62
|
/** Public display spelling for a path under the output root. */
|
|
50
63
|
export declare function outputDisplay(userPath: string): string;
|
|
51
64
|
export interface WriteTarget {
|
package/dist/sandbox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,KAAK,EA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pB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB,OAAO,CAAC,WAAW,CAAC,CAQtB;AAYD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAOzD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAW/D"}
|
package/dist/sandbox.js
CHANGED
|
@@ -24,21 +24,36 @@ import { toolError } from "./errors.js";
|
|
|
24
24
|
const MAX_SYMLINK_DEPTH = 32;
|
|
25
25
|
/** Matches a URL scheme (`http:`, `file:`) without matching a Windows drive letter (`C:`). */
|
|
26
26
|
const URL_SCHEME_RE = /^[a-zA-Z][a-zA-Z0-9+.-]+:/;
|
|
27
|
+
/**
|
|
28
|
+
* Win32 device names, reserved in *every* directory rather than living in one
|
|
29
|
+
* place on disk.
|
|
30
|
+
*
|
|
31
|
+
* The set is Microsoft's, not a guess
|
|
32
|
+
* ({@link https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file | Naming a File}),
|
|
33
|
+
* and two entries in it surprise people:
|
|
34
|
+
*
|
|
35
|
+
* - The ISO 8859-1 superscripts `¹²³` are treated as digits by the Win32 path
|
|
36
|
+
* parser, so `COM¹` is the same device as `COM1`. They have no case, so
|
|
37
|
+
* upper-casing before the test leaves them alone.
|
|
38
|
+
* - `CONIN$`/`CONOUT$` are the console's input and output handles. They are
|
|
39
|
+
* absent from the "do not use" list but `CreateFile` opens them, which is all
|
|
40
|
+
* that matters here.
|
|
41
|
+
*
|
|
42
|
+
* `COM0`/`LPT0` are deliberately *not* included: no such device exists, so a
|
|
43
|
+
* file of that name is an ordinary file and refusing it would be a false
|
|
44
|
+
* positive on every platform.
|
|
45
|
+
*/
|
|
46
|
+
const WINDOWS_RESERVED_DEVICE_RE = /^(?:CON|PRN|AUX|NUL|CONIN\$|CONOUT\$|COM[1-9¹²³]|LPT[1-9¹²³])$/;
|
|
27
47
|
/**
|
|
28
48
|
* Turn a model-supplied path into an absolute path guaranteed to sit inside
|
|
29
49
|
* `config.root`.
|
|
30
50
|
*
|
|
31
|
-
* @throws {McpToolError} `invalid_input` for a URL
|
|
32
|
-
* `not_found` when `mustExist` is set and
|
|
33
|
-
* `outside_root` for anything that escapes the sandbox.
|
|
51
|
+
* @throws {McpToolError} `invalid_input` for a URL, an empty string, a NUL byte
|
|
52
|
+
* or a reserved Windows device name, `not_found` when `mustExist` is set and
|
|
53
|
+
* it is not there, and `outside_root` for anything that escapes the sandbox.
|
|
34
54
|
*/
|
|
35
55
|
export async function resolveInRoot(config, userPath, options = {}) {
|
|
36
|
-
|
|
37
|
-
throw toolError.invalidInput("path must be a non-empty string");
|
|
38
|
-
}
|
|
39
|
-
if (URL_SCHEME_RE.test(userPath)) {
|
|
40
|
-
throw toolError.invalidInput(`path must be a local path inside the sandbox, not a URL: ${userPath}`, "Use a path relative to the server root. This server reads local files only.");
|
|
41
|
-
}
|
|
56
|
+
assertUsablePath(userPath);
|
|
42
57
|
const outputRelative = outputPathPart(userPath);
|
|
43
58
|
const base = outputRelative === undefined ? config.root : config.outputRoot;
|
|
44
59
|
const relative = outputRelative ?? userPath;
|
|
@@ -87,6 +102,7 @@ export async function resolveWriteTarget(config, userPath, options = {}) {
|
|
|
87
102
|
}
|
|
88
103
|
/** Resolve a write destination inside the disjoint output root. */
|
|
89
104
|
export async function resolveOutputPath(config, userPath) {
|
|
105
|
+
assertUsablePath(userPath);
|
|
90
106
|
const relative = outputPathPart(userPath) ?? userPath;
|
|
91
107
|
if (path.isAbsolute(relative)) {
|
|
92
108
|
throw toolError.invalidInput(`output path must be relative: ${userPath}`, "Write paths are relative to --output-root and are returned as @output/<path>.");
|
|
@@ -107,6 +123,60 @@ async function resolveInputSidecar(config, userPath) {
|
|
|
107
123
|
}
|
|
108
124
|
return resolved;
|
|
109
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Reject a path string that cannot safely name a file, before it is resolved.
|
|
128
|
+
*
|
|
129
|
+
* Separate from containment because these are properties of the *string*, and
|
|
130
|
+
* two of them are invisible to a containment check:
|
|
131
|
+
*
|
|
132
|
+
* - A NUL byte. Node throws on it deep inside `fs`, which surfaced to the model
|
|
133
|
+
* as an unclassified `internal` error carrying a raw library message. It is an
|
|
134
|
+
* invalid argument, and saying so is what lets the model correct itself.
|
|
135
|
+
* - A Win32 device name. `NUL`, `CON`, `COM1` are reserved in every directory,
|
|
136
|
+
* so `<root>/CON` passes containment yet opens the *console* rather than a
|
|
137
|
+
* file — and this server's console is the stdio transport it speaks JSON-RPC
|
|
138
|
+
* over. Reading it would wedge the process. Refused on Windows only, because
|
|
139
|
+
* on POSIX a file called `NUL` is an ordinary file and rejecting it would be
|
|
140
|
+
* a false positive.
|
|
141
|
+
*/
|
|
142
|
+
function assertUsablePath(userPath) {
|
|
143
|
+
if (typeof userPath !== "string" || userPath.trim().length === 0) {
|
|
144
|
+
throw toolError.invalidInput("path must be a non-empty string");
|
|
145
|
+
}
|
|
146
|
+
if (userPath.includes("\u0000")) {
|
|
147
|
+
throw toolError.invalidInput("path must not contain a NUL byte", "Pass the plain file name. A NUL byte cannot appear in a filesystem path.");
|
|
148
|
+
}
|
|
149
|
+
if (URL_SCHEME_RE.test(userPath)) {
|
|
150
|
+
throw toolError.invalidInput(`path must be a local path inside the sandbox, not a URL: ${userPath}`, "Use a path relative to the server root. This server reads local files only.");
|
|
151
|
+
}
|
|
152
|
+
if (process.platform === "win32") {
|
|
153
|
+
const reserved = reservedDeviceSegment(userPath);
|
|
154
|
+
if (reserved !== undefined) {
|
|
155
|
+
throw toolError.invalidInput(`path names a reserved Windows device: ${reserved}`, "Rename the file. CON, PRN, AUX, NUL, COM<n> and LPT<n> address hardware on Windows, not files on disk.");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The first path segment that names a Win32 device, or undefined.
|
|
161
|
+
*
|
|
162
|
+
* Exported for tests: the guard above only fires on Windows, so this is the
|
|
163
|
+
* only way to assert the matching rules on any host.
|
|
164
|
+
*
|
|
165
|
+
* A segment is cut at its first `.` or `:` before matching, because Windows
|
|
166
|
+
* resolves both `NUL.txt` and `NUL:stream` to the device — the extension and
|
|
167
|
+
* the stream suffix are not part of the name it looks up. Surrounding blanks go
|
|
168
|
+
* too, since the parser ignores them. `NULL` and `CONSOLE` survive all of that
|
|
169
|
+
* and stay ordinary files.
|
|
170
|
+
*/
|
|
171
|
+
export function reservedDeviceSegment(userPath) {
|
|
172
|
+
for (const segment of userPath.split(/[/\\]/)) {
|
|
173
|
+
const stem = (segment.split(/[.:]/)[0] ?? "").trim();
|
|
174
|
+
if (WINDOWS_RESERVED_DEVICE_RE.test(stem.toUpperCase())) {
|
|
175
|
+
return segment;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
110
180
|
/** Return the path after the virtual @output/ prefix, or undefined for input. */
|
|
111
181
|
function outputPathPart(userPath) {
|
|
112
182
|
const normalised = userPath.replace(/\\/g, "/");
|
package/dist/sandbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,+DAA+D;AAC/D,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,8FAA8F;AAC9F,MAAM,aAAa,GAAG,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAA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MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,eAAe,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC7F,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAEnE,IAAI,KAAK,CAAC;IACV,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA2B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACnD,sEAAsE;YACtE,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IAChF,OAAO,MAAM,eAAe,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -18,8 +18,19 @@
|
|
|
18
18
|
* edge of the paper. Fitting to the text width is the difference between a
|
|
19
19
|
* document and a broken one.
|
|
20
20
|
*/
|
|
21
|
+
import { type DrawList, type RasterFontSource } from "documonster/draw";
|
|
22
|
+
import type { MermaidRenderOptions } from "documonster/mermaid";
|
|
21
23
|
import type { MarkdownImportOptions } from "documonster/word/markdown";
|
|
22
24
|
import { type DiagramStyleArgs } from "./diagram.js";
|
|
25
|
+
/**
|
|
26
|
+
* Tallest a single embedded piece may be, in points: the page less its margins, less a little.
|
|
27
|
+
*
|
|
28
|
+
* The slack is not decoration. An image exactly as tall as the text area cannot share a page
|
|
29
|
+
* with *anything* — not even the heading it belongs to — so Word pushes it alone onto the next
|
|
30
|
+
* page and leaves the heading stranded at the bottom of the previous one, which is how a
|
|
31
|
+
* document grew a near-empty page before every large diagram.
|
|
32
|
+
*/
|
|
33
|
+
export declare const MAX_EMBED_HEIGHT_POINTS = 550;
|
|
23
34
|
export interface PreparedMarkdown {
|
|
24
35
|
/** The Markdown with every mermaid fence replaced by an image reference. */
|
|
25
36
|
readonly markdown: string;
|
|
@@ -28,11 +39,32 @@ export interface PreparedMarkdown {
|
|
|
28
39
|
* fence was rendered, so the no-diagram path behaves exactly as before.
|
|
29
40
|
*/
|
|
30
41
|
readonly resolveImage?: MarkdownImportOptions["resolveImage"];
|
|
31
|
-
/** How many diagrams were rendered. */
|
|
32
|
-
readonly count: number;
|
|
33
42
|
/** Lines worth reporting to the caller. */
|
|
34
43
|
readonly notes: readonly string[];
|
|
35
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The narrowest layout of a diagram that the text column can show legibly.
|
|
47
|
+
*
|
|
48
|
+
* Walks {@link FIT_LADDER} and stops at the first rung whose text clears
|
|
49
|
+
* {@link MIN_EMBED_FONT_POINTS} — first, not best, because the ladder is ordered by what each
|
|
50
|
+
* concession costs a reader, so the earliest rung that works is the least damage. Height is
|
|
51
|
+
* not a constraint here: a diagram taller than a page is cut across pages instead of being
|
|
52
|
+
* shrunk back into one, which would give away the legibility the narrowing just bought.
|
|
53
|
+
*
|
|
54
|
+
* If no rung clears the bar — a rank with nine nodes in it is wide however hard the labels
|
|
55
|
+
* wrap — the narrowest attempt is used and the caller is told, because a diagram nobody can
|
|
56
|
+
* read is worth a line of output rather than silence.
|
|
57
|
+
*
|
|
58
|
+
* A caller who set any of the layout numbers themselves is left alone: they have said what the
|
|
59
|
+
* layout should be, and second-guessing an explicit argument is worse than a small image.
|
|
60
|
+
*/
|
|
61
|
+
export declare function fitToColumn(source: string, options: MermaidRenderOptions & {
|
|
62
|
+
readonly background: string;
|
|
63
|
+
}, tune: boolean): {
|
|
64
|
+
list: DrawList;
|
|
65
|
+
fit: number;
|
|
66
|
+
short: boolean;
|
|
67
|
+
};
|
|
36
68
|
/**
|
|
37
69
|
* Render every mermaid fence in `markdown` and rewrite it as an inline image.
|
|
38
70
|
*
|
|
@@ -41,5 +73,8 @@ export interface PreparedMarkdown {
|
|
|
41
73
|
* throw away the nine paragraphs that were fine, and the note names the line to
|
|
42
74
|
* fix.
|
|
43
75
|
*/
|
|
44
|
-
export declare function prepareMarkdownDiagrams(markdown: string, style?: DiagramStyleArgs
|
|
76
|
+
export declare function prepareMarkdownDiagrams(markdown: string, style?: DiagramStyleArgs, fonts?: {
|
|
77
|
+
readonly raster?: readonly RasterFontSource[];
|
|
78
|
+
readonly useSystemFonts?: boolean;
|
|
79
|
+
}): Promise<PreparedMarkdown>;
|
|
45
80
|
//# sourceMappingURL=diagram-markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagram-markdown.d.ts","sourceRoot":"","sources":["../../src/tools/diagram-markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"diagram-markdown.d.ts","sourceRoot":"","sources":["../../src/tools/diagram-markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAA8B,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAqB,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAI1F,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AAWtB;;;;;;;GAOG;AAIH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AA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