dsh-progress-union 0.1.8 → 0.1.9
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 +14 -0
- package/README.md +3 -3
- package/client.js +283 -0
- package/dsh.plugin.json +1 -1
- package/index.js +30 -1
- package/package.json +1 -1
- package/test/settings.test.mjs +73 -0
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,20 @@
|
|
|
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
|
+
|
|
14
28
|
> 说明:0.1.0 是真实构建产物;0.1.1–0.1.6 由 0.1.0 → 最终态的可核验 diff 按功能块「逻辑分化重建」,每一版都只包含该版本描述的能力,源码逐版可执行;0.1.7 是发布工程面。
|
|
15
29
|
|
|
16
30
|
## 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`,重启宿主加载;**所有配置面在设置页的独立分节「进度板」**(与记忆 / 模型 / 插件并列,由客户端注册 `settings.section` 槽、经宿主 `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,44 @@ 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
|
+
setApiService: 'service',
|
|
253
|
+
setApiAnchor: 'HTTP',
|
|
254
|
+
setApiSnapshot: '快照',
|
|
255
|
+
setApiStatus: '迷你条状态',
|
|
218
256
|
etaLeft: '预计剩',
|
|
219
257
|
etaOver: '已超预估',
|
|
220
258
|
staleTag: '中断',
|
|
@@ -326,6 +364,44 @@ window.__ModuleLoader__.load({
|
|
|
326
364
|
llmAuto: ', auto-applied',
|
|
327
365
|
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
366
|
llmSettingsHint: 'Change in Settings',
|
|
367
|
+
setTitle: 'Progress board',
|
|
368
|
+
setLlmGroup: 'Assistant LLM (monitor/audit)',
|
|
369
|
+
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.',
|
|
370
|
+
setObserverGroup: 'Observer (monitoring)',
|
|
371
|
+
setObserverHint: 'How overdue the board must be before nudging/auditing; once auto-sync is off the observer only reminds and never edits current.',
|
|
372
|
+
setApiGroup: 'API (read-only)',
|
|
373
|
+
setApiHint: 'One builder, two planes: in-process service plus HTTP, consumed read-only by compaction plugins.',
|
|
374
|
+
setMode: 'Mode',
|
|
375
|
+
setModeOff: 'Off',
|
|
376
|
+
setModeRegistered: 'Registered provider',
|
|
377
|
+
setModeDirect: 'Direct endpoint',
|
|
378
|
+
setProvider: 'Provider',
|
|
379
|
+
setProviderHint: 'Provider name under Settings → Models (required for registered)',
|
|
380
|
+
setModel: 'Model',
|
|
381
|
+
setBaseUrl: 'Endpoint URL',
|
|
382
|
+
setApiKey: 'API key',
|
|
383
|
+
setApiKeyHint: 'Write-only; the snapshot only reports hasApiKey',
|
|
384
|
+
setAuthority: 'Assistant authority',
|
|
385
|
+
setAuthorityBoth: 'Slots + round draft',
|
|
386
|
+
setAuthoritySlots: 'Slots only',
|
|
387
|
+
setAuthorityRounds: 'Round draft only',
|
|
388
|
+
setInterval: 'Min interval (ms)',
|
|
389
|
+
setIntervalHint: 'Minimum gap between two audits, default 90000',
|
|
390
|
+
setAutoApply: 'Auto-apply slot changes',
|
|
391
|
+
setObserverEnabled: 'Enable observer',
|
|
392
|
+
setMaxIdleSteps: 'Overdue step threshold',
|
|
393
|
+
setMaxIdleMs: 'Overdue time threshold (ms)',
|
|
394
|
+
setAutoSyncCurrent: 'Auto-sync current',
|
|
395
|
+
setAutoSyncThrottleMs: 'Auto-sync throttle (ms)',
|
|
396
|
+
setMaxItems: 'Checklist item cap',
|
|
397
|
+
setSaved: 'Saved',
|
|
398
|
+
setFailed: 'Save failed',
|
|
399
|
+
setReadOnly: 'Current config is not writable',
|
|
400
|
+
setNoScope: 'This host exposes no settings write surface (configForms); edit the profile cordis.patch.yml instead.',
|
|
401
|
+
setApiService: 'service',
|
|
402
|
+
setApiAnchor: 'HTTP',
|
|
403
|
+
setApiSnapshot: 'Snapshot',
|
|
404
|
+
setApiStatus: 'Dock status',
|
|
329
405
|
etaLeft: '~',
|
|
330
406
|
etaOver: 'over by',
|
|
331
407
|
staleTag: 'idle',
|
|
@@ -515,6 +591,20 @@ window.__ModuleLoader__.load({
|
|
|
515
591
|
.pb-llm-title { font-size: 12px; font-weight: 650; }
|
|
516
592
|
.pb-llm-line { margin-top: 4px; font-size: 12px; line-height: 1.5; }
|
|
517
593
|
.pb-llm-hint { margin-top: 4px; font-size: 11px; line-height: 1.5; opacity: .75; }
|
|
594
|
+
.pb-set { display: grid; gap: 14px; font-size: 12px; }
|
|
595
|
+
.pb-set-group { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; }
|
|
596
|
+
.pb-set-group-title { font-size: 13px; font-weight: 650; }
|
|
597
|
+
.pb-set-group-hint { font-size: 11px; line-height: 1.5; opacity: .68; }
|
|
598
|
+
.pb-set-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 4px 12px; align-items: center; }
|
|
599
|
+
.pb-set-label { opacity: .85; }
|
|
600
|
+
.pb-set-control { min-width: 0; display: flex; gap: 6px; align-items: center; }
|
|
601
|
+
.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; }
|
|
602
|
+
.pb-set-control > input[type="checkbox"] { width: 15px; height: 15px; }
|
|
603
|
+
.pb-set-hint { grid-column: 2; font-size: 11px; line-height: 1.5; opacity: .65; }
|
|
604
|
+
.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; }
|
|
605
|
+
.pb-set-status { font-size: 12px; opacity: .75; }
|
|
606
|
+
.pb-set-api { display: grid; gap: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; opacity: .85; word-break: break-all; }
|
|
607
|
+
.pb-set-api b { font-weight: 600; opacity: .8; margin-right: 6px; }
|
|
518
608
|
.pb-header-btn {
|
|
519
609
|
display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
|
|
520
610
|
border: 1px solid transparent; border-radius: 6px; background: transparent;
|
|
@@ -1457,6 +1547,176 @@ window.__ModuleLoader__.load({
|
|
|
1457
1547
|
)
|
|
1458
1548
|
}
|
|
1459
1549
|
|
|
1550
|
+
// ── 设置分节(顶层 settings.section,与 dsh-browser-cdp 同式)─────────────
|
|
1551
|
+
// 宿主不会凭导出的 Config 自动生成表单:设置面必须由客户端注册到
|
|
1552
|
+
// `settings.section` 槽,数据臂走宿主原生 `configForms` 句柄
|
|
1553
|
+
// (get(entryId) → subscribe/getSnapshot/set),写值带 revision、改完即生效。
|
|
1554
|
+
function unionFormsScope(ctx) {
|
|
1555
|
+
let forms
|
|
1556
|
+
try {
|
|
1557
|
+
forms = typeof ctx.get === 'function' ? ctx.get('configForms') : undefined
|
|
1558
|
+
} catch (_error) {
|
|
1559
|
+
forms = undefined
|
|
1560
|
+
}
|
|
1561
|
+
if (!forms || typeof forms.get !== 'function') return undefined
|
|
1562
|
+
// entry id 在 cordis.patch.yml 里是 `progress-union`,包名是 `dsh-progress-union`,两个都试。
|
|
1563
|
+
for (const id of ['progress-union', 'dsh-progress-union']) {
|
|
1564
|
+
let scope
|
|
1565
|
+
try {
|
|
1566
|
+
scope = forms.get(id)
|
|
1567
|
+
} catch (_error) {
|
|
1568
|
+
scope = undefined
|
|
1569
|
+
}
|
|
1570
|
+
if (scope && typeof scope.getSnapshot === 'function' && typeof scope.subscribe === 'function' && typeof scope.set === 'function') return scope
|
|
1571
|
+
}
|
|
1572
|
+
return undefined
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
function SettingsRow(props) {
|
|
1576
|
+
return h(
|
|
1577
|
+
'label',
|
|
1578
|
+
{ className: 'pb-set-row' },
|
|
1579
|
+
h('span', { className: 'pb-set-label' }, props.label),
|
|
1580
|
+
h('span', { className: 'pb-set-control' }, props.children),
|
|
1581
|
+
props.hint ? h('span', { className: 'pb-set-hint' }, props.hint) : null,
|
|
1582
|
+
)
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
function SettingsGroup(props) {
|
|
1586
|
+
return h(
|
|
1587
|
+
'section',
|
|
1588
|
+
{ className: 'pb-set-group' },
|
|
1589
|
+
h('div', { className: 'pb-set-group-title' }, props.title),
|
|
1590
|
+
props.hint ? h('div', { className: 'pb-set-group-hint' }, props.hint) : null,
|
|
1591
|
+
props.children,
|
|
1592
|
+
)
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
function ProgressUnionSettings(props) {
|
|
1596
|
+
const t = makeT(props)
|
|
1597
|
+
const scope = props.scope
|
|
1598
|
+
const [snap, setSnap] = useState(null)
|
|
1599
|
+
const [status, setStatus] = useState('')
|
|
1600
|
+
useEffect(() => {
|
|
1601
|
+
if (!scope) return undefined
|
|
1602
|
+
let alive = true
|
|
1603
|
+
const read = () => {
|
|
1604
|
+
if (!alive) return
|
|
1605
|
+
try {
|
|
1606
|
+
setSnap(scope.getSnapshot())
|
|
1607
|
+
} catch (_error) {
|
|
1608
|
+
// 句柄随时会随 entry 重载重建;读失败就保持上一帧
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
read()
|
|
1612
|
+
let off
|
|
1613
|
+
try {
|
|
1614
|
+
off = scope.subscribe(read)
|
|
1615
|
+
} catch (_error) {
|
|
1616
|
+
off = undefined
|
|
1617
|
+
}
|
|
1618
|
+
return () => {
|
|
1619
|
+
alive = false
|
|
1620
|
+
if (typeof off === 'function') {
|
|
1621
|
+
try {
|
|
1622
|
+
off()
|
|
1623
|
+
} catch (_error) {
|
|
1624
|
+
// 卸载期失败无关紧要
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}, [scope])
|
|
1629
|
+
|
|
1630
|
+
const value = (snap && snap.value) || {}
|
|
1631
|
+
const writable = Boolean(scope) && (!snap || snap.writable !== false)
|
|
1632
|
+
const assistant = value.assistant && typeof value.assistant === 'object' ? value.assistant : {}
|
|
1633
|
+
const observer = value.observer && typeof value.observer === 'object' ? value.observer : {}
|
|
1634
|
+
|
|
1635
|
+
const write = async (field, next) => {
|
|
1636
|
+
if (!scope) {
|
|
1637
|
+
setStatus(t('setNoScope'))
|
|
1638
|
+
return
|
|
1639
|
+
}
|
|
1640
|
+
if (!writable) {
|
|
1641
|
+
setStatus(t('setReadOnly'))
|
|
1642
|
+
return
|
|
1643
|
+
}
|
|
1644
|
+
try {
|
|
1645
|
+
const ok = await scope.set(field, next)
|
|
1646
|
+
setStatus(ok === false ? t('setFailed') : t('setSaved'))
|
|
1647
|
+
} catch (_error) {
|
|
1648
|
+
setStatus(t('setFailed'))
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
const putAssistant = (key, v) => void write('assistant', { ...assistant, [key]: v })
|
|
1652
|
+
const putObserver = (key, v) => void write('observer', { ...observer, [key]: v })
|
|
1653
|
+
|
|
1654
|
+
const textOf = (v) => (v === undefined || v === null ? '' : String(v))
|
|
1655
|
+
const inputText = (v, onChange) => h('input', { type: 'text', value: textOf(v), onChange: (e) => onChange(e.target.value) })
|
|
1656
|
+
const inputSecret = (v, placeholder, onChange) => h('input', { type: 'password', value: textOf(v), placeholder, onChange: (e) => onChange(e.target.value) })
|
|
1657
|
+
const inputNum = (v, step, onChange) => h('input', { type: 'number', step, value: Number.isFinite(Number(v)) ? Number(v) : 0, onChange: (e) => onChange(Number(e.target.value)) })
|
|
1658
|
+
const inputBool = (v, fallback, onChange) => h('input', { type: 'checkbox', checked: v === undefined ? fallback : v !== false, onChange: (e) => onChange(e.target.checked) })
|
|
1659
|
+
const inputSelect = (v, options, onChange) =>
|
|
1660
|
+
h(
|
|
1661
|
+
'select',
|
|
1662
|
+
{ value: textOf(v), onChange: (e) => onChange(e.target.value) },
|
|
1663
|
+
options.map((opt) => h('option', { key: opt[0], value: opt[0] }, opt[1])),
|
|
1664
|
+
)
|
|
1665
|
+
|
|
1666
|
+
return h(
|
|
1667
|
+
'div',
|
|
1668
|
+
{ className: 'pb-set' },
|
|
1669
|
+
scope ? null : h('div', { className: 'pb-set-banner' }, t('setNoScope')),
|
|
1670
|
+
h(
|
|
1671
|
+
SettingsGroup,
|
|
1672
|
+
{ title: t('setLlmGroup'), hint: t('setLlmHint') },
|
|
1673
|
+
h(SettingsRow, { label: t('setMode') },
|
|
1674
|
+
inputSelect(assistant.mode || '', [['', t('setModeOff')], ['registered', t('setModeRegistered')], ['direct', t('setModeDirect')]], (v) => putAssistant('mode', v))),
|
|
1675
|
+
h(SettingsRow, { label: t('setProvider'), hint: t('setProviderHint') },
|
|
1676
|
+
inputText(assistant.provider || '', (v) => putAssistant('provider', v))),
|
|
1677
|
+
h(SettingsRow, { label: t('setModel') },
|
|
1678
|
+
inputText(assistant.model || '', (v) => putAssistant('model', v))),
|
|
1679
|
+
h(SettingsRow, { label: t('setBaseUrl') },
|
|
1680
|
+
inputText(assistant.baseUrl || '', (v) => putAssistant('baseUrl', v))),
|
|
1681
|
+
h(SettingsRow, { label: t('setApiKey'), hint: t('setApiKeyHint') },
|
|
1682
|
+
inputSecret('', assistant.hasApiKey ? '••••••' : '', (v) => putAssistant('apiKey', v))),
|
|
1683
|
+
h(SettingsRow, { label: t('setAuthority') },
|
|
1684
|
+
inputSelect(assistant.authority || 'both', [['both', t('setAuthorityBoth')], ['slots', t('setAuthoritySlots')], ['rounds', t('setAuthorityRounds')]], (v) => putAssistant('authority', v))),
|
|
1685
|
+
h(SettingsRow, { label: t('setInterval'), hint: t('setIntervalHint') },
|
|
1686
|
+
inputNum(assistant.minIntervalMs === undefined ? 90000 : assistant.minIntervalMs, 1000, (v) => putAssistant('minIntervalMs', v))),
|
|
1687
|
+
h(SettingsRow, { label: t('setAutoApply') },
|
|
1688
|
+
inputBool(assistant.autoApply, true, (v) => putAssistant('autoApply', v))),
|
|
1689
|
+
),
|
|
1690
|
+
h(
|
|
1691
|
+
SettingsGroup,
|
|
1692
|
+
{ title: t('setObserverGroup'), hint: t('setObserverHint') },
|
|
1693
|
+
h(SettingsRow, { label: t('setObserverEnabled') },
|
|
1694
|
+
inputBool(observer.enabled, true, (v) => putObserver('enabled', v))),
|
|
1695
|
+
h(SettingsRow, { label: t('setMaxIdleSteps') },
|
|
1696
|
+
inputNum(observer.maxIdleSteps === undefined ? 6 : observer.maxIdleSteps, 1, (v) => putObserver('maxIdleSteps', v))),
|
|
1697
|
+
h(SettingsRow, { label: t('setMaxIdleMs') },
|
|
1698
|
+
inputNum(observer.maxIdleMs === undefined ? 180000 : observer.maxIdleMs, 1000, (v) => putObserver('maxIdleMs', v))),
|
|
1699
|
+
h(SettingsRow, { label: t('setAutoSyncCurrent') },
|
|
1700
|
+
inputBool(observer.autoSyncCurrent, true, (v) => putObserver('autoSyncCurrent', v))),
|
|
1701
|
+
h(SettingsRow, { label: t('setAutoSyncThrottleMs') },
|
|
1702
|
+
inputNum(observer.autoSyncThrottleMs === undefined ? 60000 : observer.autoSyncThrottleMs, 1000, (v) => putObserver('autoSyncThrottleMs', v))),
|
|
1703
|
+
h(SettingsRow, { label: t('setMaxItems') },
|
|
1704
|
+
inputNum(observer.maxItems === undefined ? 12 : observer.maxItems, 1, (v) => putObserver('maxItems', v))),
|
|
1705
|
+
),
|
|
1706
|
+
h(
|
|
1707
|
+
SettingsGroup,
|
|
1708
|
+
{ title: t('setApiGroup'), hint: t('setApiHint') },
|
|
1709
|
+
h('div', { className: 'pb-set-api' },
|
|
1710
|
+
h('div', null, h('b', null, t('setApiService')), 'ctx.get(\'progressAnchor\').get(sessionId) / .list()'),
|
|
1711
|
+
h('div', null, h('b', null, t('setApiAnchor')), 'GET /progress-union/anchor?sessionId=<id>'),
|
|
1712
|
+
h('div', null, h('b', null, t('setApiSnapshot')), 'GET /progress-union/snapshot?sessionId=<id>'),
|
|
1713
|
+
h('div', null, h('b', null, t('setApiStatus')), 'GET /dsh-progress/status?sessionId=<id>'),
|
|
1714
|
+
),
|
|
1715
|
+
),
|
|
1716
|
+
status ? h('div', { className: 'pb-set-status' }, status) : null,
|
|
1717
|
+
)
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1460
1720
|
function ProgressSidePanel(props) {
|
|
1461
1721
|
const t = makeT(props)
|
|
1462
1722
|
const { sessionId } = props
|
|
@@ -2178,6 +2438,29 @@ window.__ModuleLoader__.load({
|
|
|
2178
2438
|
)
|
|
2179
2439
|
|
|
2180
2440
|
const t = ctx.locale.bind(NS)
|
|
2441
|
+
|
|
2442
|
+
// 独立设置分节:顶层 `settings.section`(与记忆/模型/插件并列)。
|
|
2443
|
+
// order 215 接在宿主内置分节之后;旧宿主没声明该槽时 inject 空转,
|
|
2444
|
+
// 面板与迷你条不受影响(不靠版本号判断,只靠槽位存在性)。
|
|
2445
|
+
const settingsScope = unionFormsScope(ctx)
|
|
2446
|
+
ctx.effect(
|
|
2447
|
+
() =>
|
|
2448
|
+
ctx.slots.inject('settings.section', () =>
|
|
2449
|
+
ctx.slots.register(
|
|
2450
|
+
{
|
|
2451
|
+
name: 'settings.section',
|
|
2452
|
+
id: 'dsh-progress-union',
|
|
2453
|
+
order: 215,
|
|
2454
|
+
locale: NS,
|
|
2455
|
+
label: () => t('setTitle'),
|
|
2456
|
+
inject: () => ({ scope: settingsScope }),
|
|
2457
|
+
},
|
|
2458
|
+
ProgressUnionSettings,
|
|
2459
|
+
),
|
|
2460
|
+
),
|
|
2461
|
+
'progress-union: settings section',
|
|
2462
|
+
)
|
|
2463
|
+
|
|
2181
2464
|
const wakeAgent = (sessionId, text) => {
|
|
2182
2465
|
try {
|
|
2183
2466
|
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.1.
|
|
3
|
+
"version": "0.1.9",
|
|
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.1.
|
|
3
|
+
"version": "0.1.9",
|
|
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,73 @@
|
|
|
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 且走 configForms 句柄', () => {
|
|
66
|
+
const file = new URL('../client.js', import.meta.url).pathname.replace(/^\//, '')
|
|
67
|
+
const src = fs.readFileSync(file, 'utf8')
|
|
68
|
+
assert.match(src, /name: 'settings\.section'/, '必须注册 settings.section 槽')
|
|
69
|
+
assert.match(src, /id: 'dsh-progress-union'/, '分节 id 必须固定')
|
|
70
|
+
assert.match(src, /configForms/, '必须经宿主 configForms 读写配置')
|
|
71
|
+
assert.match(src, /function ProgressUnionSettings\(/, '设置卡组件必须在')
|
|
72
|
+
assert.match(src, /scope\.subscribe/, '设置卡要订阅句柄快照')
|
|
73
|
+
})
|