dsh-chat-embed 0.6.8 → 0.6.10
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 +2 -0
- package/client.js +241 -128
- package/docs/architecture.md +1 -1
- package/docs/publishing.md +48 -14
- package/index.js +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -330,6 +330,8 @@ node scripts/release.mjs 0.6.7 --summary "..." --dry-run # 只看计划
|
|
|
330
330
|
|
|
331
331
|
| 版本 | 变化 |
|
|
332
332
|
| --- | --- |
|
|
333
|
+
| `0.6.10` | 修好「重启保持登录」整条链路:开关不再因 ctx 作用域错误静默失败、变成可双向切换(开启/还原)、设置菜单两行合一、预填任务说明重写;Host 半补上 inject 依赖,探针路由与 agent 工具终于生效 |
|
|
334
|
+
| `0.6.9` | 设置菜单把「跨重启保持登录」与「检查补丁配置」合成一行(滑动开关 + 确认弹窗 + 新会话引导);发版改用 OIDC Trusted Publishing,不再保存 npm 令牌,并附带 provenance |
|
|
333
335
|
| `0.6.8` | 去掉单提交策略:发版改为普通提交 + 普通推送,不再 --orphan 重写、reflog expire、gc --prune 与强推;恢复 git log/diff/blame/bisect,发版失败可 reset 回退,并为 OIDC provenance 扫清障碍 |
|
|
334
336
|
| `0.6.7` | 发版脚本:一条命令完成 bump/gate/提交/推送/等 CI/发布/打 tag/建 release;新增 dependabot 自动维护固定 SHA 的 Action |
|
|
335
337
|
| `0.6.6` | 元数据同步版:把 `engines.node` 收紧到 `>=22.14.0`、门禁脚本从 `prepublishOnly` 换成 `prepack`(同时覆盖 `npm pack` 与 `npm publish`)落到 npm 上;新增 CI 工作流(Node 22/24 跑门禁,并校验 tag 与 `BUILD` 一致)。无功能变化 |
|
package/client.js
CHANGED
|
@@ -102,8 +102,20 @@ window.__ModuleLoader__.load({
|
|
|
102
102
|
let rightDisposers = []
|
|
103
103
|
let openRightTabImpl = () => {}
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* The context handed to apply().
|
|
107
|
+
*
|
|
108
|
+
* The components and helpers live at module scope, so they cannot close over
|
|
109
|
+
* apply's parameter. Everything that needs a service after apply has returned —
|
|
110
|
+
* the restart-login action, for one — reads it from here. A re-applied bundle
|
|
111
|
+
* overwrites it, which is what keeps a hot reload honest.
|
|
112
|
+
*
|
|
113
|
+
* @type {any}
|
|
114
|
+
*/
|
|
115
|
+
let activeCtx = undefined
|
|
116
|
+
|
|
105
117
|
/** Build identity, surfaced in the panel so a packaged app can be diagnosed. */
|
|
106
|
-
const BUILD = '0.6.
|
|
118
|
+
const BUILD = '0.6.10'
|
|
107
119
|
|
|
108
120
|
/** Where a re-applied instance finds the one it must take over from. */
|
|
109
121
|
const INSTANCE_KEY = '__DSH_CHAT_EMBED_INSTANCE__'
|
|
@@ -262,22 +274,24 @@ window.__ModuleLoader__.load({
|
|
|
262
274
|
persistHint: 'Needs the shell patch; a plugin cannot change how the shell names partitions.',
|
|
263
275
|
persistRisk:
|
|
264
276
|
'Experimental: the patch rewrites the app.asar of the desktop shell and needs write access to its install folder. A shell update replaces it, so the patch has to be applied again.',
|
|
265
|
-
persistCopy: 'Copy the patch instructions',
|
|
266
|
-
persistCheck: 'Check the patch setup',
|
|
267
277
|
persistCheckHint: 'Opens a new session and drafts the check for you',
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
persistConfirmTitle: 'Turn on “login across restarts”?',
|
|
279
|
+
persistConfirmNote: 'Continuing opens a new session containing the task and the known facts; sending it lets the agent apply the patch and hand you the elevated command if permissions block it.',
|
|
280
|
+
persistConfirmGo: 'Continue',
|
|
281
|
+
persistConfirmCancel: 'Cancel',
|
|
282
|
+
persistOffTitle: 'Turn off "logins survive restarts"?',
|
|
283
|
+
persistOffBody: 'This removes the patch and puts the original app.asar back. Every restart will ask you to sign in again; flip the switch to undo.',
|
|
284
|
+
restoreTask: 'Remove the DSH desktop shell patch that keeps embedded chat logins across restarts, restoring the original app.asar.',
|
|
285
|
+
restoreStepsTitle: 'Restore steps (DSH must be fully quit first)',
|
|
286
|
+
restoreWarning: 'After this, logins no longer survive a restart.',
|
|
287
|
+
|
|
288
|
+
patchNoWorkspace: 'This composition has no Session service; the patch instructions were copied to the clipboard.',
|
|
289
|
+
patchTask: 'Apply the DSH desktop shell patch that keeps embedded chat logins across restarts.',
|
|
290
|
+
patchTaskDir: 'Install directory',
|
|
291
|
+
patchTaskCommand: 'Command',
|
|
292
|
+
patchTaskReadonly: 'The install directory is not writable: do not attempt the write, just give me the command to run with administrator rights.',
|
|
293
|
+
patchTaskNoSite: 'This shell version has no patch site, so the patch does not apply — explain why and change nothing else.',
|
|
294
|
+
patchTaskVerify: 'When it is done, tell me how to verify (restart DSH, reopen the settings menu).',
|
|
281
295
|
copyDiag: 'Copy diagnostics',
|
|
282
296
|
copied: 'Copied',
|
|
283
297
|
copyFailed: 'Copy failed',
|
|
@@ -347,29 +361,30 @@ window.__ModuleLoader__.load({
|
|
|
347
361
|
loggingOn: '开',
|
|
348
362
|
loggingOff: '关',
|
|
349
363
|
loggingCopy: '复制日志',
|
|
350
|
-
persistLabel: '
|
|
364
|
+
persistLabel: '重启保持登录',
|
|
351
365
|
persistOn: '已开启(persist: 分区)',
|
|
352
366
|
persistOff: '未开启(内存分区)',
|
|
353
367
|
persistLost: '已失效(桌面壳升级覆盖了补丁)',
|
|
354
368
|
persistUnknown: '尚未检测',
|
|
355
369
|
persistHint: '需要桌面壳补丁;插件无法改变壳的分区命名。',
|
|
356
370
|
persistRisk: '实验性功能:补丁会改写桌面壳的 app.asar,需要安装目录的写权限;桌面壳升级会覆盖补丁,需要重新打一次。',
|
|
357
|
-
persistCopy: '复制补丁说明',
|
|
358
|
-
persistCheck: '检查补丁配置',
|
|
359
371
|
persistCheckHint: '打开新会话,把检查内容写好,点发送即可',
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
372
|
+
persistConfirmTitle: '开启「重启保持登录」?',
|
|
373
|
+
persistConfirmNote: '点击「继续」会打开一个新会话,里面是给它的任务说明和已知事实;发送后由它完成补丁操作,遇到权限问题会给出需要提权的命令。',
|
|
374
|
+
persistConfirmGo: '继续',
|
|
375
|
+
persistConfirmCancel: '取消',
|
|
376
|
+
persistOffTitle: '关闭「重启保持登录」?',
|
|
377
|
+
persistOffBody: '会撤掉补丁、恢复原版 app.asar。之后每次重启都要重新登录;想再开启,再点一次这个开关即可。',
|
|
378
|
+
restoreTask: '把 DSH 桌面版的「重启保持登录」补丁撤掉,恢复原版 app.asar。',
|
|
379
|
+
restoreStepsTitle: '还原步骤(必须在 DSH 完全退出后)',
|
|
380
|
+
restoreWarning: '撤掉后登录态不再跨重启保留,每次重启都要重新登录。',
|
|
381
|
+
patchNoWorkspace: '当前拼装没有会话服务,补丁说明已复制到剪贴板。',
|
|
382
|
+
patchTask: '给 DSH 桌面版打上「跨重启保持登录」补丁。',
|
|
383
|
+
patchTaskDir: '安装目录',
|
|
384
|
+
patchTaskCommand: '命令',
|
|
385
|
+
patchTaskReadonly: '安装目录不可写:不要尝试写入,把需要管理员权限执行的命令给我。',
|
|
386
|
+
patchTaskNoSite: '当前桌面壳版本找不到补丁点,补丁不适用——说明原因即可,不要改别的。',
|
|
387
|
+
patchTaskVerify: '打好后告诉我怎么验证(重启 DSH,回设置菜单看状态)。',
|
|
373
388
|
copyDiag: '复制诊断信息',
|
|
374
389
|
copied: '已复制',
|
|
375
390
|
copyFailed: '复制失败',
|
|
@@ -2109,6 +2124,14 @@ window.__ModuleLoader__.load({
|
|
|
2109
2124
|
if (method === 'layout') {
|
|
2110
2125
|
const layout = typeof ctx.get === 'function' ? ctx.get('layout') : undefined
|
|
2111
2126
|
const out = { service: layout !== undefined && layout !== null, keys: [], hasMain: undefined, activePanelId: undefined, nav: [] }
|
|
2127
|
+
// The patch helper needs this service; report it here so a broken
|
|
2128
|
+
// composition is visible without clicking through the dialog.
|
|
2129
|
+
const workspace = typeof ctx.get === 'function' ? ctx.get('uiWorkspace') : undefined
|
|
2130
|
+
out.uiWorkspace = workspace !== undefined && workspace !== null
|
|
2131
|
+
out.uiWorkspaceStartSession = out.uiWorkspace && typeof workspace.startSession === 'function'
|
|
2132
|
+
out.patchCheckRunning = patchCheck.running
|
|
2133
|
+
out.activeCtx = activeCtx !== undefined && activeCtx !== null
|
|
2134
|
+
out.probeLoaded = patchProbe.loaded
|
|
2112
2135
|
if (out.service) {
|
|
2113
2136
|
out.keys = Object.keys(layout)
|
|
2114
2137
|
if (typeof layout.hasMainPanel === 'function') {
|
|
@@ -2518,15 +2541,25 @@ window.__ModuleLoader__.load({
|
|
|
2518
2541
|
try {
|
|
2519
2542
|
// The Host half serves this route; a relative fetch therefore works in
|
|
2520
2543
|
// both the desktop app and the Web GUI, under any deployment prefix.
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2544
|
+
// Never let a stuck request hold the click hostage: without a timeout the
|
|
2545
|
+
// whole action waits on a route that may not even exist.
|
|
2546
|
+
const controller = new AbortController()
|
|
2547
|
+
const timer = setTimeout(() => controller.abort(), 4000)
|
|
2548
|
+
let response
|
|
2549
|
+
try {
|
|
2550
|
+
response = await fetch('./dsh-chat-embed/patch-check', {
|
|
2551
|
+
method: 'GET',
|
|
2552
|
+
headers: { accept: 'application/json' },
|
|
2553
|
+
cache: 'no-store',
|
|
2554
|
+
signal: controller.signal,
|
|
2555
|
+
})
|
|
2556
|
+
} finally {
|
|
2557
|
+
clearTimeout(timer)
|
|
2558
|
+
}
|
|
2526
2559
|
patchProbe.value = response.ok ? await response.json() : undefined
|
|
2527
2560
|
} catch (error) {
|
|
2528
2561
|
patchProbe.value = undefined
|
|
2529
|
-
|
|
2562
|
+
log('warn', 'probe: the Host route did not answer: ' + messageOf(error))
|
|
2530
2563
|
}
|
|
2531
2564
|
patchProbe.loaded = true
|
|
2532
2565
|
return patchProbe.value
|
|
@@ -2544,26 +2577,81 @@ window.__ModuleLoader__.load({
|
|
|
2544
2577
|
* @param {(key: string) => string} t
|
|
2545
2578
|
* @returns {Promise<void>}
|
|
2546
2579
|
*/
|
|
2547
|
-
async function openPatchCheckSession(t) {
|
|
2548
|
-
const
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
return
|
|
2554
|
-
}
|
|
2555
|
-
patchCheck.running = true
|
|
2556
|
-
notify()
|
|
2580
|
+
async function openPatchCheckSession(t, mode) {
|
|
2581
|
+
const host = activeCtx
|
|
2582
|
+
// Nothing in here may fail silently: a click that does nothing is
|
|
2583
|
+
// indistinguishable from a broken build, so every step is logged and the
|
|
2584
|
+
// reason comes back to the dialog.
|
|
2585
|
+
let failure = ''
|
|
2557
2586
|
try {
|
|
2587
|
+
log('info', 'patch-check: entered')
|
|
2588
|
+
const workspace = host !== undefined && typeof host.get === 'function' ? host.get('uiWorkspace') : undefined
|
|
2589
|
+
log(
|
|
2590
|
+
'info',
|
|
2591
|
+
'patch-check: uiWorkspace ' +
|
|
2592
|
+
(workspace === undefined || workspace === null ? 'missing' : 'startSession=' + typeof workspace.startSession),
|
|
2593
|
+
)
|
|
2594
|
+
if (workspace === undefined || workspace === null || typeof workspace.startSession !== 'function') {
|
|
2595
|
+
void copyText(patchInstructions(t, patchProbe.value))
|
|
2596
|
+
failure = t('patchNoWorkspace')
|
|
2597
|
+
return failure
|
|
2598
|
+
}
|
|
2599
|
+
patchCheck.running = true
|
|
2600
|
+
notify()
|
|
2558
2601
|
const probe = await fetchProbe()
|
|
2559
|
-
|
|
2602
|
+
log('info', 'patch-check: probe ' + (probe === undefined || probe === null ? 'absent' : 'ok'))
|
|
2603
|
+
const prompt = mode === 'off' ? buildRestorePrompt(t, probe) : buildPatchPrompt(t, probe)
|
|
2560
2604
|
patchProbe.loaded = false
|
|
2561
|
-
|
|
2605
|
+
// A custom main panel stays selected when a Session opens, so the new
|
|
2606
|
+
// Session lands behind this panel and the click looks like a no-op.
|
|
2607
|
+
// Hand the main area back to the conversation first.
|
|
2608
|
+
const layout = host !== undefined && typeof host.get === 'function' ? host.get('layout') : undefined
|
|
2609
|
+
if (layout !== undefined && layout !== null && typeof layout.selectPanel === 'function') {
|
|
2610
|
+
log('info', 'patch-check: releasing the main panel before opening the Session')
|
|
2611
|
+
layout.selectPanel(null)
|
|
2612
|
+
}
|
|
2613
|
+
log('info', 'patch-check: opening a Session with a ' + prompt.length + '-char draft')
|
|
2614
|
+
// 'replace', not 'append': the Workspace blank can already hold a draft
|
|
2615
|
+
// from another flow (the plugin-creation template, for one), and appending
|
|
2616
|
+
// would hand the agent two unrelated instructions at once.
|
|
2617
|
+
workspace.startSession(undefined, { prompt, whenDraftExists: 'replace' })
|
|
2618
|
+
log('info', 'patch-check: startSession returned')
|
|
2562
2619
|
} catch (error) {
|
|
2563
|
-
|
|
2620
|
+
failure = messageOf(error)
|
|
2621
|
+
log('error', 'patch-check: failed', failure)
|
|
2622
|
+
void copyText(patchInstructions(t, patchProbe.value) + '\n' + t('copyFailed') + ': ' + failure)
|
|
2623
|
+
} finally {
|
|
2624
|
+
patchCheck.running = false
|
|
2625
|
+
notify()
|
|
2564
2626
|
}
|
|
2565
|
-
|
|
2566
|
-
|
|
2627
|
+
return failure
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
/**
|
|
2631
|
+
* The draft for the other direction: put the original app.asar back.
|
|
2632
|
+
*
|
|
2633
|
+
* Turning the switch off is a real operation, not a dead end — the patch
|
|
2634
|
+
* kept a copy, so undoing it is a rename away.
|
|
2635
|
+
*
|
|
2636
|
+
* @param {(key: string) => string} t
|
|
2637
|
+
* @param {any} [probe]
|
|
2638
|
+
* @returns {string}
|
|
2639
|
+
*/
|
|
2640
|
+
function buildRestorePrompt(t, probe) {
|
|
2641
|
+
const info = probe !== undefined && probe !== null ? probe : {}
|
|
2642
|
+
const lines = [t('restoreTask')]
|
|
2643
|
+
if (typeof info.resources === 'string' && info.resources !== '') {
|
|
2644
|
+
lines.push('', t('patchTaskDir') + ': ' + info.resources)
|
|
2645
|
+
}
|
|
2646
|
+
if (typeof info.asar === 'string' && info.asar !== '') {
|
|
2647
|
+
lines.push('', t('restoreStepsTitle') + ':')
|
|
2648
|
+
lines.push(' 1. ' + info.asar + ' -> ' + info.asar + '.patched.bak')
|
|
2649
|
+
lines.push(' 2. ' + info.asar + '.orig -> ' + info.asar)
|
|
2650
|
+
}
|
|
2651
|
+
if (info.writable === false) lines.push('', t('patchTaskReadonly'))
|
|
2652
|
+
lines.push('', t('restoreWarning'))
|
|
2653
|
+
lines.push('', t('patchTaskVerify'))
|
|
2654
|
+
return lines.join('\n')
|
|
2567
2655
|
}
|
|
2568
2656
|
|
|
2569
2657
|
/**
|
|
@@ -2575,34 +2663,20 @@ window.__ModuleLoader__.load({
|
|
|
2575
2663
|
* @returns {string}
|
|
2576
2664
|
*/
|
|
2577
2665
|
function buildPatchPrompt(t, probe) {
|
|
2578
|
-
const
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
row('resources', probe.resources)
|
|
2587
|
-
row('app.asar', probe.asar)
|
|
2588
|
-
row('app.asar.orig', probe.backup === true ? t('patchYes') : t('patchNo'))
|
|
2589
|
-
row(t('patchWritable'), probe.writable === true ? t('patchYes') : t('patchNo'))
|
|
2590
|
-
row(
|
|
2591
|
-
t('patchSiteLabel'),
|
|
2592
|
-
probe.patchSite === true ? t('patchPresent') : probe.patchSite === false ? t('patchMissing') : t('patchUnknown'),
|
|
2593
|
-
)
|
|
2594
|
-
row(
|
|
2595
|
-
t('patchApplied'),
|
|
2596
|
-
probe.patched === true ? t('patchYes') : probe.patched === false ? t('patchNo') : t('patchUnknown'),
|
|
2597
|
-
)
|
|
2598
|
-
if (typeof probe.patchCommand === 'string' && probe.patchCommand !== '') {
|
|
2599
|
-
facts.push('')
|
|
2600
|
-
facts.push(t('patchCommandLabel'))
|
|
2601
|
-
facts.push(probe.patchCommand)
|
|
2602
|
-
}
|
|
2603
|
-
if (typeof probe.detail === 'string' && probe.detail !== '') facts.push(t('patchDetail') + ': ' + probe.detail)
|
|
2666
|
+
const info = probe !== undefined && probe !== null ? probe : {}
|
|
2667
|
+
// The plugin already knows the state; the draft only says what to do about
|
|
2668
|
+
// it. Anything the patch script enforces itself (byte checks, quitting
|
|
2669
|
+
// first) does not belong here — that is a manual, not an instruction.
|
|
2670
|
+
const lines = [t('patchTask')]
|
|
2671
|
+
const command = typeof info.patchCommand === 'string' && info.patchCommand !== '' ? info.patchCommand : ''
|
|
2672
|
+
if (typeof info.resources === 'string' && info.resources !== '') {
|
|
2673
|
+
lines.push('', t('patchTaskDir') + ': ' + info.resources)
|
|
2604
2674
|
}
|
|
2605
|
-
|
|
2675
|
+
if (command !== '') lines.push('', t('patchTaskCommand') + ':', ' ' + command)
|
|
2676
|
+
if (info.writable === false) lines.push('', t('patchTaskReadonly'))
|
|
2677
|
+
if (info.patchSite === false) lines.push('', t('patchTaskNoSite'))
|
|
2678
|
+
lines.push('', t('patchTaskVerify'))
|
|
2679
|
+
return lines.join('\n')
|
|
2606
2680
|
}
|
|
2607
2681
|
|
|
2608
2682
|
/** @returns {{ state: string, detail: string, seats: any[] }} */
|
|
@@ -2827,10 +2901,9 @@ window.__ModuleLoader__.load({
|
|
|
2827
2901
|
'.dce-menu-row{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:5px 8px;border-radius:6px;font-size:13px;color:var(--dsw-alias-label-primary,#1f2329)}',
|
|
2828
2902
|
'.dce-menu-row:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
2829
2903
|
'.dce-menu-label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
2830
|
-
'.dce-menu-value{flex:0 0 auto;font-size:12px;color:var(--dsw-alias-label-tertiary,#9aa0a6)}',
|
|
2831
2904
|
'.dce-menu-sep{margin:5px 0 3px;border-top:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.24))}',
|
|
2832
|
-
'.dce-
|
|
2833
|
-
'.dce-
|
|
2905
|
+
'.dce-confirm-scrim{position:absolute;inset:0;z-index:7;background:rgba(0,0,0,.28)}',
|
|
2906
|
+
'.dce-card[data-modal="true"]{z-index:8}',
|
|
2834
2907
|
'.dce-menu-item{display:flex;align-items:center;justify-content:flex-start;gap:8px;width:100%;box-sizing:border-box;padding:6px 8px;border:0;border-radius:6px;background:transparent;color:inherit;font-size:13px;text-align:left;cursor:pointer}',
|
|
2835
2908
|
'.dce-menu-item:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
2836
2909
|
'.dce-right-title{display:inline-flex;align-items:center;gap:6px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
@@ -3251,6 +3324,9 @@ window.__ModuleLoader__.load({
|
|
|
3251
3324
|
// Auto-hiding tab bar: hidden until the pointer reaches the top hot zone.
|
|
3252
3325
|
const [barOpen, setBarOpen] = React.useState(false)
|
|
3253
3326
|
const [menuOpen, setMenuOpen] = React.useState(false)
|
|
3327
|
+
const [confirmOpen, setConfirmOpen] = React.useState(false)
|
|
3328
|
+
const [confirmError, setConfirmError] = React.useState('')
|
|
3329
|
+
const [confirmMode, setConfirmMode] = React.useState('on')
|
|
3254
3330
|
|
|
3255
3331
|
/**
|
|
3256
3332
|
* Close the settings menu.
|
|
@@ -3498,52 +3574,25 @@ window.__ModuleLoader__.load({
|
|
|
3498
3574
|
h(
|
|
3499
3575
|
'div',
|
|
3500
3576
|
{ className: 'dce-menu-row' },
|
|
3501
|
-
h('span', { className: 'dce-menu-label' }, t('persistLabel')),
|
|
3502
|
-
h(
|
|
3503
|
-
'
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
'data-patch-help': 'true',
|
|
3519
|
-
onClick: () => {
|
|
3520
|
-
void fetchProbe().then((probe) => copyText(patchInstructions(t, probe)))
|
|
3521
|
-
},
|
|
3522
|
-
},
|
|
3523
|
-
h('span', { className: 'dce-menu-label' }, t('persistCopy')),
|
|
3524
|
-
),
|
|
3525
|
-
h(
|
|
3526
|
-
'div',
|
|
3527
|
-
{ className: 'dce-menu-row' },
|
|
3528
|
-
h('span', { className: 'dce-menu-label', title: t('persistCheckHint') }, t('persistCheck')),
|
|
3529
|
-
h(
|
|
3530
|
-
'button',
|
|
3531
|
-
{
|
|
3532
|
-
type: 'button',
|
|
3533
|
-
role: 'switch',
|
|
3534
|
-
className: 'dce-switch',
|
|
3535
|
-
'data-on': patchCheck.running ? 'true' : 'false',
|
|
3536
|
-
'aria-checked': patchCheck.running ? 'true' : 'false',
|
|
3537
|
-
'data-patch-check': 'true',
|
|
3538
|
-
'aria-label': t('persistCheck'),
|
|
3539
|
-
title: t('persistCheckHint'),
|
|
3540
|
-
disabled: patchCheck.running,
|
|
3541
|
-
onClick: () => {
|
|
3542
|
-
closeMenu()
|
|
3543
|
-
void openPatchCheckSession(t)
|
|
3544
|
-
},
|
|
3577
|
+
h('span', { className: 'dce-menu-label', title: t('persistHint') }, t('persistLabel')),
|
|
3578
|
+
h('button', {
|
|
3579
|
+
type: 'button',
|
|
3580
|
+
role: 'switch',
|
|
3581
|
+
className: 'dce-switch',
|
|
3582
|
+
'data-on': persistenceState() === 'on' ? 'true' : 'false',
|
|
3583
|
+
'aria-checked': persistenceState() === 'on' ? 'true' : 'false',
|
|
3584
|
+
'data-persist-open': 'true',
|
|
3585
|
+
'aria-label': t('persistLabel'),
|
|
3586
|
+
title: t('persistCheckHint'),
|
|
3587
|
+
disabled: patchCheck.running,
|
|
3588
|
+
onClick: () => {
|
|
3589
|
+
log('info', 'dialog: opened by the restart-login switch')
|
|
3590
|
+
closeMenu()
|
|
3591
|
+
// The switch is a switch: on means the next click offers to undo it.
|
|
3592
|
+
setConfirmMode(persistenceState() === 'on' ? 'off' : 'on')
|
|
3593
|
+
setConfirmOpen(true)
|
|
3545
3594
|
},
|
|
3546
|
-
),
|
|
3595
|
+
}),
|
|
3547
3596
|
),
|
|
3548
3597
|
h(
|
|
3549
3598
|
'button',
|
|
@@ -3583,6 +3632,68 @@ window.__ModuleLoader__.load({
|
|
|
3583
3632
|
),
|
|
3584
3633
|
)
|
|
3585
3634
|
: null,
|
|
3635
|
+
confirmOpen
|
|
3636
|
+
? h('div', {
|
|
3637
|
+
className: 'dce-confirm-scrim',
|
|
3638
|
+
onPointerDown: () => setConfirmOpen(false),
|
|
3639
|
+
})
|
|
3640
|
+
: null,
|
|
3641
|
+
confirmOpen
|
|
3642
|
+
? h(
|
|
3643
|
+
'div',
|
|
3644
|
+
{
|
|
3645
|
+
className: 'dce-card',
|
|
3646
|
+
role: 'dialog',
|
|
3647
|
+
'aria-modal': 'true',
|
|
3648
|
+
'data-modal': 'true',
|
|
3649
|
+
'aria-label': t('persistConfirmTitle'),
|
|
3650
|
+
},
|
|
3651
|
+
h(
|
|
3652
|
+
'div',
|
|
3653
|
+
{ className: 'dce-card-title' },
|
|
3654
|
+
t(confirmMode === 'off' ? 'persistOffTitle' : 'persistConfirmTitle'),
|
|
3655
|
+
),
|
|
3656
|
+
h('div', { className: 'dce-card-body' }, t(confirmMode === 'off' ? 'persistOffBody' : 'persistRisk')),
|
|
3657
|
+
confirmMode === 'off'
|
|
3658
|
+
? null
|
|
3659
|
+
: h('div', { className: 'dce-card-body' }, t('persistConfirmNote')),
|
|
3660
|
+
confirmError === '' ? null : h('div', { className: 'dce-card-detail' }, confirmError),
|
|
3661
|
+
h(
|
|
3662
|
+
'div',
|
|
3663
|
+
{ className: 'dce-card-actions' },
|
|
3664
|
+
h(
|
|
3665
|
+
'button',
|
|
3666
|
+
{ type: 'button', className: 'dce-button', 'data-persist-cancel': 'true', onClick: () => setConfirmOpen(false) },
|
|
3667
|
+
t('persistConfirmCancel'),
|
|
3668
|
+
),
|
|
3669
|
+
h(
|
|
3670
|
+
'button',
|
|
3671
|
+
{
|
|
3672
|
+
type: 'button',
|
|
3673
|
+
className: 'dce-button dce-button-primary',
|
|
3674
|
+
'data-persist-confirm': 'true',
|
|
3675
|
+
disabled: patchCheck.running,
|
|
3676
|
+
onClick: () => {
|
|
3677
|
+
log('info', 'dialog: the confirm button was clicked')
|
|
3678
|
+
setConfirmError('')
|
|
3679
|
+
void openPatchCheckSession(t, confirmMode).then(
|
|
3680
|
+
(failure) => {
|
|
3681
|
+
if (typeof failure === 'string' && failure !== '') setConfirmError(failure)
|
|
3682
|
+
else setConfirmOpen(false)
|
|
3683
|
+
},
|
|
3684
|
+
(error) => {
|
|
3685
|
+
const reason = messageOf(error)
|
|
3686
|
+
log('error', 'dialog: openPatchCheckSession rejected', reason)
|
|
3687
|
+
setConfirmError(reason)
|
|
3688
|
+
},
|
|
3689
|
+
)
|
|
3690
|
+
},
|
|
3691
|
+
},
|
|
3692
|
+
t('persistConfirmGo'),
|
|
3693
|
+
),
|
|
3694
|
+
),
|
|
3695
|
+
)
|
|
3696
|
+
: null,
|
|
3586
3697
|
showStatus
|
|
3587
3698
|
? h(
|
|
3588
3699
|
'div',
|
|
@@ -3829,6 +3940,7 @@ window.__ModuleLoader__.load({
|
|
|
3829
3940
|
patchCheck,
|
|
3830
3941
|
openPatchCheckSession,
|
|
3831
3942
|
buildPatchPrompt,
|
|
3943
|
+
buildRestorePrompt,
|
|
3832
3944
|
setLogging,
|
|
3833
3945
|
clearLog,
|
|
3834
3946
|
readLogEntries,
|
|
@@ -3906,6 +4018,7 @@ window.__ModuleLoader__.load({
|
|
|
3906
4018
|
}
|
|
3907
4019
|
}
|
|
3908
4020
|
if (carrier !== undefined) carrier[INSTANCE_KEY] = { version: BUILD, dispose: disposeAll }
|
|
4021
|
+
activeCtx = ctx
|
|
3909
4022
|
|
|
3910
4023
|
// Locale dictionaries first: the entry label reads them.
|
|
3911
4024
|
disposers.push(ctx.effect(() => ctx.locale.register(NS, DICTS), 'dsh-chat-embed: dictionaries'))
|
package/docs/architecture.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
本文记录 `client.js` 里每一条**反直觉**的实现决策、支撑它的证据,以及升级桌面壳时必须重新验证的清单。
|
|
4
4
|
|
|
5
5
|
目标运行环境:**`@deepseek-ai/dsh-desktop 0.2.2-rc.1`(Electron / Chromium)**。
|
|
6
|
-
当前实现:**v0.6.
|
|
6
|
+
当前实现:**v0.6.10**(`client.js` 约 3985 行,85 项契约测试)。
|
|
7
7
|
|
|
8
8
|
> **架构一句话**:聊天页直接渲染在**席位的布局盒**里(`.dce-panel.dce-inline`,`width/height:100%`),几何完全交给 CSS;席位只有两个 —— 中央主面板(`main`)和右栏聊天 tab —— 二者互斥,**哪边点哪边接管**,切换时 guest 重建一次并回到上次会话。
|
|
9
9
|
|
package/docs/publishing.md
CHANGED
|
@@ -22,6 +22,13 @@
|
|
|
22
22
|
|
|
23
23
|
仓库没有运行时依赖,也没有 lock 文件,所以正常情况下 `npm ci` 会跳过;一旦加了依赖,锁文件出现后自动生效。
|
|
24
24
|
|
|
25
|
+
`.github/workflows/publish.yml`:发布专用,**只有手动触发**(`workflow_dispatch`)。它跑门禁、校验版本一致性,然后用 **OIDC Trusted Publishing** 发布,仓库和本机都不保存任何 npm 令牌。由 `scripts/release.mjs` 触发,也可以手动:
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
gh workflow run publish.yml -f version=0.6.9
|
|
29
|
+
gh run watch
|
|
30
|
+
```
|
|
31
|
+
|
|
25
32
|
`.github/dependabot.yml`:每周一维护 `ci.yml` 里固定成 commit SHA 的 action。我们钉的是 `uses: owner/action@<40 位 SHA> # vX.Y.Z` 这种形式,Dependabot 认得行尾的版本注释,会把 SHA 换成新版本的完整 SHA 并同步更新注释。同周的 action 升级合成一个 PR。包本身没有依赖,所以没有声明 npm 生态。
|
|
26
33
|
|
|
27
34
|
## 发版步骤
|
|
@@ -32,7 +39,7 @@
|
|
|
32
39
|
node scripts/release.mjs 0.6.7 --summary "一句话说明这次改了什么"
|
|
33
40
|
```
|
|
34
41
|
|
|
35
|
-
它按顺序做六件事。**顺序的理由:先发布,后打 tag。**
|
|
42
|
+
它按顺序做六件事。**顺序的理由:先发布,后打 tag。** 发布到 npm 是唯一不可逆的一步(72 小时后只能 deprecate),tag 与 Release 随时可删可重做;先做不可逆的,失败就停,不会留下"GitHub 有 Release、npm 没有包"的幽灵版本。
|
|
36
43
|
|
|
37
44
|
| 阶段 | 做什么 | 已经做过时怎么判断 |
|
|
38
45
|
| --- | --- | --- |
|
|
@@ -41,7 +48,7 @@ node scripts/release.mjs 0.6.7 --summary "一句话说明这次改了什么"
|
|
|
41
48
|
| commit | `git add -A` + 普通提交 | 工作树干净则跳过 |
|
|
42
49
|
| push | 推送 master,触发 CI | — |
|
|
43
50
|
| ci | 等这次推送的 CI 跑完,红了就停 | — |
|
|
44
|
-
| publish | `
|
|
51
|
+
| publish | 触发 `publish.yml`,由 OIDC 在 CI 里发布 | registry 上已有该版本则跳过 |
|
|
45
52
|
| tag | 打 tag 并推送(CI 再校验一次) | tag 已存在则跳过 |
|
|
46
53
|
| release | `npm run pack:dist` + `gh release create` | Release 已存在则跳过 |
|
|
47
54
|
|
|
@@ -63,7 +70,7 @@ node scripts/release.mjs 0.6.7 --summary "..." --notes dist\notes.md # Release
|
|
|
63
70
|
npm run check # 1. 本地门禁
|
|
64
71
|
# 2. git add -A && git commit && git push
|
|
65
72
|
gh run list --repo poluce/dsh-chat-embed --limit 1 # 3. 等 CI 绿
|
|
66
|
-
|
|
73
|
+
gh workflow run publish.yml -f version=<版本> # 4. 发布(OIDC,在 CI 里跑)
|
|
67
74
|
git tag v<版本> # 5. 打 tag 并推送
|
|
68
75
|
git push origin refs/tags/v<版本>
|
|
69
76
|
npm run pack:dist # 6. 打包 + 建 Release
|
|
@@ -87,15 +94,42 @@ Get-FileHash $env:TEMP\check\dsh-chat-embed-<版本>.tgz -Algorithm SHA256
|
|
|
87
94
|
|
|
88
95
|
0.6.5 及之前的版本是「tag → Release → publish」,与上面的顺序相反。已发布的历史无法回溯修正,从下一个版本起按新顺序执行。
|
|
89
96
|
|
|
90
|
-
##
|
|
97
|
+
## 发布凭证:OIDC Trusted Publishing
|
|
98
|
+
|
|
99
|
+
发布走 `.github/workflows/publish.yml`,用 **OIDC** 换取一次性的短期凭证。**仓库里、本机上都没有 npm 令牌可偷。**
|
|
100
|
+
|
|
101
|
+
### 在 npm 侧登记(一次性,只有包所有者能做)
|
|
102
|
+
|
|
103
|
+
1. npm 包设置页 → **Trusted Publisher** → 选 **GitHub Actions**;
|
|
104
|
+
2. 填三个字段:
|
|
105
|
+
- Organization or user:`poluce`
|
|
106
|
+
- Repository:`dsh-chat-embed`
|
|
107
|
+
- Workflow filename:`publish.yml`(**只填文件名,含扩展名,且必须与仓库里的一致**)
|
|
108
|
+
3. Environment 留空(这个 workflow 没有用 GitHub Environment);
|
|
109
|
+
4. 保存后在 **2 天内完成首次成功发布**,否则这条配置过期作废。
|
|
110
|
+
|
|
111
|
+
### CI 侧的要求(已在 workflow 里落实)
|
|
112
|
+
|
|
113
|
+
- job 带 `id-token: write`;
|
|
114
|
+
- 运行器是 GitHub-hosted(自托管不支持 OIDC);
|
|
115
|
+
- npm ≥ 11.5.1(workflow 里固定装 `npm@11.15.0`);
|
|
116
|
+
- **不设置** `NODE_AUTH_TOKEN` / `NPM_TOKEN`,残留令牌会干扰认证;
|
|
117
|
+
- `actions/setup-node` 刻意不传 `registry-url`,否则它会在 `.npmrc` 里写一行空的 `_authToken`。
|
|
118
|
+
|
|
119
|
+
### 为什么比令牌强
|
|
120
|
+
|
|
121
|
+
| | Granular token(旧) | OIDC(现在) |
|
|
122
|
+
| --- | --- | --- |
|
|
123
|
+
| 存在形态 | 40 字符静态串,存在 `~/.npmrc` | 每次运行现签,几分钟后失效 |
|
|
124
|
+
| 泄露后果 | 任何拿到的人在任何机器上都能发包 | 离开那次运行即无效 |
|
|
125
|
+
| 绑定 | 无 | 仓库 + workflow 文件名 + 分支 |
|
|
126
|
+
| provenance | 无 | 自动附带,用户可 `npm audit signatures` 验证 |
|
|
91
127
|
|
|
92
|
-
|
|
128
|
+
### 迁移后可以做的收尾
|
|
93
129
|
|
|
94
|
-
|
|
95
|
-
2. 该配置**必须在 2 天内完成首次成功发布**,否则过期;
|
|
96
|
-
3. 需要 workflow 带 `id-token: write`、GitHub-hosted runner、npm CLI ≥ 11.5.1、Node ≥ 22.14.0(`engines` 已收紧)。
|
|
130
|
+
迁移验证通过后,去 npm 网页撤销那个 Bypass 2FA 的 Granular token,并把包设置收紧为"仅 Trusted Publishing"。这样即使旧 token 曾泄露也不再有价值。
|
|
97
131
|
|
|
98
|
-
提交历史正常累积之后,provenance 里的 commit SHA
|
|
132
|
+
提交历史正常累积之后,provenance 里的 commit SHA 长期可达,npm 页面上"source commit"链接不会失效。
|
|
99
133
|
|
|
100
134
|
## 当前发布物
|
|
101
135
|
|
|
@@ -103,8 +137,8 @@ Get-FileHash $env:TEMP\check\dsh-chat-embed-<版本>.tgz -Algorithm SHA256
|
|
|
103
137
|
| --- | --- |
|
|
104
138
|
| 仓库 | <https://github.com/poluce/dsh-chat-embed> |
|
|
105
139
|
| Release | <https://github.com/poluce/dsh-chat-embed/releases> |
|
|
106
|
-
| 分发包 | `dsh-chat-embed-0.6.
|
|
107
|
-
| npm | `dsh-chat-embed@0.6.
|
|
140
|
+
| 分发包 | `dsh-chat-embed-0.6.10.tgz`(16 个文件,约 70 kB) |
|
|
141
|
+
| npm | `dsh-chat-embed@0.6.10`(<https://www.npmjs.com/package/dsh-chat-embed>,维护者 `poluce_auto`) |
|
|
108
142
|
| 商店图标 | `assets/icon-180.png`(180×180 PNG) |
|
|
109
143
|
| 商店截图 | `assets/screenshots/` + 仓库根 `screenshots.json`(6 张) |
|
|
110
144
|
|
|
@@ -123,7 +157,7 @@ dsh plugin --profile desktop add git+https://github.com/poluce/dsh-chat-embed.gi
|
|
|
123
157
|
|
|
124
158
|
1. 注册账号并完成邮箱验证:<https://www.npmjs.com/signup>;
|
|
125
159
|
2. 本机登录:`npm login`(浏览器确认或一次性密码;开了 2FA 输入验证码);
|
|
126
|
-
3. 发布:`npm publish`(`prepack` 自动跑门禁;包名 `dsh-chat-embed` 已发布 `0.6.
|
|
160
|
+
3. 发布:`npm publish`(`prepack` 自动跑门禁;包名 `dsh-chat-embed` 已发布 `0.6.10`);
|
|
127
161
|
4. 使用者随后只需:`dsh plugin --profile desktop add dsh-chat-embed`。
|
|
128
162
|
|
|
129
163
|
## 发布前后检查项
|
|
@@ -134,8 +168,8 @@ dsh plugin --profile desktop add git+https://github.com/poluce/dsh-chat-embed.gi
|
|
|
134
168
|
- 发布后用一份干净 profile 验证:`dsh plugin --profile <新名字> add <包名>`,然后打开左栏入口;
|
|
135
169
|
- 可选壳补丁(跨重启免登录)不是安装必需项;不装补丁时功能完整,只是重启后要重新登录;
|
|
136
170
|
- npm 首次发布新包时会出现 `0.0.0-stage` 占位版本(staged publishing 机制),审核/发布完成后 `latest` 指向正式版本;占位版本可忽略;
|
|
137
|
-
-
|
|
138
|
-
-
|
|
171
|
+
- 发布凭证走 OIDC,本机不需要任何 npm 令牌(见上文「发布凭证」);本地 `npm publish` 已不再使用;
|
|
172
|
+
- 若临时需要兜底,只能在 npm 网页创建 Bypass 2FA 的 Granular token,用完立刻撤销——npm 计划 2027 年 1 月收紧该能力。
|
|
139
173
|
|
|
140
174
|
## 提交到插件列表(awesome-dsh-plugin)
|
|
141
175
|
|
package/index.js
CHANGED
|
@@ -26,6 +26,15 @@ import { fileURLToPath } from 'node:url'
|
|
|
26
26
|
|
|
27
27
|
export const name = 'dsh-chat-embed'
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Wait for the two Host services before apply runs.
|
|
31
|
+
*
|
|
32
|
+
* Without this the loader calls apply while the tree is still assembling, both
|
|
33
|
+
* looksups below read undefined, and the probe route and the agent tool are
|
|
34
|
+
* silently skipped — which is exactly what happened until 0.6.10.
|
|
35
|
+
*/
|
|
36
|
+
export const inject = ['webServer', 'tools']
|
|
37
|
+
|
|
29
38
|
/** Route the panel fetches for the read-only shell probe. */
|
|
30
39
|
const PROBE_PATH = '/dsh-chat-embed/patch-check'
|
|
31
40
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-chat-embed",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"author": "poluce <fishsummer@126.com>",
|
|
5
5
|
"description": "Multi-tab AI chat embed for the DeepSeek Harness desktop app: DeepSeek, 豆包, ChatGPT, MiniMax, Kimi, Gemini and Grok, each signed in separately.",
|
|
6
6
|
"type": "module",
|