extrait 0.6.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/README.md +3 -1
- package/dist/generate-shared.d.ts +8 -2
- package/dist/index.cjs +384 -73
- package/dist/index.d.ts +1 -1
- package/dist/index.js +384 -73
- 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 +32 -5
- package/package.json +8 -14
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,17 +139,28 @@ 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;
|
|
145
155
|
[key: string]: unknown;
|
|
146
156
|
}
|
|
157
|
+
export type LLMReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "max";
|
|
147
158
|
export interface LLMRequest {
|
|
148
159
|
prompt?: string;
|
|
149
160
|
systemPrompt?: string;
|
|
150
161
|
messages?: LLMMessage[];
|
|
151
162
|
temperature?: number;
|
|
152
|
-
reasoningEffort?:
|
|
163
|
+
reasoningEffort?: LLMReasoningEffort;
|
|
153
164
|
maxTokens?: number;
|
|
154
165
|
mcpClients?: MCPToolClient[];
|
|
155
166
|
toolChoice?: LLMToolChoice;
|
|
@@ -161,6 +172,7 @@ export interface LLMRequest {
|
|
|
161
172
|
transformToolCallParams?: LLMToolCallParamsTransformer;
|
|
162
173
|
unknownToolError?: (toolName: string) => string;
|
|
163
174
|
toolDebug?: boolean | LLMToolDebugOptions;
|
|
175
|
+
onTurnTransition?: (transition: StreamTurnTransition) => void;
|
|
164
176
|
body?: Record<string, unknown>;
|
|
165
177
|
signal?: AbortSignal;
|
|
166
178
|
}
|
|
@@ -173,6 +185,7 @@ export interface LLMUsage {
|
|
|
173
185
|
export interface LLMResponse {
|
|
174
186
|
text: string;
|
|
175
187
|
reasoning?: string;
|
|
188
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
176
189
|
raw?: unknown;
|
|
177
190
|
usage?: LLMUsage;
|
|
178
191
|
finishReason?: string;
|
|
@@ -182,6 +195,8 @@ export interface LLMResponse {
|
|
|
182
195
|
export interface LLMStreamChunk {
|
|
183
196
|
textDelta: string;
|
|
184
197
|
reasoningDelta?: string;
|
|
198
|
+
turnIndex?: number;
|
|
199
|
+
toolCalls?: LLMToolCall[];
|
|
185
200
|
raw?: unknown;
|
|
186
201
|
done?: boolean;
|
|
187
202
|
usage?: LLMUsage;
|
|
@@ -316,6 +331,7 @@ export interface StructuredStreamDelta {
|
|
|
316
331
|
export interface StructuredStreamSnapshot<T = unknown> {
|
|
317
332
|
text: string;
|
|
318
333
|
reasoning: string;
|
|
334
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
319
335
|
data: StructuredStreamData<T> | null;
|
|
320
336
|
}
|
|
321
337
|
export interface StructuredStreamEvent<T = unknown> {
|
|
@@ -324,10 +340,13 @@ export interface StructuredStreamEvent<T = unknown> {
|
|
|
324
340
|
done: boolean;
|
|
325
341
|
usage?: LLMUsage;
|
|
326
342
|
finishReason?: string;
|
|
343
|
+
turnIndex?: number;
|
|
344
|
+
toolCalls?: LLMToolCall[];
|
|
327
345
|
}
|
|
328
346
|
export interface StructuredStreamOptions<T = unknown> {
|
|
329
347
|
enabled?: boolean;
|
|
330
348
|
onData?: (event: StructuredStreamEvent<T>) => void;
|
|
349
|
+
onTurnTransition?: (transition: StreamTurnTransition) => void;
|
|
331
350
|
to?: "stdout";
|
|
332
351
|
}
|
|
333
352
|
export type StructuredStreamInput<T = unknown> = boolean | StructuredStreamOptions<T>;
|
|
@@ -338,6 +357,7 @@ export interface GenerateStreamDelta {
|
|
|
338
357
|
export interface GenerateStreamSnapshot {
|
|
339
358
|
text: string;
|
|
340
359
|
reasoning: string;
|
|
360
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
341
361
|
}
|
|
342
362
|
export interface GenerateStreamEvent {
|
|
343
363
|
delta: GenerateStreamDelta;
|
|
@@ -345,10 +365,13 @@ export interface GenerateStreamEvent {
|
|
|
345
365
|
done: boolean;
|
|
346
366
|
usage?: LLMUsage;
|
|
347
367
|
finishReason?: string;
|
|
368
|
+
turnIndex?: number;
|
|
369
|
+
toolCalls?: LLMToolCall[];
|
|
348
370
|
}
|
|
349
371
|
export interface GenerateStreamOptions {
|
|
350
372
|
enabled?: boolean;
|
|
351
373
|
onData?: (event: GenerateStreamEvent) => void;
|
|
374
|
+
onTurnTransition?: (transition: StreamTurnTransition) => void;
|
|
352
375
|
to?: "stdout";
|
|
353
376
|
}
|
|
354
377
|
export type GenerateStreamInput = boolean | GenerateStreamOptions;
|
|
@@ -390,10 +413,11 @@ export interface StructuredAttempt<T> {
|
|
|
390
413
|
json: unknown | null;
|
|
391
414
|
candidates: string[];
|
|
392
415
|
repairLog: string[];
|
|
393
|
-
zodIssues: z.ZodIssue[];
|
|
416
|
+
zodIssues: z.core.$ZodIssue[];
|
|
394
417
|
success: boolean;
|
|
395
418
|
usage?: LLMUsage;
|
|
396
419
|
finishReason?: string;
|
|
420
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
397
421
|
parsed: ParseLLMOutputResult<T>;
|
|
398
422
|
}
|
|
399
423
|
export interface GenerateAttempt {
|
|
@@ -403,6 +427,7 @@ export interface GenerateAttempt {
|
|
|
403
427
|
reasoning: string;
|
|
404
428
|
usage?: LLMUsage;
|
|
405
429
|
finishReason?: string;
|
|
430
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
406
431
|
}
|
|
407
432
|
export interface StructuredResult<T> {
|
|
408
433
|
data: T;
|
|
@@ -412,6 +437,7 @@ export interface StructuredResult<T> {
|
|
|
412
437
|
attempts: StructuredAttempt<T>[];
|
|
413
438
|
usage?: LLMUsage;
|
|
414
439
|
finishReason?: string;
|
|
440
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
415
441
|
}
|
|
416
442
|
export interface GenerateResult {
|
|
417
443
|
text: string;
|
|
@@ -419,13 +445,14 @@ export interface GenerateResult {
|
|
|
419
445
|
attempts: GenerateAttempt[];
|
|
420
446
|
usage?: LLMUsage;
|
|
421
447
|
finishReason?: string;
|
|
448
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
422
449
|
}
|
|
423
450
|
export interface StructuredError {
|
|
424
451
|
name: "StructuredParseError";
|
|
425
452
|
text: string;
|
|
426
453
|
reasoning: string;
|
|
427
454
|
candidates: string[];
|
|
428
|
-
zodIssues?: z.ZodIssue[];
|
|
455
|
+
zodIssues?: z.core.$ZodIssue[];
|
|
429
456
|
repairLog?: string[];
|
|
430
457
|
attempt: number;
|
|
431
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"
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"main": "./dist/index.cjs",
|
|
9
9
|
"module": "./dist/index.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
12
|
-
"jsonrepair": "^3.
|
|
13
|
-
"zod": "^4.3
|
|
11
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
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"
|