cartethyia 2.4.5 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (415) hide show
  1. package/.env.example +4 -1
  2. package/README.md +63 -13
  3. package/dist/dashboard/assets/AccountCooldown-ChpdzxRH.js.gz +0 -0
  4. package/dist/dashboard/assets/BannedPage-9igfctfZ.js +1 -0
  5. package/dist/dashboard/assets/BannedPage-9igfctfZ.js.gz +0 -0
  6. package/dist/dashboard/assets/{CliToolDetailPage-BzGevuql.js → CliToolDetailPage-ZRr2K2sF.js} +1 -1
  7. package/dist/dashboard/assets/CliToolDetailPage-ZRr2K2sF.js.gz +0 -0
  8. package/dist/dashboard/assets/{CliToolsPage-BaRM_7We.js → CliToolsPage-D3xqZbN-.js} +1 -1
  9. package/dist/dashboard/assets/CliToolsPage-D3xqZbN-.js.gz +0 -0
  10. package/dist/dashboard/assets/CombosPage-CVnQPBBz.js +1 -0
  11. package/dist/dashboard/assets/CombosPage-CVnQPBBz.js.gz +0 -0
  12. package/dist/dashboard/assets/ConsoleLogPage-u6W1UXSc.js +1 -0
  13. package/dist/dashboard/assets/ConsoleLogPage-u6W1UXSc.js.gz +0 -0
  14. package/dist/dashboard/assets/{CustomizationPage-DqUGcoH0.js → CustomizationPage-CTTpCb25.js} +1 -1
  15. package/dist/dashboard/assets/CustomizationPage-CTTpCb25.js.gz +0 -0
  16. package/dist/dashboard/assets/HealthEventsModal-C5XpWlvy.js +1 -0
  17. package/dist/dashboard/assets/HealthEventsModal-C5XpWlvy.js.gz +0 -0
  18. package/dist/dashboard/assets/{LoginPage-DbhTGfhb.js → LoginPage-DHoB3Agn.js} +1 -1
  19. package/dist/dashboard/assets/LoginPage-DHoB3Agn.js.gz +0 -0
  20. package/dist/dashboard/assets/ModelPicker-oQ-SDXp8.js +1 -0
  21. package/dist/dashboard/assets/ModelPicker-oQ-SDXp8.js.gz +0 -0
  22. package/dist/dashboard/assets/OverviewPage-BrY4SgIt.js +1 -0
  23. package/dist/dashboard/assets/OverviewPage-BrY4SgIt.js.gz +0 -0
  24. package/dist/dashboard/assets/ProviderDetailPage-D9VSt7T_.js +3 -0
  25. package/dist/dashboard/assets/ProviderDetailPage-D9VSt7T_.js.gz +0 -0
  26. package/dist/dashboard/assets/ProviderIcon-CmfzxpVM.js +1 -0
  27. package/dist/dashboard/assets/ProviderIcon-CmfzxpVM.js.gz +0 -0
  28. package/dist/dashboard/assets/ProvidersPage-Df77V5I5.js +1 -0
  29. package/dist/dashboard/assets/ProvidersPage-Df77V5I5.js.gz +0 -0
  30. package/dist/dashboard/assets/ProxyPage-CDfxP7AC.js +7 -0
  31. package/dist/dashboard/assets/ProxyPage-CDfxP7AC.js.gz +0 -0
  32. package/dist/dashboard/assets/QuotaPage-CY4o2t4p.js +1 -0
  33. package/dist/dashboard/assets/QuotaPage-CY4o2t4p.js.gz +0 -0
  34. package/dist/dashboard/assets/{SettingsPage-YxRml8AT.js → SettingsPage-CvjZxHE4.js} +1 -1
  35. package/dist/dashboard/assets/SettingsPage-CvjZxHE4.js.gz +0 -0
  36. package/dist/dashboard/assets/SetupPage-D3nza7LH.js +1 -0
  37. package/dist/dashboard/assets/SetupPage-D3nza7LH.js.gz +0 -0
  38. package/dist/dashboard/assets/{SortableList-Bol1ASmI.js → SortableList-Dtt12WT1.js} +1 -1
  39. package/dist/dashboard/assets/SortableList-Dtt12WT1.js.gz +0 -0
  40. package/dist/dashboard/assets/StudioPage-CbK3hXvU.js +31 -0
  41. package/dist/dashboard/assets/StudioPage-CbK3hXvU.js.gz +0 -0
  42. package/dist/dashboard/assets/ToolIcon-K1ckcDKg.js.gz +0 -0
  43. package/dist/dashboard/assets/UsagePage-BQlWbWg2.js +56 -0
  44. package/dist/dashboard/assets/UsagePage-BQlWbWg2.js.gz +0 -0
  45. package/dist/dashboard/assets/api-keys-BmDbsior.js +1 -0
  46. package/dist/dashboard/assets/api-keys-BmDbsior.js.gz +0 -0
  47. package/dist/dashboard/assets/app-BbpSarVV.css +2 -0
  48. package/dist/dashboard/assets/app-BbpSarVV.css.gz +0 -0
  49. package/dist/dashboard/assets/{app-BDJWMThu.js → app-C-Y4oZT0.js} +3 -3
  50. package/dist/dashboard/assets/app-C-Y4oZT0.js.gz +0 -0
  51. package/dist/dashboard/assets/arrow-left-CpBxkoxI.js.gz +0 -0
  52. package/dist/dashboard/assets/arrow-right-Dl5yKnp8.js.gz +0 -0
  53. package/dist/dashboard/assets/assert-BHfaei-X.js +1 -0
  54. package/dist/dashboard/assets/assert-BHfaei-X.js.gz +0 -0
  55. package/dist/dashboard/assets/backup-file-gdKIlg8U.js.gz +0 -0
  56. package/dist/dashboard/assets/{badge-BwmwEOgA.js → badge-DpXT4Ixt.js} +1 -1
  57. package/dist/dashboard/assets/badge-DpXT4Ixt.js.gz +0 -0
  58. package/dist/dashboard/assets/{banner-BKBfKTqn.js → banner-CSAAWLJv.js} +1 -1
  59. package/dist/dashboard/assets/banner-CSAAWLJv.js.gz +0 -0
  60. package/dist/dashboard/assets/brain-Cwed_72z.js.gz +0 -0
  61. package/dist/dashboard/assets/{card-BTdbRFFg.js → card-DEhRXXw4.js} +1 -1
  62. package/dist/dashboard/assets/card-DEhRXXw4.js.gz +0 -0
  63. package/dist/dashboard/assets/check-D69FzdvC.js.gz +0 -0
  64. package/dist/dashboard/assets/chevron-right-BXIy5l3h.js.gz +0 -0
  65. package/dist/dashboard/assets/circle-alert-CntYHV5v.js.gz +0 -0
  66. package/dist/dashboard/assets/circle-check-BU3v_mFW.js.gz +0 -0
  67. package/dist/dashboard/assets/cli-tools-B0wBq-RL.js +1 -0
  68. package/dist/dashboard/assets/cli-tools-B0wBq-RL.js.gz +0 -0
  69. package/dist/dashboard/assets/clipboard-button-DOo6EU8O.js +1 -0
  70. package/dist/dashboard/assets/clipboard-button-DOo6EU8O.js.gz +0 -0
  71. package/dist/dashboard/assets/cog-CdWhsajs.js.gz +0 -0
  72. package/dist/dashboard/assets/copy-ngmQ9zcZ.js.gz +0 -0
  73. package/dist/dashboard/assets/{dialog-iocKA3jr.js → dialog-BvQeBMfP.js} +1 -1
  74. package/dist/dashboard/assets/dialog-BvQeBMfP.js.gz +0 -0
  75. package/dist/dashboard/assets/dialog-actions-B1axpEg7.js.gz +0 -0
  76. package/dist/dashboard/assets/download-A0SW9OCW.js.gz +0 -0
  77. package/dist/dashboard/assets/download-dRFo5_Wu.js.gz +0 -0
  78. package/dist/dashboard/assets/{drawer-CDKOTZdY.js → drawer-CMwPXwQB.js} +1 -1
  79. package/dist/dashboard/assets/drawer-CMwPXwQB.js.gz +0 -0
  80. package/dist/dashboard/assets/entry-D4O2229X.js +1 -0
  81. package/dist/dashboard/assets/entry-D4O2229X.js.gz +0 -0
  82. package/dist/dashboard/assets/entry-DKvr5Q9K.js +1 -0
  83. package/dist/dashboard/assets/entry-DKvr5Q9K.js.gz +0 -0
  84. package/dist/dashboard/assets/entry-FQCejoDY.js +4 -0
  85. package/dist/dashboard/assets/entry-FQCejoDY.js.gz +0 -0
  86. package/dist/dashboard/assets/eye-C_hawfH4.js.gz +0 -0
  87. package/dist/dashboard/assets/eye-off-Bk5g2luF.js.gz +0 -0
  88. package/dist/dashboard/assets/fingerprint-pattern-BWuHtbW4.js.gz +0 -0
  89. package/dist/dashboard/assets/gauge-BbIMy7MB.js.gz +0 -0
  90. package/dist/dashboard/assets/github-badge-zliLvBwr.js +1 -0
  91. package/dist/dashboard/assets/github-badge-zliLvBwr.js.gz +0 -0
  92. package/dist/dashboard/assets/image-BPaouViG.js.gz +0 -0
  93. package/dist/dashboard/assets/{index-C4hXfAMs.js → index-CXm3FIyt.js} +2 -2
  94. package/dist/dashboard/assets/index-CXm3FIyt.js.gz +0 -0
  95. package/dist/dashboard/assets/{inline-DCejSLlA.js → inline-D1IlZZ8H.js} +1 -1
  96. package/dist/dashboard/assets/inline-D1IlZZ8H.js.gz +0 -0
  97. package/dist/dashboard/assets/{input-Bn4_kNav.js → input-BpVZdrbc.js} +1 -1
  98. package/dist/dashboard/assets/input-BpVZdrbc.js.gz +0 -0
  99. package/dist/dashboard/assets/jsx-runtime-CXUMngI_.js.gz +0 -0
  100. package/dist/dashboard/assets/key-round-UkavsGxp.js.gz +0 -0
  101. package/dist/dashboard/assets/layers-2-glBbjl.js.gz +0 -0
  102. package/dist/dashboard/assets/{layout-Bv-NxqZ5.js → layout-BioLW7gN.js} +1 -1
  103. package/dist/dashboard/assets/layout-BioLW7gN.js.gz +0 -0
  104. package/dist/dashboard/assets/{list-row-BLA0sldD.js → list-row-CwVcGAIc.js} +1 -1
  105. package/dist/dashboard/assets/list-row-CwVcGAIc.js.gz +0 -0
  106. package/dist/dashboard/assets/{live-YlifPYox.js → live-yfEJFF9T.js} +1 -1
  107. package/dist/dashboard/assets/live-yfEJFF9T.js.gz +0 -0
  108. package/dist/dashboard/assets/log-in-BmRjy60c.js.gz +0 -0
  109. package/dist/dashboard/assets/message-circle-CCxGwRvv.js.gz +0 -0
  110. package/dist/dashboard/assets/model-bans-CT-TxSNX.js +1 -0
  111. package/dist/dashboard/assets/model-bans-CT-TxSNX.js.gz +0 -0
  112. package/dist/dashboard/assets/mutation-BkoLM5Ba.js +1 -0
  113. package/dist/dashboard/assets/mutation-BkoLM5Ba.js.gz +0 -0
  114. package/dist/dashboard/assets/numbers-CFL4_Dqc.js.gz +0 -0
  115. package/dist/dashboard/assets/pencil-768ysRAr.js.gz +0 -0
  116. package/dist/dashboard/assets/plus-DIdX_g-x.js.gz +0 -0
  117. package/dist/dashboard/assets/power-off-Yjw9GMJh.js +1 -0
  118. package/dist/dashboard/assets/power-off-Yjw9GMJh.js.gz +0 -0
  119. package/dist/dashboard/assets/privacy-mode-GM8bej85.js +1 -0
  120. package/dist/dashboard/assets/privacy-mode-GM8bej85.js.gz +0 -0
  121. package/dist/dashboard/assets/providers/agentrouter.svg.gz +0 -0
  122. package/dist/dashboard/assets/providers/aihubmix.svg.gz +0 -0
  123. package/dist/dashboard/assets/providers/alibaba-coding-plan.svg.gz +0 -0
  124. package/dist/dashboard/assets/providers/alibaba.svg.gz +0 -0
  125. package/dist/dashboard/assets/providers/antigravity.svg.gz +0 -0
  126. package/dist/dashboard/assets/providers/bai.svg.gz +0 -0
  127. package/dist/dashboard/assets/providers/blackbox.svg.gz +0 -0
  128. package/dist/dashboard/assets/providers/claude-code.svg.gz +0 -0
  129. package/dist/dashboard/assets/providers/cursor.webp +0 -0
  130. package/dist/dashboard/assets/providers/exa.svg.gz +0 -0
  131. package/dist/dashboard/assets/providers/gmi-cloud.svg.gz +0 -0
  132. package/dist/dashboard/assets/providers/inferhub.svg.gz +0 -0
  133. package/dist/dashboard/assets/providers/muse.svg.gz +0 -0
  134. package/dist/dashboard/assets/providers/nous-research.svg.gz +0 -0
  135. package/dist/dashboard/assets/providers/openai-light.svg.gz +0 -0
  136. package/dist/dashboard/assets/providers/parallel.svg.gz +0 -0
  137. package/dist/dashboard/assets/providers/tokenharbor.svg.gz +0 -0
  138. package/dist/dashboard/assets/providers/trae.webp +0 -0
  139. package/dist/dashboard/assets/providers/zai-coding-plan.svg.gz +0 -0
  140. package/dist/dashboard/assets/{query-keys-ROf-g1Wi.js → query-keys-D7wX2vM5.js} +1 -1
  141. package/dist/dashboard/assets/query-keys-D7wX2vM5.js.gz +0 -0
  142. package/dist/dashboard/assets/quota-DZGyp0N5.js.gz +0 -0
  143. package/dist/dashboard/assets/refresh-cw-BqJFk4sU.js.gz +0 -0
  144. package/dist/dashboard/assets/rotate-ccw-CufcqITi.js.gz +0 -0
  145. package/dist/dashboard/assets/route-CNSNj9Zm.js.gz +0 -0
  146. package/dist/dashboard/assets/routing-Cs6jl49L.js +1 -0
  147. package/dist/dashboard/assets/routing-Cs6jl49L.js.gz +0 -0
  148. package/dist/dashboard/assets/scaling-nWE4Cx8f.js.gz +0 -0
  149. package/dist/dashboard/assets/search-JOKus9rb.js.gz +0 -0
  150. package/dist/dashboard/assets/select-C0Rer3gF.js +41 -0
  151. package/dist/dashboard/assets/select-C0Rer3gF.js.gz +0 -0
  152. package/dist/dashboard/assets/settings-CfcTcOyU.js +1 -0
  153. package/dist/dashboard/assets/settings-CfcTcOyU.js.gz +0 -0
  154. package/dist/dashboard/assets/shield-check-DVS0Foqh.js.gz +0 -0
  155. package/dist/dashboard/assets/sparkles-BRaRUxAU.js.gz +0 -0
  156. package/dist/dashboard/assets/{stack-C1kTcOmP.js → stack-C9_uUjaA.js} +1 -1
  157. package/dist/dashboard/assets/stack-C9_uUjaA.js.gz +0 -0
  158. package/dist/dashboard/assets/{state-DHKdg-pm.js → state-DA0B95UQ.js} +1 -1
  159. package/dist/dashboard/assets/state-DA0B95UQ.js.gz +0 -0
  160. package/dist/dashboard/assets/stream-retry-5QnVuSSo.js.gz +0 -0
  161. package/dist/dashboard/assets/{switch-DIDeAiz9.js → switch-Cittxy-x.js} +1 -1
  162. package/dist/dashboard/assets/switch-Cittxy-x.js.gz +0 -0
  163. package/dist/dashboard/assets/terminal-Bd4ee8TA.js +1 -0
  164. package/dist/dashboard/assets/terminal-Bd4ee8TA.js.gz +0 -0
  165. package/dist/dashboard/assets/toast-CNt_jzO4.js +2 -0
  166. package/dist/dashboard/assets/toast-CNt_jzO4.js.gz +0 -0
  167. package/dist/dashboard/assets/tokens-DDxMbSRL.js.gz +0 -0
  168. package/dist/dashboard/assets/trash-Cppn5c3R.js.gz +0 -0
  169. package/dist/dashboard/assets/use-clipboard-B0Sy03fE.js.gz +0 -0
  170. package/dist/dashboard/assets/use-presence-BSZEBx7U.js.gz +0 -0
  171. package/dist/dashboard/assets/use-reduced-motion-C4B0R6Sz.js.gz +0 -0
  172. package/dist/dashboard/assets/use-timeout-BwcBBRrT.js.gz +0 -0
  173. package/dist/dashboard/assets/{useMutation-DVmwOKU-.js → useMutation-BQKMcJ1H.js} +1 -1
  174. package/dist/dashboard/assets/useMutation-BQKMcJ1H.js.gz +0 -0
  175. package/dist/dashboard/assets/wrench-B6E1oEuY.js.gz +0 -0
  176. package/dist/dashboard/index.html +1 -1
  177. package/dist/dashboard/index.html.gz +0 -0
  178. package/dist/dashboard/precompressed-assets.json +122 -0
  179. package/migrations/full-postgres/0013_add_providers_tenant_id_index.sql +22 -0
  180. package/migrations/full-postgres/0014_add_provider_accounts_tenant_id_index.sql +21 -0
  181. package/migrations/full-postgres/0015_add_payload_stages.sql +18 -0
  182. package/migrations/full-postgres/0016_add_share_link_slug.sql +20 -0
  183. package/migrations/full-postgres/0017_add_models_pro_only.sql +18 -0
  184. package/migrations/full-postgres/0018_add_accounts_quota_plan.sql +18 -0
  185. package/migrations/full-postgres/0019_add_models_free_tier.sql +15 -0
  186. package/migrations/lite-sqlite3/0000_baseline.sql +4 -2
  187. package/migrations/lite-sqlite3/0013_add_providers_tenant_id_index.sql +4 -0
  188. package/migrations/lite-sqlite3/0014_add_provider_accounts_tenant_id_index.sql +4 -0
  189. package/migrations/lite-sqlite3/0015_add_payload_stages.sql +18 -0
  190. package/migrations/lite-sqlite3/0016_add_share_link_slug.sql +20 -0
  191. package/migrations/lite-sqlite3/0017_add_models_pro_only.sql +18 -0
  192. package/migrations/lite-sqlite3/0018_add_accounts_quota_plan.sql +18 -0
  193. package/migrations/lite-sqlite3/0019_add_models_free_tier.sql +15 -0
  194. package/package.json +26 -30
  195. package/scripts/cli/{carte-launcher.cjs → bin/carte.cjs} +8 -8
  196. package/scripts/cli/{cli-launcher.cjs → bin/cartethyia.cjs} +167 -134
  197. package/scripts/cli/command/admin.ts +65 -0
  198. package/scripts/cli/command/console-menu.ts +246 -0
  199. package/scripts/cli/{doctor.ts → command/doctor.ts} +257 -258
  200. package/scripts/cli/{setup.ts → command/setup.ts} +8 -12
  201. package/scripts/cli/command/start.ts +77 -0
  202. package/scripts/cli/command/tray.ts +165 -0
  203. package/scripts/cli/command/update.ts +23 -0
  204. package/scripts/cli/{runtime-state.ts → gateway/drain-token.ts} +78 -78
  205. package/scripts/cli/gateway/instance-lock.ts +105 -0
  206. package/scripts/cli/gateway/spawn.ts +173 -0
  207. package/scripts/cli/gateway/stop.ts +51 -0
  208. package/scripts/cli/main.ts +94 -0
  209. package/scripts/cli/support/bun.ts +27 -0
  210. package/scripts/cli/support/env.ts +99 -0
  211. package/scripts/cli/support/platform.ts +64 -0
  212. package/scripts/cli/support/services.ts +88 -0
  213. package/scripts/cli/support/startup-signal.ts +23 -0
  214. package/scripts/cli/{version.ts → support/version.ts} +1 -1
  215. package/scripts/cli/tray/hidden-window.vbs +28 -0
  216. package/scripts/cli/{tray.ts → tray/index.ts} +3 -3
  217. package/scripts/cli/{tray.ps1 → tray/windows.ps1} +107 -98
  218. package/scripts/cli/ui/background.ts +110 -0
  219. package/src/boot/app.ts +23 -7
  220. package/src/boot/dependencies.ts +55 -13
  221. package/src/boot/elysia-typebox-bridge.ts +37 -0
  222. package/src/boot/lifecycle.ts +2 -0
  223. package/src/config/cooldowns.ts +138 -138
  224. package/src/config/providers.ts +31 -5
  225. package/src/config/runtime.ts +19 -3
  226. package/src/config/spec.ts +20 -0
  227. package/src/console/api-keys/contracts.ts +414 -391
  228. package/src/console/api-keys/routes.ts +880 -870
  229. package/src/console/auth/account-reset-store.ts +14 -0
  230. package/src/console/auth/account-reset.ts +3 -2
  231. package/src/console/auth/setup-service.ts +6 -3
  232. package/src/console/backup/routes.ts +8 -0
  233. package/src/console/cli-tools/contracts.ts +6 -6
  234. package/src/console/console-router.ts +5 -3
  235. package/src/console/dashboard-assets.ts +81 -11
  236. package/src/console/domain-registration.ts +9 -2
  237. package/src/console/observability/contracts.ts +475 -423
  238. package/src/console/observability/routes.ts +31 -6
  239. package/src/console/observability/store.ts +1015 -912
  240. package/src/console/providers/catalog/contracts.ts +31 -0
  241. package/src/console/providers/catalog/provider-operations.ts +8 -0
  242. package/src/console/providers/catalog/public-model-store.ts +91 -60
  243. package/src/console/providers/catalog/store.ts +1532 -1521
  244. package/src/console/providers/oauth/callback-listener.ts +18 -3
  245. package/src/console/providers/oauth/routes.ts +38 -15
  246. package/src/console/quota/account-quota-tenant.ts +9 -6
  247. package/src/console/quota/refresh.ts +19 -0
  248. package/src/console/response-compression.ts +69 -2
  249. package/src/console/routing/pools/probe-verdict.ts +72 -0
  250. package/src/console/share/share-router.ts +7 -4
  251. package/src/console/share/share-stats.ts +12 -5
  252. package/src/console/shared/read-through-cache.ts +133 -7
  253. package/src/console/updates/repository-updates.ts +39 -34
  254. package/src/console/updates/routes.ts +162 -4
  255. package/src/main.ts +3 -0
  256. package/src/network/http2-bidi.ts +85 -0
  257. package/src/network/outbound-fetch.ts +87 -24
  258. package/src/network/pool/agent.ts +478 -460
  259. package/src/network/pool/resolver.ts +1104 -544
  260. package/src/network/pool-health-machine.ts +12 -5
  261. package/src/observability/event-log.ts +29 -8
  262. package/src/observability/metrics.ts +40 -13
  263. package/src/observability/payload-capture.ts +344 -324
  264. package/src/observability/runtime-metrics.ts +7 -0
  265. package/src/persistence/db-pg.ts +9 -3
  266. package/src/persistence/db-sqlite.ts +497 -495
  267. package/src/persistence/health-event-flush.ts +137 -0
  268. package/src/persistence/migrate.ts +181 -129
  269. package/src/persistence/schema.ts +1360 -1257
  270. package/src/persistence/settings-revision.ts +25 -0
  271. package/src/persistence/shared-cache.ts +217 -0
  272. package/src/persistence/stores/share-store.ts +556 -528
  273. package/src/persistence/usage-flush.ts +61 -1
  274. package/src/protocol/canonical-model.ts +23 -1
  275. package/src/protocol/response/chat.ts +143 -10
  276. package/src/protocol/response/codex.ts +9 -75
  277. package/src/protocol/response/omp-tool-call-markup.ts +221 -0
  278. package/src/protocol/tool-identity.ts +43 -9
  279. package/src/providers/authentication/jwt-validator.ts +130 -187
  280. package/src/providers/authentication/oauth-flow-store.ts +16 -9
  281. package/src/providers/default-registry.ts +177 -1
  282. package/src/providers/discovery/catalog/catalog-format.ts +20 -0
  283. package/src/providers/discovery/models-dev-catalog.ts +39 -22
  284. package/src/providers/discovery/openai-model-discovery.ts +39 -3
  285. package/src/providers/discovery/openrouter-free-roster.ts +98 -0
  286. package/src/providers/discovery/probe-wire.ts +29 -5
  287. package/src/providers/discovery/probing-service.ts +1022 -1001
  288. package/src/providers/integrations/buddy/buddy-catalog-shared.ts +42 -2
  289. package/src/providers/integrations/buddy/buddy-chat-shared.ts +913 -914
  290. package/src/providers/integrations/buddy/buddy-cli-headers.ts +88 -0
  291. package/src/providers/integrations/buddy/buddy-conversation-headers.ts +22 -5
  292. package/src/providers/integrations/buddy/buddy-discovery-shared.ts +33 -1
  293. package/src/providers/integrations/buddy/buddy-identity.ts +46 -0
  294. package/src/providers/integrations/buddy/buddy-oauth-shared.ts +37 -1
  295. package/src/providers/integrations/buddy/buddy-usage-store.ts +40 -5
  296. package/src/providers/integrations/buddy/codebuddy/cn-provider.ts +4 -0
  297. package/src/providers/integrations/buddy/codebuddy/provider.ts +180 -175
  298. package/src/providers/integrations/buddy/codebuddy/shared.ts +115 -73
  299. package/src/providers/integrations/buddy/workbuddy/cn-provider.ts +5 -2
  300. package/src/providers/integrations/buddy/workbuddy/provider.ts +206 -204
  301. package/src/providers/integrations/buddy/workbuddy/quota.ts +172 -159
  302. package/src/providers/integrations/buddy/workbuddy/shared.ts +200 -171
  303. package/src/providers/integrations/claude/claude.ts +606 -582
  304. package/src/providers/integrations/cline/cline-quota.ts +18 -16
  305. package/src/providers/integrations/cline/cline.ts +539 -468
  306. package/src/providers/integrations/codex/codex.ts +5 -8
  307. package/src/providers/integrations/commandcode/commandcode.ts +675 -541
  308. package/src/providers/integrations/commandcode/discovery.ts +116 -0
  309. package/src/providers/integrations/commandcode/quota.ts +160 -0
  310. package/src/providers/integrations/cursor/cursor-auth.ts +418 -0
  311. package/src/providers/integrations/cursor/cursor-catalog.ts +368 -0
  312. package/src/providers/integrations/cursor/cursor-http2.ts +300 -0
  313. package/src/providers/integrations/cursor/cursor-identity.ts +92 -0
  314. package/src/providers/integrations/cursor/cursor-request.ts +471 -0
  315. package/src/providers/integrations/cursor/cursor-session-manager.ts +281 -0
  316. package/src/providers/integrations/cursor/cursor-shared.ts +108 -0
  317. package/src/providers/integrations/cursor/cursor.ts +960 -0
  318. package/src/providers/integrations/cursor/protocol/framing.ts +129 -0
  319. package/src/providers/integrations/cursor/protocol/messages.ts +2355 -0
  320. package/src/providers/integrations/cursor/protocol/struct.ts +305 -0
  321. package/src/providers/integrations/factory/factory-oauth.ts +7 -11
  322. package/src/providers/integrations/github/github.ts +4 -4
  323. package/src/providers/integrations/hermes.ts +79 -8
  324. package/src/providers/integrations/kilo/kilo-discovery.ts +10 -1
  325. package/src/providers/integrations/kilo/kilo.ts +153 -146
  326. package/src/providers/integrations/opencode/opencode-go-quota.ts +130 -0
  327. package/src/providers/integrations/opencode/provider.ts +532 -499
  328. package/src/providers/integrations/openrouter/provider.ts +139 -281
  329. package/src/providers/integrations/qoder/qoder-catalog.ts +450 -0
  330. package/src/providers/integrations/qoder/qoder-oauth.ts +310 -263
  331. package/src/providers/integrations/qoder/qoder-realm.ts +106 -0
  332. package/src/providers/integrations/qoder/qoder-virtual.ts +77 -0
  333. package/src/providers/integrations/qoder/qoder.ts +865 -730
  334. package/src/providers/integrations/shared/install-id.ts +29 -2
  335. package/src/providers/integrations/trae/trae-catalog.ts +190 -0
  336. package/src/providers/integrations/trae/trae-headers.ts +149 -0
  337. package/src/providers/integrations/trae/trae-oauth.ts +773 -0
  338. package/src/providers/integrations/trae/trae-protocol.ts +400 -0
  339. package/src/providers/integrations/trae/trae-realm.ts +220 -0
  340. package/src/providers/integrations/trae/trae.ts +458 -0
  341. package/src/providers/operations/account-health-service.ts +107 -10
  342. package/src/providers/operations/client-versions.ts +143 -6
  343. package/src/providers/operations/model-catalog-cache.ts +18 -3
  344. package/src/providers/operations/provider-catalog-seeder.ts +95 -86
  345. package/src/providers/operations/provider-catalog-service.ts +76 -0
  346. package/src/providers/operations/provider-credential-service.ts +46 -7
  347. package/src/providers/provider-contracts.ts +76 -0
  348. package/src/providers/provider-metadata.ts +78 -6
  349. package/src/providers/provider-model-definition.ts +373 -349
  350. package/src/security/api-key-auth.ts +126 -8
  351. package/src/transport/contracts.ts +3 -0
  352. package/src/transport/dispatch/attempt-finalize.ts +39 -2
  353. package/src/transport/dispatch/attempt-loop.ts +530 -513
  354. package/src/transport/dispatch/empty-stream.ts +17 -26
  355. package/src/transport/dispatch/generation.ts +88 -21
  356. package/src/transport/dispatch/leases.ts +99 -2
  357. package/src/transport/dispatch/proxy-request.ts +60 -3
  358. package/src/transport/dispatch/streaming/finalize.ts +16 -1
  359. package/src/transport/dispatch/streaming/stream.ts +22 -2
  360. package/src/transport/dispatch/upstream.ts +19 -1
  361. package/src/transport/failure-policy.ts +20 -0
  362. package/src/transport/guards/auth-guard.ts +26 -1
  363. package/src/transport/guards/body-policy.ts +5 -4
  364. package/src/transport/request/preparer.ts +103 -0
  365. package/src/transport/request/state.ts +14 -0
  366. package/src/transport/routing/plan-gate.ts +45 -0
  367. package/src/transport/routing/route-catalog.ts +799 -738
  368. package/src/transport/routing/route-model.ts +52 -1
  369. package/src/transport/routing/router.ts +51 -0
  370. package/src/transport/surface/chat/encode.ts +18 -31
  371. package/src/transport/surface/messages/stream.ts +3 -2
  372. package/src/transport/translation/tool-repair.ts +37 -16
  373. package/src/workers/account-identity-sweep.ts +14 -12
  374. package/src/workers/daily-checkin.ts +62 -0
  375. package/src/workers/quota-refresh-sweep.ts +27 -2
  376. package/dist/dashboard/assets/BannedPage-DUrXpp-X.js +0 -1
  377. package/dist/dashboard/assets/CombosPage-B7ETkfVH.js +0 -1
  378. package/dist/dashboard/assets/ConsoleLogPage-AisQzCI1.js +0 -1
  379. package/dist/dashboard/assets/HealthEventsModal-BNflDm_f.js +0 -1
  380. package/dist/dashboard/assets/ModelPicker-CAiPR5Vd.js +0 -1
  381. package/dist/dashboard/assets/OverviewPage-C3NIzsDx.js +0 -1
  382. package/dist/dashboard/assets/ProviderDetailPage-BK8i5B5X.js +0 -3
  383. package/dist/dashboard/assets/ProviderIcon-paOCq8I0.js +0 -1
  384. package/dist/dashboard/assets/ProvidersPage-CvCVgm1e.js +0 -1
  385. package/dist/dashboard/assets/ProxyPage-DjabkuzP.js +0 -7
  386. package/dist/dashboard/assets/QuotaPage-Dxe0B0iu.js +0 -1
  387. package/dist/dashboard/assets/SetupPage-BaD4P_jW.js +0 -1
  388. package/dist/dashboard/assets/StudioPage-CLP4le3U.js +0 -31
  389. package/dist/dashboard/assets/UsagePage-Djes-Epy.js +0 -56
  390. package/dist/dashboard/assets/api-keys-CjIGQhe7.js +0 -1
  391. package/dist/dashboard/assets/app-Cjgo4-Lf.css +0 -2
  392. package/dist/dashboard/assets/assert-Bwh6DJTK.js +0 -1
  393. package/dist/dashboard/assets/cli-tools-DccaOfhX.js +0 -1
  394. package/dist/dashboard/assets/clipboard-button-DQmMikNQ.js +0 -1
  395. package/dist/dashboard/assets/entry-Cpi0rph1.js +0 -4
  396. package/dist/dashboard/assets/entry-Dm3PpDCO.js +0 -1
  397. package/dist/dashboard/assets/entry-keNDZ_Wz.js +0 -1
  398. package/dist/dashboard/assets/github-badge-BuAJr8oU.js +0 -1
  399. package/dist/dashboard/assets/model-bans-CVvHZ-qz.js +0 -1
  400. package/dist/dashboard/assets/mutation-BIizFZav.js +0 -1
  401. package/dist/dashboard/assets/privacy-mode-CQjbZ3xk.js +0 -1
  402. package/dist/dashboard/assets/routing-jntw9-Ui.js +0 -1
  403. package/dist/dashboard/assets/select-CGUuTQmj.js +0 -41
  404. package/dist/dashboard/assets/settings-BAS6QbmJ.js +0 -1
  405. package/dist/dashboard/assets/sliders-horizontal-ClG7dBeJ.js +0 -1
  406. package/dist/dashboard/assets/terminal-C9mZ4Ugm.js +0 -1
  407. package/dist/dashboard/assets/toast-DKAdP2mo.js +0 -2
  408. package/scripts/cli/cli.ts +0 -771
  409. package/scripts/operations/probe-egress.ts +0 -335
  410. package/scripts/operations/restart.ts +0 -120
  411. package/scripts/shared/env.ts +0 -269
  412. /package/{tray-assets → scripts/cli/tray/assets}/cartethyia.ico +0 -0
  413. /package/{tray-assets → scripts/cli/tray/assets}/cartethyia.png +0 -0
  414. /package/scripts/cli/{menu.ts → ui/prompt.ts} +0 -0
  415. /package/scripts/cli/{wordmark.ts → ui/wordmark.ts} +0 -0
