/** * `cleo cloud status`: the agent's single verification call (cleo-nexus * device contract v2.15, §4.4, E3 `GET /v1/status`, §3.7). * * It reads local facts first (the device credential, the project, its * `.cleo/nexus-link.json` entry, the store's replica id), then asks E3, and * returns `{ verdict, summary, local, remote, warnings }`: * * - no credential: verdict `not-signed-in`, and no network call is made; * - the server's verdict is downgraded to `not-linked` when the current * project has no local link entry or no bound replica; * - unreachable: `E_NEXUS_UNREACHABLE`, its `publicDetails` (the envelope's `error.details`) carrying `local` and a * summary whose remote fields are null ({@link NexusCloudOfflineError}); * - outside a project (or `--project` naming an unknown id) the device and * account parts are still reported and the verdict comes from the device * checks only. * * Every request is a GET. Getting the credential may still upgrade a 9.24 * session (E1) and retry unsettled logouts (E9/E10), as every device-credential * command does (§3.4, §3.5). The replica id is read through * `activeReplica(db, 'project')` on a read-only snapshot handle * (`openCleoDbSnapshot`, no migrations, no pragmas): this command never binds * a replica or writes `cleo.db`. When the store cannot be read that way, * `replicaId` is `null` with `W_NEXUS_REPLICA_UNREADABLE` and the verdict is * `attention`, never `not-linked`: unknown is not unbound. * * A server without E3 (404 `E_NOT_FOUND` on `/v1/status`) gets the same * `NexusStatus` shape composed client-side from E2, E14 and E15 with the * contract's check and verdict rules, plus a `W_NEXUS_STATUS_COMPOSED` * warning. * * TODO(T12905): `cleo cloud status --report` (send presence before E3) is not * implemented here; it is the one write this command will gain. * * @task T12871 * @epic T12323 */ import type { DatabaseSync } from 'node:sqlite'; import type { CloudStatusOfflineDetails, CloudStatusResult, CloudStatusSync, CloudStatusSyncStream, CloudWarning, NexusCloudStatus, NexusCloudStatusCheck } from '@cleocode/contracts'; import { NexusAccountError } from './nexus-auth.js'; import { type NexusCloudConnection, type NexusCloudOptions } from './nexus-cloud.js'; /** Warning: the replica list (who holds the project) could not be read for `cleo cloud status` (T13290). */ export declare const W_NEXUS_STATUS_HOLDERS = "W_NEXUS_STATUS_HOLDERS"; /** Warning: the server has no E3, so the status was composed from E2, E14 and E15. */ export declare const W_NEXUS_STATUS_COMPOSED = "W_NEXUS_STATUS_COMPOSED"; /** Warning: the current project has no `.cleo/nexus-link.json` entry for the origin. */ export declare const W_NEXUS_NOT_LINKED_LOCALLY = "W_NEXUS_NOT_LINKED_LOCALLY"; /** Warning: the current project's store has no bound replica (or none could be read). */ export declare const W_NEXUS_NO_REPLICA = "W_NEXUS_NO_REPLICA"; /** Warning: the store exists but could not be read read-only, so `replicaId` is null. */ export declare const W_NEXUS_REPLICA_UNREADABLE = "W_NEXUS_REPLICA_UNREADABLE"; /** Warning: `--project` names an id the server does not show; only the device was checked. */ export declare const W_NEXUS_PROJECT_UNKNOWN = "W_NEXUS_PROJECT_UNKNOWN"; /** Options for {@link getNexusCloudStatus}. */ export interface NexusCloudStatusOptions extends NexusCloudOptions { /** `--project`: the project to check; defaults to the current project. */ projectId?: string; /** Clock for presence freshness when the status is composed (tests). */ now?: () => Date; } /** * `E_NEXUS_UNREACHABLE` from `cleo cloud status`, carrying the local facts * (§4.4 "Offline"). Holds no secret. */ export declare class NexusCloudOfflineError extends NexusAccountError { /** * Local state, a summary with every remote field null, and the warnings * collected so far. Named `publicDetails`: the CLI forwards only this * explicitly secret-free field into the error envelope. */ readonly publicDetails: CloudStatusOfflineDetails; /** * @param message - Human message. * @param publicDetails - Local state, summary and warnings. * @param fix - Remedy. */ constructor(message: string, publicDetails: CloudStatusOfflineDetails, fix?: string); } /** * The verdict of a set of checks (E3 rules, §4.2): the first matching rule wins. * * @param checks - The checks that apply. * @returns `not-registered`, `not-linked`, `attention` or `ok`. */ export declare function nexusStatusVerdict(checks: readonly NexusCloudStatusCheck[]): NexusCloudStatus['verdict']; /** What {@link readNexusLocalReplicaId} learned about the store's replica. */ export interface NexusLocalReplicaRead { /** The active replica id, or `null` (no store, no bound replica, or unreadable). */ readonly replicaId: string | null; /** * `true` when the store exists but could not be read: `replicaId: null` then * means "unknown", not "unbound", so the caller must not conclude not-linked. */ readonly unreadable: boolean; /** `W_NEXUS_REPLICA_UNREADABLE` when `unreadable`. */ readonly warning: CloudWarning | null; } /** * The active replica id of a project store, read-only: a snapshot handle with * no migrations and no pragmas, closed before returning. Never binds and never * writes a row. * * SQLite side effect: a read-only open of a WAL-mode store needs the `-wal` * and `-shm` sidecars, and SQLite creates them (empty, owned by the caller) * when they are missing and the directory is writable — the normal case for * a cleanly closed store. The store file itself is never modified. Run as * another user (for example under `sudo`), such sidecars would be left owned * by that user, so when the store has no `-wal` and the directory is not * writable by the caller the open is skipped and the store reported * unreadable instead. * * @param projectRoot - Project root. * @returns The replica id, whether the store was unreadable, and a warning. */ export declare function readNexusLocalReplicaId(projectRoot: string): Promise; /** Warning: a store's sync journal could not be read for `cleo cloud status` (T12998). */ export declare const W_NEXUS_SYNC_UNREADABLE = "W_NEXUS_SYNC_UNREADABLE"; /** * One store's local sync journal for `cleo cloud status` (T12998). Read-only: * never seals, pushes or binds. Every reader returns empty values when its * table is absent, so a store without the journal reports every flag off. * * @param db - The store, opened read-only. * @param scope - Which store it is. * @param stream - Its stream when known locally, else `null`. * @param dbPath - The store file. * @returns The stream's sync block; the server-side fields are unknown, each * with the reason. * * @task T12998 */ export declare function readStoreSyncStream(db: DatabaseSync, scope: 'project' | 'global', stream: string | null, dbPath: string): Promise; /** * The local sync journal of the project and global stores, for * `cleo cloud status` (T12998). Read-only; a store that cannot be read is a * warning, never a failure. * * @param projectRoot - The current project, or `null` outside one. * @param projectStream - The project's stream when its link records one. * @param warnings - Collects `W_NEXUS_SYNC_UNREADABLE`. * @param globalHome - The CLEO home holding the global store. @defaultValue getCleoHome() * @returns The sync block, or `undefined` when neither store exists. * * @task T12998 */ export declare function readCloudSyncStatus(projectRoot: string | null, projectStream: string | null, warnings: CloudWarning[], globalHome?: string): Promise; /** * The `NexusStatus` of E3, composed from E2, E14 and E15 with the contract's * check rules (§4.2 E3), for a server without E3. * * @param conn - Connection. * @param projectId - Project to check, or `null`. * @param replicaId - Replica to check, or `null`. * @param now - Clock for presence freshness. * @returns The composed status. */ export declare function composeNexusStatus(conn: NexusCloudConnection, projectId: string | null, replicaId: string | null, now?: () => Date): Promise; /** * `cleo cloud status [--project ]`. * * @param opts - Project, API URL, stores and test overrides. * @returns The verdict, summary, local and remote facts, and warnings. * @throws {NexusCloudOfflineError} `E_NEXUS_UNREACHABLE` when the server does not answer. * @throws {NexusAccountError} `E_NEXUS_DEVICE_REQUIRED`, `E_NEXUS_ACCOUNT_AMBIGUOUS`, * or a mapped API refusal (§4.0.4). */ export declare function getNexusCloudStatus(opts?: NexusCloudStatusOptions): Promise; //# sourceMappingURL=nexus-cloud-status.d.ts.map