import type { PluginCommand, PluginView } from "./sdk.ts"; export type PluginTool = { owner: string; id: string; title: string; kind: "command" | "view"; surface: "commands" | "open" | "settings"; icon?: PluginView["icon"]; }; export function pluginAccess(owner: string, commands: Iterable, views: Iterable): PluginTool[] { const result: PluginTool[] = []; for (const command of commands) { const legacyOpen = owner === "runestone.browser" && command.id === "new-tab"; result.push({ owner, id: command.id, title: command.title, kind: "command", surface: command.category === "open" || (command.category === undefined && legacyOpen) ? "open" : "commands", icon: command.icon }); } for (const view of views) { const settings = view.settings ?? (owner === "runestone.local-autocomplete" && view.id === "settings"); if (!settings && (view.launcher === false || (view.launcher === undefined && owner === "runestone.browser"))) continue; result.push({ owner, id: view.id, title: view.title, kind: "view", surface: settings ? "settings" : "open", icon: view.icon }); } return result; }