@arvoretech/pi-turn-notification 1.0.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 +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @arvoretech/pi-turn-notification
|
|
2
|
+
|
|
3
|
+
Pi extension that sends a macOS desktop notification at the end of each agent turn.
|
|
4
|
+
|
|
5
|
+
Uses `osascript` to trigger native macOS notifications with the "Glass" sound.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @arvoretech/pi-turn-notification
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Add to your `.pi/config.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"extensions": ["@arvoretech/pi-turn-notification"]
|
|
20
|
+
}
|
|
21
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
const TITLE = "Pi";
|
|
3
|
+
const MAX_BODY_LEN = 100;
|
|
4
|
+
function notify(body) {
|
|
5
|
+
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], () => { });
|
|
8
|
+
}
|
|
9
|
+
function extractText(messages) {
|
|
10
|
+
const last = [...messages].reverse().find((m) => m.role === "assistant");
|
|
11
|
+
if (!last?.content)
|
|
12
|
+
return "Done";
|
|
13
|
+
const text = last.content
|
|
14
|
+
.filter((block) => block.type === "text" && block.text)
|
|
15
|
+
.map((block) => block.text)
|
|
16
|
+
.join(" ")
|
|
17
|
+
.trim();
|
|
18
|
+
return text || "Done";
|
|
19
|
+
}
|
|
20
|
+
export default function turnNotificationExtension(api) {
|
|
21
|
+
api.on("agent_end", async (event) => {
|
|
22
|
+
notify(extractText(event.messages));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAClD,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
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
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",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"lint": "tsc --noEmit"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@earendil-works/pi-coding-agent": ">=0.74.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@earendil-works/pi-coding-agent": "latest",
|
|
21
|
+
"@types/node": "^20.10.0",
|
|
22
|
+
"typescript": "^5.3.0"
|
|
23
|
+
},
|
|
24
|
+
"pi": {
|
|
25
|
+
"extensions": [
|
|
26
|
+
"./dist/index.js"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"pi",
|
|
31
|
+
"extension",
|
|
32
|
+
"notification",
|
|
33
|
+
"macos"
|
|
34
|
+
],
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/arvoreeducacao/arvore-pi-extensions.git",
|
|
38
|
+
"directory": "packages/turn-notification"
|
|
39
|
+
},
|
|
40
|
+
"author": "Arvore",
|
|
41
|
+
"license": "MIT"
|
|
42
|
+
}
|