opencode-discord-notify 0.8.0 → 0.9.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 +12 -10
- package/dist/index.js +9 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OPENCODE-DISCORD-NOTIFY
|
|
2
2
|
|
|
3
|
-
[](LICENSE)
|
|
4
|
-
[](https://www.npmjs.com/package/opencode-discord-notify)
|
|
5
|
-
[](https://www.npmjs.com/package/opencode-discord-notify)
|
|
6
3
|
[](https://www.npmjs.com/package/opencode-discord-notify)
|
|
4
|
+
[](https://www.npmjs.com/package/opencode-discord-notify)
|
|
5
|
+
[](https://www.npmjs.com/package/opencode-discord-notify)
|
|
7
6
|

|
|
8
7
|

|
|
9
8
|

|
|
10
9
|
|
|
10
|
+
> **Requires OpenCode v1.1.1 or later** (due to breaking changes in the permission event system)
|
|
11
|
+
|
|
11
12
|
<p align="center">
|
|
12
13
|
<img src="assets/image/sample-forum-ch.png" width="700" alt="Discord Forum channel example" />
|
|
13
14
|
</p>
|
|
@@ -70,7 +71,7 @@ export DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/..."
|
|
|
70
71
|
| `DISCORD_WEBHOOK_COMPLETE_INCLUDE_LAST_MESSAGE` | ❌ No | `1` | Set to `0` to exclude the last assistant message from session completion notifications |
|
|
71
72
|
| `DISCORD_WEBHOOK_EXCLUDE_INPUT_CONTEXT` | ❌ No | `1` | Set to `0` to include file context in notifications |
|
|
72
73
|
| `DISCORD_WEBHOOK_SHOW_ERROR_ALERT` | ❌ No | `1` | Set to `0` to disable error toast notifications |
|
|
73
|
-
| `DISCORD_SEND_PARAMS` | ❌ No | - | Comma-separated embed fields: `sessionID,permissionID,
|
|
74
|
+
| `DISCORD_SEND_PARAMS` | ❌ No | - | Comma-separated embed fields: `sessionID,permissionID,permission,patterns,messageID,callID,partID,role,directory,projectID` |
|
|
74
75
|
| `DISCORD_WEBHOOK_FALLBACK_URL` | ❌ No | - | Fallback webhook URL for text channel (sends mentions here too for guaranteed ping) |
|
|
75
76
|
| `DISCORD_NOTIFY_QUEUE_DB_PATH` | ❌ No | `~/.config/opencode/discord-notify-queue.db` | Custom path for the persistent queue database |
|
|
76
77
|
|
|
@@ -107,7 +108,7 @@ export DISCORD_WEBHOOK_AVATAR_URL="https://example.com/avatar.png"
|
|
|
107
108
|
### Supported Events
|
|
108
109
|
|
|
109
110
|
- **`session.created`**: Queues session start notification (sent when thread info is available)
|
|
110
|
-
- **`permission.
|
|
111
|
+
- **`permission.asked`**: Posts permission request immediately
|
|
111
112
|
- **`session.idle`**: Posts session completion notification
|
|
112
113
|
- Includes the last assistant message in the embed description by default (customizable via `DISCORD_WEBHOOK_COMPLETE_INCLUDE_LAST_MESSAGE`)
|
|
113
114
|
- Message is truncated to 4096 characters if needed
|
|
@@ -216,7 +217,7 @@ Controls which metadata fields appear in embeds.
|
|
|
216
217
|
|
|
217
218
|
**Allowed keys:**
|
|
218
219
|
|
|
219
|
-
- `sessionID`, `permissionID`, `
|
|
220
|
+
- `sessionID`, `permissionID`, `permission`, `patterns`, `messageID`, `callID`, `partID`, `role`, `directory`, `projectID`
|
|
220
221
|
|
|
221
222
|
**Default behavior (unset/empty):**
|
|
222
223
|
|
|
@@ -225,7 +226,7 @@ Controls which metadata fields appear in embeds.
|
|
|
225
226
|
**To send all fields:**
|
|
226
227
|
|
|
227
228
|
```bash
|
|
228
|
-
export DISCORD_SEND_PARAMS="sessionID,permissionID,
|
|
229
|
+
export DISCORD_SEND_PARAMS="sessionID,permissionID,permission,patterns,messageID,callID,partID,role,directory,projectID"
|
|
229
230
|
```
|
|
230
231
|
|
|
231
232
|
**Note:** `session.created` always includes `sessionID` regardless of this setting.
|
|
@@ -253,8 +254,9 @@ Main implementation: `src/index.ts`
|
|
|
253
254
|
## Roadmap
|
|
254
255
|
|
|
255
256
|
- [ ] Support multiple webhooks for routing by event type
|
|
256
|
-
- [ ]
|
|
257
|
-
- [
|
|
257
|
+
- [ ] Message filtering/customization
|
|
258
|
+
- [x] Customizable notification templates
|
|
259
|
+
- [x] Configuration file support (e.g., `opencode-discord-notify.config.json`)
|
|
258
260
|
- [x] Enhanced rate limit handling (smarter retry logic, message queuing)
|
|
259
261
|
- [x] CI/CD (automated linting, formatting, testing)
|
|
260
262
|
|
package/dist/index.js
CHANGED
|
@@ -220,8 +220,8 @@ var DEFAULT_RATE_LIMIT_WAIT_MS = 1e4;
|
|
|
220
220
|
var SEND_PARAM_KEYS = [
|
|
221
221
|
"sessionID",
|
|
222
222
|
"permissionID",
|
|
223
|
-
"
|
|
224
|
-
"
|
|
223
|
+
"permission",
|
|
224
|
+
"patterns",
|
|
225
225
|
"messageID",
|
|
226
226
|
"callID",
|
|
227
227
|
"partID",
|
|
@@ -733,11 +733,13 @@ var plugin = async ({ client }) => {
|
|
|
733
733
|
});
|
|
734
734
|
return;
|
|
735
735
|
}
|
|
736
|
-
case "permission.
|
|
736
|
+
case "permission.asked": {
|
|
737
737
|
const p = event.properties;
|
|
738
738
|
const sessionID = p?.sessionID;
|
|
739
739
|
if (!sessionID) return;
|
|
740
740
|
const mention = buildPermissionMention();
|
|
741
|
+
const patternsArray = p?.patterns;
|
|
742
|
+
const patternsStr = Array.isArray(patternsArray) ? patternsArray.join(", ") : void 0;
|
|
741
743
|
const embed = {
|
|
742
744
|
title: "Permission required",
|
|
743
745
|
description: p?.title,
|
|
@@ -748,10 +750,10 @@ var plugin = async ({ client }) => {
|
|
|
748
750
|
[
|
|
749
751
|
["sessionID", sessionID],
|
|
750
752
|
["permissionID", p?.id],
|
|
751
|
-
["
|
|
752
|
-
["
|
|
753
|
-
["messageID", p?.messageID],
|
|
754
|
-
["callID", p?.callID]
|
|
753
|
+
["permission", p?.permission],
|
|
754
|
+
["patterns", patternsStr],
|
|
755
|
+
["messageID", p?.tool?.messageID],
|
|
756
|
+
["callID", p?.tool?.callID]
|
|
755
757
|
],
|
|
756
758
|
sendParams
|
|
757
759
|
)
|