// Normalizes plugin tool contracts from manifest metadata. import type { PluginManifestContracts } from "./manifest.js"; export function normalizePluginToolContractNames( contracts: Pick | undefined, ): string[] { return normalizePluginToolNames(contracts?.tools); } export function normalizePluginToolNames(names: readonly string[] | undefined): string[] { const normalized = new Set(); for (const name of names ?? []) { const trimmed = name.trim(); if (trimmed) { normalized.add(trimmed); } } return [...normalized]; } export function findUndeclaredPluginToolNames(params: { declaredNames: readonly string[]; toolNames: readonly string[]; }): string[] { const declared = new Set(normalizePluginToolNames(params.declaredNames)); return normalizePluginToolNames(params.toolNames).filter((name) => !declared.has(name)); }