@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
50 lines • 2.43 kB
TypeScript
import type { AgentStore } from '../spi/agent-store.js';
import { type QuotaProvider, type QuotaQuery, type QuotaReport } from '../spi/quota-provider.js';
import type { QuotaStore } from '../spi/quota-store.js';
/** Ceilings for one window. Either, both or neither. */
export interface QuotaWindowLimits {
tokens?: number;
usd?: number;
}
/** Ceilings per window — what `quotas.windows({ … })` takes. */
export interface QuotaLimits {
day?: QuotaWindowLimits;
month?: QuotaWindowLimits;
}
/** {@link LedgerQuotaProvider}'s tuning beyond the ceilings. */
export interface LedgerQuotaOptions {
/**
* The soft limit: the share of a ceiling (`0..1`) past which the report carries a `warning`.
* Stamped on every window that has a ceiling. Omit → no warnings.
*/
warnAt?: number;
/**
* Whether the USD windows count ESTIMATED cost (tokens × the price row, for a provider that reports
* none, e.g. Bedrock, OpenAI or Anthropic direct) as well as provider-reported cost. Default `true`:
* a USD ceiling that ignored estimates would read $0 and never block for every such provider, which
* is a budget that does not enforce. Set `false` to budget on provider-reported (gateway) cost only.
*/
countEstimatedCost?: boolean;
}
/**
* A {@link QuotaProvider} over the usage ledger: a day window (tokens from `quotaToday`, spend from
* `usageBetween` when the store has it), and a month window when the store implements
* `usageBetween`. Ceilings come from `limits`; a {@link QuotaStore} passed alongside lends the day
* window its own token ceiling when `limits.day.tokens` does not set one.
*
* Spend is what the usage rows recorded: the provider-reported cost of a gateway, plus the loop's
* estimate for a provider that reports none (unless `countEstimatedCost: false`).
*/
export declare class LedgerQuotaProvider implements QuotaProvider {
private readonly store;
private readonly quota?;
private readonly limits;
private readonly options;
constructor(store: AgentStore, quota?: QuotaStore | undefined, limits?: QuotaLimits, options?: LedgerQuotaOptions);
report(query: QuotaQuery): Promise<QuotaReport>;
private dayWindow;
/** The window's USD: every priced row, or (with `countEstimatedCost: false`) reported cost only. */
private usd;
private window;
}
//# sourceMappingURL=ledger-quota-provider.d.ts.map