dsh-chat-comprehension 0.3.5 → 0.3.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/README.md +10 -1
- package/lib/index.js +20 -0
- package/lib/qqbot-0.5.3-patches.json +6 -1
- package/lib/video.mjs +47 -2
- package/package.json +1 -1
- package/vendor/dsh-meme/memes.js +1003 -998
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
给 DeepSeek Harness 的一个「一个入口」的陪伴层:**项目人格 + QQ 联动 + 专属记忆 + B站 值班 + 表情包 + 语音**。
|
|
4
4
|
左侧栏只有一个图标「陪伴」,点开就是一整页设置,不用在好几个插件各自的页面之间来回找。
|
|
5
5
|
|
|
6
|
-
> 版本 **0.3.
|
|
6
|
+
> 版本 **0.3.6**:人格、B站、记忆、表情包、视频分镜的宿主代码都已随本插件提供,只装这一个包就能用。
|
|
7
7
|
> QQ 网关(`@tencent-connect/dsh-qqbot`)需要单独安装,本插件会自动为它打上联动补丁。
|
|
8
8
|
|
|
9
9
|
## 安装
|
|
@@ -131,6 +131,15 @@ dsh plugin --profile web add @tencent-connect/dsh-qqbot # 需要 QQ 对话时
|
|
|
131
131
|
| 语音设置 | `~/.dsh/agents/companion-tts.json`(Key 只存本机,不回显) |
|
|
132
132
|
| 安装日志 | `~/.dsh/companion/setup.log` |
|
|
133
133
|
|
|
134
|
+
## 已知问题与修复(0.3.6)
|
|
135
|
+
|
|
136
|
+
- **发表情包导致 DSH 退出**:`send_meme` 走 QQ 通道、但当前没有 QQ 聊天目标(刚重启、还没人给机器人发消息)时,
|
|
137
|
+
旧版本会让宿主把未处理的 Promise 拒绝当成致命错误退出。现在 QQ 通道的图/语音发送**永不抛错**,
|
|
138
|
+
失败只返回一行提示(如「还没有 QQ 聊天目标」),不会再带走整个 DSH。
|
|
139
|
+
- **Windows 上看不了 QQ 分享的视频**:视频分镜靠 `yt-dlp` / `ffmpeg`,而桌面版宿主的 PATH 里常常没有
|
|
140
|
+
`~/.local/bin` 或 winget 的目录。插件加载时会把这些目录自动补进 PATH;「环境」页新增
|
|
141
|
+
「视频分镜工具链」一行,直接显示它找到的 yt-dlp / ffmpeg 绝对路径。
|
|
142
|
+
|
|
134
143
|
## 许可
|
|
135
144
|
|
|
136
145
|
MIT。上游项目的版权与许可见 [NOTICE.md](./NOTICE.md)。
|
package/lib/index.js
CHANGED
|
@@ -767,6 +767,17 @@ async function doctor(ctx) {
|
|
|
767
767
|
'到「环境」页点「一键安装全部依赖」,按顺序自动装;每步进度会显示在下面', '')
|
|
768
768
|
} catch { /* 拿不到就不显示这一行 */ }
|
|
769
769
|
|
|
770
|
+
try {
|
|
771
|
+
const sb = video ? video.storyboard() : { installed: false }
|
|
772
|
+
const yt = video ? await video.ytdlp() : { found: false }
|
|
773
|
+
add('video-tools', '视频分镜工具链(ffmpeg / yt-dlp)',
|
|
774
|
+
Boolean(sb.installed && yt.found),
|
|
775
|
+
(sb.installed ? '分镜 ' + (sb.version || '?') + (sb.bundled ? '(内置)' : '') : '分镜没装')
|
|
776
|
+
+ ' · yt-dlp ' + (yt.found ? yt.bin : '没找到')
|
|
777
|
+
+ ' · ffmpeg ' + (findFfmpeg(dshHome()) || '没找到'),
|
|
778
|
+
'QQ 分享的视频要这两个才能看;点「一键安装全部依赖」会一起装好', '')
|
|
779
|
+
} catch { /* 拿不到就不显示 */ }
|
|
780
|
+
|
|
770
781
|
const ttsScript = join(dirname(fileURLToPath(import.meta.url)), 'tts_sambert.py')
|
|
771
782
|
add('tts-script', 'Sambert 脚本', existsSync(ttsScript), existsSync(ttsScript) ? ttsScript : '缺失', '插件文件不完整,重装插件', '')
|
|
772
783
|
|
|
@@ -945,6 +956,11 @@ export async function apply(ctx) {
|
|
|
945
956
|
qwen3 = createQwen3Local({ home: dshHome(), runProcess })
|
|
946
957
|
video = createVideoHelper({ home: dshHome(), runProcess, bundledStoryboard: join(dirname(fileURLToPath(import.meta.url)), '..', 'vendor', 'dsh-video-storyboard') })
|
|
947
958
|
voices = createVoiceStore({ home: dshHome(), runProcess })
|
|
959
|
+
// 视频分镜 / 转码要靠 ffmpeg / yt-dlp:先把找到的目录补进 PATH(Windows 桌面版 PATH 常常缺)
|
|
960
|
+
try {
|
|
961
|
+
const added = typeof video.ensureToolPath === 'function' ? video.ensureToolPath() : []
|
|
962
|
+
if (added.length) console.log('[companion] 已把工具目录补进 PATH:' + added.join(' ; '))
|
|
963
|
+
} catch { /* 补不了也不影响别的 */ }
|
|
948
964
|
video.sync()
|
|
949
965
|
ctx.effect(() => () => {
|
|
950
966
|
try { if (qwen3) qwen3.dispose() } catch { /* ignore */ }
|
|
@@ -1353,3 +1369,7 @@ export async function apply(ctx) {
|
|
|
1353
1369
|
// ffmpeg probe fix 1793986613
|
|
1354
1370
|
|
|
1355
1371
|
// workspace 1793989308
|
|
1372
|
+
|
|
1373
|
+
// v036 1794026709
|
|
1374
|
+
|
|
1375
|
+
// force reload 1794026820
|
|
@@ -54,6 +54,11 @@
|
|
|
54
54
|
"group": "v2",
|
|
55
55
|
"old": " setupMiddlewares(bot, config, manager, logger);",
|
|
56
56
|
"new": " setupMiddlewares(bot, config, manager, logger, ctx); // companion-patch:v2 cards"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"group": "v4",
|
|
60
|
+
"old": " async sendImage(path, caption) {\n if (!botReady) throw new Error('QQ 通道未就绪');\n const target = latestReplyTarget();\n if (!target) throw new Error('还没有 QQ 聊天目标');\n return bot.sendImage(resolveReplyTarget(target, replyLimiter, false), { localPath: String(path) }, caption ? { content: String(caption) } : undefined);\n },\n async sendVoice(path) {\n if (!botReady) throw new Error('QQ 通道未就绪');\n const target = latestReplyTarget();\n if (!target) throw new Error('还没有 QQ 聊天目标');\n return bot.sendVoice(resolveReplyTarget(target, replyLimiter, false), { localPath: String(path) });\n },",
|
|
61
|
+
"new": " // ⚠️ 这两个绝不能 reject:调用方(dsh-meme 的 send_meme)用的是同步 try/catch,\n // 拿到的 rejected Promise 没人接 ⇒ 宿主 unhandledRejection ⇒ \"fatal load failure\" ⇒ 进程退出。\n // 统一改成「永远 resolve,失败返回 { ok:false, error }」。\n async sendImage(path, caption) {\n try {\n if (!botReady) return { ok: false, error: 'QQ 通道未就绪' };\n const target = latestReplyTarget();\n if (!target) return { ok: false, error: '还没有 QQ 聊天目标(先在 QQ 里给机器人发一条消息)' };\n await bot.sendImage(resolveReplyTarget(target, replyLimiter, false), { localPath: String(path) }, caption ? { content: String(caption) } : undefined);\n return { ok: true };\n } catch (err) {\n logger.warn(`im-qqbot: sendImage 失败(已兜住):${err instanceof Error ? err.message : String(err)}`);\n return { ok: false, error: err instanceof Error ? err.message : String(err) };\n }\n },\n async sendVoice(path) {\n try {\n if (!botReady) return { ok: false, error: 'QQ 通道未就绪' };\n const target = latestReplyTarget();\n if (!target) return { ok: false, error: '还没有 QQ 聊天目标(先在 QQ 里给机器人发一条消息)' };\n await bot.sendVoice(resolveReplyTarget(target, replyLimiter, false), { localPath: String(path) });\n return { ok: true };\n } catch (err) {\n logger.warn(`im-qqbot: sendVoice 失败(已兜住):${err instanceof Error ? err.message : String(err)}`);\n return { ok: false, error: err instanceof Error ? err.message : String(err) };\n }\n },"
|
|
57
62
|
}
|
|
58
63
|
]
|
|
59
64
|
},
|
|
@@ -113,5 +118,5 @@
|
|
|
113
118
|
"0.5.4",
|
|
114
119
|
"0.5.5"
|
|
115
120
|
],
|
|
116
|
-
"level":
|
|
121
|
+
"level": 4
|
|
117
122
|
}
|
package/lib/video.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* 只动 video.json 里的 `cookies` 一项,且只在它指向我们自己那份文件时才删。
|
|
8
8
|
*/
|
|
9
9
|
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from 'node:fs'
|
|
10
|
-
import { delimiter, join } from 'node:path'
|
|
10
|
+
import { delimiter, dirname, join } from 'node:path'
|
|
11
11
|
|
|
12
12
|
export function createVideoHelper({ home, runProcess, bundledStoryboard = '' }) {
|
|
13
13
|
const videoJson = join(home, 'video.json')
|
|
@@ -150,6 +150,51 @@ export function createVideoHelper({ home, runProcess, bundledStoryboard = '' })
|
|
|
150
150
|
return r
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
/**
|
|
154
|
+
* 把找到的 yt-dlp / ffmpeg 所在目录补进 process.env.PATH。
|
|
155
|
+
*
|
|
156
|
+
* 为什么:视频分镜插件(同进程)用裸命令找 yt-dlp / ffmpeg;
|
|
157
|
+
* Windows 桌面版宿主的 PATH 通常没有 `~/.local/bin` 和 winget 的目录 ⇒ 明明装了却找不到,
|
|
158
|
+
* 表现就是「QQ 里分享的视频它不会看」。这里启动时补一次,子进程/同进程都受益。
|
|
159
|
+
*/
|
|
160
|
+
function ensureToolPath() {
|
|
161
|
+
const added = []
|
|
162
|
+
const addDir = (file) => {
|
|
163
|
+
if (!file || !existsSync(file)) return
|
|
164
|
+
const dir = dirname(file)
|
|
165
|
+
if (added.includes(dir)) return
|
|
166
|
+
added.push(dir)
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
for (const bin of ytdlpCandidates()) addDir(bin)
|
|
170
|
+
const exe = process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'
|
|
171
|
+
const ffCandidates = []
|
|
172
|
+
for (const dir of String(process.env.PATH || process.env.Path || '').split(delimiter).filter(Boolean)) ffCandidates.push(join(dir, exe))
|
|
173
|
+
const userHome = process.env.USERPROFILE || process.env.HOME || ''
|
|
174
|
+
ffCandidates.push(join(userHome, '.local', 'bin', exe))
|
|
175
|
+
ffCandidates.push(join(home, 'companion', 'bin', exe))
|
|
176
|
+
if (process.platform === 'win32') {
|
|
177
|
+
try {
|
|
178
|
+
for (const v of readdirSync(join(process.env.LOCALAPPDATA || '', 'Microsoft', 'WinGet', 'Packages'))) {
|
|
179
|
+
const base = join(process.env.LOCALAPPDATA || '', 'Microsoft', 'WinGet', 'Packages', v)
|
|
180
|
+
for (const sub of readdirSync(base).slice(0, 5)) {
|
|
181
|
+
ffCandidates.push(join(base, sub, 'bin', exe))
|
|
182
|
+
ffCandidates.push(join(base, sub, exe))
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
} catch { /* 没装过 winget 包 */ }
|
|
186
|
+
ffCandidates.push('C:\ProgramData\chocolatey\bin\ffmpeg.exe', 'C:\ffmpeg\bin\ffmpeg.exe')
|
|
187
|
+
}
|
|
188
|
+
for (const c of ffCandidates) { if (existsSync(c)) { addDir(c); break } }
|
|
189
|
+
} catch { /* 补 PATH 失败不影响加载 */ }
|
|
190
|
+
if (added.length === 0) return []
|
|
191
|
+
const current = String(process.env.PATH || process.env.Path || '')
|
|
192
|
+
const next = [...added, current].filter(Boolean).join(delimiter)
|
|
193
|
+
process.env.PATH = next
|
|
194
|
+
if (process.platform === 'win32') process.env.Path = next
|
|
195
|
+
return added
|
|
196
|
+
}
|
|
197
|
+
|
|
153
198
|
/** 插件启动时:开着就刷新一次 cookies(专用号可能重新登录过);关着就确保没有残留。 */
|
|
154
199
|
function sync() {
|
|
155
200
|
try {
|
|
@@ -169,5 +214,5 @@ export function createVideoHelper({ home, runProcess, bundledStoryboard = '' })
|
|
|
169
214
|
}
|
|
170
215
|
}
|
|
171
216
|
|
|
172
|
-
return { storyboard, ytdlp, installYtdlp, setBiliLogin, sync, view, cookieFile }
|
|
217
|
+
return { storyboard, ytdlp, installYtdlp, setBiliLogin, sync, view, cookieFile, ensureToolPath }
|
|
173
218
|
}
|