// Types in this file are original to this Pi extension. The behavior they model // is informed by oh-my-pi's MIT-licensed GitHub Actions watcher; see NOTICE.md. export type WatchMode = "run" | "commit"; export type WatchState = "watching" | "completed" | "failed" | "no-runs"; export type WatchOutcome = "pending" | "success" | "failure"; export interface GithubActionsWatchInput { repo?: string; branch?: string; run?: string; tail?: number; background?: boolean; } export type PreparedGithubActionsWatch = | { mode: "run"; repo: string; runId: number; tail: number; watchStartedAt: number; } | { mode: "commit"; repo: string; branch: string; headSha: string; tail: number; watchStartedAt: number; }; export interface RunWatchJobDetails { id: number; name: string; status?: string; conclusion?: string; durationSeconds?: number; url?: string; } export interface RunWatchRunDetails { id: number; workflowName?: string; displayTitle?: string; status?: string; conclusion?: string; branch?: string; headSha?: string; url?: string; jobs: RunWatchJobDetails[]; } export interface FailedLogDetails { runId: number; workflowName?: string; jobId: number; jobName: string; conclusion?: string; tail?: string; available: boolean; } /** Stable renderer-facing payload emitted for every partial and final result. */ export interface RunWatchDetails { schemaVersion: 1; mode: WatchMode; state: WatchState; outcome: WatchOutcome; repo: string; branch?: string; headSha?: string; pollCount: number; note?: string; observedAt: string; runs: RunWatchRunDetails[]; failedLogs: FailedLogDetails[]; artifactPath?: string; } export interface WatchResult { details: RunWatchDetails; summary: string; } export type BackgroundWatchState = "watching" | "stopping"; export type BackgroundWatchTerminalState = "completed" | "cancelled" | "error"; export interface BackgroundWatchSnapshot { watchId: string; targetKey: string; state: BackgroundWatchState; input: GithubActionsWatchInput; startedAt: number; elapsedSeconds: number; latestDetails?: RunWatchDetails; } export interface BackgroundWatchStartDetails { kind: "background-start"; watchId: string; targetKey: string; deduplicated: boolean; } export interface BackgroundWatchFinalEntry { watchId: string; targetKey: string; input: GithubActionsWatchInput; terminalState: BackgroundWatchTerminalState; startedAt: number; settledAt: number; summary: string; details?: RunWatchDetails; error?: string; } /** Process-local event payload emitted once for each non-lifecycle settlement. */ export interface BackgroundWatchSettledEvent extends BackgroundWatchFinalEntry { eventVersion: 1; artifactPath?: string; } export interface CommandResult { stdout: string; stderr: string; code: number; killed?: boolean; } export type CommandRunner = ( command: string, args: string[], options: { cwd: string; signal?: AbortSignal; timeout?: number }, ) => Promise; export interface WatchRuntime { cwd: string; exec: CommandRunner; signal?: AbortSignal; now?: () => number; sleep?: (milliseconds: number, signal?: AbortSignal) => Promise; persistLogs?: (content: string) => Promise; /** Test/configuration overrides; production uses OMP-compatible defaults. */ config?: Partial; } export interface WatchConfig { fastIntervalMs: number; slowIntervalMs: number; fastWindowMs: number; noRunsTimeoutMs: number; failureGraceMs: number; maxPollFailures: number; } export interface GithubJobSnapshot { id: number; name: string; status?: string; conclusion?: string; startedAt?: string; completedAt?: string; url?: string; } export interface GithubRunSnapshot { id: number; workflowName?: string; displayTitle?: string; status?: string; conclusion?: string; branch?: string; headSha?: string; createdAt?: string; updatedAt?: string; url?: string; jobs: GithubJobSnapshot[]; } export interface FailedJobLog { run: GithubRunSnapshot; job: GithubJobSnapshot; full?: string; tail?: string; available: boolean; }