dsh-model-groups 0.3.5 → 0.3.7
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 +48 -84
- package/docs/images/add-key-configuration.webp +0 -0
- package/docs/images/collapsed-key-configurations.webp +0 -0
- package/docs/images/key-configuration.webp +0 -0
- package/docs/images/multi-key-management.webp +0 -0
- package/docs/images/provider-multi-key-toggle.webp +0 -0
- package/docs/maintenance.md +47 -0
- package/lib/client.js +75 -27
- package/native/pi-ai.patch.json +507 -4
- package/native/settings-models.patch.json +226 -7
- package/package.json +5 -2
- package/scripts/build.mjs +2 -1
- package/scripts/doctor.mjs +22 -23
- package/scripts/native-patches.mjs +65 -5
- package/src/auto-patch.js +5 -3
- package/src/client.js +2 -2
- package/src/compatibility.js +22 -0
- package/src/index.js +2 -6
- package/src/maintenance-state.js +28 -13
- package/src/maintenance.js +35 -11
- package/src/settings-page.js +23 -12
package/src/settings-page.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { compatibilityGuidance } from './compatibility.js';
|
|
1
2
|
export function ModelGroupsSettingsPage() {
|
|
2
3
|
const h = react.createElement;
|
|
3
4
|
const controller = react.useMemo(() => createMaintenanceController(), []);
|
|
@@ -9,8 +10,11 @@ export function ModelGroupsSettingsPage() {
|
|
|
9
10
|
const snapshot = state.snapshot;
|
|
10
11
|
const phaseLabels = { idle: '检查完成,可选择操作', applied: '多密钥已应用(磁盘状态)', restored: '多密钥已关闭,插件仍保留(磁盘状态)', removing: '正在卸载,尚未确认完成', removed: '已确认关闭多密钥并卸载插件', failed: '维护失败,未确认完成' };
|
|
11
12
|
const updatesAvailable = snapshot?.patches.some(patch => patch.updateAvailable) ?? false;
|
|
12
|
-
const statusLabel = snapshot?.phase === 'idle'
|
|
13
|
-
? snapshot.patches.
|
|
13
|
+
const statusLabel = snapshot?.versionMismatch ? '网页与维护后端版本不一致,请先重启并刷新' : snapshot?.phase === 'idle'
|
|
14
|
+
? snapshot.patches.some(patch => patch.state === 'conflict') ? '磁盘文件校验冲突,已停止整批维护'
|
|
15
|
+
: snapshot.patches.some(patch => patch.applySupported === false) ? '旧补丁已识别,但此构建不支持新版协议补丁'
|
|
16
|
+
: updatesAvailable ? '旧多密钥补丁已应用,新版更新待确认'
|
|
17
|
+
: snapshot.patches.length && snapshot.patches.every(patch => patch.state === 'patched') ? '多密钥已启用(磁盘状态)'
|
|
14
18
|
: snapshot.patches.length && snapshot.patches.every(patch => patch.state === 'pristine') ? '多密钥已关闭(磁盘状态)' : '磁盘状态待处理,请查看操作限制'
|
|
15
19
|
: phaseLabels[snapshot?.phase];
|
|
16
20
|
const patchLabels = { patched: '已应用', pristine: '原版', conflict: '冲突(不会强制覆盖)' };
|
|
@@ -23,16 +27,18 @@ export function ModelGroupsSettingsPage() {
|
|
|
23
27
|
catch { setCopyStatus('无法复制,请检查浏览器剪贴板权限。'); }
|
|
24
28
|
};
|
|
25
29
|
return h('section', { className: 'mg-maintenance', 'aria-label': '模型分组设置', 'aria-busy': state.busy },
|
|
26
|
-
h('h2', null, '
|
|
27
|
-
h('p', null, '
|
|
30
|
+
h('h2', null, '多密钥管理'),
|
|
31
|
+
h('p', null, '在这里启用、更新或关闭多密钥。如果只想按供应商浏览模型,无需启用多密钥。'),
|
|
32
|
+
snapshot?.pluginVersion && h('p', { className: 'mg-maintenance-help' }, `插件 ${snapshot.pluginVersion} · DSH ${snapshot.compatibility?.hostVersion ?? '版本未确认'}`),
|
|
28
33
|
h('section', { className: 'mg-maintenance-card', 'aria-label': '当前状态' },
|
|
29
34
|
h('div', { className: 'mg-maintenance-row' }, h('h3', null, '当前状态'), h('button', { type: 'button', disabled: state.busy, onClick: refresh }, state.busy ? '处理中…' : '刷新检查')),
|
|
30
35
|
h('p', { role: 'status', 'aria-live': 'polite', className: 'mg-maintenance-help' }, state.busy ? '正在检查或执行维护,请勿关闭或重复操作。' : snapshot ? statusLabel : '尚无可验证状态,请刷新检查。'),
|
|
31
36
|
state.error && h('p', { role: 'alert', className: 'mg-maintenance-error' }, state.error),
|
|
32
|
-
state.patchedWarning && h('p', { role: 'alert', className: 'mg-maintenance-error' }, '
|
|
33
|
-
snapshot?.restartRequired && h('p', { role: 'status' }, '
|
|
37
|
+
state.patchedWarning && h('p', { role: 'alert', className: 'mg-maintenance-error' }, '从普通插件列表卸载只移除插件,不会还原 DSH 文件。需要卸载时,请使用此页的「关闭并卸载插件」。'),
|
|
38
|
+
snapshot?.restartRequired && h('p', { role: 'status' }, 'DSH 程序文件已更新,需要重启 DSH 引擎,再刷新网页。只刷新网页不会生效。'),
|
|
39
|
+
compatibilityGuidance(snapshot?.compatibility) && h('p', { role: 'status', className: 'mg-maintenance-help' }, compatibilityGuidance(snapshot.compatibility)),
|
|
34
40
|
updatesAvailable && h('p', { role: 'status' }, '多密钥补丁有更新可用;确认后将备份、校验并更新已识别的旧补丁。'),
|
|
35
|
-
snapshot?.phase === 'removed' && h('p', { role: 'status' }, '卸载已确认:仅清理本插件的两个浏览器显示偏好,密钥、历史和备份均保留。'),
|
|
41
|
+
snapshot?.phase === 'removed' && !snapshot.versionMismatch && h('p', { role: 'status' }, '卸载已确认:仅清理本插件的两个浏览器显示偏好,密钥、历史和备份均保留。'),
|
|
36
42
|
snapshot?.warnings.length > 0 && h('p', { className: 'mg-maintenance-warning', role: 'status' }, '部分使用情况未验证,关闭前请阅读提示;检查提醒不会额外禁用操作。'),
|
|
37
43
|
snapshot?.blockers.length > 0 && h('div', { role: 'alert' }, h('strong', null, '操作限制(各按钮以安全权限为准)'), h('ul', null, ...snapshot.blockers.map((blocker, index) => h('li', { key: index }, maintenanceBlockerText(blocker))))),
|
|
38
44
|
state.cleanupWarning && h('p', { role: 'status' }, '卸载已确认,但浏览器阻止清理本插件的显示偏好;其他数据未受影响。')),
|
|
@@ -42,15 +48,20 @@ export function ModelGroupsSettingsPage() {
|
|
|
42
48
|
!anyAllowed && h('p', null, '请刷新检查或处理上方操作限制。检查提醒本身不会禁用按钮。'),
|
|
43
49
|
pending && h('div', { role: 'dialog', 'aria-labelledby': confirmationId, 'aria-describedby': `${confirmationId}-help`, className: 'mg-maintenance-dialog' },
|
|
44
50
|
h('h3', { id: confirmationId }, `确认${actions.find(([action]) => action === pending)[1]}?`),
|
|
45
|
-
h('p', { id: `${confirmationId}-help` }, pending === 'apply'
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
h('p', { id: `${confirmationId}-help` }, pending === 'apply'
|
|
52
|
+
? `插件会检查并备份 DSH 程序文件,再${updatesAvailable ? '更新多密钥补丁' : '启用多密钥'}。不会自动切换模型。`
|
|
53
|
+
: '插件会还原 DSH 程序文件,保留密钥、配置和聊天记录。请先将仍使用多密钥的会话和默认模型改为普通模型;残留的多密钥配置可能影响 DSH 启动。'),
|
|
54
|
+
h('p', null, '请先保存草稿并停止所有任务。完成后按提示重启 DSH 引擎,再刷新网页。'),
|
|
55
|
+
snapshot?.warnings.length > 0 && h('p', null, '部分使用情况无法检查,请先阅读页面中的检查详情。'),
|
|
56
|
+
pending === 'restore-and-uninstall' && h('p', null, '还原成功后才会卸载插件。确认卸载后会清除本浏览器中的模型菜单显示偏好;连接中断不代表卸载成功。'),
|
|
48
57
|
h('div', { className: 'mg-maintenance-actions' }, h('button', { type: 'button', onClick: () => setPending(null) }, '取消'), h('button', { type: 'button', disabled: state.busy || !maintenanceCanAction(snapshot, pending), onClick: confirm }, '确认执行')))),
|
|
49
58
|
h('details', { className: 'mg-maintenance-card' },
|
|
50
59
|
h('summary', null, '检查详情与脱敏诊断'),
|
|
51
|
-
h('p', null, '
|
|
60
|
+
h('p', null, '这里能检查 DSH 文件,但无法确认正在运行的引擎是否已加载更新。确认操作后会再次检查;如果状态变化,需要重新确认。无法识别的文件不会被覆盖。'),
|
|
52
61
|
snapshot?.warnings.length > 0 && h('ul', null, ...snapshot.warnings.map((warning, index) => h('li', { key: index }, maintenanceWarningText(warning)))),
|
|
53
|
-
snapshot && h('ul', null, ...snapshot.patches.map((patch, index) => h('li', { key: index }, `宿主文件 ${index + 1}:${patchLabels[patch.state]}${patch.updateAvailable ? '(更新可用)' : ''}`))),
|
|
62
|
+
snapshot && h('ul', null, ...snapshot.patches.map((patch, index) => h('li', { key: index }, `宿主文件 ${index + 1}:${patchLabels[patch.state]}${patch.applySupported === false ? '(此构建不支持新版补丁)' : patch.updateAvailable ? '(更新可用)' : ''}`))),
|
|
63
|
+
snapshot?.compatibility && h('ul', null, ...snapshot.compatibility.files.map(item => h('li', { key: item.id }, `${item.id} · ${item.installedVersion ?? '版本未知'} · ${item.code} · SHA-256 ${item.observedSha256 ?? '不可读取'}`))),
|
|
64
|
+
h('p', null, '诊断仅含程序版本、固定文件标识与程序 SHA-256,不含文件路径、配置正文、密钥或聊天。升级失败请先保留现场,不要用另一构建的文件覆盖。'),
|
|
54
65
|
h('button', { type: 'button', onClick: copy }, '复制脱敏诊断'),
|
|
55
66
|
h('p', { role: 'status' }, copyStatus)));
|
|
56
67
|
}
|