llm-large-files 0.8.1 → 0.9.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.
- package/CHANGELOG.md +631 -0
- package/README.md +9 -10
- package/dist/access.d.ts +86 -0
- package/dist/access.d.ts.map +1 -0
- package/dist/access.js +131 -0
- package/dist/access.js.map +1 -0
- package/dist/ask.d.ts +45 -1
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +181 -20
- package/dist/ask.js.map +1 -1
- package/dist/cache.d.ts +12 -3
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +18 -5
- package/dist/cache.js.map +1 -1
- package/dist/encoding.js +5 -3
- package/dist/encoding.js.map +1 -1
- package/dist/error-info.d.ts +57 -0
- package/dist/error-info.d.ts.map +1 -0
- package/dist/error-info.js +217 -0
- package/dist/error-info.js.map +1 -0
- package/dist/errors.d.ts +72 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +102 -15
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +35 -9
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +42 -11
- package/dist/events.js.map +1 -1
- package/dist/evidence.d.ts +4 -2
- package/dist/evidence.d.ts.map +1 -1
- package/dist/evidence.js +14 -3
- package/dist/evidence.js.map +1 -1
- package/dist/extract.d.ts +32 -8
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +46 -35
- package/dist/extract.js.map +1 -1
- package/dist/gemini/adapter.d.ts +19 -3
- package/dist/gemini/adapter.d.ts.map +1 -1
- package/dist/gemini/adapter.js +84 -12
- package/dist/gemini/adapter.js.map +1 -1
- package/dist/gemini/chat.d.ts +18 -6
- package/dist/gemini/chat.d.ts.map +1 -1
- package/dist/gemini/chat.js +2 -0
- package/dist/gemini/chat.js.map +1 -1
- package/dist/gemini/index.d.ts +1 -1
- package/dist/gemini/index.d.ts.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/ingest.d.ts +70 -0
- package/dist/ingest.d.ts.map +1 -0
- package/dist/ingest.js +868 -0
- package/dist/ingest.js.map +1 -0
- package/dist/library.d.ts +176 -34
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +332 -512
- package/dist/library.js.map +1 -1
- package/dist/limiter.d.ts +2 -2
- package/dist/limiter.js +2 -2
- package/dist/map-reduce.js +3 -3
- package/dist/map-reduce.js.map +1 -1
- package/dist/model.d.ts +43 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +63 -3
- package/dist/model.js.map +1 -1
- package/dist/node/handlers.d.ts +234 -7
- package/dist/node/handlers.d.ts.map +1 -1
- package/dist/node/handlers.js +482 -121
- package/dist/node/handlers.js.map +1 -1
- package/dist/node/index.d.ts +3 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/ingest-child.d.ts +7 -1
- package/dist/node/ingest-child.d.ts.map +1 -1
- package/dist/node/ingest-child.js +18 -3
- package/dist/node/ingest-child.js.map +1 -1
- package/dist/node/isolated.d.ts +3 -1
- package/dist/node/isolated.d.ts.map +1 -1
- package/dist/node/isolated.js +11 -4
- package/dist/node/isolated.js.map +1 -1
- package/dist/node/originals.d.ts +19 -0
- package/dist/node/originals.d.ts.map +1 -0
- package/dist/node/originals.js +82 -0
- package/dist/node/originals.js.map +1 -0
- package/dist/node/spool.d.ts +102 -0
- package/dist/node/spool.d.ts.map +1 -0
- package/dist/node/spool.js +365 -0
- package/dist/node/spool.js.map +1 -0
- package/dist/node/sse.d.ts +4 -3
- package/dist/node/sse.d.ts.map +1 -1
- package/dist/node/sse.js +7 -6
- package/dist/node/sse.js.map +1 -1
- package/dist/pdf-layout.d.ts.map +1 -1
- package/dist/pdf-layout.js +71 -12
- package/dist/pdf-layout.js.map +1 -1
- package/dist/ranged.d.ts +22 -11
- package/dist/ranged.d.ts.map +1 -1
- package/dist/ranged.js +50 -12
- package/dist/ranged.js.map +1 -1
- package/dist/retry.d.ts +3 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +6 -2
- package/dist/retry.js.map +1 -1
- package/dist/scope.d.ts +25 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +60 -0
- package/dist/scope.js.map +1 -0
- package/dist/source.d.ts +60 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +170 -0
- package/dist/source.js.map +1 -0
- package/dist/stores.d.ts +120 -31
- package/dist/stores.d.ts.map +1 -1
- package/dist/stores.js +582 -139
- package/dist/stores.js.map +1 -1
- package/dist/testing/fake-fetch.d.ts +31 -0
- package/dist/testing/fake-fetch.d.ts.map +1 -0
- package/dist/testing/fake-fetch.js +66 -0
- package/dist/testing/fake-fetch.js.map +1 -0
- package/dist/testing/fake-model.d.ts +38 -0
- package/dist/testing/fake-model.d.ts.map +1 -0
- package/dist/testing/fake-model.js +62 -0
- package/dist/testing/fake-model.js.map +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +9 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/store-checks.d.ts +72 -0
- package/dist/testing/store-checks.d.ts.map +1 -0
- package/dist/testing/store-checks.js +619 -0
- package/dist/testing/store-checks.js.map +1 -0
- package/dist/tools.d.ts +25 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +135 -13
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +116 -13
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +17 -8
- package/docs/getting-started.md +18 -13
- package/docs/guides/anthropic.md +12 -8
- package/docs/guides/conversations.md +112 -47
- package/docs/guides/costs-and-limits.md +16 -7
- package/docs/guides/deployment.md +309 -87
- package/docs/guides/errors-and-reliability.md +161 -23
- package/docs/guides/own-adapter-and-loop.md +27 -10
- package/docs/guides/pdfs.md +123 -29
- package/docs/guides/storage.md +634 -143
- package/docs/guides/testing.md +78 -129
- package/docs/guides/vertex-and-gemini.md +10 -7
- package/docs/guides/web-app.md +322 -77
- package/docs/how-it-works.md +35 -8
- package/docs/measurements.md +63 -8
- package/docs/publishing.md +112 -36
- package/docs/reference/ask.md +154 -13
- package/docs/reference/errors-and-retries.md +166 -14
- package/docs/reference/events.md +53 -20
- package/docs/reference/gemini.md +70 -21
- package/docs/reference/library.md +709 -165
- package/docs/reference/node.md +633 -104
- package/docs/reference/testing.md +311 -0
- package/docs/reference/tools.md +15 -5
- package/docs/security.md +316 -70
- package/docs/troubleshooting.md +165 -58
- package/docs/upgrading-0.9.md +890 -0
- package/package.json +12 -3
- package/src/access.ts +144 -0
- package/src/ask.ts +230 -19
- package/src/cache.ts +20 -5
- package/src/encoding.ts +6 -4
- package/src/error-info.ts +255 -0
- package/src/errors.ts +129 -15
- package/src/events.ts +86 -21
- package/src/evidence.ts +14 -3
- package/src/extract.ts +50 -33
- package/src/gemini/adapter.ts +97 -11
- package/src/gemini/chat.ts +20 -6
- package/src/gemini/index.ts +1 -1
- package/src/index.ts +9 -6
- package/src/ingest.ts +927 -0
- package/src/library.ts +482 -523
- package/src/limiter.ts +2 -2
- package/src/map-reduce.ts +3 -3
- package/src/model.ts +69 -5
- package/src/node/handlers.ts +691 -117
- package/src/node/index.ts +13 -2
- package/src/node/ingest-child.ts +23 -5
- package/src/node/isolated.ts +11 -4
- package/src/node/originals.ts +78 -0
- package/src/node/spool.ts +365 -0
- package/src/node/sse.ts +7 -6
- package/src/pdf-layout.ts +69 -11
- package/src/ranged.ts +42 -14
- package/src/retry.ts +6 -2
- package/src/scope.ts +63 -0
- package/src/source.ts +178 -0
- package/src/stores.ts +635 -140
- package/src/testing/fake-fetch.ts +80 -0
- package/src/testing/fake-model.ts +78 -0
- package/src/testing/index.ts +11 -0
- package/src/testing/store-checks.ts +660 -0
- package/src/tools.ts +150 -14
- package/src/types.ts +106 -13
package/docs/how-it-works.md
CHANGED
|
@@ -552,6 +552,18 @@ models), against half of
|
|
|
552
552
|
out, the tool says so and the model answers from what it has. The looks of one turn run one after
|
|
553
553
|
another, each with the room the one before it left.
|
|
554
554
|
|
|
555
|
+
The looks of all questions of a library take their turns too (new in 0.9.0). A look parses the
|
|
556
|
+
whole PDF on the one thread the questions share: six at once each took about four times as long,
|
|
557
|
+
and held 352 MB more than one. By default one look runs at a time (`maxConcurrentPageLooks`), and
|
|
558
|
+
the others wait in order, before their PDF is loaded, so a look that waits holds none of its bytes.
|
|
559
|
+
The memory check above is made once the turn comes. A look that waits longer than
|
|
560
|
+
`pageLookWaitMs` (30 s) is not run: the model reads that the server is busy and to answer from the
|
|
561
|
+
text, and the question gets a `page_looks_busy` notice. The other looks of that tool turn then do
|
|
562
|
+
not wait: they run only when a turn is free at once, so a wait that ends busy comes once in a
|
|
563
|
+
turn. A look holds its turn
|
|
564
|
+
while it reads the PDF from the store for at most `ingestTimeoutMs` (2 minutes by default), and a
|
|
565
|
+
question that is stopped gives its turn back at once.
|
|
566
|
+
|
|
555
567
|
Pages are not kept in `toolTurns`: the stored round says that they were shown. Setting this up,
|
|
556
568
|
scanned PDFs and `toolFilePlacement`: [PDFs and other formats](./guides/pdfs.md).
|
|
557
569
|
|
|
@@ -628,7 +640,10 @@ once, in the core. `askGemini` is this loop with Gemini adapters ([below](#gemin
|
|
|
628
640
|
|
|
629
641
|
A question goes like this:
|
|
630
642
|
|
|
631
|
-
1. Fit the budget to the models, and [plan the documents](#how-the-plan-is-made).
|
|
643
|
+
1. Fit the budget to the models, and [plan the documents](#how-the-plan-is-made). Documents that
|
|
644
|
+
are missing are settled by `onMissingDocuments`: by default the question fails before any
|
|
645
|
+
request; with `"drop"` it is answered without them, with one line in the system instruction
|
|
646
|
+
that says how many files are no longer available.
|
|
632
647
|
2. Send a request with the tools (`toolChoice: "auto"`) to the model that explores.
|
|
633
648
|
3. A reply without tool calls ends the tool requests. Its text is the answer, unless it is empty,
|
|
634
649
|
the prompt was blocked, or it comes from an explorer. A reply with calls is a turn: its calls run, each result gets
|
|
@@ -697,7 +712,13 @@ provider has answered, by the provider's own count ([Token estimates](#token-est
|
|
|
697
712
|
all but the last two, then all but the last one, as far as needed. `steps` then holds "Older tool
|
|
698
713
|
results were shortened to make room in the request". When any model of the question, the
|
|
699
714
|
answering model or the explorer, may only grow its conversation (`capabilities.appendOnly`:
|
|
700
|
-
Claude), nothing is replaced, for either model.
|
|
715
|
+
Claude), nothing is replaced during the question, for either model.
|
|
716
|
+
- **Before the first request** (new in 0.9.0), when the stored rounds of earlier questions make it
|
|
717
|
+
larger than the room it has in tokens, their results are replaced the same way, as far as
|
|
718
|
+
needed, before it is sent. Only the estimate of its tokens is checked, as after a refused
|
|
719
|
+
request: a request is not shortened for its bytes alone. Nothing of the question was sent yet, and a stored round has no thinking in it, so
|
|
720
|
+
this is done for an append-only model too. The request is what an overflow would have had sent
|
|
721
|
+
again ([below](#a-request-too-large-for-the-model)), without the refused request before it.
|
|
701
722
|
- **No room left.** Calls that still cannot each get 1,500 characters (or their cap, when it is
|
|
702
723
|
smaller) are answered "Not run: there is no room left in this conversation for another tool
|
|
703
724
|
result. Answer now, from what the tools returned so far.", the last calls of the turn first, and
|
|
@@ -708,7 +729,9 @@ provider has answered, by the provider's own count ([Token estimates](#token-est
|
|
|
708
729
|
A stand-in is a short result in place of one that was dropped to make room. It keeps which document
|
|
709
730
|
it was about and what it showed, says `dropped: true`, and tells the model how to get it back. What
|
|
710
731
|
each tool's stand-in keeps, and which results are too small to replace, is in
|
|
711
|
-
[`stubResult`](./reference/ask.md#stubresultcall-result-hadfiles).
|
|
732
|
+
[`stubResult`](./reference/ask.md#stubresultcall-result-hadfiles). Since 0.9.0 a result is never
|
|
733
|
+
replaced by a stand-in as large as itself or larger: a search counted by group, or an
|
|
734
|
+
`aggregate_table` result, of a few short groups stays as it is. The tool rounds a question
|
|
712
735
|
returns in `toolTurns` hold stand-ins for pages, since a file cannot be kept as JSON
|
|
713
736
|
([Conversations](./guides/conversations.md)).
|
|
714
737
|
|
|
@@ -796,7 +819,10 @@ end the question:
|
|
|
796
819
|
and sends the request again. `steps` says "The request was larger than the model takes: older tool
|
|
797
820
|
results were shortened, and it was sent again". That happens at most twice a question, and once
|
|
798
821
|
for any one request. When any model of the question may only grow its conversation (Claude),
|
|
799
|
-
nothing is shortened.
|
|
822
|
+
nothing is shortened. Since 0.9.0 the first request of a question is checked against the loop's
|
|
823
|
+
own estimate first, and the stored rounds of earlier questions are shortened before it is sent
|
|
824
|
+
([making room](#room-in-the-request)): a history that grew past the window no longer costs a
|
|
825
|
+
refused request, and no longer fails a question on Claude.
|
|
800
826
|
- **Plan again.** When it happens to the first requests of a question, before any tool call was
|
|
801
827
|
answered or any text shown, the documents are planned again for a smaller window, once, as for a
|
|
802
828
|
model that declares it. The window is the one the provider named, or seven tenths of the window
|
|
@@ -948,7 +974,7 @@ Where the events of a question come from:
|
|
|
948
974
|
| `retry` | the retry rule ([Retries and waits](#retries-and-waits)) | Before each wait, between the request's start and end. |
|
|
949
975
|
| `text` | the answering model's replies | As the text arrives with `streamText`; otherwise once each reply is in. The same text as `onText`. |
|
|
950
976
|
| `tool.start`, `tool.progress`, `tool.end` | the calls of a turn ([The calls of a turn](#the-calls-of-a-turn)) | A call starts when it runs, so starts and ends of one turn interleave; ends come in call order. `tool.progress` is the progress of a whole-file read. |
|
|
951
|
-
| `notice` | the loop | What it did that is not a request or a call: `searching_instead`, `writing_answer`, `replanned`, `room_made`, `nudged`, `results_shortened`, `answer_again`, `calls_not_run`, and
|
|
977
|
+
| `notice` | the loop | What it did that is not a request or a call: `searching_instead`, `writing_answer`, `replanned`, `room_made`, `nudged`, `results_shortened`, `answer_again`, `calls_not_run`, and those that the callbacks never got: `budget_reached`, `no_room`, `blocked`, and, new in 0.9.0, `documents_missing`, `document_gone` and `page_looks_busy`. |
|
|
952
978
|
| `run.finish`, `run.error` | `askWithFiles` | Last, once. Nothing comes after them, not even a part read still running. |
|
|
953
979
|
|
|
954
980
|
The events tell a model error by its kind and status, never in the provider's words, and carry no
|
|
@@ -1003,7 +1029,7 @@ What differs is in the adapters:
|
|
|
1003
1029
|
| `tokenScale` | 1 | 1 by default (`tokenScale`) | 1.35 by default (`tokenScale`) |
|
|
1004
1030
|
| Kept free in the window for the reply | nothing | nothing | `maxTokens`, 64,000 by default |
|
|
1005
1031
|
| Request size declared | none, unless you set `maxRequestBytes` | none, unless you set `maxRequestBytes` | 32,000,000 bytes by default (`maxRequestBytes`) |
|
|
1006
|
-
| Old results shortened for room | yes, unless Claude is the other model of the question | yes, unless Claude is the other model of the question | no: the conversation may only grow (`appendOnly`); with Claude as the answering model or the explorer, nothing is shortened for either |
|
|
1032
|
+
| Old results shortened for room | yes, unless Claude is the other model of the question | yes, unless Claude is the other model of the question | no: the conversation may only grow (`appendOnly`); with Claude as the answering model or the explorer, nothing is shortened for either during the question. The stored rounds of earlier questions are, before its first request, when they make it too large (since 0.9.0) |
|
|
1007
1033
|
| Prompt cache | the provider's own | the provider's own | `cache_control` on each request: 5 minutes, `cache: "1h"`, or `false` for none |
|
|
1008
1034
|
| Streams the chat | when the loop asks for the text as it is written (`streamText`: with `onText`, or in `askStream`) and the endpoint has a `streamUrl` | when the loop asks for the text as it is written, unless `stream: false` | always, unless `stream: false` |
|
|
1009
1035
|
| A whole stream ends with | a chunk with a `finishReason` | a `finish_reason`, or `[DONE]` | a stop reason |
|
|
@@ -1037,8 +1063,9 @@ explorer (`explorerUrl`, which `explorerModel` of `geminiApi()` and `vertexAi()`
|
|
|
1037
1063
|
second `gemini()` for it, called with the same headers, without streaming, with
|
|
1038
1064
|
`explorerGenerationConfig` or else `generationConfig`. `maxToolTurns` and `maxToolCallsPerTurn` are
|
|
1039
1065
|
the names that `limits.toolTurns` and `limits.callsPerTurn` had before 0.5.0; `limits` wins.
|
|
1040
|
-
`contents` are converted to messages with `fromGeminiContents
|
|
1041
|
-
|
|
1066
|
+
`contents` are converted to messages with `fromGeminiContents`: since 0.9.0 the tool rounds that
|
|
1067
|
+
`geminiToolTurns` wrote come back as stored rounds, so pointers and stand-ins apply to them, and any
|
|
1068
|
+
other function part is sized by its JSON. Everything above applies; what is Gemini's own:
|
|
1042
1069
|
|
|
1043
1070
|
- **The model's turns go back unchanged**, so Gemini 3 thought signatures stay intact. A signature
|
|
1044
1071
|
belongs to the model that wrote it: with an explorer, the answering model gets the explorer's
|
package/docs/measurements.md
CHANGED
|
@@ -7,7 +7,7 @@ has not.
|
|
|
7
7
|
|
|
8
8
|
Each result is a measurement at one point in time, with the models named. It is not a guarantee.
|
|
9
9
|
Another model, a later version of the same model, another provider or other files can give other
|
|
10
|
-
results. Nothing was run again for this page but
|
|
10
|
+
results. Nothing was run again for this page but two records, which say so: each result is given
|
|
11
11
|
as it was recorded, with the release it was recorded for. Before you rely on a number, check it on your own files
|
|
12
12
|
([Measuring your own setup](#measuring-your-own-setup)).
|
|
13
13
|
|
|
@@ -350,13 +350,68 @@ MB took over 600 MB. Since 0.4.0 every use of a document kept in memory asks the
|
|
|
350
350
|
quotes, backslashes, tabs or many line breaks low: by 23% for a JSON-lines export and 31% for TSV.
|
|
351
351
|
A read of quoted text came out at 42,514 characters against a cap of 24,000.
|
|
352
352
|
|
|
353
|
-
**Memory and stalls of an ingest (main, November 2026, Node 24 on Windows,
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
353
|
+
**Memory and stalls of an ingest (history: main before 0.6.0, November 2026, Node 24 on Windows,
|
|
354
|
+
plain-text logs).** Recorded on 2026-11-20, with the docs of #12, on the code of 0.5.0 and the fixes
|
|
355
|
+
after it (`main` above), before 0.6.0 made an ingest work in slices. The stalls are those of the
|
|
356
|
+
ingest of 0.5.0, in one block: 0.6.0 and later have none of seconds (the record after this one, and
|
|
357
|
+
the table of 0.6.0 below). Peak memory above the uploaded bytes: about 175 MB for a log of 25 MB,
|
|
358
|
+
270 MB for 50 MB, and 470 MB for 95 MB. An ingest of the 95 MB log fitted in a worker thread of
|
|
359
|
+
256 MB. One exact search of the 95 MB log, read by range, took about 60 to 80 MB. Eight such
|
|
360
|
+
searches at once took about 70 to 85 MB, and about 220 MB with `cacheBytes` at 1 GB, which keeps the
|
|
361
|
+
decoded pieces. An ingest held the event loop for about 0.8 to 1.5 seconds (25 MB) and 3 to 5
|
|
362
|
+
seconds (95 MB). Linux was not measured.
|
|
363
|
+
|
|
364
|
+
**Memory and stalls of an ingest, measured again (0.9.0 in development, 2026-11-23, Node 22.23 on
|
|
365
|
+
Linux, plain-text logs).** Logs of 25, 50 and 95 MB made by `serviceLog` of `llm-large-files/testing`
|
|
366
|
+
(about 88 ASCII characters a line), each sent to `files.ingest` over a `FileDocumentStore` in a
|
|
367
|
+
temporary folder, in a fresh process with Node's default heap, on the build of 86b9bfd. A laptop
|
|
368
|
+
(Intel Core i5-8250U, 4 cores and 8 threads, 8 GB) that ran other work too: the load average was 5
|
|
369
|
+
to 14. Peak memory is the kernel's high-water mark of the resident set, less the resident set once
|
|
370
|
+
the log was read into memory, so the uploaded bytes are not in it. A stall is the longest gap between
|
|
371
|
+
two beats of a 5 ms timer, as in the table of 0.6.0 below.
|
|
372
|
+
|
|
373
|
+
| Log | Peak above the uploaded bytes | Longest stall | Ingest took |
|
|
374
|
+
|---|---|---|---|
|
|
375
|
+
| 25 MB, 295,660 lines (5 runs) | 133 to 136 MB | 56 to 64 ms; 134 ms in one run at a load of 6 | 3.3 to 3.8 s; 6.8 s in that run |
|
|
376
|
+
| 50 MB, 591,315 lines (5 runs) | 194 to 206 MB | 126 to 307 ms, at a load of 13 to 14 | 6.2 to 15.3 s |
|
|
377
|
+
| 95 MB, 1,123,485 lines (5 runs) | 342 to 347 MB | 233 to 360 ms | 11.6 to 14.9 s |
|
|
378
|
+
|
|
379
|
+
Over a `MemoryDocumentStore` (2 runs each), the peaks were 78 to 81 MB, 123 MB and 204 to 206 MB,
|
|
380
|
+
with the stored text in them. Its longest stall for the 95 MB log was about 150 to 240 ms, the UTF-8
|
|
381
|
+
decoding below. The 95 MB log also fitted in a heap of 256 MB
|
|
382
|
+
(`--max-old-space-size=256`), and of 192, over a `FileDocumentStore`. The longest stalls are two
|
|
383
|
+
steps that run in one block, each taking about 2 to 4 ms for each MB of text on this machine:
|
|
384
|
+
|
|
385
|
+
- the decoding of the whole UTF-8 file when its reading starts (the same `TextDecoder` call alone
|
|
386
|
+
took 192 to 205 ms for the 95 MB log);
|
|
387
|
+
- over a `FileDocumentStore`, the writing of the text, which encodes it to UTF-8 in one call
|
|
388
|
+
(`Buffer.from` alone took 184 to 217 ms).
|
|
389
|
+
|
|
390
|
+
The other steps pause about every 12 ms (gaps of 40 to 70 ms on this busy machine). 0.6.0 decoded
|
|
391
|
+
the same way and measured 31 to 34 ms for a 99 MB log (below), on Windows with Node 24. The store
|
|
392
|
+
does not explain the difference, since the decoding is one block over either store: the machine
|
|
393
|
+
and its load do.
|
|
394
|
+
[Deployment](./guides/deployment.md) turns these into sizing advice.
|
|
395
|
+
|
|
396
|
+
**Many uploads at once (0.8.2, November 2026, Node 22 on Linux, 8 cores).** 100 logs of 2 MB
|
|
397
|
+
(190.7 MB, about 10% of the lines in Hebrew), read into memory first as the upload handler does,
|
|
398
|
+
then all sent to `files.ingest` at once, over a `FileDocumentStore` on a local disk. Peak memory
|
|
399
|
+
is the resident set the kernel recorded; the machine ran other work too.
|
|
400
|
+
|
|
401
|
+
| `maxConcurrentIngests` | Peak memory | Peak heap | First answered | Half answered | All answered |
|
|
402
|
+
|---|---|---|---|---|---|
|
|
403
|
+
| `Infinity` (0.8.1) | 817 to 830 MB | 475 MB | 25 to 39 s | 27 to 40 s | 28 to 42 s |
|
|
404
|
+
| 4 | 391 MB | 105 MB | 0.9 s | 13.8 s | 29.9 s |
|
|
405
|
+
| 2 (the default since 0.8.2), 2 runs | 329 to 356 MB | 48 to 74 MB | 0.5 to 0.7 s | 13.4 to 17.4 s | 27.6 to 33.4 s |
|
|
406
|
+
|
|
407
|
+
About 190 MB of each peak is the 100 uploads, held until their ingest ends. Ingests at once share
|
|
408
|
+
one thread, so taking turns costs no time overall. One upload of 100 MB took a peak of 560 MB, and
|
|
409
|
+
one of 50 MB 325 to 345 MB from a process of about 70 MB. After the ingests the heap is back at
|
|
410
|
+
about 10 MB: nothing of a document stays in memory with a `FileDocumentStore`. Until 0.8.2 the
|
|
411
|
+
meta that `ingest` returned kept the whole text in memory while it was held (194 MB of heap for
|
|
412
|
+
the meta of the 100 MB log). A search of that 100 MB log, read by range in a new process of 59 MB,
|
|
413
|
+
took a peak of 108 MB (49 MB above the process, 1.8 s); eight at once took 115 to 159 MB, and up
|
|
414
|
+
to 9 s.
|
|
360
415
|
|
|
361
416
|
**Ingest of large and hostile files (0.6.0, November 2026, Node 24 on Windows).** Each file was
|
|
362
417
|
ingested into a `MemoryDocumentStore` in a fresh process, with the parsers loaded first, 5157e7f
|
package/docs/publishing.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
For maintainers. This page covers how a version of `llm-large-files` reaches npm: the changelog
|
|
4
4
|
while the version is in development, the release pull request, the tag that starts the release
|
|
5
|
-
workflow, and publishing by hand when the workflow's publish
|
|
5
|
+
workflow, and publishing by hand when the workflow's publish job fails. Working on the code
|
|
6
6
|
itself is in [CONTRIBUTING.md](https://github.com/renanbazinin/llm-large-files/blob/main/CONTRIBUTING.md).
|
|
7
7
|
|
|
8
8
|
## The changelog
|
|
@@ -58,6 +58,13 @@ an app receives (a `ModelErrorKind`, a `DocumentFormat`) goes in **Upgrading**:
|
|
|
58
58
|
`switch`, or a `Record` keyed by the union, needs the new case. A new export, a new optional option
|
|
59
59
|
or field, or a wider parameter type goes in **New**.
|
|
60
60
|
|
|
61
|
+
A new optional parameter at the end of a function or method goes in **Upgrading** too, for the code
|
|
62
|
+
that already fills its place: a store, or a subclass of a library class, whose method takes an extra
|
|
63
|
+
parameter of its own there, and a function passed as a callback (`.map(fromGeminiContents)` gets the
|
|
64
|
+
index in it). 0.9.0's `context` on every store method and `options` of `fromGeminiContents` did
|
|
65
|
+
both. Compile a probe of each case against the old and the new version before writing that a change
|
|
66
|
+
is only an addition.
|
|
67
|
+
|
|
61
68
|
### At release
|
|
62
69
|
|
|
63
70
|
The release pull request makes two edits:
|
|
@@ -100,15 +107,19 @@ Pushing the tag starts the release workflow.
|
|
|
100
107
|
3. Run the checks, and look at what npm will publish:
|
|
101
108
|
|
|
102
109
|
```bash
|
|
103
|
-
npm run check
|
|
104
|
-
npm pack --dry-run
|
|
110
|
+
npm run check # typecheck, tests, build
|
|
111
|
+
npm pack --dry-run # dist/, src/, docs/, CHANGELOG.md, README.md, LICENSE, package.json
|
|
112
|
+
node scripts/check-tarball.mjs # builds, packs, and checks the tarball as npm installs it
|
|
105
113
|
```
|
|
106
114
|
|
|
107
115
|
`files` in package.json publishes all of `dist/`, `src/` and `docs/`. CONTRIBUTING.md,
|
|
108
|
-
`examples/` and `test/` are not published.
|
|
116
|
+
`examples/`, `scripts/` and `test/` are not published. `check-tarball.mjs` is what the release
|
|
117
|
+
workflow runs on the tarball it publishes ([below](#what-the-release-workflow-does)); it
|
|
118
|
+
installs into temporary projects from the npm registry, so it needs the network.
|
|
109
119
|
|
|
110
120
|
4. Commit, push, and open a pull request titled "Release 0.6.0: what the version is about". Wait
|
|
111
|
-
for CI (Node
|
|
121
|
+
for CI (the tests on Node 22, 24 and 26, on Ubuntu and Windows; the tarball check on Node 22
|
|
122
|
+
and 26; the coverage report), then squash-merge it.
|
|
112
123
|
|
|
113
124
|
5. Tag the merged commit and push the tag:
|
|
114
125
|
|
|
@@ -132,7 +143,9 @@ Pushing the tag starts the release workflow.
|
|
|
132
143
|
gh run watch <run-id>
|
|
133
144
|
```
|
|
134
145
|
|
|
135
|
-
If its
|
|
146
|
+
If its build job fails, nothing was staged: see the end of
|
|
147
|
+
[What the release workflow does](#what-the-release-workflow-does). If its publish job fails, see
|
|
148
|
+
[When the publish job fails](#when-the-publish-job-fails).
|
|
136
149
|
|
|
137
150
|
7. Approve the staged version. The workflow stages it (`npm stage publish`): it is uploaded with
|
|
138
151
|
its provenance, but not installable yet. Open npmjs.com → your account → **Staged Packages**,
|
|
@@ -159,21 +172,64 @@ Pushing the tag starts the release workflow.
|
|
|
159
172
|
|
|
160
173
|
## What the release workflow does
|
|
161
174
|
|
|
162
|
-
`.github/workflows/release.yml` runs when a tag that starts with `v` is pushed. It
|
|
163
|
-
with Node 24 and no dependency cache (a poisoned cache
|
|
164
|
-
|
|
175
|
+
`.github/workflows/release.yml` runs when a tag that starts with `v` is pushed. It has two jobs, on
|
|
176
|
+
Ubuntu with Node 24 and no dependency cache (a poisoned cache would run its code in the job). The
|
|
177
|
+
actions it uses are pinned by the commit of their release, as in `ci.yml`, which says how to update
|
|
178
|
+
them.
|
|
179
|
+
|
|
180
|
+
**The build job** has `contents: read` and no identity token: the tests and the dependencies run in
|
|
181
|
+
a job that cannot ask npm for a token. Its steps:
|
|
165
182
|
|
|
166
183
|
| Step | Fails when |
|
|
167
184
|
| --- | --- |
|
|
168
|
-
| `npm ci` | package-lock.json does not match package.json. |
|
|
185
|
+
| `npm ci --ignore-scripts` | package-lock.json does not match package.json. No install script runs: nothing in the tree needs one (esbuild, under Vitest, finds its binary without its `postinstall`). |
|
|
169
186
|
| Check the tag matches package.json | The tag is not `v` + the `version` in package.json: for example `v0.6.0` on a commit whose package.json still says 0.5.0. |
|
|
170
187
|
| `npm run check` | The typecheck, a test or the build fails. |
|
|
188
|
+
| Pack | `npm pack` fails. The step prints the tarball's `npm shasum`, `npm integrity` and SHA-256: npm shows the first two for the version once it is published. |
|
|
189
|
+
| Check the tarball as npm installs it | `node scripts/check-tarball.mjs` on that tarball finds a fault (below). |
|
|
190
|
+
| Upload the tarball | It is kept as the artifact `package` of the run, for 7 days. |
|
|
191
|
+
|
|
192
|
+
`scripts/check-tarball.mjs` checks the tarball itself, not the checkout:
|
|
193
|
+
|
|
194
|
+
- the files in it: only those of `files` in package.json, and every file that `exports`, `main`,
|
|
195
|
+
`types` and `typesVersions` name is there;
|
|
196
|
+
- installed into a new project without the optional peers: `import` and `require()` of every
|
|
197
|
+
subpath of `exports`, `./testing` included, give the same module, and a PDF is refused with the
|
|
198
|
+
message that names `unpdf`;
|
|
199
|
+
- `llm-large-files/node/ingest-child.js` resolves, and a text file is ingested in a child process
|
|
200
|
+
of `createIsolatedExtractors`;
|
|
201
|
+
- a consumer compiles with the checkout's TypeScript under `moduleResolution` NodeNext (an ES module
|
|
202
|
+
and a CommonJS one), Bundler and Node10, with `skipLibCheck: false`;
|
|
203
|
+
- installed with `unpdf`, `jszip` and `@cantoo/pdf-lib` at the versions of package-lock.json, a PDF
|
|
204
|
+
and a DOCX are read, in the process and in a child process;
|
|
205
|
+
- `publint` and `@arethetypeswrong/cli` (`attw`) pass, at the versions pinned in the script. `attw`
|
|
206
|
+
ignores `cjs-resolves-to-esm` (the package is ESM, and `require()` of it works from Node 22.12)
|
|
207
|
+
and does not check `./node/ingest-child.js` (a script that child processes run, not a module to
|
|
208
|
+
import).
|
|
209
|
+
|
|
210
|
+
CI's `package` job runs the same script on Node 22.12.0 (the floor of `engines`), the newest 22,
|
|
211
|
+
and 26 for every pull request.
|
|
212
|
+
|
|
213
|
+
**The publish job** runs after the build job passed. It has `contents: read` and `id-token: write`,
|
|
214
|
+
and does not check out the repository or install anything: no code of the package or of its
|
|
215
|
+
dependencies runs where the identity token is. Its steps:
|
|
216
|
+
|
|
217
|
+
| Step | Fails when |
|
|
218
|
+
| --- | --- |
|
|
219
|
+
| Download the tarball | The artifact `package` of this run is missing, or its digest does not match what was uploaded. |
|
|
220
|
+
| Check the tarball is the one the build job checked | Its SHA-256 is not the one the build job computed. |
|
|
221
|
+
| Check this npm can stage | The npm of Node 24 is older than 11.15.0, which has no `npm stage`. |
|
|
171
222
|
| Check that this job can identify itself to npm | The job has no identity token: "No identity token for this job. The workflow needs the id-token write permission." |
|
|
172
|
-
| `npm stage publish --provenance --access public --loglevel verbose` | npm does not accept the job's identity for this package, or the trusted publisher does not allow staging (see below). The version is staged, not public, until a maintainer approves it. |
|
|
223
|
+
| `npm stage publish ./release/llm-large-files-<version>.tgz --provenance --access public --loglevel verbose` | npm does not accept the job's identity for this package, or the trusted publisher does not allow staging (see below). The version is staged, not public, until a maintainer approves it. |
|
|
224
|
+
|
|
225
|
+
`npm stage publish` takes a package spec as `npm publish` does, a tarball included (`npm help
|
|
226
|
+
stage`; it shares the code of `npm publish`). Given a tarball, npm stages those bytes as they are,
|
|
227
|
+
and runs no script of the package: `prepublishOnly` runs only when npm publishes a folder. So the
|
|
228
|
+
version on npm is the tarball that the build job checked, byte for byte. The path starts with `./`:
|
|
229
|
+
without it npm reads `release/llm-large-files-0.6.0.tgz` as a GitHub repository.
|
|
173
230
|
|
|
174
|
-
When
|
|
175
|
-
|
|
176
|
-
the fixed commit.
|
|
231
|
+
When the build job fails, nothing was staged. Fix the cause on `main` with a pull request, delete
|
|
232
|
+
the tag (`git tag -d v0.6.0`, then `git push origin :refs/tags/v0.6.0`), and tag the fixed commit.
|
|
177
233
|
|
|
178
234
|
### Trusted publishing
|
|
179
235
|
|
|
@@ -202,7 +258,10 @@ that built it. npm can make one only inside a supported CI job, so a version pub
|
|
|
202
258
|
none. npm checks the trusted publisher only at publish time, and says why it refused an identity
|
|
203
259
|
only in the verbose log: that is why the step runs with `--loglevel verbose`.
|
|
204
260
|
|
|
205
|
-
## When the publish
|
|
261
|
+
## When the publish job fails
|
|
262
|
+
|
|
263
|
+
The build job passed, so the tagged commit is good and the checked tarball is kept as the artifact
|
|
264
|
+
`package` of the run, for 7 days. Find why npm refused in the verbose log of the publish step.
|
|
206
265
|
|
|
207
266
|
**`403 Forbidden … OIDC permission denied for this action`.** npm accepted the job's identity
|
|
208
267
|
(`npm verbose oidc Successfully retrieved and set token`) but the trusted publisher does not allow
|
|
@@ -221,41 +280,57 @@ npm error 404 Not Found - PUT https://registry.npmjs.org/llm-large-files - Not f
|
|
|
221
280
|
```
|
|
222
281
|
|
|
223
282
|
npm did not accept the job's identity for this package: the trusted publisher on npmjs.com is
|
|
224
|
-
missing, or does not match the values above.
|
|
225
|
-
commit is good. There are two ways to finish the release.
|
|
283
|
+
missing, or does not match the values above. There are two ways to finish the release.
|
|
226
284
|
|
|
227
|
-
**Fix trusted publishing, then run the job again.** Correct the setting on npmjs.com (this
|
|
228
|
-
npm account that may publish the package), then `gh run rerun <run-id> --failed`.
|
|
229
|
-
|
|
285
|
+
**Fix trusted publishing, then run the publish job again.** Correct the setting on npmjs.com (this
|
|
286
|
+
needs an npm account that may publish the package), then `gh run rerun <run-id> --failed`. Only the
|
|
287
|
+
failed job runs again: it stages the same tarball, from the artifact, with provenance. This works
|
|
288
|
+
while the artifact is kept and the version is not on npm yet. After 7 days, run the whole workflow
|
|
289
|
+
again (`gh run rerun <run-id>`): its build job builds and checks a new tarball of the same commit.
|
|
230
290
|
|
|
231
|
-
**Publish by hand
|
|
291
|
+
**Publish by hand the tarball the build job checked:**
|
|
232
292
|
|
|
233
293
|
```bash
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
npm ci
|
|
294
|
+
gh run download <run-id> --name package --dir release-v0.6.0
|
|
295
|
+
sha256sum release-v0.6.0/llm-large-files-0.6.0.tgz # the SHA-256 the Pack step printed
|
|
237
296
|
npm whoami # an npm account that may publish the package; run npm login if not
|
|
238
|
-
npm publish --access public
|
|
297
|
+
npm publish ./release-v0.6.0/llm-large-files-0.6.0.tgz --access public
|
|
239
298
|
```
|
|
240
299
|
|
|
241
|
-
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
- `prepublishOnly` runs `npm run check` first; its build deletes `dist/` and builds it again.
|
|
300
|
+
- The tarball is the one the build job checked, so nothing is built again: npm runs no script of
|
|
301
|
+
the package when it publishes a tarball. Keep the `./`: npm reads `release-v0.6.0/…` as a GitHub
|
|
302
|
+
repository without it.
|
|
245
303
|
- npm asks for the account's two-factor approval: it prints
|
|
246
304
|
`Authenticate your account at: https://www.npmjs.com/auth/cli/…` (or asks for a one-time code).
|
|
247
305
|
Open the link, on any device, and approve. npm waits only a few minutes (about five in past
|
|
248
306
|
releases) and then gives up, so the person who approves must be there before you run it.
|
|
249
307
|
- Leave out `--provenance`: it works only inside a supported CI job.
|
|
250
|
-
- Before it publishes, npm prints `npm notice shasum:` for the package. The
|
|
251
|
-
the same
|
|
252
|
-
matched.
|
|
308
|
+
- Before it publishes, npm prints `npm notice shasum:` for the package. The Pack step of the build
|
|
309
|
+
job printed the same `npm shasum:`. When the two match, npm got the tarball that CI checked. (For
|
|
310
|
+
0.5.0, published by hand from a checkout, the shasum matched that of the failed job.)
|
|
311
|
+
|
|
312
|
+
When the artifact is gone (after 7 days), publish from a clean checkout of the tag, and check its
|
|
313
|
+
tarball first:
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
git clone --depth 1 --branch v0.6.0 https://github.com/renanbazinin/llm-large-files.git release-v0.6.0
|
|
317
|
+
cd release-v0.6.0
|
|
318
|
+
npm ci --ignore-scripts
|
|
319
|
+
npm run check
|
|
320
|
+
npm pack
|
|
321
|
+
node scripts/check-tarball.mjs llm-large-files-0.6.0.tgz
|
|
322
|
+
npm publish ./llm-large-files-0.6.0.tgz --access public
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Use a clean checkout, not your working copy. `files` publishes everything under `dist/`, `src/` and
|
|
326
|
+
`docs/`, so an untracked or changed file there would go to npm too. The checkout also makes sure the
|
|
327
|
+
version is exactly the tag's.
|
|
253
328
|
|
|
254
329
|
## Checking a release
|
|
255
330
|
|
|
256
331
|
```bash
|
|
257
332
|
npm view llm-large-files version # the latest version
|
|
258
|
-
npm view llm-large-files@0.6.0 dist.shasum
|
|
333
|
+
npm view llm-large-files@0.6.0 dist.shasum # the npm shasum the Pack step of the build job printed
|
|
259
334
|
```
|
|
260
335
|
|
|
261
336
|
After npm prints `+ llm-large-files@0.6.0`, the registry can take several minutes to list the
|
|
@@ -293,8 +368,9 @@ Versions follow [semantic versioning](https://semver.org). While the version is
|
|
|
293
368
|
|
|
294
369
|
These are public, and a change to them can need a change in someone's code:
|
|
295
370
|
|
|
296
|
-
- Everything exported from the
|
|
297
|
-
`llm-large-files/openai`, `llm-large-files/anthropic`, `llm-large-files/node
|
|
371
|
+
- Everything exported from the six entry points (`llm-large-files`, `llm-large-files/gemini`,
|
|
372
|
+
`llm-large-files/openai`, `llm-large-files/anthropic`, `llm-large-files/node`,
|
|
373
|
+
`llm-large-files/testing`): names,
|
|
298
374
|
signatures, options and their defaults. That includes the types an app implements:
|
|
299
375
|
`ModelAdapter`, `DocumentStore` and `Extractor`. A new required member or argument breaks every
|
|
300
376
|
adapter, store or extractor written for the previous version, so make new members optional.
|
|
@@ -305,5 +381,5 @@ These are public, and a change to them can need a change in someone's code:
|
|
|
305
381
|
- The routes, requests, responses and statuses of the HTTP handlers in `llm-large-files/node`.
|
|
306
382
|
- What a store already holds: a new version reads documents an older one stored. (0.4.0 gave
|
|
307
383
|
documents stored by older versions their line index the first time they were used.)
|
|
308
|
-
- The supported Node versions (`engines`:
|
|
384
|
+
- The supported Node versions (`engines`: 22.12 or later) and the version ranges of the optional
|
|
309
385
|
peers `jszip`, `unpdf` and `@cantoo/pdf-lib`.
|