/** * CLEO Goal runtime (`@cleocode/goal`, bin `cleo-goal`, alias `ocg`): health * and per-project registration. * * CLEO Goal is a standalone package CLEO talks to only through its bin * (T13791 owner decisions). CLEO works fully without it: every function here * reports absence instead of throwing. * * Bin contracts used here: `cleo-goal --version`, `cleo-goal status --json` * and `cleo-goal install --project --json` (idempotent, project-local * `.opencode/opencode.json`, never user-global). JSON shapes live in * `@cleocode/contracts/goal-runtime.js`; an unknown `schemaVersion` is refused. * * @task T13819 * @task T13820 * @task T13821 * @epic T13791 */ import type { EngineResult, HeavyHookDeliveryOutcome } from '@cleocode/contracts'; import { type GoalRuntimeInstall, type GoalRuntimeStatus } from '@cleocode/contracts/goal-runtime.js'; /** The npm package that ships the CLEO Goal runtime. */ export declare const GOAL_PACKAGE = "@cleocode/goal"; /** Bin names CLEO Goal installs, primary first (`ocg` = "open cleo goal"). */ export declare const GOAL_BINS: readonly ["cleo-goal", "ocg"]; /** Install command shown in remedies (the fix of every `E_GOAL_RUNTIME_MISSING`). */ export declare const GOAL_INSTALL_COMMAND = "npm i -g @cleocode/goal@latest"; /** Harnesses `cleo goal install` accepts, in rollout order (owner decision). */ export declare const GOAL_HARNESSES: readonly ["opencode", "claude", "codex", "hermes", "kimi"]; /** One of {@link GOAL_HARNESSES}. */ export type GoalHarness = (typeof GOAL_HARNESSES)[number]; /** Environment the bin lookup and spawns use (tests pass a fake `PATH`). */ type Env = Readonly>; /** What {@link inspectGoalRuntime} found. */ export interface GoalRuntimeHealth { /** Absolute path of the resolved bin, or `null` when neither bin is on PATH. */ readonly bin: string | null; /** An `ocg` on PATH that is not CLEO Goal (another tool's bin), else `null`. */ readonly foreign: string | null; /** Semver from `cleo-goal --version`, or `null` when absent or it failed. */ readonly version: string | null; /** Latest version on npm; `null` unless `checkUpdates`, or when unpublished, not found or offline. */ readonly latest: string | null; /** `true` when both versions are known and differ. */ readonly updateAvailable: boolean; } /** * Locate the CLEO Goal bin on PATH without running anything: `cleo-goal`, * else `ocg` only when it belongs to {@link GOAL_PACKAGE} (`ocg` is a short * name another tool may own). * * @param env - environment whose `PATH` is searched (default `process.env`) * @returns the bin, and a foreign `ocg` that was skipped */ export declare function locateGoalBin(env?: Env): { readonly bin: string | null; readonly foreign: string | null; }; /** * Resolve the CLEO Goal bin on PATH: `cleo-goal`, then an `ocg` that belongs * to {@link GOAL_PACKAGE}. Synchronous and spawn-free. * * @param env - environment whose `PATH` is searched (default `process.env`) * @returns the absolute bin path, or `null` */ export declare function resolveGoalBin(env?: Env): string | null; /** * The Stop dispatcher's tick command line for the resolved bin * (` tick`, shell-quoted), or `null` when CLEO Goal is not installed. * * @param env - environment whose `PATH` is searched (default `process.env`) * @returns the command line, or `null` */ export declare function goalTickCommand(env?: Env): string | null; /** * Inspect the installed CLEO Goal runtime. Local only by default: the npm * lookup runs only with `checkUpdates` (no network otherwise). Never throws; * an unpublished package or no network leaves `latest` null. * * @param env - environment for the bin lookup and spawns (default `process.env`) * @param options - `checkUpdates` asks npm for the latest version * @returns installed path, version, npm latest and whether an update exists */ export declare function inspectGoalRuntime(env?: Env, options?: { readonly checkUpdates?: boolean; }): GoalRuntimeHealth; /** * Read the live goal through `cleo-goal status --json` in the project. A * project with no goal is a success with `status: 'none'`. * * @param projectRoot - absolute project root (the bin's cwd) * @param env - environment for the bin lookup and spawn (default `process.env`) * @param timeoutMs - deadline for the bin (default 15 s; `cleo doctor` passes 2 s) * @returns the status shape, or a failure (`E_GOAL_RUNTIME_MISSING`, * `E_GOAL_RUNTIME_SCHEMA`, `E_GOAL_RUNTIME_USAGE`, `E_GOAL_RUNTIME_TIMEOUT`, * `E_GOAL_RUNTIME_FAILED`) */ export declare function readGoalStatus(projectRoot: string, env?: Env, timeoutMs?: number): EngineResult; /** Result of {@link installGoalForHarness}. */ export interface GoalInstallResult { /** The harness registered. */ readonly harness: GoalHarness; /** The CLEO Goal bin used. */ readonly bin: string; /** `opencode`: the `cleo-goal install --project --json` reply. */ readonly goal?: GoalRuntimeInstall; /** `claude` / `codex`: the project Stop dispatcher outcome. */ readonly delivery?: HeavyHookDeliveryOutcome; } /** * Register CLEO Goal with one harness for this project. Writes only * project-level config, never `~/.claude`, `~/.codex` or `~/.config`. * * - `opencode`: runs `cleo-goal install --project --json` in the project * (`--dry-run` passes through: the bin reports the planned action, writes nothing). * - `claude` / `codex`: installs only the project Stop dispatcher (`cleo hook * stop`, T13796), which runs the goal tick, whatever the heavy-command mode; * no separate Stop hook and no `PreToolUse` hook. * - `hermes` / `kimi`: `E_NOT_IMPLEMENTED` until the pilot (T13822). * * @param projectRoot - absolute project root * @param harness - harness to register with * @param env - environment for the bin lookup and spawn (default `process.env`) * @param options - `dryRun` previews without writing (opencode only, T13869) * @returns the registration result, or a failure with a remedy */ export declare function installGoalForHarness(projectRoot: string, harness: string, env?: Env, options?: { readonly dryRun?: boolean; }): Promise>; export {}; //# sourceMappingURL=runtime.d.ts.map