opencode-feishu-plugin 0.2.2 → 0.2.4

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.
Files changed (2) hide show
  1. package/dist/index.js +51 -23
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -147161,27 +147161,36 @@ async function touchLocationOverHttp(directory, deps) {
147161
147161
  var WATCHDOG_SLOT = /* @__PURE__ */ Symbol.for("opencode-feishu-v2/gateway-watchdog");
147162
147162
  function ensureGatewayWatchdog(input) {
147163
147163
  const g = globalThis;
147164
- const existing = g[WATCHDOG_SLOT];
147164
+ let existing = g[WATCHDOG_SLOT];
147165
+ if (existing && !existing.state) {
147166
+ clearWatchdogSlot(existing);
147167
+ existing = void 0;
147168
+ }
147165
147169
  if (existing) {
147166
147170
  if (input.authoritative && existing.target !== input.directory) {
147167
147171
  existing.target = input.directory;
147168
147172
  input.log.debug("\u7F51\u5173\u770B\u95E8\u72D7\u76EE\u6807\u66F4\u65B0\u4E3A\u7F51\u5173 location", { directory: input.directory });
147169
147173
  }
147174
+ existing.state.probe = input.probe ?? ((dir) => touchLocationOverHttp(dir, { log: input.log }));
147175
+ existing.state.log = input.log;
147170
147176
  return false;
147171
147177
  }
147172
147178
  const setIntervalImpl = input.setIntervalImpl ?? setInterval;
147173
147179
  input.clearIntervalImpl ?? clearInterval;
147174
147180
  const setTimeoutImpl = input.setTimeoutImpl ?? setTimeout;
147175
147181
  input.clearTimeoutImpl ?? clearTimeout;
147176
- const probe = input.probe ?? ((dir) => touchLocationOverHttp(dir, { log: input.log }));
147177
147182
  const slot = {
147178
147183
  target: input.directory,
147184
+ state: {
147185
+ probe: input.probe ?? ((dir) => touchLocationOverHttp(dir, { log: input.log })),
147186
+ log: input.log
147187
+ },
147179
147188
  timer: void 0,
147180
147189
  initial: void 0
147181
147190
  };
147182
147191
  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) });
147192
+ void slot.state.probe(slot.target).catch((err2) => {
147193
+ slot.state.log.debug("\u7F51\u5173\u770B\u95E8\u72D7\u63A2\u6D4B\u5F02\u5E38", { error: errorMessage(err2) });
147185
147194
  });
147186
147195
  };
147187
147196
  const delay3 = input.immediateDelayMs ?? 3e3;
@@ -147196,6 +147205,13 @@ function ensureGatewayWatchdog(input) {
147196
147205
  });
147197
147206
  return true;
147198
147207
  }
147208
+ function clearWatchdogSlot(slot) {
147209
+ const s = slot ?? {};
147210
+ if (s.timer) clearInterval(s.timer);
147211
+ if (s.initial) clearTimeout(s.initial);
147212
+ const g = globalThis;
147213
+ if (g[WATCHDOG_SLOT] === slot) delete g[WATCHDOG_SLOT];
147214
+ }
147199
147215
  function startKeepalive(deps) {
147200
147216
  const setIntervalImpl = deps.setIntervalImpl ?? setInterval;
147201
147217
  const clearIntervalImpl = deps.clearIntervalImpl ?? clearInterval;
@@ -150968,23 +150984,31 @@ var index_default = plugin_exports.define({
150968
150984
  if (config.keepalive) {
150969
150985
  const watchdogTarget = config.gatewayLocation ?? here;
150970
150986
  if (watchdogTarget) {
150971
- startedWatchdog = ensureGatewayWatchdog({
150972
- log: log2,
150973
- directory: watchdogTarget,
150974
- intervalMs: config.keepaliveIntervalMs
150975
- });
150987
+ try {
150988
+ startedWatchdog = ensureGatewayWatchdog({
150989
+ log: log2,
150990
+ directory: watchdogTarget,
150991
+ intervalMs: config.keepaliveIntervalMs
150992
+ });
150993
+ } catch (err2) {
150994
+ log2.warn("\u7F51\u5173\u770B\u95E8\u72D7\u542F\u52A8\u5931\u8D25\uFF08\u5DF2\u5FFD\u7565\uFF09", { error: errorMessage(err2) });
150995
+ }
150976
150996
  }
150977
150997
  }
150978
150998
  if (config.gatewayLocation) {
150979
150999
  const matched = Boolean(here) && isUnder(here, config.gatewayLocation);
150980
151000
  const keepSink = matched || startedWatchdog;
150981
- trackGatewayLocationSeen({
150982
- here: here ?? "(unknown)",
150983
- expected: config.gatewayLocation,
150984
- matched,
150985
- warn: (message) => log2.warn(message),
150986
- ...keepSink ? {} : { onSettled: () => logSink?.close() }
150987
- });
151001
+ try {
151002
+ trackGatewayLocationSeen({
151003
+ here: here ?? "(unknown)",
151004
+ expected: config.gatewayLocation,
151005
+ matched,
151006
+ warn: (message) => log2.warn(message),
151007
+ ...keepSink ? {} : { onSettled: () => logSink?.close() }
151008
+ });
151009
+ } catch (err2) {
151010
+ log2.warn("\u7F51\u5173\u4F4D\u7F6E\u8DDF\u8E2A\u5931\u8D25\uFF08\u5DF2\u5FFD\u7565\uFF09", { error: errorMessage(err2) });
151011
+ }
150988
151012
  if (!matched) {
150989
151013
  log2.debug("\u8DF3\u8FC7\u975E\u7F51\u5173 location", { here, expected: config.gatewayLocation });
150990
151014
  if (!keepSink) logSink?.close();
@@ -151548,13 +151572,17 @@ async function start(ctx, config, log2, logSink) {
151548
151572
  const here = ctx.location?.directory;
151549
151573
  const keepaliveDirectory = here ?? config.gatewayLocation;
151550
151574
  if (config.keepalive && keepaliveDirectory) {
151551
- ensureGatewayWatchdog({
151552
- log: log2,
151553
- directory: keepaliveDirectory,
151554
- intervalMs: config.keepaliveIntervalMs,
151555
- authoritative: true,
151556
- immediateDelayMs: 0
151557
- });
151575
+ try {
151576
+ ensureGatewayWatchdog({
151577
+ log: log2,
151578
+ directory: keepaliveDirectory,
151579
+ intervalMs: config.keepaliveIntervalMs,
151580
+ authoritative: true,
151581
+ immediateDelayMs: 0
151582
+ });
151583
+ } catch (err2) {
151584
+ log2.warn("\u7F51\u5173\u770B\u95E8\u72D7\u767B\u8BB0\u5931\u8D25\uFF08\u5DF2\u5FFD\u7565\uFF09", { error: errorMessage(err2) });
151585
+ }
151558
151586
  }
151559
151587
  const stopKeepalive = config.keepalive && keepaliveDirectory ? startKeepalive({
151560
151588
  log: log2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-feishu-plugin",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
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",