@mclawnet/mcp-server 0.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.
@@ -0,0 +1,3 @@
1
+ export { getAllToolDefinitions, routeToolCall } from "./tools/index.js";
2
+ export type { MemoryToolContext, ToolContext } from "./tools/index.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ // @mclawnet/mcp-server — 统一 MCP 传输层
2
+ export { getAllToolDefinitions, routeToolCall } from "./tools/index.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":""}
package/dist/server.js ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
+ import { homedir } from "node:os";
6
+ import { join } from "node:path";
7
+ import { createLogger } from "@mclawnet/logger";
8
+ import { createEmbeddingProviders, EmbeddingService, initDatabase, MemoryStore, } from "@mclawnet/memory";
9
+ import { SkillStore, EvolutionPipeline } from "@mclawnet/skill-manager";
10
+ import { getAllToolDefinitions, routeToolCall } from "./tools/index.js";
11
+ const log = createLogger({ module: "mcp-server" });
12
+ const dbPath = process.env.CLAWNET_MEMORY_DB ?? join(homedir(), ".clawnet", "memory.db");
13
+ const db = initDatabase(dbPath);
14
+ log.info({ dbPath }, "ClawNet MCP server starting");
15
+ const store = new MemoryStore(db);
16
+ const providers = createEmbeddingProviders();
17
+ const embeddingService = new EmbeddingService(db, providers);
18
+ const clawnetDir = process.env.CLAWNET_DIR ?? join(homedir(), ".clawnet");
19
+ const skillStore = new SkillStore(clawnetDir);
20
+ const evolutionPipeline = new EvolutionPipeline(clawnetDir);
21
+ const context = {
22
+ memory: { store, embeddingService },
23
+ skill: { store: skillStore },
24
+ evolution: { pipeline: evolutionPipeline },
25
+ };
26
+ const server = new Server({ name: "clawnet-mcp", version: "0.1.0" }, { capabilities: { tools: {} } });
27
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
28
+ tools: getAllToolDefinitions(),
29
+ }));
30
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
31
+ const { name, arguments: args } = request.params;
32
+ return routeToolCall(name, (args ?? {}), context);
33
+ });
34
+ const transport = new StdioServerTransport();
35
+ await server.connect(transport);
36
+ log.info("ClawNet MCP server connected via stdio");
37
+ function cleanup() {
38
+ log.info("ClawNet MCP server shutting down");
39
+ try {
40
+ db.close();
41
+ }
42
+ catch {
43
+ // ignore
44
+ }
45
+ }
46
+ process.on("exit", cleanup);
47
+ process.on("SIGINT", () => {
48
+ cleanup();
49
+ process.exit(0);
50
+ });
51
+ process.on("SIGTERM", () => {
52
+ cleanup();
53
+ process.exit(0);
54
+ });
55
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,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,EAAE;IACxB,OAAO,EAAE,CAAC;IACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,OAAO,EAAE,CAAC;IACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,76 @@
1
+ import type { EvolutionPipeline } from "@mclawnet/skill-manager";
2
+ export interface EvolutionToolContext {
3
+ pipeline: EvolutionPipeline;
4
+ }
5
+ export declare function getEvolutionToolDefinitions(): ({
6
+ name: string;
7
+ description: string;
8
+ inputSchema: {
9
+ type: "object";
10
+ properties: {
11
+ skillName: {
12
+ type: string;
13
+ description: string;
14
+ };
15
+ signal: {
16
+ type: string;
17
+ enum: string[];
18
+ };
19
+ problem: {
20
+ type: string;
21
+ description: string;
22
+ };
23
+ fix: {
24
+ type: string;
25
+ description: string;
26
+ };
27
+ patch: {
28
+ type: string;
29
+ description: string;
30
+ };
31
+ id?: undefined;
32
+ };
33
+ required: string[];
34
+ };
35
+ } | {
36
+ name: string;
37
+ description: string;
38
+ inputSchema: {
39
+ type: "object";
40
+ properties: {
41
+ skillName?: undefined;
42
+ signal?: undefined;
43
+ problem?: undefined;
44
+ fix?: undefined;
45
+ patch?: undefined;
46
+ id?: undefined;
47
+ };
48
+ required?: undefined;
49
+ };
50
+ } | {
51
+ name: string;
52
+ description: string;
53
+ inputSchema: {
54
+ type: "object";
55
+ properties: {
56
+ id: {
57
+ type: string;
58
+ description: string;
59
+ };
60
+ skillName?: undefined;
61
+ signal?: undefined;
62
+ problem?: undefined;
63
+ fix?: undefined;
64
+ patch?: undefined;
65
+ };
66
+ required: string[];
67
+ };
68
+ })[];
69
+ export declare function handleEvolutionToolCall(name: string, args: Record<string, unknown>, context: EvolutionToolContext): Promise<{
70
+ content: Array<{
71
+ type: "text";
72
+ text: string;
73
+ }>;
74
+ isError?: boolean;
75
+ }>;
76
+ //# sourceMappingURL=evolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evolution.d.ts","sourceRoot":"","sources":["../../src/tools/evolution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAIjE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAKD,wBAAgB,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiE1C;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAyEhF"}
@@ -0,0 +1,142 @@
1
+ import { createLogger } from "@mclawnet/logger";
2
+ const logger = createLogger({ module: "mcp-server/tools/evolution" });
3
+ // Layer 1 实时进化默认置信度
4
+ const LAYER1_DEFAULT_CONFIDENCE = 0.85;
5
+ export function getEvolutionToolDefinitions() {
6
+ return [
7
+ {
8
+ name: "skill_evolve",
9
+ description: `提交 Skill 进化提案。仅在以下强信号出现时调用:
10
+ 1. 你按照某个 skill 执行但遇到错误,修正后才成功 (signal: skill-error-fixed)
11
+ 2. 用户指出某个 skill 的指引有误,并给出了正确做法 (signal: user-correction)
12
+ 3. 你发现某个 skill 缺少关键步骤,实践中你补上了 (signal: missing-step)
13
+ 4. 某个 skill 的指引在当前平台/环境不适用 (signal: platform-mismatch)
14
+
15
+ 不要在以下情况调用:
16
+ - skill 正常工作没有问题
17
+ - 只是"可能更好"的优化建议
18
+ - 用户没有使用任何 skill 的普通对话`,
19
+ inputSchema: {
20
+ type: "object",
21
+ properties: {
22
+ skillName: { type: "string", description: "要进化的 skill 名称" },
23
+ signal: {
24
+ type: "string",
25
+ enum: [
26
+ "skill-error-fixed",
27
+ "user-correction",
28
+ "missing-step",
29
+ "platform-mismatch",
30
+ ],
31
+ },
32
+ problem: { type: "string", description: "遇到了什么问题" },
33
+ fix: { type: "string", description: "怎么修正的" },
34
+ patch: {
35
+ type: "string",
36
+ description: "修改后的完整 SKILL.md 内容",
37
+ },
38
+ },
39
+ required: ["skillName", "signal", "problem", "fix", "patch"],
40
+ },
41
+ },
42
+ {
43
+ name: "skill_pending_list",
44
+ description: "列出所有待审核的 Skill 进化提案。",
45
+ inputSchema: { type: "object", properties: {} },
46
+ },
47
+ {
48
+ name: "skill_pending_approve",
49
+ description: "批准一条待审核的 Skill 进化提案并应用到本地 skill。",
50
+ inputSchema: {
51
+ type: "object",
52
+ properties: {
53
+ id: { type: "string", description: "pending 提案 id" },
54
+ },
55
+ required: ["id"],
56
+ },
57
+ },
58
+ {
59
+ name: "skill_pending_reject",
60
+ description: "拒绝一条待审核的 Skill 进化提案(不应用,从队列移除)。",
61
+ inputSchema: {
62
+ type: "object",
63
+ properties: {
64
+ id: { type: "string", description: "pending 提案 id" },
65
+ },
66
+ required: ["id"],
67
+ },
68
+ },
69
+ ];
70
+ }
71
+ export async function handleEvolutionToolCall(name, args, context) {
72
+ try {
73
+ switch (name) {
74
+ case "skill_evolve": {
75
+ const result = await context.pipeline.process({
76
+ skillName: String(args.skillName ?? ""),
77
+ signal: args.signal,
78
+ problem: String(args.problem ?? ""),
79
+ fix: String(args.fix ?? ""),
80
+ patch: String(args.patch ?? ""),
81
+ confidence: LAYER1_DEFAULT_CONFIDENCE,
82
+ source: "layer1-realtime",
83
+ });
84
+ return {
85
+ content: [{ type: "text", text: JSON.stringify(result) }],
86
+ isError: result.action === "rejected" || result.action === "blocked",
87
+ };
88
+ }
89
+ case "skill_pending_list": {
90
+ const pending = context.pipeline.listPending();
91
+ return {
92
+ content: [
93
+ { type: "text", text: JSON.stringify({ pending, total: pending.length }) },
94
+ ],
95
+ };
96
+ }
97
+ case "skill_pending_approve": {
98
+ const id = String(args.id ?? "");
99
+ if (!id) {
100
+ return {
101
+ content: [{ type: "text", text: JSON.stringify({ error: "id is required" }) }],
102
+ isError: true,
103
+ };
104
+ }
105
+ const result = context.pipeline.approvePending(id);
106
+ return {
107
+ content: [{ type: "text", text: JSON.stringify(result) }],
108
+ isError: !result.applied,
109
+ };
110
+ }
111
+ case "skill_pending_reject": {
112
+ const id = String(args.id ?? "");
113
+ if (!id) {
114
+ return {
115
+ content: [{ type: "text", text: JSON.stringify({ error: "id is required" }) }],
116
+ isError: true,
117
+ };
118
+ }
119
+ const removed = context.pipeline.rejectPending(id);
120
+ return {
121
+ content: [{ type: "text", text: JSON.stringify({ removed }) }],
122
+ isError: !removed,
123
+ };
124
+ }
125
+ default:
126
+ return {
127
+ content: [
128
+ { type: "text", text: JSON.stringify({ error: `Unknown evolution tool: ${name}` }) },
129
+ ],
130
+ isError: true,
131
+ };
132
+ }
133
+ }
134
+ catch (err) {
135
+ logger.error({ err, tool: name }, "evolution tool error");
136
+ return {
137
+ content: [{ type: "text", text: JSON.stringify({ error: String(err) }) }],
138
+ isError: true,
139
+ };
140
+ }
141
+ }
142
+ //# sourceMappingURL=evolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evolution.js","sourceRoot":"","sources":["../../src/tools/evolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,4BAA4B,EAAE,CAAC,CAAC;AAMtE,oBAAoB;AACpB,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL;YACE,IAAI,EAAE,cAAc;YACpB,WAAW,EAAE;;;;;;;;;uBASI;Y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AC;YACD;gBACE,OAAO;oBACL,OAAO,EAAE;wBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,2BAA2B,IAAI,EAAE,EAAE,CAAC,EAAE;qBACrF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;QACN,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,sBAAsB,CAAC,CAAC;QAC1D,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACzE,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,229 @@
1
+ import { type MemoryToolContext } from "./memory.js";
2
+ import { type SkillToolContext } from "./skill.js";
3
+ import { type EvolutionToolContext } from "./evolution.js";
4
+ export interface ToolContext {
5
+ memory: MemoryToolContext;
6
+ skill: SkillToolContext;
7
+ evolution: EvolutionToolContext;
8
+ }
9
+ export declare function getAllToolDefinitions(): ({
10
+ name: string;
11
+ description: string;
12
+ inputSchema: {
13
+ type: "object";
14
+ properties: {
15
+ roleId: {
16
+ type: string;
17
+ description: string;
18
+ };
19
+ query: {
20
+ type: string;
21
+ description: string;
22
+ };
23
+ domain: {
24
+ type: string;
25
+ description: string;
26
+ };
27
+ limit: {
28
+ type: string;
29
+ description: string;
30
+ };
31
+ crossRole: {
32
+ type: string;
33
+ description: string;
34
+ };
35
+ content?: undefined;
36
+ type?: undefined;
37
+ tags?: undefined;
38
+ importance?: undefined;
39
+ scope?: undefined;
40
+ };
41
+ required: string[];
42
+ };
43
+ } | {
44
+ name: string;
45
+ description: string;
46
+ inputSchema: {
47
+ type: "object";
48
+ properties: {
49
+ roleId: {
50
+ type: string;
51
+ description: string;
52
+ };
53
+ content: {
54
+ type: string;
55
+ description: string;
56
+ };
57
+ type: {
58
+ type: string;
59
+ enum: string[];
60
+ description: string;
61
+ };
62
+ tags: {
63
+ type: string;
64
+ items: {
65
+ type: string;
66
+ };
67
+ description: string;
68
+ };
69
+ domain: {
70
+ type: string;
71
+ description: string;
72
+ };
73
+ importance: {
74
+ type: string;
75
+ description: string;
76
+ };
77
+ query?: undefined;
78
+ limit?: undefined;
79
+ crossRole?: undefined;
80
+ scope?: undefined;
81
+ };
82
+ required: string[];
83
+ };
84
+ } | {
85
+ name: string;
86
+ description: string;
87
+ inputSchema: {
88
+ type: "object";
89
+ properties: {
90
+ roleId: {
91
+ type: string;
92
+ description: string;
93
+ };
94
+ query?: undefined;
95
+ domain?: undefined;
96
+ limit?: undefined;
97
+ crossRole?: undefined;
98
+ content?: undefined;
99
+ type?: undefined;
100
+ tags?: undefined;
101
+ importance?: undefined;
102
+ scope?: undefined;
103
+ };
104
+ required: string[];
105
+ };
106
+ } | {
107
+ name: string;
108
+ description: string;
109
+ inputSchema: {
110
+ type: "object";
111
+ properties: {
112
+ roleId: {
113
+ type: string;
114
+ description: string;
115
+ };
116
+ scope: {
117
+ type: string;
118
+ enum: string[];
119
+ description: string;
120
+ };
121
+ query?: undefined;
122
+ domain?: undefined;
123
+ limit?: undefined;
124
+ crossRole?: undefined;
125
+ content?: undefined;
126
+ type?: undefined;
127
+ tags?: undefined;
128
+ importance?: undefined;
129
+ };
130
+ required: string[];
131
+ };
132
+ } | {
133
+ name: string;
134
+ description: string;
135
+ inputSchema: {
136
+ type: "object";
137
+ properties: {
138
+ name?: undefined;
139
+ };
140
+ required?: undefined;
141
+ };
142
+ } | {
143
+ name: string;
144
+ description: string;
145
+ inputSchema: {
146
+ type: "object";
147
+ properties: {
148
+ name: {
149
+ type: string;
150
+ description: string;
151
+ };
152
+ };
153
+ required: string[];
154
+ };
155
+ } | {
156
+ name: string;
157
+ description: string;
158
+ inputSchema: {
159
+ type: "object";
160
+ properties: {
161
+ skillName: {
162
+ type: string;
163
+ description: string;
164
+ };
165
+ signal: {
166
+ type: string;
167
+ enum: string[];
168
+ };
169
+ problem: {
170
+ type: string;
171
+ description: string;
172
+ };
173
+ fix: {
174
+ type: string;
175
+ description: string;
176
+ };
177
+ patch: {
178
+ type: string;
179
+ description: string;
180
+ };
181
+ id?: undefined;
182
+ };
183
+ required: string[];
184
+ };
185
+ } | {
186
+ name: string;
187
+ description: string;
188
+ inputSchema: {
189
+ type: "object";
190
+ properties: {
191
+ skillName?: undefined;
192
+ signal?: undefined;
193
+ problem?: undefined;
194
+ fix?: undefined;
195
+ patch?: undefined;
196
+ id?: undefined;
197
+ };
198
+ required?: undefined;
199
+ };
200
+ } | {
201
+ name: string;
202
+ description: string;
203
+ inputSchema: {
204
+ type: "object";
205
+ properties: {
206
+ id: {
207
+ type: string;
208
+ description: string;
209
+ };
210
+ skillName?: undefined;
211
+ signal?: undefined;
212
+ problem?: undefined;
213
+ fix?: undefined;
214
+ patch?: undefined;
215
+ };
216
+ required: string[];
217
+ };
218
+ })[];
219
+ export declare function routeToolCall(name: string, args: Record<string, unknown>, context: ToolContext): Promise<{
220
+ content: Array<{
221
+ type: "text";
222
+ text: string;
223
+ }>;
224
+ isError?: boolean;
225
+ }>;
226
+ export type { MemoryToolContext } from "./memory.js";
227
+ export type { SkillToolContext } from "./skill.js";
228
+ export type { EvolutionToolContext } from "./evolution.js";
229
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,EAAgD,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,EAAE,oBAAoB,CAAC;CACjC;AAED,wBAAgB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAMpC;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAehF;AAED,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { getMemoryToolDefinitions, handleMemoryToolCall } from "./memory.js";
2
+ import { getSkillToolDefinitions, handleSkillToolCall } from "./skill.js";
3
+ import { getEvolutionToolDefinitions, handleEvolutionToolCall, } from "./evolution.js";
4
+ export function getAllToolDefinitions() {
5
+ return [
6
+ ...getMemoryToolDefinitions(),
7
+ ...getSkillToolDefinitions(),
8
+ ...getEvolutionToolDefinitions(),
9
+ ];
10
+ }
11
+ export async function routeToolCall(name, args, context) {
12
+ if (name.startsWith("memory_")) {
13
+ return handleMemoryToolCall(name, args, context.memory);
14
+ }
15
+ if (name === "skill_evolve" || name.startsWith("skill_pending")) {
16
+ return handleEvolutionToolCall(name, args, context.evolution);
17
+ }
18
+ if (name.startsWith("skill_")) {
19
+ return handleSkillToolCall(name, args, context.skill);
20
+ }
21
+ return {
22
+ content: [{ type: "text", text: JSON.stringify({ error: `Unknown tool: ${name}` }) }],
23
+ isError: true,
24
+ };
25
+ }
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAA0B,MAAM,aAAa,CAAC;AACrG,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAyB,MAAM,YAAY,CAAC;AACjG,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,GAExB,MAAM,gBAAgB,CAAC;AAQxB,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,GAAG,wBAAwB,EAAE;QAC7B,GAAG,uBAAuB,EAAE;QAC5B,GAAG,2BAA2B,EAAE;KACjC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAY,EACZ,IAA6B,EAC7B,OAAoB;IAEpB,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,OAAO,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QAChE,OAAO,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,OAAO,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACxD,C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