llm-large-files 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +32 -6
  3. package/dist/analyze.d.ts.map +1 -1
  4. package/dist/analyze.js +5 -1
  5. package/dist/analyze.js.map +1 -1
  6. package/dist/extract.d.ts +30 -7
  7. package/dist/extract.d.ts.map +1 -1
  8. package/dist/extract.js +94 -23
  9. package/dist/extract.js.map +1 -1
  10. package/dist/gemini/chat.d.ts +38 -2
  11. package/dist/gemini/chat.d.ts.map +1 -1
  12. package/dist/gemini/chat.js +83 -32
  13. package/dist/gemini/chat.js.map +1 -1
  14. package/dist/gemini/generate.d.ts +34 -4
  15. package/dist/gemini/generate.d.ts.map +1 -1
  16. package/dist/gemini/generate.js +51 -8
  17. package/dist/gemini/generate.js.map +1 -1
  18. package/dist/gemini/index.d.ts +3 -3
  19. package/dist/gemini/index.d.ts.map +1 -1
  20. package/dist/gemini/index.js +2 -2
  21. package/dist/gemini/index.js.map +1 -1
  22. package/dist/index.d.ts +4 -3
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +2 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/library.d.ts +37 -1
  27. package/dist/library.d.ts.map +1 -1
  28. package/dist/library.js +59 -7
  29. package/dist/library.js.map +1 -1
  30. package/dist/map-reduce.d.ts +7 -0
  31. package/dist/map-reduce.d.ts.map +1 -1
  32. package/dist/map-reduce.js +58 -16
  33. package/dist/map-reduce.js.map +1 -1
  34. package/dist/pdf-layout.d.ts +39 -0
  35. package/dist/pdf-layout.d.ts.map +1 -0
  36. package/dist/pdf-layout.js +820 -0
  37. package/dist/pdf-layout.js.map +1 -0
  38. package/dist/pdf-pages.d.ts +45 -0
  39. package/dist/pdf-pages.d.ts.map +1 -0
  40. package/dist/pdf-pages.js +336 -0
  41. package/dist/pdf-pages.js.map +1 -0
  42. package/dist/pdf-pictures.d.ts +20 -0
  43. package/dist/pdf-pictures.d.ts.map +1 -0
  44. package/dist/pdf-pictures.js +336 -0
  45. package/dist/pdf-pictures.js.map +1 -0
  46. package/dist/plan.d.ts +13 -3
  47. package/dist/plan.d.ts.map +1 -1
  48. package/dist/plan.js +27 -18
  49. package/dist/plan.js.map +1 -1
  50. package/dist/search.d.ts +17 -4
  51. package/dist/search.d.ts.map +1 -1
  52. package/dist/search.js +90 -24
  53. package/dist/search.js.map +1 -1
  54. package/dist/stores.d.ts +7 -1
  55. package/dist/stores.d.ts.map +1 -1
  56. package/dist/stores.js +37 -5
  57. package/dist/stores.js.map +1 -1
  58. package/dist/text.d.ts +18 -4
  59. package/dist/text.d.ts.map +1 -1
  60. package/dist/text.js +155 -15
  61. package/dist/text.js.map +1 -1
  62. package/dist/tools.d.ts +11 -0
  63. package/dist/tools.d.ts.map +1 -1
  64. package/dist/tools.js +156 -16
  65. package/dist/tools.js.map +1 -1
  66. package/dist/types.d.ts +63 -3
  67. package/dist/types.d.ts.map +1 -1
  68. package/docs/api.md +56 -11
  69. package/docs/configuration.md +298 -6
  70. package/docs/getting-started.md +41 -7
  71. package/docs/how-it-works.md +77 -11
  72. package/docs/security.md +54 -6
  73. package/package.json +96 -91
  74. package/src/analyze.ts +3 -1
  75. package/src/extract.ts +105 -24
  76. package/src/gemini/chat.ts +116 -34
  77. package/src/gemini/generate.ts +66 -10
  78. package/src/gemini/index.ts +3 -3
  79. package/src/index.ts +4 -3
  80. package/src/library.ts +308 -226
  81. package/src/map-reduce.ts +69 -16
  82. package/src/node/handlers.ts +122 -122
  83. package/src/pdf-layout.ts +807 -0
  84. package/src/pdf-pages.ts +315 -0
  85. package/src/pdf-pictures.ts +324 -0
  86. package/src/plan.ts +120 -98
  87. package/src/search.ts +85 -25
  88. package/src/stores.ts +165 -132
  89. package/src/text.ts +131 -14
  90. package/src/tools.ts +408 -264
  91. package/src/types.ts +228 -168
