omnicell-router 0.3.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1077) hide show
  1. package/README.md +70 -10
  2. package/README.zh-CN.md +57 -8
  3. package/RELEASING.md +6 -0
  4. package/RELEASING.zh-CN.md +5 -0
  5. package/backend/dist/auth/api-keys.d.ts +14 -2
  6. package/backend/dist/auth/api-keys.js +26 -14
  7. package/backend/dist/auth/model-access.d.ts +27 -10
  8. package/backend/dist/auth/model-access.js +34 -17
  9. package/backend/dist/capture/migrate/engine.d.ts +38 -0
  10. package/backend/dist/capture/migrate/engine.js +307 -0
  11. package/backend/dist/capture/migrate/index.d.ts +18 -0
  12. package/backend/dist/capture/migrate/index.js +18 -0
  13. package/backend/dist/capture/migrate/migrator.d.ts +113 -0
  14. package/backend/dist/capture/migrate/migrator.js +16 -0
  15. package/backend/dist/capture/migrate/registry.d.ts +16 -0
  16. package/backend/dist/capture/migrate/registry.js +19 -0
  17. package/backend/dist/capture/migrate/steps/v1-to-v2.d.ts +86 -0
  18. package/backend/dist/capture/migrate/steps/v1-to-v2.js +396 -0
  19. package/backend/dist/capture/recorder.d.ts +422 -272
  20. package/backend/dist/capture/recorder.js +873 -417
  21. package/backend/dist/capture/turn-boundary.d.ts +17 -0
  22. package/backend/dist/capture/turn-boundary.js +31 -0
  23. package/backend/dist/cli/clients/base.d.ts +172 -26
  24. package/backend/dist/cli/clients/base.js +150 -4
  25. package/backend/dist/cli/clients/claude.d.ts +2 -1
  26. package/backend/dist/cli/clients/claude.js +4 -3
  27. package/backend/dist/cli/clients/codex.d.ts +2 -1
  28. package/backend/dist/cli/clients/codex.js +4 -3
  29. package/backend/dist/cli/clients/core-adapters.d.ts +24 -0
  30. package/backend/dist/cli/clients/core-adapters.js +43 -0
  31. package/backend/dist/cli/clients/cursor-proxy.d.ts +88 -0
  32. package/backend/dist/cli/clients/cursor-proxy.js +421 -0
  33. package/backend/dist/cli/clients/dsh.d.ts +4 -2
  34. package/backend/dist/cli/clients/dsh.js +29 -18
  35. package/backend/dist/cli/clients/grok.d.ts +53 -0
  36. package/backend/dist/cli/clients/grok.js +249 -0
  37. package/backend/dist/cli/clients/index.d.ts +35 -19
  38. package/backend/dist/cli/clients/index.js +196 -72
  39. package/backend/dist/cli/clients/kimi.d.ts +75 -0
  40. package/backend/dist/cli/clients/kimi.js +316 -0
  41. package/backend/dist/cli/clients/launcher.d.ts +56 -0
  42. package/backend/dist/cli/clients/launcher.js +41 -0
  43. package/backend/dist/cli/clients/model-meta.js +1 -1
  44. package/backend/dist/cli/clients/omp.d.ts +9 -19
  45. package/backend/dist/cli/clients/omp.js +28 -155
  46. package/backend/dist/cli/clients/openclaw.d.ts +55 -0
  47. package/backend/dist/cli/clients/openclaw.js +525 -0
  48. package/backend/dist/cli/clients/opencode-proxy.d.ts +5 -10
  49. package/backend/dist/cli/clients/opencode-proxy.js +37 -58
  50. package/backend/dist/cli/clients/opencode.d.ts +6 -19
  51. package/backend/dist/cli/clients/opencode.js +32 -159
  52. package/backend/dist/cli/clients/pi.d.ts +6 -20
  53. package/backend/dist/cli/clients/pi.js +32 -221
  54. package/backend/dist/cli/clients/plugin-adapters.d.ts +22 -0
  55. package/backend/dist/cli/clients/plugin-adapters.js +65 -0
  56. package/backend/dist/cli/clients/qoder-proxy.d.ts +84 -0
  57. package/backend/dist/cli/clients/qoder-proxy.js +497 -0
  58. package/backend/dist/cli/clients/reserved.d.ts +47 -0
  59. package/backend/dist/cli/clients/reserved.js +55 -0
  60. package/backend/dist/cli/clients/workbuddy.d.ts +31 -0
  61. package/backend/dist/cli/clients/workbuddy.js +259 -0
  62. package/backend/dist/cli/daemon.d.ts +105 -27
  63. package/backend/dist/cli/daemon.js +509 -151
  64. package/backend/dist/cli/index.d.ts +6 -1
  65. package/backend/dist/cli/index.js +289 -22
  66. package/backend/dist/cli/paths.d.ts +86 -0
  67. package/backend/dist/cli/paths.js +269 -0
  68. package/backend/dist/cli/shim.d.ts +47 -1
  69. package/backend/dist/cli/shim.js +180 -13
  70. package/backend/dist/cli/types.d.ts +114 -16
  71. package/backend/dist/cli/types.js +5 -4
  72. package/backend/dist/compression/caveman.d.ts +2 -16
  73. package/backend/dist/compression/caveman.js +25 -37
  74. package/backend/dist/compression/headroom.d.ts +4 -3
  75. package/backend/dist/compression/headroom.js +2 -2
  76. package/backend/dist/compression/index.d.ts +5 -26
  77. package/backend/dist/compression/index.js +79 -17
  78. package/backend/dist/compression/tool-output.d.ts +2 -20
  79. package/backend/dist/compression/tool-output.js +40 -47
  80. package/backend/dist/config/comments-en.d.ts +17 -0
  81. package/backend/dist/config/comments-en.js +226 -0
  82. package/backend/dist/config/comments-zh.d.ts +10 -0
  83. package/backend/dist/config/comments-zh.js +211 -0
  84. package/backend/dist/config/defaults.d.ts +245 -2
  85. package/backend/dist/config/defaults.js +259 -2
  86. package/backend/dist/config/env-archive.js +77 -38
  87. package/backend/dist/config/env.d.ts +4 -0
  88. package/backend/dist/config/env.js +16 -0
  89. package/backend/dist/config/index.d.ts +55 -12
  90. package/backend/dist/config/index.js +817 -368
  91. package/backend/dist/config/layout.d.ts +29 -0
  92. package/backend/dist/config/layout.js +86 -0
  93. package/backend/dist/config/migrations/v0-to-v1.d.ts +105 -0
  94. package/backend/dist/config/migrations/v0-to-v1.js +78 -0
  95. package/backend/dist/config/migrations/v1-to-v2.d.ts +14 -0
  96. package/backend/dist/config/migrations/v1-to-v2.js +41 -0
  97. package/backend/dist/config/migrations/v2-to-v3.d.ts +34 -0
  98. package/backend/dist/config/migrations/v2-to-v3.js +66 -0
  99. package/backend/dist/config/migrations/v3-to-v4.d.ts +34 -0
  100. package/backend/dist/config/migrations/v3-to-v4.js +61 -0
  101. package/backend/dist/config/runtime.d.ts +13 -0
  102. package/backend/dist/config/runtime.js +26 -0
  103. package/backend/dist/config/schema.d.ts +28 -0
  104. package/backend/dist/config/schema.js +98 -0
  105. package/backend/dist/config/types.d.ts +540 -121
  106. package/backend/dist/forward-proxy/access-log.d.ts +173 -0
  107. package/backend/dist/forward-proxy/access-log.js +657 -0
  108. package/backend/dist/forward-proxy/ca-trust.d.ts +42 -0
  109. package/backend/dist/forward-proxy/ca-trust.js +242 -0
  110. package/backend/dist/forward-proxy/ca.d.ts +66 -2
  111. package/backend/dist/forward-proxy/ca.js +146 -11
  112. package/backend/dist/forward-proxy/caller-context.d.ts +18 -0
  113. package/backend/dist/forward-proxy/caller-context.js +20 -0
  114. package/backend/dist/forward-proxy/egress.d.ts +112 -0
  115. package/backend/dist/forward-proxy/egress.js +318 -0
  116. package/backend/dist/forward-proxy/h2-forward.d.ts +66 -0
  117. package/backend/dist/forward-proxy/h2-forward.js +526 -0
  118. package/backend/dist/forward-proxy/index.d.ts +13 -1
  119. package/backend/dist/forward-proxy/index.js +148 -7
  120. package/backend/dist/forward-proxy/interceptor.d.ts +16 -13
  121. package/backend/dist/forward-proxy/interceptor.js +35 -57
  122. package/backend/dist/forward-proxy/ordered-relay.d.ts +29 -0
  123. package/backend/dist/forward-proxy/ordered-relay.js +46 -0
  124. package/backend/dist/forward-proxy/relay.d.ts +21 -1
  125. package/backend/dist/forward-proxy/relay.js +48 -1
  126. package/backend/dist/forward-proxy/rules.d.ts +195 -0
  127. package/backend/dist/forward-proxy/rules.js +327 -0
  128. package/backend/dist/forward-proxy/server.d.ts +102 -9
  129. package/backend/dist/forward-proxy/server.js +1504 -350
  130. package/backend/dist/forward-proxy/sni.d.ts +29 -7
  131. package/backend/dist/forward-proxy/sni.js +109 -47
  132. package/backend/dist/forward-proxy/system-proxy.d.ts +112 -0
  133. package/backend/dist/forward-proxy/system-proxy.js +480 -0
  134. package/backend/dist/forward-proxy/upstream-tls.d.ts +46 -0
  135. package/backend/dist/forward-proxy/upstream-tls.js +105 -0
  136. package/backend/dist/forward-proxy/ws-frames.d.ts +45 -0
  137. package/backend/dist/forward-proxy/ws-frames.js +153 -0
  138. package/backend/dist/harness/common/catalog-registry.d.ts +63 -0
  139. package/backend/dist/harness/common/catalog-registry.js +77 -0
  140. package/backend/dist/harness/common/github.d.ts +6 -0
  141. package/backend/dist/harness/common/github.js +13 -0
  142. package/backend/dist/harness/common/market.d.ts +590 -0
  143. package/backend/dist/harness/common/market.js +1079 -0
  144. package/backend/dist/harness/common/marketplace-rescan-scheduler.d.ts +24 -0
  145. package/backend/dist/harness/common/marketplace-rescan-scheduler.js +62 -0
  146. package/backend/dist/harness/{catalog-npm.d.ts → common/npm-catalog.d.ts} +5 -5
  147. package/backend/dist/harness/{catalog-npm.js → common/npm-catalog.js} +7 -7
  148. package/backend/dist/harness/common/npm-source.d.ts +29 -0
  149. package/backend/dist/harness/common/npm-source.js +121 -0
  150. package/backend/dist/harness/common/pypi-source.d.ts +28 -0
  151. package/backend/dist/harness/common/pypi-source.js +71 -0
  152. package/backend/dist/harness/common/source-views.d.ts +22 -0
  153. package/backend/dist/harness/common/source-views.js +25 -0
  154. package/backend/dist/harness/{stars.d.ts → common/stars.d.ts} +1 -1
  155. package/backend/dist/harness/{stars.js → common/stars.js} +2 -2
  156. package/backend/dist/harness/common/text.d.ts +11 -0
  157. package/backend/dist/harness/common/text.js +18 -0
  158. package/backend/dist/harness/config-file.d.ts +14 -1
  159. package/backend/dist/harness/config-file.js +38 -0
  160. package/backend/dist/harness/db-probe.d.ts +29 -0
  161. package/backend/dist/harness/db-probe.js +270 -0
  162. package/backend/dist/harness/detail.d.ts +10 -1
  163. package/backend/dist/harness/detail.js +144 -7
  164. package/backend/dist/harness/host/adapters/amp.d.ts +19 -0
  165. package/backend/dist/harness/host/adapters/amp.js +21 -0
  166. package/backend/dist/harness/host/adapters/antigravity.d.ts +18 -0
  167. package/backend/dist/harness/host/adapters/antigravity.js +21 -0
  168. package/backend/dist/harness/host/adapters/base.d.ts +225 -0
  169. package/backend/dist/harness/host/adapters/base.js +521 -0
  170. package/backend/dist/harness/host/adapters/claude.d.ts +54 -0
  171. package/backend/dist/harness/host/adapters/claude.js +145 -0
  172. package/backend/dist/harness/host/adapters/cline.d.ts +18 -0
  173. package/backend/dist/harness/host/adapters/cline.js +20 -0
  174. package/backend/dist/harness/host/adapters/codex.d.ts +54 -0
  175. package/backend/dist/harness/host/adapters/codex.js +133 -0
  176. package/backend/dist/harness/host/adapters/cursor.d.ts +18 -0
  177. package/backend/dist/harness/host/adapters/cursor.js +24 -0
  178. package/backend/dist/harness/host/adapters/declarative.d.ts +22 -0
  179. package/backend/dist/harness/host/adapters/declarative.js +38 -0
  180. package/backend/dist/harness/host/adapters/dsh.d.ts +76 -0
  181. package/backend/dist/harness/host/adapters/dsh.js +253 -0
  182. package/backend/dist/harness/host/adapters/factory.d.ts +36 -0
  183. package/backend/dist/harness/host/adapters/factory.js +34 -0
  184. package/backend/dist/harness/host/adapters/gemini-cli.d.ts +17 -0
  185. package/backend/dist/harness/host/adapters/gemini-cli.js +19 -0
  186. package/backend/dist/harness/host/adapters/grok.d.ts +66 -0
  187. package/backend/dist/harness/host/adapters/grok.js +136 -0
  188. package/backend/dist/harness/{adapters → host/adapters}/index.d.ts +9 -4
  189. package/backend/dist/harness/{adapters → host/adapters}/index.js +31 -10
  190. package/backend/dist/harness/host/adapters/kimi.d.ts +30 -0
  191. package/backend/dist/harness/host/adapters/kimi.js +59 -0
  192. package/backend/dist/harness/host/adapters/omp.d.ts +55 -0
  193. package/backend/dist/harness/host/adapters/omp.js +90 -0
  194. package/backend/dist/harness/host/adapters/openclaw.d.ts +54 -0
  195. package/backend/dist/harness/host/adapters/openclaw.js +141 -0
  196. package/backend/dist/harness/host/adapters/opencode.d.ts +24 -0
  197. package/backend/dist/harness/host/adapters/opencode.js +48 -0
  198. package/backend/dist/harness/host/adapters/pi.d.ts +27 -0
  199. package/backend/dist/harness/host/adapters/pi.js +58 -0
  200. package/backend/dist/harness/host/adapters/types.d.ts +395 -0
  201. package/backend/dist/harness/host/adapters/types.js +17 -0
  202. package/backend/dist/harness/host/adapters/universal.d.ts +14 -0
  203. package/backend/dist/harness/host/adapters/universal.js +18 -0
  204. package/backend/dist/harness/host/adapters/windsurf.d.ts +20 -0
  205. package/backend/dist/harness/host/adapters/windsurf.js +22 -0
  206. package/backend/dist/harness/host/adapters/zed.d.ts +12 -0
  207. package/backend/dist/harness/host/adapters/zed.js +14 -0
  208. package/backend/dist/harness/host/claude-mcp-runtime.d.ts +6 -0
  209. package/backend/dist/harness/host/claude-mcp-runtime.js +56 -0
  210. package/backend/dist/harness/{discover.d.ts → host/discover.d.ts} +54 -18
  211. package/backend/dist/harness/{discover.js → host/discover.js} +314 -53
  212. package/backend/dist/harness/{drift.d.ts → host/drift.d.ts} +1 -1
  213. package/backend/dist/harness/{drift.js → host/drift.js} +1 -1
  214. package/backend/dist/harness/host/grok-mcp-runtime.d.ts +6 -0
  215. package/backend/dist/harness/host/grok-mcp-runtime.js +56 -0
  216. package/backend/dist/harness/{hosts.d.ts → host/hosts.d.ts} +3 -3
  217. package/backend/dist/harness/{hosts.js → host/hosts.js} +7 -3
  218. package/backend/dist/harness/host/index.d.ts +10 -0
  219. package/backend/dist/harness/host/index.js +12 -0
  220. package/backend/dist/harness/host/install-log.d.ts +22 -0
  221. package/backend/dist/harness/host/install-log.js +106 -0
  222. package/backend/dist/harness/{install.d.ts → host/install.d.ts} +32 -13
  223. package/backend/dist/harness/{install.js → host/install.js} +133 -50
  224. package/backend/dist/harness/host/inventory.d.ts +30 -0
  225. package/backend/dist/harness/{inventory.js → host/inventory.js} +107 -16
  226. package/backend/dist/harness/host/kimi-mcp-runtime.d.ts +6 -0
  227. package/backend/dist/harness/host/kimi-mcp-runtime.js +84 -0
  228. package/backend/dist/harness/{ledger.d.ts → host/ledger.d.ts} +1 -1
  229. package/backend/dist/harness/{ledger.js → host/ledger.js} +3 -3
  230. package/backend/dist/harness/{maintenance.d.ts → host/maintenance.d.ts} +23 -6
  231. package/backend/dist/harness/{maintenance.js → host/maintenance.js} +355 -63
  232. package/backend/dist/harness/{manifest.d.ts → host/manifest.d.ts} +11 -2
  233. package/backend/dist/harness/{manifest.js → host/manifest.js} +76 -15
  234. package/backend/dist/harness/host/marketplace-sync.d.ts +64 -0
  235. package/backend/dist/harness/host/marketplace-sync.js +231 -0
  236. package/backend/dist/harness/host/mcp-cli.d.ts +44 -0
  237. package/backend/dist/harness/host/mcp-cli.js +545 -0
  238. package/backend/dist/harness/host/mcp-edit.d.ts +89 -0
  239. package/backend/dist/harness/host/mcp-edit.js +342 -0
  240. package/backend/dist/harness/host/mcp-entry.d.ts +100 -0
  241. package/backend/dist/harness/host/mcp-entry.js +435 -0
  242. package/backend/dist/harness/host/mcp-inspector.d.ts +125 -0
  243. package/backend/dist/harness/host/mcp-inspector.js +634 -0
  244. package/backend/dist/harness/host/mcp-registry.d.ts +66 -0
  245. package/backend/dist/harness/host/mcp-registry.js +331 -0
  246. package/backend/dist/harness/host/mcp-runtime.d.ts +19 -0
  247. package/backend/dist/harness/host/mcp-runtime.js +22 -0
  248. package/backend/dist/harness/host/opencode-mcp-runtime.d.ts +7 -0
  249. package/backend/dist/harness/host/opencode-mcp-runtime.js +73 -0
  250. package/backend/dist/harness/{probe.d.ts → host/probe.d.ts} +4 -4
  251. package/backend/dist/harness/{probe.js → host/probe.js} +8 -8
  252. package/backend/dist/harness/{registry.d.ts → host/registry.d.ts} +1 -1
  253. package/backend/dist/harness/host/registry.js +28 -0
  254. package/backend/dist/harness/host/request.d.ts +56 -0
  255. package/backend/dist/harness/host/request.js +1 -0
  256. package/backend/dist/harness/{sources → host/resolvers}/clawhub.d.ts +1 -1
  257. package/backend/dist/harness/{sources → host/resolvers}/clawhub.js +1 -1
  258. package/backend/dist/harness/host/resolvers/git-marketplace.d.ts +16 -0
  259. package/backend/dist/harness/host/resolvers/git-marketplace.js +53 -0
  260. package/backend/dist/harness/{sources → host/resolvers}/github.d.ts +1 -1
  261. package/backend/dist/harness/{sources → host/resolvers}/github.js +2 -2
  262. package/backend/dist/harness/host/resolvers/npm.d.ts +2 -0
  263. package/backend/dist/harness/{sources → host/resolvers}/npm.js +16 -10
  264. package/backend/dist/harness/host/resolvers/pypi.d.ts +2 -0
  265. package/backend/dist/harness/host/resolvers/pypi.js +100 -0
  266. package/backend/dist/harness/host/scopes.d.ts +11 -0
  267. package/backend/dist/harness/host/scopes.js +12 -0
  268. package/backend/dist/harness/host/timeouts.d.ts +8 -0
  269. package/backend/dist/harness/host/timeouts.js +8 -0
  270. package/backend/dist/harness/host/writers/kimi-web.d.ts +70 -0
  271. package/backend/dist/harness/host/writers/kimi-web.js +222 -0
  272. package/backend/dist/harness/host/writers/mcp.d.ts +119 -0
  273. package/backend/dist/harness/host/writers/mcp.js +359 -0
  274. package/backend/dist/harness/host/writers/plugin.d.ts +176 -0
  275. package/backend/dist/harness/host/writers/plugin.js +528 -0
  276. package/backend/dist/harness/{writers → host/writers}/skill.d.ts +3 -3
  277. package/backend/dist/harness/{writers → host/writers}/skill.js +6 -3
  278. package/backend/dist/harness/lang.d.ts +14 -0
  279. package/backend/dist/harness/lang.js +33 -0
  280. package/backend/dist/harness/net.d.ts +33 -0
  281. package/backend/dist/harness/net.js +63 -0
  282. package/backend/dist/harness/plugin/adapters/antigravity.d.ts +11 -0
  283. package/backend/dist/harness/plugin/adapters/antigravity.js +14 -0
  284. package/backend/dist/harness/plugin/adapters/base.d.ts +107 -0
  285. package/backend/dist/harness/plugin/adapters/base.js +454 -0
  286. package/backend/dist/harness/plugin/adapters/claude.d.ts +28 -0
  287. package/backend/dist/harness/plugin/adapters/claude.js +63 -0
  288. package/backend/dist/harness/plugin/adapters/codex.d.ts +13 -0
  289. package/backend/dist/harness/plugin/adapters/codex.js +16 -0
  290. package/backend/dist/harness/plugin/adapters/cursor.d.ts +13 -0
  291. package/backend/dist/harness/plugin/adapters/cursor.js +16 -0
  292. package/backend/dist/harness/plugin/adapters/dsh-plugin-net.d.ts +20 -0
  293. package/backend/dist/harness/plugin/adapters/dsh-plugin-net.js +371 -0
  294. package/backend/dist/harness/plugin/adapters/dsh.d.ts +22 -0
  295. package/backend/dist/harness/plugin/adapters/dsh.js +50 -0
  296. package/backend/dist/harness/plugin/adapters/factory.d.ts +11 -0
  297. package/backend/dist/harness/plugin/adapters/factory.js +19 -0
  298. package/backend/dist/harness/plugin/adapters/gemini.d.ts +12 -0
  299. package/backend/dist/harness/plugin/adapters/gemini.js +22 -0
  300. package/backend/dist/harness/plugin/adapters/grok.d.ts +15 -0
  301. package/backend/dist/harness/plugin/adapters/grok.js +23 -0
  302. package/backend/dist/harness/plugin/adapters/index.d.ts +41 -0
  303. package/backend/dist/harness/plugin/adapters/index.js +143 -0
  304. package/backend/dist/harness/plugin/adapters/kimi.d.ts +6 -0
  305. package/backend/dist/harness/plugin/adapters/kimi.js +35 -0
  306. package/backend/dist/harness/plugin/adapters/omp.d.ts +19 -0
  307. package/backend/dist/harness/plugin/adapters/omp.js +26 -0
  308. package/backend/dist/harness/plugin/adapters/openclaw.d.ts +20 -0
  309. package/backend/dist/harness/plugin/adapters/openclaw.js +36 -0
  310. package/backend/dist/harness/plugin/adapters/pi-dev.d.ts +124 -0
  311. package/backend/dist/harness/plugin/adapters/pi-dev.js +420 -0
  312. package/backend/dist/harness/plugin/adapters/pi-github.d.ts +18 -0
  313. package/backend/dist/harness/plugin/adapters/pi-github.js +27 -0
  314. package/backend/dist/harness/plugin/adapters/universal.d.ts +11 -0
  315. package/backend/dist/harness/plugin/adapters/universal.js +18 -0
  316. package/backend/dist/harness/plugin/builtin.d.ts +13 -0
  317. package/backend/dist/harness/plugin/builtin.js +34 -0
  318. package/backend/dist/harness/plugin/catalog.d.ts +30 -0
  319. package/backend/dist/harness/plugin/catalog.js +200 -0
  320. package/backend/dist/harness/plugin/index.d.ts +9 -0
  321. package/backend/dist/harness/plugin/index.js +9 -0
  322. package/backend/dist/harness/plugin/types.d.ts +164 -0
  323. package/backend/dist/harness/plugin/types.js +1 -0
  324. package/backend/dist/harness/{clawhub.d.ts → skill/clawhub.d.ts} +28 -5
  325. package/backend/dist/harness/{clawhub.js → skill/clawhub.js} +170 -5
  326. package/backend/dist/harness/skill/skills-sh.d.ts +47 -0
  327. package/backend/dist/harness/skill/skills-sh.js +270 -0
  328. package/backend/dist/harness/skill/sources.d.ts +41 -0
  329. package/backend/dist/harness/skill/sources.js +131 -0
  330. package/backend/dist/harness/spi.d.ts +11 -7
  331. package/backend/dist/harness/tcp-reach.d.ts +30 -0
  332. package/backend/dist/harness/tcp-reach.js +61 -0
  333. package/backend/dist/harness/translation.d.ts +31 -13
  334. package/backend/dist/harness/translation.js +265 -80
  335. package/backend/dist/harness/types.d.ts +62 -17
  336. package/backend/dist/harness/types.js +1 -1
  337. package/backend/dist/index.js +183 -16
  338. package/backend/dist/ir/adapters/anthropic-messages-stream.d.ts +18 -0
  339. package/backend/dist/ir/adapters/anthropic-messages-stream.js +266 -0
  340. package/backend/dist/ir/adapters/anthropic-messages.d.ts +30 -0
  341. package/backend/dist/ir/adapters/anthropic-messages.js +870 -0
  342. package/backend/dist/ir/adapters/anthropic-stream.d.ts +18 -0
  343. package/backend/dist/ir/adapters/anthropic-stream.js +247 -0
  344. package/backend/dist/ir/adapters/anthropic.d.ts +29 -0
  345. package/backend/dist/ir/adapters/anthropic.js +788 -0
  346. package/backend/dist/ir/adapters/chat.d.ts +15 -0
  347. package/backend/dist/ir/adapters/chat.js +602 -0
  348. package/backend/dist/ir/adapters/google-gemini-stream.d.ts +22 -0
  349. package/backend/dist/ir/adapters/google-gemini-stream.js +246 -0
  350. package/backend/dist/ir/adapters/google-gemini.d.ts +9 -0
  351. package/backend/dist/ir/adapters/google-gemini.js +450 -0
  352. package/backend/dist/ir/adapters/google-stream.d.ts +22 -0
  353. package/backend/dist/ir/adapters/google-stream.js +242 -0
  354. package/backend/dist/ir/adapters/google.d.ts +9 -0
  355. package/backend/dist/ir/adapters/google.js +317 -0
  356. package/backend/dist/ir/adapters/openai-chat-stream.d.ts +41 -0
  357. package/backend/dist/ir/adapters/openai-chat-stream.js +369 -0
  358. package/backend/dist/ir/adapters/openai-chat.d.ts +17 -0
  359. package/backend/dist/ir/adapters/openai-chat.js +670 -0
  360. package/backend/dist/ir/adapters/openai-responses-output.d.ts +50 -0
  361. package/backend/dist/ir/adapters/openai-responses-output.js +356 -0
  362. package/backend/dist/ir/adapters/openai-responses-stream.d.ts +12 -0
  363. package/backend/dist/ir/adapters/openai-responses-stream.js +193 -0
  364. package/backend/dist/ir/adapters/openai-responses.d.ts +29 -0
  365. package/backend/dist/ir/adapters/openai-responses.js +695 -0
  366. package/backend/dist/ir/adapters/responses-output.d.ts +50 -0
  367. package/backend/dist/ir/adapters/responses-output.js +348 -0
  368. package/backend/dist/ir/adapters/responses-stream.d.ts +12 -0
  369. package/backend/dist/ir/adapters/responses-stream.js +178 -0
  370. package/backend/dist/ir/adapters/responses.d.ts +14 -0
  371. package/backend/dist/ir/adapters/responses.js +646 -0
  372. package/backend/dist/ir/capabilities.d.ts +41 -0
  373. package/backend/dist/ir/capabilities.js +147 -0
  374. package/backend/dist/ir/errors.d.ts +23 -0
  375. package/backend/dist/ir/errors.js +31 -0
  376. package/backend/dist/ir/index.d.ts +5 -0
  377. package/backend/dist/ir/index.js +5 -0
  378. package/backend/dist/ir/media.d.ts +2 -0
  379. package/backend/dist/ir/media.js +2 -0
  380. package/backend/dist/ir/stream.d.ts +17 -0
  381. package/backend/dist/ir/stream.js +250 -0
  382. package/backend/dist/ir/types.d.ts +524 -0
  383. package/backend/dist/ir/types.js +19 -0
  384. package/backend/dist/ir/validate.d.ts +18 -0
  385. package/backend/dist/ir/validate.js +272 -0
  386. package/backend/dist/metrics/request-cost.d.ts +11 -10
  387. package/backend/dist/metrics/request-cost.js +18 -27
  388. package/backend/dist/observability/failure-events.d.ts +20 -4
  389. package/backend/dist/observability/failure-events.js +9 -1
  390. package/backend/dist/observability/http-exchange.d.ts +75 -27
  391. package/backend/dist/observability/http-exchange.js +136 -39
  392. package/backend/dist/observability/request-identity.d.ts +40 -0
  393. package/backend/dist/observability/request-identity.js +102 -0
  394. package/backend/dist/observability/traffic-live-hidden.d.ts +24 -0
  395. package/backend/dist/observability/traffic-live-hidden.js +82 -0
  396. package/backend/dist/observability/upstream-body-redaction.d.ts +23 -0
  397. package/backend/dist/observability/upstream-body-redaction.js +72 -0
  398. package/backend/dist/observability/upstream-events.d.ts +90 -62
  399. package/backend/dist/observability/upstream-events.js +145 -64
  400. package/backend/dist/opencode/agents.d.ts +3 -2
  401. package/backend/dist/opencode/catalog/auto-pull.d.ts +35 -1
  402. package/backend/dist/opencode/catalog/auto-pull.js +169 -33
  403. package/backend/dist/opencode/catalog/ocr-store.d.ts +6 -6
  404. package/backend/dist/opencode/catalog/ocr-store.js +2 -2
  405. package/backend/dist/opencode/catalog/overrides-store.d.ts +6 -5
  406. package/backend/dist/opencode/catalog/overrides-store.js +28 -3
  407. package/backend/dist/opencode/catalog/repository.d.ts +4 -0
  408. package/backend/dist/opencode/catalog/repository.js +19 -0
  409. package/backend/dist/opencode/catalog/sources/models-dev.d.ts +4 -0
  410. package/backend/dist/opencode/catalog/sources/models-dev.js +15 -4
  411. package/backend/dist/opencode/catalog/types.d.ts +19 -7
  412. package/backend/dist/opencode/connector.d.ts +2 -2
  413. package/backend/dist/opencode/connector.js +2 -2
  414. package/backend/dist/opencode/credentials/def-materialize.d.ts +0 -5
  415. package/backend/dist/opencode/credentials/def-materialize.js +149 -11
  416. package/backend/dist/opencode/credentials/ocr-store.d.ts +18 -0
  417. package/backend/dist/opencode/credentials/ocr-store.js +88 -7
  418. package/backend/dist/opencode/credentials/opencode-v2-store.d.ts +24 -13
  419. package/backend/dist/opencode/credentials/opencode-v2-store.js +70 -29
  420. package/backend/dist/opencode/credentials/paths.d.ts +8 -0
  421. package/backend/dist/opencode/credentials/paths.js +10 -0
  422. package/backend/dist/opencode/credentials/sync.d.ts +1 -1
  423. package/backend/dist/opencode/credentials/sync.js +4 -4
  424. package/backend/dist/opencode/credentials/types.d.ts +38 -2
  425. package/backend/dist/opencode/probe.d.ts +33 -6
  426. package/backend/dist/opencode/probe.js +96 -19
  427. package/backend/dist/opencode/provider-defs.js +59 -2
  428. package/backend/dist/opencode/provider-package.d.ts +31 -0
  429. package/backend/dist/opencode/provider-package.js +70 -0
  430. package/backend/dist/opencode/user-config.d.ts +16 -17
  431. package/backend/dist/opencode/user-config.js +42 -66
  432. package/backend/dist/pipeline/credential-selection.d.ts +13 -0
  433. package/backend/dist/pipeline/credential-selection.js +29 -1
  434. package/backend/dist/pipeline/directives.d.ts +18 -22
  435. package/backend/dist/pipeline/directives.js +129 -71
  436. package/backend/dist/pipeline/orchestrator.d.ts +70 -34
  437. package/backend/dist/pipeline/orchestrator.js +901 -405
  438. package/backend/dist/pipeline/prompt-optimizer.d.ts +6 -13
  439. package/backend/dist/pipeline/prompt-optimizer.js +9 -52
  440. package/backend/dist/pipeline/streaming-posture.d.ts +29 -0
  441. package/backend/dist/pipeline/streaming-posture.js +27 -0
  442. package/backend/dist/pipeline/tool-pairing.d.ts +10 -0
  443. package/backend/dist/pipeline/tool-pairing.js +90 -0
  444. package/backend/dist/pipeline/unresolved-model.d.ts +33 -0
  445. package/backend/dist/pipeline/unresolved-model.js +43 -0
  446. package/backend/dist/plugins/builtin/model-gateway.d.ts +30 -0
  447. package/backend/dist/plugins/builtin/model-gateway.js +98 -0
  448. package/backend/dist/plugins/catalog-def.d.ts +143 -0
  449. package/backend/dist/plugins/catalog-def.js +177 -0
  450. package/backend/dist/plugins/config.d.ts +41 -0
  451. package/backend/dist/plugins/config.js +113 -0
  452. package/backend/dist/plugins/gateways.d.ts +157 -0
  453. package/backend/dist/plugins/gateways.js +288 -0
  454. package/backend/dist/plugins/host.d.ts +240 -0
  455. package/backend/dist/plugins/host.js +1726 -0
  456. package/backend/dist/plugins/manifest.d.ts +152 -0
  457. package/backend/dist/plugins/manifest.js +713 -0
  458. package/backend/dist/plugins/pack.d.ts +32 -0
  459. package/backend/dist/plugins/pack.js +248 -0
  460. package/backend/dist/plugins/seed.d.ts +53 -0
  461. package/backend/dist/plugins/seed.js +136 -0
  462. package/backend/dist/plugins/types.d.ts +887 -0
  463. package/backend/dist/plugins/types.js +1 -0
  464. package/backend/dist/projects/store.d.ts +56 -0
  465. package/backend/dist/projects/store.js +194 -0
  466. package/backend/dist/projects/types.d.ts +12 -0
  467. package/backend/dist/projects/types.js +1 -0
  468. package/backend/dist/protocols/chat-compat.d.ts +2 -0
  469. package/backend/dist/protocols/chat-compat.js +137 -0
  470. package/backend/dist/protocols/systemone/convert.d.ts +6 -4
  471. package/backend/dist/protocols/systemone/convert.js +78 -27
  472. package/backend/dist/protocols/systemone/decide.js +144 -57
  473. package/backend/dist/protocols/systemone/native.d.ts +1 -1
  474. package/backend/dist/protocols/systemone/native.js +6 -6
  475. package/backend/dist/providers/anthropic-messages.d.ts +12 -0
  476. package/backend/dist/providers/anthropic-messages.js +53 -0
  477. package/backend/dist/providers/anthropic.d.ts +7 -8
  478. package/backend/dist/providers/anthropic.js +36 -324
  479. package/backend/dist/providers/base.d.ts +18 -45
  480. package/backend/dist/providers/boot-direct.d.ts +20 -2
  481. package/backend/dist/providers/boot-direct.js +140 -61
  482. package/backend/dist/providers/compat/tool-markup-leak.d.ts +41 -0
  483. package/backend/dist/providers/compat/tool-markup-leak.js +57 -0
  484. package/backend/dist/providers/compat/tool-markup-recovery.d.ts +27 -0
  485. package/backend/dist/providers/compat/tool-markup-recovery.js +831 -0
  486. package/backend/dist/providers/dispatch.d.ts +5 -22
  487. package/backend/dist/providers/dispatch.js +49 -55
  488. package/backend/dist/providers/executors/anthropic-messages.d.ts +13 -0
  489. package/backend/dist/providers/executors/anthropic-messages.js +59 -0
  490. package/backend/dist/providers/executors/dispatch.d.ts +28 -0
  491. package/backend/dist/providers/executors/dispatch.js +101 -0
  492. package/backend/dist/providers/executors/google-gemini.d.ts +13 -0
  493. package/backend/dist/providers/executors/google-gemini.js +56 -0
  494. package/backend/dist/providers/executors/http-json.d.ts +19 -0
  495. package/backend/dist/providers/executors/http-json.js +125 -0
  496. package/backend/dist/providers/executors/http-stream.d.ts +53 -0
  497. package/backend/dist/providers/executors/http-stream.js +485 -0
  498. package/backend/dist/providers/executors/openai-chat.d.ts +14 -0
  499. package/backend/dist/providers/executors/openai-chat.js +92 -0
  500. package/backend/dist/providers/executors/openai-responses.d.ts +13 -0
  501. package/backend/dist/providers/executors/openai-responses.js +74 -0
  502. package/backend/dist/providers/executors/plugin-adapter.d.ts +9 -0
  503. package/backend/dist/providers/executors/plugin-adapter.js +31 -0
  504. package/backend/dist/providers/google-gemini.d.ts +12 -0
  505. package/backend/dist/providers/google-gemini.js +50 -0
  506. package/backend/dist/providers/google.d.ts +7 -8
  507. package/backend/dist/providers/google.js +35 -308
  508. package/backend/dist/providers/http-json.d.ts +19 -0
  509. package/backend/dist/providers/http-json.js +104 -0
  510. package/backend/dist/providers/http-stream.d.ts +52 -0
  511. package/backend/dist/providers/http-stream.js +423 -0
  512. package/backend/dist/providers/member-match.d.ts +4 -5
  513. package/backend/dist/providers/member-match.js +4 -5
  514. package/backend/dist/providers/openai-chat.d.ts +13 -0
  515. package/backend/dist/providers/openai-chat.js +99 -0
  516. package/backend/dist/providers/openai-compatible.d.ts +7 -4
  517. package/backend/dist/providers/openai-compatible.js +71 -368
  518. package/backend/dist/providers/openai-responses.d.ts +12 -0
  519. package/backend/dist/providers/openai-responses.js +68 -0
  520. package/backend/dist/providers/opencode-proxy.d.ts +5 -5
  521. package/backend/dist/providers/opencode-proxy.js +49 -125
  522. package/backend/dist/providers/plugin-adapter.d.ts +9 -0
  523. package/backend/dist/providers/plugin-adapter.js +31 -0
  524. package/backend/dist/providers/plugin-wires.d.ts +34 -0
  525. package/backend/dist/providers/plugin-wires.js +82 -0
  526. package/backend/dist/providers/pool-refresh.d.ts +14 -0
  527. package/backend/dist/providers/pool-refresh.js +13 -0
  528. package/backend/dist/providers/protocol.d.ts +4 -0
  529. package/backend/dist/providers/protocol.js +61 -0
  530. package/backend/dist/providers/provider-takedown.d.ts +59 -0
  531. package/backend/dist/providers/provider-takedown.js +135 -0
  532. package/backend/dist/providers/registry.d.ts +85 -44
  533. package/backend/dist/providers/registry.js +299 -162
  534. package/backend/dist/providers/responses.d.ts +7 -26
  535. package/backend/dist/providers/responses.js +45 -250
  536. package/backend/dist/providers/tool-markup-leak.d.ts +41 -0
  537. package/backend/dist/providers/tool-markup-leak.js +57 -0
  538. package/backend/dist/providers/tool-markup-recovery.d.ts +27 -0
  539. package/backend/dist/providers/tool-markup-recovery.js +786 -0
  540. package/backend/dist/providers/virtual-meta.d.ts +21 -2
  541. package/backend/dist/providers/virtual-meta.js +49 -9
  542. package/backend/dist/providers/vocabulary.d.ts +24 -6
  543. package/backend/dist/providers/vocabulary.js +75 -33
  544. package/backend/dist/providers/wire.d.ts +12 -17
  545. package/backend/dist/providers/wire.js +43 -91
  546. package/backend/dist/proxy/asset-download.d.ts +54 -0
  547. package/backend/dist/proxy/asset-download.js +420 -0
  548. package/backend/dist/proxy/manual-node-spec.d.ts +92 -0
  549. package/backend/dist/proxy/manual-node-spec.js +408 -0
  550. package/backend/dist/proxy/mihomo-binary.d.ts +54 -0
  551. package/backend/dist/proxy/mihomo-binary.js +278 -0
  552. package/backend/dist/proxy/mihomo-client.d.ts +94 -0
  553. package/backend/dist/proxy/mihomo-client.js +308 -0
  554. package/backend/dist/proxy/mihomo-config.d.ts +40 -0
  555. package/backend/dist/proxy/mihomo-config.js +161 -0
  556. package/backend/dist/proxy/mihomo-geo.d.ts +87 -0
  557. package/backend/dist/proxy/mihomo-geo.js +213 -0
  558. package/backend/dist/proxy/mihomo-logs.d.ts +27 -0
  559. package/backend/dist/proxy/mihomo-logs.js +70 -0
  560. package/backend/dist/proxy/mihomo-pac.d.ts +37 -0
  561. package/backend/dist/proxy/mihomo-pac.js +75 -0
  562. package/backend/dist/proxy/mihomo-rules-import.d.ts +43 -0
  563. package/backend/dist/proxy/mihomo-rules-import.js +193 -0
  564. package/backend/dist/proxy/mihomo-sidecar.d.ts +81 -0
  565. package/backend/dist/proxy/mihomo-sidecar.js +637 -0
  566. package/backend/dist/quota/adapters/minimax.js +36 -13
  567. package/backend/dist/quota/cli-login.d.ts +8 -0
  568. package/backend/dist/quota/cli-login.js +18 -0
  569. package/backend/dist/quota/declarations.js +10 -0
  570. package/backend/dist/quota/dsl.js +18 -5
  571. package/backend/dist/quota/engine.d.ts +31 -3
  572. package/backend/dist/quota/engine.js +189 -30
  573. package/backend/dist/quota/prober.d.ts +13 -4
  574. package/backend/dist/quota/prober.js +20 -12
  575. package/backend/dist/quota/types.d.ts +87 -8
  576. package/backend/dist/quota/verdict.d.ts +35 -0
  577. package/backend/dist/quota/verdict.js +135 -0
  578. package/backend/dist/ratelimit/admission.d.ts +131 -0
  579. package/backend/dist/ratelimit/admission.js +233 -0
  580. package/backend/dist/ratelimit/rate-limiter.d.ts +119 -6
  581. package/backend/dist/ratelimit/rate-limiter.js +364 -20
  582. package/backend/dist/ratelimit/window-store.d.ts +34 -0
  583. package/backend/dist/ratelimit/window-store.js +70 -0
  584. package/backend/dist/resilience/breaker-state.js +8 -1
  585. package/backend/dist/resilience/circuit-breaker-manager.d.ts +229 -132
  586. package/backend/dist/resilience/circuit-breaker-manager.js +566 -297
  587. package/backend/dist/resilience/circuit-breaker.d.ts +11 -0
  588. package/backend/dist/resilience/circuit-breaker.js +39 -7
  589. package/backend/dist/resilience/error-classifier.d.ts +31 -3
  590. package/backend/dist/resilience/error-classifier.js +159 -31
  591. package/backend/dist/resilience/health-prober.d.ts +21 -4
  592. package/backend/dist/resilience/health-prober.js +100 -18
  593. package/backend/dist/resilience/types.d.ts +54 -7
  594. package/backend/dist/resilience/types.js +1 -1
  595. package/backend/dist/router/index.d.ts +6 -29
  596. package/backend/dist/router/index.js +15 -61
  597. package/backend/dist/router/layer2-decision.d.ts +3 -3
  598. package/backend/dist/router/layer2-decision.js +26 -26
  599. package/backend/dist/router/request-traits.d.ts +4 -11
  600. package/backend/dist/router/request-traits.js +5 -13
  601. package/backend/dist/routes/console.js +2145 -259
  602. package/backend/dist/routes/environments.d.ts +3 -2
  603. package/backend/dist/routes/environments.js +8 -4
  604. package/backend/dist/routes/harness.d.ts +3 -1
  605. package/backend/dist/routes/harness.js +1162 -356
  606. package/backend/dist/routes/mihomo.d.ts +7 -0
  607. package/backend/dist/routes/mihomo.js +1187 -0
  608. package/backend/dist/routes/projects.d.ts +2 -0
  609. package/backend/dist/routes/projects.js +90 -0
  610. package/backend/dist/routes/responses.d.ts +107 -9
  611. package/backend/dist/routes/responses.js +378 -35
  612. package/backend/dist/routes/translation.d.ts +9 -0
  613. package/backend/dist/routes/translation.js +155 -0
  614. package/backend/dist/server.js +379 -73
  615. package/backend/dist/session/resp-store.d.ts +18 -49
  616. package/backend/dist/session/resp-store.js +114 -122
  617. package/backend/dist/session/session-manager.d.ts +228 -81
  618. package/backend/dist/session/session-manager.js +449 -190
  619. package/backend/dist/session/session-row.d.ts +81 -2
  620. package/backend/dist/session/session-row.js +69 -1
  621. package/backend/dist/surfaces/anthropic.d.ts +1 -15
  622. package/backend/dist/surfaces/anthropic.js +63 -44
  623. package/backend/dist/surfaces/chat-pipeline.d.ts +10 -6
  624. package/backend/dist/surfaces/chat-pipeline.js +119 -42
  625. package/backend/dist/surfaces/chat.d.ts +1 -9
  626. package/backend/dist/surfaces/chat.js +67 -29
  627. package/backend/dist/surfaces/decision-pipeline.js +32 -27
  628. package/backend/dist/surfaces/direct-forward.d.ts +3 -0
  629. package/backend/dist/surfaces/direct-forward.js +206 -0
  630. package/backend/dist/surfaces/gateway-chat.d.ts +53 -0
  631. package/backend/dist/surfaces/gateway-chat.js +204 -0
  632. package/backend/dist/surfaces/ocr-headers.d.ts +25 -4
  633. package/backend/dist/surfaces/ocr-headers.js +52 -6
  634. package/backend/dist/surfaces/rate-limit-response.d.ts +17 -0
  635. package/backend/dist/surfaces/rate-limit-response.js +57 -0
  636. package/backend/dist/surfaces/responses.d.ts +9 -1
  637. package/backend/dist/surfaces/responses.js +141 -141
  638. package/backend/dist/surfaces/systemone-probe.js +1 -1
  639. package/backend/dist/surfaces/systemone.d.ts +1 -1
  640. package/backend/dist/surfaces/systemone.js +1 -1
  641. package/backend/dist/surfaces/table.d.ts +15 -0
  642. package/backend/dist/surfaces/table.js +15 -0
  643. package/backend/dist/surfaces/transport-backpressure.d.ts +46 -0
  644. package/backend/dist/surfaces/transport-backpressure.js +122 -0
  645. package/backend/dist/surfaces/transport-fastify.js +92 -21
  646. package/backend/dist/surfaces/transport-node-http.js +92 -18
  647. package/backend/dist/surfaces/types.d.ts +85 -12
  648. package/backend/dist/trace/persist.d.ts +5 -0
  649. package/backend/dist/trace/persist.js +185 -24
  650. package/backend/dist/trace/tracker.d.ts +185 -17
  651. package/backend/dist/trace/tracker.js +106 -31
  652. package/backend/dist/translation/index.d.ts +151 -0
  653. package/backend/dist/translation/index.js +735 -0
  654. package/backend/dist/types/openai.d.ts +82 -1
  655. package/backend/dist/types/router.d.ts +104 -17
  656. package/backend/dist/types/router.js +68 -7
  657. package/backend/dist/update/check.d.ts +43 -0
  658. package/backend/dist/update/check.js +126 -0
  659. package/backend/dist/utils/chat-sse.d.ts +2 -22
  660. package/backend/dist/utils/chat-sse.js +1 -69
  661. package/backend/dist/utils/chat-stream.d.ts +23 -9
  662. package/backend/dist/utils/chat-stream.js +46 -9
  663. package/backend/dist/utils/client-envelope.d.ts +108 -0
  664. package/backend/dist/utils/client-envelope.js +305 -0
  665. package/backend/dist/utils/event-ring.d.ts +12 -1
  666. package/backend/dist/utils/event-ring.js +17 -5
  667. package/backend/dist/utils/harness-profiles.d.ts +51 -0
  668. package/backend/dist/utils/harness-profiles.js +70 -0
  669. package/backend/dist/utils/percentile.d.ts +16 -0
  670. package/backend/dist/utils/percentile.js +29 -0
  671. package/backend/dist/utils/popularity.d.ts +4 -0
  672. package/backend/dist/utils/popularity.js +58 -0
  673. package/backend/dist/utils/probe-interval.d.ts +12 -0
  674. package/backend/dist/utils/probe-interval.js +16 -0
  675. package/backend/dist/utils/proxy-node.d.ts +13 -0
  676. package/backend/dist/utils/proxy-node.js +471 -0
  677. package/backend/dist/utils/proxy.d.ts +19 -0
  678. package/backend/dist/utils/proxy.js +79 -14
  679. package/backend/dist/utils/retry-after.d.ts +21 -0
  680. package/backend/dist/utils/retry-after.js +36 -0
  681. package/backend/dist/utils/run-command.d.ts +42 -0
  682. package/backend/dist/utils/run-command.js +93 -0
  683. package/backend/dist/utils/self-url.d.ts +13 -0
  684. package/backend/dist/utils/self-url.js +90 -2
  685. package/backend/dist/utils/semver.d.ts +22 -0
  686. package/backend/dist/utils/semver.js +75 -0
  687. package/backend/dist/utils/stream-relay.d.ts +35 -0
  688. package/backend/dist/utils/stream-relay.js +1 -0
  689. package/backend/dist/utils/upstream-url-guard.d.ts +15 -0
  690. package/backend/dist/utils/upstream-url-guard.js +107 -0
  691. package/backend/dist/validator/parser.d.ts +2 -5
  692. package/backend/dist/validator/parser.js +12 -16
  693. package/backend/dist/validator/schema-assertion.d.ts +3 -2
  694. package/backend/dist/validator/schema-assertion.js +53 -8
  695. package/bin/ocr.js +2 -2
  696. package/frontend/dist/assets/index-Cn3QMOQx.js +1487 -0
  697. package/frontend/dist/assets/index-DxZ9MHKB.css +1 -0
  698. package/frontend/dist/assets/qoder.color-tVX5GCcD.svg +5 -0
  699. package/frontend/dist/index.html +2 -2
  700. package/frontend/dist/provider-logos/302ai.svg +7 -0
  701. package/frontend/dist/provider-logos/NOTICE.txt +39 -0
  702. package/frontend/dist/provider-logos/abacus.svg +14 -0
  703. package/frontend/dist/provider-logos/abliteration-ai.svg +6 -0
  704. package/frontend/dist/provider-logos/above.svg +3 -0
  705. package/frontend/dist/provider-logos/agentrouter.svg +4 -0
  706. package/frontend/dist/provider-logos/agnes.svg +1 -0
  707. package/frontend/dist/provider-logos/ai-router.svg +5 -0
  708. package/frontend/dist/provider-logos/ai21.svg +3 -0
  709. package/frontend/dist/provider-logos/aiand.svg +4 -0
  710. package/frontend/dist/provider-logos/aihubmix.svg +3 -0
  711. package/frontend/dist/provider-logos/aimlapi.svg +3 -0
  712. package/frontend/dist/provider-logos/ainetcafe.svg +1 -0
  713. package/frontend/dist/provider-logos/aixy.svg +4 -0
  714. package/frontend/dist/provider-logos/aki-io.svg +8 -0
  715. package/frontend/dist/provider-logos/alibaba-cn.svg +3 -0
  716. package/frontend/dist/provider-logos/alibaba-coding-plan-cn.svg +3 -0
  717. package/frontend/dist/provider-logos/alibaba-coding-plan.svg +3 -0
  718. package/frontend/dist/provider-logos/alibaba-token-plan-cn.svg +1 -0
  719. package/frontend/dist/provider-logos/alibaba-token-plan.svg +1 -0
  720. package/frontend/dist/provider-logos/alibaba.svg +3 -0
  721. package/frontend/dist/provider-logos/amazon-bedrock.svg +3 -0
  722. package/frontend/dist/provider-logos/ambient.svg +3 -0
  723. package/frontend/dist/provider-logos/amd.svg +3 -0
  724. package/frontend/dist/provider-logos/anthropic.svg +3 -0
  725. package/frontend/dist/provider-logos/anyapi.svg +3 -0
  726. package/frontend/dist/provider-logos/arcee.svg +3 -0
  727. package/frontend/dist/provider-logos/atomic-chat.svg +1 -0
  728. package/frontend/dist/provider-logos/auriko.svg +6 -0
  729. package/frontend/dist/provider-logos/azure-cognitive-services.svg +3 -0
  730. package/frontend/dist/provider-logos/azure.svg +3 -0
  731. package/frontend/dist/provider-logos/bailing.svg +3 -0
  732. package/frontend/dist/provider-logos/baseten.svg +3 -0
  733. package/frontend/dist/provider-logos/bee.svg +1 -0
  734. package/frontend/dist/provider-logos/berget.svg +3 -0
  735. package/frontend/dist/provider-logos/blueclaw.svg +3 -0
  736. package/frontend/dist/provider-logos/bothub.svg +33 -0
  737. package/frontend/dist/provider-logos/boundless.svg +12 -0
  738. package/frontend/dist/provider-logos/cerebras.svg +4 -0
  739. package/frontend/dist/provider-logos/chutes.svg +24 -0
  740. package/frontend/dist/provider-logos/clarifai.svg +3 -0
  741. package/frontend/dist/provider-logos/claudinio.svg +19 -0
  742. package/frontend/dist/provider-logos/cline-pass.svg +24 -0
  743. package/frontend/dist/provider-logos/cloudferro-sherlock.svg +5 -0
  744. package/frontend/dist/provider-logos/cloudflare-ai-gateway.svg +4 -0
  745. package/frontend/dist/provider-logos/cloudflare-workers-ai.svg +4 -0
  746. package/frontend/dist/provider-logos/cohere.svg +5 -0
  747. package/frontend/dist/provider-logos/commandcode.svg +11 -0
  748. package/frontend/dist/provider-logos/coralbricks.svg +6 -0
  749. package/frontend/dist/provider-logos/cortecs.svg +24 -0
  750. package/frontend/dist/provider-logos/crossmodel.svg +5 -0
  751. package/frontend/dist/provider-logos/crusoe.svg +23 -0
  752. package/frontend/dist/provider-logos/daoxe.svg +3 -0
  753. package/frontend/dist/provider-logos/databricks.svg +3 -0
  754. package/frontend/dist/provider-logos/deepinfra.svg +4 -0
  755. package/frontend/dist/provider-logos/deepseek.svg +3 -0
  756. package/frontend/dist/provider-logos/digitalocean.svg +6 -0
  757. package/frontend/dist/provider-logos/dinference.svg +1 -0
  758. package/frontend/dist/provider-logos/drun.svg +8 -0
  759. package/frontend/dist/provider-logos/ebcloud.svg +8 -0
  760. package/frontend/dist/provider-logos/echo.svg +7 -0
  761. package/frontend/dist/provider-logos/edenai.svg +8 -0
  762. package/frontend/dist/provider-logos/empiriolabs.svg +1 -0
  763. package/frontend/dist/provider-logos/engy.svg +1 -0
  764. package/frontend/dist/provider-logos/evroc.svg +3 -0
  765. package/frontend/dist/provider-logos/fastrouter.svg +3 -0
  766. package/frontend/dist/provider-logos/fireworks-ai.svg +3 -0
  767. package/frontend/dist/provider-logos/freemodel.svg +3 -0
  768. package/frontend/dist/provider-logos/friendli.svg +3 -0
  769. package/frontend/dist/provider-logos/frogbot.svg +36 -0
  770. package/frontend/dist/provider-logos/github-copilot.svg +3 -0
  771. package/frontend/dist/provider-logos/gitlab.svg +3 -0
  772. package/frontend/dist/provider-logos/gmicloud.svg +24 -0
  773. package/frontend/dist/provider-logos/google-vertex-anthropic.svg +10 -0
  774. package/frontend/dist/provider-logos/google-vertex.svg +10 -0
  775. package/frontend/dist/provider-logos/google.svg +3 -0
  776. package/frontend/dist/provider-logos/greenpt.svg +6 -0
  777. package/frontend/dist/provider-logos/groq.svg +3 -0
  778. package/frontend/dist/provider-logos/helicone.svg +6 -0
  779. package/frontend/dist/provider-logos/hetzner.svg +3 -0
  780. package/frontend/dist/provider-logos/hopper.svg +4 -0
  781. package/frontend/dist/provider-logos/hpc-ai.svg +446 -0
  782. package/frontend/dist/provider-logos/huggingface.svg +3 -0
  783. package/frontend/dist/provider-logos/hyper.svg +20 -0
  784. package/frontend/dist/provider-logos/impossibl.svg +3 -0
  785. package/frontend/dist/provider-logos/inception.svg +14 -0
  786. package/frontend/dist/provider-logos/inceptron.svg +14 -0
  787. package/frontend/dist/provider-logos/inco.svg +3 -0
  788. package/frontend/dist/provider-logos/infer.svg +4 -0
  789. package/frontend/dist/provider-logos/inference.svg +3 -0
  790. package/frontend/dist/provider-logos/inferx.svg +5 -0
  791. package/frontend/dist/provider-logos/infomaniak.svg +3 -0
  792. package/frontend/dist/provider-logos/io-net.svg +5 -0
  793. package/frontend/dist/provider-logos/iteracompute.svg +7 -0
  794. package/frontend/dist/provider-logos/jalapeno.svg +8 -0
  795. package/frontend/dist/provider-logos/jiekou.svg +4 -0
  796. package/frontend/dist/provider-logos/kenari.svg +4 -0
  797. package/frontend/dist/provider-logos/kilo.svg +4 -0
  798. package/frontend/dist/provider-logos/kimi-code-plan-cn.svg +3 -0
  799. package/frontend/dist/provider-logos/kimi-code-plan-global.svg +3 -0
  800. package/frontend/dist/provider-logos/klokintegration.svg +11 -0
  801. package/frontend/dist/provider-logos/kosmik.svg +28 -0
  802. package/frontend/dist/provider-logos/kuae-cloud-coding-plan.svg +3 -0
  803. package/frontend/dist/provider-logos/lilac.svg +6 -0
  804. package/frontend/dist/provider-logos/liquid.svg +1 -0
  805. package/frontend/dist/provider-logos/llmgateway-providers.svg +6 -0
  806. package/frontend/dist/provider-logos/llmgateway.svg +6 -0
  807. package/frontend/dist/provider-logos/llmtech.svg +6 -0
  808. package/frontend/dist/provider-logos/llmtr.svg +12 -0
  809. package/frontend/dist/provider-logos/lmstudio.svg +3 -0
  810. package/frontend/dist/provider-logos/longcat.svg +6 -0
  811. package/frontend/dist/provider-logos/lowrouter.svg +8 -0
  812. package/frontend/dist/provider-logos/lucidquery.svg +3 -0
  813. package/frontend/dist/provider-logos/lynkr.svg +1 -0
  814. package/frontend/dist/provider-logos/meganova.svg +3 -0
  815. package/frontend/dist/provider-logos/melious.svg +3 -0
  816. package/frontend/dist/provider-logos/merge-gateway.svg +4 -0
  817. package/frontend/dist/provider-logos/meta.svg +3 -0
  818. package/frontend/dist/provider-logos/minimax-cn-coding-plan.svg +3 -0
  819. package/frontend/dist/provider-logos/minimax-cn.svg +3 -0
  820. package/frontend/dist/provider-logos/minimax-coding-plan.svg +3 -0
  821. package/frontend/dist/provider-logos/minimax.svg +3 -0
  822. package/frontend/dist/provider-logos/mistral.svg +3 -0
  823. package/frontend/dist/provider-logos/mixlayer.svg +9 -0
  824. package/frontend/dist/provider-logos/moark.svg +3 -0
  825. package/frontend/dist/provider-logos/modal.svg +3 -0
  826. package/frontend/dist/provider-logos/model-oracle-ai.svg +11 -0
  827. package/frontend/dist/provider-logos/modelis.svg +1 -0
  828. package/frontend/dist/provider-logos/modelscope.svg +5 -0
  829. package/frontend/dist/provider-logos/modular.svg +3 -0
  830. package/frontend/dist/provider-logos/moonshotai-cn.svg +3 -0
  831. package/frontend/dist/provider-logos/moonshotai.svg +3 -0
  832. package/frontend/dist/provider-logos/morph.svg +24 -0
  833. package/frontend/dist/provider-logos/munito-eu.svg +1 -0
  834. package/frontend/dist/provider-logos/munito.svg +1 -0
  835. package/frontend/dist/provider-logos/nan.svg +1 -0
  836. package/frontend/dist/provider-logos/nano-gpt.svg +3 -0
  837. package/frontend/dist/provider-logos/nearai.svg +1 -0
  838. package/frontend/dist/provider-logos/nebius.svg +4 -0
  839. package/frontend/dist/provider-logos/neon.svg +3 -0
  840. package/frontend/dist/provider-logos/neosmith.svg +6 -0
  841. package/frontend/dist/provider-logos/neuralwatt.svg +27 -0
  842. package/frontend/dist/provider-logos/nova.svg +3 -0
  843. package/frontend/dist/provider-logos/novita-ai.svg +10 -0
  844. package/frontend/dist/provider-logos/nvidia.svg +3 -0
  845. package/frontend/dist/provider-logos/oci.svg +3 -0
  846. package/frontend/dist/provider-logos/ofox.svg +5 -0
  847. package/frontend/dist/provider-logos/ollama-cloud.svg +7 -0
  848. package/frontend/dist/provider-logos/openai.svg +3 -0
  849. package/frontend/dist/provider-logos/opencode-go.svg +4 -0
  850. package/frontend/dist/provider-logos/opencode.svg +4 -0
  851. package/frontend/dist/provider-logos/openreason.svg +8 -0
  852. package/frontend/dist/provider-logos/openrouter.svg +5 -0
  853. package/frontend/dist/provider-logos/opper.svg +3 -0
  854. package/frontend/dist/provider-logos/orcarouter.svg +2 -0
  855. package/frontend/dist/provider-logos/ovhcloud.svg +3 -0
  856. package/frontend/dist/provider-logos/pareto.svg +5 -0
  857. package/frontend/dist/provider-logos/pendra.svg +10 -0
  858. package/frontend/dist/provider-logos/perplexity-agent.svg +3 -0
  859. package/frontend/dist/provider-logos/perplexity.svg +3 -0
  860. package/frontend/dist/provider-logos/pioneer.svg +3 -0
  861. package/frontend/dist/provider-logos/poe.svg +7 -0
  862. package/frontend/dist/provider-logos/poolside.svg +3 -0
  863. package/frontend/dist/provider-logos/prime.svg +7 -0
  864. package/frontend/dist/provider-logos/privatemode-ai.svg +5 -0
  865. package/frontend/dist/provider-logos/qihang-ai.svg +9 -0
  866. package/frontend/dist/provider-logos/qiniu-ai.svg +7 -0
  867. package/frontend/dist/provider-logos/qvac.svg +6 -0
  868. package/frontend/dist/provider-logos/reflection.svg +3 -0
  869. package/frontend/dist/provider-logos/regolo-ai.svg +46 -0
  870. package/frontend/dist/provider-logos/requesty.svg +24 -0
  871. package/frontend/dist/provider-logos/routing-run.svg +4 -0
  872. package/frontend/dist/provider-logos/runinfra.svg +10 -0
  873. package/frontend/dist/provider-logos/sakana.svg +24 -0
  874. package/frontend/dist/provider-logos/salad-cloud.svg +15 -0
  875. package/frontend/dist/provider-logos/sambanova.svg +26 -0
  876. package/frontend/dist/provider-logos/sap-ai-core.svg +24 -0
  877. package/frontend/dist/provider-logos/sarvam.svg +24 -0
  878. package/frontend/dist/provider-logos/scaleway.svg +5 -0
  879. package/frontend/dist/provider-logos/scnet-token-plan.svg +8 -0
  880. package/frontend/dist/provider-logos/scx-ai.svg +1 -0
  881. package/frontend/dist/provider-logos/sensenova.svg +18 -0
  882. package/frontend/dist/provider-logos/siliconflow-cn.svg +3 -0
  883. package/frontend/dist/provider-logos/siliconflow.svg +3 -0
  884. package/frontend/dist/provider-logos/snowflake-cortex.svg +3 -0
  885. package/frontend/dist/provider-logos/stackit.svg +4 -0
  886. package/frontend/dist/provider-logos/standardcompute.svg +5 -0
  887. package/frontend/dist/provider-logos/stepfun-ai-step-plan.svg +16 -0
  888. package/frontend/dist/provider-logos/stepfun-ai.svg +16 -0
  889. package/frontend/dist/provider-logos/stepfun-step-plan.svg +16 -0
  890. package/frontend/dist/provider-logos/stepfun.svg +16 -0
  891. package/frontend/dist/provider-logos/subconscious.svg +3 -0
  892. package/frontend/dist/provider-logos/submodel.svg +3 -0
  893. package/frontend/dist/provider-logos/synthetic.svg +24 -0
  894. package/frontend/dist/provider-logos/tempr.svg +4 -0
  895. package/frontend/dist/provider-logos/tencent-coding-plan.svg +5 -0
  896. package/frontend/dist/provider-logos/tencent-token-plan.svg +3 -0
  897. package/frontend/dist/provider-logos/tencent-tokenhub.svg +3 -0
  898. package/frontend/dist/provider-logos/tensorx.svg +6 -0
  899. package/frontend/dist/provider-logos/the-grid-ai.svg +14 -0
  900. package/frontend/dist/provider-logos/thinkingmachines.svg +3 -0
  901. package/frontend/dist/provider-logos/tinfoil.svg +3 -0
  902. package/frontend/dist/provider-logos/togetherai.svg +4 -0
  903. package/frontend/dist/provider-logos/tokengo.svg +3 -0
  904. package/frontend/dist/provider-logos/tokenrouter.svg +4 -0
  905. package/frontend/dist/provider-logos/trustedrouter.svg +4 -0
  906. package/frontend/dist/provider-logos/umans-ai-coding-plan.svg +29 -0
  907. package/frontend/dist/provider-logos/umans-ai.svg +29 -0
  908. package/frontend/dist/provider-logos/unorouter.svg +7 -0
  909. package/frontend/dist/provider-logos/upstage.svg +24 -0
  910. package/frontend/dist/provider-logos/vancine.svg +6 -0
  911. package/frontend/dist/provider-logos/venice.svg +4 -0
  912. package/frontend/dist/provider-logos/vercel.svg +3 -0
  913. package/frontend/dist/provider-logos/vispark.svg +3 -0
  914. package/frontend/dist/provider-logos/vivgrid.svg +4 -0
  915. package/frontend/dist/provider-logos/volcengine-coding-plan.svg +1 -0
  916. package/frontend/dist/provider-logos/volcengine.svg +1 -0
  917. package/frontend/dist/provider-logos/vultr.svg +6 -0
  918. package/frontend/dist/provider-logos/wafer.ai.svg +3 -0
  919. package/frontend/dist/provider-logos/wallaby.svg +4 -0
  920. package/frontend/dist/provider-logos/wally.svg +1 -0
  921. package/frontend/dist/provider-logos/wandb.svg +6 -0
  922. package/frontend/dist/provider-logos/watsonx.svg +5 -0
  923. package/frontend/dist/provider-logos/xai.svg +3 -0
  924. package/frontend/dist/provider-logos/xiaomi-token-plan-ams.svg +3 -0
  925. package/frontend/dist/provider-logos/xiaomi-token-plan-cn.svg +3 -0
  926. package/frontend/dist/provider-logos/xiaomi-token-plan-sgp.svg +3 -0
  927. package/frontend/dist/provider-logos/xiaomi.svg +3 -0
  928. package/frontend/dist/provider-logos/xpersona.svg +8 -0
  929. package/frontend/dist/provider-logos/zai-coding-plan.svg +3 -0
  930. package/frontend/dist/provider-logos/zai.svg +3 -0
  931. package/frontend/dist/provider-logos/zeldoc.svg +3 -0
  932. package/frontend/dist/provider-logos/zenifra.svg +4 -0
  933. package/frontend/dist/provider-logos/zenmux.svg +4 -0
  934. package/frontend/dist/provider-logos/zhipuai-coding-plan.svg +3 -0
  935. package/frontend/dist/provider-logos/zhipuai.svg +3 -0
  936. package/package.json +13 -5
  937. package/backend/dist/budget/budget-manager.d.ts +0 -25
  938. package/backend/dist/budget/budget-manager.js +0 -54
  939. package/backend/dist/config/governance-limits.d.ts +0 -68
  940. package/backend/dist/config/governance-limits.js +0 -261
  941. package/backend/dist/flywheel/collector.d.ts +0 -74
  942. package/backend/dist/flywheel/collector.js +0 -235
  943. package/backend/dist/flywheel/dataset.d.ts +0 -130
  944. package/backend/dist/flywheel/dataset.js +0 -638
  945. package/backend/dist/flywheel/decision-capture.d.ts +0 -68
  946. package/backend/dist/flywheel/decision-capture.js +0 -85
  947. package/backend/dist/flywheel/prune.d.ts +0 -133
  948. package/backend/dist/flywheel/prune.js +0 -495
  949. package/backend/dist/flywheel/schema.d.ts +0 -108
  950. package/backend/dist/flywheel/schema.js +0 -117
  951. package/backend/dist/flywheel/trainer.d.ts +0 -84
  952. package/backend/dist/flywheel/trainer.js +0 -198
  953. package/backend/dist/forward-proxy/bypass.d.ts +0 -20
  954. package/backend/dist/forward-proxy/bypass.js +0 -28
  955. package/backend/dist/harness/adapters/amp.d.ts +0 -2
  956. package/backend/dist/harness/adapters/amp.js +0 -8
  957. package/backend/dist/harness/adapters/claude.d.ts +0 -2
  958. package/backend/dist/harness/adapters/claude.js +0 -8
  959. package/backend/dist/harness/adapters/cline.d.ts +0 -2
  960. package/backend/dist/harness/adapters/cline.js +0 -8
  961. package/backend/dist/harness/adapters/codex.d.ts +0 -2
  962. package/backend/dist/harness/adapters/codex.js +0 -8
  963. package/backend/dist/harness/adapters/cursor.d.ts +0 -5
  964. package/backend/dist/harness/adapters/cursor.js +0 -11
  965. package/backend/dist/harness/adapters/declarative.d.ts +0 -64
  966. package/backend/dist/harness/adapters/declarative.js +0 -216
  967. package/backend/dist/harness/adapters/dsh.d.ts +0 -5
  968. package/backend/dist/harness/adapters/dsh.js +0 -6
  969. package/backend/dist/harness/adapters/gemini-cli.d.ts +0 -2
  970. package/backend/dist/harness/adapters/gemini-cli.js +0 -8
  971. package/backend/dist/harness/adapters/github-copilot.d.ts +0 -5
  972. package/backend/dist/harness/adapters/github-copilot.js +0 -11
  973. package/backend/dist/harness/adapters/omp.d.ts +0 -11
  974. package/backend/dist/harness/adapters/omp.js +0 -22
  975. package/backend/dist/harness/adapters/opencode.d.ts +0 -2
  976. package/backend/dist/harness/adapters/opencode.js +0 -56
  977. package/backend/dist/harness/adapters/pi.d.ts +0 -1
  978. package/backend/dist/harness/adapters/pi.js +0 -23
  979. package/backend/dist/harness/adapters/types.d.ts +0 -189
  980. package/backend/dist/harness/adapters/types.js +0 -12
  981. package/backend/dist/harness/adapters/universal.d.ts +0 -6
  982. package/backend/dist/harness/adapters/universal.js +0 -10
  983. package/backend/dist/harness/adapters/windsurf.d.ts +0 -2
  984. package/backend/dist/harness/adapters/windsurf.js +0 -11
  985. package/backend/dist/harness/adapters/zed.d.ts +0 -2
  986. package/backend/dist/harness/adapters/zed.js +0 -8
  987. package/backend/dist/harness/awesome-opencode.d.ts +0 -40
  988. package/backend/dist/harness/awesome-opencode.js +0 -75
  989. package/backend/dist/harness/browse.d.ts +0 -202
  990. package/backend/dist/harness/browse.js +0 -1214
  991. package/backend/dist/harness/inventory.d.ts +0 -10
  992. package/backend/dist/harness/opencode-cafe.d.ts +0 -40
  993. package/backend/dist/harness/opencode-cafe.js +0 -85
  994. package/backend/dist/harness/opencode-ecosystem.d.ts +0 -34
  995. package/backend/dist/harness/opencode-ecosystem.js +0 -246
  996. package/backend/dist/harness/pi-dev.d.ts +0 -81
  997. package/backend/dist/harness/pi-dev.js +0 -187
  998. package/backend/dist/harness/registry.js +0 -26
  999. package/backend/dist/harness/scopes.d.ts +0 -21
  1000. package/backend/dist/harness/scopes.js +0 -22
  1001. package/backend/dist/harness/skills-sh.d.ts +0 -109
  1002. package/backend/dist/harness/skills-sh.js +0 -178
  1003. package/backend/dist/harness/smithery.d.ts +0 -64
  1004. package/backend/dist/harness/smithery.js +0 -146
  1005. package/backend/dist/harness/sources/awesome-opencode.d.ts +0 -11
  1006. package/backend/dist/harness/sources/awesome-opencode.js +0 -39
  1007. package/backend/dist/harness/sources/mcp-official.d.ts +0 -2
  1008. package/backend/dist/harness/sources/mcp-official.js +0 -110
  1009. package/backend/dist/harness/sources/npm.d.ts +0 -2
  1010. package/backend/dist/harness/sources/opencode-cafe.d.ts +0 -11
  1011. package/backend/dist/harness/sources/opencode-cafe.js +0 -41
  1012. package/backend/dist/harness/sources/smithery.d.ts +0 -2
  1013. package/backend/dist/harness/sources/smithery.js +0 -81
  1014. package/backend/dist/harness/writers/extension.d.ts +0 -116
  1015. package/backend/dist/harness/writers/extension.js +0 -219
  1016. package/backend/dist/harness/writers/mcp.d.ts +0 -72
  1017. package/backend/dist/harness/writers/mcp.js +0 -195
  1018. package/backend/dist/opencode/catalog/custom-store.d.ts +0 -50
  1019. package/backend/dist/opencode/catalog/custom-store.js +0 -144
  1020. package/backend/dist/opencode/credentials/push.d.ts +0 -38
  1021. package/backend/dist/opencode/credentials/push.js +0 -116
  1022. package/backend/dist/opencode/credentials/reconcile.d.ts +0 -49
  1023. package/backend/dist/opencode/credentials/reconcile.js +0 -216
  1024. package/backend/dist/opencode/sync.d.ts +0 -29
  1025. package/backend/dist/opencode/sync.js +0 -186
  1026. package/backend/dist/pipeline/account-selection.d.ts +0 -101
  1027. package/backend/dist/pipeline/account-selection.js +0 -112
  1028. package/backend/dist/providers/systemone.d.ts +0 -29
  1029. package/backend/dist/providers/systemone.js +0 -170
  1030. package/backend/dist/ratelimit/duration.d.ts +0 -24
  1031. package/backend/dist/ratelimit/duration.js +0 -43
  1032. package/backend/dist/ratelimit/governance-runtime.d.ts +0 -121
  1033. package/backend/dist/ratelimit/governance-runtime.js +0 -183
  1034. package/backend/dist/ratelimit/index.d.ts +0 -4
  1035. package/backend/dist/ratelimit/index.js +0 -4
  1036. package/backend/dist/ratelimit/limiter.d.ts +0 -157
  1037. package/backend/dist/ratelimit/limiter.js +0 -244
  1038. package/backend/dist/ratelimit/sliding-window-counter.d.ts +0 -63
  1039. package/backend/dist/ratelimit/sliding-window-counter.js +0 -103
  1040. package/backend/dist/ratelimit/subject.d.ts +0 -26
  1041. package/backend/dist/ratelimit/subject.js +0 -28
  1042. package/backend/dist/resilience/account-state.d.ts +0 -84
  1043. package/backend/dist/resilience/account-state.js +0 -228
  1044. package/backend/dist/router/layer1-classifier.d.ts +0 -111
  1045. package/backend/dist/router/layer1-classifier.js +0 -467
  1046. package/backend/dist/router/layer2-judge.d.ts +0 -111
  1047. package/backend/dist/router/layer2-judge.js +0 -373
  1048. package/backend/dist/router/retry-escalation.d.ts +0 -89
  1049. package/backend/dist/router/retry-escalation.js +0 -99
  1050. package/backend/dist/routes/flywheel.d.ts +0 -3
  1051. package/backend/dist/routes/flywheel.js +0 -268
  1052. package/backend/dist/routes/systemone.d.ts +0 -3
  1053. package/backend/dist/routes/systemone.js +0 -90
  1054. package/backend/dist/surfaces/governance-envelope.d.ts +0 -34
  1055. package/backend/dist/surfaces/governance-envelope.js +0 -47
  1056. package/backend/dist/utils/token-estimator.d.ts +0 -7
  1057. package/backend/dist/utils/token-estimator.js +0 -20
  1058. package/frontend/dist/assets/index-B7GKsUyU.js +0 -982
  1059. package/frontend/dist/assets/index-DLKLOkQJ.css +0 -1
  1060. package/frontend/dist/assets/inter-cyrillic-800-normal-C7MGvYyJ.woff2 +0 -0
  1061. package/frontend/dist/assets/inter-cyrillic-800-normal-CCHyn08d.woff +0 -0
  1062. package/frontend/dist/assets/inter-cyrillic-ext-800-normal-BZOjs1Xv.woff2 +0 -0
  1063. package/frontend/dist/assets/inter-cyrillic-ext-800-normal-Ca-gJeZY.woff +0 -0
  1064. package/frontend/dist/assets/inter-greek-800-normal-BU00tryP.woff +0 -0
  1065. package/frontend/dist/assets/inter-greek-800-normal-CLIouy3y.woff2 +0 -0
  1066. package/frontend/dist/assets/inter-greek-ext-800-normal-B--PVpEC.woff2 +0 -0
  1067. package/frontend/dist/assets/inter-greek-ext-800-normal-DUe57HfS.woff +0 -0
  1068. package/frontend/dist/assets/inter-latin-800-normal-BYj_oED-.woff2 +0 -0
  1069. package/frontend/dist/assets/inter-latin-800-normal-D1mf63XC.woff +0 -0
  1070. package/frontend/dist/assets/inter-latin-ext-800-normal-BOMpwxm3.woff +0 -0
  1071. package/frontend/dist/assets/inter-latin-ext-800-normal-DZJjya6U.woff2 +0 -0
  1072. package/frontend/dist/assets/inter-vietnamese-800-normal-Cm7tD1pz.woff2 +0 -0
  1073. package/frontend/dist/assets/inter-vietnamese-800-normal-DDlpr_Ee.woff +0 -0
  1074. /package/backend/dist/harness/{adapters → host/adapters}/skills-paths.d.ts +0 -0
  1075. /package/backend/dist/harness/{adapters → host/adapters}/skills-paths.js +0 -0
  1076. /package/backend/dist/harness/{skill-md.d.ts → skill/skill-md.d.ts} +0 -0
  1077. /package/backend/dist/harness/{skill-md.js → skill/skill-md.js} +0 -0
