/** * Vault client for the agent-vault API — AES-256-GCM encrypted secrets. * * Two encryption paths (per migration 0022_vault_agent_encrypted.sql): * * Default (server-encrypted at rest): * .put(name, value, ...) — server encrypts; in-process runtime can read. * * Opt-in (zero-knowledge): * .put_encrypted(name, plaintext, { k_vault, ... }) — SDK encrypts * before send; agenttool stores ciphertext only. * .get_decrypted(name, { k_vault, ... }) — fetches and decrypts * locally (transparently falls through to plaintext if the secret * was stored via the default path). */ import { type HttpConfig } from "./_http.js"; export interface PutSecretOptions { description?: string; agent_ids?: string[]; tags?: string[]; ttl_seconds?: number; rotation_days?: number; agent_id?: string; } export interface PutEncryptedOptions extends PutSecretOptions { /** 32-byte AES-256 secret. Generate via `at.crypto.kVault.generate()` * and persist securely (OS keychain / encrypted file / env var). */ k_vault: Uint8Array; } export interface GetDecryptedOptions extends GetSecretOptions { /** 32-byte AES-256 secret used to decrypt the agent-encrypted path. * Ignored when the secret was stored via the server-encrypted path. */ k_vault: Uint8Array; } export interface GetSecretOptions { version?: number; agent_id?: string; } export interface ListSecretsOptions { tag?: string; expiring_soon?: boolean; rotation_due?: boolean; } export interface SetPolicyOptions { allowed_agents?: string[]; read_only?: boolean; require_agent_id?: boolean; } /** * Client for the agent-vault API. * * @example * ```ts * const at = new AgentTool(); * await at.vault.put("openai-key", "sk-..."); * const secret = await at.vault.get("openai-key"); * const names = await at.vault.list(); * await at.vault.delete("openai-key"); * ``` */ export declare class VaultClient { private readonly http; /** @internal */ constructor(http: HttpConfig); /** Store or update a secret (AES-256-GCM encrypted at rest). */ put(name: string, value: string, options?: PutSecretOptions): Promise>; /** Retrieve a secret's plaintext value. */ get(name: string, options?: GetSecretOptions): Promise>; /** Soft-delete a secret (all versions). */ delete(name: string): Promise>; /** List all secrets (names + metadata — values never returned). */ list(options?: ListSecretsOptions): Promise[]>; /** Get version history for a secret (metadata only, no values). */ versions(name: string): Promise[]>; /** Set an access policy for a secret. */ set_policy(name: string, options: SetPolicyOptions): Promise>; /** Retrieve the audit log for a secret or project-wide. */ audit(name?: string, options?: { limit?: number; }): Promise[]>; /** Retrieve multiple secrets in a single request. */ bulk(names: string[], options?: { agent_id?: string; }): Promise>; /** Check existence of multiple secrets without retrieving values. */ check(names: string[]): Promise>; /** * Encrypt locally with K_vault, then PUT as `agent_encrypted=true`. * * agenttool stores ciphertext + nonce verbatim and CANNOT decrypt. * The hosted runtime (think-worker etc.) cannot read these secrets * either — use {@link put} for secrets the server-side runtime needs * to consume. */ put_encrypted(name: string, plaintext: string, options: PutEncryptedOptions): Promise>; /** * Fetch a secret; decrypt locally if it was stored agent-encrypted. * * Transparently handles both paths: * - `agent_encrypted=true` → decrypt locally with k_vault, return * `{ value: , ... }`. * - `agent_encrypted=false` → server already returned plaintext; * pass through verbatim. * * The returned object always has `value` populated. `agent_encrypted` * is preserved so the caller can introspect which path was used. */ get_decrypted(name: string, options: GetDecryptedOptions): Promise<Record<string, unknown>>; private req; }