pi-telegram-notifier 0.1.0 → 0.1.1
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 +8 -9
- package/package.json +1 -1
- package/src/notification.js +2 -1
package/README.md
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
# pi-telegram-notifier
|
|
2
2
|
|
|
3
|
-
Send the **final** response of each Pi agent run to a paired private Telegram chat. Each notification contains a UTC timestamp, provider, full response text, and the **actual** remaining provider balance when it can be queried. Telegram metadata (provider and quota) is in English; the agent's response is forwarded verbatim in its original language. Intermediate tool calls do not trigger messages.
|
|
3
|
+
Send the **final** response of each Pi agent run to a paired private Telegram chat. Each notification contains a UTC timestamp, device hostname, provider, full response text, and the **actual** remaining provider balance when it can be queried. Telegram metadata (provider and quota) is in English; the agent's response is forwarded verbatim in its original language. Intermediate tool calls do not trigger messages.
|
|
4
4
|
|
|
5
5
|
## Install and configure
|
|
6
6
|
|
|
7
|
-
Requires Node.js 22.19+ and [Pi](https://pi.dev).
|
|
7
|
+
Requires Node.js 22.19+ and [Pi](https://pi.dev). Install the published package, create a Telegram bot using [@BotFather](https://t.me/BotFather), and set its token **outside the repository** before starting Pi:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
+
pi install npm:pi-telegram-notifier
|
|
10
11
|
export PI_TELEGRAM_BOT_TOKEN='your-bot-token'
|
|
11
|
-
pi
|
|
12
|
-
# Later, after public release: pi install npm:pi-telegram-notifier
|
|
13
|
-
# Or: pi install git:github.com/Gybra/pi-telegram-notifier
|
|
12
|
+
pi
|
|
14
13
|
```
|
|
15
14
|
|
|
16
|
-
In Pi run `/telegram-pair`. Within five minutes send **`/start <code>`** to your bot in a private Telegram chat using the displayed one-time code. The extension stores only the numeric chat ID in `~/.pi/agent/pi-telegram-notifier.json` (or `$PI_CODING_AGENT_DIR/pi-telegram-notifier.json`), with mode 0600. To switch chats, run `/telegram-pair` again; the existing chat stays paired if pairing fails. The bot needs to receive messages via `getUpdates` during pairing: a webhook or another updates consumer must be disconnected first. There is no always-on polling after pairing.
|
|
15
|
+
If Pi is already running, run `/reload` after installing the package (restart Pi if you just set the token). If you previously installed a local checkout, run `pi list`, then `pi remove /absolute/path/to/pi-telegram-notifier` to avoid loading both copies. To get future releases, run `pi update npm:pi-telegram-notifier`. In Pi run `/telegram-pair`. Within five minutes send **`/start <code>`** to your bot in a private Telegram chat using the displayed one-time code. The extension stores only the numeric chat ID in `~/.pi/agent/pi-telegram-notifier.json` (or `$PI_CODING_AGENT_DIR/pi-telegram-notifier.json`), with mode 0600. To switch chats, run `/telegram-pair` again; the existing chat stays paired if pairing fails. The bot needs to receive messages via `getUpdates` during pairing: a webhook or another updates consumer must be disconnected first. There is no always-on polling after pairing.
|
|
17
16
|
|
|
18
|
-
**Privacy:** final agent responses are sent
|
|
17
|
+
**Privacy:** final agent responses and the device hostname are sent to Telegram. Responses can contain sensitive text; only use this package if that is acceptable for your projects and Telegram chat. Bot and provider tokens are not stored in the package or sent as message text. Telegram Bot API uses the bot token in the request URL; do not log outgoing URLs. Keep your shell environment and Pi credentials private. A lost or compromised Telegram bot token must be revoked with BotFather.
|
|
19
18
|
|
|
20
19
|
## Quota coverage
|
|
21
20
|
|
|
@@ -44,7 +43,7 @@ Telegram has a message-length limit; long responses are delivered in consecutive
|
|
|
44
43
|
```sh
|
|
45
44
|
npm test
|
|
46
45
|
npm pack --dry-run --json
|
|
47
|
-
pi -e . --help
|
|
46
|
+
pi --no-extensions -e . --help
|
|
48
47
|
```
|
|
49
48
|
|
|
50
|
-
Read [AGENTS.md](AGENTS.md) before editing. Open contributions with tests for behavior changes and official provider documentation for balance integrations. MIT licensed; see [LICENSE](LICENSE). CI runs tests and packaging checks.
|
|
49
|
+
Read [AGENTS.md](AGENTS.md) before editing. Open contributions with tests for behavior changes and official provider documentation for balance integrations. MIT licensed; see [LICENSE](LICENSE). CI runs tests and packaging checks. The published npm package includes the `pi-package` keyword for the [Pi package gallery](https://pi.dev/packages). New versions are released manually; CI does not publish packages or handle real credentials.
|
package/package.json
CHANGED
package/src/notification.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hostname } from 'node:os';
|
|
1
2
|
import { loadChatId, sendTelegram } from './telegram.js';
|
|
2
3
|
import { getQuota } from './quota.js';
|
|
3
4
|
|
|
@@ -12,7 +13,7 @@ export function finalResponse(branch, startLeafId) {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export function formatNotification(timestamp, response, quota) {
|
|
15
|
-
return `${timestamp}\nProvider: ${response.provider}\n${quota}\n\n${response.text}`;
|
|
16
|
+
return `${timestamp}\nDevice: ${hostname()}\nProvider: ${response.provider}\n${quota}\n\n${response.text}`;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export function registerNotifications(pi, agentDir, token, fetchImpl = fetch) {
|