/** * The completion notice: one session message per finished task, so a task that * ends finds the user instead of waiting to be polled. * * The message is sent as a follow-up with `triggerTurn`, so it reaches the * transcript through the normal delivery path and the model can act on it. * Everything the notice says lives in `details`; the renderer draws those * facts and never parses the prose. * * @author mystery4f <40482524+mystery4f@users.noreply.github.com> */ import type { MessageRenderer } from "@earendil-works/pi-coding-agent"; import type { TaskKind, TaskStatus } from "../tasks/base/task.js"; import type { ProcessTaskView } from "../tasks/process/process-tasks.js"; /** Custom message type the completion renderer is registered under. */ export declare const TASK_FINISHED_CUSTOM_TYPE = "task-finished"; /** * Trailing output lines quoted in a notice. Deliberately fewer than the panel's * detail view (#10): a scrollback message should read at a glance. */ export declare const NOTICE_OUTPUT_LINES = 8; /** What a completion notice carries, whatever kind of task ended. */ export interface FinishedTaskDetails { readonly id: string; readonly name: string; readonly kind: TaskKind; readonly status: TaskStatus; /** Milliseconds from start to end. */ readonly durationMs: number; /** Process tasks: the exit code, or null when a signal ended the task. */ readonly exitCode?: number | null; /** Why the task ended abnormally, when the record knows: a kill or a failure. */ readonly reason?: string; /** Process tasks: the trailing output the notice quotes. */ readonly outputTail?: string; /** True when older output was left out of the tail. */ readonly outputTruncated?: boolean; } /** The message body a notice sends: facts, plus the same facts as prose. */ export interface FinishedTaskMessage { readonly content: string; readonly details: FinishedTaskDetails; } /** Build the notice for one finished task. Pure, so tests can drive any status. */ export declare function finishedTaskMessage(details: FinishedTaskDetails): FinishedTaskMessage; /** * The session slot a notice goes through. The extension hands over its live * session's send, because the `pi` object an instance was loaded with is * invalidated when that session is replaced or reloaded: `sendMessage` from the * old instance throws, and nothing awaits a notice, so the throw ended the pi * process. Keeping the slot behind one seam leaves session lifetime in one place. */ export type NoticeSender = (notice: SessionNotice) => void; /** The body of one notice: what pi records, with the delivery options left out. */ export interface SessionNotice { readonly customType: string; readonly content: string; readonly details: unknown; } /** Announce one finished task in the session. */ export declare function notifyTaskFinished(send: NoticeSender, view: ProcessTaskView): Promise; /** * Draws one completion notice. Facts come from `details`, colour from the * theme, so this stays readable under any palette and never shows raw JSON. */ export declare const renderTaskFinished: MessageRenderer; /** Custom message type a signalled fire's notice is registered under. */ export declare const LOOP_SIGNAL_CUSTOM_TYPE = "loop-signal"; /** * Leading output lines a signal notice quotes. A check's report opens with its * findings, so the head is the part worth reading; the rest stays in the file. */ export declare const SIGNAL_OUTPUT_LINES = 10; /** What a signal notice carries: the loop, the fire and the head of its report. */ export interface LoopSignalDetails { readonly id: string; readonly name: string; readonly command: string; /** One-based fire number of the loop, the same number the child process carries. */ readonly fire: number; /** The exit code the loop declared as a signal. */ readonly exitCode?: number | null; /** Milliseconds the fire ran. */ readonly durationMs: number; /** Epoch milliseconds the fire ended. */ readonly endedAt: number; /** The fire's own report, first lines only. */ readonly outputHead?: string; /** Lines the fire wrote, so a cut report says how much it left out. */ readonly outputLines?: number; /** Output file of the fire, for the lines the notice does not quote. */ readonly outputPath?: string; } /** * Announce one signalled fire. A signal is the check speaking, not the loop * breaking, so this message carries no failure vocabulary (ADR-0018). */ export declare function notifyLoopSignal(send: NoticeSender, details: LoopSignalDetails): Promise; /** Draws one signal notice: the check's report, never a failure badge. */ export declare const renderLoopSignal: MessageRenderer;