/** * In-process Sprites fake (#762, #766, S7) — a fake of the faithful Sprites API * surface for offline, Docker-free integration tests. * * It models the lifecycle state machine and checkpoint/restore semantics, not * real Firecracker VMs or real code execution (that fidelity is out of scope). * A sprite's filesystem is a `Record`; `exec` runs a small * scripted interpreter that can write/modify an `fs` key so checkpoint/restore * is observable; `checkpoint` deep-copies `fs` under a version id; `restore` * replaces `fs` with that copy. Started in-process by a test and reached via * `SPRITES_BASE_URL`, so the same activities that hit real Sprites hit the fake. * * The wire surface matches the released `spritzer:0.3.1` image so the CI * fake-based test and the docker test exercise the same protocol: * - `exec` over the control WebSocket with `[StreamID][payload]` binary framing; * - `POST /checkpoint` (singular) returning NDJSON progress + a `complete` event; * - `GET /checkpoints` returning a bare array of `{ id, comment, create_time, is_auto }`; * - `POST /checkpoints/{id}/restore` returning NDJSON. * Checkpoint ids are server versions (`v1`, `v2`, ...). */ type SpriteStatus = "starting" | "running" | "paused" | "destroyed"; interface StoredCheckpoint { id: string; comment: string; create_time: string; is_auto: boolean; fs: Record; } interface StoredService { name: string; cmd: string; args?: string[]; env?: Record; dir?: string; needs?: string[]; http_port?: number; state: { name: string; pid: number; status: string; started_at?: string; }; } interface SpriteState { id: string; status: SpriteStatus; url: string; /** Filesystem model: path → contents. */ fs: Record; /** Checkpoints in creation order; each holds a full copy of `fs` at that time. */ checkpoints: StoredCheckpoint[]; /** Monotonic version counter for `v` ids. */ version: number; policy?: unknown; /** Outbound network policy (whole-object replace via /policy/network). */ netPolicy: Array<{ domain: string; action: string; }>; /** Background services keyed by name (create-or-update via PUT). */ services: Record; /** Keep-alive tasks keyed by name; while any exists the sprite stays active. */ tasks: Record; } interface ExecResult { stdout: string; stderr: string; exitCode: number; } /** * Run one command against a sprite's `fs`. Not a real shell: it recognizes a * small set of forms so a test (and the example `guarded-task` Op) can write a * key, then overwrite/fail it, and prove restore rewinds. Segments split on * `;` run in order; the exit code is the last segment's (shell `;` semantics). */ export declare function fakeExec(sprite: SpriteState, cmd: string): ExecResult; /** * Immediate children of `dir` in a flat `path → contents` map: a key * `${dir}/name` is a file; `${dir}/name/...` contributes the dir `name` once. * Pure — the filesystem-list model for the fake. */ export declare function fakeListDir(fs: Record, dir: string): Array<{ name: string; type: "file" | "dir"; size?: number; }>; /** * Start the in-process Sprites fake on an ephemeral port. Returns its base * `url` (feed it to `SPRITES_BASE_URL`) and a `close()`. */ export declare function createSpritesFake(): Promise<{ url: string; close(): Promise; }>; export {}; //# sourceMappingURL=sprites-fake.d.ts.map