@metorial/anthropic 1.0.0-rc.3 → 1.0.0-rc.4
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 +64 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/package.json +6 -6
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var mcpSdkUtils = require('@metorial/mcp-sdk-utils');
|
|
4
|
+
|
|
5
|
+
// src/metorialAnthropic.ts
|
|
6
|
+
var metorialAnthropic = mcpSdkUtils.createMcpSdk()(async ({ tools }) => ({
|
|
7
|
+
tools: tools.getTools().map(
|
|
8
|
+
(t) => {
|
|
9
|
+
var _a;
|
|
10
|
+
return {
|
|
11
|
+
name: t.id,
|
|
12
|
+
description: (_a = t.description) != null ? _a : void 0,
|
|
13
|
+
input_schema: t.getParametersAs("json-schema")
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
),
|
|
17
|
+
callTools: async (calls) => ({
|
|
18
|
+
role: "user",
|
|
19
|
+
content: await Promise.all(
|
|
20
|
+
calls.map(async (call) => {
|
|
21
|
+
let tool = tools.getTool(call.name);
|
|
22
|
+
if (!tool) {
|
|
23
|
+
return {
|
|
24
|
+
type: "tool_result",
|
|
25
|
+
tool_use_id: call.id,
|
|
26
|
+
content: `[ERROR] Tool with name "${call.name}" not found.`
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
let data = {};
|
|
30
|
+
try {
|
|
31
|
+
if (typeof call.input == "string") {
|
|
32
|
+
data = JSON.parse(call.input);
|
|
33
|
+
} else {
|
|
34
|
+
data = call.input;
|
|
35
|
+
}
|
|
36
|
+
} catch (e) {
|
|
37
|
+
return {
|
|
38
|
+
type: "tool_result",
|
|
39
|
+
tool_use_id: call.id,
|
|
40
|
+
content: `[ERROR] Invalid JSON in tool call arguments: ${e.message}`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
let result = await tool.call(data);
|
|
45
|
+
return {
|
|
46
|
+
type: "tool_result",
|
|
47
|
+
tool_use_id: call.id,
|
|
48
|
+
content: JSON.stringify(result)
|
|
49
|
+
};
|
|
50
|
+
} catch (e) {
|
|
51
|
+
return {
|
|
52
|
+
type: "tool_result",
|
|
53
|
+
tool_use_id: call.id,
|
|
54
|
+
content: `[ERROR] Tool call failed: ${e.message}`
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
)
|
|
59
|
+
})
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
exports.metorialAnthropic = metorialAnthropic;
|
|
63
|
+
//# sourceMappingURL=out.js.map
|
|
64
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/metorialAnthropic.ts"],"names":[],"mappings":";AAMA,SAAS,oBAAoB;AAEtB,IAAI,oBAAoB,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO;AAAA,EAClE,OAAO,MAAM,SAAS,EAAE;AAAA,IACtB,OAAE;AAVN;AAWO;AAAA,QACC,MAAM,EAAE;AAAA,QACR,cAAa,OAAE,gBAAF,YAAiB;AAAA,QAC9B,cAAc,EAAE,gBAAgB,aAAa;AAAA,MAC/C;AAAA;AAAA,EACJ;AAAA,EAEA,WAAW,OAAO,WAAkD;AAAA,IAClE,MAAM;AAAA,IACN,SAAS,MAAM,QAAQ;AAAA,MACrB,MAAM,IAAI,OAAM,SAAQ;AACtB,YAAI,OAAO,MAAM,QAAQ,KAAK,IAAI;AAClC,YAAI,CAAC,MAAM;AACT,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,aAAa,KAAK;AAAA,YAClB,SAAS,2BAA2B,KAAK,IAAI;AAAA,UAC/C;AAAA,QACF;AAEA,YAAI,OAAY,CAAC;AAEjB,YAAI;AACF,cAAI,OAAO,KAAK,SAAS,UAAU;AACjC,mBAAO,KAAK,MAAM,KAAK,KAAK;AAAA,UAC9B,OAAO;AACL,mBAAO,KAAK;AAAA,UACd;AAAA,QACF,SAAS,GAAQ;AACf,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,aAAa,KAAK;AAAA,YAClB,SAAS,gDAAgD,EAAE,OAAO;AAAA,UACpE;AAAA,QACF;AAEA,YAAI;AACF,cAAI,SAAS,MAAM,KAAK,KAAK,IAAI;AAEjC,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,aAAa,KAAK;AAAA,YAClB,SAAS,KAAK,UAAU,MAAM;AAAA,UAChC;AAAA,QACF,SAAS,GAAQ;AACf,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,aAAa,KAAK;AAAA,YAClB,SAAS,6BAA6B,EAAE,OAAO;AAAA,UACjD;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,EAAE","sourcesContent":["import {\n MessageParam,\n ToolResultBlockParam,\n ToolUnion,\n ToolUseBlock\n} from '@anthropic-ai/sdk/resources/messages';\nimport { createMcpSdk } from '@metorial/mcp-sdk-utils';\n\nexport let metorialAnthropic = createMcpSdk()(async ({ tools }) => ({\n tools: tools.getTools().map(\n t =>\n ({\n name: t.id,\n description: t.description ?? undefined,\n input_schema: t.getParametersAs('json-schema') as any\n }) satisfies ToolUnion\n ) as ToolUnion[],\n\n callTools: async (calls: ToolUseBlock[]): Promise<MessageParam> => ({\n role: 'user',\n content: await Promise.all(\n calls.map(async call => {\n let tool = tools.getTool(call.name);\n if (!tool) {\n return {\n type: 'tool_result',\n tool_use_id: call.id,\n content: `[ERROR] Tool with name \"${call.name}\" not found.`\n } satisfies ToolResultBlockParam;\n }\n\n let data: any = {};\n\n try {\n if (typeof call.input == 'string') {\n data = JSON.parse(call.input);\n } else {\n data = call.input;\n }\n } catch (e: any) {\n return {\n type: 'tool_result',\n tool_use_id: call.id,\n content: `[ERROR] Invalid JSON in tool call arguments: ${e.message}`\n } satisfies ToolResultBlockParam;\n }\n\n try {\n let result = await tool.call(data);\n\n return {\n type: 'tool_result',\n tool_use_id: call.id,\n content: JSON.stringify(result)\n } satisfies ToolResultBlockParam;\n } catch (e: any) {\n return {\n type: 'tool_result',\n tool_use_id: call.id,\n content: `[ERROR] Tool call failed: ${e.message}`\n } satisfies ToolResultBlockParam;\n }\n })\n )\n })\n}));\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as _metorial_sdk from '@metorial/sdk';
|
|
2
|
+
import * as _metorial_mcp_session from '@metorial/mcp-session';
|
|
3
|
+
import { ToolUnion, ToolUseBlock, MessageParam } from '@anthropic-ai/sdk/resources/messages';
|
|
4
|
+
|
|
5
|
+
declare let metorialAnthropic: ((session: _metorial_mcp_session.MetorialMcpSession, input: void) => Promise<{
|
|
6
|
+
tools: ToolUnion[];
|
|
7
|
+
callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
|
|
8
|
+
}>) & {
|
|
9
|
+
ofSession: (session: _metorial_mcp_session.MetorialMcpSession, input: void) => Promise<{
|
|
10
|
+
tools: ToolUnion[];
|
|
11
|
+
callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
|
|
12
|
+
}>;
|
|
13
|
+
ofSdk: (sdk: _metorial_sdk.Metorial, init: _metorial_mcp_session.MetorialMcpSessionInit, input: void) => Promise<{
|
|
14
|
+
tools: ToolUnion[];
|
|
15
|
+
callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { metorialAnthropic };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as _metorial_sdk from '@metorial/sdk';
|
|
2
|
+
import * as _metorial_mcp_session from '@metorial/mcp-session';
|
|
3
|
+
import { ToolUnion, ToolUseBlock, MessageParam } from '@anthropic-ai/sdk/resources/messages';
|
|
4
|
+
|
|
5
|
+
declare let metorialAnthropic: ((session: _metorial_mcp_session.MetorialMcpSession, input: void) => Promise<{
|
|
6
|
+
tools: ToolUnion[];
|
|
7
|
+
callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
|
|
8
|
+
}>) & {
|
|
9
|
+
ofSession: (session: _metorial_mcp_session.MetorialMcpSession, input: void) => Promise<{
|
|
10
|
+
tools: ToolUnion[];
|
|
11
|
+
callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
|
|
12
|
+
}>;
|
|
13
|
+
ofSdk: (sdk: _metorial_sdk.Metorial, init: _metorial_mcp_session.MetorialMcpSessionInit, input: void) => Promise<{
|
|
14
|
+
tools: ToolUnion[];
|
|
15
|
+
callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { metorialAnthropic };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createMcpSdk } from '@metorial/mcp-sdk-utils';
|
|
2
|
+
|
|
3
|
+
// src/metorialAnthropic.ts
|
|
4
|
+
var metorialAnthropic = createMcpSdk()(async ({ tools }) => ({
|
|
5
|
+
tools: tools.getTools().map(
|
|
6
|
+
(t) => {
|
|
7
|
+
var _a;
|
|
8
|
+
return {
|
|
9
|
+
name: t.id,
|
|
10
|
+
description: (_a = t.description) != null ? _a : void 0,
|
|
11
|
+
input_schema: t.getParametersAs("json-schema")
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
),
|
|
15
|
+
callTools: async (calls) => ({
|
|
16
|
+
role: "user",
|
|
17
|
+
content: await Promise.all(
|
|
18
|
+
calls.map(async (call) => {
|
|
19
|
+
let tool = tools.getTool(call.name);
|
|
20
|
+
if (!tool) {
|
|
21
|
+
return {
|
|
22
|
+
type: "tool_result",
|
|
23
|
+
tool_use_id: call.id,
|
|
24
|
+
content: `[ERROR] Tool with name "${call.name}" not found.`
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
let data = {};
|
|
28
|
+
try {
|
|
29
|
+
if (typeof call.input == "string") {
|
|
30
|
+
data = JSON.parse(call.input);
|
|
31
|
+
} else {
|
|
32
|
+
data = call.input;
|
|
33
|
+
}
|
|
34
|
+
} catch (e) {
|
|
35
|
+
return {
|
|
36
|
+
type: "tool_result",
|
|
37
|
+
tool_use_id: call.id,
|
|
38
|
+
content: `[ERROR] Invalid JSON in tool call arguments: ${e.message}`
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
let result = await tool.call(data);
|
|
43
|
+
return {
|
|
44
|
+
type: "tool_result",
|
|
45
|
+
tool_use_id: call.id,
|
|
46
|
+
content: JSON.stringify(result)
|
|
47
|
+
};
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return {
|
|
50
|
+
type: "tool_result",
|
|
51
|
+
tool_use_id: call.id,
|
|
52
|
+
content: `[ERROR] Tool call failed: ${e.message}`
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
)
|
|
57
|
+
})
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
export { metorialAnthropic };
|
|
61
|
+
//# sourceMappingURL=out.js.map
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/metorialAnthropic.ts"],"names":[],"mappings":";AAMA,SAAS,oBAAoB;AAEtB,IAAI,oBAAoB,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO;AAAA,EAClE,OAAO,MAAM,SAAS,EAAE;AAAA,IACtB,OAAE;AAVN;AAWO;AAAA,QACC,MAAM,EAAE;AAAA,QACR,cAAa,OAAE,gBAAF,YAAiB;AAAA,QAC9B,cAAc,EAAE,gBAAgB,aAAa;AAAA,MAC/C;AAAA;AAAA,EACJ;AAAA,EAEA,WAAW,OAAO,WAAkD;AAAA,IAClE,MAAM;AAAA,IACN,SAAS,MAAM,QAAQ;AAAA,MACrB,MAAM,IAAI,OAAM,SAAQ;AACtB,YAAI,OAAO,MAAM,QAAQ,KAAK,IAAI;AAClC,YAAI,CAAC,MAAM;AACT,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,aAAa,KAAK;AAAA,YAClB,SAAS,2BAA2B,KAAK,IAAI;AAAA,UAC/C;AAAA,QACF;AAEA,YAAI,OAAY,CAAC;AAEjB,YAAI;AACF,cAAI,OAAO,KAAK,SAAS,UAAU;AACjC,mBAAO,KAAK,MAAM,KAAK,KAAK;AAAA,UAC9B,OAAO;AACL,mBAAO,KAAK;AAAA,UACd;AAAA,QACF,SAAS,GAAQ;AACf,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,aAAa,KAAK;AAAA,YAClB,SAAS,gDAAgD,EAAE,OAAO;AAAA,UACpE;AAAA,QACF;AAEA,YAAI;AACF,cAAI,SAAS,MAAM,KAAK,KAAK,IAAI;AAEjC,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,aAAa,KAAK;AAAA,YAClB,SAAS,KAAK,UAAU,MAAM;AAAA,UAChC;AAAA,QACF,SAAS,GAAQ;AACf,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,aAAa,KAAK;AAAA,YAClB,SAAS,6BAA6B,EAAE,OAAO;AAAA,UACjD;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,EAAE","sourcesContent":["import {\n MessageParam,\n ToolResultBlockParam,\n ToolUnion,\n ToolUseBlock\n} from '@anthropic-ai/sdk/resources/messages';\nimport { createMcpSdk } from '@metorial/mcp-sdk-utils';\n\nexport let metorialAnthropic = createMcpSdk()(async ({ tools }) => ({\n tools: tools.getTools().map(\n t =>\n ({\n name: t.id,\n description: t.description ?? undefined,\n input_schema: t.getParametersAs('json-schema') as any\n }) satisfies ToolUnion\n ) as ToolUnion[],\n\n callTools: async (calls: ToolUseBlock[]): Promise<MessageParam> => ({\n role: 'user',\n content: await Promise.all(\n calls.map(async call => {\n let tool = tools.getTool(call.name);\n if (!tool) {\n return {\n type: 'tool_result',\n tool_use_id: call.id,\n content: `[ERROR] Tool with name \"${call.name}\" not found.`\n } satisfies ToolResultBlockParam;\n }\n\n let data: any = {};\n\n try {\n if (typeof call.input == 'string') {\n data = JSON.parse(call.input);\n } else {\n data = call.input;\n }\n } catch (e: any) {\n return {\n type: 'tool_result',\n tool_use_id: call.id,\n content: `[ERROR] Invalid JSON in tool call arguments: ${e.message}`\n } satisfies ToolResultBlockParam;\n }\n\n try {\n let result = await tool.call(data);\n\n return {\n type: 'tool_result',\n tool_use_id: call.id,\n content: JSON.stringify(result)\n } satisfies ToolResultBlockParam;\n } catch (e: any) {\n return {\n type: 'tool_result',\n tool_use_id: call.id,\n content: `[ERROR] Tool call failed: ${e.message}`\n } satisfies ToolResultBlockParam;\n }\n })\n )\n })\n}));\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metorial/anthropic",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.4",
|
|
4
4
|
"author": "Tobias Herber",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@metorial/core": "^1.0.0-rc.
|
|
29
|
-
"@metorial/mcp-sdk-utils": "^1.0.0-rc.
|
|
30
|
-
"@metorial/mcp-session": "^1.0.0-rc.
|
|
31
|
-
"@metorial/openai-compatible": "^1.0.0-rc.
|
|
32
|
-
"@metorial/sdk": "^1.0.0-rc.
|
|
28
|
+
"@metorial/core": "^1.0.0-rc.4",
|
|
29
|
+
"@metorial/mcp-sdk-utils": "^1.0.0-rc.4",
|
|
30
|
+
"@metorial/mcp-session": "^1.0.0-rc.4",
|
|
31
|
+
"@metorial/openai-compatible": "^1.0.0-rc.4",
|
|
32
|
+
"@metorial/sdk": "^1.0.0-rc.4"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@anthropic-ai/sdk": "*"
|