feat(exec-events): bead-7 - add hooks exec config schema

This commit is contained in:
Grace (Clawdbot) 2026-01-27 14:27:49 +01:00
parent 17f0799835
commit 97c3c5f7f7
4 changed files with 42 additions and 1 deletions

View File

@ -180,6 +180,10 @@ const FIELD_LABELS: Record<string, string> = {
"tools.exec.node": "Exec Node Binding", "tools.exec.node": "Exec Node Binding",
"tools.exec.pathPrepend": "Exec PATH Prepend", "tools.exec.pathPrepend": "Exec PATH Prepend",
"tools.exec.safeBins": "Exec Safe Bins", "tools.exec.safeBins": "Exec Safe Bins",
"hooks.exec.emitEvents": "Exec Events Enabled",
"hooks.exec.commandWhitelist": "Exec Event Command Allowlist",
"hooks.exec.outputThrottleMs": "Exec Output Throttle (ms)",
"hooks.exec.outputMaxChunkBytes": "Exec Output Max Chunk (bytes)",
"tools.message.allowCrossContextSend": "Allow Cross-Context Messaging", "tools.message.allowCrossContextSend": "Allow Cross-Context Messaging",
"tools.message.crossContext.allowWithinProvider": "Allow Cross-Context (Same Provider)", "tools.message.crossContext.allowWithinProvider": "Allow Cross-Context (Same Provider)",
"tools.message.crossContext.allowAcrossProviders": "Allow Cross-Context (Across Providers)", "tools.message.crossContext.allowAcrossProviders": "Allow Cross-Context (Across Providers)",
@ -420,6 +424,14 @@ const FIELD_HELP: Record<string, string> = {
"tools.exec.pathPrepend": "Directories to prepend to PATH for exec runs (gateway/sandbox).", "tools.exec.pathPrepend": "Directories to prepend to PATH for exec runs (gateway/sandbox).",
"tools.exec.safeBins": "tools.exec.safeBins":
"Allow stdin-only safe binaries to run without explicit allowlist entries.", "Allow stdin-only safe binaries to run without explicit allowlist entries.",
"hooks.exec.emitEvents":
"Emit exec.started/output/completed gateway events for whitelisted commands (default: true).",
"hooks.exec.commandWhitelist":
"Command basenames eligible for exec event emission (default includes codex, claude, opencode, pi, playwright, and puppeteer).",
"hooks.exec.outputThrottleMs":
"Minimum delay between exec output events per process in milliseconds (default: 150).",
"hooks.exec.outputMaxChunkBytes":
"Maximum bytes per exec output event chunk (default: 4096).",
"tools.message.allowCrossContextSend": "tools.message.allowCrossContextSend":
"Legacy override: allow cross-context sends across all providers.", "Legacy override: allow cross-context sends across all providers.",
"tools.message.crossContext.allowWithinProvider": "tools.message.crossContext.allowWithinProvider":

View File

@ -110,6 +110,17 @@ export type InternalHooksConfig = {
installs?: Record<string, HookInstallRecord>; installs?: Record<string, HookInstallRecord>;
}; };
export type HooksExecConfig = {
/** Emit exec lifecycle events to gateway clients. */
emitEvents?: boolean;
/** Allowlist of command names to emit exec events for. */
commandWhitelist?: string[];
/** Minimum delay between exec output events per process (ms). */
outputThrottleMs?: number;
/** Maximum output chunk size per exec output event (bytes). */
outputMaxChunkBytes?: number;
};
export type HooksConfig = { export type HooksConfig = {
enabled?: boolean; enabled?: boolean;
path?: string; path?: string;
@ -121,4 +132,6 @@ export type HooksConfig = {
gmail?: HooksGmailConfig; gmail?: HooksGmailConfig;
/** Internal agent event hooks */ /** Internal agent event hooks */
internal?: InternalHooksConfig; internal?: InternalHooksConfig;
/** Exec lifecycle event emission settings. */
exec?: HooksExecConfig;
}; };

View File

@ -128,3 +128,13 @@ export const HooksGmailSchema = z
}) })
.strict() .strict()
.optional(); .optional();
export const HooksExecSchema = z
.object({
emitEvents: z.boolean().optional(),
commandWhitelist: z.array(z.string()).optional(),
outputThrottleMs: z.number().int().nonnegative().optional(),
outputMaxChunkBytes: z.number().int().positive().optional(),
})
.strict()
.optional();

View File

@ -3,7 +3,12 @@ import { ToolsSchema } from "./zod-schema.agent-runtime.js";
import { ApprovalsSchema } from "./zod-schema.approvals.js"; import { ApprovalsSchema } from "./zod-schema.approvals.js";
import { AgentsSchema, AudioSchema, BindingsSchema, BroadcastSchema } from "./zod-schema.agents.js"; import { AgentsSchema, AudioSchema, BindingsSchema, BroadcastSchema } from "./zod-schema.agents.js";
import { HexColorSchema, ModelsConfigSchema } from "./zod-schema.core.js"; import { HexColorSchema, ModelsConfigSchema } from "./zod-schema.core.js";
import { HookMappingSchema, HooksGmailSchema, InternalHooksSchema } from "./zod-schema.hooks.js"; import {
HookMappingSchema,
HooksExecSchema,
HooksGmailSchema,
InternalHooksSchema,
} from "./zod-schema.hooks.js";
import { ChannelsSchema } from "./zod-schema.providers.js"; import { ChannelsSchema } from "./zod-schema.providers.js";
import { CommandsSchema, MessagesSchema, SessionSchema } from "./zod-schema.session.js"; import { CommandsSchema, MessagesSchema, SessionSchema } from "./zod-schema.session.js";
@ -242,6 +247,7 @@ export const MoltbotSchema = z
mappings: z.array(HookMappingSchema).optional(), mappings: z.array(HookMappingSchema).optional(),
gmail: HooksGmailSchema, gmail: HooksGmailSchema,
internal: InternalHooksSchema, internal: InternalHooksSchema,
exec: HooksExecSchema,
}) })
.strict() .strict()
.optional(), .optional(),