@coinseeker/opencode-telegram-plugin 1.0.11 → 1.0.12

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
@@ -15,11 +15,11 @@ Configure the npm package in `~/.config/opencode/opencode.json`:
15
15
 
16
16
  ```json
17
17
  {
18
- "plugin": ["@coinseeker/opencode-telegram-plugin@1.0.11"]
18
+ "plugin": ["@coinseeker/opencode-telegram-plugin@1.0.12"]
19
19
  }
20
20
  ```
21
21
 
22
- Current stable version: `@coinseeker/opencode-telegram-plugin@1.0.11`.
22
+ Current stable version: `@coinseeker/opencode-telegram-plugin@1.0.12`.
23
23
 
24
24
  Restart OpenCode after editing the config. OpenCode resolves npm package plugins on startup.
25
25
 
@@ -508,6 +508,46 @@ async function handlePermissionUpdated(event, ctx) {
508
508
  async function handlePermissionAsked(event, ctx) {
509
509
  await handleNormalizedPermission(normalizeAsked(event.properties), ctx);
510
510
  }
511
+ function isEventPermissionReplied(event) {
512
+ if (event.type !== "permission.replied") return false;
513
+ const props = event.properties;
514
+ if (!props) return false;
515
+ if (typeof props.sessionID !== "string") return false;
516
+ const hasId = typeof props.permissionID === "string" || typeof props.requestID === "string";
517
+ return hasId;
518
+ }
519
+ function externalReplyLabel(value) {
520
+ if (value === "once") return "Allowed once in opencode";
521
+ if (value === "always") return "Always allowed in opencode";
522
+ if (value === "reject") return "Rejected in opencode";
523
+ return "Already answered in opencode";
524
+ }
525
+ async function handlePermissionReplied(event, ctx) {
526
+ const requestID = event.properties.requestID ?? event.properties.permissionID;
527
+ if (!requestID) return;
528
+ const found = await ctx.pendingPermissions.findByRequestID(requestID);
529
+ if (!found) return;
530
+ const label = externalReplyLabel(event.properties.reply ?? event.properties.response);
531
+ try {
532
+ await ctx.bot.editMessageRemoveKeyboard(
533
+ found.data.telegramMessageId,
534
+ `\u2705 ${label}
535
+
536
+ ${found.data.permission}: ${found.data.title}`
537
+ );
538
+ ctx.logger.info("permission externally replied - cleared pending", {
539
+ requestID,
540
+ sessionID: event.properties.sessionID
541
+ });
542
+ } catch (err) {
543
+ ctx.logger.error("failed to edit externally replied permission", {
544
+ error: String(err),
545
+ requestID
546
+ });
547
+ } finally {
548
+ await ctx.pendingPermissions.deletePending(found.shortHash);
549
+ }
550
+ }
511
551
  function createPermissionDispatcher(ctx) {
512
552
  return {
513
553
  async handleCallbackQuery(data, messageId) {
@@ -1784,6 +1824,9 @@ var TelegramRemote = async (input) => {
1784
1824
  if (isEventQuestionReplied(extEvent)) {
1785
1825
  return handleQuestionReplied(extEvent, ctx);
1786
1826
  }
1827
+ if (isEventPermissionReplied(extEvent)) {
1828
+ return handlePermissionReplied(extEvent, ctx);
1829
+ }
1787
1830
  return;
1788
1831
  }
1789
1832
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinseeker/opencode-telegram-plugin",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Control and monitor OpenCode from Telegram with notifications, question replies, and subagent-aware completion.",
5
5
  "type": "module",
6
6
  "main": "dist/telegram-remote.js",