omnicell-router 0.8.2 → 0.8.4

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 (86) hide show
  1. package/backend/dist/auth/api-keys.js +11 -0
  2. package/backend/dist/auth/key-models.d.ts +36 -0
  3. package/backend/dist/auth/key-models.js +99 -0
  4. package/backend/dist/cli/clients/activity.js +2 -0
  5. package/backend/dist/cli/clients/codex.d.ts +70 -0
  6. package/backend/dist/cli/clients/codex.js +470 -57
  7. package/backend/dist/cli/clients/follow-catalog-sync.d.ts +62 -0
  8. package/backend/dist/cli/clients/follow-catalog-sync.js +435 -0
  9. package/backend/dist/cli/clients/opencode.js +3 -2
  10. package/backend/dist/cli/clients/reserved.js +2 -0
  11. package/backend/dist/cli/types.d.ts +9 -0
  12. package/backend/dist/config/comments-en.js +5 -1
  13. package/backend/dist/config/comments-zh.js +5 -1
  14. package/backend/dist/config/defaults.d.ts +98 -1
  15. package/backend/dist/config/defaults.js +98 -1
  16. package/backend/dist/config/index.d.ts +15 -1
  17. package/backend/dist/config/index.js +35 -1
  18. package/backend/dist/config/migrations/v4-to-v5.d.ts +36 -0
  19. package/backend/dist/config/migrations/v4-to-v5.js +42 -0
  20. package/backend/dist/config/migrations/v5-to-v6.d.ts +27 -0
  21. package/backend/dist/config/migrations/v5-to-v6.js +29 -0
  22. package/backend/dist/config/schema.d.ts +3 -3
  23. package/backend/dist/config/schema.js +8 -4
  24. package/backend/dist/config/types.d.ts +54 -3
  25. package/backend/dist/forward-proxy/egress.js +13 -0
  26. package/backend/dist/forward-proxy/h2-forward.js +6 -5
  27. package/backend/dist/forward-proxy/index.js +5 -0
  28. package/backend/dist/forward-proxy/server.d.ts +12 -0
  29. package/backend/dist/forward-proxy/server.js +113 -15
  30. package/backend/dist/index.js +6 -1
  31. package/backend/dist/ir/adapters/openai-chat.js +5 -3
  32. package/backend/dist/ir/adapters/openai-responses-output.js +2 -2
  33. package/backend/dist/ir/adapters/openai-responses.d.ts +33 -0
  34. package/backend/dist/ir/adapters/openai-responses.js +44 -2
  35. package/backend/dist/ir/capabilities.js +4 -0
  36. package/backend/dist/ir/validate.d.ts +24 -0
  37. package/backend/dist/ir/validate.js +113 -63
  38. package/backend/dist/opencode/catalog/auto-pull.js +8 -7
  39. package/backend/dist/opencode/catalog/ocr-store.d.ts +7 -6
  40. package/backend/dist/opencode/catalog/ocr-store.js +2 -2
  41. package/backend/dist/opencode/catalog/overrides-store.d.ts +5 -3
  42. package/backend/dist/opencode/catalog/overrides-store.js +22 -19
  43. package/backend/dist/opencode/catalog/repository.js +3 -3
  44. package/backend/dist/opencode/catalog/sources/models-dev.d.ts +3 -3
  45. package/backend/dist/opencode/catalog/sources/models-dev.js +29 -11
  46. package/backend/dist/opencode/catalog/types.d.ts +7 -9
  47. package/backend/dist/opencode/credentials/def-materialize.js +27 -21
  48. package/backend/dist/opencode/migrate/engine.d.ts +20 -0
  49. package/backend/dist/opencode/migrate/engine.js +71 -0
  50. package/backend/dist/opencode/migrate/migrator.d.ts +11 -0
  51. package/backend/dist/opencode/migrate/migrator.js +6 -0
  52. package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.d.ts +6 -0
  53. package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.js +31 -0
  54. package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.d.ts +6 -0
  55. package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.js +62 -0
  56. package/backend/dist/opencode/provider-def-adapters.d.ts +12 -11
  57. package/backend/dist/opencode/provider-def-adapters.js +43 -27
  58. package/backend/dist/opencode/provider-defs.d.ts +10 -16
  59. package/backend/dist/opencode/provider-defs.js +45 -45
  60. package/backend/dist/opencode/user-config.d.ts +23 -26
  61. package/backend/dist/opencode/user-config.js +95 -77
  62. package/backend/dist/pipeline/orchestrator.js +17 -7
  63. package/backend/dist/plugins/builtin/model-gateway.js +38 -12
  64. package/backend/dist/plugins/host.d.ts +2 -2
  65. package/backend/dist/plugins/host.js +15 -12
  66. package/backend/dist/providers/boot-direct.js +32 -8
  67. package/backend/dist/providers/dial-wire.d.ts +17 -0
  68. package/backend/dist/providers/dial-wire.js +49 -0
  69. package/backend/dist/providers/protocols-field.d.ts +24 -0
  70. package/backend/dist/providers/protocols-field.js +66 -0
  71. package/backend/dist/providers/registry.d.ts +3 -1
  72. package/backend/dist/providers/registry.js +23 -7
  73. package/backend/dist/quota/cli-login.js +3 -1
  74. package/backend/dist/routes/console.js +115 -95
  75. package/backend/dist/server.js +91 -2
  76. package/backend/dist/surfaces/anthropic.js +4 -1
  77. package/backend/dist/surfaces/body-admission.d.ts +279 -0
  78. package/backend/dist/surfaces/body-admission.js +613 -0
  79. package/backend/dist/surfaces/transport-node-http.d.ts +44 -5
  80. package/backend/dist/surfaces/transport-node-http.js +86 -13
  81. package/backend/dist/utils/server-liveness.d.ts +27 -0
  82. package/backend/dist/utils/server-liveness.js +31 -0
  83. package/frontend/dist/assets/{index-55VVwfFQ.js → index-Dk76uc7e.js} +367 -366
  84. package/frontend/dist/assets/{index-DxZ9MHKB.css → index-KI1OW5x6.css} +1 -1
  85. package/frontend/dist/index.html +2 -2
  86. package/package.json +1 -1
