codex-copilot-dx 1.2.20 → 1.2.21
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 +3 -3
- package/bin/cli.mjs +9 -2
- package/docs/ARCHITECTURE.md +25 -0
- package/docs/REFERENCE.md +49 -12
- package/package.json +1 -1
- package/src/access-settings.mjs +1 -0
- package/src/client-model-plan.mjs +11 -4
- package/src/clients/codex-models.mjs +2 -2
- package/src/codex-api-config.mjs +94 -26
- package/src/codex-client-doctor.mjs +19 -5
- package/src/codex-config-doctor.mjs +6 -4
- package/src/config.mjs +8 -5
- package/src/connection-runtime.mjs +12 -6
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install -g codex-copilot-dx@latest
|
|
|
11
11
|
ccdx
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
No Node or Git? Download [install.sh](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.
|
|
14
|
+
No Node or Git? Download [install.sh](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.21/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.21/install.ps1) (Windows), then run `sh install.sh` or `./install.ps1` under your current shell policy. The bootstrap reuses compatible Node/npm or installs verified official Node 24.22.0 privately for CCDX. It adds no Git, compiler or system package manager. It keeps registry/proxy/certificate policy, verifies the Release package and installed runtime, and restores the prior CCDX package if installation fails. Dependencies still need your configured registry. See [installation limits and private command paths](docs/REFERENCE.md#install-without-node-or-git).
|
|
15
15
|
|
|
16
16
|
CCDX reuses a compatible local credential or starts GitHub Device Flow, listens on `127.0.0.1:2026`, configures Codex, and opens the App. Interactive desktop starts also open the local WebUI once; use `ccdx --no-browser` or disable this in WebUI settings. No client binary patch is needed. On Windows, open the App manually unless native prediction setup is enabled. In restricted Windows PowerShell, use `npm.cmd` to install and `ccdx.cmd` for the first launch, or run `ccdx.cmd doctor --fix`. Startup, updates and explicit repair remove only CCDX's exact npm-generated `.ps1` launchers so later calls can use `ccdx`. The npm package adds no install hook or policy change; custom launchers are preserved. npm's own script is untouched. The configured `dummy` API key is a placeholder, not a credential.
|
|
17
17
|
|
|
@@ -52,11 +52,11 @@ Requests shows live app/source/model flow above existing summaries and finished
|
|
|
52
52
|
|
|
53
53
|
## Add your own API
|
|
54
54
|
|
|
55
|
-
Run `ccdx web` without GitHub sign-in. In **Model sources → Add API**, enter the HTTPS address/key, read the catalog, select models and declare their real interfaces. Then open **Codex** or **Claude**, choose visible models across sources, set a default and save. Claude App/Code use Messages; Codex uses Responses, all on port 2026. A request stays on its selected deployment; there is no automatic cross-source retry or model replacement. Reopen clients after configuration changes and start a new conversation after source/key changes. Stop management before normal `ccdx` startup for the live terminal.
|
|
55
|
+
Run `ccdx web` without GitHub sign-in. In **Model sources → Add API**, enter the HTTPS address/key, read the catalog, select models and declare their real interfaces. Then open **Codex** or **Claude**, choose visible models across sources, set a default and save. Claude App/Code use Messages; Codex uses Responses, all on port 2026. GitHub-only Codex selections retain native OpenAI mode and readable model names. A request stays on its selected deployment; there is no automatic cross-source retry or model replacement. Reopen clients after configuration changes and start a new conversation after source/key changes. Stop management before normal `ccdx` startup for the live terminal.
|
|
56
56
|
|
|
57
57
|
Keys use system credential protection or an explicit environment reference; clients receive separate local credentials. Saving reads model metadata automatically, without inference. Startup and the existing model refresh cycle also refresh enabled APIs when the 30-minute cache expires; failed reads retain saved configuration. Closed sources can be restored on Model sources; closed apps remain reachable for restoration on their app pages. Pinned streams finish on their original source. The version-two graph preserves old single-source visibility and saves a byte-for-byte v1 backup before migration. User and managed client settings remain protected.
|
|
58
58
|
|
|
59
|
-
Model details show upstream capabilities per API, with optional manual overrides collapsed below. Context, input/output limits, reasoning levels, thinking modes, input types, tools and native search are deployment-specific. Structured Anthropic declarations are mapped to Messages; they do not grant the same capabilities to a gateway's other interfaces. Missing and unrecognized metadata are distinguished, without guessing from model names. Manual overrides, including false, take priority. Claude synchronization projects compatible routes, supported host controls and per-model budgets. Unknown or out-of-range windows and unverified client versions are reported as limited; they are not promoted to 1M. Output requests are bounded by declared limits. Compatibility routes do not prove that every model supports every App tool, search or reasoning mode. See the [capability and synchronization limits](docs/REFERENCE.md#model-capabilities-and-claude-synchronization). [1.2.
|
|
59
|
+
Model details show upstream capabilities per API, with optional manual overrides collapsed below. Context, input/output limits, reasoning levels, thinking modes, input types, tools and native search are deployment-specific. Structured Anthropic declarations are mapped to Messages; they do not grant the same capabilities to a gateway's other interfaces. Missing and unrecognized metadata are distinguished, without guessing from model names. Manual overrides, including false, take priority. Claude synchronization projects compatible routes, supported host controls and per-model budgets. Unknown or out-of-range windows and unverified client versions are reported as limited; they are not promoted to 1M. Output requests are bounded by declared limits. Compatibility routes do not prove that every model supports every App tool, search or reasoning mode. See the [capability and synchronization limits](docs/REFERENCE.md#model-capabilities-and-claude-synchronization). [1.2.21 changes and verification](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/RELEASE_1.2.21.md) cover native GitHub integration, friendly model names and startup/ownership protection.
|
|
60
60
|
|
|
61
61
|
## Microsoft 365 access
|
|
62
62
|
|
package/bin/cli.mjs
CHANGED
|
@@ -481,7 +481,14 @@ try {
|
|
|
481
481
|
|
|
482
482
|
// Refresh the VS Code version in the background; fallback is non-blocking.
|
|
483
483
|
void refreshVSCodeVersion();
|
|
484
|
-
if (providerRuntime.selection().codex === "github")
|
|
484
|
+
if (providerRuntime.selection().codex === "github") {
|
|
485
|
+
await profileModels.initialize();
|
|
486
|
+
// Provider setup can run before GitHub's directory exists. Reconcile again
|
|
487
|
+
// before opening the App, then join any existing stale-cache refresh.
|
|
488
|
+
const refreshing = profileModels.codexRegistry.refreshInFlight ? profileModels.refreshAll() : null;
|
|
489
|
+
await providerRuntime.syncClients(["codex"]);
|
|
490
|
+
void refreshing?.then(() => providerRuntime.selection().codex === "github" && providerRuntime.syncClients(["codex"])).catch(() => {});
|
|
491
|
+
}
|
|
485
492
|
if (profileModels.codexRegistry.source !== "live") {
|
|
486
493
|
console.log(startupCheck("info", "Models", `${profileModels.codexRegistry.source} list loaded${profileModels.codexRegistry.refreshInFlight ? "; refreshing" : ""}`));
|
|
487
494
|
}
|
|
@@ -539,7 +546,7 @@ try {
|
|
|
539
546
|
const refreshIntervalMs = RUNTIME.modelRefreshIntervalMs;
|
|
540
547
|
if (Number.isFinite(refreshIntervalMs) && refreshIntervalMs > 0) {
|
|
541
548
|
modelRefreshTimer = setInterval(() => {
|
|
542
|
-
if (providerRuntime.selection().codex === "github") profileModels.refreshAll().catch(() => {});
|
|
549
|
+
if (providerRuntime.selection().codex === "github") profileModels.refreshAll().then(() => providerRuntime.selection().codex === "github" && providerRuntime.syncClients(["codex"])).catch(() => {});
|
|
543
550
|
providerRuntime.refresh().catch(() => {});
|
|
544
551
|
}, refreshIntervalMs);
|
|
545
552
|
modelRefreshTimer.unref?.();
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -676,3 +676,28 @@ The existing dashboard connection controller owns one draft per client and
|
|
|
676
676
|
local operation feedback. Source browsing is one shared selection for management,
|
|
677
677
|
account and catalog. Presentation retains existing palettes, motion and native
|
|
678
678
|
controls; it adds no runtime UI dependency or protocol abstraction framework.
|
|
679
|
+
|
|
680
|
+
## Native Codex provider identity
|
|
681
|
+
|
|
682
|
+
GitHub-only managed bindings use the built-in OpenAI provider and a journal-owned
|
|
683
|
+
`openai_base_url`. Non-GitHub bindings retain the private keyed provider. Provider
|
|
684
|
+
identity is a client UI/auth boundary, not merely a transport setting; a native
|
|
685
|
+
app-server catalog does not establish the App's custom-provider rendering path.
|
|
686
|
+
The Codex reconciliation journal migrates v1 entries, records/restores root base
|
|
687
|
+
URLs, shares the startup configuration lock and protects user edits. Startup
|
|
688
|
+
leaves journal-owned base URLs to that writer. An unchanged inactive legacy
|
|
689
|
+
provider table remains available to sessions that recorded its ID; session files
|
|
690
|
+
and native authentication are not migrated or rewritten.
|
|
691
|
+
|
|
692
|
+
Codex exposes unambiguous upstream IDs and friendly metadata. Qualified defaults
|
|
693
|
+
and legacy route aliases stay internal and source-bound. Same-named deployments
|
|
694
|
+
remain distinct, with suffixes only where needed. Native replay covers a legacy
|
|
695
|
+
session, first model/list after cold/warm/old-cache starts, authMethod, effective
|
|
696
|
+
provider, model visibility and synthetic inference. Real App UI acceptance remains
|
|
697
|
+
separate from this RPC evidence.
|
|
698
|
+
|
|
699
|
+
A complete recognized qualified-ID model cache can be retired to a single private
|
|
700
|
+
backup during native reconciliation, before the config transaction commits.
|
|
701
|
+
Unknown/partial caches are not claimed. On config commit failure, the old cache
|
|
702
|
+
is restored only if the client has not created a new cache. This is a bounded
|
|
703
|
+
schema migration, not a periodic cache purge or a credential/session reset.
|
package/docs/REFERENCE.md
CHANGED
|
@@ -107,16 +107,27 @@ clients use the existing profile with generic name CCDX; M365's beta restriction
|
|
|
107
107
|
is not imposed on APIs. Only an unchanged owned restriction is restored. Adding
|
|
108
108
|
an API alone does not migrate existing M365 client credentials. First explicit
|
|
109
109
|
Claude connection management installs private client keys; reopen affected apps.
|
|
110
|
-
Codex reconciliation owns
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
provider
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
Codex reconciliation owns provider selection, the selected model, the private
|
|
111
|
+
provider table and, in native mode, `openai_base_url`. GitHub-only selections use
|
|
112
|
+
this base URL with the built-in `openai` provider; fresh native setups create no
|
|
113
|
+
custom provider table. The App therefore keeps its native provider branch.
|
|
114
|
+
An unchanged old `ccdx_gateway` table is retained inactive during migration so
|
|
115
|
+
existing sessions can still resume their recorded provider. New sessions use
|
|
116
|
+
`openai`; existing session files are never rewritten to disguise their provider.
|
|
117
|
+
|
|
118
|
+
The versioned ownership journal records exact prior/owned declarations and
|
|
119
|
+
supports native/private switching and restoration. Startup defers an owned base
|
|
120
|
+
URL to this reconciliation instead of overwriting preserved user edits. Identical
|
|
121
|
+
setup does not rewrite the file. A missing default keeps its identity and does
|
|
122
|
+
not prevent a safe native route repair. User model/base edits remain protected.
|
|
123
|
+
Reconciliation never writes `auth.json` or replaces native credentials.
|
|
124
|
+
|
|
125
|
+
Non-GitHub deployments retain the private provider/local-key route. Existing
|
|
126
|
+
native sign-in or credential-store policy keeps `requires_openai_auth = true`;
|
|
127
|
+
a fresh API-only profile remains usable without ChatGPT login. Native account
|
|
128
|
+
operations retain their own authentication. App custom-provider controls can
|
|
129
|
+
differ from native OpenAI controls; CLI catalogs do not prove App UI parity.
|
|
130
|
+
Reopen Codex after an owned provider/authentication configuration change.
|
|
120
131
|
|
|
121
132
|
GitHub-only explicit bindings preserve the legacy native loopback access contract,
|
|
122
133
|
including requests from a process that has not yet reloaded its configuration.
|
|
@@ -130,7 +141,8 @@ Saving them fails without changing prior settings; refresh the catalog or explic
|
|
|
130
141
|
clear the affected selection. A missing directory entry never means deselection.
|
|
131
142
|
|
|
132
143
|
A manual Codex provider includes an authenticated `model_catalog_url` on the same
|
|
133
|
-
listener.
|
|
144
|
+
listener. Native app-server catalogs list configured names; the App may still use
|
|
145
|
+
its custom-provider UI for non-GitHub selections. Unknown names
|
|
134
146
|
use conservative metadata without borrowed model instructions, invented context,
|
|
135
147
|
vision, web search or Fast claims. API-specific Auto Review uses its configured
|
|
136
148
|
model and advertised efforts; following the client does not synthesize low.
|
|
@@ -176,6 +188,16 @@ Codex/Claude own the selected deployment set, default and automatic synchronizat
|
|
|
176
188
|
Claude App and Claude Code have separate segments and local keys. Settings retains
|
|
177
189
|
appearance, startup and updates; source/client editors are not duplicated there.
|
|
178
190
|
|
|
191
|
+
Codex catalogs and its `model` setting use an unambiguous upstream ID. Source
|
|
192
|
+
suffixes appear only for same-named authorized deployments; friendly upstream
|
|
193
|
+
names/descriptions are retained. Internal defaults and route aliases remain
|
|
194
|
+
source-qualified, so adding another same-named source cannot move an existing
|
|
195
|
+
default. Existing qualified IDs continue to resolve to their original source. During the
|
|
196
|
+
one-time native ID migration, a complete cache containing exactly the recognized
|
|
197
|
+
old selected route IDs is moved to `models_cache.json.ccdx-qualified.bak` with
|
|
198
|
+
private permissions. The client then reads the current directory; unknown or
|
|
199
|
+
partial caches and native authentication/session data are preserved.
|
|
200
|
+
|
|
179
201
|
A deployment is identified by source plus actual model ID. Its stable public route
|
|
180
202
|
is independent of catalog order and key rotation; its private history/evidence
|
|
181
203
|
identity includes endpoint, authentication and credential generation. Same-named
|
|
@@ -1280,7 +1302,7 @@ Unknown support prevents an explicitly requested exception from starting.
|
|
|
1280
1302
|
For an older updater that still requires Git, install the Release tarball directly:
|
|
1281
1303
|
|
|
1282
1304
|
```sh
|
|
1283
|
-
npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.
|
|
1305
|
+
npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.21/codex-copilot-dx-1.2.21.tgz
|
|
1284
1306
|
# Windows PowerShell: use npm.cmd instead of npm.
|
|
1285
1307
|
```
|
|
1286
1308
|
|
|
@@ -1911,3 +1933,18 @@ saves report persistence separately from subsequent metadata refresh. Background
|
|
|
1911
1933
|
read failures retain existing messages; key read/save states use polite live
|
|
1912
1934
|
announcements. Account labels and values stay paired, and request summaries use
|
|
1913
1935
|
configured source names. Technical IDs remain available in request details.
|
|
1936
|
+
|
|
1937
|
+
### Codex App updates and model selection
|
|
1938
|
+
|
|
1939
|
+
After an App update, completely quit and reopen the App once if the model list is
|
|
1940
|
+
empty, then inspect `ccdx doctor`. On macOS, doctor reads bundled CLI package
|
|
1941
|
+
metadata and the optional model-cache version without executing a binary or
|
|
1942
|
+
altering the cache. A version mismatch is a diagnostic hint; it does not prove
|
|
1943
|
+
that the cache caused a failed catalog. HTTP catalog `models` and app-server RPC
|
|
1944
|
+
`model/list.data` are different layers, not evidence by themselves of a format
|
|
1945
|
+
regression between client versions.
|
|
1946
|
+
|
|
1947
|
+
The Responses WebSocket protocol is not implemented by CCDX. Upgrade requests
|
|
1948
|
+
are refused promptly so supported native clients can fall back to HTTP/SSE.
|
|
1949
|
+
This is tested separately from model-directory and provider-identity behavior;
|
|
1950
|
+
SSE events are not relabeled as a WebSocket protocol.
|
package/package.json
CHANGED
package/src/access-settings.mjs
CHANGED
|
@@ -12,6 +12,7 @@ export const CLIENT_IDS = Object.freeze(["codex", "claude_app", "claude_code"]);
|
|
|
12
12
|
export const CLIENT_NAMES = Object.freeze({ codex: "Codex App", claude_app: "Claude App", claude_code: "Claude Code" });
|
|
13
13
|
const APIS = ["messages", "responses", "chat"];
|
|
14
14
|
const messages = {
|
|
15
|
+
ccdx_codex_catalog_cache_unavailable: "Codex model cache could not be refreshed safely. Close Codex App and try again; existing files were kept.",
|
|
15
16
|
ccdx_client_source_disabled: "This client's CCDX access or selected source is disabled. Review Settings.",
|
|
16
17
|
ccdx_client_credential_required: "The client's local CCDX credential is missing or outdated. Reopen the client after setup.",
|
|
17
18
|
ccdx_conversation_source_changed: "This conversation was observed on another source or key. Start a new conversation.",
|
|
@@ -15,16 +15,23 @@ export function compileClientModels({ client, binding, source, enabled, names =
|
|
|
15
15
|
if (!binding.enabled) return { models: [], routes: new Map(), defaultModel: null, revision: "disabled" };
|
|
16
16
|
const explicit = Array.isArray(binding.deployments), selected = explicit ? binding.deployments : binding.source
|
|
17
17
|
? sourceModels(source(binding.source), client).map(model => ({ source: binding.source, model: model.id })) : [];
|
|
18
|
-
const models = [], routes = new Map(), raw = new Map(), catalogs = new Map();
|
|
18
|
+
const models = [], routes = new Map(), raw = new Map(), catalogs = new Map(), available = [], counts = new Map();
|
|
19
19
|
for (const item of selected) {
|
|
20
20
|
if (!binding.allowed.includes(item.source) || !enabled(item.source)) continue;
|
|
21
21
|
const provider = source(item.source);
|
|
22
22
|
if (!catalogs.has(provider)) catalogs.set(provider, new Map(sourceModels(provider, client).map(model => [model.id, model])));
|
|
23
23
|
const model = catalogs.get(provider).get(item.model);
|
|
24
24
|
if (!model || model.policy?.state && model.policy.state !== "enabled" || model.model_picker_enabled === false) continue;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
available.push({ item, provider, model, route: deploymentModelId(item.source, model.id) });counts.set(model.id, (counts.get(model.id) || 0) + 1);
|
|
26
|
+
}
|
|
27
|
+
const routeIds = new Set(available.map(entry => entry.route));
|
|
28
|
+
for (const { item, provider, model, route } of available) {
|
|
29
|
+
const capability = model.capability || resolveModelCapabilities(model, { builtin: true });
|
|
30
|
+
const sourceName = names[item.source] || provider.name || ({ github: "GitHub Copilot", m365: "Microsoft 365" })[item.source] || item.source;
|
|
31
|
+
const ambiguous = counts.get(model.id) > 1;
|
|
32
|
+
const entry = { ...model, capability, source_id: item.source, source_name: sourceName, route_id: route,
|
|
33
|
+
...(explicit ? { client_id: client === "codex" && !ambiguous && !routeIds.has(model.id) ? model.id : route,
|
|
34
|
+
...(ambiguous ? { display_name: `${model.display_name || model.name || model.id} · ${sourceName}` } : {}) } : {}) };
|
|
28
35
|
if (client === "claude_app" && explicit) entry.client_id = claudeDeploymentId(entry, route, { desktopEffortAliases });
|
|
29
36
|
const publicId = explicit ? entry.client_id : client === "codex" ? model.id : claudeModelEntries([entry], { desktopAliases: client === "claude_app" && provider.id.startsWith("api_") })[0].name;
|
|
30
37
|
entry.public_id = publicId;
|
|
@@ -5,14 +5,14 @@ export function codexModelEntry(model, { priority = 0, name = "", template = {}
|
|
|
5
5
|
base_instructions: "", support_verbosity: false, default_verbosity: null, apply_patch_tool_type: null,
|
|
6
6
|
supports_reasoning_summary_parameter: false, default_reasoning_summary: "none", truncation_policy: { mode: "bytes", limit: 10000 },
|
|
7
7
|
experimental_supported_tools: [], input_modalities: values.input_modalities || ["text"], ...template,
|
|
8
|
-
slug: model.public_id || model.id, display_name: model.display_name || model.id, description: name, visibility: "list", supported_in_api: true, priority,
|
|
8
|
+
slug: model.public_id || model.id, display_name: model.display_name || template.display_name || model.name || model.id, description: model.description || template.description || name, visibility: "list", supported_in_api: true, priority,
|
|
9
9
|
default_reasoning_level: efforts[0] || null, supported_reasoning_levels: efforts.map(effort => ({ effort, description: effort })),
|
|
10
10
|
context_window: values.context_window || template.context_window || null, max_context_window: values.context_window || template.max_context_window || null };
|
|
11
11
|
}
|
|
12
12
|
export function codexClientCatalog(plan) {
|
|
13
13
|
return Object.assign((value, nativeCatalog) => ({ ...value, models: plan.models.map((model, priority) => {
|
|
14
14
|
const template = model.source_id === "github" ? nativeCatalog?.models?.find(entry => entry.slug === model.id) : undefined;
|
|
15
|
-
return codexModelEntry(model, { priority, template, name: model.source_id });
|
|
15
|
+
return codexModelEntry(model, { priority, template, name: model.source_name || model.source_id });
|
|
16
16
|
}) }), { needsNativeCatalog: plan.models.some(model => model.source_id === "github") });
|
|
17
17
|
}
|
|
18
18
|
|
package/src/codex-api-config.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { codexTomlStatements, parseCodexToml, validateManagedConfigEdit } from "./config-toml.mjs";
|
|
4
4
|
import { codexPaths } from "./codex-paths.mjs";
|
|
5
5
|
import { accessSettingsPath, accessError } from "./access-settings.mjs";
|
|
6
6
|
import { readBoundedFileSync } from "./bounded-file.mjs";
|
|
@@ -19,49 +19,117 @@ function retainsCodexSignIn(config, directory, env) {
|
|
|
19
19
|
throw accessError("ccdx_codex_config_invalid", 409);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
function validateOwner(owner) {
|
|
23
|
+
if (owner && (![1, 2].includes(owner.version) || !Object.hasOwn(owner, "beforeProvider") || !Object.hasOwn(owner, "beforeSection")
|
|
24
|
+
|| owner.version === 1 && typeof owner.section !== "string"
|
|
25
|
+
|| owner.version === 2 && (!["openai", "gateway"].includes(owner.mode) || owner.mode === "gateway" && typeof owner.section !== "string"
|
|
26
|
+
|| owner.mode === "openai" && owner.section !== null && typeof owner.section !== "string"))) throw accessError("ccdx_codex_config_invalid", 409);
|
|
27
|
+
}
|
|
28
|
+
export function codexBaseUrlManaged(options = {}) {
|
|
29
|
+
if (options.filePath && path.resolve(options.filePath) !== codexPaths(options).config) return false;
|
|
30
|
+
const journal = path.join(path.dirname(accessSettingsPath(options)), "codex-gateway-owner.json");
|
|
31
|
+
try {
|
|
32
|
+
const owner = JSON.parse(readBoundedFileSync(journal, { encoding: "utf8", maxBytes: 16384 }));validateOwner(owner);
|
|
33
|
+
return owner?.version === 2 && Object.hasOwn(owner, "base");
|
|
34
|
+
} catch (error) { if (error.code === "ENOENT") return false;throw accessError("ccdx_codex_config_invalid", 409); }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Retain exact declarations for restoration; the scanner handles quoted keys,
|
|
38
|
+
// comments and multiline values without serializing unrelated TOML.
|
|
39
|
+
function rootDeclaration(content, key) {
|
|
40
|
+
const item = codexTomlStatements(content).find(item => item.kind === "value" && !item.section.length && item.keys.length === 1 && item.keys[0] === key);
|
|
41
|
+
if (!item) return null;
|
|
42
|
+
const start = content.lastIndexOf("\n", item.start - 1) + 1, newline = content.indexOf("\n", item.valueEnd), end = newline < 0 ? content.length : newline + 1;
|
|
43
|
+
return { start, end, text: content.slice(start, end) };
|
|
44
|
+
}
|
|
45
|
+
function replaceRoot(content, key, text) {
|
|
46
|
+
const item = rootDeclaration(content, key);
|
|
47
|
+
return item ? content.slice(0, item.start) + (text || "") + (text && !text.endsWith("\n") && item.end < content.length ? "\n" : "") + content.slice(item.end) : (text || "") + content;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Retire only the complete, recognized qualified-ID cache from the old native
|
|
51
|
+
// route. Its bytes remain available for rollback; unknown caches are untouched.
|
|
52
|
+
function retireQualifiedCache(models, options) {
|
|
53
|
+
if (!Array.isArray(models) || !models.length) return () => {};
|
|
54
|
+
const aliases = new Set(models.filter(model => model.public_id !== model.route_id && /^ccdx\/model-\d+$/.test(model.route_id)).map(model => model.route_id));
|
|
55
|
+
if (aliases.size !== models.length) return () => {};
|
|
56
|
+
const file = path.join(codexPaths(options).directory, "models_cache.json"), backup = file + ".ccdx-qualified.bak";
|
|
57
|
+
let bytes, cache;
|
|
58
|
+
try { bytes = readBoundedFileSync(file, { maxBytes: 8 * 1024 * 1024 });cache = JSON.parse(bytes.toString("utf8")); }
|
|
59
|
+
catch (error) { if (error.code === "ENOENT" || error instanceof SyntaxError) return () => {};throw accessError("ccdx_codex_catalog_cache_unavailable", 409); }
|
|
60
|
+
if (!Array.isArray(cache.models) || cache.models.length !== aliases.size || !cache.models.every(model => typeof model?.slug === "string" && aliases.has(model.slug))
|
|
61
|
+
|| new Set(cache.models.map(model => model.slug)).size !== aliases.size) return () => {};
|
|
62
|
+
try {
|
|
63
|
+
if (fs.existsSync(backup) && !readBoundedFileSync(backup, { maxBytes: 8 * 1024 * 1024 }).equals(bytes)) throw Error("cache_backup_conflict");
|
|
64
|
+
if (!readBoundedFileSync(file, { maxBytes: 8 * 1024 * 1024 }).equals(bytes)) throw Error("cache_changed");
|
|
65
|
+
fs.renameSync(file, backup);fs.chmodSync(backup, 0o600);
|
|
66
|
+
} catch { throw accessError("ccdx_codex_catalog_cache_unavailable", 409); }
|
|
67
|
+
return () => { if (!fs.existsSync(file)) fs.renameSync(backup, file); };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// GitHub-only traffic retains the built-in OpenAI provider. Private API traffic
|
|
71
|
+
// keeps its own provider and local key. Both routes share one ownership journal.
|
|
72
|
+
export function configureCodexApi({ baseUrl, apiKey, model, native = false, nativeModels, restore = false, ...options } = {}) {
|
|
24
73
|
if (!restore) {
|
|
25
74
|
let url;try { url = new URL(baseUrl); } catch { throw accessError("ccdx_codex_config_invalid"); }
|
|
26
75
|
if (url.protocol !== "http:" || url.hostname !== "127.0.0.1" || url.pathname !== "/v1" || url.username || url.password || url.search || url.hash
|
|
27
|
-
|| !/^[a-f0-9]{64}$/.test(apiKey)) throw accessError("ccdx_codex_config_invalid");
|
|
76
|
+
|| !native && !/^[a-f0-9]{64}$/.test(apiKey)) throw accessError("ccdx_codex_config_invalid");
|
|
28
77
|
}
|
|
29
78
|
const file = codexPaths(options).config, journal = path.join(path.dirname(accessSettingsPath(options)), "codex-gateway-owner.json");
|
|
30
79
|
if (restore && !fs.existsSync(journal)) return { state: "unchanged" };
|
|
31
80
|
fs.mkdirSync(path.dirname(journal), { recursive: true, mode: 0o700 });fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
32
|
-
return withFileLockSync(`${journal}.lock`, () => {
|
|
81
|
+
return withFileLockSync(`${file}.ccdx.lock`, () => withFileLockSync(`${journal}.lock`, () => {
|
|
33
82
|
let content = "", owner = null;
|
|
34
83
|
try { content = readBoundedFileSync(file, { encoding: "utf8", maxBytes: 1024 * 1024 }); } catch (error) { if (error.code !== "ENOENT") throw accessError("ccdx_codex_config_invalid", 409); }
|
|
35
84
|
try { owner = JSON.parse(readBoundedFileSync(journal, { encoding: "utf8", maxBytes: 16384 })); } catch (error) { if (error.code !== "ENOENT") throw accessError("ccdx_codex_config_invalid", 409); }
|
|
36
|
-
let config;try { config =
|
|
37
|
-
|
|
38
|
-
const
|
|
85
|
+
let config;try { config = parseCodexToml(content); } catch { throw accessError("ccdx_codex_config_invalid", 409); }
|
|
86
|
+
validateOwner(owner);
|
|
87
|
+
const table = codexTomlStatements(content).find(item => item.kind === "table"), firstTable = table ? content.lastIndexOf("\n", table.start - 1) + 1 : -1;
|
|
88
|
+
const head = firstTable < 0 ? content : content.slice(0, firstTable), tail = firstTable < 0 ? "" : content.slice(firstTable);
|
|
39
89
|
const sectionPattern = /^\[model_providers\.ccdx_gateway\]\r?\n[^]*?(?=^\[|$(?![^]))/m;
|
|
40
90
|
const currentSection = tail.match(sectionPattern)?.[0] || null;
|
|
41
|
-
|
|
91
|
+
const nativeOwner = owner?.mode === "openai", openaiProvider = !config.model_provider || config.model_provider === "openai";
|
|
92
|
+
if (owner && (currentSection !== owner.section || (nativeOwner ? !openaiProvider : config.model_provider !== ID && !(native && openaiProvider)))) return { state: "preserved" };
|
|
93
|
+
if (owner && Object.hasOwn(owner, "base") && rootDeclaration(head, "openai_base_url")?.text !== owner.base) return { state: "preserved" };
|
|
42
94
|
const modelEdited = owner?.model !== undefined && config.model !== owner.model;
|
|
43
95
|
if (restore && modelEdited) return { state: "preserved" };
|
|
44
|
-
if (!owner && (
|
|
96
|
+
if (!owner && (!openaiProvider || config.model_providers?.[ID])) return { state: "preserved" };
|
|
97
|
+
const beforeProvider = owner ? owner.beforeProvider : rootDeclaration(head, "model_provider")?.text || null;
|
|
98
|
+
const beforeSection = owner ? owner.beforeSection : currentSection;
|
|
45
99
|
let next, nextOwner = null;
|
|
46
100
|
if (restore) {
|
|
47
101
|
if (!owner) return { state: "unchanged" };
|
|
48
|
-
let root = head
|
|
49
|
-
if (owner.model !== undefined) root = root
|
|
50
|
-
|
|
102
|
+
let root = replaceRoot(head, "model_provider", beforeProvider);
|
|
103
|
+
if (owner.model !== undefined) root = replaceRoot(root, "model", owner.beforeModel);
|
|
104
|
+
if (Object.hasOwn(owner, "base")) root = replaceRoot(root, "openai_base_url", owner.beforeBase);
|
|
105
|
+
next = root + (currentSection ? tail.replace(sectionPattern, beforeSection || "") : tail);
|
|
51
106
|
} else {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
107
|
+
let root = head, section;
|
|
108
|
+
if (model && !modelEdited) root = replaceRoot(root, "model", `model = ${JSON.stringify(model)}\n`);
|
|
109
|
+
if (native) {
|
|
110
|
+
root = replaceRoot(root, "model_provider", beforeProvider);
|
|
111
|
+
root = replaceRoot(root, "openai_base_url", `openai_base_url = ${JSON.stringify(baseUrl)}\n`);
|
|
112
|
+
// Existing sessions retain their provider ID. Keep its unchanged table
|
|
113
|
+
// inactive so they can resume; fresh native installs create no table.
|
|
114
|
+
section = currentSection;
|
|
115
|
+
next = root + tail;
|
|
116
|
+
} else {
|
|
117
|
+
const requiresAuth = retainsCodexSignIn(config, path.dirname(file), options.env || process.env);
|
|
118
|
+
section = `[model_providers.${ID}]\nname = "CCDX"\nbase_url = ${JSON.stringify(baseUrl)}\nmodel_catalog_url = ${JSON.stringify(baseUrl + "/models")}\nwire_api = "responses"\nrequires_openai_auth = ${requiresAuth}\nexperimental_bearer_token = ${JSON.stringify(apiKey)}\n\n`;
|
|
119
|
+
root = replaceRoot(root, "model_provider", `model_provider = "${ID}"\n`);
|
|
120
|
+
next = root + (currentSection ? tail.replace(sectionPattern, section) : tail + (tail && !tail.endsWith("\n") ? "\n" : "") + "\n" + section);
|
|
121
|
+
}
|
|
122
|
+
nextOwner = { version: 2, mode: native ? "openai" : "gateway", beforeProvider, beforeSection, section,
|
|
123
|
+
...(native || owner && Object.hasOwn(owner, "base") ? { beforeBase: owner && Object.hasOwn(owner, "beforeBase") ? owner.beforeBase : rootDeclaration(head, "openai_base_url")?.text || null,
|
|
124
|
+
base: native ? `openai_base_url = ${JSON.stringify(baseUrl)}\n` : owner.base } : {}),
|
|
125
|
+
...(modelEdited || !model && owner?.model !== undefined ? { model: owner.model, beforeModel: owner.beforeModel }
|
|
126
|
+
: model ? { model, beforeModel: owner && Object.hasOwn(owner, "beforeModel") ? owner.beforeModel : rootDeclaration(head, "model")?.text || null } : {}) };
|
|
63
127
|
}
|
|
64
|
-
|
|
128
|
+
try { validateManagedConfigEdit(config, next, [["model"], ["model_provider"], ["model_providers", ID], ["openai_base_url"]]); }
|
|
129
|
+
catch { throw accessError("ccdx_codex_config_invalid", 409); }
|
|
130
|
+
const undoCache = native && !restore ? retireQualifiedCache(nativeModels, options) : () => {};
|
|
131
|
+
try { if (next !== content || JSON.stringify(nextOwner) !== JSON.stringify(owner)) atomicWriteFilePairSync(file, next, journal, nextOwner ? JSON.stringify(nextOwner) + "\n" : null, { mode: 0o600 }); }
|
|
132
|
+
catch (error) { undoCache();throw error; }
|
|
65
133
|
return { state: modelEdited ? "preserved" : "configured", changed: next !== content };
|
|
66
|
-
});
|
|
134
|
+
}));
|
|
67
135
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
1
|
import os from "node:os";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { execFile } from "node:child_process";
|
|
5
4
|
import { promisify } from "node:util";
|
|
6
5
|
import { readAdapterStatus } from "./cli-status.mjs";
|
|
6
|
+
import { codexPaths } from "./codex-paths.mjs";
|
|
7
|
+
import { readBoundedFileSync } from "./bounded-file.mjs";
|
|
7
8
|
import { formatPredictionEnvironment } from "./native-prediction-state.mjs";
|
|
8
9
|
|
|
9
10
|
export function parseRunningCodexApps(stdout) {
|
|
@@ -20,13 +21,13 @@ export function parseRunningCodexApps(stdout) {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export async function inspectCodexClient({
|
|
23
|
-
home = os.homedir(), platform = process.platform, running,
|
|
24
|
-
host, port, fetchImpl = fetch, readFileFn =
|
|
24
|
+
home = os.homedir(), env = process.env, platform = process.platform, running,
|
|
25
|
+
host, port, fetchImpl = fetch, readFileFn = (file, encoding) => readBoundedFileSync(file, { encoding, maxBytes: 8 * 1024 * 1024 }),
|
|
25
26
|
execFileFn = promisify(execFile), readStatus = readAdapterStatus,
|
|
26
27
|
} = {}) {
|
|
27
28
|
const checks = [];
|
|
28
29
|
if (platform === "darwin") {
|
|
29
|
-
const seen = new Set();
|
|
30
|
+
const seen = new Set(), versions = new Set();
|
|
30
31
|
for (const root of ["/Applications", path.join(home, "Applications")]) {
|
|
31
32
|
for (const name of ["ChatGPT.app", "Codex.app"]) {
|
|
32
33
|
try {
|
|
@@ -37,8 +38,21 @@ export async function inspectCodexClient({
|
|
|
37
38
|
seen.add(`${name}/${version}`);
|
|
38
39
|
}
|
|
39
40
|
} catch {}
|
|
41
|
+
try {
|
|
42
|
+
const metadata = JSON.parse(readFileFn(path.join(root, name, "Contents", "Resources", "codex-cli", "codex-package.json"), "utf8"));
|
|
43
|
+
if (/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+_-]+)?$/.test(metadata.version || "")) versions.add(metadata.version);
|
|
44
|
+
} catch { /* Older app bundles may not publish CLI package metadata. */ }
|
|
40
45
|
}
|
|
41
46
|
}
|
|
47
|
+
for (const version of versions) checks.push({ kind: "info", message: `Bundled Codex CLI: ${version}` });
|
|
48
|
+
try {
|
|
49
|
+
const cache = JSON.parse(readFileFn(path.join(codexPaths({ home, env }).directory, "models_cache.json"), "utf8"));
|
|
50
|
+
const core = value => /^(\d+\.\d+\.\d+)/.exec(String(value || ""))?.[1];
|
|
51
|
+
const current = new Set([...versions].map(core));
|
|
52
|
+
if (current.size === 1 && core(cache.client_version) && !current.has(core(cache.client_version))) {
|
|
53
|
+
checks.push({ kind: "warn", message: `Model cache client ${core(cache.client_version)} differs from bundled CLI ${[...current][0]}; fully quit and reopen the App once after updating. This does not prove a failed catalog.` });
|
|
54
|
+
}
|
|
55
|
+
} catch { /* Cache contents are optional and never repaired by this read-only check. */ }
|
|
42
56
|
try {
|
|
43
57
|
// comm contains executable names, never command-line arguments or environments.
|
|
44
58
|
const { stdout } = await execFileFn("ps", ["-axo", "pid=,comm="], { timeout: 1500, maxBuffer: 256 * 1024, encoding: "utf8" });
|
|
@@ -65,6 +79,6 @@ export async function inspectCodexClient({
|
|
|
65
79
|
} else checks.push({ kind: "info", message: "No client model-catalog request observed by this adapter" });
|
|
66
80
|
} catch { checks.push({ kind: "info", message: "Client model-catalog diagnostics unavailable from the running adapter" }); }
|
|
67
81
|
}
|
|
68
|
-
checks.push({ kind: "info", message: "App
|
|
82
|
+
checks.push({ kind: "info", message: "App adoption of the model cache is not externally verified; process age alone does not prove a stale catalog" });
|
|
69
83
|
return checks;
|
|
70
84
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import { codexPaths } from "./codex-paths.mjs";
|
|
4
|
+
import { codexBaseUrlManaged } from "./codex-api-config.mjs";
|
|
4
5
|
import { isDeepStrictEqual } from "node:util";
|
|
5
6
|
import { createHash } from "node:crypto";
|
|
6
7
|
import { parse } from "smol-toml";
|
|
@@ -53,12 +54,12 @@ function unmanagedSettings(config) {
|
|
|
53
54
|
return remaining;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
function startupPreview(content, config, host, port) {
|
|
57
|
+
function startupPreview(content, config, host, port, preserveBaseUrl = false) {
|
|
57
58
|
let updated;
|
|
58
59
|
try {
|
|
59
60
|
updated = content === null
|
|
60
61
|
? { content: initialCodexConfig(port, host), changed: true }
|
|
61
|
-
: computeUpdatedCodexConfig(content, port, host);
|
|
62
|
+
: computeUpdatedCodexConfig(content, port, host, { preserveBaseUrl });
|
|
62
63
|
} catch {
|
|
63
64
|
return { kind: "err", message: "Startup configuration cannot be edited safely; review the file before starting ccdx" };
|
|
64
65
|
}
|
|
@@ -165,7 +166,8 @@ export function inspectCodexConfig({ home = os.homedir(), env: processEnv = proc
|
|
|
165
166
|
} else {
|
|
166
167
|
checks.push({ kind: "err", message: "features.context_management must be a boolean for the basic feature flag" });
|
|
167
168
|
}
|
|
168
|
-
checks.push(startupPreview(content, config, host, port));
|
|
169
|
+
try { checks.push(startupPreview(content, config, host, port, codexBaseUrlManaged({ home, env: processEnv }))); }
|
|
170
|
+
catch { checks.push({ kind: "err", message: "Codex gateway ownership cannot be read; startup base URL changes are blocked" }); }
|
|
169
171
|
return checks;
|
|
170
172
|
}
|
|
171
173
|
|
|
@@ -182,7 +184,7 @@ export function repairCodexConfig(options = {}) {
|
|
|
182
184
|
throw Object.assign(new Error("config_preview_changed"), { code: "config_preview_changed", statusCode: 409 });
|
|
183
185
|
}
|
|
184
186
|
const next = content === null ? { content: initialCodexConfig(port, host), changed: true }
|
|
185
|
-
: computeUpdatedCodexConfig(content, port, host);
|
|
187
|
+
: computeUpdatedCodexConfig(content, port, host, { preserveBaseUrl: codexBaseUrlManaged(options) });
|
|
186
188
|
if (!next.changed) return { status: "unchanged", changed: false };
|
|
187
189
|
const before = content === null ? {} : parseConfig(content);
|
|
188
190
|
if (!isDeepStrictEqual(unmanagedSettings(before), unmanagedSettings(parseConfig(next.content)))) {
|
package/src/config.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { adapterBaseUrl } from "./running-adapter.mjs";
|
|
|
5
5
|
import { isLoopbackHost } from "./security.mjs";
|
|
6
6
|
import { codexTomlStatements, configValue, parseCodexToml, validateManagedConfigEdit } from "./config-toml.mjs";
|
|
7
7
|
import { codexPaths } from "./codex-paths.mjs";
|
|
8
|
+
import { codexBaseUrlManaged } from "./codex-api-config.mjs";
|
|
8
9
|
import { withFileLockSync } from "./lock.mjs";
|
|
9
10
|
|
|
10
11
|
const MODEL_CONTEXT_WINDOW = 1_000_000;
|
|
@@ -204,7 +205,7 @@ export function computeUpdatedCodexConfig(
|
|
|
204
205
|
content,
|
|
205
206
|
adapterPort = 2026,
|
|
206
207
|
adapterHost = "127.0.0.1",
|
|
207
|
-
{ imageProviderEnabled } = {},
|
|
208
|
+
{ imageProviderEnabled, preserveBaseUrl = false } = {},
|
|
208
209
|
) {
|
|
209
210
|
const config = parseCodexToml(content);
|
|
210
211
|
const baseUrl = `${adapterBaseUrl(adapterHost, adapterPort)}/v1`;
|
|
@@ -213,7 +214,8 @@ export function computeUpdatedCodexConfig(
|
|
|
213
214
|
|
|
214
215
|
let changed = false;
|
|
215
216
|
const openaiLine = `openai_base_url = "${baseUrl}"`;
|
|
216
|
-
if (
|
|
217
|
+
if (preserveBaseUrl) { /* The gateway journal owns this field, including preserved user edits. */ }
|
|
218
|
+
else if (!Object.hasOwn(config, "openai_base_url")) {
|
|
217
219
|
lines.unshift(openaiLine);
|
|
218
220
|
changed = true;
|
|
219
221
|
} else {
|
|
@@ -287,6 +289,7 @@ function ensureCodexConfigUnlocked(adapterPort = 2026, {
|
|
|
287
289
|
host = "127.0.0.1",
|
|
288
290
|
imageProviderEnabled = false,
|
|
289
291
|
log = console.log,
|
|
292
|
+
...options
|
|
290
293
|
} = {}) {
|
|
291
294
|
const baseUrl = `${adapterBaseUrl(host, adapterPort)}/v1`;
|
|
292
295
|
|
|
@@ -303,12 +306,12 @@ function ensureCodexConfigUnlocked(adapterPort = 2026, {
|
|
|
303
306
|
// failures must not roll it back or close an otherwise usable GPT adapter.
|
|
304
307
|
const core = content === undefined
|
|
305
308
|
? { content: initialCodexConfig(adapterPort, host), changed: true }
|
|
306
|
-
: computeUpdatedCodexConfig(content, adapterPort, host);
|
|
309
|
+
: computeUpdatedCodexConfig(content, adapterPort, host, { preserveBaseUrl: codexBaseUrlManaged({ ...options, filePath }) });
|
|
307
310
|
if (!core.changed) {
|
|
308
|
-
log(status("ok", `Codex already points to ${baseUrl}`));
|
|
311
|
+
log(status("ok", parseCodexToml(core.content).openai_base_url === baseUrl ? `Codex already points to ${baseUrl}` : "Codex configuration unchanged; existing base URL preserved"));
|
|
309
312
|
} else {
|
|
310
313
|
atomicWriteFileIfChangedSync(filePath, core.content);
|
|
311
|
-
log(status("ok", content === undefined ? `Created Codex configuration: ${filePath}` : `Configured Codex base URL: ${baseUrl}`));
|
|
314
|
+
log(status("ok", content === undefined ? `Created Codex configuration: ${filePath}` : parseCodexToml(core.content).openai_base_url === baseUrl ? `Configured Codex base URL: ${baseUrl}` : "Codex startup settings updated; existing base URL preserved"));
|
|
312
315
|
}
|
|
313
316
|
// Disabled means no image maintenance, including no implicit removal of old
|
|
314
317
|
// or user-owned entries. Explicit disable-image owns the cleanup operation.
|
|
@@ -131,12 +131,18 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
131
131
|
}
|
|
132
132
|
async function performClientSync(targets) {
|
|
133
133
|
if (!managed || closed) return;
|
|
134
|
-
const codex = binding("codex");
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
const codex = binding("codex"), compiledCodex = plan("codex");
|
|
135
|
+
const explicit = Array.isArray(codex.deployments), native = explicit ? codex.deployments.length > 0 && codex.deployments.every(item => item.source === "github") : codex.source === "github";
|
|
136
|
+
if (targets.has("codex")) try {
|
|
137
|
+
if (codex.enabled && codex.auto_sync === false) setup.codex = "manual_sync";
|
|
138
|
+
else if (codex.enabled && compiledCodex.defaultUnavailable && !native) setup.codex = "default_unavailable";
|
|
139
|
+
else {
|
|
140
|
+
setup.codex = configureCodex({ ...options, ...(codex.enabled && (native || explicit && codex.deployments.length || codex.source?.startsWith("api_"))
|
|
141
|
+
? { baseUrl: `http://127.0.0.1:${corePort}/v1`, native, ...(native ? { nativeModels: compiledCodex.models } : {}), ...(!native ? { apiKey: identities().codex } : {}),
|
|
142
|
+
...(explicit || !native ? { model: compiledCodex.defaultModel || (!compiledCodex.defaultUnavailable ? codex.model : undefined) } : {}) } : { restore: true }) }).state;
|
|
143
|
+
if (codex.enabled && compiledCodex.defaultUnavailable && setup.codex === "configured") setup.codex = "default_unavailable";
|
|
144
|
+
}
|
|
145
|
+
} catch { setup.codex = "configuration_unavailable"; }
|
|
140
146
|
if (!settings.claude_private_keys || !["claude_app", "claude_code"].some(id => targets.has(id))) return;
|
|
141
147
|
let desktopManaged;
|
|
142
148
|
for (const id of ["claude_app", "claude_code"]) {
|