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.
Files changed (204) hide show
  1. package/CHANGELOG.md +631 -0
  2. package/README.md +9 -10
  3. package/dist/access.d.ts +86 -0
  4. package/dist/access.d.ts.map +1 -0
  5. package/dist/access.js +131 -0
  6. package/dist/access.js.map +1 -0
  7. package/dist/ask.d.ts +45 -1
  8. package/dist/ask.d.ts.map +1 -1
  9. package/dist/ask.js +181 -20
  10. package/dist/ask.js.map +1 -1
  11. package/dist/cache.d.ts +12 -3
  12. package/dist/cache.d.ts.map +1 -1
  13. package/dist/cache.js +18 -5
  14. package/dist/cache.js.map +1 -1
  15. package/dist/encoding.js +5 -3
  16. package/dist/encoding.js.map +1 -1
  17. package/dist/error-info.d.ts +57 -0
  18. package/dist/error-info.d.ts.map +1 -0
  19. package/dist/error-info.js +217 -0
  20. package/dist/error-info.js.map +1 -0
  21. package/dist/errors.d.ts +72 -8
  22. package/dist/errors.d.ts.map +1 -1
  23. package/dist/errors.js +102 -15
  24. package/dist/errors.js.map +1 -1
  25. package/dist/events.d.ts +35 -9
  26. package/dist/events.d.ts.map +1 -1
  27. package/dist/events.js +42 -11
  28. package/dist/events.js.map +1 -1
  29. package/dist/evidence.d.ts +4 -2
  30. package/dist/evidence.d.ts.map +1 -1
  31. package/dist/evidence.js +14 -3
  32. package/dist/evidence.js.map +1 -1
  33. package/dist/extract.d.ts +32 -8
  34. package/dist/extract.d.ts.map +1 -1
  35. package/dist/extract.js +46 -35
  36. package/dist/extract.js.map +1 -1
  37. package/dist/gemini/adapter.d.ts +19 -3
  38. package/dist/gemini/adapter.d.ts.map +1 -1
  39. package/dist/gemini/adapter.js +84 -12
  40. package/dist/gemini/adapter.js.map +1 -1
  41. package/dist/gemini/chat.d.ts +18 -6
  42. package/dist/gemini/chat.d.ts.map +1 -1
  43. package/dist/gemini/chat.js +2 -0
  44. package/dist/gemini/chat.js.map +1 -1
  45. package/dist/gemini/index.d.ts +1 -1
  46. package/dist/gemini/index.d.ts.map +1 -1
  47. package/dist/index.d.ts +9 -6
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +4 -3
  50. package/dist/index.js.map +1 -1
  51. package/dist/ingest.d.ts +70 -0
  52. package/dist/ingest.d.ts.map +1 -0
  53. package/dist/ingest.js +868 -0
  54. package/dist/ingest.js.map +1 -0
  55. package/dist/library.d.ts +176 -34
  56. package/dist/library.d.ts.map +1 -1
  57. package/dist/library.js +332 -512
  58. package/dist/library.js.map +1 -1
  59. package/dist/limiter.d.ts +2 -2
  60. package/dist/limiter.js +2 -2
  61. package/dist/map-reduce.js +3 -3
  62. package/dist/map-reduce.js.map +1 -1
  63. package/dist/model.d.ts +43 -2
  64. package/dist/model.d.ts.map +1 -1
  65. package/dist/model.js +63 -3
  66. package/dist/model.js.map +1 -1
  67. package/dist/node/handlers.d.ts +234 -7
  68. package/dist/node/handlers.d.ts.map +1 -1
  69. package/dist/node/handlers.js +482 -121
  70. package/dist/node/handlers.js.map +1 -1
  71. package/dist/node/index.d.ts +3 -2
  72. package/dist/node/index.d.ts.map +1 -1
  73. package/dist/node/index.js +2 -1
  74. package/dist/node/index.js.map +1 -1
  75. package/dist/node/ingest-child.d.ts +7 -1
  76. package/dist/node/ingest-child.d.ts.map +1 -1
  77. package/dist/node/ingest-child.js +18 -3
  78. package/dist/node/ingest-child.js.map +1 -1
  79. package/dist/node/isolated.d.ts +3 -1
  80. package/dist/node/isolated.d.ts.map +1 -1
  81. package/dist/node/isolated.js +11 -4
  82. package/dist/node/isolated.js.map +1 -1
  83. package/dist/node/originals.d.ts +19 -0
  84. package/dist/node/originals.d.ts.map +1 -0
  85. package/dist/node/originals.js +82 -0
  86. package/dist/node/originals.js.map +1 -0
  87. package/dist/node/spool.d.ts +102 -0
  88. package/dist/node/spool.d.ts.map +1 -0
  89. package/dist/node/spool.js +365 -0
  90. package/dist/node/spool.js.map +1 -0
  91. package/dist/node/sse.d.ts +4 -3
  92. package/dist/node/sse.d.ts.map +1 -1
  93. package/dist/node/sse.js +7 -6
  94. package/dist/node/sse.js.map +1 -1
  95. package/dist/pdf-layout.d.ts.map +1 -1
  96. package/dist/pdf-layout.js +71 -12
  97. package/dist/pdf-layout.js.map +1 -1
  98. package/dist/ranged.d.ts +22 -11
  99. package/dist/ranged.d.ts.map +1 -1
  100. package/dist/ranged.js +50 -12
  101. package/dist/ranged.js.map +1 -1
  102. package/dist/retry.d.ts +3 -1
  103. package/dist/retry.d.ts.map +1 -1
  104. package/dist/retry.js +6 -2
  105. package/dist/retry.js.map +1 -1
  106. package/dist/scope.d.ts +25 -0
  107. package/dist/scope.d.ts.map +1 -0
  108. package/dist/scope.js +60 -0
  109. package/dist/scope.js.map +1 -0
  110. package/dist/source.d.ts +60 -0
  111. package/dist/source.d.ts.map +1 -0
  112. package/dist/source.js +170 -0
  113. package/dist/source.js.map +1 -0
  114. package/dist/stores.d.ts +120 -31
  115. package/dist/stores.d.ts.map +1 -1
  116. package/dist/stores.js +582 -139
  117. package/dist/stores.js.map +1 -1
  118. package/dist/testing/fake-fetch.d.ts +31 -0
  119. package/dist/testing/fake-fetch.d.ts.map +1 -0
  120. package/dist/testing/fake-fetch.js +66 -0
  121. package/dist/testing/fake-fetch.js.map +1 -0
  122. package/dist/testing/fake-model.d.ts +38 -0
  123. package/dist/testing/fake-model.d.ts.map +1 -0
  124. package/dist/testing/fake-model.js +62 -0
  125. package/dist/testing/fake-model.js.map +1 -0
  126. package/dist/testing/index.d.ts +7 -0
  127. package/dist/testing/index.d.ts.map +1 -0
  128. package/dist/testing/index.js +9 -0
  129. package/dist/testing/index.js.map +1 -0
  130. package/dist/testing/store-checks.d.ts +72 -0
  131. package/dist/testing/store-checks.d.ts.map +1 -0
  132. package/dist/testing/store-checks.js +619 -0
  133. package/dist/testing/store-checks.js.map +1 -0
  134. package/dist/tools.d.ts +25 -0
  135. package/dist/tools.d.ts.map +1 -1
  136. package/dist/tools.js +135 -13
  137. package/dist/tools.js.map +1 -1
  138. package/dist/types.d.ts +116 -13
  139. package/dist/types.d.ts.map +1 -1
  140. package/docs/README.md +17 -8
  141. package/docs/getting-started.md +18 -13
  142. package/docs/guides/anthropic.md +12 -8
  143. package/docs/guides/conversations.md +112 -47
  144. package/docs/guides/costs-and-limits.md +16 -7
  145. package/docs/guides/deployment.md +309 -87
  146. package/docs/guides/errors-and-reliability.md +161 -23
  147. package/docs/guides/own-adapter-and-loop.md +27 -10
  148. package/docs/guides/pdfs.md +123 -29
  149. package/docs/guides/storage.md +634 -143
  150. package/docs/guides/testing.md +78 -129
  151. package/docs/guides/vertex-and-gemini.md +10 -7
  152. package/docs/guides/web-app.md +322 -77
  153. package/docs/how-it-works.md +35 -8
  154. package/docs/measurements.md +63 -8
  155. package/docs/publishing.md +112 -36
  156. package/docs/reference/ask.md +154 -13
  157. package/docs/reference/errors-and-retries.md +166 -14
  158. package/docs/reference/events.md +53 -20
  159. package/docs/reference/gemini.md +70 -21
  160. package/docs/reference/library.md +709 -165
  161. package/docs/reference/node.md +633 -104
  162. package/docs/reference/testing.md +311 -0
  163. package/docs/reference/tools.md +15 -5
  164. package/docs/security.md +316 -70
  165. package/docs/troubleshooting.md +165 -58
  166. package/docs/upgrading-0.9.md +890 -0
  167. package/package.json +12 -3
  168. package/src/access.ts +144 -0
  169. package/src/ask.ts +230 -19
  170. package/src/cache.ts +20 -5
  171. package/src/encoding.ts +6 -4
  172. package/src/error-info.ts +255 -0
  173. package/src/errors.ts +129 -15
  174. package/src/events.ts +86 -21
  175. package/src/evidence.ts +14 -3
  176. package/src/extract.ts +50 -33
  177. package/src/gemini/adapter.ts +97 -11
  178. package/src/gemini/chat.ts +20 -6
  179. package/src/gemini/index.ts +1 -1
  180. package/src/index.ts +9 -6
  181. package/src/ingest.ts +927 -0
  182. package/src/library.ts +482 -523
  183. package/src/limiter.ts +2 -2
  184. package/src/map-reduce.ts +3 -3
  185. package/src/model.ts +69 -5
  186. package/src/node/handlers.ts +691 -117
  187. package/src/node/index.ts +13 -2
  188. package/src/node/ingest-child.ts +23 -5
  189. package/src/node/isolated.ts +11 -4
  190. package/src/node/originals.ts +78 -0
  191. package/src/node/spool.ts +365 -0
  192. package/src/node/sse.ts +7 -6
  193. package/src/pdf-layout.ts +69 -11
  194. package/src/ranged.ts +42 -14
  195. package/src/retry.ts +6 -2
  196. package/src/scope.ts +63 -0
  197. package/src/source.ts +178 -0
  198. package/src/stores.ts +635 -140
  199. package/src/testing/fake-fetch.ts +80 -0
  200. package/src/testing/fake-model.ts +78 -0
  201. package/src/testing/index.ts +11 -0
  202. package/src/testing/store-checks.ts +660 -0
  203. package/src/tools.ts +150 -14
  204. package/src/types.ts +106 -13