package/CHANGELOG.md CHANGED
@@ -4,6 +4,153 @@ All notable changes to this package are recorded here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
5
5
  [semantic versioning](https://semver.org).
6
6
 
7
+ ## [0.3.0] - 2026-11-10
8
+
9
+ The model can look at the pages of a large PDF. Until now such a PDF reached it as text only, and
10
+ pictures, charts and diagrams were lost. Everything here is off until you turn it on: an
11
+ application that changes nothing, and does not install the new optional dependency, sends the same
12
+ requests as with 0.2.0 (checked byte for byte against the published 0.2.0 over eight scenarios).
13
+
14
+ ### Added
15
+
16
+ - **`view_pages`: the real pages of a PDF, on request.** The tool cuts up to five pages out of the
17
+ uploaded file and returns them as one small PDF, which Gemini reads like any PDF. Asked which bar
18
+ of a chart is tallest, `gemini-3.5-flash-lite` said from the text alone that it could not see the
19
+ chart; with the tool it looked at the page unasked and answered correctly. For ten questions that
20
+ the text answers, it did not look at a page once. A page costs about 530 tokens. See
21
+ [Pictures in PDFs](docs/configuration.md#pictures-in-pdfs) for the limits and the measurements.
22
+ - It needs the new optional dependency `@cantoo/pdf-lib`, and the uploaded file (next item).
23
+ - `askGemini` offers it for every PDF whose original is kept, also for one whose text fits in
24
+ the prompt (a slide deck of photos has little text). `viewPages: false` turns it off.
25
+ It works on the Gemini API and on Vertex AI. `toolFilePlacement: "beside"` sends the pages in
26
+ a user turn of their own instead of inside the function response: Gemini 2.5 needs that, as it
27
+ does not see a file inside a function response.
28
+ - In a loop of your own: `prepare(ids, base, { viewPages: true })` lists the PDFs in
29
+ `PreparedContext.viewable`, `tools(documents, { viewPages })` declares the tool, and
30
+ `ToolSet.executeWithFiles(name, args, { maxFileBytes, maxPages })` returns `{ result, files }`.
31
+ The tool is declared only on request, and `execute()` answers it with an error, because a loop
32
+ that drops the file would tell the model that pages are attached with nothing attached.
33
+ - Search and read results carry page numbers (`page`, `pages`) for a PDF that can be shown.
34
+ - **`keepOriginals`: keep the uploaded file.** `createLargeFiles({ keepOriginals: ["pdf"] })`
35
+ stores the file next to its text. It is off by default, because a kept file takes disk space, up
36
+ to the upload limit, until the document expires. `DocumentStore` has two new optional methods,
37
+ `putOriginal` and `getOriginal`; a store without them works as before and keeps nothing.
38
+ `FileDocumentStore` writes `<id>.bin`, and delete, expiry and sweep remove it.
39
+ `DocumentMeta.originalKept` records it, and `files.getOriginal(id, { owner })` returns the file
40
+ to its owner.
41
+ - **Scanned PDFs of up to 30 pages are accepted** when their original is kept: the model reads them
42
+ by looking at the pages. `scannedPdfPages` sets the limit, and 0 refuses them as before. A longer
43
+ scan, and any scan without a kept original, is still refused.
44
+ - `geminiFunctionResponseTurns(answers, { files })`: the turns that answer a model turn's function
45
+ calls, for a loop of your own. `geminiFunctionResponses` takes the files of each call and puts
46
+ them inside its function response.
47
+ - `createPdfExtractor({ pictures })`, `ExtractInput.scannedPages`, `MAX_VIEW_PAGES`,
48
+ `FINAL_ANSWER_AFTER_PAGES`, and the types `ToolFile`, `ToolOutput`, `ToolFileLimits`,
49
+ `PrepareOptions`, `GeminiToolAnswer` and `GeminiToolFilePlacement`.
50
+
51
+ ### Changed
52
+
53
+ - **A page of a PDF that shows a picture is marked**, with one line under its header:
54
+ `[Picture on this page. This text cannot show it.]`. A picture is images that cover 3% of the
55
+ page or more, other than a logo or background that is on most pages; a drawing is shapes filled
56
+ in three or more colours, outside the tables. The pages are found from the structure of the file,
57
+ without decoding any image: a PDF of 200 photos took 0.3 s to ingest before and takes 0.8 s now.
58
+ This needs `@cantoo/pdf-lib`. Without it, and with `createPdfExtractor({ pictures: false })`, the
59
+ text is exactly that of 0.2.0. Documents already in a store keep the text they were ingested
60
+ with.
61
+ - `ToolSet` has a new method, `executeWithFiles`, `LargeFiles` has `getOriginal`, and
62
+ `PreparedContext` has `viewable`. Code that builds these objects itself (a test double, for
63
+ example) has to add them.
64
+
65
+ ### Known limits
66
+
67
+ - A chart in one or two colours, and a drawing made only of lines, is not marked. The model can
68
+ still look at the page: it did so for a one-colour chart that had only a caption.
69
+ - Every look reads the whole PDF into memory: 0.06 s for 100 MB of photos, but 4 to 5 seconds and
70
+ 700 MB for a file of 330,000 objects. A file that declares more objects than memory allows is
71
+ refused. Reading cannot be interrupted, so a crafted PDF can hold the process for a long time:
72
+ see [Security](docs/security.md#reading-pdfs-for-pages-and-pictures).
73
+ - Tested with PDFs made by Chrome, Word and PowerPoint. PDFs made by LaTeX and InDesign were not
74
+ tested. For FPDF, Ghostscript and scanners, the structures they are known to write were tested
75
+ with files made for the purpose, not with files from those tools. Encrypted PDFs were tested
76
+ with files encrypted by the library itself, and confirmed as encrypted by pdf.js.
77
+
78
+ ## [0.2.0] - 2026-11-10
79
+
80
+ ### Fixed
81
+
82
+ - **Token estimates were far too low for logs and data files.** `estimateTokens` assumed 4
83
+ characters per token, which holds for prose only: Gemini counts about one token per digit. A
84
+ service log was estimated at 37% of its real size and a CSV of numbers at 26%, so such files were
85
+ sent whole, and split into parts, at about three times the configured budget. The estimate now
86
+ prices each kind of character and was fitted to Gemini's `countTokens` on 60 texts; it lands
87
+ between 0.98 and 1.7 times the real count. Documents already in a store keep the estimate they
88
+ were ingested with until they expire.
89
+ - **A regex search could freeze the server.** Patterns such as `((a+))+$` and `(a|a)+$` passed the
90
+ nested-quantifier check and never finished on a 40-character line; the 3-second limit was only
91
+ checked between lines. Regex scans now run under a hard time limit that interrupts a match in
92
+ progress.
93
+ - **`askGemini` could return a remark instead of an answer.** If the model wrote "Let me search…"
94
+ with a tool call and its next turn came back empty (cut off, or a malformed tool call), that
95
+ remark was returned as the answer. The tool-free request is now sent whenever the model's last
96
+ turn has no text.
97
+ - **A blocked prompt resolved as an empty answer with no reason.** The result now has
98
+ `answered: false` and `blockReason`.
99
+ - **One model request was wasted when the tool turns ran out.** The last request was sent with
100
+ tools, its calls were discarded, and then another was sent without tools. `askGemini` now goes
101
+ straight to the tool-free request, so it never makes more than `maxToolTurns` requests.
102
+ - **Case-insensitive search found nothing in a file containing "İ"** (U+0130), in exact and
103
+ keyword mode: the whole file silently fell back to case-sensitive matching.
104
+ - **Coloured logs lost their profile.** Only the ESC byte of a terminal colour code was removed,
105
+ leaving `[31mERROR[0m`, which no longer matched as a level. Whole escape sequences are removed.
106
+ - **Compressed files were accepted as text.** A `.gz` log became a document of garbage. Gzip and
107
+ ZIP files are refused with a message that says what to do, and other binary files without zero
108
+ bytes are now detected too.
109
+ - **Ingest failed with "Maximum call stack size exceeded"** on files with a few hundred thousand
110
+ short heading-like lines.
111
+ - **A file name could add lines to the prompt.** Control characters, line breaks, and
112
+ text-direction overrides are removed from names at ingest, and names are quoted in the system
113
+ instruction.
114
+ - **Whole-document reads hid that they were incomplete.** When part notes or the final answer
115
+ reach the output limit, the tool result now says so (`notes_cut_short`, `answer_cut_short`, and a
116
+ `note` telling the model to say so and to use exact search for complete lists). If no part can be
117
+ read, the tool returns an error instead of an answer written from nothing.
118
+ - `read_document` reported a line range past the end of the file when no end line was given.
119
+
120
+ - **Words of right-to-left text in a PDF were glued together** when the file stores them piece by
121
+ piece (as Word does): `יתרת סגירה4,167.90`. pdf.js adds the space only between pieces that run
122
+ left to right. The space is now added from the positions.
123
+
124
+ ### Changed
125
+
126
+ - **PDF tables are rebuilt.** A PDF stores text at positions, not tables. In file order, a row
127
+ with an empty cell reads like a row without that column, so a model takes the next value for the
128
+ missing one. The PDF extractor now finds tables by the position of their text and writes each
129
+ row as `| cell | cell | | cell |`. In a live test (`gemini-3.5-flash-lite`, 110 questions about
130
+ single cells of seven PDFs made by Word and Chrome), 44 answers were right from the old text and
131
+ 110 from the new. It also handles tables in one column of a two-column page, right-to-left and
132
+ sideways tables, headings that span columns, and wrapped cells; text that is not a table is left
133
+ as it was. Two-column tables are left as text. See
134
+ [PDF tables](docs/configuration.md#pdf-tables) for the limits.
135
+ `createPdfExtractor({ tables: false })` gives the previous text. Documents already in a store
136
+ keep the text they were ingested with.
137
+ - **A PDF page without any text is marked** `[No text on this page. It may be a scan, a photo, or a
138
+ chart.]` instead of being left empty, so the model can say that it cannot see the page.
139
+ - **Documents are placed at the start of the first user turn**, not appended to the latest one.
140
+ The document then stays in the same place as the conversation grows, so Gemini's prompt cache
141
+ reuses it: in a live test, a follow-up question about a 53,000-token document had 96% of its
142
+ input served from cache, against 0% before. Pass `documentPlacement: "last"` to `askGemini` for
143
+ the previous layout.
144
+ - `maxToolTurns` is now the most requests one question can make, counting the answer. Tools still
145
+ run in at most `maxToolTurns - 1` of them, as before.
146
+
147
+ ### Added
148
+
149
+ - `createPdfExtractor({ tables })`, exported from the main entry point.
150
+ - `AskGeminiResult.answered` and `AskGeminiResult.blockReason`.
151
+ - `GenerateText` requests carry an optional `onTruncated` callback; `createGeminiGenerateText`
152
+ calls it when Gemini stops at `MAX_TOKENS`.
153
+
7
154
  ## [0.1.0] - 2026-11-06
8
155
 
9
156
  First release, extracted from the large-file support in the Gemini Prep chatbot.
package/README.md CHANGED
@@ -9,6 +9,8 @@ and 1M tokens of context. This package bridges the gap:
9
9
  - **Files that fit** go into the prompt whole.
10
10
  - **Files that don't** become a short summary card, and the model gets tools to **search**,
11
11
  **read line ranges**, or **read the whole file in parts** (map-reduce). Answers cite line numbers.
12
+ - **Pictures in a PDF** are not in its text. The model can **look at the real pages** when it
13
+ needs to: a chart, a photo, a scan.
12
14
 
13
15
  It's a small library, not a framework: no model SDK, no server, and no UI are required. A drop-in
14
16
  Gemini / Vertex AI helper and Node HTTP handlers are included for the common case.
@@ -75,11 +77,33 @@ await fetch("/api/documents", {
75
77
  The full walkthrough, with streaming to the browser, is in the [integration guide](docs/getting-started.md).
76
78
  There's also a [one-file demo server](examples/server.ts).
77
79
 
80
+ ## Pictures, charts and scans in PDFs
81
+
82
+ A large PDF goes to the model as text, and text cannot show a chart. Keep the uploaded PDFs, and
83
+ the model gets a tool, `view_pages`, that hands it the pages it asks for as a small PDF:
84
+
85
+ ```bash
86
+ npm install @cantoo/pdf-lib
87
+ ```
88
+
89
+ ```ts
90
+ const files = createLargeFiles({
91
+ store: new FileDocumentStore("./data/large-files"),
92
+ keepOriginals: ["pdf"], // off by default: a kept file takes disk space until it expires
93
+ });
94
+ // askGemini needs no change. A step then reads: Look at report.pdf pages 12-14
95
+ ```
96
+
97
+ Asked which bar of a chart is tallest, `gemini-3.5-flash-lite` said from the text that it could
98
+ not see the chart; with `view_pages` it looked at the page and answered correctly. It did not look
99
+ at a page for any of ten questions that the text answers. A page costs about 530 tokens.
100
+ Details, limits and measurements: [Pictures in PDFs](docs/configuration.md#pictures-in-pdfs).
101
+
78
102
  ## What it handles
79
103
 
80
104
  | | |
81
105
  |---|---|
82
- | **Formats** | Text, Markdown, logs (UTF-8 and UTF-16), JSON/JSONL, CSV/TSV, DOCX, PPTX, PDF (text layer) |
106
+ | **Formats** | Text, Markdown, logs (UTF-8 and UTF-16), JSON/JSONL, CSV/TSV, DOCX, PPTX, PDF (text layer, with tables rebuilt so empty cells stay empty; pages with a picture are marked, and the model can look at the pages themselves; scans of up to 30 pages) |
83
107
  | **Logs** | Detected automatically; the card shows level counts, the time range, and the most frequent errors grouped by shape (`timeout after <n>ms to <ip>`) |
84
108
  | **Books and documents** | An outline of headings with line numbers, including Markdown, "Chapter 12", numbered sections, and Hebrew chapter titles |
85
109
  | **Limits** | One budget covers tokens *and* request bytes, so files fit both your context window and your connector's payload limit |
@@ -95,22 +119,24 @@ With `gemini-3.8-flash` on the Gemini API:
95
119
  | 5 MB log, about 1.27M tokens (over the 1M limit) | "What caused the outage?" | Correct root cause, citing the right lines, in about 60 s over 11 tool calls |
96
120
  | 467 KB novel, about 117K tokens | "Where was the ledger hidden?" | Sent whole; correct. Estimated 116,840 tokens; Gemini billed 116,842 |
97
121
  | Same novel, map-reduce | "Read all of it…" | 4 parts read in parallel; correct, cited answer in 32 s |
122
+ | PDF with a chart and photos (`gemini-3.5-flash-lite`) | "Which bar is tallest, and what number is on the sign?" | Looked at 2 pages unasked; all five facts right, in 3 s. From the text alone: "cannot see the chart" |
98
123
 
99
124
  ## Documentation
100
125
 
101
126
  - [Integration guide](docs/getting-started.md): Express, plain Node, browser upload, streaming, Vertex AI, gateways, existing chat history
102
127
  - [API reference](docs/api.md)
103
- - [Configuration](docs/configuration.md): budget, stores, formats, extractors
104
- - [How it works](docs/how-it-works.md): planner, cards, tools, map-reduce, and the Gemini quirks it handles
105
- - [Security](docs/security.md): owners, tool scoping, retention, regex safety
128
+ - [Configuration](docs/configuration.md): budget, stores, formats, extractors, pictures in PDFs
129
+ - [How it works](docs/how-it-works.md): planner, cards, tools, map-reduce, looking at pages, and the Gemini quirks it handles
130
+ - [Security](docs/security.md): owners, tool scoping, retention, original files, regex safety
106
131
 
107
132
  ## Requirements
108
133
 
109
134
  Node.js 20.19 or newer. The package is ESM; CommonJS projects can `require()` it on Node 20.19+ and 22.12+.
110
- For DOCX/PPTX install `jszip`, and for PDF install `unpdf`. Both are optional:
135
+ For DOCX/PPTX install `jszip`, for PDF install `unpdf`, and to mark and show the pages of a PDF
136
+ install `@cantoo/pdf-lib`. All three are optional:
111
137
 
112
138
  ```bash
113
- npm install jszip unpdf
139
+ npm install jszip unpdf @cantoo/pdf-lib
114
140
  ```
115
141
 
116
142
  ## License
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../src/analyze.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAY,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AASrF,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAKrD;AAED,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,cAAc,GAAG,YAAY,EAAE,CA2BpF;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYhD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAgC3D"}
1
+ {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../src/analyze.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAY,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AASrF,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAKrD;AAED,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,cAAc,GAAG,YAAY,EAAE,CA6BpF;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYhD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAgC3D"}
package/dist/analyze.js CHANGED
@@ -42,7 +42,11 @@ export function buildOutline(lines, format) {
42
42
  if (entries.length <= MAX_OUTLINE_ENTRIES)
43
43
  return entries;
44
44
  // Keep the top levels first, then sample evenly so the outline still spans the document.
45
- const minLevel = Math.min(...entries.map((entry) => entry.level));
45
+ // A loop, not Math.min(...levels): spreading a few hundred thousand values overflows the stack.
46
+ let minLevel = Number.POSITIVE_INFINITY;
47
+ for (const entry of entries)
48
+ if (entry.level < minLevel)
49
+ minLevel = entry.level;
46
50
  const top = entries.filter((entry) => entry.level === minLevel);
47
51
  const pool = top.length >= 20 ? top : entries;
48
52
  const step = pool.length / MAX_OUTLINE_ENTRIES;
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.js","sourceRoot":"","sources":["../src/analyze.ts"],"names":[],"mappings":"AAEA,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,SAAS,GAAG,6EAA6E,CAAC;AAChG,MAAM,oBAAoB,GAAG,qHAAqH,CAAC;AACnJ,MAAM,KAAK,GAAG,8DAA8D,CAAC;AAC7E,MAAM,WAAW,GAA2B,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;A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"}
package/dist/extract.d.ts CHANGED
@@ -1,14 +1,37 @@
1
- import type { DocumentFormat, ExtractedText, Extractor } from "./types.js";
1
+ import type { DocumentFormat, ExtractedText, ExtractInput, Extractor } from "./types.js";
2
2
  /** Picks a format from the file name, then the MIME type. Unknown text-like files are "text". */
3
3
  export declare function detectFormat(name: string, mimeType: string): DocumentFormat;
4
- /** Decodes text bytes, honoring UTF-8 and UTF-16 byte-order marks (common for Windows logs). */
4
+ /**
5
+ * Decodes text bytes, honoring UTF-8 and UTF-16 byte-order marks (common for Windows logs).
6
+ * Throws a readable error for compressed and other binary files.
7
+ */
5
8
  export declare function decodeText(bytes: Uint8Array): string;
6
9
  /** Text of each `<prefix:p>` paragraph in Office XML. Regex keeps this free of an XML parser dependency. */
7
10
  export declare function officeXmlParagraphs(xml: string, prefix: "w" | "a"): string[];
11
+ export type PdfExtractorOptions = {
12
+ /**
13
+ * Rebuild tables from the position of the text, and write each row as `| cell | cell | |`, so an
14
+ * empty cell stays an empty cell. Defaults to true. With false, the text is in pdf.js order, as
15
+ * in version 0.1.0.
16
+ */
17
+ tables?: boolean;
18
+ /**
19
+ * Write a line under the page header of every page that shows a picture or a drawing, so the
20
+ * model knows that the text does not tell all of that page. Defaults to true. It needs the
21
+ * optional dependency `@cantoo/pdf-lib`; without it, and with false, the text is that of 0.2.0.
22
+ */
23
+ pictures?: boolean;
24
+ };
25
+ /**
26
+ * Written under the header of a page that shows a picture or a drawing. The words hold whether or
27
+ * not the model is later given a way to look at the page.
28
+ */
29
+ export declare const PICTURE_ON_PAGE = "[Picture on this page. This text cannot show it.]";
30
+ /**
31
+ * The built-in PDF extractor (needs `unpdf`). Use it to change an option:
32
+ * `createLargeFiles({ extractors: { pdf: createPdfExtractor({ tables: false }) } })`.
33
+ */
34
+ export declare function createPdfExtractor(options?: PdfExtractorOptions): Extractor;
8
35
  export declare const defaultExtractors: Record<DocumentFormat, Extractor>;
9
- export declare function extractText(bytes: Uint8Array, input: {
10
- name: string;
11
- mimeType: string;
12
- format: DocumentFormat;
13
- }, extractors?: Partial<Record<DocumentFormat, Extractor>>): Promise<ExtractedText>;
36
+ export declare function extractText(bytes: Uint8Array, input: ExtractInput, extractors?: Partial<Record<DocumentFormat, Extractor>>): Promise<ExtractedText>;
14
37
  //# sourceMappingURL=extract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAmB3E,iGAAiG;AACjG,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAG3E;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAqBpD;AAiBD,4GAA4G;AAC5G,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,EAAE,CAY5E;AAiED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,cAAc,EAAE,SAAS,CAS/D,CAAC;AAEF,wBAAsB,WAAW,CAC/B,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,EACjE,UAAU,GAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,CAAM,GAC1D,OAAO,CAAC,aAAa,CAAC,CAGxB"}
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAmBzF,iGAAiG;AACjG,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAG3E;AAID;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAkCpD;AAiBD,4GAA4G;AAC5G,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,EAAE,CAY5E;AA6CD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,eAAe,sDAAsD,CAAC;AAEnF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,SAAS,CAoD/E;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,cAAc,EAAE,SAAS,CAS/D,CAAC;AAEF,wBAAsB,WAAW,CAC/B,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,YAAY,EACnB,UAAU,GAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,CAAM,GAC1D,OAAO,CAAC,aAAa,CAAC,CAGxB"}
package/dist/extract.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { layoutPage, plainPageText } from "./pdf-layout.js";
2
+ import { findPicturePages } from "./pdf-pictures.js";
1
3
  const EXTENSION_FORMATS = {
2
4
  log: "log", out: "log", err: "log",
3
5
  md: "markdown", markdown: "markdown",
@@ -18,12 +20,23 @@ export function detectFormat(name, mimeType) {
18
20
  const extension = name.toLowerCase().split(".").at(-1) ?? "";
19
21
  return EXTENSION_FORMATS[extension] ?? MIME_FORMATS[mimeType.toLowerCase()] ?? "text";
20
22
  }
21
- /** Decodes text bytes, honoring UTF-8 and UTF-16 byte-order marks (common for Windows logs). */
23
+ const NOT_TEXT = "This file looks binary, not text. Attach a text, log, PDF, DOCX, or PPTX file.";
24
+ /**
25
+ * Decodes text bytes, honoring UTF-8 and UTF-16 byte-order marks (common for Windows logs).
26
+ * Throws a readable error for compressed and other binary files.
27
+ */
22
28
  export function decodeText(bytes) {
23
29
  if (bytes[0] === 0xff && bytes[1] === 0xfe)
24
30
  return new TextDecoder("utf-16le").decode(bytes.subarray(2));
25
31
  if (bytes[0] === 0xfe && bytes[1] === 0xff)
26
32
  return new TextDecoder("utf-16be").decode(bytes.subarray(2));
33
+ // Rotated logs often arrive as app.log.gz. Compressed bytes have few zeros, so name them here.
34
+ if (bytes[0] === 0x1f && bytes[1] === 0x8b) {
35
+ throw new Error("This file is gzip-compressed. Decompress it, then attach the text file inside.");
36
+ }
37
+ if (bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 0x03 && bytes[3] === 0x04) {
38
+ throw new Error("This file is a ZIP archive. Extract it, then attach the text file you need.");
39
+ }
27
40
  const sample = bytes.subarray(0, 8_192);
28
41
  let zeros = 0;
29
42
  for (const byte of sample)
@@ -43,9 +56,18 @@ export function decodeText(bytes) {
43
56
  if (oddZeros / half > 0.6 && evenText / half > 0.6)
44
57
  return new TextDecoder("utf-16le").decode(bytes);
45
58
  }
46
- if (sample.length > 0 && zeros / sample.length > 0.01) {
47
- throw new Error("This file looks binary, not text. Attach a text, log, PDF, DOCX, or PPTX file.");
59
+ if (sample.length > 0 && zeros / sample.length > 0.01)
60
+ throw new Error(NOT_TEXT);
61
+ // Compressed, encrypted, and media files spread control bytes evenly: about 1 byte in 10.
62
+ // Text has almost none, in UTF-8 or in a legacy single-byte encoding. Tab, line breaks, form
63
+ // feed, and ESC (colour codes) do not count.
64
+ let controls = 0;
65
+ for (const byte of sample) {
66
+ if (byte < 0x09 || (byte > 0x0d && byte < 0x20 && byte !== 0x1b) || byte === 0x7f)
67
+ controls++;
48
68
  }
69
+ if (sample.length >= 64 && controls / sample.length > 0.03)
70
+ throw new Error(NOT_TEXT);
49
71
  return new TextDecoder("utf-8").decode(bytes);
50
72
  }
51
73
  const plainText = async (bytes) => ({ text: decodeText(bytes) });
@@ -124,33 +146,82 @@ const pptx = async (bytes) => {
124
146
  }
125
147
  return { text: slides.join("\n\n"), pages: names.length };
126
148
  };
127
- const pdf = async (bytes) => {
128
- let unpdf;
129
- try {
130
- unpdf = await import("unpdf");
131
- }
132
- catch {
133
- throw new Error("Reading PDF files needs the optional dependency \"unpdf\".");
134
- }
135
- // pdf.js may detach the buffer it reads, so give it a copy.
136
- const document = await unpdf.getDocumentProxy(new Uint8Array(bytes));
137
- const { totalPages, text } = await unpdf.extractText(document, { mergePages: false });
138
- const pages = Array.isArray(text) ? text : [text];
139
- if (!pages.some((page) => page.trim())) {
140
- throw new Error("This PDF has no text layer (it may be scanned). It needs OCR before it can be searched.");
141
- }
142
- return {
143
- text: pages.map((page, index) => `--- Page ${index + 1} ---\n${page.trim()}`).join("\n\n"),
144
- pages: totalPages,
149
+ /** Written in place of a page that has no text at all, so the model can say so instead of guessing. */
150
+ const PAGE_WITHOUT_TEXT = "[No text on this page. It may be a scan, a photo, or a chart.]";
151
+ /**
152
+ * Written under the header of a page that shows a picture or a drawing. The words hold whether or
153
+ * not the model is later given a way to look at the page.
154
+ */
155
+ export const PICTURE_ON_PAGE = "[Picture on this page. This text cannot show it.]";
156
+ /**
157
+ * The built-in PDF extractor (needs `unpdf`). Use it to change an option:
158
+ * `createLargeFiles({ extractors: { pdf: createPdfExtractor({ tables: false }) } })`.
159
+ */
160
+ export function createPdfExtractor(options = {}) {
161
+ const tables = options.tables ?? true;
162
+ const pictures = options.pictures ?? true;
163
+ return async (bytes, input) => {
164
+ let unpdf;
165
+ try {
166
+ unpdf = await import("unpdf");
167
+ }
168
+ catch {
169
+ throw new Error("Reading PDF files needs the optional dependency \"unpdf\".");
170
+ }
171
+ // pdf.js may detach the buffer it reads, so give it a copy.
172
+ const document = await unpdf.getDocumentProxy(new Uint8Array(bytes));
173
+ const texts = [];
174
+ const geometry = [];
175
+ let hasText = false;
176
+ for (let number = 1; number <= document.numPages; number++) {
177
+ const page = await document.getPage(number);
178
+ const content = await page.getTextContent();
179
+ const items = content.items.filter((item) => typeof item.str === "string");
180
+ const transform = page.getViewport({ scale: 1 }).transform;
181
+ let text = "";
182
+ let found = [];
183
+ if (tables) {
184
+ try {
185
+ ({ text, tables: found } = layoutPage(items, transform));
186
+ }
187
+ catch {
188
+ // Unusual geometry must never lose a page: fall back to the plain order.
189
+ text = plainPageText(items);
190
+ }
191
+ }
192
+ else {
193
+ text = plainPageText(items);
194
+ }
195
+ text = text.trim();
196
+ if (text)
197
+ hasText = true;
198
+ texts.push(text);
199
+ geometry.push({ view: page.view, transform, tables: found });
200
+ page.cleanup();
201
+ }
202
+ if (!hasText) {
203
+ // A scan has nothing to search, but a short one can be read by looking at its pages, when the
204
+ // caller says that they can be shown. Every page then says that it has no text.
205
+ const most = input?.scannedPages ?? 0;
206
+ if (most <= 0)
207
+ throw new Error("This PDF has no text layer (it may be scanned). It needs OCR before it can be searched.");
208
+ if (document.numPages > most) {
209
+ throw new Error(`This PDF has no text layer (it may be scanned) and ${document.numPages} pages. Without text it can only be read by looking at its pages, which works for up to ${most} pages. It needs OCR first.`);
210
+ }
211
+ }
212
+ // Which pages show a picture. Undefined when that could not be found out: then none is marked.
213
+ const pictured = pictures ? await findPicturePages(bytes, geometry) : undefined;
214
+ const pages = texts.map((text, index) => `--- Page ${index + 1} ---\n${pictured?.[index] ? `${PICTURE_ON_PAGE}\n` : ""}${text || PAGE_WITHOUT_TEXT}`);
215
+ return { text: pages.join("\n\n"), pages: document.numPages };
145
216
  };
146
- };
217
+ }
147
218
  export const defaultExtractors = {
148
219
  text: plainText,
149
220
  markdown: plainText,
150
221
  log: plainText,
151
222
  json: plainText,
152
223
  csv: plainText,
153
- pdf,
224
+ pdf: createPdfExtractor(),
154
225
  docx,
155
226
  pptx,
156
227
  };
@@ -1 +1 @@
1
- {"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAEA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AAC,QAAQ,EAAE,CAAC;IAChE,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAsC;IAClE,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,SAAS;IACnB,GAAG,EAAE,SAAS;IACd,IAAI,EAAE,SAAS;IACf,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,kBAAkB,EAAE;IACzB,IAAI;IACJ,IAAI;CACL,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,KAAiB,EACjB,KAAmB,EACnB,aAAyD,EAAE;IAE3D,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9E,OAAO,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import type { LargeFiles } from "../library.js";
2
2
  import type { DocumentPlan } from "../types.js";
3
3
  import { type GeminiEndpoint } from "./endpoints.js";
4
+ import { type GeminiToolFilePlacement } from "./generate.js";
4
5
  export type GeminiPart = Record<string, unknown>;
5
6
  export type GeminiContent = {
6
7
  role: "user" | "model";
@@ -13,6 +14,8 @@ export type ChatTurn = {
13
14
  };
14
15
  /** Sent (invisibly to the user) when the model must stop using tools and answer. */
15
16
  export declare const FINAL_ANSWER_REQUEST = "Stop using tools now. Answer my question using only what the tools returned above, with line citations. Say plainly what you could not find.";
17
+ /** The same, when the only tool was `view_pages`: the text of the files is in the prompt, not in tool results. */
18
+ export declare const FINAL_ANSWER_AFTER_PAGES = "Stop using tools now. Answer my question from the text of the files and the pages you looked at. Say plainly what you could not see or find.";
16
19
  /** Some document IDs were never uploaded, have expired, or belong to another owner. */
17
20
  export declare class DocumentsNotFoundError extends Error {
18
21
  readonly ids: string[];
@@ -26,8 +29,15 @@ export declare class GeminiRequestError extends Error {
26
29
  export type AskGeminiOptions = {
27
30
  files: LargeFiles;
28
31
  endpoint: GeminiEndpoint;
29
- /** Documents this conversation may use. Their text or cards are added to the last user turn. */
32
+ /** Documents this conversation may use. Where their text or cards go: see `documentPlacement`. */
30
33
  documentIds: string[];
34
+ /**
35
+ * Where document text and cards are added. "first" (the default) puts them at the start of the
36
+ * first user turn, where they stay as the conversation grows, so Gemini's prompt cache can
37
+ * reuse them on every follow-up question. "last" appends them to the latest user turn, as 0.1.0
38
+ * did; the document then moves on every turn and is billed in full each time.
39
+ */
40
+ documentPlacement?: "first" | "last";
31
41
  /** Plain chat history; the last turn must be the user's question. Use this or `contents`. */
32
42
  messages?: ChatTurn[];
33
43
  /** Your own Gemini `contents` (with images, inline PDFs, etc.). The last turn must be the user's. */
@@ -37,10 +47,27 @@ export type AskGeminiOptions = {
37
47
  generationConfig?: Record<string, unknown>;
38
48
  /** The user asking. Documents ingested with a different owner are treated as missing. */
39
49
  owner?: string;
40
- /** Model turns that may call tools before a final, tool-free turn. Defaults to 12. */
50
+ /**
51
+ * The most model requests for one question, counting the answer. Tools can run in all but the
52
+ * last: if the model is still calling tools then, the last request is sent with no tools so it
53
+ * must answer. Defaults to 12.
54
+ */
41
55
  maxToolTurns?: number;
42
56
  /** Offer `analyze_whole_document`, which reads a whole file in many model calls. Defaults to true. */
43
57
  wholeDocumentAnalysis?: boolean;
58
+ /**
59
+ * Offer `view_pages` for PDFs whose original file is kept (`keepOriginals`), so the model can
60
+ * look at pictures, charts and layout. Defaults to true. It changes nothing for a library that
61
+ * keeps no originals.
62
+ */
63
+ viewPages?: boolean;
64
+ /**
65
+ * Where the pages go in the request. "inside" (the default) puts the PDF in the function
66
+ * response itself, which Gemini 3 models read. "beside" sends it in a user turn of its own,
67
+ * after the function responses: use it for Gemini 2.5, which does not see a file inside a
68
+ * function response.
69
+ */
70
+ toolFilePlacement?: GeminiToolFilePlacement;
44
71
  /** generationConfig for whole-document part reads. Defaults to `{ temperature: 0.2, maxOutputTokens }`. */
45
72
  analysisConfig?: (maxOutputTokens: number) => Record<string, unknown>;
46
73
  /** Answer text as it streams. Streaming is used when this is set and the endpoint has `streamUrl`. */
@@ -53,7 +80,16 @@ export type AskGeminiOptions = {
53
80
  signal?: AbortSignal;
54
81
  };
55
82
  export type AskGeminiResult = {
83
+ /** Everything the model wrote, including any remark it made before calling a tool. */
56
84
  text: string;
85
+ /**
86
+ * False when the model's last turn had no text: the prompt was blocked, the reply was cut off
87
+ * before any text, or the model produced a malformed tool call. `text` may then be empty or
88
+ * hold only an earlier remark, so show your own message instead of treating it as the answer.
89
+ */
90
+ answered: boolean;
91
+ /** Why Gemini refused the prompt (`promptFeedback.blockReason`), when it did. */
92
+ blockReason?: string;
57
93
  /** Every tool step taken, in order (also delivered through `onStep`). */
58
94
  steps: string[];
59
95
  /** Which documents went in whole and which were searched. */
@@ -1 +1 @@
1
- {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/gemini/chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIrE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjD,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC;AAC5E,0EAA0E;AAC1E,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,oFAAoF;AACpF,eAAO,MAAM,oBAAoB,iJAAiJ,CAAC;AAEnL,uFAAuF;AACvF,qBAAa,sBAAuB,SAAQ,KAAK;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE;gBA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