A notification when a long task ends
Send an OSC 9 desktop notification on terminals that show one, and print the same message as a line everywhere else — with no native binaries.
A build that takes ten minutes should say when it is done. On iTerm2, WezTerm and Ghostty, OSC 9 raises a desktop notification with no native helper installed; everywhere else the same call prints the message as a line, which is what a CI log wants anyway.
import { emit, processRuntime } from 'paratext';
const started = Date.now();
// … the long task …
const seconds = Math.round((Date.now() - started) / 1000);
process.stdout.write(`${emit(processRuntime(), 'notify', { title: 'Build finished', body: `${seconds}s` })}\n`);Build finished: 0sOn a supporting terminal the line is the notification's bytes instead, and the terminal shows
the notification rather than the text. body is optional: {title}[: {body}] prints the title
alone when there is no body.
Links in help output
Print a clickable command name where the terminal understands OSC 8, and a separate URL column only where it does not, deciding the layout with supportsLink().
Images with captions
Read an image yourself, pass the bytes with a caption, and get an inline image on iTerm2 and the caption in a pipe, a CI log or an agent's transcript.