Skip to content
Docs
Changelog

Documents

Convert supported files to Document Text in the browser, index it from cron and read it through the shared tool catalog.

Markdown

Conversion path

A confirmed upload of a supported format creates a pending document bound to the source ETag. A dedicated browser Web Worker converts the original with @firecrawl/anydoc-wasm 0.2.5, then calls documents.prepareText, PUTs the Markdown to a per-preparation hidden key incoming/orgs/<organizationId>/<fileId>/<generation>.md and calls documents.confirmText. Cron validates and indexes that Markdown; the server never runs AnyDoc. ADR-0008 records the memory gate the server design failed.

documents.prepareText binds each new preparation to the preparing member (text_submitted_by) and a unique text_generation key tracked in document_staged_upload. Superseded, expired, ownerless, or post-restore keys keep their own cleanup deadlines and are never reused by another member; confirmText rechecks ownership and generation after HEAD. For rollback safety it also copies the confirmed Markdown to the legacy key incoming/orgs/<organizationId>/<fileId>.md, which the worker reads when the confirmed ETag is only there; a trigger keeps that key's cleanup deadline at the latest one any Worker version wrote. Derived text reads (documents.read, documents.list, documents.search, files_list, search, document_read, fetch, and the Files preview) expose attribution (submittedByUserId, submittedByName, source as uploader/member/unknown, and verified: false) so readers and agents know who submitted the browser-converted text.

Supported inputs are PDF with a text layer, Word, Excel, PowerPoint, OpenDocument, RTF, EPUB, CSV, plain text and Markdown. There is no OCR, external conversion service or streaming parser. The worker is created with new Worker(new URL(...), { type: "module" }) and fetches WASM only when conversion starts; no dynamic import() is involved.

Limits

Conversion caps are separate from upload limits. Sources above 1.5 MiB (PDF) or 10 MiB (other formats) are stored but not converted. Extracted Markdown is capped at 192 KiB; plain .md/.txt files above it show the limit before upload. WASM linear memory is bounded at 32 MiB, and conversion has a 45-second deadline in the browser. The caps live in the leaf module packages/db/src/schema/documents.enums.ts.

Chunks target 4 KiB and never exceed 8 KiB. document_read returns two chunks by default and at most four, plus a nextCursor. Each Organization may hold at most 10 confirmed conversions awaiting indexing at once (DOCUMENT_MAX_OUTSTANDING_PER_ORG); further submissions fail fast with DOCUMENT_QUEUE_FULL (HTTP 429) until a queued document finishes. Cron indexes one document per tick, selecting fairly across waiting Organizations (least-recently-served first), after the other jobs settle, within a 15-second budget; see scheduled jobs.

Failures and recovery

Encrypted, malformed, unsupported, oversized, resource-limited and OCR-required documents become permanent failures. needsOcr means the PDF has no extractable text; the original stays downloadable. text_too_large means the Markdown exceeded 192 KiB and will not be indexed. A timeout after 45 seconds, a cancelled conversion or a missing converter asset leaves the document pending and resumable: the file preview can restart preparation from the stored original, which the browser downloads through a byte-capped reader and checks against its ETag.

Uploads from external clients, including MCP, report awaitingBrowser until a member opens the file in Files and the browser prepares its text. Deleting or changing a source invalidates its text and fences indexing leases before the storage operation.

Reads and privacy

Only current Organization members can read chunks. The assistant and MCP use the same files_list, search, fetch and document_read operations; see AI assistant and MCP. Reading text in the assistant sends the selected chunks to the configured model provider. Document text is untrusted: previews skip raw HTML and remote images, and text cannot grant tool permissions.

Extend

Changing the AnyDoc version or raising a cap needs a new measured browser run. Moving conversion back to the server requires passing all three gates in ADR-0008. Keep prepareText, the Markdown PUT and confirmText together so the server checks ownership, size, UTF-8 and the text ETag.

Key files

Edit on GitHubDocumentation is in English.
Cookie settings
We use essential cookies to make our app work. With your consent, we also use optional cookies to improve your experience.

Read our Cookie Policy and Privacy Policy.