@unblocklabs/unblock-codex-prompt 0.3.0 → 0.4.0

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,24 +1,45 @@
1
1
  # Unblock Codex Prompt
2
2
 
3
3
  A small, explicit prompt-management bridge for dedicated OpenClaw Mac agents.
4
- **Version 0.3.0.** The frozen bridge supports OpenClaw/Codex 2026.9.2 and newer
5
- stable releases with a compatible context-assembly layout.
4
+ **Version 0.4.0.** The bridge supports OpenClaw/Codex 2026.10.5 and newer
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).
7
+ See [Claude CLI agents](#claude-cli-agents).
6
8
 
7
9
  ## What you control
8
10
 
9
11
  - Required `promptUrl`: the shared policy compiled from Fleet Prompt's dev/prod
10
- sections and served by Cloudflare. It is the only shared-policy source.
11
- - Each agent's local snapshot of `SOUL.md`, `IDENTITY.md`, `USER.md`, its eligible
12
- model-visible OpenClaw skills catalog, and a memory reference (not memory bodies).
13
-
14
- The generated instructions replace Codex's base through `model_instructions_file`.
15
- A narrowly patched Codex adapter also replaces OpenClaw's generic developer
16
- policy and suppresses the separate soul, memory and OpenClaw-skills
17
- contributions to collaboration instructions. Cron guidance remains in its existing
18
- parent-local carrier. The optional managed catalog removes native Default-mode prose.
12
+ sections and served by Cloudflare. It is the only shared-policy source; the plugin
13
+ selects the artifact per runtime (Codex: as configured; Claude: `runtime=claude`).
14
+ - Each agent's memory reference (not memory bodies).
15
+
16
+ **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
19
+ applies to the next turn without a sync. The `MEMORY.md` body stays out of the
20
+ prompt; a memory reference points to it.
21
+
22
+ **The OpenClaw skills catalog is live on both runtimes.** Each runtime receives the
23
+ session's catalog from OpenClaw's own session skills snapshot, exactly as OpenClaw
24
+ renders it; the plugin never compiles or freezes a copy. Codex gets it in the thread
25
+ 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.
27
+
28
+ **The fleet policy is live too.** On Codex the generated file (fleet policy and memory
29
+ reference) replaces Codex's native base through `model_instructions_file`.
30
+ The patched adapter also sends that same file as each thread's `baseInstructions` when
31
+ OpenClaw starts or resumes it. Codex reads base instructions per session, not from
32
+ history, and OpenClaw fingerprints these requests, so a refreshed revision resumes an
33
+ existing thread on its next turn with the new base: no duplicate copy, nothing in
34
+ history, and compaction cannot revert it. If the adapter is ever missing, Codex still
35
+ reads the policy from the file. The adapter replaces OpenClaw's generic developer
36
+ policy with the live OpenClaw skills catalog and the live persona, in the thread
37
+ developer instructions native children inherit, and suppresses the separate memory
38
+ contribution. Cron guidance remains in its existing parent-local carrier. The optional
39
+ managed model catalog removes native Default-mode prose.
19
40
 
20
41
  There are no bundled system/developer templates or base-only mode. Downloaded
21
- policy and frozen agent context are written only to
42
+ policy and the memory reference are written only to
22
43
  `<agentDir>/codex-home/unblock-codex-prompt.md`, outside the plugin directory.
23
44
  Codex reads that generated file; the plugin package does not retain its own copy
24
45
  of the downloaded policy.
@@ -30,13 +51,17 @@ normalized; unknown `extraSystemPrompt` additions, including incognito context,
30
51
  prompt ownership; other plugins/hooks can still add instructions.
31
52
 
32
53
  Customer documents stay on each agent's machine, outside this package. Snapshot
33
- files use private permissions. Missing identity documents are recorded as absent.
54
+ files use private permissions.
34
55
 
35
56
  ## Compatibility
36
57
 
37
- - Frozen bridge: **OpenClaw and @openclaw/codex >=2026.9.2**. Reviewed layouts cover
38
- 2026.9.2, 2026.9.3, 2026.9.4, 2026.9.8, 2026.9.9, 2026.10.6 and 2026.10.8, including parent-local context,
39
- refreshable instructions and split `dist/.setup/` bundles. Bundle names
58
+ - Codex: **OpenClaw and @openclaw/codex >=2026.10.5**. Every published release from
59
+ 2026.10.5 through 2026.10.9 has the identical reviewed context-assembly functions.
60
+ Older layouts (2026.9.x and 2026.10.1–2026.10.4) are refused: 2026.9.x carries
61
+ persona in turn-scoped text native children never see. Nodes on those versions
62
+ stay on plugin 0.3.x until upgraded; restore still works for them. Once the Codex
63
+ update has replaced the 0.3.x-patched bundles (new names), a 0.4 sync starts fresh
64
+ without a restore. Bundle names
40
65
  may change; fingerprints of the context-assembly functions must still match.
41
66
  Changed assembly is refused pending review, rather than patched blindly.
42
67
  - Local stdio Codex with an OpenClaw agent-scoped home. Operator-selected
@@ -44,29 +69,229 @@ files use private permissions. Missing identity documents are recorded as absent
44
69
  The launcher must honor OpenClaw's `CODEX_HOME` and must not override the
45
70
  managed `model_instructions_file`; status cannot attest to launcher behavior.
46
71
  - One target agent per installation. Other agents use upstream behavior. Native
47
- children may inherit the parent's frozen context.
48
-
49
- This bridge uses two private upstream seams because public prompt hooks cannot
50
- fix the dropped-context path: one skill-catalog builder and guarded Codex context
51
- carriers. Older builds require parent-local suppression and removal of the
52
- separate thread-level skills append. The 2026.10.6/2026.10.8 recipe suppresses live
53
- persona, memory and OpenClaw skills at their producers, so initial threads, reuse,
54
- parent-local inference and compaction all receive the frozen context. Native
55
- AGENTS and operational context remain live; cron guidance and execution permissions
56
- are unchanged. On reviewed 2026.10.6/2026.10.8 layouts, the adapter additionally
72
+ Codex children inherit the fleet policy and live persona.
73
+
74
+ This bridge uses one private upstream seam, the guarded Codex context carriers,
75
+ because public prompt hooks cannot fix the dropped-context path. It no longer depends
76
+ on OpenClaw's private skills-catalog builder. The adapter suppresses memory at its
77
+ producer and moves two host-rendered contributions out of the parent-only and
78
+ refreshable carriers into the thread developer instructions, after the fleet policy:
79
+ the session's OpenClaw skills catalog (with OpenClaw's `skills_search`/`skills_read`
80
+ hints, exactly as upstream renders it, and nothing when upstream renders nothing), then
81
+ the persona (SOUL, IDENTITY, shared USER and the selected personal USER). Those are
82
+ rebuilt every turn: a catalog change or persona edit changes them, and Codex re-syncs
83
+ the existing thread on its next turn with a policy handoff. They survive compaction
84
+ and are inherited by native children. Native AGENTS and operational context remain
85
+ live; cron guidance and execution permissions are unchanged. The adapter additionally
57
86
  removes active-computer context, known Slack participation/style/activation policy,
