gemi 0.87.0 → 0.88.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/app/index.js +1 -1
  4. package/dist/auth/AuthController.d.ts +45 -3
  5. package/dist/auth/AuthController.d.ts.map +1 -1
  6. package/dist/auth/AuthManager.d.ts +42 -1
  7. package/dist/auth/AuthManager.d.ts.map +1 -1
  8. package/dist/auth/UserProvider.d.ts +18 -1
  9. package/dist/auth/UserProvider.d.ts.map +1 -1
  10. package/dist/auth/config.d.ts +109 -0
  11. package/dist/auth/config.d.ts.map +1 -1
  12. package/dist/auth/oneTimeCode.d.ts +99 -0
  13. package/dist/auth/oneTimeCode.d.ts.map +1 -0
  14. package/dist/auth/routes.d.ts +13 -0
  15. package/dist/auth/routes.d.ts.map +1 -1
  16. package/dist/auth/types.d.ts +8 -0
  17. package/dist/auth/types.d.ts.map +1 -1
  18. package/dist/bin/gemi.js +198 -39
  19. package/dist/bin/gemi.js.map +5 -4
  20. package/dist/bun/plugin.js +1 -1
  21. package/dist/bun/preload.js +1 -1
  22. package/dist/{chunk-3epp751c.js → chunk-0808z3mq.js} +2 -2
  23. package/dist/{chunk-3epp751c.js.map → chunk-0808z3mq.js.map} +1 -1
  24. package/dist/{chunk-q9g7g995.js → chunk-0efykzjy.js} +3 -3
  25. package/dist/{chunk-q9g7g995.js.map → chunk-0efykzjy.js.map} +1 -1
  26. package/dist/{chunk-tkhrvd30.js → chunk-16mnpn6c.js} +2 -2
  27. package/dist/{chunk-tkhrvd30.js.map → chunk-16mnpn6c.js.map} +1 -1
  28. package/dist/{chunk-r8ak7k9b.js → chunk-17nh5gfm.js} +2 -2
  29. package/dist/{chunk-r8ak7k9b.js.map → chunk-17nh5gfm.js.map} +1 -1
  30. package/dist/{chunk-m4fg0k5f.js → chunk-3ph0aj0x.js} +2 -2
  31. package/dist/{chunk-m4fg0k5f.js.map → chunk-3ph0aj0x.js.map} +1 -1
  32. package/dist/{chunk-h5mz3zdr.js → chunk-3rb5ht8v.js} +3 -3
  33. package/dist/{chunk-h5mz3zdr.js.map → chunk-3rb5ht8v.js.map} +1 -1
  34. package/dist/chunk-3w65ra1s.js +5 -0
  35. package/dist/{chunk-vme0xdf4.js.map → chunk-3w65ra1s.js.map} +1 -1
  36. package/dist/{chunk-70ha7xye.js → chunk-443dm19c.js} +2 -2
  37. package/dist/{chunk-70ha7xye.js.map → chunk-443dm19c.js.map} +1 -1
  38. package/dist/{chunk-41mz2fs2.js → chunk-49v5xq8q.js} +2 -2
  39. package/dist/{chunk-41mz2fs2.js.map → chunk-49v5xq8q.js.map} +1 -1
  40. package/dist/{chunk-hj93em1r.js → chunk-4v4v5wkh.js} +2 -2
  41. package/dist/{chunk-hj93em1r.js.map → chunk-4v4v5wkh.js.map} +1 -1
  42. package/dist/{chunk-9yd5d1ff.js → chunk-523t3bcz.js} +4 -4
  43. package/dist/{chunk-9yd5d1ff.js.map → chunk-523t3bcz.js.map} +1 -1
  44. package/dist/{chunk-xcqw162y.js → chunk-56p9a7nx.js} +3 -3
  45. package/dist/{chunk-xcqw162y.js.map → chunk-56p9a7nx.js.map} +1 -1
  46. package/dist/{chunk-4f48z676.js → chunk-61rs7kxf.js} +2 -2
  47. package/dist/{chunk-4f48z676.js.map → chunk-61rs7kxf.js.map} +1 -1
  48. package/dist/{chunk-zgy7jtcq.js → chunk-64z2zt41.js} +2 -2
  49. package/dist/{chunk-zgy7jtcq.js.map → chunk-64z2zt41.js.map} +1 -1
  50. package/dist/{chunk-2zsfntsf.js → chunk-6dyt8w27.js} +4 -4
  51. package/dist/{chunk-2zsfntsf.js.map → chunk-6dyt8w27.js.map} +1 -1
  52. package/dist/{chunk-f32t2eny.js → chunk-6rc6yec4.js} +3 -3
  53. package/dist/{chunk-f32t2eny.js.map → chunk-6rc6yec4.js.map} +1 -1
  54. package/dist/{chunk-bjd9wr4t.js → chunk-6s6fj97j.js} +2 -2
  55. package/dist/{chunk-bjd9wr4t.js.map → chunk-6s6fj97j.js.map} +1 -1
  56. package/dist/{chunk-ngqgm026.js → chunk-6tt3ynm7.js} +2 -2
  57. package/dist/{chunk-ngqgm026.js.map → chunk-6tt3ynm7.js.map} +1 -1
  58. package/dist/{chunk-brd6tb1s.js → chunk-6y62ccam.js} +3 -3
  59. package/dist/{chunk-brd6tb1s.js.map → chunk-6y62ccam.js.map} +1 -1
  60. package/dist/{chunk-f6qhsdsn.js → chunk-713fezaz.js} +2 -2
  61. package/dist/{chunk-f6qhsdsn.js.map → chunk-713fezaz.js.map} +1 -1
  62. package/dist/{chunk-27k2zsq8.js → chunk-78gs7xvn.js} +2 -2
  63. package/dist/{chunk-27k2zsq8.js.map → chunk-78gs7xvn.js.map} +1 -1
  64. package/dist/chunk-7awbkbbx.js +17 -0
  65. package/dist/{chunk-z61sdvb0.js.map → chunk-7awbkbbx.js.map} +14 -10
  66. package/dist/{chunk-4mynkrv4.js → chunk-7r78cdyd.js} +2 -2
  67. package/dist/{chunk-4mynkrv4.js.map → chunk-7r78cdyd.js.map} +1 -1
  68. package/dist/{chunk-fsad7g9c.js → chunk-8dpnghvk.js} +2 -2
  69. package/dist/{chunk-fsad7g9c.js.map → chunk-8dpnghvk.js.map} +1 -1
  70. package/dist/{chunk-mxmw42c1.js → chunk-8pesk2wm.js} +2 -2
  71. package/dist/{chunk-mxmw42c1.js.map → chunk-8pesk2wm.js.map} +1 -1
  72. package/dist/{chunk-tx51rqct.js → chunk-8r7xhy1g.js} +2 -2
  73. package/dist/{chunk-tx51rqct.js.map → chunk-8r7xhy1g.js.map} +1 -1
  74. package/dist/{chunk-c8bjqw07.js → chunk-8y08amzz.js} +2 -2
  75. package/dist/{chunk-c8bjqw07.js.map → chunk-8y08amzz.js.map} +1 -1
  76. package/dist/{chunk-ryj4wqcp.js → chunk-9c1zx81w.js} +2 -2
  77. package/dist/{chunk-ryj4wqcp.js.map → chunk-9c1zx81w.js.map} +1 -1
  78. package/dist/{chunk-3k2ykvez.js → chunk-ak3yy4za.js} +2 -2
  79. package/dist/{chunk-3k2ykvez.js.map → chunk-ak3yy4za.js.map} +1 -1
  80. package/dist/{chunk-08qvtx8v.js → chunk-bhzb8e5r.js} +2 -2
  81. package/dist/{chunk-08qvtx8v.js.map → chunk-bhzb8e5r.js.map} +1 -1
  82. package/dist/{chunk-vemwqxx2.js → chunk-bsbn7qtd.js} +2 -2
  83. package/dist/{chunk-vemwqxx2.js.map → chunk-bsbn7qtd.js.map} +1 -1
  84. package/dist/{chunk-grtmy031.js → chunk-d1r618e8.js} +1 -1
  85. package/dist/chunk-d1zt6sfj.js +5 -0
  86. package/dist/{chunk-p4125aj9.js.map → chunk-d1zt6sfj.js.map} +3 -6
  87. package/dist/{chunk-mjrxyvwr.js → chunk-d5h5v4rj.js} +2 -2
  88. package/dist/{chunk-mjrxyvwr.js.map → chunk-d5h5v4rj.js.map} +1 -1
  89. package/dist/{chunk-ma2zdn5s.js → chunk-e3fnjj0h.js} +2 -2
  90. package/dist/{chunk-ma2zdn5s.js.map → chunk-e3fnjj0h.js.map} +1 -1
  91. package/dist/{chunk-yr51wvkr.js → chunk-fkt43zw1.js} +2 -2
  92. package/dist/{chunk-yr51wvkr.js.map → chunk-fkt43zw1.js.map} +1 -1
  93. package/dist/{chunk-x74r8j5k.js → chunk-g2bsmw1m.js} +2 -2
  94. package/dist/{chunk-3bjj31n9.js.map → chunk-g2bsmw1m.js.map} +1 -1
  95. package/dist/{chunk-v36ey99b.js → chunk-gzfat1x1.js} +2 -2
  96. package/dist/{chunk-v36ey99b.js.map → chunk-gzfat1x1.js.map} +1 -1
  97. package/dist/{chunk-97bt619e.js → chunk-hnbj9jx2.js} +3 -3
  98. package/dist/{chunk-97bt619e.js.map → chunk-hnbj9jx2.js.map} +1 -1
  99. package/dist/{chunk-y3trr7xh.js → chunk-j0fgc58k.js} +2 -2
  100. package/dist/{chunk-y3trr7xh.js.map → chunk-j0fgc58k.js.map} +1 -1
  101. package/dist/{chunk-fev2yjmb.js → chunk-jfgjscq6.js} +2 -2
  102. package/dist/{chunk-fev2yjmb.js.map → chunk-jfgjscq6.js.map} +1 -1
  103. package/dist/{chunk-165mrqab.js → chunk-ngq4n2b3.js} +2 -2
  104. package/dist/{chunk-165mrqab.js.map → chunk-ngq4n2b3.js.map} +1 -1
  105. package/dist/{chunk-t70a927z.js → chunk-pqydkns8.js} +2 -2
  106. package/dist/{chunk-t70a927z.js.map → chunk-pqydkns8.js.map} +1 -1
  107. package/dist/{chunk-yd04n99w.js → chunk-pw95y0fx.js} +2 -2
  108. package/dist/{chunk-yd04n99w.js.map → chunk-pw95y0fx.js.map} +1 -1
  109. package/dist/{chunk-04ebkq8a.js → chunk-pwaftx6n.js} +3 -3
  110. package/dist/{chunk-04ebkq8a.js.map → chunk-pwaftx6n.js.map} +1 -1
  111. package/dist/{chunk-x02whwn3.js → chunk-q6ydpt33.js} +2 -2
  112. package/dist/{chunk-x02whwn3.js.map → chunk-q6ydpt33.js.map} +1 -1
  113. package/dist/{chunk-es6gxzyf.js → chunk-q77qf42t.js} +2 -2
  114. package/dist/{chunk-es6gxzyf.js.map → chunk-q77qf42t.js.map} +1 -1
  115. package/dist/{chunk-76ar9z69.js → chunk-r1sj312m.js} +2 -2
  116. package/dist/{chunk-76ar9z69.js.map → chunk-r1sj312m.js.map} +1 -1
  117. package/dist/{chunk-0w95nc15.js → chunk-r78aqvne.js} +2 -2
  118. package/dist/{chunk-0w95nc15.js.map → chunk-r78aqvne.js.map} +1 -1
  119. package/dist/{chunk-mdpm06cg.js → chunk-r9qzgvpx.js} +2 -2
  120. package/dist/{chunk-mdpm06cg.js.map → chunk-r9qzgvpx.js.map} +1 -1
  121. package/dist/{chunk-hp96c8hp.js → chunk-rhe7s1fm.js} +3 -3
  122. package/dist/{chunk-hp96c8hp.js.map → chunk-rhe7s1fm.js.map} +1 -1
  123. package/dist/{chunk-n9n3sqx5.js → chunk-rp0reqjn.js} +2 -2
  124. package/dist/{chunk-n9n3sqx5.js.map → chunk-rp0reqjn.js.map} +1 -1
  125. package/dist/{chunk-7g90me53.js → chunk-rw0t90pf.js} +2 -2
  126. package/dist/{chunk-7g90me53.js.map → chunk-rw0t90pf.js.map} +1 -1
  127. package/dist/{chunk-9zkgvggh.js → chunk-s72y1w84.js} +2 -2
  128. package/dist/{chunk-9zkgvggh.js.map → chunk-s72y1w84.js.map} +1 -1
  129. package/dist/{chunk-3bjj31n9.js → chunk-t93t317r.js} +2 -2
  130. package/dist/{chunk-x74r8j5k.js.map → chunk-t93t317r.js.map} +1 -1
  131. package/dist/{chunk-m0kbpywd.js → chunk-ttckhvew.js} +2 -2
  132. package/dist/{chunk-m0kbpywd.js.map → chunk-ttckhvew.js.map} +1 -1
  133. package/dist/{chunk-gsv1syg3.js → chunk-whjhrz97.js} +2 -2
  134. package/dist/{chunk-gsv1syg3.js.map → chunk-whjhrz97.js.map} +1 -1
  135. package/dist/chunk-x5ajfnrx.js +24 -0
  136. package/dist/{chunk-smtcmc20.js.map → chunk-x5ajfnrx.js.map} +6 -5
  137. package/dist/{chunk-ebbft1yj.js → chunk-x85x83pa.js} +1 -1
  138. package/dist/{chunk-tqzddk5e.js → chunk-xc90ycw2.js} +2 -2
  139. package/dist/{chunk-tqzddk5e.js.map → chunk-xc90ycw2.js.map} +1 -1
  140. package/dist/{chunk-w8cf1kqd.js → chunk-xqyx8kzr.js} +2 -2
  141. package/dist/{chunk-w8cf1kqd.js.map → chunk-xqyx8kzr.js.map} +2 -2
  142. package/dist/{chunk-x2ds4xaj.js → chunk-yafxbmy3.js} +1 -1
  143. package/dist/{chunk-71vjxehx.js → chunk-yc3n6zhr.js} +3 -3
  144. package/dist/{chunk-71vjxehx.js.map → chunk-yc3n6zhr.js.map} +1 -1
  145. package/dist/{chunk-rj81ysxm.js → chunk-zf8bgrnj.js} +2 -2
  146. package/dist/{chunk-rj81ysxm.js.map → chunk-zf8bgrnj.js.map} +1 -1
  147. package/dist/{chunk-0ms02b96.js → chunk-zn5bqe6m.js} +3 -3
  148. package/dist/{chunk-0ms02b96.js.map → chunk-zn5bqe6m.js.map} +1 -1
  149. package/dist/{chunk-7bynhyt1.js → chunk-ztzd90gp.js} +2 -2
  150. package/dist/{chunk-7bynhyt1.js.map → chunk-ztzd90gp.js.map} +1 -1
  151. package/dist/chunks/{ThemeProvider-D1kDfCwY.js → ThemeProvider-z_MW40tl.js} +126 -6
  152. package/dist/chunks/ThemeProvider-z_MW40tl.js.map +1 -0
  153. package/dist/client/ClientRouter.d.ts.map +1 -1
  154. package/dist/client/ClientRouterContext.d.ts.map +1 -1
  155. package/dist/client/ComponentContext.d.ts +8 -1
  156. package/dist/client/ComponentContext.d.ts.map +1 -1
  157. package/dist/client/MutationError.d.ts +4 -4
  158. package/dist/client/auth/useEmailCode.d.ts +36 -0
  159. package/dist/client/auth/useEmailCode.d.ts.map +1 -0
  160. package/dist/client/chunkLoadRecovery.d.ts +96 -0
  161. package/dist/client/chunkLoadRecovery.d.ts.map +1 -0
  162. package/dist/client/index.d.ts +4 -0
  163. package/dist/client/index.d.ts.map +1 -1
  164. package/dist/client/index.js +53 -4
  165. package/dist/client/index.js.map +1 -1
  166. package/dist/client/init.d.ts +9 -0
  167. package/dist/client/init.d.ts.map +1 -1
  168. package/dist/config/index.d.ts +12 -0
  169. package/dist/config/index.d.ts.map +1 -1
  170. package/dist/config/index.js +1 -1
  171. package/dist/config/index.js.map +2 -2
  172. package/dist/console/run.js +2 -2
  173. package/dist/console/run.js.map +1 -1
  174. package/dist/container/index.js +2 -2
  175. package/dist/container/index.js.map +1 -1
  176. package/dist/database/index.js +2 -2
  177. package/dist/database/index.js.map +1 -1
  178. package/dist/email/index.js +2 -2
  179. package/dist/email/index.js.map +1 -1
  180. package/dist/facades/index.js +2 -2
  181. package/dist/facades/index.js.map +1 -1
  182. package/dist/foundation/index.js +2 -2
  183. package/dist/foundation/index.js.map +1 -1
  184. package/dist/http/ApiRouter.d.ts +12 -1
  185. package/dist/http/ApiRouter.d.ts.map +1 -1
  186. package/dist/http/Error.d.ts +2 -2
  187. package/dist/http/index.js +2 -2
  188. package/dist/http/index.js.map +1 -1
  189. package/dist/i18n/dictionaryRuntime.js +2 -2
  190. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  191. package/dist/i18n/index.js +2 -2
  192. package/dist/i18n/index.js.map +1 -1
  193. package/dist/kernel/index.d.ts +2 -0
  194. package/dist/kernel/index.d.ts.map +1 -1
  195. package/dist/kernel/index.js +3 -3
  196. package/dist/kernel/index.js.map +2 -2
  197. package/dist/orm/index.js +3 -3
  198. package/dist/orm/index.js.map +1 -1
  199. package/dist/server/forwardedFor.d.ts +1 -1
  200. package/dist/server/index.js +2 -2
  201. package/dist/server/index.js.map +1 -1
  202. package/dist/server/staticAssetMiss.d.ts +7 -0
  203. package/dist/server/staticAssetMiss.d.ts.map +1 -1
  204. package/dist/services/index.d.ts +1 -1
  205. package/dist/services/index.d.ts.map +1 -1
  206. package/dist/services/index.js +3 -3
  207. package/dist/services/index.js.map +1 -1
  208. package/dist/services/queue/work.js +2 -2
  209. package/dist/services/queue/work.js.map +1 -1
  210. package/dist/services/rate-limiter/drivers/InMemoryRateLimiterDriver.d.ts +10 -1
  211. package/dist/services/rate-limiter/drivers/InMemoryRateLimiterDriver.d.ts.map +1 -1
  212. package/dist/services/router/createFlatApiRoutes.d.ts.map +1 -1
  213. package/dist/support/index.js +2 -2
  214. package/dist/support/index.js.map +1 -1
  215. package/dist/testing/index.js +1 -1
  216. package/package.json +1 -1
  217. package/dist/chunk-p4125aj9.js +0 -5
  218. package/dist/chunk-smtcmc20.js +0 -24
  219. package/dist/chunk-vme0xdf4.js +0 -5
  220. package/dist/chunk-z61sdvb0.js +0 -17
  221. package/dist/chunks/ThemeProvider-D1kDfCwY.js.map +0 -1
  222. /package/dist/{chunk-grtmy031.js.map → chunk-d1r618e8.js.map} +0 -0
  223. /package/dist/{chunk-ebbft1yj.js.map → chunk-x85x83pa.js.map} +0 -0
  224. /package/dist/{chunk-x2ds4xaj.js.map → chunk-yafxbmy3.js.map} +0 -0
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{fc as o}from"./chunk-q6ydpt33.js";import{gc as i}from"./chunk-bsbn7qtd.js";import{mg as t}from"./chunk-ttckhvew.js";import{tg as r}from"./chunk-e3fnjj0h.js";class n extends i{register(){this.app.singleton(r,()=>new r(t(o(),this.app.config.get("translation",{}))))}}
3
+ export{n as Wa};
4
+
5
+ //# debugId=D1094770C8BF842F64756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "import { ServiceProvider } from \"../support/ServiceProvider\";\nimport { withDefaults } from \"../support/withDefaults\";\nimport { Translator } from \"./Translator\";\nimport { translationConfigDefaults, type TranslationConfig } from \"./config\";\n\nexport class TranslationServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n Translator,\n () =>\n new Translator(\n withDefaults(\n translationConfigDefaults(),\n this.app.config.get<TranslationConfig>(\"translation\", {}),\n ),\n ),\n );\n }\n}\n"
6
6
  ],
