mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-07 22:44:16 +00:00
Gateway: suppress tools.catalog plugin conflict diagnostics
This commit is contained in:
@@ -84,6 +84,7 @@ function buildPluginGroups(params: {
|
||||
},
|
||||
existingToolNames: params.existingToolNames,
|
||||
toolAllowlist: ["group:plugins"],
|
||||
suppressNameConflicts: true,
|
||||
});
|
||||
const groups = new Map<string, ToolCatalogGroup>();
|
||||
for (const tool of pluginTools) {
|
||||
|
||||
@@ -154,4 +154,24 @@ describe("resolvePluginTools optional tools", () => {
|
||||
expect(registry.diagnostics).toHaveLength(1);
|
||||
expect(registry.diagnostics[0]?.message).toContain("plugin tool name conflict");
|
||||
});
|
||||
|
||||
it("suppresses conflict diagnostics when requested", () => {
|
||||
const registry = setRegistry([
|
||||
{
|
||||
pluginId: "multi",
|
||||
optional: false,
|
||||
source: "/tmp/multi.js",
|
||||
factory: () => [makeTool("message"), makeTool("other_tool")],
|
||||
},
|
||||
]);
|
||||
|
||||
const tools = resolvePluginTools({
|
||||
context: createContext() as never,
|
||||
existingToolNames: new Set(["message"]),
|
||||
suppressNameConflicts: true,
|
||||
});
|
||||
|
||||
expect(tools.map((tool) => tool.name)).toEqual(["other_tool"]);
|
||||
expect(registry.diagnostics).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,6 +46,7 @@ export function resolvePluginTools(params: {
|
||||
context: OpenClawPluginToolContext;
|
||||
existingToolNames?: Set<string>;
|
||||
toolAllowlist?: string[];
|
||||
suppressNameConflicts?: boolean;
|
||||
}): AnyAgentTool[] {
|
||||
// Fast path: when plugins are effectively disabled, avoid discovery/jiti entirely.
|
||||
// This matters a lot for unit tests and for tool construction hot paths.
|
||||
@@ -74,13 +75,15 @@ export function resolvePluginTools(params: {
|
||||
const pluginIdKey = normalizeToolName(entry.pluginId);
|
||||
if (existingNormalized.has(pluginIdKey)) {
|
||||
const message = `plugin id conflicts with core tool name (${entry.pluginId})`;
|
||||
log.error(message);
|
||||
registry.diagnostics.push({
|
||||
level: "error",
|
||||
pluginId: entry.pluginId,
|
||||
source: entry.source,
|
||||
message,
|
||||
});
|
||||
if (!params.suppressNameConflicts) {
|
||||
log.error(message);
|
||||
registry.diagnostics.push({
|
||||
level: "error",
|
||||
pluginId: entry.pluginId,
|
||||
source: entry.source,
|
||||
message,
|
||||
});
|
||||
}
|
||||
blockedPlugins.add(entry.pluginId);
|
||||
continue;
|
||||
}
|
||||
@@ -111,13 +114,15 @@ export function resolvePluginTools(params: {
|
||||
for (const tool of list) {
|
||||
if (nameSet.has(tool.name) || existing.has(tool.name)) {
|
||||
const message = `plugin tool name conflict (${entry.pluginId}): ${tool.name}`;
|
||||
log.error(message);
|
||||
registry.diagnostics.push({
|
||||
level: "error",
|
||||
pluginId: entry.pluginId,
|
||||
source: entry.source,
|
||||
message,
|
||||
});
|
||||
if (!params.suppressNameConflicts) {
|
||||
log.error(message);
|
||||
registry.diagnostics.push({
|
||||
level: "error",
|
||||
pluginId: entry.pluginId,
|
||||
source: entry.source,
|
||||
message,
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
nameSet.add(tool.name);
|
||||
|
||||
Reference in New Issue
Block a user