Remove unused modelHooks and toolHooks (#17115)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
Vedant Mahajan
2026-01-21 10:04:50 +05:30
committed by GitHub
parent c9f0a48bdc
commit 3a4012f76a
3 changed files with 46 additions and 478 deletions

View File

@@ -27,15 +27,56 @@ import type { AggregatedHookResult } from './hookAggregator.js';
import type {
GenerateContentParameters,
GenerateContentResponse,
GenerateContentConfig,
ContentListUnion,
ToolConfig,
ToolListUnion,
} from '@google/genai';
import type {
AfterModelHookResult,
BeforeModelHookResult,
BeforeToolSelectionHookResult,
} from '../core/geminiChatHookTriggers.js';
/**
* Main hook system that coordinates all hook-related functionality
*/
export interface BeforeModelHookResult {
/** Whether the model call was blocked */
blocked: boolean;
/** Whether the execution should be stopped entirely */
stopped?: boolean;
/** Reason for blocking (if blocked) */
reason?: string;
/** Synthetic response to return instead of calling the model (if blocked) */
syntheticResponse?: GenerateContentResponse;
/** Modified config (if not blocked) */
modifiedConfig?: GenerateContentConfig;
/** Modified contents (if not blocked) */
modifiedContents?: ContentListUnion;
}
/**
* Result from firing the BeforeToolSelection hook.
*/
export interface BeforeToolSelectionHookResult {
/** Modified tool config */
toolConfig?: ToolConfig;
/** Modified tools */
tools?: ToolListUnion;
}
/**
* Result from firing the AfterModel hook.
* Contains either a modified response or indicates to use the original chunk.
*/
export interface AfterModelHookResult {
/** The response to yield (either modified or original) */
response: GenerateContentResponse;
/** Whether the execution should be stopped entirely */
stopped?: boolean;
/** Whether the model call was blocked */
blocked?: boolean;
/** Reason for blocking or stopping */
reason?: string;
}
export class HookSystem {
private readonly hookRegistry: HookRegistry;
private readonly hookRunner: HookRunner;