@openclaw/codex 2026.7.2-beta.7 → 2026.8.1-beta.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.
Files changed (55) hide show
  1. package/README.md +2 -0
  2. package/dist/{app-server-policy-BSaO2JIT.js → app-server-policy-zcBDc1JU.js} +1 -1
  3. package/dist/attempt-client-cleanup-DMLXUfa8.js +735 -0
  4. package/dist/{notification-correlation-CU6_AnOb.js → binding-connection-I5Bo-AsX.js} +3 -37
  5. package/dist/{bounded-turn-D2ZAgZVz.js → bounded-turn-qgZmzy_4.js} +50 -49
  6. package/dist/{capabilities-BFDTVYr4.js → capabilities-CybGI1oz.js} +8 -2
  7. package/dist/cli-metadata.js +1 -1
  8. package/dist/{command-formatters-C336eRVS.js → command-formatters-B1AEz8ZA.js} +18 -18
  9. package/dist/{command-handlers-DAHUSry9.js → command-handlers-Db8pu_ds.js} +484 -95
  10. package/dist/{compact-D_uvHurS.js → compact-LspQaGfl.js} +213 -199
  11. package/dist/{conversation-binding-data-BHRpYbX3.js → conversation-binding-data-CW2GuupV.js} +6 -10
  12. package/dist/doctor-contract-api.js +40 -43
  13. package/dist/{dynamic-tools-D2gYkSBO.js → dynamic-tools-BVdyWkUD.js} +2597 -1221
  14. package/dist/{effective-mcp-catalog-Bbd98Inw.js → effective-mcp-catalog-DIIhAtOZ.js} +20 -15
  15. package/dist/{event-projector-assistant-message-DTgnPPVF.js → event-projector-assistant-message-BwxV4d6N.js} +11 -23
  16. package/dist/{attempt-notifications-AP-a-Q5k.js → event-projector-usage-e5huIQWu.js} +113 -29
  17. package/dist/harness.js +80 -14
  18. package/dist/image-payload-sanitizer-CnfoUPCE.js +65 -0
  19. package/dist/index.js +591 -240
  20. package/dist/isolated-completion-C58NbL40.js +75 -0
  21. package/dist/local-runtime-attribution-B_2mnqhb.js +19 -0
  22. package/dist/media-understanding-provider.js +5 -5
  23. package/dist/{models-BBMKU4jA.js → models-BFlpn1Ex.js} +12 -17
  24. package/dist/native-subagent-monitor-DyTGmTUx.js +3111 -0
  25. package/dist/{plugin-app-cache-key-DztPafOA.js → plugin-app-cache-key-C3H2CVp6.js} +5 -5
  26. package/dist/plugin-marketplace-discovery-CzrGJdCR.js +385 -0
  27. package/dist/{computer-use-CYEc8U3w.js → plugin-metadata-cache-CNJPj4_b.js} +105 -5
  28. package/dist/protocol-validators-B4F7L8Rf.js +2346 -0
  29. package/dist/{rate-limits-CU-gVCCS.js → rate-limits-DZXmOL8-.js} +17 -35
  30. package/dist/{request-qKh331yu.js → request-BRl5_UfX.js} +3 -3
  31. package/dist/{run-attempt-CY9WlDLc.js → run-attempt-P8BdxC1I.js} +4837 -9047
  32. package/dist/{runtime-artifact-CmtG_t1L.js → runtime-artifact-BVSPdd6g.js} +8 -23
  33. package/dist/{sandbox-guard-NuhpXmPB.js → sandbox-guard-Cmwc9eIk.js} +6 -13
  34. package/dist/{session-binding-BXpo9ymA.js → session-binding-DPxIvMgE.js} +246 -265
  35. package/dist/{session-catalog-DyOgR4WH.js → session-catalog-xwNi_SDM.js} +159 -109
  36. package/dist/{session-cli-2PZaFLRh.js → session-cli-7hgXZDV7.js} +1 -1
  37. package/dist/session-retirement-DoMMJFKm.js +36 -0
  38. package/dist/{session-upstream-marker-B6U7tLw5.js → session-upstream-marker-CrIFX06J.js} +1 -1
  39. package/dist/{settled-turn-finalizer-CXY2Z9dT.js → settled-turn-finalizer-BRWBO4MO.js} +21 -13
  40. package/dist/{shared-client-DTbvH-XV.js → shared-client-kIBbGjk4.js} +587 -223
  41. package/dist/{side-question-_ulBk1AL.js → side-question-9HAL26l9.js} +101 -52
  42. package/dist/{thread-lifecycle-DF53ogiA.js → thread-lifecycle-Bu1BTDXr.js} +694 -753
  43. package/dist/thread-ownership-6kOQHlyC.js +92 -0
  44. package/dist/thread-resume-CPrJNQVM.js +30 -0
  45. package/dist/transcript-mirror-B9gGgnJS.js +570 -0
  46. package/dist/{transport-stdio-DXgGZ7Ib.js → transport-stdio-DIImwDVS.js} +11 -0
  47. package/dist/upstream-prompt-provenance-ClRBije0.js +41 -0
  48. package/dist/{upstream-session-fork-Dy4Xvuoj.js → upstream-session-fork-CE-_LdnP.js} +5 -5
  49. package/dist/{usage-CQ6GhD5-.js → usage-CHlV0e-o.js} +3 -3
  50. package/dist/{web-search-provider.runtime-CCFhg2z5.js → web-search-provider.runtime-DRw2Vl42.js} +8 -9
  51. package/openclaw.plugin.json +18 -3
  52. package/package.json +5 -5
  53. package/dist/conversation-control-xsIeXbo4.js +0 -287
  54. package/dist/event-projector-usage-Xp4AlR2k.js +0 -86
  55. package/dist/transcript-mirror-DzsdNCf5.js +0 -6924
