extrait 0.1.1 → 0.1.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 +4 -0
- package/dist/index.cjs +9 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -4
- package/dist/types.d.ts +2 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -215,6 +215,10 @@ const result = await llm.structured(
|
|
|
215
215
|
onToolExecution: (execution) => {
|
|
216
216
|
console.log(execution.name, execution.durationMs);
|
|
217
217
|
},
|
|
218
|
+
// Optional: transform tool output before it is sent back to the LLM
|
|
219
|
+
transformToolOutput: (output, execution) => {
|
|
220
|
+
return { ...output, source: execution.name };
|
|
221
|
+
},
|
|
218
222
|
},
|
|
219
223
|
}
|
|
220
224
|
);
|
package/dist/index.cjs
CHANGED
|
@@ -1301,20 +1301,25 @@ async function executeMCPToolCalls(calls, toolset, context) {
|
|
|
1301
1301
|
name: tool.remoteName,
|
|
1302
1302
|
arguments: args
|
|
1303
1303
|
});
|
|
1304
|
-
|
|
1305
|
-
const execution = {
|
|
1304
|
+
const executionContext = {
|
|
1306
1305
|
callId,
|
|
1307
|
-
type:
|
|
1306
|
+
type: call.type ?? "function",
|
|
1308
1307
|
name: toolName,
|
|
1309
1308
|
clientId: tool.clientId,
|
|
1310
1309
|
remoteName: tool.remoteName,
|
|
1311
1310
|
arguments: parsedArguments,
|
|
1312
|
-
output,
|
|
1313
1311
|
round: context.round,
|
|
1314
1312
|
provider: context.provider,
|
|
1315
1313
|
model: context.model,
|
|
1316
1314
|
handledLocally: true,
|
|
1317
1315
|
startedAt,
|
|
1316
|
+
error: undefined
|
|
1317
|
+
};
|
|
1318
|
+
const transformedOutput = context.request.transformToolOutput ? await context.request.transformToolOutput(output, executionContext) : output;
|
|
1319
|
+
metadata.output = transformedOutput;
|
|
1320
|
+
const execution = {
|
|
1321
|
+
...executionContext,
|
|
1322
|
+
output: transformedOutput,
|
|
1318
1323
|
durationMs: Date.now() - startedAtMs
|
|
1319
1324
|
};
|
|
1320
1325
|
emitToolExecution(context.request, execution);
|
package/dist/index.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ export { createOpenAICompatibleAdapter, type OpenAICompatibleAdapterOptions, } f
|
|
|
12
12
|
export { createAnthropicCompatibleAdapter, DEFAULT_ANTHROPIC_MAX_TOKENS, DEFAULT_ANTHROPIC_VERSION, type AnthropicCompatibleAdapterOptions, } from "./providers/anthropic-compatible";
|
|
13
13
|
export { DEFAULT_MAX_TOOL_ROUNDS } from "./providers/mcp-runtime";
|
|
14
14
|
export { createDefaultProviderRegistry, createModelAdapter, createProviderRegistry, registerBuiltinProviders, type BuiltinProviderKind, type ModelAdapterConfig, type ProviderFactory, type ProviderRegistry, type ProviderTransportConfig, } from "./providers/registry";
|
|
15
|
-
export type { CandidateDiagnostics, ExtractJsonCandidatesOptions, ExtractionCandidate, ExtractionHeuristicsOptions, ExtractionParseHint, HTTPHeaders, LLMAdapter, LLMRequest, LLMResponse, LLMStreamCallbacks, LLMStreamChunk, LLMToolCall, LLMToolDebugOptions, LLMToolExecution, LLMToolChoice, MCPCallToolParams, MCPListToolsResult, MCPToolClient, MCPToolDescriptor, MCPToolSchema, LLMUsage, MarkdownCodeBlock, MarkdownCodeOptions, ParseLLMOutputOptions, ParseLLMOutputResult, ParseTraceEvent, PipelineError, StructuredAttempt, StructuredCallOptions, StructuredDebugOptions, StructuredError, StructuredMode, StructuredOptions, StructuredPromptBuilder, StructuredPromptContext, StructuredPromptPayload, StructuredPromptResolver, StructuredPromptValue, StructuredResult, StructuredStreamData, StructuredStreamEvent, StructuredStreamInput, StructuredStreamOptions, StructuredSelfHealInput, ThinkDiagnostics, ThinkBlock, StructuredTraceEvent, } from "./types";
|
|
15
|
+
export type { CandidateDiagnostics, ExtractJsonCandidatesOptions, ExtractionCandidate, ExtractionHeuristicsOptions, ExtractionParseHint, HTTPHeaders, LLMAdapter, LLMRequest, LLMResponse, LLMStreamCallbacks, LLMStreamChunk, LLMToolCall, LLMToolDebugOptions, LLMToolExecution, LLMToolOutputTransformer, LLMToolChoice, MCPCallToolParams, MCPListToolsResult, MCPToolClient, MCPToolDescriptor, MCPToolSchema, LLMUsage, MarkdownCodeBlock, MarkdownCodeOptions, ParseLLMOutputOptions, ParseLLMOutputResult, ParseTraceEvent, PipelineError, StructuredAttempt, StructuredCallOptions, StructuredDebugOptions, StructuredError, StructuredMode, StructuredOptions, StructuredPromptBuilder, StructuredPromptContext, StructuredPromptPayload, StructuredPromptResolver, StructuredPromptValue, StructuredResult, StructuredStreamData, StructuredStreamEvent, StructuredStreamInput, StructuredStreamOptions, StructuredSelfHealInput, ThinkDiagnostics, ThinkBlock, StructuredTraceEvent, } from "./types";
|
package/dist/index.js
CHANGED
|
@@ -1222,20 +1222,25 @@ async function executeMCPToolCalls(calls, toolset, context) {
|
|
|
1222
1222
|
name: tool.remoteName,
|
|
1223
1223
|
arguments: args
|
|
1224
1224
|
});
|
|
1225
|
-
|
|
1226
|
-
const execution = {
|
|
1225
|
+
const executionContext = {
|
|
1227
1226
|
callId,
|
|
1228
|
-
type:
|
|
1227
|
+
type: call.type ?? "function",
|
|
1229
1228
|
name: toolName,
|
|
1230
1229
|
clientId: tool.clientId,
|
|
1231
1230
|
remoteName: tool.remoteName,
|
|
1232
1231
|
arguments: parsedArguments,
|
|
1233
|
-
output,
|
|
1234
1232
|
round: context.round,
|
|
1235
1233
|
provider: context.provider,
|
|
1236
1234
|
model: context.model,
|
|
1237
1235
|
handledLocally: true,
|
|
1238
1236
|
startedAt,
|
|
1237
|
+
error: undefined
|
|
1238
|
+
};
|
|
1239
|
+
const transformedOutput = context.request.transformToolOutput ? await context.request.transformToolOutput(output, executionContext) : output;
|
|
1240
|
+
metadata.output = transformedOutput;
|
|
1241
|
+
const execution = {
|
|
1242
|
+
...executionContext,
|
|
1243
|
+
output: transformedOutput,
|
|
1239
1244
|
durationMs: Date.now() - startedAtMs
|
|
1240
1245
|
};
|
|
1241
1246
|
emitToolExecution(context.request, execution);
|
package/dist/types.d.ts
CHANGED
|
@@ -129,6 +129,7 @@ export interface LLMRequest {
|
|
|
129
129
|
parallelToolCalls?: boolean;
|
|
130
130
|
maxToolRounds?: number;
|
|
131
131
|
onToolExecution?: (execution: LLMToolExecution) => void;
|
|
132
|
+
transformToolOutput?: LLMToolOutputTransformer;
|
|
132
133
|
toolDebug?: boolean | LLMToolDebugOptions;
|
|
133
134
|
body?: Record<string, unknown>;
|
|
134
135
|
}
|
|
@@ -189,6 +190,7 @@ export interface LLMToolExecution {
|
|
|
189
190
|
startedAt: string;
|
|
190
191
|
durationMs?: number;
|
|
191
192
|
}
|
|
193
|
+
export type LLMToolOutputTransformer = (output: unknown, execution: Omit<LLMToolExecution, "output" | "durationMs">) => unknown | Promise<unknown>;
|
|
192
194
|
export interface LLMToolDebugOptions {
|
|
193
195
|
enabled?: boolean;
|
|
194
196
|
logger?: (line: string) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extrait",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"build:types": "bunx tsc -p tsconfig.build.json",
|
|
35
35
|
"lint": "bunx tsc -p tsconfig.lint.json",
|
|
36
36
|
"prepublishOnly": "bun run lint && bun run build && bun run build:types",
|
|
37
|
-
"test": "bun test",
|
|
37
|
+
"test": "bun test tests/ --reporter=dots --only-failures",
|
|
38
38
|
"typecheck": "bunx tsc --noEmit"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
42
|
-
"jsonrepair": "^3.13.
|
|
43
|
-
"zod": "^3.
|
|
42
|
+
"jsonrepair": "^3.13.2",
|
|
43
|
+
"zod": "^3.25.76"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/bun": "latest",
|
|
47
|
-
"typescript": "^5"
|
|
47
|
+
"typescript": "^5.9.3"
|
|
48
48
|
}
|
|
49
49
|
}
|