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
@@ -32,10 +32,14 @@ import type { AccessTap } from '../forward-proxy/access-log.js';
32
32
  */
33
33
  /** The three extension axes a plugin can occupy (ADR-0017 / ADR-0027). */
34
34
  export type PluginType = 'model-service' | 'client-gateway' | 'client-adapter';
35
+ /** The outbound leg a gateway declares for the hosts it claims (ADR-0018
36
+ * precedence step 3). `inherit` — the spelling of "absent" — means the
37
+ * catch-all row still decides, so declaring a claim changes no routing. */
38
+ export type PluginClaimEgress = 'inherit' | 'proxy' | 'direct';
35
39
  /**
36
40
  * One slot a package fills. `wires` belongs to a model-service part, `hosts`
37
- * to a client-gateway part; a client-adapter part carries neither (its
38
- * contribution is a Client Hub hook, not a wire or a claim).
41
+ * and `egress` to a client-gateway part; a client-adapter part carries none of
42
+ * them (its contribution is a Client Hub hook, not a wire or a claim).
39
43
  */
40
44
  export interface PluginPart {
41
45
  type: PluginType;
@@ -45,13 +49,26 @@ export interface PluginPart {
45
49
  /** SNI hosts this part claims on the forward proxy. Required non-empty on a
46
50
  * client-gateway part, rejected elsewhere. */
47
51
  hosts?: string[];
52
+ /** Where the bytes of EXACTLY these hosts leave the machine. Vendor knowledge
53
+ * ("this endpoint is unreachable direct here"), never an address: the
54
+ * outbound proxy it means is the operator's `config.proxy`. Rejected on a
55
+ * wildcard claim, which would pin every host on the machine. */
56
+ egress?: PluginClaimEgress;
48
57
  }
49
58
  export interface PluginManifest {
50
59
  id: string;
51
60
  name: string;
52
61
  version: string;
53
- /** Plugin contract version (ADR-0017 §6). Must EQUAL the host's
54
- * `SUPPORTED_PLUGIN_API` — v1 promises no legacy or forward compatibility. */
62
+ /** Plugin contract version (ADR-0017 §6): the surface this package was
63
+ * written against. Must sit inside the host's supported contract window
64
+ * (`[MIN_SUPPORTED_PLUGIN_API, SUPPORTED_PLUGIN_API]`).
65
+ *
66
+ * THIS is the engine declaration (ADR-0036 Amendment 1): the engine version
67
+ * is the contract version, so a package names the ONE engine it was
68
+ * developed against and nothing else. There used to be a separate
69
+ * `engines: { plugin: <semver window> }` map beside it; it was removed
70
+ * because it could only ever restate this integer in a second vocabulary,
71
+ * which is two truths for one fact. A legacy `engines` key is ignored. */
55
72
  apiVersion: number;
56
73
  /** Single-part shorthand (ADR-0028). Present on every one-axis package;
57
74
  * a multi-part package declares `parts` instead and omits this — the two
@@ -67,6 +84,8 @@ export interface PluginManifest {
67
84
  * metadata only — the runtime truth is the module's `hosts`). Single-part
68
85
  * form of `parts[].hosts`. */
69
86
  hosts?: string[];
87
+ /** Outbound leg for the claimed hosts. Single-part form of `parts[].egress`. */
88
+ egress?: PluginClaimEgress;
70
89
  /** Plain string, or a locale map ({"zh-CN": …, "en-US": …}) — the console
71
90
  * picks by current UI locale and falls back to en-US / the raw value. */
72
91
  description?: string | Record<string, string>;
@@ -76,10 +95,24 @@ export interface PluginManifest {
76
95
  * warning's `params`. Core-owned codes (`ca_not_trusted`, …) keep core
77
96
  * wording — a package declares only codes it introduced. */
78
97
  warningLabels?: Record<string, string | Record<string, string>>;
79
- /** Logo asset inside the package (served at /api/admin/plugins/:id/logo). */
98
+ /** Package-owned client presentation texts (ADR-0027): success toasts, the
99
+ * card hint, per-reasonCode failure copy and family-card labels — every
100
+ * string the console used to hardcode per client id. Core must never
101
+ * string-reference a package client id; the copy travels with the package. */
102
+ clientText?: ClientTextManifest;
103
+ /** Roster sort key among contributed hooks (lower sorts first). Absent =
104
+ * alphabetical after every ranked hook; the core popularity table
105
+ * (`utils/popularity.ts`) stays host/core-only. */
106
+ clientRank?: number;
80
107
  logo?: string;
81
108
  /** Provider presets this plugin can pre-provision (shown on the plugins page). */
82
109
  presets?: PluginProviderPreset[];
110
+ /** Release history shown by the console's Plugins page. Entries
111
+ * are declared NEWEST FIRST; the console renders them in manifest order and
112
+ * never re-sorts, so a pre-release or a backported fix keeps the author's
113
+ * placement. Purely presentational: nothing in the loader, router or config
114
+ * merge reads it. */
115
+ changelog?: PluginChangelogEntry[];
83
116
  /** Operator-facing configuration fields (ADR-0017). Flat primitives only —
84
117
  * the console renders the settings form generically from this; values are
85
118
  * stored as a plugin artifact (<pluginsRoot>/config/<id>.json), never in
@@ -121,9 +154,11 @@ export interface PluginConfigSection {
121
154
  /** The closed widget vocabulary the CONSOLE owns (ADR-0017 §7). A plugin names
122
155
  * a control, never a layout, ordering or markup: 'text' is the default for a
123
156
  * `string`, 'textarea' a multi-line box, 'model' a single model-ref picker
124
- * bound to the gateway catalog, 'models' a multi-pick list of model refs.
157
+ * bound to the gateway catalog, 'models' a multi-pick list of model refs,
158
+ * 'aliases' a row table of `client=target[#label]` mapping specs (a client's
159
+ * own model id on the left, an OCR model on the right).
125
160
  * A control that cannot drive the field's type fails the manifest. */
126
- export type PluginConfigControl = 'text' | 'textarea' | 'model' | 'models' | 'segmented' | 'apiKey';
161
+ export type PluginConfigControl = 'text' | 'textarea' | 'model' | 'models' | 'aliases' | 'segmented' | 'apiKey';
127
162
  /** One flat field of a plugin's operator-facing configuration. Primitives
128
163
  * only: the console renders string/number/boolean/string[]/enum inputs
129
164
  * generically. `title`/`desc` follow the manifest locale-map convention. */
@@ -176,14 +211,49 @@ export interface PluginConfigField {
176
211
  placement?: 'drawer' | 'card' | 'none';
177
212
  }
178
213
  /** Options/result seam shared with opencode/probe.ts (concrete types live there). */
214
+ /** What the console hands a vendor web-login flow (ADR-0017 / ADR-0022).
215
+ *
216
+ * `provider` is the provider-def id the operator is connecting. The console
217
+ * ALWAYS knows it (it is the route's `:id`), so a plugin that dials its
218
+ * vendor's login endpoints can hand it to `host.fetch` and let the operator's
219
+ * proxy split govern sign-in exactly as it governs inference — a login that
220
+ * has to reach a geo-blocked vendor host needs the same egress a completion
221
+ * does. Optional only for compatibility with packages written before the
222
+ * field existed; treat an absent value as "no provider-scoped rule matches". */
223
+ export interface PluginWebLoginOptions {
224
+ baseURL: string;
225
+ provider?: string;
226
+ }
179
227
  export interface PluginProbeOptions {
180
228
  provider?: string;
181
229
  model: string;
182
230
  apiKey: string;
183
231
  baseURL: string;
232
+ /** Capabilities the caller already knows about the model (from its def).
233
+ * A plugin probe builds a real request, so a model flag it has to guess is
234
+ * a model it can mis-test: qoder's probe once hardcoded "not a reasoning
235
+ * model" and reported 400 for every always-thinking model the gateway
236
+ * serves fine. Absent = the plugin's own pulled def decides. */
237
+ capabilities?: {
238
+ reasoning?: boolean;
239
+ vision?: boolean;
240
+ };
184
241
  headers?: Record<string, string>;
185
242
  timeoutMs?: number;
186
243
  }
244
+ /** One release note of a plugin's `changelog` (manifest presentation only).
245
+ * `version` need not equal the manifest version — the history keeps the
246
+ * versions an operator already knows, and the console marks the entry that
247
+ * matches the installed one. `notes` follows the manifest locale-map
248
+ * convention and is rendered as markdown. */
249
+ export interface PluginChangelogEntry {
250
+ /** Release identifier as the package names it (semver is not required). */
251
+ version: string;
252
+ /** Release date, `YYYY-MM-DD`; display only. Absent = undated entry. */
253
+ date?: string;
254
+ /** Release notes — plain string or BCP-47 keyed map of strings. */
255
+ notes: string | Record<string, string>;
256
+ }
187
257
  /** A provider definition the plugin offers to pre-provision (e.g. one per
188
258
  * region). Registration is ALWAYS an explicit operator action from the
189
259
  * plugins page — the host never writes provider defs on install by itself
@@ -212,15 +282,26 @@ export interface PluginProviderPreset {
212
282
  keyHint?: string | Record<string, string>;
213
283
  }
214
284
  /** Credential methods the console may offer for this plugin's providers, in
215
- * display order; the FIRST entry is the default selection. 'webLogin'
216
- * requires the webLogin capability below. Absent = legacy behavior (the key
217
- * form always renders, the web tab appears after it when webLogin exists). */
218
- export type PluginAuthType = 'webLogin' | 'key';
285
+ * display order; the FIRST entry is the default selection.
286
+ * - `none` — connect with no OCR credential (the plugin owns login)
287
+ * - `webLogin` — console web login; requires the webLogin capability below
288
+ * - `key` — paste a credential
289
+ * Absent = legacy behavior (the key form always renders, the web tab appears
290
+ * after it when webLogin exists). */
291
+ export type PluginAuthType = 'none' | 'webLogin' | 'key';
219
292
  /** Chat is the versioned external plugin contract, never the core IR. */
220
293
  export interface ChatPluginProvider {
221
294
  name: string;
222
- createCompletion(request: ChatCompletionRequest, model: ModelRegistration, upstreamEventContext?: UpstreamEventContext, credential?: CallCredential): Promise<ChatCompletionResponse>;
223
- createStream?(request: ChatCompletionRequest, model: ModelRegistration, upstreamEventContext?: UpstreamEventContext, credential?: CallCredential): Promise<AsyncIterable<ChatCompletionChunk>>;
295
+ createCompletion(request: ChatCompletionRequest, model: ModelRegistration, upstreamEventContext?: UpstreamEventContext, credential?: CallCredential,
296
+ /**
297
+ * Resolved OCR conversation id for this call (`x-session-id`, a minted
298
+ * `sess_…`, or any other resolver result). Present on every routed
299
+ * execution. The capture handle has no session field.
300
+ */
301
+ sessionId?: string): Promise<ChatCompletionResponse>;
302
+ createStream?(request: ChatCompletionRequest, model: ModelRegistration, upstreamEventContext?: UpstreamEventContext, credential?: CallCredential,
303
+ /** Same conversation id as `createCompletion`. */
304
+ sessionId?: string): Promise<AsyncIterable<ChatCompletionChunk>>;
224
305
  }
225
306
  export interface ModelServicePlugin {
226
307
  /** Build the versioned Chat executor for one declared plugin wire. */
@@ -251,16 +332,12 @@ export interface ModelServicePlugin {
251
332
  * credential store. */
252
333
  webLogin?: {
253
334
  /** Begin a login session and return the authorize URL for the browser. */
254
- start(opts: {
255
- baseURL: string;
256
- }): Promise<{
335
+ start(opts: PluginWebLoginOptions): Promise<{
257
336
  authUrl: string;
258
337
  }>;
259
338
  /** Poll the in-flight session once. done+token = login finished and the
260
339
  * plugin has already persisted its long-lived token bundle. */
261
- poll(opts: {
262
- baseURL: string;
263
- }): Promise<{
340
+ poll(opts: PluginWebLoginOptions): Promise<{
264
341
  done: boolean;
265
342
  error?: string;
266
343
  token?: string;
@@ -270,8 +347,7 @@ export interface ModelServicePlugin {
270
347
  * vendor console) and pastes the resulting token/code back. Absent = the
271
348
  * vendor flow has no user-visible token — the console hides the paste
272
349
  * box and relies on poll alone. */
273
- submit?(opts: {
274
- baseURL: string;
350
+ submit?(opts: PluginWebLoginOptions & {
275
351
  code: string;
276
352
  }): Promise<{
277
353
  ok: boolean;
@@ -298,6 +374,18 @@ export interface ModelServicePlugin {
298
374
  * period-aware ordering.
299
375
  */
300
376
  quotaCheck?(ctx: QuotaAdapterContext): Promise<QuotaProbeOutcome>;
377
+ /**
378
+ * Optional: the upstream hosts this plugin talks to for a given provider
379
+ * entry, so the core can build an egress-aware transport for INJECTED
380
+ * seams (`quotaCheck`'s `fetchImpl`) without the plugin naming a proxy.
381
+ *
382
+ * Only needed where the core, not the plugin, owns the call — a plugin that
383
+ * does its own dialing uses `host.fetch` instead. Returned URLs are matched
384
+ * against `proxy.includes` / `proxy.excludes` per call site at dial time, so
385
+ * an entry that spreads work over several origins is still classified
386
+ * correctly, one origin per attempt.
387
+ */
388
+ egressOrigins?(providerId: string, baseURL?: string): readonly string[];
301
389
  /** Optional: notified after the operator saves plugin settings; the merged
302
390
  * values arrive pre-validated (same object `host.config()` returns). */
303
391
  onConfigChange?(config: Record<string, unknown>): void | Promise<void>;
@@ -394,12 +482,45 @@ export interface ModelServicePluginHost {
394
482
  /** Operator configuration, merged (defaults ← stored artifact, validated).
395
483
  * Call-time lookup — always current after a console save. */
396
484
  config(): Record<string, unknown>;
485
+ /** The live OCR home directory — plugin state that must outlive the process
486
+ * (a device identity, sidecar files) belongs under it, never next to the
487
+ * packaged bundle, which an upgrade replaces. */
488
+ ocrHome(): string;
397
489
  /** The directory this plugin's files were loaded from — the ONE asset root.
398
490
  * Packaged plugins are a SINGLE flattened `index.js`, so a path derived
399
491
  * from `import.meta.url` of an inner source module does not survive
400
492
  * packaging; a plugin that ships data files (`prompts/`, `protos/`, ...)
401
493
  * must resolve them from here (ADR-0017 §6). */
402
494
  pluginDir(): string;
495
+ /**
496
+ * Egress-aware `fetch` — the ONLY way a model-service plugin may reach its
497
+ * upstream (ADR-0022). Wraps the core's `proxiedFetch`, so the operator's
498
+ * `proxy.includes` / `proxy.excludes` split, `proxy.enabled`, the
499
+ * `manual`/`mihomo` endpoint choice and the loopback bypass all apply to
500
+ * plugin wires exactly as they do to the four core transports.
501
+ *
502
+ * A plugin that calls the global `fetch` itself bypasses every one of those:
503
+ * it goes direct whatever the operator configured, and the probe has no
504
+ * honest egress to report (the trace leaves it UNKNOWN rather than claiming
505
+ * `direct`). That is a capability gap, not a policy — hand the request to
506
+ * this seam instead.
507
+ *
508
+ * `match` carries the logical caller so the include/exclude lists can
509
+ * evaluate provider- and model-scoped patterns. Omitting it makes the split
510
+ * answer `undefined` (allowlist needs a match), which is why every real call
511
+ * passes one.
512
+ */
513
+ fetch: (url: string, init?: RequestInit, match?: {
514
+ provider?: string;
515
+ model?: string;
516
+ }) => Promise<Response>;
517
+ /** Resolve the proxy this plugin WOULD take for `url`, without dialing —
518
+ * `undefined` means direct. Lets a plugin report its egress in a `probe()`
519
+ * result without duplicating the matching rules core-side. */
520
+ resolveProxy: (url: string, match?: {
521
+ provider?: string;
522
+ model?: string;
523
+ }) => string | undefined;
403
524
  /** Model-pull services (the auto-pull.ts seams, host-implemented). */
404
525
  pull: {
405
526
  getProviderNode(id: string): {
@@ -471,6 +592,26 @@ export interface ClientGatewayPlugin {
471
592
  /** Optional: notified after the operator saves plugin settings; the merged
472
593
  * values arrive pre-validated (same object `host.config()` returns). */
473
594
  onConfigChange?(config: Record<string, unknown>): void | Promise<void>;
595
+ /**
596
+ * The outbound leg this gateway claims for one of its hosts (ADR-0018 Revision 5).
597
+ * Evaluated PER REQUEST, so a gateway may change its mind as its own state
598
+ * changes, and it may answer host by host — this is the half where vendor
599
+ * knowledge lives, and it is the plugin's code speaking, never a rule row the
600
+ * operator has to keep. `undefined` means "code has no opinion", and the
601
+ * decision falls to what the operator set for this plugin, then to the
602
+ * manifest declaration.
603
+ *
604
+ * It is OVERRULED, not consulted, when the operator explicitly picked a leg
605
+ * for this plugin in the settings drawer: the plugin-level switch is the
606
+ * operator's word on every host this package claims.
607
+ *
608
+ * A WILDCARD gateway gets no vote: `'*'` is a read permission over every host
609
+ * the machine reaches, and an egress opinion attached to it would pin
610
+ * traffic this package does not own.
611
+ */
612
+ egressFor?(info: {
613
+ host: string;
614
+ }): PluginClaimEgress | undefined;
474
615
  }
475
616
  /** One decrypted `Upgrade:` handshake handed to a client gateway. */
476
617
  export interface ClientGatewayUpgradeContext {
@@ -691,6 +832,22 @@ export interface ClientAdapterHost {
691
832
  key: string;
692
833
  } | null;
693
834
  }
835
+ /** Text or locale map — the same shape `description` / `warningLabels` use;
836
+ * `{param}` placeholders interpolate like the warning labels do. */
837
+ export type ClientTextEntry = string | Record<string, string>;
838
+ /**
839
+ * Package-owned client presentation texts (ADR-0027). `errors` keys mirror the
840
+ * adapter's own `ClientActionResult.reasonCode` spellings (lowerCamel or
841
+ * snake_case, verbatim); `family` keys label the `ClientHookStatus.products`
842
+ * rendering (product_count, ca, ca_imported, …).
843
+ */
844
+ export interface ClientTextManifest {
845
+ setupOk?: ClientTextEntry;
846
+ teardownOk?: ClientTextEntry;
847
+ hint?: ClientTextEntry;
848
+ errors?: Record<string, ClientTextEntry>;
849
+ family?: Record<string, ClientTextEntry>;
850
+ }
694
851
  /** One plugin known to the host — loaded, or the reason it could not load. */
695
852
  export interface PluginView {
696
853
  id: string;
@@ -706,6 +863,10 @@ export interface PluginView {
706
863
  description?: string | Record<string, string>;
707
864
  /** This package's own advisory texts, keyed by warning code (see PluginManifest). */
708
865
  warningLabels?: Record<string, string | Record<string, string>>;
866
+ /** Package-owned client presentation texts (see PluginManifest.clientText). */
867
+ clientText?: ClientTextManifest;
868
+ /** Release history (see PluginManifest.changelog); rendered in declared order. */
869
+ changelog?: PluginChangelogEntry[];
709
870
  presets?: PluginProviderPreset[];
710
871
  /** Logo asset inside the package (served at /api/admin/plugins/:id/logo). */
711
872
  logo?: string;
@@ -717,5 +878,10 @@ export interface PluginView {
717
878
  /** Wall-clock ms when this view's code was imported into the runtime (undefined for disabled/failed rows). */
718
879
  loadedAt?: number;
719
880
  error?: string;
881
+ /** True when the loader refused this package on ENGINE compatibility
882
+ * (ADR-0036). `disabled` is set too — a refused package answers nothing —
883
+ * but the cause and the remedy differ: the fix is a newer gateway or a
884
+ * newer package, never the disable switch. */
885
+ incompatible?: boolean;
720
886
  }
721
887
  export type { CallCredential };
@@ -45,6 +45,7 @@ export declare function validateSystemoneRequest(body: unknown): SystemoneValida
45
45
  export declare function decisionReasoningEffort(model: {
46
46
  supportedReasoningEfforts?: readonly ReasoningEffort[];
47
47
  supportsReasoningEffort?: boolean;
48
+ reasoningDisableable?: boolean;
48
49
  effortMap?: EffortMap;
49
50
  }): ReasoningEffort | undefined;
50
51
  /**
@@ -87,7 +87,12 @@ export function decisionReasoningEffort(model) {
87
87
  const mapped = applyEffortMap(model.effortMap, 'none');
88
88
  if (mapped !== 'none')
89
89
  return mapped;
90
- const explicit = model.supportedReasoningEfforts;
90
+ // An always-think model (ADR-0035) never serves `none`: strip it before
91
+ // reading the lowest level, or a stale table would pin thinking-off on the
92
+ // decision wire. A set that empties under the strip falls through.
93
+ const explicit = model.reasoningDisableable === false
94
+ ? model.supportedReasoningEfforts?.filter((e) => e !== 'none')
95
+ : model.supportedReasoningEfforts;
91
96
  if (explicit && explicit.length > 0) {
92
97
  let lowest = explicit[0];
93
98
  for (const level of explicit) {
@@ -81,12 +81,18 @@ function isJsonModeRejection(err) {
81
81
  * is no query API for the real enum, but a rejection usually discloses it.
82
82
  */
83
83
  const EFFORT_MENTION_RE = new RegExp(`\\b(${EFFORT_LADDER.join('|')})\\b`, 'gi');
84
- function parseMentionedEfforts(errorText, exclude) {
84
+ function parseMentionedEfforts(errorText, exclude, disableable) {
85
85
  const found = new Set();
86
86
  for (const token of errorText.match(EFFORT_MENTION_RE) || []) {
87
87
  const level = token.toLowerCase();
88
- if (level !== exclude)
89
- found.add(level);
88
+ if (level === exclude)
89
+ continue;
90
+ // An always-think model's vendor may still ENUMERATE `none` in a generic
91
+ // rejection string; learning it would memoize thinking-off for the process
92
+ // lifetime and bypass the capability strip (ADR-0035). Withhold it here.
93
+ if (disableable === false && level === 'none')
94
+ continue;
95
+ found.add(level);
90
96
  }
91
97
  return [...found].sort((a, b) => EFFORT_LADDER.indexOf(a) - EFFORT_LADDER.indexOf(b));
92
98
  }
@@ -115,10 +121,10 @@ function plannedEffort(model) {
115
121
  * response_format (one omit each) — at most 5 wire calls, and any rejection
116
122
  * the fallbacks do not cover rethrows immediately.
117
123
  *
118
- * `upstreamEventContext` is the capture identity for the call (decision layer
119
- * plumbing or the surface pipeline itself), or undefined:
120
- * every attempt — including the pin-repair re-pins — is a real wire call,
121
- * so each gets its own event pair through the registry's normal mechanism.
124
+ * `upstreamEventContext` is the archive label for the call, or undefined
125
+ * when capture is off. Every attempt, including pin-repair re-pins, is a
126
+ * real wire call and gets its own event pair. The executor is not given a
127
+ * conversation id: this call is a routing decision, not the user's session.
122
128
  */
123
129
  async function executeDecision(registry, model, request, signal, upstreamEventContext) {
124
130
  let attemptRequest = request;
@@ -139,9 +145,13 @@ async function executeDecision(registry, model, request, signal, upstreamEventCo
139
145
  if (rejections >= 2)
140
146
  next = 'omit';
141
147
  else {
142
- const mentioned = parseMentionedEfforts(err.errorBody || '', attemptedEffort);
148
+ const mentioned = parseMentionedEfforts(err.errorBody || '', attemptedEffort, model.reasoningDisableable);
143
149
  next = mentioned.length > 0 ? mentioned[0] : attemptedEffort === 'none' ? 'low' : 'omit';
144
150
  }
151
+ // Never memoize thinking-off for an always-think model (ADR-0035): the
152
+ // learned pin would otherwise send `none` on every later decision call.
153
+ if (next === 'none' && model.reasoningDisableable === false)
154
+ next = 'omit';
145
155
  effortPreferenceByModel.set(model.id, next);
146
156
  console.warn(`[systemone] upstream rejected reasoning_effort '${attemptedEffort}' for model '${model.id}' — downgrading the pin to '${next}'`);
147
157
  const reasoning = { ...attemptRequest.reasoning };
@@ -0,0 +1,12 @@
1
+ import type { LLMProvider, UpstreamEventContext, CallCredential } from './base.js';
2
+ import type { ModelRegistration, ProviderConfig } from '../config/types.js';
3
+ import type { CanonicalRequest, CanonicalResponse, StreamEvent } from '../ir/types.js';
4
+ /** Anthropic Messages upstream. The provider speaks Canonical IR only. */
5
+ export declare class AnthropicMessagesProvider implements LLMProvider {
6
+ name: string;
7
+ private config;
8
+ constructor(config: ProviderConfig);
9
+ private headers;
10
+ createCompletion(request: CanonicalRequest, model: ModelRegistration, upstreamEventContext?: UpstreamEventContext, credential?: CallCredential): Promise<CanonicalResponse>;
11
+ createStream(request: CanonicalRequest, model: ModelRegistration, upstreamEventContext?: UpstreamEventContext, credential?: CallCredential): Promise<AsyncIterable<StreamEvent>>;
12
+ }
@@ -0,0 +1,53 @@
1
+ import { anthropicResponseToIR, canonicalToAnthropicPayload } from '../ir/adapters/anthropic-messages.js';
2
+ import { AnthropicMessagesStreamDecoder } from '../ir/adapters/anthropic-messages-stream.js';
3
+ import { DEFAULT_PROVIDER_TIMEOUT_MS, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DEFAULT_STREAM_TIMEOUT_MS, } from '../config/defaults.js';
4
+ import { anthropicMessagesUrl } from './wire.js';
5
+ import { mergeCommaHeader, postProviderJson, setDefaultHeaderCaseInsensitive, setHeaderCaseInsensitive } from './http-json.js';
6
+ import { postProviderStream } from './http-stream.js';
7
+ /** Anthropic Messages upstream. The provider speaks Canonical IR only. */
8
+ export class AnthropicMessagesProvider {
9
+ name;
10
+ config;
11
+ constructor(config) {
12
+ this.name = config.name;
13
+ this.config = config;
14
+ }
15
+ headers(credential) {
16
+ const headers = {
17
+ ...this.config.headers,
18
+ };
19
+ setDefaultHeaderCaseInsensitive(headers, 'Content-Type', 'application/json');
20
+ setDefaultHeaderCaseInsensitive(headers, 'anthropic-version', '2023-06-01');
21
+ setHeaderCaseInsensitive(headers, 'x-api-key', credential?.key ?? this.config.apiKey);
22
+ mergeCommaHeader(headers, 'anthropic-beta', 'prompt-caching-2024-07-31');
23
+ return headers;
24
+ }
25
+ async createCompletion(request, model, upstreamEventContext, credential) {
26
+ const data = await postProviderJson({
27
+ url: anthropicMessagesUrl(this.config.baseUrl),
28
+ headers: this.headers(credential),
29
+ payload: canonicalToAnthropicPayload(request, model),
30
+ model,
31
+ provider: this.name,
32
+ label: 'anthropic',
33
+ timeoutMs: this.config.timeoutMs || DEFAULT_PROVIDER_TIMEOUT_MS,
34
+ upstreamEventContext,
35
+ });
36
+ return anthropicResponseToIR(data);
37
+ }
38
+ async createStream(request, model, upstreamEventContext, credential) {
39
+ return postProviderStream({
40
+ url: anthropicMessagesUrl(this.config.baseUrl),
41
+ headers: this.headers(credential),
42
+ payload: { ...canonicalToAnthropicPayload(request, model), stream: true },
43
+ model,
44
+ provider: this.name,
45
+ label: 'anthropic',
46
+ timeoutMs: this.config.streamTimeoutMs || DEFAULT_STREAM_TIMEOUT_MS,
47
+ idleTimeoutMs: this.config.streamIdleTimeoutMs || DEFAULT_STREAM_IDLE_TIMEOUT_MS,
48
+ upstreamEventContext,
49
+ createDecoder: () => new AnthropicMessagesStreamDecoder(),
50
+ parseBuffered: (body) => anthropicResponseToIR(body),
51
+ });
52
+ }
53
+ }
@@ -1,13 +1,12 @@
1
- import { LLMProvider, type UpstreamEventContext, type CallCredential } from './base.js';
2
- import { ModelRegistration, ProviderConfig } from '../config/types.js';
3
- import { ChatCompletionRequest, ChatCompletionResponse } from '../types/openai.js';
4
- /** Pure payload builder: chat-completions request → Anthropic Messages payload. */
5
- export declare function buildAnthropicPayload(request: ChatCompletionRequest, model: ModelRegistration): Record<string, any>;
6
- /** Pure response mapper: Anthropic Messages payload → chat-completions response. */
7
- export declare function anthropicToChatCompletion(data: any, model: ModelRegistration): ChatCompletionResponse;
1
+ import type { LLMProvider, UpstreamEventContext, CallCredential } from './base.js';
2
+ import type { ModelRegistration, ProviderConfig } from '../config/types.js';
3
+ import type { CanonicalRequest, CanonicalResponse, StreamEvent } from '../ir/types.js';
4
+ /** Anthropic Messages upstream. The provider speaks Canonical IR only. */
8
5
  export declare class AnthropicProvider implements LLMProvider {
9
6
  name: string;
10
7
  private config;
11
8
  constructor(config: ProviderConfig);
12
- createCompletion(request: ChatCompletionRequest, model: ModelRegistration, upstreamEventContext?: UpstreamEventContext, credential?: CallCredential): Promise<ChatCompletionResponse>;
9
+ private headers;
10
+ createCompletion(request: CanonicalRequest, model: ModelRegistration, upstreamEventContext?: UpstreamEventContext, credential?: CallCredential): Promise<CanonicalResponse>;
11
+ createStream(request: CanonicalRequest, model: ModelRegistration, upstreamEventContext?: UpstreamEventContext, credential?: CallCredential): Promise<AsyncIterable<StreamEvent>>;
13
12
  }