58
87
  duplicate progress-card prose and basic Markdown tutorials. It compacts source
59
88
  delivery to current facts and scopes meaningful exec overrides to OpenClaw Gateway
60
89
  exec; inherited steady-state defaults are omitted. Unrecognized additions are
61
- preserved, not removed by heading. Older layouts retain their original per-turn
62
- operational carriers. Changed operational functions require review before sync.
90
+ preserved, not removed by heading. Changed operational functions require review
91
+ before sync.
63
92
  The installer backs up and tracks every
64
93
  patched bundle; old single-file receipts remain restorable. Runtime module paths
65
94
  come from the loader's selected entry, never its temporary execution capture.
66
95
  It validates private seams and is not a promise of compatibility with unseen layouts.
67
- The catalog uses OpenClaw's eligibility, allowlist, visibility and size-limit
68
- logic. Session-specific and execution-directory skills are not snapshotted.
69
- Remote-node-only skills are not added; this is for dedicated local Mac agents.
96
+ The skills catalog is OpenClaw's own per-session snapshot, with its eligibility,
97
+ allowlist, visibility and size-limit logic; the plugin neither adds nor removes skills.
98
+
99
+ ## Claude CLI agents
100
+
101
+ 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
106
+ control/side-question operations keep upstream behavior.
107
+
108
+ **Each runtime gets its own fleet policy.** The plugin fetches the configured
109
+ `promptUrl` once per enrolled runtime. Codex fetches it exactly as configured, with no
110
+ `runtime` parameter (the Worker returns the Codex artifact). Claude fetches it with
111
+ `runtime=claude` added (via the URL API, so `channel` and other parameters are kept) and
112
+ requires the Worker to confirm it in `X-Prompt-Runtime`. The policy wording lives in
113
+ the Fleet Prompt sections, not in this package.
114
+
115
+ **Deploy order.** Deploy the fleet-prompt Worker with runtime support **before**
116
+ enrolling any Claude agent. A Worker without it answers `runtime=claude` with HTTP 400:
117
+ sync then writes nothing and tells you to deploy the Worker, and a daily refresh keeps
118
+ the installed policy and retries hourly. Codex-only nodes never send `runtime` and do
119
+ not depend on the Worker deploy.
120
+
121
+ ### How it works
122
+
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.
165
+
166
+ ### Enroll
167
+
168
+ Sync derives runtimes from the agent's configured models using OpenClaw's public
169
+ `api.runtime.modelConfig.resolveModelRuntimePolicy`. Models resolve as OpenClaw resolves
170
+ them: the agent's own model replaces the default primary and, unless it lists its own,
171
+ the default fallbacks. The agent's own allowed-model map also counts, because the agent
172
+ can switch to those models at run time; the Gateway-wide `agents.defaults.models` map
173
+ does not.
174
+ Legacy `claude-cli/<model>` refs count as Claude CLI. This reads authored policy,
175
+ not availability; each turn's actual execution path stays authoritative. Sync adds
176
+ components and never removes one; use restore. Configuration changes never
177
+ enroll a runtime by themselves.
178
+
179
+ To drop a runtime, restore, change the agent's model configuration, then sync.
180
+ 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.
191
+
192
+ Codex `appServer` settings (agent-scoped local stdio only) are checked by sync when
193
+ it selects Codex and reported by status as `codexConfigError` for a Codex
194
+ enrollment. They never block Claude-only enrollment, status or restore.
195
+
196
+ Claude CLI enrollment requires the conversation-access grant for the
197
+ final-adoption gate:
198
+
199
+ ```json5
200
+ {
201
+ plugins: { entries: { "unblock-codex-prompt": {
202
+ enabled: true,
203
+ hooks: { allowConversationAccess: true },
204
+ config: { agentId: "main", frozenContext: true, promptUrl: "https://fleet-prompt.unblocklabs.ai/prompt?channel=dev" },
205
+ } } },
206
+ }
207
+ ```
208
+
209
+ ```sh
210
+ openclaw codex-prompt sync # add --codex-plugin-dir for a first Codex enrollment
211
+ openclaw codex-prompt status
212
+ ```
213
+
214
+ A Claude-only agent needs no Codex package, TOML pointer, provider catalog
215
+ credentials or Codex skill-config writes. Snapshot files still live under
216
+ `<agentDir>/codex-home/`. Its sync never fetches the Codex artifact. Its generated
217
+ prompt file holds only the shared agent context
218
+ (the `## Memory reference` section), so the file's hash still anchors the
219
+ sync receipt; there is no Codex policy prefix to refresh. Adding Codex later (sync) regenerates
220
+ the file in the Codex layout.
221
+
222
+ **Where each policy is stored.** The Codex policy stays the prefix of the generated file
223
+ (`model_instructions_file`, also sent as `baseInstructions`). The Claude policy and the
224
+ 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
+
288
+ ```sh
289
+ npm run build
290
+ node scripts/validate-claude-layout.mjs /path/to/disposable/node_modules/openclaw
291
+ ```
292
+
293
+ It patches that copy, renders managed and upstream prompts through the real
294
+ assembly, restores, and checks restored bytes against the vendor inventory.
70
295
 
