import type { ToolPermissions, UnknownPlimiPlugin } from "./plugin-types";

export const DEFAULT_PERMISSIONS: ToolPermissions = {
  network: "none",
  clipboard: "none",
  fileSystem: "read",
};

export function getToolPermissions(plugin: UnknownPlimiPlugin): ToolPermissions {
  return {
    ...DEFAULT_PERMISSIONS,
    ...plugin.permissions,
  };
}

export function describeToolPermissions(plugin: UnknownPlimiPlugin): string[] {
  const permissions = getToolPermissions(plugin);
  const descriptions = ["Runs locally"];

  if (permissions.network === "none") {
    descriptions.push("No network");
  } else {
    descriptions.push(`${permissions.network} network`);
  }

  if (permissions.clipboard && permissions.clipboard !== "none") {
    descriptions.push(`Clipboard ${permissions.clipboard}`);
  }

  if (permissions.fileSystem && permissions.fileSystem !== "none") {
    descriptions.push(`Files ${permissions.fileSystem}`);
  }

  return descriptions;
}
