@openclaw/codex 2026.9.2 → 2026.9.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 (108) hide show
  1. package/README.md +2 -0
  2. package/dist/api.js +14 -19
  3. package/dist/apply-B6el6hdO.js +357 -0
  4. package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-D6cR54TV.js} +39 -19
  5. package/dist/{attempt-context-CSazkWns.js → attempt-context-AO4DSjE0.js} +8 -6
  6. package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications--H8zXR5-.js} +3 -106
  7. package/dist/auth-cache-key-Kq6oerr6.js +498 -0
  8. package/dist/auth-profile-CwzO4_RG.js +43 -0
  9. package/dist/auth-profile-selection-DFu9e167.js +45 -0
  10. package/dist/binding-connection-QqgcPCgk.js +60 -0
  11. package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-lRpmZHFv.js} +25 -122
  12. package/dist/build-state-6RL6qohz.js +19 -0
  13. package/dist/{capabilities-B1mgvpP8.js → capabilities-BeqLPbtM.js} +1 -1
  14. package/dist/cli-metadata.js +1 -1
  15. package/dist/client-BEKu4yDx.js +3983 -0
  16. package/dist/command-dispatch-CisT9Jqq.js +21 -0
  17. package/dist/{command-formatters-DSbGMXA0.js → command-formatters-DeTfrapr.js} +2 -2
  18. package/dist/{command-handlers-DOJvGv6-.js → command-handlers-BfIsJEuA.js} +31 -21
  19. package/dist/command-rpc-BMqRQOFX.js +226 -0
  20. package/dist/{compact-Y_xBqrHN.js → compact-CGJZ2rlb.js} +19 -14
  21. package/dist/config-JDfTI4VI.js +106 -0
  22. package/dist/{config-CyapYSji.js → config-options-jnIFvwxD.js} +204 -592
  23. package/dist/config-runtime-BWf6JLWG.js +11 -0
  24. package/dist/conversation-binding-CxOlHiix.js +889 -0
  25. package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CUCrSIQI.js} +10 -142
  26. package/dist/doctor-contract-api.js +5 -5
  27. package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-D-JBoaLt.js} +66 -70
  28. package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-J_5Ep5Um.js} +3 -3
  29. package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
  30. package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
  31. package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
  32. package/dist/event-projector-usage-CIyrYYid.js +102 -0
  33. package/dist/{harness-Czh2Sdoc.js → harness-FR6eQgyO.js} +31 -24
  34. package/dist/harness.js +1 -1
  35. package/dist/history-rejection-B4nOXNXF.js +13 -0
  36. package/dist/incognito-session-uhrBF6wJ.js +15 -0
  37. package/dist/index.js +411 -2875
  38. package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DHBefrzg.js} +7 -4
  39. package/dist/launch-args-RXQwn8zV.js +90 -0
  40. package/dist/{managed-binary-DcpnJF9x.js → managed-binary-DrjjRRUD.js} +4 -103
  41. package/dist/managed-thread-store-D1t5jh3G.js +66 -0
  42. package/dist/media-understanding-provider.js +4 -1
  43. package/dist/{model-catalog-DT5vo6qo.js → model-catalog-B_6M04Wo.js} +6 -5
  44. package/dist/{models-CcrgSMQR.js → models-P9k2qAof.js} +3 -3
  45. package/dist/native-execution-policy-umd0tgh4.js +128 -0
  46. package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-BbCUKRwC.js} +69 -42
  47. package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
  48. package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-BY_ctYnT.js} +53 -22
  49. package/dist/plan-BMJdMOEF.js +711 -0
  50. package/dist/plugin-activation-BQK-f5sV.js +133 -0
  51. package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-CdSQzWyX.js} +4 -52
  52. package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
  53. package/dist/plugin-inventory-CoRCzWW4.js +325 -0
  54. package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
  55. package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
  56. package/dist/protocol-CAAcVIKF.js +275 -0
  57. package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-W4tfK5Y5.js} +2 -2
  58. package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-Bqnx1N4z.js} +1 -1
  59. package/dist/request-CGvGOpeR.js +198 -0
  60. package/dist/{run-attempt-BzthFQSM.js → run-attempt-DwKds3DN.js} +589 -373
  61. package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-T-NwqeSH.js} +27 -27
  62. package/dist/sandbox-guard-BcT66fWy.js +165 -0
  63. package/dist/{session-binding-4Ki04sW-.js → session-binding-CKSepwIC.js} +29 -47
  64. package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-CaZjYwNS.js} +11 -25
  65. package/dist/session-catalog-HaDcp7Sv.js +1533 -0
  66. package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
  67. package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
  68. package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
  69. package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
  70. package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
  71. package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
  72. package/dist/session-catalog-provenance-DkJHo735.js +124 -0
  73. package/dist/{session-cli-BjLhpmS1.js → session-cli-CbgaHh0f.js} +3 -2
  74. package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
  75. package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DFN7sWRU.js} +5 -50
  76. package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
  77. package/dist/session-history-worker-runtime.js +18 -6
  78. package/dist/{session-history.worker-zZVcx0ME.js → session-history.worker-CNEvGaU5.js} +58 -51
  79. package/dist/session-history.worker.js +1 -1
  80. package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Jo86C60I.js} +2 -2
  81. package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-B22InTp_.js} +4 -7
  82. package/dist/{session-retirement-DNdmYdFc.js → session-retirement-BSNG_mhf.js} +6 -5
  83. package/dist/session-upstream-marker-D15C9NHp.js +46 -0
  84. package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
  85. package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-BuLUrZl2.js} +7 -6
  86. package/dist/shared-client-CVhez2Uo.js +2911 -0
  87. package/dist/{side-question-B6DWAw1A.js → side-question-DLbr2vUU.js} +64 -169
  88. package/dist/source-Da-h6f7e.js +518 -0
  89. package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
  90. package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-D1pzRwHB.js} +112 -616
  91. package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-D6oASVRu.js} +13 -15
  92. package/dist/thread-policy-D8kI7yAO.js +54 -0
  93. package/dist/thread-resume-T5cveyxA.js +52 -0
  94. package/dist/timeout-BVw8aaM1.js +33 -0
  95. package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
  96. package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-t5TOccct.js} +50 -260
  97. package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
  98. package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-De-sLJ2r.js} +26 -18
  99. package/dist/{usage-i9fv5-4m.js → usage-CPPTmBvZ.js} +4 -3
  100. package/dist/version-omm6IPI3.js +12 -0
  101. package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
  102. package/openclaw.plugin.json +22 -1
  103. package/package.json +4 -4
  104. package/dist/request-C8H22rPi.js +0 -475
  105. package/dist/session-catalog-B47uwekb.js +0 -3272
  106. package/dist/shared-client-CKhX2kFt.js +0 -7505
  107. package/dist/thread-policy-CTalhWFy.js +0 -105
  108. package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
