/** * Secret ask-card answers (`kind: "secret"` questions). The API validates, * generates and encrypts each value before the accept transaction; this module * writes them to the chosen vault inside that transaction and returns the * references that replace them in the stored response. No plaintext secret * value reaches this layer, events or the stored response. */ import { type HumanInputQuestion, type HumanInputSecretAnswerResult, type SecretSaveTo } from "@opengeni/contracts"; import type { z } from "zod"; import type { Database } from "./database.js"; import { type VaultDbContext } from "./vaults.js"; /** One encrypted value plus its plaintext byte size (checked against vault limits). */ export type PreparedSecretValue = { valueEncrypted: string; valueSize: number; }; /** A secret answer after the API validated, generated and encrypted it. */ export type PreparedSecretAnswer = { questionId: string; saveTo: SecretSaveTo; vaultId?: string; value: PreparedSecretValue; /** The username is not a secret: the agent receives it in plain text (AC-3). */ username?: PreparedSecretValue & { plain: string; }; /** Derived from an SSH private key answer; saved by `ssh_key` questions. */ sshPublicKey?: { publicKey: PreparedSecretValue; fingerprint: PreparedSecretValue; }; generated: boolean; }; export type SecretAnswerResult = z.infer; /** * Write every answered secret to its vault in the caller's transaction and * return what the agent receives instead of the value, keyed by question. * A failure throws and rolls the whole response back (AC-2). */ export declare function applyPreparedSecretAnswersInTransaction(tx: Database, context: VaultDbContext, input: { sessionId: string; turnId: string; questions: readonly HumanInputQuestion[]; answers: readonly PreparedSecretAnswer[]; }): Promise>;