@absolutejs/ai 0.0.57 → 0.0.58
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 +6 -0
- package/README.md +32 -0
- package/changelog.json +17 -0
- package/dist/ai/index.js +163 -5
- package/dist/ai/index.js.map +6 -5
- package/dist/src/ai/index.d.ts +3 -0
- package/dist/src/ai/prepareTextInput.d.ts +12 -0
- package/dist/src/ai/streamAIWithTools.d.ts +4 -0
- package/dist/src/ai/textSource.d.ts +19 -0
- package/package.json +1 -1
package/dist/src/ai/index.d.ts
CHANGED
|
@@ -41,3 +41,6 @@ export { AIInputError, inspectAIInput } from "./inputCapacity";
|
|
|
41
41
|
export type { AIModelLimits, AIInputCapacity } from "./inputCapacity";
|
|
42
42
|
export { prepareAITextInput } from "./prepareTextInput";
|
|
43
43
|
export type { PreparedAITextInput, PrepareAITextInputOptions, } from "./prepareTextInput";
|
|
44
|
+
export { createAITextSource } from "./textSource";
|
|
45
|
+
export type { AITextPassage, AITextSource } from "./textSource";
|
|
46
|
+
export type { AITextPreparationCheckpoint } from "./prepareTextInput";
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import type { AIProviderConfig, AIProviderStreamParams, AIUsage } from "../../types/ai";
|
|
2
|
+
export type AITextPreparationCheckpoint = {
|
|
3
|
+
version: 1;
|
|
4
|
+
taskHash: string;
|
|
5
|
+
prefixHash: string;
|
|
6
|
+
processedCharacters: number;
|
|
7
|
+
sectionsProcessed: number;
|
|
8
|
+
notes: string;
|
|
9
|
+
};
|
|
2
10
|
export type PreparedAITextInput = {
|
|
3
11
|
params: AIProviderStreamParams;
|
|
4
12
|
compacted: boolean;
|
|
5
13
|
sectionsProcessed: number;
|
|
6
14
|
};
|
|
7
15
|
export type PrepareAITextInputOptions = {
|
|
16
|
+
/** Reuse only a server-owned checkpoint. Originals and task fingerprints are validated. */
|
|
17
|
+
checkpoint?: AITextPreparationCheckpoint;
|
|
18
|
+
/** Save after each finished section, before the next model call. Never accept client-supplied notes. */
|
|
19
|
+
onCheckpoint?: (checkpoint: AITextPreparationCheckpoint) => void | Promise<void>;
|
|
8
20
|
/** Persist originals BEFORE calling. Returned notes are not a replacement for source storage. */
|
|
9
21
|
onProgress?: (progress: {
|
|
10
22
|
processedCharacters: number;
|
|
@@ -3,6 +3,10 @@ import { type GenerateAIOptions, type GenerateAIToolCall } from "./generateAI";
|
|
|
3
3
|
export type StreamAIWithToolsOptions = Omit<GenerateAIOptions, "tools" | "toolChoice"> & {
|
|
4
4
|
/** Tools the model may call — each with a `handler` the loop runs on its behalf. */
|
|
5
5
|
tools: AIToolMap;
|
|
6
|
+
/** Stop immediately after one of these tools executes successfully; do not generate an extra reply. */
|
|
7
|
+
stopAfterTools?: string[];
|
|
8
|
+
/** Count every model request, including added tool results, against provider capacity. */
|
|
9
|
+
validateInput?: boolean;
|
|
6
10
|
/** Max model⇄tool round-trips before forcing a final answer. Default 8. */
|
|
7
11
|
maxTurns?: number;
|
|
8
12
|
toolChoice?: AIProviderToolChoice;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AIProviderMessage, AIToolMap } from "../../types/ai";
|
|
2
|
+
export type AITextPassage = {
|
|
3
|
+
sourceId: string;
|
|
4
|
+
role: AIProviderMessage["role"];
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
totalCharacters: number;
|
|
8
|
+
text: string;
|
|
9
|
+
};
|
|
10
|
+
/** Session-scoped, read-only access to original text. No network or model calls.
|
|
11
|
+
* IDs/UTF-16 offsets stay stable when later messages are appended. Results carry
|
|
12
|
+
* verbatim source, not generated summaries. Persist originals separately.
|
|
13
|
+
*/
|
|
14
|
+
export declare const createAITextSource: (messages: readonly AIProviderMessage[]) => {
|
|
15
|
+
search: (query: string, sourceId?: string) => AITextPassage[];
|
|
16
|
+
read: (sourceId: string, start?: number, length?: number) => AITextPassage;
|
|
17
|
+
tools: AIToolMap;
|
|
18
|
+
};
|
|
19
|
+
export type AITextSource = ReturnType<typeof createAITextSource>;
|