@xi4z/dsh-utils 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +411 -2
- package/cordis.patch.yml +63 -0
- package/icon.svg +21 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +82 -3
- package/skills/dsh-approval-policy-config/SKILL.md +96 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 xi4z
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,412 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @xi4z/dsh-utils
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
官方实验性插件的多包形态:根包 `@xi4z/dsh-utils` 只提供 bundle 层(`cordis.patch.yml` + locale + icon),四个组件各自是独立包,另有一个浏览器半侧包。行 id 就是 settings 命名空间,保持稳定。
|
|
4
|
+
|
|
5
|
+
| 组件 | 挂载项 id | 包 | 作用 |
|
|
6
|
+
|---|---|---|---|
|
|
7
|
+
| 递归技能发现 + 技能仓库同步 | `skill-recursive` | `@xi4z/dsh-utils-skill-recursive` | 嵌套目录找 `SKILL.md`;「技能仓库」面板从 Git 拉取技能,只拉取不推送 |
|
|
8
|
+
| 无人值守审批门控 | `dsh-approval-policy` | `@xi4z/dsh-utils-approval-policy` | 给审批请求设应答窗口,超时 fail-closed |
|
|
9
|
+
| 会话通知 | `dsh-notify` | `@xi4z/dsh-utils-notify` | 会话结束/等授权/等回答时,经 Gotify 网关推送,带设备名 |
|
|
10
|
+
| 技能面板 | `dsh-skill-panel` | `@xi4z/dsh-utils-skill-panel` | 列出当前会话可读取的 Skill,逐个开关;关闭后从模型目录隐藏 |
|
|
11
|
+
| 浏览器半侧 | `dsh-utils-ui` | `@xi4z/dsh-utils-ui` | 配置页 + 右侧栏技能/技能仓库面板;包根是 no-op host,只发布 `client.js` |
|
|
12
|
+
|
|
13
|
+
每个组件包用自己的 `locale/{en,zh}.json` 提供行标题(递归Skill插件 / 无人值守审批门控 / 会话通知 / 技能面板);`@xi4z/dsh-utils-ui` 行标题是「Harness 工具集」。bundle 根包没有组件代码,入口是空模块——和官方 `dsh-experimental-*-bundle` 一致:bundle 管 patch/metadata,组件包各自发布、按包名挂载。
|
|
14
|
+
|
|
15
|
+
### 关于配置界面
|
|
16
|
+
|
|
17
|
+
DSH 客户端扫描器只从**包根挂载行**加载 `client.js`。`@xi4z/dsh-utils-ui` 是独立包,它的包根行同时挂 `client.js` 的 no-op host;四个组件包分别按包根行挂载,只做宿主行为,不会被当成 client source,因此不会出现 `multiple active Loader sources`。
|
|
18
|
+
|
|
19
|
+
「技能仓库」同步的运行时代码在 `@xi4z/dsh-utils-skill-recursive` 里(`packages/skill-recursive/src/ui-host.ts`):四个 JSON 路由由 `skill-recursive` 行注册,`@xi4z/dsh-utils-ui` 只提供配置页与右侧栏面板。停用 `skill-recursive` 会同时失去递归发现和技能仓库同步。
|
|
20
|
+
|
|
21
|
+
配置写 `cordis.patch.yml`:bundle 给默认值,profile 按 id 覆盖。覆盖行**不要写 `name`**(写旧包名会被 DSH 按 name mismatch 跳过)。技能仓库的仓库地址、分支与密钥不写 profile,存在 `$DSH_HOME/storages/dsh-utils-ui.json`(沿用旧文件名)。
|
|
22
|
+
|
|
23
|
+
## 安装
|
|
24
|
+
|
|
25
|
+
这是 pnpm workspace,先准备仓库:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
cd /path/to/dsh-utils
|
|
29
|
+
pnpm install
|
|
30
|
+
pnpm build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Release 已发到 npm 时,一行安装:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
plugin_manager action=install_bundle target=@xi4z/dsh-utils
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
dsh plugin --profile <profile> add @xi4z/dsh-utils
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
本地开发用 link(组件包未发布时):
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
dsh plugin --profile <profile> add link:/path/to/dsh-utils
|
|
47
|
+
for p in skill-recursive approval-policy notify skill-panel ui; do
|
|
48
|
+
dsh plugin --profile <profile> add link:/path/to/dsh-utils/packages/$p
|
|
49
|
+
done
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
profile 的 `dsh.profile.bundles` 里是 `@xi4z/dsh-utils`。装后 bundle 的 patch 自动插五行,不手写挂载块;`config:` 只管配置。挂载项新增/改名要重启宿主。
|
|
53
|
+
|
|
54
|
+
从单包/无 scope 版本升级:
|
|
55
|
+
|
|
56
|
+
1. profile 依赖里的 `dsh-utils`、`dsh-utils-*` link 换成 `@xi4z/dsh-utils`、`@xi4z/dsh-utils-*`;
|
|
57
|
+
2. `dsh.profile.bundles` 里的 `dsh-utils` 换成 `@xi4z/dsh-utils`;
|
|
58
|
+
3. profile `cordis.patch.yml` 的组件覆盖行不要写 `name:`(只留 `id` + `config`),`id: dsh-utils-ui` 覆盖行删掉(bundle 会插);
|
|
59
|
+
4. 重启宿主。技能仓库设置、Deploy Key、上次同步记录都不用重填。
|
|
60
|
+
|
|
61
|
+
## 发布
|
|
62
|
+
|
|
63
|
+
六个包同一版本,先组件后 bundle:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
pnpm build
|
|
67
|
+
pnpm publish:components
|
|
68
|
+
pnpm publish:bundle
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`workspace:^` 在 publish 时转成 `^<本次版本>`;scope 是公开的 `@xi4z`。发布前 `npm login`,确认账号能使用 `@xi4z` scope(scope 通常是 npm 用户名或已创建的组织)。
|
|
72
|
+
|
|
73
|
+
## 组件一:递归技能发现与技能仓库同步
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
.dsh/skills/
|
|
77
|
+
├── flat-skill/SKILL.md ← 内置提供方(本组件不管第 1 层)
|
|
78
|
+
└── obsidian-skills/ ← 容器目录
|
|
79
|
+
├── defuddle/SKILL.md ← 本组件
|
|
80
|
+
└── json-canvas/SKILL.md ← 本组件
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
扫描根:项目 `.dsh/skills`、`.agents/skills`(向上找最近 `.git`)、`$DSH_HOME/skills`(默认 `~/.dsh/skills`)、`$DSH_AGENTS_HOME/skills`(默认 `~/.agents/skills`),加 `extraRoots`。同名扁平技能优先:嵌套候选 rank 低一档。
|
|
84
|
+
|
|
85
|
+
| 字段 | 默认 | 含义 |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `minDepth` | `2` | 技能第一个目录层级(相对技能根) |
|
|
88
|
+
| `maxDepth` | `8` | 最深扫描层级 |
|
|
89
|
+
| `watch` | `true` | 监听技能根,变化刷新目录 |
|
|
90
|
+
| `debounceMs` | `200` | 监听失效防抖 |
|
|
91
|
+
| `pollIntervalMs` | `2000` | 不支持递归监听时的轮询间隔 |
|
|
92
|
+
| `includeProjectRoots` | `true` | 扫项目级技能根 |
|
|
93
|
+
| `includeUserRoots` | `true` | 扫用户级技能根 |
|
|
94
|
+
| `followSymlinks` | `false` | 跟随符号链接目录(带环路保护) |
|
|
95
|
+
| `extraRoots` | `[]` | 追加技能根,绝对路径 |
|
|
96
|
+
| `ignoreDirs` | `[".system","node_modules",".git"]` | 永不进入的目录名 |
|
|
97
|
+
|
|
98
|
+
识别字段:`name`、`description`,可选 `whenToUse`、`disable-model-invocation`、`user-invocable`。非法文件记 warning,跳过。
|
|
99
|
+
|
|
100
|
+
## 组件二:无人值守审批门控
|
|
101
|
+
|
|
102
|
+
挂宿主 `'approval/request'` waterfall 链首(`prepend`)。判定无人值守的请求先 `next()` 给下游:窗口内有人答,用人的答案;窗口耗尽,按 fail-closed 默认值落定,turn 立即结束,不长期挂起。交互会话不改变。
|
|
103
|
+
|
|
104
|
+
| 字段 | 默认 | 含义 |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| `origins` | `[subagent, scheduled]` | 无人值守来源:`subagent` / `scheduled` / `cron` / `all` |
|
|
107
|
+
| `sessions` | `[]` | 按 agent id 的 glob 点名会话,命中即门控该会话所有 turn |
|
|
108
|
+
| `windowSeconds` | `60` | 应答窗口(秒);`0` = 立即拒绝,不询问下游 |
|
|
109
|
+
| `defaultOutcome` | `rejected` | 窗口到期落定值:`rejected` 或 `unavailable`。没有 `allowed-once` |
|
|
110
|
+
| `defaultPermissionPreset` | `''` | 新会话权限档;`auto` 走实验性自动审批(要对应 bundle) |
|
|
111
|
+
| `autoReviewContent` | `true` | 窗口拒绝自动审批的请求时,把复核内容附进模型读到的工具结果 |
|
|
112
|
+
|
|
113
|
+
判定粒度:`sessions` 命中与 `all` 是会话级。`subagent` 看 `session.header.origin`。`scheduled` / `cron` 看最后一条带溯源 user 消息的 `source.kind`。合成注入(`runtime-context`、`skill-catalog`)跳过;人插过话就不门控。审计由宿主 `approval/asked` + `approval/decided` 写会话日志。本组件不写日志、不落盘。
|
|
114
|
+
|
|
115
|
+
随包技能 `dsh-approval-policy-config`:配置向导。
|
|
116
|
+
|
|
117
|
+
## 组件三:会话通知
|
|
118
|
+
|
|
119
|
+
每轮跑完,或 agent 挂起在「等你回答 / 等你授权」,推一条消息到指定出口。出口默认**公网 Gotify 网关**。插件不持 Bot 凭据、不建 WebSocket、不加依赖,只发一个 HTTP POST。任何能上网的设备(笔记本、服务器、云主机)装同一份 bundle、填网关地址和 token 就能发。每条消息带**发送设备名**(默认主机名),多台机器共用一个 QQ 也能分清。
|
|
120
|
+
|
|
121
|
+
### 接线
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
session/event → 累积"刚结束这一轮"的 reason + 最后一条 assistant 文本
|
|
125
|
+
agent/status → running → idle 的边沿 = 整个任务干完的那一刻
|
|
126
|
+
↓
|
|
127
|
+
渲染中文摘要(含设备名)→ POST {gotifyUrl}/message → relay → QQ
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
不用 `turn/end` 直接发:`agent/status` 的 idle 边沿才是"整个任务结束"(含子任务收敛),天然去重。`turn/end` 只给结束原因和回复文本。
|
|
131
|
+
|
|
132
|
+
### 事件来源:只读会话日志
|
|
133
|
+
|
|
134
|
+
早期挂过 `approval/request` 与 `user-questions/request` 两个 waterfall 监听。实测**根 context 的监听器收不到**(agent 作用域派发被过滤,加 `{ global: true }` 也没解决)。改为全从 `session/event` 推导:
|
|
135
|
+
|
|
136
|
+
| 通知类型 | 日志信号 | 去抖 |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| 会话完成/出错/中止 | `turn/end` 的 `reason.kind` | 无 |
|
|
139
|
+
| 等待你回答 | `tool/call`,`name` 为 `ask_user_question` / `exit_plan_mode` | `questionDelayMs`(默认 2500),`tool/result` 到达取消 |
|
|
140
|
+
| 需要授权 | `approval/asked` | `approvalDelayMs`(默认 3000),`approval/decided` 到达取消 |
|
|
141
|
+
|
|
142
|
+
去抖:人 2.5 秒内界面答了,或策略自动裁决了,就不打扰。
|
|
143
|
+
|
|
144
|
+
### 配置
|
|
145
|
+
|
|
146
|
+
`cordis.patch.yml` 的 `config`,或环境变量。环境变量优先。字段全 volatile:改完即生效,不重启。
|
|
147
|
+
|
|
148
|
+
| 字段 | 环境变量 | 默认 | 说明 |
|
|
149
|
+
|---|---|---|---|
|
|
150
|
+
| `enabled` | — | `true` | 总开关 |
|
|
151
|
+
| `transport` | — | `gotify` | `gotify` = 公网网关;`onebot` 直连 NapCat 已废弃,仅兼容旧配置 |
|
|
152
|
+
| `deviceName` | `DSH_QQ_NOTIFY_DEVICE` | 主机名 | 设备唯一名,多设备区分基础 |
|
|
153
|
+
| `deviceLabel` | `DSH_QQ_NOTIFY_DEVICE_LABEL` | 同 `deviceName` | 给人看的名字,用于 `{device}` 与标题前缀 |
|
|
154
|
+
| `deviceInTitle` | — | `false` | `true` 时 Gotify 标题加 `[设备名]` 前缀 |
|
|
155
|
+
| `gotifyUrl` | `DSH_QQ_NOTIFY_GOTIFY_URL` | `''` | 网关地址,如 `https://notify.example.com` |
|
|
156
|
+
| `gotifyToken` | `DSH_QQ_NOTIFY_GOTIFY_TOKEN` | `''` | 该系列的 Gotify application token |
|
|
157
|
+
| `gotifyPriority` | — | `3` | 默认优先级,`targets` 未单独指定时用 |
|
|
158
|
+
| `gotifyHeaders` | `DSH_QQ_NOTIFY_GOTIFY_HEADERS`(JSON) | `{}` | 追加请求头,用于反代 Basic Auth 等 |
|
|
159
|
+
| `targets` | `DSH_QQ_NOTIFY_TARGETS`(JSON) | `[]` | 多目标列表;非空时不用 `gotifyUrl` / `gotifyToken` |
|
|
160
|
+
| `notifyOnReasons` | — | `[completed, error, aborted]` | 通知的结束原因:`completed` / `error` / `aborted` / `blocked` |
|
|
161
|
+
| `notifyOnApproval` | — | `true` | 等审批决定时通知 |
|
|
162
|
+
| `notifyOnQuestion` | — | `true` | 等用户回答时通知 |
|
|
163
|
+
| `questionDelayMs` | — | `2500` | 提问通知去抖窗口 |
|
|
164
|
+
| `approvalDelayMs` | — | `3000` | 审批通知去抖窗口 |
|
|
165
|
+
| `template` | — | 见下 | 会话结束通知格式 |
|
|
166
|
+
| `questionTemplate` | — | 见下 | 提问通知格式 |
|
|
167
|
+
| `approvalTemplate` | — | 见下 | 审批请求通知格式 |
|
|
168
|
+
| `includeSubagents` | — | `false` | 子会话(subagent)也通知? |
|
|
169
|
+
| `summaryChars` | — | `120` | `{reply}` 纯文本化后截断长度 |
|
|
170
|
+
| `timeoutMs` | — | `8000` | 单次 HTTP 超时,失败自动重试 1 次 |
|
|
171
|
+
| `dryRun` | — | `true` | **默认开**:只打日志不发消息。确认配置再关 |
|
|
172
|
+
| `traceFile` | — | `''` | 可选 JSONL 诊断轨迹(排障),空则不记 |
|
|
173
|
+
|
|
174
|
+
`endpoint` / `token` / `targetType` / `targetId` 只在 `transport: onebot` 旧直连路径用,对应 `DSH_QQ_NOTIFY_URL` 等环境变量。
|
|
175
|
+
|
|
176
|
+
### 密钥走环境变量
|
|
177
|
+
|
|
178
|
+
字符串字段支持 `${NAME}` / `${NAME:-默认值}` 插值。范围:`gotifyUrl`、`gotifyToken`、`endpoint`、`token`、`targetId`、`gotifyHeaders` 的值,`targets[]` 的 `url` / `token`。
|
|
179
|
+
|
|
180
|
+
变量未设或为空,展开成空串。该目标缺 token 就跳过,记 warning。**不发字面量** `${...}`。插值在每次投递前解析,密钥不进日志。
|
|
181
|
+
|
|
182
|
+
```yaml
|
|
183
|
+
- id: dsh-notify
|
|
184
|
+
config:
|
|
185
|
+
gotifyUrl: '${DSH_GOTIFY_URL}'
|
|
186
|
+
gotifyToken: '${DSH_GOTIFY_TOKEN}'
|
|
187
|
+
targets:
|
|
188
|
+
- name: qq-home
|
|
189
|
+
urlEnv: DSH_GOTIFY_URL
|
|
190
|
+
tokenEnv: DSH_GOTIFY_TOKEN
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`targets[]` 也支持 `urlEnv` / `tokenEnv`:直接写变量名,优先于字面量字段。整表覆盖的环境变量优先级最高:`DSH_QQ_NOTIFY_GOTIFY_URL`、`DSH_QQ_NOTIFY_GOTIFY_TOKEN`、`DSH_QQ_NOTIFY_TARGETS` 等(见上表)。
|
|
194
|
+
|
|
195
|
+
### 多设备:都能发,也能分清是谁
|
|
196
|
+
|
|
197
|
+
公网网关对任何来源 IP 开放(按 token/IP 限流)。其他设备不用部 relay,不用 NapCat,不用开本机端口。
|
|
198
|
+
|
|
199
|
+
1. **设备身份**:`deviceName` 留空自动取 `os.hostname()`。建议设 `deviceLabel`(办公本、家里的服务器),渲染进 `{device}`。
|
|
200
|
+
2. **各自一套 token**:Gotify 里给每台设备建一个 application(一个「系列」)。token 用环境变量注入,别每台共用一把:
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
export DSH_QQ_NOTIFY_DEVICE='laptop-01'
|
|
204
|
+
export DSH_QQ_NOTIFY_DEVICE_LABEL='随身本'
|
|
205
|
+
export DSH_QQ_NOTIFY_GOTIFY_TOKEN='gtfya.该设备的token'
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
系列不同,QQ 收件人也能在 relay 侧不同(见 relay 路由表)。
|
|
209
|
+
|
|
210
|
+
3. **一套配置分发多台设备**:用 `targets` + `devices` 让每个目标只对命中设备生效。`devices` 空 = 所有设备都发:
|
|
211
|
+
|
|
212
|
+
```yaml
|
|
213
|
+
targets:
|
|
214
|
+
- name: qq-home
|
|
215
|
+
url: 'https://notify.example.com'
|
|
216
|
+
token: 'gtfya.home-series-token'
|
|
217
|
+
priority: 3
|
|
218
|
+
devices: ['办公本']
|
|
219
|
+
- name: qq-laptop
|
|
220
|
+
url: 'https://notify.example.com'
|
|
221
|
+
token: 'gtfya.laptop-series-token'
|
|
222
|
+
priority: 5
|
|
223
|
+
devices: ['laptop-01']
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
配 `targets` 后不读 `gotifyUrl` / `gotifyToken` / `gotifyPriority`。每目标可单设 `priority`。一条事件并发发所有命中目标,一个失败不影响其他。
|
|
227
|
+
|
|
228
|
+
### 自定义消息格式
|
|
229
|
+
|
|
230
|
+
正文由模板决定。只改 `template` / `questionTemplate` / `approvalTemplate`:
|
|
231
|
+
|
|
232
|
+
```yaml
|
|
233
|
+
template: |
|
|
234
|
+
[DSH] 会话{status}
|
|
235
|
+
设备: {device}
|
|
236
|
+
会话: {sessionId}
|
|
237
|
+
目录: {cwd}
|
|
238
|
+
结果: {status}
|
|
239
|
+
错误: {error}
|
|
240
|
+
回复: {reply}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
会话结束(`template`)可用:
|
|
244
|
+
|
|
245
|
+
| 占位符 | 值 |
|
|
246
|
+
|---|---|
|
|
247
|
+
| `{status}` | 中文结果:完成 / 出错 / 被中止 / 被阻塞 |
|
|
248
|
+
| `{kind}` | 原始原因:`completed` / `error` / `aborted` / `blocked` |
|
|
249
|
+
| `{device}` | `deviceLabel`,默认主机名 |
|
|
250
|
+
| `{host}` | `deviceName`(默认 `os.hostname()`) |
|
|
251
|
+
| `{sessionId}` | 会话 id 去 `session-` 前缀,取前 8 位 |
|
|
252
|
+
| `{cwd}` | 会话工作目录 |
|
|
253
|
+
| `{reply}` | 最后一条 assistant 文本,去 Markdown,按 `summaryChars` 截断 |
|
|
254
|
+
| `{error}` | 失败信息(仅 `error` 有值),去 Markdown,截 120 字 |
|
|
255
|
+
| `{date}` / `{time}` | 本机日期 / 时间 |
|
|
256
|
+
|
|
257
|
+
提问通知额外可用 `{question}` / `{detail}` / `{options}`。审批通知额外可用 `{tool}` / `{reason}`。三类模板都支持 `{device}`、`{host}`、`{sessionId}`、`{cwd}`、`{date}`、`{time}`。
|
|
258
|
+
|
|
259
|
+
`{reply}` / `{error}` / 审批 `{reason}` 先转**纯文本**:代码块整段丢;行内代码留文字;标题/列表符号/表格竖线/加粗斜体/链接语法全去;连续空白压一个空格。`session_id` 这类下划线标识符不受影响。
|
|
260
|
+
|
|
261
|
+
两条替换规则:
|
|
262
|
+
|
|
263
|
+
- **值为空的行整行删**。上例 `completed` 时「错误: {error}」自动消失。不用两套模板。
|
|
264
|
+
- **不认识的占位符原样保留**,方便发现拼写错误。`{sesionId}` 会原样出现。
|
|
265
|
+
|
|
266
|
+
效果:
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
[DSH] 会话完成
|
|
270
|
+
设备: 办公本
|
|
271
|
+
会话: 878e75f4
|
|
272
|
+
目录: /root/core
|
|
273
|
+
结果: 完成
|
|
274
|
+
回复: 部署完成,3 个服务均已健康
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### 出口(Gotify 网关)
|
|
278
|
+
|
|
279
|
+
网关收 `POST {gotifyUrl}/message`,body `{title, message, priority}`,鉴权 `X-Gotify-Key`。正文按「首行当标题、其余当正文」拆,relay 再拼回「标题 + 换行 + 正文」。
|
|
280
|
+
|
|
281
|
+
`deviceInTitle: true` 时标题变「[设备名] 原标题」。`gotifyHeaders` 自定义头合并进请求,但 `X-Gotify-Key` 始终以当前目标 token 为准,自定义头不能覆盖。
|
|
282
|
+
|
|
283
|
+
历史:2026-11-07 前是 NapCat/OneBot 直连(`endpoint` + `targetId`)。NapCat 容器与 AstrBot 已删。不要再按旧文档在 NapCat WebUI 开 HTTP 服务器。
|
|
284
|
+
|
|
285
|
+
### 从 @local/dsh-plugin-qq-notify 迁移
|
|
286
|
+
|
|
287
|
+
直接合并 `@local/dsh-plugin-qq-notify` 0.2.0:模板、占位符、环境变量名、投递语义不变。只搬进 `@xi4z/dsh-utils`,补配置表单与热生效。
|
|
288
|
+
|
|
289
|
+
1. profile `package.json` 去掉 `@local/dsh-plugin-qq-notify`(依赖与 `dsh.profile.bundles` 两处),改装本包。重启后旧 bundle 的 `qq-notify` 挂载项消失。
|
|
290
|
+
2. 旧 `cordis.patch.yml` 里 `id: qq-notify` 行下的 `config:`,整体挪到新 `id: dsh-notify` 行下。字段名一致,不改写。
|
|
291
|
+
3. 两个 id 不能同时挂,否则同一事件发两遍。旧命名空间 `qq-notify` 的存量值不读取。按第 2 步搬。
|
|
292
|
+
4. 环境变量(`DSH_QQ_NOTIFY_*`)不改。
|
|
293
|
+
|
|
294
|
+
## 组件四:技能面板
|
|
295
|
+
|
|
296
|
+
右侧栏 guide 里的「技能」卡片,或 设置 → 插件 → 技能面板。列出当前会话能读取到的 Skill(模型技能目录),每行一个开关。
|
|
297
|
+
|
|
298
|
+
开关语义:关掉 = 在 `ctx.skills.snapshot()` / `list()` 里把该技能标成 `modelInvocable: false`,模型下一轮拿到的 `` `<available_skills>` `` 里不再出现;**手动 `/名称` 仍可加载**。不是 modelInvocable 的技能(只能手动调用的)显示「仅手动」,开关禁用。
|
|
299
|
+
|
|
300
|
+
数据来源:`GET /api/dsh-utils/skill-panel/list`(Connection owner 认证)。带 `sessionId` 时用该会话的 cwd 与 preset skill 层;不带时用宿主默认工作目录。返回按名称排序,`enabled = modelInvocable && !disabled`。
|
|
301
|
+
|
|
302
|
+
持久化:写 profile settings 的 `dsh-skill-panel` 命名空间:
|
|
303
|
+
|
|
304
|
+
```yaml
|
|
305
|
+
- id: dsh-skill-panel
|
|
306
|
+
config:
|
|
307
|
+
disabledSkills: []
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
`disabledSkills` 是 volatile,保存即生效、不用重启。面板本身不落盘。
|
|
311
|
+
|
|
312
|
+
注意:开关只影响模型可见性;`/name` 手动调用、以及已经加载进会话的技能正文都不会被删。下一轮对话才刷新模型目录。
|
|
313
|
+
|
|
314
|
+
### 技能仓库同步(并入组件一)
|
|
315
|
+
|
|
316
|
+
「技能仓库」原来是独立的 `dsh-utils-ui` 行;现在它是递归技能组件的一部分,由 `skill-recursive` 行注册路由。入口是右侧栏指南里的「技能仓库」卡片(原来插件页的独立配置页不再存在,仓库设置在面板里改)。
|
|
317
|
+
|
|
318
|
+
与递归发现共用一行:目标目录里的嵌套 `SKILL.md` 由同一个组件的递归发现读取,同步后下一轮技能目录更新。
|
|
319
|
+
|
|
320
|
+
面板字段:仓库地址、分支、目标目录、密钥路径(可选)、Deploy Key、递归子模块。点「同步(拉取)」:
|
|
321
|
+
|
|
322
|
+
- 目标不存在:`git clone --depth 1 --branch <branch> --single-branch`;
|
|
323
|
+
- 目标已存在:必须是同一仓库的 git checkout,且当前分支等于配置分支,否则拒绝;只做 `fetch` + `merge --ff-only`,不 reset、不 force、不覆盖;
|
|
324
|
+
- 子模块(可选):同步后 `git submodule sync --recursive` + `update --init --recursive`,失败只记 warning;
|
|
325
|
+
- 只拉取,不推送。
|
|
326
|
+
|
|
327
|
+
默认值:`repoUrl: https://github.com/xi4z/skills`、`branch: Agent`、`targetDir: $DSH_HOME/skills/herskill`、`recurseSubmodules: true`。
|
|
328
|
+
|
|
329
|
+
Deploy Key:
|
|
330
|
+
|
|
331
|
+
- 直接粘贴到面板:写到 `$DSH_HOME/storages/dsh-utils-ui.deploy-key`(600),只交给 git 子进程,接口不回显、不写日志;
|
|
332
|
+
- 或填「密钥路径」指向已有私钥(如 `~/.ssh/xi4z_skills_hermes_deploy`),路径优先;
|
|
333
|
+
- 公开 `https://` / `file://` 可以免密钥;配了密钥的 GitHub/GitLab/Gitee 等 HTTPS 仓库会转成 SSH 拉取。
|
|
334
|
+
|
|
335
|
+
配置与最近一次同步记录存在 `$DSH_HOME/storages/dsh-utils-ui.json`(600),不在 profile patch 里;要重置就删这个文件和 `.deploy-key`。
|
|
336
|
+
|
|
337
|
+
目标目录默认在 `~/.dsh/skills` 下,递归发现会读取其中的 `SKILL.md`;同步后下一轮技能目录更新。
|
|
338
|
+
|
|
339
|
+
站内路由与存储沿用 `dsh-utils-ui` 名字(`/api/dsh-utils-ui/*`、`dsh-utils-ui.json`、`dsh-utils-ui.deploy-key`),旧 profile 的设置与密钥无需迁移。
|
|
340
|
+
|
|
341
|
+
## 配置写法
|
|
342
|
+
|
|
343
|
+
覆盖行只写 `id` 与 `config`,`name` 交给 bundle:
|
|
344
|
+
|
|
345
|
+
```yaml
|
|
346
|
+
- id: skill-recursive
|
|
347
|
+
config:
|
|
348
|
+
maxDepth: 6
|
|
349
|
+
extraRoots:
|
|
350
|
+
- D:/Core/Projects/Skill
|
|
351
|
+
- id: dsh-approval-policy
|
|
352
|
+
config:
|
|
353
|
+
origins: [subagent, scheduled, cron]
|
|
354
|
+
windowSeconds: 300
|
|
355
|
+
defaultOutcome: rejected
|
|
356
|
+
- id: dsh-notify
|
|
357
|
+
config:
|
|
358
|
+
transport: gotify
|
|
359
|
+
gotifyUrl: https://notify.example.com
|
|
360
|
+
gotifyToken: gtfya.该系列的token
|
|
361
|
+
deviceLabel: 办公本
|
|
362
|
+
dryRun: false
|
|
363
|
+
- id: dsh-skill-panel
|
|
364
|
+
config:
|
|
365
|
+
disabledSkills: []
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
四个组件 id 同时是 settings 命名空间;配置写 `cordis.patch.yml`:bundle 给默认,profile 按 id 覆盖。`@xi4z/dsh-utils-ui` 的包根行让宿主加载 `client.js`;插件页每个挂载项都有配置页,右侧栏还有「技能」和「技能仓库」面板。组件启用/停用、运行状态照常显示。
|
|
369
|
+
|
|
370
|
+
`@xi4z/dsh-utils-ui` 的 `client.js` 用 `ctx.configForms.whileServed(['skill-recursive','dsh-approval-policy','dsh-notify','dsh-skill-panel'], …)` 把四条组件配置页注册到 `plugins.row.config`(key = `@xi4z/dsh-utils#<挂载项 id>`),并注册 `sidebar.right.pane.tab` 技能面板与「技能仓库」面板。四个组件字段全 volatile,写入走宿主 settings 文档,保存即生效;技能仓库的设置走它自己的 JSON 路由,存 storages。
|
|
371
|
+
|
|
372
|
+
## 包结构
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
@xi4z/dsh-utils/
|
|
376
|
+
├── package.json bundle:patch/locale/icon,空入口
|
|
377
|
+
├── pnpm-workspace.yaml
|
|
378
|
+
├── cordis.patch.yml 五行:四个组件包 + 浏览器半侧包
|
|
379
|
+
├── locale/{en,zh}.json bundle 展示名与描述
|
|
380
|
+
├── icon.svg
|
|
381
|
+
├── skills/dsh-approval-policy-config/SKILL.md
|
|
382
|
+
├── src/index.ts bundle 空入口
|
|
383
|
+
└── packages/
|
|
384
|
+
├── skill-recursive/ @xi4z/dsh-utils-skill-recursive
|
|
385
|
+
│ ├── package.json
|
|
386
|
+
│ ├── src/{index.ts,ui-host.ts}
|
|
387
|
+
│ ├── lib/…
|
|
388
|
+
│ ├── locale/{en,zh}.json
|
|
389
|
+
│ └── test/…
|
|
390
|
+
├── approval-policy/ @xi4z/dsh-utils-approval-policy
|
|
391
|
+
├── notify/ @xi4z/dsh-utils-notify
|
|
392
|
+
├── skill-panel/ @xi4z/dsh-utils-skill-panel
|
|
393
|
+
└── ui/ @xi4z/dsh-utils-ui(client.js + no-op host)
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
每个包是标准的 DSH 插件包:`package.json` 的 `exports["."]` 指向 `lib/index.js`,`@xi4z/dsh-utils-ui` 额外声明 `dsh.client` 与 `./client`。加组件就是新建 `packages/<名>/`(`src/index.ts` + `locale/` + `package.json`),再在 bundle 的 `cordis.patch.yml` 里加一行、在根 `package.json` 的依赖里加 `workspace:^`。
|
|
397
|
+
|
|
398
|
+
## 开发
|
|
399
|
+
|
|
400
|
+
```sh
|
|
401
|
+
pnpm install
|
|
402
|
+
pnpm build # 根空入口 + 各包 tsc -> lib/
|
|
403
|
+
pnpm test # 构建 + client.js 语法检查 + 根布局守卫 + 各包 node --test(163 个用例)
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## 兼容性
|
|
407
|
+
|
|
408
|
+
DeepSeek Harness `0.2.2-rc.1` 及以上。Node.js 22.19 及以上。运行时依赖 `@deepseek-ai/schemastery`;`@xi4z/dsh-utils-ui` 只依赖宿主提供的 React 运行时。技能面板需要宿主带右侧栏(web 组合默认带)。
|
|
409
|
+
|
|
410
|
+
## License
|
|
411
|
+
|
|
412
|
+
[MIT](LICENSE)
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# dsh-utils — the bundle layer for four independently packaged components.
|
|
2
|
+
#
|
|
3
|
+
# This package carries no component code of its own. Every row mounts another
|
|
4
|
+
# package of this workspace, the same shape as the official experimental
|
|
5
|
+
# bundles: the bundle package owns the patch + locale + icon, the components
|
|
6
|
+
# live in packages/ (published or linked separately), and their package names
|
|
7
|
+
# resolve from the profile's node_modules.
|
|
8
|
+
#
|
|
9
|
+
# skill-recursive — recursive SKILL.md discovery in nested skill folders,
|
|
10
|
+
# plus the skill-repository sync host (panel routes,
|
|
11
|
+
# deploy key, pull-only Git sync).
|
|
12
|
+
# dsh-approval-policy — unattended approval gate: subagent/scheduled/cron
|
|
13
|
+
# approval requests wait a bounded window, then settle
|
|
14
|
+
# with a fail-closed default instead of hanging forever.
|
|
15
|
+
# dsh-notify — session notifications: a turn ending, a pending
|
|
16
|
+
# approval, or a pending question is pushed through a
|
|
17
|
+
# Gotify gateway, tagged with this device's name.
|
|
18
|
+
# dsh-skill-panel — settings-page skill switchboard: lists the skills the
|
|
19
|
+
# current session can read and hides disabled ones from
|
|
20
|
+
# the model catalog while keeping them manually
|
|
21
|
+
# invocable.
|
|
22
|
+
#
|
|
23
|
+
# The fifth row, dsh-utils-ui, is not a utility component: it is the browser
|
|
24
|
+
# half's package, whose no-op entry makes DSH's client-module scanner serve its
|
|
25
|
+
# client.js. Row ids double as settings namespaces and stay stable.
|
|
26
|
+
|
|
27
|
+
- insert:
|
|
28
|
+
- id: skill-recursive
|
|
29
|
+
name: '@xi4z/dsh-utils-skill-recursive'
|
|
30
|
+
config: {}
|
|
31
|
+
- id: dsh-approval-policy
|
|
32
|
+
name: '@xi4z/dsh-utils-approval-policy'
|
|
33
|
+
config: {}
|
|
34
|
+
- id: dsh-notify
|
|
35
|
+
name: '@xi4z/dsh-utils-notify'
|
|
36
|
+
config:
|
|
37
|
+
# 留空 = 内置默认。下面只列出最常改的几项,完整字段见 README。
|
|
38
|
+
#
|
|
39
|
+
# 出口:Gotify 网关。url/token 建议用环境变量注入,避免把凭据写进仓库:
|
|
40
|
+
# DSH_QQ_NOTIFY_GOTIFY_URL / DSH_QQ_NOTIFY_GOTIFY_TOKEN
|
|
41
|
+
transport: gotify
|
|
42
|
+
# 密钥可以不落盘:'${VAR}' 在投递前从环境变量展开(也支持 targets[].tokenEnv),
|
|
43
|
+
# 或整段用 DSH_QQ_NOTIFY_GOTIFY_URL / DSH_QQ_NOTIFY_GOTIFY_TOKEN 覆盖。
|
|
44
|
+
# 先只记日志:确认能收到再改成 false(或在 profile patch 里覆盖)。
|
|
45
|
+
dryRun: true
|
|
46
|
+
# 设备名留空 = 自动取主机名;deviceLabel 是渲染到 {device} 的显示名。
|
|
47
|
+
deviceName: ''
|
|
48
|
+
deviceLabel: ''
|
|
49
|
+
notifyOnReasons:
|
|
50
|
+
- completed
|
|
51
|
+
- error
|
|
52
|
+
- aborted
|
|
53
|
+
notifyOnApproval: true
|
|
54
|
+
notifyOnQuestion: true
|
|
55
|
+
- id: dsh-skill-panel
|
|
56
|
+
name: '@xi4z/dsh-utils-skill-panel'
|
|
57
|
+
config:
|
|
58
|
+
# 模型技能目录里隐藏的技能名;面板开关写入这里,热生效。
|
|
59
|
+
disabledSkills: []
|
|
60
|
+
# 浏览器半侧:独立包 dsh-utils-ui 的 no-op 入口,只让宿主提供 client.js。
|
|
61
|
+
- id: dsh-utils-ui
|
|
62
|
+
name: '@xi4z/dsh-utils-ui'
|
|
63
|
+
config: {}
|
package/icon.svg
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64" role="img" aria-label="Nested folders and a bounded approval window">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
4
|
+
<stop offset="0" stop-color="#1d2f57"/>
|
|
5
|
+
<stop offset="1" stop-color="#0d1a33"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
<linearGradient id="sheet" x1="0" y1="0" x2="0" y2="1">
|
|
8
|
+
<stop offset="0" stop-color="#ffffff"/>
|
|
9
|
+
<stop offset="1" stop-color="#d9e4ff"/>
|
|
10
|
+
</linearGradient>
|
|
11
|
+
</defs>
|
|
12
|
+
<rect width="64" height="64" rx="14" fill="url(#bg)"/>
|
|
13
|
+
<path d="M8 20.5A3.5 3.5 0 0 1 11.5 17h8l3 3h14a3.5 3.5 0 0 1 3.5 3.5v4" fill="none" stroke="#4a6bb5" stroke-width="2.4" stroke-linecap="round" opacity="0.75"/>
|
|
14
|
+
<path d="M12 26.5A3 3 0 0 1 15 23.5h7l2.6 2.6h11.4a3 3 0 0 1 3 3v2" fill="none" stroke="#6d92e6" stroke-width="2.4" stroke-linecap="round" opacity="0.9"/>
|
|
15
|
+
<rect x="15" y="29" width="19" height="14" rx="3" fill="#5f8cf0"/>
|
|
16
|
+
<rect x="18" y="32" width="13" height="8" rx="1.8" fill="url(#sheet)"/>
|
|
17
|
+
<path d="M20.5 35h8M20.5 37.6h5.5" stroke="#33518f" stroke-width="1.4" stroke-linecap="round"/>
|
|
18
|
+
<path d="M44 17.5l10 3.4v7.6c0 6-4 10.2-10 12.3-6-2.1-10-6.3-10-12.3v-7.6z" fill="none" stroke="#ffd166" stroke-width="2.6" stroke-linejoin="round"/>
|
|
19
|
+
<path d="M44 24v5.4l3.4 2.1" fill="none" stroke="#ffd166" stroke-width="2.4" stroke-linecap="round"/>
|
|
20
|
+
<circle cx="44" cy="29" r="1.4" fill="#ffd166"/>
|
|
21
|
+
</svg>
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dsh-utils` bundle entry: the bundle package carries only the patch layer,
|
|
3
|
+
* bundle metadata and assets. Every utility component is its own package under
|
|
4
|
+
* `packages/`, mounted by name from `cordis.patch.yml` — the same shape as the
|
|
5
|
+
* official experimental bundles, whose own entry is an empty module.
|
|
6
|
+
*
|
|
7
|
+
* @module dsh-utils
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dsh-utils` bundle entry: the bundle package carries only the patch layer,
|
|
3
|
+
* bundle metadata and assets. Every utility component is its own package under
|
|
4
|
+
* `packages/`, mounted by name from `cordis.patch.yml` — the same shape as the
|
|
5
|
+
* official experimental bundles, whose own entry is an empty module.
|
|
6
|
+
*
|
|
7
|
+
* @module dsh-utils
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAA"}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Harness Utilities",
|
|
4
|
+
"description": "One bundle, four components: recursive SKILL.md discovery in nested skill folders, an unattended approval gate that bounds approval requests before settling fail-closed, turn-end / approval / question notifications pushed through a Gotify gateway, and a skill panel that lists and switches the skills the current session can read."
|
|
5
|
+
}
|
|
6
|
+
}
|
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xi4z/dsh-utils",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "DeepSeek Harness utility bundle: four independently mounted components (recursive skill discovery + Git skill-repository sync, unattended approval gate, session notifications, skill panel) and their browser UI.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dsh",
|
|
7
|
+
"dsh-plugin",
|
|
8
|
+
"dsh-bundle",
|
|
9
|
+
"deepseek-harness",
|
|
10
|
+
"skills",
|
|
11
|
+
"skill-panel",
|
|
12
|
+
"skill-discovery",
|
|
13
|
+
"approval",
|
|
14
|
+
"unattended",
|
|
15
|
+
"notify",
|
|
16
|
+
"gotify",
|
|
17
|
+
"qq",
|
|
18
|
+
"multi-device"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "xi4z",
|
|
22
|
+
"homepage": "https://github.com/xi4z/dsh-utils",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/xi4z/dsh-utils.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/xi4z/dsh-utils/issues"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "./lib/index.js",
|
|
32
|
+
"types": "./lib/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./lib/index.d.ts",
|
|
36
|
+
"import": "./lib/index.js",
|
|
37
|
+
"default": "./lib/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
40
|
+
"./locale/*.json": "./locale/*.json",
|
|
41
|
+
"./icon": "./icon.svg",
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"lib",
|
|
46
|
+
"cordis.patch.yml",
|
|
47
|
+
"locale",
|
|
48
|
+
"skills",
|
|
49
|
+
"icon.svg",
|
|
50
|
+
"README.md",
|
|
51
|
+
"LICENSE"
|
|
52
|
+
],
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22.19.0"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@xi4z/dsh-utils-approval-policy": "^0.3.0",
|
|
58
|
+
"@xi4z/dsh-utils-notify": "^0.3.0",
|
|
59
|
+
"@xi4z/dsh-utils-skill-panel": "^0.3.0",
|
|
60
|
+
"@xi4z/dsh-utils-skill-recursive": "^0.3.0",
|
|
61
|
+
"@xi4z/dsh-utils-ui": "^0.3.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^24.0.0",
|
|
65
|
+
"typescript": "~5.9.0"
|
|
66
|
+
},
|
|
67
|
+
"dsh": {
|
|
68
|
+
"bundle": {
|
|
69
|
+
"patch": "./cordis.patch.yml"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"dsh": ">=0.2.2-rc.1 <0.4.0-0"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"access": "public"
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"build": "tsc -p tsconfig.json && pnpm -r --filter \"./packages/*\" run build",
|
|
80
|
+
"check": "tsc --noEmit -p tsconfig.json && pnpm -r --filter \"./packages/*\" run check",
|
|
81
|
+
"test": "pnpm build && node --check packages/ui/client.js && node --test test/*.test.mjs && pnpm -r --filter \"./packages/*\" run test",
|
|
82
|
+
"publish:components": "pnpm -r --filter \"./packages/*\" publish --access public --no-git-checks",
|
|
83
|
+
"publish:bundle": "pnpm publish --access public --no-git-checks"
|
|
84
|
+
}
|
|
6
85
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dsh-approval-policy-config
|
|
3
|
+
description: "dsh-utils bundle 里无人值守审批门控组件(挂载项 dsh-approval-policy)的使用与配置指南。审批挂起、approval 挂死、无人值守、超时拒绝、subagent 审批、定时任务审批、审批门控、默认自动审批、自动审批内容回传等场景,或要配置这个门控时先读本指南:六个键(origins/sessions/windowSeconds/defaultOutcome/defaultPermissionPreset/autoReviewContent)的默认值、cordis.patch.yml 挂载块 config: 段示例、ask_user_question 配置向导、行为边界速查。触发词:approval-policy、windowSeconds、defaultPermissionPreset、autoReviewContent、审批门控。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 无人值守审批门控使用指南(dsh-utils / dsh-approval-policy)
|
|
7
|
+
|
|
8
|
+
> dsh-utils bundle 的 approval-policy 组件:挂在宿主 `'approval/request'` waterfall 链首
|
|
9
|
+
> (prepend 注册)的竞速门控器。声明为无人值守的请求先 `next()` 交给下游交互面,
|
|
10
|
+
> **窗口内有人答就用人的答案**,窗口耗尽按 fail-closed 默认裁决落定,
|
|
11
|
+
> **turn 立即结束不再挂起**;交互会话默认不变。
|
|
12
|
+
>
|
|
13
|
+
> 这版另有两项配合实验性自动审批(`@deepseek-ai/dsh-experimental-auto-review` 的 `auto` 档)
|
|
14
|
+
> 的能力:`defaultPermissionPreset: auto` 让**新会话默认走自动审批**;
|
|
15
|
+
> `autoReviewContent: true` 让**窗口超时拒绝时把复核内容附进模型读到的工具结果**。
|
|
16
|
+
|
|
17
|
+
## 配置入口
|
|
18
|
+
|
|
19
|
+
持久化在 `cordis.patch.yml` 里审批门控挂载块(id = `dsh-approval-policy`,name =
|
|
20
|
+
`dsh-utils/approval-policy`)的 `config:` 段;entry id 同时就是 settings 命名空间。
|
|
21
|
+
六个键**全部 volatile**,也可以直接在 dsh 设置页热改;改 `cordis.patch.yml` 则需重启 dsh 生效。
|
|
22
|
+
bundle 方式(装好 `dsh-utils`)自动挂载,无需手写挂载块。
|
|
23
|
+
|
|
24
|
+
同一个 bundle 里的另一个组件是递归技能发现(id = `skill-recursive`),两者互不依赖,
|
|
25
|
+
可以单独禁用其中一个挂载项。
|
|
26
|
+
|
|
27
|
+
## 配置键
|
|
28
|
+
|
|
29
|
+
| 键 | 类型 | 默认 | 说明 |
|
|
30
|
+
|---|---|---|---|
|
|
31
|
+
| `origins` | `(subagent\|scheduled\|cron\|all)[]` | `[subagent, scheduled]` | 判定为无人值守的来源;`all` 是 opt-in 的全门控 |
|
|
32
|
+
| `sessions` | `string[]`(glob) | `[]` | 按 agent id glob 点名会话,命中即门控该会话**所有** turn(与 `origins` 取并集) |
|
|
33
|
+
| `windowSeconds` | `number` 0..86400 | `60` | 应答窗口(秒);`0` = 立即拒绝且**不**问下游 |
|
|
34
|
+
| `defaultOutcome` | `rejected \| unavailable` | `rejected` | 超时落定值;**配置层没有 allowed-once**(fail-closed 红线,schema 枚举就不含) |
|
|
35
|
+
| `defaultPermissionPreset` | `string` | `''` | 新会话写入的权限档;`''` = 不动宿主默认档,`auto` = 默认实验性自动审批(需自动审批 bundle),也可写其它已配置档名 |
|
|
36
|
+
| `autoReviewContent` | `boolean` | `true` | 窗口拒绝的是自动审批发起的请求时,把复核内容附进模型读到的工具结果 |
|
|
37
|
+
|
|
38
|
+
判定粒度:`sessions` 命中与 `all` 是会话级/全局;`subagent` 看 `session.header.origin ===
|
|
39
|
+
'subagent'`(会话级);`scheduled` / `cron` 看会话**最后一条溯源** user 消息的 `source.kind`
|
|
40
|
+
(`schedule` / `cron`,turn 级;`runtime-context` / `skill-catalog` 等合成注入会被跳过,
|
|
41
|
+
不污染判定)——人插过话就不门控("有没有人在看"语义;dsh 0.2.0 timed ask 的迟到回答
|
|
42
|
+
`user-question-reply` 同理算人在场)。
|
|
43
|
+
`cron` 需要 dsh-cron 自带 `source.kind: 'cron'` 的补丁版。
|
|
44
|
+
|
|
45
|
+
挂载块形状(`~/.dsh/cordis.patch.yml` 或某个 profile 的 cordis.patch.yml):
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
- id: dsh-approval-policy
|
|
49
|
+
name: dsh-utils/approval-policy
|
|
50
|
+
config:
|
|
51
|
+
origins: [subagent, scheduled, cron] # cron 需 dsh-cron 的 source kind 补丁版
|
|
52
|
+
windowSeconds: 300
|
|
53
|
+
defaultOutcome: rejected
|
|
54
|
+
defaultPermissionPreset: auto # 新会话默认走实验性自动审批
|
|
55
|
+
autoReviewContent: true # 超时拒绝时把复核内容交给模型
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 交互式配置向导(ask_user_question)
|
|
59
|
+
|
|
60
|
+
用户抱怨审批挂起时,不要甩配置表让对方自己读——先用 `ask_user_question` 问清期望,
|
|
61
|
+
再映射到键:
|
|
62
|
+
|
|
63
|
+
1. **要门控哪些来源** → `origins`:`subagent`(子代理会话专有)/`scheduled`(定时任务)/
|
|
64
|
+
`cron`(cron 任务)/`all`(全部审批都门控)。多选;先问清是不是只想治某一类。
|
|
65
|
+
2. **有没有要整会话点名的** → `sessions`:有的话问 agent id 或前缀,按 glob 写(如 `ops-*`);
|
|
66
|
+
命中即门控该会话**所有** turn,与 `origins` 取并集。没有就留空数组。
|
|
67
|
+
3. **窗口多长** → `windowSeconds`:问能接受挂多久(默认 60 秒);要"绝不等待、立刻拒"
|
|
68
|
+
填 `0`(立即拒绝且**不**问下游);想要"人还在就还能答"就给个几十秒到几分钟的数。
|
|
69
|
+
4. **超时落什么** → `defaultOutcome`:`rejected`(默认,拒)或 `unavailable`(下游不可用)。
|
|
70
|
+
**必须强调:没有 `allowed-once`(本次放行)这一档**——无人值守的默认裁决必须 fail-closed,
|
|
71
|
+
超时就是拒;想放行就让窗口内真的有人答。
|
|
72
|
+
5. **要不要新会话默认走自动审批** → `defaultPermissionPreset`:要就填 `auto`(前提:
|
|
73
|
+
profile 里装了 `@deepseek-ai/dsh-experimental-auto-review` bundle,否则 `agent/created`
|
|
74
|
+
直接报错点名缺哪个 bundle);只想修「挂起」不想改默认档就留 `''`。也可以填其它已配置
|
|
75
|
+
档名(如 `workspace-write`)。注意 `auto` 档是 `danger-full-access` + `ask` 的组合,
|
|
76
|
+
先确认用户接受这个力度。
|
|
77
|
+
6. **超时拒绝要不要把复核内容交给模型** → `autoReviewContent`:默认 `true`,即窗口拒绝的
|
|
78
|
+
请求若来自自动审批,模型会读到复核原文;不想回传就关掉。
|
|
79
|
+
7. **落盘** → 把结果写进 `cordis.patch.yml` 挂载块的 `config:` 段(只写用户实际确认过的键,
|
|
80
|
+
其余留默认),并提醒**重启 dsh 生效**(设置页热改则即时生效)。
|
|
81
|
+
|
|
82
|
+
## 行为边界速查
|
|
83
|
+
|
|
84
|
+
- **交互会话不门控**:未命中 `sessions` 名单、也未命中任何 origin 的 turn 立即 `next()` 透传,
|
|
85
|
+
交互默认一字不变。
|
|
86
|
+
- **宿主 policy 优先**:会话级 `approval/policy`(ask|never)短路在 waterfall 之前,
|
|
87
|
+
`never` 直接 auto-reject,与本组件零冲突;本组件是"先试 N 秒再拒"的时间窗形态。
|
|
88
|
+
- **审计宿主落**:`approval/asked` + `approval/decided` 由宿主写进会话日志,本组件不写日志,
|
|
89
|
+
超时拒绝同样在 transcript 里可追溯。
|
|
90
|
+
- **窗口内下游答了就用下游的答案**;空链瞬间 fail-closed `'unavailable'` 原样透传。
|
|
91
|
+
- **turn 中止**由宿主信号竞速收 `'cancelled'`,迟到的窗口到期被忽略。
|
|
92
|
+
- **新会话固定档只在新会话上生效**:恢复的、被 seed 的、用户手动切过档的会话保持原档。
|
|
93
|
+
- **复核内容只在「窗口拒绝」时附加**:窗口内被人或其它 answerer 拒的请求不会附加;记录按
|
|
94
|
+
`callId` 单次消费、120 秒过期。
|
|
95
|
+
- **零落盘状态**:组件不写数据文件,也不写会话日志;复核内容走的是宿主已经落定的工具结果
|
|
96
|
+
内容,审计仍由宿主的 `approval/asked` + `approval/decided` 负责。
|