@openclaw/codex 2026.9.5 → 2026.9.7
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.
- package/README.md +2 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-DFhbh1zz.mjs} +6 -6
- package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-D3GcSoSa.mjs} +35 -55
- package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-DOP-cW5j.mjs} +179 -73
- package/dist/.setup/attempt-workspace-context-C5HigshI.mjs +164 -0
- package/dist/.setup/{auth-binding-DhLWa_7K.mjs → auth-binding-BLWz7stm.mjs} +14 -1
- package/dist/.setup/{auth-cache-key-QirmgiCo.mjs → auth-cache-key-Dbvq-QgB.mjs} +41 -111
- package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
- package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
- package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
- package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
- package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-6TpgD1M6.mjs} +5 -5
- package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-CbjoN2OW.mjs} +140 -37
- package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
- package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-Da1_z0kd.mjs} +1 -1
- package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-B3WEZl4e.mjs} +2 -10
- package/dist/.setup/{client-vXs2929Q.mjs → client-N0JpgSzF.mjs} +635 -872
- package/dist/.setup/client-catalog-response-5HHLdcde.mjs +285 -0
- package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-BeAoaovI.mjs} +9 -8
- package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-R3ckE3Co.mjs} +36 -64
- package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-ylTMS00z.mjs} +301 -488
- package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-CGJGUQ6Y.mjs} +40 -28
- package/dist/.setup/compact-C2WamavS.mjs +776 -0
- package/dist/.setup/{config-CedDWjM-.mjs → config-DKhXquav.mjs} +26 -28
- package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-CzyWLTJt.mjs} +68 -65
- package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
- package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C0NbLms1.mjs} +2 -2
- package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-CE-FcGw9.mjs} +51 -215
- package/dist/.setup/{config-utils-DujwEnhg.mjs → config-utils-D0CXecki.mjs} +3 -13
- package/dist/.setup/context-engine-projection-PezSESth.mjs +387 -0
- package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-3Min8qvP.mjs} +71 -105
- package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
- package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-CEP8X5JC.mjs} +30 -69
- package/dist/.setup/{cyber-failover-DYwbmf1o.mjs → cyber-failover-XV0nNRZu.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-e9G3J9-e.mjs → cyber-failover-notice-RNpGpTyP.mjs} +1 -1
- package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-DzlsLUuS.mjs} +3136 -3167
- package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CxUtC-xG.mjs} +8 -17
- package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-CDsPJOa2.mjs} +9 -6
- package/dist/.setup/event-projector-assistant-message-CigreO4K.mjs +69 -0
- package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-03R0I2dM.mjs} +4 -26
- package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
- package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
- package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D-9gWlTR.mjs} +16 -18
- package/dist/.setup/inference-dispatch-CMZtjQyz.mjs +359 -0
- package/dist/.setup/inference-metadata-CgIf7sOx.mjs +81 -0
- package/dist/.setup/inference-proxy-DhcXOgUE.mjs +561 -0
- package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-Dm3PzxJk.mjs} +15 -11
- package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
- package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-kiWRhNRE.mjs} +16 -9
- package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-PAuZgJC6.mjs} +14 -14
- package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
- package/dist/.setup/{models-BDFgm_G-.mjs → models-DHXZtVVk.mjs} +9 -18
- package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-CuG53tu4.mjs} +5 -5
- package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-BxZJy5mP.mjs} +6 -31
- package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-Dpsmf2wz.mjs} +4422 -3808
- package/dist/.setup/native-subagent-pending-assignments-DwkCzLvD.mjs +203 -0
- package/dist/.setup/native-task-assignments-DMQ0g3hu.mjs +194 -0
- package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-HC4W6FLI.mjs} +99 -111
- package/dist/.setup/node-exec-server.runtime-BgBfWQqo.mjs +244 -0
- package/dist/.setup/{plan-xD7WKYTM.mjs → plan-Y-QIvrKB.mjs} +118 -163
- package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-cNHRfaxU.mjs} +10 -47
- package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +9 -42
- package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-Cky2XJUw.mjs} +32 -23
- package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +22 -25
- package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-DsjsL1dr.mjs} +328 -318
- package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
- package/dist/.setup/provider-DH8NSzGt.mjs +51 -0
- package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-CAxoF-X1.mjs} +35 -12
- package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-B7-X2TgG.mjs} +123 -166
- package/dist/.setup/{request-BioXJLYa.mjs → request-BHZ1nz8d.mjs} +25 -16
- package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
- package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
- package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-D8RZUOzY.mjs} +2046 -1454
- package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
- package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-DDQ-HGXf.mjs} +43 -47
- package/dist/.setup/runtime-artifact-connection-D68qQn1m.mjs +78 -0
- package/dist/.setup/sandbox-guard-DjCz2eOw.mjs +126 -0
- package/dist/.setup/scope-DOC1Xjc8.mjs +6 -0
- package/dist/.setup/session-binding-DGCYAfvD.mjs +443 -0
- package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-Oe9L-CNY.mjs} +73 -132
- package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-jo6H8dFr.mjs} +242 -60
- package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-4sCdv5qx.mjs} +598 -452
- package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BU_pHWG7.mjs} +59 -26
- package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-spHfihri.mjs} +7 -7
- package/dist/.setup/session-catalog-events-DePDzzjc.mjs +139 -0
- package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
- package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-CZvDzC6z.mjs} +286 -182
- package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-BcQpHks3.mjs} +2 -2
- package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-TeO7EyO-.mjs} +6 -2
- package/dist/.setup/session-catalog-limits-DDxOsQeC.mjs +14 -0
- package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +170 -0
- package/dist/.setup/session-catalog-native-projection-DjhwGL6x.mjs +178 -0
- package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +30 -35
- package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +25 -18
- package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
- package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-parsing-CPGaPYr-.mjs} +14 -180
- package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-Cr5qP5Dj.mjs} +15 -5
- package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
- package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-Cn_nCqfq.mjs} +11 -24
- package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-D83lJWHG.mjs} +16 -23
- package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-WhX-X33a.mjs} +7 -10
- package/dist/.setup/session-history-read-Ov3StuL4.mjs +133 -0
- package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-MnPKncqP.mjs} +14 -23
- package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
- package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
- package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-qMTxkNx2.mjs} +31 -12
- package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
- package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-BsvEabkw.mjs} +17 -13
- package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DqyTMYug.mjs} +826 -485
- package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +153 -0
- package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-C4kCmQy1.mjs} +206 -334
- package/dist/.setup/{source-Bjp4UQij.mjs → source-CS_7GFJZ.mjs} +82 -139
- package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
- package/dist/.setup/{thread-archive-guard-jmecf6OJ.mjs → thread-archive-guard-C9frICzX.mjs} +10 -3
- package/dist/.setup/thread-lifecycle-DPflntEJ.mjs +2362 -0
- package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
- package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-roNP0l1c.mjs} +47 -10
- package/dist/.setup/thread-policy-DTd-DtkX.mjs +109 -0
- package/dist/.setup/thread-requests-B_bRnMGN.mjs +2102 -0
- package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-CdDaoc7T.mjs} +6 -6
- package/dist/.setup/timeout-CXOfNoaX.mjs +46 -0
- package/dist/.setup/transcript-history-projection-DRSifI-1.mjs +201 -0
- package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
- package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-kxmCYsuF.mjs} +224 -206
- package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-Bdegpn2V.mjs} +138 -75
- package/dist/.setup/transport-websocket-BTBE-LD9.mjs +211 -0
- package/dist/.setup/{upstream-prompt-provenance-LphB8slG.mjs → upstream-prompt-provenance-fXkKbPVC.mjs} +3 -9
- package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-CBeVjBpT.mjs} +48 -40
- package/dist/.setup/{usage-BOgBEKso.mjs → usage-BMzNxeR_.mjs} +5 -4
- package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-QXerDo3i.mjs} +5 -20
- package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-P77OUeoo.mjs} +10 -20
- package/dist/api.js +25 -16
- package/dist/catalog-page-worker-entrypoint.js +12 -0
- package/dist/catalog-page.worker.js +9 -0
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +50 -8
- package/dist/harness.js +344 -1
- package/dist/index.js +345 -346
- package/dist/media-understanding-provider.js +9 -22
- package/dist/migration-provider-api.js +1 -1
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +16 -33
- package/dist/session-history.worker.js +1 -1
- package/openclaw.plugin.json +14 -2
- package/package.json +11 -7
- package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
- package/dist/.setup/compact-C3i3qlzj.mjs +0 -687
- package/dist/.setup/event-projector-assistant-message-DNUR1s0A.mjs +0 -105
- package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +0 -200
- package/dist/.setup/harness-rxaaoN-o.mjs +0 -349
- package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
- package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
- package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
- package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
- package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
- package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +0 -135
- package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +0 -411
- package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
- package/dist/.setup/plugin-approval-roundtrip-CjfzafAZ.mjs +0 -122
- package/dist/.setup/provider-fFh_-VR3.mjs +0 -50
- package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
- package/dist/.setup/sandbox-guard-BBP-RbTf.mjs +0 -166
- package/dist/.setup/session-binding-_0W_fHRr.mjs +0 -721
- package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +0 -250
- package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
- package/dist/.setup/session-initialization-DH1z6fXn.mjs +0 -75
- package/dist/.setup/thread-history-page-BTx-4xsg.mjs +0 -83
- package/dist/.setup/thread-lifecycle-Cik28qWn.mjs +0 -4904
- package/dist/.setup/thread-policy-Cjs4B8xf.mjs +0 -54
- package/dist/.setup/timeout-DZF05XrR.mjs +0 -63
- package/dist/.setup/transcript-history-projection-DHNBDhCU.mjs +0 -243
- package/dist/.setup/version-CoqzXPgK.mjs +0 -12
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
1
|
+
import { u as CODEX_PLUGINS_MARKETPLACE_NAME } from "./plugin-inventory-Cky2XJUw.mjs";
|
|
2
|
+
import { t as isOnlyMigrationKind } from "./scope-DOC1Xjc8.mjs";
|
|
3
|
+
import "./config-DKhXquav.mjs";
|
|
4
|
+
import { i as hasCodexSource, n as defaultCodexHome, o as readJsonObject, r as discoverCodexSource, s as sanitizeName, t as codexPluginMigrationSubscriptionWarning } from "./source-CS_7GFJZ.mjs";
|
|
4
5
|
import { asBoolean, asOptionalRecord, isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
6
|
import { createHash } from "node:crypto";
|
|
6
7
|
import { runCommandBuffered } from "openclaw/plugin-sdk/process-runtime";
|
|
@@ -9,11 +10,12 @@ import fs from "node:fs/promises";
|
|
|
9
10
|
import { canonicalPathFromExistingAncestor, isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
|
|
10
11
|
import { readSecretFile } from "openclaw/plugin-sdk/secret-file";
|
|
11
12
|
import { fileURLToPath } from "node:url";
|
|
12
|
-
import { loadAuthProfileStoreWithoutExternalProfiles
|
|
13
|
+
import { loadAuthProfileStoreWithoutExternalProfiles } from "openclaw/plugin-sdk/agent-runtime";
|
|
13
14
|
import { applyAuthProfileConfig, buildApiKeyCredential, buildOauthProviderAuthResult, buildOpenAICodexCredentialExtra, hasUsableOAuthCredential, resolveOpenAICodexAuthIdentity, resolveOpenAICodexImportProfileName, updateAuthProfileStoreWithLock } from "openclaw/plugin-sdk/provider-auth";
|
|
14
|
-
import { extractErrorCode } from "openclaw/plugin-sdk/security-runtime";
|
|
15
|
+
import { extractErrorCode, pathExists } from "openclaw/plugin-sdk/security-runtime";
|
|
15
16
|
import { MIGRATION_REASON_TARGET_EXISTS, createMigrationItem, createMigrationManualItem, hasMigrationConfigPatchConflict, markMigrationItemConflict, markMigrationItemError, markMigrationItemSkipped, mergeMigrationConfigValue, readMigrationConfigPath, resolveMigrationConfigRuntime, summarizeMigrationItems } from "openclaw/plugin-sdk/migration";
|
|
16
|
-
import {
|
|
17
|
+
import { resolvePlannedMigrationTargets } from "openclaw/plugin-sdk/migration-runtime";
|
|
18
|
+
import { decodeOpenAICodexJwtPayload as decodeOpenAICodexJwtPayload$1 } from "openclaw/plugin-sdk/provider-oauth-runtime";
|
|
17
19
|
//#region extensions/codex/src/migration/auth-profile-target.ts
|
|
18
20
|
const OPENAI_PROVIDER_ID$1 = "openai";
|
|
19
21
|
const LEGACY_CODEX_PROFILE_ID = "openai:default";
|
|
@@ -27,7 +29,7 @@ function findMatchingOAuthProfile(store, credential) {
|
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
function oauthSubject(credential) {
|
|
30
|
-
const claims = decodeOpenAICodexJwtPayload(credential.access)?.["https://api.openai.com/auth"];
|
|
32
|
+
const claims = decodeOpenAICodexJwtPayload$1(credential.access)?.["https://api.openai.com/auth"];
|
|
31
33
|
if (!isRecord(claims)) return;
|
|
32
34
|
const accountId = normalizeOptionalString(claims.chatgpt_account_id);
|
|
33
35
|
const userId = normalizeOptionalString(claims.chatgpt_user_id) ?? normalizeOptionalString(claims.user_id);
|
|
@@ -91,15 +93,16 @@ async function readDirectKeyring(home, signal) {
|
|
|
91
93
|
return;
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
|
-
async function
|
|
96
|
+
async function readCodexCliCredentialsAsync(options) {
|
|
95
97
|
options.signal?.throwIfAborted();
|
|
98
|
+
if (!options.allowKeychainPrompt) return;
|
|
96
99
|
const home = await fs.realpath(options.codexHome).catch(() => path.resolve(options.codexHome));
|
|
97
|
-
const { CodexAppServerClient } = await import("./client-
|
|
98
|
-
const { resolveManagedCodexPackageEntrypoint, resolveManagedCodexNativeCommand } = await import("./managed-binary-
|
|
100
|
+
const { CodexAppServerClient } = await import("./client-N0JpgSzF.mjs").then((n) => n.n);
|
|
101
|
+
const { resolveManagedCodexPackageEntrypoint, resolveManagedCodexNativeCommand } = await import("./managed-binary-kiWRhNRE.mjs").then((n) => n.n);
|
|
99
102
|
const launcher = resolveManagedCodexPackageEntrypoint(path.dirname(fileURLToPath(import.meta.url)));
|
|
100
103
|
const command = launcher ? resolveManagedCodexNativeCommand(launcher) : void 0;
|
|
101
104
|
if (!command) return;
|
|
102
|
-
const signal = AbortSignal.any([AbortSignal.timeout(
|
|
105
|
+
const signal = AbortSignal.any([AbortSignal.timeout(process.platform === "darwin" ? 6e4 : 5e3), ...options.signal ? [options.signal] : []]);
|
|
103
106
|
const client = await CodexAppServerClient.start({
|
|
104
107
|
transport: "stdio",
|
|
105
108
|
command,
|
|
@@ -121,7 +124,7 @@ async function readSelectedCredentialStorage(options, requireApiKey) {
|
|
|
121
124
|
signal.addEventListener("abort", abort, { once: true });
|
|
122
125
|
let credential;
|
|
123
126
|
try {
|
|
124
|
-
credential = await readNativeCredential(client, home,
|
|
127
|
+
credential = await readNativeCredential(client, home, options, signal);
|
|
125
128
|
} catch {}
|
|
126
129
|
signal.removeEventListener("abort", abort);
|
|
127
130
|
const closed = await client.closeAndWait({
|
|
@@ -132,15 +135,11 @@ async function readSelectedCredentialStorage(options, requireApiKey) {
|
|
|
132
135
|
options.signal?.throwIfAborted();
|
|
133
136
|
return credential;
|
|
134
137
|
}
|
|
135
|
-
async function readNativeCredential(client, home,
|
|
138
|
+
async function readNativeCredential(client, home, options, signal) {
|
|
136
139
|
signal.throwIfAborted();
|
|
137
140
|
await client.initialize();
|
|
138
141
|
if (client.getRuntimeIdentity()?.codexHome !== home) return;
|
|
139
142
|
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
143
|
const configured = await client.request("config/read", {
|
|
145
144
|
includeLayers: false,
|
|
146
145
|
cwd: home
|
|
@@ -148,7 +147,7 @@ async function readNativeCredential(client, home, requireApiKey, options, signal
|
|
|
148
147
|
const mode = (await client.request("configRequirements/read", {}, { signal })).requirements?.cli_auth_credentials_store ?? configured.config.cli_auth_credentials_store ?? "file";
|
|
149
148
|
let record;
|
|
150
149
|
if (mode === "file") record = await readAuthFile(home);
|
|
151
|
-
else if ((mode === "keyring" || mode === "auto") && process.platform === "darwin"
|
|
150
|
+
else if ((mode === "keyring" || mode === "auto") && process.platform === "darwin") {
|
|
152
151
|
let cursor;
|
|
153
152
|
let encrypted;
|
|
154
153
|
do {
|
|
@@ -167,20 +166,26 @@ async function readNativeCredential(client, home, requireApiKey, options, signal
|
|
|
167
166
|
record = await readDirectKeyring(home, signal);
|
|
168
167
|
}
|
|
169
168
|
signal.throwIfAborted();
|
|
170
|
-
|
|
169
|
+
if (!record) return;
|
|
170
|
+
const oauth = options.credentialKind === "api_key" ? void 0 : parseOAuthCredential(record);
|
|
171
|
+
let apiKey = options.credentialKind === "oauth" ? void 0 : parseApiKeyCredential(record);
|
|
172
|
+
if (apiKey) {
|
|
173
|
+
const account = await client.request("account/read", { refreshToken: false }, { signal }).catch(() => void 0);
|
|
174
|
+
if (account?.account?.type !== "apiKey" || !account.requiresOpenaiAuth) apiKey = void 0;
|
|
175
|
+
}
|
|
176
|
+
signal.throwIfAborted();
|
|
177
|
+
return !client.getCloseError() && client.getModelCatalogRevision() === revision ? {
|
|
178
|
+
...oauth ? { oauth } : {},
|
|
179
|
+
...apiKey ? { apiKey } : {}
|
|
180
|
+
} : void 0;
|
|
171
181
|
}
|
|
172
182
|
function jwtExpiry(token) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return typeof exp === "number" && Number.isFinite(exp) && exp > 0 ? exp * 1e3 : void 0;
|
|
176
|
-
} catch {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
183
|
+
const exp = decodeOpenAICodexJwtPayload$1(token)?.exp;
|
|
184
|
+
return typeof exp === "number" && Number.isFinite(exp) && exp > 0 ? exp * 1e3 : void 0;
|
|
179
185
|
}
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
if (!data || mode !== void 0 && mode !== "chatgpt" && mode !== "chatgptauthtokens") return;
|
|
186
|
+
function parseOAuthCredential(data) {
|
|
187
|
+
const mode = typeof data.auth_mode === "string" ? data.auth_mode.toLowerCase() : void 0;
|
|
188
|
+
if (mode !== void 0 && mode !== "chatgpt" && mode !== "chatgptauthtokens") return;
|
|
184
189
|
const tokens = asOptionalRecord(data.tokens);
|
|
185
190
|
if (typeof tokens?.access_token !== "string" || !tokens.access_token || typeof tokens.refresh_token !== "string" || !tokens.refresh_token) return;
|
|
186
191
|
const lastRefresh = typeof data.last_refresh === "string" ? Date.parse(data.last_refresh) : NaN;
|
|
@@ -194,10 +199,9 @@ async function readCodexCliCredentialsAsync(options) {
|
|
|
194
199
|
...typeof tokens.id_token === "string" ? { idToken: tokens.id_token } : {}
|
|
195
200
|
};
|
|
196
201
|
}
|
|
197
|
-
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
if (!data || mode !== void 0 && mode !== "apikey" && mode !== "api_key") return;
|
|
202
|
+
function parseApiKeyCredential(data) {
|
|
203
|
+
const mode = typeof data.auth_mode === "string" ? data.auth_mode.toLowerCase() : void 0;
|
|
204
|
+
if (mode !== void 0 && mode !== "apikey" && mode !== "api_key") return;
|
|
201
205
|
const key = typeof data.OPENAI_API_KEY === "string" ? data.OPENAI_API_KEY.trim() : "";
|
|
202
206
|
return key ? {
|
|
203
207
|
type: "api_key",
|
|
@@ -245,13 +249,7 @@ async function readModelRefs(source) {
|
|
|
245
249
|
refs.add(OPENAI_CODEX_DEFAULT_MODEL);
|
|
246
250
|
return [...refs].toSorted();
|
|
247
251
|
}
|
|
248
|
-
async function buildCodexOAuthCredential(source,
|
|
249
|
-
const credential = await readCodexCliCredentialsAsync({
|
|
250
|
-
codexHome: source.codexHome,
|
|
251
|
-
allowKeychainPrompt: options.allowKeychainPrompt,
|
|
252
|
-
...options.signal ? { signal: options.signal } : {}
|
|
253
|
-
});
|
|
254
|
-
if (!credential) return null;
|
|
252
|
+
async function buildCodexOAuthCredential(source, credential, includeConfigPatch) {
|
|
255
253
|
const identity = resolveOpenAICodexAuthIdentity({
|
|
256
254
|
access: credential.access,
|
|
257
255
|
accountId: credential.accountId
|
|
@@ -281,39 +279,28 @@ async function buildCodexOAuthCredential(source, includeConfigPatch, options) {
|
|
|
281
279
|
result
|
|
282
280
|
} : null;
|
|
283
281
|
}
|
|
284
|
-
async function
|
|
285
|
-
const
|
|
282
|
+
async function readCodexAuthCredentials(source, options) {
|
|
283
|
+
const credentials = await readCodexCliCredentialsAsync({
|
|
286
284
|
codexHome: source.codexHome,
|
|
287
|
-
|
|
288
|
-
|
|
285
|
+
credentialKind: options.credentialKind,
|
|
286
|
+
allowKeychainPrompt: options.allowKeychainPrompt,
|
|
287
|
+
...options.signal ? { signal: options.signal } : {}
|
|
289
288
|
});
|
|
290
|
-
|
|
291
|
-
return {
|
|
289
|
+
return [credentials?.oauth ? await buildCodexOAuthCredential(source, credentials.oauth, options.includeConfigPatch) : null, credentials?.apiKey ? {
|
|
292
290
|
kind: "api_key",
|
|
293
291
|
provider: OPENAI_PROVIDER_ID,
|
|
294
292
|
profileId: "openai:codex-import",
|
|
295
|
-
key:
|
|
296
|
-
};
|
|
297
|
-
}
|
|
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);
|
|
293
|
+
key: credentials.apiKey.key
|
|
294
|
+
} : null].filter((entry) => entry !== null);
|
|
303
295
|
}
|
|
304
296
|
function replaceConfigDraft(draft, next) {
|
|
305
297
|
for (const key of Object.keys(draft)) delete draft[key];
|
|
306
298
|
Object.assign(draft, next);
|
|
307
299
|
}
|
|
308
|
-
function existingAuthProfileConfigIsCompatible(existing, profile) {
|
|
309
|
-
if (existing.provider !== profile.provider || existing.mode !== profile.mode) return false;
|
|
310
|
-
if (existing.email && profile.email && existing.email !== profile.email) return false;
|
|
311
|
-
return true;
|
|
312
|
-
}
|
|
313
300
|
function hasAuthProfileConfigConflict(config, profile, overwrite) {
|
|
314
301
|
if (overwrite) return false;
|
|
315
302
|
const existing = config.auth?.profiles?.[profile.profileId];
|
|
316
|
-
return Boolean(existing &&
|
|
303
|
+
return Boolean(existing && (existing.provider !== profile.provider || existing.mode !== profile.mode || existing.email && profile.email && existing.email !== profile.email));
|
|
317
304
|
}
|
|
318
305
|
function hasCurrentAuthProfileConfigConflict(ctx, profile) {
|
|
319
306
|
let config = ctx.config;
|
|
@@ -339,34 +326,13 @@ function applyDefaultModelIfMissing(cfg) {
|
|
|
339
326
|
}
|
|
340
327
|
};
|
|
341
328
|
}
|
|
342
|
-
function applyOAuthConfigToConfig(cfg, credential, profileId) {
|
|
343
|
-
let next = mergeMigrationConfigValue(cfg, credential.result.configPatch);
|
|
344
|
-
const profile = credential.result.profiles[0];
|
|
345
|
-
if (profile) next = applyAuthProfileConfig(next, {
|
|
346
|
-
profileId,
|
|
347
|
-
provider: profile.credential.provider,
|
|
348
|
-
mode: "oauth",
|
|
349
|
-
..."email" in profile.credential && profile.credential.email ? { email: profile.credential.email } : {},
|
|
350
|
-
..."displayName" in profile.credential && profile.credential.displayName ? { displayName: profile.credential.displayName } : {},
|
|
351
|
-
preferProfileFirst: false
|
|
352
|
-
});
|
|
353
|
-
return applyDefaultModelIfMissing(next);
|
|
354
|
-
}
|
|
355
|
-
function applyApiKeyConfigToConfig(cfg, credential, profileId) {
|
|
356
|
-
return applyAuthProfileConfig(cfg, {
|
|
357
|
-
profileId,
|
|
358
|
-
provider: credential.provider,
|
|
359
|
-
mode: "api_key",
|
|
360
|
-
displayName: CODEX_IMPORT_DISPLAY_NAME,
|
|
361
|
-
preferProfileFirst: false
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
329
|
function resolveCodexConfigPatchMode(ctx) {
|
|
365
330
|
const mode = ctx.providerOptions?.configPatchMode;
|
|
366
331
|
return mode === "none" || mode === "return" ? mode : "apply";
|
|
367
332
|
}
|
|
368
333
|
function allowCodexKeychainPrompt(ctx) {
|
|
369
|
-
|
|
334
|
+
const explicit = ctx.providerOptions?.allowKeychainPrompt;
|
|
335
|
+
return typeof explicit === "boolean" ? explicit : ctx.includeSecrets === true;
|
|
370
336
|
}
|
|
371
337
|
function resolveRequestedCredentialKind(ctx) {
|
|
372
338
|
const kind = ctx.providerOptions?.credentialKind;
|
|
@@ -397,9 +363,8 @@ async function applyCodexAuthProfileConfig(ctx, profile, applyConfig) {
|
|
|
397
363
|
base: "runtime",
|
|
398
364
|
afterWrite: { mode: "auto" },
|
|
399
365
|
mutate(draft) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
replaceConfigDraft(draft, applyConfig(current));
|
|
366
|
+
if (hasAuthProfileConfigConflict(draft, profile, Boolean(ctx.overwrite))) throw new CodexAuthConfigConflict();
|
|
367
|
+
replaceConfigDraft(draft, applyConfig(draft));
|
|
403
368
|
}
|
|
404
369
|
});
|
|
405
370
|
return "configured";
|
|
@@ -407,41 +372,42 @@ async function applyCodexAuthProfileConfig(ctx, profile, applyConfig) {
|
|
|
407
372
|
return error instanceof CodexAuthConfigConflict ? "conflict" : "unavailable";
|
|
408
373
|
}
|
|
409
374
|
}
|
|
410
|
-
async function applyCodexAuthConfig(ctx, credential, profileId) {
|
|
411
|
-
const profile = authProfileConfigForCredential(credential, profileId);
|
|
412
|
-
if (!profile) return "unavailable";
|
|
413
|
-
return applyCodexAuthProfileConfig(ctx, profile, (config) => applyCredentialConfig(config, credential, profileId));
|
|
414
|
-
}
|
|
415
375
|
function applyCredentialConfig(config, credential, profileId) {
|
|
416
|
-
|
|
376
|
+
let next = credential.kind === "oauth" ? mergeMigrationConfigValue(config, credential.result.configPatch) : config;
|
|
377
|
+
const profile = authProfileConfigForCredential(credential, profileId);
|
|
378
|
+
if (profile) next = applyAuthProfileConfig(next, {
|
|
379
|
+
...profile,
|
|
380
|
+
preferProfileFirst: false
|
|
381
|
+
});
|
|
382
|
+
return credential.kind === "oauth" ? applyDefaultModelIfMissing(next) : next;
|
|
417
383
|
}
|
|
418
384
|
async function buildCodexAuthItems(params) {
|
|
419
385
|
const configPatchMode = resolveCodexConfigPatchMode(params.ctx);
|
|
386
|
+
const allowKeychainPrompt = allowCodexKeychainPrompt(params.ctx);
|
|
420
387
|
const credentials = await readCodexAuthCredentials(params.source, {
|
|
421
388
|
credentialKind: resolveRequestedCredentialKind(params.ctx),
|
|
422
389
|
includeConfigPatch: configPatchMode !== "none",
|
|
423
|
-
allowKeychainPrompt
|
|
390
|
+
allowKeychainPrompt,
|
|
424
391
|
signal: params.ctx.signal
|
|
425
392
|
});
|
|
426
393
|
if (credentials.length === 0) {
|
|
427
394
|
const requestedKind = resolveRequestedCredentialKind(params.ctx);
|
|
428
|
-
if (!requestedKind) return [];
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
id: credentialKind === "oauth" ? OPENAI_OAUTH_ITEM_ID : OPENAI_API_KEY_ITEM_ID,
|
|
395
|
+
if (!requestedKind && allowKeychainPrompt) return [];
|
|
396
|
+
return (requestedKind ? [requestedKind] : ["oauth", "api_key"]).map((credentialKind) => createMigrationItem({
|
|
397
|
+
id: credentialKind === "api_key" ? OPENAI_API_KEY_ITEM_ID : OPENAI_OAUTH_ITEM_ID,
|
|
432
398
|
kind: "auth",
|
|
433
399
|
action: "skip",
|
|
434
400
|
source: params.source.codexHome,
|
|
435
401
|
status: "skipped",
|
|
436
402
|
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.",
|
|
403
|
+
reason: allowKeychainPrompt ? CODEX_REASON_AUTH_STORAGE_NOT_IMPORTABLE : void 0,
|
|
404
|
+
message: allowKeychainPrompt ? "No supported Codex credential could be imported. Continue with sign-in to connect OpenClaw." : "Codex credentials have not been inspected. Confirm credential import to check the current Codex sign-in.",
|
|
439
405
|
details: {
|
|
440
406
|
provider: OPENAI_PROVIDER_ID,
|
|
441
407
|
credentialKind,
|
|
442
408
|
credentialImportUnavailable: true
|
|
443
409
|
}
|
|
444
|
-
})
|
|
410
|
+
}));
|
|
445
411
|
}
|
|
446
412
|
const store = loadAuthProfileStoreWithoutExternalProfiles(params.targets.agentDir);
|
|
447
413
|
const skipped = !params.ctx.includeSecrets;
|
|
@@ -475,7 +441,24 @@ async function buildCodexAuthItems(params) {
|
|
|
475
441
|
});
|
|
476
442
|
});
|
|
477
443
|
}
|
|
478
|
-
|
|
444
|
+
function createCodexAuthItemApplier(params) {
|
|
445
|
+
const { items, ...context } = params;
|
|
446
|
+
const selectedKinds = new Set(items.filter((item) => item.kind === "auth" && item.status === "planned").map((item) => item.details?.credentialKind));
|
|
447
|
+
const selectedKind = selectedKinds.size === 1 ? selectedKinds.values().next().value : void 0;
|
|
448
|
+
let snapshot;
|
|
449
|
+
const readCredentials = () => snapshot ??= readCodexAuthCredentials(context.source, {
|
|
450
|
+
credentialKind: selectedKind === "oauth" || selectedKind === "api_key" ? selectedKind : void 0,
|
|
451
|
+
includeConfigPatch: resolveCodexConfigPatchMode(context.ctx) !== "none",
|
|
452
|
+
allowKeychainPrompt: allowCodexKeychainPrompt(context.ctx),
|
|
453
|
+
signal: context.ctx.signal
|
|
454
|
+
});
|
|
455
|
+
return (item) => applyCodexAuthItem({
|
|
456
|
+
...context,
|
|
457
|
+
item,
|
|
458
|
+
readCredentials
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
async function applyCodexAuthItem(params) {
|
|
479
462
|
const { ctx, item, source, targets } = params;
|
|
480
463
|
if (item.status !== "planned") return [item];
|
|
481
464
|
const profileId = typeof item.details?.profileId === "string" ? item.details.profileId : "";
|
|
@@ -484,14 +467,11 @@ async function applyCodexAuthItems(params) {
|
|
|
484
467
|
const credentialKind = item.details?.credentialKind;
|
|
485
468
|
if (!profileId || !provider || credentialKind !== "oauth" && credentialKind !== "api_key") return [markMigrationItemError(item, CODEX_REASON_MISSING_AUTH_METADATA)];
|
|
486
469
|
const configPatchMode = resolveCodexConfigPatchMode(ctx);
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
})).find((candidate) => candidate.provider === provider && candidate.kind === credentialKind && (!sourceProfileId || candidate.profileId === sourceProfileId));
|
|
493
|
-
if (!credential) 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)];
|
|
470
|
+
ctx.signal?.throwIfAborted();
|
|
471
|
+
const credentials = await params.readCredentials();
|
|
472
|
+
ctx.signal?.throwIfAborted();
|
|
473
|
+
const credential = credentials.find((candidate) => candidate.provider === provider && candidate.kind === credentialKind && (!sourceProfileId || candidate.profileId === sourceProfileId));
|
|
474
|
+
if (!credential || item.details?.sourceCredentialFingerprint !== sourceCredentialFingerprint(credential)) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_NO_LONGER_PRESENT)];
|
|
495
475
|
if (item.details?.legacyNativeHome !== void 0 && (item.details.legacyNativeHome !== source.codexHome || source.codexHome !== defaultCodexHome())) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_NO_LONGER_PRESENT)];
|
|
496
476
|
ctx.signal?.throwIfAborted();
|
|
497
477
|
const oauthProfile = credential.kind === "oauth" ? credential.result.profiles[0] : void 0;
|
|
@@ -536,7 +516,7 @@ async function applyCodexAuthItems(params) {
|
|
|
536
516
|
if (conflicted) return [markMigrationItemConflict(item, CODEX_REASON_AUTH_PROFILE_EXISTS)];
|
|
537
517
|
if (unusable) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_PROFILE_UNUSABLE)];
|
|
538
518
|
if (!store || !loadAuthProfileStoreWithoutExternalProfiles(targets.agentDir).profiles[profileId]) return [markMigrationItemError(item, CODEX_REASON_AUTH_PROFILE_WRITE_FAILED)];
|
|
539
|
-
const configResult = configPatchMode !== "apply" ? "unavailable" : await
|
|
519
|
+
const configResult = configPatchMode !== "apply" ? "unavailable" : await applyCodexAuthProfileConfig(ctx, configProfile, (config) => applyCredentialConfig(config, credential, profileId));
|
|
540
520
|
if (configResult === "conflict") return [markMigrationItemConflict(item, CODEX_REASON_AUTH_PROFILE_EXISTS)];
|
|
541
521
|
const migratedItem = {
|
|
542
522
|
...item,
|
|
@@ -552,44 +532,28 @@ async function applyCodexAuthItems(params) {
|
|
|
552
532
|
}
|
|
553
533
|
function buildCodexAuthConfigPatchItems(ctx, item, credential, profileId) {
|
|
554
534
|
const next = applyCredentialConfig(ctx.config, credential, profileId);
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
535
|
+
return [{
|
|
536
|
+
suffix: "auth",
|
|
537
|
+
path: ["auth"],
|
|
538
|
+
value: next.auth,
|
|
539
|
+
message: "Configure imported Codex auth profile."
|
|
540
|
+
}, {
|
|
541
|
+
suffix: "agents-defaults",
|
|
542
|
+
path: ["agents", "defaults"],
|
|
543
|
+
value: next.agents?.defaults,
|
|
544
|
+
message: "Configure imported Codex models."
|
|
545
|
+
}].flatMap(({ suffix, path, value, message }) => value ? [createMigrationItem({
|
|
546
|
+
id: `${item.id}:config:${suffix}`,
|
|
558
547
|
kind: "config",
|
|
559
548
|
action: "merge",
|
|
560
549
|
status: "migrated",
|
|
561
|
-
target: "
|
|
562
|
-
message
|
|
550
|
+
target: path.join("."),
|
|
551
|
+
message,
|
|
563
552
|
details: {
|
|
564
|
-
path
|
|
565
|
-
value
|
|
566
|
-
}
|
|
567
|
-
}));
|
|
568
|
-
if (next.agents?.defaults) items.push(createMigrationItem({
|
|
569
|
-
id: `${item.id}:config:agents-defaults`,
|
|
570
|
-
kind: "config",
|
|
571
|
-
action: "merge",
|
|
572
|
-
status: "migrated",
|
|
573
|
-
target: "agents.defaults",
|
|
574
|
-
message: "Configure imported Codex models.",
|
|
575
|
-
details: {
|
|
576
|
-
path: ["agents", "defaults"],
|
|
577
|
-
value: next.agents.defaults
|
|
553
|
+
path,
|
|
554
|
+
value
|
|
578
555
|
}
|
|
579
|
-
}));
|
|
580
|
-
return items;
|
|
581
|
-
}
|
|
582
|
-
//#endregion
|
|
583
|
-
//#region extensions/codex/src/migration/targets.ts
|
|
584
|
-
function resolveCodexMigrationTargets(ctx) {
|
|
585
|
-
const cfg = ctx.config;
|
|
586
|
-
const agentId = ctx.targetAgentId ?? resolveDefaultAgentId(cfg);
|
|
587
|
-
const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);
|
|
588
|
-
const configuredAgentDir = resolveAgentConfig(cfg, agentId)?.agentDir?.trim();
|
|
589
|
-
return {
|
|
590
|
-
workspaceDir,
|
|
591
|
-
agentDir: ctx.runtime?.agent?.resolveAgentDir(cfg, agentId) ?? (configuredAgentDir ? resolveHomePath(configuredAgentDir) : void 0) ?? path.join(ctx.stateDir, "agents", agentId, "agent")
|
|
592
|
-
};
|
|
556
|
+
})] : []);
|
|
593
557
|
}
|
|
594
558
|
//#endregion
|
|
595
559
|
//#region extensions/codex/src/migration/plan.ts
|
|
@@ -690,7 +654,7 @@ async function buildCodexSkillItems(params) {
|
|
|
690
654
|
}, /* @__PURE__ */ new Map());
|
|
691
655
|
return await Promise.all(planned.map(async (item) => {
|
|
692
656
|
const collision = (resolvedCounts.get(item.name) ?? 0) > 1;
|
|
693
|
-
const targetExists = await
|
|
657
|
+
const targetExists = await pathExists(item.target);
|
|
694
658
|
const conflict = collision || targetExists && !params.overwrite;
|
|
695
659
|
return createMigrationItem({
|
|
696
660
|
id: `skill:${item.name}`,
|
|
@@ -715,10 +679,7 @@ function readExistingCodexPluginEntries(config) {
|
|
|
715
679
|
function hasExistingCodexPluginEntry(existingEntries, configKey, pluginName, nextEntry) {
|
|
716
680
|
const existingEntry = existingEntries[configKey];
|
|
717
681
|
if (existingEntry !== void 0) return !isLegacyDestructivePolicyRepair(existingEntry, nextEntry);
|
|
718
|
-
return Object.values(existingEntries).some((entry) =>
|
|
719
|
-
if (!isRecord(entry)) return false;
|
|
720
|
-
return entry.pluginName === pluginName;
|
|
721
|
-
});
|
|
682
|
+
return Object.values(existingEntries).some((entry) => isRecord(entry) && entry.pluginName === pluginName);
|
|
722
683
|
}
|
|
723
684
|
function isLegacyDestructivePolicyRepair(existing, nextEntry) {
|
|
724
685
|
const existingEntry = isRecord(existing) ? existing : void 0;
|
|
@@ -743,14 +704,12 @@ function buildPluginItems(ctx, plugins) {
|
|
|
743
704
|
for (const plugin of plugins) {
|
|
744
705
|
if (plugin.migratable && plugin.marketplaceName === "openai-curated" && plugin.pluginName) {
|
|
745
706
|
const configKey = plugin.pluginName;
|
|
707
|
+
const allowDestructiveActions = readExistingPluginAllowDestructiveActions(existingPluginEntries[configKey], plugin.pluginName);
|
|
746
708
|
const plannedEntry = {
|
|
747
709
|
enabled: true,
|
|
748
710
|
marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
749
711
|
pluginName: plugin.pluginName,
|
|
750
|
-
...
|
|
751
|
-
const allowDestructiveActions = readExistingPluginAllowDestructiveActions(existingPluginEntries[configKey], plugin.pluginName);
|
|
752
|
-
return allowDestructiveActions ? { allow_destructive_actions: allowDestructiveActions } : {};
|
|
753
|
-
})()
|
|
712
|
+
...allowDestructiveActions ? { allow_destructive_actions: allowDestructiveActions } : {}
|
|
754
713
|
};
|
|
755
714
|
const conflict = !ctx.overwrite && hasExistingCodexPluginEntry(existingPluginEntries, configKey, plugin.pluginName, plannedEntry);
|
|
756
715
|
items.push(createMigrationItem({
|
|
@@ -769,8 +728,8 @@ function buildPluginItems(ctx, plugins) {
|
|
|
769
728
|
pluginName: plugin.pluginName,
|
|
770
729
|
sourceInstalled: plugin.installed === true,
|
|
771
730
|
sourceEnabled: plugin.enabled === true,
|
|
772
|
-
...
|
|
773
|
-
...plugin.apps && plugin.apps.length > 0 &&
|
|
731
|
+
...allowDestructiveActions ? { allowDestructiveActions } : {},
|
|
732
|
+
...plugin.apps && plugin.apps.length > 0 && ctx.providerOptions?.verifyPluginApps !== true ? { sourceAppVerification: CODEX_PLUGIN_SOURCE_APP_VERIFICATION_UNVERIFIED } : {}
|
|
774
733
|
}
|
|
775
734
|
}));
|
|
776
735
|
continue;
|
|
@@ -803,9 +762,6 @@ function buildPluginItems(ctx, plugins) {
|
|
|
803
762
|
}
|
|
804
763
|
return items;
|
|
805
764
|
}
|
|
806
|
-
function shouldVerifyPluginApps(ctx) {
|
|
807
|
-
return ctx.providerOptions?.verifyPluginApps === true;
|
|
808
|
-
}
|
|
809
765
|
function readCodexPluginMigrationConfigEntry(item, enabled) {
|
|
810
766
|
const configKey = item.details?.configKey;
|
|
811
767
|
const marketplaceName = item.details?.marketplaceName;
|
|
@@ -896,15 +852,15 @@ function buildPluginConfigItem(ctx, pluginItems) {
|
|
|
896
852
|
});
|
|
897
853
|
}
|
|
898
854
|
async function buildCodexMigrationPlan(ctx) {
|
|
899
|
-
const targets =
|
|
900
|
-
const memoryOnly = ctx
|
|
901
|
-
const authOnly = ctx
|
|
855
|
+
const targets = resolvePlannedMigrationTargets(ctx);
|
|
856
|
+
const memoryOnly = isOnlyMigrationKind(ctx, "memory");
|
|
857
|
+
const authOnly = isOnlyMigrationKind(ctx, "auth");
|
|
902
858
|
const source = await discoverCodexSource({
|
|
903
859
|
input: ctx.source,
|
|
904
860
|
memoryOnly,
|
|
905
861
|
authOnly,
|
|
906
862
|
evaluatePluginMigrationEligibility: !memoryOnly && !authOnly,
|
|
907
|
-
verifyPluginApps:
|
|
863
|
+
verifyPluginApps: ctx.providerOptions?.verifyPluginApps === true
|
|
908
864
|
});
|
|
909
865
|
if (!hasCodexSource(source) && !authOnly) throw new Error(`Codex state was not found at ${source.root}. Pass --from <path> if it lives elsewhere.`);
|
|
910
866
|
const items = [];
|
|
@@ -938,7 +894,6 @@ async function buildCodexMigrationPlan(ctx) {
|
|
|
938
894
|
}));
|
|
939
895
|
}
|
|
940
896
|
const warnings = [
|
|
941
|
-
...!ctx.includeSecrets && items.some((item) => item.kind === "auth") ? ["Auth credentials were detected but skipped. Re-run interactively or pass --include-secrets to import supported credentials."] : [],
|
|
942
897
|
...items.some((item) => item.status === "conflict") ? ["Conflicts were found. Re-run with --overwrite to replace conflicting migration targets after item-level backups."] : [],
|
|
943
898
|
...source.pluginDiscoveryError ? [`Codex app-server plugin inventory discovery failed: ${source.pluginDiscoveryError}. Cached plugin bundles, if any, are advisory only.`] : [],
|
|
944
899
|
...source.plugins.some((plugin) => plugin.migrationBlock?.code === "codex_subscription_required") ? [codexPluginMigrationSubscriptionWarning()] : []
|
|
@@ -960,4 +915,4 @@ async function buildCodexMigrationPlan(ctx) {
|
|
|
960
915
|
};
|
|
961
916
|
}
|
|
962
917
|
//#endregion
|
|
963
|
-
export { CODEX_PLUGIN_CONFIG_ITEM_ID, CODEX_PLUGIN_CONFIG_PATH, buildCodexMigrationPlan, buildCodexPluginsConfigValue, hasCodexPluginConfigConflict,
|
|
918
|
+
export { CODEX_PLUGIN_CONFIG_ITEM_ID, CODEX_PLUGIN_CONFIG_PATH, buildCodexMigrationPlan, buildCodexPluginsConfigValue, hasCodexPluginConfigConflict, resolveCodexConfigPatchMode as n, readCodexPluginMigrationConfigEntry, createCodexAuthItemApplier as t };
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "./config-
|
|
1
|
+
import { i as listCodexPluginMetadata, n as isOpenAiCuratedMarketplace, o as pluginReadParams, r as isOpenAiCuratedMarketplaceName, t as findCodexMarketplacePluginSummary, u as CODEX_PLUGINS_MARKETPLACE_NAME } from "./plugin-inventory-Cky2XJUw.mjs";
|
|
2
|
+
import { n as CodexAppServerRpcError } from "./rpc-error-BlD2vuzn.mjs";
|
|
3
|
+
import "./config-DKhXquav.mjs";
|
|
4
4
|
import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
5
5
|
//#region extensions/codex/src/app-server/plugin-activation.ts
|
|
6
|
-
/**
|
|
7
|
-
* Activates legacy curated Codex plugins while requiring owner-managed
|
|
8
|
-
* installation for every other marketplace.
|
|
9
|
-
*/
|
|
10
6
|
/** Activates legacy curated plugins without granting install authority to other marketplaces. */
|
|
11
7
|
async function ensureCodexPluginActivation(params) {
|
|
12
8
|
if (params.identity.marketplaceName === "workspace-directory") return activationFailure(params.identity, "disabled", { message: "workspace-directory plugins must be installed and enabled outside OpenClaw before use." });
|
|
@@ -14,7 +10,7 @@ async function ensureCodexPluginActivation(params) {
|
|
|
14
10
|
const target = params.identity.pluginName.endsWith(`@${params.identity.marketplaceName}`) ? params.identity.pluginName : `${params.identity.pluginName}@${params.identity.marketplaceName}`;
|
|
15
11
|
return activationFailure(params.identity, "disabled", { message: `${params.identity.marketplaceName} plugins must be installed and enabled by an owner before use. Run /codex plugins install ${target}.` });
|
|
16
12
|
}
|
|
17
|
-
const listed = await
|
|
13
|
+
const listed = await listCodexPluginMetadata(params, CODEX_PLUGINS_MARKETPLACE_NAME);
|
|
18
14
|
const resolved = findCodexMarketplacePluginSummary(listed, params.identity.marketplaceName, params.identity.pluginName);
|
|
19
15
|
if (!resolved) {
|
|
20
16
|
if (!listed.marketplaces.some((marketplace) => isOpenAiCuratedMarketplace(marketplace))) return activationFailure(params.identity, "marketplace_missing", { message: `Codex marketplace ${CODEX_PLUGINS_MARKETPLACE_NAME} was not found.` });
|
|
@@ -45,19 +41,10 @@ async function ensureCodexPluginActivation(params) {
|
|
|
45
41
|
diagnostics: [{ message: `Codex plugin install failed: ${coerceErrorMessage(error)}` }]
|
|
46
42
|
};
|
|
47
43
|
}
|
|
48
|
-
if (params.metadataCache && params.appCacheKey) params.metadataCache.invalidate(params.appCacheKey);
|
|
49
44
|
const refreshDiagnostics = [];
|
|
50
45
|
let refreshFailed = false;
|
|
51
46
|
try {
|
|
52
|
-
const refreshResult = await refreshCodexPluginRuntimeState(
|
|
53
|
-
request: params.request,
|
|
54
|
-
appCache: params.appCache,
|
|
55
|
-
appCacheKey: params.appCacheKey,
|
|
56
|
-
configCwd: params.configCwd,
|
|
57
|
-
metadataCache: params.metadataCache,
|
|
58
|
-
deferAppInventoryRefresh: params.deferAppInventoryRefresh,
|
|
59
|
-
targetAppIds: params.targetAppIds
|
|
60
|
-
});
|
|
47
|
+
const refreshResult = await refreshCodexPluginRuntimeState(params);
|
|
61
48
|
refreshDiagnostics.push(...refreshResult.diagnostics);
|
|
62
49
|
} catch (error) {
|
|
63
50
|
refreshFailed = true;
|
|
@@ -74,25 +61,15 @@ async function ensureCodexPluginActivation(params) {
|
|
|
74
61
|
diagnostics: [...refreshDiagnostics, ...installResponse.appsNeedingAuth.map((app) => ({ message: `${app.name} requires app authentication before plugin tools are exposed.` }))]
|
|
75
62
|
};
|
|
76
63
|
}
|
|
77
|
-
/** Forces Codex plugin, skill, hook, MCP, and app inventory refreshes after activation. */
|
|
78
64
|
async function refreshCodexPluginRuntimeState(params) {
|
|
79
65
|
const diagnostics = [];
|
|
80
|
-
|
|
81
|
-
await params
|
|
82
|
-
cwds: params.configCwd ? [params.configCwd] : [],
|
|
83
|
-
forceReload: true
|
|
84
|
-
});
|
|
85
|
-
try {
|
|
86
|
-
await params.request("hooks/list", { cwds: params.configCwd ? [params.configCwd] : [] });
|
|
87
|
-
} catch (error) {
|
|
88
|
-
diagnostics.push({ message: `Codex hooks refresh skipped: ${coerceErrorMessage(error)}` });
|
|
89
|
-
}
|
|
90
|
-
await params.request("config/mcpServer/reload", void 0);
|
|
66
|
+
if (params.appCacheKey) params.metadataCache?.invalidate(params.appCacheKey);
|
|
67
|
+
await listCodexPluginMetadata(params, CODEX_PLUGINS_MARKETPLACE_NAME, { forceRefetch: true });
|
|
91
68
|
if (params.appCache && params.appCacheKey) try {
|
|
92
69
|
await refreshCodexAppRuntimeState({
|
|
93
70
|
...params,
|
|
94
71
|
appCache: params.appCache,
|
|
95
|
-
appCacheKey: params.appCacheKey
|
|
72
|
+
appCacheKey: params.appInventoryCacheKey ?? params.appCacheKey
|
|
96
73
|
});
|
|
97
74
|
} catch (error) {
|
|
98
75
|
diagnostics.push({ message: `Codex app inventory refresh skipped: ${coerceErrorMessage(error)}` });
|
|
@@ -111,27 +88,13 @@ async function refreshCodexAppRuntimeState(params) {
|
|
|
111
88
|
targetAppIds: params.targetAppIds
|
|
112
89
|
});
|
|
113
90
|
}
|
|
114
|
-
|
|
115
|
-
const requestParams = {
|
|
116
|
-
...params.configCwd ? { cwds: [params.configCwd] } : {},
|
|
117
|
-
...options.forceRefetch ? { forceRefetch: true } : {}
|
|
118
|
-
};
|
|
119
|
-
if (!params.metadataCache || !params.appCacheKey) return await params.request("plugin/list", requestParams);
|
|
120
|
-
return (await params.metadataCache.load({
|
|
121
|
-
appCacheKey: params.appCacheKey,
|
|
122
|
-
queryKind: "curated-global",
|
|
123
|
-
requestParams,
|
|
124
|
-
request: async (method, listedParams) => await params.request(method, listedParams),
|
|
125
|
-
cacheable: (response) => response.marketplaces.some((marketplace) => isOpenAiCuratedMarketplace(marketplace))
|
|
126
|
-
})).response;
|
|
127
|
-
}
|
|
128
|
-
function activationFailure(identity, reason, diagnostic, extraDiagnostics = []) {
|
|
91
|
+
function activationFailure(identity, reason, diagnostic) {
|
|
129
92
|
return {
|
|
130
93
|
identity,
|
|
131
94
|
ok: false,
|
|
132
95
|
reason,
|
|
133
96
|
installAttempted: false,
|
|
134
|
-
diagnostics: [diagnostic
|
|
97
|
+
diagnostics: [diagnostic]
|
|
135
98
|
};
|
|
136
99
|
}
|
|
137
100
|
//#endregion
|