@rezti/dsh-rez-wechat 0.1.20 → 0.1.21

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 CHANGED
@@ -19,7 +19,7 @@ dsh plugin --profile web add @rezti/dsh-rez-suite
19
19
 
20
20
  - 左侧工作区分组是 **微信**,不是 Ungrouped
21
21
  - 连续消息延续同一会话
22
- - 模型跟网页默认(网页选了 Kimi,微信也走 Kimi)
22
+ - 模型跟网页默认(官方默认 DeepSeek-V4-Flash;不要因为微信通道去切 Kimi)
23
23
  - 网页归档后再从微信说话会自动回到侧栏(官方会藏空白会话,所以「重启对话」会先打一句招呼)
24
24
  - 网页端选择题(Selection)会编成 `1. 2. 3.` 发到微信;回复数字或选项原文即可继续,不必在网页点选
25
25
  - 思考过程不会发到微信;多段正文会保留换行
package/lib/channel.js CHANGED
@@ -167,7 +167,7 @@ export class WeixinChannel {
167
167
  if (this.runChild !== undefined && this.runChild.exitCode === null)
168
168
  return;
169
169
  this.phase = 'listening';
170
- this.hint = '微信通道已在后台听着。消息会进网页「微信」文件夹的同一会话,模型跟网页默认(例如 Kimi)。';
170
+ this.hint = '微信通道已在后台听着。消息会进网页「微信」文件夹的同一会话,模型跟网页默认(DeepSeek-V4-Flash)。';
171
171
  const child = spawn('npx', ['-y', 'dsh-wechat-bridge', 'run', '--data-dir', DATA_DIR], {
172
172
  env: weixinRunEnv(),
173
173
  stdio: ['ignore', 'pipe', 'pipe'],
package/lib/index.js CHANGED
@@ -7,7 +7,7 @@ export const name = 'rez-wechat';
7
7
  export const inject = ['systemPrompt', 'webServer', 'rezSso'];
8
8
  const GUIDANCE = [
9
9
  '企业微信有两层,不要混:① 房间消息通道 = 官方 @wecom/aibot-node-sdk(设置页 BotID + Secret 长连接),同事在企微跟哪个 bot 说话就进哪个 Harness 房间(人事/财务/法务/设计/发布/电商/实验室/老板三室),并固定同一条网页会话;只有同事说「重启对话」才新开并把旧的归档。② 办公能力 = 官方 wecom-cli >=1.1(通讯录/在线文档/在线表格/智能表格/智能文档/待办/日程/会议/邮件/微盘/消息),本企业已开通,看 rez_status.wecomCli.modules,按房间 wecomcli-* 技能执行。不要因为状态页没有企微 MCP 就说没有企微能力,也不要说「超过 10 人只能用文档」。CLI 报未授权才说该模块未开通。密钥写在 ~/.dsh/wecom-channels.json,不要写进 compose。没有绑定任何 bot 且仍配置了 REZ_WECHAT_WEBHOOK 时,才兼容旧的 wecom-mcp 群发,不要引导去填群 Webhook。不要自写 WebSocket/HTTP 客户端。',
10
- '个人微信是 QClaw 同款 ClawBot 通道:在 Rez 面板「微信」页扫码一次,然后直接在微信里说话。消息进入网页左侧「微信」文件夹并延续同一会话,模型跟网页默认(在网页里选了 Kimi 就会走 Kimi)。网页端归档了也能从微信自动恢复到侧栏(空白会话网页会藏起来,所以新开的会话会先打一句招呼再出现)。网页端出现选择题时会编成纯文本发到微信,回复数字或选项原文即可;思考过程不会转发。发「重启对话」会新开一条可见的网页会话并把旧的归档。通道断了点「重新连接」(已登录不必再扫码)。不要再跑 npx weixin-mcp login,也不要调用 mcp__weixin__*。网页端必须开着。工商查询请切到法务助理,避免串房间。',
10
+ '个人微信是 QClaw 同款 ClawBot 通道:在 Rez 面板「微信」页扫码一次,然后直接在微信里说话。消息进入网页左侧「微信」文件夹并延续同一会话,模型跟网页默认(官方默认 DeepSeek-V4-Flash,不要因为微信去切 Kimi)。网页端归档了也能从微信自动恢复到侧栏(空白会话网页会藏起来,所以新开的会话会先打一句招呼再出现)。网页端出现选择题时会编成纯文本发到微信,回复数字或选项原文即可;思考过程不会转发。发「重启对话」会新开一条可见的网页会话并把旧的归档。通道断了点「重新连接」(已登录不必再扫码)。不要再跑 npx weixin-mcp login,也不要调用 mcp__weixin__*。网页端必须开着。工商查询请切到法务助理,避免串房间。',
11
11
  '这是 ClawBot 客服会话,不是用个人微信号管好友/群。对外发消息必须先征得用户批准。',
12
12
  ].join('');
13
13
  function isLoopbackRequest(request) {
@@ -3,6 +3,10 @@
3
3
  * Executable stand-in for `dsh`. dsh-wechat-bridge spawns:
4
4
  * $DSH_BRIDGE_DSH --profile headless <task>
5
5
  * stdout is the WeChat reply; logs go to stderr.
6
+ *
7
+ * Must process.exit: native fetch keeps the event loop alive, and the bridge
8
+ * holds a per-chat lock until this child exits. Without an explicit exit the
9
+ * first WeChat turn can reply, then every follow-up waits forever.
6
10
  */
7
11
  import { parseHeadlessArgv, runHeadlessViaWeb } from './web-shim.js';
8
12
  const parsed = parseHeadlessArgv(process.argv.slice(1));
@@ -20,3 +24,4 @@ catch (error) {
20
24
  process.stderr.write(`dsh-web-shim: ${message}\n`);
21
25
  process.stdout.write(`${message}\n`);
22
26
  }
27
+ process.exit(0);
package/lib/web-shim.d.ts CHANGED
@@ -4,8 +4,7 @@
4
4
  *
5
5
  * Headless always mints a fresh Agent (DeepSeek default, Ungrouped cwd hash).
6
6
  * Web RPC reuses one session under ~/.dsh/workspaces/微信 so the sidebar
7
- * folder is named 微信, turns continue, and the model follows the web default
8
- * (Kimi if that is what the user selected).
7
+ * folder is named 微信, turns continue, and the model follows the web default.
9
8
  */
10
9
  export declare const WECHAT_WORKSPACE_NAME = "\u5FAE\u4FE1";
11
10
  export declare const DEFAULT_WEB_URL = "http://127.0.0.1:3080";
package/lib/web-shim.js CHANGED
@@ -4,8 +4,7 @@
4
4
  *
5
5
  * Headless always mints a fresh Agent (DeepSeek default, Ungrouped cwd hash).
6
6
  * Web RPC reuses one session under ~/.dsh/workspaces/微信 so the sidebar
7
- * folder is named 微信, turns continue, and the model follows the web default
8
- * (Kimi if that is what the user selected).
7
+ * folder is named 微信, turns continue, and the model follows the web default.
9
8
  */
10
9
  import { randomUUID } from 'node:crypto';
11
10
  import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
@@ -813,7 +812,10 @@ export function pickWechatModel(models, env = process.env) {
813
812
  const provider = env.REZ_WECHAT_PROVIDER?.trim();
814
813
  return provider !== undefined && provider !== '' ? { provider, model: forced } : { model: forced };
815
814
  }
816
- if (env.REZ_WECHAT_PREFER_KIMI === '0')
815
+ // Follow the web default (official agent-default-model is DeepSeek-V4-Flash).
816
+ // Do not switch a DeepSeek session onto Kimi: session/selectModel also writes
817
+ // the global default, so a WeChat message would make the next restart land on Kimi.
818
+ if (env.REZ_WECHAT_PREFER_KIMI !== '1')
817
819
  return undefined;
818
820
  const current = currentModelRef(models);
819
821
  if (current !== undefined && looksLikeKimi(`${current.provider ?? ''} ${current.model}`))
@@ -966,13 +968,29 @@ async function maybeSelectModel(rpc, sessionId, env) {
966
968
  }
967
969
  }
968
970
  }
969
- /** 0.1.5 replaced session.history with session/page. */
971
+ /** Prefer session/page (0.1.5 surface); fall back to session/history (apiproxy). */
970
972
  async function fetchSessionHistory(rpc, sessionId, maxMessages = 40) {
971
- return historyEvents(await rpc('session/page', {
972
- address: { kind: 'session', sessionId },
973
- throughSeq: Number.MAX_SAFE_INTEGER,
974
- maxMessages,
975
- }));
973
+ const attempts = [
974
+ {
975
+ method: 'session/page',
976
+ params: {
977
+ address: { kind: 'session', sessionId },
978
+ throughSeq: Number.MAX_SAFE_INTEGER,
979
+ maxMessages,
980
+ },
981
+ },
982
+ { method: 'session/history', params: { sessionId, maxMessages } },
983
+ ];
984
+ let lastError;
985
+ for (const attempt of attempts) {
986
+ try {
987
+ return historyEvents(await rpc(attempt.method, attempt.params));
988
+ }
989
+ catch (error) {
990
+ lastError = error;
991
+ }
992
+ }
993
+ throw lastError instanceof Error ? lastError : new Error(String(lastError));
976
994
  }
977
995
  async function sessionAlive(rpc, sessionId) {
978
996
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rezti/dsh-rez-wechat",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "ReZ-TI WeChat/WeCom bridges. Personal WeChat is QClaw/ClawBot scan-and-chat via dsh-wechat-bridge; WeCom AI bots use the official @wecom/aibot-node-sdk (BotID + Secret) bound per Harness room.",
5
5
  "type": "module",
6
6
  "engines": {