@mrrisega/dsh-remote 0.7.12-beta.5 → 0.7.12-beta.6
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/clients/dsh-remote/dingtalk-bot.mjs +249 -32
- package/clients/dsh-remote/feishu-bot.mjs +101 -0
- package/clients/dsh-remote/im-commands.mjs +302 -0
- package/clients/dsh-remote/test/dingtalk-bot.test.mjs +218 -1
- package/clients/dsh-remote/test/feishu-bot.test.mjs +34 -2
- package/clients/dsh-remote/test/im-caps-fixture.mjs +8 -0
- package/clients/dsh-remote/test/im-commands.test.mjs +283 -0
- package/clients/dsh-remote/test/wecom-bot.test.mjs +37 -0
- package/clients/dsh-remote/wecom-bot.mjs +84 -2
- package/dsh-setup.mjs +1 -1
- package/package.json +2 -2
- package/packages/dsh-remote-web/package.json +1 -1
- package/packages/dsh-remote-web/runtime/clients/dsh-remote/dingtalk-auth.mjs +631 -0
- package/packages/dsh-remote-web/runtime/clients/dsh-remote/dsh-bridge.mjs +35 -0
- package/packages/dsh-remote-web/runtime/dsh-setup.mjs +1 -1
|
@@ -124,6 +124,15 @@ import { createAgentRuntime } from "./agent/index.mjs";
|
|
|
124
124
|
import { createWecomBotController } from "./wecom-bot.mjs";
|
|
125
125
|
// 钉钉 Stream 模式长连接(2026-11-08):与企微同构、零新增依赖;默认关闭,配置在 im-bots.json 的 dingtalk 段。
|
|
126
126
|
import { createDingtalkBotController } from "./dingtalk-bot.mjs";
|
|
127
|
+
// 钉钉「扫码一键创建机器人」授权会话:**持久化 + 断点续轮询**(2026-11-08)。
|
|
128
|
+
// 根因:device_code 只存在插件进程内存 → 面板关/宿主重启就丢,而凭据只在 poll SUCCESS 那次返回。
|
|
129
|
+
// 现在授权会话落盘在 <relayDir>/im-dingtalk-auth.json,bridge 启动即续轮询,桥在跑就能接住。
|
|
130
|
+
import {
|
|
131
|
+
resumeDingtalkAuth,
|
|
132
|
+
startDingtalkAuthCommandWatcher,
|
|
133
|
+
stopDingtalkAuthCommandWatcher,
|
|
134
|
+
stopDingtalkAuthPolling
|
|
135
|
+
} from "./dingtalk-auth.mjs";
|
|
127
136
|
// 飞书通道:官方 SDK 按需下载(41MB,不随包分发)、懒加载;未启用时零副作用
|
|
128
137
|
import { createFeishuBotController } from "./feishu-bot.mjs";
|
|
129
138
|
|
|
@@ -3358,6 +3367,29 @@ function imBotLog(level, message) {
|
|
|
3358
3367
|
}
|
|
3359
3368
|
|
|
3360
3369
|
function startImBots() {
|
|
3370
|
+
// ⓪ 钉钉扫码授权断点续轮询(fire-and-forget,绝不阻塞隧道/连接主链路):
|
|
3371
|
+
// 上次没等到用户确认就重启/关面板也没关系 —— 会话在磁盘上,桥一跑就继续 poll,
|
|
3372
|
+
// 成功后自动写 im-bots.json(credentialSource:"scan")→ controller 热更新把机器人连上。
|
|
3373
|
+
try {
|
|
3374
|
+
void resumeDingtalkAuth({
|
|
3375
|
+
relayDir: RELAY_DIR,
|
|
3376
|
+
logger: imBotLog,
|
|
3377
|
+
onWarn: (m) => imBotLog("warn", m),
|
|
3378
|
+
onSuccess: () => { try { startImBots(); } catch { /* 忽略 */ } }
|
|
3379
|
+
}).catch((e) => {
|
|
3380
|
+
console.warn(`[bridge] 钉钉扫码授权续轮询失败(不影响远程访问): ${redactText(e)}`);
|
|
3381
|
+
});
|
|
3382
|
+
// 控制命令文件:插件写 <relayDir>/im-dingtalk-auth-cmd.json(begin/cancel),桥读并执行。
|
|
3383
|
+
// 插件不需要 device_code,也不需要 HTTP 端点 —— 只表达意图;桥在跑就能接住。
|
|
3384
|
+
startDingtalkAuthCommandWatcher({
|
|
3385
|
+
relayDir: RELAY_DIR,
|
|
3386
|
+
logger: imBotLog,
|
|
3387
|
+
onWarn: (m) => imBotLog("warn", m),
|
|
3388
|
+
onSuccess: () => { try { startImBots(); } catch { /* 忽略 */ } }
|
|
3389
|
+
});
|
|
3390
|
+
} catch (e) {
|
|
3391
|
+
console.warn(`[bridge] 钉钉扫码授权续轮询初始化失败(忽略): ${redactText(e)}`);
|
|
3392
|
+
}
|
|
3361
3393
|
// ① 企业微信(现有)
|
|
3362
3394
|
try {
|
|
3363
3395
|
if (!imBots) {
|
|
@@ -3437,6 +3469,9 @@ function startImBots() {
|
|
|
3437
3469
|
|
|
3438
3470
|
/** 优雅退出 IM 机器人通道(企微 + 钉钉,互不影响)。失败只记日志。 */
|
|
3439
3471
|
async function stopImBots() {
|
|
3472
|
+
// 先停扫码授权轮询/命令监听(**保留** auth 文件:下次启动能续轮询;用户显式取消才删文件)
|
|
3473
|
+
try { stopDingtalkAuthCommandWatcher(); } catch { /* 忽略 */ }
|
|
3474
|
+
try { stopDingtalkAuthPolling(); } catch { /* 忽略 */ }
|
|
3440
3475
|
const wecom = imBots;
|
|
3441
3476
|
const dingtalk = imBotsDingtalk;
|
|
3442
3477
|
const feishu = imBotsFeishu;
|
|
@@ -149,7 +149,7 @@ function findDepWs(startDir) {
|
|
|
149
149
|
* 漏同步就会出现「入口脚本在、依赖不在」的半装运行时(插件半据此判定「运行环境已就绪」,
|
|
150
150
|
* 却永远起不来 bridge —— 2026-09-23 用户反馈的现场)。`src/channel-ref.mjs` 同理(本安装器也 import)。
|
|
151
151
|
*/
|
|
152
|
-
const RUNTIME_CLIENT_FILES = ["mobile-adapter.mjs", "dsh-bridge.mjs", "e2ee-shim.mjs", "e2ee-client.mjs", "e2ee-shim-script.js", "mobile-adapter.test.mjs", "wechat-channel.mjs", "dsh-events.mjs", "wechat-runtime.mjs", "wecom-bot.mjs", "im-format.mjs", "dingtalk-bot.mjs", "feishu-bot.mjs", "src/lifecycle.mjs", "src/channel-ref.mjs"];
|
|
152
|
+
const RUNTIME_CLIENT_FILES = ["mobile-adapter.mjs", "dsh-bridge.mjs", "e2ee-shim.mjs", "e2ee-client.mjs", "e2ee-shim-script.js", "mobile-adapter.test.mjs", "wechat-channel.mjs", "dsh-events.mjs", "wechat-runtime.mjs", "wecom-bot.mjs", "im-format.mjs", "dingtalk-bot.mjs", "dingtalk-auth.mjs", "feishu-bot.mjs", "src/lifecycle.mjs", "src/channel-ref.mjs"];
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* 把"客户端脚本"补齐到配置目录。
|