omnicell-router 0.8.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/README.md +26 -7
  2. package/README.zh-CN.md +18 -5
  3. package/backend/dist/auth/api-keys.js +11 -0
  4. package/backend/dist/auth/key-models.d.ts +36 -0
  5. package/backend/dist/auth/key-models.js +99 -0
  6. package/backend/dist/capture/recorder.d.ts +4 -10
  7. package/backend/dist/capture/recorder.js +6 -58
  8. package/backend/dist/cli/clients/activity.js +2 -0
  9. package/backend/dist/cli/clients/base.d.ts +36 -11
  10. package/backend/dist/cli/clients/base.js +31 -15
  11. package/backend/dist/cli/clients/claude.d.ts +9 -0
  12. package/backend/dist/cli/clients/claude.js +6 -0
  13. package/backend/dist/cli/clients/codex.d.ts +78 -0
  14. package/backend/dist/cli/clients/codex.js +475 -57
  15. package/backend/dist/cli/clients/core-adapters.d.ts +1 -1
  16. package/backend/dist/cli/clients/core-adapters.js +1 -1
  17. package/backend/dist/cli/clients/dsh.d.ts +8 -0
  18. package/backend/dist/cli/clients/dsh.js +5 -0
  19. package/backend/dist/cli/clients/follow-catalog-sync.d.ts +62 -0
  20. package/backend/dist/cli/clients/follow-catalog-sync.js +435 -0
  21. package/backend/dist/cli/clients/grok.d.ts +15 -1
  22. package/backend/dist/cli/clients/grok.js +16 -2
  23. package/backend/dist/cli/clients/index.d.ts +13 -1
  24. package/backend/dist/cli/clients/index.js +97 -19
  25. package/backend/dist/cli/clients/kimi.d.ts +6 -0
  26. package/backend/dist/cli/clients/kimi.js +3 -0
  27. package/backend/dist/cli/clients/launcher.d.ts +1 -1
  28. package/backend/dist/cli/clients/model-meta.js +6 -3
  29. package/backend/dist/cli/clients/omp.d.ts +6 -0
  30. package/backend/dist/cli/clients/omp.js +3 -0
  31. package/backend/dist/cli/clients/openclaw.d.ts +6 -0
  32. package/backend/dist/cli/clients/openclaw.js +3 -0
  33. package/backend/dist/cli/clients/opencode.d.ts +8 -0
  34. package/backend/dist/cli/clients/opencode.js +8 -2
  35. package/backend/dist/cli/clients/pi.d.ts +6 -0
  36. package/backend/dist/cli/clients/pi.js +3 -0
  37. package/backend/dist/cli/clients/reserved.js +2 -0
  38. package/backend/dist/cli/clients/update-check.d.ts +37 -0
  39. package/backend/dist/cli/clients/update-check.js +309 -0
  40. package/backend/dist/cli/clients/workbuddy.d.ts +19 -0
  41. package/backend/dist/cli/clients/workbuddy.js +66 -0
  42. package/backend/dist/cli/index.js +5 -4
  43. package/backend/dist/cli/paths.js +8 -0
  44. package/backend/dist/cli/types.d.ts +101 -16
  45. package/backend/dist/config/comments-en.js +34 -25
  46. package/backend/dist/config/comments-zh.js +33 -24
  47. package/backend/dist/config/defaults.d.ts +280 -22
  48. package/backend/dist/config/defaults.js +279 -21
  49. package/backend/dist/config/env.d.ts +10 -0
  50. package/backend/dist/config/env.js +3 -2
  51. package/backend/dist/config/index.d.ts +22 -1
  52. package/backend/dist/config/index.js +218 -43
  53. package/backend/dist/config/migrations/v0-to-v1.d.ts +2 -2
  54. package/backend/dist/config/migrations/v10-to-v11.d.ts +38 -0
  55. package/backend/dist/config/migrations/v10-to-v11.js +43 -0
  56. package/backend/dist/config/migrations/v4-to-v5.d.ts +36 -0
  57. package/backend/dist/config/migrations/v4-to-v5.js +42 -0
  58. package/backend/dist/config/migrations/v5-to-v6.d.ts +27 -0
  59. package/backend/dist/config/migrations/v5-to-v6.js +29 -0
  60. package/backend/dist/config/migrations/v6-to-v7.d.ts +45 -0
  61. package/backend/dist/config/migrations/v6-to-v7.js +97 -0
  62. package/backend/dist/config/migrations/v7-to-v8.d.ts +36 -0
  63. package/backend/dist/config/migrations/v7-to-v8.js +43 -0
  64. package/backend/dist/config/migrations/v8-to-v9.d.ts +38 -0
  65. package/backend/dist/config/migrations/v8-to-v9.js +43 -0
  66. package/backend/dist/config/migrations/v9-to-v10.d.ts +51 -0
  67. package/backend/dist/config/migrations/v9-to-v10.js +71 -0
  68. package/backend/dist/config/runtime.js +1 -1
  69. package/backend/dist/config/schema.d.ts +3 -3
  70. package/backend/dist/config/schema.js +18 -4
  71. package/backend/dist/config/types.d.ts +221 -41
  72. package/backend/dist/egress-proxy/asset-download.d.ts +54 -0
  73. package/backend/dist/egress-proxy/asset-download.js +420 -0
  74. package/backend/dist/egress-proxy/manual-node-spec.d.ts +92 -0
  75. package/backend/dist/egress-proxy/manual-node-spec.js +408 -0
  76. package/backend/dist/egress-proxy/mihomo-binary.d.ts +54 -0
  77. package/backend/dist/egress-proxy/mihomo-binary.js +278 -0
  78. package/backend/dist/egress-proxy/mihomo-client.d.ts +94 -0
  79. package/backend/dist/egress-proxy/mihomo-client.js +308 -0
  80. package/backend/dist/egress-proxy/mihomo-config.d.ts +40 -0
  81. package/backend/dist/egress-proxy/mihomo-config.js +161 -0
  82. package/backend/dist/egress-proxy/mihomo-geo.d.ts +87 -0
  83. package/backend/dist/egress-proxy/mihomo-geo.js +213 -0
  84. package/backend/dist/egress-proxy/mihomo-logs.d.ts +43 -0
  85. package/backend/dist/egress-proxy/mihomo-logs.js +84 -0
  86. package/backend/dist/egress-proxy/mihomo-pac.d.ts +37 -0
  87. package/backend/dist/egress-proxy/mihomo-pac.js +75 -0
  88. package/backend/dist/egress-proxy/mihomo-rules-import.d.ts +43 -0
  89. package/backend/dist/egress-proxy/mihomo-rules-import.js +193 -0
  90. package/backend/dist/egress-proxy/mihomo-sidecar.d.ts +81 -0
  91. package/backend/dist/egress-proxy/mihomo-sidecar.js +637 -0
  92. package/backend/dist/forward-proxy/egress.d.ts +50 -11
  93. package/backend/dist/forward-proxy/egress.js +63 -17
  94. package/backend/dist/forward-proxy/h2-forward.js +42 -15
  95. package/backend/dist/forward-proxy/index.d.ts +11 -8
  96. package/backend/dist/forward-proxy/index.js +27 -60
  97. package/backend/dist/forward-proxy/interceptor.d.ts +3 -2
  98. package/backend/dist/forward-proxy/interceptor.js +4 -4
  99. package/backend/dist/forward-proxy/relay.js +3 -3
  100. package/backend/dist/forward-proxy/rules.d.ts +4 -4
  101. package/backend/dist/forward-proxy/rules.js +25 -4
  102. package/backend/dist/forward-proxy/server.d.ts +12 -16
  103. package/backend/dist/forward-proxy/server.js +237 -171
  104. package/backend/dist/harness/host/hosts.js +3 -2
  105. package/backend/dist/index.js +59 -19
  106. package/backend/dist/ingress-proxy/access-log.d.ts +176 -0
  107. package/backend/dist/ingress-proxy/access-log.js +774 -0
  108. package/backend/dist/ingress-proxy/ca-inventory.d.ts +106 -0
  109. package/backend/dist/ingress-proxy/ca-inventory.js +525 -0
  110. package/backend/dist/ingress-proxy/ca-trust.d.ts +96 -0
  111. package/backend/dist/ingress-proxy/ca-trust.js +315 -0
  112. package/backend/dist/ingress-proxy/ca.d.ts +104 -0
  113. package/backend/dist/ingress-proxy/ca.js +273 -0
  114. package/backend/dist/ingress-proxy/data-dir.d.ts +28 -0
  115. package/backend/dist/ingress-proxy/data-dir.js +45 -0
  116. package/backend/dist/ingress-proxy/egress.d.ts +151 -0
  117. package/backend/dist/ingress-proxy/egress.js +364 -0
  118. package/backend/dist/ingress-proxy/h2-forward.d.ts +66 -0
  119. package/backend/dist/ingress-proxy/h2-forward.js +561 -0
  120. package/backend/dist/ingress-proxy/index.d.ts +24 -0
  121. package/backend/dist/ingress-proxy/index.js +144 -0
  122. package/backend/dist/ingress-proxy/interceptor.d.ts +25 -0
  123. package/backend/dist/ingress-proxy/interceptor.js +52 -0
  124. package/backend/dist/ingress-proxy/ordered-relay.d.ts +29 -0
  125. package/backend/dist/ingress-proxy/ordered-relay.js +46 -0
  126. package/backend/dist/ingress-proxy/relay.d.ts +54 -0
  127. package/backend/dist/ingress-proxy/relay.js +188 -0
  128. package/backend/dist/ingress-proxy/rules.d.ts +195 -0
  129. package/backend/dist/ingress-proxy/rules.js +348 -0
  130. package/backend/dist/ingress-proxy/server.d.ts +153 -0
  131. package/backend/dist/ingress-proxy/server.js +2065 -0
  132. package/backend/dist/ingress-proxy/sni.d.ts +35 -0
  133. package/backend/dist/ingress-proxy/sni.js +124 -0
  134. package/backend/dist/ingress-proxy/status.d.ts +32 -0
  135. package/backend/dist/ingress-proxy/status.js +15 -0
  136. package/backend/dist/ingress-proxy/system-proxy.d.ts +112 -0
  137. package/backend/dist/ingress-proxy/system-proxy.js +481 -0
  138. package/backend/dist/ingress-proxy/traffic-delete.d.ts +21 -0
  139. package/backend/dist/ingress-proxy/traffic-delete.js +64 -0
  140. package/backend/dist/ingress-proxy/traffic-delete.worker.d.ts +44 -0
  141. package/backend/dist/ingress-proxy/traffic-delete.worker.js +228 -0
  142. package/backend/dist/ingress-proxy/traffic-files.d.ts +10 -0
  143. package/backend/dist/ingress-proxy/traffic-files.js +10 -0
  144. package/backend/dist/ingress-proxy/upstream-tls.d.ts +46 -0
  145. package/backend/dist/ingress-proxy/upstream-tls.js +105 -0
  146. package/backend/dist/ingress-proxy/ws-frames.d.ts +45 -0
  147. package/backend/dist/ingress-proxy/ws-frames.js +153 -0
  148. package/backend/dist/ir/adapters/anthropic-messages-stream.js +6 -1
  149. package/backend/dist/ir/adapters/anthropic-messages.js +12 -5
  150. package/backend/dist/ir/adapters/google-gemini-stream.js +7 -2
  151. package/backend/dist/ir/adapters/google-gemini.js +5 -2
  152. package/backend/dist/ir/adapters/openai-chat-stream.js +5 -1
  153. package/backend/dist/ir/adapters/openai-chat.d.ts +25 -0
  154. package/backend/dist/ir/adapters/openai-chat.js +50 -6
  155. package/backend/dist/ir/adapters/openai-responses-output.d.ts +1 -0
  156. package/backend/dist/ir/adapters/openai-responses-output.js +67 -21
  157. package/backend/dist/ir/adapters/openai-responses-stream.d.ts +13 -0
  158. package/backend/dist/ir/adapters/openai-responses-stream.js +34 -1
  159. package/backend/dist/ir/adapters/openai-responses.d.ts +92 -1
  160. package/backend/dist/ir/adapters/openai-responses.js +163 -12
  161. package/backend/dist/ir/capabilities.js +4 -0
  162. package/backend/dist/ir/media.d.ts +20 -0
  163. package/backend/dist/ir/media.js +41 -0
  164. package/backend/dist/ir/tool-identity.d.ts +35 -0
  165. package/backend/dist/ir/tool-identity.js +40 -0
  166. package/backend/dist/ir/types.d.ts +9 -1
  167. package/backend/dist/ir/validate.d.ts +24 -0
  168. package/backend/dist/ir/validate.js +113 -63
  169. package/backend/dist/local/build-jobs.d.ts +66 -0
  170. package/backend/dist/local/build-jobs.js +243 -0
  171. package/backend/dist/local/detect.d.ts +32 -0
  172. package/backend/dist/local/detect.js +145 -0
  173. package/backend/dist/local/draft-match.d.ts +58 -0
  174. package/backend/dist/local/draft-match.js +124 -0
  175. package/backend/dist/local/engine-runtime.d.ts +522 -0
  176. package/backend/dist/local/engine-runtime.js +1 -0
  177. package/backend/dist/local/engines.d.ts +241 -0
  178. package/backend/dist/local/engines.js +651 -0
  179. package/backend/dist/local/gguf.d.ts +35 -0
  180. package/backend/dist/local/gguf.js +314 -0
  181. package/backend/dist/local/hf.d.ts +120 -0
  182. package/backend/dist/local/hf.js +304 -0
  183. package/backend/dist/local/install.d.ts +90 -0
  184. package/backend/dist/local/install.js +421 -0
  185. package/backend/dist/local/llamacpp.d.ts +55 -0
  186. package/backend/dist/local/llamacpp.js +177 -0
  187. package/backend/dist/local/local-provider.d.ts +81 -0
  188. package/backend/dist/local/local-provider.js +301 -0
  189. package/backend/dist/local/machine-stats.d.ts +87 -0
  190. package/backend/dist/local/machine-stats.js +332 -0
  191. package/backend/dist/local/model-store.d.ts +347 -0
  192. package/backend/dist/local/model-store.js +1215 -0
  193. package/backend/dist/local/part-sweep.d.ts +32 -0
  194. package/backend/dist/local/part-sweep.js +156 -0
  195. package/backend/dist/local/plan.d.ts +65 -0
  196. package/backend/dist/local/plan.js +146 -0
  197. package/backend/dist/local/resources.d.ts +49 -0
  198. package/backend/dist/local/resources.js +64 -0
  199. package/backend/dist/local/run-stats.d.ts +95 -0
  200. package/backend/dist/local/run-stats.js +195 -0
  201. package/backend/dist/local/runner.d.ts +235 -0
  202. package/backend/dist/local/runner.js +1392 -0
  203. package/backend/dist/local/settings.d.ts +79 -0
  204. package/backend/dist/local/settings.js +180 -0
  205. package/backend/dist/local/strata-catalog.d.ts +30 -0
  206. package/backend/dist/local/strata-catalog.js +511 -0
  207. package/backend/dist/local/strata-drafting.d.ts +46 -0
  208. package/backend/dist/local/strata-drafting.js +265 -0
  209. package/backend/dist/local/strata.d.ts +278 -0
  210. package/backend/dist/local/strata.js +1392 -0
  211. package/backend/dist/local/tar.d.ts +20 -0
  212. package/backend/dist/local/tar.js +367 -0
  213. package/backend/dist/local/transport.d.ts +35 -0
  214. package/backend/dist/local/transport.js +89 -0
  215. package/backend/dist/local/tune.d.ts +58 -0
  216. package/backend/dist/local/tune.js +324 -0
  217. package/backend/dist/observability/http-exchange.d.ts +2 -2
  218. package/backend/dist/opencode/catalog/auto-pull.d.ts +14 -3
  219. package/backend/dist/opencode/catalog/auto-pull.js +284 -77
  220. package/backend/dist/opencode/catalog/ocr-store.d.ts +7 -6
  221. package/backend/dist/opencode/catalog/ocr-store.js +4 -2
  222. package/backend/dist/opencode/catalog/overrides-store.d.ts +15 -4
  223. package/backend/dist/opencode/catalog/overrides-store.js +28 -19
  224. package/backend/dist/opencode/catalog/reasoning-declaration.d.ts +35 -0
  225. package/backend/dist/opencode/catalog/reasoning-declaration.js +66 -0
  226. package/backend/dist/opencode/catalog/repository.js +28 -5
  227. package/backend/dist/opencode/catalog/sources/models-dev.d.ts +3 -3
  228. package/backend/dist/opencode/catalog/sources/models-dev.js +42 -14
  229. package/backend/dist/opencode/catalog/types.d.ts +42 -12
  230. package/backend/dist/opencode/catalog/types.js +38 -1
  231. package/backend/dist/opencode/credentials/def-materialize.js +27 -21
  232. package/backend/dist/opencode/credentials/ocr-store.js +11 -2
  233. package/backend/dist/opencode/credentials/sync.js +12 -3
  234. package/backend/dist/opencode/credentials/types.d.ts +31 -4
  235. package/backend/dist/opencode/credentials/types.js +25 -0
  236. package/backend/dist/opencode/migrate/engine.d.ts +20 -0
  237. package/backend/dist/opencode/migrate/engine.js +71 -0
  238. package/backend/dist/opencode/migrate/migrator.d.ts +11 -0
  239. package/backend/dist/opencode/migrate/migrator.js +6 -0
  240. package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.d.ts +6 -0
  241. package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.js +31 -0
  242. package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.d.ts +6 -0
  243. package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.js +62 -0
  244. package/backend/dist/opencode/probe.d.ts +21 -4
  245. package/backend/dist/opencode/probe.js +34 -10
  246. package/backend/dist/opencode/provider-def-adapters.d.ts +12 -11
  247. package/backend/dist/opencode/provider-def-adapters.js +43 -27
  248. package/backend/dist/opencode/provider-defs.d.ts +10 -16
  249. package/backend/dist/opencode/provider-defs.js +45 -45
  250. package/backend/dist/opencode/user-config.d.ts +23 -26
  251. package/backend/dist/opencode/user-config.js +95 -77
  252. package/backend/dist/pipeline/directives.d.ts +9 -4
  253. package/backend/dist/pipeline/directives.js +14 -10
  254. package/backend/dist/pipeline/orchestrator.d.ts +42 -13
  255. package/backend/dist/pipeline/orchestrator.js +514 -172
  256. package/backend/dist/plugins/builtin/model-gateway.js +38 -12
  257. package/backend/dist/plugins/environment-ack.d.ts +51 -0
  258. package/backend/dist/plugins/environment-ack.js +81 -0
  259. package/backend/dist/plugins/gateways.d.ts +6 -6
  260. package/backend/dist/plugins/gateways.js +2 -2
  261. package/backend/dist/plugins/host.d.ts +100 -16
  262. package/backend/dist/plugins/host.js +637 -99
  263. package/backend/dist/plugins/install-run.d.ts +27 -0
  264. package/backend/dist/plugins/install-run.js +99 -0
  265. package/backend/dist/plugins/manifest.d.ts +84 -32
  266. package/backend/dist/plugins/manifest.js +149 -45
  267. package/backend/dist/plugins/market-install.d.ts +18 -0
  268. package/backend/dist/plugins/market-install.js +111 -0
  269. package/backend/dist/plugins/market-source.d.ts +100 -0
  270. package/backend/dist/plugins/market-source.js +449 -0
  271. package/backend/dist/plugins/market-updates.d.ts +70 -0
  272. package/backend/dist/plugins/market-updates.js +97 -0
  273. package/backend/dist/plugins/market.d.ts +677 -0
  274. package/backend/dist/plugins/market.js +2113 -0
  275. package/backend/dist/plugins/source-index.d.ts +155 -0
  276. package/backend/dist/plugins/source-index.js +217 -0
  277. package/backend/dist/plugins/types.d.ts +402 -37
  278. package/backend/dist/projects/worktrees.d.ts +88 -0
  279. package/backend/dist/projects/worktrees.js +220 -0
  280. package/backend/dist/providers/boot-direct.d.ts +41 -7
  281. package/backend/dist/providers/boot-direct.js +284 -44
  282. package/backend/dist/providers/compat/tool-markup-recovery.js +31 -6
  283. package/backend/dist/providers/dial-wire.d.ts +17 -0
  284. package/backend/dist/providers/dial-wire.js +49 -0
  285. package/backend/dist/providers/executors/dispatch.d.ts +17 -7
  286. package/backend/dist/providers/executors/dispatch.js +28 -9
  287. package/backend/dist/providers/executors/openai-chat.js +14 -2
  288. package/backend/dist/providers/executors/plugin-adapter.d.ts +23 -1
  289. package/backend/dist/providers/executors/plugin-adapter.js +59 -3
  290. package/backend/dist/providers/member-match.d.ts +32 -9
  291. package/backend/dist/providers/member-match.js +65 -21
  292. package/backend/dist/providers/model-resolution.d.ts +62 -0
  293. package/backend/dist/providers/model-resolution.js +62 -0
  294. package/backend/dist/providers/price-order.d.ts +51 -0
  295. package/backend/dist/providers/price-order.js +54 -0
  296. package/backend/dist/providers/protocols-field.d.ts +24 -0
  297. package/backend/dist/providers/protocols-field.js +66 -0
  298. package/backend/dist/providers/provider-takedown.d.ts +5 -2
  299. package/backend/dist/providers/registry.d.ts +87 -26
  300. package/backend/dist/providers/registry.js +232 -121
  301. package/backend/dist/providers/selection.d.ts +91 -0
  302. package/backend/dist/providers/selection.js +158 -0
  303. package/backend/dist/providers/virtual-meta.d.ts +33 -2
  304. package/backend/dist/providers/virtual-meta.js +74 -18
  305. package/backend/dist/quota/cli-login.d.ts +25 -4
  306. package/backend/dist/quota/cli-login.js +38 -6
  307. package/backend/dist/quota/coverage-generation.d.ts +24 -0
  308. package/backend/dist/quota/coverage-generation.js +29 -0
  309. package/backend/dist/quota/declarations.js +8 -4
  310. package/backend/dist/quota/engine.js +2 -2
  311. package/backend/dist/quota/prober.d.ts +43 -2
  312. package/backend/dist/quota/prober.js +97 -22
  313. package/backend/dist/ratelimit/rate-limiter.d.ts +1 -1
  314. package/backend/dist/resilience/error-classifier.js +29 -0
  315. package/backend/dist/router/index.d.ts +1 -1
  316. package/backend/dist/router/index.js +17 -1
  317. package/backend/dist/router/layer2-decision.d.ts +1 -1
  318. package/backend/dist/router/layer2-decision.js +2 -2
  319. package/backend/dist/routes/console.js +1043 -405
  320. package/backend/dist/routes/environments.js +1 -1
  321. package/backend/dist/routes/local-models.d.ts +2 -0
  322. package/backend/dist/routes/local-models.js +1414 -0
  323. package/backend/dist/routes/mihomo.d.ts +2 -2
  324. package/backend/dist/routes/mihomo.js +20 -11
  325. package/backend/dist/routes/projects.js +121 -0
  326. package/backend/dist/server.js +409 -15
  327. package/backend/dist/session/session-manager.d.ts +42 -5
  328. package/backend/dist/session/session-manager.js +64 -11
  329. package/backend/dist/session/session-row.d.ts +29 -8
  330. package/backend/dist/session/session-row.js +18 -13
  331. package/backend/dist/snapshot/bundle.d.ts +40 -0
  332. package/backend/dist/snapshot/bundle.js +177 -0
  333. package/backend/dist/snapshot/handoff/compress.d.ts +46 -0
  334. package/backend/dist/snapshot/handoff/compress.js +77 -0
  335. package/backend/dist/snapshot/handoff/index.d.ts +119 -0
  336. package/backend/dist/snapshot/handoff/index.js +160 -0
  337. package/backend/dist/snapshot/handoff/jsonl-writer.d.ts +78 -0
  338. package/backend/dist/snapshot/handoff/jsonl-writer.js +175 -0
  339. package/backend/dist/snapshot/handoff/opencode-writer.d.ts +51 -0
  340. package/backend/dist/snapshot/handoff/opencode-writer.js +214 -0
  341. package/backend/dist/snapshot/handoff/summarize.d.ts +39 -0
  342. package/backend/dist/snapshot/handoff/summarize.js +118 -0
  343. package/backend/dist/snapshot/handoff/transcript.d.ts +71 -0
  344. package/backend/dist/snapshot/handoff/transcript.js +167 -0
  345. package/backend/dist/snapshot/media-fs.d.ts +10 -0
  346. package/backend/dist/snapshot/media-fs.js +50 -0
  347. package/backend/dist/snapshot/media.d.ts +32 -0
  348. package/backend/dist/snapshot/media.js +87 -0
  349. package/backend/dist/snapshot/store.d.ts +226 -0
  350. package/backend/dist/snapshot/store.js +887 -0
  351. package/backend/dist/snapshot/tree.d.ts +112 -0
  352. package/backend/dist/snapshot/tree.js +207 -0
  353. package/backend/dist/snapshot/types.d.ts +212 -0
  354. package/backend/dist/snapshot/types.js +14 -0
  355. package/backend/dist/snapshot/view.d.ts +19 -0
  356. package/backend/dist/snapshot/view.js +57 -0
  357. package/backend/dist/snapshot/write-worker.d.ts +67 -0
  358. package/backend/dist/snapshot/write-worker.js +129 -0
  359. package/backend/dist/surfaces/anthropic.js +4 -1
  360. package/backend/dist/surfaces/body-admission.d.ts +344 -0
  361. package/backend/dist/surfaces/body-admission.js +818 -0
  362. package/backend/dist/surfaces/chat-pipeline.js +8 -0
  363. package/backend/dist/surfaces/decision-pipeline.js +10 -7
  364. package/backend/dist/surfaces/gateway-catalog.d.ts +26 -0
  365. package/backend/dist/surfaces/gateway-catalog.js +202 -0
  366. package/backend/dist/surfaces/gateway-chat.d.ts +7 -11
  367. package/backend/dist/surfaces/gateway-chat.js +50 -12
  368. package/backend/dist/surfaces/ocr-headers.d.ts +6 -4
  369. package/backend/dist/surfaces/ocr-headers.js +11 -7
  370. package/backend/dist/surfaces/systemone.js +1 -1
  371. package/backend/dist/surfaces/transport-fastify.js +32 -5
  372. package/backend/dist/surfaces/transport-node-http.d.ts +51 -6
  373. package/backend/dist/surfaces/transport-node-http.js +76 -16
  374. package/backend/dist/surfaces/types.d.ts +11 -3
  375. package/backend/dist/trace/persist.js +21 -1
  376. package/backend/dist/trace/tracker.d.ts +35 -3
  377. package/backend/dist/trace/tracker.js +23 -0
  378. package/backend/dist/types/openai.d.ts +8 -0
  379. package/backend/dist/types/router.d.ts +17 -6
  380. package/backend/dist/types/router.js +14 -2
  381. package/backend/dist/utils/client-families.d.ts +66 -0
  382. package/backend/dist/utils/client-families.js +127 -0
  383. package/backend/dist/utils/event-ring.d.ts +1 -1
  384. package/backend/dist/utils/event-ring.js +1 -1
  385. package/backend/dist/utils/proxy-node.js +1 -1
  386. package/backend/dist/utils/proxy.d.ts +135 -11
  387. package/backend/dist/utils/proxy.js +144 -29
  388. package/backend/dist/utils/run-command.d.ts +21 -1
  389. package/backend/dist/utils/run-command.js +64 -4
  390. package/backend/dist/utils/server-liveness.d.ts +28 -0
  391. package/backend/dist/utils/server-liveness.js +32 -0
  392. package/backend/dist/utils/session-file.d.ts +28 -0
  393. package/backend/dist/utils/session-file.js +34 -0
  394. package/frontend/dist/assets/antigravity.color-DXFfVr6X.svg +39 -0
  395. package/frontend/dist/assets/gemini-cli.color-BfquLd1p.svg +1 -0
  396. package/frontend/dist/assets/index-CTZNvn1d.js +1707 -0
  397. package/frontend/dist/assets/{index-DxZ9MHKB.css → index-CqDSOPQ0.css} +1 -1
  398. package/frontend/dist/index.html +2 -2
  399. package/package.json +3 -1
  400. package/frontend/dist/assets/index-55VVwfFQ.js +0 -1521
