@agiflowai/one-mcp 0.3.2 → 0.3.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/cli.cjs +89 -41
- package/dist/cli.mjs +89 -41
- package/dist/{http-C4IfZSwW.cjs → http-BzrxGEr-.cjs} +159 -129
- package/dist/{http-xi_ha63Y.mjs → http-DeUYygKb.mjs} +159 -129
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_http = require('./http-
|
|
2
|
+
const require_http = require('./http-BzrxGEr-.cjs');
|
|
3
3
|
let node_fs_promises = require("node:fs/promises");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
let liquidjs = require("liquidjs");
|
|
@@ -148,14 +148,27 @@ const listToolsCommand = new commander.Command("list-tools").description("List a
|
|
|
148
148
|
process.exit(1);
|
|
149
149
|
}
|
|
150
150
|
const toolsByServer = {};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
151
|
+
const toolResults = await Promise.all(clients.map(async (client) => {
|
|
152
|
+
try {
|
|
153
|
+
const tools = await client.listTools();
|
|
154
|
+
const blacklist = new Set(client.toolBlacklist || []);
|
|
155
|
+
const filteredTools = tools.filter((t) => !blacklist.has(t.name));
|
|
156
|
+
return {
|
|
157
|
+
serverName: client.serverName,
|
|
158
|
+
tools: filteredTools,
|
|
159
|
+
error: null
|
|
160
|
+
};
|
|
161
|
+
} catch (error) {
|
|
162
|
+
return {
|
|
163
|
+
serverName: client.serverName,
|
|
164
|
+
tools: [],
|
|
165
|
+
error
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}));
|
|
169
|
+
for (const { serverName, tools, error } of toolResults) {
|
|
170
|
+
if (error && !options.json) console.error(`Failed to list tools from ${serverName}:`, error);
|
|
171
|
+
toolsByServer[serverName] = tools;
|
|
159
172
|
}
|
|
160
173
|
if (options.json) console.log(JSON.stringify(toolsByServer, null, 2));
|
|
161
174
|
else for (const [serverName, tools] of Object.entries(toolsByServer)) {
|
|
@@ -229,43 +242,60 @@ const describeToolsCommand = new commander.Command("describe-tools").description
|
|
|
229
242
|
const foundTools = [];
|
|
230
243
|
const foundSkills = [];
|
|
231
244
|
const notFoundTools = [...toolNames];
|
|
232
|
-
|
|
233
|
-
|
|
245
|
+
const filteredClients = clients.filter((client) => !options.server || client.serverName === options.server);
|
|
246
|
+
const toolResults = await Promise.all(filteredClients.map(async (client) => {
|
|
234
247
|
try {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
server: client.serverName,
|
|
241
|
-
name: tool.name,
|
|
242
|
-
description: tool.description,
|
|
243
|
-
inputSchema: tool.inputSchema
|
|
244
|
-
});
|
|
245
|
-
const idx = notFoundTools.indexOf(toolName);
|
|
246
|
-
if (idx > -1) notFoundTools.splice(idx, 1);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
248
|
+
return {
|
|
249
|
+
client,
|
|
250
|
+
tools: await client.listTools(),
|
|
251
|
+
error: null
|
|
252
|
+
};
|
|
249
253
|
} catch (error) {
|
|
254
|
+
return {
|
|
255
|
+
client,
|
|
256
|
+
tools: [],
|
|
257
|
+
error
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
}));
|
|
261
|
+
for (const { client, tools, error } of toolResults) {
|
|
262
|
+
if (error) {
|
|
250
263
|
if (!options.json) console.error(`Failed to list tools from ${client.serverName}:`, error);
|
|
264
|
+
continue;
|
|
251
265
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
name: skill.name,
|
|
261
|
-
location: skill.basePath,
|
|
262
|
-
instructions: skill.content
|
|
266
|
+
for (const toolName of toolNames) {
|
|
267
|
+
const tool = tools.find((t) => t.name === toolName);
|
|
268
|
+
if (tool) {
|
|
269
|
+
foundTools.push({
|
|
270
|
+
server: client.serverName,
|
|
271
|
+
name: tool.name,
|
|
272
|
+
description: tool.description,
|
|
273
|
+
inputSchema: tool.inputSchema
|
|
263
274
|
});
|
|
264
275
|
const idx = notFoundTools.indexOf(toolName);
|
|
265
276
|
if (idx > -1) notFoundTools.splice(idx, 1);
|
|
266
277
|
}
|
|
267
278
|
}
|
|
268
279
|
}
|
|
280
|
+
if (skillService && notFoundTools.length > 0) {
|
|
281
|
+
const skillsToCheck = [...notFoundTools];
|
|
282
|
+
const skillResults = await Promise.all(skillsToCheck.map(async (toolName) => {
|
|
283
|
+
const skillName = toolName.startsWith("skill__") ? toolName.slice(7) : toolName;
|
|
284
|
+
return {
|
|
285
|
+
toolName,
|
|
286
|
+
skill: await skillService.getSkill(skillName)
|
|
287
|
+
};
|
|
288
|
+
}));
|
|
289
|
+
for (const { toolName, skill } of skillResults) if (skill) {
|
|
290
|
+
foundSkills.push({
|
|
291
|
+
name: skill.name,
|
|
292
|
+
location: skill.basePath,
|
|
293
|
+
instructions: skill.content
|
|
294
|
+
});
|
|
295
|
+
const idx = notFoundTools.indexOf(toolName);
|
|
296
|
+
if (idx > -1) notFoundTools.splice(idx, 1);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
269
299
|
const nextSteps = [];
|
|
270
300
|
if (foundTools.length > 0) nextSteps.push("For MCP tools: Use the use_tool function with toolName and toolArgs based on the inputSchema above.");
|
|
271
301
|
if (foundSkills.length > 0) nextSteps.push(`For skill, just follow skill's description to continue.`);
|
|
@@ -398,11 +428,29 @@ const useToolCommand = new commander.Command("use-tool").description("Execute an
|
|
|
398
428
|
process.exit(1);
|
|
399
429
|
}
|
|
400
430
|
}
|
|
431
|
+
const searchResults = await Promise.all(clients.map(async (client$1) => {
|
|
432
|
+
try {
|
|
433
|
+
const hasTool = (await client$1.listTools()).some((t) => t.name === toolName);
|
|
434
|
+
return {
|
|
435
|
+
serverName: client$1.serverName,
|
|
436
|
+
hasTool,
|
|
437
|
+
error: null
|
|
438
|
+
};
|
|
439
|
+
} catch (error) {
|
|
440
|
+
return {
|
|
441
|
+
serverName: client$1.serverName,
|
|
442
|
+
hasTool: false,
|
|
443
|
+
error
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
}));
|
|
401
447
|
const matchingServers = [];
|
|
402
|
-
for (const
|
|
403
|
-
if (
|
|
404
|
-
|
|
405
|
-
|
|
448
|
+
for (const { serverName, hasTool, error } of searchResults) {
|
|
449
|
+
if (error) {
|
|
450
|
+
if (!options.json) console.error(`Failed to list tools from ${serverName}:`, error);
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (hasTool) matchingServers.push(serverName);
|
|
406
454
|
}
|
|
407
455
|
if (matchingServers.length === 0) {
|
|
408
456
|
const cwd = process.env.PROJECT_PATH || process.cwd();
|
|
@@ -1003,7 +1051,7 @@ const prefetchCommand = new commander.Command("prefetch").description("Pre-downl
|
|
|
1003
1051
|
|
|
1004
1052
|
//#endregion
|
|
1005
1053
|
//#region package.json
|
|
1006
|
-
var version = "0.3.
|
|
1054
|
+
var version = "0.3.2";
|
|
1007
1055
|
|
|
1008
1056
|
//#endregion
|
|
1009
1057
|
//#region src/cli.ts
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as SkillService, c as ConfigFetcherService, i as createServer, n as SseTransportHandler, o as findConfigFile, r as StdioTransportHandler, s as McpClientManagerService, t as HttpTransportHandler } from "./http-
|
|
2
|
+
import { a as SkillService, c as ConfigFetcherService, i as createServer, n as SseTransportHandler, o as findConfigFile, r as StdioTransportHandler, s as McpClientManagerService, t as HttpTransportHandler } from "./http-DeUYygKb.mjs";
|
|
3
3
|
import { writeFile } from "node:fs/promises";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { Liquid } from "liquidjs";
|
|
@@ -148,14 +148,27 @@ const listToolsCommand = new Command("list-tools").description("List all availab
|
|
|
148
148
|
process.exit(1);
|
|
149
149
|
}
|
|
150
150
|
const toolsByServer = {};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
151
|
+
const toolResults = await Promise.all(clients.map(async (client) => {
|
|
152
|
+
try {
|
|
153
|
+
const tools = await client.listTools();
|
|
154
|
+
const blacklist = new Set(client.toolBlacklist || []);
|
|
155
|
+
const filteredTools = tools.filter((t) => !blacklist.has(t.name));
|
|
156
|
+
return {
|
|
157
|
+
serverName: client.serverName,
|
|
158
|
+
tools: filteredTools,
|
|
159
|
+
error: null
|
|
160
|
+
};
|
|
161
|
+
} catch (error) {
|
|
162
|
+
return {
|
|
163
|
+
serverName: client.serverName,
|
|
164
|
+
tools: [],
|
|
165
|
+
error
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}));
|
|
169
|
+
for (const { serverName, tools, error } of toolResults) {
|
|
170
|
+
if (error && !options.json) console.error(`Failed to list tools from ${serverName}:`, error);
|
|
171
|
+
toolsByServer[serverName] = tools;
|
|
159
172
|
}
|
|
160
173
|
if (options.json) console.log(JSON.stringify(toolsByServer, null, 2));
|
|
161
174
|
else for (const [serverName, tools] of Object.entries(toolsByServer)) {
|
|
@@ -229,43 +242,60 @@ const describeToolsCommand = new Command("describe-tools").description("Describe
|
|
|
229
242
|
const foundTools = [];
|
|
230
243
|
const foundSkills = [];
|
|
231
244
|
const notFoundTools = [...toolNames];
|
|
232
|
-
|
|
233
|
-
|
|
245
|
+
const filteredClients = clients.filter((client) => !options.server || client.serverName === options.server);
|
|
246
|
+
const toolResults = await Promise.all(filteredClients.map(async (client) => {
|
|
234
247
|
try {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
server: client.serverName,
|
|
241
|
-
name: tool.name,
|
|
242
|
-
description: tool.description,
|
|
243
|
-
inputSchema: tool.inputSchema
|
|
244
|
-
});
|
|
245
|
-
const idx = notFoundTools.indexOf(toolName);
|
|
246
|
-
if (idx > -1) notFoundTools.splice(idx, 1);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
248
|
+
return {
|
|
249
|
+
client,
|
|
250
|
+
tools: await client.listTools(),
|
|
251
|
+
error: null
|
|
252
|
+
};
|
|
249
253
|
} catch (error) {
|
|
254
|
+
return {
|
|
255
|
+
client,
|
|
256
|
+
tools: [],
|
|
257
|
+
error
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
}));
|
|
261
|
+
for (const { client, tools, error } of toolResults) {
|
|
262
|
+
if (error) {
|
|
250
263
|
if (!options.json) console.error(`Failed to list tools from ${client.serverName}:`, error);
|
|
264
|
+
continue;
|
|
251
265
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
name: skill.name,
|
|
261
|
-
location: skill.basePath,
|
|
262
|
-
instructions: skill.content
|
|
266
|
+
for (const toolName of toolNames) {
|
|
267
|
+
const tool = tools.find((t) => t.name === toolName);
|
|
268
|
+
if (tool) {
|
|
269
|
+
foundTools.push({
|
|
270
|
+
server: client.serverName,
|
|
271
|
+
name: tool.name,
|
|
272
|
+
description: tool.description,
|
|
273
|
+
inputSchema: tool.inputSchema
|
|
263
274
|
});
|
|
264
275
|
const idx = notFoundTools.indexOf(toolName);
|
|
265
276
|
if (idx > -1) notFoundTools.splice(idx, 1);
|
|
266
277
|
}
|
|
267
278
|
}
|
|
268
279
|
}
|
|
280
|
+
if (skillService && notFoundTools.length > 0) {
|
|
281
|
+
const skillsToCheck = [...notFoundTools];
|
|
282
|
+
const skillResults = await Promise.all(skillsToCheck.map(async (toolName) => {
|
|
283
|
+
const skillName = toolName.startsWith("skill__") ? toolName.slice(7) : toolName;
|
|
284
|
+
return {
|
|
285
|
+
toolName,
|
|
286
|
+
skill: await skillService.getSkill(skillName)
|
|
287
|
+
};
|
|
288
|
+
}));
|
|
289
|
+
for (const { toolName, skill } of skillResults) if (skill) {
|
|
290
|
+
foundSkills.push({
|
|
291
|
+
name: skill.name,
|
|
292
|
+
location: skill.basePath,
|
|
293
|
+
instructions: skill.content
|
|
294
|
+
});
|
|
295
|
+
const idx = notFoundTools.indexOf(toolName);
|
|
296
|
+
if (idx > -1) notFoundTools.splice(idx, 1);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
269
299
|
const nextSteps = [];
|
|
270
300
|
if (foundTools.length > 0) nextSteps.push("For MCP tools: Use the use_tool function with toolName and toolArgs based on the inputSchema above.");
|
|
271
301
|
if (foundSkills.length > 0) nextSteps.push(`For skill, just follow skill's description to continue.`);
|
|
@@ -398,11 +428,29 @@ const useToolCommand = new Command("use-tool").description("Execute an MCP tool
|
|
|
398
428
|
process.exit(1);
|
|
399
429
|
}
|
|
400
430
|
}
|
|
431
|
+
const searchResults = await Promise.all(clients.map(async (client$1) => {
|
|
432
|
+
try {
|
|
433
|
+
const hasTool = (await client$1.listTools()).some((t) => t.name === toolName);
|
|
434
|
+
return {
|
|
435
|
+
serverName: client$1.serverName,
|
|
436
|
+
hasTool,
|
|
437
|
+
error: null
|
|
438
|
+
};
|
|
439
|
+
} catch (error) {
|
|
440
|
+
return {
|
|
441
|
+
serverName: client$1.serverName,
|
|
442
|
+
hasTool: false,
|
|
443
|
+
error
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
}));
|
|
401
447
|
const matchingServers = [];
|
|
402
|
-
for (const
|
|
403
|
-
if (
|
|
404
|
-
|
|
405
|
-
|
|
448
|
+
for (const { serverName, hasTool, error } of searchResults) {
|
|
449
|
+
if (error) {
|
|
450
|
+
if (!options.json) console.error(`Failed to list tools from ${serverName}:`, error);
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (hasTool) matchingServers.push(serverName);
|
|
406
454
|
}
|
|
407
455
|
if (matchingServers.length === 0) {
|
|
408
456
|
const cwd = process.env.PROJECT_PATH || process.cwd();
|
|
@@ -1003,7 +1051,7 @@ const prefetchCommand = new Command("prefetch").description("Pre-download packag
|
|
|
1003
1051
|
|
|
1004
1052
|
//#endregion
|
|
1005
1053
|
//#region package.json
|
|
1006
|
-
var version = "0.3.
|
|
1054
|
+
var version = "0.3.2";
|
|
1007
1055
|
|
|
1008
1056
|
//#endregion
|
|
1009
1057
|
//#region src/cli.ts
|
|
@@ -557,22 +557,21 @@ var RemoteConfigCacheService = class {
|
|
|
557
557
|
try {
|
|
558
558
|
if (!(0, node_fs.existsSync)(this.cacheDir)) return;
|
|
559
559
|
const now = Date.now();
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
for (const file of files) {
|
|
563
|
-
if (!file.endsWith(".json")) continue;
|
|
560
|
+
const jsonFiles = (await (0, node_fs_promises.readdir)(this.cacheDir)).filter((file) => file.endsWith(".json"));
|
|
561
|
+
const expiredCount = (await Promise.all(jsonFiles.map(async (file) => {
|
|
564
562
|
const filePath = (0, node_path.join)(this.cacheDir, file);
|
|
565
563
|
try {
|
|
566
564
|
const content = await (0, node_fs_promises.readFile)(filePath, "utf-8");
|
|
567
565
|
if (now > JSON.parse(content).expiresAt) {
|
|
568
566
|
await (0, node_fs_promises.unlink)(filePath);
|
|
569
|
-
|
|
567
|
+
return true;
|
|
570
568
|
}
|
|
569
|
+
return false;
|
|
571
570
|
} catch (error) {
|
|
572
571
|
await (0, node_fs_promises.unlink)(filePath).catch(() => {});
|
|
573
|
-
|
|
572
|
+
return true;
|
|
574
573
|
}
|
|
575
|
-
}
|
|
574
|
+
}))).filter(Boolean).length;
|
|
576
575
|
if (expiredCount > 0) console.error(`Cleaned up ${expiredCount} expired remote config cache entries`);
|
|
577
576
|
} catch (error) {
|
|
578
577
|
console.error("Failed to clean expired remote config cache:", error);
|
|
@@ -588,14 +587,15 @@ var RemoteConfigCacheService = class {
|
|
|
588
587
|
totalSize: 0
|
|
589
588
|
};
|
|
590
589
|
const jsonFiles = (await (0, node_fs_promises.readdir)(this.cacheDir)).filter((file) => file.endsWith(".json"));
|
|
591
|
-
|
|
592
|
-
for (const file of jsonFiles) {
|
|
590
|
+
const totalSize = (await Promise.all(jsonFiles.map(async (file) => {
|
|
593
591
|
const filePath = (0, node_path.join)(this.cacheDir, file);
|
|
594
592
|
try {
|
|
595
593
|
const content = await (0, node_fs_promises.readFile)(filePath, "utf-8");
|
|
596
|
-
|
|
597
|
-
} catch {
|
|
598
|
-
|
|
594
|
+
return Buffer.byteLength(content, "utf-8");
|
|
595
|
+
} catch {
|
|
596
|
+
return 0;
|
|
597
|
+
}
|
|
598
|
+
}))).reduce((sum, size) => sum + size, 0);
|
|
599
599
|
return {
|
|
600
600
|
totalEntries: jsonFiles.length,
|
|
601
601
|
totalSize
|
|
@@ -1416,13 +1416,13 @@ var SkillService = class {
|
|
|
1416
1416
|
if (this.cachedSkills !== null) return this.cachedSkills;
|
|
1417
1417
|
const skills = [];
|
|
1418
1418
|
const loadedSkillNames = /* @__PURE__ */ new Set();
|
|
1419
|
-
|
|
1419
|
+
const allDirSkills = await Promise.all(this.skillPaths.map(async (skillPath) => {
|
|
1420
1420
|
const skillsDir = (0, node_path.isAbsolute)(skillPath) ? skillPath : (0, node_path.join)(this.cwd, skillPath);
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1421
|
+
return this.loadSkillsFromDirectory(skillsDir, "project");
|
|
1422
|
+
}));
|
|
1423
|
+
for (const dirSkills of allDirSkills) for (const skill of dirSkills) if (!loadedSkillNames.has(skill.name)) {
|
|
1424
|
+
skills.push(skill);
|
|
1425
|
+
loadedSkillNames.add(skill.name);
|
|
1426
1426
|
}
|
|
1427
1427
|
this.cachedSkills = skills;
|
|
1428
1428
|
this.skillsByName = new Map(skills.map((skill) => [skill.name, skill]));
|
|
@@ -1460,9 +1460,15 @@ var SkillService = class {
|
|
|
1460
1460
|
*/
|
|
1461
1461
|
async startWatching() {
|
|
1462
1462
|
this.stopWatching();
|
|
1463
|
-
|
|
1463
|
+
const existenceChecks = await Promise.all(this.skillPaths.map(async (skillPath) => {
|
|
1464
1464
|
const skillsDir = (0, node_path.isAbsolute)(skillPath) ? skillPath : (0, node_path.join)(this.cwd, skillPath);
|
|
1465
|
-
|
|
1465
|
+
return {
|
|
1466
|
+
skillsDir,
|
|
1467
|
+
exists: await pathExists(skillsDir)
|
|
1468
|
+
};
|
|
1469
|
+
}));
|
|
1470
|
+
for (const { skillsDir, exists } of existenceChecks) {
|
|
1471
|
+
if (!exists) continue;
|
|
1466
1472
|
const abortController = new AbortController();
|
|
1467
1473
|
this.watchers.push(abortController);
|
|
1468
1474
|
this.watchDirectory(skillsDir, abortController.signal).catch((error) => {
|
|
@@ -1520,34 +1526,49 @@ var SkillService = class {
|
|
|
1520
1526
|
} catch (error) {
|
|
1521
1527
|
throw new SkillLoadError(`Failed to read skills directory: ${error instanceof Error ? error.message : "Unknown error"}`, dirPath, error instanceof Error ? error : void 0);
|
|
1522
1528
|
}
|
|
1523
|
-
|
|
1529
|
+
const entryStats = await Promise.all(entries.map(async (entry) => {
|
|
1524
1530
|
const entryPath = (0, node_path.join)(dirPath, entry);
|
|
1525
|
-
let entryStat;
|
|
1526
1531
|
try {
|
|
1527
|
-
|
|
1532
|
+
return {
|
|
1533
|
+
entry,
|
|
1534
|
+
entryPath,
|
|
1535
|
+
stat: await (0, node_fs_promises.stat)(entryPath),
|
|
1536
|
+
error: null
|
|
1537
|
+
};
|
|
1528
1538
|
} catch (error) {
|
|
1529
1539
|
console.warn(`Skipping entry ${entryPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1530
|
-
|
|
1540
|
+
return {
|
|
1541
|
+
entry,
|
|
1542
|
+
entryPath,
|
|
1543
|
+
stat: null,
|
|
1544
|
+
error
|
|
1545
|
+
};
|
|
1531
1546
|
}
|
|
1547
|
+
}));
|
|
1548
|
+
const skillFilesToLoad = [];
|
|
1549
|
+
for (const { entry, entryPath, stat: entryStat } of entryStats) {
|
|
1550
|
+
if (!entryStat) continue;
|
|
1532
1551
|
if (entryStat.isDirectory()) {
|
|
1533
1552
|
const skillFilePath = (0, node_path.join)(entryPath, "SKILL.md");
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
if (
|
|
1553
|
+
skillFilesToLoad.push({
|
|
1554
|
+
filePath: skillFilePath,
|
|
1555
|
+
isRootLevel: false
|
|
1556
|
+
});
|
|
1557
|
+
} else if (entry === "SKILL.md") skillFilesToLoad.push({
|
|
1558
|
+
filePath: entryPath,
|
|
1559
|
+
isRootLevel: true
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
const loadResults = await Promise.all(skillFilesToLoad.map(async ({ filePath, isRootLevel }) => {
|
|
1563
|
+
try {
|
|
1564
|
+
if (!isRootLevel && !await pathExists(filePath)) return null;
|
|
1565
|
+
return await this.loadSkillFile(filePath, location);
|
|
1546
1566
|
} catch (error) {
|
|
1547
|
-
console.warn(`Skipping skill at ${
|
|
1548
|
-
|
|
1567
|
+
console.warn(`Skipping skill at ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1568
|
+
return null;
|
|
1549
1569
|
}
|
|
1550
|
-
}
|
|
1570
|
+
}));
|
|
1571
|
+
for (const skill of loadResults) if (skill) skills.push(skill);
|
|
1551
1572
|
return skills;
|
|
1552
1573
|
}
|
|
1553
1574
|
/**
|
|
@@ -1689,44 +1710,42 @@ var DescribeToolsTool = class DescribeToolsTool {
|
|
|
1689
1710
|
async detectSkillsFromPromptFrontMatter() {
|
|
1690
1711
|
if (this.autoDetectedSkillsCache !== null) return this.autoDetectedSkillsCache;
|
|
1691
1712
|
const clients = this.clientManager.getAllClients();
|
|
1692
|
-
const autoDetectedSkills = [];
|
|
1693
1713
|
let listPromptsFailures = 0;
|
|
1694
1714
|
let fetchPromptFailures = 0;
|
|
1695
|
-
const
|
|
1696
|
-
|
|
1715
|
+
const autoDetectedSkills = (await Promise.all(clients.map(async (client) => {
|
|
1716
|
+
const detectedSkills = [];
|
|
1697
1717
|
const configuredPromptNames = new Set(client.prompts ? Object.keys(client.prompts) : []);
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
|
|
1728
|
-
}
|
|
1729
|
-
await Promise.all(fetchPromises);
|
|
1718
|
+
try {
|
|
1719
|
+
const prompts = await client.listPrompts();
|
|
1720
|
+
if (!prompts || prompts.length === 0) return detectedSkills;
|
|
1721
|
+
const promptResults = await Promise.all(prompts.map(async (promptInfo) => {
|
|
1722
|
+
if (configuredPromptNames.has(promptInfo.name)) return null;
|
|
1723
|
+
try {
|
|
1724
|
+
const skillExtraction = extractSkillFrontMatter(((await client.getPrompt(promptInfo.name)).messages || []).map((m) => {
|
|
1725
|
+
const content = m.content;
|
|
1726
|
+
if (typeof content === "string") return content;
|
|
1727
|
+
if (content && typeof content === "object" && "text" in content) return String(content.text);
|
|
1728
|
+
return "";
|
|
1729
|
+
}).join("\n"));
|
|
1730
|
+
if (skillExtraction) return {
|
|
1731
|
+
serverName: client.serverName,
|
|
1732
|
+
promptName: promptInfo.name,
|
|
1733
|
+
skill: skillExtraction.skill
|
|
1734
|
+
};
|
|
1735
|
+
return null;
|
|
1736
|
+
} catch (error) {
|
|
1737
|
+
fetchPromptFailures++;
|
|
1738
|
+
console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to fetch prompt '${promptInfo.name}' from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1739
|
+
return null;
|
|
1740
|
+
}
|
|
1741
|
+
}));
|
|
1742
|
+
for (const result of promptResults) if (result) detectedSkills.push(result);
|
|
1743
|
+
} catch (error) {
|
|
1744
|
+
listPromptsFailures++;
|
|
1745
|
+
console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to list prompts from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1746
|
+
}
|
|
1747
|
+
return detectedSkills;
|
|
1748
|
+
}))).flat();
|
|
1730
1749
|
if (listPromptsFailures > 0 || fetchPromptFailures > 0) console.error(`${LOG_PREFIX_SKILL_DETECTION} Completed with ${listPromptsFailures} server failure(s) and ${fetchPromptFailures} prompt failure(s). Detected ${autoDetectedSkills.length} skill(s).`);
|
|
1731
1750
|
this.autoDetectedSkillsCache = autoDetectedSkills;
|
|
1732
1751
|
return autoDetectedSkills;
|
|
@@ -1977,40 +1996,42 @@ var DescribeToolsTool = class DescribeToolsTool {
|
|
|
1977
1996
|
serverToolsMap.set(client.serverName, []);
|
|
1978
1997
|
}
|
|
1979
1998
|
}));
|
|
1980
|
-
const
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1999
|
+
const lookupResults = await Promise.all(toolNames.map(async (requestedName) => {
|
|
2000
|
+
const result$1 = {
|
|
2001
|
+
tools: [],
|
|
2002
|
+
skills: [],
|
|
2003
|
+
notFound: null
|
|
2004
|
+
};
|
|
1984
2005
|
if (requestedName.startsWith(SKILL_PREFIX)) {
|
|
1985
2006
|
const skillName = requestedName.slice(SKILL_PREFIX.length);
|
|
1986
2007
|
if (this.skillService) {
|
|
1987
2008
|
const skill = await this.skillService.getSkill(skillName);
|
|
1988
2009
|
if (skill) {
|
|
1989
|
-
|
|
2010
|
+
result$1.skills.push({
|
|
1990
2011
|
name: skill.name,
|
|
1991
2012
|
location: skill.basePath,
|
|
1992
2013
|
instructions: formatSkillInstructions(skill.name, skill.content)
|
|
1993
2014
|
});
|
|
1994
|
-
|
|
2015
|
+
return result$1;
|
|
1995
2016
|
}
|
|
1996
2017
|
}
|
|
1997
2018
|
const promptSkillContent = await this.getPromptSkillContent(skillName);
|
|
1998
2019
|
if (promptSkillContent) {
|
|
1999
|
-
|
|
2000
|
-
|
|
2020
|
+
result$1.skills.push(promptSkillContent);
|
|
2021
|
+
return result$1;
|
|
2001
2022
|
}
|
|
2002
|
-
|
|
2003
|
-
|
|
2023
|
+
result$1.notFound = requestedName;
|
|
2024
|
+
return result$1;
|
|
2004
2025
|
}
|
|
2005
2026
|
const { serverName, actualToolName } = parseToolName(requestedName);
|
|
2006
2027
|
if (serverName) {
|
|
2007
2028
|
const serverTools = serverToolsMap.get(serverName);
|
|
2008
2029
|
if (!serverTools) {
|
|
2009
|
-
|
|
2010
|
-
|
|
2030
|
+
result$1.notFound = requestedName;
|
|
2031
|
+
return result$1;
|
|
2011
2032
|
}
|
|
2012
2033
|
const tool = serverTools.find((t) => t.name === actualToolName);
|
|
2013
|
-
if (tool)
|
|
2034
|
+
if (tool) result$1.tools.push({
|
|
2014
2035
|
server: serverName,
|
|
2015
2036
|
tool: {
|
|
2016
2037
|
name: tool.name,
|
|
@@ -2018,52 +2039,61 @@ var DescribeToolsTool = class DescribeToolsTool {
|
|
|
2018
2039
|
inputSchema: tool.inputSchema
|
|
2019
2040
|
}
|
|
2020
2041
|
});
|
|
2021
|
-
else
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
}
|
|
2036
|
-
const promptSkillContent = await this.getPromptSkillContent(actualToolName);
|
|
2037
|
-
if (promptSkillContent) {
|
|
2038
|
-
foundSkills.push(promptSkillContent);
|
|
2039
|
-
continue;
|
|
2042
|
+
else result$1.notFound = requestedName;
|
|
2043
|
+
return result$1;
|
|
2044
|
+
}
|
|
2045
|
+
const servers = toolToServers.get(actualToolName);
|
|
2046
|
+
if (!servers || servers.length === 0) {
|
|
2047
|
+
if (this.skillService) {
|
|
2048
|
+
const skill = await this.skillService.getSkill(actualToolName);
|
|
2049
|
+
if (skill) {
|
|
2050
|
+
result$1.skills.push({
|
|
2051
|
+
name: skill.name,
|
|
2052
|
+
location: skill.basePath,
|
|
2053
|
+
instructions: formatSkillInstructions(skill.name, skill.content)
|
|
2054
|
+
});
|
|
2055
|
+
return result$1;
|
|
2040
2056
|
}
|
|
2041
|
-
notFoundItems.push(requestedName);
|
|
2042
|
-
continue;
|
|
2043
2057
|
}
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
server,
|
|
2049
|
-
tool: {
|
|
2050
|
-
name: tool.name,
|
|
2051
|
-
description: tool.description,
|
|
2052
|
-
inputSchema: tool.inputSchema
|
|
2053
|
-
}
|
|
2054
|
-
});
|
|
2055
|
-
} else for (const server of servers) {
|
|
2056
|
-
const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
|
|
2057
|
-
foundTools.push({
|
|
2058
|
-
server,
|
|
2059
|
-
tool: {
|
|
2060
|
-
name: tool.name,
|
|
2061
|
-
description: tool.description,
|
|
2062
|
-
inputSchema: tool.inputSchema
|
|
2063
|
-
}
|
|
2064
|
-
});
|
|
2058
|
+
const promptSkillContent = await this.getPromptSkillContent(actualToolName);
|
|
2059
|
+
if (promptSkillContent) {
|
|
2060
|
+
result$1.skills.push(promptSkillContent);
|
|
2061
|
+
return result$1;
|
|
2065
2062
|
}
|
|
2063
|
+
result$1.notFound = requestedName;
|
|
2064
|
+
return result$1;
|
|
2066
2065
|
}
|
|
2066
|
+
if (servers.length === 1) {
|
|
2067
|
+
const server = servers[0];
|
|
2068
|
+
const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
|
|
2069
|
+
result$1.tools.push({
|
|
2070
|
+
server,
|
|
2071
|
+
tool: {
|
|
2072
|
+
name: tool.name,
|
|
2073
|
+
description: tool.description,
|
|
2074
|
+
inputSchema: tool.inputSchema
|
|
2075
|
+
}
|
|
2076
|
+
});
|
|
2077
|
+
} else for (const server of servers) {
|
|
2078
|
+
const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
|
|
2079
|
+
result$1.tools.push({
|
|
2080
|
+
server,
|
|
2081
|
+
tool: {
|
|
2082
|
+
name: tool.name,
|
|
2083
|
+
description: tool.description,
|
|
2084
|
+
inputSchema: tool.inputSchema
|
|
2085
|
+
}
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
return result$1;
|
|
2089
|
+
}));
|
|
2090
|
+
const foundTools = [];
|
|
2091
|
+
const foundSkills = [];
|
|
2092
|
+
const notFoundItems = [];
|
|
2093
|
+
for (const result$1 of lookupResults) {
|
|
2094
|
+
foundTools.push(...result$1.tools);
|
|
2095
|
+
foundSkills.push(...result$1.skills);
|
|
2096
|
+
if (result$1.notFound) notFoundItems.push(result$1.notFound);
|
|
2067
2097
|
}
|
|
2068
2098
|
if (foundTools.length === 0 && foundSkills.length === 0) return {
|
|
2069
2099
|
content: [{
|
|
@@ -528,22 +528,21 @@ var RemoteConfigCacheService = class {
|
|
|
528
528
|
try {
|
|
529
529
|
if (!existsSync(this.cacheDir)) return;
|
|
530
530
|
const now = Date.now();
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
for (const file of files) {
|
|
534
|
-
if (!file.endsWith(".json")) continue;
|
|
531
|
+
const jsonFiles = (await readdir(this.cacheDir)).filter((file) => file.endsWith(".json"));
|
|
532
|
+
const expiredCount = (await Promise.all(jsonFiles.map(async (file) => {
|
|
535
533
|
const filePath = join(this.cacheDir, file);
|
|
536
534
|
try {
|
|
537
535
|
const content = await readFile(filePath, "utf-8");
|
|
538
536
|
if (now > JSON.parse(content).expiresAt) {
|
|
539
537
|
await unlink(filePath);
|
|
540
|
-
|
|
538
|
+
return true;
|
|
541
539
|
}
|
|
540
|
+
return false;
|
|
542
541
|
} catch (error) {
|
|
543
542
|
await unlink(filePath).catch(() => {});
|
|
544
|
-
|
|
543
|
+
return true;
|
|
545
544
|
}
|
|
546
|
-
}
|
|
545
|
+
}))).filter(Boolean).length;
|
|
547
546
|
if (expiredCount > 0) console.error(`Cleaned up ${expiredCount} expired remote config cache entries`);
|
|
548
547
|
} catch (error) {
|
|
549
548
|
console.error("Failed to clean expired remote config cache:", error);
|
|
@@ -559,14 +558,15 @@ var RemoteConfigCacheService = class {
|
|
|
559
558
|
totalSize: 0
|
|
560
559
|
};
|
|
561
560
|
const jsonFiles = (await readdir(this.cacheDir)).filter((file) => file.endsWith(".json"));
|
|
562
|
-
|
|
563
|
-
for (const file of jsonFiles) {
|
|
561
|
+
const totalSize = (await Promise.all(jsonFiles.map(async (file) => {
|
|
564
562
|
const filePath = join(this.cacheDir, file);
|
|
565
563
|
try {
|
|
566
564
|
const content = await readFile(filePath, "utf-8");
|
|
567
|
-
|
|
568
|
-
} catch {
|
|
569
|
-
|
|
565
|
+
return Buffer.byteLength(content, "utf-8");
|
|
566
|
+
} catch {
|
|
567
|
+
return 0;
|
|
568
|
+
}
|
|
569
|
+
}))).reduce((sum, size) => sum + size, 0);
|
|
570
570
|
return {
|
|
571
571
|
totalEntries: jsonFiles.length,
|
|
572
572
|
totalSize
|
|
@@ -1387,13 +1387,13 @@ var SkillService = class {
|
|
|
1387
1387
|
if (this.cachedSkills !== null) return this.cachedSkills;
|
|
1388
1388
|
const skills = [];
|
|
1389
1389
|
const loadedSkillNames = /* @__PURE__ */ new Set();
|
|
1390
|
-
|
|
1390
|
+
const allDirSkills = await Promise.all(this.skillPaths.map(async (skillPath) => {
|
|
1391
1391
|
const skillsDir = isAbsolute(skillPath) ? skillPath : join(this.cwd, skillPath);
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1392
|
+
return this.loadSkillsFromDirectory(skillsDir, "project");
|
|
1393
|
+
}));
|
|
1394
|
+
for (const dirSkills of allDirSkills) for (const skill of dirSkills) if (!loadedSkillNames.has(skill.name)) {
|
|
1395
|
+
skills.push(skill);
|
|
1396
|
+
loadedSkillNames.add(skill.name);
|
|
1397
1397
|
}
|
|
1398
1398
|
this.cachedSkills = skills;
|
|
1399
1399
|
this.skillsByName = new Map(skills.map((skill) => [skill.name, skill]));
|
|
@@ -1431,9 +1431,15 @@ var SkillService = class {
|
|
|
1431
1431
|
*/
|
|
1432
1432
|
async startWatching() {
|
|
1433
1433
|
this.stopWatching();
|
|
1434
|
-
|
|
1434
|
+
const existenceChecks = await Promise.all(this.skillPaths.map(async (skillPath) => {
|
|
1435
1435
|
const skillsDir = isAbsolute(skillPath) ? skillPath : join(this.cwd, skillPath);
|
|
1436
|
-
|
|
1436
|
+
return {
|
|
1437
|
+
skillsDir,
|
|
1438
|
+
exists: await pathExists(skillsDir)
|
|
1439
|
+
};
|
|
1440
|
+
}));
|
|
1441
|
+
for (const { skillsDir, exists } of existenceChecks) {
|
|
1442
|
+
if (!exists) continue;
|
|
1437
1443
|
const abortController = new AbortController();
|
|
1438
1444
|
this.watchers.push(abortController);
|
|
1439
1445
|
this.watchDirectory(skillsDir, abortController.signal).catch((error) => {
|
|
@@ -1491,34 +1497,49 @@ var SkillService = class {
|
|
|
1491
1497
|
} catch (error) {
|
|
1492
1498
|
throw new SkillLoadError(`Failed to read skills directory: ${error instanceof Error ? error.message : "Unknown error"}`, dirPath, error instanceof Error ? error : void 0);
|
|
1493
1499
|
}
|
|
1494
|
-
|
|
1500
|
+
const entryStats = await Promise.all(entries.map(async (entry) => {
|
|
1495
1501
|
const entryPath = join(dirPath, entry);
|
|
1496
|
-
let entryStat;
|
|
1497
1502
|
try {
|
|
1498
|
-
|
|
1503
|
+
return {
|
|
1504
|
+
entry,
|
|
1505
|
+
entryPath,
|
|
1506
|
+
stat: await stat(entryPath),
|
|
1507
|
+
error: null
|
|
1508
|
+
};
|
|
1499
1509
|
} catch (error) {
|
|
1500
1510
|
console.warn(`Skipping entry ${entryPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1501
|
-
|
|
1511
|
+
return {
|
|
1512
|
+
entry,
|
|
1513
|
+
entryPath,
|
|
1514
|
+
stat: null,
|
|
1515
|
+
error
|
|
1516
|
+
};
|
|
1502
1517
|
}
|
|
1518
|
+
}));
|
|
1519
|
+
const skillFilesToLoad = [];
|
|
1520
|
+
for (const { entry, entryPath, stat: entryStat } of entryStats) {
|
|
1521
|
+
if (!entryStat) continue;
|
|
1503
1522
|
if (entryStat.isDirectory()) {
|
|
1504
1523
|
const skillFilePath = join(entryPath, "SKILL.md");
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
if (
|
|
1524
|
+
skillFilesToLoad.push({
|
|
1525
|
+
filePath: skillFilePath,
|
|
1526
|
+
isRootLevel: false
|
|
1527
|
+
});
|
|
1528
|
+
} else if (entry === "SKILL.md") skillFilesToLoad.push({
|
|
1529
|
+
filePath: entryPath,
|
|
1530
|
+
isRootLevel: true
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
const loadResults = await Promise.all(skillFilesToLoad.map(async ({ filePath, isRootLevel }) => {
|
|
1534
|
+
try {
|
|
1535
|
+
if (!isRootLevel && !await pathExists(filePath)) return null;
|
|
1536
|
+
return await this.loadSkillFile(filePath, location);
|
|
1517
1537
|
} catch (error) {
|
|
1518
|
-
console.warn(`Skipping skill at ${
|
|
1519
|
-
|
|
1538
|
+
console.warn(`Skipping skill at ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1539
|
+
return null;
|
|
1520
1540
|
}
|
|
1521
|
-
}
|
|
1541
|
+
}));
|
|
1542
|
+
for (const skill of loadResults) if (skill) skills.push(skill);
|
|
1522
1543
|
return skills;
|
|
1523
1544
|
}
|
|
1524
1545
|
/**
|
|
@@ -1660,44 +1681,42 @@ var DescribeToolsTool = class DescribeToolsTool {
|
|
|
1660
1681
|
async detectSkillsFromPromptFrontMatter() {
|
|
1661
1682
|
if (this.autoDetectedSkillsCache !== null) return this.autoDetectedSkillsCache;
|
|
1662
1683
|
const clients = this.clientManager.getAllClients();
|
|
1663
|
-
const autoDetectedSkills = [];
|
|
1664
1684
|
let listPromptsFailures = 0;
|
|
1665
1685
|
let fetchPromptFailures = 0;
|
|
1666
|
-
const
|
|
1667
|
-
|
|
1686
|
+
const autoDetectedSkills = (await Promise.all(clients.map(async (client) => {
|
|
1687
|
+
const detectedSkills = [];
|
|
1668
1688
|
const configuredPromptNames = new Set(client.prompts ? Object.keys(client.prompts) : []);
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
const
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
}
|
|
1700
|
-
await Promise.all(fetchPromises);
|
|
1689
|
+
try {
|
|
1690
|
+
const prompts = await client.listPrompts();
|
|
1691
|
+
if (!prompts || prompts.length === 0) return detectedSkills;
|
|
1692
|
+
const promptResults = await Promise.all(prompts.map(async (promptInfo) => {
|
|
1693
|
+
if (configuredPromptNames.has(promptInfo.name)) return null;
|
|
1694
|
+
try {
|
|
1695
|
+
const skillExtraction = extractSkillFrontMatter(((await client.getPrompt(promptInfo.name)).messages || []).map((m) => {
|
|
1696
|
+
const content = m.content;
|
|
1697
|
+
if (typeof content === "string") return content;
|
|
1698
|
+
if (content && typeof content === "object" && "text" in content) return String(content.text);
|
|
1699
|
+
return "";
|
|
1700
|
+
}).join("\n"));
|
|
1701
|
+
if (skillExtraction) return {
|
|
1702
|
+
serverName: client.serverName,
|
|
1703
|
+
promptName: promptInfo.name,
|
|
1704
|
+
skill: skillExtraction.skill
|
|
1705
|
+
};
|
|
1706
|
+
return null;
|
|
1707
|
+
} catch (error) {
|
|
1708
|
+
fetchPromptFailures++;
|
|
1709
|
+
console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to fetch prompt '${promptInfo.name}' from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1710
|
+
return null;
|
|
1711
|
+
}
|
|
1712
|
+
}));
|
|
1713
|
+
for (const result of promptResults) if (result) detectedSkills.push(result);
|
|
1714
|
+
} catch (error) {
|
|
1715
|
+
listPromptsFailures++;
|
|
1716
|
+
console.error(`${LOG_PREFIX_SKILL_DETECTION} Failed to list prompts from ${client.serverName}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1717
|
+
}
|
|
1718
|
+
return detectedSkills;
|
|
1719
|
+
}))).flat();
|
|
1701
1720
|
if (listPromptsFailures > 0 || fetchPromptFailures > 0) console.error(`${LOG_PREFIX_SKILL_DETECTION} Completed with ${listPromptsFailures} server failure(s) and ${fetchPromptFailures} prompt failure(s). Detected ${autoDetectedSkills.length} skill(s).`);
|
|
1702
1721
|
this.autoDetectedSkillsCache = autoDetectedSkills;
|
|
1703
1722
|
return autoDetectedSkills;
|
|
@@ -1948,40 +1967,42 @@ var DescribeToolsTool = class DescribeToolsTool {
|
|
|
1948
1967
|
serverToolsMap.set(client.serverName, []);
|
|
1949
1968
|
}
|
|
1950
1969
|
}));
|
|
1951
|
-
const
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1970
|
+
const lookupResults = await Promise.all(toolNames.map(async (requestedName) => {
|
|
1971
|
+
const result$1 = {
|
|
1972
|
+
tools: [],
|
|
1973
|
+
skills: [],
|
|
1974
|
+
notFound: null
|
|
1975
|
+
};
|
|
1955
1976
|
if (requestedName.startsWith(SKILL_PREFIX)) {
|
|
1956
1977
|
const skillName = requestedName.slice(SKILL_PREFIX.length);
|
|
1957
1978
|
if (this.skillService) {
|
|
1958
1979
|
const skill = await this.skillService.getSkill(skillName);
|
|
1959
1980
|
if (skill) {
|
|
1960
|
-
|
|
1981
|
+
result$1.skills.push({
|
|
1961
1982
|
name: skill.name,
|
|
1962
1983
|
location: skill.basePath,
|
|
1963
1984
|
instructions: formatSkillInstructions(skill.name, skill.content)
|
|
1964
1985
|
});
|
|
1965
|
-
|
|
1986
|
+
return result$1;
|
|
1966
1987
|
}
|
|
1967
1988
|
}
|
|
1968
1989
|
const promptSkillContent = await this.getPromptSkillContent(skillName);
|
|
1969
1990
|
if (promptSkillContent) {
|
|
1970
|
-
|
|
1971
|
-
|
|
1991
|
+
result$1.skills.push(promptSkillContent);
|
|
1992
|
+
return result$1;
|
|
1972
1993
|
}
|
|
1973
|
-
|
|
1974
|
-
|
|
1994
|
+
result$1.notFound = requestedName;
|
|
1995
|
+
return result$1;
|
|
1975
1996
|
}
|
|
1976
1997
|
const { serverName, actualToolName } = parseToolName(requestedName);
|
|
1977
1998
|
if (serverName) {
|
|
1978
1999
|
const serverTools = serverToolsMap.get(serverName);
|
|
1979
2000
|
if (!serverTools) {
|
|
1980
|
-
|
|
1981
|
-
|
|
2001
|
+
result$1.notFound = requestedName;
|
|
2002
|
+
return result$1;
|
|
1982
2003
|
}
|
|
1983
2004
|
const tool = serverTools.find((t) => t.name === actualToolName);
|
|
1984
|
-
if (tool)
|
|
2005
|
+
if (tool) result$1.tools.push({
|
|
1985
2006
|
server: serverName,
|
|
1986
2007
|
tool: {
|
|
1987
2008
|
name: tool.name,
|
|
@@ -1989,52 +2010,61 @@ var DescribeToolsTool = class DescribeToolsTool {
|
|
|
1989
2010
|
inputSchema: tool.inputSchema
|
|
1990
2011
|
}
|
|
1991
2012
|
});
|
|
1992
|
-
else
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
}
|
|
2007
|
-
const promptSkillContent = await this.getPromptSkillContent(actualToolName);
|
|
2008
|
-
if (promptSkillContent) {
|
|
2009
|
-
foundSkills.push(promptSkillContent);
|
|
2010
|
-
continue;
|
|
2013
|
+
else result$1.notFound = requestedName;
|
|
2014
|
+
return result$1;
|
|
2015
|
+
}
|
|
2016
|
+
const servers = toolToServers.get(actualToolName);
|
|
2017
|
+
if (!servers || servers.length === 0) {
|
|
2018
|
+
if (this.skillService) {
|
|
2019
|
+
const skill = await this.skillService.getSkill(actualToolName);
|
|
2020
|
+
if (skill) {
|
|
2021
|
+
result$1.skills.push({
|
|
2022
|
+
name: skill.name,
|
|
2023
|
+
location: skill.basePath,
|
|
2024
|
+
instructions: formatSkillInstructions(skill.name, skill.content)
|
|
2025
|
+
});
|
|
2026
|
+
return result$1;
|
|
2011
2027
|
}
|
|
2012
|
-
notFoundItems.push(requestedName);
|
|
2013
|
-
continue;
|
|
2014
2028
|
}
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
server,
|
|
2020
|
-
tool: {
|
|
2021
|
-
name: tool.name,
|
|
2022
|
-
description: tool.description,
|
|
2023
|
-
inputSchema: tool.inputSchema
|
|
2024
|
-
}
|
|
2025
|
-
});
|
|
2026
|
-
} else for (const server of servers) {
|
|
2027
|
-
const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
|
|
2028
|
-
foundTools.push({
|
|
2029
|
-
server,
|
|
2030
|
-
tool: {
|
|
2031
|
-
name: tool.name,
|
|
2032
|
-
description: tool.description,
|
|
2033
|
-
inputSchema: tool.inputSchema
|
|
2034
|
-
}
|
|
2035
|
-
});
|
|
2029
|
+
const promptSkillContent = await this.getPromptSkillContent(actualToolName);
|
|
2030
|
+
if (promptSkillContent) {
|
|
2031
|
+
result$1.skills.push(promptSkillContent);
|
|
2032
|
+
return result$1;
|
|
2036
2033
|
}
|
|
2034
|
+
result$1.notFound = requestedName;
|
|
2035
|
+
return result$1;
|
|
2037
2036
|
}
|
|
2037
|
+
if (servers.length === 1) {
|
|
2038
|
+
const server = servers[0];
|
|
2039
|
+
const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
|
|
2040
|
+
result$1.tools.push({
|
|
2041
|
+
server,
|
|
2042
|
+
tool: {
|
|
2043
|
+
name: tool.name,
|
|
2044
|
+
description: tool.description,
|
|
2045
|
+
inputSchema: tool.inputSchema
|
|
2046
|
+
}
|
|
2047
|
+
});
|
|
2048
|
+
} else for (const server of servers) {
|
|
2049
|
+
const tool = serverToolsMap.get(server).find((t) => t.name === actualToolName);
|
|
2050
|
+
result$1.tools.push({
|
|
2051
|
+
server,
|
|
2052
|
+
tool: {
|
|
2053
|
+
name: tool.name,
|
|
2054
|
+
description: tool.description,
|
|
2055
|
+
inputSchema: tool.inputSchema
|
|
2056
|
+
}
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
return result$1;
|
|
2060
|
+
}));
|
|
2061
|
+
const foundTools = [];
|
|
2062
|
+
const foundSkills = [];
|
|
2063
|
+
const notFoundItems = [];
|
|
2064
|
+
for (const result$1 of lookupResults) {
|
|
2065
|
+
foundTools.push(...result$1.tools);
|
|
2066
|
+
foundSkills.push(...result$1.skills);
|
|
2067
|
+
if (result$1.notFound) notFoundItems.push(result$1.notFound);
|
|
2038
2068
|
}
|
|
2039
2069
|
if (foundTools.length === 0 && foundSkills.length === 0) return {
|
|
2040
2070
|
content: [{
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as createServer, n as SseTransportHandler, r as StdioTransportHandler, t as HttpTransportHandler } from "./http-
|
|
1
|
+
import { i as createServer, n as SseTransportHandler, r as StdioTransportHandler, t as HttpTransportHandler } from "./http-DeUYygKb.mjs";
|
|
2
2
|
|
|
3
3
|
export { HttpTransportHandler, SseTransportHandler, StdioTransportHandler, createServer };
|