@openclaw/codex 2026.8.1-beta.2 → 2026.8.1-beta.3

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.
Files changed (59) hide show
  1. package/dist/api.js +147 -0
  2. package/dist/app-server-policy-bg5QPSVP.js +25 -0
  3. package/dist/{attempt-client-cleanup-DMLXUfa8.js → attempt-client-cleanup-URjUlCHg.js} +1 -1
  4. package/dist/{binding-connection-I5Bo-AsX.js → binding-connection-DAvZwp96.js} +15 -3
  5. package/dist/{bounded-turn-qgZmzy_4.js → bounded-turn-4BjrZEwW.js} +22 -16
  6. package/dist/{capabilities-CybGI1oz.js → capabilities-CH3K57v4.js} +1 -1
  7. package/dist/cli-metadata.js +1 -1
  8. package/dist/{command-formatters-B1AEz8ZA.js → command-formatters-D0nZ3qtd.js} +2 -2
  9. package/dist/{command-handlers-Db8pu_ds.js → command-handlers-DC86lgT4.js} +39 -22
  10. package/dist/command-rpc-xUIIonsO.js +90 -0
  11. package/dist/{compact-LspQaGfl.js → compact-COqgBRny.js} +35 -29
  12. package/dist/{session-binding-DPxIvMgE.js → config-CpNeo5AE.js} +28 -888
  13. package/dist/context-compaction-activity-BOeJf7yo.js +58 -0
  14. package/dist/doctor-contract-api.js +15 -14
  15. package/dist/{dynamic-tools-BVdyWkUD.js → dynamic-tools-fJZhl4CE.js} +1284 -651
  16. package/dist/{effective-mcp-catalog-DIIhAtOZ.js → effective-mcp-catalog-4YKn51aG.js} +2 -2
  17. package/dist/elicitation-input-DMkeki8d.js +71 -0
  18. package/dist/{event-projector-usage-e5huIQWu.js → event-projector-usage-CLwNEJqW.js} +16 -16
  19. package/dist/harness-DoKQcF8n.js +258 -0
  20. package/dist/harness.js +2 -226
  21. package/dist/index.js +171 -48
  22. package/dist/{isolated-completion-C58NbL40.js → isolated-completion-DPMtlH9r.js} +3 -3
  23. package/dist/managed-binary-By4FZC6i.js +212 -0
  24. package/dist/media-understanding-provider.js +2 -2
  25. package/dist/model-catalog-CmGoqVKB.js +48 -0
  26. package/dist/{models-BFlpn1Ex.js → models-CZw1wClT.js} +2 -2
  27. package/dist/{native-subagent-monitor-DyTGmTUx.js → native-subagent-monitor-GGq3RnOo.js} +185 -71
  28. package/dist/node-exec-server.runtime-Bsu1LdFZ.js +192 -0
  29. package/dist/{plugin-app-cache-key-C3H2CVp6.js → plugin-app-cache-key-DMNQ8Zi8.js} +15 -3
  30. package/dist/plugin-approval-roundtrip-C75Yiiwc.js +95 -0
  31. package/dist/{plugin-marketplace-discovery-CzrGJdCR.js → plugin-marketplace-discovery-CSWDkMrP.js} +40 -26
  32. package/dist/{plugin-metadata-cache-CNJPj4_b.js → plugin-metadata-cache-BXH5NF-4.js} +8 -5
  33. package/dist/{protocol-validators-B4F7L8Rf.js → protocol-validators-VAVyEnDp.js} +55 -2
  34. package/dist/{rate-limits-DZXmOL8-.js → rate-limits-BI1dMHDG.js} +1 -1
  35. package/dist/{request-BRl5_UfX.js → request-DSK0W6YI.js} +2 -2
  36. package/dist/{run-attempt-P8BdxC1I.js → run-attempt-BV3HzuCf.js} +1098 -666
  37. package/dist/{runtime-artifact-BVSPdd6g.js → runtime-artifact-BvyT1uyd.js} +4 -7
  38. package/dist/{sandbox-guard-Cmwc9eIk.js → sandbox-guard-C1qEeZ5C.js} +25 -19
  39. package/dist/session-binding-BTrLf9Qm.js +874 -0
  40. package/dist/{session-catalog-xwNi_SDM.js → session-catalog-ezP_UcRM.js} +1541 -1296
  41. package/dist/session-catalog-home-id-BNwAJ9D7.js +18 -0
  42. package/dist/{session-cli-7hgXZDV7.js → session-cli-B1hKvfkI.js} +20 -7
  43. package/dist/{session-retirement-DoMMJFKm.js → session-retirement-CE4iMiLh.js} +3 -3
  44. package/dist/{session-upstream-marker-CrIFX06J.js → session-upstream-marker-D_2npHlA.js} +1 -1
  45. package/dist/{settled-turn-finalizer-BRWBO4MO.js → settled-turn-finalizer-Dx1onIqg.js} +23 -19
  46. package/dist/{shared-client-kIBbGjk4.js → shared-client-Dw-rzii0.js} +755 -273
  47. package/dist/{side-question-9HAL26l9.js → side-question-DbXkJZzg.js} +52 -30
  48. package/dist/{thread-lifecycle-Bu1BTDXr.js → thread-lifecycle-DKdrnTMX.js} +310 -92
  49. package/dist/{thread-ownership-6kOQHlyC.js → thread-ownership-i2NBwDUL.js} +2 -2
  50. package/dist/{thread-resume-CPrJNQVM.js → thread-resume-CdJk2Ehf.js} +3 -3
  51. package/dist/{transcript-mirror-B9gGgnJS.js → transcript-mirror-BU0_LKAL.js} +46 -28
  52. package/dist/{transport-stdio-DIImwDVS.js → transport-stdio-DhoGy33Z.js} +2 -2
  53. package/dist/{upstream-prompt-provenance-ClRBije0.js → upstream-prompt-provenance-CFmsKwr9.js} +12 -14
  54. package/dist/{upstream-session-fork-CE-_LdnP.js → upstream-session-fork-BDVJCLAD.js} +12 -6
  55. package/dist/{usage-CHlV0e-o.js → usage-9dKJCgcy.js} +3 -3
  56. package/dist/{web-search-provider.runtime-DRw2Vl42.js → web-search-provider.runtime-DCdx4DGu.js} +3 -3
  57. package/openclaw.plugin.json +31 -1
  58. package/package.json +6 -5
  59. package/dist/app-server-policy-zcBDc1JU.js +0 -49
