Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
docs(images): complete localized specification coverage
Jack9f034cc29f13
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 89335766b..b2e86fa85 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -14265,7 +14265,7 @@ the latest destination. These assertions measure work counts, not device FPS.Attempt the tool in a durable Plan session and verify no HTTP request occurs.- **Expected:** One image binding persists without changing the chat default;generated files, edit sources and transcript references survive restart.- Images render in chat; unconfigured errors navigate to AI settings.+ Images render in chat; unconfigured errors navigate to Models settings.- **Specs:** 03-runtime/21-image-generation; 03-runtime/13-model-catalog-and-selection.- **Acceptance:** Configured image generation/editing, safe cancellation and persistence.- **Milestone:** Post-MVP.diff --git a/docs/spec/NAV.md b/docs/spec/NAV.mdindex 6d92dc608..e085bacfa 100644--- a/docs/spec/NAV.md+++ b/docs/spec/NAV.md@@ -42,6 +42,7 @@- [18-line-anchored-edit-contract.md](03-runtime/18-line-anchored-edit-contract.md)- [19-remote-agent-control-protocol.md](03-runtime/19-remote-agent-control-protocol.md)- [20-speech.md](03-runtime/20-speech.md)+- [21-image-generation.md](03-runtime/21-image-generation.md)## 4. UX- [README.md](04-ux/README.md)diff --git a/docs/zh-CN/spec/03-runtime/02-agent-runtime.md b/docs/zh-CN/spec/03-runtime/02-agent-runtime.mdindex 9e03f3076..026d712c1 100644--- a/docs/zh-CN/spec/03-runtime/02-agent-runtime.md+++ b/docs/zh-CN/spec/03-runtime/02-agent-runtime.md@@ -194,6 +194,7 @@ not temporary retry activity. See the English source section 5d and ADR 0206.网络/瞬时故障(含 `PROVIDER_RATE_LIMITED`)的次数上限。退避、`Retry-After`、可见重试状态和停止路径不变。不可重试错误、上下文恢复、压缩、工具执行和一次性补全仍走原有有界预算。开启后可能在用户停止回合前持续消耗 API 用量。+设置读取对此开关返回明确布尔值:缺省或关闭均规范化为 `false`。修改并保存其他设置不得因此校验失败或启用重试;非布尔值写入仍被拒绝。当 429 预算耗尽时,最终的助手错误和生命周期 `error` 只发出一次。提供程序故障在可用时于 `AppError.details` 中携带有界诊断:diff --git a/docs/zh-CN/spec/03-runtime/03-tools-and-permissions.md b/docs/zh-CN/spec/03-runtime/03-tools-and-permissions.mdindex 9e23a01bd..b141878b3 100644--- a/docs/zh-CN/spec/03-runtime/03-tools-and-permissions.md+++ b/docs/zh-CN/spec/03-runtime/03-tools-and-permissions.md@@ -566,3 +566,7 @@ sidecar 不附加覆盖,委托使用会话的有效权限模式;因此父会- 命令允许列表/拒绝列表- 空运行模式- 预览后应用补丁++## 图片生成与编辑++`GenerateImages` 是仅供 Agent 使用的高风险能力,可信桌面执行请求前必须由 host-core 授权。即使处于 Auto,Plan/Goal 仍被拒绝。取消、限制和结果语义见[图片生成规格](/zh-CN/spec/03-runtime/21-image-generation)。diff --git a/docs/zh-CN/spec/03-runtime/13-model-catalog-and-selection.md b/docs/zh-CN/spec/03-runtime/13-model-catalog-and-selection.mdindex 28d0cf990..ad0ee8dba 100644--- a/docs/zh-CN/spec/03-runtime/13-model-catalog-and-selection.md+++ b/docs/zh-CN/spec/03-runtime/13-model-catalog-and-selection.md@@ -329,3 +329,7 @@ Electron 使用本地 `models.dev` 记录装饰缓存和新发现的模型行。- [ ] 来源标记能在提供商保存/读取往返后保留,未标记记录仍可正常使用- [ ] 紧凑上限文本不会高于已发布值,1M 附近的相邻窗口保持可区分(`1M` / `1.05M` / `1.1M`),且永远不会渲染出大于等于 1000 的 `K` 尾数++## 生图模型绑定++默认对话模型下方有独立的生图模型行。模型高级设置可指定唯一绑定;保存服务商表单才生效,取消丢弃选择,替换不会改变对话默认值。工具和批量合约见[图片生成与编辑](/zh-CN/spec/03-runtime/21-image-generation)。diff --git a/docs/zh-CN/spec/03-runtime/21-image-generation.md b/docs/zh-CN/spec/03-runtime/21-image-generation.mdnew file mode 100644index 000000000..791c021c3--- /dev/null+++ b/docs/zh-CN/spec/03-runtime/21-image-generation.md@@ -0,0 +1,45 @@+# 图片生成与编辑++> **翻译说明:** 本页对应 [英文源规格](/spec/03-runtime/21-image-generation)。代码、协议字段和标识符保持原文;如有歧义,以英文版本为准。++桌面通过可选的 `AppSettings.imageGeneration` 绑定唯一生图模型,包含 `providerId` 和 `modelId`。`null` 清除绑定,缺省表示未配置。host-core 使用现有设置存储校验并持久化,无需数据库版本升级。绑定独立于默认对话模型,引用已启用的 API-key 或免认证服务商及其已配置模型。++## 配置++模型高级设置提供“设为生图模型”。只有保存服务商表单后选择才生效,取消不改变设置;保存不会替换默认对话模型。默认模型下方同一面板中的生图模型行只展示摘要,服务商和模型字号与默认模型一致,两行间距为 12px。摘要不提供更改或清除操作;替换通过服务商高级设置完成。绑定缺失、服务商停用、缺少凭据或模型移除时仅显示“暂不可用”。OAuth 账户不适用,也不会自动回退。++所选服务商与模型组合从默认对话模型选择器、服务商快速设为默认操作和 Composer 模型菜单中排除。其他服务商的同名模型独立保留。已有会话绑定和历史不改写;仍绑定生图模型的会话必须选择对话模型才能发送,运行时也会在推理前拒绝该绑定。++## Agent 合约++`GenerateImages({items: [{prompt, count?, images?}]})` 仅供 Agent 模式使用。`count` 默认为 1,支持不同提示词和同一提示词的多个变体,总输出为 1–10 张。每项可通过 `images` 提供 1–4 张本地参考图,之前生成的路径可用于迭代编辑。提示词最多 32,000 个字符;不支持或超限输入直接拒绝,不截断。Plan 和 Goal 不得执行此工具。++内置 `pi-desktop/imagegen` skill 可在普通会话中发现,并通过现有 Skill 工具加载。它说明提示词、批量、参考图编辑、保留原图、部分失败处理和项目素材交付,不授予权限,也不携带凭据。++可信桌面桥先使用相同身份、参数和权限范围调用 host-core `tools.execute`。host-core 应用现有高风险工具策略,仅返回授权结果;获得批准后桥才执行图片服务。宿主授权审计与 sidecar 的实际工具结果分开记录。取消会传递给待批准操作和网络请求;宿主断开或 sidecar 销毁时中止本地工作。++## OpenAI Images 适配器++仅支持 OpenAI-compatible Images。根地址自动补充 `/v1`,显式路径前缀保留。生成通过 `POST images/generations` 发送 `model`、`prompt` 和 `n: 1`;编辑通过 `POST images/edits` 发送 multipart 图片、提示词、模型和 `n: 1`。不包含浏览器蒙版编辑器。服务商可能只支持生成;编辑错误直接报告,不悄悄改为生成或切换模型。++对于精确匹配的 DALL-E 2/3 模型 ID,生成请求显式发送 `response_format: b64_json`,支持的 DALL-E 编辑请求使用同名表单字段。GPT Image 和未知兼容模型省略该参数。编辑使用二进制 multipart 上传,单图字段为 `image`,多图为 `image[]`,Content-Type boundary 由传输层生成。++每批请求在分发前快照模型绑定和服务商,使用两个工作线程,并按输入顺序返回结果。每张输出的请求预算为 180 秒。请求不会自动重试;认证失败停止队列工作。取消停止队列并中止活动 HTTP 请求,但不能保证上游停止处理或收费。已完成的输出文件保留。++每次响应接受一张 Base64 图片或 HTTPS 图片地址。JSON 和下载响应体有大小限制;图片最多 16 MiB,只接受 PNG、JPEG、WebP 文件签名。下载使用已校验并固定的公网 DNS 地址,拒绝重定向和私网目标,也不携带服务商请求头。++编辑输入必须在 realpath 校验后属于会话项目、该会话 scratch 目录或附件存储。每组参考图最多 32 MiB,每批输入缓存预算为 64 MiB。凭据不会进入渲染进程或工具结果。++## 结果与恢复++每项结果记录序号、状态(`succeeded`、`failed`、`cancelled`)、成功路径/MIME 类型或安全错误码。输出以唯一文件名保存至会话 scratch,编辑不覆盖原图。工具结果和对话只保留文件引用,不保存 Base64;预览复用现有受限图片读取和文件查看器。++本地工具抛出的稳定 `errorCode` 跨真实 sidecar RPC 边界保留,独立于普通结构化工具失败结果。现有 RPC code、message 和 data 保留,不序列化任意 Error 属性;sidecar 接收端同时提供错误码与 data。++部分成功时仍展示成功图片和逐项失败。未配置返回结构化错误及“设置 → 模型”跳转操作。会话重载或重启后同一引用仍可显示。图片结果和配置操作显示在可折叠过程详情之外,展开工具详情不会重复图片列表。++生成文件绝对路径(包括 Windows 盘符路径)的 Markdown 图片引用通过现有受限宿主图片读取接口解析。URL 清理仍启用,宿主继续拒绝允许的工作区、scratch 和附件根目录之外的文件。++验证:`node scripts/e2e-image-generation.mjs` 覆盖宿主、stdio、HTTP 和存储;`node scripts/e2e-image-generation-ui.mjs` 使用 API 边界夹具覆盖真实 React/Chromium 交互。单元及服务测试覆盖限制、取消、部分失败、认证、超时、不安全路径和受限下载。++`node scripts/e2e-image-chat.mjs` 在隔离桌面中使用本地模型/图片 HTTP 夹具,覆盖相邻默认设置、Composer 提交、批量结果、引用生成文件编辑、收起详情和配置跳转。真实接口验证通过 `scripts/test-image-generation-live.mjs` 显式启用,仅限一次生成和一次编辑,不属于默认测试命令。diff --git a/docs/zh-CN/spec/03-runtime/README.md b/docs/zh-CN/spec/03-runtime/README.mdindex ba72d2a20..42e009c29 100644--- a/docs/zh-CN/spec/03-runtime/README.md+++ b/docs/zh-CN/spec/03-runtime/README.md@@ -25,3 +25,5 @@| [18-line-anchored-edit-contract.md](/zh-CN/spec/03-runtime/18-line-anchored-edit-contract) | 按行锚定的 Edit 合约 || [19-remote-agent-control-protocol.md](/zh-CN/spec/03-runtime/19-remote-agent-control-protocol) | 远程 Agent 控制协议 || [20-speech.md](/zh-CN/spec/03-runtime/20-speech) | 宿主语音(转写/朗读) |++- [图片生成与编辑](/zh-CN/spec/03-runtime/21-image-generation)diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex b736bd847..9a68c4ab5 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -8263,6 +8263,36 @@ the latest destination. These assertions measure work counts, not device FPS.default.- **Status:** Contract-covered; no end-to-end driver waits out a real 70s call.+### E2E-IMAGES-desktop-conversation++- **Preconditions:** Isolated desktop profile and workspace, built image feature,+ local chat and OpenAI Images HTTP fixtures; no live provider credentials.+- **Steps:** Open Models settings; verify the conversation and image defaults+ share a compact panel. Submit a two-image request through the composer, then+ edit the first output through a follow-up message. Collapse tool details.+ Clear the binding and follow the visible configuration action back to Models.+- **Expected:** A 12px default-row gap, decoded image previews outside collapsed+ process details, multipart source upload for editing, preserved originals,+ and no image HTTP request while unconfigured.+- **Settings interactions:** The image summary has no Change/Clear buttons and+ matches the default model's provider/model text styles. Select another+ provider's image model in Advanced and save; the summary changes while the+ chat default stays unchanged. Missing/disabled bindings show only Currently+ unavailable. Covered in `scripts/e2e-image-generation-ui.mjs`.+- **Conversation selection:** The selected image provider/model is absent from+ default and Composer candidates. Other providers retain same-ID models. An+ existing session pinned to the image binding is rejected before inference.+- **Transport contracts:** Real stdio reverse RPC retains a thrown local image+ error's stable code in the production ParentHostProxy. Local HTTP tests check+ single/multiple binary multipart fields and boundaries, DALL-E `b64_json`+ requests, GPT Image parameter omission, bounded responses, and rejection of+ more than four references before I/O. These are protocol tests, not official+ provider account/live compatibility certification.+- **Status:** Automated in `node scripts/e2e-image-chat.mjs`; optional screenshots+ use `PI_IMAGE_CHAT_EVIDENCE_DIR`. The images are deterministic raster fixtures,+ not evidence of real-model quality or provider compatibility.++### E2E-SCHEDULED-desktop-automation-lifecycle- **前提:** 独立桌面配置、构建后的任务候选版本、本地 SSE 模拟模型;不使用真实@@ -8398,6 +8428,29 @@ the latest destination. These assertions measure work counts, not device FPS.- **状态:** 运行时层已自动化;无 UI 驱动读取插件页的错误文本。+### E2E-IMAGE-generation-and-editing++- **Preconditions:** Built task candidate containing latest origin/main; isolated+ host data directory, local image HTTP fixture, no production credentials.+- **Steps:** Choose a model in Advanced, cancel and verify no change; save and+ replace it through another provider's Advanced settings. Clear the binding via+ the test settings API to verify recovery. Generate same-prompt variants and distinct images,+ edit a generated image, inspect partial failures, then restart the host/session.+ Attempt the tool in a durable Plan session and verify no HTTP request occurs.+- **Expected:** One image binding persists without changing the chat default;+ generated files, edit sources and transcript references survive restart.+ Images render in chat; unconfigured errors navigate to Models settings.+- **Specs:** 03-runtime/21-image-generation; 03-runtime/13-model-catalog-and-selection.+- **Acceptance:** Configured image generation/editing, safe cancellation and persistence.+- **Milestone:** Post-MVP.+- **Status:** Automated by `scripts/e2e-image-generation.mjs` and+ `scripts/e2e-image-generation-ui.mjs`; backend test uses real Rust/stdio/HTTP/files,+ UI test uses real Chromium and production components with API-boundary fixtures.++| Scenario | Acceptance | Specification | Automation |+| --- | --- | --- | --- |+| E2E-IMAGE-generation-and-editing | Image capability and recovery | 03-runtime/21-image-generation | Host and UI suites above |+#### E2E-CHAT-parenthesized-url:用户消息中的完整网址- **步骤**:在用户消息中发送 `https://en.wikipedia.org/wiki/React_(software)` 并点击链接,再验证正文用圆括号包裹该网址、网址后跟句号及紧接另一链接或文件引用的情况。diff --git a/docs/zh-CN/spec/NAV.md b/docs/zh-CN/spec/NAV.mdindex 80e36552d..d51b3af11 100644--- a/docs/zh-CN/spec/NAV.md+++ b/docs/zh-CN/spec/NAV.md@@ -45,6 +45,7 @@- [18-line-anchored-edit-contract.md](/zh-CN/spec/03-runtime/18-line-anchored-edit-contract)- [19-remote-agent-control-protocol.md](/zh-CN/spec/03-runtime/19-remote-agent-control-protocol)- [20-speech.md](/zh-CN/spec/03-runtime/20-speech)+- [21-image-generation.md](/zh-CN/spec/03-runtime/21-image-generation)## 4. 用户体验- [README.md](/zh-CN/spec/04-ux/README)