import type { Finding } from './patterns'; import type { StreamMessage } from '../controlplane/types'; export type { Finding }; export interface EscalationSummary { exists: boolean; id: string | null; status: string | null; signal_key: string | null; role: string | null; type: string | null; created_at: string | null; } export interface StreamSummary { worker_total: number; engine_total: number; dead_lettered: number; pending: number; in_flight: number; } /** A large string field replaced with a bounded summary instead of the full payload. */ export interface TruncatedString { bytes: number; preview: string; truncated: true; } /** Pointer to the stream browser for the raw, untruncated message payloads. */ export interface RawMessagesHint { hint: string; jid: string; } /** A stream message whose large `message` payload may have been summarized. */ export type SummarizedStreamMessage = Omit & { message: string | TruncatedString; }; export interface JobDiagnosis { workflow_id: string; app_id: string; status: 'running' | 'completed' | 'failed' | 'not_found'; /** * Milliseconds since the last execution event. NOT a fault signal on its own — * a workflow can sit at a condition()/waitFor()/sleepFor() for days legitimately. * Read `findings` for the actual interpretation. */ idle_for_ms: number | null; workflow_type: string | null; last_event_at: string | null; stream_summary: StreamSummary; escalation: EscalationSummary; findings: Finding[]; /** Total events before any cap was applied (execution_events may be truncated to the most recent `maxEvents`). */ total_events: number; events_truncated: boolean; /** * Full event timeline — present only when `include` contains `'events'` (or * `verbosity: 'full'`). Large string attributes are summarized to * `{ bytes, preview, truncated }`. Omitted by default to keep the verdict compact. */ execution_events?: unknown[]; /** * Raw engine + worker stream messages — present only when `include` contains * `'streams'` (or `verbosity: 'full'`). Large `message` payloads are summarized. * Omitted by default; see `raw_messages` for where to fetch the full payloads. */ stream_messages?: { worker: SummarizedStreamMessage[]; engine: SummarizedStreamMessage[]; }; /** Pointer to `list_stream_messages` for the raw payloads (present when streams are omitted). */ raw_messages?: RawMessagesHint; } export type DiagnoseVerbosity = 'summary' | 'full'; export type DiagnoseSection = 'events' | 'streams'; export interface DiagnoseOptions { maxEvents?: number; /** Heavy sections to include in the response. Default: none (verdict only). */ include?: DiagnoseSection[]; /** Shorthand: `'full'` includes both events and streams; `'summary'` (default) includes neither. */ verbosity?: DiagnoseVerbosity; } export declare function diagnoseJob(workflowId: string, appId?: string, options?: DiagnoseOptions): Promise; export declare function findStalledJobs(params: { appId?: string; idleMinutes?: number; workflowType?: string | null; limit?: number; }): Promise<{ jobs: unknown[]; total: number; }>; export declare function findOrphanedSignals(params: { appId?: string; withinHours?: number; limit?: number; }): Promise<{ orphans: unknown[]; total: number; within_hours: number; }>;