/** * Programmatic daemon lifecycle (change: extend-api-for-supervising-hosts). * * A supervising host holds one OpenLore daemon per working tree and releases it at shutdown. Today * that means spawning the CLI binary and managing a PID — in a single-file distribution, an extra * re-entry path built solely to exec that binary. This makes the daemon a call that returns a * handle the host closes. * * Two properties separate this from a wrapper over the CLI entry point: * * 1. It never touches the host's process. `runServe` returns every outcome as a value, so a * refusal — static configuration OR a runtime one such as lock contention or a posture * mismatch — is thrown, never logged-and-exited. A library that set the exit code of a process * it does not own would already have failed the contract by the time it threw. * 2. A handle says whether closing it stops anything. The CLI's reuse path deliberately returns a * no-op `close()` — "never tear down a daemon this process didn't start" — and passing that * off as an owned handle would let a host believe it released a daemon that is still live. * So the default here is to REFUSE an already-running daemon and name it; adopting one is an * explicit opt-in that yields `owned: false`. */ import { type ServeHandle } from '../cli/commands/serve.js'; import { OpenLoreError } from '../utils/errors.js'; import type { BaseOptions } from './types.js'; /** Thrown by {@link openloreServe} when a compatible daemon already serves the working tree. */ export declare class ServeAlreadyRunningError extends OpenLoreError { readonly host: string; readonly port: number; readonly baseUrl: string; constructor(host: string, port: number, baseUrl: string); } export interface ServeApiOptions extends BaseOptions { /** Bind host. Default 127.0.0.1. A non-loopback bind without a token is refused. */ host?: string; /** Bind port as a number; 0 requests an ephemeral port, reported back on the handle. */ port?: number; /** Shared secret required on every tool request. Generated when omitted. */ token?: string; /** Tool surface to advertise. Default: the lean serve preset. */ preset?: string; /** false disables the freshness watcher and its re-analyze lane. Default true. */ watch?: boolean; /** Idle milliseconds before the daemon self-terminates. 0 disables. Default: the CLI default. */ idleTimeoutMs?: number; /** * What to do when a compatible daemon already serves this tree. * `'reject'` (default) throws {@link ServeAlreadyRunningError} and returns no handle. * `'adopt'` returns a handle with `owned: false` whose `close()` detaches without stopping it. */ ifRunning?: 'reject' | 'adopt'; } /** * Start (or deliberately adopt) the local daemon for a working tree. * * Resolves to a live handle, or throws. It never writes to the console, never sets * `process.exitCode`, and never returns undefined to signal failure. */ export declare function openloreServe(options?: ServeApiOptions): Promise; export type { ServeHandle }; //# sourceMappingURL=serve.d.ts.map