omnicell-router 0.8.4 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/README.md +26 -7
  2. package/README.zh-CN.md +18 -5
  3. package/backend/dist/capture/recorder.d.ts +4 -10
  4. package/backend/dist/capture/recorder.js +6 -58
  5. package/backend/dist/cli/clients/base.d.ts +36 -11
  6. package/backend/dist/cli/clients/base.js +31 -15
  7. package/backend/dist/cli/clients/claude.d.ts +9 -0
  8. package/backend/dist/cli/clients/claude.js +6 -0
  9. package/backend/dist/cli/clients/codex.d.ts +8 -0
  10. package/backend/dist/cli/clients/codex.js +5 -0
  11. package/backend/dist/cli/clients/core-adapters.d.ts +1 -1
  12. package/backend/dist/cli/clients/core-adapters.js +1 -1
  13. package/backend/dist/cli/clients/dsh.d.ts +8 -0
  14. package/backend/dist/cli/clients/dsh.js +5 -0
  15. package/backend/dist/cli/clients/grok.d.ts +15 -1
  16. package/backend/dist/cli/clients/grok.js +16 -2
  17. package/backend/dist/cli/clients/index.d.ts +13 -1
  18. package/backend/dist/cli/clients/index.js +97 -19
  19. package/backend/dist/cli/clients/kimi.d.ts +6 -0
  20. package/backend/dist/cli/clients/kimi.js +3 -0
  21. package/backend/dist/cli/clients/launcher.d.ts +1 -1
  22. package/backend/dist/cli/clients/model-meta.js +6 -3
  23. package/backend/dist/cli/clients/omp.d.ts +6 -0
  24. package/backend/dist/cli/clients/omp.js +3 -0
  25. package/backend/dist/cli/clients/openclaw.d.ts +6 -0
  26. package/backend/dist/cli/clients/openclaw.js +3 -0
  27. package/backend/dist/cli/clients/opencode.d.ts +8 -0
  28. package/backend/dist/cli/clients/opencode.js +5 -0
  29. package/backend/dist/cli/clients/pi.d.ts +6 -0
  30. package/backend/dist/cli/clients/pi.js +3 -0
  31. package/backend/dist/cli/clients/update-check.d.ts +37 -0
  32. package/backend/dist/cli/clients/update-check.js +309 -0
  33. package/backend/dist/cli/clients/workbuddy.d.ts +19 -0
  34. package/backend/dist/cli/clients/workbuddy.js +66 -0
  35. package/backend/dist/cli/index.js +5 -4
  36. package/backend/dist/cli/paths.js +8 -0
  37. package/backend/dist/cli/types.d.ts +92 -16
  38. package/backend/dist/config/comments-en.js +31 -26
  39. package/backend/dist/config/comments-zh.js +29 -24
  40. package/backend/dist/config/defaults.d.ts +194 -33
  41. package/backend/dist/config/defaults.js +193 -32
  42. package/backend/dist/config/env.d.ts +10 -0
  43. package/backend/dist/config/env.js +3 -2
  44. package/backend/dist/config/index.d.ts +7 -0
  45. package/backend/dist/config/index.js +184 -43
  46. package/backend/dist/config/migrations/v0-to-v1.d.ts +2 -2
  47. package/backend/dist/config/migrations/v10-to-v11.d.ts +38 -0
  48. package/backend/dist/config/migrations/v10-to-v11.js +43 -0
  49. package/backend/dist/config/migrations/v6-to-v7.d.ts +45 -0
  50. package/backend/dist/config/migrations/v6-to-v7.js +97 -0
  51. package/backend/dist/config/migrations/v7-to-v8.d.ts +36 -0
  52. package/backend/dist/config/migrations/v7-to-v8.js +43 -0
  53. package/backend/dist/config/migrations/v8-to-v9.d.ts +38 -0
  54. package/backend/dist/config/migrations/v8-to-v9.js +43 -0
  55. package/backend/dist/config/migrations/v9-to-v10.d.ts +51 -0
  56. package/backend/dist/config/migrations/v9-to-v10.js +71 -0
  57. package/backend/dist/config/runtime.js +1 -1
  58. package/backend/dist/config/schema.d.ts +3 -3
  59. package/backend/dist/config/schema.js +14 -4
  60. package/backend/dist/config/types.d.ts +167 -38
  61. package/backend/dist/egress-proxy/asset-download.d.ts +54 -0
  62. package/backend/dist/egress-proxy/asset-download.js +420 -0
  63. package/backend/dist/egress-proxy/manual-node-spec.d.ts +92 -0
  64. package/backend/dist/egress-proxy/manual-node-spec.js +408 -0
  65. package/backend/dist/egress-proxy/mihomo-binary.d.ts +54 -0
  66. package/backend/dist/egress-proxy/mihomo-binary.js +278 -0
  67. package/backend/dist/egress-proxy/mihomo-client.d.ts +94 -0
  68. package/backend/dist/egress-proxy/mihomo-client.js +308 -0
  69. package/backend/dist/egress-proxy/mihomo-config.d.ts +40 -0
  70. package/backend/dist/egress-proxy/mihomo-config.js +161 -0
  71. package/backend/dist/egress-proxy/mihomo-geo.d.ts +87 -0
  72. package/backend/dist/egress-proxy/mihomo-geo.js +213 -0
  73. package/backend/dist/egress-proxy/mihomo-logs.d.ts +43 -0
  74. package/backend/dist/egress-proxy/mihomo-logs.js +84 -0
  75. package/backend/dist/egress-proxy/mihomo-pac.d.ts +37 -0
  76. package/backend/dist/egress-proxy/mihomo-pac.js +75 -0
  77. package/backend/dist/egress-proxy/mihomo-rules-import.d.ts +43 -0
  78. package/backend/dist/egress-proxy/mihomo-rules-import.js +193 -0
  79. package/backend/dist/egress-proxy/mihomo-sidecar.d.ts +81 -0
  80. package/backend/dist/egress-proxy/mihomo-sidecar.js +637 -0
  81. package/backend/dist/forward-proxy/egress.d.ts +50 -11
  82. package/backend/dist/forward-proxy/egress.js +50 -17
  83. package/backend/dist/forward-proxy/h2-forward.js +36 -10
  84. package/backend/dist/forward-proxy/index.d.ts +11 -8
  85. package/backend/dist/forward-proxy/index.js +22 -60
  86. package/backend/dist/forward-proxy/interceptor.d.ts +3 -2
  87. package/backend/dist/forward-proxy/interceptor.js +4 -4
  88. package/backend/dist/forward-proxy/relay.js +3 -3
  89. package/backend/dist/forward-proxy/rules.d.ts +4 -4
  90. package/backend/dist/forward-proxy/rules.js +25 -4
  91. package/backend/dist/forward-proxy/server.d.ts +0 -16
  92. package/backend/dist/forward-proxy/server.js +124 -156
  93. package/backend/dist/harness/host/hosts.js +3 -2
  94. package/backend/dist/index.js +53 -18
  95. package/backend/dist/ingress-proxy/access-log.d.ts +176 -0
  96. package/backend/dist/ingress-proxy/access-log.js +774 -0
  97. package/backend/dist/ingress-proxy/ca-inventory.d.ts +106 -0
  98. package/backend/dist/ingress-proxy/ca-inventory.js +525 -0
  99. package/backend/dist/ingress-proxy/ca-trust.d.ts +96 -0
  100. package/backend/dist/ingress-proxy/ca-trust.js +315 -0
  101. package/backend/dist/ingress-proxy/ca.d.ts +104 -0
  102. package/backend/dist/ingress-proxy/ca.js +273 -0
  103. package/backend/dist/ingress-proxy/data-dir.d.ts +28 -0
  104. package/backend/dist/ingress-proxy/data-dir.js +45 -0
  105. package/backend/dist/ingress-proxy/egress.d.ts +151 -0
  106. package/backend/dist/ingress-proxy/egress.js +364 -0
  107. package/backend/dist/ingress-proxy/h2-forward.d.ts +66 -0
  108. package/backend/dist/ingress-proxy/h2-forward.js +561 -0
  109. package/backend/dist/ingress-proxy/index.d.ts +24 -0
  110. package/backend/dist/ingress-proxy/index.js +144 -0
  111. package/backend/dist/ingress-proxy/interceptor.d.ts +25 -0
  112. package/backend/dist/ingress-proxy/interceptor.js +52 -0
  113. package/backend/dist/ingress-proxy/ordered-relay.d.ts +29 -0
  114. package/backend/dist/ingress-proxy/ordered-relay.js +46 -0
  115. package/backend/dist/ingress-proxy/relay.d.ts +54 -0
  116. package/backend/dist/ingress-proxy/relay.js +188 -0
  117. package/backend/dist/ingress-proxy/rules.d.ts +195 -0
  118. package/backend/dist/ingress-proxy/rules.js +348 -0
  119. package/backend/dist/ingress-proxy/server.d.ts +153 -0
  120. package/backend/dist/ingress-proxy/server.js +2065 -0
  121. package/backend/dist/ingress-proxy/sni.d.ts +35 -0
  122. package/backend/dist/ingress-proxy/sni.js +124 -0
  123. package/backend/dist/ingress-proxy/status.d.ts +32 -0
  124. package/backend/dist/ingress-proxy/status.js +15 -0
  125. package/backend/dist/ingress-proxy/system-proxy.d.ts +112 -0
  126. package/backend/dist/ingress-proxy/system-proxy.js +481 -0
  127. package/backend/dist/ingress-proxy/traffic-delete.d.ts +21 -0
  128. package/backend/dist/ingress-proxy/traffic-delete.js +64 -0
  129. package/backend/dist/ingress-proxy/traffic-delete.worker.d.ts +44 -0
  130. package/backend/dist/ingress-proxy/traffic-delete.worker.js +228 -0
  131. package/backend/dist/ingress-proxy/traffic-files.d.ts +10 -0
  132. package/backend/dist/ingress-proxy/traffic-files.js +10 -0
  133. package/backend/dist/ingress-proxy/upstream-tls.d.ts +46 -0
  134. package/backend/dist/ingress-proxy/upstream-tls.js +105 -0
  135. package/backend/dist/ingress-proxy/ws-frames.d.ts +45 -0
  136. package/backend/dist/ingress-proxy/ws-frames.js +153 -0
  137. package/backend/dist/ir/adapters/anthropic-messages-stream.js +6 -1
  138. package/backend/dist/ir/adapters/anthropic-messages.js +12 -5
  139. package/backend/dist/ir/adapters/google-gemini-stream.js +7 -2
  140. package/backend/dist/ir/adapters/google-gemini.js +5 -2
  141. package/backend/dist/ir/adapters/openai-chat-stream.js +5 -1
  142. package/backend/dist/ir/adapters/openai-chat.d.ts +25 -0
  143. package/backend/dist/ir/adapters/openai-chat.js +45 -3
  144. package/backend/dist/ir/adapters/openai-responses-output.d.ts +1 -0
  145. package/backend/dist/ir/adapters/openai-responses-output.js +67 -21
  146. package/backend/dist/ir/adapters/openai-responses-stream.d.ts +13 -0
  147. package/backend/dist/ir/adapters/openai-responses-stream.js +34 -1
  148. package/backend/dist/ir/adapters/openai-responses.d.ts +82 -24
  149. package/backend/dist/ir/adapters/openai-responses.js +146 -37
  150. package/backend/dist/ir/media.d.ts +20 -0
  151. package/backend/dist/ir/media.js +41 -0
  152. package/backend/dist/ir/tool-identity.d.ts +35 -0
  153. package/backend/dist/ir/tool-identity.js +40 -0
  154. package/backend/dist/ir/types.d.ts +9 -1
  155. package/backend/dist/local/build-jobs.d.ts +66 -0
  156. package/backend/dist/local/build-jobs.js +243 -0
  157. package/backend/dist/local/detect.d.ts +32 -0
  158. package/backend/dist/local/detect.js +145 -0
  159. package/backend/dist/local/draft-match.d.ts +58 -0
  160. package/backend/dist/local/draft-match.js +124 -0
  161. package/backend/dist/local/engine-runtime.d.ts +522 -0
  162. package/backend/dist/local/engine-runtime.js +1 -0
  163. package/backend/dist/local/engines.d.ts +241 -0
  164. package/backend/dist/local/engines.js +651 -0
  165. package/backend/dist/local/gguf.d.ts +35 -0
  166. package/backend/dist/local/gguf.js +314 -0
  167. package/backend/dist/local/hf.d.ts +120 -0
  168. package/backend/dist/local/hf.js +304 -0
  169. package/backend/dist/local/install.d.ts +90 -0
  170. package/backend/dist/local/install.js +421 -0
  171. package/backend/dist/local/llamacpp.d.ts +55 -0
  172. package/backend/dist/local/llamacpp.js +177 -0
  173. package/backend/dist/local/local-provider.d.ts +81 -0
  174. package/backend/dist/local/local-provider.js +301 -0
  175. package/backend/dist/local/machine-stats.d.ts +87 -0
  176. package/backend/dist/local/machine-stats.js +332 -0
  177. package/backend/dist/local/model-store.d.ts +347 -0
  178. package/backend/dist/local/model-store.js +1215 -0
  179. package/backend/dist/local/part-sweep.d.ts +32 -0
  180. package/backend/dist/local/part-sweep.js +156 -0
  181. package/backend/dist/local/plan.d.ts +65 -0
  182. package/backend/dist/local/plan.js +146 -0
  183. package/backend/dist/local/resources.d.ts +49 -0
  184. package/backend/dist/local/resources.js +64 -0
  185. package/backend/dist/local/run-stats.d.ts +95 -0
  186. package/backend/dist/local/run-stats.js +195 -0
  187. package/backend/dist/local/runner.d.ts +235 -0
  188. package/backend/dist/local/runner.js +1392 -0
  189. package/backend/dist/local/settings.d.ts +79 -0
  190. package/backend/dist/local/settings.js +180 -0
  191. package/backend/dist/local/strata-catalog.d.ts +30 -0
  192. package/backend/dist/local/strata-catalog.js +511 -0
  193. package/backend/dist/local/strata-drafting.d.ts +46 -0
  194. package/backend/dist/local/strata-drafting.js +265 -0
  195. package/backend/dist/local/strata.d.ts +278 -0
  196. package/backend/dist/local/strata.js +1392 -0
  197. package/backend/dist/local/tar.d.ts +20 -0
  198. package/backend/dist/local/tar.js +367 -0
  199. package/backend/dist/local/transport.d.ts +35 -0
  200. package/backend/dist/local/transport.js +89 -0
  201. package/backend/dist/local/tune.d.ts +58 -0
  202. package/backend/dist/local/tune.js +324 -0
  203. package/backend/dist/observability/http-exchange.d.ts +2 -2
  204. package/backend/dist/opencode/catalog/auto-pull.d.ts +14 -3
  205. package/backend/dist/opencode/catalog/auto-pull.js +276 -70
  206. package/backend/dist/opencode/catalog/ocr-store.js +3 -1
  207. package/backend/dist/opencode/catalog/overrides-store.d.ts +10 -1
  208. package/backend/dist/opencode/catalog/overrides-store.js +6 -0
  209. package/backend/dist/opencode/catalog/reasoning-declaration.d.ts +35 -0
  210. package/backend/dist/opencode/catalog/reasoning-declaration.js +66 -0
  211. package/backend/dist/opencode/catalog/repository.js +25 -2
  212. package/backend/dist/opencode/catalog/sources/models-dev.js +13 -3
  213. package/backend/dist/opencode/catalog/types.d.ts +35 -3
  214. package/backend/dist/opencode/catalog/types.js +38 -1
  215. package/backend/dist/opencode/credentials/ocr-store.js +11 -2
  216. package/backend/dist/opencode/credentials/sync.js +12 -3
  217. package/backend/dist/opencode/credentials/types.d.ts +31 -4
  218. package/backend/dist/opencode/credentials/types.js +25 -0
  219. package/backend/dist/opencode/probe.d.ts +21 -4
  220. package/backend/dist/opencode/probe.js +34 -10
  221. package/backend/dist/pipeline/directives.d.ts +9 -4
  222. package/backend/dist/pipeline/directives.js +14 -10
  223. package/backend/dist/pipeline/orchestrator.d.ts +42 -13
  224. package/backend/dist/pipeline/orchestrator.js +497 -165
  225. package/backend/dist/plugins/environment-ack.d.ts +51 -0
  226. package/backend/dist/plugins/environment-ack.js +81 -0
  227. package/backend/dist/plugins/gateways.d.ts +6 -6
  228. package/backend/dist/plugins/gateways.js +2 -2
  229. package/backend/dist/plugins/host.d.ts +98 -14
  230. package/backend/dist/plugins/host.js +622 -87
  231. package/backend/dist/plugins/install-run.d.ts +27 -0
  232. package/backend/dist/plugins/install-run.js +99 -0
  233. package/backend/dist/plugins/manifest.d.ts +84 -32
  234. package/backend/dist/plugins/manifest.js +149 -45
  235. package/backend/dist/plugins/market-install.d.ts +18 -0
  236. package/backend/dist/plugins/market-install.js +111 -0
  237. package/backend/dist/plugins/market-source.d.ts +100 -0
  238. package/backend/dist/plugins/market-source.js +449 -0
  239. package/backend/dist/plugins/market-updates.d.ts +70 -0
  240. package/backend/dist/plugins/market-updates.js +97 -0
  241. package/backend/dist/plugins/market.d.ts +677 -0
  242. package/backend/dist/plugins/market.js +2113 -0
  243. package/backend/dist/plugins/source-index.d.ts +155 -0
  244. package/backend/dist/plugins/source-index.js +217 -0
  245. package/backend/dist/plugins/types.d.ts +402 -37
  246. package/backend/dist/projects/worktrees.d.ts +88 -0
  247. package/backend/dist/projects/worktrees.js +220 -0
  248. package/backend/dist/providers/boot-direct.d.ts +41 -7
  249. package/backend/dist/providers/boot-direct.js +252 -36
  250. package/backend/dist/providers/compat/tool-markup-recovery.js +31 -6
  251. package/backend/dist/providers/executors/dispatch.d.ts +17 -7
  252. package/backend/dist/providers/executors/dispatch.js +28 -9
  253. package/backend/dist/providers/executors/openai-chat.js +14 -2
  254. package/backend/dist/providers/executors/plugin-adapter.d.ts +23 -1
  255. package/backend/dist/providers/executors/plugin-adapter.js +59 -3
  256. package/backend/dist/providers/member-match.d.ts +32 -9
  257. package/backend/dist/providers/member-match.js +65 -21
  258. package/backend/dist/providers/model-resolution.d.ts +62 -0
  259. package/backend/dist/providers/model-resolution.js +62 -0
  260. package/backend/dist/providers/price-order.d.ts +51 -0
  261. package/backend/dist/providers/price-order.js +54 -0
  262. package/backend/dist/providers/provider-takedown.d.ts +5 -2
  263. package/backend/dist/providers/registry.d.ts +84 -25
  264. package/backend/dist/providers/registry.js +209 -114
  265. package/backend/dist/providers/selection.d.ts +91 -0
  266. package/backend/dist/providers/selection.js +158 -0
  267. package/backend/dist/providers/virtual-meta.d.ts +33 -2
  268. package/backend/dist/providers/virtual-meta.js +74 -18
  269. package/backend/dist/quota/cli-login.d.ts +25 -4
  270. package/backend/dist/quota/cli-login.js +35 -5
  271. package/backend/dist/quota/coverage-generation.d.ts +24 -0
  272. package/backend/dist/quota/coverage-generation.js +29 -0
  273. package/backend/dist/quota/declarations.js +8 -4
  274. package/backend/dist/quota/engine.js +2 -2
  275. package/backend/dist/quota/prober.d.ts +43 -2
  276. package/backend/dist/quota/prober.js +97 -22
  277. package/backend/dist/ratelimit/rate-limiter.d.ts +1 -1
  278. package/backend/dist/resilience/error-classifier.js +29 -0
  279. package/backend/dist/router/index.d.ts +1 -1
  280. package/backend/dist/router/index.js +17 -1
  281. package/backend/dist/router/layer2-decision.d.ts +1 -1
  282. package/backend/dist/router/layer2-decision.js +2 -2
  283. package/backend/dist/routes/console.js +928 -310
  284. package/backend/dist/routes/environments.js +1 -1
  285. package/backend/dist/routes/local-models.d.ts +2 -0
  286. package/backend/dist/routes/local-models.js +1414 -0
  287. package/backend/dist/routes/mihomo.d.ts +2 -2
  288. package/backend/dist/routes/mihomo.js +20 -11
  289. package/backend/dist/routes/projects.js +121 -0
  290. package/backend/dist/server.js +318 -13
  291. package/backend/dist/session/session-manager.d.ts +42 -5
  292. package/backend/dist/session/session-manager.js +64 -11
  293. package/backend/dist/session/session-row.d.ts +29 -8
  294. package/backend/dist/session/session-row.js +18 -13
  295. package/backend/dist/snapshot/bundle.d.ts +40 -0
  296. package/backend/dist/snapshot/bundle.js +177 -0
  297. package/backend/dist/snapshot/handoff/compress.d.ts +46 -0
  298. package/backend/dist/snapshot/handoff/compress.js +77 -0
  299. package/backend/dist/snapshot/handoff/index.d.ts +119 -0
  300. package/backend/dist/snapshot/handoff/index.js +160 -0
  301. package/backend/dist/snapshot/handoff/jsonl-writer.d.ts +78 -0
  302. package/backend/dist/snapshot/handoff/jsonl-writer.js +175 -0
  303. package/backend/dist/snapshot/handoff/opencode-writer.d.ts +51 -0
  304. package/backend/dist/snapshot/handoff/opencode-writer.js +214 -0
  305. package/backend/dist/snapshot/handoff/summarize.d.ts +39 -0
  306. package/backend/dist/snapshot/handoff/summarize.js +118 -0
  307. package/backend/dist/snapshot/handoff/transcript.d.ts +71 -0
  308. package/backend/dist/snapshot/handoff/transcript.js +167 -0
  309. package/backend/dist/snapshot/media-fs.d.ts +10 -0
  310. package/backend/dist/snapshot/media-fs.js +50 -0
  311. package/backend/dist/snapshot/media.d.ts +32 -0
  312. package/backend/dist/snapshot/media.js +87 -0
  313. package/backend/dist/snapshot/store.d.ts +226 -0
  314. package/backend/dist/snapshot/store.js +887 -0
  315. package/backend/dist/snapshot/tree.d.ts +112 -0
  316. package/backend/dist/snapshot/tree.js +207 -0
  317. package/backend/dist/snapshot/types.d.ts +212 -0
  318. package/backend/dist/snapshot/types.js +14 -0
  319. package/backend/dist/snapshot/view.d.ts +19 -0
  320. package/backend/dist/snapshot/view.js +57 -0
  321. package/backend/dist/snapshot/write-worker.d.ts +67 -0
  322. package/backend/dist/snapshot/write-worker.js +129 -0
  323. package/backend/dist/surfaces/body-admission.d.ts +67 -2
  324. package/backend/dist/surfaces/body-admission.js +218 -13
  325. package/backend/dist/surfaces/chat-pipeline.js +8 -0
  326. package/backend/dist/surfaces/decision-pipeline.js +10 -7
  327. package/backend/dist/surfaces/gateway-catalog.d.ts +26 -0
  328. package/backend/dist/surfaces/gateway-catalog.js +202 -0
  329. package/backend/dist/surfaces/gateway-chat.d.ts +7 -11
  330. package/backend/dist/surfaces/gateway-chat.js +50 -12
  331. package/backend/dist/surfaces/ocr-headers.d.ts +6 -4
  332. package/backend/dist/surfaces/ocr-headers.js +11 -7
  333. package/backend/dist/surfaces/systemone.js +1 -1
  334. package/backend/dist/surfaces/transport-fastify.js +32 -5
  335. package/backend/dist/surfaces/transport-node-http.d.ts +9 -3
  336. package/backend/dist/surfaces/transport-node-http.js +6 -19
  337. package/backend/dist/surfaces/types.d.ts +11 -3
  338. package/backend/dist/trace/persist.js +21 -1
  339. package/backend/dist/trace/tracker.d.ts +35 -3
  340. package/backend/dist/trace/tracker.js +23 -0
  341. package/backend/dist/types/openai.d.ts +8 -0
  342. package/backend/dist/types/router.d.ts +17 -6
  343. package/backend/dist/types/router.js +14 -2
  344. package/backend/dist/utils/client-families.d.ts +66 -0
  345. package/backend/dist/utils/client-families.js +127 -0
  346. package/backend/dist/utils/event-ring.d.ts +1 -1
  347. package/backend/dist/utils/event-ring.js +1 -1
  348. package/backend/dist/utils/proxy-node.js +1 -1
  349. package/backend/dist/utils/proxy.d.ts +135 -11
  350. package/backend/dist/utils/proxy.js +144 -29
  351. package/backend/dist/utils/run-command.d.ts +21 -1
  352. package/backend/dist/utils/run-command.js +64 -4
  353. package/backend/dist/utils/server-liveness.d.ts +3 -2
  354. package/backend/dist/utils/server-liveness.js +3 -2
  355. package/backend/dist/utils/session-file.d.ts +28 -0
  356. package/backend/dist/utils/session-file.js +34 -0
  357. package/frontend/dist/assets/antigravity.color-DXFfVr6X.svg +39 -0
  358. package/frontend/dist/assets/gemini-cli.color-BfquLd1p.svg +1 -0
  359. package/frontend/dist/assets/index-CTZNvn1d.js +1707 -0
  360. package/frontend/dist/assets/{index-KI1OW5x6.css → index-CqDSOPQ0.css} +1 -1
  361. package/frontend/dist/index.html +2 -2
  362. package/package.json +3 -1
  363. package/frontend/dist/assets/index-Dk76uc7e.js +0 -1522
