Skip to content

feat(adapters): add Claude Code Gateway hook adapter#326

Open
Arreboi06 wants to merge 4 commits into
TencentCloud:mainfrom
Arreboi06:feature/cross-platform-adapter-sdk
Open

feat(adapters): add Claude Code Gateway hook adapter#326
Arreboi06 wants to merge 4 commits into
TencentCloud:mainfrom
Arreboi06:feature/cross-platform-adapter-sdk

Conversation

@Arreboi06

@Arreboi06 Arreboi06 commented Jun 30, 2026

Copy link
Copy Markdown

Summary

This PR has been rescoped per the #235 duplicate/scope cleanup note.

It now reuses the #316 Gateway client boundary instead of carrying a parallel generic adapter SDK. The remaining unique value is a focused Claude Code platform helper built on top of GatewayMemoryClient + createGatewayPlatformAdapter().

What changed

  • Keeps the feat(adapters): add gateway client adapter kit #316 baseline shape: GatewayMemoryClient, createGatewayPlatformAdapter(), Gateway lifecycle mapping tests, and focused adapter docs.
  • Adds a small Claude Code Gateway hook helper:
    • createClaudeCodeGatewayAdapter() maps prompt prefetch, completed-turn capture, search, and session flush to the Gateway adapter lifecycle.
    • createClaudeCodeContextFromHookInput() maps Claude Code hook JSON identity fields (session_id, cwd) into adapter context.
    • createClaudeCodeSessionKey() derives stable workspace/session keys for TDAI memory grouping.
  • Exports the Gateway and Claude Code helpers from the package entrypoint and adapter barrel.
  • Adds focused tests and a Claude Code usage note.

Why this shape

The previous version tried to solve the challenge-level adapter goal by introducing a broad SDK and multiple platform implementations in one PR. After #316 became the verified lightweight baseline, that shape would create competing adapter frameworks.

This version intentionally keeps the reusable seam small and canonical:

  • no second Gateway client abstraction
  • no generic PlatformAdapter/BasePlatformAdapter SDK
  • no unrelated core/runtime storage changes
  • no mixed OpenClaw/Hermes/Claude platform bundle

While #316 is still open, this branch is based on the #316 commits. The unique delta over #316 is the Claude Code follow-up only: 6 files, +407/-3.

Verification

Local verification after the rescope:

npm.cmd test -- --reporter=dot
# Test Files  6 passed (6)
# Tests       75 passed (75)

npm.cmd run build:plugin
# Build complete

git diff --check origin/main...HEAD
# clean

Build note: tsdown prints a Node.js v22.17.0 deprecation warning, but the build exits successfully.

Related

Refs #235. Builds on the Gateway client baseline from #316.

Signed-off-by: Ziyang Guo <121015044+RerankerGuo@users.noreply.github.com>
Signed-off-by: Ziyang Guo <121015044+RerankerGuo@users.noreply.github.com>
Signed-off-by: Ziyang Guo <121015044+RerankerGuo@users.noreply.github.com>
@Yuntong8888

Copy link
Copy Markdown
Collaborator

Hi @Arreboi06 👋,
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! 🚀

@Arreboi06 Arreboi06 changed the title docs(adapter): add cross-platform adapter architecture and integration guide feat(adapter): add executable cross-platform adapter SDK Jul 8, 2026
@Arreboi06

Copy link
Copy Markdown
Author

I pushed a follow-up hardening commit (568f2b4) on top of the original adapter SDK implementation.

The most important improvement is that the SDK default tools are now executable through ToolRegistry, with a regression test proving tdai_memory_search and tdai_conversation_search route into the adapter's public search methods.

Verification after the update:

  • npm.cmd test -- --reporter=dot -> 11 files / 186 tests passed
  • npm.cmd run build:plugin -> build complete
  • SDK entrypoint tsc --noEmit ... src/adapters/sdk/index.ts -> passed
  • git diff --check --cached -> clean

This should make the PR stronger as a challenge-level solution for #235: unified SDK + multi-platform adapters + docs + tests.

@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.

@Arreboi06 Arreboi06 force-pushed the feature/cross-platform-adapter-sdk branch from e6ff2a1 to 7949d10 Compare July 9, 2026 15:35
@Arreboi06 Arreboi06 changed the title feat(adapter): add executable cross-platform adapter SDK feat(adapters): add Claude Code Gateway hook adapter Jul 9, 2026
@Arreboi06

Arreboi06 commented Jul 9, 2026

Copy link
Copy Markdown
Author

Rescoped this PR according to the #235 duplicate/scope cleanup note.

What changed in the latest force-push:

  • Cleaned the branch history so it now reads as: origin/main -> feat(adapters): add gateway client adapter kit #316 Gateway baseline commits -> one Claude Code Gateway hook adapter commit.
  • Removed the previous parallel generic adapter SDK / BasePlatformAdapter / ToolRegistry / lifecycle/config/event/error framework.
  • Removed unrelated core/runtime SQLite changes from this adapter PR.
  • Kept the unique platform value as a focused Claude Code helper built on the feat(adapters): add gateway client adapter kit #316 seam.

Current shape:

Verification after the rescope:

npm.cmd test -- --reporter=dot
Test Files 6 passed (6)
Tests 75 passed (75)

image

npm.cmd run build:plugin
Build complete

image

git diff --check origin/main...HEAD
clean

image

This is now intended as a small platform-specific follow-up on top of the canonical #316 Gateway client boundary, not as a competing adapter framework.

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.

4 participants