@xi4z/dsh-utils 0.9.2 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -336,18 +336,18 @@ DSH 的预设除了目录版,还可能来自 Cordis 声明(随包内置的 `
336
336
 
337
337
  ## 组件二:无人值守审批门控
338
338
 
339
- 挂宿主 `'approval/request'` waterfall 链首(`prepend`)。判定无人值守的请求先 `next()` 给下游:窗口内有人答,用人的答案;窗口耗尽,按 fail-closed 默认值落定,turn 立即结束,不长期挂起。交互会话不改变。
339
+ 挂宿主 `'approval/request'` waterfall 链首(`prepend`)。判定无人值守的请求先 `next()` 给下游:窗口内有人答,用人的答案;窗口耗尽,按 fail-closed 默认值落定,turn 立即结束,不长期挂起。**请求一旦落定就撤回仍未回答的提示**,不管是谁落定的:门控把自己的 controller 融进请求的 signal,窗口到期、下游(网页/ACP/自动审批)作答、或外部人类渠道通过 `approvalPolicyInfo.withdraw(request, outcome)` 报回答案时都会 abort,宿主随即取消那条转发的 Remote 请求,网页审批卡片和侧栏「等待审批」标记一起消失,不会堆成一片已经决定过的旧卡片。交互会话不改变。
340
340
 
341
341
  | 字段 | 默认 | 含义 |
342
342
  |---|---|---|
343
- | `origins` | `[subagent, scheduled]` | 无人值守来源:`subagent` / `scheduled` / `cron` / `all` |
343
+ | `origins` | `[subagent, scheduled]` | 无人值守来源:`subagent` / `scheduled` / `cron` / `interactive` / `all`;`interactive` = 人类驱动的 turn 也进窗口(会话进行中的审批) |
344
344
  | `sessions` | `[]` | 按 agent id 的 glob 点名会话,命中即门控该会话所有 turn |
345
345
  | `windowSeconds` | `60` | 应答窗口(秒);`0` = 立即拒绝,不询问下游 |
346
346
  | `defaultOutcome` | `rejected` | 窗口到期落定值:`rejected` 或 `unavailable`。没有 `allowed-once` |
347
347
  | `defaultPermissionPreset` | `''` | 新会话权限档;`auto` 走实验性自动审批(要对应 bundle) |
348
348
  | `autoReviewContent` | `true` | 窗口拒绝自动审批的请求时,把复核内容附进模型读到的工具结果 |
349
349
 
350
- 判定粒度:`sessions` 命中与 `all` 是会话级。`subagent` 看 `session.header.origin`。`scheduled` / `cron` 看最后一条带溯源 user 消息的 `source.kind`。合成注入(`runtime-context`、`skill-catalog`)跳过;人插过话就不门控。审计由宿主 `approval/asked` + `approval/decided` 写会话日志;本组件不写日志、不落盘。
350
+ 判定粒度:`sessions` 命中与 `all` 是会话级。`subagent` 看 `session.header.origin`。`scheduled` / `cron` 看最后一条带溯源 user 消息的 `source.kind`。合成注入(`runtime-context`、`skill-catalog`)跳过;默认人插过话就不门控。`interactive` 是机器来源的补集:最后一条溯源消息是 `user` / `user-question-reply` 且不是 subagent 时也门控——即**会话进行中的审批**同样有截止时间;它不覆盖未知溯源(那仍然只有 `all` 覆盖),可与机器来源组合(`[subagent, scheduled, interactive]` ≈ 除 cron 外全覆盖)。审计由宿主 `approval/asked` + `approval/decided` 写会话日志;本组件不写日志、不落盘。
351
351
 
352
352
  ## 组件三:QQ 审批卡片
353
353
 
@@ -371,16 +371,19 @@ DSH 的预设除了目录版,还可能来自 Cordis 声明(随包内置的 `
371
371
  └─ 出卡(正文含「N 秒内未处理将自动拒绝」)
372
372
  ├─ 网页先答 / 门控到期 → POST settle ignored(静默关闭)
373
373
  └─ 点击 → relay ack(0) → 长轮询取到 clicked
374
+ → 调 approvalPolicyInfo.withdraw(request, 结果) 关掉网页那张卡
374
375
  → 回填 allowed-once / rejected → POST settle(默认静默,不发回执)
375
376
  ```
376
377
 
378
+ 门控到期时,本组件看到的是一次**撤回**(abort 原因 `UnattendedApprovalWindowExpired`):卡片照旧静默关闭(settle `ignored`,原因 `auto-rejected`),但回给宿主的是门控自己的 fail-closed 结果——不会把这次「拒绝」记成 `cancelled`,模型读到的仍是拒绝。反向同理:网页先答时门控会以 `UnattendedApprovalSettledElsewhere` 撤回,本组件把卡片 settle 成 `answered-elsewhere` 并回填对方的结果。
379
+
377
380
  ### 配置
378
381
 
379
382
  | 字段 | 默认 | 含义 |
380
383
  |---|---|---|
381
384
  | `enabled` | `false` | 总开关;关闭时完全不碰 waterfall |
382
385
  | `relayUrl` | `''` | relay 审批基地址,以 `/approval` 结尾,如 `https://notify.xiaz.work/_qq/approval` |
383
- | `sharedKey` | `''` | 与 relay 的 `approval.key` 一致;**只写密钥**,显式填写,不回显、不插值 |
386
+ | `sharedKey` | `''` | relay 侧鉴权:relay 没配 `approval.key` 时复用它的 `gotify.clientToken`,这里填同一把;**只写密钥**,显式填写,不回显、不插值 |
384
387
  | `deviceLabel` | 主机名 | 卡片上的设备名 |
385
388
  | `sendDelayMs` | `1200` | 发卡防抖;自动裁决落在此窗口内就不打扰 |
386
389
  | `pollWaitSeconds` | `25` | 长轮询窗口;点击到恢复通常 <1s |
@@ -398,7 +401,7 @@ DSH 的预设除了目录版,还可能来自 Cordis 声明(随包内置的 `
398
401
 
399
402
  ### relay 侧
400
403
 
401
- `config.json` 增加一段(键与 DSH 的 `sharedKey` 对齐):
404
+ `config.json` 增加一段(**不用再建单独密钥**):
402
405
 
403
406
  ```json
404
407
  {
@@ -406,15 +409,17 @@ DSH 的预设除了目录版,还可能来自 Cordis 声明(随包内置的 `
406
409
  "enabled": true,
407
410
  "host": "127.0.0.1",
408
411
  "port": 8787,
409
- "key": "与 sharedKey 相同的共享密钥",
410
412
  "route": "1"
411
413
  }
412
414
  }
413
415
  ```
414
416
 
417
+ - 鉴权复用 relay 顶层已有的 `gotify.clientToken`:DSH 的 `sharedKey` 填同一把即可。
418
+ `approval.key` 仍可作为显式覆盖。
419
+
415
420
  - `route` 指向发卡的私聊系列(默认 `1`);审批卡片只支持单聊。
416
421
  - relay 会额外连一条 QQ 机器人 WebSocket(只订阅 `INTERACTION`),与现有 Gotify 单向投递并行;同一 shard 只能有一个连接,所以不要再起第二个 relay 实例。
417
- - 端点:`POST /approval`、`GET /approval/{askId}?wait=N`、`POST /approval/{askId}/settle`、`GET /healthz`;鉴权头 `X-Approval-Key`。
422
+ - 端点:`POST /approval`、`GET /approval/{askId}?wait=N`、`POST /approval/{askId}/settle`、`GET /healthz`;鉴权头 `X-Approval-Key` 或 `X-Gotify-Key`(同一把 token)。
418
423
 
419
424
  openresty 反代一条受保护路径:
420
425
 
@@ -466,7 +471,7 @@ agent/status → running → idle 的边沿 = 整个任务结束
466
471
  | `deviceLabel` | `DSH_QQ_NOTIFY_DEVICE_LABEL` | 同 `deviceName` | 给人看的名字,用于 `{device}` 与标题前缀 |
467
472
  | `deviceInTitle` | — | `false` | `true` 时 Gotify 标题加 `[设备名]` 前缀 |
468
473
  | `gotifyUrl` | `DSH_QQ_NOTIFY_GOTIFY_URL` | `''` | 网关地址,如 `https://notify.example.com` |
469
- | `gotifyToken` | — | `''` | 该系列的 Gotify application token;**只写密钥**,显式填写,不回显、不插值 |
474
+ | `gotifyToken` | — | `''` | 该系列的 Gotify application token;**只写密钥**,显式填写,不回显、不插值;全角标点/前缀大小写/漏点会自动纠正 |
470
475
  | `gotifyPriority` | — | `3` | 默认优先级,`targets` 未单独指定时用 |
471
476
  | `gotifyHeaders` | `DSH_QQ_NOTIFY_GOTIFY_HEADERS`(JSON) | `{}` | 追加请求头,用于反代 Basic Auth 等 |
472
477
  | `targets` | `DSH_QQ_NOTIFY_TARGETS`(JSON) | `[]` | 多目标列表;非空时不用 `gotifyUrl` / `gotifyToken` |
@@ -490,6 +495,10 @@ agent/status → running → idle 的边沿 = 整个任务结束
490
495
 
491
496
  `gotifyToken` 声明为 schemastery 的 `role('secret')`:DSH 设置接口在把配置发给浏览器前会剥掉这个字段,只留下「是否已设置」;设置页因此只能覆盖,不能查看。运行时组件仍从 live config 读到真实值,配置写在 profile 的 `cordis.patch.yml` 或插件页里均可,且按字面量使用。
492
497
 
498
+ `gotifyToken`(以及 `targets[].token`)在投递前会做一次**兜底**:去掉首尾空白、零宽字符和包裹引号,全角 ASCII 和中文标点转半角(`。`→`.`),`gtfya` / `gtfyc` 前缀转小写并补上漏掉的分隔点。修完仍有非 ASCII 字符的目标直接跳过并记 warning,不再让 `fetch` 在构造请求头时抛 `Cannot convert argument to a ByteString`。
499
+
500
+ > token 只能从 Gotify 创建 application 时显示的那一次复制。`gotify.db` 的 `applications.token` 列存的是摘要而不是可用凭据,从数据库/备份里抄出来的值一律 401。
501
+
493
502
  其余字符串字段仍支持 `${NAME}` / `${NAME:-默认值}` 插值:`gotifyUrl`、`endpoint`、`token`、`targetId`、`gotifyHeaders` 的值,`targets[]` 的 `url` / `token`。
494
503
 
495
504
  变量未设或为空,展开成空串。该目标缺 token 就跳过,记 warning。**不发字面量** `${...}`。插值在每次投递前解析,密钥不进日志。
package/cordis.patch.yml CHANGED
@@ -41,7 +41,7 @@
41
41
  # relay 的审批基地址(HTTPS 反代到 relay 的 /approval 端点),
42
42
  # 例如 https://notify.xiaz.work/_qq/approval。
43
43
  relayUrl: ''
44
- # 与 relay 侧 approval.key 一致;建议用环境变量注入。
44
+ # relay 侧鉴权:relay 没配 approval.key 时复用 gotify.clientToken,这里填同一把。
45
45
  sharedKey: ''
46
46
  deviceLabel: ''
47
47
  # 自动裁决(auto review / GUI 抢答)落在防抖窗口内时不出卡。
@@ -52,11 +52,14 @@
52
52
  config:
53
53
  # 留空 = 内置默认。下面只列出最常改的几项,完整字段见 README。
54
54
  #
55
- # 出口:Gotify 网关。url/token 建议用环境变量注入,避免把凭据写进仓库:
56
- # DSH_QQ_NOTIFY_GOTIFY_URL / DSH_QQ_NOTIFY_GOTIFY_TOKEN
55
+ # 出口:Gotify 网关。网关地址可写 '${VAR}'(投递前展开);token 是只写密钥,
56
+ # 只认字面量,不做 ${ENV} 插值。想把 token 放在环境变量里,用 targets[].tokenEnv:
57
+ # targets:
58
+ # - name: qq-home
59
+ # url: 'https://notify.example.com'
60
+ # tokenEnv: DSH_GOTIFY_TOKEN
57
61
  transport: gotify
58
- # 密钥可以不落盘:'${VAR}' 在投递前从环境变量展开(也支持 targets[].tokenEnv),
59
- # 或整段用 DSH_QQ_NOTIFY_GOTIFY_URL / DSH_QQ_NOTIFY_GOTIFY_TOKEN 覆盖。
62
+ # token 从 Gotify 直接复制;全角标点(。)、大写前缀或漏掉的点会在投递前自动纠正。
60
63
  # 先只记日志:确认能收到再改成 false(或在 profile patch 里覆盖)。
61
64
  dryRun: true
62
65
  # 设备名留空 = 自动取主机名;deviceLabel 是渲染到 {device} 的显示名。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xi4z/dsh-utils",
3
- "version": "0.9.2",
3
+ "version": "0.10.1",
4
4
  "description": "DeepSeek Harness utility bundle: a patch-only package that assembles five independently published components — the utils-agents preset/skill panel (nested SKILL.md discovery, model visibilities, skills, repositories and AGENTS.md), an unattended approval gate, a QQ approval card answerer, session notifications, and the shared browser UI that configures every row.",
5
5
  "keywords": [
6
6
  "dsh",
@@ -58,11 +58,11 @@
58
58
  "node": ">=22.19.0"
59
59
  },
60
60
  "dependencies": {
61
- "@xi4z/dsh-utils-approval-policy": "0.9.2",
62
- "@xi4z/dsh-utils-approval-qq": "0.9.2",
63
- "@xi4z/dsh-utils-notify": "0.9.2",
64
- "@xi4z/dsh-utils-ui": "0.9.2",
65
- "@xi4z/dsh-utils-utils-agents": "0.9.2"
61
+ "@xi4z/dsh-utils-approval-policy": "0.10.1",
62
+ "@xi4z/dsh-utils-approval-qq": "0.10.1",
63
+ "@xi4z/dsh-utils-notify": "0.10.1",
64
+ "@xi4z/dsh-utils-ui": "0.10.1",
65
+ "@xi4z/dsh-utils-utils-agents": "0.10.1"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "@deepseek-ai/cordis": "~4.1.0"