7
7
  "mappings": ";sLAKO,AAAM,IAAmC,LAAgB,CAC9D,QAAQ,EAAG,CACT,KAAK,IAAI,UACP,EACA,IACE,IAAI,EACF,EACE,EAA0B,EAC1B,KAAK,IAAI,OAAO,IAAuB,cAAe,CAAC,CAAC,CAC1D,CACF,CACJ,EAEJ",
8
- "debugId": "0B1F8E310934FD5E64756E2164756E21",
8
+ "debugId": "D1094770C8BF842F64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{H as F}from"./chunk-27k2zsq8.js";import{$ as w}from"./chunk-f6qhsdsn.js";import{Lg as h}from"./chunk-3bjj31n9.js";var P=h((p)=>{var t=w(),l=F();function d(e){try{let o=new Set(Array.from(e.match(/([A-Z_]){3,}/g)??[]));return o.delete("CONFIG"),o.delete("CONFIG_PREFIX_SEPARATOR"),o.delete("ENV"),[...o].join(", ")}catch(o){return e}}var u=(e,o)=>async()=>{try{let r=e(process.env,o);if(r===void 0)throw Error();return r}catch(r){throw new t.CredentialsProviderError(r.message||`Not found in ENV: ${d(e.toString())}`,{logger:o?.logger})}},C=(e,{preferredFile:o="config",...r}={})=>async()=>{let n=l.getProfileName(r),{configFile:i,credentialsFile:c}=await l.loadSharedConfigFiles(r),s=c[n]||{},g=i[n]||{},m=o==="config"?{...s,...g}:{...g,...s};try{let f=e(m,o==="config"?i:c);if(f===void 0)throw Error();return f}catch(a){throw new t.CredentialsProviderError(a.message||`Not found in config files w/ profile [${n}]: ${d(e.toString())}`,{logger:r.logger})}},y=(e)=>typeof e==="function",E=(e)=>y(e)?async()=>await e():t.fromStatic(e),N=({environmentVariableSelector:e,configFileSelector:o,default:r},n={})=>{let{signingName:i,logger:c}=n,s={signingName:i,logger:c};return t.memoize(t.chain(u(e,s),C(o,n),E(r)))};p.loadConfig=N});
2
+ import{H as F}from"./chunk-78gs7xvn.js";import{$ as w}from"./chunk-713fezaz.js";import{Ng as h}from"./chunk-t93t317r.js";var P=h((p)=>{var t=w(),l=F();function d(e){try{let o=new Set(Array.from(e.match(/([A-Z_]){3,}/g)??[]));return o.delete("CONFIG"),o.delete("CONFIG_PREFIX_SEPARATOR"),o.delete("ENV"),[...o].join(", ")}catch(o){return e}}var u=(e,o)=>async()=>{try{let r=e(process.env,o);if(r===void 0)throw Error();return r}catch(r){throw new t.CredentialsProviderError(r.message||`Not found in ENV: ${d(e.toString())}`,{logger:o?.logger})}},C=(e,{preferredFile:o="config",...r}={})=>async()=>{let n=l.getProfileName(r),{configFile:i,credentialsFile:c}=await l.loadSharedConfigFiles(r),s=c[n]||{},g=i[n]||{},m=o==="config"?{...s,...g}:{...g,...s};try{let f=e(m,o==="config"?i:c);if(f===void 0)throw Error();return f}catch(a){throw new t.CredentialsProviderError(a.message||`Not found in config files w/ profile [${n}]: ${d(e.toString())}`,{logger:r.logger})}},y=(e)=>typeof e==="function",E=(e)=>y(e)?async()=>await e():t.fromStatic(e),N=({environmentVariableSelector:e,configFileSelector:o,default:r},n={})=>{let{signingName:i,logger:c}=n,s={signingName:i,logger:c};return t.memoize(t.chain(u(e,s),C(o,n),E(r)))};p.loadConfig=N});
3
3
  export{P as G};