@@ -0,0 +1,27 @@
1
+ import type { ProviderRegistry } from '../providers/registry.js';
2
+ /**
3
+ * The ONE install pipeline (ADR-0017 §6 / ADR-0037).
4
+ *
5
+ * A package arrives from exactly two places: the console's file picker (raw
6
+ * bytes in a POST body) and the plugin market (bytes the backend downloaded
7
+ * from a repository the registry names). Both must land identically — same
8
+ * version gate, same engine parking, same discard-and-roll-back on a failed
9
+ * load, same preset registration, same pool refresh — so there is one function,
10
+ * not two routes that agree today and drift tomorrow.
11
+ *
12
+ * Answers a status + body rather than touching a reply: the caller owns the
13
+ * envelope it sends (`status: 'error'` vs `status: 'ok'`), and the market verb
14
+ * adds nothing to it.
15
+ */
16
+ export interface PluginInstallOutcome {
17
+ statusCode: number;
18
+ body: Record<string, unknown>;
19
+ }
20
+ export declare function installPluginBytes(bytes: Uint8Array, registry: ProviderRegistry,
21
+ /** The caller states that a LOWER version is intentional. `installPluginPackage`
22
+ * refuses a downgrade because the console's upload picker cannot tell a
23
+ * mistake from a rollback — but the market's "install this tag" verb CAN: the
24
+ * operator picked that version off a list. */
25
+ opts?: {
26
+ allowDowngrade?: boolean;
27
+ }): Promise<PluginInstallOutcome>;
@@ -0,0 +1,99 @@
1
+ import { refreshDirectPool } from '../providers/boot-direct.js';
2
+ import { discardPluginPackage, installPluginPackage, listInstalledPlugins, loadInstalledPlugins, packageIdOf, pluginPackageZip, syncPluginPresets, } from './host.js';
3
+ export async function installPluginBytes(bytes, registry,
4
+ /** The caller states that a LOWER version is intentional. `installPluginPackage`
5
+ * refuses a downgrade because the console's upload picker cannot tell a
6
+ * mistake from a rollback — but the market's "install this tag" verb CAN: the
7
+ * operator picked that version off a list. */
8
+ opts = {}) {
9
+ // Snapshot the version this upload is about to REPLACE (a packaged one — a
10
+ // dev-tree plugin is not ours to materialize here). A failed upgrade must not
11
+ // delete a working install. `disabled` does NOT disqualify the snapshot: a
12
+ // switched-off package is still an install the operator owns, and a broken
13
+ // upload over it would otherwise leave them with nothing to roll back to.
14
+ let previous;
15
+ try {
16
+ const target = packageIdOf(new Uint8Array(bytes));
17
+ const existing = listInstalledPlugins().find((p) => p.id === target);
18
+ if (existing?.source === 'packaged')
19
+ previous = await pluginPackageZip(target);
20
+ }
21
+ catch {
22
+ // unreadable upload: installPluginPackage below reports it properly
23
+ }
24
+ const { id: installed, version: installedVersion, replacedVersion } = installPluginPackage(new Uint8Array(bytes), opts.allowDowngrade ? { allowDowngrade: true } : {});
25
+ await loadInstalledPlugins();
26
+ const plugins = listInstalledPlugins();
27
+ // An engine-INCOMPATIBLE package is not a broken one: it is on disk, it is
28
+ // listed as disabled, and it becomes usable in place once the matching side is
29
+ // updated. Discarding it would only make the operator upload the same file
30
+ // again after that update, so the discard / rollback path below stays reserved
31
+ // for packages that genuinely fail to load. The test is the ROW'S OWN flag,
32
+ // never `disabled && !loaded` — an operator-disabled package satisfies that
33
+ // shape too, and a failed load of one must still be discarded and rolled back.
34
+ //
35
+ // The upload itself is PARKED, not refused (ADR-0036 §5): the engine gate lets
36
+ // an incompatible package land and this branch reports it in the 200 body
37
+ // (`incompatible: true`) so the console toasts the honest outcome instead of a
38
+ // green "installed" over a dead row. A swap that would displace a package this
39
+ // host CAN run is still refused up front, inside `installPluginPackage`.
40
+ const view = plugins.find((p) => p.id === installed);
41
+ const incompatible = view?.incompatible === true;
42
+ if (!view?.loaded && !incompatible) {
43
+ // a package that cannot load would re-fail every boot — discard it; discard
44
+ // BEFORE preset sync / pool refresh so a broken package registers nothing
45
+ discardPluginPackage(installed);
46
+ // Roll BACK to the version that was working until this upload, so a bad
47
+ // upgrade is a no-op instead of a lost plugin.
48
+ if (previous) {
49
+ // A ROLLBACK is the one legitimate downgrade: the caller did not ask for
50
+ // it, the loader did — the version guard exists for uploads, and it must
51
+ // not block the recovery path.
52
+ installPluginPackage(previous, { allowDowngrade: true });
53
+ await loadInstalledPlugins();
54
+ return {
55
+ statusCode: 422,
56
+ body: {
57
+ status: 'error',
58
+ error: `package rejected and discarded (${view?.error ?? 'unknown error'}); rolled back to the previously installed version`,
59
+ plugins: listInstalledPlugins(),
60
+ },
61
+ };
62
+ }
63
+ // Reload AFTER the discard: otherwise the response would hand the console a
64
+ // row for a package that is no longer on disk (the list is the disk's truth,
65
+ // not the last failed import's).
66
+ await loadInstalledPlugins();
67
+ return {
68
+ statusCode: 422,
69
+ body: {
70
+ status: 'error',
71
+ error: `package installed but failed to load (discarded): ${view?.error ?? 'unknown error'}`,
72
+ plugins: listInstalledPlugins(),
73
+ },
74
+ };
75
+ }
76
+ // presets register at install time (same contract as boot/reload) — after a
77
+ // verified successful load, BEFORE the pool refresh so the defs are routable
78
+ // immediately on the next dispatch. An engine-refused package reaches this
79
+ // line too: it loaded nothing, so `syncPluginPresets` has nothing of it to
80
+ // register, and its row stays DISABLED in `plugins`.
81
+ const registered = await syncPluginPresets();
82
+ await refreshDirectPool(registry);
83
+ return {
84
+ statusCode: 200,
85
+ body: {
86
+ status: 'ok',
87
+ id: installed,
88
+ version: installedVersion,
89
+ replacedVersion,
90
+ plugins,
91
+ registered,
92
+ // Kept in the 200 body so the console can toast the honest outcome: the
93
+ // bytes landed, but the package answers nothing until one side is updated.
94
+ // A green "installed" toast over a red row is the one reading an operator
95
+ // must not be left with.
96
+ ...(incompatible ? { incompatible: true, error: view.error } : {}),
97
+ },
98
+ };
99
+ }
@@ -10,7 +10,7 @@
10
10
  * extension point is claimed SNI hosts; the runtime view reads `wires ?? []`),
