import { type ServerResponse } from "node:http"; import type { ObserverData } from "./observer-data.js"; import { type PreparedRunArtifactPaths } from "./run-paths.js"; import type { LoadedStudyAnalysis } from "./study-analysis.js"; export declare const OBSERVER_SCHEMA = "humanish.observer-result.v1"; export interface ObserverResult { schema: typeof OBSERVER_SCHEMA; ok: boolean; cwd: string; run: string; observerPath?: string; observerDataPath?: string; eventsPath?: string; observerUrl?: string; serverUrl?: string; bundlePath?: string; opened?: boolean; openCommand?: string; warnings: string[]; error?: { code: "HUMANISH_RUN_NOT_FOUND" | "HUMANISH_INVALID_RUN_BUNDLE"; message: string; }; } export interface ObserverOptions { open?: boolean; /** Internal producer pin: refreshing a finished run must not bind a replacement. */ expectedRun?: PreparedRunArtifactPaths; } export interface ObserverServeOptions { open?: boolean; port?: number; /** Restrict history and evidence routes to the selected run. Exposed viewers always do this. */ scope?: "run" | "library"; exposed?: boolean; } export interface ObserverServer { url: string; port: number; opened: boolean; openCommand?: string; warning?: string; addPublicOrigin(origin: string): void; close(): Promise; } export interface ObserverRuntimeStreamUrl { streamId: string; url: string; /** Set when the lane's sandbox is gone (finished or torn down). An ended stream's live URL is a * dead noVNC page — the overlay stops injecting it so the tile falls back to the recorded * evidence (keyframe replay/screenshot) instead of rendering "sandbox not found" (#357). */ ended?: boolean; } /** internal: consumed by observer-serve */ export interface PinnedDirectory { readonly birthtimeNs: bigint; readonly dev: bigint; readonly ino: bigint; readonly physicalPath: string; } export declare function attachObserverRuntimeStreamUrls(result: ObserverResult, streams: ObserverRuntimeStreamUrl[]): void; export declare function renderObserver(cwdInput: string, runInput: string, options?: ObserverOptions): Promise; export declare function serveObserver(result: ObserverResult, options?: ObserverServeOptions): Promise; /** * Resolve — and in a repo checkout, build — the Observer artifact BEFORE any run or * lab work starts. A missing artifact must cost seconds at startup, never a completed * session (a live lane spends real money before the render step would have noticed). * Unconditional on purpose: the artifact is the only renderer now, so the fail-before- * spend property this preflight bought under the flag matters more, not less. */ export declare function preflightObserverArtifact(): void; /** internal: exported for tests. Missing artifact, or any workspace source newer than it. */ export declare function observerArtifactNeedsBuild(workspaceDir: string, artifactPath: string): boolean; /** Portable files store each exact raster once, outside the run-data JSON. */ export type ObserverExportAssets = Record; /** Render current packaged UI around a validated/projected Observer snapshot. */ export declare function renderObserverHtml(data: ObserverData, options?: { snapshot?: boolean; analysis?: LoadedStudyAnalysis; assets?: ObserverExportAssets; }): string; /** internal: consumed by observer-serve */ export declare function serveRunPath(runRoot: PinnedDirectory, relativePath: string, response: ServerResponse, runtimeStreamUrls?: ObserverRuntimeStreamUrl[]): Promise; /** internal: exported for the #357 lifecycle tests (consumed by observer-serve). */ export declare function withRuntimeStreamUrls(data: ObserverData, runtimeStreamUrls: ObserverRuntimeStreamUrl[]): ObserverData; /** internal: consumed by observer-serve */ export declare function buildHistoryIndex(proofRoot: PinnedDirectory): Promise<{ latestRunId: string | null; runs: Array<{ runId: string; createdAt: string | null; mode: string | null; href: string; status: string; runtimeState?: NonNullable["state"]; streamCount: number; estimatedCostUsd: number | null; costRatesAsOf: string | null; costPlaceholder: boolean; }>; }>; /** internal: consumed by observer-serve */ export declare function matchRunRoute(pathname: string): { runId: string; relativePath: string; } | null; /** internal: consumed by observer-serve */ export declare function pinDirectory(directoryInput: string): Promise; /** internal: consumed by observer-serve */ export declare function pinDirectChildDirectory(root: PinnedDirectory, name: string): Promise; export declare function openTarget(target: string): { opened: boolean; command?: string; warning?: string; };