4
4
 
5
- //# debugId=DB200F154F5A555264756E2164756E21
5
+ //# debugId=723F5469946859B264756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "'use strict';\n\nvar propertyProvider = require('@smithy/property-provider');\nvar sharedIniFileLoader = require('@smithy/shared-ini-file-loader');\n\nfunction getSelectorName(functionString) {\n try {\n const constants = new Set(Array.from(functionString.match(/([A-Z_]){3,}/g) ?? []));\n constants.delete(\"CONFIG\");\n constants.delete(\"CONFIG_PREFIX_SEPARATOR\");\n constants.delete(\"ENV\");\n return [...constants].join(\", \");\n }\n catch (e) {\n return functionString;\n }\n}\n\nconst fromEnv = (envVarSelector, options) => async () => {\n try {\n const config = envVarSelector(process.env, options);\n if (config === undefined) {\n throw new Error();\n }\n return config;\n }\n catch (e) {\n throw new propertyProvider.CredentialsProviderError(e.message || `Not found in ENV: ${getSelectorName(envVarSelector.toString())}`, { logger: options?.logger });\n }\n};\n\nconst fromSharedConfigFiles = (configSelector, { preferredFile = \"config\", ...init } = {}) => async () => {\n const profile = sharedIniFileLoader.getProfileName(init);\n const { configFile, credentialsFile } = await sharedIniFileLoader.loadSharedConfigFiles(init);\n const profileFromCredentials = credentialsFile[profile] || {};\n const profileFromConfig = configFile[profile] || {};\n const mergedProfile = preferredFile === \"config\"\n ? { ...profileFromCredentials, ...profileFromConfig }\n : { ...profileFromConfig, ...profileFromCredentials };\n try {\n const cfgFile = preferredFile === \"config\" ? configFile : credentialsFile;\n const configValue = configSelector(mergedProfile, cfgFile);\n if (configValue === undefined) {\n throw new Error();\n }\n return configValue;\n }\n catch (e) {\n throw new propertyProvider.CredentialsProviderError(e.message || `Not found in config files w/ profile [${profile}]: ${getSelectorName(configSelector.toString())}`, { logger: init.logger });\n }\n};\n\nconst isFunction = (func) => typeof func === \"function\";\nconst fromStatic = (defaultValue) => isFunction(defaultValue) ? async () => await defaultValue() : propertyProvider.fromStatic(defaultValue);\n\nconst loadConfig = ({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => {\n const { signingName, logger } = configuration;\n const envOptions = { signingName, logger };\n return propertyProvider.memoize(propertyProvider.chain(fromEnv(environmentVariableSelector, envOptions), fromSharedConfigFiles(configFileSelector, configuration), fromStatic(defaultValue)));\n};\n\nexports.loadConfig = loadConfig;\n"
6
6
  ],