@@ -1,7 +1,15 @@
1
1
  import { capabilitiesFor } from './capabilities.js';
2
2
  import { IrUnsupportedError } from './errors.js';
3
- function fail(protocol, code, detail) {
4
- throw new IrUnsupportedError(code, `${detail} Target protocol: ${protocol}.`, protocol);
3
+ /** Default fix when a capability is simply missing on the dialed wire. */
4
+ const GENERIC_HINT = 'Omit this field or use a protocol that supports it';
5
+ /**
6
+ * Client-visible unsupported_parameter body. One voice for the gate and adapters:
7
+ * feature + dialed protocol + actionable hint. Dial context (model / protocols[])
8
+ * is layered on by `withDialContext` in the registry.
9
+ */
10
+ export function formatUnsupported(protocol, feature, hint = GENERIC_HINT) {
11
+ const tip = hint.trim().replace(/\.$/, '');
12
+ return `Unsupported on outbound protocol '${protocol}': ${feature}. ${tip}.`;
5
13
  }
6
14
  /** Carrier shape family. The chat family is the DEFAULT: the three typed
7
15
  * carriers are named, and every other protocol id (systemone, an OCR-native
@@ -9,56 +17,94 @@ function fail(protocol, code, detail) {
9
17
  function isChatProtocol(protocol) {
10
18
  return protocol !== 'openai-responses' && protocol !== 'anthropic-messages' && protocol !== 'google-gemini';
11
19
  }
12
- function validateCache(cache, protocol, supported, code, detail, strip) {
20
+ function fail(protocol, code, feature, hint = GENERIC_HINT) {
21
+ throw new IrUnsupportedError(code, formatUnsupported(protocol, feature, hint), protocol);
22
+ }
23
+ /**
24
+ * Operator-facing copy when a wire rejects non-function tools.
25
+ * OpenAI Platform Chat Completions added `type:"custom"` in 2025-08, but OCR's
26
+ * `openai-chat` id is the *portable* Chat Completions contract used by Xiaomi /
27
+ * DeepSeek / Kimi-style compat endpoints — those accept function tools, not
28
+ * OpenAI's freeform/grammar custom dialect or Responses builtins.
29
+ */
30
+ export function unsupportedToolKindMessage(protocol, kind, forChoice) {
31
+ const feature = forChoice ? `Forcing a ${kind} tool (tool_choice)` : `${kind} tools`;
32
+ const responsesHint = `Add 'openai-responses' to the model's protocols[] if the vendor can serve it, or use a model whose protocols admit ${kind} tools`;
33
+ if (isChatProtocol(protocol) && (kind === 'custom' || kind === 'builtin')) {
34
+ const chatHint = kind === 'custom'
35
+ ? `Portable openai-chat carries function tools only; ${responsesHint}`
36
+ : `Portable openai-chat cannot carry builtin/hosted tools; ${responsesHint}`;
37
+ return formatUnsupported(protocol, feature, chatHint);
38
+ }
39
+ if (kind === 'custom' || kind === 'builtin') {
40
+ return formatUnsupported(protocol, feature, responsesHint);
41
+ }
42
+ return formatUnsupported(protocol, feature);
43
+ }
44
+ /**
45
+ * Layer dial facts onto a gate/adapter refusal so the client sees which model
46
+ * and protocols[] were in play. Same code/protocol; message only.
47
+ */
48
+ export function withDialContext(err, opts) {
49
+ if (err.message.startsWith('Request for model '))
50
+ return err;
51
+ const list = opts.protocols && opts.protocols.length > 0
52
+ ? opts.protocols.join(', ')
53
+ : opts.dialWire;
54
+ const message = `Request for model '${opts.modelId}' (declared protocols: ${list}): ${err.message}`;
55
+ return new IrUnsupportedError(err.code, message, err.protocol ?? opts.dialWire);
56
+ }
57
+ function validateCache(cache, protocol, supported, code, feature, strip, hint = GENERIC_HINT) {
13
58
  if (strip)
14
59
  return;
15
60
  if (!supported)
16
- fail(protocol, code, detail);
61
+ fail(protocol, code, feature, hint);
17
62
  // Responses breakpoints are opaque objects; Anthropic only accepts its own
18
63
  // typed cache_control marker. Replaying a foreign marker is not passthrough.
19
64
  if (protocol === 'anthropic-messages' && cache.raw && !cache.type) {
20
- fail(protocol, code, 'Protocol cannot translate a foreign raw cache breakpoint.');
65
+ fail(protocol, code, 'Foreign raw cache breakpoints', 'Use an Anthropic cache_control marker');
21
66
  }
22
67
  if (protocol === 'openai-responses' && cache.type && !cache.raw) {
23
- fail(protocol, code, 'Protocol cannot translate an Anthropic cache_control breakpoint.');
68
+ fail(protocol, code, 'Anthropic cache_control breakpoints', 'Use a Responses prompt_cache breakpoint');
24
69
  }
25
70
  }
26
71
  function validatePart(part, protocol, caps, stripCarrierExtensions = false) {
27
72
  if (part.type === 'extension') {
28
- if (part.protocol !== protocol)
29
- fail(protocol, 'extension_part', `Cannot convert ${part.protocol} extension content.`);
73
+ if (part.protocol !== protocol) {
74
+ fail(protocol, 'extension_part', `${part.protocol} extension content`, 'Keep same-carrier extensions only');
75
+ }
30
76
  return;
31
77
  }
32
78
  if (!caps.parts[part.type])
33
- fail(protocol, `${part.type}_part`, `Protocol cannot carry ${part.type} content.`);
79
+ fail(protocol, `${part.type}_part`, `${part.type} content parts`);
34
80
  if ('cache' in part && part.cache) {
35
- validateCache(part.cache, protocol, caps.cache.part_breakpoint === true, 'cache_part_breakpoint', 'Protocol cannot carry a content cache breakpoint.', stripCarrierExtensions);
81
+ validateCache(part.cache, protocol, caps.cache.part_breakpoint === true, 'cache_part_breakpoint', 'Content cache breakpoints', stripCarrierExtensions);
36
82
  }
37
83
  if ('source' in part) {
38
84
  const allowed = caps.sources[part.type] ?? [];
39
85
  if (!allowed.includes(part.source.kind)) {
40
- fail(protocol, `${part.type}_source`, `Protocol cannot carry a ${part.source.kind} ${part.type} source.`);
86
+ fail(protocol, `${part.type}_source`, `${part.source.kind} ${part.type} sources`);
41
87
  }
42
88
  }
43
89
  if ((part.type === 'text' || part.type === 'image' || part.type === 'file' || part.type === 'audio') && part.signature) {
44
90
  if (!caps.reasoningSignature)
45
- fail(protocol, 'content_signature', 'Protocol cannot replay signed content.');
91
+ fail(protocol, 'content_signature', 'Signed content replay');
46
92
  }
47
93
  if (part.type === 'text' && part.annotations?.length && !caps.annotations) {
48
- fail(protocol, 'annotations', 'Protocol cannot carry text annotations.');
94
+ fail(protocol, 'annotations', 'Text annotations');
49
95
  }
50
96
  if (part.type === 'text' && part.logprobs?.length && !caps.logprobs) {
51
- fail(protocol, 'logprobs', 'Protocol cannot carry token log probabilities.');
97
+ fail(protocol, 'logprobs', 'Token log probabilities on content');
52
98
  }
53
99
  }
54
100
  function validateToolChoice(choice, protocol, caps) {
55
101
  if (!choice)
56
102
  return;
57
103
  if (choice.type === 'custom' && !caps.toolKinds.custom) {
58
- fail(protocol, 'tool_choice', 'Protocol cannot force a custom tool.');
104
+ throw new IrUnsupportedError('tool_choice', unsupportedToolKindMessage(protocol, 'custom', true), protocol);
59
105
  }
60
106
  if (choice.type === 'allowed' && !caps.allowedToolChoice) {
61
- fail(protocol, 'allowed_tools', 'Protocol cannot represent allowed_tools.');
107
+ fail(protocol, 'allowed_tools', 'allowed_tools tool_choice');
62
108
  }
63
109
  }
64
110
  /**
@@ -73,127 +119,131 @@ export function assertCanonicalRequestSupported(ir, protocol, options = {}) {
73
119
  validateItem(item, protocol, caps, strip, 'request');
74
120
  for (const tool of ir.tools ?? []) {
75
121
  if (tool.type === 'extension') {
76
- if (tool.protocol !== protocol)
77
- fail(protocol, 'extension_tool', `Cannot convert ${tool.protocol} tool definition.`);
122
+ if (tool.protocol !== protocol) {
123
+ fail(protocol, 'extension_tool', `${tool.protocol} tool definitions`, 'Keep same-carrier tools only');
124
+ }
78
125
  continue;
79
126
  }
80
- if (!caps.toolKinds[tool.type])
81
- fail(protocol, 'tool_type', `Protocol cannot carry ${tool.type} tools.`);
127
+ if (!caps.toolKinds[tool.type]) {
128
+ throw new IrUnsupportedError('tool_type', unsupportedToolKindMessage(protocol, tool.type, false), protocol);
129
+ }
82
130
  if (tool.type === 'function' && tool.function.strict === true && !caps.toolStrict) {
83
- fail(protocol, 'tool_strict', 'Protocol cannot enforce strict function schemas.');
131
+ fail(protocol, 'tool_strict', 'Strict function schemas');
84
132
  }
85
133
  const cache = tool.type === 'function' ? tool.function.cache : tool.type === 'custom' ? tool.cache : undefined;
86
134
  if (cache) {
87
- validateCache(cache, protocol, caps.cache.tool_breakpoint === true, 'cache_tool_breakpoint', 'Protocol cannot carry a tool cache breakpoint.', strip);
135
+ validateCache(cache, protocol, caps.cache.tool_breakpoint === true, 'cache_tool_breakpoint', 'Tool cache breakpoints', strip);
88
136
  }
89
137
  }
90
138
  validateToolChoice(ir.toolChoice, protocol, caps);
91
139
  if (ir.parallelToolCalls === false && !caps.parallelToolCalls) {
92
- fail(protocol, 'parallel_tool_calls', 'Protocol cannot disable parallel tool calls.');
140
+ fail(protocol, 'parallel_tool_calls', 'Disabling parallel tool calls');
93
141
  }
94
142
  if (ir.text?.format && ir.text.format.type !== 'text' && !caps.responseFormat[ir.text.format.type]) {
95
- fail(protocol, 'response_format', `Protocol cannot enforce ${ir.text.format.type}.`);
143
+ fail(protocol, 'response_format', `${ir.text.format.type} response format`);
96
144
  }
97
145
  if (ir.text?.verbosity && !caps.textVerbosity)
98
- fail(protocol, 'text_verbosity', 'Protocol cannot control text verbosity.');
146
+ fail(protocol, 'text_verbosity', 'text.verbosity');
99
147
  if (ir.reasoning?.budgetTokens !== undefined && !caps.reasoningBudget) {
100
- fail(protocol, 'reasoning_budget', 'Protocol cannot enforce a thinking-token budget.');
148
+ fail(protocol, 'reasoning_budget', 'Thinking-token budgets');
101
149
  }
102
150
  if (ir.reasoning?.summary && !caps.reasoningSummary) {
103
- fail(protocol, 'reasoning_summary', 'Protocol cannot request reasoning summaries.');
151
+ fail(protocol, 'reasoning_summary', 'Reasoning summaries');
104
152
  }
105
153
  if (ir.n !== undefined && ir.n !== 1 && !caps.candidates) {
106
- fail(protocol, 'candidates', 'Protocol cannot return multiple candidates.');
154
+ fail(protocol, 'candidates', 'Multiple candidates (n > 1)');
107
155
  }
108
156
  if ((ir.logprobs === true || ir.topLogprobs !== undefined) && !caps.logprobs) {
109
- fail(protocol, 'logprobs', 'Protocol cannot return log probabilities.');
157
+ fail(protocol, 'logprobs', 'Log probabilities');
110
158
  }
111
159
  if (ir.logitBias !== undefined && !isChatProtocol(protocol)) {
112
- fail(protocol, 'logit_bias', 'Protocol cannot honor token logit bias.');
160
+ fail(protocol, 'logit_bias', 'Token logit bias');
113
161
  }
114
162
  if (ir.include !== undefined && protocol !== 'openai-responses') {
115
- fail(protocol, 'include', 'Protocol cannot honor Responses include controls.');
163
+ fail(protocol, 'include', 'Responses include controls');
116
164
  }
117
165
  if (ir.store !== undefined || ir.previousResponseId || ir.conversation || ir.prompt) {
118
166
  if (!caps.stateful)
119
- fail(protocol, 'stateful_request', 'Protocol cannot carry server-side response state controls.');
167
+ fail(protocol, 'stateful_request', 'Server-side response state controls');
120
168
  }
121
169
  if (ir.background && !caps.background)
122
- fail(protocol, 'background', 'Protocol cannot execute background responses.');
170
+ fail(protocol, 'background', 'Background responses');
123
171
  if (ir.truncation === 'auto' && !caps.stateful)
124
- fail(protocol, 'truncation', 'Protocol cannot perform server-side truncation.');
172
+ fail(protocol, 'truncation', 'Server-side truncation');
125
173
  if (ir.metadata && !caps.metadata)
126
- fail(protocol, 'metadata', 'Protocol cannot carry opaque request metadata.');
174
+ fail(protocol, 'metadata', 'Opaque request metadata');
127
175
  if (ir.serviceTier && !caps.serviceTier)
128
- fail(protocol, 'service_tier', 'Protocol cannot select a service tier.');
176
+ fail(protocol, 'service_tier', 'Service tier selection');
129
177
  if (ir.safetyIdentifier && !caps.safetyIdentifier) {
130
- fail(protocol, 'safety_identifier', 'Protocol cannot carry a safety identifier.');
178
+ fail(protocol, 'safety_identifier', 'Safety identifiers');
131
179
  }
132
180
  if (ir.user && !caps.user)
133
- fail(protocol, 'user', 'Protocol cannot carry end-user attribution.');
181
+ fail(protocol, 'user', 'End-user attribution');
134
182
  // streamOptions controls the northbound Chat encoder; it is not an upstream field.
135
183
  for (const key of ['key', 'retention', 'options']) {
136
184
  if (ir.cache?.[key] !== undefined && !caps.cache[key] && !(strip && key !== 'key')) {
137
- fail(protocol, `cache_${key}`, `Protocol cannot honor cache.${key}.`);
185
+ fail(protocol, `cache_${key}`, `cache.${key}`);
138
186
  }
139
187
  }
140
188
  if (!strip && ir.vendor?.anthropic?.systemCache && typeof ir.vendor.anthropic.systemCache === 'object') {
141
- validateCache(ir.vendor.anthropic.systemCache, protocol, caps.cache.item_breakpoint === true, 'cache_system_breakpoint', 'Protocol cannot carry Anthropic system cache breakpoints.', strip);
189
+ validateCache(ir.vendor.anthropic.systemCache, protocol, caps.cache.item_breakpoint === true, 'cache_system_breakpoint', 'Anthropic system cache breakpoints', strip);
142
190
  }
143
191
  if (ir.reasoning?.include && protocol !== 'openai-responses') {
144
- fail(protocol, 'reasoning_include', 'Protocol cannot return encrypted reasoning content.');
192
+ fail(protocol, 'reasoning_include', 'Encrypted reasoning content');
145
193
  }
146
194
  for (const key of Object.keys(ir.generation ?? {})) {
147
195
  if (ir.generation?.[key] !== undefined && !caps.generation[key]) {
148
- fail(protocol, `generation_${key}`, `Protocol cannot honor generation.${key}.`);
196
+ fail(protocol, `generation_${key}`, `generation.${key}`);
149
197
  }
150
198
  }
151
199
  }
152
200
  function validateItem(item, protocol, caps, stripCarrierExtensions = false, direction = 'request') {
153
201
  if (item.type === 'extension') {
154
- if (item.protocol !== protocol)
155
- fail(protocol, 'extension_item', `Cannot convert ${item.protocol} extension item.`);
202
+ if (item.protocol !== protocol) {
203
+ fail(protocol, 'extension_item', `${item.protocol} extension items`, 'Keep same-carrier extensions only');
204
+ }
156
205
  return;
157
206
  }
158
207
  if (item.type === 'item_reference') {
159
208
  if (!caps.itemReference)
160
- fail(protocol, 'item_reference', 'Protocol cannot resolve stored item references.');
209
+ fail(protocol, 'item_reference', 'Stored item references');
161
210
  return;
162
211
  }
163
212
  if (item.type === 'reasoning') {
164
213
  if ((item.signature || item.encrypted) && !caps.reasoningSignature) {
165
- fail(protocol, 'reasoning_signature', 'Protocol cannot replay signed or encrypted reasoning.');
214
+ fail(protocol, 'reasoning_signature', 'Signed or encrypted reasoning replay');
166
215
  }
167
216
  // Responses replays `encrypted_content` on the request wire and may echo a
168
217
  // `signature` on northbound output, but a foreign signature has no request
169
218
  // field — reject here so the matrix matches `itemToWire`, not only the adapter.
170
219
  if (direction === 'request' && protocol === 'openai-responses' && item.signature) {
171
- fail(protocol, 'reasoning_signature', 'Responses cannot replay a foreign reasoning signature.');
220
+ fail(protocol, 'reasoning_signature', 'Foreign reasoning signatures', 'Strip signatures before dialing Responses, or stay on the signing carrier');
172
221
  }
173
222
  if (direction === 'request' && protocol === 'google-gemini' && item.encrypted) {
174
- fail(protocol, 'reasoning_signature', 'Gemini reasoning replay cannot carry encrypted OpenAI/Anthropic thought blobs.');
223
+ fail(protocol, 'reasoning_signature', 'Encrypted OpenAI/Anthropic thought blobs', 'Strip encrypted reasoning before dialing Gemini');
175
224
  }
176
225
  if (item.summary?.length && !caps.reasoningSummary) {
177
- fail(protocol, 'reasoning_summary', 'Protocol cannot replay structured reasoning summaries.');
226
+ fail(protocol, 'reasoning_summary', 'Structured reasoning summaries');
178
227
  }
179
228
  return;
180
229
  }
181
230
  if (item.type === 'tool_call') {
182
- if (item.signature && !caps.reasoningSignature)
183
- fail(protocol, 'tool_call_signature', 'Protocol cannot replay signed calls.');
231
+ if (item.signature && !caps.reasoningSignature) {
232
+ fail(protocol, 'tool_call_signature', 'Signed tool-call replay');
233
+ }
184
234
  if (direction === 'request' && protocol === 'openai-responses' && item.signature) {
185
- fail(protocol, 'tool_call_signature', 'Responses cannot replay a foreign tool-call signature.');
235
+ fail(protocol, 'tool_call_signature', 'Foreign tool-call signatures', 'Strip signatures before dialing Responses, or stay on the signing carrier');
186
236
  }
187
237
  if (item.cache) {
188
- validateCache(item.cache, protocol, caps.cache.item_breakpoint === true, 'cache_item_breakpoint', 'Protocol cannot carry an item-level cache breakpoint.', stripCarrierExtensions);
238
+ validateCache(item.cache, protocol, caps.cache.item_breakpoint === true, 'cache_item_breakpoint', 'Item-level cache breakpoints', stripCarrierExtensions);
189
239
  }
190
240
  return;
191
241
  }
192
242
  if (item.type === 'tool_result' && item.isError && protocol !== 'anthropic-messages') {
193
- fail(protocol, 'tool_result_error', 'Protocol cannot preserve the tool result error marker.');
243
+ fail(protocol, 'tool_result_error', 'Tool-result error markers');
194
244
  }
195
245
  if ('cache' in item && item.cache) {
196
- validateCache(item.cache, protocol, caps.cache.item_breakpoint === true, 'cache_item_breakpoint', 'Protocol cannot carry an item-level cache breakpoint.', stripCarrierExtensions);
246
+ validateCache(item.cache, protocol, caps.cache.item_breakpoint === true, 'cache_item_breakpoint', 'Item-level cache breakpoints', stripCarrierExtensions);
197
247
  }
198
248
  for (const part of item.content)
199
249
  validatePart(part, protocol, caps, stripCarrierExtensions);
@@ -201,22 +251,22 @@ function validateItem(item, protocol, caps, stripCarrierExtensions = false, dire
201
251
  function validateOutputPart(part, protocol, caps) {
202
252
  validatePart(part, protocol, caps);
203
253
  if (part.type !== 'extension' && part.type !== 'text' && part.type !== 'refusal') {
204
- fail(protocol, 'output_part', `Protocol output adapter cannot emit ${part.type} content.`);
254
+ fail(protocol, 'output_part', `${part.type} output content`);
205
255
  }
206
256
  if (part.type !== 'text')
207
257
  return;
208
258
  for (const annotation of part.annotations ?? []) {
209
259
  if (annotation.type === 'extension' && annotation.protocol !== protocol) {
210
- fail(protocol, 'annotation', `Protocol cannot convert ${annotation.protocol} annotations.`);
260
+ fail(protocol, 'annotation', `${annotation.protocol} annotations`);
211
261
  }
212
262
  if (protocol === 'anthropic-messages' && (annotation.type !== 'extension' || annotation.protocol !== protocol)) {
213
- fail(protocol, 'annotation', 'Anthropic output requires carrier-native citation payloads.');
263
+ fail(protocol, 'annotation', 'Non-native annotations', 'Anthropic output requires carrier-native citation payloads');
214
264
  }
215
265
  }
216
266
  // Chat logprobs have a token-aligned stream shape that this output adapter
217
267
  // does not synthesize from Responses-span data. Reject instead of dropping.
218
268
  if (isChatProtocol(protocol) && part.logprobs?.length) {
219
- fail(protocol, 'output_logprobs', 'Chat output cannot preserve Responses token log probabilities.');
269
+ fail(protocol, 'output_logprobs', 'Responses token log probabilities on Chat output');
220
270
  }
221
271
  }
222
272
  function validateOutputItem(item, protocol, caps) {
@@ -233,7 +283,7 @@ export function assertCanonicalResponseSupported(response, protocol) {
233
283
  index: 0, status: response.status, ...(response.reason ? { reason: response.reason } : {}), output: response.output,
234
284
  }];
235
285
  if (candidates.length > 1 && !caps.candidates) {
236
- fail(protocol, 'candidates', 'Protocol cannot return multiple candidates.');
286
+ fail(protocol, 'candidates', 'Multiple candidates');
237
287
  }
238
288
  for (const candidate of candidates) {
239
289
  for (const item of candidate.output)
@@ -244,7 +294,7 @@ export function assertCanonicalResponseSupported(response, protocol) {
244
294
  export function assertCanonicalStreamEventSupported(event, protocol) {
245
295
  const caps = capabilitiesFor(protocol);
246
296
  if ((event.candidateIndex ?? 0) !== 0 && !caps.candidates) {
247
- fail(protocol, 'candidates', 'Protocol cannot stream multiple candidates.');
297
+ fail(protocol, 'candidates', 'Streaming multiple candidates');
248
298
  }
249
299
  if (event.type === 'response.output_item.added' || event.type === 'response.output_item.done') {
250
300
  validateOutputItem(event.item, protocol, caps);
@@ -263,10 +313,10 @@ export function assertCanonicalStreamEventSupported(event, protocol) {
263
313
  return;
264
314
  }
265
315
  if ((event.type === 'response.refusal.delta' || event.type === 'response.refusal.done') && !caps.parts.refusal) {
266
- fail(protocol, 'refusal_part', 'Protocol cannot stream refusal content.');
316
+ fail(protocol, 'refusal_part', 'Streaming refusal content');
267
317
  return;
268
318
  }
269
319
  if (event.type.startsWith('response.reasoning_summary') && !caps.reasoningSummary) {
270
- fail(protocol, 'reasoning_summary', 'Protocol cannot stream structured reasoning summaries.');
320
+ fail(protocol, 'reasoning_summary', 'Streaming structured reasoning summaries');
271
321
  }
272
322
  }
@@ -459,8 +459,9 @@ export async function autoPullProvider(id, opts = {}) {
459
459
  const def = getProviderNodeById(id);
460
460
  // Plugin-provided model-service wire: the model source is the plugin's own
461
461
  // pullModels() — a plain /models GET cannot exist on this transport class.
462
- const npm = def?.npm || def?.package || '';
463
- const npmWire = npm ? wireFor(npm) : 'unroutable';
462
+ const { primaryProtocol, normalizeProtocols } = await import('../../providers/protocols-field.js');
463
+ const protocols = normalizeProtocols(def?.protocols ?? def?.package ?? def?.npm);
464
+ const npmWire = protocols.length > 0 ? wireFor(primaryProtocol(protocols)) : 'unroutable';
464
465
  if (isPluginWire(npmWire)) {
465
466
  // The executor's wire id is also the protocol id a plugin labels its own
466
467
  // model list with, so the message names the wire the def resolved to.
@@ -516,14 +517,14 @@ export async function ensureConnectedProviderBook(id, opts = {}) {
516
517
  // (node absent, or present-but-baseless) — an operator-owned node needs no
517
518
  // network on this path.
518
519
  let catalogName;
519
- let catalogNpm;
520
+ let catalogProtocols;
520
521
  let catalogBase;
521
522
  if ((!existing || !existing.options?.baseURL) && !opts.baseURL) {
522
523
  try {
523
524
  const { catalogRepository } = await import('./repository.js');
524
525
  const rec = await catalogRepository.getProvider(id);
525
526
  catalogName = rec?.name;
526
- catalogNpm = rec?.npm;
527
+ catalogProtocols = rec?.protocols;
527
528
  catalogBase = rec?.baseURL || rec?.api;
528
529
  }
529
530
  catch {
@@ -531,21 +532,21 @@ export async function ensureConnectedProviderBook(id, opts = {}) {
531
532
  }
532
533
  }
533
534
  if (!existing) {
534
- const up = upsertProviderDef({ id, name: catalogName, npm: catalogNpm, baseURL: opts.baseURL || catalogBase });
535
+ const up = upsertProviderDef({ id, name: catalogName, protocols: catalogProtocols, baseURL: opts.baseURL || catalogBase });
535
536
  if (!up.success)
536
537
  return { nodeCreated: false, pulled: 0, fillError: up.error };
537
538
  nodeCreated = true;
538
539
  }
539
540
  else if (!existing.options?.baseURL) {
540
541
  // Baseless node (the bind sweep's shape). Merging, not rebuilding: every
541
- // other slot the operator owns (name/npm/headers/models/env/canonical/body)
542
+ // other slot the operator owns (name/protocols/headers/models/env/canonical/body)
542
543
  // rides through untouched.
543
544
  const baseURL = opts.baseURL || catalogBase;
544
545
  if (baseURL) {
545
546
  const up = upsertProviderDef({
546
547
  id,
547
548
  name: existing.name,
548
- npm: existing.npm,
549
+ protocols: existing.protocols,
549
550
  baseURL,
550
551
  headers: existing.options?.headers,
551
552
  models: existing.models,
@@ -13,12 +13,13 @@ export interface OcrCatalogStore {
13
13
  /** Bump to invalidate every on-disk snapshot when the aggregation semantics
14
14
  * change in code (the signature only covers defs/config mtimes + source
15
15
  * defs + locked ids — code-level changes cannot drift it). Monotonic only —
16
- * never reuse or step back: 1–4 are burned (2 was the pre-rename snapshot
17
- * with `builtin` source ids; 3 the custom-store 'custom' source, retired
18
- * when model books unified into providers.json; 4 still stored SDK package
19
- * strings in the `npm` slot). A stale 1–4 file stays invalid forever and
20
- * the next semantic change goes to 6. */
21
- version: 5;
16
+ * never reuse or step back: 1–5 are burned (2 was the pre-rename snapshot
17
+ * with `builtin` source ids; 3 the custom-store 'custom' source, retired
18
+ * when model books unified into providers.json; 4 still stored SDK package
19
+ * strings in the `npm` slot; 5 stored singular protocol ids under `npm`).
20
+ * Version 6 stores `protocols: string[]` (ADR-0010). A stale 1–5 file stays
21
+ * invalid forever. */
22
+ version: 6;
22
23
  /** aggregation signature — defs/config.yaml mtimes + source defs + locked ids */
23
24
  sig: string;
24
25
  /** when this snapshot was aggregated (epoch ms) */
@@ -14,7 +14,7 @@ export function readOcrStore() {
14
14
  if (!fs.existsSync(file))
15
15
  return null;
16
16
  const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
17
- if (parsed?.version !== 5 || typeof parsed.sig !== 'string' || typeof parsed.builtAt !== 'number')
17
+ if (parsed?.version !== 6 || typeof parsed.sig !== 'string' || typeof parsed.builtAt !== 'number')
18
18
  return null;
19
19
  if (!Array.isArray(parsed.providers))
20
20
  return null;
@@ -28,7 +28,7 @@ export function writeOcrStore(sig, providers) {
28
28
  try {
29
29
  const file = getOcrStorePath();
30
30
  fs.mkdirSync(path.dirname(file), { recursive: true });
31
- const store = { version: 5, sig, builtAt: Date.now(), providers };
31
+ const store = { version: 6, sig, builtAt: Date.now(), providers };
32
32
  const tmp = `${file}.tmp.${process.pid}.${Date.now()}`;
33
33
  fs.writeFileSync(tmp, JSON.stringify(store), 'utf8');
34
34
  renameWithRetry(tmp, file);
@@ -7,6 +7,8 @@ import type { ReasoningEffort } from '../../types/router.js';
7
7
  * this is the landing spot for edits made in the OCR Catalog viewer, which
8
8
  * targets the AGGREGATION (not the defs-file nodes themselves).
9
9
  * Key is `${providerId}||${modelId}` (model ids may contain '/').
10
+ *
11
+ * Schema version 2: protocol slot is `protocols: string[]` only (ADR-0010).
10
12
  */
11
13
  export interface OverrideEntry {
12
14
  name?: string;
@@ -43,8 +45,8 @@ export interface OverrideEntry {
43
45
  reasoningEfforts?: ReasoningEffort[];
44
46
  /** Model-default thinking level; `null` clears the override (follow the catalog/def). */
45
47
  defaultEffort?: ReasoningEffort | null;
46
- /** Model-level protocol id. Retired SDK package strings are translated on read. */
47
- npm?: string;
48
+ /** Model-level outbound protocol set (ordered). */
49
+ protocols?: string[];
48
50
  /** Named thinking-level variants (UI short shape `{id, effort}` — materialized to the def shape at aggregation). */
49
51
  variants?: {
50
52
  id: string;
@@ -52,7 +54,7 @@ export interface OverrideEntry {
52
54
  }[];
53
55
  }
54
56
  export interface OverrideStore {
55
- version: 1;
57
+ version: 2;
56
58
  updated: number;
57
59
  models: Record<string, OverrideEntry>;
58
60
  }
@@ -1,8 +1,10 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { getOcrStorePath } from './ocr-store.js';
4
- import { protocolIdFromNpm } from '../provider-package.js';
5
4
  import { renameWithRetry } from '../../utils/atomic-write.js';
5
+ import { migrateOverridesFile, OVERRIDES_SCHEMA } from '../migrate/engine.js';
6
+ import { normalizeProtocols } from '../../providers/protocols-field.js';
7
+ import { protocolIdFromNpm } from '../provider-package.js';
6
8
  export const overrideKey = (providerId, modelId) => `${providerId}||${modelId}`;
7
9
  export function getOverridesStorePath() {
8
10
  return path.join(path.dirname(getOcrStorePath()), 'overrides.json');
@@ -12,33 +14,32 @@ export function readOverridesStore() {
12
14
  const file = getOverridesStorePath();
13
15
  if (!fs.existsSync(file))
14
16
  return null;
17
+ migrateOverridesFile(file);
15
18
  const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
16
- if (parsed?.version !== 1 || typeof parsed.models !== 'object' || parsed.models === null)
19
+ if (parsed?.version !== OVERRIDES_SCHEMA || typeof parsed.models !== 'object' || parsed.models === null)
17
20
  return null;
18
21
  const models = {};
19
22
  for (const [key, entry] of Object.entries(parsed.models)) {
20
- models[key] = translateOverrideNpm(entry);
23
+ models[key] = normalizeOverrideEntry(entry);
21
24
  }
22
- return { ...parsed, models };
25
+ return { ...parsed, version: 2, models };
23
26
  }
24
27
  catch {
25
28
  return null;
26
29
  }
27
30
  }
28
- /** Read view only. The file is not rewritten here; the next override write
29
- * persists the translated id because it round-trips this view. */
30
- function translateOverrideNpm(entry) {
31
- if (!entry || typeof entry.npm !== 'string')
31
+ function normalizeOverrideEntry(entry) {
32
+ if (!entry)
32
33
  return entry;
33
- const npm = protocolIdFromNpm(entry.npm);
34
- if (npm === entry.npm)
34
+ if (entry.protocols === undefined)
35
35
  return entry;
36
- if (npm === undefined) {
36
+ const list = normalizeProtocols(entry.protocols);
37
+ if (list.length === 0) {
37
38
  const rest = { ...entry };
38
- delete rest.npm;
39
+ delete rest.protocols;
39
40
  return rest;
40
41
  }
41
- return { ...entry, npm };
42
+ return { ...entry, protocols: list };
42
43
  }
43
44
  export function getOverride(providerId, modelId) {
44
45
  return readOverridesStore()?.models[overrideKey(providerId, modelId)];
@@ -46,6 +47,7 @@ export function getOverride(providerId, modelId) {
46
47
  function persist(store) {
47
48
  const file = getOverridesStorePath();
48
49
  store.updated = Date.now();
50
+ store.version = 2;
49
51
  fs.mkdirSync(path.dirname(file), { recursive: true });
50
52
  const tmp = `${file}.tmp.${process.pid}.${Date.now()}`;
51
53
  fs.writeFileSync(tmp, JSON.stringify(store), 'utf8');
@@ -53,7 +55,7 @@ function persist(store) {
53
55
  }
54
56
  export function upsertOverride(providerId, modelId, entry) {
55
57
  try {
56
- const store = readOverridesStore() ?? { version: 1, updated: 0, models: {} };
58
+ const store = readOverridesStore() ?? { version: 2, updated: 0, models: {} };
57
59
  const merged = { ...(store.models[overrideKey(providerId, modelId)] ?? {}) };
58
60
  if (entry.name !== undefined)
59
61
  merged.name = entry.name;
@@ -75,12 +77,13 @@ export function upsertOverride(providerId, modelId, entry) {
75
77
  merged.disabled = entry.disabled;
76
78
  if (entry.reasoningEfforts !== undefined)
77
79
  merged.reasoningEfforts = entry.reasoningEfforts;
78
- if (entry.npm !== undefined) {
79
- const npm = protocolIdFromNpm(entry.npm);
80
- if (npm === undefined)
81
- delete merged.npm;
80
+ if (entry.protocols !== undefined) {
81
+ // Console may still post a singular SDK string via a one-element list.
82
+ const list = normalizeProtocols(entry.protocols.map((p) => protocolIdFromNpm(p) ?? p));
83
+ if (list.length === 0)
84
+ delete merged.protocols;
82
85
  else
83
- merged.npm = npm;
86
+ merged.protocols = list;
84
87
  }
85
88
  if (entry.defaultEffort !== undefined) {
86
89
  if (entry.defaultEffort === null)
@@ -606,7 +606,7 @@ export class CatalogRepository {
606
606
  unified.set(v.id, {
607
607
  id: v.id,
608
608
  name: v.name,
609
- npm: v.npm,
609
+ protocols: v.protocols,
610
610
  baseURL: v.baseURL,
611
611
  // dynamic tag — final value derived at the step-5 mapping
612
612
  custom: false,
@@ -782,8 +782,8 @@ export class CatalogRepository {
782
782
  ? [{ type: 'effort', values: [...entry.reasoningEfforts] }]
783
783
  : [{ type: 'toggle' }]; // empty = no explicit level control
784
784
  }
785
- if (entry.npm !== undefined)
786
- model.npm = entry.npm;
785
+ if (entry.protocols !== undefined)
786
+ model.protocols = entry.protocols;
787
787
  if (entry.defaultEffort !== undefined) {
788
788
  if (entry.defaultEffort === null)
789
789
  delete model.defaultEffort; // clear → follow catalog/def
@@ -2,9 +2,9 @@ import type { CatalogProviderRecord, CatalogSourceState } from '../types.js';
2
2
  export declare function modelsDevLogoUrl(providerId: string): string;
3
3
  /** Pure normalizer (unit-tested without network). models.dev shape ≈ opencode schema. */
4
4
  export declare function normalizeModelsDev(raw: Record<string, any>): CatalogProviderRecord[];
5
- /** SDK package strings on a catalog record become OCR protocol ids.
6
- * Idempotent: a record that already holds protocol ids is unchanged in value.
7
- * Cache replays call this too — those files skip normalizeModelsDev. */
5
+ /** External npm / raw protocol strings become OCR `protocols: string[]`.
6
+ * Idempotent on already-canonical ids. Cache replays call this too, including
7
+ * caches a pre-protocols build wrote in the retired singular `npm` slot. */
8
8
  export declare function withProtocolIds(providers: CatalogProviderRecord[]): CatalogProviderRecord[];
9
9
  /**
10
10
  * Sync models.dev: network → 24h cache → stale-on-error.