@bitkyc08/opencodex 2.55.0 → 2.57.0
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/bin/ocx.mjs +10 -0
- package/gui/dist/assets/{index-BBOZWGB6.css → index-C5-RdDmD.css} +1 -1
- package/gui/dist/assets/{index-VuoiWj9J.js → index-Cz7CLdif.js} +21 -21
- package/gui/dist/index.html +2 -2
- package/package.json +4 -3
- package/src/adapters/base.ts +21 -0
- package/src/adapters/codebuddy/adapter.ts +2 -1
- package/src/adapters/codebuddy/scaffold-guard.ts +248 -0
- package/src/adapters/command-code.ts +1 -1
- package/src/adapters/cursor/envelope-echo.ts +8 -2
- package/src/adapters/cursor/transport-retry.ts +46 -1
- package/src/adapters/cursor.ts +4 -0
- package/src/adapters/google.ts +7 -7
- package/src/adapters/kiro/adapter.ts +42 -1
- package/src/adapters/kiro/payload.ts +17 -3
- package/src/adapters/kiro/reasoning.ts +70 -7
- package/src/adapters/kiro/stream.ts +8 -2
- package/src/adapters/kiro/wire.ts +2 -1
- package/src/adapters/kiro-events.ts +21 -13
- package/src/adapters/kiro-retry.ts +23 -4
- package/src/adapters/openai-chat/errors.ts +116 -0
- package/src/adapters/openai-chat/messages.ts +346 -0
- package/src/adapters/openai-chat/passthrough.ts +146 -0
- package/src/adapters/openai-chat/response-events.ts +117 -0
- package/src/adapters/openai-chat/tool-call-validation.ts +200 -0
- package/src/adapters/openai-chat/tool-name-registry.ts +166 -0
- package/src/adapters/openai-chat/tool-schema.ts +495 -0
- package/src/adapters/openai-chat/wire.ts +50 -0
- package/src/adapters/openai-chat.ts +40 -1452
- package/src/adapters/openai-responses/canonical-forward.ts +202 -0
- package/src/adapters/openai-responses/image-gen.ts +406 -0
- package/src/adapters/openai-responses/internal.ts +3 -0
- package/src/adapters/openai-responses/passthrough.ts +642 -0
- package/src/adapters/openai-responses/prompt-cache.ts +83 -0
- package/src/adapters/openai-responses/reasoning.ts +220 -0
- package/src/adapters/openai-responses/request-strips.ts +185 -0
- package/src/adapters/openai-responses/tool-output-recovery.ts +509 -0
- package/src/adapters/openai-responses/tool-schema.ts +293 -0
- package/src/adapters/openai-responses/web-search.ts +156 -0
- package/src/adapters/openai-responses.ts +4 -2625
- package/src/bridge/errors.ts +58 -0
- package/src/bridge/internal.ts +174 -0
- package/src/bridge/response-json.ts +630 -0
- package/src/bridge/sse.ts +1462 -0
- package/src/bridge.ts +5 -2204
- package/src/chat/inbound.ts +12 -1
- package/src/claude/desktop-profile.ts +66 -9
- package/src/claude/outbound.ts +18 -0
- package/src/cli/account-main.ts +1 -1
- package/src/cli/capabilities.ts +2 -2
- package/src/cli/combo.ts +10 -1
- package/src/cli/index.ts +48 -5
- package/src/cli/registry.ts +2 -1
- package/src/cli/system-command.ts +4 -4
- package/src/clients/config-export.ts +7 -3
- package/src/codex/account-label.ts +14 -3
- package/src/codex/account-lifecycle.ts +3 -0
- package/src/codex/account-store.ts +184 -35
- package/src/codex/account-usability.ts +21 -0
- package/src/codex/auth-api/account-list.ts +507 -0
- package/src/codex/auth-api/http.ts +32 -0
- package/src/codex/auth-api/login-flow.ts +566 -0
- package/src/codex/auth-api/login-state.ts +64 -0
- package/src/codex/auth-api/main-account-probe.ts +331 -0
- package/src/codex/auth-api/pool-mode-gate.ts +274 -0
- package/src/codex/auth-api/pool-quota-probe.ts +512 -0
- package/src/codex/auth-api/reset-credit-service.ts +431 -0
- package/src/codex/auth-api/routes.ts +425 -0
- package/src/codex/auth-api/runtime-config.ts +48 -0
- package/src/codex/auth-api.ts +27 -3118
- package/src/codex/auth-context.ts +252 -35
- package/src/codex/catalog/aggregation.ts +80 -1
- package/src/codex/catalog/auto-review.ts +507 -0
- package/src/codex/catalog/build-entries.ts +981 -0
- package/src/codex/catalog/combo-member.ts +375 -0
- package/src/codex/catalog/derive-entry.ts +229 -0
- package/src/codex/catalog/effort.ts +0 -1
- package/src/codex/catalog/gated-native-warn.ts +63 -0
- package/src/codex/catalog/gather-capture.ts +533 -0
- package/src/codex/catalog/model-hints.ts +691 -0
- package/src/codex/catalog/model-visibility.ts +305 -0
- package/src/codex/catalog/provider-fetch.ts +52 -2942
- package/src/codex/catalog/provider-models.ts +685 -0
- package/src/codex/catalog/remote.ts +30 -0
- package/src/codex/catalog/restore.ts +132 -0
- package/src/codex/catalog/retained-sync.ts +714 -0
- package/src/codex/catalog/routed-gather.ts +895 -0
- package/src/codex/catalog/subagent-roster.ts +176 -0
- package/src/codex/catalog/sync.ts +52 -2698
- package/src/codex/cli-install-provenance.ts +7 -1
- package/src/codex/convergence.ts +7 -2
- package/src/codex/desktop-app/types.ts +11 -2
- package/src/codex/desktop-app/windows.ts +5 -5
- package/src/codex/inject/config-toml.ts +563 -0
- package/src/codex/inject/remove.ts +192 -0
- package/src/codex/inject/restore.ts +567 -0
- package/src/codex/inject/routing-classify.ts +109 -0
- package/src/codex/inject/routing-target.ts +125 -0
- package/src/codex/inject.ts +89 -1444
- package/src/codex/lineage.ts +458 -0
- package/src/codex/model-entitlements.ts +152 -15
- package/src/codex/pool-refresh-backoff.ts +161 -0
- package/src/codex/quota-rejection.ts +104 -15
- package/src/codex/routing/active-account.ts +194 -0
- package/src/codex/routing/cache-affinity.ts +70 -0
- package/src/codex/routing/cooldown-math.ts +285 -0
- package/src/codex/routing/health-store.ts +402 -0
- package/src/codex/routing/probe-lease.ts +358 -0
- package/src/codex/routing/selection.ts +780 -0
- package/src/codex/routing/thread-affinity.ts +586 -0
- package/src/codex/routing/transient-hold-dispatch.ts +141 -0
- package/src/codex/routing.ts +370 -2271
- package/src/codex/shim-fingerprint.ts +223 -0
- package/src/codex/shim-inspect.ts +175 -0
- package/src/codex/shim-probe.ts +367 -0
- package/src/codex/shim-restore-lock.ts +169 -0
- package/src/codex/shim-state-file.ts +151 -0
- package/src/codex/shim-templates.ts +265 -0
- package/src/codex/shim.ts +48 -1268
- package/src/codex/warmup.ts +1 -1
- package/src/combos/failover.ts +85 -0
- package/src/combos/request.ts +17 -10
- package/src/combos/types.ts +23 -2
- package/src/config/diagnostics.ts +705 -0
- package/src/config/feature-flags.ts +55 -0
- package/src/config/live-reconcile.ts +403 -0
- package/src/config/load-degrade.ts +880 -0
- package/src/config/mutation-lock.ts +244 -0
- package/src/config/openai-tier-backup.ts +268 -0
- package/src/config/pending-teardown.ts +31 -0
- package/src/config/persist-unlocked.ts +92 -0
- package/src/config/proxy-env.ts +188 -0
- package/src/config/salvage.ts +244 -0
- package/src/config/schema/config-schema.ts +640 -0
- package/src/config/schema/leaf-validators.ts +855 -0
- package/src/config/warn-memo.ts +28 -0
- package/src/config.ts +234 -4481
- package/src/generated/compatibility-version.json +649 -121
- package/src/images/loop.ts +1 -1
- package/src/lib/errors.ts +17 -0
- package/src/lib/request-execution-budget.ts +198 -23
- package/src/lib/spend-reservation-ledger.ts +958 -0
- package/src/lib/state-store-registrations.ts +6 -2
- package/src/lib/test-home-guard.ts +85 -1
- package/src/lib/upstream-retry.ts +132 -21
- package/src/lib/windows-elevation.ts +76 -14
- package/src/lib/workflow-budget.ts +553 -30
- package/src/oauth/index.ts +2 -2
- package/src/oauth/key-providers.ts +2 -2
- package/src/providers/kiro-models.ts +4 -3
- package/src/providers/label.ts +19 -1
- package/src/providers/model-discovery.ts +16 -0
- package/src/providers/quota/account-cache.ts +441 -0
- package/src/providers/quota/antigravity.ts +295 -0
- package/src/providers/quota/report-cache.ts +320 -0
- package/src/providers/quota/vendor-probes-key.ts +1243 -0
- package/src/providers/quota/vendor-probes-oauth.ts +590 -0
- package/src/providers/quota.ts +324 -3079
- package/src/providers/registry/entries-core.ts +1228 -0
- package/src/providers/registry/entries-extended.ts +1213 -0
- package/src/providers/registry/model-seeds.ts +912 -0
- package/src/providers/registry/types.ts +352 -0
- package/src/providers/registry.ts +24 -3536
- package/src/responses/continuation-ownership.ts +29 -0
- package/src/responses/reasoning-envelope.ts +6 -3
- package/src/responses/state/replay-fingerprint.ts +80 -0
- package/src/responses/state/snapshot-codec.ts +104 -0
- package/src/responses/state/spill-failure.ts +118 -0
- package/src/responses/state/spill-queue.ts +665 -0
- package/src/responses/state/temp-recovery.ts +257 -0
- package/src/responses/state.ts +82 -1143
- package/src/routing/identity-domains.ts +456 -0
- package/src/routing/probe-lease.ts +613 -0
- package/src/server/chat-completions.ts +3 -1
- package/src/server/chat-native.ts +37 -9
- package/src/server/index/bounded-request.ts +88 -0
- package/src/server/index/live-sideband.ts +601 -0
- package/src/server/index/serve-options.ts +1766 -0
- package/src/server/index/startup-warnings.ts +213 -0
- package/src/server/index/websocket-handler.ts +339 -0
- package/src/server/index.ts +45 -2552
- package/src/server/inspection-tee.ts +107 -0
- package/src/server/live.ts +46 -1
- package/src/server/management/combo-routes.ts +10 -1
- package/src/server/management/route-registry.ts +26 -23
- package/src/server/management/shared.ts +8 -5
- package/src/server/management/workflow-budget-routes.ts +133 -0
- package/src/server/management-api.ts +12 -0
- package/src/server/relay-eager.ts +2 -0
- package/src/server/relay.ts +14 -19
- package/src/server/request-log-conversation.ts +9 -7
- package/src/server/request-log.ts +372 -4
- package/src/server/response-log-body.ts +153 -0
- package/src/server/responses/account-change-state.ts +307 -0
- package/src/server/responses/adapter-continuation.ts +540 -0
- package/src/server/responses/adapter-delivery.ts +208 -0
- package/src/server/responses/adapter-dispatch.ts +1042 -0
- package/src/server/responses/codex-ws-wire.ts +5 -0
- package/src/server/responses/collaboration.ts +74 -4
- package/src/server/responses/combo-session-recall.ts +68 -8
- package/src/server/responses/compact.ts +113 -17
- package/src/server/responses/completion-policy.ts +33 -0
- package/src/server/responses/core-auth.ts +529 -0
- package/src/server/responses/core-codex-account.ts +907 -0
- package/src/server/responses/core-combo-failure.ts +210 -0
- package/src/server/responses/core-combo.ts +787 -0
- package/src/server/responses/core-errors.ts +170 -0
- package/src/server/responses/core-lifetime.ts +95 -0
- package/src/server/responses/core-normalize.ts +350 -0
- package/src/server/responses/core-opaque-recovery.ts +380 -0
- package/src/server/responses/core-options.ts +159 -0
- package/src/server/responses/core-replay.ts +298 -0
- package/src/server/responses/core.ts +192 -8893
- package/src/server/responses/encrypted-payload.ts +0 -1
- package/src/server/responses/input-admission.ts +126 -6
- package/src/server/responses/passthrough-delivery.ts +869 -0
- package/src/server/responses/passthrough-dispatch.ts +1494 -0
- package/src/server/responses/passthrough-error.ts +38 -2
- package/src/server/responses/passthrough-execution.ts +54 -0
- package/src/server/responses/request-prepare.ts +1080 -0
- package/src/server/responses/request-send-budget.ts +259 -0
- package/src/server/responses/request-sidecar-auth.ts +149 -0
- package/src/server/responses/request-spend.ts +147 -0
- package/src/server/responses/request-transport.ts +803 -0
- package/src/server/responses/response-effects.ts +157 -0
- package/src/server/responses/run-turn-execution.ts +476 -0
- package/src/server/responses/sidecar-execution.ts +463 -0
- package/src/server/responses/terminal-guard.ts +65 -4
- package/src/server/responses-image-gen-repair.ts +1 -1
- package/src/server/responses-undeclared-tool-guard.ts +9 -5
- package/src/server/workflow-refusal.ts +84 -0
- package/src/service/windows-ops.ts +210 -16
- package/src/service/windows-scheduler.ts +28 -21
- package/src/service.ts +1 -1
- package/src/types/config.ts +34 -1
- package/src/types/request.ts +8 -5
- package/src/types/tools.ts +24 -0
- package/src/types.ts +2 -0
- package/src/update/index.ts +10 -0
- package/src/update/stop-contract.d.mts +1 -0
- package/src/update/stop-contract.mjs +19 -0
- package/src/update/stop-decision.d.mts +1 -1
- package/src/update/stop-decision.mjs +12 -3
- package/src/usage/log.ts +147 -1
- package/src/usage/summary.ts +171 -21
- package/src/vision/anthropic-describe.ts +1 -1
- package/src/vision/describe.ts +5 -5
- package/src/web-search/anthropic-executor.ts +1 -1
- package/src/web-search/exa-executor.ts +1 -1
- package/src/web-search/executor.ts +1 -1
- package/src/web-search/gemini-executor.ts +1 -1
- package/src/web-search/loop.ts +1 -1
- package/src/web-search/ollama-executor.ts +1 -1
- package/src/web-search/parse.ts +67 -14
- package/src/web-search/passthrough-bridge.ts +64 -31
- package/src/web-search/xai-executor.ts +1 -1
|
@@ -113,12 +113,42 @@ function safeTimeout(value: number | undefined): number {
|
|
|
113
113
|
? Math.min(Math.floor(value), 120_000) : DEFAULT_TIMEOUT_MS;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/** Match Bun fetch's environment routing, not the broader WebSocket NO_PROXY grammar. */
|
|
117
|
+
function catalogRequestUsesBunHttpProxy(url: URL): boolean {
|
|
118
|
+
if (url.protocol !== "http:") return false;
|
|
119
|
+
const proxy = process.env.http_proxy || process.env.HTTP_PROXY;
|
|
120
|
+
if (!proxy || proxy === '""' || proxy === "''") return false;
|
|
121
|
+
const hostname = url.hostname.toLowerCase();
|
|
122
|
+
const host = url.host.toLowerCase();
|
|
123
|
+
// Bun env_loader::is_no_proxy (1.4.2): lowercase wins unless empty, ASCII
|
|
124
|
+
// whitespace only, no scheme/path/wildcard/bracket/trailing-dot normalization.
|
|
125
|
+
const bypasses = process.env.no_proxy || process.env.NO_PROXY || "";
|
|
126
|
+
for (let entry of bypasses.split(",")) {
|
|
127
|
+
entry = entry.replace(/^[ \t\n\r\v\f]+|[ \t\n\r\v\f]+$/g, "")
|
|
128
|
+
.replace(/[A-Z]/g, letter => letter.toLowerCase());
|
|
129
|
+
if (entry === "*") return false;
|
|
130
|
+
if (entry.startsWith(".")) entry = entry.slice(1);
|
|
131
|
+
if (!entry) continue;
|
|
132
|
+
const hasPort = entry.startsWith("[")
|
|
133
|
+
? entry.includes("]:")
|
|
134
|
+
: (entry.match(/:/g)?.length ?? 0) === 1;
|
|
135
|
+
if (hasPort ? host === entry : hostname === entry || hostname.endsWith(`.${entry}`)) return false;
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
|
|
116
140
|
export async function fetchRemoteCatalog(
|
|
117
141
|
input: string,
|
|
118
142
|
options: Pick<PullRemoteCatalogOptions, "token" | "timeoutMs" | "maxBytes" | "fetchImpl"> = {},
|
|
119
143
|
): Promise<{ document: RemoteCatalogDocument; content: string }> {
|
|
120
144
|
const url = validateRemoteCatalogUrl(input);
|
|
121
145
|
const token = validateToken(options.token);
|
|
146
|
+
if (catalogRequestUsesBunHttpProxy(url)) {
|
|
147
|
+
throw new RemoteCatalogError(
|
|
148
|
+
"insecure_http_refused",
|
|
149
|
+
"Loopback HTTP catalog requests must bypass outbound HTTP proxy routing",
|
|
150
|
+
);
|
|
151
|
+
}
|
|
122
152
|
const headers = new Headers({ Accept: "application/json" });
|
|
123
153
|
if (token !== undefined) headers.set("Authorization", `Bearer ${token}`);
|
|
124
154
|
let response: Response;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { readConfigDiagnostics } from "../../config";
|
|
2
|
+
import { getCodexHome } from "../paths";
|
|
3
|
+
import { readCatalog, readCatalogBackup, readCodexCatalogPath } from "./parsing";
|
|
4
|
+
import type { RawEntry } from "./parsing";
|
|
5
|
+
import { RETIRED_NATIVE_OPENAI_MODELS, SUPPORTED_NATIVE_OPENAI_SLUGS } from "./metadata";
|
|
6
|
+
import { trustedAccountBoundNativeCatalogSlug } from "./account-models";
|
|
7
|
+
import {
|
|
8
|
+
withCatalogWriteSerialization,
|
|
9
|
+
type CatalogWritePermit,
|
|
10
|
+
} from "../catalog-write-serialization";
|
|
11
|
+
import { replaceActiveCodexCatalog } from "../internal/catalog-writer";
|
|
12
|
+
|
|
13
|
+
function visibleAccountReplacementNatives(
|
|
14
|
+
models: readonly RawEntry[],
|
|
15
|
+
disabledModels: ReadonlySet<string> | null,
|
|
16
|
+
): Map<string, boolean> {
|
|
17
|
+
const replacements = new Map<string, boolean>();
|
|
18
|
+
for (const entry of models) {
|
|
19
|
+
const nativeSlug = trustedAccountBoundNativeCatalogSlug(entry);
|
|
20
|
+
if (nativeSlug === undefined || !SUPPORTED_NATIVE_OPENAI_SLUGS.has(nativeSlug)) continue;
|
|
21
|
+
const exactSlug = typeof entry.slug === "string" ? entry.slug : "";
|
|
22
|
+
const visible = entry.visibility === "list"
|
|
23
|
+
|| (disabledModels !== null
|
|
24
|
+
&& (disabledModels.has(nativeSlug) || disabledModels.has(exactSlug)));
|
|
25
|
+
replacements.set(nativeSlug, (replacements.get(nativeSlug) ?? true) && visible);
|
|
26
|
+
}
|
|
27
|
+
return replacements;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function restoreAccountHiddenBareNatives(
|
|
31
|
+
entries: readonly RawEntry[],
|
|
32
|
+
replacementVisibility: ReadonlyMap<string, boolean>,
|
|
33
|
+
disabledModels: ReadonlySet<string> | null,
|
|
34
|
+
): RawEntry[] {
|
|
35
|
+
return entries.map(entry => {
|
|
36
|
+
const slug = typeof entry.slug === "string" ? entry.slug : "";
|
|
37
|
+
if (
|
|
38
|
+
entry.visibility !== "hide"
|
|
39
|
+
|| !SUPPORTED_NATIVE_OPENAI_SLUGS.has(slug)
|
|
40
|
+
|| replacementVisibility.get(slug) !== true
|
|
41
|
+
|| disabledModels === null
|
|
42
|
+
|| disabledModels.has(slug)
|
|
43
|
+
) {
|
|
44
|
+
return entry;
|
|
45
|
+
}
|
|
46
|
+
return { ...entry, visibility: "list" };
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function currentDisabledModelsForRestore(): Set<string> | null {
|
|
51
|
+
try {
|
|
52
|
+
const diagnostics = readConfigDiagnostics();
|
|
53
|
+
if (diagnostics.source === "fallback" || diagnostics.error !== null) return null;
|
|
54
|
+
return new Set(diagnostics.config.disabledModels ?? []);
|
|
55
|
+
} catch {
|
|
56
|
+
// An unreadable config cannot safely authorize a visibility change during restore.
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function restoreCodexCatalogWithPermit(
|
|
62
|
+
permit: CatalogWritePermit,
|
|
63
|
+
owningCodexHome: string,
|
|
64
|
+
/**
|
|
65
|
+
* The catalog this injection actually wrote, when it is known (#1798).
|
|
66
|
+
*
|
|
67
|
+
* Re-resolving from the CURRENT config is wrong after a Codex app rewrite that dropped
|
|
68
|
+
* `model_catalog_json`: that sends restore to the default catalog while the routed file we
|
|
69
|
+
* really wrote is left untouched. The recorded path is the file whose routing is ours.
|
|
70
|
+
*/
|
|
71
|
+
injectedCatalogPath?: string | null,
|
|
72
|
+
): { removed: number; kept: number; path: string } {
|
|
73
|
+
const catalogPath = injectedCatalogPath ?? readCodexCatalogPath();
|
|
74
|
+
const catalog = readCatalog(catalogPath);
|
|
75
|
+
if (!catalog || !Array.isArray(catalog.models)) return { removed: 0, kept: 0, path: catalogPath };
|
|
76
|
+
const disabledModels = currentDisabledModelsForRestore();
|
|
77
|
+
const replacementVisibility = visibleAccountReplacementNatives(catalog.models, disabledModels);
|
|
78
|
+
const backup = readCatalogBackup(catalogPath);
|
|
79
|
+
if (backup && Array.isArray(backup.models)) {
|
|
80
|
+
const removed = (catalog.models ?? []).filter(m => typeof m.slug === "string"
|
|
81
|
+
&& (m.slug.includes("/") || RETIRED_NATIVE_OPENAI_MODELS.has(m.slug))).length;
|
|
82
|
+
const backupSlugs = new Set(backup.models.flatMap(m => typeof m.slug === "string" ? [m.slug] : []));
|
|
83
|
+
const userNativeAdditions = restoreAccountHiddenBareNatives(
|
|
84
|
+
(catalog.models ?? []).filter(m =>
|
|
85
|
+
typeof m.slug === "string" && !m.slug.includes("/") && !backupSlugs.has(m.slug)
|
|
86
|
+
&& !RETIRED_NATIVE_OPENAI_MODELS.has(m.slug)
|
|
87
|
+
),
|
|
88
|
+
replacementVisibility,
|
|
89
|
+
disabledModels,
|
|
90
|
+
);
|
|
91
|
+
const restored = {
|
|
92
|
+
...backup,
|
|
93
|
+
// A pristine backup predates retirement; it must not revive withdrawn native rows.
|
|
94
|
+
models: [...backup.models.filter(m => typeof m.slug !== "string"
|
|
95
|
+
|| !RETIRED_NATIVE_OPENAI_MODELS.has(trustedAccountBoundNativeCatalogSlug(m) ?? m.slug)), ...userNativeAdditions],
|
|
96
|
+
};
|
|
97
|
+
replaceActiveCodexCatalog(permit, owningCodexHome, {
|
|
98
|
+
path: catalogPath,
|
|
99
|
+
content: `${JSON.stringify(restored, null, 2)}\n`,
|
|
100
|
+
});
|
|
101
|
+
return { removed, kept: restored.models.length, path: catalogPath };
|
|
102
|
+
}
|
|
103
|
+
const before = catalog.models.length;
|
|
104
|
+
const native = restoreAccountHiddenBareNatives(
|
|
105
|
+
catalog.models.filter(m => !(typeof m.slug === "string"
|
|
106
|
+
&& (m.slug.includes("/") || RETIRED_NATIVE_OPENAI_MODELS.has(m.slug)))),
|
|
107
|
+
replacementVisibility,
|
|
108
|
+
disabledModels,
|
|
109
|
+
);
|
|
110
|
+
const removed = before - native.length;
|
|
111
|
+
if (removed > 0) {
|
|
112
|
+
catalog.models = native;
|
|
113
|
+
replaceActiveCodexCatalog(permit, owningCodexHome, {
|
|
114
|
+
path: catalogPath,
|
|
115
|
+
content: `${JSON.stringify(catalog, null, 2)}\n`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return { removed, kept: native.length, path: catalogPath };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function restoreCodexCatalog(): { removed: number; kept: number; path: string } {
|
|
122
|
+
const owningCodexHome = getCodexHome();
|
|
123
|
+
const outcome = withCatalogWriteSerialization(
|
|
124
|
+
owningCodexHome,
|
|
125
|
+
permit => restoreCodexCatalogWithPermit(permit, owningCodexHome),
|
|
126
|
+
);
|
|
127
|
+
return outcome.kind === "completed"
|
|
128
|
+
? outcome.value
|
|
129
|
+
: { removed: 0, kept: 0, path: readCodexCatalogPath() };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Force Codex's models_cache stale from the on-disk catalog. Returns whether a cache write occurred. */
|