71
296
  ## Install and enroll
72
297
 
@@ -74,7 +299,7 @@ Remote-node-only skills are not added; this is for dedicated local Mac agents.
74
299
  npm ci
75
300
  npm run preflight
76
301
  npm pack
77
- openclaw plugins install ./unblocklabs-unblock-codex-prompt-0.3.0.tgz --force --accept-capabilities
302
+ openclaw plugins install ./unblocklabs-unblock-codex-prompt-0.4.0.tgz --force --accept-capabilities
78
303
  ```
79
304
 
80
305
  Include the plugin in `plugins.allow` if applicable, then configure:
@@ -96,10 +321,12 @@ Include the plugin in `plugins.allow` if applicable, then configure:
96
321
  ```
97
322
 
98
323
  `agentId` defaults to `main`. Both `promptUrl` and `frozenContext: true` are
99
- required. Legacy `agentName` values remain accepted but are unused; identity comes
100
- from local agent documents. Existing remote fleet configurations need no changes.
324
+ required; the key keeps its historical name, though identity files are now live.
325
+ Legacy `agentName` values remain accepted but are unused; identity comes from the
326
+ live agent documents. Existing remote fleet configurations need no changes.
101
327
  Configurations without a remote URL or with base-only mode are no longer supported.
102
- No conversation-access hook grant is needed. Initial enrollment enables daily shared-prompt refresh
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
103
330
  and overdue startup catch-up. Startup never rebuilds local context or patches the
