/** * CLEO KMS Adapter — `CLEO_KMS_ADAPTER` key-backend selector. * * Exports {@link loadSigningIdentity} which returns an `AgentIdentity` * from `llmtxt/identity` using the backend selected by the * `CLEO_KMS_ADAPTER` environment variable. * * Supported backends: * * | Adapter | Env var value | Key source | * |---------|---------------|------------| * | `env` | `"env"` | `CLEO_SIGNING_SEED` (64-char hex) | * | `file` | `"file"` (default) | `.cleo/keys/sentient.ed25519` (mode 0600) | * | `vault` | `"vault"` | HashiCorp Vault `transit/` engine (stub) | * | `aws` | `"aws"` | AWS KMS Ed25519 key (stub) | * * Dev/CI: use `env` adapter. Production: use `vault` or `aws`. * * The daemon process owns the signing context. The experiment agent * container NEVER receives the key material directly (closes Round 2 * attack #3 — mode-0600 keyfile is accessible to the host OS user). * * @see DESIGN.md §4.2 — KMS adapter abstraction * @task T1021 */ import type { AgentIdentity } from 'llmtxt/identity'; /** * Supported CLEO KMS adapter backends. * * Selected by the `CLEO_KMS_ADAPTER` environment variable. * Defaults to `"file"` for backward compatibility with ADR-054. */ export type KmsAdapterKind = 'env' | 'file' | 'vault' | 'aws'; /** * Load a signing identity using the backend selected by `CLEO_KMS_ADAPTER`. * * The returned `AgentIdentity` from `llmtxt/identity` provides `sign()`, * `verify()`, and `pubkeyHex` without exposing raw private-key bytes to * callers. The private key is only read once per call; caching is the * caller's responsibility. * * @param projectRoot - Absolute path to the CLEO project root. Used by the * `file` adapter to locate `.cleo/keys/sentient.ed25519`. * @returns An `AgentIdentity` constructed from the selected backend. * @throws If the selected backend cannot load key material (missing env var, * wrong file permissions, network error, etc.). * * @example * ```ts * import { loadSigningIdentity } from '@cleocode/core/sentient/kms.js'; * * const identity = await loadSigningIdentity(projectRoot); * const sig = await identity.sign(Buffer.from('hello')); * ``` */ export declare function loadSigningIdentity(projectRoot: string): Promise; /** * Resolve the adapter kind from `CLEO_KMS_ADAPTER` environment variable. * * Defaults to `"file"` when the variable is absent or empty. * * @throws If the value is set but not one of the valid adapter kinds. */ export declare function resolveAdapterKind(): KmsAdapterKind; /** * Load an `AgentIdentity` from the `CLEO_SIGNING_SEED` environment variable. * * `CLEO_SIGNING_SEED` must be a 64-character lowercase hex string encoding * a 32-byte Ed25519 seed. Suitable for development and CI pipelines where * secrets are injected as environment variables. * * @throws If `CLEO_SIGNING_SEED` is absent, malformed, or not exactly 64 hex chars. */ export declare function loadEnvIdentity(): Promise; /** * Load an `AgentIdentity` from a keyfile on disk. * * The keyfile must be located at `/.cleo/keys/sentient.ed25519` * and must have UNIX permissions `0600` (owner read+write only). * The file must contain exactly 32 raw bytes (the Ed25519 seed). * * Refuses to load if permissions are wider than 0600 — this closes the * Round 2 attack surface where a prompt-injected agent running as the same * OS user could read the key. * * @param projectRoot - Absolute path to the CLEO project root. * @throws If the keyfile is missing, has wrong permissions, or wrong size. */ export declare function loadFileIdentity(projectRoot: string): Promise; /** * Load an `AgentIdentity` backed by HashiCorp Vault's Transit Engine. * * **STUB implementation** — this adapter is an interface-compliance skeleton. * Full implementation requires a Vault SDK or direct HTTP calls to the * Transit Engine API endpoints: * * - `POST /v1/transit/sign/` — sign a payload * - `POST /v1/transit/verify/` — verify a signature * - `GET /v1/transit/keys/` — retrieve public key * * Required environment variables: * - `VAULT_ADDR` — Vault server address (e.g. `https://vault.example.com`) * - `VAULT_TOKEN` — authentication token * - `CLEO_KMS_VAULT_KEY` — Transit key name (default: `cleo-sentient`) * * @throws Always throws with a descriptive message indicating this is a stub. */ export declare function loadVaultIdentity(): Promise; /** * Load an `AgentIdentity` backed by AWS KMS. * * **STUB implementation** — this adapter is an interface-compliance skeleton. * Full implementation requires `@aws-sdk/client-kms` or direct calls to the * AWS KMS API: * * - `Sign` — sign a message digest with the KMS key * - `Verify` — verify a signature * - `GetPublicKey` — retrieve the public key bytes * * Required environment variables: * - `CLEO_KMS_AWS_KEY_ID` — AWS KMS Key ARN or alias * - Standard AWS credentials: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, * `AWS_REGION` (or IAM role via instance metadata) * * AWS KMS Sign API (Ed25519): * ``` * POST https://kms..amazonaws.com/ * Action: Sign * KeyId: * Message: * MessageType: RAW * SigningAlgorithm: ECDSA_SHA_256 (Ed25519 uses EdDSA; use KEY_SPEC: ECC_NIST_P256 or SM2) * ``` * * @throws Always throws with a descriptive message indicating this is a stub. */ export declare function loadAwsIdentity(): Promise; /** Re-export AgentIdentity type for callers who import from this module. */ export type { AgentIdentity }; //# sourceMappingURL=kms.d.ts.map