Skip to content
Sign in Create account

File attachments

Attachment support varies by client and file type. Keep original file bytes on your device. Send a file’s prepared text only after local tokenization and review. Leave a file out if your client cannot process it or show the prepared text for review. You can continue with the rest of the reviewed message. Detection can miss values, so check what your client shows. See Known limitations.

How it works

On a supported, reviewed client-side path:

  1. The client decodes the file and converts it to Markdown or text on your device.
  2. It adds the text to messages[].
  3. It replaces detector matches with <<CLOAK:…>> placeholders, also on your device.
  4. It drops the raw file bytes.
  5. The CloakAPI gateway relays the request bytes. It does not process attachment bytes.
  6. The model provider receives what the client sent.

For direct gateway calls, the gateway does not process attachments[] as a file upload. The field is a legacy local-proxy input; a direct request must not rely on the gateway to remove or protect its base64 bytes.

Images and OCR

In the browser portal, extension, and desktop chat, review the text read on the device and the languages shown in the review. These clients default to English and supported browser or computer languages. The native SDK engine uses Tesseract with English by default. To use other languages with the native engine, install the packs and select them with CLOAK_OCR_LANGS or the C ABI’s ocr_langs option. See Reading text in images for the language settings of each client.

Clients

ClientWhere the file is processedReview before sendingA file it cannot process
Browser portalExtracted and tokenized on your deviceShows the prepared textLeft out with a notice
Desktop appRead on your device; for cloud requests, tokenized on your deviceCloud requests: shows the exact outgoing text and waits for approvalLeft out with a notice
Browser extensionOn your device on supported upload pathsReview of the prepared attachment or placeholder on protected paths in version 0.1.97Omitted or represented by a placeholder, depending on the path
Local proxyConverted and tokenized on your machineNo approval promptOmitted, with an attachment omitted note
Browser SDKExtracted and tokenized in the browserYour application must provide itReturned as { ok: false, reason }
MCP serverOn your machine; text and markup formats, not PDF, DOCX or XLSXUp to the MCP host—

A dash means this page does not describe that behavior for the client.

Browser portal

In Chat (/chat), select the paperclip next to the composer to attach up to 5 files, or paste files from the clipboard (Ctrl/Cmd+V). The portal extracts and tokenizes supported file text on your device, then shows what it prepared so you can review it. An unreadable file is skipped with a notice; typed text can continue through review and send. If the receipt strip shows a count of tokenized files, that is a client-reported status; the signed fields do not independently prove file processing.

Desktop app

Select the attach button in the chat composer to open the native file picker. The app reads supported files on your device and adds the extracted text to the outgoing message. For cloud requests, the desktop app tokenizes extracted text on-device, shows the exact outgoing text and waits for approval before sending. A file it cannot read is left out with a notice. The file count in its receipt status is client-reported and is not independent proof of processing.

Browser extension

File-upload behavior varies by site. On some Claude and Grok upload paths, the extension prepares files on your device. On protected upload paths in version 0.1.97, a failed file relay does not send the original file. Where offered, you can leave the file out and continue with protected text, or cancel. On paths that offer a placeholder for an unsupported or unreadable file, you can review the placeholder before it is sent. Whether ChatGPT and Gemini accept substituted uploads has not been established. The tracked coverage map labels Claude and Grok full, and ChatGPT and Gemini text-only. The source contains upload-substitution tests for ChatGPT and Gemini, but they use synthetic capture stubs and do not prove that those providers accept the uploads today. Do not treat those test paths as verified upload support.

Local proxy

The local proxy accepts a non-standard attachments[] key, base64 in JSON, alongside the standard body. It decodes each file and converts it to Markdown or text on your machine with pure-Rust extractors (the same file pipeline the desktop app uses), adds the text to the message content, tokenizes it and strips the raw attachments[] before forwarding. If it cannot process a file, it omits that attachment, puts an attachment omitted note in its place and returns x-cloak-name-protection: reduced with a notice. It still tokenizes readable message text and files it can process.

The proxy forwards the processed text without an approval prompt. Keep files and images out of requests to the local proxy. Use a client that shows the exact prepared text and waits for approval.

Browser SDK

For a web app without the local proxy, the downloadable SDK’s browser entry, @cloakapi/sdk/browser, extracts a file’s text and tokenizes it in the browser. On this path the original file bytes stay on the device. cloakup uses this path to process files.

