@unblocklabs/unblock-codex-prompt 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # Unblock Codex Prompt
2
2
 
3
3
  A small, explicit prompt-management bridge for dedicated OpenClaw Mac agents.
4
- **Version 0.4.0.** The bridge supports OpenClaw/Codex 2026.10.5 and newer
4
+ **Version 0.5.1.** The bridge supports OpenClaw/Codex 2026.10.5 and newer
5
5
  stable releases with a reviewed context-assembly layout, and agents running
6
- through the Claude CLI backend on reviewed OpenClaw core layouts (2026.10.6–2026.10.9).
6
+ through the Claude CLI backend, whose whole system prompt it replaces through
7
+ OpenClaw's public `before_prompt_build` hook without patching OpenClaw core.
7
8
  See [Claude CLI agents](#claude-cli-agents).
8
9
 
9
10
  ## What you control
@@ -14,8 +15,9 @@ See [Claude CLI agents](#claude-cli-agents).
14
15
  - Each agent's memory reference (not memory bodies).
15
16
 
16
17
  **Identity and workspace files are live.** `SOUL.md`, `IDENTITY.md`, `USER.md`
17
- (shared and the session's selected personal file) and `AGENTS.md` are never
18
- snapshotted. OpenClaw loads them every turn, so an edit by you or by the agent
18
+ and `AGENTS.md` are never snapshotted. On Codex OpenClaw loads them every turn
19
+ (shared `USER.md` and the session's selected personal file); on Claude CLI the
20
+ plugin reads the workspace files every turn. An edit by you or by the agent
19
21
  applies to the next turn without a sync. The `MEMORY.md` body stays out of the
20
22
  prompt; a memory reference points to it.
21
23
 
@@ -23,7 +25,8 @@ prompt; a memory reference points to it.
23
25
  session's catalog from OpenClaw's own session skills snapshot, exactly as OpenClaw
24
26
  renders it; the plugin never compiles or freezes a copy. Codex gets it in the thread
25
27
  developer instructions (see below); Claude gets it through OpenClaw's native
26
- `openclaw-skills` mount, or the live session skills prompt when no mount exists.
28
+ `openclaw-skills` Claude plugin mount. When OpenClaw mounts no such plugin it lists
29
+ skills in its system prompt instead, and that list is dropped with the rest of that prompt.
27
30
 
28
31
  **The fleet policy is live too.** On Codex the generated file (fleet policy and memory
29
32
  reference) replaces Codex's native base through `model_instructions_file`.
@@ -46,9 +49,10 @@ of the downloaded policy.
46
49
 
47
50
  **Still live and untouched:** native AGENTS.md, native skills, tool schemas and
48
51
  executor protocol, sandbox/approvals, native collaboration mechanics, routing
49
- identifiers, date/timezone and user messages. Reviewed duplicate OpenClaw prose is
50
- normalized; unknown `extraSystemPrompt` additions, including incognito context, survive. This is not total
51
- prompt ownership; other plugins/hooks can still add instructions.
52
+ identifiers, date/timezone and user messages. On Codex, reviewed duplicate OpenClaw prose is
53
+ normalized; unknown `extraSystemPrompt` additions, including incognito context, survive.
54
+ On Claude CLI they are dropped (see [What Claude CLI no longer receives](#what-claude-cli-no-longer-receives)).
55
+ This is not total prompt ownership; other plugins/hooks can still add instructions.
52
56
 
53
57
  Customer documents stay on each agent's machine, outside this package. Snapshot
54
58
  files use private permissions.
@@ -70,6 +74,11 @@ files use private permissions.
70
74
  managed `model_instructions_file`; status cannot attest to launcher behavior.
71
75
  - One target agent per installation. Other agents use upstream behavior. Native
72
76
  Codex children inherit the fleet policy and live persona.
77
+ - Claude CLI: no OpenClaw core layout is reviewed or patched for Claude any more. The
78
+ plugin uses OpenClaw's public `before_prompt_build` hook, whose `systemPrompt`
79
+ result replaces the CLI system prompt, so it works on any OpenClaw version with that
80
+ hook behavior. Verified on **2026.10.6** and **2026.10.9** with
81
+ `scripts/validate-claude-hook.mjs` (see [Verify against an OpenClaw install](#verify-against-an-openclaw-install)).
73
82
 
74
83
  This bridge uses one private upstream seam, the guarded Codex context carriers,
75
84
  because public prompt hooks cannot fix the dropped-context path. It no longer depends
@@ -99,10 +108,11 @@ allowlist, visibility and size-limit logic; the plugin neither adds nor removes
99
108
  ## Claude CLI agents
100
109
 
101
110
  For agents whose models run through OpenClaw's `claude-cli` backend, the plugin
102
- replaces **only OpenClaw's generic operating policy** with the fleet policy for Claude.
103
- Identity and workspace files stay live through OpenClaw's own project context. Claude Code's native system prompt and prefix,
104
- `CLAUDE.md`, independently installed Claude skills/plugins, tool schemas,
105
- permissions and authentication are untouched. Other agents, other CLI backends and
111
+ replaces **OpenClaw's entire Claude CLI system prompt**, as it does for Codex. It
112
+ does this through OpenClaw's public `before_prompt_build` hook and never patches
113
+ OpenClaw core. Claude Code's native system prompt and prefix, `CLAUDE.md`,
114
+ independently installed Claude skills/plugins, tool schemas, permissions and
115
+ authentication are untouched. Other agents, other CLI backends and
106
116
  control/side-question operations keep upstream behavior.
107
117
 
108
118
  **Each runtime gets its own fleet policy.** The plugin fetches the configured
@@ -120,48 +130,96 @@ not depend on the Worker deploy.
120
130
 
121
131
  ### How it works
122
132
 
123
- OpenClaw renders the Claude CLI appended system prompt in core, not in a separate
124
- package. Two reviewed functions are patched with exact-byte backups, fingerprinted by
125
- function body (identical in 2026.10.6 and 2026.10.9) and located by following the
126
- assembly's own imports:
127
-
128
- - `buildCliAgentSystemPrompt` scopes management to the target agent and the
129
- host-generated `claude-cli/<model>` model display, then passes the hash-verified
130
- snapshot down. Tampered or invalid enrolled state aborts the run.
131
- - `buildAgentSystemPrompt` reuses OpenClaw's own builders for the retained mechanics
132
- and context, and omits the generic policy sections. Downstream Claude MCP
133
- tool-naming guidance, registered text transforms and the model identity line
134
- still apply.
135
-
136
- | Context or mechanic | Claude CLI treatment |
137
- |---|---|
138
- | Fleet operating policy | The Claude policy (`runtime=claude`), once; never the Codex policy |
139
- | SOUL / IDENTITY / shared USER / selected personal USER | Live host project context, with host persona and precedence wording |
140
- | MEMORY body, generic memory recall section | Omitted; managed memory reference retained |
141
- | AGENTS / TOOLS / HEARTBEAT / BOOTSTRAP and other eligible files | Live host-selected context, routing and truncation; bootstrap notices |
142
- | Unknown `extraSystemPrompt`, including incognito restrictions | Kept, with the reviewed duplicate-prose normalization |
143
- | Output directives, messaging/delivery mechanics, channel message-tool hints | Kept (OpenClaw's builders) |
144
- | Authorized senders, exec-approval protocol, sandbox/elevated facts, TTS, reactions, Control UI embeds, collapsible details | Kept |
145
- | Directory roles, temporal facts, Runtime section, git co-author guidance | Kept |
146
- | Runtime-context block protocol | Short plugin-owned mechanics note |
147
- | Identity line, tooling list, tool-call style, execution bias, Care, OpenClaw Control, delegation/orchestration, docs, model aliases, UI presentation, side chat, silent-reply section | Replaced by the fleet policy |
148
- | OpenClaw's generated `openclaw-skills` Claude plugin | Kept |
149
- | Live session skills catalog (only when OpenClaw mounts no native plugin) | Kept |
150
-
151
- **Skills are live on both runtimes.** Both take the catalog from OpenClaw's session
152
- skills snapshot, so skill selection follows OpenClaw's session/refresh lifecycle on
153
- each: Codex in its thread developer instructions, Claude through OpenClaw's native
154
- skills mount or the live session skills prompt.
155
-
156
- **Identity files are live on both runtimes, and so is the session's selected
157
- personal USER.md.** Unlike upstream OpenClaw, which keeps persona and personal files
158
- away from subagents, native Codex children inherit them with the thread developer
159
- instructions. Claude Code's native subagents do not receive the appended system
160
- prompt at all (verified on Claude Code 2.1.316), so they see neither the fleet policy
161
- nor persona. On Codex, editing a persona file or changing the skills catalog during a
162
- live incognito conversation changes its thread instructions, which Codex refuses for
163
- incognito threads: that thread's next turn fails. Start a new incognito conversation
164
- after such a change.
133
+ For a run whose hook context names the `claude-cli` provider and the target agent
134
+ (subagent sessions of that agent included), with an active enrollment that includes
135
+ Claude CLI, the hook returns `systemPrompt`. OpenClaw uses it in place of the prompt it
136
+ built (`prepareCliTurnPromptContext`), then applies registered text transforms and
137
+ appends its model identity line. The prompt is, in order, with nothing else added:
138
+
139
+ 1. the Claude fleet policy (`runtime=claude`), never the Codex policy;
140
+ 2. the memory reference (`## Memory reference`);
141
+ 3. local media context naming `<run-workspace>/media` as a generated-media staging
142
+ directory, rather than an arbitrary `/tmp` directory that media loaders may reject;
143
+ 4. each of `AGENTS.md`, `SOUL.md`, `IDENTITY.md`, `USER.md` and `BOOTSTRAP.md` that
144
+ exists in the run's workspace and is not empty, under a `## <absolute path>` header.
145
+ That is OpenClaw's own workspace bootstrap set without `MEMORY.md`, whose body is
146
+ never included. As in OpenClaw, `BOOTSTRAP.md` goes only to primary user or manual
147
+ runs, never to subagent sessions, heartbeats or cron.
148
+
149
+ The files are read on every call from the run's workspace (the configured agent
150
+ workspace when the run names none), so an edit applies to the next turn. Each file is
151
+ cut to OpenClaw's per-file bootstrap cap: the agent's `bootstrapMaxChars`, else
152
+ `agents.defaults.bootstrapMaxChars`, else OpenClaw's default of 20000 characters, and at
153
+ most 4000 for `USER.md` as in OpenClaw. All files together are cut to OpenClaw's total
154
+ budget, `bootstrapTotalMaxChars` (default 60000). A cut file keeps its head, with no
155
+ marker (OpenClaw keeps head and tail and adds a marker).
156
+ Symlinks are followed only within the workspace; a file resolving outside it, a
157
+ non-regular file or one over 2 MiB is left out with a warning.
158
+
159
+ The policy and memory reference come from the sync receipt, verified on every call
160
+ (enrollment, prompt-file hash). Invalid or tampered enrolled state is logged as an
161
+ error, without prompt text, and that run keeps OpenClaw's own prompt. Other agents,
162
+ other providers, and paused or never-enrolled agents are left alone. When the hook
163
+ returns nothing, OpenClaw's prompt applies unchanged.
164
+
165
+ **Attachments and local media.**
166
+
167
+ The prompt hook does not receive or change channel attachment settings. For iMessage
168
+ nodes that should receive attachments, explicitly enable forwarding:
169
+
170
+ ```sh
171
+ openclaw config set channels.imessage.includeAttachments true --strict-json
172
+ ```
173
+
174
+ For a named iMessage account, set the value under
175
+ `channels.imessage.accounts.<accountId>.includeAttachments` instead. OpenClaw defaults
176
+ this setting to false: without it, an incoming image can be absent from the agent's
177
+ turn even when the file exists in Messages. Restart the Gateway to re-subscribe the
178
+ iMessage watcher, then verify with an incoming image in a permitted conversation.
179
+ The plugin never changes channel settings during installation, sync or refresh.
180
+
181
+ Claude's local media context is rebuilt from the run's workspace every turn, including
182
+ subagent sessions. It names `<run-workspace>/media` for generated files that OpenClaw
183
+ must view or send; the directory is not created by the prompt hook. Paths returned by
184
+ OpenClaw's media tools remain usable. This does not widen media roots or change file
185
+ permissions. A `path-not-allowed` media error is different from macOS Full Disk Access:
186
+ use a supported staging path rather than granting arbitrary `/tmp` access.
187
+
188
+ **Skills.** Claude gets the session skills through OpenClaw's native `openclaw-skills`
189
+ Claude plugin mount, which is not part of the system prompt and is kept.
190
+
191
+ **Identity on both runtimes.** Native Codex children inherit persona with the thread
192
+ developer instructions. Claude Code's native subagents do not receive the appended
193
+ system prompt at all (verified on Claude Code 2.1.316), so they see neither the fleet
194
+ policy nor persona. On Codex, editing a persona file or changing the skills catalog
195
+ during a live incognito conversation changes its thread instructions, which Codex
196
+ refuses for incognito threads: that thread's next turn fails. Start a new incognito
197
+ conversation after such a change.
198
+
199
+ ### What Claude CLI no longer receives
200
+
201
+ Replacing the whole prompt drops everything OpenClaw puts in it for these runs, with no
202
+ exception for subagent sessions:
203
+
204
+ - `extraSystemPrompt` content: incognito restrictions, group-chat and channel prompts,
205
+ and subagent task framing;
206
+ - per-person `USER.md` overlays (the session's selected personal file); only the
207
+ workspace `USER.md` is carried;
208
+ - OpenClaw's generic sections: identity line, tooling list, tool-call style, execution
209
+ bias, Care, OpenClaw Control, delegation, docs, model aliases, UI presentation, side
210
+ chat and silent replies;
211
+ - its mechanics: output directives, messaging and delivery sections, channel hints,
212
+ authorized senders, exec-approval protocol, sandbox and elevated facts, TTS,
213
+ reactions, Control UI embeds, directory roles, the Runtime section, git co-author
214
+ guidance, bootstrap truncation notices, and the system-prompt skills list used when no
215
+ native skills plugin is mounted;
216
+ - the Claude backend's tool-name section, which OpenClaw adds before hooks run.
217
+
218
+ Still delivered: per-turn facts OpenClaw puts in the turn's user context (source
219
+ delivery, runtime context blocks, relocated runtime facts), the native skills mount,
220
+ `prependSystemContext`/`appendSystemContext` from other plugins' hooks, registered text
221
+ transforms and the model identity line. If several plugins return `systemPrompt`, the
222
+ highest-priority hook wins; this hook registers at priority 1000 so it runs first.
165
223
 
166
224
  ### Enroll
167
225
 
@@ -178,23 +236,27 @@ enroll a runtime by themselves.
178
236
 
179
237
  To drop a runtime, restore, change the agent's model configuration, then sync.
180
238
  The receipts and backups restore keeps are rollback evidence, so a restored
181
- runtime is not re-enrolled from them. If restore was interrupted and this plugin's
182
- patched bytes are still installed for a runtime that is no longer configured, sync
183
- refuses until `openclaw codex-prompt restore` completes.
184
-
185
- Both adapters share one rule for a receipt. It is cleared once every recorded file is
186
- back at its original bytes (a completed restore), or once nothing of the plugin's is
187
- left: every changed file is gone (an update renamed it, or the install directory was
188
- deleted) or the recorded install version was replaced. A sync after that starts fresh,
189
- may target a different OpenClaw installation or Codex package, and replaces the old
190
- receipt's backups. Otherwise sync keeps refusing foreign edits and foreign backups.
239
+ runtime is not re-enrolled from them. If a restore was interrupted and the Codex
240
+ adapter's patched bytes are still installed while Codex is no longer configured, sync
241
+ refuses until `openclaw codex-prompt restore` completes. A leftover 0.4 Claude core
242
+ patch is instead removed by sync (see [Upgrading from 0.4](#upgrading-from-04-and-openclaw-updates)).
243
+
244
+ The Codex adapter and the 0.4 Claude core receipt share one rule. A receipt is cleared
245
+ once every recorded file is back at its original bytes (a completed restore), or once
246
+ nothing of the plugin's is left: every changed file is gone (an update renamed it, or
247
+ the install directory was deleted) or the recorded install version was replaced. A
248
+ Codex sync after that starts fresh, may target a different Codex package, and replaces
249
+ the old receipt's backups. Otherwise sync and restore keep refusing foreign edits and
250
+ foreign backups.
191
251
 
192
252
  Codex `appServer` settings (agent-scoped local stdio only) are checked by sync when
193
253
  it selects Codex and reported by status as `codexConfigError` for a Codex
194
254
  enrollment. They never block Claude-only enrollment, status or restore.
195
255
 
196
- Claude CLI enrollment requires the conversation-access grant for the
197
- final-adoption gate:
256
+ Claude CLI enrollment needs the hook to be registrable. OpenClaw registers
257
+ `before_prompt_build` for a non-bundled plugin only with
258
+ `hooks.allowConversationAccess: true`, and blocks it when `hooks.allowPromptInjection`
259
+ is `false` (it defaults to allowed). Sync refuses Claude without both:
198
260
 
199
261
  ```json5
200
262
  {
@@ -222,76 +284,58 @@ the file in the Codex layout.
222
284
  **Where each policy is stored.** The Codex policy stays the prefix of the generated file
223
285
  (`model_instructions_file`, also sent as `baseInstructions`). The Claude policy and the
224
286
  shared agent context are stored in the sync receipt (`.unblock-codex-prompt-bundle.json`)
225
- as `claudePolicy` (`text`, `url`, `revision`, `checkedAt`) and `agentContext`. The managed
226
- Claude prompt is `claudePolicy.text`, a blank line, then `agentContext`, read from the
227
- receipt only; the generated file is still verified against the receipt's `promptSha256`.
228
- The receipt is the trust root for Claude: anyone who can write it can set the policy, as
229
- with the file. The final-adoption gate compares the rendered prompt with what the
230
- receipt currently yields, so an edit to `claudePolicy` after assembly blocks the run and
231
- an invalid or missing `claudePolicy` fails closed with a "run codex-prompt sync" error.
232
-
233
- **Activation:** drain the target agent's work and restart the Gateway to load the
234
- patched core (and to register the gate after adding the grant). From sync until that
235
- restart, the running Gateway still holds unpatched core, so the gate blocks the
236
- target agent's enrolled Claude runs. The next Claude CLI
237
- process receives the managed prompt. Later policy refreshes change the prompt hash
238
- that OpenClaw keys live Claude processes on, so the conversation's next turn starts a
239
- new process with the new revision and resumes the conversation; its earlier history
240
- is not cleaned. Validate each policy revision in a fresh native conversation.
241
-
242
- ### Final-adoption gate
243
-
244
- A `before_agent_run` gate, registered only with the grant above, checks enrolled
245
- Claude runs for the target agent. If the grant is removed after enrollment, the gate is
246
- not registered and those runs are not checked; startup logs this as an error. The CLI runner's gate context has no runtime
247
- identity, so an observe-only `before_prompt_build` hook marks runs whose preparation
248
- context reports `claude-cli`; it never changes the prompt. Keep `allowPromptInjection`
249
- unset or true. Model fallback reuses the run ID, so each preparation replaces the
250
- mark and a gate context naming a non-Claude provider is never checked as Claude: a
251
- Claude attempt that fails before execution cannot block its fallback. It blocks the run when the final system prompt
252
- lacks the verified managed policy, still contains OpenClaw's generic policy, or the
253
- managed state is invalid. This covers a lost assembly patch, a later prompt-hook
254
- replacement and an incompatible registered text transform. Never-enrolled or
255
- restored agents pass and are reported once with a sync suggestion. Prompt and
256
- history text are compared, never logged. It is a prompt-management guarantee
257
- while the plugin is enabled, not a security boundary.
258
-
259
- Known limitation: a run is marked as Claude only when OpenClaw's prompt-build hooks
260
- run. If OpenClaw cannot prepare those hooks (for example, history holding a value its
261
- hook isolation cannot copy), the run is not marked and the gate does not check it. The
262
- assembly patch still manages the prompt; only this extra check is skipped. The gate
263
- does not block unmarked runs, because at that point nothing reliably tells a Claude
264
- run from another CLI backend.
265
-
266
- ### OpenClaw updates and core integrity
267
-
268
- OpenClaw core ships `dist/postinstall-content-inventory.json`, which its update,
269
- triage and settlement paths compare against installed files. A patched core does
270
- not match it. Status reports `coreIntegrity` and distinguishes `patched`,
271
- `partial` (an interrupted restore), `original`, `missing` and `changed` core files. The plugin never edits vendor
272
- inventories.
273
-
274
- 1. `openclaw codex-prompt restore`, then confirm status reports `original`.
275
- 2. Update OpenClaw.
276
- 3. Review the new layout. Sync refuses an unreviewed assembly function.
277
- 4. `openclaw codex-prompt sync`, then restart the Gateway.
278
-
279
- If an update already replaced the patched chunks, restore leaves the updater's
280
- files alone (they are superseded) and restores any chunk still holding the plugin's
281
- bytes; enrolled Claude runs are blocked until re-sync. If OpenClaw was reinstalled in
282
- another directory and the old one deleted, the old receipt is superseded and sync
283
- targets the new installation directly. Prove update and rollback behavior on a disposable installation; inventory
284
- checks alone do not show which update paths fail.
285
-
286
- To review a layout without touching the Gateway's installation:
287
+ as `claudePolicy` (`text`, `url`, `revision`, `checkedAt`) and `agentContext`, and read
288
+ from the receipt only; the generated file is still verified against the receipt's
289
+ `promptSha256`. The receipt is the trust root for Claude: anyone who can write it can set
290
+ the policy, as with the file. An invalid or missing `claudePolicy` is reported by status
291
+ and leaves Claude runs on OpenClaw's prompt until `sync`.
292
+
293
+ **Activation.** The hook builds the prompt on every turn, so once the Gateway has
294
+ loaded this plugin version the target agent's next Claude turn uses it: no restart
295
+ after sync, refresh or a workspace edit. Installing or updating the plugin needs a
296
+ Gateway restart to load it; a grant change hot-reloads under OpenClaw's default hybrid
297
+ reload mode. A changed prompt changes the hash OpenClaw keys live Claude processes on,
298
+ so the conversation's next turn starts a new process that resumes the conversation; its
299
+ earlier history is not cleaned. Validate each policy revision in a fresh native
300
+ conversation. Status `claude.ready` means enrolled, a valid Claude policy, the hook
301
+ grant in place and no leftover 0.4 core patch.
302
+
303
+ Known limitations: OpenClaw runs prompt-build hooks only after it prepares them; if that
304
+ fails (for example, history its hook isolation cannot copy) or its turn-context
305
+ preparation fails, OpenClaw logs a warning and that run keeps OpenClaw's prompt. The
306
+ plugin cannot see those runs.
307
+
308
+ ### Upgrading from 0.4 and OpenClaw updates
309
+
310
+ 0.4 patched two OpenClaw core functions for Claude and kept a receipt
311
+ (`codex-home/.unblock-claude-prompt-adapter.json`) with exact-byte backups. On a node
312
+ with that patch still installed, status reports `legacyClaudeCore` with
313
+ `leftover: true` and Claude is not ready. `sync` validates the patched files and their
314
+ backups before writing anything, restores the original bytes, and reports
315
+ `legacyClaudeCoreRestored` with `restartRequired: true`: restart the Gateway to reload
316
+ the restored core. `restore` removes a leftover patch too. A same-version foreign edit
317
+ to a patched file is refused rather than overwritten; files an OpenClaw update already
318
+ replaced are left to the updater.
319
+
320
+ Updating OpenClaw needs no restore for Claude: there is nothing in core to remove. Run
321
+ `openclaw codex-prompt restore` first only while status still shows a leftover 0.4
322
+ patch, or for Codex as described below.
323
+
324
+ ### Verify against an OpenClaw install
287
325
 
288
326
  ```sh
289
327
  npm run build
290
- node scripts/validate-claude-layout.mjs /path/to/disposable/node_modules/openclaw
328
+ node scripts/validate-claude-hook.mjs /path/to/node_modules/openclaw [...]
291
329
  ```
292
330
 
293
- It patches that copy, renders managed and upstream prompts through the real
294
- assembly, restores, and checks restored bytes against the vendor inventory.
331
+ With no argument it checks the development dependency (also run by `npm test`). It
332
+ loads that OpenClaw's own plugin registrar, hook runner, `resolvePromptBuildHookResult`
333
+ and `prepareCliTurnPromptContext`, registers this plugin through them, and checks that
334
+ the hook's prompt replaces OpenClaw's, that turn context stays in the user prompt, and
335
+ that OpenClaw refuses the hook without the grant. It also asserts on the CLI runner's
336
+ source that the hook context carries the provider, agent and workspace, that the hook
337
+ result reaches the turn context, and that only finalization follows. It does not run a
338
+ Claude CLI process. It uses a temporary state directory and changes nothing installed.
295
339
 
296
340
  ## Install and enroll
297
341
 
@@ -299,7 +343,7 @@ assembly, restores, and checks restored bytes against the vendor inventory.
299
343
  npm ci
300
344
  npm run preflight
301
345
  npm pack
302
- openclaw plugins install ./unblocklabs-unblock-codex-prompt-0.4.0.tgz --force --accept-capabilities
346
+ openclaw plugins install ./unblocklabs-unblock-codex-prompt-0.5.1.tgz --force --accept-capabilities
303
347
  ```
304
348
 
305
349
  Include the plugin in `plugins.allow` if applicable, then configure:
@@ -325,8 +369,8 @@ required; the key keeps its historical name, though identity files are now live.
325
369
  Legacy `agentName` values remain accepted but are unused; identity comes from the
326
370
  live agent documents. Existing remote fleet configurations need no changes.
327
371
  Configurations without a remote URL or with base-only mode are no longer supported.
328
- Codex-only enrollment needs no conversation-access hook grant; Claude CLI
329
- enrollment requires one (see [Claude CLI agents](#claude-cli-agents)). Initial enrollment enables daily shared-prompt refresh
372
+ Codex-only enrollment needs no hook grant; Claude CLI enrollment needs
373
+ `hooks.allowConversationAccess: true` with prompt injection not disabled (see [Claude CLI agents](#claude-cli-agents)). Initial enrollment enables daily shared-prompt refresh
330
374
  and overdue startup catch-up. Startup never rebuilds local context or patches the
331
375
  adapter. The optional model-catalog service can also refresh metadata.
332
376
 
@@ -516,8 +560,8 @@ openclaw codex-prompt restore
516
560
  openclaw codex-prompt status
517
561
  ```
518
562
 
519
- Restore recovers exact original adapter bytes (Codex package and OpenClaw core),
520
- deactivates enrollment and restores the previous TOML pointer. It plans each adapter
563
+ Restore recovers exact original adapter bytes (the Codex package, and any 0.4 Claude
564
+ patch left in OpenClaw core), deactivates enrollment and restores the previous TOML pointer. It plans each adapter
521
565
  first, validating its files and the backups it will write; an adapter is restored only
522
566
  while any recorded file still holds the plugin's bytes. Restore then validates the
523
567
  pointer and pauses enrollment, and only then removes the Codex catalog and skills
@@ -528,30 +572,38 @@ foreign edits. A receipt whose files are restored, superseded or otherwise no lo
528
572
  hold the plugin's bytes never blocks a restore (its state is reported in the output
529
573
  and in status). Restore retains backup, receipt and generated files as rollback
530
574
  evidence; they do not keep a runtime enrolled. It does not require the current Codex
531
- `appServer` settings to be supported. Restart and use fresh conversations to activate it.
575
+ `appServer` settings to be supported. Restart and use fresh conversations to activate it
576
+ for Codex. Claude CLI turns use OpenClaw's prompt from the next turn, because the hook
577
+ reads the paused enrollment; a restart is needed only when a 0.4 core patch was removed.
532
578
  Restore **before** disabling/uninstalling or changing target agents. Disabling
533
579
  without restoring leaves the managed base but re-enables OpenClaw's generic injections.
534
580
 
581
+ ### Rolling back to 0.4
582
+
583
+ 0.4 manages Claude CLI through its OpenClaw core patch, and its final-adoption gate
584
+ blocks enrolled Claude runs whose prompt lacks it. Restore with 0.5 first, install 0.4,
585
+ then run its `sync` and restart the Gateway. The Codex adapter and the state format are
586
+ unchanged between 0.4 and 0.5.
587
+
535
588
  ### Rolling back to 0.3.x
536
589
 
537
- 1. With 0.4 still installed, run `openclaw codex-prompt restore`. A restored enrollment
590
+ 1. With 0.5 still installed, run `openclaw codex-prompt restore`. A restored enrollment
538
591
  is saved in the state format 0.3 reads.
539
592
  2. Restart the Gateway so the restored OpenClaw core and Codex package are loaded.
540
593
  3. Install the 0.3.x plugin, then run its `sync` if you want it to manage the agent again.
541
594
 
542
595
  0.3.x cannot manage Claude CLI agents. Any enrollment that includes Codex, with or
543
596
  without Claude, and any restored enrollment are saved in the format 0.3.x reads. If the
544
- plugin is rolled back without restoring first, the 0.4 patches find the older runtime
545
- and fall back instead of failing turns: 0.3.x keeps managing Codex, which reads the
546
- policy from its base file, and Claude renders OpenClaw's normal prompt. An active
547
- Claude-only enrollment is refused by 0.3.x; install 0.4 again and restore. 0.3.x
548
- rewrites the state without the Claude runtime when it syncs or restores, and does not
549
- restore OpenClaw core: after returning to 0.4, run restore (or sync) before relying on
550
- Claude runs. A 0.4 snapshot uses a heading 0.3.x's daily refresh does not recognize, so
597
+ plugin is rolled back without restoring first, the Codex patch finds the older runtime
598
+ and falls back instead of failing turns: 0.3.x keeps managing Codex, which reads the
599
+ policy from its base file, and Claude renders OpenClaw's normal prompt (0.3.x registers
600
+ no Claude hook). An active Claude-only enrollment is refused by 0.3.x; install 0.5 again
601
+ and restore. 0.3.x rewrites the state without the Claude runtime when it syncs or
602
+ restores. A 0.4 or 0.5 snapshot uses a heading 0.3.x's daily refresh does not recognize, so
551
603
  after rolling back, run 0.3.x's `sync` once to rebuild it. That sync reinstalls 0.3.x's
552
604
  Codex patch and its frozen skills catalog; drain and restart after it, as after any
553
- sync. Until then the 0.4 patch keeps relaying the live catalog (the relay is inline in
554
- the patch, so it does not depend on the plugin runtime).
605
+ sync. Until then the current Codex patch keeps relaying the live catalog (the relay is
606
+ inline in the patch, so it does not depend on the plugin runtime).
555
607
 
556
608
  ## Safety and scope
557
609
 
@@ -564,15 +616,15 @@ the patch, so it does not depend on the plugin runtime).
564
616
  - Do not run concurrent sync/install/restore operations. If a crash left an empty
565
617
  lock directory, confirm no sync is running before removing it.
566
618
  - A prompt guides behavior; it is not a security boundary or obedience guarantee.
567
- - The fleet policy replaces OpenClaw's generic policy, so upstream base-policy
568
- improvements are not inherited. Review upgrades.
619
+ - The fleet policy replaces OpenClaw's generic policy (on Claude CLI, OpenClaw's whole
620
+ system prompt), so upstream base-policy improvements are not inherited. Review upgrades.
569
621
  - Never commit customer snapshots, raw captures, credentials or host backups.
570
622
 
571
623
  ## Development and release
572
624
 
573
625
  ```sh
574
626
  npm run preflight
575
- npm run release:check -- v0.4.0
627
+ npm run release:check -- v0.5.1
576
628
  ```
577
629
 
578
630
  Tests cover compilation, explicit refresh, native/private-body exclusion,
@@ -582,7 +634,7 @@ proof and limits.
582
634
 
583
635
  Install with
584
636
  the packed archive above for an unreleased candidate. After publication, use
585
- `openclaw plugins install npm:@unblocklabs/unblock-codex-prompt@0.4.0 --accept-capabilities`.
637
+ `openclaw plugins install npm:@unblocklabs/unblock-codex-prompt@0.5.1 --accept-capabilities`.
586
638
  The existing [GitHub Release workflow](RELEASING.md) publishes npm only when a
587
639
  GitHub Release is published. Normal pushes do not release the package.
588
640
 
@@ -1,44 +1,13 @@
1
- import { type FunctionDeclaration, type Program } from "acorn";
2
- import { type PatchedFile, type RestorePlan } from "./patched-files.js";
3
- export declare const CLAUDE_ASSEMBLY_HASHES: {
4
- readonly buildCliAgentSystemPrompt: "6b21cdba8192074f8014243b8f8588bdcf51f8dada2f52f61c1787c7d3a60eb3";
5
- readonly buildConfiguredAgentSystemPrompt: "9f5a1c2923678008d7f276f7fc3af62af4e1cef8c5cc7678fcfe665d036e154a";
6
- readonly buildAgentSystemPrompt: "c81eb1a28a58a943bc17cec18459a2080ebf411a92811dc61b868d574312aa86";
7
- };
8
- type Role = keyof typeof CLAUDE_ASSEMBLY_HASHES;
9
- type Located = {
10
- role: Role;
11
- path: string;
12
- node: FunctionDeclaration;
13
- program: Program;
14
- };
15
- type Receipt = {
16
- schema: 1;
17
- openclawRoot: string;
18
- openclawVersion: string;
19
- files: PatchedFile[];
20
- };
1
+ import { type RestorePlan } from "./patched-files.js";
2
+ /** "patched" while any recorded core file still holds the 0.4 patch: a leftover to remove. */
21
3
  export declare function claudeAdapterOwnership(agentDir: string): Promise<import("./patched-files.js").Ownership>;
22
- /** Pure patch over original sources keyed by path; fingerprints are checked first. */
23
- export declare function patchClaudeAssembly(sources: Map<string, string>, located: Located[], agentDir: string, agentId: string, runtimePath: string): Map<string, string>;
24
- /** Locate the selected assembly chain from its single definition, following imports. */
25
- export declare function locateClaudeAssembly(root: string, read: (path: string) => Promise<string>): Promise<{
26
- sources: Map<string, string>;
27
- located: Located[];
28
- }>;
29
- export declare function prepareClaudeAdapter(agentDir: string, agentId: string, runtimePath: string, root?: string): Promise<{
30
- files: import("./patched-files.js").PreparedFile[];
31
- receipt: Receipt;
32
- previousReceipt: string | null;
33
- staleBackups: Set<string>;
34
- }>;
35
- export declare function installClaudeAdapter(agentDir: string, plan: Awaited<ReturnType<typeof prepareClaudeAdapter>>): Promise<{
36
- adapterChanged: boolean;
37
- restartRequired: boolean;
38
- }>;
39
- /** Disk state: distinguishes missing (e.g. after an OpenClaw update) from foreign edits. */
4
+ /**
5
+ * Disk state of a 0.4 receipt's files; distinguishes missing (e.g. after an OpenClaw update) from
6
+ * foreign edits. `leftover` is true while any recorded file still holds the 0.4 patch bytes.
7
+ */
40
8
  export declare function claudeAdapterStatus(agentDir: string): Promise<{
41
9
  installed: boolean;
10
+ leftover: boolean;
42
11
  state: "absent";
43
12
  openclawRoot?: never;
44
13
  openclawVersion?: never;
@@ -46,13 +15,14 @@ export declare function claudeAdapterStatus(agentDir: string): Promise<{
46
15
  coreIntegrity?: never;
47
16
  } | {
48
17
  installed: boolean;
18
+ leftover: boolean;
49
19
  state: "changed" | "patched" | "partial" | "original" | "missing";
50
20
  openclawRoot: string;
51
21
  openclawVersion: string | undefined;
52
22
  paths: string[];
53
23
  coreIntegrity: string;
54
24
  }>;
55
- /** Validates every recorded chunk before any write; empty unless this adapter's bytes are installed. */
25
+ /** Validates every recorded chunk and backup before any write; empty unless the 0.4 patch bytes are installed. */
56
26
  export declare function planClaudeRestore(agentDir: string): Promise<RestorePlan>;
57
27
  export declare function applyClaudeRestore(plan: RestorePlan): Promise<{
58
28
  ownership: import("./patched-files.js").Ownership;
@@ -60,4 +30,3 @@ export declare function applyClaudeRestore(plan: RestorePlan): Promise<{
60
30
  superseded: string[];
61
31
  restartRequired: boolean;
62
32
  }>;
63
- export {};