fix(gateway): load plugin tools for catalog

This commit is contained in:
Peter Steinberger
2026-05-02 14:52:14 +01:00
parent 1466878c36
commit afbc395dda
2 changed files with 23 additions and 7 deletions

View File

@@ -1,5 +1,8 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { resolvePluginTools } from "../../plugins/tools.js";
import {
ensureStandalonePluginToolRegistryLoaded,
resolvePluginTools,
} from "../../plugins/tools.js";
import { ErrorCodes } from "../protocol/index.js";
import { toolsCatalogHandlers } from "./tools-catalog.js";
@@ -19,6 +22,7 @@ const pluginToolMetaState = new Map<string, { pluginId: string; optional: boolea
vi.mock("../../plugins/tools.js", () => ({
buildPluginToolMetadataKey: (pluginId: string, toolName: string) =>
JSON.stringify([pluginId, toolName]),
ensureStandalonePluginToolRegistryLoaded: vi.fn(),
resolvePluginTools: vi.fn(() => [
{ name: "voice_call", label: "voice_call", description: "Plugin calling tool" },
{
@@ -159,5 +163,10 @@ describe("tools.catalog handler", () => {
allowGatewaySubagentBinding: true,
}),
);
expect(vi.mocked(ensureStandalonePluginToolRegistryLoaded)).toHaveBeenCalledWith(
expect.objectContaining({
allowGatewaySubagentBinding: true,
}),
);
});
});

View File

@@ -14,6 +14,7 @@ import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { getActivePluginRegistry } from "../../plugins/runtime.js";
import {
buildPluginToolMetadataKey,
ensureStandalonePluginToolRegistryLoaded,
getPluginToolMeta,
resolvePluginTools,
} from "../../plugins/tools.js";
@@ -88,13 +89,19 @@ function buildPluginGroups(params: {
}): ToolCatalogGroup[] {
const workspaceDir = resolveAgentWorkspaceDir(params.cfg, params.agentId);
const agentDir = resolveAgentDir(params.cfg, params.agentId);
const toolContext = {
config: params.cfg,
workspaceDir,
agentDir,
agentId: params.agentId,
};
ensureStandalonePluginToolRegistryLoaded({
context: toolContext,
toolAllowlist: ["group:plugins"],
allowGatewaySubagentBinding: true,
});
const pluginTools = resolvePluginTools({
context: {
config: params.cfg,
workspaceDir,
agentDir,
agentId: params.agentId,
},
context: toolContext,
existingToolNames: params.existingToolNames,
toolAllowlist: ["group:plugins"],
suppressNameConflicts: true,