@@ -1,253 +1,586 @@
1
- import { HOSTS } from '../harness/hosts.js';
2
- import { adapterFor, hostDetected, isExtensionHost, isMcpHost, isSkillsHost, skillOwner, skillRootsFor, } from '../harness/adapters/index.js';
3
- import { scanInventory } from '../harness/inventory.js';
4
- import { claimsPath, manifestPath } from '../harness/manifest.js';
5
- import { applyRemove, planRemove } from '../harness/maintenance.js';
6
- import { pruneTranslationStore, probeTranslationChain, readCachedTranslations, translateDescription, translateMarkdown, } from '../harness/translation.js';
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { getProject } from '../projects/store.js';
4
+ import { HOSTS } from '../harness/host/hosts.js';
5
+ import { popularityRank } from '../utils/popularity.js';
6
+ import { adapterFor, hostDetected, isPluginHost, isMcpHost, isSkillsHost, mcpHostIds, skillOwner, skillRootsFor, } from '../harness/host/adapters/index.js';
7
+ import { scanInventory } from '../harness/host/inventory.js';
8
+ import { claimsPath, manifestPath } from '../harness/host/manifest.js';
9
+ import { applyRemove, planRemove } from '../harness/host/maintenance.js';
10
+ import { isSupportedLang } from '../translation/index.js';
7
11
  import { probeSystemoneDefault } from '../surfaces/systemone-probe.js';
