import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import type { Orckit } from '../orchestrator/orchestrator.js'; import type { ProcessState } from '../orchestrator/lifecycle.js'; import type { OrckitConfig } from '../config/schema.js'; import type { OutputLine } from '../process/output.js'; import { type BuildTracker } from '../process/build-tracker.js'; import { type BuildEvent, type BuildStatus } from '../process/parsers.js'; /** * Minimum surface the tool helpers need from an Orckit. The full `Orckit` * class naturally satisfies this; tests can pass a stub. */ export interface OrckitView { readonly config: OrckitConfig; inspect(name: string): { state: ProcessState; pid: number | null; startedAt: number | null; retries: number; }; states(): Map; output(name: string, n?: number): OutputLine[]; } export interface StatusEntry { name: string; state: ProcessState; pid: number | null; startedAt: number | null; uptimeMs: number | null; retries: number; manualRetry: boolean; } export interface ErrorEntry { name: string; state: ProcessState; lastError: string | null; recentStderr: { timestamp: number; text: string; }[]; } export interface LogsResult { name: string; state: ProcessState; lines: { timestamp: number; stream: 'stdout' | 'stderr'; text: string; }[]; } export interface BuildStatusEntry { name: string; state: ProcessState; /** False when the process's `type` has no build parser — `build` is always null then. */ tracked: boolean; /** Current reduced build status, or null if no build event has been seen yet. */ build: BuildStatus | null; /** Diagnostic lines from the latest failing build (empty unless `build.phase === 'failed'`). */ diagnostics: string[]; } export interface WaitForBuildResult extends BuildStatusEntry { /** True if the call blocked waiting for the build to settle (vs. returning a state it found). */ waited: boolean; /** True if the timeout elapsed before the build settled — `build` is the last-seen state. */ timedOut: boolean; } export declare function buildStatus(orckit: OrckitView): StatusEntry[]; export declare function buildErrors(orckit: OrckitView, lastErrors: Map): ErrorEntry[]; export declare function buildLogs(orckit: OrckitView, args: { name: string; lines?: number; stream?: 'stdout' | 'stderr' | 'all'; }): LogsResult; export declare function formatStatusText(entries: StatusEntry[]): string; export declare function formatErrorsText(entries: ErrorEntry[]): string; export declare function formatLogsText(result: LogsResult): string; /** Default and ceiling for `wait_for_build`'s timeout. */ export declare const DEFAULT_WAIT_TIMEOUT_MS = 60000; export declare const MAX_WAIT_TIMEOUT_MS = 600000; export declare function buildBuildStatus(orckit: OrckitView, tracker: BuildTracker, name: string): BuildStatusEntry; /** * Build status for one process (when `name` is given) or for every process that * has a build parser / has emitted a build event. */ export declare function buildBuildStatuses(orckit: OrckitView, tracker: BuildTracker, name?: string): BuildStatusEntry[]; /** Minimal event surface `waitForBuild` subscribes to. The full Orckit satisfies it. */ export interface BuildEventSource { on(event: 'process:build', listener: (name: string, event: BuildEvent) => void): unknown; off(event: 'process:build', listener: (name: string, event: BuildEvent) => void): unknown; } /** * Block until the named process's build settles, then return its outcome. * * - Already settled (`done`/`failed`) or untracked (no build parser): returns * immediately, `waited: false`. * - In progress: waits for a `build:complete`, or for a quiet period after the * last `build:failed` diagnostic, whichever comes first. * - Timeout elapses first: returns the last-seen state with `timedOut: true`. * * Caveat (stale-success race): if the caller edits a file then calls this before * the watcher's `build:start` has been parsed, the previous cycle's `done` is * still current and is returned immediately. Poll `get_build_status` until the * phase flips to `building` first if that matters. */ export declare function waitForBuild(orckit: OrckitView, source: BuildEventSource, tracker: BuildTracker, args: { name: string; timeoutMs?: number; }): Promise; export declare function formatBuildStatusText(entries: BuildStatusEntry[]): string; export declare function formatWaitForBuildText(result: WaitForBuildResult): string; export declare function registerTools(server: McpServer, orckit: Orckit, lastErrors: Map, tracker: BuildTracker): void; //# sourceMappingURL=tools.d.ts.map