omnicell-router 0.7.0 → 0.8.2

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 (246) hide show
  1. package/backend/dist/cli/clients/activity.d.ts +35 -0
  2. package/backend/dist/cli/clients/activity.js +67 -0
  3. package/backend/dist/cli/clients/base.d.ts +13 -2
  4. package/backend/dist/cli/clients/claude.d.ts +2 -2
  5. package/backend/dist/cli/clients/codex.d.ts +2 -2
  6. package/backend/dist/cli/clients/core-adapters.d.ts +3 -4
  7. package/backend/dist/cli/clients/core-adapters.js +3 -4
  8. package/backend/dist/cli/clients/cursor-proxy.d.ts +88 -0
  9. package/backend/dist/cli/clients/cursor-proxy.js +421 -0
  10. package/backend/dist/cli/clients/dsh.d.ts +2 -2
  11. package/backend/dist/cli/clients/grok.d.ts +2 -2
  12. package/backend/dist/cli/clients/index.d.ts +8 -1
  13. package/backend/dist/cli/clients/index.js +55 -21
  14. package/backend/dist/cli/clients/kimi.d.ts +2 -2
  15. package/backend/dist/cli/clients/launcher.d.ts +8 -0
  16. package/backend/dist/cli/clients/model-meta.js +1 -1
  17. package/backend/dist/cli/clients/omp.d.ts +2 -2
  18. package/backend/dist/cli/clients/openclaw.d.ts +2 -2
  19. package/backend/dist/cli/clients/opencode-proxy.d.ts +11 -0
  20. package/backend/dist/cli/clients/opencode-proxy.js +351 -0
  21. package/backend/dist/cli/clients/opencode.d.ts +2 -2
  22. package/backend/dist/cli/clients/pi.d.ts +2 -2
  23. package/backend/dist/cli/clients/plugin-adapters.d.ts +3 -1
  24. package/backend/dist/cli/clients/plugin-adapters.js +6 -29
  25. package/backend/dist/cli/clients/qoder-proxy.d.ts +84 -0
  26. package/backend/dist/cli/clients/qoder-proxy.js +497 -0
  27. package/backend/dist/cli/clients/reserved.d.ts +2 -6
  28. package/backend/dist/cli/clients/reserved.js +2 -0
  29. package/backend/dist/cli/clients/workbuddy.d.ts +2 -2
  30. package/backend/dist/cli/index.js +60 -9
  31. package/backend/dist/cli/types.d.ts +29 -8
  32. package/backend/dist/compression/caveman-prompts.d.ts +1 -1
  33. package/backend/dist/config/comments-en.js +6 -12
  34. package/backend/dist/config/comments-zh.js +6 -12
  35. package/backend/dist/config/defaults.d.ts +56 -1
  36. package/backend/dist/config/defaults.js +68 -0
  37. package/backend/dist/config/index.d.ts +9 -2
  38. package/backend/dist/config/index.js +26 -3
  39. package/backend/dist/config/types.d.ts +55 -43
  40. package/backend/dist/forward-proxy/egress.d.ts +10 -2
  41. package/backend/dist/forward-proxy/egress.js +42 -4
  42. package/backend/dist/forward-proxy/ordered-relay.d.ts +29 -0
  43. package/backend/dist/forward-proxy/ordered-relay.js +46 -0
  44. package/backend/dist/forward-proxy/rules.d.ts +66 -19
  45. package/backend/dist/forward-proxy/rules.js +61 -14
  46. package/backend/dist/forward-proxy/server.js +226 -77
  47. package/backend/dist/forward-proxy/system-proxy.d.ts +42 -2
  48. package/backend/dist/forward-proxy/system-proxy.js +199 -22
  49. package/backend/dist/harness/common/market.d.ts +3 -3
  50. package/backend/dist/harness/host/adapters/amp.d.ts +1 -1
  51. package/backend/dist/harness/host/adapters/antigravity.d.ts +1 -1
  52. package/backend/dist/harness/host/adapters/claude.d.ts +1 -1
  53. package/backend/dist/harness/host/adapters/cline.d.ts +1 -1
  54. package/backend/dist/harness/host/adapters/codex.d.ts +1 -1
  55. package/backend/dist/harness/host/adapters/cursor.d.ts +1 -1
  56. package/backend/dist/harness/host/adapters/dsh.d.ts +2 -2
  57. package/backend/dist/harness/host/adapters/factory.d.ts +1 -1
  58. package/backend/dist/harness/host/adapters/gemini-cli.d.ts +1 -1
  59. package/backend/dist/harness/host/adapters/grok.d.ts +1 -1
  60. package/backend/dist/harness/host/adapters/kimi.d.ts +1 -1
  61. package/backend/dist/harness/host/adapters/omp.d.ts +1 -1
  62. package/backend/dist/harness/host/adapters/openclaw.d.ts +1 -1
  63. package/backend/dist/harness/host/adapters/opencode.d.ts +1 -1
  64. package/backend/dist/harness/host/adapters/pi.d.ts +1 -1
  65. package/backend/dist/harness/host/adapters/universal.d.ts +1 -1
  66. package/backend/dist/harness/host/adapters/windsurf.d.ts +1 -1
  67. package/backend/dist/harness/host/adapters/zed.d.ts +1 -1
  68. package/backend/dist/harness/skill/skills-sh.d.ts +1 -1
  69. package/backend/dist/harness/translation.js +64 -21
  70. package/backend/dist/harness/types.d.ts +1 -1
  71. package/backend/dist/harness/types.js +1 -1
  72. package/backend/dist/index.js +31 -18
  73. package/backend/dist/ir/adapters/anthropic-stream.d.ts +18 -0
  74. package/backend/dist/ir/adapters/anthropic-stream.js +247 -0
  75. package/backend/dist/ir/adapters/anthropic.d.ts +29 -0
  76. package/backend/dist/ir/adapters/anthropic.js +788 -0
  77. package/backend/dist/ir/adapters/chat.d.ts +15 -0
  78. package/backend/dist/ir/adapters/chat.js +602 -0
  79. package/backend/dist/ir/adapters/google-stream.d.ts +22 -0
  80. package/backend/dist/ir/adapters/google-stream.js +242 -0
  81. package/backend/dist/ir/adapters/google.d.ts +9 -0
  82. package/backend/dist/ir/adapters/google.js +317 -0
  83. package/backend/dist/ir/adapters/openai-responses-output.js +8 -5
  84. package/backend/dist/ir/adapters/openai-responses.d.ts +15 -0
  85. package/backend/dist/ir/adapters/openai-responses.js +26 -1
  86. package/backend/dist/ir/adapters/responses-output.d.ts +50 -0
  87. package/backend/dist/ir/adapters/responses-output.js +348 -0
  88. package/backend/dist/ir/adapters/responses-stream.d.ts +12 -0
  89. package/backend/dist/ir/adapters/responses-stream.js +178 -0
  90. package/backend/dist/ir/adapters/responses.d.ts +14 -0
  91. package/backend/dist/ir/adapters/responses.js +646 -0
  92. package/backend/dist/ir/errors.d.ts +2 -2
  93. package/backend/dist/ir/types.d.ts +2 -1
  94. package/backend/dist/metrics/request-cost.d.ts +11 -2
  95. package/backend/dist/metrics/request-cost.js +12 -3
  96. package/backend/dist/observability/request-identity.d.ts +1 -1
  97. package/backend/dist/observability/trace-id.d.ts +40 -0
  98. package/backend/dist/observability/trace-id.js +134 -0
  99. package/backend/dist/observability/upstream-events.d.ts +82 -60
  100. package/backend/dist/observability/upstream-events.js +142 -67
  101. package/backend/dist/opencode/catalog/types.d.ts +9 -0
  102. package/backend/dist/opencode/credentials/types.d.ts +2 -2
  103. package/backend/dist/opencode/probe.d.ts +24 -1
  104. package/backend/dist/opencode/probe.js +28 -4
  105. package/backend/dist/opencode/user-config.d.ts +5 -0
  106. package/backend/dist/pipeline/directives.d.ts +6 -2
  107. package/backend/dist/pipeline/directives.js +7 -3
  108. package/backend/dist/pipeline/orchestrator.d.ts +28 -27
  109. package/backend/dist/pipeline/orchestrator.js +220 -194
  110. package/backend/dist/pipeline/unresolved-model.d.ts +33 -0
  111. package/backend/dist/pipeline/unresolved-model.js +43 -0
  112. package/backend/dist/plugins/catalog-def.d.ts +143 -0
  113. package/backend/dist/plugins/catalog-def.js +177 -0
  114. package/backend/dist/plugins/gateways.d.ts +62 -3
  115. package/backend/dist/plugins/gateways.js +139 -2
  116. package/backend/dist/plugins/host.d.ts +42 -5
  117. package/backend/dist/plugins/host.js +454 -38
  118. package/backend/dist/plugins/manifest.d.ts +119 -10
  119. package/backend/dist/plugins/manifest.js +265 -14
  120. package/backend/dist/plugins/pack.js +26 -0
  121. package/backend/dist/plugins/types.d.ts +187 -21
  122. package/backend/dist/protocols/systemone/convert.d.ts +1 -0
  123. package/backend/dist/protocols/systemone/convert.js +6 -1
  124. package/backend/dist/protocols/systemone/decide.js +18 -8
  125. package/backend/dist/providers/anthropic-messages.d.ts +12 -0
  126. package/backend/dist/providers/anthropic-messages.js +53 -0
  127. package/backend/dist/providers/anthropic.d.ts +7 -8
  128. package/backend/dist/providers/anthropic.js +36 -324
  129. package/backend/dist/providers/base.d.ts +14 -2
  130. package/backend/dist/providers/boot-direct.js +68 -38
  131. package/backend/dist/providers/dispatch.d.ts +5 -19
  132. package/backend/dist/providers/dispatch.js +46 -58
  133. package/backend/dist/providers/executors/anthropic-messages.d.ts +1 -0
  134. package/backend/dist/providers/executors/anthropic-messages.js +3 -0
  135. package/backend/dist/providers/executors/dispatch.d.ts +16 -2
  136. package/backend/dist/providers/executors/dispatch.js +39 -9
  137. package/backend/dist/providers/executors/google-gemini.d.ts +1 -0
  138. package/backend/dist/providers/executors/google-gemini.js +3 -0
  139. package/backend/dist/providers/executors/http-stream.js +16 -3
  140. package/backend/dist/providers/executors/openai-chat.d.ts +1 -0
  141. package/backend/dist/providers/executors/openai-chat.js +3 -0
  142. package/backend/dist/providers/executors/openai-responses.d.ts +1 -0
  143. package/backend/dist/providers/executors/openai-responses.js +3 -0
  144. package/backend/dist/providers/executors/plugin-adapter.js +4 -4
  145. package/backend/dist/providers/google-gemini.d.ts +12 -0
  146. package/backend/dist/providers/google-gemini.js +50 -0
  147. package/backend/dist/providers/google.d.ts +7 -8
  148. package/backend/dist/providers/google.js +35 -308
  149. package/backend/dist/providers/http-json.d.ts +19 -0
  150. package/backend/dist/providers/http-json.js +104 -0
  151. package/backend/dist/providers/http-stream.d.ts +52 -0
  152. package/backend/dist/providers/http-stream.js +423 -0
  153. package/backend/dist/providers/member-match.d.ts +4 -5
  154. package/backend/dist/providers/member-match.js +4 -5
  155. package/backend/dist/providers/openai-chat.d.ts +13 -0
  156. package/backend/dist/providers/openai-chat.js +99 -0
  157. package/backend/dist/providers/openai-compatible.d.ts +7 -4
  158. package/backend/dist/providers/openai-compatible.js +71 -368
  159. package/backend/dist/providers/openai-responses.d.ts +12 -0
  160. package/backend/dist/providers/openai-responses.js +68 -0
  161. package/backend/dist/providers/opencode-proxy.d.ts +5 -5
  162. package/backend/dist/providers/opencode-proxy.js +49 -125
  163. package/backend/dist/providers/plugin-adapter.d.ts +9 -0
  164. package/backend/dist/providers/plugin-adapter.js +31 -0
  165. package/backend/dist/providers/registry.d.ts +49 -24
  166. package/backend/dist/providers/registry.js +97 -55
  167. package/backend/dist/providers/responses.d.ts +7 -28
  168. package/backend/dist/providers/responses.js +45 -253
  169. package/backend/dist/providers/tool-markup-leak.d.ts +41 -0
  170. package/backend/dist/providers/tool-markup-leak.js +57 -0
  171. package/backend/dist/providers/tool-markup-recovery.d.ts +27 -0
  172. package/backend/dist/providers/tool-markup-recovery.js +786 -0
  173. package/backend/dist/providers/virtual-meta.d.ts +21 -2
  174. package/backend/dist/providers/virtual-meta.js +49 -9
  175. package/backend/dist/proxy/asset-download.d.ts +54 -0
  176. package/backend/dist/proxy/asset-download.js +420 -0
  177. package/backend/dist/proxy/manual-node-spec.d.ts +16 -16
  178. package/backend/dist/proxy/mihomo-binary.d.ts +17 -2
  179. package/backend/dist/proxy/mihomo-binary.js +62 -51
  180. package/backend/dist/proxy/mihomo-client.js +15 -1
  181. package/backend/dist/proxy/mihomo-config.js +11 -2
  182. package/backend/dist/proxy/mihomo-geo.d.ts +87 -0
  183. package/backend/dist/proxy/mihomo-geo.js +213 -0
  184. package/backend/dist/proxy/mihomo-logs.d.ts +27 -0
  185. package/backend/dist/proxy/mihomo-logs.js +70 -0
  186. package/backend/dist/proxy/mihomo-pac.d.ts +11 -0
  187. package/backend/dist/proxy/mihomo-pac.js +15 -0
  188. package/backend/dist/proxy/mihomo-rules-import.d.ts +1 -1
  189. package/backend/dist/proxy/mihomo-rules-import.js +7 -7
  190. package/backend/dist/proxy/mihomo-sidecar.d.ts +17 -1
  191. package/backend/dist/proxy/mihomo-sidecar.js +148 -26
  192. package/backend/dist/quota/adapters/minimax.js +36 -13
  193. package/backend/dist/quota/cli-login.d.ts +8 -0
  194. package/backend/dist/quota/cli-login.js +18 -0
  195. package/backend/dist/quota/declarations.js +10 -0
  196. package/backend/dist/quota/dsl.js +18 -5
  197. package/backend/dist/quota/engine.d.ts +22 -1
  198. package/backend/dist/quota/engine.js +170 -29
  199. package/backend/dist/quota/prober.d.ts +5 -0
  200. package/backend/dist/quota/prober.js +11 -2
  201. package/backend/dist/quota/types.d.ts +87 -8
  202. package/backend/dist/quota/verdict.d.ts +35 -0
  203. package/backend/dist/quota/verdict.js +135 -0
  204. package/backend/dist/ratelimit/admission.d.ts +131 -0
  205. package/backend/dist/ratelimit/admission.js +233 -0
  206. package/backend/dist/ratelimit/rate-limiter.js +6 -0
  207. package/backend/dist/resilience/types.d.ts +2 -2
  208. package/backend/dist/router/layer2-decision.d.ts +1 -1
  209. package/backend/dist/router/layer2-decision.js +5 -8
  210. package/backend/dist/routes/console.js +248 -52
  211. package/backend/dist/routes/mihomo.d.ts +2 -0
  212. package/backend/dist/routes/mihomo.js +334 -29
  213. package/backend/dist/routes/responses.d.ts +87 -8
  214. package/backend/dist/routes/responses.js +314 -33
  215. package/backend/dist/server.js +34 -6
  216. package/backend/dist/session/session-manager.d.ts +6 -0
  217. package/backend/dist/session/session-manager.js +20 -9
  218. package/backend/dist/surfaces/chat-pipeline.d.ts +2 -2
  219. package/backend/dist/surfaces/chat-pipeline.js +17 -7
  220. package/backend/dist/surfaces/chat.js +15 -0
  221. package/backend/dist/surfaces/decision-pipeline.js +7 -10
  222. package/backend/dist/surfaces/direct-forward.d.ts +3 -0
  223. package/backend/dist/surfaces/direct-forward.js +206 -0
  224. package/backend/dist/surfaces/rate-limit-response.d.ts +17 -0
  225. package/backend/dist/surfaces/rate-limit-response.js +57 -0
  226. package/backend/dist/surfaces/types.d.ts +11 -0
  227. package/backend/dist/trace/tracker.d.ts +32 -1
  228. package/backend/dist/trace/tracker.js +29 -4
  229. package/backend/dist/types/router.d.ts +34 -12
  230. package/backend/dist/types/router.js +35 -6
  231. package/backend/dist/utils/chat-stream.d.ts +21 -8
  232. package/backend/dist/utils/chat-stream.js +46 -9
  233. package/backend/dist/utils/event-ring.d.ts +4 -0
  234. package/backend/dist/utils/event-ring.js +4 -0
  235. package/backend/dist/utils/popularity.js +29 -4
  236. package/backend/dist/utils/proxy.d.ts +7 -0
  237. package/backend/dist/utils/proxy.js +35 -10
  238. package/backend/dist/utils/retry-after.d.ts +21 -0
  239. package/backend/dist/utils/retry-after.js +36 -0
  240. package/bin/ocr.js +2 -2
  241. package/frontend/dist/assets/index-55VVwfFQ.js +1521 -0
  242. package/frontend/dist/assets/{index-CQSLGFTV.css → index-DxZ9MHKB.css} +1 -1
  243. package/frontend/dist/assets/workbuddy.color-DOMpQkxJ.svg +29 -0
  244. package/frontend/dist/index.html +2 -2
  245. package/package.json +1 -1
  246. package/frontend/dist/assets/index-CLvxJjp_.js +0 -1476
