Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(codex-plugin): stop injecting PreToolUse context between a tool call and its output (#6296)

t0saki15c9a339aa18
diff --git a/docs/en/agent-integrations/04-codex.md b/docs/en/agent-integrations/04-codex.md
index 87d77ff54..14c08a8ef 100644
--- a/docs/en/agent-integrations/04-codex.md
+++ b/docs/en/agent-integrations/04-codex.md
@@ -81,7 +81,6 @@ The plugin handles memory at these Codex lifecycle events:
| `Stop` | Append new conversation turns to the OpenViking session. |
| `PreCompact` | Capture remaining turns and commit the complete transcript before compaction. |
| `SessionEnd` | Commit the session on graceful exit for subsequent memory extraction. |
-| `PreToolUse` (`Bash`) | Detect `viking://` URIs in shell commands and suggest the OpenViking MCP tools. The command still runs; the model can ignore the notice when the URI is intentional data, such as an `ov` argument. |
Starting a new session also sweeps orphaned sessions from earlier runs once their idle TTL has expired.
diff --git a/docs/en/agent-integrations/13-trae.md b/docs/en/agent-integrations/13-trae.md
index 94f6d535d..04ee6454b 100644
--- a/docs/en/agent-integrations/13-trae.md
+++ b/docs/en/agent-integrations/13-trae.md
@@ -37,7 +37,7 @@ TRAE and TRAE CN use the installed `hooks.json` and need no hook approval; resta
- `SessionStart` loads your profile, current project memory, and an `<available-skills>` catalog of your OpenViking skills.
- `UserPromptSubmit` recalls and injects context for the current request, including your own skills and those shared with your account under `viking://agent/skills`.
-- `PreToolUse` on TRAE and TRAE CN denies `Read`, `Glob`, and `Grep` calls whose path is a `viking://` URI and points to OpenViking MCP tools; a `Bash` or `RunCommand` command that carries a `viking://` URI still runs, with a notice suggesting those tools. TraeCode CLI 2.0 uses the Codex plugin, whose `PreToolUse` matches only `Bash`: it adds the same notice and never denies a call.
+- `PreToolUse` on TRAE and TRAE CN denies `Read`, `Glob`, and `Grep` calls whose path is a `viking://` URI and points to OpenViking MCP tools; a `Bash` or `RunCommand` command that carries a `viking://` URI still runs, with a notice suggesting those tools. TraeCode CLI 2.0 uses the Codex plugin, which has no URI guard.
- TRAE/TRAE CN `Stop` captures and commits the completed turn. TraeCode CLI 2.0 follows the Codex plugin’s capture and lifecycle commit policy.
- The OpenViking MCP server transparently exposes the full server MCP tool set (21 tools): `find`, `search`, `read`, `download`, `list`, `tree`, `remember`, `write`, `edit`, `add_resource`, `add_skill`, `list_watches`, `cancel_watch`, `grep`, `glob`, `forget`, `health`, `list_users`, `list_groups`, `get_acl`, and `set_acl`. `search` with `mode="context"` returns assembled context.
The skill catalog lists your own skills before those shared with your account, with each description cut to about 40 tokens. Its budget, `skillCatalogTokenBudget` (default `1200` tokens), is separate from the profile budget; when not every description fits, the catalog lists names only. Set `skillCatalog` to `false` or the budget to `0` to turn it off, either in the `plugin` section of `~/.openviking/ovcli.conf` ([Plugin Settings](../configuration/02-client.md#plugin-settings)) or through `OPENVIKING_SKILL_CATALOG` and `OPENVIKING_SKILL_CATALOG_TOKEN_BUDGET`.
diff --git a/docs/en/agent-integrations/16-capability-reference.md b/docs/en/agent-integrations/16-capability-reference.md
index c63553d98..a9cdea4f4 100644
--- a/docs/en/agent-integrations/16-capability-reference.md
+++ b/docs/en/agent-integrations/16-capability-reference.md
@@ -549,7 +549,7 @@ Settings that apply only to some integrations:
| Hermes (bundled) | No | None | None | Yes; `hermes memory status` lists environment overrides |
| ov CLI | No | The CLI itself | None | `ov config` |
-Claude Code, Codex, Cursor, TRAE, ZCode, Kimi Code, DSH, and pi also install a **URI guard**: a file tool whose path is a `viking://` URI is denied with a hint to use the OpenViking tools, and a shell command that contains one runs with a notice attached. Which tools are checked differs by host and is listed in [Notes by integration](#notes-by-integration).
+Claude Code, Cursor, TRAE, ZCode, Kimi Code, DSH, and pi also install a **URI guard**: a file tool whose path is a `viking://` URI is denied with a hint to use the OpenViking tools, and a shell command that contains one runs with a notice attached. Which tools are checked differs by host and is listed in [Notes by integration](#notes-by-integration).
<a id="_4-harness-profile-cards"></a>
@@ -571,11 +571,11 @@ Each note covers what is specific to one integration. Shared behavior is in the
### Codex and TraeCode CLI 2.0
-[Codex Memory Plugin](./04-codex.md), [TRAE Memory Integration](./13-trae.md). A marketplace plugin with 6 hooks (`SessionStart`, `UserPromptSubmit`, `PreToolUse:Bash`, `Stop`, `SessionEnd`, `PreCompact`), an MCP proxy, and the same 4 skills as Claude Code.
+[Codex Memory Plugin](./04-codex.md), [TRAE Memory Integration](./13-trae.md). A marketplace plugin with 6 hooks (`SessionStart`, `UserPromptSubmit`, `Stop`, `SessionEnd`, `PreCompact`, `PostToolUse`), an MCP proxy, and the same 4 skills as Claude Code.
- `SessionEnd` fires only on a clean exit and only on Codex 0.145 and later. Signals, crashes, older builds, and `codex app-server` deferral fall to the start-up sweep, which uses a 30-minute idle timeout.
- `Stop` and `SessionEnd` write in a detached worker. A per-session lock orders the `Stop` worker, `PreCompact`, the `SessionEnd` worker, and the sweep.
-- Codex edits files with `apply_patch`, which has no path argument, so the URI guard on Bash only adds notices and never denies.
+- There is no URI guard. Codex writes a `PreToolUse` notice into the history between a tool call and its output, and Responses servers that check the history as chat messages, such as Volcengine Ark, reject that order with HTTP 400.
- Codex keeps a trust record per hook. After an upgrade that adds hooks, approve the new ones in `/hooks`.
- TraeCode CLI 2.0 (binary `traecli`, config `~/.trae/traecli.toml`) is a Codex-family CLI and installs this same plugin. Only version 2.0 is supported; the earlier standalone plugin for 1.0 has been removed, and `--harness trae-cli --uninstall` still removes a copy an old install left behind. A build without `SessionEnd` ignores that hook.
diff --git a/docs/en/agent-integrations/18-plugin-development.md b/docs/en/agent-integrations/18-plugin-development.md
index 0c68f3910..668ec705d 100644
--- a/docs/en/agent-integrations/18-plugin-development.md
+++ b/docs/en/agent-integrations/18-plugin-development.md
@@ -193,7 +193,7 @@ A persistent MCP proxy cannot infer the active project from its startup cwd. Use
| Before compaction | Ensure preceding messages were written, then commit as appropriate | `PreCompact` commits existing messages; this entrypoint does not catch up the transcript | `PreCompact` catches up the transcript and commits |
| Session end | Finish outstanding writes and commit | `SessionEnd` commits existing messages; this entrypoint does not catch up the transcript | `SessionEnd` catches up and commits in a worker, with startup recovery retained |
| Subagents | Preserve identity and parent relationships without duplicates | `SubagentStart`, `SubagentStop` | Neither event is registered in the current hook manifest |
-| Local tool checks | Deny a file tool whose path is a virtual URI; attach a notice to a shell command that carries one | `PreToolUse` URI guard on Read, Glob, Grep, Edit, Write, and Bash | `PreToolUse` URI guard on Bash, notice only; file edits go through `apply_patch`, which has no path argument |
+| Local tool checks | Deny a file tool whose path is a virtual URI; attach a notice to a shell command that carries one | `PreToolUse` URI guard on Read, Glob, Grep, Edit, Write, and Bash | Not registered: Codex records `PreToolUse` context as a developer message between a tool call and its output, which some Responses servers reject; file edits go through `apply_patch`, which has no path argument |
Use [Claude Code hooks.json](https://github.com/volcengine/OpenViking/blob/main/examples/claude-code-memory-plugin/hooks/hooks.json) and [Codex hooks.json](https://github.com/volcengine/OpenViking/blob/main/examples/codex-memory-plugin/hooks/hooks.json) as the event registration references. Identical event names do not guarantee identical payloads or outputs. A host without an end event must choose and document an alternative commit point, such as ZCode's Stop commits, rather than register an unreachable SessionEnd handler.
diff --git a/docs/zh/agent-integrations/04-codex.md b/docs/zh/agent-integrations/04-codex.md
index 52e085334..b9d568536 100644
--- a/docs/zh/agent-integrations/04-codex.md
+++ b/docs/zh/agent-integrations/04-codex.md
@@ -79,7 +79,6 @@ memory 插件默认内置 OV-Usage。报告汇总自动召回和显式 OpenVikin
| `Stop` | 将新增对话追加到 OpenViking 会话。 |
| `PreCompact` | 补齐并提交压缩前的完整对话记录。 |
| `SessionEnd` | 正常退出时提交会话,触发后续记忆提取。 |
-| `PreToolUse`(`Bash`) | 检查命令中的 `viking://` URI,并提示模型使用 OpenViking MCP 工具。命令仍会执行;URI 是 `ov` 参数等有意传入的数据时,可以忽略提示。 |
新会话启动时还会清理上次运行遗留、已超过闲置 TTL 的孤儿会话。
diff --git a/docs/zh/agent-integrations/13-trae.md b/docs/zh/agent-integrations/13-trae.md
index a9e69d007..d922c70fe 100644
--- a/docs/zh/agent-integrations/13-trae.md
+++ b/docs/zh/agent-integrations/13-trae.md
@@ -37,7 +37,7 @@ TRAE 和 TRAE CN 使用安装后的 `hooks.json`,不需要审阅 hook,安装
- `SessionStart`:加载用户画像、当前项目记忆,以及 OpenViking skill 清单 `<available-skills>`。
- `UserPromptSubmit`:根据当前问题召回并注入相关内容,召回范围包括你自己的 skill 和账号内共享在 `viking://agent/skills` 下的 skill。
-- `PreToolUse`:在 TRAE 和 TRAE CN 上,`Read`、`Glob`、`Grep` 的路径是 `viking://` URI 时拒绝调用,并提示改用 OpenViking MCP 工具;`Bash` 或 `RunCommand` 命令带 `viking://` URI 时照常执行,同时附加改用建议。TraeCode CLI 2.0 使用 Codex 插件,它的 `PreToolUse` 只匹配 `Bash`,只附加同样的提示,不拒绝调用。
+- `PreToolUse`:在 TRAE 和 TRAE CN 上,`Read`、`Glob`、`Grep` 的路径是 `viking://` URI 时拒绝调用,并提示改用 OpenViking MCP 工具;`Bash` 或 `RunCommand` 命令带 `viking://` URI 时照常执行,同时附加改用建议。TraeCode CLI 2.0 使用 Codex 插件,它不安装 URI guard。
- TRAE/TRAE CN 的 `Stop` 捕获并提交本轮消息;TraeCode CLI 2.0 遵循 Codex 插件的捕获与生命周期提交策略。
- OpenViking MCP Server:透传服务端完整 MCP 工具集(21 个工具):`find`、`search`、`read`、`download`、`list`、`tree`、`remember`、`write`、`edit`、`add_resource`、`add_skill`、`list_watches`、`cancel_watch`、`grep`、`glob`、`forget`、`health`、`list_users`、`list_groups`、`get_acl`、`set_acl`。其中 `search` 的 `mode="context"` 可返回组装后的上下文。
skill 清单先列你自己的 skill,再列账号内共享的 skill,每条描述截到约 40 token。清单的预算 `skillCatalogTokenBudget`(默认 `1200` token)独立于画像预算;描述放不下时只列名称。把 `skillCatalog` 设为 `false` 或把预算设为 `0` 即可关闭,既可以写在 `~/.openviking/ovcli.conf` 的 `plugin` 段(见[插件配置](../configuration/02-client.md#插件配置)),也可以用环境变量 `OPENVIKING_SKILL_CATALOG` 和 `OPENVIKING_SKILL_CATALOG_TOKEN_BUDGET`。
diff --git a/docs/zh/agent-integrations/16-capability-reference.md b/docs/zh/agent-integrations/16-capability-reference.md
index 0dfeb7d3a..ead9a0c36 100644
--- a/docs/zh/agent-integrations/16-capability-reference.md
+++ b/docs/zh/agent-integrations/16-capability-reference.md
@@ -548,7 +548,7 @@ Claude Code 和 Codex 默认 `auto`,其他集成默认 `off`。支持服务端
| Hermes(内置) | 无 | 无 | 无 | 有;`hermes memory status` 列出环境变量覆盖项 |
| ov CLI | 无 | CLI 本身 | 无 | `ov config` |
-Claude Code、Codex、Cursor、TRAE、ZCode、Kimi Code、DSH 和 pi 还会安装 **URI guard**:文件工具的路径是 `viking://` URI 时,调用会被拒绝,并提示改用 OpenViking 工具;shell 命令中包含这种 URI 时照常执行,但附带一条提示。各宿主检查哪些工具不同,见[各集成说明](#各集成说明)。
+Claude Code、Cursor、TRAE、ZCode、Kimi Code、DSH 和 pi 还会安装 **URI guard**:文件工具的路径是 `viking://` URI 时,调用会被拒绝,并提示改用 OpenViking 工具;shell 命令中包含这种 URI 时照常执行,但附带一条提示。各宿主检查哪些工具不同,见[各集成说明](#各集成说明)。
<a id="_4-harness-档案卡"></a>
@@ -570,11 +570,11 @@ Claude Code、Codex、Cursor、TRAE、ZCode、Kimi Code、DSH 和 pi 还会安
### Codex 与 TraeCode CLI 2.0
-[Codex](./04-codex.md)、[TRAE](./13-trae.md)。插件市场插件,包含 6 个 hook(`SessionStart`、`UserPromptSubmit`、`PreToolUse:Bash`、`Stop`、`SessionEnd`、`PreCompact`)、一个 MCP 代理,以及与 Claude Code 相同的 4 个 skill。
+[Codex](./04-codex.md)、[TRAE](./13-trae.md)。插件市场插件,包含 6 个 hook(`SessionStart`、`UserPromptSubmit`、`Stop`、`SessionEnd`、`PreCompact`、`PostToolUse`)、一个 MCP 代理,以及与 Claude Code 相同的 4 个 skill。
- `SessionEnd` 只在干净退出且 Codex 0.145 及以上时触发。信号、崩溃、旧版本和 `codex app-server` 延后的情况都交给启动时的扫描,扫描使用 30 分钟空闲超时。
- `Stop` 和 `SessionEnd` 在分离的 worker 中写入。每个会话一把锁,按顺序处理 `Stop` worker、`PreCompact`、`SessionEnd` worker 和扫描。
-- Codex 用 `apply_patch` 编辑文件,它没有路径参数,所以 Bash 上的 URI guard 只附加提示,从不拒绝。
+- 不安装 URI guard。Codex 会把 `PreToolUse` 的提示写在工具调用和它的输出之间,火山方舟 Ark 这类按 chat 消息校验历史的 Responses 服务端会因此返回 HTTP 400。
- Codex 为每个 hook 保存信任记录。升级新增 hook 后,需要在 `/hooks` 中批准新的 hook。
- TraeCode CLI 2.0(可执行文件 `traecli`,配置 `~/.trae/traecli.toml`)是 Codex 系 CLI,安装同一个插件。只支持 2.0;早期面向 1.0 的独立插件已移除,`--harness trae-cli --uninstall` 仍可删除旧安装留下的副本。不带 `SessionEnd` 的版本会忽略该 hook。
diff --git a/docs/zh/agent-integrations/18-plugin-development.md b/docs/zh/agent-integrations/18-plugin-development.md
index 50f0127cf..cdde19c5d 100644
--- a/docs/zh/agent-integrations/18-plugin-development.md
+++ b/docs/zh/agent-integrations/18-plugin-development.md
@@ -193,7 +193,7 @@ peer 解析使用共享实现。现状默认从 Git 身份推导,普通非 Git
| 压缩前 | 确认压缩前消息已写入,再执行相应提交 | `PreCompact` 提交已有消息;本入口不补采 transcript | `PreCompact` 补齐 transcript 后提交 |
| 会话结束 | 完成尚未完成的写入与提交 | `SessionEnd` 提交已有消息;本入口不补采 transcript | `SessionEnd` 后台补齐并提交,保留启动补偿 |
| 子代理 | 保留身份和父子关系,避免重复 | `SubagentStart`、`SubagentStop` | 当前 hook manifest 没有这两个事件 |
-| 本地工具检查 | 文件工具的路径是虚拟 URI 时拒绝;shell 命令带虚拟 URI 时附加提示 | `PreToolUse` URI guard,匹配 Read、Glob、Grep、Edit、Write、Bash | `PreToolUse` URI guard 只匹配 Bash,只附加提示;文件编辑走 `apply_patch`,没有路径参数 |
+| 本地工具检查 | 文件工具的路径是虚拟 URI 时拒绝;shell 命令带虚拟 URI 时附加提示 | `PreToolUse` URI guard,匹配 Read、Glob、Grep、Edit、Write、Bash | 不注册:Codex 会把 `PreToolUse` 的上下文作为 developer 消息插在工具调用和输出之间,部分 Responses 服务端会拒绝;文件编辑走 `apply_patch`,没有路径参数 |
以两份 [Claude Code hooks.json](https://github.com/volcengine/OpenViking/blob/main/examples/claude-code-memory-plugin/hooks/hooks.json) 和 [Codex hooks.json](https://github.com/volcengine/OpenViking/blob/main/examples/codex-memory-plugin/hooks/hooks.json) 为事件注册依据。相同事件名称不保证 payload 或输出格式相同。没有结束事件的宿主必须选择并说明替代提交点,例如 ZCode 在 Stop 提交;不能假装存在一个永远不会执行的 SessionEnd。
diff --git a/examples/codex-memory-plugin/.codex-plugin/plugin.json b/examples/codex-memory-plugin/.codex-plugin/plugin.json
index 64569b05f..e15fee9af 100644
--- a/examples/codex-memory-plugin/.codex-plugin/plugin.json
+++ b/examples/codex-memory-plugin/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
- "version": "0.11.13",
+ "version": "0.11.14",
"description": "Long-term semantic memory for Codex, powered by OpenViking. Recall on UserPromptSubmit, incremental add_message on Stop (per turn), commit on SessionEnd (Codex >= 0.145) and on PreCompact, with an idle/ended sweep on SessionStart as the fallback for signals, crashes and older Codex builds. Includes a local stdio MCP proxy that reads OpenViking credentials from env/ovcli.conf.",
"author": {
"name": "OpenViking",
diff --git a/examples/codex-memory-plugin/README.md b/examples/codex-memory-plugin/README.md
index ec84bc9af..cf42effc9 100644
--- a/examples/codex-memory-plugin/README.md
+++ b/examples/codex-memory-plugin/README.md
@@ -14,7 +14,6 @@ This is the Codex counterpart to [`claude-code-memory-plugin`](../claude-code-me
- **Session-start profile injection** on `startup`, `clear`, and `resume`: load `profile.md` plus abstract-annotated indexes of `preferences/` and `entities/` through the shared CJK-aware profile builder, followed by an `<available-skills>` catalog of your own and account-shared OpenViking skills.
- **Auto-recall** relevant memories on every `UserPromptSubmit` and inject them via `hookSpecificOutput.additionalContext`
- **OV-Usage source summaries** after each answer: show sources made available through automatic recall and explicit OpenViking lookups, with optional source URI and query details.
-- **`viking://` notice on `PreToolUse` (`Bash`)**: a shell command that carries a `viking://` URI still runs, and the model is told that the URI is an OpenViking virtual path and which MCP tool reads it.
- **Incremental capture on `Stop`** (turn end): append the new user/assistant turns to a deterministic OpenViking session id `cx-<codex_session_id>`. When `pending_tokens` reaches `OPENVIKING_COMMIT_TOKEN_THRESHOLD`, commit and archive every captured message.
- **Commit on `PreCompact`**: trigger OpenViking's memory extractor on the full pre-compact transcript before Codex summarizes it.
- **Commit on `SessionEnd`** (Codex ≥ 0.145): when a thread shuts down gracefully, catch up any turns `Stop` never sent and commit the OV session, so the extractor runs on the whole conversation the moment you leave.
@@ -380,14 +379,6 @@ Client-side knobs can also live in `~/.openviking/ovcli.conf` under
layers; resolution order is env vars → the workspace layers → `plugin.codex` →
`plugin` → the legacy `codex` block in `ov.conf` → defaults.
-### viking:// URI notice (PreToolUse on Bash)
-
-`viking://` URIs are OpenViking virtual paths, so `cat viking://…` or `ls viking://…` cannot open them. `uri-guard.mjs` runs before every `Bash` call. When the command contains a `viking://` URI, it returns `hookSpecificOutput.additionalContext` without a `permissionDecision`: the command runs unchanged, and the model is told which OpenViking MCP tool reads the URI and to ignore the notice when the URI is intentional data (an `ov` CLI argument, an HTTP payload, a search pattern). A command without a `viking://` URI gets no output.
-
-Nothing is denied: Codex edits files through `apply_patch`, whose input is a patch body rather than a path (Codex's `Edit` / `Write` matchers are aliases for it), so there is no path argument to guard.
-
-> **Upgrading to 0.9.1**: `PreToolUse` is a newly registered hook event. Run `/hooks` in Codex after updating and approve it; until then shell commands run without the notice.
-
### Stop (turn end → `add_message`, threshold commit)
`auto-capture.mjs` derives one long-lived OpenViking session id per Codex `session_id` as `cx-<safe-session-id>` and incrementally appends every new user/assistant turn via `/api/v1/sessions/{id}/messages`. The `/messages` endpoint auto-creates the session on first append. Per-codex-session state lives at `~/.openviking/codex-plugin-state/<safe-session-id>.json`. Capture sanitizes obvious hook noise, metadata wrappers, and plugin-injected `<openviking-context ...>` blocks before append. Tool calls and results become dedicated `tool` parts and `tool_output` is reported verbatim — the server externalizes anything larger than `tool_output_externalization.threshold_chars` (default `20000`) and leaves a synopsis stub plus `tool_output_ref`, so the original stays readable via `/api/v1/sessions/{id}/tool-results`. `OPENVIKING_CAPTURE_TOOL_MAX_CHARS` (default `1000000`) is only a guard against pathological payloads. Configured `captureFilters` rules run last, just before the payload is sent — see [Input filters](#input-filters).
@@ -424,7 +415,6 @@ Codex's hook output schema differs from Claude Code's. Notably:
|------|------------------------|--------------------------------------|
| `SessionStart` | `source` (`startup`/`resume`/`clear`), `session_id`, `cwd` | `hookSpecificOutput.additionalContext`; may also include `systemMessage` when an orphaned session was committed |
| `UserPromptSubmit` | `prompt`, `session_id` | `hookSpecificOutput.additionalContext` |
-| `PreToolUse` (`Bash`) | `tool_name`, `tool_input.command` | `hookSpecificOutput.additionalContext` with no `permissionDecision`, so the command still runs; no output when the command has no `viking://` URI |
| `Stop` | `last_assistant_message`, `transcript_path`, `session_id` | `systemMessage` (only) |
| `PreCompact` | `trigger` (`manual`/`auto`), `transcript_path`, `session_id` | `systemMessage` (only) |
| `SessionEnd` | `session_id`, `transcript_path`, `cwd`, `reason` (constant `other`) | none — Codex ignores the output; the script prints `{}` for symmetry |
@@ -484,7 +474,7 @@ codex-memory-plugin/
├── .codex-plugin/
│ └── plugin.json # Plugin manifest (hooks + mcp wiring)
├── hooks/
-│ └── hooks.json # SessionStart + UserPromptSubmit + PreToolUse + Stop
+│ └── hooks.json # SessionStart + UserPromptSubmit + Stop
│ + SessionEnd + PreCompact (uses Codex's native
│ ${PLUGIN_ROOT} token; no rendering needed on modern Codex)
├── skills/
@@ -505,7 +495,6 @@ codex-memory-plugin/
│ ├── session-start-commit.mjs # SessionStart hook (profile + fallback sweep + resume archive)
│ ├── session-end.mjs # SessionEnd hook (mark + detached catch-up + commit)
│ ├── pre-compact-capture.mjs # PreCompact hook
-│ ├── uri-guard.mjs # PreToolUse hook (viking:// notice on Bash)
│ └── *.test.mjs # node --test suites (session-end, pre-compact, ...)
├── servers/
│ └── mcp-proxy.mjs # stdio -> OpenViking /mcp bridge
diff --git a/examples/codex-memory-plugin/hooks/hooks.json b/examples/codex-memory-plugin/hooks/hooks.json
index 6d517d4fe..1c814a224 100644
--- a/examples/codex-memory-plugin/hooks/hooks.json
+++ b/examples/codex-memory-plugin/hooks/hooks.json
@@ -24,18 +24,6 @@
]
}
],
- "PreToolUse": [
- {
- "matcher": "Bash",
- "hooks": [
- {
- "type": "command",
- "command": "node \"${PLUGIN_ROOT}/scripts/uri-guard.mjs\"",
- "timeout": 5
- }
- ]
- }
- ],
"Stop": [
{
"matcher": "*",
diff --git a/examples/codex-memory-plugin/scripts/marketplace.test.mjs b/examples/codex-memory-plugin/scripts/marketplace.test.mjs
index 9d8f88d6f..cd7672d3d 100644
--- a/examples/codex-memory-plugin/scripts/marketplace.test.mjs
+++ b/examples/codex-memory-plugin/scripts/marketplace.test.mjs
@@ -278,8 +278,6 @@ test("required plugin files are present", () => {
"skills/ov-memory-doctor/reference.md",
"scripts/ov-memory-doctor.mjs",
"scripts/shared/doctor-core.mjs",
- "scripts/uri-guard.mjs",
- "scripts/shared/uri-guard.mjs",
]) {
assert.ok(existsSync(join(pluginDir, rel)), `missing required plugin file: ${rel}`);
}
@@ -319,7 +317,7 @@ test("hooks.json uses Codex's native ${PLUGIN_ROOT}, not the legacy placeholder"
.flat()
.flatMap((group) => group.hooks || [])
.map((h) => h.command || "");
- assert.ok(commands.length >= 6, "expected at least 6 hook commands (SessionStart/UserPromptSubmit/PreToolUse/Stop/SessionEnd/PreCompact)");
+ assert.ok(commands.length >= 6, "expected at least 6 hook commands (SessionStart/UserPromptSubmit/Stop/SessionEnd/PreCompact/PostToolUse)");
for (const cmd of commands) {
assert.match(
cmd,
@@ -338,16 +336,13 @@ test("hooks.json registers SessionEnd within Codex's clamped budget", () => {
assert.ok(entries[0].timeout <= 3, `SessionEnd timeout must be <= 3, got ${entries[0].timeout}`);
});
-test("hooks.json registers the PreToolUse URI guard on Bash only", () => {
- // Codex's Edit and Write matchers are aliases for apply_patch, whose input is
- // a patch body with no path argument to guard.
+test("hooks.json registers no PreToolUse hook", () => {
+ // Codex records PreToolUse additionalContext as a developer message before the
+ // tool runs, i.e. between the function_call and its function_call_output.
+ // Responses servers that validate the history as chat messages (Ark) reject
+ // that order with HTTP 400 and the turn fails.
const parsed = JSON.parse(readFileSync(join(pluginDir, "hooks", "hooks.json"), "utf-8"));
- const groups = parsed.hooks?.PreToolUse || [];
- assert.deepEqual(groups.map((group) => group.matcher), ["Bash"]);
- const entries = groups.flatMap((group) => group.hooks || []);
- assert.equal(entries.length, 1, "expected exactly one PreToolUse hook");
- assert.equal(entries[0].command, 'node "${PLUGIN_ROOT}/scripts/uri-guard.mjs"');
- execFileSync("node", ["--check", join(pluginDir, "scripts", "uri-guard.mjs")], { stdio: "pipe" });
+ assert.equal(parsed.hooks?.PreToolUse, undefined);
});
test(".mcp.json starts the stdio MCP proxy from the plugin root", () => {
diff --git a/examples/codex-memory-plugin/scripts/ov-memory-doctor.mjs b/examples/codex-memory-plugin/scripts/ov-memory-doctor.mjs
index 5cb778fff..0b523894d 100644
--- a/examples/codex-memory-plugin/scripts/ov-memory-doctor.mjs
+++ b/examples/codex-memory-plugin/scripts/ov-memory-doctor.mjs
@@ -52,8 +52,8 @@ const LEGACY_MARKETPLACE = "openviking-plugins-local";
const CODEX_DIR = join(homedir(), ".codex");
const CODEX_CONFIG = process.env.CODEX_CONFIG_FILE || join(CODEX_DIR, "config.toml");
const CACHE_DIR = join(CODEX_DIR, "plugins", "cache", MARKETPLACE, PLUGIN_NAME);
-const HOOK_EVENTS = ["session_start", "user_prompt_submit", "pre_tool_use", "stop", "session_end", "pre_compact"];
-const REQUIRED_PLUGIN_FILES = [".codex-plugin/plugin.json", "hooks/hooks.json", ".mcp.json", "servers/mcp-proxy.mjs", "scripts/config.mjs", "scripts/auto-recall.mjs", "scripts/auto-capture.mjs", "scripts/session-end.mjs", "scripts/ov-session.mjs", "scripts/uri-guard.mjs"];
+const HOOK_EVENTS = ["session_start", "user_prompt_submit", "stop", "session_end", "pre_compact"];
+const REQUIRED_PLUGIN_FILES = [".codex-plugin/plugin.json", "hooks/hooks.json", ".mcp.json", "servers/mcp-proxy.mjs", "scripts/config.mjs", "scripts/auto-recall.mjs", "scripts/auto-capture.mjs", "scripts/session-end.mjs", "scripts/ov-session.mjs"];
/**
* Minimal TOML reader — enough for config.toml's [section] headers (including
@@ -275,7 +275,7 @@ function checkInstall(report, { cliOnPath }) {
else trusted.push(event);
}
if (disabled.length) report.fail(`hooks disabled in [hooks.state]: ${disabled.join(", ")}`, "", `remove enabled = false from those [hooks.state] sections in ${homeShort(CODEX_CONFIG)}`);
- if (untrusted.length) report.info(`hooks without a trust record yet: ${untrusted.join(", ")} (Codex records trusted_hash the first time a hook is approved; a changed hooks.json — including a newly added event such as pre_tool_use — needs re-approval)`);
+ if (untrusted.length) report.info(`hooks without a trust record yet: ${untrusted.join(", ")} (Codex records trusted_hash the first time a hook is approved; a changed hooks.json — including a newly added event — needs re-approval)`);
if (trusted.length === HOOK_EVENTS.length) report.ok(`all ${HOOK_EVENTS.length} hooks have trust records in config.toml`);
const legacyKeys = Object.keys(toml).filter((k) => k.includes(LEGACY_MARKETPLACE));
if (legacyKeys.length) report.info(`config.toml still has ${legacyKeys.length} section(s) for the legacy id ${LEGACY_MARKETPLACE} (harmless)`);
diff --git a/examples/codex-memory-plugin/scripts/shared/uri-guard.mjs b/examples/codex-memory-plugin/scripts/shared/uri-guard.mjs
deleted file mode 100644
index dc168cea0..000000000
--- a/examples/codex-memory-plugin/scripts/shared/uri-guard.mjs
+++ /dev/null
@@ -1,283 +0,0 @@
-// GENERATED FROM examples/memory-plugin-shared/lib. DO NOT EDIT.
-import { readFileSync, realpathSync } from "node:fs";
-import { resolve } from "node:path";
-import { fileURLToPath } from "node:url";
-
-const DEFAULT_URI_KEYS = [
- "filePath",
- "file_path",
- "filepath",
- "path",
- "uri",
- "target_uri",
- "targetUri",
-];
-
-export function normalizeToolName(value) {
- return String(value || "").trim().toLowerCase();
-}
-
-// Arguments that carry file CONTENT rather than a location. The sweep below
-// looks past the known path keys so an unusual one (`paths`, a nested target)
-// is still caught, but text a tool is asked to WRITE is not a path: a local
-// `write` whose body merely mentions viking://user/default/ was denied, and no
-// file was created. Skipped by name at any depth.
-const DEFAULT_CONTENT_KEYS = [
- "content",
- "contents",
- "text",
- "body",
- "old_string",
- "oldString",
- "new_string",
- "newString",
- "old_str",
- "new_str",
- "file_text",
- "insert_line",
- "replacement",
-];
-
-export function findVikingUri(args = {}, keys = DEFAULT_URI_KEYS, contentKeys = DEFAULT_CONTENT_KEYS) {
- if (!args || typeof args !== "object") return null;
- for (const key of keys) {
- const uri = findVikingUriInValue(args[key]);
- if (uri) return uri;
- }
- return findVikingUriInValue(args, new Set(contentKeys));
-}
-
-export function findVikingUriInValue(value, skipKeys) {
- if (typeof value === "string") {
- const match = value.match(/\bviking:\/\/[^\s"'`<>)]*/i);
- return match?.[0] || null;
- }
- if (Array.isArray(value)) {
- for (const item of value) {
- const uri = findVikingUriInValue(item, skipKeys);
- if (uri) return uri;
- }
- return null;
- }
- if (value && typeof value === "object") {
- for (const [key, item] of Object.entries(value)) {
- if (skipKeys?.has(key)) continue;
- const uri = findVikingUriInValue(item, skipKeys);
- if (uri) return uri;
- }
- }
- return null;
-}
-
-export function buildGuardMessage(uri, hint = {}) {
- const tool = hint.tool || "the OpenViking MCP tools";
- const example = typeof hint.example === "function" ? hint.example(uri) : hint.example;
- const lines = [
- "viking:// URIs are OpenViking virtual paths, not local filesystem paths.",
- `Use ${tool} instead.`,
- ];
- if (example) lines.push(`Example: ${example}`);
- return lines.join("\n");
-}
-
-export function buildGuardNotice(uri, hint = {}) {
- const lines = [
- `[OpenViking memory plugin] URI guard: this shell command contains the viking:// URI ${uri}.`,
- "viking:// URIs are OpenViking virtual paths, not local files, so cat, ls, grep and other file commands cannot open them.",
- `If you meant to read or search OpenViking content, use ${hint.tool || "the OpenViking MCP tools"} instead.`,
- ];
- if (hint.example) lines.push(`Example: ${hint.example}`);
- lines.push("If the URI is intentional data (an ov CLI argument, an HTTP payload, a search pattern), ignore this notice.");
- return lines.join("\n");
-}
-
-const SKILL_URI_RE = /^viking:\/\/(?:~|user\/[^/]+|agent)\/skills(?:\/|$)/i;
-const SHARED_SKILL_URI_RE = /^viking:\/\/agent\/skills(?:\/|$)/i;
-// The skills root, a skill directory, or its SKILL.md; anything deeper is a helper file.
-const SKILL_MD_URI_RE = /^viking:\/\/(?:~|user\/[^/]+|agent)\/skills(?:\/[^/]+(?:\/SKILL\.md)?)?\/?$/i;
-
-/**
- * Skills are installed through the MCP add_skill tool: write and edit refuse
- * the user's own skills subtree, and under the shared root they would bypass
- * installation.
- */
-export function isSkillUri(uri) {
- return SKILL_URI_RE.test(String(uri || ""));
-}
-
-/**
- * The add_skill call that replaces a write or edit aimed at `uri`. A shared
- * skill goes back to the shared root: without target_uri, add_skill makes a
- * private copy that then shadows it.
- */
-export function addSkillExample(uri, { call = "add_skill", edited = false } = {}) {
- const value = String(uri || "");
- const shared = SHARED_SKILL_URI_RE.test(value) ? ', target_uri="viking://agent/skills"' : "";
- return SKILL_MD_URI_RE.test(value)
- ? `${call}(data="<the full ${edited ? "edited " : ""}SKILL.md text>"${shared})`
- : `${call}(path="<local skill folder or .zip with the changed files>"${shared})`;
-}
-
-/** The hints a host gets when it names no table of its own. */
-export const DEFAULT_TOOL_HINTS = {
- read: {
- tool: "OpenViking MCP read",
- example: (uri) => `read(uris="${uri}")`,
- },
- glob: {
- tool: "OpenViking MCP glob or list",
- example: (uri, input = {}) => (
- `glob(pattern="${String(input.pattern ?? "**/*").replaceAll('"', '\\"')}", uri="${uri}")`
- ),
- },
- grep: {
- tool: "OpenViking MCP grep or search",
- example: (uri, input = {}) => (
- `grep(uri="${uri}", pattern="${String(input.pattern ?? "").replaceAll('"', '\\"')}")`
- ),
- },
- edit: {
- tool: (uri) => (isSkillUri(uri) ? "OpenViking MCP add_skill" : "OpenViking MCP edit"),
- example: (uri) => (
- isSkillUri(uri)
- ? addSkillExample(uri, { edited: true })
- : `edit(uri="${uri}", old_string="...", new_string="...")`
- ),
- },
- write: {
- tool: (uri) => (isSkillUri(uri) ? "OpenViking MCP add_skill" : "OpenViking MCP write"),
- example: (uri) => (
- isSkillUri(uri) ? addSkillExample(uri) : `write(uri="${uri}", content="...")`
- ),
- },
- bash: {
- tool: "OpenViking MCP read or search",
- example: (uri) => `read(uris="${uri}")`,
- },
- runcommand: {
- tool: "OpenViking MCP read or search",
- example: (uri) => `read(uris="${uri}")`,
- },
- shell: {
- tool: "OpenViking MCP read or search",
- example: (uri) => `read(uris="${uri}")`,
- },
-};
-
-// Tools whose argument is a command line rather than a location. A viking:// URI
-// in one is data (an `ov` argument, an HTTP payload, a grep pattern) as often as
-// a path the model hoped to open, so the command runs and the model gets a notice.
-const SHELL_TOOL_NAMES = new Set(["bash", "shell", "runcommand"]);
-
-// `pattern` is where glob looks but what grep looks for: a grep for the text
-// "viking://" in a local tree is not a path. The generic sweep still reaches
-// glob's pattern.
-const TEXT_ARGS_BY_TOOL = { grep: ["pattern"] };
-
-function resolveGuardedUri(toolName, input, { hints = DEFAULT_TOOL_HINTS } = {}) {
- const name = normalizeToolName(toolName);
- const hint = hints[name];
- if (!hint) return null;
- const textArgs = TEXT_ARGS_BY_TOOL[name];
- const uri = findVikingUri(input, DEFAULT_URI_KEYS, textArgs ? [...DEFAULT_CONTENT_KEYS, ...textArgs] : DEFAULT_CONTENT_KEYS);
- if (!uri) return null;
- return {
- uri,
- shell: SHELL_TOOL_NAMES.has(name),
- hint: {
- tool: typeof hint.tool === "function" ? hint.tool(uri, input) : hint.tool,
- example: typeof hint.example === "function" ? hint.example(uri, input) : hint.example,
- },
- };
-}
-
-/**
- * The deny decision for one tool call, or null when the call may proceed.
- *
- * A file tool whose path is a viking:// URI cannot succeed, and a write would
- * leave a junk local file, so it is denied. A shell tool is never denied here;
- * `evaluateUriNotice` covers it. `hints` carries the host's replacement tool
- * names and example calls, and a tool without a hint is not guarded.
- */
-export function evaluateUriGuard(toolName, input = {}, opts = {}) {
- const match = resolveGuardedUri(toolName, input, opts);
- if (!match || match.shell) return null;
- return { uri: match.uri, reason: buildGuardMessage(match.uri, match.hint) };
-}
-
-/** The notice for a shell command that carries a viking:// URI, or null. The command still runs. */
-export function evaluateUriNotice(toolName, input = {}, opts = {}) {
- const match = resolveGuardedUri(toolName, input, opts);
- if (!match?.shell) return null;
- return { uri: match.uri, reason: buildGuardNotice(match.uri, match.hint) };
-}
-
-/** The PreToolUse deny envelope claude-code, trae and zcode all read. */
-export function denyHookSpecificOutput(reason) {
- return {
- hookSpecificOutput: {
- hookEventName: "PreToolUse",
- permissionDecision: "deny",
- permissionDecisionReason: reason,
- },
- };
-}
-
-/** The PreToolUse notice envelope: no permissionDecision, so the host's own permission flow still runs. */
-export function noticeHookSpecificOutput(reason) {
- return { hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: reason } };
-}
-
-/** A hook event's tool name and input, under any of the spellings the hosts use. */
-export function readToolEvent(event = {}) {
- return {
- toolName: event.tool_name ?? event.toolName ?? event.name ?? event.tool,
- toolInput: event.tool_input ?? event.toolInput ?? event.input ?? {},
- };
-}
-
-/** The whole PreToolUse guard: a deny envelope, a notice envelope, or {}. */
-export function preToolUseOutput(event = {}, opts = {}) {
- const { toolName, toolInput } = readToolEvent(event);
- const denied = evaluateUriGuard(toolName, toolInput, opts);
- if (denied) return denyHookSpecificOutput(denied.reason);
- const notice = evaluateUriNotice(toolName, toolInput, opts);
- return notice ? noticeHookSpecificOutput(notice.reason) : {};
-}
-
-/** Cursor's beforeReadFile deny envelope. */
-export function denyCursorPermission(reason) {
- return { permission: "deny", user_message: reason };
-}
-
-function readHookInput() {
- try {
- const raw = readFileSync(0, "utf8").trim();
- return raw ? JSON.parse(raw) : {};
- } catch {
- return {};
- }
-}
-
-/**
- * Run a guard as a hook process: read the event off stdin, print the envelope.
- *
- * A guard is also imported by its harness tests, so the body only runs when the
- * module is the process entrypoint. An empty envelope prints nothing — every
- * host treats unrecognized or empty output as "no opinion", and one of them
- * rejects any key it does not know.
- */
-function isEntrypoint(moduleUrl) {
- if (!process.argv[1]) return false;
- try {
- return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(moduleUrl));
- } catch {
- return resolve(process.argv[1]) === fileURLToPath(moduleUrl);
- }
-}
-
-export function runUriGuardHook(moduleUrl, evaluate) {
- if (!isEntrypoint(moduleUrl)) return;
- const output = evaluate(readHookInput());
- if (Object.keys(output).length > 0) process.stdout.write(`${JSON.stringify(output)}\n`);
-}
diff --git a/examples/codex-memory-plugin/scripts/uri-guard.mjs b/examples/codex-memory-plugin/scripts/uri-guard.mjs
deleted file mode 100644
index 8ad6eaadf..000000000
--- a/examples/codex-memory-plugin/scripts/uri-guard.mjs
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env node
-
-import { preToolUseOutput, runUriGuardHook } from "./shared/uri-guard.mjs";
-
-export const evaluatePreToolUse = (input = {}) => preToolUseOutput(input);
-
-runUriGuardHook(import.meta.url, evaluatePreToolUse);
diff --git a/examples/codex-memory-plugin/scripts/uri-guard.test.mjs b/examples/codex-memory-plugin/scripts/uri-guard.test.mjs
deleted file mode 100644
index d942fc5e8..000000000
--- a/examples/codex-memory-plugin/scripts/uri-guard.test.mjs
+++ /dev/null
@@ -1,57 +0,0 @@
-import test from "node:test";
-import assert from "node:assert/strict";
-import { execFileSync } from "node:child_process";
-import { dirname, join } from "node:path";
-import { fileURLToPath } from "node:url";
-import { evaluatePreToolUse } from "./uri-guard.mjs";
-
-const scriptPath = join(dirname(fileURLToPath(import.meta.url)), "uri-guard.mjs");
-
-function codexEvent(toolName, toolInput) {
- return {
- session_id: "019a0000-0000-7000-8000-000000000000",
- turn_id: "turn-1",
- tool_use_id: "call-1",
- hook_event_name: "PreToolUse",
- cwd: "/repo",
- permission_mode: "default",
- tool_name: toolName,
- tool_input: toolInput,
- };
-}
-
-test("Codex URI guard lets Bash carrying a viking URI run with a notice", () => {
- const out = evaluatePreToolUse(codexEvent("Bash", { command: "ov read viking://resources/a.md" }));
-
- assert.equal(out.hookSpecificOutput?.hookEventName, "PreToolUse");
- assert.equal(out.hookSpecificOutput?.permissionDecision, undefined);
- assert.equal(out.hookSpecificOutput?.permissionDecisionReason, undefined);
- assert.match(out.hookSpecificOutput?.additionalContext ?? "", /viking:\/\/resources\/a\.md/);
- assert.match(out.hookSpecificOutput?.additionalContext ?? "", /ignore this notice/);
-});
-
-test("Codex URI guard notices a command given as an argv array", () => {
- const out = evaluatePreToolUse(codexEvent("Bash", { command: ["bash", "-lc", "cat viking://user/memories/a.md"] }));
-
- assert.equal(out.hookSpecificOutput?.permissionDecision, undefined);
- assert.match(out.hookSpecificOutput?.additionalContext ?? "", /viking:\/\/user\/memories\/a\.md/);
-});
-
-test("Codex URI guard stays silent for plain commands and apply_patch", () => {
- assert.deepEqual(evaluatePreToolUse(codexEvent("Bash", { command: "ls -la /tmp" })), {});
- assert.deepEqual(
- evaluatePreToolUse(codexEvent("apply_patch", {
- command: "*** Begin Patch\n*** Update File: README.md\n@@\n-local/path\n+viking://resources/docs\n*** End Patch\n",
- })),
- {},
- );
-});
-
-test("Codex URI guard hook prints the notice envelope and nothing otherwise", () => {
- const run = (event) => execFileSync("node", [scriptPath], { input: JSON.stringify(event), encoding: "utf-8" });
-
- const notice = JSON.parse(run(codexEvent("Bash", { command: "curl -d '{\"uri\":\"viking://resources/a\"}' http://127.0.0.1:1933" })));
- assert.deepEqual(Object.keys(notice), ["hookSpecificOutput"]);
- assert.deepEqual(Object.keys(notice.hookSpecificOutput).sort(), ["additionalContext", "hookEventName"]);
- assert.equal(run(codexEvent("Bash", { command: "echo hello" })), "");
-});
diff --git a/examples/codex-memory-plugin/skills/ov-memory-doctor/reference.md b/examples/codex-memory-plugin/skills/ov-memory-doctor/reference.md
index 6e36ee300..4aa9403e1 100644
--- a/examples/codex-memory-plugin/skills/ov-memory-doctor/reference.md
+++ b/examples/codex-memory-plugin/skills/ov-memory-doctor/reference.md
@@ -14,7 +14,7 @@ and `CODEX_CONFIG_FILE` relocate individual pieces.
| `~/.openviking/ovcli.conf.<name>` | Saved CLI profiles (`ov config switch` copies one over `ovcli.conf`). `ovcli.conf.bak.<epoch>` are installer backups. |
| `<repo root>/.openviking/config.json` / `config.local.json` | Workspace config layers, `version: 1` required: `peer.source`, `peer.id`, `recall.*`, `capture.*`, `bypass.session_patterns`, `usage.*`, `labels`. `config.json` is committed and shared; `config.local.json` is private and gitignored. Trusted without a prompt, but connection and credential keys (`url`, `api_key`, `account`, `user`, `extra_headers`, …) are stripped with a warning and `${VAR}` is never expanded. A blanket `.openviking/` rule in `.gitignore` stops `config.json` from ever being committed — narrow it to `.openviking/media/` and `.openviking/downloads/`. |
| `~/.openviking/workspaces/<slot>.json` | Per-machine workspace registry, one file per workspace (`<dir name>-<hash>.json`, mode 0600). Outranks both workspace files, and nothing writes it — a user creates the file by hand. An entry recorded for a different repository is ignored, not inherited. |
-| `~/.codex/config.toml` | `[features] hooks` (or legacy `plugin_hooks`), `[plugins."openviking-memory@openviking"] enabled`, `[marketplaces.openviking]` (source, ref), `[hooks.state."openviking-memory@openviking:hooks/hooks.json:<event>:0:0"] trusted_hash` for `session_start`, `user_prompt_submit`, `pre_tool_use`, `stop`, `session_end`, `pre_compact`. |
+| `~/.codex/config.toml` | `[features] hooks` (or legacy `plugin_hooks`), `[plugins."openviking-memory@openviking"] enabled`, `[marketplaces.openviking]` (source, ref), `[hooks.state."openviking-memory@openviking:hooks/hooks.json:<event>:0:0"] trusted_hash` for `session_start`, `user_prompt_submit`, `stop`, `session_end`, `pre_compact`. |
| `~/.codex/plugins/cache/openviking/openviking-memory/<version>/` | The copy Codex runs hooks from. Keyed by `plugin.json` version. |
| `~/.codex/.tmp/marketplaces/openviking/` | Git clone of the marketplace (GitHub/TOS dist); `examples/codex-memory-plugin` inside it is what `codex plugin list` reports as the source path. |
| `~/.openviking/codex-plugin-state/<session_id>.json` | Per-session state: `ovSessionId` (`cx-<session_id>`, null once committed), `transcriptPath` (last rollout seen, used by the SessionStart sweep to catch up unsent turns), `capturedTurnCount`, `captureFormatVersion` (2; absent means the old cursor format and is migrated on the next readable rollout), `lastUpdatedAt`. |
@@ -52,8 +52,8 @@ Codex plugin. Disable features with `OPENVIKING_AUTO_RECALL=0`,
`codex plugin remove openviking-memory@openviking` / `enabled = false`.
Hook budgets in `hooks/hooks.json`: SessionStart 70s, UserPromptSubmit 130s,
-PreToolUse 5s (`Bash` only, the `viking://` notice), Stop 30s, SessionEnd 3s
-(Codex clamps it there; the hook detaches a worker), PreCompact 60s.
+Stop 30s, SessionEnd 3s (Codex clamps it there; the hook detaches a worker),
+PreCompact 60s.
`recallTimeoutMs` (default 120000) must stay below 130s and `captureTimeoutMs`
(default 30000) at or below 30s.