opencode-plugin-apprise 1.2.6 → 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"]>;
|
|
@@ -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)
|
|
@@ -295,7 +297,7 @@ function createIdleHook(ctx, config, dedup, delayMs = 30000) {
|
|
|
295
297
|
}
|
|
296
298
|
|
|
297
299
|
// src/hooks/permission.ts
|
|
298
|
-
function createPermissionHooks(config, dedup) {
|
|
300
|
+
function createPermissionHooks(ctx, config, dedup) {
|
|
299
301
|
const notifiedPermissions = new Set;
|
|
300
302
|
const permissionAsk = async (input, _output) => {
|
|
301
303
|
const permId = input.id ?? "unknown";
|
|
@@ -305,7 +307,17 @@ function createPermissionHooks(config, dedup) {
|
|
|
305
307
|
const title = input.title ?? "Unknown";
|
|
306
308
|
const pattern = input.pattern;
|
|
307
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
|
+
}
|
|
308
319
|
const payload = createPayload("permission", "\uD83D\uDD10 OpenCode Permission Required", {
|
|
320
|
+
sessionTitle,
|
|
309
321
|
toolName: title,
|
|
310
322
|
action
|
|
311
323
|
});
|
|
@@ -320,7 +332,17 @@ function createPermissionHooks(config, dedup) {
|
|
|
320
332
|
if (notifiedPermissions.has(permId))
|
|
321
333
|
return;
|
|
322
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
|
+
}
|
|
323
344
|
const payload = createPayload("permission", "\uD83D\uDD10 OpenCode Permission Required", {
|
|
345
|
+
sessionTitle,
|
|
324
346
|
toolName: props.permission ?? "Unknown",
|
|
325
347
|
action: props.patterns?.join(", ") ?? "Unknown"
|
|
326
348
|
});
|
|
@@ -330,7 +352,7 @@ function createPermissionHooks(config, dedup) {
|
|
|
330
352
|
}
|
|
331
353
|
|
|
332
354
|
// src/hooks/question.ts
|
|
333
|
-
function createQuestionHook(config, dedup, delayMs = 30000) {
|
|
355
|
+
function createQuestionHook(ctx, config, dedup, delayMs = 30000) {
|
|
334
356
|
const timers = new Map;
|
|
335
357
|
return async ({ event }) => {
|
|
336
358
|
const eventType = event.type;
|
|
@@ -352,9 +374,17 @@ function createQuestionHook(config, dedup, delayMs = 30000) {
|
|
|
352
374
|
const question = firstQuestion.question;
|
|
353
375
|
const options = firstQuestion.options.map((opt) => opt.label);
|
|
354
376
|
const requestId = props.id;
|
|
377
|
+
const sessionID = props.sessionID;
|
|
355
378
|
const timer = setTimeout(async () => {
|
|
356
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 {}
|
|
357
386
|
const payload = createPayload("question", "❓ OpenCode Question", {
|
|
387
|
+
sessionTitle,
|
|
358
388
|
question,
|
|
359
389
|
options: options.length > 0 ? options : undefined
|
|
360
390
|
});
|
|
@@ -383,8 +413,8 @@ var plugin = async (input) => {
|
|
|
383
413
|
}
|
|
384
414
|
const dedup = createDedupChecker();
|
|
385
415
|
const idleHook = createIdleHook(input, config, dedup);
|
|
386
|
-
const questionHook = createQuestionHook(config, dedup);
|
|
387
|
-
const permissionHooks = createPermissionHooks(config, dedup);
|
|
416
|
+
const questionHook = createQuestionHook(input, config, dedup);
|
|
417
|
+
const permissionHooks = createPermissionHooks(input, config, dedup);
|
|
388
418
|
const combinedEventHook = async ({ event }) => {
|
|
389
419
|
await questionHook({ event });
|
|
390
420
|
await permissionHooks.eventFallback({ event });
|
package/package.json
CHANGED