Skip to content

v1.4.0:SDK 破坏性变更 + HTTP 代理 + OTLP 可观测性

发布日期:2026年4月8日


🎯 一句话总结

SDK 数据模型有破坏性变更(Diff 格式和 UserMessage.variant),新增 HTTP 代理、OTLP 可观测性导出、PDF 拖拽附件、--dangerously-skip-permissions 模式。


⚠️ SDK 破坏性变更

如果你使用 JavaScript SDK 开发,需要注意以下变更:

Diff 元数据变更

Diff 不再包含 tofrom 的完整文件内容,只保留 patch 字段(unified diff 格式)。所有快照 Diff 也统一为这个格式。

UserMessage.variant 移动

userMessage.variant 字段移到了 userMessage.model.variant

如果你不开发 SDK 应用,这些变更不影响你的使用。


🆕 新功能:HTTP 代理支持

这次更新了什么?

OpenCode 现在支持完整的 HTTP 代理。

这有什么用?

在企业内网或需要代理的网络环境中,OpenCode 可以通过 HTTP/HTTPS 代理连接外部 API,不再受限于直连。


🆕 新功能:OTLP 可观测性导出

这次更新了什么?

新增 OTLP(OpenTelemetry Protocol)可观测性数据导出支持。

这有什么用?

可以将 OpenCode 的遥测数据(traces、metrics)导出到 Grafana、Jaeger 等 OpenTelemetry 兼容的后端,用于监控和调试。

适合企业用户或需要对 AI 调用链做可观测性分析的场景。


🆕 新功能:PDF 拖拽附件

这次更新了什么?

TUI 现在支持拖拽 PDF 文件作为附件发送给 AI。

这有什么用?

之前只能拖拽图片,现在可以直接拖入 PDF 文件让 AI 分析内容。


🆕 新功能:跳过权限确认模式

这次更新了什么?

新增 opencode run --dangerously-skip-permissions 命令行选项,自动批准非拒绝列表中的权限提示。

这有什么用?

CI/CD 流水线或自动化场景中,不希望每次都手动确认权限。使用此选项可以跳过确认(但仍有安全底线——被拒绝的权限不会被自动批准)。

⚠️ 仅在受信任的环境中使用此选项。


🆕 新功能:模型变体切换快捷键

这次更新了什么?

TUI 新增了「Switch model variant」的可自定义快捷键。

这有什么用?

你可以为切换模型变体绑定自己喜欢的快捷键,而不必使用默认的。


🔧 问题修复

  • Alibaba 提供商限流:遇到限流错误现在会自动重试,而不是直接失败
  • OpenRouter 兼容性:修复了 OpenRouter 提供商的问题
  • GitHub Copilot Anthropic 推理级别:对齐了推理级别设置,移除了不正确的 Qwen 变体
  • TypeScript LSP 内存泄漏:使用原生项目配置,减少了 TypeScript LSP 的内存占用

📊 要不要升级?

情况建议
使用 SDK 开发✅ 必须升级(破坏性变更)
需要 HTTP 代理✅ 强烈推荐
CI/CD 自动化✅ 强烈推荐
使用 Desktop 版✅ 推荐
正常使用中✅ 推荐

⬆️ 升级命令

bash
opencode upgrade

📋 技术细节

点击展开完整更新列表

Breaking Changes in SDK

Diff metadata

The diffs contained in the metadata for the edit and patch tool will no longer contain a to and from field with full file contents. they will only contain a patch field with the unified diff. Additionally all snapshot diffs contained in user message and session diff will follow this format.

UserMessage.variant

Before the user message had a variant field - it is now nested under model so userMessage.model.variant

Core

  • Added OTLP observability export support.
  • Fixed failed web fetches leaving stale timeouts behind.
  • Improved opencode login transport error messages.
  • Retried Alibaba provider rate-limit errors instead of failing immediately.
  • Kept model variants scoped to the selected model.
  • Added full HTTP proxy support.
  • Fixed OpenRouter provider issues.
  • Aligned GitHub Copilot Anthropic reasoning levels and removed incorrect Qwen variants.
  • Reduced TypeScript LSP memory use by using the native project config. (@derekbar90)

TUI

  • Added a keybinding option for "Switch model variant". (@ariane-emory)
  • Added PDF drag and drop for attachments. (@gitpush-gitpaid)
  • Added opencode run --dangerously-skip-permissions to auto-approve non-denied permission prompts.

Desktop

  • Improved subagent sessions with clearer titles, navigation, and progress states.
  • Moved auto-accept permissions into Settings.
  • Showed full file names on attachment chips.

Thank you to 4 community contributors:

  • @derekbar90: fix(lsp): MEMORY LEAK: ensure typescript server uses native project config (#19953)
  • @mchenco: docs: update Cloudflare provider setup to reflect /connect prompt flow (#20589)
  • @gitpush-gitpaid: feat(opencode): Add PDF attachment Drag and Drop (#16926)
  • @ariane-emory: fix(tui): use sentence case for theme mode command palette items (#21192), feat(tui): allow variant_list keybind for the "Switch model variant" command (#21185)

← 返回更新日志