Repository navigation
Send a teammate a PDF: the gateway extracts its text - #26
Merged
Merged
Conversation
read_file cannot read a PDF, so a PDF sent to a teammate was something it could not open. The gateway now extracts the text when a PDF is uploaded and puts it beside the document on the teammate's computer (uploads/<id8>-report.pdf and .pdf.txt, one heading per page). - Extraction runs in a worker thread with a memory ceiling, a 20 second limit and caps of 200 pages and 2 million characters. A scan (no text), a document that cannot be parsed and one that hits a limit are all accepted and recorded as such: `text` in the upload's reply is ok, truncated, none or failed, and the teammate is told the same in the conversation. Pages are not rendered. - The worker is started from a string with eval, with the library path resolved by the main thread, so the same code path runs under tsx, vitest, the built gateway and a packaged app. - Extracted text has CJK radical look-alikes and Latin ligatures replaced by the real characters. A PDF printed by Chrome on macOS came out with U+2F6C for 目 and U+2EDB for 风, which read fine and cannot be searched. The Kangxi block goes through NFKC; the radicals supplement needs a table, generated from Unicode 18.0 EquivalentUnifiedIdeograph.txt. - Schema v9 adds `pages` and `text_state` to uploads. Removing an upload, the daily clean-up of unsent uploads and the folder check all cover the text file too. - New dependency: unpdf ^1.4.0 (MIT, no native code, 2 MB). Its 2.x needs Node 24 and this project still supports 22, so Dependabot skips that major for now. Verified with the suites, a real PDF with Chinese and English text printed by Chrome (through tsx, through the built gateway, and through a running gateway with curl), and a scan-like PDF. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A teammate can now read a PDF you send it. This is the third piece of #12, after mentions (#19) and the upload API (#24).
read_filecannot read a PDF, so the gateway extracts the text when a PDF is uploaded and puts it beside the document on the teammate's computer:uploads/1a2b3c4d-report.pdfanduploads/1a2b3c4d-report.pdf.txt, one heading per page. The teammate is told where both are.When there is nothing to read
The upload is accepted either way, and both you and the teammate are told which case it is. The upload's reply carries
text:textoktruncatednonefailedDecisions worth a look
unpdf1.4. MIT, no native code, about 2 MB. Its 2.x needs Node 24, and this project still supports 22, so Dependabot is told to skip that major. The officialpdfjs-distis 37 MB and brings an optional native canvas.failed; the upload still succeeds and the gateway keeps running.tsx, vitest, the built gateway and a packaged desktop app.⽬(U+2F6C) where the page says目, and⻛(U+2EDB) for风. They read fine and cannot be searched. Kangxi radicals go through NFKC. The radicals supplement block needs a table, which is generated from Unicode 18.0EquivalentUnifiedIdeograph.txt. Latin ligatures are spelled out. Nothing else is touched, so full-width punctuation stays.pagesandtext_statetouploads.Limits of this approach
Verification
tsx, through the built gateway, and end to end through a running gateway with curl. The teammate's computer received the document byte for byte and the text file.none.🤖 Generated with Claude Code