@coinseeker/opencode-telegram-plugin 1.0.7 → 1.0.9

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.7"]
18
+ "plugin": ["@coinseeker/opencode-telegram-plugin@1.0.9"]
19
19
  }
20
20
  ```
21
21
 
22
- Current stable version: `@coinseeker/opencode-telegram-plugin@1.0.7`.
22
+ Current stable version: `@coinseeker/opencode-telegram-plugin@1.0.9`.
23
23
 
24
24
  Restart OpenCode after editing the config. OpenCode resolves npm package plugins on startup.
25
25
 
@@ -45,7 +45,6 @@ function createTelegramBot(opts) {
45
45
  let activeChatId = opts.initialChatId;
46
46
  let questionDispatcher;
47
47
  let permissionDispatcher;
48
- let startWorkDispatcher;
49
48
  if (polling) {
50
49
  bot.use(async (ctx, next) => {
51
50
  const userId = ctx.from?.id;
@@ -98,13 +97,6 @@ This chat is now active for OpenCode notifications.`
98
97
  if (!permissionDispatcher || messageId === void 0) return;
99
98
  await permissionDispatcher.handleCallbackQuery(data, messageId);
100
99
  });
101
- bot.callbackQuery(/^sw:(.+)$/, async (ctx) => {
102
- await ctx.answerCallbackQuery();
103
- const data = ctx.callbackQuery.data;
104
- const messageId = ctx.callbackQuery.message?.message_id;
105
- if (!startWorkDispatcher || messageId === void 0) return;
106
- await startWorkDispatcher.handleCallbackQuery(data, messageId);
107
- });
108
100
  bot.on("message:text", async (ctx) => {
109
101
  const replyToMessageId = ctx.message.reply_to_message?.message_id;
110
102
  const chatId = ctx.chat.id;
@@ -198,9 +190,6 @@ This chat is now active for OpenCode notifications.`
198
190
  },
199
191
  setPermissionDispatcher(dispatcher) {
200
192
  permissionDispatcher = dispatcher;
201
- },
202
- setStartWorkDispatcher(dispatcher) {
203
- startWorkDispatcher = dispatcher;
204
193
  }
205
194
  };
206
195
  }
@@ -953,46 +942,6 @@ async function handleSessionError(event, ctx) {
953
942
  ctx.logger.info("session abort recorded", { sessionId: event.properties.sessionID ?? "global" });
954
943
  }
955
944
 
956
- // src/events/start-work.ts
957
- var CALLBACK_RE3 = /^sw:(.+)$/;
958
- var START_WORK_COMMAND = "start-work";
959
- function startWorkCallbackData(sessionID) {
960
- const data = `sw:${encodeURIComponent(sessionID)}`;
961
- return Buffer.byteLength(data, "utf8") <= 64 ? data : void 0;
962
- }
963
- function startWorkKeyboard(sessionID) {
964
- const callbackData = startWorkCallbackData(sessionID);
965
- if (!callbackData) return void 0;
966
- return [[{ text: "\u25B6\uFE0F Run /start-work", callback_data: callbackData }]];
967
- }
968
- function createStartWorkDispatcher(ctx) {
969
- return {
970
- async handleCallbackQuery(data, messageId) {
971
- const match = CALLBACK_RE3.exec(data);
972
- if (!match) return;
973
- const sessionID = decodeURIComponent(match[1]);
974
- try {
975
- await ctx.runSessionCommand(sessionID, START_WORK_COMMAND);
976
- await ctx.bot.editMessageRemoveKeyboard(
977
- messageId,
978
- `\u25B6\uFE0F Sent /start-work to opencode.
979
-
980
- Session: ${sessionID}`
981
- );
982
- ctx.logger.info("start-work command sent", { sessionID });
983
- } catch (err) {
984
- await ctx.bot.editMessageRemoveKeyboard(
985
- messageId,
986
- `\u26A0\uFE0F Failed to send /start-work to opencode.
987
-
988
- Session: ${sessionID}`
989
- );
990
- ctx.logger.error("failed to send start-work command", { sessionID, error: String(err) });
991
- }
992
- }
993
- };
994
- }
995
-
996
945
  // src/events/session-idle.ts
997
946
  var ROOT_IDLE_RECHECK_DELAY_MS = 2500;
998
947
  function sleep(ms) {
@@ -1039,15 +988,9 @@ async function sendIdleNotification(sessionId, ctx) {
1039
988
  });
1040
989
  if (!claimed) return;
1041
990
  const title = ctx.sessionTitleService.getSessionTitle(sessionId);
1042
- const message = title ? `Agent has finished: ${title}
1043
-
1044
- If this was a plan builder session, tap below to run /start-work.` : "Agent has finished.\n\nIf this was a plan builder session, tap below to run /start-work.";
1045
- const keyboard = startWorkKeyboard(sessionId);
991
+ const text = title ? `Agent has finished: ${title}` : "Agent has finished.";
1046
992
  try {
1047
- await ctx.bot.sendMessage(
1048
- message,
1049
- keyboard ? { reply_markup: { inline_keyboard: keyboard } } : void 0
1050
- );
993
+ await ctx.bot.sendMessage(text);
1051
994
  ctx.sessionTitleService.clearDeferredIdleNotification(sessionId);
1052
995
  ctx.logger.info("idle notification sent", { sessionId, title });
1053
996
  } catch (err) {
@@ -1478,13 +1421,6 @@ var TelegramRemote = async (input) => {
1478
1421
  throwOnError: true
1479
1422
  });
1480
1423
  };
1481
- const runSessionCommand = async (sessionID, command) => {
1482
- await input.client.session.command({
1483
- path: { id: sessionID },
1484
- body: { command, arguments: "" },
1485
- throwOnError: true
1486
- });
1487
- };
1488
1424
  const bot = createTelegramBot({
1489
1425
  config,
1490
1426
  stateStore,
@@ -1530,13 +1466,11 @@ var TelegramRemote = async (input) => {
1530
1466
  pendingQuestions,
1531
1467
  pendingPermissions,
1532
1468
  replyToQuestion,
1533
- replyToPermission,
1534
- runSessionCommand
1469
+ replyToPermission
1535
1470
  };
1536
1471
  if (isLeader) {
1537
1472
  bot.setQuestionDispatcher(createQuestionDispatcher(ctx));
1538
1473
  bot.setPermissionDispatcher(createPermissionDispatcher(ctx));
1539
- bot.setStartWorkDispatcher(createStartWorkDispatcher(ctx));
1540
1474
  }
1541
1475
  return {
1542
1476
  event: async ({ event }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinseeker/opencode-telegram-plugin",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
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",