@@ -11,7 +11,9 @@ import { nodeProxiedFetch } from './proxy-node.js';
11
11
  * 3. includes — the ALLOWLIST: only a matching provider/model is proxied. An
12
12
  * empty (or absent) list proxies NOTHING — no rule configured means no
13
13
  * outbound proxy (ADR-0022 amendment 2026-12).
14
- * 4. undefined — direct; Bun fetch then still honors HTTP_PROXY/HTTPS_PROXY/NO_PROXY.
14
+ * 4. direct — and the verdict says WHY (`EgressDirectReason`), so a caller can
15
+ * report an honest leg instead of guessing from an absence. Bun fetch still
16
+ * honors HTTP_PROXY/HTTPS_PROXY/NO_PROXY on a direct dial.
15
17
  *
16
18
  * List patterns match BOTH the composite `provider/modelId` and the bare model id,
17
19
  * so one syntax covers both levels: `providerName/asterisk` (slash-star) selects
@@ -20,6 +22,11 @@ import { nodeProxiedFetch } from './proxy-node.js';
20
22
  * unlisted: a call with no match target is never proxied, because the empty
21
23
  * includes list is direct.
22
24
  *
25
+ * Before any of that, a caller may pass a {@link PluginEgressMode} — the operator's
26
+ * plugin-level switch, folded by the host SDK — which this resolver applies as a
27
+ * single decision. Omitting it (`'inherit'`) leaves the provider/model split in
28
+ * charge, which is the default for every core dial.
29
+ *
23
30
  * proxiedFetch passes the resolved proxy via Bun's fetch `proxy` option
