

























@@ -12,7 +12,9 @@ import { createOpenClawCodingTools } from "./pi-tools.js";
1212import { resolveEffectiveToolPolicy } from "./pi-tools.policy.js";
1313import { summarizeToolDescriptionText } from "./tool-description-summary.js";
1414import { resolveToolDisplay } from "./tool-display.js";
15+import { normalizeToolName } from "./tool-policy.js";
1516import type {
17+EffectiveToolInventoryNotice,
1618EffectiveToolInventoryEntry,
1719EffectiveToolInventoryGroup,
1820EffectiveToolInventoryResult,
@@ -70,6 +72,82 @@ function groupLabel(source: EffectiveToolSource): string {
7072}
7173}
727475+function listIncludesTool(list: string[] | undefined, toolName: string): boolean {
76+if (!Array.isArray(list)) {
77+return false;
78+}
79+const normalizedToolName = normalizeToolName(toolName);
80+return list.some((entry) => normalizeToolName(entry) === normalizedToolName);
81+}
82+83+function policyDeniesTool(policy: { deny?: string[] } | undefined, toolName: string): boolean {
84+return (
85+listIncludesTool(policy?.deny, toolName) ||
86+listIncludesTool(policy?.deny, "group:ui") ||
87+listIncludesTool(policy?.deny, "group:openclaw")
88+);
89+}
90+91+function hasExplicitBrowserIntent(cfg: OpenClawConfig): boolean {
92+return cfg.browser?.enabled !== false && Boolean(cfg.browser || cfg.plugins?.entries?.browser);
93+}
94+95+function buildToolInventoryNotices(params: {
96+cfg: OpenClawConfig;
97+profile: string;
98+entries: EffectiveToolInventoryEntry[];
99+effectivePolicy: ReturnType<typeof resolveEffectiveToolPolicy>;
100+}): EffectiveToolInventoryNotice[] | undefined {
101+const hasBrowserTool = params.entries.some((entry) => normalizeToolName(entry.id) === "browser");
102+if (hasBrowserTool || !hasExplicitBrowserIntent(params.cfg)) {
103+return undefined;
104+}
105+106+const browserDenied = [
107+params.effectivePolicy.globalPolicy,
108+params.effectivePolicy.globalProviderPolicy,
109+params.effectivePolicy.agentPolicy,
110+params.effectivePolicy.agentProviderPolicy,
111+].some((policy) => policyDeniesTool(policy, "browser"));
112+if (browserDenied) {
113+return [
114+{
115+id: "browser-denied-by-policy",
116+severity: "info",
117+message:
118+"Browser is configured, but this session does not expose the browser tool because tool policy denies it. Remove the browser deny entry to use browser automation.",
119+},
120+];
121+}
122+123+if (params.profile !== "full") {
124+return [
125+{
126+id: "browser-filtered-by-profile",
127+severity: "info",
128+message:
129+'Browser is configured, but the current tool profile does not include the browser tool. Add tools.alsoAllow: ["browser"] or agents.list[].tools.alsoAllow: ["browser"]; tools.subagents.tools.allow alone cannot add it back after profile filtering.',
130+},
131+];
132+}
133+134+if (
135+Array.isArray(params.cfg.plugins?.allow) &&
136+!listIncludesTool(params.cfg.plugins.allow, "browser")
137+) {
138+return [
139+{
140+id: "browser-plugin-not-allowed",
141+severity: "warning",
142+message:
143+'Browser is configured, but plugins.allow does not include browser. Add "browser" to plugins.allow or remove the restrictive plugin allowlist.',
144+},
145+];
146+}
147+148+return undefined;
149+}
150+73151function disambiguateLabels(entries: EffectiveToolInventoryEntry[]): EffectiveToolInventoryEntry[] {
74152const counts = new Map<string, number>();
75153for (const entry of entries) {
@@ -170,6 +248,7 @@ export function resolveEffectiveToolInventory(
170248})
171249.toSorted((a, b) => a.label.localeCompare(b.label)),
172250);
251+const notices = buildToolInventoryNotices({ cfg: params.cfg, profile, entries, effectivePolicy });
173252const groupsBySource = new Map<EffectiveToolSource, EffectiveToolInventoryEntry[]>();
174253for (const entry of entries) {
175254const tools = groupsBySource.get(entry.source) ?? [];
@@ -192,5 +271,5 @@ export function resolveEffectiveToolInventory(
192271})
193272.filter((group): group is EffectiveToolInventoryGroup => group !== null);
194273195-return { agentId, profile, groups };
274+return { agentId, profile, groups, ...(notices ? { notices } : {}) };
196275}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。