extrait 0.6.1 → 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/README.md +3 -1
- package/dist/generate-shared.d.ts +8 -2
- package/dist/index.cjs +325 -71
- package/dist/index.d.ts +1 -1
- package/dist/index.js +325 -71
- package/dist/parse.d.ts +1 -1
- package/dist/providers/mcp-runtime.d.ts +1 -1
- package/dist/structured.d.ts +3 -3
- package/dist/types.d.ts +30 -4
- package/package.json +7 -13
package/dist/parse.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import type { ParseLLMOutputOptions, ParseLLMOutputResult } from "./types";
|
|
3
3
|
export declare function parseLLMOutput<TSchema extends z.ZodTypeAny>(output: string, schema: TSchema, options?: ParseLLMOutputOptions): ParseLLMOutputResult<z.infer<TSchema>>;
|
|
4
|
-
export declare function formatZodIssues(issues: z.ZodIssue[]): string;
|
|
4
|
+
export declare function formatZodIssues(issues: z.core.$ZodIssue[]): string;
|
|
@@ -27,7 +27,7 @@ export interface ExecutedMCPToolCall {
|
|
|
27
27
|
call: LLMToolCall;
|
|
28
28
|
execution: LLMToolExecution;
|
|
29
29
|
}
|
|
30
|
-
export declare const DEFAULT_MAX_TOOL_ROUNDS =
|
|
30
|
+
export declare const DEFAULT_MAX_TOOL_ROUNDS = 100;
|
|
31
31
|
export declare function resolveMCPToolset(clients: MCPToolClient[] | undefined): Promise<ResolvedMCPToolset>;
|
|
32
32
|
export declare function toProviderFunctionTools(toolset: ResolvedMCPToolset): Array<Record<string, unknown>> | undefined;
|
|
33
33
|
export declare function executeMCPToolCalls(calls: RuntimeToolCall[], toolset: ResolvedMCPToolset, context: ExecuteMCPToolCallsOptions): Promise<ExecutedMCPToolCall[]>;
|
package/dist/structured.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class StructuredParseError extends Error implements StructuredErr
|
|
|
5
5
|
readonly text: string;
|
|
6
6
|
readonly reasoning: string;
|
|
7
7
|
readonly candidates: string[];
|
|
8
|
-
readonly zodIssues?: z.ZodIssue[];
|
|
8
|
+
readonly zodIssues?: z.core.$ZodIssue[];
|
|
9
9
|
readonly repairLog?: string[];
|
|
10
10
|
readonly attempt: number;
|
|
11
11
|
constructor(input: {
|
|
@@ -13,7 +13,7 @@ export declare class StructuredParseError extends Error implements StructuredErr
|
|
|
13
13
|
text: string;
|
|
14
14
|
reasoning: string;
|
|
15
15
|
candidates: string[];
|
|
16
|
-
zodIssues?: z.ZodIssue[];
|
|
16
|
+
zodIssues?: z.core.$ZodIssue[];
|
|
17
17
|
repairLog?: string[];
|
|
18
18
|
attempt: number;
|
|
19
19
|
});
|
|
@@ -57,7 +57,7 @@ export declare const DEFAULT_SELF_HEAL_BY_MODE: {
|
|
|
57
57
|
export declare function buildDefaultStructuredPrompt(task: string, options?: BuildDefaultStructuredPromptOptions): string;
|
|
58
58
|
interface SelfHealPromptInput {
|
|
59
59
|
rawOutput: string;
|
|
60
|
-
issues: z.ZodIssue[];
|
|
60
|
+
issues: z.core.$ZodIssue[];
|
|
61
61
|
schema: z.ZodTypeAny;
|
|
62
62
|
schemaInstruction?: string;
|
|
63
63
|
selectedOutput?: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export interface CandidateDiagnostics {
|
|
|
63
63
|
selected: boolean;
|
|
64
64
|
stage: "repair" | "parse" | "validate" | "success";
|
|
65
65
|
message?: string;
|
|
66
|
-
zodIssues?: z.ZodIssue[];
|
|
66
|
+
zodIssues?: z.core.$ZodIssue[];
|
|
67
67
|
}
|
|
68
68
|
export interface ThinkBlock {
|
|
69
69
|
id: string;
|
|
@@ -90,7 +90,7 @@ export interface ParseLLMOutputResult<T> {
|
|
|
90
90
|
candidates: ExtractionCandidate[];
|
|
91
91
|
diagnostics: CandidateDiagnostics[];
|
|
92
92
|
errors: PipelineError[];
|
|
93
|
-
zodIssues: z.ZodIssue[];
|
|
93
|
+
zodIssues: z.core.$ZodIssue[];
|
|
94
94
|
}
|
|
95
95
|
export interface MCPToolSchema {
|
|
96
96
|
type?: string;
|
|
@@ -139,6 +139,16 @@ export interface LLMToolCallRef {
|
|
|
139
139
|
arguments: string;
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
+
export interface ReasoningBlock {
|
|
143
|
+
turnIndex: number;
|
|
144
|
+
text: string;
|
|
145
|
+
}
|
|
146
|
+
export interface StreamTurnTransition {
|
|
147
|
+
turnIndex: number;
|
|
148
|
+
kind: "reasoningComplete" | "toolCallsEmit" | "toolResultsReceived" | "streamEnd";
|
|
149
|
+
reasoningText?: string;
|
|
150
|
+
toolCalls?: LLMToolCall[];
|
|
151
|
+
}
|
|
142
152
|
export interface LLMMessage {
|
|
143
153
|
role: "system" | "user" | "assistant" | "tool";
|
|
144
154
|
content: LLMMessageContent;
|
|
@@ -162,6 +172,7 @@ export interface LLMRequest {
|
|
|
162
172
|
transformToolCallParams?: LLMToolCallParamsTransformer;
|
|
163
173
|
unknownToolError?: (toolName: string) => string;
|
|
164
174
|
toolDebug?: boolean | LLMToolDebugOptions;
|
|
175
|
+
onTurnTransition?: (transition: StreamTurnTransition) => void;
|
|
165
176
|
body?: Record<string, unknown>;
|
|
166
177
|
signal?: AbortSignal;
|
|
167
178
|
}
|
|
@@ -174,6 +185,7 @@ export interface LLMUsage {
|
|
|
174
185
|
export interface LLMResponse {
|
|
175
186
|
text: string;
|
|
176
187
|
reasoning?: string;
|
|
188
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
177
189
|
raw?: unknown;
|
|
178
190
|
usage?: LLMUsage;
|
|
179
191
|
finishReason?: string;
|
|
@@ -183,6 +195,8 @@ export interface LLMResponse {
|
|
|
183
195
|
export interface LLMStreamChunk {
|
|
184
196
|
textDelta: string;
|
|
185
197
|
reasoningDelta?: string;
|
|
198
|
+
turnIndex?: number;
|
|
199
|
+
toolCalls?: LLMToolCall[];
|
|
186
200
|
raw?: unknown;
|
|
187
201
|
done?: boolean;
|
|
188
202
|
usage?: LLMUsage;
|
|
@@ -317,6 +331,7 @@ export interface StructuredStreamDelta {
|
|
|
317
331
|
export interface StructuredStreamSnapshot<T = unknown> {
|
|
318
332
|
text: string;
|
|
319
333
|
reasoning: string;
|
|
334
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
320
335
|
data: StructuredStreamData<T> | null;
|
|
321
336
|
}
|
|
322
337
|
export interface StructuredStreamEvent<T = unknown> {
|
|
@@ -325,10 +340,13 @@ export interface StructuredStreamEvent<T = unknown> {
|
|
|
325
340
|
done: boolean;
|
|
326
341
|
usage?: LLMUsage;
|
|
327
342
|
finishReason?: string;
|
|
343
|
+
turnIndex?: number;
|
|
344
|
+
toolCalls?: LLMToolCall[];
|
|
328
345
|
}
|
|
329
346
|
export interface StructuredStreamOptions<T = unknown> {
|
|
330
347
|
enabled?: boolean;
|
|
331
348
|
onData?: (event: StructuredStreamEvent<T>) => void;
|
|
349
|
+
onTurnTransition?: (transition: StreamTurnTransition) => void;
|
|
332
350
|
to?: "stdout";
|
|
333
351
|
}
|
|
334
352
|
export type StructuredStreamInput<T = unknown> = boolean | StructuredStreamOptions<T>;
|
|
@@ -339,6 +357,7 @@ export interface GenerateStreamDelta {
|
|
|
339
357
|
export interface GenerateStreamSnapshot {
|
|
340
358
|
text: string;
|
|
341
359
|
reasoning: string;
|
|
360
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
342
361
|
}
|
|
343
362
|
export interface GenerateStreamEvent {
|
|
344
363
|
delta: GenerateStreamDelta;
|
|
@@ -346,10 +365,13 @@ export interface GenerateStreamEvent {
|
|
|
346
365
|
done: boolean;
|
|
347
366
|
usage?: LLMUsage;
|
|
348
367
|
finishReason?: string;
|
|
368
|
+
turnIndex?: number;
|
|
369
|
+
toolCalls?: LLMToolCall[];
|
|
349
370
|
}
|
|
350
371
|
export interface GenerateStreamOptions {
|
|
351
372
|
enabled?: boolean;
|
|
352
373
|
onData?: (event: GenerateStreamEvent) => void;
|
|
374
|
+
onTurnTransition?: (transition: StreamTurnTransition) => void;
|
|
353
375
|
to?: "stdout";
|
|
354
376
|
}
|
|
355
377
|
export type GenerateStreamInput = boolean | GenerateStreamOptions;
|
|
@@ -391,10 +413,11 @@ export interface StructuredAttempt<T> {
|
|
|
391
413
|
json: unknown | null;
|
|
392
414
|
candidates: string[];
|
|
393
415
|
repairLog: string[];
|
|
394
|
-
zodIssues: z.ZodIssue[];
|
|
416
|
+
zodIssues: z.core.$ZodIssue[];
|
|
395
417
|
success: boolean;
|
|
396
418
|
usage?: LLMUsage;
|
|
397
419
|
finishReason?: string;
|
|
420
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
398
421
|
parsed: ParseLLMOutputResult<T>;
|
|
399
422
|
}
|
|
400
423
|
export interface GenerateAttempt {
|
|
@@ -404,6 +427,7 @@ export interface GenerateAttempt {
|
|
|
404
427
|
reasoning: string;
|
|
405
428
|
usage?: LLMUsage;
|
|
406
429
|
finishReason?: string;
|
|
430
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
407
431
|
}
|
|
408
432
|
export interface StructuredResult<T> {
|
|
409
433
|
data: T;
|
|
@@ -413,6 +437,7 @@ export interface StructuredResult<T> {
|
|
|
413
437
|
attempts: StructuredAttempt<T>[];
|
|
414
438
|
usage?: LLMUsage;
|
|
415
439
|
finishReason?: string;
|
|
440
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
416
441
|
}
|
|
417
442
|
export interface GenerateResult {
|
|
418
443
|
text: string;
|
|
@@ -420,13 +445,14 @@ export interface GenerateResult {
|
|
|
420
445
|
attempts: GenerateAttempt[];
|
|
421
446
|
usage?: LLMUsage;
|
|
422
447
|
finishReason?: string;
|
|
448
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
423
449
|
}
|
|
424
450
|
export interface StructuredError {
|
|
425
451
|
name: "StructuredParseError";
|
|
426
452
|
text: string;
|
|
427
453
|
reasoning: string;
|
|
428
454
|
candidates: string[];
|
|
429
|
-
zodIssues?: z.ZodIssue[];
|
|
455
|
+
zodIssues?: z.core.$ZodIssue[];
|
|
430
456
|
repairLog?: string[];
|
|
431
457
|
attempt: number;
|
|
432
458
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extrait",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/tterrasson/extrait.git"
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"module": "./dist/index.js",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
12
|
-
"jsonrepair": "^3.
|
|
13
|
-
"zod": "^4.3
|
|
12
|
+
"jsonrepair": "^3.14.0",
|
|
13
|
+
"zod": "^4.4.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/bun": "^1.3.
|
|
16
|
+
"@types/bun": "^1.3.13",
|
|
17
17
|
"@types/sharp": "^0.32.0",
|
|
18
18
|
"typescript": "^5.9.3"
|
|
19
19
|
},
|
|
@@ -34,9 +34,6 @@
|
|
|
34
34
|
"LICENSE"
|
|
35
35
|
],
|
|
36
36
|
"license": "MIT",
|
|
37
|
-
"overrides": {
|
|
38
|
-
"zod": "^4.3.6"
|
|
39
|
-
},
|
|
40
37
|
"peerDependencies": {
|
|
41
38
|
"sharp": "^0.34.5"
|
|
42
39
|
},
|
|
@@ -45,20 +42,17 @@
|
|
|
45
42
|
"optional": true
|
|
46
43
|
}
|
|
47
44
|
},
|
|
48
|
-
"resolutions": {
|
|
49
|
-
"zod": "^4.3.6"
|
|
50
|
-
},
|
|
51
45
|
"scripts": {
|
|
52
46
|
"dev": "bun run examples/runner.ts",
|
|
53
|
-
"build": "bun run build:esm && bun run build:cjs",
|
|
47
|
+
"build": "bun run build:types && bun run build:esm && bun run build:cjs",
|
|
54
48
|
"build:esm": "bun build ./src/index.ts --outfile ./dist/index.js --target node --format esm --packages external",
|
|
55
49
|
"build:cjs": "bun build ./src/index.ts --outfile ./dist/index.cjs --target node --format cjs --packages external",
|
|
56
50
|
"build:types": "bunx tsc -p tsconfig.build.json",
|
|
57
51
|
"lint": "bunx tsc -p tsconfig.lint.json",
|
|
58
|
-
"prepublishOnly": "bun run lint && bun run build
|
|
52
|
+
"prepublishOnly": "bun run lint && bun run build",
|
|
59
53
|
"test": "bun test tests/ --reporter=dots --only-failures",
|
|
60
54
|
"typecheck": "bunx tsc --noEmit",
|
|
61
|
-
"pack": "bun run build
|
|
55
|
+
"pack": "bun run build && npm pack"
|
|
62
56
|
},
|
|
63
57
|
"type": "module",
|
|
64
58
|
"types": "./dist/index.d.ts"
|