11
11
  * every other shape rule holds for both plugin types.
12
12
  */
13
- import type { PluginClaimEgress, PluginConfigField, PluginManifest, PluginPart, PluginType } from './types.js';
13
+ import type { PluginDeclaredEgress, PluginConfigField, PluginManifest, PluginPart, PluginType } from './types.js';
14
14
  /** The plugin ENGINE version the host implements — the version of the plugin
15
15
  * surface core offers package code (`createPlugin(host)` and everything
16
16
  * reachable from it).
@@ -26,7 +26,7 @@ import type { PluginClaimEgress, PluginConfigField, PluginManifest, PluginPart,
26
26
  * Bump discipline: raising this constant is the ONLY step a surface change
27
27
  * needs. Packages declaring the previous value are then refused with a
28
28
  * sentence that says which side is behind; nothing else in core reads it. */
29
- export declare const PLUGIN_ENGINE_VERSION = 1;
29
+ export declare const PLUGIN_ENGINE_VERSION = 2;
30
30
  /** The plugin CONTRACT this host implements — the same number by another name.
31
31
  * Kept as its own constant because readers come at it from two directions: a
32
32
  * package DECLARES `apiVersion`, this host boasts `SUPPORTED_PLUGIN_API`, and
@@ -34,12 +34,12 @@ export declare const PLUGIN_ENGINE_VERSION = 1;
34
34
  * `pluginEngineCompatibility`). Equal to {@link PLUGIN_ENGINE_VERSION} by
35
35
  * construction, never by coincidence — see ADR-0036 on why there is one
36
36
  * number. */
