@contractspec/lib.ai-agent 5.0.0 → 5.0.3
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/node/tools/index.js
CHANGED
|
@@ -2612,13 +2612,14 @@ init_json_schema_to_zod();
|
|
|
2612
2612
|
init_i18n();
|
|
2613
2613
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2614
2614
|
import * as z3 from "zod";
|
|
2615
|
+
import { sanitizeMcpName } from "@contractspec/lib.contracts-spec/jsonschema";
|
|
2615
2616
|
function agentToMcpServer(agent, spec) {
|
|
2616
2617
|
const i18n = createAgentI18n(spec.locale);
|
|
2617
2618
|
const server = new McpServer({
|
|
2618
2619
|
name: spec.meta.key,
|
|
2619
2620
|
version: `${spec.meta.version}`
|
|
2620
2621
|
});
|
|
2621
|
-
server.registerTool(spec.meta.key, {
|
|
2622
|
+
server.registerTool(sanitizeMcpName(spec.meta.key), {
|
|
2622
2623
|
description: spec.description ?? i18n.t("tool.mcp.agentDescription", { key: spec.meta.key }),
|
|
2623
2624
|
inputSchema: z3.object({
|
|
2624
2625
|
message: z3.string().describe(i18n.t("tool.mcp.param.message")),
|
|
@@ -2641,7 +2642,7 @@ function agentToMcpServer(agent, spec) {
|
|
|
2641
2642
|
});
|
|
2642
2643
|
for (const toolConfig of spec.tools) {
|
|
2643
2644
|
const inputSchema = toolConfig.schema ? jsonSchemaToZodSafe(toolConfig.schema) : z3.object({});
|
|
2644
|
-
server.registerTool(`${spec.meta.key}.${toolConfig.name}
|
|
2645
|
+
server.registerTool(sanitizeMcpName(`${spec.meta.key}.${toolConfig.name}`), {
|
|
2645
2646
|
description: toolConfig.description ?? i18n.t("tool.mcp.toolDescription", { name: toolConfig.name }),
|
|
2646
2647
|
inputSchema
|
|
2647
2648
|
}, async (args) => {
|
|
@@ -2265,13 +2265,14 @@ init_json_schema_to_zod();
|
|
|
2265
2265
|
init_i18n();
|
|
2266
2266
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2267
2267
|
import * as z2 from "zod";
|
|
2268
|
+
import { sanitizeMcpName } from "@contractspec/lib.contracts-spec/jsonschema";
|
|
2268
2269
|
function agentToMcpServer(agent, spec) {
|
|
2269
2270
|
const i18n = createAgentI18n(spec.locale);
|
|
2270
2271
|
const server = new McpServer({
|
|
2271
2272
|
name: spec.meta.key,
|
|
2272
2273
|
version: `${spec.meta.version}`
|
|
2273
2274
|
});
|
|
2274
|
-
server.registerTool(spec.meta.key, {
|
|
2275
|
+
server.registerTool(sanitizeMcpName(spec.meta.key), {
|
|
2275
2276
|
description: spec.description ?? i18n.t("tool.mcp.agentDescription", { key: spec.meta.key }),
|
|
2276
2277
|
inputSchema: z2.object({
|
|
2277
2278
|
message: z2.string().describe(i18n.t("tool.mcp.param.message")),
|
|
@@ -2294,7 +2295,7 @@ function agentToMcpServer(agent, spec) {
|
|
|
2294
2295
|
});
|
|
2295
2296
|
for (const toolConfig of spec.tools) {
|
|
2296
2297
|
const inputSchema = toolConfig.schema ? jsonSchemaToZodSafe(toolConfig.schema) : z2.object({});
|
|
2297
|
-
server.registerTool(`${spec.meta.key}.${toolConfig.name}
|
|
2298
|
+
server.registerTool(sanitizeMcpName(`${spec.meta.key}.${toolConfig.name}`), {
|
|
2298
2299
|
description: toolConfig.description ?? i18n.t("tool.mcp.toolDescription", { name: toolConfig.name }),
|
|
2299
2300
|
inputSchema
|
|
2300
2301
|
}, async (args) => {
|
package/dist/tools/index.js
CHANGED
|
@@ -2612,13 +2612,14 @@ init_json_schema_to_zod();
|
|
|
2612
2612
|
init_i18n();
|
|
2613
2613
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2614
2614
|
import * as z3 from "zod";
|
|
2615
|
+
import { sanitizeMcpName } from "@contractspec/lib.contracts-spec/jsonschema";
|
|
2615
2616
|
function agentToMcpServer(agent, spec) {
|
|
2616
2617
|
const i18n = createAgentI18n(spec.locale);
|
|
2617
2618
|
const server = new McpServer({
|
|
2618
2619
|
name: spec.meta.key,
|
|
2619
2620
|
version: `${spec.meta.version}`
|
|
2620
2621
|
});
|
|
2621
|
-
server.registerTool(spec.meta.key, {
|
|
2622
|
+
server.registerTool(sanitizeMcpName(spec.meta.key), {
|
|
2622
2623
|
description: spec.description ?? i18n.t("tool.mcp.agentDescription", { key: spec.meta.key }),
|
|
2623
2624
|
inputSchema: z3.object({
|
|
2624
2625
|
message: z3.string().describe(i18n.t("tool.mcp.param.message")),
|
|
@@ -2641,7 +2642,7 @@ function agentToMcpServer(agent, spec) {
|
|
|
2641
2642
|
});
|
|
2642
2643
|
for (const toolConfig of spec.tools) {
|
|
2643
2644
|
const inputSchema = toolConfig.schema ? jsonSchemaToZodSafe(toolConfig.schema) : z3.object({});
|
|
2644
|
-
server.registerTool(`${spec.meta.key}.${toolConfig.name}
|
|
2645
|
+
server.registerTool(sanitizeMcpName(`${spec.meta.key}.${toolConfig.name}`), {
|
|
2645
2646
|
description: toolConfig.description ?? i18n.t("tool.mcp.toolDescription", { name: toolConfig.name }),
|
|
2646
2647
|
inputSchema
|
|
2647
2648
|
}, async (args) => {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe stub for mcp-client. MCP stdio/process spawning cannot run in browser.
|
|
3
|
+
* Use this when bundling for client; the real implementation runs only on Node.
|
|
4
|
+
*/
|
|
5
|
+
import type { Tool } from "ai";
|
|
6
|
+
export type McpTransportType = "stdio" | "sse" | "http";
|
|
7
|
+
interface McpClientBaseConfig {
|
|
8
|
+
name: string;
|
|
9
|
+
toolPrefix?: string;
|
|
10
|
+
clientName?: string;
|
|
11
|
+
clientVersion?: string;
|
|
12
|
+
authMethod?: "api-key" | "oauth2" | "bearer";
|
|
13
|
+
authHeaders?: Record<string, string>;
|
|
14
|
+
apiVersion?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface McpStdioClientConfig extends McpClientBaseConfig {
|
|
17
|
+
transport?: "stdio";
|
|
18
|
+
command: string;
|
|
19
|
+
args?: string[];
|
|
20
|
+
env?: Record<string, string>;
|
|
21
|
+
cwd?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface McpRemoteClientConfig extends McpClientBaseConfig {
|
|
24
|
+
transport: "sse" | "http";
|
|
25
|
+
url: string;
|
|
26
|
+
headers?: Record<string, string>;
|
|
27
|
+
authProvider?: unknown;
|
|
28
|
+
accessToken?: string;
|
|
29
|
+
accessTokenEnvVar?: string;
|
|
30
|
+
}
|
|
31
|
+
export type McpClientConfig = McpStdioClientConfig | McpRemoteClientConfig;
|
|
32
|
+
export interface McpClientResult {
|
|
33
|
+
tools: Record<string, Tool<unknown, unknown>>;
|
|
34
|
+
cleanup: () => Promise<void>;
|
|
35
|
+
serverToolNames: Record<string, string[]>;
|
|
36
|
+
}
|
|
37
|
+
export interface CreateMcpToolsetsOptions {
|
|
38
|
+
onNameCollision?: "overwrite" | "error";
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Browser stub: MCP tools require Node (child_process). Returns empty tools.
|
|
42
|
+
*/
|
|
43
|
+
export declare function mcpServerToTools(_config: McpClientConfig): Promise<McpClientResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Browser stub: MCP tools require Node. Returns empty combined tools.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createMcpToolsets(_configs: McpClientConfig[], _options?: CreateMcpToolsetsOptions): Promise<McpClientResult>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
set: (newValue) => all[name] = () => newValue
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
13
|
+
var __require = import.meta.require;
|
|
14
|
+
|
|
15
|
+
// src/tools/mcp-client.browser.ts
|
|
16
|
+
async function mcpServerToTools(_config) {
|
|
17
|
+
return {
|
|
18
|
+
tools: {},
|
|
19
|
+
cleanup: async () => {},
|
|
20
|
+
serverToolNames: {}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async function createMcpToolsets(_configs, _options = {}) {
|
|
24
|
+
return {
|
|
25
|
+
tools: {},
|
|
26
|
+
cleanup: async () => {},
|
|
27
|
+
serverToolNames: {}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
mcpServerToTools,
|
|
32
|
+
createMcpToolsets
|
|
33
|
+
};
|
package/dist/tools/mcp-server.js
CHANGED
|
@@ -2265,13 +2265,14 @@ init_json_schema_to_zod();
|
|
|
2265
2265
|
init_i18n();
|
|
2266
2266
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2267
2267
|
import * as z2 from "zod";
|
|
2268
|
+
import { sanitizeMcpName } from "@contractspec/lib.contracts-spec/jsonschema";
|
|
2268
2269
|
function agentToMcpServer(agent, spec) {
|
|
2269
2270
|
const i18n = createAgentI18n(spec.locale);
|
|
2270
2271
|
const server = new McpServer({
|
|
2271
2272
|
name: spec.meta.key,
|
|
2272
2273
|
version: `${spec.meta.version}`
|
|
2273
2274
|
});
|
|
2274
|
-
server.registerTool(spec.meta.key, {
|
|
2275
|
+
server.registerTool(sanitizeMcpName(spec.meta.key), {
|
|
2275
2276
|
description: spec.description ?? i18n.t("tool.mcp.agentDescription", { key: spec.meta.key }),
|
|
2276
2277
|
inputSchema: z2.object({
|
|
2277
2278
|
message: z2.string().describe(i18n.t("tool.mcp.param.message")),
|
|
@@ -2294,7 +2295,7 @@ function agentToMcpServer(agent, spec) {
|
|
|
2294
2295
|
});
|
|
2295
2296
|
for (const toolConfig of spec.tools) {
|
|
2296
2297
|
const inputSchema = toolConfig.schema ? jsonSchemaToZodSafe(toolConfig.schema) : z2.object({});
|
|
2297
|
-
server.registerTool(`${spec.meta.key}.${toolConfig.name}
|
|
2298
|
+
server.registerTool(sanitizeMcpName(`${spec.meta.key}.${toolConfig.name}`), {
|
|
2298
2299
|
description: toolConfig.description ?? i18n.t("tool.mcp.toolDescription", { name: toolConfig.name }),
|
|
2299
2300
|
inputSchema
|
|
2300
2301
|
}, async (args) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/lib.ai-agent",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "AI agent orchestration with MCP and tool support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
43
43
|
"@posthog/react": "^1.8.2",
|
|
44
44
|
"@posthog/ai": "7.9.5",
|
|
45
|
-
"@contractspec/lib.contracts-spec": "3.5.
|
|
46
|
-
"@contractspec/lib.ai-providers": "3.5.
|
|
47
|
-
"@contractspec/lib.knowledge": "3.5.
|
|
45
|
+
"@contractspec/lib.contracts-spec": "3.5.3",
|
|
46
|
+
"@contractspec/lib.ai-providers": "3.5.3",
|
|
47
|
+
"@contractspec/lib.knowledge": "3.5.3",
|
|
48
48
|
"compare-versions": "^6.1.1",
|
|
49
49
|
"zod": "^4.3.5"
|
|
50
50
|
},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@anthropic-ai/claude-agent-sdk": ">=0.1.0",
|
|
53
53
|
"@opencode-ai/sdk": ">=1.0.0",
|
|
54
54
|
"posthog-node": ">=4.0.0",
|
|
55
|
-
"@contractspec/lib.surface-runtime": "0.3.
|
|
55
|
+
"@contractspec/lib.surface-runtime": "0.3.3"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@anthropic-ai/claude-agent-sdk": {
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@contractspec/tool.typescript": "3.5.
|
|
75
|
+
"@contractspec/tool.typescript": "3.5.3",
|
|
76
76
|
"typescript": "^5.9.3",
|
|
77
|
-
"@contractspec/tool.bun": "3.5.
|
|
77
|
+
"@contractspec/tool.bun": "3.5.3"
|
|
78
78
|
},
|
|
79
79
|
"exports": {
|
|
80
80
|
".": {
|
|
@@ -505,9 +505,9 @@
|
|
|
505
505
|
},
|
|
506
506
|
"./tools/mcp-client": {
|
|
507
507
|
"types": "./dist/tools/mcp-client.d.ts",
|
|
508
|
-
"bun": "./dist/tools/mcp-client.js",
|
|
508
|
+
"bun": "./dist/tools/mcp-client.browser.js",
|
|
509
509
|
"node": "./dist/node/tools/mcp-client.js",
|
|
510
|
-
"default": "./dist/tools/mcp-client.js"
|
|
510
|
+
"default": "./dist/tools/mcp-client.browser.js"
|
|
511
511
|
},
|
|
512
512
|
"./tools/mcp-client-helpers": {
|
|
513
513
|
"types": "./dist/tools/mcp-client-helpers.d.ts",
|
|
@@ -515,6 +515,11 @@
|
|
|
515
515
|
"node": "./dist/node/tools/mcp-client-helpers.js",
|
|
516
516
|
"default": "./dist/tools/mcp-client-helpers.js"
|
|
517
517
|
},
|
|
518
|
+
"./tools/mcp-client.browser": {
|
|
519
|
+
"types": "./dist/tools/mcp-client.browser.d.ts",
|
|
520
|
+
"bun": "./dist/tools/mcp-client.browser.js",
|
|
521
|
+
"default": "./dist/tools/mcp-client.browser.js"
|
|
522
|
+
},
|
|
518
523
|
"./tools/mcp-server": {
|
|
519
524
|
"types": "./dist/tools/mcp-server.d.ts",
|
|
520
525
|
"bun": "./dist/tools/mcp-server.js",
|
|
@@ -965,9 +970,9 @@
|
|
|
965
970
|
},
|
|
966
971
|
"./tools/mcp-client": {
|
|
967
972
|
"types": "./dist/tools/mcp-client.d.ts",
|
|
968
|
-
"bun": "./dist/tools/mcp-client.js",
|
|
973
|
+
"bun": "./dist/tools/mcp-client.browser.js",
|
|
969
974
|
"node": "./dist/node/tools/mcp-client.js",
|
|
970
|
-
"default": "./dist/tools/mcp-client.js"
|
|
975
|
+
"default": "./dist/tools/mcp-client.browser.js"
|
|
971
976
|
},
|
|
972
977
|
"./tools/mcp-client-helpers": {
|
|
973
978
|
"types": "./dist/tools/mcp-client-helpers.d.ts",
|
|
@@ -975,6 +980,11 @@
|
|
|
975
980
|
"node": "./dist/node/tools/mcp-client-helpers.js",
|
|
976
981
|
"default": "./dist/tools/mcp-client-helpers.js"
|
|
977
982
|
},
|
|
983
|
+
"./tools/mcp-client.browser": {
|
|
984
|
+
"types": "./dist/tools/mcp-client.browser.d.ts",
|
|
985
|
+
"bun": "./dist/tools/mcp-client.browser.js",
|
|
986
|
+
"default": "./dist/tools/mcp-client.browser.js"
|
|
987
|
+
},
|
|
978
988
|
"./tools/mcp-server": {
|
|
979
989
|
"types": "./dist/tools/mcp-server.d.ts",
|
|
980
990
|
"bun": "./dist/tools/mcp-server.js",
|