// Action registry — defines all available actions, their parameters, and policies. // policy: "auto-accept" | "auto-deny" | "queue" import { resolve_path, exec } from "./helpers.mjs"; export const actions = { "list-actions": { description: "List all available actions and their definitions", params: [], policy: "auto-accept", handler: () => { return Object.entries(actions).map(([name, def]) => ({ action: name, description: def.description, params: def.params, policy: def.policy, })); }, }, "edit-file": { description: "Open a file in the editor", params: [{ name: "filename", required: true, type: "path" }], policy: "auto-accept", handler: ({ filename }) => { const resolved = resolve_path(filename); exec('subl3', [resolved]); return { opened: resolved }; }, }, /* "open-directory": { description: "Open a directory in the file manager", params: [{ name: "path", required: true, type: "path" }], policy: 'queue', handler: ({ path }) => { const resolved = resolve_path(path); // exec( ... ); return { opened: resolved }; }, }, */ "open-browser": { description: "Open a URL in the web browser", params: [{ name: "url", required: true, type: "string" }], policy: "queue", handler: ({ url }) => { const parsed = new URL(url); if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { throw new Error(`Disallowed protocol: ${parsed.protocol}`); } exec('xdg-open', [parsed.href]); return { opened: parsed.href }; }, }, "open-terminal": { description: "Open a terminal in a given directory", params: [{ name: "path", required: false, type: "path" }], policy: 'queue', handler: ({ path }) => { const resolved = resolve_path(path ?? 'workspace'); exec('konsole', ['--workdir', resolved, '-e', 'bash']); return { opened: resolved }; }, }, };