feat: add two-layer tool call validation system (proactive + reactive) (#249)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
Sisyphus
2025-12-26 03:36:27 +09:00
committed by GitHub
parent ad2bd673c4
commit 9bc2360d31
9 changed files with 282 additions and 8 deletions

View File

@@ -23,6 +23,7 @@ import {
createNonInteractiveEnvHook,
createInteractiveBashSessionHook,
createEmptyMessageSanitizerHook,
createToolCallValidatorHook,
} from "./hooks";
import { createGoogleAntigravityAuthPlugin } from "./auth/antigravity";
import {
@@ -49,6 +50,7 @@ import { BackgroundManager } from "./features/background-agent";
import { createBuiltinMcps } from "./mcp";
import { OhMyOpenCodeConfigSchema, type OhMyOpenCodeConfig, type HookName } from "./config";
import { log, deepMerge, getUserConfigDir, addConfigLoadError } from "./shared";
import { createToolRegistry } from "./shared/tool-registry";
import { PLAN_SYSTEM_PROMPT, PLAN_PERMISSION } from "./agents/plan-prompt";
import * as fs from "fs";
import * as path from "path";
@@ -345,16 +347,28 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
const tmuxAvailable = await getTmuxPath();
const allTools = {
...builtinTools,
...backgroundTools,
call_omo_agent: callOmoAgent,
look_at: lookAt,
...(tmuxAvailable ? { interactive_bash } : {}),
};
const toolRegistry = createToolRegistry(
allTools,
{},
{}
);
const toolCallValidator = isHookEnabled("tool-call-validator")
? createToolCallValidatorHook(toolRegistry)
: null;
return {
...(googleAuthHooks ? { auth: googleAuthHooks.auth } : {}),
tool: {
...builtinTools,
...backgroundTools,
call_omo_agent: callOmoAgent,
look_at: lookAt,
...(tmuxAvailable ? { interactive_bash } : {}),
},
tool: allTools,
"chat.message": async (input, output) => {
await claudeCodeHooks["chat.message"]?.(input, output);
@@ -367,6 +381,8 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await emptyMessageSanitizer?.["experimental.chat.messages.transform"]?.(input, output as any);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await toolCallValidator?.["experimental.chat.messages.transform"]?.(input, output as any);
},
config: async (config) => {