Files
openclaw/src/agents/openclaw-tools.client-caps.ts
2026-07-24 01:24:03 -05:00

18 lines
646 B
TypeScript

import type { AnyAgentTool } from "./tools/common.js";
/**
* Drops tools whose requiredClientCaps the originating gateway client did not
* declare. Capability availability is a hard fact, not policy: every tool
* assembly path (core, plugin-only plans) must apply it or gated tools leak
* onto surfaces that cannot render them.
*/
export function filterToolsByClientCaps(
tools: AnyAgentTool[],
declaredClientCaps: string[] | undefined,
): AnyAgentTool[] {
const clientCaps = new Set(declaredClientCaps ?? []);
return tools.filter(
(tool) => !tool.requiredClientCaps?.some((requiredCap) => !clientCaps.has(requiredCap)),
);
}