@coinseeker/opencode-telegram-plugin 1.1.5 → 1.1.6

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,15 +15,15 @@ Configure the npm package in `~/.config/opencode/opencode.json`:
15
15
 
16
16
  ```json
17
17
  {
18
- "plugin": ["@coinseeker/opencode-telegram-plugin@1.1.4"]
18
+ "plugin": ["@coinseeker/opencode-telegram-plugin@1.1.6"]
19
19
  }
20
20
  ```
21
21
 
22
- Current stable version: `@coinseeker/opencode-telegram-plugin@1.1.4`.
22
+ Current stable version: `@coinseeker/opencode-telegram-plugin@1.1.6`.
23
23
 
24
24
  Restart OpenCode after editing the config. OpenCode resolves npm package plugins on startup.
25
25
 
26
- To update an existing install, replace the previous pinned package entry with `@coinseeker/opencode-telegram-plugin@1.1.4`, keep the rest of the `plugin` array unchanged, and restart OpenCode.
26
+ To update an existing install, replace the previous pinned package entry with `@coinseeker/opencode-telegram-plugin@1.1.6`, keep the rest of the `plugin` array unchanged, and restart OpenCode.
27
27
 
28
28
  ## Configure Telegram
29
29
 
@@ -1474,8 +1474,8 @@ async function handleSessionError(event, ctx) {
1474
1474
  // src/lib/plan-agent.ts
1475
1475
  function isPlanSessionAgent(agent) {
1476
1476
  if (!agent) return false;
1477
- const normalized = agent.trim().replace(/[–—]/g, "-").replace(/\s+/g, " ").toLowerCase();
1478
- return normalized === "plan" || normalized === "prometheus" || normalized === "prometheus - plan builder" || normalized === "prometheus (plan builder)";
1477
+ const normalized = agent.normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g, "").replace(/[‐‑‒–—―]/g, "-").replace(/\s+/g, " ").replace(/\s*-\s*/g, " - ").trim().toLowerCase();
1478
+ return normalized === "plan" || normalized === "prometheus" || normalized === "prometheus - plan builder" || normalized === "prometheus (plan builder)" || normalized.includes("prometheus") && normalized.includes("plan builder");
1479
1479
  }
1480
1480
 
1481
1481
  // src/lib/pending-start-work.ts
@@ -1663,6 +1663,34 @@ function agentFinishedMessage(title, agent) {
1663
1663
  const base = title ? `Agent has finished: ${title}` : "Agent has finished.";
1664
1664
  return agent ? `${base} (${agent})` : base;
1665
1665
  }
1666
+ function selectPlanSessionAgent(candidates) {
1667
+ return candidates.find(isPlanSessionAgent) ?? candidates.find((agent) => agent !== void 0);
1668
+ }
1669
+ async function resolveSessionAgent(sessionId, ctx) {
1670
+ const candidates = [
1671
+ ctx.sessionTitleService.getSessionAgent(sessionId)
1672
+ ];
1673
+ try {
1674
+ const registryEntry = (await ctx.sessionRegistry.listSessions()).find(
1675
+ (entry) => entry.sessionId === sessionId
1676
+ );
1677
+ candidates.push(registryEntry?.agent);
1678
+ } catch (err) {
1679
+ ctx.logger.warn("session registry agent lookup failed", { sessionId, error: String(err) });
1680
+ }
1681
+ try {
1682
+ const result = await ctx.client.session.get({ path: { id: sessionId } });
1683
+ if (result.data) {
1684
+ ctx.sessionTitleService.setSessionInfo(result.data);
1685
+ candidates.push(ctx.sessionTitleService.getSessionAgent(sessionId));
1686
+ }
1687
+ } catch (err) {
1688
+ ctx.logger.warn("session agent live lookup failed", { sessionId, error: String(err) });
1689
+ }
1690
+ const agent = selectPlanSessionAgent(candidates);
1691
+ if (agent !== void 0) ctx.sessionTitleService.setSessionAgent(sessionId, agent);
1692
+ return agent;
1693
+ }
1666
1694
  function cancelDeferredParentConfirm(sessionId) {
1667
1695
  const timer = deferredConfirmTimers.get(sessionId);
1668
1696
  if (timer === void 0) return;
@@ -1724,7 +1752,7 @@ async function sendIdleNotification(sessionId, ctx) {
1724
1752
  });
1725
1753
  if (!claimed) return;
1726
1754
  const title = ctx.sessionTitleService.getSessionTitle(sessionId);
1727
- const agent = ctx.sessionTitleService.getSessionAgent(sessionId);
1755
+ const agent = await resolveSessionAgent(sessionId, ctx);
1728
1756
  const isPlanSession = isPlanSessionAgent(agent);
1729
1757
  const text = isPlanSession ? planCompleteMessage(title) : agentFinishedMessage(title, agent);
1730
1758
  try {
@@ -1747,7 +1775,7 @@ async function sendIdleNotification(sessionId, ctx) {
1747
1775
  await ctx.bot.sendMessage(text);
1748
1776
  }
1749
1777
  ctx.sessionTitleService.clearDeferredIdleNotification(sessionId);
1750
- ctx.logger.info("idle notification sent", { sessionId, title });
1778
+ ctx.logger.info("idle notification sent", { sessionId, title, agent, isPlanSession });
1751
1779
  } catch (err) {
1752
1780
  ctx.logger.error("failed to send idle notification", { error: String(err) });
1753
1781
  }
@@ -2523,6 +2551,9 @@ function agentFromSession3(session) {
2523
2551
  function resolveProjectRoot2(session) {
2524
2552
  return session.directory;
2525
2553
  }
2554
+ function selectPlanSessionAgent2(candidates) {
2555
+ return candidates.find(isPlanSessionAgent) ?? candidates.find((agent) => agent !== void 0);
2556
+ }
2526
2557
  function readinessMessage(reason) {
2527
2558
  switch (reason) {
2528
2559
  case "no-omo-dir":
@@ -2638,7 +2669,11 @@ function createStartWorkCommandDispatcher(deps) {
2638
2669
  deps.logger.error("start-work session lookup failed", { sessionId, error: String(err) });
2639
2670
  return;
2640
2671
  }
2641
- const agent = deps.sessionTitleService.getSessionAgent(sessionId) ?? agentFromSession3(session) ?? entry.agent;
2672
+ const agent = selectPlanSessionAgent2([
2673
+ deps.sessionTitleService.getSessionAgent(sessionId),
2674
+ entry.agent,
2675
+ agentFromSession3(session)
2676
+ ]);
2642
2677
  if (!isPlanSessionAgent(agent)) {
2643
2678
  await sendPlain(
2644
2679
  bot,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinseeker/opencode-telegram-plugin",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
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",