@openclaw/codex 2026.9.2 → 2026.9.4

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 (120) hide show
  1. package/README.md +2 -0
  2. package/dist/api.js +29 -26
  3. package/dist/apply-CvT8tW5i.js +356 -0
  4. package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-DKHzbwt5.js} +38 -214
  5. package/dist/{attempt-context-CSazkWns.js → attempt-context-D44yeDII.js} +9 -7
  6. package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications-C9XufG6l.js} +3 -106
  7. package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-CWlKVccJ.js} +2 -2
  8. package/dist/auth-cache-key-7orQae_j.js +498 -0
  9. package/dist/auth-profile-CwzO4_RG.js +43 -0
  10. package/dist/auth-profile-selection-DFu9e167.js +45 -0
  11. package/dist/binding-connection-D3udKbIE.js +60 -0
  12. package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-C_Hneydj.js} +28 -125
  13. package/dist/build-state-BCmg9-5p.js +19 -0
  14. package/dist/{capabilities-B1mgvpP8.js → capabilities-8vx68WLH.js} +1 -1
  15. package/dist/cli-metadata.js +1 -1
  16. package/dist/client-B57KWPQx.js +4005 -0
  17. package/dist/command-dispatch-BpduNGVf.js +21 -0
  18. package/dist/{command-formatters-DSbGMXA0.js → command-formatters-lxlkNZgU.js} +4 -3
  19. package/dist/{command-handlers-DOJvGv6-.js → command-handlers-tiL9iWj7.js} +788 -135
  20. package/dist/command-rpc-CR5EOEZX.js +233 -0
  21. package/dist/{compact-Y_xBqrHN.js → compact-B_H3AOd7.js} +19 -14
  22. package/dist/config-oIORaQ5T.js +106 -0
  23. package/dist/{config-CyapYSji.js → config-options-CXMq1T-C.js} +205 -593
  24. package/dist/config-runtime-D0zGNIHu.js +11 -0
  25. package/dist/{config-utils-C57JiJrU.js → config-utils-DujwEnhg.js} +2 -4
  26. package/dist/conversation-binding-DsB4-O7U.js +900 -0
  27. package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CtUu1b3m.js} +11 -143
  28. package/dist/doctor-contract-api.js +5 -5
  29. package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-CmN5RAip.js} +133 -76
  30. package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-Bd73bqA8.js} +3 -3
  31. package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
  32. package/dist/ephemeral-turn-D78_VmzO.js +101 -0
  33. package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
  34. package/dist/event-projector-items-5VhsECCO.js +200 -0
  35. package/dist/event-projector-usage-BfXmpOec.js +102 -0
  36. package/dist/{harness-Czh2Sdoc.js → harness-C7rRa7bm.js} +48 -24
  37. package/dist/harness.js +1 -1
  38. package/dist/history-rejection-B4nOXNXF.js +13 -0
  39. package/dist/incognito-session-uhrBF6wJ.js +15 -0
  40. package/dist/index.js +406 -2915
  41. package/dist/inference-context-Dr_mzvk4.js +94 -0
  42. package/dist/inference-proxy-HGXKUIre.js +311 -0
  43. package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DWVb5U2J.js} +7 -4
  44. package/dist/launch-args-RXQwn8zV.js +90 -0
  45. package/dist/{managed-binary-DcpnJF9x.js → managed-binary-D22rNEcR.js} +13 -103
  46. package/dist/managed-thread-store-D1t5jh3G.js +66 -0
  47. package/dist/media-understanding-provider.js +4 -1
  48. package/dist/migration-provider-api.js +2 -0
  49. package/dist/{model-catalog-DT5vo6qo.js → model-catalog-Dq2n8f_p.js} +6 -5
  50. package/dist/{models-CcrgSMQR.js → models-PCKOim-h.js} +3 -3
  51. package/dist/native-execution-policy-umd0tgh4.js +128 -0
  52. package/dist/native-subagent-history-DjtPloaU.js +140 -0
  53. package/dist/native-subagent-history-owner-Pcp7JuVF.js +34 -0
  54. package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-fQ7eIXEf.js} +115 -460
  55. package/dist/native-subagent-task-ids-BzTdT0Uw.js +387 -0
  56. package/dist/node-cli-sessions-DKaOmVUh.js +527 -0
  57. package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-Cl2vapEi.js} +55 -24
  58. package/dist/plan-7uG-Fp36.js +947 -0
  59. package/dist/plugin-activation-BYQculil.js +138 -0
  60. package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-d0eKxy7b.js} +4 -52
  61. package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-Bz3FT8W5.js} +1 -1
  62. package/dist/plugin-inventory-oL4Na1ZG.js +328 -0
  63. package/dist/plugin-marketplace-discovery-P-Vndfqq.js +137 -0
  64. package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-ClPJpRio.js} +17 -9
  65. package/dist/protocol-5bh1G-H7.js +275 -0
  66. package/dist/provider-MQ8PVkuE.js +50 -0
  67. package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-BvCUL69A.js} +2 -2
  68. package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-CBMmWBr9.js} +1 -1
  69. package/dist/request-B7hEkBGq.js +212 -0
  70. package/dist/rpc-error-ttN_QjEm.js +30 -0
  71. package/dist/{run-attempt-BzthFQSM.js → run-attempt-CvsAAGa0.js} +664 -377
  72. package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-BJ0rXBZ_.js} +27 -27
  73. package/dist/sandbox-guard-BxgyoM8M.js +166 -0
  74. package/dist/{session-binding-4Ki04sW-.js → session-binding-CI8UuilT.js} +30 -48
  75. package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-Bcvslnhf.js} +12 -26
  76. package/dist/session-catalog-adoption-tcZi1IfX.js +251 -0
  77. package/dist/session-catalog-archive-CwKg8Xz2.js +56 -0
  78. package/dist/session-catalog-ct-AH01I.js +1477 -0
  79. package/dist/session-catalog-home-id-CwhLdC03.js +18 -0
  80. package/dist/session-catalog-node-adoption-B1tgDW-m.js +182 -0
  81. package/dist/session-catalog-node-continue-Ci-DXyJP.js +238 -0
  82. package/dist/session-catalog-provenance-D-dIfRAH.js +96 -0
  83. package/dist/{session-cli-BjLhpmS1.js → session-cli-DNN_jhGc.js} +3 -2
  84. package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
  85. package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DwyijFI6.js} +5 -50
  86. package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
  87. package/dist/session-history-worker-runtime.js +18 -6
  88. package/dist/session-history.worker-BeK1YOyT.js +378 -0
  89. package/dist/session-history.worker.js +1 -1
  90. package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Ct0_Hzmg.js} +2 -2
  91. package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-BBmXA8Eg.js} +4 -7
  92. package/dist/{session-retirement-DNdmYdFc.js → session-retirement-B2YfbAAT.js} +6 -5
  93. package/dist/session-upstream-marker-D15C9NHp.js +46 -0
  94. package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
  95. package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-Dn91stmc.js} +8 -7
  96. package/dist/shared-client-CscigXXL.js +3109 -0
  97. package/dist/{side-question-B6DWAw1A.js → side-question-BGMJQf4U.js} +65 -170
  98. package/dist/source-CElXU0Oy.js +518 -0
  99. package/dist/thread-archive-guard-DfpBr-Sz.js +53 -0
  100. package/dist/thread-history-page-D0JIp48V.js +361 -0
  101. package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-DXl1-I6b.js} +187 -639
  102. package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-BsDRTsyp.js} +13 -15
  103. package/dist/thread-policy-BuEQfE0g.js +54 -0
  104. package/dist/thread-resume-DsDOZpFg.js +52 -0
  105. package/dist/timeout-BVw8aaM1.js +33 -0
  106. package/dist/transcript-history-projection-v17wXgdK.js +238 -0
  107. package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-C5CKgNy6.js} +50 -260
  108. package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
  109. package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
  110. package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-BZerMte_.js} +27 -19
  111. package/dist/{usage-i9fv5-4m.js → usage-tCk-mg_x.js} +4 -3
  112. package/dist/version-omm6IPI3.js +12 -0
  113. package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-B7bGbGWq.js} +3 -3
  114. package/openclaw.plugin.json +23 -1
  115. package/package.json +4 -4
  116. package/dist/request-C8H22rPi.js +0 -475
  117. package/dist/session-catalog-B47uwekb.js +0 -3272
  118. package/dist/session-history.worker-zZVcx0ME.js +0 -267
  119. package/dist/shared-client-CKhX2kFt.js +0 -7505
  120. package/dist/thread-policy-CTalhWFy.js +0 -105
