opencode-plugin-apprise 1.2.5 → 1.2.7
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"]>;
|
|
@@ -51,6 +51,11 @@ function createDedupChecker() {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// src/formatter.ts
|
|
54
|
+
var SEPARATOR = `
|
|
55
|
+
|
|
56
|
+
────────────────────
|
|
57
|
+
|
|
58
|
+
`;
|
|
54
59
|
var TYPE_MAP = {
|
|
55
60
|
idle: "info",
|
|
56
61
|
question: "warning",
|
|
@@ -84,9 +89,7 @@ function formatNotification(payload) {
|
|
|
84
89
|
parts.push(`\uD83E\uDD16 RESPONSE: ${context.agentResponse}`);
|
|
85
90
|
if (context.todoStatus)
|
|
86
91
|
parts.push(`\uD83D\uDCCB TODO: ${context.todoStatus}`);
|
|
87
|
-
body = parts.join(
|
|
88
|
-
|
|
89
|
-
`);
|
|
92
|
+
body = parts.join(SEPARATOR);
|
|
90
93
|
break;
|
|
91
94
|
}
|
|
92
95
|
case "question": {
|
|
@@ -100,20 +103,18 @@ function formatNotification(payload) {
|
|
|
100
103
|
${context.options.map((option, index) => ` ${index + 1}. ${option}`).join(`
|
|
101
104
|
`)}`);
|
|
102
105
|
}
|
|
103
|
-
body = parts.join(
|
|
104
|
-
|
|
105
|
-
`);
|
|
106
|
+
body = parts.join(SEPARATOR);
|
|
106
107
|
break;
|
|
107
108
|
}
|
|
108
109
|
case "permission": {
|
|
109
110
|
const parts = [];
|
|
111
|
+
if (context.sessionTitle)
|
|
112
|
+
parts.push(`\uD83D\uDCCC TITLE: ${context.sessionTitle}`);
|
|
110
113
|
if (context.toolName)
|
|
111
114
|
parts.push(`\uD83D\uDD27 TOOL: ${context.toolName}`);
|
|
112
115
|
if (context.action)
|
|
113
116
|
parts.push(`⚡ ACTION: ${context.action}`);
|
|
114
|
-
body = parts.join(
|
|
115
|
-
|
|
116
|
-
`);
|
|
117
|
+
body = parts.join(SEPARATOR);
|
|
117
118
|
break;
|
|
118
119
|
}
|
|
119
120
|
default:
|
|
@@ -296,7 +297,7 @@ function createIdleHook(ctx, config, dedup, delayMs = 30000) {
|
|
|
296
297
|
}
|
|
297
298
|
|
|
298
299
|
// src/hooks/permission.ts
|
|
299
|
-
function createPermissionHooks(config, dedup) {
|
|
300
|
+
function createPermissionHooks(ctx, config, dedup) {
|
|
300
301
|
const notifiedPermissions = new Set;
|
|
301
302
|
const permissionAsk = async (input, _output) => {
|
|
302
303
|
const permId = input.id ?? "unknown";
|
|
@@ -306,7 +307,17 @@ function createPermissionHooks(config, dedup) {
|
|
|
306
307
|
const title = input.title ?? "Unknown";
|
|
307
308
|
const pattern = input.pattern;
|
|
308
309
|
const action = Array.isArray(pattern) ? pattern.join(", ") : pattern ?? "Unknown";
|
|
310
|
+
const sessionID = input.sessionID;
|
|
311
|
+
let sessionTitle;
|
|
312
|
+
if (sessionID) {
|
|
313
|
+
try {
|
|
314
|
+
const sessionResponse = await ctx.client.session.get({ path: { id: sessionID } });
|
|
315
|
+
const sessionInfo = sessionResponse.data;
|
|
316
|
+
sessionTitle = sessionInfo.title || undefined;
|
|
317
|
+
} catch {}
|
|
318
|
+
}
|
|
309
319
|
const payload = createPayload("permission", "\uD83D\uDD10 OpenCode Permission Required", {
|
|
320
|
+
sessionTitle,
|
|
310
321
|
toolName: title,
|
|
311
322
|
action
|
|
312
323
|
});
|
|
@@ -321,7 +332,17 @@ function createPermissionHooks(config, dedup) {
|
|
|
321
332
|
if (notifiedPermissions.has(permId))
|
|
322
333
|
return;
|
|
323
334
|
notifiedPermissions.add(permId);
|
|
335
|
+
let sessionTitle;
|
|
336
|
+
const sessionID = props.sessionID;
|
|
337
|
+
if (sessionID) {
|
|
338
|
+
try {
|
|
339
|
+
const sessionResponse = await ctx.client.session.get({ path: { id: sessionID } });
|
|
340
|
+
const sessionInfo = sessionResponse.data;
|
|
341
|
+
sessionTitle = sessionInfo.title || undefined;
|
|
342
|
+
} catch {}
|
|
343
|
+
}
|
|
324
344
|
const payload = createPayload("permission", "\uD83D\uDD10 OpenCode Permission Required", {
|
|
345
|
+
sessionTitle,
|
|
325
346
|
toolName: props.permission ?? "Unknown",
|
|
326
347
|
action: props.patterns?.join(", ") ?? "Unknown"
|
|
327
348
|
});
|
|
@@ -331,7 +352,7 @@ function createPermissionHooks(config, dedup) {
|
|
|
331
352
|
}
|
|
332
353
|
|
|
333
354
|
// src/hooks/question.ts
|
|
334
|
-
function createQuestionHook(config, dedup, delayMs = 30000) {
|
|
355
|
+
function createQuestionHook(ctx, config, dedup, delayMs = 30000) {
|
|
335
356
|
const timers = new Map;
|
|
336
357
|
return async ({ event }) => {
|
|
337
358
|
const eventType = event.type;
|
|
@@ -353,9 +374,17 @@ function createQuestionHook(config, dedup, delayMs = 30000) {
|
|
|
353
374
|
const question = firstQuestion.question;
|
|
354
375
|
const options = firstQuestion.options.map((opt) => opt.label);
|
|
355
376
|
const requestId = props.id;
|
|
377
|
+
const sessionID = props.sessionID;
|
|
356
378
|
const timer = setTimeout(async () => {
|
|
357
379
|
timers.delete(requestId);
|
|
380
|
+
let sessionTitle;
|
|
381
|
+
try {
|
|
382
|
+
const sessionResponse = await ctx.client.session.get({ path: { id: sessionID } });
|
|
383
|
+
const sessionInfo = sessionResponse.data;
|
|
384
|
+
sessionTitle = sessionInfo.title || undefined;
|
|
385
|
+
} catch {}
|
|
358
386
|
const payload = createPayload("question", "❓ OpenCode Question", {
|
|
387
|
+
sessionTitle,
|
|
359
388
|
question,
|
|
360
389
|
options: options.length > 0 ? options : undefined
|
|
361
390
|
});
|
|
@@ -384,8 +413,8 @@ var plugin = async (input) => {
|
|
|
384
413
|
}
|
|
385
414
|
const dedup = createDedupChecker();
|
|
386
415
|
const idleHook = createIdleHook(input, config, dedup);
|
|
387
|
-
const questionHook = createQuestionHook(config, dedup);
|
|
388
|
-
const permissionHooks = createPermissionHooks(config, dedup);
|
|
416
|
+
const questionHook = createQuestionHook(input, config, dedup);
|
|
417
|
+
const permissionHooks = createPermissionHooks(input, config, dedup);
|
|
389
418
|
const combinedEventHook = async ({ event }) => {
|
|
390
419
|
await questionHook({ event });
|
|
391
420
|
await permissionHooks.eventFallback({ event });
|
package/package.json
CHANGED