opencode-feishu-plugin 0.2.1 → 0.2.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.en.md CHANGED
@@ -421,7 +421,7 @@ The plugin ships two built-in layers (both on by default, **no external script r
421
421
  - if the gateway instance was evicted, it is revived automatically as long as **any other Location** still has a loaded instance (e.g. you have a TUI/Web open in another project);
422
422
  - after a **service restart**, the first use of any Location starts the watchdog, which fires an immediate probe after ~3s and brings the gateway back up.
423
423
 
424
- > Still recommended (optional, not required): a cron / systemd timer doing one session-scoped GET every 15–30 minutes, covering the extreme case where the opencode process is down and nothing is used for a long time. See `scripts/keepalive-feishu.sh`. Set `keepalive: false` to disable all keep-alive.
424
+ > **No external script / cron / systemd setup is required**: both layers run inside the plugin process. The only case neither can cover is "the opencode process is fully down and nothing is used for a long time" — no plugin can run then; the watchdog restores the gateway as soon as opencode is used again. Set `keepalive: false` to disable all keep-alive.
425
425
 
426
426
  ---
427
427
 
@@ -473,7 +473,7 @@ otherwise (per session preset) → ask ─────────────
473
473
  | No plugin logs | Plugin stderr is discarded in service mode; set `logFile: true` and read `<configDir>/plugins/feishu.log` |
474
474
  | Main chat replies with a hint card | Expected: the main chat is management-only. Use `/new` and work inside a topic; set `threadRouting: false` to revert |
475
475
  | Session looks stuck and messages only queue | The watchdog auto-interrupts it after `staleExecutionMs` (default 5 min) and cancels the queue, then sends a notice card; you can also tap the card's "⏹ force stop" or send `/stop` |
476
- | **Bot goes completely silent after ~1 hour idle** (no "long connection started" in the log) | OpenCode evicted the idle Location (hardcoded 60-min TTL). The built-in keep-alive is on by default; if it still happens (service restart / long sleep / keep-alive disabled), one session-scoped request re-creates it: `opencode api get /api/session/{id}`, or set up the external cron described under "Location keep-alive" |
476
+ | **Bot goes completely silent after ~1 hour idle** (no "long connection started" in the log) | OpenCode evicted the idle Location (hardcoded 60-min TTL). The built-in keep-alive + process-wide watchdog are on by default and restore it automatically; you can also force it manually with one session-scoped request: `opencode api get /api/session/{id}`. If it never recovers, check that `keepalive` is not set to `false` |
477
477
  | Switched `/model` but older messages still show the old model | Expected: a switch only affects **subsequent** replies; history keeps each message's model. The receipt / run-card footer / `/current` all show the read-back truth |
478
478
 
479
479
  ---
package/README.md CHANGED
@@ -301,7 +301,9 @@ opencode 会**回收空闲的 location**,这会连带卸载插件、关闭飞
301
301
  - **服务重启后**,你第一次使用任意 location 时看门狗即启动(并在约 3 秒后立即探测一次),网关随之上线;
302
302
  - 首次探测带 3 秒延迟,重启后恢复很快。
303
303
 
304
- > 仍建议(可选,非必需):用 cron / systemd timer 每 15–30 分钟做一次「会话级 GET」,覆盖「opencode 进程整个挂掉且长时间无人使用」的极端场景。仓库提供 `scripts/keepalive-feishu.sh` 一键脚本;`keepalive: false` 可关闭全部保活。
304
+ > **不需要任何外部脚本 / cron / systemd 配置**:以上两道防线都在插件进程内完成。
305
+ > 唯一无法覆盖的是「opencode 进程整个挂掉且长时间无人使用」——此时任何插件都无从执行;
306
+ > 重新使用 opencode 时会由看门狗自动恢复。`keepalive: false` 可关闭全部保活。
305
307
 
306
308
  ---
307
309
 
@@ -320,7 +322,7 @@ opencode 会**回收空闲的 location**,这会连带卸载插件、关闭飞
320
322
  | 卡片内容被截断 | 飞书卡片上限约 30KB,超长会话丢弃卡片上最旧块(完整内容仍在会话里) |
321
323
  | 建会话后没看到话题 | 表单卡会改写为「✅ 已创建 · …」并附手动创建话题指引 |
322
324
  | 会话像卡死、发消息只排队 | 看门狗默认 5 分钟后自动中断;也可点「⏹ 强制停止」或发 `/stop` |
323
- | **空闲约 1 小时后机器人完全失联**(日志无「长连接已启动」) | opencode 回收了空闲 location(60 分钟硬编码 TTL)。内置保活默认开启;若仍发生(服务重启 / 长休眠 / 保活被关),用 `opencode api get /api/session/{id}` 任一本地会话即可唤起,或按上方「位置保活」配置外部 cron |
325
+ | **空闲约 1 小时后机器人完全失联**(日志无「长连接已启动」) | opencode 回收了空闲 location(60 分钟硬编码 TTL)。内置保活 + 进程级看门狗默认开启,会自动恢复;也可手动用 `opencode api get /api/session/{id}`(任一本地会话)立即唤起。若长期不恢复,确认 `keepalive` 未被设为 `false` |
324
326
  | 看不到插件日志 | 服务模式下 stderr 被丢弃,设 `logFile: true` |
325
327
  | 切了 `/model` 但历史还是旧模型 | 预期行为:切换只影响后续回复,历史消息保留各自当时的模型 |
326
328
 
package/dist/index.js CHANGED
@@ -147167,21 +147167,26 @@ function ensureGatewayWatchdog(input) {
147167
147167
  existing.target = input.directory;
147168
147168
  input.log.debug("\u7F51\u5173\u770B\u95E8\u72D7\u76EE\u6807\u66F4\u65B0\u4E3A\u7F51\u5173 location", { directory: input.directory });
147169
147169
  }
147170
+ existing.state.probe = input.probe ?? ((dir) => touchLocationOverHttp(dir, { log: input.log }));
147171
+ existing.state.log = input.log;
147170
147172
  return false;
147171
147173
  }