@@ -0,0 +1,305 @@
1
+ /**
2
+ * Vendored from `cursor-opencode-provider` (protocol layer only).
3
+ *
4
+ * MIT License
5
+ *
6
+ * Copyright (c) 2026 Oleksiy Akimov
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+
27
+ // Minimal encoder for google.protobuf.Value / Struct / ListValue.
28
+ //
29
+ // Cursor's per-turn tool descriptors carry the tool `input_schema` (a JSON
30
+ // Schema object) as a `google.protobuf.Value` whose `struct_value` holds the
31
+ // schema — NOT a JSON string. Verified against a live capture
32
+ // (request_context #7 → McpToolDefinition #3):
33
+ // 2a 9a07 0a10 0a04 74797065 1208 1a06 6f626a656374 ...
34
+ // = Value{#5 struct_value: Struct{#1 fields: {"type": Value{#3 string "object"}}}}
35
+ //
36
+ // Field numbers (well-known types):
37
+ // Value: 1 null_value, 2 number_value(double), 3 string_value,
38
+ // 4 bool_value, 5 struct_value(Struct), 6 list_value(ListValue)
39
+ // Struct: 1 fields (map<string, Value>) — each entry msg{1 key, 2 value}
40
+ // ListValue: 1 values (repeated Value)
41
+
42
+ function writeVarint(out: number[], n: number): void {
43
+ let v = n >>> 0
44
+ while (v > 0x7f) {
45
+ out.push((v & 0x7f) | 0x80)
46
+ v >>>= 7
47
+ }
48
+ out.push(v)
49
+ }
50
+
51
+ function writeTag(out: number[], field: number, wire: number): void {
52
+ writeVarint(out, (field << 3) | wire)
53
+ }
54
+
55
+ function writeLengthDelimited(out: number[], field: number, bytes: Uint8Array): void {
56
+ writeTag(out, field, 2)
57
+ writeVarint(out, bytes.length)
58
+ for (let i = 0; i < bytes.length; i++) out.push(bytes[i] ?? 0)
59
+ }
60
+
61
+ function writeString(out: number[], field: number, str: string): void {
62
+ writeLengthDelimited(out, field, new TextEncoder().encode(str))
63
+ }
64
+
65
+ function writeDouble(out: number[], field: number, num: number): void {
66
+ writeTag(out, field, 1) // 64-bit
67
+ const buf = new ArrayBuffer(8)
68
+ new DataView(buf).setFloat64(0, num, true) // little-endian
69
+ const view = new Uint8Array(buf)
70
+ for (let i = 0; i < 8; i++) out.push(view[i] ?? 0)
71
+ }
72
+
73
+ // ── Decoding (reverse): google.protobuf.Value bytes → JSON ──
74
+
75
+ export type RawField = { fn: number; wt: number; varint: number; bytes?: Uint8Array; i64?: Uint8Array }
76
+
77
+ function readVarintAt(b: Uint8Array, i: number): [number, number] {
78
+ let r = 0, s = 0
79
+ while (i < b.length) {
80
+ const x = b[i++] ?? 0
81
+ r |= (x & 0x7f) << s
82
+ if (!(x & 0x80)) break
83
+ s += 7
84
+ }
85
+ return [r >>> 0, i]
86
+ }
87
+
88
+ /** Walk a protobuf message's top-level fields off the raw wire bytes. */
89
+ export function readAllFields(b: Uint8Array): RawField[] {
90
+ let i = 0
91
+ const out: RawField[] = []
92
+ while (i < b.length) {
93
+ let key: number
94
+ ;[key, i] = readVarintAt(b, i)
95
+ const fn = key >>> 3, wt = key & 7
96
+ if (wt === 0) {
97
+ let v: number
98
+ ;[v, i] = readVarintAt(b, i)
99
+ out.push({ fn, wt, varint: v })
100
+ } else if (wt === 2) {
101
+ let len: number
102
+ ;[len, i] = readVarintAt(b, i)
103
+ out.push({ fn, wt, varint: 0, bytes: b.subarray(i, i + len) })
104
+ i += len
105
+ } else if (wt === 1) {
106
+ out.push({ fn, wt, varint: 0, i64: b.subarray(i, i + 8) })
107
+ i += 8
108
+ } else if (wt === 5) {
109
+ i += 4 // i32 — not used by Value
110
+ } else break
111
+ }
112
+ return out
113
+ }
114
+
115
+ export type StrictRawField = {
116
+ fn: number
117
+ wt: number
118
+ varint?: bigint
119
+ bytes?: Uint8Array
120
+ fixed64?: Uint8Array
121
+ fixed32?: Uint8Array
122
+ }
123
+
124
+ type DecodedVarint = { value: bigint; nextOffset: number }
125
+
126
+ const MAX_UINT32 = 0xffff_ffffn
127
+ const MAX_UINT64 = 0xffff_ffff_ffff_ffffn
128
+ const MAX_PROTOBUF_FIELD_NUMBER = 0x1fff_ffff
129
+
130
+ /**
131
+ * Decode one unsigned protobuf varint without JavaScript's 32-bit bitwise
132
+ * truncation. `maximum` also enforces the protocol width: tags and lengths are
133
+ * uint32, while wire-type 0 scalar values may use the full uint64 range.
134
+ */
135
+ function readBoundedVarint(
136
+ bytes: Uint8Array,
137
+ offset: number,
138
+ maximum: bigint,
139
+ ): DecodedVarint | undefined {
140
+ let value = 0n
141
+ let shift = 0n
142
+ for (let index = offset; index < bytes.length && index < offset + 10; index++) {
143
+ const byte = bytes[index]!
144
+ value |= BigInt(byte & 0x7f) << shift
145
+ if (value > maximum) return undefined
146
+ if ((byte & 0x80) === 0) return { value, nextOffset: index + 1 }
147
+ shift += 7n
148
+ }
149
+ return undefined
150
+ }
151
+
152
+ /**
153
+ * Strictly walk a protobuf message for security/replay decisions.
154
+ *
155
+ * Unlike `readAllFields`, this parser consumes the complete input, preserves
156
+ * uint64 varints as bigint, represents fixed-width fields, and rejects invalid
157
+ * tags, truncation, overflow, groups, and unsupported wire types. It deliberately
158
+ * returns `undefined` instead of a partial result: callers must fail closed when
159
+ * deciding whether replay is safe.
160
+ */
161
+ export function readAllFieldsStrict(bytes: Uint8Array): StrictRawField[] | undefined {
162
+ let offset = 0
163
+ const fields: StrictRawField[] = []
164
+
165
+ while (offset < bytes.length) {
166
+ const tag = readBoundedVarint(bytes, offset, MAX_UINT32)
167
+ if (!tag) return undefined
168
+ offset = tag.nextOffset
169
+
170
+ const fieldNumber = Number(tag.value >> 3n)
171
+ const wireType = Number(tag.value & 7n)
172
+ if (fieldNumber === 0 || fieldNumber > MAX_PROTOBUF_FIELD_NUMBER) return undefined
173
+
174
+ if (wireType === 0) {
175
+ const scalar = readBoundedVarint(bytes, offset, MAX_UINT64)
176
+ if (!scalar) return undefined
177
+ fields.push({ fn: fieldNumber, wt: wireType, varint: scalar.value })
178
+ offset = scalar.nextOffset
179
+ continue
180
+ }
181
+
182
+ if (wireType === 1) {
183
+ if (offset + 8 > bytes.length) return undefined
184
+ fields.push({ fn: fieldNumber, wt: wireType, fixed64: bytes.subarray(offset, offset + 8) })
185
+ offset += 8
186
+ continue
187
+ }
188
+
189
+ if (wireType === 2) {
190
+ const encodedLength = readBoundedVarint(bytes, offset, MAX_UINT32)
191
+ if (!encodedLength) return undefined
192
+ offset = encodedLength.nextOffset
193
+ const length = Number(encodedLength.value)
194
+ if (offset + length > bytes.length) return undefined
195
+ fields.push({ fn: fieldNumber, wt: wireType, bytes: bytes.subarray(offset, offset + length) })
196
+ offset += length
197
+ continue
198
+ }
199
+
200
+ if (wireType === 5) {
201
+ if (offset + 4 > bytes.length) return undefined
202
+ fields.push({ fn: fieldNumber, wt: wireType, fixed32: bytes.subarray(offset, offset + 4) })
203
+ offset += 4
204
+ continue
205
+ }
206
+
207
+ // Groups (3/4) are deprecated and recursive; no replay-safe frame uses them.
208
+ return undefined
209
+ }
210
+
211
+ return fields
212
+ }
213
+
214
+ function decodeStructBytes(b: Uint8Array): Record<string, unknown> {
215
+ const obj: Record<string, unknown> = {}
216
+ for (const f of readAllFields(b)) {
217
+ if (f.fn !== 1 || !f.bytes) continue // Struct.fields (map) entries
218
+ const { key, valBytes } = readMapEntry(f.bytes)
219
+ if (key !== undefined) obj[key] = valBytes ? decodeValueToJson(valBytes) : null
220
+ }
221
+ return obj
222
+ }
223
+
224
+ function decodeListBytes(b: Uint8Array): unknown[] {
225
+ const arr: unknown[] = []
226
+ for (const f of readAllFields(b)) {
227
+ if (f.fn === 1 && f.bytes) arr.push(decodeValueToJson(f.bytes))
228
+ }
229
+ return arr
230
+ }
231
+
232
+ function readMapEntry(b: Uint8Array): { key?: string; valBytes?: Uint8Array } {
233
+ let key: string | undefined
234
+ let valBytes: Uint8Array | undefined
235
+ for (const e of readAllFields(b)) {
236
+ if (e.fn === 1 && e.bytes) key = new TextDecoder().decode(e.bytes)
237
+ else if (e.fn === 2 && e.bytes) valBytes = e.bytes
238
+ }
239
+ return { ...(key === undefined ? {} : { key }), ...(valBytes === undefined ? {} : { valBytes }) }
240
+ }
241
+
242
+ /** Decode a google.protobuf.Value message (bytes) back into a JSON value. */
243
+ export function decodeValueToJson(bytes: Uint8Array): unknown {
244
+ const fs = readAllFields(bytes)
245
+ const f = fs[0]
246
+ if (f === undefined) return null
247
+ switch (f.fn) {
248
+ case 1: return null // null_value
249
+ case 2: return f.i64 ? new DataView(f.i64.buffer, f.i64.byteOffset, 8).getFloat64(0, true) : 0
250
+ case 3: return f.bytes ? new TextDecoder().decode(f.bytes) : ""
251
+ case 4: return f.varint !== 0
252
+ case 5: return f.bytes ? decodeStructBytes(f.bytes) : {}
253
+ case 6: return f.bytes ? decodeListBytes(f.bytes) : []
254
+ default: return null
255
+ }
256
+ }
257
+
258
+ /**
259
+ * Decode a `map<string, Value>` field that was captured as repeated map-entry
260
+ * messages (each `{1 key, 2 value}`) into a plain JSON object. Used for
261
+ * `McpArgs.args`, which arrives as repeated field #2 on the wire.
262
+ */
263
+ export function decodeStructEntriesToJson(entries: Uint8Array[]): Record<string, unknown> {
264
+ const obj: Record<string, unknown> = {}
265
+ for (const entry of entries) {
266
+ const { key, valBytes } = readMapEntry(entry)
267
+ if (key !== undefined) obj[key] = valBytes ? decodeValueToJson(valBytes) : null
268
+ }
269
+ return obj
270
+ }
271
+
272
+ /** Encode an arbitrary JSON value as google.protobuf.Value bytes. */
273
+ export function encodeJsonAsValue(v: unknown): Uint8Array {
274
+ const out: number[] = []
275
+ if (v === null || v === undefined) {
276
+ writeTag(out, 1, 0) // null_value = 0
277
+ writeVarint(out, 0)
278
+ } else if (typeof v === "number") {
279
+ writeDouble(out, 2, v)
280
+ } else if (typeof v === "boolean") {
281
+ writeTag(out, 4, 0)
282
+ writeVarint(out, v ? 1 : 0)
283
+ } else if (typeof v === "string") {
284
+ writeString(out, 3, v)
285
+ } else if (Array.isArray(v)) {
286
+ const lv: number[] = []
287
+ for (const item of v) writeLengthDelimited(lv, 1, encodeJsonAsValue(item))
288
+ writeLengthDelimited(out, 6, new Uint8Array(lv))
289
+ } else if (typeof v === "object") {
290
+ const st: number[] = []
291
+ for (const [key, val] of Object.entries(v as Record<string, unknown>).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0)) {
292
+ if (val === undefined) continue
293
+ const entry: number[] = []
294
+ writeString(entry, 1, key)
295
+ writeLengthDelimited(entry, 2, encodeJsonAsValue(val))
296
+ writeLengthDelimited(st, 1, new Uint8Array(entry))
297
+ }
298
+ writeLengthDelimited(out, 5, new Uint8Array(st))
299
+ } else {
300
+ // Fallback: treat as null.
301
+ writeTag(out, 1, 0)
302
+ writeVarint(out, 0)
303
+ }
304
+ return new Uint8Array(out)
305
+ }
@@ -29,6 +29,7 @@ import type {
29
29
  } from "../../authentication/oauth-flow-store";