package/src/events.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  // What a question or an ingest does while it runs, as typed data in order. The callbacks of
2
2
  // earlier versions (onText, onActivity, onStep) still get the same strings, at the same moments.
3
3
  import type { AskResult } from "./ask.js";
4
- import { DocumentStoreError, IngestError, type IngestErrorCode } from "./errors.js";
4
+ import { DocumentScopeError, DocumentStoreError, IngestError, isErrorCode, type DocumentScopeErrorCode, type IngestErrorCode } from "./errors.js";
5
5
  import type { Evidence } from "./evidence.js";
6
6
  import { modelFailureReason } from "./map-reduce.js";
7
- import type { ModelErrorKind, ModelReply, ModelUsage, ToolTurn } from "./model.js";
7
+ import { classifyModelError, DocumentsNotFoundError, isModelStatus, type ModelErrorKind, type ModelReply, type ModelUsage, type ToolTurn } from "./model.js";
8
8
  import type { DocumentFormat, DocumentMeta, DocumentSummary, ToolResult } from "./types.js";
9
9
 
10
10
  /** What every event carries. */
@@ -35,7 +35,10 @@ export type EventError = {
35
35
  * code only.
36
36
  */
37
37
  message: string;
38
- /** For a model error: what kind it is (`errorKindOf`). */
38
+ /**
39
+ * For a model error: what kind it is (`errorKindOf`). Since 0.9.0 also for an error with a status
40
+ * (0, or 400 and more) and no kind of its own: the kind its status gives (`classifyModelError`).
41
+ */
39
42
  kind?: ModelErrorKind;
40
43
  /** For an HTTP error: its status. 0 when no answer came. */
41
44
  status?: number;
@@ -43,9 +46,11 @@ export type EventError = {
43
46
  name?: string;
44
47
  /**
45
48
  * For a file `ingest` could not read: why, as `IngestError.code` ("too_large", "no_text",
46
- * "busy"…), so a page can say it in its own words. New in 0.8.0.
49
+ * "busy"…), so a page can say it in its own words. New in 0.8.0. Since 0.9.0 also the code of a
50
+ * scope that cannot be used (`DocumentScopeError`, `name` "DocumentScopeError"): "scope_missing"
51
+ * when the chat was deleted.
47
52
  */
48
- code?: IngestErrorCode;
53
+ code?: IngestErrorCode | DocumentScopeErrorCode;
49
54
  };
50
55
 
51
56
  /**
@@ -93,7 +98,15 @@ export type ToolOutcome = "ok" | "error" | "refused" | "already_shown" | "not_ru
93
98
  * - "calls_not_run": a turn had more calls than `limits.callsPerTurn`;
94
99
  * - "budget_reached": `limits.inputTokens` or `limits.requests` was reached, so no more tools run;
95
100
  * - "no_room": there is no room left in the conversation for another tool result;
96
- * - "blocked": the provider refused the prompt (`AskResult.blockReason`).
101
+ * - "blocked": the provider refused the prompt (`AskResult.blockReason`);
102
+ * - "documents_missing": documents of `documentIds` were missing, and the question is answered
103
+ * without them (`AskOptions.onMissingDocuments` "drop"; `AskResult.missing`). New in 0.9.0;
104
+ * - "document_gone": a tool call found a document gone during the question (deleted or expired
105
+ * since it was planned). The model was told so in the call's result. New in 0.9.0;
106
+ * - "page_looks_busy": a look at pages waited its turn (`maxConcurrentPageLooks`) longer than
107
+ * `pageLookWaitMs`, and was not run. The model was told so in the call's result. New in 0.9.0.
108
+ *
109
+ * A switch over every code must handle the codes added in a later version.
97
110
  */
98
111
  export type NoticeCode =
99
112
  | "searching_instead"
@@ -106,7 +119,10 @@ export type NoticeCode =
106
119
  | "calls_not_run"
107
120
  | "budget_reached"
108
121
  | "no_room"
109
- | "blocked";
122
+ | "blocked"
123
+ | "documents_missing"
124
+ | "document_gone"
125
+ | "page_looks_busy";
110
126
 
111
127
  /**
112
128
  * Where a notice went in the callbacks of earlier versions: "activity" to `onActivity`, "step" to
@@ -125,8 +141,9 @@ export type EventResult = Omit<AskResult, "toolTurns" | "plan"> & {
125
141
  toolTurns?: ToolTurn[];
126
142
  /**
127
143
  * Which documents went in whole and which were searched, named as `DocumentRef`s: their full
128
- * `DocumentMeta` (owner, outline headings, the commonest lines of a log) is left out unless
129
- * `eventResults` is true. The returned result has the full plan.
144
+ * `DocumentMeta` (owner, scope, the SHA-256 and the ref of the original, outline headings, the
145
+ * commonest lines of a log) is left out unless `eventResults` is true. The returned result has
146
+ * the full plan.
130
147
  */
131
148
  plan: { inline: Array<DocumentRef | DocumentMeta>; searchable: Array<DocumentRef | DocumentMeta> };
132
149
  };
