dsh-message-gateway 0.1.17 → 0.1.19

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/lib/index.js CHANGED
@@ -1,11 +1,5 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
5
- }) : x)(function(x) {
6
- if (typeof require !== "undefined") return require.apply(this, arguments);
7
- throw Error('Dynamic require of "' + x + '" is not supported');
8
- });
9
3
  var __esm = (fn, res) => function __init() {
10
4
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
5
  };
@@ -4799,7 +4793,7 @@ var BridgeManager = class {
4799
4793
  return;
4800
4794
  }
4801
4795
  if (event.type === "turn/end") {
4802
- if (p.buffer !== "" && p.pushed) {
4796
+ if (p.buffer !== "") {
4803
4797
  void this.pushStream(p, true);
4804
4798
  this.finishPending(key);
4805
4799
  return;
@@ -5045,7 +5039,7 @@ var BridgeManager = class {
5045
5039
  }, 400);
5046
5040
  p.fallback = setTimeout(() => {
5047
5041
  if (this.pendingMap.get(id.key) === p) this.finishPending(id.key);
5048
- }, 10 * 60 * 1e3);
5042
+ }, 2 * 60 * 1e3);
5049
5043
  p.fallback.unref?.();
5050
5044
  } catch (error) {
5051
5045
  console.error("[dsh-message-gateway] handleExternalMessage failed", error);
@@ -5118,16 +5112,6 @@ var BridgeManager = class {
5118
5112
  const userid = body.from?.userid ?? "";
5119
5113
  const chatid = body.chatid ?? "";
5120
5114
  const key = chatid !== "" ? `wecom:group:${chatid}` : `wecom:user:${userid}`;
5121
- try {
5122
- const fs = __require("node:fs");
5123
- const path = __require("node:path");
5124
- const os = __require("node:os");
5125
- const target = chatid !== "" ? chatid : userid;
5126
- if (target) {
5127
- fs.writeFileSync(path.join(os.homedir(), ".dsh", "latest_wecom_target.txt"), target, "utf8");
5128
- }
5129
- } catch {
5130
- }
5131
5115
  const sink = {
5132
5116
  stream: (f, sid, content, finish) => void this.wecom?.streamReply(f, sid, content, finish)
5133
5117
  // 企业微信走单一流式消息(ack → 内容 → 定稿同一条消息就地更新);
@@ -6605,19 +6589,6 @@ function registerGatewayRoutes(ctx, manager) {
6605
6589
  json(res, { ok: true, value: { sent: true } });
6606
6590
  return;
6607
6591
  }
6608
- if (path === "/gateway/recent-target") {
6609
- const fs = await import("node:fs");
6610
- const pathModule = await import("node:path");
6611
- const os = await import("node:os");
6612
- const targetFile = pathModule.join(os.homedir(), ".dsh", "latest_wecom_target.txt");
6613
- let target = "";
6614
- try {
6615
- target = fs.readFileSync(targetFile, "utf8").trim();
6616
- } catch {
6617
- }
6618
- json(res, { ok: true, value: { target } });
6619
- return;
6620
- }
6621
6592
  if (path === "/gateway/send") {
6622
6593
  const body = payload;
6623
6594
  const chatid = typeof body?.chatid === "string" ? body.chatid.trim() : "";