@@ -2,6 +2,7 @@ import { isModelAllowed, tierFromVirtualEntry } from '../auth/model-access.js';
2
2
  import { loadConfig } from '../config/index.js';
3
3
  import { SessionManager } from '../session/session-manager.js';
4
4
  import { emitClientRequest, captureKeyIdentity, setClientExchangeContext } from '../observability/http-exchange.js';
5
+ import { UpstreamEventContext } from '../observability/upstream-events.js';
5
6
  import { NO_TURN } from '../capture/turn-boundary.js';
6
7
  import { resolveClientRequestId, mintRequestId } from '../observability/request-identity.js';
7
8
  import { runSystemoneDecision } from '../protocols/systemone/decide.js';
@@ -149,16 +150,12 @@ export async function runDecisionSurface(t, orchestrator, body) {
149
150
  : undefined;
150
151
  // Gateway-owned per-request id (ADR-0021) — the capture turn-join key.
151
152
  const requestId = mintRequestId();
152
- // sessionId: archive key ONLY (same SessionManager entry the chat leg
153
- // pre-resolves through; no ratchet, no turn registration).
153
+ // File name only. A header the caller already sent groups the archive
154
+ // with that conversation; otherwise the request id names the file.
155
+ // This does not resolve or register a session.
154
156
  const keyId = captureKeyIdentity(pctx.fastifyRequest ?? pctx.clientRequest)?.id;
155
157
  const decisionRequest = buildDecisionRequest(sysBody, effective);
156
- const sessionId = orchestrator
157
- .getSessionManager()
158
- .resolveSessionId(decisionRequest, {
159
- keyId,
160
- headers: t.headers,
161
- }).sessionId;
158
+ const sessionId = SessionManager.explicitSessionId(t.headers) ?? requestId;
162
159
  const conversationKey = SessionManager.conversationKey(decisionRequest.input, keyId) ?? undefined;
163
160
  const clientExchangeCtx = emitClientRequest({
164
161
  recorder,
@@ -181,7 +178,7 @@ export async function runDecisionSurface(t, orchestrator, body) {
181
178
  // Upstream leg shares the client-leg identity. Set only AFTER the client
182
179
  // event durably landed — a client-side failure keeps both legs silent
183
180
  // (consistent pairing, no orphan upstream events).
184
- upstreamEventContext = {
181
+ upstreamEventContext = new UpstreamEventContext({
185
182
  recorder,
186
183
  sessionId,
187
184
  clientRequestId,
@@ -190,7 +187,7 @@ export async function runDecisionSurface(t, orchestrator, body) {
190
187
  apiKey: captureKeyIdentity(pctx.fastifyRequest),
191
188
  conversationKey,
192
189
  turn: NO_TURN,
193
- };
190
+ });
194
191
  }
195
192
  catch (captureErr) {
196
193
  // Non-fatal: decision proceeds unrecorded on any capture failure.
@@ -0,0 +1,3 @@
1
+ import type { DirectForwardPlan } from '../types/router.js';
2
+ import type { TransportContext } from './types.js';
3
+ export declare function relayDirectForward(t: TransportContext, plan: DirectForwardPlan): Promise<void>;
@@ -0,0 +1,206 @@
1
+ import http from 'node:http';
2
+ import https from 'node:https';
3
+ import net from 'node:net';
4
+ import { FORWARD_PROXY_HANG_TIMEOUT_MS } from '../config/defaults.js';
5
+ import { filterHeaders, openViaProxy, parseProxy, transitEgressFor, transitProxyFor, upstreamServernameOption, } from '../forward-proxy/egress.js';
6
+ import { emitUpstreamFailureOnce, emitUpstreamRequestOnce, emitUpstreamResponseOnce, } from '../observability/upstream-events.js';
7
+ /**
8
+ * The `direct` unresolved-model executor (ADR-0003 §7a) — the pipeline-side
9
+ * verbatim relay. The turn has already run THROUGH the pipeline (normalization,
10
+ * session id, compression, client-leg capture); this helper performs the one
11
+ * thing the pipeline's provider executors cannot: an HTTP round trip to the
12
+ * ORIGINAL destination with the client's own auth headers and the origin wire
13
+ * body, then hands the origin response to the transport's raw relay
14
+ * (`t.relayUpstream`) — JSON or SSE alike, byte-verbatim.
15
+ *
16
+ * Egress follows the SAME rule table as the forward proxy's own legs
17
+ * (ADR-0018 — this is client traffic, so `forwardProxy.rules` owns it;
18
+ * CONNECT tunnel for https targets). `reject` is an admission gate for the
19
+ * proxy listener, not a relay veto, so it degrades to direct here.
20
+ * Upstream-leg capture fires here (request once the target is known, response
21
+ * on completion) with the provenance orchestrator attached to the plan.
22
+ */
23
+ const DIRECT_RELAY_BODY_CAP = 80_000;
24
+ export async function relayDirectForward(t, plan) {
25
+ let u;
26
+ try {
27
+ u = new URL(plan.url);
28
+ }
29
+ catch {
30
+ t.sendJson(502, { error: { message: `Direct forward: invalid original destination URL '${plan.url}'` } });
31
+ return;
32
+ }
33
+ const secure = u.protocol === 'https:';
34
+ const port = Number(u.port) || (secure ? 443 : 80);
35
+ const headers = { ...plan.requestHeaders, host: u.host };
36
+ const captureCtx = plan.capture?.recorder.isEnabled() ? plan.capture : undefined;
37
+ const exchangeId = emitUpstreamRequestOnce(captureCtx, {
38
+ url: plan.url,
39
+ method: 'POST',
40
+ requestHeaders: headers,
41
+ requestBody: plan.requestBody,
42
+ });
43
+ await new Promise((resolve) => {
44
+ const fail = (status, message, err) => {
45
+ emitUpstreamFailureOnce(captureCtx, {
46
+ exchangeId,
47
+ url: plan.url,
48
+ method: 'POST',
49
+ status,
50
+ statusText: 'Bad Gateway',
51
+ error: err instanceof Error ? err.message : String(err ?? message),
52
+ });
53
+ t.sendJson(status, { error: { message } });
54
+ resolve();
55
+ };
56
+ const onOriginResponse = (up) => {
57
+ // The egress caller clears the hang-protection timer before calling
58
+ // this (SSE direct turns stream for minutes — never killed mid-flight).
59
+ let body = '';
60
+ const firstByteTs = Date.now();
61
+ up.on('data', (chunk) => {
62
+ if (body.length < DIRECT_RELAY_BODY_CAP)
63
+ body = (body + chunk.toString('utf8')).slice(0, DIRECT_RELAY_BODY_CAP);
64
+ });
65
+ up.on('end', () => {
66
+ emitUpstreamResponseOnce(captureCtx, {
67
+ exchangeId,
68
+ url: plan.url,
69
+ method: 'POST',
70
+ status: up.statusCode || 502,
71
+ statusText: up.statusMessage || '',
72
+ responseHeaders: nodeHeadersToFetch(up.headers),
73
+ responseBody: body,
74
+ firstByteTs,
75
+ });
76
+ resolve();
77
+ });
78
+ up.on('error', (err) => {
79
+ emitUpstreamFailureOnce(captureCtx, {
80
+ exchangeId,
81
+ url: plan.url,
82
+ method: 'POST',
83
+ status: up.statusCode || 502,
84
+ statusText: up.statusMessage || '',
85
+ responseHeaders: nodeHeadersToFetch(up.headers),
86
+ responseBody: body,
87
+ error: err?.message || 'upstream response stream error',
88
+ });
89
+ resolve();
90
+ });
91
+ t.relayUpstream({
92
+ statusCode: up.statusCode || 502,
93
+ statusMessage: up.statusMessage,
94
+ headers: filterHeaders(up.headers),
95
+ stream: up,
96
+ });
97
+ };
98
+ /** Each egress mode clears its own hang guard once headers arrive. */
99
+ const onHeaders = (upstream) => (up) => {
100
+ upstream.setTimeout(0);
101
+ onOriginResponse(up);
102
+ };
103
+ const hangGuard = (upstream) => {
104
+ // Applies only until response headers arrive (cleared in onHeaders).
105
+ upstream.setTimeout(FORWARD_PROXY_HANG_TIMEOUT_MS, () => {
106
+ upstream.destroy(new Error('upstream timeout'));
107
+ });
108
+ };
109
+ const egress = transitEgressFor(u.hostname);
110
+ const proxyUrl = transitProxyFor(egress.proxy);
111
+ if (!proxyUrl) {
112
+ const transport = secure ? https : http;
113
+ const upstream = transport.request({
114
+ host: u.hostname,
115
+ port,
116
+ method: 'POST',
117
+ path: `${u.pathname}${u.search}`,
118
+ headers,
119
+ ...(secure ? upstreamServernameOption(u.hostname) : {}),
120
+ }, (up) => onHeaders(upstream)(up));
121
+ hangGuard(upstream);
122
+ upstream.on('error', (err) => {
123
+ const timedOut = err?.message === 'upstream timeout';
124
+ fail(timedOut ? 504 : 502, timedOut ? 'Direct forward: upstream timed out (target unreachable from this machine?)' : `Direct forward: upstream connection failed (${err.message})`, err);
125
+ });
126
+ upstream.end(plan.requestBody);
127
+ return;
128
+ }
129
+ const p = parseProxy(proxyUrl);
130
+ if (!p) {
131
+ fail(502, 'Direct forward: invalid outbound proxy url');
132
+ return;
133
+ }
134
+ if (!secure) {
135
+ // Plain-HTTP target via the outbound proxy (absolute-URI request form).
136
+ const upstream = http.request({
137
+ host: p.host,
138
+ port: p.port,
139
+ method: 'POST',
140
+ path: plan.url,
141
+ headers: { ...headers, ...(p.auth ? { 'proxy-authorization': p.auth } : {}) },
142
+ });
143
+ hangGuard(upstream);
144
+ upstream.on('error', (err) => fail(502, `Direct forward: upstream connection failed via outbound proxy (${err.message})`, err));
145
+ upstream.on('response', (up) => onHeaders(upstream)(up));
146
+ upstream.end(plan.requestBody);
147
+ return;
148
+ }
149
+ // HTTPS target: CONNECT tunnel → one-shot loopback relay → https.request
150
+ // over the relay (TLS end-to-end; the real target cert is validated).
151
+ openViaProxy(proxyUrl, u.hostname, port)
152
+ .then((pipeSock) => {
153
+ const relay = net.createServer((c) => {
154
+ c.pipe(pipeSock);
155
+ pipeSock.pipe(c);
156
+ });
157
+ const cleanup = () => {
158
+ try {
159
+ relay.close();
160
+ }
161
+ catch { }
162
+ try {
163
+ pipeSock.destroy();
164
+ }
165
+ catch { }
166
+ };
167
+ relay.on('error', cleanup);
168
+ relay.listen(0, '127.0.0.1', () => {
169
+ const relayPort = relay.address().port;
170
+ const upstream = https.request({
171
+ host: '127.0.0.1',
172
+ port: relayPort,
173
+ method: 'POST',
174
+ path: `${u.pathname}${u.search}`,
175
+ headers,
176
+ ...upstreamServernameOption(u.hostname),
177
+ });
178
+ hangGuard(upstream);
179
+ upstream.on('error', (err) => {
180
+ cleanup();
181
+ fail(502, `Direct forward: upstream connection failed via outbound proxy (${err.message})`, err);
182
+ });
183
+ upstream.on('response', (up) => {
184
+ cleanup();
185
+ onHeaders(upstream)(up);
186
+ });
187
+ upstream.end(plan.requestBody);
188
+ });
189
+ })
190
+ .catch((err) => fail(502, `Direct forward: outbound proxy connection failed (${err.message})`, err));
191
+ });
192
+ }
193
+ /** Origin IncomingHttpHeaders → fetch Headers (emitUpstreamResponse contract). */
194
+ function nodeHeadersToFetch(headers) {
195
+ const out = new Headers();
196
+ for (const [k, v] of Object.entries(headers)) {
197
+ if (v === undefined)
198
+ continue;
199
+ if (Array.isArray(v))
200
+ for (const item of v)
201
+ out.append(k, item);
202
+ else
203
+ out.set(k, v);
204
+ }
205
+ return out;
206
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Map ADR-0023 `RateLimitRejected` onto the chat-shaped wire (429 JSON or
3
+ * SSE error event with `retry_after_ms` once 200 headers are out).
4
+ */
5
+ import { type RateLimitRejected } from '../ratelimit/admission.js';
6
+ export declare function rateLimitRejectHeaders(err: RateLimitRejected): Record<string, string>;
7
+ export declare function rateLimitRejectJsonBody(err: RateLimitRejected): unknown;
8
+ /** SSE error event carrying retry_after_ms (post-200-SSE-header path). */
9
+ export declare function rateLimitRejectSseEvent(err: RateLimitRejected): string;
10
+ export declare function mapExecutionError(err: unknown, fallback: (e: unknown) => {
11
+ status: number;
12
+ body: unknown;
13
+ }): {
14
+ status: number;
15
+ body: unknown;
16
+ headers?: Record<string, string>;
17
+ };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Map ADR-0023 `RateLimitRejected` onto the chat-shaped wire (429 JSON or
3
+ * SSE error event with `retry_after_ms` once 200 headers are out).
4
+ */
5
+ import { isRateLimitRejected } from '../ratelimit/admission.js';
6
+ import { retryAfterSecFromMs } from '../utils/retry-after.js';
7
+ export function rateLimitRejectHeaders(err) {
8
+ const sec = retryAfterSecFromMs(err.retryAfterMs);
9
+ const headers = {
10
+ 'Retry-After': String(sec),
11
+ 'RateLimit-Reset': String(sec),
12
+ };
13
+ // Inbound (apiKey) subjects own Limit/Remaining; outbound credential caps
14
+ // must NOT leak RateLimit-Limit / -Remaining across the boundary (ADR-0023 §2.1).
15
+ if (err.subject.startsWith('apikey:')) {
16
+ headers['RateLimit-Limit'] = String(err.limit);
17
+ headers['RateLimit-Remaining'] = '0';
18
+ }
19
+ return headers;
20
+ }
21
+ export function rateLimitRejectJsonBody(err) {
22
+ const sec = retryAfterSecFromMs(err.retryAfterMs);
23
+ return {
24
+ error: {
25
+ message: err.message,
26
+ type: 'rate_limit_error',
27
+ code: 'rate_limit_exceeded',
28
+ param: err.limitedBy,
29
+ ...(err.waitedMs > 0 ? { waited_ms: err.waitedMs } : {}),
30
+ ...(err.retryAfterKind === 'estimate' ? { retry_after_kind: 'estimate' } : {}),
31
+ retry_after_ms: err.retryAfterMs,
32
+ },
33
+ };
34
+ }
35
+ /** SSE error event carrying retry_after_ms (post-200-SSE-header path). */
36
+ export function rateLimitRejectSseEvent(err) {
37
+ const payload = {
38
+ error: {
39
+ message: err.message,
40
+ type: 'rate_limit_error',
41
+ code: 'rate_limit_exceeded',
42
+ retry_after_ms: err.retryAfterMs,
43
+ ...(err.waitedMs > 0 ? { waited_ms: err.waitedMs } : {}),
44
+ },
45
+ };
46
+ return `data: ${JSON.stringify(payload)}\n\n`;
47
+ }
48
+ export function mapExecutionError(err, fallback) {
49
+ if (isRateLimitRejected(err)) {
50
+ return {
51
+ status: 429,
52
+ body: rateLimitRejectJsonBody(err),
53
+ headers: rateLimitRejectHeaders(err),
54
+ };
55
+ }
56
+ return fallback(err);
57
+ }
@@ -176,6 +176,17 @@ export interface ChatSurface {
176
176
  */
177
177
  streamStart?(state: unknown, ctx: ChatChunkContext): string[];
178
178
  streamEnd?(result: ExecutionResult, state: unknown, ctx: ChatChunkContext): string[];
179
+ /**
180
+ * Optional in-band failure frame for an ALREADY COMMITTED SSE response
181
+ * (headers and at least one chunk are on the wire, so no second HTTP
182
+ * response and no retry is legal — ADR-0008 §1).
183
+ *
184
+ * Contract: return a frame to emit it (the pipeline writes it, then
185
+ * `endSse`); return `null` to keep the bare close for failures this wire
186
+ * cannot express. A throw is caught and logged, and `endSse` still runs
187
+ * exactly once — a surface must never close the turn itself.
188
+ */
189
+ streamError?(err: unknown): string | null;
179
190
  errorBody(status: number, message: string, code?: string): unknown;
180
191
  executionError(err: unknown): {
181
192
  status: number;
@@ -166,6 +166,17 @@ export interface ExecutionTrace {
166
166
  * existed and on mock execution.
167
167
  */
168
168
  wireKind?: string;
169
+ /**
170
+ * Outbound egress of the SERVED attempt (ADR-0018 / ADR-0022): `direct` =
171
+ * straight out of the machine, `proxy` = through the operator's outbound
172
+ * proxy, whose redacted endpoint rides in `egressProxy`. Resolved at the
173
+ * dial, never at trace time — the proxy config hot-applies, and a long
174
+ * stream outlives a save. Absent = UNKNOWN (legacy rows, plugin-owned
175
+ * transports, mock execution), never read as direct.
176
+ */
177
+ egress?: 'direct' | 'proxy';
178
+ /** Redacted `scheme://host:port` of the outbound proxy; set only with `egress: 'proxy'`. */
179
+ egressProxy?: string;
169
180
  /**
170
181
  * Perceived stall time: total time the committed attempt's stream spent in
171
182
  * gaps of ≥1 s between two consecutive chunks the client received with
@@ -209,8 +220,12 @@ export interface ExecutionTrace {
209
220
  * Actual USD cost of this request, computed at request time with the
210
221
  * catalog pricing that was current then. The only cost figure stored —
211
222
  * derived comparisons (baseline/savings) are intentionally not recorded.
223
+ *
224
+ * Absent when the serving model had NO known price: an unpriced model must
225
+ * stay unpriceable all the way to the console, because writing 0 here would
226
+ * read as "this request was free" and drag every aggregate toward a lie.
212
227
  */
213
- costUsd: number;
228
+ costUsd?: number;
214
229
  };
215
230
  }
216
231
  /**
@@ -227,6 +242,8 @@ export interface CredentialPairUsageRow {
227
242
  outputTokens: number;
228
243
  cachedTokens: number;
229
244
  costUsd: number;
245
+ /** Turns of this pair whose model carried no price (excluded from `costUsd`). */
246
+ unpricedRequests: number;
230
247
  }
231
248
  /** Per-API-key token usage row (also used for the anonymous bucket). */
232
249
  export interface KeyUsageRow {
@@ -239,6 +256,8 @@ export interface KeyUsageRow {
239
256
  latencyMsSum: number;
240
257
  /** Sum of the per-request actual costs (USD) — data-only, not rendered yet. */
241
258
  costUsd: number;
259
+ /** Turns of this row whose model carried no price (excluded from `costUsd`). */
260
+ unpricedRequests: number;
242
261
  /**
243
262
  * Output tokens summed over STREAMED turns only (genMs present) — the
244
263
  * numerator paired with genMsSum for the decode-TPS aggregate.
@@ -254,7 +273,13 @@ export interface UsageStatsSummary {
254
273
  outputTokens: number;
255
274
  cachedTokens: number;
256
275
  avgLatencyMs: number;
276
+ /** Cost of the requests that could be priced; see {@link unpricedRequests}. */
257
277
  costUsd: number;
278
+ /**
279
+ * Requests whose serving model carried no price, excluded from `costUsd`.
280
+ * Non-zero means the total is a floor, not the window's real spend.
281
+ */
282
+ unpricedRequests: number;
258
283
  /** Same streamed-turns-only pairing as KeyUsageRow, window-wide. */
259
284
  genOutputTokens: number;
260
285
  genMsSum: number;
@@ -373,7 +398,13 @@ export declare class TraceTracker {
373
398
  inputTokens: number;
374
399
  outputTokens: number;
375
400
  cachedTokens: number;
401
+ /** Cost of the turns that COULD be priced; see {@link unpricedTurns}. */
376
402
  costUsd: number;
403
+ /**
404
+ * Turns whose model carried no price, hence excluded from `costUsd`.
405
+ * Non-zero means the total is a floor, not the session's real spend.
406
+ */
407
+ unpricedTurns: number;
377
408
  totalLatencyMs: number;
378
409
  genOutputTokens: number;
379
410
  genMsSum: number;
@@ -178,6 +178,10 @@ export class TraceTracker {
178
178
  let cachedTokens = 0;
179
179
  let latencyMsSum = 0;
180
180
  let costUsdSum = 0;
181
+ // Requests whose serving model carried no price. Reported alongside the
182
+ // sum so a smaller-than-expected total reads as "partly unpriceable"
183
+ // instead of silently looking like a bargain.
184
+ let unpricedRequests = 0;
181
185
  let genOutputTokens = 0;
182
186
  let genMsSum = 0;
183
187
  for (const t of this.traces.values()) {
@@ -189,7 +193,12 @@ export class TraceTracker {
189
193
  outputTokens += f.outputTokens;
190
194
  cachedTokens += f.cachedTokens;
191
195
  latencyMsSum += t.execution.latencyMs;
192
- costUsdSum += f.costUsd;
196
+ // Skip unpriced requests rather than folding them in as 0: the sum then
197
+ // answers "cost of what we could price", which is the honest figure.
198
+ if (f.costUsd !== undefined)
199
+ costUsdSum += f.costUsd;
200
+ else
201
+ unpricedRequests++;
193
202
  // Decode-TPS pairing: accumulate BOTH sides only when the turn streamed,
194
203
  // so the quotient never mixes a streamed numerator into a full-window
195
204
  // denominator (that would be the effective-rate confusion again).
@@ -209,6 +218,7 @@ export class TraceTracker {
209
218
  cachedTokens: 0,
210
219
  latencyMsSum: 0,
211
220
  costUsd: 0,
221
+ unpricedRequests: 0,
212
222
  genOutputTokens: 0,
213
223
  genMsSum: 0,
214
224
  };
@@ -219,7 +229,10 @@ export class TraceTracker {
219
229
  row.outputTokens += f.outputTokens;
220
230
  row.cachedTokens += f.cachedTokens;
221
231
  row.latencyMsSum += t.execution.latencyMs;
222
- row.costUsd += f.costUsd;
232
+ if (f.costUsd !== undefined)
233
+ row.costUsd += f.costUsd;
234
+ else
235
+ row.unpricedRequests++;
223
236
  if (typeof t.execution.genMs === 'number') {
224
237
  row.genOutputTokens += f.outputTokens;
225
238
  row.genMsSum += t.execution.genMs;
@@ -233,6 +246,7 @@ export class TraceTracker {
233
246
  cachedTokens,
234
247
  avgLatencyMs: requests > 0 ? Math.round(latencyMsSum / requests) : 0,
235
248
  costUsd: Number(costUsdSum.toFixed(6)),
249
+ unpricedRequests,
236
250
  genOutputTokens,
237
251
  genMsSum,
238
252
  },
@@ -267,6 +281,7 @@ export class TraceTracker {
267
281
  outputTokens: 0,
268
282
  cachedTokens: 0,
269
283
  costUsd: 0,
284
+ unpricedRequests: 0,
270
285
  };
271
286
  byPair.set(id, row);
272
287
  }
@@ -274,7 +289,12 @@ export class TraceTracker {
274
289
  row.inputTokens += t.finops.inputTokens;
275
290
  row.outputTokens += t.finops.outputTokens;
276
291
  row.cachedTokens += t.finops.cachedTokens;
277
- row.costUsd = Number((row.costUsd + t.finops.costUsd).toFixed(6));
292
+ // Skip-and-count, same as the other two planes: an unpriced turn is
293
+ // excluded from the sum (a floor, not a confident total) and counted.
294
+ if (t.finops.costUsd !== undefined)
295
+ row.costUsd = Number((row.costUsd + t.finops.costUsd).toFixed(6));
296
+ else
297
+ row.unpricedRequests++;
278
298
  }
279
299
  return [...byPair.values()].sort((a, b) => a.provider.localeCompare(b.provider) || a.keyHashPrefix.localeCompare(b.keyHashPrefix));
280
300
  }
@@ -312,6 +332,7 @@ export class TraceTracker {
312
332
  let outputTokens = 0;
313
333
  let cachedTokens = 0;
314
334
  let costUsd = 0;
335
+ let unpricedTurns = 0;
315
336
  let totalLatencyMs = 0;
316
337
  let genOutputTokens = 0;
317
338
  let genMsSum = 0;
@@ -326,7 +347,10 @@ export class TraceTracker {
326
347
  inputTokens += t.finops.inputTokens;
327
348
  outputTokens += t.finops.outputTokens;
328
349
  cachedTokens += t.finops.cachedTokens;
329
- costUsd += t.finops.costUsd;
350
+ if (t.finops.costUsd !== undefined)
351
+ costUsd += t.finops.costUsd;
352
+ else
353
+ unpricedTurns++;
330
354
  totalLatencyMs += t.execution.latencyMs;
331
355
  if (typeof t.execution.genMs === 'number') {
332
356
  genOutputTokens += t.finops.outputTokens;
@@ -347,6 +371,7 @@ export class TraceTracker {
347
371
  outputTokens,
348
372
  cachedTokens,
349
373
  costUsd: Number(costUsd.toFixed(6)),
374
+ unpricedTurns,
350
375
  totalLatencyMs,
351
376
  genOutputTokens,
352
377
  genMsSum,
@@ -3,11 +3,14 @@ import type { CircuitBreakerSnapshot } from '../resilience/types.js';
3
3
  import type { ModelAvailability } from '../resilience/circuit-breaker-manager.js';
4
4
  export type TierLevel = 'lite' | 'plus' | 'pro' | 'ultra';
5
5
  /**
6
- * What a model's smart-match classification yields. `TierLevel`
7
- * is the REQUEST-side four-state vocabulary (targetTier, TIER_RANK,
8
- * escalateTier, session ratchet); `'unclassified'` is a
9
- * MODEL-side pool-membership outcome only. Kept as a separate type so the
10
- * two axes can't be conflated.
6
+ * What the member lists yield for a model. `TierLevel` is the REQUEST-side
7
+ * four-state vocabulary (targetTier, TIER_RANK, escalateTier, session
8
+ * ratchet); `'unclassified'` is a MODEL-side pool-membership outcome only —
9
+ * no member list claims the model, so it joins no pool and carries no home
10
+ * tier. Kept as a separate type so the two axes can't be conflated: it is a
11
+ * CLAIM RESULT, never a value stored on a registration (`ModelRegistration.tier`
12
+ * stays `TierLevel | undefined` precisely so TIER_RANK and the ratchet never
13
+ * see a fifth level).
11
14
  *
12
15
  * Tier naming: strength-gradient labels that work across model vendors
13
16
  * (Claude, GPT-*, Gemini, etc.) instead of vendor-specific brand names.
@@ -39,7 +42,7 @@ export declare const TIER_RANK: Record<TierLevel, number>;
39
42
  * Default `supportedReasoningEfforts` for a thinking-capable model is
40
43
  * the full 6-level ladder — there is no 5-level "thinking subset".
41
44
  */
42
- export declare const EFFORT_LADDER: readonly ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
45
+ export declare const EFFORT_LADDER: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
43
46
  export type ReasoningEffort = (typeof EFFORT_LADDER)[number];
44
47
  /** Shared thinking-token budget estimates for protocols that express effort as a token budget. */
45
48
  export declare const EFFORT_TO_BUDGET: Record<ReasoningEffort, number>;
@@ -71,7 +74,12 @@ export type EffortSource = 'client' | 'l2-decision' | 'entry' | 'directive' | 'd
71
74
  * `EFFORT_LADDER` (assume the model supports everything); an explicit
72
75
  * EMPTY array → `'none'` (the model serves no explicit level).
73
76
  */
74
- export declare function downgradeReasoning(requested: ReasoningEffort, supported: readonly ReasoningEffort[] | undefined): ReasoningEffort;
77
+ export declare function downgradeReasoning(requested: ReasoningEffort, supported: readonly ReasoningEffort[] | undefined, alwaysThink?: boolean): ReasoningEffort;
78
+ /** The lowest level a DECLARED support set can serve (`undefined` for an empty
79
+ * or undeclared set). The floor an always-think model is clamped to when an
80
+ * ask or a directive step would otherwise land on `none` the vendor forbids
81
+ * (ADR-0035: a table without `none` can never serve thinking-off). */
82
+ export declare function lowestSupportedEffort(supported: readonly ReasoningEffort[] | undefined): ReasoningEffort | undefined;
75
83
  /**
76
84
  * Per-model thinking-level TRANSLATION table (client-requested →
77
85
  * upstream value), inline on a tier member rule. `effortMap[requested] ??
@@ -86,8 +94,11 @@ export type EffortMap = Partial<Record<ReasoningEffort, ReasoningEffort>>;
86
94
  * - the legacy boolean `true` → the full EFFORT_LADDER;
87
95
  * - otherwise `undefined` = "no explicit effort control" (callers decide:
88
96
  * selection skips the candidate; wire-side recompute clamps to `[]`).
97
+ * `disableable === false` (the vendor's always-think fact, ADR-0035) strips
98
+ * `none` from the resolved set on EVERY branch — the withholding must hold at
99
+ * the routing plane, not only on the published effort table.
89
100
  */
90
- export declare function modelSupportsEfforts(supported: readonly ReasoningEffort[] | undefined, legacyFlag: boolean | undefined): ReasoningEffort[] | undefined;
101
+ export declare function modelSupportsEfforts(supported: readonly ReasoningEffort[] | undefined, legacyFlag: boolean | undefined, disableable?: boolean): ReasoningEffort[] | undefined;
91
102
  export interface ModelPricing {
92
103
  input: number;
93
104
  output: number;
@@ -101,7 +112,10 @@ export interface TierModelConfig {
101
112
  upstreamModel?: string;
102
113
  realModel?: string;
103
114
  tier?: TierLevel;
104
- pricing: ModelPricing;
115
+ /** USD per 1M tokens, or absent when the price is unknown (see
116
+ * {@link ModelRegistration.pricing}). Cost maths must treat a missing
117
+ * value as unpriceable rather than as zero. */
118
+ pricing?: ModelPricing;
105
119
  supportsStreaming?: boolean;
106
120
  supportsTools?: boolean;
107
121
  supportsJsonSchema?: boolean;
@@ -109,21 +123,29 @@ export interface TierModelConfig {
109
123
  * Subset of `ReasoningEffort` this model can natively serve. Empty /
110
124
  * missing means "no explicit effort control — the model handles effort
111
125
  * internally". Default for thinking-capable models is the full
112
- * `EFFORT_LADDER` (all 6 levels).
126
+ * `EFFORT_LADDER` (all 7 levels).
113
127
  */
114
128
  supportedReasoningEfforts?: readonly ReasoningEffort[];
115
129
  /**
116
130
  * Legacy boolean kept for back-compat with catalog / config files that
117
131
  * pre-date the per-level vocabulary. When true and no
118
132
  * `supportedReasoningEfforts` is set, `modelSupportsEfforts` resolves it to
119
- * the FULL `EFFORT_LADDER` (all 6 levels, `none` included). Carrying `none`
133
+ * the FULL `EFFORT_LADDER` (all 7 levels, `none` included). Carrying `none`
120
134
  * is a no-op on every generic path: a `none` target short-circuits before
121
135
  * the support set is read, and a clamp that can reach only `none` yields
122
- * `'none'` anyway. The ONE place where legacy still means the 5 non-`none`
136
+ * `'none'` anyway. The ONE place where legacy still means the 6 non-`none`
123
137
  * levels is the System One wire, whose vendor enum has no `none`
124
138
  * (protocols/systemone/convert.ts → `'low'`).
125
139
  */
126
140
  supportsReasoningEffort?: boolean;
141
+ /**
142
+ * The vendor's on/off fact for a thinking model (ADR-0035): `false` = the
143
+ * model ALWAYS thinks, so `none` is withheld from every resolved effort set
144
+ * (`modelSupportsEfforts`) — including a legacy boolean expansion and a
145
+ * stale config table. Written by the shared catalog-def mapper; absent =
146
+ * off allowed / not stated.
147
+ */
148
+ reasoningDisableable?: boolean;
127
149
  supportsPromptCaching?: boolean;
128
150
  isDefaultInTier?: boolean;
129
151
  }