import { applyReviewDecisions, createBrowserEngine, extractFileForReview } from "@cloakapi/sdk/browser";
const engine = await createBrowserEngine(); // fail-closed: throws if unavailable
// Extract and tokenise ON-DEVICE. This does not send. protectFileForEgress is
// not exported from @cloakapi/sdk/browser.
const r = await extractFileForReview(file, { engine, pdfWorkerSrc });
if (!r.ok) {
// Show a non-blocking notice and leave this file out of the request.
// Do not fall back to sending the original file bytes.
} else {
// r.body is a local candidate, not approval to POST. Show r.originalText and
// r.spans, then build the reviewed text. Keep r.map on the device.
const reviewed = applyReviewDecisions(r.originalText, r.spans);
// Send reviewed.body only through a relay whose reviewRequest requires
// approved === true and text === the exact string that will be posted.
}
  • extractFileForReview(file, { engine }) returns { ok: false, reason } for input the browser cannot extract. On success, body is a local candidate, not approval to send.
  • applyReviewDecisions(originalText, spans, { decisions, manual }) builds text from the decisions you pass. Your application must still show the content and reject a send unless the reviewed text is exactly the text submitted.
  • protectFileForEgress is not exported from @cloakapi/sdk/browser.
  • The lower-level extractTextFromFile only extracts text; it does not tokenize it.
  • For an image the SDK cannot read, produce any caption or OCR text on the device before you pass it as extractedText.

What the browser SDK extracts on your device today (parser dependencies load only when a file of that type is attached):

KindFormatsDependency (lazy import())
Text.txt .md .csv .tsv .json .xml .html .log .yaml …none
PDF.pdfpdfjs-dist (optional peer dep)
Word.docxmammoth (optional peer dep)

It cannot extract images, .xlsx or .pptx files, .zip archives or unknown binary files through extractTextFromFile. Leave out a file it cannot process, show a warning and let the user continue with the rest of the reviewed message. Do not send that file as raw bytes. Other clients may support more formats when they can extract, tokenize and show the prepared text for review.

pdfjs-dist and mammoth are optional peer dependencies of the SDK, reached only through dynamic import(). Install them in your app when you need PDF or Word support (npm i pdfjs-dist mammoth). An app that only needs text, CSV or JSON does not load them, and the SDK’s main bundle stays small.

MCP server

The MCP server’s file helper extracts supported text and markup formats. PDF, DOCX and XLSX files are not read directly. For images, install Tesseract and your language packs locally or supply pre-extracted text. Starting in 0.6.2, a local OCR read reports the languages it used and any unavailable packs. The MCP host controls any later network handling. See MCP server install and tool notes.

Supported formats

Each client reads a different set of formats. Leave a file out if the client cannot read it or show the prepared text for review.

FormatExtensionsBrowser portal, desktop app, browser extensionBrowser SDKMCP serverLocal proxy
Plain text and Markdown.txt, .log, .md, .markdownYesYesYesYes
CSV and TSV.csv, .tsvYesYesYes.csv only
JSON, XML, HTML, YAML.json, .xml, .html, .htm, .yaml, .ymlYesYesYesYes, except YAML
Jupyter notebook.ipynbYes, as textOnly when the browser reports a JSON typeNoYes
Email (MIME).emlYesNoNoYes
PDF.pdfYesYes, with pdfjs-distNoYes
Microsoft Word.docxYesYes, with mammothNoYes
Microsoft Word, legacy.docNoNoNoYes
Microsoft Excel.xlsx, .xlsYesNoNoYes
Microsoft PowerPoint.pptx, .pptNoNoNoYes
EPUB.epubNoNoNoYes
OpenDocument and RTF.odt, .ods, .odp, .rtfNoNoNoYes
Images.png, .jpg, .jpeg, .webp, .bmp, .gif, .tiff, .tifYes, text read on the deviceSupply locally extracted textWith a local Tesseract install or locally extracted textInline image data with local Tesseract
Source code and config files.js, .ts, .py, .go, .toml, .ini and similarNoRead as text when the browser reports a text typeYesNo

The portal and desktop file pickers also list .doc, .pptx, .ppt, .epub and .msg. Those files cannot be read on the device today so the client skips them and says so. Audio, video and archive files are not supported by the attachment flows described here.

Limits

LimitValue
Max file size20 MB per file (local proxy: CLOAK_DOCUMENT_MAX_BYTES, default 20 MiB)
Max files per request5 (portal, desktop app, extension)
Allowed formatsSee Supported formats

Receipt audit trail

When supported, a request with attachments can carry client-reported per-file attestations in its receipt: the format, file hashes before and after processing, and detector firings, under the registered v1.1-file-ext claim (see the extension registry). The receipt signature protects those recorded fields from undetected alteration; it does not prove that extraction or tokenization succeeded, or that every identifier was replaced.

{
"claims": {
"file_attestations": [
{
"mime": "application/pdf",
"sha256_pre": "…",
"sha256_post": "…",
"exif_stripped": true,
"processing_ms": 412
}
]
}
}

To confirm that the signature and recorded fields are intact, verify the receipt with POST /api/v1/receipts/verify or in the browser at app.cloakapi.io/receipt-verifier; see Verification methods. Those fields do not prove that all file content was tokenized or that no raw content left the client.