/** * The terminal notification: one OSC 9 escape per task that ended, written to the * terminal's own stdout. * * The rule from issue #15 is "emit always, let the terminal decide": whether the * terminal is focused cannot be observed, so nothing here tries to guess. A * terminal without notification support ignores an OSC 9 string it does not know * and prints nothing, which is why no external command and no dependency is * needed — the bytes are the entire mechanism. * * Nothing here runs, waits or throws on behalf of a task: a task's ending is * already announced in the session, and this is the extra trace for the terminal * the user may be looking at. * * @author mystery4f <40482524+mystery4f@users.noreply.github.com> */ import type { TaskStatus } from "../tasks/base/task.js"; /** The OSC 9 introducer: `ESC ] 9 ;` starts a terminal notification. */ export declare const OSC9_START = "\u001B]9;"; /** BEL ends an OSC 9 string; the sequence takes no other terminator. */ export declare const STRING_TERMINATOR = "\u0007"; /** * Whole escapes stay under this many bytes. A terminal is free to drop a string * it considers too long, and a name is user text: capping it keeps the escape * recognisable instead of leaving the decision to the terminal's buffer. */ export declare const MAX_NOTIFICATION_BYTES = 200; /** * One escape carrying the task name and its ending: `ESC ] 9 ; BEL`. * * The name is user text, so it is sanitised first: a raw BEL would end the string * early and a raw ESC would start another one. Printable non-ASCII is kept — * task names are written in the user's own language, and a notification without * its name would not say which task ended. */ export declare function terminalNotification(name: string, status: TaskStatus): string; /** Where the escape goes; the default is stdout, but only when it is a terminal. */ export type TerminalWrite = (text: string) => void; export interface TerminalNotificationOptions { /** `PI_PRETTY_TASK_NOTIFY`, already validated into a boolean by Settings. */ readonly enabled: boolean; /** Whether a terminal UI is attached to this session right now. */ readonly attached: () => boolean; /** Test seam: where the bytes go. Defaults to a TTY-checked stdout. */ readonly write?: TerminalWrite; } export interface TerminalNotifications { /** Raise the notification for a task that just ended; silent in every other case. */ finished(name: string, status: TaskStatus): void; } /** * The notifier the extension holds for its whole life. It is silent unless all * three hold: notifications are enabled, a terminal UI is attached, and the task * actually ended. */ export declare function createTerminalNotifications(options: TerminalNotificationOptions): TerminalNotifications;