@openclaw/codex 2026.9.1-beta.1 → 2026.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/api.js +8 -9
  2. package/dist/{attempt-client-cleanup-bfsmcQ6m.js → attempt-client-cleanup-Bp1ZOnk2.js} +105 -75
  3. package/dist/attempt-context-CSazkWns.js +634 -0
  4. package/dist/{auth-binding-B4FfbcCg.js → auth-binding-Ds_QVm-X.js} +18 -3
  5. package/dist/{bounded-turn-B7iBUcuP.js → bounded-turn-DxGJRYbY.js} +53 -57
  6. package/dist/{capabilities-BRMh0aIq.js → capabilities-B1mgvpP8.js} +2 -1
  7. package/dist/cli-metadata.js +1 -1
  8. package/dist/{command-formatters-DEsIufkt.js → command-formatters-DSbGMXA0.js} +5 -4
  9. package/dist/{command-handlers-D_-1_qRp.js → command-handlers-DOJvGv6-.js} +243 -148
  10. package/dist/{compact-BglNFZrQ.js → compact-Y_xBqrHN.js} +109 -65
  11. package/dist/{config-giW8X0QA.js → config-CyapYSji.js} +328 -374
  12. package/dist/config-utils-C57JiJrU.js +69 -0
  13. package/dist/{context-compaction-activity-BOeJf7yo.js → context-compaction-activity-CMla5FPJ.js} +4 -1
  14. package/dist/{conversation-binding-data-CW2GuupV.js → conversation-binding-data-BiodpIzq.js} +2 -1
  15. package/dist/doctor-contract-api.js +144 -14
  16. package/dist/{dynamic-tools-Dnlfa--w.js → dynamic-tools-BwpvTxaX.js} +1119 -1135
  17. package/dist/{effective-mcp-catalog-CTeGrnfO.js → effective-mcp-catalog-CY9Jn4bA.js} +4 -3
  18. package/dist/{event-projector-assistant-message-C5-Ds8mA.js → event-projector-assistant-message-B9kp6iGC.js} +15 -6
  19. package/dist/event-projector-usage-ZqEVbAEY.js +212 -0
  20. package/dist/{harness-Csz0F-DK.js → harness-Czh2Sdoc.js} +65 -52
  21. package/dist/harness.js +1 -1
  22. package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
  23. package/dist/index.js +495 -457
  24. package/dist/{isolated-completion-Cv6FqygM.js → isolated-completion-CRh-51AK.js} +9 -21
  25. package/dist/{managed-binary-DFYK4DWq.js → managed-binary-DcpnJF9x.js} +117 -80
  26. package/dist/media-understanding-provider.js +1 -1
  27. package/dist/model-catalog-DT5vo6qo.js +101 -0
  28. package/dist/{models-TS3HBU-q.js → models-CcrgSMQR.js} +26 -29
  29. package/dist/{native-subagent-monitor-4Mfq2HDs.js → native-subagent-monitor-B3bvQGcg.js} +63 -122
  30. package/dist/{node-exec-server.runtime-BpWqJO1V.js → node-exec-server.runtime-nfbUOtUB.js} +10 -7
  31. package/dist/{plugin-approval-roundtrip-bUm777tR.js → plugin-approval-roundtrip-aQVdyL5g.js} +30 -3
  32. package/dist/{plugin-marketplace-discovery-B9DvaAG-.js → plugin-marketplace-discovery-B7gHXJ3d.js} +44 -30
  33. package/dist/{plugin-metadata-cache-CTCT3w5L.js → plugin-metadata-cache-BwCLTY_U.js} +6 -6
  34. package/dist/provider-capabilities-BpG9Ltc5.js +101 -0
  35. package/dist/{rate-limits-C5_D8Gmb.js → rate-limits-Fx_l4eNa.js} +3 -2
  36. package/dist/{sandbox-guard-kuWTn9C5.js → request-C8H22rPi.js} +195 -2
  37. package/dist/{run-attempt-DYc0QCBF.js → run-attempt-BzthFQSM.js} +1616 -2634
  38. package/dist/{runtime-artifact-BvyT1uyd.js → runtime-artifact-Bh_gf6-t.js} +22 -15
  39. package/dist/{session-binding-Bcynfd-_.js → session-binding-4Ki04sW-.js} +282 -399
  40. package/dist/session-binding-record-CyaXZvTe.js +270 -0
  41. package/dist/{session-catalog-DaLKVtpH.js → session-catalog-B47uwekb.js} +812 -504
  42. package/dist/{session-cli-DMc4oS2w.js → session-cli-BjLhpmS1.js} +1 -1
  43. package/dist/session-history-DWmMqiqW.js +93 -0
  44. package/dist/session-history-read-LHldwvyh.js +36 -0
  45. package/dist/session-history-worker-runtime.js +48 -0
  46. package/dist/session-history.worker-zZVcx0ME.js +267 -0
  47. package/dist/session-history.worker.js +2 -0
  48. package/dist/session-initialization-BCFVnLL4.js +75 -0
  49. package/dist/{session-permission-policy-BrNH1bjy.js → session-permission-policy-BaueHmSj.js} +2 -2
  50. package/dist/session-retirement-DNdmYdFc.js +97 -0
  51. package/dist/{session-upstream-marker-BIkusb95.js → session-upstream-marker-DReTpGz6.js} +20 -4
  52. package/dist/settled-turn-context-BOM3Y1pl.js +45 -0
  53. package/dist/settled-turn-finalizer-BI-b1sry.js +115 -0
  54. package/dist/{shared-client-DKz23hHY.js → shared-client-CKhX2kFt.js} +3659 -847
  55. package/dist/{side-question-DjA_jsNe.js → side-question-B6DWAw1A.js} +168 -81
  56. package/dist/{thread-lifecycle-L7oEkTlq.js → thread-lifecycle-DPK30jad.js} +2412 -2145
  57. package/dist/{thread-ownership-DZeuKH1j.js → thread-ownership-CbucAmmp.js} +27 -16
  58. package/dist/thread-policy-CTalhWFy.js +105 -0
  59. package/dist/{plugin-app-cache-key-C1CAdfcP.js → thread-resume-BLgqkUc1.js} +61 -9
  60. package/dist/{transcript-mirror-DsCMWBca.js → transcript-mirror-_njEB84z.js} +114 -110
  61. package/dist/transcript-mirror-attestation-Byl34PC-.js +76 -0
  62. package/dist/transport-stdio-CzTngV0j.js +728 -0
  63. package/dist/{upstream-prompt-provenance-CFmsKwr9.js → upstream-prompt-provenance-LphB8slG.js} +8 -4
  64. package/dist/upstream-session-fork-1fwbNKzQ.js +886 -0
  65. package/dist/{usage-ROIaW3wo.js → usage-i9fv5-4m.js} +3 -3
  66. package/dist/{web-search-provider.runtime-ClaNPV7N.js → web-search-provider.runtime-DKQn67A7.js} +3 -3
  67. package/openclaw.plugin.json +1 -30
  68. package/package.json +6 -6
  69. package/dist/binding-connection-BMvPX73o.js +0 -45
  70. package/dist/command-rpc-CCeCkf_v.js +0 -90
  71. package/dist/event-projector-usage-Bk1I90Bg.js +0 -328
  72. package/dist/incognito-session-ET_ufDH-.js +0 -2
  73. package/dist/model-catalog-i9rNBthX.js +0 -48
  74. package/dist/protocol-validators-VeJxxJ0U.js +0 -2421
  75. package/dist/request-DXXGHko0.js +0 -157
  76. package/dist/session-catalog-home-id-BNwAJ9D7.js +0 -18
  77. package/dist/session-retirement-CcNC3YSY.js +0 -36
  78. package/dist/settled-turn-finalizer-Dc3ApjU4.js +0 -328
  79. package/dist/thread-resume-BE9qNEW0.js +0 -30
  80. package/dist/transport-stdio-DhoGy33Z.js +0 -99
  81. package/dist/upstream-session-fork-DlaHxSLC.js +0 -326
