/** * Harness service — the one engine behind both setup front ends. * * The REST API (`/api/harness`, used by the web setup page) and the `crewly` * CLI (`crewly onboard`, `crewly login`, `crewly harness`) both call this * facade, so detection, install, orc choice and login behave identically. * The backend uses the process-wide {@link getHarnessService}; the CLI builds * its own instance with {@link createHarnessService} (silent logger, no * backend running required). * * @module services/harness/harness.service */ import { HarnessApiKeyService } from './harness-api-key.service.js'; import { HarnessInstallService } from './harness-install.service.js'; import { HarnessStatusService } from './harness-status.service.js'; import { type HarnessId, type HarnessLogger, type HarnessOverview, type HarnessStatus, type ReloginPending, type InstallJob, type LoginSession } from './harness.types.js'; import { LoginBrokerService } from './login-broker.service.js'; import { OrcHarnessStore, type DefaultRuntimeUpdater } from './orc-harness.store.js'; /** Error for an id that is not a harness (REST: 404). */ export declare class UnknownHarnessError extends Error { readonly id: string; /** * @param id - The id that was asked for */ constructor(id: string); } /** Parts of the service (each injectable for tests). */ export interface HarnessServiceParts { status: HarnessStatusService; install: HarnessInstallService; broker: LoginBrokerService; apiKeys: HarnessApiKeyService; orc: OrcHarnessStore; } /** Facade over status, install, orc choice, broker login and API-key login. */ export declare class HarnessService { readonly status: HarnessStatusService; readonly install: HarnessInstallService; readonly broker: LoginBrokerService; readonly apiKeys: HarnessApiKeyService; readonly orc: OrcHarnessStore; /** Pending Slack re-login per harness (set by the backend's re-login coordinator; the CLI has none) */ private reloginPendingProvider; /** * @param parts - Service parts */ constructor(parts: HarnessServiceParts); /** * Validate a harness id. * * @param id - Candidate * @returns The id, typed * @throws UnknownHarnessError for an unknown id */ requireHarnessId(id: string): HarnessId; /** * Everything the setup screen needs. * * @returns Harness statuses, the orc harness and system tools */ getOverview(): Promise; /** * Provide the pending-re-login lookup shown in {@link getOverview}. * * @param provider - Lookup, or null to clear */ setReloginPendingProvider(provider: ((harnessId: HarnessId) => ReloginPending | null) | null): void; /** * The pending Slack re-login for a harness. * * @param harnessId - Harness id * @returns The pending re-login, or null (also when no provider is set or it throws) */ getReloginPending(harnessId: HarnessId): ReloginPending | null; /** * Status of one harness. * * @param id - Harness id * @returns The status * @throws UnknownHarnessError for an unknown id */ getStatus(id: string): Promise; /** * Start installing (or updating) a harness. * * @param id - Harness id * @returns The install job * @throws UnknownHarnessError for an unknown id */ startInstall(id: string): InstallJob; /** * Read an install job. * * @param jobId - Job id * @returns The job * @throws HarnessInstallError job_not_found */ getInstallJob(jobId: string): InstallJob; /** * Set the orchestrator's harness. * * @param id - Harness id * @returns The recorded harness id * @throws UnknownHarnessError for an unknown id */ setOrcHarness(id: string): Promise; /** * Start a broker login. * * @param id - Harness id * @param method - Broker login method * @returns The login session * @throws UnknownHarnessError | LoginBrokerError */ startLogin(id: string, method: string): LoginSession; /** * Store an API key for a harness and return its fresh status. * * @param id - Harness id * @param key - The key (never echoed) * @returns The harness status after login * @throws UnknownHarnessError | HarnessApiKeyError */ submitApiKey(id: string, key: unknown): Promise; } /** Options for {@link createHarnessService}. */ export interface CreateHarnessServiceOptions { logger?: HarnessLogger; /** How `settings.general.defaultRuntime` is updated (the CLI passes a fresh SettingsService) */ updateDefaultRuntime?: DefaultRuntimeUpdater; env?: NodeJS.ProcessEnv; } /** * Build a harness service with real dependencies. * * Codex broker logins are confirmed with `codex login status` through the * status service. * * @param options - Logger, settings updater, env * @returns A new service * * @example * ```ts * const harness = createHarnessService({ logger: SILENT_HARNESS_LOGGER }); * const overview = await harness.getOverview(); * ``` */ export declare function createHarnessService(options?: CreateHarnessServiceOptions): HarnessService; /** * The backend's harness service (logs through LoggerService). * * @returns The singleton */ export declare function getHarnessService(): HarnessService; /** * Replace or clear the backend singleton (tests). * * @param service - Service to use, or null to clear */ export declare function setHarnessServiceForTesting(service: HarnessService | null): void; //# sourceMappingURL=harness.service.d.ts.map