@@ -252,7 +269,17 @@ export type AskEvent =
252
269
  /** The result itself. Only with `AskOptions.eventResults: true`: it holds document text. */
253
270
  result?: ToolResult;
254
271
  })
255
- | (EventBase & { type: "notice"; code: NoticeCode; message: string; display: NoticeDisplay })
272
+ | (EventBase & {
273
+ type: "notice";
274
+ code: NoticeCode;
275
+ message: string;
276
+ display: NoticeDisplay;
277
+ /**
278
+ * The documents the notice is about: those left out ("documents_missing"), the one found gone
279
+ * ("document_gone"), the one whose pages were not looked at ("page_looks_busy"). New in 0.9.0.
280
+ */
281
+ documentIds?: string[];
282
+ })
256
283
  /** Always last when the question returns. Nothing comes after it. */
257
284
  | (EventBase & { type: "run.finish"; result: EventResult })
258
285
  /**
@@ -280,7 +307,15 @@ export type IngestEvent =
280
307
  unit: "pages" | "parts" | "bytes" | "characters";
281
308
  })
282
309
  /** Always last when the ingest stores the document. */
283
- | (EventBase & { type: "ingest.finish"; document: DocumentSummary })
310
+ | (EventBase & {
311
+ type: "ingest.finish";
312
+ document: DocumentSummary;
313
+ /**
314
+ * What the upload handler's `onUploaded` returned as `answer`, for the page: only in the
315
+ * event the handler sends, never in the events of `files.ingest`. New in 0.9.0.
316
+ */
317
+ app?: Record<string, unknown>;
318
+ })
284
319
  /** Always last when the ingest throws (a refusal or an abort included). */
285
320
  | (EventBase & { type: "ingest.error"; error: EventError });
286
321
 
