whatsapp-pi 1.0.55 → 1.0.57

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,171 +1,172 @@
1
- <p align="center">
2
- <img src="https://upload.wikimedia.org/wikipedia/commons/6/6b/WhatsApp.svg" alt="WhatsApp Logo" width="100">
3
- </p>
4
-
5
- # WhatsApp-Pi
6
- [![GitHub](https://img.shields.io/badge/github-repo-black.svg?style=flat-square&logo=github)](https://github.com/RaphaCastelloes/whatsapp-pi)
7
-
8
- A WhatsApp integration extension for the **[Pi Coding Agent](https://github.com/mariozechner/pi-coding-agent)**.
9
-
10
- Pi is a powerful agentic AI coding assistant that operates in your terminal. This extension lets you chat and pair-program with your Pi agent through WhatsApp, with message filtering, allowed contacts/groups, recents/history browsing, message detail/reply, group-only binding, and reliable message delivery.
11
-
12
-
13
- ## Features
14
-
15
- - **Manual WhatsApp Connection**: QR code-based authentication with session persistence
16
- - **Allowed Contacts**: Control which phone numbers can interact with Pi
17
- - Add contacts with optional names for easy identification
18
- - View ignored numbers (not yet allowed) and add them when needed
19
- - Manage aliases and print allowed contacts from the menu
20
- - **Allowed Groups**: Control which WhatsApp groups can interact with Pi
21
- - Add group JIDs with optional aliases
22
- - Choose reaction mode per group: **Active** (reply to all allowed group messages) or **Passive** (reply only when mentioned with @)
23
- - Only groups in Allowed Groups are processed by the agent
24
- - **Recents & History**: Browse recent conversations, inspect full message history, and reply from message detail view
25
- - **Reliable Messaging**: Queue-based message sending with retry logic
26
- - **TUI Integration**: Menu-driven interface for managing connections, contacts, and recent chats
27
- - **Group-Only Mode**: Bind the agent to a single WhatsApp group with `--whatsapp-group`
28
- - **Media Support**:
29
- - **Vision Analysis**: Automatically forwards WhatsApp images to Pi for analysis.
30
- - **Audio Transcription**: Transcribes voice notes when Whisper is installed.
31
- - **Document Handling**: Downloads and stores documents (PDF, text) for agent access; PDFs include a bounded text preview when readable.
32
-
33
- ## Prerequisites
34
-
35
- To enable audio transcription features:
36
- ```bash
37
- python -m pip install -U openai-whisper
38
- ```
39
-
40
- PDF documents are parsed locally and do not require extra system utilities.
41
- If a PDF cannot be parsed automatically, it is still saved and forwarded with a clear fallback notice.
42
-
43
- ## Quick Start
44
-
45
- 1. Install the extension:
46
- ```bash
47
- pi install npm:whatsapp-pi
48
- ```
49
-
50
- 2. Start Pi:
51
- ```bash
52
- pi
53
- ```
54
-
55
- 3. Open `/whatsapp` and choose **Connect / Reconnect WhatsApp**.
56
- - QR appears only on first pair or after logoff.
57
-
58
- 4. Add the chat you will use with Pi to **Allowed Contacts** or **Allowed Groups**.
59
-
60
- 5. Send a message from that allowed chat to Pi.
61
- - Pi replies in same thread.
62
- - Use **Recents** only to browse history or reply manually.
63
-
64
- After first pairing, you can start Pi with auto-connect enabled:
65
- ```bash
66
- pi --whatsapp-pi-online
67
- ```
68
-
69
- ## Development / Testing
70
-
71
- If you are developing or testing the extension locally, you can clone the repository from [GitHub](https://github.com/RaphaCastelloes/whatsapp-pi):
72
-
73
- 1. Clone and install dependencies:
74
- ```bash
75
- git clone https://github.com/RaphaCastelloes/whatsapp-pi.git
76
- cd whatsapp-pi
77
- npm install
78
- ```
79
-
80
- 2. Run the extension:
81
- ```bash
82
- pi -e whatsapp-pi.ts
83
- ```
84
-
85
- For verbose mode (shows Baileys trace logs for debugging):
86
- ```bash
87
- pi -e whatsapp-pi.ts --verbose
88
- ```
89
-
90
- To test startup auto-connect locally after you have already paired WhatsApp:
91
- ```bash
92
- pi -e whatsapp-pi.ts --whatsapp-pi-online
93
- ```
94
-
95
- ## How It Works
96
-
97
- - Pi processes **incoming** messages only from allowed contacts or allowed groups.
98
- - **Recents** is history browser, not trigger.
99
- - **Send Message** and `send_wa_message` are outbound only.
100
- - If you message yourself, WhatsApp may show sent/read ticks, but that does not guarantee Pi will treat it as a trigger.
101
-
102
- ## WhatsApp Numbers and JIDs
103
-
104
- - Contacts use phone format in UI: `+5511999999999`
105
- - Internally, contacts map to JIDs like `5511999999999@s.whatsapp.net`
106
- - Groups use JIDs like `120363012345@g.us`
107
- - Recents may show normalized values from WhatsApp, so use **Print Contact** / **Print Group JID** and aliases to avoid confusion.
108
-
109
- ## Commands
110
-
111
- - `/whatsapp` - Open the WhatsApp management menu
112
-
113
- ### Main Menu Options
114
- - **Connect / Reconnect WhatsApp** - Start WhatsApp connection using saved credentials when available; QR code appears only if pairing is required
115
- - **Disconnect WhatsApp** - Stop WhatsApp connection
116
- - **Logoff (Delete Session)** - Remove all credentials and session data
117
- - **Recents** - Open recent conversations, view history, and reply
118
- - **Allowed Contacts** - Manage contacts that can interact with Pi
119
- - **Allowed Groups** - Manage WhatsApp groups that can interact with Pi
120
-
121
- ### Allowed Contacts Management
122
- - **Add Contact** - Add a new contact to the allowed contacts list (format: +5511999999999)
123
- - **Select a contact** - Open a submenu with **History**, **Send Message**, **Print Contact**, alias actions, **Remove Contact**, and **Back**
124
- - **Back** - Return to main menu
125
-
126
- ### Allowed Groups Management
127
- - **Add Group** - Add a WhatsApp group JID to the allowed groups list (format: 120363012345@g.us)
128
- - **Select a group** - Open a submenu with **History**, **Send Message**, **Print Group JID**, **Reaction Mode**, alias actions, **Remove Group**, and **Back**
129
- - **Reaction Mode** - Switch between **Active** and **Passive** behavior for that group
130
- - **Back** - Return to main menu
131
-
132
- ### Recents Management
133
- - **History** - Open full message history for that conversation
134
- - **Send Message** - Send a new message without Pi suffix
135
- - **Reply** - Open message detail, then press `R` to reply
136
- - **Allow Contact / Allow Group** - Move a recent sender into the appropriate allowed list
137
- - **Remove Alias** - Clear saved alias for that sender
138
- - **Back** - Return to main menu
139
-
140
- ## Project Structure
141
-
142
- ```
143
- src/
144
- ├── models/ # Type definitions
145
- ├── services/ # Core services (WhatsApp, Session, Recents, Media)
146
- └── ui/ # Menu handlers and TUI views
147
-
148
- tests/
149
- └── unit/ # Unit tests
150
- ```
151
-
152
- ## Development
153
-
154
- Run tests:
155
- ```bash
156
- npm test
157
- ```
158
-
159
- ## Implementation Notes
160
-
161
- ### Recent Feature Updates (2026-05)
162
-
163
- - **Auto-Connect Support**: Use the `--whatsapp-pi-online` flag to connect on startup when credentials already exist.
164
- - **Group-Only Mode**: Use `--whatsapp-group <jid>` to bind Pi to a single WhatsApp group. The group must also be present in Allowed Groups.
165
- - **Allowed Group Reaction Mode**: Each allowed group can be set to Active or Passive. Passive mode only replies when the bot is directly mentioned with @.
166
- - **Recents Store**: Recent conversations and message history are persisted in `~/.pi/whatsapp-pi/recents/recents.json`.
167
- - **Message Detail / Reply**: Open a message from history to inspect full content and reply with `R`.
168
- - **Media Support**: Images are forwarded for vision analysis, audio is transcribed with Whisper, and PDFs are saved under `./.pi-data/whatsapp/documents/` with local text preview when available.
169
- - **Session Handling**: Saved state, allow list, and startup reconnects are restored automatically when available.
170
- - **Intelligent Message Filtering**: Messages ending with `π` are ignored to prevent bot loops.
171
- - **Storage Management**: Persistent data lives under `.pi-data/` plus the recents store in the user home directory.
1
+ <p align="center">
2
+ <img src="https://upload.wikimedia.org/wikipedia/commons/6/6b/WhatsApp.svg" alt="WhatsApp Logo" width="100">
3
+ </p>
4
+
5
+ # WhatsApp-Pi
6
+ [![GitHub](https://img.shields.io/badge/github-repo-black.svg?style=flat-square&logo=github)](https://github.com/RaphaCastelloes/whatsapp-pi)
7
+
8
+ A WhatsApp integration extension for the **[Pi Coding Agent](https://github.com/mariozechner/pi-coding-agent)**.
9
+
10
+ Pi is a powerful agentic AI coding assistant that operates in your terminal. This extension lets you chat and pair-program with your Pi agent through WhatsApp, with message filtering, allowed contacts/groups, recents/history browsing, message detail/reply, group-only binding, and reliable message delivery.
11
+
12
+
13
+ ## Features
14
+
15
+ - **Manual WhatsApp Connection**: QR code-based authentication with session persistence
16
+ - **Allowed Contacts**: Control which phone numbers can interact with Pi
17
+ - Add contacts with optional names for easy identification
18
+ - View ignored numbers (not yet allowed) and add them when needed
19
+ - Manage aliases and print allowed contacts from the menu
20
+ - **Allowed Groups**: Control which WhatsApp groups can interact with Pi
21
+ - Add group JIDs with optional aliases
22
+ - Choose reaction mode per group: **Active** (reply to all allowed group messages) or **Passive** (reply only when mentioned with @)
23
+ - Only groups in Allowed Groups are processed by the agent
24
+ - **Recents & History**: Browse recent conversations, inspect full message history, and reply from message detail view
25
+ - **Reliable Messaging**: Queue-based message sending with retry logic
26
+ - **TUI Integration**: Menu-driven interface for managing connections, contacts, and recent chats
27
+ - **Group-Only Mode**: Bind the agent to a single WhatsApp group with `--whatsapp-group`
28
+ - **Media Support**:
29
+ - **Vision Analysis**: Automatically forwards WhatsApp images to Pi for analysis.
30
+ - **Audio Transcription**: Transcribes voice notes when Whisper is installed.
31
+ - **Document Handling**: Downloads and stores documents (PDF, text) for agent access; PDFs include a bounded text preview when readable.
32
+
33
+ ## Prerequisites
34
+
35
+ To enable audio transcription features:
36
+ ```bash
37
+ python -m pip install -U openai-whisper
38
+ ```
39
+
40
+ PDF documents are parsed locally and do not require extra system utilities.
41
+ If a PDF cannot be parsed automatically, it is still saved and forwarded with a clear fallback notice.
42
+
43
+ ## Quick Start
44
+
45
+ 1. Install the extension:
46
+ ```bash
47
+ pi install npm:whatsapp-pi
48
+ ```
49
+
50
+ 2. Start Pi:
51
+ ```bash
52
+ pi
53
+ ```
54
+
55
+ 3. Open `/whatsapp` and choose **Connect / Reconnect WhatsApp**.
56
+ - QR appears only on first pair or after logoff.
57
+
58
+ 4. Add the chat you will use with Pi to **Allowed Contacts** or **Allowed Groups**.
59
+
60
+ 5. Send a message from that allowed chat to Pi.
61
+ - Pi replies in same thread.
62
+ - Use **Recents** only to browse history or reply manually.
63
+
64
+ After first pairing, you can start Pi with auto-connect enabled:
65
+ ```bash
66
+ pi --whatsapp-pi-online
67
+ ```
68
+
69
+ ## Development / Testing
70
+
71
+ If you are developing or testing the extension locally, you can clone the repository from [GitHub](https://github.com/RaphaCastelloes/whatsapp-pi):
72
+
73
+ 1. Clone and install dependencies:
74
+ ```bash
75
+ git clone https://github.com/RaphaCastelloes/whatsapp-pi.git
76
+ cd whatsapp-pi
77
+ npm install
78
+ ```
79
+
80
+ 2. Run the extension:
81
+ ```bash
82
+ pi -e whatsapp-pi.ts
83
+ ```
84
+
85
+ For verbose mode (shows Baileys trace logs for debugging):
86
+ ```bash
87
+ pi -e whatsapp-pi.ts --verbose
88
+ ```
89
+
90
+ To test startup auto-connect locally after you have already paired WhatsApp:
91
+ ```bash
92
+ pi -e whatsapp-pi.ts --whatsapp-pi-online
93
+ ```
94
+
95
+ ## How It Works
96
+
97
+ - Pi processes **incoming** messages only from allowed contacts or allowed groups.
98
+ - **Recents** is history browser, not trigger.
99
+ - **Send Message** and `send_wa_message` are outbound only.
100
+ - If you message yourself, WhatsApp may show sent/read ticks, but that does not guarantee Pi will treat it as a trigger.
101
+
102
+ ## WhatsApp Numbers and JIDs
103
+
104
+ - Contacts use phone format in UI: `+5511999999999`
105
+ - Internally, contacts map to JIDs like `5511999999999@s.whatsapp.net`
106
+ - Groups use JIDs like `120363012345@g.us`
107
+ - Recents may show normalized values from WhatsApp, so use **Print Contact** / **Print Group JID** and aliases to avoid confusion.
108
+
109
+ ## Commands
110
+
111
+ - `/whatsapp` - Open the WhatsApp management menu
112
+
113
+ ### Main Menu Options
114
+ - **Connect / Reconnect WhatsApp** - Start WhatsApp connection using saved credentials when available; QR code appears only if pairing is required
115
+ - **Disconnect WhatsApp** - Stop WhatsApp connection
116
+ - **Logoff (Delete Session)** - Remove all credentials and session data
117
+ - **Recents** - Open recent conversations, view history, and reply
118
+ - **Allowed Contacts** - Manage contacts that can interact with Pi
119
+ - **Allowed Groups** - Manage WhatsApp groups that can interact with Pi
120
+
121
+ ### Allowed Contacts Management
122
+ - **Add Contact** - Add a new contact to the allowed contacts list (format: +5511999999999)
123
+ - **Select a contact** - Open a submenu with **History**, **Send Message**, **Print Contact**, alias actions, **Remove Contact**, and **Back**
124
+ - **Back** - Return to main menu
125
+
126
+ ### Allowed Groups Management
127
+ - **Add Group** - Add a WhatsApp group JID to the allowed groups list (format: 120363012345@g.us)
128
+ - **Select a group** - Open a submenu with **History**, **Send Message**, **Print Group JID**, **Reaction Mode**, alias actions, **Remove Group**, and **Back**
129
+ - **Reaction Mode** - Switch between **Active** and **Passive** behavior for that group
130
+ - **Back** - Return to main menu
131
+
132
+ ### Recents Management
133
+ - **History** - Open full message history for that conversation
134
+ - **Send Message** - Send a new message without Pi suffix
135
+ - **Reply** - Open message detail, then press `R` to reply
136
+ - **Allow Contact / Allow Group** - Move a recent sender into the appropriate allowed list
137
+ - **Remove Alias** - Clear saved alias for that sender
138
+ - **Back** - Return to main menu
139
+
140
+ ## Project Structure
141
+
142
+ ```
143
+ src/
144
+ ├── models/ # Type definitions
145
+ ├── services/ # Core services (WhatsApp, Session, Recents, Media)
146
+ └── ui/ # Menu handlers and TUI views
147
+
148
+ tests/
149
+ └── unit/ # Unit tests
150
+ ```
151
+
152
+ ## Development
153
+
154
+ Run tests:
155
+ ```bash
156
+ npm test
157
+ ```
158
+
159
+ ## Implementation Notes
160
+
161
+ ### Recent Feature Updates (2026-05)
162
+
163
+ - **Auto-Connect Support**: Use the `--whatsapp-pi-online` flag to connect on startup when credentials already exist.
164
+ - **Group-Only Mode**: Use `--whatsapp-group <jid>` to bind Pi to a single WhatsApp group. The group must also be present in Allowed Groups.
165
+ - **Allowed Group Reaction Mode**: Each allowed group can be set to Active or Passive. Passive mode only replies when the bot is directly mentioned with @.
166
+ - **Recents Store**: Recent conversations and message history are persisted in `~/.pi/whatsapp-pi/recents/recents.json`.
167
+ - **Message Detail / Reply**: Open a message from history to inspect full content and reply with `R`.
168
+ - **Media Support**: Images are forwarded for vision analysis, audio is transcribed with Whisper, and PDFs are saved under `./.pi-data/whatsapp/documents/` with local text preview when available.
169
+ - **Session Handling**: Saved state, allow list, and startup reconnects are restored automatically when available.
170
+ - **Intelligent Message Filtering**: Messages ending with `π` are ignored to prevent bot loops.
171
+ - **Storage Management**: Persistent data lives under `.pi-data/` plus the recents store in the user home directory.
172
+ - **Improved Test Coverage (v1.0.56)**: Added unit tests for the `message_end` auto-reply handler, covering the happy path, disconnected guard, role guard, send failure, thrown exceptions, and the `send_wa_message` dedup flag. Fixed a Windows path separator bug in the recents service test suite.
package/package.json CHANGED
@@ -1,60 +1,60 @@
1
- {
2
- "name": "whatsapp-pi",
3
- "version": "1.0.55",
4
- "type": "module",
5
- "description": "WhatsApp integration extension for Pi",
6
- "main": "whatsapp-pi.ts",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/RaphaCastelloes/whatsapp-pi.git"
10
- },
11
- "bugs": {
12
- "url": "https://github.com/RaphaCastelloes/whatsapp-pi/issues"
13
- },
14
- "homepage": "https://github.com/RaphaCastelloes/whatsapp-pi#readme",
15
- "files": [
16
- "whatsapp-pi.ts",
17
- "src"
18
- ],
19
- "keywords": [
20
- "pi",
21
- "pi-package",
22
- "pi-extension",
23
- "whatsapp",
24
- "baileys",
25
- "agent"
26
- ],
27
- "author": "Rapha",
28
- "license": "MIT",
29
- "scripts": {
30
- "lint": "eslint whatsapp-pi.ts \"src/**/*.ts\" \"tests/**/*.ts\"",
31
- "test": "vitest run",
32
- "typecheck": "tsc --noEmit"
33
- },
34
- "dependencies": {
35
- "@llamaindex/liteparse": "^1.5.3",
36
- "baileys": "^6.7.21",
37
- "pino": "^10.3.1",
38
- "qrcode-terminal": "^0.12.0"
39
- },
40
- "devDependencies": {
41
- "@eslint/js": "^9.39.4",
42
- "@mariozechner/pi-coding-agent": "latest",
43
- "@types/node": "^20.11.0",
44
- "@types/qrcode-terminal": "^0.12.2",
45
- "@typescript-eslint/eslint-plugin": "^8.58.1",
46
- "@typescript-eslint/parser": "^8.58.1",
47
- "@vitest/coverage-v8": "^1.6.1",
48
- "eslint": "^9.39.4",
49
- "ts-node": "^10.9.2",
50
- "tsx": "^4.7.0",
51
- "typescript": "^5.3.0",
52
- "vitest": "^1.2.0"
53
- },
54
- "pi": {
55
- "extensions": [
56
- "./whatsapp-pi.ts"
57
- ],
58
- "image": "https://upload.wikimedia.org/wikipedia/commons/6/6b/WhatsApp.svg"
59
- }
60
- }
1
+ {
2
+ "name": "whatsapp-pi",
3
+ "version": "1.0.57",
4
+ "type": "module",
5
+ "description": "WhatsApp integration extension for Pi",
6
+ "main": "whatsapp-pi.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/RaphaCastelloes/whatsapp-pi.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/RaphaCastelloes/whatsapp-pi/issues"
13
+ },
14
+ "homepage": "https://github.com/RaphaCastelloes/whatsapp-pi#readme",
15
+ "files": [
16
+ "whatsapp-pi.ts",
17
+ "src"
18
+ ],
19
+ "keywords": [
20
+ "pi",
21
+ "pi-package",
22
+ "pi-extension",
23
+ "whatsapp",
24
+ "baileys",
25
+ "agent"
26
+ ],
27
+ "author": "Rapha",
28
+ "license": "MIT",
29
+ "scripts": {
30
+ "lint": "eslint whatsapp-pi.ts \"src/**/*.ts\" \"tests/**/*.ts\"",
31
+ "test": "vitest run",
32
+ "typecheck": "tsc --noEmit"
33
+ },
34
+ "dependencies": {
35
+ "@llamaindex/liteparse": "^1.5.3",
36
+ "baileys": "^6.7.21",
37
+ "pino": "^10.3.1",
38
+ "qrcode-terminal": "^0.12.0"
39
+ },
40
+ "devDependencies": {
41
+ "@eslint/js": "^9.39.4",
42
+ "@mariozechner/pi-coding-agent": "latest",
43
+ "@types/node": "^20.11.0",
44
+ "@types/qrcode-terminal": "^0.12.2",
45
+ "@typescript-eslint/eslint-plugin": "^8.58.1",
46
+ "@typescript-eslint/parser": "^8.58.1",
47
+ "@vitest/coverage-v8": "^1.6.1",
48
+ "eslint": "^9.39.4",
49
+ "ts-node": "^10.9.2",
50
+ "tsx": "^4.7.0",
51
+ "typescript": "^5.3.0",
52
+ "vitest": "^1.2.0"
53
+ },
54
+ "pi": {
55
+ "extensions": [
56
+ "./whatsapp-pi.ts"
57
+ ],
58
+ "image": "https://upload.wikimedia.org/wikipedia/commons/6/6b/WhatsApp.svg"
59
+ }
60
+ }