Files
claude-code-conduit/server/actions.mjs
mikael-lovqvists-claude-agent 67c1c3f9a4 Add HMAC auth, user permissions, snake_case rename
Each request is signed with HMAC-SHA256 over timestamp+body using a
per-user secret loaded from a --secrets file (never env vars or git).
Users have a canApprove list controlling who may approve queued actions.
Queue entries track submitted_by for permission checks on approve/deny.

Also renames all identifiers to snake_case throughout the codebase.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 20:18:41 +00:00

64 lines
1.7 KiB
JavaScript

// 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: async () => {
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: async ({ filename }) => {
const resolved = resolve_path(filename);
await exec("xdg-open", [resolved]);
return { opened: resolved };
},
},
"open-directory": {
description: "Open a directory in the file manager",
params: [{ name: "path", required: true, type: "path" }],
policy: "auto-accept",
handler: async ({ path }) => {
const resolved = resolve_path(path);
await exec("xdg-open", [resolved]);
return { opened: resolved };
},
},
"open-browser": {
description: "Open a URL in the web browser",
params: [{ name: "url", required: true, type: "string" }],
policy: "queue",
handler: async ({ url }) => {
await exec("xdg-open", [url]);
return { opened: url };
},
},
"open-terminal": {
description: "Open a terminal in a given directory",
params: [{ name: "path", required: false, type: "path" }],
policy: "queue",
handler: async ({ path }) => {
const resolved = path ? resolve_path(path) : process.env.HOME;
await exec("xdg-open", [resolved]);
return { opened: resolved };
},
},
};