@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.
Files changed (276) hide show
  1. package/AGENTS_INSTALL.md +19 -1
  2. package/README.md +37 -33
  3. package/SPONSORS.md +5 -1
  4. package/bin/ocx.mjs +1 -1
  5. package/gui/dist/assets/{App-C1hGwaN1.css → App-COo8Yopd.css} +1 -1
  6. package/gui/dist/assets/App-g3Cm2xhZ.js +59 -0
  7. package/gui/dist/assets/Tray-BMDkAiXy.js +1 -0
  8. package/gui/dist/assets/brand-mark-nr3ziR-T.js +1 -0
  9. package/gui/dist/assets/index-Bziu8gTy.css +2 -0
  10. package/gui/dist/assets/index-OYzhQUNP.js +94 -0
  11. package/gui/dist/assets/{segment-thumb-features-fYEMxBaW.js → segment-thumb-features-DKCVUUTi.js} +1 -1
  12. package/gui/dist/classic/assets/App-CgPBKUP-.js +58 -0
  13. package/gui/dist/classic/assets/{Tray-BqZueZOx.js → Tray-BedmOsE7.js} +1 -1
  14. package/gui/dist/classic/assets/index-BR-HhNrp.js +94 -0
  15. package/gui/dist/classic/assets/quota-summary-CXKhvSmQ.js +1 -0
  16. package/gui/dist/classic/index.html +1 -1
  17. package/gui/dist/index.html +2 -2
  18. package/native/ocx-child/Cargo.lock +215 -0
  19. package/native/ocx-child/Cargo.toml +31 -0
  20. package/native/ocx-child/src/cli.rs +1901 -0
  21. package/native/ocx-child/src/codex_home.rs +429 -0
  22. package/native/ocx-child/src/codex_settings.rs +231 -0
  23. package/native/ocx-child/src/daemon.rs +363 -0
  24. package/native/ocx-child/src/http_wire.rs +619 -0
  25. package/native/ocx-child/src/journal.rs +977 -0
  26. package/native/ocx-child/src/lib.rs +22 -0
  27. package/native/ocx-child/src/main.rs +9 -0
  28. package/native/ocx-child/src/parity.rs +102 -0
  29. package/native/ocx-child/src/platform.rs +1487 -0
  30. package/native/ocx-child/src/relay.rs +1288 -0
  31. package/native/ocx-child/src/relay_auth.rs +166 -0
  32. package/native/ocx-child/src/routes.rs +236 -0
  33. package/native/ocx-child/src/state.rs +190 -0
  34. package/native/ocx-child/src/test_hooks.rs +58 -0
  35. package/native/ocx-child/src/toml_surgeon.rs +1156 -0
  36. package/package.json +8 -2
  37. package/src/adapters/anthropic-image-normalize.ts +1 -1
  38. package/src/adapters/anthropic.ts +28 -2
  39. package/src/adapters/claude-cli/adapter.ts +5 -25
  40. package/src/adapters/claude-cli/instruction-images.ts +31 -0
  41. package/src/adapters/claude-cli/stable-replay.ts +42 -14
  42. package/src/adapters/claude-cli/usage-admission.ts +53 -64
  43. package/src/adapters/client-fingerprint.ts +1 -1
  44. package/src/adapters/coding-agent/protocol.ts +1 -1
  45. package/src/adapters/devin/live-models.ts +3 -0
  46. package/src/adapters/google-http.ts +3 -0
  47. package/src/adapters/google-vertex-key-project.ts +10 -2
  48. package/src/adapters/google.ts +40 -8
  49. package/src/adapters/kiro/usage.ts +3 -13
  50. package/src/adapters/openai-chat/mistral-image-limit.ts +28 -15
  51. package/src/adapters/openai-chat-images.ts +100 -0
  52. package/src/adapters/openai-chat.ts +6 -9
  53. package/src/adapters/openai-responses/passthrough.ts +5 -2
  54. package/src/adapters/openai-responses/request-strips.ts +32 -0
  55. package/src/adapters/openai-responses/tool-schema.ts +9 -4
  56. package/src/chat/inbound.ts +1 -1
  57. package/src/claude/auth-detect.ts +26 -8
  58. package/src/claude/inbound-content-options.ts +18 -3
  59. package/src/claude/inbound.ts +5 -2
  60. package/src/cli/bundled-bun-diagnostic.ts +91 -0
  61. package/src/cli/capabilities-agents-routing.ts +2 -2
  62. package/src/cli/capabilities-observe-system.ts +60 -0
  63. package/src/cli/combo-input.ts +6 -0
  64. package/src/cli/combo-result.ts +1 -1
  65. package/src/cli/combo.ts +4 -0
  66. package/src/cli/config-command.ts +16 -2
  67. package/src/cli/connect.ts +12 -10
  68. package/src/cli/dispatch.ts +4 -0
  69. package/src/cli/doctor.ts +11 -0
  70. package/src/cli/help.ts +1 -0
  71. package/src/cli/init.ts +4 -0
  72. package/src/cli/link-enrollment.ts +152 -25
  73. package/src/cli/link-local-control.ts +49 -0
  74. package/src/cli/link.ts +37 -10
  75. package/src/cli/provider-lifecycle-runtime.ts +4 -2
  76. package/src/cli/registry.ts +13 -0
  77. package/src/cli/star-prompt.ts +2 -0
  78. package/src/cli/status.ts +1 -1
  79. package/src/cli/telemetry-profile.ts +206 -0
  80. package/src/cli/telemetry.ts +260 -0
  81. package/src/client/hub-relay.ts +26 -0
  82. package/src/client/machine-api.ts +3 -0
  83. package/src/clients/config-export/t3code.ts +44 -5
  84. package/src/clients/omo-role-models.ts +1 -1
  85. package/src/codex/catalog/bundled.ts +44 -2
  86. package/src/codex/runtime.ts +12 -0
  87. package/src/codex/shim-restore-lock.ts +67 -30
  88. package/src/combos/types.ts +21 -1
  89. package/src/config/atomic-write.ts +24 -1
  90. package/src/config/diagnostics.ts +15 -0
  91. package/src/config/live-reconcile.ts +17 -0
  92. package/src/config/load-degrade.ts +16 -0
  93. package/src/config/provider-validation.ts +29 -0
  94. package/src/config/schema/config-schema.ts +24 -0
  95. package/src/config/schema/leaf-validators.ts +17 -0
  96. package/src/config/telemetry-carry.ts +30 -0
  97. package/src/config.ts +13 -1
  98. package/src/generated/compatibility-version.json +422 -170
  99. package/src/generated/model-metadata.ts +3 -3
  100. package/src/integrations/aside-profiles.ts +7 -1
  101. package/src/integrations/owned-refresh.ts +9 -2
  102. package/src/lab/artifacts/secure-fs.ts +12 -11
  103. package/src/lab/fabric/scratch.ts +11 -9
  104. package/src/lab/public/community.ts +2 -3
  105. package/src/lab/public/file-safety.ts +18 -20
  106. package/src/lab/public/mutation-lock.ts +109 -337
  107. package/src/lab/public/private-file.ts +4 -3
  108. package/src/lib/bun-runtime-preflight.ts +1 -1
  109. package/src/lib/codex-catalog-read-only.ts +122 -0
  110. package/src/lib/config-ownership.ts +56 -18
  111. package/src/lib/errors.ts +11 -0
  112. package/src/lib/gcp-adc.ts +167 -48
  113. package/src/lib/jsonc.ts +4 -2
  114. package/src/lib/local-control-socket.ts +88 -0
  115. package/src/lib/privacy.ts +15 -0
  116. package/src/lib/provider-client-headers.ts +3 -0
  117. package/src/lib/token-estimate.ts +13 -2
  118. package/src/link/child-binary-source.ts +228 -0
  119. package/src/link/ephemeral-child.ts +45 -0
  120. package/src/link/remote-plant.ts +306 -0
  121. package/src/link/remote-windows.ts +59 -5
  122. package/src/link/ssh-argv.ts +71 -8
  123. package/src/link/status-projection.ts +2 -0
  124. package/src/link/store.ts +5 -1
  125. package/src/oauth/anthropic-model-quota.ts +12 -0
  126. package/src/oauth/anthropic-routing.ts +11 -4
  127. package/src/oauth/claude-keychain-read.ts +165 -0
  128. package/src/oauth/kiro-iam-identity-center.ts +4 -1
  129. package/src/oauth/local-token-detect.ts +14 -17
  130. package/src/protocols/envelope.ts +20 -2
  131. package/src/providers/api-key-selection.ts +8 -2
  132. package/src/providers/claude-cli-identity.ts +9 -3
  133. package/src/providers/claude-cli-usage-state.ts +93 -0
  134. package/src/providers/claude-cli-usage.ts +3 -2
  135. package/src/providers/github-copilot-auto.ts +25 -5
  136. package/src/providers/meta-muse-plan-refusal.ts +94 -0
  137. package/src/providers/model-rename-fields.ts +3 -0
  138. package/src/providers/quota/anthropic-family-headers.ts +8 -1
  139. package/src/providers/quota/anthropic-usage-windows.ts +49 -2
  140. package/src/providers/quota/vendor-probes-key.ts +23 -4
  141. package/src/providers/quota/vendor-probes-oauth.ts +59 -0
  142. package/src/providers/quota/workbuddy.ts +2 -2
  143. package/src/providers/quota-types.ts +7 -0
  144. package/src/providers/quota.ts +25 -18
  145. package/src/providers/registry/entries-core.ts +7 -4
  146. package/src/providers/registry/entries-extended.ts +42 -8
  147. package/src/providers/registry/model-ids.ts +1 -0
  148. package/src/providers/registry/model-seeds.ts +10 -2
  149. package/src/providers/registry/types.ts +6 -0
  150. package/src/providers/resolved-model-policy.ts +4 -0
  151. package/src/providers/routed-config.ts +30 -3
  152. package/src/providers/stale-no-vision-seed-migration.ts +7 -0
  153. package/src/providers/vertex-environment-authority.ts +50 -0
  154. package/src/providers/workbuddy-credit-balance.ts +38 -6
  155. package/src/quota-pool/assemble.ts +14 -6
  156. package/src/responses/retained-compaction.ts +31 -5
  157. package/src/router.ts +1 -0
  158. package/src/server/adapter-resolve.ts +11 -6
  159. package/src/server/audio-dictation.ts +21 -7
  160. package/src/server/auth-cors.ts +19 -0
  161. package/src/server/background-lifecycle.ts +71 -0
  162. package/src/server/chat-completions.ts +2 -0
  163. package/src/server/claude-messages.ts +30 -3
  164. package/src/server/index/live-sideband.ts +15 -1
  165. package/src/server/index/local-control-listener.ts +515 -0
  166. package/src/server/index/optional-listeners.ts +21 -1
  167. package/src/server/index/serve-options.ts +4 -3
  168. package/src/server/index/websocket-handler.ts +2 -0
  169. package/src/server/index.ts +3 -0
  170. package/src/server/management/combo-routes.ts +6 -1
  171. package/src/server/management/context.ts +1 -0
  172. package/src/server/management/link-child-preflight.ts +74 -0
  173. package/src/server/management/link-enrollment.ts +190 -25
  174. package/src/server/management/link-route-state.ts +6 -1
  175. package/src/server/management/link-routes.ts +27 -9
  176. package/src/server/management/model-rows.ts +4 -0
  177. package/src/server/management/oauth-account-routes.ts +9 -4
  178. package/src/server/management/provider-overwrite-carry.ts +9 -2
  179. package/src/server/management/provider-routes.ts +14 -0
  180. package/src/server/management/provider-thinking-display-patch.ts +54 -0
  181. package/src/server/management/route-registry.ts +7 -0
  182. package/src/server/management/session-routes.ts +4 -1
  183. package/src/server/management/telemetry-routes.ts +37 -0
  184. package/src/server/management/usage-aggregate-cache.ts +290 -67
  185. package/src/server/management-api.ts +11 -2
  186. package/src/server/messages-native-preflight.ts +166 -0
  187. package/src/server/messages-native.ts +143 -43
  188. package/src/server/messages-shared.ts +14 -0
  189. package/src/server/proxy-liveness.ts +99 -6
  190. package/src/server/request-log-conversation.ts +18 -2
  191. package/src/server/request-log.ts +7 -2
  192. package/src/server/responses/adapter-continuation.ts +1 -0
  193. package/src/server/responses/adapter-dispatch.ts +11 -28
  194. package/src/server/responses/adapter-failure-message.ts +68 -0
  195. package/src/server/responses/combo-stream-preflight.ts +14 -2
  196. package/src/server/responses/compact.ts +13 -1
  197. package/src/server/responses/core-auth.ts +26 -5
  198. package/src/server/responses/core-codex-account.ts +8 -1
  199. package/src/server/responses/core-combo-failure.ts +6 -1
  200. package/src/server/responses/core-combo-native.ts +150 -37
  201. package/src/server/responses/core-combo.ts +15 -9
  202. package/src/server/responses/core-normalize.ts +1 -0
  203. package/src/server/responses/core-options.ts +7 -1
  204. package/src/server/responses/core-pipeline.ts +21 -1
  205. package/src/server/responses/fetch-helpers.ts +5 -0
  206. package/src/server/responses/opengateway-completion-guard.ts +7 -3
  207. package/src/server/responses/passthrough-delivery.ts +8 -1
  208. package/src/server/responses/passthrough-error.ts +22 -0
  209. package/src/server/responses/request-prepare.ts +7 -1
  210. package/src/server/responses/request-transport.ts +28 -5
  211. package/src/server/responses/run-turn-execution.ts +13 -0
  212. package/src/server/sse-frame-buffer.ts +5 -0
  213. package/src/server/ws-bridge.ts +10 -0
  214. package/src/service/launchd.ts +78 -4
  215. package/src/telemetry/aggregate.ts +348 -0
  216. package/src/telemetry/consent.ts +128 -0
  217. package/src/telemetry/contract.ts +403 -0
  218. package/src/telemetry/disclosure.ts +19 -0
  219. package/src/telemetry/install-id.ts +226 -0
  220. package/src/telemetry/payload.ts +129 -0
  221. package/src/telemetry/profile/client.ts +150 -0
  222. package/src/telemetry/profile/contract.ts +288 -0
  223. package/src/telemetry/profile/disclosure.ts +14 -0
  224. package/src/telemetry/profile/paths.ts +13 -0
  225. package/src/telemetry/profile/routes.ts +99 -0
  226. package/src/telemetry/profile/service.ts +234 -0
  227. package/src/telemetry/profile/state.ts +189 -0
  228. package/src/telemetry/profile/sync.ts +276 -0
  229. package/src/telemetry/routes.ts +183 -0
  230. package/src/telemetry/scheduler.ts +386 -0
  231. package/src/telemetry/sender.ts +97 -0
  232. package/src/telemetry/state.ts +334 -0
  233. package/src/types/combo-jev-effort-mode.ts +11 -0
  234. package/src/types/config.ts +3 -0
  235. package/src/types/provider.ts +11 -1
  236. package/src/types/request.ts +2 -0
  237. package/src/types/telemetry.ts +15 -0
  238. package/src/types/wire.ts +10 -0
  239. package/src/types.ts +5 -0
  240. package/src/update/index.ts +7 -1
  241. package/src/update/minisign.d.mts +17 -0
  242. package/src/update/minisign.mjs +88 -0
  243. package/src/update/signed-supply.d.mts +59 -0
  244. package/src/update/signed-supply.mjs +289 -0
  245. package/src/update/trust-root.json +38 -0
  246. package/src/update/update-bounded-json.d.mts +4 -0
  247. package/src/update/update-bounded-json.mjs +113 -0
  248. package/src/update/update-bytes.d.mts +2 -0
  249. package/src/update/update-bytes.mjs +23 -0
  250. package/src/update/update-candidate-id.d.mts +2 -0
  251. package/src/update/update-candidate-id.mjs +23 -0
  252. package/src/update/update-checkpoint-codec.d.mts +33 -0
  253. package/src/update/update-checkpoint-codec.mjs +217 -0
  254. package/src/update/update-contracts.d.mts +24 -0
  255. package/src/update/update-contracts.mjs +207 -0
  256. package/src/update/update-signature-threshold.d.mts +12 -0
  257. package/src/update/update-signature-threshold.mjs +47 -0
  258. package/src/update/update-signed-version.d.mts +5 -0
  259. package/src/update/update-signed-version.mjs +25 -0
  260. package/src/update/update-trust-anchor.d.mts +2 -0
  261. package/src/update/update-trust-anchor.mjs +2 -0
  262. package/src/usage/cache-diagnostic.ts +195 -50
  263. package/src/usage/expected-prices.ts +20 -2
  264. package/src/usage/filter-index.ts +1469 -0
  265. package/src/usage/ledger-scanner.ts +245 -4
  266. package/src/usage/source-filter.ts +10 -2
  267. package/src/usage/summary.ts +16 -0
  268. package/src/web-search/parse.ts +265 -38
  269. package/gui/dist/assets/App-BepstgEN.js +0 -59
  270. package/gui/dist/assets/Tray-BinxbEZo.js +0 -1
  271. package/gui/dist/assets/brand-mark-wzPe3R-J.js +0 -1
  272. package/gui/dist/assets/index-C-9X2yaI.js +0 -94
  273. package/gui/dist/assets/index-bnUWypyz.css +0 -2
  274. package/gui/dist/classic/assets/App-DX88_GCW.js +0 -58
  275. package/gui/dist/classic/assets/index-fSP71pLB.js +0 -94
  276. package/gui/dist/classic/assets/quota-summary-y2fl0WBv.js +0 -1