104
331
  adapter. The optional model-catalog service can also refresh metadata.
105
332
 
@@ -110,10 +337,8 @@ plain-text content, a 256 KiB limit, UTF-8, and the endpoint's SHA-256
110
337
  `X-Prompt-Revision` header, with a ten-second request timeout. These integrity
111
338
  checks are not a signature; the configured HTTPS publisher controls the policy.
112
339
 
113
- The remote text supplies the shared Codex base; the OpenClaw generic developer
114
- policy is empty rather than a second shared-policy copy. Empty policy is valid
115
- only within the normal hash/pointer-validated frozen
116
- bundle. The frozen local context is still appended.
340
+ The remote text supplies the shared base and replaces OpenClaw's generic developer
341
+ policy; the generated file is hash-checked against its sync receipt at every assembly.
117
342
  No local documents are sent to the Worker. The installed snapshot is the local
118
343
  last-known-good generated file in the agent's managed home: a failed fetch aborts
119
344
  sync before writes and does not disrupt normal turns. There is no bundled fallback. Status shows
@@ -130,8 +355,8 @@ openclaw codex-prompt status
130
355
 
131
356
  `--adopt` explicitly takes ownership of an existing custom prompt pointer. Its
132
357
  previous value is retained for restoration; leave the original file in place.
133
- First frozen sync compiles local documents/catalog and installs the guarded
134
- adapter patch with a private original-source backup. Later syncs reuse its receipt.
358
+ First sync compiles the memory reference and installs the guarded adapter patch with
359
+ a private original-source backup. Later syncs reuse its receipt.
135
360
 
136
361
  ## Refresh and activate
137
362
 
@@ -140,16 +365,30 @@ openclaw codex-prompt sync
140
365
  openclaw codex-prompt status
