/** * Cost Cap Gate * * Pre-call gate that checks the accumulated cost for the current session * against a configured cap. Returns a COST_LIMIT_EXCEEDED error response * when the cap is reached (block mode) or fires a warn hook and proceeds * (warn mode). * * Requires: * - hazo_llm_api_log table to exist (ensure_api_log_table must be called first) * - A session_id available via hazo_logs ALS (safe_get_log_context) * - cost_cap.enabled = true in LLMApiConfig */ import type { Logger, LLMResponse, CostCapConfig } from '../llm_api/types.js'; import type { HazoConnect } from '../hazo_connect/types.js'; /** * Ensure the session_id + created_at composite index exists on hazo_llm_api_log. * Idempotent — safe to call on every initialization. * Errors are swallowed to avoid crashing initialization. */ export declare function ensure_cost_cap_index(connect: HazoConnect, logger: Logger): Promise; /** * Query the total cost_usd accumulated for a session within the given window. * * Returns 0 if connect has no raw_sql, if there are no matching rows, or if * any DB error occurs (errors are swallowed). */ export declare function query_session_cost(connect: HazoConnect, session_id: string, window_start: string, logger: Logger): Promise; /** * Pre-call cost cap gate. * * Returns: * - `null` if the gate should not block (cap disabled, no session, current < cap, or warn mode) * - `LLMResponse` if the call should be blocked (block mode, cap exceeded) * * In warn mode the `cost_cap_exceeded` hook is called (errors swallowed) and null is returned * so the call proceeds. */ export declare function check_cost_cap_gate(connect: HazoConnect | null, cap_config: CostCapConfig | undefined, logger: Logger): Promise; //# sourceMappingURL=cost_cap.d.ts.map