@@ -0,0 +1,206 @@
1
+ import { isatty } from "node:tty";
2
+ import { PROFILE_AVATARS, isProfileAvatar, type ProfileRankV1 } from "../telemetry/profile/contract";
3
+ import { PROFILE_DISCLOSURE_HEADING, PROFILE_DISCLOSURE_POINTS } from "../telemetry/profile/disclosure";
4
+ import {
5
+ ProfileActionError,
6
+ buildProfileStatusSnapshot,
7
+ connectTelemetryProfile,
8
+ disconnectTelemetryProfile,
9
+ fetchConnectedProfileRank,
10
+ type ProfileStatusSnapshot,
11
+ } from "../telemetry/profile/service";
12
+ import { isAgentDriven } from "./agent-driven";
13
+ import { interactiveConfirm } from "./interactive-confirm";
14
+ import {
15
+ CliUsageError,
16
+ RuntimeApiError,
17
+ printData,
18
+ rejectArgs,
19
+ runCliAction,
20
+ runtimeRequest,
21
+ takeOption,
22
+ type RuntimeApiDeps,
23
+ } from "./runtime-api";
24
+
25
+ export const TELEMETRY_PROFILE_USAGE = `Usage:
26
+ ocx telemetry profile [status] [--json]
27
+ ocx telemetry profile connect --handle <handle> [--name <display name>] [--avatar <${PROFILE_AVATARS.join("|")}>] [--json]
28
+ ocx telemetry profile disconnect [--json]`;
29
+
30
+ export const PROFILE_CLI_DISCLOSURE_LINES = Object.freeze([
31
+ ` ${PROFILE_DISCLOSURE_HEADING}`,
32
+ ...PROFILE_DISCLOSURE_POINTS.map(point => ` • ${point}`),
33
+ ]);
34
+
35
+ export interface TelemetryProfileCliTestDeps {
36
+ interactiveConfirm?: typeof interactiveConfirm;
37
+ isTty?: () => boolean;
38
+ }
39
+
40
+ let testDeps: TelemetryProfileCliTestDeps | null = null;
41
+
42
+ export function setTelemetryProfileCliDepsForTests(deps: TelemetryProfileCliTestDeps | null): void {
43
+ testDeps = deps;
44
+ }
45
+
46
+ function isInteractiveTty(): boolean {
47
+ try {
48
+ return testDeps?.isTty ? testDeps.isTty() : Boolean(isatty(0) && isatty(1));
49
+ } catch {
50
+ return false;
51
+ }
52
+ }
53
+
54
+ function refuse(code: string, error: string, wantsJson: boolean): number {
55
+ if (wantsJson) console.log(JSON.stringify({ ok: false, code, error }, null, 2));
56
+ else console.error(`${code}: ${error}`);
57
+ return 1;
58
+ }
59
+
60
+ function rankLines(rank: ProfileRankV1 | null): string[] {
61
+ if (!rank) return [];
62
+ return (["day", "week", "month"] as const).map(period => {
63
+ const entry = rank.periods[period];
64
+ const position = entry.rank === null ? "not ranked yet" : `#${entry.rank} of ${entry.of}`;
65
+ return ` ${period.padEnd(5)} ${position} · ${entry.tokens.toLocaleString("en-US")} tokens · ${entry.requests.toLocaleString("en-US")} requests`;
66
+ });
67
+ }
68
+
69
+ function statusLines(snapshot: ProfileStatusSnapshot, rank: ProfileRankV1 | null): string[] {
70
+ if (snapshot.unreadable) {
71
+ return ["Public profile: the local profile file cannot be read; nothing is sent. Run 'ocx telemetry profile disconnect' for details."];
72
+ }
73
+ if (!snapshot.profile) {
74
+ return [
75
+ "Public profile: not connected.",
76
+ snapshot.telemetryEffective
77
+ ? "Connect one with 'ocx telemetry profile connect --handle <handle>' or from the dashboard Home."
78
+ : "Anonymous telemetry is off; a public profile needs it on.",
79
+ ];
80
+ }
81
+ const profile = snapshot.profile;
82
+ const state = profile.pendingDelete
83
+ ? "deletion pending (retried by the proxy)"
84
+ : profile.revoked
85
+ ? "revoked by the server; disconnect and connect again"
86
+ : snapshot.telemetryEffective
87
+ ? "connected"
88
+ : "paused while anonymous telemetry is off";
89
+ return [
90
+ `Public profile: @${profile.handle} (${profile.displayName}) — ${state}`,
91
+ `Connected: ${profile.connectedAt}; last sent day: ${profile.lastSentDay ?? "none yet"}`,
92
+ snapshot.preview
93
+ ? `Next submission (${snapshot.preview.day}): ${snapshot.preview.requests} requests, ${snapshot.preview.families.map(row => `${row.family} ${row.tokens} tokens`).join(", ")}; --json shows the exact payload`
94
+ : `Next submission: none due (${snapshot.nextDayReason})`,
95
+ ...rankLines(rank),
96
+ ];
97
+ }
98
+
99
+ async function readSnapshot(deps: RuntimeApiDeps): Promise<ProfileStatusSnapshot> {
100
+ try {
101
+ return await runtimeRequest<ProfileStatusSnapshot>("/api/telemetry/profile", {}, deps);
102
+ } catch {
103
+ return await buildProfileStatusSnapshot();
104
+ }
105
+ }
106
+
107
+ async function readRank(deps: RuntimeApiDeps): Promise<ProfileRankV1 | null> {
108
+ try {
109
+ const live = await runtimeRequest<{ rank?: ProfileRankV1 }>("/api/telemetry/profile/rank", {}, deps);
110
+ return live.rank ?? null;
111
+ } catch (error) {
112
+ if (error instanceof RuntimeApiError && error.status !== 503) return null;
113
+ const local = await fetchConnectedProfileRank();
114
+ return local.ok ? local.rank : null;
115
+ }
116
+ }
117
+
118
+ async function disconnect(deps: RuntimeApiDeps): Promise<{ status: string }> {
119
+ try {
120
+ return await runtimeRequest<{ status: string }>("/api/telemetry/profile", { method: "DELETE" }, deps);
121
+ } catch (error) {
122
+ // Only a stopped or unreachable proxy falls back; a refusal from a running proxy is reported.
123
+ if (error instanceof RuntimeApiError && error.status !== 503) throw error;
124
+ return await disconnectTelemetryProfile();
125
+ }
126
+ }
127
+
128
+ export async function handleTelemetryProfileCommand(argv: string[], wantsJson: boolean, deps: RuntimeApiDeps = {}): Promise<number> {
129
+ const args = [...argv];
130
+ const sub = (args.shift() ?? "status").toLowerCase();
131
+ if (sub === "connect") {
132
+ if (isAgentDriven()) {
133
+ return refuse(
134
+ "agent_consent_required",
135
+ "Refused: a public profile must be connected by a human user in their own interactive terminal or in the dashboard Home.",
136
+ wantsJson,
137
+ );
138
+ }
139
+ if (Boolean(process.env.OCX_SERVICE) || !isInteractiveTty()) {
140
+ return refuse(
141
+ "tty_required",
142
+ "Refused: 'ocx telemetry profile connect' requires an interactive human terminal (TTY stdin and stdout, not OCX_SERVICE). Connect in an interactive terminal or from the dashboard Home.",
143
+ wantsJson,
144
+ );
145
+ }
146
+ }
147
+ return runCliAction(async () => {
148
+ if (sub === "status") {
149
+ rejectArgs(args, TELEMETRY_PROFILE_USAGE);
150
+ const snapshot = await readSnapshot(deps);
151
+ const rank = snapshot.profile && !snapshot.profile.pendingDelete ? await readRank(deps) : null;
152
+ printData({ ...snapshot, rank }, wantsJson, statusLines(snapshot, rank));
153
+ return;
154
+ }
155
+ if (sub === "connect") {
156
+ const handle = takeOption(args, "--handle");
157
+ const name = takeOption(args, "--name");
158
+ const avatar = takeOption(args, "--avatar") ?? "blue";
159
+ rejectArgs(args, TELEMETRY_PROFILE_USAGE);
160
+ if (!handle) throw new CliUsageError("--handle is required", TELEMETRY_PROFILE_USAGE);
161
+ if (!isProfileAvatar(avatar)) throw new CliUsageError(`--avatar must be one of ${PROFILE_AVATARS.join(", ")}`, TELEMETRY_PROFILE_USAGE);
162
+ // Refuse before asking anything when the connect could not succeed.
163
+ const before = await buildProfileStatusSnapshot();
164
+ if (!before.telemetryEffective) {
165
+ throw new Error("telemetry_off: A public profile needs anonymous telemetry to be on: its totals come from the same daily aggregate.");
166
+ }
167
+ console.log(PROFILE_CLI_DISCLOSURE_LINES.join("\n"));
168
+ const ask = testDeps?.interactiveConfirm ?? interactiveConfirm;
169
+ const yes = await ask({ question: "\n Create this public profile? [y/N]", defaultYes: false });
170
+ if (!yes) throw new Error("Profile connect cancelled: confirmation was declined. Nothing was sent.");
171
+ try {
172
+ const profile = await connectTelemetryProfile({ handle, displayName: name ?? handle, avatar });
173
+ // A running proxy starts its profile loop when it next reads the profile status.
174
+ await runtimeRequest("/api/telemetry/profile", {}, deps).catch(() => undefined);
175
+ printData({ ok: true, profile }, wantsJson, [
176
+ `Public profile @${profile.handle} connected. Your first rank appears after the next completed UTC day.`,
177
+ ]);
178
+ } catch (error) {
179
+ if (error instanceof ProfileActionError) throw new Error(`${error.code}: ${error.message}`);
180
+ throw error;
181
+ }
182
+ return;
183
+ }
184
+ if (sub === "disconnect") {
185
+ rejectArgs(args, TELEMETRY_PROFILE_USAGE);
186
+ let outcome: { status: string };
187
+ try {
188
+ outcome = await disconnect(deps);
189
+ } catch (error) {
190
+ if (error instanceof ProfileActionError) throw new Error(`${error.code}: ${error.message}`);
191
+ throw error;
192
+ }
193
+ const line = outcome.status === "deleted"
194
+ ? "Public profile deleted on the server and disconnected."
195
+ : outcome.status === "not_connected"
196
+ ? "No public profile is connected."
197
+ : outcome.status === "local_removed"
198
+ ? "The unreadable local profile file was removed. Its secret could not be read, so the server profile was not deleted; it stops receiving data and is pruned after 400 days without submissions."
199
+ : "deletion_pending: the telemetry service could not be reached. Nothing more is sent; the proxy retries the deletion on every tick and on its next start.";
200
+ printData({ ok: true, ...outcome }, wantsJson, [line]);
201
+ return;
202
+ }
203
+ throw new CliUsageError(`unknown telemetry profile command ${sub}`, TELEMETRY_PROFILE_USAGE);
204
+ });
205
+ }
206
+
@@ -0,0 +1,260 @@
1
+ import { lstatSync, mkdirSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { isatty } from "node:tty";
4
+ import { getConfigDir, mutatePersistedConfig, readConfigDiagnostics } from "../config";
5
+ import { atomicWriteFileNoFollow } from "../config/atomic-write";
6
+ import { withConfigDirHardeningSettled } from "../config/paths";
7
+ import { recordOwnedConfigPath } from "../lib/config-ownership";
8
+ import { resolveTelemetryStatus } from "../telemetry/consent";
9
+ import { TELEMETRY_DISCLOSURE_HEADING, TELEMETRY_DISCLOSURE_POINTS } from "../telemetry/disclosure";
10
+ import { deleteTelemetryInstallId } from "../telemetry/install-id";
11
+ import { buildTelemetryStatusSnapshot, type TelemetryStatusSnapshot } from "../telemetry/routes";
12
+ import {
13
+ clearPendingTelemetryDecision,
14
+ recordPendingTelemetryDecision,
15
+ withPendingTelemetryDecision,
16
+ } from "../telemetry/scheduler";
17
+ import type { OcxTelemetryConfig, OcxTelemetryDecision } from "../types";
18
+ import { currentVersion } from "../update/index";
19
+ import { isAgentDriven } from "./agent-driven";
20
+ import { interactiveConfirm } from "./interactive-confirm";
21
+ import {
22
+ CliUsageError,
23
+ printData,
24
+ rejectArgs,
25
+ runCliAction,
26
+ runtimeRequest,
27
+ takeFlag,
28
+ type RuntimeApiDeps,
29
+ } from "./runtime-api";
30
+
31
+ const USAGE = `Usage:
32
+ ocx telemetry [status] [--json]
33
+ ocx telemetry enable [--json]
34
+ ocx telemetry disable [--json]
35
+ ocx telemetry profile [status|connect|disconnect] [--json]`;
36
+
37
+ export const TELEMETRY_DEFERRAL_FILE = ".telemetry-deferred";
38
+ const DEFERRAL_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
39
+
40
+ export const TELEMETRY_CLI_DISCLOSURE_LINES = Object.freeze([
41
+ ` ${TELEMETRY_DISCLOSURE_HEADING}`,
42
+ ...TELEMETRY_DISCLOSURE_POINTS.map(point => ` • ${point}`),
43
+ ]);
44
+
45
+ export function printTelemetryDisclosure(): void {
46
+ console.log(TELEMETRY_CLI_DISCLOSURE_LINES.join("\n"));
47
+ }
48
+
49
+ export function isTelemetryDeferralCurrent(record: string | null, version: string, now: number): boolean {
50
+ if (!record) return false;
51
+ const match = /^(\S+)\s+(\S+)\s*$/.exec(record.trim());
52
+ if (!match) return false;
53
+ const at = Date.parse(match[1]!);
54
+ if (Number.isNaN(at)) return false;
55
+ const age = now - at;
56
+ if (version !== "?" && match[2] === version) return age >= 0;
57
+ return age >= 0 && age < DEFERRAL_MAX_AGE_MS;
58
+ }
59
+
60
+ export interface TelemetryPromptTestDeps {
61
+ interactiveConfirm?: typeof interactiveConfirm;
62
+ isTty?: () => boolean;
63
+ }
64
+
65
+ let promptDepsForTests: TelemetryPromptTestDeps | null = null;
66
+
67
+ export function setTelemetryPromptDepsForTests(deps: TelemetryPromptTestDeps | null): void {
68
+ promptDepsForTests = deps;
69
+ }
70
+
71
+ function isInteractiveTty(): boolean {
72
+ try {
73
+ return promptDepsForTests?.isTty ? promptDepsForTests.isTty() : Boolean(isatty(0) && isatty(1));
74
+ } catch {
75
+ return false;
76
+ }
77
+ }
78
+
79
+ async function persistTelemetryDecision(decision: OcxTelemetryDecision): Promise<void> {
80
+ const nowIso = new Date().toISOString();
81
+ const dir = getConfigDir();
82
+ const mutate = () =>
83
+ mutatePersistedConfig(fresh => {
84
+ const prev = fresh.telemetry;
85
+ const next: OcxTelemetryConfig = {
86
+ decision,
87
+ decidedAt: nowIso,
88
+ noticeShownAt: prev?.noticeShownAt ?? nowIso,
89
+ };
90
+ const changed = JSON.stringify(prev) !== JSON.stringify(next);
91
+ fresh.telemetry = next;
92
+ return { changed, value: next };
93
+ });
94
+ const outcome = await withConfigDirHardeningSettled(dir, () => mutate());
95
+ if (outcome.status === "unavailable" && outcome.reason === "missing") {
96
+ // A fresh install has no config.json yet; the Windows installer's opt-out arrives exactly
97
+ // then. Creating the config would make `ocx init` skip setup, so hold the decision in
98
+ // telemetry-state.json; it applies until a decision is written into the config.
99
+ recordPendingTelemetryDecision({ decision, decidedAt: nowIso, noticeShownAt: nowIso }, dir);
100
+ } else if (outcome.status === "unavailable") {
101
+ throw new Error(
102
+ `Cannot update telemetry configuration: config.json is ${outcome.reason}. Fix or restore config.json before retrying.`,
103
+ );
104
+ } else {
105
+ clearPendingTelemetryDecision(dir);
106
+ }
107
+ if (decision === "declined") {
108
+ deleteTelemetryInstallId(dir);
109
+ }
110
+ }
111
+
112
+ /**
113
+ * One-time telemetry consent prompt for interactive starts (`ocx start`, `ocx service install`,
114
+ * `ocx init`). Under an agent-driven session, non-TTY, or `OCX_SERVICE=1`, prints a one-line
115
+ * notice at most once per version and records neither `noticeShownAt` nor `decision`.
116
+ */
117
+ export async function maybeShowTelemetryPrompt(): Promise<void> {
118
+ try {
119
+ const diagnostics = readConfigDiagnostics({ passive: true });
120
+ const status = resolveTelemetryStatus(withPendingTelemetryDecision(diagnostics.config), process.env);
121
+ if (status.envOverride !== null || status.decision !== null || status.noticeShownAt !== null) {
122
+ return;
123
+ }
124
+ const isTty = isInteractiveTty();
125
+ const dir = getConfigDir();
126
+ if (isAgentDriven() || !isTty || Boolean(process.env.OCX_SERVICE)) {
127
+ const deferralPath = join(dir, TELEMETRY_DEFERRAL_FILE);
128
+ let record: string | null = null;
129
+ try {
130
+ const stat = lstatSync(deferralPath);
131
+ if (stat.isFile() && !stat.isSymbolicLink() && stat.size <= 1024) {
132
+ record = readFileSync(deferralPath, "utf8");
133
+ }
134
+ } catch { /* best-effort */ }
135
+ const version = currentVersion();
136
+ if (isTelemetryDeferralCurrent(record, version, Date.now())) return;
137
+ console.log(
138
+ " ℹ️ Anonymous telemetry is awaiting human consent (run 'ocx telemetry status' or open the dashboard; disable anytime with 'ocx telemetry disable' or OCX_TELEMETRY=0).",
139
+ );
140
+ try {
141
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
142
+ recordOwnedConfigPath(dir, deferralPath);
143
+ atomicWriteFileNoFollow(deferralPath, `${new Date().toISOString()} ${version}\n`);
144
+ } catch { /* best-effort */ }
145
+ return;
146
+ }
147
+ printTelemetryDisclosure();
148
+ const ask = promptDepsForTests?.interactiveConfirm ?? interactiveConfirm;
149
+ const yes = await ask({
150
+ question: "\n Share anonymous usage statistics? [Y/n]",
151
+ defaultYes: true,
152
+ });
153
+ await persistTelemetryDecision(yes ? "accepted" : "declined");
154
+ } catch {
155
+ /* never disrupt startup or setup */
156
+ }
157
+ }
158
+
159
+ function formatStatusLines(snapshot: TelemetryStatusSnapshot): string[] {
160
+ return [
161
+ `Telemetry: ${snapshot.effective ? "enabled" : "disabled"} (${snapshot.reason})`,
162
+ `Decision: ${snapshot.decision ?? "undecided"}`,
163
+ ...(snapshot.envOverride ? [`Environment override: ${snapshot.envOverride}`] : []),
164
+ `Install channel: ${snapshot.installChannel}`,
165
+ `Last sent day: ${snapshot.lastSentDay ?? "never"}`,
166
+ ...(snapshot.stateUnreadable
167
+ ? ["Sending paused: telemetry-state.json cannot be read. Choosing again (ocx telemetry enable or disable) rebuilds it."]
168
+ : []),
169
+ `Preview eligible: ${snapshot.previewEligible ? "yes" : "no"}`,
170
+ snapshot.previewEligible
171
+ ? `Preview (${snapshot.preview.day}, next eligible send):`
172
+ : `Preview (${snapshot.preview.day}, sample only — not eligible to send):`,
173
+ JSON.stringify(snapshot.preview, null, 2),
174
+ ];
175
+ }
176
+
177
+ async function readLiveOrLocalSnapshot(deps: RuntimeApiDeps): Promise<TelemetryStatusSnapshot> {
178
+ try {
179
+ return await runtimeRequest("/api/telemetry", {}, deps) as TelemetryStatusSnapshot;
180
+ } catch {
181
+ const config = readConfigDiagnostics({ passive: true }).config;
182
+ return await buildTelemetryStatusSnapshot(config);
183
+ }
184
+ }
185
+
186
+ export async function handleTelemetryCommand(argv: string[], deps: RuntimeApiDeps = {}): Promise<number> {
187
+ const args = [...argv];
188
+ const wantsJson = takeFlag(args, "--json");
189
+ const sub = (args.shift() ?? "status").toLowerCase();
190
+ if (sub === "profile") {
191
+ if (args.includes("--json")) {
192
+ return runCliAction(async () => { throw new CliUsageError("telemetry flags may only be specified once", USAGE); });
193
+ }
194
+ const { handleTelemetryProfileCommand } = await import("./telemetry-profile");
195
+ return handleTelemetryProfileCommand(args, wantsJson, deps);
196
+ }
197
+ if (sub === "enable") {
198
+ if (isAgentDriven()) {
199
+ const error = {
200
+ ok: false,
201
+ code: "agent_consent_required",
202
+ error:
203
+ "Refused: telemetry consent must be enabled by a human user in their own interactive terminal or in the dashboard (Proxy details).",
204
+ };
205
+ if (wantsJson) console.log(JSON.stringify(error, null, 2));
206
+ else console.error(`${error.code}: ${error.error}`);
207
+ return 1;
208
+ }
209
+ if (Boolean(process.env.OCX_SERVICE) || !isInteractiveTty()) {
210
+ const error = {
211
+ ok: false,
212
+ code: "tty_required",
213
+ error:
214
+ "Refused: 'ocx telemetry enable' requires an interactive human terminal (TTY stdin and stdout, not OCX_SERVICE). Enable telemetry in an interactive terminal or in the dashboard (Proxy details).",
215
+ };
216
+ if (wantsJson) console.log(JSON.stringify(error, null, 2));
217
+ else console.error(`${error.code}: ${error.error}`);
218
+ return 1;
219
+ }
220
+ }
221
+ return runCliAction(async () => {
222
+ if (args.includes("--json")) {
223
+ throw new CliUsageError("telemetry flags may only be specified once", USAGE);
224
+ }
225
+ if (sub === "status") {
226
+ rejectArgs(args, USAGE);
227
+ const snapshot = await readLiveOrLocalSnapshot(deps);
228
+ printData(snapshot, wantsJson, formatStatusLines(snapshot));
229
+ return;
230
+ }
231
+ if (sub === "enable") {
232
+ rejectArgs(args, USAGE);
233
+ printTelemetryDisclosure();
234
+ const ask = promptDepsForTests?.interactiveConfirm ?? interactiveConfirm;
235
+ const yes = await ask({
236
+ question: "\n Share anonymous usage statistics? [Y/n]",
237
+ defaultYes: true,
238
+ });
239
+ if (!yes) {
240
+ throw new Error("Telemetry enable cancelled: confirmation was declined.");
241
+ }
242
+ await persistTelemetryDecision("accepted");
243
+ const snapshot = await buildTelemetryStatusSnapshot(readConfigDiagnostics({ passive: true }).config);
244
+ printData({ ok: true, ...snapshot }, wantsJson, ["Anonymous telemetry enabled."]);
245
+ return;
246
+ }
247
+ if (sub === "disable") {
248
+ rejectArgs(args, USAGE);
249
+ await persistTelemetryDecision("declined");
250
+ const snapshot = await buildTelemetryStatusSnapshot(readConfigDiagnostics({ passive: true }).config);
251
+ printData({ ok: true, ...snapshot }, wantsJson, [
252
+ "Anonymous telemetry disabled and local telemetry identifier removed.",
253
+ ]);
254
+ return;
255
+ }
256
+ throw new CliUsageError(`unknown telemetry command ${sub}`, USAGE);
257
+ });
258
+ }
259
+
260
+ export const TELEMETRY_USAGE = USAGE;
@@ -10,6 +10,8 @@ export const HUB_RELAY_REQUEST_BODY_MAX_BYTES = 4 * 1024 * 1024;
10
10
  export const HUB_RELAY_RESPONSE_BODY_MAX_BYTES = 16 * 1024 * 1024;
11
11
  export const HUB_RELAY_DEFAULT_TIMEOUT_MS = 15_000;
12
12
  export const HUB_RELAY_HEADER_MAX_BYTES = 64 * 1024;
13
+ export const HUB_RELAY_EXPECTED_TARGET_HEADER = "x-opencodex-expected-target";
14
+ export const HUB_RELAY_EXPECTED_TARGET_MAX_BYTES = 512;
13
15
 
14
16
  const ALLOWED_METHODS = new Set(["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"]);
15
17
  const REQUEST_HEADERS = new Set([
@@ -90,6 +92,12 @@ function canonicalOrigin(value: string): string | null {
90
92
  }
91
93
  }
92
94
 
95
+ /** A canonical HTTP(S) origin, no userinfo/path/query/fragment/trailing slash. */
96
+ function canonicalExpectedOrigin(value: string): string | null {
97
+ const origin = canonicalOrigin(value);
98
+ return origin && value === origin ? origin : null;
99
+ }
100
+
93
101
  function relayDestination(suffix: string, target: HubRelayTarget, method: string): URL | null {
94
102
  const origin = canonicalOrigin(target.managementUrl);
95
103
  const browserOrigin = canonicalOrigin(target.browserOrigin);
@@ -234,6 +242,24 @@ export async function relayHubManagementRequest(
234
242
  const requestHeaderValidation = validateHubRelayRequestHeaders([...req.headers]);
235
243
  if (!requestHeaderValidation.ok) return relayError(400, "hub relay request headers refused");
236
244
 
245
+ // The expected-target claim is checked against the same immutable target snapshot used
246
+ // for forwarding, before the body is read. Absence keeps the legacy caller contract.
247
+ const expectedTarget = req.headers.get(HUB_RELAY_EXPECTED_TARGET_HEADER);
248
+ if (expectedTarget !== null) {
249
+ if (expectedTarget.includes(",") || new TextEncoder().encode(expectedTarget).byteLength > HUB_RELAY_EXPECTED_TARGET_MAX_BYTES) {
250
+ return relayError(400, "invalid_expected_target");
251
+ }
252
+ const claimed = canonicalExpectedOrigin(expectedTarget);
253
+ const current = canonicalOrigin(target.managementUrl);
254
+ if (!claimed || !current) return relayError(400, "invalid_expected_target");
255
+ if (claimed !== current) {
256
+ return new Response(JSON.stringify({ error: "target_changed" }), {
257
+ status: 409,
258
+ headers: { "Content-Type": "application/json", "Cache-Control": "no-store" },
259
+ });
260
+ }
261
+ }
262
+
237
263
  let body: Uint8Array<ArrayBuffer> | null;
238
264
  try {
239
265
  body = method === "GET" || method === "HEAD"
@@ -15,6 +15,8 @@ export interface MachineStatusV1 {
15
15
  sharedBase: string;
16
16
  sharedServerOrigin: string;
17
17
  managementTransport: "direct" | "relay";
18
+ /** Present when this listener's relay can check an expected target before forwarding. */
19
+ relayTargetCheck?: "expected-target-v1";
18
20
  apiKeyId: string;
19
21
  protocolVersion: 1;
20
22
  connectedAt: string;
@@ -69,6 +71,7 @@ function statusPayload(req: Request, state: OcxClientConnectionConfig, deps: Mac
69
71
  sharedBase: relay ? `${machineBase}/api/machine/hub-relay` : state.managementUrl,
70
72
  sharedServerOrigin: linkMode ? machineBase : state.managementUrl,
71
73
  managementTransport: relay ? "relay" : state.managementTransport,
74
+ ...(relay && !linkMode ? { relayTargetCheck: "expected-target-v1" as const } : {}),
72
75
  apiKeyId: state.apiKeyId,
73
76
  protocolVersion: state.protocolVersion,
74
77
  connectedAt: state.connectedAt,
@@ -4,7 +4,7 @@ import { PROXY_MARKER } from "../../claude/auth-detect";
4
4
  import { isLoopbackHostname, shouldInjectApiAuthHeader } from "../../codex/loopback-target";
5
5
  import { resolveApiSurfaceSettings } from "../../protocols/settings";
6
6
  import { absoluteClientPath, ClientPathError } from "../client-path";
7
- import type { ExportContext, ManagedContribution, OpencodeLaunchEnv } from "./contracts";
7
+ import type { ExportContext, ExportModel, ManagedContribution, OpencodeLaunchEnv } from "./contracts";
8
8
  import { OPENCODE_PROVIDER_ID } from "./constants";
9
9
  import { normalizeExportModels, singleFragment } from "./model-metadata";
10
10
 
@@ -45,16 +45,28 @@ export interface T3CodeEnvironmentVariable {
45
45
  sensitive: false;
46
46
  }
47
47
 
48
+ /** T3 Code's `ModelCapabilities`: the options a thread or subagent may select for this model. */
49
+ export interface T3CodeModelCapabilities {
50
+ optionDescriptors: {
51
+ id: "effort";
52
+ label: string;
53
+ type: "select";
54
+ options: { id: string; label: string; isDefault?: true }[];
55
+ }[];
56
+ }
57
+
48
58
  /** One T3 Code `CustomModelEntry`: the slug is sent verbatim as the Claude model id. */
49
59
  export interface T3CodeCustomModel {
50
60
  slug: string;
51
61
  name: string;
62
+ capabilities?: T3CodeModelCapabilities;
52
63
  }
53
64
 
54
65
  /** The `providerInstances.opencodex` value opencodex owns in T3 Code's settings.json. */
55
66
  export interface T3CodeProviderInstance {
56
67
  driver: "claudeAgent";
57
68
  displayName: string;
69
+ accentColor: string;
58
70
  environment: T3CodeEnvironmentVariable[];
59
71
  config: { customModels: T3CodeCustomModel[] };
60
72
  }
@@ -92,6 +104,7 @@ function t3codeDocument(ctx: ExportContext): T3CodeGeneratedConfig {
92
104
  [OPENCODE_PROVIDER_ID]: {
93
105
  driver: "claudeAgent",
94
106
  displayName: "opencodex",
107
+ accentColor: T3CODE_ACCENT_COLOR,
95
108
  environment: [
96
109
  variable("ANTHROPIC_BASE_URL", origin),
97
110
  variable("ANTHROPIC_AUTH_TOKEN", PROXY_MARKER),
@@ -99,16 +112,42 @@ function t3codeDocument(ctx: ExportContext): T3CodeGeneratedConfig {
99
112
  variable("CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST", "1"),
100
113
  ],
101
114
  config: {
102
- customModels: models.map(model => ({
103
- slug: model.namespaced,
104
- name: model.displayName || model.namespaced,
105
- })),
115
+ customModels: models.map(model => {
116
+ const capabilities = t3codeCapabilities(model);
117
+ return {
118
+ slug: model.namespaced,
119
+ name: model.displayName || model.namespaced,
120
+ ...(capabilities ? { capabilities } : {}),
121
+ };
122
+ }),
106
123
  },
107
124
  },
108
125
  },
109
126
  };
110
127
  }
111
128
 
129
+ /** Tints the instance's badge. T3 Code picks the icon from the driver, so this is all that sets it apart from Claude. */
130
+ const T3CODE_ACCENT_COLOR = "#a6a6a6";
131
+
132
+ /** The efforts Claude Code's `--effort` accepts, labelled the way T3 Code labels its built-in models. */
133
+ const T3CODE_EFFORT_LABELS: Readonly<Record<string, string>> = {
134
+ low: "Low", medium: "Medium", high: "High", xhigh: "Extra High", max: "Max",
135
+ };
136
+
137
+ /**
138
+ * T3 Code rejects any option a custom model does not declare, so a model exported without
139
+ * this cannot be started with an effort at all. A model with no usable effort declares nothing.
140
+ */
141
+ function t3codeCapabilities(model: ExportModel): T3CodeModelCapabilities | undefined {
142
+ if (model.supportsReasoningEffort === false) return undefined;
143
+ const options = (model.reasoningEfforts ?? []).flatMap(id => {
144
+ const label = T3CODE_EFFORT_LABELS[id];
145
+ if (!label) return [];
146
+ return [{ id, label, ...(id === model.defaultReasoningEffort ? { isDefault: true as const } : {}) }];
147
+ });
148
+ return options.length ? { optionDescriptors: [{ id: "effort", label: "Reasoning", type: "select", options }] } : undefined;
149
+ }
150
+
112
151
  /** Refuses any listener that needs an admission header: T3 Code would send only the marker. */
113
152
  export function buildT3CodeClientConfig(ctx: ExportContext): T3CodeGeneratedConfig {
114
153
  if (shouldInjectApiAuthHeader(ctx.config) || !isLoopbackHostname(new URL(ctx.baseUrl).hostname)) {
@@ -76,7 +76,7 @@ function load(path: string): Loaded {
76
76
  }
77
77
  if (hasJsoncComments(text)) return { kind: "comments" };
78
78
  try {
79
- const doc = parseJsonc(text.replace(/^\ufeff/, ""));
79
+ const doc = parseJsonc(text);
80
80
  return isObject(doc) ? { kind: "document", text, doc } : { kind: "invalid" };
81
81
  } catch {
82
82
  return { kind: "invalid" };