@bitkyc08/opencodex 2.55.0 → 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-VuoiWj9J.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,192 @@
|
|
|
1
|
+
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
2
|
+
import { atomicWriteFile } from "../../config";
|
|
3
|
+
import {
|
|
4
|
+
OCX_SECTION_MARKER,
|
|
5
|
+
REALTIME_WS_BASE_URL_KEY,
|
|
6
|
+
hasInjectedOpenaiBaseUrl,
|
|
7
|
+
rootTomlString,
|
|
8
|
+
stripJournaledOpenaiBaseUrl,
|
|
9
|
+
} from "../injected-marker";
|
|
10
|
+
import { preflightCodexHistoryInjection } from "../history-provider";
|
|
11
|
+
import {
|
|
12
|
+
journaledInjectedOpenaiBaseUrl,
|
|
13
|
+
journaledInjectedRealtimeWsBaseUrl,
|
|
14
|
+
} from "../journal";
|
|
15
|
+
import { CODEX_CONFIG_PATH, CODEX_PROFILE_PATH, readRootTomlString } from "../paths";
|
|
16
|
+
import { transformManagedSubagentDefaults } from "../subagent-defaults";
|
|
17
|
+
import {
|
|
18
|
+
applyEol,
|
|
19
|
+
dominantEol,
|
|
20
|
+
removeProfileSection,
|
|
21
|
+
stripInjectedOpenaiBaseUrl,
|
|
22
|
+
stripOpencodexCatalogPath,
|
|
23
|
+
stripRootRoutedModel,
|
|
24
|
+
} from "./config-toml";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Sub-table headers like `[model_providers.opencodex.env_http_headers]` appear when a Codex app
|
|
28
|
+
* config rewrite re-serializes the provider's inline `env_http_headers` table. They define the
|
|
29
|
+
* same `model_providers.opencodex` provider, so cleanup must remove them too — otherwise the
|
|
30
|
+
* provider survives with no `name` and Codex rejects the whole config
|
|
31
|
+
* ("provider name must not be empty"). The dot terminator keeps a user's
|
|
32
|
+
* `[model_providers.opencodex_backup]`-style tables out of scope.
|
|
33
|
+
*/
|
|
34
|
+
function isOcxProviderHeaderLine(trimmedLine: string): boolean {
|
|
35
|
+
// Root form matched by regex, not equality: TOML v1.0 allows a trailing comment
|
|
36
|
+
// (`[model_providers.opencodex] # comment`), and an exact compare would miss that form.
|
|
37
|
+
// The sub-table prefix check already tolerates trailing comments by construction.
|
|
38
|
+
return (
|
|
39
|
+
/^\[model_providers\.opencodex\]\s*(?:#.*)?$/.test(trimmedLine) ||
|
|
40
|
+
trimmedLine.startsWith("[model_providers.opencodex.")
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function hasOcxProviderTable(content: string): boolean {
|
|
45
|
+
return content
|
|
46
|
+
.split("\n")
|
|
47
|
+
.some((line) => isOcxProviderHeaderLine(line.trim()));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function removeOcxSection(content: string): string {
|
|
51
|
+
const lines = content.split("\n");
|
|
52
|
+
const filtered: string[] = [];
|
|
53
|
+
let inOcxSection = false;
|
|
54
|
+
for (const line of lines) {
|
|
55
|
+
if (
|
|
56
|
+
line.includes(OCX_SECTION_MARKER) ||
|
|
57
|
+
isOcxProviderHeaderLine(line.trim())
|
|
58
|
+
) {
|
|
59
|
+
inOcxSection = true;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (inOcxSection) {
|
|
63
|
+
// End the injected section at the next table header that ISN'T our own. Exact match on the
|
|
64
|
+
// provider name (plus our own sub-tables) so a user's
|
|
65
|
+
// "[model_providers.opencodex_backup]" (or similar) is preserved, not swallowed.
|
|
66
|
+
if (/^\s*\[/.test(line) && !isOcxProviderHeaderLine(line.trim())) {
|
|
67
|
+
inOcxSection = false;
|
|
68
|
+
filtered.push(line);
|
|
69
|
+
}
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
filtered.push(line);
|
|
73
|
+
}
|
|
74
|
+
return (
|
|
75
|
+
filtered
|
|
76
|
+
.join("\n")
|
|
77
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
78
|
+
.trimEnd() + "\n"
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface StripOpencodexConfigResult {
|
|
83
|
+
content: string;
|
|
84
|
+
managedDefaultsError: string | null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Detailed form used by the on-disk restore path. A damaged ownership marker is
|
|
89
|
+
* ambiguous: keep the associated value, but return the transform error so the
|
|
90
|
+
* caller cannot report a complete restore.
|
|
91
|
+
*/
|
|
92
|
+
function stripOpencodexConfigResult(
|
|
93
|
+
content: string,
|
|
94
|
+
journaledBaseUrl: string | null = null,
|
|
95
|
+
journaledRealtimeWsBaseUrl: string | null = null,
|
|
96
|
+
): StripOpencodexConfigResult {
|
|
97
|
+
let out = content;
|
|
98
|
+
const hadRootOcxProvider =
|
|
99
|
+
readRootTomlString(out, "model_provider") === "opencodex";
|
|
100
|
+
// #1798: marker adjacency is FORMATTING evidence, and a Codex app rewrite keeps values
|
|
101
|
+
// while dropping comments. Fall back to VALUE evidence -- the exact URL we recorded
|
|
102
|
+
// writing -- so an app-rewritten config is still recognized as ours.
|
|
103
|
+
const hadInjectedBaseUrl = hasInjectedOpenaiBaseUrl(out)
|
|
104
|
+
|| (journaledBaseUrl !== null && rootTomlString(out, "openai_base_url") === journaledBaseUrl);
|
|
105
|
+
out = stripInjectedOpenaiBaseUrl(out); // before removeOcxSection — it keys on the marker line too
|
|
106
|
+
out = stripJournaledOpenaiBaseUrl(out, journaledBaseUrl, journaledRealtimeWsBaseUrl);
|
|
107
|
+
if (hasOcxProviderTable(out)) {
|
|
108
|
+
out = removeOcxSection(out);
|
|
109
|
+
}
|
|
110
|
+
out = removeProfileSection(out);
|
|
111
|
+
// Regex (not exact-string) removal so compact `model_provider="opencodex"` is stripped too —
|
|
112
|
+
// must match the detection regex above, or a detected line could survive un-removed.
|
|
113
|
+
out = out
|
|
114
|
+
.split("\n")
|
|
115
|
+
.filter((l) => !/^\s*model_provider\s*=\s*"opencodex"\s*$/.test(l))
|
|
116
|
+
.join("\n");
|
|
117
|
+
// Routed root model ids (`model = "provider/slug"`) only make sense while the proxy serves
|
|
118
|
+
// them — strip on both the legacy re-tag form and the Design B injected-base-url form.
|
|
119
|
+
if (hadRootOcxProvider || hadInjectedBaseUrl) out = stripRootRoutedModel(out);
|
|
120
|
+
const managedDefaults = transformManagedSubagentDefaults(out, null);
|
|
121
|
+
if (managedDefaults.ok) out = managedDefaults.content;
|
|
122
|
+
out = stripOpencodexCatalogPath(out);
|
|
123
|
+
return {
|
|
124
|
+
content: out.replace(/\n{3,}/g, "\n\n").trimEnd() + "\n",
|
|
125
|
+
managedDefaultsError: !managedDefaults.ok ? managedDefaults.error : null,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Pure transform: strip the opencodex provider block + `model_provider = "opencodex"` lines. */
|
|
130
|
+
export function stripOpencodexConfig(content: string): string {
|
|
131
|
+
return stripOpencodexConfigResult(content).content;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function hasOpencodexRouting(content: string): boolean {
|
|
135
|
+
return (
|
|
136
|
+
hasOcxProviderTable(content) ||
|
|
137
|
+
/^\s*model_provider\s*=\s*"opencodex"/m.test(content) ||
|
|
138
|
+
hasInjectedOpenaiBaseUrl(content)
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function removeCodexConfig(
|
|
143
|
+
options: { preserveProfile?: boolean } = {},
|
|
144
|
+
): { success: boolean; message: string } {
|
|
145
|
+
const historyError = preflightCodexHistoryInjection(false, false);
|
|
146
|
+
if (historyError) return { success: false, message: `Codex configuration preserved: ${historyError}. Native writer coordination is required.` };
|
|
147
|
+
if (!existsSync(CODEX_CONFIG_PATH)) {
|
|
148
|
+
if (!options.preserveProfile && existsSync(CODEX_PROFILE_PATH))
|
|
149
|
+
unlinkSync(CODEX_PROFILE_PATH);
|
|
150
|
+
return {
|
|
151
|
+
success: true,
|
|
152
|
+
message: `Codex config not found; no native restore was needed${options.preserveProfile ? "." : ", and the opencodex profile was removed if present."}`,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const rawContent = readFileSync(CODEX_CONFIG_PATH, "utf-8");
|
|
156
|
+
// Same EOL boundary as inject: strip in LF space, write back in the file's own ending.
|
|
157
|
+
// The unchanged fast path compares in LF space so an untouched file is never rewritten.
|
|
158
|
+
const eol = dominantEol(rawContent);
|
|
159
|
+
const content = applyEol(rawContent, "\n");
|
|
160
|
+
// Read the recorded injection once: the strip below consumes it, and so does the
|
|
161
|
+
// ownership verdict, which must agree with what was actually removed.
|
|
162
|
+
const journaledBaseUrl = journaledInjectedOpenaiBaseUrl();
|
|
163
|
+
const journaledRealtimeWsBaseUrl = journaledInjectedRealtimeWsBaseUrl();
|
|
164
|
+
const had = hasOpencodexRouting(content)
|
|
165
|
+
|| (journaledBaseUrl !== null && rootTomlString(content, "openai_base_url") === journaledBaseUrl)
|
|
166
|
+
|| (journaledRealtimeWsBaseUrl !== null
|
|
167
|
+
&& rootTomlString(content, REALTIME_WS_BASE_URL_KEY) === journaledRealtimeWsBaseUrl);
|
|
168
|
+
const stripped = stripOpencodexConfigResult(content, journaledBaseUrl, journaledRealtimeWsBaseUrl);
|
|
169
|
+
if (had || stripped.content !== content) {
|
|
170
|
+
atomicWriteFile(CODEX_CONFIG_PATH, applyEol(stripped.content, eol));
|
|
171
|
+
}
|
|
172
|
+
if (!options.preserveProfile && existsSync(CODEX_PROFILE_PATH))
|
|
173
|
+
unlinkSync(CODEX_PROFILE_PATH);
|
|
174
|
+
const removedMessage = had
|
|
175
|
+
? `Removed opencodex routing from Codex config${options.preserveProfile ? "." : " + profile."}`
|
|
176
|
+
: "opencodex not present in Codex config.";
|
|
177
|
+
if (stripped.managedDefaultsError) {
|
|
178
|
+
const routingMessage = had
|
|
179
|
+
? removedMessage
|
|
180
|
+
: "No opencodex routing was present in Codex config.";
|
|
181
|
+
return {
|
|
182
|
+
success: false,
|
|
183
|
+
message:
|
|
184
|
+
`${routingMessage} Native Codex sub-agent defaults could not be safely removed: ${stripped.managedDefaultsError}. ` +
|
|
185
|
+
"The ambiguous marker and adjacent value were preserved; inspect $CODEX_HOME/config.toml before using native Codex.",
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
success: true,
|
|
190
|
+
message: removedMessage,
|
|
191
|
+
};
|
|
192
|
+
}
|