@arvoretech/pi-turn-notification 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # @arvoretech/pi-turn-notification
2
2
 
3
- Pi extension that sends a macOS desktop notification at the end of each agent turn.
3
+ Pi extension that sends a native desktop notification at the end of each agent turn.
4
4
 
5
- Uses `osascript` to trigger native macOS notifications with the "Glass" sound.
5
+ Works on macOS and Linux:
6
+
7
+ - **macOS**: uses `osascript` to trigger native notifications with the "Glass" sound.
8
+ - **Linux**: uses `notify-send` (libnotify) for the notification, and plays a sound via `canberra-gtk-play` or `paplay` when available.
9
+
10
+ On Linux, make sure `libnotify` is installed (`notify-send` binary). The sound is best-effort and silently skipped if no player is available.
6
11
 
7
12
  ## Install
8
13
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAsBpE,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAIzE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAoDpE,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAIzE"}
package/dist/index.js CHANGED
@@ -1,10 +1,39 @@
1
1
  import { execFile } from "node:child_process";
2
+ import { platform } from "node:os";
2
3
  const TITLE = "Pi";
3
4
  const MAX_BODY_LEN = 100;
5
+ function notifyMac(body) {
6
+ const script = `display notification "${body.replace(/"/g, '\\"')}" with title "${TITLE}" sound name "Glass"`;
7
+ execFile("osascript", ["-e", script], () => { });
8
+ }
9
+ function notifyLinux(body) {
10
+ execFile("notify-send", ["--app-name=Pi", TITLE, body], () => { });
11
+ playLinuxSound();
12
+ }
13
+ const LINUX_SOUNDS = [
14
+ ["canberra-gtk-play", ["--id=message"]],
15
+ ["paplay", ["/usr/share/sounds/freedesktop/stereo/message.oga"]],
16
+ ];
17
+ function playLinuxSound(index = 0) {
18
+ const candidate = LINUX_SOUNDS[index];
19
+ if (!candidate)
20
+ return;
21
+ const [cmd, args] = candidate;
22
+ execFile(cmd, args, (error) => {
23
+ if (error)
24
+ playLinuxSound(index + 1);
25
+ });
26
+ }
4
27
  function notify(body) {
5
28
  const truncated = body.length > MAX_BODY_LEN ? `${body.slice(0, MAX_BODY_LEN)}…` : body;
6
- const script = `display notification "${truncated.replace(/"/g, '\\"')}" with title "${TITLE}" sound name "Glass"`;
7
- execFile("osascript", ["-e", script], () => { });
29
+ if (platform() === "darwin") {
30
+ notifyMac(truncated);
31
+ return;
32
+ }
33
+ if (platform() === "linux") {
34
+ notifyLinux(truncated);
35
+ return;
36
+ }
8
37
  }
9
38
  function extractText(messages) {
10
39
  const last = [...messages].reverse().find((m) => m.role === "assistant");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,MAAM,KAAK,GAAG,IAAI,CAAC;AACnB,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,SAAS,MAAM,CAAC,IAAY;IAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACxF,MAAM,MAAM,GAAG,yBAAyB,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,iBAAiB,KAAK,sBAAsB,CAAC;IACnH,QAAQ,CAAC,WAA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vB,OAAO;IACT,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,QAAoF;IACvG,MAAM,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;IACzE,IAAI,CAAC,IAAI,EAAE,OAAO;QAAE,OAAO,MAAM,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO;SACtB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC;SACtD,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAK,CAAC;SAC3B,IAAI,CAAC,GAAG,CAAC;SACT,IAAI,EAAE,CAAC;IACV,OAAO,IAAI,IAAI,MAAM,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,GAAiB;IACjE,GAAG,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAClC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,QAAe,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,18 +1,13 @@
1
1
  {
2
2
  "name": "@arvoretech/pi-turn-notification",
3
- "version": "1.0.0",
4
- "description": "PI extension that sends a macOS desktop notification at the end of each agent turn",
3
+ "version": "1.1.0",
4
+ "description": "PI extension that sends a native desktop notification at the end of each agent turn (macOS and Linux)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
- "scripts": {
12
- "build": "tsc",
13
- "dev": "tsc --watch",
14
- "lint": "tsc --noEmit"
15
- },
16
11
  "peerDependencies": {
17
12
  "@earendil-works/pi-coding-agent": ">=0.74.0"
18
13
  },
@@ -30,7 +25,8 @@
30
25
  "pi",
31
26
  "extension",
32
27
  "notification",
33
- "macos"
28
+ "macos",
29
+ "linux"
34
30
  ],
35
31
  "repository": {
36
32
  "type": "git",
@@ -38,5 +34,10 @@
38
34
  "directory": "packages/turn-notification"
39
35
  },
40
36
  "author": "Arvore",
41
- "license": "MIT"
42
- }
37
+ "license": "MIT",
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "dev": "tsc --watch",
41
+ "lint": "tsc --noEmit"
42
+ }
43
+ }