@documonster/mcp 0.8.0-canary.sha.09791dab
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/LICENSE +205 -0
- package/README.md +253 -0
- package/dist/capabilities.d.ts +29 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +188 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/cli.d.ts +13 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +64 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +65 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +189 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +66 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +96 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/sandbox.d.ts +86 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +224 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/server.d.ts +22 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +66 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/archive-read.d.ts +31 -0
- package/dist/tools/archive-read.d.ts.map +1 -0
- package/dist/tools/archive-read.js +315 -0
- package/dist/tools/archive-read.js.map +1 -0
- package/dist/tools/archive-write.d.ts +9 -0
- package/dist/tools/archive-write.d.ts.map +1 -0
- package/dist/tools/archive-write.js +219 -0
- package/dist/tools/archive-write.js.map +1 -0
- package/dist/tools/chart.d.ts +93 -0
- package/dist/tools/chart.d.ts.map +1 -0
- package/dist/tools/chart.js +263 -0
- package/dist/tools/chart.js.map +1 -0
- package/dist/tools/doc-convert.d.ts +13 -0
- package/dist/tools/doc-convert.d.ts.map +1 -0
- package/dist/tools/doc-convert.js +209 -0
- package/dist/tools/doc-convert.js.map +1 -0
- package/dist/tools/doc-paginate.d.ts +14 -0
- package/dist/tools/doc-paginate.d.ts.map +1 -0
- package/dist/tools/doc-paginate.js +153 -0
- package/dist/tools/doc-paginate.js.map +1 -0
- package/dist/tools/doc-read.d.ts +14 -0
- package/dist/tools/doc-read.d.ts.map +1 -0
- package/dist/tools/doc-read.js +175 -0
- package/dist/tools/doc-read.js.map +1 -0
- package/dist/tools/doc-review.d.ts +17 -0
- package/dist/tools/doc-review.d.ts.map +1 -0
- package/dist/tools/doc-review.js +249 -0
- package/dist/tools/doc-review.js.map +1 -0
- package/dist/tools/doc-search.d.ts +20 -0
- package/dist/tools/doc-search.d.ts.map +1 -0
- package/dist/tools/doc-search.js +268 -0
- package/dist/tools/doc-search.js.map +1 -0
- package/dist/tools/doc-write.d.ts +11 -0
- package/dist/tools/doc-write.d.ts.map +1 -0
- package/dist/tools/doc-write.js +81 -0
- package/dist/tools/doc-write.js.map +1 -0
- package/dist/tools/document.d.ts +74 -0
- package/dist/tools/document.d.ts.map +1 -0
- package/dist/tools/document.js +157 -0
- package/dist/tools/document.js.map +1 -0
- package/dist/tools/form-fill.d.ts +20 -0
- package/dist/tools/form-fill.d.ts.map +1 -0
- package/dist/tools/form-fill.js +270 -0
- package/dist/tools/form-fill.js.map +1 -0
- package/dist/tools/formula-evaluate.d.ts +14 -0
- package/dist/tools/formula-evaluate.d.ts.map +1 -0
- package/dist/tools/formula-evaluate.js +192 -0
- package/dist/tools/formula-evaluate.js.map +1 -0
- package/dist/tools/fs-helpers.d.ts +106 -0
- package/dist/tools/fs-helpers.d.ts.map +1 -0
- package/dist/tools/fs-helpers.js +257 -0
- package/dist/tools/fs-helpers.js.map +1 -0
- package/dist/tools/help.d.ts +227 -0
- package/dist/tools/help.d.ts.map +1 -0
- package/dist/tools/help.js +262 -0
- package/dist/tools/help.js.map +1 -0
- package/dist/tools/index.d.ts +33 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +78 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/inspect.d.ts +14 -0
- package/dist/tools/inspect.d.ts.map +1 -0
- package/dist/tools/inspect.js +463 -0
- package/dist/tools/inspect.js.map +1 -0
- package/dist/tools/pdf-edit.d.ts +26 -0
- package/dist/tools/pdf-edit.d.ts.map +1 -0
- package/dist/tools/pdf-edit.js +390 -0
- package/dist/tools/pdf-edit.js.map +1 -0
- package/dist/tools/result.d.ts +25 -0
- package/dist/tools/result.d.ts.map +1 -0
- package/dist/tools/result.js +43 -0
- package/dist/tools/result.js.map +1 -0
- package/dist/tools/sheet-edit.d.ts +16 -0
- package/dist/tools/sheet-edit.d.ts.map +1 -0
- package/dist/tools/sheet-edit.js +325 -0
- package/dist/tools/sheet-edit.js.map +1 -0
- package/dist/tools/sheet-read.d.ts +10 -0
- package/dist/tools/sheet-read.d.ts.map +1 -0
- package/dist/tools/sheet-read.js +139 -0
- package/dist/tools/sheet-read.js.map +1 -0
- package/dist/tools/sheet-write.d.ts +15 -0
- package/dist/tools/sheet-write.d.ts.map +1 -0
- package/dist/tools/sheet-write.js +290 -0
- package/dist/tools/sheet-write.js.map +1 -0
- package/dist/tools/spreadsheet.d.ts +100 -0
- package/dist/tools/spreadsheet.d.ts.map +1 -0
- package/dist/tools/spreadsheet.js +210 -0
- package/dist/tools/spreadsheet.js.map +1 -0
- package/dist/tools/template.d.ts +18 -0
- package/dist/tools/template.d.ts.map +1 -0
- package/dist/tools/template.js +209 -0
- package/dist/tools/template.js.map +1 -0
- package/dist/tools/types.d.ts +79 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +18 -0
- package/dist/tools/types.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared document helpers for the Word / PDF tools.
|
|
3
|
+
*
|
|
4
|
+
* Concentrates three things the document tools must not each re-derive: which
|
|
5
|
+
* format a path denotes, the awkward corners of the underlying API that were
|
|
6
|
+
* verified empirically, and paginating long text so a tool result never blows
|
|
7
|
+
* the caller's context.
|
|
8
|
+
*/
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { toolError } from "../errors.js";
|
|
11
|
+
const EXTENSION_FORMATS = {
|
|
12
|
+
".docx": "docx",
|
|
13
|
+
".docm": "docx",
|
|
14
|
+
".pdf": "pdf",
|
|
15
|
+
".md": "md",
|
|
16
|
+
".markdown": "md",
|
|
17
|
+
".html": "html",
|
|
18
|
+
".htm": "html",
|
|
19
|
+
".txt": "txt",
|
|
20
|
+
".xlsx": "xlsx",
|
|
21
|
+
".xlsm": "xlsx",
|
|
22
|
+
".csv": "csv",
|
|
23
|
+
".odt": "odt"
|
|
24
|
+
};
|
|
25
|
+
/** Format implied by a path's extension, or `undefined` when unrecognised. */
|
|
26
|
+
function formatFromPath(filePath) {
|
|
27
|
+
return EXTENSION_FORMATS[path.extname(filePath).toLowerCase()];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Format implied by a path, or a tool error naming what is supported.
|
|
31
|
+
*
|
|
32
|
+
* Listing the accepted extensions in the error matters: a model that guessed
|
|
33
|
+
* `.doc` can correct itself in one step instead of retrying variations.
|
|
34
|
+
*/
|
|
35
|
+
export function requireFormat(filePath, field) {
|
|
36
|
+
const format = formatFromPath(filePath);
|
|
37
|
+
if (format === undefined) {
|
|
38
|
+
throw toolError.invalidInput(`cannot tell the format of ${field} from its extension: ${JSON.stringify(filePath)}`, `Use one of: ${Object.keys(EXTENSION_FORMATS).join(", ")}`);
|
|
39
|
+
}
|
|
40
|
+
return format;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reject macro-enabled extensions for newly generated output.
|
|
44
|
+
*
|
|
45
|
+
* The writer produces ordinary DOCX/XLSX content. Naming that package `.docm`
|
|
46
|
+
* or `.xlsm` does not make it macro-enabled; worse, rewriting an existing macro
|
|
47
|
+
* file through a path that cannot prove VBA preservation risks silent macro
|
|
48
|
+
* loss. Read operations may still inspect such files.
|
|
49
|
+
*/
|
|
50
|
+
export function assertNonMacroOutput(filePath) {
|
|
51
|
+
const extension = path.extname(filePath).toLowerCase();
|
|
52
|
+
if (extension === ".docm" || extension === ".xlsm") {
|
|
53
|
+
throw toolError.unsupported(`cannot write ${extension} output safely`, `Use ${extension === ".docm" ? ".docx" : ".xlsx"}. A normal OOXML package with a macro-enabled extension is invalid, and this tool does not create or verify a VBA project.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Take a line-bounded window of text.
|
|
58
|
+
*
|
|
59
|
+
* Line-based rather than character-based so the cursor a caller passes back is
|
|
60
|
+
* stable and meaningful: "continue from line 240" survives, whereas a character
|
|
61
|
+
* offset into re-extracted text does not.
|
|
62
|
+
*/
|
|
63
|
+
export function takeLines(text, startLine, maxLines) {
|
|
64
|
+
const lines = text.split("\n");
|
|
65
|
+
const from = Math.max(1, startLine);
|
|
66
|
+
const to = Math.min(lines.length, from + maxLines - 1);
|
|
67
|
+
return {
|
|
68
|
+
text: lines.slice(from - 1, to).join("\n"),
|
|
69
|
+
startLine: from,
|
|
70
|
+
endLine: to,
|
|
71
|
+
totalLines: lines.length,
|
|
72
|
+
truncated: to < lines.length
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Render the standard "here is what I left out" footer.
|
|
77
|
+
*
|
|
78
|
+
* Always emitted when content was cut, because a model given a silent partial
|
|
79
|
+
* read will reason over it as though it were complete.
|
|
80
|
+
*/
|
|
81
|
+
export function continuationNote(window, cursorField = "startLine") {
|
|
82
|
+
if (!window.truncated) {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
return [
|
|
86
|
+
`- **${window.totalLines - window.endLine} more line(s) not shown.** Continue with \`${cursorField}: ${window.endLine + 1}\`.`
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Normalize a page selection into 1-based page numbers.
|
|
91
|
+
*
|
|
92
|
+
* Accepts `[1,2,5]` or `"1-3,7"`, because a model reaches for both.
|
|
93
|
+
*/
|
|
94
|
+
export function parsePages(pages) {
|
|
95
|
+
if (pages === undefined) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
if (typeof pages !== "string") {
|
|
99
|
+
if (pages.length > MAX_SELECTABLE_PAGES) {
|
|
100
|
+
throw toolError.invalidInput(`page selection lists ${pages.length} pages, over the ${MAX_SELECTABLE_PAGES} limit`);
|
|
101
|
+
}
|
|
102
|
+
return pages.map(page => assertPage(page));
|
|
103
|
+
}
|
|
104
|
+
const out = [];
|
|
105
|
+
for (const part of pages.split(",")) {
|
|
106
|
+
const trimmed = part.trim();
|
|
107
|
+
if (trimmed.length === 0) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const dash = trimmed.indexOf("-");
|
|
111
|
+
if (dash > 0) {
|
|
112
|
+
const from = assertPage(Number(trimmed.slice(0, dash)));
|
|
113
|
+
const to = assertPage(Number(trimmed.slice(dash + 1)));
|
|
114
|
+
if (to < from) {
|
|
115
|
+
throw toolError.invalidInput(`page range ${JSON.stringify(trimmed)} runs backwards`);
|
|
116
|
+
}
|
|
117
|
+
// Bound the span before expanding it: "1-1000000000" would otherwise
|
|
118
|
+
// allocate a billion entries before any page-count check could reject it.
|
|
119
|
+
if (to - from + 1 > MAX_SELECTABLE_PAGES ||
|
|
120
|
+
out.length + (to - from + 1) > MAX_SELECTABLE_PAGES) {
|
|
121
|
+
throw toolError.invalidInput(`page selection ${JSON.stringify(trimmed)} covers more than ${MAX_SELECTABLE_PAGES} pages`, "Name a narrower range; no document here has that many pages.");
|
|
122
|
+
}
|
|
123
|
+
for (let page = from; page <= to; page += 1) {
|
|
124
|
+
out.push(page);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
out.push(assertPage(Number(trimmed)));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (out.length === 0) {
|
|
132
|
+
throw toolError.invalidInput(`could not parse ${JSON.stringify(pages)} as pages`, 'Use a list like [1,2,5] or a string like "1-3,7".');
|
|
133
|
+
}
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
function assertPage(value) {
|
|
137
|
+
if (!Number.isInteger(value) || value < 1) {
|
|
138
|
+
throw toolError.invalidInput(`${value} is not a 1-based page number`);
|
|
139
|
+
}
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Whether a PDF can receive a genuine incremental update.
|
|
144
|
+
*
|
|
145
|
+
* `PdfEditor.saveIncremental()` silently falls back to a full rebuild for
|
|
146
|
+
* xref-stream files (PDF 1.5+ without a `trailer` keyword). A full rebuild
|
|
147
|
+
* renumbers objects and invalidates any existing signature, so a tool must not
|
|
148
|
+
* claim "signature preserved" without checking — and callers deserve to know
|
|
149
|
+
* when structure may be reorganised.
|
|
150
|
+
*/
|
|
151
|
+
export function supportsIncrementalUpdate(bytes) {
|
|
152
|
+
const tail = bytes.subarray(Math.max(0, bytes.length - 1024));
|
|
153
|
+
return new TextDecoder().decode(tail).includes("trailer");
|
|
154
|
+
}
|
|
155
|
+
/** Cap on how many pages a selector may name, before it is expanded. */
|
|
156
|
+
export const MAX_SELECTABLE_PAGES = 10_000;
|
|
157
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/tools/document.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAWzC,MAAM,iBAAiB,GAAwC;IAC7D,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,IAAI;IACX,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,MAAM;IACf,OAAO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,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,SAAS,CAAC,YAAY,CAC1B,mBAAmB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,EACnD,mDAAmD,CACpD,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,SAAS,CAAC,YAAY,CAAC,GAAG,KAAK,+BAA+B,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAiB;IACzD,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAC9D,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC5D,CAAC;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `form_fill` — list and fill form fields in Word documents and PDFs.
|
|
3
|
+
*
|
|
4
|
+
* Another well-shaped task, for the same reason as templates: the document
|
|
5
|
+
* declares what it needs, so listing the fields *is* the schema and the model
|
|
6
|
+
* supplies only values. "Fill in this form" is also one of the most concrete
|
|
7
|
+
* requests a user can make, which makes it hard to get subtly wrong.
|
|
8
|
+
*
|
|
9
|
+
* One implementation detail is load-bearing. A PDF must be saved with
|
|
10
|
+
* `saveIncremental()`, not `save()`: the full rebuild path drops AcroForm
|
|
11
|
+
* values, so `save()` produces a document that looks fine and contains none of
|
|
12
|
+
* the answers. Verified empirically — do not "simplify" this.
|
|
13
|
+
*
|
|
14
|
+
* The corollary is that a PDF whose format cannot take an incremental update
|
|
15
|
+
* (a cross-reference stream file) cannot be filled correctly at all here. Such a
|
|
16
|
+
* file is refused rather than written, because the failure is invisible: the
|
|
17
|
+
* output opens, looks like the right form, and is blank.
|
|
18
|
+
*/
|
|
19
|
+
export declare const formFillTool: import("./types.js").AnyToolDefinition;
|
|
20
|
+
//# sourceMappingURL=form-fill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-fill.d.ts","sourceRoot":"","sources":["../../src/tools/form-fill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAmCH,eAAO,MAAM,YAAY,wCA0FvB,CAAC"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `form_fill` — list and fill form fields in Word documents and PDFs.
|
|
3
|
+
*
|
|
4
|
+
* Another well-shaped task, for the same reason as templates: the document
|
|
5
|
+
* declares what it needs, so listing the fields *is* the schema and the model
|
|
6
|
+
* supplies only values. "Fill in this form" is also one of the most concrete
|
|
7
|
+
* requests a user can make, which makes it hard to get subtly wrong.
|
|
8
|
+
*
|
|
9
|
+
* One implementation detail is load-bearing. A PDF must be saved with
|
|
10
|
+
* `saveIncremental()`, not `save()`: the full rebuild path drops AcroForm
|
|
11
|
+
* values, so `save()` produces a document that looks fine and contains none of
|
|
12
|
+
* the answers. Verified empirically — do not "simplify" this.
|
|
13
|
+
*
|
|
14
|
+
* The corollary is that a PDF whose format cannot take an incremental update
|
|
15
|
+
* (a cross-reference stream file) cannot be filled correctly at all here. Such a
|
|
16
|
+
* file is refused rather than written, because the failure is invisible: the
|
|
17
|
+
* output opens, looks like the right form, and is blank.
|
|
18
|
+
*/
|
|
19
|
+
import { readFile } from "node:fs/promises";
|
|
20
|
+
import { Pdf } from "documonster/pdf";
|
|
21
|
+
import { Io, Query } from "documonster/word";
|
|
22
|
+
import { z } from "zod";
|
|
23
|
+
import { toolError } from "../errors.js";
|
|
24
|
+
import { assertWritable, resolveEditTarget, resolveInRoot } from "../sandbox.js";
|
|
25
|
+
import { requireFormat, supportsIncrementalUpdate } from "./document.js";
|
|
26
|
+
import { assertReadableSize, assertUnchanged, backupOnce, describeBackup, exists, fingerprint, isSameFile, replaceAtomically, writeFileAtomic } from "./fs-helpers.js";
|
|
27
|
+
import { textResult } from "./result.js";
|
|
28
|
+
import { defineTool } from "./types.js";
|
|
29
|
+
/** Fields listed in one call. */
|
|
30
|
+
const MAX_FIELDS = 200;
|
|
31
|
+
export const formFillTool = defineTool({
|
|
32
|
+
name: "form_fill",
|
|
33
|
+
group: "forms",
|
|
34
|
+
title: "List or fill form fields",
|
|
35
|
+
description: "List the fillable fields in a .docx or .pdf form, or fill them from supplied values. Call it without `values` first: the field list tells you exactly what names and types the form expects, so there is nothing to guess. Works with Word legacy form fields and PDF AcroForms.",
|
|
36
|
+
inputSchema: {
|
|
37
|
+
path: z.string().min(1).describe("Form path (.docx or .pdf), relative to the server root."),
|
|
38
|
+
values: z
|
|
39
|
+
.record(z.string(), z.union([z.string(), z.boolean(), z.number()]))
|
|
40
|
+
.optional()
|
|
41
|
+
.describe('Values keyed by field name, e.g. { "fullName": "Jane Doe", "agree": true }. Omit to list the fields without changing anything.'),
|
|
42
|
+
out: z
|
|
43
|
+
.string()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("Write the filled form below @output/. Required for input files unless --allow-in-place is enabled."),
|
|
46
|
+
backup: z
|
|
47
|
+
.boolean()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe("When filling in place, copy the original to <name>.bak first. Defaults to true."),
|
|
50
|
+
overwrite: z
|
|
51
|
+
.boolean()
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Replace an existing `out` file. Defaults to false. Does not apply in place.")
|
|
54
|
+
},
|
|
55
|
+
annotations: {
|
|
56
|
+
readOnlyHint: false,
|
|
57
|
+
destructiveHint: true,
|
|
58
|
+
idempotentHint: true,
|
|
59
|
+
openWorldHint: false
|
|
60
|
+
},
|
|
61
|
+
// Listing is read-only; only filling writes. Declared non-mutating so the
|
|
62
|
+
// tool stays visible under --readonly — a read-only server should still be
|
|
63
|
+
// able to report what fields a form has — and the write path calls
|
|
64
|
+
// assertWritable itself.
|
|
65
|
+
mutates: false,
|
|
66
|
+
handler: async (args, context) => {
|
|
67
|
+
const { config } = context;
|
|
68
|
+
const resolved = await resolveInRoot(config, args.path, { mustExist: true });
|
|
69
|
+
await assertReadableSize(config, resolved, args.path);
|
|
70
|
+
const inputVersion = await fingerprint(resolved);
|
|
71
|
+
const format = requireFormat(args.path, "path");
|
|
72
|
+
if (format !== "docx" && format !== "pdf") {
|
|
73
|
+
throw toolError.unsupported(`form_fill works with .docx and .pdf, not .${format}`, "For spreadsheets use sheet_edit; for Word templates with {{placeholders}} use template_fill.");
|
|
74
|
+
}
|
|
75
|
+
if (args.values === undefined) {
|
|
76
|
+
return textResult(config, format === "docx"
|
|
77
|
+
? await listWordFields(resolved, args.path)
|
|
78
|
+
: await listPdfFields(resolved, args.path));
|
|
79
|
+
}
|
|
80
|
+
assertWritable(config);
|
|
81
|
+
if (args.out !== undefined && requireFormat(args.out, "out") !== format) {
|
|
82
|
+
throw toolError.invalidInput(`out must have the same format as the source (.${format})`, "form_fill fills a form; use doc_convert afterwards to change format.");
|
|
83
|
+
}
|
|
84
|
+
await assertUnchanged(resolved, inputVersion);
|
|
85
|
+
const writeTarget = await resolveEditTarget(config, args.path, args.out);
|
|
86
|
+
const inPlace = isSameFile(writeTarget.path, resolved);
|
|
87
|
+
if (!inPlace && args.overwrite !== true && (await exists(writeTarget.path))) {
|
|
88
|
+
throw toolError.invalidInput(`${writeTarget.display} already exists`, "Pass overwrite: true to replace it, or choose a different output.");
|
|
89
|
+
}
|
|
90
|
+
const write = { target: writeTarget, inPlace, takeBackup: inPlace && (args.backup ?? true) };
|
|
91
|
+
return textResult(config, format === "docx"
|
|
92
|
+
? await fillWordFields(resolved, write, args)
|
|
93
|
+
: await fillPdfFields(resolved, write, args));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
async function listWordFields(resolved, displayPath) {
|
|
97
|
+
const doc = await readWord(resolved, displayPath);
|
|
98
|
+
const fields = Query.extractFormFields(doc);
|
|
99
|
+
if (fields.length === 0) {
|
|
100
|
+
return [
|
|
101
|
+
`# ${displayPath}`,
|
|
102
|
+
"",
|
|
103
|
+
"This document has no legacy form fields.",
|
|
104
|
+
"",
|
|
105
|
+
"If it uses `{{placeholder}}` syntax instead, use template_inspect and template_fill. If it is an ordinary document, use doc_edit to change text."
|
|
106
|
+
].join("\n");
|
|
107
|
+
}
|
|
108
|
+
return [
|
|
109
|
+
`# ${displayPath} — ${fields.length} form field(s)`,
|
|
110
|
+
"",
|
|
111
|
+
"| field | type | current value | choices |",
|
|
112
|
+
"| --- | --- | --- | --- |",
|
|
113
|
+
...fields
|
|
114
|
+
.slice(0, MAX_FIELDS)
|
|
115
|
+
.map(field => `| \`${field.name}\` | ${field.type} | ${JSON.stringify(field.value)} | ${field.entries === undefined ? "—" : field.entries.join(", ")} |`),
|
|
116
|
+
...(fields.length > MAX_FIELDS ? ["", `[${fields.length - MAX_FIELDS} more not listed]`] : []),
|
|
117
|
+
"",
|
|
118
|
+
"## Values shape",
|
|
119
|
+
"",
|
|
120
|
+
"```json",
|
|
121
|
+
JSON.stringify(Object.fromEntries(fields.slice(0, 40).map(field => [field.name, field.type === "checkBox" ? true : "…"])), null, 2),
|
|
122
|
+
"```",
|
|
123
|
+
"",
|
|
124
|
+
"Pass that as `values` to fill the form."
|
|
125
|
+
].join("\n");
|
|
126
|
+
}
|
|
127
|
+
async function fillWordFields(resolved, write, args) {
|
|
128
|
+
const doc = await readWord(resolved, args.path);
|
|
129
|
+
const before = Query.extractFormFields(doc);
|
|
130
|
+
if (before.length === 0) {
|
|
131
|
+
throw toolError.invalidInput(`${args.path} has no form fields to fill`, "Call form_fill without `values` to confirm, or use template_fill if the document uses {{placeholders}}.");
|
|
132
|
+
}
|
|
133
|
+
const known = new Set(before.map(field => field.name));
|
|
134
|
+
const supplied = Object.entries(args.values ?? {});
|
|
135
|
+
const unknown = supplied.filter(([name]) => !known.has(name)).map(([name]) => name);
|
|
136
|
+
if (unknown.length > 0) {
|
|
137
|
+
// Naming the real fields turns a wrong guess into a one-step correction.
|
|
138
|
+
throw toolError.invalidInput(`no such field(s): ${unknown.map(name => JSON.stringify(name)).join(", ")}`, `The form's fields are: ${[...known].map(name => JSON.stringify(name)).join(", ")}. Nothing was written.`);
|
|
139
|
+
}
|
|
140
|
+
const filled = Query.fillFormFields(doc, new Map(supplied.map(([name, value]) => [name, value])));
|
|
141
|
+
const backupPath = write.takeBackup ? await backupOnce(write.target) : undefined;
|
|
142
|
+
await replaceAtomically(write.target.path, temporary => Io.writeFile(filled, temporary));
|
|
143
|
+
const after = Query.extractFormFields(filled);
|
|
144
|
+
const untouched = after.filter(field => !known.has(field.name) || !(field.name in (args.values ?? {})));
|
|
145
|
+
return [
|
|
146
|
+
`Filled **${supplied.length}** of ${before.length} field(s) in ${args.path}.`,
|
|
147
|
+
`- written to ${write.target.display}${write.inPlace ? " (in place)" : ""}`,
|
|
148
|
+
...describeBackup(write.target.display, backupPath),
|
|
149
|
+
"",
|
|
150
|
+
"| field | value now |",
|
|
151
|
+
"| --- | --- |",
|
|
152
|
+
...after
|
|
153
|
+
.slice(0, MAX_FIELDS)
|
|
154
|
+
.map(field => `| \`${field.name}\` | ${JSON.stringify(field.value)} |`),
|
|
155
|
+
...(untouched.length > 0
|
|
156
|
+
? ["", `${untouched.length} field(s) were left at their existing value.`]
|
|
157
|
+
: []),
|
|
158
|
+
"",
|
|
159
|
+
"Read it back with form_fill (no `values`) to verify."
|
|
160
|
+
].join("\n");
|
|
161
|
+
}
|
|
162
|
+
async function listPdfFields(resolved, displayPath) {
|
|
163
|
+
const bytes = await readFile(resolved);
|
|
164
|
+
const result = await Pdf.read(new Uint8Array(bytes), {
|
|
165
|
+
extractFormFields: true,
|
|
166
|
+
extractText: false,
|
|
167
|
+
extractImages: false
|
|
168
|
+
}).catch((cause) => {
|
|
169
|
+
throw toolError.unsupported(`could not read ${displayPath} as a PDF`, undefined, { cause });
|
|
170
|
+
});
|
|
171
|
+
const fields = result.formFields ?? [];
|
|
172
|
+
if (fields.length === 0) {
|
|
173
|
+
return [
|
|
174
|
+
`# ${displayPath}`,
|
|
175
|
+
"",
|
|
176
|
+
"This PDF has no AcroForm fields — it is not a fillable form.",
|
|
177
|
+
"",
|
|
178
|
+
"A scanned or flattened form has no fields to fill; there is no OCR here, so say so rather than guessing where the blanks are."
|
|
179
|
+
].join("\n");
|
|
180
|
+
}
|
|
181
|
+
return [
|
|
182
|
+
`# ${displayPath} — ${fields.length} form field(s)`,
|
|
183
|
+
"",
|
|
184
|
+
"| field | type | current value | choices | required |",
|
|
185
|
+
"| --- | --- | --- | --- | --- |",
|
|
186
|
+
...fields
|
|
187
|
+
.slice(0, MAX_FIELDS)
|
|
188
|
+
.map(field => `| \`${field.name}\` | ${field.type} | ${JSON.stringify(field.value)} | ${field.options !== undefined && field.options.length > 0 ? field.options.join(", ") : "—"} | ${field.required ? "yes" : "no"} |`),
|
|
189
|
+
...(fields.length > MAX_FIELDS ? ["", `[${fields.length - MAX_FIELDS} more not listed]`] : []),
|
|
190
|
+
"",
|
|
191
|
+
"Checkbox fields take their export value (often `Yes`) to tick and `Off` to clear.",
|
|
192
|
+
"",
|
|
193
|
+
"Pass `values` keyed by these names to fill the form."
|
|
194
|
+
].join("\n");
|
|
195
|
+
}
|
|
196
|
+
async function fillPdfFields(resolved, write, args) {
|
|
197
|
+
const bytes = new Uint8Array(await readFile(resolved));
|
|
198
|
+
// Refuse rather than write a blank form: filling depends on the incremental
|
|
199
|
+
// save path, and this format cannot take one.
|
|
200
|
+
if (!supportsIncrementalUpdate(bytes)) {
|
|
201
|
+
throw toolError.unsupported(`${args.path} uses a cross-reference stream, which cannot be filled without discarding the values`, "Saving such a file rebuilds it, and the rebuild drops AcroForm values — the result would open as an empty form. Nothing was written. Ask the user for a form saved in the classic format, or fill it in a PDF viewer.");
|
|
202
|
+
}
|
|
203
|
+
// Editor.load is synchronous.
|
|
204
|
+
let editor;
|
|
205
|
+
try {
|
|
206
|
+
editor = Pdf.Editor.load(bytes);
|
|
207
|
+
}
|
|
208
|
+
catch (cause) {
|
|
209
|
+
throw toolError.unsupported(`could not open ${args.path} for editing`, "A password-protected PDF cannot be filled here.", { cause });
|
|
210
|
+
}
|
|
211
|
+
const existing = editor.getFormFields();
|
|
212
|
+
if (existing.length === 0) {
|
|
213
|
+
throw toolError.invalidInput(`${args.path} has no AcroForm fields to fill`, "Call form_fill without `values` to confirm. A flattened or scanned form has no fields.");
|
|
214
|
+
}
|
|
215
|
+
const known = new Set(existing.map(field => field.name));
|
|
216
|
+
const supplied = Object.entries(args.values ?? {});
|
|
217
|
+
const unknown = supplied.filter(([name]) => !known.has(name)).map(([name]) => name);
|
|
218
|
+
if (unknown.length > 0) {
|
|
219
|
+
throw toolError.invalidInput(`no such field(s): ${unknown.map(name => JSON.stringify(name)).join(", ")}`, `The form's fields are: ${[...known].map(name => JSON.stringify(name)).join(", ")}. Nothing was written.`);
|
|
220
|
+
}
|
|
221
|
+
editor.setFormFields(Object.fromEntries(supplied.map(([name, value]) => [name, stringifyPdfValue(value)])));
|
|
222
|
+
// saveIncremental, never save: the full rebuild drops AcroForm values, so
|
|
223
|
+
// save() would write a form that still contains none of the answers.
|
|
224
|
+
const out = await editor.saveIncremental();
|
|
225
|
+
// Verify in memory before either backing up or writing. A silently unfilled
|
|
226
|
+
// form is the failure this path exists to avoid, and a failed verification
|
|
227
|
+
// must have no filesystem side effects.
|
|
228
|
+
const verified = await Pdf.read(new Uint8Array(out), {
|
|
229
|
+
extractFormFields: true,
|
|
230
|
+
extractText: false,
|
|
231
|
+
extractImages: false
|
|
232
|
+
});
|
|
233
|
+
const after = verified.formFields ?? [];
|
|
234
|
+
const missed = supplied.filter(([name, value]) => {
|
|
235
|
+
const field = after.find(candidate => candidate.name === name);
|
|
236
|
+
return field === undefined || field.value !== stringifyPdfValue(value);
|
|
237
|
+
});
|
|
238
|
+
if (missed.length > 0) {
|
|
239
|
+
throw toolError.unsupported(`the saved PDF did not retain ${missed.length} supplied field value(s): ${missed.map(([name]) => JSON.stringify(name)).join(", ")}`, "Nothing was written. For a checkbox, supply true/false or its export value.");
|
|
240
|
+
}
|
|
241
|
+
const backupPath = write.takeBackup ? await backupOnce(write.target) : undefined;
|
|
242
|
+
await writeFileAtomic(write.target.path, out);
|
|
243
|
+
return [
|
|
244
|
+
`Filled **${supplied.length - missed.length}** of ${supplied.length} supplied field(s) in ${args.path}.`,
|
|
245
|
+
`- written to ${write.target.display}${write.inPlace ? " (in place)" : ""}`,
|
|
246
|
+
...describeBackup(write.target.display, backupPath),
|
|
247
|
+
"- saved as an incremental update, so original signature bytes are preserved; a certified signature may still report the form as modified if its DocMDP permissions forbid filling fields",
|
|
248
|
+
"",
|
|
249
|
+
"| field | value now |",
|
|
250
|
+
"| --- | --- |",
|
|
251
|
+
...after
|
|
252
|
+
.slice(0, MAX_FIELDS)
|
|
253
|
+
.map(field => `| \`${field.name}\` | ${JSON.stringify(field.value)} |`),
|
|
254
|
+
"",
|
|
255
|
+
"Verified by re-reading the saved file."
|
|
256
|
+
].join("\n");
|
|
257
|
+
}
|
|
258
|
+
/** PDF field values are strings; booleans map to a checkbox's on/off states. */
|
|
259
|
+
function stringifyPdfValue(value) {
|
|
260
|
+
if (typeof value === "boolean") {
|
|
261
|
+
return value ? "Yes" : "Off";
|
|
262
|
+
}
|
|
263
|
+
return String(value);
|
|
264
|
+
}
|
|
265
|
+
async function readWord(resolved, displayPath) {
|
|
266
|
+
return await Io.readFile(resolved).catch((cause) => {
|
|
267
|
+
throw toolError.unsupported(`could not read ${displayPath} as a Word document`, "Run doc_inspect to check the real file type.", { cause });
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=form-fill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-fill.js","sourceRoot":"","sources":["../../src/tools/form-fill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAoB,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,cAAc,EACd,MAAM,EACN,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AASxC,iCAAiC;AACjC,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;IACrC,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,0BAA0B;IACjC,WAAW,EACT,kRAAkR;IACpR,WAAW,EAAE;QACX,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yDAAyD,CAAC;QAC3F,MAAM,EAAE,CAAC;aACN,MAAM,CAAC,CAAC,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CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/B,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,QAAgB,EAAE,WAAmB;IAC3D,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QAC1D,MAAM,SAAS,CAAC,WAAW,CACzB,kBAAkB,WAAW,qBAAqB,EAClD,8CAA8C,EAC9C,EAAE,KAAK,EAAE,CACV,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `formula_evaluate` — run a spreadsheet formula against a supplied cell context.
|
|
3
|
+
*
|
|
4
|
+
* The most distinctive tool here. A model asked "is this XLOOKUP right?" can
|
|
5
|
+
* only answer from memory of Excel semantics, and it is often confidently wrong
|
|
6
|
+
* about match modes, error propagation and date serials. This turns the
|
|
7
|
+
* question into an execution: build a throwaway workbook, populate the context,
|
|
8
|
+
* evaluate with the real engine (450-odd functions, spill support), read back
|
|
9
|
+
* what Excel would actually show.
|
|
10
|
+
*
|
|
11
|
+
* Touches no files, so it is safe under --readonly.
|
|
12
|
+
*/
|
|
13
|
+
export declare const formulaEvaluateTool: import("./types.js").AnyToolDefinition;
|
|
14
|
+
//# sourceMappingURL=formula-evaluate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formula-evaluate.d.ts","sourceRoot":"","sources":["../../src/tools/formula-evaluate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA0BH,eAAO,MAAM,mBAAmB,wCAiH9B,CAAC"}
|