gemi 0.207.2 → 0.209.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 (253) hide show
  1. package/dist/ai/Agent.d.ts +83 -1
  2. package/dist/ai/Agent.d.ts.map +1 -1
  3. package/dist/ai/AgentController.d.ts +7 -1
  4. package/dist/ai/AgentController.d.ts.map +1 -1
  5. package/dist/ai/AgentProvider.d.ts +20 -2
  6. package/dist/ai/AgentProvider.d.ts.map +1 -1
  7. package/dist/ai/FallbackProvider.d.ts.map +1 -1
  8. package/dist/ai/index.d.ts +4 -4
  9. package/dist/ai/index.d.ts.map +1 -1
  10. package/dist/ai/index.js +38 -38
  11. package/dist/ai/index.js.map +4 -4
  12. package/dist/ai/providers/call.d.ts +3 -1
  13. package/dist/ai/providers/call.d.ts.map +1 -1
  14. package/dist/ai/providers/capabilities.d.ts.map +1 -1
  15. package/dist/ai/providers/endpoints.d.ts +9 -0
  16. package/dist/ai/providers/endpoints.d.ts.map +1 -1
  17. package/dist/ai/providers/errors.d.ts +4 -2
  18. package/dist/ai/providers/errors.d.ts.map +1 -1
  19. package/dist/ai/providers/http.d.ts +33 -0
  20. package/dist/ai/providers/http.d.ts.map +1 -1
  21. package/dist/ai/providers/request.d.ts.map +1 -1
  22. package/dist/ai/store/stubAgentRun.d.ts +2 -1
  23. package/dist/ai/store/stubAgentRun.d.ts.map +1 -1
  24. package/dist/ai/testing/index.js +2 -2
  25. package/dist/ai/testing/index.js.map +1 -1
  26. package/dist/ai/types.d.ts +31 -2
  27. package/dist/ai/types.d.ts.map +1 -1
  28. package/dist/app/index.js +1 -1
  29. package/dist/bun/plugin.js +1 -1
  30. package/dist/bun/preload.js +1 -1
  31. package/dist/{chunk-24tj4dzx.js → chunk-094hbhc8.js} +2 -2
  32. package/dist/{chunk-24tj4dzx.js.map → chunk-094hbhc8.js.map} +1 -1
  33. package/dist/{chunk-1em8t2x1.js → chunk-101rvvje.js} +3 -3
  34. package/dist/{chunk-1em8t2x1.js.map → chunk-101rvvje.js.map} +1 -1
  35. package/dist/{chunk-qc0e278w.js → chunk-12gthjxx.js} +1 -1
  36. package/dist/{chunk-8ar7180x.js → chunk-1agwddws.js} +2 -2
  37. package/dist/{chunk-8ar7180x.js.map → chunk-1agwddws.js.map} +1 -1
  38. package/dist/{chunk-nfher0gz.js → chunk-1vnbw1d8.js} +2 -2
  39. package/dist/{chunk-nfher0gz.js.map → chunk-1vnbw1d8.js.map} +1 -1
  40. package/dist/{chunk-53fv4c39.js → chunk-24z18t5q.js} +4 -4
  41. package/dist/{chunk-53fv4c39.js.map → chunk-24z18t5q.js.map} +1 -1
  42. package/dist/{chunk-6ge27ygx.js → chunk-2jbdbvd8.js} +2 -2
  43. package/dist/{chunk-6ge27ygx.js.map → chunk-2jbdbvd8.js.map} +1 -1
  44. package/dist/{chunk-fhn92are.js → chunk-2k438dp6.js} +2 -2
  45. package/dist/{chunk-fhn92are.js.map → chunk-2k438dp6.js.map} +1 -1
  46. package/dist/{chunk-rjtge67x.js → chunk-3raywsbj.js} +2 -2
  47. package/dist/{chunk-rjtge67x.js.map → chunk-3raywsbj.js.map} +1 -1
  48. package/dist/{chunk-k8peybx0.js → chunk-3rgf7rsy.js} +3 -3
  49. package/dist/{chunk-k8peybx0.js.map → chunk-3rgf7rsy.js.map} +1 -1
  50. package/dist/{chunk-hthyn5pj.js → chunk-3wsmgdcr.js} +3 -3
  51. package/dist/{chunk-hthyn5pj.js.map → chunk-3wsmgdcr.js.map} +1 -1
  52. package/dist/{chunk-3830ee5d.js → chunk-5399t8zm.js} +2 -2
  53. package/dist/{chunk-3830ee5d.js.map → chunk-5399t8zm.js.map} +1 -1
  54. package/dist/{chunk-ndcqbwsj.js → chunk-641fns6j.js} +2 -2
  55. package/dist/{chunk-ndcqbwsj.js.map → chunk-641fns6j.js.map} +1 -1
  56. package/dist/{chunk-wrfz0jsw.js → chunk-6zcqa5fz.js} +2 -2
  57. package/dist/{chunk-wrfz0jsw.js.map → chunk-6zcqa5fz.js.map} +1 -1
  58. package/dist/{chunk-6zpf257t.js → chunk-716832vw.js} +2 -2
  59. package/dist/{chunk-6zpf257t.js.map → chunk-716832vw.js.map} +1 -1
  60. package/dist/{chunk-092magz7.js → chunk-7fr265wp.js} +2 -2
  61. package/dist/{chunk-092magz7.js.map → chunk-7fr265wp.js.map} +1 -1
  62. package/dist/{chunk-e0scxs81.js → chunk-8gyq2etb.js} +3 -3
  63. package/dist/{chunk-e0scxs81.js.map → chunk-8gyq2etb.js.map} +3 -3
  64. package/dist/{chunk-8q5kxzxn.js → chunk-8ty6yp6r.js} +3 -3
  65. package/dist/{chunk-8q5kxzxn.js.map → chunk-8ty6yp6r.js.map} +1 -1
  66. package/dist/{chunk-8ncqxja2.js → chunk-9d8tz60r.js} +1 -1
  67. package/dist/{chunk-xgc5tj8k.js → chunk-9qyedsvw.js} +3 -3
  68. package/dist/{chunk-xgc5tj8k.js.map → chunk-9qyedsvw.js.map} +1 -1
  69. package/dist/{chunk-zf1eqgzt.js → chunk-a76a7869.js} +2 -2
  70. package/dist/{chunk-72e857nw.js.map → chunk-a76a7869.js.map} +1 -1
  71. package/dist/{chunk-djnn8vvp.js → chunk-achvynaf.js} +2 -2
  72. package/dist/{chunk-djnn8vvp.js.map → chunk-achvynaf.js.map} +1 -1
  73. package/dist/{chunk-0eq7am78.js → chunk-ad0dx73f.js} +2 -2
  74. package/dist/{chunk-0eq7am78.js.map → chunk-ad0dx73f.js.map} +1 -1
  75. package/dist/{chunk-emt36pxm.js → chunk-agrr8f8y.js} +2 -2
  76. package/dist/{chunk-emt36pxm.js.map → chunk-agrr8f8y.js.map} +1 -1
  77. package/dist/{chunk-znw55n6g.js → chunk-arzp5dne.js} +2 -2
  78. package/dist/{chunk-znw55n6g.js.map → chunk-arzp5dne.js.map} +1 -1
  79. package/dist/{chunk-jn1h76sa.js → chunk-b1y54j6v.js} +2 -2
  80. package/dist/{chunk-jn1h76sa.js.map → chunk-b1y54j6v.js.map} +1 -1
  81. package/dist/{chunk-te4vz0rw.js → chunk-b51a77kv.js} +2 -2
  82. package/dist/{chunk-te4vz0rw.js.map → chunk-b51a77kv.js.map} +1 -1
  83. package/dist/{chunk-wfees83q.js → chunk-bdzj9znx.js} +3 -3
  84. package/dist/{chunk-wfees83q.js.map → chunk-bdzj9znx.js.map} +1 -1
  85. package/dist/{chunk-39dz1abf.js → chunk-bhc9vk13.js} +1 -1
  86. package/dist/{chunk-460c8k50.js → chunk-cfbhhfkv.js} +3 -3
  87. package/dist/{chunk-460c8k50.js.map → chunk-cfbhhfkv.js.map} +1 -1
  88. package/dist/{chunk-78g1cngk.js → chunk-dje6exhs.js} +2 -2
  89. package/dist/{chunk-78g1cngk.js.map → chunk-dje6exhs.js.map} +1 -1
  90. package/dist/{chunk-bpqkzpkt.js → chunk-dm6tkkwv.js} +2 -2
  91. package/dist/{chunk-bpqkzpkt.js.map → chunk-dm6tkkwv.js.map} +1 -1
  92. package/dist/{chunk-8gyanh1b.js → chunk-efskg8cp.js} +2 -2
  93. package/dist/{chunk-8gyanh1b.js.map → chunk-efskg8cp.js.map} +1 -1
  94. package/dist/{chunk-bxznwntw.js → chunk-enq03rgh.js} +2 -2
  95. package/dist/{chunk-bxznwntw.js.map → chunk-enq03rgh.js.map} +1 -1
  96. package/dist/{chunk-34vvev4a.js → chunk-ewhgsw1n.js} +2 -2
  97. package/dist/{chunk-34vvev4a.js.map → chunk-ewhgsw1n.js.map} +1 -1
  98. package/dist/{chunk-a7zqp5m7.js → chunk-fsae9dgb.js} +2 -2
  99. package/dist/{chunk-a7zqp5m7.js.map → chunk-fsae9dgb.js.map} +1 -1
  100. package/dist/{chunk-hqg4dfca.js → chunk-fv6ncgbc.js} +2 -2
  101. package/dist/{chunk-hqg4dfca.js.map → chunk-fv6ncgbc.js.map} +1 -1
  102. package/dist/{chunk-etcds9w3.js → chunk-h1f4f9wx.js} +2 -2
  103. package/dist/{chunk-etcds9w3.js.map → chunk-h1f4f9wx.js.map} +1 -1
  104. package/dist/{chunk-m3v661b3.js → chunk-h4byt0x3.js} +2 -2
  105. package/dist/{chunk-m3v661b3.js.map → chunk-h4byt0x3.js.map} +1 -1
  106. package/dist/{chunk-c8bvpkr2.js → chunk-hbdqv48k.js} +2 -2
  107. package/dist/{chunk-c8bvpkr2.js.map → chunk-hbdqv48k.js.map} +1 -1
  108. package/dist/{chunk-9m6mkaqb.js → chunk-hcysexst.js} +2 -2
  109. package/dist/{chunk-9m6mkaqb.js.map → chunk-hcysexst.js.map} +1 -1
  110. package/dist/{chunk-wpfempaj.js → chunk-hmccxtd3.js} +2 -2
  111. package/dist/{chunk-wpfempaj.js.map → chunk-hmccxtd3.js.map} +1 -1
  112. package/dist/{chunk-tx5zrdmb.js → chunk-jggtz103.js} +2 -2
  113. package/dist/{chunk-tx5zrdmb.js.map → chunk-jggtz103.js.map} +1 -1
  114. package/dist/{chunk-sjve1yvv.js → chunk-jr9y6k90.js} +1 -1
  115. package/dist/{chunk-6x2zbh1q.js → chunk-kax9ghny.js} +2 -2
  116. package/dist/{chunk-6x2zbh1q.js.map → chunk-kax9ghny.js.map} +1 -1
  117. package/dist/{chunk-q1t9gvm1.js → chunk-kbkyde5f.js} +2 -2
  118. package/dist/{chunk-q1t9gvm1.js.map → chunk-kbkyde5f.js.map} +1 -1
  119. package/dist/{chunk-77dt2tap.js → chunk-mtf5kzza.js} +2 -2
  120. package/dist/{chunk-77dt2tap.js.map → chunk-mtf5kzza.js.map} +1 -1
  121. package/dist/{chunk-3z8d8v8q.js → chunk-mxedsqbe.js} +3 -3
  122. package/dist/{chunk-3z8d8v8q.js.map → chunk-mxedsqbe.js.map} +1 -1
  123. package/dist/{chunk-jy61580r.js → chunk-n0sbg84n.js} +2 -2
  124. package/dist/{chunk-jy61580r.js.map → chunk-n0sbg84n.js.map} +1 -1
  125. package/dist/{chunk-06w8hhnk.js → chunk-n65hk6bq.js} +2 -2
  126. package/dist/{chunk-06w8hhnk.js.map → chunk-n65hk6bq.js.map} +1 -1
  127. package/dist/{chunk-4ksnhx8x.js → chunk-ntcj2sgv.js} +3 -3
  128. package/dist/{chunk-4ksnhx8x.js.map → chunk-ntcj2sgv.js.map} +1 -1
  129. package/dist/{chunk-scw0vknj.js → chunk-p27ft91c.js} +1 -1
  130. package/dist/{chunk-vyaedzr8.js → chunk-p608rrfc.js} +3 -3
  131. package/dist/{chunk-vyaedzr8.js.map → chunk-p608rrfc.js.map} +1 -1
  132. package/dist/chunk-pag82mxh.js +5 -0
  133. package/dist/{chunk-4q59y78y.js.map → chunk-pag82mxh.js.map} +1 -1
  134. package/dist/{chunk-yj1h4rzn.js → chunk-q634cwbc.js} +3 -3
  135. package/dist/{chunk-yj1h4rzn.js.map → chunk-q634cwbc.js.map} +1 -1
  136. package/dist/{chunk-09hzyf9g.js → chunk-q7x7ddw0.js} +3 -3
  137. package/dist/{chunk-09hzyf9g.js.map → chunk-q7x7ddw0.js.map} +1 -1
  138. package/dist/{chunk-65btke6p.js → chunk-qc7x8q1q.js} +2 -2
  139. package/dist/{chunk-65btke6p.js.map → chunk-qc7x8q1q.js.map} +1 -1
  140. package/dist/{chunk-wdrmzjtq.js → chunk-r5ggnywk.js} +2 -2
  141. package/dist/{chunk-wdrmzjtq.js.map → chunk-r5ggnywk.js.map} +1 -1
  142. package/dist/{chunk-72e857nw.js → chunk-raejxs3y.js} +2 -2
  143. package/dist/{chunk-zf1eqgzt.js.map → chunk-raejxs3y.js.map} +1 -1
  144. package/dist/{chunk-k8a41gkt.js → chunk-rffpqhn8.js} +2 -2
  145. package/dist/{chunk-k8a41gkt.js.map → chunk-rffpqhn8.js.map} +1 -1
  146. package/dist/{chunk-p9c5rc1z.js → chunk-rhyhxgxg.js} +3 -3
  147. package/dist/{chunk-p9c5rc1z.js.map → chunk-rhyhxgxg.js.map} +1 -1
  148. package/dist/chunk-szaq0f6n.js +24 -0
  149. package/dist/{chunk-e05rbjn2.js.map → chunk-szaq0f6n.js.map} +6 -5
  150. package/dist/{chunk-eeq9ty68.js → chunk-t0xfzpfa.js} +2 -2
  151. package/dist/{chunk-eeq9ty68.js.map → chunk-t0xfzpfa.js.map} +1 -1
  152. package/dist/chunk-t9gc6mhq.js +11 -0
  153. package/dist/{chunk-2e40rx0p.js.map → chunk-t9gc6mhq.js.map} +8 -8
  154. package/dist/{chunk-9qyet3nb.js → chunk-tj8wbxyz.js} +2 -2
  155. package/dist/{chunk-9qyet3nb.js.map → chunk-tj8wbxyz.js.map} +1 -1
  156. package/dist/{chunk-q751b0jx.js → chunk-tjfvkzq8.js} +1 -1
  157. package/dist/{chunk-njnng5ew.js → chunk-v10kckwp.js} +4 -4
  158. package/dist/{chunk-njnng5ew.js.map → chunk-v10kckwp.js.map} +1 -1
  159. package/dist/{chunk-ne51fxg2.js → chunk-vrpsgq3x.js} +2 -2
  160. package/dist/{chunk-ne51fxg2.js.map → chunk-vrpsgq3x.js.map} +1 -1
  161. package/dist/{chunk-jy26hy7z.js → chunk-w92n83g2.js} +2 -2
  162. package/dist/{chunk-jy26hy7z.js.map → chunk-w92n83g2.js.map} +1 -1
  163. package/dist/{chunk-dwya9z8p.js → chunk-wcpqn1pg.js} +2 -2
  164. package/dist/{chunk-dwya9z8p.js.map → chunk-wcpqn1pg.js.map} +1 -1
  165. package/dist/{chunk-zvk6dydb.js → chunk-wkh9xcdq.js} +2 -2
  166. package/dist/{chunk-zvk6dydb.js.map → chunk-wkh9xcdq.js.map} +1 -1
  167. package/dist/{chunk-7wzhdq1x.js → chunk-wy87gc0b.js} +3 -3
  168. package/dist/{chunk-7wzhdq1x.js.map → chunk-wy87gc0b.js.map} +1 -1
  169. package/dist/{chunk-aed0vv5g.js → chunk-xt90xbes.js} +2 -2
  170. package/dist/{chunk-aed0vv5g.js.map → chunk-xt90xbes.js.map} +1 -1
  171. package/dist/{chunk-6cx6kh04.js → chunk-y16vp7yf.js} +2 -2
  172. package/dist/{chunk-6cx6kh04.js.map → chunk-y16vp7yf.js.map} +1 -1
  173. package/dist/{chunk-cffx7wqp.js → chunk-yn3pf1fp.js} +2 -2
  174. package/dist/{chunk-cffx7wqp.js.map → chunk-yn3pf1fp.js.map} +1 -1
  175. package/dist/{chunk-s1fa5f8b.js → chunk-yzbj11dd.js} +2 -2
  176. package/dist/{chunk-s1fa5f8b.js.map → chunk-yzbj11dd.js.map} +1 -1
  177. package/dist/{chunk-vebstesm.js → chunk-zcx8n3mk.js} +3 -3
  178. package/dist/{chunk-vebstesm.js.map → chunk-zcx8n3mk.js.map} +1 -1
  179. package/dist/chunk-zrqzxc50.js +48 -0
  180. package/dist/chunk-zrqzxc50.js.map +27 -0
  181. package/dist/{chunk-8d2g78vc.js → chunk-zv6a6w1v.js} +2 -2
  182. package/dist/{chunk-8d2g78vc.js.map → chunk-zv6a6w1v.js.map} +1 -1
  183. package/dist/{chunk-1tc6j8bn.js → chunk-zzs96hc8.js} +2 -2
  184. package/dist/{chunk-1tc6j8bn.js.map → chunk-zzs96hc8.js.map} +1 -1
  185. package/dist/chunks/{RealtimeClient-DIxu38Vp.js → RealtimeClient-CmGMu3vA.js} +2 -2
  186. package/dist/chunks/{RealtimeClient-DIxu38Vp.js.map → RealtimeClient-CmGMu3vA.js.map} +1 -1
  187. package/dist/chunks/{ThemeProvider-DwBG9z7t.js → ThemeProvider-Cd7Ioorg.js} +30 -5
  188. package/dist/chunks/{ThemeProvider-DwBG9z7t.js.map → ThemeProvider-Cd7Ioorg.js.map} +1 -1
  189. package/dist/chunks/{fetchFileRequest-DbtCribY.js → fetchFileRequest-VDh0ivL-.js} +2 -2
  190. package/dist/chunks/{fetchFileRequest-DbtCribY.js.map → fetchFileRequest-VDh0ivL-.js.map} +1 -1
  191. package/dist/chunks/{live-Dw8WcP_Q.js → live-DAt2MPE2.js} +3 -3
  192. package/dist/chunks/{live-Dw8WcP_Q.js.map → live-DAt2MPE2.js.map} +1 -1
  193. package/dist/chunks/{mutationExtras-BHBySXVs.js → mutationExtras-CodkSO_f.js} +2 -2
  194. package/dist/chunks/{mutationExtras-BHBySXVs.js.map → mutationExtras-CodkSO_f.js.map} +1 -1
  195. package/dist/chunks/{subscriptionStream-CdYxY-Q6.js → subscriptionStream-CotXoVnq.js} +2 -2
  196. package/dist/chunks/{subscriptionStream-CdYxY-Q6.js.map → subscriptionStream-CotXoVnq.js.map} +1 -1
  197. package/dist/client/ClientRouter.d.ts.map +1 -1
  198. package/dist/client/ComponentContext.d.ts.map +1 -1
  199. package/dist/client/chunkLoadRecovery.d.ts +24 -1
  200. package/dist/client/chunkLoadRecovery.d.ts.map +1 -1
  201. package/dist/client/index.js +36 -7
  202. package/dist/client/index.js.map +1 -1
  203. package/dist/config/index.js +1 -1
  204. package/dist/console/run.js +2 -2
  205. package/dist/console/run.js.map +1 -1
  206. package/dist/container/index.js +2 -2
  207. package/dist/container/index.js.map +1 -1
  208. package/dist/database/index.js +2 -2
  209. package/dist/database/index.js.map +1 -1
  210. package/dist/email/index.js +2 -2
  211. package/dist/email/index.js.map +1 -1
  212. package/dist/facades/index.js +2 -2
  213. package/dist/facades/index.js.map +1 -1
  214. package/dist/foundation/index.js +2 -2
  215. package/dist/foundation/index.js.map +1 -1
  216. package/dist/http/index.js +2 -2
  217. package/dist/http/index.js.map +1 -1
  218. package/dist/i18n/dictionaryRuntime.js +2 -2
  219. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  220. package/dist/i18n/index.js +2 -2
  221. package/dist/i18n/index.js.map +1 -1
  222. package/dist/kernel/index.js +2 -2
  223. package/dist/kernel/index.js.map +1 -1
  224. package/dist/orm/index.js +2 -2
  225. package/dist/orm/index.js.map +1 -1
  226. package/dist/probe/index.js +2 -2
  227. package/dist/probe/index.js.map +1 -1
  228. package/dist/server/assetFallback.d.ts +46 -0
  229. package/dist/server/assetFallback.d.ts.map +1 -0
  230. package/dist/server/httpProd.d.ts.map +1 -1
  231. package/dist/server/index.js +2 -2
  232. package/dist/server/index.js.map +1 -1
  233. package/dist/services/index.js +2 -2
  234. package/dist/services/index.js.map +1 -1
  235. package/dist/services/queue/work.js +2 -2
  236. package/dist/services/queue/work.js.map +1 -1
  237. package/dist/stats/route-table.js +1 -1
  238. package/dist/support/index.js +2 -2
  239. package/dist/support/index.js.map +1 -1
  240. package/dist/testing/index.js +2 -2
  241. package/dist/vitest/index.js +1 -1
  242. package/package.json +1 -1
  243. package/dist/chunk-2e40rx0p.js +0 -11
  244. package/dist/chunk-4q59y78y.js +0 -5
  245. package/dist/chunk-e05rbjn2.js +0 -24
  246. package/dist/chunk-v1d7xya8.js +0 -46
  247. package/dist/chunk-v1d7xya8.js.map +0 -27
  248. /package/dist/{chunk-qc0e278w.js.map → chunk-12gthjxx.js.map} +0 -0
  249. /package/dist/{chunk-8ncqxja2.js.map → chunk-9d8tz60r.js.map} +0 -0
  250. /package/dist/{chunk-39dz1abf.js.map → chunk-bhc9vk13.js.map} +0 -0
  251. /package/dist/{chunk-sjve1yvv.js.map → chunk-jr9y6k90.js.map} +0 -0
  252. /package/dist/{chunk-scw0vknj.js.map → chunk-p27ft91c.js.map} +0 -0
  253. /package/dist/{chunk-q751b0jx.js.map → chunk-tjfvkzq8.js.map} +0 -0
