@openclaw/codex 2026.7.2-beta.7 → 2026.7.34

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 (64) hide show
  1. package/README.md +3 -27
  2. package/dist/{command-formatters-C336eRVS.js → .setup/app-server-policy-C_qTMEMy.mjs} +51 -9
  3. package/dist/{attempt-notifications-AP-a-Q5k.js → .setup/attempt-notifications-F8krwWL4.mjs} +6 -3
  4. package/dist/{command-handlers-DAHUSry9.js → .setup/command-handlers-DSRFfor4.mjs} +1156 -1319
  5. package/dist/.setup/command-rpc-BvYsfQ7G.mjs +786 -0
  6. package/dist/{compact-D_uvHurS.js → .setup/compact-BNgh7I4t.mjs} +10 -40
  7. package/dist/.setup/computer-use-C3QkmSO3.mjs +377 -0
  8. package/dist/.setup/config-CYEDnLJ2.mjs +1138 -0
  9. package/dist/{conversation-binding-data-BHRpYbX3.js → .setup/conversation-binding-data-CrRxtDBu.mjs} +1 -1
  10. package/dist/{bounded-turn-D2ZAgZVz.js → .setup/media-understanding-provider-EbJCyDqe.mjs} +203 -109
  11. package/dist/{models-BBMKU4jA.js → .setup/models-C_aZk03A.mjs} +11 -6
  12. package/dist/.setup/notification-correlation-iYs4WieS.mjs +35 -0
  13. package/dist/.setup/plugin-app-cache-key-DR8jV9oS.mjs +99 -0
  14. package/dist/.setup/protocol-2POPqAY4.mjs +13 -0
  15. package/dist/{transcript-mirror-DzsdNCf5.js → .setup/protocol-validators-dZQ-UTOa.mjs} +112 -922
  16. package/dist/{rate-limits-CU-gVCCS.js → .setup/provider-DGxDs6g8.mjs} +269 -13
  17. package/dist/{dynamic-tools-D2gYkSBO.js → .setup/provider-capabilities-DS2N_zc1.mjs} +5632 -3953
  18. package/dist/.setup/request-DFR0JyoV.mjs +36 -0
  19. package/dist/.setup/run-attempt-C7xEKFVB.mjs +8180 -0
  20. package/dist/{sandbox-guard-NuhpXmPB.js → .setup/sandbox-guard-DA2TQfZW.mjs} +1 -14
  21. package/dist/.setup/session-binding-DuihlMJc.mjs +628 -0
  22. package/dist/.setup/shared-client-B2KmLPRw.mjs +1854 -0
  23. package/dist/{side-question-_ulBk1AL.js → .setup/side-question-Cv6JXWCS.mjs} +84 -159
  24. package/dist/.setup/thread-lifecycle-u6CZdOOH.mjs +2593 -0
  25. package/dist/{web-search-provider.runtime-CCFhg2z5.js → .setup/web-search-provider.runtime-Ce2zOHxW.mjs} +3 -3
  26. package/dist/doctor-contract-api.js +122 -88
  27. package/dist/harness.js +20 -89
  28. package/dist/index.js +436 -1615
  29. package/dist/media-understanding-provider.js +1 -173
  30. package/dist/prompt-overlay.js +15 -0
  31. package/dist/provider-catalog.js +79 -0
  32. package/dist/provider-discovery.js +34 -0
  33. package/dist/provider.js +2 -0
  34. package/dist/web-search-contract-api.js +1 -1
  35. package/openclaw.plugin.json +178 -221
  36. package/package.json +8 -9
  37. package/dist/app-server-policy-BSaO2JIT.js +0 -49
  38. package/dist/auth-binding-B4FfbcCg.js +0 -62
  39. package/dist/capabilities-BFDTVYr4.js +0 -36
  40. package/dist/cli-metadata.js +0 -20
  41. package/dist/computer-use-CYEc8U3w.js +0 -693
  42. package/dist/conversation-control-xsIeXbo4.js +0 -287
  43. package/dist/effective-mcp-catalog-Bbd98Inw.js +0 -114
  44. package/dist/event-projector-assistant-message-DTgnPPVF.js +0 -101
  45. package/dist/event-projector-usage-Xp4AlR2k.js +0 -86
  46. package/dist/incognito-session-ET_ufDH-.js +0 -2
  47. package/dist/notification-correlation-CU6_AnOb.js +0 -67
  48. package/dist/plugin-app-cache-key-DztPafOA.js +0 -408
  49. package/dist/request-qKh331yu.js +0 -157
  50. package/dist/run-attempt-CY9WlDLc.js +0 -12413
  51. package/dist/runtime-artifact-CmtG_t1L.js +0 -554
  52. package/dist/session-binding-BXpo9ymA.js +0 -2214
  53. package/dist/session-catalog-DyOgR4WH.js +0 -2668
  54. package/dist/session-cli-2PZaFLRh.js +0 -175
  55. package/dist/session-upstream-marker-B6U7tLw5.js +0 -82
  56. package/dist/settled-turn-finalizer-CXY2Z9dT.js +0 -316
  57. package/dist/shared-client-DTbvH-XV.js +0 -3069
  58. package/dist/thread-lifecycle-DF53ogiA.js +0 -3987
  59. package/dist/transport-stdio-DXgGZ7Ib.js +0 -88
  60. package/dist/upstream-session-fork-Dy4Xvuoj.js +0 -320
  61. package/dist/usage-CQ6GhD5-.js +0 -25
  62. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  63. /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
  64. /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
