llm-large-files 0.5.0 → 0.7.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 +1402 -467
- package/README.md +188 -60
- package/dist/analyze.d.ts +5 -0
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +96 -47
- package/dist/analyze.js.map +1 -1
- package/dist/anthropic/adapter.d.ts +14 -3
- package/dist/anthropic/adapter.d.ts.map +1 -1
- package/dist/anthropic/adapter.js +190 -39
- package/dist/anthropic/adapter.js.map +1 -1
- package/dist/ask.d.ts +60 -4
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +1068 -206
- package/dist/ask.js.map +1 -1
- package/dist/encoding.d.ts +17 -0
- package/dist/encoding.d.ts.map +1 -0
- package/dist/encoding.js +852 -0
- package/dist/encoding.js.map +1 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +333 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +159 -0
- package/dist/events.js.map +1 -0
- package/dist/evidence.d.ts +2 -0
- package/dist/evidence.d.ts.map +1 -1
- package/dist/evidence.js +3 -2
- package/dist/evidence.js.map +1 -1
- package/dist/extract.d.ts +35 -3
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +626 -58
- package/dist/extract.js.map +1 -1
- package/dist/gemini/adapter.d.ts +17 -8
- package/dist/gemini/adapter.d.ts.map +1 -1
- package/dist/gemini/adapter.js +108 -61
- package/dist/gemini/adapter.js.map +1 -1
- package/dist/gemini/chat.d.ts +23 -3
- package/dist/gemini/chat.d.ts.map +1 -1
- package/dist/gemini/chat.js +6 -2
- package/dist/gemini/chat.js.map +1 -1
- package/dist/gemini/errors.d.ts +9 -4
- package/dist/gemini/errors.d.ts.map +1 -1
- package/dist/gemini/errors.js +32 -0
- package/dist/gemini/errors.js.map +1 -1
- package/dist/gemini/generate.d.ts +10 -2
- package/dist/gemini/generate.d.ts.map +1 -1
- package/dist/gemini/generate.js +13 -7
- package/dist/gemini/generate.js.map +1 -1
- package/dist/gemini/index.d.ts +3 -3
- package/dist/gemini/index.d.ts.map +1 -1
- package/dist/gemini/index.js +2 -2
- package/dist/gemini/index.js.map +1 -1
- package/dist/gemini/sse.d.ts +1 -1
- package/dist/gemini/sse.d.ts.map +1 -1
- package/dist/gemini/sse.js +1 -1
- package/dist/gemini/sse.js.map +1 -1
- package/dist/http.d.ts +116 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +347 -1
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +11 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/library.d.ts +67 -5
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +405 -85
- package/dist/library.js.map +1 -1
- package/dist/map-reduce.d.ts +28 -1
- package/dist/map-reduce.d.ts.map +1 -1
- package/dist/map-reduce.js +240 -52
- package/dist/map-reduce.js.map +1 -1
- package/dist/model.d.ts +84 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +182 -1
- package/dist/model.js.map +1 -1
- package/dist/node/handlers.d.ts +20 -4
- package/dist/node/handlers.d.ts.map +1 -1
- package/dist/node/handlers.js +122 -20
- package/dist/node/handlers.js.map +1 -1
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/sse.d.ts +59 -0
- package/dist/node/sse.d.ts.map +1 -0
- package/dist/node/sse.js +174 -0
- package/dist/node/sse.js.map +1 -0
- package/dist/openai/adapter.d.ts +29 -5
- package/dist/openai/adapter.d.ts.map +1 -1
- package/dist/openai/adapter.js +311 -37
- package/dist/openai/adapter.js.map +1 -1
- package/dist/output-limit.d.ts +14 -2
- package/dist/output-limit.d.ts.map +1 -1
- package/dist/output-limit.js +39 -10
- package/dist/output-limit.js.map +1 -1
- package/dist/pause.d.ts +24 -0
- package/dist/pause.d.ts.map +1 -0
- package/dist/pause.js +38 -0
- package/dist/pause.js.map +1 -0
- package/dist/pdf-pages.d.ts +32 -2
- package/dist/pdf-pages.d.ts.map +1 -1
- package/dist/pdf-pages.js +275 -14
- package/dist/pdf-pages.js.map +1 -1
- package/dist/pdf-pictures.d.ts +30 -3
- package/dist/pdf-pictures.d.ts.map +1 -1
- package/dist/pdf-pictures.js +50 -8
- package/dist/pdf-pictures.js.map +1 -1
- package/dist/pdf-work.d.ts +40 -0
- package/dist/pdf-work.d.ts.map +1 -0
- package/dist/pdf-work.js +734 -0
- package/dist/pdf-work.js.map +1 -0
- package/dist/plan.d.ts +22 -4
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +61 -12
- package/dist/plan.js.map +1 -1
- package/dist/retry.d.ts +23 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +33 -3
- package/dist/retry.js.map +1 -1
- package/dist/search.d.ts +8 -2
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +60 -10
- package/dist/search.js.map +1 -1
- package/dist/sse.d.ts +35 -2
- package/dist/sse.d.ts.map +1 -1
- package/dist/sse.js +145 -31
- package/dist/sse.js.map +1 -1
- package/dist/stores.d.ts.map +1 -1
- package/dist/stores.js +5 -2
- package/dist/stores.js.map +1 -1
- package/dist/text-index.d.ts +6 -0
- package/dist/text-index.d.ts.map +1 -1
- package/dist/text-index.js +25 -8
- package/dist/text-index.js.map +1 -1
- package/dist/text.d.ts +62 -2
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +314 -14
- package/dist/text.js.map +1 -1
- package/dist/tools.d.ts +61 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +269 -42
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +102 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/zip-directory.d.ts +43 -0
- package/dist/zip-directory.d.ts.map +1 -0
- package/dist/zip-directory.js +130 -0
- package/dist/zip-directory.js.map +1 -0
- package/docs/README.md +288 -0
- package/docs/api.md +37 -381
- package/docs/configuration.md +28 -558
- package/docs/getting-started.md +407 -223
- package/docs/guides/anthropic.md +590 -0
- package/docs/guides/conversations.md +629 -0
- package/docs/guides/costs-and-limits.md +726 -0
- package/docs/guides/deployment.md +654 -0
- package/docs/guides/errors-and-reliability.md +735 -0
- package/docs/guides/explorer-model.md +399 -0
- package/docs/guides/openai-compatible.md +602 -0
- package/docs/guides/own-adapter-and-loop.md +1169 -0
- package/docs/guides/pdfs.md +971 -0
- package/docs/guides/storage.md +731 -0
- package/docs/guides/testing.md +1199 -0
- package/docs/guides/vertex-and-gemini.md +717 -0
- package/docs/guides/web-app.md +1589 -0
- package/docs/how-it-works.md +1012 -164
- package/docs/measurements.md +881 -0
- package/docs/publishing.md +274 -46
- package/docs/reference/anthropic.md +427 -0
- package/docs/reference/ask.md +892 -0
- package/docs/reference/errors-and-retries.md +758 -0
- package/docs/reference/events.md +993 -0
- package/docs/reference/gemini.md +823 -0
- package/docs/reference/library.md +1467 -0
- package/docs/reference/node.md +528 -0
- package/docs/reference/openai.md +385 -0
- package/docs/reference/tools.md +883 -0
- package/docs/security.md +897 -103
- package/docs/troubleshooting.md +1390 -0
- package/package.json +2 -2
- package/src/analyze.ts +93 -42
- package/src/anthropic/adapter.ts +196 -39
- package/src/ask.ts +1087 -202
- package/src/encoding.ts +850 -0
- package/src/errors.ts +17 -0
- package/src/events.ts +442 -0
- package/src/evidence.ts +5 -2
- package/src/extract.ts +602 -62
- package/src/gemini/adapter.ts +118 -65
- package/src/gemini/chat.ts +28 -4
- package/src/gemini/errors.ts +34 -1
- package/src/gemini/generate.ts +23 -10
- package/src/gemini/index.ts +3 -3
- package/src/gemini/sse.ts +1 -1
- package/src/http.ts +376 -1
- package/src/index.ts +27 -5
- package/src/library.ts +459 -85
- package/src/map-reduce.ts +252 -51
- package/src/model.ts +236 -3
- package/src/node/handlers.ts +137 -22
- package/src/node/index.ts +2 -0
- package/src/node/sse.ts +198 -0
- package/src/openai/adapter.ts +306 -38
- package/src/output-limit.ts +44 -8
- package/src/pause.ts +41 -0
- package/src/pdf-pages.ts +268 -15
- package/src/pdf-pictures.ts +56 -9
- package/src/pdf-work.ts +722 -0
- package/src/plan.ts +68 -12
- package/src/retry.ts +49 -5
- package/src/search.ts +63 -10
- package/src/sse.ts +153 -28
- package/src/stores.ts +5 -2
- package/src/text-index.ts +26 -7
- package/src/text.ts +323 -13
- package/src/tools.ts +261 -42
- package/src/types.ts +107 -4
- package/src/zip-directory.ts +136 -0
package/dist/text.d.ts
CHANGED
|
@@ -1,16 +1,54 @@
|
|
|
1
|
+
import type { TimeSlicer } from "./pause.js";
|
|
1
2
|
/** Lines longer than this are split so line-based tools always return bounded output. */
|
|
2
3
|
export declare const MAX_LINE_CHARACTERS = 2000;
|
|
4
|
+
/** `text` without the characters of `INVISIBLE`. */
|
|
5
|
+
export declare function removeInvisible(text: string): string;
|
|
6
|
+
/** A word for a count: "line" for 1, "lines" for any other. */
|
|
7
|
+
export declare const plural: (count: number, word: string) => string;
|
|
3
8
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
9
|
+
* Whether the U+0085 of `text` end lines: only when it has no other line break, one at its very end
|
|
10
|
+
* aside. A mainframe file converted to UTF-8 has none. In a text that has them, a U+0085 is more
|
|
11
|
+
* often in a JSON string or a CSV field, or a windows-1252 "…" read as Latin-1, and a line break
|
|
12
|
+
* there would split a record and move every line after it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function breaksAtNextLine(text: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Strips a BOM, unifies line endings, and removes terminal escape sequences, control characters
|
|
17
|
+
* other than tab and newline, and the invisible characters of `INVISIBLE`. In a text with no other
|
|
18
|
+
* line break, a U+0085 becomes one (see `NEXT_LINE`).
|
|
6
19
|
*/
|
|
7
20
|
export declare function normalizeText(raw: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* `normalizeLines`, a piece of about `piece` characters at a time, with a pause between pieces. A
|
|
23
|
+
* line with no break for megabytes can hold millions of characters or escape sequences to remove,
|
|
24
|
+
* which take seconds in one go. The escape sequences are found in order, as in one go, and the
|
|
25
|
+
* pieces of the last step (`cleanLines`) end where `cutsCleanly` says, so the result is the same.
|
|
26
|
+
*/
|
|
27
|
+
export declare function normalizeInPieces(raw: string, slicer: TimeSlicer, nextLines: boolean, piece?: number): Promise<string>;
|
|
8
28
|
/**
|
|
9
29
|
* Lowercases for case-insensitive search without changing the string's length, so an offset in the
|
|
10
30
|
* result points at the same character in the original. "İ" (U+0130) is the one character whose
|
|
11
31
|
* lowercase form is longer; it is folded to "i".
|
|
12
32
|
*/
|
|
13
33
|
export declare function foldCase(text: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* The first `end` UTF-16 units of `text`, one fewer when the last of them would be the first half
|
|
36
|
+
* of a character outside the basic plane (an emoji). Half of one is not text: JSON writes it as
|
|
37
|
+
* `\ud83d`, and an API that checks its input (Claude's) refuses the request.
|
|
38
|
+
*/
|
|
39
|
+
export declare function sliceWhole(text: string, end: number): string;
|
|
40
|
+
/**
|
|
41
|
+
* `text` with each half of a character that is on its own (an emoji cut in two) made a replacement
|
|
42
|
+
* character, as `String.prototype.toWellFormed` does. 0.5.0 cut some strings that way, and kept them:
|
|
43
|
+
* log templates in the metadata, and search windows in tool rounds. Claude's API refuses a request
|
|
44
|
+
* that holds one. Text that is whole comes back as it is.
|
|
45
|
+
*/
|
|
46
|
+
export declare function wellFormed(text: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* A JSON value with `wellFormed` applied to every string in it, keys included. The same value, not
|
|
49
|
+
* a copy, when nothing in it needed that.
|
|
50
|
+
*/
|
|
51
|
+
export declare function wellFormedJson<T>(value: T): T;
|
|
14
52
|
/**
|
|
15
53
|
* Splits lines longer than `limit`, preferring a break after whitespace or punctuation near the
|
|
16
54
|
* end of each piece. Minified JSON or a PDF paragraph becomes many addressable lines.
|
|
@@ -41,6 +79,28 @@ export declare function textSizes(text: string): {
|
|
|
41
79
|
utf8: number;
|
|
42
80
|
json: number;
|
|
43
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* `estimateTokens` and `textSizes` of a text, the same numbers, worked out a slice at a time so
|
|
84
|
+
* that other requests get a turn while a large upload is measured. Slices end after a line break.
|
|
85
|
+
*/
|
|
86
|
+
export declare function measureText(text: string, slicer: TimeSlicer): Promise<{
|
|
87
|
+
tokens: number;
|
|
88
|
+
utf8: number;
|
|
89
|
+
json: number;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* What ingest makes of extracted text, a slice at a time: `normalizeText`, then `wrapLongLines`,
|
|
93
|
+
* then the lines (a line break at the very end does not start another line). The same results as
|
|
94
|
+
* doing each in one go: no step of `normalizeText` reaches across a line break, and whether a U+0085
|
|
95
|
+
* ends lines is decided once, for the whole text. A slice that runs far past its size holds a long
|
|
96
|
+
* line: it is cleaned in pieces too. `onProgress` is told the characters of `raw` cleaned so far,
|
|
97
|
+
* after each slice; splitting the lines after that is quick, and is not counted.
|
|
98
|
+
*/
|
|
99
|
+
export declare function prepareText(raw: string, slicer: TimeSlicer, onProgress?: (done: number, total: number) => void): Promise<{
|
|
100
|
+
text: string;
|
|
101
|
+
wrapped: number;
|
|
102
|
+
lines: string[];
|
|
103
|
+
}>;
|
|
44
104
|
/** UTF-8 byte length without allocating an encoded copy. */
|
|
45
105
|
export declare function utf8Bytes(text: string): number;
|
|
46
106
|
/** Bytes a string takes in a JSON request body: its UTF-8 bytes, the escapes JSON adds, and its two quotes. */
|
package/dist/text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,eAAO,MAAM,mBAAmB,OAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,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AAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM;CAO3C"}
|
package/dist/text.js
CHANGED
|
@@ -6,20 +6,173 @@ export const MAX_LINE_CHARACTERS = 2_000;
|
|
|
6
6
|
* ("ESC 7", "ESC c"). Coloured logs are full of them. An "ESC ]" whose end is not on its line is
|
|
7
7
|
* not a sequence: only those two characters go. Otherwise one stray "ESC ]", a cut-off window title
|
|
8
8
|
* or two bytes in a logged user agent, would take every line after it.
|
|
9
|
+
* U+009B, the one-character form of "ESC [", starts a sequence only with a parameter ("\x9b31m"),
|
|
10
|
+
* and not right after U+0080-U+00FF: there it is the end of a letter of UTF-8 read as Latin-1
|
|
11
|
+
* ("ś" is C5 9B, so "Coś? Tak" holds "\xc5\x9b? Tak"), and what follows it is text. `INVISIBLE`
|
|
12
|
+
* removes the U+009B alone then.
|
|
9
13
|
*/
|
|
10
14
|
// eslint-disable-next-line no-control-regex
|
|
11
|
-
const ANSI_ESCAPE = /\x1b(?:\[[0-?]*[ -\/]*[@-~]|\][^\x07\x1b\n]*(?:\x07|\x1b\\)|[ -\/]+[0-~]|[0-~])/g;
|
|
15
|
+
const ANSI_ESCAPE = /\x1b(?:\[[0-?]*[ -\/]*[@-~]|\][^\x07\x1b\n]*(?:\x07|\x1b\\)|[ -\/]+[0-~]|[0-~])|(?<![\x80-\xff])\x9b[0-?]+[ -\/]*[@-~]/g;
|
|
12
16
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
17
|
+
* Characters that show nothing, that no script needs, and that can hide text from a person who
|
|
18
|
+
* reads the file while a model reads it:
|
|
19
|
+
* - control characters other than tab and line breaks: C0 (U+0000-U+001F, U+007F) and C1
|
|
20
|
+
* (U+0080-U+009F);
|
|
21
|
+
* - Unicode tag characters (U+E0000-U+E007F). Each spells out one ASCII character, which a model
|
|
22
|
+
* reads and a person does not see. The three flags written with them (England, Scotland,
|
|
23
|
+
* Wales) are kept;
|
|
24
|
+
* - the text-direction controls that change the order a person sees: embeddings and overrides
|
|
25
|
+
* (U+202A-U+202E) and isolates (U+2066-U+2069). The marks that right-to-left text needs
|
|
26
|
+
* (U+200E, U+200F, U+061C) are kept;
|
|
27
|
+
* - the zero-width space (U+200B), the word joiner and invisible operators (U+2060-U+2064), the
|
|
28
|
+
* deprecated format characters (U+206A-U+206F), a byte order mark inside the text (U+FEFF), and
|
|
29
|
+
* the soft hyphen (U+00AD), but not one before a line break: there it shows, as a hyphen.
|
|
30
|
+
* Zero-width joiners and non-joiners (U+200C, U+200D) are kept: emoji and some scripts need them.
|
|
31
|
+
* Tab, "\n" and "\r" are not among them, so removing them moves no line. U+0085 goes with the other
|
|
32
|
+
* C1 characters, except where it ends lines (see `NEXT_LINE`).
|
|
33
|
+
*/
|
|
34
|
+
// eslint-disable-next-line no-control-regex
|
|
35
|
+
const INVISIBLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\u200B\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF]+|\xAD(?!\n)|\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|(?:\uDB40[\uDC00-\uDC7F])+/g;
|
|
36
|
+
/** A flag written with tag characters starts with U+1F3F4, whose first half is this. */
|
|
37
|
+
const FLAG_START = 0xd83c;
|
|
38
|
+
/**
|
|
39
|
+
* U+0085 (next line) ends each record of a mainframe file converted to UTF-8, which has no other
|
|
40
|
+
* line break: in such a text it becomes a line break (see `breaksAtNextLine`). Not one right after
|
|
41
|
+
* U+0080-U+00FF: there it is the last byte of a UTF-8 letter read as Latin-1 ("ą" is C4 85), and a
|
|
42
|
+
* line break would split the word. `INVISIBLE` removes that one, and those of other texts.
|
|
43
|
+
*/
|
|
44
|
+
const NEXT_LINE = /(?<![\x80-\xFF])\x85/g;
|
|
45
|
+
/** A run of U+0085, to go past it in one step. */
|
|
46
|
+
const NEXT_LINE_RUN = /\x85+/y;
|
|
47
|
+
/** `text` without the characters of `INVISIBLE`. */
|
|
48
|
+
export function removeInvisible(text) {
|
|
49
|
+
return text.replace(INVISIBLE, (found) => (found.charCodeAt(0) === FLAG_START ? found : ""));
|
|
50
|
+
}
|
|
51
|
+
/** A word for a count: "line" for 1, "lines" for any other. */
|
|
52
|
+
export const plural = (count, word) => (count === 1 ? word : `${word}s`);
|
|
53
|
+
/**
|
|
54
|
+
* Whether the U+0085 of `text` end lines: only when it has no other line break, one at its very end
|
|
55
|
+
* aside. A mainframe file converted to UTF-8 has none. In a text that has them, a U+0085 is more
|
|
56
|
+
* often in a JSON string or a CSV field, or a windows-1252 "…" read as Latin-1, and a line break
|
|
57
|
+
* there would split a record and move every line after it.
|
|
58
|
+
*/
|
|
59
|
+
export function breaksAtNextLine(text) {
|
|
60
|
+
let end = text.length;
|
|
61
|
+
if (text.charCodeAt(end - 1) === 10)
|
|
62
|
+
end--;
|
|
63
|
+
if (text.charCodeAt(end - 1) === 13)
|
|
64
|
+
end--;
|
|
65
|
+
const lineFeed = text.indexOf("\n");
|
|
66
|
+
if (lineFeed !== -1 && lineFeed < end)
|
|
67
|
+
return false;
|
|
68
|
+
const carriageReturn = text.indexOf("\r");
|
|
69
|
+
return carriageReturn === -1 || carriageReturn >= end;
|
|
70
|
+
}
|
|
71
|
+
/** `removeInvisible`, after each U+0085 that ends a line is made a line break, when `nextLines`. */
|
|
72
|
+
function cleanLines(text, nextLines) {
|
|
73
|
+
return removeInvisible(nextLines && text.includes("\x85") ? text.replace(NEXT_LINE, "\n") : text);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Strips a BOM, unifies line endings, and removes terminal escape sequences, control characters
|
|
77
|
+
* other than tab and newline, and the invisible characters of `INVISIBLE`. In a text with no other
|
|
78
|
+
* line break, a U+0085 becomes one (see `NEXT_LINE`).
|
|
15
79
|
*/
|
|
16
80
|
export function normalizeText(raw) {
|
|
17
|
-
|
|
81
|
+
const text = raw.replace(/^/, "");
|
|
82
|
+
return normalizeLines(text, breaksAtNextLine(text));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* `normalizeText` without the BOM: the same on a whole text as on pieces of it cut after line
|
|
86
|
+
* breaks, given `breaksAtNextLine` of the whole text as `nextLines`.
|
|
87
|
+
*/
|
|
88
|
+
function normalizeLines(raw, nextLines) {
|
|
89
|
+
return cleanLines(withoutEscapes(raw.replace(/\r\n?/g, "\n")), nextLines);
|
|
90
|
+
}
|
|
91
|
+
/** `text` without terminal escape sequences. */
|
|
92
|
+
function withoutEscapes(text) {
|
|
18
93
|
// Remove whole sequences first. Dropping only the ESC byte would leave "[31mERROR[0m" behind.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
94
|
+
// U+009B is the one-character form of "ESC [".
|
|
95
|
+
return text.includes("\x1b") || text.includes("\x9b") ? text.replace(ANSI_ESCAPE, "") : text;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* `withoutEscapes`, with a pause after each `piece` characters or so. The sequences are found one
|
|
99
|
+
* after the other, as `replace` finds them, so the result is the same.
|
|
100
|
+
*/
|
|
101
|
+
async function withoutEscapesInPieces(text, slicer, piece) {
|
|
102
|
+
if (!text.includes("\x1b") && !text.includes("\x9b"))
|
|
103
|
+
return text;
|
|
104
|
+
// A copy of its own: during a pause, another ingest may use `ANSI_ESCAPE`, which moves its lastIndex.
|
|
105
|
+
const escape = new RegExp(ANSI_ESCAPE.source, "g");
|
|
106
|
+
const done = [];
|
|
107
|
+
let parts = [];
|
|
108
|
+
// Where the text after the last sequence starts, and where the last pause was.
|
|
109
|
+
let kept = 0;
|
|
110
|
+
let paused = 0;
|
|
111
|
+
for (let found = escape.exec(text); found !== null; found = escape.exec(text)) {
|
|
112
|
+
parts.push(text.slice(kept, found.index));
|
|
113
|
+
kept = escape.lastIndex;
|
|
114
|
+
if (kept - paused >= piece) {
|
|
115
|
+
done.push(parts.join(""));
|
|
116
|
+
parts = [];
|
|
117
|
+
paused = kept;
|
|
118
|
+
await slicer.maybePause();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
parts.push(text.slice(kept));
|
|
122
|
+
done.push(parts.join(""));
|
|
123
|
+
return done.length === 1 ? done[0] : done.join("");
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* `normalizeLines`, a piece of about `piece` characters at a time, with a pause between pieces. A
|
|
127
|
+
* line with no break for megabytes can hold millions of characters or escape sequences to remove,
|
|
128
|
+
* which take seconds in one go. The escape sequences are found in order, as in one go, and the
|
|
129
|
+
* pieces of the last step (`cleanLines`) end where `cutsCleanly` says, so the result is the same.
|
|
130
|
+
*/
|
|
131
|
+
export async function normalizeInPieces(raw, slicer, nextLines, piece = SLICE_CHARACTERS) {
|
|
132
|
+
const text = await withoutEscapesInPieces(raw.replace(/\r\n?/g, "\n"), slicer, piece);
|
|
133
|
+
const parts = [];
|
|
134
|
+
for (let from = 0; from < text.length;) {
|
|
135
|
+
let to = Math.min(text.length, from + piece);
|
|
136
|
+
// Where the next piece starts.
|
|
137
|
+
let next = to;
|
|
138
|
+
while (to < text.length && !cutsCleanly(text, to)) {
|
|
139
|
+
if (text.charCodeAt(to) === 0x85) {
|
|
140
|
+
// A run of U+0085 after U+0080-U+00FF, which no place may cut. `cleanLines` removes all of
|
|
141
|
+
// it, and gives the same on the text before it and after it alone: the run is left out.
|
|
142
|
+
NEXT_LINE_RUN.lastIndex = to;
|
|
143
|
+
NEXT_LINE_RUN.test(text);
|
|
144
|
+
next = NEXT_LINE_RUN.lastIndex;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
next = ++to;
|
|
148
|
+
}
|
|
149
|
+
parts.push(cleanLines(text.slice(from, to), nextLines));
|
|
150
|
+
from = next;
|
|
151
|
+
await slicer.maybePause();
|
|
152
|
+
}
|
|
153
|
+
return parts.length === 1 ? parts[0] : parts.join("");
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Whether `cleanLines` gives the same result on `text` cut before `at` as on it whole. It does
|
|
157
|
+
* unless the cut is between the two halves of a character outside the basic plane, inside a flag,
|
|
158
|
+
* between a soft hyphen and a line break, or before a U+0085 right after U+0080-U+00FF. Only
|
|
159
|
+
* these places are kept whole: a rule that never cut after a soft hyphen or half of a pair would
|
|
160
|
+
* never cut a line of soft hyphens, or of tag characters and emoji in turn, and such a line
|
|
161
|
+
* would be cleaned in one go again.
|
|
162
|
+
*/
|
|
163
|
+
function cutsCleanly(text, at) {
|
|
164
|
+
const before = text.charCodeAt(at - 1);
|
|
165
|
+
const after = text.charCodeAt(at);
|
|
166
|
+
if (isHighSurrogate(before) && isLowSurrogate(after))
|
|
167
|
+
return false;
|
|
168
|
+
if (before === 0xad && after === 0x0a)
|
|
169
|
+
return false;
|
|
170
|
+
if (after === 0x85 && before >= 0x80 && before <= 0xff)
|
|
171
|
+
return false;
|
|
172
|
+
// A flag is 14 units: U+1F3F4, then tag characters, each a pair that starts with U+DB40.
|
|
173
|
+
if (after === 0xdb40 && text.slice(Math.max(0, at - 12), at).includes("\uD83C\uDFF4"))
|
|
174
|
+
return false;
|
|
175
|
+
return true;
|
|
23
176
|
}
|
|
24
177
|
/**
|
|
25
178
|
* Lowercases for case-insensitive search without changing the string's length, so an offset in the
|
|
@@ -42,11 +195,74 @@ export function foldCase(text) {
|
|
|
42
195
|
/** The first and the second half of a character outside the basic plane, as JavaScript holds it. */
|
|
43
196
|
const isHighSurrogate = (code) => code >= 0xd800 && code <= 0xdbff;
|
|
44
197
|
const isLowSurrogate = (code) => code >= 0xdc00 && code <= 0xdfff;
|
|
198
|
+
/**
|
|
199
|
+
* The first `end` UTF-16 units of `text`, one fewer when the last of them would be the first half
|
|
200
|
+
* of a character outside the basic plane (an emoji). Half of one is not text: JSON writes it as
|
|
201
|
+
* `\ud83d`, and an API that checks its input (Claude's) refuses the request.
|
|
202
|
+
*/
|
|
203
|
+
export function sliceWhole(text, end) {
|
|
204
|
+
const at = Math.max(0, Math.min(text.length, Math.trunc(end)));
|
|
205
|
+
return at > 0 && at < text.length && isHighSurrogate(text.charCodeAt(at - 1)) ? text.slice(0, at - 1) : text.slice(0, at);
|
|
206
|
+
}
|
|
207
|
+
/** Half of a character outside the basic plane, on its own. */
|
|
208
|
+
const LONE_SURROGATE = /[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/g;
|
|
209
|
+
/**
|
|
210
|
+
* `text` with each half of a character that is on its own (an emoji cut in two) made a replacement
|
|
211
|
+
* character, as `String.prototype.toWellFormed` does. 0.5.0 cut some strings that way, and kept them:
|
|
212
|
+
* log templates in the metadata, and search windows in tool rounds. Claude's API refuses a request
|
|
213
|
+
* that holds one. Text that is whole comes back as it is.
|
|
214
|
+
*/
|
|
215
|
+
export function wellFormed(text) {
|
|
216
|
+
return /[\ud800-\udfff]/.test(text) ? text.replace(LONE_SURROGATE, "\ufffd") : text;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* A JSON value with `wellFormed` applied to every string in it, keys included. The same value, not
|
|
220
|
+
* a copy, when nothing in it needed that.
|
|
221
|
+
*/
|
|
222
|
+
export function wellFormedJson(value) {
|
|
223
|
+
if (typeof value === "string")
|
|
224
|
+
return wellFormed(value);
|
|
225
|
+
if (Array.isArray(value)) {
|
|
226
|
+
let changed = false;
|
|
227
|
+
const items = value.map((item) => {
|
|
228
|
+
const fixed = wellFormedJson(item);
|
|
229
|
+
if (fixed !== item)
|
|
230
|
+
changed = true;
|
|
231
|
+
return fixed;
|
|
232
|
+
});
|
|
233
|
+
return (changed ? items : value);
|
|
234
|
+
}
|
|
235
|
+
if (value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
|
|
236
|
+
let changed = false;
|
|
237
|
+
const entries = Object.entries(value).map(([key, item]) => {
|
|
238
|
+
const fixedKey = wellFormed(key);
|
|
239
|
+
const fixed = wellFormedJson(item);
|
|
240
|
+
if (fixedKey !== key || fixed !== item)
|
|
241
|
+
changed = true;
|
|
242
|
+
return [fixedKey, fixed];
|
|
243
|
+
});
|
|
244
|
+
return (changed ? Object.fromEntries(entries) : value);
|
|
245
|
+
}
|
|
246
|
+
return value;
|
|
247
|
+
}
|
|
45
248
|
/**
|
|
46
249
|
* Splits lines longer than `limit`, preferring a break after whitespace or punctuation near the
|
|
47
250
|
* end of each piece. Minified JSON or a PDF paragraph becomes many addressable lines.
|
|
48
251
|
*/
|
|
49
252
|
export function wrapLongLines(text, limit = MAX_LINE_CHARACTERS) {
|
|
253
|
+
// Most files have no long line: then the text is used as it is, without splitting and joining it.
|
|
254
|
+
let longest = 0;
|
|
255
|
+
let start = 0;
|
|
256
|
+
for (let end = text.indexOf("\n");; end = text.indexOf("\n", start)) {
|
|
257
|
+
const stop = end === -1 ? text.length : end;
|
|
258
|
+
if (stop - start > longest)
|
|
259
|
+
longest = stop - start;
|
|
260
|
+
if (end === -1 || longest > limit)
|
|
261
|
+
break;
|
|
262
|
+
start = end + 1;
|
|
263
|
+
}
|
|
264
|
+
if (longest <= limit)
|
|
265
|
+
return { text, wrapped: 0 };
|
|
50
266
|
let wrapped = 0;
|
|
51
267
|
const lines = text.split("\n");
|
|
52
268
|
const out = [];
|
|
@@ -109,13 +325,19 @@ const SYMBOL = 1; // Dashes, quotes, arrows, box drawing, and anything unclassif
|
|
|
109
325
|
* of random letters in a single case with no digits (about 70% of the real count).
|
|
110
326
|
*/
|
|
111
327
|
export function estimateTokens(text) {
|
|
112
|
-
|
|
328
|
+
return Math.ceil(tokensIn(text, 0, text.length, 0));
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* The tokens of `text` from `from` to `to`, added to `tokens`. Every count starts again after a line
|
|
332
|
+
* break, so a text cut after line breaks gives, piece by piece, the sum it gives whole.
|
|
333
|
+
*/
|
|
334
|
+
function tokensIn(text, from, to, tokens) {
|
|
113
335
|
// The current run of ASCII letters: its length since the last case change, and its casing.
|
|
114
336
|
let piece = 0;
|
|
115
337
|
let capitalsInARow = 0;
|
|
116
338
|
let previousWasLower = false;
|
|
117
339
|
let previous = 0; // 1 = space, 2 = ASCII punctuation, 0 = anything else
|
|
118
|
-
for (let index =
|
|
340
|
+
for (let index = from; index < to; index++) {
|
|
119
341
|
const code = text.charCodeAt(index);
|
|
120
342
|
if ((code >= 97 && code <= 122) || (code >= 65 && code <= 90)) {
|
|
121
343
|
const capital = code <= 90;
|
|
@@ -198,7 +420,7 @@ export function estimateTokens(text) {
|
|
|
198
420
|
else
|
|
199
421
|
tokens += KANA;
|
|
200
422
|
}
|
|
201
|
-
return
|
|
423
|
+
return tokens;
|
|
202
424
|
}
|
|
203
425
|
/**
|
|
204
426
|
* The size of a text in one pass: its UTF-8 bytes, and the bytes it takes as a string in a JSON
|
|
@@ -208,9 +430,14 @@ export function estimateTokens(text) {
|
|
|
208
430
|
* quarter or more, a novel by a hundredth.
|
|
209
431
|
*/
|
|
210
432
|
export function textSizes(text) {
|
|
433
|
+
const { utf8, escapes } = sizesIn(text, 0, text.length);
|
|
434
|
+
return { utf8, json: utf8 + escapes + 2 };
|
|
435
|
+
}
|
|
436
|
+
/** UTF-8 bytes and JSON escapes of `text` from `from` to `to`, which must not split a surrogate pair. */
|
|
437
|
+
function sizesIn(text, from, to) {
|
|
211
438
|
let utf8 = 0;
|
|
212
439
|
let escapes = 0;
|
|
213
|
-
for (let index =
|
|
440
|
+
for (let index = from; index < to; index++) {
|
|
214
441
|
const code = text.charCodeAt(index);
|
|
215
442
|
if (code < 0x80) {
|
|
216
443
|
utf8 += 1;
|
|
@@ -222,7 +449,7 @@ export function textSizes(text) {
|
|
|
222
449
|
else if (code < 0x800) {
|
|
223
450
|
utf8 += 2;
|
|
224
451
|
}
|
|
225
|
-
else if (isHighSurrogate(code) && isLowSurrogate(text.charCodeAt(index + 1))) {
|
|
452
|
+
else if (isHighSurrogate(code) && index + 1 < to && isLowSurrogate(text.charCodeAt(index + 1))) {
|
|
226
453
|
utf8 += 4;
|
|
227
454
|
index++;
|
|
228
455
|
}
|
|
@@ -233,7 +460,80 @@ export function textSizes(text) {
|
|
|
233
460
|
escapes += 3;
|
|
234
461
|
}
|
|
235
462
|
}
|
|
236
|
-
return { utf8,
|
|
463
|
+
return { utf8, escapes };
|
|
464
|
+
}
|
|
465
|
+
/** Characters worked on between two looks at the clock while ingesting. */
|
|
466
|
+
const SLICE_CHARACTERS = 1 << 18;
|
|
467
|
+
/**
|
|
468
|
+
* The text cut into slices of about 256K characters, each ending after a line break (the last
|
|
469
|
+
* one at the end of the text), as `[from, to)` offsets.
|
|
470
|
+
*/
|
|
471
|
+
function* lineSlices(text) {
|
|
472
|
+
for (let from = 0; from < text.length;) {
|
|
473
|
+
let to = Math.min(text.length, from + SLICE_CHARACTERS);
|
|
474
|
+
if (to < text.length) {
|
|
475
|
+
const newline = text.indexOf("\n", to - 1);
|
|
476
|
+
to = newline === -1 ? text.length : newline + 1;
|
|
477
|
+
}
|
|
478
|
+
yield [from, to];
|
|
479
|
+
from = to;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* `estimateTokens` and `textSizes` of a text, the same numbers, worked out a slice at a time so
|
|
484
|
+
* that other requests get a turn while a large upload is measured. Slices end after a line break.
|
|
485
|
+
*/
|
|
486
|
+
export async function measureText(text, slicer) {
|
|
487
|
+
let tokens = 0;
|
|
488
|
+
let utf8 = 0;
|
|
489
|
+
let escapes = 0;
|
|
490
|
+
for (const [from, to] of lineSlices(text)) {
|
|
491
|
+
tokens = tokensIn(text, from, to, tokens);
|
|
492
|
+
const sizes = sizesIn(text, from, to);
|
|
493
|
+
utf8 += sizes.utf8;
|
|
494
|
+
escapes += sizes.escapes;
|
|
495
|
+
await slicer.maybePause();
|
|
496
|
+
}
|
|
497
|
+
return { tokens: Math.ceil(tokens), utf8, json: utf8 + escapes + 2 };
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* What ingest makes of extracted text, a slice at a time: `normalizeText`, then `wrapLongLines`,
|
|
501
|
+
* then the lines (a line break at the very end does not start another line). The same results as
|
|
502
|
+
* doing each in one go: no step of `normalizeText` reaches across a line break, and whether a U+0085
|
|
503
|
+
* ends lines is decided once, for the whole text. A slice that runs far past its size holds a long
|
|
504
|
+
* line: it is cleaned in pieces too. `onProgress` is told the characters of `raw` cleaned so far,
|
|
505
|
+
* after each slice; splitting the lines after that is quick, and is not counted.
|
|
506
|
+
*/
|
|
507
|
+
export async function prepareText(raw, slicer, onProgress) {
|
|
508
|
+
const start = raw.charCodeAt(0) === 0xfeff ? 1 : 0;
|
|
509
|
+
const body = start === 1 ? raw.slice(1) : raw;
|
|
510
|
+
const nextLines = breaksAtNextLine(body);
|
|
511
|
+
const parts = [];
|
|
512
|
+
// A clean text (most logs) comes back as it is: joining its slices would copy all of it.
|
|
513
|
+
let changed = false;
|
|
514
|
+
for (const [from, to] of lineSlices(body)) {
|
|
515
|
+
const slice = body.slice(from, to);
|
|
516
|
+
const normalized = slice.length > 2 * SLICE_CHARACTERS ? await normalizeInPieces(slice, slicer, nextLines) : normalizeLines(slice, nextLines);
|
|
517
|
+
if (normalized !== slice)
|
|
518
|
+
changed = true;
|
|
519
|
+
parts.push(normalized);
|
|
520
|
+
onProgress?.(start + to, raw.length);
|
|
521
|
+
await slicer.maybePause();
|
|
522
|
+
}
|
|
523
|
+
const { text, wrapped } = wrapLongLines(!changed ? body : parts.length === 1 ? parts[0] : parts.join(""));
|
|
524
|
+
parts.length = 0;
|
|
525
|
+
await slicer.maybePause();
|
|
526
|
+
const lines = [];
|
|
527
|
+
for (const [from, to] of lineSlices(text)) {
|
|
528
|
+
const piece = text.slice(from, to).split("\n");
|
|
529
|
+
// A slice that ends with a line break splits into one empty string too many.
|
|
530
|
+
if (text.charCodeAt(to - 1) === 10)
|
|
531
|
+
piece.pop();
|
|
532
|
+
for (const line of piece)
|
|
533
|
+
lines.push(line);
|
|
534
|
+
await slicer.maybePause();
|
|
535
|
+
}
|
|
536
|
+
return { text, wrapped, lines };
|
|
237
537
|
}
|
|
238
538
|
/** UTF-8 byte length without allocating an encoded copy. */
|
|
239
539
|
export function utf8Bytes(text) {
|
package/dist/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC;;;;;;GAMG;AACH,4CAA4C;AAC5C,MAAM,WAAW,GAAG,kFAAkF,CAAC;AAEvG;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACzD,8FAA8F;IAC9F,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAChE,4CAA4C;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,mCAAmC,EAAE,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9F,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC/C,+FAA+F;IAC/F,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE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,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,mEAAmE;IACnE,QAAQ,CAAC,IAAY,EAAE,EAAU;QAC/B,MAAM,GAAG,GAAa,EAAE,CAAC;QACzB,KAAK,IAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;YAChF,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACF"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -4,10 +4,12 @@ import type { Budget, GenerateText, ProgressListener, ToolResult, ToolSet } from
|
|
|
4
4
|
/** The most pages one `view_pages` call shows. A page costs a model about 530 tokens. */
|
|
5
5
|
export declare const MAX_VIEW_PAGES = 5;
|
|
6
6
|
/**
|
|
7
|
-
* The time the regex searches of one tool set (one question, in `
|
|
7
|
+
* The time the regex searches of one tool set (one question, in `askWithFiles`) may take together,
|
|
8
8
|
* unless `regexBudgetMs` says otherwise. An ordinary search of a 60 MB log takes about 0.15 s.
|
|
9
9
|
*/
|
|
10
10
|
export declare const REGEX_BUDGET_MS = 6000;
|
|
11
|
+
/** A result is never cut below this, whatever room a caller names: less holds no line of a file. */
|
|
12
|
+
export declare const LEAST_RESULT_CHARACTERS = 600;
|
|
11
13
|
/**
|
|
12
14
|
* How many times one document is read whole by the tools of one tool set (one question, in
|
|
13
15
|
* `askWithFiles`), unless `maxWholeDocumentReads` says otherwise. One read of a large file is
|
|
@@ -21,11 +23,69 @@ export declare const TOOL_NAMES: {
|
|
|
21
23
|
readonly analyze: "analyze_whole_document";
|
|
22
24
|
readonly view: "view_pages";
|
|
23
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* The result of a whole-document read within `limit` characters: its answer is cut at the end,
|
|
28
|
+
* and says so, rather than the result being cut as JSON, which loses what the other fields say.
|
|
29
|
+
*/
|
|
30
|
+
export declare function fitAnswer(result: ToolResult, limit: number): ToolResult;
|
|
31
|
+
/**
|
|
32
|
+
* A call's arguments as its tool reads them, with the defaults filled in: two calls with the same
|
|
33
|
+
* key get the same result from a file that has not changed. Undefined for a tool whose calls are
|
|
34
|
+
* not compared (a whole-file read has a count of its own; a look at pages returns a file).
|
|
35
|
+
*/
|
|
36
|
+
export declare function toolCallKey(name: string, args: Record<string, unknown>): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* When an earlier call's result already holds all that `call` would return, and is still in the
|
|
39
|
+
* conversation in full: a short result that says so, in place of running the call again. A result
|
|
40
|
+
* that was cut to the room it had, or replaced by a stand-in, or failed, is not pointed to: the call
|
|
41
|
+
* is run, and may get more. A read of lines inside a read that is shown in full is pointed to.
|
|
42
|
+
* `stored` is true for a result in the tool rounds of an earlier question, which an older version
|
|
43
|
+
* may have written: 0.5.0 cut the text of a read of one long line without saying so (no
|
|
44
|
+
* `text_cut`), so a read of one line from there is not taken as shown in full.
|
|
45
|
+
*/
|
|
46
|
+
export declare function alreadyShown(call: {
|
|
47
|
+
name: string;
|
|
48
|
+
args: Record<string, unknown>;
|
|
49
|
+
}, earlier: {
|
|
50
|
+
call: {
|
|
51
|
+
name: string;
|
|
52
|
+
args: Record<string, unknown>;
|
|
53
|
+
};
|
|
54
|
+
result: ToolResult;
|
|
55
|
+
}, stored?: boolean): ToolResult | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* A hint added to the error of a search that failed twice in a row in the same mode, so that the
|
|
58
|
+
* model tries another way instead of sending the same kind of call a third time.
|
|
59
|
+
*/
|
|
60
|
+
export declare function repeatedFailureHint(call: {
|
|
61
|
+
name: string;
|
|
62
|
+
args: Record<string, unknown>;
|
|
63
|
+
}): string;
|
|
64
|
+
/**
|
|
65
|
+
* The tool and mode of a search, to tell whether two failures in a row were of the same kind.
|
|
66
|
+
* Undefined for the other tools: their errors say what to do (a whole-file read that is not made
|
|
67
|
+
* again, a page that does not exist), and a hint would only blur that.
|
|
68
|
+
*/
|
|
69
|
+
export declare function failureKind(call: {
|
|
70
|
+
name: string;
|
|
71
|
+
args: Record<string, unknown>;
|
|
72
|
+
}): string | undefined;
|
|
24
73
|
/**
|
|
25
74
|
* What a finished tool call found, as a suffix for its `describe()` label, for a steps list:
|
|
26
75
|
* "Search app.log (exact) for “timeout”" + " — 12 matching lines".
|
|
27
76
|
*/
|
|
28
77
|
export declare function toolResultSummary(label: string, result: ToolResult): string;
|
|
78
|
+
/**
|
|
79
|
+
* A step, or a label of one, as one line of plain text. Steps quote what the model sent (a query, a
|
|
80
|
+
* task, the name of a tool, arguments that were not JSON), and they reach users' screens: the
|
|
81
|
+
* invisible characters that file text and names lose are dropped (`removeInvisible`: text-direction
|
|
82
|
+
* overrides and isolates, zero-width spaces, tag characters), a line break, a tab or another control
|
|
83
|
+
* character becomes one space with the blanks around it, and "](" gets a space, so that a markdown
|
|
84
|
+
* link or picture in a query stays text. A line without them is unchanged.
|
|
85
|
+
*/
|
|
86
|
+
export declare function stepLine(text: string): string;
|
|
87
|
+
/** An unknown tool's name as a step or an error quotes it: the model chose it, at any length. */
|
|
88
|
+
export declare const unknownToolName: (name: string) => string;
|
|
29
89
|
export declare function createDocumentTools(options: {
|
|
30
90
|
/** Loads a document the tools may access. Return undefined for anything out of scope. */
|
|
31
91
|
load(documentId: string): Promise<DocumentSource | undefined>;
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4D,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4D,KAAK,cAAc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