30
30
  import {
31
31
  devicePollBackoff,
32
+ decodeJwtPayload,
32
33
  nonEmptyTrimmedString,
33
34
  readJsonResponse,
34
35
  record,
@@ -71,19 +72,14 @@ export type { FactoryDroidEnvelope } from "../../../security/credential-codec";
71
72
  * Repeating it on every refresh would add a JWKS fetch to the dispatch path for
72
73
  * no additional guarantee: the signature cannot change without the payload
73
74
  * changing, and the payload is what this reads.
75
+ *
76
+ * Delegates to the shared decoder rather than hand-rolling a base64url pass:
77
+ * `atob` decodes to a Latin-1 string, so a claim carrying multi-byte UTF-8
78
+ * came back as mojibake. `Buffer.from(segment, "base64url")` round-trips the
79
+ * original bytes.
74
80
  */
75
81
  function jwtClaims(token: string): Record<string, unknown> | undefined {
76
- const segments = token.split(".");
77
- const payload = segments[1];
78
- if (segments.length < 2 || payload === undefined || payload.length === 0) return undefined;
79
- try {
80
- const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
81
- const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), "=");
82
- const parsed: unknown = JSON.parse(atob(padded));
83
- return record(parsed);
84
- } catch {
85
- return undefined;
86
- }
82
+ return decodeJwtPayload(token);
87
83
  }