37
- export declare const SUPPORTED_PLUGIN_API = 1;
37
+ export declare const SUPPORTED_PLUGIN_API = 2;
38
38
  /** Lower bound of the supported CONTRACT window. Equal to
39
39
  * `SUPPORTED_PLUGIN_API` today: one contract, no legacy. Raising it retires
40
40
  * the contracts in `[MIN, SUPPORTED)` — packages declaring them are refused
41
41
  * exactly like a too-new one. */
42
- export declare const MIN_SUPPORTED_PLUGIN_API = 1;
42
+ export declare const MIN_SUPPORTED_PLUGIN_API = 2;
43
43
  /** Why a package was refused. Two directions, never one sentence: a package
44
44
  * that targeted a retired contract is fixed by installing its newer release;
45
45
  * a package that needs a newer engine is fixed by updating the GATEWAY, and
@@ -76,28 +76,71 @@ export declare function pluginEngineCompatibility(manifest: PluginManifest): Plu
76
76
  * by CORE, never by a package: it is an instruction about what the operator
77
77
  * must DO, and it has to name the right side to act on. */
78
78
  export declare function pluginEngineRefusal(manifest: PluginManifest): string | undefined;
79
- /** Reject a package the host cannot run. Called at INSTALL (before anything
80
- * touches disk) and at LOAD (packages already on disk); the LOAD path turns
81
- * the same verdict into a disabled console row instead of a failed one, so the
82
- * message below is what the operator reads. */
79
+ /** Reject a package the host cannot run. Called at LOAD (and by the installer
80
+ * before it parks a package); the LOAD path turns the same verdict into a
81
+ * disabled console row instead of a failed one, so the message below is what
82
+ * the operator reads either way. */
83
83
  export declare function assertSupportedPluginApi(manifest: PluginManifest): void;
84
+ /**
85
+ * The INSTALL-time gate (ADR-0036 §5, amended 2026-12-01). A package this host
86
+ * cannot run is still the operator's file: refusing it outright made the
87
+ * console reject a picker they had already made, and cost them a second upload
88
+ * of the same bytes after the upgrade that fixes it.
89
+ *
90
+ * So an incompatible upload is PARKED instead — written to disk and listed as a
91
+ * disabled `incompatible: true` row, exactly the state a package already on
92
+ * disk reaches when the gateway is downgraded under it (the loader refuses to
93
+ * import it either way; see `doLoadInstalledPlugins`). The row adopts the
94
+ * package in place the moment the mismatch is resolved, with no reinstall.
95
+ *
96
+ * The ONE thing a parked package may not do is take over an install that
97
+ * WORKS. Install is over-the-top — the previous package file is replaced and
98
+ * the console's rollback path deliberately skips incompatible rows — so parking
99
+ * over a working install would trade a running plugin for a dead one with
100
+ * nothing to restore it from. `replaced` is the manifest this upload would
101
+ * displace; taking that place requires uninstalling it first, which is the
102
+ * operator saying "yes, I mean the swap".
103
+ */
104
+ export declare function assertInstallablePluginApi(manifest: PluginManifest, replaced?: PluginManifest): void;
84
105
  /** Where a config field is edited: the plugin drawer (default), the Client Hub
85
106
  * card the hook backs, or nowhere (stored, but dead for this hook). */
86
107
  export declare const CONFIG_PLACEMENTS: readonly ["drawer", "card", "none"];
108
+ /**
109
+ * A declared `state` path, resolved to its path SEGMENTS relative to the OCR
110
+ * home — or undefined when the declaration would reach outside what uninstall
111
+ * owns. ONE reader, used by both the packager's refusal and the uninstall
112
+ * sweep: two spellings of this rule would drift, and the drift would delete (or
113
+ * refuse) the wrong files.
114
+ *
115
+ * Two shapes are accepted, because both are documented layouts:
116
+ *
117
+ * - under `plugins/` — the envelope the host SDK describes for outliving state
118
+ * (`plugins/workbuddy-auth.json`, `plugins/traffic/<id>`, `plugins/clients`);
119
+ * - a TOP-LEVEL entry whose name starts with `<id>.` / `<id>-` — vendor-neutral
120
+ * plugin files that predate the `plugins/` envelope. Top level only: a
121
+ * foreign envelope must never become deletable by a name prefix.
122
+ *
123
+ * Absolute paths, drive letters, `..` and empty segments are REFUSED rather than
124
+ * normalized (a normalizer would quietly turn a suspicious entry into a valid
125
+ * one), and the install roots/ledgers (`unpacked`, `bundled`, `config`,
126
+ * `traffic`) are core layout a package may not claim as a whole.
127
+ */
128
+ export declare function resolvePluginStatePath(id: string, raw: unknown): string[] | undefined;
87
129
  /**
88
130
  * The plugin-level outbound-leg switch (ADR-0018 Revision 5), keyed and valued by
89
- * CORE. Once a package claims a host, the leg under that host is the package's
90
- * business — but the operator keeps the last word over the code they installed,
91
- * and that word is spoken ONCE per plugin, not once per host: one switch that
92
- * reaches every host this gateway claims.
131
+ * CORE. Once a package owns traffic — a claimed host, or a wire whose dial only
132
+ * the package can make — the leg under it is the package's business. The
133
+ * operator keeps the last word over the code they installed, and that word is
134
+ * spoken ONCE per plugin, not once per host or per wire: one switch that reaches
135
+ * every dial this package makes.
93
136
  *
94
137
  * The default is `inherit`, deliberately NOT the manifest's own declaration:
95
138
  * the switch sits ABOVE the plugin's code, and a default of `proxy` would make
96
- * every untouched plugin a silent override of its own `egressFor()` answers.
97
- * `inherit` is the state that leaves the claim in charge.
139
+ * every untouched plugin a silent override of its own `egressFor()` / `fetch`
140
+ * argument. `inherit` is the state that leaves the package in charge.
98
141
  */