@@ -0,0 +1,45 @@
1
+ import { resolveDefaultAgentDir } from "openclaw/plugin-sdk/agent-harness-registration";
2
+ //#region extensions/codex/src/app-server/auth-profile-selection.ts
3
+ const CODEX_APP_SERVER_AUTH_PROVIDER = "openai";
4
+ const CODEX_APP_SERVER_EXTERNAL_CLI_PROVIDER_IDS = [CODEX_APP_SERVER_AUTH_PROVIDER];
5
+ function createCodexAuthProfileSelection({ ensureAuthProfileStore, resolveAuthProfileOrder }) {
6
+ function resolveCodexAppServerAuthProfileId(params) {
7
+ const requested = params.authProfileId?.trim();
8
+ if (requested) return requested;
9
+ return resolveAuthProfileOrder({
10
+ cfg: params.config,
11
+ store: params.store,
12
+ provider: CODEX_APP_SERVER_AUTH_PROVIDER
13
+ })[0]?.trim();
14
+ }
15
+ function resolveCodexAppServerAuthProfileIdForAgent(params) {
16
+ const store = resolveCodexAppServerAuthProfileStore({
17
+ agentDir: params.agentDir?.trim() || resolveDefaultAgentDir(params.config ?? {}),
18
+ authProfileId: params.authProfileId,
19
+ authProfileStore: params.authProfileStore,
20
+ config: params.config
21
+ });
22
+ return resolveCodexAppServerAuthProfileId({
23
+ authProfileId: params.authProfileId,
24
+ store,
25
+ config: params.config
26
+ });
27
+ }
28
+ function resolveCodexAppServerAuthProfileStore(params) {
29
+ if (params.authProfileStore) return params.authProfileStore;
30
+ return ensureAuthProfileStore(params.agentDir, {
31
+ profileId: params.authProfileId,
32
+ allowKeychainPrompt: false,
33
+ config: params.config,
34
+ externalCliProviderIds: CODEX_APP_SERVER_EXTERNAL_CLI_PROVIDER_IDS,
35
+ ...params.authProfileId ? { externalCliProfileIds: [params.authProfileId] } : {}
36
+ });
37
+ }
38
+ return {
39
+ resolveCodexAppServerAuthProfileId,
40
+ resolveCodexAppServerAuthProfileIdForAgent,
41
+ resolveCodexAppServerAuthProfileStore
42
+ };
43
+ }
44
+ //#endregion
45
+ export { createCodexAuthProfileSelection as n, CODEX_APP_SERVER_AUTH_PROVIDER as t };
@@ -0,0 +1,60 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { x as readCodexPluginConfig } from "./protocol-CAAcVIKF.js";
3
+ import { a as resolveCodexCatalogConnectionHome, t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-CdSQzWyX.js";
4
+ import { n as resolveCodexAppServerRuntimeOptions, r as resolveCodexSupervisionAppServerRuntimeOptions } from "./config-runtime-BWf6JLWG.js";
5
+ import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-registration";
6
+ //#region extensions/codex/src/app-server/binding-connection.ts
7
+ var binding_connection_exports = /* @__PURE__ */ __exportAll({
8
+ assertCodexSessionRuntimeOwnership: () => assertCodexSessionRuntimeOwnership,
9
+ requireCodexSupervisionModelSelection: () => requireCodexSupervisionModelSelection,
10
+ resolveCodexBindingAppServerConnection: () => resolveCodexBindingAppServerConnection
11
+ });
12
+ /** Prevents a prepared native session from becoming a fresh thread after its binding changes. */
13
+ function assertCodexSessionRuntimeOwnership(binding, expected) {
14
+ if (!expected) return;
15
+ const auth = binding?.connectionScope === "supervision" ? "native" : "host";
16
+ const hostModelChanged = expected.auth === "host" && (!expected.modelRef || binding?.model !== expected.modelRef.model || binding?.modelProvider !== expected.modelRef.provider);
17
+ if (binding?.preserveNativeModel !== true || auth !== expected.auth || hostModelChanged) throw new AgentHarnessPreflightError("Codex native session ownership is missing or changed. Reattach the original native session or create a new chat with a concrete model; no replacement thread was started.");
18
+ }
19
+ /** Requires the native model pair after a supervised pending branch has materialized. */
20
+ function requireCodexSupervisionModelSelection(binding) {
21
+ const model = binding.model?.trim();
22
+ const modelProvider = binding.modelProvider?.trim();
23
+ if (binding.connectionScope !== "supervision" || !model || !modelProvider) throw new Error("Codex supervised binding is missing its native model and provider; refusing request selection");
24
+ return {
25
+ model,
26
+ modelProvider
27
+ };
28
+ }
29
+ /** Resolves connection and auth ownership exclusively from the private thread binding. */
30
+ function resolveCodexBindingAppServerConnection(params) {
31
+ const { binding, authProfileId, ...runtimeParams } = params;
32
+ const usesSupervisionConnection = binding?.connectionScope === "supervision";
33
+ if (usesSupervisionConnection && readCodexPluginConfig(runtimeParams.pluginConfig).supervision?.enabled !== true) throw new Error("Codex supervision is disabled; refusing to open a native user-home supervised session");
34
+ let appServer = (usesSupervisionConnection ? resolveCodexSupervisionAppServerRuntimeOptions : resolveCodexAppServerRuntimeOptions)(runtimeParams);
35
+ if (usesSupervisionConnection) {
36
+ const persistedFingerprint = binding.pendingSupervisionBranch?.connectionFingerprint ?? binding.appServerRuntimeFingerprint;
37
+ const catalogHome = persistedFingerprint ? resolveCodexCatalogConnectionHome(persistedFingerprint, runtimeParams.agentDir) : void 0;
38
+ if (catalogHome) appServer = {
39
+ ...appServer,
40
+ start: {
41
+ ...appServer.start,
42
+ homeScope: "user",
43
+ env: {
44
+ ...appServer.start.env,
45
+ CODEX_HOME: catalogHome
46
+ }
47
+ }
48
+ };
49
+ const currentFingerprint = buildCodexAppServerConnectionFingerprint(appServer, runtimeParams.agentDir);
50
+ if (!persistedFingerprint || persistedFingerprint !== currentFingerprint) throw new Error("Codex supervision connection changed; refusing to operate on its bound native thread");
51
+ }
52
+ return {
53
+ appServer,
54
+ usesSupervisionConnection,
55
+ requestAuthProfileId: usesSupervisionConnection ? void 0 : authProfileId,
56
+ clientAuthProfileId: usesSupervisionConnection ? null : authProfileId
57
+ };
58
+ }
59
+ //#endregion
60
+ export { resolveCodexBindingAppServerConnection as i, binding_connection_exports as n, requireCodexSupervisionModelSelection as r, assertCodexSessionRuntimeOwnership as t };
@@ -1,15 +1,15 @@
1
- import { B as isJsonObject, i as resolveCodexAppServerRuntimeOptions } from "./config-CyapYSji.js";
2
- import { at as readCodexErrorNotification, ct as createCodexElicitationResponse, nt as assertCodexThreadStartResponse, rt as assertCodexTurnStartResponse, st as readCodexTurnCompletedNotification, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-CKhX2kFt.js";
3
- import { m as readCodexAppServerConfigOptions } from "./managed-binary-DcpnJF9x.js";
4
- import { _ as readCodexNotificationTurnId, a as closeCodexStartupClientBestEffort, o as interruptCodexTurnAndWaitBestEffort, t as CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS } from "./attempt-client-cleanup-Bp1ZOnk2.js";
5
- import { c as isRetryableErrorNotification, l as isTerminalTurnStatus, t as CodexUsageProjection, u as readCodexNotificationItem } from "./event-projector-usage-ZqEVbAEY.js";
6
- import { r as readModelListResult } from "./models-CcrgSMQR.js";
7
- import { Et as mergeCodexThreadConfigs, G as attestCodexRestrictedToolSurfaceMcpServersDisabled, _ as buildCodexRingZeroThreadConfigPatch, b as readCodexInheritedMcpServerNames, g as assertCodexManagedRequirementsDoNotOverrideToolPolicy, v as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-DPK30jad.js";
8
- import { readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { r as readCodexAppServerConfigOptions } from "./launch-args-RXQwn8zV.js";
2
+ import { C as readCodexErrorNotification, E as createCodexElicitationResponse, b as assertCodexThreadStartResponse, x as assertCodexTurnStartResponse } from "./client-BEKu4yDx.js";
3
+ import "./config-JDfTI4VI.js";
4
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-BWf6JLWG.js";
5
+ import { u as isCodexAppServerStartSelectionChangedError } from "./shared-client-CVhez2Uo.js";
6
+ import { a as closeCodexStartupClientBestEffort, o as interruptCodexTurnAndWaitBestEffort, t as CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS } from "./attempt-client-cleanup-D6cR54TV.js";
7
+ import { t as CodexEphemeralTurn } from "./ephemeral-turn-DSwzP8YY.js";
8
+ import { r as readModelListResult } from "./models-P9k2qAof.js";
9
+ import { G as attestCodexRestrictedToolSurfaceMcpServersDisabled, Tt as mergeCodexThreadConfigs, _ as buildCodexRingZeroThreadConfigPatch, b as readCodexInheritedMcpServerNames, g as assertCodexManagedRequirementsDoNotOverrideToolPolicy, v as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-D1pzRwHB.js";
9
10
  import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
10
- import fs from "node:fs/promises";
11
11
  import path from "node:path";
12
- import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
12
+ import fs from "node:fs/promises";
13
13
  import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
14
14
  //#region extensions/codex/src/app-server/bounded-turn.ts
15
15
  const CODEX_APP_SERVER_ARGS_ENV_KEY = "OPENCLAW_CODEX_APP_SERVER_ARGS";
@@ -79,7 +79,7 @@ async function runBoundedCodexAppServerTurnInWorkspace(params, appServer, worksp
79
79
  assertCurrent: params.assertCurrent,
80
80
  ...params.signal ? { abandonSignal: params.signal } : {}
81
81
  };
82
- const client = params.options.clientFactory ? await params.options.clientFactory(clientOptions) : await import("./shared-client-CKhX2kFt.js").then((n) => n.x).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
82
+ const client = params.options.clientFactory ? await params.options.clientFactory(clientOptions) : await import("./shared-client-CVhez2Uo.js").then((n) => n.y).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
83
83
  ...clientOptions,
84
84
  authProfileStore: params.authProfileStore
85
85
  }));
@@ -147,9 +147,10 @@ async function runBoundedCodexAppServerTurnInWorkspace(params, appServer, worksp
147
147
  items: params.historyItems
148
148
  }, requestOptions);
149
149
  params.assertCurrent?.();
150
- const collector = createCodexBoundedTurnCollector(thread.thread.id, params.taskLabel, params.allowEmptyText === true);
151
- const cleanup = client.addNotificationHandler(collector.handleNotification);
152
- const requestCleanup = client.addRequestHandler(createCodexBoundedApprovalHandler(params.taskLabel));
150
+ const collector = new CodexEphemeralTurn(client, thread.thread.id, {
151
+ textMode: "all",
152
+ onRequest: createCodexBoundedApprovalHandler(params.taskLabel)
153
+ });
153
154
  try {
154
155
  const turn = assertCodexTurnStartResponse(await client.request("turn/start", {
155
156
  threadId: thread.thread.id,
@@ -159,13 +160,18 @@ async function runBoundedCodexAppServerTurnInWorkspace(params, appServer, worksp
159
160
  }, requestOptions));
160
161
  activeTurnId = turn.turn.id;
161
162
  if (abortController.signal.aborted) requestInterrupt();
162
- const result = await collector.collect(turn.turn, {
163
+ const result = await collector.wait(turn.turn, {
163
164
  signal: abortController.signal,
164
- timeoutError
165
+ abortError: () => resolveCodexBoundedTurnAbortError(abortController.signal, params.taskLabel, timeoutError)
165
166
  });
167
+ if (result.error || result.turn?.status === "failed") throw new Error((result.error ? readCodexErrorNotification(result.error)?.error.message : result.turn?.error?.message) ?? `codex app-server ${params.taskLabel} turn failed`);
168
+ if (result.turn?.status !== "completed") throw new Error(`codex app-server ${params.taskLabel} turn ended with status ${result.turn?.status ?? "unknown"}`);
169
+ if (!result.text && !params.allowEmptyText) throw new Error(`Codex app-server ${params.taskLabel} turn returned no text.`);
166
170
  params.assertCurrent?.();
167
171
  return {
168
- ...result,
172
+ text: result.text,
173
+ items: result.items,
174
+ usage: result.usage,
169
175
  model: modelSelection.catalogId,
170
176
  nativeSelection: {
171
177
  model: thread.model,
@@ -174,8 +180,7 @@ async function runBoundedCodexAppServerTurnInWorkspace(params, appServer, worksp
174
180
  };
175
181
  } finally {
176
182
  await interruptPromise;
177
- requestCleanup();
178
- cleanup();
183
+ collector.route.release();
179
184
  }
180
185
  } catch (error) {
181
186
  if (abortController.signal.aborted) throw resolveCodexBoundedTurnAbortError(abortController.signal, params.taskLabel, timeoutError);
@@ -269,110 +274,8 @@ async function resolveCodexBoundedTurnModel(params) {
269
274
  runtimeModelId: match.model
270
275
  };
271
276
  }
272
- function createCodexBoundedTurnCollector(threadId, taskLabel, allowEmptyText) {
273
- let turnId;
274
- let completedTurn;
275
- let promptError;
276
- const usageProjection = new CodexUsageProjection();
277
- const pending = [];
278
- const completedItems = /* @__PURE__ */ new Map();
279
- const assistantTextByItem = /* @__PURE__ */ new Map();
280
- const assistantItemOrder = [];
281
- const { promise: completion, resolve: resolveCompletion } = createDeferred();
282
- const rememberAssistantText = (itemId, text) => {
283
- if (!text) return;
284
- if (!assistantTextByItem.has(itemId)) assistantItemOrder.push(itemId);
285
- assistantTextByItem.set(itemId, text);
286
- };
287
- const handleNotification = (notification) => {
288
- const params = isJsonObject(notification.params) ? notification.params : void 0;
289
- if (!params || readStringField(params, "threadId") !== threadId) return;
290
- if (!turnId) {
291
- pending.push(notification);
292
- return;
293
- }
294
- if (readCodexNotificationTurnId(params) !== turnId) return;
295
- if (notification.method === "item/completed") {
296
- const item = readCodexNotificationItem(notification.params);
297
- if (item) {
298
- completedItems.set(item.id, item);
299
- if (item.type === "agentMessage" && typeof item.text === "string") rememberAssistantText(item.id, item.text);
300
- }
301
- return;
302
- }
303
- if (notification.method === "item/agentMessage/delta") {
304
- const itemId = readStringField(params, "itemId") ?? readStringField(params, "id") ?? "assistant";
305
- const delta = readStringField(params, "delta") ?? "";
306
- rememberAssistantText(itemId, `${assistantTextByItem.get(itemId) ?? ""}${delta}`);
307
- return;
308
- }
309
- if (notification.method === "rawResponse/completed") {
310
- usageProjection.record(params);
311
- return;
312
- }
313
- if (notification.method === "turn/completed") {
314
- completedTurn = readCodexTurnCompletedNotification(notification.params)?.turn ?? completedTurn;
315
- resolveCompletion();
316
- return;
317
- }
318
- if (notification.method === "error") {
319
- usageProjection.invalidateContext();
320
- if (isRetryableErrorNotification(notification.params)) return;
321
- promptError = readCodexErrorNotification(notification.params)?.error.message ?? `codex app-server ${taskLabel} turn failed`;
322
- resolveCompletion();
323
- }
324
- };
325
- return {
326
- handleNotification,
327
- async collect(startedTurn, options) {
328
- turnId = startedTurn.id;
329
- if (isTerminalTurnStatus(startedTurn.status)) completedTurn = startedTurn;
330
- for (const notification of pending.splice(0)) handleNotification(notification);
331
- if (!completedTurn && !promptError) await waitForTurnCompletion({
332
- completion,
333
- signal: options.signal,
334
- taskLabel,
335
- timeoutError: options.timeoutError
336
- });
337
- if (promptError) throw new Error(promptError);
338
- if (completedTurn?.status === "failed") throw new Error(completedTurn.error?.message ?? `codex app-server ${taskLabel} turn failed`);
339
- if (completedTurn?.status !== "completed") throw new Error(`codex app-server ${taskLabel} turn ended with status ${completedTurn?.status ?? "unknown"}`);
340
- const items = collectCompletedItems(completedTurn?.items, completedItems);
341
- const itemText = collectAssistantTextFromItems(items);
342
- const deltaText = assistantItemOrder.map((itemId) => assistantTextByItem.get(itemId)?.trim()).filter((text) => Boolean(text)).join("\n\n").trim();
343
- const text = (itemText || deltaText).trim();
344
- if (!text && !allowEmptyText) throw new Error(`Codex app-server ${taskLabel} turn returned no text.`);
345
- return {
346
- text,
347
- items,
348
- usage: usageProjection.usage
349
- };
350
- }
351
- };
352
- }
353
- function collectCompletedItems(turnItems, notificationItems) {
354
- const items = new Map(notificationItems);
355
- for (const item of turnItems ?? []) items.set(item.id, item);
356
- return [...items.values()];
357
- }
358
- async function waitForTurnCompletion(params) {
359
- if (params.signal.aborted) throw resolveCodexBoundedTurnAbortError(params.signal, params.taskLabel, params.timeoutError);
360
- let cleanupAbort;
361
- try {
362
- await Promise.race([params.completion, new Promise((_, reject) => {
363
- const abortListener = () => reject(resolveCodexBoundedTurnAbortError(params.signal, params.taskLabel, params.timeoutError));
364
- params.signal.addEventListener("abort", abortListener, { once: true });
365
- cleanupAbort = () => params.signal.removeEventListener("abort", abortListener);
366
- })]);
367
- } finally {
368
- cleanupAbort?.();
369
- }
370
- }
371
277
  function resolveCodexBoundedTurnAbortError(signal, taskLabel, timeoutError) {
372
278
  return signal.reason === timeoutError ? timeoutError : /* @__PURE__ */ new Error(`codex app-server ${taskLabel} turn aborted`);
373
279
  }
374
- function collectAssistantTextFromItems(items) {
375
- return (items ?? []).filter((item) => item.type === "agentMessage").map((item) => item.text.trim()).filter(Boolean).join("\n\n").trim();
376
- }
377
280
  //#endregion
378
- export { runBoundedCodexAppServerTurn as t };
281
+ export { runBoundedCodexAppServerTurn };
@@ -0,0 +1,19 @@
1
+ //#region extensions/codex/package.json
2
+ var version = "2026.9.3";
3
+ //#endregion
4
+ //#region extensions/codex/src/build-state.ts
5
+ /**
6
+ * Duplicate module copies share one immutable published version's state.
7
+ * In-process restarts retain old records and callbacks for their old owners.
8
+ * Local rebuilds without a version bump deliberately share the same state.
9
+ */
10
+ function codexBuildSymbol(name) {
11
+ return Symbol.for(`${name}@${version}`);
12
+ }
13
+ function defineCodexBuildState(name, create) {
14
+ const key = codexBuildSymbol(name);
15
+ const globalState = globalThis;
16
+ return () => globalState[key] ??= create();
17
+ }
18
+ //#endregion
19
+ export { defineCodexBuildState as n, codexBuildSymbol as t };
@@ -1,4 +1,4 @@
1
- import { q as CodexAppServerRpcError } from "./shared-client-CKhX2kFt.js";
1
+ import { r as CodexAppServerRpcError } from "./session-catalog-provenance-DkJHo735.js";
2
2
  //#region extensions/codex/src/app-server/capabilities.ts
3
3
  /**
4
4
  * Capability helpers for optional Codex app-server control-plane methods.
@@ -2,7 +2,7 @@ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
2
2
  //#region extensions/codex/cli-metadata.ts
3
3
  function registerCodexCliMetadata(api) {
4
4
  api.registerCli(async ({ program }) => {
5
- const { registerCodexSessionCli } = await import("./session-cli-BjLhpmS1.js");
5
+ const { registerCodexSessionCli } = await import("./session-cli-CbgaHh0f.js");
6
6
  registerCodexSessionCli(program);
7
7
  }, { descriptors: [{
8
8
  name: "codex",