@@ -1,15 +1,21 @@
1
- import { $ as releaseCodexAppServerLiveThread, Z as isCodexAppServerLiveThreadClaimed, et as retainCodexAppServerLiveThread, h as retainSharedCodexAppServerClientByInstanceId } from "./shared-client-DKz23hHY.js";
2
- import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-bfsmcQ6m.js";
1
+ import { Mt as retainCodexAppServerLiveThread, Ot as isCodexAppServerLiveThreadClaimed, _ as retainSharedCodexAppServerClientByInstanceId, jt as releaseCodexAppServerLiveThread } from "./shared-client-CKhX2kFt.js";
2
+ import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-Bp1ZOnk2.js";
3
+ import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
4
+ import { isIncognitoSessionKey } from "openclaw/plugin-sdk/routing";
3
5
  import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
4
6
  //#region extensions/codex/src/app-server/thread-ownership.ts
5
- const nativeThreadOwners = new KeyedAsyncQueue();
7
+ const nativeThreadOwners = resolveGlobalSingleton(Symbol.for("openclaw.codexNativeThreadOwners"), () => new KeyedAsyncQueue());
8
+ /** Serialize OpenClaw-owned lifecycle changes, not native-internal thread controllers. */
9
+ async function withCodexAppServerThreadMutation(threadId, run) {
10
+ return await nativeThreadOwners.enqueue(`thread:${threadId}`, run);
11
+ }
6
12
  /** Codex subscriptions belong to a physical connection, not the native thread ID alone. */