141
366
  ```
142
367
 
143
- Only explicit `sync` rebuilds local documents, skills, and the adapter policy.
144
- The daily service fetches the configured Worker channel and
145
- replaces only the shared prompt prefix when its content changes. The existing
146
- frozen context is preserved byte-for-byte, without rereading workspace files.
147
- Editing a source document or restarting does not rebuild that local snapshot.
148
- Skill bodies remain files the model reads when triggered; their contents are not
149
- frozen. The catalog and its selection are frozen.
368
+ Only explicit `sync` rebuilds the memory reference and adapter policy.
369
+ Sync fetches every enrolled runtime's policy before writing anything; if any fetch
370
+ fails, nothing is written. The daily service fetches the configured Worker channel for
371
+ each enrolled runtime, then, in one locked write, replaces only the Codex policy prefix
372
+ of the generated file and/or `claudePolicy` in the receipt when their content changes;
373
+ everything after the Codex prefix is preserved byte-for-byte, and a Claude-only change
374
+ leaves the Codex file untouched (same bytes and inode). Identity and workspace files
375
+ and the skills catalog need neither: they are read live every turn. The catalog lists
376
+ each skill's name, description and location; skill bodies remain files the model reads
377
+ when triggered. Editing only a `SKILL.md` body therefore does not change the catalog
378
+ (or the Codex thread instructions); the next read of that file sees the edit.
379
+
380
+ A snapshot written by an earlier version still ends in its frozen skills catalog.
381
+ Refresh keeps that tail byte-for-byte until the next `sync` rewrites the file without
382
+ it. The earlier adapter suppressed the live catalog, so no thread sees both copies,
383
+ and no migration is needed: sync, then restart as below.
150
384
 
151
385
  **After sync, drain work, restart the Gateway/managed app-server, and use new
152
- conversations.** Existing native threads may retain earlier base instructions.
386
+ conversations.** Sync can change the adapter itself, which a running app-server keeps
387
+ until restart. Policy refreshes, identity edits and catalog changes need neither.
388
+ Upgrading from a version with a frozen catalog: between this sync and the restart, the
389
+ running Gateway still holds the earlier patch, which suppresses the live catalog, while
390
+ the new file no longer carries the frozen one, so Codex turns in that window have no
391
+ skills catalog. Drain the agent before sync and restart right after it.
153
392
  The plugin never interrupts or resets sessions. Capture an actual request after
154
393
  provisioning or upgrades; `status` is disk evidence, not live adoption.
155
394
 
@@ -169,12 +408,11 @@ possible higher-priority Codex config override. An upgrade replacing the adapter
169
408
  removes the guard; startup status is diagnostic, not a global inference gate.
170
409
  Restore before upgrading, then revalidate compatibility before reenrollment.
171
410
 
172
- If an upgrade already removed the old package generation, do not run restore
173
- against replacement files or rewrite receipt paths. Verify that every old target
174
- is absent and each retained original backup matches its receipt hash, privately
175
- archive the stale receipt, then install the reviewed adapter against the current
176
- inspected official package. Keep the frozen snapshot and operator-selected launcher intact
177
- unless a new snapshot was requested. A source update still requires idle activation
411
+ If an upgrade already removed the old package generation, restore leaves the
412
+ replacement files alone and the old receipt is superseded: sync installs the reviewed
413
+ adapter against the current inspected official package without editing receipts.
414
+ Keep the snapshot and operator-selected launcher intact unless a new snapshot was
415
+ requested. A source update still requires idle activation
178
416
  and fresh-session verification; disk status alone does not prove adoption.
179
417
 
180
418
  ### Daily shared-prompt refresh
@@ -185,14 +423,23 @@ Use `openclaw codex-prompt refresh` to run the same remote-prompt and enabled
185
423
  model-catalog refresh immediately, without resnapshotting local context.
186
424
 
187
425
  Both components are attempted independently: a catalog outage cannot prevent a
188
- prompt update, or vice versa. Failed fetches or validation keep the installed
189
- copy; failures retry hourly. Unchanged prompt content is not rewritten. Status
190
- includes the remote revision and last successful `checkedAt` timestamp. Updates
191
- are intended for fresh conversations; existing conversations are left alone.
426
+ prompt update, or vice versa. Within the shared prompt, every enrolled runtime is
427
+ fetched first: if any fetch fails or validation fails, neither runtime's policy is
428
+ updated; failures retry hourly. Unchanged prompt content is not rewritten. Status
429
+ reports each runtime's policy revision and last successful `checkedAt` timestamp:
430
+ `remotePrompt` for Codex and `claudePolicy` (`url`, `revision`, `checkedAt`) for Claude;
431
+ policy text is never printed. A changed
432
+ revision reaches existing conversations on their next turn: Codex resumes the thread
433
+ with the new base instructions (`nextCodexTurn`), and Claude starts the next CLI
434
+ process with the new prompt, resuming the conversation (`nextClaudeProcess`). Earlier
435
+ history is not rewritten. A live Codex incognito conversation cannot be resumed; it
436
+ keeps the revision it started with.
192
437
  The plugin never restarts the Gateway automatically.
193
438
 
194
439
  Existing remote snapshots migrate their shared/context boundary without rereading
195
- agent files. Ambiguous or externally modified snapshots are refused rather than
440
+ agent files. A node upgraded from 0.3.x keeps its frozen identity copy and old
441
+ adapter until its next `sync`, which installs live identity and policy delivery;
442
+ until then refreshes still reach only new conversations. Ambiguous or externally modified snapshots are refused rather than
196
443
  guessed; inspect them and use explicit `sync` to rebuild when appropriate.
197
444
 
198
445
  ## Optional daily model-catalog refresh
@@ -269,11 +516,42 @@ openclaw codex-prompt restore
269
516
  openclaw codex-prompt status
270
517
  ```
