UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

52 lines • 2.37 kB
import { Encryption } from '@adonisjs/core/encryption'; import type { KmsAdapter } from './kms.js'; /** * What the kit needs from Adonis' encryption: an `Encryption` or the app's `EncryptionManager` * (`@adonisjs/core/services/encryption`) both fit. */ export interface EncrypterLike { encrypt(payload: unknown, options?: { purpose?: string; }): string; decrypt<T = unknown>(value: string, purpose?: string): T | null; } /** A key: a string, or an Adonis `Secret` (`env.get('APP_KEY')`). At least 16 characters. */ export type SecretLike = string | { release(): string; }; /** * Opens a value written before the kit (a lib's old format). Returns the plaintext, or `undefined` * when the value is not one it knows. A throw counts as `undefined`. */ export type LegacyReader = (sealed: string) => string | undefined | Promise<string | undefined>; export interface KeyringOptions { /** Domain separation, e.g. `authkit:keystore`: bound into every value as Adonis' `purpose`. */ purpose: string; /** * Keys, newest first: the first encrypts, every one decrypts (Adonis' AES-256-GCM driver). The * kit can then tell values sealed with an older key apart (`retired`). */ keys?: SecretLike[]; /** * Or an Adonis encryption instance (the app's `encryption` service by default in the libs). Its * own keys rotate in `config/encryption.ts`; the kit can't tell which of them sealed a value. */ encryption?: EncrypterLike; /** Envelope encryption: a fresh data key per value, wrapped by the KMS and stored inline. */ kms?: KmsAdapter; /** Readers for values written before the kit, tried in order. Never used to write. */ legacy?: LegacyReader[]; } export interface Keyring { readonly purpose: string; /** Opens with every key. */ readonly all: EncrypterLike; /** Opens with the encrypting key only; `undefined` when the kit can't tell keys apart. */ readonly active: EncrypterLike | undefined; readonly kms: KmsAdapter | undefined; readonly legacy: readonly LegacyReader[]; } /** Adonis `Encryption` over AES-256-GCM with these keys (first encrypts). */ export declare function gcmEncryption(keys: SecretLike[], id?: string): Encryption; export declare function createKeyring(options: KeyringOptions): Keyring; //# sourceMappingURL=keyring.d.ts.map