Go implementation of DeepSeek Harness and self-hosted personal agent.
Go
feat(plugins): add Gemini API CLI integration
xycd0500a507b5a
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex b5c5ea6..70acf72 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -37,6 +37,7 @@ jobs:pnpm --dir extensions/cordis install --frozen-lockfile --ignore-scriptspnpm --dir extensions/sdk install --frozen-lockfile --ignore-scriptsnpm --prefix extensions/plugins/x ci --ignore-scripts --no-audit --no-fund+ npm --prefix extensions/plugins/gemini-api ci --ignore-scripts --no-audit --no-fund- name: Test the Cordis runtime and plugin SDKrun: |pnpm --dir extensions/cordis testdiff --git a/README.md b/README.mdindex fdf8536..c77e2fe 100644--- a/README.md+++ b/README.md@@ -135,7 +135,7 @@ Open the browser after startup. Controller already serves the web app.name. Opening the account starts its Host in a separate Docker container.2. In **Model settings**, choose **OpenAI Responses** or **Anthropic Messages** in the protocol dropdown, then add the endpoint URL, API key,and at least one model ID. Then select **New chat** and send a message.-3. For web search, save a key for DeepSeek, Zhipu, Doubao, Tavily, or Brave Search under **Settings → Web search**. For image generation, configure Seedream, OpenAI Images, or Google Nano Banana under **Settings → Image generation**. Choose **Use provider** to activate a saved service. [Provider setup](docs/providers.md)+3. For web search, save a key for DeepSeek, Zhipu, Doubao, Tavily, or Brave Search under **Settings → Web search**, then choose **Use provider**. For image generation and other Gemini media capabilities, install and enable **Gemini API CLI** in the plugin market and configure its API key. [Provider setup](docs/providers.md) · [Plugin connection](docs/plugin-account-setup.md#gemini-api-cli)Choose **English** or **简体中文** on the account page or in **Settings**. The browser remembers your choice.@@ -185,6 +185,14 @@ discovery Skill. They remain in their plugin packages underuser Skill directories. Disabling withdraws the Skills and retains installed CLIsoftware. The model discovers Skill names/descriptions and loads instructions on demand.+**Gemini API CLI** is also available in the plugin market. Install and enable it,+then choose **Accounts and authorization → Configure API Key** and enter a key from+[Google AI Studio](https://aistudio.google.com/apikey). The Agent can use the+official `gemini-api` commands for media generation, file analysis and research.+The key stays in the CLI's default `/root/.config/gemini-api/config.yaml`, outside+the workspace volume; configure it again after replacing the Host container.+[Connection guide](docs/plugin-account-setup.md#gemini-api-cli)+| Runtime | Where Host data lives | What **Stop Host** does || --- | --- | --- || Local Docker | Named volume for the account, mounted at `/root/harness` | Stops the container and keeps its files |@@ -266,8 +274,8 @@ when you open an account.`start.sh` loads the selected profile, applies explicitly set deploymentenvironment variables, validates the merged configuration, and saves validoverrides to the profile before launch. An explicitly empty value overrides a-saved value. Model, web search and image generation settings are saved per-account through the UI.+saved value. Model and web-search settings are saved per account through the UI.+Gemini media capabilities use the API key configured in the plugin detail.For an offline configuration check or a read-only runtime check, use:@@ -319,6 +327,9 @@ Scan the QR code in QQ or search for group **710767129**.## Upstream and acknowledgments+- [Gemini API CLI](https://github.com/google-gemini/gemini-api-cli) provides the+ official shell interface for Gemini models and managed agents.+- [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) is the upstream project that this Go implementation is based on. [Compatibility notes](docs/compatibility.md)- [Hermes Agent](https://github.com/NousResearch/hermes-agent) informed the design of local long-term memory and cross-session history search. [Memory design](docs/hermes-agent-memory-design.zh-CN.md)- [OfficeCLI](https://github.com/iOfficeAI/OfficeCLI) supplies the Word, PowerPoint, and Excel tools. The Host also includes [LibreOffice](https://www.libreoffice.org/).diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 0c7c4b7..8501cc8 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -132,7 +132,7 @@ go-bot 是用 Go 实现的 DeepSeek Harness,也是一款可自托管的 Person打开账号时,Controller 会启动独立的 Docker Host 容器。2. 在 **Model settings** 通过协议下拉框选择 **OpenAI Responses** 或 **Anthropic Messages**,填写端点地址、API Key 和至少一个模型 ID,然后点击 **New chat** 发消息。-3. 在 **Settings → Web search** 可配置 DeepSeek、智谱、豆包、Tavily 或 Brave Search。在 **Settings → Image generation** 可配置 Seedream、OpenAI Images 或 Google Nano Banana。保存凭证后点击 **Use provider** 选用。 [供应商配置](docs/providers.md)+3. 在 **Settings → Web search** 配置 DeepSeek、智谱、豆包、Tavily 或 Brave Search,保存后点击 **Use provider** 选用。需要生图及其他 Gemini 媒体能力时,在插件市场安装并启用 **Gemini API CLI**,然后配置其 API Key。[供应商配置](docs/providers.md) · [插件连接](docs/plugin-account-setup.md#gemini-api-cli)可在账号页或「设置」选择简体中文或 English。浏览器会记住语言偏好。@@ -176,6 +176,12 @@ OfficeCLI 提供 11 个原始 Skills,agent-browser 提供官方发现 Skill;`/root/harness/.dsh/plugins/profile/node_modules/` 的对应包内,不再复制到用户 Skill 目录。停用会撤销 Skills,保留已安装的 CLI。模型先看到名称和摘要,再按需加载正文。+插件市场还提供 **Gemini API CLI**。安装并启用后,在「账号与授权 → 配置 API Key」+填写从 [Google AI Studio](https://aistudio.google.com/apikey) 获取的密钥,Agent 即可通过+官方 `gemini-api` 命令生成媒体、分析文件和开展研究。密钥保存在 CLI 默认的+`/root/.config/gemini-api/config.yaml`,不在工作区卷内;更换 Host 容器后需要重新配置。+[连接指引](docs/plugin-account-setup.md#gemini-api-cli)+| 运行模式 | Host 数据存在哪里 | 点击 **Stop Host** 后 || --- | --- | --- || 本地 Docker | 账号自己的命名卷,挂到 `/root/harness` | 停止容器,保留文件 |@@ -247,7 +253,7 @@ OfficeCLI 提供 11 个原始 Skills,agent-browser 提供官方发现 Skill;## 配置与检查`start.sh` 读取指定配置文件,合并显式设置的部署环境变量,校验通过后才将覆盖值写回文件并启动。-显式传入空值会覆盖文件里的值。模型、网页搜索和生图由用户在界面按账号配置。+显式传入空值会覆盖文件里的值。模型和网页搜索由用户在设置界面按账号配置;Gemini 生图等能力在插件详情中配置 API Key。用下面的命令检查 ECI 配置或运行环境:@@ -294,6 +300,8 @@ Compose 负责启动 Redis 并构建前端。Agent 使用的 Python、Node.js、## 上游项目与致谢+- [Gemini API CLI](https://github.com/google-gemini/gemini-api-cli) 提供调用 Gemini 模型与托管 Agent 的官方命令行接口。+- [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 是本 Go 实现所参考的上游项目。 [兼容性说明](docs/compatibility.md)- [Hermes Agent](https://github.com/NousResearch/hermes-agent) 启发了本地长期记忆和跨会话历史检索的设计。 [记忆设计](docs/hermes-agent-memory-design.zh-CN.md)- [OfficeCLI](https://github.com/iOfficeAI/OfficeCLI) 提供 Word、PPT、Excel 处理能力。Host 也包含 [LibreOffice](https://www.libreoffice.org/)。diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex 577b6e8..ef938cc 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -109,3 +109,14 @@ GitHub organization avatar, obtained from<https://avatars.githubusercontent.com/u/3708359?v=4>.Google names and marks belong to their owners. This CLI is not an officiallysupported Google product.++## Gemini API CLI++The Gemini API CLI plugin installs Google's official+https://github.com/google-gemini/gemini-api-cli with its official install script.+The upstream Apache-2.0 license is included at+`/usr/share/go-bot/plugins/gemini-api/UPSTREAM_LICENSE`.+The wrapper uses `yaml` (ISC) for the upstream native configuration format.+Its icon is the official Google AI Studio mark from+https://www.gstatic.com/images/branding/productlogos/ai_studio/v1/web-512dp/logo_ai_studio_color_1x_web_512dp.png.+Google names and marks belong to Google.diff --git a/build/Dockerfile.host b/build/Dockerfile.hostindex cf6c829..6b7ca65 100644--- a/build/Dockerfile.host+++ b/build/Dockerfile.host@@ -63,6 +63,7 @@ COPY --from=plugin-packages /opt/plugins/agent-browser/ /usr/share/go-bot/pluginCOPY --from=plugin-packages /opt/plugins/officecli/ /usr/share/go-bot/plugins/officecli/COPY --from=plugin-packages /opt/plugins/x/ /usr/share/go-bot/plugins/x/COPY --from=plugin-packages /opt/plugins/google-workspace/ /usr/share/go-bot/plugins/google-workspace/+COPY --from=plugin-packages /opt/plugins/gemini-api/ /usr/share/go-bot/plugins/gemini-api/# Plugin runtime dependencies are shared; business modules load only after activation.COPY --from=cordis /opt/cordis/ /usr/share/go-bot/cordis/diff --git a/docs/README.md b/docs/README.mdindex d0cbef9..2ed399d 100644--- a/docs/README.md+++ b/docs/README.md@@ -13,6 +13,7 @@| [Proactive wake-up research](proactive-service-research-and-plan.zh-CN.md) | Verified Muse, Grok Bot and dots behavior, disclosed triggers, and limits of public implementation details || [Extending capabilities](providers.md) · [Contributing](../CONTRIBUTING.md) | Provider contracts and development workflow || [X / Google account setup](plugin-account-setup.md) | Obtain your application credentials and connect native accounts |+| [Gemini API CLI plugin plan](gemini-api-cli-plugin-plan.zh-CN.md) | API-key connection, official CLI installation, Agent usage and file delivery || [Business plugin SDK](../extensions/sdk/README.md) · [Examples](../examples/plugins/README.md) | Native Cordis plugins, async Host APIs, credentials and MCP || [Frontend development](../frontend/README.md) | Develop the UI with Vite against Controller || [Upstream compatibility](compatibility.md) · [Validation](validation.md) | Upstream fixtures and historical verification results |diff --git a/docs/configuration.md b/docs/configuration.mdindex d9dcc91..3f574ad 100644--- a/docs/configuration.md+++ b/docs/configuration.md@@ -60,10 +60,12 @@ first model of the default endpoint. An individual session can switch modelsduring the lifetime of its Host. Child agents inherit the parent turn's route.The Host uses a 1,000,000-token context budget.-In **Settings → Web search**, save a key for DeepSeek, Zhipu, or Doubao,+In **Settings → Web search**, save a key for DeepSeek, Zhipu, Doubao, Tavily or Brave,then choose **Use provider** on your preferred service. Chat and page fetching-work without a search key. In **Settings → Image generation**, configure the-key and model for Seedream, OpenAI Images, or Google Nano Banana and select it.+work without a search key. For image generation, install and enable **Gemini API CLI**+in the plugin market and configure its API key in **Accounts and authorization**.+The built-in image-generation tool and settings UI are currently disabled; their+implementations and saved settings remain available for future integration.See the [provider guide](providers.md) for account and key requirements.## Credentialsdiff --git a/docs/gemini-api-cli-plugin-plan.zh-CN.md b/docs/gemini-api-cli-plugin-plan.zh-CN.mdnew file mode 100644index 0000000..7ccd59b--- /dev/null+++ b/docs/gemini-api-cli-plugin-plan.zh-CN.md@@ -0,0 +1,286 @@+# Gemini API CLI 插件接入方案++状态:已实现,2026-11-21 完成本地 Docker、真实 Web 和 Android 模拟器的安装与 API Key 配置验收。生图实调受 Google 项目计费前提限制,详见末尾验收记录。++## 1. 接入目标与边界++将 Google 的 [Gemini API CLI](https://aistudio.google.com/docs/cli) 包装为 Go Bot 插件,使用用户自己的 API Key,为现有 Agent 增加多模态生成、文件理解和远端研究能力。++本方案接入的是命令为 `gemini-api` 的 [google-gemini/gemini-api-cli](https://github.com/google-gemini/gemini-api-cli)。它与交互式编码 Agent `@google/gemini-cli` 是两个项目。++确定如下:++- 展示名称:`Gemini API CLI`;插件 ID:`gemini-api`;包名:`@go-bot/plugin-gemini-api`;首个包装包版本:`0.1.0`。+- 通过现有插件市场安装、更新、启用、停用、卸载,沿用 pnpm 包安装与 Cordis 生命周期。+- 只提供 API Key 连接方式,不提供 OAuth、Access Token 输入或 Google Workspace 授权复用。+- 业务入口为官方 CLI,由现有 Shell 工具调用;不新增一套 Gemini 工具集合或 MCP Server。+- Go 继续管理 AgentLoop、Session、工具执行、权限、审批、文件交付和前端投影。+- 不新增 `.env` 字段,不改变 LLM、Web search 设置,不将本插件设为默认模型服务。+- 按最新产品决定,Host 不再注册内置 `generateimage`,Web/mobile 隐藏原生图设置入口;工具、provider、设置组件、服务端设置处理和已存数据保留在代码及原存储中,供未来重新接入。保留 readimage、图片附件和 present。++## 2. 能力范围++以下为上游 CLI 已公开的命令分组;实际可用模型与能力取决于用户项目、地区、权限、配额和服务状态。插件不承诺填写 Key 后所有模型均可使用。++| 能力 | 官方入口 | 接入 Go Bot 的方式 |+| --- | --- | --- |+| 文本生成、辅助推理 | `generate` | Shell 调用并读取文本结果 |+| 文生图、参考图编辑 | `image` | 输出工作区文件,再按需调用现有 readimage / present |+| 语音合成、音乐、视频 | `tts`、`music`、`video` | 输出工作区文件,通过现有文件交付展示 |+| 文档与多模态理解、转录 | `analyze`、`transcribe` | 传入实际文件,读取分析或转录结果 |+| Google 托管研究任务 | `agent run/status/cancel` | 保存返回的 interaction ID,按官方接口查询或取消 |+| 文件上传、模型发现 | `files`、`models` | Agent 按任务需要调用 |++命令参数、模型名和输出选项以已安装 CLI 的 `--help`、`--usage`、`--schema` 为准。插件不在前端维护另一份模型列表,也不把模型名称固定到系统提示中。++依据:[官方 CLI 使用说明](https://aistudio.google.com/docs/cli)、[上游项目介绍及 Agent 指引](https://github.com/google-gemini/gemini-api-cli#readme)。++## 3. 源码与发布资源++沿用当前仓库结构:++```text+extensions/plugins/gemini-api/+ package.json+ plugin.json+ src/+ index.mjs # Cordis apply;授权及提示注册+ native-cli.mjs # 原生配置、私有写入、子进程与错误处理+ upstream-instructions.md # 官方 README 的 Agent 指引原文+ scripts/+ install.mjs # pnpm postinstall 调用官方安装方式+ assets/+ icon.png+ LICENSE+ UPSTREAM_LICENSE+ THIRD_PARTY_NOTICES.md+```++`plugin.json` 声明原始产品名、英文/简体中文 description、icon 后端资源路径、版本、维护者、包装包许可证。包版本及许可证与 `package.json` 一致;上游许可证另行保留。++图标使用从 Google 官方品牌或项目资源确认可使用的 Gemini 图标,并记录来源;使用 `/assets/plugins/gemini-api/icon.png` 分发,前端不画供应商专属 SVG。++`extensions/catalog/plugins.json` 增加 bundled 条目,允许该包装包的标准安装脚本。Host 镜像复制包装包到 `/usr/share/go-bot/plugins/gemini-api/`,不在镜像构建时安装业务 CLI,不包含任何 Key。++没有已完成的教程视频时不填写 `tutorials` 占位条目;详情中的双语文字指引和官方链接即可完成初次配置。++## 4. 安装、启用与更新++### 4.1 安装++```text+用户点击安装+ → Controller / Host 执行现有插件包安装操作+ → pnpm 安装包装包及依赖+ → 经审核放行的 postinstall+ → 下载并运行 Google 官方安装脚本+ → 验证 gemini-api --version 与 --help+ → 本次安装成功或返回具体错误+```++安装阶段使用官方方式:++```sh+curl -fsSL https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.sh | bash+```++实际脚本先检查下载成功,再运行 Bash,并将整个子进程纳入现有安装操作的取消处理。安装不读取用户 Key,也不发起收费生成请求。++官方安装脚本会识别 Linux amd64 / arm64;正常 Host 内以 root 安装到默认 `/usr/local/bin/gemini-api`,已有 PATH 即可访问。无需 Host 预装 Go 编译工具链、npm 全局 Gemini 包或额外 launcher。++与当前采用官方默认安装方式的 CLI 插件一致,本方案安装时取官方默认最新 release;包装包自身仍按市场版本管理。上游为 beta,官方建议自动化环境固定 release,因此要明确:同一包装包在不同日期重装可能得到不同 CLI 版本。验收记录实际 `--version`;如后续出现破坏性变更,再在包装包内部选择已验证 release,不增加普通用户版本表单。++依据:[官方安装脚本](https://github.com/google-gemini/gemini-api-cli/blob/main/scripts/install.sh)、[官方安装与 beta 提示](https://aistudio.google.com/docs/cli#install)。++### 4.2 启用与停用++`apply()` 只检查本地命令并注册授权入口及 Agent 指引,不下载软件、不等待用户输入、不请求远端服务。配置直接使用 CLI 的默认目录,不建立目录映射。++未填写 Key 也可以安装并启用,详情显示「未配置」。Host 和其他能力继续正常使用。++停用由 Cordis 撤销本插件注册的提示及授权入口,不卸载 CLI、不删除 Key。与当前插件机制一致,停用不是操作系统层面的命令封禁;已经运行的命令不会因撤销提示而自动取消。++### 4.3 更新与卸载++- 可更新状态沿用 Controller 对市场包装包版本与实际已安装版本的比较,不用上游 CLI 版本冒充插件版本。+- 用户更新时复用安装流程,重新执行官方安装,验证后恢复原启用状态;保留原生配置及用户产物。+- `apply()`、打开详情、Host 重启均不自动升级 CLI。+- 卸载沿用现有语义:移除包装包和注册项,保留全局 CLI、原生凭证及文件;用户希望清除 Key 时先点击「移除 API Key」。+- 安装请求等待成功或失败,安装状态只影响相应插件操作;Web/mobile 仍可离开页面、切换会话和发送消息,不增加全屏操作遮罩。++## 5. API Key 授权与存储++### 5.1 复用现有原生 CLI 授权模式++本插件使用现有 `ctx.host.authorization.register()` 的 `run / inspect / disconnect` 模式,与 X、Google Workspace 的原生存储适配一致。++只注册一个 method:`api-key`。用户在现有授权面板输入 Key,表单通过 `session.prompt({kind: 'secret', ...})` 驱动。该输入不进入聊天消息和模型上下文。++不使用 `session.commit()` 再保存一份 Go CredentialRecord;授权结束由现有框架调用 `inspect()` 确认原生配置是否存在。原因是 Agent 将直接执行官方 CLI,CLI 必须能从自己的配置读取凭证;本方案选择原生配置作为唯一密钥来源,避免两份数据同步。++这不新增授权框架,也不更改其他插件使用 `ctx.host.credentials` 的方式。++### 5.2 数据位置++保持 `HOME=/root`,直接使用官方默认位置:++```text+/root/.config/gemini-api/config.yaml+```++插件授权与 Agent 执行 CLI 都读写这一份默认配置,不创建软链接,不复制到 `.dsh/credentials`,也不增加 Docker/NAS 挂载。当前工作区挂载 `/root/harness` 不包含这个目录:同一容器 stop/start 时文件保留,删除并重新创建容器后不能依靠工作区卷或 NAS 恢复这份 Key,需要重新配置。++拟保存的原生配置结构:++```yaml+version: 1+security:+ api_key: "用户提供的值"+no_keyring: "true"+```++这是上游支持的 YAML 配置,`no_keyring` 在当前源码中为字符串字段。插件通过包管理引入 YAML 库读取、更新配置;不手工拼接用户输入。目录权限 0700、文件权限 0600,通过临时文件替换保存;使用容器文件存储,不依赖桌面系统 Keychain。++读取并保留原生配置中的其他设置,只更新本插件管理的 API Key 及文件存储选项。配置损坏时明确报错,不删除用户数据来制造成功状态。++Redis 仍只保存用户已选插件的 `catalogId/version/enabled`,不新增 Key、整份 CLI 配置或常驻授权任务。++依据:[官方配置结构及读取优先级](https://github.com/google-gemini/gemini-api-cli/blob/main/internal/config/config.go)、[官方 Keychain 与文件存储方式](https://aistudio.google.com/docs/cli#authentication)。++### 5.3 保存与验证流程++```text+点击「配置 API Key」+ → 输入 Key+ → 检查非空、无换行等输入错误+ → 仅为验证子进程设置 GEMINI_API_KEY+ → 用官方 models 命令执行轻量认证检查+ → 检查成功后写入原生配置+ → inspect 确认已配置+ → 授权面板显示完成+```++验证调用只读模型列表,不生成图片或文本;不消耗生成 tokens。实施时确认所安装版本的 JSON 输出和退出码,并用失败响应证明无效 Key 不会误判为成功。`whoami` 和 `--dry-run` 只能用于本地配置或命令检查,不能作为远端验证成功的证据。++验证失败或用户取消时,保留此前可用 Key。401/认证失败、403/权限问题、429/限流、网络错误分别显示可理解的原因,不直接回显含密钥的原生错误对象或完整子进程参数。++验证子进程通过独立 env 接收 Key,不更改 `process.env` 或 Host 主进程环境,不将 Key 放入 Shell 命令、进程参数、通知或日志。排除继承的 Gemini Token 等冲突认证变量,确保本次检查使用用户刚输入的 Key。成功配置 API Key 时清除原生文件中先前的 access_token,明确切换到当前插件支持的认证方式;其他原生偏好保留。++普通命令后续从原生配置直接读取 Key,无需启动时设置环境变量。CLI 本身仍遵循官方 flags/env/config 优先级;本项目不提供第二个全局 Gemini Key 配置入口,避免面板所见与实际使用的 Key 不一致。++`inspect()` 只检查本地已配置状态,不在每次打开详情或恢复 Host 时请求 Google;因此 UI 用「已配置」,不用「已验证所有服务」或「Google 账号已登录」。Key 后续失效由真实调用报错暴露,用户可以重新配置。++「移除 API Key」删除本插件保存的原生 Key,由 `disconnect()` 完成,框架再确认未配置。不删除生成文件;不是撤销 Google 控制台上的 Key。运行中已读取 Key 的子进程不保证立即失效。++## 6. Agent 如何发现与使用++官方项目提供 Agent 使用指引和可查询命令 schema。本次核对未发现仓库内的原生 `SKILL.md`,因此不宣称存在官方 Skill,也不引入另一项目面向 SDK 编程的 Skills 来冒充此 CLI 用法。++启用后通过已有 `ctx.host.prompts.register()`,从包装包内 `src/upstream-instructions.md` 读取官方 README 的 Agent 指引,原样注入,仅注册这一条。不改写原文,也不另加 Go Bot 授权入口或 readimage/present 的自写说明;原有界面、工具定义和核心提示继续承担各自职责。官方原文的来源 commit 和许可记录在 THIRD_PARTY_NOTICES.md,插件运行时不联网获取提示。官方指引包含:++1. 可通过 Shell 使用 `gemini-api` 调用模型、生成或编辑媒体、分析文件或使用托管 Agent。+2. 查阅 `--help` / `--usage` 及请求体 `--schema`。+3. 使用官方 dry-run 方式预览 API 调用。+4. 非流式 JSON、流式命令及 background 返回结果的用法。+5. 保存文件路径和 interaction ID,用于继续多步工作。++指引由包装包注册,停用即撤销。既有会话在下一次组装模型上下文时取得当前插件提示,不要求新建会话或重启 Host。不会向模型注入 Key,也不会复制完整 CLI 手册到 system prompt。++当前生图使用插件提供的 CLI 能力。Host 不再为模型注册 `generateimage`,插件提示也不再建议调用它。原生图实现和 provider 代码保留;既有供应商配置不删除,前端不展示其设置入口。Web 直接访问旧设置路径时显示模型设置。此调整不影响读取图片、图片附件、图片展示和文件交付。++## 7. 文件与长任务链路++### 7.1 图片和其他文件++```text+Agent → Shell → gemini-api → 当前工作目录中的文件+ → 需要图片进入模型上下文时:readimage+ → 需要向用户交付时:present+ → Go 提交现有 image / file 内容与事件+ → Controller 转发 → Web/mobile 现有渲染与下载+```++CLI 返回路径不自动变成 image block 或 file block,不扫描目录、不解析 Markdown 来补交付,不增加插件 assets API。readimage 和 present 分别沿用当前图片附件和工作区文件语义。++音频、视频先作为现有 file 块交付,不承诺新增播放器或流式通话界面。文件分析向 Google 发送指定输入,插件详情应说明数据会交给 Google 处理。++### 7.2 命令执行++Agent 通过现有 Shell 调用官方命令,读取退出码、文本输出和文件路径。执行较久的命令沿用已有 job/joboutput 行为。具体命令需要多步操作时,按官方使用说明继续调用。++## 8. Web 与 mobile 交互++沿用当前插件市场及详情样式,不新增供应商专属页面:++| 位置 | 表现 |+| --- | --- |+| 市场列表 | 官方名称、图标、双语 description、现有安装/启用状态 |+| 插件详情 | 介绍、官方 Key 获取链接、配置前置说明、安装和启用操作 |+| 账号与授权区域 | 单一「API Key」方式;配置、重新配置、移除入口 |+| 输入过程 | 现有 secret 输入与取消交互;不要求输入模型、URL、Client ID 或 Secret |+| 配置结果 | 未配置 / 已配置;失败时保留原因和重试入口 |++用户路径:打开市场 → 安装 → 启用 → 配置 API Key → 返回会话发任务。详情说明从 [Google AI Studio API Keys](https://aistudio.google.com/apikey) 获取 Key,配额和计费由用户自己的 Google 项目承担。++中英文文案由元数据和现有通用授权文案机制提供。客户端不根据 `pluginId === 'gemini-api'` 手写授权表单。输入 Key 后请求仍通过现有 Controller → Host → 插件授权链路处理。++## 9. 实施范围与验收++实施时按以下顺序完成:++1. 新增包装包、元数据、官方图标和许可证说明。+2. 接入 pnpm postinstall,使用官方安装脚本,并验证两种 Host 架构。+3. 接入默认位置的原生配置读写、Key 验证、授权 run/inspect/disconnect 及错误脱敏。+4. 注册官方 CLI 使用指引,接通市场清单、Host 资源复制和静态资源分发。+5. 补充插件使用文档,核对 Web/mobile 通用表单、操作状态及翻译。+ 同时验证原生图设置入口隐藏、旧 Web 路径不会打开生图表单、实际 Host 工具列表无 generateimage 而保留 readimage/present。+6. 重新构建 Host/Controller,并进行真实前端验收。++必要验证:++- 新 Host 安装成功;下载失败和取消明确结束;未配置 Key 不阻塞安装或 Host 启动。+- 启用/停用不重复安装;卸载/重装不误删凭证;更新保持用户启用选择。+- 无效 Key、网络错误、取消不覆盖旧 Key;API Key 不进入聊天日志、模型请求、Redis、安装输出或源码。+- 授权写入和普通 CLI 读取同一份默认配置;同容器重启后正常使用;损坏配置不显示成功;不创建软链接或额外挂载。+- 用 mock 验证输入、认证检查、失败和清除逻辑;真实 Key 验收只做小量请求:一次简短文本或文件分析、一次小尺寸生图,确认 readimage/present 与前端展示。+- 从 Web 和 Android 模拟器分别完成配置/重新配置/移除,确认安装期间可正常切换会话与使用其他操作。+- Linux amd64 与 arm64 检查 CLI 安装、启动和配置读取;不要求本次专门创建 ECI/NAS 资源。++真实服务验收使用用户提供的 Key;未实测的媒体类型明确标为未验收,不以命令存在代替成功证据。验收结果如下。++## 10. 官方依据与本地对应实现++上游资料(核对日期:2026-11-21):++- [Gemini API CLI 官方说明](https://aistudio.google.com/docs/cli):用途、命令、认证、Agent 指引和已知限制。+- [官方 GitHub 仓库](https://github.com/google-gemini/gemini-api-cli):源码、发布和许可证。+- [官方安装脚本](https://github.com/google-gemini/gemini-api-cli/blob/main/scripts/install.sh):默认安装位置及架构识别。+- [配置实现](https://github.com/google-gemini/gemini-api-cli/blob/main/internal/config/config.go):原生 YAML 字段和认证优先级。+- [认证实现](https://github.com/google-gemini/gemini-api-cli/blob/main/internal/cli/auth.go):本地认证配置与退出语义。+- [官方 API Key 指引](https://aistudio.google.com/docs/api-key):项目、Key 获取和使用前提。++本项目现有可复用位置:++- `extensions/sdk/README.md`、`extensions/sdk/index.d.ts`:插件安装、生命周期、授权 run/inspect/disconnect 契约。+- `extensions/plugins/google-workspace/src/native-cli.mjs`:私有文件写入和子进程取消处理的参考;本插件不复用其中的目录映射函数。+- `extensions/plugins/google-workspace/src/index.mjs`:原生存储授权适配与 Agent 授权指引注册的参考。+- `extensions/catalog/plugins.json`:审核清单与安装脚本放行。+- `extensions/plugins/manifest.go`、`extensions/plugins/assets.go`:展示元数据和后端资源。+- `build/Dockerfile.host`:包装包资源分发。++以上为在现有机制上的新增业务插件,不需要重构核心插件框架。++## 11. 实施与验收记录(2026-11-21)++- 新增 `@go-bot/[email protected]`,市场名称 Gemini API CLI。经真实市场安装,官方安装器取得 `gemini-api 0.5.0`。+- Web 与 Android 模拟器分别使用独立测试账号,从市场安装、启用并用真实 Key 配置成功;安装期间可以离开插件页。+- Web 验证无效 Key 的错误显示、取消、移除后重新配置;同一 Host 容器重启后仍显示已配置。+- Android 最新 QA APK 已重新打包并安装;验证配置、无效 Key 更新失败后保留旧 Key、移除及重新配置。+- 实际文件位于 `/root/.config/gemini-api/config.yaml`,目录/文件无软链接,文件权限 0600;普通 CLI 不传 Key 参数即可成功执行在线模型列表。两账号 Redis 不含该 Key,源码中不含该 Key。+- 官方 README Agent 指引单独保存在 `src/upstream-instructions.md`,仅原文注册一条 system 提示;来源 commit 与许可在插件 notices 中记录。没有 Go Bot 授权入口、readimage/present 的自写补充。+- 默认 Host 停用 `generateimage` 注册,保留实现及 provider;Web/mobile 生图设置入口隐藏,旧 Web 路径显示模型设置。Docker 集成测试检查实际模型请求:无 generateimage,仍有 readimage/present。+- `make test vet check`、Cordis 29 项测试、Web 25 项测试、Web 构建、mobile TypeScript 检查、Host 镜像 smoke、Docker Web 会话集成检查通过。最后提示词调整另跑插件定向测试和相关 Go 包测试通过。+- Linux ARM64 官方安装及启动实测成功;同 release 的 Linux AMD64 官方二进制在 Docker 模拟执行下成功输出版本。未创建 ECI/NAS 资源,也未执行 iOS 验收。+- 额外尝试一次 512 尺寸生图,Google 返回 `403 permission_denied`:当前项目不可使用免费层,需要配置计费。在线模型列表验证成功并不代表项目具备全部生成能力。没有生成成功的图片,不宣称生图验收通过;未进行其他媒体生成或修改 Google 计费设置。++真实截图和本地测试日志位于忽略目录 `.local/gemini-api-qa/`;不纳入发布源码,不保存真实 Key 到文档。diff --git a/docs/plugin-account-setup.md b/docs/plugin-account-setup.mdindex 9561eca..30149ad 100644--- a/docs/plugin-account-setup.md+++ b/docs/plugin-account-setup.md@@ -1,4 +1,4 @@-# Connect X and Google Workspace+# Connect plugin servicesX uses each user's own developer application, entered inside the plugin'sAccounts and authorization panel. Google Workspace also uses each user's own@@ -7,6 +7,34 @@ first connection. Accounttokens for both services stay in each user's native CLI store, never in Redis orGo credentials. Do not put user credentials in chat, deployment `.env` or Git.+## Gemini API CLI++1. Create your own Gemini API key in [Google AI Studio](https://aistudio.google.com/apikey).+2. Install and enable **Gemini API CLI** in the plugin market.+3. Open **Accounts and authorization → Configure API Key**. Enter the key in the+ protected field. A live `models list` request checks access without generating content.+4. Return to chat. The Agent uses the official CLI and existing image/file delivery.++Use **Update API Key** to replace a key, or **Remove API Key** to clear it from+this Host. A failed or cancelled replacement preserves the previous key.+Only API-key authentication is offered; no OAuth application or callback is needed.+Google controls available models, regional access, quotas and billing.++The CLI reads `/root/.config/gemini-api/config.yaml` directly. No symlink or+additional mount is created. Configuration remains across a stop/start of the+same container, but is outside `/root/harness` and needs to be entered again+after the Host container is replaced. Redis and chat history do not store it.++### Gemini API CLI:中文配置指引++在 [Google AI Studio](https://aistudio.google.com/apikey) 创建自己的 API Key,+安装并启用插件后,打开「账号与授权 → 配置 API Key」输入密钥。保存前通过在线+`models list` 检查访问,不生成内容。修改用「更新 API Key」,清除用「移除 API Key」;+修改失败或取消会保留原密钥。仅支持 API Key,不需要 OAuth 应用或回跳地址。++配置直接位于 `/root/.config/gemini-api/config.yaml`,不做映射,不写入 Redis 或聊天记录。+同一容器停止再启动后保留;删除并重建 Host 容器后需重新填写。模型、配额、地区和费用由 Google 管理。+## X1. Open the [X Developer Console](https://developer.x.com/), create an app anddiff --git a/docs/providers.md b/docs/providers.mdindex 1238415..4d3fbcd 100644--- a/docs/providers.md+++ b/docs/providers.md@@ -120,6 +120,13 @@ controller. Preserve durable v4 facts and tool-intent checkpoints.## Image generation+The default Host currently does not register `generateimage`, and Web/mobile+hide its settings entry. Use the **Gemini API CLI** plugin for image generation;+see [connection setup](plugin-account-setup.md#gemini-api-cli). `readimage`, image+attachments and `present` remain active. The adapters, tool, settings code and+saved account settings below are retained for future integration. This section+documents those retained implementations, rather than the current UI.+| ID | Service | Suggested model || --- | --- | --- || `seedream` (default) | Volcengine Ark Images API | `doubao-seedream-5-0-260128` |diff --git a/extensions/catalog/plugins.json b/extensions/catalog/plugins.jsonindex e0c33de..5448479 100644--- a/extensions/catalog/plugins.json+++ b/extensions/catalog/plugins.json@@ -35,6 +35,13 @@"@go-bot/plugin-x"]},+ {+ "pluginId": "gemini-api",+ "package": "@go-bot/plugin-gemini-api",+ "version": "0.1.0",+ "source": { "type": "bundled", "spec": "gemini-api" },+ "builds": ["@go-bot/plugin-gemini-api"]+ },{"pluginId": "google-workspace","package": "@go-bot/plugin-google-workspace",diff --git a/extensions/cordis/test/gemini-api-plugin.test.mjs b/extensions/cordis/test/gemini-api-plugin.test.mjsnew file mode 100644index 0000000..1d32a80--- /dev/null+++ b/extensions/cordis/test/gemini-api-plugin.test.mjs@@ -0,0 +1,101 @@+import test from 'node:test'+import assert from 'node:assert/strict'+import { mkdtemp, mkdir, writeFile, readFile, lstat, rm } from 'node:fs/promises'+import path from 'node:path'+import { tmpdir } from 'node:os'+import { apply, authorize, inspect, disconnect } from '../../plugins/gemini-api/src/index.mjs'+import { configFile, readConfig } from '../../plugins/gemini-api/src/native-cli.mjs'++async function fixture(t) {+ const directory = await mkdtemp(path.join(tmpdir(), 'go-bot-gemini-test-'))+ const previous = { ...process.env }+ process.env.HOME = path.join(directory, 'home')+ await mkdir(process.env.HOME)+ const bin = path.join(directory, 'bin'); await mkdir(bin)+ process.env.PATH = bin + path.delimiter + process.env.PATH+ await writeFile(path.join(bin, 'gemini-api'), '#!' + process.execPath + '\n' + `+const args=process.argv.slice(2);+if(args[0]==='--version'){console.log('gemini-api test');process.exit(0)}+if(args.slice(0,2).join(' ')!=='models list' || !args.includes('--no-keyring') || args.includes(process.env.GEMINI_API_KEY)) process.exit(8);+if(process.env.GEMINI_ACCESS_TOKEN || process.env.GEMINI_SERVER_URL) process.exit(9);+switch(process.env.GEMINI_API_KEY){+case 'valid-test-key':console.log(JSON.stringify({models:[{name:'models/test'}]}));break;+case 'valid-replacement':console.log(JSON.stringify({models:[]}));break;+case 'slow-test-key':setInterval(()=>{},1000);break;+case 'network-test-key':console.error('dial tcp: connection refused private-raw-secret');process.exit(1);break;+case 'help-test-key':console.log('Offline model catalog');break;+default:console.error('401 UNAUTHENTICATED API_KEY_INVALID '+process.env.GEMINI_API_KEY);process.exit(3);+}+`, { mode: 0o755 })+ t.after(async () => {+ for (const key of Object.keys(process.env)) if (!(key in previous)) delete process.env[key]+ Object.assign(process.env, previous)+ await rm(directory, { recursive: true, force: true })+ })+ return directory+}+function session(key, controller = new AbortController()) {+ return { method: 'api-key', signal: controller.signal, prompts: [], async prompt(prompt) { this.prompts.push(prompt); return key } }+}+test('Gemini registers the existing authorization flow and uses only the native default configuration', async t => {+ await fixture(t)+ const flows = [], prompts = []+ await apply({ host: { authorization: { register: async flow => flows.push(flow) }, prompts: { register: async prompt => prompts.push(prompt) } } })+ assert.deepEqual(flows[0].methods, [{ id: 'api-key', label: 'Configure API Key' }])+ assert.deepEqual(await flows[0].inspect(), { configured: false })+ const attempt = session('valid-test-key'); await flows[0].run(attempt)+ assert.deepEqual(await flows[0].inspect(), { configured: true })+ assert.equal(attempt.prompts.length, 1); assert.equal(attempt.prompts[0].kind, 'secret')+ assert.equal((await lstat(configFile())).isSymbolicLink(), false)+ assert.equal((await lstat(configFile())).mode & 0o777, 0o600)+ assert.equal((await lstat(path.dirname(configFile()))).mode & 0o777, 0o700)+ assert.equal((await readConfig()).no_keyring, 'true')+ await assert.rejects(lstat(path.join(process.env.HOME, 'harness')), { code: 'ENOENT' })+ assert.equal(prompts[0].location, 'system'); assert.ok(!prompts[0].text.includes('valid-test-key'))+ assert.equal(prompts.length, 1)+ assert.equal(prompts[0].id, 'official-cli-usage')+ assert.equal(prompts[0].text, await readFile(new URL('../../plugins/gemini-api/src/upstream-instructions.md', import.meta.url), 'utf8'))+ await flows[0].disconnect({ signal: new AbortController().signal })+ assert.deepEqual(await inspect(), { configured: false })+})+test('verification ignores inherited Gemini credentials, keeps Host env unchanged and preserves native preferences', async t => {+ await fixture(t)+ await mkdir(path.dirname(configFile()), { recursive: true })+ await writeFile(configFile(), 'output_format: json\nsecurity:\n api_key: old\n access_token: expired\n')+ process.env.GEMINI_API_KEY = 'unrelated-key'; process.env.GEMINI_ACCESS_TOKEN = 'unrelated-token'; process.env.GEMINI_SERVER_URL = 'https://unrelated.invalid'+ await authorize(session('valid-test-key'))+ const config = await readConfig()+ assert.equal(config.output_format, 'json'); assert.equal(config.security.api_key, 'valid-test-key'); assert.equal(config.security.access_token, undefined)+ assert.equal(process.env.GEMINI_API_KEY, 'unrelated-key'); assert.equal(process.env.GEMINI_ACCESS_TOKEN, 'unrelated-token')+ await authorize(session('valid-replacement'))+ assert.equal((await readConfig()).security.api_key, 'valid-replacement')+ await disconnect(); assert.equal((await readConfig()).output_format, 'json')+})+test('invalid keys and offline output cannot overwrite a previously configured key or leak raw errors', async t => {+ await fixture(t); await authorize(session('valid-test-key'))+ const before = await readFile(configFile(), 'utf8')+ for (const key of ['invalid-private-value', 'help-test-key', 'network-test-key']) {+ await assert.rejects(authorize(session(key)), error => !error.message.includes(key) && !error.message.includes('private-raw-secret'))+ assert.equal(await readFile(configFile(), 'utf8'), before)+ }+ for (const key of ['', 'abc\ndef', 'abc def']) await assert.rejects(authorize(session(key)), /valid Gemini API key/)+ await assert.rejects(authorize({ ...session('valid-test-key'), method: 'oauth' }), /API Key authorization/)+})+test('cancelling verification terminates the CLI and leaves no candidate configuration', async t => {+ await fixture(t)+ const controller = new AbortController()+ const attempt = authorize(session('slow-test-key', controller))+ const timer = setTimeout(() => controller.abort(new Error('test cancelled')), 100)+ try { await assert.rejects(attempt, /test cancelled/) } finally { clearTimeout(timer) }+ assert.deepEqual(await inspect(), { configured: false })+ await assert.rejects(readFile(configFile()), { code: 'ENOENT' })+})+test('broken native YAML is reported without replacing it', async t => {+ await fixture(t)+ await mkdir(path.dirname(configFile()), { recursive: true })+ const malformed = 'security: [broken'+ await writeFile(configFile(), malformed)+ await assert.rejects(inspect(), /Repair config.yaml/)+ await assert.rejects(authorize(session('valid-test-key')), /Repair config.yaml/)+ assert.equal(await readFile(configFile(), 'utf8'), malformed)+})diff --git a/extensions/plugins/gemini-api/LICENSE b/extensions/plugins/gemini-api/LICENSEnew file mode 100644index 0000000..09f7d46--- /dev/null+++ b/extensions/plugins/gemini-api/LICENSE@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2026 Go Harness contributors++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/extensions/plugins/gemini-api/THIRD_PARTY_NOTICES.md b/extensions/plugins/gemini-api/THIRD_PARTY_NOTICES.mdnew file mode 100644index 0000000..24cb87b--- /dev/null+++ b/extensions/plugins/gemini-api/THIRD_PARTY_NOTICES.md@@ -0,0 +1,16 @@+# Third-party notices++This MIT-licensed wrapper installs Google's official Gemini API CLI from+https://github.com/google-gemini/gemini-api-cli using its official installer.+The upstream CLI is Apache-2.0; see UPSTREAM_LICENSE. Agent guidance references+the official README and https://aistudio.google.com/docs/cli.++YAML parsing uses the `yaml` npm package (ISC), resolved by pnpm.++The icon is Google's official AI Studio product mark, obtained from+https://www.gstatic.com/images/branding/productlogos/ai_studio/v1/web-512dp/logo_ai_studio_color_1x_web_512dp.png+and used to identify this integration. Google retains its trademarks.++`src/upstream-instructions.md` reproduces the Agent instruction block unchanged+from the Apache-2.0 upstream README at commit ff27df6ff109f56c4dcb46ed85d23124515f9e34.+Source: https://github.com/google-gemini/gemini-api-cli/blob/ff27df6ff109f56c4dcb46ed85d23124515f9e34/README.md#2-give-your-agent-instructionsdiff --git a/extensions/plugins/gemini-api/UPSTREAM_LICENSE b/extensions/plugins/gemini-api/UPSTREAM_LICENSEnew file mode 100644index 0000000..ece823a--- /dev/null+++ b/extensions/plugins/gemini-api/UPSTREAM_LICENSE@@ -0,0 +1,201 @@+ Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.diff --git a/extensions/plugins/gemini-api/assets/icon.png b/extensions/plugins/gemini-api/assets/icon.pngnew file mode 100644index 0000000..3e897a3Binary files /dev/null and b/extensions/plugins/gemini-api/assets/icon.png differdiff --git a/extensions/plugins/gemini-api/package-lock.json b/extensions/plugins/gemini-api/package-lock.jsonnew file mode 100644index 0000000..7a0a5bf--- /dev/null+++ b/extensions/plugins/gemini-api/package-lock.json@@ -0,0 +1,32 @@+{+ "name": "@go-bot/plugin-gemini-api",+ "version": "0.1.0",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "@go-bot/plugin-gemini-api",+ "version": "0.1.0",+ "hasInstallScript": true,+ "license": "MIT",+ "dependencies": {+ "yaml": "^2.8.1"+ }+ },+ "node_modules/yaml": {+ "version": "2.9.1",+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz",+ "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==",+ "license": "ISC",+ "bin": {+ "yaml": "bin.mjs"+ },+ "engines": {+ "node": ">= 14.6"+ },+ "funding": {+ "url": "https://github.com/sponsors/eemeli"+ }+ }+ }+}diff --git a/extensions/plugins/gemini-api/package.json b/extensions/plugins/gemini-api/package.jsonnew file mode 100644index 0000000..1db1812--- /dev/null+++ b/extensions/plugins/gemini-api/package.json@@ -0,0 +1,12 @@+{+ "name": "@go-bot/plugin-gemini-api",+ "version": "0.1.0",+ "type": "module",+ "description": "Use the official Gemini API CLI for media generation, file analysis and research.",+ "license": "MIT",+ "exports": "./src/index.mjs",+ "files": ["src/", "scripts/", "plugin.json", "assets/", "LICENSE", "UPSTREAM_LICENSE", "THIRD_PARTY_NOTICES.md"],+ "goBot": { "api": "1" },+ "scripts": { "postinstall": "node ./scripts/install.mjs" },+ "dependencies": { "yaml": "^2.8.1" }+}diff --git a/extensions/plugins/gemini-api/plugin.json b/extensions/plugins/gemini-api/plugin.jsonnew file mode 100644index 0000000..5a8df5a--- /dev/null+++ b/extensions/plugins/gemini-api/plugin.json@@ -0,0 +1,11 @@+{+ "name": "Gemini API CLI",+ "description": {+ "en": "Generate and edit images, create speech, music and video, analyze files and run research with the official gemini-api CLI.\n\n1. Open [Google AI Studio API Keys](https://aistudio.google.com/apikey) and create a Gemini API key for your own project. Google controls model availability, regional access, quotas and billing.\n2. Install and enable this plugin, open Accounts and authorization, then choose Configure API Key. Enter your key in the protected field. A live model-list request checks access before saving; it does not generate content.\n3. Return to chat and describe your task. The Agent can inspect official command help, use Gemini and deliver the resulting files.\n\nOnly API-key authentication is offered. Configuration is saved in the official default location /root/.config/gemini-api/config.yaml inside your Host. It survives a stop/start of that container; replacing the container requires configuring the key again. It is not stored in Redis or the workspace.\n\nInputs supplied to the CLI are processed by Google. Paid capabilities use your Google project's quota and billing. The CLI is a beta release; available commands and models may change.\n\nOfficial guide: [Gemini API CLI](https://aistudio.google.com/docs/cli).",+ "zh-CN": "通过官方 gemini-api CLI 生成与编辑图片、合成语音、制作音乐和视频、分析文件并开展研究。\n\n1. 打开 [Google AI Studio API Keys](https://aistudio.google.com/apikey),在自己的项目中创建 Gemini API Key。可用模型、地区限制、配额和计费由 Google 管理。\n2. 安装并启用插件,打开「账号与授权」,点击「配置 API Key」,在受保护输入框中填写密钥。保存前会请求在线模型列表检查访问权限,不生成内容。\n3. 返回会话描述任务,Agent 可以查阅官方命令帮助,调用 Gemini 并交付生成的文件。\n\n仅提供 API Key 认证。配置保存在 Host 的官方默认位置 /root/.config/gemini-api/config.yaml。同一容器停止再启动后保留,删除并重建容器后需要重新配置;不存入 Redis 或工作区。\n\n传给 CLI 的输入会由 Google 处理,付费能力使用你自己的 Google 项目额度并计费。此 CLI 为 beta,命令与可用模型可能变化。\n\n官方指引:[Gemini API CLI](https://aistudio.google.com/docs/cli)。"+ },+ "icon": "/assets/plugins/gemini-api/icon.png",+ "version": "0.1.0",+ "maintainer": "Go Bot",+ "license": "MIT"+}diff --git a/extensions/plugins/gemini-api/scripts/install.mjs b/extensions/plugins/gemini-api/scripts/install.mjsnew file mode 100644index 0000000..5db1188--- /dev/null+++ b/extensions/plugins/gemini-api/scripts/install.mjs@@ -0,0 +1,21 @@+import { mkdtemp, rm } from 'node:fs/promises'+import { tmpdir } from 'node:os'+import path from 'node:path'+import { execFileSync } from 'node:child_process'++// Dependency setup belongs to pnpm installation, never Cordis apply/dispose.+const directory = await mkdtemp(path.join(tmpdir(), 'go-bot-gemini-install-'))+try {+ const file = path.join(directory, 'install.sh')+ execFileSync('curl', ['--fail', '--silent', '--show-error', '--location', '--connect-timeout', '15', '--max-time', '120',+ 'https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.sh', '--output', file], { stdio: 'inherit' })+ const env = { ...process.env }+ delete env.GEMINI_VERSION+ delete env.GEMINI_INSTALL_DIR+ // Default official release and install location; no user credential is needed.+ execFileSync('bash', [file], { stdio: 'inherit', env, timeout: 8 * 60_000 })+ execFileSync('gemini-api', ['--version'], { stdio: 'inherit', timeout: 15_000 })+ execFileSync('gemini-api', ['--help'], { stdio: 'ignore', timeout: 15_000 })+} finally {+ await rm(directory, { recursive: true, force: true })+}diff --git a/extensions/plugins/gemini-api/src/index.mjs b/extensions/plugins/gemini-api/src/index.mjsnew file mode 100644index 0000000..b51989d--- /dev/null+++ b/extensions/plugins/gemini-api/src/index.mjs@@ -0,0 +1,44 @@+import { configFile, readConfig, writeConfig, verifyCLI, validateKey } from './native-cli.mjs'+import { readFile } from 'node:fs/promises'++export const name = 'gemini-api'+export const inject = ['host']++export async function inspect(file = configFile()) {+ const config = await readConfig(file)+ return { configured: typeof config.security?.api_key === 'string' && !!config.security.api_key.trim() }+}+export async function authorize(session, file = configFile()) {+ if (session.method !== 'api-key') throw new Error('Select the API Key authorization method.')+ const key = (await session.prompt({ kind: 'secret', message: 'Enter your Gemini API key from Google AI Studio.' })).trim()+ if (!key || key.length > 4096 || /\s|\p{Cc}/u.test(key)) throw new Error('Enter a valid Gemini API key without spaces or line breaks.')+ // Read first so a broken configuration cannot be silently overwritten.+ await readConfig(file)+ await validateKey(key, session.signal)+ session.signal.throwIfAborted()+ const config = await readConfig(file)+ config.version ??= 1+ config.security = { ...config.security, api_key: key }+ delete config.security.access_token+ config.no_keyring = 'true'+ await writeConfig(config, file)+}+export async function disconnect(file = configFile()) {+ const config = await readConfig(file)+ if (config.security) delete config.security.api_key+ await writeConfig(config, file)+}+export async function apply(ctx) {+ await verifyCLI()+ await ctx.host.authorization.register({+ key: 'api-key', title: 'Gemini API CLI',+ methods: [{ id: 'api-key', label: 'Configure API Key' }],+ inspect: () => inspect(),+ disconnect: ({ signal }) => { signal.throwIfAborted(); return disconnect() },+ run: session => authorize(session),+ })+ await ctx.host.prompts.register({+ id: 'official-cli-usage', location: 'system', order: 0,+ text: await readFile(new URL('./upstream-instructions.md', import.meta.url), 'utf8'),+ })+}diff --git a/extensions/plugins/gemini-api/src/native-cli.mjs b/extensions/plugins/gemini-api/src/native-cli.mjsnew file mode 100644index 0000000..dbbd608--- /dev/null+++ b/extensions/plugins/gemini-api/src/native-cli.mjs@@ -0,0 +1,80 @@+import { execFile } from 'node:child_process'+import { promisify } from 'node:util'+import { mkdir, lstat, readFile, open, rename, rm, chmod } from 'node:fs/promises'+import { randomUUID } from 'node:crypto'+import path from 'node:path'+import { parse, stringify } from 'yaml'++const exec = promisify(execFile)+const isObject = value => value !== null && typeof value === 'object' && !Array.isArray(value)+export function configFile() {+ return path.join(process.env.HOME || '/root', '.config', 'gemini-api', 'config.yaml')+}+export async function readConfig(file = configFile()) {+ try {+ const info = await lstat(file)+ if (!info.isFile() || info.size > 1 << 20) throw new Error()+ const value = parse(await readFile(file, 'utf8'), { maxAliasCount: 50 })+ if (!isObject(value) || (value.security !== undefined && !isObject(value.security))) throw new Error()+ return value+ } catch (error) {+ if (error.code === 'ENOENT') return {}+ throw new Error('Could not read the Gemini API CLI configuration. Repair config.yaml and try again.')+ }+}+export async function writeConfig(value, file = configFile()) {+ const directory = path.dirname(file)+ const temporary = path.join(directory, '.config-' + randomUUID())+ let handle+ try {+ await mkdir(directory, { recursive: true, mode: 0o700 })+ await chmod(directory, 0o700)+ handle = await open(temporary, 'wx', 0o600)+ await handle.writeFile(stringify(value))+ await handle.close(); handle = undefined+ await rename(temporary, file)+ } catch {+ throw new Error('Could not save the Gemini API CLI configuration. Check the Host filesystem and try again.')+ } finally {+ await handle?.close()+ await rm(temporary, { force: true })+ }+}+export async function verifyCLI(signal) {+ try {+ const { stdout } = await exec('gemini-api', ['--version'], { signal, timeout: 15_000, maxBuffer: 128 << 10 })+ if (!stdout.trim()) throw new Error()+ } catch {+ signal?.throwIfAborted()+ throw new Error('Gemini API CLI is not ready. Reinstall the plugin to prepare the official CLI.')+ }+}+function failure(error) {+ const diagnostic = String(error.stderr || '') + '\n' + String(error.stdout || '')+ if (/\b429\b|RESOURCE_EXHAUSTED|rate.limit/i.test(diagnostic)) return 'Google rate limited the request. Wait and try again.'+ if (/\b403\b|PERMISSION_DENIED|SERVICE_DISABLED/i.test(diagnostic)) return 'Google denied access. Check your Gemini project, API key permissions and regional availability.'+ if (/\b401\b|UNAUTHENTICATED|API_KEY_INVALID|API key not valid|invalid.api.key/i.test(diagnostic) || error.code === 3) return 'Google rejected the API key. Check it in Google AI Studio and try again.'+ if (/ENOTFOUND|ECONN|ETIMEDOUT|network|dial tcp|TLS|timeout|timed out|no such host/i.test(diagnostic) || error.killed) return 'Could not reach the Gemini API. Check the Host network and try again.'+ return 'Gemini API key verification failed. Check your Google project and try again.'+}+export async function validateKey(key, signal) {+ const env = { ...process.env }+ // A candidate must not inherit another Gemini credential or endpoint.+ for (const name of Object.keys(env)) if (name.startsWith('GEMINI_')) delete env[name]+ env.GEMINI_API_KEY = key+ let stdout+ try {+ ;({ stdout } = await exec('gemini-api', ['models', 'list', '--page-size', '1', '--output-format', 'json', '--no-keyring'], {+ env, signal, timeout: 30_000, maxBuffer: 512 << 10,+ }))+ } catch (error) {+ signal?.throwIfAborted()+ throw new Error(failure(error))+ }+ let result+ try { result = JSON.parse(stdout) } catch {}+ // Offline help/usage is not evidence of authenticated access.+ if (!isObject(result) || result.error || !Array.isArray(result.models)) {+ throw new Error('Gemini API CLI returned an unexpected model-list response. Reinstall the plugin and try again.')+ }+}diff --git a/extensions/plugins/gemini-api/src/upstream-instructions.md b/extensions/plugins/gemini-api/src/upstream-instructions.mdnew file mode 100644index 0000000..2c3f8a2--- /dev/null+++ b/extensions/plugins/gemini-api/src/upstream-instructions.md@@ -0,0 +1,6 @@+You have access to gemini-api through the shell.+Use it to call Gemini models, generate or edit media, analyze files, or launch managed agents.+1. Inspect --help or --usage to choose a command, and --schema when building a --body JSON payload.+2. Preview API calls with --dry-run (or --dry-run --output-format json).+3. For discrete JSON output or --jq filtering on streaming commands (generate, agent run, agent status --stream), pass --stream=false --output-format json (--background on agent run returns a single interaction without streaming unless --stream is passed).+4. Capture returned file paths (from media commands) and interaction IDs (from agent/model runs) to continue multi-step tasks.diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex cef3ba7..4bba7cc 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -12,13 +12,14 @@ import { ToolProviders } from './settings/ToolProviders'import { HostFiles } from './files/HostFiles'import { Plugins } from './extensions/Plugins'import { ExtensionDialogs } from './extensions/Dialogs'+import { imageGenerationSettingsEnabled } from './features'type SettingsPage = 'models' | ProviderPage | 'plugins'function currentSettings(): SettingsPage | undefined {if (window.location.pathname === '/settings/models') return 'models'if (window.location.pathname === '/settings/web-search') return 'web-search'- if (window.location.pathname === '/settings/image-generation') return 'image-generation'+ if (window.location.pathname === '/settings/image-generation') return imageGenerationSettingsEnabled ? 'image-generation' : 'models'if (window.location.pathname === '/plugins') return 'plugins'}@@ -374,8 +375,8 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })onClick={() => selectSettings('models')}><SlidersHorizontal size={16} /> {t('Models')}</button><button type="button" aria-current={settingsPage === 'web-search' ? 'page' : undefined}onClick={() => selectSettings('web-search')}><Globe size={16} /> {t('Web search')}</button>- <button type="button" aria-current={settingsPage === 'image-generation' ? 'page' : undefined}- onClick={() => selectSettings('image-generation')}><Image size={16} /> {t('Image generation')}</button>+ {imageGenerationSettingsEnabled && <button type="button" aria-current={settingsPage === 'image-generation' ? 'page' : undefined}+ onClick={() => selectSettings('image-generation')}><Image size={16} /> {t('Image generation')}</button>}</nav>}<div className="settings-content">{settingsPage === 'models' ? <Models userId={userId} /> : settingsPage === 'plugins' ? <Plugins userId={userId} cache={transcriptCache} selected={selectedPlugin} onSelect={setSelectedPlugin} />diff --git a/frontend/src/extensions/Authorizations.tsx b/frontend/src/extensions/Authorizations.tsxindex 6b2713f..cc7b994 100644--- a/frontend/src/extensions/Authorizations.tsx+++ b/frontend/src/extensions/Authorizations.tsx@@ -7,7 +7,7 @@ import { authorizationLabel, authorizationURL, useAuthorization } from './useAutimport { useReturnFocus } from './shared'import { readAuthorizationJSON } from './authorizationFile'import { useMCPAuthorization } from './useMCPAuthorization'-import { connectionLabel, connectionTitle, mcpAuthorizationLabel, mcpAuthorizationRunning } from './connections'+import { authorizationEntryLabels, connectionLabel, connectionTitle, mcpAuthorizationLabel, mcpAuthorizationRunning } from './connections'export function Authorizations({ user, cache, instanceIds }: { user: string; cache: TranscriptCache; instanceIds: string[] }) {const api = useMemo(() => authorizationAPI(user), [user]), mcpAPI = useMemo(() => mcpAuthorizationAPI(user), [user])@@ -33,10 +33,11 @@ export function Authorizations({ user, cache, instanceIds }: { user: string; cac}function AuthorizationRow({ entry, busy, onStart, onCancel, onView, onDisconnect }: { entry: AuthorizationEntry; busy: boolean; onStart: (method: string) => void; onCancel: () => void; onView: () => void; onDisconnect: () => void }) {const { t } = useLocale(), [method, setMethod] = useState(entry.methods[0]?.id ?? '')- return <div className="extension-account-row"><KeyRound size={18} strokeWidth={1.6} /><div className="extension-identity"><strong>{entry.label}</strong><small>{t(entry.inFlight ? 'Authorization in progress' : entry.configured ? 'Connected' : 'Not configured')}{entry.accountLabel && <> · {entry.accountLabel}</>}</small></div>+ const labels = authorizationEntryLabels(entry)+ return <div className="extension-account-row"><KeyRound size={18} strokeWidth={1.6} /><div className="extension-identity"><strong>{entry.label}</strong><small>{t(labels.status)}{entry.accountLabel && <> · {entry.accountLabel}</>}</small></div>{entry.methods.length > 1 && <select className="extension-auth-method" aria-label={t('Authorization method') + ': ' + entry.label} value={method} disabled={busy || entry.inFlight} onChange={event => setMethod(event.target.value)}>{entry.methods.map(method => <option key={method.id} value={method.id}>{t(method.label)}</option>)}</select>}- <button className="model-secondary" type="button" disabled={busy} onClick={() => onStart(method)}>{t(entry.inFlight ? 'Continue authorization' : entry.configured ? 'Authorize again' : entry.methods.length === 1 ? entry.methods[0].label : 'Authorize')}</button>- {entry.configured && entry.canDisconnect && !entry.inFlight && <button type="button" className="extension-text" disabled={busy} onClick={onDisconnect}>{t('Disconnect account')}</button>}+ <button className="model-secondary" type="button" disabled={busy} onClick={() => onStart(method)}>{t(labels.start)}</button>+ {entry.configured && entry.canDisconnect && !entry.inFlight && <button type="button" className="extension-text" disabled={busy} onClick={onDisconnect}>{t(labels.disconnect)}</button>}{entry.inFlight && <button className="extension-text" type="button" disabled={busy} onClick={onCancel}>{t('Cancel authorization')}</button>}{!entry.inFlight && entry.attemptId && <button className="extension-text" type="button" disabled={busy} onClick={onView}>{t('View last result')}</button>}</div>diff --git a/frontend/src/extensions/connections.ts b/frontend/src/extensions/connections.tsindex 31f5f4a..1486bd1 100644--- a/frontend/src/extensions/connections.ts+++ b/frontend/src/extensions/connections.ts@@ -1,4 +1,13 @@-import type { MCPServer, MCPOAuthAttempt } from '../api/extensions'+import type { AuthorizationEntry, MCPServer, MCPOAuthAttempt } from '../api/extensions'++export function authorizationEntryLabels(entry: AuthorizationEntry) {+ const apiKey = entry.methods.length === 1 && entry.methods[0].id === 'api-key'+ return {+ status: entry.inFlight ? 'Authorization in progress' : entry.configured ? apiKey ? 'Configured' : 'Connected' : 'Not configured',+ start: entry.inFlight ? 'Continue authorization' : entry.configured ? apiKey ? 'Update API Key' : 'Authorize again' : entry.methods.length === 1 ? entry.methods[0].label : 'Authorize',+ disconnect: apiKey ? 'Remove API Key' : 'Disconnect account',+ }+}export function pluginOAuthConnections(servers: MCPServer[], instances: string[]): MCPServer[] {return servers.filter(server => server.source === 'plugin' && server.oauthEnabled && instances.some(id => server.name.startsWith(id + '__')))diff --git a/frontend/src/extensions/messages.ts b/frontend/src/extensions/messages.tsindex 318fa9a..d09f465 100644--- a/frontend/src/extensions/messages.ts+++ b/frontend/src/extensions/messages.ts@@ -1,5 +1,18 @@// Shared with Expo; Android's bundle inputs include this external source tree.export const extensionChinese: Readonly<Record<string, string>> = {+ 'Configure API Key': '配置 API Key', 'Update API Key': '更新 API Key', 'Remove API Key': '移除 API Key', 'Configured': '已配置',+ 'Enter your Gemini API key from Google AI Studio.': '请输入从 Google AI Studio 获取的 Gemini API Key。',+ 'Enter a valid Gemini API key without spaces or line breaks.': '请输入有效的 Gemini API Key,不要包含空格或换行。',+ 'Select the API Key authorization method.': '请选择 API Key 授权方式。',+ 'Google rate limited the request. Wait and try again.': 'Google 对请求进行了限流,请稍后重试。',+ 'Google denied access. Check your Gemini project, API key permissions and regional availability.': 'Google 拒绝了访问,请检查 Gemini 项目、API Key 权限和地区可用性。',+ 'Google rejected the API key. Check it in Google AI Studio and try again.': 'Google 拒绝了此 API Key,请到 Google AI Studio 核对后重试。',+ 'Could not reach the Gemini API. Check the Host network and try again.': '无法连接 Gemini API,请检查 Host 网络后重试。',+ 'Gemini API key verification failed. Check your Google project and try again.': 'Gemini API Key 验证失败,请检查 Google 项目后重试。',+ 'Gemini API CLI returned an unexpected model-list response. Reinstall the plugin and try again.': 'Gemini API CLI 返回的模型列表格式异常,请重新安装插件后重试。',+ 'Gemini API CLI is not ready. Reinstall the plugin to prepare the official CLI.': 'Gemini API CLI 尚未就绪,请重新安装插件以准备官方 CLI。',+ 'Could not read the Gemini API CLI configuration. Repair config.yaml and try again.': '无法读取 Gemini API CLI 配置,请修复 config.yaml 后重试。',+ 'Could not save the Gemini API CLI configuration. Check the Host filesystem and try again.': '无法保存 Gemini API CLI 配置,请检查 Host 文件系统后重试。','Plugin changes continue while you use other features.': '插件操作会继续进行,你可以使用其他功能。','Workspace menu': '工作区菜单', 'Close menu': '收起菜单','Credential saved': '凭证已保存', 'Not configured': '尚未配置', 'The credential has been saved.': '凭证已保存。',@@ -93,7 +106,7 @@ export const extensionChinese: Readonly<Record<string, string>> = {"Connect X account": "连接 X 账号","Connect Google account": "连接 Google 账号","Disconnect account": "退出账号授权",- "Authorization is ready.": "账号授权已就绪。",+ "Authorization is ready.": "授权已就绪。","Could not disconnect this account. Refresh to check the current state.": "无法退出账号授权,请刷新检查当前状态。","Choose the Google Workspace permissions to request.": "选择本次请求的 Google Workspace 权限。","Read and write": "读写",diff --git a/frontend/src/features.ts b/frontend/src/features.tsnew file mode 100644index 0000000..08b5147--- /dev/null+++ b/frontend/src/features.ts@@ -0,0 +1,3 @@+// Product surface choices, shared with mobile. Provider implementations remain+// available in source while image generation is offered through CLI plugins.+export const imageGenerationSettingsEnabled = falsediff --git a/frontend/tests/pluginConnections.test.ts b/frontend/tests/pluginConnections.test.tsindex 9ac7f97..082ab4a 100644--- a/frontend/tests/pluginConnections.test.ts+++ b/frontend/tests/pluginConnections.test.ts@@ -1,7 +1,7 @@import assert from 'node:assert/strict'import test from 'node:test'-import { connectionLabel, mcpAuthorizationRunning, pluginOAuthConnections } from '../src/extensions/connections.ts'-import type { MCPServer } from '../src/api/extensions.ts'+import { authorizationEntryLabels, connectionLabel, mcpAuthorizationRunning, pluginOAuthConnections } from '../src/extensions/connections.ts'+import type { AuthorizationEntry, MCPServer } from '../src/api/extensions.ts'const server = (overrides: Partial<MCPServer> = {}): MCPServer => ({ name: 'mail__account', source: 'plugin', state: 'waiting-authorization', oauthEnabled: true, ...overrides })@@ -19,3 +19,12 @@ test('credential authorization and an actual service connection remain distinct'assert.equal(mcpAuthorizationRunning({ ...grant, phase: 'failed' }), false)assert.equal(mcpAuthorizationRunning(undefined), false)})++test('API-key flows show configuration actions while OAuth retains account language', () => {+ const entry = { methods: [{ id: 'api-key', label: 'Configure API Key' }], configured: false } as AuthorizationEntry+ assert.deepEqual(authorizationEntryLabels(entry), { status: 'Not configured', start: 'Configure API Key', disconnect: 'Remove API Key' })+ assert.deepEqual(authorizationEntryLabels({ ...entry, configured: true }), { status: 'Configured', start: 'Update API Key', disconnect: 'Remove API Key' })+ assert.equal(authorizationEntryLabels({ ...entry, inFlight: true }).start, 'Continue authorization')+ const oauth = { ...entry, methods: [{ id: 'oauth', label: 'Connect Google account' }], configured: true }+ assert.deepEqual(authorizationEntryLabels(oauth), { status: 'Connected', start: 'Authorize again', disconnect: 'Disconnect account' })+})diff --git a/internal/host/host.go b/internal/host/host.goindex e3ec68f..1d09a28 100644--- a/internal/host/host.go+++ b/internal/host/host.go@@ -93,7 +93,12 @@ func run(ctx context.Context, c config.Config, newSearchProvider web.Factory, febuilder.ImageAttachments = imagesbuilder.ImageInputEnabled = truebuilder.WebSearcher = search- builder.ImageGenerator = imageGeneration+ // Image generation is currently supplied by CLI plugins. Keep the native+ // implementation and stored settings available for future composition.+ const builtinImageGenerationEnabled = false+ if builtinImageGenerationEnabled {+ builder.ImageGenerator = imageGeneration+ }native := &hostruntime.NativeHost{UserID: c.Host.AccountID, Mode: "host", StartedAt: time.Now().UTC(), ReserveScheduleModel: models.reserve}runCtx, cancel := context.WithCancel(ctx)defer cancel()diff --git a/mobile/src/Me.tsx b/mobile/src/Me.tsxindex 5ab9075..907dc48 100644--- a/mobile/src/Me.tsx+++ b/mobile/src/Me.tsx@@ -1,4 +1,5 @@import { ProtocolDropdown } from './ProtocolDropdown'+import { imageGenerationSettingsEnabled } from '../../frontend/src/features'import { changeProtocolURL, modelProtocol, modelRequestURL, protocolNames, protocolURLs, type ModelProtocol } from '../../frontend/src/settings/modelProtocol'import { languages, useLocale } from './locale'import { useEffect, useState } from 'react'@@ -57,7 +58,7 @@ export function Me({ api, section, open, close, exitAccount }: {['web-search', '网页搜索', Search],['image-generation', '图片生成', Drawing],['language', '语言', Languages],- ] as const).map(([id, label, Icon], index) => <Pressable accessibilityRole="button" key={id}+ ] as const).filter(([id]) => id !== 'image-generation' || imageGenerationSettingsEnabled).map(([id, label, Icon], index) => <Pressable accessibilityRole="button" key={id}onPress={() => id === 'language' ? setLanguageOpen(true) : open(id)}style={[s.row, { minHeight: 54, gap: 14 }, index > 0 && { borderTopWidth: StyleSheet.hairlineWidth, borderColor: edge }]}><Icon size={20} color={muted} strokeWidth={1.7} />@@ -100,7 +101,7 @@ export function Me({ api, section, open, close, exitAccount }: {if (!modelDirty) { proceed(); return }Alert.alert(t('放弃未保存的修改?'), undefined, [{ text: t('取消'), style: 'cancel' }, { text: t('放弃修改'), style: 'destructive', onPress: proceed }])}}><Models api={api} onDirtyChange={setModelDirty} /></Sheet>}- {section && section !== 'models' && <Sheet title={t(providerLabels[section])} onClose={close}><Providers key={section} api={api} page={section} /></Sheet>}+ {section && section !== 'models' && (section !== 'image-generation' || imageGenerationSettingsEnabled) && <Sheet title={t(providerLabels[section])} onClose={close}><Providers key={section} api={api} page={section} /></Sheet>}</>}diff --git a/mobile/src/extensions/Authorizations.tsx b/mobile/src/extensions/Authorizations.tsxindex 3eebf01..fba87fc 100644--- a/mobile/src/extensions/Authorizations.tsx+++ b/mobile/src/extensions/Authorizations.tsx@@ -7,7 +7,7 @@ import { useLocale } from '../locale'import { accent, Button, edge, Field, Hint, ink, muted, Panel, s } from '../ui'import { authorizationAPI, mcpAuthorizationAPI } from './api'import { useMCPAuthorization } from '../../../frontend/src/extensions/useMCPAuthorization'-import { connectionLabel, connectionTitle, mcpAuthorizationLabel, mcpAuthorizationRunning } from '../../../frontend/src/extensions/connections'+import { authorizationEntryLabels, connectionLabel, connectionTitle, mcpAuthorizationLabel, mcpAuthorizationRunning } from '../../../frontend/src/extensions/connections'import { Choice } from './Choice'import { Feedback, TextAction, Toolbar, type ScreenProps, x } from './shared'@@ -49,10 +49,11 @@ export function Authorizations({ connections, onBusyChange, onBack }: Pick<Scree}function Account({ entry, busy, onStart, onCancel, onView, onDisconnect }: { entry: AuthorizationEntry; busy: boolean; onStart: (method: string) => void; onCancel: () => void; onView: () => void; onDisconnect: () => void }) {const { t } = useLocale(), [method, setMethod] = useState(entry.methods[0]?.id ?? '')- return <Panel style={a.panel}><View style={a.status}><KeyRound size={19} color={muted} strokeWidth={1.6} /><View style={x.identity}><Text style={x.heading}>{entry.label}</Text><Text style={s.meta}>{t(entry.inFlight ? 'Authorization in progress' : entry.configured ? 'Connected' : 'Not configured')}{entry.accountLabel ? ' · ' + entry.accountLabel : ''}</Text></View></View>+ const labels = authorizationEntryLabels(entry)+ return <Panel style={a.panel}><View style={a.status}><KeyRound size={19} color={muted} strokeWidth={1.6} /><View style={x.identity}><Text style={x.heading}>{entry.label}</Text><Text style={s.meta}>{t(labels.status)}{entry.accountLabel ? ' · ' + entry.accountLabel : ''}</Text></View></View>{entry.methods.length > 1 && <Choice label="Authorization method" value={method} options={entry.methods.map(method => ({ value: method.id, label: t(method.label) }))} disabled={busy || entry.inFlight} onChange={setMethod} />}- <TextAction label={entry.inFlight ? 'Continue authorization' : entry.configured ? 'Authorize again' : entry.methods.length === 1 ? entry.methods[0].label : 'Authorize'} disabled={busy} onPress={() => onStart(method)} />- {entry.configured && entry.canDisconnect && !entry.inFlight && <TextAction label="Disconnect account" disabled={busy} onPress={onDisconnect} />}+ <TextAction label={labels.start} disabled={busy} onPress={() => onStart(method)} />+ {entry.configured && entry.canDisconnect && !entry.inFlight && <TextAction label={labels.disconnect} disabled={busy} onPress={onDisconnect} />}{entry.inFlight && <TextAction label="Cancel authorization" disabled={busy} onPress={onCancel} />}{!entry.inFlight && entry.attemptId && <TextAction label="View last result" disabled={busy} onPress={onView} />}</Panel>diff --git a/scripts/smoke-image.sh b/scripts/smoke-image.shindex 4eedaaa..37db659 100755--- a/scripts/smoke-image.sh+++ b/scripts/smoke-image.sh@@ -16,8 +16,9 @@ docker run --rm --entrypoint /bin/sh "$image" -ec '! command -v agent-browser! command -v xurl! command -v gws+ ! command -v gemini-apitest ! -e /usr/share/go-bot/skill-seed- for plugin in agent-browser officecli x google-workspace; do+ for plugin in agent-browser officecli x google-workspace gemini-api; dotest -s "/usr/share/go-bot/plugins/$plugin/package.json"test -s "/usr/share/go-bot/plugins/$plugin/scripts/install.mjs"test -s "/usr/share/go-bot/plugins/$plugin/UPSTREAM_LICENSE"diff --git a/tests/integration/browser_use_docker_test.go b/tests/integration/browser_use_docker_test.goindex d05d2f0..e812929 100644--- a/tests/integration/browser_use_docker_test.go+++ b/tests/integration/browser_use_docker_test.go@@ -61,7 +61,7 @@ func TestDockerBrowserSkillAndSessionIsolation(t *testing.T) {for _, tool := range body.Tools {tools[tool.Name] = true}- if !tools["generateimage"] || !tools["web_search"] || !tools["skill"] {+ if tools["generateimage"] || !tools["readimage"] || !tools["present"] || !tools["web_search"] || !tools["skill"] {t.Error("expected built-in tools were not registered")}var userMessage string@@ -137,12 +137,9 @@ printf "fresh browser session"} else {check("browser-cold", "fresh browser session")}- case "Image without configuration":- if outputs["image-without-key"] == "" {- output = webCall("image-without-key", "generateimage", `{"prompt":"a flower"}`)- } else {- check("image-without-key", "Image generation is not configured")- }+ case "Built-in image generation disabled":+ // The model can read and present plugin-generated images, but no+ // built-in generation tool is advertised, even with saved settings.default:t.Errorf("unexpected user message %q", userMessage)}@@ -250,5 +247,5 @@ printf "fresh browser session"t.Fatal(err)}send(second, "Browser after restart", after)- send(newSession(), "Image without configuration", "")+ send(newSession(), "Built-in image generation disabled", "")}diff --git a/tests/integration/web_chat_docker_test.go b/tests/integration/web_chat_docker_test.goindex 8414cee..32f160d 100644--- a/tests/integration/web_chat_docker_test.go+++ b/tests/integration/web_chat_docker_test.go@@ -30,6 +30,19 @@ func TestDockerWebChatPreview(t *testing.T) {var modelCalls atomic.Int32release := make(chan struct{})model := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ var request struct{ Tools []struct{ Name string } }+ if err := json.NewDecoder(r.Body).Decode(&request); err != nil {+ t.Error(err)+ http.Error(w, "invalid request", 400)+ return+ }+ tools := map[string]bool{}+ for _, tool := range request.Tools {+ tools[tool.Name] = true+ }+ if tools["generateimage"] || !tools["readimage"] || !tools["present"] {+ t.Error("Host must retain image reading and delivery without registering native generation")+ }call := modelCalls.Add(1)if call == 1 {select {@@ -49,7 +62,7 @@ func TestDockerWebChatPreview(t *testing.T) {model.Start()defer model.Close()- c := config.Default()+ c := dockerFixtureConfig()c.Model.Main = config.MainModel{Provider: "custom", Name: "preview-fixture", Protocol: "responses",BaseURL: fmt.Sprintf("http://host.docker.internal:%d", listener.Addr().(*net.TCPAddr).Port),Auth: "bearer", APIKey: "fixture-model-key", ContextWindow: config.ModelContextWindow}