dsh-chat-comprehension 0.4.0 → 0.5.1
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/NOTICE.md +4 -3
- package/README.md +62 -15
- package/client.js +400 -52
- package/lib/engines.mjs +36 -5
- package/lib/index.js +210 -20
- package/lib/qqbot-0.5.3-patches.json +31 -1
- package/lib/qqbot-patch.mjs +1 -1
- package/lib/video.mjs +45 -2
- package/package.json +6 -6
- package/vendor/dsh-agent-md/lib/chat-persona.js +9 -3
- package/vendor/dsh-agent-md/lib/index.js +72 -18
- package/vendor/dsh-agent-md/lib/qq.js +64 -0
- package/vendor/dsh-agent-md/package.json +1 -1
- package/vendor/dsh-bili-scroll/index.js +39 -10
- package/vendor/dsh-meme/index.js +3 -1
- package/vendor/dsh-video-storyboard/LICENSE-workbuddy.txt +21 -0
- package/vendor/dsh-video-storyboard/NOTICE +7 -0
- package/vendor/dsh-video-storyboard/NOTICE-workbuddy.md +18 -0
- package/vendor/dsh-video-storyboard/dsh.plugin.json +1 -1
- package/vendor/dsh-video-storyboard/package.json +1 -1
- package/vendor/dsh-video-storyboard/src/sniff.mjs +545 -0
- package/vendor/dsh-video-storyboard/src/storyboard/direct-url.js +2 -2
- package/vendor/dsh-video-storyboard/src/storyboard/fetch.js +3 -3
- package/vendor/dsh-video-storyboard/src/storyboard/pipeline.js +1 -1
- package/vendor/dsh-video-storyboard/src/storyboard/source.js +409 -0
- package/vendor/dsh-video-storyboard/src/storyboard/tool-spec.js +5 -3
- package/vendor/dsh-video-storyboard/src/storyboard/url.js +105 -17
- package/vendor/dsh-video-storyboard/src/tools/locate.js +1 -1
- package/vendor/dsh-video-storyboard/src/tools/probe.js +4 -6
- package/vendor/dsh-video-storyboard/src/tools/zoom.js +1 -1
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
listTemplates,
|
|
34
34
|
listWorkspaces,
|
|
35
35
|
normalizePathKey,
|
|
36
|
+
isInsideAgentsRoot,
|
|
36
37
|
normalizeText,
|
|
37
38
|
projectsDir,
|
|
38
39
|
readTextFile,
|
|
@@ -42,12 +43,13 @@ import {
|
|
|
42
43
|
statePath,
|
|
43
44
|
writeTextFile,
|
|
44
45
|
} from './persona.js'
|
|
45
|
-
import { bindQqPeer, parsePeerKey, qqStatus, readBindings, readQqPeers, syncQqMemoryWithPeers, unbindQqPeer } from './qq.js'
|
|
46
|
+
import { bindQqPeer, parsePeerKey, qqStatus, readBindings, readQqPeers, resetQqPeerSession, setQqModelOverride, syncQqMemoryWithPeers, unbindQqPeer } from './qq.js'
|
|
46
47
|
import {
|
|
47
48
|
composeChatPersona,
|
|
48
49
|
listChats,
|
|
49
50
|
readChatPersona,
|
|
50
51
|
removeChatPersona,
|
|
52
|
+
peerKeyForSession,
|
|
51
53
|
resolveChatPersonaForSession,
|
|
52
54
|
saveChatPersona,
|
|
53
55
|
syncChatRegistry,
|
|
@@ -86,6 +88,31 @@ const DEFAULT_CONFIG = {
|
|
|
86
88
|
/** 内存态配置(启动时从 statePath() 读回)。 */
|
|
87
89
|
let config = { ...DEFAULT_CONFIG }
|
|
88
90
|
|
|
91
|
+
/** 合法人格文件名:只允许 .md 结尾的安全字符名,挡掉 .bat / authorized_keys 等。 */
|
|
92
|
+
const LEGAL_LOCAL_NAME = /^[A-Za-z0-9._-]{1,64}\.md$/
|
|
93
|
+
|
|
94
|
+
export function sanitizeLocalNames(list) {
|
|
95
|
+
if (!Array.isArray(list)) return null
|
|
96
|
+
const names = list.filter((n) => typeof n === 'string' && LEGAL_LOCAL_NAME.test(n.trim())).map((n) => n.trim())
|
|
97
|
+
return names.length > 0 ? names.slice(0, 5) : null
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** 同源闸:挡住浏览器跨源发起的 text/plain 简单请求;无 Origin 的本机客户端放行。 */
|
|
101
|
+
export function sameOrigin(req) {
|
|
102
|
+
const headers = req.headers ?? {}
|
|
103
|
+
const site = headers['sec-fetch-site']
|
|
104
|
+
if (site === 'cross-site' || site === 'same-site') return false
|
|
105
|
+
const origin = headers.origin
|
|
106
|
+
if (origin === undefined || origin === '') return true
|
|
107
|
+
try { return new URL(origin).host === headers.host } catch { return false }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** POST 写接口只接受 application/json,挡掉不触发预检的跨源简单请求。 */
|
|
111
|
+
export function isJsonRequest(req) {
|
|
112
|
+
return String(req.headers?.['content-type'] || '').toLowerCase().startsWith('application/json')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
89
116
|
/**
|
|
90
117
|
* 浏览器半侧的握手回执。
|
|
91
118
|
*
|
|
@@ -142,10 +169,8 @@ function loadConfig() {
|
|
|
142
169
|
if (typeof parsed.chatPersonaEnabled === 'boolean') config.chatPersonaEnabled = parsed.chatPersonaEnabled
|
|
143
170
|
if (typeof parsed.chatModelEnabled === 'boolean') config.chatModelEnabled = parsed.chatModelEnabled
|
|
144
171
|
if (typeof parsed.showInSettings === 'boolean') config.showInSettings = parsed.showInSettings
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (names.length > 0) config.localNames = names.slice(0, 5)
|
|
148
|
-
}
|
|
172
|
+
const names = sanitizeLocalNames(parsed.localNames)
|
|
173
|
+
if (names !== null) config.localNames = names
|
|
149
174
|
} catch {
|
|
150
175
|
// 损坏 → 保持默认
|
|
151
176
|
}
|
|
@@ -440,8 +465,10 @@ export function apply(ctx) {
|
|
|
440
465
|
if (!config.chatModelEnabled || config.enabled === false) return
|
|
441
466
|
const sessionId = String(agent?.id || '')
|
|
442
467
|
if (sessionId === '') return
|
|
443
|
-
//
|
|
444
|
-
|
|
468
|
+
// 会话专属模型优先;普通会话不套用「QQ 默认模型」——
|
|
469
|
+
// 那个默认值只该影响接入 QQ 的对话(用户明确要求:网页里别的对话不要被换掉)。
|
|
470
|
+
const peerKey = peerKeyForSession(sessionId)
|
|
471
|
+
const wanted = chatModelForSession(sessionId) || (peerKey !== '' ? globalModel() : null)
|
|
445
472
|
if (wanted === null) return
|
|
446
473
|
const current = typeof agent.model?.current === 'function' ? agent.model.current() : undefined
|
|
447
474
|
if (current !== undefined && current.provider === wanted.provider && current.model === wanted.model) return
|
|
@@ -465,6 +492,8 @@ export function apply(ctx) {
|
|
|
465
492
|
kind: 'prefix',
|
|
466
493
|
path: API_PREFIX,
|
|
467
494
|
handler: async (req, res) => {
|
|
495
|
+
if (!sameOrigin(req)) return sendJson(res, 403, { error: '跨源请求已拒绝' })
|
|
496
|
+
if (req.method === 'POST' && !isJsonRequest(req)) return sendJson(res, 415, { error: '只接受 application/json 请求体' })
|
|
468
497
|
const route = (req.url ?? '').split('?')[0].slice(API_PREFIX.length) || '/'
|
|
469
498
|
try {
|
|
470
499
|
if (route === '/state' && req.method === 'GET') {
|
|
@@ -541,6 +570,9 @@ export function apply(ctx) {
|
|
|
541
570
|
|
|
542
571
|
/** 写一个受管人格文件(带 .bak 备份)。 */
|
|
543
572
|
const writeManaged = async (file) => {
|
|
573
|
+
if (!isInsideAgentsRoot(file) && path.resolve(file) !== path.resolve(globalPath())) {
|
|
574
|
+
throw Object.assign(new Error('目标路径不在人格目录内,已拒绝'), { status: 400 })
|
|
575
|
+
}
|
|
544
576
|
if (Buffer.byteLength(content, 'utf8') > MAX_FILE_BYTES) {
|
|
545
577
|
throw Object.assign(new Error(`内容超过上限 ${Math.round(MAX_FILE_BYTES / 1024)} KB`), { status: 413 })
|
|
546
578
|
}
|
|
@@ -604,7 +636,14 @@ export function apply(ctx) {
|
|
|
604
636
|
const deleted = await removeLocal(cwd)
|
|
605
637
|
return sendJson(res, 200, { saved: true, file: deleted, scope, kind, deleted: true })
|
|
606
638
|
}
|
|
607
|
-
const
|
|
639
|
+
const name = config.localNames[0]
|
|
640
|
+
if (!LEGAL_LOCAL_NAME.test(name)) {
|
|
641
|
+
throw Object.assign(new Error(`非法人格文件名: ${name}`), { status: 400 })
|
|
642
|
+
}
|
|
643
|
+
const target = path.join(cwd, name)
|
|
644
|
+
try { await fs.access(path.dirname(target)) } catch {
|
|
645
|
+
throw Object.assign(new Error('目标目录不存在,不会自动创建'), { status: 400 })
|
|
646
|
+
}
|
|
608
647
|
if (Buffer.byteLength(content, 'utf8') > MAX_FILE_BYTES) {
|
|
609
648
|
throw Object.assign(new Error(`内容超过上限 ${Math.round(MAX_FILE_BYTES / 1024)} KB`), { status: 413 })
|
|
610
649
|
}
|
|
@@ -616,7 +655,6 @@ export function apply(ctx) {
|
|
|
616
655
|
// 忽略
|
|
617
656
|
}
|
|
618
657
|
}
|
|
619
|
-
await fs.mkdir(path.dirname(target), { recursive: true })
|
|
620
658
|
const tmpLocal = `${target}.tmp-${process.pid}`
|
|
621
659
|
await fs.writeFile(tmpLocal, normalizeText(content), 'utf8')
|
|
622
660
|
await fs.rename(tmpLocal, target)
|
|
@@ -678,10 +716,8 @@ export function apply(ctx) {
|
|
|
678
716
|
if (typeof body.projectPersonaEnabled === 'boolean') config.projectPersonaEnabled = body.projectPersonaEnabled
|
|
679
717
|
if (typeof body.showInSettings === 'boolean') config.showInSettings = body.showInSettings
|
|
680
718
|
if (Array.isArray(body.localNames)) {
|
|
681
|
-
const names = body.localNames
|
|
682
|
-
|
|
683
|
-
.map((n) => n.trim())
|
|
684
|
-
config.localNames = names.length > 0 ? names.slice(0, 5) : DEFAULT_CONFIG.localNames
|
|
719
|
+
const names = sanitizeLocalNames(body.localNames)
|
|
720
|
+
config.localNames = names !== null ? names : DEFAULT_CONFIG.localNames
|
|
685
721
|
}
|
|
686
722
|
await persistConfig()
|
|
687
723
|
return sendJson(res, 200, { ok: true, config: { ...config } })
|
|
@@ -689,6 +725,9 @@ export function apply(ctx) {
|
|
|
689
725
|
|
|
690
726
|
if (route === '/open' && req.method === 'POST') {
|
|
691
727
|
const body = await readBody(req)
|
|
728
|
+
if (/^\\\\/.test(String(body.cwd ?? '')) || /^\\\\/.test(String(body.path ?? ''))) {
|
|
729
|
+
throw Object.assign(new Error('不允许 UNC 路径'), { status: 400 })
|
|
730
|
+
}
|
|
692
731
|
const scope = String(body.scope ?? 'global')
|
|
693
732
|
let target = ''
|
|
694
733
|
if (scope === 'global') {
|
|
@@ -786,8 +825,18 @@ export function apply(ctx) {
|
|
|
786
825
|
}
|
|
787
826
|
if (route === '/chats/workspace' && req.method === 'POST') {
|
|
788
827
|
const body = await readBody(req)
|
|
789
|
-
const
|
|
790
|
-
|
|
828
|
+
const peerKey = String(body.peerKey || '')
|
|
829
|
+
const before = chatWorkspaceOf(peerKey)
|
|
830
|
+
const saved = saveChatWorkspace(peerKey, String(body.cwd || ''))
|
|
831
|
+
// 只写文件不够:已经存在的 QQ 会话还是会 resume 回旧目录。
|
|
832
|
+
// 让网关把会话 fork / 重建到新工作区,下一次消息就落在这里。
|
|
833
|
+
// 值没变就不折腾会话(避免同一个工作区被反复重建)。
|
|
834
|
+
const applied = saved.cwd === before ? { ok: true, unchanged: true } : await resetQqPeerSession(ctx, peerKey)
|
|
835
|
+
return sendJson(res, 200, {
|
|
836
|
+
...saved,
|
|
837
|
+
applied,
|
|
838
|
+
chats: listChats().map((c) => ({ ...c, cwd: chatWorkspaceOf(c.peerKey) })),
|
|
839
|
+
})
|
|
791
840
|
}
|
|
792
841
|
if (route === '/chats/model' && req.method === 'POST') {
|
|
793
842
|
const body = await readBody(req)
|
|
@@ -798,13 +847,18 @@ export function apply(ctx) {
|
|
|
798
847
|
const known = await knownModel(ctx, provider, model)
|
|
799
848
|
if (known === false) throw Object.assign(new Error(`DSH 里没有模型 ${provider}/${model}(provider 没启用或模型名不对)`), { status: 400 })
|
|
800
849
|
const saved = saveChatModel(peerKey, { provider, model, reasoningEffort: body.reasoningEffort })
|
|
801
|
-
//
|
|
850
|
+
// 1) 写进网关自己的 per-peer 覆盖:以后新建 / 恢复这个聊天都会先用这个模型
|
|
851
|
+
let routed = false
|
|
852
|
+
try { routed = setQqModelOverride(peerKey, saved.selection) } catch { routed = false }
|
|
853
|
+
// 2) 这个 QQ 聊天的对话要是正开着,立刻换上,不用等下次重开
|
|
802
854
|
const applied = applyChatModelNow(ctx, peerKey, saved.selection)
|
|
803
|
-
return sendJson(res, 200, { ...saved, applied, models: listChatModels() })
|
|
855
|
+
return sendJson(res, 200, { ...saved, routed, applied, models: listChatModels() })
|
|
804
856
|
}
|
|
805
857
|
if (route === '/chats/model/delete' && req.method === 'POST') {
|
|
806
858
|
const body = await readBody(req)
|
|
807
|
-
const
|
|
859
|
+
const peerKey = String(body.peerKey || '')
|
|
860
|
+
const removed = removeChatModel(peerKey)
|
|
861
|
+
try { setQqModelOverride(peerKey, null) } catch { /* 网关没装也不影响删除 */ }
|
|
808
862
|
return sendJson(res, 200, { ...removed, models: listChatModels() })
|
|
809
863
|
}
|
|
810
864
|
if (route === '/qq' && req.method === 'GET') {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* 以真实路径解析,裸包名会解析失败)。
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
import { randomUUID } from 'node:crypto'
|
|
24
25
|
import { spawnSync } from 'node:child_process'
|
|
25
26
|
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from 'node:fs'
|
|
26
27
|
import { homedir } from 'node:os'
|
|
@@ -365,6 +366,59 @@ export function peerKeyFor(appId, scope, peerId) {
|
|
|
365
366
|
return `${KEY_PREFIX}${appId}:${scope}:${peerId}`
|
|
366
367
|
}
|
|
367
368
|
|
|
369
|
+
/**
|
|
370
|
+
* 把「这个 QQ 聊天用哪个模型」写进网关自己的 per-peer 覆盖表。
|
|
371
|
+
* 网关建会话/恢复会话时会读它,所以新建的群也能一开口就用对模型。
|
|
372
|
+
* @param {string} peerKey `qqbot:<appId>:<scope>:<peerId>`
|
|
373
|
+
* @param {{provider:string,model:string,reasoningEffort?:string}|null} route null 表示删掉覆盖
|
|
374
|
+
*/
|
|
375
|
+
export function setQqModelOverride(peerKey, route) {
|
|
376
|
+
const key = String(peerKey || '')
|
|
377
|
+
if (parsePeerKey(key) === null) return false
|
|
378
|
+
const prefs = readQqPrefs()
|
|
379
|
+
if (route && String(route.provider || '') !== '' && String(route.model || '') !== '') {
|
|
380
|
+
prefs.overrides[key] = {
|
|
381
|
+
provider: String(route.provider),
|
|
382
|
+
model: String(route.model),
|
|
383
|
+
...(String(route.reasoningEffort || '') !== '' ? { reasoningEffort: String(route.reasoningEffort) } : {}),
|
|
384
|
+
}
|
|
385
|
+
} else {
|
|
386
|
+
delete prefs.overrides[key]
|
|
387
|
+
}
|
|
388
|
+
writeQqPrefs(prefs)
|
|
389
|
+
return true
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* 让人格 / 工作区改动立刻作用到这个 QQ 聊天:
|
|
394
|
+
* 1. 网关补丁 v6 有 companionQq.resetSession 时,让它 fork 到新目录(保留历史);
|
|
395
|
+
* 2. 没有的话退回「换一个新的 sessionId + 重启网关」,下一条消息会按新工作区新建会话
|
|
396
|
+
* (更早的对话仍然在 QQ 记忆里,不会被忘掉)。
|
|
397
|
+
* @returns {Promise<{ok:boolean, rebuilt?:boolean, error?:string}>}
|
|
398
|
+
*/
|
|
399
|
+
export async function resetQqPeerSession(ctx, peerKey) {
|
|
400
|
+
const key = String(peerKey || '')
|
|
401
|
+
if (parsePeerKey(key) === null) return { ok: false, error: '不是合法的 QQ 会话 key' }
|
|
402
|
+
try {
|
|
403
|
+
const qq = ctx && typeof ctx.get === 'function' ? ctx.get('companionQq') : null
|
|
404
|
+
if (qq && typeof qq.resetSession === 'function') {
|
|
405
|
+
const r = await qq.resetSession(key)
|
|
406
|
+
if (r && r.ok) return r
|
|
407
|
+
}
|
|
408
|
+
} catch { /* 老补丁没有这个方法 */ }
|
|
409
|
+
try {
|
|
410
|
+
const prefs = readQqPrefs()
|
|
411
|
+
prefs.sessionIds[key] = randomUUID()
|
|
412
|
+
writeQqPrefs(prefs)
|
|
413
|
+
const { entry } = findQqEntry(ctx)
|
|
414
|
+
await stopGatewayEntry(entry)
|
|
415
|
+
const reload = await startGatewayEntry(ctx, entry)
|
|
416
|
+
return { ok: true, rebuilt: false, reload }
|
|
417
|
+
} catch (error) {
|
|
418
|
+
return { ok: false, error: String((error && error.message) || error) }
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
368
422
|
/**
|
|
369
423
|
* 列出网关已经记下的 QQ 账号(= prefs.sessionIds 的 key)。
|
|
370
424
|
*
|
|
@@ -374,11 +428,21 @@ export function peerKeyFor(appId, scope, peerId) {
|
|
|
374
428
|
export function listQqPeers(prefs) {
|
|
375
429
|
const table = (prefs || readQqPrefs()).sessionIds
|
|
376
430
|
const peers = []
|
|
431
|
+
const seen = new Set()
|
|
377
432
|
for (const [key, sessionId] of Object.entries(table)) {
|
|
378
433
|
const info = parsePeerKey(key)
|
|
379
434
|
if (info === null) continue
|
|
435
|
+
seen.add(info.key)
|
|
380
436
|
peers.push({ ...info, sessionId: typeof sessionId === 'string' ? sessionId : '' })
|
|
381
437
|
}
|
|
438
|
+
// 网关卡(补丁 v5 写)里有、但 prefs 还没登记的聊天(比如第一次说话的群)也要列出来,
|
|
439
|
+
// 否则页面里根本看不到这个群,人格/工作区/模型都没地方设。
|
|
440
|
+
for (const [key, row] of Object.entries(readQqPeers())) {
|
|
441
|
+
const info = parsePeerKey(key)
|
|
442
|
+
if (info === null || seen.has(info.key)) continue
|
|
443
|
+
seen.add(info.key)
|
|
444
|
+
peers.push({ ...info, sessionId: row && typeof row.current === 'string' ? row.current : '' })
|
|
445
|
+
}
|
|
382
446
|
peers.sort((a, b) => (a.scope === b.scope ? a.peerId.localeCompare(b.peerId) : a.scope === 'c2c' ? -1 : 1))
|
|
383
447
|
return peers
|
|
384
448
|
}
|
|
@@ -77,7 +77,7 @@ export const Config = !z ? undefined : z.object({
|
|
|
77
77
|
/** 关注关键词(空了用章程里默认那几组) */
|
|
78
78
|
keywords: z.array(z.string()).default([]).extra('volatile', true),
|
|
79
79
|
/** Python:指向 venv 里的那个最好 */
|
|
80
|
-
pythonPath: z.string().default('python').extra('volatile', true),
|
|
80
|
+
pythonPath: z.string().default(process.platform === 'win32' ? 'python' : 'python3').extra('volatile', true),
|
|
81
81
|
/** dsh 的 bin.js(不填就试自动探测,再退化成 shell 里的 dsh) */
|
|
82
82
|
dshBin: z.string().default('').extra('volatile', true),
|
|
83
83
|
/** headless 那一轮用哪个 profile */
|
|
@@ -106,7 +106,7 @@ export const Config = !z ? undefined : z.object({
|
|
|
106
106
|
/** 值班轮用的 model(留空 = 跟当前默认模型) */
|
|
107
107
|
roundModel: z.string().default('').extra('volatile', true),
|
|
108
108
|
/** 「人格」页对应的项目目录 */
|
|
109
|
-
personaCwd: z.string().default('
|
|
109
|
+
personaCwd: z.string().default('').extra('volatile', true),
|
|
110
110
|
/** 「别像 AI」那段文字(使用者自己写;留空就不加) */
|
|
111
111
|
extraPrompt: z.string().default('').extra('volatile', true),
|
|
112
112
|
/** 带上 QQ 对话的记忆摘要(<DSH_HOME>/agents/qq-memory.md) */
|
|
@@ -270,8 +270,8 @@ function reportMeta() {
|
|
|
270
270
|
personaPrompt: '',
|
|
271
271
|
perDay: 5, peakValley: false, noon: true, night: true, autoComment: false, transcribe: false, asrModel: 'small',
|
|
272
272
|
dmMode: 'only', dmUid: 0,
|
|
273
|
-
keywords: [], roundProvider: '', roundModel: '', commentPerRound: 1, mentionName: '', pythonPath: 'python', dshBin: '', headlessProfile: 'headless', overlayMcp: true, workspace: '', reportLevel: 'full', replyToComments: false, replyPerRound: 1, favFolderId: 0,
|
|
274
|
-
customTimes: '', timeSync: true, focusFollowings: true, focusLimit: 12, focusTopicsEnabled: false, focusTopics: '', personaFromPage: true, personaCwd: '
|
|
273
|
+
keywords: [], roundProvider: '', roundModel: '', commentPerRound: 1, mentionName: '', pythonPath: process.platform === 'win32' ? 'python' : 'python3', dshBin: '', headlessProfile: 'headless', overlayMcp: true, workspace: '', reportLevel: 'full', replyToComments: false, replyPerRound: 1, favFolderId: 0,
|
|
274
|
+
customTimes: '', timeSync: true, focusFollowings: true, focusLimit: 12, focusTopicsEnabled: false, focusTopics: '', personaFromPage: true, personaCwd: '', extraPrompt: '', memoryExcerpt: true,
|
|
275
275
|
}
|
|
276
276
|
const normalize = (src, base) => {
|
|
277
277
|
const out = { ...base }
|
|
@@ -420,6 +420,19 @@ function reportMeta() {
|
|
|
420
420
|
const cfg = loadCfg()
|
|
421
421
|
// ⭐ 配置是"随时可能被设置页就地改掉"的东西 ⇒ 每个入口用之前重算一遍(cfg 这个对象要一直指向同一份)
|
|
422
422
|
const refreshCfg = () => { Object.assign(cfg, loadCfg()) }
|
|
423
|
+
/**
|
|
424
|
+
* 热重载(HMR)激活本插件时,apply 跑在 hmr.executing 上下文里;此时再调
|
|
425
|
+
* ctx.settings.update() 会二次进入 hmr.runExclusive 并抛
|
|
426
|
+
* "HMR transactions cannot be nested",设置就静默同步失败(上游 2.5.2 / #198)。
|
|
427
|
+
* 调用前先退出这个 store;其它路径不受影响。
|
|
428
|
+
*/
|
|
429
|
+
const outsideHmr = (fn) => {
|
|
430
|
+
try {
|
|
431
|
+
const ex = ctx.get('hmr')?.executing
|
|
432
|
+
if (ex && typeof ex.exit === 'function' && ex.getStore()) return ex.exit(fn)
|
|
433
|
+
} catch { /* 老宿主没有这个字段 */ }
|
|
434
|
+
return fn()
|
|
435
|
+
}
|
|
423
436
|
|
|
424
437
|
/* ─────────────── 值班进阶:联网校时 / 自定义时间 / 关注 UP 主 / 人格页 / 记忆 ───────────────
|
|
425
438
|
* 这一层是 dsh-bili-scroll 之上给这个本机加的东西,全部只读配置、只影响「哪一轮、看谁、怎么说」。
|
|
@@ -473,7 +486,7 @@ function reportMeta() {
|
|
|
473
486
|
*/
|
|
474
487
|
const personaPageText = () => {
|
|
475
488
|
try {
|
|
476
|
-
const file = join(dshHomeDir(), 'agents', 'projects', `${slugForCwd(cfg.personaCwd)}.md`)
|
|
489
|
+
const file = join(dshHomeDir(), 'agents', 'projects', `${slugForCwd(cfg.personaCwd || cfg.workspace)}.md`)
|
|
477
490
|
let text = readFileSync(file, 'utf8')
|
|
478
491
|
text = text.replace(/<!--[\s\S]*?-->/g, '').trim()
|
|
479
492
|
const parts = text.split(/(?=【[^】]+】)/)
|
|
@@ -563,7 +576,7 @@ function reportMeta() {
|
|
|
563
576
|
if (!row?.ns || typeof ctx.settings?.update !== 'function') {
|
|
564
577
|
throw Object.assign(new Error('DSH 这边没有可写的设置表单(值只落在插件自己的 config.json 里)'), { noForm: true })
|
|
565
578
|
}
|
|
566
|
-
await ctx.settings.update(row.ns, patch, row.revision)
|
|
579
|
+
await outsideHmr(() => ctx.settings.update(row.ns, patch, row.revision))
|
|
567
580
|
// ⭐ READBACK(2026-10-18):update() 不报错 ≠ 值真的生效 ✗
|
|
568
581
|
// 三四位用户装了 0.1.9 后开关照样弹回,而界面**没有**出现"没同步"提示
|
|
569
582
|
// ⇒ 说明 host.ok 判成了成功、值却没落进生效层 ⇒ 必须**回读用户层**再确认一遍 ✓
|
|
@@ -649,7 +662,7 @@ function reportMeta() {
|
|
|
649
662
|
if (!existsSync(script)) throw new Error(`家里没有 mcp_server.py(应有 ${script})—— 装上插件后重启一次 dsh 会自动铺好`)
|
|
650
663
|
mcpKey = mcpKeyNow()
|
|
651
664
|
mcp = new McpClient({
|
|
652
|
-
command: cfg.pythonPath || 'python',
|
|
665
|
+
command: cfg.pythonPath || (process.platform === 'win32' ? 'python' : 'python3'),
|
|
653
666
|
args: [script],
|
|
654
667
|
cwd: stateDir, // 凭证落在家里 ✓
|
|
655
668
|
// ⭐ 这个内置的 Python MCP 会往 stdout 打中文(ensure_ascii=False);
|
|
@@ -1512,18 +1525,34 @@ function reportMeta() {
|
|
|
1512
1525
|
// ⇒ overlay 里补一条 agent-default-model,**优先跟随用户当前选的模型**;拿不到就不写(保持原行为)✓
|
|
1513
1526
|
try {
|
|
1514
1527
|
const sel = ctx.get('agentDefaultModel')?.currentSelection?.() ?? null
|
|
1528
|
+
// companion 的「默认模型(全局)」:只作用于 QQ 和 B站 值班,绝不改 DSH 网页对话的默认模型。
|
|
1529
|
+
// (0.5.0 起不再通过改 agentDefaultModel 实现,所以在这里直接读那份文件。)
|
|
1530
|
+
const companion = (() => {
|
|
1531
|
+
try {
|
|
1532
|
+
const home = String(process.env.DSH_HOME || '').trim() || join(homedir(), '.dsh')
|
|
1533
|
+
const raw = readJson(join(home, 'agents', 'companion-model.json'), {}) || {}
|
|
1534
|
+
const provider = String(raw.provider || '').trim()
|
|
1535
|
+
const model = String(raw.model || '').trim()
|
|
1536
|
+
return provider !== '' && model !== '' ? { provider, model, reasoningEffort: String(raw.reasoningEffort || '').trim() } : null
|
|
1537
|
+
} catch { return null }
|
|
1538
|
+
})()
|
|
1515
1539
|
// ⭐ 2026-11-07(用户要求):值班轮可以有自己独立的模型,和 QQ / 网页默认互不干扰。
|
|
1516
1540
|
const cfgProvider = String(cfg.roundProvider || '').trim()
|
|
1517
1541
|
const cfgModel = String(cfg.roundModel || '').trim()
|
|
1518
|
-
|
|
1519
|
-
|
|
1542
|
+
// headless 值班 profile 里只保证有 deepseek-account 这条路由;companion 默认若是别的
|
|
1543
|
+
// (比如 packyapi),headless 里没有 adapter,照搬会直接 NO_ADAPTER。所以只在可用时沿用。
|
|
1544
|
+
const useCompanion = companion !== null && cfgProvider === '' && cfgModel === ''
|
|
1545
|
+
&& /^deepseek-account$/.test(String(companion.provider || ''))
|
|
1546
|
+
const selProvider = cfgProvider !== '' ? cfgProvider : (useCompanion ? companion.provider : (sel?.provider ?? sel?.providerId))
|
|
1547
|
+
const selModel = cfgModel !== '' ? cfgModel : (useCompanion ? companion.model : (sel?.model ?? sel?.modelId))
|
|
1548
|
+
const selEffort = useCompanion ? companion.reasoningEffort : String(sel?.reasoningEffort ?? '')
|
|
1520
1549
|
if (selProvider && selModel) {
|
|
1521
1550
|
yml.push(
|
|
1522
1551
|
'- id: agent-default-model',
|
|
1523
1552
|
' config:',
|
|
1524
1553
|
' provider: ' + String(selProvider),
|
|
1525
1554
|
' model: ' + String(selModel),
|
|
1526
|
-
...(
|
|
1555
|
+
...(selEffort ? [' reasoningEffort: ' + String(selEffort)] : []),
|
|
1527
1556
|
'',
|
|
1528
1557
|
)
|
|
1529
1558
|
}
|
package/vendor/dsh-meme/index.js
CHANGED
|
@@ -603,7 +603,9 @@ export function apply(ctx, config) {
|
|
|
603
603
|
text = custom ? custom + '\n\n' + imCompanionRules(channel) : imCompanionPrompt(channel)
|
|
604
604
|
}
|
|
605
605
|
if (sendMode === 'image') text = text + '\n\n' + IMAGE_MODE_RULE
|
|
606
|
-
|
|
606
|
+
// 显式给 order:新版 DSH 的段准入会把没有有限 order 的 waterfall 段判成不可 JSON 序列化,
|
|
607
|
+
// 整轮对话直接失败;上游 dsh-meme 0.1.85 同样用 10200(排在宿主内置末段 10100 之后)。
|
|
608
|
+
assembled.sections.push({ name: 'dsh-expression:companion', order: 10200, text })
|
|
607
609
|
return assembled
|
|
608
610
|
})
|
|
609
611
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 video-comprehension contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -10,3 +10,10 @@ Documentation images in `docs/` are not part of that grant:
|
|
|
10
10
|
|
|
11
11
|
No third-party footage, model weights or binaries are redistributed in this repository. See
|
|
12
12
|
`CREDITS.md` for the projects this one takes ideas from.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 本插件内的改动(0.5.1)
|
|
16
|
+
|
|
17
|
+
页面嗅探与取源层(`src/sniff.mjs`、`src/storyboard/source.js`)、远程取源兜底与安全闸,
|
|
18
|
+
移植/改写自 [workbuddy-video-comprehension](https://github.com/JoeXuan123/workbuddy-video-comprehension)
|
|
19
|
+
(MIT,Copyright (c) 2026 video-comprehension contributors);按 MIT 许可随本包分发。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# NOTICE
|
|
2
|
+
|
|
3
|
+
## dsh-video-storyboard
|
|
4
|
+
|
|
5
|
+
`server/storyboard/` 下的分镜算法层移植自 **dsh-video-storyboard**:
|
|
6
|
+
|
|
7
|
+
- 项目:<https://github.com/SAOS-3624/dsh-video-storyboard>
|
|
8
|
+
- 作者:SAOS-3624
|
|
9
|
+
- 许可证:MIT,原文见 [`third_party/dsh-video-storyboard-LICENSE.txt`](third_party/dsh-video-storyboard-LICENSE.txt)
|
|
10
|
+
- 取自 [JoeXuan123/dsh-chat-comprehension](https://github.com/JoeXuan123/dsh-chat-comprehension) 仓库的 `vendor/dsh-video-storyboard`(版本 0.5.0)
|
|
11
|
+
|
|
12
|
+
涉及文件:`pipeline.js`、`scan.js`、`plan.js`、`density.js`、`segments.js`、`flash.js`、`sheet.js`、`frames.js`、`audio.js`、`probe.js`、`format.js`、`board.js`、`cache.js`、`media-store.js`、`storage.js`、`direct-url.js`、`locate.js`、`memory.js`、`cells.js`、`injection.js`、`provenance.js`、`transcript-file.js`、`url.js`、`fetch.js`、`ytdlp.js`,以及 `transcript.js`、`subtitles.js`、`binaries.js` 中的一部分。
|
|
13
|
+
|
|
14
|
+
移植时做的改动:去掉 DSH 宿主专用的部分(本机 / 云端 ASR、OCR 硬字幕校正、从浏览器读 cookies 的自愈),把环境变量和配置路径换成 WorkBuddy 插件约定,转写改为交给宿主的音频转写工具再回填。镜头切分、分格规划、选帧、拼图、清单渲染等算法本身未改动。
|
|
15
|
+
|
|
16
|
+
## 边界
|
|
17
|
+
|
|
18
|
+
本插件不托管、不分发任何视频内容,下载的副本只缓存在本机并会自动淘汰;不提供 DRM 绕过、付费内容访问、区域限制绕过或批量抓取能力。能不能下载某个链接取决于你有没有相应授权,请自行确认并遵守目标站点的条款与当地法律。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-video-storyboard",
|
|
3
3
|
"description": "Scene-aware storyboard tool for DeepSeek Harness: one addressable grid per video, with an index the model can cite.",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"entry": {
|
|
6
6
|
"name": "dsh-video-storyboard",
|
|
7
7
|
"inject": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-video-storyboard",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Scene-aware storyboard for DeepSeek Harness: one addressable grid per video (numbered cells, timestamps, transcript, audio envelope) so a text-only agent can look at the video itself instead of being told a summary.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|