@metorial/anthropic 2.0.0 → 2.1.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/dist/index.cjs CHANGED
@@ -3,8 +3,8 @@
3
3
  var mcpSdkUtils = require('@metorial/mcp-sdk-utils');
4
4
 
5
5
  // src/metorialAnthropic.ts
6
- var metorialAnthropic = mcpSdkUtils.createMcpSdk()(async ({ tools }) => ({
7
- tools: tools.getTools().map(
6
+ var metorialAnthropic = mcpSdkUtils.createMcpSdk(async ({ tools }) => ({
7
+ tools: () => tools.getTools().map(
8
8
  (t) => {
9
9
  var _a;
10
10
  return {
@@ -1 +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"]}
1
+ {"version":3,"sources":["../src/metorialAnthropic.ts"],"names":[],"mappings":";AAMA,SAAS,oBAAoB;AAEtB,IAAI,oBAAoB,aAAa,OAAO,EAAE,MAAM,OAAO;AAAA,EAChE,OAAO,MAAM,MAAM,SAAS,EAAE;AAAA,IAC5B,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 CHANGED
@@ -1,19 +1,9 @@
1
- import * as _metorial_mcp_session from '@metorial/mcp-session';
2
1
  import * as _metorial_mcp_sdk_utils from '@metorial/mcp-sdk-utils';
3
2
  import { ToolUnion, ToolUseBlock, MessageParam } from '@anthropic-ai/sdk/resources/messages';
4
3
 
5
- declare let metorialAnthropic: ((session: _metorial_mcp_sdk_utils.McpSessionLike, input: void) => Promise<{
6
- tools: ToolUnion[];
4
+ declare let metorialAnthropic: () => _metorial_mcp_sdk_utils.MetorialAdapter<{
5
+ tools: () => ToolUnion[];
7
6
  callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
8
- }>) & {
9
- ofSession: (session: _metorial_mcp_sdk_utils.McpSessionLike, input: void) => Promise<{
10
- tools: ToolUnion[];
11
- callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
12
- }>;
13
- ofSdk: (sdk: _metorial_mcp_sdk_utils.McpSDK, init: _metorial_mcp_session.MetorialMcpSessionInit, input: void) => Promise<{
14
- tools: ToolUnion[];
15
- callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
16
- }>;
17
- };
7
+ }>;
18
8
 
19
9
  export { metorialAnthropic };
package/dist/index.d.ts CHANGED
@@ -1,19 +1,9 @@
1
- import * as _metorial_mcp_session from '@metorial/mcp-session';
2
1
  import * as _metorial_mcp_sdk_utils from '@metorial/mcp-sdk-utils';
3
2
  import { ToolUnion, ToolUseBlock, MessageParam } from '@anthropic-ai/sdk/resources/messages';
4
3
 
5
- declare let metorialAnthropic: ((session: _metorial_mcp_sdk_utils.McpSessionLike, input: void) => Promise<{
6
- tools: ToolUnion[];
4
+ declare let metorialAnthropic: () => _metorial_mcp_sdk_utils.MetorialAdapter<{
5
+ tools: () => ToolUnion[];
7
6
  callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
8
- }>) & {
9
- ofSession: (session: _metorial_mcp_sdk_utils.McpSessionLike, input: void) => Promise<{
10
- tools: ToolUnion[];
11
- callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
12
- }>;
13
- ofSdk: (sdk: _metorial_mcp_sdk_utils.McpSDK, init: _metorial_mcp_session.MetorialMcpSessionInit, input: void) => Promise<{
14
- tools: ToolUnion[];
15
- callTools: (calls: ToolUseBlock[]) => Promise<MessageParam>;
16
- }>;
17
- };
7
+ }>;
18
8
 
19
9
  export { metorialAnthropic };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createMcpSdk } from '@metorial/mcp-sdk-utils';
2
2
 
3
3
  // src/metorialAnthropic.ts
4
- var metorialAnthropic = createMcpSdk()(async ({ tools }) => ({
5
- tools: tools.getTools().map(
4
+ var metorialAnthropic = createMcpSdk(async ({ tools }) => ({
5
+ tools: () => tools.getTools().map(
6
6
  (t) => {
7
7
  var _a;
8
8
  return {
package/dist/index.js.map CHANGED
@@ -1 +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}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,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,12 +1,16 @@
1
1
  {
2
2
  "name": "@metorial/anthropic",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "author": "Metorial Inc.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs",
8
8
  "types": "dist/index.d.ts",
9
9
  "module": "dist/index.js",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/metorial/metorial-node"
13
+ },
10
14
  "exports": {
11
15
  ".": {
12
16
  "types": "./dist/index.d.ts",
@@ -25,10 +29,10 @@
25
29
  "dist"
26
30
  ],
27
31
  "dependencies": {
28
- "@metorial/core": "^2.0.0",
29
- "@metorial/mcp-sdk-utils": "^2.0.0",
30
- "@metorial/mcp-session": "^2.0.0",
31
- "@metorial/openai-compatible": "^2.0.0"
32
+ "@metorial/core": "^2.1.0",
33
+ "@metorial/mcp-sdk-utils": "^2.1.0",
34
+ "@metorial/mcp-session": "^2.1.0",
35
+ "@metorial/openai-compatible": "^2.1.0"
32
36
  },
33
37
  "peerDependencies": {
34
38
  "@anthropic-ai/sdk": "*"