Skip to content

feat(integrations): add opencode adapter - #660

Open
Syt3s wants to merge 1 commit into
TencentCloud:mainfrom
Syt3s:issue-235-opencode-adapter
Open

feat(integrations): add opencode adapter#660
Syt3s wants to merge 1 commit into
TencentCloud:mainfrom
Syt3s:issue-235-opencode-adapter

Conversation

@Syt3s

@Syt3s Syt3s commented Jul 31, 2026

Copy link
Copy Markdown

Description | 描述

新增完整的 OpenCode Agent Memory 适配层,通过 OpenCode 原生插件生命周期接入现有 memory-tencentdb Gateway。

主要功能:

  • 使用 chat.message 自动召回相关记忆并注入 synthetic context
  • 使用 session.idle 自动捕获新完成的 user/assistant 回合
  • 使用 session.deleteddispose 执行最终捕获、Session flush 和资源清理
  • 提供以下七个显式工具:
    • agent_memory_health
    • agent_memory_recall
    • agent_memory_capture
    • agent_memory_search
    • agent_conversation_search
    • agent_memory_session_end
    • agent_memory_seed
  • 通过 assistant message ID 和 session 串行队列避免重复捕获
  • 排除 synthetic、recalled、reasoning、tool、summary、失败及未完成内容,防止记忆递归污染
  • 实现 Gateway HTTP client、Bearer 鉴权、超时、响应校验和结果限长
  • 实现 Gateway sidecar 自动发现、启动、健康检查、日志和进程所有权管理
  • 实现 circuit breaker、恢复节流和非致命降级
  • 新增独立 OpenCode 发布包、配置模板、中英文文档和完整测试

架构保持 Gateway-first:

OpenCode
→ OpenCode adapter
→ memory-tencentdb Gateway
→ StandaloneHostAdapter
→ TdaiCore
→ L0/L1/L2/L3

OpenCode adapter 不直接创建 TdaiCore,也不直接读写 memory 内部存储文件。

Related Issue | 关联 Issue

N/A

Change Type | 修改类型

  • Bug fix | Bug 修复
  • New feature | 新功能
  • Documentation update | 文档更新
  • Code optimization | 代码优化

Self-test Checklist | 自测清单

  • Verified locally | 本地验证通过
  • No existing features affected | 无影响现有功能

验证结果:

  • npx tsc -p integrations/opencode/tsconfig.json:通过
  • npm run build:通过
  • OpenCode adapter tests:9 个测试文件、26 个测试通过
  • 全量回归测试:13 个测试文件、93 个测试通过
  • OpenCode 独立包和根包 npm pack --dry-run:通过
  • 构建入口确认只导出一个 OpenCode plugin function,避免重复注册 hooks

Additional Notes | 其他说明

  • 不修改现有 L0/L1/L2/L3 算法和存储格式
  • 不改变现有 OpenClaw 和 Hermes 接入路径
  • Gateway 不可用时不会阻断 OpenCode 主任务
  • 适配层基于 @opencode-ai/plugin 1.18.10 构建和验证

Signed-off-by: lkx <lkxyout@gmail.com>
@Maxwell-Code07

Copy link
Copy Markdown
Collaborator

Thank you for your interest and contributions! We will review your code and get back to you as soon as possible!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants