Skip to content

follow-up(adapter): 添加 Dify 工作流记忆适配器#438

Open
Qiyuanqiii wants to merge 2 commits into
TencentCloud:mainfrom
Qiyuanqiii:fix/issue-235-mcp-adapter
Open

follow-up(adapter): 添加 Dify 工作流记忆适配器#438
Qiyuanqiii wants to merge 2 commits into
TencentCloud:mainfrom
Qiyuanqiii:fix/issue-235-mcp-adapter

Conversation

@Qiyuanqiii

@Qiyuanqiii Qiyuanqiii commented Jul 9, 2026

Copy link
Copy Markdown

Refs #235

定位说明

根据维护者的分流建议,本 PR 已重新收窄范围:不再作为 #235 的通用 Gateway client / 跨平台适配器总方案,而是作为 #316 之后的 Dify 平台适配 follow-up。

#316 已覆盖 shared Gateway client / adapter kit 的基础边界,因此本 PR 移除了原先新增的通用 Gateway SDK 抽象,只保留 Dify workflow 到现有 Gateway /recall/capture 路由的字段映射和文档。

本 PR 做了什么

  • 添加 DifyWorkflowMemoryAdapter,用于把 Dify workflow 输入映射到 TencentDB Agent Memory Gateway:
    • recall 阶段:query / inputs.query -> /recall
    • capture 阶段:query + answer -> /capture
  • 为 Dify 构造稳定的 session_key
    • platform:user:conversation
    • 支持可选 session_id
  • 支持两种接入方式:
    • 注入 Dify 专属 memory port
    • 使用 Dify-scoped HTTP Gateway options 调用 /recall/capture
  • 新增 docs/DIFY-ADAPTER.md,说明 Dify workflow / HTTP-only 节点接入方式
  • 更新 README 文档入口

非目标范围

本 PR 不再包含:

  • 通用 Gateway SDK / client 抽象
  • MCP server
  • Python SDK
  • Codex / Claude hooks
  • core/runtime 改动
  • CI 或打包流程改动

这些应拆到更小的后续 PR,或基于 #316 的 Gateway client 边界继续推进。

验证

npm.cmd test -- src/adapters/dify/index.test.ts
npm.cmd test
npm.cmd run build
git diff --check

验证结果:

  • Dify targeted tests:6 passed
  • Full test:73 passed
  • Build:passed
  • Diff check:passed

验证截图

image

@YOMXXX

YOMXXX commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Triage note for #235 duplicate/scope cleanup:

The shared Gateway client / generic adapter SDK part now overlaps with #316, which is the currently verified lightweight baseline for #235. #316 is CI green, locally verified, and keeps the reusable boundary small: GatewayMemoryClient + createGatewayPlatformAdapter() + lifecycle mapping tests + focused docs.

For this PR, please consider re-scoping rather than merging it as-is:

  • Rebase/reuse the feat(adapters): add gateway client adapter kit #316 Gateway client boundary instead of carrying another parallel Gateway SDK/client abstraction.
  • Split remaining unique value into smaller PRs by platform or concern, for example MCP server, Dify adapter, Codex/Claude hooks, Python SDK, docs, or CI changes.
  • Keep unrelated core/runtime changes out of the adapter PR unless they are strictly required and covered by focused tests.

This is not a rejection of the platform-specific work. It is a request to avoid merging multiple competing adapter frameworks from one broad #235 PR now that a smaller canonical gateway-client base exists.

@Qiyuanqiii Qiyuanqiii changed the title feat: add gateway adapter SDK follow-up(adapter): 添加 Dify 工作流记忆适配器 Jul 9, 2026
@Qiyuanqiii

Copy link
Copy Markdown
Author

#235重复/示波器清理的分诊说明:

共享网关客户端/通用适配器SDK部分现在与#316重叠,#316是#235目前经过验证的轻量级基线。#316 是 CI 绿色,经过本地验证,并且保持可重用边界较小:GatewayMemoryClient + createGatewayPlatformAdapter() + 生命周期映射测试 + 聚焦文档。

对于这个PR,请考虑重新划定范围,而不是按原样合并:

  • 重新基底/重复使用Feat(适配器):添加网关客户端适配器套件 #316Gateway 客户端边界,而不是承载另一个并行的 Gateway SDK/客户端抽象。
  • 将剩余的唯一值按平台或关注点拆分成较小的PR,例如MCP服务器、Dify适配器、Codex/Claude钩子、Python SDK、文档或CI变更。
  • 除非严格要求且有针对性测试覆盖,否则不涉及核心/运行时的更改。

这并不是对平台特定作品的否定。这是请求避免在一个较小的规范网关-客户端基础存在的情况下,从一个广泛的 #235 PR 合并多个竞争的适配器框架。

感谢大佬您的分流说明,我接受这个方向。您指出 #316 已经作为 #235 的 shared Gateway client / adapter kit 基线后,我重新收窄了 #438 的定位:不再把它作为通用 Gateway SDK 或跨平台适配器总方案,而是改成一个 Dify-only follow-up。

本次已推送更新 commit:7ec8901

调整点:

  • 移除了本 PR 中的 TdaiGatewayClient / createGatewaySessionKey / GatewayClientError 等通用 Gateway SDK 抽象,避免和 feat(adapters): add gateway client adapter kit #316 的 Gateway client 边界重叠。
  • 保留并聚焦 Dify workflow 适配:Dify 输入字段映射、稳定 session_key 构造、/recall/capture 两条 Gateway 路径。
  • 将文档从泛化的跨平台 adapter guide 改为 docs/DIFY-ADAPTER.md,明确说明本 PR 不包含 MCP server、Python SDK、Codex/Claude hooks、core/runtime 或 CI 改动。
  • 测试也改成只覆盖 Dify 适配器行为和 Dify-scoped HTTP 路径。

验证:

  • npm.cmd test -- src/adapters/dify/index.test.ts:6 passed
  • npm.cmd test:73 passed
  • npm.cmd run build:passed
  • git diff --check:passed

这样 #438 现在只作为 #316 之后的 Dify 平台映射后续,不再和 #235 的主基线方案竞争。

@Qiyuanqiii

Copy link
Copy Markdown
Author

#235重复/示波器清理的分诊说明:

共享网关客户端/通用适配器SDK部分现在与#316重叠,#316是#235目前经过验证的轻量级基线。#316 是 CI 绿色,经过本地验证,并且保持可重用边界较小:GatewayMemoryClient + createGatewayPlatformAdapter() + 生命周期映射测试 + 聚焦文档。

对于这个PR,请考虑重新划定范围,而不是按原样合并:

  • 重新基底/重复使用Feat(适配器):添加网关客户端适配器套件 #316Gateway 客户端边界,而不是承载另一个并行的 Gateway SDK/客户端抽象。
  • 将剩余的唯一值按平台或关注点拆分成较小的PR,例如MCP服务器、Dify适配器、Codex/Claude钩子、Python SDK、文档或CI变更。
  • 除非严格要求且有针对性测试覆盖,否则不涉及核心/运行时的更改。

这并不是对平台特定作品的否定。这是请求避免在一个较小的规范网关-客户端基础存在的情况下,从一个广泛的 #235 PR 合并多个竞争的适配器框架。

大佬大佬,能不能麻烦您有空再帮忙看下这个收窄后的方向是否符合预期,如果您仍然觉得应该基于 #316 merge 后再继续拆分,我也可以继续调整。

@Maxwell-Code07

Copy link
Copy Markdown
Collaborator

Thank you for submitting this PR and participating in Tencent Rhino-bird Open-source Training Program!
We have successfully received your submission. The program is currently in full swing, and we will complete the Code Review for you as soon as possible. Please keep an eye on the status notifications for this PR so you can follow up promptly once the review feedback is provided.
Thanks again for your contribution and open-source spirit! 🚀

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.

3 participants