/** * container-lease — pure-function lease store for `peaks container spawn`. * * runtime). Mirrors the design of `worktree-lease.ts` (Part 1): * - Pure function module: every helper takes the lease * directory path as an argument and returns structured data. * Atomic filesystem writes happen at the call site (CLI * command), keeping the helpers trivially testable. * - Lifecycle states: active → released/expired/gc, irreversible * once terminal. * - The CLI in `src/cli/commands/container-commands.ts` writes * the lease file and runs `docker run` / `docker rm`; the * `peaks sub-agent dispatch --isolation container` command * (Part 8) shells out to the spawn CLI and persists the * leaseId on the dispatch record (v3 schema). * * Why a separate lease (not reusing the worktree one): the two * isolation modes have different lifecycles, different runtime * commands, and different env-var hooks for the PreToolUse * gate. Reusing the worktree lease would have made the lease * file schema bimodal (worktree-or-container in every field). * Two thin modules is cleaner than one thick one. * * Note: container runtime is docker-only for Part 12. podman * support (drop-in CLI-compatible for `run` / `rm` / `ps`) is * a follow-up; the runtime-agnostic interface lives in * container-runtime.ts (next slice). */ export declare const DEFAULT_TTL_BY_ROLE: Readonly>; export declare const DEFAULT_TTL_MS: number | undefined; export type ContainerLeaseStatus = 'active' | 'released' | 'expired' | 'gc'; export interface ContainerLease { readonly leaseId: string; /** The peaks request id (rid) that the lease was spawned for. */ readonly rid: string; /** Sub-agent role (rd | qa | ui | sc | prd | general-purpose | ...). */ readonly role: string; /** Absolute container working dir (mounted into the container). */ readonly path: string; /** Docker image name (e.g. `node:22-slim`). */ readonly image: string; /** Container id reported by `docker run`. */ readonly containerId: string; /** Unix epoch ms when the lease was created. */ readonly createdAt: number; /** Unix epoch ms when the lease expires. */ readonly expiresAt: number; /** Operator-supplied purpose text (audit log). */ readonly purpose: string; readonly status: ContainerLeaseStatus; readonly consumedBySubAgents: ReadonlyArray; } export type ContainerLeaseDraft = Omit; export declare function containerLeaseStoreDir(sessionRuntimeDir: string): string; export declare function containerLeaseFilePath(sessionRuntimeDir: string, leaseId: string): string; /** Pure: generate a 16-hex lease id (8 random bytes, hex-encoded). */ export declare function generateContainerLeaseId(): string; export declare function ttlForContainerRole(role: string): number; export declare function finalizeContainerLease(draft: ContainerLeaseDraft): ContainerLease; export declare function markContainerReleased(lease: ContainerLease): ContainerLease; export declare function markContainerExpired(lease: ContainerLease): ContainerLease; export declare function markContainerGc(lease: ContainerLease): ContainerLease; export declare function recordContainerConsumption(lease: ContainerLease, subAgentId: string): ContainerLease; export declare function isContainerLeaseActive(lease: ContainerLease, now?: number): boolean; export declare function serializeContainerLease(lease: ContainerLease): string; export declare function deserializeContainerLease(raw: string): ContainerLease;