fix(models): unify model selection entries and preserve routes on budget saves

This commit is contained in:
Agent Workbench Dev
2026-11-03 14:40:45 +08:00
parent 9ea2533f22
commit 6bd605ad15
29 changed files with 468 additions and 82 deletions
+7
View File
@@ -1,5 +1,12 @@
# Agent Workbench 更新记录
## 1.24.3 · 统一模型选择入口(发行验收中)
- 左下角和顶部都打开模型中心,可选择已有连接/模型池、添加模型;选中连接与旧会话实际运行分开展示。
- 运行预算独立保存,保留当前模型选择;演示切回真实连接可直接生效。新增和切换不自动请求模型。
- 原单连接编辑改为次级入口,明确「保存并切换原连接」,避免无意覆盖所选号池。
- 源码、路由与界面证据及正式部署进度见docs/QA-MODEL-SELECTION-K.md;本阶段真实模型请求0。
## 1.24.2 · 模型身份与交付推进修复(已本地交付)
- 分开显示请求型号与上游报告型号,保留原响应;可要求一致或使用有依据的显式映射,不一致时暂停并保留原用量。
+13
View File
@@ -0,0 +1,13 @@
# 选择和管理模型
左下角「模型与连接」、顶部当前模型按钮和「模型中心」打开同一个模型中心。上方「新任务默认模型」可直接选择已保存连接或模型池,也可点击「添加模型」保存新的接口、协议、请求型号和凭据。保存新连接后,再在选择器中选用它;新增和切换本身不调用模型。
需要凭据但尚未填写、或已经停用的连接不能在选择器中选用。可先编辑连接,或在「凭据保存」中保存、加载本机加密凭据。需要实测接口时,「验证响应(调用模型)」会发出请求并记录用量,区别于保存和切换操作。
默认选择用于后续运行。当前会话已有 Run 会保留当时封存的连接、请求型号、原响应和用量;切换默认不改写旧记录。模型池中的实际成员与上游报告型号请查看「请求账本」。请求的型号与上游报告的型号分别显示,名称本身不能认证底层模型权重。
「运行预算」可单独保存工具轮次、运行时间和 token 预算,保留所选连接或模型池。有效上下文与输出上限同时受连接自己的配置限制。有任务执行时,默认模型、添加连接与预算修改均锁定;服务端也拒绝其他会话的并发修改。
原单连接设置保留为「原模型连接 → 编辑 → 原连接与演示设置」。按钮明确标为「保存并切换原连接」,用于有意编辑并选用这条原连接。只调整运行预算时使用独立预算页。
其他标签页修改后,重新打开模型中心、点击刷新或返回窗口时会读取服务端当前选择。旧浏览器 URL 中的 `release` 参数只是历史链接参数,实际版本以左下角版本号为准。
+15
View File
@@ -0,0 +1,15 @@
# 1.24.3:统一模型入口修复
用户反馈左下角只能设置一个固定模型,怀疑它覆盖了 Claude 连接。实际界面与源码确认:旧左下角打开原单连接设置,顶部虽然显示「高性能」池,旧窗口仍显示 legacy GPT;保存该窗口会调用 `/api/config` 并选回 legacy。这里存在入口与保存语义问题。
J 原真实样本仍明确发送到 api.apikey.fan,请求 `claude-opus-5-5`,上游 SSE 报告 `gpt-6.1-sol`。本次界面问题不能解释该原样本。J 原请求、响应、用量和身份拒绝结论保持,见 [原预检结果](LIVE-MODEL-IDENTITY-J-RESULTS.md)。本阶段不重新调用真实模型。
修复统一左下角、顶部和模型中心,提供已有连接/模型池选择器与添加模型入口。独立预算与演示模式接口不会隐式选择 legacy。原连接编辑成为明确次级入口,保存按钮说明切换后果。打开中心和窗口恢复前台时同步服务端默认;已有 Run 的封存身份单独显示。
已通过 30/30 相关后端与源码编译。新编译 UI 的七组流程覆盖添加、切换、刷新、独立预算、原连接取消、演示切回真实模型、其他标签页选择同步、长名称和 390px、活动锁定与服务端 409。自有 HTTP 路由证明选中连接收到它的请求地址、型号和所属凭据,legacy 没有收到选中线路的请求;切换默认保持旧 Run 原记录。所有接口为自有 localhost 夹具,真实配置模型请求 0。
开发验收中的失败另保留:Playwright 对实际带 `disabled` 的原生 option 仍报告 enabled,两次原失败截图/日志保留;改为检查原生 `disabled` 属性。历史模型中心验收用 `.mc-content select` 匹配新增默认选择器后变成两个元素,已精确定位「配置格式」;没有放宽产品禁用或多元素规则。
六类相关历史 UI 已全部通过:模型中心、协议/流式/配对停止、严格型号核对、主工作台、运行诊断和执行/预算续接。修正了这几处验收器的旧按钮与标签名称,协议验收仍使用旧「实际模型名称」导致的失败亦保留。路由夹具改为合法无工具响应后,三项新路由检查再次通过,明确原连接的独立请求能够完成。
独立发行重建、安装、正式部署及数据保留证据继续验收,最终结果在本报告续记。此时不能把源码通过写成已经上线。
+6
View File
@@ -1,5 +1,11 @@
# 汇总发现
## K:模型入口分裂的实际原因
实际内置浏览器左下角“模型连接”打开原设置,尽管顶部显示“高性能”,窗口仍展示 legacy jojocode/gpt-6.1-sol。App.saveSettings POST /config,服务端 hub.select({type:'legacy'}, config);所以保存原设置会隐式切回 legacy。ModelCenter 添加/选择能力已有但不是左下角入口。J原请求实际地址 api.apikey.fan、model claude-opus-5-5、指定 connectionId 与原响应均封存,不能把上游返回gpt现象归为原模型默认覆盖。设计对比:仅换按钮跳转能消除最明显分裂,但仍需多卡寻找;新增独立切换弹窗又形成多入口状态。选用统一模型中心顶部紧凑默认选择器+现有连接管理,保留原品牌/React栈,明确旧配置的作用。CUA旧连接browser.user错误经一次重建会话恢复;未修改正式配置。
新UI七组与六类相关历史UI实际通过;桌面/390px长名称和当前默认/旧Run信息均目视核对。两个独立localhost接口核对了实际发送地址、所属Key、请求model和原请求SHA;严格返回不一致先暂停,另选legacy有独立合法成功响应,旧Run保持。预算独立接口拒绝路由字段注入;活动期间UI锁定且其他会话API409。本轮未做真实上游调用,不将夹具结果解释为Claude/Purge实测收益。
## 当前 J:apikey 线路仍存在请求/返回身份差异
用户指定 apikey Claude 的独立新样本中,封存请求模型为 claude-opus-5-5,完整 SSE 为 gpt-6.1-sol;单次4307+27=4334报告tokens,严格门禁在工具执行前暂停。接口能回复唯一 nonce,但不能用于认证 Claude 能力或模型权重。已恢复原状态并独立核对全部原行和原70导出/3566工件;更正连接前不做工程/Purge。raw usage 额外包含 cache_write_tokens4304,离线验证器按三项规范化总量核对并单独核对原详细字段;初封存源码/清单保持,加法更正,不把缓存报告解释为收益。
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "local-agent-workbench",
"version": "1.24.2",
"version": "1.24.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "local-agent-workbench",
"version": "1.24.2",
"version": "1.24.3",
"dependencies": {
"@babel/parser": "7.29.11",
"@peculiar/x509": "3.1.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "local-agent-workbench",
"version": "1.24.2",
"version": "1.24.3",
"private": true,
"type": "module",
"description": "A local coding workbench with explicit tool execution, reviewable changes and recoverable sessions.",
+6
View File
@@ -1,5 +1,11 @@
# 统一执行进度
## K:模型入口核查与修复
用户要求查明左下角固定模型是否覆盖测试。已实际打开该窗口(未保存),复现旧单连接与顶部号池显示不一致;源码确认保存会选legacy。已建立fix/model-selection-entry-1.24.3,开始统一入口、直接选择和新建、模型默认与实际运行区分的集中修复。J原件保持,本轮真实请求0。
1.24.3实现已完成;30/30相关后端、最终构建、七组新编译UI与六类相关历史UI通过,三项路由夹具合法无工具响应补验通过。原生option两次误判、历史泛选择器、旧协议字段标签首失败保持,没有放宽产品规则。正式原生窗口已用Computer Use只读回看并关闭,原PID36552/Provider/hasKey=true/idle与windows=0核对;开始不可变发行和保留状态安装验收。
## 当前 J:单次真实身份预检结束
apikey 请求 claude-opus-5-5,上游标记 gpt-6.1-sol;1 请求/4334 报告 tokens/0 工具,系统以 model_identity 暂停。原 PID36552/Provider/凭据保持,70 原导出/3566 原工件及原表行核对完成;原池/参数恢复,公开修订与等价默认身份字段如实记录。30 份/190046 字节新证据离线通过;未启动工程或 Purge。首三次整表验收器失败和首次封存中离线脚本 raw usage 比较修正均追加保留,不重发真实请求。详见 docs/LIVE-MODEL-IDENTITY-J-RESULTS.md。
+1
View File
@@ -21,6 +21,7 @@ const prefixes = Object.freeze({
'1.24.0': 'existing-results',
'1.24.1': 'delivery-reliability',
'1.24.2': 'delivery-integrity',
'1.24.3': 'model-selection',
});
export function releaseEvidencePrefix(version) {
const prefix = prefixes[version];
+20 -20
View File
@@ -9,36 +9,36 @@ import { randomUUID } from 'node:crypto';
if (process.argv.slice(2).some(value => value !== '--help')) throw new Error('Unsupported argument; use --help.');
if (process.argv.includes('--help')) { console.log('node scripts/verify-all-ui.mjs - run serial desktop/390px checks in independent local hosts; use explicit QA Python/Harness/Purge source paths for 1.15.'); process.exit(0); }
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
assert.ok(['1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version), 'Review evidence paths when introducing the next release.');
assert.ok(['1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version), 'Review evidence paths when introducing the next release.');
const prefix = releaseEvidencePrefix(version), resultFile = `.qa/${prefix}-all-ui-validation.json`, results = [];
const qaEnvironment = Object.fromEntries(['AGENT_WORKBENCH_TEST_PYTHON', 'AGENT_WORKBENCH_DEEPSEEK_ROOT', 'AGENT_WORKBENCH_PURGE_178_ROOT', 'AGENT_WORKBENCH_PURGE_181_ROOT']
.filter(name => process.env[name]).map(name => [name, process.env[name]]));
for (const [name, value] of Object.entries(qaEnvironment)) assert.ok(path.isAbsolute(value) && fs.existsSync(value), 'Use an existing absolute QA runtime/source path: ' + name);
const cases = [
...(['1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-file-results-ui.mjs', null]] : []),
...(['1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-release-efficiency-ui.mjs', null]] : []),
...(['1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-local-files.mjs', null]] : []),
...(['1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version)?[['verify-embedded-browser.mjs',null]]:[]),
...(['1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version)?[['verify-environment-ui.mjs',null],['verify-model-fidelity-ui.mjs',null],['verify-model-wait-ui.mjs',null],['verify-task-control-ui.mjs',null]]:[]),
...(['1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-evaluations-ui.mjs', null]] : []),
...(['1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-project-cache-ui.mjs', null]] : []),
...(['1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-vision-ui.mjs', null]] : []),
...(['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-model-protocols-ui.mjs', null]] : []),
...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-companion-ui.mjs', null]] : []),
...(['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-controlled-ui.mjs', null], ['verify-purge-ui.mjs', null]] : []),
...(['1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-workers-ui.mjs', null]] : []),
...(['1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-task-plans-ui.mjs', `docs/${prefix}-task-ui-validation.json`]] : []),
...(['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-browser-ui.mjs', `docs/${prefix}-browser-ui-validation.json`]] : []),
...(['1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-file-results-ui.mjs', null]] : []),
...(['1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-release-efficiency-ui.mjs', null]] : []),
...(['1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-local-files.mjs', null]] : []),
...(['1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version)?[['verify-embedded-browser.mjs',null]]:[]),
...(['1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version)?[['verify-environment-ui.mjs',null],['verify-model-fidelity-ui.mjs',null],['verify-model-wait-ui.mjs',null],['verify-task-control-ui.mjs',null]]:[]),
...(['1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-evaluations-ui.mjs', null]] : []),
...(['1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-project-cache-ui.mjs', null]] : []),
...(['1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-vision-ui.mjs', null]] : []),
...(['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-model-protocols-ui.mjs', null]] : []),
...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-companion-ui.mjs', null]] : []),
...(['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-controlled-ui.mjs', null], ['verify-purge-ui.mjs', null]] : []),
...(['1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-workers-ui.mjs', null]] : []),
...(['1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-task-plans-ui.mjs', `docs/${prefix}-task-ui-validation.json`]] : []),
...(['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-browser-ui.mjs', `docs/${prefix}-browser-ui-validation.json`]] : []),
['verify-ui.mjs', '.qa/ui-validation.json'], ['verify-diagnostics-ui.mjs', '.qa/diagnostics-ui-validation.json'],
['verify-execution-ui.mjs', '.qa/execution-ui-validation.json'], ['verify-delivery-ui.mjs', '.qa/delivery-ui-validation.json'],
['verify-index-ui.mjs', '.qa/index-ui-result.json'], ['verify-change-sets-ui.mjs', `docs/${prefix}-batch-ui-validation.json`],
['verify-context-ui.mjs', `.qa/${version === '1.6.0' ? 'workspaces-context' : prefix}-ui-validation.json`],
['verify-workspaces-ui.mjs', `docs/${prefix === 'workspaces' ? prefix : prefix + '-workspaces'}-ui-validation.json`],
...(['1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-python-ui.mjs', `docs/${prefix}-python-ui-validation.json`]] : []),
...(['1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-react-delivery.mjs', version === '1.7.0' ? 'docs/react-engine-delivery-validation.json' : `docs/${prefix}-react-delivery-validation.json`]] : []),
...(['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-research-ui.mjs', `docs/${prefix}-research-ui-validation.json`]] : []),
...(['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? [['verify-engines-ui.mjs', version === '1.9.0' ? 'docs/engines-ui-validation.json' : `docs/${prefix}-engines-ui-validation.json`]] : []),
...(['1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(version) ? ['model-center', 'project-memory', 'task-checkpoints', 'skills', 'mcp', 'mcp-recovery'].map(name => [`verify-${name}-ui.mjs`, null]) : []),
...(['1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-python-ui.mjs', `docs/${prefix}-python-ui-validation.json`]] : []),
...(['1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-react-delivery.mjs', version === '1.7.0' ? 'docs/react-engine-delivery-validation.json' : `docs/${prefix}-react-delivery-validation.json`]] : []),
...(['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-research-ui.mjs', `docs/${prefix}-research-ui-validation.json`]] : []),
...(['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? [['verify-engines-ui.mjs', version === '1.9.0' ? 'docs/engines-ui-validation.json' : `docs/${prefix}-engines-ui-validation.json`]] : []),
...(['1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version) ? ['model-center', 'project-memory', 'task-checkpoints', 'skills', 'mcp', 'mcp-recovery'].map(name => [`verify-${name}-ui.mjs`, null]) : []),
];
fs.mkdirSync('.qa', { recursive: true });
const externalHost = new Set(['verify-ui.mjs', 'verify-diagnostics-ui.mjs', 'verify-execution-ui.mjs', 'verify-index-ui.mjs']);
+1 -1
View File
@@ -149,7 +149,7 @@ try {
const beforeRestart = snapshotPersistentData(dataRoot); await controller.stop(); const restarted = (await controller.start()).identity;
assert.notEqual(restarted.pid, original.pid); assert.deepEqual(snapshotPersistentData(dataRoot), beforeRestart);
await controller.api('/model-center/probe', { method: 'POST', input: { id: connectionId } }); assert.equal(authenticated, 3); record(stage, { originalPid: original.pid, restartedPid: restarted.pid, authenticatedRequests: authenticated });
if (['1.24.0', '1.24.1', '1.24.2'].includes(version)) {
if (['1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(version)) {
stage = 'actual installed current results and saved HTML user paths';
const pointer = JSON.parse(fs.readFileSync(path.join(installRoot, 'current.json')));
const installedRoot = fs.realpathSync.native(path.join(installRoot, 'versions', pointer.active.directory)), proofs = [];
+6 -2
View File
@@ -87,7 +87,11 @@ const task = async content => {
await page.getByLabel('任务内容').fill(content); await page.getByRole('button', { name: '发送任务', exact: true }).click();
await page.waitForFunction(() => !!localStorage.getItem('awb-session')); sessionId = await page.evaluate(() => localStorage.getItem('awb-session'));
};
const settings = async () => { await page.getByRole('button', { name: '模型连接', exact: true }).click(); return page.getByRole('dialog', { name: '模型连接' }); };
const settings = async () => {
await page.getByRole('button', { name: '选择与管理模型', exact: true }).click();
await page.getByRole('dialog', { name: '模型中心', exact: true }).locator('.mc-connection').filter({ has: page.getByRole('heading', { name: '原模型连接', exact: true }) }).getByRole('button', { name: '编辑', exact: true }).click();
return page.getByRole('dialog', { name: '原连接与演示设置', exact: true });
};
try {
page = await browser.newPage({ viewport: { width: 1440, height: 960 }, deviceScaleFactor: 1 }); page.setDefaultTimeout(15000);
page.on('pageerror', error => pageErrors.push(error.message));
@@ -103,7 +107,7 @@ try {
await connection.getByLabel('模型名称').fill('ui-diagnostics-fixture');
await connection.getByRole('button', { name: '验证模型响应', exact: true }).click();
await connection.getByText(/模型响应验证通过/).waitFor(); assert.equal((await api('/diagnostics')).connection.mode, 'demo');
await connection.getByRole('button', { name: '保存连接', exact: true }).click(); await connection.waitFor({ state: 'hidden' });
await connection.getByRole('button', { name: '保存并切换原连接', exact: true }).click(); await connection.waitFor({ state: 'hidden' });
mark('model response validation checks the tentative connection before saving');
requestCount = 0; await task('制造读取成功后的模型服务错误'); await waitState('failed');
+7 -3
View File
@@ -108,11 +108,15 @@ try {
await expect(page.locator('.session-list')).toContainText('断线期间的其他项目任务'); await page.getByLabel('当前项目').selectOption(project.id); expectedDisconnect = false;
mark('reconnection synchronizes missed session changes in other projects');
await page.getByRole('button', { name: '模型连接', exact: true }).click(); const settings = page.getByRole('dialog', { name: '模型连接' });
const openLegacy = async () => {
await page.getByRole('button', { name: '选择与管理模型', exact: true }).click();
await page.getByRole('dialog', { name: '模型中心', exact: true }).locator('.mc-connection').filter({ has: page.getByRole('heading', { name: '原模型连接', exact: true }) }).getByRole('button', { name: '编辑', exact: true }).click();
};
await openLegacy(); const settings = page.getByRole('dialog', { name: '原连接与演示设置', exact: true });
await settings.getByText('上下文与任务预算', { exact: true }).click(); await settings.getByLabel('单次运行token预算').fill('1000'); await settings.getByLabel('运行时间预算').fill('2'); await settings.getByLabel('任务累计token预算').fill('50000');
await settings.getByRole('button', { name: '保存连接' }).click(); mode = 'budget'; await newTask('保留预算暂停的任务目标'); await waitState('paused');
await settings.getByRole('button', { name: '保存并切换原连接' }).click(); mode = 'budget'; await newTask('保留预算暂停的任务目标'); await waitState('paused');
const original = await state(); assert.equal(original.execution.run.stopReason, 'token_limit'); assert.equal(original.approvals.length, 0);
await page.getByRole('button', { name: '模型连接', exact: true }).click(); await settings.getByText('上下文与任务预算', { exact: true }).click(); await settings.getByLabel('单次运行token预算').fill('16000'); await settings.getByRole('button', { name: '保存连接' }).click();
await openLegacy(); await settings.getByText('上下文与任务预算', { exact: true }).click(); await settings.getByLabel('单次运行token预算').fill('16000'); await settings.getByRole('button', { name: '保存并切换原连接' }).click();
mode = 'answer'; await page.getByRole('button', { name: '继续任务', exact: true }).click(); await waitState('completed');
const resumed = await state(); assert.equal(resumed.execution.task.id, original.execution.task.id); assert.equal(resumed.execution.runs.length, 2);
await page.getByRole('button', { name: '查看任务记录' }).click(); await taskPanel().getByLabel('选择运行记录').selectOption(original.execution.run.id);
+1 -1
View File
@@ -60,7 +60,7 @@ try {
await dialog.getByRole('button', { name: '配置导入', exact: true }).click();
await expect(dialog.locator('.mc-tabs button[aria-current]')).toContainText('配置导入');
await dialog.locator('.mc-content select').selectOption('workbench-json');
await dialog.getByLabel('配置格式').selectOption('workbench-json');
await dialog.getByLabel('本地文件路径', { exact: true }).fill(importFile);
await dialog.getByRole('button', { name: '预览可导入连接', exact: true }).click();
await expect(dialog.locator('.mc-editor').filter({ hasText: '本次预览' })).toContainText('Imported Fixture');
+1 -1
View File
@@ -66,7 +66,7 @@ try {
await expect(form.getByLabel('使用流式输出', { exact: true })).toBeDisabled();
await form.getByLabel('流式能力', { exact: true }).selectOption('supported'); await form.getByLabel('使用流式输出', { exact: true }).check();
await form.getByLabel('接口根地址', { exact: true }).fill('http://127.0.0.1:' + modelServer.address().port + '/v1');
await form.getByLabel('实际模型名称', { exact: true }).fill('owned-responses'); await form.getByLabel('服务需要 API Key', { exact: true }).uncheck();
await form.getByLabel('请求模型名称', { exact: true }).fill('owned-responses'); await form.getByLabel('服务需要 API Key', { exact: true }).uncheck();
await shot(page, 'desktop-editor'); await page.setViewportSize({ width: 390, height: 844 }); await form.scrollIntoViewIfNeeded(); await shot(page, 'narrow-editor');
await form.getByRole('button', { name: '保存模型连接', exact: true }).click(); await expect(form).toHaveCount(0);
await page.reload(); await page.getByRole('button', { name: '打开模型中心', exact: true }).click();
+149
View File
@@ -0,0 +1,149 @@
import fs from 'node:fs';
import path from 'node:path';
import http from 'node:http';
import assert from 'node:assert/strict';
import { createHash, randomUUID } from 'node:crypto';
import { chromium, expect } from 'playwright/test';
import { fixture, launchWorkbench, until } from '../tests/helpers.mjs';
import { Provider } from '../src/server/provider.mjs';
if (process.argv.includes('--help')) { console.log('node scripts/verify-model-selection-ui.mjs [--app-root ABS] — isolated compiled UI, two owned HTTP routes, add/switch/budget/reload/demo/locking at desktop and 390px; no configured-model calls'); process.exit(0); }
const args = process.argv.slice(2);
assert.ok(!args.length || args.length === 2 && args[0] === '--app-root' && path.isAbsolute(args[1]));
const appRoot = args[1] ?? process.cwd();
const directory = path.resolve('.qa/model-selection-k-' + randomUUID()); fs.mkdirSync(directory, { recursive: true });
const disposers = [], t = { after: fn => disposers.push(fn) }, f = fixture(t), requests = [];
let release, block = false;
const upstream = http.createServer(async (req, res) => {
const chunks = []; for await (const chunk of req) chunks.push(chunk);
const body = JSON.parse(Buffer.concat(chunks)); requests.push({ url: req.url, body });
if (block) await new Promise(resolve => { release = resolve; });
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ model: body.model, choices: [{ message: { role: 'assistant', content: 'Owned route receipt.' } }],
usage: { prompt_tokens: 13, completion_tokens: 7, total_tokens: 20 } }));
});
await new Promise(resolve => upstream.listen(0, '127.0.0.1', resolve));
const endpoint = 'http://127.0.0.1:' + upstream.address().port;
f.store.saveConfig({ mode: 'compatible', baseUrl: endpoint + '/legacy/v1', model: 'owned-legacy-gpt', maxSteps: 1 });
const provider = new Provider(), hub = provider.modelHub(f.store);
const selected = hub.upsert({ name: 'Claude · 自有接口', model: 'owned-claude', baseUrl: endpoint + '/selected/v1', requiresKey: false, modelIdentityPolicy: 'require-match' });
const noKey = hub.upsert({ name: '待填凭据', model: 'no-credential', baseUrl: endpoint + '/no-key/v1' });
const pool = hub.pool({ name: '工程模型池', members: [{ connectionId: selected.id, weight: 1 }], strategy: 'round-robin', sticky: true, maxAttempts: 1, queueTimeoutMs: 1000 });
hub.select({ type: 'pool', id: pool.id }); f.store.close();
const nodePath = fs.existsSync(path.join(appRoot, 'runtime/node.exe')) ? path.join(appRoot, 'runtime/node.exe') : process.execPath;
const host = await launchWorkbench(t, f.data, {}, { appRoot, nodePath });
assert.notEqual(new URL(host.url).port, '4318');
let browser, page, result; const checks = [], screenshots = [], errors = [];
const mark = name => { checks.push(name); console.log('PASS ' + name); };
const capture = async name => { const file = path.join(directory, name + '.png'); await page.screenshot({ path: file }); screenshots.push({ path: file, sha256: createHash('sha256').update(fs.readFileSync(file)).digest('hex') }); };
const dialog = () => page.getByRole('dialog', { name: '模型中心', exact: true });
const select = () => dialog().getByLabel('新任务默认模型', { exact: true });
const close = () => dialog().getByRole('button', { name: '关闭窗口', exact: true }).click();
try {
browser = await chromium.launch({ channel: 'msedge', headless: true }); page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
page.on('pageerror', error => errors.push(error.message));
await page.goto(host.url); await page.waitForLoadState('networkidle'); await page.getByLabel('当前项目').selectOption(f.project.id);
await page.getByRole('button', { name: '选择与管理模型', exact: true }).click();
await expect(dialog()).toBeVisible(); await expect(select()).toHaveValue('pool:' + pool.id);
// This Playwright build reports disabled <option> as enabled. Inspect the
// native option property instead; the original DOM/error is kept in QA.
await expect(select().locator('option[value="connection:' + noKey.id + '"]')).toHaveJSProperty('disabled', true);
await capture('unified-entry-desktop');
await select().selectOption('connection:' + selected.id);
await expect(dialog().locator('.mc-current')).toContainText(selected.name);
assert.equal((await host.api('/model-center/selection')).modelSelection.id, selected.id);
await close(); await expect(page.getByRole('button', { name: '选择与管理模型' })).toContainText(selected.name);
await expect(page.getByRole('button', { name: '切换当前模型' })).toContainText(selected.name);
mark('sidebar and header share the authoritative multi-model selector; selection persists without a request');
await page.getByRole('button', { name: '切换当前模型', exact: true }).click();
await dialog().getByRole('button', { name: '添加模型', exact: true }).click();
const form = dialog().getByRole('form', { name: '编辑模型连接', exact: true });
const longName = 'DeepSeek · 本机工程备用连接与长名称适配';
await form.getByLabel('连接名称', { exact: true }).fill(longName);
await form.getByLabel('接口根地址', { exact: true }).fill(endpoint + '/new/v1');
await form.getByLabel('请求模型名称', { exact: true }).fill('owned-new-model');
await form.getByLabel('服务需要 API Key', { exact: true }).uncheck();
await form.getByRole('button', { name: '保存模型连接', exact: true }).click(); await expect(form).toHaveCount(0);
assert.equal((await host.api('/model-center/selection')).modelSelection.id, selected.id);
const added = (await host.api('/model-center')).connections.find(c => c.name === longName); assert.ok(added);
await select().selectOption('connection:' + added.id); await expect(select()).toHaveValue('connection:' + added.id);
await close(); await page.reload(); await page.getByRole('button', { name: '选择与管理模型' }).click();
await expect(select()).toHaveValue('connection:' + added.id); assert.equal(requests.length, 0);
mark('add from primary entry keeps the previous default, supports a new selection and survives reload without paid probes');
await select().selectOption('pool:' + pool.id); await expect(select()).toHaveValue('pool:' + pool.id);
await dialog().getByRole('button', { name: '运行预算', exact: true }).click();
const budgets = dialog().getByRole('form', { name: '运行预算设置', exact: true });
await budgets.getByLabel('上下文预算', { exact: true }).fill('32000');
await budgets.getByLabel('单次运行 tokens', { exact: true }).fill('90000');
await budgets.getByRole('button', { name: '保存运行预算', exact: true }).click();
await expect(dialog().getByRole('status')).toContainText('当前模型选择保持');
assert.equal((await host.api('/model-center/selection')).modelSelection.id, pool.id);
await dialog().getByRole('button', { name: '模型连接', exact: true }).click();
await dialog().locator('.mc-connection').filter({ has: page.getByRole('heading', { name: '原模型连接', exact: true }) }).getByRole('button', { name: '编辑', exact: true }).click();
const legacy = page.getByRole('dialog', { name: '原连接与演示设置', exact: true });
await expect(legacy.getByRole('button', { name: '保存并切换原连接', exact: true })).toBeVisible();
await legacy.getByRole('button', { name: '取消', exact: true }).click();
assert.equal((await host.api('/model-center/selection')).modelSelection.id, pool.id);
mark('budget-only saves preserve the pool and original connection editing is explicitly secondary and cancellable');
await page.getByLabel('任务内容').fill('仅回复一次,用于自有接口路由验收,不执行工具。');
await page.getByRole('button', { name: '发送任务', exact: true }).click();
await until(async () => { const current = await host.api('/sessions/' + f.session.id); return current.status !== 'running' && current.execution.run?.consumption?.length === 1; });
const firstRun = (await host.api('/sessions/' + f.session.id)).execution.run; const frozen = structuredClone(firstRun);
assert.equal(requests.length, 1); assert.equal(requests[0].url, '/selected/v1/chat/completions'); assert.equal(requests[0].body.model, selected.model);
await page.getByRole('button', { name: '切换当前模型' }).click();
await select().selectOption('legacy:legacy-default'); await expect(select()).toHaveValue('legacy:legacy-default');
await expect(dialog().locator('.mc-run-model')).toContainText(selected.model);
assert.deepEqual((await host.api('/sessions/' + f.session.id)).execution.run, frozen);
await capture('default-versus-run-desktop'); await close();
mark('actual pool request reaches only the selected endpoint; changing defaults preserves the sealed old Run and shows both identities');
await host.api('/model-center/select', { type: 'connection', id: selected.id });
await page.getByRole('button', { name: '打开模型中心', exact: true }).click();
await expect(select()).toHaveValue('connection:' + selected.id); await close();
await expect(page.getByRole('button', { name: '切换当前模型' })).toContainText(selected.name);
await page.getByRole('button', { name: '切换当前模型' }).click(); await select().selectOption('demo'); await expect(select()).toHaveValue('demo');
assert.equal((await host.api('/model-center')).selected.id, selected.id);
await select().selectOption('legacy:legacy-default'); await expect(select()).toHaveValue('legacy:legacy-default');
assert.equal((await host.api('/model-center/selection')).config.mode, 'compatible');
await close();
mark('opening refreshes another tab selection and choosing a real connection exits demo without losing profiles');
await page.setViewportSize({ width: 390, height: 844 }); await page.getByRole('button', { name: '切换当前模型' }).click();
await expect(select()).toHaveValue('legacy:legacy-default');
await select().selectOption('connection:' + added.id); await expect(select()).toHaveValue('connection:' + added.id);
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
await capture('selection-390'); await close();
await page.getByRole('button', { name: '展开项目栏' }).click();
await expect(page.getByRole('button', { name: '选择与管理模型' })).toContainText(longName);
await page.getByRole('button', { name: '选择与管理模型' }).click(); await expect(select()).toHaveValue('connection:' + added.id);
await capture('sidebar-entry-390'); await close();
mark('390px header and sidebar both add and switch with long model labels and no page overflow');
await page.setViewportSize({ width: 1440, height: 1000 }); await host.api('/model-center/select', { type: 'connection', id: selected.id });
block = true; const second = await host.api('/sessions', { projectId: f.project.id });
await host.api('/sessions/' + second.id + '/messages', { content: 'Owned held request.' });
await until(() => requests.length === 2 && release);
await page.reload(); await page.getByRole('button', { name: '切换当前模型' }).click();
// The host also rejects edits if the active task belongs to a different visible session.
const attempted = await fetch(host.url + '/api/model-center/runtime-budgets', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': host.bootstrap.token }, body: JSON.stringify({ maxSteps: 4 }) });
assert.equal(attempted.status, 409);
await expect(select()).toBeDisabled(); await expect(dialog().getByRole('button', { name: '添加模型', exact: true })).toBeDisabled();
await capture('active-request-lock'); release(); block = false;
await until(async () => (await host.api('/sessions/' + second.id)).status !== 'running');
assert.deepEqual(errors, []);
mark('active request locks route and add controls and server rejects budget overrides across sessions');
result = { success: true, appRoot, testedVersion: (await host.api('/health')).version, directory, checks, screenshots, errors,
requests: requests.map(r => ({ path: r.url, model: r.body.model })), realModelRequests: 0 };
} catch (error) {
if (page) fs.writeFileSync(path.join(directory, 'failure.html'), await page.content());
fs.writeFileSync(path.join(directory, 'failure-center.json'), JSON.stringify(await host.api('/model-center'), null, 2));
if (page) await capture('failure').catch(() => {}); result = { success: false, directory, error: error.stack, checks, screenshots, errors, realModelRequests: 0 }; throw error;
} finally {
release?.(); fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2) + '\n');
console.log(JSON.stringify({ success: result.success, directory, checks: checks.length }));
await browser?.close(); upstream.closeAllConnections(); await new Promise(resolve => upstream.close(resolve));
for (const dispose of disposers.reverse()) await dispose();
}
+7 -7
View File
@@ -34,7 +34,7 @@ for (const name of Object.keys(env)) if (name.toLowerCase() === 'path') delete e
const windowsRoot = process.env.SystemRoot || 'C:\\Windows';
env.PATH = [windowsRoot, path.join(windowsRoot, 'System32'), path.join(windowsRoot, 'System32', 'WindowsPowerShell', 'v1.0')].join(path.delimiter);
let externalGit = null;
if (['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(manifest.version)) {
if (['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(manifest.version)) {
// The controlled project requires external Git. Preserve its observed binary
// directory while keeping system Node/npm unavailable to the packaged host.
const binary = fs.realpathSync.native(execFileSync('where.exe', ['git.exe'], { env: gitEnvironment(), encoding: 'utf8', windowsHide: true, timeout: 10000 }).trim().split(/\r?\n/)[0]);
@@ -88,7 +88,7 @@ try {
console.log((await launch()).trim());
assert.equal(JSON.parse(fs.readFileSync(path.join(data, 'service-info.json'), 'utf8')).pid, firstInfo.pid);
const example = bootstrap.projects.find(project => project.id === bootstrap.exampleProjectId);
if (['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(manifest.version)) {
if (['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(manifest.version)) {
assert.equal(path.resolve(example.root).toLowerCase(), path.join(data, 'projects', 'starter-project').toLowerCase());
const compareTemplate = relative => { for (const entry of fs.readdirSync(path.join(appRoot, 'examples/starter-project', relative), { withFileTypes: true })) {
const next = path.join(relative, entry.name); if (entry.isDirectory()) compareTemplate(next);
@@ -114,7 +114,7 @@ try {
const checkLog = await api('/artifacts/' + checked.results[0].logArtifactId + '?session=' + session.id); assert.match(checkLog.content, /tests 4/);
assert.ok(fs.existsSync(path.join(appRoot, 'runtime/node_modules/npm/bin/npm-cli.js')));
const actualRea = [];
if (['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(manifest.version)) {
if (['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(manifest.version)) {
const installation = await api('/research/availability'); assert.equal(installation.status, 'available'); assert.equal(installation.version, '6.8.0');
assert.equal(fs.realpathSync.native(installation.packageRoot), fs.realpathSync.native(path.join(appRoot, 'runtime/node_modules/rea-agents')));
assert.equal(fs.realpathSync.native(installation.node.path), fs.realpathSync.native(path.join(appRoot, 'runtime/node.exe')));
@@ -146,7 +146,7 @@ try {
console.log('PASS actual contained REA: ASAR, PE imports and PE resources; zero target execution/model requests');
}
let actualEngine = null;
if (['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(manifest.version) && process.argv.includes('--native-engines')) {
if (['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(manifest.version) && process.argv.includes('--native-engines')) {
const installation = await api('/engines/deepseek/availability'); assert.equal(installation.status, 'available', installation.message);
assert.equal(fs.realpathSync.native(installation.node.path), fs.realpathSync.native(path.join(appRoot, 'runtime/node.exe')));
const engineRoot = path.join(data, 'engine-project'); fs.mkdirSync(engineRoot); fs.writeFileSync(path.join(engineRoot, 'README.md'), '# Owned portable engine connection\n');
@@ -166,8 +166,8 @@ try {
assert.equal((await api('/research')).length, 4);
const page = await fetch(url); assert.equal(page.status, 200);
assert.match(await page.text(), /Agent Workbench/);
const actualBrowser = ['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(manifest.version) ? await verifyBrowserApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
const actualControlled = ['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(manifest.version) ? await verifyControlledApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
const actualBrowser = ['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(manifest.version) ? await verifyBrowserApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
const actualControlled = ['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(manifest.version) ? await verifyControlledApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
console.log((await stop()).trim()); started = false;
await until(async () => { try { await fetch(url + '/api/health'); return false; } catch { return true; } });
for (const file of manifest.files) {
@@ -176,7 +176,7 @@ try {
}
const result = { success: true, date: new Date().toISOString(), appRoot, version: manifest.version, nodeVersion: manifest.nodeVersion,
verifiedFiles: manifest.files.length, url, reusedPid: firstInfo.pid, checks: { jobId, status: checked.status, tests: checked.results[0].tests }, actualRea, actualEngine, actualBrowser, actualControlled, externalGit,
steps: ['manifest hashes', 'bundled Node launch', 'same-service reuse', 'packaged example and static page', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(manifest.version) ? ['starter project copied to owned user data; original template bytes matched'] : []), 'explicit command consent', 'actual bundled Node version', 'actual bundled npm check without system Node/npm', 'check log artifact', ...(actualRea.length ? ['contained REA installation and Node identity', 'actual ASAR/imports/resources', 'original Bundle and target hash binding', 'verified reuse without producer replay'] : []), 'report availability', 'graceful stop', 'every original packaged file remains unchanged'], realModel: false };
steps: ['manifest hashes', 'bundled Node launch', 'same-service reuse', 'packaged example and static page', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(manifest.version) ? ['starter project copied to owned user data; original template bytes matched'] : []), 'explicit command consent', 'actual bundled Node version', 'actual bundled npm check without system Node/npm', 'check log artifact', ...(actualRea.length ? ['contained REA installation and Node identity', 'actual ASAR/imports/resources', 'original Bundle and target hash binding', 'verified reuse without producer replay'] : []), 'report availability', 'graceful stop', 'every original packaged file remains unchanged'], realModel: false };
fs.writeFileSync('.qa/release-validation.json', JSON.stringify(result, null, 2));
console.log(JSON.stringify(result, null, 2));
} finally { if (started) { try { await stop(); } catch {} } }
+20 -20
View File
@@ -19,7 +19,7 @@ assert.ok(fs.existsSync(npmCli), 'Use Node with its bundled npm.');
const files = (root, relative = '') => fs.readdirSync(path.join(root, relative), { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))
.flatMap(entry => entry.isDirectory() ? files(root, path.join(relative, entry.name)) : [path.join(relative, entry.name)]);
const digest = file => createHash('sha256').update(fs.readFileSync(file)).digest('hex');
const buildFolders = ['dist-client', 'dist-server', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version) ? ['dist-desktop'] : [])];
const buildFolders = ['dist-client', 'dist-server', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version) ? ['dist-desktop'] : [])];
const expected = Object.fromEntries(buildFolders.flatMap(folder => files(path.join(workspace, folder)).map(relative => [path.join(folder, relative), digest(path.join(workspace, folder, relative))])));
const allowedEnv = /^(path|pathext|systemroot|systemdrive|windir|comspec|temp|tmp|userprofile|homedrive|homepath|home|appdata|localappdata|programfiles(?:\(x86\))?|commonprogramfiles(?:\(x86\))?|lang|lc_all|AGENT_WORKBENCH_TEST_PYTHON|AGENT_WORKBENCH_DEEPSEEK_ROOT|AGENT_WORKBENCH_PURGE_ROOT)$/i;
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => allowedEnv.test(key)));
@@ -30,7 +30,7 @@ const directory = path.join(sourceRoot, '.qa', 'package-validation-' + randomUUI
fs.mkdirSync(directory, { recursive: true });
const inputFolders = ['src', 'tests', 'scripts', ...['benchmarks', 'public', 'examples', 'research'].filter(folder => fs.existsSync(path.join(sourceRoot, folder)))];
const inputNames = [...inputFolders.flatMap(folder => files(path.join(sourceRoot, folder)).map(relative => path.join(folder, relative))),
'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', ...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version) ? ['mobile.html'] : []), ...['.gitattributes', '.gitignore', 'Start-Desktop.cmd', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'].filter(name => fs.existsSync(path.join(sourceRoot, name)))].sort();
'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', ...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version) ? ['mobile.html'] : []), ...['.gitattributes', '.gitignore', 'Start-Desktop.cmd', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'].filter(name => fs.existsSync(path.join(sourceRoot, name)))].sort();
const snapshot = () => inputNames.map(relative => ({ path: relative.replaceAll('\\', '/'), bytes: fs.statSync(path.join(sourceRoot, relative)).size, sha256: digest(path.join(sourceRoot, relative)) }));
const inputs = snapshot(); fs.writeFileSync(path.join(directory, 'inputs.json'), JSON.stringify(inputs, null, 2));
let stage = 'environment preflight', python = null;
@@ -83,7 +83,7 @@ try {
assert.deepEqual(actualFiles.slice().sort(), Object.keys(expected).sort());
for (const [relative, sha256] of Object.entries(expected)) assert.equal(digest(path.join(sourceRoot, relative)), sha256, relative);
let actualRea = null;
if (['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'contained REA';
const reaOutput = await run(['scripts/verify-rea.mjs', '--app-root', sourceRoot, '--contained'], 'rea.log');
actualRea = JSON.parse(reaOutput.trim().split('\n').at(-1));
@@ -91,7 +91,7 @@ try {
assert.ok(actualRea.results.every(item => item.rootExited === true));
}
let actualEngine = null;
if (['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version) && process.argv.includes('--native-engines')) {
if (['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version) && process.argv.includes('--native-engines')) {
stage = 'native DeepSeek SDK';
const output = await run(['scripts/verify-engines.mjs'], 'engines.log');
actualEngine = JSON.parse(output.trim().split('\n').at(-1));
@@ -99,7 +99,7 @@ try {
assert.equal(actualEngine.modelRequests, 0); assert.equal(actualEngine.rootExited, true); assert.equal(actualEngine.nativeMethods.length, 6);
}
let actualBrowser = null;
if (['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'contained browser runtime';
const output = await run(['scripts/verify-browser.mjs', '--app-root', sourceRoot, '--contained'], 'browser.log');
actualBrowser = JSON.parse(output.trim().split('\n').at(-1));
@@ -109,7 +109,7 @@ try {
assert.equal(actualBrowser.modelRequests, 0);
}
let actualControlled = null;
if (['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'compiled controlled-engine delivery';
const output = await run(['scripts/verify-controlled-release.mjs', '--app-root', sourceRoot], 'controlled-engine.log');
actualControlled = JSON.parse(output.trim().split('\n').at(-1));
@@ -117,7 +117,7 @@ try {
assert.equal(actualControlled.realModelRequests, 0); assert.equal(actualControlled.cases, 4); assert.ok(actualControlled.fixtureModelRequests > 0);
}
let actualCompanion = null;
if (['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'contained companion gateway and UI';
const output = await run(['scripts/verify-companion-ui.mjs', '--app-root', sourceRoot], 'companion-ui.log');
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
@@ -128,7 +128,7 @@ try {
assert.equal(actualCompanion.passed.length, 7); assert.deepEqual(actualCompanion.errors, []); assert.equal(actualCompanion.realModelRequests, 0);
}
let actualProtocols = null;
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'contained model protocols and mobile streams';
const output = await run(['scripts/verify-model-protocols-ui.mjs', '--app-root', sourceRoot], 'model-protocols-ui.log');
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
@@ -139,7 +139,7 @@ try {
assert.equal(actualProtocols.passed.length, 5); assert.deepEqual(actualProtocols.pageErrors, []); assert.deepEqual(actualProtocols.requestFailures, []);
}
let actualVision = null;
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'contained screenshot inputs and exact Task budget resume';
const output = await run(['scripts/verify-vision-ui.mjs', '--app-root', sourceRoot], 'vision-ui.log');
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
@@ -150,7 +150,7 @@ try {
assert.equal(actualVision.passed.length, 5); assert.deepEqual(actualVision.pageErrors, []); assert.equal(actualVision.realModelRequests, 0);
}
let actualProjectCache = null;
if (['1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'contained source-verified parsing cache controls';
const output = await run(['scripts/verify-project-cache-ui.mjs', '--app-root', sourceRoot], 'project-cache-ui.log');
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
@@ -161,7 +161,7 @@ try {
assert.equal(actualProjectCache.realModelRequests, 0); assert.deepEqual(actualProjectCache.pageErrors, []);
}
let actualEnvironment = null, actualEnvironmentEngineering = null;
if (['1.21.0','1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.21.0','1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'contained environment approval, stop and recovery UI';
const output = await run(['scripts/verify-environment-ui.mjs', '--app-root', sourceRoot], 'environment-ui.log');
const summary = JSON.parse(output.trim().split(/\r?\n/).findLast(line => line.startsWith('{"success":')));
@@ -179,7 +179,7 @@ try {
assert.equal(actualEnvironmentEngineering.pythonTests, 2); assert.equal(actualEnvironmentEngineering.realModelRequests, 0);
}
let actualEmbeddedBrowser = null;
if (['1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'actual embedded Electron, Vite and original mobile observation';
await run(['scripts/verify-embedded-browser.mjs', '--app-root', sourceRoot], 'embedded-browser.log');
actualEmbeddedBrowser = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/embedded-browser-latest.json'), 'utf8'));
@@ -189,7 +189,7 @@ try {
assert.equal(actualEmbeddedBrowser.realModelRequests, 0); assert.deepEqual(actualEmbeddedBrowser.errors, []);
}
let actualReleaseEfficiency = null;
if (['1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'actual update status Edge/Electron and basic saved HTML flows';
const proofs = [];
for (const script of ['verify-release-efficiency-ui.mjs', 'verify-local-files.mjs']) {
@@ -203,7 +203,7 @@ try {
actualReleaseEfficiency = proofs;
}
let actualFileResults = null;
if (['1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'current file results Edge, Electron and paired mobile observation';
await run(['scripts/verify-file-results-ui.mjs'], 'file-results-ui.log');
actualFileResults = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/file-results-ui-latest.json'), 'utf8'));
@@ -243,14 +243,14 @@ try {
for (const key of ['fail', 'cancelled', 'skipped', 'todo']) assert.equal(groupStats[key], 0);
}
let actualTaskControl = null;
if (['1.20.1', '1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.20.1', '1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'task control desktop and 390px';
await run(['scripts/verify-task-control-ui.mjs', '--app-root', sourceRoot], 'task-control-ui.log');
actualTaskControl = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/task-control-ui-validation.json'), 'utf8'));
assert.equal(actualTaskControl.success, true); assert.equal(actualTaskControl.passed.length, 5); assert.equal(actualTaskControl.realModelRequests, 0);
}
let actualDesktop = null;
if (['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'actual contained Electron window'; await run(['scripts/verify-desktop-window.mjs'], 'desktop-window.log');
const window = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/desktop-window-latest.json'), 'utf8'));
assert.equal(window.success, true); assert.equal(path.resolve(window.appRoot), sourceRoot); assert.equal(window.results.length, 7);
@@ -264,7 +264,7 @@ try {
actualDesktop = { window, ui, projects, scope: 'Independently rebuilt source and its shipped Electron binary; original window/engine/engineering assertions. Own credentials/HTTP fixtures; Windows native picker and complete host crash/stop have separate actual evidence.' };
}
let actualProtocolEngineering = null;
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'Responses SSE actual Node React Python engineering';
await run(['scripts/verify-controlled-projects.mjs', '--responses'], 'responses-engineering.log');
const location = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/responses-engineering-location.json'), 'utf8'));
@@ -274,7 +274,7 @@ try {
assert.deepEqual(actualProtocolEngineering.results.map(value => value.parentCheck.results[0].tests.passed), [8, 9, 10]);
}
let actualVisionEngineering = null;
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'screenshot Task Node React Python engineering';
await run(['scripts/verify-vision-projects.mjs'], 'vision-engineering.log');
const location = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/vision-engineering-location.json'), 'utf8'));
@@ -284,7 +284,7 @@ try {
assert.deepEqual(actualVisionEngineering.results.map(value => value.check.results[0].tests.passed), [8, 9, 10]);
}
let actualCacheEngineering = null;
if (['1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'cached index original requests and Node React Python engineering';
await run(['scripts/verify-project-cache-projects.mjs'], 'project-cache-engineering.log');
const location = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/project-cache-engineering-location.json'), 'utf8'));
@@ -294,7 +294,7 @@ try {
assert.deepEqual(actualCacheEngineering.results.map(value => value.check.results[0].tests.passed), [8, 9, 10]);
}
let actualEvaluations = null, actualEvaluationEngineering = null;
if (['1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2'].includes(evidence.version)) {
if (['1.20.0', '1.20.1','1.21.0', '1.22.0', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3'].includes(evidence.version)) {
stage = 'compiled fixed engineering evaluations';
const output = await run(['scripts/verify-evaluations-release.mjs', '--app-root', sourceRoot], 'evaluations-release.log');
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
+10 -6
View File
@@ -215,16 +215,20 @@ try {
mark('unified and detailed research reports render');
stage = 'compatible model settings';
await page.getByRole('button', { name: '模型连接', exact: true }).click();
const settings = page.getByRole('dialog', { name: '模型连接' });
const openLegacy = async () => {
await page.getByRole('button', { name: '选择与管理模型', exact: true }).click();
await page.getByRole('dialog', { name: '模型中心', exact: true }).locator('.mc-connection').filter({ has: page.getByRole('heading', { name: '原模型连接', exact: true }) }).getByRole('button', { name: '编辑', exact: true }).click();
};
await openLegacy();
const settings = page.getByRole('dialog', { name: '原连接与演示设置', exact: true });
await settings.getByRole('button', { name: /兼容模型服务/ }).click();
await settings.getByLabel('接口根地址', { exact: true }).fill('http://127.0.0.1:' + model.address().port + '/v1');
await settings.getByLabel('API Key(按服务要求填写)', { exact: true }).fill('fixture-ui-key');
await settings.getByRole('button', { name: '读取模型列表', exact: true }).click();
await expect(settings.getByLabel('模型名称', { exact: true })).toHaveValue('fixture-ui-agent');
assert.equal((await api('/bootstrap')).config.hasKey, false);
await settings.getByRole('button', { name: '保存连接', exact: true }).click();
await expect(page.getByRole('button', { name: 'fixture-ui-agent', exact: true })).toBeVisible();
await settings.getByRole('button', { name: '保存并切换原连接', exact: true }).click();
await expect(page.getByRole('button', { name: '切换当前模型', exact: true })).toContainText('fixture-ui-agent');
await newTask('UI 兼容接口验证');
await expect(page.locator('.conversation')).toContainText('兼容协议流程已完成', { timeout: 20000 });
await expect(page.locator('.task-toolbar .status')).toHaveText('待审查');
@@ -234,10 +238,10 @@ try {
await expect(page.locator('.change-summary .status')).toHaveText('已应用');
assert.match(fs.readFileSync(path.join(projectRoot, 'COMPATIBLE-TEST.md'), 'utf8'), /没有使用真实大模型/);
await screenshot('compatible-fixture');
await page.getByRole('button', { name: '模型连接', exact: true }).click();
await openLegacy();
await settings.getByRole('button', { name: '清除 Key', exact: true }).click();
await settings.getByRole('button', { name: /离线演示/ }).click();
await settings.getByRole('button', { name: '保存连接', exact: true }).click();
await settings.getByRole('button', { name: '保存并切换原连接', exact: true }).click();
assert.equal((await api('/bootstrap')).config.hasKey, false);
mark('model list, ephemeral key, compatible fixture tool loop and return to offline mode');
+19 -6
View File
@@ -265,7 +265,7 @@ export default function App() {
async function submit() {
if (!composer.trim() || sending || isRunning || (sessionId && !session)) return;
if (restrictedWorker || session?.execution?.collaborations?.some(value => !['completed', 'discarded', 'resolved_external'].includes(value.status))) { setWorkersOpen(true); return; }
if (config.mode === 'compatible' && modelSelection.type === 'legacy' && !config.model) { openSettings(); notify('请先填写模型名称。'); return; }
if (config.mode === 'compatible' && modelSelection.type === 'legacy' && !config.model) { setModelCenterOpen(true); notify('请先填写模型名称。'); return; }
setSending(true);
const content = composer.trim();
try {
@@ -447,6 +447,19 @@ export default function App() {
return () => { alive = false; };
}, []);
useEffect(() => { if (token && projectId) refreshFiles(projectId).catch(failure); }, [token, projectId]);
useEffect(() => {
if (!token) return;
let alive = true, generation = 0;
const refreshSelection = () => {
if (document.visibilityState === 'hidden') return;
const marker = ++generation;
void api<{ config: Config; modelSelection: ModelSelection }>('/model-center/selection').then(value => {
if (alive && marker === generation) { setConfig(value.config); setModelSelection(value.modelSelection); }
}).catch(() => { /* Existing connection status handles host disconnection. */ });
};
window.addEventListener('focus', refreshSelection); document.addEventListener('visibilitychange', refreshSelection);
return () => { alive = false; generation++; window.removeEventListener('focus', refreshSelection); document.removeEventListener('visibilitychange', refreshSelection); };
}, [token]);
useEffect(() => {
if (!token || !sessionId) return;
let alive = true;
@@ -573,11 +586,11 @@ export default function App() {
if (file.kind === 'directory') setCollapsed(previous => { const next = new Set(previous); if (next.has(file.path)) next.delete(file.path); else next.add(file.path); return next; }); else loadFile(file.path);
}}>{file.kind === 'directory' ? <><span className="tree-chevron">{collapsed.has(file.path) ? <ChevronRight size={11} /> : <ChevronDown size={11} />}</span><Folder size={14} /></> : <><span className="tree-chevron" /><File size={13} /></>}<span>{filter ? file.path : file.name}</span></button>)}{filter && !visibleFiles.length && <p className="sidebar-hint">没有匹配的文件。</p>}</div>
</div>
<div className="sidebar-footer"><button onClick={openResearch}><BookOpenText size={16} />机制研究与设计<ChevronRight size={13} /></button><button onClick={() => setMemoryOpen(true)} disabled={!selectedProject || restrictedWorker}><Brain size={16} />项目记忆<ChevronRight size={13} /></button><button onClick={() => openDiagnostics()}><Activity size={16} />运行诊断<ChevronRight size={13} /></button><button onClick={openSettings}><Settings2 size={16} />模型连接<ChevronRight size={13} /></button><div className={'connection ' + (ready ? 'connected' : '')}><span />{ready ? '本地服务已连接' : '正在连接本地服务'}<button className="version-entry" aria-label="版本与更新" onClick={() => setInstallationOpen(true)}>v{version}</button></div></div>
<div className="sidebar-footer"><button onClick={openResearch}><BookOpenText size={16} />机制研究与设计<ChevronRight size={13} /></button><button onClick={() => setMemoryOpen(true)} disabled={!selectedProject || restrictedWorker}><Brain size={16} />项目记忆<ChevronRight size={13} /></button><button onClick={() => openDiagnostics()}><Activity size={16} />运行诊断<ChevronRight size={13} /></button><button className="model-sidebar-entry" onClick={() => setModelCenterOpen(true)} aria-label="选择与管理模型"><ModelServer size={16} /><span>模型与连接<small>{config.mode === 'demo' ? '离线演示' : modelSelection.type === 'legacy' ? config.model || '尚未配置' : modelSelection.name}</small></span><ChevronRight size={13} /></button><div className={'connection ' + (ready ? 'connected' : '')}><span />{ready ? '本地服务已连接' : '正在连接本地服务'}<button className="version-entry" aria-label="版本与更新" onClick={() => setInstallationOpen(true)}>v{version}</button></div></div>
</aside>
<main className="task-pane">
<header className="work-header"><div className="work-title">{(!sidebarOpen || mobile) && <IconButton label="展开项目栏" onClick={() => setSidebarOpen(true)}><PanelLeftOpen size={18} /></IconButton>}<span className="header-symbol"><Code2 size={17} /></span><div><span className="header-breadcrumb">{selectedProject?.name || '工作空间'} <ChevronRight size={12} /> 任务</span><h1>{session?.title || '让任务走到完成'}</h1></div></div>
<div className="model-launch"><button className="button secondary" onClick={() => setCompanionOpen(true)} aria-label="手机连接"><Link2 size={16} /><span>手机连接</span></button>{desktop && <button className="button secondary desktop-launch" onClick={() => setDesktopOpen(true)} aria-label="桌面宿主"><SquareTerminal size={16} /><span>桌面宿主</span></button>}<button className="button secondary" onClick={() => setModelCenterOpen(true)} aria-label="打开模型中心"><ModelServer size={16} /><span>模型中心</span></button><button className={'model-button ' + (config.mode === 'demo' ? 'demo' : '')} onClick={() => modelSelection.type !== 'legacy' && config.mode !== 'demo' ? setModelCenterOpen(true) : openSettings()}><span className="model-light" />{config.mode === 'demo' ? '离线演示' : modelSelection.type !== 'legacy' ? modelSelection.name : config.model || '选择模型'}<ChevronDown size={13} /></button></div>
<div className="model-launch"><button className="button secondary" onClick={() => setCompanionOpen(true)} aria-label="手机连接"><Link2 size={16} /><span>手机连接</span></button>{desktop && <button className="button secondary desktop-launch" onClick={() => setDesktopOpen(true)} aria-label="桌面宿主"><SquareTerminal size={16} /><span>桌面宿主</span></button>}<button className="button secondary" onClick={() => setModelCenterOpen(true)} aria-label="打开模型中心"><ModelServer size={16} /><span>模型中心</span></button><button className={'model-button ' + (config.mode === 'demo' ? 'demo' : '')} aria-label="切换当前模型" title="选择模型、模型池或添加连接" onClick={() => setModelCenterOpen(true)}><span className="model-light" />{config.mode === 'demo' ? '离线演示' : modelSelection.type !== 'legacy' ? modelSelection.name : config.model || '选择模型'}<ChevronDown size={13} /></button></div>
</header>
<div className="task-toolbar"><span className="task-local"><GitBranch size={13} />本地项目</span>{session ? <Status value={session.status} /> : <span className="subtle">等待新任务</span>}<div className="toolbar-actions">
<IconButton label="运行诊断" onClick={() => openDiagnostics()}><Activity size={15} /></IconButton>
@@ -631,14 +644,14 @@ export default function App() {
{projectOpen && <Modal title="打开项目" description="选择这台电脑上的项目文件夹,或输入完整路径。" onClose={() => { if (!projectBusy) { setProjectOpen(false); setDirectoryPickerOpen(false); setProjectError(''); } }}><form onSubmit={event => { event.preventDefault(); if (!directoryPickerOpen) void openProject(); }}><label className="form-field">项目文件夹<input autoFocus value={projectInput} disabled={projectBusy} onChange={event => { setProjectInput(event.target.value); setProjectError(''); }} placeholder="C:\Projects\my-app" aria-label="项目文件夹路径" /></label>{projectError && <p className="local-files-error" role="alert">{projectError}</p>}{directoryPickerOpen && <ProjectDirectoryPicker initialPath={projectInput.trim()} onChoose={value => { setProjectInput(value); setProjectError(''); setDirectoryPickerOpen(false); }} onCancel={() => setDirectoryPickerOpen(false)} />}<div className="modal-actions"><button type="button" className="button secondary" disabled={pickingProject || projectBusy} onClick={() => desktop ? void pickDesktopProject() : setDirectoryPickerOpen(value => !value)}><FolderOpen size={15} />选择文件夹</button>{exampleId && <button type="button" className="button secondary" disabled={projectBusy} onClick={() => { chooseProject(exampleId); setProjectOpen(false); setDirectoryPickerOpen(false); }}>打开示例项目</button>}<button type="submit" className="button primary" disabled={!projectInput.trim() || projectBusy || directoryPickerOpen}>{projectBusy ? <LoaderCircle className="spin" size={15} /> : <FolderOpen size={15} />}{projectBusy ? '正在打开…' : '打开项目'}</button></div></form></Modal>}
{companionOpen && <Modal title="手机连接" description="指定项目和权限,连接到同一个Windows执行宿主。" onClose={() => setCompanionOpen(false)} wide><CompanionPanel projects={projects} selectedProjectId={selectedProject?.id ?? ''} /></Modal>}
{desktopOpen && desktop && <Modal title="桌面与后台任务" description="当前窗口连接同一个本机执行宿主。" onClose={() => setDesktopOpen(false)}><DesktopPanel project={selectedProject} session={session} file={openFile} onProject={acceptDesktopProject} onReview={scope => { if (selectedProjectRef.current === scope.projectId && selectedSessionRef.current === scope.sessionId && selectedTaskRef.current === scope.taskId) { setDesktopOpen(false); showInspector('task'); } }} /></Modal>}
{settingsOpen && <Modal title="模型连接" description="同一套项目工具,可以使用离线演示或你自己的模型服务。" onClose={() => setSettingsOpen(false)}><form onSubmit={event => { event.preventDefault(); saveSettings(); }}><div className="mode-picker"><button type="button" className={settings.mode === 'demo' ? 'selected' : ''} onClick={() => setSettings(previous => ({ ...previous, mode: 'demo' }))}><Play size={18} /><strong>离线演示</strong><span>固定脚本,真实本地工具</span></button><button type="button" className={settings.mode === 'compatible' ? 'selected' : ''} onClick={() => setSettings(previous => ({ ...previous, mode: 'compatible' }))}><Link2 size={18} /><strong>兼容模型服务</strong><span>使用自己的本地或远程模型</span></button></div>
{settingsOpen && <Modal title="原连接与演示设置" description="此处只编辑原连接。添加、切换模型请使用模型中心;运行预算也可单独保存。" onClose={() => setSettingsOpen(false)}><form onSubmit={event => { event.preventDefault(); saveSettings(); }}><div className="mode-picker"><button type="button" className={settings.mode === 'demo' ? 'selected' : ''} onClick={() => setSettings(previous => ({ ...previous, mode: 'demo' }))}><Play size={18} /><strong>离线演示</strong><span>固定脚本,真实本地工具</span></button><button type="button" className={settings.mode === 'compatible' ? 'selected' : ''} onClick={() => setSettings(previous => ({ ...previous, mode: 'compatible' }))}><Link2 size={18} /><strong>兼容模型服务</strong><span>使用自己的本地或远程模型</span></button></div>
{settings.mode === 'compatible' && <><div className="connection-presets"><button type="button" onClick={() => setSettings(previous => ({ ...previous, baseUrl: 'http://127.0.0.1:11434/v1' }))}>Ollama</button><button type="button" onClick={() => setSettings(previous => ({ ...previous, baseUrl: 'http://127.0.0.1:8000/v1' }))}>vLLM</button><span>Chat Completions 兼容接口</span></div><label className="form-field">接口根地址<input type="url" value={settings.baseUrl} onChange={event => setSettings(previous => ({ ...previous, baseUrl: event.target.value }))} placeholder="http://127.0.0.1:11434/v1" /></label><label className="form-field">API Key(按服务要求填写)<input type="password" autoComplete="off" value={keyValue} onChange={event => { setKeyValue(event.target.value); setClearKey(false); }} placeholder={config.hasKey ? '本次运行已设置,留空保留' : '本地服务可以不填'} /></label><div className="key-note"><span>只在本次服务内存中使用,不写入会话与配置。</span>{config.hasKey && <button type="button" onClick={() => { setClearKey(true); setKeyValue(''); }}>{clearKey ? '保存后清除' : '清除 Key'}</button>}</div><div className="model-field"><label className="form-field">模型名称<input list="model-list" value={settings.model} onChange={event => setSettings(previous => ({ ...previous, model: event.target.value }))} placeholder="例如 qwen3:8b" /><datalist id="model-list">{models.map(model => <option key={model} value={model} />)}</datalist></label><button className="button secondary" type="button" onClick={readModels} disabled={settingsBusy || anyRunning}>{settingsBusy ? <LoaderCircle size={14} className="spin" /> : <Search size={14} />}读取模型列表</button></div><div className="model-test-row"><span>填写服务提供的接口根地址。</span><button type="button" className="button secondary" onClick={testModel} disabled={settingsBusy || anyRunning || !settings.model}><Activity size={14} />验证模型响应</button></div>{modelCheck && <div className={'model-check model-check-' + modelCheck.kind} role="status">{modelCheck.message}</div>}</>}
<details className="budget-settings"><summary>上下文与任务预算<ChevronDown size={13} /></summary><div className="budget-fields"><label>上下文预算<input type="number" min={1000} max={200000} value={settings.contextLimit} onChange={event => setSettings(previous => ({ ...previous, contextLimit: Number(event.target.value) }))} /></label><label>最大工具轮次<input type="number" min={1} max={30} value={settings.maxSteps} onChange={event => setSettings(previous => ({ ...previous, maxSteps: Number(event.target.value) }))} /></label><label>输出上限<input type="number" min={256} max={16000} value={settings.maxOutputTokens} onChange={event => setSettings(previous => ({ ...previous, maxOutputTokens: Number(event.target.value) }))} /></label><label>运行时间(分钟)<input aria-label="运行时间预算" type="number" min={1} max={60} value={settings.maxRunDurationMs / 60000} onChange={event => setSettings(previous => ({ ...previous, maxRunDurationMs: Number(event.target.value) * 60000 }))} /></label><label>单次运行 tokens<input aria-label="单次运行token预算" type="number" min={1000} max={2000000} value={settings.maxRunTokens} onChange={event => setSettings(previous => ({ ...previous, maxRunTokens: Number(event.target.value) }))} /></label><label>任务累计 tokens<input aria-label="任务累计token预算" type="number" min={1000} max={10000000} value={settings.maxTaskTokens} onChange={event => setSettings(previous => ({ ...previous, maxTaskTokens: Number(event.target.value) }))} /></label></div><p>上下文使用本地估算;实际用量与未知用量分开保存。达到预算会暂停,已完成的工具结果保留。</p></details>{anyRunning && <p className="form-warning">有任务在执行,请先停止任务再改变连接。</p>}<div className="modal-actions"><button type="button" className="button secondary" onClick={() => setSettingsOpen(false)}>取消</button><button type="submit" className="button primary" disabled={settingsBusy || anyRunning}><Check size={15} />保存连接</button></div></form></Modal>}
<details className="budget-settings"><summary>上下文与任务预算<ChevronDown size={13} /></summary><div className="budget-fields"><label>上下文预算<input type="number" min={1000} max={200000} value={settings.contextLimit} onChange={event => setSettings(previous => ({ ...previous, contextLimit: Number(event.target.value) }))} /></label><label>最大工具轮次<input type="number" min={1} max={30} value={settings.maxSteps} onChange={event => setSettings(previous => ({ ...previous, maxSteps: Number(event.target.value) }))} /></label><label>输出上限<input type="number" min={256} max={16000} value={settings.maxOutputTokens} onChange={event => setSettings(previous => ({ ...previous, maxOutputTokens: Number(event.target.value) }))} /></label><label>运行时间(分钟)<input aria-label="运行时间预算" type="number" min={1} max={60} value={settings.maxRunDurationMs / 60000} onChange={event => setSettings(previous => ({ ...previous, maxRunDurationMs: Number(event.target.value) * 60000 }))} /></label><label>单次运行 tokens<input aria-label="单次运行token预算" type="number" min={1000} max={2000000} value={settings.maxRunTokens} onChange={event => setSettings(previous => ({ ...previous, maxRunTokens: Number(event.target.value) }))} /></label><label>任务累计 tokens<input aria-label="任务累计token预算" type="number" min={1000} max={10000000} value={settings.maxTaskTokens} onChange={event => setSettings(previous => ({ ...previous, maxTaskTokens: Number(event.target.value) }))} /></label></div><p>上下文使用本地估算;实际用量与未知用量分开保存。达到预算会暂停,已完成的工具结果保留。</p></details>{anyRunning && <p className="form-warning">有任务在执行,请先停止任务再改变连接。</p>}<div className="modal-actions"><button type="button" className="button secondary" onClick={() => setSettingsOpen(false)}>取消</button><button type="submit" className="button primary" disabled={settingsBusy || anyRunning}><Check size={15} />保存并切换原连接</button></div></form></Modal>}
{diagnosticsOpen && <Modal title="运行诊断" description="查看工作台的模型连接、终端环境、最近错误和文件实际状态。" wide onClose={() => setDiagnosticsOpen(false)}><DiagnosticsPanel value={diagnostics} busy={diagnosticsBusy} onRefresh={() => openDiagnostics()} /></Modal>}
{reaOpen && session && selectedProject && <Modal title="REA 工件研究" description="原分析与同一项目、任务和运行绑定。" wide onClose={() => setReaOpen(false)}><ResearchPanel key={session.id} project={selectedProject} session={session} onSession={acceptSession} onError={failureFor(session)} busy={isRunning} /></Modal>}
{engineOpen && session && selectedProject && <Modal title="本地代理引擎" description="本地安装、受控工程运行与原记录。" wide onClose={() => setEngineOpen(false)}><EnginePanel key={session.id} project={selectedProject} session={session} onSession={acceptSession} onError={failureFor(session)} busy={isRunning} onNavigate={async (projectId, sessionId) => { setEngineOpen(false); await navigateWorkspace(projectId, sessionId); }} /></Modal>}
{researchOpen && <Modal title="机制研究与独立设计" description="从分发客户端的静态证据提炼产品机制。运行时与远端服务的未知部分在报告中说明。" wide onClose={() => setResearchOpen(false)}><div className="research-layout"><nav>{researchDocs.map(document => <button className={report?.title === document.title ? 'selected' : ''} key={document.id} onClick={() => loadReport(document.id)}><BookOpenText size={15} /><span><strong>{document.title}</strong><small>{document.description}</small></span></button>)}</nav><article className="research-document">{report && <ResearchContent content={report.content} />}</article></div></Modal>}
{modelCenterOpen && <Modal title="模型中心" description="连接、模型池与执行健康统一管理。" wide onClose={() => setModelCenterOpen(false)}><ModelCenter busy={anyRunning} onConfig={(value, selection) => { setConfig(value); if (selection) setModelSelection(selection); }} onLegacy={() => { setModelCenterOpen(false); openSettings(); }} /></Modal>}
{modelCenterOpen && <Modal title="模型中心" description="连接、模型池与执行健康统一管理。" wide onClose={() => setModelCenterOpen(false)}><ModelCenter busy={anyRunning} runModel={session?.execution?.run?.model} onConfig={(value, selection) => { setConfig(value); if (selection) setModelSelection(selection); }} onLegacy={() => { setModelCenterOpen(false); openSettings(); }} /></Modal>}
{memoryOpen && selectedProject && <Modal title="项目记忆" description="项目事实与决策绑定源码指纹,变化后自动要求重新核对。" wide onClose={() => setMemoryOpen(false)}><ProjectMemoryPanel key={selectedProject.id + ':' + (session?.id ?? '')} project={selectedProject} session={session?.projectId === selectedProject.id ? session : null} /></Modal>}
{skillsOpen && selectedProject && <Modal title="项目技能" description="管理当前项目的技能来源、版本与启用状态。" wide onClose={() => setSkillsOpen(false)}><SkillCenter key={selectedProject.id} projectId={selectedProject.id} busy={isRunning} /></Modal>}
{mcpOpen && selectedProject && <Modal title="项目 MCP 工具" description="实际探测本地 stdio 服务,选择可以请求的工具,并核对每次运行原记录。" wide onClose={() => setMcpOpen(false)}><McpPanel key={selectedProject.id + ':' + (session?.id ?? '')} projectId={selectedProject.id} session={session?.projectId === selectedProject.id ? session : null} busy={isRunning} onSession={acceptSession} onError={session ? failureFor(session) : failure} /></Modal>}
+18
View File
@@ -0,0 +1,18 @@
import { useState } from 'react';
import type { Config } from './types';
export function ModelBudgetSettings({ value, disabled, onSave }: { value: Config; disabled: boolean; onSave: (input: Partial<Config>) => void }) {
const [draft, setDraft] = useState(() => ({ contextLimit: value.contextLimit, maxOutputTokens: value.maxOutputTokens,
maxSteps: value.maxSteps, maxRunDurationMs: value.maxRunDurationMs, maxRunTokens: value.maxRunTokens, maxTaskTokens: value.maxTaskTokens }));
const fields = [
['contextLimit', '上下文预算', 1000, 200000], ['maxOutputTokens', '输出上限', 256, 16000],
['maxSteps', '最大工具轮次', 1, 30], ['maxRunDurationMs', '运行时间(秒)', 1, 3600],
['maxRunTokens', '单次运行 tokens', 1000, 2000000], ['maxTaskTokens', '任务累计 tokens', 1000, 10000000],
] as const;
return <form className="mc-editor" aria-label="运行预算设置" onSubmit={event => { event.preventDefault(); onSave(draft); }}>
<h3>运行预算</h3><p>保存仅调整后续运行的预算,保留已选连接或模型池。实际上下文与输出上限还受所选连接限制;旧运行的预算与用量保持原记录。</p>
<div className="mc-form-grid">{fields.map(([key, label, min, max]) => <label key={key}>{label}<input aria-label={label} type="number" required step={1} min={min} max={max} disabled={disabled}
value={key === 'maxRunDurationMs' ? draft[key] / 1000 : draft[key]} onChange={event => setDraft(previous => ({ ...previous, [key]: Number(event.target.value) * (key === 'maxRunDurationMs' ? 1000 : 1) }))} /></label>)}</div>
<div className="mc-actions"><button className="button primary" type="submit" disabled={disabled}>保存运行预算</button></div>
</form>;
}
+2
View File
@@ -22,3 +22,5 @@
.mc-form-grid label > small { color: #475b73; font-size: 12px; line-height: 1.7; font-weight: 400; }
.mc-native>label{display:flex;flex-direction:column;gap:8px;font-size:12px;color:#40576e;margin:14px 0}.mc-native select,.mc-native textarea{width:100%;min-width:0;padding:10px;border:1px solid #a9bdcf;border-radius:5px;background:white;font-size:12px;line-height:1.75}.mc-native textarea{resize:vertical;font-family:Consolas,"Microsoft YaHei",monospace}.mc-native select:focus-visible,.mc-native textarea:focus-visible{outline:2px solid #2560a3;outline-offset:2px}
.mc-route-control{margin-bottom:24px;padding:18px 20px;background:#fff;border:1px solid #b8cadb;border-left:3px solid #2560a3;border-radius:6px;min-width:0}.mc-route-heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:14px}.mc-route-heading h3{font-size:15px;margin-bottom:5px}.mc-route-heading p,.mc-route-detail{font-size:12px;color:#4b6078;line-height:1.7;overflow-wrap:anywhere}.mc-route-heading>.button{flex-shrink:0}.mc-route-select{display:flex;gap:12px;align-items:center;font-size:12px;color:#425974}.mc-route-select select{min-width:0;flex:1;width:100%;min-height:42px;border:1px solid #a7bbcf;border-radius:5px;background:#fff;padding:10px;color:#15283f;font-size:13px}.mc-route-detail{margin-top:9px}.mc-run-model{display:flex;flex-wrap:wrap;gap:6px 12px;border-top:1px solid #dce4eb;margin-top:13px;padding-top:12px;font-size:12px;line-height:1.7;overflow-wrap:anywhere}.mc-run-model strong{color:#344c67}.mc-run-model span{color:#405670}.mc-run-model small{width:100%;color:#566b81;font-size:11px}.mc-route-select select:focus-visible{outline:2px solid #2560a3;outline-offset:2px}
@media(max-width:620px){.mc-route-control{padding:14px}.mc-route-heading{align-items:flex-start;gap:10px}.mc-route-heading p{font-size:11px}.mc-route-heading>.button{padding:8px;font-size:11px}.mc-route-select{align-items:stretch;flex-direction:column;gap:7px}.mc-route-select select{font-size:12px}.mc-run-model{display:block}.mc-run-model strong,.mc-run-model span,.mc-run-model small{display:block}.mc-run-model span{margin-top:4px}}
+32 -6
View File
@@ -1,13 +1,14 @@
import { useEffect, useRef, useState } from 'react';
import { Activity, Check, CircleHelp, KeyRound, Layers3, Plus, Power, RefreshCw, Route, Server, Settings2 } from 'lucide-react';
import { api, downloadArtifact } from './api';
import type { Config, ModelSelection, RuntimeFailure } from './types';
import type { Config, ModelSelection, ModelSnapshot, RuntimeFailure } from './types';
import './ModelCenter.css';
import { ModelIdentityDetails } from './ModelIdentityDetails';
import type { ModelIdentity } from '../shared/contracts/model-identity.mjs';
import { ModelWaitSettings, type WaitSettings } from './ModelWaitSettings';
import { NativeParameters } from './NativeParameters';
import { ModelErrorDetails } from './ModelErrorDetails';
import { ModelBudgetSettings } from './ModelBudgetSettings';
type Connection = { id: string; name: string; brand: string; protocol: string; baseUrl: string; model: string; enabled: boolean; revision: number; hasKey: boolean;
requiresKey: boolean; modelIdentityPolicy?: string; modelIdentityAliases?: string[]; modelIdentityAliasSource?: string; nativeParameters?: Record<string, unknown>; outputTokenField?: string; streaming?: boolean; capabilityDeclarations?: Record<string, string>; capabilities?: Record<string, string>; capabilityEvidence?: { checkedAt: string }; contextLimit: number; maxOutputTokens: number; concurrency: number; status: string; activeRequests: number; savedCredential?: { status: string }; health: { state: string; reason?: string; cooldownUntil?: number } };
@@ -25,8 +26,9 @@ const initial = { modelIdentityAliasesText: '', modelIdentityPolicy: 'record', m
const capabilityLabels: Record<string, string> = { text: '文本', tools: '工具', streaming: '流式', vision: '视觉', audio: '语音' };
const capabilityStates: Record<string, string> = { protocol_declared: '声明支持', verified: '已验证', unknown: '待验证', unsupported: '不支持' };
const emptyPool: Pool = { name: '', members: [], strategy: 'round-robin', sticky: true, maxAttempts: 3, queueTimeoutMs: 15000 };
export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Config, selection?: ModelSelection) => void; onLegacy: () => void; busy: boolean }) {
export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig: (value: Config, selection?: ModelSelection) => void; onLegacy: () => void; busy: boolean; runModel?: ModelSnapshot }) {
const [view, setView] = useState<Center | null>(null);
const [runtimeConfig, setRuntimeConfig] = useState<Config | null>(null);
const [tab, setTab] = useState('connections');
const [draft, setDraft] = useState<typeof initial & { id?: string; revision?: number }>(initial);
const [editing, setEditing] = useState(false), [key, setKey] = useState('');
@@ -43,7 +45,19 @@ export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Co
const [discovery, setDiscovery] = useState<{ source: string; path: string; available: boolean; supported: boolean; detail?: string }[]>([]);
const alive = useRef(true), generation = useRef(0);
const tabsRef = useRef<HTMLElement>(null);
async function refresh() { const marker = ++generation.current; const result = await api<Center>('/model-center'); if (alive.current && marker === generation.current) setView(result); }
async function refresh() {
const marker = ++generation.current;
const [result, selection] = await Promise.all([api<Center>('/model-center'), api<{ config: Config; modelSelection: ModelSelection }>('/model-center/selection')]);
if (alive.current && marker === generation.current) { setView(result); setRuntimeConfig(selection.config); onConfig(selection.config, selection.modelSelection); }
}
function addConnection() { setTab('connections'); setDraft(initial); setKey(''); setPersistKey(false); setEditing(true); }
async function selectRoute(value: string) {
await act(async () => {
if (value === 'demo') await api('/model-center/mode', { mode: 'demo' });
else { const [type, id] = value.split(':'); await api('/model-center/select', { type, id }); }
if (alive.current) setNotice(value === 'demo' ? '已切换到离线演示;已保存连接仍保留。' : '默认模型已更新;后续运行使用此选择,旧运行保留原记录。');
});
}
async function act(action: () => Promise<void>) {
setWorking(true); setNotice(''); setNoticeFailure(null);
try { await action(); if (alive.current) { await refresh(); if (credentialView) await refreshCredentials(); } }
@@ -56,6 +70,7 @@ export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Co
useEffect(() => { alive.current = true; void refresh().catch(error => { if (alive.current) setNotice(error.message); }); return () => { alive.current = false; generation.current++; }; }, []);
useEffect(() => { if (!autoInspect || tab !== 'operations') return; const timer = window.setInterval(() => { void inspect().catch(error => { if (alive.current) setNotice(error.message); }); }, 30000); return () => window.clearInterval(timer); }, [autoInspect, tab]);
useEffect(() => { setCredentialKey(''); if (tab === 'credentials') void refreshCredentials().catch(error => { if (alive.current) setNotice(error.message); }); }, [tab]);
useEffect(() => { if (!editing) return; const frame = requestAnimationFrame(() => document.querySelector('.mc-editor[aria-label="编辑模型连接"]')?.scrollIntoView({ block: 'start' })); return () => cancelAnimationFrame(frame); }, [editing]);
useEffect(() => {
const ensureVisible = () => { const nav = tabsRef.current, button = nav?.querySelector<HTMLButtonElement>('button[aria-current]'); if (!nav || !button) return;
const area = nav.getBoundingClientRect(), target = button.getBoundingClientRect(), start = target.left - area.left;
@@ -68,19 +83,30 @@ export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Co
const selectionName = selected?.type === 'pool' ? view?.pools.find(value => value.id === selected.id)?.name : view?.connections.find(value => value.id === selected?.id)?.name;
const locked = working || busy;
return <section className="model-center" aria-label="模型控制台" aria-busy={working}>
<div className="mc-overview"><div><span className="mc-eyebrow">MODEL CONTROL</span><h2>连接有序,执行有据。</h2><p>统一管理模型服务、调度和每次真实请求。</p></div><div className="mc-current"><Route size={18} /><span>当前路由<strong>{selectionName || '原模型连接'}</strong></span><span className="mc-count">{view?.waiting ?? 0} 等待</span></div></div>
<nav ref={tabsRef} className="mc-tabs" aria-label="模型中心分类">{[['connections', '模型连接', Server], ['pools', '模型池', Layers3], ['waits', '等待时限', Settings2], ['attempts', '请求账本', Route], ['imports', '配置导入', Settings2], ['credentials', '凭据保存', KeyRound], ['operations', '运行巡检', Activity]].map(([id, title, Icon]) => {
<div className="mc-overview"><div><span className="mc-eyebrow">MODEL CONTROL</span><h2>选择模型,继续开发。</h2><p>连接、模型池和实际请求使用同一个入口。</p></div><div className="mc-current"><Route size={18} /><span>新任务默认<strong>{runtimeConfig?.mode === 'demo' ? '离线演示' : selectionName || '正在读取'}</strong></span><span className="mc-count">{view?.waiting ?? 0} 等待</span></div></div>
<nav ref={tabsRef} className="mc-tabs" aria-label="模型中心分类">{[['connections', '模型连接', Server], ['pools', '模型池', Layers3], ['budgets', '运行预算', Settings2], ['waits', '等待时限', Settings2], ['attempts', '请求账本', Route], ['imports', '配置导入', Settings2], ['credentials', '凭据保存', KeyRound], ['operations', '运行巡检', Activity]].map(([id, title, Icon]) => {
const Symbol = Icon as typeof Server; return <button key={id as string} type="button" aria-current={tab === id ? 'page' : undefined} onClick={() => { setTab(id as string); setNotice(''); }}><Symbol size={16} />{title as string}</button>;
})}<button className="mc-refresh" type="button" disabled={working} onClick={() => void act(refresh)} aria-label="刷新模型中心"><RefreshCw size={16} /></button></nav>
{notice && <div className="mc-notice" role="status">{notice}{noticeFailure && <ModelErrorDetails failure={noticeFailure} />}</div>}
{busy && <p className="mc-notice">有任务正在执行;连接可停用,其他配置请在任务结束后修改。</p>}
{!view ? <p className="mc-empty">正在读取实际连接状态…</p> : <div className="mc-content">
<section className="mc-route-control" aria-label="默认模型选择">
<div className="mc-route-heading"><div><h3>新任务默认模型</h3><p>选择已保存的连接,或使用模型池调度。切换本身不请求模型。</p></div><button className="button secondary" disabled={locked} onClick={addConnection}><Plus size={15} />添加模型</button></div>
<label className="mc-route-select">当前选择<select aria-label="新任务默认模型" disabled={locked || !runtimeConfig} value={runtimeConfig?.mode === 'demo' ? 'demo' : selected?.type + ':' + selected?.id} onChange={event => void selectRoute(event.target.value)}>
<option value="demo">离线演示 · 固定脚本</option>
<optgroup label="模型连接">{view.connections.map(connection => <option key={connection.id} value={(connection.id === 'legacy-default' ? 'legacy' : 'connection') + ':' + connection.id} disabled={!connection.enabled || connection.requiresKey && !connection.hasKey}>{connection.name} · {connection.model || '尚未填写型号'}{connection.status !== 'configured' ? ' · ' + states[connection.status] : ''}</option>)}</optgroup>
{!!view.pools.length && <optgroup label="模型池">{view.pools.map(pool => <option key={pool.id} value={'pool:' + pool.id}>{pool.name} · {pool.members.length} 个连接</option>)}</optgroup>}
</select></label>
<div className="mc-route-detail">{runtimeConfig?.mode === 'demo' ? '离线演示使用固定脚本,不调用大模型。' : selected?.type === 'pool' ? '模型池按成员配置调度;每次实际连接和返回型号保存在请求账本。' : (() => { const connection = view.connections.find(c => c.id === selected?.id); return connection ? `${connection.protocol === 'responses' ? 'Responses' : 'Chat Completions'} · ${connection.baseUrl} · 请求 ${connection.model || '未配置'}` : '请选择可用连接。'; })()}</div>
{runModel && <div className="mc-run-model"><strong>当前会话最近运行</strong><span>{runModel.mode === 'demo' ? '离线演示' : runModel.routing?.members?.length ? runModel.routing.members.map(member => member.name + ' · ' + member.model).join(';') : runModel.model}</span><small>这是该次运行封存的请求配置;实际返回型号请看请求账本。更改默认选择不会改写旧记录。</small></div>}
</section>
{tab === 'budgets' && runtimeConfig && <ModelBudgetSettings key={JSON.stringify(runtimeConfig)} value={runtimeConfig} disabled={locked} onSave={input => void act(async () => { await api('/model-center/runtime-budgets', input); if (alive.current) setNotice('运行预算已保存,当前模型选择保持。'); })} />}
{tab === 'waits' && <ModelWaitSettings key={JSON.stringify(view.waitSettings)} value={view.waitSettings} disabled={locked} onSave={value => void act(async () => {
const result = await api<{ config: Config }>('/model-center/wait-settings', value);
if (alive.current) { onConfig(result.config); setNotice('等待时限已保存,从下一次运行生效。当前模型路由保持。'); }
})} />}
{tab === 'connections' && <>
<div className="mc-section-title"><div><h3>模型连接</h3><p>默认仅在本次宿主内存中使用;可在凭据保存中选择本机加密。已配置与调用通过分别显示。</p></div><button className="button primary" disabled={locked} onClick={() => { setDraft(initial); setKey(''); setPersistKey(false); setEditing(true); }}><Plus size={16} />添加连接</button></div>
<div className="mc-section-title"><div><h3>模型连接</h3><p>保存多条连接后可在上方切换;添加连接不会替换当前模型。凭据可选择本机加密保存。</p></div><button className="button primary" disabled={locked} onClick={addConnection}><Plus size={16} />添加连接</button></div>
<div className="mc-connections">{view.connections.map(value => <article className={'mc-connection ' + (!value.enabled ? 'mc-disabled' : '')} key={value.id}>
<div className="mc-card-heading"><span className="mc-service-icon"><Server size={20} /></span><div><h4>{value.name}</h4><span>{value.brand} · {value.protocol === 'responses' ? 'Responses' : 'Chat Completions'}{value.streaming ? ' · 流式开启' : ''}</span></div><span className={'mc-state mc-state-' + value.status}>{states[value.status]}</span></div>
<dl><dt>模型</dt><dd>{value.model || '尚未填写'}</dd><dt>接口</dt><dd>{value.baseUrl}</dd><dt>凭据</dt><dd>{value.hasKey ? value.savedCredential?.status === 'saved' ? '已设置,可从本机加密保存加载' : '已设置,重启需重新填写' : value.requiresKey ? '尚未填写' : '此服务可不填'}</dd><dt>请求 / 容量</dt><dd>{value.activeRequests} 在途 · 并发 {value.concurrency} · 上下文 {value.contextLimit.toLocaleString()}</dd></dl>
+1
View File
@@ -32,3 +32,4 @@ html,body,#root{width:100%;height:100%;overflow:hidden}.workbench{grid-template-
.model-stream-preview span, .model-stream-preview p { color: #52665b; font-size: 12px; }
.model-stream-preview pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow-y: auto; font: inherit; line-height: 1.7; margin: 10px 0; }
.model-stream-preview p { margin: 8px 0 0; }
.sidebar-footer>.model-sidebar-entry>span{display:block;min-width:0;text-align:left;flex:1}.model-sidebar-entry small{display:block;font-size:11px;line-height:1.5;color:#415f52;margin-top:3px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;max-width:158px}.sidebar-footer>.model-sidebar-entry>svg{flex-shrink:0}
+6
View File
@@ -122,6 +122,12 @@ export class ModelHub {
view() { return { revision: this.state.revision, selected: this.state.selected, waitSettings: modelWaitSettings(this.store.config), connections: this.connections().map(value => this.status(value)), pools: this.state.pools,
imports: Object.entries(this.state.imports).map(([id, value]) => ({ id, ...value })), attempts: this.attempts.slice(-100).reverse(), waiting: this.waiting,
storage: { credentials: this.credentialVault ? 'memory-or-windows-user-dpapi' : 'memory', restart: '临时凭据在宿主退出后需要重新填写;已明确本机加密保存的连接按用户与原配置加载。', attemptsRetained: 1000 } }; }
selectionView() {
const selected = this.state.selected;
const name = selected.type === 'pool' ? this.state.pools.find(value => value.id === selected.id)?.name
: this.connections().find(value => value.id === selected.id)?.name;
return { ...selected, name: name ?? '原模型连接' };
}
connection(id) { const value = this.connections().find(item => item.id === id); if (!value) throw error('模型连接不存在。', 404); return value; }
async probe(id, scope = 'text') {
if (!['text', 'tools', 'streaming', 'vision'].includes(scope)) throw error('请选择文本、工具调用、流式或图像检测。');
+15
View File
@@ -0,0 +1,15 @@
const ranges = {
contextLimit: [1000, 200000], maxOutputTokens: [256, 16000], maxSteps: [1, 30],
maxRunDurationMs: [1000, 3600000], maxRunTokens: [1000, 2000000], maxTaskTokens: [1000, 10000000],
};
// Budget-only edits cannot change the selected route, endpoint or credential.
export function validateRuntimeBudgets(input) {
if (!input || typeof input !== 'object' || Array.isArray(input) || !Object.keys(input).length
|| Object.keys(input).some(key => !Object.hasOwn(ranges, key))) throw new Error('只接受运行预算字段;模型连接请在模型选择中切换。');
for (const [key, value] of Object.entries(input)) {
const [min, max] = ranges[key];
if (!Number.isSafeInteger(value) || value < min || value > max) throw new Error(key + ' 需填写范围内的整数。');
}
return { ...input };
}
+16 -5
View File
@@ -1,3 +1,4 @@
import { validateRuntimeBudgets } from '../core/models/runtime-settings.mjs';
import fs from 'node:fs';
import { createHash } from 'node:crypto';
import path from 'node:path';
@@ -186,12 +187,24 @@ return async (request, response) => {
const hub = provider.modelHub(store);
const importer = () => hub.importer ??= new ConfigImporter(hub);
if (method === 'GET' && route === '/api/model-center') return json(response, hub.view());
if (method === 'GET' && route === '/api/model-center/selection') return json(response, {
config: { ...store.config, hasKey: provider.hasKey() }, modelSelection: hub.selectionView(),
});
if (method === 'GET' && route === '/api/model-center/credentials') return json(response, hub.vault().view(hub));
if (method === 'GET' && route === '/api/model-center/imports') return json(response, importer().discover());
if (method === 'POST') {
const input = await body(request);
if (route === '/api/model-center/toggle') return json(response, hub.toggle(input.id, input.enabled));
if (runtime.hasActivity()) throw Object.assign(new Error('请先停止正在运行的任务,再修改或测试模型配置。'), { status: 409 });
if (route === '/api/model-center/runtime-budgets') {
store.saveConfig(validateRuntimeBudgets(input));
return json(response, { config: { ...store.config, hasKey: provider.hasKey() }, modelSelection: hub.selectionView() });
}
if (route === '/api/model-center/mode') {
if (!input || Object.keys(input).length !== 1 || !['demo', 'compatible'].includes(input.mode)) throw new Error('请选择离线演示或真实模型模式。');
store.saveConfig({ mode: input.mode });
return json(response, { config: { ...store.config, hasKey: provider.hasKey() }, modelSelection: hub.selectionView() });
}
if (route === '/api/model-center/wait-settings') {
store.saveConfig(validateModelWaitSettings(input, store.config));
return json(response, { center: hub.view(), config: { ...store.config, hasKey: provider.hasKey() } });
@@ -200,7 +213,7 @@ return async (request, response) => {
if (route === '/api/model-center/native-parameters') return json(response, hub.setNativeParameters(input));
if (route === '/api/model-center/connections') return json(response, hub.upsert(input), 201);
if (route === '/api/model-center/pools') return json(response, hub.pool(input), 201);
if (route === '/api/model-center/select') return json(response, { center: hub.select(input), config: { ...store.config, hasKey: provider.hasKey() } });
if (route === '/api/model-center/select') return json(response, { center: hub.select(input, { mode: 'compatible' }), config: { ...store.config, hasKey: provider.hasKey() } });
if (route === '/api/model-center/import-preview') return json(response, importer().preview(input.source, String(input.path ?? '')));
if (route === '/api/model-center/import-apply') return json(response, importer().apply(input.previewId, input.autoSync, input.persistCredentials));
if (route === '/api/model-center/import-toggle') return json(response, importer().toggle(input.id, input.enabled));
@@ -214,12 +227,10 @@ return async (request, response) => {
return json(response, inspectOperations({ store, provider, runtime, server, appDirectory, version: APP_VERSION, parameters: url.searchParams }));
}
if (method === 'GET' && route === '/api/bootstrap') {
const hub = provider.modelHub(store), selected = hub.state.selected;
const name = selected.type === 'pool' ? hub.state.pools.find(value => value.id === selected.id)?.name
: hub.connections().find(value => value.id === selected.id)?.name;
const hub = provider.modelHub(store);
return json(response, {
token, version: APP_VERSION, config: { ...store.config, hasKey: provider.hasKey() },
modelSelection: { ...selected, name: name ?? '原模型连接' },
modelSelection: hub.selectionView(),
eventCursor: store.eventCursor, storage: store.storageInfo(), runtimeRoot: appDirectory,
environment: executionEnvironment(),
projects: store.projects, sessions: store.listSessions(), exampleProjectId: exampleProject?.id ?? null,
+1 -1
View File
@@ -1,6 +1,6 @@
import { randomUUID, createHash } from 'node:crypto';
export const APP_VERSION = '1.24.2';
export const APP_VERSION = '1.24.3';
export function executionEnvironment() {
const windows = process.platform === 'win32';
+8
View File
@@ -1,5 +1,13 @@
# Agent Workbench:核心代理能力研究与产品计划
## 当前 K:统一模型入口与默认路由核对
- [complete] 实际回看证实:左下角仍开旧单连接窗口,保存会选 legacy;刚才 J 原请求仍明确为 apikey/Claude,不能归因为旧 GPT 覆盖。
- [complete] 所有模型入口统一到模型中心,提供直接选择已有连接/号池、添加连接;原连接编辑/演示改为明确次级入口。
- [complete] 选中状态以服务端为准,显示默认模型与本次运行的区别;预算修改不隐式切回原连接,保留旧任务封存身份。
- [complete] 30/30相关后端与最终构建、编译UI七组桌面/390px和实际自有路由验证通过;两次原生option验收器误判与历史泛选择器失败保持。
- [in_progress] 相关历史UI、独立发行重建/安装与原宿主/凭据/数据保留部署,本地Git实现和最终证据收尾。本轮无新增真实模型请求。
## 当前 J:真实连接身份已核对,工程待新连接
用户选择 apikey Claude,已完成单次真实预检:请求 claude-opus-5-5 / 返回 gpt-6.1-sol,1 请求、4334 报告 tokens、0 工具,严格暂停。原状态复核、30 份新证据离线核对与报告完成,原参数/号池已恢复。见 docs/LIVE-MODEL-IDENTITY-J-RESULTS.md;下一只在更正或新选连接的独立预检通过后做 Node 工程,当前工程/Purge 未测。以下 I 及更早任务按历史时点理解。
+77
View File
@@ -0,0 +1,77 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { fixture, compatibleFixture, completion, until, launchWorkbench } from './helpers.mjs';
import { Provider } from '../src/server/provider.mjs';
import { Runtime } from '../src/server/runtime.mjs';
import { validateRuntimeBudgets } from '../src/core/models/runtime-settings.mjs';
test('selected connection owns the actual endpoint, credential, wire model and mismatch even when legacy is configured for GPT', async t => {
const f = fixture(t);
const legacy = await compatibleFixture(t, () => ({ ...completion([], 'Legacy response'), model: 'owned-gpt' }));
const chosen = await compatibleFixture(t, () => ({ ...completion([], 'Chosen response'), model: 'owned-gpt' }));
f.store.saveConfig({ mode: 'compatible', baseUrl: legacy.baseUrl, model: 'owned-gpt', maxSteps: 1 });
const provider = new Provider(); provider.setKey('owned-legacy-key');
const hub = provider.modelHub(f.store), connection = hub.upsert({ name: 'Chosen Claude route', model: 'owned-claude',
baseUrl: chosen.baseUrl, apiKey: 'owned-chosen-key', modelIdentityPolicy: 'require-match' });
hub.select({ type: 'connection', id: connection.id });
const runtime = new Runtime(f.store, provider); f.onCleanup(() => runtime.stopAll());
runtime.start(f.session.id, 'Reply only; no tools.'); await runtime.active.get(f.session.id).promise;
assert.equal(legacy.requests.length, 0); assert.equal(chosen.requests.length, 1);
assert.equal(chosen.requests[0].headers.authorization, 'Bearer owned-chosen-key');
assert.equal(chosen.requests[0].input.model, 'owned-claude');
const attempt = hub.view().attempts[0], run = f.store.core.run.get(f.session.runId);
assert.equal(attempt.connectionId, connection.id); assert.equal(attempt.poolId, null);
assert.equal(attempt.requestSha256, createHash('sha256').update(JSON.stringify(chosen.requests[0].input)).digest('hex'));
assert.equal(run.stopReason, 'model_identity'); assert.equal(run.model.model, 'owned-claude');
assert.equal(f.store.core.tool.size, 0); assert.deepEqual(attempt.modelIdentity.reportedModels, ['owned-gpt']);
const sealedRun = structuredClone(run);
hub.select({ type: 'legacy' }, { mode: 'compatible' });
const next = f.store.createSession(f.project.id); runtime.start(next.id, 'Reply only; no tools.'); await runtime.active.get(next.id).promise;
assert.equal(legacy.requests.length, 1); assert.equal(chosen.requests.length, 1);
assert.equal(legacy.requests[0].headers.authorization, 'Bearer owned-legacy-key');
assert.equal(legacy.requests[0].input.model, 'owned-gpt'); assert.equal(next.status, 'completed'); assert.deepEqual(run, sealedRun);
});
test('budget-only API and demo/real selection preserve routes, reject injected endpoint fields and publish authoritative selection without keys', async t => {
const f = fixture(t); f.store.close(); const host = await launchWorkbench(t, f.data);
const connection = await host.api('/model-center/connections', { name: 'Owned model', model: 'owned-real',
baseUrl: 'http://127.0.0.1:9/v1', apiKey: 'owned-private-key' });
await host.api('/model-center/select', { type: 'connection', id: connection.id });
const before = await host.api('/model-center'), original = await host.api('/model-center/selection');
const result = await host.api('/model-center/runtime-budgets', { contextLimit: 32000, maxSteps: 8, maxRunTokens: 90000 });
assert.deepEqual(result.modelSelection, { type: 'connection', id: connection.id, name: 'Owned model' });
assert.equal(result.config.contextLimit, 32000); assert.equal(result.config.baseUrl, original.config.baseUrl);
assert.deepEqual((await host.api('/model-center')).connections.find(c => c.id === connection.id), before.connections.find(c => c.id === connection.id));
await assert.rejects(host.api('/model-center/runtime-budgets', { baseUrl: 'http://127.0.0.1:1' }), /只接受运行预算/);
await assert.rejects(host.api('/model-center/runtime-budgets', { maxSteps: 0 }), /范围内的整数/);
await host.api('/model-center/mode', { mode: 'demo' });
assert.deepEqual((await host.api('/model-center')).selected, before.selected);
await host.api('/model-center/select', { type: 'legacy', id: 'legacy-default' });
const legacy = await host.api('/model-center/selection'); assert.equal(legacy.config.mode, 'compatible');
assert.equal(legacy.modelSelection.type, 'legacy');
await host.api('/model-center/select', { type: 'connection', id: connection.id });
const current = await host.api('/model-center/selection'); assert.equal(current.modelSelection.name, 'Owned model');
assert.equal(JSON.stringify(current).includes('owned-private-key'), false);
assert.equal((await host.api('/model-center')).attempts.length, 0);
for (const input of [null, [], {}, { maxSteps: '8' }, { maxTaskTokens: Infinity }, { apiKey: 'never-save' }]) {
assert.throws(() => validateRuntimeBudgets(input));
}
});
test('another session cannot change default model, mode or budgets while a request is active', async t => {
let release; const pending = new Promise(resolve => { release = resolve; });
const upstream = await compatibleFixture(t, async () => { await pending; return { ...completion([], 'Done'), model: 'owned-running' }; });
t.after(() => release());
const f = fixture(t); f.store.close(); const host = await launchWorkbench(t, f.data);
const connection = await host.api('/model-center/connections', { name: 'Active model', model: 'owned-running', baseUrl: upstream.baseUrl, requiresKey: false });
await host.api('/model-center/select', { type: 'connection', id: connection.id });
await host.api('/sessions/' + f.session.id + '/messages', { content: 'Reply only; no tools.' });
await until(() => upstream.requests.length === 1);
const before = await host.api('/model-center/selection');
for (const [route, input] of [['runtime-budgets', { maxSteps: 8 }], ['mode', { mode: 'demo' }], ['select', { type: 'legacy' }]]) {
await assert.rejects(host.api('/model-center/' + route, input), error => error.status === 409);
}
assert.deepEqual(await host.api('/model-center/selection'), before);
release(); await until(async () => (await host.api('/sessions/' + f.session.id)).status !== 'running');
});