UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

35 lines • 1.64 kB
import { type QuotaBlock, type QuotaReport, type QuotaWarning, type QuotaWindow } from '../../../spi/quota-provider.js'; import { type AgentBackend } from '../backend.js'; export interface UseQuotaOptions { /** Default: the enclosing `<AgentProvider>`'s. Must implement `getQuota`. */ backend?: AgentBackend; /** `false` holds the request. Default `true`. */ enabled?: boolean; /** Re-read every `pollMs` ms as well. Default: only on mount, after runs, and on `refresh`. */ pollMs?: number; } export interface QuotaState { /** The full report, once loaded. */ report: QuotaReport | undefined; windows: QuotaWindow[]; /** The `day` / `month` windows, when the server reports them. */ day: QuotaWindow | undefined; month: QuotaWindow | undefined; /** The window that blocks sends, or `null` — pass it to `useAgentChat({ blocked })`. */ blocked: QuotaBlock | null; /** * The soft limit: the fullest window past its `warnAt` (`{ period, ratio, reason? }`), or `null`. * The server's `warning`, else derived from the windows; never set while `blocked`. */ warning: QuotaWarning | null; isLoading: boolean; error: Error | null; refresh: () => Promise<void>; } /** * The caller's budget (`GET <base>/quota`): every window's usage against its ceilings, and which * one — if any — blocks sends. Re-read after every run a chat on the same backend settles, so a * meter moves with the conversation. Headless: draw the meter yourself. */ export declare function useQuota(options?: UseQuotaOptions): QuotaState; //# sourceMappingURL=use-quota.d.ts.map