88
84
 
89
85
  /** Expiry from the token's own `exp` claim, or the fallback when absent. */
@@ -72,9 +72,7 @@ function clampGithubReasoningEffort(payload: Record<string, unknown>): void {
72
72
  /** Supported virtual Copilot Auto catalog ids and their router tiers. */
73
73
  export const GITHUB_AUTO_MODEL_TIERS: ReadonlyMap<string, "efficiency" | "balance" | "intelligence"> = new Map([
74
74
  ["auto", "balance"],
75
- ["gpt-6-luna-low", "efficiency"],
76
- ["gpt-6-luna-medium", "balance"],
77
- ["gpt-6-luna-high", "intelligence"],
75
+ ["gpt-6-luna", "efficiency"],
78
76
  ]);
79
77
 
80
78
  /** Copilot model ids excluded from both the fallback and discovered catalogs. */
@@ -86,7 +84,9 @@ export const GITHUB_EXCLUDED_MODEL_IDS: ReadonlySet<string> = new Set([
86
84
  "gpt-5.4-mini-free-auto",
87
85
  "gpt-5.6-luna",
88
86
  "gpt-5.6-luna-free-auto",
89
- "gpt-6-luna",
87
+ "gpt-6-luna-low",
88
+ "gpt-6-luna-medium",
89
+ "gpt-6-luna-high",
90
90
  "kimi-k3",
91
91
  "kimi-k3-base",
92
92
  "kimi-k3-copilot",
@@ -3,18 +3,57 @@ import type { ProviderDispatchTarget } from "../provider-contracts";
3
3
  import type { ApiKeyProviderSpec } from "../configured-provider";
4
4
  import { isRecord } from "../../protocol/codecs";
5
5
  import { boundedUpstreamArray, boundedUpstreamNumber, sanitizeUpstreamLabel } from "../provider-sanitize";
6
+ import { getHermesVersion } from "../operations/client-versions";
6
7
 
7
8
  const HERMES_PROVIDER_ID = "hermes" as const;
8
9
 
9
- /** Portal attribution tags required by the Nous Research inference API. */
10
- const HERMES_PORTAL_TAGS = ["product=hermes-agent", "client=hermes-client-v0.13.0"] as const;
10
+ /**
11
+ * Portal attribution tags the Nous Research inference API requires.
12
+ *
13
+ * The endpoint validates the *shape* and rejects the request with 400 `missing
14
+ * user tag` when no `user=` tag is present. Measured against the live API:
15
+ *
16
+ * tags=[user=u1] → 200 tags=[a=b] → 400 missing user tag
17
+ * tags=[user=] → 200 tags=[x] → 400 missing user tag
18
+ * tags=[] / absent → 400 no user tag → 400
19
+ *
20
+ * The value is not validated — any non-empty value passes — so `user=` is a
21
+ * required field rather than a credential. That matters for what to put in it:
22
+ * a fabricated product name would be a false attribution, and there is no
23
+ * account identity to send, because the inference API exposes no account,
24
+ * usage or quota endpoint (every candidate answers 404). `user=hermes-agent`
25
+ * names the client rather than inventing an end user.
26
+ *
27
+ * `product=` and `client=` are the tags Hermes' own client sends
28
+ * (`agent/portal_tags.py` in `NousResearch/hermes-agent`). Neither is required
29
+ * for dispatch — a request carrying only `user=` answers 200 — but they are
30
+ * sent because they are the client's real attribution and cost nothing. The
31
+ * client version tracks the released tag `v2026.9.24`, which is date-based:
32
+ * Hermes does not publish a semver, so the `0.13.0` this used to claim was not
33
+ * a version Hermes ever had.
34
+ */
35
+ /**
36
+ * Builds the portal tags for one dispatch.
37
+ *
38
+ * `client=` carries the version in the shape the released tag used
39
+ * (`v<version>`), but the version itself is now the resolved one: the previous
40
+ * constant named a date tag (`v2026.9.24`) that was neither a release nor the
41
+ * version the project publishes. `getHermesVersion()` tracks the real release.
42
+ */
43
+ function hermesPortalTags(): readonly string[] {
44
+ return [
45
+ "product=hermes-agent",
46
+ `client=hermes-client-v${getHermesVersion()}`,
47
+ "user=hermes-agent",
48
+ ];
49
+ }
11
50
 
12
51
  function injectHermesTags(
13
52
  payload: Record<string, unknown>,
14
53
  _request: CanonicalRequest,
15
54
  _candidate: ProviderDispatchTarget,
16
55
  ): void {
17
- payload["tags"] = [...HERMES_PORTAL_TAGS];
56
+ payload["tags"] = hermesPortalTags();
18
57
  }
19
58
 
20
59
 
@@ -37,10 +76,27 @@ import type { ModelDefinition } from "../provider-model-definition";
37
76
  * `upstage/solar-mini4:free` exist).
38
77
  */
39
78
  export const HERMES_MODELS: readonly ModelDefinition[] = [
40
- defineModel({ id: "poolside/laguna-s-2.1:free", ctx: 262144, out: 131072, reasoning: true }),
41
- defineModel({ id: "poolside/laguna-xs-2.1:free", ctx: 262144, out: 32768, reasoning: true }),
42
- defineModel({ id: "stepfun/step-3.7-flash:free", ctx: 262144, out: 256000, vision: true, reasoning: true }),
43
- defineModel({ id: "meituan/longcat-2.0:free", ctx: 1048756, out: 262144, reasoning: true }),
79
+ // The live `/models` free rows, with the limits the catalog states. Verified
80
+ // against the API: every id here answers 200.
81
+ //
82
+ // `meituan/longcat-2.0:free` is gone: the catalog still lists the id, but
83
+ // dispatching it answers 404 "This model is no longer free", so keeping it
84
+ // would be a card that can only ever fail. `meituan/longcat-2.5-preview:free`
85
+ // replaces it and answers 200.
86
+ //
87
+ // `stepfun/step-5-preview:free` is gone: it is absent from the live catalog
88
+ // entirely and dispatching it answers 404 "This model's free period has
89
+ // ended" — a retired row, not a capacity blip, so it cannot be left in.
90
+ //
91
+ // Output caps are the catalog's own `top_provider.max_completion_tokens`,
92
+ // which differ per row: `poolside/laguna-xs-2.1:free` is 32768 while its
93
+ // sibling `laguna-s` is 131072, so a uniform value overstates one of them.
94
+ defineModel({ id: "poolside/laguna-s-2.1:free", ctx: 262144, out: 131072, reasoning: true, free: true, freeTier: true }),
95
+ defineModel({ id: "poolside/laguna-xs-2.1:free", ctx: 262144, out: 32768, reasoning: true, free: true, freeTier: true }),
96
+ defineModel({ id: "stepfun/step-3.7-flash:free", ctx: 262144, out: 256000, vision: true, reasoning: true, free: true, freeTier: true }),
97
+ defineModel({ id: "upstage/solar-mini4:free", ctx: 524288, out: 131072, reasoning: true, free: true, freeTier: true }),
98
+ defineModel({ id: "reflection/beam-1.0-501b-a23b:free", ctx: 262144, out: 131072, reasoning: true, free: true, freeTier: true }),
99
+ defineModel({ id: "meituan/longcat-2.5-preview:free", ctx: 1048576, out: 131072, reasoning: true, free: true, freeTier: true }),
44
100
  ];
45
101
 
46
102
 
@@ -53,6 +109,16 @@ export const HERMES_SPEC: ApiKeyProviderSpec = {
53
109
  provider_id: HERMES_PROVIDER_ID,
54
110
  endpoint_paths_by_wire_family: {},
55
111
  prePayload: injectHermesTags,
112
+ // The origin sits behind Cloudflare, which answers a request carrying no
113
+ // `user-agent` with 403 "Attention Required!" while the same request with any
114
+ // non-empty UA answers 200 — measured directly against the API: an empty UA
115
+ // is 403, and `curl`, `node`, `python-requests`, `undici` and Bun's own
116
+ // default are all accepted.
117
+ //
118
+ // The value names this client as Hermes rather than claiming to be the
119
+ // gateway: the upstream meters by the product tag, and the version is the
120
+ // resolved release so a stale pin cannot drift into a mismatch.
121
+ extra_headers: { "user-agent": `hermes-agent/${getHermesVersion()}` },
56
122
  };
57
123
 
58
124
  /**
@@ -123,7 +189,12 @@ export async function discoverHermesFreeModels(options: {
123
189
  modalities: { input: hasImage ? ["text", "image"] : ["text"], output: ["text"] },
124
190
  reasoning: true,
125
191
  toolCall: true,
126
- // The row reached this point only because both rates parse to zero.
192
+ // The row reached this point only because both rates parse to zero, so
193
+ // it is the free tier by the provider's own pricing. `free` is the
194
+ // billing statement and `freeTier` the catalog one; the model list groups
195
+ // on the tier, so without it these rows land in the fetched tail instead
196
+ // of the free section.
197
+ freeTier: true,
127
198
  cost: { input: 0, output: 0, pricing_model: "pay-per-use" },
128
199
  });
129
200
  }
@@ -76,6 +76,10 @@ function toModelDefinition(entry: Record<string, unknown>): ModelDefinition | un
76
76
  // clamped the same way every other catalog row is.
77
77
  const outputLimit = Math.min(declaredOutput, contextLimit);
78
78
  const parameters = supportedParameters(entry);
79
+ // Kilo resells the OpenRouter catalog, so the `:free` suffix is the same
80
+ // zero-cost spelling it carries there. Matched exactly rather than as a
81
+ // substring, so an id whose own name contains "free" is not swept in.
82
+ const freeTier = modelId.endsWith(":free");
79
83
  return {
80
84
  modelId,
81
85
  // Kilo Code exposes one OpenAI-compatible chat surface; its directory
@@ -87,7 +91,12 @@ function toModelDefinition(entry: Record<string, unknown>): ModelDefinition | un
87
91
  modalities: { input: inputModalities(entry), output: ["text"] },
88
92
  reasoning: parameters.has("reasoning") || parameters.has("include_reasoning"),
89
93
  toolCall: parameters.has("tools"),
90
- cost: modelsDevCatalog.costFor(KILO_PROVIDER_ID, modelId),
94
+ // A `:free` row bills zero, and the catalog lookup would otherwise price it
95
+ // from a models.dev row that describes the paid listing.
96
+ ...(freeTier ? { free: true, freeTier: true } : {}),
97
+ cost: freeTier
98
+ ? { input: 0, output: 0, pricing_model: "pay-per-use" as const }
99
+ : modelsDevCatalog.costFor(KILO_PROVIDER_ID, modelId),
91
100
  };
92
101
  }
93
102