@bitkyc08/opencodex 2.99.0-preview.20261108 → 2.100.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/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-CitvEefy.js +59 -0
- package/gui/dist/assets/Tray-CeKVWQyB.js +1 -0
- package/gui/dist/assets/{brand-mark-DpiBmFGI.js → brand-mark-M92UnxX2.js} +1 -1
- package/gui/dist/assets/index-BP47do6-.js +94 -0
- package/gui/dist/assets/index-DmDooSAG.css +2 -0
- package/gui/dist/assets/{segment-thumb-features-JcszQ18T.js → segment-thumb-features-CcxZBnxv.js} +1 -1
- package/gui/dist/classic/assets/App-aYgIQMxI.js +58 -0
- package/gui/dist/classic/assets/{Tray-5v86r9Az.js → Tray-D8jfUXpQ.js} +1 -1
- package/gui/dist/classic/assets/index-CfGqHooN.js +94 -0
- package/gui/dist/classic/assets/quota-summary-R-ih7OlS.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.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/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-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 +405 -153
- 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 +49 -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/claude-keychain-read.ts +165 -0
- 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-usage-state.ts +93 -0
- 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/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.ts +25 -18
- package/src/providers/registry/entries-core.ts +7 -4
- package/src/providers/registry/entries-extended.ts +39 -7
- package/src/providers/registry/model-seeds.ts +10 -2
- 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/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/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 +244 -38
- package/gui/dist/assets/App-CWz0areF.js +0 -59
- package/gui/dist/assets/Tray-BosDoskm.js +0 -1
- package/gui/dist/assets/index-CAxjGWkm.js +0 -94
- package/gui/dist/assets/index-bnUWypyz.css +0 -2
- package/gui/dist/classic/assets/App-BOEsFmiN.js +0 -58
- package/gui/dist/classic/assets/index-ClZ_zZ77.js +0 -94
- package/gui/dist/classic/assets/quota-summary-xwvDtvu7.js +0 -1
|
@@ -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();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { OcxConfig } from "../types";
|
|
2
|
+
import { telemetryConfigSchema } from "./schema/leaf-validators";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Telemetry consent is owned by `config.json` on disk: `ocx telemetry`, the start prompt and the
|
|
6
|
+
* consent route write it there, often while another process holds an older snapshot. A whole-config
|
|
7
|
+
* save therefore writes the on-disk block (validated; a malformed hand edit is dropped, as a load
|
|
8
|
+
* would drop it) instead of the snapshot's, so a decision is never dropped or rolled back. Without a
|
|
9
|
+
* readable file, a whole-config save never introduces a decision: before `config.json` exists a
|
|
10
|
+
* decision is held in telemetry-state.json (and another process may have replaced it there), and a
|
|
11
|
+
* file that cannot be read may hold a decline the snapshot never saw. Only a snapshot decline
|
|
12
|
+
* survives; anything else is dropped, and the held decision or the notice applies.
|
|
13
|
+
*
|
|
14
|
+
* Returns whether the block was taken from disk and the value now in `target`.
|
|
15
|
+
*/
|
|
16
|
+
export function carryPersistedTelemetry(
|
|
17
|
+
target: OcxConfig,
|
|
18
|
+
onDisk: Record<string, unknown> | undefined,
|
|
19
|
+
): { carried: boolean; value: OcxConfig["telemetry"] } {
|
|
20
|
+
if (onDisk === undefined) {
|
|
21
|
+
if (target.telemetry?.decision === "declined") return { carried: true, value: target.telemetry };
|
|
22
|
+
delete target.telemetry;
|
|
23
|
+
return { carried: true, value: undefined };
|
|
24
|
+
}
|
|
25
|
+
const parsed = onDisk.telemetry === undefined ? undefined : telemetryConfigSchema.safeParse(onDisk.telemetry);
|
|
26
|
+
const value = parsed?.success ? (structuredClone(parsed.data) as OcxConfig["telemetry"]) : undefined;
|
|
27
|
+
if (value === undefined) delete target.telemetry;
|
|
28
|
+
else target.telemetry = value;
|
|
29
|
+
return { carried: true, value };
|
|
30
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -161,6 +161,8 @@ import { persistConfigUnlocked, readRawConfigJson } from "./config/persist-unloc
|
|
|
161
161
|
import { withConfigMutationLockSync, bumpGenerationForCooperatingConfigWrite } from "./config/mutation-lock";
|
|
162
162
|
import { getDefaultConfig } from "./config/proxy-env";
|
|
163
163
|
import { configSchema } from "./config/schema/config-schema";
|
|
164
|
+
import { adoptPersistedTelemetry } from "./config/live-reconcile";
|
|
165
|
+
import { carryPersistedTelemetry } from "./config/telemetry-carry";
|
|
164
166
|
import { sanitizeOpenCodeOverridesForLoad } from "./config/opencode-wire-upgrade";
|
|
165
167
|
import { projectRemovedOpenCodeFreeSnapshot } from "./config/removed-opencode-free-backup";
|
|
166
168
|
import {
|
|
@@ -348,12 +350,17 @@ export function initializePersistedConfigIfMissing(
|
|
|
348
350
|
const before = observeInitialConfigState();
|
|
349
351
|
if (before !== "missing") return before;
|
|
350
352
|
let published = false;
|
|
353
|
+
let telemetry: ReturnType<typeof carryPersistedTelemetry> | undefined;
|
|
351
354
|
try {
|
|
352
355
|
const persisted = withConfigMutationLockSync((): OcxConfig | "exists" | "invalid" => {
|
|
353
356
|
const current = observeInitialConfigState();
|
|
354
357
|
if (current !== "missing") return current;
|
|
355
358
|
const projected = projectCustomModelCatalogMigration(undefined, projectConfigRebaseProvenance(config));
|
|
356
359
|
normalizeAccountAutoPauseRevisions(undefined, projected);
|
|
360
|
+
// Creating config.json never introduces a telemetry decision: one made before the file existed
|
|
361
|
+
// is held in telemetry-state.json, where another process may have replaced it (see
|
|
362
|
+
// carryPersistedTelemetry). Only an in-memory decline survives.
|
|
363
|
+
telemetry = carryPersistedTelemetry(projected, undefined);
|
|
357
364
|
if (!validateConfigCandidate(projected).ok) throw new Error("Initial configuration is invalid.");
|
|
358
365
|
if (!publishInitialConfigNoReplace(getConfigPath(), JSON.stringify(projected, null, 2) + "\n", io)) {
|
|
359
366
|
return observeInitialConfigState() === "exists" ? "exists" : "invalid";
|
|
@@ -366,6 +373,7 @@ export function initializePersistedConfigIfMissing(
|
|
|
366
373
|
});
|
|
367
374
|
if (typeof persisted === "string") return persisted;
|
|
368
375
|
adoptCustomModelCatalogMigration(config, persisted);
|
|
376
|
+
if (telemetry?.carried) adoptPersistedTelemetry(config, telemetry.value);
|
|
369
377
|
if (persisted.configRebaseProvenance === undefined) delete config.configRebaseProvenance;
|
|
370
378
|
else config.configRebaseProvenance = structuredClone(persisted.configRebaseProvenance);
|
|
371
379
|
clearPendingConfigDeletions(config);
|
|
@@ -384,12 +392,16 @@ export function saveConfig(config: OcxConfig): void {
|
|
|
384
392
|
// Keep the real-home assertion ahead of even lock-directory preparation.
|
|
385
393
|
assertNotRealHomeUnderTest(getConfigDir());
|
|
386
394
|
withConfigMutationLockSync(() => {
|
|
395
|
+
const onDisk = readRawConfigJson();
|
|
387
396
|
const withProvenance = projectCustomModelCatalogMigration(
|
|
388
|
-
|
|
397
|
+
onDisk,
|
|
389
398
|
projectConfigRebaseProvenance(config),
|
|
390
399
|
);
|
|
400
|
+
// Telemetry consent is owned by the file, as in the live save (see carryPersistedTelemetry).
|
|
401
|
+
const telemetry = carryPersistedTelemetry(withProvenance, onDisk);
|
|
391
402
|
if (persistConfigUnlocked(withProvenance)) bumpGenerationForCooperatingConfigWrite();
|
|
392
403
|
adoptCustomModelCatalogMigration(config, withProvenance);
|
|
404
|
+
if (telemetry.carried) adoptPersistedTelemetry(config, telemetry.value);
|
|
393
405
|
if (withProvenance.configRebaseProvenance === undefined) delete config.configRebaseProvenance;
|
|
394
406
|
else config.configRebaseProvenance = structuredClone(withProvenance.configRebaseProvenance);
|
|
395
407
|
clearPendingConfigDeletions(config);
|