@@ -9,6 +9,6 @@
9
9
  "import type { Dialect } from \"../../database/dialect\";\nimport type { Binder, Fragment } from \"../compile/fragment\";\nimport type { RowLockClause } from \"../compile/lock\";\nimport type { FieldSchema, ScalarType } from \"../schema\";\nimport { PostgresDialect } from \"./postgres\";\nimport { SqliteDialect } from \"./sqlite\";\n\n/**\n * The per-database strategy.\n *\n * The rule this interface exists to enforce: no `if (dialect === \"postgres\")`\n * ever appears inside the compiler. When something genuinely cannot be\n * expressed through the interface, the interface widens — which is why\n * `inList`, `like` and `paginate` return `Fragment`s rather than strings. Each\n * of the three is a place where SQLite and Postgres disagree about *structure*,\n * not just spelling:\n *\n * - `inList` — SQLite expands one placeholder per element, so `in: [1,2]` and\n * `in: [1,2,3]` are different SQL and different plans. Postgres binds the\n * whole array to one parameter with `= any($1)`, so every length shares a\n * single plan and a single prepared statement.\n * - `like` — Postgres has `ilike` for `mode: \"insensitive\"`; SQLite has no\n * equivalent, and Prisma rejects the argument there outright.\n * - `paginate` — SQLite cannot parse `offset` without a preceding `limit`.\n */\nexport interface SqlDialect {\n readonly name: Dialect;\n\n /**\n * Whether `mode: \"insensitive\"` can be expressed at all. False on SQLite,\n * where Prisma rejects the argument rather than emulating it.\n */\n readonly supportsInsensitiveMode: boolean;\n\n /**\n * Whether an `in` list binds as a single parameter however long it is.\n *\n * True on Postgres (`= any($1)`), false on SQLite (`in (?, ?, ?)`). It is the\n * plan *cache* that needs to know: where the length does not change the SQL\n * text, it must not change the cache key either, or every distinct list\n * length mints another entry holding SQL identical to its neighbours'. That\n * matters most for relations, where the list length is the parent row count\n * and so varies with the data rather than with the code.\n */\n readonly bindsListAsOneParameter: boolean;\n\n /**\n * Whether `insert`/`update`/`delete` can return the rows they touched.\n *\n * True on both implemented dialects — Postgres has had `RETURNING` forever,\n * and SQLite since 3.35 (Bun 1.3.14 bundles 3.51.0, verified by querying\n * `sqlite_version()` rather than by reading a changelog).\n *\n * It is a capability rather than an assumption because MySQL and MariaDB have\n * no `RETURNING` at all. Their fallback — `lastInsertRowid` plus a re-select,\n * and no way to identify the rows an `updateMany` touched — is a different\n * statement shape, not a different spelling. Iteration 4 does not build it,\n * but it must stay expressible, so the write compiler asks rather than\n * assumes and raises a clear error when the answer is no.\n */\n readonly supportsReturning: boolean;\n\n /**\n * How many parameters one statement may bind.\n *\n * A hard protocol/driver limit, not a tuning knob: Postgres sends the\n * parameter count as an int16 in the Bind message, and SQLite compiles\n * `SQLITE_MAX_VARIABLE_NUMBER` in.\n *\n * Three shapes can approach it, all of them scaling with the caller's *data*\n * rather than with the query's shape:\n *\n * - `createMany`, at `rows × columns`.\n * - An `in` list on SQLite, which binds one placeholder per element — and\n * such a list is routinely request-derived (`?ids=…`).\n * - A to-many `include` on SQLite, which batches an `in` over the parent\n * keys, so a large enough `findMany` reaches it with no big list in sight.\n *\n * Postgres escapes the last two: `= any($1)` is one parameter however long\n * the array. The check itself lives in `compile/fragment.ts`'s `render`,\n * because that is the one place that sees a statement's final count.\n *\n * It lives *here* rather than as a constant in the compiler for the usual\n * reason: the number differs per dialect, and the compiler is not allowed to\n * know which dialect it is compiling for.\n */\n readonly maxBoundParameters: number;\n\n /**\n * Whether the **statement** decides a parameter's type, so a cast the caller\n * wrote onto their own placeholder changes how the driver encodes the value.\n *\n * True on Postgres: the server describes the statement, the client is told\n * the parameter is `jsonb`, and Bun then JSON-*encodes* whatever JS value it\n * was handed. That is the whole of #376 — the reason `json-param.ts` retypes\n * such a parameter through `text` and serialises it to match.\n *\n * False on SQLite, and not merely because the correction is unnecessary\n * there: it would be **wrong**, and it would not parse. A parameter's type is\n * the bound value's, and `cast(x as json)` is not a JSON cast at all — SQLite\n * takes any type name and applies affinity rules, and a name containing none\n * of INT/CHAR/CLOB/TEXT/BLOB/REAL/FLOA/DOUB gets NUMERIC affinity, so\n * `cast('{\"a\":1}' as json)` is `0`. Measured through `bun:sqlite` (Bun\n * 1.3.14):\n *\n * select cast(? as jsonb) -> 0 (runs)\n * select json_set('{\"a\":1}','$.b', cast(? as json)) -> {\"a\":1,\"b\":2}\n * select cast(? as text)::json -> ERROR unrecognized token: \":\"\n *\n * So the retyping's rewrite — `cast(? as text)::json` — turns a statement\n * that runs on SQLite today into a syntax error. `::` genuinely cannot fire\n * there (it does not parse), but `cast(… as …)` is not Postgres-only syntax,\n * and \"SQLite has no jsonb type\" is a claim about semantics rather than about\n * what the parser accepts. Asking here rather than matching on `name` is what\n * makes that a fact `tsc` and a test can hold.\n */\n readonly typesParametersFromStatement: boolean;\n\n /** Quote a table or column name. Only ever called with names from the schema. */\n quoteIdent(name: string): string;\n\n /**\n * The parameter marker for the `index`-th (0-based) parameter in a statement.\n * SQLite ignores the index and returns `?`; Postgres returns `$1`, `$2`, ...\n */\n placeholder(index: number): string;\n\n /**\n * Prisma-shaped value -> the value the driver must be handed for this field.\n * The mirror of `decode`, and just as load-bearing: Bun's SQLite driver binds\n * a `Date` to `NULL`, so an unencoded `where: { createdAt: date }` would\n * return no rows rather than failing.\n *\n * Applied at bind time, not compile time — it is a function of the value.\n * Which encoder runs is still decided from the schema, so compile stays pure.\n */\n encode(value: unknown, field: FieldSchema): unknown;\n\n /**\n * SQL appended to this field's placeholder, or `\"\"` for none.\n *\n * The one string a dialect contributes to the statement that is not a\n * parameter, so it must be a constant — never derived from a value, and never\n * from anything an application supplies. `fieldParam` is the only caller, and\n * a non-empty cast also means it serialises the value; the two travel\n * together and neither is correct alone (#209).\n */\n castParameter(field: FieldSchema): string;\n\n /**\n * The same, for a value with **no declared column type** — a parameter\n * interpolated into a composed raw fragment, where there is no schema to ask.\n *\n * It exists because \"raw\" cannot mean \"unportable\". Bun's SQLite driver\n * rejects a `Date` outright (`Binding expected string, TypedArray, boolean,\n * number, bigint or null`) while Postgres takes one, so\n * ``sql`where \"createdAt\" > ${date}` `` would work on one dialect and throw on\n * the other — and the caller has no dialect-independent value to reach for\n * instead, because milliseconds are only correct if that is what the ORM\n * stored. Which it is: this converts to exactly what `encode` writes for a\n * `DateTime`, so a raw statement compares against ORM-written rows correctly.\n *\n * Deliberately narrow. It normalises the JavaScript types whose SQL form the\n * ORM has already decided — a `Date`, a boolean — and touches nothing else. A\n * plain object is *not* JSON-encoded here: the compiler only knows to do that\n * because a field says `Json`, and guessing from the value would turn a\n * mistyped parameter into a successfully-written string.\n *\n * The exception is a parameter the *caller* cast to `json`/`jsonb`, which is\n * a declared type by another route and does not reach this at all — see\n * `json-param.ts`. It is still not a guess from the value: the statement says\n * so.\n */\n encodeUntyped(value: unknown): unknown;\n\n /** Driver value -> the value Prisma would have returned for this field. */\n decode(value: unknown, field: FieldSchema): unknown;\n\n /**\n * False when the driver already returns exactly what Prisma would for this\n * field, letting the shaper skip the call entirely on the hot path.\n */\n needsDecode(field: FieldSchema): boolean;\n\n /**\n * `<lhs> in (...)` / `<lhs> not in (...)`.\n *\n * `length` is the element count, which is shape information and is already\n * part of the plan key. `values` returns the whole array at bind time; how it\n * is spread across parameters is the dialect's business.\n */\n inList(\n lhs: string,\n negated: boolean,\n length: number,\n values: Binder,\n ): Fragment;\n\n /** `<lhs> like <pattern>`, case-insensitively when the dialect can. */\n like(lhs: string, insensitive: boolean, pattern: Binder): Fragment;\n\n /**\n * Whether this dialect can match a **tuple** of columns against a list of\n * tuples in a statement whose text does not grow with the list.\n *\n * The single-column case is `inList`, and on Postgres `= any($1)` already\n * gives one SQL text for every length — which is what lets `collapsedList`\n * keep a batched relation query to one plan entry however many parents it\n * has. A relation joining on *more than one* field cannot use it, so the\n * loader falls back to an `OR` of `AND`s whose text does grow, and the plan\n * cache churns with the parent count (#97).\n *\n * `unnest` closes that on Postgres — one array parameter per *column*, so the\n * text is fixed — but it needs each column's SQL type for the cast, and the\n * types are asked about here rather than assumed: a dialect that cannot spell\n * one of them says so and the caller keeps the portable `OR`.\n */\n canBindCompositeIn(types: readonly ScalarType[]): boolean;\n\n /**\n * `(a, b) in (select * from unnest($1::t[], $2::u[]))`.\n *\n * `values` yields one tuple per parent at bind time; the dialect decides how\n * they are transposed into per-column arrays. Only called when\n * {@link canBindCompositeIn} returned true for these types.\n */\n compositeIn(\n columns: readonly string[],\n types: readonly ScalarType[],\n values: Binder,\n ): Fragment;\n\n /**\n * The filters this dialect can apply to a **scalar list** — `tags String[]`.\n *\n * **Empty is the whole of SQLite's answer**, and it is a capability rather\n * than a gap in this ORM: SQLite has no array type, and Prisma refuses the\n * declaration there at validation time — *\"Field `tags` in model `User` can't\n * be a list. The current connector does not support lists of primitive\n * types.\"* So a SQLite database cannot hold such a column to begin with.\n *\n * The refusal lives here rather than in the generator, which is where it used\n * to live (#300). The generated artifact is dialect-agnostic on purpose —\n * `DATABASE_URL` can name a different database than `prisma generate` saw —\n * so a generator that refused a scalar list refused it for Postgres too, and\n * one `String[]` anywhere meant no artifact for *any* model. Asking the\n * dialect at compile time refuses exactly the combination that cannot work,\n * and names it, which is the shape {@link UnsupportedDialectError} already\n * has for the dialects with no compiler at all.\n */\n readonly listFilters: ReadonlySet<string>;\n\n /**\n * `<value> = any(<column>)` — is this element in the list?\n *\n * The mirror of {@link inList} rather than a variant of it, and the two are\n * easy to confuse: there, one column is matched against a caller's list;\n * here, one caller value is matched against a column that *is* a list.\n *\n * **These four take a `Fragment` where every other member here takes a\n * `Binder`**, which is a deliberate exception. A list operand may need a cast\n * on its placeholder — a single element of a `Json[]` needs #209's\n * `::text::jsonb`, and the serialisation that must travel with it — so the\n * parameter is built by `fieldParam` before it arrives and the dialect\n * chooses only the operator. Handing over a `Binder` instead would oblige\n * each dialect to restate `fieldParam`'s rule, and restating it slightly\n * wrong is silent: `$1::jsonb = any(col)` answers *false* where\n * `$1::text::jsonb = any(col)` answers true, with no error on either.\n */\n listHas(column: string, value: Fragment): Fragment;\n\n /** `hasEvery` — every element of the operand is present in the column. */\n listHasEvery(column: string, values: Fragment): Fragment;\n\n /** `hasSome` — the column and the operand share at least one element. */\n listHasSome(column: string, values: Fragment): Fragment;\n\n /**\n * `isEmpty: true`, or its negation when `empty` is false.\n *\n * The odd one out with no operand at all: the value being compared against is\n * the empty list, which is the compiler's own constant rather than the\n * caller's. It stays a bound parameter regardless — see `jsonNullComparison`,\n * which declines the same exception for the same reason.\n */\n listIsEmpty(column: string, empty: boolean): Fragment;\n\n /**\n * The right-hand side of a `push`: the column's current value with the\n * operand appended. An expression rather than a statement, because it is\n * assigned by the write compiler like any other `set` value.\n */\n listPush(column: string, values: Fragment): Fragment;\n\n /**\n * How this dialect spells a JSON path, and which filters it can apply to one.\n *\n * The **path grammar itself differs**, which is unusual enough to be worth\n * stating rather than hiding: Prisma takes `path: [\"a\", \"b\"]` on Postgres and\n * `path: \"$.a.b\"` on SQLite, and refuses the other form on each. That is not\n * a gemi choice — it is the shape the generated client accepts, measured on\n * both — so reproducing it is what \"Prisma-compatible\" means here.\n *\n * `jsonFilters` is the set of scalar filters the dialect can apply to an\n * extracted value. Prisma refuses `array_contains` and the numeric\n * comparisons on SQLite with *\"Unknown argument\"*, so refusing them here is\n * matching it rather than falling short of it.\n */\n readonly jsonPathSyntax: \"array\" | \"jsonpath\";\n readonly jsonFilters: ReadonlySet<string>;\n\n /**\n * Whether an extracted value compares as **text**.\n *\n * Postgres's `#>>` yields `text`, so `equals: 3` has to bind `\"3\"` — comparing\n * text to an integer parameter is a type error there. SQLite's `json_extract`\n * yields a native value, so the same filter has to bind `3`: bind `\"3\"` and\n * SQLite compares an INTEGER to a TEXT, which is silently *false* rather than\n * an error. One filter, two encodings, and the wrong one is a returned-no-rows\n * bug on one dialect and a raised error on the other.\n */\n readonly jsonComparesAsText: boolean;\n\n /**\n * The extracted value, as a fragment whose path is **bound**.\n *\n * A JSON path is the one place a caller's *value* decides part of an\n * expression's meaning, which makes it the obvious place to interpolate by\n * accident and break invariant 2. Both dialects can take it as a parameter —\n * Postgres's `#>` accepts a `text[]`, SQLite's `json_extract` a string — so\n * nothing has to be bent to keep it out of the SQL text.\n *\n * `asText` picks the extraction that yields SQL text rather than JSON. Every\n * comparison in `jsonComparison` passes `true` — the string filters compare\n * against text, and `equals` / `not` / the numeric operators compare an\n * extracted *scalar*, which is what the text form gives them. The JSON form\n * has exactly one caller, `jsonArrayContains`, because containment is the one\n * operator whose right-hand side is a document.\n *\n * SQLite ignores the flag: `json_extract` already yields a SQL value rather\n * than a JSON document for a scalar at the path. That is why the null\n * sentinels need {@link jsonValueAt} instead of this — see there.\n */\n jsonExtract(column: string, path: Binder, asText: boolean): Fragment;\n\n /** `<extracted> @> <value>` — Postgres only; see `jsonFilters`. */\n jsonArrayContains(column: string, path: Binder, value: Binder): Fragment;\n\n /**\n * The value at `path` **as JSON**, in the form two JSON values compare in.\n *\n * The difference from {@link jsonExtract} is the whole of #407, and it is the\n * distinction the null sentinels are made of. Both dialects have an\n * extraction that collapses \"the key is absent\" into \"the key holds the JSON\n * value `null`\", and both have one that does not:\n *\n * | | collapses | keeps the distinction |\n * | --- | --- | --- |\n * | postgres | `#>>` (text) | `#>` (jsonb) |\n * | sqlite | `json_extract` | `->` (JSON text) |\n *\n * `jsonExtract` is the left column at `asText: true`, which is what every\n * scalar comparison wants — a value to compare, not a document. This is the\n * right column, and it is what lets `equals: DbNull` compile to\n * `<value at path> is null` while `equals: JsonNull` compiles to\n * `<value at path> = <the JSON null>`. Refusing them because `#>>` cannot\n * tell the two apart was true of `#>>` and not of the dialect.\n *\n * **Postgres casts and SQLite does not**, and the cast is not decoration:\n * `#>` on a `json` column (a `@db.Json` field) yields `json`, which has no\n * equality operator at all — *\"operator does not exist: json = jsonb\"*, a\n * raised error rather than a wrong answer, but still one Prisma does not\n * raise. Prisma emits `(…#>…)::jsonb` for exactly this reason and so does\n * this. SQLite's `->` already yields the JSON text form.\n *\n * Bound, never interpolated, for the same reason `jsonExtract` is.\n */\n jsonValueAt(column: string, path: Binder): Fragment;\n\n /**\n * Whether the JSON value at `path` — the column itself when `path` is\n * `undefined` — is an **object** holding the key, any of the keys, or all of\n * them: `has_key`, `has_some_keys`, `has_every_key` (#664).\n *\n * `keys` binds a string for `\"one\"` and a string array for the other two;\n * `count` is that array's length, which SQLite needs because it tests one\n * key per term. Postgres binds the array whole, so its text does not depend\n * on `count` and the plan key collapses the list (`LIST_KEYS` in `plan.ts`).\n *\n * **Objects only, on both dialects.** Postgres's `?` also matches a string\n * *element* of a top-level array; SQLite's path lookup does not. Both forms\n * are guarded with \"the value is an object\" so the two answer the same rows:\n * `has_every_key: []` is \"is an object\", and `has_some_keys: []` is false.\n * A key holding the JSON value `null` exists.\n */\n jsonHasKeys(\n column: string,\n path: Binder | undefined,\n keys: Binder,\n mode: \"one\" | \"some\" | \"every\",\n count: number,\n ): Fragment;\n\n /**\n * `lhs` differs from `rhs`, treating NULL as equal to NULL — the guard\n * `skipIfUnchanged` adds to an update's `where` (#664).\n *\n * `rhs` is the same parameter the `set` binds, so the comparison is against\n * the stored encoding of the value. A `Json` column compares as JSON rather\n * than as text: `jsonb` equality on Postgres (key order and whitespace do not\n * matter), and `json()`-normalised text on SQLite (whitespace does not\n * matter; key order does).\n */\n distinctFrom(lhs: string, rhs: Fragment, field: FieldSchema): Fragment;\n\n /**\n * `limit`/`offset`. Both are values and therefore parameters — this is the\n * single most tempting place in the compiler to inline a number.\n */\n paginate(take: Binder | null, skip: Binder | null): Fragment;\n\n /**\n * The clause that makes an insert skip rows violating a unique constraint —\n * `createMany({ skipDuplicates: true })` — or `null` where it is not offered.\n *\n * **`null` is a parity decision, not a missing feature**, and that is worth\n * knowing before someone \"fixes\" SQLite by returning `insert or ignore`.\n * SQLite has `on conflict do nothing` and has since 3.24; Prisma nonetheless\n * rejects the *argument* on SQLite — `Unknown argument 'skipDuplicates'`,\n * whatever its value, verified against a generated 6.19 client. Offering it\n * here would make gemi a silent superset of Prisma on the one dialect the\n * differential harness could then no longer compare, which is the trade this\n * project has declined every other time it came up.\n *\n * A method rather than a boolean because the SQL differs where it exists, and\n * a `Fragment` because everything the compiler emits is one.\n */\n ignoreConflicts(): Fragment | null;\n\n /**\n * The clause a locking read ends with — `lock: \"update\"` on a `findMany` —\n * naming `table` as the only table whose rows are locked.\n *\n * Scoped to the root table (`for update of \"User\"`) rather than left bare,\n * because a folded `include` puts a lateral subquery in the `from` clause and\n * Postgres refuses to lock through one (`FOR UPDATE is not allowed with\n * aggregate functions`). Scoping it also matches the documented contract on\n * both strategies: the root rows are locked, related rows never are.\n *\n * **Empty on SQLite, and that is a decision.** SQLite has no row locks, and\n * does not need them for what a locking read is for: its transactions are\n * serializable, with one writer at a time on the whole database, so the lost\n * update a row lock prevents cannot happen there. Two transactions that race\n * wait on (or fail with `SQLITE_BUSY` on) the database lock instead of the\n * row's, and `skipLocked` / `noWait` have no row lock to react to. Refusing\n * would stop code that runs on Postgres in production from running against\n * SQLite in development and tests, for no gain. The one misuse that matters\n * on both — a lock outside a transaction — is refused in `Model.$execute`\n * on every dialect.\n */\n rowLock(lock: RowLockClause, table: string): Fragment;\n\n /**\n * Recognise a driver error as a constraint violation, and say which columns\n * it names.\n *\n * Returns `null` for anything else, including the *other* constraint kinds:\n * SQLite reports NOT NULL and FOREIGN KEY failures through the same exception\n * type, and reporting one of those as a duplicate-key error would send a\n * caller looking for a row that does not exist.\n *\n * Columns, not fields — the driver only knows the database's names. The\n * caller maps them back through the schema, where `@map` is in scope.\n */\n constraintViolation(error: unknown): ConstraintViolation | null;\n}\n\n/** A driver error identified as a constraint failure, in dialect-neutral terms. */\nexport interface ConstraintViolation {\n /** Only `unique` is translated today; the rest surface as the raw error. */\n kind: \"unique\";\n /** Database column names, in the order the driver reported them. */\n columns: string[];\n /** The constraint's own name, when the driver gives one. Postgres does. */\n constraint?: string;\n}\n\n/**\n * The ORM was asked to compile against a dialect it does not implement.\n *\n * **The split this message has to convey**, because it is the surprising part:\n * `DatabaseManager` connects to MySQL and MariaDB perfectly well — Bun's client\n * speaks all four — so raw SQL through `DB.query` / `DB.sql` works, and\n * transactions work. What does not exist is a `SqlDialect` for them, so\n * everything that *compiles* a statement stops here.\n *\n * A caller who reads only \"not supported\" reasonably concludes the connection\n * is unusable, which is wrong and is the more expensive misreading: it is the\n * ORM that is unavailable, not the database.\n */\nexport class UnsupportedDialectError extends Error {\n constructor(dialect: Dialect) {\n super(\n `The gemi ORM does not support the '${dialect}' dialect. Only sqlite ` +\n `and postgres are implemented — see the supported matrix in ` +\n `docs/orm.md.\\n\\n` +\n `The *connection* is fine: Bun's client speaks ${dialect}, so raw SQL ` +\n `through DB.query / DB.sql and transactions all work. It is the query ` +\n `compiler that has no ${dialect} dialect, so every model operation ` +\n `raises this.\\n\\n` +\n `Point DATABASE_URL at Postgres or SQLite to use the ORM, or keep ` +\n `using Prisma's own client for this database.`,\n );\n this.name = \"UnsupportedDialectError\";\n }\n}\n\n/**\n * Whether the ORM can compile for this dialect at all.\n *\n * Exported so an application can find out at **boot** rather than on its first\n * query. That is the whole gap this closes: `DatabaseManager` constructs\n * happily against MySQL, so a deploy pointed at one starts, passes a health\n * check, serves traffic, and fails on the first model read — which is the\n * latest and most expensive moment to learn it.\n */\nexport function ormSupports(dialect: Dialect): boolean {\n return COMPILERS[dialect] !== null;\n}\n\n/** Every dialect `Dialect` names, for anything that has to walk them all. */\nexport function everyDialect(): Dialect[] {\n return Object.keys(COMPILERS) as Dialect[];\n}\n\n/**\n * The compiler for each dialect, or `null` where the ORM has none.\n *\n * **One map rather than two lists, and `satisfies` rather than a lookup.** The\n * supported set used to be written three times — `ormSupports`' `||` chain,\n * `dialectFor`'s `if` chain, and a test enumerating a hand-written copy of the\n * `Dialect` union — so adding a fifth member to that union changed nothing\n * anywhere: `tsc` clean, tests green, the new dialect silently reported as\n * unsupported by one function and unknown to the other.\n *\n * That moment is exactly what the guard exists for. Adding a dialect to the\n * union is the *first step of implementing one*, and it is the step where a\n * half-added dialect would disagree with itself.\n *\n * `satisfies Record<Dialect, …>` makes it a compile error in a file the build\n * actually checks. It has to live here rather than in a test: `tsconfig.json`\n * excludes test files and vitest transpiles without type-checking, so an\n * exhaustiveness check written there is a type error nothing ever evaluates.\n *\n * The sixth thing in this codebase made `tsc`'s job rather than a convention's\n * — see the note on `resolveLink`'s `operation`.\n */\nconst COMPILERS = {\n sqlite: new SqliteDialect(),\n postgres: new PostgresDialect(),\n // Bun's client speaks both; the ORM has no compiler for either. See\n // `UnsupportedDialectError`, which is careful to say that the *connection*\n // still works.\n mysql: null,\n mariadb: null,\n} satisfies Record<Dialect, SqlDialect | null>;\n\n/**\n * Resolved per call from `DatabaseManager.dialect`, never baked into a\n * generated artifact — `DATABASE_URL` can point at a different database than\n * the one `prisma generate` saw.\n */\nexport function dialectFor(dialect: Dialect): SqlDialect {\n const compiler = COMPILERS[dialect];\n if (compiler === null) throw new UnsupportedDialectError(dialect);\n return compiler;\n}\n\nexport { PostgresDialect, SqliteDialect };\n"
10
10
  ],
11
11
  "mappings": ";iDAoCO,SAAS,CAAiB,EAAgB,CAC/C,MAAO,CAAE,IAAK,IAAI,KAAQ,SAAU,CAAC,CAAE,EAOzC,IAAM,EAA4B,CAAE,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Q,EAAM,UACP,WACH,OAAO,EAAO,EAAO,CAAK,MACvB,UACH,GAAI,OAAO,IAAU,UAAW,OAAO,EAGvC,OAAO,OAAO,CAAK,IAAM,MACtB,SACH,GAAI,OAAO,IAAU,SAAU,OAAO,EACtC,GAAI,CACF,OAAO,OAAO,CAAe,EAC7B,KAAM,CAGN,MAAM,IAAI,EAAY,EAAO,CAAK,MAEjC,OACH,GAAI,CACF,OAAO,OAAO,IAAU,SAAW,KAAK,MAAM,CAAK,EAAI,EACvD,KAAM,CACN,MAAM,IAAI,EAAY,EAAO,CAAK,UAGpC,OAAO,GAGf,CAEA,SAAS,CAAe,CAAC,EAA0B,CACjD,MACE,mDAAmD,qDC/ChD,MAAM,UAAgC,KAAM,CACjD,WAAW,CAAC,EAAkB,CAC5B,MACE,sCAAsC,2BACpC,mEACA;AAAA;AAAA,gDACiD,2GAEzB;AAAA;AAAA,8GAI5B,EACA,KAAK,KAAO,0BAEhB,CAWO,SAAS,EAAW,CAAC,EAA2B,CACrD,OAAO,EAAU,KAAa,KAIzB,SAAS,EAAY,EAAc,CACxC,OAAO,OAAO,KAAK,CAAS,EAyB9B,IAAM,EAAY,CAChB,OAAQ,IAAI,EACZ,SAAU,IAAI,EAId,MAAO,KACP,QAAS,IACX,EAOO,SAAS,EAAU,CAAC,EAA8B,CACvD,IAAM,EAAW,EAAU,GAC3B,GAAI,IAAa,KAAM,MAAM,IAAI,EAAwB,CAAO,EAChE,OAAO",
12
- "debugId": "D5C82C500A54BEB864756E2164756E21",
12
+ "debugId": "0034F617F5F1776964756E2164756E21",
13
13
  "names": []
