@unblocklabs/unblock-codex-prompt 0.3.0 → 0.5.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 +376 -70
- package/dist/adapter.d.ts +23 -25
- package/dist/adapter.js +141 -152
- package/dist/claude-adapter.d.ts +32 -0
- package/dist/claude-adapter.js +91 -0
- package/dist/claude-prompt.d.ts +36 -0
- package/dist/claude-prompt.js +134 -0
- package/dist/compatibility.d.ts +1 -1
- package/dist/compatibility.js +4 -3
- package/dist/compiler.d.ts +103 -13
- package/dist/compiler.js +42 -37
- package/dist/index.js +249 -64
- package/dist/managed-target.d.ts +25 -0
- package/dist/managed-target.js +46 -0
- package/dist/manager.d.ts +72 -18
- package/dist/manager.js +131 -40
- package/dist/patched-files.d.ts +117 -0
- package/dist/patched-files.js +160 -0
- package/dist/refresh-error.js +2 -0
- package/dist/remote.d.ts +27 -2
- package/dist/remote.js +23 -4
- package/dist/runtime.d.ts +23 -1
- package/dist/runtime.js +84 -14
- package/dist/runtimes.d.ts +34 -0
- package/dist/runtimes.js +79 -0
- package/openclaw.plugin.json +4 -4
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,42 +1,71 @@
|
|
|
1
1
|
# Unblock Codex Prompt
|
|
2
2
|
|
|
3
3
|
A small, explicit prompt-management bridge for dedicated OpenClaw Mac agents.
|
|
4
|
-
**Version 0.
|
|
5
|
-
stable releases with a
|
|
4
|
+
**Version 0.5.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, whose whole system prompt it replaces through
|
|
7
|
+
OpenClaw's public `before_prompt_build` hook without patching OpenClaw core.
|
|
8
|
+
See [Claude CLI agents](#claude-cli-agents).
|
|
6
9
|
|
|
7
10
|
## What you control
|
|
8
11
|
|
|
9
12
|
- 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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
sections and served by Cloudflare. It is the only shared-policy source; the plugin
|
|
14
|
+
selects the artifact per runtime (Codex: as configured; Claude: `runtime=claude`).
|
|
15
|
+
- Each agent's memory reference (not memory bodies).
|
|
16
|
+
|
|
17
|
+
**Identity and workspace files are live.** `SOUL.md`, `IDENTITY.md`, `USER.md`
|
|
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
|
|
21
|
+
applies to the next turn without a sync. The `MEMORY.md` body stays out of the
|
|
22
|
+
prompt; a memory reference points to it.
|
|
23
|
+
|
|
24
|
+
**The OpenClaw skills catalog is live on both runtimes.** Each runtime receives the
|
|
25
|
+
session's catalog from OpenClaw's own session skills snapshot, exactly as OpenClaw
|
|
26
|
+
renders it; the plugin never compiles or freezes a copy. Codex gets it in the thread
|
|
27
|
+
developer instructions (see below); Claude gets it through OpenClaw's native
|
|
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.
|
|
30
|
+
|
|
31
|
+
**The fleet policy is live too.** On Codex the generated file (fleet policy and memory
|
|
32
|
+
reference) replaces Codex's native base through `model_instructions_file`.
|
|
33
|
+
The patched adapter also sends that same file as each thread's `baseInstructions` when
|
|
34
|
+
OpenClaw starts or resumes it. Codex reads base instructions per session, not from
|
|
35
|
+
history, and OpenClaw fingerprints these requests, so a refreshed revision resumes an
|
|
36
|
+
existing thread on its next turn with the new base: no duplicate copy, nothing in
|
|
37
|
+
history, and compaction cannot revert it. If the adapter is ever missing, Codex still
|
|
38
|
+
reads the policy from the file. The adapter replaces OpenClaw's generic developer
|
|
39
|
+
policy with the live OpenClaw skills catalog and the live persona, in the thread
|
|
40
|
+
developer instructions native children inherit, and suppresses the separate memory
|
|
41
|
+
contribution. Cron guidance remains in its existing parent-local carrier. The optional
|
|
42
|
+
managed model catalog removes native Default-mode prose.
|
|
19
43
|
|
|
20
44
|
There are no bundled system/developer templates or base-only mode. Downloaded
|
|
21
|
-
policy and
|
|
45
|
+
policy and the memory reference are written only to
|
|
22
46
|
`<agentDir>/codex-home/unblock-codex-prompt.md`, outside the plugin directory.
|
|
23
47
|
Codex reads that generated file; the plugin package does not retain its own copy
|
|
24
48
|
of the downloaded policy.
|
|
25
49
|
|
|
26
50
|
**Still live and untouched:** native AGENTS.md, native skills, tool schemas and
|
|
27
51
|
executor protocol, sandbox/approvals, native collaboration mechanics, routing
|
|
28
|
-
identifiers, date/timezone and user messages.
|
|
29
|
-
normalized; unknown `extraSystemPrompt` additions, including incognito context, survive.
|
|
30
|
-
|
|
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.
|
|
31
56
|
|
|
32
57
|
Customer documents stay on each agent's machine, outside this package. Snapshot
|
|
33
|
-
files use private permissions.
|
|
58
|
+
files use private permissions.
|
|
34
59
|
|
|
35
60
|
## Compatibility
|
|
36
61
|
|
|
37
|
-
-
|
|
38
|
-
2026.
|
|
39
|
-
|
|
62
|
+
- Codex: **OpenClaw and @openclaw/codex >=2026.10.5**. Every published release from
|
|
63
|
+
2026.10.5 through 2026.10.9 has the identical reviewed context-assembly functions.
|
|
64
|
+
Older layouts (2026.9.x and 2026.10.1–2026.10.4) are refused: 2026.9.x carries
|
|
65
|
+
persona in turn-scoped text native children never see. Nodes on those versions
|
|
66
|
+
stay on plugin 0.3.x until upgraded; restore still works for them. Once the Codex
|
|
67
|
+
update has replaced the 0.3.x-patched bundles (new names), a 0.4 sync starts fresh
|
|
68
|
+
without a restore. Bundle names
|
|
40
69
|
may change; fingerprints of the context-assembly functions must still match.
|
|
41
70
|
Changed assembly is refused pending review, rather than patched blindly.
|
|
42
71
|
- Local stdio Codex with an OpenClaw agent-scoped home. Operator-selected
|
|
@@ -44,29 +73,244 @@ files use private permissions. Missing identity documents are recorded as absent
|
|
|
44
73
|
The launcher must honor OpenClaw's `CODEX_HOME` and must not override the
|
|
45
74
|
managed `model_instructions_file`; status cannot attest to launcher behavior.
|
|
46
75
|
- One target agent per installation. Other agents use upstream behavior. Native
|
|
47
|
-
children
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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)).
|
|
82
|
+
|
|
83
|
+
This bridge uses one private upstream seam, the guarded Codex context carriers,
|
|
84
|
+
because public prompt hooks cannot fix the dropped-context path. It no longer depends
|
|
85
|
+
on OpenClaw's private skills-catalog builder. The adapter suppresses memory at its
|
|
86
|
+
producer and moves two host-rendered contributions out of the parent-only and
|
|
87
|
+
refreshable carriers into the thread developer instructions, after the fleet policy:
|
|
88
|
+
the session's OpenClaw skills catalog (with OpenClaw's `skills_search`/`skills_read`
|
|
89
|
+
hints, exactly as upstream renders it, and nothing when upstream renders nothing), then
|
|
90
|
+
the persona (SOUL, IDENTITY, shared USER and the selected personal USER). Those are
|
|
91
|
+
rebuilt every turn: a catalog change or persona edit changes them, and Codex re-syncs
|
|
92
|
+
the existing thread on its next turn with a policy handoff. They survive compaction
|
|
93
|
+
and are inherited by native children. Native AGENTS and operational context remain
|
|
94
|
+
live; cron guidance and execution permissions are unchanged. The adapter additionally
|
|
57
95
|
removes active-computer context, known Slack participation/style/activation policy,
|
|
58
96
|
duplicate progress-card prose and basic Markdown tutorials. It compacts source
|
|
59
97
|
delivery to current facts and scopes meaningful exec overrides to OpenClaw Gateway
|
|
60
98
|
exec; inherited steady-state defaults are omitted. Unrecognized additions are
|
|
61
|
-
preserved, not removed by heading.
|
|
62
|
-
|
|
99
|
+
preserved, not removed by heading. Changed operational functions require review
|
|
100
|
+
before sync.
|
|
63
101
|
The installer backs up and tracks every
|
|
64
102
|
patched bundle; old single-file receipts remain restorable. Runtime module paths
|
|
65
103
|
come from the loader's selected entry, never its temporary execution capture.
|
|
66
104
|
It validates private seams and is not a promise of compatibility with unseen layouts.
|
|
67
|
-
The catalog
|
|
68
|
-
|
|
69
|
-
|
|
105
|
+
The skills catalog is OpenClaw's own per-session snapshot, with its eligibility,
|
|
106
|
+
allowlist, visibility and size-limit logic; the plugin neither adds nor removes skills.
|
|
107
|
+
|
|
108
|
+
## Claude CLI agents
|
|
109
|
+
|
|
110
|
+
For agents whose models run through OpenClaw's `claude-cli` backend, the plugin
|
|
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
|
|
116
|
+
control/side-question operations keep upstream behavior.
|
|
117
|
+
|
|
118
|
+
**Each runtime gets its own fleet policy.** The plugin fetches the configured
|
|
119
|
+
`promptUrl` once per enrolled runtime. Codex fetches it exactly as configured, with no
|
|
120
|
+
`runtime` parameter (the Worker returns the Codex artifact). Claude fetches it with
|
|
121
|
+
`runtime=claude` added (via the URL API, so `channel` and other parameters are kept) and
|
|
122
|
+
requires the Worker to confirm it in `X-Prompt-Runtime`. The policy wording lives in
|
|
123
|
+
the Fleet Prompt sections, not in this package.
|
|
124
|
+
|
|
125
|
+
**Deploy order.** Deploy the fleet-prompt Worker with runtime support **before**
|
|
126
|
+
enrolling any Claude agent. A Worker without it answers `runtime=claude` with HTTP 400:
|
|
127
|
+
sync then writes nothing and tells you to deploy the Worker, and a daily refresh keeps
|
|
128
|
+
the installed policy and retries hourly. Codex-only nodes never send `runtime` and do
|
|
129
|
+
not depend on the Worker deploy.
|
|
130
|
+
|
|
131
|
+
### How it works
|
|
132
|
+
|
|
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. each of `AGENTS.md`, `SOUL.md`, `IDENTITY.md`, `USER.md` and `BOOTSTRAP.md` that
|
|
142
|
+
exists in the run's workspace and is not empty, under a `## <absolute path>` header.
|
|
143
|
+
That is OpenClaw's own workspace bootstrap set without `MEMORY.md`, whose body is
|
|
144
|
+
never included. As in OpenClaw, `BOOTSTRAP.md` goes only to primary user or manual
|
|
145
|
+
runs, never to subagent sessions, heartbeats or cron.
|
|
146
|
+
|
|
147
|
+
The files are read on every call from the run's workspace (the configured agent
|
|
148
|
+
workspace when the run names none), so an edit applies to the next turn. Each file is
|
|
149
|
+
cut to OpenClaw's per-file bootstrap cap: the agent's `bootstrapMaxChars`, else
|
|
150
|
+
`agents.defaults.bootstrapMaxChars`, else OpenClaw's default of 20000 characters, and at
|
|
151
|
+
most 4000 for `USER.md` as in OpenClaw. All files together are cut to OpenClaw's total
|
|
152
|
+
budget, `bootstrapTotalMaxChars` (default 60000). A cut file keeps its head, with no
|
|
153
|
+
marker (OpenClaw keeps head and tail and adds a marker).
|
|
154
|
+
Symlinks are followed only within the workspace; a file resolving outside it, a
|
|
155
|
+
non-regular file or one over 2 MiB is left out with a warning.
|
|
156
|
+
|
|
157
|
+
The policy and memory reference come from the sync receipt, verified on every call
|
|
158
|
+
(enrollment, prompt-file hash). Invalid or tampered enrolled state is logged as an
|
|
159
|
+
error, without prompt text, and that run keeps OpenClaw's own prompt. Other agents,
|
|
160
|
+
other providers, and paused or never-enrolled agents are left alone. When the hook
|
|
161
|
+
returns nothing, OpenClaw's prompt applies unchanged.
|
|
162
|
+
|
|
163
|
+
**Skills.** Claude gets the session skills through OpenClaw's native `openclaw-skills`
|
|
164
|
+
Claude plugin mount, which is not part of the system prompt and is kept.
|
|
165
|
+
|
|
166
|
+
**Identity on both runtimes.** Native Codex children inherit persona with the thread
|
|
167
|
+
developer instructions. Claude Code's native subagents do not receive the appended
|
|
168
|
+
system prompt at all (verified on Claude Code 2.1.316), so they see neither the fleet
|
|
169
|
+
policy nor persona. On Codex, editing a persona file or changing the skills catalog
|
|
170
|
+
during a live incognito conversation changes its thread instructions, which Codex
|
|
171
|
+
refuses for incognito threads: that thread's next turn fails. Start a new incognito
|
|
172
|
+
conversation after such a change.
|
|
173
|
+
|
|
174
|
+
### What Claude CLI no longer receives
|
|
175
|
+
|
|
176
|
+
Replacing the whole prompt drops everything OpenClaw puts in it for these runs, with no
|
|
177
|
+
exception for subagent sessions:
|
|
178
|
+
|
|
179
|
+
- `extraSystemPrompt` content: incognito restrictions, group-chat and channel prompts,
|
|
180
|
+
and subagent task framing;
|
|
181
|
+
- per-person `USER.md` overlays (the session's selected personal file); only the
|
|
182
|
+
workspace `USER.md` is carried;
|
|
183
|
+
- OpenClaw's generic sections: identity line, tooling list, tool-call style, execution
|
|
184
|
+
bias, Care, OpenClaw Control, delegation, docs, model aliases, UI presentation, side
|
|
185
|
+
chat and silent replies;
|
|
186
|
+
- its mechanics: output directives, messaging and delivery sections, channel hints,
|
|
187
|
+
authorized senders, exec-approval protocol, sandbox and elevated facts, TTS,
|
|
188
|
+
reactions, Control UI embeds, directory roles, the Runtime section, git co-author
|
|
189
|
+
guidance, bootstrap truncation notices, and the system-prompt skills list used when no
|
|
190
|
+
native skills plugin is mounted;
|
|
191
|
+
- the Claude backend's tool-name section, which OpenClaw adds before hooks run.
|
|
192
|
+
|
|
193
|
+
Still delivered: per-turn facts OpenClaw puts in the turn's user context (source
|
|
194
|
+
delivery, runtime context blocks, relocated runtime facts), the native skills mount,
|
|
195
|
+
`prependSystemContext`/`appendSystemContext` from other plugins' hooks, registered text
|
|
196
|
+
transforms and the model identity line. If several plugins return `systemPrompt`, the
|
|
197
|
+
highest-priority hook wins; this hook registers at priority 1000 so it runs first.
|
|
198
|
+
|
|
199
|
+
### Enroll
|
|
200
|
+
|
|
201
|
+
Sync derives runtimes from the agent's configured models using OpenClaw's public
|
|
202
|
+
`api.runtime.modelConfig.resolveModelRuntimePolicy`. Models resolve as OpenClaw resolves
|
|
203
|
+
them: the agent's own model replaces the default primary and, unless it lists its own,
|
|
204
|
+
the default fallbacks. The agent's own allowed-model map also counts, because the agent
|
|
205
|
+
can switch to those models at run time; the Gateway-wide `agents.defaults.models` map
|
|
206
|
+
does not.
|
|
207
|
+
Legacy `claude-cli/<model>` refs count as Claude CLI. This reads authored policy,
|
|
208
|
+
not availability; each turn's actual execution path stays authoritative. Sync adds
|
|
209
|
+
components and never removes one; use restore. Configuration changes never
|
|
210
|
+
enroll a runtime by themselves.
|
|
211
|
+
|
|
212
|
+
To drop a runtime, restore, change the agent's model configuration, then sync.
|
|
213
|
+
The receipts and backups restore keeps are rollback evidence, so a restored
|
|
214
|
+
runtime is not re-enrolled from them. If a restore was interrupted and the Codex
|
|
215
|
+
adapter's patched bytes are still installed while Codex is no longer configured, sync
|
|
216
|
+
refuses until `openclaw codex-prompt restore` completes. A leftover 0.4 Claude core
|
|
217
|
+
patch is instead removed by sync (see [Upgrading from 0.4](#upgrading-from-04-and-openclaw-updates)).
|
|
218
|
+
|
|
219
|
+
The Codex adapter and the 0.4 Claude core receipt share one rule. A receipt is cleared
|
|
220
|
+
once every recorded file is back at its original bytes (a completed restore), or once
|
|
221
|
+
nothing of the plugin's is left: every changed file is gone (an update renamed it, or
|
|
222
|
+
the install directory was deleted) or the recorded install version was replaced. A
|
|
223
|
+
Codex sync after that starts fresh, may target a different Codex package, and replaces
|
|
224
|
+
the old receipt's backups. Otherwise sync and restore keep refusing foreign edits and
|
|
225
|
+
foreign backups.
|
|
226
|
+
|
|
227
|
+
Codex `appServer` settings (agent-scoped local stdio only) are checked by sync when
|
|
228
|
+
it selects Codex and reported by status as `codexConfigError` for a Codex
|
|
229
|
+
enrollment. They never block Claude-only enrollment, status or restore.
|
|
230
|
+
|
|
231
|
+
Claude CLI enrollment needs the hook to be registrable. OpenClaw registers
|
|
232
|
+
`before_prompt_build` for a non-bundled plugin only with
|
|
233
|
+
`hooks.allowConversationAccess: true`, and blocks it when `hooks.allowPromptInjection`
|
|
234
|
+
is `false` (it defaults to allowed). Sync refuses Claude without both:
|
|
235
|
+
|
|
236
|
+
```json5
|
|
237
|
+
{
|
|
238
|
+
plugins: { entries: { "unblock-codex-prompt": {
|
|
239
|
+
enabled: true,
|
|
240
|
+
hooks: { allowConversationAccess: true },
|
|
241
|
+
config: { agentId: "main", frozenContext: true, promptUrl: "https://fleet-prompt.unblocklabs.ai/prompt?channel=dev" },
|
|
242
|
+
} } },
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
```sh
|
|
247
|
+
openclaw codex-prompt sync # add --codex-plugin-dir for a first Codex enrollment
|
|
248
|
+
openclaw codex-prompt status
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
A Claude-only agent needs no Codex package, TOML pointer, provider catalog
|
|
252
|
+
credentials or Codex skill-config writes. Snapshot files still live under
|
|
253
|
+
`<agentDir>/codex-home/`. Its sync never fetches the Codex artifact. Its generated
|
|
254
|
+
prompt file holds only the shared agent context
|
|
255
|
+
(the `## Memory reference` section), so the file's hash still anchors the
|
|
256
|
+
sync receipt; there is no Codex policy prefix to refresh. Adding Codex later (sync) regenerates
|
|
257
|
+
the file in the Codex layout.
|
|
258
|
+
|
|
259
|
+
**Where each policy is stored.** The Codex policy stays the prefix of the generated file
|
|
260
|
+
(`model_instructions_file`, also sent as `baseInstructions`). The Claude policy and the
|
|
261
|
+
shared agent context are stored in the sync receipt (`.unblock-codex-prompt-bundle.json`)
|
|
262
|
+
as `claudePolicy` (`text`, `url`, `revision`, `checkedAt`) and `agentContext`, and read
|
|
263
|
+
from the receipt only; the generated file is still verified against the receipt's
|
|
264
|
+
`promptSha256`. The receipt is the trust root for Claude: anyone who can write it can set
|
|
265
|
+
the policy, as with the file. An invalid or missing `claudePolicy` is reported by status
|
|
266
|
+
and leaves Claude runs on OpenClaw's prompt until `sync`.
|
|
267
|
+
|
|
268
|
+
**Activation.** The hook builds the prompt on every turn, so once the Gateway has
|
|
269
|
+
loaded this plugin version the target agent's next Claude turn uses it: no restart
|
|
270
|
+
after sync, refresh or a workspace edit. Installing or updating the plugin needs a
|
|
271
|
+
Gateway restart to load it; a grant change hot-reloads under OpenClaw's default hybrid
|
|
272
|
+
reload mode. A changed prompt changes the hash OpenClaw keys live Claude processes on,
|
|
273
|
+
so the conversation's next turn starts a new process that resumes the conversation; its
|
|
274
|
+
earlier history is not cleaned. Validate each policy revision in a fresh native
|
|
275
|
+
conversation. Status `claude.ready` means enrolled, a valid Claude policy, the hook
|
|
276
|
+
grant in place and no leftover 0.4 core patch.
|
|
277
|
+
|
|
278
|
+
Known limitations: OpenClaw runs prompt-build hooks only after it prepares them; if that
|
|
279
|
+
fails (for example, history its hook isolation cannot copy) or its turn-context
|
|
280
|
+
preparation fails, OpenClaw logs a warning and that run keeps OpenClaw's prompt. The
|
|
281
|
+
plugin cannot see those runs.
|
|
282
|
+
|
|
283
|
+
### Upgrading from 0.4 and OpenClaw updates
|
|
284
|
+
|
|
285
|
+
0.4 patched two OpenClaw core functions for Claude and kept a receipt
|
|
286
|
+
(`codex-home/.unblock-claude-prompt-adapter.json`) with exact-byte backups. On a node
|
|
287
|
+
with that patch still installed, status reports `legacyClaudeCore` with
|
|
288
|
+
`leftover: true` and Claude is not ready. `sync` validates the patched files and their
|
|
289
|
+
backups before writing anything, restores the original bytes, and reports
|
|
290
|
+
`legacyClaudeCoreRestored` with `restartRequired: true`: restart the Gateway to reload
|
|
291
|
+
the restored core. `restore` removes a leftover patch too. A same-version foreign edit
|
|
292
|
+
to a patched file is refused rather than overwritten; files an OpenClaw update already
|
|
293
|
+
replaced are left to the updater.
|
|
294
|
+
|
|
295
|
+
Updating OpenClaw needs no restore for Claude: there is nothing in core to remove. Run
|
|
296
|
+
`openclaw codex-prompt restore` first only while status still shows a leftover 0.4
|
|
297
|
+
patch, or for Codex as described below.
|
|
298
|
+
|
|
299
|
+
### Verify against an OpenClaw install
|
|
300
|
+
|
|
301
|
+
```sh
|
|
302
|
+
npm run build
|
|
303
|
+
node scripts/validate-claude-hook.mjs /path/to/node_modules/openclaw [...]
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
With no argument it checks the development dependency (also run by `npm test`). It
|
|
307
|
+
loads that OpenClaw's own plugin registrar, hook runner, `resolvePromptBuildHookResult`
|
|
308
|
+
and `prepareCliTurnPromptContext`, registers this plugin through them, and checks that
|
|
309
|
+
the hook's prompt replaces OpenClaw's, that turn context stays in the user prompt, and
|
|
310
|
+
that OpenClaw refuses the hook without the grant. It also asserts on the CLI runner's
|
|
311
|
+
source that the hook context carries the provider, agent and workspace, that the hook
|
|
312
|
+
result reaches the turn context, and that only finalization follows. It does not run a
|
|
313
|
+
Claude CLI process. It uses a temporary state directory and changes nothing installed.
|
|
70
314
|
|
|
71
315
|
## Install and enroll
|
|
72
316
|
|
|
@@ -74,7 +318,7 @@ Remote-node-only skills are not added; this is for dedicated local Mac agents.
|
|
|
74
318
|
npm ci
|
|
75
319
|
npm run preflight
|
|
76
320
|
npm pack
|
|
77
|
-
openclaw plugins install ./unblocklabs-unblock-codex-prompt-0.
|
|
321
|
+
openclaw plugins install ./unblocklabs-unblock-codex-prompt-0.5.0.tgz --force --accept-capabilities
|
|
78
322
|
```
|
|
79
323
|
|
|
80
324
|
Include the plugin in `plugins.allow` if applicable, then configure:
|
|
@@ -96,10 +340,12 @@ Include the plugin in `plugins.allow` if applicable, then configure:
|
|
|
96
340
|
```
|
|
97
341
|
|
|
98
342
|
`agentId` defaults to `main`. Both `promptUrl` and `frozenContext: true` are
|
|
99
|
-
required
|
|
100
|
-
|
|
343
|
+
required; the key keeps its historical name, though identity files are now live.
|
|
344
|
+
Legacy `agentName` values remain accepted but are unused; identity comes from the
|
|
345
|
+
live agent documents. Existing remote fleet configurations need no changes.
|
|
101
346
|
Configurations without a remote URL or with base-only mode are no longer supported.
|
|
102
|
-
|
|
347
|
+
Codex-only enrollment needs no hook grant; Claude CLI enrollment needs
|
|
348
|
+
`hooks.allowConversationAccess: true` with prompt injection not disabled (see [Claude CLI agents](#claude-cli-agents)). Initial enrollment enables daily shared-prompt refresh
|
|
103
349
|
and overdue startup catch-up. Startup never rebuilds local context or patches the
|
|
104
350
|
adapter. The optional model-catalog service can also refresh metadata.
|
|
105
351
|
|
|
@@ -110,10 +356,8 @@ plain-text content, a 256 KiB limit, UTF-8, and the endpoint's SHA-256
|
|
|
110
356
|
`X-Prompt-Revision` header, with a ten-second request timeout. These integrity
|
|
111
357
|
checks are not a signature; the configured HTTPS publisher controls the policy.
|
|
112
358
|
|
|
113
|
-
The remote text supplies the shared
|
|
114
|
-
policy
|
|
115
|
-
only within the normal hash/pointer-validated frozen
|
|
116
|
-
bundle. The frozen local context is still appended.
|
|
359
|
+
The remote text supplies the shared base and replaces OpenClaw's generic developer
|
|
360
|
+
policy; the generated file is hash-checked against its sync receipt at every assembly.
|
|
117
361
|
No local documents are sent to the Worker. The installed snapshot is the local
|
|
118
362
|
last-known-good generated file in the agent's managed home: a failed fetch aborts
|
|
119
363
|
sync before writes and does not disrupt normal turns. There is no bundled fallback. Status shows
|
|
@@ -130,8 +374,8 @@ openclaw codex-prompt status
|
|
|
130
374
|
|
|
131
375
|
`--adopt` explicitly takes ownership of an existing custom prompt pointer. Its
|
|
132
376
|
previous value is retained for restoration; leave the original file in place.
|
|
133
|
-
First
|
|
134
|
-
|
|
377
|
+
First sync compiles the memory reference and installs the guarded adapter patch with
|
|
378
|
+
a private original-source backup. Later syncs reuse its receipt.
|
|
135
379
|
|
|
136
380
|
## Refresh and activate
|
|
137
381
|
|
|
@@ -140,16 +384,30 @@ openclaw codex-prompt sync
|
|
|
140
384
|
openclaw codex-prompt status
|
|
141
385
|
```
|
|
142
386
|
|
|
143
|
-
Only explicit `sync` rebuilds
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
387
|
+
Only explicit `sync` rebuilds the memory reference and adapter policy.
|
|
388
|
+
Sync fetches every enrolled runtime's policy before writing anything; if any fetch
|
|
389
|
+
fails, nothing is written. The daily service fetches the configured Worker channel for
|
|
390
|
+
each enrolled runtime, then, in one locked write, replaces only the Codex policy prefix
|
|
391
|
+
of the generated file and/or `claudePolicy` in the receipt when their content changes;
|
|
392
|
+
everything after the Codex prefix is preserved byte-for-byte, and a Claude-only change
|
|
393
|
+
leaves the Codex file untouched (same bytes and inode). Identity and workspace files
|
|
394
|
+
and the skills catalog need neither: they are read live every turn. The catalog lists
|
|
395
|
+
each skill's name, description and location; skill bodies remain files the model reads
|
|
396
|
+
when triggered. Editing only a `SKILL.md` body therefore does not change the catalog
|
|
397
|
+
(or the Codex thread instructions); the next read of that file sees the edit.
|
|
398
|
+
|
|
399
|
+
A snapshot written by an earlier version still ends in its frozen skills catalog.
|
|
400
|
+
Refresh keeps that tail byte-for-byte until the next `sync` rewrites the file without
|
|
401
|
+
it. The earlier adapter suppressed the live catalog, so no thread sees both copies,
|
|
402
|
+
and no migration is needed: sync, then restart as below.
|
|
150
403
|
|
|
151
404
|
**After sync, drain work, restart the Gateway/managed app-server, and use new
|
|
152
|
-
conversations.**
|
|
405
|
+
conversations.** Sync can change the adapter itself, which a running app-server keeps
|
|
406
|
+
until restart. Policy refreshes, identity edits and catalog changes need neither.
|
|
407
|
+
Upgrading from a version with a frozen catalog: between this sync and the restart, the
|
|
408
|
+
running Gateway still holds the earlier patch, which suppresses the live catalog, while
|
|
409
|
+
the new file no longer carries the frozen one, so Codex turns in that window have no
|
|
410
|
+
skills catalog. Drain the agent before sync and restart right after it.
|
|
153
411
|
The plugin never interrupts or resets sessions. Capture an actual request after
|
|
154
412
|
provisioning or upgrades; `status` is disk evidence, not live adoption.
|
|
155
413
|
|
|
@@ -169,12 +427,11 @@ possible higher-priority Codex config override. An upgrade replacing the adapter
|
|
|
169
427
|
removes the guard; startup status is diagnostic, not a global inference gate.
|
|
170
428
|
Restore before upgrading, then revalidate compatibility before reenrollment.
|
|
171
429
|
|
|
172
|
-
If an upgrade already removed the old package generation,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
unless a new snapshot was requested. A source update still requires idle activation
|
|
430
|
+
If an upgrade already removed the old package generation, restore leaves the
|
|
431
|
+
replacement files alone and the old receipt is superseded: sync installs the reviewed
|
|
432
|
+
adapter against the current inspected official package without editing receipts.
|
|
433
|
+
Keep the snapshot and operator-selected launcher intact unless a new snapshot was
|
|
434
|
+
requested. A source update still requires idle activation
|
|
178
435
|
and fresh-session verification; disk status alone does not prove adoption.
|
|
179
436
|
|
|
180
437
|
### Daily shared-prompt refresh
|
|
@@ -185,14 +442,23 @@ Use `openclaw codex-prompt refresh` to run the same remote-prompt and enabled
|
|
|
185
442
|
model-catalog refresh immediately, without resnapshotting local context.
|
|
186
443
|
|
|
187
444
|
Both components are attempted independently: a catalog outage cannot prevent a
|
|
188
|
-
prompt update, or vice versa.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
445
|
+
prompt update, or vice versa. Within the shared prompt, every enrolled runtime is
|
|
446
|
+
fetched first: if any fetch fails or validation fails, neither runtime's policy is
|
|
447
|
+
updated; failures retry hourly. Unchanged prompt content is not rewritten. Status
|
|
448
|
+
reports each runtime's policy revision and last successful `checkedAt` timestamp:
|
|
449
|
+
`remotePrompt` for Codex and `claudePolicy` (`url`, `revision`, `checkedAt`) for Claude;
|
|
450
|
+
policy text is never printed. A changed
|
|
451
|
+
revision reaches existing conversations on their next turn: Codex resumes the thread
|
|
452
|
+
with the new base instructions (`nextCodexTurn`), and Claude starts the next CLI
|
|
453
|
+
process with the new prompt, resuming the conversation (`nextClaudeProcess`). Earlier
|
|
454
|
+
history is not rewritten. A live Codex incognito conversation cannot be resumed; it
|
|
455
|
+
keeps the revision it started with.
|
|
192
456
|
The plugin never restarts the Gateway automatically.
|
|
193
457
|
|
|
194
458
|
Existing remote snapshots migrate their shared/context boundary without rereading
|
|
195
|
-
agent files.
|
|
459
|
+
agent files. A node upgraded from 0.3.x keeps its frozen identity copy and old
|
|
460
|
+
adapter until its next `sync`, which installs live identity and policy delivery;
|
|
461
|
+
until then refreshes still reach only new conversations. Ambiguous or externally modified snapshots are refused rather than
|
|
196
462
|
guessed; inspect them and use explicit `sync` to rebuild when appropriate.
|
|
197
463
|
|
|
198
464
|
## Optional daily model-catalog refresh
|
|
@@ -269,11 +535,50 @@ openclaw codex-prompt restore
|
|
|
269
535
|
openclaw codex-prompt status
|
|
270
536
|
```
|
|
271
537
|
|
|
272
|
-
Restore recovers exact original adapter bytes
|
|
273
|
-
the previous TOML pointer. It
|
|
274
|
-
|
|
538
|
+
Restore recovers exact original adapter bytes (the Codex package, and any 0.4 Claude
|
|
539
|
+
patch left in OpenClaw core), deactivates enrollment and restores the previous TOML pointer. It plans each adapter
|
|
540
|
+
first, validating its files and the backups it will write; an adapter is restored only
|
|
541
|
+
while any recorded file still holds the plugin's bytes. Restore then validates the
|
|
542
|
+
pointer and pauses enrollment, and only then removes the Codex catalog and skills
|
|
543
|
+
block and restores the adapters, so a refusal changes nothing and no run sees a
|
|
544
|
+
half-restored bridge. Missing files, and files with other bytes after the recorded
|
|
545
|
+
version changed, are superseded and left to the updater; other changes are refused as
|
|
546
|
+
foreign edits. A receipt whose files are restored, superseded or otherwise no longer
|
|
547
|
+
hold the plugin's bytes never blocks a restore (its state is reported in the output
|
|
548
|
+
and in status). Restore retains backup, receipt and generated files as rollback
|
|
549
|
+
evidence; they do not keep a runtime enrolled. It does not require the current Codex
|
|
550
|
+
`appServer` settings to be supported. Restart and use fresh conversations to activate it
|
|
551
|
+
for Codex. Claude CLI turns use OpenClaw's prompt from the next turn, because the hook
|
|
552
|
+
reads the paused enrollment; a restart is needed only when a 0.4 core patch was removed.
|
|
275
553
|
Restore **before** disabling/uninstalling or changing target agents. Disabling
|
|
276
|
-
without restoring leaves the
|
|
554
|
+
without restoring leaves the managed base but re-enables OpenClaw's generic injections.
|
|
555
|
+
|
|
556
|
+
### Rolling back to 0.4
|
|
557
|
+
|
|
558
|
+
0.4 manages Claude CLI through its OpenClaw core patch, and its final-adoption gate
|
|
559
|
+
blocks enrolled Claude runs whose prompt lacks it. Restore with 0.5 first, install 0.4,
|
|
560
|
+
then run its `sync` and restart the Gateway. The Codex adapter and the state format are
|
|
561
|
+
unchanged between 0.4 and 0.5.
|
|
562
|
+
|
|
563
|
+
### Rolling back to 0.3.x
|
|
564
|
+
|
|
565
|
+
1. With 0.5 still installed, run `openclaw codex-prompt restore`. A restored enrollment
|
|
566
|
+
is saved in the state format 0.3 reads.
|
|
567
|
+
2. Restart the Gateway so the restored OpenClaw core and Codex package are loaded.
|
|
568
|
+
3. Install the 0.3.x plugin, then run its `sync` if you want it to manage the agent again.
|
|
569
|
+
|
|
570
|
+
0.3.x cannot manage Claude CLI agents. Any enrollment that includes Codex, with or
|
|
571
|
+
without Claude, and any restored enrollment are saved in the format 0.3.x reads. If the
|
|
572
|
+
plugin is rolled back without restoring first, the Codex patch finds the older runtime
|
|
573
|
+
and falls back instead of failing turns: 0.3.x keeps managing Codex, which reads the
|
|
574
|
+
policy from its base file, and Claude renders OpenClaw's normal prompt (0.3.x registers
|
|
575
|
+
no Claude hook). An active Claude-only enrollment is refused by 0.3.x; install 0.5 again
|
|
576
|
+
and restore. 0.3.x rewrites the state without the Claude runtime when it syncs or
|
|
577
|
+
restores. A 0.4 or 0.5 snapshot uses a heading 0.3.x's daily refresh does not recognize, so
|
|
578
|
+
after rolling back, run 0.3.x's `sync` once to rebuild it. That sync reinstalls 0.3.x's
|
|
579
|
+
Codex patch and its frozen skills catalog; drain and restart after it, as after any
|
|
580
|
+
sync. Until then the current Codex patch keeps relaying the live catalog (the relay is
|
|
581
|
+
inline in the patch, so it does not depend on the plugin runtime).
|
|
277
582
|
|
|
278
583
|
## Safety and scope
|
|
279
584
|
|
|
@@ -286,14 +591,15 @@ without restoring leaves the frozen base but re-enables live injections.
|
|
|
286
591
|
- Do not run concurrent sync/install/restore operations. If a crash left an empty
|
|
287
592
|
lock directory, confirm no sync is running before removing it.
|
|
288
593
|
- A prompt guides behavior; it is not a security boundary or obedience guarantee.
|
|
289
|
-
-
|
|
594
|
+
- The fleet policy replaces OpenClaw's generic policy (on Claude CLI, OpenClaw's whole
|
|
595
|
+
system prompt), so upstream base-policy improvements are not inherited. Review upgrades.
|
|
290
596
|
- Never commit customer snapshots, raw captures, credentials or host backups.
|
|
291
597
|
|
|
292
598
|
## Development and release
|
|
293
599
|
|
|
294
600
|
```sh
|
|
295
601
|
npm run preflight
|
|
296
|
-
npm run release:check -- v0.
|
|
602
|
+
npm run release:check -- v0.5.0
|
|
297
603
|
```
|
|
298
604
|
|
|
299
605
|
Tests cover compilation, explicit refresh, native/private-body exclusion,
|
|
@@ -303,7 +609,7 @@ proof and limits.
|
|
|
303
609
|
|
|
304
610
|
Install with
|
|
305
611
|
the packed archive above for an unreleased candidate. After publication, use
|
|
306
|
-
`openclaw plugins install npm:@unblocklabs/unblock-codex-prompt@0.
|
|
612
|
+
`openclaw plugins install npm:@unblocklabs/unblock-codex-prompt@0.5.0 --accept-capabilities`.
|
|
307
613
|
The existing [GitHub Release workflow](RELEASING.md) publishes npm only when a
|
|
308
614
|
GitHub Release is published. Normal pushes do not release the package.
|
|
309
615
|
|