@@ -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,114 +0,0 @@
1
- import { d as retainSharedCodexAppServerClientByInstanceId } from "./shared-client-DTbvH-XV.js";
2
- import { d as sessionBindingIdentity } from "./session-binding-BXpo9ymA.js";
3
- import { assignMcpCatalogSafeServerNames } from "openclaw/plugin-sdk/agent-harness-runtime";
4
- //#region extensions/codex/src/app-server/effective-mcp-catalog.ts
5
- const MCP_STATUS_PAGE_SIZE = 100;
6
- const MCP_STATUS_MAX_PAGES = 100;
7
- function asRecord(value) {
8
- return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
9
- }
10
- function readString(value) {
11
- return typeof value === "string" && value.trim() ? value.trim() : void 0;
12
- }
13
- function catalogTool(params) {
14
- const raw = asRecord(params.raw);
15
- const description = readString(raw?.description);
16
- return {
17
- serverName: params.serverName,
18
- safeServerName: params.safeServerName,
19
- toolName: params.toolName,
20
- ...readString(raw?.title) ? { title: readString(raw?.title) } : {},
21
- ...description ? { description } : {},
22
- inputSchema: asRecord(raw?.inputSchema) ?? { type: "object" },
23
- fallbackDescription: description ?? params.toolName,
24
- ...params.deniedBySession ? { deniedBySession: true } : {}
25
- };
26
- }
27
- /** Converts Codex's thread-scoped status response into OpenClaw's MCP catalog shape. */
28
- function buildCodexEffectiveMcpCatalog(statuses, toolOverrides) {
29
- const orderedStatuses = [...new Map(statuses.map((status) => [status.name, status])).values()].toSorted((left, right) => left.name.localeCompare(right.name));
30
- const safeNames = assignMcpCatalogSafeServerNames(orderedStatuses.map((status) => status.name));
31
- const serverEntries = [];
32
- const tools = [];
33
- const sessionDeniedTools = [];
34
- for (const status of orderedStatuses) {
35
- const safeServerName = safeNames.get(status.name) ?? status.name;
36
- const denialMap = toolOverrides?.mcpToolsDeny;
37
- const deniedNames = new Set(denialMap && Object.hasOwn(denialMap, status.name) ? denialMap[status.name] : []);
38
- const observedNames = /* @__PURE__ */ new Set();
39
- for (const [toolName, raw] of Object.entries(status.tools).toSorted(([left], [right]) => left.localeCompare(right))) {
40
- observedNames.add(toolName);
41
- const deniedBySession = deniedNames.has(toolName) ? true : void 0;
42
- const tool = catalogTool({
43
- serverName: status.name,
44
- safeServerName,
45
- toolName,
46
- raw,
47
- ...deniedBySession ? { deniedBySession } : {}
48
- });
49
- if (deniedBySession) sessionDeniedTools.push(tool);
50
- else tools.push(tool);
51
- }
52
- for (const toolName of [...deniedNames].toSorted()) {
53
- if (observedNames.has(toolName)) continue;
54
- sessionDeniedTools.push(catalogTool({
55
- serverName: status.name,
56
- safeServerName,
57
- toolName,
58
- deniedBySession: true
59
- }));
60
- }
61
- serverEntries.push([status.name, {
62
- serverName: status.name,
63
- safeServerName,
64
- launchSummary: "Codex native MCP connection",
65
- toolCount: observedNames.size + [...deniedNames].filter((name) => !observedNames.has(name)).length
66
- }]);
67
- }
68
- return {
69
- version: 1,
70
- generatedAt: Date.now(),
71
- servers: Object.fromEntries(serverEntries),
72
- tools,
73
- ...sessionDeniedTools.length > 0 ? { sessionDeniedTools } : {}
74
- };
75
- }
76
- async function listCodexMcpServerStatuses(client, threadId) {
77
- const statuses = [];
78
- const seenCursors = /* @__PURE__ */ new Set();
79
- let cursor;
80
- for (let page = 0; page < MCP_STATUS_MAX_PAGES; page += 1) {
81
- const response = await client.request("mcpServerStatus/list", {
82
- threadId,
83
- detail: "toolsAndAuthOnly",
84
- limit: MCP_STATUS_PAGE_SIZE,
85
- ...cursor ? { cursor } : {}
86
- });
87
- statuses.push(...response.data);
88
- cursor = response.nextCursor;
89
- if (!cursor) return statuses;
90
- if (seenCursors.has(cursor)) throw new Error("Codex mcpServerStatus/list repeated its pagination cursor");
91
- seenCursors.add(cursor);
92
- }
93
- throw new Error("Codex mcpServerStatus/list exceeded the bounded page limit");
94
- }
95
- /** Loads MCP inventory only from the already-bound Codex process and thread. */
96
- async function loadCodexEffectiveMcpCatalog(params, options) {
97
- const binding = await options.bindingStore.read(sessionBindingIdentity({
98
- agentId: params.agentId,
99
- sessionId: params.sessionId,
100
- sessionKey: params.sessionKey,
101
- config: params.config
102
- }));
103
- if (!binding?.clientId) return;
104
- const retained = retainSharedCodexAppServerClientByInstanceId(binding.clientId);
105
- if (!retained) return;
106
- try {
107
- const allowedServerNames = new Set(params.mcpServerNames);
108
- return buildCodexEffectiveMcpCatalog((await listCodexMcpServerStatuses(retained.client, binding.threadId)).filter((status) => allowedServerNames.has(status.name)), params.toolOverrides);
109
- } finally {
110
- retained.release();
111
- }
112
- }
113
- //#endregion
114
- export { loadCodexEffectiveMcpCatalog };
@@ -1,101 +0,0 @@
1
- import { formatErrorMessage } from "openclaw/plugin-sdk/agent-harness-runtime";
2
- //#region extensions/codex/src/app-server/local-runtime-attribution.ts
3
- const OPENAI_PROVIDER_ID = "openai";
4
- const OPENAI_RESPONSES_API = "openai-responses";
5
- const OPENAI_CODEX_RESPONSES_API = "openai-chatgpt-responses";
6
- function normalizeRuntimeId(value) {
7
- return value?.trim().toLowerCase() ?? "";
8
- }
9
- /** Maps local Codex runtime plans onto the provider/api pair exposed to event projection. */
10
- function resolveCodexLocalRuntimeAttribution(params) {
11
- const authProfileProvider = normalizeRuntimeId(params.runtimePlan?.auth?.authProfileProviderForAuth);
12
- if (normalizeRuntimeId(params.runtimePlan?.observability.harnessId) === "codex" && authProfileProvider !== OPENAI_PROVIDER_ID && normalizeRuntimeId(params.model.provider) === OPENAI_PROVIDER_ID && normalizeRuntimeId(params.model.api) === OPENAI_RESPONSES_API) return {
13
- provider: OPENAI_PROVIDER_ID,
14
- api: OPENAI_CODEX_RESPONSES_API
15
- };
16
- return {
17
- provider: params.provider,
18
- api: params.model.api
19
- };
20
- }
21
- //#endregion
22
- //#region extensions/codex/src/app-server/event-projector-assistant-message.ts
23
- const ZERO_USAGE = {
24
- input: 0,
25
- output: 0,
26
- cacheRead: 0,
27
- cacheWrite: 0,
28
- totalTokens: 0,
29
- cost: {
30
- input: 0,
31
- output: 0,
32
- cacheRead: 0,
33
- cacheWrite: 0,
34
- total: 0
35
- }
36
- };
37
- function createAssistantMessage(params, text, options) {
38
- const attribution = resolveCodexLocalRuntimeAttribution(params);
39
- const usage = options.tokenUsage ? {
40
- input: options.tokenUsage.input ?? 0,
41
- output: options.tokenUsage.output ?? 0,
42
- cacheRead: options.tokenUsage.cacheRead ?? 0,
43
- cacheWrite: options.tokenUsage.cacheWrite ?? 0,
44
- ...options.tokenUsage.contextUsage ? { contextUsage: options.tokenUsage.contextUsage } : {},
45
- totalTokens: options.tokenUsage.total ?? (options.tokenUsage.input ?? 0) + (options.tokenUsage.output ?? 0) + (options.tokenUsage.cacheRead ?? 0) + (options.tokenUsage.cacheWrite ?? 0),
46
- cost: ZERO_USAGE.cost
47
- } : ZERO_USAGE;
48
- return {
49
- role: "assistant",
50
- content: [{
51
- type: "text",
52
- text
53
- }],
54
- api: attribution.api ?? "openai-chatgpt-responses",
55
- provider: attribution.provider,
56
- model: params.modelId,
57
- usage,
58
- stopReason: options.aborted ? "aborted" : options.promptError ? "error" : "stop",
59
- errorMessage: options.promptError ? formatErrorMessage(options.promptError) : void 0,
60
- timestamp: Date.now()
61
- };
62
- }
63
- function createAssistantCommentaryMessage(params, text, itemId, timestamp) {
64
- const attribution = resolveCodexLocalRuntimeAttribution(params);
65
- return {
66
- role: "assistant",
67
- content: [{
68
- type: "text",
69
- text
70
- }],
71
- api: attribution.api ?? "openai-chatgpt-responses",
72
- provider: attribution.provider,
73
- model: params.modelId,
74
- usage: ZERO_USAGE,
75
- stopReason: "stop",
76
- timestamp,
77
- openclawStreamFallback: {
78
- replacementText: text,
79
- source: "segment",
80
- itemId
81
- }
82
- };
83
- }
84
- function createAssistantMirrorMessage(params, title, text) {
85
- const attribution = resolveCodexLocalRuntimeAttribution(params);
86
- return {
87
- role: "assistant",
88
- content: [{
89
- type: "text",
90
- text: `${title}:\n${text}`
91
- }],
92
- api: attribution.api ?? "openai-chatgpt-responses",
93
- provider: attribution.provider,
94
- model: params.modelId,
95
- usage: ZERO_USAGE,
96
- stopReason: "stop",
97
- timestamp: Date.now()
98
- };
99
- }
100
- //#endregion
101
- export { resolveCodexLocalRuntimeAttribution as i, createAssistantMessage as n, createAssistantMirrorMessage as r, createAssistantCommentaryMessage as t };
@@ -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 };
@@ -1,2 +0,0 @@
1
- import { isIncognitoSessionKey } from "openclaw/plugin-sdk/routing";
2
- export { isIncognitoSessionKey as t };
@@ -1,67 +0,0 @@
1
- import { W as isJsonObject } from "./shared-client-DTbvH-XV.js";
2
- import { O as readCodexPluginConfig, g as resolveCodexAppServerRuntimeOptions, y as resolveCodexSupervisionAppServerRuntimeOptions } from "./session-binding-BXpo9ymA.js";
3
- import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-DztPafOA.js";
4
- //#region extensions/codex/src/app-server/binding-connection.ts
5
- /** Requires the native model pair after a supervised pending branch has materialized. */
6
- function requireCodexSupervisionModelSelection(binding) {
7
- const model = binding.model?.trim();
8
- const modelProvider = binding.modelProvider?.trim();
9
- if (binding.connectionScope !== "supervision" || !model || !modelProvider) throw new Error("Codex supervised binding is missing its native model and provider; refusing request selection");
10
- return {
11
- model,
12
- modelProvider
13
- };
14
- }
15
- /** Resolves connection and auth ownership exclusively from the private thread binding. */
16
- function resolveCodexBindingAppServerConnection(params) {
17
- const { binding, authProfileId, ...runtimeParams } = params;
18
- const usesSupervisionConnection = binding?.connectionScope === "supervision";
19
- if (usesSupervisionConnection && readCodexPluginConfig(runtimeParams.pluginConfig).supervision?.enabled !== true) throw new Error("Codex supervision is disabled; refusing to open a native user-home supervised session");
20
- const appServer = (usesSupervisionConnection ? resolveCodexSupervisionAppServerRuntimeOptions : resolveCodexAppServerRuntimeOptions)(runtimeParams);
21
- if (usesSupervisionConnection) {
22
- const persistedFingerprint = binding.pendingSupervisionBranch?.connectionFingerprint ?? binding.appServerRuntimeFingerprint;
23
- const currentFingerprint = buildCodexAppServerConnectionFingerprint(appServer, runtimeParams.agentDir);
24
- if (!persistedFingerprint || persistedFingerprint !== currentFingerprint) throw new Error("Codex supervision connection changed; refusing to operate on its bound native thread");
25
- }
26
- return {
27
- appServer,
28
- usesSupervisionConnection,
29
- requestAuthProfileId: usesSupervisionConnection ? void 0 : authProfileId,
30
- clientAuthProfileId: usesSupervisionConnection ? null : authProfileId
31
- };
32
- }
33
- //#endregion
34
- //#region extensions/codex/src/app-server/notification-correlation.ts
35
- /**
36
- * Correlates Codex app-server notifications with the active thread/turn so
37
- * projectors can ignore global or stale events without losing diagnostics.
38
- */
39
- /** Returns true when a notification payload belongs to the exact active thread and turn. */
40
- function isCodexNotificationForTurn(value, threadId, turnId) {
41
- if (!isJsonObject(value)) return false;
42
- return readCodexNotificationThreadId(value) === threadId && readCodexNotificationTurnId(value) === turnId;
43
- }
44
- /**
45
- * Reads a thread id from canonical top-level or nested thread payloads.
46
- * The generated v2 schemas require top-level `threadId` on turn/item-scoped
47
- * notifications and define `Turn` without one, so `turn.threadId` is not a
48
- * wire shape and is deliberately not read here.
49
- */
50
- function readCodexNotificationThreadId(record) {
51
- const thread = isJsonObject(record.thread) ? record.thread : void 0;
52
- return readString(record, "threadId") ?? (thread ? readString(thread, "id") : void 0);
53
- }
54
- /** Reads a turn id from either top-level notification params or nested turn payloads. */
55
- function readCodexNotificationTurnId(record) {
56
- return readNestedTurnId(record) ?? readString(record, "turnId");
57
- }
58
- function readNestedTurnId(record) {
59
- const turn = record.turn;
60
- return isJsonObject(turn) ? readString(turn, "id") : void 0;
61
- }
62
- function readString(record, key) {
63
- const value = record[key];
64
- return typeof value === "string" && value.trim() ? value.trim() : void 0;
65
- }
66
- //#endregion
67
- export { resolveCodexBindingAppServerConnection as a, requireCodexSupervisionModelSelection as i, readCodexNotificationThreadId as n, readCodexNotificationTurnId as r, isCodexNotificationForTurn as t };