@@ -303,15 +338,32 @@ export function newRunId(prefix = "run"): string {
303
338
  export function eventErrorOf(error: unknown, message?: string): EventError {
304
339
  // It never throws: an error whose fields throw when read (a getter, a proxy) is told plainly.
305
340
  try {
306
- const record = (typeof error === "object" && error !== null ? error : {}) as { kind?: unknown; status?: unknown; name?: unknown };
307
- if (error instanceof IngestError) {
308
- // Its status is the upload's answer, not a model's.
309
- return { message: message ?? error.message, name: error.name, code: error.code, ...(error.code === "busy" || error.code === "too_large" ? { status: error.status } : {}) };
341
+ const record = (typeof error === "object" && error !== null ? error : {}) as { kind?: unknown; status?: unknown; name?: unknown; code?: unknown };
342
+ if (IngestError.is(error)) {
343
+ // Its status is the upload's answer, not a model's. A subclass of a name of its own (an
344
+ // extractor's) is told by the name errorInfoOf reads, as a store's own DocumentStoreError is.
345
+ return { message: message ?? error.message, name: "IngestError", code: error.code, ...(error.status !== 422 ? { status: error.status } : {}) };
346
+ }
347
+ // Its code tells a deleted chat from a scope the server gave wrong (errorInfoOf).
348
+ if (DocumentScopeError.is(error)) {
349
+ return { message: message ?? userMessageOf(error), name: "DocumentScopeError", ...(typeof error.code === "string" ? { code: error.code } : {}) };
310
350
  }
311
351
  const out: EventError = { message: message ?? userMessageOf(error) };
352
+ const own = DocumentStoreError.is(error) ? "DocumentStoreError" : DocumentsNotFoundError.is(error) ? "DocumentsNotFoundError" : undefined;
312
353
  if (typeof record.kind === "string") out.kind = record.kind as ModelErrorKind;
354
+ else if (isModelStatus(record.status) && own === undefined && !isPlainData(record)) {
355
+ // A model's error without a kind of its own (an adapter of yours, `httpError`): the kind its
356
+ // status gives, as its message is told, so that a model's EventError always has its kind.
357
+ // Plain data thrown is not an adapter's error, as errorInfoOf reads it. The message is read
358
+ // from any class, an Error or not (an SDK's own), as errorInfoOf and the loop read it.
359
+ const { code, message: text } = record as { code?: unknown; message?: unknown };
360
+ out.kind = classifyModelError(record.status, typeof text === "string" ? text : "", { code: typeof code === "string" ? code : undefined }).kind;
361
+ }
313
362
  if (typeof record.status === "number") out.status = record.status;
314
- if (typeof record.name === "string" && record.name) out.name = record.name;
363
+ // A store's own subclass of DocumentStoreError, of a name of its own, is told by the name
364
+ // errorInfoOf reads, as the upload handlers tell it.
365
+ if (own !== undefined) out.name = own;
366
+ else if (typeof record.name === "string" && record.name) out.name = record.name;
315
367
  return out;
316
368
  } catch {
317
369
  return { message: message ?? SOMETHING_WENT_WRONG };
@@ -320,19 +372,32 @@ export function eventErrorOf(error: unknown, message?: string): EventError {
320
372
 
321
373
  const SOMETHING_WENT_WRONG = "Something went wrong.";
322
374
 
375
+ /** Data, not an error: an object of no class, as an `EventError` is, or one parsed from JSON. */
376
+ export function isPlainData(value: object): boolean {
377
+ const proto: unknown = Object.getPrototypeOf(value);
378
+ return proto === Object.prototype || proto === null;
379
+ }
380
+
323
381
  /**
324
382
  * A message for users: a model error by its kind and status, a storage error by its code, the
325
383
  * library's own errors (refusals, a stop) as they are written, and anything that is not an
326
384
  * `Error` as "Something went wrong."
327
385
  */
328
386
  function userMessageOf(error: unknown): string {
329
- if (error instanceof DocumentStoreError) return error.message;
387
+ // The library's own errors with a status (503, 404) are not model errors: their words are safe.
388
+ if (DocumentStoreError.is(error) || DocumentsNotFoundError.is(error)) return (error as Error).message;
330
389
  if (typeof error !== "object" || error === null) return SOMETHING_WENT_WRONG;
331
390
  const record = error as { kind?: unknown; status?: unknown; code?: unknown; syscall?: unknown; message?: unknown };
332
- // A model error: the provider's words stay on the error.
333
- if (typeof record.kind === "string" || typeof record.status === "number") return modelFailureReason(error);
334
- // A system error (ENOENT, EACCES…): its message names paths of the server.
335
- if (typeof record.code === "string" && typeof record.syscall === "string") return `The file could not be read from storage (${record.code}).`;
391
+ // A model error, as eventErrorOf gives it a kind: the provider's words stay on the error.
392
+ if (typeof record.kind === "string" || (isModelStatus(record.status) && !isPlainData(record))) return modelFailureReason(error);
393
+ // Any other status (thrown plain data, a status no model answers with) is not a model's, and the
394
+ // words that came with it may be anyone's: errorInfoOf tells it so too.
395
+ if (typeof record.status === "number") return SOMETHING_WENT_WRONG;
396
+ // A system error (ENOENT, EACCES…): its message names paths of the server. Its code is told only
397
+ // when it reads as one: a driver may put a host in it.
398
+ if (typeof record.code === "string" && typeof record.syscall === "string") {
399
+ return `The file could not be read from storage${isErrorCode(record.code) ? ` (${record.code})` : ""}.`;
400
+ }
336
401
  if (!(error instanceof Error) && !(typeof DOMException !== "undefined" && error instanceof DOMException)) return SOMETHING_WENT_WRONG;
337
402
  return typeof record.message === "string" && record.message ? record.message : SOMETHING_WENT_WRONG;
338
403
  }
package/src/evidence.ts CHANGED
@@ -124,12 +124,23 @@ const rangeText = ([from, to]: NumberRange) => (to > from ? `${from}-${to}` : St
124
124
  * A short stand-in for a tool result that is dropped from the request to make room: it keeps
125
125
  * which document it was about and which lines or pages it showed, so the model can read them
126
126
  * again, and says that it is a stand-in. Undefined when there is nothing to gain: the result is an
127
- * error, is small already, or is such a stand-in. `hadFiles` is true for a result whose files
128
- * (pages) are dropped with it, however small its JSON is.
127
+ * error, is small already, is such a stand-in, or is no larger than its stand-in would be (a search
128
+ * counted by group, or an `aggregate_table` result, of a few short groups: the stand-in keeps the
129
+ * groups and adds a note; since 0.9.0). `hadFiles` is true for a result whose files (pages) are
130
+ * dropped with it, however small its JSON is: its stand-in is always given.
129
131
  */
130
132
  export function stubResult(call: ToolCall, result: ToolResult, hadFiles = false): ToolResult | undefined {
131
133
  if (typeof result.error === "string" || result.dropped === true) return undefined;
132
- if (!hadFiles && JSON.stringify(result).length < SMALL_RESULT_CHARACTERS) return undefined;
134
+ if (hadFiles) return standIn(call, result);
135
+ const size = JSON.stringify(result).length;
136
+ if (size < SMALL_RESULT_CHARACTERS) return undefined;
137
+ const stub = standIn(call, result);
138
+ // A stand-in as large as the result would take more room than it makes.
139
+ return JSON.stringify(stub).length < size ? stub : undefined;
140
+ }
141
+
142
+ /** The stand-in of `stubResult`, whatever its size. */
143
+ function standIn(call: ToolCall, result: ToolResult): ToolResult {
133
144
  const evidence = evidenceOf(call, result);
134
145
  const base: ToolResult = { ...(typeof result.document === "string" ? { document: result.document } : {}), dropped: true };
135
146
  const lines = evidence?.lines?.slice(0, MOST_RANGES).map(rangeText);
package/src/extract.ts CHANGED
@@ -39,23 +39,34 @@ const MIME_FORMATS: Record<string, DocumentFormat> = {
39
39
  };
40
40
 
41
41
  /**
42
- * Picks a format from the file name, then the MIME type. Unknown text-like files are "text". Both
42
+ * The format a file's name, then its MIME type, say, and whether its bytes are to be looked at
43
+ * (`sniff`): a name and a type that say nothing more than text, without a ".txt" extension. Both
43
44
  * come from the upload: only the tables' own keys count, not "constructor" or "__proto__", which
44
45
  * every object has.
45
46
  */
46
- export function detectFormat(name: string, mimeType: string, bytes?: Uint8Array): DocumentFormat {
47
+ export function namedFormat(name: string, mimeType: string): { format: DocumentFormat; sniff: boolean } {
47
48
  const extension = name.toLowerCase().split(".").at(-1) ?? "";
48
49
  const mime = mimeType.toLowerCase();
49
- const named = (Object.hasOwn(EXTENSION_FORMATS, extension) ? EXTENSION_FORMATS[extension] : undefined)
50
+ const format = (Object.hasOwn(EXTENSION_FORMATS, extension) ? EXTENSION_FORMATS[extension] : undefined)
50
51
  ?? (Object.hasOwn(MIME_FORMATS, mime) ? MIME_FORMATS[mime] : undefined)
51
52
  ?? "text";
52
53
  // A name that says text ("notes.txt") is taken at its word.
53
- return named === "text" && bytes && extension !== "txt" ? sniffFormat(bytes) ?? named : named;
54
+ return { format, sniff: format === "text" && extension !== "txt" };
54
55
  }
55
56
 
56
- /** Where the part names of an Office file are looked for: its directory at the end, and its first parts. */
57
- const SNIFFED_HEAD = 64 * 1024;
58
- const SNIFFED_TAIL = 1024 * 1024;
57
+ /** Picks a format from the file name, then the MIME type, then the bytes, when they are given and the name and type say nothing. Unknown text-like files are "text". */
58
+ export function detectFormat(name: string, mimeType: string, bytes?: Uint8Array): DocumentFormat {
59
+ const { format, sniff } = namedFormat(name, mimeType);
60
+ return sniff && bytes ? sniffFormat(bytes) ?? format : format;
61
+ }
62
+
63
+ /**
64
+ * The bytes the format of a file is told by (`sniffFormat`): its first KB, and for a ZIP (an Office
65
+ * file) the names of its parts, in its first 64 KB and its directory, in its last MB.
66
+ */
67
+ export const SNIFFED_FIRST = 1_024;
68
+ export const SNIFFED_HEAD = 64 * 1024;
69
+ export const SNIFFED_TAIL = 1024 * 1024;
59
70
 
60
71
  /**
61
72
  * The format of a file whose name and type say nothing (no extension, "application/octet-stream"),
@@ -64,11 +75,22 @@ const SNIFFED_TAIL = 1024 * 1024;
64
75
  * extension was told "This file is a ZIP archive".
65
76
  */
66
77
  export function sniffFormat(bytes: Uint8Array): DocumentFormat | undefined {
67
- const head = latin1(bytes.subarray(0, 1_024));
68
- const start = head.replace(/^\xef\xbb\xbf/, "").trimStart();
78
+ return sniffParts(bytes.subarray(0, SNIFFED_HEAD), bytes.subarray(Math.max(SNIFFED_HEAD, bytes.length - SNIFFED_TAIL)));
79
+ }
80
+
81
+ /** Whether the bytes start as a ZIP archive does: an Office file is one. */
82
+ export const isZip = (head: Uint8Array) => head[0] === 0x50 && head[1] === 0x4b && head[2] === 0x03 && head[3] === 0x04;
83
+
84
+ /**
85
+ * `sniffFormat`, from the parts of a file it looks at, as they are read from a path without reading
86
+ * the rest: `head`, the file from its start (its first KB, or for a ZIP its first 64 KB), and
87
+ * `tail`, for a ZIP, the file from 64 KB (or its last MB, when it is larger) to its end.
88
+ */
89
+ export function sniffParts(head: Uint8Array, tail: Uint8Array): DocumentFormat | undefined {
90
+ const start = latin1(head.subarray(0, SNIFFED_FIRST)).replace(/^\xef\xbb\xbf/, "").trimStart();
69
91
  if (start.startsWith("%PDF-")) return "pdf";
70
- if (bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 0x03 && bytes[3] === 0x04) {
71
- const names = latin1(bytes.subarray(0, SNIFFED_HEAD)) + latin1(bytes.subarray(Math.max(SNIFFED_HEAD, bytes.length - SNIFFED_TAIL)));
92
+ if (isZip(head)) {
93
+ const names = latin1(head.subarray(0, SNIFFED_HEAD)) + latin1(tail);
72
94
  if (names.includes("word/document.xml")) return "docx";
73
95
  if (names.includes("ppt/presentation.xml") || names.includes("ppt/slides/")) return "pptx";
74
96
  if (names.includes("xl/workbook.xml")) return "xlsx";
@@ -176,30 +198,21 @@ function pageProgress(input: ExtractInput | undefined, stage: ExtractProgress["s
176
198
  }
177
199
 
178
200
  /**
179
- * Loads pdf.js through `unpdf`, and refuses a version of unpdf that cannot read PDFs on this
180
- * version of Node (`node`, as in `process.versions.node`), with a message that says what to install:
181
- * - unpdf 1.9 and later load a pdf.js that needs Node 22: on Node 20, every PDF fails.
182
- * - pdf.js calls `Promise.try`, which Node 20 and 22 do not have (Node 24 does). unpdf adds it
183
- * where it is missing, but 1.5.0 to 1.6.0 do not: there, the first PDF throws where nothing can
184
- * catch it, and the whole process stops.
185
- * The messages give the major version of Node only: an upload can be answered with them.
201
+ * Loads pdf.js through `unpdf`, and refuses a version of unpdf that would stop the process on this
202
+ * version of Node (`node`, as in `process.versions.node`), with a message that says what to install.
203
+ * pdf.js calls `Promise.try`, which Node 22 does not have (Node 24 does). unpdf adds it where it is
204
+ * missing, but 1.5.0 to 1.6.0 do not: there, the first PDF throws where nothing can catch it, and
205
+ * the whole process stops. An error of unpdf while it loads pdf.js is passed on as it is.
206
+ * The message gives the major version of Node only: an upload can be answered with it. Its start,
207
+ * "The unpdf installed would stop the whole server", is what `ingestErrorCodeOf` (errors.ts) reads
208
+ * as missing_dependency.
186
209
  */
187
210
  export async function checkUnpdf(unpdf: { getResolvedPDFJS?: unknown }, node: string = process.versions.node): Promise<void> {
188
211
  if (typeof unpdf.getResolvedPDFJS !== "function") return;
189
- const major = Number.parseInt(node, 10);
190
- try {
191
- await (unpdf.getResolvedPDFJS as () => Promise<unknown>)();
192
- } catch (error) {
193
- if (major >= 22) throw error;
194
- const reason = error instanceof Error ? error.message : String(error);
195
- throw new Error(`The unpdf installed cannot read PDF files on Node ${major} (${reason}). Install unpdf 1.7.0 (npm install unpdf@1.7.0), or run Node 22 or later.`);
196
- }
212
+ await (unpdf.getResolvedPDFJS as () => Promise<unknown>)();
197
213
  if (typeof (Promise as { try?: unknown }).try !== "function") {
198
- const advice = major < 22
199
- ? "Install unpdf 1.7.0 (npm install unpdf@1.7.0), or run Node 24 or later."
200
- : major < 24
201
- ? "Install unpdf 1.6.1 or later, or run Node 24 or later."
202
- : "Install unpdf 1.6.1 or later.";
214
+ const major = Number.parseInt(node, 10);
215
+ const advice = major < 24 ? "Install unpdf 1.6.1 or later, or run Node 24 or later." : "Install unpdf 1.6.1 or later.";
203
216
  throw new Error(`The unpdf installed would stop the whole server at the first PDF file on Node ${major}, so PDF files are not read. ${advice}`);
204
217
  }
205
218
  }
@@ -329,11 +342,15 @@ export const defaultExtractors: Record<DocumentFormat, Extractor> = {
329
342
  html,
330
343
  };
331
344
 
345
+ /** The extractor of a format: the application's own (`LargeFilesOptions.extractors`), or the built-in one. */
346
+ export function extractorFor(format: DocumentFormat, extractors: Partial<Record<DocumentFormat, Extractor>> = {}): Extractor {
347
+ return extractors[format] ?? defaultExtractors[format];
348
+ }
349
+
332
350
  export async function extractText(
333
351
  bytes: Uint8Array,
334
352
  input: ExtractInput,
335
353
  extractors: Partial<Record<DocumentFormat, Extractor>> = {},
336
354
  ): Promise<ExtractedText> {
337
- const extractor = extractors[input.format] ?? defaultExtractors[input.format];
338
- return extractor(bytes, input);
355
+ return extractorFor(input.format, extractors)(bytes, input);
339
356
  }
@@ -1,5 +1,7 @@
1
1
  // Gemini (Generate Content REST) as a model of `askWithFiles`.
2
- import { laterResult, type ChatMessage, type ModelAdapter, type ModelMessage, type ModelReply, type ModelRequest, type ModelTextMessage, type ModelToolRound, type SendHooks, type ToolCall, type ToolTurn } from "../model.js";
2
+ import { laterResult, TOOL_TURN_VERSION, type ChatMessage, type ModelAdapter, type ModelMessage, type ModelPart, type ModelReply, type ModelRequest, type ModelTextMessage, type ModelToolRound, type SendHooks, type ToolCall, type ToolTurn } from "../model.js";
3
+ import { TOOL_NAMES } from "../tools.js";
4
+ import type { ToolResult } from "../types.js";
3
5
  import { retryAfterMs } from "../retry.js";
4
6
  import { idleWatch, noteCutReply, readJson, streamedReply, type IdleWatch } from "../http.js";
5
7
  import { eventTooLongMessage, parseSseJson, SseEventTooLongError } from "../sse.js";
@@ -88,18 +90,102 @@ const textTurn = (message: ModelTextMessage): GeminiContent[] => {
88
90
  return parts.length > 0 ? [{ role: message.role === "user" ? "user" : "model", parts }] : [];
89
91
  };
90
92
 
93
+ export type FromGeminiContentsOptions = {
94
+ /**
95
+ * Turn the tool rounds of earlier questions back into stored rounds (`ToolTurn`), as
96
+ * `geminiToolTurns` wrote them: a `model` turn made only of `functionCall` parts that call this
97
+ * library's tools (`TOOL_NAMES`), followed by the `user` turn of their `functionResponse` parts,
98
+ * one for each call, in the same order, with the same names and ids. The loop can then point a
99
+ * repeated call to them, shorten them to make room, and size them as it sizes `toolTurns`. The
100
+ * request is the same for the rounds `geminiToolTurns` wrote. A turn with anything else in it (a
101
+ * function of your own, a thought signature, a file in a response) stays as it is, and so does a
102
+ * round that ends `contents`: its responses are the turn the model answers. Defaults to true;
103
+ * false gives the turns of 0.8. New in 0.9.0.
104
+ */
105
+ rounds?: boolean;
106
+ };
107
+
108
+ /** The names of the library's tools. */
109
+ const LIBRARY_TOOLS: ReadonlySet<string> = new Set(Object.values(TOOL_NAMES));
110
+
111
+ const isPlainObject = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === "object" && !Array.isArray(value);
112
+ /** Whether `value` has no keys but those `allowed`. */
113
+ const onlyKeys = (value: Record<string, unknown>, allowed: readonly string[]) => Object.keys(value).every((key) => allowed.includes(key));
114
+ /** The field `name` of a part that has that field and no other, when it is an object. */
115
+ const soleField = (part: GeminiPart | undefined, name: string): Record<string, unknown> | undefined => {
116
+ if (!isPlainObject(part)) return undefined;
117
+ const keys = Object.keys(part);
118
+ return keys.length === 1 && keys[0] === name && isPlainObject(part[name]) ? part[name] : undefined;
119
+ };
120
+
91
121
  /**
92
- * Gemini `contents` as messages of `askWithFiles`: text parts as text, every other part (an image,
93
- * an inline PDF, a function call of an earlier question) as it is.
122
+ * A stored tool round of the library, in the form `geminiToolTurns` gives it: `asked` is a model
123
+ * turn of calls of the library's tools and nothing else, and `answered` the turn of their
124
+ * responses, in the same order. Undefined for anything else.
94
125
  */
95
- export function fromGeminiContents(contents: GeminiContent[]): ChatMessage[] {
96
- return contents.map((content): ModelTextMessage => ({
97
- role: content.role === "user" ? "user" : "assistant",
98
- parts: content.parts.map((part) => {
99
- if (typeof part.text !== "string") return { native: part };
100
- return Object.keys(part).length === 1 ? { text: part.text } : { native: part, text: part.text };
101
- }),
102
- }));
126
+ function liftedRound(asked: GeminiContent, answered: GeminiContent | undefined): ToolTurn | undefined {
127
+ if (asked.role !== "model" || answered?.role !== "user" || !Array.isArray(asked.parts) || !Array.isArray(answered.parts)) return undefined;
128
+ if (asked.parts.length === 0 || answered.parts.length !== asked.parts.length) return undefined;
129
+ const calls: ToolTurn["calls"] = [];
130
+ for (const [index, part] of asked.parts.entries()) {
131
+ const call = soleField(part, "functionCall");
132
+ const response = soleField(answered.parts[index], "functionResponse");
133
+ if (!call || !response || !onlyKeys(call, ["name", "args", "id"]) || !onlyKeys(response, ["name", "id", "response"])) return undefined;
134
+ const { name, args = {}, id } = call;
135
+ if (typeof name !== "string" || !LIBRARY_TOOLS.has(name) || !isPlainObject(args) || (id !== undefined && typeof id !== "string")) return undefined;
136
+ if (response.name !== name || response.id !== id || !isPlainObject(response.response)) return undefined;
137
+ calls.push({ ...(id ? { id } : {}), name, args, result: response.response as ToolResult });
138
+ }
139
+ return { role: "tools", version: TOOL_TURN_VERSION, calls };
140
+ }
141
+
142
+ /**
143
+ * The text a function part is sized by: the JSON of its call or response. Undefined for any other
144
+ * part, and for a response with files in it, which is sized as media.
145
+ */
146
+ function sizingText(part: GeminiPart): string | undefined {
147
+ for (const name of ["functionCall", "functionResponse"]) {
148
+ const field = part[name];
149
+ if (!isPlainObject(field)) continue;
150
+ if (Array.isArray(field.parts) && field.parts.length > 0) return undefined;
151
+ return JSON.stringify(field);
152
+ }
153
+ return undefined;
154
+ }
155
+
156
+ /** A part of a turn that is not part of a stored round. */
157
+ function partOf(part: GeminiPart): ModelPart {
158
+ if (typeof part.text !== "string") {
159
+ const text = sizingText(part);
160
+ return text === undefined ? { native: part } : { native: part, text };
161
+ }
162
+ return Object.keys(part).length === 1 ? { text: part.text } : { native: part, text: part.text };
163
+ }
164
+
165
+ /**
166
+ * Gemini `contents` as messages of `askWithFiles`: text parts as text, the tool rounds of earlier
167
+ * questions that `geminiToolTurns` gave as stored rounds (see `options.rounds`, since 0.9.0), and
168
+ * every other part (an image, an inline PDF, a function call of your own) as it is. A function
169
+ * part kept as it is is sized by the JSON of its call or response (since 0.9.0; before, as media).
170
+ */
171
+ export function fromGeminiContents(contents: GeminiContent[], options: FromGeminiContentsOptions = {}): ChatMessage[] {
172
+ const lift = options.rounds !== false;
173
+ const messages: ChatMessage[] = [];
174
+ for (let at = 0; at < contents.length; at++) {
175
+ const content = contents[at]!;
176
+ // A round is lifted only when a turn follows it. Responses that end `contents` are the turn the
177
+ // model answers (an application that ran the tools in a loop of its own hands them over), and
178
+ // stay as they are, as in 0.8.
179
+ const round = lift && at + 2 < contents.length ? liftedRound(content, contents[at + 1]) : undefined;
180
+ if (round) {
181
+ messages.push(round);
182
+ at++;
183
+ continue;
184
+ }
185
+ const turn: ModelTextMessage = { role: content.role === "user" ? "user" : "assistant", parts: content.parts.map(partOf) };
186
+ messages.push(turn);
187
+ }
188
+ return messages;
103
189
  }
104
190
 
105
191
  /**
@@ -1,9 +1,9 @@
1
- import { askWithFiles, type AskLimits, type AskResult } from "../ask.js";
1
+ import { askWithFiles, type AskLimits, type AskOptions, type AskResult } from "../ask.js";
2
2
  import type { LargeFiles } from "../library.js";
3
3
  import type { AskEvent } from "../events.js";
4
- import type { ChatTurn, ToolTurn } from "../model.js";
4
+ import type { ChatMessage } from "../model.js";
5
5
  import type { RetryOptions } from "../retry.js";
6
- import type { Budget } from "../types.js";
6
+ import type { Budget, DocumentScope } from "../types.js";
7
7
  import { fromGeminiContents, gemini, type GeminiContent } from "./adapter.js";
8
8
  import type { GeminiEndpoint } from "./endpoints.js";
9
9
  import type { GeminiToolFilePlacement } from "./generate.js";
@@ -34,10 +34,12 @@ export type AskGeminiOptions = {
34
34
  */
35
35
  documentPlacement?: "first" | "last";
36
36
  /**
37
- * Plain chat history; the last turn must be the user's question. It may hold the tool rounds of
38
- * earlier questions (`toolTurns` of their results). Use this or `contents`.
37
+ * The chat history, as `askWithFiles` takes it; the last turn must be the user's question. It
38
+ * may hold the tool rounds of earlier questions (`toolTurns` of their results), and turns with
39
+ * parts, such as `fromGeminiContents(contents, { rounds: false })` gives. Use this or
40
+ * `contents`. Typed `ChatMessage[]` since 0.9.0; before, `Array<ChatTurn | ToolTurn>`.
39
41
  */
40
- messages?: Array<ChatTurn | ToolTurn>;
42
+ messages?: ChatMessage[];
41
43
  /** Your own Gemini `contents` (with images, inline PDFs, etc.). The last turn must be the user's. */
42
44
  contents?: GeminiContent[];
43
45
  system?: string;
@@ -51,6 +53,16 @@ export type AskGeminiOptions = {
51
53
  explorerGenerationConfig?: Record<string, unknown>;
52
54
  /** The user asking. Documents ingested with a different owner are treated as missing. */
53
55
  owner?: string;
56
+ /**
57
+ * The scope of the question, such as [userId, chatId] (`AskOptions.scope`): documents ingested
58
+ * with another scope are treated as missing. New in 0.9.0.
59
+ */
60
+ scope?: DocumentScope;
61
+ /**
62
+ * What to do when documents of `documentIds` are missing: "throw" (the default), "drop", or a
63
+ * function that says (`AskOptions.onMissingDocuments`). New in 0.9.0.
64
+ */
65
+ onMissingDocuments?: AskOptions["onMissingDocuments"];
54
66
  /** The limits of the question: tool turns, calls in a turn, whole-file reads, tokens and requests. */
55
67
  limits?: AskLimits;
56
68
  /** `limits.toolTurns`, under the name it had before 0.5.0. Defaults to 12. */
@@ -137,6 +149,8 @@ export async function askGemini(options: AskGeminiOptions): Promise<AskGeminiRes
137
149
  messages: options.contents ? fromGeminiContents(options.contents) : options.messages ?? [],
138
150
  ...(options.system !== undefined ? { system: options.system } : {}),
139
151
  ...(options.owner !== undefined ? { owner: options.owner } : {}),
152
+ ...(options.scope !== undefined ? { scope: options.scope } : {}),
153
+ ...(options.onMissingDocuments !== undefined ? { onMissingDocuments: options.onMissingDocuments } : {}),
140
154
  limits: {
141
155
  ...(options.maxToolTurns !== undefined ? { toolTurns: options.maxToolTurns } : {}),
142
156
  ...(options.maxToolCallsPerTurn !== undefined ? { callsPerTurn: options.maxToolCallsPerTurn } : {}),
@@ -1,7 +1,7 @@
1
1
  export { askGemini, DocumentsNotFoundError, EXPLORER_INSTRUCTION, FINAL_ANSWER_AFTER_PAGES, FINAL_ANSWER_REQUEST, FINAL_ANSWER_WITHOUT_TOOLS, GeminiRequestError, partialResultOf } from "./chat.js";
2
2
  export type { AskEvent, AskGeminiOptions, AskGeminiResult, ChatTurn, GeminiContent, GeminiPart } from "./chat.js";
3
3
  export { fromGeminiContents, gemini, GEMINI_PAGE_TOKENS, geminiToolTurns } from "./adapter.js";
4
- export type { GeminiModelOptions } from "./adapter.js";
4
+ export type { FromGeminiContentsOptions, GeminiModelOptions } from "./adapter.js";
5
5
  export { geminiApi, vertexAi, vertexHost } from "./endpoints.js";
6
6
  export type { GeminiEndpoint } from "./endpoints.js";
7
7
  export { createGeminiGenerateText, geminiFunctionResponses, geminiFunctionResponseTurns, THINKING_OUTPUT_TOKENS, toGeminiTools, usageOfGemini } from "./generate.js";
package/src/index.ts CHANGED
@@ -2,12 +2,12 @@
2
2
  // "llm-large-files/gemini", "llm-large-files/openai", "llm-large-files/anthropic", or your own.
3
3
  // Node HTTP handlers are in "llm-large-files/node".
4
4
  export { createLargeFiles, DEFAULT_CACHE_BYTES, DEFAULT_INGEST_TIMEOUT_MS, DEFAULT_MAX_PDF_PAGES, DEFAULT_MAX_TEXT_BYTES, DEFAULT_WHOLE_DOCUMENT_BYTES, isDocumentId, NEVER_EXPIRES, toDocumentSummary } from "./library.js";
5
- export type { AccessOptions, IngestInput, LargeFiles, LargeFilesOptions, PrepareOptions, ToolOptions } from "./library.js";
5
+ export type { AccessOptions, IngestFromSource, IngestInput, IngestSource, LargeFiles, LargeFilesOptions, OriginalReadContext, OriginalsReader, PrepareOptions, ToolOptions } from "./library.js";
6
6
  export { DEFAULT_BUDGET, resolveBudget } from "./budget.js";
7
7
  export type { ModelLimits } from "./budget.js";
8
8
  export { askStream, askWithFiles, EXPLORER_INSTRUCTION, FINAL_ANSWER_AFTER_PAGES, FINAL_ANSWER_REQUEST, FINAL_ANSWER_WITHOUT_TOOLS, partialResultOf } from "./ask.js";
9
- export type { AskLimits, AskOptions, AskResult } from "./ask.js";
10
- export { classifyModelError, DocumentsNotFoundError, errorKindOf, ModelRequestError, UsageMeter } from "./model.js";
9
+ export type { AskLimits, AskOptions, AskResult, MissingDocumentsAction, MissingDocumentsContext } from "./ask.js";
10
+ export { classifyModelError, DocumentsNotFoundError, errorKindOf, ModelRequestError, TOOL_TURN_VERSION, UsageMeter } from "./model.js";
11
11
  export type {
12
12
  ChatMessage,
13
13
  ModelErrorClass,
@@ -53,9 +53,12 @@ export { parseSseJson, SseEventTooLongError } from "./sse.js";
53
53
  export type { SseHooks } from "./sse.js";
54
54
  export { DEFAULT_FIRST_BYTE_TIMEOUT_MS, DEFAULT_IDLE_TIMEOUT_MS } from "./http.js";
55
55
  export type { IdleWaits } from "./http.js";
56
- export { DocumentStoreError, IngestError, ingestErrorCodeOf } from "./errors.js";
57
- export type { IngestErrorCode } from "./errors.js";
58
- export { FileDocumentStore, MemoryDocumentStore, DOCUMENT_ID_PATTERN } from "./stores.js";
56
+ export { DocumentScopeError, DocumentStoreError, IngestError, ingestErrorCodeOf } from "./errors.js";
57
+ export type { DocumentScopeErrorCode, DocumentStoreOperation, IngestErrorCode } from "./errors.js";
58
+ export { errorInfoOf } from "./error-info.js";
59
+ export type { ErrorCategory, ErrorInfo } from "./error-info.js";
60
+ export { APP_DOCUMENT_ID_PATTERN, DOCUMENT_ID_PATTERN, DOCUMENT_META_VERSION, FileDocumentStore, hashedScopeSegment, isSafeScopeSegment, MemoryDocumentStore } from "./stores.js";
61
+ export type { FileDocumentScopes, FileDocumentStoreOptions } from "./stores.js";
59
62
  export { createPdfExtractor, defaultExtractors, detectFormat } from "./extract.js";
60
63
  export type { PdfExtractorOptions } from "./extract.js";
61
64
  export { estimateTokens, utf8Bytes, jsonBytes } from "./text.js";