@@ -1,6 +1,7 @@
1
- import { W as isJsonObject } from "./shared-client-DTbvH-XV.js";
2
- import { h as buildCodexNativeWebSearchThreadConfig } from "./thread-lifecycle-DF53ogiA.js";
3
- import { t as runBoundedCodexAppServerTurn } from "./bounded-turn-D2ZAgZVz.js";
1
+ import { ct as isJsonObject } from "./shared-client-kIBbGjk4.js";
2
+ import { d as buildCodexNativeWebSearchThreadConfig } from "./thread-lifecycle-Bu1BTDXr.js";
3
+ import { t as runBoundedCodexAppServerTurn } from "./bounded-turn-qgZmzy_4.js";
4
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
5
  import { readStringParam, resolveSearchTimeoutSeconds, wrapWebContent } from "openclaw/plugin-sdk/provider-web-search";
5
6
  //#region extensions/codex/src/web-search-provider.runtime.ts
6
7
  async function executeCodexWebSearchProviderTool(ctx, args, executionContext, options) {
@@ -9,6 +10,7 @@ async function executeCodexWebSearchProviderTool(ctx, args, executionContext, op
9
10
  const result = await runBoundedCodexAppServerTurn({
10
11
  config: ctx.config,
11
12
  model: { mode: "live-default" },
13
+ modelProvider: "openai",
12
14
  timeoutMs: resolveSearchTimeoutSeconds(ctx.searchConfig) * 1e3,
13
15
  signal: executionContext?.signal,
14
16
  agentDir: ctx.agentDir,
@@ -45,7 +47,7 @@ function summarizeCodexWebSearchItem(item) {
45
47
  const action = isJsonObject(item.action) ? item.action : void 0;
46
48
  const actionType = readNonEmptyString(action, "type");
47
49
  const queries = actionType === "search" ? readNonEmptyStringArray(action, "queries") : [];
48
- const query = normalizeNonEmptyString(item.query) ?? (actionType === "search" ? readNonEmptyString(action, "query") : void 0) ?? queries[0];
50
+ const query = normalizeOptionalString(item.query) ?? (actionType === "search" ? readNonEmptyString(action, "query") : void 0) ?? queries[0];
49
51
  const url = readNonEmptyString(action, "url");
50
52
  const pattern = readNonEmptyString(action, "pattern");
51
53
  return {
@@ -57,18 +59,15 @@ function summarizeCodexWebSearchItem(item) {
57
59
  };
58
60
  }
59
61
  function readNonEmptyString(record, key) {
60
- return record ? normalizeNonEmptyString(record[key]) : void 0;
62
+ return record ? normalizeOptionalString(record[key]) : void 0;
61
63
  }
62
64
  function readNonEmptyStringArray(record, key) {
63
65
  const value = record?.[key];
64
66
  if (!Array.isArray(value)) return [];
65
67
  return value.flatMap((entry) => {
66
- const normalized = normalizeNonEmptyString(entry);
68
+ const normalized = normalizeOptionalString(entry);
67
69
  return normalized ? [normalized] : [];
68
70
  });
69
71
  }
70
- function normalizeNonEmptyString(value) {
71
- return typeof value === "string" ? value.trim() || void 0 : void 0;
72
- }
73
72
  //#endregion
74
73
  export { executeCodexWebSearchProviderTool };
@@ -1,5 +1,19 @@
1
1
  {
2
2
  "id": "codex",
3
+ "doctorContract": {
4
+ "configRepair": true,
5
+ "stateMigrations": true
6
+ },
7
+ "sessionRouteStateOwners": [
8
+ {
9
+ "id": "codex",
10
+ "label": "Codex",
11
+ "providerIds": ["codex", "codex-cli", "openai-codex"],
12
+ "runtimeIds": ["codex", "codex-cli"],
13
+ "cliSessionKeys": ["codex-cli"],
14
+ "authProfilePrefixes": ["codex:", "codex-cli:", "openai-codex:"]
15
+ }
16
+ ],
3
17
  "name": "Codex",
4
18
  "description": "Codex app-server harness and native session catalog.",
5
19
  "contracts": {
@@ -7,6 +21,7 @@
7
21
  "migrationProviders": ["codex"],
8
22
  "tools": [
9
23
  "codex_threads",
24
+ "codex_plugins",
10
25
  "codex_endpoint_probe",
11
26
  "codex_sessions_list",
12
27
  "codex_session_read",
@@ -28,6 +43,7 @@
28
43
  "onAgentHarnesses": ["codex"],
29
44
  "onCommands": ["codex"],
30
45
  "onConfigPaths": [
46
+ "plugins.entries.codex.config.appServer.transport",
31
47
  "plugins.entries.codex.config.sessionCatalog.enabled",
32
48
  "plugins.entries.codex.config.supervision.enabled"
33
49
  ]
@@ -167,7 +183,7 @@
167
183
  },
168
184
  "marketplaceName": {
169
185
  "type": "string",
170
- "enum": ["openai-curated", "workspace-directory"]
186
+ "pattern": "^[A-Za-z0-9_-]+$"
171
187
  },
172
188
  "pluginName": {
173
189
  "type": "string"
@@ -235,8 +251,7 @@
235
251
  },
236
252
  "homeScope": {
237
253
  "type": "string",
238
- "enum": ["agent", "user"],
239
- "default": "agent"
254
+ "enum": ["agent", "user"]
240
255
  },
241
256
  "command": { "type": "string" },
242
257
  "args": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/codex",
3
- "version": "2026.7.2-beta.7",
3
+ "version": "2026.8.1-beta.2",
4
4
  "description": "OpenClaw Codex app-server harness and native session supervision plugin.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "type": "module",
10
10
  "dependencies": {
11
- "@openai/codex": "0.146.0",
11
+ "@openai/codex": "0.147.0",
12
12
  "smol-toml": "1.7.1",
13
13
  "typebox": "1.3.6",
14
14
  "ws": "8.21.1",
@@ -35,10 +35,10 @@
35
35
  ]
36
36
  },
37
37
  "compat": {
38
- "pluginApi": ">=2026.7.2-beta.7"
38
+ "pluginApi": ">=2026.8.1-beta.2"
39
39
  },
40
40
  "build": {
41
- "openclawVersion": "2026.7.2-beta.7"
41
+ "openclawVersion": "2026.8.1-beta.2"
42
42
  },
43
43
  "release": {
44
44
  "publishToClawHub": true,
@@ -58,7 +58,7 @@
58
58
  "README.md"
59
59
  ],
60
60
  "peerDependencies": {
61
- "openclaw": ">=2026.7.2-beta.7"
61
+ "openclaw": ">=2026.8.1-beta.2"
62
62
  },
63
63
  "peerDependenciesMeta": {
64
64
  "openclaw": {
@@ -1,287 +0,0 @@
1
- import { a as getLeasedSharedCodexAppServerClient, c as releaseCodexAppServerClientLease, h as withLeasedCodexAppServerClientStartSelectionRetry, l as releaseLeasedSharedCodexAppServerClient } from "./shared-client-DTbvH-XV.js";
2
- import { T as resolveCodexModelBackedReviewerPolicyContext, g as resolveCodexAppServerRuntimeOptions, j as isCodexFastServiceTier, o as isCodexAppServerNativeAuthProfile, r as bindingStoreKey, s as normalizeCodexAppServerBindingModelProvider } from "./session-binding-BXpo9ymA.js";
3
- import { S as resolveCodexBindingModelProviderFallback, b as resolveCodexAppServerRequestModelSelection } from "./thread-lifecycle-DF53ogiA.js";
4
- import { t as CODEX_CONTROL_METHODS } from "./capabilities-BFDTVYr4.js";
5
- import { r as formatCodexDisplayText } from "./command-formatters-C336eRVS.js";
6
- import { a as resolveCodexBindingAppServerConnection } from "./notification-correlation-CU6_AnOb.js";
7
- import { ModelSelectionLockedError } from "openclaw/plugin-sdk/model-session-runtime";
8
- //#region extensions/codex/src/command-authorization.ts
9
- const CODEX_NATIVE_EXECUTION_AUTH_ERROR = "Only an owner or operator.admin can control Codex native execution.";
10
- function canMutateCodexHost(ctx) {
11
- return ctx.senderIsOwner === true || ctx.gatewayClientScopes?.includes("operator.admin") === true;
12
- }
13
- //#endregion
14
- //#region extensions/codex/src/conversation-control.ts
15
- const CODEX_CONVERSATION_CONTROL_STATE = Symbol.for("openclaw.codex.conversationControl");
16
- function getActiveTurns() {
17
- const globalState = globalThis;
18
- globalState[CODEX_CONVERSATION_CONTROL_STATE] ??= /* @__PURE__ */ new Map();
19
- return globalState[CODEX_CONVERSATION_CONTROL_STATE];
20
- }
21
- function trackCodexConversationActiveTurn(active) {
22
- const activeTurns = getActiveTurns();
23
- const key = bindingStoreKey(active.identity);
24
- activeTurns.set(key, active);
25
- return () => {
26
- if (activeTurns.get(key)?.turnId === active.turnId) activeTurns.delete(key);
27
- };
28
- }
29
- function readCodexConversationActiveTurn(identity) {
30
- return getActiveTurns().get(bindingStoreKey(identity));
31
- }
32
- async function stopCodexConversationTurn(params) {
33
- const active = readCodexConversationActiveTurn(params.identity);
34
- if (!active) return {
35
- stopped: false,
36
- message: "No active Codex run to stop."
37
- };
38
- const lookup = buildBindingLookup(params);
39
- const binding = await params.bindingStore.read(params.identity);
40
- if (binding?.threadId !== active.threadId) return {
41
- stopped: false,
42
- message: "The active Codex run no longer matches this session binding."
43
- };
44
- const connection = resolveCodexBindingAppServerConnection({
45
- binding,
46
- authProfileId: binding?.authProfileId,
47
- pluginConfig: params.pluginConfig
48
- });
49
- const runtime = connection.appServer;
50
- const client = active.client ?? await getLeasedSharedCodexAppServerClient({
51
- startOptions: runtime.start,
52
- timeoutMs: runtime.requestTimeoutMs,
53
- authProfileId: connection.clientAuthProfileId,
54
- ...lookup
55
- });
56
- try {
57
- await client.request("turn/interrupt", {
58
- threadId: active.threadId,
59
- turnId: active.turnId
60
- }, { timeoutMs: runtime.requestTimeoutMs });
61
- } finally {
62
- if (!active.client) releaseLeasedSharedCodexAppServerClient(client);
63
- }
64
- return {
65
- stopped: true,
66
- message: "Codex stop requested."
67
- };
68
- }
69
- async function steerCodexConversationTurn(params) {
70
- const active = readCodexConversationActiveTurn(params.identity);
71
- const text = params.message.trim();
72
- if (!text) return {
73
- steered: false,
74
- message: "Usage: /codex steer <message>"
75
- };
76
- if (!active) return {
77
- steered: false,
78
- message: "No active Codex run to steer."
79
- };
80
- const lookup = buildBindingLookup(params);
81
- const binding = await params.bindingStore.read(params.identity);
82
- if (binding?.threadId !== active.threadId) return {
83
- steered: false,
84
- message: "The active Codex run no longer matches this session binding."
85
- };
86
- const connection = resolveCodexBindingAppServerConnection({
87
- binding,
88
- authProfileId: binding?.authProfileId,
89
- pluginConfig: params.pluginConfig
90
- });
91
- const runtime = connection.appServer;
92
- const client = active.client ?? await getLeasedSharedCodexAppServerClient({
93
- startOptions: runtime.start,
94
- timeoutMs: runtime.requestTimeoutMs,
95
- authProfileId: connection.clientAuthProfileId,
96
- ...lookup
97
- });
98
- try {
99
- await client.request("turn/steer", {
100
- threadId: active.threadId,
101
- expectedTurnId: active.turnId,
102
- input: [{
103
- type: "text",
104
- text,
105
- text_elements: []
106
- }]
107
- }, { timeoutMs: runtime.requestTimeoutMs });
108
- } finally {
109
- if (!active.client) releaseLeasedSharedCodexAppServerClient(client);
110
- }
111
- return {
112
- steered: true,
113
- message: "Sent steer message to Codex."
114
- };
115
- }
116
- async function setCodexConversationModel(params) {
117
- const model = params.model.trim();
118
- if (!model) return "Usage: /codex model <model>";
119
- const lookup = buildBindingLookup(params);
120
- const binding = await requireThreadBinding(params.bindingStore, params.identity);
121
- if (binding.connectionScope === "supervision") throw new ModelSelectionLockedError();
122
- const reviewerPolicyContext = resolveCodexModelBackedReviewerPolicyContext({
123
- provider: "codex",
124
- model,
125
- bindingModelProvider: binding.modelProvider,
126
- bindingModel: binding.model,
127
- nativeAuthProfile: isCodexAppServerNativeAuthProfile({
128
- authProfileId: binding.authProfileId,
129
- ...lookup
130
- })
131
- });
132
- const runtime = resolveCodexAppServerRuntimeOptions({
133
- pluginConfig: params.pluginConfig,
134
- modelProvider: reviewerPolicyContext.modelProvider,
135
- model: reviewerPolicyContext.model,
136
- config: params.config,
137
- agentDir: params.agentDir
138
- });
139
- const modelSelection = resolveCodexAppServerRequestModelSelection({
140
- model,
141
- modelProvider: resolveConversationControlModelProvider({
142
- authProfileId: binding.authProfileId,
143
- bindingModel: binding.model,
144
- bindingModelProvider: binding.modelProvider,
145
- currentModel: model,
146
- ...lookup
147
- }),
148
- authProfileId: binding.authProfileId,
149
- ...lookup
150
- });
151
- const resumed = await resumeThreadWithOverrides({
152
- runtime,
153
- threadId: binding.threadId,
154
- authProfileId: binding.authProfileId,
155
- ...lookup,
156
- model: modelSelection.model,
157
- modelProvider: modelSelection.modelProvider
158
- });
159
- const response = resumed.response;
160
- const nextModel = response.model ?? modelSelection.model;
161
- const nextModelProvider = normalizeCodexAppServerBindingModelProvider({
162
- authProfileId: binding.authProfileId,
163
- modelProvider: response.modelProvider ?? modelSelection.modelProvider,
164
- ...lookup
165
- });
166
- const modelChanged = nextModel !== binding.model || nextModelProvider !== binding.modelProvider;
167
- await patchThreadBinding(params.bindingStore, params.identity, binding.threadId, {
168
- clientId: resumed.clientId,
169
- cwd: response.thread.cwd ?? binding.cwd,
170
- model: nextModel,
171
- modelProvider: nextModelProvider,
172
- ...modelChanged && binding.contextEngine?.projection ? { contextEngine: {
173
- ...binding.contextEngine,
174
- projection: void 0
175
- } } : {},
176
- approvalPolicy: binding.approvalPolicy,
177
- sandbox: binding.sandbox,
178
- serviceTier: binding.serviceTier ?? runtime.serviceTier ?? void 0
179
- });
180
- return `Codex model set to ${formatCodexDisplayText(response.model ?? model)}.`;
181
- }
182
- async function setCodexConversationFastMode(params) {
183
- const binding = await requireThreadBinding(params.bindingStore, params.identity);
184
- if (params.enabled == null) return `Codex fast mode: ${isCodexFastServiceTier(binding.serviceTier) ? "on" : "off"}.`;
185
- const serviceTier = params.enabled ? "priority" : "flex";
186
- await patchThreadBinding(params.bindingStore, params.identity, binding.threadId, { serviceTier });
187
- return `Codex fast mode ${params.enabled ? "enabled" : "disabled"}.`;
188
- }
189
- async function setCodexConversationPermissions(params) {
190
- const binding = await requireThreadBinding(params.bindingStore, params.identity);
191
- if (!params.mode) return `Codex permissions: ${formatPermissionsMode(binding)}.`;
192
- const policy = permissionsForMode(params.mode);
193
- await patchThreadBinding(params.bindingStore, params.identity, binding.threadId, {
194
- approvalPolicy: policy.approvalPolicy,
195
- sandbox: policy.sandbox
196
- });
197
- return `Codex permissions set to ${params.mode === "yolo" ? "full access" : "default"}.`;
198
- }
199
- function parseCodexFastModeArg(arg) {
200
- const normalized = arg?.trim().toLowerCase();
201
- if (!normalized || normalized === "status") return;
202
- if (normalized === "on" || normalized === "true" || normalized === "fast") return true;
203
- if (normalized === "off" || normalized === "false" || normalized === "flex") return false;
204
- }
205
- function parseCodexPermissionsModeArg(arg) {
206
- const normalized = arg?.trim().toLowerCase();
207
- if (!normalized || normalized === "status") return;
208
- if (normalized === "yolo" || normalized === "full" || normalized === "full-access") return "yolo";
209
- if (normalized === "default" || normalized === "guardian") return "default";
210
- }
211
- function formatPermissionsMode(binding) {
212
- return binding.approvalPolicy === "never" && binding.sandbox === "danger-full-access" ? "full access" : "default";
213
- }
214
- async function requireThreadBinding(bindingStore, identity) {
215
- const binding = await bindingStore.read(identity);
216
- if (!binding?.threadId) throw new Error("No Codex thread is attached to this OpenClaw session yet.");
217
- return binding;
218
- }
219
- async function patchThreadBinding(bindingStore, identity, threadId, patch) {
220
- if (!await bindingStore.mutate(identity, {
221
- kind: "patch",
222
- threadId,
223
- patch
224
- })) throw new Error("Codex thread binding changed while applying the control update.");
225
- }
226
- async function resumeThreadWithOverrides(params) {
227
- const runtime = params.runtime;
228
- const clientOptions = {
229
- startOptions: runtime.start,
230
- timeoutMs: runtime.requestTimeoutMs,
231
- authProfileId: params.authProfileId,
232
- ...buildBindingLookup(params)
233
- };
234
- let client = await getLeasedSharedCodexAppServerClient(clientOptions);
235
- const clientLease = { client };
236
- try {
237
- return {
238
- response: await withLeasedCodexAppServerClientStartSelectionRetry({
239
- lease: clientLease,
240
- options: clientOptions,
241
- run: async (requestClient, requestOptions) => await requestClient.request(CODEX_CONTROL_METHODS.resumeThread, {
242
- threadId: params.threadId,
243
- ...params.model ? { model: params.model } : {},
244
- ...params.modelProvider ? { modelProvider: params.modelProvider } : {},
245
- approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,
246
- sandbox: params.sandbox ?? runtime.sandbox,
247
- approvalsReviewer: runtime.approvalsReviewer,
248
- ...params.serviceTier ? { serviceTier: params.serviceTier } : {}
249
- }, requestOptions),
250
- onClientChange: (nextClient) => {
251
- client = nextClient;
252
- }
253
- }),
254
- clientId: client.getInstanceId()
255
- };
256
- } finally {
257
- releaseCodexAppServerClientLease(clientLease);
258
- }
259
- }
260
- function buildBindingLookup(params) {
261
- const agentDir = params.agentDir?.trim();
262
- return {
263
- ...agentDir ? { agentDir } : {},
264
- ...params.config ? { config: params.config } : {}
265
- };
266
- }
267
- function resolveConversationControlModelProvider(params) {
268
- const modelProvider = resolveCodexBindingModelProviderFallback({
269
- currentModel: params.currentModel,
270
- bindingModel: params.bindingModel,
271
- bindingModelProvider: params.bindingModelProvider
272
- })?.trim();
273
- if (!modelProvider || modelProvider.toLowerCase() === "codex") return;
274
- if (isCodexAppServerNativeAuthProfile(params) && modelProvider.toLowerCase() === "openai") return;
275
- return modelProvider.toLowerCase() === "openai" ? "openai" : modelProvider;
276
- }
277
- function permissionsForMode(mode) {
278
- return mode === "yolo" ? {
279
- approvalPolicy: "never",
280
- sandbox: "danger-full-access"
281
- } : {
282
- approvalPolicy: "on-request",
283
- sandbox: "workspace-write"
284
- };
285
- }
286
- //#endregion
287
- export { setCodexConversationFastMode as a, steerCodexConversationTurn as c, CODEX_NATIVE_EXECUTION_AUTH_ERROR as d, canMutateCodexHost as f, readCodexConversationActiveTurn as i, stopCodexConversationTurn as l, parseCodexFastModeArg as n, setCodexConversationModel as o, parseCodexPermissionsModeArg as r, setCodexConversationPermissions as s, formatPermissionsMode as t, trackCodexConversationActiveTurn as u };
@@ -1,86 +0,0 @@
1
- import { W as isJsonObject } from "./shared-client-DTbvH-XV.js";
2
- import { at as readNonNegativeInteger, ct as readString, st as readNumber } from "./thread-lifecycle-DF53ogiA.js";
3
- import { normalizeUsage } from "openclaw/plugin-sdk/agent-harness-runtime";
4
- //#region extensions/codex/src/app-server/event-projector-usage.ts
5
- function readTokenCount(record, key) {
6
- const value = readNonNegativeInteger(record, key);
7
- return value !== void 0 && Number.isSafeInteger(value) ? value : void 0;
8
- }
9
- function readCodexThreadTokenUsage(params) {
10
- const tokenUsage = isJsonObject(params.tokenUsage) ? params.tokenUsage : void 0;
11
- const last = tokenUsage && isJsonObject(tokenUsage.last) ? tokenUsage.last : void 0;
12
- return last ? normalizeCodexThreadTokenUsage(last) : void 0;
13
- }
14
- function readCodexThreadContextSnapshot(params) {
15
- const tokenUsage = isJsonObject(params.tokenUsage) ? params.tokenUsage : void 0;
16
- const last = tokenUsage && isJsonObject(tokenUsage.last) ? tokenUsage.last : void 0;
17
- const modelContextWindow = tokenUsage ? readTokenCount(tokenUsage, "modelContextWindow") : void 0;
18
- const promptTokens = last ? readTokenCount(last, "inputTokens") : void 0;
19
- return {
20
- ...modelContextWindow && modelContextWindow > 0 ? { modelContextWindow } : {},
21
- ...promptTokens !== void 0 ? { promptTokens } : {}
22
- };
23
- }
24
- function projectCodexThreadUsageUpdate(params, currentUsage, applyUsage, emitContext) {
25
- applyUsage(readCodexThreadTokenUsage(params) ?? currentUsage);
26
- const context = readCodexThreadContextSnapshot(params);
27
- if (context.modelContextWindow !== void 0 || context.promptTokens !== void 0) emitContext(context);
28
- }
29
- function normalizeCodexThreadTokenUsage(record) {
30
- const inputTokens = readNumber(record, "inputTokens");
31
- const cacheRead = readNumber(record, "cachedInputTokens");
32
- const usage = normalizeUsage({
33
- input: inputTokens !== void 0 && cacheRead !== void 0 ? Math.max(0, inputTokens - cacheRead) : inputTokens,
34
- output: readNumber(record, "outputTokens"),
35
- cacheRead,
36
- total: readNumber(record, "totalTokens")
37
- });
38
- return usage ? {
39
- ...usage,
40
- contextUsage: { state: "unavailable" }
41
- } : void 0;
42
- }
43
- function normalizeCodexResponseTokenUsage(record) {
44
- const totalTokens = readTokenCount(record, "totalTokens");
45
- const inputTokens = readTokenCount(record, "inputTokens");
46
- const cacheRead = readTokenCount(record, "cachedInputTokens");
47
- const output = readTokenCount(record, "outputTokens");
48
- const reasoningOutput = readTokenCount(record, "reasoningOutputTokens");
49
- const cacheWrite = record.cacheWriteInputTokens === void 0 ? 0 : readTokenCount(record, "cacheWriteInputTokens");
50
- if (totalTokens === void 0 || inputTokens === void 0 || cacheRead === void 0 || cacheWrite === void 0 || output === void 0 || reasoningOutput === void 0 || cacheRead + cacheWrite > inputTokens || totalTokens !== inputTokens + output) return;
51
- const usage = normalizeUsage({
52
- input: inputTokens - cacheRead - cacheWrite,
53
- output,
54
- cacheRead,
55
- cacheWrite,
56
- total: totalTokens
57
- });
58
- if (!usage) return;
59
- return {
60
- ...usage,
61
- contextUsage: {
62
- state: "available",
63
- promptTokens: inputTokens,
64
- totalTokens
65
- }
66
- };
67
- }
68
- var CodexResponseCompletionProjection = class {
69
- constructor() {
70
- this.responseIds = /* @__PURE__ */ new Set();
71
- }
72
- get modelIterations() {
73
- return this.responseIds.size;
74
- }
75
- clear() {
76
- this.usage = void 0;
77
- }
78
- record(params) {
79
- const responseId = readString(params, "responseId");
80
- if (responseId) this.responseIds.add(responseId);
81
- const usage = isJsonObject(params.usage) ? params.usage : void 0;
82
- this.usage = usage ? normalizeCodexResponseTokenUsage(usage) : void 0;
83
- }
84
- };
85
- //#endregion
86
- export { normalizeCodexResponseTokenUsage as n, projectCodexThreadUsageUpdate as r, CodexResponseCompletionProjection as t };