7
7
  "mappings": ";mJAEA,FAAI,AACA,MAEJ,SAAS,CAAe,CAAC,EAAgB,CACrC,GAAI,CACA,IAAM,EAAY,IAAI,IAAI,MAAM,KAAK,EAAe,MAAM,eAAe,GAAK,CAAC,CAAC,CAAC,EAIjF,OAHA,EAAU,OAAO,QAAQ,EACzB,EAAU,OAAO,yBAAyB,EAC1C,EAAU,OAAO,KAAK,EACf,CAAC,GAAG,CAAS,EAAE,KAAK,IAAI,EAEnC,MAAO,EAAG,CACN,OAAO,GAIf,IAAM,EAAU,CAAC,EAAgB,IAAY,SAAY,CACrD,GAAI,CACA,IAAM,EAAS,EAAe,QAAQ,IAAK,CAAO,EAClD,GAAI,IAAW,OACX,MAAU,MAAM,EAEpB,OAAO,EAEX,MAAO,EAAG,CACN,MAAM,IAAI,EAAiB,yBAAyB,EAAE,SAAW,qBAAqB,EAAgB,EAAe,SAAS,CAAC,IAAK,CAAE,OAAQ,GAAS,MAAO,CAAC,IAIjK,EAAwB,CAAC,GAAkB,gBAAgB,YAAa,GAAS,CAAC,IAAM,SAAY,CACtG,IAAM,EAAU,EAAoB,eAAe,CAAI,GAC/C,aAAY,mBAAoB,MAAM,EAAoB,sBAAsB,CAAI,EACtF,EAAyB,EAAgB,IAAY,CAAC,EACtD,EAAoB,EAAW,IAAY,CAAC,EAC5C,EAAgB,IAAkB,SAClC,IAAK,KAA2B,CAAkB,EAClD,IAAK,KAAsB,CAAuB,EACxD,GAAI,CAEA,IAAM,EAAc,EAAe,EADnB,IAAkB,SAAW,EAAa,CACD,EACzD,GAAI,IAAgB,OAChB,MAAU,MAAM,EAEpB,OAAO,EAEX,MAAO,EAAG,CACN,MAAM,IAAI,EAAiB,yBAAyB,EAAE,SAAW,yCAAyC,OAAa,EAAgB,EAAe,SAAS,CAAC,IAAK,CAAE,OAAQ,EAAK,MAAO,CAAC,IAI9L,EAAa,CAAC,IAAS,OAAO,IAAS,WACvC,EAAa,CAAC,IAAiB,EAAW,CAAY,EAAI,SAAY,MAAM,EAAa,EAAI,EAAiB,WAAW,CAAY,EAErI,EAAa,EAAG,8BAA6B,qBAAoB,QAAS,GAAgB,EAAgB,CAAC,IAAM,CACnH,IAAQ,cAAa,UAAW,EAC1B,EAAa,CAAE,cAAa,QAAO,EACzC,OAAO,EAAiB,QAAQ,EAAiB,MAAM,EAAQ,EAA6B,CAAU,EAAG,EAAsB,EAAoB,CAAa,EAAG,EAAW,CAAY,CAAC,CAAC,GAGxL,aAAa",
