@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
52 lines • 2.67 kB
TypeScript
import type { ConfirmTokenClaim, ConfirmTokenStore } from './spi/confirm-token-store.js';
/** How long a preview stays confirmable unless the tool says otherwise. */
export declare const DEFAULT_CONFIRM_TTL_MS: number;
/** What a confirm token is bound to. Change any of it and the token stops matching. */
export interface ConfirmTokenSubject {
/** The tool's name. */
tool: string;
/** `ctx.actor.id`. */
actorId: string;
/** `ctx.actor.tenantRef`; absent and `''` sign the same. */
tenantRef?: string;
/** The call's arguments, WITHOUT `confirm` / `confirmToken`. */
args: unknown;
}
/**
* JSON with object keys sorted at every depth, so two argument objects that differ only in key
* order produce the same text. `undefined` properties are dropped (as `JSON.stringify` does); a
* bare `undefined` and an `undefined` array element are `null`.
*/
export declare function canonicalJson(value: unknown): string;
/**
* Issue a confirm token: `<expiresAt>.<signature>`, an HMAC-SHA256 (keyed by `secret`) over the tool,
* the actor, the tenant, the expiry and the canonical arguments. Stateless — nothing is stored — and
* useless for another actor, tenant, tool or argument, or after `expiresAt` (epoch-ms).
*/
export declare function signConfirmToken(subject: ConfirmTokenSubject, options: {
secret: string;
expiresAt: number;
}): string;
/** The expiry (epoch-ms) a token carries, or `undefined` for a malformed one. Not a verification. */
export declare function confirmTokenExpiry(token: string): number | undefined;
/** Was this token issued for exactly this subject, with this secret, and is it still valid at `now`? */
export declare function verifyConfirmToken(token: string | null | undefined, subject: ConfirmTokenSubject, options: {
secret: string;
now?: number;
}): boolean;
/** SHA-256 (hex) of a token — what a {@link ConfirmTokenStore} keys on, so the token is never stored. */
export declare function hashConfirmToken(token: string): string;
/**
* A single-process {@link ConfirmTokenStore}: tests, scripts, and a deployment that runs ONE replica.
* With more than one, a token spent on replica A is still fresh on replica B — use the Lucid store.
* Expired marks are dropped lazily, on the next claim.
*/
export declare class InMemoryConfirmTokenStore implements ConfirmTokenStore {
private readonly claims;
claim(input: ConfirmTokenClaim): Promise<boolean>;
release(hash: string): Promise<void>;
purgeExpired(now?: number): Promise<number>;
/** How many tokens are currently marked as spent. */
get size(): number;
}
//# sourceMappingURL=confirm-token.d.ts.map