@@ -1,203 +1,15 @@
1
- import { B as isJsonObject } from "./config-CyapYSji.js";
2
- import { Nt as unsubscribeCodexAppServerLiveThread, q as CodexAppServerRpcError, y as retireSharedCodexAppServerClientIfCurrent } from "./shared-client-CKhX2kFt.js";
3
- import { asFiniteNumber, normalizeOptionalString, normalizeOptionalString as normalizeOptionalString$1, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { o as isJsonObject } from "./protocol-5bh1G-H7.js";
2
+ import "./client-B57KWPQx.js";
3
+ import { m as retireSharedCodexAppServerClientIfCurrent } from "./auth-cache-key-7orQae_j.js";
4
+ import { t as CodexAppServerRpcError } from "./rpc-error-ttN_QjEm.js";
5
+ import { h as unknownItemStatus } from "./event-projector-items-5VhsECCO.js";
6
+ import { Y as unsubscribeCodexAppServerLiveThread } from "./shared-client-CscigXXL.js";
7
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
8
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
5
9
  import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
10
+ import { AsyncResource } from "node:async_hooks";
6
11
  import { redactSensitiveText } from "openclaw/plugin-sdk/logging-core";
7
12
  import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
8
- //#region extensions/codex/src/app-server/event-projector-values.ts
9
- const BIO_POLICY_SAFETY_ACCESS_BLOCK_PREFIX = "This content was flagged for possible biological risk.";
10
- /** Project only Codex's explicit refusal contracts; other policy errors retain their own paths. */
11
- function readCodexProviderRefusal(message, codexErrorInfo) {
12
- if (!message) return;
13
- if (codexErrorInfo === "cyberPolicy") return {
14
- category: "cyber",
15
- message
16
- };
17
- return message.startsWith(BIO_POLICY_SAFETY_ACCESS_BLOCK_PREFIX) ? {
18
- category: "bio",
19
- message
20
- } : void 0;
21
- }
22
- function readNonEmptyString(record, key) {
23
- return normalizeOptionalString$1(record[key]);
24
- }
25
- function readNonEmptyStringArray(record, key) {
26
- const value = record[key];
27
- if (!Array.isArray(value)) return [];
28
- const entries = [];
29
- for (const entry of value) {
30
- const normalized = normalizeOptionalString$1(entry);
31
- if (normalized) entries.push(normalized);
32
- }
33
- return entries;
34
- }
35
- function readNullableString(record, key) {
36
- const value = record[key];
37
- if (value === null) return null;
38
- return typeof value === "string" ? value : void 0;
39
- }
40
- function readNonNegativeInteger(record, key) {
41
- const value = asFiniteNumber(record[key]);
42
- return value !== void 0 && Number.isInteger(value) && value >= 0 ? value : void 0;
43
- }
44
- function readCodexErrorNotificationMessage(record) {
45
- const error = record.error;
46
- return isJsonObject(error) ? readStringField(error, "message") : void 0;
47
- }
48
- function readHookOutputEntries(value) {
49
- if (!Array.isArray(value)) return [];
50
- return value.flatMap((entry) => {
51
- if (!isJsonObject(entry)) return [];
52
- const text = readStringField(entry, "text");
53
- if (!text) return [];
54
- const kind = readStringField(entry, "kind");
55
- return [{
56
- ...kind ? { kind } : {},
57
- text
58
- }];
59
- });
60
- }
61
- function splitPlanText(text) {
62
- return text.split(/\r?\n/).map((line) => line.trim().replace(/^[-*]\s+/, "")).filter((line) => line.length > 0);
63
- }
64
- function extractRawAssistantText(item) {
65
- const parts = (Array.isArray(item.content) ? item.content : []).flatMap((entry) => {
66
- if (!isJsonObject(entry)) return [];
67
- const type = readStringField(entry, "type");
68
- if (type !== "output_text" && type !== "text") return [];
69
- const value = readStringField(entry, "text");
70
- return value === void 0 ? [] : [value];
71
- });
72
- return parts.length > 0 ? parts.join("").trim() : void 0;
73
- }
74
- function readItemString(item, key) {
75
- const value = item[key];
76
- return typeof value === "string" ? value : void 0;
77
- }
78
- function readItem(value) {
79
- if (!isJsonObject(value)) return;
80
- const type = typeof value.type === "string" ? value.type : void 0;
81
- const id = typeof value.id === "string" ? value.id : void 0;
82
- if (!type || !id) return;
83
- return value;
84
- }
85
- //#endregion
86
- //#region extensions/codex/src/app-server/event-projector-items.ts
87
- function matchesCodexSnapshotTurn(item, turnId) {
88
- const itemTurnId = readItemString(item, "turnId");
89
- return itemTurnId === void 0 || itemTurnId === turnId;
90
- }
91
- function itemKind(item) {
92
- switch (item.type) {
93
- case "dynamicToolCall":
94
- case "mcpToolCall": return "tool";
95
- case "commandExecution": return "command";
96
- case "fileChange": return "patch";
97
- case "webSearch": return "search";
98
- case "reasoning":
99
- case "contextCompaction": return "analysis";
100
- default: return;
101
- }
102
- }
103
- function itemTitle(item) {
104
- switch (item.type) {
105
- case "commandExecution": return "Command";
106
- case "fileChange": return "File change";
107
- case "mcpToolCall": return "MCP tool";
108
- case "dynamicToolCall": return "Tool";
109
- case "webSearch": return "Web search";
110
- case "contextCompaction": return "Context compaction";
111
- case "reasoning": return "Reasoning";
112
- default: return item.type;
113
- }
114
- }
115
- function itemStatus(item) {
116
- const status = readItemString(item, "status");
117
- if (status === "failed" || status === "error") return "failed";
118
- if (status === "declined") return "blocked";
119
- if (status === "inProgress" || status === "in_progress" || status === "running") return "running";
120
- return "completed";
121
- }
122
- function unknownItemStatus(item) {
123
- const status = readItemString(item, "status");
124
- switch (status) {
125
- case void 0:
126
- case "completed":
127
- case "failed":
128
- case "error":
129
- case "declined":
130
- case "inProgress":
131
- case "in_progress":
132
- case "running": return;
133
- default: return status;
134
- }
135
- }
136
- function auditNativeToolTerminalStatus(item) {
137
- if (item.type === "imageView" || item.type === "sleep") return "completed";
138
- const status = readItemString(item, "status");
139
- if (status === "completed") return "completed";
140
- if (status === "failed" || status === "error") return "failed";
141
- if (status === "declined") return "blocked";
142
- return "unknown";
143
- }
144
- function auditNativeToolUnfinishedStatus(item) {
145
- return item.type === "webSearch" || item.type === "imageGeneration" ? "unknown" : "failed";
146
- }
147
- function isNonSuccessItemStatus(status) {
148
- return status === "failed" || status === "blocked";
149
- }
150
- function itemName(item) {
151
- if (item.type === "dynamicToolCall" && typeof item.tool === "string") return item.tool;
152
- if (item.type === "mcpToolCall" && typeof item.tool === "string") {
153
- const server = typeof item.server === "string" ? item.server : void 0;
154
- return server ? `${server}.${item.tool}` : item.tool;
155
- }
156
- if (item.type === "commandExecution") return "bash";
157
- if (item.type === "fileChange") return "apply_patch";
158
- if (item.type === "webSearch") return "web_search";
159
- }
160
- function auditNativeToolName(item) {
161
- if (item.type === "dynamicToolCall") return;
162
- const progressName = itemName(item);
163
- if (progressName) return progressName;
164
- if (item.type === "collabAgentToolCall") return typeof item.tool === "string" && item.tool.trim() ? `collab.${item.tool.trim()}` : "collab_agent";
165
- if (item.type === "imageGeneration") return "image_generation";
166
- if (item.type === "imageView") return "image_view";
167
- if (item.type === "sleep") return "sleep";
168
- }
169
- function isSideEffectingNativeToolItem(item) {
170
- return itemStatus(item) !== "blocked" && (isMutatingNativeToolItem(item) || item.type === "mcpToolCall");
171
- }
172
- function shouldSynthesizeToolProgressForItem(item) {
173
- switch (item.type) {
174
- case "commandExecution":
175
- case "fileChange":
176
- case "webSearch":
177
- case "mcpToolCall": return true;
178
- default: return false;
179
- }
180
- }
181
- function shouldRecordNativeToolTranscript(item) {
182
- return shouldSynthesizeToolProgressForItem(item);
183
- }
184
- function isMutatingNativeToolItem(item) {
185
- if (item.type === "commandExecution") return true;
186
- return item.type === "fileChange" || item.type === "collabAgentToolCall" || item.type === "imageGeneration";
187
- }
188
- function shouldClearTerminalPresentationForNativeItem(item) {
189
- switch (item.type) {
190
- case "collabAgentToolCall":
191
- case "commandExecution":
192
- case "fileChange":
193
- case "imageGeneration":
194
- case "imageView":
195
- case "mcpToolCall":
196
- case "webSearch": return true;
197
- default: return false;
198
- }
199
- }
200
- //#endregion
201
13
  //#region extensions/codex/src/app-server/notification-correlation.ts
202
14
  /**
203
15
  * Correlates Codex app-server notifications with the active thread/turn so
@@ -293,7 +105,6 @@ var ClientTurnRouter = class {
293
105
  this.routes = /* @__PURE__ */ new Map();
294
106
  this.globalWarnings = [];
295
107
  this.nativeTurnCompletionWatchers = /* @__PURE__ */ new Map();
296
- this.disposed = false;
297
108
  client.addNotificationHandler((notification) => this.routeNotification(notification));
298
109
  client.addRequestHandler((request, signal) => this.routeRequest(request, signal));
299
110
  client.addCloseHandler((closedClient) => {
@@ -334,9 +145,12 @@ var ClientTurnRouter = class {
334
145
  get observedNativeTurnId() {
335
146
  return route.observedNativeTurn?.id;
336
147
  },
148
+ get completed() {
149
+ return Boolean(route.turnId && route.completedNativeTurnIds.has(route.turnId));
150
+ },
337
151
  activate: (handlers) => this.activate(route, handlers),
338
152
  armTurn: () => this.armTurn(route),
339
- bindTurn: (turnId) => this.bindTurn(route, turnId),
153
+ bindTurn: (turnId, bindingOptions) => this.bindTurn(route, turnId, bindingOptions),
340
154
  cancelTurn: () => this.cancelTurn(route),
341
155
  drain: () => this.drainNotifications(route),
342
156
  release: () => this.release(route)
@@ -393,9 +207,9 @@ var ClientTurnRouter = class {
393
207
  };
394
208
  }
395
209
  dispose(cause) {
396
- if (this.disposed) return;
397
- this.disposed = true;
210
+ if (this.closeError) return;
398
211
  const closeError = cause ? new Error("codex app-server turn router closed", { cause }) : /* @__PURE__ */ new Error("codex app-server turn router closed");
212
+ this.closeError = closeError;
399
213
  for (const route of this.routes.values()) this.release(route, closeError);
400
214
  for (const watchers of this.nativeTurnCompletionWatchers.values()) for (const watcher of watchers) watcher.finish(false);
401
215
  }
@@ -409,7 +223,11 @@ var ClientTurnRouter = class {
409
223
  if (route.handlers) throw new Error(`codex app-server thread route already activated: ${route.threadId}`);
410
224
  this.assertRoute(route);
411
225
  if (!handlers.onNotification && !handlers.onRequest) throw new Error("codex app-server thread route requires a notification or request handler");
412
- route.handlers = handlers;
226
+ route.handlers = {
227
+ onRequest: handlers.onRequest && AsyncResource.bind(handlers.onRequest),
228
+ onNotification: handlers.onNotification && AsyncResource.bind(handlers.onNotification),
229
+ onNotificationReceived: handlers.onNotificationReceived && AsyncResource.bind(handlers.onNotificationReceived, void 0, handlers)
230
+ };
413
231
  if (!handlers.onNotification) route.pending.length = 0;
414
232
  else if (route.gate !== "armed") this.flushNotifications(route);
415
233
  route.activated.resolve();
@@ -432,20 +250,22 @@ var ClientTurnRouter = class {
432
250
  await this.waitForNotifications(route);
433
251
  this.assertRoute(route);
434
252
  }
435
- async bindTurn(route, turnIdInput) {
436
- this.assertRoute(route);
253
+ async bindTurn(route, turnIdInput, options) {
254
+ const turnId = requireId(turnIdInput, "turn id");
255
+ if (options?.completed && route.gate === "armed" && (!route.released || route.released === this.closeError)) route.completedNativeTurnIds.add(turnId);
256
+ this.assertRoute(route, route.gate === "armed" ? turnId : void 0);
437
257
  if (!route.handlers) throw new Error("codex app-server thread route must be activated before binding a turn");
438
258
  if (route.gate !== "armed") throw new Error(`codex app-server thread route cannot bind from ${route.gate}`);
439
- const turnId = requireId(turnIdInput, "turn id");
440
259
  route.gate = "bound";
441
260
  route.turnId = turnId;
442
261
  this.flushNotifications(route);
443
262
  route.binding?.resolve();
444
263
  await this.waitForNotifications(route);
445
- this.assertRoute(route);
264
+ this.assertRoute(route, turnId);
265
+ await route.notificationTail;
446
266
  }
447
267
  routeNotification(notification) {
448
- if (this.disposed) return;
268
+ if (this.closeError) return;
449
269
  const scope = readScope(notification.params);
450
270
  if (!scope.threadId && (notification.method === "configWarning" || notification.method === "warning")) {
451
271
  if (this.globalWarnings.length === DEFAULT_GLOBAL_WARNING_LIMIT) this.globalWarnings.shift();
@@ -504,7 +324,7 @@ var ClientTurnRouter = class {
504
324
  return route.notificationTail;
505
325
  }
506
326
  async routeRequest(request, signal = new AbortController().signal) {
507
- if (this.disposed || signal.aborted) return;
327
+ if (this.closeError || signal.aborted) return;
508
328
  const scope = readScope(request.params);
509
329
  if (!scope.threadId) return;
510
330
  const route = this.routes.get(scope.threadId);
@@ -579,7 +399,7 @@ var ClientTurnRouter = class {
579
399
  this.release(route, error);
580
400
  }
581
401
  enqueueNotification(route, handler, notification, scope) {
582
- if (route.released) return;
402
+ if (route.released && !this.canDrainClosedTurn(route, route.turnId)) return;
583
403
  route.notificationTail = route.notificationTail.then(() => handler(notification, scope)).catch((error) => {
584
404
  if (!route.released) embeddedAgentLog.warn("codex app-server keyed notification handler failed", {
585
405
  method: notification.method,
@@ -598,7 +418,7 @@ var ClientTurnRouter = class {
598
418
  release(route, error = /* @__PURE__ */ new Error("codex app-server thread route is released")) {
599
419
  if (route.released) return;
600
420
  route.released = error;
601
- route.pending.length = 0;
421
+ if (error !== this.closeError) route.pending.length = 0;
602
422
  route.ended.resolve();
603
423
  route.activated.resolve();
604
424
  route.binding?.resolve();
@@ -607,10 +427,13 @@ var ClientTurnRouter = class {
607
427
  if (this.routes.get(route.threadId) === route) this.routes.delete(route.threadId);
608
428
  }
609
429
  assertActive() {
610
- if (this.disposed) throw new Error("codex app-server turn router is closed");
430
+ if (this.closeError) throw new Error("codex app-server turn router is closed");
431
+ }
432
+ canDrainClosedTurn(route, turnId) {
433
+ return Boolean(this.closeError && route.released === this.closeError && turnId && route.completedNativeTurnIds.has(turnId));
611
434
  }
612
- assertRoute(route) {
613
- if (route.released) throw route.released;
435
+ assertRoute(route, completedTurnId) {
436
+ if (route.released && !this.canDrainClosedTurn(route, completedTurnId)) throw route.released;
614
437
  }
615
438
  };
616
439
  async function waitForPromiseOrAbort(promise, signal) {
@@ -745,7 +568,7 @@ async function interruptCodexTurnAndWaitBestEffort(client, params) {
745
568
  }
746
569
  }
747
570
  /** Stops native terminals on the cancelled thread without retiring peer threads. */
748
- async function terminateCodexBackgroundTerminals(client, threadId) {
571
+ async function terminateCodexBackgroundTerminals(client, threadId, oneShotCliRun = false) {
749
572
  const options = {
750
573
  timeoutMs: CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS,
751
574
  signal: AbortSignal.timeout(CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS)
@@ -761,6 +584,7 @@ async function terminateCodexBackgroundTerminals(client, threadId) {
761
584
  threadId,
762
585
  limit: 1
763
586
  }, options)).data.length > 0) throw new Error("native background terminals remain running");
587
+ if (oneShotCliRun) throw new Error("native terminal termination did not confirm process cleanup");
764
588
  }
765
589
  } catch (cause) {
766
590
  throw new Error("Codex background-terminal cleanup failed; inspect the thread's running terminals before starting more work.", { cause });
@@ -781,4 +605,4 @@ async function unsubscribeCodexThreadBestEffort(client, params) {
781
605
  }
782
606
  }
783
607
  //#endregion
784
- export { shouldRecordNativeToolTranscript as A, readNonEmptyStringArray as B, isSideEffectingNativeToolItem as C, itemTitle as D, itemStatus as E, readCodexProviderRefusal as F, readNullableString as H, readHookOutputEntries as I, readItem as L, extractRawAssistantText as M, normalizeOptionalString$1 as N, matchesCodexSnapshotTurn as O, readCodexErrorNotificationMessage as P, readItemString as R, isNonSuccessItemStatus as S, itemName as T, splitPlanText as U, readNonNegativeInteger as V, readCodexNotificationTurnId as _, closeCodexStartupClientBestEffort as a, auditNativeToolUnfinishedStatus as b, isCodexNoActiveTurnInterruptError as c, unsubscribeCodexThreadBestEffort as d, CODEX_APP_SERVER_NATIVE_TURN_WAIT_TIMEOUT_MS as f, readCodexNotificationThreadId as g, isCodexNotificationForTurn as h, assertCodexThreadResumeSubscription as i, shouldSynthesizeToolProgressForItem as j, shouldClearTerminalPresentationForNativeItem as k, retireUnsafeCodexTurnClientBestEffort as l, CodexProjectionDiagnostics as m, CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS as n, interruptCodexTurnAndWaitBestEffort as o, getCodexAppServerTurnRouter as p, CodexAppServerUnsafeSubscriptionError as r, isCodexAppServerUnsafeSubscriptionError as s, CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS as t, terminateCodexBackgroundTerminals as u, auditNativeToolName as v, itemKind as w, isMutatingNativeToolItem as x, auditNativeToolTerminalStatus as y, readNonEmptyString as z };
608
+ export { readCodexNotificationTurnId as _, closeCodexStartupClientBestEffort as a, isCodexNoActiveTurnInterruptError as c, unsubscribeCodexThreadBestEffort as d, CODEX_APP_SERVER_NATIVE_TURN_WAIT_TIMEOUT_MS as f, readCodexNotificationThreadId as g, isCodexNotificationForTurn as h, assertCodexThreadResumeSubscription as i, retireUnsafeCodexTurnClientBestEffort as l, CodexProjectionDiagnostics as m, CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS as n, interruptCodexTurnAndWaitBestEffort as o, getCodexAppServerTurnRouter as p, CodexAppServerUnsafeSubscriptionError as r, isCodexAppServerUnsafeSubscriptionError as s, CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS as t, terminateCodexBackgroundTerminals as u };
@@ -1,11 +1,11 @@
1
- import { B as isJsonObject, z as flattenCodexDynamicToolFunctions } from "./config-CyapYSji.js";
2
- import { ct as isMessageOnlyCodexSourceReply, et as areCodexDynamicToolFingerprintsCompatible, mt as isContextEngineBindingCompatible } from "./thread-lifecycle-DPK30jad.js";
3
- import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-DWmMqiqW.js";
1
+ import { a as flattenCodexDynamicToolFunctions, o as isJsonObject } from "./protocol-5bh1G-H7.js";
2
+ import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-Cz-tOOYj.js";
3
+ import { Q as areCodexDynamicToolFingerprintsCompatible, ft as isContextEngineBindingCompatible, ot as isMessageOnlyCodexSourceReply } from "./thread-lifecycle-DXl1-I6b.js";
4
4
  import { readNonBlankString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  import { createHash } from "node:crypto";
6
6
  import path from "node:path";
7
- import { buildBootstrapContextForFiles, buildWatchedSessionsHarnessContext, embeddedAgentLog, resolveBootstrapFilesForRun } from "openclaw/plugin-sdk/agent-harness-runtime";
8
7
  import { resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
8
+ import { buildBootstrapContextForFiles, buildWatchedSessionsHarnessContext, embeddedAgentLog, resolveBootstrapFilesForRun } from "openclaw/plugin-sdk/agent-harness-runtime";
9
9
  import { resolveBootstrapFilesForPreparation } from "openclaw/plugin-sdk/codex-mcp-projection";
10
10
  import { prepareMemorySystemPromptAddition } from "openclaw/plugin-sdk/core";
11
11
  import { MESSAGE_TOOL_DELIVERY_HINTS } from "openclaw/plugin-sdk/message-tool-delivery-hints";
@@ -214,6 +214,7 @@ function buildCodexSystemPromptReport(params) {
214
214
  injectedWorkspaceFiles: buildCodexBootstrapInjectionStats({
215
215
  bootstrapFiles: params.workspaceBootstrapContext.bootstrapFiles,
216
216
  injectedFiles: params.workspaceBootstrapContext.promptContextFiles ?? [],
217
+ omitReferenceFiles: params.omitWorkspaceReferences,
217
218
  developerInstructionFiles: [...params.workspaceBootstrapContext.threadDeveloperInstructionFiles ?? [], ...params.workspaceBootstrapContext.turnScopedDeveloperInstructionFiles ?? []],
218
219
  memoryToolRoutedBootstrapFiles: params.workspaceBootstrapContext.memoryToolRoutedBootstrapFiles ?? [],
219
220
  memoryToolRouted: params.workspaceBootstrapContext.memoryToolRouted === true
@@ -304,8 +305,9 @@ function buildCodexBootstrapInjectionStats(params) {
304
305
  injectedChars: null,
305
306
  truncated: null
306
307
  };
307
- const injectedChars = memoryToolRoutedFile ? 0 : injected?.length ?? 0;
308
- const truncated = memoryToolRoutedFile ? false : !file.missing && injectedChars < rawChars;
308
+ const omitted = memoryToolRoutedFile || params.omitReferenceFiles && readCodexIndexedContextFileContent(injectedIndex, pathValue, fileName) !== void 0;
309
+ const injectedChars = omitted ? 0 : injected?.length ?? 0;
310
+ const truncated = omitted ? false : !file.missing && injectedChars < rawChars;
309
311
  return {
310
312
  name: displayName,
311
313
  path: pathValue,
@@ -440,7 +442,7 @@ function renderCodexWorkspaceBootstrapPromptContext(contextFiles) {
440
442
  const files = contextFiles;
441
443
  if (files.length === 0) return;
442
444
  const lines = [
443
- "OpenClaw loaded these user-editable workspace files for the current turn. Codex loads project-local AGENTS.md natively. When execution uses another folder, OpenClaw supplies the agent workspace AGENTS.md as thread-level developer instructions. SOUL.md, IDENTITY.md, and USER.md remain turn-scoped collaboration instructions. Those files are not repeated here.",
445
+ "OpenClaw loaded these user-editable workspace files for the current turn. Codex loads project-local AGENTS.md natively. When execution uses another folder, OpenClaw supplies the agent workspace AGENTS.md as thread-level developer instructions. SOUL.md, IDENTITY.md, and USER.md are prepared separately from user input and are not repeated here.",
444
446
  "",
445
447
  "# Project Context",
446
448
  "",
@@ -1,6 +1,5 @@
1
- import { B as isJsonObject } from "./config-CyapYSji.js";
2
- import { asSafeIntegerInRange, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
3
- import { normalizeUsage } from "openclaw/plugin-sdk/agent-harness-runtime";
1
+ import { o as isJsonObject } from "./protocol-5bh1G-H7.js";
2
+ import { readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
4
3
  //#region extensions/codex/src/app-server/attempt-notifications.ts
5
4
  const CODEX_TURN_ABORT_MARKER_START = "<turn_aborted>";
6
5
  const CODEX_TURN_ABORT_MARKER_END = "</turn_aborted>";
@@ -41,10 +40,6 @@ function isAssistantCommentaryCompletionNotification(notification) {
41
40
  const item = isJsonObject(notification.params.item) ? notification.params.item : void 0;
42
41
  return Boolean(item && readStringField(item, "type") === "agentMessage" && (readStringField(item, "phase") === "commentary" || readStringField(item, "delivery") === "async"));
43
42
  }
44
- /** A retryable native error is not a terminal outcome for bounded operations. */
45
- function isRetryableErrorNotification(value) {
46
- return isJsonObject(value) && value.willRetry === true;
47
- }
48
43
  /** Returns true for terminal app-server thread status strings. */
49
44
  function isTerminalTurnStatus(status) {
50
45
  return status === "completed" || status === "interrupted" || status === "failed";
@@ -111,102 +106,4 @@ function isNonEmptyString(value) {
111
106
  return typeof value === "string" && value.length > 0;
112
107
  }
113
108
  //#endregion
114
- //#region extensions/codex/src/app-server/event-projector-usage.ts
115
- function readTokenCount(record, key) {
116
- return asSafeIntegerInRange(record[key], { min: 0 });
117
- }
118
- function readCodexThreadTokenUsage(params) {
119
- const tokenUsage = isJsonObject(params.tokenUsage) ? params.tokenUsage : void 0;
120
- const last = tokenUsage && isJsonObject(tokenUsage.last) ? tokenUsage.last : void 0;
121
- return last ? normalizeCodexResponseTokenUsage(last) : void 0;
122
- }
123
- function readCodexThreadContextSnapshot(params) {
124
- const tokenUsage = isJsonObject(params.tokenUsage) ? params.tokenUsage : void 0;
125
- const last = tokenUsage && isJsonObject(tokenUsage.last) ? tokenUsage.last : void 0;
126
- const modelContextWindow = tokenUsage ? readTokenCount(tokenUsage, "modelContextWindow") : void 0;
127
- const activeContextTokens = last ? readTokenCount(last, "totalTokens") : void 0;
128
- const inputTokens = last ? readTokenCount(last, "inputTokens") : void 0;
129
- const cachedInputTokens = last ? readTokenCount(last, "cachedInputTokens") : void 0;
130
- const cacheWriteInputTokens = last ? readTokenCount(last, "cacheWriteInputTokens") : void 0;
131
- const reasoningOutputTokens = last ? readTokenCount(last, "reasoningOutputTokens") : void 0;
132
- return {
133
- ...activeContextTokens !== void 0 ? { activeContextTokens } : {},
134
- ...cachedInputTokens !== void 0 ? { cachedInputTokens } : {},
135
- ...cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens } : {},
136
- ...inputTokens !== void 0 ? { inputTokens } : {},
137
- ...modelContextWindow && modelContextWindow > 0 ? { modelContextWindow } : {},
138
- ...inputTokens !== void 0 ? { promptTokens: inputTokens } : {},
139
- ...reasoningOutputTokens !== void 0 ? { reasoningOutputTokens } : {}
140
- };
141
- }
142
- function normalizeCodexResponseTokenUsage(record) {
143
- const totalTokens = readTokenCount(record, "totalTokens");
144
- const inputTokens = readTokenCount(record, "inputTokens");
145
- const cacheRead = readTokenCount(record, "cachedInputTokens");
146
- const output = readTokenCount(record, "outputTokens");
147
- const reasoningTokens = readTokenCount(record, "reasoningOutputTokens");
148
- const cacheWrite = record.cacheWriteInputTokens === void 0 ? 0 : readTokenCount(record, "cacheWriteInputTokens");
149
- const hasCoherentInput = inputTokens !== void 0 && cacheRead !== void 0 && cacheWrite !== void 0 && cacheRead + cacheWrite <= inputTokens;
150
- const hasCoherentContext = hasCoherentInput && totalTokens !== void 0 && output !== void 0 && totalTokens === inputTokens + output;
151
- const usage = normalizeUsage({
152
- input: hasCoherentInput ? inputTokens - cacheRead - cacheWrite : void 0,
153
- output,
154
- cacheRead,
155
- cacheWrite,
156
- reasoningTokens,
157
- total: totalTokens
158
- });
159
- if (!usage) return;
160
- return {
161
- ...usage,
162
- contextUsage: hasCoherentContext ? {
163
- state: "available",
164
- promptTokens: inputTokens,
165
- totalTokens
166
- } : { state: "unavailable" }
167
- };
168
- }
169
- var CodexUsageProjection = class {
170
- constructor() {
171
- this.responseIds = /* @__PURE__ */ new Set();
172
- }
173
- get usage() {
174
- const usage = this.responseUsage ?? this.threadUsage;
175
- return usage ? {
176
- ...usage,
177
- contextUsage: this.contextUsage
178
- } : void 0;
179
- }
180
- get modelIterations() {
181
- return this.responseIds.size;
182
- }
183
- invalidateContext() {
184
- this.contextUsage = { state: "unavailable" };
185
- }
186
- recordThread(params) {
187
- const usage = readCodexThreadTokenUsage(params);
188
- this.threadUsage = usage ?? this.threadUsage;
189
- if (!this.responseUsage && usage) this.contextUsage = usage.contextUsage;
190
- return readCodexThreadContextSnapshot(params);
191
- }
192
- record(params, reportOutputTokens) {
193
- const responseId = readStringField(params, "responseId");
194
- if (!responseId || this.responseIds.has(responseId)) return;
195
- this.responseIds.add(responseId);
196
- const usage = isJsonObject(params.usage) ? normalizeCodexResponseTokenUsage(params.usage) : void 0;
197
- this.contextUsage = usage?.contextUsage ?? { state: "unavailable" };
198
- this.responseUsage ??= {};
199
- for (const field of [
200
- "input",
201
- "output",
202
- "cacheRead",
203
- "cacheWrite",
204
- "reasoningTokens",
205
- "total"
206
- ]) if (usage?.[field] !== void 0) this.responseUsage[field] = (this.responseUsage[field] ?? 0) + usage[field];
207
- const outputTokens = usage?.output;
208
- if (outputTokens !== void 0) reportOutputTokens?.(outputTokens);
209
- }
210
- };
211
- //#endregion
212
- export { isCodexTurnAbortMarkerNotification as a, isRetryableErrorNotification as c, readNotificationItemId as d, readRawResponseToolCallId as f, isAssistantCommentaryCompletionNotification as i, isTerminalTurnStatus as l, readCodexThreadContextSnapshot as n, isPendingOpenClawDynamicToolCompletionNotification as o, updateActiveTurnItemIds as p, codexExecutionToolName as r, isRawFunctionToolOutputCompletionNotification as s, CodexUsageProjection as t, readCodexNotificationItem as u };
109
+ export { isRawFunctionToolOutputCompletionNotification as a, readNotificationItemId as c, isPendingOpenClawDynamicToolCompletionNotification as i, readRawResponseToolCallId as l, isAssistantCommentaryCompletionNotification as n, isTerminalTurnStatus as o, isCodexTurnAbortMarkerNotification as r, readCodexNotificationItem as s, codexExecutionToolName as t, updateActiveTurnItemIds as u };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { fingerprintResolvedAuthProfileCredential } from "openclaw/plugin-sdk/agent-harness-runtime";
3
2
  import { resolveApiKeyForProfile } from "openclaw/plugin-sdk/agent-runtime";
3
+ import { fingerprintResolvedAuthProfileCredential } from "openclaw/plugin-sdk/agent-harness-runtime";
4
4
  import { resolveOpenAICodexAuthIdentity } from "openclaw/plugin-sdk/provider-auth";
5
5
  //#region extensions/codex/src/app-server/auth-binding.ts
6
6
  var auth_binding_exports = /* @__PURE__ */ __exportAll({
@@ -74,4 +74,4 @@ async function fingerprintCodexAppServerAuthBinding(params) {
74
74
  return (await prepareCodexAppServerAuthBinding(params))?.fingerprint;
75
75
  }
76
76
  //#endregion
77
- export { prepareCodexAppServerAuthBinding as n, auth_binding_exports as t };
77
+ export { fingerprintCodexAppServerAuthBinding as n, prepareCodexAppServerAuthBinding as r, auth_binding_exports as t };