





















11// Coverage for Tool Search control planning and allowlist accounting.
22import { describe, expect, it } from "vitest";
33import { setPluginToolMeta } from "../../../plugins/tools.js";
4-import {
5-buildAutoAddedToolSearchControlNamesForAllowlistCheck,
6-buildCallableToolNamesForEmptyAllowlistCheck,
7-buildToolSearchRunPlan,
8-} from "./attempt.tool-search-run-plan.js";
9-10-describe("buildCallableToolNamesForEmptyAllowlistCheck", () => {
11-it("ignores auto-added Tool Search controls so bad allowlists still fail", () => {
12-// Auto-added controls are not real callable tools when the backing catalog
13-// is empty.
14-expect(
15-buildCallableToolNamesForEmptyAllowlistCheck({
16-effectiveToolNames: ["tool_search_code"],
17-autoAddedToolSearchControlNames: new Set(["tool_search_code"]),
18-toolSearchCatalogToolCount: 0,
19-}),
20-).toEqual([]);
21-});
22-23-it("counts cataloged tools hidden behind auto-added Tool Search controls", () => {
24-expect(
25-buildCallableToolNamesForEmptyAllowlistCheck({
26-effectiveToolNames: ["tool_search_code"],
27-autoAddedToolSearchControlNames: new Set(["tool_search_code"]),
28-toolSearchCatalogToolCount: 1,
29-}),
30-).toEqual(["tool-search:0"]);
31-});
32-33-it("keeps explicitly requested Tool Search controls callable", () => {
34-expect(
35-buildCallableToolNamesForEmptyAllowlistCheck({
36-effectiveToolNames: ["tool_search_code"],
37-autoAddedToolSearchControlNames: new Set(),
38-toolSearchCatalogToolCount: 0,
39-}),
40-).toEqual(["tool_search_code"]);
41-});
42-});
43-44-describe("buildAutoAddedToolSearchControlNamesForAllowlistCheck", () => {
45-it("treats controls as auto-added unless any explicit allowlist requested them", () => {
46-expect(
47-buildAutoAddedToolSearchControlNamesForAllowlistCheck({
48-toolSearchControlsEnabled: true,
49-explicitAllowlistSources: [{ entries: ["missing_tool"] }],
50-controlNames: ["tool_search_code", "tool_search"],
51-}),
52-).toEqual(new Set(["tool_search_code", "tool_search"]));
53-54-expect(
55-buildAutoAddedToolSearchControlNamesForAllowlistCheck({
56-toolSearchControlsEnabled: true,
57-explicitAllowlistSources: [{ entries: ["tool_search_code"] }],
58-controlNames: ["tool_search_code", "tool_search"],
59-}),
60-).toEqual(new Set(["tool_search"]));
61-});
62-});
4+import { buildToolSearchRunPlan } from "./attempt.tool-search-run-plan.js";
635646describe("buildToolSearchRunPlan", () => {
657it("keeps compact visible names separate from replay-safe names", () => {
@@ -161,6 +103,19 @@ describe("buildToolSearchRunPlan", () => {
161103expect(plan.emptyAllowlistCallableNames).toEqual([]);
162104});
163105106+it("keeps explicitly requested Tool Search controls callable", () => {
107+const plan = buildToolSearchRunPlan({
108+visibleTools: [{ name: "tool_search_code" }] as never,
109+uncompactedTools: [{ name: "tool_search_code" }] as never,
110+clientToolsCataloged: true,
111+catalogToolCount: 0,
112+controlsEnabled: true,
113+explicitAllowlistSources: [{ entries: ["tool_search_code"] }],
114+});
115+116+expect(plan.emptyAllowlistCallableNames).toEqual(["tool_search_code"]);
117+});
118+164119it("keeps uncataloged directory-mode client tools visible", () => {
165120const plan = buildToolSearchRunPlan({
166121visibleTools: [
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。