opencode-plugin-apprise 1.2.0 → 1.2.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 CHANGED
@@ -5,9 +5,8 @@ OpenCode plugin for multi-service notifications via Apprise.
5
5
  ## Features
6
6
 
7
7
  - Multi-service support for 128+ notification services via Apprise.
8
- - Automatic notifications when sessions go idle.
8
+ - Automatic notifications when foreground sessions go idle (background tasks are excluded).
9
9
  - Delayed notifications for Question tool prompts (30-second grace period).
10
- - Alerts when sessions transition to idle after activity.
11
10
  - Notifications for permission requests with dual-mechanism reliability.
12
11
 
13
12
  ## Prerequisites
@@ -74,7 +73,7 @@ For complete configuration options, see: https://github.com/caronc/apprise#confi
74
73
 
75
74
  ### Idle
76
75
 
77
- Fires immediately when OpenCode emits a `session.idle` event. Includes the last user request, agent response, and todo status.
76
+ Fires when a foreground session goes idle. Only sessions where the user has sent at least one message are tracked — background agent sessions are excluded. Includes the last user request, agent response, and todo status.
78
77
 
79
78
  **Severity**: info
80
79
 
@@ -100,17 +99,6 @@ Options:
100
99
  3. cancel
101
100
  ```
102
101
 
103
- ### Background
104
-
105
- Fires when a session's status transitions to `idle` after being active. This indicates the agent has finished working and the session is waiting.
106
-
107
- **Severity**: success
108
-
109
- ```
110
- ✅ Background Task Complete
111
- Task: Session ses_abc123
112
- ```
113
-
114
102
  ### Permission
115
103
 
116
104
  Fires when a tool requires explicit user permission. Uses two mechanisms for reliability: the primary `permission.ask` hook and a fallback `permission.updated` event listener. Permissions are deduplicated by ID to prevent double notifications.
@@ -150,7 +138,6 @@ Identical notifications are suppressed for 5 minutes. Duplicates are identified
150
138
  |-------|:-------------|
151
139
  | Idle | info |
152
140
  | Question | warning |
153
- | Background | success |
154
141
  | Permission | warning |
155
142
 
156
143
  ## Troubleshooting
@@ -230,12 +230,9 @@ async function sendHookNotification(hookName, config, dedup, payload) {
230
230
  }
231
231
 
232
232
  // src/hooks/idle.ts
233
- function extractText(message) {
234
- if (!message || typeof message !== "object") {
235
- return;
236
- }
237
- const parts = Array.isArray(message) ? message.map((p) => typeof p === "string" ? p : p.text || "") : [];
238
- return parts.join(`
233
+ function extractText(parts) {
234
+ const texts = parts.filter((p) => p.type === "text" && p.text).map((p) => p.text);
235
+ return texts.join(`
239
236
  `).trim() || undefined;
240
237
  }
241
238
  function createIdleHook(ctx, config, dedup, interactiveSessions) {
@@ -259,16 +256,16 @@ function createIdleHook(ctx, config, dedup, interactiveSessions) {
259
256
  const messages = messagesResponse.data ?? [];
260
257
  for (let i = messages.length - 1;i >= 0; i--) {
261
258
  const msg = messages[i];
262
- if (msg?.role === "user") {
263
- userRequest = extractText(msg.content);
259
+ if (msg?.info?.role === "user") {
260
+ userRequest = extractText(msg.parts);
264
261
  break;
265
262
  }
266
263
  }
267
264
  if (userRequest) {
268
265
  for (let i = messages.length - 1;i >= 0; i--) {
269
266
  const msg = messages[i];
270
- if (msg?.role === "assistant") {
271
- agentResponse = extractText(msg.content);
267
+ if (msg?.info?.role === "assistant") {
268
+ agentResponse = extractText(msg.parts);
272
269
  break;
273
270
  }
274
271
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-plugin-apprise",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "OpenCode plugin that sends rich notifications via Apprise CLI when the agent needs your attention",
5
5
  "type": "module",
6
6
  "main": "dist/opencode-plugin-apprise.js",