@unblocklabs/unblock-codex-prompt 0.6.1 → 0.7.2

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/dist/runtime.d.ts CHANGED
@@ -6,12 +6,14 @@ export { normalizeOpenClawAdditions, normalizeOpenClawTurnContext } from "./cont
6
6
  */
7
7
  export declare function readFrozenPolicy(agentDir: string, config?: unknown): string | null;
8
8
  /**
9
- * The verified base file, sent as each managed thread's base instructions at start and resume.
10
- * Codex reads base instructions per session rather than from history, so a refreshed file
11
- * reaches an existing thread when OpenClaw resumes it; the file itself stays the fallback.
12
- * Lightweight runs take only the recorded policy prefix, without the agent-context tail.
9
+ * The verified base instructions for a managed Codex thread at start and resume.
10
+ * Picks the GPT-6.2 or standard Codex fleet policy from the active session's `modelId`
11
+ * (falling back to the agent's primary model in `config`, then the bundle's recorded primary).
12
+ * Codex reads base instructions per session rather than from history, so a refreshed policy
13
+ * or a model switch reaches an existing thread when OpenClaw resumes it; the base file stays
14
+ * the fallback. Lightweight runs take only the policy prefix, without the agent-context tail.
13
15
  */
14
- export declare function readCodexBaseInstructions(agentDir: string, config?: unknown, contextMode?: "full" | "lightweight"): string | null;
16
+ export declare function readCodexBaseInstructions(agentDir: string, config?: unknown, contextMode?: "full" | "lightweight", modelId?: unknown): string | null;
15
17
  export type ClaudeManagedContext = {
16
18
  policy: string;
17
19
  agentContext: string;
package/dist/runtime.js CHANGED
@@ -2,8 +2,10 @@ import { lstatSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { createHash } from "node:crypto";
4
4
  import { readPromptPointer } from "./toml.js";
5
- import { isCodexPolicyBoundary, parseClaudePolicy, parseEnrollment } from "./manager.js";
5
+ import { isCodexPolicyBoundary, parseClaudePolicy, parseEnrollment, parseStoredPolicy } from "./manager.js";
6
6
  import { assertDedicatedCodexHome, configuredCodexHome } from "./codex-home.js";
7
+ import { managedTargetAgent } from "./managed-target.js";
8
+ import { classifyCodexModel, configuredCodexModelFamily } from "./model-family.js";
7
9
  export { normalizeOpenClawAdditions, normalizeOpenClawTurnContext } from "./context.js";
8
10
  function readPrivate(path) {
9
11
  const stat = lstatSync(path);
@@ -79,16 +81,40 @@ export function readFrozenPolicy(agentDir, config) {
79
81
  return readCodexSnapshot(agentDir, config)?.policy ?? null;
80
82
  }
81
83
  /**
82
- * The verified base file, sent as each managed thread's base instructions at start and resume.
83
- * Codex reads base instructions per session rather than from history, so a refreshed file
84
- * reaches an existing thread when OpenClaw resumes it; the file itself stays the fallback.
85
- * Lightweight runs take only the recorded policy prefix, without the agent-context tail.
84
+ * The verified base instructions for a managed Codex thread at start and resume.
85
+ * Picks the GPT-6.2 or standard Codex fleet policy from the active session's `modelId`
86
+ * (falling back to the agent's primary model in `config`, then the bundle's recorded primary).
87
+ * Codex reads base instructions per session rather than from history, so a refreshed policy
88
+ * or a model switch reaches an existing thread when OpenClaw resumes it; the base file stays
89
+ * the fallback. Lightweight runs take only the policy prefix, without the agent-context tail.
86
90
  */
87
- export function readCodexBaseInstructions(agentDir, config, contextMode) {
91
+ export function readCodexBaseInstructions(agentDir, config, contextMode, modelId) {
88
92
  const snapshot = readCodexSnapshot(agentDir, config);
89
93
  if (!snapshot)
90
94
  return null;
91
95
  const { bundle, prompt } = snapshot;
96
+ const family = typeof modelId === "string" && modelId.trim()
97
+ ? classifyCodexModel(modelId)
98
+ : config !== undefined
99
+ ? configuredCodexModelFamily(config, managedTargetAgent(config) ?? "main")
100
+ : "codexPrimaryFamily" in bundle && bundle.codexPrimaryFamily === "gpt-6.2"
101
+ ? "gpt-6.2"
102
+ : "default";
103
+ const hasSplitCodex = ("codexGpt62Policy" in bundle && bundle.codexGpt62Policy !== undefined) ||
104
+ ("codexDefaultPolicy" in bundle && bundle.codexDefaultPolicy !== undefined);
105
+ if (hasSplitCodex) {
106
+ const selected = family === "gpt-6.2"
107
+ ? parseStoredPolicy("codexGpt62Policy" in bundle ? bundle.codexGpt62Policy : undefined, "Codex GPT-6.2 policy")
108
+ : parseStoredPolicy("codexDefaultPolicy" in bundle ? bundle.codexDefaultPolicy : undefined, "Codex default policy");
109
+ const policyText = selected.text.trim();
110
+ if (contextMode === "lightweight")
111
+ return policyText;
112
+ const boundary = "basePromptLength" in bundle ? bundle.basePromptLength : undefined;
113
+ if (!isCodexPolicyBoundary(prompt, boundary)) {
114
+ throw new Error("Frozen context boundary is ambiguous; run codex-prompt sync");
115
+ }
116
+ return `${policyText}${prompt.slice(boundary)}`;
117
+ }
92
118
  if (contextMode !== "lightweight")
93
119
  return prompt;
94
120
  const boundary = "basePromptLength" in bundle ? bundle.basePromptLength : undefined;
@@ -1,28 +1,83 @@
1
1
  {
2
2
  "id": "unblock-codex-prompt",
3
3
  "name": "Unblock Codex Prompt",
4
- "version": "0.6.1",
4
+ "version": "0.7.2",
5
5
  "description": "Maintain an agent-scoped fleet prompt for Codex (model_instructions_file) and Claude CLI (before_prompt_build hook).",
6
- "activation": { "onStartup": true },
6
+ "activation": {
7
+ "onStartup": true
8
+ },
7
9
  "configSchema": {
8
10
  "type": "object",
9
11
  "additionalProperties": false,
10
- "required": ["promptUrl", "frozenContext"],
12
+ "required": [
13
+ "promptUrl",
14
+ "frozenContext"
15
+ ],
11
16
  "properties": {
12
- "agentId": { "type": "string", "pattern": "^[a-z0-9][a-z0-9_-]*$", "default": "main" },
13
- "agentName": { "type": "string", "minLength": 1, "maxLength": 100, "deprecated": true },
14
- "frozenContext": { "type": "boolean", "const": true },
15
- "promptUrl": { "type": "string", "format": "uri", "pattern": "^https://" },
16
- "suppressExplicitDelegationPrompt": { "type": "boolean", "default": false },
17
- "disabledCodexSkills": { "type": "array", "default": ["documents:documents", "pages", "work-pets"], "maxItems": 64, "uniqueItems": true, "items": { "type": "string", "pattern": "^[\\w.@:-]{1,128}$" } }
17
+ "agentId": {
18
+ "type": "string",
19
+ "pattern": "^[a-z0-9][a-z0-9_-]*$",
20
+ "default": "main"
21
+ },
22
+ "agentName": {
23
+ "type": "string",
24
+ "minLength": 1,
25
+ "maxLength": 100,
26
+ "deprecated": true
27
+ },
28
+ "frozenContext": {
29
+ "type": "boolean",
30
+ "const": true
31
+ },
32
+ "promptUrl": {
33
+ "type": "string",
34
+ "format": "uri",
35
+ "pattern": "^https://"
36
+ },
37
+ "suppressExplicitDelegationPrompt": {
38
+ "type": "boolean",
39
+ "default": false
40
+ },
41
+ "disabledCodexSkills": {
42
+ "type": "array",
43
+ "default": [
44
+ "documents:documents",
45
+ "pages",
46
+ "work-pets"
47
+ ],
48
+ "maxItems": 64,
49
+ "uniqueItems": true,
50
+ "items": {
51
+ "type": "string",
52
+ "pattern": "^[\\w.@:-]{1,128}$"
53
+ }
54
+ }
18
55
  }
19
56
  },
20
57
  "uiHints": {
21
- "agentId": { "label": "OpenClaw agent ID", "help": "Only this agent's prompt is managed (on Claude CLI, its claude-cli runs, subagent sessions included). Defaults to main." },
22
- "agentName": { "label": "Legacy agent name (unused)", "help": "Accepted for existing configs only. Identity comes from agent documents; shared prompt text comes only from promptUrl." },
23
- "frozenContext": { "label": "Managed prompt bridge", "help": "Required: true. Codex: replaces base instructions and OpenClaw generic policy on reviewed OpenClaw/Codex >=2026.10.5 layouts. Claude CLI: replaces OpenClaw's entire system prompt through the public before_prompt_build hook (policy, memory reference, local media context and the workspace AGENTS, SOUL, IDENTITY, USER and BOOTSTRAP files, read every turn); no OpenClaw core patch. Needs hooks.allowConversationAccess: true and allowPromptInjection not false. Runtimes come from the agent's configured model policy at explicit sync. SOUL, IDENTITY, USER and AGENTS stay live." },
24
- "promptUrl": { "label": "Fleet prompt endpoint", "help": "Required public HTTPS plain-text endpoint with X-Prompt-Revision SHA-256. The only shared-policy source. After initial sync, refreshed daily and when overdue on startup without refreshing agent context. No bundled prompt fallback." },
25
- "suppressExplicitDelegationPrompt": { "label": "Compact managed Codex instructions", "help": "Manage a model_catalog_json override: suppress explicit-only delegation and Default-mode prose, trim role introductions and compact full-access/never-approval text. Runtime mechanics and permissions are unchanged. Refreshed daily from the configured provider. Requires frozenContext and an available provider env_key. Generated-file edits are replaced on refresh." },
26
- "disabledCodexSkills": { "label": "Codex skills to remove", "help": "Plugin names (all of their skills) or exact skill names to disable in Codex's native skills list. Defaults to documents:documents, pages, and work-pets. An explicit list replaces the defaults; set [] to remove all managed rules. Applied at startup, sync and refresh." }
58
+ "agentId": {
59
+ "label": "OpenClaw agent ID",
60
+ "help": "Only this agent's prompt is managed (on Claude CLI, its claude-cli runs, subagent sessions included). Defaults to main."
61
+ },
62
+ "agentName": {
63
+ "label": "Legacy agent name (unused)",
64
+ "help": "Accepted for existing configs only. Identity comes from agent documents; shared prompt text comes only from promptUrl."
65
+ },
66
+ "frozenContext": {
67
+ "label": "Managed prompt bridge",
68
+ "help": "Required: true. Codex: replaces base instructions and OpenClaw generic policy on reviewed OpenClaw/Codex >=2026.10.5 layouts. Claude CLI: replaces OpenClaw's entire system prompt through the public before_prompt_build hook (policy, memory reference, local media context and the workspace AGENTS, SOUL, IDENTITY, USER and BOOTSTRAP files, read every turn); no OpenClaw core patch. Needs hooks.allowConversationAccess: true and allowPromptInjection not false. Runtimes come from the agent's configured model policy at explicit sync. SOUL, IDENTITY, USER and AGENTS stay live."
69
+ },
70
+ "promptUrl": {
71
+ "label": "Fleet prompt endpoint",
72
+ "help": "Required public HTTPS plain-text endpoint with X-Prompt-Revision SHA-256. The only shared-policy source. After initial sync, refreshed daily and when overdue on startup without refreshing agent context. No bundled prompt fallback."
73
+ },
74
+ "suppressExplicitDelegationPrompt": {
75
+ "label": "Compact managed Codex instructions",
76
+ "help": "Manage a model_catalog_json override: suppress explicit-only delegation and Default-mode prose, trim role introductions and compact full-access/never-approval text. Runtime mechanics and permissions are unchanged. Refreshed daily from the configured provider. Requires frozenContext and an available provider env_key. Generated-file edits are replaced on refresh."
77
+ },
78
+ "disabledCodexSkills": {
79
+ "label": "Codex skills to remove",
80
+ "help": "Plugin names (all of their skills) or exact skill names to disable in Codex's native skills list. Defaults to documents:documents, pages, and work-pets. An explicit list replaces the defaults; set [] to remove all managed rules. Applied at startup, sync and refresh."
81
+ }
27
82
  }
28
83
  }
package/package.json CHANGED
@@ -1,12 +1,23 @@
1
1
  {
2
2
  "name": "@unblocklabs/unblock-codex-prompt",
3
- "version": "0.6.1",
3
+ "version": "0.7.2",
4
4
  "description": "Manage a shared fleet prompt for an OpenClaw agent on Codex and Claude CLI.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
- "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
9
- "files": ["dist/", "openclaw.plugin.json", "README.md", "RELEASING.md", "LICENSE"],
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist/",
16
+ "openclaw.plugin.json",
17
+ "README.md",
18
+ "RELEASING.md",
19
+ "LICENSE"
20
+ ],
10
21
  "scripts": {
11
22
  "build": "tsc -p tsconfig.json && node scripts/build-codex-bridge.mjs",
12
23
  "check": "tsc -p tsconfig.json --noEmit",
@@ -17,7 +28,10 @@
17
28
  "release:check": "node scripts/check-release-version.mjs",
18
29
  "prepack": "npm run build"
19
30
  },
20
- "dependencies": { "acorn": "^8.18.0", "toml-eslint-parser": "^1.0.3" },
31
+ "dependencies": {
32
+ "acorn": "^8.18.0",
33
+ "toml-eslint-parser": "^1.0.3"
34
+ },
21
35
  "devDependencies": {
22
36
  "@openclaw/plugin-inspector": "^0.3.25",
23
37
  "@types/node": "^22.0.0",
@@ -25,21 +39,57 @@
25
39
  "openclaw": "2026.10.9",
26
40
  "typescript": "^5.9.3"
27
41
  },
28
- "peerDependencies": { "openclaw": ">=2026.10.5" },
29
- "peerDependenciesMeta": { "openclaw": { "optional": true } },
42
+ "peerDependencies": {
43
+ "openclaw": ">=2026.10.5"
44
+ },
45
+ "peerDependenciesMeta": {
46
+ "openclaw": {
47
+ "optional": true
48
+ }
49
+ },
30
50
  "openclaw": {
31
- "extensions": ["./dist/index.js"],
32
- "install": { "npmSpec": "@unblocklabs/unblock-codex-prompt", "defaultChoice": "npm", "minHostVersion": ">=2026.10.5" },
33
- "release": { "publishToClawHub": false, "publishToNpm": true },
34
- "compat": { "pluginApi": ">=2026.10.5", "minGatewayVersion": ">=2026.10.5" },
35
- "build": { "openclawVersion": "2026.10.9", "pluginSdkVersion": "2026.10.9" }
36
- },
37
- "engines": { "node": ">=22.22.3" },
38
- "publishConfig": { "access": "public" },
51
+ "extensions": [
52
+ "./dist/index.js"
53
+ ],
54
+ "install": {
55
+ "npmSpec": "@unblocklabs/unblock-codex-prompt",
56
+ "defaultChoice": "npm",
57
+ "minHostVersion": ">=2026.10.5"
58
+ },
59
+ "release": {
60
+ "publishToClawHub": false,
61
+ "publishToNpm": true
62
+ },
63
+ "compat": {
64
+ "pluginApi": ">=2026.10.5",
65
+ "minGatewayVersion": ">=2026.10.5"
66
+ },
67
+ "build": {
68
+ "openclawVersion": "2026.10.9",
69
+ "pluginSdkVersion": "2026.10.9"
70
+ }
71
+ },
72
+ "engines": {
73
+ "node": ">=22.22.3"
74
+ },
75
+ "publishConfig": {
76
+ "access": "public"
77
+ },
39
78
  "license": "MIT",
40
79
  "author": "Unblock Labs",
41
- "keywords": ["openclaw", "openclaw-plugin", "codex", "claude-cli", "prompt"],
42
- "repository": { "type": "git", "url": "git+https://github.com/unblocklabs-ai/unblock-codex-prompt.git" },
43
- "bugs": { "url": "https://github.com/unblocklabs-ai/unblock-codex-prompt/issues" },
80
+ "keywords": [
81
+ "openclaw",
82
+ "openclaw-plugin",
83
+ "codex",
84
+ "claude-cli",
85
+ "prompt"
86
+ ],
87
+ "repository": {
88
+ "type": "git",
89
+ "url": "git+https://github.com/unblocklabs-ai/unblock-codex-prompt.git"
90
+ },
91
+ "bugs": {
92
+ "url": "https://github.com/unblocklabs-ai/unblock-codex-prompt/issues"
93
+ },
44
94
  "homepage": "https://github.com/unblocklabs-ai/unblock-codex-prompt#readme"
45
95
  }