diff --git a/CHANGELOG.md b/CHANGELOG.md index fbb7c5b8..0ec97438 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Agent Workbench 更新记录 +## 1.20.3 · 模型原生参数与错误保留 + +- 错误详情与模型请求账本保留上游原文、code/type、请求ID和原Retry-After,并标明本地超时/协议核验与上游失败的来源。 +- HTTP错误正文有界保存、凭据脱敏、截断范围与工件校验可查;SSE失败保留原事件、已报告用量和原流,不重放未完整工具。 +- 额度不足不重复请求同线路,模型池可按规则选其他可用成员;长Retry-After不截成90秒,不足等待预算时结束原请求。 +- 每个连接可配置现有Chat/Responses已接入的推理、采样、工具并行和文本详略参数,以及Chat输出上限字段;实际请求可下载,未知字段明确拒绝。 +- 1.22内置浏览器的阶段、前置依赖和实际验收已明确;当前1.10静态工程页面验收不冒充通用浏览器。 + + ## 1.20.2 · 模型响应等待修复 - 修复模型生成被固定60秒截止的问题:响应总等待默认5分钟、流式无数据默认2分钟,模型中心可调整。 diff --git a/README.md b/README.md index 21348cae..bb3fe478 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # 本地 Agent 工作台 -1.20.2修复固定60秒生成截止,新增模型中心「等待时限」;当前正式版本已升级,原连接和历史保持。见[工作台](http://127.0.0.1:4318/?release=1.20.2)、[验收](docs/QA-1.20.2.md)、[回顾](docs/RETROSPECTIVE-1.20.2.md)和[发行身份](docs/model-wait-release-identity.json)。历史失败仍按原记录显示,手动续接的新请求使用新时限,任务总预算仍优先。 +1.20.3新增上游错误详情/原文下载、原生参数配置和按原因处理429,见[验收记录](docs/QA-1.20.3.md)。正式部署以最终发行身份为准。内置浏览器已明确为[1.22阶段](docs/PLAN-1.22.md),当前已有静态工程页面验收。 + +上一维护版1.20.2修复固定60秒生成截止,新增模型中心「等待时限」;当前正式版本已升级,原连接和历史保持。见[工作台](http://127.0.0.1:4318/?release=1.20.2)、[验收](docs/QA-1.20.2.md)、[回顾](docs/RETROSPECTIVE-1.20.2.md)和[发行身份](docs/model-wait-release-identity.json)。历史失败仍按原记录显示,手动续接的新请求使用新时限,任务总预算仍优先。 1.20.1已修复任务目标丢失、审查后附加测试、完整无参工具报错、失败消费漏记和无进展循环,并修复暂停收尾及Windows退出竞态。独立626项、实际桌面/390px、安装/升级通过,原连接与全部历史保持。见[工作台](http://127.0.0.1:4318/?release=1.20.1)、[验收](docs/QA-1.20.1.md)、[回顾](docs/RETROSPECTIVE-1.20.1.md)和[发行身份](docs/task-control-release-identity.json)。1.21计划保留,真实模型自主工程复验单列。 diff --git a/docs/MODEL-FIDELITY-PLAN.md b/docs/MODEL-FIDELITY-PLAN.md index a27de103..4dd642ec 100644 --- a/docs/MODEL-FIDELITY-PLAN.md +++ b/docs/MODEL-FIDELITY-PLAN.md @@ -1,6 +1,6 @@ # 模型能力与错误信息保留方案 -用户提出工作台应保留大模型能力,错误也应传到用户面前,并询问Codex是否为原样透传。本记录固定接入原则与已确认缺口;属于后续维护方案,尚未实现,不改变正式1.20.2服务或原会话。 +用户提出工作台应保留大模型能力,错误也应传到用户面前,并询问Codex是否为原样透传。本记录固定接入原则与已确认缺口。用户随后授权实现上线,1.20.3候选已完成HTTP/SSE错误、重试语义、错误界面与现有Chat/Responses原生参数接入;最终验证/部署见[QA-1.20.3](QA-1.20.3.md),不将候选阶段写为正式上线。更多原生参数与新模态继续逐项开发,原会话不回写。 ## 接入原则 diff --git a/docs/NEXT-STEPS.md b/docs/NEXT-STEPS.md index ec58ed7d..55fdbc7c 100644 --- a/docs/NEXT-STEPS.md +++ b/docs/NEXT-STEPS.md @@ -1,6 +1,8 @@ # 后续执行计划 -新增接入要求:按[模型能力与错误信息保留方案](MODEL-FIDELITY-PLAN.md)先补有界HTTP/SSE原错误、上游request ID、原code/type与Retry-After,再逐项验证供应商原生能力和参数。1.20.2目前不是全能力/全错误字段透传;本次只完成源码审查与方案登记,正式服务未改动。原失败不回写,本机ID与上游ID分开,不把中文解释当原文。 +最新执行顺序:1.20.3实现并本地上线模型错误保留与现有协议原生参数 → [1.21工程依赖与可复现环境](PLAN-1.21.md) → [1.22工作台内置浏览器](PLAN-1.22.md)。1.10已有静态构建的真实Edge页面验收,1.22才是项目开发预览、桌面内嵌标签页与可观察/停止的通用网站操作;Codex右侧浏览器不算本产品内置能力。 + +新增接入要求按[模型能力与错误信息保留方案](MODEL-FIDELITY-PLAN.md)执行:1.20.3候选已实现有界HTTP/SSE原错误、上游request ID、原code/type与Retry-After及现有Chat/Responses原生参数;实际验证/部署以[QA-1.20.3](QA-1.20.3.md)为准。更多供应商参数与模态仍逐项验证,不能称为全能力透传。原失败不回写,本机ID与上游ID分开,不把中文解释当原文。 本轮正式暂存及独立核对实际耗时860秒,最终安装指针激活及原状态核对647秒,发行19560文件。原暂存后因新增模型尝试被拒绝的结果保持失败,耗时不能当成已通过的性能指标。后续维护优先研究运行载荷与历史验收材料分离、同一发行的必要核对复用,以及当前校验阶段/耗时/失败收据的可见反馈;保留路径、字节变化和回滚门槛,另行实现验收。 diff --git a/docs/PLAN-1.22.md b/docs/PLAN-1.22.md new file mode 100644 index 00000000..6bb74f58 --- /dev/null +++ b/docs/PLAN-1.22.md @@ -0,0 +1,23 @@ +# 1.22 后续方案:工作台内置浏览器 + +当前是计划,尚未实现。1.20.3先完成模型错误与原生参数维护;1.21完成工程依赖与可复现环境,随后1.22交付内置浏览器。具体版本取决于前置验收,阶段边界以本文件为准。 + +## 现有基础与目标 + +1.10以来已有封存静态工程构建、独立Edge上下文、填写/选择/点击/断言、DOM/控制台/请求/PNG与Task归属;现有桌面入口也可打开所属成果。它们用于工程页面验收,不等于工作台内已有通用浏览器。Codex右侧浏览器是Codex提供的外部功能,不计入本产品能力。 + +让用户在工作台查看和操作所属项目预览,也能给代理一个明确的网站目标,观察页面、连续交互、核对结果;用户与代理共享可核对的标签页状态。桌面内嵌视图与受控浏览服务分层,手机伴随端先观察原结果及审批,不直接取得Windows浏览器进程控制权。 + +## 执行切片 + +| 切片 | 实际交付 | 验收 | +| --- | --- | --- | +| A 项目开发预览 | 复用1.21固定环境,所属开发服务的启动/就绪URL/日志/停止;静态和开发服务均可打开 | React实际开发服务、改动后页面更新、服务退出/端口冲突/停止;不自动复用未知进程 | +| B 桌面浏览区 | Electron独立浏览视图、标签页、地址/来源、前进后退/刷新/关闭;任务与页面归属可见 | 真正可交互页面、外站无法取得工作台宿主API或Node权限、关闭视图与停止任务行为分别验证 | +| C 代理浏览工具 | 打开明确目标、读取可见页面/DOM/截图、点击/输入/滚动/等待;保存原定位、输入、输出和截图工件 | 多步真实网站任务、失败定位、页面变更、弹窗和停止;模型建议只通过所属执行工具生效 | +| D 会话与权限 | 独立浏览配置、可选持久登录资料、域名/操作范围、可撤销授权;下载与敏感提交有可核对审批 | 登录态隔离/清除/关闭;下载绑定目录/文件/来源;站点内容不能自行授予新权限或跨任务访问 | +| E 验收与交付 | 本地测试站和真实允许目标,桌面/390px观察与手机审批;原任务/浏览进程/证据保留和本地发行 | 页面身份、可恢复状态、无自动重放敏感操作、实际任务结果、更新回退;每切片本地Git与回顾 | + +支付、发消息、上传私有资料等操作按实际用户授权处理;通用操作电脑、任意浏览器登录导入、语音与视频另列后续,不从能打开网页推断全部实现。浏览器里的文字和下载文件属于任务数据。 + +先完成项目预览与浏览区,再接网站连续操作;开发和验收均复用现有Task/Run、审批、预算、事件与工件,避免再建一套不受任务内核管理的浏览器。 diff --git a/docs/QA-1.20.3.md b/docs/QA-1.20.3.md new file mode 100644 index 00000000..0ce37876 --- /dev/null +++ b/docs/QA-1.20.3.md @@ -0,0 +1,32 @@ +# 1.20.3 模型原生参数与错误保留验收 + +本文件随实施更新;正式部署状态以最终发行身份及下方部署记录为准,不根据浏览器release参数判断运行版本。用户授权实现MODEL-FIDELITY-PLAN并本地上线,基线02cefd0,分支fix/model-fidelity-1.20.3。 + +## 实现范围 + +- Task所属HTTP错误保存前64KiB,界面预览前8000字符;保留code/type/message/param、允许诊断响应头、上游请求/响应ID、原Retry-After与实际模型/接口/物理尝试ID。原文脱敏,截断/中断范围、保存工件及SHA可查,不把中文说明称为原文。 +- SSE错误保留原失败事件及原流,区分上游失败、本地等待截止和协议拒绝;HTTP 200是事件流的传输状态,不代表响应任务成功。保留已报告用量,未完整工具不执行,失败片段不自动重发或切池。 +- 已知额度/消费限制不在同线路重复请求,模型池可按现有规则选其它独立可用成员。429未给明确code时原因保持未确定;Retry-After不截成90秒,预算不足或无效等待头不提前重试。 +- 每个连接(含原连接)有原生参数入口,保存保留当前路由和内存凭据,新Run/实际请求封存参数;旧Run和原失败不回写。Chat输出字段可选max_tokens/max_completion_tokens,Responses沿用max_output_tokens。预算仍由宿主控制。 +- 模型中心的显式检测没有工程Task/Run时仅保留有界诊断预览,并显示原错误;不把检测记录冒充工程工件。真实上游和任意品牌全能力未在本轮验证。 + +| 协议 | 此版实际发送的可选原生字段 | 未接入范围 | +| --- | --- | --- | +| Chat Completions | temperature、top_p、seed、parallel_tool_calls、reasoning_effort、verbosity;可选择输出上限字段 | 任意额外参数、音视频输出、服务端内置工具 | +| Responses | temperature、top_p、parallel_tool_calls、reasoning.effort、text.verbosity;原reasoning.encrypted_content继续项保持 | 任意额外参数、音视频输出、服务端内置工具和额外缓存选项 | + +字段接入代表已核对实际线上的请求构造,不代表所有同协议模型都接受该参数。具体拒绝信息按原上游错误展示,未接入字段在保存/发送前明确拒绝。 + +## 已完成的阶段验证 + +实施中既有诊断/模型池/SSE相关45项通过,错误/原生参数/预算/协议50项通过。首次新增15项14通过、1失败来自测试夹具HTTP status与Responses status混用,修正后的整组已包含在50项中;原失败保留。 + +TypeScript、Vite、手机静态壳及服务端构建通过。Edge两视口六组流程/十截图通过:原生参数保存与刷新、未知字段拒绝、实际HTTP错误及原文SHA下载、请求账本、Responses失败事件/用量/零工具执行,以及显式检测诊断预览。全部请求仅发送到自有本机HTTP/SSE,不使用真实模型或用户工程。 + +截图实际回看后修正SSE错误的上游/本地措辞及实际模型/接口合并;新增API错误详情、转义凭据脱敏及原连接检测参数映射。最终冻结源码验证、随包、旧版到新版升级与正式部署待下方补充,不能以中间结果代替。 + +补强后相关八文件103项通过;HTTP错误读取分支另外补齐已报告用量,随后最终17项新增专项整轮通过。原生参数、上游/本地来源、失败HTTP/SSE用量、JSON转义凭据、旧数据重开和原连接检测均已核对。更广的源码轮仍执行中;本次103项开始于最后用量补强前,最终17项覆盖该补强,不合并冒充同一冻结源码整轮。 + +## 正式部署 + +待完成候选与保留状态升级,当前此处不登记上线成功。 diff --git a/findings.md b/findings.md index 509ba05b..95caa5ea 100644 --- a/findings.md +++ b/findings.md @@ -1,5 +1,8 @@ # 汇总发现 +- 1.20.3已进入实现:HTTP错误原文上限64KiB、界面预览8000字符;保留上游请求ID、code/type/param、允许的诊断头和原Retry-After,额度类错误不重复同线路请求,池内可切换其它可用成员;SSE原事件及原流分开标明,不自动重放片段。原生参数按现有Chat/Responses协议接入,逐连接封存,禁止覆盖消息/工具/预算。实现和部署仍须后续验证,暂不标完成。 +- 浏览器现状核对:1.10已实现静态工程构建的真实Edge交互/DOM/请求/PNG验收,通用内置浏览器此前只有跨阶段能力项,未排具体版本;本次明确为1.22,位于1.21工程依赖与可复现环境之后。 + - 用户提出能力/错误透传。源码确认HTTP错误仅提取message截600字符,缺原code/type和上游request ID;429只按状态判可重试,Retry-After截90秒;SSE错误原片段有工件但诊断通用化。Chat/Responses已有适配不等于全部供应商原生能力。细节与后续门槛见docs/MODEL-FIDELITY-PLAN.md,正式1.20.2未改变。 - 最新结论:1.20.2已完成模型响应等待修复与保留状态部署:单次响应默认300秒、流式无数据120秒,模型中心可调整。111项专项/关联回归、真实本机JSON/SSE各65秒、五组等待UI/五组协议UI及五组随包等待UI通过;实际旧版到新版升级及正式Edge/Electron两视口回看通过。正式PID36552/Provider、17项目/31全部会话/3207记录/6138事件和1761个工件文件原字节保持,仅公开模型中心增加计算出的等待默认值;磁盘配置不回写。本轮验收发起真实模型请求0。 发行源码3b650275ffe6984a1147a39ba1c22dd3a6859a61,原始用户导出/SSE和SQLite备份仅保留本机忽略目录,不进Git。用户确认另一次429来自当前Codex对话,和工作台超时分属不同请求链。 diff --git a/package-lock.json b/package-lock.json index ac1a96f0..f810dded 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "local-agent-workbench", - "version": "1.20.2", + "version": "1.20.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "local-agent-workbench", - "version": "1.20.2", + "version": "1.20.3", "dependencies": { "@babel/parser": "7.29.11", "@peculiar/x509": "3.1.0", diff --git a/package.json b/package.json index 8752cdfd..484b366d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "local-agent-workbench", - "version": "1.20.2", + "version": "1.20.3", "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 7b3e844d..4dceca0b 100644 --- a/progress.md +++ b/progress.md @@ -1,5 +1,17 @@ # 统一执行进度 +## 1.20.3 模型错误和原生参数上线(进行中) + +最终新增17项通过;相关八文件103项通过(该轮开始于最后HTTP错误用量补强前,最后17项单列覆盖补强,不冒充冻结同轮)。HTTP/SSE错误已报告用量、转义凭据、原生参数实际发送和原连接检测均核对。真实Edge六组/十截图通过,已回看宽屏原HTTP正文与390px原SSE事件;当前准备冻结源码、本地提交和不可变候选。更广源码轮仍运行,尚不登记完整通过。 + +真实Edge五组流程/七截图通过并实际回看。截图审查发现SSE错误说明把上游事件混称为本地响应核验,且undefined诊断字段覆盖了实际模型/地址;已修正来源措辞和上下文合并并补断言。探测界面API已返回diagnostic但前端丢弃,也已补到模型中心提示中;没有Task/Run的检测只保存预览,明确标注不造工程工件。首轮完整源码回归开始于此补强前,不作为最终冻结源码验收;后续须按最终来源验证。 + +首轮既有相关回归45/45通过。初次构建因新MJS共享契约缺声明失败,已补native-parameters.d.mts,TypeScript/Vite/手机及服务端构建随后通过。新增15项首轮14通过、1失败:Responses测试夹具把原响应status="completed"误当HTTP状态,修正为显式body后再运行;原失败日志保留。未部署失败候选。 + +界面连接脚本在DiagnosticsPanel的宽泛import锚点处发现多处匹配并停止;此前ModelCenter五处修改已保存,后续读取实际import后用精确补丁继续,未重新执行前面修改。 + +用户授权实现并本地上线;已切fix/model-fidelity-1.20.3,QA隔离数据和本机HTTP/SSE。已接HTTP/SSE错误捕获/诊断、原Retry-After、额度分类和原生参数协议构造,正在补界面和实际验证。正式服务尚未切换。首次检索误用了不存在的FailureNotice.tsx、config.mjs和PowerShell路径通配符;均为只读失败,随后根据实际components.tsx、legacy-import.mjs和目录过滤定位,没有重复原失败。早期批量输出过长截断,后续改为限定行段读取。 + ## 模型能力与错误信息保留讨论 只读核对官方Harness/错误文档与当前源码,明确模型推理、协议能力和产品执行环境的关系;确认HTTP/SSE错误字段及原生参数覆盖缺口。已写MODEL-FIDELITY-PLAN并更新后续计划,尚未实现;正式服务、原用户任务/配置均未操作,没有模型调用。首轮批量文档补丁因findings标题误猜整体拒绝,无文件写入;读取实际标题后修正。一次rg使用PowerShell不展开的路径通配符导致局部查询报错,已改为已存在目录加-g过滤;其余结果实际读取。 diff --git a/scripts/verify-model-fidelity-ui.mjs b/scripts/verify-model-fidelity-ui.mjs new file mode 100644 index 00000000..7488bbe0 --- /dev/null +++ b/scripts/verify-model-fidelity-ui.mjs @@ -0,0 +1,109 @@ +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'; + +const args = process.argv.slice(2); +assert.ok(args.length === 0 || args.length === 2 && args[0] === '--app-root' && path.isAbsolute(args[1])); +const appRoot = args[1] ?? process.cwd(), directory = path.resolve('.qa', 'model-fidelity-ui-' + randomUUID()); +fs.mkdirSync(directory, { recursive: true }); +const disposers = [], t = { after: action => disposers.push(action) }, f = fixture(t), requests = [], screenshots = [], checks = [], errors = []; +let mode = 'quota', browser, page; +const model = http.createServer(async (request, response) => { + const parts = []; for await (const part of request) parts.push(part); requests.push({ route: request.url, body: JSON.parse(Buffer.concat(parts)) }); + if (mode === 'quota') { + response.writeHead(429, { 'Content-Type': 'application/json', 'X-Request-ID': 'owned-upstream-quota-ui', 'Retry-After': '180' }); + response.end(JSON.stringify({ error: { code: 'insufficient_quota', type: 'billing_error', param: 'account', message: 'Owned quota error; owned-ui-private-key' } })); + } else { + response.writeHead(200, { 'Content-Type': 'text/event-stream', 'X-Request-ID': 'owned-upstream-stream-ui' }); + const event = value => 'data: ' + JSON.stringify(value) + '\n\n'; + response.end(event({ type: 'response.created', sequence_number: 1, response: { id: 'resp-owned-ui' } }) + + event({ type: 'response.output_item.added', sequence_number: 2, item: { id: 'fc-owned-ui', call_id: 'owned-ui-tool', type: 'function_call', name: 'propose_file', arguments: '' } }) + + event({ type: 'response.function_call_arguments.delta', sequence_number: 3, item_id: 'fc-owned-ui', delta: '{"path":' }) + + event({ type: 'response.failed', sequence_number: 4, response: { id: 'resp-owned-ui', status: 'failed', error: { code: 'server_error', type: 'api_error', message: 'Owned stream failed' }, usage: { input_tokens: 20, output_tokens: 4 } } })); + } +}); +await new Promise(resolve => model.listen(0, '127.0.0.1', resolve)); +const provider = new Provider(), hub = provider.modelHub(f.store); +let member = hub.upsert({ name: 'Owned UI 模型', model: 'owned-ui-model', baseUrl: 'http://127.0.0.1:' + model.address().port + '/v1', apiKey: 'owned-ui-private-key', requiresKey: true }); +hub.select({ type: 'connection', id: member.id }); f.store.close(); +const host = await launchWorkbench(t, f.data, {}, { appRoot, nodePath: fs.existsSync(path.join(appRoot, 'runtime/node.exe')) ? path.join(appRoot, 'runtime/node.exe') : process.execPath }); +// The test credential is intentionally volatile; set it in this new test host. +member = await host.api('/model-center/connections', { ...member, apiKey: 'owned-ui-private-key' }); +const mark = text => { checks.push(text); console.log('PASS ' + text); }; +async function capture(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') }); } +async function openCenter() { await page.getByRole('button', { name: '打开模型中心', exact: true }).click(); return page.getByRole('dialog', { name: '模型中心', exact: true }); } +async function run(prompt) { + await page.getByLabel('任务内容').fill(prompt); await page.getByRole('button', { name: '发送任务', exact: true }).click(); + let id; await until(async () => { id = (await host.api('/sessions')).find(value => value.title === prompt)?.id; return id && (await host.api('/sessions/' + id)).status === 'failed'; }, 15000); + return host.api('/sessions/' + id); +} +let result; +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.getByLabel('当前项目').selectOption(f.project.id); + let dialog = await openCenter(); const card = dialog.locator('.mc-connection').filter({ has: page.getByRole('heading', { name: 'Owned UI 模型', exact: true }) }); + await card.getByRole('button', { name: '原生参数', exact: true }).click(); + await page.getByLabel('原生参数 JSON', { exact: true }).fill('{"reasoning_effort":"high","temperature":0.4,"parallel_tool_calls":false}'); + await page.getByLabel('输出上限字段', { exact: true }).selectOption('max_completion_tokens'); + await page.getByRole('button', { name: '保存原生参数', exact: true }).click(); await expect(dialog.getByRole('status')).toContainText('原生参数已保存'); + assert.equal(requests.length, 0); await page.reload(); dialog = await openCenter(); + await dialog.locator('.mc-connection').filter({ has: page.getByRole('heading', { name: 'Owned UI 模型', exact: true }) }).getByRole('button', { name: '原生参数', exact: true }).click(); + await expect(page.getByLabel('原生参数 JSON', { exact: true })).toContainText('reasoning_effort'); + await capture('native-desktop'); await page.setViewportSize({ width: 390, height: 844 }); + await page.getByRole('button', { name: '保存原生参数', exact: true }).scrollIntoViewIfNeeded(); + const bounds = await page.getByRole('button', { name: '保存原生参数', exact: true }).boundingBox(); assert.ok(bounds && bounds.x >= 0 && bounds.x + bounds.width <= 390); + assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)); await capture('native-390'); mark('native parameters persist after reload and the narrow form remains usable without calling a model'); + await page.getByLabel('原生参数 JSON', { exact: true }).fill('{"tools":[]}'); await page.getByRole('button', { name: '保存原生参数', exact: true }).click(); + await expect(page.getByRole('form', { name: '原生请求参数' }).getByRole('alert')).toContainText('尚未接入原生参数:tools'); + assert.equal(requests.length, 0); await page.keyboard.press('Escape'); await page.setViewportSize({ width: 1440, height: 1000 }); mark('unsupported field is rejected visibly before any dispatch'); + const first = await run('读取当前项目,HTTP错误原文验收'); assert.equal(requests.length, 1); assert.equal(first.changes.length, 0); + assert.equal(requests[0].body.reasoning_effort, 'high'); assert.equal(requests[0].body.temperature, 0.4); assert.equal(requests[0].body.parallel_tool_calls, false); + assert.ok(requests[0].body.max_completion_tokens > 0); assert.equal(requests[0].body.max_tokens, undefined); + const failureCard = page.locator('.failure-card').last(); await failureCard.getByText('查看上游原文与请求信息', { exact: true }).click(); + await expect(failureCard).toContainText('owned-upstream-quota-ui'); await expect(failureCard).toContainText('insufficient_quota'); await expect(failureCard).toContainText('180 秒'); + assert.ok(!(await failureCard.innerText()).includes('owned-ui-private-key')); await capture('http-error-desktop'); + await failureCard.getByLabel('上游错误原文').scrollIntoViewIfNeeded(); await capture('http-raw-desktop'); + const downloadEvent = page.waitForEvent('download'); await failureCard.getByRole('button', { name: '下载已保存的原文', exact: true }).click(); + const download = await downloadEvent, downloaded = path.join(directory, 'owned-http-error.txt'); await download.saveAs(downloaded); + assert.equal(createHash('sha256').update(fs.readFileSync(downloaded)).digest('hex'), first.failure.upstream.artifactSha256); + await page.setViewportSize({ width: 390, height: 844 }); await failureCard.scrollIntoViewIfNeeded(); await capture('http-error-390'); + assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)); mark('actual HTTP error shows raw fields and original wait, keeps secrets hidden and downloads SHA-verified original at both widths'); + dialog = await openCenter(); await dialog.getByRole('button', { name: '请求账本', exact: true }).click(); + const attempt = dialog.locator('.mc-attempts article').first(); await attempt.getByText('查看上游原文与请求信息', { exact: true }).click(); + await expect(attempt).toContainText('owned-upstream-quota-ui'); await expect(attempt.getByRole('button', { name: '下载实际请求', exact: true })).toBeVisible(); + await capture('ledger-390'); await page.keyboard.press('Escape'); mark('physical request ledger preserves the same error origin and offers the sealed actual request'); + mode = 'stream'; let center = await host.api('/model-center'), current = center.connections.find(value => value.id === member.id); + member = await host.api('/model-center/connections', { ...current, protocol: 'responses', streaming: true, capabilityDeclarations: { ...current.capabilityDeclarations, streaming: 'supported' }, + nativeParameters: { reasoning: { effort: 'medium' }, text: { verbosity: 'high' } }, outputTokenField: 'max_output_tokens' }); + const secondSession = await host.api('/sessions', { projectId: f.project.id }); + await page.evaluate(value => { localStorage.setItem('awb-project', value.projectId); localStorage.setItem('awb-session', value.id); }, secondSession); + await page.reload(); await page.setViewportSize({ width: 1440, height: 1000 }); + const second = await run('读取当前项目,Responses流失败验收'); + assert.equal(requests.length, 2); assert.equal(requests[1].route, '/v1/responses'); assert.deepEqual(requests[1].body.reasoning, { effort: 'medium' }); + assert.equal(second.execution.run.usage.totalTokens, 24); assert.equal(second.changes.length, 0); assert.equal(second.execution.run.usage.requests, 1); + const streamCard = page.locator('.failure-card').last(); await streamCard.getByText('查看上游原文与请求信息', { exact: true }).click(); + await expect(streamCard).toContainText('response.failed'); await expect(streamCard).toContainText('resp-owned-ui'); await expect(streamCard).toContainText('owned-upstream-stream-ui'); + await expect(streamCard).toContainText('流式响应已开始'); await capture('sse-error-desktop'); + await page.setViewportSize({ width: 390, height: 844 }); await streamCard.scrollIntoViewIfNeeded(); await capture('sse-error-390'); + await streamCard.getByLabel('上游错误原文').scrollIntoViewIfNeeded(); await capture('sse-raw-390'); + assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)); assert.deepEqual(errors, []); + mark('Responses failed event retains original identity and reported use at both widths; partial tool is never dispatched or retried'); + mode = 'quota'; + await until(async () => (await host.api('/model-center')).connections.find(value => value.id === member.id).status === 'configured'); + dialog = await openCenter(); + await dialog.locator('.mc-connection').filter({ has: page.getByRole('heading', { name: 'Owned UI 模型', exact: true }) }).getByRole('button', { name: '验证响应(调用模型)', exact: true }).click(); + await expect(dialog.locator('.mc-notice')).toContainText('额度或消费限制'); + await dialog.locator('.mc-notice').getByText('查看上游原文与请求信息', { exact: true }).click(); + await expect(dialog.locator('.mc-notice')).toContainText('owned-upstream-quota-ui'); + await expect(dialog.locator('.mc-notice')).toContainText('仅保留以上诊断预览'); + assert.equal(requests.length, 3); assert.deepEqual(errors, []); await capture('probe-error-390'); + mark('explicit synthetic probe also shows the API diagnostic and labels its preview-only retention without inventing a Task artifact'); + result = { success: true, appRoot, checks, screenshots, errors, modelRequests: requests.length, realModelRequests: 0 }; +} catch (error) { if (page) await capture('failure').catch(() => {}); result = { success: false, appRoot, error: error.stack, checks, screenshots, errors, realModelRequests: 0 }; throw error; } +finally { fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2)); console.log(JSON.stringify({ success: result.success, directory, checks: checks.length, screenshots: screenshots.length })); + await browser?.close(); await new Promise(resolve => { model.closeAllConnections(); model.close(resolve); }); for (const action of disposers.reverse()) await action(); } diff --git a/src/client/DiagnosticsPanel.tsx b/src/client/DiagnosticsPanel.tsx index 54084f7d..28b43f6e 100644 --- a/src/client/DiagnosticsPanel.tsx +++ b/src/client/DiagnosticsPanel.tsx @@ -1,6 +1,7 @@ import { Activity, LoaderCircle, RotateCw } from 'lucide-react'; import type { RuntimeDiagnostics } from './types'; import { Status } from './components'; +import { ModelErrorDetails } from './ModelErrorDetails'; export function DiagnosticsPanel({ value, busy, onRefresh }: { value: RuntimeDiagnostics | null; busy: boolean; onRefresh: () => void }) { if (!value) return
{busy ? '正在读取本机执行记录…' : '诊断记录暂时不可用,请刷新重试。'}
; @@ -16,7 +17,7 @@ export function DiagnosticsPanel({ value, busy, onRefresh }: { value: RuntimeDia
当前项目上次核对
{value.projectCache.latest ? new Date(value.projectCache.latest.checkedAt).toLocaleString('zh-CN') : '本次进程尚未检索'}
{value.projectCache.latest &&

{value.projectCache.latest.reusedFiles} 份解析材料复用,{value.projectCache.latest.parsedFiles} 份重新解析;来源{value.projectCache.latest.sourceVerified ? '已核对' : '范围不完整'}。

}

在工程「索引 → 解析缓存」管理开关与清除。此处仅显示派生缓存状态,不触发工程检索或模型请求。

{value.projectCache.error &&

{value.projectCache.error}

}} - {failure &&

最近的错误记录

{failure.source === 'model_connection' ? '模型服务请求' : '工作台任务'}
{failure.title}

{failure.message}

{failure.detail &&

{failure.detail}

}{failure.occurredAt && {new Date(failure.occurredAt).toLocaleString('zh-CN')}}{failure.suggestion &&

{failure.suggestion}

}
} + {failure &&

最近的错误记录

{failure.source === 'model_connection' ? '模型服务请求' : '工作台任务'}
{failure.title}

{failure.message}

{failure.occurredAt && {new Date(failure.occurredAt).toLocaleString('zh-CN')}}{failure.suggestion &&

{failure.suggestion}

}
} {!!value.session?.changes.length &&

文件改动的实际状态

{value.session.changes.map(change =>
{change.path}
)}
} {!!value.session?.recentTools.length &&

近期工具结果

{value.session.recentTools.slice(-8).map((tool, index) =>
{tool.tool}{tool.exitCode !== null && 退出码 {tool.exitCode}}
{tool.outputExcerpt || '没有文本输出。'}
)}
} ; diff --git a/src/client/ModelCenter.css b/src/client/ModelCenter.css index c60cac65..544e01c2 100644 --- a/src/client/ModelCenter.css +++ b/src/client/ModelCenter.css @@ -20,3 +20,5 @@ .mc-stream-receipt .button { margin-top: 8px; } .mc-editor > p { color: #475b73; font-size: 13px; line-height: 1.8; margin: 12px 0; } .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} diff --git a/src/client/ModelCenter.tsx b/src/client/ModelCenter.tsx index 13aecde8..56ef751e 100644 --- a/src/client/ModelCenter.tsx +++ b/src/client/ModelCenter.tsx @@ -1,14 +1,16 @@ 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 } from './types'; +import type { Config, ModelSelection, RuntimeFailure } from './types'; import './ModelCenter.css'; import { ModelWaitSettings, type WaitSettings } from './ModelWaitSettings'; +import { NativeParameters } from './NativeParameters'; +import { ModelErrorDetails } from './ModelErrorDetails'; type Connection = { id: string; name: string; brand: string; protocol: string; baseUrl: string; model: string; enabled: boolean; revision: number; hasKey: boolean; - requiresKey: boolean; 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 } }; + requiresKey: boolean; 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 = { 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 = { 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 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 }[]; @@ -26,10 +28,12 @@ export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Co const [tab, setTab] = useState('connections'); const [draft, setDraft] = useState(initial); const [editing, setEditing] = useState(false), [key, setKey] = useState(''); + const [nativeTarget, setNativeTarget] = useState(null); const [persistKey, setPersistKey] = useState(false), [persistImports, setPersistImports] = useState(false); const [credentialView, setCredentialView] = useState(null), [credentialKey, setCredentialKey] = useState(''), [credentialTarget, setCredentialTarget] = useState(''); const [pool, setPool] = useState(emptyPool), [poolEditing, setPoolEditing] = useState(false); const [working, setWorking] = useState(false), [notice, setNotice] = useState(''); + const [noticeFailure, setNoticeFailure] = useState(null); const [probeScopes, setProbeScopes] = useState>({}); const [operations, setOperations] = useState(null), [autoInspect, setAutoInspect] = useState(false); const [importPath, setImportPath] = useState(''), [importSource, setImportSource] = useState('ccswitch'); @@ -39,9 +43,10 @@ export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Co const tabsRef = useRef(null); async function refresh() { const marker = ++generation.current; const result = await api
('/model-center'); if (alive.current && marker === generation.current) setView(result); } async function act(action: () => Promise) { - setWorking(true); setNotice(''); + setWorking(true); setNotice(''); setNoticeFailure(null); try { await action(); if (alive.current) { await refresh(); if (credentialView) await refreshCredentials(); } } - catch (cause) { if (alive.current) setNotice(cause instanceof Error ? cause.message : '操作未完成,请刷新核对。'); } + catch (cause) { if (alive.current) { setNotice(cause instanceof Error ? cause.message : '操作未完成,请刷新核对。'); + if (cause && typeof cause === 'object' && 'diagnostic' in cause && cause.diagnostic) setNoticeFailure(cause.diagnostic as RuntimeFailure); } } finally { if (alive.current) setWorking(false); } } async function inspect(offset?: number) { const value = await api('/operations' + (offset === undefined ? '' : '?artifactOffset=' + offset)); if (alive.current) setOperations(value); } @@ -65,7 +70,7 @@ export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Co - {notice &&
{notice}
} + {notice &&
{notice}{noticeFailure && }
} {busy &&

有任务正在执行;连接可停用,其他配置请在任务结束后修改。

} {!view ?

正在读取实际连接状态…

:
{tab === 'waits' && void act(async () => { @@ -83,9 +88,9 @@ export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Co {value.id !== 'legacy-default' && } - + )}
- {editing &&
{ event.preventDefault(); void act(async () => { await api('/model-center/connections', { ...draft, ...(key ? { apiKey: key } : {}), ...(persistKey ? { persistKey: true } : {}) }); if (alive.current) { setKey(''); setEditing(false); setNotice(persistKey ? '连接与本机加密凭据已一起保存。' : '连接已保存。'); } }); }}> + {nativeTarget && setNativeTarget(null)} onSave={async input => { await act(async () => { const result = await api<{ config: Config }>("/model-center/native-parameters", input); if (alive.current) { onConfig(result.config); setNativeTarget(null); setNotice("原生参数已保存;新任务按所选协议发送,旧请求保持原记录。"); } }); }} />}{editing && { event.preventDefault(); void act(async () => { await api('/model-center/connections', { ...draft, ...(key ? { apiKey: key } : {}), ...(persistKey ? { persistKey: true } : {}) }); if (alive.current) { setKey(''); setEditing(false); setNotice(persistKey ? '连接与本机加密凭据已一起保存。' : '连接已保存。'); } }); }}>

{draft.id ? '编辑模型连接' : '添加模型连接'}

@@ -141,7 +146,7 @@ export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Co
模型池成员与权重{view.connections.map(connection => { const member = pool.members.find(value => value.connectionId === connection.id); return ; })}
} } - {tab === 'attempts' && <>

请求账本

最近100次物理请求;最多保存1000次。未知用量保持未知。

{view.attempts.length} 条记录
{!view.attempts.length &&

当前没有模型中心请求。选择连接或模型池执行任务后,实际尝试会保存在这里。

}
{view.attempts.map(value =>
{states[value.status]}{value.model}

{view.connections.find(connection => connection.id === value.connectionId)?.name || '未派发'} · {value.protocol === 'responses' ? 'Responses' : value.protocol ? 'Chat Completions' : '能力筛选'}{value.streaming ? ' · 流式' : ''} · {value.ordinal ? '尝试 ' + value.ordinal : '未发送'} · {value.usageStatus === 'reported' ? `${value.usage?.prompt_tokens ?? '?'} 输入 / ${value.usage?.completion_tokens ?? '?'} 输出 tokens` : value.usageStatus === 'not_dispatched' ? '未产生请求用量' : '用量未知'}

Run {value.runId}{value.stream &&

{value.stream.terminal ? "响应完整终结" : "响应未完整,片段保留待核对"} · 已接收 {value.stream.bytes.toLocaleString()} bytes · {value.stream.frames} 个事件{value.stream.capturedBytes !== undefined && value.stream.capturedBytes < value.stream.bytes ? " · 仅保存上限内片段" : ""}

原流 SHA256 {value.stream.sha256}{value.responseSha256 && 工件 SHA256 {value.responseSha256}{value.responseRedacted ? "(已脱敏)" : ""}}{value.sessionId && value.responseArtifactId && }
}{value.reason &&

{value.reason}

}{!!value.rejections?.length &&

{value.rejections.map(item => item.connectionName + ':' + (capabilityLabels[item.capability] ?? item.capability) + ' · ' + item.reason).join(';')}

}
)}
} + {tab === 'attempts' && <>

请求账本

最近100次物理请求;最多保存1000次。未知用量保持未知。

{view.attempts.length} 条记录
{!view.attempts.length &&

当前没有模型中心请求。选择连接或模型池执行任务后,实际尝试会保存在这里。

}
{view.attempts.map(value =>
{states[value.status]}{value.model}

{view.connections.find(connection => connection.id === value.connectionId)?.name || '未派发'} · {value.protocol === 'responses' ? 'Responses' : value.protocol ? 'Chat Completions' : '能力筛选'}{value.streaming ? ' · 流式' : ''} · {value.ordinal ? '尝试 ' + value.ordinal : '未发送'} · {value.usageStatus === 'reported' ? `${value.usage?.prompt_tokens ?? '?'} 输入 / ${value.usage?.completion_tokens ?? '?'} 输出 tokens` : value.usageStatus === 'not_dispatched' ? '未产生请求用量' : '用量未知'}

Run {value.runId}{value.stream &&

{value.stream.terminal ? "响应完整终结" : "响应未完整,片段保留待核对"} · 已接收 {value.stream.bytes.toLocaleString()} bytes · {value.stream.frames} 个事件{value.stream.capturedBytes !== undefined && value.stream.capturedBytes < value.stream.bytes ? " · 仅保存上限内片段" : ""}

原流 SHA256 {value.stream.sha256}{value.responseSha256 && 工件 SHA256 {value.responseSha256}{value.responseRedacted ? "(已脱敏)" : ""}}{value.sessionId && value.responseArtifactId && }
}{value.reason &&

{value.reason}

}{value.diagnostic && }{!value.diagnostic && value.upstreamResponse?.requestId &&

上游请求 ID:{value.upstreamResponse.requestId}

}{value.requestArtifactId && value.sessionId && }{!!value.rejections?.length &&

{value.rejections.map(item => item.connectionName + ':' + (capabilityLabels[item.capability] ?? item.capability) + ' · ' + item.reason).join(';')}

}
)}
} {tab === 'imports' && <>

已有配置导入

先预览来源和模型,再导入。原客户端配置保持原样。

{view.imports.length > 0 && <>

已登记来源

{view.imports.map(value =>
{value.source}{value.path}{value.enabled ? '每分钟检查' : '自动同步已关闭'}{value.lastCheckedAt &&

最近检查 {new Date(value.lastCheckedAt).toLocaleString()}

}{value.lastError &&

{value.lastError}

}{!!value.lastResult?.conflicts?.length &&

有 {value.lastResult.conflicts.length} 项与手动修改冲突,已保留工作台中的修改。

}
)}} {discovery.map(value =>
{value.source}{value.path || '当前版本尚无可发现的配置路径'}{value.available ? value.supported ? '可预览' : '当前不支持' : '未发现'}{value.detail &&

{value.detail}

}
)} diff --git a/src/client/ModelErrorDetails.css b/src/client/ModelErrorDetails.css new file mode 100644 index 00000000..b6e566b5 --- /dev/null +++ b/src/client/ModelErrorDetails.css @@ -0,0 +1,9 @@ +.model-error-details{font-size:12px;line-height:1.7;margin-top:10px;min-width:0;color:#344e40} +.model-error-details summary{cursor:pointer;font-weight:600;color:#365d48;padding:6px 0} +.model-error-details summary:focus-visible,.model-error-details pre:focus-visible{outline:2px solid #4c795e;outline-offset:3px} +.model-error-details dl{display:grid;grid-template-columns:minmax(84px,128px) minmax(0,1fr);gap:6px 14px;margin:12px 0} +.model-error-details dt{color:#56695b}.model-error-details dd{margin:0;min-width:0;overflow-wrap:anywhere} +.model-error-details pre{max-height:280px;max-width:100%;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;padding:12px;background:#f2f4f1;border:1px solid #d5ded5;border-radius:5px;font-size:12px;line-height:1.7;color:#2c4134} +.model-error-caption,.model-error-hash{font-size:11px;overflow-wrap:anywhere;color:#526556}.model-error-hash code{font-size:10px} +.model-error-details .button{margin:6px 0;max-width:100%;min-height:38px} +@media(max-width:560px){.model-error-details dl{grid-template-columns:1fr;gap:2px}.model-error-details dd{margin-bottom:7px}.model-error-details pre{padding:9px}} diff --git a/src/client/ModelErrorDetails.tsx b/src/client/ModelErrorDetails.tsx new file mode 100644 index 00000000..75dcf2ff --- /dev/null +++ b/src/client/ModelErrorDetails.tsx @@ -0,0 +1,46 @@ +import { useState } from 'react'; +import type { RuntimeFailure } from './types'; +import { downloadArtifact } from './api'; +import './ModelErrorDetails.css'; + +const decisions: Record = { retry_after_wait: '按等待时间重试', stream_not_replayed: '流式响应已开始,保留原片段并停止自动重发', + not_retryable: '该错误不在同一线路自动重试', attempt_limit: '达到本次尝试上限', wait_budget: '剩余等待预算不足,保持上游建议时间并结束本次请求' }; + +export function ModelErrorDetails({ failure }: { failure: RuntimeFailure }) { + const upstream = failure.upstream; + const requestId = upstream?.requestId ?? failure.upstreamRequestId; + const [notice, setNotice] = useState(''), [busy, setBusy] = useState(false); + const origin = failure.origin === 'upstream' ? '上游模型服务' : failure.origin === 'local' || failure.source === 'workbench' ? '工作台本地' : '旧记录未保存具体层级'; + return
{upstream ? '查看上游原文与请求信息' : '查看错误详情'} +
错误来源
{origin}
+ {failure.model && <>
实际模型
{failure.model}
} + {failure.endpoint && <>
实际接口
{failure.endpoint}{failure.route}
} + {requestId && <>
上游请求 ID
{requestId}
} + {upstream?.responseId && <>
上游响应 ID
{upstream.responseId}
} + {failure.wireAttemptId && <>
本地物理尝试 ID
{failure.wireAttemptId}
} + {upstream?.code && <>
上游 code
{upstream.code}
} + {upstream?.type && <>
上游 type
{upstream.type}
} + {upstream?.param && <>
上游参数位置
{upstream.param}
} + {upstream?.eventType && <>
上游事件
{upstream.eventType}
} + {upstream?.reason && <>
上游结束原因
{upstream.reason}
} + {upstream?.retryAfter !== null && upstream?.retryAfter !== undefined && <>
原 Retry-After
{upstream.retryAfter}{upstream.retryAfterMs !== null && upstream.retryAfterMs !== undefined ? ' · ' + upstream.retryAfterMs / 1000 + ' 秒' : ' · 未能解析,已停止自动重试'}
} + {failure.limitReason === 'unspecified' && <>
限额类型
上游未提供明确原因
} + {failure.retryDecision && <>
重试处理
{decisions[failure.retryDecision] ?? failure.retryDecision}
} +
+ {!upstream && failure.detail &&

{failure.detail}

} + {upstream?.rawPreview !== undefined && <>

上游原文{upstream.scope === 'sse-event' ? ' · 失败事件' : ' · 响应正文'}{upstream.capture?.redacted ? ' · 已脱敏' : ''}{upstream.previewTruncated ? ' · 此处显示前 8000 字符' : ''}

+
{upstream.rawPreview || '(空响应)'}
+ {upstream.capture &&

已接收 {upstream.capture.receivedBytes.toLocaleString()} 字节,保留前 {upstream.capture.capturedBytes.toLocaleString()} 字节。{upstream.capture.complete ? '该范围完整接收。' : upstream.capture.truncated ? '已达到保存上限,仅保留前缀;完整长度未知。' : '接收中断,原文可能不完整。'}{upstream.artifactScope === 'sse-stream' ? '下载文件包含已保存的整段事件流。' : ''}

} + } + {!!upstream?.shortenedFields?.length &&

部分诊断字段已缩短,详见保存的原文。

} + {upstream?.capture?.retention === 'preview-only' &&

此请求未绑定工程任务,仅保留以上诊断预览;完整原文未归档为任务工件。

} + {upstream?.artifactSha256 &&

工件 SHA-256 {upstream.artifactSha256}

} + {upstream?.artifactId && upstream.sessionId && } + {notice &&

{notice}

} +
; +} diff --git a/src/client/NativeParameters.tsx b/src/client/NativeParameters.tsx new file mode 100644 index 00000000..7cdefa73 --- /dev/null +++ b/src/client/NativeParameters.tsx @@ -0,0 +1,26 @@ +import { useEffect, useRef, useState } from 'react'; +import { nativeParameterSettings } from '../shared/contracts/native-parameters.mjs'; + +export type NativeConnection = { id: string; revision: number; name: string; protocol: string; nativeParameters?: Record; outputTokenField?: string }; +export function NativeParameters({ connection, busy, onCancel, onSave }: { connection: NativeConnection; busy: boolean; onCancel: () => void; + onSave: (input: { id: string; revision: number; nativeParameters: Record; outputTokenField: string }) => Promise }) { + const [text, setText] = useState(JSON.stringify(connection.nativeParameters ?? {}, null, 2)); + const [field, setField] = useState(connection.outputTokenField ?? (connection.protocol === 'responses' ? 'max_output_tokens' : 'max_tokens')); + const [error, setError] = useState(''); + const form = useRef(null); + useEffect(() => { form.current?.scrollIntoView({ block: 'nearest' }); }, []); + return
{ + event.preventDefault(); setError(''); + try { const settings = nativeParameterSettings(connection.protocol, JSON.parse(text), field); await onSave({ id: connection.id, revision: connection.revision, ...settings }); } + catch (cause) { setError(cause instanceof Error ? cause.message : '参数格式无效。'); } + }}> +

{connection.name} · 原生请求参数

+

参数按所选协议原字段发送,并封存在实际请求中。具体模型是否接受这些选项,以服务响应为准;未填写的选项采用上游默认值。

+ +

数值沿用当前任务和连接的输出预算,不允许原生参数覆盖预算、消息、工具或接口。

+