@coinseeker/opencode-telegram-plugin 1.0.4 → 1.0.5
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 +3 -1
- package/dist/telegram-remote.js +38 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,10 +15,12 @@ Configure the npm package in `~/.config/opencode/opencode.json`:
|
|
|
15
15
|
|
|
16
16
|
```json
|
|
17
17
|
{
|
|
18
|
-
"plugin": ["@coinseeker/opencode-telegram-plugin"]
|
|
18
|
+
"plugin": ["@coinseeker/opencode-telegram-plugin@1.0.5"]
|
|
19
19
|
}
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
Current stable version: `@coinseeker/opencode-telegram-plugin@1.0.5`.
|
|
23
|
+
|
|
22
24
|
Restart OpenCode after editing the config. OpenCode resolves npm package plugins on startup.
|
|
23
25
|
|
|
24
26
|
## Configure Telegram
|
package/dist/telegram-remote.js
CHANGED
|
@@ -772,6 +772,10 @@ function shouldSuppressIdle(sessionID) {
|
|
|
772
772
|
}
|
|
773
773
|
|
|
774
774
|
// src/events/session-idle.ts
|
|
775
|
+
var ROOT_IDLE_RECHECK_DELAY_MS = 2500;
|
|
776
|
+
function sleep(ms) {
|
|
777
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
778
|
+
}
|
|
775
779
|
async function resolveParentID(sessionId, ctx) {
|
|
776
780
|
const cachedParentID = ctx.sessionTitleService.getParentID(sessionId);
|
|
777
781
|
if (cachedParentID !== void 0) return cachedParentID;
|
|
@@ -788,6 +792,19 @@ async function resolveParentID(sessionId, ctx) {
|
|
|
788
792
|
return void 0;
|
|
789
793
|
}
|
|
790
794
|
}
|
|
795
|
+
async function hydrateDescendants(sessionId, ctx, seen = /* @__PURE__ */ new Set()) {
|
|
796
|
+
if (seen.has(sessionId)) return;
|
|
797
|
+
seen.add(sessionId);
|
|
798
|
+
try {
|
|
799
|
+
const result = await ctx.client.session.children({ path: { id: sessionId } });
|
|
800
|
+
for (const child of result.data ?? []) {
|
|
801
|
+
ctx.sessionTitleService.setSessionInfo(child);
|
|
802
|
+
await hydrateDescendants(child.id, ctx, seen);
|
|
803
|
+
}
|
|
804
|
+
} catch (err) {
|
|
805
|
+
ctx.logger.warn("session children fetch failed", { sessionId, error: String(err) });
|
|
806
|
+
}
|
|
807
|
+
}
|
|
791
808
|
async function sendIdleNotification(sessionId, ctx) {
|
|
792
809
|
if (shouldSuppressIdle(sessionId)) {
|
|
793
810
|
ctx.logger.info("idle suppressed - session was aborted", { sessionId });
|
|
@@ -808,9 +825,21 @@ async function sendIdleNotification(sessionId, ctx) {
|
|
|
808
825
|
async function flushDeferredParentIfReady(parentID, ctx) {
|
|
809
826
|
if (!ctx.sessionTitleService.hasDeferredIdleNotification(parentID)) return;
|
|
810
827
|
if (ctx.sessionTitleService.hasUnfinishedDescendants(parentID)) return;
|
|
828
|
+
if (ctx.sessionTitleService.getSessionStatus(parentID) !== "idle") {
|
|
829
|
+
ctx.sessionTitleService.clearDeferredIdleNotification(parentID);
|
|
830
|
+
ctx.logger.info("clearing deferred parent idle notification - parent resumed", { sessionId: parentID });
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
811
833
|
ctx.logger.info("sending deferred parent idle notification", { sessionId: parentID });
|
|
812
834
|
await sendIdleNotification(parentID, ctx);
|
|
813
835
|
}
|
|
836
|
+
async function deferParentIdleIfDescendantsRunning(sessionId, ctx) {
|
|
837
|
+
await hydrateDescendants(sessionId, ctx);
|
|
838
|
+
if (!ctx.sessionTitleService.hasUnfinishedDescendants(sessionId)) return false;
|
|
839
|
+
ctx.sessionTitleService.deferIdleNotification(sessionId);
|
|
840
|
+
ctx.logger.info("deferring parent idle notification - child sessions still running", { sessionId });
|
|
841
|
+
return true;
|
|
842
|
+
}
|
|
814
843
|
async function handleSessionIdle(event, ctx) {
|
|
815
844
|
const sessionId = event.properties.sessionID;
|
|
816
845
|
ctx.sessionTitleService.setSessionStatus(sessionId, "idle");
|
|
@@ -823,9 +852,15 @@ async function handleSessionIdle(event, ctx) {
|
|
|
823
852
|
if (parentID === void 0) {
|
|
824
853
|
ctx.logger.warn("session parentID unknown; sending idle notification", { sessionId });
|
|
825
854
|
}
|
|
826
|
-
if (
|
|
827
|
-
|
|
828
|
-
|
|
855
|
+
if (await deferParentIdleIfDescendantsRunning(sessionId, ctx)) {
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
await sleep(ctx.idleRecheckDelayMs ?? ROOT_IDLE_RECHECK_DELAY_MS);
|
|
859
|
+
if (ctx.sessionTitleService.getSessionStatus(sessionId) !== "idle") {
|
|
860
|
+
ctx.logger.info("idle notification skipped - session resumed during recheck delay", { sessionId });
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
if (await deferParentIdleIfDescendantsRunning(sessionId, ctx)) {
|
|
829
864
|
return;
|
|
830
865
|
}
|
|
831
866
|
await sendIdleNotification(sessionId, ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinseeker/opencode-telegram-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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",
|