extrait 0.4.0 → 0.5.2
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 +91 -0
- package/dist/image.d.ts +8 -0
- package/dist/index.cjs +375 -199
- package/dist/index.d.ts +3 -2
- package/dist/index.js +360 -191
- package/dist/prompt.d.ts +2 -0
- package/dist/types.d.ts +27 -3
- package/package.json +31 -16
package/dist/prompt.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export interface PromptMessageBuilder extends StructuredPromptResolver {
|
|
|
4
4
|
system(strings: TemplateStringsArray, ...values: unknown[]): PromptMessageBuilder;
|
|
5
5
|
user(input: string): PromptMessageBuilder;
|
|
6
6
|
user(strings: TemplateStringsArray, ...values: unknown[]): PromptMessageBuilder;
|
|
7
|
+
assistant(input: string): PromptMessageBuilder;
|
|
8
|
+
assistant(strings: TemplateStringsArray, ...values: unknown[]): PromptMessageBuilder;
|
|
7
9
|
build(): StructuredPromptPayload;
|
|
8
10
|
}
|
|
9
11
|
export declare function prompt(strings: TemplateStringsArray, ...values: unknown[]): string;
|
package/dist/types.d.ts
CHANGED
|
@@ -119,9 +119,25 @@ export interface MCPToolClient {
|
|
|
119
119
|
callTool(params: MCPCallToolParams): Promise<unknown>;
|
|
120
120
|
close?(): Promise<void>;
|
|
121
121
|
}
|
|
122
|
+
export interface LLMTextContent {
|
|
123
|
+
type: "text";
|
|
124
|
+
text: string;
|
|
125
|
+
}
|
|
126
|
+
export interface LLMImageContent {
|
|
127
|
+
type: "image_url";
|
|
128
|
+
image_url: {
|
|
129
|
+
url: string;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export type LLMMessageContent = string | (LLMTextContent | LLMImageContent)[];
|
|
133
|
+
export interface LLMMessage {
|
|
134
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
135
|
+
content: LLMMessageContent;
|
|
136
|
+
}
|
|
122
137
|
export interface LLMRequest {
|
|
123
|
-
prompt
|
|
138
|
+
prompt?: string;
|
|
124
139
|
systemPrompt?: string;
|
|
140
|
+
messages?: LLMMessage[];
|
|
125
141
|
temperature?: number;
|
|
126
142
|
maxTokens?: number;
|
|
127
143
|
mcpClients?: MCPToolClient[];
|
|
@@ -224,8 +240,9 @@ export interface StructuredPromptContext {
|
|
|
224
240
|
mode: StructuredMode;
|
|
225
241
|
}
|
|
226
242
|
export interface StructuredPromptPayload {
|
|
227
|
-
prompt
|
|
243
|
+
prompt?: string;
|
|
228
244
|
systemPrompt?: string;
|
|
245
|
+
messages?: LLMMessage[];
|
|
229
246
|
}
|
|
230
247
|
export interface StructuredPromptResolver {
|
|
231
248
|
resolvePrompt(context: StructuredPromptContext): StructuredPromptPayload;
|
|
@@ -244,6 +261,12 @@ export interface StructuredSelfHealOptions {
|
|
|
244
261
|
maxContextChars?: number;
|
|
245
262
|
}
|
|
246
263
|
export type StructuredSelfHealInput = boolean | number | StructuredSelfHealOptions;
|
|
264
|
+
export interface StructuredTimeoutOptions {
|
|
265
|
+
/** Timeout in ms for each LLM HTTP request. Creates an AbortSignal.timeout internally if no signal is already provided. */
|
|
266
|
+
request?: number;
|
|
267
|
+
/** Timeout in ms for each MCP tool call. */
|
|
268
|
+
tool?: number;
|
|
269
|
+
}
|
|
247
270
|
export type StructuredStreamData<T> = T extends Array<infer TItem> ? Array<StructuredStreamData<TItem>> : T extends object ? {
|
|
248
271
|
[K in keyof T]?: StructuredStreamData<T[K]> | null;
|
|
249
272
|
} : T | null;
|
|
@@ -269,8 +292,9 @@ export interface StructuredCallOptions<TSchema extends z.ZodTypeAny> {
|
|
|
269
292
|
debug?: boolean | StructuredDebugOptions;
|
|
270
293
|
observe?: (event: StructuredTraceEvent) => void;
|
|
271
294
|
systemPrompt?: string;
|
|
272
|
-
request?: Omit<LLMRequest, "prompt" | "systemPrompt">;
|
|
295
|
+
request?: Omit<LLMRequest, "prompt" | "systemPrompt" | "messages">;
|
|
273
296
|
schemaInstruction?: string;
|
|
297
|
+
timeout?: StructuredTimeoutOptions;
|
|
274
298
|
}
|
|
275
299
|
export interface StructuredOptions<TSchema extends z.ZodTypeAny> extends StructuredCallOptions<TSchema> {
|
|
276
300
|
schema: TSchema;
|
package/package.json
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extrait",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"license": "MIT",
|
|
3
|
+
"version": "0.5.2",
|
|
5
4
|
"repository": {
|
|
6
5
|
"type": "git",
|
|
7
6
|
"url": "git+https://github.com/tterrasson/extrait.git"
|
|
8
7
|
},
|
|
9
|
-
"bugs": {
|
|
10
|
-
"url": "https://github.com/tterrasson/extrait/issues"
|
|
11
|
-
},
|
|
12
8
|
"main": "./dist/index.cjs",
|
|
13
9
|
"module": "./dist/index.js",
|
|
14
|
-
"
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
12
|
+
"jsonrepair": "^3.13.2",
|
|
13
|
+
"zod": "^4.3.6"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/bun": "^1.3.10",
|
|
17
|
+
"@types/sharp": "^0.32.0",
|
|
18
|
+
"typescript": "^5.9.3"
|
|
19
|
+
},
|
|
15
20
|
"exports": {
|
|
16
21
|
".": {
|
|
17
22
|
"types": "./dist/index.d.ts",
|
|
@@ -20,12 +25,29 @@
|
|
|
20
25
|
"default": "./dist/index.js"
|
|
21
26
|
}
|
|
22
27
|
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/tterrasson/extrait/issues"
|
|
30
|
+
},
|
|
23
31
|
"files": [
|
|
24
32
|
"dist",
|
|
25
33
|
"README.md",
|
|
26
34
|
"LICENSE"
|
|
27
35
|
],
|
|
28
|
-
"
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"overrides": {
|
|
38
|
+
"zod": "^4.3.6"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"sharp": "^0.34.5"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"sharp": {
|
|
45
|
+
"optional": true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"resolutions": {
|
|
49
|
+
"zod": "^4.3.6"
|
|
50
|
+
},
|
|
29
51
|
"scripts": {
|
|
30
52
|
"dev": "bun run examples/runner.ts",
|
|
31
53
|
"build": "bun run build:esm && bun run build:cjs",
|
|
@@ -38,13 +60,6 @@
|
|
|
38
60
|
"typecheck": "bunx tsc --noEmit",
|
|
39
61
|
"pack": "bun run build:types && bun run build && npm pack"
|
|
40
62
|
},
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
"jsonrepair": "^3.13.2",
|
|
44
|
-
"zod": "^3.25.76"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@types/bun": "latest",
|
|
48
|
-
"typescript": "^5.9.3"
|
|
49
|
-
}
|
|
63
|
+
"type": "module",
|
|
64
|
+
"types": "./dist/index.d.ts"
|
|
50
65
|
}
|