




















@@ -53,6 +53,12 @@ function createInvokeParams(params: Record<string, unknown>) {
5353};
5454}
555556+function firstMockArg<T>(mock: { mock: { calls: unknown[][] } }, label: string): T {
57+const arg = mock.mock.calls[0]?.[0];
58+expect(arg, label).toBeDefined();
59+return arg as T;
60+}
61+5662describe("tools.catalog handler", () => {
5763beforeEach(() => {
5864pluginToolMetaState.clear();
@@ -124,9 +130,17 @@ describe("tools.catalog handler", () => {
124130const voiceCall = pluginGroups
125131.flatMap((group) => group.tools)
126132.find((tool) => tool.id === "voice_call");
127-expect(voiceCall?.source).toBe("plugin");
128-expect(voiceCall?.pluginId).toBe("voice-call");
129-expect(voiceCall?.optional).toBe(true);
133+expect(voiceCall).toEqual({
134+id: "voice_call",
135+label: "voice_call",
136+description: "Plugin calling tool",
137+source: "plugin",
138+pluginId: "voice-call",
139+optional: true,
140+risk: undefined,
141+tags: undefined,
142+defaultProfiles: [],
143+});
130144});
131145132146it("summarizes plugin tool descriptions the same way as the effective inventory", async () => {
@@ -157,12 +171,42 @@ describe("tools.catalog handler", () => {
157171158172await invoke();
159173160-expect(vi.mocked(resolvePluginTools).mock.calls[0]?.[0]?.allowGatewaySubagentBinding).toBe(
161-true,
162-);
163-expect(
164-vi.mocked(ensureStandalonePluginToolRegistryLoaded).mock.calls[0]?.[0]
165-?.allowGatewaySubagentBinding,
166-).toBe(true);
174+const resolveArgs = firstMockArg<{
175+allowGatewaySubagentBinding?: boolean;
176+suppressNameConflicts?: boolean;
177+toolAllowlist?: string[];
178+context?: {
179+agentId?: string;
180+workspaceDir?: string;
181+agentDir?: string;
182+};
183+existingToolNames?: Set<string>;
184+}>(vi.mocked(resolvePluginTools), "resolvePluginTools args");
185+expect(resolveArgs.allowGatewaySubagentBinding).toBe(true);
186+expect(resolveArgs.suppressNameConflicts).toBe(true);
187+expect(resolveArgs.toolAllowlist).toEqual(["group:plugins"]);
188+expect(resolveArgs.context?.agentId).toBe("main");
189+expect(resolveArgs.context?.workspaceDir).toBe("/tmp/workspace-main");
190+expect(resolveArgs.context?.agentDir).toBe("/tmp/agents/main/agent");
191+expect(resolveArgs.existingToolNames).toBeInstanceOf(Set);
192+expect(resolveArgs.existingToolNames?.has("tts")).toBe(true);
193+194+const registryArgs = firstMockArg<{
195+allowGatewaySubagentBinding?: boolean;
196+toolAllowlist?: string[];
197+context?: {
198+agentId?: string;
199+workspaceDir?: string;
200+agentDir?: string;
201+};
202+}>(vi.mocked(ensureStandalonePluginToolRegistryLoaded), "registry load args");
203+expect(registryArgs.allowGatewaySubagentBinding).toBe(true);
204+expect(registryArgs.toolAllowlist).toEqual(["group:plugins"]);
205+expect(registryArgs.context).toEqual({
206+config: {},
207+workspaceDir: "/tmp/workspace-main",
208+agentDir: "/tmp/agents/main/agent",
209+agentId: "main",
210+});
167211});
168212});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。