@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
49 lines • 2.79 kB
TypeScript
import type { AgentPricingStore, CurrentModelPrice, ModelPriceInput } from '../spi/pricing-store.js';
import type { LucidDatabaseLike } from './lucid.js';
/** Options for {@link LucidPricingStore}. */
export interface LucidPricingStoreOptions {
/**
* Provision the shared agent tables on first use. Default `true` (the ecosystem convention). The
* pricing store writes to `agent_model_pricing`, one of the six shared tables; auto-provisioning
* here is what lets a pricing seed run before the first agent run. Set `false` to run the migration.
*/
autoCreateTables?: boolean;
/**
* The database schema (a Postgres schema, a MySQL database) the agent tables live in — the same
* one the agent store writes to. Default: none (the connection's current schema). Refused on SQLite.
*/
schema?: string | undefined;
}
/**
* A production {@link AgentPricingStore} backed by AdonisJS **Lucid** (Knex) over the
* `agent_model_pricing` table — the write side the loop's cost fold prices token usage against. Like
* {@link import('./lucid.js').LucidAgentStore} it touches only the structural {@link LucidDatabaseLike}
* slice, so `@adonisjs/lucid` stays an optional peer (the factory casts the real `db` in).
*
* Atomic supersede (mirrors the reference Drizzle/MikroORM stores): `upsertModelPrice` retires the
* model's prior `is_current` row and inserts a fresh current one, so exactly one live price exists
* per model. `effective_from` is stored as epoch-ms (matching the rest of the schema) and read back
* as an ISO string. Booleans are `INTEGER` 0/1 for cross-dialect portability.
*/
export declare class LucidPricingStore implements AgentPricingStore {
private readonly db;
private readonly autoCreateTables;
private readonly schema;
/** The agent tables as the query builder names them (`schema.table` under a schema). */
private readonly tables;
/**
* Whether `agent_model_pricing` has `created_at` / `updated_at`. Always so when the store provisions
* the schema; probed once under `autoCreateTables: false`, where the app's migration may lag.
*/
private timestampColumns;
constructor(db: LucidDatabaseLike, options?: LucidPricingStoreOptions);
/** Provision the shared schema on first use (no-op when disabled), memoized across the stores. */
private ready;
/** Whether the timestamp columns can be written (see {@link timestampColumns}). */
private hasTimestamps;
/** Provision the shared schema now (what the agent provider calls at app start). Idempotent. */
ensureSchema(): Promise<void>;
upsertModelPrice(input: ModelPriceInput): Promise<void>;
listCurrentPrices(): Promise<CurrentModelPrice[]>;
}
//# sourceMappingURL=lucid-pricing.d.ts.map