mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 09:01:14 +00:00
example: add desktop notification extension (OSC 777) (#658)
This commit is contained in:
parent
175a137d00
commit
424597d558
1 changed files with 25 additions and 0 deletions
25
packages/coding-agent/examples/extensions/notify.ts
Normal file
25
packages/coding-agent/examples/extensions/notify.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Desktop Notification Extension
|
||||
*
|
||||
* Sends a native desktop notification when the agent finishes and is waiting for input.
|
||||
* Uses OSC 777 escape sequence - no external dependencies.
|
||||
*
|
||||
* Supported terminals: Ghostty, iTerm2, WezTerm, rxvt-unicode
|
||||
* Not supported: Kitty (uses OSC 99), Terminal.app, Windows Terminal, Alacritty
|
||||
*/
|
||||
|
||||
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
/**
|
||||
* Send a desktop notification via OSC 777 escape sequence.
|
||||
*/
|
||||
function notify(title: string, body: string): void {
|
||||
// OSC 777 format: ESC ] 777 ; notify ; title ; body BEL
|
||||
process.stdout.write(`\x1b]777;notify;${title};${body}\x07`);
|
||||
}
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
pi.on("agent_end", async () => {
|
||||
notify("Pi", "Ready for input");
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue