@pyric/cli 0.1.0-alpha.20 → 0.1.0-alpha.22

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 (502) hide show
  1. package/README.md +64 -89
  2. package/dist/assurance/.generated/conformance-verdicts.d.ts +238 -1
  3. package/dist/assurance/.generated/conformance-verdicts.d.ts.map +1 -1
  4. package/dist/assurance/.generated/conformance-verdicts.js +238 -1
  5. package/dist/assurance/.generated/conformance-verdicts.js.map +1 -1
  6. package/dist/bridge/client/dispatch.d.ts +25 -19
  7. package/dist/bridge/client/dispatch.d.ts.map +1 -1
  8. package/dist/bridge/client/dispatch.js +41 -48
  9. package/dist/bridge/client/dispatch.js.map +1 -1
  10. package/dist/bridge/client/tool-family-factories.d.ts +26 -0
  11. package/dist/bridge/client/tool-family-factories.d.ts.map +1 -0
  12. package/dist/bridge/client/tool-family-factories.js +10 -0
  13. package/dist/bridge/client/tool-family-factories.js.map +1 -0
  14. package/dist/bridge/server/mcp-contract.d.ts +7 -6
  15. package/dist/bridge/server/mcp-contract.d.ts.map +1 -1
  16. package/dist/bridge/server/mcp-contract.js +9 -48
  17. package/dist/bridge/server/mcp-contract.js.map +1 -1
  18. package/dist/bridge/server/peer.d.ts +11 -1
  19. package/dist/bridge/server/peer.d.ts.map +1 -1
  20. package/dist/bridge/server/peer.js +22 -1
  21. package/dist/bridge/server/peer.js.map +1 -1
  22. package/dist/bridge/server/tool-family-factories.d.ts +30 -0
  23. package/dist/bridge/server/tool-family-factories.d.ts.map +1 -0
  24. package/dist/bridge/server/tool-family-factories.js +22 -0
  25. package/dist/bridge/server/tool-family-factories.js.map +1 -0
  26. package/dist/bridge/server/tool-metadata.d.ts +17 -18
  27. package/dist/bridge/server/tool-metadata.d.ts.map +1 -1
  28. package/dist/bridge/server/tool-metadata.js +24 -59
  29. package/dist/bridge/server/tool-metadata.js.map +1 -1
  30. package/dist/bridge/tool-families.d.ts +48 -0
  31. package/dist/bridge/tool-families.d.ts.map +1 -0
  32. package/dist/bridge/tool-families.generated.d.ts +32 -0
  33. package/dist/bridge/tool-families.generated.d.ts.map +1 -0
  34. package/dist/bridge/tool-families.generated.js +15 -0
  35. package/dist/bridge/tool-families.generated.js.map +1 -0
  36. package/dist/bridge/tool-families.js +51 -0
  37. package/dist/bridge/tool-families.js.map +1 -0
  38. package/dist/bridge/tool-family-records/conformance.d.ts +7 -0
  39. package/dist/bridge/tool-family-records/conformance.d.ts.map +1 -0
  40. package/dist/bridge/tool-family-records/conformance.js +6 -0
  41. package/dist/bridge/tool-family-records/conformance.js.map +1 -0
  42. package/dist/bridge/tool-family-records/firestore-data.d.ts +7 -0
  43. package/dist/bridge/tool-family-records/firestore-data.d.ts.map +1 -0
  44. package/dist/bridge/tool-family-records/firestore-data.js +15 -0
  45. package/dist/bridge/tool-family-records/firestore-data.js.map +1 -0
  46. package/dist/bridge/tool-family-records/firestore-inspect.d.ts +7 -0
  47. package/dist/bridge/tool-family-records/firestore-inspect.d.ts.map +1 -0
  48. package/dist/bridge/tool-family-records/firestore-inspect.js +6 -0
  49. package/dist/bridge/tool-family-records/firestore-inspect.js.map +1 -0
  50. package/dist/bridge/tool-family-records/firestore-rules.d.ts +7 -0
  51. package/dist/bridge/tool-family-records/firestore-rules.d.ts.map +1 -0
  52. package/dist/bridge/tool-family-records/firestore-rules.js +15 -0
  53. package/dist/bridge/tool-family-records/firestore-rules.js.map +1 -0
  54. package/dist/bridge/tool-family-records/firestore-simulator.d.ts +7 -0
  55. package/dist/bridge/tool-family-records/firestore-simulator.d.ts.map +1 -0
  56. package/dist/bridge/tool-family-records/firestore-simulator.js +16 -0
  57. package/dist/bridge/tool-family-records/firestore-simulator.js.map +1 -0
  58. package/dist/bridge/tool-family-records/rtdb-inspection.d.ts +7 -0
  59. package/dist/bridge/tool-family-records/rtdb-inspection.d.ts.map +1 -0
  60. package/dist/bridge/tool-family-records/rtdb-inspection.js +6 -0
  61. package/dist/bridge/tool-family-records/rtdb-inspection.js.map +1 -0
  62. package/dist/bundler/externals.d.ts +37 -0
  63. package/dist/bundler/externals.d.ts.map +1 -0
  64. package/dist/bundler/externals.js +52 -0
  65. package/dist/bundler/externals.js.map +1 -0
  66. package/dist/bundler/index.d.ts +17 -0
  67. package/dist/bundler/index.d.ts.map +1 -0
  68. package/dist/bundler/index.js +17 -0
  69. package/dist/bundler/index.js.map +1 -0
  70. package/dist/cli/inlined-sdk-scanner.d.ts +6 -0
  71. package/dist/cli/inlined-sdk-scanner.d.ts.map +1 -0
  72. package/dist/cli/inlined-sdk-scanner.js +82 -0
  73. package/dist/cli/inlined-sdk-scanner.js.map +1 -0
  74. package/dist/cli/sandbox-interlock.d.ts +97 -0
  75. package/dist/cli/sandbox-interlock.d.ts.map +1 -0
  76. package/dist/cli/sandbox-interlock.js +112 -0
  77. package/dist/cli/sandbox-interlock.js.map +1 -0
  78. package/dist/cli/sandbox-runner.d.ts +20 -12
  79. package/dist/cli/sandbox-runner.d.ts.map +1 -1
  80. package/dist/cli/sandbox-runner.js +24 -21
  81. package/dist/cli/sandbox-runner.js.map +1 -1
  82. package/dist/cli/serve.d.ts +6 -10
  83. package/dist/cli/serve.d.ts.map +1 -1
  84. package/dist/cli/serve.js +57 -77
  85. package/dist/cli/serve.js.map +1 -1
  86. package/dist/cli/unsupported-runtime.d.ts +27 -0
  87. package/dist/cli/unsupported-runtime.d.ts.map +1 -0
  88. package/dist/cli/unsupported-runtime.js +63 -0
  89. package/dist/cli/unsupported-runtime.js.map +1 -0
  90. package/dist/conformance/.generated/can-i-use-browser.d.ts +1 -1
  91. package/dist/conformance/.generated/can-i-use-browser.d.ts.map +1 -1
  92. package/dist/conformance/.generated/can-i-use-browser.js +1 -1
  93. package/dist/conformance/.generated/can-i-use-browser.js.map +1 -1
  94. package/dist/conformance/.generated/can-i-use.d.ts +1 -1
  95. package/dist/conformance/.generated/can-i-use.d.ts.map +1 -1
  96. package/dist/conformance/.generated/can-i-use.js +1 -1
  97. package/dist/conformance/.generated/can-i-use.js.map +1 -1
  98. package/dist/conformance/.generated/conformance-docs.d.ts.map +1 -1
  99. package/dist/conformance/.generated/conformance-docs.js +1 -1
  100. package/dist/conformance/.generated/conformance-docs.js.map +1 -1
  101. package/dist/functions-rtdb/child.d.ts +37 -0
  102. package/dist/functions-rtdb/child.d.ts.map +1 -1
  103. package/dist/functions-rtdb/child.js +90 -21
  104. package/dist/functions-rtdb/child.js.map +1 -1
  105. package/dist/functions-rtdb/development-runtime.d.ts +3 -0
  106. package/dist/functions-rtdb/development-runtime.d.ts.map +1 -1
  107. package/dist/functions-rtdb/development-runtime.js +1 -0
  108. package/dist/functions-rtdb/development-runtime.js.map +1 -1
  109. package/dist/google-endpoints.d.ts +67 -0
  110. package/dist/google-endpoints.d.ts.map +1 -0
  111. package/dist/google-endpoints.js +119 -0
  112. package/dist/google-endpoints.js.map +1 -0
  113. package/dist/next/runtime-env.d.ts.map +1 -1
  114. package/dist/next/runtime-env.js +5 -0
  115. package/dist/next/runtime-env.js.map +1 -1
  116. package/dist/next/with-pyric.d.ts +1 -1
  117. package/dist/next/with-pyric.js +1 -1
  118. package/dist/register/beacon.d.ts +69 -0
  119. package/dist/register/beacon.d.ts.map +1 -0
  120. package/dist/register/beacon.js +199 -0
  121. package/dist/register/beacon.js.map +1 -0
  122. package/dist/register/index.d.ts.map +1 -1
  123. package/dist/register/index.js +65 -6
  124. package/dist/register/index.js.map +1 -1
  125. package/dist/register/net-guard.d.ts +110 -0
  126. package/dist/register/net-guard.d.ts.map +1 -0
  127. package/dist/register/net-guard.js +462 -0
  128. package/dist/register/net-guard.js.map +1 -0
  129. package/dist/serve/ai-diagnostics-relay.d.ts +63 -0
  130. package/dist/serve/ai-diagnostics-relay.d.ts.map +1 -0
  131. package/dist/serve/ai-diagnostics-relay.js +125 -0
  132. package/dist/serve/ai-diagnostics-relay.js.map +1 -0
  133. package/dist/serve/ai-proxy.d.ts +92 -0
  134. package/dist/serve/ai-proxy.d.ts.map +1 -0
  135. package/dist/serve/ai-proxy.js +269 -0
  136. package/dist/serve/ai-proxy.js.map +1 -0
  137. package/dist/serve/ai-status.d.ts +44 -0
  138. package/dist/serve/ai-status.d.ts.map +1 -0
  139. package/dist/serve/ai-status.js +77 -0
  140. package/dist/serve/ai-status.js.map +1 -0
  141. package/dist/serve/ai-terminal-blocks.d.ts +97 -0
  142. package/dist/serve/ai-terminal-blocks.d.ts.map +1 -0
  143. package/dist/serve/ai-terminal-blocks.js +128 -0
  144. package/dist/serve/ai-terminal-blocks.js.map +1 -0
  145. package/dist/serve/ai-terminal-text.d.ts +36 -0
  146. package/dist/serve/ai-terminal-text.d.ts.map +1 -0
  147. package/dist/serve/ai-terminal-text.js +48 -0
  148. package/dist/serve/ai-terminal-text.js.map +1 -0
  149. package/dist/serve/beacon-route.d.ts +53 -0
  150. package/dist/serve/beacon-route.d.ts.map +1 -0
  151. package/dist/serve/beacon-route.js +101 -0
  152. package/dist/serve/beacon-route.js.map +1 -0
  153. package/dist/serve/entries/active-auth-registry.d.ts +16 -0
  154. package/dist/serve/entries/active-auth-registry.d.ts.map +1 -0
  155. package/dist/serve/entries/active-auth-registry.js +48 -0
  156. package/dist/serve/entries/active-auth-registry.js.map +1 -0
  157. package/dist/serve/entries/active-auth.d.ts +18 -0
  158. package/dist/serve/entries/active-auth.d.ts.map +1 -0
  159. package/dist/serve/entries/active-auth.js +84 -0
  160. package/dist/serve/entries/active-auth.js.map +1 -0
  161. package/dist/serve/entries/auth-helper-core.d.ts +1 -0
  162. package/dist/serve/entries/auth-helper-core.d.ts.map +1 -1
  163. package/dist/serve/entries/auth-helper-core.js +4 -0
  164. package/dist/serve/entries/auth-helper-core.js.map +1 -1
  165. package/dist/serve/entries/auth-helper-dom.d.ts.map +1 -1
  166. package/dist/serve/entries/auth-helper-dom.js +28 -2
  167. package/dist/serve/entries/auth-helper-dom.js.map +1 -1
  168. package/dist/serve/entries/auth.d.ts.map +1 -1
  169. package/dist/serve/entries/auth.js +8 -0
  170. package/dist/serve/entries/auth.js.map +1 -1
  171. package/dist/serve/entries/bridge-url.d.ts +1 -1
  172. package/dist/serve/entries/bridge-url.js +1 -1
  173. package/dist/serve/entries/init.d.ts.map +1 -1
  174. package/dist/serve/entries/init.js +70 -4
  175. package/dist/serve/entries/init.js.map +1 -1
  176. package/dist/serve/entries/runtime.d.ts.map +1 -1
  177. package/dist/serve/entries/runtime.js +9 -0
  178. package/dist/serve/entries/runtime.js.map +1 -1
  179. package/dist/serve/namespace.d.ts +14 -5
  180. package/dist/serve/namespace.d.ts.map +1 -1
  181. package/dist/serve/namespace.js +57 -124
  182. package/dist/serve/namespace.js.map +1 -1
  183. package/dist/serve/runtime/chip-config.d.ts.map +1 -1
  184. package/dist/serve/runtime/chip-config.js +16 -2
  185. package/dist/serve/runtime/chip-config.js.map +1 -1
  186. package/dist/serve/runtime/chip-dialog.d.ts +18 -0
  187. package/dist/serve/runtime/chip-dialog.d.ts.map +1 -0
  188. package/dist/serve/runtime/chip-dialog.js +315 -0
  189. package/dist/serve/runtime/chip-dialog.js.map +1 -0
  190. package/dist/serve/runtime/chip-install.d.ts +2 -0
  191. package/dist/serve/runtime/chip-install.d.ts.map +1 -1
  192. package/dist/serve/runtime/chip-install.js +9 -4
  193. package/dist/serve/runtime/chip-install.js.map +1 -1
  194. package/dist/serve/runtime/chip-user-search.d.ts +16 -0
  195. package/dist/serve/runtime/chip-user-search.d.ts.map +1 -0
  196. package/dist/serve/runtime/chip-user-search.js +354 -0
  197. package/dist/serve/runtime/chip-user-search.js.map +1 -0
  198. package/dist/serve/runtime/chip.d.ts +10 -0
  199. package/dist/serve/runtime/chip.d.ts.map +1 -1
  200. package/dist/serve/runtime/chip.js +118 -15
  201. package/dist/serve/runtime/chip.js.map +1 -1
  202. package/dist/serve/runtime/identity.d.ts +17 -0
  203. package/dist/serve/runtime/identity.d.ts.map +1 -0
  204. package/dist/serve/runtime/identity.js +10 -0
  205. package/dist/serve/runtime/identity.js.map +1 -0
  206. package/dist/serve/sandbox-session.d.ts +7 -0
  207. package/dist/serve/sandbox-session.d.ts.map +1 -1
  208. package/dist/serve/sandbox-session.js +2 -0
  209. package/dist/serve/sandbox-session.js.map +1 -1
  210. package/dist/serve/site-ui/_astro/{RulesCodeEditor.XtDmHOlN.js → RulesCodeEditor.DsTAsKIa.js} +1 -1
  211. package/dist/serve/site-ui/_astro/app.CMmTxyhL.js +1 -0
  212. package/dist/serve/site-ui/_astro/app.DhALsVii.js +115 -0
  213. package/dist/serve/site-ui/_astro/{chess-showcase.B72XYeoh.js → chess-showcase.Bn_pP6UJ.js} +2 -2
  214. package/dist/serve/site-ui/_astro/{example-runtime.C25_lx6Z.js → example-runtime.CXopTGv7.js} +1 -1
  215. package/dist/serve/site-ui/_astro/sandbox-controls.rOuZTOUG.js +510 -0
  216. package/dist/serve/site-ui/_astro/{seed.Co0yUJY5.js → seed.lywYbXZ0.js} +2 -2
  217. package/dist/serve/site-ui/_astro/writes.BsPBG3dp.js +653 -0
  218. package/dist/serve/site-ui/auth/index.html +1 -1
  219. package/dist/serve/site-ui/docs/_rhythm/index.html +1 -1
  220. package/dist/serve/site-ui/docs/agent/set-up-your-agent/index.html +1 -1
  221. package/dist/serve/site-ui/docs/agent/watch-and-review/index.html +1 -1
  222. package/dist/serve/site-ui/docs/agent/work-with-an-agent/index.html +1 -1
  223. package/dist/serve/site-ui/docs/ai-compat/index.html +1 -1
  224. package/dist/serve/site-ui/docs/api-reference/index.html +8 -1
  225. package/dist/serve/site-ui/docs/api-reference.md +7 -0
  226. package/dist/serve/site-ui/docs/app-compat/index.html +1 -1
  227. package/dist/serve/site-ui/docs/auth-compat/index.html +3 -3
  228. package/dist/serve/site-ui/docs/auth-compat.md +2 -2
  229. package/dist/serve/site-ui/docs/build/ai-logic/index.html +6 -1
  230. package/dist/serve/site-ui/docs/build/ai-logic.md +6 -0
  231. package/dist/serve/site-ui/docs/build/authentication/index.html +2 -2
  232. package/dist/serve/site-ui/docs/build/authentication.md +1 -1
  233. package/dist/serve/site-ui/docs/build/cloud-firestore/index.html +4 -2
  234. package/dist/serve/site-ui/docs/build/cloud-firestore.md +4 -0
  235. package/dist/serve/site-ui/docs/build/cloud-messaging/index.html +1 -1
  236. package/dist/serve/site-ui/docs/build/cloud-storage/index.html +1 -1
  237. package/dist/serve/site-ui/docs/build/realtime-database/index.html +1 -1
  238. package/dist/serve/site-ui/docs/conformance-scores/index.html +14 -2
  239. package/dist/serve/site-ui/docs/conformance-scores.md +13 -1
  240. package/dist/serve/site-ui/docs/create-pyric-reference-api/index.html +1 -1
  241. package/dist/serve/site-ui/docs/database-compat/index.html +44 -44
  242. package/dist/serve/site-ui/docs/database-compat.md +43 -43
  243. package/dist/serve/site-ui/docs/examples/chess/index.html +1 -1
  244. package/dist/serve/site-ui/docs/examples/index.html +1 -1
  245. package/dist/serve/site-ui/docs/firestore-compat/index.html +4 -4
  246. package/dist/serve/site-ui/docs/firestore-compat.md +3 -3
  247. package/dist/serve/site-ui/docs/firestore-flutter-compat/index.html +319 -0
  248. package/dist/serve/site-ui/docs/firestore-flutter-compat.md +344 -0
  249. package/dist/serve/site-ui/docs/firestore-kotlin-compat/index.html +319 -0
  250. package/dist/serve/site-ui/docs/firestore-kotlin-compat.md +344 -0
  251. package/dist/serve/site-ui/docs/firestore-swift-compat/index.html +490 -0
  252. package/dist/serve/site-ui/docs/firestore-swift-compat.md +517 -0
  253. package/dist/serve/site-ui/docs/functions-rtdb-compat/index.html +1 -1
  254. package/dist/serve/site-ui/docs/get-started/backend-bundlers/index.html +105 -0
  255. package/dist/serve/site-ui/docs/get-started/backend-bundlers.md +165 -0
  256. package/dist/serve/site-ui/docs/get-started/flutter/index.html +98 -0
  257. package/dist/serve/site-ui/docs/get-started/flutter.md +105 -0
  258. package/dist/serve/site-ui/docs/get-started/how-the-swap-works/index.html +1 -1
  259. package/dist/serve/site-ui/docs/get-started/nextjs/index.html +1 -1
  260. package/dist/serve/site-ui/docs/get-started/start-building/index.html +1 -1
  261. package/dist/serve/site-ui/docs/get-started/vite/index.html +1 -1
  262. package/dist/serve/site-ui/docs/index.json +3211 -1471
  263. package/dist/serve/site-ui/docs/messaging-compat/index.html +1 -1
  264. package/dist/serve/site-ui/docs/observe/resolve-runtime-status/index.html +4 -3
  265. package/dist/serve/site-ui/docs/observe/resolve-runtime-status.md +3 -1
  266. package/dist/serve/site-ui/docs/observe/see-whats-happening/index.html +1 -1
  267. package/dist/serve/site-ui/docs/observe/shape-your-data/index.html +1 -1
  268. package/dist/serve/site-ui/docs/observe/switch-and-impersonate-identities/index.html +110 -0
  269. package/dist/serve/site-ui/docs/observe/switch-and-impersonate-identities.md +134 -0
  270. package/dist/serve/site-ui/docs/overview/index.html +1 -1
  271. package/dist/serve/site-ui/docs/pyric-admin-app-reference-api/index.html +1 -1
  272. package/dist/serve/site-ui/docs/pyric-admin-auth-reference-api/index.html +1 -1
  273. package/dist/serve/site-ui/docs/pyric-admin-database-reference-api/index.html +1 -1
  274. package/dist/serve/site-ui/docs/pyric-admin-firestore-reference-api/index.html +1 -1
  275. package/dist/serve/site-ui/docs/pyric-admin-messaging-reference-api/index.html +1 -1
  276. package/dist/serve/site-ui/docs/pyric-admin-reference-api/index.html +1 -1
  277. package/dist/serve/site-ui/docs/pyric-admin-storage-reference-api/index.html +1 -1
  278. package/dist/serve/site-ui/docs/pyric-ai-reference-api/index.html +1 -1
  279. package/dist/serve/site-ui/docs/pyric-ai-scripting-reference-api/index.html +1 -1
  280. package/dist/serve/site-ui/docs/pyric-analytics-reference-api/index.html +124 -0
  281. package/dist/serve/site-ui/docs/pyric-analytics-reference-api.md +287 -0
  282. package/dist/serve/site-ui/docs/pyric-app-check-reference-api/index.html +87 -0
  283. package/dist/serve/site-ui/docs/pyric-app-check-reference-api.md +199 -0
  284. package/dist/serve/site-ui/docs/pyric-app-reference-api/index.html +1 -1
  285. package/dist/serve/site-ui/docs/pyric-auth-reference-api/index.html +6 -2
  286. package/dist/serve/site-ui/docs/pyric-auth-reference-api.md +2 -1
  287. package/dist/serve/site-ui/docs/pyric-cli-assurance-browser-reference-api/index.html +1 -1
  288. package/dist/serve/site-ui/docs/pyric-cli-assurance-reference-api/index.html +1 -1
  289. package/dist/serve/site-ui/docs/pyric-cli-bridge-client-reference-api/index.html +2 -2
  290. package/dist/serve/site-ui/docs/pyric-cli-bridge-client-reference-api.md +1 -1
  291. package/dist/serve/site-ui/docs/pyric-cli-bridge-reference-api/index.html +1 -1
  292. package/dist/serve/site-ui/docs/pyric-cli-bundler-reference-api/index.html +56 -0
  293. package/dist/serve/site-ui/docs/pyric-cli-bundler-reference-api.md +72 -0
  294. package/dist/serve/site-ui/docs/pyric-cli-conformance-browser-reference-api/index.html +4 -1
  295. package/dist/serve/site-ui/docs/pyric-cli-conformance-browser-reference-api.md +3 -0
  296. package/dist/serve/site-ui/docs/pyric-cli-conformance-docs-reference-api/index.html +1 -1
  297. package/dist/serve/site-ui/docs/pyric-cli-conformance-reference-api/index.html +4 -1
  298. package/dist/serve/site-ui/docs/pyric-cli-conformance-reference-api.md +3 -0
  299. package/dist/serve/site-ui/docs/pyric-cli-credentials-node-reference-api/index.html +1 -1
  300. package/dist/serve/site-ui/docs/pyric-cli-discover-reference-api/index.html +1 -1
  301. package/dist/serve/site-ui/docs/pyric-cli-next-reference-api/index.html +2 -2
  302. package/dist/serve/site-ui/docs/pyric-cli-next-reference-api.md +1 -1
  303. package/dist/serve/site-ui/docs/pyric-cli-register-app-bridge-reference-api/index.html +1 -1
  304. package/dist/serve/site-ui/docs/pyric-cli-register-reference-api/index.html +1 -1
  305. package/dist/serve/site-ui/docs/pyric-cli-remote-reference-api/index.html +34 -9
  306. package/dist/serve/site-ui/docs/pyric-cli-remote-reference-api.md +16 -8
  307. package/dist/serve/site-ui/docs/pyric-cli-serve-worker-reference-api/index.html +133 -93
  308. package/dist/serve/site-ui/docs/pyric-cli-serve-worker-reference-api.md +61 -1
  309. package/dist/serve/site-ui/docs/pyric-cli-verify-reference-api/index.html +2 -2
  310. package/dist/serve/site-ui/docs/pyric-cli-verify-reference-api.md +1 -1
  311. package/dist/serve/site-ui/docs/pyric-cli-vite-reference-api/index.html +2 -2
  312. package/dist/serve/site-ui/docs/pyric-cli-vite-reference-api.md +2 -2
  313. package/dist/serve/site-ui/docs/pyric-database-reference-api/index.html +2 -2
  314. package/dist/serve/site-ui/docs/pyric-database-reference-api.md +1 -1
  315. package/dist/serve/site-ui/docs/pyric-firestore-lite-reference-api/index.html +559 -0
  316. package/dist/serve/site-ui/docs/pyric-firestore-lite-reference-api.md +1240 -0
  317. package/dist/serve/site-ui/docs/pyric-firestore-reference-api/index.html +40 -11
  318. package/dist/serve/site-ui/docs/pyric-firestore-reference-api.md +18 -8
  319. package/dist/serve/site-ui/docs/pyric-functions-reference-api/index.html +67 -0
  320. package/dist/serve/site-ui/docs/pyric-functions-reference-api.md +149 -0
  321. package/dist/serve/site-ui/docs/pyric-messaging-reference-api/index.html +1 -1
  322. package/dist/serve/site-ui/docs/pyric-messaging-sw-reference-api/index.html +1 -1
  323. package/dist/serve/site-ui/docs/pyric-performance-reference-api/index.html +35 -0
  324. package/dist/serve/site-ui/docs/pyric-performance-reference-api.md +69 -0
  325. package/dist/serve/site-ui/docs/pyric-remote-config-reference-api/index.html +132 -0
  326. package/dist/serve/site-ui/docs/pyric-remote-config-reference-api.md +307 -0
  327. package/dist/serve/site-ui/docs/pyric-rules-reference-api/index.html +1 -1
  328. package/dist/serve/site-ui/docs/pyric-sandbox-database-reference-api/index.html +52 -17
  329. package/dist/serve/site-ui/docs/pyric-sandbox-database-reference-api.md +48 -9
  330. package/dist/serve/site-ui/docs/pyric-sandbox-firestore-reference-api/index.html +1 -1
  331. package/dist/serve/site-ui/docs/pyric-sandbox-reference-api/index.html +239 -49
  332. package/dist/serve/site-ui/docs/pyric-sandbox-reference-api.md +148 -31
  333. package/dist/serve/site-ui/docs/pyric-storage-reference-api/index.html +22 -4
  334. package/dist/serve/site-ui/docs/pyric-storage-reference-api.md +25 -3
  335. package/dist/serve/site-ui/docs/pyric-ui-agents-reference-api/index.html +26 -96
  336. package/dist/serve/site-ui/docs/pyric-ui-agents-reference-api.md +20 -51
  337. package/dist/serve/site-ui/docs/pyric-ui-auth-hooks-reference-api/index.html +1 -1
  338. package/dist/serve/site-ui/docs/pyric-ui-auth-reference-api/index.html +2 -2
  339. package/dist/serve/site-ui/docs/pyric-ui-auth-reference-api.md +1 -1
  340. package/dist/serve/site-ui/docs/pyric-ui-events-hooks-reference-api/index.html +1 -1
  341. package/dist/serve/site-ui/docs/pyric-ui-events-reference-api/index.html +1 -1
  342. package/dist/serve/site-ui/docs/pyric-ui-firestore-hooks-reference-api/index.html +1 -1
  343. package/dist/serve/site-ui/docs/pyric-ui-firestore-reference-api/index.html +2 -2
  344. package/dist/serve/site-ui/docs/pyric-ui-firestore-reference-api.md +1 -1
  345. package/dist/serve/site-ui/docs/pyric-ui-primitives-reference-api/index.html +124 -26
  346. package/dist/serve/site-ui/docs/pyric-ui-primitives-reference-api.md +58 -5
  347. package/dist/serve/site-ui/docs/pyric-ui-rtdb-reference-api/index.html +1 -1
  348. package/dist/serve/site-ui/docs/pyric-ui-rules-hooks-reference-api/index.html +1 -1
  349. package/dist/serve/site-ui/docs/pyric-ui-rules-reference-api/index.html +1 -1
  350. package/dist/serve/site-ui/docs/pyric-ui-storage-hooks-reference-api/index.html +1 -1
  351. package/dist/serve/site-ui/docs/pyric-ui-storage-reference-api/index.html +4 -5
  352. package/dist/serve/site-ui/docs/pyric-ui-storage-reference-api.md +3 -4
  353. package/dist/serve/site-ui/docs/pyric-ui-traffic-hooks-reference-api/index.html +1 -1
  354. package/dist/serve/site-ui/docs/pyric-ui-traffic-reference-api/index.html +1 -1
  355. package/dist/serve/site-ui/docs/reference/cli/index.html +6 -3
  356. package/dist/serve/site-ui/docs/reference/cli.md +8 -2
  357. package/dist/serve/site-ui/docs/rules-compat/index.html +10 -2
  358. package/dist/serve/site-ui/docs/rules-compat.md +9 -1
  359. package/dist/serve/site-ui/docs/secure/audit-your-rules/index.html +1 -1
  360. package/dist/serve/site-ui/docs/secure/firestore-rules-limits/index.html +1 -1
  361. package/dist/serve/site-ui/docs/secure/read-a-denial/index.html +1 -1
  362. package/dist/serve/site-ui/docs/secure/rtdb-rules-in-typescript/index.html +1 -1
  363. package/dist/serve/site-ui/docs/secure/rules-standard-library/index.html +1 -1
  364. package/dist/serve/site-ui/docs/secure/secure-it-with-rules/index.html +1 -1
  365. package/dist/serve/site-ui/docs/secure/simulate-and-lint/index.html +1 -1
  366. package/dist/serve/site-ui/docs/secure/write-a-rules-test-suite/index.html +1 -1
  367. package/dist/serve/site-ui/docs/ship/ship-to-production/index.html +1 -1
  368. package/dist/serve/site-ui/docs/ship/test-in-node/index.html +1 -1
  369. package/dist/serve/site-ui/docs/storage-compat/index.html +13 -13
  370. package/dist/serve/site-ui/docs/storage-compat.md +12 -12
  371. package/dist/serve/site-ui/docs/trust/how-we-know-it-matches-firebase/index.html +1 -1
  372. package/dist/serve/site-ui/docs/trust/rules-standard-library/index.html +1 -1
  373. package/dist/serve/site-ui/docs/trust/versioning-and-compatibility/index.html +1 -1
  374. package/dist/serve/site-ui/docs/tutorial/index.html +1 -1
  375. package/dist/serve/site-ui/examples/chess/index.html +1 -1
  376. package/dist/serve/site-ui/firestore/index.html +1 -1
  377. package/dist/serve/site-ui/llms.txt +13 -0
  378. package/dist/serve/site-ui/rtdb/index.html +1 -1
  379. package/dist/serve/site-ui/settings/index.html +1 -1
  380. package/dist/serve/site-ui/storage/index.html +1 -1
  381. package/dist/serve/site-ui/studio/index.html +1 -1
  382. package/dist/serve/site-ui/traffic/index.html +1 -1
  383. package/dist/serve/studio/disk-workspace.d.ts.map +1 -1
  384. package/dist/serve/studio/disk-workspace.js +64 -2
  385. package/dist/serve/studio/disk-workspace.js.map +1 -1
  386. package/dist/serve/vite-plugin.d.ts +7 -7
  387. package/dist/serve/vite-plugin.js +1 -1
  388. package/dist/serve/vite-plugin.js.map +1 -1
  389. package/dist/serve/vite-sandbox-generation.d.ts.map +1 -1
  390. package/dist/serve/vite-sandbox-generation.js +12 -0
  391. package/dist/serve/vite-sandbox-generation.js.map +1 -1
  392. package/dist/serve/worker/client/auth.js +1 -2
  393. package/dist/serve/worker/client/auth.js.map +1 -1
  394. package/dist/serve/worker/client/core.d.ts +21 -1
  395. package/dist/serve/worker/client/core.d.ts.map +1 -1
  396. package/dist/serve/worker/client/core.js +79 -3
  397. package/dist/serve/worker/client/core.js.map +1 -1
  398. package/dist/serve/worker/client.d.ts +1 -1
  399. package/dist/serve/worker/client.d.ts.map +1 -1
  400. package/dist/serve/worker/client.js +1 -1
  401. package/dist/serve/worker/client.js.map +1 -1
  402. package/dist/serve/worker/context-resolver.d.ts +30 -0
  403. package/dist/serve/worker/context-resolver.d.ts.map +1 -0
  404. package/dist/serve/worker/context-resolver.js +44 -0
  405. package/dist/serve/worker/context-resolver.js.map +1 -0
  406. package/dist/serve/worker/entry.js +23 -19
  407. package/dist/serve/worker/entry.js.map +1 -1
  408. package/dist/serve/worker/host/core.d.ts +1 -0
  409. package/dist/serve/worker/host/core.d.ts.map +1 -1
  410. package/dist/serve/worker/host/core.js +12 -6
  411. package/dist/serve/worker/host/core.js.map +1 -1
  412. package/dist/serve/worker/host/storage.js +2 -2
  413. package/dist/serve/worker/host-auth.js +1 -2
  414. package/dist/serve/worker/host-auth.js.map +1 -1
  415. package/dist/serve/worker/index.d.ts +1 -1
  416. package/dist/serve/worker/index.d.ts.map +1 -1
  417. package/dist/serve/worker/index.js +2 -2
  418. package/dist/serve/worker/index.js.map +1 -1
  419. package/dist/serve/worker/port-lifecycle.d.ts +18 -0
  420. package/dist/serve/worker/port-lifecycle.d.ts.map +1 -0
  421. package/dist/serve/worker/port-lifecycle.js +28 -0
  422. package/dist/serve/worker/port-lifecycle.js.map +1 -0
  423. package/dist/serve/worker/serve-init.d.ts.map +1 -1
  424. package/dist/serve/worker/serve-init.js +8 -2
  425. package/dist/serve/worker/serve-init.js.map +1 -1
  426. package/dist/verify/fixture.d.ts +1 -1
  427. package/package.json +16 -5
  428. package/src/assurance/.generated/conformance-verdicts.ts +238 -1
  429. package/src/bridge/client/dispatch.ts +52 -56
  430. package/src/bridge/client/tool-family-factories.ts +34 -0
  431. package/src/bridge/server/mcp-contract.ts +15 -59
  432. package/src/bridge/server/peer.ts +24 -1
  433. package/src/bridge/server/tool-family-factories.ts +40 -0
  434. package/src/bridge/server/tool-metadata.ts +29 -61
  435. package/src/bridge/tool-families.generated.ts +17 -0
  436. package/src/bridge/tool-families.ts +87 -0
  437. package/src/bridge/tool-family-records/conformance.ts +6 -0
  438. package/src/bridge/tool-family-records/firestore-data.ts +15 -0
  439. package/src/bridge/tool-family-records/firestore-inspect.ts +6 -0
  440. package/src/bridge/tool-family-records/firestore-rules.ts +15 -0
  441. package/src/bridge/tool-family-records/firestore-simulator.ts +16 -0
  442. package/src/bridge/tool-family-records/rtdb-inspection.ts +6 -0
  443. package/src/bundler/externals.ts +55 -0
  444. package/src/bundler/index.ts +21 -0
  445. package/src/cli/cli.test.ts +0 -44
  446. package/src/cli/inlined-sdk-scanner.ts +77 -0
  447. package/src/cli/sandbox-interlock.ts +167 -0
  448. package/src/cli/sandbox-runner.ts +37 -26
  449. package/src/cli/serve.ts +68 -69
  450. package/src/cli/unsupported-runtime.ts +68 -0
  451. package/src/conformance/.generated/can-i-use-browser.ts +2 -2
  452. package/src/conformance/.generated/can-i-use.ts +2 -2
  453. package/src/conformance/.generated/conformance-docs.ts +1 -1
  454. package/src/functions-rtdb/child.ts +115 -21
  455. package/src/functions-rtdb/development-runtime.ts +4 -0
  456. package/src/google-endpoints.ts +155 -0
  457. package/src/next/runtime-env.ts +5 -0
  458. package/src/next/with-pyric.ts +1 -1
  459. package/src/register/beacon.ts +232 -0
  460. package/src/register/index.ts +68 -6
  461. package/src/register/net-guard.ts +567 -0
  462. package/src/serve/ai-diagnostics-relay.ts +243 -0
  463. package/src/serve/ai-proxy.ts +327 -0
  464. package/src/serve/ai-status.ts +109 -0
  465. package/src/serve/ai-terminal-blocks.ts +210 -0
  466. package/src/serve/ai-terminal-text.ts +52 -0
  467. package/src/serve/beacon-route.ts +141 -0
  468. package/src/serve/entries/active-auth-registry.ts +56 -0
  469. package/src/serve/entries/active-auth.ts +100 -0
  470. package/src/serve/entries/auth-helper-core.ts +5 -0
  471. package/src/serve/entries/auth-helper-dom.ts +26 -2
  472. package/src/serve/entries/auth.ts +8 -0
  473. package/src/serve/entries/bridge-url.ts +1 -1
  474. package/src/serve/entries/init.ts +78 -3
  475. package/src/serve/entries/runtime.ts +10 -0
  476. package/src/serve/namespace.ts +73 -140
  477. package/src/serve/runtime/chip-config.ts +16 -2
  478. package/src/serve/runtime/chip-dialog.ts +366 -0
  479. package/src/serve/runtime/chip-install.ts +10 -4
  480. package/src/serve/runtime/chip-user-search.ts +391 -0
  481. package/src/serve/runtime/chip.ts +140 -15
  482. package/src/serve/runtime/identity.ts +26 -0
  483. package/src/serve/sandbox-session.ts +9 -0
  484. package/src/serve/studio/disk-workspace.ts +76 -2
  485. package/src/serve/vite-plugin.ts +8 -8
  486. package/src/serve/vite-sandbox-generation.ts +15 -0
  487. package/src/serve/worker/client/auth.ts +1 -1
  488. package/src/serve/worker/client/core.ts +80 -3
  489. package/src/serve/worker/client.ts +1 -1
  490. package/src/serve/worker/context-resolver.ts +60 -0
  491. package/src/serve/worker/entry.ts +22 -18
  492. package/src/serve/worker/host/core.ts +9 -7
  493. package/src/serve/worker/host/storage.ts +2 -2
  494. package/src/serve/worker/host-auth.ts +1 -1
  495. package/src/serve/worker/index.ts +4 -1
  496. package/src/serve/worker/port-lifecycle.ts +45 -0
  497. package/src/serve/worker/serve-init.ts +9 -2
  498. package/src/verify/fixture.ts +1 -1
  499. package/dist/serve/site-ui/_astro/app.B52xr-DK.js +0 -1
  500. package/dist/serve/site-ui/_astro/app.DWBraPUw.js +0 -12
  501. package/dist/serve/site-ui/_astro/sandbox-controls.DEpnKg-O.js +0 -1169
  502. package/dist/serve/site-ui/_astro/writes.rpjrFzmu.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AAK,IAAI;YAAE,OAAO;QAC7B,IAAI,CAAC;YACH,KAAK,OAAO,CAAC,kBAAkB,EAAE;gBAC/B,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;aAC9B,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBACZ,qEAAqE;YACvE,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,sEAAsE;QACxE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * `/__pyric/ai-proxy`: the same-origin passthrough to an OpenAI-compatible
