Add optional Codex adapter#46
Draft
SiyaoZheng wants to merge 1 commit into
Draft
Conversation
c53c8c9 to
c30f3e4
Compare
7686cd7 to
c0258fc
Compare
d6c84c6 to
398109e
Compare
5 tasks
Signed-off-by: Siyao Zheng <zhengsy24@sjtu.edu.cn>
398109e to
dafe266
Compare
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.
Description | 描述
This PR proposes an optional Codex adapter for TencentDB Agent Memory, supporting both Codex CLI and Codex App. It is more than a Codex manifest: it wires Codex hooks, MCP tools, JSONL history, and context injection into the shared Gateway/Core pipeline, keeps Codex-specific state under
codex-plugin/, and leaves the existing OpenClaw and Hermes loading paths unchanged.The main contribution is a complete Codex memory path around the existing four-layer memory system:
SessionStart,UserPromptSubmit,PreToolUse,PostToolUse,PermissionRequest,PreCompact,PostCompact, andStophook handlers for recall, capture, tool/permission activity, compaction safety, and periodic flushes.additionalContextinjection, injected-memory tag cleanup before persistence, pending-turn preservation when capture fails, project-scoped session-key prefixes, and local L0 JSONL fallback when the Gateway is unavailable or returns no useful context.PostToolUseresults are redacted, stored under local JSONL/ref/Mermaid artifacts, replaced with compact hook feedback, and retrievable throughtdai_offload_lookupor the CLI.~/.codexsessions into Gateway/seedinput, supports dry-run/cwd/time filters, and can wait for the full L0 -> L1 -> L2 -> L3 pipeline.tdai-memory-gatewaypackage bin, token-file auth, root/health endpoint support, optionalstarted_atmetadata, session-prefix search filtering, opt-in full-pipeline/seedwaiting, and a prepack-safe optional script build path.hook.logdiagnostics, non-loopback request refusal by default, blocked credential-bearing/seed config_overridekeys, symlink-safe standalone file tools, and secure TLS defaults.I am happy to split the Gateway/seed/security support from the Codex adapter files if that would make review easier.
Related Issue | 关联 Issue
Related to #5 and #6.
Change Type | 修改类型
Self-test Checklist | 自测清单
npm test-> 4 files / 30 tests passedfind codex-plugin/scripts -name '*.mjs' -print0 | xargs -0 -n1 node --checkgit diff --checknpm run build:pluginnpm pack --dry-run --jsonrunsprepack, includesdist/src/gateway/cli.mjs,codex-plugin/.codex-plugin/plugin.json,codex-plugin/.mcp.json,codex-plugin/hooks/hooks.codex.json, andcodex-plugin/scripts/mcp-server.mjs, and excludes Codex test filescodex exec --jsonin this repo returned the expected response and created a captured Codex session withl0_recorded: 2dist/src/gateway/cli.mjsstarts with token-file auth and/healthreturns 200TDAI_TOKEN_PATH=~/...expands consistently for adapter and spawned Gateway env/seed config_override.llm.baseUrl-> 400, tokenless loopback POST -> 401 by default, explicit loopback dev opt-in reaches route validationhook.logandquery statusreports log pathsnpm view @tencentdb-agent-memory/memory-tencentdb@0.3.4 binchecked; default package-bin launch no longer pins to a published version withouttdai-memory-gatewayAdditional Notes | 其他说明
Maintainer Review Checklist | 维护者评审确认
GITHUB_OPENSOURCE_SCAN_PIPELINEis passing on head commitdafe266bc1aa966563431c041974b555f33aa8c1.Signed-off-by: Siyao Zheng <zhengsy24@sjtu.edu.cn>.Relation to PR #7 | 与 PR #7 的关系
Thank you to the author of #7 for pushing the host-adapter direction forward. It may be useful to review this PR alongside #7 because the two PRs intentionally overlap in Gateway, daemon, auth, and packaging concerns while targeting different host surfaces.
#7 is valuable Claude Code + Codex CLI plugin work: it adds dual manifests, a shared hook path, daemon/token handling, manual memory skills, and a useful test baseline. This PR is complementary rather than a replacement: it contributes a fuller Codex adapter that covers Codex CLI and Codex App, with additional Codex App adaptation and validation.
The practical difference is the Codex feature surface covered here. This PR implements Codex lifecycle and retrieval paths that are not covered by #7's current scope, including tool and permission hooks, compact hooks, bundled MCP tools, large tool-output offload/lookup, local L0 fallback, Codex JSONL importer, scoped offload lookup, injected-memory cleanup, and defensive Gateway/security/packaging checks.
To reduce duplicate review effort, this PR also incorporates compatible host-neutral pieces in the same spirit: the
tdai-memory-gatewaypackage bin, bearer token-file handling, Gateway auth/CORS hardening, packaging fixes, and targeted tests. I am happy to rebase on #7, split this into smaller PRs, or fold the Codex-specific pieces into a combined host-plugin structure if maintainers prefer that path.Security posture | 安全边界
The intent is balanced local-agent security rather than maximum lock-down:
hook.logafter redaction;DCO
Single commit, signed off as:
Signed-off-by: Siyao Zheng <zhengsy24@sjtu.edu.cn>