@openclaw/codex 2026.9.3 → 2026.9.5

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 (146) hide show
  1. package/assets/activity.svg +30 -0
  2. package/assets/icon.png +0 -0
  3. package/dist/.setup/account-usage-runtime-C2MOIvfq.mjs +75 -0
  4. package/dist/{apply-B6el6hdO.js → .setup/apply-CJ0ZfmBG.mjs} +12 -13
  5. package/dist/.setup/async-questions-DdhOCwGi.mjs +27 -0
  6. package/dist/{attempt-client-cleanup-D6cR54TV.js → .setup/attempt-client-cleanup-BpYKdTA0.mjs} +30 -211
  7. package/dist/{attempt-context-AO4DSjE0.js → .setup/attempt-context-VXVwTCfS.mjs} +6 -6
  8. package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +5 -0
  9. package/dist/{auth-binding-Co2Vfcf_.js → .setup/auth-binding-DhLWa_7K.mjs} +2 -2
  10. package/dist/{auth-cache-key-Kq6oerr6.js → .setup/auth-cache-key-QirmgiCo.mjs} +3 -3
  11. package/dist/{auth-profile-CwzO4_RG.js → .setup/auth-profile-WqZtZfXN.mjs} +1 -1
  12. package/dist/.setup/binding-connection-Bm38niE8.mjs +50 -0
  13. package/dist/.setup/binding-connection.runtime-CnRMC0ta.mjs +48 -0
  14. package/dist/{bounded-turn-lRpmZHFv.js → .setup/bounded-turn-BtlZcivC.mjs} +19 -14
  15. package/dist/{build-state-6RL6qohz.js → .setup/build-state-Xx9ybZqa.mjs} +1 -1
  16. package/dist/{capabilities-BeqLPbtM.js → .setup/capabilities-_vXcZGSx.mjs} +1 -1
  17. package/dist/{client-BEKu4yDx.js → .setup/client-vXs2929Q.mjs} +355 -164
  18. package/dist/{command-dispatch-CisT9Jqq.js → .setup/command-dispatch-naHIZwwF.mjs} +3 -3
  19. package/dist/{command-formatters-DeTfrapr.js → .setup/command-formatters-CGEkdawF.mjs} +4 -3
  20. package/dist/{command-handlers-BfIsJEuA.js → .setup/command-handlers-BtAJEW1X.mjs} +812 -152
  21. package/dist/{command-rpc-BMqRQOFX.js → .setup/command-rpc-DHFpn4le.mjs} +37 -21
  22. package/dist/{compact-CGJZ2rlb.js → .setup/compact-C3i3qlzj.mjs} +28 -43
  23. package/dist/{config-JDfTI4VI.js → .setup/config-CedDWjM-.mjs} +5 -4
  24. package/dist/{config-options-jnIFvwxD.js → .setup/config-options-BsanJ8QG.mjs} +9 -421
  25. package/dist/{protocol-CAAcVIKF.js → .setup/config-parsing-CcB9iPoq.mjs} +9 -51
  26. package/dist/{config-runtime-BWf6JLWG.js → .setup/config-runtime-CeAhl_h4.mjs} +2 -2
  27. package/dist/.setup/config-security-BRQ2mgW9.mjs +465 -0
  28. package/dist/{config-utils-C57JiJrU.js → .setup/config-utils-DujwEnhg.mjs} +2 -4
  29. package/dist/{conversation-binding-CxOlHiix.js → .setup/conversation-binding-DhzrpTM6.mjs} +60 -47
  30. package/dist/{conversation-binding-data-BiodpIzq.js → .setup/conversation-binding-data-CrcyZk6O.mjs} +1 -1
  31. package/dist/{conversation-control-CUCrSIQI.js → .setup/conversation-control-DN53ns41.mjs} +17 -13
  32. package/dist/.setup/cyber-failover-DYwbmf1o.mjs +123 -0
  33. package/dist/.setup/cyber-failover-notice-e9G3J9-e.mjs +17 -0
  34. package/dist/{dynamic-tools-D-JBoaLt.js → .setup/dynamic-tools-D16lOp67.mjs} +168 -61
  35. package/dist/{effective-mcp-catalog-J_5Ep5Um.js → .setup/effective-mcp-catalog-K6kLCN8X.mjs} +3 -3
  36. package/dist/{ephemeral-turn-DSwzP8YY.js → .setup/ephemeral-turn-R1gA8Sn6.mjs} +4 -5
  37. package/dist/{event-projector-assistant-message-BmBM4qBV.js → .setup/event-projector-assistant-message-DNUR1s0A.mjs} +6 -3
  38. package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +200 -0
  39. package/dist/{attempt-notifications--H8zXR5-.js → .setup/event-projector-usage-C7Ntzs-f.mjs} +102 -9
  40. package/dist/{harness-FR6eQgyO.js → .setup/harness-rxaaoN-o.mjs} +90 -19
  41. package/dist/.setup/inference-context-fulhZuz8.mjs +94 -0
  42. package/dist/.setup/inference-proxy-CC15HuSi.mjs +311 -0
  43. package/dist/{isolated-completion-DHBefrzg.js → .setup/isolated-completion-B6srt48J.mjs} +7 -7
  44. package/dist/{launch-args-RXQwn8zV.js → .setup/launch-args-DnMak49W.mjs} +22 -1
  45. package/dist/{managed-binary-DrjjRRUD.js → .setup/managed-binary-DP6Rib3P.mjs} +11 -2
  46. package/dist/{managed-thread-store-D1t5jh3G.js → .setup/managed-thread-store-BMqgThVL.mjs} +48 -14
  47. package/dist/{model-catalog-B_6M04Wo.js → .setup/model-catalog-DkvUuBey.mjs} +35 -10
  48. package/dist/{models-P9k2qAof.js → .setup/models-BDFgm_G-.mjs} +3 -3
  49. package/dist/.setup/native-auth-BLZGqFjw.mjs +57 -0
  50. package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +135 -0
  51. package/dist/.setup/native-subagent-monitor-B1hxzIOy.mjs +5031 -0
  52. package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +411 -0
  53. package/dist/{node-cli-sessions-rj0ysJwM.js → .setup/node-cli-sessions-Cl8b2ZF3.mjs} +1 -1
  54. package/dist/{node-exec-server.runtime-BY_ctYnT.js → .setup/node-exec-server.runtime-BaViBKNz.mjs} +5 -5
  55. package/dist/{plan-BMJdMOEF.js → .setup/plan-xD7WKYTM.mjs} +331 -79
  56. package/dist/{plugin-activation-BQK-f5sV.js → .setup/plugin-activation-r8nq5Jzp.mjs} +24 -19
  57. package/dist/{plugin-app-cache-key-CdSQzWyX.js → .setup/plugin-app-cache-key-BOxKP7db.mjs} +29 -25
  58. package/dist/{plugin-approval-roundtrip-DeW95wB5.js → .setup/plugin-approval-roundtrip-CjfzafAZ.mjs} +1 -1
  59. package/dist/{plugin-inventory-CoRCzWW4.js → .setup/plugin-inventory-DUle8DLz.mjs} +12 -8
  60. package/dist/{plugin-marketplace-discovery-3akBizzF.js → .setup/plugin-marketplace-discovery-P-Vndfqq.mjs} +18 -15
  61. package/dist/{plugin-metadata-cache-DgNfRAGA.js → .setup/plugin-metadata-cache-DsS5buNa.mjs} +33 -14
  62. package/dist/{provider-capabilities-W4tfK5Y5.js → .setup/provider-capabilities-B8J4Dy-O.mjs} +2 -2
  63. package/dist/.setup/provider-fFh_-VR3.mjs +50 -0
  64. package/dist/{rate-limits-Bqnx1N4z.js → .setup/rate-limits-DOEGYRNs.mjs} +90 -46
  65. package/dist/.setup/request-BioXJLYa.mjs +292 -0
  66. package/dist/.setup/run-attempt-lifecycle-B7JbY4-F.mjs +71 -0
  67. package/dist/{run-attempt-DwKds3DN.js → .setup/run-attempt-rlA07pUv.mjs} +644 -491
  68. package/dist/{runtime-artifact-T-NwqeSH.js → .setup/runtime-artifact-Dy38Z5iU.mjs} +2 -2
  69. package/dist/{sandbox-guard-BcT66fWy.js → .setup/sandbox-guard-BBP-RbTf.mjs} +4 -3
  70. package/dist/{session-binding-CKSepwIC.js → .setup/session-binding-_0W_fHRr.mjs} +45 -63
  71. package/dist/{session-binding-record-CaZjYwNS.js → .setup/session-binding-record-TH3xA0zj.mjs} +181 -3
  72. package/dist/.setup/session-binding-sidecars-CKYEcfNn.mjs +543 -0
  73. package/dist/{session-catalog-adoption-BKLtSrwi.js → .setup/session-catalog-adoption-CR_whkEW.mjs} +6 -6
  74. package/dist/{session-catalog-archive-D0i2pGj2.js → .setup/session-catalog-archive-CwZaPacf.mjs} +6 -6
  75. package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +250 -0
  76. package/dist/.setup/session-catalog-fUdWDx-U.mjs +2464 -0
  77. package/dist/.setup/session-catalog-index-B141u15s.mjs +1070 -0
  78. package/dist/.setup/session-catalog-index-order-Cc5BzlQr.mjs +48 -0
  79. package/dist/.setup/session-catalog-index-state-BAuDztHN.mjs +180 -0
  80. package/dist/{session-catalog-parsing-CdD3JhdM.js → .setup/session-catalog-native-projection-ChV3cCtm.mjs} +213 -21
  81. package/dist/{session-catalog-node-adoption-BUuDYY8R.js → .setup/session-catalog-node-adoption-BVRsYOSh.mjs} +3 -3
  82. package/dist/{session-catalog-node-continue-CBtc4wkI.js → .setup/session-catalog-node-continue-Dowv8osw.mjs} +7 -7
  83. package/dist/.setup/session-catalog-projection-C1Bj9Jl-.mjs +414 -0
  84. package/dist/{session-cli-CbgaHh0f.js → .setup/session-cli-DIj-IE-E.mjs} +4 -4
  85. package/dist/{session-history-Cz-tOOYj.js → .setup/session-history-C--SrLI8.mjs} +10 -5
  86. package/dist/{session-history-import-DFN7sWRU.js → .setup/session-history-import-JHXT5Xfi.mjs} +4 -4
  87. package/dist/{session-history-read-cxPUxyVV.js → .setup/session-history-read-B3ZfSUbF.mjs} +2 -2
  88. package/dist/{session-history.worker-CNEvGaU5.js → .setup/session-history.worker-CpNj7H_P.mjs} +192 -89
  89. package/dist/{session-initialization-Jo86C60I.js → .setup/session-initialization-DH1z6fXn.mjs} +2 -2
  90. package/dist/{session-permission-policy-B22InTp_.js → .setup/session-permission-policy-DhurXY0l.mjs} +2 -2
  91. package/dist/{session-retirement-BSNG_mhf.js → .setup/session-retirement-CU87AOg9.mjs} +6 -6
  92. package/dist/{settled-turn-context-Du6gdUDd.js → .setup/settled-turn-context-fmwouT5I.mjs} +2 -2
  93. package/dist/{settled-turn-finalizer-BuLUrZl2.js → .setup/settled-turn-finalizer-CiY2bLFK.mjs} +10 -10
  94. package/dist/{shared-client-CVhez2Uo.js → .setup/shared-client-BpTtuLQ5.mjs} +495 -156
  95. package/dist/{side-question-DLbr2vUU.js → .setup/side-question-DSCZyoBD.mjs} +64 -47
  96. package/dist/{source-Da-h6f7e.js → .setup/source-Bjp4UQij.mjs} +15 -14
  97. package/dist/{thread-archive-guard-D1bP04Tf.js → .setup/thread-archive-guard-jmecf6OJ.mjs} +1 -1
  98. package/dist/.setup/thread-history-page-BTx-4xsg.mjs +83 -0
  99. package/dist/{thread-lifecycle-D1pzRwHB.js → .setup/thread-lifecycle-Cik28qWn.mjs} +330 -150
  100. package/dist/{thread-ownership-D6oASVRu.js → .setup/thread-ownership-skomxnIt.mjs} +4 -4
  101. package/dist/{thread-policy-D8kI7yAO.js → .setup/thread-policy-Cjs4B8xf.mjs} +3 -3
  102. package/dist/{thread-resume-T5cveyxA.js → .setup/thread-resume-BkNpj9Pz.mjs} +8 -5
  103. package/dist/.setup/timeout-DZF05XrR.mjs +63 -0
  104. package/dist/{session-catalog-home-id-D7-aLiNt.js → .setup/transcript-history-projection-DHNBDhCU.mjs} +73 -20
  105. package/dist/{transcript-mirror-t5TOccct.js → .setup/transcript-mirror-D4qp_leP.mjs} +15 -6
  106. package/dist/{transcript-mirror-attestation-DibE0krH.js → .setup/transcript-mirror-attestation-CzM-94NC.mjs} +4 -1
  107. package/dist/{transport-stdio-BGjHoYLr.js → .setup/transport-stdio-Cmx94Oiy.mjs} +149 -44
  108. package/dist/{upstream-session-fork-De-sLJ2r.js → .setup/upstream-session-fork-D3UKxgVD.mjs} +27 -26
  109. package/dist/{usage-CPPTmBvZ.js → .setup/usage-BOgBEKso.mjs} +4 -4
  110. package/dist/.setup/usage-limit-error-C0ow7DOc.mjs +166 -0
  111. package/dist/{version-omm6IPI3.js → .setup/version-CoqzXPgK.mjs} +1 -1
  112. package/dist/{web-search-provider.runtime-CSVgQL0w.js → .setup/web-search-provider.runtime-CTGuJt6i.mjs} +3 -3
  113. package/dist/api.js +28 -20
  114. package/dist/cli-metadata.js +1 -1
  115. package/dist/doctor-contract-api.js +8 -528
  116. package/dist/harness.js +1 -1
  117. package/dist/index.js +130 -135
  118. package/dist/media-understanding-provider.js +3 -3
  119. package/dist/migration-provider-api.js +2 -0
  120. package/dist/native-tool-policy.js +12 -0
  121. package/dist/provider-discovery.js +18 -0
  122. package/dist/session-history-worker-runtime.js +23 -5
  123. package/dist/session-history.worker.js +2 -2
  124. package/dist/web-search-contract-api.js +1 -1
  125. package/openclaw.plugin.json +354 -68
  126. package/package.json +11 -8
  127. package/dist/binding-connection-QqgcPCgk.js +0 -60
  128. package/dist/event-projector-usage-CIyrYYid.js +0 -102
  129. package/dist/native-subagent-monitor-BbCUKRwC.js +0 -3350
  130. package/dist/request-CGvGOpeR.js +0 -198
  131. package/dist/session-catalog-HaDcp7Sv.js +0 -1533
  132. package/dist/session-catalog-provenance-DkJHo735.js +0 -124
  133. package/dist/timeout-BVw8aaM1.js +0 -33
  134. package/dist/{auth-profile-selection-DFu9e167.js → .setup/auth-profile-selection-DFu9e167.mjs} +0 -0
  135. package/dist/{context-compaction-activity-CMla5FPJ.js → .setup/context-compaction-activity-CMla5FPJ.mjs} +0 -0
  136. package/dist/{elicitation-input-DPoK8F7w.js → .setup/elicitation-input-DPoK8F7w.mjs} +0 -0
  137. package/dist/{history-rejection-B4nOXNXF.js → .setup/history-rejection-B4nOXNXF.mjs} +0 -0
  138. package/dist/{image-payload-sanitizer-tupAr-2o.js → .setup/image-payload-sanitizer-tupAr-2o.mjs} +0 -0
  139. package/dist/{incognito-session-uhrBF6wJ.js → .setup/incognito-session-uhrBF6wJ.mjs} +0 -0
  140. package/dist/{local-runtime-attribution-B_2mnqhb.js → .setup/local-runtime-attribution-B_2mnqhb.mjs} +0 -0
  141. package/dist/{native-execution-policy-umd0tgh4.js → .setup/native-execution-policy-YBMHSzC4.mjs} +1 -1
  142. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  143. /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
  144. /package/dist/{session-upstream-marker-D15C9NHp.js → .setup/session-upstream-marker-D15C9NHp.mjs} +0 -0
  145. /package/dist/{upstream-prompt-provenance-LphB8slG.js → .setup/upstream-prompt-provenance-LphB8slG.mjs} +0 -0
  146. /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
