feat: 新增统一适配 SDK 与 MCP/Dify 平台适配#388
Open
shifang0511 wants to merge 1 commit into
Open
Conversation
Resolve issue TencentCloud#235 (cross-platform adapters for the memory plugin) by distilling the Gateway boundary into a reusable SDK and adding two new platform integrations on top of it. - src/sdk: TdaiGatewayClient (typed, retrying HTTP client), the MemoryAdapter interface + GatewayMemoryAdapter, and buildMemoryTools() neutral tool descriptors — the single interface a new platform implements/consumes. - src/adapters/mcp: pure JSON-RPC 2.0 stdio MCP server exposing memory as tools; one server unlocks Claude Code, Codex, Cursor, and Cline. New bin: tdai-memory-mcp. - src/adapters/dify: OpenAPI schema for Dify custom tools (declarative, no glue). - docs/adapters: architecture + recall/capture data-flow diagrams, an OpenClaw/Hermes/MCP/Dify comparison, and an "add a platform in ~30 lines" guide. Covers all four acceptance tiers (architecture → one platform → two platforms + comparison → unified SDK). 43 new tests; full suite 110 passing. Verified end-to-end against a live Gateway: MCP capture then search round-trips real data. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
|
Thank you for submitting this PR and participating in Tencent Rhino-bird Open-source Training Program! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
Resolves #235
本 PR 将现有 Gateway 边界抽象为一套统一适配 SDK,并基于这套 SDK 新增 MCP 与 Dify 两个平台适配,让“为新平台接入 TDAI Memory”变得更简单、更统一,部分平台可以做到主要依赖配置完成接入。
本次实现覆盖 issue 中的四档验收要求:架构说明、单平台读写适配、双平台适配与对比文档、统一适配 SDK。
验收标准对照
docs/adapters/ARCHITECTURE.md:说明核心TdaiCore能力、现有适配器关系,以及 recall/capture 数据流图src/adapters/mcp/:提供 MCP stdio server,暴露tdai_memory_search、tdai_conversation_search、tdai_recall、tdai_capture等能力src/adapters/dify/Dify OpenAPI 自定义工具适配,并补充docs/adapters/COMPARISON.mdsrc/sdk/与docs/adapters/ADDING-A-PLATFORM.md,沉淀统一接口和新增平台接入指南主要变更
src/sdk:统一适配 SDKTdaiGatewayClient:为 Gateway 各接口提供类型化、无额外依赖的 HTTP client,支持超时、有限重试、Bearer 鉴权和类型化TdaiGatewayError。MemoryAdapter接口与GatewayMemoryAdapter:统一抽象recall、searchMemories、searchConversations、capture、endSession、health等能力。buildMemoryTools():生成与宿主无关的工具描述,包括工具名、描述、JSON Schema 和非抛错式invoke,可映射到 MCP、Dify、Vercel AI SDK、OpenAI functions 等平台。src/adapters/mcp:MCP 平台适配tdai-memory-mcpbin 入口和不同宿主的配置示例。src/adapters/dify:Dify 平台适配sys.conversation_id的 recall/capture 流程。docs/adapters:文档补充测试验证
tdai_conversation_search进程中检索到对应内容,验证 MCP -> SDK -> Gateway -> Core 的完整读写链路。strict+nodenext配置下类型检查通过。npm pack已确认包含新增源码并排除测试文件,产物大小约 675 KB,低于 CI 的 2 MB 限制。其他说明
TdaiCore、Gateway、OpenClaw/Hermes 适配器。