dsh-progress-union 0.1.6 → 0.1.8
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 +77 -0
- package/README.md +25 -13
- package/client.js +14 -189
- package/dsh.plugin.json +1 -1
- package/index.js +51 -25
- package/package.json +9 -4
- package/test/anchor.test.mjs +139 -0
- package/test/assistant.test.mjs +215 -0
- package/test/client.test.mjs +54 -0
- package/test/e2e.test.mjs +77 -0
- package/test/goal.test.mjs +110 -0
- package/test/harness.mjs +210 -0
- package/test/host.test.mjs +184 -0
- package/test/observer.test.mjs +171 -0
- package/test/stats.test.mjs +54 -0
- package/test/time.test.mjs +147 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# 更新日志
|
|
2
|
+
|
|
3
|
+
本项目的所有值得记录的变更都写在这里。版本号遵循语义化版本。
|
|
4
|
+
|
|
5
|
+
## 0.1.8 (2026-11-26)
|
|
6
|
+
|
|
7
|
+
**修复:registered 通道写错 DSH LLM 契约;配置面搬回宿主设置页。**
|
|
8
|
+
|
|
9
|
+
- 事故:registered 模式把 system prompt 塞进 `messages[{role:'system'}]`、content 又传裸字符串,而 `llm.stream` 的 `GenerateOptions.system` 才是 adapter 映射到 provider system 槽的字段 → 请求实际没有 system,DeepSeek 回落到内置 “You are a helpful assistant.” 并把它当正文返回,`parseProposal` 失败只剩 `proposal-unparsable`(旧测试把 chunk 桩成 `{content}`,跟着一起错,没能拦住)。
|
|
10
|
+
- 修复:改为 `system: ASSISTANT_SYSTEM` + `messages: [{ role: 'user', content: [{ type: 'text', text }] }]`,chunk 只认 `type === 'text-delta'`,`finish.reason` 非 stop/max-tokens 直接报错,空正文报 `assistant-empty`;并透传 `signal`。
|
|
11
|
+
- 回归测试:锁定 system 必须在 `options.system`、`messages` 不得出现 `role:system`、content 必须是块数组。
|
|
12
|
+
- 设置面:`Config.assistant` 改为**逐叶子 `.volatile()`**(整对象标 volatile 不会生成字段表单——这就是「设置 → 插件」里看不到辅助 LLM 配置的原因);侧边栏不再放编辑表单,只留只读状态并指向设置页;新增「live ref 逐字段重读」测试。
|
|
13
|
+
|
|
14
|
+
> 说明:0.1.0 是真实构建产物;0.1.1–0.1.6 由 0.1.0 → 最终态的可核验 diff 按功能块「逻辑分化重建」,每一版都只包含该版本描述的能力,源码逐版可执行;0.1.7 是发布工程面。
|
|
15
|
+
|
|
16
|
+
## 0.1.7 (2026-11-26)
|
|
17
|
+
|
|
18
|
+
**发布工程面。**
|
|
19
|
+
|
|
20
|
+
- 仓库落地:`repository`/`homepage`/`bugs` 指向 GitHub,`publishConfig` 固定 npmjs + public + latest;
|
|
21
|
+
- `engines.dsh` 与 `dsh.plugin.json` 对齐(`>=0.2.0-0 <0.3.0-0`),双清单版本同值;
|
|
22
|
+
- 包内容纳入 `test/` 与 `CHANGELOG.md`;README 补安装面并移除"不发 npm"表述;
|
|
23
|
+
- 测试:47 用例全绿(`node --test test/*.test.mjs`);代码与 0.1.6 一致,无行为变更。
|
|
24
|
+
|
|
25
|
+
## 0.1.6 (2026-11-26)
|
|
26
|
+
|
|
27
|
+
**`/progress-goal` 命令面。**
|
|
28
|
+
|
|
29
|
+
- `status`/`budget <n>`/`edit <objective>`/`pause`/`resume`/`clear` 六个子命令,其余输入视为新目标;
|
|
30
|
+
- 命令只在宿主注册了 `commands` 服务时挂载,缺失则静默降级。
|
|
31
|
+
|
|
32
|
+
## 0.1.5 (2026-11-26)
|
|
33
|
+
|
|
34
|
+
**模型侧 `progress_goal_report` 工具。**
|
|
35
|
+
|
|
36
|
+
- 模型每轮末上报 `continue|complete|blocked`:`complete` 必须给证据且进度板已全 done;`blocked` 需具体 blocker 且连续 3 轮同因才落 phase;
|
|
37
|
+
- 助手草案只作建议,绝不自动调用此工具。
|
|
38
|
+
|
|
39
|
+
## 0.1.4 (2026-11-26)
|
|
40
|
+
|
|
41
|
+
**助手双通道 + 护栏 + 面板可编辑。**
|
|
42
|
+
|
|
43
|
+
- `registered` 走宿主 `llm.stream`(复用 Settings→模型里的 provider/model,免密钥);`direct` 走自建 OpenAI 兼容端点;
|
|
44
|
+
- `authority` 三档(slots/rounds/both)+`maxSlotChanges` 护栏:助手可增删改槽位、产出轮次草案,判断权仍归主模型;用户未确认改动优先(先 ack);
|
|
45
|
+
- 面板 `LlmAssistNotice` 升级为可展开编辑器(模式/提供方/模型/端点/密钥/权限/保存),配置写入 settings 命名空间即时生效。
|
|
46
|
+
|
|
47
|
+
## 0.1.3 (2026-11-26)
|
|
48
|
+
|
|
49
|
+
**续轮驱动器(重试)。**
|
|
50
|
+
|
|
51
|
+
- idle 时自动派发下一轮 `followup`,消息带自建 `source.kind`;`pre-step` 身份栅栏精确匹配 attempt/goalId/revision/round,不匹配直接 reject;
|
|
52
|
+
- 任何非本域消息进 inbox 视为用户抢占:标记 attempt stale 并暂停目标;
|
|
53
|
+
- 轮次草案随 followup 拼入,回合切换时清空,避免跨轮复用。
|
|
54
|
+
|
|
55
|
+
## 0.1.2 (2026-11-26)
|
|
56
|
+
|
|
57
|
+
**迷你目标域内核(自建,不复用官方 goals 域)。**
|
|
58
|
+
|
|
59
|
+
- `goal` 状态机(idle/active/paused/blocked/complete)+ 状态归一化 + 预算 `maxRounds`;
|
|
60
|
+
- create/edit/budget/pause/resume/clear 与 `goalView` 播报视图;快照回声新增 `goal` 字段;
|
|
61
|
+
- 助手提示词带上当前目标,观察者不再只看到板。
|
|
62
|
+
|
|
63
|
+
## 0.1.1 (2026-11-26)
|
|
64
|
+
|
|
65
|
+
**设置面。**
|
|
66
|
+
|
|
67
|
+
- 导出 `Config`(schemastery),progress-union 出现在「设置 → 插件」,客户端 `scopeOf('progress-union')` 可读写;
|
|
68
|
+
- 注入 `settings`/`llm`/`commands`;`.volatile()` 字段支持 live ref(带 `.get()`)解包,面板改了立即生效;
|
|
69
|
+
- `DEFAULT_CONFIG.assistant` 扩展(provider/authority/maxSlotChanges),配置回声按 settings 实时值输出。
|
|
70
|
+
|
|
71
|
+
## 0.1.0 (2026-11-25)
|
|
72
|
+
|
|
73
|
+
**首个原型。**
|
|
74
|
+
|
|
75
|
+
- board 槽位真相源(用户可编辑、revision/diff/ack 增量、staleness nudge);
|
|
76
|
+
- 鲸程时间引擎(step 计数、elapsed、ETA 四档 board > todo > local > prior);
|
|
77
|
+
- 只读三层进度锚点 `progressAnchor`(service + HTTP 双平面),供压缩类插件消费。
|
package/README.md
CHANGED
|
@@ -7,6 +7,15 @@
|
|
|
7
7
|
- [l3j3y3/dsh-progress-board](https://github.com/l3j3y3/dsh-progress-board) —— 用户可编辑实时进度板(槽位、revision/diff/ack、staleness nudge)
|
|
8
8
|
- [uuhihj/task-progress-bar](https://github.com/uuhihj/task-progress-bar)(鲸程 dsh-progress-widget)—— 事件时间引擎(steps/elapsed/ETA 学习链)
|
|
9
9
|
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm i dsh-progress-union # 走 npm 版本号
|
|
14
|
+
# 或本地开发:pnpm --dir <profile> add file:<repo>/dsh-progress-union-<ver>.tgz
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
装好后在 profile 的 `dsh.profile.bundles` 里挂上 `dsh-progress-union`,重启宿主加载;**所有配置面在「设置 → 插件 → dsh-progress-union」**(宿主按插件导出的 `Config` 逐叶子 `.volatile()` 自动生成表单,改完即生效、无需重启)。
|
|
18
|
+
|
|
10
19
|
## 它解决什么
|
|
11
20
|
|
|
12
21
|
长程任务被上下文压缩时最容易丢的是"我干到哪了"。本插件把这件事拆成两个正交数据面并统一出口:
|
|
@@ -109,33 +118,36 @@ observer:
|
|
|
109
118
|
|
|
110
119
|
## 辅助 LLM(审查/监视进度)
|
|
111
120
|
|
|
112
|
-
观察者默认是**规则版(零 LLM 费用)**。可选的辅助模型会把"清单 + 最近输出 + 最近动作 + 最近改动"
|
|
121
|
+
观察者默认是**规则版(零 LLM 费用)**。可选的辅助模型会把"清单 + 最近输出 + 最近动作 + 最近改动"交给一个小模型做审查:
|
|
122
|
+
|
|
123
|
+
**配置位置:设置 → 插件 → dsh-progress-union**(字段同下;也可在 profile 的 `cordis.patch.yml` 里写 `config:` 作部署面默认值)。
|
|
113
124
|
|
|
114
125
|
```yaml
|
|
115
126
|
assistant:
|
|
116
|
-
mode:
|
|
117
|
-
|
|
118
|
-
model: qwen2.5-3b #
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
mode: '' # '' 关(默认)| 'registered' | 'direct'
|
|
128
|
+
provider: local-35b # registered:Settings→模型 里的 provider 名(走宿主 llm.stream,免密钥)
|
|
129
|
+
model: qwen2.5-3b # registered/direct 共用的模型 id
|
|
130
|
+
baseUrl: http://127.0.0.1:8000/v1 # direct 专用
|
|
131
|
+
apiKey: '' # direct 专用;快照只回布尔 hasApiKey
|
|
132
|
+
authority: both # slots | rounds | both
|
|
121
133
|
minIntervalMs: 90000 # 两次审查的最小间隔
|
|
122
|
-
maxCallsPerTurn: 1 # 每回合至多一次
|
|
123
134
|
autoApply: true # false = 只记录建议不落地
|
|
124
135
|
```
|
|
125
136
|
|
|
137
|
+
- **两条通道**:`registered` 走宿主 `llm.stream`(复用 Settings→模型 里已配好的 provider/model,无需另存密钥;system prompt 走 `options.system`,输入走 `ContentBlock[]`);`direct` 直连自建 OpenAI 兼容端点;
|
|
126
138
|
- **触发**:板有未完成项,且主模型滞后(`maxIdleSteps`/`maxIdleMs` 超阈值)——与催办/自补同一时机,不额外打扰;
|
|
127
|
-
-
|
|
139
|
+
- **职责**:按 `authority` 可增删改槽位(≤8 条/次,用户未确认改动优先)并产出轮次草案(仅建议,判断权归主模型);每回合配额 + 最小间隔双节流;失败静默(`assistantError` 入观察块,不阻断板与主流程);
|
|
128
140
|
- **产出**:落地项 `updatedBy=assistant`;审查结论一行进观察块:`助手审查:<note>`;
|
|
129
|
-
-
|
|
130
|
-
-
|
|
141
|
+
- **端点建议**:`direct` 优先本地/局域网自建 OpenAI 兼容端点(Ollama、LM Studio、自建 llama.cpp、vLLM、SGLang、Strata、Ninfer 等);
|
|
142
|
+
- 侧边栏与全展开两个视图的**第一个内容块**只做只读状态展示(未启用/已启用 + 端点 + 频率)并指向设置页,**不再放编辑表单**——配置单挂在宿主设置面,避免两处写同一命名空间。
|
|
131
143
|
|
|
132
|
-
**为什么不做 host 通道**:union
|
|
144
|
+
**为什么不做 host 通道**:union 自身不直接持有宿主 chat 会话;`registered` 只借 `llm.stream` 一次性调用(不走主对话),`direct` 则完全不依赖宿主内部 API,两路都只拿回一段 JSON,不触碰会话历史。
|
|
133
145
|
|
|
134
146
|
## 明确不做
|
|
135
147
|
|
|
136
148
|
- 不修改上游两仓库;不改 dsh-prime-memory / dsh-spirit / dsh-brief-sidebar / dsh-context-compression-improved 的任何代码。
|
|
137
149
|
- `slotTrail` 恒为 `null`:prime-memory 关闭槽位 → L1 记忆的"后置清理扇出"仅有定性方案(见 `docs/`),字段为未来集成预留。
|
|
138
|
-
-
|
|
150
|
+
- 发布形态:npm 包 `dsh-progress-union` 自 0.1.0 起逐版打 tag 与 GitHub Release;宿主侧按 npm 版本号安装,不再依赖本地 tgz。
|
|
139
151
|
|
|
140
152
|
## docs/
|
|
141
153
|
|
|
@@ -146,5 +158,5 @@ assistant:
|
|
|
146
158
|
## 开发与测试
|
|
147
159
|
|
|
148
160
|
```bash
|
|
149
|
-
npm test # node --test test/*.test.mjs(
|
|
161
|
+
npm test # node --test test/*.test.mjs(48 用例,纯 mock ctx,无需宿主进程)
|
|
150
162
|
```
|
package/client.js
CHANGED
|
@@ -18,23 +18,8 @@ window.__ModuleLoader__.load({
|
|
|
18
18
|
window.dispatchEvent(new CustomEvent(PROGRESS_EVENT, { detail: { sessionId, snapshot } }))
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
// 辅助 LLM
|
|
22
|
-
//
|
|
23
|
-
let scopeOf = undefined
|
|
24
|
-
function installSettingsScope(ctx) {
|
|
25
|
-
const tryInject = (deps, pick) => {
|
|
26
|
-
try {
|
|
27
|
-
ctx.inject(deps, (scope) => {
|
|
28
|
-
const src = scope && pick(scope)
|
|
29
|
-
if (src === undefined) return
|
|
30
|
-
if (typeof src.bind === 'function') scopeOf = (ns) => src.bind({ namespace: ns })
|
|
31
|
-
else if (typeof src.get === 'function') scopeOf = (ns) => src.get(ns)
|
|
32
|
-
})
|
|
33
|
-
} catch (_err) {}
|
|
34
|
-
}
|
|
35
|
-
tryInject(['settingsScope'], (s) => s.settingsScope)
|
|
36
|
-
tryInject(['configForms'], (s) => s.configForms)
|
|
37
|
-
}
|
|
21
|
+
// 辅助 LLM 的配置面不在客户端:宿主设置页(设置 → 插件 → dsh-progress-union)
|
|
22
|
+
// 按插件导出的 Config 逐叶子 .volatile() 自动生成表单,本面板只做只读状态展示。
|
|
38
23
|
|
|
39
24
|
/*
|
|
40
25
|
* DeepSeek list prices in CNY per 1M tokens (api-docs.deepseek.com,
|
|
@@ -228,25 +213,8 @@ window.__ModuleLoader__.load({
|
|
|
228
213
|
llmOn: '已启用',
|
|
229
214
|
llmOff: '未启用:观察者为规则版(零 LLM 费用)。启用后由辅助模型管理任务槽位、产出续轮建议。',
|
|
230
215
|
llmAuto: ',自动落地',
|
|
231
|
-
llmHint: '
|
|
232
|
-
|
|
233
|
-
llmModeOff: '关闭',
|
|
234
|
-
llmModeRegistered: '已注册 provider',
|
|
235
|
-
llmModeDirect: '直连端点',
|
|
236
|
-
llmProvider: '提供方',
|
|
237
|
-
llmModel: '模型',
|
|
238
|
-
llmBaseUrl: '端点地址',
|
|
239
|
-
llmApiKey: 'API 密钥',
|
|
240
|
-
llmAuthority: '权限',
|
|
241
|
-
llmAuthoritySlots: '管理槽位',
|
|
242
|
-
llmAuthorityRounds: '轮次草案',
|
|
243
|
-
llmAuthorityBoth: '两者',
|
|
244
|
-
llmPickModel: '选择模型…',
|
|
245
|
-
llmNoProviders: 'Settings→模型 里没有已配置的 provider/model',
|
|
246
|
-
llmSave: '保存',
|
|
247
|
-
llmSaved: '已保存',
|
|
248
|
-
llmSaveFail: '保存失败',
|
|
249
|
-
llmResult: '结果',
|
|
216
|
+
llmHint: '配置在「设置 → 插件 → dsh-progress-union」:mode 选 registered 复用 Settings→模型 里的 provider/model(走宿主,免密钥),或 direct 直连自建 OpenAI 兼容端点。仅滞后时触发,每回合至多一次。助手可增删改槽位并产出轮次草案(仅供参考),判断权归主模型。',
|
|
217
|
+
llmSettingsHint: '在设置页修改',
|
|
250
218
|
etaLeft: '预计剩',
|
|
251
219
|
etaOver: '已超预估',
|
|
252
220
|
staleTag: '中断',
|
|
@@ -356,25 +324,8 @@ window.__ModuleLoader__.load({
|
|
|
356
324
|
llmOn: 'Enabled',
|
|
357
325
|
llmOff: 'Disabled: the observer is rule-based (zero LLM cost). When enabled, the assistant manages task slots and produces round suggestions.',
|
|
358
326
|
llmAuto: ', auto-applied',
|
|
359
|
-
llmHint: '
|
|
360
|
-
|
|
361
|
-
llmModeOff: 'Off',
|
|
362
|
-
llmModeRegistered: 'Registered provider',
|
|
363
|
-
llmModeDirect: 'Direct endpoint',
|
|
364
|
-
llmProvider: 'Provider',
|
|
365
|
-
llmModel: 'Model',
|
|
366
|
-
llmBaseUrl: 'Endpoint URL',
|
|
367
|
-
llmApiKey: 'API key',
|
|
368
|
-
llmAuthority: 'Authority',
|
|
369
|
-
llmAuthoritySlots: 'Manage slots',
|
|
370
|
-
llmAuthorityRounds: 'Round draft',
|
|
371
|
-
llmAuthorityBoth: 'Both',
|
|
372
|
-
llmPickModel: 'Pick a model…',
|
|
373
|
-
llmNoProviders: 'No configured provider/model under Settings → Models',
|
|
374
|
-
llmSave: 'Save',
|
|
375
|
-
llmSaved: 'Saved',
|
|
376
|
-
llmSaveFail: 'Save failed',
|
|
377
|
-
llmResult: 'Result',
|
|
327
|
+
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
|
+
llmSettingsHint: 'Change in Settings',
|
|
378
329
|
etaLeft: '~',
|
|
379
330
|
etaOver: 'over by',
|
|
380
331
|
staleTag: 'idle',
|
|
@@ -564,10 +515,6 @@ window.__ModuleLoader__.load({
|
|
|
564
515
|
.pb-llm-title { font-size: 12px; font-weight: 650; }
|
|
565
516
|
.pb-llm-line { margin-top: 4px; font-size: 12px; line-height: 1.5; }
|
|
566
517
|
.pb-llm-hint { margin-top: 4px; font-size: 11px; line-height: 1.5; opacity: .75; }
|
|
567
|
-
.pb-llm-editor { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(217,119,6,.25); display: grid; gap: 6px; }
|
|
568
|
-
.pb-llm-field { display: flex; align-items: center; gap: 8px; font-size: 11px; }
|
|
569
|
-
.pb-llm-field > span { flex: 0 0 72px; opacity: .8; }
|
|
570
|
-
.pb-llm-field select, .pb-llm-field input { flex: 1; min-width: 0; padding: 3px 6px; font-size: 11px; border: 1px solid rgba(128,128,128,.4); border-radius: 4px; background: transparent; color: inherit; }
|
|
571
518
|
.pb-header-btn {
|
|
572
519
|
display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
|
|
573
520
|
border: 1px solid transparent; border-radius: 6px; background: transparent;
|
|
@@ -1488,105 +1435,25 @@ window.__ModuleLoader__.load({
|
|
|
1488
1435
|
)
|
|
1489
1436
|
}
|
|
1490
1437
|
|
|
1438
|
+
// 只读状态行:配置面归宿主设置页(设置 → 插件 → dsh-progress-union),
|
|
1439
|
+
// 侧边栏不再放编辑表单(避免两处写同一命名空间)。
|
|
1491
1440
|
function LlmAssistNotice(props) {
|
|
1492
1441
|
const t = makeT(props)
|
|
1493
1442
|
const a = props.assistant
|
|
1494
|
-
const cfg = props.assistantCfg
|
|
1495
|
-
const [open, setOpen] = useState(false)
|
|
1496
|
-
const [mode, setMode] = useState((a && a.mode) || '')
|
|
1497
|
-
const [provider, setProvider] = useState((a && a.provider) || '')
|
|
1498
|
-
const [model, setModel] = useState((a && a.model) || '')
|
|
1499
|
-
const [baseUrl, setBaseUrl] = useState((a && a.baseUrl) || '')
|
|
1500
|
-
const [apiKey, setApiKey] = useState('')
|
|
1501
|
-
const [authority, setAuthority] = useState((a && a.authority) || 'both')
|
|
1502
|
-
const [status, setStatus] = useState('')
|
|
1503
1443
|
if (!a) return null
|
|
1504
1444
|
const on = a.enabled === true
|
|
1505
|
-
const
|
|
1506
|
-
const selectedProvider = providers.find((p) => p.name === provider)
|
|
1507
|
-
const models = selectedProvider ? selectedProvider.models : []
|
|
1508
|
-
|
|
1509
|
-
const save = async () => {
|
|
1510
|
-
if (!cfg || !cfg.available) { setStatus(t('llmSaveFail')); return }
|
|
1511
|
-
const patch = { mode, provider, model, baseUrl, authority, apiKey }
|
|
1512
|
-
try {
|
|
1513
|
-
await cfg.save(patch)
|
|
1514
|
-
setStatus(t('llmSaved'))
|
|
1515
|
-
if (apiKey) setApiKey('')
|
|
1516
|
-
} catch (_err) {
|
|
1517
|
-
setStatus(t('llmSaveFail'))
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
const select = (label, value, onChange, options) =>
|
|
1522
|
-
h(
|
|
1523
|
-
'label',
|
|
1524
|
-
{ className: 'pb-llm-field' },
|
|
1525
|
-
h('span', null, label),
|
|
1526
|
-
h(
|
|
1527
|
-
'select',
|
|
1528
|
-
{ value, onChange: (e) => onChange(e.target.value) },
|
|
1529
|
-
options.map((opt) => h('option', { key: opt.value, value: opt.value }, opt.label)),
|
|
1530
|
-
),
|
|
1531
|
-
)
|
|
1532
|
-
|
|
1445
|
+
const every = Math.max(1, Math.round((a.minIntervalMs || 0) / 60000))
|
|
1533
1446
|
const line = on
|
|
1534
1447
|
? (a.mode === 'registered'
|
|
1535
|
-
? `${t('llmOn')}:${a.provider} · ${a.model}(≤${
|
|
1536
|
-
: `${t('llmOn')}:${a.baseUrl} · ${a.model}(≤${
|
|
1448
|
+
? `${t('llmOn')}:${a.provider} · ${a.model}(≤${every} min/次${a.autoApply ? t('llmAuto') : ''})`
|
|
1449
|
+
: `${t('llmOn')}:${a.baseUrl} · ${a.model}(≤${every} min/次${a.autoApply ? t('llmAuto') : ''})`)
|
|
1537
1450
|
: t('llmOff')
|
|
1538
|
-
|
|
1539
1451
|
return h(
|
|
1540
1452
|
'div',
|
|
1541
1453
|
{ className: on ? 'pb-llm' : 'pb-llm pb-llm-off' },
|
|
1542
1454
|
h('div', { className: 'pb-llm-title' }, t('llmTitle')),
|
|
1543
1455
|
h('div', { className: 'pb-llm-line' }, line),
|
|
1544
1456
|
h('div', { className: 'pb-llm-hint' }, t('llmHint')),
|
|
1545
|
-
h('button', { type: 'button', className: 'pb-side-link', style: { marginTop: '4px' }, onClick: () => setOpen((v) => !v) }, open ? '▾' : '▸'),
|
|
1546
|
-
open
|
|
1547
|
-
? h(
|
|
1548
|
-
'div',
|
|
1549
|
-
{ className: 'pb-llm-editor' },
|
|
1550
|
-
select(t('llmMode'), mode, setMode, [
|
|
1551
|
-
{ value: '', label: t('llmModeOff') },
|
|
1552
|
-
{ value: 'registered', label: t('llmModeRegistered') },
|
|
1553
|
-
{ value: 'direct', label: t('llmModeDirect') },
|
|
1554
|
-
]),
|
|
1555
|
-
mode === 'registered'
|
|
1556
|
-
? h(
|
|
1557
|
-
'div',
|
|
1558
|
-
null,
|
|
1559
|
-
providers.length === 0
|
|
1560
|
-
? h('div', { className: 'pb-llm-hint' }, t('llmNoProviders'))
|
|
1561
|
-
: select(t('llmProvider'), provider, (v) => { setProvider(v); setModel('') }, [
|
|
1562
|
-
{ value: '', label: t('llmPickModel') },
|
|
1563
|
-
...providers.map((p) => ({ value: p.name, label: p.name })),
|
|
1564
|
-
]),
|
|
1565
|
-
models.length > 0
|
|
1566
|
-
? select(t('llmModel'), model, setModel, [
|
|
1567
|
-
{ value: '', label: t('llmPickModel') },
|
|
1568
|
-
...models.map((m) => ({ value: m, label: m })),
|
|
1569
|
-
])
|
|
1570
|
-
: null,
|
|
1571
|
-
)
|
|
1572
|
-
: mode === 'direct'
|
|
1573
|
-
? h(
|
|
1574
|
-
'div',
|
|
1575
|
-
null,
|
|
1576
|
-
h('label', { className: 'pb-llm-field' }, h('span', null, t('llmBaseUrl')), h('input', { type: 'text', value: baseUrl, onChange: (e) => setBaseUrl(e.target.value) })),
|
|
1577
|
-
h('label', { className: 'pb-llm-field' }, h('span', null, t('llmModel')), h('input', { type: 'text', value: model, onChange: (e) => setModel(e.target.value) })),
|
|
1578
|
-
h('label', { className: 'pb-llm-field' }, h('span', null, t('llmApiKey')), h('input', { type: 'password', value: apiKey, placeholder: a.hasApiKey ? '••••••' : '', onChange: (e) => setApiKey(e.target.value) })),
|
|
1579
|
-
)
|
|
1580
|
-
: null,
|
|
1581
|
-
select(t('llmAuthority'), authority, setAuthority, [
|
|
1582
|
-
{ value: 'both', label: t('llmAuthorityBoth') },
|
|
1583
|
-
{ value: 'slots', label: t('llmAuthoritySlots') },
|
|
1584
|
-
{ value: 'rounds', label: t('llmAuthorityRounds') },
|
|
1585
|
-
]),
|
|
1586
|
-
h('button', { type: 'button', className: 'pb-btn pb-btn-primary', style: { marginTop: '6px' }, onClick: () => void save() }, t('llmSave')),
|
|
1587
|
-
status ? h('span', { className: 'pb-llm-hint', style: { marginLeft: '8px' } }, status) : null,
|
|
1588
|
-
)
|
|
1589
|
-
: null,
|
|
1590
1457
|
)
|
|
1591
1458
|
}
|
|
1592
1459
|
|
|
@@ -1743,7 +1610,7 @@ window.__ModuleLoader__.load({
|
|
|
1743
1610
|
),
|
|
1744
1611
|
),
|
|
1745
1612
|
readError ? h('div', { className: 'pb-side-error' }, `${t('readError')}${readError}`) : null,
|
|
1746
|
-
h(LlmAssistNotice, { assistant: snapshot?.assistant, t: props.t
|
|
1613
|
+
h(LlmAssistNotice, { assistant: snapshot?.assistant, t: props.t }),
|
|
1747
1614
|
actionError ? h('div', { className: 'pb-side-error' }, `${t('saveError')}${actionError}`) : null,
|
|
1748
1615
|
usageView
|
|
1749
1616
|
? h(
|
|
@@ -2163,7 +2030,7 @@ window.__ModuleLoader__.load({
|
|
|
2163
2030
|
),
|
|
2164
2031
|
),
|
|
2165
2032
|
),
|
|
2166
|
-
h(LlmAssistNotice, { assistant: snapshot?.assistant, t: props.t
|
|
2033
|
+
h(LlmAssistNotice, { assistant: snapshot?.assistant, t: props.t }),
|
|
2167
2034
|
snapshot?.enabled === false
|
|
2168
2035
|
? h(
|
|
2169
2036
|
'div',
|
|
@@ -2301,7 +2168,6 @@ window.__ModuleLoader__.load({
|
|
|
2301
2168
|
return {
|
|
2302
2169
|
inject: ['slots', 'locale', 'layout', 'sidebarRight', 'sidebarRightTabs', 'sessions'],
|
|
2303
2170
|
apply(ctx) {
|
|
2304
|
-
installSettingsScope(ctx)
|
|
2305
2171
|
ctx.effect(
|
|
2306
2172
|
() =>
|
|
2307
2173
|
ctx.locale.register(NS, {
|
|
@@ -2312,46 +2178,6 @@ window.__ModuleLoader__.load({
|
|
|
2312
2178
|
)
|
|
2313
2179
|
|
|
2314
2180
|
const t = ctx.locale.bind(NS)
|
|
2315
|
-
// 辅助 LLM 配置读写面:面板用它在 settings 里改 assistant(运行时生效,无需重启)。
|
|
2316
|
-
const assistantCfg = {
|
|
2317
|
-
available: () => Boolean(scopeOf),
|
|
2318
|
-
// llm-pi-ai 里的 provider/model 列表(供下拉)
|
|
2319
|
-
providers() {
|
|
2320
|
-
if (!scopeOf) return []
|
|
2321
|
-
try {
|
|
2322
|
-
const scope = scopeOf('llm-pi-ai')
|
|
2323
|
-
const snap = scope && typeof scope.getSnapshot === 'function' ? scope.getSnapshot() : null
|
|
2324
|
-
const value = snap && (snap.value !== undefined ? snap.value : snap)
|
|
2325
|
-
const providers = value && Array.isArray(value.providers) ? value.providers : []
|
|
2326
|
-
return providers.map((p) => ({
|
|
2327
|
-
name: String(p && (p.name || p.id || p.provider) || ''),
|
|
2328
|
-
models: Array.isArray(p && p.models)
|
|
2329
|
-
? p.models.map((m) => String((m && (m.id || m.name)) || '')).filter(Boolean)
|
|
2330
|
-
: [],
|
|
2331
|
-
})).filter((p) => p.name)
|
|
2332
|
-
} catch (_err) {
|
|
2333
|
-
return []
|
|
2334
|
-
}
|
|
2335
|
-
},
|
|
2336
|
-
// progress-union settings 里当前的 assistant 配置
|
|
2337
|
-
current() {
|
|
2338
|
-
if (!scopeOf) return null
|
|
2339
|
-
try {
|
|
2340
|
-
const scope = scopeOf('progress-union')
|
|
2341
|
-
const snap = scope && typeof scope.getSnapshot === 'function' ? scope.getSnapshot() : null
|
|
2342
|
-
const value = snap && (snap.value !== undefined ? snap.value : snap)
|
|
2343
|
-
return value && typeof value === 'object' && value.assistant ? value.assistant : null
|
|
2344
|
-
} catch (_err) {
|
|
2345
|
-
return null
|
|
2346
|
-
}
|
|
2347
|
-
},
|
|
2348
|
-
async save(patch) {
|
|
2349
|
-
if (!scopeOf) throw new Error('settings unavailable')
|
|
2350
|
-
const scope = scopeOf('progress-union')
|
|
2351
|
-
if (!scope || typeof scope.set !== 'function') throw new Error('scope.set unavailable')
|
|
2352
|
-
await scope.set('assistant', patch)
|
|
2353
|
-
},
|
|
2354
|
-
}
|
|
2355
2181
|
const wakeAgent = (sessionId, text) => {
|
|
2356
2182
|
try {
|
|
2357
2183
|
const binding = ctx.sessions.binding(sessionId)
|
|
@@ -2448,7 +2274,6 @@ window.__ModuleLoader__.load({
|
|
|
2448
2274
|
openFullPanel,
|
|
2449
2275
|
wakeAgent,
|
|
2450
2276
|
usage: usageApi,
|
|
2451
|
-
assistantCfg,
|
|
2452
2277
|
}),
|
|
2453
2278
|
},
|
|
2454
2279
|
ProgressSidePanel,
|
|
@@ -2465,7 +2290,7 @@ window.__ModuleLoader__.load({
|
|
|
2465
2290
|
name: 'main',
|
|
2466
2291
|
key: PANEL_ID,
|
|
2467
2292
|
locale: NS,
|
|
2468
|
-
inject: () => ({ wakeAgent, usage: usageApi
|
|
2293
|
+
inject: () => ({ wakeAgent, usage: usageApi }),
|
|
2469
2294
|
},
|
|
2470
2295
|
ProgressPanel,
|
|
2471
2296
|
),
|
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.8",
|
|
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
|
@@ -21,20 +21,21 @@ import os from 'node:os'
|
|
|
21
21
|
import path from 'node:path'
|
|
22
22
|
import z from '@deepseek-ai/schemastery'
|
|
23
23
|
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
24
|
+
// 设置页可见性:0.1.7+ 宿主把 composition entry 当设置节,直接按导出的 Config
|
|
25
|
+
// **逐叶子**的 .volatile() 标记生成「设置 → 插件」里的表单,并把 volatile 字段以
|
|
26
|
+
// live ref(带 .get())注入 apply。整对象套一层 .volatile() 不生成字段表单(面板
|
|
27
|
+
// 只会空空如也),所以必须每个叶子单独标——与 dsh-llm-openai-completions 同式。
|
|
27
28
|
export const Config = z.object({
|
|
28
29
|
assistant: z.object({
|
|
29
|
-
mode: z.union(['', 'registered', 'direct']).default(''),
|
|
30
|
-
provider: z.string().default(''),
|
|
31
|
-
model: z.string().default(''),
|
|
32
|
-
baseUrl: z.string().default(''),
|
|
33
|
-
apiKey: z.string().role('secret').default(''),
|
|
34
|
-
authority: z.union(['slots', 'rounds', 'both']).default('both'),
|
|
35
|
-
minIntervalMs: z.number().step(1000).min(0).default(90000),
|
|
36
|
-
autoApply: z.boolean().default(true),
|
|
37
|
-
}).default({})
|
|
30
|
+
mode: z.union(['', 'registered', 'direct']).default('').volatile(),
|
|
31
|
+
provider: z.string().default('').volatile(),
|
|
32
|
+
model: z.string().default('').volatile(),
|
|
33
|
+
baseUrl: z.string().default('').volatile(),
|
|
34
|
+
apiKey: z.string().role('secret').default('').volatile(),
|
|
35
|
+
authority: z.union(['slots', 'rounds', 'both']).default('both').volatile(),
|
|
36
|
+
minIntervalMs: z.number().step(1000).min(0).default(90000).volatile(),
|
|
37
|
+
autoApply: z.boolean().default(true).volatile(),
|
|
38
|
+
}).default({}),
|
|
38
39
|
})
|
|
39
40
|
|
|
40
41
|
// —— 路由与存储标识 ——
|
|
@@ -518,21 +519,37 @@ const DEFAULT_CONFIG = {
|
|
|
518
519
|
}
|
|
519
520
|
|
|
520
521
|
// .volatile() 字段在 0.1.7+ 宿主以 live ref(带 .get())传入,旧宿主为普通值。
|
|
521
|
-
function
|
|
522
|
+
function unwrapLive(value) {
|
|
522
523
|
if (value !== null && typeof value === 'object' && typeof value.get === 'function') {
|
|
523
524
|
const snap = value.get()
|
|
524
|
-
return snap === undefined ?
|
|
525
|
+
return snap === undefined ? undefined : snap
|
|
525
526
|
}
|
|
526
|
-
return value
|
|
527
|
+
return value === undefined || value === null ? undefined : value
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function readVolatile(value, fallback) {
|
|
531
|
+
const v = unwrapLive(value)
|
|
532
|
+
return v === undefined ? fallback : v
|
|
527
533
|
}
|
|
528
534
|
|
|
529
535
|
export async function apply(ctx, config) {
|
|
530
536
|
const cfg = Object.assign({}, DEFAULT_CONFIG, config && typeof config === 'object' ? config : {})
|
|
531
537
|
cfg.observer = Object.assign({}, DEFAULT_CONFIG.observer, cfg.observer && typeof cfg.observer === 'object' ? cfg.observer : {})
|
|
532
|
-
// assistant
|
|
538
|
+
// assistant 的每个字段都是 volatile:保留原始 ref(整对象或逐叶子皆可),
|
|
539
|
+
// 每次读取时解包,设置页改完下一次审查即生效,无需重启。
|
|
533
540
|
const assistantRaw = config && typeof config === 'object' ? config.assistant : undefined
|
|
534
|
-
|
|
535
|
-
|
|
541
|
+
function assistantNow() {
|
|
542
|
+
const base = DEFAULT_CONFIG.assistant
|
|
543
|
+
const raw = unwrapLive(assistantRaw)
|
|
544
|
+
if (!isObject(raw)) return { ...base }
|
|
545
|
+
const out = { ...base }
|
|
546
|
+
for (const key of Object.keys(base)) {
|
|
547
|
+
const v = unwrapLive(raw[key])
|
|
548
|
+
if (v !== undefined) out[key] = v
|
|
549
|
+
}
|
|
550
|
+
return out
|
|
551
|
+
}
|
|
552
|
+
cfg.assistant = assistantNow()
|
|
536
553
|
const now = () => Date.now()
|
|
537
554
|
|
|
538
555
|
// —— 状态容器 ——
|
|
@@ -575,11 +592,12 @@ export async function apply(ctx, config) {
|
|
|
575
592
|
} catch (_err) {}
|
|
576
593
|
return undefined
|
|
577
594
|
}
|
|
578
|
-
//
|
|
595
|
+
// 运行时配置:设置页(volatile live ref)优先,settings 命名空间作补充覆盖。
|
|
579
596
|
function liveAssistant() {
|
|
597
|
+
const current = assistantNow()
|
|
580
598
|
const section = readAssistantSection()
|
|
581
599
|
const fromSettings = section && isObject(section.value) && isObject(section.value.assistant) ? section.value.assistant : undefined
|
|
582
|
-
return fromSettings ? { ...
|
|
600
|
+
return fromSettings ? { ...current, ...fromSettings } : current
|
|
583
601
|
}
|
|
584
602
|
|
|
585
603
|
// ==========================================================================
|
|
@@ -1478,18 +1496,26 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
|
|
|
1478
1496
|
try {
|
|
1479
1497
|
let raw = ''
|
|
1480
1498
|
if (a.mode === 'registered') {
|
|
1481
|
-
//
|
|
1499
|
+
// 应主 llm.stream 契约:system 必须走 options.system(adapter 才把它映射到
|
|
1500
|
+
// provider 的 system 槽);写进 messages 的 role:'system' 会被忽略 → 请求实际
|
|
1501
|
+
// 没有 system,DeepSeek 回落到内置 "You are a helpful assistant." 并把它当正文
|
|
1502
|
+
// 吐回来。content 也必须是 ContentBlock[](块数组)而非裸字符串。
|
|
1503
|
+
// 参考 dsh-media-lens/src/providers/registered.ts 的调用形状。
|
|
1482
1504
|
const stream = llm.stream({
|
|
1483
1505
|
provider: String(a.provider),
|
|
1484
1506
|
model: String(a.model),
|
|
1485
|
-
|
|
1507
|
+
system: ASSISTANT_SYSTEM,
|
|
1508
|
+
messages: [{ role: 'user', content: [{ type: 'text', text: lines.join('\n') }] }],
|
|
1509
|
+
signal: controller.signal,
|
|
1486
1510
|
})
|
|
1487
1511
|
for await (const chunk of stream) {
|
|
1488
|
-
if (chunk && typeof chunk.content === 'string') raw += chunk.content
|
|
1489
|
-
else if (chunk && typeof chunk.text === 'string') raw += chunk.text
|
|
1490
|
-
else if (chunk && chunk.delta && typeof chunk.delta === 'string') raw += chunk.delta
|
|
1491
1512
|
if (controller.signal.aborted) break
|
|
1513
|
+
if (chunk && chunk.type === 'text-delta' && typeof chunk.text === 'string') raw += chunk.text
|
|
1514
|
+
else if (chunk && chunk.type === 'finish' && chunk.reason && chunk.reason.kind !== 'stop' && chunk.reason.kind !== 'max-tokens') {
|
|
1515
|
+
throw new Error(`assistant finish: ${chunk.reason.kind}`)
|
|
1516
|
+
}
|
|
1492
1517
|
}
|
|
1518
|
+
if (raw.trim() === '') throw new Error('assistant-empty')
|
|
1493
1519
|
} else {
|
|
1494
1520
|
const base = String(a.baseUrl || '').replace(/\/+$/, '')
|
|
1495
1521
|
const response = await fetch(`${base}/chat/completions`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-progress-union",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
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",
|
|
@@ -27,13 +27,16 @@
|
|
|
27
27
|
"cordis.patch.yml",
|
|
28
28
|
"dsh.plugin.json",
|
|
29
29
|
"icon.svg",
|
|
30
|
-
"docs/"
|
|
30
|
+
"docs/",
|
|
31
|
+
"test/",
|
|
32
|
+
"CHANGELOG.md"
|
|
31
33
|
],
|
|
32
34
|
"scripts": {
|
|
33
35
|
"test": "node --test test/*.test.mjs"
|
|
34
36
|
},
|
|
35
37
|
"engines": {
|
|
36
|
-
"node": ">=22.19.0"
|
|
38
|
+
"node": ">=22.19.0",
|
|
39
|
+
"dsh": ">=0.2.0-0 <0.3.0-0"
|
|
37
40
|
},
|
|
38
41
|
"dsh": {
|
|
39
42
|
"bundle": {
|
|
@@ -57,7 +60,9 @@
|
|
|
57
60
|
"dsh-plugin",
|
|
58
61
|
"progress-board",
|
|
59
62
|
"progress-anchor",
|
|
60
|
-
"compaction"
|
|
63
|
+
"compaction",
|
|
64
|
+
"progress-tracking",
|
|
65
|
+
"eta"
|
|
61
66
|
],
|
|
62
67
|
"repository": {
|
|
63
68
|
"type": "git",
|