/** * Budget enforcement hooks — wires AgentBudgetEnforcer into the plugin * hook lifecycle. * * - `chat.message` → recordTurn per agent+session * - `tool.execute.after` → recordToolFailure when metadata.is_error is truthy * * When a budget violation fires with policy=stop or warn_then_stop, the * hook appends a notice to the tool output so the model sees the budget * exhaustion. */ import type { AgentBudgetEnforcer } from '../runtime/agent-budget'; import type { TelemetryCollector } from '../runtime/telemetry'; import type { KvService } from '../services/kv'; import type { AgentBudget, Logger, PluginConfig } from '../types'; export interface BudgetHooks { /** Called from chat.message hook. */ onMessage: (input: { sessionID: string; agent?: string; }) => void; /** Called from tool.execute.after hook. */ onToolAfter: (input: { sessionID: string; tool: string; }, output: { output: string; metadata: unknown; }) => void; } export interface BudgetSnapshot { agent: string; sessionId: string; state: { turns: number; toolFailures: number; requests: number; tokensUsed: number; }; budget: AgentBudget | null; warnings: string[]; violations: string[]; detail: string; allowed: boolean; updatedAt: number; } export declare function budgetSnapshotKey(sessionId: string, agent: string): string; export declare function createBudgetHooks(enforcer: AgentBudgetEnforcer, logger: Logger, config: PluginConfig, telemetry?: TelemetryCollector, projectId?: string, kvService?: KvService): BudgetHooks; //# sourceMappingURL=budget.d.ts.map