7
13
  function isSameCodexAppServerThreadOwner(current, expected) {
8
14
  return current !== void 0 && expected !== void 0 && current.threadId === expected.threadId && current.clientId === expected.clientId;
9
15
  }
10
16
  /** Fences native subscription and commit together; Codex subscriptions are not reference-counted. */
11
17
  async function withExclusiveCodexAppServerThread(params) {
12
- return await nativeThreadOwners.enqueue(`thread:${params.threadId}`, async () => {
18
+ return await withCodexAppServerThreadMutation(params.threadId, async () => {
13
19
  if (await params.bindingStore.hasOtherThreadOwner(params.threadId, params.identity)) throw new Error(`Codex thread ${params.threadId} is owned by another OpenClaw session or conversation.`);
14
20
  return await params.run();
15
21
  });
@@ -18,17 +24,19 @@ async function withExclusiveCodexAppServerThread(params) {
18
24
  async function withCodexConversationThreadActivity(bindingId, run) {
19
25
  return await nativeThreadOwners.enqueue(`conversation:${bindingId}`, run);
20
26
  }
21
- /** Publishes one owned persistent subscription into the shared bounded idle registry. */
27
+ /** Publishes one owned subscription with its persistent or ephemeral retention lifetime. */
22
28
  async function retainCodexAppServerBindingSubscription(client, threadId, ownership) {
23
- return await retainCodexAppServerLiveThread(client, threadId, ownership?.release ?? (async (releasedThreadId) => {
29
+ return await retainCodexAppServerLiveThread(client, threadId, ownership?.release ?? (async (releasedThreadId, assertCurrent) => {
24
30
  if (!await unsubscribeCodexThreadBestEffort(client, {
25
31
  threadId: releasedThreadId,
26
- timeoutMs: 5e3
32
+ timeoutMs: 5e3,
33
+ assertCurrent
27
34
  })) {
35
+ assertCurrent?.();
28
36
  await closeCodexStartupClientBestEffort(client);
29
37
  throw new CodexAppServerUnsafeSubscriptionError(`Codex thread subscription could not be released: ${releasedThreadId}`);
30
38
  }
31
- }), ownership?.configFingerprint, ownership?.serviceTier);
39
+ }), ownership?.configFingerprint, ownership?.serviceTier, ownership?.ephemeralPolicy);
32
40
  }
33
41
  /** Rolls back the exact subscription Codex created before its binding was committed. */
34
42
  async function rollbackCodexAppServerBindingSubscription(client, threadId, retained) {
@@ -41,15 +49,18 @@ async function rollbackCodexAppServerBindingSubscription(client, threadId, retai
41
49
  }
42
50
  /** Releases only the physical client and native thread recorded by the displaced binding owner. */
43
51
  async function releaseCodexAppServerBindingSubscription(binding, options = {}) {
52
+ options.assertCurrent?.();
44
53
  const clientLease = retainSharedCodexAppServerClientByInstanceId(binding.clientId);
45
54
  if (!clientLease) return;
46
55
  try {
47
- if (await releaseCodexAppServerLiveThread(clientLease.client, binding.threadId)) return;
56
+ if (await releaseCodexAppServerLiveThread(clientLease.client, binding.threadId, options.assertCurrent)) return;
57
+ options.assertCurrent?.();
48
58
  if (isCodexAppServerLiveThreadClaimed(clientLease.client, binding.threadId)) throw new Error(`Codex thread ${binding.threadId} has an active run; stop it before changing its owner.`);
49
59
  if (!options.allowUntracked) return;
50
60
  if (!await unsubscribeCodexThreadBestEffort(clientLease.client, {
51
61
  threadId: binding.threadId,
52
- timeoutMs: 5e3
62
+ timeoutMs: 5e3,
63
+ assertCurrent: options.assertCurrent
53
64
  })) {
54
65
  await closeCodexStartupClientBestEffort(clientLease.client);
55
66
  throw new CodexAppServerUnsafeSubscriptionError(`Codex retired thread subscription could not be released: ${binding.threadId}`);
@@ -60,11 +71,11 @@ async function releaseCodexAppServerBindingSubscription(binding, options = {}) {
60
71
  }
61
72
  /** Clears and releases one exact conversation generation without touching its replacement. */
62
73
  async function retireCodexConversationThreadBinding(params) {
63
- const expected = await params.bindingStore.read(params.identity);
74
+ const expected = params.bindingStore.read(params.identity);
64
75
  if (!expected || params.expectedThreadId && expected.threadId !== params.expectedThreadId) return false;
65
- return await params.bindingStore.withLease(params.identity, async () => {
66
- const current = await params.bindingStore.read(params.identity);
67
- if (current?.threadId !== expected.threadId || params.expectedStartId && current.conversationStartId !== params.expectedStartId) return false;
76
+ return await withCodexAppServerThreadMutation(expected.threadId, () => params.bindingStore.withLease(params.identity, async () => {
77
+ const current = params.bindingStore.read(params.identity);
78
+ if (!current || !isSameCodexAppServerThreadOwner(current, expected) || params.expectedStartId && current?.conversationStartId !== params.expectedStartId) return false;
68
79
  await releaseCodexAppServerBindingSubscription(current, { allowUntracked: params.allowUntracked });
69
80
  const cleared = await params.bindingStore.mutate(params.identity, {
70
81
  kind: "clear",
@@ -86,7 +97,7 @@ async function retireCodexConversationThreadBinding(params) {
86
97
  }
87
98
  throw error;
88
99
  }
89
- });
100
+ }));
90
101
  }
91
102
  //#endregion
92
- export { rollbackCodexAppServerBindingSubscription as a, retireCodexConversationThreadBinding as i, releaseCodexAppServerBindingSubscription as n, withCodexConversationThreadActivity as o, retainCodexAppServerBindingSubscription as r, withExclusiveCodexAppServerThread as s, isSameCodexAppServerThreadOwner as t };
103
+ export { rollbackCodexAppServerBindingSubscription as a, withExclusiveCodexAppServerThread as c, retireCodexConversationThreadBinding as i, isIncognitoSessionKey as l, releaseCodexAppServerBindingSubscription as n, withCodexAppServerThreadMutation as o, retainCodexAppServerBindingSubscription as r, withCodexConversationThreadActivity as s, isSameCodexAppServerThreadOwner as t };
@@ -0,0 +1,105 @@
1
+ import { O as readCodexPluginConfig, i as resolveCodexAppServerRuntimeOptions, s as resolveCodexSupervisionAppServerRuntimeOptions } from "./config-CyapYSji.js";
2
+ import { H as isCodexAppServerOverloadError, U as isCodexAppServerPrewriteRequestCancellationError } from "./shared-client-CKhX2kFt.js";
3
+ import { n as buildCodexAppServerConnectionFingerprint, o as resolveCodexCatalogConnectionHome } from "./thread-resume-BLgqkUc1.js";
4
+ import { r as requestCodexAppServerClientJson, t as CodexAppServerScopedRequestRejectedError } from "./request-C8H22rPi.js";
5
+ import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-runtime";
6
+ //#region extensions/codex/src/app-server/binding-connection.ts
7
+ /** Prevents a prepared native session from becoming a fresh thread after its binding changes. */
8
+ function assertCodexSessionRuntimeOwnership(binding, expected) {
9
+ if (!expected) return;
10
+ const auth = binding?.connectionScope === "supervision" ? "native" : "host";
11
+ const hostModelChanged = expected.auth === "host" && (!expected.modelRef || binding?.model !== expected.modelRef.model || binding?.modelProvider !== expected.modelRef.provider);
12
+ 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.");
13
+ }
14
+ /** Requires the native model pair after a supervised pending branch has materialized. */
15
+ function requireCodexSupervisionModelSelection(binding) {
16
+ const model = binding.model?.trim();
17
+ const modelProvider = binding.modelProvider?.trim();
18
+ if (binding.connectionScope !== "supervision" || !model || !modelProvider) throw new Error("Codex supervised binding is missing its native model and provider; refusing request selection");
19
+ return {
20
+ model,
21
+ modelProvider
22
+ };
23
+ }
24
+ /** Resolves connection and auth ownership exclusively from the private thread binding. */
25
+ function resolveCodexBindingAppServerConnection(params) {
26
+ const { binding, authProfileId, ...runtimeParams } = params;
27
+ const usesSupervisionConnection = binding?.connectionScope === "supervision";
28
+ if (usesSupervisionConnection && readCodexPluginConfig(runtimeParams.pluginConfig).supervision?.enabled !== true) throw new Error("Codex supervision is disabled; refusing to open a native user-home supervised session");
29
+ let appServer = (usesSupervisionConnection ? resolveCodexSupervisionAppServerRuntimeOptions : resolveCodexAppServerRuntimeOptions)(runtimeParams);
30
+ if (usesSupervisionConnection) {
31
+ const persistedFingerprint = binding.pendingSupervisionBranch?.connectionFingerprint ?? binding.appServerRuntimeFingerprint;
32
+ const catalogHome = persistedFingerprint ? resolveCodexCatalogConnectionHome(persistedFingerprint, runtimeParams.agentDir) : void 0;
33
+ if (catalogHome) appServer = {
34
+ ...appServer,
35
+ start: {
36
+ ...appServer.start,
37
+ homeScope: "user",
38
+ env: {
39
+ ...appServer.start.env,
40
+ CODEX_HOME: catalogHome
41
+ }
42
+ }
43
+ };
44
+ const currentFingerprint = buildCodexAppServerConnectionFingerprint(appServer, runtimeParams.agentDir);
45
+ if (!persistedFingerprint || persistedFingerprint !== currentFingerprint) throw new Error("Codex supervision connection changed; refusing to operate on its bound native thread");
46
+ }
47
+ return {
48
+ appServer,
49
+ usesSupervisionConnection,
50
+ requestAuthProfileId: usesSupervisionConnection ? void 0 : authProfileId,
51
+ clientAuthProfileId: usesSupervisionConnection ? null : authProfileId
52
+ };
53
+ }
54
+ //#endregion
55
+ //#region extensions/codex/src/app-server/thread-policy.ts
56
+ /** A refusal, not a failed native write: the ephemeral conversation must stay alive. */
57
+ var CodexIncognitoPolicyChangeError = class extends AgentHarnessPreflightError {
58
+ constructor() {
59
+ super("Codex cannot change generic instructions in a live incognito conversation. No turn was sent and the conversation is preserved. Restore the previous instructions to continue it, or start a new incognito conversation for the changed policy.");
60
+ this.name = "CodexIncognitoPolicyChangeError";
61
+ }
62
+ };
63
+ /** Never replay a handoff: native persistence can precede an unsuccessful RPC response. */
64
+ var CodexThreadPolicyHandoffError = class extends AgentHarnessPreflightError {
65
+ constructor(outcome, cause) {
66
+ super(`Codex session policy handoff failed: ${cause instanceof Error ? cause.message : String(cause)}. The conversation is preserved; reconnect before retrying.`, { cause });
67
+ this.outcome = outcome;
68
+ this.name = "CodexThreadPolicyHandoffError";
69
+ }
70
+ };
71
+ /** The complete body remains generic configuration for compaction and native child inheritance. */
72
+ async function refreshCodexThreadPolicy(params) {
73
+ const text = "The following is the complete current OpenClaw-supplied generic instruction policy. It replaces earlier OpenClaw-supplied generic policy, including OpenClaw-carried workspace text and sections now absent. Independently supplied native managed, guardian, security, collaboration, and project instructions retain their authority. User requests retain their own authority.\n\n" + (params.developerInstructions === "" ? "The current OpenClaw generic policy is empty; earlier OpenClaw generic policy is withdrawn." : params.developerInstructions);
74
+ let outcome = "unknown";
75
+ try {
76
+ await requestCodexAppServerClientJson({
77
+ ...params,
78
+ method: "thread/inject_items",
79
+ requestParams: {
80
+ threadId: params.threadId,
81
+ items: [{
82
+ type: "message",
83
+ role: "developer",
84
+ content: [{
85
+ type: "input_text",
86
+ text
87
+ }]
88
+ }]
89
+ }
90
+ });
91
+ outcome = "acknowledged";
92
+ params.assertCurrent();
93
+ params.signal?.throwIfAborted();
94
+ } catch (cause) {
95
+ if (outcome !== "acknowledged" && (cause instanceof CodexAppServerScopedRequestRejectedError || isCodexAppServerPrewriteRequestCancellationError(cause) || isCodexAppServerOverloadError(cause))) outcome = "not-written";
96
+ throw new CodexThreadPolicyHandoffError(outcome, cause);
97
+ }
98
+ }
99
+ /** Native lineage classifies the exact bound thread; it never grants session authority. */
100
+ function assertCodexSupervisionThreadLineage(binding, thread) {
101
+ if (binding.connectionScope !== "supervision" || binding.pendingSupervisionBranch) return;
102
+ if (thread.id !== binding.threadId || !binding.supervisionSourceThreadId || thread.forkedFromId !== null && (typeof thread.forkedFromId !== "string" || !thread.forkedFromId.trim() || thread.forkedFromId === thread.id)) throw new Error("Codex supervision lineage could not be verified; reconnect before continuing.");
103
+ }
104
+ //#endregion
105
+ export { assertCodexSessionRuntimeOwnership as a, refreshCodexThreadPolicy as i, CodexThreadPolicyHandoffError as n, requireCodexSupervisionModelSelection as o, assertCodexSupervisionThreadLineage as r, resolveCodexBindingAppServerConnection as s, CodexIncognitoPolicyChangeError as t };
@@ -1,11 +1,13 @@
1
- import { S as resolveCodexAppServerUserHomeDir } from "./config-giW8X0QA.js";
2
- import { St as resolveCodexAppServerLocalHomeDir, xt as resolveCodexAppServerHomeDir } from "./shared-client-DKz23hHY.js";
1
+ import { M as resolveCodexAppServerHomeDir, N as resolveCodexAppServerLocalHomeDir, P as resolveCodexAppServerUserHomeDir } from "./config-CyapYSji.js";
2
+ import { H as isCodexAppServerOverloadError, M as isCodexAppServerStartupError, U as isCodexAppServerPrewriteRequestCancellationError, q as CodexAppServerRpcError, tt as assertCodexThreadResumeResponse, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-CKhX2kFt.js";
3
+ import { d as unsubscribeCodexThreadBestEffort, i as assertCodexThreadResumeSubscription, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-Bp1ZOnk2.js";
4
+ import { t as CodexAppServerScopedRequestRejectedError } from "./request-C8H22rPi.js";
3
5
  import { createRequire } from "node:module";
4
6
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
5
- import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
7
+ import { createHash } from "node:crypto";
6
8
  import { isFutureDateTimestampMs, resolveDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
9
+ import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
7
10
  import { OPENCLAW_VERSION, embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
8
- import { createHash } from "node:crypto";
9
11
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
10
12
  //#region extensions/codex/src/app-server/app-inventory-cache.ts
11
13
  /**
@@ -13,7 +15,7 @@ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
13
15
  * identity and safe to refresh in the background.
14
16
  */
15
17
  /** Default app inventory cache freshness window. */
16
- const CODEX_APP_INVENTORY_CACHE_TTL_MS = 3600 * 1e3;
18
+ const CODEX_APP_INVENTORY_CACHE_TTL_MS = 36e5;
17
19
  const CODEX_APP_READ_BATCH_LIMIT = 100;
18
20
  const MAX_SERIALIZED_ERROR_MESSAGE_LENGTH = 500;
19
21
  /** In-memory app inventory cache with coalesced refreshes per key. */
@@ -264,7 +266,10 @@ async function readInstalledApps(request, options) {
264
266
  apps: [],
265
267
  installedApps: []
266
268
  };
267
- const metadataResponses = await Promise.all(Array.from({ length: Math.ceil(apps.length / CODEX_APP_READ_BATCH_LIMIT) }, (_, index) => request("app/read", { appIds: apps.slice(index * CODEX_APP_READ_BATCH_LIMIT, (index + 1) * CODEX_APP_READ_BATCH_LIMIT).map((app) => app.id) })));
269
+ const metadataResponses = await Promise.all(Array.from({ length: Math.ceil(apps.length / CODEX_APP_READ_BATCH_LIMIT) }, (_, index) => request("app/read", {
270
+ appIds: apps.slice(index * CODEX_APP_READ_BATCH_LIMIT, (index + 1) * CODEX_APP_READ_BATCH_LIMIT).map((app) => app.id),
271
+ includeTools: true
272
+ })));
268
273
  const metadataById = new Map(metadataResponses.flatMap((response) => response.apps).map((metadata) => [metadata.id, metadata]));
269
274
  return {
270
275
  apps: apps.flatMap((installedApp) => {
@@ -283,7 +288,8 @@ async function readInstalledApps(request, options) {
283
288
  installUrl: metadata.installUrl ?? null,
284
289
  isAccessible: true,
285
290
  isEnabled: installedApp.enabled,
286
- pluginDisplayNames: metadata.pluginDisplayNames
291
+ pluginDisplayNames: metadata.pluginDisplayNames,
292
+ ...metadata.toolSummaries ? { toolSummaries: metadata.toolSummaries } : {}
287
293
  }];
288
294
  }),
289
295
  installedApps: apps
@@ -330,7 +336,8 @@ function isSensitiveErrorDataKey(key) {
330
336
  * Builds stable Codex plugin/app inventory cache keys from app-server startup,
331
337
  * auth, account, and version inputs without storing secret material.
332
338
  */
333
- const CODEX_PLUGIN_VERSION = readPluginPackageVersion({ require: createRequire(import.meta.url) });
339
+ const require = createRequire(import.meta.url);
340
+ const CODEX_PLUGIN_VERSION = readPluginPackageVersion({ require });
334
341
  let catalogConnectionHomes = /* @__PURE__ */ new Map();
335
342
  function catalogConnectionHomeKey(fingerprint, agentDir) {
336
343
  return `${agentDir ?? ""}\0${fingerprint}`;
@@ -420,4 +427,49 @@ function fingerprintCodexPluginAppCacheCredentials(startOptions) {
420
427
  return `sha256:${hash.digest("hex")}`;
421
428
  }
422
429
  //#endregion
423
- export { resolveCodexCatalogConnectionHome as a, replaceCodexCatalogConnectionHomes as i, buildCodexAppServerRuntimeFingerprint as n, defaultCodexAppInventoryCache as o, buildCodexPluginAppCacheKey as r, serializeCodexAppInventoryError as s, buildCodexAppServerConnectionFingerprint as t };
430
+ //#region extensions/codex/src/app-server/thread-resume.ts
431
+ /** Owns Codex thread/resume subscription safety. */
432
+ /** Resumes one thread, releasing or isolating every possible native subscription. */
433
+ async function resumeCodexAppServerThread(params) {
434
+ const threadId = params.request.threadId;
435
+ let response;
436
+ let ownershipRejected = false;
437
+ const assertCurrent = params.assertCurrent && (() => {
438
+ try {
439
+ params.assertCurrent?.();
440
+ } catch (error) {
441
+ ownershipRejected = true;
442
+ throw error;
443
+ }
444
+ });
445
+ try {
446
+ response = assertCodexThreadResumeResponse(await (params.requestResume ? params.requestResume(params.request) : params.client.request("thread/resume", params.request, {
447
+ ...params.timeoutMs !== void 0 ? { timeoutMs: params.timeoutMs } : {},
448
+ ...params.signal ? { signal: params.signal } : {},
449
+ assertCurrent
450
+ })));
451
+ assertCodexThreadResumeSubscription(threadId, response.thread.id);
452
+ } catch (error) {
453
+ if (ownershipRejected || isCodexAppServerStartSelectionChangedError(error) || isCodexAppServerStartupError(error) || error instanceof CodexAppServerScopedRequestRejectedError || isCodexAppServerPrewriteRequestCancellationError(error) || isCodexAppServerOverloadError(error)) throw error;
454
+ if (error instanceof CodexAppServerRpcError) {
455
+ if (await unsubscribeCodexThreadBestEffort(params.client, {
456
+ threadId,
457
+ timeoutMs: 5e3,
458
+ assertCurrent: params.assertCurrent
459
+ }).catch(() => false)) {
460
+ params.onSubscriptionReleased?.();
461
+ throw error;
462
+ }
463
+ }
464
+ try {
465
+ await params.abandonClient();
466
+ } catch (abandonError) {
467
+ throw new CodexAppServerUnsafeSubscriptionError(`Codex thread/resume client could not be retired for ${threadId}`, { cause: abandonError });
468
+ }
469
+ if (error instanceof CodexAppServerUnsafeSubscriptionError) throw error;
470
+ throw new CodexAppServerUnsafeSubscriptionError(error instanceof Error ? error.message : `Codex thread/resume outcome is indeterminate for ${threadId}`, { cause: error });
471
+ }
472
+ return response;
473
+ }
474
+ //#endregion
475
+ export { replaceCodexCatalogConnectionHomes as a, defaultCodexAppInventoryCache as c, buildCodexPluginAppCacheKey as i, serializeCodexAppInventoryError as l, buildCodexAppServerConnectionFingerprint as n, resolveCodexCatalogConnectionHome as o, buildCodexAppServerRuntimeFingerprint as r, CodexAppInventoryCache as s, resumeCodexAppServerThread as t };