opencode-plugin-apprise 1.2.2 → 1.2.4

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.
@@ -76,12 +76,14 @@ function formatNotification(payload) {
76
76
  switch (type) {
77
77
  case "idle": {
78
78
  const parts = [];
79
+ if (context.sessionTitle)
80
+ parts.push(`\uD83D\uDCCC **Title:** ${context.sessionTitle}`);
79
81
  if (context.userRequest)
80
- parts.push(`\uD83D\uDCDD Request: ${context.userRequest}`);
82
+ parts.push(`\uD83D\uDCDD **Request:** ${context.userRequest}`);
81
83
  if (context.agentResponse)
82
- parts.push(`\uD83E\uDD16 Response: ${context.agentResponse}`);
84
+ parts.push(`\uD83E\uDD16 **Response:** ${context.agentResponse}`);
83
85
  if (context.todoStatus)
84
- parts.push(`\uD83D\uDCCB Todo: ${context.todoStatus}`);
86
+ parts.push(`\uD83D\uDCCB **Todo:** ${context.todoStatus}`);
85
87
  body = parts.join(`
86
88
 
87
89
  `);
@@ -89,12 +91,12 @@ function formatNotification(payload) {
89
91
  }
90
92
  case "question": {
91
93
  const parts = [];
92
- if (context.userRequest)
93
- parts.push(`\uD83D\uDCDD Request: ${context.userRequest}`);
94
+ if (context.sessionTitle)
95
+ parts.push(`\uD83D\uDCCC **Title:** ${context.sessionTitle}`);
94
96
  if (context.question)
95
- parts.push(`❓ Question: ${context.question}`);
97
+ parts.push(`❓ **Question:** ${context.question}`);
96
98
  if (context.options && context.options.length > 0) {
97
- parts.push(`Options:
99
+ parts.push(`**Options:**
98
100
  ${context.options.map((option, index) => ` ${index + 1}. ${option}`).join(`
99
101
  `)}`);
100
102
  }
@@ -106,9 +108,9 @@ ${context.options.map((option, index) => ` ${index + 1}. ${option}`).join(`
106
108
  case "permission": {
107
109
  const parts = [];
108
110
  if (context.toolName)
109
- parts.push(`\uD83D\uDD27 Tool: ${context.toolName}`);
111
+ parts.push(`\uD83D\uDD27 **Tool:** ${context.toolName}`);
110
112
  if (context.action)
111
- parts.push(`⚡ Action: ${context.action}`);
113
+ parts.push(`⚡ **Action:** ${context.action}`);
112
114
  body = parts.join(`
113
115
 
114
116
  `);
@@ -176,6 +178,7 @@ async function sendNotification(config, notification) {
176
178
 
177
179
  // src/hooks/shared.ts
178
180
  var EMPTY_CONTEXT = {
181
+ sessionTitle: undefined,
179
182
  userRequest: undefined,
180
183
  agentResponse: undefined,
181
184
  question: undefined,
@@ -204,10 +207,17 @@ async function sendHookNotification(hookName, config, dedup, payload) {
204
207
 
205
208
  // src/hooks/idle.ts
206
209
  function extractText(parts) {
207
- const texts = parts.filter((p) => p.type === "text" && p.text).map((p) => p.text);
210
+ const textParts = parts.filter((p) => p.type === "text" && p.text);
211
+ const nonSynthetic = textParts.filter((p) => !p.synthetic);
212
+ const source = nonSynthetic.length > 0 ? nonSynthetic : textParts;
213
+ const texts = source.map((p) => p.text);
208
214
  return texts.join(`
209
215
  `).trim() || undefined;
210
216
  }
217
+ function isFullySyntheticMessage(parts) {
218
+ const textParts = parts.filter((p) => p.type === "text");
219
+ return textParts.length > 0 && textParts.every((p) => p.synthetic === true);
220
+ }
211
221
  function createIdleHook(ctx, config, dedup, delayMs = 30000) {
212
222
  const pendingTimers = new Map;
213
223
  return async ({ event }) => {
@@ -239,6 +249,7 @@ function createIdleHook(ctx, config, dedup, delayMs = 30000) {
239
249
  const sessionInfo = sessionResponse.data;
240
250
  if (sessionInfo.parentID)
241
251
  return;
252
+ const sessionTitle = sessionInfo.title || undefined;
242
253
  const messagesResponse = await ctx.client.session.messages({
243
254
  path: { id: sessionID }
244
255
  });
@@ -246,6 +257,8 @@ function createIdleHook(ctx, config, dedup, delayMs = 30000) {
246
257
  for (let i = messages.length - 1;i >= 0; i--) {
247
258
  const msg = messages[i];
248
259
  if (msg?.info?.role === "user") {
260
+ if (isFullySyntheticMessage(msg.parts))
261
+ continue;
249
262
  userRequest = extractText(msg.parts);
250
263
  break;
251
264
  }
@@ -268,6 +281,7 @@ function createIdleHook(ctx, config, dedup, delayMs = 30000) {
268
281
  }
269
282
  } catch {}
270
283
  const payload = createPayload("idle", "\uD83D\uDCE2 OpenCode Attention Required", {
284
+ sessionTitle,
271
285
  userRequest,
272
286
  agentResponse,
273
287
  todoStatus
package/dist/types.d.ts CHANGED
@@ -4,6 +4,7 @@ export interface PluginConfig {
4
4
  export type HookEventType = "idle" | "question" | "permission";
5
5
  export type AppriseNotificationType = "info" | "warning" | "success" | "failure";
6
6
  export interface NotificationContext {
7
+ sessionTitle: string | undefined;
7
8
  userRequest: string | undefined;
8
9
  agentResponse: string | undefined;
9
10
  question: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-plugin-apprise",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
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",