feat: register anthropic-effort hook in plugin lifecycle

- Add "anthropic-effort" to HookNameSchema enum
- Import and create hook in plugin entry with isHookEnabled guard
- Wire chat.params event handler to invoke the effort hook
- First hook to use the chat.params lifecycle event from plugin
This commit is contained in:
YeonGyu-Kim 2026-02-06 21:47:18 +09:00
parent 6febebc166
commit ec520e6228
2 changed files with 29 additions and 0 deletions

View File

@ -101,6 +101,7 @@ export const HookNameSchema = z.enum([
"stop-continuation-guard", "stop-continuation-guard",
"tasks-todowrite-disabler", "tasks-todowrite-disabler",
"write-existing-file-guard", "write-existing-file-guard",
"anthropic-effort",
]) ])
export const BuiltinCommandNameSchema = z.enum([ export const BuiltinCommandNameSchema = z.enum([

View File

@ -40,6 +40,7 @@ import {
createTasksTodowriteDisablerHook, createTasksTodowriteDisablerHook,
createWriteExistingFileGuardHook, createWriteExistingFileGuardHook,
} from "./hooks"; } from "./hooks";
import { createAnthropicEffortHook } from "./hooks/anthropic-effort";
import { import {
contextCollector, contextCollector,
createContextInjectorMessagesTransformHook, createContextInjectorMessagesTransformHook,
@ -294,6 +295,10 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
const taskResumeInfo = createTaskResumeInfoHook(); const taskResumeInfo = createTaskResumeInfoHook();
const anthropicEffort = isHookEnabled("anthropic-effort")
? createAnthropicEffortHook()
: null;
const tmuxSessionManager = new TmuxSessionManager(ctx, tmuxConfig); const tmuxSessionManager = new TmuxSessionManager(ctx, tmuxConfig);
const backgroundManager = new BackgroundManager( const backgroundManager = new BackgroundManager(
@ -550,6 +555,29 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
return { return {
tool: filteredTools, tool: filteredTools,
"chat.params": async (
input: {
sessionID: string
agent: string
model: Record<string, unknown>
provider: Record<string, unknown>
message: Record<string, unknown>
},
output: {
temperature: number
topP: number
topK: number
options: Record<string, unknown>
},
) => {
const model = input.model as { providerID: string; modelID: string }
const message = input.message as { variant?: string }
await anthropicEffort?.["chat.params"]?.(
{ ...input, agent: { name: input.agent }, model, provider: input.provider as { id: string }, message },
output,
);
},
"chat.message": async (input, output) => { "chat.message": async (input, output) => {
if (input.agent) { if (input.agent) {
setSessionAgent(input.sessionID, input.agent); setSessionAgent(input.sessionID, input.agent);