/** * `@cleocode/core/status` — `CleoStatus` snapshot aggregator (T-E3-4). * * Implements the data layer for `cleo status`: aggregates identity, * credentials, config-tier state, session, harness, and sentient-daemon * state into a single typed envelope without performing any network calls * or credential seeding. Read-only; safe to invoke on every CLI tick. * * Spec: `docs/plans/E-CONFIG-AUTH-UNIFY.md` §3.3.6 (`CleoStatus` interface) * and §5.3 T-E3-4 (acceptance criteria). * * Performance contract: `getCleoStatus()` MUST complete in under 2 seconds * on a populated project. Each sub-block guards its dependency with a * try/catch fall-through so a misconfigured subsystem never blocks the * status surface — failures degrade to a sensible default instead. * * @epic T9402 (E-CONFIG-AUTH-UNIFY E3) * @task T9423 (T-E3-4) */ import type { SeederSourceId } from '../llm/credential-seeders/index.js'; import type { StoredAuthType } from '../llm/credentials-store.js'; import type { ModelTransport } from '../llm/types-config.js'; /** * Per-credential row in the {@link CleoStatus.credentials} array. * * Derived from `StoredCredential`: `source` is narrowed to the seeder-source * union (defaults to `'none'` when a credential pre-dates the seeder tagging * introduced in T9408); `isExpired` is computed against `expiresAt`. * * @task T9423 */ export interface CredentialStatusEntry { /** LLM transport the credential authenticates. */ provider: ModelTransport; /** Seeder source that produced the entry, or `'none'` when unknown. */ source: SeederSourceId | 'none'; /** Always `true` when emitted by {@link getCleoStatus} — kept for forward-compat with future "expected provider but no credential" rows. */ hasCredential: boolean; /** Storage-level auth scheme. */ authType?: StoredAuthType; /** Unix epoch ms expiry; `null` or `undefined` when not bound to a TTL. */ expiresAt?: number | null; /** `true` when `expiresAt` is set and has elapsed at status-snapshot time. */ isExpired?: boolean; /** Status of last request through this credential, when observed. */ lastStatus?: 'ok' | 'exhausted' | 'invalid'; /** Human-readable identifier; unique within `provider`. */ label?: string; } /** * Full status envelope returned by {@link getCleoStatus}. * * @task T9423 */ export interface CleoStatus { /** Agent-identity block — `agentId`/`identityFile` are `null` until the operator binds an identity. */ identity: { agentId: string | null; loggedIn: boolean; identityFile: string | null; }; /** Credential-pool snapshot — every entry currently persisted, regardless of provider. */ credentials: CredentialStatusEntry[]; /** Config-tier paths and footgun warnings (secrets-in-project-config). */ config: { globalConfigPath: string; projectConfigPath: string | null; activeConfigPath: string; hasSecretsInProjectConfig: boolean; secretsWarnings: string[]; }; /** Active session, if any. */ session: { active: boolean; sessionId: string | null; focusedTask: string | null; }; /** Detected harness; `'unknown'` when `CLEO_HARNESS` is not set. */ harness: { active: 'pi' | 'claude-code' | 'unknown'; healthy: boolean; issues: string[]; }; /** Sentient-daemon snapshot. */ daemon: { running: boolean; pid: number | null; lastTickAt: number | null; killSwitchActive: boolean; }; } /** * Aggregate the full {@link CleoStatus} snapshot. * * Reads identity, credentials, config-tier state, session, harness, and * sentient-daemon state in parallel and folds them into one envelope. No * network calls; no credential seeding (the pool's `list()` is pure-read). * Sub-blocks degrade independently — a broken session store does not * suppress the credentials block, etc. * * Performance contract (T-E3-4): completes in under 2 seconds on a * populated project. * * @example * ```ts * import { getCleoStatus } from '@cleocode/core/status'; * * const snapshot = await getCleoStatus(); * if (!snapshot.identity.loggedIn) { * console.warn('No CLEO identity bound — run `cleo setup`.'); * } * if (snapshot.config.hasSecretsInProjectConfig) { * for (const w of snapshot.config.secretsWarnings) console.warn(w); * } * ``` * * @returns Fully-populated {@link CleoStatus} envelope. * * @task T9423 */ export declare function getCleoStatus(): Promise; //# sourceMappingURL=index.d.ts.map