Repository navigation
Releases
Releases · In-dor/opencode-gemini-grounding
v1.5.0
🎉 v1.5.0 Release Notes / 更新说明
🇨🇳 中文更新说明
🚀 旗舰默认模型与容灾升级
- 默认主模型升级为
gemini-4-hydrogen:提供更强的搜索整合与深度思考表现;默认单模型请求超时提升至 60s(总容灾超时 180s)。 - 可配置容灾降级链:默认降级链为
gemini-4-hydrogen -> gemini-3.8-flash -> gemini-3.5-flash-lite -> gemini-3.7-flash -> gemini-3.1-flash-lite -> gemini-3-flash-preview -> gemini-2.5-flash,支持通过options.fallbackModels或环境变量OPENCODE_GOOGLE_FALLBACK_MODELS自定义。 - 空响应 / 截断保护:遇到空输出、
MAX_TOKENS截断或promptFeedback.blockReason安全拦截时自动降级下一候选模型,且严禁将异常/空结果写入缓存。
🖥️ OpenChamber 网页搜索 UI 配置面板接入 (ctx.integration)
- 自动在 OpenChamber 「设置 → 网页搜索 → Google Gemini Grounding」 注册完整可视化表单,支持配置 API Key、可选 Base URL(反代网关)与可选 Preferred Model,并自动声明环境变量状态检测(
OPENCODE_GOOGLE_API_KEY、GOOGLE_API_KEY、GOOGLE_GENERATIVE_AI_API_KEY、GEMINI_API_KEY)。 - 尊重用户在 UI 中已选定的默认搜索源或禁用状态(
setDefaultWebsearch仅在显式设置为true或当前未指定默认源时设为google-grounding)。
🗄️ 全面兼容 OpenCode V2.2.6+ opencode.db 与多级配置解析
- 只读 SQLite 凭据读取:内置兼容
node:sqlite与bun:sqlite的readCredentialFromSqlite,支持 mtime + WAL 文件变更感知缓存,自动识别~/.local/share/opencode/opencode.dbcredential表中的key/oauth凭据与表单metadata(baseURL、model)。 - 完整配置优先级与运行时联动:支持实时
ctx.integration、ctx.provider、ctx.config,祖先目录项目级opencode.json(c)/.opencode/opencode.json(c),传统auth.json,以及{env:VAR}/{file:path/to/secret}(支持~/与相对路径)占位符解析。
🔐 智能认证分流、思考深度控制与稳定性加固
- 智能认证头分流 (
authMode):Google 官方*.googleapis.com端点默认仅发x-goog-api-key(避免双头冲突);OAuth 凭据仅发Authorization: Bearer;第三方网关(OneAPI / NewAPI 等)发送双头,并支持authMode(auto/x-goog-api-key/bearer/both)与自定义headers合并。 - 原生深度思考保留 &
#variant归一化:默认不注入thinkingConfig以保留gemini-4-hydrogen服务端原生HIGH深度思考;支持通过thinkingLevel/OPENCODE_GOOGLE_THINKING_LEVEL按需调节(LOW/MEDIUM/HIGH/XHIGH);normalizeModelId自动剥离google/前缀与#variant后缀。 - 全信号并发合并 & 安全脱敏:Singleflight 并发去重支持多订阅者独立
AbortSignal隔离;缓存键纳入非默认baseURL并在过期时调用storage.remove清理;非 JSON 401/403 立即抛出FatalError终止,超长错误信息自动截断并对key=/ API Key / Bearer Token 脱敏;卡片 URL 强制校验http(s)://。 - 测试覆盖升级:单元测试扩展至 23 项并全部通过(
npm test)。
🇺🇸 English Release Notes
🚀 Default Model & Fallback Chain Upgrade
- Default model upgraded to
gemini-4-hydrogen: With per-model request timeout raised to 60s (requestTimeoutMs) and overall chain timeout at 180s (timeoutMs). - Customizable fallback chain: Defaults to
gemini-4-hydrogen -> gemini-3.8-flash -> gemini-3.5-flash-lite -> gemini-3.7-flash -> gemini-3.1-flash-lite -> gemini-3-flash-preview -> gemini-2.5-flash, configurable viaoptions.fallbackModelsorOPENCODE_GOOGLE_FALLBACK_MODELS. - Empty /
MAX_TOKENS/ blocked fallback: Automatically falls back when a model returns empty output,MAX_TOKENS, orpromptFeedback.blockReason, without pollutingctx.storagecache.
🖥️ OpenChamber Web Search UI Integration (ctx.integration)
- Registers Google Gemini Grounding (
google-grounding) in OpenChamber Settings → Web Search with a configuration form (API Key, optional Base URL, optional Preferred Model) and environment variable detection (OPENCODE_GOOGLE_API_KEY,GOOGLE_API_KEY,GOOGLE_GENERATIVE_AI_API_KEY,GEMINI_API_KEY). - Preserves existing user
websearchdefaults or disabled preference unlesssetDefaultWebsearch: trueis set or no default is currently selected.
🗄️ OpenCode V2.2.6+ opencode.db & Full Config Resolution
- Safe read-only SQLite credential reader: Supports
node:sqliteandbun:sqlitewith mtime/WAL-aware caching (readCredentialFromSqlite) to read activekey/oauthcredentials andmetadata(baseURL,model) from~/.local/share/opencode/opencode.db. - Live runtime & project-level resolution: Integrates with live
ctx.integration,ctx.provider, andctx.config, ancestor projectopencode.json(c)/.opencode/opencode.json(c), legacyauth.json,GOOGLE_GENERATIVE_AI_API_KEY, and{env:VAR}/{file:path/to/secret}placeholders.
🔐 Smart Auth Routing, Thinking Config & Hardening
- Smart auth header routing (
authMode): Official*.googleapis.comendpoints sendx-goog-api-keyonly; OAuth sendsAuthorization: Beareronly; custom third-party proxies send dual headers, with explicitauthMode(auto|x-goog-api-key|bearer|both) and customheadersmerging. - Native thinking preservation &
#variantnormalization: OmitsthinkingConfigby default to keepgemini-4-hydrogen's native server-sideHIGHthinking; optionally injectsgenerationConfig.thinkingConfig.thinkingLevel(LOW/MEDIUM/HIGH/XHIGH) for Gemini 3/4 models;normalizeModelIdstrips bothgoogle/prefixes and#variantsuffixes. - Subscriber-aware Singleflight & hardening: Per-caller
AbortSignalisolation in Singleflight deduplication; non-defaultbaseURLcache key isolation and expired entry cleanup viastorage.remove; immediateFatalErroron non-JSON 401/403; error truncation & secret redaction (key=, API keys, Bearer tokens); stricthttp(s)://card URL sanitization. - Expanded tests: All 23 unit tests passing via
npm test.