/** * Machine-level workflow overview for remote clients (the hub's * `GET /api/workflow-overview`). * * The per-instance settings routes answer with each BRIDGE's own slice: a * workspace with two bridges (editor + serve) yields two project groups for * the same project, and a bridge only sees the runs of its own cwd — so a * client polling "is anything flying?" against the one instance it happens to * be attached to reads an empty list while another project's run is very much * alive (observed 2026-10-01: the management page double-listed ai-hot-app * and its live-run zone showed nothing). Every part of that story is * machine-level data: * * - the dwf journal (run history) is ONE sqlite store shared by every backend * process — any bridge's `workflows/runs?scope=global` read (no cwd filter) * answers for the whole machine, each row carrying its own `cwd`; * - the saved-workflow FILES are per workspace, so the project list needs one * bridge per workspace — but every bridge of that workspace reads the same * directory, so ONE representative suffices; * - the global saved-workflow directory is machine-wide, so one global group * is enough; * - and a journal row can LIE about a living run: upstream's orphan * reconciliation writes stopped(interrupted) onto runs that are still * executing in another process (and the row never flips back mid-run), so * rows carrying that signature are cross-checked against the owning * process's live read before the overview trusts them (collectLiveOverrides). * * This module folds all of that server-side (the hub owns the instance map): * dedupe instances to one group per workspace, race the pair reads with the * freshest-started bridge preferred (an old long-lived bridge may predate the * workflow routes — fall back to a sibling that answers), and answer with a * ready-to-render list plus the machine-wide `activeRuns` (journal rows with * status pending/running, annotated with the instance that currently lists * their session so the client can address stop/resume correctly) and * `recentRuns` (the finished complement — the top-level completion list's * feed). * * Everything is best-effort per group: a failing workspace degrades to an * `error` group (the list must not blank out because one bridge is down), * and the whole call only rejects on a structural bug. */ import type { WorkflowScope } from "../settings/workflow.js"; /** The instance facts this module needs from the hub's registry. */ export interface OverviewInstance { id: string; port: number; workspace: string; startedAt: number; sessions: Array<{ sessionId: string; status?: "running" | "idle"; updatedAt?: number; }>; } /** A journal run row (the bridge's `workflows/runs` shape, passthrough). */ export interface OverviewRunRow { runId?: string; name?: string; status?: string; updatedAt?: number; acpSessionId?: string; /** Injected here: the instance whose live session list holds this run. */ ownerInstanceId?: string; [key: string]: unknown; } /** One list group — shape-compatible with the client's existing group model. */ export interface OverviewGroup { instanceId: string; scope: WorkflowScope; workspace: string; workflows: unknown[]; invalid: unknown[]; lastRuns: Record; error: string | null; } export interface WorkflowOverview { ok: true; groups: OverviewGroup[]; activeRuns: OverviewRunRow[]; /** * Recently finished runs (terminal statuses only, newest first, capped) — * the same machine-wide journal read activeRuns feeds, minus the live rows. * The completion list's home: without it a settled run only resurfaces two * taps deep (workflow card → per-name history). */ recentRuns: OverviewRunRow[]; } /** * Build the machine-level overview from the hub's instance snapshot. * Never throws for bridge-side failures — only for structural bugs. */ export declare function buildWorkflowOverview(instances: OverviewInstance[]): Promise; //# sourceMappingURL=workflow-overview.d.ts.map