271
518
 
272
- Restore recovers exact original adapter bytes, deactivates enrollment and restores
273
- the previous TOML pointer. It refuses foreign edits and retains backup, receipt
274
- and generated files. Restart and use fresh conversations to activate it.
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
521
+ first, validating its files and the backups it will write; an adapter is restored only
522
+ while any recorded file still holds the plugin's bytes. Restore then validates the
523
+ pointer and pauses enrollment, and only then removes the Codex catalog and skills
524
+ block and restores the adapters, so a refusal changes nothing and no run sees a
525
+ half-restored bridge. Missing files, and files with other bytes after the recorded
526
+ version changed, are superseded and left to the updater; other changes are refused as
527
+ foreign edits. A receipt whose files are restored, superseded or otherwise no longer
528
+ hold the plugin's bytes never blocks a restore (its state is reported in the output
529
+ and in status). Restore retains backup, receipt and generated files as rollback
530
+ 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.
275
532
  Restore **before** disabling/uninstalling or changing target agents. Disabling
276
- without restoring leaves the frozen base but re-enables live injections.
533
+ without restoring leaves the managed base but re-enables OpenClaw's generic injections.
534
+
535
+ ### Rolling back to 0.3.x
536
+
537
+ 1. With 0.4 still installed, run `openclaw codex-prompt restore`. A restored enrollment
538
+ is saved in the state format 0.3 reads.
539
+ 2. Restart the Gateway so the restored OpenClaw core and Codex package are loaded.
540
+ 3. Install the 0.3.x plugin, then run its `sync` if you want it to manage the agent again.
541
+
542
+ 0.3.x cannot manage Claude CLI agents. Any enrollment that includes Codex, with or
543
+ 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
551
+ after rolling back, run 0.3.x's `sync` once to rebuild it. That sync reinstalls 0.3.x's
552
+ 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).
277
555
 
278
556
  ## Safety and scope
279
557
 
@@ -286,14 +564,15 @@ without restoring leaves the frozen base but re-enables live injections.
286
564
  - Do not run concurrent sync/install/restore operations. If a crash left an empty
287
565
  lock directory, confirm no sync is running before removing it.
288
566
  - A prompt guides behavior; it is not a security boundary or obedience guarantee.
289
- - Frozen prompts do not inherit upstream base-policy improvements. Review upgrades.
567
+ - The fleet policy replaces OpenClaw's generic policy, so upstream base-policy
568
+ improvements are not inherited. Review upgrades.
290
569
  - Never commit customer snapshots, raw captures, credentials or host backups.
291
570
 
292
571
  ## Development and release
293
572
 
294
573
  ```sh
295
574
  npm run preflight
296
- npm run release:check -- v0.3.0
575
+ npm run release:check -- v0.4.0
297
576
  ```