8
- import { browseSource } from '../harness/browse.js';
9
- import { fetchRepoStars, peekStarCache } from '../harness/stars.js';
12
+ import { browseSource } from '../harness/common/market.js';
13
+ import { allHostProbes, createPluginAdapter, probeOptionsFor } from '../harness/plugin/adapters/index.js';
14
+ import { appendInstallLog, finishInstallLog, readInstallLog, startInstallLog } from '../harness/host/install-log.js';
15
+ import { fetchRepoStars, peekStarCache } from '../harness/common/stars.js';
10
16
  import { readMarketDetail } from '../harness/detail.js';
11
- import { installArtifact } from '../harness/install.js';
12
- import { recentApplies } from '../harness/ledger.js';
13
- import { ENABLED_SCOPES, isEnabledScope } from '../harness/scopes.js';
17
+ import { installArtifact } from '../harness/host/install.js';
18
+ import { editMcpServer, readMcpEntry } from '../harness/host/mcp-edit.js';
19
+ import { callMcpTool, disconnectMcpSession, getMcpPrompt, inspectMcpServer, readMcpResource, } from '../harness/host/mcp-inspector.js';
20
+ import { searchMcpRegistry } from '../harness/host/mcp-registry.js';
21
+ import { probeMcpCli } from '../harness/host/mcp-cli.js';
22
+ import { probeMcpRuntimes } from '../harness/host/mcp-runtime.js';
23
+ import { isProbeHost, probeTcp } from '../harness/tcp-reach.js';
24
+ import { mcpServerNameFromPackage } from '../harness/host/mcp-entry.js';
25
+ import { dbEngineFor, probeDatabase } from '../harness/db-probe.js';
26
+ import { recentApplies } from '../harness/host/ledger.js';
27
+ import { ENABLED_SCOPES, isEnabledScope } from '../harness/host/scopes.js';
28
+ import { MCP_DEFAULT_VIEWS, SKILL_VIEWS, SOURCES } from '../harness/common/source-views.js';
29
+ import { checkSkillSource, registerSkillSource, removeSkillSource, rescanSkillSource, skillSourceEntry, updateSkillSource, } from '../harness/skill/sources.js';
30
+ import { harvestAll } from '../harness/plugin/catalog.js';
31
+ import { browseMarketplace, getMarketplaceEntry, listMarketplaceEntries, latestSnapshot, marketplaceSourceId, probeMarketplace, snapshotHistory, updateMarketplaceEntry, writeMcpSourceSnapshot, writeNpmSourceSnapshot, } from '../harness/common/market.js';
32
+ import { parseNpmSource, probeNpmSource } from '../harness/common/npm-source.js';
33
+ import { parsePypiSource, probePypiSource } from '../harness/common/pypi-source.js';
34
+ import { getBuiltinViewsForHarness } from '../harness/plugin/builtin.js';
35
+ import { reconcileMarketplaces } from '../harness/host/marketplace-sync.js';
36
+ /**
37
+ * Resolve the project attribution one harness request claims.
38
+ *
39
+ * `projectRoot`/`projectId` arrive from the console and become the base a writer lands in or a scan
40
+ * reads; an unvalidated string would let a request aim either at any directory on the machine.
41
+ * A `projectId` is looked up in the registry (a stale id is an ERROR, never a silent global read),
42
+ * and a raw root must name an existing directory — the same rule install already enforced.
43
+ */
44
+ function resolveProjectRoot(input, opts) {
45
+ const rawRoot = typeof input.projectRoot === 'string' ? input.projectRoot.trim() : '';
46
+ const rawId = typeof input.projectId === 'string' ? input.projectId.trim() : '';
47
+ let projectRoot;
48
+ if (rawRoot) {
49
+ projectRoot = path.resolve(rawRoot);
50
+ try {
51
+ if (!fs.statSync(projectRoot).isDirectory()) {
52
+ return { ok: false, message: `projectRoot is not a directory: ${projectRoot}` };
53
+ }
54
+ }
55
+ catch {
56
+ return { ok: false, message: `projectRoot does not exist: ${projectRoot}` };
57
+ }
58
+ }
59
+ else if (rawId) {
60
+ const proj = getProject(rawId);
61
+ if (!proj)
62
+ return { ok: false, message: `projectId '${rawId}' not found` };
63
+ projectRoot = path.resolve(proj.path);
64
+ }
65
+ if (!projectRoot && opts.required) {
66
+ return { ok: false, message: 'projectRoot is required for project scope' };
67
+ }
68
+ return { ok: true, ...(projectRoot ? { projectRoot } : {}) };
69
+ }
14
70
  /**
15
71
  * Harness admin surface (ADR-0015): sources, hosts, inventory, install, uninstall, translate.
16
72
  *
17
- * Install goes through the source SPI (adapter.resolve → kind writer). MCP/extension writers land
73
+ * Install goes through the source SPI (adapter.resolve → kind writer). MCP/plugin writers land
18
74
  * with their milestones; a request they cannot serve answers `unsupported_source`/`unsupported_kind`
19
75
  * — an endpoint that accepts a plan it cannot execute would be worse than a typed refusal.
20
76
  *
21
- * Measured accessibility, 2026-10-24: skills.sh API 401 (Vercel OIDC only), MCP official registry 200
22
- * anonymous, Smithery 200 anonymous, PulseMCP 410 (retired),
23
- * mcp.so 404, npm registry 200 anonymous. Measured 2026-10-25: `pi.dev/packages` 200 anonymous
24
- * (server-rendered HTML, no JSON API — the reader keys off the catalog's own card attributes), and
25
- * `skills.sh`'s leaderboard PAGES 200 anonymous (`/`, `/trending`, `/hot`, each shipping its 600-row
26
- * board in the RSC flight payload) and so does its own search endpoint (`/api/search`, 200 anonymous,
27
- * capped at 200 rows per query) even though its API stays closed. Measured the same day, ClawHub's
77
+ * Measured accessibility, 2026-10-24: npm registry 200
78
+ * anonymous. Measured 2026-10-25: `pi.dev/packages` 200 anonymous
79
+ * (server-rendered HTML, no JSON API — the reader keys off the catalog's own card attributes).
80
+ * Measured the same day, ClawHub's
28
81
  * public v1 API (`clawhub.ai`) answers 200 anonymous throughout — cursor-paged catalog, capped
29
82
  * whole-catalog search, and deterministic per-version ZIP downloads (3000 reads/min/IP).
30
- * The curated OpenCode catalog is
31
- * NOT a network source: it ships as a snapshot
32
- * (`harness/opencode-ecosystem.ts`), because `raw.githubusercontent.com` and `cdn.jsdelivr.net` both
33
- * reset the connection from here.
34
83
  */
