@openclaw/codex 2026.7.2-beta.5 → 2026.7.33

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 (66) hide show
  1. package/README.md +3 -27
  2. package/dist/{command-formatters-ico4ZFnk.js → .setup/app-server-policy-C_qTMEMy.mjs} +51 -9
  3. package/dist/{attempt-notifications-CMR2_fmR.js → .setup/attempt-notifications-F8krwWL4.mjs} +6 -3
  4. package/dist/{command-handlers-CRmnwI2N.js → .setup/command-handlers-DSRFfor4.mjs} +1156 -1319
  5. package/dist/.setup/command-rpc-BvYsfQ7G.mjs +786 -0
  6. package/dist/{compact-dEN49UH6.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-FEbUXoYT.js → .setup/media-understanding-provider-EbJCyDqe.mjs} +193 -92
  11. package/dist/{models-BA01NEez.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/{protocol-validators-Dm4eXZmt.js → .setup/protocol-validators-dZQ-UTOa.mjs} +111 -334
  16. package/dist/{rate-limits-S_PXs0ul.js → .setup/provider-DGxDs6g8.mjs} +269 -13
  17. package/dist/{dynamic-tools-LIt9ojep.js → .setup/provider-capabilities-DS2N_zc1.mjs} +5465 -3399
  18. package/dist/.setup/request-DFR0JyoV.mjs +36 -0
  19. package/dist/.setup/run-attempt-C7xEKFVB.mjs +8180 -0
  20. package/dist/{sandbox-guard-D1Wky__S.js → .setup/sandbox-guard-DA2TQfZW.mjs} +1 -10
  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-CO12sHxo.js → .setup/side-question-Cv6JXWCS.mjs} +84 -159
  24. package/dist/{thread-lifecycle-DRg_FdzC.js → .setup/thread-lifecycle-u6CZdOOH.mjs} +1159 -1799
  25. package/dist/{web-search-provider.runtime-CaQMYDbp.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 -85
  28. package/dist/index.js +381 -1537
  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 -10
  37. package/dist/app-server-policy-BmDgseo_.js +0 -49
  38. package/dist/attempt-client-cleanup-Ia52yRWc.js +0 -127
  39. package/dist/auth-binding-B4FfbcCg.js +0 -62
  40. package/dist/capabilities-BHRSI6Cn.js +0 -36
  41. package/dist/cli-metadata.js +0 -20
  42. package/dist/computer-use-BjGylO-E.js +0 -695
  43. package/dist/conversation-control-DE7d9DOj.js +0 -287
  44. package/dist/event-projector-assistant-message-DTgnPPVF.js +0 -101
  45. package/dist/event-projector-usage-tvgb1NCX.js +0 -69
  46. package/dist/incognito-session-ET_ufDH-.js +0 -2
  47. package/dist/notification-correlation-Bj_Ak_jI.js +0 -67
  48. package/dist/plugin-app-cache-key-DSXX-rXO.js +0 -315
  49. package/dist/realtime-voice-api-BPcA1uN9.js +0 -494
  50. package/dist/realtime-voice-api.js +0 -2
  51. package/dist/request-CXpPennK.js +0 -157
  52. package/dist/run-attempt-C5GTPJOE.js +0 -11935
  53. package/dist/runtime-artifact-C2ITXdhM.js +0 -488
  54. package/dist/session-binding-DlVQ-Pxs.js +0 -2161
  55. package/dist/session-catalog-CP2oCcEb.js +0 -2444
  56. package/dist/session-cli-CqZ0Fp2a.js +0 -175
  57. package/dist/session-upstream-marker-QE-m5QFG.js +0 -82
  58. package/dist/settled-turn-finalizer-CA_2QXIE.js +0 -303
  59. package/dist/shared-client-BVKE40c-.js +0 -2952
  60. package/dist/transcript-mirror-uKA-A4tB.js +0 -550
  61. package/dist/transport-stdio-DXgGZ7Ib.js +0 -88
  62. package/dist/upstream-session-fork-_Vrz4WJr.js +0 -320
  63. package/dist/usage-UpVbdX5G.js +0 -25
  64. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  65. /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
  66. /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, l as releaseLeasedSharedCodexAppServerClient, m as withLeasedCodexAppServerClientStartSelectionRetry } from "./shared-client-BVKE40c-.js";
2
- import { O as isCodexFastServiceTier, S as resolveCodexModelBackedReviewerPolicyContext, o as isCodexAppServerNativeAuthProfile, p as resolveCodexAppServerRuntimeOptions, r as bindingStoreKey, s as normalizeCodexAppServerBindingModelProvider } from "./session-binding-DlVQ-Pxs.js";
3
- import { x as resolveCodexBindingModelProviderFallback, y as resolveCodexAppServerRequestModelSelection } from "./thread-lifecycle-DRg_FdzC.js";
4
- import { t as CODEX_CONTROL_METHODS } from "./capabilities-BHRSI6Cn.js";
5
- import { r as formatCodexDisplayText } from "./command-formatters-ico4ZFnk.js";
6
- import { a as resolveCodexBindingAppServerConnection } from "./notification-correlation-Bj_Ak_jI.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,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,69 +0,0 @@
1
- import { V as isJsonObject } from "./shared-client-BVKE40c-.js";
2
- import { it as readNonNegativeInteger, ot as readNumber } from "./thread-lifecycle-DRg_FdzC.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
- //#endregion
69
- export { projectCodexThreadUsageUpdate as n, normalizeCodexResponseTokenUsage 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 { V as isJsonObject } from "./shared-client-BVKE40c-.js";
2
- import { T as readCodexPluginConfig, g as resolveCodexSupervisionAppServerRuntimeOptions, p as resolveCodexAppServerRuntimeOptions } from "./session-binding-DlVQ-Pxs.js";
3
- import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-DSXX-rXO.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 };