@bitkyc08/opencodex 2.99.0 → 2.100.1
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/AGENTS_INSTALL.md +19 -1
- package/README.md +37 -33
- package/SPONSORS.md +5 -1
- package/bin/ocx.mjs +1 -1
- package/gui/dist/assets/{App-C1hGwaN1.css → App-COo8Yopd.css} +1 -1
- package/gui/dist/assets/App-g3Cm2xhZ.js +59 -0
- package/gui/dist/assets/Tray-BMDkAiXy.js +1 -0
- package/gui/dist/assets/brand-mark-nr3ziR-T.js +1 -0
- package/gui/dist/assets/index-Bziu8gTy.css +2 -0
- package/gui/dist/assets/index-OYzhQUNP.js +94 -0
- package/gui/dist/assets/{segment-thumb-features-fYEMxBaW.js → segment-thumb-features-DKCVUUTi.js} +1 -1
- package/gui/dist/classic/assets/App-CgPBKUP-.js +58 -0
- package/gui/dist/classic/assets/{Tray-BqZueZOx.js → Tray-BedmOsE7.js} +1 -1
- package/gui/dist/classic/assets/index-BR-HhNrp.js +94 -0
- package/gui/dist/classic/assets/quota-summary-CXKhvSmQ.js +1 -0
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/native/ocx-child/Cargo.lock +215 -0
- package/native/ocx-child/Cargo.toml +31 -0
- package/native/ocx-child/src/cli.rs +1901 -0
- package/native/ocx-child/src/codex_home.rs +429 -0
- package/native/ocx-child/src/codex_settings.rs +231 -0
- package/native/ocx-child/src/daemon.rs +363 -0
- package/native/ocx-child/src/http_wire.rs +619 -0
- package/native/ocx-child/src/journal.rs +977 -0
- package/native/ocx-child/src/lib.rs +22 -0
- package/native/ocx-child/src/main.rs +9 -0
- package/native/ocx-child/src/parity.rs +102 -0
- package/native/ocx-child/src/platform.rs +1487 -0
- package/native/ocx-child/src/relay.rs +1288 -0
- package/native/ocx-child/src/relay_auth.rs +166 -0
- package/native/ocx-child/src/routes.rs +236 -0
- package/native/ocx-child/src/state.rs +190 -0
- package/native/ocx-child/src/test_hooks.rs +58 -0
- package/native/ocx-child/src/toml_surgeon.rs +1156 -0
- package/package.json +8 -2
- package/src/adapters/anthropic-image-normalize.ts +1 -1
- package/src/adapters/anthropic.ts +28 -2
- package/src/adapters/claude-cli/adapter.ts +5 -25
- package/src/adapters/claude-cli/instruction-images.ts +31 -0
- package/src/adapters/claude-cli/stable-replay.ts +42 -14
- package/src/adapters/claude-cli/usage-admission.ts +53 -64
- package/src/adapters/client-fingerprint.ts +1 -1
- package/src/adapters/coding-agent/protocol.ts +1 -1
- package/src/adapters/devin/live-models.ts +3 -0
- package/src/adapters/google-http.ts +3 -0
- package/src/adapters/google-vertex-key-project.ts +10 -2
- package/src/adapters/google.ts +40 -8
- package/src/adapters/kiro/usage.ts +3 -13
- package/src/adapters/openai-chat/mistral-image-limit.ts +28 -15
- package/src/adapters/openai-chat-images.ts +100 -0
- package/src/adapters/openai-chat.ts +6 -9
- package/src/adapters/openai-responses/passthrough.ts +5 -2
- package/src/adapters/openai-responses/request-strips.ts +32 -0
- package/src/adapters/openai-responses/tool-schema.ts +9 -4
- package/src/chat/inbound.ts +1 -1
- package/src/claude/auth-detect.ts +26 -8
- package/src/claude/inbound-content-options.ts +18 -3
- package/src/claude/inbound.ts +5 -2
- package/src/cli/bundled-bun-diagnostic.ts +91 -0
- package/src/cli/capabilities-agents-routing.ts +2 -2
- package/src/cli/capabilities-observe-system.ts +60 -0
- package/src/cli/combo-input.ts +6 -0
- package/src/cli/combo-result.ts +1 -1
- package/src/cli/combo.ts +4 -0
- package/src/cli/config-command.ts +16 -2
- package/src/cli/connect.ts +12 -10
- package/src/cli/dispatch.ts +4 -0
- package/src/cli/doctor.ts +11 -0
- package/src/cli/help.ts +1 -0
- package/src/cli/init.ts +4 -0
- package/src/cli/link-enrollment.ts +152 -25
- package/src/cli/link-local-control.ts +49 -0
- package/src/cli/link.ts +37 -10
- package/src/cli/provider-lifecycle-runtime.ts +4 -2
- package/src/cli/registry.ts +13 -0
- package/src/cli/star-prompt.ts +2 -0
- package/src/cli/status.ts +1 -1
- package/src/cli/telemetry-profile.ts +206 -0
- package/src/cli/telemetry.ts +260 -0
- package/src/client/hub-relay.ts +26 -0
- package/src/client/machine-api.ts +3 -0
- package/src/clients/config-export/t3code.ts +44 -5
- package/src/clients/omo-role-models.ts +1 -1
- package/src/codex/catalog/bundled.ts +44 -2
- package/src/codex/runtime.ts +12 -0
- package/src/codex/shim-restore-lock.ts +67 -30
- package/src/combos/types.ts +21 -1
- package/src/config/atomic-write.ts +24 -1
- package/src/config/diagnostics.ts +15 -0
- package/src/config/live-reconcile.ts +17 -0
- package/src/config/load-degrade.ts +16 -0
- package/src/config/provider-validation.ts +29 -0
- package/src/config/schema/config-schema.ts +24 -0
- package/src/config/schema/leaf-validators.ts +17 -0
- package/src/config/telemetry-carry.ts +30 -0
- package/src/config.ts +13 -1
- package/src/generated/compatibility-version.json +422 -170
- package/src/generated/model-metadata.ts +3 -3
- package/src/integrations/aside-profiles.ts +7 -1
- package/src/integrations/owned-refresh.ts +9 -2
- package/src/lab/artifacts/secure-fs.ts +12 -11
- package/src/lab/fabric/scratch.ts +11 -9
- package/src/lab/public/community.ts +2 -3
- package/src/lab/public/file-safety.ts +18 -20
- package/src/lab/public/mutation-lock.ts +109 -337
- package/src/lab/public/private-file.ts +4 -3
- package/src/lib/bun-runtime-preflight.ts +1 -1
- package/src/lib/codex-catalog-read-only.ts +122 -0
- package/src/lib/config-ownership.ts +56 -18
- package/src/lib/errors.ts +11 -0
- package/src/lib/gcp-adc.ts +167 -48
- package/src/lib/jsonc.ts +4 -2
- package/src/lib/local-control-socket.ts +88 -0
- package/src/lib/privacy.ts +15 -0
- package/src/lib/provider-client-headers.ts +3 -0
- package/src/lib/token-estimate.ts +13 -2
- package/src/link/child-binary-source.ts +228 -0
- package/src/link/ephemeral-child.ts +45 -0
- package/src/link/remote-plant.ts +306 -0
- package/src/link/remote-windows.ts +59 -5
- package/src/link/ssh-argv.ts +71 -8
- package/src/link/status-projection.ts +2 -0
- package/src/link/store.ts +5 -1
- package/src/oauth/anthropic-model-quota.ts +12 -0
- package/src/oauth/anthropic-routing.ts +11 -4
- package/src/oauth/claude-keychain-read.ts +165 -0
- package/src/oauth/kiro-iam-identity-center.ts +4 -1
- package/src/oauth/local-token-detect.ts +14 -17
- package/src/protocols/envelope.ts +20 -2
- package/src/providers/api-key-selection.ts +8 -2
- package/src/providers/claude-cli-identity.ts +9 -3
- package/src/providers/claude-cli-usage-state.ts +93 -0
- package/src/providers/claude-cli-usage.ts +3 -2
- package/src/providers/github-copilot-auto.ts +25 -5
- package/src/providers/meta-muse-plan-refusal.ts +94 -0
- package/src/providers/model-rename-fields.ts +3 -0
- package/src/providers/quota/anthropic-family-headers.ts +8 -1
- package/src/providers/quota/anthropic-usage-windows.ts +49 -2
- package/src/providers/quota/vendor-probes-key.ts +23 -4
- package/src/providers/quota/vendor-probes-oauth.ts +59 -0
- package/src/providers/quota/workbuddy.ts +2 -2
- package/src/providers/quota-types.ts +7 -0
- package/src/providers/quota.ts +25 -18
- package/src/providers/registry/entries-core.ts +7 -4
- package/src/providers/registry/entries-extended.ts +42 -8
- package/src/providers/registry/model-ids.ts +1 -0
- package/src/providers/registry/model-seeds.ts +10 -2
- package/src/providers/registry/types.ts +6 -0
- package/src/providers/resolved-model-policy.ts +4 -0
- package/src/providers/routed-config.ts +30 -3
- package/src/providers/stale-no-vision-seed-migration.ts +7 -0
- package/src/providers/vertex-environment-authority.ts +50 -0
- package/src/providers/workbuddy-credit-balance.ts +38 -6
- package/src/quota-pool/assemble.ts +14 -6
- package/src/responses/retained-compaction.ts +31 -5
- package/src/router.ts +1 -0
- package/src/server/adapter-resolve.ts +11 -6
- package/src/server/audio-dictation.ts +21 -7
- package/src/server/auth-cors.ts +19 -0
- package/src/server/background-lifecycle.ts +71 -0
- package/src/server/chat-completions.ts +2 -0
- package/src/server/claude-messages.ts +30 -3
- package/src/server/index/live-sideband.ts +15 -1
- package/src/server/index/local-control-listener.ts +515 -0
- package/src/server/index/optional-listeners.ts +21 -1
- package/src/server/index/serve-options.ts +4 -3
- package/src/server/index/websocket-handler.ts +2 -0
- package/src/server/index.ts +3 -0
- package/src/server/management/combo-routes.ts +6 -1
- package/src/server/management/context.ts +1 -0
- package/src/server/management/link-child-preflight.ts +74 -0
- package/src/server/management/link-enrollment.ts +190 -25
- package/src/server/management/link-route-state.ts +6 -1
- package/src/server/management/link-routes.ts +27 -9
- package/src/server/management/model-rows.ts +4 -0
- package/src/server/management/oauth-account-routes.ts +9 -4
- package/src/server/management/provider-overwrite-carry.ts +9 -2
- package/src/server/management/provider-routes.ts +14 -0
- package/src/server/management/provider-thinking-display-patch.ts +54 -0
- package/src/server/management/route-registry.ts +7 -0
- package/src/server/management/session-routes.ts +4 -1
- package/src/server/management/telemetry-routes.ts +37 -0
- package/src/server/management/usage-aggregate-cache.ts +290 -67
- package/src/server/management-api.ts +11 -2
- package/src/server/messages-native-preflight.ts +166 -0
- package/src/server/messages-native.ts +143 -43
- package/src/server/messages-shared.ts +14 -0
- package/src/server/proxy-liveness.ts +99 -6
- package/src/server/request-log-conversation.ts +18 -2
- package/src/server/request-log.ts +7 -2
- package/src/server/responses/adapter-continuation.ts +1 -0
- package/src/server/responses/adapter-dispatch.ts +11 -28
- package/src/server/responses/adapter-failure-message.ts +68 -0
- package/src/server/responses/combo-stream-preflight.ts +14 -2
- package/src/server/responses/compact.ts +13 -1
- package/src/server/responses/core-auth.ts +26 -5
- package/src/server/responses/core-codex-account.ts +8 -1
- package/src/server/responses/core-combo-failure.ts +6 -1
- package/src/server/responses/core-combo-native.ts +150 -37
- package/src/server/responses/core-combo.ts +15 -9
- package/src/server/responses/core-normalize.ts +1 -0
- package/src/server/responses/core-options.ts +7 -1
- package/src/server/responses/core-pipeline.ts +21 -1
- package/src/server/responses/fetch-helpers.ts +5 -0
- package/src/server/responses/opengateway-completion-guard.ts +7 -3
- package/src/server/responses/passthrough-delivery.ts +8 -1
- package/src/server/responses/passthrough-error.ts +22 -0
- package/src/server/responses/request-prepare.ts +7 -1
- package/src/server/responses/request-transport.ts +28 -5
- package/src/server/responses/run-turn-execution.ts +13 -0
- package/src/server/sse-frame-buffer.ts +5 -0
- package/src/server/ws-bridge.ts +10 -0
- package/src/service/launchd.ts +78 -4
- package/src/telemetry/aggregate.ts +348 -0
- package/src/telemetry/consent.ts +128 -0
- package/src/telemetry/contract.ts +403 -0
- package/src/telemetry/disclosure.ts +19 -0
- package/src/telemetry/install-id.ts +226 -0
- package/src/telemetry/payload.ts +129 -0
- package/src/telemetry/profile/client.ts +150 -0
- package/src/telemetry/profile/contract.ts +288 -0
- package/src/telemetry/profile/disclosure.ts +14 -0
- package/src/telemetry/profile/paths.ts +13 -0
- package/src/telemetry/profile/routes.ts +99 -0
- package/src/telemetry/profile/service.ts +234 -0
- package/src/telemetry/profile/state.ts +189 -0
- package/src/telemetry/profile/sync.ts +276 -0
- package/src/telemetry/routes.ts +183 -0
- package/src/telemetry/scheduler.ts +386 -0
- package/src/telemetry/sender.ts +97 -0
- package/src/telemetry/state.ts +334 -0
- package/src/types/combo-jev-effort-mode.ts +11 -0
- package/src/types/config.ts +3 -0
- package/src/types/provider.ts +11 -1
- package/src/types/request.ts +2 -0
- package/src/types/telemetry.ts +15 -0
- package/src/types/wire.ts +10 -0
- package/src/types.ts +5 -0
- package/src/update/index.ts +7 -1
- package/src/update/minisign.d.mts +17 -0
- package/src/update/minisign.mjs +88 -0
- package/src/update/signed-supply.d.mts +59 -0
- package/src/update/signed-supply.mjs +289 -0
- package/src/update/trust-root.json +38 -0
- package/src/update/update-bounded-json.d.mts +4 -0
- package/src/update/update-bounded-json.mjs +113 -0
- package/src/update/update-bytes.d.mts +2 -0
- package/src/update/update-bytes.mjs +23 -0
- package/src/update/update-candidate-id.d.mts +2 -0
- package/src/update/update-candidate-id.mjs +23 -0
- package/src/update/update-checkpoint-codec.d.mts +33 -0
- package/src/update/update-checkpoint-codec.mjs +217 -0
- package/src/update/update-contracts.d.mts +24 -0
- package/src/update/update-contracts.mjs +207 -0
- package/src/update/update-signature-threshold.d.mts +12 -0
- package/src/update/update-signature-threshold.mjs +47 -0
- package/src/update/update-signed-version.d.mts +5 -0
- package/src/update/update-signed-version.mjs +25 -0
- package/src/update/update-trust-anchor.d.mts +2 -0
- package/src/update/update-trust-anchor.mjs +2 -0
- package/src/usage/cache-diagnostic.ts +195 -50
- package/src/usage/expected-prices.ts +20 -2
- package/src/usage/filter-index.ts +1469 -0
- package/src/usage/ledger-scanner.ts +245 -4
- package/src/usage/source-filter.ts +10 -2
- package/src/usage/summary.ts +16 -0
- package/src/web-search/parse.ts +265 -38
- package/gui/dist/assets/App-BepstgEN.js +0 -59
- package/gui/dist/assets/Tray-BinxbEZo.js +0 -1
- package/gui/dist/assets/brand-mark-wzPe3R-J.js +0 -1
- package/gui/dist/assets/index-C-9X2yaI.js +0 -94
- package/gui/dist/assets/index-bnUWypyz.css +0 -2
- package/gui/dist/classic/assets/App-DX88_GCW.js +0 -58
- package/gui/dist/classic/assets/index-fSP71pLB.js +0 -94
- package/gui/dist/classic/assets/quota-summary-y2fl0WBv.js +0 -1
|
@@ -38,6 +38,7 @@ import { retainedNativeInheritanceTemplate } from "./native-template";
|
|
|
38
38
|
import type { RawCatalog, RawEntry } from "./parsing";
|
|
39
39
|
import { isSpawnableCodexCandidate } from "../exec-invocation";
|
|
40
40
|
import { validatedCodexExecInvocation, validatedCodexExecInvocationAsync } from "../exec-boundary";
|
|
41
|
+
import { macCodexAppCommands } from "../mac-app-bundle";
|
|
41
42
|
import { isPlainObject } from "../../lib/plain-data";
|
|
42
43
|
import {
|
|
43
44
|
parsePersistedCodexRuntime,
|
|
@@ -47,10 +48,12 @@ import {
|
|
|
47
48
|
codexRuntimeSelectionIdentity,
|
|
48
49
|
codexRuntimeStateEpoch,
|
|
49
50
|
execCodexFileAsync,
|
|
51
|
+
codexRuntimeIsUnresolved,
|
|
50
52
|
} from "../runtime";
|
|
51
53
|
import type {
|
|
52
54
|
DeepReadonly,
|
|
53
55
|
EffortClampDiagnostic,
|
|
56
|
+
ResolveCodexRuntimeResult,
|
|
54
57
|
ResolvedCodexRuntime,
|
|
55
58
|
} from "../runtime";
|
|
56
59
|
import type {
|
|
@@ -188,6 +191,12 @@ export interface BundledCatalogDeps {
|
|
|
188
191
|
/** Already-observed source for server clamping; null never triggers a probe. */
|
|
189
192
|
observedCatalog?: ReadonlyRawCatalog | null;
|
|
190
193
|
commandCandidates?: () => string[];
|
|
194
|
+
/**
|
|
195
|
+
* The resolver selection `commandCandidates` came from, when the caller resolved first. Only an
|
|
196
|
+
* unresolved selection lets the macOS probe add the ChatGPT.app CLI (#8360); without it, injected
|
|
197
|
+
* candidates are probed as given.
|
|
198
|
+
*/
|
|
199
|
+
selectedRuntime?: Pick<ResolvedCodexRuntime, "source" | "version">;
|
|
191
200
|
execFileSync?: ExecFile;
|
|
192
201
|
execFile?: (...args: Parameters<ExecFile>) => Promise<string>;
|
|
193
202
|
onEffortClamp?: (diagnostic: EffortClampDiagnostic) => void;
|
|
@@ -332,6 +341,39 @@ function bundledRuntimeDeps(deps: BundledCatalogDeps) {
|
|
|
332
341
|
};
|
|
333
342
|
}
|
|
334
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Candidates for the bundled-catalog probe.
|
|
346
|
+
*
|
|
347
|
+
* When discovery finds no Codex CLI it answers with the bare `codex` sentinel, so the probe
|
|
348
|
+
* asks a command that does not exist while a real CLI sits inside ChatGPT.app. Discovery only
|
|
349
|
+
* offers that app candidate after classifying the bundle's XML `Info.plist` identity, so a
|
|
350
|
+
* bundle it cannot classify (a binary plist, or an identity assertion that moved with an app
|
|
351
|
+
* update) left `ocx connect status` reporting `unverified` on a macOS Child whose only Codex
|
|
352
|
+
* was the bundled CLI (#8360).
|
|
353
|
+
*
|
|
354
|
+
* The known app locations are therefore added after a bare sentinel. This list grants no
|
|
355
|
+
* trust: every execution still passes the app-bundle signature and ownership gate in
|
|
356
|
+
* `exec-boundary.ts`, so an unverifiable bundle yields `null` rather than an invented ladder.
|
|
357
|
+
* Windows needs no entry here because its Codex App install root under LOCALAPPDATA is already
|
|
358
|
+
* enumerated by `installedCodexCandidates` in `runtime.ts`.
|
|
359
|
+
*/
|
|
360
|
+
function bundledCatalogCandidates(
|
|
361
|
+
deps: BundledCatalogDeps,
|
|
362
|
+
resolved: ResolveCodexRuntimeResult | null,
|
|
363
|
+
): string[] {
|
|
364
|
+
const candidates = deps.commandCandidates?.() ?? [resolved!.runtime.command];
|
|
365
|
+
// An explicit empty list asks for no probe at all.
|
|
366
|
+
if (candidates.length === 0) return candidates;
|
|
367
|
+
if ((deps.platform ?? process.platform) !== "darwin") return candidates;
|
|
368
|
+
// Decide from the resolver's own result, not from the command's shape: a bare command that ran
|
|
369
|
+
// (a PATH fallback or a bare CODEX_CLI_PATH) is the operator's runtime, and borrowing the app's
|
|
370
|
+
// catalog for it would report a ladder that runtime may reject.
|
|
371
|
+
const selection = resolved?.runtime ?? deps.selectedRuntime;
|
|
372
|
+
if (!selection || !codexRuntimeIsUnresolved(selection)) return candidates;
|
|
373
|
+
const exists = deps.existsSync ?? existsSync;
|
|
374
|
+
return [...candidates, ...macCodexAppCommands(deps).filter(command => exists(command))];
|
|
375
|
+
}
|
|
376
|
+
|
|
335
377
|
function* bundledCatalogSteps(
|
|
336
378
|
candidates: string[],
|
|
337
379
|
cacheKey: string | null,
|
|
@@ -390,7 +432,7 @@ export function loadBundledCodexCatalog(deps: BundledCatalogDeps = {}): Readonly
|
|
|
390
432
|
const useCache = !deps.commandCandidates && !deps.execFileSync && !deps.execFile && !deps.configDir && !deps.env;
|
|
391
433
|
const resolved = deps.commandCandidates ? null : resolveAndPersistCodexRuntime(bundledRuntimeDeps(deps));
|
|
392
434
|
const inputs = codexRuntimeSelectionIdentity(bundledRuntimeDeps(deps));
|
|
393
|
-
const steps = bundledCatalogSteps(deps
|
|
435
|
+
const steps = bundledCatalogSteps(bundledCatalogCandidates(deps, resolved),
|
|
394
436
|
useCache ? bundledRuntimeKey(resolved!.runtime) : null,
|
|
395
437
|
() => inputs === codexRuntimeSelectionIdentity(bundledRuntimeDeps(deps)));
|
|
396
438
|
let step = steps.next();
|
|
@@ -449,7 +491,7 @@ export function loadBundledCodexCatalogAsync(
|
|
|
449
491
|
const runtimeEpoch = codexRuntimeStateEpoch();
|
|
450
492
|
const current = () => active() && runtimeEpoch === codexRuntimeStateEpoch()
|
|
451
493
|
&& flight.inputs === codexRuntimeSelectionIdentity(runtimeDeps);
|
|
452
|
-
const steps = bundledCatalogSteps(deps
|
|
494
|
+
const steps = bundledCatalogSteps(bundledCatalogCandidates(deps, resolved),
|
|
453
495
|
useCache ? bundledRuntimeKey(resolved!.runtime) : null, current, false);
|
|
454
496
|
let step = steps.next();
|
|
455
497
|
while (!step.done) {
|
package/src/codex/runtime.ts
CHANGED
|
@@ -55,6 +55,18 @@ export interface EffortClampDiagnostic {
|
|
|
55
55
|
readonly affectedModels: readonly string[];
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* True for the selection the resolver returns when no candidate ran: the bare `codex` fallback
|
|
60
|
+
* with no version. A probed candidate always carries the version it parsed, so a bare command
|
|
61
|
+
* that actually ran (a bare CODEX_CLI_PATH or shim, or the bare fallback itself) is not this
|
|
62
|
+
* sentinel. Deferred resolution (`probeVersion: false`) gives every candidate a null version and
|
|
63
|
+
* so cannot be told apart here; the bundled-catalog probe, `ocx connect` and `ocx status` all
|
|
64
|
+
* resolve with probing.
|
|
65
|
+
*/
|
|
66
|
+
export function codexRuntimeIsUnresolved(runtime: Pick<ResolvedCodexRuntime, "source" | "version">): boolean {
|
|
67
|
+
return runtime.source === "fallback" && runtime.version === null;
|
|
68
|
+
}
|
|
69
|
+
|
|
58
70
|
export interface ResolveCodexRuntimeResult {
|
|
59
71
|
readonly runtime: ResolvedCodexRuntime;
|
|
60
72
|
readonly failures: readonly RuntimeProbeFailure[];
|
|
@@ -32,70 +32,107 @@ interface ShimRestoreLockRecord {
|
|
|
32
32
|
createdAt: number;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
interface
|
|
35
|
+
interface ShimRestoreLockOwner {
|
|
36
36
|
record: ShimRestoreLockRecord;
|
|
37
37
|
ownerPath: string;
|
|
38
|
-
lockIdentity: FileIdentity;
|
|
39
38
|
fingerprint: ShimPathFingerprint;
|
|
40
39
|
}
|
|
41
40
|
|
|
41
|
+
interface ShimRestoreLockSnapshot {
|
|
42
|
+
lockIdentity: FileIdentity;
|
|
43
|
+
/** Sorted by owner filename so two snapshots compare entry by entry. */
|
|
44
|
+
owners: ShimRestoreLockOwner[];
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
function restoreLockPath(): string {
|
|
43
48
|
return join(getConfigDir(), "codex-shim.autorestore.lock");
|
|
44
49
|
}
|
|
45
50
|
|
|
51
|
+
function readShimRestoreLockOwner(path: string, entry: string): ShimRestoreLockOwner | null {
|
|
52
|
+
if (!entry.endsWith(".json")) return null;
|
|
53
|
+
const ownerPath = join(path, entry);
|
|
54
|
+
const probe = stableShimPathProbe(ownerPath);
|
|
55
|
+
if (!probe || probe.fingerprint.kind !== "file" || probe.fingerprint.size > 4096) return null;
|
|
56
|
+
try {
|
|
57
|
+
const value = JSON.parse(probe.prefix) as Partial<ShimRestoreLockRecord>;
|
|
58
|
+
if (value.version !== 1 || typeof value.token !== "string" || value.token.length === 0
|
|
59
|
+
|| typeof value.pid !== "number" || !Number.isSafeInteger(value.pid) || value.pid <= 0
|
|
60
|
+
|| typeof value.createdAt !== "number" || !Number.isFinite(value.createdAt)) return null;
|
|
61
|
+
if (entry !== `${value.token}.json`) return null;
|
|
62
|
+
return { record: value as ShimRestoreLockRecord, ownerPath, fingerprint: probe.fingerprint };
|
|
63
|
+
} catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Every entry must be a valid token-named owner record; one unaccounted entry (foreign file,
|
|
70
|
+
* unparsable or empty record, mismatched name) makes the whole lock unreadable. A normal lock
|
|
71
|
+
* holds one owner. Two or more are not produced by the current acquire path, but have been
|
|
72
|
+
* observed in the field (#8317) and must stay recoverable rather than block repair forever.
|
|
73
|
+
*/
|
|
46
74
|
function readShimRestoreLockSnapshot(path: string): ShimRestoreLockSnapshot | null {
|
|
47
75
|
let lockIdentity: BigIntStats;
|
|
48
76
|
let entries: string[];
|
|
49
77
|
try {
|
|
50
78
|
lockIdentity = lstatSync(path, { bigint: true });
|
|
51
79
|
if (!lockIdentity.isDirectory()) return null;
|
|
52
|
-
entries = readdirSync(path);
|
|
80
|
+
entries = readdirSync(path).sort();
|
|
53
81
|
} catch {
|
|
54
82
|
return null;
|
|
55
83
|
}
|
|
56
|
-
if (entries.length
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
84
|
+
if (entries.length === 0) return null;
|
|
85
|
+
const owners: ShimRestoreLockOwner[] = [];
|
|
86
|
+
for (const entry of entries) {
|
|
87
|
+
const owner = readShimRestoreLockOwner(path, entry);
|
|
88
|
+
if (!owner) return null;
|
|
89
|
+
owners.push(owner);
|
|
90
|
+
}
|
|
60
91
|
try {
|
|
61
|
-
const value = JSON.parse(probe.prefix) as Partial<ShimRestoreLockRecord>;
|
|
62
|
-
if (value.version !== 1 || typeof value.token !== "string" || value.token.length === 0
|
|
63
|
-
|| typeof value.pid !== "number" || !Number.isSafeInteger(value.pid) || value.pid <= 0
|
|
64
|
-
|| typeof value.createdAt !== "number" || !Number.isFinite(value.createdAt)) return null;
|
|
65
|
-
if (entries[0] !== `${value.token}.json`) return null;
|
|
66
92
|
const currentLockIdentity = lstatSync(path, { bigint: true });
|
|
67
93
|
if (!currentLockIdentity.isDirectory() || !sameFileIdentity(lockIdentity, currentLockIdentity)) return null;
|
|
68
|
-
return {
|
|
69
|
-
record: value as ShimRestoreLockRecord,
|
|
70
|
-
ownerPath,
|
|
71
|
-
lockIdentity,
|
|
72
|
-
fingerprint: probe.fingerprint,
|
|
73
|
-
};
|
|
74
94
|
} catch {
|
|
75
95
|
return null;
|
|
76
96
|
}
|
|
97
|
+
return { lockIdentity, owners };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Release only ever removes a lock it solely owns; an ambiguous set is left to stale recovery. */
|
|
101
|
+
function soleShimRestoreLockOwner(path: string): ShimRestoreLockOwner | null {
|
|
102
|
+
const snapshot = readShimRestoreLockSnapshot(path);
|
|
103
|
+
return snapshot?.owners.length === 1 ? snapshot.owners[0] : null;
|
|
77
104
|
}
|
|
78
105
|
|
|
79
106
|
function sameShimRestoreLock(left: ShimRestoreLockSnapshot, right: ShimRestoreLockSnapshot): boolean {
|
|
80
|
-
return left.
|
|
81
|
-
&&
|
|
82
|
-
&&
|
|
107
|
+
return sameFileIdentity(left.lockIdentity, right.lockIdentity)
|
|
108
|
+
&& left.owners.length === right.owners.length
|
|
109
|
+
&& left.owners.every((owner, index) => owner.record.token === right.owners[index].record.token
|
|
110
|
+
&& sameFingerprint(owner.fingerprint, right.owners[index].fingerprint));
|
|
83
111
|
}
|
|
84
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Reclaim requires every owner record to be past the stale window and to name a dead PID.
|
|
115
|
+
* Any live, fresh or unaccounted entry keeps the lock: age alone never evicts a live holder,
|
|
116
|
+
* and an entry this code cannot attribute might belong to an owner it cannot judge.
|
|
117
|
+
*/
|
|
85
118
|
function reclaimStaleRestoreLock(path: string, beforeDelete?: () => void): boolean {
|
|
86
119
|
const observed = readShimRestoreLockSnapshot(path);
|
|
87
120
|
if (!observed) return false;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
121
|
+
const now = Date.now();
|
|
122
|
+
for (const owner of observed.owners) {
|
|
123
|
+
const createdAt = Math.max(owner.record.createdAt, owner.fingerprint.mtimeMs);
|
|
124
|
+
if (now - createdAt <= CODEX_SHIM_RESTORE_LOCK_STALE_MS) return false;
|
|
125
|
+
if (isProcessAlive(owner.record.pid)) return false;
|
|
126
|
+
}
|
|
91
127
|
const current = readShimRestoreLockSnapshot(path);
|
|
92
128
|
if (!current || !sameShimRestoreLock(observed, current)) return false;
|
|
93
129
|
beforeDelete?.();
|
|
94
130
|
try {
|
|
95
|
-
// The token is part of
|
|
96
|
-
// replaced after the comparison,
|
|
97
|
-
// differently named owner record.
|
|
98
|
-
|
|
131
|
+
// The token is part of each owner filename. Even if the lock directory is
|
|
132
|
+
// replaced after the comparison, these unlinks cannot target a successor's
|
|
133
|
+
// differently named owner record. A failure part-way leaves a smaller set
|
|
134
|
+
// of the same dead owners, which the next attempt reclaims.
|
|
135
|
+
for (const owner of observed.owners) unlinkSync(owner.ownerPath);
|
|
99
136
|
rmdirSync(path);
|
|
100
137
|
return true;
|
|
101
138
|
} catch {
|
|
@@ -132,7 +169,7 @@ function tryAcquireShimRestoreLock(beforeStaleDelete?: () => void): ShimRestoreL
|
|
|
132
169
|
released = true;
|
|
133
170
|
try { closeSync(fd!); } catch { /* stale recovery handles an uncertain lock */ }
|
|
134
171
|
try {
|
|
135
|
-
const current =
|
|
172
|
+
const current = soleShimRestoreLockOwner(path);
|
|
136
173
|
if (identity && current && current.record.token === record.token
|
|
137
174
|
&& sameFileIdentity(identity, current.fingerprint.identity)) {
|
|
138
175
|
unlinkSync(ownerPath);
|
|
@@ -145,7 +182,7 @@ function tryAcquireShimRestoreLock(beforeStaleDelete?: () => void): ShimRestoreL
|
|
|
145
182
|
if (fd !== null) {
|
|
146
183
|
try { closeSync(fd); } catch { /* best-effort close before ownership cleanup */ }
|
|
147
184
|
try {
|
|
148
|
-
const current =
|
|
185
|
+
const current = soleShimRestoreLockOwner(path);
|
|
149
186
|
if (identity && current && current.record.token === record.token
|
|
150
187
|
&& sameFileIdentity(identity, current.fingerprint.identity)) {
|
|
151
188
|
unlinkSync(ownerPath);
|
package/src/combos/types.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./jev-session-pin-config";
|
|
8
8
|
import { isCodexReasoningEffort, isDeclaredReasoningEffort } from "../reasoning-effort";
|
|
9
9
|
import { SUPPORTED_NATIVE_OPENAI_SLUGS } from "../codex/catalog/native-models";
|
|
10
|
-
import type { OcxComboConfig, OcxComboCooldownWaitPolicy, OcxComboDefaultEffort, OcxComboDefaultEffortMode, OcxComboReasoningEffortMode, OcxComboStrategy, OcxComboTarget, OcxProviderConfig } from "../types";
|
|
10
|
+
import type { OcxComboConfig, OcxComboCooldownWaitPolicy, OcxComboDefaultEffort, OcxComboDefaultEffortMode, OcxComboJevEffortMode, OcxComboReasoningEffortMode, OcxComboStrategy, OcxComboTarget, OcxProviderConfig } from "../types";
|
|
11
11
|
import { COMBO_NAMESPACE, isValidComboId, resolveComboId, targetKey } from "./identifiers";
|
|
12
12
|
import {
|
|
13
13
|
CANONICAL_JEV_DECISION_PROVIDER,
|
|
@@ -69,6 +69,15 @@ export interface NormalizedComboConfig {
|
|
|
69
69
|
defaultEffortMode: OcxComboDefaultEffortMode;
|
|
70
70
|
/** Picker-ladder derivation policy; `strict` preserves the legacy intersection rule. */
|
|
71
71
|
reasoningEffortMode: OcxComboReasoningEffortMode;
|
|
72
|
+
/**
|
|
73
|
+
* Who owns the wire effort on a JEV combo.
|
|
74
|
+
*
|
|
75
|
+
* `decide` (default) applies the decision's effort and lets it override the caller.
|
|
76
|
+
* `client` keeps the decision's target choice but leaves effort to the caller and the
|
|
77
|
+
* target ladder, so a provider that must hold one tier to keep its prompt cache warm
|
|
78
|
+
* (for example one whose effort swaps the upstream model id) is never re-tiered.
|
|
79
|
+
*/
|
|
80
|
+
jevEffortMode: OcxComboJevEffortMode;
|
|
72
81
|
/** Disable image input; `auto` preserves the intersection derived from all targets. */
|
|
73
82
|
imageInput: "auto" | "disabled";
|
|
74
83
|
/** Trimmed public alias, or null when the combo keeps the default `combo/<id>` slug. */
|
|
@@ -272,6 +281,16 @@ export function comboConfigIssues(
|
|
|
272
281
|
message: "defaultEffort is required when defaultEffortMode is force",
|
|
273
282
|
});
|
|
274
283
|
}
|
|
284
|
+
if (body.jevEffortMode !== undefined
|
|
285
|
+
&& body.jevEffortMode !== "decide"
|
|
286
|
+
&& body.jevEffortMode !== "client") {
|
|
287
|
+
issues.push({
|
|
288
|
+
path: ["jevEffortMode"],
|
|
289
|
+
message: 'jevEffortMode must be "decide" or "client"',
|
|
290
|
+
});
|
|
291
|
+
} else if (body.jevEffortMode === "client" && body.strategy !== "jev") {
|
|
292
|
+
issues.push({ path: ["jevEffortMode"], message: 'jevEffortMode "client" is only valid with strategy "jev"' });
|
|
293
|
+
}
|
|
275
294
|
if (body.imageInput !== undefined && body.imageInput !== "auto" && body.imageInput !== "disabled") {
|
|
276
295
|
issues.push({ path: ["imageInput"], message: 'imageInput must be "auto" or "disabled"' });
|
|
277
296
|
}
|
|
@@ -564,6 +583,7 @@ export function normalizeComboConfig(raw: OcxComboConfig): NormalizedComboConfig
|
|
|
564
583
|
defaultEffort,
|
|
565
584
|
defaultEffortMode: raw.defaultEffortMode === "force" && defaultEffort !== null ? "force" : "fallback",
|
|
566
585
|
reasoningEffortMode: raw.reasoningEffortMode === "adaptive" ? "adaptive" : "strict",
|
|
586
|
+
jevEffortMode: raw.jevEffortMode === "client" ? "client" : "decide",
|
|
567
587
|
imageInput: raw.imageInput === "disabled" ? "disabled" : "auto",
|
|
568
588
|
alias: alias || null,
|
|
569
589
|
nativeAlias: raw.nativeAlias === true,
|
|
@@ -29,6 +29,11 @@ import {
|
|
|
29
29
|
renameAtomicFile,
|
|
30
30
|
renameAtomicFileAsync,
|
|
31
31
|
} from "../lib/windows-atomic-replace";
|
|
32
|
+
import {
|
|
33
|
+
catalogReadOnlyRepairFor,
|
|
34
|
+
publishWithReadOnlyRepair,
|
|
35
|
+
setCatalogReadOnlyRepairForTests as setCatalogReadOnlyRepairOverride,
|
|
36
|
+
} from "../lib/codex-catalog-read-only";
|
|
32
37
|
import { getConfigDir } from "./paths";
|
|
33
38
|
|
|
34
39
|
let atomicSequence = 0;
|
|
@@ -103,6 +108,16 @@ export interface AtomicWriteHooks {
|
|
|
103
108
|
afterRename?: (targetPath: string) => void;
|
|
104
109
|
}
|
|
105
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Test seam for the read-only catalog repair (#8358). `null` disables it, `undefined`
|
|
113
|
+
* restores the production rule (win32 and the OpenCodex catalog artifact only).
|
|
114
|
+
*/
|
|
115
|
+
export function setCatalogReadOnlyRepairForTests(
|
|
116
|
+
repair: Parameters<typeof setCatalogReadOnlyRepairOverride>[0],
|
|
117
|
+
): void {
|
|
118
|
+
setCatalogReadOnlyRepairOverride(repair);
|
|
119
|
+
}
|
|
120
|
+
|
|
106
121
|
export class AtomicWriteResidualTempError extends Error {
|
|
107
122
|
constructor(readonly tempPath: string, readonly hardened = true, options?: ErrorOptions) {
|
|
108
123
|
super(`Atomic config write left a ${hardened ? "hardened " : ""}zero-byte temporary file`, options);
|
|
@@ -377,7 +392,13 @@ function atomicWriteFileToTarget(
|
|
|
377
392
|
publicationAttempted = true;
|
|
378
393
|
linkSync(tmp, target);
|
|
379
394
|
assertIdentity(target);
|
|
380
|
-
} else
|
|
395
|
+
} else {
|
|
396
|
+
// The Codex catalog owner repairs its own read-only artifact (#8358); every
|
|
397
|
+
// other destination, and every other platform, keeps the plain rename.
|
|
398
|
+
const repair = catalogReadOnlyRepairFor(target);
|
|
399
|
+
if (repair) publishWithReadOnlyRepair(() => effective.rename(tmp, target), target, repair);
|
|
400
|
+
else effective.rename(tmp, target);
|
|
401
|
+
}
|
|
381
402
|
hooks.afterRename?.(target);
|
|
382
403
|
if (exclusive) { assertIdentity(tmp); effective.unlink(tmp); }
|
|
383
404
|
// The rename is only as durable as the directory entry recording it. Fsyncing the temp's
|
|
@@ -529,6 +550,8 @@ export async function atomicWriteFileAsync(
|
|
|
529
550
|
}
|
|
530
551
|
try { chmodSync(tempPath, 0o600); } catch { /* platform may ignore chmod */ }
|
|
531
552
|
},
|
|
553
|
+
// The read-only catalog repair (#8358) is wired only into the sync writer; no async
|
|
554
|
+
// caller writes the Codex catalog today. Route one through publishWithReadOnlyRepair too.
|
|
532
555
|
rename: renameAtomicFileAsync,
|
|
533
556
|
truncate: target => truncateSync(target, 0),
|
|
534
557
|
unlink: unlinkSync,
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
malformedQuotaResetNotifyWarning,
|
|
50
50
|
malformedCatalogAutoRefreshWarning,
|
|
51
51
|
malformedCodexPoolWarning,
|
|
52
|
+
malformedTelemetryWarning,
|
|
52
53
|
malformedSpendWarning,
|
|
53
54
|
rawConfigRecord,
|
|
54
55
|
malformedNativeSubagentFields,
|
|
@@ -81,6 +82,7 @@ import {
|
|
|
81
82
|
compactionRoutingSchema,
|
|
82
83
|
reasoningRetentionSchema,
|
|
83
84
|
skillsConfigSchema,
|
|
85
|
+
telemetryConfigSchema,
|
|
84
86
|
memoryModelsSchema,
|
|
85
87
|
} from "./schema/leaf-validators";
|
|
86
88
|
|
|
@@ -175,6 +177,8 @@ function validFileConfigDiagnostics(config: OcxConfig, rawParsed: unknown): Conf
|
|
|
175
177
|
if (catalogRefreshWarning) warnings.push(catalogRefreshWarning);
|
|
176
178
|
const codexPoolWarning = malformedCodexPoolWarning(rawParsed);
|
|
177
179
|
if (codexPoolWarning) warnings.push(codexPoolWarning);
|
|
180
|
+
const telemetryWarning = malformedTelemetryWarning(rawParsed);
|
|
181
|
+
if (telemetryWarning) warnings.push(telemetryWarning);
|
|
178
182
|
const spendWarning = malformedSpendWarning(rawParsed);
|
|
179
183
|
if (spendWarning) warnings.push(spendWarning);
|
|
180
184
|
const retentionWarning = degradedReasoningRetentionWarning(rawParsed, normalized);
|
|
@@ -709,6 +713,16 @@ function skillsConfigError(value: unknown): string | null {
|
|
|
709
713
|
return "schema_invalid: skills" + (field ? "." + field : "") + ": " + (issue?.message ?? "invalid configuration");
|
|
710
714
|
}
|
|
711
715
|
|
|
716
|
+
export function telemetryConfigError(value: unknown): string | null {
|
|
717
|
+
const raw = rawConfigRecord(value);
|
|
718
|
+
if (!raw || !Object.hasOwn(raw, "telemetry") || raw.telemetry === undefined) return null;
|
|
719
|
+
const result = telemetryConfigSchema.safeParse(raw.telemetry);
|
|
720
|
+
if (result.success) return null;
|
|
721
|
+
const issue = result.error.issues[0];
|
|
722
|
+
const field = issue?.path.join(".");
|
|
723
|
+
return "schema_invalid: telemetry" + (field ? "." + field : "") + ": " + (issue?.message ?? "invalid configuration");
|
|
724
|
+
}
|
|
725
|
+
|
|
712
726
|
export function validateConfigCandidate(value: unknown): { ok: true; config: OcxConfig } | { ok: false; error: string } {
|
|
713
727
|
const chatgptDesktop = rawConfigRecord(value)?.chatgptDesktop;
|
|
714
728
|
if (chatgptDesktop !== undefined && !chatgptDesktopSchema.safeParse(chatgptDesktop).success) {
|
|
@@ -773,6 +787,7 @@ export function validateConfigCandidate(value: unknown): { ok: true; config: Ocx
|
|
|
773
787
|
?? managementIngressConfigError(value)
|
|
774
788
|
?? metricsExportConfigError(value)
|
|
775
789
|
?? serviceHealthRecoveryConfigError(value)
|
|
790
|
+
?? telemetryConfigError(value)
|
|
776
791
|
?? skillsConfigError(value);
|
|
777
792
|
if (boundaryError) return { ok: false, error: boundaryError };
|
|
778
793
|
const result = configSchema.safeParse(value);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { observeAccountAutoPauseRevisions, snapshotAutoPauseFingerprints } from "./account-auto-pause-revisions";
|
|
2
2
|
import type { OcxConfig, OcxProviderConfig, ProviderCostOverlay } from "../types";
|
|
3
3
|
import { configReasoningPinsConfigError } from "./provider-validation";
|
|
4
|
+
import { carryPersistedTelemetry } from "./telemetry-carry";
|
|
4
5
|
import { adoptCustomModelCatalogMigration, projectCustomModelCatalogMigration } from "../codex/custom-model-catalog-migration";
|
|
5
6
|
import { refreshPreservedProviderOwner } from "../usage/user-cost-overlays";
|
|
6
7
|
import { refreshConfigDerivedRegistries } from "./derived-registries";
|
|
@@ -118,6 +119,19 @@ export function adoptPersistedAdvisor(config: OcxConfig, persisted: OcxConfig["a
|
|
|
118
119
|
clearConfigTopLevelDeletionIntent(config, ["advisor"]);
|
|
119
120
|
if (baseline) clearConfigTopLevelDeletionIntent(baseline, ["advisor"]);
|
|
120
121
|
}
|
|
122
|
+
|
|
123
|
+
/** Adopt the committed telemetry consent subtree without advancing unrelated pending live intent. */
|
|
124
|
+
export function adoptPersistedTelemetry(config: OcxConfig, persisted: OcxConfig["telemetry"]): void {
|
|
125
|
+
if (persisted === undefined) delete config.telemetry;
|
|
126
|
+
else config.telemetry = structuredClone(persisted);
|
|
127
|
+
const baseline = liveConfigBaseline.get(config);
|
|
128
|
+
if (baseline) {
|
|
129
|
+
if (persisted === undefined) delete baseline.telemetry;
|
|
130
|
+
else baseline.telemetry = structuredClone(persisted);
|
|
131
|
+
}
|
|
132
|
+
clearConfigTopLevelDeletionIntent(config, ["telemetry"]);
|
|
133
|
+
if (baseline) clearConfigTopLevelDeletionIntent(baseline, ["telemetry"]);
|
|
134
|
+
}
|
|
121
135
|
/**
|
|
122
136
|
* The live config retains the address of the socket Bun actually opened, while
|
|
123
137
|
* this map retains the operator's desired address for the next process start.
|
|
@@ -623,6 +637,9 @@ export function saveConfigPreservingClaudeCode(config: OcxConfig): void {
|
|
|
623
637
|
);
|
|
624
638
|
if (provenanceProjection.configRebaseProvenance === undefined) delete projectedConfig.configRebaseProvenance;
|
|
625
639
|
else projectedConfig.configRebaseProvenance = provenanceProjection.configRebaseProvenance;
|
|
640
|
+
// Telemetry consent is owned by the file (see carryPersistedTelemetry).
|
|
641
|
+
const telemetry = carryPersistedTelemetry(projectedConfig, onDisk as Record<string, unknown> | undefined);
|
|
642
|
+
if (telemetry.carried) adoptPersistedTelemetry(config, telemetry.value);
|
|
626
643
|
const persistedBinding = (bindingBaseline || diskDeletedKeys.has("hostname")) && onDisk
|
|
627
644
|
? readPersistedServerBinding(onDisk, bindingBaseline ?? { port: config.port, hostname: config.hostname })
|
|
628
645
|
: bindingBaseline;
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
transientRetryOn5xxPolicySchema,
|
|
53
53
|
runtimeRoleSchema,
|
|
54
54
|
spendSchema,
|
|
55
|
+
telemetryConfigSchema,
|
|
55
56
|
chatgptDesktopConfigIssue,
|
|
56
57
|
} from "./schema/leaf-validators";
|
|
57
58
|
import { hasWarnedInheritedFastWireConflict, markWarnedInheritedFastWireConflict } from "./warn-memo";
|
|
@@ -152,6 +153,7 @@ export function warnDegradedTopLevelOptIns(rawParsed: unknown, validated: OcxCon
|
|
|
152
153
|
warnDegradedStreamMode(rawParsed, validated);
|
|
153
154
|
warnDegradedCompactionRouting(rawParsed, validated);
|
|
154
155
|
warnDegradedMemoryModels(rawParsed, validated);
|
|
156
|
+
warnDegradedTelemetry(rawParsed);
|
|
155
157
|
// The schema replaces a malformed policy with { allProfiles: false }, which silently turns every Aside profile off (#6757).
|
|
156
158
|
const asidePolicy = rawParsed && typeof rawParsed === "object" ? (rawParsed as Record<string, unknown>).asideProfileSync : undefined;
|
|
157
159
|
if (asidePolicy !== undefined && !asideProfileSyncSchema.safeParse(asidePolicy).success) {
|
|
@@ -850,6 +852,20 @@ export function malformedCodexPoolWarning(rawParsed: unknown): string | null {
|
|
|
850
852
|
return `codexPool${field ? `.${field}` : ""} ignored: invalid Codex pool selection policy`;
|
|
851
853
|
}
|
|
852
854
|
|
|
855
|
+
export function malformedTelemetryWarning(rawParsed: unknown): string | null {
|
|
856
|
+
const raw = rawConfigRecord(rawParsed);
|
|
857
|
+
if (!raw || !Object.hasOwn(raw, "telemetry") || raw.telemetry === undefined) return null;
|
|
858
|
+
const result = telemetryConfigSchema.safeParse(raw.telemetry);
|
|
859
|
+
if (result.success) return null;
|
|
860
|
+
const field = result.error.issues[0]?.path.join(".");
|
|
861
|
+
return `telemetry${field ? `.${field}` : ""} ignored: invalid telemetry consent configuration`;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
export function warnDegradedTelemetry(rawParsed: unknown): void {
|
|
865
|
+
const warning = malformedTelemetryWarning(rawParsed);
|
|
866
|
+
if (warning) console.warn(`⚠️ config.json ${warning}. Other settings were preserved.`);
|
|
867
|
+
}
|
|
868
|
+
|
|
853
869
|
/**
|
|
854
870
|
* Warn once per load that the section was dropped.
|
|
855
871
|
*
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
isWirePinnedModel,
|
|
14
14
|
MODEL_ADAPTER_OVERRIDE_ALLOWED,
|
|
15
15
|
REASONING_SUMMARY_DELIVERY_VALUES,
|
|
16
|
+
THINKING_DISPLAY_VALUES,
|
|
16
17
|
UPSTREAM_HTTP_VERSION_VALUES,
|
|
17
18
|
type OcxProviderConfig,
|
|
18
19
|
type ModelCapabilities,
|
|
@@ -29,6 +30,7 @@ const SENSITIVE_PROVIDER_HEADERS = new Set([
|
|
|
29
30
|
"x-amz-security-token",
|
|
30
31
|
]);
|
|
31
32
|
const REASONING_SUMMARY_DELIVERY_SET = new Set<string>(REASONING_SUMMARY_DELIVERY_VALUES);
|
|
33
|
+
const THINKING_DISPLAY_SET = new Set<string>(THINKING_DISPLAY_VALUES);
|
|
32
34
|
const DISPLAY_NAME_CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/;
|
|
33
35
|
const MAX_MODEL_DISPLAY_NAME_LENGTH = 128;
|
|
34
36
|
|
|
@@ -385,6 +387,33 @@ export function reasoningSummaryDeliveryRecordConfigError(
|
|
|
385
387
|
return null;
|
|
386
388
|
}
|
|
387
389
|
|
|
390
|
+
/** Validate `thinkingDisplay`: one closed vocabulary shared by config and management writes. */
|
|
391
|
+
export function thinkingDisplayConfigError(value: unknown, field = "thinkingDisplay"): string | null {
|
|
392
|
+
if (value === undefined) return null;
|
|
393
|
+
if (typeof value !== "string" || !THINKING_DISPLAY_SET.has(value)) {
|
|
394
|
+
return `${field} must be one of: ${THINKING_DISPLAY_VALUES.join(", ")}`;
|
|
395
|
+
}
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Validate `modelThinkingDisplay`: a plain map of model id to the same closed vocabulary. */
|
|
400
|
+
export function modelThinkingDisplayConfigError(value: unknown, field = "modelThinkingDisplay"): string | null {
|
|
401
|
+
if (value === undefined) return null;
|
|
402
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return `${field} must be a plain object`;
|
|
403
|
+
const prototype = Object.getPrototypeOf(value);
|
|
404
|
+
if (prototype !== Object.prototype && prototype !== null) return `${field} must be a plain object with own properties`;
|
|
405
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
406
|
+
const safeKey = JSON.stringify(redactSecretString(key));
|
|
407
|
+
if (!key.trim()) return `${field} keys must be nonblank model ids`;
|
|
408
|
+
if (["__proto__", "prototype", "constructor"].includes(key)) {
|
|
409
|
+
return `${field} keys must not be reserved object keys`;
|
|
410
|
+
}
|
|
411
|
+
const entryError = thinkingDisplayConfigError(entry, `${field}.${safeKey}`);
|
|
412
|
+
if (entryError) return entryError;
|
|
413
|
+
}
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
|
|
388
417
|
/** Validate a provider's per-model wire override map against runtime routing rules. */
|
|
389
418
|
export function modelAdapterRecordConfigError(
|
|
390
419
|
value: unknown,
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
spendSchema,
|
|
30
30
|
chatgptDesktopSchema,
|
|
31
31
|
skillsConfigSchema,
|
|
32
|
+
telemetryConfigSchema,
|
|
32
33
|
configuredCodexPoolAccountIds,
|
|
33
34
|
apiKeyEntrySchema,
|
|
34
35
|
asideProfileSyncSchema,
|
|
@@ -60,6 +61,8 @@ import {
|
|
|
60
61
|
providerHeadersConfigError,
|
|
61
62
|
providerForwardClientHeadersConfigError,
|
|
62
63
|
reasoningSummaryDeliveryRecordConfigError,
|
|
64
|
+
thinkingDisplayConfigError,
|
|
65
|
+
modelThinkingDisplayConfigError,
|
|
63
66
|
credentialPinnedProviderConfigError,
|
|
64
67
|
} from "../provider-validation";
|
|
65
68
|
import {
|
|
@@ -120,6 +123,7 @@ export const configSchema = z.object({
|
|
|
120
123
|
skills: skillsConfigSchema.optional().catch(undefined),
|
|
121
124
|
// Malformed hand edits disable this opt-in exporter. Live writes reject them in diagnostics.ts.
|
|
122
125
|
metricsExport: z.object({ enabled: z.boolean().optional() }).strict().optional().catch(undefined),
|
|
126
|
+
telemetry: telemetryConfigSchema.optional().catch(undefined),
|
|
123
127
|
// Same contract as metricsExport: a malformed hand edit leaves recovery off; live writes reject it.
|
|
124
128
|
serviceHealthRecovery: z.object({ enabled: z.boolean().optional() }).strict().optional().catch(undefined),
|
|
125
129
|
// Kept raw on purpose: `.catch(undefined)` would turn a mistyped `enabled` into "inherit",
|
|
@@ -767,6 +771,26 @@ export const configSchema = z.object({
|
|
|
767
771
|
message: reasoningSummaryDeliveryError,
|
|
768
772
|
});
|
|
769
773
|
}
|
|
774
|
+
const thinkingDisplayError = thinkingDisplayConfigError(
|
|
775
|
+
(provider as { thinkingDisplay?: unknown }).thinkingDisplay,
|
|
776
|
+
);
|
|
777
|
+
if (thinkingDisplayError) {
|
|
778
|
+
ctx.addIssue({
|
|
779
|
+
code: "custom",
|
|
780
|
+
path: ["providers", redactSecretString(name), "thinkingDisplay"],
|
|
781
|
+
message: thinkingDisplayError,
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
const modelThinkingDisplayError = modelThinkingDisplayConfigError(
|
|
785
|
+
(provider as { modelThinkingDisplay?: unknown }).modelThinkingDisplay,
|
|
786
|
+
);
|
|
787
|
+
if (modelThinkingDisplayError) {
|
|
788
|
+
ctx.addIssue({
|
|
789
|
+
code: "custom",
|
|
790
|
+
path: ["providers", redactSecretString(name), "modelThinkingDisplay"],
|
|
791
|
+
message: modelThinkingDisplayError,
|
|
792
|
+
});
|
|
793
|
+
}
|
|
770
794
|
const minMaxOutputError = positiveIntegerConfigError(
|
|
771
795
|
(provider as { minMaxOutputTokens?: unknown }).minMaxOutputTokens,
|
|
772
796
|
"minMaxOutputTokens",
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
MODEL_ADAPTER_OVERRIDE_ALLOWED,
|
|
30
30
|
pinnedWireAdapter,
|
|
31
31
|
PROVIDER_WEB_SEARCH_BRIDGE_BACKENDS,
|
|
32
|
+
THINKING_DISPLAY_VALUES,
|
|
32
33
|
UPSTREAM_HTTP_VERSION_VALUES,
|
|
33
34
|
type OcxProviderConfig,
|
|
34
35
|
type OcxConfig,
|
|
@@ -360,12 +361,17 @@ export const providerConfigSchema = z.object({
|
|
|
360
361
|
inferContextWindow: z.boolean().optional(),
|
|
361
362
|
modelSupportsServiceTier: z.record(z.string().min(1), z.boolean()).optional(),
|
|
362
363
|
modelSuppressSyntheticMax: z.record(z.string().min(1), z.boolean()).optional(),
|
|
364
|
+
// Validated against a closed vocabulary here as well as at the write boundaries, so a
|
|
365
|
+
// hand-edited typo cannot load silently and leave the operator with the built-in display (#8363).
|
|
366
|
+
thinkingDisplay: z.enum(THINKING_DISPLAY_VALUES).optional(),
|
|
367
|
+
modelThinkingDisplay: z.record(z.string().min(1), z.enum(THINKING_DISPLAY_VALUES)).optional(),
|
|
363
368
|
promoteAdditionalTools: z.boolean().optional(),
|
|
364
369
|
preserveResponsesReasoningContent: z.boolean().optional(),
|
|
365
370
|
preserveResponsesInputItemIds: z.boolean().optional(),
|
|
366
371
|
preserveResponsesMessageMetadata: z.boolean().optional(),
|
|
367
372
|
projectResponsesLiteHostedSearchHistory: z.boolean().optional(),
|
|
368
373
|
dropResponsesReasoningItems: z.boolean().optional(),
|
|
374
|
+
arkKimiResponsesModels: z.array(z.string().min(1)).optional(),
|
|
369
375
|
modelReasoningEffortsAuthoritative: z.boolean().optional(),
|
|
370
376
|
decodesNativeCompactionBlobs: z.boolean().optional(),
|
|
371
377
|
supportsNativeCompactionTrigger: z.boolean().optional(),
|
|
@@ -1189,3 +1195,14 @@ export const spendSchema = z.object({
|
|
|
1189
1195
|
export const skillsConfigSchema = z.object({
|
|
1190
1196
|
catalog_refresh: z.enum(["per_session", "per_turn"]).optional(),
|
|
1191
1197
|
}).strict();
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* Anonymous telemetry consent state.
|
|
1201
|
+
*
|
|
1202
|
+
* No endpoint is accepted here: the collector URL is a constant in src/telemetry/sender.ts.
|
|
1203
|
+
*/
|
|
1204
|
+
export const telemetryConfigSchema = z.object({
|
|
1205
|
+
decision: z.enum(["accepted", "declined"]).optional(),
|
|
1206
|
+
decidedAt: clientTimestampSchema.optional(),
|
|
1207
|
+
noticeShownAt: clientTimestampSchema.optional(),
|
|
1208
|
+
}).strict();
|