99
- export declare const GATEWAY_EGRESS_CONFIG_KEY = "egress";
100
- export declare const GATEWAY_EGRESS_VALUES: readonly ["inherit", "proxy", "direct"];
142
+ export declare const PLUGIN_EGRESS_CONFIG_KEY = "egress";
143
+ export declare const PLUGIN_EGRESS_VALUES: readonly ["inherit", "proxy", "direct"];
101
144
  /** The three extension axes (ADR-0017 / ADR-0027), in the order a console row
102
145
  * prefers to label them: a package that is both an ingress hook and a traffic
103
146
  * owner reads as a client adapter first, because that is the half the operator
@@ -116,35 +159,44 @@ export declare function normalizePluginParts(manifest: PluginManifest): PluginPa
116
159
  * is not a gateway at all. */
117
160
  export declare function gatewayClaimedHosts(manifest: PluginManifest): string[];
118
161
  /**
119
- * Whether the console should offer the operator the plugin-level leg switch:
120
- * a gateway with at least one CONCRETE claimed host. A wildcard gateway claims
121
- * no host, so a switch over it would be a switch over traffic it does not own
122
- * (the same refusal the manifest validator applies to `egress` on `'*'`).
162
+ * Whether the console should offer the operator the plugin-level leg switch.
163
+ *
164
+ * A gateway qualifies with at least one CONCRETE claimed host: a wildcard
165
+ * gateway claims no host, so a switch over it would be a switch over traffic it
166
+ * does not own (the same refusal the manifest validator applies to `egress` on
167
+ * `'*'`).
168
+ *
169
+ * A model-service qualifies with at least one WIRE, whether or not it dials
170
+ * itself: its traffic leaves this machine on the leg the operator pays for, and
171
+ * a package that spawns a vendor daemon (qoder-cli) has NO other way to be told
172
+ * (ADR-0022 amendment). The switch names a leg, never an address, so it grants a
173
+ * package no reach it did not already have.
123
174
  */
124
175
  export declare function hasOwnableClaim(manifest: PluginManifest): boolean;
125
176
  /**
126
- * The field core injects into a gateway's `configSchema` so the operator's
127
- * switch appears in the plugin's own settings drawer (ADR-0018 Revision 5). No
128
- * `title`/`desc`/`enumLabels` on purpose: this row is CORE chrome, not package
129
- * content, so its wording comes from the console's translation tables the same
130
- * as every other label (`isCoreEgressField` in the frontend recognizes it) and
131
- * never from a package author's English.
177
+ * The field core injects into a package's `configSchema` so the operator's
178
+ * switch appears in the plugin's own settings drawer (ADR-0018 Revision 5).
179
+ * No `title`/`desc`/`enumLabels` on purpose: this row is CORE chrome, not
180
+ * package content, so its wording comes from the console's translation tables
181
+ * the same as every other label (`isCoreEgressField` in the frontend recognizes
182
+ * it, and picks the gateway or model-service sentence by `type`) and never from
183
+ * a package author's English.
132
184
  */
133
- export declare function gatewayEgressField(): PluginConfigField;
185
+ export declare function pluginEgressField(): PluginConfigField;
134
186
  /**
135
187
  * The operator's EXPLICIT leg choice out of a merged plugin config. `inherit` —
136
188
  * the untouched default — is deliberately NOT a choice: it means "let the claim
137
- * answer", so it must not outrank the plugin's own `egressFor()` the way a
138
- * picked value does.
189
+ * answer", so it must not outrank the plugin's own `egressFor()` / `fetch`
190
+ * argument the way a picked value does.
139
191
  */
140
- export declare function operatorEgressChoice(values: Record<string, unknown>): PluginClaimEgress | undefined;
192
+ export declare function operatorEgressChoice(values: Record<string, unknown>): PluginDeclaredEgress | undefined;
141
193
  /**
142
- * Add the core switch to a gateway manifest, idempotently and without touching
194
+ * Add the core switch to a package manifest, idempotently and without touching
143
195
  * any other field. Called at MANIFEST READ, before the host SDK hands the
144
196
  * manifest to a plugin's `config()` closure: injected later, the drawer, the
145
197
  * merge and the plugin's own read would disagree about whether the key exists.
146
198
  */
147
- export declare function withGatewayEgressField(manifest: PluginManifest): PluginManifest;
199
+ export declare function withPluginEgressField(manifest: PluginManifest): PluginManifest;
148
200
  export declare function isValidPluginId(id: unknown): id is string;
149
201
  export declare function validatePluginManifest(manifest: unknown, label: string): void;
150
202
  /** Validate one plugin's `configSchema` (flat primitive fields, ADR-0017 §7)
@@ -13,7 +13,7 @@
13
13
  * Bump discipline: raising this constant is the ONLY step a surface change
14
14
  * needs. Packages declaring the previous value are then refused with a
15
15
  * sentence that says which side is behind; nothing else in core reads it. */
16
- export const PLUGIN_ENGINE_VERSION = 1;
16
+ export const PLUGIN_ENGINE_VERSION = 2;
17
17
  /** The plugin CONTRACT this host implements — the same number by another name.
18
18
  * Kept as its own constant because readers come at it from two directions: a
19
19
  * package DECLARES `apiVersion`, this host boasts `SUPPORTED_PLUGIN_API`, and
@@ -64,32 +64,110 @@ export function pluginEngineRefusal(manifest) {
64
64
  }
65
65
  return `plugin ${who} targets plugin contract ${verdict.required}, which this gateway no longer supports (supported: ${MIN_SUPPORTED_PLUGIN_API}–${SUPPORTED_PLUGIN_API}) — update the plugin to a newer release`;
66
66
  }
67
- /** Reject a package the host cannot run. Called at INSTALL (before anything
68
- * touches disk) and at LOAD (packages already on disk); the LOAD path turns
69
- * the same verdict into a disabled console row instead of a failed one, so the
70
- * message below is what the operator reads. */
67
+ /** Reject a package the host cannot run. Called at LOAD (and by the installer
68
+ * before it parks a package); the LOAD path turns the same verdict into a
69
+ * disabled console row instead of a failed one, so the message below is what
70
+ * the operator reads either way. */
71
71
  export function assertSupportedPluginApi(manifest) {
72
72
  const refusal = pluginEngineRefusal(manifest);
73
73
  if (refusal)
74
74
  throw new Error(refusal);
75
75
  }
76
+ /**
77
+ * The INSTALL-time gate (ADR-0036 §5, amended 2026-12-01). A package this host
78
+ * cannot run is still the operator's file: refusing it outright made the
79
+ * console reject a picker they had already made, and cost them a second upload
80
+ * of the same bytes after the upgrade that fixes it.
81
+ *
82
+ * So an incompatible upload is PARKED instead — written to disk and listed as a
83
+ * disabled `incompatible: true` row, exactly the state a package already on
84
+ * disk reaches when the gateway is downgraded under it (the loader refuses to
85
+ * import it either way; see `doLoadInstalledPlugins`). The row adopts the
86
+ * package in place the moment the mismatch is resolved, with no reinstall.
87
+ *
88
+ * The ONE thing a parked package may not do is take over an install that
89
+ * WORKS. Install is over-the-top — the previous package file is replaced and
90
+ * the console's rollback path deliberately skips incompatible rows — so parking
91
+ * over a working install would trade a running plugin for a dead one with
92
+ * nothing to restore it from. `replaced` is the manifest this upload would
93
+ * displace; taking that place requires uninstalling it first, which is the
94
+ * operator saying "yes, I mean the swap".
95
+ */
96
+ export function assertInstallablePluginApi(manifest, replaced) {
97
+ const refusal = pluginEngineRefusal(manifest);
98
+ // A fresh id (or a same-id upgrade by a compatible package) is always fine.
99
+ if (!refusal)
100
+ return;
101
+ if (!replaced)
102
+ return;
103
+ // The outgoing package is engine-refused too: it is not "working", so there
104
+ // is nothing to protect — this replaces one parked row with another.
105
+ if (pluginEngineRefusal(replaced))
106
+ return;
107
+ throw new Error(`${refusal} — refused to replace the working '${replaced.id}' ${replaced.version}; uninstall it first if you really mean to swap it for a package this gateway cannot run`);
108
+ }
76
109
  /** Where a config field is edited: the plugin drawer (default), the Client Hub
77
110
  * card the hook backs, or nowhere (stored, but dead for this hook). */
