file
fileRead, write, generate, edit, and convert Office documents, PDFs, and text or code content, including downloading remote sources and rendering pages for visual review.
Instructions
Read existing PDFs, Word documents, spreadsheets and presentations with readContent(artifactId OR attachmentId). For a remote PDF/document URL: download(urlOrPath) → readContent(returned artifactId). Use contentPages for PDF text pages and offset/limit for text chunks; reading needs no plan/render or codeSandbox parser installation. Use visualRead for scanned pages or layout-dependent evidence when available. File workflow: readSource(documentId) reads editable HTML/Python/JavaScript; readContent(artifactId OR attachmentId) reads file text/data, NOT source. To repair layout: readSource → edit → render → visualRead using render.visualIndex.nextRead → visualReport. render includes screenshot IDs; call visualIndex only for missing index entries. list discovers drafts; plan selects engine; generate creates source; download fetches assets; convert changes file format; unoApi/jsApi describe the planned engine. Never substitute IDs or infer behavior from reason. For text/code/config files use write(fileName, content): publishes exact UTF-8 content immediately, including empty files, without plan, Office engines or rendering. Markdown, TXT, HTML, JS, CSS, JSON, YAML, CSV and custom text extensions use the same write action. Saved code is not executed. Office design: original/high-design work starts with plan.design (bespoke audience, objective, distinct directions, selection and rhythm), then body for content/layout or program for complete-source control. Consistent visual rules do not mean identical page layouts. Edit is atomic: prefer exact replacements, uniquely matched on one pre-edit snapshot; any conflict saves nothing. Preserve indentation; never rely on fuzzy matching. After saved=true, inspect validation separately and use the returned patchBaseDigest. Only an identical request confirmed by a saved edit receipt is deduplicated. unoApi exact module IDs return only that module. Recovery: readSource/list return saved diagnostics, not a new execution. Check validationEvidence freshness. Do not infer bridge failure from NoneType or source correctness from a runtime blocker. Respect retryable/retryAfter; no unchanged retry loops.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"action": "<action>"
},
"name": "file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | For download: verified direct file URL, not a search result, preview webpage, artifactId or source-unit path. | |
| body | No | Preferred custom generate input. UNO: Python content operations using the provided deck (presentation), document (Word/flowing PDF), or workbook (Excel) variable. ExcelJS: JavaScript using provided workbook; await is allowed. HTML: a fragment, with section[data-slide] for PPTX. The SDK creates the document and adds entrypoint/save/close or HTML shell. Do not include those yourself. Follow plan.sourceGuidance. Choose exactly one of body or program. Repairs use edit on the complete source returned by readSource. | |
| path | No | For readSource/edit: exact source-unit path returned by readSource, not draft.py, an Office filename or filesystem path. For download: legacy alias of urlOrPath, accepting an HTTP(S) URL or page-relative URL path; local filesystem paths are unsupported. | |
| limit | No | readContent: maximum text characters (default 8000, max 40000), NOT source lines. visualIndex: maximum index entries (default 100, max 200). readSource uses startLine/endLine instead. | |
| pages | No | Only for readContent(includeVisuals=true): one-based rendered/printed page numbers, at most six. A worksheet may span multiple pages. visualRead instead uses screenshotIds. | |
| patch | No | For edit, use patch OR replacements. Codex patch: Begin Patch, Update File: draft.py, @@ hunks, End Patch. Literal -old/+new markers are separate from ALL source indentation. Every target must match uniquely and exactly in the current source. Any conflict rejects the WHOLE call; no partial saves or fuzzy matching. Prefer replacements for small fixes. | |
| query | No | For an API lookup: omit to list modules, then pass an exact module id returned by that index. | |
| range | No | readContent: A1 cell/range, for example A1:D20; specify sheet for multi-sheet files. | |
| sheet | No | readContent: exact spreadsheet worksheet name. | |
| action | Yes | Required. write + fileName + content publishes text/code files immediately. readSource + documentId = editable Office generation code; readContent + artifactId/attachmentId = file text/data; visualIndex/visualRead/visualReport = rendered-page QA. generate/edit validate Office source; render publishes it. | |
| design | No | For initial plan: template for conventional fast files; bespoke for original art direction. Bespoke records audience/objective, 2–3 distinct directions (or one grounded user reference), selectedDirection, selectionReason and page rhythm. This is not a visual pass or permission to delete requested content. | |
| intent | No | For plan: concise description of the document to create or modify. | |
| offset | No | readContent: zero-based character offset. visualIndex: zero-based screenshot-list offset. Never a source line number. | |
| reason | No | User-visible explanation only. Saying "read source" here does NOT select source reading; action and identity fields control behavior. | |
| render | No | Legacy generate/edit flag; use a separate action=render to publish. generate/edit create or validate source, not a deliverable download. | |
| content | No | For write only: exact UTF-8 text to save as a downloadable file (Markdown, HTML, code, configuration, CSV, etc.). Preserves whitespace and empty strings. No Markdown fences unless part of the requested file. Does not execute code or render Office documents. | |
| endLine | No | For readSource only: inclusive last code line, at least startLine. This is not a worksheet row or PDF page number. | |
| program | No | Advanced generate input: complete HTML, or complete Python/JavaScript source with the engine entrypoint. UNO requires def create_document(job): and exactly one document save/close. Prefer body to omit this boilerplate. Choose exactly one of body or program. readSource returns the complete stored source; use edit for repairs. | |
| reviews | No | For visualReport: conclusions for pages actually seen via visualRead on this artifact. passed requires no failed checks and no issues; failed requires a failed check and concrete issues. Reporting does not modify source. | |
| section | No | readContent: exact, unique Word document heading; reads through the next heading of the same or higher level. | |
| fileName | No | For write/plan/download/convert: output name with extension. Required for write; optional for plan, which derives it from the intent/title and documentType when omitted. A name is not an artifactId or documentId. The bundled convert outputs PDF only. | |
| fileType | No | For download: expected extension without a dot. | |
| operation | No | For plan: create a new document or modify an attached existing Office document. | |
| startLine | No | For readSource only: one-based first code line; use the returned coordinateSpace when a source-unit path is selected. Maximum 80 lines per response. | |
| urlOrPath | No | For download: real HTTP(S) file URL or page-relative URL path resolved against sourcePageUrl. Not an operating-system path. Local assets must be uploaded/host-bound attachments. Supply exactly one of urlOrPath/url/path. | |
| artifactId | No | For readContent/visualIndex/visualRead/visualReport: exact finished-file artifact id from render/download/convert. Reading an .xlsx artifact returns spreadsheet content, NOT Python source. | |
| deckReview | No | Complete-document consistency review submitted after every page has been read and reviewed. | |
| documentId | No | Required for readSource/generate/edit/render; copy from plan/list. Optional for a new plan (generated automatically) and unoApi/jsApi (unbound documentation reads). Re-plan an existing document using its returned id. New ids use 1-96 ASCII letters/numbers/dot/underscore/hyphen. | |
| attachmentId | No | For readContent: exact uploaded attachment id. Not a draft id and not usable to read generation source. | |
| contentPages | No | readContent: PDF text pages or presentation slides in actual document order, one-based. Independent from visual-preview pages. | |
| documentType | No | Required for plan. Optional for unoApi/jsApi: choose word/spreadsheet/presentation to read that API without a documentId; omit both to get the document-type index. Common Office extension aliases are normalized before validation. | |
| replacements | No | Preferred for small/indentation repairs: unique exact oldText/newText pairs on the current source. All pairs commit together or NONE do; combine helper and caller changes in one call. No whitespace guessing. Missing oldText is a conflict, not proof of previous success. Use documentId; inspect saved and validation separately. | |
| screenshotIds | No | For visualRead: one to eight exact screenshot ids from render.visualIndex or action=visualIndex. Prefer render.visualIndex.nextRead without repeating the index call. | |
| includeVisuals | No | For readContent only: false by default; true explicitly attaches rendered pages. Text reading is not visual QA. For page inspection, use visualRead with render.visualIndex; request visualIndex only if no current index is available. | |
| sourceArtifactId | No | For convert: exact artifact id of the existing Office file to export as PDF. Does not read or modify generation source. | |
| includeDiagnostics | No | readSource only, default false: include saved diagnostic details, NOT a new validation run. Check validationEvidence source/worker freshness before treating old errors as current blockers. Ordinary reads return counts, not full warnings. | |
| sourceAttachmentId | No | For operation=modify: exact attachment id of the existing Office file. |