@@ -1,25 +1,238 @@
1
- import { m as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-utils-C57JiJrU.js";
2
- import "./config-JDfTI4VI.js";
3
- import { a as exists, c as sanitizeName, n as discoverCodexSource, o as readJsonObject, r as hasCodexSource, s as resolveHomePath, t as codexPluginMigrationSubscriptionWarning } from "./source-Da-h6f7e.js";
4
- import { asBoolean, isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { c as CODEX_PLUGINS_MARKETPLACE_NAME } from "./plugin-inventory-DUle8DLz.mjs";
2
+ import "./config-CedDWjM-.mjs";
3
+ import { c as resolveHomePath, i as hasCodexSource, l as sanitizeName, n as defaultCodexHome, o as exists, r as discoverCodexSource, s as readJsonObject, t as codexPluginMigrationSubscriptionWarning } from "./source-Bjp4UQij.mjs";
4
+ import { asBoolean, asOptionalRecord, isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
+ import { createHash } from "node:crypto";
6
+ import { runCommandBuffered } from "openclaw/plugin-sdk/process-runtime";
5
7
  import path from "node:path";
6
8
  import fs from "node:fs/promises";
7
9
  import { canonicalPathFromExistingAncestor, isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
10
+ import { readSecretFile } from "openclaw/plugin-sdk/secret-file";
11
+ import { fileURLToPath } from "node:url";
8
12
  import { loadAuthProfileStoreWithoutExternalProfiles, resolveAgentConfig, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "openclaw/plugin-sdk/agent-runtime";
13
+ import { applyAuthProfileConfig, buildApiKeyCredential, buildOauthProviderAuthResult, buildOpenAICodexCredentialExtra, hasUsableOAuthCredential, resolveOpenAICodexAuthIdentity, resolveOpenAICodexImportProfileName, updateAuthProfileStoreWithLock } from "openclaw/plugin-sdk/provider-auth";
9
14
  import { extractErrorCode } from "openclaw/plugin-sdk/security-runtime";
10
- import { applyAuthProfileConfig, buildApiKeyCredential, buildOauthProviderAuthResult, buildOpenAICodexCredentialExtra, readCodexCliCredentialsCached, resolveOpenAICodexAuthIdentity, resolveOpenAICodexImportProfileName, updateAuthProfileStoreWithLock } from "openclaw/plugin-sdk/provider-auth";
11
15
  import { MIGRATION_REASON_TARGET_EXISTS, createMigrationItem, createMigrationManualItem, hasMigrationConfigPatchConflict, markMigrationItemConflict, markMigrationItemError, markMigrationItemSkipped, mergeMigrationConfigValue, readMigrationConfigPath, resolveMigrationConfigRuntime, summarizeMigrationItems } from "openclaw/plugin-sdk/migration";
16
+ import { decodeOpenAICodexJwtPayload } from "openclaw/plugin-sdk/provider-oauth-runtime";
17
+ //#region extensions/codex/src/migration/auth-profile-target.ts
18
+ const OPENAI_PROVIDER_ID$1 = "openai";
19
+ const LEGACY_CODEX_PROFILE_ID = "openai:default";
20
+ function findMatchingOAuthProfile(store, credential) {
21
+ const subject = oauthSubject(credential);
22
+ if (!subject) return;
23
+ for (const [profileId, existing] of Object.entries(store.profiles)) {
24
+ if (existing.type !== "oauth" || existing.provider !== credential.provider) continue;
25
+ const previous = oauthSubject(existing);
26
+ if (previous?.accountId === subject.accountId && previous.userId === subject.userId) return profileId;
27
+ }
28
+ }
29
+ function oauthSubject(credential) {
30
+ const claims = decodeOpenAICodexJwtPayload(credential.access)?.["https://api.openai.com/auth"];
31
+ if (!isRecord(claims)) return;
32
+ const accountId = normalizeOptionalString(claims.chatgpt_account_id);
33
+ const userId = normalizeOptionalString(claims.chatgpt_user_id) ?? normalizeOptionalString(claims.user_id);
34
+ return accountId && userId ? {
35
+ accountId,
36
+ userId
37
+ } : void 0;
38
+ }
39
+ function findMatchingApiKeyProfile(store, provider, key) {
40
+ for (const [profileId, existing] of Object.entries(store.profiles)) if (existing.type === "api_key" && existing.provider === provider && existing.key === key) return profileId;
41
+ }
42
+ function itemProfileTarget(credential, store, ctx, source) {
43
+ if (credential.kind === "oauth") {
44
+ const profile = credential.result.profiles[0];
45
+ const matched = profile?.credential.type === "oauth" ? findMatchingOAuthProfile(store, profile.credential) : void 0;
46
+ if (matched) return {
47
+ profileId: matched,
48
+ matchedExisting: true
49
+ };
50
+ const legacyProfile = ctx.config.auth?.profiles?.[LEGACY_CODEX_PROFILE_ID];
51
+ return {
52
+ profileId: legacyProfile?.provider === OPENAI_PROVIDER_ID$1 && legacyProfile.mode === "oauth" && source.codexHome === defaultCodexHome() && profile?.credential.type === "oauth" && oauthSubject(profile.credential) !== void 0 && !Object.entries(store.profiles).some(([id, existing]) => id !== "openai:default" && existing.type === "oauth" && existing.provider === OPENAI_PROVIDER_ID$1) ? LEGACY_CODEX_PROFILE_ID : credential.profileId,
53
+ matchedExisting: false
54
+ };
55
+ }
56
+ const matched = findMatchingApiKeyProfile(store, credential.provider, credential.key);
57
+ return {
58
+ profileId: matched ?? credential.profileId,
59
+ matchedExisting: Boolean(matched)
60
+ };
61
+ }
62
+ //#endregion
63
+ //#region extensions/codex/src/migration/cli-credentials.ts
64
+ /** Explicit migration reads the storage selected by the native credential owner. */
65
+ async function readAuthFile(home) {
66
+ try {
67
+ return asOptionalRecord(JSON.parse(await readSecretFile(path.join(home, "auth.json"), "Codex auth")));
68
+ } catch {
69
+ return;
70
+ }
71
+ }
72
+ async function readDirectKeyring(home, signal) {
73
+ const account = `cli|${createHash("sha256").update(home).digest("hex").slice(0, 16)}`;
74
+ const result = await runCommandBuffered([
75
+ "security",
76
+ "find-generic-password",
77
+ "-s",
78
+ "Codex Auth",
79
+ "-a",
80
+ account,
81
+ "-w"
82
+ ], {
83
+ timeoutMs: 6e4,
84
+ maxCombinedOutputBytes: 16384,
85
+ signal
86
+ });
87
+ if (result.termination !== "exit" || result.code !== 0) return;
88
+ try {
89
+ return asOptionalRecord(JSON.parse(result.stdout.toString("utf8")));
90
+ } catch {
91
+ return;
92
+ }
93
+ }
94
+ async function readSelectedCredentialStorage(options, requireApiKey) {
95
+ options.signal?.throwIfAborted();
96
+ const home = await fs.realpath(options.codexHome).catch(() => path.resolve(options.codexHome));
97
+ const { CodexAppServerClient } = await import("./client-vXs2929Q.mjs").then((n) => n.n);
98
+ const { resolveManagedCodexPackageEntrypoint, resolveManagedCodexNativeCommand } = await import("./managed-binary-DP6Rib3P.mjs").then((n) => n.n);
99
+ const launcher = resolveManagedCodexPackageEntrypoint(path.dirname(fileURLToPath(import.meta.url)));
100
+ const command = launcher ? resolveManagedCodexNativeCommand(launcher) : void 0;
101
+ if (!command) return;
102
+ const signal = AbortSignal.any([AbortSignal.timeout(options.allowKeychainPrompt && process.platform === "darwin" ? 6e4 : 5e3), ...options.signal ? [options.signal] : []]);
103
+ const client = await CodexAppServerClient.start({
104
+ transport: "stdio",
105
+ command,
106
+ commandSource: "resolved-managed",
107
+ args: ["app-server"],
108
+ cwd: home,
109
+ homeScope: "user",
110
+ env: { CODEX_HOME: home },
111
+ clearEnv: [
112
+ "OPENAI_API_KEY",
113
+ "CODEX_API_KEY",
114
+ "CODEX_ACCESS_TOKEN"
115
+ ]
116
+ }, () => signal.throwIfAborted()).catch(() => {
117
+ options.signal?.throwIfAborted();
118
+ });
119
+ if (!client) return;
120
+ const abort = () => client.close();
121
+ signal.addEventListener("abort", abort, { once: true });
122
+ let credential;
123
+ try {
124
+ credential = await readNativeCredential(client, home, requireApiKey, options, signal);
125
+ } catch {}
126
+ signal.removeEventListener("abort", abort);
127
+ const closed = await client.closeAndWait({
128
+ forceKillDelayMs: 6e3,
129
+ exitTimeoutMs: 7e3
130
+ });
131
+ if (!closed.exited || closed.cleanup !== "closed") throw new Error("The Codex credential reader could not stop. No credential was imported.", { cause: options.signal?.reason });
132
+ options.signal?.throwIfAborted();
133
+ return credential;
134
+ }
135
+ async function readNativeCredential(client, home, requireApiKey, options, signal) {
136
+ signal.throwIfAborted();
137
+ await client.initialize();
138
+ if (client.getRuntimeIdentity()?.codexHome !== home) return;
139
+ const revision = client.getModelCatalogRevision();
140
+ if (requireApiKey) {
141
+ const account = await client.request("account/read", { refreshToken: false }, { signal });
142
+ if (asOptionalRecord(account.account)?.type !== "apiKey" || account.requiresOpenaiAuth !== true) return;
143
+ }
144
+ const configured = await client.request("config/read", {
145
+ includeLayers: false,
146
+ cwd: home
147
+ }, { signal });
148
+ const mode = (await client.request("configRequirements/read", {}, { signal })).requirements?.cli_auth_credentials_store ?? configured.config.cli_auth_credentials_store ?? "file";
149
+ let record;
150
+ if (mode === "file") record = await readAuthFile(home);
151
+ else if ((mode === "keyring" || mode === "auto") && process.platform === "darwin" && options.allowKeychainPrompt) {
152
+ let cursor;
153
+ let encrypted;
154
+ do {
155
+ const features = await client.request("experimentalFeature/list", {
156
+ limit: 100,
157
+ cursor
158
+ }, { signal });
159
+ const storage = features.data.find((feature) => feature.name === "secret_auth_storage");
160
+ if (storage) {
161
+ encrypted = storage.enabled;
162
+ break;
163
+ }
164
+ cursor = features.nextCursor ?? void 0;
165
+ } while (cursor);
166
+ if (encrypted !== false) return;
167
+ record = await readDirectKeyring(home, signal);
168
+ }
169
+ signal.throwIfAborted();
170
+ return !client.getCloseError() && client.getModelCatalogRevision() === revision ? record : void 0;
171
+ }
172
+ function jwtExpiry(token) {
173
+ try {
174
+ const exp = asOptionalRecord(JSON.parse(Buffer.from(token.split(".")[1] ?? "", "base64url").toString("utf8")))?.exp;
175
+ return typeof exp === "number" && Number.isFinite(exp) && exp > 0 ? exp * 1e3 : void 0;
176
+ } catch {
177
+ return;
178
+ }
179
+ }
180
+ async function readCodexCliCredentialsAsync(options) {
181
+ const data = await readSelectedCredentialStorage(options, false);
182
+ const mode = typeof data?.auth_mode === "string" ? data.auth_mode.toLowerCase() : void 0;
183
+ if (!data || mode !== void 0 && mode !== "chatgpt" && mode !== "chatgptauthtokens") return;
184
+ const tokens = asOptionalRecord(data.tokens);
185
+ if (typeof tokens?.access_token !== "string" || !tokens.access_token || typeof tokens.refresh_token !== "string" || !tokens.refresh_token) return;
186
+ const lastRefresh = typeof data.last_refresh === "string" ? Date.parse(data.last_refresh) : NaN;
187
+ return {
188
+ type: "oauth",
189
+ provider: "openai",
190
+ access: tokens.access_token,
191
+ refresh: tokens.refresh_token,
192
+ expires: jwtExpiry(tokens.access_token) ?? (Number.isFinite(lastRefresh) ? lastRefresh : Date.now()) + 36e5,
193
+ ...typeof tokens.account_id === "string" ? { accountId: tokens.account_id } : {},
194
+ ...typeof tokens.id_token === "string" ? { idToken: tokens.id_token } : {}
195
+ };
196
+ }
197
+ async function readCodexCliActiveApiKeyAsync(options) {
198
+ const data = await readSelectedCredentialStorage(options, true);
199
+ const mode = typeof data?.auth_mode === "string" ? data.auth_mode.toLowerCase() : void 0;
200
+ if (!data || mode !== void 0 && mode !== "apikey" && mode !== "api_key") return;
201
+ const key = typeof data.OPENAI_API_KEY === "string" ? data.OPENAI_API_KEY.trim() : "";
202
+ return key ? {
203
+ type: "api_key",
204
+ provider: "openai",
205
+ key
206
+ } : void 0;
207
+ }
208
+ //#endregion
12
209
  //#region extensions/codex/src/migration/auth.ts
13
210
  const OPENAI_PROVIDER_ID = "openai";
14
- const OPENAI_CODEX_DEFAULT_MODEL = "openai/gpt-5.6-sol";
211
+ const OPENAI_OAUTH_ITEM_ID = "auth:openai";
212
+ const OPENAI_API_KEY_ITEM_ID = "auth:openai:api-key";
213
+ const OPENAI_CODEX_DEFAULT_MODEL = "openai/gpt-6-astra";
15
214
  const CODEX_IMPORT_DISPLAY_NAME = "Codex import";
16
215
  const CODEX_REASON_AUTH_NOT_SELECTED = "auth credential migration not selected";
17
216
  const CODEX_REASON_AUTH_PROFILE_EXISTS = "auth profile exists";
217
+ const CODEX_REASON_AUTH_PROFILE_UNUSABLE = "existing OAuth profile requires sign-in";
18
218
  const CODEX_REASON_AUTH_PROFILE_WRITE_FAILED = "failed to write auth profile";
19
219
  const CODEX_REASON_AUTH_NO_LONGER_PRESENT = "auth credential no longer present";
20
220
  const CODEX_REASON_MISSING_AUTH_METADATA = "missing auth metadata";
21
- const CODEX_CONFIG_PATCH_MODE_RETURN = "return";
221
+ const CODEX_REASON_AUTH_STORAGE_NOT_IMPORTABLE = "credential storage is not importable";
22
222
  var CodexAuthConfigConflict = class extends Error {};
223
+ function authItemId(credential) {
224
+ return credential.kind === "oauth" ? OPENAI_OAUTH_ITEM_ID : OPENAI_API_KEY_ITEM_ID;
225
+ }
226
+ function sourceCredentialFingerprint(credential) {
227
+ const profile = credential.kind === "oauth" ? credential.result.profiles[0]?.credential : void 0;
228
+ const source = credential.kind === "api_key" ? credential.key : profile?.type === "oauth" ? [
229
+ profile.access,
230
+ profile.refresh,
231
+ profile.accountId,
232
+ profile.idToken
233
+ ] : void 0;
234
+ return createHash("sha256").update(JSON.stringify([credential.kind, source])).digest("hex");
235
+ }
23
236
  async function readModelRefs(source) {
24
237
  const cache = await readJsonObject(source.modelsCachePath);
25
238
  const models = Array.isArray(cache.models) ? cache.models : [];
@@ -32,19 +245,18 @@ async function readModelRefs(source) {
32
245
  refs.add(OPENAI_CODEX_DEFAULT_MODEL);
33
246
  return [...refs].toSorted();
34
247
  }
35
- async function buildCodexOAuthCredential(source) {
36
- const credential = readCodexCliCredentialsCached({
248
+ async function buildCodexOAuthCredential(source, includeConfigPatch, options) {
249
+ const credential = await readCodexCliCredentialsAsync({
37
250
  codexHome: source.codexHome,
38
- allowKeychainPrompt: false,
39
- ttlMs: 0
251
+ allowKeychainPrompt: options.allowKeychainPrompt,
252
+ ...options.signal ? { signal: options.signal } : {}
40
253
  });
41
254
  if (!credential) return null;
42
255
  const identity = resolveOpenAICodexAuthIdentity({
43
256
  access: credential.access,
44
257
  accountId: credential.accountId
45
258
  });
46
- const modelRefs = await readModelRefs(source);
47
- const configPatch = { agents: { defaults: { models: Object.fromEntries(modelRefs.map((modelRef) => [modelRef, {}])) } } };
259
+ const configPatch = includeConfigPatch ? { agents: { defaults: { models: Object.fromEntries((await readModelRefs(source)).map((modelRef) => [modelRef, {}])) } } } : {};
48
260
  const result = buildOauthProviderAuthResult({
49
261
  providerId: OPENAI_PROVIDER_ID,
50
262
  defaultModel: OPENAI_CODEX_DEFAULT_MODEL,
@@ -69,44 +281,25 @@ async function buildCodexOAuthCredential(source) {
69
281
  result
70
282
  } : null;
71
283
  }
72
- async function buildCodexApiKeyCredential(source) {
73
- const raw = await readJsonObject(source.authPath);
74
- const key = normalizeOptionalString(raw.OPENAI_API_KEY);
75
- if (!key) return null;
284
+ async function buildCodexApiKeyCredential(source, allowKeychainPrompt, signal) {
285
+ const credential = await readCodexCliActiveApiKeyAsync({
286
+ codexHome: source.codexHome,
287
+ allowKeychainPrompt,
288
+ ...signal ? { signal } : {}
289
+ });
290
+ if (!credential) return null;
76
291
  return {
77
292
  kind: "api_key",
78
293
  provider: OPENAI_PROVIDER_ID,
79
294
  profileId: "openai:codex-import",
80
- key
295
+ key: credential.key
81
296
  };
82
297
  }
83
- async function readCodexAuthCredentials(source) {
84
- return [await buildCodexOAuthCredential(source), await buildCodexApiKeyCredential(source)].filter((entry) => entry !== null);
85
- }
86
- function findMatchingOAuthProfile(store, credential) {
87
- for (const [profileId, existing] of Object.entries(store.profiles)) {
88
- if (existing.type !== "oauth" || existing.provider !== credential.provider) continue;
89
- if (credential.accountId && existing.accountId === credential.accountId) return profileId;
90
- if ((!credential.accountId || !existing.accountId) && credential.email && existing.email === credential.email) return profileId;
91
- }
92
- }
93
- function findMatchingApiKeyProfile(store, provider, key) {
94
- for (const [profileId, existing] of Object.entries(store.profiles)) if (existing.type === "api_key" && existing.provider === provider && existing.key === key) return profileId;
95
- }
96
- function itemProfileTarget(credential, store) {
97
- if (credential.kind === "oauth") {
98
- const profile = credential.result.profiles[0];
99
- const matched = profile?.credential.type === "oauth" ? findMatchingOAuthProfile(store, profile.credential) : void 0;
100
- return {
101
- profileId: matched ?? credential.profileId,
102
- matchedExisting: Boolean(matched)
103
- };
104
- }
105
- const matched = findMatchingApiKeyProfile(store, credential.provider, credential.key);
106
- return {
107
- profileId: matched ?? credential.profileId,
108
- matchedExisting: Boolean(matched)
109
- };
298
+ async function readCodexAuthCredentials(source, options) {
299
+ return [options.credentialKind === "api_key" ? null : await buildCodexOAuthCredential(source, options.includeConfigPatch, {
300
+ allowKeychainPrompt: options.allowKeychainPrompt,
301
+ ...options.signal ? { signal: options.signal } : {}
302
+ }), options.credentialKind === "oauth" ? null : await buildCodexApiKeyCredential(source, options.allowKeychainPrompt, options.signal)].filter((entry) => entry !== null);
110
303
  }
111
304
  function replaceConfigDraft(draft, next) {
112
305
  for (const key of Object.keys(draft)) delete draft[key];
@@ -168,8 +361,16 @@ function applyApiKeyConfigToConfig(cfg, credential, profileId) {
168
361
  preferProfileFirst: false
169
362
  });
170
363
  }
171
- function shouldReturnAuthConfigPatch(ctx) {
172
- return ctx.providerOptions?.configPatchMode === CODEX_CONFIG_PATCH_MODE_RETURN;
364
+ function resolveCodexConfigPatchMode(ctx) {
365
+ const mode = ctx.providerOptions?.configPatchMode;
366
+ return mode === "none" || mode === "return" ? mode : "apply";
367
+ }
368
+ function allowCodexKeychainPrompt(ctx) {
369
+ return ctx.providerOptions?.allowKeychainPrompt === true;
370
+ }
371
+ function resolveRequestedCredentialKind(ctx) {
372
+ const kind = ctx.providerOptions?.credentialKind;
373
+ return kind === "oauth" || kind === "api_key" ? kind : void 0;
173
374
  }
174
375
  function authProfileConfigForCredential(credential, profileId) {
175
376
  if (credential.kind === "api_key") return {
@@ -215,32 +416,61 @@ function applyCredentialConfig(config, credential, profileId) {
215
416
  return credential.kind === "oauth" ? applyOAuthConfigToConfig(config, credential, profileId) : applyApiKeyConfigToConfig(config, credential, profileId);
216
417
  }
217
418
  async function buildCodexAuthItems(params) {
218
- const credentials = await readCodexAuthCredentials(params.source);
219
- if (credentials.length === 0) return [];
419
+ const configPatchMode = resolveCodexConfigPatchMode(params.ctx);
420
+ const credentials = await readCodexAuthCredentials(params.source, {
421
+ credentialKind: resolveRequestedCredentialKind(params.ctx),
422
+ includeConfigPatch: configPatchMode !== "none",
423
+ allowKeychainPrompt: allowCodexKeychainPrompt(params.ctx),
424
+ signal: params.ctx.signal
425
+ });
426
+ if (credentials.length === 0) {
427
+ const requestedKind = resolveRequestedCredentialKind(params.ctx);
428
+ if (!requestedKind) return [];
429
+ const credentialKind = requestedKind;
430
+ return [createMigrationItem({
431
+ id: credentialKind === "oauth" ? OPENAI_OAUTH_ITEM_ID : OPENAI_API_KEY_ITEM_ID,
432
+ kind: "auth",
433
+ action: "skip",
434
+ source: params.source.codexHome,
435
+ status: "skipped",
436
+ sensitive: true,
437
+ reason: CODEX_REASON_AUTH_STORAGE_NOT_IMPORTABLE,
438
+ message: "No supported Codex credential could be imported. Continue with sign-in to connect OpenClaw.",
439
+ details: {
440
+ provider: OPENAI_PROVIDER_ID,
441
+ credentialKind,
442
+ credentialImportUnavailable: true
443
+ }
444
+ })];
445
+ }
220
446
  const store = loadAuthProfileStoreWithoutExternalProfiles(params.targets.agentDir);
221
447
  const skipped = !params.ctx.includeSecrets;
222
448
  return credentials.map((credential) => {
223
- const { profileId, matchedExisting } = itemProfileTarget(credential, store);
224
- const targetExists = Boolean(store.profiles[profileId]);
449
+ const { profileId, matchedExisting } = itemProfileTarget(credential, store, params.ctx, params.source);
450
+ const existing = store.profiles[profileId];
225
451
  const configProfile = authProfileConfigForCredential(credential, profileId);
226
452
  const configConflict = configProfile ? hasAuthProfileConfigConflict(params.ctx.config, configProfile, Boolean(params.ctx.overwrite)) : false;
227
- const conflict = (targetExists && !matchedExisting && !params.ctx.overwrite || configConflict) && !skipped;
453
+ const conflict = (existing && !matchedExisting && !params.ctx.overwrite || configConflict) && !skipped;
454
+ const unavailable = !skipped && !conflict && !params.ctx.overwrite && existing?.type === "oauth" && !hasUsableOAuthCredential(existing);
228
455
  return createMigrationItem({
229
- id: `auth:${credential.provider}`,
456
+ id: authItemId(credential),
230
457
  kind: "auth",
231
- action: skipped ? "skip" : "create",
232
- source: params.source.authPath,
458
+ action: skipped || unavailable ? "skip" : "create",
459
+ source: params.source.codexHome,
233
460
  target: `${params.targets.agentDir}/openclaw-agent.sqlite#auth_profile_store:${profileId}`,
234
- status: skipped ? "skipped" : conflict ? "conflict" : "planned",
461
+ status: skipped || unavailable ? "skipped" : conflict ? "conflict" : "planned",
235
462
  sensitive: true,
236
- reason: skipped ? CODEX_REASON_AUTH_NOT_SELECTED : conflict ? CODEX_REASON_AUTH_PROFILE_EXISTS : void 0,
237
- message: credential.kind === "oauth" ? "Import Codex OAuth credentials and configure OpenAI Codex models." : "Import Codex OpenAI API key.",
463
+ reason: skipped ? CODEX_REASON_AUTH_NOT_SELECTED : conflict ? CODEX_REASON_AUTH_PROFILE_EXISTS : unavailable ? CODEX_REASON_AUTH_PROFILE_UNUSABLE : void 0,
464
+ message: unavailable ? "The existing OpenAI sign-in needs to be renewed. Continue with sign-in." : credential.kind === "oauth" ? configPatchMode === "none" ? "Import Codex OAuth credentials." : "Import Codex OAuth credentials and configure OpenAI Codex models." : "Import Codex OpenAI API key.",
238
465
  details: {
239
466
  provider: credential.provider,
240
467
  profileId,
241
468
  sourceProfileId: credential.profileId,
242
- sourceKind: "codex-auth-json",
243
- credentialKind: credential.kind
469
+ sourceCredentialFingerprint: sourceCredentialFingerprint(credential),
470
+ sourceKind: "codex-native-selected-storage",
471
+ ...profileId === "openai:default" && !matchedExisting ? { legacyNativeHome: params.source.codexHome } : {},
472
+ credentialKind: credential.kind,
473
+ credentialImportUnavailable: unavailable
244
474
  }
245
475
  });
246
476
  });
@@ -251,10 +481,19 @@ async function applyCodexAuthItems(params) {
251
481
  const profileId = typeof item.details?.profileId === "string" ? item.details.profileId : "";
252
482
  const provider = typeof item.details?.provider === "string" ? item.details.provider : "";
253
483
  const sourceProfileId = typeof item.details?.sourceProfileId === "string" ? item.details.sourceProfileId : void 0;
254
- if (!profileId || !provider) return [markMigrationItemError(item, CODEX_REASON_MISSING_AUTH_METADATA)];
255
- const credential = (await readCodexAuthCredentials(source)).find((candidate) => candidate.provider === provider);
484
+ const credentialKind = item.details?.credentialKind;
485
+ if (!profileId || !provider || credentialKind !== "oauth" && credentialKind !== "api_key") return [markMigrationItemError(item, CODEX_REASON_MISSING_AUTH_METADATA)];
486
+ const configPatchMode = resolveCodexConfigPatchMode(ctx);
487
+ const credential = (await readCodexAuthCredentials(source, {
488
+ credentialKind,
489
+ includeConfigPatch: configPatchMode !== "none",
490
+ allowKeychainPrompt: allowCodexKeychainPrompt(ctx),
491
+ signal: ctx.signal
492
+ })).find((candidate) => candidate.provider === provider && candidate.kind === credentialKind && (!sourceProfileId || candidate.profileId === sourceProfileId));
256
493
  if (!credential) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_NO_LONGER_PRESENT)];
257
- if (credential.kind === "oauth" && sourceProfileId && credential.profileId !== sourceProfileId) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_NO_LONGER_PRESENT)];
494
+ if (item.details?.sourceCredentialFingerprint !== sourceCredentialFingerprint(credential)) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_NO_LONGER_PRESENT)];
495
+ if (item.details?.legacyNativeHome !== void 0 && (item.details.legacyNativeHome !== source.codexHome || source.codexHome !== defaultCodexHome())) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_NO_LONGER_PRESENT)];
496
+ ctx.signal?.throwIfAborted();
258
497
  const oauthProfile = credential.kind === "oauth" ? credential.result.profiles[0] : void 0;
259
498
  const oauthCredential = oauthProfile?.credential.type === "oauth" ? oauthProfile.credential : void 0;
260
499
  if (credential.kind === "oauth" && !oauthCredential) return [markMigrationItemError(item, CODEX_REASON_MISSING_AUTH_METADATA)];
@@ -262,14 +501,24 @@ async function applyCodexAuthItems(params) {
262
501
  if (!configProfile) return [markMigrationItemError(item, CODEX_REASON_MISSING_AUTH_METADATA)];
263
502
  if (hasCurrentAuthProfileConfigConflict(ctx, configProfile)) return [markMigrationItemConflict(item, CODEX_REASON_AUTH_PROFILE_EXISTS)];
264
503
  let conflicted = false;
504
+ let unusable = false;
265
505
  let wrote = false;
266
506
  const store = await updateAuthProfileStoreWithLock({
267
507
  agentDir: targets.agentDir,
268
508
  stateDir: ctx.stateDir,
269
509
  updater: (freshStore) => {
270
- const existing = freshStore.profiles[profileId];
510
+ ctx.signal?.throwIfAborted();
511
+ const effectiveStore = loadAuthProfileStoreWithoutExternalProfiles(targets.agentDir);
512
+ if (item.details?.legacyNativeHome !== void 0 && itemProfileTarget(credential, effectiveStore, ctx, source).profileId !== profileId) {
513
+ conflicted = true;
514
+ return false;
515
+ }
516
+ const existing = effectiveStore.profiles[profileId];
271
517
  if (!ctx.overwrite && existing) {
272
- if ((credential.kind === "oauth" ? findMatchingOAuthProfile(freshStore, oauthCredential) : findMatchingApiKeyProfile(freshStore, credential.provider, credential.key)) === profileId) return false;
518
+ if ((credential.kind === "oauth" ? findMatchingOAuthProfile(effectiveStore, oauthCredential) : findMatchingApiKeyProfile(effectiveStore, credential.provider, credential.key)) === profileId) {
519
+ unusable = existing.type === "oauth" && !hasUsableOAuthCredential(existing);
520
+ return false;
521
+ }
273
522
  conflicted = true;
274
523
  return false;
275
524
  }
@@ -285,8 +534,9 @@ async function applyCodexAuthItems(params) {
285
534
  }
286
535
  });
287
536
  if (conflicted) return [markMigrationItemConflict(item, CODEX_REASON_AUTH_PROFILE_EXISTS)];
288
- if (!store?.profiles[profileId]) return [markMigrationItemError(item, CODEX_REASON_AUTH_PROFILE_WRITE_FAILED)];
289
- const configResult = shouldReturnAuthConfigPatch(ctx) ? "unavailable" : await applyCodexAuthConfig(ctx, credential, profileId);
537
+ if (unusable) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_PROFILE_UNUSABLE)];
538
+ if (!store || !loadAuthProfileStoreWithoutExternalProfiles(targets.agentDir).profiles[profileId]) return [markMigrationItemError(item, CODEX_REASON_AUTH_PROFILE_WRITE_FAILED)];
539
+ const configResult = configPatchMode !== "apply" ? "unavailable" : await applyCodexAuthConfig(ctx, credential, profileId);
290
540
  if (configResult === "conflict") return [markMigrationItemConflict(item, CODEX_REASON_AUTH_PROFILE_EXISTS)];
291
541
  const migratedItem = {
292
542
  ...item,
@@ -295,10 +545,10 @@ async function applyCodexAuthItems(params) {
295
545
  ...item.details,
296
546
  wroteAuthProfile: wrote,
297
547
  configUpdated: configResult === "configured",
298
- ...shouldReturnAuthConfigPatch(ctx) ? { configPatchReturned: true } : {}
548
+ ...configPatchMode === "return" ? { configPatchReturned: true } : {}
299
549
  }
300
550
  };
301
- return [migratedItem, ...shouldReturnAuthConfigPatch(ctx) ? buildCodexAuthConfigPatchItems(ctx, migratedItem, credential, profileId) : []];
551
+ return [migratedItem, ...configPatchMode === "return" ? buildCodexAuthConfigPatchItems(ctx, migratedItem, credential, profileId) : []];
302
552
  }
303
553
  function buildCodexAuthConfigPatchItems(ctx, item, credential, profileId) {
304
554
  const next = applyCredentialConfig(ctx.config, credential, profileId);
@@ -648,25 +898,27 @@ function buildPluginConfigItem(ctx, pluginItems) {
648
898
  async function buildCodexMigrationPlan(ctx) {
649
899
  const targets = resolveCodexMigrationTargets(ctx);
650
900
  const memoryOnly = ctx.itemKinds !== void 0 && ctx.itemKinds.length > 0 && ctx.itemKinds.every((kind) => kind === "memory");
901
+ const authOnly = ctx.itemKinds !== void 0 && ctx.itemKinds.length > 0 && ctx.itemKinds.every((kind) => kind === "auth");
651
902
  const source = await discoverCodexSource({
652
903
  input: ctx.source,
653
904
  memoryOnly,
654
- evaluatePluginMigrationEligibility: !memoryOnly,
905
+ authOnly,
906
+ evaluatePluginMigrationEligibility: !memoryOnly && !authOnly,
655
907
  verifyPluginApps: shouldVerifyPluginApps(ctx)
656
908
  });
657
- if (!hasCodexSource(source)) throw new Error(`Codex state was not found at ${source.root}. Pass --from <path> if it lives elsewhere.`);
909
+ if (!hasCodexSource(source) && !authOnly) throw new Error(`Codex state was not found at ${source.root}. Pass --from <path> if it lives elsewhere.`);
658
910
  const items = [];
659
- items.push(...await buildCodexMemoryItems({
911
+ if (!authOnly) items.push(...await buildCodexMemoryItems({
660
912
  memoryFiles: source.memoryFiles,
661
913
  workspaceDir: targets.workspaceDir,
662
914
  overwrite: ctx.overwrite
663
915
  }));
664
- if (!memoryOnly) {
665
- items.push(...await buildCodexAuthItems({
666
- ctx,
667
- source,
668
- targets
669
- }));
916
+ if (!memoryOnly) items.push(...await buildCodexAuthItems({
917
+ ctx,
918
+ source,
919
+ targets
920
+ }));
921
+ if (!memoryOnly && !authOnly) {
670
922
  items.push(...await buildCodexSkillItems({
671
923
  skills: source.skills,
672
924
  workspaceDir: targets.workspaceDir,
@@ -708,4 +960,4 @@ async function buildCodexMigrationPlan(ctx) {
708
960
  };
709
961
  }
710
962
  //#endregion
711
- export { CODEX_PLUGIN_CONFIG_ITEM_ID, CODEX_PLUGIN_CONFIG_PATH, buildCodexMigrationPlan, buildCodexPluginsConfigValue, hasCodexPluginConfigConflict, applyCodexAuthItems as n, readCodexPluginMigrationConfigEntry, resolveCodexMigrationTargets as t };
963
+ export { CODEX_PLUGIN_CONFIG_ITEM_ID, CODEX_PLUGIN_CONFIG_PATH, buildCodexMigrationPlan, buildCodexPluginsConfigValue, hasCodexPluginConfigConflict, applyCodexAuthItems as n, resolveCodexConfigPatchMode as r, readCodexPluginMigrationConfigEntry, resolveCodexMigrationTargets as t };
@@ -1,7 +1,6 @@
1
- import { m as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-utils-C57JiJrU.js";
2
- import { r as CodexAppServerRpcError } from "./session-catalog-provenance-DkJHo735.js";
3
- import "./config-JDfTI4VI.js";
4
- import { i as pluginReadParams, n as isOpenAiCuratedMarketplace, r as isOpenAiCuratedMarketplaceName, t as findCodexMarketplacePluginSummary } from "./plugin-inventory-CoRCzWW4.js";
1
+ import { c as CODEX_PLUGINS_MARKETPLACE_NAME, i as pluginReadParams, n as isOpenAiCuratedMarketplace, r as isOpenAiCuratedMarketplaceName, t as findCodexMarketplacePluginSummary } from "./plugin-inventory-DUle8DLz.mjs";
2
+ import { i as CodexAppServerRpcError } from "./timeout-DZF05XrR.mjs";
3
+ import "./config-CedDWjM-.mjs";
5
4
  import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
6
5
  //#region extensions/codex/src/app-server/plugin-activation.ts
7
6
  /**
@@ -89,23 +88,29 @@ async function refreshCodexPluginRuntimeState(params) {
89
88
  diagnostics.push({ message: `Codex hooks refresh skipped: ${coerceErrorMessage(error)}` });
90
89
  }
91
90
  await params.request("config/mcpServer/reload", void 0);
92
- if (params.appCache && params.appCacheKey) {
93
- params.appCache.invalidate(params.appCacheKey, "Codex plugin activation changed app inventory", void 0, params.targetAppIds);
94
- if (params.deferAppInventoryRefresh) return { diagnostics };
95
- const request = async (method, requestParams) => await params.request(method, requestParams);
96
- try {
97
- await params.appCache.refreshNow({
98
- key: params.appCacheKey,
99
- request,
100
- forceRefetch: true,
101
- targetAppIds: params.targetAppIds
102
- });
103
- } catch (error) {
104
- diagnostics.push({ message: `Codex app inventory refresh skipped: ${coerceErrorMessage(error)}` });
105
- }
91
+ if (params.appCache && params.appCacheKey) try {
92
+ await refreshCodexAppRuntimeState({
93
+ ...params,
94
+ appCache: params.appCache,
95
+ appCacheKey: params.appCacheKey
96
+ });
97
+ } catch (error) {
98
+ diagnostics.push({ message: `Codex app inventory refresh skipped: ${coerceErrorMessage(error)}` });
106
99
  }
107
100
  return { diagnostics };
108
101
  }
102
+ /** Refreshes hosted app tools without reloading unrelated active threads. */
103
+ async function refreshCodexAppRuntimeState(params) {
104
+ params.appCache.invalidate(params.appCacheKey, "Codex plugin app inventory refresh requested", void 0, params.targetAppIds);
105
+ if (params.deferAppInventoryRefresh) return;
106
+ const request = async (method, requestParams) => await params.request(method, requestParams);
107
+ await params.appCache.refreshNow({
108
+ key: params.appCacheKey,
109
+ request,
110
+ forceRefetch: true,
111
+ targetAppIds: params.targetAppIds
112
+ });
113
+ }
109
114
  async function listCuratedCodexPluginMetadata(params, options = {}) {
110
115
  const requestParams = {
111
116
  ...params.configCwd ? { cwds: [params.configCwd] } : {},
@@ -130,4 +135,4 @@ function activationFailure(identity, reason, diagnostic, extraDiagnostics = [])
130
135
  };
131
136
  }
132
137
  //#endregion
133
- export { refreshCodexPluginRuntimeState as n, ensureCodexPluginActivation as t };
138
+ export { refreshCodexAppRuntimeState as n, refreshCodexPluginRuntimeState as r, ensureCodexPluginActivation as t };