@mcviseron/dsh-qq-bridge 0.3.4 → 0.3.8
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 +8 -5
- package/cordis.patch.yml +4 -3
- package/lib/client.js +50 -5
- package/lib/index.js +22 -6
- package/lib/install.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,21 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
## 安装
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
**规则只有一条:profile 里的 `name` 永远是裸名 `dsh-qq-bridge`,profile 的
|
|
6
|
+
node_modules 里必须有同名包可解析。** 名字解析不到时 DSH 不会报错,而是让
|
|
7
|
+
`id: qq-bridge` 的配置静默落空(插件用默认配置跑:statePath / cwd / token 全丢)。
|
|
8
|
+
|
|
9
|
+
npm 上的包名是 scoped 的 `@mcviseron/dsh-qq-bridge`,所以用**别名**安装把裸名造出来:
|
|
7
10
|
|
|
8
11
|
```bash
|
|
9
|
-
npm i @mcviseron/dsh-qq-bridge
|
|
12
|
+
npm i dsh-qq-bridge@npm:@mcviseron/dsh-qq-bridge@<版本>
|
|
10
13
|
```
|
|
11
14
|
|
|
12
15
|
```yaml
|
|
13
16
|
# profile 的 cordis.patch.yml
|
|
14
17
|
- insert:
|
|
15
18
|
- id: qq-bridge
|
|
16
|
-
name: '
|
|
19
|
+
name: 'dsh-qq-bridge'
|
|
17
20
|
```
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
本地开发直接 link:
|
|
20
23
|
|
|
21
24
|
```bash
|
|
22
25
|
npm i dsh-qq-bridge@link:/path/to/plugin
|
package/cordis.patch.yml
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
# assistant reply plus every pending tool approval back to the bot.
|
|
5
5
|
- insert:
|
|
6
6
|
- id: qq-bridge
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
|
|
7
|
+
# 条目名固定为裸名 dsh-qq-bridge:link 安装与本机 profile 都用这个名字。
|
|
8
|
+
# 从 npm 装(包名是 scoped 的 @mcviseron/dsh-qq-bridge)时用别名让裸名可解析:
|
|
9
|
+
# pnpm add "dsh-qq-bridge@npm:@mcviseron/dsh-qq-bridge@<版本>"
|
|
10
|
+
name: 'dsh-qq-bridge'
|
|
10
11
|
config:
|
|
11
12
|
enabled: true
|
|
12
13
|
host: '127.0.0.1'
|
package/lib/client.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 全部改用内联样式:宿主 main 槽位不在同一个样式作用域,注入 <style> 不可靠。
|
|
4
4
|
*/
|
|
5
5
|
window.__ModuleLoader__.load({
|
|
6
|
-
id: "
|
|
6
|
+
id: "dsh-qq-bridge",
|
|
7
7
|
factory: (require) => {
|
|
8
8
|
var module = { exports: {} }
|
|
9
9
|
var exports = module.exports
|
|
@@ -301,11 +301,56 @@ window.__ModuleLoader__.load({
|
|
|
301
301
|
}, [call, paused])
|
|
302
302
|
|
|
303
303
|
if (state !== null && state.offline) {
|
|
304
|
+
// 面板还没起来(新机器上根本没装机器人)时也必须能一键安装,否则鸡生蛋死循环
|
|
305
|
+
const setField = function (key, next) { const copy = Object.assign({}, draft); copy[key] = next; setDraft(copy) }
|
|
306
|
+
const secretNow = String(draft.appsecret === undefined ? "" : draft.appsecret)
|
|
307
|
+
const runInstall = async function () {
|
|
308
|
+
setInstallNote("")
|
|
309
|
+
try {
|
|
310
|
+
const started = await installCall({
|
|
311
|
+
action: "start",
|
|
312
|
+
appid: draft.appid === undefined ? "" : draft.appid,
|
|
313
|
+
appsecret: secretNow.indexOf("****") >= 0 ? "" : secretNow,
|
|
314
|
+
})
|
|
315
|
+
if (started.ok !== true) { setInstallNote("启动安装失败:" + (started.error || "未知错误")); return }
|
|
316
|
+
setInstall(started.state || null)
|
|
317
|
+
} catch (error) {
|
|
318
|
+
setInstallNote("连不上宿主插件(39061),确认插件已加载")
|
|
319
|
+
}
|
|
320
|
+
}
|
|
304
321
|
return h("div", { style: T.page },
|
|
305
322
|
h("div", { style: T.inner },
|
|
306
|
-
h("div", { style: T.title }, "
|
|
307
|
-
h("div", { style: T.hint }, "
|
|
308
|
-
h(
|
|
323
|
+
h("div", { style: T.title }, "机器人还没装,或者面板没起来"),
|
|
324
|
+
h("div", { style: T.hint }, "新机器直接点下面的「下载 / 配置机器人」一次装好(找 Python → 建 venv → 装依赖 → 放机器人代码 → 拉起守护进程);已经装过只是没起来,点重试。"),
|
|
325
|
+
h(Row, { title: "APPID(开放平台的机器人 AppID)" },
|
|
326
|
+
h("input", {
|
|
327
|
+
style: Object.assign({}, T.input, T.inputWide),
|
|
328
|
+
value: draft.appid === undefined ? "" : draft.appid,
|
|
329
|
+
onChange: function (event) { setField("appid", event.target.value) },
|
|
330
|
+
})),
|
|
331
|
+
h(Row, { title: "APPSECRET" },
|
|
332
|
+
h("input", {
|
|
333
|
+
type: "password",
|
|
334
|
+
placeholder: "安装时会写进 bot/.env",
|
|
335
|
+
style: Object.assign({}, T.input, T.inputWide),
|
|
336
|
+
value: secretNow,
|
|
337
|
+
onChange: function (event) { setField("appsecret", event.target.value) },
|
|
338
|
+
})),
|
|
339
|
+
h("div", { style: T.actions },
|
|
340
|
+
h("button", {
|
|
341
|
+
style: Object.assign({}, T.btn, T.btnPrimary),
|
|
342
|
+
disabled: busy || (install !== null && install.running === true),
|
|
343
|
+
onClick: function () { void runInstall() },
|
|
344
|
+
}, install && install.running ? "正在配置…" : "下载 / 配置机器人"),
|
|
345
|
+
h("button", { style: T.btn, onClick: load }, "重试")),
|
|
346
|
+
install && install.running && Array.isArray(install.steps)
|
|
347
|
+
? h("div", { style: T.hint }, "第 " + (install.step + 1) + "/" + install.steps.length + " 步:" + install.steps[install.step])
|
|
348
|
+
: null,
|
|
349
|
+
install && install.error ? h("div", { style: T.hint }, "失败:" + install.error) : null,
|
|
350
|
+
installNote ? h("div", { style: T.hint }, installNote) : null,
|
|
351
|
+
install && Array.isArray(install.lines) && install.lines.length
|
|
352
|
+
? h("pre", { style: T.log }, install.lines.slice(-60).join("\n"))
|
|
353
|
+
: null))
|
|
309
354
|
}
|
|
310
355
|
if (state === null) return h("div", { style: T.page }, h("div", { style: T.inner }, h("div", { style: T.hint }, "读取中…")))
|
|
311
356
|
|
|
@@ -329,7 +374,7 @@ window.__ModuleLoader__.load({
|
|
|
329
374
|
const startInstall = async function () {
|
|
330
375
|
setInstallNote("")
|
|
331
376
|
try {
|
|
332
|
-
// 面板回传的 AppSecret 是打码值(
|
|
377
|
+
// 面板回传的 AppSecret 是打码值(ab12****yz),别把它当真的传下去
|
|
333
378
|
const rawSecret = String(value("appsecret") === undefined ? "" : value("appsecret"))
|
|
334
379
|
const started = await installCall({
|
|
335
380
|
action: "start",
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* approval.
|
|
9
9
|
*/
|
|
10
10
|
import { randomUUID } from 'node:crypto'
|
|
11
|
-
import { readFileSync } from 'node:fs'
|
|
11
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
12
12
|
import { appendFile, mkdir } from 'node:fs/promises'
|
|
13
13
|
import { dirname, join, resolve } from 'node:path'
|
|
14
14
|
import { fileURLToPath } from 'node:url'
|
|
@@ -34,12 +34,13 @@ export const DEFAULT_CONFIG = {
|
|
|
34
34
|
quoteContextChars: 300,
|
|
35
35
|
historyMax: 200,
|
|
36
36
|
autoGroup: true,
|
|
37
|
-
|
|
37
|
+
// 这些路径不能写死某台机器:留空则用插件数据目录,或由「一键安装」写下的 install.json 提供
|
|
38
|
+
autoGroupRoot: '',
|
|
38
39
|
streamEnabled: true,
|
|
39
40
|
streamIntervalMs: 250,
|
|
40
41
|
autoStartBot: true,
|
|
41
|
-
botDir: '
|
|
42
|
-
pythonPath: '
|
|
42
|
+
botDir: '',
|
|
43
|
+
pythonPath: '',
|
|
43
44
|
modelProvider: '',
|
|
44
45
|
model: '',
|
|
45
46
|
reasoningEffort: '',
|
|
@@ -134,6 +135,7 @@ export function apply(ctx, rawConfig) {
|
|
|
134
135
|
stdio: 'ignore',
|
|
135
136
|
windowsHide: true,
|
|
136
137
|
})
|
|
138
|
+
child.on('error', (error) => log(`bot supervisor spawn failed: ${error.message}`))
|
|
137
139
|
child.unref()
|
|
138
140
|
log(`bot supervisor spawned after install (pid ${child.pid})`)
|
|
139
141
|
return child.pid
|
|
@@ -165,7 +167,7 @@ export function apply(ctx, rawConfig) {
|
|
|
165
167
|
const workspaceFor = async (convKey, overrides) => {
|
|
166
168
|
const enabled = overrides?.autoGroup === undefined ? config.autoGroup === true : overrides.autoGroup === true
|
|
167
169
|
if (!enabled) return config.cwd
|
|
168
|
-
const root = String(overrides?.autoGroupRoot || config.autoGroupRoot || '
|
|
170
|
+
const root = String(overrides?.autoGroupRoot || config.autoGroupRoot || join(config.dataDir, 'auto-group'))
|
|
169
171
|
const name = convKey.replace(/[^A-Za-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 60) || 'qq'
|
|
170
172
|
const dir = join(root, name)
|
|
171
173
|
try {
|
|
@@ -813,6 +815,19 @@ export function apply(ctx, rawConfig) {
|
|
|
813
815
|
const installed = await readInstall(config.dataDir)
|
|
814
816
|
const pythonPath = typeof installed?.pythonPath === 'string' && installed.pythonPath !== '' ? installed.pythonPath : config.pythonPath
|
|
815
817
|
const botDir = typeof installed?.botDir === 'string' && installed.botDir !== '' ? installed.botDir : config.botDir
|
|
818
|
+
// 没配置 / 路径不存在就明确跳过:spawn 的 ENOENT 是异步 'error' 事件,抛不进 try/catch,会直接崩掉宿主
|
|
819
|
+
if (pythonPath === '' || botDir === '') {
|
|
820
|
+
log('bot autostart skipped: pythonPath/botDir 未配置(用设置页的「下载 / 配置机器人」装一次)')
|
|
821
|
+
return
|
|
822
|
+
}
|
|
823
|
+
if (!existsSync(join(botDir, 'main.py'))) {
|
|
824
|
+
log(`bot autostart skipped: 找不到 ${join(botDir, 'main.py')}`)
|
|
825
|
+
return
|
|
826
|
+
}
|
|
827
|
+
if (!existsSync(pythonPath)) {
|
|
828
|
+
log(`bot autostart skipped: 解释器不存在 ${pythonPath}`)
|
|
829
|
+
return
|
|
830
|
+
}
|
|
816
831
|
const { spawn } = await import('node:child_process')
|
|
817
832
|
const child = spawn(pythonPath, ['-u', 'main.py', '--supervise'], {
|
|
818
833
|
cwd: botDir,
|
|
@@ -820,6 +835,7 @@ export function apply(ctx, rawConfig) {
|
|
|
820
835
|
stdio: 'ignore',
|
|
821
836
|
windowsHide: true,
|
|
822
837
|
})
|
|
838
|
+
child.on('error', (error) => log(`bot autostart failed: ${error.message}`))
|
|
823
839
|
child.unref()
|
|
824
840
|
log(`bot supervisor spawned (pid ${child.pid})`)
|
|
825
841
|
} catch (error) {
|
|
@@ -1053,7 +1069,7 @@ export function apply(ctx, rawConfig) {
|
|
|
1053
1069
|
|
|
1054
1070
|
const readMembers = () => {
|
|
1055
1071
|
try {
|
|
1056
|
-
const file = join(String(config.botDir ||
|
|
1072
|
+
const file = join(String(config.botDir || join(config.dataDir, 'bot')), "state", "members.json")
|
|
1057
1073
|
const raw = readFileSync(file, "utf8")
|
|
1058
1074
|
return JSON.parse(raw)
|
|
1059
1075
|
} catch (error) {
|
package/lib/install.js
CHANGED
|
@@ -250,7 +250,7 @@ export class Installer {
|
|
|
250
250
|
|
|
251
251
|
/** 写 bot/config.json 与 bot/.env:面板可改的进 json,启动时读的进 .env。 */
|
|
252
252
|
async #writeConfig({ appid, appsecret, autoGroupRoot, bridgeUrl, bridgeToken }) {
|
|
253
|
-
// 面板回传的密钥是打码值(
|
|
253
|
+
// 面板回传的密钥是打码值(ab12****yz),写进去等于没有,必须跳过
|
|
254
254
|
const clean = (value) => {
|
|
255
255
|
const text = typeof value === 'string' ? value.trim() : ''
|
|
256
256
|
return text.includes('****') ? '' : text
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcviseron/dsh-qq-bridge",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "DeepSeek Harness plugin: bridge QQ conversations (driven by an external viseron-botpy bot) to DSH sessions — injects user messages, captures assistant replies, streams C2C answers, and relays tool approvals to the bot owner.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|