8
- "debugId": "DB200F154F5A555264756E2164756E21",
8
+ "debugId": "723F5469946859B264756E2164756E21",
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 ag,H as bg,U as cg,K as dg,S as eg,L as fg,R as gg,w as hg,F as ig,f as jg};
3
+ export{D as cg,H as dg,U as eg,K as fg,S as gg,L as hg,R as ig,w as jg,F as kg,f as lg};
4
4
 
5
- //# debugId=7722CF339B7F61BE64756E2164756E21
5
+ //# debugId=B53B69547C8572AA64756E2164756E21
@@ -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,CA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AA64756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -2,6 +2,6 @@
2
2
  class p extends Error{retryable;constructor(B,H={}){super(B,H.cause!==void 0?{cause:H.cause}:void 0);this.name="ToolError",this.retryable=H.retryable??!0}}var m={provider_error:"The model provider returned an error.",rate_limited:"The model provider is rate limiting requests. Try again shortly.",context_length_exceeded:"The conversation is too long for the model.",content_filtered:"The model provider's content filter blocked this request.",invalid_tool_input:"The model provider rejected the request.",tool_error:"A tool failed.",unknown:"The run failed unexpectedly."};function f(B,H){if(H.source==="tool"){if(H.cause instanceof p)return B;return{...B,message:`The tool "${H.toolName}" failed with an unexpected error.`}}let Q=m[B.code];return Q===void 0?B:{...B,message:Q}}function XB(B,H,Q,Z){let V;try{V=(B??f)(H,Q)}catch(X){Z(X),V=f(H,Q)}return{code:V.code,message:V.message,...V.toolCallId!==void 0?{toolCallId:V.toolCallId}:{},retryable:V.retryable}}var v=new WeakMap;function ZB(B,H){if(B!==H)v.set(B,H)}function $B(B){return v.get(B)??B}var b=new WeakMap;function g(B){let H=b.get(B);if(!H)throw Error("gemi/ai: expected a schema built with `s`, got a foreign object");return H}function j(B){let H=(B.optional||B.nullable)&&B.node.kind!=="json",Q=n(u(B.node),H),Z=[B.description,r(B.node)].filter(Boolean).join(" ");return Z?{description:Z,...Q}:Q}function r(B){let H=[];if(B.kind==="string"||B.kind==="enum"){let Q=B.checks;if(Q?.format)H.push(`Format: ${Q.format.name}.`);if(Q?.minLength!==void 0)H.push(`At least ${Q.minLength} characters.`);if(Q?.maxLength!==void 0)H.push(`At most ${Q.maxLength} characters.`)}else if(B.kind==="number"){let Q=B.checks;if(Q?.minimum!==void 0)H.push(`Minimum ${Q.minimum}.`);if(Q?.exclusiveMinimum!==void 0)H.push(`Greater than ${Q.exclusiveMinimum}.`);if(Q?.maximum!==void 0)H.push(`Maximum ${Q.maximum}.`);if(Q?.exclusiveMaximum!==void 0)H.push(`Less than ${Q.exclusiveMaximum}.`)}else if(B.kind==="array"){let Q=B.checks;if(Q?.minItems!==void 0)H.push(`At least ${Q.minItems} items.`);if(Q?.maxItems!==void 0)H.push(`At most ${Q.maxItems} items.`)}return H.join(" ")}function u(B){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:j(B.item)};case"object":return{type:"object",properties:Object.fromEntries(Object.entries(B.shape).map(([H,Q])=>[H,j(Q)])),required:Object.keys(B.shape),additionalProperties:!1};case"union":return{anyOf:B.members.map(j)};case"json":return{}}}function n(B,H){if(!H)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 o(B){if(B===null)return"null";if(Array.isArray(B))return"array";return typeof B}function t(B,H){if(typeof H==="number"&&!Number.isFinite(H))return String(H);if(B.kind==="literal"||B.kind==="enum"){if(typeof H==="string"||typeof H==="number"||typeof H==="boolean")return JSON.stringify(H)}return o(H)}function l(B){let H=B.node,Q=(()=>{switch(H.kind){case"number":return H.checks?.integer?"integer":"number";case"string":case"boolean":return H.kind;case"literal":return JSON.stringify(H.value);case"enum":return`one of ${H.values.map((Z)=>JSON.stringify(Z)).join(" | ")}`;case"array":return"array";case"object":return"object";case"union":return"one of the variants";case"json":return"a JSON value"}})();return B.optional||B.nullable?`${Q} or null`:Q}function i(B){let H="";for(let Q of B)H+=typeof Q==="number"?`[${Q}]`:H?`.${Q}`:Q;return H}function s(B){let H=i(B);return H?`${H}: `:""}function y(B){return`${s(B.path)}${B.message}`}function k(B,H){if(H===null||H===void 0)return B.optional||B.nullable?1:0;let Q=B.node;switch(Q.kind){case"string":return typeof H==="string"?1:0;case"number":return typeof H==="number"?1:0;case"boolean":return typeof H==="boolean"?1:0;case"literal":return H===Q.value?10:0;case"enum":return typeof H==="string"&&Q.values.includes(H)?10:0;case"array":return Array.isArray(H)?1:0;case"object":{if(typeof H!=="object"||Array.isArray(H))return 0;let Z=H,V=1;for(let[X,M]of Object.entries(Q.shape))V+=k(M,Z[X]);return V}case"union":return Q.members.reduce((Z,V)=>Math.max(Z,k(V,H)),0);case"json":return 1}}function C(B,H,Q,Z){if(B.optional&&(H===null||H===void 0))return{drop:!0,value:void 0};if(B.nullable&&H===null)return{drop:!1,value:null};return{drop:!1,value:a(B,H,Q,Z)}}function a(B,H,Q,Z){let V=B.node,X=()=>{let M=H===void 0?"required":V.kind==="literal"?"const":V.kind==="enum"&&typeof H==="string"?"enum":"type",U=M==="const"?{allowedValue:V.value}:M==="enum"?{allowedValues:V.values}:{};Z.push({path:Q,code:M,message:`expected ${l(B)}, got ${t(V,H)}`,params:U});return};switch(V.kind){case"string":if(typeof H!=="string")return X();return h(V.checks,H,Q,Z),H;case"number":if(typeof H!=="number"||!Number.isFinite(H))return X();if(V.checks?.integer&&!Number.isInteger(H))return X();return BB(V.checks,H,Q,Z),H;case"boolean":return typeof H==="boolean"?H:X();case"literal":return H===V.value?H:X();case"enum":if(typeof H!=="string"||!V.values.includes(H))return X();return h(V.checks,H,Q,Z),H;case"array":{if(!Array.isArray(H))return X();let M=H.map((F,W)=>{let T=C(V.item,F,[...Q,W],Z);return T.drop?void 0:T.value}),{minItems:U,maxItems:G}=V.checks??{};if(U!==void 0&&H.length<U)Z.push({path:Q,code:"minItems",message:`expected at least ${U} items, got ${H.length}`,params:{limit:U}});if(G!==void 0&&H.length>G)Z.push({path:Q,code:"maxItems",message:`expected at most ${G} items, got ${H.length}`,params:{limit:G}});return M}case"object":{if(typeof H!=="object"||H===null||Array.isArray(H))return X();let M=H,U={};for(let[G,F]of Object.entries(V.shape)){let W=C(F,M[G],[...Q,G],Z);if(!W.drop)U[G]=W.value}return U}case"union":{let M;for(let U of V.members){let G=[],F=C(U,H,Q,G);if(G.length===0)return F.drop?void 0:F.value;let W=k(U,H);if(!M||W>M.score)M={issues:G,score:W}}Z.push({path:Q,code:"anyOf",message:`no matching variant; closest: ${M.issues.map(y).join("; ")}`,params:{closest:M.issues}});return}case"json":if(H===void 0)return X();return x(H,Q,Z,new Set),H}}function e(B){let H=0;for(let Q of B)H++;return H}function h(B,H,Q,Z){if(!B)return;let{minLength:V,maxLength:X,format:M}=B;if(V!==void 0||X!==void 0){let U=e(H);if(V!==void 0&&U<V)Z.push({path:Q,code:"minLength",message:`expected at least ${V} characters, got ${U}`,params:{limit:V}});if(X!==void 0&&U>X)Z.push({path:Q,code:"maxLength",message:`expected at most ${X} characters, got ${U}`,params:{limit:X}})}if(M){let U=!1;try{U=M.test(H)===!0}catch{}if(!U)Z.push({path:Q,code:"format",message:`expected a string in format "${M.name}"`,params:{format:M.name}})}}function BB(B,H,Q,Z){if(!B)return;let V=(X,M,U,G)=>{if(M===void 0||U(M))return;Z.push({path:Q,code:X,message:`expected ${G} ${M}, got ${H}`,params:{limit:M}})};V("minimum",B.minimum,(X)=>H>=X,"at least"),V("exclusiveMinimum",B.exclusiveMinimum,(X)=>H>X,"more than"),V("maximum",B.maximum,(X)=>H<=X,"at most"),V("exclusiveMaximum",B.exclusiveMaximum,(X)=>H<X,"less than")}function x(B,H,Q,Z,V=!0){let X=(U)=>{Q.push({path:H,code:"type",message:`expected a JSON value, got ${U}`,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 M=B;if(Z.has(M))return X("a circular reference");Z.add(M);try{let U=V?M.toJSON:void 0;if(typeof U==="function"){let G;try{G=U.call(M)}catch{return X("a toJSON that threw")}if(G===void 0)return X("a toJSON that returns undefined");return x(G,H,Q,Z,!1)}if(Array.isArray(B))B.forEach((G,F)=>x(G,[...H,F],Q,Z));else for(let[G,F]of Object.entries(M))x(F,[...H,G],Q,Z)}finally{Z.delete(M)}}function K(B){return J(B)}function J(B){let H={toJSONSchema:()=>j(B),parse(Q){let Z=[],V=C(B,Q,[],Z);if(Z.length>0)throw Error(Z.map(y).join("; "));return V.drop?void 0:V.value},safeParse(Q){let Z=[],V=C(B,Q,[],Z);if(Z.length>0)return{ok:!1,errors:Z.map(y)};return{ok:!0,value:V.drop?void 0:V.value}},validate(Q){let Z=[],V=C(B,Q,[],Z);if(Z.length>0)return{ok:!1,issues:Z};return{ok:!0,value:V.drop?void 0:V.value}},describe:(Q)=>J({...B,description:Q}),optional:()=>J({...B,optional:!0}),nullable:()=>J({...B,nullable:!0,optional:!1})};return b.set(H,B),H}function P(B){return{node:B,optional:!1,nullable:!1}}class d extends Error{problems;constructor(B){super(`gemi/ai: s.fromJSONSchema cannot model this schema:
3
3
  ${B.map((H)=>`- ${H}`).join(`
4
4
  `)}`);this.name="JSONSchemaError",this.problems=B}}var HB=new Set(["title","$schema","$id","$comment","examples","default","deprecated","readOnly","writeOnly"]),I={string:["minLength","maxLength","format"],number:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],integer:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],boolean:[],object:["properties","required","additionalProperties"],array:["items","minItems","maxItems"]};function E(B){return typeof B==="object"&&B!==null&&!Array.isArray(B)}function w(B,H,Q,Z){let V=($,_=Q)=>{Z.push(_?`${_}: ${$}`:$);return},X=($)=>Q?`${Q}.${$}`:$;if(!E(B))return V("expected a schema object");let M=new Set(H.ignoreKeywords??[]),U=($)=>HB.has($)||$.startsWith("x-")||M.has($),G=!1,F=B.type;if(Array.isArray(F)){let $=F.filter((_)=>_!=="null");if($.length!==1)return V(`type ${JSON.stringify(F)} is not supported; only one type, optionally with "null". Use anyOf for alternatives`,X("type"));G=$.length<F.length,F=$[0]}if(F!==void 0&&(typeof F!=="string"||!(F in I)))return V(`type ${JSON.stringify(F)} is not supported; expected one of ${Object.keys(I).join(", ")}`,X("type"));let W=new Set(["type","description","enum","const","anyOf",...F?I[F]:[]]),T=!1;for(let $ of Object.keys(B)){if(W.has($)||U($))continue;T=!0;let _=Object.entries(I).find(([,q])=>q.includes($));V(_&&_[0]!==F?`"${$}" applies to type ${_[0]}, and this schema is ${F?`type ${F}`:"untyped"}`:`"${$}" is not supported by s.fromJSONSchema`,X($))}if(T)return;if(B.description!==void 0&&typeof B.description!=="string")return V("expected a string",X("description"));let L=B.description,D=($)=>({node:$,optional:!1,nullable:G,...L?{description:L}:{}});if(B.anyOf!==void 0){if(F!==void 0||B.enum!==void 0||B.const!==void 0)return V("anyOf cannot be combined with type, enum or const here",X("anyOf"));if(!Array.isArray(B.anyOf)||B.anyOf.length===0)return V("expected a non-empty array",X("anyOf"));let $=[],_=!1;if(B.anyOf.forEach((q,A)=>{if(E(q)&&q.type==="null"&&Object.keys(q).length===1){G=!0;return}let z=w(q,H,X(`anyOf[${A}]`),Z);if(z)$.push(z);else _=!0}),_)return;if($.length===0)return V("anyOf has only null in it",X("anyOf"));if($.length===1){let q=$[0];return{...q,nullable:q.nullable||G,...L?{description:L}:{}}}return D({kind:"union",members:$})}if(B.const!==void 0){let $=B.const;if(typeof $!=="string"&&typeof $!=="number"&&typeof $!=="boolean")return V("only a string, number or boolean const is supported",X("const"));if(F!==void 0&&typeof $!==(F==="integer"?"number":F))return V(`const ${JSON.stringify($)} is not of type ${F}`,X("const"));return D({kind:"literal",value:$})}let R;if(F==="string"){if(R=QB(B,H,X,Z),R===null)return}if(B.enum!==void 0){if(!Array.isArray(B.enum)||B.enum.length===0)return V("expected a non-empty array",X("enum"));let $=B.enum.filter((A)=>A!==null);if($.length<B.enum.length)G=!0;let _=$.find((A)=>!(typeof A==="string"||typeof A==="number"||typeof A==="boolean")||F!==void 0&&typeof A!==(F==="integer"?"number":F));if(_!==void 0||$.length===0)return V(F?`every value must be of type ${F}${$.length===0?", and there must be one":`; ${JSON.stringify(_)} is not`}`:"only strings, numbers and booleans are supported",X("enum"));if($.every((A)=>typeof A==="string"))return D({kind:"enum",values:[...new Set($)],...R?{checks:R}:{}});let q=[...new Set($)];if(q.length===1)return D({kind:"literal",value:q[0]});return D({kind:"union",members:q.map((A)=>P({kind:"literal",value:A}))})}switch(F){case void 0:return V("a schema needs a type, an enum, a const or an anyOf");case"string":return D({kind:"string",...R?{checks:R}:{}});case"number":case"integer":{let $=F==="integer"?{integer:!0}:{},_=!1;for(let q of I.number){let A=B[q];if(A===void 0)continue;if(typeof A!=="number"||!Number.isFinite(A)){V("expected a number",X(q)),_=!0;continue}$[q]=A}if(_)return;return D({kind:"number",...Object.keys($).length>0?{checks:$}:{}})}case"boolean":return D({kind:"boolean"});case"array":{if(!E(B.items))return V('an array needs "items" to be one schema (tuples are not supported)',X("items"));let $={},_=!1;for(let A of["minItems","maxItems"]){let z=B[A];if(z===void 0)continue;if(typeof z!=="number"||!Number.isInteger(z)||z<0){V("expected a non-negative integer",X(A)),_=!0;continue}$[A]=z}let q=w(B.items,H,X("items"),Z);if(!q||_)return;return D({kind:"array",item:q,...Object.keys($).length>0?{checks:$}:{}})}case"object":{let $=B.properties??{};if(!E($))return V("expected an object",X("properties"));if(B.additionalProperties!==void 0&&B.additionalProperties!==!1)return V("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((Y)=>typeof Y==="string"))return V("expected an array of property names",X("required"));let q=_.filter((Y)=>!Object.hasOwn($,Y));if(q.length>0)return V(`lists properties the schema doesn't have: ${q.join(", ")}`,X("required"));let A={},z=!1;for(let[Y,c]of Object.entries($)){let S=w(c,H,X(`properties.${Y}`),Z);if(!S){z=!0;continue}A[Y]=_.includes(Y)?S:{...S,optional:!0}}if(z)return;return D({kind:"object",shape:A})}}return}function QB(B,H,Q,Z){let V={},X=!1;for(let M of["minLength","maxLength"]){let U=B[M];if(U===void 0)continue;if(typeof U!=="number"||!Number.isInteger(U)||U<0){Z.push(`${Q(M)}: expected a non-negative integer`),X=!0;continue}V[M]=U}if(B.format!==void 0){let M=B.format,U=typeof M==="string"?H.formats?.[M]:void 0;if(typeof M!=="string")Z.push(`${Q("format")}: expected a string`),X=!0;else if(!U||!Object.hasOwn(H.formats,M))Z.push(`${Q("format")}: unknown format ${JSON.stringify(M)}; pass a check for it in the formats option`),X=!0;else V.format={name:M,test:VB(U)}}if(X)return null;return Object.keys(V).length>0?V:void 0}function VB(B){if(B===!0)return()=>!0;if(B instanceof RegExp)return(H)=>{return B.lastIndex=0,B.test(H)};return B}var UB={string:()=>K(P({kind:"string"})),number:()=>K(P({kind:"number"})),boolean:()=>K(P({kind:"boolean"})),literal:(B)=>K(P({kind:"literal",value:B})),enum:(B)=>K(P({kind:"enum",values:B})),object:(B)=>K(P({kind:"object",shape:Object.fromEntries(Object.entries(B).map(([H,Q])=>[H,g(Q)]))})),array:(B)=>K(P({kind:"array",item:g(B)})),union:(B)=>K(P({kind:"union",members:B.map(g)})),json:()=>K(P({kind:"json"})),fromJSONSchema:(B,H={})=>{let Q=[],Z=w(B,H,"",Q);if(!Z||Q.length>0)throw new d(Q.length>0?Q:["unreadable schema"]);return K(Z)}};function FB(B){let H=b.get(B);if(H)return N(H.node);return O(B.toJSONSchema())}function O(B){if(!(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 Q of Object.values(B.properties??{}))if(!O(Q))return!1;if(B.items&&!O(B.items))return!1;for(let Q of B.anyOf??[])if(!O(Q))return!1;return!0}function N(B){switch(B.kind){case"string":case"number":case"boolean":case"literal":case"enum":return!0;case"object":return Object.values(B.shape).every((H)=>N(H.node));case"array":return N(B.item.node);case"union":return B.members.every((H)=>N(H.node));case"json":return!1}}
5
- export{p as Db,f as Eb,XB as Fb,ZB as Gb,$B as Hb,d as Ib,UB as Jb,FB as Kb};
5
+ export{p as zb,f as Ab,XB as Bb,ZB as Cb,$B as Db,d as Eb,UB as Fb,FB as Gb};
6
6
 
7
- //# debugId=D1BAB7F7C1BBE20164756E2164756E21
7
+ //# debugId=FA19541B73B738AD64756E2164756E21
@@ -6,6 +6,6 @@
6
6
  "/**\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, a\n * recursive document. It does not widen the subset — it turns strict mode off\n * for the schema containing it, which `supportsStrict` reads back off the tree\n * so that no caller has to remember to.\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\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 *\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\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 | { kind: \"object\"; shape: Record<string, Definition> }\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\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\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\nfunction emit(definition: Definition): 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 const body = allowNull(emitNode(definition.node), widen);\n const description = [definition.description, hint(definition.node)].filter(Boolean).join(\" \");\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 return said.join(\" \");\n}\n\nfunction emitNode(node: SchemaNode): 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) };\n case \"object\":\n return {\n type: \"object\",\n properties: Object.fromEntries(\n Object.entries(node.shape).map(([key, child]) => [key, emit(child)]),\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(emit) };\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 }\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 }\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 }\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 // Unknown keys are DROPPED, not rejected. `additionalProperties: false`\n // has already told the model not to send them, so one arriving anyway is\n // a slip rather than an attack, and failing a whole tool call over a\n // stray field costs a turn to fix nothing. Dropping is also what keeps\n // `execute` from ever seeing a field its input type says cannot be there.\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 }\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: () => emit(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\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 return finish({ kind: \"object\", shape });\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 that nests into itself.\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 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. Unlike Ajv, an unknown key in an object is dropped from the\n * parsed value rather than reported.\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 fromJSONSchema: <T>(schema: unknown, options: FromJSONSchemaOptions = {}) => {\n const problems: string[] = [];\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.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 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 * Needs no cycle guard: a definition tree is built bottom-up out of finished\n * builders, so nothing in it can refer to something still being constructed.\n */\nfunction strictNode(node: SchemaNode): 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));\n case \"array\":\n return strictNode(node.item.node);\n case \"union\":\n return node.members.every((member) => strictNode(member.node));\n case \"json\":\n return false;\n }\n}\n"
7
7
  ],
8
8
  "mappings": ";AAgBO,MAAM,UAAkB,KAAM,CAE1B,UAET,WAAW,CAAC,EAAiB,EAAoD,CAAC,EAAG,CACnF,MAAM,EAAS,EAAQ,QAAU,OAAY,CAAE,MAAO,EAAQ,KAAM,EAAI,MAAS,EACjF,KAAK,KAAO,YACZ,KAAK,UAAY,EAAQ,WAAa,GAE1C,CAoCA,IAAM,EAAgE,CACpE,eAAgB,wCAChB,aAAc,mEACd,wBAAyB,8CACzB,iBAAkB,4DAClB,mBAAoB,2CACp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