298
577
 
299
578
  Tests cover compilation, explicit refresh, native/private-body exclusion,
@@ -303,7 +582,7 @@ proof and limits.
303
582
 
304
583
  Install with
305
584
  the packed archive above for an unreleased candidate. After publication, use
306
- `openclaw plugins install npm:@unblocklabs/unblock-codex-prompt@0.3.0 --accept-capabilities`.
585
+ `openclaw plugins install npm:@unblocklabs/unblock-codex-prompt@0.4.0 --accept-capabilities`.
307
586
  The existing [GitHub Release workflow](RELEASING.md) publishes npm only when a
308
587
  GitHub Release is published. Normal pushes do not release the package.
309
588
 
package/dist/adapter.d.ts CHANGED
@@ -1,37 +1,27 @@
1
- type AdapterFile = {
2
- path: string;
3
- originalSha256: string;
4
- patchedSha256: string;
5
- previousPatchedSha256?: string;
6
- };
1
+ import { type PatchedFile, type RestorePlan } from "./patched-files.js";
2
+ /** packageVersion (recorded since 0.4) lets restore tell an updater's replacement from a foreign edit. */
7
3
  type Receipt = ({
8
4
  schema: 1;
9
5
  packageDir: string;
10
- } & AdapterFile) | {
6
+ } & PatchedFile) | {
11
7
  schema: 2;
12
8
  packageDir: string;
13
- files: AdapterFile[];
9
+ packageVersion?: string;
10
+ files: PatchedFile[];
14
11
  };
15
12
  export declare function readReceipt(agentDir: string): Promise<Receipt | null>;
13
+ export declare function codexAdapterOwnership(agentDir: string): Promise<import("./patched-files.js").Ownership>;
16
14
  export declare function patchAdapterSources(sources: string[], agentDir: string, agentId: string, runtimePath: string): string[];
17
15
  export declare function prepareAdapter(agentDir: string, agentId: string, suppliedDir: string | undefined, runtimePath: string): Promise<{
18
- files: {
19
- patched: string;
20
- path: string;
21
- current: string;
22
- original: string;
23
- }[];
16
+ files: import("./patched-files.js").PreparedFile[];
24
17
  receipt: {
25
18
  schema: 2;
26
19
  packageDir: string;
27
- files: {
28
- previousPatchedSha256?: string;
29
- path: string;
30
- originalSha256: string;
31
- patchedSha256: string;
32
- }[];
20
+ packageVersion: string;
21
+ files: PatchedFile[];
33
22
  };
34
23
  previousReceipt: string | null;
24
+ staleBackups: Set<string>;
35
25
  }>;
36
26
  export declare function installAdapter(agentDir: string, plan: Awaited<ReturnType<typeof prepareAdapter>>): Promise<{
37
27
  adapterChanged: boolean;
@@ -39,14 +29,22 @@ export declare function installAdapter(agentDir: string, plan: Awaited<ReturnTyp
39
29
  }>;
40
30
  export declare function adapterStatus(agentDir: string): Promise<{
41
31
  installed: boolean;
42
- path?: never;
43
- paths?: never;
44
- minimumVersion?: never;
32
+ state: "absent";
45
33
  } | {
34
+ minimumVersion: string;
35
+ packageVersion?: string;
46
36
  installed: boolean;
37
+ state: "changed" | "patched" | "partial" | "original" | "missing";
47
38
  path: string;
48
39
  paths: string[];
49
- minimumVersion: string;
40
+ packageDir: string;
41
+ }>;
42
+ /** Validates every recorded file before any write; empty unless this adapter's bytes are installed. */
43
+ export declare function planAdapterRestore(agentDir: string): Promise<RestorePlan>;
44
+ export declare function applyAdapterRestore(plan: RestorePlan): Promise<{
45
+ ownership: import("./patched-files.js").Ownership;
46
+ files: string[];
47
+ superseded: string[];
48
+ restartRequired: boolean;
50
49
  }>;
51
- export declare function restoreAdapter(agentDir: string): Promise<void>;
52
50
  export {};