import { sendNotification as send } from "./send.ts"; import { detectTerminal } from "./terminal-detect.ts"; import { createRuntime } from "./runtime.ts"; import type { Runtime } from "./runtime.ts"; import type { NotificationInput, TerminalNotification } from "./notify-protocol.ts"; export type { NotificationInput, TerminalNotification } from "./notify-protocol.ts"; export { NotifyProtocol, normalizeNotification } from "./notify-protocol.ts"; export { detectTerminal } from "./terminal-detect.ts"; export { sendNotification } from "./send.ts"; /** Best-effort notification for hosts that do not load the extension entry. */ export function notify(message: NotificationInput): void { send(message); } /** True when this process can attempt a terminal notification; it does not probe daemons. */ export function isAvailable(runtime: Runtime = createRuntime()): boolean { const globalSuppressed = /^(?:off|0|false)$/iu.test(runtime.env.PI_NOTIFICATIONS?.trim() ?? ""); if (!runtime.stdoutIsTTY || globalSuppressed) return false; return Boolean(detectTerminal(runtime.env, undefined, () => runtime.readFileSync("/proc/version"))); }