147172
147174
  const setIntervalImpl = input.setIntervalImpl ?? setInterval;
147173
147175
  input.clearIntervalImpl ?? clearInterval;
147174
147176
  const setTimeoutImpl = input.setTimeoutImpl ?? setTimeout;
147175
147177
  input.clearTimeoutImpl ?? clearTimeout;
147176
- const probe = input.probe ?? ((dir) => touchLocationOverHttp(dir, { log: input.log }));
147177
147178
  const slot = {
147178
147179
  target: input.directory,
147180
+ state: {
147181
+ probe: input.probe ?? ((dir) => touchLocationOverHttp(dir, { log: input.log })),
147182
+ log: input.log
147183
+ },
147179
147184
  timer: void 0,
147180
147185
  initial: void 0
147181
147186
  };
147182
147187
  const run2 = () => {
147183
- void probe(slot.target).catch((err2) => {
147184
- input.log.debug("\u7F51\u5173\u770B\u95E8\u72D7\u63A2\u6D4B\u5F02\u5E38", { error: errorMessage(err2) });
147188
+ void slot.state.probe(slot.target).catch((err2) => {
147189
+ slot.state.log.debug("\u7F51\u5173\u770B\u95E8\u72D7\u63A2\u6D4B\u5F02\u5E38", { error: errorMessage(err2) });
147185
147190
  });
147186
147191
  };
147187
147192
  const delay3 = input.immediateDelayMs ?? 3e3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-feishu-plugin",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Feishu/Lark plugin for OpenCode V2 — single-user topics as sessions, in-card permission approvals, streaming cards. Minimal permissions, no public endpoint.",
5
5
  "type": "module",
6
6
  "main": "index.js",