extrait 0.3.0 → 0.3.1
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/dist/index.cjs +32 -4
- package/dist/index.js +32 -4
- package/dist/mcp.d.ts +2 -0
- package/dist/types.d.ts +1 -0
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -1294,10 +1294,36 @@ async function executeMCPToolCalls(calls, toolset, context) {
|
|
|
1294
1294
|
throw new Error("Received a function tool call without id or name.");
|
|
1295
1295
|
}
|
|
1296
1296
|
const tool = toolset.byName.get(toolName);
|
|
1297
|
+
const parsedArguments = parseToolArguments(call.arguments);
|
|
1297
1298
|
if (!tool) {
|
|
1298
|
-
|
|
1299
|
+
const errorMessage = context.request.unknownToolError ? context.request.unknownToolError(toolName) : `Tool "${toolName}" is not registered in the current toolset.`;
|
|
1300
|
+
const metadata2 = {
|
|
1301
|
+
id: callId,
|
|
1302
|
+
type: call.type ?? "function",
|
|
1303
|
+
name: toolName,
|
|
1304
|
+
arguments: parsedArguments,
|
|
1305
|
+
error: errorMessage
|
|
1306
|
+
};
|
|
1307
|
+
const startedAt2 = new Date().toISOString();
|
|
1308
|
+
const execution = {
|
|
1309
|
+
callId,
|
|
1310
|
+
type: metadata2.type,
|
|
1311
|
+
name: toolName,
|
|
1312
|
+
clientId: "__unregistered__",
|
|
1313
|
+
remoteName: toolName,
|
|
1314
|
+
arguments: parsedArguments,
|
|
1315
|
+
error: errorMessage,
|
|
1316
|
+
round: context.round,
|
|
1317
|
+
provider: context.provider,
|
|
1318
|
+
model: context.model,
|
|
1319
|
+
handledLocally: true,
|
|
1320
|
+
startedAt: startedAt2,
|
|
1321
|
+
durationMs: 0
|
|
1322
|
+
};
|
|
1323
|
+
emitToolExecution(context.request, execution);
|
|
1324
|
+
out.push({ call: metadata2, execution });
|
|
1325
|
+
continue;
|
|
1299
1326
|
}
|
|
1300
|
-
const parsedArguments = parseToolArguments(call.arguments);
|
|
1301
1327
|
const args = isRecord(parsedArguments) ? parsedArguments : {};
|
|
1302
1328
|
const metadata = {
|
|
1303
1329
|
id: callId,
|
|
@@ -4640,7 +4666,8 @@ async function createMCPClient(options) {
|
|
|
4640
4666
|
return wrapMCPClient({
|
|
4641
4667
|
id: options.id,
|
|
4642
4668
|
client,
|
|
4643
|
-
transport
|
|
4669
|
+
transport,
|
|
4670
|
+
toolCallTimeoutMs: options.toolCallTimeoutMs
|
|
4644
4671
|
});
|
|
4645
4672
|
}
|
|
4646
4673
|
function wrapMCPClient(options) {
|
|
@@ -4660,7 +4687,8 @@ function wrapMCPClient(options) {
|
|
|
4660
4687
|
};
|
|
4661
4688
|
},
|
|
4662
4689
|
async callTool(params) {
|
|
4663
|
-
|
|
4690
|
+
const callOptions = options.toolCallTimeoutMs === undefined ? undefined : { timeout: options.toolCallTimeoutMs };
|
|
4691
|
+
return options.client.callTool(params, undefined, callOptions);
|
|
4664
4692
|
},
|
|
4665
4693
|
async close() {
|
|
4666
4694
|
await options.client.close();
|
package/dist/index.js
CHANGED
|
@@ -1215,10 +1215,36 @@ async function executeMCPToolCalls(calls, toolset, context) {
|
|
|
1215
1215
|
throw new Error("Received a function tool call without id or name.");
|
|
1216
1216
|
}
|
|
1217
1217
|
const tool = toolset.byName.get(toolName);
|
|
1218
|
+
const parsedArguments = parseToolArguments(call.arguments);
|
|
1218
1219
|
if (!tool) {
|
|
1219
|
-
|
|
1220
|
+
const errorMessage = context.request.unknownToolError ? context.request.unknownToolError(toolName) : `Tool "${toolName}" is not registered in the current toolset.`;
|
|
1221
|
+
const metadata2 = {
|
|
1222
|
+
id: callId,
|
|
1223
|
+
type: call.type ?? "function",
|
|
1224
|
+
name: toolName,
|
|
1225
|
+
arguments: parsedArguments,
|
|
1226
|
+
error: errorMessage
|
|
1227
|
+
};
|
|
1228
|
+
const startedAt2 = new Date().toISOString();
|
|
1229
|
+
const execution = {
|
|
1230
|
+
callId,
|
|
1231
|
+
type: metadata2.type,
|
|
1232
|
+
name: toolName,
|
|
1233
|
+
clientId: "__unregistered__",
|
|
1234
|
+
remoteName: toolName,
|
|
1235
|
+
arguments: parsedArguments,
|
|
1236
|
+
error: errorMessage,
|
|
1237
|
+
round: context.round,
|
|
1238
|
+
provider: context.provider,
|
|
1239
|
+
model: context.model,
|
|
1240
|
+
handledLocally: true,
|
|
1241
|
+
startedAt: startedAt2,
|
|
1242
|
+
durationMs: 0
|
|
1243
|
+
};
|
|
1244
|
+
emitToolExecution(context.request, execution);
|
|
1245
|
+
out.push({ call: metadata2, execution });
|
|
1246
|
+
continue;
|
|
1220
1247
|
}
|
|
1221
|
-
const parsedArguments = parseToolArguments(call.arguments);
|
|
1222
1248
|
const args = isRecord(parsedArguments) ? parsedArguments : {};
|
|
1223
1249
|
const metadata = {
|
|
1224
1250
|
id: callId,
|
|
@@ -4565,7 +4591,8 @@ async function createMCPClient(options) {
|
|
|
4565
4591
|
return wrapMCPClient({
|
|
4566
4592
|
id: options.id,
|
|
4567
4593
|
client,
|
|
4568
|
-
transport
|
|
4594
|
+
transport,
|
|
4595
|
+
toolCallTimeoutMs: options.toolCallTimeoutMs
|
|
4569
4596
|
});
|
|
4570
4597
|
}
|
|
4571
4598
|
function wrapMCPClient(options) {
|
|
@@ -4585,7 +4612,8 @@ function wrapMCPClient(options) {
|
|
|
4585
4612
|
};
|
|
4586
4613
|
},
|
|
4587
4614
|
async callTool(params) {
|
|
4588
|
-
|
|
4615
|
+
const callOptions = options.toolCallTimeoutMs === undefined ? undefined : { timeout: options.toolCallTimeoutMs };
|
|
4616
|
+
return options.client.callTool(params, undefined, callOptions);
|
|
4589
4617
|
},
|
|
4590
4618
|
async close() {
|
|
4591
4619
|
await options.client.close();
|
package/dist/mcp.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface CreateMCPClientOptions {
|
|
|
26
26
|
id: string;
|
|
27
27
|
transport: MCPTransportConfig;
|
|
28
28
|
clientInfo?: MCPClientInfo;
|
|
29
|
+
toolCallTimeoutMs?: number;
|
|
29
30
|
}
|
|
30
31
|
export interface ManagedMCPToolClient extends MCPToolClient {
|
|
31
32
|
sdkClient: Client;
|
|
@@ -36,5 +37,6 @@ export interface WrapMCPClientOptions {
|
|
|
36
37
|
id: string;
|
|
37
38
|
client: Client;
|
|
38
39
|
transport?: Transport;
|
|
40
|
+
toolCallTimeoutMs?: number;
|
|
39
41
|
}
|
|
40
42
|
export declare function wrapMCPClient(options: WrapMCPClientOptions): ManagedMCPToolClient;
|
package/dist/types.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ export interface LLMRequest {
|
|
|
130
130
|
maxToolRounds?: number;
|
|
131
131
|
onToolExecution?: (execution: LLMToolExecution) => void;
|
|
132
132
|
transformToolOutput?: LLMToolOutputTransformer;
|
|
133
|
+
unknownToolError?: (toolName: string) => string;
|
|
133
134
|
toolDebug?: boolean | LLMToolDebugOptions;
|
|
134
135
|
body?: Record<string, unknown>;
|
|
135
136
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extrait",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"lint": "bunx tsc -p tsconfig.lint.json",
|
|
36
36
|
"prepublishOnly": "bun run lint && bun run build && bun run build:types",
|
|
37
37
|
"test": "bun test tests/ --reporter=dots --only-failures",
|
|
38
|
-
"typecheck": "bunx tsc --noEmit"
|
|
38
|
+
"typecheck": "bunx tsc --noEmit",
|
|
39
|
+
"pack": "bun run build && npm pack"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"@modelcontextprotocol/sdk": "^1.26.0",
|