78
111
  export const CONFIG_PLACEMENTS = ['drawer', 'card', 'none'];
112
+ /**
113
+ * A declared `state` path, resolved to its path SEGMENTS relative to the OCR
114
+ * home — or undefined when the declaration would reach outside what uninstall
115
+ * owns. ONE reader, used by both the packager's refusal and the uninstall
116
+ * sweep: two spellings of this rule would drift, and the drift would delete (or
117
+ * refuse) the wrong files.
118
+ *
119
+ * Two shapes are accepted, because both are documented layouts:
120
+ *
121
+ * - under `plugins/` — the envelope the host SDK describes for outliving state
122
+ * (`plugins/workbuddy-auth.json`, `plugins/traffic/<id>`, `plugins/clients`);
123
+ * - a TOP-LEVEL entry whose name starts with `<id>.` / `<id>-` — vendor-neutral
124
+ * plugin files that predate the `plugins/` envelope. Top level only: a
125
+ * foreign envelope must never become deletable by a name prefix.
126
+ *
127
+ * Absolute paths, drive letters, `..` and empty segments are REFUSED rather than
128
+ * normalized (a normalizer would quietly turn a suspicious entry into a valid
129
+ * one), and the install roots/ledgers (`unpacked`, `bundled`, `config`,
130
+ * `traffic`) are core layout a package may not claim as a whole.
131
+ */
132
+ export function resolvePluginStatePath(id, raw) {
133
+ if (typeof raw !== 'string')
134
+ return undefined;
135
+ const rel = raw.trim().replaceAll('\\', '/');
136
+ if (!rel || rel.startsWith('/') || /^[A-Za-z]:/.test(rel))
137
+ return undefined;
138
+ const segments = rel.split('/').filter((s) => s.length > 0);
139
+ if (segments.length === 0 || segments.some((s) => s === '.' || s === '..'))
140
+ return undefined;
141
+ if (segments[0] === 'plugins') {
142
+ const inside = segments.slice(1);
143
+ if (inside.length === 0)
144
+ return undefined;
145
+ if (inside.length === 1 && ['unpacked', 'bundled', 'config', 'traffic'].includes(inside[0]))
146
+ return undefined;
147
+ return segments;
148
+ }
149
+ if (segments.length !== 1)
150
+ return undefined;
151
+ const name = segments[0];
152
+ if (!name.startsWith(`${id}.`) && !name.startsWith(`${id}-`))
153
+ return undefined;
154
+ return segments;
155
+ }
79
156
  /**
80
157
  * The plugin-level outbound-leg switch (ADR-0018 Revision 5), keyed and valued by
81
- * CORE. Once a package claims a host, the leg under that host is the package's
82
- * business — but the operator keeps the last word over the code they installed,
83
- * and that word is spoken ONCE per plugin, not once per host: one switch that
84
- * reaches every host this gateway claims.
158
+ * CORE. Once a package owns traffic — a claimed host, or a wire whose dial only
159
+ * the package can make — the leg under it is the package's business. The
160
+ * operator keeps the last word over the code they installed, and that word is
161
+ * spoken ONCE per plugin, not once per host or per wire: one switch that reaches
162
+ * every dial this package makes.
85
163
  *
86
164
  * The default is `inherit`, deliberately NOT the manifest's own declaration:
87
165
  * the switch sits ABOVE the plugin's code, and a default of `proxy` would make
88
- * every untouched plugin a silent override of its own `egressFor()` answers.
89
- * `inherit` is the state that leaves the claim in charge.
166
+ * every untouched plugin a silent override of its own `egressFor()` / `fetch`
167
+ * argument. `inherit` is the state that leaves the package in charge.
90
168
  */
91
- export const GATEWAY_EGRESS_CONFIG_KEY = 'egress';
92
- export const GATEWAY_EGRESS_VALUES = ['inherit', 'proxy', 'direct'];
169
+ export const PLUGIN_EGRESS_CONFIG_KEY = 'egress';
170
+ export const PLUGIN_EGRESS_VALUES = ['inherit', 'proxy', 'direct'];
93
171
  /** The three extension axes (ADR-0017 / ADR-0027), in the order a console row
94
172
  * prefers to label them: a package that is both an ingress hook and a traffic
95
173
  * owner reads as a client adapter first, because that is the half the operator
@@ -118,27 +196,39 @@ export function gatewayClaimedHosts(manifest) {
118
196
  return normalizePluginParts(manifest).find((p) => p.type === 'client-gateway')?.hosts ?? [];
119
197
  }
120
198
  /**
121
- * Whether the console should offer the operator the plugin-level leg switch:
122
- * a gateway with at least one CONCRETE claimed host. A wildcard gateway claims
123
- * no host, so a switch over it would be a switch over traffic it does not own
124
- * (the same refusal the manifest validator applies to `egress` on `'*'`).
199
+ * Whether the console should offer the operator the plugin-level leg switch.
200
+ *
201
+ * A gateway qualifies with at least one CONCRETE claimed host: a wildcard
202
+ * gateway claims no host, so a switch over it would be a switch over traffic it
203
+ * does not own (the same refusal the manifest validator applies to `egress` on
204
+ * `'*'`).
205
+ *
206
+ * A model-service qualifies with at least one WIRE, whether or not it dials
207
+ * itself: its traffic leaves this machine on the leg the operator pays for, and
208
+ * a package that spawns a vendor daemon (qoder-cli) has NO other way to be told
209
+ * (ADR-0022 amendment). The switch names a leg, never an address, so it grants a
210
+ * package no reach it did not already have.
125
211
  */
126
212
  export function hasOwnableClaim(manifest) {
213
+ if (normalizePluginParts(manifest).some((p) => p.type === 'model-service' && (p.wires?.length ?? 0) > 0)) {
214
+ return true;
215
+ }
127
216
  return gatewayClaimedHosts(manifest).some((h) => String(h).trim() !== '*');
128
217
  }
129
218
  /**
130
- * The field core injects into a gateway's `configSchema` so the operator's
131
- * switch appears in the plugin's own settings drawer (ADR-0018 Revision 5). No
132
- * `title`/`desc`/`enumLabels` on purpose: this row is CORE chrome, not package
133
- * content, so its wording comes from the console's translation tables the same
134
- * as every other label (`isCoreEgressField` in the frontend recognizes it) and
135
- * never from a package author's English.
219
+ * The field core injects into a package's `configSchema` so the operator's
220
+ * switch appears in the plugin's own settings drawer (ADR-0018 Revision 5).
221
+ * No `title`/`desc`/`enumLabels` on purpose: this row is CORE chrome, not
222
+ * package content, so its wording comes from the console's translation tables
223
+ * the same as every other label (`isCoreEgressField` in the frontend recognizes
224
+ * it, and picks the gateway or model-service sentence by `type`) and never from
225
+ * a package author's English.
136
226
  */