@@ -1,5 +1,5 @@
1
- import { d as sessionBindingIdentity } from "./session-binding-DPxIvMgE.js";
2
- import { d as retainSharedCodexAppServerClientByInstanceId } from "./shared-client-kIBbGjk4.js";
1
+ import { d as retainSharedCodexAppServerClientByInstanceId } from "./shared-client-Dw-rzii0.js";
2
+ import { d as sessionBindingIdentity } from "./session-binding-BTrLf9Qm.js";
3
3
  import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  import { assignMcpCatalogSafeServerNames } from "openclaw/plugin-sdk/agent-harness-runtime";
5
5
  //#region extensions/codex/src/app-server/effective-mcp-catalog.ts
@@ -0,0 +1,71 @@
1
+ import { agentHarnessStructuredInput } from "openclaw/plugin-sdk/agent-harness-runtime";
2
+ //#region extensions/codex/src/app-server/elicitation-input.ts
3
+ /** Snapshots and compiles ordinary Codex input before it enters the per-turn queue. */
4
+ function compileCodexOrdinaryElicitation(params) {
5
+ if (readRawOwnString(params.value, "threadId") !== params.threadId) return { kind: "ignored" };
6
+ const snapshot = agentHarnessStructuredInput.snapshot(params.value);
7
+ if (!agentHarnessStructuredInput.isRecord(snapshot)) return {
8
+ kind: "compiled",
9
+ input: {
10
+ kind: "unsupported",
11
+ message: "OpenClaw declined a malformed or over-limit MCP elicitation request."
12
+ }
13
+ };
14
+ const requestTurnId = readValue(snapshot, "turnId");
15
+ if (typeof requestTurnId === "string" && requestTurnId !== params.turnId) return { kind: "ignored" };
16
+ if (requestTurnId !== null && typeof requestTurnId !== "string") return {
17
+ kind: "compiled",
18
+ input: {
19
+ kind: "unsupported",
20
+ message: "OpenClaw declined an MCP elicitation with invalid turn correlation."
21
+ }
22
+ };
23
+ const mode = readCodexElicitationString(snapshot, "mode");
24
+ if (mode === "url") return {
25
+ kind: "compiled",
26
+ input: agentHarnessStructuredInput.compileUrl({
27
+ url: readValue(snapshot, "url"),
28
+ elicitationId: readValue(snapshot, "elicitationId"),
29
+ message: readValue(snapshot, "message"),
30
+ fallbackMessage: "Codex provided a URL",
31
+ protocolName: "MCP"
32
+ })
33
+ };
34
+ if (mode !== "form" && mode !== "openai/form") return {
35
+ kind: "compiled",
36
+ input: {
37
+ kind: "unsupported",
38
+ message: `OpenClaw does not support MCP elicitation mode ${JSON.stringify(mode ?? "unknown")}.`
39
+ }
40
+ };
41
+ return {
42
+ kind: "compiled",
43
+ input: agentHarnessStructuredInput.compileForm({
44
+ schema: readValue(snapshot, "requestedSchema"),
45
+ message: readCodexElicitationString(snapshot, "message"),
46
+ fallbackMessage: "Codex needs input",
47
+ options: {
48
+ protocolName: mode === "openai/form" ? "OpenAI" : "MCP",
49
+ allowEmptyForm: true,
50
+ minimumChoiceCount: 1,
51
+ allowEnumNames: true,
52
+ allowImagePicker: mode === "openai/form",
53
+ metadata: { secretPath: ["isSecret"] }
54
+ }
55
+ })
56
+ };
57
+ }
58
+ function readValue(record, key) {
59
+ return Object.hasOwn(record, key) ? record[key] : void 0;
60
+ }
61
+ function readCodexElicitationString(record, key) {
62
+ const value = readValue(record, key);
63
+ return typeof value === "string" ? value : void 0;
64
+ }
65
+ function readRawOwnString(value, key) {
66
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
67
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
68
+ return descriptor && "value" in descriptor && typeof descriptor.value === "string" ? descriptor.value : void 0;
69
+ }
70
+ //#endregion
71
+ export { compileCodexOrdinaryElicitation };
@@ -1,5 +1,5 @@
1
- import { ct as isJsonObject } from "./shared-client-kIBbGjk4.js";
2
- import { asFiniteNumber, asSafeIntegerInRange, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { ut as isJsonObject } from "./shared-client-Dw-rzii0.js";
2
+ import { asSafeIntegerInRange, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import { normalizeUsage } from "openclaw/plugin-sdk/agent-harness-runtime";
4
4
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
5
5
  //#region extensions/codex/src/app-server/attempt-notifications.ts
@@ -275,22 +275,22 @@ function projectCodexThreadUsageUpdate(params, currentUsage, applyUsage, emitCon
275
275
  if (Object.keys(context).length > 0) emitContext(context);
276
276
  }
277
277
  function normalizeCodexThreadTokenUsage(record) {
278
- return normalizeCodexTokenUsageBreakdown(record, "thread");
278
+ return normalizeCodexTokenUsageBreakdown(record);
279
279
  }
280
280
  function normalizeCodexResponseTokenUsage(record) {
281
- return normalizeCodexTokenUsageBreakdown(record, "response");
282
- }
283
- function normalizeCodexTokenUsageBreakdown(record, source) {
284
- const readCount = source === "response" ? readTokenCount : (value, key) => asFiniteNumber(value[key]);
285
- const totalTokens = readCount(record, "totalTokens");
286
- const inputTokens = readCount(record, "inputTokens");
287
- const cacheRead = readCount(record, "cachedInputTokens");
288
- const output = readCount(record, "outputTokens");
289
- const reasoningTokens = readCount(record, "reasoningOutputTokens");
290
- const cacheWrite = record.cacheWriteInputTokens === void 0 && source === "response" ? 0 : readCount(record, "cacheWriteInputTokens");
291
- if (source === "response" && (totalTokens === void 0 || inputTokens === void 0 || cacheRead === void 0 || cacheWrite === void 0 || output === void 0 || reasoningTokens === void 0 || cacheRead + cacheWrite > inputTokens || totalTokens !== inputTokens + output)) return;
281
+ return normalizeCodexTokenUsageBreakdown(record);
282
+ }
283
+ function normalizeCodexTokenUsageBreakdown(record) {
284
+ const totalTokens = readTokenCount(record, "totalTokens");
285
+ const inputTokens = readTokenCount(record, "inputTokens");
286
+ const cacheRead = readTokenCount(record, "cachedInputTokens");
287
+ const output = readTokenCount(record, "outputTokens");
288
+ const reasoningTokens = readTokenCount(record, "reasoningOutputTokens");
289
+ const cacheWrite = record.cacheWriteInputTokens === void 0 ? 0 : readTokenCount(record, "cacheWriteInputTokens");
290
+ const hasCoherentInput = inputTokens !== void 0 && cacheRead !== void 0 && cacheWrite !== void 0 && cacheRead + cacheWrite <= inputTokens;
291
+ const hasCoherentContext = hasCoherentInput && totalTokens !== void 0 && output !== void 0 && totalTokens === inputTokens + output;
292
292
  const usage = normalizeUsage({
293
- input: inputTokens === void 0 ? void 0 : Math.max(0, inputTokens - (cacheRead ?? 0) - (cacheWrite ?? 0)),
293
+ input: hasCoherentInput ? inputTokens - cacheRead - cacheWrite : void 0,
294
294
  output,
295
295
  cacheRead,
296
296
  cacheWrite,
@@ -300,7 +300,7 @@ function normalizeCodexTokenUsageBreakdown(record, source) {
300
300
  if (!usage) return;
301
301
  return {
302
302
  ...usage,
303
- contextUsage: source === "response" && inputTokens !== void 0 && totalTokens !== void 0 ? {
303
+ contextUsage: hasCoherentContext ? {
304
304
  state: "available",
305
305
  promptTokens: inputTokens,
306
306
  totalTokens
@@ -0,0 +1,258 @@
1
+ import { resolvePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
2
+ import { completeWithPreparedSimpleCompletionModel } from "openclaw/plugin-sdk/simple-completion-runtime";
3
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ //#region extensions/codex/src/app-server/model-runtime.ts
5
+ const CODEX_APP_SERVER_RUNTIME_MODEL_PARAM = "codexAppServerRuntimeModel";
6
+ function buildCodexRuntimeModelParams(catalogId, runtimeModelId) {
7
+ return catalogId === runtimeModelId ? void 0 : { [CODEX_APP_SERVER_RUNTIME_MODEL_PARAM]: runtimeModelId };
8
+ }
9
+ function readCodexRuntimeModelId(model, fallbackId) {
10
+ return normalizeOptionalString(model?.params?.[CODEX_APP_SERVER_RUNTIME_MODEL_PARAM]) ?? model?.id ?? fallbackId;
11
+ }
12
+ //#endregion
13
+ //#region extensions/codex/harness.ts
14
+ const DEFAULT_CODEX_HARNESS_PROVIDER_IDS = /* @__PURE__ */ new Set(["codex", "openai"]);
15
+ const SHARED_CODEX_APP_SERVER_CLIENT_DISPOSER = Symbol.for("openclaw.codexAppServerClientDisposer");
16
+ const CODEX_TOOL_POLICY_SAFE_DENY_NAMES = [
17
+ "web_fetch",
18
+ "x_search",
19
+ "memory_search",
20
+ "memory_get",
21
+ "dashboard",
22
+ "canvas",
23
+ "show_widget",
24
+ "message",
25
+ "heartbeat_respond",
26
+ "automations",
27
+ "gateway",
28
+ "skill_workshop",
29
+ "image_generate",
30
+ "music_generate",
31
+ "video_generate",
32
+ "tts"
33
+ ];
34
+ const CODEX_APP_SERVER_CONTEXT_ENGINE_HOST_CAPABILITIES = [
35
+ "bootstrap",
36
+ "assemble-before-prompt",
37
+ "after-turn",
38
+ "maintain",
39
+ "compact",
40
+ "runtime-llm-complete",
41
+ "thread-bootstrap-projection"
42
+ ];
43
+ async function runCodexHostPreparedIsolatedCompletion(params) {
44
+ const timeoutSignal = AbortSignal.timeout(params.timeoutMs);
45
+ const signal = params.abortSignal ? AbortSignal.any([params.abortSignal, timeoutSignal]) : timeoutSignal;
46
+ return { assistant: await completeWithPreparedSimpleCompletionModel({
47
+ model: params.model,
48
+ auth: params.auth,
49
+ cfg: params.config,
50
+ context: {
51
+ systemPrompt: params.systemPrompt,
52
+ messages: [{
53
+ role: "user",
54
+ content: params.prompt,
55
+ timestamp: Date.now()
56
+ }],
57
+ tools: []
58
+ },
59
+ options: {
60
+ maxTokens: params.streamParams?.maxTokens,
61
+ temperature: params.streamParams?.temperature,
62
+ reasoning: params.thinkLevel,
63
+ signal
64
+ }
65
+ }) };
66
+ }
67
+ async function disposeSharedCodexAppServerClients() {
68
+ const dispose = globalThis[SHARED_CODEX_APP_SERVER_CLIENT_DISPOSER];
69
+ await dispose?.();
70
+ }
71
+ /**
72
+ * Creates the Codex app-server harness used for attempts, side questions,
73
+ * compaction, reset, and disposal.
74
+ */
75
+ function createCodexAppServerAgentHarness(options) {
76
+ const harnessRuntimeId = options?.id ?? "codex";
77
+ const normalizedHarnessRuntimeId = harnessRuntimeId.trim().toLowerCase();
78
+ const providerIds = new Set([...options?.providerIds ?? DEFAULT_CODEX_HARNESS_PROVIDER_IDS].map((id) => id.trim().toLowerCase()));
79
+ const sessionCatalogControlFactory = options.sessionCatalogControlFactory;
80
+ const sessionRuntime = options.runtime;
81
+ const resolveAttemptPluginConfig = (config) => resolvePluginConfigObject(config, "codex") ?? options.resolvePluginConfig?.() ?? options.pluginConfig;
82
+ return {
83
+ id: harnessRuntimeId,
84
+ label: options?.label ?? "Codex agent harness",
85
+ autoSelection: { providerIds: [...providerIds] },
86
+ cloudPlacement: {
87
+ mode: "remote-exec",
88
+ devicePlacement: {
89
+ requiredNodeCommands: ["codex.exec-server.stdio.v1"],
90
+ consumesWorkerSlot: false
91
+ }
92
+ },
93
+ delegatedExecutionPluginIds: ["voice-call"],
94
+ contextEngineHostCapabilities: CODEX_APP_SERVER_CONTEXT_ENGINE_HOST_CAPABILITIES,
95
+ conversationToolPolicySupport: "exact",
96
+ conversationToolPolicySafeDenyTools: CODEX_TOOL_POLICY_SAFE_DENY_NAMES,
97
+ deliveryDefaults: { visibleReplies: "message_tool" },
98
+ authBootstrap: "harness",
99
+ ...sessionCatalogControlFactory && sessionRuntime ? { sessionFork: {
100
+ upstreamKinds: ["codex-app-server"],
101
+ fork: async (params) => {
102
+ const { forkCodexUpstreamSession } = await import("./upstream-session-fork-BDVJCLAD.js");
103
+ return await forkCodexUpstreamSession(params, {
104
+ bindingStore: options.bindingStore,
105
+ controlFactory: sessionCatalogControlFactory,
106
+ harnessRuntimeId,
107
+ resolveConfig: options.resolveConfig,
108
+ runtime: sessionRuntime
109
+ });
110
+ }
111
+ } } : {},
112
+ authBinding: { fingerprint: async (params) => {
113
+ const { fingerprintCodexAppServerAuthBinding } = await import("./auth-binding-B4FfbcCg.js").then((n) => n.t);
114
+ return fingerprintCodexAppServerAuthBinding(params);
115
+ } },
116
+ runtimeArtifact: { validate: async (binding) => {
117
+ const { validateCodexAppServerRuntimeArtifact } = await import("./runtime-artifact-BvyT1uyd.js");
118
+ return validateCodexAppServerRuntimeArtifact(binding);
119
+ } },
120
+ fetchUsageSnapshot: async (ctx) => {
121
+ const { fetchCodexAppServerUsageSnapshot } = await import("./usage-9dKJCgcy.js");
122
+ return await fetchCodexAppServerUsageSnapshot(ctx, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
123
+ },
124
+ loadModelCatalog: async (params) => {
125
+ const { loadCodexAppServerModelCatalog } = await import("./model-catalog-CmGoqVKB.js");
126
+ return await loadCodexAppServerModelCatalog(params, resolveAttemptPluginConfig(params.config));
127
+ },
128
+ loadMcpToolCatalog: async (params) => {
129
+ const { loadCodexEffectiveMcpCatalog } = await import("./effective-mcp-catalog-4YKn51aG.js");
130
+ return await loadCodexEffectiveMcpCatalog(params, { bindingStore: options.bindingStore });
131
+ },
132
+ supports: (ctx) => {
133
+ const provider = ctx.provider.trim().toLowerCase();
134
+ if (!providerIds.has(provider)) return {
135
+ supported: false,
136
+ reason: `provider is not one of: ${[...providerIds].toSorted().join(", ")}`
137
+ };
138
+ if (ctx.modelProvider?.requestTransportOverrides === "present") return {
139
+ supported: false,
140
+ reason: "Codex cannot reproduce authored request transport overrides",
141
+ fallbackRuntime: "openclaw"
142
+ };
143
+ const preparedAuth = ctx.modelProvider?.preparedAuth;
144
+ const runtimePolicy = ctx.modelProvider?.runtimePolicy;
145
+ const nativeAccountOwnsUnobservedModel = provider === "openai" && ctx.requestedRuntime === "codex" && Boolean(ctx.modelId?.trim()) && (preparedAuth === void 0 || preparedAuth.source === "harness") && preparedAuth?.mode === void 0 && preparedAuth?.requirement === void 0 && ctx.modelProvider?.api === void 0 && ctx.modelProvider?.baseUrl === void 0 && ctx.modelProvider?.azureApiVersion === void 0 && ctx.modelProvider?.request === void 0;
146
+ if (runtimePolicy) {
147
+ if (!runtimePolicy.compatibleIds.some((id) => id.trim().toLowerCase() === normalizedHarnessRuntimeId)) return {
148
+ supported: false,
149
+ reason: "Codex cannot reproduce the prepared provider route"
150
+ };
151
+ } else if (ctx.modelProvider && provider !== "codex" && !nativeAccountOwnsUnobservedModel) return {
152
+ supported: false,
153
+ reason: "provider route compatibility with Codex is not declared"
154
+ };
155
+ if (preparedAuth?.requirement === "subscription") {
156
+ if (!(preparedAuth.source === "profile" && (preparedAuth.mode === "oauth" || preparedAuth.mode === "token"))) return {
157
+ supported: false,
158
+ reason: "Codex subscription auth requires a prepared OAuth or token profile"
159
+ };
160
+ } else if (preparedAuth?.requirement === "api-key") {
161
+ if (!(preparedAuth.source !== "none" && preparedAuth.source !== "harness" && (preparedAuth.mode === "api-key" || preparedAuth.mode === "api_key"))) return {
162
+ supported: false,
163
+ reason: "Codex Platform auth requires a prepared API key"
164
+ };
165
+ }
166
+ return {
167
+ supported: true,
168
+ priority: 100
169
+ };
170
+ },
171
+ runAttempt: async (params) => {
172
+ const { runCodexAppServerAttempt } = await import("./run-attempt-BV3HzuCf.js");
173
+ return runCodexAppServerAttempt(params, {
174
+ bindingStore: options.bindingStore,
175
+ pluginConfig: resolveAttemptPluginConfig(params.config),
176
+ runtime: sessionRuntime,
177
+ runtimeModelId: readCodexRuntimeModelId(params.model, params.modelId),
178
+ nativeHookRelay: { enabled: true }
179
+ });
180
+ },
181
+ runIsolatedCompletionV2: async (params) => {
182
+ if (params.authorization.owner === "host") {
183
+ const { authorization, ...commonParams } = params;
184
+ return runCodexHostPreparedIsolatedCompletion({
185
+ ...commonParams,
186
+ model: authorization.model,
187
+ auth: authorization.auth,
188
+ ...authorization.sourceAuthFingerprint ? { sourceAuthFingerprint: authorization.sourceAuthFingerprint } : {}
189
+ });
190
+ }
191
+ const { runCodexIsolatedCompletion } = await import("./isolated-completion-DPMtlH9r.js");
192
+ return runCodexIsolatedCompletion(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
193
+ },
194
+ runIsolatedCompletion: async (params) => {
195
+ return runCodexHostPreparedIsolatedCompletion(params);
196
+ },
197
+ finalizeSettledTurn: async (params) => {
198
+ const { runCodexSettledTurnFinalization } = await import("./settled-turn-finalizer-Dx1onIqg.js");
199
+ return runCodexSettledTurnFinalization(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
200
+ },
201
+ runSideQuestion: async (params) => {
202
+ const { runCodexAppServerSideQuestion } = await import("./side-question-DbXkJZzg.js");
203
+ return runCodexAppServerSideQuestion(params, {
204
+ bindingStore: options.bindingStore,
205
+ pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
206
+ runtime: sessionRuntime,
207
+ runtimeModelId: readCodexRuntimeModelId(params.runtimeModel, params.model),
208
+ nativeHookRelay: { enabled: true }
209
+ });
210
+ },
211
+ compact: async (params) => {
212
+ const { maybeCompactCodexAppServerSession } = await import("./compact-COqgBRny.js");
213
+ return maybeCompactCodexAppServerSession(params, {
214
+ bindingStore: options.bindingStore,
215
+ pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig
216
+ });
217
+ },
218
+ reset: async (params) => {
219
+ if (params.sessionId) {
220
+ const [{ reclaimCurrentCodexSessionGeneration, sessionBindingIdentity }, { retireCodexAppServerSessionGeneration }] = await Promise.all([import("./session-binding-BTrLf9Qm.js").then((n) => n.f), import("./session-retirement-CE4iMiLh.js")]);
221
+ const identity = sessionBindingIdentity({
222
+ agentId: params.agentId,
223
+ sessionId: params.sessionId,
224
+ sessionKey: params.sessionKey
225
+ });
226
+ const resetGeneration = () => retireCodexAppServerSessionGeneration({
227
+ bindingStore: options.bindingStore,
228
+ identity,
229
+ mode: params.reason === "deleted" ? "retire" : "reset"
230
+ });
231
+ let reset = await resetGeneration();
232
+ if (reset === "conflict") {
233
+ if (await reclaimCurrentCodexSessionGeneration({
234
+ bindingStore: options.bindingStore,
235
+ identity,
236
+ config: options.resolveConfig?.()
237
+ })) reset = await resetGeneration();
238
+ }
239
+ if (reset === "conflict") throw new Error(`Codex binding generation changed before session ${params.sessionId} could reset`);
240
+ }
241
+ },
242
+ dispose: disposeSharedCodexAppServerClients
243
+ };
244
+ }
245
+ /** Creates the private native-compaction bridge registered in host-owned capability state. */
246
+ function createCodexAppServerNativeCompaction(options) {
247
+ return async (params) => {
248
+ const { maybeCompactCodexAppServerSession } = await import("./compact-COqgBRny.js");
249
+ return maybeCompactCodexAppServerSession(params, {
250
+ bindingStore: options.bindingStore,
251
+ pluginConfig: options.resolvePluginConfig?.() ?? options.pluginConfig,
252
+ allowNonManualNativeRequest: true,
253
+ nativeCompactionRequest: params.nativeCompactionRequest
254
+ });
255
+ };
256
+ }
257
+ //#endregion
258
+ export { createCodexAppServerNativeCompaction as n, buildCodexRuntimeModelParams as r, createCodexAppServerAgentHarness as t };
package/dist/harness.js CHANGED
@@ -1,226 +1,2 @@
1
- import { completeWithPreparedSimpleCompletionModel } from "openclaw/plugin-sdk/simple-completion-runtime";
2
- //#region extensions/codex/harness.ts
3
- const DEFAULT_CODEX_HARNESS_PROVIDER_IDS = /* @__PURE__ */ new Set(["codex", "openai"]);
4
- const SHARED_CODEX_APP_SERVER_CLIENT_DISPOSER = Symbol.for("openclaw.codexAppServerClientDisposer");
5
- const CODEX_TOOL_POLICY_SAFE_DENY_NAMES = [
6
- "web_fetch",
7
- "x_search",
8
- "memory_search",
9
- "memory_get",
10
- "dashboard",
11
- "canvas",
12
- "show_widget",
13
- "message",
14
- "heartbeat_respond",
15
- "automations",
16
- "gateway",
17
- "skill_workshop",
18
- "music_generate",
19
- "video_generate",
20
- "tts"
21
- ];
22
- const CODEX_APP_SERVER_CONTEXT_ENGINE_HOST_CAPABILITIES = [
23
- "bootstrap",
24
- "assemble-before-prompt",
25
- "after-turn",
26
- "maintain",
27
- "compact",
28
- "runtime-llm-complete",
29
- "thread-bootstrap-projection"
30
- ];
31
- async function runCodexHostPreparedIsolatedCompletion(params) {
32
- const timeoutSignal = AbortSignal.timeout(params.timeoutMs);
33
- const signal = params.abortSignal ? AbortSignal.any([params.abortSignal, timeoutSignal]) : timeoutSignal;
34
- return { assistant: await completeWithPreparedSimpleCompletionModel({
35
- model: params.model,
36
- auth: params.auth,
37
- cfg: params.config,
38
- context: {
39
- systemPrompt: params.systemPrompt,
40
- messages: [{
41
- role: "user",
42
- content: params.prompt,
43
- timestamp: Date.now()
44
- }],
45
- tools: []
46
- },
47
- options: {
48
- maxTokens: params.streamParams?.maxTokens,
49
- temperature: params.streamParams?.temperature,
50
- reasoning: params.thinkLevel,
51
- signal
52
- }
53
- }) };
54
- }
55
- async function disposeSharedCodexAppServerClients() {
56
- const dispose = globalThis[SHARED_CODEX_APP_SERVER_CLIENT_DISPOSER];
57
- await dispose?.();
58
- }
59
- /**
60
- * Creates the Codex app-server harness used for attempts, side questions,
61
- * compaction, reset, and disposal.
62
- */
63
- function createCodexAppServerAgentHarness(options) {
64
- const harnessRuntimeId = options?.id ?? "codex";
65
- const normalizedHarnessRuntimeId = harnessRuntimeId.trim().toLowerCase();
66
- const providerIds = new Set([...options?.providerIds ?? DEFAULT_CODEX_HARNESS_PROVIDER_IDS].map((id) => id.trim().toLowerCase()));
67
- const sessionCatalogControl = options.sessionCatalogControl;
68
- const sessionRuntime = options.runtime;
69
- return {
70
- id: harnessRuntimeId,
71
- label: options?.label ?? "Codex agent harness",
72
- autoSelection: { providerIds: [...providerIds] },
73
- cloudPlacement: { mode: "remote-exec" },
74
- delegatedExecutionPluginIds: ["voice-call"],
75
- contextEngineHostCapabilities: CODEX_APP_SERVER_CONTEXT_ENGINE_HOST_CAPABILITIES,
76
- conversationToolPolicySupport: "exact",
77
- conversationToolPolicySafeDenyTools: CODEX_TOOL_POLICY_SAFE_DENY_NAMES,
78
- deliveryDefaults: { visibleReplies: "message_tool" },
79
- authBootstrap: "harness",
80
- ...sessionCatalogControl && sessionRuntime ? { sessionFork: {
81
- upstreamKinds: ["codex-app-server"],
82
- fork: async (params) => {
83
- const { forkCodexUpstreamSession } = await import("./upstream-session-fork-CE-_LdnP.js");
84
- return await forkCodexUpstreamSession(params, {
85
- bindingStore: options.bindingStore,
86
- control: sessionCatalogControl,
87
- harnessRuntimeId,
88
- resolveConfig: options.resolveConfig,
89
- runtime: sessionRuntime
90
- });
91
- }
92
- } } : {},
93
- authBinding: { fingerprint: async (params) => {
94
- const { fingerprintCodexAppServerAuthBinding } = await import("./auth-binding-B4FfbcCg.js").then((n) => n.t);
95
- return fingerprintCodexAppServerAuthBinding(params);
96
- } },
97
- runtimeArtifact: { validate: async (binding) => {
98
- const { validateCodexAppServerRuntimeArtifact } = await import("./runtime-artifact-BVSPdd6g.js");
99
- return validateCodexAppServerRuntimeArtifact(binding);
100
- } },
101
- fetchUsageSnapshot: async (ctx) => {
102
- const { fetchCodexAppServerUsageSnapshot } = await import("./usage-CHlV0e-o.js");
103
- return await fetchCodexAppServerUsageSnapshot(ctx, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
104
- },
105
- loadMcpToolCatalog: async (params) => {
106
- const { loadCodexEffectiveMcpCatalog } = await import("./effective-mcp-catalog-DIIhAtOZ.js");
107
- return await loadCodexEffectiveMcpCatalog(params, { bindingStore: options.bindingStore });
108
- },
109
- supports: (ctx) => {
110
- const provider = ctx.provider.trim().toLowerCase();
111
- if (!providerIds.has(provider)) return {
112
- supported: false,
113
- reason: `provider is not one of: ${[...providerIds].toSorted().join(", ")}`
114
- };
115
- if (ctx.modelProvider?.requestTransportOverrides === "present") return {
116
- supported: false,
117
- reason: "Codex cannot reproduce authored request transport overrides",
118
- fallbackRuntime: "openclaw"
119
- };
120
- const preparedAuth = ctx.modelProvider?.preparedAuth;
121
- const runtimePolicy = ctx.modelProvider?.runtimePolicy;
122
- if (runtimePolicy) {
123
- if (!runtimePolicy.compatibleIds.some((id) => id.trim().toLowerCase() === normalizedHarnessRuntimeId)) return {
124
- supported: false,
125
- reason: "Codex cannot reproduce the prepared provider route"
126
- };
127
- } else if (ctx.modelProvider && provider !== "codex") return {
128
- supported: false,
129
- reason: "provider route compatibility with Codex is not declared"
130
- };
131
- if (preparedAuth?.requirement === "subscription") {
132
- if (!(preparedAuth.source === "profile" && (preparedAuth.mode === "oauth" || preparedAuth.mode === "token"))) return {
133
- supported: false,
134
- reason: "Codex subscription auth requires a prepared OAuth or token profile"
135
- };
136
- } else if (preparedAuth?.requirement === "api-key") {
137
- if (!(preparedAuth.source !== "none" && preparedAuth.source !== "harness" && (preparedAuth.mode === "api-key" || preparedAuth.mode === "api_key"))) return {
138
- supported: false,
139
- reason: "Codex Platform auth requires a prepared API key"
140
- };
141
- }
142
- return {
143
- supported: true,
144
- priority: 100
145
- };
146
- },
147
- runAttempt: async (params) => {
148
- const { runCodexAppServerAttempt } = await import("./run-attempt-P8BdxC1I.js");
149
- return runCodexAppServerAttempt(params, {
150
- bindingStore: options.bindingStore,
151
- pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
152
- nativeHookRelay: { enabled: true }
153
- });
154
- },
155
- runIsolatedCompletionV2: async (params) => {
156
- if (params.authorization.owner === "host") {
157
- const { authorization, ...commonParams } = params;
158
- return runCodexHostPreparedIsolatedCompletion({
159
- ...commonParams,
160
- model: authorization.model,
161
- auth: authorization.auth,
162
- ...authorization.sourceAuthFingerprint ? { sourceAuthFingerprint: authorization.sourceAuthFingerprint } : {}
163
- });
164
- }
165
- const { runCodexIsolatedCompletion } = await import("./isolated-completion-C58NbL40.js");
166
- return runCodexIsolatedCompletion(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
167
- },
168
- runIsolatedCompletion: async (params) => {
169
- return runCodexHostPreparedIsolatedCompletion(params);
170
- },
171
- finalizeSettledTurn: async (params) => {
172
- const { runCodexSettledTurnFinalization } = await import("./settled-turn-finalizer-BRWBO4MO.js");
173
- return runCodexSettledTurnFinalization(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
174
- },
175
- runSideQuestion: async (params) => {
176
- const { runCodexAppServerSideQuestion } = await import("./side-question-9HAL26l9.js");
177
- return runCodexAppServerSideQuestion(params, {
178
- bindingStore: options.bindingStore,
179
- pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
180
- nativeHookRelay: { enabled: true }
181
- });
182
- },
183
- compact: async (params) => {
184
- const { maybeCompactCodexAppServerSession } = await import("./compact-LspQaGfl.js");
185
- return maybeCompactCodexAppServerSession(params, {
186
- bindingStore: options.bindingStore,
187
- pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig
188
- });
189
- },
190
- compactAfterContextEngine: async (params) => {
191
- const { maybeCompactCodexAppServerSession } = await import("./compact-LspQaGfl.js");
192
- return maybeCompactCodexAppServerSession(params, {
193
- bindingStore: options.bindingStore,
194
- pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
195
- allowNonManualNativeRequest: true
196
- });
197
- },
198
- reset: async (params) => {
199
- if (params.sessionId) {
200
- const [{ reclaimCurrentCodexSessionGeneration, sessionBindingIdentity }, { retireCodexAppServerSessionGeneration }] = await Promise.all([import("./session-binding-DPxIvMgE.js").then((n) => n.f), import("./session-retirement-DoMMJFKm.js")]);
201
- const identity = sessionBindingIdentity({
202
- agentId: params.agentId,
203
- sessionId: params.sessionId,
204
- sessionKey: params.sessionKey
205
- });
206
- const resetGeneration = () => retireCodexAppServerSessionGeneration({
207
- bindingStore: options.bindingStore,
208
- identity,
209
- mode: params.reason === "deleted" ? "retire" : "reset"
210
- });
211
- let reset = await resetGeneration();
212
- if (reset === "conflict") {
213
- if (await reclaimCurrentCodexSessionGeneration({
214
- bindingStore: options.bindingStore,
215
- identity,
216
- config: options.resolveConfig?.()
217
- })) reset = await resetGeneration();
218
- }
219
- if (reset === "conflict") throw new Error(`Codex binding generation changed before session ${params.sessionId} could reset`);
220
- }
221
- },
222
- dispose: disposeSharedCodexAppServerClients
223
- };
224
- }
225
- //#endregion
226
- export { createCodexAppServerAgentHarness };
1
+ import { n as createCodexAppServerNativeCompaction, t as createCodexAppServerAgentHarness } from "./harness-DoKQcF8n.js";
2
+ export { createCodexAppServerAgentHarness, createCodexAppServerNativeCompaction };