diff --git a/AGENTS.md b/AGENTS.md index 13bf24de..5b0683da 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,5 +1,7 @@ # Agent Workbench项目执行规范 +M原生Messages开发验收中:1.24.4源码已接入Anthropic请求/工具与PNG历史、JSON/SSE/累计缓存用量、起始型号、严格暂停、两种显式鉴权与实际URL。首23专项、61相关、48旧协议/身份及编译宿主七组两视口新UI/四类历史UI通过;首307诊断漏URL已修正,原失败保留。当前正式仍原1.24.3/PID36552/Provider;新发行独立源码/便携/安装、保留状态正式升级与单次真实Messages身份预检尚未完成。不得把夹具验证当Claude线路已修复或真实工程/Purge通过;原J/K/L证据保持。 + L只读调查完成:确认当前1.24.3仅支持Chat/Responses,没有原生Messages;供应商公开Claude示例为/v1/messages,原apikey请求按封存配置拼接为/chat/completions,协议/路径与示例不同。原J原字节GPT、单独选定Claude请求与无切池保持,三组实际localhost回放证明没有客户端默认GPT回填;不把文档差异或匿名GET404当作服务器映射的唯一原因,Key分组/实际权重未知。最终37份/652352字节证据离线通过,截图实际JPEG更正与首封存保持;正式PID36552/Provider/55项目71会话及所有原行导出工件/配置精确保持,本轮0真实模型请求。见docs/APIKEY-ROUTE-L-INVESTIGATION.md。下一优先完整Messages协议适配与实际URL诊断,再新开单次有界预检;该产品修复尚未实现,不重跑J/E/H或伪造型号别名。 K已本地交付:1.24.3/source f53eebb7/候选20261103065830519,左下角与顶部统一模型中心,可直接选择/添加连接或号池;独立预算不覆盖路由、旧Run身份保持、跨窗口同步。30相关后端/25升级安装、六类历史UI、最终源码/便携/安装载荷各七组UI、541源码输入/22编译独立重建、三归档/实际便携/12隔离安装及安装副本16+9组通过。正式原PID36552/Provider、55项目/71会话及每表原行/全导出/工件/模型中心精确保持;正式网页和原生窗口回看及再次核对通过,9229关闭。743份/29747694字节证据离线通过,首验收器/长路径/版本清单失败保留;见docs/QA-MODEL-SELECTION-K.md及docs/model-selection-release-identity.json。本阶段真实模型请求0,原J请求Claude/上游报告GPT仍未解决,当前默认高性能池保持;更正连接后再开独立单次身份预检,不重跑J/E/H。下方旧记录按历史时点理解。 diff --git a/CHANGELOG.md b/CHANGELOG.md index fc08c929..0c24ccb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Agent Workbench 更新记录 +## 1.24.4 · 原生 Anthropic Messages(开发验收中) + +- 模型中心增加 Messages 协议和 x-api-key/Bearer 鉴权;预览最终请求地址,支持服务根或 /v1 根地址,保存切换不自动调用模型。 +- 接入原生系统/工具/图片历史、JSON/SSE、停止与完整性检查,以及起始事件中的真实返回型号;不完整或身份不符时保留原响应并暂停。 +- 保留原生用量和缓存分项,累计流用量只结算一次;账本和错误显示请求/响应地址,模型请求不自动跟随重定向。 +- 本机协议、界面与发行验收分别记录;真实连接身份及工程/Purge效果单独判定,未完成项目不宣称已通过。 + ## 1.24.3 · 统一模型选择入口(已本地交付) - 左下角和顶部都打开模型中心,可选择已有连接/模型池、添加模型;选中连接与旧会话实际运行分开展示。 diff --git a/docs/MODEL-PROTOCOLS.md b/docs/MODEL-PROTOCOLS.md index f3268bad..d9e75e88 100644 --- a/docs/MODEL-PROTOCOLS.md +++ b/docs/MODEL-PROTOCOLS.md @@ -1,11 +1,21 @@ # 模型协议与能力边界 -1.17新增OpenAI Responses适配,保留既有Chat Completions。品牌、模型名称与声明不能替代检测。现有API代理可按实际协议添加;未知WorkBuddy登录态、Anthropic原生协议及视觉/音频输入仍未接入。 +1.17新增OpenAI Responses适配,1.24.4新增原生Anthropic Messages,保留既有Chat Completions。品牌、模型名称与声明不能替代检测。现有API代理可按实际协议添加;PNG任务图片按各协议发送,未知WorkBuddy登录态、音频和视频输入尚未接入。 ## 实际协议 Chat沿用messages与tool_calls/tool_call_id;Responses使用typed input/output Items,function_call.call_id与function_call_output严格配对,保留原用量字段。请求使用store:false,支持同一接口和模型下携带加密reasoning Items,换接口/模型时重新生成普通历史,不泄露私有Items。工具采用strict:false以保持现有可选参数契约。 +Messages 使用顶层 system、messages 内容块、tool_use/input_schema 和带原 tool_use_id 的 tool_result。原生 thinking/signature 与 redacted_thinking 只为同地址/型号保留上游历史,不拼成普通助手文本。未知服务端工具和内容块明确暂停;达到输出/上下文上限、pause_turn 或缺少完整终结时不执行工具。 + +连接选择 Anthropic Messages 后,可填服务根地址或以 /v1 结尾的 API 根地址,界面预览最终 POST 地址;例如 https://api.apikey.fan 和 https://api.apikey.fan/v1 都发送到 https://api.apikey.fan/v1/messages。完整 /messages 端点不作为根地址接受。Chat/Responses 延续原有根地址拼接规则,不自动为其它协议增加 /v1。Messages 默认 x-api-key,可显式选择兼容服务的 Bearer;同时发送 anthropic-version:2023-06-01。保存、选择与切换不自动请求模型。 + +Messages SSE 必须依次核对 message_start、每个内容块的 start/delta/stop、message_delta 和 message_stop,工具 JSON 必须完整为对象。message_start.message.model 参与原有请求/返回型号核对,严格模式下未知或不一致即暂停,不以注册别名掩盖不一致。原响应和用量保留;相同字符串也不认证底层模型权重。 + +Messages 的输入计数为 input_tokens + cache_creation_input_tokens + cache_read_input_tokens,message_delta 用量是累计快照,不能把每个快照相加。原字段与缓存分项保留;这是消费记录,不是 Purge 收益证明。原生参数已接入 temperature(0–1)、top_p、top_k、stop_sequences、thinking;max_tokens 始终来自工作台硬预算,不能由自定义参数覆盖。 + +新的请求账本、消费记录和错误信息保存实际请求 URL 与 fetch 观察到的响应 URL。所有模型请求不自动跟随 HTTP 重定向,避免向跳转目标转发任一种凭据;3xx 保留错误并要求核对地址。旧记录没有保存的历史最终 URL 不补造。 + 混合协议或流式模型池封存每个成员实际请求变体;真正发送的请求另有原字节SHA、长度和Task/Run所属工件。历史纯Chat请求继续按原格式核对。预算按最大变体估算和最小成员容量保守预留;不把多线路变体总和当一次发送量。 SSE只显示有界进展。完整参数和终结核对前不派发工具;Chat须完整finish_reason及[DONE],Responses须completed且身份、参数和文本与原片段一致。收到流后断开、超时或协议失败不自动换成员重发。主动停止关闭原HTTP并释放租约。保存有界原响应工件;已知凭据会脱敏,原流SHA和脱敏后工件SHA分别保留。超过4MB则停止读取并明确标记捕获范围。 @@ -24,4 +34,6 @@ SSE只显示有界进展。完整参数和终结核对前不派发工具;Chat - [函数调用](https://developers.openai.com/api/docs/guides/function-calling) - [Responses流式事件](https://developers.openai.com/api/docs/guides/streaming-responses?api-mode=responses) -以上是协议依据,不能证明任意代理完整兼容。专项使用自有loopback服务;真实模型工程效果和Purge收益仍按用户此前选择单独待验。 +Messages 实际读取依据为 [Anthropic 官方 TypeScript SDK 的 Messages 契约](https://github.com/anthropics/anthropic-sdk-typescript/blob/main/src/resources/messages/messages.ts) 和 [apikey 公开请求示例](https://apikey.fan/docs/api-scripts)。本次两份官方文档网页实际转到地区不可用页,没有将该 HTTP200 当作文档内容。 + +以上是协议依据,不能证明任意代理完整兼容。专项使用自有loopback服务;真实连接身份预检、真实模型工程效果和Purge收益分别记录,不借用本机夹具结论。 diff --git a/findings.md b/findings.md index 9048ec6e..e62ead0c 100644 --- a/findings.md +++ b/findings.md @@ -1025,3 +1025,10 @@ I正式交付完成:源码1153e19a/候选20261103042107173,179/179相关回 第三轮整表已完成后,额外“兼容 config.json 全字节不变”的错误断言拒绝。实际仅 configRevision 48→52;按真实 atomicJson 序列化重建的原配置 SHA 精确为测试前 e6d8236b99057d8d42cf2e473f0aca272c01a5ec9c07bfb64cf803395048bc3d。第四轮只为该已证明的修订单调增长增加精确归一化,projects.json 仍要求原字节一致;保留全部首失败,未改写磁盘或降低未知差异检查。 用户要求先核对已有 apikey(请求 claude-opus-5-5)。上一阶段没有真实调用;本轮先新建有界身份预检,不读取或复制 Provider 凭据。旧 E/H 返回身份不一致不能证明本次线路状态。本轮批读历史记录的首输出超过上限,已改为精确文件/短段;PowerShell 未展开路径通配符的 rg 查询报错,后续使用实际目录和 -g。 +# M 接续:Messages 适配边界 + +基线只支持 Chat/Responses;需要第三种协议的完整请求/历史/流/身份/用量转换,不能仅改 URL。Messages 的 message_start.message.model 目前不在身份观察对象中;混合池的预构建变体条件也要纳入非 Chat 协议。保留既有 Chat/Responses wire 字节与历史证据语义。下一核对官方契约,再实施。 + +M 官方来源:Anthropic TypeScript SDK messages.ts(公开 GitHub main,SHA e4a57d12f91fa40aecaa14304e93132eab36b2427741030d720e92cd913c8cb9)确认 /v1/messages、系统独立字段、工具块与 cumulative message_delta、输入量为 input_tokens+cache_creation_input_tokens+cache_read_input_tokens。两份官方文档页面实际重定向到地区不可用页,HTTP200 不作为文档读取成功。供应商公开 api-scripts 页面另存;原始响应和 URL 收据保留 .qa/messages-m/reference。 + +M 首23专项22通过/1失败:真实 JSON/SSE 两轮原工具与缓存用量、混合池、取消、九类异常流均通过;307确实未跟随且目标零请求,但失败诊断没有保留新 requestUrl。原因是 connectionFailure/httpFailure 显式选取旧字段;已在 Provider catch 绑定本次实际 URL,复验而不更改首日志。已有 Chat/Responses/identity 48项通过,首构建通过。 diff --git a/package-lock.json b/package-lock.json index eeb2b5b6..52d174dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "local-agent-workbench", - "version": "1.24.3", + "version": "1.24.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "local-agent-workbench", - "version": "1.24.3", + "version": "1.24.4", "dependencies": { "@babel/parser": "7.29.11", "@peculiar/x509": "3.1.0", diff --git a/package.json b/package.json index 9dc23047..c49758b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "local-agent-workbench", - "version": "1.24.3", + "version": "1.24.4", "private": true, "type": "module", "description": "A local coding workbench with explicit tool execution, reviewable changes and recoverable sessions.", diff --git a/progress.md b/progress.md index 2a37ca0b..5ce53a16 100644 --- a/progress.md +++ b/progress.md @@ -1552,3 +1552,12 @@ I本地索引1648份/88426738字节批量原字节核对通过。首次cached di ## J:真实连接预检开始 已接收用户选择“先核对现有 apikey Claude 连接”。先按 docs/LIVE-RETEST-J-PLAN.md 封存正式基线和新契约,再单次发送;尚未发出真实请求。Provider 和原始密钥保持在原进程,测试不抽取凭据、不重启服务。 +# M 接续:原生 Anthropic Messages(2026-11-03) + +已恢复 L 结论与干净基线 b832982d;创建 feat/anthropic-messages-1.24.4。session-catchup 未返回待同步内容。读取执行规范、既有协议与流适配,开始契约核对;尚无源码修改、新发行或真实模型请求。 + +恢复时宽批读输出截断,已改为按真实文件短段读取;一次 rg 指向不存在的 src/web/src/ui,改用 rg --files 定位,不把截断或缺失输出记为已审查。 + +M 开发验收:原23专项修正后23/23,补充严格SSE型号与原工具块关闭后仍需message_stop后最终25/25;相关14文件144/144通过。原Chat/Responses/identity48项、另一批相关61项保持。编译宿主新7组两视口UI与模型中心/协议/身份/选择4类历史UI通过;实际回看desktop-editor/narrow-ledger原图,补充账本滚入截图。首307诊断漏URL失败保留,修正catch绑定实际URL;新请求不自动跟随重定向。 + +正式发行前只读基线再次通过:原1.24.3/PID36552/Provider、hasKey=true、55项目/71全部会话、所有原表行/全导出/工件/公开模型中心均与K最终精确一致;本轮到此真实请求0。独立发行和单次新预检未完成,不将本机夹具当Claude线路通过。 diff --git a/scripts/verify-all-ui.mjs b/scripts/verify-all-ui.mjs index ad5d171e..a23328da 100644 --- a/scripts/verify-all-ui.mjs +++ b/scripts/verify-all-ui.mjs @@ -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', '1.24.3'].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', '1.24.4'].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', '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`]] : []), + ...(['1.24.0', '1.24.1', '1.24.2', '1.24.3', '1.24.4'].includes(version) ? [['verify-file-results-ui.mjs', null]] : []), + ...(['1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '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]) : []), + ...(['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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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', '1.24.4'].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']); diff --git a/scripts/verify-anthropic-messages-ui.mjs b/scripts/verify-anthropic-messages-ui.mjs new file mode 100644 index 00000000..547ba25c --- /dev/null +++ b/scripts/verify-anthropic-messages-ui.mjs @@ -0,0 +1,122 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import http from 'node:http'; +import assert from 'node:assert/strict'; +import { randomUUID, createHash } from 'node:crypto'; +import { chromium, expect } from 'playwright/test'; +import { fixture, launchWorkbench, until } from '../tests/helpers.mjs'; + +if (process.argv.includes('--help')) { console.log('node scripts/verify-anthropic-messages-ui.mjs [--app-root ABS] — isolated Messages editor, actual JSON/SSE, tool roundtrip, identity mismatch, URLs, raw errors, reload and 390px; synthetic credentials only.'); 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 = fs.realpathSync.native(args[1] ?? process.cwd()); +const directory = path.resolve('.qa', 'messages-ui-m-' + randomUUID()); fs.mkdirSync(directory, { recursive: true }); console.log('EVIDENCE ' + directory); +const disposers = [], t = { after: fn => disposers.push(fn) }, f = fixture(t); f.store.close(); +const requests = [], sockets = new Set(), checks = [], screenshots = [], errors = []; +let mode = 'ok'; +const msg = (content, stop_reason) => ({ id: 'msg_owned_ui', type: 'message', role: 'assistant', model: mode === 'mismatch' ? 'gpt-owned-other' : 'claude-owned-ui', content, stop_reason, + usage: { input_tokens: 40, cache_creation_input_tokens: 10, cache_read_input_tokens: 20, output_tokens: 8 } }); +const modelServer = http.createServer(async (req, res) => { + try { + const parts = []; for await (const chunk of req) parts.push(chunk); + const body = JSON.parse(Buffer.concat(parts)), raw = Buffer.concat(parts); + requests.push({ route: req.url, body, auth: req.headers.authorization === 'Bearer owned-ui-key', keyHeaderPresent: req.headers['x-api-key'] !== undefined, version: req.headers['anthropic-version'], sha256: createHash('sha256').update(raw).digest('hex') }); + assert.equal(req.url, '/v1/messages'); assert.equal(req.headers.authorization, 'Bearer owned-ui-key'); assert.equal(req.headers['x-api-key'], undefined); assert.equal(req.headers['anthropic-version'], '2023-06-01'); + if (mode === 'error') { res.writeHead(429, { 'Content-Type': 'application/json', 'request-id': 'req_owned_limit', 'Retry-After': '1' }); res.end(JSON.stringify({ type: 'error', error: { type: 'rate_limit_error', message: 'owned Messages limit' } })); return; } + const prompt = body.messages.filter(m => m.role === 'user').flatMap(m => m.content).filter(b => b.type === 'text').map(b => b.text).join('\n'); + const nonce = prompt.match(/nonce ([a-f0-9-]+)/)?.[1], probe = prompt === 'Reply OK.' || !!nonce; + const completedTool = body.messages.some(m => m.content.some(b => b.type === 'tool_result')); + const tool = { type: 'tool_use', id: 'call_owned_ui', name: nonce ? 'workbench_capability_echo' : 'list_files', input: nonce ? { nonce } : { path: '', depth: 1 } }; + const content = mode === 'mismatch' || probe && !nonce || completedTool ? [{ type: 'text', text: '已核对。' }] : [tool]; + const final = msg(content, content[0].type === 'tool_use' ? 'tool_use' : 'end_turn'); + if (!body.stream) { res.writeHead(200, { 'Content-Type': 'application/json', 'request-id': 'req_owned_native' }); res.end(JSON.stringify(final)); return; } + res.writeHead(200, { 'Content-Type': 'text/event-stream', 'request-id': 'req_owned_native' }); + const send = (type, fields = {}) => res.write('event: ' + type + '\ndata: ' + JSON.stringify({ type, ...fields }) + '\n\n'); + send('message_start', { message: { ...final, content: [], stop_reason: null, usage: { ...final.usage, output_tokens: 1 } } }); + content.forEach((block, index) => { + send('content_block_start', { index, content_block: block.type === 'text' ? { ...block, text: '' } : { ...block, input: {} } }); + send('content_block_delta', { index, delta: block.type === 'text' ? { type: 'text_delta', text: block.text } : { type: 'input_json_delta', partial_json: JSON.stringify(block.input) } }); + send('content_block_stop', { index }); + }); + send('message_delta', { delta: { stop_reason: final.stop_reason, stop_sequence: null }, usage: { output_tokens: final.usage.output_tokens } }); send('message_stop'); res.end(); + } catch (cause) { errors.push('owned upstream: ' + cause.message); res.destroy(); } +}); +modelServer.on('connection', socket => { sockets.add(socket); socket.on('close', () => sockets.delete(socket)); }); +await new Promise(resolve => modelServer.listen(0, '127.0.0.1', resolve)); +const baseUrl = 'http://127.0.0.1:' + modelServer.address().port; +const host = await launchWorkbench(t, f.data, {}, { appRoot, nodePath: args.length ? path.join(appRoot, 'runtime/node.exe') : process.execPath }); +const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1000 } }); +page.on('pageerror', cause => errors.push(cause.message)); +const mark = message => { checks.push(message); console.log('PASS ' + message); }; +const dialog = () => page.getByRole('dialog', { name: '模型中心', exact: true }); +async function open() { if (!await dialog().isVisible()) await page.getByRole('button', { name: '打开模型中心', exact: true }).click(); return dialog(); } +async function shot(name) { + const file = path.join(directory, name + '.png'); await page.screenshot({ path: file }); screenshots.push(file); + assert.ok(await page.locator('body').evaluate(node => node.scrollWidth <= innerWidth), 'page overflow: ' + name); + assert.ok(await dialog().evaluate(node => node.scrollWidth <= node.clientWidth + 1), 'dialog overflow: ' + name); +} +let result; +try { + await page.addInitScript(({ projectId, sessionId }) => { localStorage.setItem('awb-project', projectId); localStorage.setItem('awb-session', sessionId); }, { projectId: f.project.id, sessionId: f.session.id }); + await page.goto(host.url); await page.waitForLoadState('networkidle'); await open(); + await dialog().getByRole('button', { name: '添加连接', exact: true }).click(); const form = dialog().getByRole('form', { name: '编辑模型连接', exact: true }); + await form.getByLabel('连接名称', { exact: true }).fill('本机 Messages 验收'); await form.getByLabel('接口协议', { exact: true }).selectOption('anthropic-messages'); + await form.getByLabel('接口根地址', { exact: true }).fill(baseUrl); await form.getByLabel('请求模型名称', { exact: true }).fill('claude-owned-ui'); + await form.getByLabel('临时 API Key', { exact: true }).fill('owned-ui-key'); await form.getByLabel('Messages 鉴权', { exact: true }).selectOption('bearer'); + await form.getByLabel('型号核对', { exact: true }).selectOption('require-match'); await form.getByLabel('流式能力', { exact: true }).selectOption('supported'); await form.getByLabel('使用流式输出', { exact: true }).check(); + await expect(form.getByLabel('请求地址预览', { exact: true })).toContainText(baseUrl + '/v1/messages'); await shot('desktop-editor'); + await page.setViewportSize({ width: 390, height: 844 }); await form.scrollIntoViewIfNeeded(); await shot('narrow-editor'); + await form.getByLabel('接口根地址', { exact: true }).fill(baseUrl + '/v1/messages'); await form.getByRole('button', { name: '保存模型连接', exact: true }).click(); + await expect(dialog().locator('.mc-notice')).toContainText('根地址'); await expect(form.getByLabel('连接名称', { exact: true })).toHaveValue('本机 Messages 验收'); + await form.getByLabel('接口根地址', { exact: true }).fill(baseUrl + '/v1'); await form.getByRole('button', { name: '保存模型连接', exact: true }).click(); await expect(form).toHaveCount(0); + assert.equal(requests.length, 0); mark('root and /v1 preview agree, full endpoint rejects with input retained; save makes no model request'); + await page.reload(); await open(); const card = dialog().locator('.mc-connection').filter({ hasText: '本机 Messages 验收' }); + await expect(card).toContainText('Anthropic Messages · 流式开启'); await expect(card).toContainText('Bearer'); await expect(card).toContainText(baseUrl + '/v1/messages'); + let center = await host.api('/model-center'), connection = center.connections.find(c => c.name === '本机 Messages 验收'); assert.equal(connection.messagesAuth, 'bearer'); + await card.getByRole('button', { name: '用于新任务', exact: true }).click(); assert.equal(requests.length, 0); await page.reload(); await open(); + await expect(dialog().getByLabel('新任务默认模型', { exact: true })).toHaveValue('connection:' + connection.id); await shot('narrow-saved'); + mark('saved protocol, auth and selected connection survive reload and remain operable at 390px'); + await page.setViewportSize({ width: 1440, height: 1000 }); await card.getByRole('button', { name: '原生参数', exact: true }).click(); + const native = dialog().getByRole('form', { name: '原生请求参数', exact: true }); await expect(native.getByLabel('输出上限字段')).toHaveValue('max_tokens'); + await expect(native.getByLabel('输出上限字段').locator('option')).toHaveCount(1); await native.getByLabel('原生参数 JSON').fill('{"reasoning_effort":"high"}'); + await native.getByRole('button', { name: '保存原生参数', exact: true }).click(); await expect(native.getByRole('alert')).toContainText('尚未接入'); + await native.getByLabel('原生参数 JSON').fill('{"temperature":0.3,"top_k":12}'); await native.getByRole('button', { name: '保存原生参数', exact: true }).click(); await expect(native).toHaveCount(0); + assert.equal(requests.length, 0); mark('native settings reject other-protocol fields and keep a single hard max_tokens output field'); + for (const [scope, title] of [['text', '文本'], ['tools', '工具'], ['streaming', '流式']]) { + await card.getByLabel('本机 Messages 验收检测范围').selectOption(scope); await card.getByRole('button', { name: '验证响应(调用模型)', exact: true }).click(); + await expect(dialog().locator('.mc-notice')).toContainText(title + '检测通过'); + } + assert.equal(requests.length, 3); assert.ok(requests.every(r => r.body.top_k === 12 && r.body.temperature === 0.3)); mark('actual local JSON text/tool and native SSE capability probes use the saved protocol and auth'); + await dialog().getByRole('button', { name: '关闭窗口', exact: true }).click(); + await host.api('/sessions/' + f.session.id + '/messages', { content: '读取本项目文件一次后结束。' }); + await until(async () => !['running', 'queued'].includes((await host.api('/sessions/' + f.session.id)).status), 20000); + const session = await host.api('/sessions/' + f.session.id); assert.equal(session.status, 'completed'); + assert.equal(requests.length, 5); assert.ok(requests[4].body.messages.some(m => m.content.some(b => b.type === 'tool_result' && b.tool_use_id === 'call_owned_ui'))); + await open(); await dialog().getByRole('button', { name: '请求账本', exact: true }).click(); + await expect(dialog().locator('.mc-attempts')).toContainText('请求与返回型号一致'); await expect(dialog().locator('.mc-attempts')).toContainText(baseUrl + '/v1/messages'); + await expect(dialog().locator('.mc-attempts')).toContainText('70 输入 / 8 输出 tokens'); await dialog().locator('.mc-attempts article').first().scrollIntoViewIfNeeded(); await shot('desktop-ledger'); + await page.setViewportSize({ width: 390, height: 844 }); await dialog().locator('.mc-attempts article').first().scrollIntoViewIfNeeded(); await shot('narrow-ledger'); mark('compiled native tool roundtrip completes with original call ID, cache-inclusive usage and observed request/response URLs'); + await dialog().getByRole('button', { name: '关闭窗口', exact: true }).click(); mode = 'mismatch'; + const second = await host.api('/sessions', { projectId: f.project.id }); await host.api('/sessions/' + second.id + '/messages', { content: '有界身份异常夹具。' }); + await until(async () => !['running', 'queued'].includes((await host.api('/sessions/' + second.id)).status), 20000); + center = await host.api('/model-center'); assert.equal(center.attempts[0].modelIdentity.status, 'mismatch'); assert.equal(requests.length, 6); + await open(); await dialog().getByRole('button', { name: '请求账本', exact: true }).click(); await expect(dialog().locator('.mc-attempts')).toContainText('请求与返回型号不一致'); await shot('narrow-mismatch'); + mark('strict mismatch is visible with original GPT identifier and one request, no retry or tool dispatch'); + // A separate owned connection avoids bypassing the intentionally blocked identity route. + mode = 'error'; const original = center.connections.find(c => c.id === connection.id); + connection = await host.api('/model-center/connections', { ...original, id: undefined, name: '本机 Messages 错误验收', apiKey: 'owned-ui-key' }); + // The API returns the authoritative center; resolve by its explicit owned name. + center = await host.api('/model-center'); connection = center.connections.find(c => c.name === '本机 Messages 错误验收'); + await expect(dialog().getByRole('button', { name: '刷新模型中心', exact: true })).toBeEnabled(); await dialog().getByRole('button', { name: '刷新模型中心', exact: true }).click(); + await dialog().getByRole('button', { name: '模型连接', exact: true }).click(); const errorCard = dialog().locator('.mc-connection').filter({ hasText: '本机 Messages 错误验收' }); + await errorCard.getByRole('button', { name: '验证响应(调用模型)', exact: true }).click(); await expect(dialog().locator('.mc-notice')).toContainText('模型服务请求达到限额'); + await dialog().locator('.mc-notice summary').click(); await expect(dialog().getByLabel('上游错误原文')).toContainText('owned Messages limit'); + await expect(dialog().locator('.mc-notice')).toContainText('req_owned_limit'); await expect(dialog().locator('.mc-notice')).toContainText(baseUrl + '/v1/messages'); await shot('narrow-error'); + assert.equal(requests.length, 7); mark('429 preserves native type, raw message, request ID, URL and inputs without automatic replay'); + assert.deepEqual(errors, []); + result = { success: true, appRoot, testedVersion: (await host.api('/health')).version, directory, checks, screenshots, errors, requests, realModelRequests: 0, + scope: 'Compiled UI and actual owned localhost API; no configured-model capability or model-weight claim.' }; +} catch (cause) { result = { success: false, directory, checks, screenshots, errors, error: cause.stack, requests, realModelRequests: 0 }; await page.screenshot({ path: path.join(directory, 'failure.png') }).catch(() => {}); process.exitCode = 1; } +finally { + fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify({ success: result.success, checks: checks.length, directory, error: result.error })); + await browser.close(); for (const dispose of disposers.reverse()) await dispose(); for (const socket of sockets) socket.destroy(); await new Promise(resolve => modelServer.close(resolve)); +} diff --git a/scripts/verify-controlled-release.mjs b/scripts/verify-controlled-release.mjs index e775f5d7..31aa97d7 100644 --- a/scripts/verify-controlled-release.mjs +++ b/scripts/verify-controlled-release.mjs @@ -22,7 +22,7 @@ export async function verifyControlledApi({ api, url, token, directory, appRoot, const origin = new URL(url); assert.equal(origin.hostname, '127.0.0.1'); assert.notEqual(origin.port, '4318'); const expectedVersion = JSON.parse(fs.readFileSync(path.join(appRoot, fs.existsSync(path.join(appRoot, 'MANIFEST.json')) ? 'MANIFEST.json' : 'package.json'), 'utf8')).version; - assert.ok(['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.20.2', '1.20.3', '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(expectedVersion)); + assert.ok(['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.20.2', '1.20.3', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3', '1.24.4'].includes(expectedVersion)); const bootstrap = await api('/bootstrap'); assert.equal(bootstrap.version, expectedVersion); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false); const root = path.join(directory, 'compiled-controlled-node'), hooks = path.join(directory, 'disabled-hooks'); diff --git a/scripts/verify-desktop-install.mjs b/scripts/verify-desktop-install.mjs index e92ba970..e21b4172 100644 --- a/scripts/verify-desktop-install.mjs +++ b/scripts/verify-desktop-install.mjs @@ -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', '1.24.3'].includes(version)) { + if (['1.24.0', '1.24.1', '1.24.2', '1.24.3', '1.24.4'].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 = []; diff --git a/scripts/verify-release.mjs b/scripts/verify-release.mjs index cd111429..3c0c9e2e 100644 --- a/scripts/verify-release.mjs +++ b/scripts/verify-release.mjs @@ -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', '1.24.3'].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', '1.24.4'].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', '1.24.3'].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', '1.24.4'].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', '1.24.3'].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', '1.24.4'].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', '1.24.3'].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', '1.24.4'].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', '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; + 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', '1.24.4'].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', '1.24.4'].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', '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 }; + 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', '1.24.4'].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 {} } } diff --git a/src/client/ModelCenter.css b/src/client/ModelCenter.css index 1ca8d557..7eecac0f 100644 --- a/src/client/ModelCenter.css +++ b/src/client/ModelCenter.css @@ -24,3 +24,4 @@ .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}} +.mc-request-url { overflow-wrap: anywhere; font-family: var(--font-mono, monospace); font-size: 12px; line-height: 1.6; } diff --git a/src/client/ModelCenter.tsx b/src/client/ModelCenter.tsx index 2a7ba235..14387ddb 100644 --- a/src/client/ModelCenter.tsx +++ b/src/client/ModelCenter.tsx @@ -9,11 +9,14 @@ import { ModelWaitSettings, type WaitSettings } from './ModelWaitSettings'; import { NativeParameters } from './NativeParameters'; import { ModelErrorDetails } from './ModelErrorDetails'; import { ModelBudgetSettings } from './ModelBudgetSettings'; +import { modelRequestUrl, protocolLabel } from '../shared/contracts/model-endpoint.mjs'; -type Connection = { id: string; name: string; brand: string; protocol: string; baseUrl: string; model: string; enabled: boolean; revision: number; hasKey: boolean; +const previewUrl = (value: { protocol: string; baseUrl: string }) => { try { return modelRequestUrl(value); } catch { return '请填写有效的接口根地址'; } }; + +type Connection = { id: string; name: string; brand: string; protocol: string; messagesAuth?: string; baseUrl: string; model: string; enabled: boolean; revision: number; hasKey: boolean; requiresKey: boolean; modelIdentityPolicy?: string; modelIdentityAliases?: string[]; modelIdentityAliasSource?: string; nativeParameters?: Record; outputTokenField?: string; streaming?: boolean; capabilityDeclarations?: Record; capabilities?: Record; capabilityEvidence?: { checkedAt: string }; contextLimit: number; maxOutputTokens: number; concurrency: number; status: string; activeRequests: number; savedCredential?: { status: string }; health: { state: string; reason?: string; cooldownUntil?: number } }; type Pool = { id?: string; name: string; members: { connectionId: string; weight: number }[]; strategy: string; sticky: boolean; maxAttempts: number; revision?: number; queueTimeoutMs: number }; -type Attempt = { modelIdentity?: ModelIdentity; diagnostic?: RuntimeFailure; upstreamResponse?: { requestId?: string | null }; id: string; connectionId: string; poolId: string | null; model: string; protocol?: string; streaming?: boolean; rejections?: { connectionName: string; capability: string; reason: string }[]; status: string; startedAt: string; ordinal: number; usageStatus: string; reason?: string; taskId?: string; sessionId?: string; runId: string; requestArtifactId?: string; responseArtifactId?: string; responseSha256?: string; responseRedacted?: boolean; stream?: { bytes: number; capturedBytes?: number; frames: number; sha256: string; terminal: boolean }; usage?: { prompt_tokens?: number; completion_tokens?: number } }; +type Attempt = { modelIdentity?: ModelIdentity; diagnostic?: RuntimeFailure; requestUrl?: string; upstreamResponse?: { requestId?: string | null; requestUrl?: string; responseUrl?: string | null; redirectMode?: string }; id: string; connectionId: string; poolId: string | null; model: string; protocol?: string; streaming?: boolean; rejections?: { connectionName: string; capability: string; reason: string }[]; status: string; startedAt: string; ordinal: number; usageStatus: string; reason?: string; taskId?: string; sessionId?: string; runId: string; requestArtifactId?: string; responseArtifactId?: string; responseSha256?: string; responseRedacted?: boolean; stream?: { bytes: number; capturedBytes?: number; frames: number; sha256: string; terminal: boolean }; usage?: { prompt_tokens?: number; completion_tokens?: number } }; type ImportRecord = { id: string; source: string; path: string; enabled: boolean; lastCheckedAt?: string; lastSyncedAt?: string; lastError?: string; lastResult?: { imported?: number; conflicts?: string[] } }; type Center = { revision: number; selected: { type: string; id: string }; waitSettings: WaitSettings; connections: Connection[]; pools: Pool[]; imports: ImportRecord[]; attempts: Attempt[]; waiting: number }; type Operations = { checkedAt: string; version: string; scope: string; activeTasks: number; queue: number; checks: { id: string; title: string; status: string; detail: string }[]; @@ -30,7 +33,7 @@ export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig: const [view, setView] = useState
(null); const [runtimeConfig, setRuntimeConfig] = useState(null); const [tab, setTab] = useState('connections'); - const [draft, setDraft] = useState(initial); + const [draft, setDraft] = useState; outputTokenField?: string }>(initial); const [editing, setEditing] = useState(false), [key, setKey] = useState(''); const [nativeTarget, setNativeTarget] = useState(null); const [persistKey, setPersistKey] = useState(false), [persistImports, setPersistImports] = useState(false); @@ -97,7 +100,7 @@ export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig: {view.connections.map(connection => )} {!!view.pools.length && {view.pools.map(pool => )}} -
{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 || '未配置'}` : '请选择可用连接。'; })()}
+
{runtimeConfig?.mode === 'demo' ? '离线演示使用固定脚本,不调用大模型。' : selected?.type === 'pool' ? '模型池按成员配置调度;每次实际连接和返回型号保存在请求账本。' : (() => { const connection = view.connections.find(c => c.id === selected?.id); return connection ? `${protocolLabel(connection.protocol)} · ${previewUrl(connection)} · 请求 ${connection.model || '未配置'}` : '请选择可用连接。'; })()}
{runModel &&
当前会话最近运行{runModel.mode === 'demo' ? '离线演示' : runModel.routing?.members?.length ? runModel.routing.members.map(member => member.name + ' · ' + member.model).join(';') : runModel.model}这是该次运行封存的请求配置;实际返回型号请看请求账本。更改默认选择不会改写旧记录。
} {tab === 'budgets' && runtimeConfig && void act(async () => { await api('/model-center/runtime-budgets', input); if (alive.current) setNotice('运行预算已保存,当前模型选择保持。'); })} />} @@ -108,8 +111,8 @@ export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig: {tab === 'connections' && <>

模型连接

保存多条连接后可在上方切换;添加连接不会替换当前模型。凭据可选择本机加密保存。

{view.connections.map(value =>
-

{value.name}

{value.brand} · {value.protocol === 'responses' ? 'Responses' : 'Chat Completions'}{value.streaming ? ' · 流式开启' : ''}
{states[value.status]}
-
模型
{value.model || '尚未填写'}
接口
{value.baseUrl}
凭据
{value.hasKey ? value.savedCredential?.status === 'saved' ? '已设置,可从本机加密保存加载' : '已设置,重启需重新填写' : value.requiresKey ? '尚未填写' : '此服务可不填'}
请求 / 容量
{value.activeRequests} 在途 · 并发 {value.concurrency} · 上下文 {value.contextLimit.toLocaleString()}
+

{value.name}

{value.brand} · {protocolLabel(value.protocol)}{value.streaming ? ' · 流式开启' : ''}
{states[value.status]}
+
模型
{value.model || '尚未填写'}
请求地址
{previewUrl(value)}
{value.protocol === 'anthropic-messages' && <>
鉴权
{value.messagesAuth === 'bearer' ? 'Bearer' : 'x-api-key'} · anthropic-version 2023-06-01
}
凭据
{value.hasKey ? value.savedCredential?.status === 'saved' ? '已设置,可从本机加密保存加载' : '已设置,重启需重新填写' : value.requiresKey ? '尚未填写' : '此服务可不填'}
请求 / 容量
{value.activeRequests} 在途 · 并发 {value.concurrency} · 上下文 {value.contextLimit.toLocaleString()}
{Object.entries(capabilityLabels).map(([key, title]) => {title}:{capabilityStates[value.capabilities?.[key] ?? 'unknown']})}
{value.health.reason &&

{value.health.reason}{!!value.health.cooldownUntil && value.health.cooldownUntil > Date.now() && ' · 冷却至 ' + new Date(value.health.cooldownUntil).toLocaleTimeString()}

}