@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
44 lines • 2.18 kB
TypeScript
/**
* Reversible tokenization for one request: each distinct sensitive value gets a stable placeholder
* (`[EMAIL_1]`, `[CREDIT_CARD_2]`…) in order of first appearance, so a conversation re-sent turn
* after turn maps to the same placeholders. The model only sees placeholders; `restore` puts the
* values back into what the caller receives.
*
* Values stay in this object. {@link toJSON} / {@link fromJSON} exist for a caller that must carry a
* vault across processes (a durable run resumed elsewhere); wherever that snapshot is stored holds
* the raw values, so treat it like the data it came from.
*/
export declare class Vault {
private readonly byValue;
private readonly byToken;
private readonly counters;
/**
* Placeholder for `value` under `label` (e.g. `CREDIT_CARD`). Reversible placeholders look like
* `[CREDIT_CARD_1]`; one-way ones (tool results, answers, rules with `restore: false`) like
* `[REDACTED_CREDIT_CARD_1]`, so they can never be mistaken for a reversible one.
*/
tokenFor(label: string, value: string, restorable: boolean): string;
get size(): number;
get restorableCount(): number;
/** Longest placeholder, for stream hold-back windows. */
get maxTokenLength(): number;
/** Puts restorable values back. `jsonString`: the text is inside a JSON string literal. */
restore(text: string, jsonString?: boolean): string;
/** Whether `text` ends with what could be the beginning of a placeholder (streaming). */
pendingPrefix(text: string): number;
/** Every entry, in the order the placeholders were minted. */
toJSON(): VaultSnapshot;
/** Rebuilds a vault from {@link toJSON}; placeholders keep their numbers and counters resume. */
static fromJSON(snapshot: VaultSnapshot): Vault;
}
/** A serializable {@link Vault}. */
export interface VaultSnapshot {
entries: Array<{
token: string;
value: string;
restorable: boolean;
}>;
}
/** `pii.credit_card` -> `CREDIT_CARD`, `secret.openai_key` -> `OPENAI_KEY`, `ner.person` -> `PERSON`. */
export declare function labelFor(category: string): string;
//# sourceMappingURL=vault.d.ts.map