Thread exec and mailer_send through ctx instead of importing directly

- actions.mjs no longer imports exec from helpers; uses ctx.exec instead
- index.mjs builds ctx via make_ctx(), which injects dry-run stubs for
  exec and mailer_send when --dry-run is active
- Handlers now run fully (including permission checks) in dry-run mode;
  only the actual side effects are stubbed out

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 22:58:00 +00:00
parent 3841c5418a
commit 64df986a5f
2 changed files with 21 additions and 16 deletions

View File

@@ -2,7 +2,7 @@
// policy: "auto-accept" | "auto-deny" | "queue"
import { resolve_path, exec } from './helpers.mjs';
import { resolve_path } from './helpers.mjs';
import { check_can_approve } from './auth.mjs';
export const actions = {
@@ -24,7 +24,7 @@ export const actions = {
description: "Open a file in the editor",
params: [{ name: "filename", required: true, type: "path" }],
policy: "auto-accept",
handler: ({ filename }) => {
handler: ({ filename }, { exec }) => {
const resolved = resolve_path(filename);
exec('subl3', [resolved]);
return { opened: resolved };
@@ -48,7 +48,7 @@ export const actions = {
description: "Open a URL in the web browser",
params: [{ name: "url", required: true, type: "string" }],
policy: "queue",
handler: ({ url }) => {
handler: ({ url }, { exec }) => {
const parsed = new URL(url);
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
throw new Error(`Disallowed protocol: ${parsed.protocol}`);
@@ -62,7 +62,7 @@ export const actions = {
description: "Open a terminal in a given directory",
params: [{ name: "path", required: false, type: "path" }],
policy: 'queue',
handler: ({ path }) => {
handler: ({ path }, { exec }) => {
const resolved = resolve_path(path ?? 'workspace');
exec('konsole', ['--workdir', resolved, '-e', 'bash']);
return { opened: resolved };