/** * `codexpethub install ` — download manifest, verify sha256 + WebP * magic + size caps, then atomically place files in `~/.codex/pets//`. * * Architecture references: * - §9.1: install-manifest.v1 schema (fetched in manifest.ts) * - §16.2: client-side verification rules (sha256 + WebP magic + size caps) * * The implementation is in-memory by design: spritesheets cap at 4 MB and * pet.json caps at 50 KB, so loading both into Buffers keeps the code * simple, the streaming-vs-buffered tradeoff trivial, and verification * straightforward (hash the whole buffer; check magic bytes; write atomically * via a sibling temp dir + fs.rename). */ import { type HttpResponse, type InstallManifest, type ManifestFile } from "./manifest.js"; export type InstallErrorCode = "sha_mismatch" | "oversized" | "size_mismatch" | "host_not_allowed" | "exists_no_overwrite" | "network_error" | "webp_invalid" | "manifest_invalid"; export declare class InstallError extends Error { readonly code: InstallErrorCode; constructor(code: InstallErrorCode, message: string); } export interface FileFetchResponse { status: number; body: Buffer; contentType?: string | undefined; } export type FileFetcher = (url: URL) => Promise; export type ManifestFetcher = (url: URL) => Promise; export interface InstallOptions { slug: string; registryUrl?: string; /** Override $CODEX_HOME / ~/.codex; the CLI installs into `/pets/`. */ codexHome?: string; overwrite?: boolean; log?: (line: string) => void; /** Test injection — replaces network access for the manifest. */ manifestFetch?: ManifestFetcher; /** Test injection — replaces network access for file downloads. */ fileFetch?: FileFetcher; } export interface InstalledFile { role: ManifestFile["role"]; path: string; bytes: number; sha256: string; } export interface InstallResult { installDir: string; manifest: InstallManifest; files: InstalledFile[]; } /** * Returns the absolute install dir for a slug, honoring (in order): * 1. explicit `--codex-home` override * 2. `$CODEX_HOME` env var * 3. `~/.codex` */ export declare function resolveInstallDir(slug: string, codexHomeOverride?: string, env?: NodeJS.ProcessEnv): string; /** Validates RIFF/WEBP magic bytes (offsets 0-3 = "RIFF", 8-11 = "WEBP"). */ export declare function isValidWebP(buf: Buffer): boolean; /** * Install a pet by slug. Resolves to an InstallResult on success or * rejects with InstallError / ManifestError on any verification failure. */ export declare function installPet(options: InstallOptions): Promise; /** Maps any thrown error from installPet/fetchInstallManifest to a CLI exit code. */ export declare function exitCodeForError(err: unknown): number; //# sourceMappingURL=install.d.ts.map