opencode-smart-voice-notify 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/LICENSE +21 -0
- package/README.md +200 -0
- package/assets/Machine-alert-beep-sound-effect.mp3 +0 -0
- package/assets/Soft-high-tech-notification-sound-effect.mp3 +0 -0
- package/example.config.jsonc +158 -0
- package/index.js +431 -0
- package/package.json +43 -0
- package/util/config.js +182 -0
- package/util/tts.js +447 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 MasuRii
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# OpenCode Smart Voice Notify
|
|
2
|
+
|
|
3
|
+
> **Disclaimer**: This project is not built by the OpenCode team and is not affiliated with [OpenCode](https://opencode.ai) in any way. It is an independent community plugin.
|
|
4
|
+
|
|
5
|
+
A smart voice notification plugin for [OpenCode](https://opencode.ai) with **multiple TTS engines** and an intelligent reminder system.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
### Smart TTS Engine Selection
|
|
10
|
+
The plugin automatically tries multiple TTS engines in order, falling back if one fails:
|
|
11
|
+
|
|
12
|
+
1. **ElevenLabs** (Online) - High-quality, anime-like voices with natural expression
|
|
13
|
+
2. **Edge TTS** (Free) - Microsoft's neural voices, no API key required
|
|
14
|
+
3. **Windows SAPI** (Offline) - Built-in Windows speech synthesis
|
|
15
|
+
4. **Local Sound Files** (Fallback) - Plays bundled MP3 files if all TTS fails
|
|
16
|
+
|
|
17
|
+
### Smart Notification System
|
|
18
|
+
- **Sound-first mode**: Play a sound immediately, then speak a TTS reminder if user doesn't respond
|
|
19
|
+
- **TTS-first mode**: Speak immediately using TTS
|
|
20
|
+
- **Both mode**: Play sound AND speak TTS at the same time
|
|
21
|
+
- **Sound-only mode**: Just play sounds, no TTS
|
|
22
|
+
|
|
23
|
+
### Intelligent Reminders
|
|
24
|
+
- Delayed TTS reminders if user doesn't respond within configurable time
|
|
25
|
+
- Follow-up reminders with exponential backoff
|
|
26
|
+
- Automatic cancellation when user responds
|
|
27
|
+
- Per-notification type delays (permission requests are more urgent)
|
|
28
|
+
|
|
29
|
+
### System Integration
|
|
30
|
+
- Wake monitor from sleep before notifying
|
|
31
|
+
- Auto-boost volume if too low
|
|
32
|
+
- TUI toast notifications
|
|
33
|
+
- Cross-platform support (Windows, macOS, Linux)
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
### Option 1: From npm (Recommended)
|
|
38
|
+
|
|
39
|
+
Add to your OpenCode config file (`~/.config/opencode/config.json`):
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"$schema": "https://opencode.ai/config.json",
|
|
44
|
+
"plugin": ["opencode-smart-voice-notify@latest"]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Option 2: From GitHub
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"$schema": "https://opencode.ai/config.json",
|
|
53
|
+
"plugin": ["github:MasuRii/opencode-smart-voice-notify"]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Option 3: Local Development
|
|
58
|
+
|
|
59
|
+
1. Clone the repository:
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/MasuRii/opencode-smart-voice-notify.git
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. Reference the local path in your config:
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"plugin": ["file:///path/to/opencode-smart-voice-notify"]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Configuration
|
|
72
|
+
|
|
73
|
+
### Automatic Setup
|
|
74
|
+
|
|
75
|
+
When you first run OpenCode with this plugin installed, it will **automatically create**:
|
|
76
|
+
|
|
77
|
+
1. **`~/.config/opencode/smart-voice-notify.jsonc`** - A default config file with sensible defaults
|
|
78
|
+
2. **`~/.config/opencode/assets/*.mp3`** - Bundled notification sound files
|
|
79
|
+
|
|
80
|
+
You can then customize the config file as needed.
|
|
81
|
+
|
|
82
|
+
### Manual Configuration
|
|
83
|
+
|
|
84
|
+
If you prefer to create the config manually, add a `smart-voice-notify.jsonc` file in your OpenCode config directory (`~/.config/opencode/`):
|
|
85
|
+
|
|
86
|
+
```jsonc
|
|
87
|
+
{
|
|
88
|
+
// ============================================================
|
|
89
|
+
// NOTIFICATION MODE SETTINGS
|
|
90
|
+
// ============================================================
|
|
91
|
+
// 'sound-first' - Play sound immediately, TTS reminder after delay (RECOMMENDED)
|
|
92
|
+
// 'tts-first' - Speak TTS immediately
|
|
93
|
+
// 'both' - Play sound AND speak TTS immediately
|
|
94
|
+
// 'sound-only' - Only play sound, no TTS
|
|
95
|
+
"notificationMode": "sound-first",
|
|
96
|
+
|
|
97
|
+
// ============================================================
|
|
98
|
+
// TTS ENGINE SELECTION
|
|
99
|
+
// ============================================================
|
|
100
|
+
// 'elevenlabs' - Best quality (requires API key)
|
|
101
|
+
// 'edge' - Free neural voices (requires: pip install edge-tts)
|
|
102
|
+
// 'sapi' - Windows built-in (free, offline)
|
|
103
|
+
"ttsEngine": "elevenlabs",
|
|
104
|
+
"enableTTS": true,
|
|
105
|
+
|
|
106
|
+
// ============================================================
|
|
107
|
+
// ELEVENLABS SETTINGS
|
|
108
|
+
// ============================================================
|
|
109
|
+
// Get your API key from: https://elevenlabs.io/app/settings/api-keys
|
|
110
|
+
"elevenLabsApiKey": "your-api-key-here",
|
|
111
|
+
"elevenLabsVoiceId": "cgSgspJ2msm6clMCkdW9", // Jessica voice
|
|
112
|
+
"elevenLabsModel": "eleven_turbo_v2_5",
|
|
113
|
+
|
|
114
|
+
// ============================================================
|
|
115
|
+
// TTS REMINDER SETTINGS
|
|
116
|
+
// ============================================================
|
|
117
|
+
"enableTTSReminder": true,
|
|
118
|
+
"idleReminderDelaySeconds": 30,
|
|
119
|
+
"permissionReminderDelaySeconds": 20,
|
|
120
|
+
"enableFollowUpReminders": true,
|
|
121
|
+
"maxFollowUpReminders": 3,
|
|
122
|
+
|
|
123
|
+
// ============================================================
|
|
124
|
+
// SOUND FILES (relative to OpenCode config directory)
|
|
125
|
+
// ============================================================
|
|
126
|
+
"idleSound": "assets/Soft-high-tech-notification-sound-effect.mp3",
|
|
127
|
+
"permissionSound": "assets/Machine-alert-beep-sound-effect.mp3"
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
See `example.config.jsonc` for the full configuration options.
|
|
132
|
+
|
|
133
|
+
## Requirements
|
|
134
|
+
|
|
135
|
+
### For ElevenLabs TTS
|
|
136
|
+
- ElevenLabs API key (free tier: 10,000 characters/month)
|
|
137
|
+
- Internet connection
|
|
138
|
+
|
|
139
|
+
### For Edge TTS
|
|
140
|
+
- Python with `edge-tts` package:
|
|
141
|
+
```bash
|
|
142
|
+
pip install edge-tts
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### For Windows SAPI
|
|
146
|
+
- Windows OS (uses built-in System.Speech)
|
|
147
|
+
|
|
148
|
+
### For Sound Playback
|
|
149
|
+
- **Windows**: Built-in (uses Windows Media Player)
|
|
150
|
+
- **macOS**: Built-in (`afplay`)
|
|
151
|
+
- **Linux**: `paplay` or `aplay`
|
|
152
|
+
|
|
153
|
+
## Events Handled
|
|
154
|
+
|
|
155
|
+
| Event | Action |
|
|
156
|
+
|-------|--------|
|
|
157
|
+
| `session.idle` | Agent finished working - notify user |
|
|
158
|
+
| `permission.updated` | Permission request - alert user |
|
|
159
|
+
| `permission.replied` | User responded - cancel pending reminders |
|
|
160
|
+
| `message.updated` | New user message - cancel pending reminders |
|
|
161
|
+
| `session.created` | New session - reset state |
|
|
162
|
+
|
|
163
|
+
## Development
|
|
164
|
+
|
|
165
|
+
To develop on this plugin locally:
|
|
166
|
+
|
|
167
|
+
1. Clone the repository:
|
|
168
|
+
```bash
|
|
169
|
+
git clone https://github.com/MasuRii/opencode-smart-voice-notify.git
|
|
170
|
+
cd opencode-smart-voice-notify
|
|
171
|
+
bun install # or npm install
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
2. Link to your OpenCode config:
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"plugin": ["file:///absolute/path/to/opencode-smart-voice-notify"]
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Updating
|
|
182
|
+
|
|
183
|
+
OpenCode does not automatically update plugins. To update to the latest version:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# Clear the cached plugin
|
|
187
|
+
rm -rf ~/.cache/opencode/node_modules/opencode-smart-voice-notify
|
|
188
|
+
|
|
189
|
+
# Run OpenCode to trigger a fresh install
|
|
190
|
+
opencode
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
MIT
|
|
196
|
+
|
|
197
|
+
## Support
|
|
198
|
+
|
|
199
|
+
- Open an issue on [GitHub](https://github.com/MasuRii/opencode-smart-voice-notify/issues)
|
|
200
|
+
- Check the [OpenCode docs](https://opencode.ai/docs/plugins)
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
{
|
|
2
|
+
// ============================================================
|
|
3
|
+
// NOTIFICATION MODE SETTINGS (Smart Notification System)
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Controls how notifications are delivered:
|
|
6
|
+
// 'sound-first' - Play sound immediately, TTS reminder after delay (RECOMMENDED)
|
|
7
|
+
// 'tts-first' - Speak TTS immediately, no sound
|
|
8
|
+
// 'both' - Play sound AND speak TTS immediately
|
|
9
|
+
// 'sound-only' - Only play sound, no TTS at all
|
|
10
|
+
"notificationMode": "sound-first",
|
|
11
|
+
|
|
12
|
+
// ============================================================
|
|
13
|
+
// TTS REMINDER SETTINGS (When user doesn't respond to sound)
|
|
14
|
+
// ============================================================
|
|
15
|
+
|
|
16
|
+
// Enable TTS reminder if user doesn't respond after sound notification
|
|
17
|
+
"enableTTSReminder": true,
|
|
18
|
+
|
|
19
|
+
// Delay (in seconds) before TTS reminder fires
|
|
20
|
+
// Set globally or per-notification type
|
|
21
|
+
"ttsReminderDelaySeconds": 30, // Global default
|
|
22
|
+
"idleReminderDelaySeconds": 30, // For task completion notifications
|
|
23
|
+
"permissionReminderDelaySeconds": 20, // For permission requests (more urgent)
|
|
24
|
+
|
|
25
|
+
// Follow-up reminders if user STILL doesn't respond after first TTS
|
|
26
|
+
"enableFollowUpReminders": true,
|
|
27
|
+
"maxFollowUpReminders": 3, // Max number of follow-up TTS reminders
|
|
28
|
+
"reminderBackoffMultiplier": 1.5, // Each follow-up waits longer (30s, 45s, 67s...)
|
|
29
|
+
|
|
30
|
+
// ============================================================
|
|
31
|
+
// TTS ENGINE SELECTION
|
|
32
|
+
// ============================================================
|
|
33
|
+
// 'elevenlabs' - Best quality, anime-like voices (requires API key, free tier: 10k chars/month)
|
|
34
|
+
// 'edge' - Good quality neural voices (free, requires: pip install edge-tts)
|
|
35
|
+
// 'sapi' - Windows built-in voices (free, offline, robotic)
|
|
36
|
+
"ttsEngine": "elevenlabs",
|
|
37
|
+
|
|
38
|
+
// Enable TTS for notifications (falls back to sound files if TTS fails)
|
|
39
|
+
"enableTTS": true,
|
|
40
|
+
|
|
41
|
+
// ============================================================
|
|
42
|
+
// ELEVENLABS SETTINGS (Best Quality - Anime-like Voices)
|
|
43
|
+
// ============================================================
|
|
44
|
+
// Get your API key from: https://elevenlabs.io/app/settings/api-keys
|
|
45
|
+
// Free tier: 10,000 characters/month
|
|
46
|
+
"elevenLabsApiKey": "YOUR_API_KEY_HERE",
|
|
47
|
+
|
|
48
|
+
// Voice ID - Recommended cute/anime-like voices:
|
|
49
|
+
// 'cgSgspJ2msm6clMCkdW9' - Jessica (Playful, Bright, Warm) - RECOMMENDED
|
|
50
|
+
// 'FGY2WhTYpPnrIDTdsKH5' - Laura (Enthusiast, Quirky)
|
|
51
|
+
// 'jsCqWAovK2LkecY7zXl4' - Freya (Expressive, Confident)
|
|
52
|
+
// 'EXAVITQu4vr4xnSDxMaL' - Sarah (Soft, Warm)
|
|
53
|
+
// Browse more at: https://elevenlabs.io/voice-library
|
|
54
|
+
"elevenLabsVoiceId": "cgSgspJ2msm6clMCkdW9",
|
|
55
|
+
|
|
56
|
+
// Model: 'eleven_turbo_v2_5' (fast, good), 'eleven_multilingual_v2' (highest quality)
|
|
57
|
+
"elevenLabsModel": "eleven_turbo_v2_5",
|
|
58
|
+
|
|
59
|
+
// Voice tuning (0.0 to 1.0)
|
|
60
|
+
"elevenLabsStability": 0.5, // Lower = more expressive, Higher = more consistent
|
|
61
|
+
"elevenLabsSimilarity": 0.75, // How closely to match the original voice
|
|
62
|
+
"elevenLabsStyle": 0.5, // Style exaggeration (higher = more expressive)
|
|
63
|
+
|
|
64
|
+
// ============================================================
|
|
65
|
+
// EDGE TTS SETTINGS (Free Neural Voices - Fallback)
|
|
66
|
+
// ============================================================
|
|
67
|
+
// Requires: pip install edge-tts
|
|
68
|
+
|
|
69
|
+
// Voice options (run 'edge-tts --list-voices' to see all):
|
|
70
|
+
// 'en-US-AnaNeural' - Young, cute, cartoon-like
|
|
71
|
+
// 'en-US-JennyNeural' - Friendly, warm
|
|
72
|
+
// 'en-US-AriaNeural' - Confident, clear
|
|
73
|
+
"edgeVoice": "en-US-AnaNeural",
|
|
74
|
+
|
|
75
|
+
// Pitch adjustment: +0Hz to +100Hz (higher = more anime-like)
|
|
76
|
+
"edgePitch": "+50Hz",
|
|
77
|
+
|
|
78
|
+
// Speech rate: -50% to +100%
|
|
79
|
+
"edgeRate": "+10%",
|
|
80
|
+
|
|
81
|
+
// ============================================================
|
|
82
|
+
// SAPI SETTINGS (Windows Built-in - Last Resort Fallback)
|
|
83
|
+
// ============================================================
|
|
84
|
+
|
|
85
|
+
// Voice (run PowerShell to list all):
|
|
86
|
+
// Add-Type -AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).GetInstalledVoices() | % { $_.VoiceInfo.Name }
|
|
87
|
+
"sapiVoice": "Microsoft Zira Desktop",
|
|
88
|
+
"sapiRate": -1,
|
|
89
|
+
"sapiPitch": "medium",
|
|
90
|
+
"sapiVolume": "loud",
|
|
91
|
+
|
|
92
|
+
// ============================================================
|
|
93
|
+
// INITIAL TTS MESSAGES (Used immediately or after sound)
|
|
94
|
+
// These are randomly selected each time
|
|
95
|
+
// ============================================================
|
|
96
|
+
|
|
97
|
+
// Messages when agent finishes work
|
|
98
|
+
"idleTTSMessages": [
|
|
99
|
+
"All done! Your task has been completed successfully.",
|
|
100
|
+
"Hey there! I finished working on your request.",
|
|
101
|
+
"Task complete! Ready for your review whenever you are.",
|
|
102
|
+
"Good news! Everything is done and ready for you.",
|
|
103
|
+
"Finished! Let me know if you need anything else."
|
|
104
|
+
],
|
|
105
|
+
|
|
106
|
+
// Messages for permission requests
|
|
107
|
+
"permissionTTSMessages": [
|
|
108
|
+
"Attention please! I need your permission to continue.",
|
|
109
|
+
"Hey! Quick approval needed to proceed with the task.",
|
|
110
|
+
"Heads up! There is a permission request waiting for you.",
|
|
111
|
+
"Excuse me! I need your authorization before I can continue.",
|
|
112
|
+
"Permission required! Please review and approve when ready."
|
|
113
|
+
],
|
|
114
|
+
|
|
115
|
+
// ============================================================
|
|
116
|
+
// TTS REMINDER MESSAGES (More urgent - used after delay if no response)
|
|
117
|
+
// These are more personalized and urgent to get user attention
|
|
118
|
+
// ============================================================
|
|
119
|
+
|
|
120
|
+
// Reminder messages when agent finished but user hasn't responded
|
|
121
|
+
"idleReminderTTSMessages": [
|
|
122
|
+
"Hey, are you still there? Your task has been waiting for review.",
|
|
123
|
+
"Just a gentle reminder - I finished your request a while ago!",
|
|
124
|
+
"Hello? I completed your task. Please take a look when you can.",
|
|
125
|
+
"Still waiting for you! The work is done and ready for review.",
|
|
126
|
+
"Knock knock! Your completed task is patiently waiting for you."
|
|
127
|
+
],
|
|
128
|
+
|
|
129
|
+
// Reminder messages when permission still needed
|
|
130
|
+
"permissionReminderTTSMessages": [
|
|
131
|
+
"Hey! I still need your permission to continue. Please respond!",
|
|
132
|
+
"Reminder: There is a pending permission request. I cannot proceed without you.",
|
|
133
|
+
"Hello? I am waiting for your approval. This is getting urgent!",
|
|
134
|
+
"Please check your screen! I really need your permission to move forward.",
|
|
135
|
+
"Still waiting for authorization! The task is on hold until you respond."
|
|
136
|
+
],
|
|
137
|
+
|
|
138
|
+
// ============================================================
|
|
139
|
+
// SOUND FILES (For immediate notifications)
|
|
140
|
+
// These are played first before TTS reminder kicks in
|
|
141
|
+
// Paths are relative to OpenCode config directory (~/.config/opencode/)
|
|
142
|
+
// ============================================================
|
|
143
|
+
|
|
144
|
+
"idleSound": "assets/Soft-high-tech-notification-sound-effect.mp3",
|
|
145
|
+
"permissionSound": "assets/Machine-alert-beep-sound-effect.mp3",
|
|
146
|
+
|
|
147
|
+
// ============================================================
|
|
148
|
+
// GENERAL SETTINGS
|
|
149
|
+
// ============================================================
|
|
150
|
+
|
|
151
|
+
"wakeMonitor": true, // Wake monitor when notifying
|
|
152
|
+
"forceVolume": true, // Force volume up if too low
|
|
153
|
+
"enableToast": true, // Show TUI toast notifications
|
|
154
|
+
"enableSound": true, // Enable audio notifications
|
|
155
|
+
"volumeThreshold": 50, // Force volume if below this level
|
|
156
|
+
"idleThresholdSeconds": 60, // Consider monitor asleep after this
|
|
157
|
+
"debugLog": false // Enable debug logging to file
|
|
158
|
+
}
|