@bitkyc08/opencodex 2.55.0-preview.20260914 → 2.56.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/gui/dist/assets/{index-DH2PUHqr.js → index-D4zuyIxQ.js} +1 -1
- package/gui/dist/index.html +1 -1
- package/package.json +2 -1
- package/src/adapters/base.ts +21 -0
- package/src/adapters/cursor/transport-retry.ts +46 -1
- package/src/adapters/cursor.ts +4 -0
- package/src/adapters/kiro/adapter.ts +42 -1
- 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-schema.ts +477 -0
- package/src/adapters/openai-chat/wire.ts +50 -0
- package/src/adapters/openai-chat.ts +33 -1445
- 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 +611 -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 +34 -0
- package/src/bridge/internal.ts +174 -0
- package/src/bridge/response-json.ts +624 -0
- package/src/bridge/sse.ts +1444 -0
- package/src/bridge.ts +5 -2204
- package/src/chat/inbound.ts +12 -1
- package/src/codex/account-lifecycle.ts +3 -0
- package/src/codex/account-store.ts +71 -9
- 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 +554 -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 +422 -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 +95 -28
- 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 +304 -0
- package/src/codex/catalog/provider-fetch.ts +52 -2942
- package/src/codex/catalog/provider-models.ts +685 -0
- package/src/codex/catalog/restore.ts +132 -0
- package/src/codex/catalog/retained-sync.ts +706 -0
- package/src/codex/catalog/routed-gather.ts +858 -0
- package/src/codex/catalog/subagent-roster.ts +176 -0
- package/src/codex/catalog/sync.ts +52 -2698
- package/src/codex/inject/config-toml.ts +563 -0
- package/src/codex/inject/remove.ts +192 -0
- package/src/codex/inject/restore.ts +540 -0
- package/src/codex/inject/routing-classify.ts +109 -0
- package/src/codex/inject/routing-target.ts +125 -0
- package/src/codex/inject.ts +81 -1436
- package/src/codex/lineage.ts +458 -0
- package/src/codex/pool-refresh-backoff.ts +152 -0
- package/src/codex/routing/active-account.ts +194 -0
- package/src/codex/routing/cooldown-math.ts +275 -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 +703 -0
- package/src/codex/routing/thread-affinity.ts +538 -0
- package/src/codex/routing.ts +353 -2234
- 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/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/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 +539 -39
- package/src/lib/request-execution-budget.ts +69 -20
- package/src/lib/spend-reservation-ledger.ts +940 -0
- package/src/lib/upstream-retry.ts +55 -11
- package/src/lib/workflow-budget.ts +553 -30
- 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 +1221 -0
- package/src/providers/registry/entries-extended.ts +1204 -0
- package/src/providers/registry/model-seeds.ts +908 -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/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 +449 -0
- package/src/routing/probe-lease.ts +511 -0
- package/src/server/index/bounded-request.ts +88 -0
- package/src/server/index/live-sideband.ts +565 -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 +335 -0
- package/src/server/index.ts +40 -2547
- 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/request-log-conversation.ts +9 -7
- package/src/server/request-log.ts +245 -1
- package/src/server/responses/account-change-state.ts +233 -0
- package/src/server/responses/adapter-continuation.ts +514 -0
- package/src/server/responses/adapter-delivery.ts +214 -0
- package/src/server/responses/adapter-dispatch.ts +971 -0
- package/src/server/responses/compact.ts +59 -4
- package/src/server/responses/completion-policy.ts +33 -0
- package/src/server/responses/core-auth.ts +527 -0
- package/src/server/responses/core-codex-account.ts +859 -0
- package/src/server/responses/core-combo-failure.ts +210 -0
- package/src/server/responses/core-combo.ts +707 -0
- package/src/server/responses/core-errors.ts +152 -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 +225 -0
- package/src/server/responses/core.ts +192 -8893
- package/src/server/responses/passthrough-delivery.ts +856 -0
- package/src/server/responses/passthrough-dispatch.ts +1476 -0
- package/src/server/responses/passthrough-execution.ts +54 -0
- package/src/server/responses/request-prepare.ts +970 -0
- package/src/server/responses/request-send-budget.ts +164 -0
- package/src/server/responses/request-sidecar-auth.ts +149 -0
- package/src/server/responses/request-transport.ts +744 -0
- package/src/server/responses/response-effects.ts +157 -0
- package/src/server/responses/run-turn-execution.ts +448 -0
- package/src/server/responses/sidecar-execution.ts +469 -0
- package/src/server/responses-image-gen-repair.ts +1 -1
- package/src/server/workflow-refusal.ts +84 -0
- package/src/types/config.ts +30 -0
- package/src/usage/log.ts +146 -0
- package/src/usage/summary.ts +171 -21
|
@@ -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. */
|