@coinseeker/opencode-telegram-plugin 1.1.2 → 1.1.3
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 -3
- package/dist/telegram-remote.js +50 -6
- package/package.json +1 -1
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.
|
|
18
|
+
"plugin": ["@coinseeker/opencode-telegram-plugin@1.1.3"]
|
|
19
19
|
}
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Current stable version: `@coinseeker/opencode-telegram-plugin@1.1.
|
|
22
|
+
Current stable version: `@coinseeker/opencode-telegram-plugin@1.1.3`.
|
|
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.
|
|
26
|
+
To update an existing install, replace the previous pinned package entry with `@coinseeker/opencode-telegram-plugin@1.1.3`, keep the rest of the `plugin` array unchanged, and restart OpenCode.
|
|
27
27
|
|
|
28
28
|
## Configure Telegram
|
|
29
29
|
|
package/dist/telegram-remote.js
CHANGED
|
@@ -384,6 +384,8 @@ function parsePending(text) {
|
|
|
384
384
|
throw new Error("Invalid pending permission: requestID");
|
|
385
385
|
if (typeof parsed.sessionID !== "string")
|
|
386
386
|
throw new Error("Invalid pending permission: sessionID");
|
|
387
|
+
if (parsed.directory !== void 0 && typeof parsed.directory !== "string")
|
|
388
|
+
throw new Error("Invalid pending permission: directory");
|
|
387
389
|
if (typeof parsed.title !== "string") throw new Error("Invalid pending permission: title");
|
|
388
390
|
if (typeof parsed.permission !== "string")
|
|
389
391
|
throw new Error("Invalid pending permission: permission");
|
|
@@ -537,10 +539,34 @@ function replyLabel(reply) {
|
|
|
537
539
|
if (reply === "always") return "Always allowed";
|
|
538
540
|
return "Rejected";
|
|
539
541
|
}
|
|
542
|
+
async function upgradeLegacyPendingPermission(permission, ctx) {
|
|
543
|
+
const found = await ctx.pendingPermissions.findByRequestID(
|
|
544
|
+
permission.requestID,
|
|
545
|
+
permission.sessionID,
|
|
546
|
+
ctx.serverUrl.href
|
|
547
|
+
);
|
|
548
|
+
if (!found || found.data.endpoint === "request") return;
|
|
549
|
+
await ctx.pendingPermissions.savePending(found.shortHash, {
|
|
550
|
+
...found.data,
|
|
551
|
+
directory: ctx.directory,
|
|
552
|
+
title: permission.title,
|
|
553
|
+
permission: permission.permission,
|
|
554
|
+
patterns: permission.patterns,
|
|
555
|
+
always: permission.always,
|
|
556
|
+
endpoint: "request"
|
|
557
|
+
});
|
|
558
|
+
ctx.logger.info("permission pending upgraded to request endpoint", {
|
|
559
|
+
requestID: permission.requestID,
|
|
560
|
+
sessionID: permission.sessionID
|
|
561
|
+
});
|
|
562
|
+
}
|
|
540
563
|
async function handleNormalizedPermission(permission, ctx) {
|
|
541
564
|
const permissionKey = `${ctx.serverUrl.href}:${permission.sessionID}:${permission.requestID}`;
|
|
542
565
|
const claimed = await claimOnce({ claimsDir: ctx.claimsDir, key: `permission:${permissionKey}` });
|
|
543
|
-
if (!claimed)
|
|
566
|
+
if (!claimed) {
|
|
567
|
+
if (permission.endpoint === "request") await upgradeLegacyPendingPermission(permission, ctx);
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
544
570
|
const shortHash = createPermissionShortHash(
|
|
545
571
|
permission.requestID,
|
|
546
572
|
permission.sessionID,
|
|
@@ -558,6 +584,7 @@ async function handleNormalizedPermission(permission, ctx) {
|
|
|
558
584
|
requestID: permission.requestID,
|
|
559
585
|
sessionID: permission.sessionID,
|
|
560
586
|
serverUrl: ctx.serverUrl.href,
|
|
587
|
+
directory: ctx.directory,
|
|
561
588
|
title: permission.title,
|
|
562
589
|
permission: permission.permission,
|
|
563
590
|
patterns: permission.patterns,
|
|
@@ -641,7 +668,8 @@ function createPermissionDispatcher(ctx) {
|
|
|
641
668
|
pending.sessionID,
|
|
642
669
|
reply,
|
|
643
670
|
pending.endpoint,
|
|
644
|
-
pending.serverUrl
|
|
671
|
+
pending.serverUrl,
|
|
672
|
+
pending.directory
|
|
645
673
|
);
|
|
646
674
|
await ctx.bot.editMessageRemoveKeyboard(
|
|
647
675
|
messageId,
|
|
@@ -661,7 +689,10 @@ ${pending.permission}: ${pending.title}`
|
|
|
661
689
|
);
|
|
662
690
|
ctx.logger.error("failed to send permission reply", {
|
|
663
691
|
error: String(err),
|
|
664
|
-
requestID: pending.requestID
|
|
692
|
+
requestID: pending.requestID,
|
|
693
|
+
endpoint: pending.endpoint,
|
|
694
|
+
serverUrl: pending.serverUrl,
|
|
695
|
+
directory: pending.directory
|
|
665
696
|
});
|
|
666
697
|
} finally {
|
|
667
698
|
await ctx.pendingPermissions.deletePending(shortHash);
|
|
@@ -3097,6 +3128,12 @@ var SessionTitleService = class {
|
|
|
3097
3128
|
|
|
3098
3129
|
// src/telegram-remote.ts
|
|
3099
3130
|
var pluginDir = dirname6(fileURLToPath(import.meta.url));
|
|
3131
|
+
function withDirectoryQuery(path, directory) {
|
|
3132
|
+
if (directory === void 0) return path;
|
|
3133
|
+
const url = new URL(path, "http://opencode.local");
|
|
3134
|
+
url.searchParams.set("directory", directory);
|
|
3135
|
+
return `${url.pathname}${url.search}`;
|
|
3136
|
+
}
|
|
3100
3137
|
async function postToServer(serverUrl, path, body) {
|
|
3101
3138
|
const safeServerUrl = normalizeOpenCodeServerUrl(serverUrl);
|
|
3102
3139
|
if (!safeServerUrl) throw new Error("Invalid OpenCode server URL");
|
|
@@ -3169,9 +3206,12 @@ var TelegramRemote = async (input) => {
|
|
|
3169
3206
|
throwOnError: true
|
|
3170
3207
|
});
|
|
3171
3208
|
};
|
|
3172
|
-
const replyToPermission = async (requestID, sessionID, reply, endpoint2, serverUrl = input.serverUrl.href) => {
|
|
3209
|
+
const replyToPermission = async (requestID, sessionID, reply, endpoint2, serverUrl = input.serverUrl.href, directory = input.directory) => {
|
|
3173
3210
|
if (endpoint2 === "request") {
|
|
3174
|
-
const path2 =
|
|
3211
|
+
const path2 = withDirectoryQuery(
|
|
3212
|
+
`/permission/${encodeURIComponent(requestID)}/reply`,
|
|
3213
|
+
directory
|
|
3214
|
+
);
|
|
3175
3215
|
if (serverUrl !== input.serverUrl.href) {
|
|
3176
3216
|
await postToServer(serverUrl, path2, { reply });
|
|
3177
3217
|
return;
|
|
@@ -3184,7 +3224,10 @@ var TelegramRemote = async (input) => {
|
|
|
3184
3224
|
});
|
|
3185
3225
|
return;
|
|
3186
3226
|
}
|
|
3187
|
-
const path =
|
|
3227
|
+
const path = withDirectoryQuery(
|
|
3228
|
+
`/session/${encodeURIComponent(sessionID)}/permissions/${encodeURIComponent(requestID)}`,
|
|
3229
|
+
directory
|
|
3230
|
+
);
|
|
3188
3231
|
if (serverUrl !== input.serverUrl.href) {
|
|
3189
3232
|
await postToServer(serverUrl, path, { response: reply });
|
|
3190
3233
|
return;
|
|
@@ -3286,6 +3329,7 @@ var TelegramRemote = async (input) => {
|
|
|
3286
3329
|
claimsDir,
|
|
3287
3330
|
pluginDir,
|
|
3288
3331
|
serverUrl: input.serverUrl,
|
|
3332
|
+
directory: input.directory,
|
|
3289
3333
|
tokenHash,
|
|
3290
3334
|
pendingQuestions,
|
|
3291
3335
|
pendingPermissions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinseeker/opencode-telegram-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
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",
|