@bitkyc08/opencodex 2.92.0 → 2.93.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 -5
- package/gui/dist/assets/{App-sUf_8afJ.js → App-CizjBqyk.js} +18 -18
- package/gui/dist/assets/{Tray-BSsxznDm.js → Tray-DamiMqcX.js} +1 -1
- package/gui/dist/assets/{index-BlFE_VB_.js → index-DQsht3vH.js} +12 -12
- package/gui/dist/assets/index-DRe8Hhfz.css +1 -0
- package/gui/dist/assets/{quota-summary-BRlbXgw0.js → quota-summary-BXu4zE8H.js} +1 -1
- package/gui/dist/index.html +2 -2
- package/package.json +5 -5
- package/src/adapters/anthropic.ts +28 -5
- package/src/adapters/coding-agent/batch-dispatcher.ts +122 -0
- package/src/adapters/coding-agent/profile.ts +54 -16
- package/src/adapters/coding-agent/turn.ts +30 -2
- package/src/adapters/command-code.ts +114 -7
- package/src/adapters/cursor/native-exec-fs.ts +11 -9
- package/src/adapters/devin/live-models.ts +4 -0
- package/src/adapters/google-wire-compiler.ts +1 -2
- package/src/adapters/kiro/reasoning.ts +2 -0
- package/src/adapters/kiro-refusal.ts +6 -1
- package/src/adapters/kiro-wire.ts +1 -1
- package/src/adapters/openai-chat/messages.ts +8 -2
- package/src/adapters/openai-chat/passthrough.ts +35 -14
- package/src/adapters/openai-chat/reasoning-replay.ts +27 -16
- package/src/adapters/openai-chat/reasoning-wire.ts +117 -8
- package/src/adapters/openai-chat/required-tool-result.ts +64 -0
- package/src/adapters/openai-chat.ts +7 -8
- package/src/adapters/openai-responses/passthrough.ts +7 -4
- package/src/adapters/openai-responses/reasoning.ts +13 -0
- package/src/adapters/openai-responses/request-strips.ts +1 -1
- package/src/adapters/qoder/adapter.ts +129 -8
- package/src/adapters/qoder/scaffold-guard.ts +5 -0
- package/src/adapters/reasoning-controls.ts +16 -0
- package/src/adapters/tool-call-id.ts +1 -3
- package/src/bridge/errors.ts +27 -0
- package/src/bridge.ts +1 -1
- package/src/chat/inbound.ts +4 -1
- package/src/chat/outbound.ts +9 -2
- package/src/chat/reasoning-details.ts +28 -5
- package/src/claude/desktop-first-party.ts +54 -4
- package/src/claude/desktop-picker.ts +11 -8
- package/src/claude/first-party-settings.ts +3 -1
- package/src/claude/inbound.ts +2 -1
- package/src/claude/intercept/local-ca.ts +2 -1
- package/src/claude/intercept/picker-ca-cleanup.ts +4 -2
- package/src/claude/intercept/picker-ca-startup.ts +3 -1
- package/src/claude/intercept/picker-models.ts +6 -3
- package/src/claude/intercept/picker-runtime.ts +3 -2
- package/src/claude/intercept/runtime.ts +6 -3
- package/src/claude/model-info.ts +31 -8
- package/src/cli/account-api.ts +11 -0
- package/src/cli/capabilities-agents-routing.ts +2 -2
- package/src/cli/capabilities-base.ts +7 -1
- package/src/cli/capabilities-observe-system.ts +10 -0
- package/src/cli/claude-desktop.ts +9 -8
- package/src/cli/claude.ts +3 -2
- package/src/cli/codex-shim-autorestore.ts +9 -0
- package/src/cli/combo-result.ts +7 -0
- package/src/cli/combo.ts +18 -0
- package/src/cli/cross-home-owner.ts +13 -1
- package/src/cli/dispatch.ts +25 -6
- package/src/cli/ensure-desired-integrations.ts +8 -6
- package/src/cli/export-command.ts +4 -1
- package/src/cli/help.ts +2 -1
- package/src/cli/index.ts +45 -45
- package/src/cli/integration-plan-dto.ts +4 -0
- package/src/cli/opencode.ts +20 -9
- package/src/cli/registry.ts +6 -4
- package/src/cli/root.ts +9 -0
- package/src/cli/status.ts +59 -1
- package/src/cli/stop-restore.ts +113 -0
- package/src/cli/sync-expectation.ts +60 -0
- package/src/cli/uninstall-integrations.ts +41 -7
- package/src/client/connect.ts +40 -3
- package/src/client/link-home.ts +10 -1
- package/src/client/machine-api.ts +3 -1
- package/src/client/sync-expectation.ts +118 -0
- package/src/clients/config-export/agent-clients.ts +96 -0
- package/src/clients/config-export/contracts.ts +25 -7
- package/src/clients/config-export/qoder.ts +38 -23
- package/src/clients/config-export/reasoning-metadata.ts +55 -8
- package/src/clients/config-export.ts +12 -0
- package/src/clients/lazycodex.ts +7 -2
- package/src/clients/reasoning-controls.ts +49 -0
- package/src/codex/auth-api/account-identity.ts +14 -0
- package/src/codex/auth-api/account-list.ts +29 -2
- package/src/codex/auth-api/http.ts +13 -0
- package/src/codex/auth-api/main-account-probe.ts +2 -2
- package/src/codex/auth-api/pool-mode-gate.ts +16 -3
- package/src/codex/auth-api/pool-quota-probe.ts +15 -0
- package/src/codex/auth-context.ts +15 -12
- package/src/codex/catalog/build-entries.ts +22 -0
- package/src/codex/catalog/configured-tiers.ts +70 -0
- package/src/codex/catalog/effort.ts +44 -10
- package/src/codex/catalog/gather-capture.ts +1 -0
- package/src/codex/catalog/heal-observation.ts +155 -13
- package/src/codex/catalog/metadata.ts +6 -0
- package/src/codex/catalog/model-hints.ts +60 -11
- package/src/codex/catalog/model-visibility.ts +3 -2
- package/src/codex/catalog/native-models.ts +18 -3
- package/src/codex/catalog/parsing.ts +10 -8
- package/src/codex/catalog/pinned-models.ts +2 -1
- package/src/codex/catalog/provider-models.ts +4 -5
- package/src/codex/catalog/retained-sync.ts +2 -1
- package/src/codex/catalog/routed-gather.ts +19 -20
- package/src/codex/catalog/write-audit.ts +3 -2
- package/src/codex/catalog-self-heal.ts +43 -23
- package/src/codex/collision-identity.ts +30 -5
- package/src/codex/convergence.ts +4 -3
- package/src/codex/data/roster-pinned-models.json +177 -1
- package/src/codex/desired-state.ts +6 -1
- package/src/codex/desktop-compatibility/installed-build.ts +88 -12
- package/src/codex/desktop-compatibility/runtime.ts +29 -5
- package/src/codex/desktop-compatibility/usage-controller.ts +2 -0
- package/src/codex/desktop-compatibility/windows-certificate-trust.ts +46 -12
- package/src/codex/inject/config-toml.ts +0 -18
- package/src/codex/inject/plan.ts +18 -3
- package/src/codex/inject/remove.ts +6 -2
- package/src/codex/inject.ts +1 -1
- package/src/codex/journal.ts +61 -1
- package/src/codex/model-entitlements.ts +1 -1
- package/src/codex/native-main-owner.ts +27 -1
- package/src/codex/native-profile-store.ts +2 -1
- package/src/codex/pool-credit-policy.ts +35 -1
- package/src/codex/quota-types.ts +3 -0
- package/src/codex/quota.ts +24 -4
- package/src/codex/role-auto-assign.ts +6 -2
- package/src/codex/subagent-defaults.ts +49 -4
- package/src/combos/failover.ts +17 -2
- package/src/combos/jev-decision-contract.ts +22 -1
- package/src/combos/jev-service-exchange.ts +3 -1
- package/src/combos/jev.ts +95 -9
- package/src/combos/resolve.ts +45 -1
- package/src/combos/types.ts +24 -0
- package/src/config/load-degrade.ts +5 -0
- package/src/config/paths.ts +19 -3
- package/src/config/pending-teardown.ts +22 -1
- package/src/config/provider-validation.ts +15 -4
- package/src/config/removed-opencode-free.ts +11 -0
- package/src/config/schema/leaf-validators.ts +5 -0
- package/src/generated/compatibility-version.json +314 -230
- package/src/generated/model-metadata.ts +5 -5
- package/src/images/loop.ts +16 -2
- package/src/integrations/catalog-refresh.ts +1 -1
- package/src/integrations/hermes-profiles.ts +251 -0
- package/src/integrations/merge.ts +8 -0
- package/src/integrations/mutation-plan.ts +19 -4
- package/src/integrations/registry.ts +5 -0
- package/src/integrations/state.ts +36 -1
- package/src/integrations/writer.ts +18 -4
- package/src/lib/bun-path-runtime.mjs +2 -1
- package/src/lib/errors.ts +62 -0
- package/src/lib/eventstream-decoder.ts +81 -37
- package/src/lib/opaque-proxy-tunnel.ts +32 -8
- package/src/lib/pinned-http.ts +35 -2
- package/src/lib/process-control.ts +13 -1
- package/src/lib/socks5-fetch.ts +59 -64
- package/src/lib/socks5-upload-waiter.ts +50 -0
- package/src/lib/sse-decoder.ts +7 -2
- package/src/lib/state-store-sweeper.ts +40 -14
- package/src/lib/windows-native-principal-worker.ts +14 -0
- package/src/lib/windows-native-principal.ts +188 -0
- package/src/lib/windows-secret-acl.ts +39 -3
- package/src/lib/windows-user-principal.ts +62 -18
- package/src/link/ssh-config.ts +35 -3
- package/src/providers/account-quota-disk.ts +12 -4
- package/src/providers/codebuddy-models.ts +6 -0
- package/src/providers/codex-capacity.ts +3 -1
- package/src/providers/derive.ts +28 -0
- package/src/providers/kiro-models.ts +3 -0
- package/src/providers/mimo-thinking.ts +12 -0
- package/src/providers/model-rename-fields.ts +1 -0
- package/src/providers/model-rename-migration.ts +10 -0
- package/src/providers/openai-sidecar-credit.ts +2 -2
- package/src/providers/reasoning-capabilities.ts +76 -0
- package/src/providers/registry/entries-core.ts +14 -12
- package/src/providers/registry/entries-extended.ts +63 -20
- package/src/providers/registry/model-ids.ts +2 -0
- package/src/providers/registry/model-seeds.ts +93 -28
- package/src/providers/registry/types.ts +10 -1
- package/src/providers/resolved-model-policy.ts +26 -6
- package/src/providers/routed-config.ts +9 -1
- package/src/providers/stale-model-roster-migration.ts +44 -7
- package/src/remote-control/workspace-pi-runtime.ts +11 -6
- package/src/responses/compaction-summary.ts +45 -0
- package/src/responses/muse-tool-name-alias.ts +1 -2
- package/src/responses/parser.ts +3 -2
- package/src/responses/schema.ts +1 -0
- package/src/responses/thought-signature-replay.ts +10 -2
- package/src/routing/capability.ts +8 -2
- package/src/routing/history/ingest.ts +28 -3
- package/src/server/auth-cors.ts +3 -2
- package/src/server/chat-completions.ts +7 -0
- package/src/server/chat-native-eligibility.ts +7 -0
- package/src/server/chat-native-reasoning.ts +14 -4
- package/src/server/direct-local-http.ts +5 -2
- package/src/server/effort-policy.ts +5 -1
- package/src/server/index/live-sideband.ts +18 -15
- package/src/server/index/serve-options.ts +5 -4
- package/src/server/management/agent-settings-routes.ts +27 -15
- package/src/server/management/combo-routes.ts +4 -0
- package/src/server/management/config-routes.ts +2 -2
- package/src/server/management/decision-discovery.ts +12 -2
- package/src/server/management/hermes-profile-routes.ts +156 -0
- package/src/server/management/integration-routes.ts +85 -24
- package/src/server/management/model-routes.ts +2 -2
- package/src/server/management/model-row-export-metadata.ts +25 -6
- package/src/server/management/model-rows.ts +15 -20
- package/src/server/management/native-integration-routes.ts +11 -8
- package/src/server/management/route-registry.ts +4 -0
- package/src/server/management-api.ts +5 -0
- package/src/server/models-capabilities.ts +21 -3
- package/src/server/responses/adapter-delivery.ts +11 -1
- package/src/server/responses/adapter-dispatch.ts +2 -2
- package/src/server/responses/codex-ws-exchange.ts +39 -9
- package/src/server/responses/codex-ws-session.ts +38 -4
- package/src/server/responses/codex-ws-wire.ts +6 -1
- package/src/server/responses/combo-required-tool-contract.ts +103 -0
- package/src/server/responses/combo-stream-preflight.ts +8 -1
- package/src/server/responses/compact.ts +4 -3
- package/src/server/responses/context-overflow.ts +8 -1
- package/src/server/responses/core-combo-failure.ts +10 -0
- package/src/server/responses/core-combo.ts +23 -15
- package/src/server/responses/core-lifetime.ts +3 -0
- package/src/server/responses/core-normalize.ts +11 -1
- package/src/server/responses/core-options.ts +2 -0
- package/src/server/responses/main-hard-lock-routing.ts +60 -44
- package/src/server/responses/passthrough-delivery.ts +40 -2
- package/src/server/responses/policy-fallback.ts +6 -1
- package/src/server/responses/request-compression.ts +12 -7
- package/src/server/responses/request-prepare.ts +22 -2
- package/src/server/responses/request-sidecar-auth.ts +2 -0
- package/src/server/responses/response-effects.ts +22 -10
- package/src/server/responses/sidecar-execution.ts +11 -3
- package/src/server/stop-teardown.ts +36 -1
- package/src/server/ws-bridge.ts +1 -1
- package/src/service/desktop-supervision.d.mts +7 -4
- package/src/service/desktop-supervision.mjs +90 -13
- package/src/service/ownership-mutation-lease.mjs +21 -7
- package/src/types/config.ts +8 -2
- package/src/types/provider.ts +20 -6
- package/src/types/request.ts +10 -0
- package/src/types.ts +1 -0
- package/src/update/bind-probe.ts +29 -0
- package/src/update/job.ts +10 -29
- package/src/update/npm-install-job.ps1 +173 -0
- package/src/update/npm-install.mjs +70 -0
- package/src/update/stop-contract.d.mts +1 -0
- package/src/update/stop-contract.mjs +14 -0
- package/src/update/stop-decision.d.mts +1 -1
- package/src/update/stop-decision.mjs +13 -3
- package/src/update/teardown-handover.ts +166 -0
- package/src/update/transactional-install.d.mts +14 -3
- package/src/update/transactional-install.mjs +33 -7
- package/src/usage/expected-prices.ts +64 -31
- package/src/usage/timeline.ts +19 -9
- package/src/vision/eligibility.ts +15 -5
- package/src/vision/plan.ts +2 -2
- package/src/web-search/loop.ts +16 -2
- package/gui/dist/assets/index-DPeB9HpV.css +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { canInferVendorContext } from "./vendor-context";
|
|
2
2
|
import { effectiveProviderAlias, effectiveProviderAliasDecision } from "../../providers/default-aliases";
|
|
3
3
|
import { initialModelSelectionPending } from "../../providers/initial-model-selection";
|
|
4
|
-
import { supportsConfiguredUltraFast } from "./configured-tiers";
|
|
4
|
+
import { supportsConfiguredFlex, supportsConfiguredUltraFast } from "./configured-tiers";
|
|
5
5
|
import { execFileSync } from "node:child_process";
|
|
6
6
|
import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
7
7
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, realpathSync } from "node:fs";
|
|
@@ -102,7 +102,7 @@ import type {
|
|
|
102
102
|
CatalogTrustedOpenAiApiPolicySnapshot,
|
|
103
103
|
} from "../convergence-types";
|
|
104
104
|
import type { CatalogGatherProviderAuthOutcome, CatalogGatherProviderModelOutcome, GatherFlightCapture, ModelsAuthResolverFactory } from "./gather-capture";
|
|
105
|
-
import { applyProviderConfigHints, configuredAutoCompactTokenLimit, configuredMaxInputTokens, configuredModelDisplayName, configuredReasoningSummarySupport, modelInputModalities, routedMaxOutputTokens, withVisionSidecarInput } from "./model-hints";
|
|
105
|
+
import { applyProviderConfigHints, configuredAutoCompactTokenLimit, configuredMaxInputTokens, configuredModelDisplayName, configuredReasoningSummarySupport, copyReasoningHintSource, modelInputModalities, routedMaxOutputTokens, withVisionSidecarInput } from "./model-hints";
|
|
106
106
|
import { resolveComboCatalogMember } from "./combo-member";
|
|
107
107
|
import { captureGatherFlight, captureTrustedOpenAiApiPolicy, gatherFlightKey, keyedGatherBytesIdentity, withCanonicalOpenAiForwardAuthDefault } from "./gather-capture";
|
|
108
108
|
import { fetchProviderModelsWithAuth, observedModelsAuthResolver, refreshingModelsAuthResolver } from "./provider-models";
|
|
@@ -364,6 +364,7 @@ async function gatherRoutedModelsUncached(
|
|
|
364
364
|
const supported = serviceTierSupportFromPolicy(policy);
|
|
365
365
|
if (supported !== undefined) model.supportsServiceTier = supported;
|
|
366
366
|
model.supportsUltraFastTier = supportsConfiguredUltraFast(policy);
|
|
367
|
+
model.supportsFlexTier = supportsConfiguredFlex(policy);
|
|
367
368
|
if (supported === true && policy.fastTierDescription !== undefined) model.fastTierDescription = policy.fastTierDescription;
|
|
368
369
|
}
|
|
369
370
|
}
|
|
@@ -661,6 +662,7 @@ async function gatherRoutedModelsUncached(
|
|
|
661
662
|
...(cm.defaultReasoningEffort ? { defaultReasoningEffort: cm.defaultReasoningEffort } : {}),
|
|
662
663
|
...(typeof supportsServiceTier === "boolean" ? { supportsServiceTier } : {}),
|
|
663
664
|
supportsUltraFastTier: supportsConfiguredUltraFast(fastPolicy),
|
|
665
|
+
supportsFlexTier: supportsConfiguredFlex(fastPolicy),
|
|
664
666
|
...(supportsServiceTier === true && fastPolicy?.fastTierDescription !== undefined
|
|
665
667
|
? { fastTierDescription: fastPolicy.fastTierDescription }
|
|
666
668
|
: {}),
|
|
@@ -818,8 +820,8 @@ async function gatherRoutedModelsUncached(
|
|
|
818
820
|
? config.combos?.[model.id]?.targets ?? []
|
|
819
821
|
: [{ provider: model.provider }];
|
|
820
822
|
const inactive = quotaInactiveReason(config, targets);
|
|
821
|
-
const named = displayName && !model.displayName ? { ...model, displayName } : model;
|
|
822
|
-
return inactive ? { ...named, quotaInactiveReason: inactive } : named;
|
|
823
|
+
const named = displayName && !model.displayName ? copyReasoningHintSource(model, { ...model, displayName }) : model;
|
|
824
|
+
return inactive ? copyReasoningHintSource(named, { ...named, quotaInactiveReason: inactive }) : named;
|
|
823
825
|
}),
|
|
824
826
|
comboOmissions: localOmissions,
|
|
825
827
|
providerAuthOutcomes: localProviderAuthOutcomes,
|
|
@@ -966,7 +968,7 @@ export function augmentRoutedModelsWithMetadata(
|
|
|
966
968
|
: undefined;
|
|
967
969
|
const liveWindow = typeof existing.contextWindow === "number" && existing.contextWindow > 0;
|
|
968
970
|
if (liveWindow || publishedWindow === undefined) continue;
|
|
969
|
-
const seeded
|
|
971
|
+
const seeded = copyReasoningHintSource(existing, { ...existing, contextWindow: publishedWindow });
|
|
970
972
|
out[existingIndex] = providers?.[provider]
|
|
971
973
|
? applyProviderConfigHints(
|
|
972
974
|
provider,
|
|
@@ -990,21 +992,18 @@ export function augmentRoutedModelsWithMetadata(
|
|
|
990
992
|
...(typeof meta.maxTokens === "number" && meta.maxTokens > 0 ? { maxOutputTokens: meta.maxTokens } : {}),
|
|
991
993
|
...(Array.isArray(meta.input) && meta.input.length > 0 ? { inputModalities: [...meta.input] } : {}),
|
|
992
994
|
};
|
|
993
|
-
out.push(
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
)
|
|
1006
|
-
: {}),
|
|
1007
|
-
});
|
|
995
|
+
out.push(providers?.[provider]
|
|
996
|
+
? applyProviderConfigHints(
|
|
997
|
+
provider,
|
|
998
|
+
providers[provider],
|
|
999
|
+
model,
|
|
1000
|
+
contextCap,
|
|
1001
|
+
metadataModelIdCaseFoldByProvider?.get(provider),
|
|
1002
|
+
undefined,
|
|
1003
|
+
metadataConfigDirByProvider?.get(provider),
|
|
1004
|
+
includeVisionSidecar,
|
|
1005
|
+
)
|
|
1006
|
+
: model);
|
|
1008
1007
|
}
|
|
1009
1008
|
}
|
|
1010
1009
|
return out;
|
|
@@ -68,6 +68,8 @@ function readTail(fd: number, size: number): Buffer {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
function completeRecords(bytes: Buffer): { records: Buffer[]; count: number; clean: boolean } {
|
|
71
|
+
// Keep a BOM in the decoded text so JSON.parse still rejects BOM-prefixed rows.
|
|
72
|
+
const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
71
73
|
const records: Buffer[] = [];
|
|
72
74
|
let start = 0;
|
|
73
75
|
let clean = true;
|
|
@@ -75,8 +77,7 @@ function completeRecords(bytes: Buffer): { records: Buffer[]; count: number; cle
|
|
|
75
77
|
for (let end = bytes.indexOf(10); end !== -1; end = bytes.indexOf(10, start)) {
|
|
76
78
|
const line = bytes.subarray(start, end);
|
|
77
79
|
try {
|
|
78
|
-
const text =
|
|
79
|
-
if (!line.equals(Buffer.from(text))) throw new Error("invalid UTF-8");
|
|
80
|
+
const text = decoder.decode(line);
|
|
80
81
|
JSON.parse(text);
|
|
81
82
|
records[count % CATALOG_AUDIT_KEEP_RECORDS] = bytes.subarray(start, end + 1);
|
|
82
83
|
count++;
|
|
@@ -3,7 +3,7 @@ import { readRuntimePort } from "../config/process-state";
|
|
|
3
3
|
import { readClientConnectionState } from "../client/state";
|
|
4
4
|
import { getActiveTurnCount, isDraining, isRecyclingForExit, isShutdownDraining } from "../server/lifecycle";
|
|
5
5
|
import type { OcxConfig } from "../types";
|
|
6
|
-
import { observeCatalogHealFile,
|
|
6
|
+
import { compareCatalogHealPaths, observeCatalogHealFile, retainCatalogHealPath, selectCatalogHealPath, type CatalogObservation } from "./catalog/heal-observation";
|
|
7
7
|
import { subscribeCatalogPublication } from "./catalog/publication-observer";
|
|
8
8
|
import { configEnablesRoutedNamespace, ocxRoutedNamespaceCounts } from "./catalog/routed-removal";
|
|
9
9
|
import { inspectCodexHomeOwner } from "./codex-home-owner";
|
|
@@ -51,6 +51,7 @@ export interface CatalogSelfHealDeps {
|
|
|
51
51
|
now?: () => number;
|
|
52
52
|
catalogPath?: () => string | null;
|
|
53
53
|
observe?: (path: string, readContent: boolean) => CatalogObservation | null;
|
|
54
|
+
retainPath?: typeof retainCatalogHealPath;
|
|
54
55
|
converge?: (config: OcxConfig, lifecycle: CatalogHealLifecycle) => Promise<CatalogHealOutcome>;
|
|
55
56
|
subscribe?: typeof subscribeCatalogPublication;
|
|
56
57
|
gates?: Partial<CatalogSelfHealGates>;
|
|
@@ -135,14 +136,19 @@ export function startCodexCatalogSelfHeal(options: { port?: number; deps?: Catal
|
|
|
135
136
|
const attempts: number[] = [];
|
|
136
137
|
const heals: number[] = [];
|
|
137
138
|
|
|
138
|
-
const read = (path: string): NamespaceObservation | null => {
|
|
139
|
+
const read = (path: string, fresh = false): NamespaceObservation | null => {
|
|
139
140
|
const quick = observe(path, false);
|
|
140
141
|
if (quick === null) return null;
|
|
141
|
-
if (
|
|
142
|
+
if (!fresh && observed !== null) {
|
|
143
|
+
const relation = compareCatalogHealPaths(observed.path, path);
|
|
144
|
+
if (relation === "unknown") return null;
|
|
145
|
+
if (relation === "same" && observed.signature === quick.signature) return observed;
|
|
146
|
+
}
|
|
142
147
|
const seen = observe(path, true);
|
|
143
148
|
if (seen === null) return null;
|
|
144
|
-
|
|
145
|
-
|
|
149
|
+
const result = { path, signature: seen.signature, namespaces: seen.catalog ? new Set(ocxRoutedNamespaceCounts(seen.catalog).keys()) : null };
|
|
150
|
+
if (!fresh) observed = result;
|
|
151
|
+
return result;
|
|
146
152
|
};
|
|
147
153
|
const accept = (path: string): void => {
|
|
148
154
|
const seen = read(path);
|
|
@@ -154,18 +160,23 @@ export function startCodexCatalogSelfHeal(options: { port?: number; deps?: Catal
|
|
|
154
160
|
pendingRetry = null;
|
|
155
161
|
recheckAt = 0;
|
|
156
162
|
};
|
|
157
|
-
const updateTarget = (path: string | null):
|
|
163
|
+
const updateTarget = (path: string | null): boolean => {
|
|
158
164
|
// Unavailable selection is not evidence of a different target or lost authority.
|
|
159
|
-
if (path === null) return;
|
|
160
|
-
if (target !== null
|
|
165
|
+
if (path === null) return false;
|
|
166
|
+
if (target !== null) {
|
|
167
|
+
const relation = compareCatalogHealPaths(target, path);
|
|
168
|
+
if (relation === "unknown") return false;
|
|
169
|
+
if (relation === "same") return true;
|
|
170
|
+
}
|
|
161
171
|
clear();
|
|
162
172
|
target = path;
|
|
173
|
+
return true;
|
|
163
174
|
};
|
|
164
175
|
const beforeCommit = (path: string, entryGeneration: number): boolean => {
|
|
165
176
|
try {
|
|
166
177
|
const selected = catalogPath();
|
|
167
178
|
return !stopped && !released && generation === entryGeneration
|
|
168
|
-
&& selected !== null &&
|
|
179
|
+
&& selected !== null && compareCatalogHealPaths(selected, path) === "same" && evaluateCatalogSelfHealGates(gates).open;
|
|
169
180
|
} catch { return false; }
|
|
170
181
|
};
|
|
171
182
|
const capRetryAt = (now: number): number => {
|
|
@@ -182,8 +193,7 @@ export function startCodexCatalogSelfHeal(options: { port?: number; deps?: Catal
|
|
|
182
193
|
running = true;
|
|
183
194
|
try {
|
|
184
195
|
const path = catalogPath();
|
|
185
|
-
updateTarget(path);
|
|
186
|
-
if (path === null) return;
|
|
196
|
+
if (!updateTarget(path) || path === null) return;
|
|
187
197
|
// Pending cache/funnel failure is independent of catalog stat or apparent repaired rows.
|
|
188
198
|
if (pendingRetry) {
|
|
189
199
|
const config = gates.loadConfig();
|
|
@@ -226,7 +236,7 @@ export function startCodexCatalogSelfHeal(options: { port?: number; deps?: Catal
|
|
|
226
236
|
})).committed; }
|
|
227
237
|
catch { /* Failed attempts retain pending retry and consume the attempt budget. */ }
|
|
228
238
|
const selected = catalogPath();
|
|
229
|
-
if (stopped || released || generation !== entryGeneration || selected === null ||
|
|
239
|
+
if (stopped || released || generation !== entryGeneration || selected === null || compareCatalogHealPaths(selected, path) !== "same") return;
|
|
230
240
|
last = { at: new Date().toISOString(), lostNamespaces: lostEnabled.length, committed };
|
|
231
241
|
if (committed) {
|
|
232
242
|
heals.push(clock());
|
|
@@ -241,33 +251,43 @@ export function startCodexCatalogSelfHeal(options: { port?: number; deps?: Catal
|
|
|
241
251
|
|
|
242
252
|
const unsubscribe = (deps.subscribe ?? subscribeCatalogPublication)(event => {
|
|
243
253
|
if (stopped) return;
|
|
254
|
+
const release = event.kind === "native-released" || event.intent === "restore";
|
|
255
|
+
// Bind publication evidence before comparisons can observe a retargeted alias.
|
|
256
|
+
const stillPublished = !release && event.path !== null ? (deps.retainPath ?? retainCatalogHealPath)(event.path) : null;
|
|
244
257
|
// Native restoration can remove the journal before notification. Fence the known
|
|
245
258
|
// target (and target-less releases) without resolving possibly unavailable evidence.
|
|
246
|
-
const
|
|
247
|
-
if (release && (event.path === null ||
|
|
259
|
+
const known = event.path !== null && target !== null ? compareCatalogHealPaths(event.path, target) : "different";
|
|
260
|
+
if (release && (event.path === null || known !== "different")) {
|
|
248
261
|
clear();
|
|
249
262
|
released = true;
|
|
250
263
|
return;
|
|
251
264
|
}
|
|
252
265
|
const path = catalogPath();
|
|
253
|
-
|
|
254
|
-
|
|
266
|
+
const selected = event.path !== null && path !== null ? compareCatalogHealPaths(event.path, path) : "different";
|
|
267
|
+
if (event.path !== null && known === "different" && selected === "different") return;
|
|
255
268
|
if (release) {
|
|
256
269
|
clear();
|
|
257
270
|
released = true; // Only a later accepted owner publication can re-arm this lifecycle.
|
|
258
271
|
return;
|
|
259
272
|
}
|
|
260
|
-
if (running)
|
|
273
|
+
if (running) {
|
|
274
|
+
if (known === "unknown" || selected === "unknown") clear();
|
|
275
|
+
return; // Catalog-success/cache-failure must not accept a baseline.
|
|
276
|
+
}
|
|
261
277
|
// A committed owner publication supplies a read-only baseline even while heal writes are gated.
|
|
262
|
-
if (event.path === null || path === null ||
|
|
263
|
-
|
|
278
|
+
if (event.path === null || path === null || selected !== "same" || stillPublished === null) return;
|
|
279
|
+
// Read independently of obsolete evidence, but retire it only after current selection proof.
|
|
280
|
+
const seen = read(event.path, true);
|
|
281
|
+
const current = catalogPath();
|
|
282
|
+
if (seen?.namespaces == null || current === null
|
|
283
|
+
|| compareCatalogHealPaths(event.path, current) !== "same" || !stillPublished(seen.signature)) return;
|
|
284
|
+
clear();
|
|
285
|
+
target = current;
|
|
286
|
+
baseline = observed = seen;
|
|
264
287
|
released = false;
|
|
265
|
-
pendingRetry = null;
|
|
266
|
-
recheckAt = 0;
|
|
267
|
-
accept(event.path);
|
|
268
288
|
});
|
|
269
289
|
// Capture immediately after startup sync, before a foreign write can become the first tick.
|
|
270
|
-
try {
|
|
290
|
+
try { const path = catalogPath(); if (updateTarget(path) && target !== null) accept(target); }
|
|
271
291
|
catch { /* Unavailable observation can be retried by the scheduled tick. */ }
|
|
272
292
|
const schedule = (): void => {
|
|
273
293
|
if (stopped) return;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { extractAccountIdClaims, extractEmail } from "../oauth/chatgpt";
|
|
1
|
+
import { decodeJwtPayload, extractAccountIdClaims, extractEmail } from "../oauth/chatgpt";
|
|
2
2
|
import type { CodexAccount, OcxConfig } from "../types";
|
|
3
3
|
import { getCodexAccountCredential } from "./account-store";
|
|
4
4
|
import type { CodexTokens } from "./auth-collision";
|
|
5
5
|
import { captureMainAccountIdentityGeneration, isMainAccountIdentityGenerationLive } from "./main-account-cache";
|
|
6
6
|
import { codexPlanKey, extractChatgptPlanType } from "./plan";
|
|
7
|
+
import { nativeUserIdClaims } from "./reserve-availability";
|
|
7
8
|
|
|
8
9
|
export interface CodexCollisionIdentity {
|
|
9
10
|
accountId: string;
|
|
11
|
+
userId?: string;
|
|
10
12
|
email?: string | null;
|
|
11
13
|
plan?: unknown;
|
|
12
14
|
}
|
|
@@ -34,19 +36,42 @@ function homeScope(): string {
|
|
|
34
36
|
|
|
35
37
|
let observed: { identity: CodexCollisionIdentity; homeScope: string; generation: number } | undefined;
|
|
36
38
|
|
|
39
|
+
function suppressObservedUserId(): void {
|
|
40
|
+
if (!observed || observed.homeScope !== homeScope()
|
|
41
|
+
|| !isMainAccountIdentityGenerationLive(observed.generation)) return;
|
|
42
|
+
observed = { ...observed, identity: { ...observed.identity, userId: undefined } };
|
|
43
|
+
}
|
|
44
|
+
|
|
37
45
|
/** Only existing owned lifecycle observations may publish; never call with a request bearer. */
|
|
38
46
|
export function observeMainCodexCollisionIdentity(tokens?: CodexTokens): void {
|
|
39
47
|
if (!tokens) { observed = undefined; return; }
|
|
40
48
|
if (typeof tokens.access_token !== "string" || typeof tokens.account_id !== "string"
|
|
41
|
-
|| (tokens.id_token !== undefined && typeof tokens.id_token !== "string"))
|
|
49
|
+
|| (tokens.id_token !== undefined && typeof tokens.id_token !== "string")) {
|
|
50
|
+
suppressObservedUserId();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
42
53
|
const claims = [extractAccountIdClaims(tokens.id_token), extractAccountIdClaims(tokens.access_token)];
|
|
43
|
-
if (claims.some(claim => claim.conflict)) return;
|
|
54
|
+
if (claims.some(claim => claim.conflict)) { suppressObservedUserId(); return; }
|
|
44
55
|
const accountId = tokens.account_id || claims.find(claim => claim.accountId)?.accountId;
|
|
45
|
-
if (!accountId || claims.some(claim => claim.accountId && claim.accountId !== accountId))
|
|
56
|
+
if (!accountId || claims.some(claim => claim.accountId && claim.accountId !== accountId)) {
|
|
57
|
+
suppressObservedUserId();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
46
60
|
const emails = new Set([extractEmail(tokens.id_token), extractEmail(undefined, tokens.access_token)]
|
|
47
61
|
.flatMap(email => normalizedEmail(email) ? [normalizedEmail(email)!] : []));
|
|
48
|
-
if (emails.size > 1) return;
|
|
62
|
+
if (emails.size > 1) { suppressObservedUserId(); return; }
|
|
63
|
+
const idPayload: unknown = tokens.id_token === undefined ? undefined : decodeJwtPayload(tokens.id_token);
|
|
64
|
+
const idTokenMalformed = tokens.id_token !== undefined
|
|
65
|
+
&& (idPayload === null || typeof idPayload !== "object" || Array.isArray(idPayload));
|
|
66
|
+
const users = [tokens.id_token ? nativeUserIdClaims(tokens.id_token) : undefined, nativeUserIdClaims(tokens.access_token)];
|
|
67
|
+
const userIds = new Set(users.flatMap(user => user?.userId ? [user.userId] : []));
|
|
68
|
+
// A join key needs one token claiming both the account and the user, as a Pool access token does;
|
|
69
|
+
// auth.json account_id alone, or claims split across a mixed token set, prove no pairing.
|
|
70
|
+
const bound = claims.some((claim, index) => claim.accountId === accountId && users[index]?.userId);
|
|
71
|
+
const userId = !idTokenMalformed && !users.some(user => user?.conflict) && bound && userIds.size === 1
|
|
72
|
+
? [...userIds][0] : undefined;
|
|
49
73
|
observed = { identity: { accountId, email: [...emails][0],
|
|
74
|
+
...(userId ? { userId } : {}),
|
|
50
75
|
plan: extractChatgptPlanType(tokens.id_token, tokens.access_token) },
|
|
51
76
|
homeScope: homeScope(), generation: captureMainAccountIdentityGeneration() };
|
|
52
77
|
}
|
package/src/codex/convergence.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { projectAntigravitySelectedModels } from "../providers/antigravity-effort-families";
|
|
2
|
-
import { configuredUltraFastSlugs } from "./catalog/configured-tiers";
|
|
2
|
+
import { configuredUltraFastSlugs, retainedFlexPolicyBySlug } from "./catalog/configured-tiers";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { compareCatalogHealPaths } from "./catalog/heal-observation";
|
|
5
5
|
|
|
6
6
|
import { getConfigDir, saveConfigPreservingClaudeCode, ultraFastTierEnabled, websocketsEnabled, withExpectedConfigGenerationSync } from "../config";
|
|
7
7
|
import { reconcileSuccessfulModelDiscoveries } from "../providers/new-model-policy";
|
|
@@ -373,6 +373,7 @@ function prepareCatalog(
|
|
|
373
373
|
const mergedModels = mergeCatalogEntriesFromObservedState({
|
|
374
374
|
ultraFastTier: ultraFastTierEnabled(config),
|
|
375
375
|
configuredUltraFastSlugs: configuredUltraFastSlugs(ordered),
|
|
376
|
+
retainedFlexPolicyBySlug: retainedFlexPolicyBySlug(config.providers ?? {}, catalogModels, ordered),
|
|
376
377
|
modelPickerOrder,
|
|
377
378
|
accountSelectors,
|
|
378
379
|
catalogModels,
|
|
@@ -674,7 +675,7 @@ export async function commitCodexCatalogCandidate(
|
|
|
674
675
|
const guarded = withExpectedConfigGenerationSync(state.generation, () => {
|
|
675
676
|
const invalid = revalidateCandidate(state);
|
|
676
677
|
if (invalid) return invalid;
|
|
677
|
-
if (lifecycle.expectedCatalogPath !== undefined &&
|
|
678
|
+
if (lifecycle.expectedCatalogPath !== undefined && compareCatalogHealPaths(state.catalog.path, lifecycle.expectedCatalogPath) !== "same") {
|
|
678
679
|
return { kind: "stale", reason: "target-identity" } as const;
|
|
679
680
|
}
|
|
680
681
|
if (lifecycle.beforeCommit && lifecycle.beforeCommit() !== true) return { kind: "stale", reason: "process-local" } as const;
|