Skip to content

feat(bridle): extract text from uploaded documents so the agent can read them (CLEAN-63) - #60

Merged
maksymhryzodub-prog merged 2 commits into
mainfrom
feat/CLEAN-63-document-parsing
Sep 4, 2026
Merged

feat(bridle): extract text from uploaded documents so the agent can read them (CLEAN-63)#60
maksymhryzodub-prog merged 2 commits into
mainfrom
feat/CLEAN-63-document-parsing

Conversation

@maksymhryzodub-prog

@maksymhryzodub-prog maksymhryzodub-prog commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • A document given to the agent as a URL was usable, but the same file uploaded directly arrived as a named reference the model can't open — a direct upload was strictly worse than a link. expand() now extracts text server-side and inlines it the way txt/csv already are:
    • xlsx/xlsm → sheets rendered as CSV under == Sheet: name == headers (exceljs; formulas contribute cached results)
    • docx → paragraph text (mammoth)
    • pdf → text layer (pdf-parse v2)
  • Legacy .doc/.xls and PowerPoint stay named references; a broken or text-less file (scanned PDF) degrades to the CLEAN-57 unreadable-file notice instead of failing the message. MAX_EXTRACTED_TEXT_CHARS truncation applies as for text files.
  • readableByAgent is now kind + MIME (wire kind stays binary — the released runtime's transcript sanitizer accepts only image/text/binary). Chips in both consoles use the same rule, so an xlsx no longer says "the agent sees the name, not the contents".
  • Jest gets NODE_OPTIONS=--experimental-vm-modules: pdf.js loads its worker via dynamic import, which the jest VM otherwise forbids. Production node is unaffected.

Jira: CLEAN-63

Test plan

  • api jest: 318 pass — extractor covered with real fixtures (exceljs round-trip xlsx, hand-built docx zip, committed Chrome-printed PDF), expansion covered for inline/fallback/attachment-only paths
  • admin + app nuxt typecheck
  • Live check on the dev stack: uploaded real totals.xlsxreadableByAgent: true; deck.pptxfalse
  • After deploy: send an .xlsx with "что в файле?" to the prod Rancher — expect the agent to quote the sheet contents (API-side only, no runtime release or agent restart needed)

🤖 Generated with Claude Code

maksymhryzodub-prog and others added 2 commits September 4, 2026 13:56
…ead them (CLEAN-63)

A document handed to the agent as a URL was usable (its own tools fetch
and parse it), but the same file uploaded directly arrived as a named
reference the model cannot open — a direct upload was strictly worse
than a link. expand() now extracts text server-side and inlines it the
way txt/csv already are: xlsx/xlsm sheets render as CSV under per-sheet
headers (exceljs), docx paragraphs via mammoth, pdf text layer via
pdf-parse. Legacy .doc/.xls and PowerPoint stay named references, and a
broken or text-less file (a scanned PDF) degrades to the unreadable-file
notice rather than failing the message.

readableByAgent is now decided by kind + MIME — the wire kind stays
`binary` because the released runtime's transcript sanitizer accepts
only image/text/binary. Chips in both consoles use the same rule, so an
xlsx no longer claims "the agent sees the name, not the contents".

Jest needs --experimental-vm-modules because pdf.js loads its worker via
dynamic import, which the jest VM otherwise forbids; production node is
unaffected.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… (CLEAN-63)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@maksymhryzodub-prog
maksymhryzodub-prog merged commit 7bc96d7 into main Sep 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant