Expand description
Everything derived from a non-image attachment: a short text preview for the tile, a text version of Office documents (no agent reads those), the page count of a PDF, and whether an Office file carries macros. docs/specs/SPEC_AGENT_PANE_FILE_ATTACHMENTS_2026_09_26.md Β§6.
Office files are ZIPs, so every read here is bounded: an entry-count cap, a declared compression-ratio cap, one decompressed-bytes budget shared by all parts (the zip crate never reads past an entryβs declared size, so the declared sizes bound the work), quick-xml with predefined entities only, a cap on the text produced, and a wall-clock deadline.
Parsing runs in a child process (CHILD_ARG): srv re-runs its own
executable, reads the result from its stdout and kills it after
DEADLINE. Whatever a hostile file does to a parser (panic, deep
recursion, a sheet that loads for minutes, memory) happens to the child.
StructsΒ§
- Extract
Error - Why no text version was made.
- PdfFacts
- What can be read out of a PDF.
- Text
Outcome π - What the child reports for a text version: the text, none for this kind, or why it failed.
EnumsΒ§
- Child
Run π - How a child run ended.
- OdfOr
Ooxml π
ConstantsΒ§
- CHILD_
ARG - The hidden argument srv re-executes itself with to read a document in a
separate process:
srv __extract <pdf|text> <kind> <path> <name>(seerun_childandmain.rs). - DEADLINE
- MAX_
COMPRESSION_ RATIO - An entry claiming more than this ratio of uncompressed to compressed size is treated as a bomb.
- MAX_
DECOMPRESSED_ BYTES - Total bytes all parts of one document may decompress to.
- MAX_
PDF_ BYTES_ FOR_ COUNT - PDFs larger than this arenβt opened for a page count.
- MAX_
TEXT_ BYTES - Text versions are cut here (Codex refuses prompts over ~1M characters).
- MAX_
ZIP_ ENTRIES - PREVIEW_
BYTES - PREVIEW_
LINES
FunctionsΒ§
- cap_
text π - child_
output π - What the child prints for one request;
Nonefor a malformed request. - document_
text - Text version of a Word/Excel/PowerPoint/RTF document, in this process.
Production code calls
document_text_isolated. - document_
text_ isolated document_textin the child process.- docx_
text π - err π
- has_
macros - Whether an OOXML package carries a VBA project, whatever its extension.
- kind_
from_ πstr - office_
text - Text version of an Office document (
kindWord/Excel/PowerPoint), with a header saying where it came from.Ok(None)for kinds with no text version (legacy binary .doc/.ppt). - open_
checked_ πzip - Open a ZIP after checking entry count and every entryβs declared ratio.
Ok(None)if it isnβt a ZIP at all. - pdf_
facts_ in_ process - Page count and text of a PDF, in this process. PDF parsers can panic or
recurse deeply on malformed input: production code calls
pdf_facts_isolated, which runs this in the child process. - pdf_
facts_ isolated pdf_facts_in_processin the child process. A crash or timeout just means no facts.- pptx_
text π - Slides in presentation order:
presentation.xmlβssldIdLstgives relationship ids,presentation.xml.relsmaps them to slide parts. - read_
part π - Read one part as UTF-8, charging its bytes to
budget. - relationship_
targets π (Id, Target)pairs of a.relspart.- rtf_
text - Plain text of an RTF document: control words dropped,
{\*β¦}and a few non-text destinations skipped,\par/\line/\tab,\'hhand\uNdecoded. - run_
child - Entry point for the child process:
srv __extract <mode> <kind> <path> <name>. PrintsPdfFacts(pdf) or a text outcome (text) as JSON. - run_
isolated π srv __extract <mode> <kind> <path> <name>with the deadline.- run_
with_ πdeadline - Run
cmdwith stdout piped, killing it afterdeadline. - spreadsheet_
text π - Every sheet as tab-separated rows under a
## Sheetheading. A ZIP workbook is checked with the same limits first; calamine then reads through the zip crate, which stops at each entryβs declared size. Loading one sheet canβt be interrupted, which is why this runs in the child process (document_text_isolated) that is killed at the deadline. - text_
preview - The first lines of a text file, cut at a UTF-8 boundary.
- xml_
text π - Plain text of one WordprocessingML, DrawingML or ODF part.