35
84
  /**
36
85
  * The array order IS the console's display order and landing priority: per axis, the chip row
37
86
  * follows this sequence and the market opens on the FIRST enabled+browsable source for that axis.
38
87
  * The principle is low-noise first — within an axis, the order follows how far a row's claim
39
- * reaches: a catalog whose row IS the artifact (an official catalog, a curated snapshot, a
88
+ * reaches: a catalog whose row IS the artifact (an official catalog, a
40
89
  * leaderboard entry) outranks a search over containers that CARRY the artifact (github's
41
90
  * topic-qualified repo search — the topic is self-declared, the stars reward the repo), which
42
91
  * outranks the one source that searches an entire package registry: npm, the wide net, is LAST
43
92
  * on purpose.
44
93
  */
45
- const SOURCES = [
46
- {
47
- id: 'skills-sh',
48
- label: 'skills.sh',
49
- kinds: ['skill'],
50
- trust: 'aggregator',
51
- // `auth` describes the API (`/api/v1/skills` = 401 without a Vercel workload token), which this
52
- // console never calls. The market reads the endpoint the SITE's own browser reads, so it needs no
53
- // credential: measured 2026-10-25, `GET /api/skills/<view>/<page>` answers 200 anonymously with
54
- // 200 rows per (0-based) page, its own `total` (9 911 on All-time) and `hasMore`
55
- // (`harness/skills-sh.ts`).
56
- auth: 'oidc',
57
- enabled: true,
58
- browsable: true,
59
- // The site's three leaderboards in its own tab order. An empty query lands on the chosen board; a
60
- // query of 2+ characters goes to the site's own search endpoint (`/api/search`, anonymous, whole
61
- // catalog, capped at 200 rows). Rows install as `github:<owner/repo>#<skill-dir>` — the site's own
62
- // `npx skills add` identity.
63
- sorts: ['all-time', 'trending', 'hot'],
64
- // FIRST on the skills axis on purpose: a row here IS a skill directory, ranked by the site's
65
- // own install tally. github's topic-qualified search answers with REPOS that self-declare the
66
- // topic — a noisier unit, one repo holding any number of skills or none — and npm's
67
- // registry-wide keyword search (whose rows cannot install as skills at all) is the wide net
68
- // below that.
69
- },
70
- {
71
- id: 'clawhub',
72
- label: 'ClawHub',
73
- kinds: ['skill'],
94
+ /** One operator git-marketplace chip, materialized from the store: enabled state from the entry,
95
+ * browsable only once a probe has left a snapshot to browse. */
96
+ function mpSourceView(slug) {
97
+ const entry = getMarketplaceEntry(slug);
98
+ if (!entry)
99
+ return undefined;
100
+ const snap = latestSnapshot(slug, entry.harness);
101
+ const mcp = entry.axis === 'mcp';
102
+ const packageType = entry.type === 'npm' || entry.type === 'pypi' ? entry.type : null;
103
+ const label = mcp
104
+ ? `${slug} (${packageType === 'pypi' ? 'PyPI' : 'npm'} MCP)`
105
+ : packageType === 'npm'
106
+ ? `${slug} (npm)`
107
+ : `${slug} (git marketplace)`;
108
+ return {
109
+ catalog: entry.catalog ?? 'default',
110
+ id: marketplaceSourceId(slug),
111
+ label,
112
+ // A package entry carries packages only and serves ONE axis; a git entry may carry both kinds.
113
+ kinds: mcp ? ['mcp'] : packageType ? ['plugin'] : ['skill', 'plugin'],
74
114
  trust: 'community',
75
115
  auth: 'none',
76
- enabled: true,
77
- browsable: true,
78
- // OpenClaw's public skill registry (`clawhub.ai`), measured 2026-10-25: `GET /api/v1/skills`
79
- // pages by opaque CURSOR with its own `sort` enum, `GET /api/v1/search` covers the whole catalog
80
- // with NO paging parameter (a `totalScope: 'window'` answer, like skills.sh's search), and
81
- // `GET /api/v1/download?slug=&ownerHandle=&version=` answers deterministic ZIP bytes. Install
82
- // reads the newest published semver, downloads THAT version, and pins `{ clawhub: { slug,
83
- // version } }` — a registry-version pin, not a commit. `ownerHandle` is the disambiguator the
84
- // registry's own 409 error names; it is undocumented on the endpoints but measured working.
85
- // AFTER skills-sh, BEFORE github on the skills axis on purpose: a row here IS a skill (a slug
86
- // in a dedicated registry), while github's search answers with REPOS that self-declare the
87
- // topic and npm's registry-wide search is the wide net. Rows carry no GitHub repo, so no star
88
- // count is ever claimed for them.
89
- sorts: ['downloads', 'stars', 'updated'],
90
- },
91
- {
92
- id: 'mcp-official',
93
- label: 'MCP official registry',
94
- kinds: ['mcp'],
95
- trust: 'official',
96
- auth: 'none',
97
- enabled: true,
98
- browsable: true,
99
- // Browse reads `GET /v0/servers?limit=&search=&cursor=&version=latest` (200 anonymous, measured
100
- // 2026-10-25) and pages by opaque CURSOR, so a market page number walks a chain rather than an
101
- // offset. No `sorts`: the registry publishes no ordering parameter. Install resolves ONE record
102
- // through `/v0/servers/<name>/versions/latest` — the bare `/v0/servers/<name>` path answers 404.
103
- },
104
- {
105
- id: 'smithery',
106
- label: 'Smithery',
107
- kinds: ['mcp'],
108
- trust: 'aggregator',
109
- auth: 'none',
110
- enabled: true,
111
- browsable: true,
112
- // Browse reads `GET /servers?page=&pageSize=&q=` (200 anonymous, measured 2026-10-25). No `sorts`:
113
- // the registry publishes one order (its own usage ranking) and no parameter to change it. The
114
- // listing serves 500 rows at most while claiming ~20 765, so the market reports the REACHABLE count
115
- // and says so (`noteCode: 'smithery-window'`). Install resolves `GET /servers/<qualifiedName>` and
116
- // emits the HOSTED deployment plus an `Authorization` env reference — Smithery hosts these servers,
117
- // which is why it is the one aggregator allowed to supply a launch spec (ADR-0015 §D6).
118
- },
119
- {
120
- id: 'pi-dev',
121
- label: 'pi.dev (official)',
122
- kinds: ['extension'],
123
- trust: 'official',
124
- auth: 'none',
125
- enabled: true,
126
- browsable: true,
127
- // The official Pi package catalog (`pi.dev/packages`): extensions plus untyped Pi packages, every
128
- // row printed with its own `pi install npm:<pkg>` command. Rows therefore carry an `npm:<pkg>`
129
- // handle and install through the npm source — one package, ONE identity, and the console's
130
- // installed-state join stays exact. This source produces no payload of its own (browse-only).
131
- //
132
- // First for the extension axis on purpose: a pi page should open on its own official catalog, not
133
- // on a keyword search of the whole npm registry.
134
- hosts: ['pi'],
135
- // The catalog's sort CONTROL offers three orders (`Most downloads` / `Recently published` / `A-Z`),
136
- // which map to `?sort=downloads|recent|name` — measured 2026-10-25: each reorders the page, and an
137
- // unknown value silently falls back to downloads. Those three are the source's whole official set.
138
- sorts: ['downloads', 'recent', 'name'],
139
- },
140
- {
141
- id: 'github',
142
- label: 'GitHub',
143
- kinds: ['skill'],
144
- trust: 'community',
145
- auth: 'none',
146
- enabled: true,
147
- browsable: true,
148
- // AFTER skills-sh and clawhub on the skills axis on purpose: both answer with rows that ARE
149
- // skills — the leaderboard ranked by installs, the registry by its own tally — while a topic
150
- // is self-declared on the REPO and a star count rewards the repo, not the skill. github is
151
- // the wider net here, and npm — whose rows cannot install as skills at all — stays below it.
152
- //
153
- // GitHub search repositories is the ONE market source with a published ordering contract:
154
- // `sort=stars|forks|help-wanted-issues|updated` (+ best-match when the parameter is omitted).
155
- // ALL of them are offered — the official set is the ceiling, not a curation of it; `stars` stays
156
- // first because it is what this market has always shown.
157
- sorts: ['stars', 'best-match', 'forks', 'updated', 'help-wanted-issues'],
158
- },
159
- {
160
- id: 'static-opencode',
161
- label: 'OpenCode ecosystem (curated)',
162
- kinds: ['extension'],
163
- trust: 'community',
164
- auth: 'none',
165
- enabled: true,
166
- browsable: true,
167
- // The curated list is OpenCode's own plugin catalog: those packages are written against the
168
- // OpenCode plugin API, so the source is bound to that one harness (ADR-0015 §D2 — no free host
169
- // checkbox list). Browse reads a shipped snapshot (no network); a row that has a verified npm
170
- // package name carries an `npm:<pkg>` install key, so installing it runs the npm source — this
171
- // source produces no payload of its own and has no install adapter.
172
- //
173
- // First of the opencode cluster on purpose: a curated snapshot whose rows were verified
174
- // against the registry is the lowest-noise answer for this runtime, so an opencode page opens
175
- // on it — the community catalogs follow, and npm's registry-wide search closes the axis.
176
- hosts: ['opencode'],
177
- // Full-catalog sources are read WHOLE by the backend before paging, so an order computed here is
178
- // global and honest (unlike a console-side re-sort of the visible page). `catalog` is the
179
- // snapshot's own order; `name` is the one dimension these rows all carry.
180
- sorts: ['catalog', 'name'],
181
- },
182
- {
183
- id: 'awesome-opencode',
184
- label: 'awesome-opencode (community)',
185
- kinds: ['extension'],
186
- trust: 'community',
187
- auth: 'none',
188
- enabled: true,
189
- browsable: true,
190
- // The community list publishes `dist/registry.json` — a flat array with a declared shape
191
- // (`data/schema.json`), generated from one YAML file per entry. It is read through the GitHub
192
- // contents API (raw mirrors reset from this environment). Entries carry no package name, so the
193
- // install adapter resolves one on demand (declared name → repository-verified candidate) and
194
- // answers the npm identity; the row's key stays this source's until install time.
195
- hosts: ['opencode'],
196
- sorts: ['catalog', 'name'],
197
- },
198
- {
199
- id: 'opencode-cafe',
200
- label: 'opencode.cafe (community)',
201
- kinds: ['extension'],
202
- trust: 'community',
203
- auth: 'none',
204
- enabled: true,
205
- browsable: true,
206
- // A Next.js site over a Convex deployment; the catalog query (`extensions:listAllApproved`) is
207
- // anonymously readable and is read directly with a POST. Undocumented contract: a re-provisioned
208
- // deployment answers `upstream`, never an empty catalog. Only `type: 'plugin'` rows are
209
- // extensions. The public query ships author e-mail addresses, which `opencode-cafe.ts` narrows
210
- // away before anything else sees a row.
211
- hosts: ['opencode'],
212
- sorts: ['catalog', 'name'],
213
- },
214
- {
215
- id: 'npm',
216
- label: 'npm registry',
217
- kinds: ['skill', 'extension', 'mcp'],
218
- trust: 'community',
219
- auth: 'none',
220
- enabled: true,
221
- browsable: true,
222
- // LAST in the array on purpose — the noisiest surface in the registry. An empty query is a
223
- // relevance guess across the WHOLE npm registry (the pinned per-runtime tag below narrows it),
224
- // it is bound to no runtime, and its search serves the most rows. Every source above pins its
225
- // rows to the artifact kind harder than npm does, so npm is the wide net an operator opts
226
- // into, never the landing state.
227
- //
228
- // npm's registry search has NO `sort` and its documented ranking weights are inert today
229
- // (measured 2026-10-25). `name`/`updated` are therefore ordered by the BACKEND over one maximum
230
- // window of the registry's own ranking — server-side, not in the page, and the note names the
231
- // window. `relevance` is the registry's untouched order.
232
- sorts: ['relevance', 'updated', 'name'],
233
- // The MCP axis opens on the author's own `mcp-server` tag (measured 2026-10-25: 10 501
234
- // packages; the wider `model-context-protocol` tag at 41 344 is mostly SDKs and clients), and
235
- // an mcp row resolves to a launch over the pinned spec (`npx -y <pkg@version>` + integrity).
236
- // No `hosts`: a package is not bound to a runtime until the operator names the harness, and
237
- // only a runtime with a verified package-manager landing can take it.
238
- },
239
- ];
240
- export function registerHarnessRoutes(app) {
116
+ enabled: entry.enabled,
117
+ browsable: entry.enabled && snap !== null,
118
+ // MCP: one shared catalogue, listed on every host with a verified landing. A package source
119
+ // has no detected form set, so the landing table (not the snapshot) is the honest host claim.
120
+ hosts: mcp ? mcpHostIds() : entry.harness ? [entry.harness] : snap?.hosts,
121
+ };
122
+ }
123
+ /** Re-read one MCP package source's row from its own registry (npm / PyPI). The source names ONE
124
+ * package, so the probe answers at most one row; a missing record is a probe failure, never an
125
+ * empty success. */
126
+ async function probeMcpPackage(entry, fetchImpl) {
127
+ if (entry.type === 'pypi') {
128
+ const query = parsePypiSource(entry.repo);
129
+ if (!query.ok)
130
+ return { ok: false, message: query.message };
131
+ const probed = await probePypiSource(query, fetchImpl);
132
+ return probed.ok ? { ok: true, row: probed.pkg } : { ok: false, message: probed.message };
133
+ }
134
+ const query = parseNpmSource(entry.repo);
135
+ if (!query.ok)
136
+ return { ok: false, message: query.message };
137
+ const probed = await probeNpmSource(query, fetchImpl);
138
+ const pkg = probed.ok ? probed.packages[0] : undefined;
139
+ if (!pkg) {
140
+ return { ok: false, message: probed.ok ? `'${entry.repo}' published no package record` : probed.message };
141
+ }
142
+ return { ok: true, row: { name: pkg.name, description: pkg.description, version: null } };
143
+ }
144
+ export function registerHarnessRoutes(app, opts = {}) {
241
145
  // Source registry + health. The console derives its tab row from this, never from a hardcoded list.
242
- app.get('/api/admin/harness/sources', async () => ({ status: 'ok', sources: SOURCES }));
146
+ app.get('/api/admin/harness/sources', async () => ({
147
+ status: 'ok',
148
+ sources: [...SOURCES, ...listMarketplaceEntries().map((e) => mpSourceView(e.slug))],
149
+ }));
150
+ // Per-harness plugin market (ADR-0015 §D10): the maintenance verbs live HERE, scoped to the
151
+ // harness whose market tab is showing them — never on a global surface. The adapter forwards to
152
+ // the SHARED marketplace store; the store being global is stated in §D11, and every mutation
153
+ // re-harvests all served harnesses' indexes so no sibling tab goes stale.
154
+ const pluginAdapterFor = (harness) => {
155
+ if (!HOSTS.some((h) => h.id === harness))
156
+ return undefined;
157
+ // The dialog maintains OPERATOR sources, so it always gets the writable chain: pi's official
158
+ // surface is read-only by contract, while its git-source chain is the one that can add/remove.
159
+ return createPluginAdapter(harness, opts.marketplaceFetch, { custom: true });
160
+ };
161
+ /** The entry behind a plugin-axis request: an entry whose snapshot carries no plugin or MCP row
162
+ * serves the skill axis only, so this route must not edit or delete it (§D11 route isolation). */
163
+ const pluginEntry = (slug, harness) => {
164
+ const entry = getMarketplaceEntry(slug, harness);
165
+ if (!entry)
166
+ return undefined;
167
+ const snap = latestSnapshot(slug, entry.axis === 'mcp' ? null : (entry.harness ?? harness));
168
+ const rows = (snap?.plugins.length ?? 0) + (snap?.mcps?.length ?? 0);
169
+ return rows > 0 ? entry : undefined;
170
+ };
171
+ // Per-harness sync: imports the marketplaces already configured in THIS harness's native
172
+ // environment and pushes OCR's registrations back into it (ADR-0015 §D9, one direction each).
173
+ app.get('/api/admin/harness/plugins/:harness/sources', async (req, reply) => {
174
+ const harnessParam = req.params.harness;
175
+ const adapter = pluginAdapterFor(harnessParam);
176
+ if (!adapter) {
177
+ reply.code(404);
178
+ return { status: 'error', code: 'unknown_harness', message: `unknown harness` };
179
+ }
180
+ // KIND isolation (§D11): this route is the PER-HARNESS surface (plugin, plus MCP views when a
181
+ // directory is wired). SKILLS are a GLOBAL directory with their OWN route (`/skills/sources`):
182
+ // they are never served from a harness-scoped endpoint, because a skill source is not any
183
+ // harness's private market. A source that cannot serve the open kind is noise, not information.
184
+ const kindQ = (req.query || {}).kind;
185
+ const kindOk = (kinds) => !kindQ || kinds.includes(kindQ);
186
+ const harness = harnessParam;
187
+ const perHarness = [...MCP_DEFAULT_VIEWS, ...getBuiltinViewsForHarness(harness)].filter((v) => !v.hosts || v.hosts.includes(harness));
188
+ return {
189
+ status: 'ok',
190
+ // This harness's published extension layer (`pi-extension`, `.claude-plugin`, …) or null.
191
+ // The dialog pre-fills the add form with it; the API never applies it implicitly.
192
+ extensionDir: adapter.extensionDir,
193
+ sources: perHarness.filter((s) => kindOk(s.kinds)).map((s) => ({
194
+ id: s.id,
195
+ label: s.label,
196
+ tier: 'federated',
197
+ sorts: s.sorts ?? [],
198
+ counts: false,
199
+ })),
200
+ operator: listMarketplaceEntries(harness)
201
+ .map((e) => {
202
+ const snap = latestSnapshot(e.slug, e.axis === 'mcp' ? null : harness);
203
+ // A plugin entry lists on a tab only when its snapshot detected that harness's form
204
+ // (pre-detection snapshots recorded nothing and keep the tolerant everywhere-visibility).
205
+ // An MCP package source is shared, so its host claim is the LANDING table instead.
206
+ const hosts = e.axis === 'mcp' ? mcpHostIds() : snap?.hosts ?? [];
207
+ if (!e.harness && hosts.length > 0 && !hosts.includes(harness))
208
+ return null;
209
+ const kinds = [
210
+ ...((snap?.rows.length ?? 0) > 0 ? ['skill'] : []),
211
+ ...((snap?.plugins.length ?? 0) > 0 ? ['plugin'] : []),
212
+ ...((snap?.mcps?.length ?? 0) > 0 ? ['mcp'] : []),
213
+ ];
214
+ return {
215
+ ...e,
216
+ type: e.type ?? 'github',
217
+ /** Harnesses the repository's own forms declare (detected at probe time). */
218
+ hosts,
219
+ marketplace: snap?.marketplace ?? null,
220
+ kinds,
221
+ };
222
+ })
223
+ .filter((e) => e !== null && kindOk(e.kinds)),
224
+ };
225
+ });
226
+ // Full CRUD (§D11): the dialog edits the entry config in place — enable/disable and the rescan
227
+ // schedule are independent fields, updated through this PATCH without a whole-store replace.
228
+ app.patch('/api/admin/harness/plugins/:harness/sources/:slug', async (req, reply) => {
229
+ const harnessParam = req.params.harness;
230
+ const adapter = pluginAdapterFor(harnessParam);
231
+ if (!adapter) {
232
+ reply.code(404);
233
+ return { status: 'error', code: 'unknown_harness', message: `unknown harness` };
234
+ }
235
+ const { slug } = req.params;
236
+ const entry = pluginEntry(slug, harnessParam);
237
+ if (!entry) {
238
+ reply.code(404);
239
+ return { status: 'error', code: 'not_found', message: `no source '${slug}'` };
240
+ }
241
+ const body = (req.body || {});
242
+ const patch = {};
243
+ if (typeof body.enabled === 'boolean')
244
+ patch.enabled = body.enabled;
245
+ if (typeof body.catalog === 'string')
246
+ patch.catalog = body.catalog;
247
+ if (body.rescan)
248
+ patch.rescan = body.rescan;
249
+ if (Object.keys(patch).length === 0)
250
+ return { status: 'ok' };
251
+ if (!updateMarketplaceEntry(slug, patch, harnessParam)) {
252
+ reply.code(404);
253
+ return { status: 'error', code: 'not_found', message: `no source '${slug}'` };
254
+ }
255
+ // Enabling/disabling or re-cataloguing moves rows: every index re-reads the snapshot now.
256
+ harvestAll();
257
+ return { status: 'ok' };
258
+ });
259
+ // Manual rescan from the dialog (reports the diff: added / removed row counts).
260
+ app.post('/api/admin/harness/plugins/:harness/sources/:slug/rescan', async (req, reply) => {
261
+ const harnessParam = req.params.harness;
262
+ const adapter = pluginAdapterFor(harnessParam);
263
+ if (!adapter) {
264
+ reply.code(404);
265
+ return { status: 'error', code: 'unknown_harness', message: `unknown harness` };
266
+ }
267
+ const { slug } = req.params;
268
+ const entry = pluginEntry(slug, harnessParam);
269
+ if (!entry) {
270
+ reply.code(404);
271
+ return { status: 'error', code: 'not_found', message: `no source '${slug}'` };
272
+ }
273
+ // An MCP package source has no harness scope: its snapshot is the one every capable tab
274
+ // reads, so a rescan from any tab rewrites the global file (legacy harness snapshots stay
275
+ // readable through the global fallback but are never written again).
276
+ const scope = entry.axis === 'mcp' ? null : (entry.harness ?? harnessParam);
277
+ if (entry.type === 'npm' || entry.type === 'pypi') {
278
+ if (entry.axis === 'mcp') {
279
+ // An MCP package source's freshness is its registry read: one package, one rewritten row.
280
+ const probed = await probeMcpPackage(entry, opts.marketplaceFetch);
281
+ if (!probed.ok) {
282
+ reply.code(400);
283
+ return { status: 'error', code: 'probe_failed', message: probed.message };
284
+ }
285
+ writeMcpSourceSnapshot(slug, probed.row, scope);
286
+ return { status: 'ok', rows: 1 };
287
+ }
288
+ const parsed = parseNpmSource(entry.repo);
289
+ if (!parsed) {
290
+ reply.code(400);
291
+ return { status: 'error', code: 'invalid_source', message: 'invalid npm source spec' };
292
+ }
293
+ const probed = await probeNpmSource(parsed, opts.marketplaceFetch);
294
+ if (!probed.ok) {
295
+ reply.code(400);
296
+ return { status: 'error', code: 'probe_failed', message: probed.message };
297
+ }
298
+ writeNpmSourceSnapshot(slug, probed.packages, scope);
299
+ harvestAll();
300
+ return { status: 'ok', rows: probed.packages.length };
301
+ }
302
+ const prev = latestSnapshot(slug, scope);
303
+ const probe = await probeMarketplace(entry, opts.marketplaceFetch, {
304
+ ...probeOptionsFor(entry.harness ?? harnessParam),
305
+ hosts: allHostProbes(),
306
+ });
307
+ if (!probe.ok) {
308
+ reply.code(400);
309
+ return { status: 'error', code: 'probe_failed', message: probe.message };
310
+ }
311
+ // The new snapshot is the index's input: re-harvest every served harness so a rescan that
312
+ // gained rows is visible in the catalog immediately.
313
+ harvestAll();
314
+ // Snapshots retain history: diff is against the IMMEDIATELY PRECEDING snapshot, not empty.
315
+ const added = prev ? probe.snapshot.rows.filter((r) => !prev.rows.some((p) => p.name === r.name)).map((r) => r.name) : [];
316
+ const removed = prev ? prev.rows.filter((p) => !probe.snapshot.rows.some((r) => r.name === p.name)).map((p) => p.name) : [];
317
+ return { status: 'ok', rows: probe.snapshot.rows.length, diff: { added, removed } };
318
+ });
319
+ // Snapshot ledger inspection: the dialog can render recent scans with their timestamps.
320
+ app.get('/api/admin/harness/plugins/:harness/sources/:slug/snapshots', async (req, reply) => {
321
+ const harnessParam = req.params.harness;
322
+ const adapter = pluginAdapterFor(harnessParam);
323
+ if (!adapter) {
324
+ reply.code(404);
325
+ return { status: 'error', code: 'unknown_harness', message: `unknown harness` };
326
+ }
327
+ const slug = req.params.slug;
328
+ const entry = getMarketplaceEntry(slug, harnessParam);
329
+ if (!entry) {
330
+ reply.code(404);
331
+ return { status: 'error', code: 'unknown_source', message: `unknown source '${slug}'` };
332
+ }
333
+ const history = snapshotHistory(slug, entry.axis === 'mcp' ? null : harnessParam);
334
+ return {
335
+ status: 'ok',
336
+ slug,
337
+ snapshots: history.map((s) => ({
338
+ probedAt: s.probedAt,
339
+ sha: s.sha,
340
+ rows: s.rows.length,
341
+ plugins: s.plugins?.length ?? 0,
342
+ stars: s.stars,
343
+ pushedAt: s.pushedAt,
344
+ marketplace: s.marketplace ?? null,
345
+ })),
346
+ };
347
+ });
348
+ // Register PROBES FIRST (an entry is written only when its repo answers a manifest or a
349
+ // SKILL.md scan) and re-harvests every served harness's index; duplicate slugs answer 409.
350
+ app.post('/api/admin/harness/plugins/:harness/sources', async (req, reply) => {
351
+ const adapter = pluginAdapterFor(req.params.harness);
352
+ if (!adapter) {
353
+ reply.code(404);
354
+ return { status: 'error', code: 'unknown_harness', message: `unknown harness` };
355
+ }
356
+ const body = (req.body || {});
357
+ if (!body.url) {
358
+ reply.code(400);
359
+ return { status: 'error', code: 'bad_request', message: 'url is required' };
360
+ }
361
+ const outcome = await adapter.registerSource(body.url, {
362
+ catalog: body.catalog,
363
+ rescan: body.rescan,
364
+ extensionDir: body.extensionDir,
365
+ ...(body.type ? { type: body.type } : {}),
366
+ ...(body.kind ? { kind: body.kind } : {}),
367
+ ...(body.shared ? { shared: true } : {}),
368
+ });
369
+ if (!outcome.ok) {
370
+ const reason = outcome.reason;
371
+ // `no_form`/`probe_failed` are answers about the SOURCE; only a duplicate is a conflict.
372
+ const conflict = reason === 'already_configured' || reason === 'slug_taken';
373
+ reply.code(conflict ? 409 : 400);
374
+ return {
375
+ status: 'error',
376
+ code: conflict ? 'conflict' : 'bad_request',
377
+ reason,
378
+ params: outcome.params,
379
+ message: outcome.message ?? '',
380
+ };
381
+ }
382
+ return { status: 'ok', reason: outcome.reason, params: outcome.params, message: outcome.message };
383
+ });
384
+ // Dry-run probe: reports counts without writing anything (the operator's "check before add").
385
+ app.post('/api/admin/harness/plugins/:harness/sources/check', async (req, reply) => {
386
+ const adapter = pluginAdapterFor(req.params.harness);
387
+ if (!adapter) {
388
+ reply.code(404);
389
+ return { status: 'error', code: 'unknown_harness', message: `unknown harness` };
390
+ }
391
+ const body = (req.body || {});
392
+ if (!body.url) {
393
+ reply.code(400);
394
+ return { status: 'error', code: 'bad_request', message: 'url is required' };
395
+ }
396
+ const check = await adapter.checkSource(body.url, {
397
+ extensionDir: body.extensionDir,
398
+ ...(body.type ? { type: body.type } : {}),
399
+ ...(body.kind ? { kind: body.kind } : {}),
400
+ });
401
+ return { status: 'ok', ...check };
402
+ });
403
+ app.delete('/api/admin/harness/plugins/:harness/sources/:slug', async (req, reply) => {
404
+ const harnessParam = req.params.harness;
405
+ const adapter = pluginAdapterFor(harnessParam);
406
+ if (!adapter) {
407
+ reply.code(404);
408
+ return { status: 'error', code: 'unknown_harness', message: `unknown harness` };
409
+ }
410
+ const { slug } = req.params;
411
+ if (!pluginEntry(slug, harnessParam) || !adapter.unregisterSource(slug)) {
412
+ reply.code(404);
413
+ return { status: 'error', code: 'unknown_source', message: `unknown source '${slug}'` };
414
+ }
415
+ return { status: 'ok' };
416
+ });
417
+ app.post('/api/admin/harness/plugins/:harness/sources/sync', async (req, reply) => {
418
+ const harnessParam = req.params.harness;
419
+ if (!pluginAdapterFor(harnessParam)) {
420
+ reply.code(404);
421
+ return { status: 'error', code: 'unknown_harness', message: 'unknown harness' };
422
+ }
423
+ const report = await reconcileMarketplaces([harnessParam], opts.marketplaceFetch);
424
+ return { status: 'ok', ...report };
425
+ });
426
+ // ── Skill sources: the GLOBAL maintenance surface (§D11) ─────────────────────────────────────
427
+ // The skill axis is not harness-scoped, so these verbs carry NO `:harness`: the registry is
428
+ // code-configured (ClawHub) and an operator extension is a GitHub repository that publishes
429
+ // SKILL.md rows. Plugin maintenance lives under `/plugins/:harness/sources*`; the two surfaces
430
+ // never serve each other's axis.
431
+ app.get('/api/admin/harness/skills/sources', async () => ({
432
+ status: 'ok',
433
+ sources: SKILL_VIEWS.map((s) => ({
434
+ id: s.id,
435
+ label: s.label,
436
+ tier: 'federated',
437
+ sorts: s.sorts ?? [],
438
+ counts: false,
439
+ })),
440
+ operator: listMarketplaceEntries()
441
+ .map((e) => {
442
+ const snap = latestSnapshot(e.slug, e.harness);
443
+ const kinds = [
444
+ ...((snap?.rows.length ?? 0) > 0 ? ['skill'] : []),
445
+ ...((snap?.plugins.length ?? 0) > 0 ? ['plugin'] : []),
446
+ ...((snap?.mcps?.length ?? 0) > 0 ? ['mcp'] : []),
447
+ ];
448
+ return {
449
+ ...e,
450
+ type: e.type ?? 'github',
451
+ hosts: snap?.hosts ?? [],
452
+ marketplace: snap?.marketplace ?? null,
453
+ kinds,
454
+ };
455
+ })
456
+ .filter((e) => e.kinds.includes('skill')),
457
+ }));
458
+ // Dry-run probe: a skill source must actually publish skills (check-before-add).
459
+ app.post('/api/admin/harness/skills/sources/check', async (req, reply) => {
460
+ const body = (req.body || {});
461
+ if (!body.url) {
462
+ reply.code(400);
463
+ return { status: 'error', code: 'bad_request', message: 'url is required' };
464
+ }
465
+ return { status: 'ok', ...(await checkSkillSource(body.url, opts.marketplaceFetch)) };
466
+ });
467
+ app.post('/api/admin/harness/skills/sources', async (req, reply) => {
468
+ const body = (req.body || {});
469
+ if (!body.url) {
470
+ reply.code(400);
471
+ return { status: 'error', code: 'bad_request', message: 'url is required' };
472
+ }
473
+ const outcome = await registerSkillSource(body.url, { catalog: body.catalog, rescan: body.rescan }, opts.marketplaceFetch);
474
+ if (!outcome.ok) {
475
+ const conflict = outcome.reason === 'already_configured' || outcome.reason === 'slug_taken';
476
+ reply.code(conflict ? 409 : 400);
477
+ return {
478
+ status: 'error',
479
+ code: conflict ? 'conflict' : 'bad_request',
480
+ reason: outcome.reason,
481
+ params: outcome.params,
482
+ message: outcome.message ?? '',
483
+ };
484
+ }
485
+ return { status: 'ok', reason: outcome.reason, params: outcome.params, message: outcome.message };
486
+ });
487
+ app.patch('/api/admin/harness/skills/sources/:slug', async (req, reply) => {
488
+ const body = (req.body || {});
489
+ if (!updateSkillSource(req.params.slug, body)) {
490
+ reply.code(404);
491
+ return { status: 'error', code: 'not_found', message: `no source '${req.params.slug}'` };
492
+ }
493
+ return { status: 'ok' };
494
+ });
495
+ app.delete('/api/admin/harness/skills/sources/:slug', async (req, reply) => {
496
+ const { slug } = req.params;
497
+ if (!removeSkillSource(slug)) {
498
+ reply.code(404);
499
+ return { status: 'error', code: 'unknown_source', message: `unknown source '${slug}'` };
500
+ }
501
+ return { status: 'ok' };
502
+ });
503
+ app.post('/api/admin/harness/skills/sources/:slug/rescan', async (req, reply) => {
504
+ const { slug } = req.params;
505
+ if (!skillSourceEntry(slug)) {
506
+ reply.code(404);
507
+ return { status: 'error', code: 'not_found', message: `no source '${slug}'` };
508
+ }
509
+ const result = await rescanSkillSource(slug, opts.marketplaceFetch);
510
+ if (!result.ok) {
511
+ reply.code(400);
512
+ return { status: 'error', code: 'probe_failed', message: result.message };
513
+ }
514
+ return { status: 'ok', rows: result.rows, diff: { added: result.diff.added, removed: result.diff.removed } };
515
+ });
516
+ app.get('/api/admin/harness/plugins/:harness/catalog', async (req, reply) => {
517
+ const adapter = pluginAdapterFor(req.params.harness);
518
+ if (!adapter) {
519
+ reply.code(404);
520
+ return { status: 'error', code: 'unknown_harness', message: `unknown harness` };
521
+ }
522
+ const query = (req.query || {});
523
+ const page = await adapter.search(query.q ?? '', {
524
+ ...(query.page ? { page: Number(query.page) || 1 } : {}),
525
+ ...(query.pageSize ? { pageSize: Number(query.pageSize) || 24 } : {}),
526
+ ...(query.sort ? { sort: query.sort } : {}),
527
+ });
528
+ return { status: 'ok', ...page };
529
+ });
530
+ // Install funnels through the adapter into the HOST axis (§D11): the market adapter only
531
+ // translates the row; the write lands via HarnessHostAdapter with gate-3 discipline intact.
532
+ app.post('/api/admin/harness/plugins/:harness/install', async (req, reply) => {
533
+ const adapter = pluginAdapterFor(req.params.harness);
534
+ if (!adapter) {
535
+ reply.code(404);
536
+ return { status: 'error', code: 'unknown_harness', message: `unknown harness` };
537
+ }
538
+ const body = (req.body || {});
539
+ if (!body.row || typeof body.row !== 'object') {
540
+ reply.code(400);
541
+ return { status: 'error', code: 'bad_request', message: 'row is required' };
542
+ }
543
+ // Same trust boundary as the main install route: the body cannot widen the scope set the rest
544
+ // of the domain reads from `ENABLED_SCOPES`, and a project landing needs a verified root.
545
+ const scope = body.scope ?? 'global';
546
+ if (!isEnabledScope(scope)) {
547
+ reply.code(400);
548
+ return {
549
+ status: 'error',
550
+ code: 'unsupported_scope',
551
+ message: `scope '${scope}' is not supported — installs target ${ENABLED_SCOPES.join(', ')} scope`,
552
+ };
553
+ }
554
+ const root = resolveProjectRoot(body, { required: scope === 'project' });
555
+ if (!root.ok) {
556
+ reply.code(400);
557
+ return { status: 'error', code: 'bad_request', message: root.message };
558
+ }
559
+ const result = await adapter.install(body.row, {
560
+ scope,
561
+ ...(root.projectRoot ? { projectRoot: root.projectRoot } : {}),
562
+ confirm: body.confirm === true,
563
+ });
564
+ if (!result.ok) {
565
+ const status = result.code === 'exists' || result.code === 'foreign' || result.code === 'confirm_required'
566
+ ? 409
567
+ : result.code === 'upstream' || result.code === 'unavailable'
568
+ ? 502
569
+ : 400;
570
+ reply.code(status);
571
+ return { status: 'error', ...result };
572
+ }
573
+ return { status: 'ok', ...result };
574
+ });
243
575
  // Host catalog + resolved roots. `origin` explains why a path is what it is.
244
576
  app.get('/api/admin/harness/hosts', async () => ({
245
577
  status: 'ok',
246
- // The scopes this build accepts (ADR-0015 §D2 "Scope"). A consumer must read this instead of
247
- // assuming a `project` landing exists: project support is deferred, and `roots` below carries
248
- // exactly the scopes named here.
578
+ // The scopes this build accepts (ADR-0015 §D2 "Scope") — the build-wide accept list. What a
579
+ // given host can actually land per kind is narrower: `kindScopes` below is the per-host
580
+ // answer, and the writers refuse a scope absent from it.
249
581
  scopes: [...ENABLED_SCOPES],
250
582
  hosts: HOSTS.map((host) => {
583
+ const adapter = adapterFor(host.id);
251
584
  const roots = {
252
585
  global: skillRootsFor(host.id, 'global'),
253
586
  };
@@ -256,14 +589,27 @@ export function registerHarnessRoutes(app) {
256
589
  return {
257
590
  id: host.id,
258
591
  label: host.label,
592
+ /** Popularity order shared with the Clients page (1 = most popular; unranked = last).
593
+ * `universal` is unranked by design — the rail pins it first by id. */
594
+ rank: popularityRank(host.id),
259
595
  /** Present on this machine (executable, config dir, or an existing skills root). The
260
596
  * console rail hides undetected hosts — but never one whose rows are already landed. */
261
- detected: hostDetected(adapterFor(host.id)),
262
- hasSkills: isSkillsHost(adapterFor(host.id)),
597
+ detected: hostDetected(adapter),
598
+ hasSkills: isSkillsHost(adapter),
263
599
  /** MCP-capable host: its adapter implements the MCP landing capability. */
264
- hasMcp: isMcpHost(adapterFor(host.id)),
265
- /** Extension-capable host: its adapter implements the extension landing capability. */
266
- hasExt: isExtensionHost(adapterFor(host.id)),
600
+ hasMcp: isMcpHost(adapter),
601
+ /** Plugin-capable host: its adapter implements the plugin landing capability. */
602
+ hasExt: isPluginHost(adapter),
603
+ /** Per-profile plugin store (DSH): the targets the console may pick. */
604
+ ...(isPluginHost(adapter) && adapter.installProfiles ? { profiles: adapter.installProfiles() } : {}),
605
+ /** Per-kind scope capability (ADR-0015 §D2): the scopes an install may target for each
606
+ * kind. The console greys out a scope absent from the kind's list instead of letting
607
+ * the operator aim an install at a landing the runtime has no write grammar for. */
608
+ kindScopes: {
609
+ skill: [...adapter.supportedScopes('skill')],
610
+ mcp: [...adapter.supportedScopes('mcp')],
611
+ plugin: [...adapter.supportedScopes('plugin')],
612
+ },
267
613
  roots,
268
614
  owner: {
269
615
  global: roots.global[0] ? skillOwner(roots.global[0].root, 'global') : null,
@@ -274,8 +620,14 @@ export function registerHarnessRoutes(app) {
274
620
  // Apply ledger — the audit trail behind every install/remove (ADR-0015 apply ledger).
275
621
  app.get('/api/admin/harness/applies', async () => ({ status: 'ok', applies: recentApplies(100) }));
276
622
  // Installed artifacts + untracked directories, reconciled per copy.
277
- app.get('/api/admin/harness/inventory', async () => {
278
- const inventory = scanInventory();
623
+ app.get('/api/admin/harness/inventory', async (req, reply) => {
624
+ const query = (req.query || {});
625
+ const root = resolveProjectRoot(query, { required: false });
626
+ if (!root.ok) {
627
+ reply.code(400);
628
+ return { status: 'error', code: 'bad_request', message: root.message };
629
+ }
630
+ const inventory = scanInventory(root.projectRoot);
279
631
  return {
280
632
  status: 'ok',
281
633
  ...inventory,
@@ -307,14 +659,19 @@ export function registerHarnessRoutes(app) {
307
659
  }
308
660
  if (item.removal !== undefined) {
309
661
  const op = item.removal?.op;
310
- if (op !== 'trash-path' && op !== 'drop-entry' && op !== 'drop-server') {
662
+ if (op !== 'trash-path' && op !== 'drop-entry' && op !== 'drop-server' && op !== 'cli-remove') {
311
663
  reply.code(400);
312
664
  return { status: 'error', code: 'bad_request', message: `unknown removal op '${String(op)}'` };
313
665
  }
314
666
  }
315
667
  }
316
668
  // artifactId null = a directory with no manifest entry; root containment is the guard.
317
- const plan = planRemove(body.items);
669
+ const root = resolveProjectRoot(body, { required: false });
670
+ if (!root.ok) {
671
+ reply.code(400);
672
+ return { status: 'error', code: 'bad_request', message: root.message };
673
+ }
674
+ const plan = planRemove(body.items, { projectRoot: root.projectRoot });
318
675
  if ('error' in plan) {
319
676
  reply.code(400);
320
677
  return { status: 'error', code: 'plan_rejected', message: plan.error };
@@ -325,21 +682,107 @@ export function registerHarnessRoutes(app) {
325
682
  // an empty market reads as "nothing exists", which is a different (and false) claim.
326
683
  app.get('/api/admin/harness/browse', async (req, reply) => {
327
684
  const query = (req.query || {});
328
- const source = SOURCES.find((s) => s.id === (query.source || 'github'));
685
+ const requestedSource = query.source || SOURCES[0]?.id || '';
686
+ const source = SOURCES.find((s) => s.id === requestedSource) ??
687
+ mpSourceView(requestedSource.startsWith('mp-') ? requestedSource.slice(3) : requestedSource);
329
688
  if (!source) {
330
689
  reply.code(404);
331
- return { status: 'error', code: 'unknown_source', message: `unknown source '${query.source}'` };
690
+ return { status: 'error', code: 'unknown_source', message: `unknown source '${requestedSource}'` };
691
+ }
692
+ // An operator entry browses from its own snapshot, not the live-source dispatcher. The plugin
693
+ // axis reads the snapshot's plugin rows: those ARE the plugins the operator added, and their
694
+ // keys are the native install handles (`mp-<slug>:<repo>#<source>` / `npm:<pkg>`).
695
+ if (source.id.startsWith('mp-')) {
696
+ const slug = source.id.slice(3);
697
+ const page = Math.max(Number(query.page) || 1, 1);
698
+ const pageSize = Math.min(Number(query.limit) || 24, 100);
699
+ const entry = getMarketplaceEntry(slug);
700
+ if (query.kind === 'mcp' && entry) {
701
+ // The MCP axis reads the snapshot's single package row; the install handle is the
702
+ // registry key (`npm:<pkg>` / `pypi:<pkg>`), which the resolver pins at install time.
703
+ const snapshot = latestSnapshot(slug);
704
+ const needle = (query.q || '').trim().toLowerCase();
705
+ const ecosystem = entry.type === 'pypi' ? 'pypi' : 'npm';
706
+ const all = (snapshot?.mcps ?? [])
707
+ .filter((m) => !needle || m.name.toLowerCase().includes(needle) || (m.description ?? '').toLowerCase().includes(needle))
708
+ .map((m) => ({
709
+ id: `${ecosystem}:${m.name}`,
710
+ key: `${ecosystem}:${m.name}`,
711
+ sourceId: source.id,
712
+ installKind: 'mcp',
713
+ name: m.name,
714
+ // The key the install will merge under, derived by the SAME rule the resolver applies
715
+ // (`mcpServerNameFromPackage`): the sheet shows it read-only, and it must not promise a
716
+ // name the host grammar refuses (`@bytebase/dbhub` fails every verified landing).
717
+ serverName: mcpServerNameFromPackage(m.name),
718
+ description: m.description,
719
+ url: ecosystem === 'pypi' ? `https://pypi.org/project/${m.name}/` : `https://www.npmjs.com/package/${m.name}`,
720
+ version: m.version,
721
+ stars: null,
722
+ updatedAt: '',
723
+ topics: [],
724
+ }));
725
+ return {
726
+ status: 'ok',
727
+ source: source.id,
728
+ page,
729
+ items: all.slice((page - 1) * pageSize, page * pageSize),
730
+ hasMore: page * pageSize < all.length,
731
+ total: all.length,
732
+ };
733
+ }
734
+ if (query.kind === 'plugin' && entry) {
735
+ const snapshot = latestSnapshot(slug);
736
+ const needle = (query.q || '').trim().toLowerCase();
737
+ const all = (snapshot?.plugins ?? [])
738
+ .filter((p) => !needle || p.name.toLowerCase().includes(needle) || (p.description ?? '').toLowerCase().includes(needle))
739
+ .map((p) => {
740
+ const key = entry.type === 'npm' ? `npm:${p.name}` : `${source.id}:${entry.repo}#${p.source}`;
741
+ return {
742
+ id: key,
743
+ key,
744
+ sourceId: source.id,
745
+ installKind: 'plugin',
746
+ name: p.name,
747
+ ...(entry.type === 'npm' ? {} : { repo: entry.repo }),
748
+ description: p.description,
749
+ url: entry.type === 'npm'
750
+ ? `https://www.npmjs.com/package/${p.name}`
751
+ : `https://github.com/${entry.repo}`,
752
+ stars: entry.type === 'npm' ? null : snapshot?.stars ?? null,
753
+ updatedAt: '',
754
+ topics: [],
755
+ // The install command spells `<plugin>@<marketplace>`; an npm row installs by spec.
756
+ ...(entry.type === 'npm' ? {} : { marketplace: snapshot?.marketplace ?? null }),
757
+ };
758
+ });
759
+ return {
760
+ status: 'ok',
761
+ source: source.id,
762
+ page,
763
+ items: all.slice((page - 1) * pageSize, page * pageSize),
764
+ hasMore: page * pageSize < all.length,
765
+ total: all.length,
766
+ };
767
+ }
768
+ const browsed = browseMarketplace(slug, { query: query.q, page, pageSize });
769
+ if (!browsed.ok) {
770
+ reply.code(browsed.code === 'unknown_source' ? 404 : 409);
771
+ return { status: 'error', code: browsed.code, message: browsed.message, source: source.id };
772
+ }
773
+ return {
774
+ status: 'ok',
775
+ source: source.id,
776
+ page,
777
+ items: browsed.items.map((i) => ({ ...i, id: i.key, sourceId: source.id, installKind: 'skill', stars: null, updatedAt: '', url: null, topics: [] })),
778
+ hasMore: browsed.hasMore,
779
+ total: browsed.total,
780
+ };
332
781
  }
333
- // The market axis the console is browsing. Only npm forks on it today (default query + row
334
- // install kind); a value outside the kind vocabulary is dropped, never forwarded.
335
- const kind = ['skill', 'mcp', 'extension'].includes(query.kind ?? '')
336
- ? query.kind
337
- : undefined;
338
782
  // `page` is 1-based; a nonsense value falls back to the first page rather than answering empty.
339
783
  const page = Math.max(Number(query.page) || 1, 1);
340
784
  const result = await browseSource(source, query.q || '', Number(query.limit) || 24, {
341
785
  ...(query.harness ? { harness: query.harness } : {}),
342
- ...(kind ? { kind } : {}),
343
786
  page,
344
787
  // `sort` is validated against the source's OWN declared orderings inside `browseSource`: an
345
788
  // order the upstream cannot serve is dropped, never forwarded as a guess.
@@ -419,16 +862,228 @@ export function registerHarnessRoutes(app) {
419
862
  // would turn an admin GET into an arbitrary-URL proxy.
420
863
  app.get('/api/admin/harness/detail', async (req, reply) => {
421
864
  const query = (req.query || {});
422
- const source = SOURCES.find((s) => s.id === (query.source || 'github'));
423
- if (!source) {
424
- reply.code(404);
425
- return { status: 'error', code: 'unknown_source', message: `unknown source '${query.source}'` };
865
+ let sourceId = 'direct';
866
+ if (query.source) {
867
+ const source = SOURCES.find((s) => s.id === query.source) ??
868
+ mpSourceView(query.source.startsWith('mp-') ? query.source.slice(3) : query.source);
869
+ if (!source) {
870
+ reply.code(404);
871
+ return { status: 'error', code: 'unknown_source', message: `unknown source '${query.source}'` };
872
+ }
873
+ sourceId = source.id;
426
874
  }
875
+ // The console's language lets the reader prefer the README's own localized edition (and report
876
+ // `readmeLang`), so an already-Chinese/Japanese/Korean page is shown instead of translated.
877
+ const lang = query.lang && isSupportedLang(query.lang) ? query.lang : undefined;
427
878
  const detail = await readMarketDetail({
428
879
  ...(query.key ? { key: query.key } : {}),
429
880
  ...(query.repo ? { repo: query.repo } : {}),
881
+ ...(lang ? { lang } : {}),
430
882
  });
431
- return { status: 'ok', source: source.id, detail };
883
+ return { status: 'ok', source: sourceId, detail };
884
+ });
885
+ // ── MCP entry read / edit (ADR-0015 §D8 amendment, 2026-11-01) ──────────────────────────────
886
+ // The harness page's edit surface. A read answers the launch behind ONE existing server member,
887
+ // with env/header KEY NAMES plus the set of keys that already hold a value; the write changes that
888
+ // member through the same gate-2 discipline as install. `name` names an EXISTING key — renaming is
889
+ // delete + add, never an edit.
890
+ // ── MCP Registry parameter schema (ADR-0015 §D8 amendment, 2026-11-01) ──────────────────────
891
+ // The add/edit sheet's visual form is generated from the registry's own `server.json`, so it works
892
+ // for any server instead of a hand-written per-package form. Read-only: nothing here is written.
893
+ app.get('/api/admin/harness/mcp/registry', async (req, reply) => {
894
+ const query = (req.query || {});
895
+ if (!query.q) {
896
+ reply.code(400);
897
+ return { status: 'error', code: 'bad_request', message: 'q is required' };
898
+ }
899
+ const result = await searchMcpRegistry(query.q);
900
+ if (!result.ok) {
901
+ reply.code(result.code === 'bad_request' ? 400 : 502);
902
+ return { status: 'error', code: result.code, message: result.message };
903
+ }
904
+ return { status: 'ok', candidates: result.candidates };
905
+ });
906
+ // ── MCP npm package CLI flags (ADR-0015 §D8 amendment, 2026-11-01) ──────────────────────────
907
+ // The registry declares DBHub's environment variables and no `runtimeArguments`, so the package
908
+ // itself is read for the flags it parses (`--transport`, `--port`, `--dsn`). The tarball is
909
+ // downloaded into memory and scanned; the package is never executed and nothing is written.
910
+ app.get('/api/admin/harness/mcp/cli', async (req, reply) => {
911
+ const query = (req.query || {});
912
+ if (!query.pkg) {
913
+ reply.code(400);
914
+ return { status: 'error', code: 'bad_request', message: 'pkg is required' };
915
+ }
916
+ // npx / bunx resolve on npm; uvx resolves on PyPI. No parameter means npm.
917
+ if (query.registry !== undefined && query.registry !== 'npm' && query.registry !== 'pypi') {
918
+ reply.code(400);
919
+ return { status: 'error', code: 'bad_request', message: "registry must be 'npm' or 'pypi'" };
920
+ }
921
+ const result = await probeMcpCli(query.pkg, { registry: query.registry ?? 'npm' });
922
+ if (!result.ok) {
923
+ reply.code(result.code === 'bad_request'
924
+ ? 400
925
+ : result.code === 'not_found'
926
+ ? 404
927
+ : result.code === 'too_large'
928
+ ? 413
929
+ : 502);
930
+ return { status: 'error', code: result.code, message: result.message };
931
+ }
932
+ return { status: 'ok', ...result };
933
+ });
934
+ // ── Live MCP runtime status (ADR-0015 §D8.8) ────────────────────────────────────────────────
935
+ // The config landing says a server was WRITTEN; only the runtime knows whether it CONNECTED.
936
+ // Read-only, never installs or spawns a server, and a host absent from the answer (or reported
937
+ // unreachable) is "no live claim": the console keeps its on-disk state and adds no runtime verdict.
938
+ app.get('/api/admin/harness/mcp/runtime', async () => ({ status: 'ok', ...(await probeMcpRuntimes()) }));
939
+ // ── DSN connection test (ADR-0015 §D11 amendment, 2026-11) ──────────────────────────────────
940
+ // Two tiers, both read-only. For postgres/postgresql and mysql/mariadb the route logs in with the
941
+ // operator's values through the real driver (`select 1` / `ping`) and answers a verdict code,
942
+ // because a TCP answer cannot tell a wrong password from a missing database. Every other scheme
943
+ // gets the credential-free TCP dial. The credential is used for this one request: the admin route
944
+ // is auth + CSRF gated, the value is never logged and never echoed back, and the driver's failure
945
+ // text (which does not contain the password) is all that returns.
946
+ app.post('/api/admin/harness/mcp/dsn-probe', async (req, reply) => {
947
+ const body = (req.body ?? {});
948
+ const text = (value, max) => typeof value === 'string' ? value.slice(0, max) : '';
949
+ const host = text(body.host, 253).trim();
950
+ const port = typeof body.port === 'number' ? body.port : Number.NaN;
951
+ if (!isProbeHost(host) || !Number.isInteger(port) || port < 1 || port > 65535) {
952
+ reply.code(400);
953
+ return { status: 'error', code: 'bad_request', message: 'host and port (1-65535) are required' };
954
+ }
955
+ const target = `${host}:${port}`;
956
+ const params = {};
957
+ if (body.params && typeof body.params === 'object' && !Array.isArray(body.params)) {
958
+ for (const [key, value] of Object.entries(body.params).slice(0, 64)) {
959
+ if (key !== '' && typeof value === 'string')
960
+ params[key.slice(0, 64)] = value.slice(0, 256);
961
+ }
962
+ }
963
+ const engine = dbEngineFor(text(body.driver, 32));
964
+ if (engine) {
965
+ const result = await probeDatabase({
966
+ engine,
967
+ host,
968
+ port,
969
+ user: text(body.user, 256),
970
+ password: text(body.password, 4_096),
971
+ database: text(body.database, 256),
972
+ params,
973
+ });
974
+ return { status: 'ok', target, engine, ...result };
975
+ }
976
+ const dial = await probeTcp(host, port);
977
+ const failure = dial.message ?? '';
978
+ const code = dial.reachable
979
+ ? 'reachable'
980
+ : failure.includes('ECONNREFUSED')
981
+ ? 'refused'
982
+ : /timeout/i.test(failure)
983
+ ? 'timeout'
984
+ : 'unreachable';
985
+ return {
986
+ status: 'ok',
987
+ target,
988
+ engine: null,
989
+ reachable: dial.reachable,
990
+ verified: false,
991
+ code,
992
+ ...(dial.message ? { message: dial.message } : {}),
993
+ };
994
+ });
995
+ app.get('/api/admin/harness/mcp/entry', async (req, reply) => {
996
+ const query = (req.query || {});
997
+ if (!query.host || !query.name) {
998
+ reply.code(400);
999
+ return { status: 'error', code: 'bad_request', message: 'host and name are required' };
1000
+ }
1001
+ if (!HOSTS.some((host) => host.id === query.host)) {
1002
+ reply.code(400);
1003
+ return { status: 'error', code: 'bad_request', message: `unknown host '${query.host}'` };
1004
+ }
1005
+ const scope = query.scope ?? 'global';
1006
+ if (!isEnabledScope(scope)) {
1007
+ reply.code(400);
1008
+ return {
1009
+ status: 'error',
1010
+ code: 'unsupported_scope',
1011
+ message: `scope '${scope}' is not supported — reads target ${ENABLED_SCOPES.join(', ')} scope`,
1012
+ };
1013
+ }
1014
+ const root = resolveProjectRoot(query, { required: false });
1015
+ if (!root.ok) {
1016
+ reply.code(400);
1017
+ return { status: 'error', code: 'bad_request', message: root.message };
1018
+ }
1019
+ const result = readMcpEntry({
1020
+ host: query.host,
1021
+ scope,
1022
+ name: query.name,
1023
+ ...(root.projectRoot ? { projectRoot: root.projectRoot } : {}),
1024
+ });
1025
+ if (!result.ok) {
1026
+ reply.code(result.code === 'not_found' ? 404 : 400);
1027
+ return { status: 'error', code: result.code, message: result.message };
1028
+ }
1029
+ return {
1030
+ status: 'ok',
1031
+ host: result.host,
1032
+ name: result.name,
1033
+ file: result.file,
1034
+ container: result.container,
1035
+ launch: result.launch,
1036
+ setKeys: result.setKeys,
1037
+ };
1038
+ });
1039
+ app.post('/api/admin/harness/mcp/edit', async (req, reply) => {
1040
+ const body = (req.body || {});
1041
+ if (!body.host || !body.name || body.launch === undefined) {
1042
+ reply.code(400);
1043
+ return { status: 'error', code: 'bad_request', message: 'host, name and launch are required' };
1044
+ }
1045
+ if (!HOSTS.some((host) => host.id === body.host)) {
1046
+ reply.code(400);
1047
+ return { status: 'error', code: 'bad_request', message: `unknown host '${body.host}'` };
1048
+ }
1049
+ // Same scope boundary as install: the body cannot widen the set the rest of the domain reads.
1050
+ const scope = body.scope ?? 'global';
1051
+ if (!isEnabledScope(scope)) {
1052
+ reply.code(400);
1053
+ return {
1054
+ status: 'error',
1055
+ code: 'unsupported_scope',
1056
+ message: `scope '${scope}' is not supported — edits target ${ENABLED_SCOPES.join(', ')} scope`,
1057
+ };
1058
+ }
1059
+ const root = resolveProjectRoot(body, { required: scope === 'project' });
1060
+ if (!root.ok) {
1061
+ reply.code(400);
1062
+ return { status: 'error', code: 'bad_request', message: root.message };
1063
+ }
1064
+ const result = await editMcpServer({
1065
+ host: body.host,
1066
+ scope,
1067
+ name: body.name,
1068
+ launch: body.launch,
1069
+ ...(typeof body.artifactId === 'string' ? { artifactId: body.artifactId } : {}),
1070
+ ...(root.projectRoot ? { projectRoot: root.projectRoot } : {}),
1071
+ confirm: body.confirm === true,
1072
+ });
1073
+ if (!result.ok) {
1074
+ const status = result.code === 'not_found' ? 404 : result.code === 'bad_request' ? 400 : 409;
1075
+ reply.code(status);
1076
+ return { status: 'error', ...result };
1077
+ }
1078
+ return {
1079
+ status: 'ok',
1080
+ changed: result.changed,
1081
+ host: result.host,
1082
+ name: result.name,
1083
+ file: result.file,
1084
+ container: result.container,
1085
+ artifactId: result.artifactId,
1086
+ };
432
1087
  });
433
1088
  // Install one artifact into one or more host locations — one store entry, N copies. The route
434
1089
  // speaks keys (`<sourceId>:<ref>[#detail]`); the SPI resolves the payload, the kind writer does
@@ -441,9 +1096,8 @@ export function registerHarnessRoutes(app) {
441
1096
  reply.code(400);
442
1097
  return { status: 'error', code: 'bad_request', message: 'hosts[] and scope are required' };
443
1098
  }
444
- // Scope is a capability, not a free-form field: this build installs to the user-level roots only
445
- // (ADR-0015 §D2 "Scope"). The orchestrator keeps `scope` as the seam, so the refusal lives here —
446
- // a request naming `project` must not reach a writer that would happily land inside the repo.
1099
+ // Scope is a capability, not a free-form field (ADR-0015 §D2 "Scope"): the build's accept set is
1100
+ // `ENABLED_SCOPES`, and a `project` landing additionally requires a verified `projectRoot` below.
447
1101
  if (!isEnabledScope(body.scope)) {
448
1102
  reply.code(400);
449
1103
  return {
@@ -452,6 +1106,12 @@ export function registerHarnessRoutes(app) {
452
1106
  message: `scope '${body.scope}' is not supported — installs target ${ENABLED_SCOPES.join(', ')} scope`,
453
1107
  };
454
1108
  }
1109
+ const root = resolveProjectRoot(body, { required: body.scope === 'project' });
1110
+ if (!root.ok) {
1111
+ reply.code(400);
1112
+ return { status: 'error', code: 'bad_request', message: root.message };
1113
+ }
1114
+ const projectRoot = root.projectRoot;
455
1115
  // Validate the host catalog HERE, at the trust boundary: an unknown id would otherwise travel
456
1116
  // through resolve/write and fail deep inside a writer with a message about the wrong thing.
457
1117
  const unknown = hosts.find((id) => !HOSTS.some((host) => host.id === id));
@@ -468,7 +1128,7 @@ export function registerHarnessRoutes(app) {
468
1128
  }
469
1129
  // Kind is validated HERE, at the trust boundary, for the same reason as hosts above: an unknown
470
1130
  // kind must fail with a message about kind, not deep inside the orchestrator's default branch.
471
- if (body.kind !== 'skill' && body.kind !== 'mcp' && body.kind !== 'extension') {
1131
+ if (body.kind !== 'skill' && body.kind !== 'mcp' && body.kind !== 'plugin') {
472
1132
  reply.code(400);
473
1133
  return { status: 'error', code: 'bad_request', message: `unknown kind '${body.kind}'` };
474
1134
  }
@@ -478,23 +1138,61 @@ export function registerHarnessRoutes(app) {
478
1138
  : undefined;
479
1139
  // Listing surfaces are validated HERE, at the trust boundary, against the same registry the
480
1140
  // console builds its source chips from: a claim about where a row was browsed must name a source
481
- // this gateway declares, or it is dropped rather than recorded.
1141
+ // this gateway declares — built-in views OR an operator git source (`mp-*`, materialized from
1142
+ // the marketplace store) — or it is dropped rather than recorded.
482
1143
  const listedOn = Array.isArray(body.listedOn)
483
- ? body.listedOn.filter((id) => typeof id === 'string' && SOURCES.some((s) => s.id === id))
1144
+ ? body.listedOn.filter((id) => typeof id === 'string' && (SOURCES.some((s) => s.id === id) || /^mp-[a-z0-9][a-z0-9-]{0,38}$/.test(id)))
484
1145
  : undefined;
485
- const result = await installArtifact({
486
- sourceId: body.sourceId,
487
- key: body.key,
488
- repo: body.repo,
489
- kind,
490
- skillDir: body.skillDir,
491
- manualPayload,
492
- manualSpec: typeof body.manualSpec === 'string' ? body.manualSpec : undefined,
493
- confirm: body.confirm === true,
494
- listedOn,
495
- hosts: hostIds,
496
- scope: body.scope,
497
- });
1146
+ const logId = body.confirm === true && kind === 'plugin' && typeof body.installLogId === 'string'
1147
+ ? body.installLogId
1148
+ : undefined;
1149
+ if (logId && !startInstallLog(logId)) {
1150
+ reply.code(400);
1151
+ return { status: 'error', code: 'bad_request', message: 'invalid installLogId' };
1152
+ }
1153
+ let failure;
1154
+ let result;
1155
+ try {
1156
+ result = await installArtifact({
1157
+ sourceId: body.sourceId,
1158
+ key: body.key,
1159
+ repo: body.repo,
1160
+ kind,
1161
+ skillDir: body.skillDir,
1162
+ launch: kind === 'mcp' && body.launch && typeof body.launch === 'object'
1163
+ ? body.launch
1164
+ : undefined,
1165
+ manualPayload,
1166
+ manualSpec: typeof body.manualSpec === 'string' ? body.manualSpec : undefined,
1167
+ confirm: body.confirm === true,
1168
+ listedOn,
1169
+ ...(typeof body.description === 'string' ? { description: body.description } : {}),
1170
+ hosts: hostIds,
1171
+ scope: body.scope,
1172
+ ...(projectRoot ? { projectRoot } : {}),
1173
+ ...(kind === 'plugin' &&
1174
+ body.marketplace &&
1175
+ typeof body.marketplace.repo === 'string' &&
1176
+ typeof body.marketplace.plugin === 'string' &&
1177
+ typeof body.marketplace.name === 'string'
1178
+ ? { marketplace: { repo: body.marketplace.repo, plugin: body.marketplace.plugin, name: body.marketplace.name } }
1179
+ : {}),
1180
+ ...(typeof body.profile === 'string' && body.profile.trim() ? { profile: body.profile.trim() } : {}),
1181
+ ...(logId ? { onOutput: (chunk, stream) => appendInstallLog(logId, stream, chunk) } : {}),
1182
+ });
1183
+ }
1184
+ catch (e) {
1185
+ failure = e instanceof Error ? e.message : String(e);
1186
+ throw e;
1187
+ }
1188
+ finally {
1189
+ if (logId)
1190
+ finishInstallLog(logId, failure ?? (result && !result.ok ? result.message : undefined));
1191
+ }
1192
+ if (!result) {
1193
+ reply.code(500);
1194
+ return { status: 'error', code: 'internal', message: 'install returned no result' };
1195
+ }
498
1196
  if (!result.ok) {
499
1197
  const status = result.code === 'exists' || result.code === 'foreign' || result.code === 'confirm_required'
500
1198
  ? 409
@@ -506,120 +1204,228 @@ export function registerHarnessRoutes(app) {
506
1204
  }
507
1205
  return { status: 'ok', ...result };
508
1206
  });
509
- // Description translation (derived cache; the model call goes through this gateway's own /v1).
510
- // `format: 'markdown'` switches to the long-form contract: a README is a document, so it is
511
- // translated in chunked prose runs (fenced code preserved verbatim) under its own cache namespace
512
- // and a length budget — the description prompt would answer a 3 000-word page with two sentences.
513
- app.post('/api/admin/harness/translate', async (req, reply) => {
514
- const body = (req.body || {});
515
- const text = (body.text || '').trim();
516
- if (!text) {
517
- reply.code(400);
518
- return { status: 'error', code: 'bad_request', message: 'text is required' };
1207
+ /** Poll target for the install sheet: the child's mirrored stdout/stderr while POST /install runs. */
1208
+ app.get('/api/admin/harness/install-log/:id', async (req, reply) => {
1209
+ const { id } = req.params;
1210
+ const log = readInstallLog(id);
1211
+ if (!log) {
1212
+ reply.code(404);
1213
+ return { status: 'error', code: 'not_found', message: 'install log not found or expired' };
519
1214
  }
520
- if (!body.lang) {
1215
+ return { status: 'ok', ...log };
1216
+ });
1217
+ // System One default-model probe — the Settings "default model" card's second "test" button. Fires
1218
+ // the REAL /v1/systemone fallback path; with a pending selection it rides as an explicit
1219
+ // `model` through the surface's own admission gates.
1220
+ app.post('/api/admin/systemone/probe', async (req) => {
1221
+ const body = (req.body || {});
1222
+ return probeSystemoneDefault(typeof body.model === 'string' ? body.model : undefined);
1223
+ });
1224
+ // Execute a plan. 409 for every refusal — the plan is stale, unknown, or needs a discard flag.
1225
+ app.post('/api/admin/harness/apply', async (req, reply) => {
1226
+ const body = (req.body || {});
1227
+ if (!body.planId) {
521
1228
  reply.code(400);
522
- return { status: 'error', code: 'bad_request', message: 'lang is required' };
1229
+ return { status: 'error', code: 'bad_request', message: 'planId is required' };
523
1230
  }
524
- const result = body.format === 'markdown'
525
- ? await translateMarkdown(text, body.lang)
526
- : await translateDescription(text, body.lang);
527
- if ('code' in result) {
528
- reply.code(result.code === 'no_api_key' ? 409 : 502);
529
- return { status: 'error', ...result };
1231
+ const result = await applyRemove(body.planId, { discardLocalEdits: body.discardLocalEdits === true });
1232
+ if (!result.ok) {
1233
+ reply.code(409);
1234
+ return { status: 'error', code: result.code, message: result.message };
530
1235
  }
531
1236
  return { status: 'ok', ...result };
532
1237
  });
533
- // Batch translation. One chunk per call, small in-process pool: the console walks the list in
534
- // chunks so a slow tier never turns one request into a 60-second hang, and a dropped connection
535
- // resumes from the cache instead of losing everything.
536
- app.post('/api/admin/harness/translate-batch', async (req, reply) => {
537
- const body = (req.body || {});
538
- if (!body.lang || !Array.isArray(body.texts)) {
539
- reply.code(400);
540
- return { status: 'error', code: 'bad_request', message: 'lang and texts[] are required' };
541
- }
542
- const texts = [
543
- ...new Set(body.texts.filter((x) => typeof x === 'string' && x.trim().length > 0).map((x) => x.trim())),
544
- ].slice(0, 50);
545
- if (texts.length === 0)
546
- return { status: 'ok', results: {}, errors: [] };
547
- const results = {};
548
- const errors = [];
549
- let cursor = 0;
550
- const worker = async () => {
551
- while (cursor < texts.length) {
552
- const text = texts[cursor++];
553
- const result = await translateDescription(text, body.lang);
554
- if ('code' in result)
555
- errors.push({ text, code: result.code, message: result.message });
556
- else
557
- results[text] = result;
1238
+ const parseInspectTarget = (raw) => {
1239
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
1240
+ return { ok: false, code: 'bad_request', message: 'target object is required' };
1241
+ }
1242
+ const input = raw;
1243
+ if (input.mode === 'custom') {
1244
+ const transport = typeof input.transport === 'string' ? input.transport : 'stdio';
1245
+ if (transport === 'stdio') {
1246
+ const command = typeof input.command === 'string' ? input.command.trim() : '';
1247
+ if (!command)
1248
+ return { ok: false, code: 'bad_request', message: 'command is required' };
1249
+ const args = Array.isArray(input.args) ? input.args.filter((a) => typeof a === 'string') : [];
1250
+ const env = input.env && typeof input.env === 'object' && !Array.isArray(input.env)
1251
+ ? Object.fromEntries(Object.entries(input.env).filter((kv) => typeof kv[1] === 'string'))
1252
+ : undefined;
1253
+ const cwd = typeof input.cwd === 'string' && input.cwd.trim() ? input.cwd.trim() : undefined;
1254
+ return {
1255
+ ok: true,
1256
+ target: { mode: 'custom', transport: 'stdio', command, args, ...(env ? { env } : {}), ...(cwd ? { cwd } : {}) },
1257
+ };
558
1258
  }
559
- };
560
- await Promise.all(Array.from({ length: Math.min(3, texts.length) }, worker));
561
- // No key = every item fails the same way; say it once instead of 50 identical rows.
562
- if (errors.length === texts.length && errors.every((e) => e.code === 'no_api_key')) {
563
- reply.code(409);
564
- return { status: 'error', code: 'no_api_key', message: errors[0].message };
1259
+ if (transport === 'auto' || transport === 'streamable-http' || transport === 'sse') {
1260
+ const url = typeof input.url === 'string' ? input.url.trim() : '';
1261
+ if (!url)
1262
+ return { ok: false, code: 'bad_request', message: 'url is required' };
1263
+ const headers = input.headers && typeof input.headers === 'object' && !Array.isArray(input.headers)
1264
+ ? Object.fromEntries(Object.entries(input.headers).filter((kv) => typeof kv[1] === 'string'))
1265
+ : undefined;
1266
+ return {
1267
+ ok: true,
1268
+ target: { mode: 'custom', transport, url, ...(headers ? { headers } : {}) },
1269
+ };
1270
+ }
1271
+ return { ok: false, code: 'bad_request', message: `unsupported transport '${transport}'` };
565
1272
  }
566
- return { status: 'ok', results, errors };
567
- });
568
- // Cache-only lookup: the console seeds every already-translated description on mount, no spend.
569
- app.post('/api/admin/harness/translations', async (req, reply) => {
570
- const body = (req.body || {});
571
- if (!body.lang || !Array.isArray(body.texts)) {
572
- reply.code(400);
573
- return { status: 'error', code: 'bad_request', message: 'lang and texts[] are required' };
1273
+ const host = typeof input.host === 'string' ? input.host : '';
1274
+ const name = typeof input.name === 'string' ? input.name : '';
1275
+ if (!host || !name) {
1276
+ return { ok: false, code: 'bad_request', message: 'host and name are required' };
1277
+ }
1278
+ if (!HOSTS.some((h) => h.id === host)) {
1279
+ return { ok: false, code: 'bad_request', message: `unknown host '${host}'` };
1280
+ }
1281
+ const scope = typeof input.scope === 'string' ? input.scope : 'global';
1282
+ if (!isEnabledScope(scope)) {
1283
+ return {
1284
+ ok: false,
1285
+ code: 'unsupported_scope',
1286
+ message: `scope '${scope}' is not supported — reads target ${ENABLED_SCOPES.join(', ')} scope`,
1287
+ };
1288
+ }
1289
+ const root = resolveProjectRoot({ projectRoot: input.projectRoot, projectId: input.projectId }, { required: scope === 'project' });
1290
+ if (!root.ok) {
1291
+ return { ok: false, code: 'bad_request', message: root.message };
574
1292
  }
575
- const texts = body.texts
576
- .filter((x) => typeof x === 'string' && x.trim().length > 0)
577
- .slice(0, 500);
578
1293
  return {
579
- status: 'ok',
580
- translations: readCachedTranslations(texts, body.lang, body.format === 'markdown' ? 'readme' : 'descriptions'),
1294
+ ok: true,
1295
+ target: {
1296
+ mode: 'host',
1297
+ host: host,
1298
+ scope,
1299
+ name,
1300
+ ...(root.projectRoot ? { projectRoot: root.projectRoot } : {}),
1301
+ },
1302
+ };
1303
+ };
1304
+ const inspectErrorReply = (reply, err) => {
1305
+ const e = err;
1306
+ const status = e.code === 'not_found' ? 404 : e.code === 'bad_request' || e.code === 'unsupported_scope' ? 400 : 502;
1307
+ reply.code(status);
1308
+ return {
1309
+ status: 'error',
1310
+ code: e.code ?? 'inspect_failed',
1311
+ message: e instanceof Error ? e.message : String(err),
581
1312
  };
1313
+ };
1314
+ app.post('/api/admin/harness/mcp/inspect', async (req, reply) => {
1315
+ const body = (req.body || {});
1316
+ const rawTarget = body.target ?? body;
1317
+ const parsed = parseInspectTarget(rawTarget);
1318
+ if (!parsed.ok) {
1319
+ reply.code(400);
1320
+ return { status: 'error', code: parsed.code, message: parsed.message };
1321
+ }
1322
+ try {
1323
+ const snapshot = await inspectMcpServer(parsed.target, { refresh: body.refresh === true });
1324
+ return { status: 'ok', ...snapshot };
1325
+ }
1326
+ catch (err) {
1327
+ return inspectErrorReply(reply, err);
1328
+ }
582
1329
  });
583
- // Housekeeping on the derived translation store: age expiry, then oldest-first trimming under the
584
- // size budget. Writes sweep on a throttle; this is the manual lever for an operator (or a future
585
- // console button) that wants it now. Nothing here is correctness-bearing — the cache is derived.
586
- app.post('/api/admin/harness/translations/prune', async (req) => {
1330
+ app.post('/api/admin/harness/mcp/disconnect', async (req, reply) => {
587
1331
  const body = (req.body || {});
588
- const maxAgeDays = typeof body.maxAgeDays === 'number' ? body.maxAgeDays : undefined;
589
- const maxBytes = typeof body.maxBytes === 'number' ? body.maxBytes : undefined;
590
- const stats = pruneTranslationStore({
591
- ...(maxAgeDays !== undefined ? { maxAgeMs: Math.max(maxAgeDays, 0) * 24 * 60 * 60 * 1000 } : {}),
592
- ...(maxBytes !== undefined ? { maxBytes: Math.max(maxBytes, 0) } : {}),
593
- });
594
- return { status: 'ok', ...stats };
1332
+ if (typeof body.sessionId !== 'string' || !body.sessionId.trim()) {
1333
+ reply.code(400);
1334
+ return { status: 'error', code: 'bad_request', message: 'sessionId is required' };
1335
+ }
1336
+ const closed = await disconnectMcpSession(body.sessionId.trim());
1337
+ return { status: 'ok', closed };
595
1338
  });
596
- // Chain probe behind the console's default-model "test" buttons. `model` in the body carries the
597
- // PICKER'S PENDING value (test BEFORE save; empty string = "as if unset"); absent → the saved
598
- // config. Both probes under one diagnostic contract: explicit click = explicit one-call spend,
599
- // honest verdicts, nothing persisted by the probe itself.
600
- app.post('/api/admin/harness/translations/probe', async (req) => {
1339
+ app.post('/api/admin/harness/mcp/call-tool', async (req, reply) => {
601
1340
  const body = (req.body || {});
602
- return probeTranslationChain(typeof body.lang === 'string' ? body.lang : 'en', typeof body.model === 'string' ? body.model : undefined);
1341
+ if (typeof body.toolName !== 'string' || !body.toolName.trim()) {
1342
+ reply.code(400);
1343
+ return { status: 'error', code: 'bad_request', message: 'toolName is required' };
1344
+ }
1345
+ let target;
1346
+ if (body.target !== undefined) {
1347
+ const parsed = parseInspectTarget(body.target);
1348
+ if (!parsed.ok) {
1349
+ reply.code(400);
1350
+ return { status: 'error', code: parsed.code, message: parsed.message };
1351
+ }
1352
+ target = parsed.target;
1353
+ }
1354
+ const args = body.arguments && typeof body.arguments === 'object' && !Array.isArray(body.arguments)
1355
+ ? body.arguments
1356
+ : {};
1357
+ try {
1358
+ const result = await callMcpTool({
1359
+ ...(typeof body.sessionId === 'string' && body.sessionId ? { sessionId: body.sessionId } : {}),
1360
+ ...(target ? { target } : {}),
1361
+ toolName: body.toolName.trim(),
1362
+ arguments: args,
1363
+ ...(typeof body.timeoutMs === 'number' ? { timeoutMs: body.timeoutMs } : {}),
1364
+ });
1365
+ return { status: 'ok', ...result };
1366
+ }
1367
+ catch (err) {
1368
+ return inspectErrorReply(reply, err);
1369
+ }
603
1370
  });
604
- // System One default-model probe — the Settings "默认模型" card's second "test" button. Fires
605
- // the REAL /v1/systemone fallback path; with a pending selection it rides as an explicit
606
- // `model` through the surface's own admission gates.
607
- app.post('/api/admin/systemone/probe', async (req) => {
1371
+ app.post('/api/admin/harness/mcp/read-resource', async (req, reply) => {
608
1372
  const body = (req.body || {});
609
- return probeSystemoneDefault(typeof body.model === 'string' ? body.model : undefined);
1373
+ if (typeof body.uri !== 'string' || !body.uri.trim()) {
1374
+ reply.code(400);
1375
+ return { status: 'error', code: 'bad_request', message: 'uri is required' };
1376
+ }
1377
+ let target;
1378
+ if (body.target !== undefined) {
1379
+ const parsed = parseInspectTarget(body.target);
1380
+ if (!parsed.ok) {
1381
+ reply.code(400);
1382
+ return { status: 'error', code: parsed.code, message: parsed.message };
1383
+ }
1384
+ target = parsed.target;
1385
+ }
1386
+ try {
1387
+ const result = await readMcpResource({
1388
+ ...(typeof body.sessionId === 'string' && body.sessionId ? { sessionId: body.sessionId } : {}),
1389
+ ...(target ? { target } : {}),
1390
+ uri: body.uri.trim(),
1391
+ ...(typeof body.timeoutMs === 'number' ? { timeoutMs: body.timeoutMs } : {}),
1392
+ });
1393
+ return { status: 'ok', ...result };
1394
+ }
1395
+ catch (err) {
1396
+ return inspectErrorReply(reply, err);
1397
+ }
610
1398
  });
611
- // Execute a plan. 409 for every refusal — the plan is stale, unknown, or needs a discard flag.
612
- app.post('/api/admin/harness/apply', async (req, reply) => {
1399
+ app.post('/api/admin/harness/mcp/get-prompt', async (req, reply) => {
613
1400
  const body = (req.body || {});
614
- if (!body.planId) {
1401
+ if (typeof body.promptName !== 'string' || !body.promptName.trim()) {
615
1402
  reply.code(400);
616
- return { status: 'error', code: 'bad_request', message: 'planId is required' };
1403
+ return { status: 'error', code: 'bad_request', message: 'promptName is required' };
617
1404
  }
618
- const result = applyRemove(body.planId, { discardLocalEdits: body.discardLocalEdits === true });
619
- if (!result.ok) {
620
- reply.code(409);
621
- return { status: 'error', code: result.code, message: result.message };
1405
+ let target;
1406
+ if (body.target !== undefined) {
1407
+ const parsed = parseInspectTarget(body.target);
1408
+ if (!parsed.ok) {
1409
+ reply.code(400);
1410
+ return { status: 'error', code: parsed.code, message: parsed.message };
1411
+ }
1412
+ target = parsed.target;
1413
+ }
1414
+ const args = body.arguments && typeof body.arguments === 'object' && !Array.isArray(body.arguments)
1415
+ ? Object.fromEntries(Object.entries(body.arguments).filter((kv) => typeof kv[1] === 'string'))
1416
+ : undefined;
1417
+ try {
1418
+ const result = await getMcpPrompt({
1419
+ ...(typeof body.sessionId === 'string' && body.sessionId ? { sessionId: body.sessionId } : {}),
1420
+ ...(target ? { target } : {}),
1421
+ promptName: body.promptName.trim(),
1422
+ ...(args ? { arguments: args } : {}),
1423
+ ...(typeof body.timeoutMs === 'number' ? { timeoutMs: body.timeoutMs } : {}),
1424
+ });
1425
+ return { status: 'ok', ...result };
1426
+ }
1427
+ catch (err) {
1428
+ return inspectErrorReply(reply, err);
622
1429
  }
623
- return { status: 'ok', ...result };
624
1430
  });
625
1431
  }