@unblocklabs/unblock-codex-prompt 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -17
- package/dist/adapter.js +4 -3
- package/dist/codex-bridge-source.js +1 -1
- package/dist/compiler.d.ts +121 -4
- package/dist/compiler.js +29 -9
- package/dist/config.js +2 -2
- package/dist/index.js +42 -9
- package/dist/manager.d.ts +17 -5
- package/dist/manager.js +47 -10
- package/dist/model-family.d.ts +9 -0
- package/dist/model-family.js +41 -0
- package/dist/refresh-error.js +2 -0
- package/dist/remote.d.ts +14 -5
- package/dist/remote.js +10 -5
- package/dist/runtime.d.ts +7 -5
- package/dist/runtime.js +32 -6
- package/openclaw.plugin.json +3 -3
- package/package.json +1 -1
package/dist/remote.js
CHANGED
|
@@ -4,9 +4,10 @@ const MAX_BYTES = 256 * 1024;
|
|
|
4
4
|
export const WORKER_RUNTIME_HINT = "deploy the fleet-prompt Worker with runtime support first";
|
|
5
5
|
/**
|
|
6
6
|
* Explicit sync and daily shared-prompt refresh validate before changing local state.
|
|
7
|
-
* Without `runtime` the configured URL is fetched exactly as written (the Codex artifact,
|
|
8
|
-
* every Worker version serves). `runtime
|
|
9
|
-
* `channel` and any other parameters, and requires the Worker
|
|
7
|
+
* Without `runtime` the configured URL is fetched exactly as written (the standard Codex artifact,
|
|
8
|
+
* which every Worker version serves). Passing `runtime` (`claude` or `codex-gpt-6.2`) adds the
|
|
9
|
+
* parameter with the URL API, keeping `channel` and any other parameters, and requires the Worker
|
|
10
|
+
* to confirm it in X-Prompt-Runtime.
|
|
10
11
|
*/
|
|
11
12
|
export async function fetchPrompt(url, request = fetch, options = {}) {
|
|
12
13
|
const target = validatePromptUrl(url);
|
|
@@ -55,7 +56,11 @@ export async function fetchPrompt(url, request = fetch, options = {}) {
|
|
|
55
56
|
throw new Error("Prompt revision does not match response body");
|
|
56
57
|
return { prompt, source: { url: options.runtime ? target.href : url, revision } };
|
|
57
58
|
}
|
|
58
|
-
/** Per-runtime fetchers for one configured promptUrl; Codex never sends `runtime`. */
|
|
59
|
+
/** Per-runtime fetchers for one configured promptUrl; standard Codex never sends `runtime`. */
|
|
59
60
|
export function policyFetchers(url, request) {
|
|
60
|
-
return {
|
|
61
|
+
return {
|
|
62
|
+
codex: () => fetchPrompt(url, request),
|
|
63
|
+
codexGpt62: () => fetchPrompt(url, request, { runtime: "codex-gpt-6.2" }),
|
|
64
|
+
claude: () => fetchPrompt(url, request, { runtime: "claude" }),
|
|
65
|
+
};
|
|
61
66
|
}
|
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
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
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;
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "unblock-codex-prompt",
|
|
3
3
|
"name": "Unblock Codex Prompt",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.1",
|
|
5
5
|
"description": "Maintain an agent-scoped fleet prompt for Codex (model_instructions_file) and Claude CLI (before_prompt_build hook).",
|
|
6
6
|
"activation": { "onStartup": true },
|
|
7
7
|
"configSchema": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"frozenContext": { "type": "boolean", "const": true },
|
|
15
15
|
"promptUrl": { "type": "string", "format": "uri", "pattern": "^https://" },
|
|
16
16
|
"suppressExplicitDelegationPrompt": { "type": "boolean", "default": false },
|
|
17
|
-
"disabledCodexSkills": { "type": "array", "default": ["pages", "work-pets"], "maxItems": 64, "uniqueItems": true, "items": { "type": "string", "pattern": "^[\\w.@:-]{1,128}$" } }
|
|
17
|
+
"disabledCodexSkills": { "type": "array", "default": ["documents:documents", "pages", "work-pets"], "maxItems": 64, "uniqueItems": true, "items": { "type": "string", "pattern": "^[\\w.@:-]{1,128}$" } }
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"uiHints": {
|
|
@@ -23,6 +23,6 @@
|
|
|
23
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
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
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
|
|
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." }
|
|
27
27
|
}
|
|
28
28
|
}
|