137
- export function gatewayEgressField() {
227
+ export function pluginEgressField() {
138
228
  return {
139
- key: GATEWAY_EGRESS_CONFIG_KEY,
229
+ key: PLUGIN_EGRESS_CONFIG_KEY,
140
230
  type: 'enum',
141
- values: [...GATEWAY_EGRESS_VALUES],
231
+ values: [...PLUGIN_EGRESS_VALUES],
142
232
  default: 'inherit',
143
233
  control: 'segmented',
144
234
  essential: true,
@@ -147,26 +237,26 @@ export function gatewayEgressField() {
147
237
  /**
148
238
  * The operator's EXPLICIT leg choice out of a merged plugin config. `inherit` —
149
239
  * the untouched default — is deliberately NOT a choice: it means "let the claim
150
- * answer", so it must not outrank the plugin's own `egressFor()` the way a
151
- * picked value does.
240
+ * answer", so it must not outrank the plugin's own `egressFor()` / `fetch`
241
+ * argument the way a picked value does.
152
242
  */
153
243
  export function operatorEgressChoice(values) {
154
- const v = values[GATEWAY_EGRESS_CONFIG_KEY];
244
+ const v = values[PLUGIN_EGRESS_CONFIG_KEY];
155
245
  return v === 'proxy' || v === 'direct' ? v : undefined;
156
246
  }
157
247
  /**
158
- * Add the core switch to a gateway manifest, idempotently and without touching
248
+ * Add the core switch to a package manifest, idempotently and without touching
159
249
  * any other field. Called at MANIFEST READ, before the host SDK hands the
160
250
  * manifest to a plugin's `config()` closure: injected later, the drawer, the
161
251
  * merge and the plugin's own read would disagree about whether the key exists.
162
252
  */
163
- export function withGatewayEgressField(manifest) {
253
+ export function withPluginEgressField(manifest) {
164
254
  if (!hasOwnableClaim(manifest))
165
255
  return manifest;
166
256
  const schema = manifest.configSchema ?? [];
167
- if (schema.some((f) => f.key === GATEWAY_EGRESS_CONFIG_KEY))
257
+ if (schema.some((f) => f.key === PLUGIN_EGRESS_CONFIG_KEY))
168
258
  return manifest;
169
- return { ...manifest, configSchema: [gatewayEgressField(), ...schema] };
259
+ return { ...manifest, configSchema: [pluginEgressField(), ...schema] };
170
260
  }
171
261
  /** A plugin id is a PATH COMPONENT — `<pluginsRoot>/<id>.zip`,
172
262
  * `<pluginsRoot>/unpacked/<id>/`, `<pluginsRoot>/bundled/<id>.zip` — so the
@@ -208,7 +298,7 @@ export function validatePluginManifest(manifest, label) {
208
298
  if (typeof m.version !== 'string' || !m.version)
209
299
  fail('version must be a non-empty string');
210
300
  if (typeof m.apiVersion !== 'number' || !Number.isInteger(m.apiVersion) || m.apiVersion < 1) {
211
- fail('apiVersion must be a positive integer (the plugin contract version, currently 1)');
301
+ fail(`apiVersion must be a positive integer (the plugin contract version, currently ${SUPPORTED_PLUGIN_API})`);
212
302
  }
213
303
  // `engines` is RETIRED (ADR-0036 Amendment 1): the engine version is the
214
304
  // contract version, so `apiVersion` above is the whole declaration. A
@@ -228,7 +318,7 @@ export function validatePluginManifest(manifest, label) {
228
318
  // wildcard claim: `'*'` is not a host, and a declaration that reached every
229
319
  // host would let one installed package pin the egress of the whole machine —
230
320
  // the exact blast radius Revision 4 was written to keep out of a claim.
231
- const claimEgress = (value, label, hosts) => {
321
+ const declaredEgress = (value, label, hosts) => {
232
322
  if (value === undefined)
233
323
  return;
234
324
  if (value !== 'inherit' && value !== 'proxy' && value !== 'direct') {
@@ -287,7 +377,7 @@ export function validatePluginManifest(manifest, label) {
287
377
  fail(`parts[${i}] is a client-gateway part and needs a non-empty hosts array`);
288
378
  }
289
379
  wildcardExclusive(part.hosts, `parts[${i}].hosts`, fail);
290
- claimEgress(part.egress, `parts[${i}].egress`, part.hosts);
380
+ declaredEgress(part.egress, `parts[${i}].egress`, part.hosts);
291
381
  }
292
382
  else if (part.egress !== undefined) {
293
383
  fail(`parts[${i}].egress declares the exit of a host, and only a client-gateway part claims hosts`);
@@ -308,7 +398,7 @@ export function validatePluginManifest(manifest, label) {
308
398
  fail('a client-gateway manifest needs a non-empty hosts array');
309
399
  }
310
400
  wildcardExclusive(m.hosts, 'hosts', fail);
311
- claimEgress(m.egress, 'egress', m.hosts);
401
+ declaredEgress(m.egress, 'egress', m.hosts);
312
402
  }
313
403
  else if (m.egress !== undefined) {
314
404
  fail('`egress` declares the exit of a host, and only a client-gateway plugin claims hosts');
@@ -321,19 +411,33 @@ export function validatePluginManifest(manifest, label) {
321
411
  if (m.configSections !== undefined && m.configSchema === undefined) {
322
412
  fail('configSections without configSchema groups nothing');
323
413
  }
324
- // The leg switch is core-owned vocabulary (`GATEWAY_EGRESS_CONFIG_KEY`), and
325
- // core INJECTS it into a gateway's schema. A package that declares the key
414
+ // The leg switch is core-owned vocabulary (`PLUGIN_EGRESS_CONFIG_KEY`), and
415
+ // core INJECTS it into a package's schema. A package that declares the key
326
416
  // itself is refused here rather than silently shadowed: two rows named
327
417
  // `egress` in one drawer means the merged read can no longer say which one
328
418
  // the operator touched, and the operator's word on the leg is the whole
329
- // contract of that field.
330
- if (hasOwnableClaim(m) &&
331
- Array.isArray(m.configSchema) &&
332
- m.configSchema.some((f) => f?.key === GATEWAY_EGRESS_CONFIG_KEY)) {
333
- fail(`configSchema may not declare '${GATEWAY_EGRESS_CONFIG_KEY}' — the outbound-leg switch belongs to core`);
419
+ // contract of that field. Refused for EVERY package type that could grow the
420
+ // switch — model-service packages gain it too (ADR-0022 amendment).
421
+ if (Array.isArray(m.configSchema) &&
422
+ m.configSchema.some((f) => f?.key === PLUGIN_EGRESS_CONFIG_KEY)) {
423
+ fail(`configSchema may not declare '${PLUGIN_EGRESS_CONFIG_KEY}' — the outbound-leg switch belongs to core`);
334
424
  }
335
425
  if (m.logo !== undefined && typeof m.logo !== 'string')
336
426
  fail('logo must be a string');
427
+ // `state` paths are resolved against the OCR home and deleted on uninstall,
428
+ // so a declaration must stay inside what uninstall owns: a path under
429
+ // `plugins/`, or a top-level entry named `<id>.…` / `<id>-…`. The uninstall
430
+ // sweep re-guards the same rule; this copy exists so the packager refuses the
431
+ // package before an operator ever has it.
432
+ if (m.state !== undefined) {
433
+ stringArray(m.state, 'state');
434
+ const id = String(m.id);
435
+ for (const raw of m.state) {
436
+ if (!resolvePluginStatePath(id, raw)) {
437
+ fail(`state entry '${raw}' must be a path under 'plugins/' or a top-level '<id>.' / '<id>-' entry`);
438
+ }
439
+ }
440
+ }
337
441
  if (m.description !== undefined &&
338
442
  typeof m.description !== 'string' &&
339
443
  (typeof m.description !== 'object' || m.description === null)) {
@@ -463,7 +567,7 @@ const CONFIG_CONTROLS = {
463
567
  models: { 'string[]': true },
464
568
  // A mapping table of `client=target[#label]` specs; each row maps one of the
465
569
  // client's OWN model ids onto an OCR model the gateway rewrites to.
466
- aliases: { 'string[]': true },
570
+ mappings: { 'string[]': true },
467
571
  // A short closed choice rendered as joined buttons instead of a dropdown --
468
572
  // the console's own mode switches (none / custom / follow) use the same shape.
469
573
  segmented: { enum: true },
@@ -0,0 +1,18 @@
1
+ import type { ProviderRegistry } from '../providers/registry.js';
2
+ import { type PluginInstallOutcome } from './install-run.js';
3
+ /**
4
+ * ONE market install, reached from three verbs (ADR-0037 §5/§7): the market
5
+ * card's Install, one plugin's Upgrade, and the bulk upgrade run. All three do
6
+ * exactly this — resolve the registry row, obtain the bytes by the row's
7
+ * method, verify the zip declares the row's id, land it through the shared
8
+ * install pipeline, and record where it came from.
9
+ *
10
+ * Keeping it in one function is the same rule the upload path follows: two
11
+ * copies of "download, verify, install, remember" would agree today and drift
12
+ * the day one of them learns a new gate.
13
+ */
14
+ export declare function installFromMarket(repo: string, opts?: {
15
+ ref?: string;
16
+ allowDowngrade?: boolean;
17
+ upgrade?: boolean;
18
+ }, registry?: ProviderRegistry): Promise<PluginInstallOutcome>;