@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
38 lines • 2.02 kB
TypeScript
import type { ConfirmTokenClaim, ConfirmTokenStore } from '../spi/confirm-token-store.js';
import type { LucidDatabaseLike } from './lucid.js';
/** Options for {@link LucidConfirmTokenStore}. */
export interface LucidConfirmTokenStoreOptions {
/**
* Provision the shared agent tables on first use. Default `true` (the ecosystem convention). Set
* `false` to run the migration.
*/
autoCreateTables?: boolean;
}
/**
* A production {@link ConfirmTokenStore} backed by AdonisJS **Lucid** over the `agent_confirm_token`
* table — what makes a confirmed write single use across replicas. Like
* {@link import('./lucid.js').LucidAgentStore} it touches only the structural {@link LucidDatabaseLike}
* slice, so `@adonisjs/lucid` stays an optional peer.
*
* `claim` is one `INSERT` that skips on a duplicate hash, so the primary key is the lock: of two
* concurrent confirmations one inserts and the other touches no row. It is a statement that does not
* FAIL on the duplicate (`ON CONFLICT DO NOTHING`; `INSERT IGNORE` on MySQL) rather than an insert
* whose unique violation is caught, because on Postgres a failed statement aborts the transaction it
* ran in.
*
* Only the token's SHA-256, the actor and the tool name are stored. `expires_at` is epoch-ms, like the
* rest of the schema; call {@link purgeExpired} from a scheduled job to drop the dead rows.
*/
export declare class LucidConfirmTokenStore implements ConfirmTokenStore {
private readonly db;
private readonly autoCreateTables;
constructor(db: LucidDatabaseLike, options?: LucidConfirmTokenStoreOptions);
/** Provision the shared schema on first use (no-op when disabled), memoized across the stores. */
private ready;
/** Provision the shared schema now. Idempotent. */
ensureSchema(): Promise<void>;
claim(input: ConfirmTokenClaim): Promise<boolean>;
release(hash: string): Promise<void>;
purgeExpired(now?: number): Promise<number>;
}
//# sourceMappingURL=lucid-confirm-tokens.d.ts.map