24
31
  * (verified on bun 1.3.14). Node's fetch ignores that option, so the Node
25
32
  * path opens the proxy itself (absolute-form HTTP, CONNECT for HTTPS) —
@@ -83,15 +90,20 @@ export function isBunRuntime() {
83
90
  * The endpoint `proxy.enabled` actually dials, with no include/exclude gate.
84
91
  * `manual` uses `proxy.url`. `mihomo` uses the loopback mixed-port (ADR-0022)
85
92
  * and ignores `proxy.url`.
93
+ *
94
+ * Returns BOTH names for the endpoint, because the validation parse has them
95
+ * anyway: `url` is dialable (userinfo included), `origin` is display-safe
96
+ * (`URL.origin` drops userinfo). One parse, no second redaction helper call.
86
97
  */
87
- function globalProxyUrl() {
98
+ function globalProxyEndpoint() {
88
99
  const cfg = activeConfig;
89
100
  if (cfg?.mode === 'mihomo') {
90
101
  const port = cfg.mihomo?.mixedPort;
91
102
  const controller = cfg.mihomo?.controllerPort;
92
103
  if (!Number.isInteger(port) || port < 1 || port > 65535 || port === controller)
93
104
  return undefined;
94
- return `http://127.0.0.1:${port}`;
105
+ const url = `http://127.0.0.1:${port}`;
106
+ return { url, origin: url };
95
107
  }
96
108
  const url = (cfg?.url || '').trim();
97
109
  if (!url)
@@ -102,6 +114,7 @@ function globalProxyUrl() {
102
114
  const parsed = new URL(url);
103
115
  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')
104
116
  throw new Error('scheme');
117
+ return { url, origin: parsed.origin };
105
118
  }
106
119
  catch {
107
120
  if (!warnedInvalidProxyUrl) {
@@ -110,39 +123,97 @@ function globalProxyUrl() {
110
123
  }
111
124
  return undefined;
112
125
  }
113
- return url;
114
126
  }
115
127
  /**
116
- * The outbound proxy URL with NO provider/model gating — `proxy.enabled` +
117
- * `proxy.url`, nothing else.
128
+ * The outbound proxy endpoint with NO provider/model gating — `proxy.enabled` +
129
+ * the effective endpoint, nothing else.
118
130
  *
119
- * `resolveProxyUrl` answers "which proxy for THIS provider/model" (includes /
131
+ * `resolveEgress` answers "which leg for THIS provider/model" (includes /
120
132
  * excludes). Callers that already decided the egress themselves — the
121
- * forward-proxy transit legs after the egress table (ADR-0018) — must not be
133
+ * ingress-proxy transit legs after the egress table (ADR-0018) — must not be
122
134
  * re-gated by a list that was never about hosts.
135
+ *
136
+ * Named `egress` (not `outbound`): "outbound" is the HOST SDK's axis
137
+ * (`egressProxyFor`, ADR-0022), while this answers the core's own question —
138
+ * where this machine's egress proxy is. It is the single place that turns
139
+ * `proxy.enabled` + the endpoint into a dialable string; nothing else should
140
+ * re-derive it.
123
141
  */
124
- export function outboundProxyUrl() {
142
+ export function egressEndpointUrl() {
125
143
  const cfg = activeConfig;
126
144
  if (!cfg || cfg.enabled !== true)
127
145
  return undefined;
128
- return globalProxyUrl();
146
+ return globalProxyEndpoint()?.url;
129
147
  }
130
- /**
131
- * Resolve the proxy URL for a target. `match` identifies the logical caller
132
- * ({ provider, model }) for list evaluation; omit it for unlisted infra calls.
133
- * Returns undefined for direct connections.
148
+ /** Resolve the egress for a target. `match` identifies the logical caller
149
+ * ({ provider, model }) for list evaluation; omit it for unlisted infra calls.
150
+ *
151
+ * `egress` is the plugin-level answer (ADR-0022 amendment), already folded by
152
+ * the host SDK so the operator's switch and the package's own request never
153
+ * both speak. Its ladder, and nothing more:
154
+ *
155
+ * 1. loopback stays direct — cycle safety is not a setting;
156
+ * 2. `'proxy'` names the operator's endpoint, and a missing one is
157
+ * `no-endpoint` (a refusal), never a silent direct dial;
158
+ * 3. `'direct'` goes direct, reported as `plugin`;
159
+ * 4. `'inherit'` (or omitted) is the untouched default: the provider/model
160
+ * split decides exactly as it did before this argument existed.
134
161
  */
135
- export function resolveProxyUrl(targetUrl, match) {
162
+ export function resolveEgress(targetUrl, match, egress) {
136
163
  const cfg = activeConfig;
137
- if (!cfg || cfg.enabled !== true)
138
- return undefined; // opt-in: off unless explicitly enabled
139
164
  if (isLoopbackUrl(targetUrl))
140
- return undefined;
141
- if (cfg.excludes?.length && cfg.excludes.some((p) => patternHits(p, match)))
142
- return undefined;
143
- if (!cfg.includes?.length || !match)
144
- return undefined;
145
- return cfg.includes.some((p) => patternHits(p, match)) ? globalProxyUrl() : undefined;
165
+ return { mode: 'direct', reason: 'loopback' };
166
+ if (egress === 'proxy') {
167
+ const endpoint = cfg?.enabled === true ? globalProxyEndpoint() : undefined;
168
+ return endpoint
169
+ ? { mode: 'proxy', url: endpoint.url, origin: endpoint.origin, reason: 'plugin' }
170
+ : { mode: 'direct', reason: 'no-endpoint', wantsProxy: true };
171
+ }
172
+ if (egress === 'direct')
173
+ return { mode: 'direct', reason: 'plugin' };
174
+ // An EXCLUDE is its own explicit "go direct" demand on this caller, so it is
175
+ // resolved FIRST — before the global switch is read. Otherwise turning
176
+ // `proxy.enabled` off would mask an exclude as `no-endpoint` (refused) and a
177
+ // provider the operator deliberately pinned to direct would start failing.
178
+ // Precedence is the ADR-0022 one: excludes, then the allowlist.
179
+ if (cfg?.excludes?.length && cfg.excludes.some((p) => patternHits(p, match))) {
180
+ return { mode: 'direct', reason: 'exclude' };
181
+ }
182
+ // An EXPLICIT include is the operator's demand for the proxy on this caller,
183
+ // and it outranks the global switch's off state: turning `proxy.enabled` off
184
+ // while an include still names a provider must NOT silently send that
185
+ // provider out over the machine's real address. It resolves to `no-endpoint`
186
+ // (refused at dial time) so the operator either fixes the proxy or removes the
187
+ // include deliberately.
188
+ const included = !!cfg?.includes?.length && !!match && cfg.includes.some((p) => patternHits(p, match));
189
+ if (!cfg || cfg.enabled !== true) {
190
+ return included
191
+ ? { mode: 'direct', reason: 'no-endpoint', wantsProxy: true }
192
+ : { mode: 'direct', reason: 'disabled' };
193
+ }
194
+ if (!cfg.includes?.length)
195
+ return { mode: 'direct', reason: 'unlisted' };
196
+ if (!match)
197
+ return { mode: 'direct', reason: 'no-target' };
198
+ // No list, or a list that does not cover this caller: same leg, same operator
199
+ // fix (add a matching include), so ONE reason covers both.
200
+ if (!included)
201
+ return { mode: 'direct', reason: 'unlisted' };
202
+ const endpoint = globalProxyEndpoint();
203
+ return endpoint
204
+ ? { mode: 'proxy', url: endpoint.url, origin: endpoint.origin, reason: 'include' }
205
+ : { mode: 'direct', reason: 'no-endpoint', wantsProxy: true };
206
+ }
207
+ /**
208
+ * The proxy URL for a target, or `undefined` for direct — the PROJECTION of
209
+ * {@link resolveEgress} that every dial site consumes. New seams take the
210
+ * verdict; this stays because handing a string to `fetch({ proxy })` is what
211
+ * the transport needs. Never re-derive the lists here: one resolver, one
212
+ * answer.
213
+ */
214
+ export function resolveProxyUrl(targetUrl, match, egress) {
215
+ const verdict = resolveEgress(targetUrl, match, egress);
216
+ return verdict.mode === 'proxy' ? verdict.url : undefined;
146
217
  }
147
218
  /**
148
219
  * Redact a proxy URL to its origin (`scheme://host:port`). Proxy URLs may
@@ -158,12 +229,56 @@ export function redactProxyUrl(url) {
158
229
  return 'invalid-proxy-url';
159
230
  }
160
231
  }
161
- /** fetch wrapper honoring proxy.url + includes/excludes matching. */
162
- export async function proxiedFetch(url, init = {}, match) {
163
- const proxy = resolveProxyUrl(url, match);
164
- if (!proxy)
165
- return fetch(url, init);
166
- return fetchViaProxy(url, init, proxy);
232
+ /**
233
+ * The provider axle's refusal when the operator DEMANDED the proxy and the
234
+ * machine has no usable endpoint (`no-endpoint`: `proxy.enabled` is on, an
235
+ * include matched this provider/model, but the endpoint is missing or
236
+ * unparseable). This is NOT a fallback candidate: dialing direct here would put
237
+ * the operator's real IP on a request they explicitly asked to route through
238
+ * their proxy — the exact silent leak the host axle already refuses with
239
+ * {@link EGRESS_UNAVAILABLE_MESSAGE}. Spelled once, mirrored from that message so
240
+ * both axles name the same fix.
241
+ */
242
+ export const OUTBOUND_REFUSED_MESSAGE = 'Outbound proxy: this call is routed through the proxy (proxy.includes, or the plugin\'s own egress setting), but no usable ' +
243
+ 'proxy endpoint is configured — enable `proxy.enabled` with a valid URL (or a mihomo core), fix the endpoint, ' +
244
+ 'or remove the include / set the plugin to direct to go direct.';
245
+ /** The error a refused provider dial throws. Status 502 so every surface maps it
246
+ * to a gateway failure instead of a 499/abort, and `errorBody` carries the
247
+ * operator fix. */
248
+ export class OutboundEgressRefusedError extends Error {
249
+ status = 502;
250
+ code = 'outbound_egress_refused';
251
+ errorBody;
252
+ constructor(target) {
253
+ super(OUTBOUND_REFUSED_MESSAGE);
254
+ this.name = 'OutboundEgressRefusedError';
255
+ this.errorBody = OUTBOUND_REFUSED_MESSAGE;
256
+ void target;
257
+ }
258
+ }
259
+ /** fetch wrapper honoring proxy.url + includes/excludes matching. `egress` is
260
+ * the plugin-level answer folded by the host SDK (see {@link PluginEgressMode}). */
261
+ export async function proxiedFetch(url, init = {}, match, egress) {
262
+ const verdict = resolveEgress(url, match, egress);
263
+ if (verdict.mode === 'proxy')
264
+ return fetchViaProxy(url, init, verdict.url);
265
+ // `no-endpoint` — the operator asked for the proxy on this provider and there
266
+ // is nothing to dial. REFUSE: a direct dial would leak the real IP on exactly
267
+ // the traffic they tried to protect. Every other direct reason (disabled /
268
+ // loopback / exclude / unlisted / no-target) is a genuine "go direct".
269
+ if (verdict.reason === 'no-endpoint')
270
+ throw new OutboundEgressRefusedError(url);
271
+ // A `direct` verdict hands the request to the runtime's own `fetch`, which is
272
+ // NOT necessarily the machine's address: Bun honours `HTTP_PROXY` /
273
+ // `HTTPS_PROXY` from the environment around every call, and `mihomo.ts`
274
+ // documents the same for `node:http`/`node:https`. So an install launched
275
+ // behind a shell export lands its direct verdicts on that proxy's rules. This
276
+ // seam does not scrub the variables (an operator's launch environment is not
277
+ // ours to rewrite), which is why `egress: 'direct'` means "the operator's
278
+ // model-scoped split did not select the proxy" — never a claim about the
279
+ // machine's own IP. A proxy-bypass guarantee needs an explicit `fetchViaProxy`
280
+ // or a scrubbed child, not a direct verdict.
281
+ return fetch(url, init);
167
282
  }
168
283
  /**
169
284
  * fetch through an EXPLICIT proxy endpoint, bypassing the `proxy.enabled` /
@@ -3,7 +3,27 @@ export interface CommandResult {
3
3
  ok: boolean;
4
4
  stdout: string;
5
5
  stderr: string;
6
+ /**
7
+ * Exit status; `null` when the process never started (spawn error) or was
8
+ * killed on our deadline. OPTIONAL so a hand-written `CommandRunner` (the CA
9
+ * trust probes' test doubles) keeps compiling.
10
+ */
11
+ code?: number | null;
12
+ /**
13
+ * The command itself does not exist on this machine (POSIX `ENOENT`, or the
14
+ * Windows shell's "not recognized" answer). Deliberately distinct from "it
15
+ * ran and failed": only this one may be reported to an operator as NOT
16
+ * INSTALLED — a broken install, a timeout or a non-zero exit must never
17
+ * masquerade as an absent client.
18
+ */
19
+ notFound?: boolean;
6
20
  }
21
+ /**
22
+ * Would the shell resolve this command name? Locale-independent on purpose (see
23
+ * {@link COMMAND_NOT_FOUND_RE}) and consulted ONLY after a run has already
24
+ * failed, so it can never turn a working command into a "missing" one.
25
+ */
26
+ export declare function commandResolves(cmd: string): boolean;
7
27
  /**
8
28
  * Quote ONE argv element for a cmd.exe command line.
9
29
  *
@@ -34,7 +54,7 @@ export declare function quoteWindowsArgs(args: string[]): string[];
34
54
  * that prompts for input would otherwise wait on a pipe nobody writes.
35
55
  *
36
56
  * Lives in `utils/` (not a client adapter) because the CA-trust probe in
37
- * `forward-proxy/ca-trust.ts` shells out to platform trust tools too; a second
57
+ * `ingress-proxy/ca-trust.ts` shells out to platform trust tools too; a second
38
58
  * runner there would be a drift twin. The packaged JetBrains plugin keeps a
39
59
  * local copy of this contract (`plugins/jetbrains-gateway/exec.ts`) because a
40
60
  * plugin bundle must not import backend runtime modules.
@@ -1,4 +1,50 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ /** Spellings of "there is no such command", in the shells we spawn through.
5
+ * Best-effort only: cmd.exe writes its message in the console OEM codepage, so
6
+ * on a non-UTF-8 Windows it arrives here as mojibake and can never match. The
7
+ * authoritative signal is {@link commandResolves}. */
8
+ const COMMAND_NOT_FOUND_RE = /not recognized as an internal or external command|不是内部或外部命令|command not found|No such file or directory/i;
9
+ const isWin = process.platform === 'win32';
10
+ function isRunnableFile(file) {
11
+ try {
12
+ const stat = fs.statSync(file);
13
+ if (!stat.isFile())
14
+ return false;
15
+ // Windows has no execute bit — a readable file with a runnable extension is
16
+ // runnable; elsewhere the x bit is the answer.
17
+ return isWin ? true : (stat.mode & 0o111) !== 0;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
23
+ /**
24
+ * Would the shell resolve this command name? Locale-independent on purpose (see
25
+ * {@link COMMAND_NOT_FOUND_RE}) and consulted ONLY after a run has already
26
+ * failed, so it can never turn a working command into a "missing" one.
27
+ */
28
+ export function commandResolves(cmd) {
29
+ if (!cmd)
30
+ return false;
31
+ const extensions = isWin
32
+ ? ['', ...(process.env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean)]
33
+ : [''];
34
+ // A name carrying a separator is a path, not a PATH lookup.
35
+ if (cmd.includes('/') || cmd.includes('\\')) {
36
+ return extensions.some((ext) => isRunnableFile(cmd + ext));
37
+ }
38
+ // cmd.exe also resolves the CURRENT directory before PATH.
39
+ const dirs = [process.cwd(), ...(process.env.PATH ?? '').split(isWin ? ';' : ':').filter(Boolean)];
40
+ for (const dir of dirs) {
41
+ for (const ext of extensions) {
42
+ if (isRunnableFile(path.join(dir, cmd + ext)))
43
+ return true;
44
+ }
45
+ }
46
+ return false;
47
+ }
2
48
  /**
3
49
  * Quote ONE argv element for a cmd.exe command line.
4
50
  *
@@ -33,13 +79,12 @@ export function quoteWindowsArgs(args) {
33
79
  * that prompts for input would otherwise wait on a pipe nobody writes.
34
80
  *
35
81
  * Lives in `utils/` (not a client adapter) because the CA-trust probe in
36
- * `forward-proxy/ca-trust.ts` shells out to platform trust tools too; a second
82
+ * `ingress-proxy/ca-trust.ts` shells out to platform trust tools too; a second
37
83
  * runner there would be a drift twin. The packaged JetBrains plugin keeps a
38
84
  * local copy of this contract (`plugins/jetbrains-gateway/exec.ts`) because a
39
85
  * plugin bundle must not import backend runtime modules.
40
86
  */
41
87
  export async function runCommand(cmd, args, timeoutMs = 5000) {
42
- const isWin = process.platform === 'win32';
43
88
  const finalArgs = isWin ? quoteWindowsArgs(args) : args;
44
89
  // `new Promise` (not `Promise.withResolvers`): the backend tsconfig targets a
45
90
  // pre-ES2024 lib, and this file is the base every probe imports.
@@ -47,6 +92,8 @@ export async function runCommand(cmd, args, timeoutMs = 5000) {
47
92
  let stdout = '';
48
93
  let stderr = '';
49
94
  let settled = false;
95
+ let code = null;
96
+ let spawnEnoent = false;
50
97
  // POSIX: a new process group, so the deadline can kill the whole tree (a
51
98
  // shim spawns children that keep the pipes open). Windows has no group
52
99
  // kill — `taskkill /T` below.
@@ -61,7 +108,13 @@ export async function runCommand(cmd, args, timeoutMs = 5000) {
61
108
  return;
62
109
  settled = true;
63
110
  clearTimeout(timer);
64
- resolve({ ok, stdout, stderr });
111
+ // "There is no such command" — decided ONLY for a run that already
112
+ // failed, from three independent signals: a spawn-level ENOENT, the
113
+ // shell's own wording (when it survives the codepage), or our own
114
+ // PATH/PATHEXT resolution. A deadline kill leaves `code` null and the
115
+ // command resolvable, so a hung client is never reported as missing.
116
+ const notFound = !ok && (spawnEnoent || code === 9009 || COMMAND_NOT_FOUND_RE.test(stderr) || !commandResolves(cmd));
117
+ resolve({ ok, stdout, stderr, code, notFound });
65
118
  };
66
119
  const timer = setTimeout(() => {
67
120
  stderr += `${stderr ? '\n' : ''}${cmd}: timed out after ${timeoutMs}ms`;
@@ -86,8 +139,15 @@ export async function runCommand(cmd, args, timeoutMs = 5000) {
86
139
  proc.stderr?.on('data', (c) => (stderr += String(c)));
87
140
  proc.on('error', (err) => {
88
141
  stderr += `${stderr ? '\n' : ''}${String(err)}`;
142
+ // Only a spawn-level ENOENT means "no such command"; every other spawn
143
+ // error (EACCES, EMFILE…) is a failure of a command that DOES exist.
144
+ if (err.code === 'ENOENT')
145
+ spawnEnoent = true;
89
146
  finish(false);
90
147
  });
91
- proc.on('close', (code) => finish(code === 0));
148
+ proc.on('close', (c) => {
149
+ code = typeof c === 'number' ? c : null;
150
+ finish(code === 0);
151
+ });
92
152
  });
93
153
  }
@@ -7,8 +7,9 @@ import type http from 'node:http';
7
7
  * quietly re-pick its own timeouts. Leaving these to the runtime is not neutral:
8
8
  * Node ships 300s / 60s / 5s, Bun ships none, so the same slow client holds a
9
9
  * socket open forever on one runtime and is reaped on the other. These values
10
- * match Node's shipped numbers deliberately — on Node this changes nothing, it
11
- * makes Bun behave like Node instead of behaving undefined.
10
+ * align with Node's raw `http` defaults, but Fastify's init defaults differ
11
+ * (requestTimeout 0, headersTimeout 60s, keepAliveTimeout 72s) - so assigning
12
+ * them is a real behavior change on both runtimes, not a no-op on Node.
12
13
  *
13
14
  * Per-chunk body progress is a DIFFERENT bound that a server-level clock cannot
14
15
  * express (`requestTimeout` measures the whole request, so a trickling client never
@@ -7,8 +7,9 @@ import { SERVER_HEADERS_TIMEOUT_MS, SERVER_KEEP_ALIVE_TIMEOUT_MS, SERVER_REQUEST
7
7
  * quietly re-pick its own timeouts. Leaving these to the runtime is not neutral:
8
8
  * Node ships 300s / 60s / 5s, Bun ships none, so the same slow client holds a
9
9
  * socket open forever on one runtime and is reaped on the other. These values
10
- * match Node's shipped numbers deliberately — on Node this changes nothing, it
11
- * makes Bun behave like Node instead of behaving undefined.
10
+ * align with Node's raw `http` defaults, but Fastify's init defaults differ
11
+ * (requestTimeout 0, headersTimeout 60s, keepAliveTimeout 72s) - so assigning
12
+ * them is a real behavior change on both runtimes, not a no-op on Node.
12
13
  *
13
14
  * Per-chunk body progress is a DIFFERENT bound that a server-level clock cannot
14
15
  * express (`requestTimeout` measures the whole request, so a trickling client never
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Filesystem-safe file name for a (client-controlled) session id.
3
+ *
4
+ * ONE spelling, shared by every per-session on-disk store — the capture
5
+ * archive and the session-snapshot store both key a file by the gateway
6
+ * session id, and two divergent sanitizers would let one id name two
7
+ * different files (or two ids collide on one). Read and write call this
8
+ * verbatim, so names match by construction; there is no per-side
9
+ * normalization to keep in sync.
10
+ *
11
+ * An id that is already safe is kept verbatim for browsability; anything
12
+ * else (path traversal, separators, excess length) falls back to a stable
13
+ * content hash. `HASH_NAME_RE` reserves the hash output namespace: an id
14
+ * literally shaped like this function's own digest output goes through the
15
+ * hash branch (hash-of-hash), so a crafted `h_<16hex>` can never alias some
16
+ * other unsafe id's file. Case-insensitive because the verbatim branch
17
+ * accepts uppercase hex, which aliases the lowercase digest on
18
+ * case-insensitive filesystems (Windows/macOS).
19
+ *
20
+ * Migration note (capture): archives written before that guard for a literal
21
+ * `h_<16hex>` id keep their old verbatim name and become read-side orphans
22
+ * (the reader now resolves that id to the hash-of-hash name). They stay
23
+ * visible and deletable through the captures directory browser, and the
24
+ * retention sweep backstops them — existing files are never rewritten.
25
+ */
26
+ export declare const SAFE_SESSION_RE: RegExp;
27
+ export declare const HASH_NAME_RE: RegExp;
28
+ export declare function sessionFileName(sessionId: string, suffix?: string): string;
@@ -0,0 +1,34 @@
1
+ import crypto from 'node:crypto';
2
+ /**
3
+ * Filesystem-safe file name for a (client-controlled) session id.
4
+ *
5
+ * ONE spelling, shared by every per-session on-disk store — the capture
6
+ * archive and the session-snapshot store both key a file by the gateway
7
+ * session id, and two divergent sanitizers would let one id name two
8
+ * different files (or two ids collide on one). Read and write call this
9
+ * verbatim, so names match by construction; there is no per-side
10
+ * normalization to keep in sync.
11
+ *
12
+ * An id that is already safe is kept verbatim for browsability; anything
13
+ * else (path traversal, separators, excess length) falls back to a stable
14
+ * content hash. `HASH_NAME_RE` reserves the hash output namespace: an id
15
+ * literally shaped like this function's own digest output goes through the
16
+ * hash branch (hash-of-hash), so a crafted `h_<16hex>` can never alias some
17
+ * other unsafe id's file. Case-insensitive because the verbatim branch
18
+ * accepts uppercase hex, which aliases the lowercase digest on
19
+ * case-insensitive filesystems (Windows/macOS).
20
+ *
21
+ * Migration note (capture): archives written before that guard for a literal
22
+ * `h_<16hex>` id keep their old verbatim name and become read-side orphans
23
+ * (the reader now resolves that id to the hash-of-hash name). They stay
24
+ * visible and deletable through the captures directory browser, and the
25
+ * retention sweep backstops them — existing files are never rewritten.
26
+ */
27
+ export const SAFE_SESSION_RE = /^[\w.@:-]{1,80}$/;
28
+ export const HASH_NAME_RE = /^h_[0-9a-f]{16}$/i;
29
+ export function sessionFileName(sessionId, suffix = '.jsonl') {
30
+ if (SAFE_SESSION_RE.test(sessionId) && !HASH_NAME_RE.test(sessionId))
31
+ return sessionId + suffix;
32
+ const hash = crypto.createHash('sha256').update(sessionId).digest('hex').slice(0, 16);
33
+ return `h_${hash}${suffix}`;
34
+ }
@@ -0,0 +1,39 @@
1
+ <svg width="120" height="120" viewBox="0 0 136 136" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <style>
3
+ .fav-bg { fill: #FFFFFF; }
4
+ @media (prefers-color-scheme: dark) {
5
+ .fav-bg { fill: #000000; }
6
+ }
7
+ </style>
8
+ <circle class="fav-bg" cx="68" cy="68" r="65" fill="#FFFFFF"/>
9
+ <g transform="translate(12 10)">
10
+ <path d="M89.6992 93.695C94.3659 97.195 101.366 94.8617 94.9492 88.445C75.6992 69.7783 79.7825 18.445 55.8659 18.445C31.9492 18.445 36.0325 69.7783 16.7825 88.445C9.78251 95.445 17.3658 97.195 22.0325 93.695C40.1159 81.445 38.9492 59.8617 55.8659 59.8617C72.7825 59.8617 71.6159 81.445 89.6992 93.695Z" fill="#3186FF"/>
11
+ <mask id="ag_fav_m" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="13" y="18" width="85" height="78">
12
+ <path d="M89.6992 93.695C94.3659 97.195 101.366 94.8617 94.9492 88.445C75.6992 69.7783 79.7825 18.445 55.8659 18.445C31.9492 18.445 36.0325 69.7783 16.7825 88.445C9.78251 95.445 17.3658 97.195 22.0325 93.695C40.1159 81.445 38.9492 59.8617 55.8659 59.8617C72.7825 59.8617 71.6159 81.445 89.6992 93.695Z" fill="black"/>
13
+ </mask>
14
+ <g mask="url(#ag_fav_m)">
15
+ <g filter="url(#ag_fav_f0)"><ellipse cx="22.7873" cy="26.8098" rx="22.7873" ry="26.8098" transform="matrix(-0.112784 0.99362 -0.99362 -0.112781 66.2473 -15.5344)" fill="#FFE432"/></g>
16
+ <g filter="url(#ag_fav_f1)"><ellipse cx="96.491" cy="35.1231" rx="29.5007" ry="30.1492" transform="rotate(76.9243 96.491 35.1231)" fill="#FC413D"/></g>
17
+ <g filter="url(#ag_fav_f2)"><ellipse cx="9.02988" cy="41.6647" rx="30.832" ry="39.9417" transform="rotate(74.1257 9.02988 41.6647)" fill="#00B95C"/></g>
18
+ <g filter="url(#ag_fav_f3)"><ellipse cx="11.2212" cy="42.8915" rx="30.22" ry="33.2695" transform="rotate(45.6065 11.2212 42.8915)" fill="#00B95C"/></g>
19
+ <g filter="url(#ag_fav_f4)"><ellipse cx="75.7546" cy="104.822" rx="29.0177" ry="27.943" transform="rotate(76.9243 75.7546 104.822)" fill="#3186FF"/></g>
20
+ <g filter="url(#ag_fav_f5)"><ellipse cx="33.5661" cy="35.4043" rx="33.5661" ry="35.4043" transform="matrix(-0.409539 0.912293 -0.912294 -0.409537 101.25 -15.1674)" fill="#FBBC04"/></g>
21
+ <g filter="url(#ag_fav_f6)"><path d="M2.56802 149.695C-15.8116 142.48 15.5987 83.1163 23.4093 63.2203C31.22 43.3244 52.4514 33.0447 70.831 40.26C89.2107 47.4753 110.996 87.2162 103.185 107.112C95.3742 127.008 20.9477 156.91 2.56802 149.695Z" fill="#3186FF"/></g>
22
+ <g filter="url(#ag_fav_f7)"><path d="M113.934 75.8079C109.013 81.5509 96.1724 78.6224 85.253 69.2667C74.3335 59.911 69.4704 47.6711 74.391 41.928C79.3116 36.185 92.1525 39.1136 103.072 48.4692C113.991 57.8249 118.855 70.0648 113.934 75.8079Z" fill="#749BFF"/></g>
23
+ <g filter="url(#ag_fav_f8)"><ellipse cx="92.611" cy="23.7962" rx="44.2411" ry="27.5016" transform="rotate(34.0763 92.611 23.7962)" fill="#FC413D"/></g>
24
+ <g filter="url(#ag_fav_f9)"><ellipse cx="23.4949" cy="29.5887" rx="23.7071" ry="13.7869" transform="rotate(112.516 23.4949 29.5887)" fill="#FFEE48"/></g>
25
+ </g>
26
+ </g>
27
+ <defs>
28
+ <filter id="ag_fav_f0" x="2.49348" y="-26.5423" width="69.0899" height="61.2525" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="3.89034"/></filter>
29
+ <filter id="ag_fav_f1" x="28.7524" y="-32.0333" width="135.477" height="134.313" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="18.8078"/></filter>
30
+ <filter id="ag_fav_f2" x="-62.2884" y="-21.9253" width="142.637" height="127.18" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="15.9884"/></filter>
31
+ <filter id="ag_fav_f3" x="-52.5697" y="-20.8346" width="127.582" height="127.452" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="15.9884"/></filter>
32
+ <filter id="ag_fav_f4" x="17.3619" y="45.4646" width="116.786" height="118.715" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="15.1937"/></filter>
33
+ <filter id="ag_fav_f5" x="-7.44765" y="-60.4737" width="125.303" height="122.858" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="13.7698"/></filter>
34
+ <filter id="ag_fav_f6" x="-27.7086" y="13.3597" width="157.119" height="162.029" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="12.297"/></filter>
35
+ <filter id="ag_fav_f7" x="50.4638" y="16.981" width="87.3973" height="83.7738" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="11.0036"/></filter>
36
+ <filter id="ag_fav_f8" x="34.2604" y="-28.457" width="116.701" height="104.506" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="9.29385"/></filter>
37
+ <filter id="ag_fav_f9" x="-15.1522" y="-15.9493" width="77.2941" height="91.076" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="11.5027"/></filter>
38
+ </defs>
39
+ </svg>
@@ -0,0 +1 @@
1
+ <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 65 65"><mask id="maskme" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="65" height="65"><path d="M32.447 0c.68 0 1.273.465 1.439 1.125a38.904 38.904 0 001.999 5.905c2.152 5 5.105 9.376 8.854 13.125 3.751 3.75 8.126 6.703 13.125 8.855a38.98 38.98 0 005.906 1.999c.66.166 1.124.758 1.124 1.438 0 .68-.464 1.273-1.125 1.439a38.902 38.902 0 00-5.905 1.999c-5 2.152-9.375 5.105-13.125 8.854-3.749 3.751-6.702 8.126-8.854 13.125a38.973 38.973 0 00-2 5.906 1.485 1.485 0 01-1.438 1.124c-.68 0-1.272-.464-1.438-1.125a38.913 38.913 0 00-2-5.905c-2.151-5-5.103-9.375-8.854-13.125-3.75-3.749-8.125-6.702-13.125-8.854a38.973 38.973 0 00-5.905-2A1.485 1.485 0 010 32.448c0-.68.465-1.272 1.125-1.438a38.903 38.903 0 005.905-2c5-2.151 9.376-5.104 13.125-8.854 3.75-3.749 6.703-8.125 8.855-13.125a38.972 38.972 0 001.999-5.905A1.485 1.485 0 0132.447 0z" fill="#000"/><path d="M32.447 0c.68 0 1.273.465 1.439 1.125a38.904 38.904 0 001.999 5.905c2.152 5 5.105 9.376 8.854 13.125 3.751 3.75 8.126 6.703 13.125 8.855a38.98 38.98 0 005.906 1.999c.66.166 1.124.758 1.124 1.438 0 .68-.464 1.273-1.125 1.439a38.902 38.902 0 00-5.905 1.999c-5 2.152-9.375 5.105-13.125 8.854-3.749 3.751-6.702 8.126-8.854 13.125a38.973 38.973 0 00-2 5.906 1.485 1.485 0 01-1.438 1.124c-.68 0-1.272-.464-1.438-1.125a38.913 38.913 0 00-2-5.905c-2.151-5-5.103-9.375-8.854-13.125-3.75-3.749-8.125-6.702-13.125-8.854a38.973 38.973 0 00-5.905-2A1.485 1.485 0 010 32.448c0-.68.465-1.272 1.125-1.438a38.903 38.903 0 005.905-2c5-2.151 9.376-5.104 13.125-8.854 3.75-3.749 6.703-8.125 8.855-13.125a38.972 38.972 0 001.999-5.905A1.485 1.485 0 0132.447 0z" fill="url(#prefix__paint0_linear_2001_67)"/></mask><g mask="url(#maskme)"><g filter="url(#prefix__filter0_f_2001_67)"><path d="M-5.859 50.734c7.498 2.663 16.116-2.33 19.249-11.152 3.133-8.821-.406-18.131-7.904-20.794-7.498-2.663-16.116 2.33-19.25 11.151-3.132 8.822.407 18.132 7.905 20.795z" fill="#FFE432"/></g><g filter="url(#prefix__filter1_f_2001_67)"><path d="M27.433 21.649c10.3 0 18.651-8.535 18.651-19.062 0-10.528-8.35-19.062-18.651-19.062S8.78-7.94 8.78 2.587c0 10.527 8.35 19.062 18.652 19.062z" fill="#FC413D"/></g><g filter="url(#prefix__filter2_f_2001_67)"><path d="M20.184 82.608c10.753-.525 18.918-12.244 18.237-26.174-.68-13.93-9.95-24.797-20.703-24.271C6.965 32.689-1.2 44.407-.519 58.337c.681 13.93 9.95 24.797 20.703 24.271z" fill="#00B95C"/></g><g filter="url(#prefix__filter3_f_2001_67)"><path d="M20.184 82.608c10.753-.525 18.918-12.244 18.237-26.174-.68-13.93-9.95-24.797-20.703-24.271C6.965 32.689-1.2 44.407-.519 58.337c.681 13.93 9.95 24.797 20.703 24.271z" fill="#00B95C"/></g><g filter="url(#prefix__filter4_f_2001_67)"><path d="M30.954 74.181c9.014-5.485 11.427-17.976 5.389-27.9-6.038-9.925-18.241-13.524-27.256-8.04-9.015 5.486-11.428 17.977-5.39 27.902 6.04 9.924 18.242 13.523 27.257 8.038z" fill="#00B95C"/></g><g filter="url(#prefix__filter5_f_2001_67)"><path d="M67.391 42.993c10.132 0 18.346-7.91 18.346-17.666 0-9.757-8.214-17.667-18.346-17.667s-18.346 7.91-18.346 17.667c0 9.757 8.214 17.666 18.346 17.666z" fill="#3186FF"/></g><g filter="url(#prefix__filter6_f_2001_67)"><path d="M-13.065 40.944c9.33 7.094 22.959 4.869 30.442-4.972 7.483-9.84 5.987-23.569-3.343-30.663C4.704-1.786-8.924.439-16.408 10.28c-7.483 9.84-5.986 23.57 3.343 30.664z" fill="#FBBC04"/></g><g filter="url(#prefix__filter7_f_2001_67)"><path d="M34.74 51.43c11.135 7.656 25.896 5.524 32.968-4.764 7.073-10.287 3.779-24.832-7.357-32.488C49.215 6.52 34.455 8.654 27.382 18.94c-7.072 10.288-3.779 24.833 7.357 32.49z" fill="#3186FF"/></g><g filter="url(#prefix__filter8_f_2001_67)"><path d="M54.984-2.336c2.833 3.852-.808 11.34-8.131 16.727-7.324 5.387-15.557 6.631-18.39 2.78-2.833-3.853.807-11.342 8.13-16.728 7.324-5.387 15.558-6.631 18.39-2.78z" fill="#749BFF"/></g><g filter="url(#prefix__filter9_f_2001_67)"><path d="M31.727 16.104C43.053 5.598 46.94-8.626 40.41-15.666c-6.53-7.04-21.006-4.232-32.332 6.274s-15.214 24.73-8.683 31.77c6.53 7.04 21.006 4.232 32.332-6.274z" fill="#FC413D"/></g><g filter="url(#prefix__filter10_f_2001_67)"><path d="M8.51 53.838c6.732 4.818 14.46 5.55 17.262 1.636 2.802-3.915-.384-10.994-7.116-15.812-6.731-4.818-14.46-5.55-17.261-1.636-2.802 3.915.383 10.994 7.115 15.812z" fill="#FFEE48"/></g></g><defs><filter id="prefix__filter0_f_2001_67" x="-19.824" y="13.152" width="39.274" height="43.217" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="2.46" result="effect1_foregroundBlur_2001_67"/></filter><filter id="prefix__filter1_f_2001_67" x="-15.001" y="-40.257" width="84.868" height="85.688" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="11.891" result="effect1_foregroundBlur_2001_67"/></filter><filter id="prefix__filter2_f_2001_67" x="-20.776" y="11.927" width="79.454" height="90.916" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="10.109" result="effect1_foregroundBlur_2001_67"/></filter><filter id="prefix__filter3_f_2001_67" x="-20.776" y="11.927" width="79.454" height="90.916" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="10.109" result="effect1_foregroundBlur_2001_67"/></filter><filter id="prefix__filter4_f_2001_67" x="-19.845" y="15.459" width="79.731" height="81.505" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="10.109" result="effect1_foregroundBlur_2001_67"/></filter><filter id="prefix__filter5_f_2001_67" x="29.832" y="-11.552" width="75.117" height="73.758" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="9.606" result="effect1_foregroundBlur_2001_67"/></filter><filter id="prefix__filter6_f_2001_67" x="-38.583" y="-16.253" width="78.135" height="78.758" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="8.706" result="effect1_foregroundBlur_2001_67"/></filter><filter id="prefix__filter7_f_2001_67" x="8.107" y="-5.966" width="78.877" height="77.539" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="7.775" result="effect1_foregroundBlur_2001_67"/></filter><filter id="prefix__filter8_f_2001_67" x="13.587" y="-18.488" width="56.272" height="51.81" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="6.957" result="effect1_foregroundBlur_2001_67"/></filter><filter id="prefix__filter9_f_2001_67" x="-15.526" y="-31.297" width="70.856" height="69.306" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="5.876" result="effect1_foregroundBlur_2001_67"/></filter><filter id="prefix__filter10_f_2001_67" x="-14.168" y="20.964" width="55.501" height="51.571" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="7.273" result="effect1_foregroundBlur_2001_67"/></filter><linearGradient id="prefix__paint0_linear_2001_67" x1="18.447" y1="43.42" x2="52.153" y2="15.004" gradientUnits="userSpaceOnUse"><stop stop-color="#4893FC"/><stop offset=".27" stop-color="#4893FC"/><stop offset=".777" stop-color="#969DFF"/><stop offset="1" stop-color="#BD99FE"/></linearGradient></defs></svg>