3
+ * upstream, plus the terminal diagnostics that make an upstream failure
4
+ * visible to a developer with no browser console open.
5
+ *
6
+ * The route is always mounted; it only touches the network when a request
7
+ * arrives. Everything about WHERE it forwards is resolved by
8
+ * {@link resolveAiProxyUpstream}, which the startup banner (`ai-status.ts`)
9
+ * shares so the two can never disagree.
10
+ */
11
+ import type { IncomingMessage, ServerResponse } from 'node:http';
12
+ import type { ServeLogger } from './server.js';
13
+ /** The dev server's diagnostics throttle, as this module needs it: the
14
+ * denials route owns the instance, and the proxy shares it so a failing
15
+ * upstream cannot out-shout a denied listener. */
16
+ export interface AiDiagnosticThrottle {
17
+ shouldPrint(key: string, now: number): boolean;
18
+ }
19
+ /** Default upstream: local Ollama's OpenAI-compatible endpoint. */
20
+ export declare const AI_PROXY_DEFAULT_UPSTREAM = "http://localhost:11434/v1";
21
+ /** The route the dev server mounts for OpenAI-compatible traffic. */
22
+ export declare const AI_PROXY_ROUTE = "/__pyric/ai-proxy";
23
+ /** The upstream-failure shapes the proxy surfaces to the terminal. */
24
+ type AiProxyFailure = {
25
+ kind: 'unreachable';
26
+ target: string;
27
+ latencyMs: number;
28
+ cause: string;
29
+ } | {
30
+ kind: 'status';
31
+ target: string;
32
+ latencyMs: number;
33
+ status: number;
34
+ /** The upstream's raw `Retry-After` header, when it sent one. */
35
+ retryAfter?: string;
36
+ } | {
37
+ kind: 'stream-abort';
38
+ target: string;
39
+ latencyMs: number;
40
+ cause: string;
41
+ };
42
+ /**
43
+ * Format an upstream failure into the compact terminal block, the same
44
+ * ` [pyric] ...` idiom the denial relay prints, so ai-proxy trouble reads
45
+ * like every other dev-server diagnostic. Two lines: what went wrong, then
46
+ * the (redacted) upstream URL with the elapsed time. Exported for unit tests.
47
+ *
48
+ * A 429 says so in words (`rate limited`): the bare number reads as one more
49
+ * failed request, when it actually means the upstream is shedding load or the
50
+ * key is out of quota. When the upstream sent a `Retry-After`, a third line
51
+ * prints the wait it asked for, and states that NOTHING here waits on the
52
+ * developer's behalf. The proxy has no retry loop (the status rides straight
53
+ * through to the caller), so the backoff is the app's decision, not pyric's.
54
+ */
55
+ export declare function formatAiProxyWarning(failure: AiProxyFailure): string;
56
+ /**
57
+ * Resolve the upstream `/__pyric/ai-proxy` forwards to, and say WHERE that
58
+ * value came from. One resolution shared by the proxy handler (which needs
59
+ * the target) and the startup line (which needs the provenance, so a
60
+ * developer can tell a deliberate `PYRIC_AI_PROXY_UPSTREAM` from the Ollama
61
+ * default nobody chose).
62
+ */
63
+ export declare function resolveAiProxyUpstream(configured: string | undefined): {
64
+ target: string;
65
+ source: 'option' | 'env' | 'default';
66
+ };
67
+ /**
68
+ * Handle `POST /__pyric/ai-proxy/<suffix>`: a same-origin passthrough to the
69
+ * configured OpenAI-compatible upstream, so the browser openai engine
70
+ * (running in the served page or the SharedWorker host) reaches a localhost
71
+ * upstream like Ollama with ZERO CORS setup (no `OLLAMA_ORIGINS`, ever).
72
+ *
73
+ * Behavior:
74
+ * - POST only (the OpenAI chat-completions surface is POST); 405 otherwise.
75
+ * - the path suffix + query ride through verbatim
76
+ * (`/__pyric/ai-proxy/chat/completions` becomes `<upstream>/chat/completions`).
77
+ * - the request body is forwarded verbatim; headers minus the
78
+ * origin-sensitive/hop-by-hop set above (`authorization` DOES forward,
79
+ * since upstreams may require a key).
80
+ * - the response body is STREAMED through chunk-by-chunk. SSE passthrough
81
+ * must never buffer, or `stream: true` completions would arrive all at
82
+ * once at the end.
83
+ * - an unreachable upstream answers 502 with a plain-text explanation.
84
+ * - every upstream failure (unreachable/timeout, non-2xx status, mid-stream
85
+ * abort) ALSO prints a structured warning on the dev server's terminal
86
+ * logger; a stopped Ollama used to fail in total silence. Diagnostics
87
+ * only: nothing here changes what the caller receives. No logger wired
88
+ * means dropped silently (same opt-out contract as the denial relay).
89
+ */
90
+ export declare function handleAiProxy(configuredUpstream: string | undefined, throttle: AiDiagnosticThrottle, req: IncomingMessage, res: ServerResponse, url: URL, logger?: ServeLogger): Promise<void>;
91
+ export {};
92
+ //# sourceMappingURL=ai-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-proxy.d.ts","sourceRoot":"","sources":["../../src/serve/ai-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C;;mDAEmD;AACnD,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAChD;AAED,mEAAmE;AACnE,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE,qEAAqE;AACrE,eAAO,MAAM,cAAc,sBAAsB,CAAC;AA0BlD,sEAAsE;AACtE,KAAK,cAAc,GACf;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACzE;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACD;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAuD/E;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CA2BpE;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAA;CAAE,CAY1D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,aAAa,CACjC,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,QAAQ,EAAE,oBAAoB,EAC9B,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,GAAG,EACR,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAiHf"}
@@ -0,0 +1,269 @@
1
+ import { redactUrl } from 'pyric/ai/internal';
2
+ import { sanitizeForTerminal } from './ai-terminal-text.js';
3
+ /** Default upstream: local Ollama's OpenAI-compatible endpoint. */
4
+ export const AI_PROXY_DEFAULT_UPSTREAM = 'http://localhost:11434/v1';
5
+ /** The route the dev server mounts for OpenAI-compatible traffic. */
6
+ export const AI_PROXY_ROUTE = '/__pyric/ai-proxy';
7
+ /**
8
+ * Request headers that must NOT be forwarded upstream: origin-sensitive
9
+ * browser context (`origin`/`referer`/`cookie`, since the upstream is a
10
+ * different origin and must never see the page's), hop-by-hop headers, and
11
+ * the two the proxy re-derives (`host`, `content-length`). `accept-encoding`
12
+ * is dropped so fetch negotiates its own compression and the streamed body
13
+ * needs no length fixups.
14
+ */
15
+ const AI_PROXY_STRIPPED_HEADERS = new Set([
16
+ 'host',
17
+ 'origin',
18
+ 'referer',
19
+ 'cookie',
20
+ 'connection',
21
+ 'content-length',
22
+ 'accept-encoding',
23
+ 'keep-alive',
24
+ 'proxy-authorization',
25
+ 'te',
26
+ 'trailer',
27
+ 'transfer-encoding',
28
+ 'upgrade',
29
+ ]);
30
+ /** Longest `Retry-After` value echoed to the terminal (delta-seconds and
31
+ * HTTP-dates are both far shorter; anything longer is upstream noise). */
32
+ const AI_PROXY_RETRY_AFTER_MAX = 64;
33
+ /**
34
+ * Render a `Retry-After` value for the terminal, or `null` when there is
35
+ * nothing worth printing.
36
+ *
37
+ * The header is remote-authored, so it is sanitized and length-capped like
38
+ * every other upstream string that reaches the terminal. Delta-seconds (the
39
+ * common form) get an `s` suffix so the wait reads as a duration; the
40
+ * HTTP-date form is echoed verbatim, since `Wed, 21 Oct 2026 07:28:00 GMTs`
41
+ * would be nonsense.
42
+ */
43
+ function formatRetryAfter(raw) {
44
+ const clean = sanitizeForTerminal(raw).slice(0, AI_PROXY_RETRY_AFTER_MAX).trim();
45
+ if (clean === '')
46
+ return null;
47
+ if (/^\d+$/.test(clean))
48
+ return `${clean}s`;
49
+ return clean;
50
+ }
51
+ /**
52
+ * Mask credentials, then flatten and cap, in that order. Both the target and
53
+ * a raw fetch error message are remote-influenced: the URL carries whatever
54
+ * the page put in the query string, and an error message can quote it back.
55
+ */
56
+ function safeUpstreamText(text) {
57
+ return sanitizeForTerminal(redactUrl(text));
58
+ }
59
+ /**
60
+ * The throttle key for one upstream failure. A failing upstream fails on
61
+ * every request, so the key is the failure itself (kind, status, and the
62
+ * redacted target) rather than anything per-request: one line per window,
63
+ * exactly like a denied listener that re-fires.
64
+ */
65
+ function aiProxyThrottleKey(failure) {
66
+ const target = redactUrl(failure.target);
67
+ if (failure.kind === 'status')
68
+ return `ai-proxy status ${failure.status} ${target}`;
69
+ return `ai-proxy ${failure.kind} ${target}`;
70
+ }
71
+ /** Print one upstream failure, unless the throttle already printed it. */
72
+ function noteAiProxyFailure(failure, throttle, logger) {
73
+ if (logger === undefined)
74
+ return;
75
+ if (!throttle.shouldPrint(aiProxyThrottleKey(failure), Date.now()))
76
+ return;
77
+ logger.note(formatAiProxyWarning(failure));
78
+ }
79
+ /**
80
+ * Format an upstream failure into the compact terminal block, the same
81
+ * ` [pyric] ...` idiom the denial relay prints, so ai-proxy trouble reads
82
+ * like every other dev-server diagnostic. Two lines: what went wrong, then
83
+ * the (redacted) upstream URL with the elapsed time. Exported for unit tests.
84
+ *
85
+ * A 429 says so in words (`rate limited`): the bare number reads as one more
86
+ * failed request, when it actually means the upstream is shedding load or the
87
+ * key is out of quota. When the upstream sent a `Retry-After`, a third line
88
+ * prints the wait it asked for, and states that NOTHING here waits on the
89
+ * developer's behalf. The proxy has no retry loop (the status rides straight
90
+ * through to the caller), so the backoff is the app's decision, not pyric's.
91
+ */
92
+ export function formatAiProxyWarning(failure) {
93
+ const target = safeUpstreamText(failure.target);
94
+ let headline;
95
+ if (failure.kind === 'unreachable') {
96
+ headline = `upstream unreachable: ${safeUpstreamText(failure.cause)}`;
97
+ }
98
+ else if (failure.kind === 'status') {
99
+ const rateLimited = failure.status === 429;
100
+ headline = `upstream returned ${failure.status}${rateLimited ? ' (rate limited / quota exhausted)' : ''}`;
101
+ }
102
+ else {
103
+ headline = `upstream stream aborted mid-response: ${safeUpstreamText(failure.cause)}`;
104
+ }
105
+ const lines = [
106
+ ` ⚠ [pyric] ai-proxy: ${headline}`,
107
+ ` POST ${target} (${failure.latencyMs}ms)`,
108
+ ];
109
+ if (failure.kind === 'unreachable') {
110
+ lines.push(` set PYRIC_AI_PROXY_UPSTREAM to an OpenAI-compatible base URL (default ${AI_PROXY_DEFAULT_UPSTREAM})`);
111
+ }
112
+ if (failure.kind === 'status' && failure.retryAfter !== undefined) {
113
+ const wait = formatRetryAfter(failure.retryAfter);
114
+ if (wait !== null) {
115
+ lines.push(` Retry-After: ${wait}, no automatic retry; the status went to the caller`);
116
+ }
117
+ }
118
+ return lines.join('\n');
119
+ }
120
+ /**
121
+ * Resolve the upstream `/__pyric/ai-proxy` forwards to, and say WHERE that
122
+ * value came from. One resolution shared by the proxy handler (which needs
123
+ * the target) and the startup line (which needs the provenance, so a
124
+ * developer can tell a deliberate `PYRIC_AI_PROXY_UPSTREAM` from the Ollama
125
+ * default nobody chose).
126
+ */
127
+ export function resolveAiProxyUpstream(configured) {
128
+ const envUpstream = process.env.PYRIC_AI_PROXY_UPSTREAM;
129
+ let raw = AI_PROXY_DEFAULT_UPSTREAM;
130
+ let source = 'default';
131
+ if (configured !== undefined) {
132
+ raw = configured;
133
+ source = 'option';
134
+ }
135
+ else if (envUpstream !== undefined) {
136
+ raw = envUpstream;
137
+ source = 'env';
138
+ }
139
+ return { target: raw.replace(/\/$/, ''), source };
140
+ }
141
+ /**
142
+ * Handle `POST /__pyric/ai-proxy/<suffix>`: a same-origin passthrough to the
143
+ * configured OpenAI-compatible upstream, so the browser openai engine
144
+ * (running in the served page or the SharedWorker host) reaches a localhost
145
+ * upstream like Ollama with ZERO CORS setup (no `OLLAMA_ORIGINS`, ever).
146
+ *
147
+ * Behavior:
148
+ * - POST only (the OpenAI chat-completions surface is POST); 405 otherwise.
149
+ * - the path suffix + query ride through verbatim
150
+ * (`/__pyric/ai-proxy/chat/completions` becomes `<upstream>/chat/completions`).
151
+ * - the request body is forwarded verbatim; headers minus the
152
+ * origin-sensitive/hop-by-hop set above (`authorization` DOES forward,
153
+ * since upstreams may require a key).
154
+ * - the response body is STREAMED through chunk-by-chunk. SSE passthrough
155
+ * must never buffer, or `stream: true` completions would arrive all at
156
+ * once at the end.
157
+ * - an unreachable upstream answers 502 with a plain-text explanation.
158
+ * - every upstream failure (unreachable/timeout, non-2xx status, mid-stream
159
+ * abort) ALSO prints a structured warning on the dev server's terminal
160
+ * logger; a stopped Ollama used to fail in total silence. Diagnostics
161
+ * only: nothing here changes what the caller receives. No logger wired
162
+ * means dropped silently (same opt-out contract as the denial relay).
163
+ */
164
+ export async function handleAiProxy(configuredUpstream, throttle, req, res, url, logger) {
165
+ if (req.method !== 'POST') {
166
+ res.writeHead(405, { allow: 'POST' }).end('method not allowed');
167
+ return;
168
+ }
169
+ const upstreamBase = resolveAiProxyUpstream(configuredUpstream).target;
170
+ const suffix = url.pathname.slice(AI_PROXY_ROUTE.length);
171
+ const target = `${upstreamBase}${suffix}${url.search}`;
172
+ // Buffer the REQUEST body (small JSON payloads); the RESPONSE streams.
173
+ const raw = await new Promise((resolve, reject) => {
174
+ const chunks = [];
175
+ req.on('data', (c) => chunks.push(c));
176
+ req.on('end', () => resolve(Buffer.concat(chunks)));
177
+ req.on('error', reject);
178
+ });
179
+ // Copy into a plain-ArrayBuffer view; fetch's BodyInit typing rejects
180
+ // Buffer's ArrayBufferLike backing.
181
+ const body = new Uint8Array(raw.byteLength);
182
+ body.set(raw);
183
+ const headers = {};
184
+ for (const [key, value] of Object.entries(req.headers)) {
185
+ if (value === undefined)
186
+ continue;
187
+ if (AI_PROXY_STRIPPED_HEADERS.has(key.toLowerCase()))
188
+ continue;
189
+ headers[key] = Array.isArray(value) ? value.join(', ') : value;
190
+ }
191
+ const startedAt = Date.now();
192
+ let upstream;
193
+ try {
194
+ upstream = await fetch(target, { method: 'POST', headers, body });
195
+ }
196
+ catch (e) {
197
+ const cause = e instanceof Error ? e.message : String(e);
198
+ noteAiProxyFailure({ kind: 'unreachable', target, latencyMs: Date.now() - startedAt, cause }, throttle, logger);
199
+ // The 502 body quotes the same two strings the terminal block does, so it
200
+ // gets the same masking: the target carries the page's own query string,
201
+ // and a fetch error routinely echoes the URL back.
202
+ res.writeHead(502, { 'content-type': 'text/plain' });
203
+ res.end(`pyric dev ai-proxy: upstream ${redactUrl(target)} unreachable: ${redactUrl(cause)}\n` +
204
+ 'Set PYRIC_AI_PROXY_UPSTREAM to an OpenAI-compatible base URL ' +
205
+ `(default ${AI_PROXY_DEFAULT_UPSTREAM}).`);
206
+ return;
207
+ }
208
+ // A refusal from a reachable upstream (bad model, missing key, rate limit)
209
+ // is just as invisible to a headless developer as a dead socket: the
210
+ // status rides through to the caller untouched, and is ALSO announced here.
211
+ // `Retry-After` rides along when the upstream sent one (429s and 503s carry
212
+ // it): it is the only place the requested backoff appears, since nothing in
213
+ // this path retries or sleeps.
214
+ if (!upstream.ok) {
215
+ const retryAfter = upstream.headers.get('retry-after');
216
+ const failure = {
217
+ kind: 'status',
218
+ target,
219
+ latencyMs: Date.now() - startedAt,
220
+ status: upstream.status,
221
+ };
222
+ if (retryAfter !== null)
223
+ failure.retryAfter = retryAfter;
224
+ noteAiProxyFailure(failure, throttle, logger);
225
+ }
226
+ const responseHeaders = { 'cache-control': 'no-store' };
227
+ const contentType = upstream.headers.get('content-type');
228
+ if (contentType)
229
+ responseHeaders['content-type'] = contentType;
230
+ res.writeHead(upstream.status, responseHeaders);
231
+ if (!upstream.body) {
232
+ res.end();
233
+ return;
234
+ }
235
+ res.flushHeaders?.();
236
+ // Chunk-by-chunk passthrough. A dropped client cancels the upstream read
237
+ // so an abandoned SSE stream doesn't keep the upstream generating.
238
+ const reader = upstream.body.getReader();
239
+ let clientGone = false;
240
+ res.on('close', () => {
241
+ clientGone = true;
242
+ void reader.cancel().catch(() => { });
243
+ });
244
+ try {
245
+ for (;;) {
246
+ const { done, value } = await reader.read();
247
+ if (done)
248
+ break;
249
+ res.write(value);
250
+ }
251
+ }
252
+ catch (e) {
253
+ // Nothing to salvage for the caller: the response is already committed
254
+ // with the upstream's status, so a truncated body is all it gets. But a
255
+ // half-delivered completion is exactly the failure that used to vanish,
256
+ // so announce it, unless the CLIENT is the one who walked away (a closed
257
+ // tab cancelling an SSE stream is normal, not a fault worth a warning).
258
+ if (!clientGone) {
259
+ noteAiProxyFailure({
260
+ kind: 'stream-abort',
261
+ target,
262
+ latencyMs: Date.now() - startedAt,
263
+ cause: e instanceof Error ? e.message : String(e),
264
+ }, throttle, logger);
265
+ }
266
+ }
267
+ res.end();
268
+ }
269
+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AAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI;gBAAE,MAAM;YAChB,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,uEAAuE;QACvE,wEAAwE;QACxE,wEAAwE;QACxE,yEAAyE;QACzE,wEAAwE;QACxE,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,kBAAkB,CAChB;gBACE,IAAI,EAAE,cAAc;gBACpB,MAAM;gBACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;gBACjC,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;aAClD,EACD,QAAQ,EACR,MAAM,CACP,CAAC;QACJ,CAAC;IACH,CAAC;IACD,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The AI line in the dev server's startup banner.
3
+ *
4
+ * AI is the only live service that used to boot silently: hosting, sandbox
5
+ * bundles, rules, Studio, the bridge and persistence all announce themselves,
6
+ * so "nothing about AI" read as "AI isn't part of this server" rather than
7
+ * "AI is here, unconfigured". One description ({@link describeAiStatus}),
8
+ * rendered in the two dev-server flavors, so the `pyric dev` banner and the
9
+ * Vite plugin can never disagree about what AI resolved to.
10
+ */
11
+ import type { AiEngineConfigWire } from './worker/protocol.js';
12
+ /**
13
+ * What the dev server itself knows about AI by the time it finishes booting.
14
+ *
15
+ * Everything here is resolved SYNCHRONOUSLY at bootstrap: the plugin's
16
+ * `ai.engine`/`ai.model` (already reduced to the worker wire shape) and the
17
+ * proxy upstream. Nothing in this shape forces a broker, a page, or an
18
+ * upstream connection into existence just to be reported. The engine is
19
+ * instantiated lazily, on the first `ai.*` op, in the page or the worker.
20
+ */
21
+ export interface AiStartupStatus {
22
+ /** Engine resolved by the dev server (the Vite plugin's `ai.engine` /
23
+ * `ai.model`). Absent means nothing server-side: the served page's own
24
+ * `getAI(...)` chooses the engine at runtime, and the server cannot know
25
+ * which (there is no CLI surface for it under `pyric dev`). */
26
+ engine?: AiEngineConfigWire;
27
+ /** `ai.mode`: `production` passes through to Google AI instead of mirroring. */
28
+ mode?: 'sandbox' | 'production';
29
+ /** Configured OpenAI-compatible upstream (`ai.proxyUpstream`). Absent falls
30
+ * back to `PYRIC_AI_PROXY_UPSTREAM`, then the local-Ollama default. */
31
+ proxyUpstream?: string;
32
+ }
33
+ /**
34
+ * The banner line for `pyric dev`'s aligned status column (`✔ hosting ...`).
35
+ * Exported for unit tests.
36
+ */
37
+ export declare function formatAiStatusLine(status: AiStartupStatus): string;
38
+ /**
39
+ * The same report in the Vite dev server's flavor (` ✔ [pyric] ...`, the
40
+ * idiom `vite-functions-development.ts` prints). Same content, so the two
41
+ * dev-server front doors never disagree about what AI resolved to.
42
+ */
43
+ export declare function formatAiStatusNote(status: AiStartupStatus): string;
44
+ //# sourceMappingURL=ai-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-status.d.ts","sourceRoot":"","sources":["../../src/serve/ai-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK/D;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B;;;oEAGgE;IAChE,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,gFAAgF;IAChF,IAAI,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IAChC;4EACwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAwDD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAGlE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAGlE"}
@@ -0,0 +1,77 @@
1
+ import { GEMINI_DEFAULT_BASE_URL, redactUrl } from 'pyric/ai/internal';
2
+ import { AI_PROXY_ROUTE, resolveAiProxyUpstream } from './ai-proxy.js';
3
+ import { sanitizeForTerminal } from './ai-terminal-text.js';
4
+ /** Where the resolved proxy upstream came from, in the terminal's words. The
5
+ * provenance is the point of the line: a developer has to be able to tell a
6
+ * deliberate upstream from the Ollama default nobody chose, so every source
7
+ * names the knob that set it. */
8
+ function describeUpstreamProvenance(source) {
9
+ if (source === 'option')
10
+ return ' (ai.proxyUpstream)';
11
+ if (source === 'env')
12
+ return ' (PYRIC_AI_PROXY_UPSTREAM)';
13
+ return ' (default)';
14
+ }
15
+ /** The openai engine's model binding, which may not be pinned at all. */
16
+ function describeOpenAiModel(model) {
17
+ if (model === undefined)
18
+ return 'no model pinned';
19
+ return `model ${sanitizeForTerminal(model)}`;
20
+ }
21
+ /** Mark + body for one AI status line, in both terminal flavors. */
22
+ function describeAiStatus(status) {
23
+ const upstream = resolveAiProxyUpstream(status.proxyUpstream);
24
+ const provenance = describeUpstreamProvenance(upstream.source);
25
+ const proxyChain = `${AI_PROXY_ROUTE} → ${redactUrl(upstream.target)}${provenance}`;
26
+ const engine = status.engine;
27
+ if (engine === undefined) {
28
+ // Visible absence, the `• rules no firestore.rules ...` idiom: AI
29
+ // silence used to be indistinguishable from AI-not-wired-up.
30
+ return {
31
+ mark: '•',
32
+ body: `no engine configured; the served page's getAI() picks one; ${proxyChain}`,
33
+ };
34
+ }
35
+ if (engine.kind === 'openai') {
36
+ const model = describeOpenAiModel(engine.model);
37
+ const baseUrl = engine.baseUrl ?? AI_PROXY_ROUTE;
38
+ let endpoint = proxyChain;
39
+ if (baseUrl !== AI_PROXY_ROUTE) {
40
+ endpoint = `${redactUrl(baseUrl)} (direct, bypasses ${AI_PROXY_ROUTE})`;
41
+ }
42
+ return { mark: '✔', body: `openai (${model}) → ${endpoint}` };
43
+ }
44
+ if (engine.kind === 'gemini') {
45
+ let passthrough = '';
46
+ if (status.mode === 'production')
47
+ passthrough = 'production passthrough, ';
48
+ const hasKey = engine.apiKey !== undefined && engine.apiKey !== '';
49
+ let key = 'no API key; set GEMINI_API_KEY';
50
+ if (hasKey)
51
+ key = 'API key set';
52
+ let endpoint = GEMINI_DEFAULT_BASE_URL;
53
+ if (engine.baseUrl !== undefined)
54
+ endpoint = redactUrl(engine.baseUrl);
55
+ return { mark: '✔', body: `gemini (${passthrough}${key}) → ${endpoint}` };
56
+ }
57
+ const responses = engine.script?.length ?? 0;
58
+ return { mark: '✔', body: `scripted (${responses} canned response(s), no network)` };
59
+ }
60
+ /**
61
+ * The banner line for `pyric dev`'s aligned status column (`✔ hosting ...`).
62
+ * Exported for unit tests.
63
+ */
64
+ export function formatAiStatusLine(status) {
65
+ const { mark, body } = describeAiStatus(status);
66
+ return `${mark} ai ${body}`;
67
+ }
68
+ /**
69
+ * The same report in the Vite dev server's flavor (` ✔ [pyric] ...`, the
70
+ * idiom `vite-functions-development.ts` prints). Same content, so the two
71
+ * dev-server front doors never disagree about what AI resolved to.
72
+ */
73
+ export function formatAiStatusNote(status) {
74
+ const { mark, body } = describeAiStatus(status);
75
+ return ` ${mark} [pyric] ai: ${body}`;
76
+ }
77
+ //# sourceMappingURL=ai-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-status.js","sourceRoot":"","sources":["../../src/serve/ai-status.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAwB5D;;;kCAGkC;AAClC,SAAS,0BAA0B,CAAC,MAAoC;IACtE,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,qBAAqB,CAAC;IACtD,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,4BAA4B,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). */
3
+ export interface AiRejectionPayload {
4
+ /** `'ai-rejection'`: what tells the route the body is NOT a rules denial. */
5
+ kind?: unknown;
6
+ /** Model resource the rejected op targeted. */
7
+ model?: unknown;
8
+ /** Resolved broker engine (`scripted` | `openai` | `gemini` | `custom`). */
9
+ engine?: unknown;
10
+ /** Wire error status (e.g. `INVALID_ARGUMENT`) and HTTP-ish code. */
11
+ status?: unknown;
12
+ code?: unknown;
13
+ /** The rejection reason: production's own message for shape errors. */
14
+ message?: unknown;
15
+ }
16
+ /** Loosely-typed mirror of the AI blocked-response payload. Unlike a
17
+ * rejection this carries no `message`: a filter block has no error envelope
18
+ * at all (HTTP 200, empty candidate), only the wire's reason enums, so the
19
+ * phrasing is this file's job. */
20
+ export interface AiBlockedPayload {
21
+ /** `'ai-blocked'`: what tells the route the body is a filter block. */
22
+ kind?: unknown;
23
+ /** Model resource the blocked op targeted. */
24
+ model?: unknown;
25
+ /** Resolved broker engine (`scripted` | `openai` | `gemini` | `custom`). */
26
+ engine?: unknown;
27
+ /** Candidate-level block: `SAFETY`, `RECITATION`, `BLOCKLIST`, and so on. */
28
+ finishReason?: unknown;
29
+ /** Production's own explanatory text for the block, when it sent one. */
30
+ finishMessage?: unknown;
31
+ /** Prompt-level block: `promptFeedback.blockReason`. */
32
+ blockReason?: unknown;
33
+ }
34
+ /** Loosely-typed mirror of the AI model-substitution payload. Not a refusal:
35
+ * the request SUCCEEDED, answered by a model the developer never named,
36
+ * which is why nothing else in the stack reports it. */
37
+ export interface AiModelSubstitutionPayload {
38
+ /** `'ai-model-substituted'`: what tells the route the body is a swap. */
39
+ kind?: unknown;
40
+ /** The model the request asked for. */
41
+ requestedModel?: unknown;
42
+ /** The model the engine actually calls. */
43
+ effectiveModel?: unknown;
44
+ /** Resolved broker engine (`openai` | `gemini` | ...). */
45
+ engine?: unknown;
46
+ /** Why it differs, e.g. `engine modelMap`, `experimental alias`. */
47
+ reason?: unknown;
48
+ }
49
+ /** What the route reads off a body before it knows which kind it holds. */
50
+ export type AiDiagnosticPayload = AiRejectionPayload & AiBlockedPayload & AiModelSubstitutionPayload;
51
+ /**
52
+ * Format a relayed AI broker rejection into the compact terminal block, the
53
+ * same ` [pyric] ...` idiom the denial relay and the ai-proxy warning print.
54
+ * Three lines at most: the reason production itself gives, then the model
55
+ * (with the resolved engine, since a rejection reads very differently for
56
+ * `scripted` than for a real upstream), then the wire status. Exported for
57
+ * unit tests.
58
+ */
59
+ export declare function formatAiRejectionBlock(payload: AiRejectionPayload): string;
60
+ /**
61
+ * Format a relayed AI filter block, in the same three lines as
62
+ * {@link formatAiRejectionBlock}: the wire's own reason, the model + resolved
63
+ * engine, then WHY there is no content. That third line matters more here
64
+ * than for a rejection: a block throws nothing, so the only symptom a
65
+ * developer sees is an empty answer, and production's `finishMessage` (when
66
+ * it sent one) is the whole explanation. Exported for unit tests.
67
+ */
68
+ export declare function formatAiBlockedBlock(payload: AiBlockedPayload): string;
69
+ /**
70
+ * Format a relayed AI model substitution into ONE terminal line, a single
71
+ * line on purpose: there is no error, no status, and no missing content to
72
+ * explain. The whole fact IS the arrow, and the parenthetical says which
73
+ * engine did it and why (`engine modelMap`, `experimental alias`, ...).
74
+ * Exported for unit tests.
75
+ */
76
+ export declare function formatAiModelSubstitutionBlock(payload: AiModelSubstitutionPayload): string;
77
+ /**
78
+ * One record per AI diagnostic kind: how it prints, and the (target, reason)
79
+ * pair the denials route throttles it by.
80
+ *
81
+ * The prefixes on `throttleTarget` keep an AI key from colliding with a
82
+ * rules-denial key built from a Firestore path, or with each other: a
83
+ * rejection, a block, and a substitution on the same model are three
84
+ * different problems. `throttleReason` is each kind's identity: a block has
85
+ * no message of its own, so its reason enum is what collapses an agent's
86
+ * retry loop into one line, and a substitution's identity is the model it
87
+ * actually called, so a swap onto a DIFFERENT model still prints.
88
+ */
89
+ export interface AiTerminalBlock {
90
+ format(payload: AiDiagnosticPayload): string;
91
+ throttleTarget(payload: AiDiagnosticPayload): string;
92
+ throttleReason(payload: AiDiagnosticPayload): string;
93
+ }
94
+ /** The record for a relayed body's `kind`, or `null` when the body is a rules
95
+ * denial (or anything else this route does not recognize). */
96
+ export declare function aiTerminalBlockFor(kind: unknown): AiTerminalBlock | null;
97
+ //# sourceMappingURL=ai-terminal-blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-terminal-blocks.d.ts","sourceRoot":"","sources":["../../src/serve/ai-terminal-blocks.ts"],"names":[],"mappings":"AAkBA;8DAC8D;AAC9D,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qEAAqE;IACrE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;mCAGmC;AACnC,MAAM,WAAW,gBAAgB;IAC/B,uEAAuE;IACvE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,yEAAyE;IACzE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wDAAwD;IACxD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;yDAEyD;AACzD,MAAM,WAAW,0BAA0B;IACzC,yEAAyE;IACzE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uCAAuC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2CAA2C;IAC3C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oEAAoE;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