Add optional Codex adapter#46
Conversation
c53c8c9 to
c30f3e4
Compare
7686cd7 to
c0258fc
Compare
d6c84c6 to
398109e
Compare
Signed-off-by: Siyao Zheng <zhengsy24@sjtu.edu.cn>
398109e to
dafe266
Compare
|
Hi @SiyaoZheng — thanks for the very detailed PR description and the explicit "complementary, not replacement" framing on #7. Replying here to mirror what I just posted on #7 and offer a concrete sequence. Pinging @Maxwell-Code07 for triage awareness. Overlap I noticed reading your PR descriptionYour "Security and operability hardening" bullets describe the same surface as four small follow-up PRs I opened off #7, each isolated to one concern:
Each of these is ≤200 LOC, has its own isolated test file under You explicitly offered to "split the Gateway/seed/security support from the Codex adapter files if that would make review easier" — yes, that would help me a lot too. Concretely, if reviewers land #39 / #42 / #51 / #52 first, your On the Codex sideYour Proposed sequence (mirroring what I wrote on #7)
Deferring to reviewers on the actual order. Wanted to surface this so we don't end up with three rounds of rebase-conflict ping-pong on the shared Gateway files. |
|
Hi @SiyaoZheng, We've received your PR for the Codex adapter integration. Thanks for the comprehensive work! Also thanks @YOMXXX for the detailed review and overlap analysis — community coordination like this is very helpful 👍. We'll review internally and work out the merge sequence. |
Signed-off-by: Siyao Zheng <zhengsy24@sjtu.edu.cn>
Signed-off-by: Siyao Zheng <zhengsy24@sjtu.edu.cn>
Signed-off-by: Siyao Zheng <zhengsy24@sjtu.edu.cn>
Signed-off-by: Siyao Zheng <zhengsy24@sjtu.edu.cn>
dac02cc to
3ff37c3
Compare
|
Thanks @YOMXXX and @Maxwell-Code07 — this sequencing discussion is helpful. I have marked #46 ready for review now so maintainers can evaluate both the Codex adapter and the merge order explicitly. I agree the PR is large, so I am happy to follow the maintainer-preferred sequence:
Latest local validation is reflected in the PR body: |
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-> 12 files / 67 tests passedfind codex-plugin/scripts -name '*.mjs' -print0 | xargs -0 -n1 node --checkgit diff --checknpm run buildnpm pack --dry-runrunsprepack, includesdist/src/gateway/cli.mjs,codex-plugin/.codex-plugin/plugin.json,codex-plugin/.mcp.json,codex-plugin/hooks/hooks.codex.json, and runtime Codex scriptscodex 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 validationmessage/contentarrays and transcript JSONL fallback preserve the real user prompt; assistant and synthetic interruption messages are ignoredhook.logandquery statusreports log pathsTDAI_CODEX_AUTOSTART=false TDAI_CODEX_GATEWAY_URL=http://127.0.0.1:9 node codex-plugin/scripts/doctor.mjs --json->ok: truenpm 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 | 维护者评审确认
3ff37c353b724c35f53ca024a76603358cb74807is in progress. PreviousGITHUB_OPENSOURCE_SCAN_PIPELINEpassed on head commit8b62ade9414547c2a20d2fe4a887683759c273f5.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
All commits are signed off as:
Signed-off-by: Siyao Zheng <zhengsy24@sjtu.edu.cn>