/** * Step-by-step progress reporting for `hikoutei setup`. * * The setup flow creates several remote Google Cloud resources and waits on * asynchronous IAM/ACL propagation, so a run can take minutes with no stdout * activity. This module renders that progress to stderr as two bars: * * - an OVERALL bar that advances one segment per completed setup phase * (never a guessed percentage or an ETA — only finished work moves it); * and * - a DETAIL bar for the bounded retry polls inside the key-settlement and * service-account access-verification phases (how many of the eight * propagation checks have run, and during a known wait how far through * that wait the clock is) plus a fixed `working…` label for * unknown-duration steps. * * The flow reports progress through a discriminated * {@link SetupProgressEvent} union: `resumed` (once, with the phases a * checkpoint guarantees), `phase_started` / `phase_completed` at phase * boundaries, `operation_started` / `operation_completed` around the * notable remote/local steps (fixed safe labels; the bounded propagation * checks additionally carry 1-based attempt info), `retry_wait_started` * before each bounded sleep, and `phase_failed` (a stable * {@link SetupErrorCode} only) emitted by the CLI controller when a run * ends in error — the flow itself returns a stable error result and never * knows it is the final attempt (the interactive login retry can still * rescue an auth preflight failure). * * Two renderers share one validating state machine: * - an interactive (TTY, color-capable) renderer that redraws a fixed * four-line block in place with ANSI and animates a known wait through * an `unref`-ed interval timer; and * - an append-only renderer for CI / non-TTY / `NO_COLOR` that prints a * static line per phase start / phase completion / bounded-check attempt * / retry wait / failure and NEVER uses control sequences, a clock tick, * or a line for ordinary operation events (no log spam). The final * bounded attempt (8/8) has no following wait line, so it must print its * own attempt line or it would be invisible before success/failure. * * Security contract: progress events and rendered text carry ONLY fixed * labels, attempt/delay numbers, and stable error codes. Project ids, * service-account emails, owner emails, paths, access tokens, private keys, * key ids, raw gcloud output, and raw provider payloads are NEVER placed in * an event or written by a renderer. A throwing renderer callback is * swallowed by {@link safeProgressSink}, and the controller swallows its * own write/scheduler failures, so progress can never change the setup * result, the mutation order, or the process exit code. This module is * internal CLI machinery only; it is not part of the application-facing * API. */ import { type SetupErrorCode } from "./errors.js"; /** The ten setup phases in execution order. */ export declare const SETUP_PROGRESS_PHASES: readonly ["cloud_auth", "drive_access", "project", "apis", "service_account", "service_account_key", "spreadsheet", "share", "sa_access", "output"]; /** One setup phase. */ export type SetupProgressPhase = (typeof SETUP_PROGRESS_PHASES)[number] | typeof POOL_EXPANSION_PHASE; /** * Credential-pool expansion phase for `--sa-count` runs with N > 1. * * Deliberately OUTSIDE {@link SETUP_PROGRESS_PHASES}: the fixed ten-phase * list (and its denominator) is the byte-identical N=1 contract, so the * pool phase never counts toward the overall bar. It is emitted only when * the pool is active (after the output phase of the primary flow), and the * tracker accepts it without advancing the completed count. */ export declare const POOL_EXPANSION_PHASE: "pool_expansion"; /** Total number of setup phases (drives the overall bar denominator). */ export declare const SETUP_PROGRESS_PHASE_COUNT: 10; /** Fixed, safe human labels for each phase (never secrets). */ export declare const SETUP_PROGRESS_LABELS: Readonly>; /** Short labels for the compact "done" line. */ export declare const SETUP_PROGRESS_SHORT_LABELS: Readonly>; /** The bounded retry polls that carry a nested detail bar. */ export type SetupRetryKind = "key_settlement" | "sa_access"; /** * Fixed, safe operation labels for the notable setup steps. * * The flow emits `operation_started` / `operation_completed` around the * unknown-duration calls (gcloud spawns, API calls) so the detail bar can * show a fixed `working…