opencode-plugin-apprise 1.2.6 → 1.2.8
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Hooks } from "@opencode-ai/plugin";
|
|
1
|
+
import type { Hooks, PluginInput } from "@opencode-ai/plugin";
|
|
2
2
|
import type { DedupChecker } from "../dedup.js";
|
|
3
3
|
import type { PluginConfig } from "../types.js";
|
|
4
4
|
export interface PermissionHooks {
|
|
@@ -7,4 +7,4 @@ export interface PermissionHooks {
|
|
|
7
7
|
/** Fallback: event hook watching permission.asked */
|
|
8
8
|
eventFallback: NonNullable<Hooks["event"]>;
|
|
9
9
|
}
|
|
10
|
-
export declare function createPermissionHooks(config: PluginConfig, dedup: DedupChecker): PermissionHooks;
|
|
10
|
+
export declare function createPermissionHooks(ctx: PluginInput, config: PluginConfig, dedup: DedupChecker): PermissionHooks;
|
package/dist/hooks/question.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Hooks } from "@opencode-ai/plugin";
|
|
1
|
+
import type { Hooks, PluginInput } from "@opencode-ai/plugin";
|
|
2
2
|
import type { DedupChecker } from "../dedup.js";
|
|
3
3
|
import type { PluginConfig } from "../types.js";
|
|
4
|
-
export declare function createQuestionHook(config: PluginConfig, dedup: DedupChecker, delayMs?: number): NonNullable<Hooks["event"]>;
|
|
4
|
+
export declare function createQuestionHook(ctx: PluginInput, config: PluginConfig, dedup: DedupChecker, delayMs?: number): NonNullable<Hooks["event"]>;
|
|
@@ -108,6 +108,8 @@ ${context.options.map((option, index) => ` ${index + 1}. ${option}`).join(`
|
|
|
108
108
|
}
|
|
109
109
|
case "permission": {
|
|
110
110
|
const parts = [];
|
|
111
|
+
if (context.sessionTitle)
|
|
112
|
+
parts.push(`\uD83D\uDCCC TITLE: ${context.sessionTitle}`);
|
|
111
113
|
if (context.toolName)
|
|
112
114
|
parts.push(`\uD83D\uDD27 TOOL: ${context.toolName}`);
|
|
113
115
|
if (context.action)
|
|
@@ -118,6 +120,11 @@ ${context.options.map((option, index) => ` ${index + 1}. ${option}`).join(`
|
|
|
118
120
|
default:
|
|
119
121
|
body = "";
|
|
120
122
|
}
|
|
123
|
+
if (body) {
|
|
124
|
+
body = `────────────────────
|
|
125
|
+
|
|
126
|
+
${body}`;
|
|
127
|
+
}
|
|
121
128
|
return { title, body, notificationType };
|
|
122
129
|
}
|
|
123
130
|
|
|
@@ -295,7 +302,7 @@ function createIdleHook(ctx, config, dedup, delayMs = 30000) {
|
|
|
295
302
|
}
|
|
296
303
|
|
|
297
304
|
// src/hooks/permission.ts
|
|
298
|
-
function createPermissionHooks(config, dedup) {
|
|
305
|
+
function createPermissionHooks(ctx, config, dedup) {
|
|
299
306
|
const notifiedPermissions = new Set;
|
|
300
307
|
const permissionAsk = async (input, _output) => {
|
|
301
308
|
const permId = input.id ?? "unknown";
|
|
@@ -305,7 +312,17 @@ function createPermissionHooks(config, dedup) {
|
|
|
305
312
|
const title = input.title ?? "Unknown";
|
|
306
313
|
const pattern = input.pattern;
|
|
307
314
|
const action = Array.isArray(pattern) ? pattern.join(", ") : pattern ?? "Unknown";
|
|
315
|
+
const sessionID = input.sessionID;
|
|
316
|
+
let sessionTitle;
|
|
317
|
+
if (sessionID) {
|
|
318
|
+
try {
|
|
319
|
+
const sessionResponse = await ctx.client.session.get({ path: { id: sessionID } });
|
|
320
|
+
const sessionInfo = sessionResponse.data;
|
|
321
|
+
sessionTitle = sessionInfo.title || undefined;
|
|
322
|
+
} catch {}
|
|
323
|
+
}
|
|
308
324
|
const payload = createPayload("permission", "\uD83D\uDD10 OpenCode Permission Required", {
|
|
325
|
+
sessionTitle,
|
|
309
326
|
toolName: title,
|
|
310
327
|
action
|
|
311
328
|
});
|
|
@@ -320,7 +337,17 @@ function createPermissionHooks(config, dedup) {
|
|
|
320
337
|
if (notifiedPermissions.has(permId))
|
|
321
338
|
return;
|
|
322
339
|
notifiedPermissions.add(permId);
|
|
340
|
+
let sessionTitle;
|
|
341
|
+
const sessionID = props.sessionID;
|
|
342
|
+
if (sessionID) {
|
|
343
|
+
try {
|
|
344
|
+
const sessionResponse = await ctx.client.session.get({ path: { id: sessionID } });
|
|
345
|
+
const sessionInfo = sessionResponse.data;
|
|
346
|
+
sessionTitle = sessionInfo.title || undefined;
|
|
347
|
+
} catch {}
|
|
348
|
+
}
|
|
323
349
|
const payload = createPayload("permission", "\uD83D\uDD10 OpenCode Permission Required", {
|
|
350
|
+
sessionTitle,
|
|
324
351
|
toolName: props.permission ?? "Unknown",
|
|
325
352
|
action: props.patterns?.join(", ") ?? "Unknown"
|
|
326
353
|
});
|
|
@@ -330,7 +357,7 @@ function createPermissionHooks(config, dedup) {
|
|
|
330
357
|
}
|
|
331
358
|
|
|
332
359
|
// src/hooks/question.ts
|
|
333
|
-
function createQuestionHook(config, dedup, delayMs = 30000) {
|
|
360
|
+
function createQuestionHook(ctx, config, dedup, delayMs = 30000) {
|
|
334
361
|
const timers = new Map;
|
|
335
362
|
return async ({ event }) => {
|
|
336
363
|
const eventType = event.type;
|
|
@@ -352,9 +379,17 @@ function createQuestionHook(config, dedup, delayMs = 30000) {
|
|
|
352
379
|
const question = firstQuestion.question;
|
|
353
380
|
const options = firstQuestion.options.map((opt) => opt.label);
|
|
354
381
|
const requestId = props.id;
|
|
382
|
+
const sessionID = props.sessionID;
|
|
355
383
|
const timer = setTimeout(async () => {
|
|
356
384
|
timers.delete(requestId);
|
|
385
|
+
let sessionTitle;
|
|
386
|
+
try {
|
|
387
|
+
const sessionResponse = await ctx.client.session.get({ path: { id: sessionID } });
|
|
388
|
+
const sessionInfo = sessionResponse.data;
|
|
389
|
+
sessionTitle = sessionInfo.title || undefined;
|
|
390
|
+
} catch {}
|
|
357
391
|
const payload = createPayload("question", "❓ OpenCode Question", {
|
|
392
|
+
sessionTitle,
|
|
358
393
|
question,
|
|
359
394
|
options: options.length > 0 ? options : undefined
|
|
360
395
|
});
|
|
@@ -383,8 +418,8 @@ var plugin = async (input) => {
|
|
|
383
418
|
}
|
|
384
419
|
const dedup = createDedupChecker();
|
|
385
420
|
const idleHook = createIdleHook(input, config, dedup);
|
|
386
|
-
const questionHook = createQuestionHook(config, dedup);
|
|
387
|
-
const permissionHooks = createPermissionHooks(config, dedup);
|
|
421
|
+
const questionHook = createQuestionHook(input, config, dedup);
|
|
422
|
+
const permissionHooks = createPermissionHooks(input, config, dedup);
|
|
388
423
|
const combinedEventHook = async ({ event }) => {
|
|
389
424
|
await questionHook({ event });
|
|
390
425
|
await permissionHooks.eventFallback({ event });
|
package/package.json
CHANGED