dsh-progress-union 0.7.1 → 0.7.3
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 +5 -1
- package/client.js +10 -1
- package/dsh.plugin.json +1 -1
- package/index.js +70 -7
- package/package.json +1 -1
- package/test/client.test.mjs +8 -0
- package/test/download-classify.test.mjs +52 -0
- package/test/ops.test.mjs +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
本项目的所有值得记录的变更都写在这里。版本号遵循语义化版本。
|
|
4
4
|
|
|
5
|
+
## 0.7.3 (2026-12-04)
|
|
6
|
+
|
|
7
|
+
**fix(download):Windows 宿主上 `curl.exe` / `Invoke-WebRequest` / `pwsh -Command "…"` 全漏识别,下载子条根本不出来。**
|
|
8
|
+
|
|
9
|
+
真机回灌(沙箱宿主 0.2.2-rc.5 + dsh-progress-union 0.7.2):让模型跑 `mkdir -p dl072 && curl -L -o dl072/node.tar.gz https://…`,整个回合里 `snapshot.download` 恒为 idle、`.pb-dock-dl` 一次都没渲染(DOM 探针 20+ 次全为 `NO-SUBBAR`,后台轮询 0 样本)。查下来不是网络问题(curl 因 SChannel `SEC_E_NO_CREDENTIALS` 零字节退出),而是 **分类器只认 POSIX 首词**:DSH 的 Bash 工具在 Windows 上实落 pwsh,命令名带 `.exe` 后缀与路径前缀,首词比对永远对不上。
|
|
10
|
+
|
|
11
|
+
- **首词归一**:新增 `normalizeHead()`——剥引号、取 basename(`\\` 与 `/` 都给)、去 `.exe/.cmd/.bat/.ps1` 后缀。`headWord()` 与三处 `findIndex(w => w.toLowerCase() === head)`(classifyDownload / glossCommand)统一改用它。于是 `C:\Windows\System32\curl.exe -O …`、`/mingw64/bin/git.exe clone …`、`WGET.EXE -q …` 均能识别。
|
|
12
|
+
- **shell 包层拆引号体**:新增 `wrapperSegments()`(`pwsh|powershell|sh|bash|zsh|dash|cmd|wsl` + `-Command|-c|/c|-file` 后的引号体再切一段,只拆一层不递归),并入 `classifyDownload` 的逐段循环。`pwsh -Command "curl.exe -L -o out.bin …"` 不再因为外层首词是 `pwsh` 而整条静默。
|
|
13
|
+
- **PowerShell 自有下载词入表**:`DOWNLOADERS` 补 `invoke-webrequest / iwr / invoke-restmethod / irm / start-bitstransfer`;`firstOperand` 的输出型 flag 扩到 `-OutFile / -FilePath / -Destination / -Uri` 等(`iwr URL -OutFile a.txt` 目标取 URL 末段,`iwr -Uri URL -OutFile big.iso` 目标取文件名)。
|
|
14
|
+
- **工序可解释同步**:`HEAD_GLOSS` 补 `invoke-webrequest/iwr → 下载文件`、`invoke-restmethod/irm → 发 HTTP 请求`、`start-bitstransfer → 传输文件`、`new-item → 建目录或文件`、`set-variable → 设环境变量`、`test-path → 查路径`,避免 Windows 会话里「最近动作」退回 `Bash×n`。
|
|
15
|
+
- **不误判**:新增反例用例 — `pwsh -Command "Get-Process | …"`、`git.exe status --short`、`New-Item -ItemType Directory out` 仍必须返回 `null`(软感知只认词表,不做语义猜)。POSIX 旧用例零修改全绿。
|
|
16
|
+
- **测试**:`test/download-classify.test.mjs` +5 用例(共 19),`npm test` **239 pass / 0 fail**(234 → +5),零回归。
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## 0.7.2 (2026-12-04)
|
|
20
|
+
|
|
21
|
+
**feat(ops):侧边栏 LLM 任务操作面补上整块开关 `ops.enabled`,关掉后不枚举宿主、不发 token、面板整块收起。**
|
|
22
|
+
|
|
23
|
+
- **配置面**:`Config` 新增 `ops: z.object({ enabled: z.boolean().default(true).volatile() }).default({})`,与 `download` / `toolGloss` 同构。三处同步齐全(schema 叶子 `.volatile()` + `DEFAULT_CONFIG.ops = { enabled: true }` + `apply()` 里 `flatSection('ops', DEFAULT_CONFIG.ops)` 解包),所以设置页改完立即热生效,老 profile 零迁移。
|
|
24
|
+
- **`GET /ops/providers`**:`ops.enabled !== true` 时早退,直接报 `{ok:true, disabled:true, providers:[], default:{provider:'',model:''}, configured:{…}}`,且**不再打宿主 `llm.listProviders()`**(省一次宿主调用)。正常路径新增显式 `disabled:false`,让客户端区分「没配服务」和「整块关了」两种空下拉。
|
|
25
|
+
- **`POST /ops`**:新增 `forbidden()`(`error.statusCode = 403`),门只卡在三个花 token 的动作上 —— `refine` / `mutate` / `ask` 一律 403 并回可读文案;`validate` 是纯本地零 token 的板面体检,照常 200,不因开关被封。
|
|
26
|
+
- **客户端**:`fetchOpsProviders()` 透出 `disabled`;`LlmOpsBlock` 新增 `off` 状态,在全部 hooks 之后 `if (off) return null` 整块不渲染(而不是摆一排点了就报错的按钮,也不是给一个空白下拉)。
|
|
27
|
+
- **默认模型口径不变**:仍只走 `assistant.*` 与宿主 `agentDefaultModel.currentSelection()`,本开关不提供 `defaultProvider/defaultModel` 覆盖 —— 计划里的这两个字段由宿主模型选择器承担,避免插件里长出第二套模型配置面(与 rc.3 已实现的 providers 逻辑一致,属口径收敛而非删功能)。
|
|
28
|
+
- **测试**:`test/ops.test.mjs` 新增开关用例(providers 报 `disabled:true` 且 `listProviders` 调用数为 0、三动作 403、validate 200)并在原 providers 用例补 `disabled===false`;`test/client.test.mjs` 补 disabled 透出 / `setOff` 早退 / hook 顺序断言。`npm test` **234 pass / 0 fail**,零回归。
|
|
29
|
+
|
|
30
|
+
|
|
5
31
|
## 0.7.1 (2026-12-04)
|
|
6
32
|
|
|
7
33
|
**fix(ops):同回合被合并的重大变更也要告知客户端,否则面板 wake 与 R4 提醒还是会在队列里各留一条。**
|
package/README.md
CHANGED
|
@@ -268,7 +268,7 @@ assistant:
|
|
|
268
268
|
## 开发与测试
|
|
269
269
|
|
|
270
270
|
```bash
|
|
271
|
-
npm test # node --test test/*.test.mjs(
|
|
271
|
+
npm test # node --test test/*.test.mjs(239 用例,纯 mock ctx,无需宿主进程)
|
|
272
272
|
```
|
|
273
273
|
|
|
274
274
|
## 冷启动接续(v0.6.2)
|
|
@@ -291,6 +291,8 @@ npm test # node --test test/*.test.mjs(233 用例,纯 mock ctx,无需宿
|
|
|
291
291
|
|
|
292
292
|
识别结果进两条出口:观察块多一行下载事实(动作 · 目标 · 已下字节 · 耗时 · 真值来源),以及 `snapshot.download`(供客户端子条)。配置 `download.enabled=false` 整条链路关闭,`snapshot` 少一个字段,UI 逐字退回 0.6.x。
|
|
293
293
|
|
|
294
|
+
**Windows 宿主形状(v0.7.3)**:DSH 的 Bash 工具在 Windows 上实落 pwsh,命令名常带 `.exe` 后缀与路径前缀,真下载还常被裹在 `pwsh -Command "…"` 的引号体里。分类器因此做三件事:首词先过 `normalizeHead`(剥引号 → 取 basename → 去 `.exe/.cmd/.bat/.ps1`),shell 包层的引号体额外再切一段(只拆一层),下载器词表补 PowerShell 自有的 `Invoke-WebRequest/iwr/Invoke-RestMethod/irm/Start-BitsTransfer`。反例仍然拦得住:`git.exe status`、`New-Item -ItemType Directory`、`pwsh -Command "Get-Process …"` 依旧返回 `null`。
|
|
295
|
+
|
|
294
296
|
## 下载子进度条(v0.7.0)
|
|
295
297
|
|
|
296
298
|
输入框上方的迷你条在主条行之后渲染一行子条,真值全部来自本插件自解析 `tool/result`(`parseProgress` 覆盖 wget/curl 的 `45%` 与 `12.3MB/27.8MB`、pip/uv 单尾单位、git `Receiving objects: 62%`、pnpm `[3/12]`),**零跨插件依赖**。
|
|
@@ -308,6 +310,8 @@ npm test # node --test test/*.test.mjs(233 用例,纯 mock ctx,无需宿
|
|
|
308
310
|
|
|
309
311
|
选模型口径同 prime-memory:`GET /ops/providers` 读宿主 `llm.listProviders()` 与默认模型选择,宿主没给服务时退回设置页里的 `assistant.provider/model`(下拉显示「沿用设置页」),不报错。落盘走同一条 `callAssistant → parseProposal → applyChanges(origin:'ops')` 通道:改动截 8 条、未知 id 与空 title 丢弃、模型答非 JSON 返 502 且**板 revision 不动**、未配置模型返 400。`origin:'ops'` 不算「主模型刚刚同过步」,催办计时不被侧边栏操作抹平。
|
|
310
312
|
|
|
313
|
+
**整块开关 `ops.enabled`(v0.7.2,默认开)**:关掉后 `GET /ops/providers` 直接报 `disabled:true` 且**不再打宿主 `listProviders`**,客户端据此把「LLM 操作」块整块收起(不是一堆禁用按钮,也不是报错);`POST /ops` 的 refine / mutate / ask 一律 **403**,唯独 `validate` 照常 200 —— 它是零 token 的本地板面体检,与花不花钱无关。该键与 `download.*` / `toolGloss.*` 同级:逐叶子 `.volatile()`、`DEFAULT_CONFIG.ops`、`flatSection('ops', …)` 三处齐全,设置页改完即生效,老 profile 零迁移。默认模型仍只走 `assistant.*` 与宿主当前选择,本开关不提供 `defaultProvider/defaultModel` 覆盖(计划里的那两个字段由宿主选择器承担,避免第二套模型配置面)。
|
|
314
|
+
|
|
311
315
|
## 重大变更落输入队列(v0.7.0)
|
|
312
316
|
|
|
313
317
|
用户在面板直接改板(或经侧边栏 LLM 操作改板)导致**结构性**变化(add / remove / `order`)时,插件把这件事递到模型的收件队列,而不是等下一次审查才发现板变了:
|
package/client.js
CHANGED
|
@@ -24,7 +24,7 @@ window.__ModuleLoader__.load({
|
|
|
24
24
|
var REPO_URL = "https://github.com/drscrewdriver/dsh-progress-union";
|
|
25
25
|
var STAR_NS = "progress-union";
|
|
26
26
|
var STAR_GEN = "v4"; /* ladder:gen */
|
|
27
|
-
var STAR_VERSION = "0.7.
|
|
27
|
+
var STAR_VERSION = "0.7.3"; /* ladder:ver */
|
|
28
28
|
var LANGS = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es", "pt"];
|
|
29
29
|
|
|
30
30
|
// 三代共享:GitHub 单色 mark(octicon 轮廓,fill 随 currentColor)。
|
|
@@ -1599,6 +1599,8 @@ window.__ModuleLoader__.load({
|
|
|
1599
1599
|
return {
|
|
1600
1600
|
providers: body && Array.isArray(body.providers) ? body.providers : [],
|
|
1601
1601
|
default: body && body.default ? body.default : null,
|
|
1602
|
+
// 宿主侧 ops.enabled=false 时的整块开关信号(旧版回执没这个字段 = 未关)。
|
|
1603
|
+
disabled: !!(body && body.disabled === true),
|
|
1602
1604
|
}
|
|
1603
1605
|
}
|
|
1604
1606
|
|
|
@@ -1632,12 +1634,17 @@ window.__ModuleLoader__.load({
|
|
|
1632
1634
|
const [question, setQuestion] = useState('')
|
|
1633
1635
|
const [busy, setBusy] = useState('')
|
|
1634
1636
|
const [out, setOut] = useState(null)
|
|
1637
|
+
const [off, setOff] = useState(false)
|
|
1635
1638
|
|
|
1636
1639
|
useEffect(() => {
|
|
1637
1640
|
let alive = true
|
|
1638
1641
|
fetchOpsProviders()
|
|
1639
1642
|
.then((data) => {
|
|
1640
1643
|
if (!alive) return
|
|
1644
|
+
if (data.disabled) {
|
|
1645
|
+
setOff(true)
|
|
1646
|
+
return
|
|
1647
|
+
}
|
|
1641
1648
|
setProviders(data.providers)
|
|
1642
1649
|
const d = data.default || {}
|
|
1643
1650
|
if (d.provider) setProvider(String(d.provider))
|
|
@@ -1689,6 +1696,8 @@ window.__ModuleLoader__.load({
|
|
|
1689
1696
|
}
|
|
1690
1697
|
}
|
|
1691
1698
|
|
|
1699
|
+
if (off) return null
|
|
1700
|
+
|
|
1692
1701
|
return h(
|
|
1693
1702
|
'section',
|
|
1694
1703
|
{ className: 'pb-ops' },
|
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-progress-union",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
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 双平面),并在 0.6.0 起每回合落一版会话归档(handoff 规则摘要 + 重启注入一次)。",
|
|
6
6
|
"engines": {
|
package/index.js
CHANGED
|
@@ -93,6 +93,10 @@ export const Config = z.object({
|
|
|
93
93
|
}).default({}),
|
|
94
94
|
// v0.7.0 R4:任务板重大(结构性)变更提醒落输入队列。
|
|
95
95
|
notifyMajorChanges: z.boolean().default(true).volatile(),
|
|
96
|
+
// v0.7.0 R3:侧边栏 LLM 任务操作面(整块开关;默认模型仍走 assistant.* 与宿主默认)。
|
|
97
|
+
ops: z.object({
|
|
98
|
+
enabled: z.boolean().default(true).volatile(),
|
|
99
|
+
}).default({}),
|
|
96
100
|
})
|
|
97
101
|
|
|
98
102
|
// —— 路由与存储标识 ——
|
|
@@ -196,7 +200,10 @@ const INSTALLERS = new Map([
|
|
|
196
200
|
])
|
|
197
201
|
|
|
198
202
|
// 单一下载器:命令首词即意图,无需第二个动词。
|
|
199
|
-
|
|
203
|
+
// 后五个是 Windows 宿主实测形状:Bash 工具落 pwsh 时,模型常写
|
|
204
|
+
// `curl.exe -L -o …` 或 `Invoke-WebRequest -Uri …`,只认 POSIX 名的话整条漏识别。
|
|
205
|
+
const DOWNLOADERS = new Set(['curl', 'wget', 'aria2c', 'axel', 'rsync', 'scp', 'aws', 'gcs', 'rclone',
|
|
206
|
+
'invoke-webrequest', 'iwr', 'invoke-restmethod', 'irm', 'start-bitstransfer'])
|
|
200
207
|
|
|
201
208
|
// 把 `act` 包装透传回内层工具(宿主侧 act 的入参形状就是 `{tool, input}`)。
|
|
202
209
|
// 只做一层,不递归展开嵌套 input:够用来避免「观察者把动作误记成 act」,不因此引入依赖。
|
|
@@ -222,20 +229,47 @@ function commandSegments(command) {
|
|
|
222
229
|
|
|
223
230
|
// 跳过 env/时间/权限等前缀词,拿到真正的命令名。
|
|
224
231
|
const COMMAND_PREFIX_WORDS = new Set(['sudo', 'env', 'time', 'nohup', 'doas', 'command', 'nice', 'setsid', 'noglob', 'cross-env', 'xargs'])
|
|
232
|
+
// 真下载藏在引号体里时的外层壳:`pwsh -Command "curl.exe …"` / `sh -c 'wget …'` / `cmd /c "…"`。
|
|
233
|
+
const SHELL_WRAPPERS = /(?:^|[\s;&(])(?:pwsh|powershell|sh|bash|zsh|dash|cmd|wsl)(?:\.exe)?[\s]+(?:-{0,2}(?:command|c|file|login|noexit|nologo)[\s]*|\/c[\s]+)("[^"]*"|'[^']*'|`[^`]*`)/gi
|
|
234
|
+
/**
|
|
235
|
+
* 首词归一(Windows 实测必修):剥引号、取 basename、去 `.exe/.cmd/.bat/.ps1` 后缀。
|
|
236
|
+
* 不这么做的话 `C:\Windows\System32\curl.exe`、`/mingw64/bin/git.exe` 全都认不出。
|
|
237
|
+
*/
|
|
238
|
+
function normalizeHead(word) {
|
|
239
|
+
let w = String(word || '').toLowerCase().replace(/^['"`]+/, '').replace(/['"`;)]+$/, '')
|
|
240
|
+
if (!w) return ''
|
|
241
|
+
w = w.split(/[\\/]/).pop()
|
|
242
|
+
return w.replace(/\.(?:exe|cmd|bat|ps1)$/, '')
|
|
243
|
+
}
|
|
225
244
|
function headWord(words) {
|
|
226
245
|
for (const w of words) {
|
|
227
|
-
const key = w
|
|
228
|
-
if (
|
|
246
|
+
const key = normalizeHead(w)
|
|
247
|
+
if (!key) continue
|
|
248
|
+
if (COMMAND_PREFIX_WORDS.has(key) || w.trim().startsWith('-')) continue
|
|
229
249
|
return key
|
|
230
250
|
}
|
|
231
251
|
return ''
|
|
232
252
|
}
|
|
233
253
|
|
|
254
|
+
// 把 shell 包层的引号体再切成段(只拆一层,不递归解嵌套引号——够用来补 Windows 漏识别)。
|
|
255
|
+
function wrapperSegments(command) {
|
|
256
|
+
const out = []
|
|
257
|
+
SHELL_WRAPPERS.lastIndex = 0
|
|
258
|
+
let m
|
|
259
|
+
while ((m = SHELL_WRAPPERS.exec(String(command || '')))) out.push(...commandSegments(m[1]))
|
|
260
|
+
return out
|
|
261
|
+
}
|
|
262
|
+
|
|
234
263
|
// 取第一个非 flag 词作为目标(包名 / 镜像 / URL)。
|
|
235
264
|
function firstOperand(words, from) {
|
|
236
265
|
for (let i = from; i < words.length; i++) {
|
|
237
266
|
const w = words[i]
|
|
238
|
-
if (
|
|
267
|
+
if (/^(?:-o|-O|--output|--target|-t|--?outfile|-out-file|--filepath|-file|-destination|--url)$/i.test(w)) {
|
|
268
|
+
const nxt = words[i + 1]
|
|
269
|
+
if (nxt && !nxt.startsWith('-')) return nxt
|
|
270
|
+
continue
|
|
271
|
+
}
|
|
272
|
+
if (w.startsWith('-')) continue
|
|
239
273
|
return w
|
|
240
274
|
}
|
|
241
275
|
return ''
|
|
@@ -274,12 +308,12 @@ function classifyDownload(name, argsRaw) {
|
|
|
274
308
|
// 后台线索:独立的一个 &(两侧不是另一个 &,且自成一词)、nohup、--detach、> log &
|
|
275
309
|
if (/(?:^|\s)&(?!&)(?:\s|$)/.test(command) || /\bnohup\b|--detach\b|\bdetached\b/i.test(command)) background = true
|
|
276
310
|
|
|
277
|
-
for (const words of commandSegments(command)) {
|
|
311
|
+
for (const words of commandSegments(command).concat(wrapperSegments(command))) {
|
|
278
312
|
// `--dry-run` 只试跑不拉取:逐段判,不让同一条命令里的另一段背锅。
|
|
279
313
|
if (/--dry-?run\b/i.test(words.join(' '))) continue
|
|
280
314
|
const head = headWord(words)
|
|
281
315
|
if (!head) continue
|
|
282
|
-
const headIdx = words.findIndex((w) => w
|
|
316
|
+
const headIdx = words.findIndex((w) => normalizeHead(w) === head)
|
|
283
317
|
|
|
284
318
|
if (head === 'git') {
|
|
285
319
|
const sub = String(words[headIdx + 1] || '').toLowerCase()
|
|
@@ -475,6 +509,10 @@ const HEAD_GLOSS = new Map([
|
|
|
475
509
|
['export', '设环境变量'], ['source', '载入脚本'], ['git', '跑 git'], ['gh', '操作 GitHub'],
|
|
476
510
|
['aws', '调 AWS'], ['brew', '装软件'], ['cargo', '跑 Rust 工程'], ['go', '跑 Go 工程'],
|
|
477
511
|
['dotnet', '跑 .NET'], ['mix', '跑 Elixir'], ['composer', '跑 PHP 依赖'],
|
|
512
|
+
// Windows 宿主的 Bash 实落 pwsh,不补这几条就只能退回 `Bash×n`。
|
|
513
|
+
['invoke-webrequest', '下载文件'], ['iwr', '下载文件'], ['invoke-restmethod', '发 HTTP 请求'],
|
|
514
|
+
['irm', '发 HTTP 请求'], ['start-bitstransfer', '传输文件'], ['new-item', '建目录或文件'],
|
|
515
|
+
['set-variable', '设环境变量'], ['test-path', '查路径'],
|
|
478
516
|
])
|
|
479
517
|
|
|
480
518
|
function argText(o, keys) {
|
|
@@ -517,7 +555,7 @@ function glossCommand(command) {
|
|
|
517
555
|
const words = segs[0]
|
|
518
556
|
const head = headWord(words)
|
|
519
557
|
if (!head) return ''
|
|
520
|
-
const at = words.findIndex((w) => w
|
|
558
|
+
const at = words.findIndex((w) => normalizeHead(w) === head)
|
|
521
559
|
const sub = String(words[at + 1] || '').toLowerCase().replace(/^-+/, '')
|
|
522
560
|
if (head === 'git') return GIT_SUB_GLOSS.get(sub) || ''
|
|
523
561
|
if (head === 'docker' || head === 'podman' || head === 'nerdctl') return CONTAINER_SUB_GLOSS.get(sub) || ''
|
|
@@ -1481,6 +1519,9 @@ const DEFAULT_CONFIG = {
|
|
|
1481
1519
|
},
|
|
1482
1520
|
// v0.7.0 R4:任务板结构性变更(add/remove/order)提醒落输入队列;关掉则完全不插队。
|
|
1483
1521
|
notifyMajorChanges: true,
|
|
1522
|
+
// v0.7.0 R3:侧边栏 LLM 任务操作块。enabled=false 时 providers 面报 disabled、
|
|
1523
|
+
// POST /ops 直接 403,客户端整块收起(不依赖 assistant 是否已配)。
|
|
1524
|
+
ops: { enabled: true },
|
|
1484
1525
|
// 辅助 LLM(审查/监视 + 槽位管理 + 轮次草案):
|
|
1485
1526
|
// mode: 'registered' 走宿主 llm.stream(选已注册 llm-pi-ai provider/model);
|
|
1486
1527
|
// 'direct' 走自建 OpenAI 兼容端点(baseUrl/apiKey/model);'' 关。
|
|
@@ -1625,6 +1666,7 @@ export async function apply(ctx, config) {
|
|
|
1625
1666
|
}
|
|
1626
1667
|
Object.defineProperty(cfg, 'download', { get: flatSection('download', DEFAULT_CONFIG.download), configurable: true, enumerable: true })
|
|
1627
1668
|
Object.defineProperty(cfg, 'toolGloss', { get: flatSection('toolGloss', DEFAULT_CONFIG.toolGloss), configurable: true, enumerable: true })
|
|
1669
|
+
Object.defineProperty(cfg, 'ops', { get: flatSection('ops', DEFAULT_CONFIG.ops), configurable: true, enumerable: true })
|
|
1628
1670
|
const majorRaw = config && typeof config === 'object' ? config.notifyMajorChanges : undefined
|
|
1629
1671
|
Object.defineProperty(cfg, 'notifyMajorChanges', {
|
|
1630
1672
|
get: () => readVolatile(majorRaw, DEFAULT_CONFIG.notifyMajorChanges),
|
|
@@ -3251,6 +3293,18 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
|
|
|
3251
3293
|
// 再读 agentDefaultModel.currentSelection() 拿宿主当前选择。服务缺失就空数组,
|
|
3252
3294
|
// 面板据此隐藏下拉(而不是报错)。
|
|
3253
3295
|
async function opsProviders() {
|
|
3296
|
+
const a0 = liveAssistant()
|
|
3297
|
+
// ops.enabled=false:整块开关关掉。不再去枚举宿主 provider(省一次宿主调用),
|
|
3298
|
+
// 直接报 disabled,客户端据此把操作块整体收起(而不是报错)。
|
|
3299
|
+
if (cfg.ops.enabled !== true) {
|
|
3300
|
+
return {
|
|
3301
|
+
ok: true,
|
|
3302
|
+
disabled: true,
|
|
3303
|
+
providers: [],
|
|
3304
|
+
default: { provider: '', model: '' },
|
|
3305
|
+
configured: { mode: String(a0.mode || ''), provider: String(a0.provider || ''), model: String(a0.model || '') },
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3254
3308
|
const providers = []
|
|
3255
3309
|
const src = ctx.llm && typeof ctx.llm.listProviders === 'function' ? ctx.llm : llm
|
|
3256
3310
|
try {
|
|
@@ -3274,6 +3328,7 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
|
|
|
3274
3328
|
const sel = isObject(selection) ? { provider: String(selection.provider ?? ''), model: String(selection.model ?? '') } : { provider: '', model: '' }
|
|
3275
3329
|
return {
|
|
3276
3330
|
ok: true,
|
|
3331
|
+
disabled: false,
|
|
3277
3332
|
providers,
|
|
3278
3333
|
default: sel.provider && sel.model ? sel : { provider: String(a.provider || ''), model: String(a.model || '') },
|
|
3279
3334
|
configured: { mode: String(a.mode || ''), provider: String(a.provider || ''), model: String(a.model || '') },
|
|
@@ -3368,11 +3423,19 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
|
|
|
3368
3423
|
throw error
|
|
3369
3424
|
}
|
|
3370
3425
|
|
|
3426
|
+
function forbidden(message) {
|
|
3427
|
+
const error = new Error(message)
|
|
3428
|
+
error.statusCode = 403
|
|
3429
|
+
throw error
|
|
3430
|
+
}
|
|
3431
|
+
|
|
3371
3432
|
async function runOps(body) {
|
|
3372
3433
|
const sessionId = String(body && body.sessionId ? body.sessionId : '')
|
|
3373
3434
|
if (!sessionId || sessionId.length > 240) badRequest('缺少有效的 sessionId')
|
|
3374
3435
|
const op = String(body && body.op ? body.op : '').toLowerCase()
|
|
3375
3436
|
if (!OPS_KINDS.has(op)) badRequest(`未知操作:${op || '(空)'}(可用 refine|mutate|ask|validate)`)
|
|
3437
|
+
// ops.enabled=false 只封花 token 的三个 LLM 动作;validate 是纯本地零 token 的板面体检,照常可用。
|
|
3438
|
+
if (op !== 'validate' && cfg.ops.enabled !== true) forbidden('LLM 任务操作已在设置页关闭(ops.enabled=false)')
|
|
3376
3439
|
const state = ensureState(sessionId)
|
|
3377
3440
|
const question = text(body && body.question, 1200) || ''
|
|
3378
3441
|
const targetId = String(body && body.targetId ? body.targetId : '')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-progress-union",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "进度结合原型:dsh-progress-board 槽位真相源 × 鲸程 widget 时间/ETA 引擎;向压缩插件暴露只读三层进度锚点(service + HTTP 双平面);0.6.0 起每回合落一版会话归档(handoff + 重启注入一次)。基于 l3j3y3/dsh-progress-board (MIT) 与 uuhihj/task-progress-bar dsh-progress-widget (MIT)。",
|
|
6
6
|
"license": "MIT",
|
package/test/client.test.mjs
CHANGED
|
@@ -332,6 +332,14 @@ test('rc.3:LLM 操作块只读 providers + POST /ops,不开新标签也不
|
|
|
332
332
|
// 落盘回执就地刷板,不额外 GET 一次
|
|
333
333
|
assert.match(src, /if \(body\.applied === true && body\.snapshot\) onApplied\(body\.snapshot\)/)
|
|
334
334
|
assert.match(src, /const applyRemoteSnapshot = useCallback\(/)
|
|
335
|
+
// 宿主侧 ops.enabled=false 时整块收起(不是报错、不是空下拉)
|
|
336
|
+
assert.match(src, /disabled: !!\(body && body\.disabled === true\)/, 'providers 回执里的 disabled 必须透出来')
|
|
337
|
+
const blockStart = src.indexOf('function LlmOpsBlock({')
|
|
338
|
+
const blockEnd = src.indexOf('\n }\n', blockStart)
|
|
339
|
+
const block = src.slice(blockStart, blockEnd)
|
|
340
|
+
assert.match(block, /if \(data\.disabled\) \{[\s\S]*setOff\(true\)/, 'disabled 必须先于 setProviders 短路')
|
|
341
|
+
assert.match(block, /if \(off\) return null/, '开关关掉时整个操作块不渲染')
|
|
342
|
+
assert.ok(block.indexOf('if (off) return null') > block.indexOf('useEffect('), '早退必须在全部 hooks 之后,不破坏 hook 顺序')
|
|
335
343
|
})
|
|
336
344
|
|
|
337
345
|
test('rc.3:操作块样式只用宿主令牌,窄屏降级', () => {
|
|
@@ -197,3 +197,55 @@ test('快照 items 追加 isDownload(老字段不动)', async () => {
|
|
|
197
197
|
assert.ok(Object.keys(snap.items[0]).includes(key), `老字段 ${key} 不得丢`)
|
|
198
198
|
}
|
|
199
199
|
})
|
|
200
|
+
|
|
201
|
+
// ── Windows 宿主实测形状(v0.7.3)───────────────────────────────────
|
|
202
|
+
// 真机回灌:DSH 0.2.2 沙箱的 Bash 工具实落 pwsh,命令名带 .exe / 路径前缀,
|
|
203
|
+
// 只认 POSIX 首词时 `curl.exe -L -o …` 整条漏识别(子条根本不出现)。
|
|
204
|
+
|
|
205
|
+
test('classifyDownload:Windows 形态的 .exe / 绝对路径首词照样识别', () => {
|
|
206
|
+
const a = classifyDownload(...sh('New-Item -ItemType Directory -Force -Path dl072; curl.exe -L -o dl072/node.tar.gz https://nodejs.org/dist/v22.12.0/node-v22.12.0.tar.gz'))
|
|
207
|
+
assert.equal(a?.kind, 'download', '复合命令里带 curl.exe 的那一段必须被抓到')
|
|
208
|
+
assert.equal(a.target, 'node.tar.gz')
|
|
209
|
+
assert.equal(classifyDownload(...sh('C:\\Windows\\System32\\curl.exe -O https://example.com/a.bin')).kind, 'download')
|
|
210
|
+
assert.equal(classifyDownload(...sh('/mingw64/bin/git.exe clone https://github.com/a/b')).kind, 'clone')
|
|
211
|
+
assert.equal(classifyDownload(...sh('WGET.EXE -q https://example.com/x')).kind, 'download')
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
test('classifyDownload:pwsh/cmd 包层的引号体不再漏识别', () => {
|
|
215
|
+
assert.equal(classifyDownload(...sh('pwsh -Command "curl.exe -L -o out.bin https://example.com/out.bin"')).kind, 'download')
|
|
216
|
+
assert.equal(classifyDownload(...sh('powershell -Command "Invoke-WebRequest -Uri https://example.com/f.zip -OutFile f.zip"')).kind, 'download')
|
|
217
|
+
assert.equal(classifyDownload(...sh('cmd /c "wget -qO- https://example.com/y"')).kind, 'download')
|
|
218
|
+
assert.equal(classifyDownload(...sh('sh -c \'npm install left-pad\'')).kind, 'install')
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
test('classifyDownload:PowerShell 自有下载 cmdlet 入表', () => {
|
|
222
|
+
assert.equal(classifyDownload(...sh('Invoke-WebRequest -Uri https://example.com/big.iso -OutFile big.iso')).kind, 'download')
|
|
223
|
+
assert.equal(classifyDownload(...sh('iwr https://example.com/a -OutFile a.txt')).target, 'a', 'URL 在前时目标取 URL 末段')
|
|
224
|
+
assert.equal(classifyDownload(...sh('iwr -Uri https://example.com/big.iso -OutFile big.iso')).target, 'big.iso', '-OutFile 显式给目标时用文件名')
|
|
225
|
+
assert.equal(classifyDownload(...sh('Start-BitsTransfer -Source https://example.com/b -Destination b.bin')).kind, 'download')
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
test('classifyDownload:Windows 形状不得误判(无拉取语义的 pwsh 命令仍返回 null)', () => {
|
|
229
|
+
for (const cmd of [
|
|
230
|
+
'pwsh -Command "Get-Process | Select-Object -First 5"',
|
|
231
|
+
'curl.exe -s -X POST https://example.com/api -d \'{}\'',
|
|
232
|
+
'Invoke-WebRequest -Uri https://example.com/page',
|
|
233
|
+
'git.exe status --short',
|
|
234
|
+
'New-Item -ItemType Directory out',
|
|
235
|
+
]) {
|
|
236
|
+
const r = classifyDownload(...sh(cmd))
|
|
237
|
+
if (cmd === 'curl.exe -s -X POST https://example.com/api -d \'{}\'' || cmd === 'Invoke-WebRequest -Uri https://example.com/page') {
|
|
238
|
+
// 拉取器就是单一动词,这两条允许命中(与 POSIX 口径一致),但不许是 install 型误判。
|
|
239
|
+
assert.ok(!r || r.kind !== 'install', cmd)
|
|
240
|
+
continue
|
|
241
|
+
}
|
|
242
|
+
assert.equal(r, null, `不该误判成下载:${cmd}`)
|
|
243
|
+
}
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
test('glossCommand:Windows 命令名给人话而不是退回 Bash×n', async () => {
|
|
247
|
+
const { glossCommand } = await import('../index.js')
|
|
248
|
+
assert.match(glossCommand('curl.exe -L -o a.bin https://x/a.bin'), /发 HTTP 请求|下载/)
|
|
249
|
+
assert.match(glossCommand('Invoke-WebRequest -Uri https://x -OutFile y'), /下载文件/)
|
|
250
|
+
assert.match(glossCommand('git.exe clone https://github.com/a/b'), /克隆|拉取/)
|
|
251
|
+
})
|
package/test/ops.test.mjs
CHANGED
|
@@ -92,6 +92,7 @@ test('providers:llm.listProviders 有值就列出来;服务缺失退回空
|
|
|
92
92
|
const res = await callRoute(harness, `${OPS}/providers`, { method: 'GET', url: `${OPS}/providers`, headers: {} })
|
|
93
93
|
const json = res.json()
|
|
94
94
|
assert.equal(json.ok, true)
|
|
95
|
+
assert.equal(json.disabled, false, '默认开关下 providers 必须报 disabled=false')
|
|
95
96
|
assert.deepEqual(json.providers.map((p) => p.id), ['local', 'other'])
|
|
96
97
|
assert.deepEqual(json.providers[0].models.map((m) => m.id), ['qwen', 'deepseek'])
|
|
97
98
|
assert.equal(json.default.provider, 'local', '无宿主默认选择时退回设置页')
|
|
@@ -105,6 +106,29 @@ test('providers:llm.listProviders 有值就列出来;服务缺失退回空
|
|
|
105
106
|
assert.equal(wrong.status, 405)
|
|
106
107
|
})
|
|
107
108
|
|
|
109
|
+
test('ops.enabled=false:providers 报 disabled 且不枚举宿主、refine/mutate/ask 一律 403,validate 照常可用', async () => {
|
|
110
|
+
let listed = 0
|
|
111
|
+
const harness = await booted({
|
|
112
|
+
config: { ops: { enabled: false } },
|
|
113
|
+
providers: [{ id: 'local', models: ['qwen'] }],
|
|
114
|
+
})
|
|
115
|
+
const src = harness.ctx.get('llm')
|
|
116
|
+
const origin = src.listProviders
|
|
117
|
+
src.listProviders = async () => { listed += 1; return origin() }
|
|
118
|
+
const prov = (await callRoute(harness, `${OPS}/providers`, { method: 'GET', url: `${OPS}/providers`, headers: {} })).json()
|
|
119
|
+
assert.equal(prov.disabled, true, '开关关掉必须告知客户端,而不是只给空数组')
|
|
120
|
+
assert.deepEqual(prov.providers, [])
|
|
121
|
+
assert.equal(listed, 0, '关了就不再打宿主 listProviders')
|
|
122
|
+
for (const op of ['refine', 'mutate', 'ask']) {
|
|
123
|
+
const r = await ops(harness, { sessionId: SESSION, op, question: '拆一下' })
|
|
124
|
+
assert.equal(r.status, 403, `${op} 在 ops.enabled=false 时必须 403`)
|
|
125
|
+
assert.match(r.json.error, /关闭|ops\.enabled/)
|
|
126
|
+
}
|
|
127
|
+
const v = await ops(harness, { sessionId: SESSION, op: 'validate' })
|
|
128
|
+
assert.equal(v.status, 200, 'validate 是零 token 的本地体检,不被开关封掉')
|
|
129
|
+
assert.equal(v.json.ok, true)
|
|
130
|
+
})
|
|
131
|
+
|
|
108
132
|
// ── /ops validate:本地活,不进 LLM ────────────────────────────────────
|
|
109
133
|
|
|
110
134
|
test('op=validate 纯本地跑,一次 llm 调用都不发', async () => {
|