dsh-progress-union 0.1.8 → 0.2.0
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/CHANGELOG.md +26 -0
- package/README.md +3 -3
- package/client.js +522 -0
- package/dsh.plugin.json +1 -1
- package/index.js +30 -1
- package/package.json +1 -1
- package/test/settings.test.mjs +76 -0
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,32 @@
|
|
|
11
11
|
- 回归测试:锁定 system 必须在 `options.system`、`messages` 不得出现 `role:system`、content 必须是块数组。
|
|
12
12
|
- 设置面:`Config.assistant` 改为**逐叶子 `.volatile()`**(整对象标 volatile 不会生成字段表单——这就是「设置 → 插件」里看不到辅助 LLM 配置的原因);侧边栏不再放编辑表单,只留只读状态并指向设置页;新增「live ref 逐字段重读」测试。
|
|
13
13
|
|
|
14
|
+
## 0.1.9 (2026-11-26)
|
|
15
|
+
|
|
16
|
+
**设置面真正落地:顶层 settings.section + configForms 三组卡片。**
|
|
17
|
+
|
|
18
|
+
- 上一版只标了 schema 的 volatile,仍无入口——宿主不会凭导出的 `Config` 自动生成表单,设置面必须由**客户端**注册到 `settings.section` 槽(与 dsh-browser-cdp / dsh-spirit 同式)。
|
|
19
|
+
- 新增独立分节「进度板」(id `dsh-progress-union`,order 215),卡内三组:
|
|
20
|
+
- 辅助 LLM:mode / provider / model / baseUrl / apiKey / authority / minIntervalMs / autoApply;
|
|
21
|
+
- 观察者:enabled / maxIdleSteps / maxIdleMs / autoSyncCurrent / autoSyncThrottleMs / maxItems;
|
|
22
|
+
- API(只读):`progressAnchor` service、`/progress-anchor`、`/snapshot`、`/dsh-progress/status` 三条 HTTP。
|
|
23
|
+
- 数据臂走宿主原生 `configForms.get(entryId)` 句柄(subscribe / getSnapshot / set,写值带 revision);宿主无该服务时卡内显示只读提示,不静默丢入口。
|
|
24
|
+
- `Config` 增 `protocolHint` 与 `observer.*` 叶子级 volatile;`apply` 对 `cfg.observer` / `cfg.protocolHint` 改用 getter 解包 live ref → 设置页改阈值立即生效。
|
|
25
|
+
- 侧边栏保持只读状态行(编辑统一留在设置页,避免两处写同一命名空间)。
|
|
26
|
+
- 测试:新增 3 条设置面契约守卫(逐叶子 volatile、外层不标、客户端注册 settings.section + configForms),共 51 用例全绿。
|
|
27
|
+
|
|
28
|
+
## 0.2.0 (2026-11-26)
|
|
29
|
+
|
|
30
|
+
**设置面双座位 + 卡片重做(向 browser-cdp / prime-memory 的密度看齐)。**
|
|
31
|
+
|
|
32
|
+
- 为什么 0.1.9 只"勉强看到":样式写在数据面板的 `<style>` 里,而设置页是另一个 React 根,样式到不了 → 卡片裸奔、标签与输入框挤成一行。现在改为把样式表注入 `document.head`(id `dsh-progress-union-settings-style`),全命名空间 `.dsu-*` 前缀。
|
|
33
|
+
- 双座位:顶层 `settings.section`(独立分节「进度板」)+ `plugins.bundle.config`(插件详情页卡片,keyed by **包名**)。bundle 页此前是空的,现在与分节共用同一张卡。
|
|
34
|
+
- `configForms` 句柄改为 deferred `ctx.inject(['configForms'])` 捕获:该服务可能晚于客户端 apply 就绪,旧写法在那种时序下会永远拿不到写面;现在句柄到位后两个座位自动刷新。
|
|
35
|
+
- 卡片结构:可折叠分组卡(标题 + 徽标 + 折叠箭头)/行式 label+control、开关为药丸开关、枚举为分段控件(模式:关闭·已注册·直连;权限:槽位+轮次·仅槽位·仅轮次)、数值带单位后缀(ms / 步 / 项)、底部动作条(保存 / 撤销 / 未保存提示 / 状态)。
|
|
36
|
+
- 写入策略:文本与数字走草稿,点「保存」按组一次落盘(避免逐字符写盘);开关与分段即时落盘(乐观刷新 + 状态回执)。
|
|
37
|
+
- 模式为「关闭」时只显示模式行,选中 registered 才出现 provider,选中 direct 才出现 baseUrl/apiKey——不再把互斥字段一起摊开。
|
|
38
|
+
- 测试:设置面守卫扩到 8 条断言(双座位、包名 key、configForms、样式注入),共 51 用例全绿。
|
|
39
|
+
|
|
14
40
|
> 说明:0.1.0 是真实构建产物;0.1.1–0.1.6 由 0.1.0 → 最终态的可核验 diff 按功能块「逻辑分化重建」,每一版都只包含该版本描述的能力,源码逐版可执行;0.1.7 是发布工程面。
|
|
15
41
|
|
|
16
42
|
## 0.1.7 (2026-11-26)
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npm i dsh-progress-union # 走 npm 版本号
|
|
|
14
14
|
# 或本地开发:pnpm --dir <profile> add file:<repo>/dsh-progress-union-<ver>.tgz
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
装好后在 profile 的 `dsh.profile.bundles` 里挂上 `dsh-progress-union
|
|
17
|
+
装好后在 profile 的 `dsh.profile.bundles` 里挂上 `dsh-progress-union`,重启宿主加载;**配置面有两个入口**:设置页左侧的独立分节「进度板」(与记忆 / 模型 / 插件并列),以及插件详情页(bundle 设置页)里的同名配置卡。两处是同一张卡,经宿主 `configForms` 句柄读写;文本/数字改完点「保存」,开关与分段即时落盘,均无需重启。也可在 profile 的 `cordis.patch.yml` 里写 `config:` 作部署面默认值。
|
|
18
18
|
|
|
19
19
|
## 它解决什么
|
|
20
20
|
|
|
@@ -120,7 +120,7 @@ observer:
|
|
|
120
120
|
|
|
121
121
|
观察者默认是**规则版(零 LLM 费用)**。可选的辅助模型会把"清单 + 最近输出 + 最近动作 + 最近改动"交给一个小模型做审查:
|
|
122
122
|
|
|
123
|
-
**配置位置:设置 →
|
|
123
|
+
**配置位置:设置 → 进度板**(或插件详情页的同名卡片)。卡内三组可折叠:辅助 LLM / 观察者 / 只读 API;观察者的滞后阈值也在这张卡里。
|
|
124
124
|
|
|
125
125
|
```yaml
|
|
126
126
|
assistant:
|
|
@@ -158,5 +158,5 @@ assistant:
|
|
|
158
158
|
## 开发与测试
|
|
159
159
|
|
|
160
160
|
```bash
|
|
161
|
-
npm test # node --test test/*.test.mjs(
|
|
161
|
+
npm test # node --test test/*.test.mjs(51 用例,纯 mock ctx,无需宿主进程)
|
|
162
162
|
```
|
package/client.js
CHANGED
|
@@ -215,6 +215,53 @@ window.__ModuleLoader__.load({
|
|
|
215
215
|
llmAuto: ',自动落地',
|
|
216
216
|
llmHint: '配置在「设置 → 插件 → dsh-progress-union」:mode 选 registered 复用 Settings→模型 里的 provider/model(走宿主,免密钥),或 direct 直连自建 OpenAI 兼容端点。仅滞后时触发,每回合至多一次。助手可增删改槽位并产出轮次草案(仅供参考),判断权归主模型。',
|
|
217
217
|
llmSettingsHint: '在设置页修改',
|
|
218
|
+
setTitle: '进度板',
|
|
219
|
+
setLlmGroup: '辅助 LLM(监控/审查)',
|
|
220
|
+
setLlmHint: '选「已注册」复用 Settings→模型 里的 provider/model(走宿主 llm.stream,免密钥);「直连」打自建 OpenAI 兼容端点。仅在进度板滞后时触发,每回合至多一次。',
|
|
221
|
+
setObserverGroup: '观察者(监控)',
|
|
222
|
+
setObserverHint: '板滞后到什么程度才催办/审查;关掉自动同步后只做提醒,不改 current。',
|
|
223
|
+
setApiGroup: 'API(只读)',
|
|
224
|
+
setApiHint: '同一 builder 双平面出口:进程内 service + HTTP,供压缩类插件只读消费。',
|
|
225
|
+
setMode: '模式',
|
|
226
|
+
setModeOff: '关闭',
|
|
227
|
+
setModeRegistered: '已注册 provider',
|
|
228
|
+
setModeDirect: '直连端点',
|
|
229
|
+
setProvider: '提供方',
|
|
230
|
+
setProviderHint: 'Settings→模型 里的 provider 名(registered 必填)',
|
|
231
|
+
setModel: '模型',
|
|
232
|
+
setBaseUrl: '端点地址',
|
|
233
|
+
setApiKey: 'API 密钥',
|
|
234
|
+
setApiKeyHint: '只写不回显;保存后快照只回布尔 hasApiKey',
|
|
235
|
+
setAuthority: '助手权限',
|
|
236
|
+
setAuthorityBoth: '槽位 + 轮次草案',
|
|
237
|
+
setAuthoritySlots: '只管理槽位',
|
|
238
|
+
setAuthorityRounds: '只产轮次草案',
|
|
239
|
+
setInterval: '最小间隔(毫秒)',
|
|
240
|
+
setIntervalHint: '两次审查之间的最小间隔,默认 90000',
|
|
241
|
+
setAutoApply: '自动落地槽位',
|
|
242
|
+
setObserverEnabled: '启用观察者',
|
|
243
|
+
setMaxIdleSteps: '滞后步数阈值',
|
|
244
|
+
setMaxIdleMs: '滞后时长阈值(毫秒)',
|
|
245
|
+
setAutoSyncCurrent: '自动同步 current',
|
|
246
|
+
setAutoSyncThrottleMs: '自动同步节流(毫秒)',
|
|
247
|
+
setMaxItems: '清单条目上限',
|
|
248
|
+
setSaved: '已保存',
|
|
249
|
+
setFailed: '保存失败',
|
|
250
|
+
setReadOnly: '当前 config 不可写',
|
|
251
|
+
setNoScope: '此宿主未提供设置写入面(configForms),只能从 profile 的 cordis.patch.yml 改配置。',
|
|
252
|
+
setLive: '运行时·可编辑',
|
|
253
|
+
setTopHint: '改完即时落盘,无需重启',
|
|
254
|
+
setLlmBadge: '监控审查',
|
|
255
|
+
setObserverBadge: '监控',
|
|
256
|
+
setApiBadge: '只读',
|
|
257
|
+
setSave: '保存',
|
|
258
|
+
setSaving: '保存中…',
|
|
259
|
+
setReset: '撤销',
|
|
260
|
+
setDirty: '有未保存的改动',
|
|
261
|
+
setApiService: 'service',
|
|
262
|
+
setApiAnchor: 'HTTP',
|
|
263
|
+
setApiSnapshot: '快照',
|
|
264
|
+
setApiStatus: '迷你条状态',
|
|
218
265
|
etaLeft: '预计剩',
|
|
219
266
|
etaOver: '已超预估',
|
|
220
267
|
staleTag: '中断',
|
|
@@ -326,6 +373,53 @@ window.__ModuleLoader__.load({
|
|
|
326
373
|
llmAuto: ', auto-applied',
|
|
327
374
|
llmHint: 'Configure in Settings → Plugins → dsh-progress-union: set mode=registered to reuse a provider/model from Settings → Models (via host, no API key), or mode=direct for a self-hosted OpenAI-compatible endpoint. Triggered only while overdue, at most once per turn. The assistant may add/edit/remove slots and emit round suggestions (advice only); the main model decides.',
|
|
328
375
|
llmSettingsHint: 'Change in Settings',
|
|
376
|
+
setTitle: 'Progress board',
|
|
377
|
+
setLlmGroup: 'Assistant LLM (monitor/audit)',
|
|
378
|
+
setLlmHint: 'Pick "Registered" to reuse a provider/model from Settings → Models (via host llm.stream, no API key), or "Direct" for a self-hosted OpenAI-compatible endpoint. Runs only while the board is overdue, at most once per turn.',
|
|
379
|
+
setObserverGroup: 'Observer (monitoring)',
|
|
380
|
+
setObserverHint: 'How overdue the board must be before nudging/auditing; once auto-sync is off the observer only reminds and never edits current.',
|
|
381
|
+
setApiGroup: 'API (read-only)',
|
|
382
|
+
setApiHint: 'One builder, two planes: in-process service plus HTTP, consumed read-only by compaction plugins.',
|
|
383
|
+
setMode: 'Mode',
|
|
384
|
+
setModeOff: 'Off',
|
|
385
|
+
setModeRegistered: 'Registered provider',
|
|
386
|
+
setModeDirect: 'Direct endpoint',
|
|
387
|
+
setProvider: 'Provider',
|
|
388
|
+
setProviderHint: 'Provider name under Settings → Models (required for registered)',
|
|
389
|
+
setModel: 'Model',
|
|
390
|
+
setBaseUrl: 'Endpoint URL',
|
|
391
|
+
setApiKey: 'API key',
|
|
392
|
+
setApiKeyHint: 'Write-only; the snapshot only reports hasApiKey',
|
|
393
|
+
setAuthority: 'Assistant authority',
|
|
394
|
+
setAuthorityBoth: 'Slots + round draft',
|
|
395
|
+
setAuthoritySlots: 'Slots only',
|
|
396
|
+
setAuthorityRounds: 'Round draft only',
|
|
397
|
+
setInterval: 'Min interval (ms)',
|
|
398
|
+
setIntervalHint: 'Minimum gap between two audits, default 90000',
|
|
399
|
+
setAutoApply: 'Auto-apply slot changes',
|
|
400
|
+
setObserverEnabled: 'Enable observer',
|
|
401
|
+
setMaxIdleSteps: 'Overdue step threshold',
|
|
402
|
+
setMaxIdleMs: 'Overdue time threshold (ms)',
|
|
403
|
+
setAutoSyncCurrent: 'Auto-sync current',
|
|
404
|
+
setAutoSyncThrottleMs: 'Auto-sync throttle (ms)',
|
|
405
|
+
setMaxItems: 'Checklist item cap',
|
|
406
|
+
setSaved: 'Saved',
|
|
407
|
+
setFailed: 'Save failed',
|
|
408
|
+
setReadOnly: 'Current config is not writable',
|
|
409
|
+
setNoScope: 'This host exposes no settings write surface (configForms); edit the profile cordis.patch.yml instead.',
|
|
410
|
+
setLive: 'Runtime editable',
|
|
411
|
+
setTopHint: 'Changes persist immediately, no restart needed',
|
|
412
|
+
setLlmBadge: 'Audit',
|
|
413
|
+
setObserverBadge: 'Monitor',
|
|
414
|
+
setApiBadge: 'Read-only',
|
|
415
|
+
setSave: 'Save',
|
|
416
|
+
setSaving: 'Saving…',
|
|
417
|
+
setReset: 'Discard',
|
|
418
|
+
setDirty: 'Unsaved changes',
|
|
419
|
+
setApiService: 'service',
|
|
420
|
+
setApiAnchor: 'HTTP',
|
|
421
|
+
setApiSnapshot: 'Snapshot',
|
|
422
|
+
setApiStatus: 'Dock status',
|
|
329
423
|
etaLeft: '~',
|
|
330
424
|
etaOver: 'over by',
|
|
331
425
|
staleTag: 'idle',
|
|
@@ -515,6 +609,20 @@ window.__ModuleLoader__.load({
|
|
|
515
609
|
.pb-llm-title { font-size: 12px; font-weight: 650; }
|
|
516
610
|
.pb-llm-line { margin-top: 4px; font-size: 12px; line-height: 1.5; }
|
|
517
611
|
.pb-llm-hint { margin-top: 4px; font-size: 11px; line-height: 1.5; opacity: .75; }
|
|
612
|
+
.pb-set { display: grid; gap: 14px; font-size: 12px; }
|
|
613
|
+
.pb-set-group { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; }
|
|
614
|
+
.pb-set-group-title { font-size: 13px; font-weight: 650; }
|
|
615
|
+
.pb-set-group-hint { font-size: 11px; line-height: 1.5; opacity: .68; }
|
|
616
|
+
.pb-set-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 4px 12px; align-items: center; }
|
|
617
|
+
.pb-set-label { opacity: .85; }
|
|
618
|
+
.pb-set-control { min-width: 0; display: flex; gap: 6px; align-items: center; }
|
|
619
|
+
.pb-set-control > input[type="text"], .pb-set-control > input[type="password"], .pb-set-control > input[type="number"], .pb-set-control > select { flex: 1; min-width: 0; padding: 5px 8px; font: inherit; font-size: 12px; border: 1px solid var(--dsw-alias-border-l1); border-radius: 6px; background: transparent; color: inherit; }
|
|
620
|
+
.pb-set-control > input[type="checkbox"] { width: 15px; height: 15px; }
|
|
621
|
+
.pb-set-hint { grid-column: 2; font-size: 11px; line-height: 1.5; opacity: .65; }
|
|
622
|
+
.pb-set-banner { padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(217,119,6,.35); background: rgba(217,119,6,.08); font-size: 12px; line-height: 1.5; }
|
|
623
|
+
.pb-set-status { font-size: 12px; opacity: .75; }
|
|
624
|
+
.pb-set-api { display: grid; gap: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; opacity: .85; word-break: break-all; }
|
|
625
|
+
.pb-set-api b { font-weight: 600; opacity: .8; margin-right: 6px; }
|
|
518
626
|
.pb-header-btn {
|
|
519
627
|
display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
|
|
520
628
|
border: 1px solid transparent; border-radius: 6px; background: transparent;
|
|
@@ -1457,6 +1565,392 @@ window.__ModuleLoader__.load({
|
|
|
1457
1565
|
)
|
|
1458
1566
|
}
|
|
1459
1567
|
|
|
1568
|
+
// ── 设置面:顶层 settings.section + 插件页 plugins.bundle.config 双座位 ──────
|
|
1569
|
+
// 宿主的既有规则(与 dsh-brief-sidebar / dsh-browser-cdp 一致):
|
|
1570
|
+
// · 顶层 `settings.section`:独立导航分节,id 自定义;
|
|
1571
|
+
// · `plugins.bundle.config`:bundle 详情页配置卡,key 必须是 **包名**;
|
|
1572
|
+
// · `configForms` 可能在客户端 apply 之后才就绪 → 句柄走 deferred inject,
|
|
1573
|
+
// 两个座位共用同一句柄,卡内自行降级为空态提示(不静默吞掉入口)。
|
|
1574
|
+
let unionConfigForms
|
|
1575
|
+
const unionFormsListeners = new Set()
|
|
1576
|
+
|
|
1577
|
+
function unionFormsScope() {
|
|
1578
|
+
const forms = unionConfigForms
|
|
1579
|
+
if (!forms || typeof forms.get !== 'function') return undefined
|
|
1580
|
+
// entry id 在 cordis.patch.yml 里是 `progress-union`,包名是 `dsh-progress-union`,两个都试。
|
|
1581
|
+
for (const id of ['progress-union', 'dsh-progress-union']) {
|
|
1582
|
+
try {
|
|
1583
|
+
const scope = forms.get(id)
|
|
1584
|
+
if (scope && typeof scope.getSnapshot === 'function' && typeof scope.subscribe === 'function' && typeof scope.set === 'function') return scope
|
|
1585
|
+
} catch (_error) {
|
|
1586
|
+
// entry 尚未注册时跳过
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
return undefined
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
function bindUnionConfigForms(ctx) {
|
|
1593
|
+
try {
|
|
1594
|
+
ctx.inject(['configForms'], (scope) => {
|
|
1595
|
+
unionConfigForms = scope && scope.configForms
|
|
1596
|
+
for (const fn of unionFormsListeners) {
|
|
1597
|
+
try {
|
|
1598
|
+
fn()
|
|
1599
|
+
} catch (_error) {
|
|
1600
|
+
// 监听者卸载期失败无关紧要
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
})
|
|
1604
|
+
} catch (_error) {
|
|
1605
|
+
// 宿主无 ctx.inject:卡退化为只读提示
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
function useUnionScope() {
|
|
1610
|
+
const [scope, setScope] = useState(() => unionFormsScope())
|
|
1611
|
+
useEffect(() => {
|
|
1612
|
+
const sync = () => setScope(unionFormsScope())
|
|
1613
|
+
unionFormsListeners.add(sync)
|
|
1614
|
+
sync()
|
|
1615
|
+
return () => {
|
|
1616
|
+
unionFormsListeners.delete(sync)
|
|
1617
|
+
}
|
|
1618
|
+
}, [])
|
|
1619
|
+
return scope
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
// 样式必须注入 document.head:设置页 / 插件详情页是另一个 React 根,
|
|
1623
|
+
// 数据面板里的 <style> 到不了那里(上一版设置卡「裸奔」的原因)。
|
|
1624
|
+
const SETTINGS_STYLE_ID = 'dsh-progress-union-settings-style'
|
|
1625
|
+
const SETTINGS_CSS = `
|
|
1626
|
+
.dsu-set { display: grid; gap: 14px; font-size: 12px; color: inherit; }
|
|
1627
|
+
.dsu-topline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
1628
|
+
.dsu-chip { font-size: 11px; line-height: 1.6; padding: 1px 9px; border-radius: 999px; background: rgba(47,111,237,.12); color: #2f6fed; white-space: nowrap; }
|
|
1629
|
+
.dsu-chip-warn { background: rgba(217,119,6,.14); color: #b45309; }
|
|
1630
|
+
.dsu-card { border: 1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.22)); border-radius: 12px; background: var(--dsw-alias-bg-layer-1, rgba(128,128,128,.04)); overflow: hidden; }
|
|
1631
|
+
.dsu-card-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; cursor: pointer; user-select: none; }
|
|
1632
|
+
.dsu-card-head:hover { background: rgba(128,128,128,.06); }
|
|
1633
|
+
.dsu-card-title { font-size: 13px; font-weight: 650; }
|
|
1634
|
+
.dsu-card-badge { font-size: 10px; line-height: 1.7; padding: 0 7px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.25)); opacity: .72; white-space: nowrap; }
|
|
1635
|
+
.dsu-card-chev { margin-left: auto; opacity: .55; font-size: 11px; }
|
|
1636
|
+
.dsu-card-body { display: grid; gap: 10px; padding: 2px 14px 14px; }
|
|
1637
|
+
.dsu-hint { font-size: 11px; line-height: 1.6; opacity: .66; }
|
|
1638
|
+
.dsu-row { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 4px 12px; align-items: center; }
|
|
1639
|
+
.dsu-row-hint { grid-column: 2; }
|
|
1640
|
+
.dsu-label { opacity: .84; }
|
|
1641
|
+
.dsu-control { min-width: 0; display: flex; align-items: center; gap: 8px; }
|
|
1642
|
+
.dsu-input, .dsu-select { flex: 1; min-width: 0; padding: 7px 10px; font: inherit; font-size: 12px; color: inherit; background: var(--dsw-alias-bg-base, rgba(255,255,255,.04)); border: 1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.3)); border-radius: 8px; outline: none; transition: border-color .15s, box-shadow .15s; }
|
|
1643
|
+
.dsu-input:focus, .dsu-select:focus { border-color: #2f6fed; box-shadow: 0 0 0 3px rgba(47,111,237,.14); }
|
|
1644
|
+
.dsu-input[disabled] { opacity: .6; }
|
|
1645
|
+
.dsu-unit { flex: none; font-size: 11px; opacity: .6; min-width: 18px; }
|
|
1646
|
+
.dsu-switch { position: relative; display: inline-flex; width: 38px; height: 21px; flex: none; }
|
|
1647
|
+
.dsu-switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
|
|
1648
|
+
.dsu-switch > i { position: absolute; inset: 0; border-radius: 999px; background: rgba(128,128,128,.38); transition: background .16s; pointer-events: none; }
|
|
1649
|
+
.dsu-switch > i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.24); transition: transform .16s; }
|
|
1650
|
+
.dsu-switch input:checked + i { background: #2f6fed; }
|
|
1651
|
+
.dsu-switch input:checked + i::after { transform: translateX(17px); }
|
|
1652
|
+
.dsu-seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(128,128,128,.14); }
|
|
1653
|
+
.dsu-seg > button { appearance: none; border: 0; background: transparent; color: inherit; font: inherit; font-size: 12px; padding: 5px 12px; border-radius: 7px; cursor: pointer; opacity: .72; white-space: nowrap; }
|
|
1654
|
+
.dsu-seg > button[data-on="true"] { background: var(--dsw-alias-bg-base, #fff); box-shadow: 0 1px 3px rgba(0,0,0,.14); opacity: 1; font-weight: 600; }
|
|
1655
|
+
.dsu-actions { display: flex; align-items: center; gap: 10px; padding-top: 2px; }
|
|
1656
|
+
.dsu-actions .dsu-spacer { flex: 1; }
|
|
1657
|
+
.dsu-btn { appearance: none; font: inherit; font-size: 12px; padding: 6px 14px; border-radius: 8px; cursor: pointer; border: 1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.3)); background: transparent; color: inherit; }
|
|
1658
|
+
.dsu-btn:disabled { opacity: .45; cursor: default; }
|
|
1659
|
+
.dsu-btn-primary { background: #2f6fed; border-color: #2f6fed; color: #fff; font-weight: 600; }
|
|
1660
|
+
.dsu-api { display: grid; gap: 6px; font-size: 11px; }
|
|
1661
|
+
.dsu-api > div { display: flex; gap: 8px; padding: 6px 9px; border-radius: 7px; background: rgba(128,128,128,.09); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
|
|
1662
|
+
.dsu-api b { flex: none; font-family: inherit; font-weight: 600; opacity: .72; }
|
|
1663
|
+
.dsu-empty { padding: 12px 14px; border-radius: 10px; border: 1px dashed var(--dsw-alias-border-l1, rgba(128,128,128,.35)); font-size: 12px; line-height: 1.6; opacity: .8; }
|
|
1664
|
+
`
|
|
1665
|
+
|
|
1666
|
+
function ensureUnionSettingsStyle() {
|
|
1667
|
+
try {
|
|
1668
|
+
if (typeof document === 'undefined') return
|
|
1669
|
+
if (document.getElementById(SETTINGS_STYLE_ID)) return
|
|
1670
|
+
const el = document.createElement('style')
|
|
1671
|
+
el.id = SETTINGS_STYLE_ID
|
|
1672
|
+
el.textContent = SETTINGS_CSS
|
|
1673
|
+
document.head.appendChild(el)
|
|
1674
|
+
} catch (_error) {
|
|
1675
|
+
// 无 DOM(SSR / 测试环境)时静默跳过
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
function SettingsSwitch(props) {
|
|
1680
|
+
return h(
|
|
1681
|
+
'span',
|
|
1682
|
+
{ className: 'dsu-switch' },
|
|
1683
|
+
h('input', { type: 'checkbox', checked: props.checked === true, disabled: props.disabled === true, onChange: (e) => props.onChange(e.target.checked) }),
|
|
1684
|
+
h('i', null),
|
|
1685
|
+
)
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
function SettingsSegment(props) {
|
|
1689
|
+
return h(
|
|
1690
|
+
'span',
|
|
1691
|
+
{ className: 'dsu-seg' },
|
|
1692
|
+
props.options.map((opt) =>
|
|
1693
|
+
h(
|
|
1694
|
+
'button',
|
|
1695
|
+
{
|
|
1696
|
+
key: opt[0],
|
|
1697
|
+
type: 'button',
|
|
1698
|
+
'data-on': String(props.value === opt[0]),
|
|
1699
|
+
disabled: props.disabled === true,
|
|
1700
|
+
onClick: () => {
|
|
1701
|
+
if (props.value !== opt[0]) props.onChange(opt[0])
|
|
1702
|
+
},
|
|
1703
|
+
},
|
|
1704
|
+
opt[1],
|
|
1705
|
+
),
|
|
1706
|
+
),
|
|
1707
|
+
)
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
function SettingsCard(props) {
|
|
1711
|
+
const [open, setOpen] = useState(props.defaultOpen !== false)
|
|
1712
|
+
return h(
|
|
1713
|
+
'div',
|
|
1714
|
+
{ className: 'dsu-card' },
|
|
1715
|
+
h(
|
|
1716
|
+
'div',
|
|
1717
|
+
{
|
|
1718
|
+
className: 'dsu-card-head',
|
|
1719
|
+
role: 'button',
|
|
1720
|
+
tabIndex: 0,
|
|
1721
|
+
onClick: () => setOpen((v) => !v),
|
|
1722
|
+
onKeyDown: (e) => {
|
|
1723
|
+
if (e && (e.key === 'Enter' || e.key === ' ')) setOpen((v) => !v)
|
|
1724
|
+
},
|
|
1725
|
+
},
|
|
1726
|
+
h('span', { className: 'dsu-card-title' }, props.title),
|
|
1727
|
+
props.badge ? h('span', { className: 'dsu-card-badge' }, props.badge) : null,
|
|
1728
|
+
h('span', { className: 'dsu-card-chev' }, open ? '▾' : '▸'),
|
|
1729
|
+
),
|
|
1730
|
+
open
|
|
1731
|
+
? h(
|
|
1732
|
+
'div',
|
|
1733
|
+
{ className: 'dsu-card-body' },
|
|
1734
|
+
props.hint ? h('div', { className: 'dsu-hint' }, props.hint) : null,
|
|
1735
|
+
props.children,
|
|
1736
|
+
)
|
|
1737
|
+
: null,
|
|
1738
|
+
)
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
function SettingsRow(props) {
|
|
1742
|
+
return h(
|
|
1743
|
+
'div',
|
|
1744
|
+
{ className: 'dsu-row' },
|
|
1745
|
+
h('span', { className: 'dsu-label' }, props.label),
|
|
1746
|
+
h('span', { className: 'dsu-control' }, props.children),
|
|
1747
|
+
props.hint ? h('span', { className: 'dsu-hint dsu-row-hint' }, props.hint) : null,
|
|
1748
|
+
)
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
function ProgressUnionSettings(props) {
|
|
1752
|
+
const t = makeT(props)
|
|
1753
|
+
const scope = useUnionScope()
|
|
1754
|
+
const [snap, setSnap] = useState(null)
|
|
1755
|
+
const [draft, setDraft] = useState({})
|
|
1756
|
+
const [status, setStatus] = useState('')
|
|
1757
|
+
const [busy, setBusy] = useState(false)
|
|
1758
|
+
|
|
1759
|
+
useEffect(() => {
|
|
1760
|
+
if (!scope) return undefined
|
|
1761
|
+
let alive = true
|
|
1762
|
+
const read = () => {
|
|
1763
|
+
if (!alive) return
|
|
1764
|
+
try {
|
|
1765
|
+
setSnap(scope.getSnapshot())
|
|
1766
|
+
} catch (_error) {
|
|
1767
|
+
// 句柄随 entry 重载重建;读失败保持上一帧
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
read()
|
|
1771
|
+
let off
|
|
1772
|
+
try {
|
|
1773
|
+
off = scope.subscribe(read)
|
|
1774
|
+
} catch (_error) {
|
|
1775
|
+
off = undefined
|
|
1776
|
+
}
|
|
1777
|
+
return () => {
|
|
1778
|
+
alive = false
|
|
1779
|
+
if (typeof off === 'function') {
|
|
1780
|
+
try {
|
|
1781
|
+
off()
|
|
1782
|
+
} catch (_error) {
|
|
1783
|
+
// 卸载期失败无关紧要
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
}, [scope])
|
|
1788
|
+
|
|
1789
|
+
const value = (snap && snap.value) || {}
|
|
1790
|
+
const writable = Boolean(scope) && (!snap || snap.writable !== false)
|
|
1791
|
+
const asObject = (v) => (v && typeof v === 'object' && !Array.isArray(v) ? v : {})
|
|
1792
|
+
const assistant = asObject(value.assistant)
|
|
1793
|
+
const observer = asObject(value.observer)
|
|
1794
|
+
|
|
1795
|
+
// 文本/数字走草稿(避免逐字符写盘),开关与分段直接落盘(即时生效)。
|
|
1796
|
+
const readField = (group, key, fallback) => {
|
|
1797
|
+
const bucket = draft[group]
|
|
1798
|
+
if (bucket && Object.prototype.hasOwnProperty.call(bucket, key)) return bucket[key]
|
|
1799
|
+
const stored = (group === 'assistant' ? assistant : observer)[key]
|
|
1800
|
+
return stored === undefined || stored === null ? fallback : stored
|
|
1801
|
+
}
|
|
1802
|
+
const setDraftField = (group, key, v) => setDraft((prev) => ({ ...prev, [group]: { ...(prev[group] || {}), [key]: v } }))
|
|
1803
|
+
const dirtyKeys = (group) => Object.keys(draft[group] || {})
|
|
1804
|
+
|
|
1805
|
+
const commit = async (group, patch) => {
|
|
1806
|
+
if (!scope) {
|
|
1807
|
+
setStatus(t('setNoScope'))
|
|
1808
|
+
return false
|
|
1809
|
+
}
|
|
1810
|
+
if (!writable) {
|
|
1811
|
+
setStatus(t('setReadOnly'))
|
|
1812
|
+
return false
|
|
1813
|
+
}
|
|
1814
|
+
setBusy(true)
|
|
1815
|
+
try {
|
|
1816
|
+
const ok = await scope.set(group, patch)
|
|
1817
|
+
setStatus(ok === false ? t('setFailed') : t('setSaved'))
|
|
1818
|
+
return ok !== false
|
|
1819
|
+
} catch (_error) {
|
|
1820
|
+
setStatus(t('setFailed'))
|
|
1821
|
+
return false
|
|
1822
|
+
} finally {
|
|
1823
|
+
setBusy(false)
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
const commitNow = (group, base, key, next) => void commit(group, { ...base, [key]: next })
|
|
1827
|
+
const flush = async () => {
|
|
1828
|
+
const aKeys = dirtyKeys('assistant')
|
|
1829
|
+
const oKeys = dirtyKeys('observer')
|
|
1830
|
+
if (aKeys.length) await commit('assistant', { ...assistant, ...draft.assistant })
|
|
1831
|
+
if (oKeys.length) await commit('observer', { ...observer, ...draft.observer })
|
|
1832
|
+
setDraft({})
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
const textInput = (group, key, fallback, placeholder) =>
|
|
1836
|
+
h('input', {
|
|
1837
|
+
className: 'dsu-input',
|
|
1838
|
+
type: 'text',
|
|
1839
|
+
value: String(readField(group, key, fallback) ?? ''),
|
|
1840
|
+
placeholder: placeholder || '',
|
|
1841
|
+
disabled: !writable,
|
|
1842
|
+
onChange: (e) => setDraftField(group, key, e.target.value),
|
|
1843
|
+
})
|
|
1844
|
+
const secretInput = (group, key, placeholder) =>
|
|
1845
|
+
h('input', {
|
|
1846
|
+
className: 'dsu-input',
|
|
1847
|
+
type: 'password',
|
|
1848
|
+
value: String(readField(group, key, '') ?? ''),
|
|
1849
|
+
placeholder: placeholder || '',
|
|
1850
|
+
disabled: !writable,
|
|
1851
|
+
onChange: (e) => setDraftField(group, key, e.target.value),
|
|
1852
|
+
})
|
|
1853
|
+
const numberInput = (group, key, fallback, step, unit) => [
|
|
1854
|
+
h('input', {
|
|
1855
|
+
key: 'input',
|
|
1856
|
+
className: 'dsu-input',
|
|
1857
|
+
type: 'number',
|
|
1858
|
+
step,
|
|
1859
|
+
value: String(readField(group, key, fallback)),
|
|
1860
|
+
disabled: !writable,
|
|
1861
|
+
onChange: (e) => setDraftField(group, key, Number(e.target.value)),
|
|
1862
|
+
}),
|
|
1863
|
+
unit ? h('span', { key: 'unit', className: 'dsu-unit' }, unit) : null,
|
|
1864
|
+
]
|
|
1865
|
+
const switchInput = (group, base, key, fallback) =>
|
|
1866
|
+
h(SettingsSwitch, {
|
|
1867
|
+
checked: readField(group, key, fallback) !== false,
|
|
1868
|
+
disabled: !writable || busy,
|
|
1869
|
+
onChange: (v) => {
|
|
1870
|
+
setDraftField(group, key, v)
|
|
1871
|
+
commitNow(group, base, key, v)
|
|
1872
|
+
},
|
|
1873
|
+
})
|
|
1874
|
+
const segmentInput = (group, base, key, fallback, options) =>
|
|
1875
|
+
h(SettingsSegment, {
|
|
1876
|
+
value: readField(group, key, fallback),
|
|
1877
|
+
disabled: !writable || busy,
|
|
1878
|
+
options,
|
|
1879
|
+
onChange: (v) => {
|
|
1880
|
+
setDraftField(group, key, v)
|
|
1881
|
+
commitNow(group, base, key, v)
|
|
1882
|
+
},
|
|
1883
|
+
})
|
|
1884
|
+
|
|
1885
|
+
const hasDirty = dirtyKeys('assistant').length > 0 || dirtyKeys('observer').length > 0
|
|
1886
|
+
const mode = readField('assistant', 'mode', '')
|
|
1887
|
+
const authority = readField('assistant', 'authority', 'both')
|
|
1888
|
+
|
|
1889
|
+
return h(
|
|
1890
|
+
'div',
|
|
1891
|
+
{ className: 'dsu-set' },
|
|
1892
|
+
h(
|
|
1893
|
+
'div',
|
|
1894
|
+
{ className: 'dsu-topline' },
|
|
1895
|
+
h('span', { className: writable ? 'dsu-chip' : 'dsu-chip dsu-chip-warn' }, writable ? t('setLive') : t('setReadOnly')),
|
|
1896
|
+
h('span', { className: 'dsu-hint' }, writable ? t('setTopHint') : t('setNoScope')),
|
|
1897
|
+
),
|
|
1898
|
+
h(
|
|
1899
|
+
SettingsCard,
|
|
1900
|
+
{ title: t('setLlmGroup'), badge: t('setLlmBadge'), hint: t('setLlmHint') },
|
|
1901
|
+
h(SettingsRow, { label: t('setMode') },
|
|
1902
|
+
segmentInput('assistant', assistant, 'mode', '', [['', t('setModeOff')], ['registered', t('setModeRegistered')], ['direct', t('setModeDirect')]])),
|
|
1903
|
+
mode === 'registered'
|
|
1904
|
+
? h(SettingsRow, { label: t('setProvider'), hint: t('setProviderHint') }, textInput('assistant', 'provider', '', 'local-35b'))
|
|
1905
|
+
: null,
|
|
1906
|
+
h(SettingsRow, { label: t('setModel') }, textInput('assistant', 'model', '', mode === 'direct' ? 'qwen2.5-3b' : 'Qwen3.6-35B-A3B')),
|
|
1907
|
+
mode === 'direct' ? h(SettingsRow, { label: t('setBaseUrl') }, textInput('assistant', 'baseUrl', '', 'http://127.0.0.1:8000/v1')) : null,
|
|
1908
|
+
mode === 'direct' ? h(SettingsRow, { label: t('setApiKey'), hint: t('setApiKeyHint') }, secretInput('assistant', 'apiKey', assistant.hasApiKey ? '••••••' : '')) : null,
|
|
1909
|
+
mode === ''
|
|
1910
|
+
? null
|
|
1911
|
+
: h(SettingsRow, { label: t('setAuthority') },
|
|
1912
|
+
segmentInput('assistant', assistant, 'authority', 'both', [['both', t('setAuthorityBoth')], ['slots', t('setAuthoritySlots')], ['rounds', t('setAuthorityRounds')]])),
|
|
1913
|
+
mode === '' ? null : h(SettingsRow, { label: t('setInterval'), hint: t('setIntervalHint') }, numberInput('assistant', 'minIntervalMs', 90000, 1000, 'ms')),
|
|
1914
|
+
mode === '' ? null : h(SettingsRow, { label: t('setAutoApply') }, switchInput('assistant', assistant, 'autoApply', true)),
|
|
1915
|
+
),
|
|
1916
|
+
h(
|
|
1917
|
+
SettingsCard,
|
|
1918
|
+
{ title: t('setObserverGroup'), badge: t('setObserverBadge'), hint: t('setObserverHint') },
|
|
1919
|
+
h(SettingsRow, { label: t('setObserverEnabled') }, switchInput('observer', observer, 'enabled', true)),
|
|
1920
|
+
h(SettingsRow, { label: t('setMaxIdleSteps') }, numberInput('observer', 'maxIdleSteps', 6, 1, '步')),
|
|
1921
|
+
h(SettingsRow, { label: t('setMaxIdleMs') }, numberInput('observer', 'maxIdleMs', 180000, 1000, 'ms')),
|
|
1922
|
+
h(SettingsRow, { label: t('setAutoSyncCurrent') }, switchInput('observer', observer, 'autoSyncCurrent', true)),
|
|
1923
|
+
h(SettingsRow, { label: t('setAutoSyncThrottleMs') }, numberInput('observer', 'autoSyncThrottleMs', 60000, 1000, 'ms')),
|
|
1924
|
+
h(SettingsRow, { label: t('setMaxItems') }, numberInput('observer', 'maxItems', 12, 1, '项')),
|
|
1925
|
+
),
|
|
1926
|
+
h(
|
|
1927
|
+
SettingsCard,
|
|
1928
|
+
{ title: t('setApiGroup'), badge: t('setApiBadge'), hint: t('setApiHint'), defaultOpen: false },
|
|
1929
|
+
h('div', { className: 'dsu-api' },
|
|
1930
|
+
h('div', null, h('b', null, t('setApiService')), "ctx.get('progressAnchor').get(sessionId) / .list()"),
|
|
1931
|
+
h('div', null, h('b', null, t('setApiAnchor')), 'GET /progress-union/anchor?sessionId=<id>'),
|
|
1932
|
+
h('div', null, h('b', null, t('setApiSnapshot')), 'GET /progress-union/snapshot?sessionId=<id>'),
|
|
1933
|
+
h('div', null, h('b', null, t('setApiStatus')), 'GET /dsh-progress/status?sessionId=<id>'),
|
|
1934
|
+
),
|
|
1935
|
+
),
|
|
1936
|
+
h(
|
|
1937
|
+
'div',
|
|
1938
|
+
{ className: 'dsu-actions' },
|
|
1939
|
+
h('button', { type: 'button', className: 'dsu-btn dsu-btn-primary', disabled: !hasDirty || busy || !writable, onClick: () => void flush() }, busy ? t('setSaving') : t('setSave')),
|
|
1940
|
+
h('button', {
|
|
1941
|
+
type: 'button',
|
|
1942
|
+
className: 'dsu-btn',
|
|
1943
|
+
disabled: !hasDirty || busy,
|
|
1944
|
+
onClick: () => {
|
|
1945
|
+
setDraft({})
|
|
1946
|
+
setStatus('')
|
|
1947
|
+
},
|
|
1948
|
+
}, t('setReset')),
|
|
1949
|
+
h('span', { className: 'dsu-hint dsu-spacer' }, hasDirty ? t('setDirty') : ''),
|
|
1950
|
+
status ? h('span', { className: 'dsu-hint' }, status) : null,
|
|
1951
|
+
),
|
|
1952
|
+
)
|
|
1953
|
+
}
|
|
1460
1954
|
function ProgressSidePanel(props) {
|
|
1461
1955
|
const t = makeT(props)
|
|
1462
1956
|
const { sessionId } = props
|
|
@@ -2178,6 +2672,34 @@ window.__ModuleLoader__.load({
|
|
|
2178
2672
|
)
|
|
2179
2673
|
|
|
2180
2674
|
const t = ctx.locale.bind(NS)
|
|
2675
|
+
|
|
2676
|
+
// 双座位注册:顶层设置分节(settings.section)+ 插件详情页配置卡
|
|
2677
|
+
// (plugins.bundle.config,keyed by **包名**)。
|
|
2678
|
+
// configForms 可能在 apply 之后才就绪 → 走 deferred inject 捕获句柄,
|
|
2679
|
+
// 卡内自己订阅句柄并重取 scope,所以两个座位都可以先注空 prop。
|
|
2680
|
+
bindUnionConfigForms(ctx)
|
|
2681
|
+
ensureUnionSettingsStyle()
|
|
2682
|
+
const registerSettingsSeat = (seat, options) =>
|
|
2683
|
+
ctx.slots.inject(seat, () =>
|
|
2684
|
+
ctx.slots.register(
|
|
2685
|
+
{
|
|
2686
|
+
name: seat,
|
|
2687
|
+
...options,
|
|
2688
|
+
locale: NS,
|
|
2689
|
+
inject: () => ({}),
|
|
2690
|
+
},
|
|
2691
|
+
ProgressUnionSettings,
|
|
2692
|
+
),
|
|
2693
|
+
)
|
|
2694
|
+
ctx.effect(
|
|
2695
|
+
() => registerSettingsSeat('settings.section', { id: 'dsh-progress-union', order: 215, label: () => t('setTitle') }),
|
|
2696
|
+
'progress-union: settings section',
|
|
2697
|
+
)
|
|
2698
|
+
ctx.effect(
|
|
2699
|
+
() => registerSettingsSeat('plugins.bundle.config', { key: 'dsh-progress-union', order: 15 }),
|
|
2700
|
+
'progress-union: bundle config card',
|
|
2701
|
+
)
|
|
2702
|
+
|
|
2181
2703
|
const wakeAgent = (sessionId, text) => {
|
|
2182
2704
|
try {
|
|
2183
2705
|
const binding = ctx.sessions.binding(sessionId)
|
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-progress-union",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"description": "进度结合原型:board 槽位真相源(用户可编辑、diff+ack 增量同步、staleness nudge)× 鲸程时间引擎(step 计数、ETA 三档 board>todo>local>prior、悬浮迷你条),并向压缩插件暴露只读三层进度锚点 progressAnchor(board 语义锚 + time 时间锚 + userEdits 未确认改动,service 与 HTTP 双平面)。",
|
|
6
6
|
"engines": {
|
package/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import z from '@deepseek-ai/schemastery'
|
|
|
26
26
|
// live ref(带 .get())注入 apply。整对象套一层 .volatile() 不生成字段表单(面板
|
|
27
27
|
// 只会空空如也),所以必须每个叶子单独标——与 dsh-llm-openai-completions 同式。
|
|
28
28
|
export const Config = z.object({
|
|
29
|
+
protocolHint: z.boolean().default(true).volatile(),
|
|
29
30
|
assistant: z.object({
|
|
30
31
|
mode: z.union(['', 'registered', 'direct']).default('').volatile(),
|
|
31
32
|
provider: z.string().default('').volatile(),
|
|
@@ -36,6 +37,14 @@ export const Config = z.object({
|
|
|
36
37
|
minIntervalMs: z.number().step(1000).min(0).default(90000).volatile(),
|
|
37
38
|
autoApply: z.boolean().default(true).volatile(),
|
|
38
39
|
}).default({}),
|
|
40
|
+
observer: z.object({
|
|
41
|
+
enabled: z.boolean().default(true).volatile(),
|
|
42
|
+
maxIdleSteps: z.number().step(1).min(1).default(6).volatile(),
|
|
43
|
+
maxIdleMs: z.number().step(1000).min(1000).default(180000).volatile(),
|
|
44
|
+
autoSyncCurrent: z.boolean().default(true).volatile(),
|
|
45
|
+
autoSyncThrottleMs: z.number().step(1000).min(0).default(60000).volatile(),
|
|
46
|
+
maxItems: z.number().step(1).min(1).default(12).volatile(),
|
|
47
|
+
}).default({}),
|
|
39
48
|
})
|
|
40
49
|
|
|
41
50
|
// —— 路由与存储标识 ——
|
|
@@ -534,7 +543,27 @@ function readVolatile(value, fallback) {
|
|
|
534
543
|
|
|
535
544
|
export async function apply(ctx, config) {
|
|
536
545
|
const cfg = Object.assign({}, DEFAULT_CONFIG, config && typeof config === 'object' ? config : {})
|
|
537
|
-
|
|
546
|
+
// observer 的每个叶子都是 volatile(设置页可改):统一每次读取时解包。
|
|
547
|
+
const observerRaw = config && typeof config === 'object' ? config.observer : undefined
|
|
548
|
+
function observerNow() {
|
|
549
|
+
const base = DEFAULT_CONFIG.observer
|
|
550
|
+
const raw = unwrapLive(observerRaw)
|
|
551
|
+
if (!isObject(raw)) return { ...base }
|
|
552
|
+
const out = { ...base }
|
|
553
|
+
for (const key of Object.keys(base)) {
|
|
554
|
+
const v = unwrapLive(raw[key])
|
|
555
|
+
if (v !== undefined) out[key] = v
|
|
556
|
+
}
|
|
557
|
+
return out
|
|
558
|
+
}
|
|
559
|
+
// 用 getter 而不是快照:所有 `cfg.observer.x` 读点无需逐个改,设置页改完即生效。
|
|
560
|
+
Object.defineProperty(cfg, 'observer', { get: observerNow, configurable: true, enumerable: true })
|
|
561
|
+
const protocolHintRaw = config && typeof config === 'object' ? config.protocolHint : undefined
|
|
562
|
+
Object.defineProperty(cfg, 'protocolHint', {
|
|
563
|
+
get: () => readVolatile(protocolHintRaw, DEFAULT_CONFIG.protocolHint),
|
|
564
|
+
configurable: true,
|
|
565
|
+
enumerable: true,
|
|
566
|
+
})
|
|
538
567
|
// assistant 的每个字段都是 volatile:保留原始 ref(整对象或逐叶子皆可),
|
|
539
568
|
// 每次读取时解包,设置页改完下一次审查即生效,无需重启。
|
|
540
569
|
const assistantRaw = config && typeof config === 'object' ? config.assistant : undefined
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-progress-union",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "进度结合原型:dsh-progress-board 槽位真相源 × 鲸程 widget 时间/ETA 引擎,另向压缩插件暴露只读三层进度锚点(service + HTTP 双平面)。基于 l3j3y3/dsh-progress-board (MIT) 与 uuhihj/task-progress-bar dsh-progress-widget (MIT)。",
|
|
6
6
|
"license": "MIT",
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设置面契约守卫(2026-11-26 事故回归)。
|
|
3
|
+
*
|
|
4
|
+
* 1) 设置页字段表单靠 **schema 叶子** 的 `.volatile()` 标记生成:整对象标 volatile
|
|
5
|
+
* 时一个字段都不渲染(客户端也就看不到任何可编辑项)。这里逐叶子断言标记存在。
|
|
6
|
+
* 2) 客户端必须把设置卡注册到 `settings.section` 槽,并通过宿主 `configForms`
|
|
7
|
+
* 句柄读写——否则「bundle 页 / 设置页」都没有配置入口。
|
|
8
|
+
*/
|
|
9
|
+
import assert from 'node:assert/strict'
|
|
10
|
+
import fs from 'node:fs'
|
|
11
|
+
import os from 'node:os'
|
|
12
|
+
import path from 'node:path'
|
|
13
|
+
import test from 'node:test'
|
|
14
|
+
|
|
15
|
+
process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), 'union-test-'))
|
|
16
|
+
const { Config } = await import('../index.js')
|
|
17
|
+
|
|
18
|
+
/** 递归收集点分键 → 是否带 volatile 标记。 */
|
|
19
|
+
function volatileLeaves(node, prefix = '', out = {}) {
|
|
20
|
+
const inner = node && (node.dict || node.inner)
|
|
21
|
+
if (!inner || typeof inner !== 'object') return out
|
|
22
|
+
for (const [key, child] of Object.entries(inner)) {
|
|
23
|
+
const dotted = prefix ? `${prefix}.${key}` : key
|
|
24
|
+
const meta = (child && child.meta) || {}
|
|
25
|
+
const nested = child && (child.dict || child.inner)
|
|
26
|
+
if (nested && typeof nested === 'object') volatileLeaves(child, dotted, out)
|
|
27
|
+
else out[dotted] = meta.volatile !== undefined
|
|
28
|
+
}
|
|
29
|
+
return out
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
test('Config:assistant / observer 的每个叶子都带 volatile(否则设置页不生成字段)', () => {
|
|
33
|
+
const leaves = volatileLeaves(Config)
|
|
34
|
+
const expected = [
|
|
35
|
+
'protocolHint',
|
|
36
|
+
'assistant.mode',
|
|
37
|
+
'assistant.provider',
|
|
38
|
+
'assistant.model',
|
|
39
|
+
'assistant.baseUrl',
|
|
40
|
+
'assistant.apiKey',
|
|
41
|
+
'assistant.authority',
|
|
42
|
+
'assistant.minIntervalMs',
|
|
43
|
+
'assistant.autoApply',
|
|
44
|
+
'observer.enabled',
|
|
45
|
+
'observer.maxIdleSteps',
|
|
46
|
+
'observer.maxIdleMs',
|
|
47
|
+
'observer.autoSyncCurrent',
|
|
48
|
+
'observer.autoSyncThrottleMs',
|
|
49
|
+
'observer.maxItems',
|
|
50
|
+
]
|
|
51
|
+
for (const key of expected) {
|
|
52
|
+
assert.ok(key in leaves, `缺少配置键 ${key}`)
|
|
53
|
+
assert.equal(leaves[key], true, `${key} 必须是叶子级 .volatile()`)
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('Config:外层对象不得自己标 volatile(嵌套 volatile 会被宿主拒绝)', () => {
|
|
58
|
+
for (const key of ['assistant', 'observer']) {
|
|
59
|
+
const node = (Config.dict || Config.inner || {})[key]
|
|
60
|
+
assert.ok(node, `缺少 ${key} 节点`)
|
|
61
|
+
assert.equal((node.meta || {}).volatile, undefined, `${key} 这层不能标 volatile`)
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('客户端:设置卡双座位(settings.section + plugins.bundle.config)且走 configForms 句柄', () => {
|
|
66
|
+
const file = new URL('../client.js', import.meta.url).pathname.replace(/^\//, '')
|
|
67
|
+
const src = fs.readFileSync(file, 'utf8')
|
|
68
|
+
assert.match(src, /registerSettingsSeat\('settings\.section'/, '必须注册 settings.section 槽')
|
|
69
|
+
assert.match(src, /id: 'dsh-progress-union'/, '分节 id 必须固定')
|
|
70
|
+
assert.match(src, /registerSettingsSeat\('plugins\.bundle\.config'/, 'bundle 详情页也要有配置卡(keyed by 包名)')
|
|
71
|
+
assert.match(src, /key: 'dsh-progress-union'/, 'bundle 座位 key 必须是包名')
|
|
72
|
+
assert.match(src, /configForms/, '必须经宿主 configForms 读写配置')
|
|
73
|
+
assert.match(src, /function ProgressUnionSettings\(/, '设置卡组件必须在')
|
|
74
|
+
assert.match(src, /scope\.subscribe/, '设置卡要订阅句柄快照')
|
|
75
|
+
assert.match(src, /function ensureUnionSettingsStyle\(/, '样式要注入 document.head,否则设置页里裸奔')
|
|
76
|
+
})
|