clearai-dsh 0.5.4 → 0.5.6
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 +47 -1
- package/README.md +5 -5
- package/README.zh-CN.md +5 -5
- package/bin/clearai.mjs +21 -2
- package/lib/client.js +33 -5
- package/package.json +1 -1
- package/presets/clearai/agent.cordis.yml +10 -2
- package/presets/clearai/clearai.patch.yml +96 -2
- package/presets/clearai/evaluator.cordis.yml +76 -0
- package/presets/clearai/plugins/clearai-evaluator-face.js +60 -0
- package/presets/clearai/plugins/clearai-kernel.js +244 -20
- package/presets/clearai/skills/clearai-loop/SKILL.md +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
-
## [
|
|
5
|
+
## [0.5.6] — 2026-10-19
|
|
6
|
+
|
|
7
|
+
**适配 DSH 0.2.1:独立评估者在新宿主上重新派得出去,且仍然只读(issue #38);交给评估者的材料有了体积闸门(issue #36),复跑副本能被认出是副本(issue #35);另补上递归删除闸门的几处绕过。**
|
|
8
|
+
|
|
9
|
+
DSH 0.2.1-alpha.2 把 `subagents.start(provider, request)` 换成了 `startActivation(spec)`,而 `engines.dsh` 拦不住新宿主:装得上、跑得起,直到第一次派评估者才以 `audit_dispatch_failed` 失败,结案与 L3+ 交付都过不去。桌面版 0.2.1-rc.2 正是这一代。
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **评估者在 0.2.1 上派得出去**(issue #38,报告者 devil233-ui):内核按方法是否存在选入口——有 `start` 走旧路径(逐次请求给 persona / toolFilter),只有 `startActivation` 时以 `agentPreset: 'clearai-evaluator'`、`delivery: 'caller'` 派遣;回包统一成 `{ id, result, dispose }`,账本、目录对账与落定照旧。两个入口都不在时,挂载那一刻就警告,派遣时 fail-closed 并点名原因。
|
|
14
|
+
- **新宿主上评估者仍然只读**:0.2.1 的 `startActivation` 会**静默丢掉**请求里的 `persona` / `toolFilter`。照旧塞进请求而不选预设,评估者会加入主会话的 ClearAI 组合,拿到写工具与主人格(issue 里的临时补丁正是这样)。所以新增随包的评估者预设 `clearai-evaluator`:只读文件面(`tool-fs` 关掉 `write` / `edit`)、搜索、shell 与后台任务;再由 `clearai-evaluator-face` 把宿主全局层继承下来的工具(`write` / `edit` / `subagent` / `web_*` / goal 工具……)从工具清单里遮掉,并在执行处用 guard 拦住白名单外的调用。评估者的工具面与旧入口 `toolFilter` 给的是同一张表。
|
|
15
|
+
- **递归删除闸门的绕过**:pwsh 与 bash 两条规则从前只查命令里**第一段**删除(`Remove-Item a; Remove-Item -Recurse C:\`、`rm a; rm -rf ~` 都能过);pwsh 一条还把 `-Force` 当成递归,认不出 `C:/`、`$env:SystemRoot` 与 `{ … }` 里的命令。现在逐段查,认 pwsh 别名(`ri / rm / rd / del / erase`)与 `-recurse` 的缩写;提权规则不区分大小写。
|
|
16
|
+
- `.gitattributes` 开头的 BOM 让 git 把第一行注释读成无效属性(`is not a valid attribute name`)。
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **评估材料体积闸门**(issue #36,报告者 GameKingdomNatives):L3+ 交付随交付带给评估者的未解释项(`anomalies`)有了上限——每次至多 4 条、每条至多 400 字,可用预设配置 `auditMaterialLimits: { anomalies, anomalyChars }` 调整,写错在装配期就抛错。超限**拒绝而不截断**(从前单条超过 400 字是静默截断),在落账之前拒,被拒的这一批不留记录,也不算连拦;拒因写明超了多少、怎么压(同源合并,读数与推导写进产物文件)。只量 `anomalies`:observations 的 note 与 `basis` 并不进评估者的任务书(`basis` 只用于 L2 自判),限它们减不了评估者的负担。
|
|
21
|
+
- **复跑副本做了记号**(issue #35,报告者 GameKingdomNatives):副本根目录写一份 `.clearai-rerun.json`(原工作区与副本路径、用途),原工作区不写;任务书告诉评估者这是一次性副本,并提醒复跑可能写进被检程序按项目名定位的全局用户数据目录、有改道约定先改道、没有就在裁决里写明可能写到了哪里。项目可在工作区根声明 `.clearai-rerun-env`(每行 `KEY=VALUE`,`{copy}` 换成副本路径),变量随记号写下并列进任务书,评估者复跑前先设上。内核**不**关闭被检项目的采集:评估者要核的数字可能正是采集出来的。
|
|
22
|
+
|
|
23
|
+
### Tests
|
|
24
|
+
|
|
25
|
+
- 模拟宿主可扮演两代子代理入口;`test/run.sh` 把整套内核用例在 `startActivation` 上再跑一遍(两遍各 700/0)。新增评估者工具面插件、两代入口都不在、删除规则绕过与误伤、评估材料闸门(超限拒绝不落账、刚好在限内放行、上限可调、配置写错抛错、L2 不受限)、复跑记号与项目声明变量的用例。
|
|
26
|
+
- `verify-clean-install` 多一项:名册里 `clearai-evaluator` 在场且没有 broken。DSH 0.2.1-rc.2 与 0.2.0-rc.2 上干净安装均 23/0。
|
|
27
|
+
- 桌面版 DSH 0.2.1-rc.2 上的真实评估(`tools/native-headless/audit-wait-probe.mjs`):评估者派出、裁决回到内核、目标 `achieved`;评估者子会话的工具面为 `read, read_image, glob, grep, bash, job_output, job_list, job_kill, structured_output`,主会话不受影响。
|
|
28
|
+
- `tools/native-headless` 增加两个显式开关:`CLEARAI_NATIVE_RUNTIME`(在预注册的 0.2.0-rc.2 之外的宿主上跑兼容性检查,并记入安装记录)与 `CLEARAI_NATIVE_PASS_ENV`(按名转发模型密钥这类环境变量;缺省仍是白名单)。
|
|
29
|
+
|
|
30
|
+
## [0.5.5] — 2026-10-14
|
|
31
|
+
|
|
32
|
+
**Windows 上的硬边界、证据落盘与自检全部补齐;另按社区 issue #33 / #34 做了能做的那部分加固。**
|
|
33
|
+
|
|
34
|
+
这一版来自「在 Windows 上装最新发行版、按真实环境跑一遍」的结果:报告里的 issue #30(社区 PR #31,作者 YunzhouLi-hub)属实,且同一类平台假设在证据捕获与开发工具里还有几处。
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- **全屏退得出**(issue #33):本体图的全屏是自画的覆盖层(`position:fixed`),退出入口原先只是工具条里一个文字链接——没有快捷键、也不保证不被画布盖住,被遮住就只能刷新页面。现在:Escape 退出(window 级监听 + 覆盖层内 `onKeyDown` 两条一起,焦点在哪都能退)、退出入口在全屏时固定浮在右上角(`z-index:41`,高于覆盖层 `40`),并补了 6 条客户端检查(全屏态标记、入口在场且标出快捷键、点击/ Escape 都退出、别的键不误触、非全屏不接 Escape)。
|
|
39
|
+
- **预设不再依赖宿主模板变量**(issue #34):persona 里的 `{{cwd}}` 去掉了。宿主渲染提示词时按**变量表**严格解析,表里没有这个名字就整轮直接抛错(`unknown prompt variable "{{cwd}}" in section …`),而各宿主版本注册的变量并不一样——工作区的绝对路径本来就由宿主的运行时上下文给出,预设只留产品含义。同时加了一道门:预设里再出现 `{{…}}` 必须是宿主注册过的名字(`model` / `cwd`),并拿一条假变量自检这道门抓得到。
|
|
40
|
+
- **shell 硬边界不再只认 bash**(issue #30):危险命令闸、系统所有的路径写检测、L4 不可逆动作人放行三处从前写死 `exec.name === 'bash'`,而本预设按平台只挂一个 shell(win32 只挂 pwsh)——这三道门在 Windows 上**整体失效**。现在统一按 `SHELL_TOOLS = {bash, pwsh}` 判定。
|
|
41
|
+
- 补齐 pwsh 形态的危险写法:递归删除系统路径(`Remove-Item -Recurse C:\`)、远程脚本直灌(`iwr … | iex`)、动态执行下载内容、卷格式化、提权;写动词同时认 bash 与 pwsh(`Remove-Item`/`Set-Content`/`Out-File`…),并认 Windows 的反斜杠相对路径(`clear\knowledge\facts\x.json`)——只认正斜杠的门在 Windows 上会被绕开。写本体三支目录(`clear/ontology/{concepts,relations,entities}`)在两种分隔符下都照旧放行。
|
|
42
|
+
- 拒因文案由 `dangerous bash command` 改为 `dangerous shell command`(门不再只覆盖 bash,文案跟着如实)。
|
|
43
|
+
- **证据捕获(native 验收)不再依赖路径分隔符**:Windows 上 `relative()` 给出反斜杠,于是 `.git`/`.env` 排除、工作区归属校验、注册方法的输入/脚本捕获、report 提取**全都静默失配**。现在统一归一到 `/`,`inside()` 也按归一后的路径判越界。
|
|
44
|
+
- **按行解析不再被检出格式坑**:`tools/sim/config.mjs` 剥注释靠 `$` 收尾,CRLF 的 `\r` 会让注释整行留下、解析当场炸在"读不懂这一行"。同时新增 `.gitattributes`(`eol=lf`)从根上统一行尾,`tools/build-package.mjs` 读源时归一成 LF,保证 Windows 上重建的 `pack/presets/clearai.patch.yml` 与提交件仍逐字节一致。
|
|
45
|
+
- 模拟宿主按平台选 shell(win32 用 pwsh):写死 `bash` 会让内核按平台点的 `pwsh` 在工具表里不存在,核算复检当场「执行未完成」。
|
|
46
|
+
- 测试套件可在 Windows 运行:动态 `import()` 用 `file://` URL(原样传 `C:\…` 会 `ERR_UNSUPPORTED_ESM_URL_SCHEME`);文档扫描按归一后的路径判归属;没有符号链接权限时(Windows 需开发者模式)不再整条红。
|
|
47
|
+
|
|
48
|
+
### Tests
|
|
49
|
+
|
|
50
|
+
- `test/kernel.test.mjs` 新增 8 条 pwsh 侧检查(危险闸门、卷格式化、递归删除、只读放行、绝对路径与反斜杠相对路径伪造评估卡、本体目录放行),`test/truth-table.test.mjs`/`docs-consistency` 的真值表符号同步更新。
|
|
51
|
+
- Windows 本机全量:内核 660/0、领域语言 251/0、本体 101/0、真值表 19/0、状态机 41/0、文档 15/0、注释 7/0、边界 19/0、组合 16/0、段 23/0、长测 41/0、不变量 27/0、对照 39/0、可读性 37/0、预算 28/0、native 七份全绿;宿主/客户端两份跑的是部署出去的那一份,装完本版即绿。
|
|
6
52
|
|
|
7
53
|
## [0.5.4] — 2026-10-10
|
|
8
54
|
|
package/README.md
CHANGED
|
@@ -22,8 +22,8 @@ ClearAI is an **ontology discovery and exploration platform**, built on two core
|
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
# Install (npm package, prebuilt — no build step, no allowBuilds prompt)
|
|
25
|
-
dsh plugin --profile web add clearai-dsh@0.5.
|
|
26
|
-
# or in the app: Plugins → Add plugin → clearai-dsh@0.5.
|
|
25
|
+
dsh plugin --profile web add clearai-dsh@0.5.6
|
|
26
|
+
# or in the app: Plugins → Add plugin → clearai-dsh@0.5.6
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
Restart `dsh web`, then pick **ClearAI** in the preset picker at the top of a new session. That is the whole setup. [Full install notes ↓](#install-and-use)
|
|
@@ -86,12 +86,12 @@ ClearAI does **not** claim recursive self-improvement. It provides the epistemic
|
|
|
86
86
|
|
|
87
87
|
**Recommended — install it in the app, with the version pinned:**
|
|
88
88
|
|
|
89
|
-
In the sidebar open **Plugins → Add plugin**, enter `clearai-dsh@0.5.
|
|
89
|
+
In the sidebar open **Plugins → Add plugin**, enter `clearai-dsh@0.5.6`, and install. That is DSH's own plugin manager: it hands what you type to pnpm, checks that the package declares a bundle and is compatible with this host, and applies it live. (The Settings page **插件列表 / Plugins** is the read-only inventory — installing happens on the sidebar's Plugins page.)
|
|
90
90
|
|
|
91
91
|
**Or from a terminal — the same install:**
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
|
-
dsh plugin --profile web add clearai-dsh@0.5.
|
|
94
|
+
dsh plugin --profile web add clearai-dsh@0.5.6
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
This installs the prebuilt package from the npm registry. Nothing is compiled on your machine, so there is no `allowBuilds` grant to approve — the plugin is ready the moment the command returns.
|
|
@@ -156,7 +156,7 @@ node docs/diagrams/build-hero.mjs # redraw the product hero (needs google-chro
|
|
|
156
156
|
|
|
157
157
|
## What it looks like
|
|
158
158
|
|
|
159
|
-
Two panes in the middle: **Explore** and **Ontology**. Explore holds the process; Ontology holds only results.
|
|
159
|
+
Two panes in the middle: **Explore** and **Ontology**. Explore holds the process; Ontology holds only results. Plan progress mirrors to DSH's native todo dock.
|
|
160
160
|
|
|
161
161
|
**Explore** — what is being answered, which possibilities are still open, and what comes next. The header gives the topic and mode (survey / solve), the current question and plan progress. Below come the items awaiting you, the survey areas (in survey mode), each question's candidate hypotheses (being examined / excluded / adopted / set aside; open one for its source, refutation condition, prediction and related records), the next step with each candidate's prediction (with a note when the predictions are identical and the step cannot tell them apart), and unexplained observations. A newly found question carries two buttons, "Make it a question" and "Park"; pressing one sends a sentence to the model on your behalf, and the model revises the framing. At the bottom, a collapsed **process record**: judgment counts and the progress rail, every judgment, and the plan's steps and gates.
|
|
162
162
|
|
package/README.zh-CN.md
CHANGED
|
@@ -22,8 +22,8 @@ ClearAI 是一个**本体发现与探索平台**,核心由两个概念支撑
|
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
# 安装(npm 包,预构建——无需构建步骤,不会触发 allowBuilds 授权)
|
|
25
|
-
dsh plugin --profile web add clearai-dsh@0.5.
|
|
26
|
-
# 或在应用里:侧栏「插件」→ 添加插件 → clearai-dsh@0.5.
|
|
25
|
+
dsh plugin --profile web add clearai-dsh@0.5.6
|
|
26
|
+
# 或在应用里:侧栏「插件」→ 添加插件 → clearai-dsh@0.5.6
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
重启 `dsh web`,在新建会话顶部的模式选择器里选 **ClearAI** 即可。这就是全部步骤。[完整安装说明 ↓](#安装与使用)
|
|
@@ -86,12 +86,12 @@ ClearAI **不**声称递归自我改进。它提供的是自我改进系统所
|
|
|
86
86
|
|
|
87
87
|
**推荐——在应用里装,并把版本钉住:**
|
|
88
88
|
|
|
89
|
-
侧栏打开**「插件」→ 添加插件**,填 `clearai-dsh@0.5.
|
|
89
|
+
侧栏打开**「插件」→ 添加插件**,填 `clearai-dsh@0.5.6`,安装。这就是 DSH 自己的插件管理器:它把你填的东西交给 pnpm,校验这个包声明了组合包、与当前宿主兼容,然后当场生效。(设置里的**插件列表**是**只读清单**;安装入口在侧栏那个「插件」页。)
|
|
90
90
|
|
|
91
91
|
**或者开终端——同一次安装:**
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
|
-
dsh plugin --profile web add clearai-dsh@0.5.
|
|
94
|
+
dsh plugin --profile web add clearai-dsh@0.5.6
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
从 npm registry 装预构建产物。本机不跑任何编译,因此不需要批准 `allowBuilds` 授权——命令返回时插件就已经可用。
|
|
@@ -157,7 +157,7 @@ node docs/diagrams/build-hero.mjs # 重画产品主图(需 google-chrome)
|
|
|
157
157
|
|
|
158
158
|
## 它长什么样
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
中栏两格:**探索**与**本体**。探索记录过程,本体只放结果。计划进度同步到 DSH 原生的 todo 停靠栏。
|
|
161
161
|
|
|
162
162
|
**探索**——当前在回答什么、还有哪些可能未被排除、下一步做什么。页眉是课题与阶段(广度调研 / 定向求解)、当前问题、计划进度;下面依次是待您处理的事项、调研板块(广度调研时)、每个问题的候选假设(考察中 / 已排除 / 已采纳 / 暂不考察,点开看提出依据、推翻条件、预测与关联记录)、下一步及各候选的预测(预测相同时说明此步骤无法区分它们)、未解释的现象。新发现的问题带「立为问题 / 暂缓」两个按钮,按下即替您向模型发一句话,由模型修订立题。最下面是默认折叠的**过程记录**:判断的计数与进度轨、全部判断、计划的步骤与门。
|
|
163
163
|
|
package/bin/clearai.mjs
CHANGED
|
@@ -163,6 +163,25 @@ function findOnPath(name) {
|
|
|
163
163
|
return null
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
/**
|
|
167
|
+
* 跑一个在 PATH 上找到的命令。
|
|
168
|
+
*
|
|
169
|
+
* **Windows 上 `.cmd`/`.bat` 不能直接 spawn** —— Node 只认 PE 可执行文件,裸 spawn 一个
|
|
170
|
+
* `dsh.cmd` 会失败(EINVAL/ENOENT),而 Windows 上的 CLI 正是 `.cmd` 包装脚本。
|
|
171
|
+
* 这类脚本要交给 `cmd.exe` 执行。
|
|
172
|
+
*/
|
|
173
|
+
function spawnOnPath(bin, args, options) {
|
|
174
|
+
if (process.platform === 'win32' && /\.(?:cmd|bat)$/i.test(bin)) {
|
|
175
|
+
// `/s` 会剥掉整串的**最外层**引号,所以按 cmd 的规范写成 `""bin" "arg"…"`:
|
|
176
|
+
// 每个参数各自加引号(路径里有空格是常态),整体再包一层。`windowsVerbatimArguments`
|
|
177
|
+
// 让 Node 原样透传 —— 否则 Node 自己那套转义在 cmd 眼里是错的。
|
|
178
|
+
const quote = (value) => `"${String(value).replaceAll('"', '""')}"`
|
|
179
|
+
const line = `"${[bin, ...args].map(quote).join(' ')}"`
|
|
180
|
+
return spawnSync(process.env.ComSpec ?? 'cmd.exe', ['/d', '/s', '/c', line], { ...options, windowsVerbatimArguments: true })
|
|
181
|
+
}
|
|
182
|
+
return spawnSync(bin, args, options)
|
|
183
|
+
}
|
|
184
|
+
|
|
166
185
|
/**
|
|
167
186
|
* 问组合:宿主行到底有没有真的进组合。
|
|
168
187
|
*
|
|
@@ -174,7 +193,7 @@ function composeQuery(profileName, env) {
|
|
|
174
193
|
const args = ['--profile', profileName, '--dump-config']
|
|
175
194
|
const run = onPath === null
|
|
176
195
|
? spawnSync('npx', ['--no-install', '@deepseek-ai/dsh', ...args], { encoding: 'utf8', env, timeout: 120000, stdio: ['ignore', 'pipe', 'ignore'] })
|
|
177
|
-
:
|
|
196
|
+
: spawnOnPath(onPath, args, { encoding: 'utf8', env, timeout: 120000, stdio: ['ignore', 'pipe', 'ignore'] })
|
|
178
197
|
return run.status === 0 ? String(run.stdout ?? '') : null
|
|
179
198
|
}
|
|
180
199
|
|
|
@@ -238,7 +257,7 @@ function install() {
|
|
|
238
257
|
* 子进程**继承 stdio**:安装进度、以及 CLI 那句 `initialized profile …` 都如实流到用户眼前;
|
|
239
258
|
* 失败时他看到的也是真实报错,而不是我截出来的尾巴。
|
|
240
259
|
*/
|
|
241
|
-
const dsh = (args) => (dshPath === null ? spawnSync('npx', ['--yes', '@deepseek-ai/dsh', ...args], { env, stdio: 'inherit', timeout: 900000 }) :
|
|
260
|
+
const dsh = (args) => (dshPath === null ? spawnSync('npx', ['--yes', '@deepseek-ai/dsh', ...args], { env, stdio: 'inherit', timeout: 900000 }) : spawnOnPath(dshPath, args, { env, stdio: 'inherit', timeout: 900000 }))
|
|
242
261
|
|
|
243
262
|
console.log(t('installHeader', { name: manifest.name, version: manifest.version }))
|
|
244
263
|
console.log(` ${t('installWhat')}${spec}(${source})`)
|
package/lib/client.js
CHANGED
|
@@ -81,10 +81,10 @@ var Wt=Object.create;var Le=Object.defineProperty;var Pt=Object.getOwnPropertyDe
|
|
|
81
81
|
/**
|
|
82
82
|
* clearai-dsh —— 浏览器半(ClearAI 的面板)。
|
|
83
83
|
*
|
|
84
|
-
*
|
|
84
|
+
* 它注册两个座位:
|
|
85
85
|
* 中栏 `conversation.view` 探索(问题 → 候选假设 → 下一步;过程记录里有判断列表与计划的世界树)
|
|
86
86
|
* 中栏 `conversation.view` 本体(结论四部分 + 本体图 / 实体图 + 已确立的事实 + 经验)
|
|
87
|
-
*
|
|
87
|
+
* 计划进度同步到 DSH 原生的 todo 停靠栏,不再有输入框芯片。
|
|
88
88
|
* 交付与文件改动走 DSH 原生的卡片,技能走原生技能目录,这里都不另做一份。
|
|
89
89
|
* 面板**只读**:没有写入口。要人拍板的事由开门的那次工具调用当场问人;「立为问题 / 暂缓」只替人往对话里发一句话。
|
|
90
90
|
*
|
|
@@ -300,7 +300,7 @@ window.__ModuleLoader__.load({
|
|
|
300
300
|
/* 图 */
|
|
301
301
|
.clearai-graph{margin-bottom:18px}
|
|
302
302
|
.clearai-graph[data-full="1"]{position:fixed;inset:0;z-index:40;background:var(--dsw-alias-bg-base);padding:16px 20px;display:flex;flex-direction:column;margin:0}
|
|
303
|
-
.clearai-graph-bar{display:flex;align-items:center;gap:14px;margin-bottom:8px;font-size:12px}
|
|
303
|
+
.clearai-graph-bar{display:flex;align-items:center;gap:14px;margin-bottom:8px;font-size:12px;position:relative;z-index:2}
|
|
304
304
|
.clearai-seg{display:inline-flex;border:.5px solid var(--dsw-alias-border-l3);border-radius:999px;padding:2px}
|
|
305
305
|
.clearai-seg>span{padding:2px 12px;border-radius:999px;cursor:pointer;color:var(--dsw-alias-label-secondary);white-space:nowrap}
|
|
306
306
|
.clearai-seg>span[data-on="1"]{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-label-primary-inverted)}
|
|
@@ -314,6 +314,14 @@ window.__ModuleLoader__.load({
|
|
|
314
314
|
.clearai-graph-body[data-side="1"]{flex-direction:row}
|
|
315
315
|
.clearai-graph-canvas{height:340px;border:.5px solid var(--dsw-alias-border-l2);border-radius:10px;overflow:hidden;background:var(--dsw-alias-bg-base)}
|
|
316
316
|
.clearai-graph[data-full="1"] .clearai-graph-canvas{height:auto;flex:1 1 auto;min-width:0}
|
|
317
|
+
/**
|
|
318
|
+
* 全屏是自画的覆盖层(fixed / inset:0 / z-index:40),画布与右下角抽屉都长在它里面。
|
|
319
|
+
* 「退出全屏」原来只是工具条里的一个文字链接(没有快捷键、也不保证不被画布盖住)——
|
|
320
|
+
* 一旦它被遮住或换行挤出视口,用户只能刷新页面(社区 issue #33)。
|
|
321
|
+
* 所以全屏时把退出入口做成浮层里的固定按钮:比覆盖层高一档(z-index 41),永远在右上角。
|
|
322
|
+
*/
|
|
323
|
+
.clearai-graph[data-full="1"] .clearai-link[data-exit="1"]{position:fixed;top:12px;right:20px;z-index:41;padding:3px 10px;border:.5px solid var(--dsw-alias-border-l3);border-radius:8px;background:var(--dsw-alias-bg-base);text-decoration:none}
|
|
324
|
+
.clearai-graph[data-full="1"] .clearai-link[data-exit="1"]:hover{border-color:var(--dsw-alias-label-secondary)}
|
|
317
325
|
.clearai-graph-side{flex:0 0 auto}
|
|
318
326
|
.clearai-graph-body[data-side="1"] .clearai-graph-side{width:380px;overflow-y:auto}
|
|
319
327
|
.clearai-graph-problems{margin-top:6px;font-size:11.5px;color:var(--dsw-alias-label-secondary)}.clearai-graph-problems summary{cursor:pointer;color:var(--dsw-alias-state-warn-primary)}.clearai-graph-problems>div{padding:2px 0 2px 12px;line-height:1.5}.clearai-graph-problems>div[data-sev=info]{opacity:.7}.clearai-graph-problems code{font-size:11px}
|
|
@@ -2693,6 +2701,21 @@ window.__ModuleLoader__.load({
|
|
|
2693
2701
|
return () => clearTimeout(timer)
|
|
2694
2702
|
}, [fullscreen, layer, picked !== null, allNodes.length])
|
|
2695
2703
|
|
|
2704
|
+
/**
|
|
2705
|
+
* **Escape 退出全屏**(issue #33)。
|
|
2706
|
+
*
|
|
2707
|
+
* 全屏是自画的覆盖层,不是原生 Fullscreen API,所以浏览器不会自己给退出键;
|
|
2708
|
+
* 退出入口又只有一个文字链接。这里挂一个 window 级监听(焦点在画布任意位置都能退,
|
|
2709
|
+
* 退出全屏或卸载时摘掉),并在根节点上同时接 onKeyDown —— 事件在组件内冒泡时同样生效,
|
|
2710
|
+
* 且这条接线在测试里可以直接验。
|
|
2711
|
+
*/
|
|
2712
|
+
React.useEffect(() => {
|
|
2713
|
+
if (fullscreen !== true || typeof window === 'undefined' || typeof window.addEventListener !== 'function') return undefined
|
|
2714
|
+
const onKey = (event) => { if (event?.key === 'Escape') onToggleFullscreen() }
|
|
2715
|
+
window.addEventListener('keydown', onKey)
|
|
2716
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
2717
|
+
}, [fullscreen, onToggleFullscreen])
|
|
2718
|
+
|
|
2696
2719
|
/** 全屏时小卡走右侧抽屉:摆在画布下方会把画布压矮,刚点开的那个点直接掉出可视区。 */
|
|
2697
2720
|
const sideBySide = fullscreen === true
|
|
2698
2721
|
const empty =
|
|
@@ -2701,7 +2724,12 @@ window.__ModuleLoader__.load({
|
|
|
2701
2724
|
: t('本体图暂无内容。模型在 clear/ontology/concepts/ 与 relations/ 下建立概念与关系文件后,将在此显示。')
|
|
2702
2725
|
return h(
|
|
2703
2726
|
'div',
|
|
2704
|
-
{
|
|
2727
|
+
{
|
|
2728
|
+
className: 'clearai-graph',
|
|
2729
|
+
'data-full': fullscreen === true ? '1' : '0',
|
|
2730
|
+
/** 覆盖层内也认 Escape(见上面的 window 监听):两条一起,焦点在哪都能退。 */
|
|
2731
|
+
onKeyDown: fullscreen === true ? (event) => { if (event?.key === 'Escape') onToggleFullscreen() } : undefined,
|
|
2732
|
+
},
|
|
2705
2733
|
h(
|
|
2706
2734
|
'div',
|
|
2707
2735
|
{ className: 'clearai-graph-bar' },
|
|
@@ -2721,7 +2749,7 @@ window.__ModuleLoader__.load({
|
|
|
2721
2749
|
),
|
|
2722
2750
|
h('span', { style: { flex: '1 1 auto' } }),
|
|
2723
2751
|
allNodes.length === 0 ? null : h('span', { className: 'clearai-link', onClick: () => rfRef.current?.fitView?.({ padding: 0.18, duration: 200 }) }, t('适配')),
|
|
2724
|
-
h('span', { className: 'clearai-link', onClick: onToggleFullscreen }, fullscreen === true ? t('退出全屏') : t('全屏')),
|
|
2752
|
+
h('span', { className: 'clearai-link', 'data-exit': '1', onClick: onToggleFullscreen }, fullscreen === true ? `${t('退出全屏')} (Esc)` : t('全屏')),
|
|
2725
2753
|
),
|
|
2726
2754
|
h(
|
|
2727
2755
|
'div',
|
package/package.json
CHANGED
|
@@ -16,12 +16,20 @@
|
|
|
16
16
|
|
|
17
17
|
# ── 身份 ────────────────────────────────────────────────────────────────────
|
|
18
18
|
|
|
19
|
-
# 预设自己的 persona
|
|
19
|
+
# 预设自己的 persona,覆盖部署默认。
|
|
20
|
+
#
|
|
21
|
+
# **刻意不写 `{{cwd}}` / `{{model}}` 这类模板变量**:宿主在渲染提示词时按**变量表**严格解析,
|
|
22
|
+
# 表里没有的名字会让整轮直接抛错(`unknown prompt variable "{{cwd}}" in section …`),
|
|
23
|
+
# 而各宿主版本注册的变量并不一样 —— 社区 issue #34 就是某些宿主的表里只有 provider/model、
|
|
24
|
+
# 没有 cwd,ClearAI 会话起不来。工作区的绝对路径本来由宿主的运行时上下文给出,
|
|
25
|
+
# 这里只写产品含义(工作区 = 用户的文件夹),不依赖模板变量。
|
|
26
|
+
#
|
|
27
|
+
# 变量契约由 test/prompt-sections.test.mjs 钉住:预设里若再出现 `{{…}}`,必须是宿主注册过的名字。
|
|
20
28
|
- id: persona
|
|
21
29
|
name: '@deepseek-ai/dsh-persona'
|
|
22
30
|
config:
|
|
23
31
|
prefix: '你是 ClearAI 的主人格,运行在 DeepSeek Harness 上。怎么工作见下面三段:身份、循环、对人说话。'
|
|
24
|
-
suffix:
|
|
32
|
+
suffix: 工作区就是用户的文件夹;`clear/` 下除本体(`clear/ontology/`)外是系统的目录,其余目录都是用户的。
|
|
25
33
|
|
|
26
34
|
- id: agent-instructions
|
|
27
35
|
name: '@deepseek-ai/dsh-agent-instructions'
|
|
@@ -33,12 +33,20 @@
|
|
|
33
33
|
|
|
34
34
|
# ── 身份 ────────────────────────────────────────────────────────────────────
|
|
35
35
|
|
|
36
|
-
# 预设自己的 persona
|
|
36
|
+
# 预设自己的 persona,覆盖部署默认。
|
|
37
|
+
#
|
|
38
|
+
# **刻意不写 `{{cwd}}` / `{{model}}` 这类模板变量**:宿主在渲染提示词时按**变量表**严格解析,
|
|
39
|
+
# 表里没有的名字会让整轮直接抛错(`unknown prompt variable "{{cwd}}" in section …`),
|
|
40
|
+
# 而各宿主版本注册的变量并不一样 —— 社区 issue #34 就是某些宿主的表里只有 provider/model、
|
|
41
|
+
# 没有 cwd,ClearAI 会话起不来。工作区的绝对路径本来由宿主的运行时上下文给出,
|
|
42
|
+
# 这里只写产品含义(工作区 = 用户的文件夹),不依赖模板变量。
|
|
43
|
+
#
|
|
44
|
+
# 变量契约由 test/prompt-sections.test.mjs 钉住:预设里若再出现 `{{…}}`,必须是宿主注册过的名字。
|
|
37
45
|
- id: persona
|
|
38
46
|
name: '@deepseek-ai/dsh-persona'
|
|
39
47
|
config:
|
|
40
48
|
prefix: '你是 ClearAI 的主人格,运行在 DeepSeek Harness 上。怎么工作见下面三段:身份、循环、对人说话。'
|
|
41
|
-
suffix:
|
|
49
|
+
suffix: 工作区就是用户的文件夹;`clear/` 下除本体(`clear/ontology/`)外是系统的目录,其余目录都是用户的。
|
|
42
50
|
|
|
43
51
|
- id: agent-instructions
|
|
44
52
|
name: '@deepseek-ai/dsh-agent-instructions'
|
|
@@ -320,3 +328,89 @@
|
|
|
320
328
|
# 产不出一条 clearai 变更。「不挂」当年防的是「自己派一个来判自己」——评估者的派遣
|
|
321
329
|
# 在内核里(auditProvider),与模型面的 subagent 是两层;后者派出去的只是干活的,
|
|
322
330
|
# 它的结论要进账本,只能回到主线过观测准入。
|
|
331
|
+
|
|
332
|
+
- id: preset-clearai-evaluator
|
|
333
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
334
|
+
config:
|
|
335
|
+
id: clearai-evaluator
|
|
336
|
+
name: ClearAI 评估者 · Evaluator
|
|
337
|
+
description: |-
|
|
338
|
+
由 ClearAI 内核派出的只读独立评估者,不用于直接对话。Read-only evaluator dispatched by ClearAI; not for direct chat.
|
|
339
|
+
order: 90
|
|
340
|
+
plugins:
|
|
341
|
+
# The `clearai-evaluator` agent preset:ClearAI 内核派出的**独立评估者**用的组合。
|
|
342
|
+
#
|
|
343
|
+
# 为什么要有这一份(issue #38):宿主 ≥0.2.1-alpha.2 的 `subagents.startActivation` 不再接受
|
|
344
|
+
# 逐次请求的 persona / toolFilter —— 本地子会话的人格与工具面**只由所选预设决定**。
|
|
345
|
+
# 不选预设,评估者就加入父会话的 ClearAI 组合:拿到写工具和 ClearAI 自己的工具,读到主人格。
|
|
346
|
+
# 所以评估者改用这一份组合:身份、只读的文件面由「挂了哪些行」决定;
|
|
347
|
+
# 宿主全局层继承下来的工具由下面的 clearai-evaluator-face 遮掉并在执行处拦住。
|
|
348
|
+
#
|
|
349
|
+
# 旧宿主(仍有 `subagents.start`)上内核走逐次请求的 toolFilter,这一份预设不被用到。
|
|
350
|
+
#
|
|
351
|
+
# 名册没有「隐藏」开关,这一份会出现在预设选择器里;名字和介绍都写明它不用于直接对话。
|
|
352
|
+
# 由 tools/build-package.mjs 装配成 `presets/clearai/clearai.patch.yml` 里的第二条声明行。
|
|
353
|
+
|
|
354
|
+
# ── 身份 ────────────────────────────────────────────────────────────────────
|
|
355
|
+
|
|
356
|
+
# 评估纪律在任务书里(内核 `evaluatorPrompt` 的第一段,跟着人说话的语言走);这里只说身份。
|
|
357
|
+
# 同主预设一样,不写 `{{…}}` 模板变量(issue #34)。
|
|
358
|
+
- id: persona
|
|
359
|
+
name: '@deepseek-ai/dsh-persona'
|
|
360
|
+
config:
|
|
361
|
+
prefix: '你是 ClearAI 派出的独立评估者:只核对,不做方案,不改原工作区。怎么判见任务书。You are the independent evaluator dispatched by ClearAI: verify only, do not redo the work, do not modify the original workspace. The brief says how to judge.'
|
|
362
|
+
|
|
363
|
+
# ── 只读文件面 ──────────────────────────────────────────────────────────────
|
|
364
|
+
|
|
365
|
+
# 只开读:`write` / `edit` 关掉,工具注册表里就没有它们(不是挂上再拦)。
|
|
366
|
+
# `read_image` 照旧随 `attachments` 在场与否(看图也是读)。
|
|
367
|
+
- id: tool-fs
|
|
368
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
369
|
+
config:
|
|
370
|
+
write: false
|
|
371
|
+
edit: false
|
|
372
|
+
|
|
373
|
+
- id: tool-fs-search
|
|
374
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
375
|
+
config:
|
|
376
|
+
sampleOverCapGlobResults: false
|
|
377
|
+
|
|
378
|
+
# ── 复跑 ────────────────────────────────────────────────────────────────────
|
|
379
|
+
|
|
380
|
+
# 复跑在工作区副本里进行(内核 `rerunCopy`,不含 `clear/`);任务书写明原工作区只读,
|
|
381
|
+
# 评估期间产物被改动过,内核按 `evaluator_touched_outputs` 不认这份裁决。
|
|
382
|
+
- id: tool-bash
|
|
383
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
384
|
+
disabled: !!js process.platform === 'win32'
|
|
385
|
+
|
|
386
|
+
- id: tool-pwsh
|
|
387
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
388
|
+
disabled: !!js process.platform !== 'win32'
|
|
389
|
+
|
|
390
|
+
# 命令转后台 job 时,评估者要能收取 / 取消自己的任务。
|
|
391
|
+
- id: tool-jobs
|
|
392
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
393
|
+
|
|
394
|
+
# ── 工具面 ──────────────────────────────────────────────────────────────────
|
|
395
|
+
|
|
396
|
+
# 只换预设不够:宿主 profile 在全局层注册的工具(write / edit / subagent / web_* / goal……)
|
|
397
|
+
# 每个 agent 都继承得到:不遮这一层,评估者照样拿得到 write 与 edit。
|
|
398
|
+
# 这一行把继承来的全局工具按白名单遮掉,并在执行处再拦一道。白名单与旧入口的 toolFilter 同一张。
|
|
399
|
+
- id: clearai-evaluator-face
|
|
400
|
+
name: 'clearai-dsh/presets/clearai/plugins/clearai-evaluator-face.js'
|
|
401
|
+
config:
|
|
402
|
+
allow:
|
|
403
|
+
- read
|
|
404
|
+
- read_image
|
|
405
|
+
- glob
|
|
406
|
+
- grep
|
|
407
|
+
- bash
|
|
408
|
+
- pwsh
|
|
409
|
+
- job_output
|
|
410
|
+
- job_list
|
|
411
|
+
- job_kill
|
|
412
|
+
|
|
413
|
+
# ── 刻意不挂的行 ────────────────────────────────────────────────────────────
|
|
414
|
+
#
|
|
415
|
+
# · ClearAI 内核:评估者不立题、不推进、不结案;它的裁决经结构化回包回到父会话的内核。
|
|
416
|
+
# · 子代理 / workflow / ralph / ask-user / web:判的人不再派人,也不找人问。
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# The `clearai-evaluator` agent preset:ClearAI 内核派出的**独立评估者**用的组合。
|
|
2
|
+
#
|
|
3
|
+
# 为什么要有这一份(issue #38):宿主 ≥0.2.1-alpha.2 的 `subagents.startActivation` 不再接受
|
|
4
|
+
# 逐次请求的 persona / toolFilter —— 本地子会话的人格与工具面**只由所选预设决定**。
|
|
5
|
+
# 不选预设,评估者就加入父会话的 ClearAI 组合:拿到写工具和 ClearAI 自己的工具,读到主人格。
|
|
6
|
+
# 所以评估者改用这一份组合:身份、只读的文件面由「挂了哪些行」决定;
|
|
7
|
+
# 宿主全局层继承下来的工具由下面的 clearai-evaluator-face 遮掉并在执行处拦住。
|
|
8
|
+
#
|
|
9
|
+
# 旧宿主(仍有 `subagents.start`)上内核走逐次请求的 toolFilter,这一份预设不被用到。
|
|
10
|
+
#
|
|
11
|
+
# 名册没有「隐藏」开关,这一份会出现在预设选择器里;名字和介绍都写明它不用于直接对话。
|
|
12
|
+
# 由 tools/build-package.mjs 装配成 `presets/clearai/clearai.patch.yml` 里的第二条声明行。
|
|
13
|
+
|
|
14
|
+
# ── 身份 ────────────────────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
# 评估纪律在任务书里(内核 `evaluatorPrompt` 的第一段,跟着人说话的语言走);这里只说身份。
|
|
17
|
+
# 同主预设一样,不写 `{{…}}` 模板变量(issue #34)。
|
|
18
|
+
- id: persona
|
|
19
|
+
name: '@deepseek-ai/dsh-persona'
|
|
20
|
+
config:
|
|
21
|
+
prefix: '你是 ClearAI 派出的独立评估者:只核对,不做方案,不改原工作区。怎么判见任务书。You are the independent evaluator dispatched by ClearAI: verify only, do not redo the work, do not modify the original workspace. The brief says how to judge.'
|
|
22
|
+
|
|
23
|
+
# ── 只读文件面 ──────────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
# 只开读:`write` / `edit` 关掉,工具注册表里就没有它们(不是挂上再拦)。
|
|
26
|
+
# `read_image` 照旧随 `attachments` 在场与否(看图也是读)。
|
|
27
|
+
- id: tool-fs
|
|
28
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
29
|
+
config:
|
|
30
|
+
write: false
|
|
31
|
+
edit: false
|
|
32
|
+
|
|
33
|
+
- id: tool-fs-search
|
|
34
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
35
|
+
config:
|
|
36
|
+
sampleOverCapGlobResults: false
|
|
37
|
+
|
|
38
|
+
# ── 复跑 ────────────────────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
# 复跑在工作区副本里进行(内核 `rerunCopy`,不含 `clear/`);任务书写明原工作区只读,
|
|
41
|
+
# 评估期间产物被改动过,内核按 `evaluator_touched_outputs` 不认这份裁决。
|
|
42
|
+
- id: tool-bash
|
|
43
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
44
|
+
disabled: !!js process.platform === 'win32'
|
|
45
|
+
|
|
46
|
+
- id: tool-pwsh
|
|
47
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
48
|
+
disabled: !!js process.platform !== 'win32'
|
|
49
|
+
|
|
50
|
+
# 命令转后台 job 时,评估者要能收取 / 取消自己的任务。
|
|
51
|
+
- id: tool-jobs
|
|
52
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
53
|
+
|
|
54
|
+
# ── 工具面 ──────────────────────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
# 只换预设不够:宿主 profile 在全局层注册的工具(write / edit / subagent / web_* / goal……)
|
|
57
|
+
# 每个 agent 都继承得到:不遮这一层,评估者照样拿得到 write 与 edit。
|
|
58
|
+
# 这一行把继承来的全局工具按白名单遮掉,并在执行处再拦一道。白名单与旧入口的 toolFilter 同一张。
|
|
59
|
+
- id: clearai-evaluator-face
|
|
60
|
+
name: 'clearai-dsh/presets/clearai/plugins/clearai-evaluator-face.js'
|
|
61
|
+
config:
|
|
62
|
+
allow:
|
|
63
|
+
- read
|
|
64
|
+
- read_image
|
|
65
|
+
- glob
|
|
66
|
+
- grep
|
|
67
|
+
- bash
|
|
68
|
+
- pwsh
|
|
69
|
+
- job_output
|
|
70
|
+
- job_list
|
|
71
|
+
- job_kill
|
|
72
|
+
|
|
73
|
+
# ── 刻意不挂的行 ────────────────────────────────────────────────────────────
|
|
74
|
+
#
|
|
75
|
+
# · ClearAI 内核:评估者不立题、不推进、不结案;它的裁决经结构化回包回到父会话的内核。
|
|
76
|
+
# · 子代理 / workflow / ralph / ask-user / web:判的人不再派人,也不找人问。
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clearai-evaluator-face —— 独立评估者的**工具面**(只挂在 `clearai-evaluator` 预设里)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要它(issue #38,宿主 ≥0.2.1-alpha.2):`startActivation` 不再接受逐次请求的
|
|
5
|
+
* toolFilter,评估者预设又只能决定「自己挂了哪些行」。可宿主 profile 在**全局层**注册的工具
|
|
6
|
+
* (`write` / `edit` / `subagent` / `workflow` / `web_*` / goal 工具……)每个 agent 都继承得到 ——
|
|
7
|
+
* 只换预设,评估者照样拿得到写工具。旧入口的 toolFilter 遮的正是这一层。
|
|
8
|
+
*
|
|
9
|
+
* 两道,缺一不可:
|
|
10
|
+
* · **可见面**:`tools.restrict({ deny })` 把白名单外的全局工具从评估者的工具清单里拿掉,
|
|
11
|
+
* 模型看不见就不会去试。restriction 遮的是 agent 继承来的面(全局 + 祖先层),
|
|
12
|
+
* 预设层对评估者是祖先,所以这里只能 deny 具体名字,不能 allow —— allow 会连本预设挂的 read 一起遮掉。
|
|
13
|
+
* · **硬边界**:`tools.guard` 拒绝白名单外的一切执行。guard 单调(别的 guard 放行不了它拒的),
|
|
14
|
+
* 也兜住挂载之后才注册进来的全局工具 —— deny 名单只认得挂载那一刻的名字。
|
|
15
|
+
*
|
|
16
|
+
* 白名单与旧入口的 toolFilter 同一张:read / read_image / glob / grep + 复跑用的 shell 与后台任务;
|
|
17
|
+
* `structured_output` 是宿主挂在评估者自己层上的回包通道,不在继承面里,但执行要经过 guard,所以列上。
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export const name = 'clearai-evaluator-face'
|
|
21
|
+
export const inject = ['tools']
|
|
22
|
+
|
|
23
|
+
const PRESET_ID = 'clearai-evaluator'
|
|
24
|
+
/** `run_code` 是 PTC 模式的呈现通道(里面的每次调用仍按原名过 guard),不是一件能力。 */
|
|
25
|
+
const ALWAYS = ['structured_output', 'run_code']
|
|
26
|
+
|
|
27
|
+
export function apply(ctx, config = {}) {
|
|
28
|
+
const allow = new Set([...(Array.isArray(config.allow) ? config.allow : []), ...ALWAYS])
|
|
29
|
+
if (allow.size === ALWAYS.length) throw new Error('clearai-evaluator-face: config.allow must list the evaluator tools')
|
|
30
|
+
const tools = ctx.tools
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 只管评估者自己。restriction / guard 注册在预设作用域里,本来就只覆盖加入这个预设的 agent;
|
|
34
|
+
* 若宿主把这一层当成全局(作用域判断变了),再按 agent 实际加入的预设核一遍,绝不误伤主会话。
|
|
35
|
+
*/
|
|
36
|
+
let scoped = true
|
|
37
|
+
const presets = () => {
|
|
38
|
+
try { return ctx.get('agentPresets') } catch { return undefined }
|
|
39
|
+
}
|
|
40
|
+
const isEvaluator = (agent) => {
|
|
41
|
+
if (scoped) return true
|
|
42
|
+
const composed = agent?.ctx === undefined ? undefined : presets()?.composedPreset?.(agent.ctx)
|
|
43
|
+
return composed === PRESET_ID
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const inherited = [...(tools.view?.(undefined)?.restrictableNames ?? [])]
|
|
48
|
+
const deny = inherited.filter((toolName) => !allow.has(toolName) && toolName !== 'run_code')
|
|
49
|
+
if (deny.length > 0) tools.restrict({ deny })
|
|
50
|
+
} catch (error) {
|
|
51
|
+
const message = String(error?.message ?? error)
|
|
52
|
+
if (/scoped context/.test(message)) scoped = false
|
|
53
|
+
ctx.logger?.warn?.(`clearai-evaluator-face: could not hide inherited tools (${message.slice(0, 160)}); the execution guard still applies`)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
tools.guard((exec) => {
|
|
57
|
+
if (allow.has(exec?.name) || !isEvaluator(exec?.agent)) return undefined
|
|
58
|
+
return `The ClearAI evaluator is read-only: "${exec?.name}" is outside its tool face (${[...allow].join(', ')}). Verify with the allowed tools and report the limitation in the verdict.`
|
|
59
|
+
})
|
|
60
|
+
}
|
|
@@ -90,6 +90,12 @@ const canonicalVerdict = (value) => {
|
|
|
90
90
|
}
|
|
91
91
|
/** 自判等级上限:L0–L2 可自判,L3 以上拒绝。 */
|
|
92
92
|
const SELF_JUDGE_MAX_INDEX = 2
|
|
93
|
+
/**
|
|
94
|
+
* 一次 L3+ 交付随交付带给评估者的未解释项上限(issue #36)。
|
|
95
|
+
* 评估者的任务书里,这次交付由做的人决定的那一份就是 `anomalies`(observations 的 note 与 basis 不进任务书);
|
|
96
|
+
* 0.5.4 起评估者不再被硬取消,材料体积是剩下的那道刹车。超限**拒绝而不截断**:截断会让做的人以为都送到了。
|
|
97
|
+
*/
|
|
98
|
+
const AUDIT_MATERIAL_LIMITS = { anomalies: 4, anomalyChars: 400 }
|
|
93
99
|
/**
|
|
94
100
|
* **给模型选的只有三档**:L2 自判、L3 独立评估、L4 人放行。L0 / L1 / L2 的细分从没改变过谁来判
|
|
95
101
|
* (模型一律自标 L1/L2),所以合并成「自判」:旧账照旧读(界面一律说「自判」),新写的 L0 / L1 当 L2 收。
|
|
@@ -224,6 +230,8 @@ export const CONFIG_KEYS = [
|
|
|
224
230
|
'auditTimeoutMs',
|
|
225
231
|
'auditHardTimeoutMs',
|
|
226
232
|
'auditToolFilter',
|
|
233
|
+
'auditPreset',
|
|
234
|
+
'auditMaterialLimits',
|
|
227
235
|
'auditRerun',
|
|
228
236
|
'runtimeCard',
|
|
229
237
|
'contributions',
|
|
@@ -259,7 +267,6 @@ const CONTRIB_DEFAULTS = {
|
|
|
259
267
|
* 清单校验:装配语义——清单里出现表外的名字当场抛错,
|
|
260
268
|
* 而不是静默少装一件工具、等某一轮才发现。错法一律装配期抛错:
|
|
261
269
|
* unknown_mechanism / unknown_tool / tool_of_disabled_mechanism / unknown_policy_slot
|
|
262
|
-
* / unknown_budget / unknown_budget_tier / invalid_budget
|
|
263
270
|
*/
|
|
264
271
|
function resolveContributions(contributions) {
|
|
265
272
|
const declared = contributions ?? {}
|
|
@@ -330,6 +337,14 @@ export function apply(ctx, config = {}) {
|
|
|
330
337
|
if (config.blockedThreshold !== undefined && (!Number.isInteger(config.blockedThreshold) || config.blockedThreshold < 1)) {
|
|
331
338
|
throw new Error('invalid_config:clearai-kernel:blockedThreshold')
|
|
332
339
|
}
|
|
340
|
+
if (config.auditMaterialLimits !== undefined) {
|
|
341
|
+
const limits = config.auditMaterialLimits
|
|
342
|
+
if (limits === null || typeof limits !== 'object' || Array.isArray(limits)) throw new Error('invalid_config:clearai-kernel:auditMaterialLimits')
|
|
343
|
+
for (const [key, value] of Object.entries(limits)) {
|
|
344
|
+
if (!(key in AUDIT_MATERIAL_LIMITS)) throw new Error(`invalid_config:clearai-kernel:auditMaterialLimits.${key}`)
|
|
345
|
+
if (!Number.isInteger(value) || value < 1) throw new Error(`invalid_config:clearai-kernel:auditMaterialLimits.${key}`)
|
|
346
|
+
}
|
|
347
|
+
}
|
|
333
348
|
const CFG = {
|
|
334
349
|
// Native experimental variants; published ClearAI keeps both enabled.
|
|
335
350
|
applicabilityFeedback: config.applicabilityFeedback !== false,
|
|
@@ -373,12 +388,30 @@ export function apply(ctx, config = {}) {
|
|
|
373
388
|
// (见 resolveToolFace):`read_image` 只在挂了 `attachments` 的部署里存在,名单里写了它、
|
|
374
389
|
// 部署里没有,`tools.restrict` 会**直接抛**(未知工具名)→ 评估整条路 fail-closed。
|
|
375
390
|
auditToolFilter: config.auditToolFilter ?? ['read', 'glob', 'grep', 'read_image'],
|
|
391
|
+
/**
|
|
392
|
+
* 宿主 ≥0.2.1-alpha.2 的评估者组合:`startActivation` 的请求里**没有** persona / toolFilter
|
|
393
|
+
* (传了也被静默丢掉),子会话的人格与工具面只由所选预设决定。这一份预设随包声明
|
|
394
|
+
* (`preset/evaluator.cordis.yml`):文件只读、搜索、shell 与后台任务,不挂写工具也不挂 ClearAI 工具。
|
|
395
|
+
*/
|
|
396
|
+
auditPreset: config.auditPreset ?? 'clearai-evaluator',
|
|
397
|
+
/** 一次 L3+ 交付随交付带给评估者的未解释项:条数与每条长度的上限(issue #36,见 `auditMaterialProblem`)。 */
|
|
398
|
+
auditMaterialLimits: { ...AUDIT_MATERIAL_LIMITS, ...(config.auditMaterialLimits ?? {}) },
|
|
376
399
|
auditRerun: config.auditRerun === true,
|
|
377
400
|
runtimeCard: config.runtimeCard !== false,
|
|
378
401
|
/** 贡献表。缺省 = 全开;要裁剪就从这里裁,而不是去改装配代码。 */
|
|
379
402
|
contributions: config.contributions ?? {},
|
|
380
403
|
}
|
|
381
404
|
if (config.auditHardTimeoutMs !== undefined) ctx.logger?.warn?.('clearai: auditHardTimeoutMs is deprecated and ignored; auditTimeoutMs is diagnostic only. Cancellation and run budgets belong to the host.')
|
|
405
|
+
/**
|
|
406
|
+
* 启动自检(issue #38):子代理入口两代都不认识,就在挂载时说出来,
|
|
407
|
+
* 而不是等用户跑完长任务、在结案那一步才拿到 `audit_dispatch_failed`。
|
|
408
|
+
* 服务暂时不在不报(它在宿主平面,可能晚到);派遣时还会再判一次并 fail-closed。
|
|
409
|
+
*/
|
|
410
|
+
{
|
|
411
|
+
let probe
|
|
412
|
+
try { probe = ctx.get('subagents') } catch { probe = undefined }
|
|
413
|
+
if (probe !== undefined && subagentApi(probe) === null) ctx.logger?.warn?.('clearai: the host subagents service exposes neither start() nor startActivation(); independent evaluation will fail closed on this host version')
|
|
414
|
+
}
|
|
382
415
|
|
|
383
416
|
/** 贡献表:先校验(装配期炸),后登记(见文件末尾的装配段)。 */
|
|
384
417
|
const CONTRIB = resolveContributions(CFG.contributions)
|
|
@@ -1014,6 +1047,28 @@ export function apply(ctx, config = {}) {
|
|
|
1014
1047
|
]
|
|
1015
1048
|
}
|
|
1016
1049
|
|
|
1050
|
+
/**
|
|
1051
|
+
* 任务书里「这是副本」的那几句(issue #35):记号文件在哪、项目声明的复跑变量、全局用户数据目录的提醒。
|
|
1052
|
+
* 不叫评估者关掉被检项目的采集 —— 它要核的数字可能正是采集出来的。
|
|
1053
|
+
*/
|
|
1054
|
+
function rerunNotice(rerunDir) {
|
|
1055
|
+
if (rerunDir === null) return { zh: [], en: [] }
|
|
1056
|
+
const environment = Object.entries(rerunEnvironments.get(rerunDir) ?? {})
|
|
1057
|
+
const assignments = environment.map(([key, value]) => `${key}=${value}`).join(' ')
|
|
1058
|
+
return {
|
|
1059
|
+
zh: [
|
|
1060
|
+
`副本根目录有 \`.clearai-rerun.json\`:这里是一次性副本,不是原作者的工作区。`,
|
|
1061
|
+
...(environment.length === 0 ? [] : [`项目声明了复跑用的环境变量,复跑前先设上(例如命令前加 \`${assignments}\`):${environment.map(([key]) => key).join('、')}。`]),
|
|
1062
|
+
'复跑可能写进被检程序的**全局用户数据目录**(很多引擎按项目名定位它,不随目录改变),从而混进原作者的取证集。若项目有改道约定(上面的变量、或项目文档写的开关),先按约定改道再跑;没有约定时,在裁决里写明复跑可能写到了哪里。不要擅自关闭项目的采集:你要核的数字可能正是它产出的。',
|
|
1063
|
+
],
|
|
1064
|
+
en: [
|
|
1065
|
+
`The copy root contains \`.clearai-rerun.json\`: this is a disposable copy, not the author's workspace.`,
|
|
1066
|
+
...(environment.length === 0 ? [] : [`The project declares environment variables for re-runs; set them first (for example prefix the command with \`${assignments}\`): ${environment.map(([key]) => key).join(', ')}.`]),
|
|
1067
|
+
'A re-run may write into the program\'s **global user-data directory** (many engines locate it by project name, not by folder), mixing your outputs into the author\'s evidence. If the project has a redirect convention (the variables above, or a switch its docs describe), apply it before running; if it has none, say in the verdict where the re-run may have written. Do not switch off the project\'s data collection: the numbers you check may come from it.',
|
|
1068
|
+
],
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1017
1072
|
function evaluatorPrompt(state, step, gate, sessionId, rerunDir = null) {
|
|
1018
1073
|
const goal = state.goal
|
|
1019
1074
|
const tested = testedBy(step)
|
|
@@ -1068,6 +1123,7 @@ export function apply(ctx, config = {}) {
|
|
|
1068
1123
|
rerunDir === null
|
|
1069
1124
|
? '你不得修改任何文件,不得执行写入命令,不得重做方案。'
|
|
1070
1125
|
: `原工作区只读:不要在里面写文件或运行命令。要核对数字就复跑:工作区副本在 ${rerunDir}(不含 clear/),cd 进去运行产物自带的脚本,对照它打印的结果。命令转为后台 job 时,用 job_output({job_id,wait:true,timeout_ms:600000}) 等待并收取同一任务的结果;不要用 sleep 轮询、重跑相同命令或读取宿主私有日志找结果。不再需要的任务用 job_kill 取消。复跑的读数是硬信号;不要重做方案。`,
|
|
1126
|
+
...rerunNotice(rerunDir).zh,
|
|
1071
1127
|
],
|
|
1072
1128
|
[
|
|
1073
1129
|
`Working directory: ${sessionCwdLabel(sessionId)}`,
|
|
@@ -1077,6 +1133,7 @@ export function apply(ctx, config = {}) {
|
|
|
1077
1133
|
rerunDir === null
|
|
1078
1134
|
? 'You may not modify any file, run write commands or redo the work.'
|
|
1079
1135
|
: `The original workspace is read-only: do not write files or run commands in it. To check numbers, re-run: a copy of the workspace is at ${rerunDir} (without clear/); cd into it and run the scripts the outputs came from, and compare what they print. When a command becomes a background job, collect that same job with job_output({job_id,wait:true,timeout_ms:600000}); do not sleep-poll, repeat the command, or search private host logs for its output. Cancel unnecessary jobs with job_kill. Re-run readings are hard signals; do not redo the work.`,
|
|
1136
|
+
...rerunNotice(rerunDir).en,
|
|
1080
1137
|
],
|
|
1081
1138
|
),
|
|
1082
1139
|
].join('\n')
|
|
@@ -1336,6 +1393,9 @@ export function apply(ctx, config = {}) {
|
|
|
1336
1393
|
async function dispatchSubRun(options) {
|
|
1337
1394
|
const subagents = ctx.get('subagents')
|
|
1338
1395
|
if (subagents === undefined) return { ok: false, reason: tr('subagents 服务不可用', 'the subagents service is unavailable'), failures: [] }
|
|
1396
|
+
const api = subagentApi(subagents)
|
|
1397
|
+
if (api === null) return { ok: false, reason: tr('宿主的 subagents 服务既没有 start 也没有 startActivation:这个宿主版本不受支持', 'the host subagents service has neither start nor startActivation; this host version is unsupported'), failures: [] }
|
|
1398
|
+
if (api === 'activation') return dispatchActivation(subagents, options)
|
|
1339
1399
|
const base = { label: options.label, parent: options.parent, signal: options.signal, prompt: text(options.prompt) }
|
|
1340
1400
|
const persona = options.persona
|
|
1341
1401
|
const schema = options.outputSchema ? nativeAuditSchema(options.outputSchema) : undefined
|
|
@@ -1359,6 +1419,80 @@ export function apply(ctx, config = {}) {
|
|
|
1359
1419
|
return { ok: false, reason: failures.join(' | '), failures }
|
|
1360
1420
|
}
|
|
1361
1421
|
|
|
1422
|
+
/**
|
|
1423
|
+
* 一次 L3+ 交付随交付带给评估者的未解释项,超限就说清怎么压(issue #36)。
|
|
1424
|
+
* 只量 `anomalies`:这是这次交付里由做的人决定、又会进评估者任务书的那一份。
|
|
1425
|
+
* 拒的是这一次调用的形状,不是这份发现 —— 合并同类、把细节写进产物文件,换一种写法再交。
|
|
1426
|
+
*/
|
|
1427
|
+
function auditMaterialProblem(anomalies) {
|
|
1428
|
+
const items = (Array.isArray(anomalies) ? anomalies : []).filter((item) => String(item?.what ?? '').trim() !== '')
|
|
1429
|
+
const { anomalies: maxItems, anomalyChars } = CFG.auditMaterialLimits
|
|
1430
|
+
const long = items.map((item, index) => ({ index, length: String(item.what).trim().length })).filter((item) => item.length > anomalyChars)
|
|
1431
|
+
if (items.length <= maxItems && long.length === 0) return null
|
|
1432
|
+
const parts = []
|
|
1433
|
+
if (items.length > maxItems) parts.push(tr(`这次带了 ${items.length} 条未解释项,上限 ${maxItems} 条`, `this delivery carries ${items.length} unexplained items; the limit is ${maxItems}`))
|
|
1434
|
+
if (long.length > 0) parts.push(tr(`第 ${long.map((item) => item.index + 1).join('、')} 条超过 ${anomalyChars} 字(${long.map((item) => item.length).join('、')} 字)`, `item(s) ${long.map((item) => item.index + 1).join(', ')} exceed ${anomalyChars} characters (${long.map((item) => item.length).join(', ')})`))
|
|
1435
|
+
return tr(
|
|
1436
|
+
`交给独立评估者的材料太重:${parts.join(';')}。评估者要逐条核对、还要复跑,材料越重越容易跑不完。没有截断、没有落账,请压一压再交:同一来源的合并成一条;每条只写「预测为何、实际为何」一句,读数与推导写进产物文件(放进这一步的 artifacts),由评估者去读。上限可在预设配置 auditMaterialLimits 里调。`,
|
|
1437
|
+
`The material for the independent evaluator is too heavy: ${parts.join('; ')}. The evaluator checks each item and may re-run the work, so heavy material makes it more likely to not finish. Nothing was truncated or recorded; trim it and deliver again: merge items with the same source; give each one sentence (what was expected, what was seen) and put readings and derivations in an output file listed in this step's artifacts for the evaluator to read. The limits can be changed with auditMaterialLimits in the preset config.`,
|
|
1438
|
+
)
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
/**
|
|
1442
|
+
* 宿主的子代理入口是哪一代(issue #38)。
|
|
1443
|
+
*
|
|
1444
|
+
* DSH 0.2.1-alpha.2 把 `subagents.start(provider, request)` 换成了 `startActivation(spec)`,
|
|
1445
|
+
* 而 `engines.dsh` 拦不住新宿主:装得上、跑得起,直到第一次派评估者才炸。
|
|
1446
|
+
* 按**方法在不在**判,不按版本号判 —— 方法在场就是能力本身,版本号只是它的间接证据。
|
|
1447
|
+
* 两个都在时走旧入口:那一代的 persona / toolFilter 是逐次请求给的,不依赖随包预设。
|
|
1448
|
+
*/
|
|
1449
|
+
function subagentApi(subagents) {
|
|
1450
|
+
if (typeof subagents?.start === 'function') return 'start'
|
|
1451
|
+
if (typeof subagents?.startActivation === 'function') return 'activation'
|
|
1452
|
+
return null
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* 新一代入口(宿主 ≥0.2.1-alpha.2)。
|
|
1457
|
+
*
|
|
1458
|
+
* 这一代的 `startActivation` 请求里**没有** `persona` / `toolFilter`:本地子会话的组合只取
|
|
1459
|
+
* `request.agentPreset`(宿主 `startLocal` 里是 `composition: { agentPreset }`),多传的字段被静默丢掉。
|
|
1460
|
+
* 若照旧把两项塞进请求、不选预设,评估者会加入父会话的 ClearAI 组合 —— 拿到写工具与 ClearAI 自己的工具,
|
|
1461
|
+
* 读到主人格的提示词,「独立、只读」就只剩一句话。所以评估者的工具面改由随包的评估者预设
|
|
1462
|
+
* (`CFG.auditPreset`)决定:平台按挂了哪些行给工具,不是靠我们事后拦。
|
|
1463
|
+
*
|
|
1464
|
+
* 评估纪律照旧写在任务书里(`evaluatorPrompt` 第一段就是它),预设的人格只说身份。
|
|
1465
|
+
* `delivery: 'caller'`:裁决只回到内核,不往父会话的模型面投递;子会话仍进父会话的目录,
|
|
1466
|
+
* 所以 `sweepEndedAudits` 的 `listChildren` 照样看得见它。
|
|
1467
|
+
*
|
|
1468
|
+
* 这一代 `signal` 只管「发布之前」;发布之后的取消归 `dispose`。与 0.5.4 起的语义一致:
|
|
1469
|
+
* 调用方中途放弃只是不再等,评估者不因此被掐断。
|
|
1470
|
+
*/
|
|
1471
|
+
async function dispatchActivation(subagents, options) {
|
|
1472
|
+
const schema = options.outputSchema ? nativeAuditSchema(options.outputSchema) : undefined
|
|
1473
|
+
const capability = `preset:${CFG.auditPreset}${schema === undefined ? '' : '+outputSchema'}`
|
|
1474
|
+
try {
|
|
1475
|
+
const activation = await subagents.startActivation({
|
|
1476
|
+
provider: CFG.auditProvider,
|
|
1477
|
+
label: options.label,
|
|
1478
|
+
delivery: 'caller',
|
|
1479
|
+
signal: options.signal ?? new AbortController().signal,
|
|
1480
|
+
request: {
|
|
1481
|
+
prompt: text(options.prompt),
|
|
1482
|
+
parent: options.parent,
|
|
1483
|
+
agentPreset: CFG.auditPreset,
|
|
1484
|
+
...(schema === undefined ? {} : { outputSchema: schema }),
|
|
1485
|
+
},
|
|
1486
|
+
})
|
|
1487
|
+
/** 回包归一成旧形状:这一代的身份叫 `childId`,下游(账本、目录对账、落定)只认 `id`。 */
|
|
1488
|
+
const run = { id: String(activation.childId), result: activation.result, dispose: () => activation.dispose() }
|
|
1489
|
+
return { ok: true, run, capability, native: false, degraded: null }
|
|
1490
|
+
} catch (error) {
|
|
1491
|
+
const failure = `${capability}:${String(error?.message ?? error).slice(0, 160)}`
|
|
1492
|
+
return { ok: false, reason: failure, failures: [failure] }
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1362
1496
|
/**
|
|
1363
1497
|
* **从评估者自己的会话日志里读回结论**(结论若只挂在父进程内存的 promise 上,父进程一断就永久丢)。
|
|
1364
1498
|
*
|
|
@@ -1730,6 +1864,8 @@ export function apply(ctx, config = {}) {
|
|
|
1730
1864
|
const skip = new Set([join(cwd, 'clear'), join(cwd, '.git'), join(cwd, 'node_modules')])
|
|
1731
1865
|
try {
|
|
1732
1866
|
cpSync(cwd, target, { recursive: true, filter: (source) => !skip.has(source) })
|
|
1867
|
+
// 记号写不进不影响复跑本身:任务书照样说明这是副本。
|
|
1868
|
+
try { markRerunCopy(cwd, target) } catch (error) { ctx.logger?.warn?.(`clearai kernel: 复跑副本记号没写成 ${String(error?.message ?? error).slice(0, 160)}`) }
|
|
1733
1869
|
return target
|
|
1734
1870
|
} catch (error) {
|
|
1735
1871
|
ctx.logger?.warn?.(`clearai kernel: 复跑副本没建成 ${String(error?.message ?? error).slice(0, 160)}`)
|
|
@@ -1738,8 +1874,43 @@ export function apply(ctx, config = {}) {
|
|
|
1738
1874
|
}
|
|
1739
1875
|
}
|
|
1740
1876
|
|
|
1877
|
+
/** 副本 → 项目声明的复跑环境变量(任务书要列给评估者)。副本删掉时一起丢。 */
|
|
1878
|
+
const rerunEnvironments = new Map()
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* **给副本做记号**(issue #35)。
|
|
1882
|
+
*
|
|
1883
|
+
* 副本只隔开了工作区:很多桌面引擎的用户数据目录按**项目名**定位(Godot 的 `user://`
|
|
1884
|
+
* = `%APPDATA%\Godot\app_userdata\<项目名>`),不随目录改变,于是评估者在副本里复跑,
|
|
1885
|
+
* 写的仍是原作者的全局目录,原作者的取证集里混进另一份代码态的产物。
|
|
1886
|
+
*
|
|
1887
|
+
* 内核替不了被检项目做决定(采集可能正是评估者要核的东西,所以**不关**),能做的是让「这是副本」可被看见:
|
|
1888
|
+
* · 副本根放一份 `.clearai-rerun.json`(原工作区不写):被检项目可以据此把输出改道到副本内;
|
|
1889
|
+
* · 项目若在工作区根声明了 `.clearai-rerun-env`(每行 `KEY=VALUE`,`{copy}` 换成副本路径),
|
|
1890
|
+
* 变量随标记写下,并由任务书列给评估者 —— 宿主不提供替子会话设环境变量的接口,只能告诉它复跑前先设。
|
|
1891
|
+
*/
|
|
1892
|
+
function markRerunCopy(cwd, target) {
|
|
1893
|
+
const environment = {}
|
|
1894
|
+
try {
|
|
1895
|
+
const declared = readFileSync(join(cwd, '.clearai-rerun-env'), 'utf8')
|
|
1896
|
+
for (const line of declared.split(/\r?\n/)) {
|
|
1897
|
+
const match = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*$/.exec(line)
|
|
1898
|
+
if (match === null || line.trimStart().startsWith('#')) continue
|
|
1899
|
+
environment[match[1]] = match[2].replaceAll('{copy}', target)
|
|
1900
|
+
}
|
|
1901
|
+
} catch {
|
|
1902
|
+
/* 没有声明就没有变量:标记照写 */
|
|
1903
|
+
}
|
|
1904
|
+
writeTextFile(
|
|
1905
|
+
join(target, '.clearai-rerun.json'),
|
|
1906
|
+
`${JSON.stringify({ clearai_rerun_copy: true, purpose: 'independent evaluator re-run', original_workspace: cwd, copy: target, environment, note: 'This directory is a disposable copy. Write outputs inside it; do not write the original author\'s global user-data directories.' }, null, 2)}\n`,
|
|
1907
|
+
)
|
|
1908
|
+
if (Object.keys(environment).length > 0) rerunEnvironments.set(target, environment)
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1741
1911
|
function dropRerunCopy(dir) {
|
|
1742
1912
|
if (dir === null) return
|
|
1913
|
+
rerunEnvironments.delete(dir)
|
|
1743
1914
|
try {
|
|
1744
1915
|
rmSync(dir, { recursive: true, force: true })
|
|
1745
1916
|
} catch {
|
|
@@ -4287,6 +4458,11 @@ export function apply(ctx, config = {}) {
|
|
|
4287
4458
|
if (grounding) return grounding
|
|
4288
4459
|
const level = step.tests?.level ?? null
|
|
4289
4460
|
const levelIndex = levelIndexOf(level)
|
|
4461
|
+
// ⓪ 交给评估者的材料先过体积闸门:在落账之前拒,被拒的这一批不留半截记录。
|
|
4462
|
+
if (levelIndex > SELF_JUDGE_MAX_INDEX) {
|
|
4463
|
+
const heavy = auditMaterialProblem(args.anomalies)
|
|
4464
|
+
if (heavy !== null) return fail('audit_material_too_large', heavy)
|
|
4465
|
+
}
|
|
4290
4466
|
|
|
4291
4467
|
// ① 登记观测(只追加)
|
|
4292
4468
|
const accepted = []
|
|
@@ -4800,20 +4976,31 @@ export function apply(ctx, config = {}) {
|
|
|
4800
4976
|
}
|
|
4801
4977
|
}
|
|
4802
4978
|
|
|
4803
|
-
// ═══ 事实边界:保护「系统所有」的路径 +
|
|
4979
|
+
// ═══ 事实边界:保护「系统所有」的路径 + shell 危险闸门 + L4 人放行 ═══════
|
|
4980
|
+
|
|
4981
|
+
/**
|
|
4982
|
+
* 门对**所有 shell 工具**生效:bash 与 pwsh。
|
|
4983
|
+
*
|
|
4984
|
+
* 从前三处硬边界都写死 `exec.name === 'bash'`,而本预设按平台只挂一个 shell
|
|
4985
|
+
* (`tool-bash` 在 win32 禁用,`tool-pwsh` 只在 win32 挂上,见 agent.cordis.yml)——
|
|
4986
|
+
* 于是 Windows 上危险命令闸、系统路径写检测、L4 人放行**整体失效**,
|
|
4987
|
+
* 而它们本该是平台无关的硬边界(社区 issue #30)。
|
|
4988
|
+
*/
|
|
4989
|
+
const SHELL_TOOLS = new Set(['bash', 'pwsh'])
|
|
4804
4990
|
|
|
4805
4991
|
const DENY_REASONS = [
|
|
4806
4992
|
[
|
|
4807
4993
|
['递归删除系统路径', 'recursive delete of a system path'],
|
|
4808
4994
|
(command) => {
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4995
|
+
// 每个 `rm` 段都查:只看第一段时,`rm a; rm -rf ~` 会从第二段漏过去。
|
|
4996
|
+
for (const match of command.matchAll(/(^|[;&|]\s*)rm\s+([^;&|]*)/gi)) {
|
|
4997
|
+
const segment = match[2]
|
|
4998
|
+
if (!(/(^|\s)-[A-Za-z]*r/i.test(segment) || segment.includes('--recursive'))) continue
|
|
4999
|
+
for (const token of segment.split(/\s+/)) {
|
|
5000
|
+
if (token === '' || token.startsWith('-')) continue
|
|
5001
|
+
const bare = token.replace(/^["']|["']$/g, '')
|
|
5002
|
+
if (bare === '/' || bare === '~' || bare.startsWith('~/') || /^\/[^/]+$/.test(bare)) return true
|
|
5003
|
+
}
|
|
4817
5004
|
}
|
|
4818
5005
|
return false
|
|
4819
5006
|
},
|
|
@@ -4835,6 +5022,39 @@ export function apply(ctx, config = {}) {
|
|
|
4835
5022
|
},
|
|
4836
5023
|
],
|
|
4837
5024
|
[['拉起宿主应用', 'launching the host app'], (command) => /\.app\/Contents\/MacOS\/|\bopen\s+-a\b/.test(command)],
|
|
5025
|
+
// ── pwsh 形态:Windows 上本预设只挂 pwsh,这几种写法缺了门就等于没有闸门。──
|
|
5026
|
+
[
|
|
5027
|
+
['递归删除系统路径(pwsh)', 'recursive delete of a system path (pwsh)'],
|
|
5028
|
+
(command) => {
|
|
5029
|
+
/**
|
|
5030
|
+
* 每一段都查,不只第一段:`Remove-Item a.txt; Remove-Item -Recurse C:\` 的危险在第二段。
|
|
5031
|
+
* 段边界除了 `; & |` 还有 `{ } ( )` 与换行(`% { Remove-Item -Recurse C:\ }`)。
|
|
5032
|
+
* 动词认 pwsh 的内置别名(`ri / rm / rmdir / rd / del / erase`)。
|
|
5033
|
+
*/
|
|
5034
|
+
const verbs = /(?:^|[;&|{}()\n]\s*)(?:remove-item|ri|rm|rmdir|rd|del|erase)\s+([^;&|{}()\n]*)/gi
|
|
5035
|
+
for (const match of command.matchAll(verbs)) {
|
|
5036
|
+
const tokens = match[1].split(/\s+/).filter((token) => token !== '')
|
|
5037
|
+
/**
|
|
5038
|
+
* 递归开关:pwsh 参数可以缩写成 `-recurse` 的任意前缀(`-r` / `-rec` / `-Recurse:$true`),
|
|
5039
|
+
* bash 式短开关簇(`-rf` / `-fr`)也算。`-Force` 不是递归 —— 从前「破折号后任意处有 r」把它也算进去了。
|
|
5040
|
+
*/
|
|
5041
|
+
const recursive = tokens.some((token) => /^-(r|re|rec|recu|recur|recurs|recurse)(:\$?true)?$/i.test(token) || /^-[fdiv]*r[fdiv]*$/i.test(token) || token.toLowerCase() === '--recursive')
|
|
5042
|
+
if (!recursive) continue
|
|
5043
|
+
for (const token of tokens) {
|
|
5044
|
+
if (token.startsWith('-')) continue
|
|
5045
|
+
const bare = token.replace(/^["']|["']$/g, '').toLowerCase().replaceAll('\\', '/').replace(/\/+$/, '')
|
|
5046
|
+
if (bare === '' || bare === '~' || bare.startsWith('~/') || bare === '$home' || bare.startsWith('$home/') || /^\/[^/]+$/.test(bare)) return true
|
|
5047
|
+
if (/^[a-z]:$/.test(bare) || /^[a-z]:\/(windows|users|program files|program files \(x86\))$/.test(bare)) return true
|
|
5048
|
+
if (/^(\$env:|env:)(systemroot|windir|systemdrive|userprofile|homedrive|programfiles)$/.test(bare) || /^%(systemroot|windir|systemdrive|userprofile)%$/.test(bare)) return true
|
|
5049
|
+
}
|
|
5050
|
+
}
|
|
5051
|
+
return false
|
|
5052
|
+
},
|
|
5053
|
+
],
|
|
5054
|
+
[['远程脚本直灌 shell(pwsh)', 'remote script piped into a shell (pwsh)'], (command) => /(iwr|invoke-webrequest|invoke-restmethod|curl|wget)\b[^;&|]*\|\s*(iex|invoke-expression)\b/i.test(command)],
|
|
5055
|
+
[['动态执行下载内容(pwsh)', 'dynamic execution of downloaded content (pwsh)'], (command) => /(iex|invoke-expression)\b[^;&|]*((iwr|invoke-webrequest|invoke-restmethod|curl|wget)\b|https?:\/\/)/i.test(command)],
|
|
5056
|
+
[['卷格式化(pwsh)', 'volume formatting (pwsh)'], (command) => /(^|[;&|]\s*)format-volume\b|(^|[;&|]\s*)format\s+[a-z]:/i.test(command)],
|
|
5057
|
+
[['提权(pwsh)', 'privilege escalation (pwsh)'], (command) => /(^|[;&|]\s*)(sudo|gsudo)\s/i.test(command)],
|
|
4838
5058
|
]
|
|
4839
5059
|
|
|
4840
5060
|
/**
|
|
@@ -4868,20 +5088,24 @@ export function apply(ctx, config = {}) {
|
|
|
4868
5088
|
return root === undefined ? null : root.join('/')
|
|
4869
5089
|
}
|
|
4870
5090
|
|
|
4871
|
-
/**
|
|
4872
|
-
|
|
4873
|
-
|
|
5091
|
+
/**
|
|
5092
|
+
* shell 命令里**写**系统格子的迹象:命令里出现了那一格(相对或绝对写法)且带写操作。只读命令不拦。
|
|
5093
|
+
* 两族 shell 的写动词都要认:bash 的 `rm / tee / sed -i`,pwsh 的 `Remove-Item / Set-Content / Out-File`。
|
|
5094
|
+
*/
|
|
5095
|
+
const WRITE_HINT = /((?<![0-9&])>(?!&|\s*\/dev\/null)|\b(rm|mv|cp|tee|touch|mkdir|ln|chmod|truncate|install|rsync|dd|del|ri|ni|sc|si)\b|\b(Remove-Item|Move-Item|Copy-Item|Set-Content|Add-Content|Clear-Content|New-Item|Out-File|Rename-Item|Tee-Object|Set-Item|Set-ItemProperty|Remove-ItemProperty)\b|\bsed\s+-i|\bperl\s+-[a-z]*i)/i
|
|
5096
|
+
function shellTouchesProtected(sessionId, command) {
|
|
4874
5097
|
if (typeof command !== 'string' || command === '' || !WRITE_HINT.test(command)) return null
|
|
4875
5098
|
const cwd = sessionCwd(sessionId)
|
|
4876
5099
|
for (const parts of PROTECTED_REL) {
|
|
4877
5100
|
const rel = parts.join('/')
|
|
4878
|
-
|
|
5101
|
+
// Windows 上模型会用反斜杠写相对路径(`clear\knowledge\facts\x.json`):只认正斜杠的门会当场漏掉。
|
|
5102
|
+
const forms = cwd === null ? [rel, rel.replaceAll('/', '\\')] : [rel, rel.replaceAll('/', '\\'), join(cwd, ...parts)]
|
|
4879
5103
|
for (const form of forms) {
|
|
4880
5104
|
let index = command.indexOf(form)
|
|
4881
5105
|
while (index !== -1) {
|
|
4882
5106
|
const rest = command.slice(index + form.length)
|
|
4883
|
-
/** 写的是三支本体目录:放行(挪目录正是重新分层的方式)
|
|
4884
|
-
if (!(parts.at(-1) === 'ontology' && ONTOLOGY_BRANCH_DIRS.some((branch) => rest.startsWith(`/${branch}`)))) return rel
|
|
5107
|
+
/** 写的是三支本体目录:放行(挪目录正是重新分层的方式)。反斜杠写法同样放行。 */
|
|
5108
|
+
if (!(parts.at(-1) === 'ontology' && ONTOLOGY_BRANCH_DIRS.some((branch) => rest.startsWith(`/${branch}`) || rest.startsWith(`\\${branch}`)))) return rel
|
|
4885
5109
|
index = command.indexOf(form, index + form.length)
|
|
4886
5110
|
}
|
|
4887
5111
|
}
|
|
@@ -5011,7 +5235,7 @@ export function apply(ctx, config = {}) {
|
|
|
5011
5235
|
* 是模型自己的,写进去要过第一道校验。
|
|
5012
5236
|
*/
|
|
5013
5237
|
const writing = exec.name === 'write' || exec.name === 'edit'
|
|
5014
|
-
const suspect = writing ? (protectedPath(sessionId, args.file_path) ?? protectedPath(sessionId, args.path)) : exec.name
|
|
5238
|
+
const suspect = writing ? (protectedPath(sessionId, args.file_path) ?? protectedPath(sessionId, args.path)) : SHELL_TOOLS.has(exec.name) ? shellTouchesProtected(sessionId, args.command) : null
|
|
5015
5239
|
if (suspect !== null) {
|
|
5016
5240
|
return {
|
|
5017
5241
|
kind: 'deny',
|
|
@@ -5025,12 +5249,12 @@ export function apply(ctx, config = {}) {
|
|
|
5025
5249
|
}
|
|
5026
5250
|
}
|
|
5027
5251
|
}
|
|
5028
|
-
if (CFG.bashDenyRules && exec.name
|
|
5252
|
+
if (CFG.bashDenyRules && SHELL_TOOLS.has(exec.name) && typeof args.command === 'string') {
|
|
5029
5253
|
for (const [reason, test] of DENY_REASONS) {
|
|
5030
|
-
if (test(args.command)) return { kind: 'deny', reason: tr(`危险的
|
|
5254
|
+
if (test(args.command)) return { kind: 'deny', reason: tr(`危险的 shell 命令(${reason[0]}):改写命令避开这种写法(dangerous shell command)`, `dangerous shell command (${reason[1]}); rewrite the command to avoid this pattern`) }
|
|
5031
5255
|
}
|
|
5032
5256
|
}
|
|
5033
|
-
if (owned && exec.name
|
|
5257
|
+
if (owned && SHELL_TOOLS.has(exec.name) && typeof args.command === 'string') {
|
|
5034
5258
|
const denied = await releaseIrreversible(exec, sessionId, state, args.command)
|
|
5035
5259
|
if (denied !== null) return denied
|
|
5036
5260
|
}
|
|
@@ -38,7 +38,7 @@ description: Use when working inside the ClearAI preset and a delivery keeps get
|
|
|
38
38
|
|
|
39
39
|
`holds=yes` 这一步就完成,不管 `results` 是支持、推翻还是说不清。推翻和说不清照样记成证据,判断的状态由证据算。评估卡写不进来时裁决降级为 `unknown`,这一步不推进,绝不静默放行。
|
|
40
40
|
|
|
41
|
-
评估卡、证据、事实由系统落盘;`clear/evidence`、`clear/knowledge/facts`、`clear/knowledge/lessons`、`clear/goals` 你都写不了。重评产生新证据,旧证据不改不删。
|
|
41
|
+
评估卡、证据、事实由系统落盘;`clear/evidence`、`clear/knowledge/facts`、`clear/knowledge/lessons`、`clear/knowledge/negatives`、`clear/goals` 你都写不了。重评产生新证据,旧证据不改不删。
|
|
42
42
|
|
|
43
43
|
## 本体文件被拒或被标出来
|
|
44
44
|
|
|
@@ -95,7 +95,7 @@ One card carries two verdicts, each answering its own question:
|
|
|
95
95
|
|
|
96
96
|
With `holds=yes` the step is complete, whatever `results` says. Refute and inconclusive are recorded as evidence all the same, and the judgment's status is computed from the evidence. If the card cannot be written, the verdict degrades to `unknown` and the step does not advance; it is never silently let through.
|
|
97
97
|
|
|
98
|
-
The system writes evaluator cards, evidence and facts; you cannot write `clear/evidence`, `clear/knowledge/facts`, `clear/knowledge/lessons` or `clear/goals`. A re-evaluation adds new evidence; old evidence is never changed or deleted.
|
|
98
|
+
The system writes evaluator cards, evidence and facts; you cannot write `clear/evidence`, `clear/knowledge/facts`, `clear/knowledge/lessons`, `clear/knowledge/negatives` or `clear/goals`. A re-evaluation adds new evidence; old evidence is never changed or deleted.
|
|
99
99
|
|
|
100
100
|
## When an ontology file is refused or flagged
|
|
101
101
|
|