14
14
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-zf1eqgzt.js";import Eu from"os";import Au from"fs";var Wl=new Map,hh=new Map,nh=Symbol("OriginError"),Dl={};class fl extends Promise{constructor(l,n,u,c,w={}){let E,t;super((_,B)=>{E=_,t=B});this.tagged=Array.isArray(l.raw),this.strings=l,this.args=n,this.handler=u,this.canceller=c,this.options=w,this.state=null,this.statement=null,this.resolve=(_)=>(this.active=!1,E(_)),this.reject=(_)=>(this.active=!1,t(_)),this.active=!1,this.cancelled=null,this.executed=!1,this.signature="",this[nh]=this.handler.debug?Error():this.tagged&&vn(this.strings)}get origin(){return(this.handler.debug?this[nh].stack:this.tagged&&hh.has(this.strings)?hh.get(this.strings):hh.set(this.strings,this[nh].stack).get(this.strings))||""}static get[Symbol.species](){return Promise}cancel(){return this.canceller&&(this.canceller(this),this.canceller=null)}simple(){return this.options.simple=!0,this.options.prepare=!1,this}async readable(){return this.simple(),this.streaming=!0,this}async writable(){return this.simple(),this.streaming=!0,this}cursor(l=1,n){if(this.options.simple=!1,typeof l==="function")n=l,l=1;if(this.cursorRows=l,typeof n==="function")return this.cursorFn=n,this;let u;return{[Symbol.asyncIterator]:()=>({next:()=>{if(this.executed&&!this.active)return{done:!0};u&&u();let c=new Promise((w,E)=>{this.cursorFn=(t)=>{return w({value:t,done:!1}),new Promise((_)=>u=_)},this.resolve=()=>(this.active=!1,w({done:!0})),this.reject=(t)=>(this.active=!1,E(t))});return this.execute(),c},return(){return u&&u(Dl),{done:!0}}})}}describe(){return this.options.simple=!1,this.onlyDescribe=this.options.prepare=!0,this}stream(){throw Error(".stream has been renamed to .forEach")}forEach(l){return this.forEachFn=l,this.handle(),this}raw(){return this.isRaw=!0,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=!0)&&await 1&&this.handler(this)}execute(){return this.handle(),this}then(){return this.handle(),super.then.apply(this,arguments)}catch(){return this.handle(),super.catch.apply(this,arguments)}finally(){return this.handle(),super.finally.apply(this,arguments)}}function vn(l){if(Wl.has(l))return Wl.get(l);let n=Error.stackTraceLimit;return Error.stackTraceLimit=4,Wl.set(l,Error()),Error.stackTraceLimit=n,Wl.get(l)}class Yl extends Error{constructor(l){super(l.message);this.name=this.constructor.name,Object.assign(this,l)}}var K={connection:Th,postgres:Xh,generic:Ch,notSupported:Zh};function Th(l,n,u){let{host:c,port:w}=u||n,E=Object.assign(Error("write "+l+" "+(n.path||c+":"+w)),{code:l,errno:l,address:n.path||c},n.path?{}:{port:w});return Error.captureStackTrace(E,Th),E}function Xh(l){let n=new Yl(l);return Error.captureStackTrace(n,Xh),n}function Ch(l,n){let u=Object.assign(Error(l+": "+n),{code:l});return Error.captureStackTrace(u,Ch),u}function Zh(l){let n=Object.assign(Error(l+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:l});return Error.captureStackTrace(n,Zh),n}var mn={string:{to:25,from:null,serialize:(l)=>""+l},number:{to:0,from:[21,23,26,700,701],serialize:(l)=>""+l,parse:(l)=>+l},json:{to:114,from:[114,3802],serialize:(l)=>JSON.stringify(l),parse:(l)=>JSON.parse(l)},boolean:{to:16,from:16,serialize:(l)=>l===!0?"t":"f",parse:(l)=>l==="t"},date:{to:1184,from:[1082,1114,1184],serialize:(l)=>(l instanceof Date?l:new Date(l)).toISOString(),parse:(l)=>new Date(l)},bytea:{to:17,from:17,serialize:(l)=>"\\x"+Buffer.from(l).toString("hex"),parse:(l)=>Buffer.from(l.slice(2),"hex")}};class ml{then(){uh()}catch(){uh()}finally(){uh()}}class il extends ml{constructor(l){super();this.value=el(l)}}class wl extends ml{constructor(l,n,u){super();this.value=l,this.type=n,this.array=u}}class bl extends ml{constructor(l,n){super();this.first=l,this.rest=n}build(l,n,u,c){let w=bn.map(([E,t])=>({fn:t,i:l.search(E)})).sort((E,t)=>E.i-t.i).pop();return w.i===-1?_h(this.first,c):w.fn(this.first,this.rest,n,u,c)}}function al(l,n,u,c){let w=l instanceof wl?l.value:l;if(w===void 0){if(l instanceof wl?l.value=c.transform.undefined:w=l=c.transform.undefined,w===void 0)throw K.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return"$"+u.push(l instanceof wl?(n.push(l.value),l.array?l.array[l.type||vl(l.value)]||l.type||ih(l.value):l.type):(n.push(l),vl(l)))}var Hh=Qh(mn);function th(l,n,u,c,w,E){for(let t=1;t<l.strings.length;t++)n+=wh(n,u,c,w,E)+l.strings[t],u=l.args[t];return n}function wh(l,n,u,c,w){return n instanceof bl?n.build(l,u,c,w):n instanceof fl?ch(n,u,c,w):n instanceof il?n.value:n&&n[0]instanceof fl?n.reduce((E,t)=>E+" "+ch(t,u,c,w),""):al(n,u,c,w)}function ch(l,n,u,c){return l.fragment=!0,th(l,l.strings[0],l.args[0],n,u,c)}function zh(l,n,u,c,w){return l.map((E)=>"("+c.map((t)=>wh("values",E[t],n,u,w)).join(",")+")").join(",")}function Fh(l,n,u,c,w){let E=Array.isArray(l[0]),t=n.length?n.flat():Object.keys(E?l[0]:l);return zh(E?l:[l],u,c,t,w)}function Kl(l,n,u,c,w){if(typeof l==="string"&&(l=[l].concat(n)),Array.isArray(l))return _h(l,w);let E;return(n.length?n.flat():Object.keys(l)).map((_)=>{return E=l[_],(E instanceof fl?ch(E,u,c,w):E instanceof il?E.value:al(E,u,c,w))+" as "+el(w.transform.column.to?w.transform.column.to(_):_)}).join(",")}var bn=Object.entries({values:Fh,in:(...l)=>{let n=Fh(...l);return n==="()"?"(null)":n},select:Kl,as:Kl,returning:Kl,"\\(":Kl,update(l,n,u,c,w){return(n.length?n.flat():Object.keys(l)).map((E)=>el(w.transform.column.to?w.transform.column.to(E):E)+"="+wh("values",l[E],u,c,w))},insert(l,n,u,c,w){let E=n.length?n.flat():Object.keys(Array.isArray(l)?l[0]:l);return"("+_h(E,w)+")values"+zh(Array.isArray(l)?l:[l],u,c,E,w)}}).map(([l,n])=>[new RegExp("((?:^|[\\s(])"+l+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),n]);function uh(){throw K.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var{serializers:an,parsers:en}=Hh;function ih(l){if(Array.isArray(l))return ih(l[0]);return typeof l==="string"?1009:0}var Jh=function(l){let n=Qh(l||{});return{serializers:Object.assign({},an,n.serializers),parsers:Object.assign({},en,n.parsers)}};function Qh(l){return Object.keys(l).reduce((n,u)=>{if(l[u].from&&[].concat(l[u].from).forEach((c)=>n.parsers[c]=l[u].parse),l[u].serialize)n.serializers[l[u].to]=l[u].serialize,l[u].from&&[].concat(l[u].from).forEach((c)=>n.serializers[c]=l[u].serialize);return n},{parsers:{},serializers:{}})}function _h(l,{transform:{column:n}}){return l.map((u)=>el(n.to?n.to(u):u)).join(",")}var el=function(n){return'"'+n.replace(/"/g,'""').replace(/\./g,'"."')+'"'},vl=function l(n){return n instanceof wl?n.type:n instanceof Date?1184:n instanceof Uint8Array?17:n===!0||n===!1?16:typeof n==="bigint"?20:Array.isArray(n)?l(n[0]):0},kn=/\\/g,on=/"/g;function pn(l){return l.replace(kn,"\\\\").replace(on,"\\\"")}var Vh=function l(n,u,c,w){if(Array.isArray(n)===!1)return n;if(!n.length)return"{}";let E=n[0],t=w===1020?";":",";if(Array.isArray(E)&&!E.type)return"{"+n.map((_)=>l(_,u,c,w)).join(t)+"}";return"{"+n.map((_)=>{if(_===void 0){if(_=c.transform.undefined,_===void 0)throw K.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return _===null?"null":'"'+pn(u?u(_.type?_.value:_):""+_)+'"'}).join(t)+"}"},fh={i:0,char:null,str:"",quoted:!1,last:0},Wh=function(n,u,c){return fh.i=fh.last=0,Kh(fh,n,u,c)};function Kh(l,n,u,c){let w=[],E=c===1020?";":",";for(;l.i<n.length;l.i++){if(l.char=n[l.i],l.quoted)if(l.char==="\\")l.str+=n[++l.i];else if(l.char==='"')w.push(u?u(l.str):l.str),l.str="",l.quoted=n[l.i+1]==='"',l.last=l.i+2;else l.str+=l.char;else if(l.char==='"')l.quoted=!0;else if(l.char==="{")l.last=++l.i,w.push(Kh(l,n,u,c));else if(l.char==="}"){l.quoted=!1,l.last<l.i&&w.push(u?u(n.slice(l.last,l.i)):n.slice(l.last,l.i)),l.last=l.i+1;break}else if(l.char===E&&l.p!=="}"&&l.p!=='"')w.push(u?u(n.slice(l.last,l.i)):n.slice(l.last,l.i)),l.last=l.i+1;l.p=l.char}return l.last<l.i&&w.push(u?u(n.slice(l.last,l.i+1)):n.slice(l.last,l.i+1)),w}var Sl=(l)=>{let n=l[0];for(let u=1;u<l.length;u++)n+=l[u]==="_"?l[++u].toUpperCase():l[u];return n},Gl=(l)=>{let n=l[0].toUpperCase();for(let u=1;u<l.length;u++)n+=l[u]==="_"?l[++u].toUpperCase():l[u];return n},jl=(l)=>l.replace(/_/g,"-"),Fl=(l)=>l.replace(/([A-Z])/g,"_$1").toLowerCase(),Hl=(l)=>(l.slice(0,1)+l.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),zl=(l)=>l.replace(/-/g,"_");function Oh(l){return function n(u,c){return typeof u==="object"&&u!==null&&(c.type===114||c.type===3802)?Array.isArray(u)?u.map((w)=>n(w,c)):Object.entries(u).reduce((w,[E,t])=>Object.assign(w,{[l(E)]:n(t,c)}),{}):u}}Sl.column={from:Sl};Sl.value={from:Oh(Sl)};Fl.column={to:Fl};var Eh={...Sl};Eh.column.to=Fl;Gl.column={from:Gl};Gl.value={from:Oh(Gl)};Hl.column={to:Hl};var Ah={...Gl};Ah.column.to=Hl;jl.column={from:jl};jl.value={from:Oh(jl)};zl.column={to:zl};var Uh={...jl};Uh.column.to=zl;import vh from"net";import qn from"tls";import Jl from"crypto";import $h from"stream";import{performance as mh}from"perf_hooks";class Ml extends Array{constructor(){super();Object.defineProperties(this,{count:{value:null,writable:!0},state:{value:null,writable:!0},command:{value:null,writable:!0},columns:{value:null,writable:!0},statement:{value:null,writable:!0}})}static get[Symbol.species](){return Array}}var hl=yn;function yn(l=[]){let n=l.slice(),u=0;return{get length(){return n.length-u},remove:(c)=>{let w=n.indexOf(c);return w===-1?null:(n.splice(w,1),c)},push:(c)=>(n.push(c),c),shift:()=>{let c=n[u++];if(u===n.length)u=0,n=[];else n[u-1]=void 0;return c}}}var p=Buffer.allocUnsafe(256),rn="BCcDdEFfHPpQSX".split("").reduce((l,n)=>{let u=n.charCodeAt(0);return l[n]=()=>{return p[0]=u,R.i=5,R},l},{}),R=Object.assign(sn,rn,{N:String.fromCharCode(0),i:0,inc(l){return R.i+=l,R},str(l){let n=Buffer.byteLength(l);return kl(n),R.i+=p.write(l,R.i,n,"utf8"),R},i16(l){return kl(2),p.writeUInt16BE(l,R.i),R.i+=2,R},i32(l,n){if(n||n===0)return p.writeUInt32BE(l,n),R;return kl(4),p.writeUInt32BE(l,R.i),R.i+=4,R},z(l){return kl(l),p.fill(0,R.i,R.i+l),R.i+=l,R},raw(l){return p=Buffer.concat([p.subarray(0,R.i),l]),R.i=p.length,R},end(l=1){p.writeUInt32BE(R.i-l,l);let n=p.subarray(0,R.i);return R.i=0,p=Buffer.allocUnsafe(256),n}}),$=R;function kl(l){if(p.length-R.i<l){let n=p,u=n.length;p=Buffer.allocUnsafe(u+(u>>1)+l),n.copy(p)}}function sn(){return R.i=0,R}var Bh=eh,xn=1,Bl=$().S().end(),bh=$().H().end(),lu=$().i32(8).i32(80877103).end(8),hu=Buffer.concat([$().E().str($.N).i32(0).end(),Bl]),nu=$().D().str("S").str($.N).end(),Rl=()=>{},uu=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),fu={83:"severity_local",86:"severity",67:"code",77:"message",68:"detail",72:"hint",80:"position",112:"internal_position",113:"internal_query",87:"where",115:"schema_name",116:"table_name",99:"column_name",100:"data type_name",110:"constraint_name",70:"file",76:"line",82:"routine"};function eh(l,n={},{onopen:u=Rl,onend:c=Rl,onclose:w=Rl}={}){let{sslnegotiation:E,ssl:t,max:_,user:B,host:Q,port:T,database:Y,parsers:j,transform:M,onnotice:H,onnotify:I,onparameter:b,max_pipeline:Z,keep_alive:cl,backoff:nl,target_session_attrs:x}=l,d=hl(),Ul=xn++,_l={pid:null,secret:null},Pl=gh(xl,l.idle_timeout),Il=gh(xl,l.max_lifetime),L=gh(xh,l.connect_timeout),U=null,Ol,q=null,N=new Ml,y=Buffer.alloc(0),dl=l.fetch_types,El={},O={},S=Math.random().toString(36).slice(2),F=1,v=0,V=0,G=0,D=0,i=0,J=0,m=0,r=null,X=null,Al=!1,tl=null,$l=null,e=null,z=null,C=null,ll=null,Ql=null,sl=null,A=null,Tl=null,k={queue:n.closed,idleTimer:Pl,connect(h){e=h,Lh()},terminate:Zl,execute:Xl,cancel:yh,end:xl,count:0,id:Ul};return n.closed&&n.closed.push(k),k;async function ph(){let h;try{h=l.socket?await Promise.resolve(l.socket(l)):new vh.Socket}catch(f){Nl(f);return}return h.on("error",Nl),h.on("close",Nh),h.on("drain",Ph),h}async function yh({pid:h,secret:f},g,P){try{Ol=$().i32(16).i32(80877102).i32(h).i32(f).end(16),await dh(),U.once("error",P),U.once("close",g)}catch(W){P(W)}}function Xl(h){if(Al)return Cl(h,K.connection("CONNECTION_DESTROYED",l));if(C)return Cl(h,K.generic("COPY_IN_PROGRESS","You cannot execute queries during copy"));if(h.cancelled)return;try{return h.state=_l,A?d.push(h):(A=h,A.active=!0),qh(h),a(rh(h))&&!h.describeFirst&&!h.cursorFn&&d.length<Z&&(!h.options.onexecute||h.options.onexecute(k))}catch(f){return d.length===0&&a(Bl),ul(f),!0}}function rh(h){if(h.parameters.length>=65534)throw K.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return h.options.simple?$().Q().str(h.statement.string+$.N).end():h.describeFirst?Buffer.concat([Gh(h),bh]):h.prepare?h.prepared?Vl(h):Buffer.concat([Gh(h),Vl(h)]):sh(h)}function Gh(h){return Buffer.concat([Yh(h.statement.string,h.parameters,h.statement.types,h.statement.name),Vn("S",h.statement.name)])}function Vl(h){return Buffer.concat([Qn(h.parameters,h.statement.types,h.statement.name,h.cursorName),h.cursorFn?Rh("",h.cursorRows):hu])}function sh(h){return Buffer.concat([Yh(h.statement.string,h.parameters,h.statement.types),nu,Vl(h)])}function qh(h){let f=[],g=[],P=th(h,h.strings[0],h.args[0],f,g,l);!h.tagged&&h.args.forEach((W)=>al(W,f,g,l)),h.prepare=l.prepare&&("prepare"in h.options?h.options.prepare:!0),h.string=P,h.signature=h.prepare&&g+P,h.onlyDescribe&&delete O[h.signature],h.parameters=h.parameters||f,h.prepared=h.prepare&&h.signature in O,h.describeFirst=h.onlyDescribe||f.length&&!h.prepared,h.statement=h.prepared?O[h.signature]:{string:P,types:g,name:h.prepare?S+F++:""},typeof l.debug==="function"&&l.debug(Ul,P,f,g)}function a(h,f){if(ll=ll?Buffer.concat([ll,h]):Buffer.from(h),f||ll.length>=1024)return jh(f);return X===null&&(X=setImmediate(jh)),!0}function jh(h){let f=U.write(ll,h);return X!==null&&clearImmediate(X),ll=X=null,f}function xh(){ul(K.connection("CONNECT_TIMEOUT",l,U)),U.destroy()}async function Mh(){if(E!=="direct"){if(a(lu),!await new Promise((g)=>U.once("data",(P)=>g(P[0]===83)))&&t==="prefer")return Ll()}let h={socket:U,servername:vh.isIP(U.host)?void 0:U.host};if(E==="direct")h.ALPNProtocols=["postgresql"];if(t==="require"||t==="allow"||t==="prefer")h.rejectUnauthorized=!1;else if(typeof t==="object")Object.assign(h,t);U.removeAllListeners(),U=qn.connect(h),U.on("secureConnect",Ll),U.on("error",Nl),U.on("close",Nh),U.on("drain",Ph)}function Ph(){!A&&u(k)}function ql(h){if(tl){if(tl.push(h),V-=h.length,V>0)return}y=tl?Buffer.concat(tl,i-V):y.length===0?h:Buffer.concat([y,h],y.length+h.length);while(y.length>4){if(i=y.readUInt32BE(1),i>=y.length){V=i-y.length,tl=[y];break}try{ln(y.subarray(0,i+1))}catch(f){A&&(A.cursorFn||A.describeFirst)&&a(Bl),ul(f)}y=y.subarray(i+1),V=0,tl=null}}async function dh(){if(Al=!1,El={},U||(U=await ph()),!U)return;if(L.start(),l.socket)return t?Mh():Ll();if(U.on("connect",t?Mh:Ll),l.path)return U.connect(l.path);U.ssl=t,U.connect(T[G],Q[G]),U.host=Q[G],U.port=T[G],G=(G+1)%T.length}function Lh(){setTimeout(dh,v?Math.max(0,v+J-mh.now()):0)}function Ll(){try{O={},dl=l.fetch_types,S=Math.random().toString(36).slice(2),F=1,Il.start(),U.on("data",ql),cl&&U.setKeepAlive&&U.setKeepAlive(!0,1000*cl);let h=Kn();a(h)}catch(h){Nl(h)}}function Nl(h){if(k.queue===n.connecting&&l.host[D+1])return;ul(h);while(d.length)Cl(d.shift(),h)}function ul(h){C&&(C.destroy(h),C=null),A&&Cl(A,h),e&&(Cl(e,h),e=null)}function Cl(h,f){if(h.reserve)return h.reject(f);if(!f||typeof f!=="object")f=Error(f);"query"in f||"parameters"in f||Object.defineProperties(f,{stack:{value:f.stack+h.origin.replace(/.*\n/,`
2
+ import"./chunk-a76a7869.js";import Eu from"os";import Au from"fs";var Wl=new Map,hh=new Map,nh=Symbol("OriginError"),Dl={};class fl extends Promise{constructor(l,n,u,c,w={}){let E,t;super((_,B)=>{E=_,t=B});this.tagged=Array.isArray(l.raw),this.strings=l,this.args=n,this.handler=u,this.canceller=c,this.options=w,this.state=null,this.statement=null,this.resolve=(_)=>(this.active=!1,E(_)),this.reject=(_)=>(this.active=!1,t(_)),this.active=!1,this.cancelled=null,this.executed=!1,this.signature="",this[nh]=this.handler.debug?Error():this.tagged&&vn(this.strings)}get origin(){return(this.handler.debug?this[nh].stack:this.tagged&&hh.has(this.strings)?hh.get(this.strings):hh.set(this.strings,this[nh].stack).get(this.strings))||""}static get[Symbol.species](){return Promise}cancel(){return this.canceller&&(this.canceller(this),this.canceller=null)}simple(){return this.options.simple=!0,this.options.prepare=!1,this}async readable(){return this.simple(),this.streaming=!0,this}async writable(){return this.simple(),this.streaming=!0,this}cursor(l=1,n){if(this.options.simple=!1,typeof l==="function")n=l,l=1;if(this.cursorRows=l,typeof n==="function")return this.cursorFn=n,this;let u;return{[Symbol.asyncIterator]:()=>({next:()=>{if(this.executed&&!this.active)return{done:!0};u&&u();let c=new Promise((w,E)=>{this.cursorFn=(t)=>{return w({value:t,done:!1}),new Promise((_)=>u=_)},this.resolve=()=>(this.active=!1,w({done:!0})),this.reject=(t)=>(this.active=!1,E(t))});return this.execute(),c},return(){return u&&u(Dl),{done:!0}}})}}describe(){return this.options.simple=!1,this.onlyDescribe=this.options.prepare=!0,this}stream(){throw Error(".stream has been renamed to .forEach")}forEach(l){return this.forEachFn=l,this.handle(),this}raw(){return this.isRaw=!0,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=!0)&&await 1&&this.handler(this)}execute(){return this.handle(),this}then(){return this.handle(),super.then.apply(this,arguments)}catch(){return this.handle(),super.catch.apply(this,arguments)}finally(){return this.handle(),super.finally.apply(this,arguments)}}function vn(l){if(Wl.has(l))return Wl.get(l);let n=Error.stackTraceLimit;return Error.stackTraceLimit=4,Wl.set(l,Error()),Error.stackTraceLimit=n,Wl.get(l)}class Yl extends Error{constructor(l){super(l.message);this.name=this.constructor.name,Object.assign(this,l)}}var K={connection:Th,postgres:Xh,generic:Ch,notSupported:Zh};function Th(l,n,u){let{host:c,port:w}=u||n,E=Object.assign(Error("write "+l+" "+(n.path||c+":"+w)),{code:l,errno:l,address:n.path||c},n.path?{}:{port:w});return Error.captureStackTrace(E,Th),E}function Xh(l){let n=new Yl(l);return Error.captureStackTrace(n,Xh),n}function Ch(l,n){let u=Object.assign(Error(l+": "+n),{code:l});return Error.captureStackTrace(u,Ch),u}function Zh(l){let n=Object.assign(Error(l+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:l});return Error.captureStackTrace(n,Zh),n}var mn={string:{to:25,from:null,serialize:(l)=>""+l},number:{to:0,from:[21,23,26,700,701],serialize:(l)=>""+l,parse:(l)=>+l},json:{to:114,from:[114,3802],serialize:(l)=>JSON.stringify(l),parse:(l)=>JSON.parse(l)},boolean:{to:16,from:16,serialize:(l)=>l===!0?"t":"f",parse:(l)=>l==="t"},date:{to:1184,from:[1082,1114,1184],serialize:(l)=>(l instanceof Date?l:new Date(l)).toISOString(),parse:(l)=>new Date(l)},bytea:{to:17,from:17,serialize:(l)=>"\\x"+Buffer.from(l).toString("hex"),parse:(l)=>Buffer.from(l.slice(2),"hex")}};class ml{then(){uh()}catch(){uh()}finally(){uh()}}class il extends ml{constructor(l){super();this.value=el(l)}}class wl extends ml{constructor(l,n,u){super();this.value=l,this.type=n,this.array=u}}class bl extends ml{constructor(l,n){super();this.first=l,this.rest=n}build(l,n,u,c){let w=bn.map(([E,t])=>({fn:t,i:l.search(E)})).sort((E,t)=>E.i-t.i).pop();return w.i===-1?_h(this.first,c):w.fn(this.first,this.rest,n,u,c)}}function al(l,n,u,c){let w=l instanceof wl?l.value:l;if(w===void 0){if(l instanceof wl?l.value=c.transform.undefined:w=l=c.transform.undefined,w===void 0)throw K.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return"$"+u.push(l instanceof wl?(n.push(l.value),l.array?l.array[l.type||vl(l.value)]||l.type||ih(l.value):l.type):(n.push(l),vl(l)))}var Hh=Qh(mn);function th(l,n,u,c,w,E){for(let t=1;t<l.strings.length;t++)n+=wh(n,u,c,w,E)+l.strings[t],u=l.args[t];return n}function wh(l,n,u,c,w){return n instanceof bl?n.build(l,u,c,w):n instanceof fl?ch(n,u,c,w):n instanceof il?n.value:n&&n[0]instanceof fl?n.reduce((E,t)=>E+" "+ch(t,u,c,w),""):al(n,u,c,w)}function ch(l,n,u,c){return l.fragment=!0,th(l,l.strings[0],l.args[0],n,u,c)}function zh(l,n,u,c,w){return l.map((E)=>"("+c.map((t)=>wh("values",E[t],n,u,w)).join(",")+")").join(",")}function Fh(l,n,u,c,w){let E=Array.isArray(l[0]),t=n.length?n.flat():Object.keys(E?l[0]:l);return zh(E?l:[l],u,c,t,w)}function Kl(l,n,u,c,w){if(typeof l==="string"&&(l=[l].concat(n)),Array.isArray(l))return _h(l,w);let E;return(n.length?n.flat():Object.keys(l)).map((_)=>{return E=l[_],(E instanceof fl?ch(E,u,c,w):E instanceof il?E.value:al(E,u,c,w))+" as "+el(w.transform.column.to?w.transform.column.to(_):_)}).join(",")}var bn=Object.entries({values:Fh,in:(...l)=>{let n=Fh(...l);return n==="()"?"(null)":n},select:Kl,as:Kl,returning:Kl,"\\(":Kl,update(l,n,u,c,w){return(n.length?n.flat():Object.keys(l)).map((E)=>el(w.transform.column.to?w.transform.column.to(E):E)+"="+wh("values",l[E],u,c,w))},insert(l,n,u,c,w){let E=n.length?n.flat():Object.keys(Array.isArray(l)?l[0]:l);return"("+_h(E,w)+")values"+zh(Array.isArray(l)?l:[l],u,c,E,w)}}).map(([l,n])=>[new RegExp("((?:^|[\\s(])"+l+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),n]);function uh(){throw K.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var{serializers:an,parsers:en}=Hh;function ih(l){if(Array.isArray(l))return ih(l[0]);return typeof l==="string"?1009:0}var Jh=function(l){let n=Qh(l||{});return{serializers:Object.assign({},an,n.serializers),parsers:Object.assign({},en,n.parsers)}};function Qh(l){return Object.keys(l).reduce((n,u)=>{if(l[u].from&&[].concat(l[u].from).forEach((c)=>n.parsers[c]=l[u].parse),l[u].serialize)n.serializers[l[u].to]=l[u].serialize,l[u].from&&[].concat(l[u].from).forEach((c)=>n.serializers[c]=l[u].serialize);return n},{parsers:{},serializers:{}})}function _h(l,{transform:{column:n}}){return l.map((u)=>el(n.to?n.to(u):u)).join(",")}var el=function(n){return'"'+n.replace(/"/g,'""').replace(/\./g,'"."')+'"'},vl=function l(n){return n instanceof wl?n.type:n instanceof Date?1184:n instanceof Uint8Array?17:n===!0||n===!1?16:typeof n==="bigint"?20:Array.isArray(n)?l(n[0]):0},kn=/\\/g,on=/"/g;function pn(l){return l.replace(kn,"\\\\").replace(on,"\\\"")}var Vh=function l(n,u,c,w){if(Array.isArray(n)===!1)return n;if(!n.length)return"{}";let E=n[0],t=w===1020?";":",";if(Array.isArray(E)&&!E.type)return"{"+n.map((_)=>l(_,u,c,w)).join(t)+"}";return"{"+n.map((_)=>{if(_===void 0){if(_=c.transform.undefined,_===void 0)throw K.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return _===null?"null":'"'+pn(u?u(_.type?_.value:_):""+_)+'"'}).join(t)+"}"},fh={i:0,char:null,str:"",quoted:!1,last:0},Wh=function(n,u,c){return fh.i=fh.last=0,Kh(fh,n,u,c)};function Kh(l,n,u,c){let w=[],E=c===1020?";":",";for(;l.i<n.length;l.i++){if(l.char=n[l.i],l.quoted)if(l.char==="\\")l.str+=n[++l.i];else if(l.char==='"')w.push(u?u(l.str):l.str),l.str="",l.quoted=n[l.i+1]==='"',l.last=l.i+2;else l.str+=l.char;else if(l.char==='"')l.quoted=!0;else if(l.char==="{")l.last=++l.i,w.push(Kh(l,n,u,c));else if(l.char==="}"){l.quoted=!1,l.last<l.i&&w.push(u?u(n.slice(l.last,l.i)):n.slice(l.last,l.i)),l.last=l.i+1;break}else if(l.char===E&&l.p!=="}"&&l.p!=='"')w.push(u?u(n.slice(l.last,l.i)):n.slice(l.last,l.i)),l.last=l.i+1;l.p=l.char}return l.last<l.i&&w.push(u?u(n.slice(l.last,l.i+1)):n.slice(l.last,l.i+1)),w}var Sl=(l)=>{let n=l[0];for(let u=1;u<l.length;u++)n+=l[u]==="_"?l[++u].toUpperCase():l[u];return n},Gl=(l)=>{let n=l[0].toUpperCase();for(let u=1;u<l.length;u++)n+=l[u]==="_"?l[++u].toUpperCase():l[u];return n},jl=(l)=>l.replace(/_/g,"-"),Fl=(l)=>l.replace(/([A-Z])/g,"_$1").toLowerCase(),Hl=(l)=>(l.slice(0,1)+l.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),zl=(l)=>l.replace(/-/g,"_");function Oh(l){return function n(u,c){return typeof u==="object"&&u!==null&&(c.type===114||c.type===3802)?Array.isArray(u)?u.map((w)=>n(w,c)):Object.entries(u).reduce((w,[E,t])=>Object.assign(w,{[l(E)]:n(t,c)}),{}):u}}Sl.column={from:Sl};Sl.value={from:Oh(Sl)};Fl.column={to:Fl};var Eh={...Sl};Eh.column.to=Fl;Gl.column={from:Gl};Gl.value={from:Oh(Gl)};Hl.column={to:Hl};var Ah={...Gl};Ah.column.to=Hl;jl.column={from:jl};jl.value={from:Oh(jl)};zl.column={to:zl};var Uh={...jl};Uh.column.to=zl;import vh from"net";import qn from"tls";import Jl from"crypto";import $h from"stream";import{performance as mh}from"perf_hooks";class Ml extends Array{constructor(){super();Object.defineProperties(this,{count:{value:null,writable:!0},state:{value:null,writable:!0},command:{value:null,writable:!0},columns:{value:null,writable:!0},statement:{value:null,writable:!0}})}static get[Symbol.species](){return Array}}var hl=yn;function yn(l=[]){let n=l.slice(),u=0;return{get length(){return n.length-u},remove:(c)=>{let w=n.indexOf(c);return w===-1?null:(n.splice(w,1),c)},push:(c)=>(n.push(c),c),shift:()=>{let c=n[u++];if(u===n.length)u=0,n=[];else n[u-1]=void 0;return c}}}var p=Buffer.allocUnsafe(256),rn="BCcDdEFfHPpQSX".split("").reduce((l,n)=>{let u=n.charCodeAt(0);return l[n]=()=>{return p[0]=u,R.i=5,R},l},{}),R=Object.assign(sn,rn,{N:String.fromCharCode(0),i:0,inc(l){return R.i+=l,R},str(l){let n=Buffer.byteLength(l);return kl(n),R.i+=p.write(l,R.i,n,"utf8"),R},i16(l){return kl(2),p.writeUInt16BE(l,R.i),R.i+=2,R},i32(l,n){if(n||n===0)return p.writeUInt32BE(l,n),R;return kl(4),p.writeUInt32BE(l,R.i),R.i+=4,R},z(l){return kl(l),p.fill(0,R.i,R.i+l),R.i+=l,R},raw(l){return p=Buffer.concat([p.subarray(0,R.i),l]),R.i=p.length,R},end(l=1){p.writeUInt32BE(R.i-l,l);let n=p.subarray(0,R.i);return R.i=0,p=Buffer.allocUnsafe(256),n}}),$=R;function kl(l){if(p.length-R.i<l){let n=p,u=n.length;p=Buffer.allocUnsafe(u+(u>>1)+l),n.copy(p)}}function sn(){return R.i=0,R}var Bh=eh,xn=1,Bl=$().S().end(),bh=$().H().end(),lu=$().i32(8).i32(80877103).end(8),hu=Buffer.concat([$().E().str($.N).i32(0).end(),Bl]),nu=$().D().str("S").str($.N).end(),Rl=()=>{},uu=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),fu={83:"severity_local",86:"severity",67:"code",77:"message",68:"detail",72:"hint",80:"position",112:"internal_position",113:"internal_query",87:"where",115:"schema_name",116:"table_name",99:"column_name",100:"data type_name",110:"constraint_name",70:"file",76:"line",82:"routine"};function eh(l,n={},{onopen:u=Rl,onend:c=Rl,onclose:w=Rl}={}){let{sslnegotiation:E,ssl:t,max:_,user:B,host:Q,port:T,database:Y,parsers:j,transform:M,onnotice:H,onnotify:I,onparameter:b,max_pipeline:Z,keep_alive:cl,backoff:nl,target_session_attrs:x}=l,d=hl(),Ul=xn++,_l={pid:null,secret:null},Pl=gh(xl,l.idle_timeout),Il=gh(xl,l.max_lifetime),L=gh(xh,l.connect_timeout),U=null,Ol,q=null,N=new Ml,y=Buffer.alloc(0),dl=l.fetch_types,El={},O={},S=Math.random().toString(36).slice(2),F=1,v=0,V=0,G=0,D=0,i=0,J=0,m=0,r=null,X=null,Al=!1,tl=null,$l=null,e=null,z=null,C=null,ll=null,Ql=null,sl=null,A=null,Tl=null,k={queue:n.closed,idleTimer:Pl,connect(h){e=h,Lh()},terminate:Zl,execute:Xl,cancel:yh,end:xl,count:0,id:Ul};return n.closed&&n.closed.push(k),k;async function ph(){let h;try{h=l.socket?await Promise.resolve(l.socket(l)):new vh.Socket}catch(f){Nl(f);return}return h.on("error",Nl),h.on("close",Nh),h.on("drain",Ph),h}async function yh({pid:h,secret:f},g,P){try{Ol=$().i32(16).i32(80877102).i32(h).i32(f).end(16),await dh(),U.once("error",P),U.once("close",g)}catch(W){P(W)}}function Xl(h){if(Al)return Cl(h,K.connection("CONNECTION_DESTROYED",l));if(C)return Cl(h,K.generic("COPY_IN_PROGRESS","You cannot execute queries during copy"));if(h.cancelled)return;try{return h.state=_l,A?d.push(h):(A=h,A.active=!0),qh(h),a(rh(h))&&!h.describeFirst&&!h.cursorFn&&d.length<Z&&(!h.options.onexecute||h.options.onexecute(k))}catch(f){return d.length===0&&a(Bl),ul(f),!0}}function rh(h){if(h.parameters.length>=65534)throw K.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return h.options.simple?$().Q().str(h.statement.string+$.N).end():h.describeFirst?Buffer.concat([Gh(h),bh]):h.prepare?h.prepared?Vl(h):Buffer.concat([Gh(h),Vl(h)]):sh(h)}function Gh(h){return Buffer.concat([Yh(h.statement.string,h.parameters,h.statement.types,h.statement.name),Vn("S",h.statement.name)])}function Vl(h){return Buffer.concat([Qn(h.parameters,h.statement.types,h.statement.name,h.cursorName),h.cursorFn?Rh("",h.cursorRows):hu])}function sh(h){return Buffer.concat([Yh(h.statement.string,h.parameters,h.statement.types),nu,Vl(h)])}function qh(h){let f=[],g=[],P=th(h,h.strings[0],h.args[0],f,g,l);!h.tagged&&h.args.forEach((W)=>al(W,f,g,l)),h.prepare=l.prepare&&("prepare"in h.options?h.options.prepare:!0),h.string=P,h.signature=h.prepare&&g+P,h.onlyDescribe&&delete O[h.signature],h.parameters=h.parameters||f,h.prepared=h.prepare&&h.signature in O,h.describeFirst=h.onlyDescribe||f.length&&!h.prepared,h.statement=h.prepared?O[h.signature]:{string:P,types:g,name:h.prepare?S+F++:""},typeof l.debug==="function"&&l.debug(Ul,P,f,g)}function a(h,f){if(ll=ll?Buffer.concat([ll,h]):Buffer.from(h),f||ll.length>=1024)return jh(f);return X===null&&(X=setImmediate(jh)),!0}function jh(h){let f=U.write(ll,h);return X!==null&&clearImmediate(X),ll=X=null,f}function xh(){ul(K.connection("CONNECT_TIMEOUT",l,U)),U.destroy()}async function Mh(){if(E!=="direct"){if(a(lu),!await new Promise((g)=>U.once("data",(P)=>g(P[0]===83)))&&t==="prefer")return Ll()}let h={socket:U,servername:vh.isIP(U.host)?void 0:U.host};if(E==="direct")h.ALPNProtocols=["postgresql"];if(t==="require"||t==="allow"||t==="prefer")h.rejectUnauthorized=!1;else if(typeof t==="object")Object.assign(h,t);U.removeAllListeners(),U=qn.connect(h),U.on("secureConnect",Ll),U.on("error",Nl),U.on("close",Nh),U.on("drain",Ph)}function Ph(){!A&&u(k)}function ql(h){if(tl){if(tl.push(h),V-=h.length,V>0)return}y=tl?Buffer.concat(tl,i-V):y.length===0?h:Buffer.concat([y,h],y.length+h.length);while(y.length>4){if(i=y.readUInt32BE(1),i>=y.length){V=i-y.length,tl=[y];break}try{ln(y.subarray(0,i+1))}catch(f){A&&(A.cursorFn||A.describeFirst)&&a(Bl),ul(f)}y=y.subarray(i+1),V=0,tl=null}}async function dh(){if(Al=!1,El={},U||(U=await ph()),!U)return;if(L.start(),l.socket)return t?Mh():Ll();if(U.on("connect",t?Mh:Ll),l.path)return U.connect(l.path);U.ssl=t,U.connect(T[G],Q[G]),U.host=Q[G],U.port=T[G],G=(G+1)%T.length}function Lh(){setTimeout(dh,v?Math.max(0,v+J-mh.now()):0)}function Ll(){try{O={},dl=l.fetch_types,S=Math.random().toString(36).slice(2),F=1,Il.start(),U.on("data",ql),cl&&U.setKeepAlive&&U.setKeepAlive(!0,1000*cl);let h=Kn();a(h)}catch(h){Nl(h)}}function Nl(h){if(k.queue===n.connecting&&l.host[D+1])return;ul(h);while(d.length)Cl(d.shift(),h)}function ul(h){C&&(C.destroy(h),C=null),A&&Cl(A,h),e&&(Cl(e,h),e=null)}function Cl(h,f){if(h.reserve)return h.reject(f);if(!f||typeof f!=="object")f=Error(f);"query"in f||"parameters"in f||Object.defineProperties(f,{stack:{value:f.stack+h.origin.replace(/.*\n/,`
3
3
  `),enumerable:l.debug},query:{value:h.string,enumerable:l.debug},parameters:{value:h.parameters,enumerable:l.debug},args:{value:h.args,enumerable:l.debug},types:{value:h.statement&&h.statement.types,enumerable:l.debug}}),h.reject(f)}function xl(){return z||(!k.reserved&&c(k),!k.reserved&&!e&&!A&&d.length===0?(Zl(),new Promise((h)=>U&&U.readyState!=="closed"?U.once("close",h):h())):z=new Promise((h)=>Ql=h))}function Zl(){if(Al=!0,C||A||e||d.length)Nl(K.connection("CONNECTION_DESTROYED",l));if(clearImmediate(X),U)U.removeListener("data",ql),U.removeListener("connect",Ll),U.readyState==="open"&&U.end($().X().end());Ql&&(Ql(),z=Ql=null)}async function Nh(h){if(y=Buffer.alloc(0),V=0,tl=null,clearImmediate(X),U.removeListener("data",ql),U.removeListener("connect",Ll),Pl.cancel(),Il.cancel(),L.cancel(),U.removeAllListeners(),U=null,e)return Lh();!h&&(A||d.length)&&Nl(K.connection("CONNECTION_CLOSED",l,U)),v=mh.now(),h&&l.shared.retries++,J=(typeof nl==="function"?nl(l.shared.retries):nl)*1000,w(k,K.connection("CONNECTION_CLOSED",l,U))}function ln(h,f=h[0]){(f===68?hn:f===100?Tn:f===65?dn:f===83?nn:f===90?un:f===67?fn:f===50?Dh:f===49?cn:f===116?tn:f===84?wn:f===82?_n:f===110?gn:f===75?Bn:f===69?Mn:f===115?Ln:f===51?Nn:f===71?Dn:f===78?Cn:f===72?Yn:f===99?Xn:f===73?Zn:f===86?Fn:f===118?Hn:f===87?Rn:zn)(h)}function hn(h){let f=7,g,P,W,o=A.isRaw?Array(A.statement.columns.length):{};for(let s=0;s<A.statement.columns.length;s++)P=A.statement.columns[s],g=h.readInt32BE(f),f+=4,W=g===-1?null:A.isRaw===!0?h.subarray(f,f+=g):P.parser===void 0?h.toString("utf8",f,f+=g):P.parser.array===!0?P.parser(h.toString("utf8",f+1,f+=g)):P.parser(h.toString("utf8",f,f+=g)),A.isRaw?o[s]=A.isRaw===!0?W:M.value.from?M.value.from(W,P):W:o[P.name]=M.value.from?M.value.from(W,P):W;A.forEachFn?A.forEachFn(M.row.from?M.row.from(o):o,N):N[m++]=M.row.from?M.row.from(o):o}function nn(h){let[f,g]=h.toString("utf8",5,h.length-1).split($.N);if(El[f]=g,l.parameters[f]!==g)l.parameters[f]=g,b&&b(f,g)}function un(h){if(A)if(q)A.retried?ul(A.retried):A.prepared&&uu.has(q.routine)?Pn(A,q):ul(q);else A.resolve($l||N);else if(q)ul(q);if(A=$l=q=null,N=new Ml,L.cancel(),e){if(x){if(!El.in_hot_standby||!El.default_transaction_read_only)return jn();else if(Gn(x,El))return Zl()}if(dl)return e.reserve&&(e=null),In();e&&!e.reserve&&Xl(e),l.shared.retries=D=0,e=null;return}while(d.length&&(A=d.shift())&&(A.active=!0,A.cancelled))eh(l).cancel(A.state,A.cancelled.resolve,A.cancelled.reject);if(A)return;k.reserved?!k.reserved.release&&h[5]===73?z?Zl():(k.reserved=null,u(k)):k.reserved():z?Zl():u(k)}function fn(h){m=0;for(let f=h.length-1;f>0;f--){if(h[f]===32&&h[f+1]<58&&N.count===null)N.count=+h.toString("utf8",f+1,h.length-1);if(h[f-1]>=65){N.command=h.toString("utf8",5,f),N.state=_l;break}}if(Tl&&(Tl(),Tl=null),N.command==="BEGIN"&&_!==1&&!k.reserved)return ul(K.generic("UNSAFE_TRANSACTION","Only use sql.begin, sql.reserved or max: 1"));if(A.options.simple)return Dh();if(A.cursorFn)N.count&&A.cursorFn(N),a(Bl)}function cn(){A.parsing=!1}function Dh(){!N.statement&&(N.statement=A.statement),N.columns=A.statement.columns}function tn(h){let f=h.readUInt16BE(5);for(let g=0;g<f;++g)!A.statement.types[g]&&(A.statement.types[g]=h.readUInt32BE(7+g*4));A.prepare&&(O[A.signature]=A.statement),A.describeFirst&&!A.onlyDescribe&&(a(Vl(A)),A.describeFirst=!1)}function wn(h){if(N.command)$l=$l||[N],$l.push(N=new Ml),N.count=null,A.statement.columns=null;let f=h.readUInt16BE(5),g=7,P;A.statement.columns=Array(f);for(let W=0;W<f;++W){P=g;while(h[g++]!==0);let o=h.readUInt32BE(g),s=h.readUInt16BE(g+4),gl=h.readUInt32BE(g+6);A.statement.columns[W]={name:M.column.from?M.column.from(h.toString("utf8",P,g-1)):h.toString("utf8",P,g-1),parser:j[gl],table:o,number:s,type:gl},g+=18}if(N.statement=A.statement,A.onlyDescribe)return A.resolve(A.statement),a(Bl)}async function _n(h,f=h.readUInt32BE(5)){(f===3?On:f===5?En:f===10?An:f===11?Un:f===12?$n:f!==0?Jn:Rl)(h,f)}async function On(){let h=await lh();a($().p().str(h).z(1).end())}async function En(h){let f="md5"+await ah(Buffer.concat([Buffer.from(await ah(await lh()+B)),h.subarray(9)]));a($().p().str(f).z(1).end())}async function An(){sl=(await Jl.randomBytes(18)).toString("base64"),$().p().str("SCRAM-SHA-256"+$.N);let h=$.i;a($.inc(4).str("n,,n=*,r="+sl).i32($.i-h-4,h).end())}async function Un(h){let f=h.toString("utf8",9).split(",").reduce((s,gl)=>(s[gl[0]]=gl.slice(2),s),{}),g=await Jl.pbkdf2Sync(await lh(),Buffer.from(f.s,"base64"),parseInt(f.i),32,"sha256"),P=await pl(g,"Client Key"),W="n=*,r="+sl+",r="+f.r+",s="+f.s+",i="+f.i+",c=biws,r="+f.r;r=(await pl(await pl(g,"Server Key"),W)).toString("base64");let o="c=biws,r="+f.r+",p="+tu(P,Buffer.from(await pl(await cu(P),W))).toString("base64");a($().p().str(o).end())}function $n(h){if(h.toString("utf8",9).split($.N,1)[0].slice(2)===r)return;ul(K.generic("SASL_SIGNATURE_MISMATCH","The server did not return the correct signature")),U.destroy()}function lh(){return Promise.resolve(typeof l.pass==="function"?l.pass():l.pass)}function gn(){if(N.statement=A.statement,N.statement.columns=[],A.onlyDescribe)return A.resolve(A.statement),a(Bl)}function Bn(h){_l.pid=h.readUInt32BE(5),_l.secret=h.readUInt32BE(9)}async function In(){dl=!1,(await new fl([`
4
4
  select b.oid, b.typarray
5
5
  from pg_catalog.pg_type a
@@ -2,6 +2,6 @@
2
2
  function I(B){if(!B.definition)throw Error(`gemi/ai: the recursive schema "${B.name}" was used before its definition returned; \`self\` can be nested into the schema, but not parsed or emitted inside the callback`);return B.definition}var k=new WeakMap;function MB(B){return typeof B==="object"&&B!==null&&k.has(B)}function x(B){let F=k.get(B);if(!F)throw Error("gemi/ai: expected a schema built with `s`, got a foreign object");return F}function o(B){let F={defs:{},cells:new Map},G=B;if(B.node.kind==="ref"){let Q=I(B.node.cell);G={...Q,...B.description?{description:B.description}:{},optional:B.optional,nullable:B.nullable||Q.nullable}}let H=K(G,F);return Object.keys(F.defs).length>0?{...H,$defs:F.defs}:H}function K(B,F){let G=(B.optional||B.nullable)&&B.node.kind!=="json",H=n(l(B.node,F),G),Q=[B.description,t(B.node)].filter(Boolean).join(" ");if(Q&&H.$ref!==void 0)H={anyOf:[H]};return Q?{description:Q,...H}:H}function t(B){let F=[];if(B.kind==="string"||B.kind==="enum"){let G=B.checks;if(G?.format)F.push(`Format: ${G.format.name}.`);if(G?.minLength!==void 0)F.push(`At least ${G.minLength} characters.`);if(G?.maxLength!==void 0)F.push(`At most ${G.maxLength} characters.`)}else if(B.kind==="number"){let G=B.checks;if(G?.minimum!==void 0)F.push(`Minimum ${G.minimum}.`);if(G?.exclusiveMinimum!==void 0)F.push(`Greater than ${G.exclusiveMinimum}.`);if(G?.maximum!==void 0)F.push(`Maximum ${G.maximum}.`);if(G?.exclusiveMaximum!==void 0)F.push(`Less than ${G.exclusiveMaximum}.`)}else if(B.kind==="array"){let G=B.checks;if(G?.minItems!==void 0)F.push(`At least ${G.minItems} items.`);if(G?.maxItems!==void 0)F.push(`At most ${G.maxItems} items.`)}return F.join(" ")}function l(B,F){switch(B.kind){case"string":return{type:"string"};case"number":return{type:B.checks?.integer?"integer":"number"};case"boolean":return{type:"boolean"};case"literal":return{type:typeof B.value,const:B.value};case"enum":return{type:"string",enum:B.values};case"array":return{type:"array",items:K(B.item,F)};case"object":return{type:"object",properties:Object.fromEntries(Object.entries(B.shape).map(([G,H])=>[G,K(H,F)])),required:Object.keys(B.shape),additionalProperties:!1};case"union":return{anyOf:B.members.map((G)=>K(G,F))};case"json":return{};case"ref":{let{cell:G}=B,H=F.cells.get(G.name);if(H&&H!==G)throw Error(`gemi/ai: two different recursive schemas are named "${G.name}" in one schema; give each s.recursive(...) its own name`);if(!H)F.cells.set(G.name,G),F.defs[G.name]={},F.defs[G.name]=K(I(G),F);return{$ref:`#/$defs/${G.name}`}}}}function n(B,F){if(!F)return B;if(B.anyOf)return{...B,anyOf:[...B.anyOf,{type:"null"}]};if(B.enum||B.const!==void 0)return{anyOf:[B,{type:"null"}]};if(typeof B.type==="string")return{...B,type:[B.type,"null"]};return{anyOf:[B,{type:"null"}]}}function i(B){if(B===null)return"null";if(Array.isArray(B))return"array";return typeof B}function s(B,F){if(typeof F==="number"&&!Number.isFinite(F))return String(F);if(B.kind==="literal"||B.kind==="enum"){if(typeof F==="string"||typeof F==="number"||typeof F==="boolean")return JSON.stringify(F)}return i(F)}function d(B){let F=B.node,G=(()=>{switch(F.kind){case"number":return F.checks?.integer?"integer":"number";case"string":case"boolean":return F.kind;case"literal":return JSON.stringify(F.value);case"enum":return`one of ${F.values.map((H)=>JSON.stringify(H)).join(" | ")}`;case"array":return"array";case"object":return"object";case"union":return"one of the variants";case"json":return"a JSON value";case"ref":return d({...I(F.cell),optional:!1,nullable:!1})}})();return B.optional||B.nullable?`${G} or null`:G}function a(B){let F="";for(let G of B)F+=typeof G==="number"?`[${G}]`:F?`.${G}`:G;return F}function e(B){let F=a(B);return F?`${F}: `:""}function p(B){return`${e(B.path)}${B.message}`}function O(B,F){if(F===null||F===void 0)return B.optional||B.nullable?1:0;let G=B.node;switch(G.kind){case"string":return typeof F==="string"?1:0;case"number":return typeof F==="number"?1:0;case"boolean":return typeof F==="boolean"?1:0;case"literal":return F===G.value?10:0;case"enum":return typeof F==="string"&&G.values.includes(F)?10:0;case"array":return Array.isArray(F)?1:0;case"object":{if(typeof F!=="object"||Array.isArray(F))return 0;let H=F,Q=1;for(let[X,$]of Object.entries(G.shape))Q+=O($,H[X]);return Q}case"union":return G.members.reduce((H,Q)=>Math.max(H,O(Q,F)),0);case"json":return 1;case"ref":return m(G.cell,F,()=>1,()=>O(I(G.cell),F))}}function m(B,F,G,H){if(typeof F!=="object"||F===null)return H();if(B.active.has(F))return G();B.active.add(F);try{return H()}finally{B.active.delete(F)}}function R(B,F,G,H){if(B.optional&&(F===null||F===void 0))return{drop:!0,value:void 0};if(B.nullable&&F===null)return{drop:!1,value:null};return{drop:!1,value:BB(B,F,G,H)}}function BB(B,F,G,H){let Q=B.node,X=()=>{let $=F===void 0?"required":Q.kind==="literal"?"const":Q.kind==="enum"&&typeof F==="string"?"enum":"type",M=$==="const"?{allowedValue:Q.value}:$==="enum"?{allowedValues:Q.values}:{};H.push({path:G,code:$,message:`expected ${d(B)}, got ${s(Q,F)}`,params:M});return};switch(Q.kind){case"string":if(typeof F!=="string")return X();return r(Q.checks,F,G,H),F;case"number":if(typeof F!=="number"||!Number.isFinite(F))return X();if(Q.checks?.integer&&!Number.isInteger(F))return X();return GB(Q.checks,F,G,H),F;case"boolean":return typeof F==="boolean"?F:X();case"literal":return F===Q.value?F:X();case"enum":if(typeof F!=="string"||!Q.values.includes(F))return X();return r(Q.checks,F,G,H),F;case"array":{if(!Array.isArray(F))return X();let $=F.map((V,Y)=>{let L=R(Q.item,V,[...G,Y],H);return L.drop?void 0:L.value}),{minItems:M,maxItems:A}=Q.checks??{};if(M!==void 0&&F.length<M)H.push({path:G,code:"minItems",message:`expected at least ${M} items, got ${F.length}`,params:{limit:M}});if(A!==void 0&&F.length>A)H.push({path:G,code:"maxItems",message:`expected at most ${A} items, got ${F.length}`,params:{limit:A}});return $}case"object":{if(typeof F!=="object"||F===null||Array.isArray(F))return X();let $=F,M={};for(let[A,V]of Object.entries(Q.shape)){let Y=R(V,$[A],[...G,A],H);if(!Y.drop)M[A]=Y.value}if(Q.unknownKeys)for(let A of Object.keys($)){if(Object.hasOwn(Q.shape,A)||$[A]===void 0)continue;if(Q.unknownKeys==="error"){H.push({path:[...G,A],code:"additionalProperties",message:"unknown key",params:{additionalProperty:A}});continue}N($[A],[...G,A],H,new Set),Object.defineProperty(M,A,{value:$[A],enumerable:!0,writable:!0,configurable:!0})}return M}case"union":{let $;for(let M of Q.members){let A=[],V=R(M,F,G,A);if(A.length===0)return V.drop?void 0:V.value;let Y=O(M,F);if(!$||Y>$.score)$={issues:A,score:Y}}H.push({path:G,code:"anyOf",message:`no matching variant; closest: ${$.issues.map(p).join("; ")}`,params:{closest:$.issues}});return}case"json":if(F===void 0)return X();return N(F,G,H,new Set),F;case"ref":return m(Q.cell,F,()=>{H.push({path:G,code:"type",message:"expected a finite tree, got a circular reference",params:{}});return},()=>R(I(Q.cell),F,G,H).value)}}function FB(B){let F=0;for(let G of B)F++;return F}function r(B,F,G,H){if(!B)return;let{minLength:Q,maxLength:X,format:$}=B;if(Q!==void 0||X!==void 0){let M=FB(F);if(Q!==void 0&&M<Q)H.push({path:G,code:"minLength",message:`expected at least ${Q} characters, got ${M}`,params:{limit:Q}});if(X!==void 0&&M>X)H.push({path:G,code:"maxLength",message:`expected at most ${X} characters, got ${M}`,params:{limit:X}})}if($){let M=!1;try{M=$.test(F)===!0}catch{}if(!M)H.push({path:G,code:"format",message:`expected a string in format "${$.name}"`,params:{format:$.name}})}}function GB(B,F,G,H){if(!B)return;let Q=(X,$,M,A)=>{if($===void 0||M($))return;H.push({path:G,code:X,message:`expected ${A} ${$}, got ${F}`,params:{limit:$}})};Q("minimum",B.minimum,(X)=>F>=X,"at least"),Q("exclusiveMinimum",B.exclusiveMinimum,(X)=>F>X,"more than"),Q("maximum",B.maximum,(X)=>F<=X,"at most"),Q("exclusiveMaximum",B.exclusiveMaximum,(X)=>F<X,"less than")}function N(B,F,G,H,Q=!0){let X=(M)=>{G.push({path:F,code:"type",message:`expected a JSON value, got ${M}`,params:{}})};switch(typeof B){case"undefined":case"string":case"boolean":return;case"number":if(!Number.isFinite(B))X(String(B));return;case"bigint":return X("a bigint");case"function":return X("a function");case"symbol":return X("a symbol")}if(B===null)return;let $=B;if(H.has($))return X("a circular reference");H.add($);try{let M=Q?$.toJSON:void 0;if(typeof M==="function"){let A;try{A=M.call($)}catch{return X("a toJSON that threw")}if(A===void 0)return X("a toJSON that returns undefined");return N(A,F,G,H,!1)}if(Array.isArray(B))B.forEach((A,V)=>N(A,[...F,V],G,H));else for(let[A,V]of Object.entries($))N(V,[...F,A],G,H)}finally{H.delete($)}}function D(B){return g(B)}function g(B){let F={toJSONSchema:()=>o(B),parse(G){let H=[],Q=R(B,G,[],H);if(H.length>0)throw Error(H.map(p).join("; "));return Q.drop?void 0:Q.value},safeParse(G){let H=[],Q=R(B,G,[],H);if(H.length>0)return{ok:!1,errors:H.map(p)};return{ok:!0,value:Q.drop?void 0:Q.value}},validate(G){let H=[],Q=R(B,G,[],H);if(H.length>0)return{ok:!1,issues:H};return{ok:!0,value:Q.drop?void 0:Q.value}},describe:(G)=>g({...B,description:G}),optional:()=>g({...B,optional:!0}),nullable:()=>g({...B,nullable:!0,optional:!1})};return k.set(F,B),F}function T(B){return{node:B,optional:!1,nullable:!1}}var h=["strip","error","passthrough"];class u extends Error{problems;constructor(B){super(`gemi/ai: s.fromJSONSchema cannot model this schema:
3
3
  ${B.map((F)=>`- ${F}`).join(`
4
4
  `)}`);this.name="JSONSchemaError",this.problems=B}}var HB=new Set(["title","$schema","$id","$comment","examples","default","deprecated","readOnly","writeOnly"]),E={string:["minLength","maxLength","format"],number:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],integer:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],boolean:[],object:["properties","required","additionalProperties"],array:["items","minItems","maxItems"]};function S(B){return typeof B==="object"&&B!==null&&!Array.isArray(B)}function y(B,F,G,H){let Q=(Z,_=G)=>{H.push(_?`${_}: ${Z}`:Z);return},X=(Z)=>G?`${G}.${Z}`:Z;if(!S(B))return Q("expected a schema object");let $=new Set(F.ignoreKeywords??[]),M=(Z)=>HB.has(Z)||Z.startsWith("x-")||$.has(Z),A=!1,V=B.type;if(Array.isArray(V)){let Z=V.filter((_)=>_!=="null");if(Z.length!==1)return Q(`type ${JSON.stringify(V)} is not supported; only one type, optionally with "null". Use anyOf for alternatives`,X("type"));A=Z.length<V.length,V=Z[0]}if(V!==void 0&&(typeof V!=="string"||!(V in E)))return Q(`type ${JSON.stringify(V)} is not supported; expected one of ${Object.keys(E).join(", ")}`,X("type"));let Y=new Set(["type","description","enum","const","anyOf",...V?E[V]:[]]),L=!1;for(let Z of Object.keys(B)){if(Y.has(Z)||M(Z))continue;L=!0;let _=Object.entries(E).find(([,z])=>z.includes(Z));Q(_&&_[0]!==V?`"${Z}" applies to type ${_[0]}, and this schema is ${V?`type ${V}`:"untyped"}`:`"${Z}" is not supported by s.fromJSONSchema`,X(Z))}if(L)return;if(B.description!==void 0&&typeof B.description!=="string")return Q("expected a string",X("description"));let w=B.description,U=(Z)=>({node:Z,optional:!1,nullable:A,...w?{description:w}:{}});if(B.anyOf!==void 0){if(V!==void 0||B.enum!==void 0||B.const!==void 0)return Q("anyOf cannot be combined with type, enum or const here",X("anyOf"));if(!Array.isArray(B.anyOf)||B.anyOf.length===0)return Q("expected a non-empty array",X("anyOf"));let Z=[],_=!1;if(B.anyOf.forEach((z,q)=>{if(S(z)&&z.type==="null"&&Object.keys(z).length===1){A=!0;return}let P=y(z,F,X(`anyOf[${q}]`),H);if(P)Z.push(P);else _=!0}),_)return;if(Z.length===0)return Q("anyOf has only null in it",X("anyOf"));if(Z.length===1){let z=Z[0];return{...z,nullable:z.nullable||A,...w?{description:w}:{}}}return U({kind:"union",members:Z})}if(B.const!==void 0){let Z=B.const;if(typeof Z!=="string"&&typeof Z!=="number"&&typeof Z!=="boolean")return Q("only a string, number or boolean const is supported",X("const"));if(V!==void 0&&typeof Z!==(V==="integer"?"number":V))return Q(`const ${JSON.stringify(Z)} is not of type ${V}`,X("const"));return U({kind:"literal",value:Z})}let W;if(V==="string"){if(W=QB(B,F,X,H),W===null)return}if(B.enum!==void 0){if(!Array.isArray(B.enum)||B.enum.length===0)return Q("expected a non-empty array",X("enum"));let Z=B.enum.filter((q)=>q!==null);if(Z.length<B.enum.length)A=!0;let _=Z.find((q)=>!(typeof q==="string"||typeof q==="number"||typeof q==="boolean")||V!==void 0&&typeof q!==(V==="integer"?"number":V));if(_!==void 0||Z.length===0)return Q(V?`every value must be of type ${V}${Z.length===0?", and there must be one":`; ${JSON.stringify(_)} is not`}`:"only strings, numbers and booleans are supported",X("enum"));if(Z.every((q)=>typeof q==="string"))return U({kind:"enum",values:[...new Set(Z)],...W?{checks:W}:{}});let z=[...new Set(Z)];if(z.length===1)return U({kind:"literal",value:z[0]});return U({kind:"union",members:z.map((q)=>T({kind:"literal",value:q}))})}switch(V){case void 0:return Q("a schema needs a type, an enum, a const or an anyOf");case"string":return U({kind:"string",...W?{checks:W}:{}});case"number":case"integer":{let Z=V==="integer"?{integer:!0}:{},_=!1;for(let z of E.number){let q=B[z];if(q===void 0)continue;if(typeof q!=="number"||!Number.isFinite(q)){Q("expected a number",X(z)),_=!0;continue}Z[z]=q}if(_)return;return U({kind:"number",...Object.keys(Z).length>0?{checks:Z}:{}})}case"boolean":return U({kind:"boolean"});case"array":{if(!S(B.items))return Q('an array needs "items" to be one schema (tuples are not supported)',X("items"));let Z={},_=!1;for(let q of["minItems","maxItems"]){let P=B[q];if(P===void 0)continue;if(typeof P!=="number"||!Number.isInteger(P)||P<0){Q("expected a non-negative integer",X(q)),_=!0;continue}Z[q]=P}let z=y(B.items,F,X("items"),H);if(!z||_)return;return U({kind:"array",item:z,...Object.keys(Z).length>0?{checks:Z}:{}})}case"object":{let Z=B.properties??{};if(!S(Z))return Q("expected an object",X("properties"));if(B.additionalProperties!==void 0&&B.additionalProperties!==!1)return Q("only false is supported; a record with arbitrary keys has no strict-mode form (use s.json())",X("additionalProperties"));let _=B.required??[];if(!Array.isArray(_)||!_.every((C)=>typeof C==="string"))return Q("expected an array of property names",X("required"));let z=_.filter((C)=>!Object.hasOwn(Z,C));if(z.length>0)return Q(`lists properties the schema doesn't have: ${z.join(", ")}`,X("required"));let q={},P=!1;for(let[C,c]of Object.entries(Z)){let f=y(c,F,X(`properties.${C}`),H);if(!f){P=!0;continue}q[C]=_.includes(C)?f:{...f,optional:!0}}if(P)return;let b=F.unknownKeys;return U({kind:"object",shape:q,...b==="error"||b==="passthrough"?{unknownKeys:b}:{}})}}return}function QB(B,F,G,H){let Q={},X=!1;for(let $ of["minLength","maxLength"]){let M=B[$];if(M===void 0)continue;if(typeof M!=="number"||!Number.isInteger(M)||M<0){H.push(`${G($)}: expected a non-negative integer`),X=!0;continue}Q[$]=M}if(B.format!==void 0){let $=B.format,M=typeof $==="string"?F.formats?.[$]:void 0;if(typeof $!=="string")H.push(`${G("format")}: expected a string`),X=!0;else if(!M||!Object.hasOwn(F.formats,$))H.push(`${G("format")}: unknown format ${JSON.stringify($)}; pass a check for it in the formats option`),X=!0;else Q.format={name:$,test:XB(M)}}if(X)return null;return Object.keys(Q).length>0?Q:void 0}function XB(B){if(B===!0)return()=>!0;if(B instanceof RegExp)return(F)=>{return B.lastIndex=0,B.test(F)};return B}var VB={string:()=>D(T({kind:"string"})),number:()=>D(T({kind:"number"})),boolean:()=>D(T({kind:"boolean"})),literal:(B)=>D(T({kind:"literal",value:B})),enum:(B)=>D(T({kind:"enum",values:B})),object:(B)=>D(T({kind:"object",shape:Object.fromEntries(Object.entries(B).map(([F,G])=>[F,x(G)]))})),array:(B)=>D(T({kind:"array",item:x(B)})),union:(B)=>D(T({kind:"union",members:B.map(x)})),json:()=>D(T({kind:"json"})),recursive:$B,fromJSONSchema:(B,F={})=>{let G=[];if(F.unknownKeys!==void 0&&!h.includes(F.unknownKeys))throw Error(`gemi/ai: s.fromJSONSchema's unknownKeys option must be one of ${h.map((Q)=>JSON.stringify(Q)).join(", ")}, got ${JSON.stringify(F.unknownKeys)}`);let H=y(B,F,"",G);if(!H||G.length>0)throw new u(G.length>0?G:["unreadable schema"]);return D(H)}};function AB(B){let F=k.get(B);if(F)return J(F.node);return j(B.toJSONSchema())}function j(B){if(!(B.$ref!==void 0||B.type!==void 0||B.enum!==void 0||B.const!==void 0||B.anyOf!==void 0||B.properties!==void 0||B.items!==void 0))return!1;for(let G of Object.values(B.properties??{}))if(!j(G))return!1;if(B.items&&!j(B.items))return!1;for(let G of B.anyOf??[])if(!j(G))return!1;for(let G of Object.values(B.$defs??{}))if(!j(G))return!1;return!0}function J(B,F=new Set){switch(B.kind){case"string":case"number":case"boolean":case"literal":case"enum":return!0;case"object":return Object.values(B.shape).every((G)=>J(G.node,F));case"array":return J(B.item.node,F);case"union":return B.members.every((G)=>J(G.node,F));case"json":return!1;case"ref":if(F.has(B.cell))return!0;return F.add(B.cell),J(I(B.cell).node,F)}}function v(B,F,G=new Set){let H=B.node;if(H.kind==="union")return H.members.some((Q)=>v(Q,F,G));if(H.kind!=="ref")return!1;if(H.cell===F)return!0;if(G.has(H.cell)||!H.cell.definition)return!1;return G.add(H.cell),v(H.cell.definition,F,G)}var ZB=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;function $B(B,F){if(typeof B!=="string"||!ZB.test(B))throw Error(`gemi/ai: s.recursive needs a name of letters, digits, "_" and "-" (starting with a letter or "_", at most 64), got ${JSON.stringify(B)}`);let G={name:B,active:new Set},H=()=>T({kind:"ref",cell:G}),Q=x(F(D(H())));if(Q.optional)throw Error(`gemi/ai: the recursive schema "${B}" is optional() as a whole; mark the places that use it optional instead`);if(v(Q,G))throw Error(`gemi/ai: the recursive schema "${B}" refers to itself outside any object or array, so it describes no finite value; nest \`self\` in an s.object(...) field or an s.array(...)`);return G.definition=Q,D(H())}
5
- export{MB as Tj,u as Uj,VB as Vj,AB as Wj};
5
+ export{MB as Uj,u as Vj,VB as Wj,AB as Xj};
6
6
 
7
- //# debugId=6AFD8696B0354F8064756E2164756E21
7
+ //# debugId=34FF549A62407D7D64756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "/**\n * The schema layer for tool inputs, tool outputs and structured final answers.\n *\n * Two things have to come out of one declaration: a TypeScript type, so\n * `execute(input)` is typed at the call site and the result is typed in the\n * browser, and a JSON Schema, because that is what the model is actually shown.\n * A phantom `Schema<T>` gives the first and nothing of the second, and a\n * hand-written JSON Schema next to a hand-written type gives both and lets them\n * drift. So the builder below is the single source, and `Infer` reads the type\n * back off it.\n *\n * Everything here is deliberately narrower than JSON Schema. OpenAI's strict\n * structured output only accepts a subset — every property listed in\n * `required`, `additionalProperties: false` on every object, no patterns, no\n * `oneOf` at the root — and a builder that cannot express the rejected parts is\n * better than one that lets you write a schema the API refuses at runtime.\n *\n * `json()` is the one deliberate hole in that, for the formats strict mode\n * cannot describe at all: a record with arbitrary keys, a mixed-type tuple. It\n * does not widen the subset — it turns strict mode off for the schema containing\n * it, which `supportsStrict` reads back off the tree so that no caller has to\n * remember to.\n *\n * A document that nests into itself is NOT one of those: strict mode accepts\n * `$defs` + `$ref`, and `recursive()` emits exactly that (#745).\n */\n\nexport type JSONSchema = {\n type?: string | string[];\n description?: string;\n enum?: readonly (string | number)[];\n const?: string | number | boolean;\n properties?: Record<string, JSONSchema>;\n required?: readonly string[];\n additionalProperties?: false;\n items?: JSONSchema;\n anyOf?: readonly JSONSchema[];\n /**\n * `#/$defs/<name>`, pointing at an entry of the root's `$defs`. Emitted by\n * `s.recursive` and never with a sibling keyword: OpenAI's strict mode\n * refuses `{ $ref, description }`, so a described or nullable reference is\n * wrapped in an `anyOf` instead.\n */\n $ref?: string;\n /** Only ever on the root: every `s.recursive` the schema reaches, by name. */\n $defs?: Record<string, JSONSchema>;\n};\n\n/**\n * Any value JSON can carry. The default output type of `json()`, and the\n * annotation an app reaches for when it hands one of those values on.\n */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\ndeclare const OUTPUT: unique symbol;\ndeclare const OPTIONAL: unique symbol;\n\n/**\n * `T` is carried in a phantom property rather than a real one: it exists only\n * for inference, and a real field would show up on the object the app writes.\n */\nexport interface Schema<T> {\n readonly [OUTPUT]: T;\n /** The JSON Schema handed to the provider. */\n toJSONSchema(): JSONSchema;\n /**\n * Parses a value coming back from the model. Tool arguments arrive as a JSON\n * string the model generated, so they are untrusted in exactly the way a\n * request body is: shape-checked before `execute` ever sees them.\n */\n parse(value: unknown): T;\n safeParse(value: unknown): { ok: true; value: T } | { ok: false; errors: string[] };\n}\n\n/**\n * A schema whose key may be left out of the object containing it.\n *\n * Marked with a property rather than detected from the output type, because\n * `undefined extends T` — the obvious test — is true of *everything* when\n * `strictNullChecks` is off, which is how this package and plenty of apps\n * compile. That version made every field of every tool optional, and did it\n * quietly: the JSON Schema was still right, so only the TypeScript types lied.\n */\nexport interface OptionalSchema<T> extends Schema<T | undefined> {\n readonly [OPTIONAL]: true;\n}\n\nexport type AnySchema = Schema<any>;\n\nexport type Infer<S> = S extends Schema<infer T> ? T : never;\n\n/**\n * Collapses a type into one flat object.\n *\n * `ShapeOutput` builds its result as an intersection of two mapped types, one\n * required and one optional, and that intersection is what every hover, every\n * error message and every type assertion would otherwise show. The difference\n * is between an app reading `{ command: string; cwd?: string }` and reading two\n * mapped types joined by an ampersand.\n *\n * It also drops `readonly`, which the mapped types copy from the shape literal\n * — `s.object({ ... })` infers that literal as `const` to keep the keys, and a\n * tool has no reason to receive an immutable input because of how its schema\n * was written down.\n */\ntype Flatten<T> = { -readonly [K in keyof T]: T[K] };\n\ntype ShapeOutput<S extends Record<string, AnySchema>> = Flatten<\n {\n [K in keyof S as S[K] extends OptionalSchema<any> ? never : K]: Infer<S[K]>;\n } & {\n [K in keyof S as S[K] extends OptionalSchema<any> ? K : never]?: Infer<S[K]>;\n }\n>;\n\ninterface SchemaBuilder<T> extends Schema<T> {\n /**\n * The description is not documentation — it is the only prose the model gets\n * about a field, and it is the difference between a tool that is called\n * correctly and one that is not.\n */\n describe(description: string): this;\n /**\n * Strict mode has no notion of an omitted key: every property must appear in\n * `required`. So `optional()` emits a nullable union and the model is told to\n * send `null`, while the TypeScript type says `| undefined` and the parsed\n * value drops the key. The asymmetry is the point — it is what lets an app\n * write ordinary optional fields against an API that forbids them.\n */\n optional(): OptionalSchemaBuilder<T>;\n nullable(): SchemaBuilder<T | null>;\n /**\n * `safeParse` with the failures as structured issues rather than sentences:\n * each one names the path it is about, a JSON Schema keyword as its `code`\n * and the keyword's argument in `params`. For an app that validates a value\n * against a schema itself — a form, a stored record — and wants to word or\n * group the problems per field. All failures are reported, not the first.\n */\n validate(value: unknown): { ok: true; value: T } | { ok: false; issues: SchemaIssue[] };\n}\n\n/**\n * One reason a value failed `validate`.\n *\n * `code` is the JSON Schema keyword the value broke — the same names Ajv puts\n * on its `keyword` — so a mapping written against one reads the other:\n *\n * - `required`: the key is missing (`path` ends in it).\n * - `type`: the wrong kind of value, an integer that isn't whole, or a value\n * that isn't JSON at all.\n * - `const`, `enum`: a literal or a choice that didn't match (`params.allowedValues`).\n * - `minLength`, `maxLength`, `minimum`, `maximum`, `exclusiveMinimum`,\n * `exclusiveMaximum`, `minItems`, `maxItems`: `params.limit` is the bound.\n * - `format`: `params.format` names the format the string failed.\n * - `anyOf`: no union member matched; `message` names the closest one's problems.\n * - `additionalProperties`: a key the object doesn't declare, reported only by\n * a schema built with `s.fromJSONSchema(schema, { unknownKeys: \"error\" })`.\n * `path` ends in the key (Ajv's `instancePath` stops at the object), and\n * `params.additionalProperty` is the key, as in Ajv.\n *\n * `message` is the sentence `safeParse` reports for it, without the path.\n */\nexport type SchemaIssueCode =\n | \"required\"\n | \"type\"\n | \"const\"\n | \"enum\"\n | \"anyOf\"\n | \"minLength\"\n | \"maxLength\"\n | \"minimum\"\n | \"maximum\"\n | \"exclusiveMinimum\"\n | \"exclusiveMaximum\"\n | \"minItems\"\n | \"maxItems\"\n | \"format\"\n | \"additionalProperties\";\n\nexport type SchemaIssue = {\n /** Keys and array indices from the root, `[]` for the root itself. */\n path: (string | number)[];\n code: SchemaIssueCode;\n message: string;\n params: Record<string, unknown>;\n};\n\ninterface OptionalSchemaBuilder<T> extends SchemaBuilder<T | undefined>, OptionalSchema<T> {}\n\n// --- the runtime ---------------------------------------------------------\n\n/**\n * What a builder actually is. `optional` and `nullable` are flags rather than\n * wrapper nodes so that `.nullable().optional()` cannot nest into something\n * whose emitted shape depends on which order they were called in.\n */\ntype Definition = {\n node: SchemaNode;\n description?: string;\n optional: boolean;\n nullable: boolean;\n};\n\n/**\n * The constraints `s.fromJSONSchema` can carry over from a JSON Schema. None of\n * the builders set them; they exist so that a schema read from data validates\n * what it says it does.\n *\n * They are CHECKED, NOT EMITTED as keywords. Strict structured output refuses\n * most of them (`minLength`, `maxLength`, `minimum` on Anthropic; any `format`\n * outside a short list on both), so the model is told them in the field's\n * description instead, and `parse` enforces them — a model that ignores the\n * prose gets an `invalid_tool_input` it can correct, the same as a wrong type.\n */\ntype StringChecks = {\n minLength?: number;\n maxLength?: number;\n format?: { name: string; test: (value: string) => boolean };\n};\n\ntype NumberChecks = {\n integer?: boolean;\n minimum?: number;\n maximum?: number;\n exclusiveMinimum?: number;\n exclusiveMaximum?: number;\n};\n\ntype ArrayChecks = { minItems?: number; maxItems?: number };\n\ntype SchemaNode =\n | { kind: \"string\"; checks?: StringChecks }\n | { kind: \"number\"; checks?: NumberChecks }\n | { kind: \"boolean\" }\n | { kind: \"literal\"; value: string | number | boolean }\n | { kind: \"enum\"; values: readonly string[]; checks?: StringChecks }\n /**\n * `unknownKeys` is what parsing does with a key `shape` doesn't declare:\n * absent is \"strip\", the default and the only thing the builders make. Only\n * `s.fromJSONSchema` sets the others. Emission ignores it: every object is\n * sent with `additionalProperties: false` either way.\n */\n | { kind: \"object\"; shape: Record<string, Definition>; unknownKeys?: \"error\" | \"passthrough\" }\n | { kind: \"array\"; item: Definition; checks?: ArrayChecks }\n | { kind: \"union\"; members: readonly Definition[] }\n /** Constrains nothing. The node strict mode has no spelling for. */\n | { kind: \"json\" }\n /**\n * A use of an `s.recursive` schema — its `self`, or the builder it returned.\n * Emitted as a `$ref` into the root's `$defs`, read by following the cell.\n */\n | { kind: \"ref\"; cell: RecursiveCell };\n\n/**\n * One `s.recursive` declaration. `definition` is filled in once the callback\n * returns; until then `self` is a reference to something that does not exist\n * yet, which is the whole trick.\n *\n * `active` is the set of values being read through this cell right now, the\n * cycle guard for a JavaScript value that contains itself (a tool output an app\n * built). Per cell rather than global, so that one value read through two\n * different recursive schemas in a row is not mistaken for a cycle.\n */\ntype RecursiveCell = {\n name: string;\n definition?: Definition;\n active: Set<object>;\n};\n\nfunction bodyOf(cell: RecursiveCell): Definition {\n if (!cell.definition) {\n throw new Error(\n `gemi/ai: the recursive schema \"${cell.name}\" was used before its definition returned; \\`self\\` can be nested into the schema, but not parsed or emitted inside the callback`,\n );\n }\n return cell.definition;\n}\n\ntype ParseResult = { ok: true; value: unknown } | { ok: false; errors: string[] };\n\ntype Path = (string | number)[];\n\n/** The public interface with the phantoms and the generic taken off. */\ninterface RuntimeSchema {\n toJSONSchema(): JSONSchema;\n parse(value: unknown): unknown;\n safeParse(value: unknown): ParseResult;\n validate(value: unknown): { ok: true; value: unknown } | { ok: false; issues: SchemaIssue[] };\n describe(description: string): RuntimeSchema;\n optional(): RuntimeSchema;\n nullable(): RuntimeSchema;\n}\n\n/**\n * Definitions hang off the builders here rather than on the builders\n * themselves: a property, however obscurely named, is a property an app can\n * see, serialise or accidentally depend on, and `Schema<T>` promises exactly\n * three methods.\n */\nconst definitions = new WeakMap<object, Definition>();\n\n/**\n * Whether `value` is a schema built with `s`. How `HttpRequest` tells an `s`\n * body schema from a map of rules (#711), without a property on the builder.\n */\nexport function isSchema(value: unknown): value is SchemaBuilder<unknown> {\n return typeof value === \"object\" && value !== null && definitions.has(value);\n}\n\nfunction definitionOf(schema: AnySchema): Definition {\n const definition = definitions.get(schema);\n if (!definition) {\n throw new Error(\"gemi/ai: expected a schema built with `s`, got a foreign object\");\n }\n return definition;\n}\n\n// --- emitting ------------------------------------------------------------\n\n/**\n * What one `toJSONSchema()` call collects on its way down: the `$defs` the\n * root will carry, and which cell owns each name in them.\n */\ntype EmitContext = {\n defs: Record<string, JSONSchema>;\n cells: Map<string, RecursiveCell>;\n};\n\n/**\n * The schema as the provider sees it: the tree, plus `$defs` at the root when\n * an `s.recursive` is anywhere in it.\n *\n * A recursive schema used AS the root is inlined there, and its `$defs` entry\n * is a second copy of the same body. Pointing the root at itself with\n * `\"$ref\": \"#\"` would be shorter, and OpenAI accepts it, but `#` means \"the\n * whole document\" — and a document that gets merged into (MCP's\n * `combineSchemas` adds properties to an input's root) would then demand the\n * merged-in fields at every level of the tree.\n */\nfunction emitRoot(definition: Definition): JSONSchema {\n const context: EmitContext = { defs: {}, cells: new Map() };\n let root = definition;\n if (definition.node.kind === \"ref\") {\n const body = bodyOf(definition.node.cell);\n root = {\n ...body,\n ...(definition.description ? { description: definition.description } : {}),\n optional: definition.optional,\n nullable: definition.nullable || body.nullable,\n };\n }\n const schema = emit(root, context);\n return Object.keys(context.defs).length > 0 ? { ...schema, $defs: context.defs } : schema;\n}\n\nfunction emit(definition: Definition, context: EmitContext): JSONSchema {\n // A `json` node already admits every value there is, null included, so\n // widening it would only add an `anyOf` for the model to read past — and one\n // whose second branch is a strictly narrower repeat of its first.\n const widen = (definition.optional || definition.nullable) && definition.node.kind !== \"json\";\n let body = allowNull(emitNode(definition.node, context), widen);\n const description = [definition.description, hint(definition.node)].filter(Boolean).join(\" \");\n // `$ref` takes no siblings under strict mode, so a described reference\n // becomes a one-member `anyOf` that can carry the description beside it.\n if (description && body.$ref !== undefined) body = { anyOf: [body] };\n return description ? { description, ...body } : body;\n}\n\n/**\n * The checks a node carries, in words, for the description — the one place a\n * strict-mode provider lets them through. See `StringChecks`.\n */\nfunction hint(node: SchemaNode): string {\n const said: string[] = [];\n if (node.kind === \"string\" || node.kind === \"enum\") {\n const checks = node.checks;\n if (checks?.format) said.push(`Format: ${checks.format.name}.`);\n if (checks?.minLength !== undefined) said.push(`At least ${checks.minLength} characters.`);\n if (checks?.maxLength !== undefined) said.push(`At most ${checks.maxLength} characters.`);\n } else if (node.kind === \"number\") {\n const checks = node.checks;\n if (checks?.minimum !== undefined) said.push(`Minimum ${checks.minimum}.`);\n if (checks?.exclusiveMinimum !== undefined) {\n said.push(`Greater than ${checks.exclusiveMinimum}.`);\n }\n if (checks?.maximum !== undefined) said.push(`Maximum ${checks.maximum}.`);\n if (checks?.exclusiveMaximum !== undefined) said.push(`Less than ${checks.exclusiveMaximum}.`);\n } else if (node.kind === \"array\") {\n const checks = node.checks;\n if (checks?.minItems !== undefined) said.push(`At least ${checks.minItems} items.`);\n if (checks?.maxItems !== undefined) said.push(`At most ${checks.maxItems} items.`);\n }\n // A `ref` says nothing of its own: its body's hints are in its `$defs` entry.\n return said.join(\" \");\n}\n\nfunction emitNode(node: SchemaNode, context: EmitContext): JSONSchema {\n switch (node.kind) {\n case \"string\":\n return { type: \"string\" };\n case \"number\":\n // `integer` is in the strict subset of every provider gemi speaks to.\n return { type: node.checks?.integer ? \"integer\" : \"number\" };\n case \"boolean\":\n return { type: \"boolean\" };\n // `const` rather than a one-member `enum`, because a boolean literal has no\n // `enum` form and one branch that works for all three beats two that\n // disagree about what a literal is.\n case \"literal\":\n return { type: typeof node.value, const: node.value };\n case \"enum\":\n return { type: \"string\", enum: node.values };\n case \"array\":\n return { type: \"array\", items: emit(node.item, context) };\n case \"object\":\n return {\n type: \"object\",\n properties: Object.fromEntries(\n Object.entries(node.shape).map(([key, child]) => [key, emit(child, context)]),\n ),\n // Every declared property, optional ones included. This is the whole of\n // strict mode's bargain: the model is never allowed to omit a key, so\n // \"may be absent\" has to be spelled as \"may be null\" instead.\n required: Object.keys(node.shape),\n additionalProperties: false,\n };\n case \"union\":\n return { anyOf: node.members.map((member) => emit(member, context)) };\n // The empty schema, which is JSON Schema's own way of saying \"any value\" —\n // no `type` listing all seven, which reads as a constraint the model then\n // has to check itself. What the field actually is gets said in\n // `description`, the one channel a model reads either way.\n case \"json\":\n return {};\n case \"ref\": {\n const { cell } = node;\n const owner = context.cells.get(cell.name);\n if (owner && owner !== cell) {\n throw new Error(\n `gemi/ai: two different recursive schemas are named \"${cell.name}\" in one schema; give each s.recursive(...) its own name`,\n );\n }\n if (!owner) {\n // Claimed BEFORE the body is emitted: the body refers to itself, and\n // that inner reference has to find the name taken and stop here.\n context.cells.set(cell.name, cell);\n context.defs[cell.name] = {};\n context.defs[cell.name] = emit(bodyOf(cell), context);\n }\n return { $ref: `#/$defs/${cell.name}` };\n }\n }\n}\n\n/**\n * Widens a schema to admit `null` — for a `nullable()` field, and for the null\n * an `optional()` field tells the model to send in place of omitting the key.\n */\nfunction allowNull(base: JSONSchema, on: boolean): JSONSchema {\n if (!on) return base;\n // A union is already a list of alternatives; appending to it is flatter than\n // nesting an `anyOf` inside an `anyOf`, and reads the same to the model.\n if (base.anyOf) return { ...base, anyOf: [...base.anyOf, { type: \"null\" }] };\n // `enum` and `const` cannot carry the null themselves — `enum` here is\n // strings and numbers by declaration — so those get wrapped rather than\n // widened.\n if (base.enum || base.const !== undefined) return { anyOf: [base, { type: \"null\" }] };\n if (typeof base.type === \"string\") return { ...base, type: [base.type, \"null\"] };\n return { anyOf: [base, { type: \"null\" }] };\n}\n\n// --- parsing -------------------------------------------------------------\n\nfunction typeName(value: unknown): string {\n if (value === null) return \"null\";\n if (Array.isArray(value)) return \"array\";\n return typeof value;\n}\n\n/**\n * What the value looked like. For a literal or an enum the *type* is usually\n * right and the value is wrong, and \"expected \\\"refund\\\", got string\" tells\n * whoever is reading the failed tool call nothing they did not know.\n */\nfunction saw(node: SchemaNode, value: unknown): string {\n if (typeof value === \"number\" && !Number.isFinite(value)) return String(value);\n if (node.kind === \"literal\" || node.kind === \"enum\") {\n const primitive =\n typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n if (primitive) return JSON.stringify(value);\n }\n return typeName(value);\n}\n\nfunction wanted(definition: Definition): string {\n const node = definition.node;\n const base = (() => {\n switch (node.kind) {\n case \"number\":\n return node.checks?.integer ? \"integer\" : \"number\";\n case \"string\":\n case \"boolean\":\n return node.kind;\n case \"literal\":\n return JSON.stringify(node.value);\n case \"enum\":\n return `one of ${node.values.map((v) => JSON.stringify(v)).join(\" | \")}`;\n case \"array\":\n return \"array\";\n case \"object\":\n return \"object\";\n case \"union\":\n return \"one of the variants\";\n case \"json\":\n return \"a JSON value\";\n case \"ref\":\n return wanted({ ...bodyOf(node.cell), optional: false, nullable: false });\n }\n })();\n return definition.optional || definition.nullable ? `${base} or null` : base;\n}\n\n/** `orders[2].total` — keys joined with dots, indices in brackets. */\nfunction formatPath(path: Path): string {\n let out = \"\";\n for (const segment of path) {\n out += typeof segment === \"number\" ? `[${segment}]` : out ? `.${segment}` : segment;\n }\n return out;\n}\n\n/** `orders[2].total: ` — empty at the root, where a prefix would be noise. */\nfunction at(path: Path): string {\n const text = formatPath(path);\n return text ? `${text}: ` : \"\";\n}\n\n/** The sentence `safeParse` reports for an issue. */\nfunction render(issue: SchemaIssue): string {\n return `${at(issue.path)}${issue.message}`;\n}\n\n/**\n * How well a value matches, used only to pick which union variant to blame.\n * A literal or an enum hit counts for far more than an ordinary field, because\n * that is what a discriminated union turns on: the variant whose `kind` matched\n * is the one the model meant, whatever else it got wrong.\n */\nfunction score(definition: Definition, value: unknown): number {\n if (value === null || value === undefined) {\n return definition.optional || definition.nullable ? 1 : 0;\n }\n const node = definition.node;\n switch (node.kind) {\n case \"string\":\n return typeof value === \"string\" ? 1 : 0;\n case \"number\":\n return typeof value === \"number\" ? 1 : 0;\n case \"boolean\":\n return typeof value === \"boolean\" ? 1 : 0;\n case \"literal\":\n return value === node.value ? 10 : 0;\n case \"enum\":\n return typeof value === \"string\" && node.values.includes(value) ? 10 : 0;\n case \"array\":\n return Array.isArray(value) ? 1 : 0;\n case \"object\": {\n if (typeof value !== \"object\" || Array.isArray(value)) return 0;\n const source = value as Record<string, unknown>;\n let total = 1;\n for (const [key, child] of Object.entries(node.shape)) {\n total += score(child, source[key]);\n }\n return total;\n }\n case \"union\":\n return node.members.reduce((best, member) => Math.max(best, score(member, value)), 0);\n // Matches, because it matches everything — but at the score of a plain\n // scalar, so a sibling variant that pinned its discriminant still wins the\n // blame.\n //\n // Reached only when no member parsed, which for a `json` member means the\n // value is not JSON at all: a function, a bigint, a cycle. Then this is\n // what makes the report name the reason the value was refused rather than\n // the discriminant of a variant the model was never aiming at.\n case \"json\":\n return 1;\n case \"ref\":\n return through(\n node.cell,\n value,\n () => 1,\n () => score(bodyOf(node.cell), value),\n );\n }\n}\n\n/**\n * Runs `walk` with `value` marked as being read through `cell`, or `cycle` when\n * it already is. A value can only meet the same cell again further down by\n * containing itself — `s.recursive` refuses a body that reaches `self` without\n * an object or array in between — so this is exactly the cycle guard, and a\n * value that merely appears twice side by side is read twice.\n */\nfunction through<R>(cell: RecursiveCell, value: unknown, cycle: () => R, walk: () => R): R {\n if (typeof value !== \"object\" || value === null) return walk();\n if (cell.active.has(value)) return cycle();\n cell.active.add(value);\n try {\n return walk();\n } finally {\n cell.active.delete(value);\n }\n}\n\n/** `drop` is a key that should not appear in the parsed object at all. */\ntype Reading = { drop: boolean; value: unknown };\n\nfunction read(definition: Definition, value: unknown, path: Path, issues: SchemaIssue[]): Reading {\n // `optional` is checked before `nullable`, so a schema that is both treats\n // null as \"absent\". They are not distinguishable on the wire: strict mode\n // gives the model one spelling for \"nothing\", and pretending otherwise would\n // mean `.nullable().optional()` silently kept a key the type says is\n // optional. What that trades away is the ability to say \"present and null\" on\n // a field that may also be absent — a distinction no model can express here.\n if (definition.optional && (value === null || value === undefined)) {\n return { drop: true, value: undefined };\n }\n if (definition.nullable && value === null) return { drop: false, value: null };\n return { drop: false, value: readNode(definition, value, path, issues) };\n}\n\nfunction readNode(\n definition: Definition,\n value: unknown,\n path: Path,\n issues: SchemaIssue[],\n): unknown {\n const node = definition.node;\n const fail = () => {\n const code: SchemaIssueCode =\n value === undefined\n ? \"required\"\n : node.kind === \"literal\"\n ? \"const\"\n : node.kind === \"enum\" && typeof value === \"string\"\n ? \"enum\"\n : \"type\";\n const params =\n code === \"const\"\n ? { allowedValue: (node as { value: unknown }).value }\n : code === \"enum\"\n ? { allowedValues: (node as { values: readonly string[] }).values }\n : {};\n issues.push({\n path,\n code,\n message: `expected ${wanted(definition)}, got ${saw(node, value)}`,\n params,\n });\n return undefined;\n };\n\n switch (node.kind) {\n case \"string\":\n if (typeof value !== \"string\") return fail();\n checkString(node.checks, value, path, issues);\n return value;\n case \"number\":\n // NaN and Infinity do not survive `JSON.stringify`, so a tool that\n // returns one produces a body the provider cannot be sent.\n if (typeof value !== \"number\" || !Number.isFinite(value)) return fail();\n if (node.checks?.integer && !Number.isInteger(value)) return fail();\n checkNumber(node.checks, value, path, issues);\n return value;\n case \"boolean\":\n return typeof value === \"boolean\" ? value : fail();\n case \"literal\":\n return value === node.value ? value : fail();\n case \"enum\":\n if (typeof value !== \"string\" || !node.values.includes(value)) return fail();\n checkString(node.checks, value, path, issues);\n return value;\n case \"array\": {\n if (!Array.isArray(value)) return fail();\n const items = value.map((item, index) => {\n const element = read(node.item, item, [...path, index], issues);\n return element.drop ? undefined : element.value;\n });\n const { minItems, maxItems } = node.checks ?? {};\n if (minItems !== undefined && value.length < minItems) {\n issues.push({\n path,\n code: \"minItems\",\n message: `expected at least ${minItems} items, got ${value.length}`,\n params: { limit: minItems },\n });\n }\n if (maxItems !== undefined && value.length > maxItems) {\n issues.push({\n path,\n code: \"maxItems\",\n message: `expected at most ${maxItems} items, got ${value.length}`,\n params: { limit: maxItems },\n });\n }\n return items;\n }\n case \"object\": {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return fail();\n const source = value as Record<string, unknown>;\n const output: Record<string, unknown> = {};\n for (const [key, child] of Object.entries(node.shape)) {\n const element = read(child, source[key], [...path, key], issues);\n if (!element.drop) output[key] = element.value;\n }\n // By default unknown keys are DROPPED, not rejected. `additionalProperties:\n // false` has already told the model not to send them, so one arriving\n // anyway is a slip rather than an attack, and failing a whole tool call\n // over a stray field costs a turn to fix nothing. Dropping is also what\n // keeps `execute` from ever seeing a field its input type says cannot be\n // there.\n //\n // A schema read from data can ask otherwise (#753): a form submission\n // with a field the form doesn't have is a bot or a stale page, and\n // dropping it loses what the visitor typed without telling them.\n if (node.unknownKeys) {\n for (const key of Object.keys(source)) {\n // `undefined` is absent, the same as for `required`: JSON cannot\n // carry it, and `JSON.stringify` leaves the key out.\n if (Object.hasOwn(node.shape, key) || source[key] === undefined) continue;\n if (node.unknownKeys === \"error\") {\n issues.push({\n path: [...path, key],\n code: \"additionalProperties\",\n message: \"unknown key\",\n params: { additionalProperty: key },\n });\n continue;\n }\n // Kept as it came, checked only for being JSON — there is no schema\n // to read it with. Defined rather than assigned, so that a\n // `__proto__` key from `JSON.parse` stays a key instead of setting\n // the output's prototype.\n checkJson(source[key], [...path, key], issues, new Set());\n Object.defineProperty(output, key, {\n value: source[key],\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n }\n return output;\n }\n case \"union\": {\n let best: { issues: SchemaIssue[]; score: number } | undefined;\n for (const member of node.members) {\n const attempt: SchemaIssue[] = [];\n const element = read(member, value, path, attempt);\n if (attempt.length === 0) return element.drop ? undefined : element.value;\n const points = score(member, value);\n if (!best || points > best.score) best = { issues: attempt, score: points };\n }\n // \"no match\" is useless when one field of a five-field variant was wrong.\n // Naming the closest variant and why it stopped is the difference between\n // a debuggable bad tool call and a shrug.\n issues.push({\n path,\n code: \"anyOf\",\n message: `no matching variant; closest: ${best!.issues.map(render).join(\"; \")}`,\n params: { closest: best!.issues },\n });\n return undefined;\n }\n // Passed through by reference, not rebuilt. Two reasons beyond the obvious\n // one: a rebuild would turn a `Date` into `{}` by copying own properties\n // that a `toJSON` was going to replace anyway, and the agent loop signs the\n // *parsed* input and later verifies the signature against it — a parse that\n // is exactly the identity cannot disagree with itself.\n case \"json\":\n if (value === undefined) return fail();\n checkJson(value, path, issues, new Set());\n return value;\n // The reference's own `optional`/`nullable` were settled by `read` above;\n // the body's are its own business, settled by the `read` below.\n case \"ref\":\n return through(\n node.cell,\n value,\n () => {\n issues.push({\n path,\n code: \"type\",\n message: \"expected a finite tree, got a circular reference\",\n params: {},\n });\n return undefined;\n },\n () => read(bodyOf(node.cell), value, path, issues).value,\n );\n }\n}\n\n/**\n * Length in code points, not UTF-16 units — what JSON Schema (and Ajv) count,\n * so an emoji is one character against a `maxLength` either way.\n */\nfunction length(value: string): number {\n let count = 0;\n for (const _ of value) count++;\n return count;\n}\n\nfunction checkString(\n checks: StringChecks | undefined,\n value: string,\n path: Path,\n issues: SchemaIssue[],\n): void {\n if (!checks) return;\n const { minLength, maxLength, format } = checks;\n if (minLength !== undefined || maxLength !== undefined) {\n const size = length(value);\n if (minLength !== undefined && size < minLength) {\n issues.push({\n path,\n code: \"minLength\",\n message: `expected at least ${minLength} characters, got ${size}`,\n params: { limit: minLength },\n });\n }\n if (maxLength !== undefined && size > maxLength) {\n issues.push({\n path,\n code: \"maxLength\",\n message: `expected at most ${maxLength} characters, got ${size}`,\n params: { limit: maxLength },\n });\n }\n }\n if (format) {\n let ok = false;\n try {\n ok = format.test(value) === true;\n } catch {\n // A check that throws has not said yes.\n }\n if (!ok) {\n issues.push({\n path,\n code: \"format\",\n message: `expected a string in format \"${format.name}\"`,\n params: { format: format.name },\n });\n }\n }\n}\n\nfunction checkNumber(\n checks: NumberChecks | undefined,\n value: number,\n path: Path,\n issues: SchemaIssue[],\n): void {\n if (!checks) return;\n const bound = (\n code: SchemaIssueCode,\n limit: number | undefined,\n passes: (limit: number) => boolean,\n words: string,\n ) => {\n if (limit === undefined || passes(limit)) return;\n issues.push({\n path,\n code,\n message: `expected ${words} ${limit}, got ${value}`,\n params: { limit },\n });\n };\n bound(\"minimum\", checks.minimum, (limit) => value >= limit, \"at least\");\n bound(\"exclusiveMinimum\", checks.exclusiveMinimum, (limit) => value > limit, \"more than\");\n bound(\"maximum\", checks.maximum, (limit) => value <= limit, \"at most\");\n bound(\"exclusiveMaximum\", checks.exclusiveMaximum, (limit) => value < limit, \"less than\");\n}\n\n/**\n * Checks that a value is JSON, which is the only check a `json()` node makes.\n *\n * Tool arguments arrive through `JSON.parse`, so this never fires on model\n * input. It fires on a tool *output* or a structured answer an app built, where\n * a `bigint` or a cycle throws inside `JSON.stringify` and a function or a\n * `symbol` is dropped without a word — one turn later, with the provider's\n * request body to debug instead of the value.\n *\n * `undefined` and non-plain objects are deliberately allowed below the root:\n * `JSON.stringify` drops an `undefined` property, writes `null` for an\n * `undefined` element, and calls `toJSON` where there is one. Those are JSON's\n * own answers, and rejecting a `Date` to catch a `Map` is a bad trade.\n *\n * `toJSON` is honoured rather than assumed harmless: the walk checks what it\n * returns and never the object behind it, because that is all `JSON.stringify`\n * will look at.\n */\nfunction checkJson(\n value: unknown,\n path: Path,\n issues: SchemaIssue[],\n seen: Set<object>,\n // False for the value a `toJSON` just returned: `JSON.stringify` applies\n // `toJSON` once per position, and re-applying it is how a pair of them\n // returning each other became an infinite loop.\n applyToJSON = true,\n): void {\n const reject = (what: string) => {\n issues.push({ path, code: \"type\", message: `expected a JSON value, got ${what}`, params: {} });\n };\n\n switch (typeof value) {\n case \"undefined\":\n case \"string\":\n case \"boolean\":\n return;\n case \"number\":\n if (!Number.isFinite(value)) reject(String(value));\n return;\n case \"bigint\":\n return reject(\"a bigint\");\n case \"function\":\n return reject(\"a function\");\n case \"symbol\":\n return reject(\"a symbol\");\n }\n\n if (value === null) return;\n const object = value as object;\n\n // The cycle guard comes FIRST, above `toJSON`, and that ordering is the whole\n // of it: a `toJSON` is arbitrary code that can hand back another object with a\n // `toJSON` of its own, so two of them returning each other is a cycle that\n // `seen` catches and an identity test cannot. Below the guard, that pair hung\n // `safeParse` forever — and a `toJSON` returning a fresh object each time threw\n // `RangeError` out of a function documented to return `{ ok: false, errors }`.\n if (seen.has(object)) return reject(\"a circular reference\");\n seen.add(object);\n try {\n // `JSON.stringify` asks `toJSON` what to write and never looks at the object\n // itself, so that answer is what has to be checked. Without this the walk\n // descended into the wrapper's own fields and refused values `stringify`\n // serializes without complaint — a `toJSON` returning a string off a `bigint`\n // field being the archetype, since writing a `toJSON` is exactly what one\n // does about a field JSON cannot carry. `Date` passed only by having no own\n // enumerable properties to trip over.\n const toJSON = applyToJSON ? (object as { toJSON?: unknown }).toJSON : undefined;\n if (typeof toJSON === \"function\") {\n let replaced: unknown;\n try {\n replaced = (toJSON as (key?: string) => unknown).call(object);\n } catch {\n return reject(\"a toJSON that threw\");\n }\n // `JSON.stringify` applies `toJSON` once per value position, not until it\n // stops changing, so the replacement is checked with it switched off here\n // — its nested values get their own.\n if (replaced === undefined) return reject(\"a toJSON that returns undefined\");\n return checkJson(replaced, path, issues, seen, false);\n }\n if (Array.isArray(value)) {\n value.forEach((item, index) => checkJson(item, [...path, index], issues, seen));\n } else {\n for (const [key, child] of Object.entries(object)) {\n checkJson(child, [...path, key], issues, seen);\n }\n }\n } finally {\n // Removed rather than left in: `seen` is the path currently being walked, and\n // keeping it would call the same object appearing twice side by side — which\n // `JSON.stringify` writes out twice quite happily — a cycle. In a `finally`\n // so the `toJSON` returns above cannot leave it marked.\n seen.delete(object);\n }\n}\n\n/**\n * The one cast in this file, and the reason it has to exist: `OUTPUT` and\n * `OPTIONAL` are `declare const` unique symbols. They have no runtime\n * counterpart — they are inference channels — so no object that can actually be\n * constructed satisfies `Schema<T>` structurally. Funnelling every builder\n * through here means the lie is told once, in one place, and everything else in\n * the module is checked against the real declarations.\n */\nfunction make<T>(definition: Definition): SchemaBuilder<T> {\n return build(definition) as unknown as SchemaBuilder<T>;\n}\n\n/**\n * Builders are immutable: `describe`, `optional` and `nullable` each build a\n * fresh one from a copied definition. Mutating in place is the obvious\n * implementation and it is wrong — `const id = s.string()` reused in two\n * objects, described in one of them, would carry that description into the\n * other, and the only symptom is a model being told the wrong thing about a\n * field somewhere else.\n */\nfunction build(definition: Definition): RuntimeSchema {\n const runtime: RuntimeSchema = {\n toJSONSchema: () => emitRoot(definition),\n parse(value) {\n const issues: SchemaIssue[] = [];\n const result = read(definition, value, [], issues);\n if (issues.length > 0) throw new Error(issues.map(render).join(\"; \"));\n return result.drop ? undefined : result.value;\n },\n safeParse(value) {\n const issues: SchemaIssue[] = [];\n const result = read(definition, value, [], issues);\n if (issues.length > 0) return { ok: false, errors: issues.map(render) };\n return { ok: true, value: result.drop ? undefined : result.value };\n },\n validate(value) {\n const issues: SchemaIssue[] = [];\n const result = read(definition, value, [], issues);\n if (issues.length > 0) return { ok: false, issues };\n return { ok: true, value: result.drop ? undefined : result.value };\n },\n describe: (description) => build({ ...definition, description }),\n optional: () => build({ ...definition, optional: true }),\n // Clearing `optional` is not tidiness. `nullable()` returns a\n // `SchemaBuilder`, not an `OptionalSchemaBuilder`, so the key it describes\n // is required again in `ShapeOutput` — and a parse that still dropped it\n // would hand back an object missing a key its own type declares.\n nullable: () => build({ ...definition, nullable: true, optional: false }),\n };\n definitions.set(runtime, definition);\n return runtime;\n}\n\nfunction leaf(node: SchemaNode): Definition {\n return { node, optional: false, nullable: false };\n}\n\n// --- reading a JSON Schema ---------------------------------------------------\n\n/**\n * How `s.fromJSONSchema` checks a `format`. `true` accepts any string (a format\n * that is only a hint, like `markdown`); a `RegExp` or a function decides.\n */\nexport type JSONSchemaFormat = true | RegExp | ((value: string) => boolean);\n\nexport type FromJSONSchemaOptions = {\n /**\n * The formats the schema may name. A `format` not listed here is refused, not\n * ignored: gemi ships no format checks of its own, and a format that quietly\n * checked nothing would be a constraint that only looks enforced.\n */\n formats?: Record<string, JSONSchemaFormat>;\n /**\n * Keywords to skip as annotations, on top of the ones always skipped:\n * `title`, `$schema`, `$id`, `$comment`, `examples`, `default`,\n * `deprecated`, `readOnly`, `writeOnly`, and every `x-` keyword.\n */\n ignoreKeywords?: readonly string[];\n /**\n * What `parse`, `safeParse` and `validate` do with a key an object of the\n * schema doesn't declare, at every depth:\n *\n * - `\"strip\"` (the default): drop it from the parsed value, silently.\n * - `\"error\"`: fail with an `additionalProperties` issue whose `path` ends in\n * the key and whose `params.additionalProperty` is the key.\n * - `\"passthrough\"`: keep it in the parsed value as it came (it is only\n * checked for being JSON).\n *\n * Every object is closed in `s`, so this applies whether or not the object\n * says `additionalProperties: false`, and the emitted schema still says\n * `additionalProperties: false` (strict mode requires it). It applies to\n * this schema's objects only: an `s.object` it is nested into keeps\n * stripping.\n */\n unknownKeys?: \"strip\" | \"error\" | \"passthrough\";\n};\n\nconst UNKNOWN_KEYS = [\"strip\", \"error\", \"passthrough\"] as const;\n\n/**\n * Thrown by `s.fromJSONSchema` for a schema outside the subset `s` models.\n * `problems` lists every one found, each starting with the path into the\n * schema (`properties.price.type: ...`), so a schema written by a user or a\n * model can be sent back with all of them at once.\n */\nexport class JSONSchemaError extends Error {\n readonly problems: string[];\n constructor(problems: string[]) {\n super(\n `gemi/ai: s.fromJSONSchema cannot model this schema:\\n${problems.map((p) => `- ${p}`).join(\"\\n\")}`,\n );\n this.name = \"JSONSchemaError\";\n this.problems = problems;\n }\n}\n\nconst ANNOTATIONS = new Set([\n \"title\",\n \"$schema\",\n \"$id\",\n \"$comment\",\n \"examples\",\n \"default\",\n \"deprecated\",\n \"readOnly\",\n \"writeOnly\",\n]);\n\n/** The keywords each type may carry, beyond `type`, `description`, `enum` and `const`. */\nconst KEYWORDS: Record<string, readonly string[]> = {\n string: [\"minLength\", \"maxLength\", \"format\"],\n number: [\"minimum\", \"maximum\", \"exclusiveMinimum\", \"exclusiveMaximum\"],\n integer: [\"minimum\", \"maximum\", \"exclusiveMinimum\", \"exclusiveMaximum\"],\n boolean: [],\n object: [\"properties\", \"required\", \"additionalProperties\"],\n array: [\"items\", \"minItems\", \"maxItems\"],\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Reads a JSON Schema into a definition, collecting every problem rather than\n * stopping at the first. Returns `undefined` where a node could not be read;\n * the caller throws once the walk is done.\n */\nfunction fromJSON(\n schema: unknown,\n options: FromJSONSchemaOptions,\n where: string,\n problems: string[],\n): Definition | undefined {\n const problem = (message: string, at = where) => {\n problems.push(at ? `${at}: ${message}` : message);\n return undefined;\n };\n const child = (key: string) => (where ? `${where}.${key}` : key);\n if (!isPlainObject(schema)) return problem(\"expected a schema object\");\n\n const ignored = new Set(options.ignoreKeywords ?? []);\n const skip = (key: string) => ANNOTATIONS.has(key) || key.startsWith(\"x-\") || ignored.has(key);\n\n // `type: [T, \"null\"]`, `enum` with a null in it and an `anyOf` with a\n // `{ type: \"null\" }` member all mean the same: T, nullable.\n let nullable = false;\n let type = schema.type;\n if (Array.isArray(type)) {\n const rest = type.filter((t) => t !== \"null\");\n if (rest.length !== 1) {\n return problem(\n `type ${JSON.stringify(type)} is not supported; only one type, optionally with \"null\". Use anyOf for alternatives`,\n child(\"type\"),\n );\n }\n nullable = rest.length < type.length;\n type = rest[0];\n }\n if (type !== undefined && (typeof type !== \"string\" || !(type in KEYWORDS))) {\n return problem(\n `type ${JSON.stringify(type)} is not supported; expected one of ${Object.keys(KEYWORDS).join(\", \")}`,\n child(\"type\"),\n );\n }\n\n const allowed = new Set([\n \"type\",\n \"description\",\n \"enum\",\n \"const\",\n \"anyOf\",\n ...(type ? KEYWORDS[type as string] : []),\n ]);\n let unknown = false;\n for (const key of Object.keys(schema)) {\n if (allowed.has(key) || skip(key)) continue;\n unknown = true;\n const owner = Object.entries(KEYWORDS).find(([, keys]) => keys.includes(key));\n problem(\n owner && owner[0] !== type\n ? `\"${key}\" applies to type ${owner[0]}, and this schema is ${type ? `type ${type}` : \"untyped\"}`\n : `\"${key}\" is not supported by s.fromJSONSchema`,\n child(key),\n );\n }\n if (unknown) return undefined;\n\n if (schema.description !== undefined && typeof schema.description !== \"string\") {\n return problem(\"expected a string\", child(\"description\"));\n }\n const description = schema.description as string | undefined;\n const finish = (node: SchemaNode): Definition => ({\n node,\n optional: false,\n nullable,\n ...(description ? { description } : {}),\n });\n\n if (schema.anyOf !== undefined) {\n if (type !== undefined || schema.enum !== undefined || schema.const !== undefined) {\n return problem(\"anyOf cannot be combined with type, enum or const here\", child(\"anyOf\"));\n }\n if (!Array.isArray(schema.anyOf) || schema.anyOf.length === 0) {\n return problem(\"expected a non-empty array\", child(\"anyOf\"));\n }\n const members: Definition[] = [];\n let failed = false;\n schema.anyOf.forEach((member, index) => {\n if (isPlainObject(member) && member.type === \"null\" && Object.keys(member).length === 1) {\n nullable = true;\n return;\n }\n const read = fromJSON(member, options, child(`anyOf[${index}]`), problems);\n if (read) members.push(read);\n else failed = true;\n });\n if (failed) return undefined;\n if (members.length === 0) return problem(\"anyOf has only null in it\", child(\"anyOf\"));\n if (members.length === 1) {\n const only = members[0]!;\n return {\n ...only,\n nullable: only.nullable || nullable,\n ...(description ? { description } : {}),\n };\n }\n return finish({ kind: \"union\", members });\n }\n\n if (schema.const !== undefined) {\n const value = schema.const;\n if (typeof value !== \"string\" && typeof value !== \"number\" && typeof value !== \"boolean\") {\n return problem(\"only a string, number or boolean const is supported\", child(\"const\"));\n }\n if (type !== undefined && typeof value !== (type === \"integer\" ? \"number\" : type)) {\n return problem(`const ${JSON.stringify(value)} is not of type ${type}`, child(\"const\"));\n }\n return finish({ kind: \"literal\", value });\n }\n\n let stringChecks: StringChecks | undefined;\n if (type === \"string\") {\n stringChecks = readStringChecks(schema, options, child, problems);\n if (stringChecks === null) return undefined;\n }\n\n if (schema.enum !== undefined) {\n if (!Array.isArray(schema.enum) || schema.enum.length === 0) {\n return problem(\"expected a non-empty array\", child(\"enum\"));\n }\n const values = schema.enum.filter((value) => value !== null);\n if (values.length < schema.enum.length) nullable = true;\n const bad = values.find(\n (value) =>\n !(typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") ||\n (type !== undefined && typeof value !== (type === \"integer\" ? \"number\" : type)),\n );\n if (bad !== undefined || values.length === 0) {\n return problem(\n type\n ? `every value must be of type ${type}${values.length === 0 ? \", and there must be one\" : `; ${JSON.stringify(bad)} is not`}`\n : \"only strings, numbers and booleans are supported\",\n child(\"enum\"),\n );\n }\n if (values.every((value) => typeof value === \"string\")) {\n return finish({\n kind: \"enum\",\n values: [...new Set(values as string[])],\n ...(stringChecks ? { checks: stringChecks } : {}),\n });\n }\n const literals = [...new Set(values as (string | number | boolean)[])];\n if (literals.length === 1) return finish({ kind: \"literal\", value: literals[0]! });\n return finish({\n kind: \"union\",\n members: literals.map((value) => leaf({ kind: \"literal\", value })),\n });\n }\n\n switch (type) {\n case undefined:\n return problem(\"a schema needs a type, an enum, a const or an anyOf\");\n case \"string\":\n return finish({ kind: \"string\", ...(stringChecks ? { checks: stringChecks } : {}) });\n case \"number\":\n case \"integer\": {\n const checks: NumberChecks = type === \"integer\" ? { integer: true } : {};\n let failed = false;\n for (const key of KEYWORDS.number!) {\n const value = schema[key];\n if (value === undefined) continue;\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n problem(\"expected a number\", child(key));\n failed = true;\n continue;\n }\n checks[key as \"minimum\"] = value;\n }\n if (failed) return undefined;\n return finish({ kind: \"number\", ...(Object.keys(checks).length > 0 ? { checks } : {}) });\n }\n case \"boolean\":\n return finish({ kind: \"boolean\" });\n case \"array\": {\n if (!isPlainObject(schema.items)) {\n return problem(\n 'an array needs \"items\" to be one schema (tuples are not supported)',\n child(\"items\"),\n );\n }\n const checks: ArrayChecks = {};\n let failed = false;\n for (const key of [\"minItems\", \"maxItems\"] as const) {\n const value = schema[key];\n if (value === undefined) continue;\n if (typeof value !== \"number\" || !Number.isInteger(value) || value < 0) {\n problem(\"expected a non-negative integer\", child(key));\n failed = true;\n continue;\n }\n checks[key] = value;\n }\n const item = fromJSON(schema.items, options, child(\"items\"), problems);\n if (!item || failed) return undefined;\n return finish({ kind: \"array\", item, ...(Object.keys(checks).length > 0 ? { checks } : {}) });\n }\n case \"object\": {\n const properties = schema.properties ?? {};\n if (!isPlainObject(properties)) return problem(\"expected an object\", child(\"properties\"));\n if (schema.additionalProperties !== undefined && schema.additionalProperties !== false) {\n return problem(\n \"only false is supported; a record with arbitrary keys has no strict-mode form (use s.json())\",\n child(\"additionalProperties\"),\n );\n }\n const required = schema.required ?? [];\n if (!Array.isArray(required) || !required.every((key) => typeof key === \"string\")) {\n return problem(\"expected an array of property names\", child(\"required\"));\n }\n const missing = required.filter((key) => !Object.hasOwn(properties, key));\n if (missing.length > 0) {\n return problem(\n `lists properties the schema doesn't have: ${missing.join(\", \")}`,\n child(\"required\"),\n );\n }\n const shape: Record<string, Definition> = {};\n let failed = false;\n for (const [key, value] of Object.entries(properties)) {\n const read = fromJSON(value, options, child(`properties.${key}`), problems);\n if (!read) {\n failed = true;\n continue;\n }\n // Not in `required` is \"may be left out\", which is `optional()`: the\n // model is told to send null, and a parse drops the key.\n shape[key] = required.includes(key) ? read : { ...read, optional: true };\n }\n if (failed) return undefined;\n const unknownKeys = options.unknownKeys;\n return finish({\n kind: \"object\",\n shape,\n ...(unknownKeys === \"error\" || unknownKeys === \"passthrough\" ? { unknownKeys } : {}),\n });\n }\n }\n return undefined;\n}\n\n/** `null` when a problem was reported. */\nfunction readStringChecks(\n schema: Record<string, unknown>,\n options: FromJSONSchemaOptions,\n child: (key: string) => string,\n problems: string[],\n): StringChecks | undefined | null {\n const checks: StringChecks = {};\n let failed = false;\n for (const key of [\"minLength\", \"maxLength\"] as const) {\n const value = schema[key];\n if (value === undefined) continue;\n if (typeof value !== \"number\" || !Number.isInteger(value) || value < 0) {\n problems.push(`${child(key)}: expected a non-negative integer`);\n failed = true;\n continue;\n }\n checks[key] = value;\n }\n if (schema.format !== undefined) {\n const name = schema.format;\n const format = typeof name === \"string\" ? options.formats?.[name] : undefined;\n if (typeof name !== \"string\") {\n problems.push(`${child(\"format\")}: expected a string`);\n failed = true;\n } else if (!format || !Object.hasOwn(options.formats!, name)) {\n problems.push(\n `${child(\"format\")}: unknown format ${JSON.stringify(name)}; pass a check for it in the formats option`,\n );\n failed = true;\n } else {\n checks.format = { name, test: formatTest(format) };\n }\n }\n if (failed) return null;\n return Object.keys(checks).length > 0 ? checks : undefined;\n}\n\nfunction formatTest(format: JSONSchemaFormat): (value: string) => boolean {\n if (format === true) return () => true;\n if (format instanceof RegExp) {\n // A `g` or `y` regex keeps `lastIndex` between calls, so the second value\n // tested would start halfway in. Reset it every time.\n return (value) => {\n format.lastIndex = 0;\n return format.test(value);\n };\n }\n return format;\n}\n\nexport const s: {\n string(): SchemaBuilder<string>;\n number(): SchemaBuilder<number>;\n boolean(): SchemaBuilder<boolean>;\n literal<const L extends string | number | boolean>(value: L): SchemaBuilder<L>;\n /** Modelled as a JSON Schema `enum`, which strict mode does support. */\n enum<const L extends readonly [string, ...string[]]>(values: L): SchemaBuilder<L[number]>;\n object<const S extends Record<string, AnySchema>>(shape: S): SchemaBuilder<ShapeOutput<S>>;\n array<const S extends AnySchema>(item: S): SchemaBuilder<Infer<S>[]>;\n /**\n * `anyOf` of object schemas, discriminated by a literal member. Left in\n * because tool outputs are frequently a success/failure pair, and modelling\n * that as one object with everything optional is worse for the model.\n */\n union<const S extends readonly [AnySchema, AnySchema, ...AnySchema[]]>(\n members: S,\n ): SchemaBuilder<Infer<S[number]>>;\n /**\n * Any JSON value, constrained by nothing — for a format the rest of this\n * builder cannot describe: a record with arbitrary keys, a mixed-type tuple,\n * a document whose shape is not known in advance. (A document that nests\n * into itself has a strict spelling: `s.recursive`.)\n *\n * A schema containing one cannot be sent under strict mode, so a tool whose\n * input uses it is sent with `strict: false` automatically. That is not an\n * option to pass anywhere; it is read back off the schema by\n * `supportsStrict`. The rest of the tool is unaffected, and so is streaming:\n * partial arguments are parsed from the raw text, never through a schema.\n *\n * `T` is an assertion, not a guarantee. The emitted schema constrains\n * nothing, so nothing checks the model's output against `T` — only that it is\n * JSON. Validate it in `execute` and hand the model back an error it can fix,\n * the way it would any other bad argument. `describe()` is where you tell it\n * the format; with no constraints to read, that prose is all it gets.\n *\n * TWO CALL SIGNATURES, NOT A DEFAULT TYPE PARAMETER, and that is load-bearing.\n * Written `json<T = JsonValue>()`, the default lost to the surrounding\n * contextual type in the position this is actually used: `s.object`'s shape is\n * constrained to `Record<string, AnySchema>` — `Schema<any>` — which supplies\n * `any` as an inference candidate, and a candidate beats a default. So\n * `s.object({ definition: s.json() })` inferred `{ definition: any }`, which is\n * type checking switched off around exactly the field this exists for, and the\n * opposite of what the default was written to prevent. An overload with no type\n * parameter has nothing to infer, so `s.json()` is `JsonValue` wherever it is\n * written.\n *\n * `ai:generate-client` maps it to the native `JSONValue` and says nothing about\n * it. `JsonValue` is a union of every JSON shape, so it used to reach the\n * generator's \"a union that is not told apart by one string member\" warning —\n * true, and a misdescription of a field that is free-form on purpose. The\n * extractor recognises it now.\n */\n json(): SchemaBuilder<JsonValue>;\n json<T>(): SchemaBuilder<T>;\n /**\n * A schema that contains itself — a tree of UI nodes, a comment thread, a\n * folder listing — and stays strict-mode safe, unlike `s.json()`.\n *\n * ```ts\n * type Node = { tag: string; text?: string; children: Node[] };\n *\n * const node = s.recursive<Node>(\"Node\", (self) =>\n * s.object({\n * tag: s.enum([\"section\", \"heading\", \"text\"]),\n * text: s.string().optional(),\n * children: s.array(self),\n * }),\n * );\n * const output = s.object({ title: s.string(), root: node });\n * ```\n *\n * Emitted the way OpenAI's strict structured output spells recursion: the\n * body once under the root's `$defs[name]`, and `{ \"$ref\": \"#/$defs/<name>\" }`\n * wherever it is used. Used as the root itself, the body is also inlined at\n * the root, since a tool's parameters and an agent's output must be an\n * object there. `parse`, `safeParse` and `validate` follow the reference to\n * any depth.\n *\n * `T` has to be written out: TypeScript cannot infer a type from a value\n * that mentions itself. The callback's schema is checked against it, so a\n * field the type has and the schema lacks (or the reverse) is a type error.\n *\n * Rules, each an error when the schema is built:\n *\n * - `name` is the `$defs` key: letters, digits, `_` and `-`. Two different\n * recursive schemas in one tool or output need different names.\n * - `self` must be nested inside an `s.object` field or an `s.array` — a\n * body that is `self` again through a union describes no finite value.\n * - The body cannot be `optional()`; make the uses optional instead\n * (`children: s.array(self).optional()`, `next: self.optional()`).\n *\n * Strict mode limits the rest as usual: every node of the body is in the\n * strict subset or the whole schema is sent non-strict (`supportsStrict`).\n */\n recursive<T>(name: string, define: (self: SchemaBuilder<T>) => Schema<T>): SchemaBuilder<T>;\n /**\n * A schema read from a JSON Schema at runtime — for a shape that comes from\n * data rather than code, like a collection whose items a user defined.\n *\n * Only the subset `s` itself models is accepted, so the result stays\n * strict-mode safe and can be a tool's `inputSchema` like any other:\n *\n * - `type`: `string`, `number`, `integer`, `boolean`, `object`, `array`,\n * or one of them with `\"null\"` (`[\"string\", \"null\"]`).\n * - `enum` (strings become `s.enum`, numbers and booleans a union of\n * literals; a `null` in it makes the field nullable), `const`, `anyOf`.\n * - strings: `minLength`, `maxLength`, `format` (checked with\n * `options.formats`). Numbers: `minimum`, `maximum`, `exclusiveMinimum`,\n * `exclusiveMaximum`. Arrays: `items` (one schema), `minItems`, `maxItems`.\n * - objects: `properties`, `required`, `additionalProperties: false`. A\n * property not in `required` is `optional()`.\n * - `description`; annotations (`title`, `default`, `examples`, `$schema`,\n * `x-*`, … and `options.ignoreKeywords`) are skipped.\n *\n * Anything else — `pattern`, `oneOf`, `allOf`, `$ref`, a tuple, an open\n * `additionalProperties`, an unknown `format` — throws a `JSONSchemaError`\n * listing every problem with its path.\n *\n * The length, range, item-count and format constraints are enforced by\n * `parse`/`safeParse`/`validate` and told to the model in the field's\n * description, because strict structured output does not accept them as\n * keywords. By default an unknown key in an object is dropped from the\n * parsed value rather than reported; pass `unknownKeys: \"error\"` to report\n * it as an `additionalProperties` issue (as Ajv does), or `\"passthrough\"`\n * to keep it.\n *\n * The output type is `JsonValue` (or the `T` you assert). Validate a value\n * with `.validate(value)` for per-path issues, or `.safeParse(value)`.\n */\n fromJSONSchema(schema: unknown, options?: FromJSONSchemaOptions): SchemaBuilder<JsonValue>;\n fromJSONSchema<T>(schema: unknown, options?: FromJSONSchemaOptions): SchemaBuilder<T>;\n} = {\n string: () => make<string>(leaf({ kind: \"string\" })),\n number: () => make<number>(leaf({ kind: \"number\" })),\n boolean: () => make<boolean>(leaf({ kind: \"boolean\" })),\n literal: (value) => make<typeof value>(leaf({ kind: \"literal\", value })),\n enum: (values) => make<(typeof values)[number]>(leaf({ kind: \"enum\", values })),\n object: (shape) =>\n make<ShapeOutput<typeof shape>>(\n leaf({\n kind: \"object\",\n shape: Object.fromEntries(\n Object.entries(shape).map(([key, child]) => [key, definitionOf(child)]),\n ),\n }),\n ),\n array: (item) => make<Infer<typeof item>[]>(leaf({ kind: \"array\", item: definitionOf(item) })),\n // A union is legal wherever a property is, but not as the root of a tool's\n // input or an agent's structured output: the provider wants an object there.\n // `s` cannot know where a schema will be used, so `AgentTool.create` and\n // `Agent.create` are what reject it at the root.\n union: (members) =>\n make<Infer<(typeof members)[number]>>(\n leaf({ kind: \"union\", members: members.map(definitionOf) }),\n ),\n json: <T>() => make<T>(leaf({ kind: \"json\" })),\n recursive,\n fromJSONSchema: <T>(schema: unknown, options: FromJSONSchemaOptions = {}) => {\n const problems: string[] = [];\n if (\n options.unknownKeys !== undefined &&\n !(UNKNOWN_KEYS as readonly unknown[]).includes(options.unknownKeys)\n ) {\n throw new Error(\n `gemi/ai: s.fromJSONSchema's unknownKeys option must be one of ${UNKNOWN_KEYS.map((v) => JSON.stringify(v)).join(\", \")}, got ${JSON.stringify(options.unknownKeys)}`,\n );\n }\n const definition = fromJSON(schema, options, \"\", problems);\n if (!definition || problems.length > 0) {\n throw new JSONSchemaError(problems.length > 0 ? problems : [\"unreadable schema\"]);\n }\n return make<T>(definition);\n },\n};\n\n/**\n * Whether a schema can be sent under a provider's strict mode.\n *\n * False exactly when a `json()` node is somewhere inside it. Strict mode's\n * bargain is that every node constrains its value; an unconstrained one has no\n * spelling there, and sending it anyway is a 400 naming a path.\n *\n * Derived from the tree rather than declared alongside it, because the two\n * would drift: a field added to a tool's input a year from now would need\n * whoever adds it to know that a flag somewhere else describes it. Adding the\n * field is the whole of turning strict off.\n */\nexport function supportsStrict(schema: AnySchema): boolean {\n const definition = definitions.get(schema);\n if (definition) return strictNode(definition.node);\n // A schema built by hand rather than with `s`: `questionSchema` in\n // `ai/Agent.ts`, and the merged one `services/mcp` casts together.\n //\n // Answering `true` here was wrong, and not harmlessly. `McpRegistry`'s\n // `combineSchemas` spreads `meta.input.toJSONSchema()` into its own object,\n // so an `s.json()` field an app declared on an `mcp` route survives into the\n // emitted schema while the *tree* that would have reported it is discarded.\n // Every MCP-projected tool was therefore sent `strict: true` with an empty\n // subschema inside it — a 400 on every turn, from the one path this function\n // exists to get right.\n //\n // So the emitted schema is read instead. It is the same question asked of the\n // artifact rather than the source, which is the only thing a foreign schema\n // has to offer.\n return strictJSONSchema(schema.toJSONSchema());\n}\n\n/**\n * Whether an already-emitted JSON Schema constrains every value it describes.\n *\n * Only for schemas with no definition tree. It answers a narrower question than\n * `strictNode` — it cannot see optionality or a builder's intent, just whether\n * some node says nothing about its value — but that is exactly the property\n * strict mode rejects, and it is visible in the artifact.\n */\nfunction strictJSONSchema(schema: JSONSchema): boolean {\n // `description` is prose, not a constraint. A node carrying only that — which\n // is what `s.json().describe(...)` emits — says nothing about its value.\n const constrained =\n schema.$ref !== undefined ||\n schema.type !== undefined ||\n schema.enum !== undefined ||\n schema.const !== undefined ||\n schema.anyOf !== undefined ||\n schema.properties !== undefined ||\n schema.items !== undefined;\n if (!constrained) return false;\n\n for (const child of Object.values(schema.properties ?? {})) {\n if (!strictJSONSchema(child)) return false;\n }\n if (schema.items && !strictJSONSchema(schema.items)) return false;\n for (const member of schema.anyOf ?? []) {\n if (!strictJSONSchema(member)) return false;\n }\n // A `$ref` is answered for by the `$defs` entry it points at, which is\n // checked here once rather than followed — following it is a cycle.\n for (const definition of Object.values(schema.$defs ?? {})) {\n if (!strictJSONSchema(definition)) return false;\n }\n return true;\n}\n\n/**\n * Enumerated rather than defaulted, so that a node kind added later cannot\n * inherit \"strict\" by omission — which is the failure that shows up as a 400\n * from the provider rather than as a type error here.\n *\n * The one cycle in a definition tree is an `s.recursive` reaching itself, so\n * `seen` holds the cells already being answered for: a body that is strict\n * apart from its references to itself is strict.\n */\nfunction strictNode(node: SchemaNode, seen = new Set<RecursiveCell>()): boolean {\n switch (node.kind) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n case \"literal\":\n case \"enum\":\n return true;\n case \"object\":\n return Object.values(node.shape).every((child) => strictNode(child.node, seen));\n case \"array\":\n return strictNode(node.item.node, seen);\n case \"union\":\n return node.members.every((member) => strictNode(member.node, seen));\n case \"json\":\n return false;\n case \"ref\":\n if (seen.has(node.cell)) return true;\n seen.add(node.cell);\n return strictNode(bodyOf(node.cell).node, seen);\n }\n}\n\n/**\n * Whether `definition` can reach `cell` without an object property or an\n * array item in between — through a union member, or another recursive\n * schema's body. Such a schema describes no finite value (`Self = Self |\n * string` is just `string`), and reading one would recurse forever on a\n * primitive, where no object is there to catch the cycle with.\n */\nfunction reachesUnguarded(\n definition: Definition,\n cell: RecursiveCell,\n seen = new Set<RecursiveCell>(),\n): boolean {\n const node = definition.node;\n if (node.kind === \"union\") {\n return node.members.some((member) => reachesUnguarded(member, cell, seen));\n }\n if (node.kind !== \"ref\") return false;\n if (node.cell === cell) return true;\n if (seen.has(node.cell) || !node.cell.definition) return false;\n seen.add(node.cell);\n return reachesUnguarded(node.cell.definition, cell, seen);\n}\n\nconst RECURSIVE_NAME = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;\n\nfunction recursive<T>(\n name: string,\n define: (self: SchemaBuilder<T>) => Schema<T>,\n): SchemaBuilder<T> {\n if (typeof name !== \"string\" || !RECURSIVE_NAME.test(name)) {\n throw new Error(\n `gemi/ai: s.recursive needs a name of letters, digits, \"_\" and \"-\" (starting with a letter or \"_\", at most 64), got ${JSON.stringify(name)}`,\n );\n }\n const cell: RecursiveCell = { name, active: new Set() };\n const reference = (): Definition => leaf({ kind: \"ref\", cell });\n const body = definitionOf(define(make<T>(reference())));\n if (body.optional) {\n throw new Error(\n `gemi/ai: the recursive schema \"${name}\" is optional() as a whole; mark the places that use it optional instead`,\n );\n }\n if (reachesUnguarded(body, cell)) {\n throw new Error(\n `gemi/ai: the recursive schema \"${name}\" refers to itself outside any object or array, so it describes no finite value; nest \\`self\\` in an s.object(...) field or an s.array(...)`,\n );\n }\n cell.definition = body;\n return make<T>(reference());\n}\n"
6
6
  ],
7
7
  "mappings": ";AAmRA,SAAS,CAAM,CAAC,EAAiC,CAC/C,GAAI,CAAC,EAAK,WACR,MAAU,MACR,kCAAkC,EAAK,sIACzC,EAEF,OAAO,EAAK,WAwBd,IAAM,EAAc,IAAI,QAMjB,SAAS,EAAQ,CAAC,EAAiD,CACxE,OAAO,OAAO,IAAU,UAAY,IAAU,MAAQ,E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64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
2
  var j=globalThis.__GEMI_DICTIONARY_REGISTRY__??={registry:new Map,resolved:new Map,inFlight:new Map,renderThenables:new Map,order:[],warmed:new Map,activeLocale:null},{registry:W,resolved:Z,inFlight:V,renderThenables:I,order:E,warmed:X}=j;function N(q,x){return`${q}\x00${x}`}function D(q){if(W.has(q.id))return;W.set(q.id,q),E.push(q.id)}function H(){return E.length}function P(q,x){return Z.get(q)?.get(x)}function $(q,x,A){let z=Z.get(q);if(!z)z=new Map,Z.set(q,z);z.set(x,A)}function U(q,x){let A=P(q,x);if(A)return A;let z=N(q,x),C=V.get(z);if(C)return C;let B=W.get(q);if(!B)throw Error(`Unknown dictionary "${q}". A dictionary must be created with defineDictionary() and its module must have been evaluated before it is read.`);let J=B.load(x);if(!(J instanceof Promise))return $(q,x,J),J;let O=J.then((Q)=>{return $(q,x,Q),V.delete(z),Q},(Q)=>{throw V.delete(z),Q});return V.set(z,O),O}function K(q,x){let A=N(q,x),z=P(q,x),C=I.get(A);if(C&&!(C.degraded&&z))return C;if(z)return G(A,M(z,!C));let B=U(q,x);if(!(B instanceof Promise))return G(A,M(B,!0));let J=B.then((O)=>O,(O)=>{return console.error(`Failed to load dictionary ${q} for locale ${x}; rendering keys instead.`,O),J.degraded=!0,Y});return G(A,J)}function G(q,x){return I.set(q,x),x}function M(q,x){return Object.assign(Promise.resolve(q),{status:"fulfilled",value:q,inHand:x?q:void 0})}var Y={};async function S(q,x){let A=x??X.get(q)??0,z=E.slice(A);if(z.length===0)return;let C=await Promise.all(z.map(async(B)=>{try{return await U(B,_(B,q)),!0}catch{return!1}}));if(x===void 0){let B=C.indexOf(!1),J=B===-1?z.length:B;X.set(q,Math.max(X.get(q)??0,A+J))}}function _(q,x){if(x)return x;return W.get(q)?.locales[0]??x}function L(q,x){if(!q)return;for(let[A,z]of Object.entries(q))$(A,x,z)}function R(q){if(q)j.activeLocale=q}function w(){return j.activeLocale}if(typeof window<"u"){let q=window,x=([z,C,B])=>{$(z,C,B)},A=Array.isArray(q.__GEMI_DICT__)?q.__GEMI_DICT__:[];q.__GEMI_DICT__={push:x};for(let z of A)x(z)}function F(){W.clear(),Z.clear(),V.clear(),I.clear(),X.clear(),E.length=0,j.activeLocale=null}function f(){let q=new Set,x=[],A=[];return{use(z,C,B){let J=`${z} ${C}`;if(q.has(J))return;q.add(J);let O={id:z,locale:C,strings:B};if(x.length===0){A.push(O);return}for(let Q of x)Q(O)},onUse(z){x.push(z);while(A.length>0)z(A.shift())}}}
3
- export{D as Gl,H as Hl,U as Il,K as Jl,S as Kl,L as Ll,R as Ml,w as Nl,F as Ol,f as Pl};
3
+ export{D as Hl,H as Il,U as Jl,K as Kl,S as Ll,L as Ml,R as Nl,w as Ol,F as Pl,f as Ql};
4
4
 
5
- //# debugId=995726F999A2854D64756E2164756E21
5
+ //# debugId=046CD4EB4A4125BB64756E2164756E21
@@ -6,6 +6,6 @@
6
6
  "import type { LocaleStrings } from \"./dictionaryShape\";\n\n/**\n * Collects the dictionaries one SSR render actually read.\n *\n * Scoped per request by living in React context rather than in module state: a\n * streaming server has several renders in flight at once, so a module-level\n * collector would mix one page's dictionaries into another's payload. Context\n * is per render tree, which is exactly the boundary wanted, and it needs no\n * async-local storage to survive React's internal scheduling.\n *\n * Why stream these rather than put them in `__GEMI_DATA__`: that snapshot is\n * serialized before `renderToReadableStream` is even called, and which\n * dictionaries a page reads is only known once it has rendered. A suspended\n * segment reveals later still, long after the shell has flushed.\n *\n * The sink deliberately emits data, not markup — `streamQueryInjection` owns\n * script formatting and the `</script>`-safe encoding that goes with it.\n */\nexport interface DictionaryUse {\n id: string;\n locale: string;\n strings: LocaleStrings;\n}\n\nexport interface DictionarySink {\n /** Called during render, the first time a dictionary is read. */\n use(id: string, locale: string, strings: LocaleStrings): void;\n /** The response injector subscribes to receive uses as they happen. */\n onUse(cb: (use: DictionaryUse) => void): void;\n}\n\nexport function createDictionarySink(): DictionarySink {\n const seen = new Set<string>();\n const listeners: Array<(use: DictionaryUse) => void> = [];\n // Uses recorded before the injector subscribed — the render begins before the\n // response stream is wrapped.\n const pending: DictionaryUse[] = [];\n\n return {\n use(id, locale, strings) {\n const key = `${id} ${locale}`;\n if (seen.has(key)) return;\n seen.add(key);\n const entry: DictionaryUse = { id, locale, strings };\n if (listeners.length === 0) {\n pending.push(entry);\n return;\n }\n for (const listener of listeners) listener(entry);\n },\n onUse(cb) {\n listeners.push(cb);\n while (pending.length > 0) {\n cb(pending.shift()!);\n }\n },\n };\n}\n"
7
7
  ],
8
8
  "mappings": ";AA6FA,IAAM,EAAyB,WAFZ,+BAE+C,CAChE,SAAU,IAAI,IACd,SAAU,IAAI,IACd,SAAU,IAAI,IACd,gBAAiB,IAAI,IACrB,MAAO,CAAC,EACR,OAAQ,IAAI,IACZ,aAAc,IAChB,GAEQ,WAAU,WAAU,WAAU,kBAAiB,QAAO,UAAW,EAEzE,SAAS,CAAQ,CAAC,EAAY,EAAgB,CAC5C,MAAO,GAAG,QAAO,IAGZ,SAAS,CAAkB,CAAC,EAA6B,CAM9D,GAAI,EAAS,IAAI,EAAM,EAAE,EACvB,OAEF,EAAS,IAAI,EAAM,GAAI,CAAK,EAC5B,EAAM,KAAK,EAAM,EAAE,EAId,SAAS,CAA0B,EAAW,CACnD,OAAO,EAAM,OAGR,SAAS,CAAW,CACzB,EACA,EAC2B,CAC3B,OAAO,EAAS,IAAI,CAAE,GAAG,IAAI,CAAM,EAGrC,SAAS,CAAW,CAAC,EAAY,EAAgB,EAAwB,CACvE,IAAI,EAAW,EAAS,IAAI,CAAE,EAC9B,GAAI,CAAC,EACH,EAAW,IAAI,IACf,EAAS,IAAI,EAAI,CAAQ,EAE3B,EAAS,IAAI,EAAQ,CAAO,EAQvB,SAAS,CAAc,CAC5B,EACA,EACwC,CACxC,IAAM,EAAU,EAAY,EAAI,CAAM,EACtC,GAAI,EACF,OAAO,EAGT,IAAM,EAAM,EAAS,EAAI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