gemi 0.207.2 → 0.208.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/dist/ai/Agent.d.ts +83 -1
  2. package/dist/ai/Agent.d.ts.map +1 -1
  3. package/dist/ai/AgentController.d.ts +7 -1
  4. package/dist/ai/AgentController.d.ts.map +1 -1
  5. package/dist/ai/AgentProvider.d.ts +20 -2
  6. package/dist/ai/AgentProvider.d.ts.map +1 -1
  7. package/dist/ai/FallbackProvider.d.ts.map +1 -1
  8. package/dist/ai/index.d.ts +4 -4
  9. package/dist/ai/index.d.ts.map +1 -1
  10. package/dist/ai/index.js +38 -38
  11. package/dist/ai/index.js.map +4 -4
  12. package/dist/ai/providers/call.d.ts +3 -1
  13. package/dist/ai/providers/call.d.ts.map +1 -1
  14. package/dist/ai/providers/capabilities.d.ts.map +1 -1
  15. package/dist/ai/providers/endpoints.d.ts +9 -0
  16. package/dist/ai/providers/endpoints.d.ts.map +1 -1
  17. package/dist/ai/providers/errors.d.ts +4 -2
  18. package/dist/ai/providers/errors.d.ts.map +1 -1
  19. package/dist/ai/providers/http.d.ts +33 -0
  20. package/dist/ai/providers/http.d.ts.map +1 -1
  21. package/dist/ai/providers/request.d.ts.map +1 -1
  22. package/dist/ai/store/stubAgentRun.d.ts +2 -1
  23. package/dist/ai/store/stubAgentRun.d.ts.map +1 -1
  24. package/dist/ai/testing/index.js +2 -2
  25. package/dist/ai/testing/index.js.map +1 -1
  26. package/dist/ai/types.d.ts +31 -2
  27. package/dist/ai/types.d.ts.map +1 -1
  28. package/dist/app/index.js +1 -1
  29. package/dist/bun/plugin.js +1 -1
  30. package/dist/bun/preload.js +1 -1
  31. package/dist/{chunk-24tj4dzx.js → chunk-094hbhc8.js} +2 -2
  32. package/dist/{chunk-24tj4dzx.js.map → chunk-094hbhc8.js.map} +1 -1
  33. package/dist/{chunk-1em8t2x1.js → chunk-101rvvje.js} +3 -3
  34. package/dist/{chunk-1em8t2x1.js.map → chunk-101rvvje.js.map} +1 -1
  35. package/dist/{chunk-qc0e278w.js → chunk-12gthjxx.js} +1 -1
  36. package/dist/{chunk-8ar7180x.js → chunk-1agwddws.js} +2 -2
  37. package/dist/{chunk-8ar7180x.js.map → chunk-1agwddws.js.map} +1 -1
  38. package/dist/{chunk-nfher0gz.js → chunk-1vnbw1d8.js} +2 -2
  39. package/dist/{chunk-nfher0gz.js.map → chunk-1vnbw1d8.js.map} +1 -1
  40. package/dist/{chunk-53fv4c39.js → chunk-24z18t5q.js} +4 -4
  41. package/dist/{chunk-53fv4c39.js.map → chunk-24z18t5q.js.map} +1 -1
  42. package/dist/{chunk-6ge27ygx.js → chunk-2jbdbvd8.js} +2 -2
  43. package/dist/{chunk-6ge27ygx.js.map → chunk-2jbdbvd8.js.map} +1 -1
  44. package/dist/{chunk-fhn92are.js → chunk-2k438dp6.js} +2 -2
  45. package/dist/{chunk-fhn92are.js.map → chunk-2k438dp6.js.map} +1 -1
  46. package/dist/{chunk-rjtge67x.js → chunk-3raywsbj.js} +2 -2
  47. package/dist/{chunk-rjtge67x.js.map → chunk-3raywsbj.js.map} +1 -1
  48. package/dist/{chunk-k8peybx0.js → chunk-3rgf7rsy.js} +3 -3
  49. package/dist/{chunk-k8peybx0.js.map → chunk-3rgf7rsy.js.map} +1 -1
  50. package/dist/{chunk-hthyn5pj.js → chunk-3wsmgdcr.js} +3 -3
  51. package/dist/{chunk-hthyn5pj.js.map → chunk-3wsmgdcr.js.map} +1 -1
  52. package/dist/{chunk-3830ee5d.js → chunk-5399t8zm.js} +2 -2
  53. package/dist/{chunk-3830ee5d.js.map → chunk-5399t8zm.js.map} +1 -1
  54. package/dist/{chunk-ndcqbwsj.js → chunk-641fns6j.js} +2 -2
  55. package/dist/{chunk-ndcqbwsj.js.map → chunk-641fns6j.js.map} +1 -1
  56. package/dist/{chunk-wrfz0jsw.js → chunk-6zcqa5fz.js} +2 -2
  57. package/dist/{chunk-wrfz0jsw.js.map → chunk-6zcqa5fz.js.map} +1 -1
  58. package/dist/{chunk-6zpf257t.js → chunk-716832vw.js} +2 -2
  59. package/dist/{chunk-6zpf257t.js.map → chunk-716832vw.js.map} +1 -1
  60. package/dist/{chunk-e0scxs81.js → chunk-8gyq2etb.js} +3 -3
  61. package/dist/{chunk-e0scxs81.js.map → chunk-8gyq2etb.js.map} +3 -3
  62. package/dist/{chunk-8q5kxzxn.js → chunk-8ty6yp6r.js} +3 -3
  63. package/dist/{chunk-8q5kxzxn.js.map → chunk-8ty6yp6r.js.map} +1 -1
  64. package/dist/{chunk-8ncqxja2.js → chunk-9d8tz60r.js} +1 -1
  65. package/dist/{chunk-xgc5tj8k.js → chunk-9qyedsvw.js} +3 -3
  66. package/dist/{chunk-xgc5tj8k.js.map → chunk-9qyedsvw.js.map} +1 -1
  67. package/dist/{chunk-zf1eqgzt.js → chunk-a76a7869.js} +2 -2
  68. package/dist/{chunk-72e857nw.js.map → chunk-a76a7869.js.map} +1 -1
  69. package/dist/{chunk-djnn8vvp.js → chunk-achvynaf.js} +2 -2
  70. package/dist/{chunk-djnn8vvp.js.map → chunk-achvynaf.js.map} +1 -1
  71. package/dist/{chunk-0eq7am78.js → chunk-ad0dx73f.js} +2 -2
  72. package/dist/{chunk-0eq7am78.js.map → chunk-ad0dx73f.js.map} +1 -1
  73. package/dist/{chunk-092magz7.js → chunk-ag5nhjcr.js} +2 -2
  74. package/dist/{chunk-092magz7.js.map → chunk-ag5nhjcr.js.map} +1 -1
  75. package/dist/{chunk-emt36pxm.js → chunk-agrr8f8y.js} +2 -2
  76. package/dist/{chunk-emt36pxm.js.map → chunk-agrr8f8y.js.map} +1 -1
  77. package/dist/{chunk-znw55n6g.js → chunk-arzp5dne.js} +2 -2
  78. package/dist/{chunk-znw55n6g.js.map → chunk-arzp5dne.js.map} +1 -1
  79. package/dist/{chunk-jn1h76sa.js → chunk-b1y54j6v.js} +2 -2
  80. package/dist/{chunk-jn1h76sa.js.map → chunk-b1y54j6v.js.map} +1 -1
  81. package/dist/{chunk-te4vz0rw.js → chunk-b51a77kv.js} +2 -2
  82. package/dist/{chunk-te4vz0rw.js.map → chunk-b51a77kv.js.map} +1 -1
  83. package/dist/{chunk-wfees83q.js → chunk-bdzj9znx.js} +3 -3
  84. package/dist/{chunk-wfees83q.js.map → chunk-bdzj9znx.js.map} +1 -1
  85. package/dist/{chunk-39dz1abf.js → chunk-bhc9vk13.js} +1 -1
  86. package/dist/{chunk-460c8k50.js → chunk-cfbhhfkv.js} +3 -3
  87. package/dist/{chunk-460c8k50.js.map → chunk-cfbhhfkv.js.map} +1 -1
  88. package/dist/{chunk-78g1cngk.js → chunk-dje6exhs.js} +2 -2
  89. package/dist/{chunk-78g1cngk.js.map → chunk-dje6exhs.js.map} +1 -1
  90. package/dist/{chunk-bpqkzpkt.js → chunk-dm6tkkwv.js} +2 -2
  91. package/dist/{chunk-bpqkzpkt.js.map → chunk-dm6tkkwv.js.map} +1 -1
  92. package/dist/{chunk-bxznwntw.js → chunk-enq03rgh.js} +2 -2
  93. package/dist/{chunk-bxznwntw.js.map → chunk-enq03rgh.js.map} +1 -1
  94. package/dist/{chunk-34vvev4a.js → chunk-ewhgsw1n.js} +2 -2
  95. package/dist/{chunk-34vvev4a.js.map → chunk-ewhgsw1n.js.map} +1 -1
  96. package/dist/{chunk-8gyanh1b.js → chunk-f0sfh1r2.js} +2 -2
  97. package/dist/{chunk-8gyanh1b.js.map → chunk-f0sfh1r2.js.map} +1 -1
  98. package/dist/{chunk-a7zqp5m7.js → chunk-fsae9dgb.js} +2 -2
  99. package/dist/{chunk-a7zqp5m7.js.map → chunk-fsae9dgb.js.map} +1 -1
  100. package/dist/{chunk-hqg4dfca.js → chunk-fv6ncgbc.js} +2 -2
  101. package/dist/{chunk-hqg4dfca.js.map → chunk-fv6ncgbc.js.map} +1 -1
  102. package/dist/{chunk-etcds9w3.js → chunk-h1f4f9wx.js} +2 -2
  103. package/dist/{chunk-etcds9w3.js.map → chunk-h1f4f9wx.js.map} +1 -1
  104. package/dist/{chunk-m3v661b3.js → chunk-h4byt0x3.js} +2 -2
  105. package/dist/{chunk-m3v661b3.js.map → chunk-h4byt0x3.js.map} +1 -1
  106. package/dist/{chunk-c8bvpkr2.js → chunk-hbdqv48k.js} +2 -2
  107. package/dist/{chunk-c8bvpkr2.js.map → chunk-hbdqv48k.js.map} +1 -1
  108. package/dist/{chunk-9m6mkaqb.js → chunk-hcysexst.js} +2 -2
  109. package/dist/{chunk-9m6mkaqb.js.map → chunk-hcysexst.js.map} +1 -1
  110. package/dist/{chunk-wpfempaj.js → chunk-hmccxtd3.js} +2 -2
  111. package/dist/{chunk-wpfempaj.js.map → chunk-hmccxtd3.js.map} +1 -1
  112. package/dist/{chunk-tx5zrdmb.js → chunk-jggtz103.js} +2 -2
  113. package/dist/{chunk-tx5zrdmb.js.map → chunk-jggtz103.js.map} +1 -1
  114. package/dist/{chunk-sjve1yvv.js → chunk-jr9y6k90.js} +1 -1
  115. package/dist/{chunk-6x2zbh1q.js → chunk-kax9ghny.js} +2 -2
  116. package/dist/{chunk-6x2zbh1q.js.map → chunk-kax9ghny.js.map} +1 -1
  117. package/dist/{chunk-q1t9gvm1.js → chunk-kbkyde5f.js} +2 -2
  118. package/dist/{chunk-q1t9gvm1.js.map → chunk-kbkyde5f.js.map} +1 -1
  119. package/dist/{chunk-77dt2tap.js → chunk-mtf5kzza.js} +2 -2
  120. package/dist/{chunk-77dt2tap.js.map → chunk-mtf5kzza.js.map} +1 -1
  121. package/dist/{chunk-3z8d8v8q.js → chunk-mxedsqbe.js} +3 -3
  122. package/dist/{chunk-3z8d8v8q.js.map → chunk-mxedsqbe.js.map} +1 -1
  123. package/dist/{chunk-jy61580r.js → chunk-n0sbg84n.js} +2 -2
  124. package/dist/{chunk-jy61580r.js.map → chunk-n0sbg84n.js.map} +1 -1
  125. package/dist/{chunk-06w8hhnk.js → chunk-n65hk6bq.js} +2 -2
  126. package/dist/{chunk-06w8hhnk.js.map → chunk-n65hk6bq.js.map} +1 -1
  127. package/dist/{chunk-4ksnhx8x.js → chunk-ntcj2sgv.js} +3 -3
  128. package/dist/{chunk-4ksnhx8x.js.map → chunk-ntcj2sgv.js.map} +1 -1
  129. package/dist/{chunk-scw0vknj.js → chunk-p27ft91c.js} +1 -1
  130. package/dist/{chunk-vyaedzr8.js → chunk-p608rrfc.js} +3 -3
  131. package/dist/{chunk-vyaedzr8.js.map → chunk-p608rrfc.js.map} +1 -1
  132. package/dist/chunk-pag82mxh.js +5 -0
  133. package/dist/{chunk-4q59y78y.js.map → chunk-pag82mxh.js.map} +1 -1
  134. package/dist/{chunk-yj1h4rzn.js → chunk-q634cwbc.js} +3 -3
  135. package/dist/{chunk-yj1h4rzn.js.map → chunk-q634cwbc.js.map} +1 -1
  136. package/dist/{chunk-09hzyf9g.js → chunk-q7x7ddw0.js} +3 -3
  137. package/dist/{chunk-09hzyf9g.js.map → chunk-q7x7ddw0.js.map} +1 -1
  138. package/dist/{chunk-65btke6p.js → chunk-qc7x8q1q.js} +2 -2
  139. package/dist/{chunk-65btke6p.js.map → chunk-qc7x8q1q.js.map} +1 -1
  140. package/dist/{chunk-wdrmzjtq.js → chunk-r5ggnywk.js} +2 -2
  141. package/dist/{chunk-wdrmzjtq.js.map → chunk-r5ggnywk.js.map} +1 -1
  142. package/dist/{chunk-72e857nw.js → chunk-raejxs3y.js} +2 -2
  143. package/dist/{chunk-zf1eqgzt.js.map → chunk-raejxs3y.js.map} +1 -1
  144. package/dist/{chunk-k8a41gkt.js → chunk-rffpqhn8.js} +2 -2
  145. package/dist/{chunk-k8a41gkt.js.map → chunk-rffpqhn8.js.map} +1 -1
  146. package/dist/{chunk-p9c5rc1z.js → chunk-rhyhxgxg.js} +3 -3
  147. package/dist/{chunk-p9c5rc1z.js.map → chunk-rhyhxgxg.js.map} +1 -1
  148. package/dist/{chunk-eeq9ty68.js → chunk-t0xfzpfa.js} +2 -2
  149. package/dist/{chunk-eeq9ty68.js.map → chunk-t0xfzpfa.js.map} +1 -1
  150. package/dist/chunk-t9gc6mhq.js +11 -0
  151. package/dist/{chunk-2e40rx0p.js.map → chunk-t9gc6mhq.js.map} +8 -8
  152. package/dist/{chunk-9qyet3nb.js → chunk-tj8wbxyz.js} +2 -2
  153. package/dist/{chunk-9qyet3nb.js.map → chunk-tj8wbxyz.js.map} +1 -1
  154. package/dist/{chunk-q751b0jx.js → chunk-tjfvkzq8.js} +1 -1
  155. package/dist/{chunk-njnng5ew.js → chunk-v10kckwp.js} +4 -4
  156. package/dist/{chunk-njnng5ew.js.map → chunk-v10kckwp.js.map} +1 -1
  157. package/dist/{chunk-ne51fxg2.js → chunk-vrpsgq3x.js} +2 -2
  158. package/dist/{chunk-ne51fxg2.js.map → chunk-vrpsgq3x.js.map} +1 -1
  159. package/dist/{chunk-jy26hy7z.js → chunk-w92n83g2.js} +2 -2
  160. package/dist/{chunk-jy26hy7z.js.map → chunk-w92n83g2.js.map} +1 -1
  161. package/dist/{chunk-dwya9z8p.js → chunk-wcpqn1pg.js} +2 -2
  162. package/dist/{chunk-dwya9z8p.js.map → chunk-wcpqn1pg.js.map} +1 -1
  163. package/dist/{chunk-zvk6dydb.js → chunk-wkh9xcdq.js} +2 -2
  164. package/dist/{chunk-zvk6dydb.js.map → chunk-wkh9xcdq.js.map} +1 -1
  165. package/dist/{chunk-7wzhdq1x.js → chunk-wy87gc0b.js} +3 -3
  166. package/dist/{chunk-7wzhdq1x.js.map → chunk-wy87gc0b.js.map} +1 -1
  167. package/dist/{chunk-aed0vv5g.js → chunk-xt90xbes.js} +2 -2
  168. package/dist/{chunk-aed0vv5g.js.map → chunk-xt90xbes.js.map} +1 -1
  169. package/dist/{chunk-6cx6kh04.js → chunk-y16vp7yf.js} +2 -2
  170. package/dist/{chunk-6cx6kh04.js.map → chunk-y16vp7yf.js.map} +1 -1
  171. package/dist/{chunk-e05rbjn2.js → chunk-ykh78bct.js} +2 -2
  172. package/dist/{chunk-e05rbjn2.js.map → chunk-ykh78bct.js.map} +1 -1
  173. package/dist/{chunk-cffx7wqp.js → chunk-yn3pf1fp.js} +2 -2
  174. package/dist/{chunk-cffx7wqp.js.map → chunk-yn3pf1fp.js.map} +1 -1
  175. package/dist/{chunk-s1fa5f8b.js → chunk-yzbj11dd.js} +2 -2
  176. package/dist/{chunk-s1fa5f8b.js.map → chunk-yzbj11dd.js.map} +1 -1
  177. package/dist/{chunk-vebstesm.js → chunk-zcx8n3mk.js} +3 -3
  178. package/dist/{chunk-vebstesm.js.map → chunk-zcx8n3mk.js.map} +1 -1
  179. package/dist/chunk-zrqzxc50.js +48 -0
  180. package/dist/chunk-zrqzxc50.js.map +27 -0
  181. package/dist/{chunk-8d2g78vc.js → chunk-zv6a6w1v.js} +2 -2
  182. package/dist/{chunk-8d2g78vc.js.map → chunk-zv6a6w1v.js.map} +1 -1
  183. package/dist/{chunk-1tc6j8bn.js → chunk-zzs96hc8.js} +2 -2
  184. package/dist/{chunk-1tc6j8bn.js.map → chunk-zzs96hc8.js.map} +1 -1
  185. package/dist/config/index.js +1 -1
  186. package/dist/console/run.js +2 -2
  187. package/dist/console/run.js.map +1 -1
  188. package/dist/container/index.js +2 -2
  189. package/dist/container/index.js.map +1 -1
  190. package/dist/database/index.js +2 -2
  191. package/dist/database/index.js.map +1 -1
  192. package/dist/email/index.js +2 -2
  193. package/dist/email/index.js.map +1 -1
  194. package/dist/facades/index.js +2 -2
  195. package/dist/facades/index.js.map +1 -1
  196. package/dist/foundation/index.js +2 -2
  197. package/dist/foundation/index.js.map +1 -1
  198. package/dist/http/index.js +2 -2
  199. package/dist/http/index.js.map +1 -1
  200. package/dist/i18n/dictionaryRuntime.js +2 -2
  201. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  202. package/dist/i18n/index.js +2 -2
  203. package/dist/i18n/index.js.map +1 -1
  204. package/dist/kernel/index.js +2 -2
  205. package/dist/kernel/index.js.map +1 -1
  206. package/dist/orm/index.js +2 -2
  207. package/dist/orm/index.js.map +1 -1
  208. package/dist/probe/index.js +2 -2
  209. package/dist/probe/index.js.map +1 -1
  210. package/dist/server/index.js +2 -2
  211. package/dist/server/index.js.map +1 -1
  212. package/dist/services/index.js +2 -2
  213. package/dist/services/index.js.map +1 -1
  214. package/dist/services/queue/work.js +2 -2
  215. package/dist/services/queue/work.js.map +1 -1
  216. package/dist/stats/route-table.js +1 -1
  217. package/dist/support/index.js +2 -2
  218. package/dist/support/index.js.map +1 -1
  219. package/dist/vitest/index.js +1 -1
  220. package/package.json +1 -1
  221. package/dist/chunk-2e40rx0p.js +0 -11
  222. package/dist/chunk-4q59y78y.js +0 -5
  223. package/dist/chunk-v1d7xya8.js +0 -46
  224. package/dist/chunk-v1d7xya8.js.map +0 -27
  225. /package/dist/{chunk-qc0e278w.js.map → chunk-12gthjxx.js.map} +0 -0
  226. /package/dist/{chunk-8ncqxja2.js.map → chunk-9d8tz60r.js.map} +0 -0
  227. /package/dist/{chunk-39dz1abf.js.map → chunk-bhc9vk13.js.map} +0 -0
  228. /package/dist/{chunk-sjve1yvv.js.map → chunk-jr9y6k90.js.map} +0 -0
  229. /package/dist/{chunk-scw0vknj.js.map → chunk-p27ft91c.js.map} +0 -0
  230. /package/dist/{chunk-q751b0jx.js.map → chunk-tjfvkzq8.js.map} +0 -0
@@ -12,6 +12,6 @@
12
12
  "import { existsSync } from \"node:fs\";\nimport { dirname, isAbsolute, join } from \"node:path\";\n\nimport {\n discoverClasses,\n DiscoveryError,\n projectRoot,\n} from \"../support/discover\";\nimport { Command, type CommandClass } from \"../console/Command\";\nimport { commandConfigDefaults } from \"../console/config\";\nimport { isUnfinishedBuilder } from \"../console/builder\";\nimport { CronJob } from \"./cron/CronJob\";\nimport { scheduleConfigDefaults } from \"./cron/config\";\nimport { eventConfigDefaults } from \"./events/config\";\nimport type { EventClass } from \"./events/Event\";\nimport { Listener, type ListenerClass } from \"./events/Listener\";\nimport { Job } from \"./queue/Job\";\nimport { queueConfigDefaults } from \"./queue/config\";\nimport { Workflow, type WorkflowClass } from \"./queue/workflow/Workflow\";\n\n/**\n * Reading an application's jobs off the filesystem, for the two subsystems that\n * were asking every app to write its job list twice.\n *\n * Both functions here are the same call to `discoverClasses` with a different\n * base class, which is deliberate: one walk, one set of skip rules, one answer\n * to \"what does this app have\". They are exported from `gemi/services` rather\n * than kept private to the providers because the list stopped being something\n * an app could import — a test that used to walk the exported `jobs` array\n * needs somewhere to ask the same question, and so does a script.\n *\n * What the providers add on top of these is the decision of *whether* to ask,\n * which is the config's to make and not this file's.\n */\n\n/**\n * A directory the app named, resolved the way the app meant it.\n *\n * Relative paths hang off the project root rather than `process.cwd()` at the\n * moment of the call, because a config slice saying `app/jobs` means the app's\n * `app/jobs` and not whatever directory somebody happened to launch a script\n * from. Absolute paths are taken as given, which is what makes these callable\n * from a test that has no project around it.\n */\nfunction resolveDir(dir: string): string {\n return isAbsolute(dir) ? dir : join(projectRoot(), dir);\n}\n\n/**\n * Says something when the directory is missing *and so is the tree it lives in*.\n *\n * A missing directory has two readings and they want opposite responses. An app\n * that has never written a cron job has no `app/cron`, and warning about that on\n * every boot for the rest of its life is noise — the answer \"you have no cron\n * jobs\" is correct and uninteresting. But a deploy that ships `dist/` and\n * `node_modules/` without the source has no `app/cron` *and no `app/`*, and\n * there discovery quietly returns nothing while the app very much does have\n * jobs: the exact silence #322 and #323 exist to remove, reintroduced one layer\n * down and in production only.\n *\n * The parent directory is what tells them apart. If neither the directory nor\n * the one above it is there, the tree this was pointed into is not there\n * either, and that is worth a sentence.\n */\nfunction warnIfSourceIsMissing(\n resolved: string,\n subject: string,\n slice: string,\n) {\n if (existsSync(resolved) || existsSync(dirname(resolved))) return;\n\n console.warn(\n `No ${subject} were discovered: neither ${resolved} nor the directory ` +\n `above it exists, so this process cannot see the application's source. ` +\n `If this is a deploy that ships only the build output, list the classes ` +\n `explicitly in app/config/${slice}.ts so they travel with it.`,\n );\n}\n\n/**\n * The `Job` subclasses under `dir`, defaulting to the config slice's `app/jobs`.\n *\n * This is what a `queue` config slice with no `jobs` key resolves to. Call it\n * directly to ask the question a test used to answer by importing the array:\n * every job this application would register, in the order it would register\n * them.\n *\n * Every file underneath is imported, so calling this runs the app's job modules\n * — the cost `discoverClasses` documents at length, paid once per call.\n */\nexport async function discoverJobs(\n dir: string = queueConfigDefaults().jobsDir,\n): Promise<Array<new () => Job>> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"queue jobs\", \"queue\");\n const jobs = await discoverClasses(resolved, Job);\n warnIfNameWillNotSurviveTheBuild(jobs);\n return jobs;\n}\n\n/**\n * The `Workflow` subclasses under `dir`, defaulting to the queue slice's\n * `app/workflows`: what a `queue` slice with no `workflows` key resolves to.\n * A missing directory is no workflows, said nothing about unless the tree\n * above it is missing too.\n */\nexport async function discoverWorkflows(\n dir: string = queueConfigDefaults().workflowsDir,\n): Promise<WorkflowClass[]> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"workflows\", \"queue\");\n const workflows = (await discoverClasses(resolved, Workflow)) as WorkflowClass[];\n for (const workflow of workflows) {\n if (Object.getOwnPropertyDescriptor(workflow, \"name\")?.writable) continue;\n console.warn(\n `Workflow ${workflow.name} does not declare \\`static name\\`. A workflow ` +\n `is stored under its name, and a production build renames the class. ` +\n `Add: static name = \"${workflow.name}\";`,\n );\n }\n return workflows;\n}\n\n/**\n * Says something about a discovered job that never declared `static name`.\n *\n * This is the one hazard discovery introduces rather than removes, and it is\n * production-only. `gemi build` minifies the server entry, and app code\n * reachable from it — a controller, and every job class that controller\n * imports to dispatch — is bundled and minified with it. Minification renames\n * the class binding, and a class's implicit `.name` is that binding: a\n * `TestJob` in the bundle reports `\"D\"`. Discovery, meanwhile, imports\n * `app/jobs/TestJob.ts` from source at runtime, where it is still `\"TestJob\"`.\n * The queue is keyed by that name, so the two halves stop agreeing and the\n * dispatch is dropped — in production, and only there.\n *\n * A declared `static name = \"TestJob\"` is a string literal, which survives\n * minification intact, and the two halves agree again. `docs/jobs-and-queues.md`\n * has always called it required; before discovery an app could get away without\n * it, because the explicit `jobs` array was bundled too and both sides were\n * wrong in the same way.\n *\n * The check is exact rather than a guess: a `static name = \"...\"` class field\n * defines a *writable* own property, while the implicit class name is\n * non-writable. Cron is unaffected — `CronJob.name` is an instance field\n * holding a string literal, not the class binding.\n */\nfunction warnIfNameWillNotSurviveTheBuild(jobs: Array<new () => Job>) {\n for (const job of jobs) {\n if (Object.getOwnPropertyDescriptor(job, \"name\")?.writable) continue;\n\n console.warn(\n `Queued job ${job.name} does not declare \\`static name\\`, so it is ` +\n `registered under its class name. A production build minifies the ` +\n `class that dispatches it and renames it, while discovery reads this ` +\n `file from source and does not — so the dispatch would be dropped in ` +\n `production and nowhere else. Add: static name = \"${job.name}\";`,\n );\n }\n}\n\n/**\n * The `CronJob` subclasses under `dir`, defaulting to the config slice's\n * `app/cron`.\n *\n * This is what a `schedule` config slice with no `jobs` key resolves to. Call it\n * directly to ask the question a test used to answer by importing the array —\n * though after boot `app(Scheduler).jobs` is the better one, because it is what\n * the scheduler actually took rather than what this would find if asked again.\n *\n * Every file underneath is imported, so calling this runs the app's cron\n * modules — the cost `discoverClasses` documents at length, paid once per call.\n */\nexport async function discoverCronJobs(\n dir: string = scheduleConfigDefaults().jobsDir,\n): Promise<Array<new () => CronJob>> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"cron jobs\", \"schedule\");\n return await discoverClasses(resolved, CronJob);\n}\n\n/**\n * The `Command` subclasses under `dir`, defaulting to the config slice's\n * `app/commands`.\n *\n * This is what a `commands`-less `command` slice resolves to, and what\n * `gemi run` lists. Unlike the two above it is not called during boot — a\n * command registry has one consumer, and importing every file under\n * `app/commands` into every server process would be a cost paid on every start\n * for code no request reaches.\n *\n * Every file underneath is imported, so calling this runs the app's command\n * modules — the cost `discoverClasses` documents at length, paid once per call.\n */\nexport async function discoverCommands(\n dir: string = commandConfigDefaults().commandsDir,\n): Promise<CommandClass[]> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"commands\", \"command\");\n\n const unfinished: string[] = [];\n\n const commands = await discoverClasses(\n resolved,\n Command,\n [],\n (value, file) => {\n if (isUnfinishedBuilder(value)) unfinished.push(file);\n },\n );\n\n refuseUnfinishedBuilders(unfinished);\n\n return commands as CommandClass[];\n}\n\n/**\n * Stops the walk for a builder chain that was never finished.\n *\n * This is the one silence the builder introduces, and it is the exact shape\n * #322 and #323 exist to remove. `defineCommand(...).arg(...)` without a\n * trailing `.handle(...)` is a plain object rather than a class, so\n * `discoverClasses` discards it along with every constant and helper a command\n * file happens to export — and the command disappears from `gemi run` with\n * nothing raised. The author sees a listing containing every command except the\n * one they just wrote.\n *\n * A throw rather than a warning, because there is no reading of an unfinished\n * builder under which the author meant it: the chain builds a description of a\n * command and then discards it.\n *\n * \"Unfinished\" is decided by `.handle()` clearing the brand, not by the export\n * still being a builder object. Those differ for the natural way to share\n * declarations —\n *\n * export const base = defineCommand(\"reindex\").option(\"verbose\", …);\n * export default base.handle(async () => {});\n *\n * — where `base` is a builder that *did* produce a command. Keying off the shape\n * alone made that file abort the whole of `gemi run`, taking every other command\n * in the project down with it, under a message that was untrue for it.\n */\nfunction refuseUnfinishedBuilders(files: string[]): void {\n if (files.length === 0) return;\n\n const subject =\n files.length === 1\n ? `${files[0]} exports a command builder that never called \\`.handle()\\``\n : `${files.length} files export a command builder that never called ` +\n `\\`.handle()\\`:\\n ${files.join(\"\\n \")}`;\n\n throw new DiscoveryError(\n `${subject}, so there is no command to run. \\`.handle()\\` is what turns ` +\n `the chain into a command — finish it:\\n\\n` +\n ` export default defineCommand(\"my-command\")\\n` +\n ` .handle(async ({ line }) => { line(\"hello\") })`,\n );\n}\n\n/**\n * The `Listener` subclasses under `dir`, defaulting to the config slice's\n * `app/listeners`.\n *\n * This is what an `events` config slice with no `listeners` key resolves to.\n * Call it directly to ask what an application would register: every listener,\n * in the order it would register them.\n *\n * Only listeners are walked. Event classes are never discovered — each is\n * imported by the listener that binds to it and by the code that dispatches it,\n * so there is nothing a walk over them would find that is not already in the\n * module graph.\n *\n * **Known residual, matching jobs and cron.** `discoverClasses` excludes the\n * `base` it is handed and not intermediates, so an abstract listener base\n * written in `listenersDir` and extended by its siblings is discovered and\n * registered alongside them — constructed, with its `handle` called, on every\n * dispatch of whatever event it declares. Keep shared bases outside the\n * directory.\n *\n * Every file underneath is imported, so calling this runs the app's listener\n * modules — the cost `discoverClasses` documents at length, paid once per call.\n *\n * @throws DiscoveryError if a discovered listener declares no `static event`.\n */\nexport async function discoverListeners(\n dir: string = eventConfigDefaults().listenersDir,\n): Promise<ListenerClass[]> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"event listeners\", \"events\");\n\n const listeners = (await discoverClasses(\n resolved,\n Listener,\n )) as ListenerClass[];\n\n refuseListenersWithNoEvent(listeners);\n warnIfListenerNameWillNotSurviveTheBuild(listeners);\n warnIfEventNameWillNotSurviveTheBuild(listeners);\n\n return listeners;\n}\n\n/**\n * Stops the walk for a listener that binds to nothing.\n *\n * `static event` is declared as required on the base and the compiler still\n * cannot see it missing: every subclass inherits the declaration whether or not\n * it assigns to one, so `typeof SomeListener` type-checks either way. What the\n * author gets instead is a file that is imported, registered under no name, and\n * never called — the silence this whole module is arranged against.\n *\n * A throw rather than a warning, because there is no reading of a listener with\n * no event under which the author meant it. The usual cause is the residual\n * above: an abstract base sharing a gate between two listeners, sitting in\n * `listenersDir` where the walk finds it. Moving it out is the fix, and the\n * message says so — the alternative, excluding it by some guess about\n * abstractness, is how a discovery pass ends up quietly covering less than the\n * directory holds.\n */\nfunction refuseListenersWithNoEvent(listeners: ListenerClass[]): void {\n const orphans = listeners.filter((listener) => !listener.event);\n if (orphans.length === 0) return;\n\n throw new DiscoveryError(\n `${orphans\n .map((listener) => listener.name)\n .join(\", \")} declare no \\`static event\\`, so there is no event name to ` +\n `register them under and their \\`handle\\` would never run. Every ` +\n `listener binds to exactly one event:\\n\\n` +\n ` static event = UserRegistered;\\n\\n` +\n `If this is an abstract base its subclasses extend, move it out of the ` +\n `listeners directory — the walk excludes gemi's \\`Listener\\` and ` +\n `nothing else, so a base sitting beside its subclasses is registered ` +\n `and run like one of them.`,\n );\n}\n\n/**\n * Says something about a discovered listener that never declared `static name`.\n *\n * The hazard is `warnIfNameWillNotSurviveTheBuild`'s, one subsystem over: a\n * `static name = \"...\"` class field defines a *writable* own property while the\n * implicit class binding does not, and a minifier renames the binding while\n * leaving the string literal alone. The two spellings are indistinguishable by\n * value — both read `\"SendWelcomeEmail\"` in development — so the descriptor is\n * the only thing that tells them apart, and the difference only becomes visible\n * in a production build.\n *\n * A warning rather than a refusal, because a *sync* listener's name has no\n * second half to disagree with: every reader of it comes from this same\n * source-side walk, so a minified build and this walk cannot produce two\n * different strings for it. A **queued** listener does have one — the name is\n * the queue's key and it crosses a JSON boundary — and that case is refused\n * outright, by `jobForListener`, at the point the listener is registered with\n * the queue rather than here. This walk cannot tell the two apart without\n * constructing every listener it found; the registry constructs them anyway.\n */\nfunction warnIfListenerNameWillNotSurviveTheBuild(listeners: ListenerClass[]) {\n for (const listener of listeners) {\n if (Object.getOwnPropertyDescriptor(listener, \"name\")?.writable) continue;\n\n console.warn(\n `Event listener ${listener.name} does not declare \\`static name\\`, so ` +\n `it is registered under its class name, which a production build ` +\n `renames. Nothing reads that name across a build boundary while the ` +\n `listener is sync, which is why this is a warning — but adding ` +\n `\\`queued = true\\` to it is refused at boot for the same reason, ` +\n `because the queue's key is that string. Add: static name = ` +\n `\"${listener.name}\";`,\n );\n }\n}\n\n/**\n * Says something about the *event* a discovered listener binds to, when that\n * event's name is the implicit class binding.\n *\n * This is the check that matters from the first dispatch, and it is the reason\n * `discoverListeners` reads `static event` at all. The registry is keyed by the\n * event's name; the dispatcher supplies that name from the class it constructs.\n * A production build minifies the server entry and the app code reachable from\n * it — the controller, and the event class it imports in order to dispatch —\n * while discovery imports `app/listeners/*.ts` from source, and those files\n * import `app/events/*.ts` from source too. Two module graphs, two class\n * objects, and an implicit `.name` that reads `\"UserRegistered\"` on one side\n * and `\"D\"` on the other. The dispatch then finds no listeners, which is legal,\n * normal, and completely silent.\n *\n * A declared `static name` is a string literal, which survives minification\n * intact, and the two halves agree again.\n *\n * Checked through the descriptor rather than the string, and not by comparing\n * `event.name` to anything: in development the two spellings produce the same\n * value, so a check on the string would be a tautology that passes forever.\n */\nfunction warnIfEventNameWillNotSurviveTheBuild(listeners: ListenerClass[]) {\n const warned = new Set<EventClass>();\n\n for (const { event } of listeners) {\n if (warned.has(event)) continue;\n if (Object.getOwnPropertyDescriptor(event, \"name\")?.writable) continue;\n warned.add(event);\n\n console.warn(\n `Event ${event.name} does not declare \\`static name\\`, so it is ` +\n `dispatched under its class name. A production build minifies the ` +\n `code that dispatches it and renames the class, while discovery reads ` +\n `the listener's copy from source and does not — so the dispatch would ` +\n `reach no listener in production and nowhere else. Add: ` +\n `static name = \"${event.name}\";`,\n );\n }\n}\n"
13
13
  ],
14
14
  "mappings": "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",
15
- "debugId": "C33C3FC2EBE8579E64756E2164756E21",
15
+ "debugId": "49CE6B75789A04A964756E2164756E21",
16
16
  "names": []
17
17
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{W as J}from"./chunk-fhn92are.js";import{Fm as I}from"./chunk-zf1eqgzt.js";var Z=I((Q)=>{var K=J(),L=(b)=>{return{setHttpHandler(j){b.httpHandler=j},httpHandler(){return b.httpHandler},updateHttpClientConfig(j,w){b.httpHandler?.updateHttpClientConfig(j,w)},httpHandlerConfigs(){return b.httpHandler.httpHandlerConfigs()}}},M=(b)=>{return{httpHandler:b.httpHandler()}};class B{name;kind;values;constructor({name:b,kind:j=K.FieldPosition.HEADER,values:w=[]}){this.name=b,this.kind=j,this.values=w}add(b){this.values.push(b)}set(b){this.values=b}remove(b){this.values=this.values.filter((j)=>j!==b)}toString(){return this.values.map((b)=>b.includes(",")||b.includes(" ")?`"${b}"`:b).join(", ")}get(){return this.values}}class D{entries={};encoding;constructor({fields:b=[],encoding:j="utf-8"}){b.forEach(this.setField.bind(this)),this.encoding=j}setField(b){this.entries[b.name.toLowerCase()]=b}getField(b){return this.entries[b.toLowerCase()]}removeField(b){delete this.entries[b.toLowerCase()]}getByType(b){return Object.values(this.entries).filter((j)=>j.kind===b)}}class z{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(b){this.method=b.method||"GET",this.hostname=b.hostname||"localhost",this.port=b.port,this.query=b.query||{},this.headers=b.headers||{},this.body=b.body,this.protocol=b.protocol?b.protocol.slice(-1)!==":"?`${b.protocol}:`:b.protocol:"https:",this.path=b.path?b.path.charAt(0)!=="/"?`/${b.path}`:b.path:"/",this.username=b.username,this.password=b.password,this.fragment=b.fragment}static clone(b){let j=new z({...b,headers:{...b.headers}});if(j.query)j.query=O(j.query);return j}static isInstance(b){if(!b)return!1;let j=b;return"method"in j&&"protocol"in j&&"hostname"in j&&"path"in j&&typeof j.query==="object"&&typeof j.headers==="object"}clone(){return z.clone(this)}}function O(b){return Object.keys(b).reduce((j,w)=>{let A=b[w];return{...j,[w]:Array.isArray(A)?[...A]:A}},{})}class G{statusCode;reason;headers;body;constructor(b){this.statusCode=b.statusCode,this.reason=b.reason,this.headers=b.headers||{},this.body=b.body}static isInstance(b){if(!b)return!1;let j=b;return typeof j.statusCode==="number"&&typeof j.headers==="object"}}function P(b){return/^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/.test(b)}Q.Field=B;Q.Fields=D;Q.HttpRequest=z;Q.HttpResponse=G;Q.getHttpHandlerExtensionConfiguration=L;Q.isValidHostname=P;Q.resolveHttpHandlerRuntimeConfig=M});
2
+ import{W as J}from"./chunk-2k438dp6.js";import{Gm as I}from"./chunk-a76a7869.js";var Z=I((Q)=>{var K=J(),L=(b)=>{return{setHttpHandler(j){b.httpHandler=j},httpHandler(){return b.httpHandler},updateHttpClientConfig(j,w){b.httpHandler?.updateHttpClientConfig(j,w)},httpHandlerConfigs(){return b.httpHandler.httpHandlerConfigs()}}},M=(b)=>{return{httpHandler:b.httpHandler()}};class B{name;kind;values;constructor({name:b,kind:j=K.FieldPosition.HEADER,values:w=[]}){this.name=b,this.kind=j,this.values=w}add(b){this.values.push(b)}set(b){this.values=b}remove(b){this.values=this.values.filter((j)=>j!==b)}toString(){return this.values.map((b)=>b.includes(",")||b.includes(" ")?`"${b}"`:b).join(", ")}get(){return this.values}}class D{entries={};encoding;constructor({fields:b=[],encoding:j="utf-8"}){b.forEach(this.setField.bind(this)),this.encoding=j}setField(b){this.entries[b.name.toLowerCase()]=b}getField(b){return this.entries[b.toLowerCase()]}removeField(b){delete this.entries[b.toLowerCase()]}getByType(b){return Object.values(this.entries).filter((j)=>j.kind===b)}}class z{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(b){this.method=b.method||"GET",this.hostname=b.hostname||"localhost",this.port=b.port,this.query=b.query||{},this.headers=b.headers||{},this.body=b.body,this.protocol=b.protocol?b.protocol.slice(-1)!==":"?`${b.protocol}:`:b.protocol:"https:",this.path=b.path?b.path.charAt(0)!=="/"?`/${b.path}`:b.path:"/",this.username=b.username,this.password=b.password,this.fragment=b.fragment}static clone(b){let j=new z({...b,headers:{...b.headers}});if(j.query)j.query=O(j.query);return j}static isInstance(b){if(!b)return!1;let j=b;return"method"in j&&"protocol"in j&&"hostname"in j&&"path"in j&&typeof j.query==="object"&&typeof j.headers==="object"}clone(){return z.clone(this)}}function O(b){return Object.keys(b).reduce((j,w)=>{let A=b[w];return{...j,[w]:Array.isArray(A)?[...A]:A}},{})}class G{statusCode;reason;headers;body;constructor(b){this.statusCode=b.statusCode,this.reason=b.reason,this.headers=b.headers||{},this.body=b.body}static isInstance(b){if(!b)return!1;let j=b;return typeof j.statusCode==="number"&&typeof j.headers==="object"}}function P(b){return/^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/.test(b)}Q.Field=B;Q.Fields=D;Q.HttpRequest=z;Q.HttpResponse=G;Q.getHttpHandlerExtensionConfiguration=L;Q.isValidHostname=P;Q.resolveHttpHandlerRuntimeConfig=M});
3
3
  export{Z as Q};
4
4
 
5
- //# debugId=2B61B604F7D242D964756E2164756E21
5
+ //# debugId=48C2F82FB0F00CB964756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "'use strict';\n\nvar types = require('@smithy/types');\n\nconst getHttpHandlerExtensionConfiguration = (runtimeConfig) => {\n return {\n setHttpHandler(handler) {\n runtimeConfig.httpHandler = handler;\n },\n httpHandler() {\n return runtimeConfig.httpHandler;\n },\n updateHttpClientConfig(key, value) {\n runtimeConfig.httpHandler?.updateHttpClientConfig(key, value);\n },\n httpHandlerConfigs() {\n return runtimeConfig.httpHandler.httpHandlerConfigs();\n },\n };\n};\nconst resolveHttpHandlerRuntimeConfig = (httpHandlerExtensionConfiguration) => {\n return {\n httpHandler: httpHandlerExtensionConfiguration.httpHandler(),\n };\n};\n\nclass Field {\n name;\n kind;\n values;\n constructor({ name, kind = types.FieldPosition.HEADER, values = [] }) {\n this.name = name;\n this.kind = kind;\n this.values = values;\n }\n add(value) {\n this.values.push(value);\n }\n set(values) {\n this.values = values;\n }\n remove(value) {\n this.values = this.values.filter((v) => v !== value);\n }\n toString() {\n return this.values.map((v) => (v.includes(\",\") || v.includes(\" \") ? `\"${v}\"` : v)).join(\", \");\n }\n get() {\n return this.values;\n }\n}\n\nclass Fields {\n entries = {};\n encoding;\n constructor({ fields = [], encoding = \"utf-8\" }) {\n fields.forEach(this.setField.bind(this));\n this.encoding = encoding;\n }\n setField(field) {\n this.entries[field.name.toLowerCase()] = field;\n }\n getField(name) {\n return this.entries[name.toLowerCase()];\n }\n removeField(name) {\n delete this.entries[name.toLowerCase()];\n }\n getByType(kind) {\n return Object.values(this.entries).filter((field) => field.kind === kind);\n }\n}\n\nclass HttpRequest {\n method;\n protocol;\n hostname;\n port;\n path;\n query;\n headers;\n username;\n password;\n fragment;\n body;\n constructor(options) {\n this.method = options.method || \"GET\";\n this.hostname = options.hostname || \"localhost\";\n this.port = options.port;\n this.query = options.query || {};\n this.headers = options.headers || {};\n this.body = options.body;\n this.protocol = options.protocol\n ? options.protocol.slice(-1) !== \":\"\n ? `${options.protocol}:`\n : options.protocol\n : \"https:\";\n this.path = options.path ? (options.path.charAt(0) !== \"/\" ? `/${options.path}` : options.path) : \"/\";\n this.username = options.username;\n this.password = options.password;\n this.fragment = options.fragment;\n }\n static clone(request) {\n const cloned = new HttpRequest({\n ...request,\n headers: { ...request.headers },\n });\n if (cloned.query) {\n cloned.query = cloneQuery(cloned.query);\n }\n return cloned;\n }\n static isInstance(request) {\n if (!request) {\n return false;\n }\n const req = request;\n return (\"method\" in req &&\n \"protocol\" in req &&\n \"hostname\" in req &&\n \"path\" in req &&\n typeof req[\"query\"] === \"object\" &&\n typeof req[\"headers\"] === \"object\");\n }\n clone() {\n return HttpRequest.clone(this);\n }\n}\nfunction cloneQuery(query) {\n return Object.keys(query).reduce((carry, paramName) => {\n const param = query[paramName];\n return {\n ...carry,\n [paramName]: Array.isArray(param) ? [...param] : param,\n };\n }, {});\n}\n\nclass HttpResponse {\n statusCode;\n reason;\n headers;\n body;\n constructor(options) {\n this.statusCode = options.statusCode;\n this.reason = options.reason;\n this.headers = options.headers || {};\n this.body = options.body;\n }\n static isInstance(response) {\n if (!response)\n return false;\n const resp = response;\n return typeof resp.statusCode === \"number\" && typeof resp.headers === \"object\";\n }\n}\n\nfunction isValidHostname(hostname) {\n const hostPattern = /^[a-z0-9][a-z0-9\\.\\-]*[a-z0-9]$/;\n return hostPattern.test(hostname);\n}\n\nexports.Field = Field;\nexports.Fields = Fields;\nexports.HttpRequest = HttpRequest;\nexports.HttpResponse = HttpResponse;\nexports.getHttpHandlerExtensionConfiguration = getHttpHandlerExtensionConfiguration;\nexports.isValidHostname = isValidHostname;\nexports.resolveHttpHandlerRuntimeConfig = resolveHttpHandlerRuntimeConfig;\n"
6
6
  ],
7
7
  "mappings": "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",
8
- "debugId": "2B61B604F7D242D964756E2164756E21",
8
+ "debugId": "48C2F82FB0F00CB964756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import{Nd as FQ,Td as _,Ud as n,Vd as eQ,Wd as Q5,Xd as qQ,Yd as v,Zd as x,xd as o,zd as s}from"./chunk-8gyq2etb.js";import{Uj as cQ}from"./chunk-1agwddws.js";var x5=4000,O5=60000;function vQ(Q){if(Q===void 0)return;let $=(J,Z)=>typeof J==="number"&&Number.isFinite(J)&&J>=Z;if(!Q||!$(Q.patienceMs,0)||Q.initialWaitMs!==void 0&&!$(Q.initialWaitMs,1)||Q.maxWaitMs!==void 0&&!$(Q.maxWaitMs,1))throw Error(`The provider's retry policy ${JSON.stringify(Q)} is not usable: patienceMs has to be a number of milliseconds (0 or more), and initialWaitMs and maxWaitMs above 0.`)}function ZQ(Q,$,J,Z,Y){let G=Q.patienceMs-Z;if(G<=0)return;let V=Q.maxWaitMs??O5,z=Q.initialWaitMs??x5,j=J!==void 0?Math.min(J,V):Math.round(Math.min(V,z*2**$)*(0.5+Y()*0.5));return Math.min(j,G)}var S5=500,hQ=20000;function M5(Q,$){if(!Q)return;let J=Q.trim();if(/^\d+(\.\d+)?$/.test(J))return Math.max(0,Number(J)*1000);let Z=Date.parse(J);if(Number.isNaN(Z))return;return Math.max(0,Z-$)}function i(Q,$){let J=Math.min(hQ,S5*2**Q);return Math.round(J*(0.5+$()*0.5))}function _5(Q){return Q===429||Q===408||Q===409||Q>=500}function R5(Q,$){return _5(Q)&&x($).retryable}function bQ(Q){return Q.reason??new DOMException("The operation was aborted.","AbortError")}function yQ(Q,$){return new Promise((J,Z)=>{let Y=setTimeout(J,Q);$?.addEventListener("abort",()=>{clearTimeout(Y),Z(bQ($))},{once:!0})})}async function YQ(Q,$,J=yQ){if(!$)return await J(Q);$.throwIfAborted();let Z;try{await Promise.race([J(Q,$),new Promise((Y,G)=>{Z=()=>G(bQ($)),$.addEventListener("abort",Z,{once:!0})})])}finally{if(Z)$.removeEventListener("abort",Z)}}async function u(Q,$,J){let Z=J.fetchImpl??((W,X)=>fetch(W,X)),Y=J.sleep??yQ,G=J.random??Math.random,V=J.now??Date.now,z=Math.max(0,J.maxRetries),j=J.startedAt??V(),K=J.retry,B=(W,X,q,U)=>{let O=V()-j;try{J.onRetry?.({attempt:X+1,maxRetries:z,error:x(q),...v(q),timedOut:U,delayMs:W,elapsedMs:O,...K?{remainingMs:Math.max(0,K.patienceMs-O-W)}:{}})}catch{}return YQ(W,J.signal,Y)},H=(W,X)=>K?ZQ(K,W-z,X,V()-j,G):void 0;for(let W=0;;W++){J.signal?.throwIfAborted();let X=new AbortController,q=()=>X.abort(J.signal?.reason);J.signal?.addEventListener("abort",q,{once:!0});let U=!1,O=J.timeoutMs>0?setTimeout(()=>{U=!0,X.abort()},J.timeoutMs):void 0,N;try{N=await Z(Q,{...$,signal:X.signal})}catch(R){if(O!==void 0)clearTimeout(O);if(J.signal?.removeEventListener("abort",q),J.signal?.aborted)throw R;let I=U?new n(J.timeoutMs):R;if(U&&J.retryTimeouts===!1)throw I;let A=W<z?i(W,G):H(W,void 0);if(A===void 0)throw I;await B(A,W,I,U);continue}if(O!==void 0)clearTimeout(O);if(N.ok)return N;J.signal?.removeEventListener("abort",q);let S=await I5(N),P=new _(N.status,S,N.headers.get("x-request-id")??N.headers.get("request-id")??void 0,M5(N.headers.get("retry-after"),V()));if(!R5(N.status,P))throw P;let y=P.retryAfter??(N.status===429?x(P).retryAfter:void 0),w=W>=z?H(W,y):y===void 0?i(W,G):Math.min(y,hQ);if(w===void 0)throw P;await B(w,W,P,!1)}}async function I5(Q){let $;try{$=await Q.text()}catch{return null}try{return JSON.parse($)}catch{return $}}function fQ(Q,$,J){let Z=$.idleMs>0?$.idleMs:0,Y=$.maxMs>0?$.maxMs:0;if(!Q||!Z&&!Y)return Q;let G=Y?performance.now()+Y:1/0,V=Q.getReader();return new ReadableStream({async pull(z){let j,K,B=Math.max(0,G-performance.now()),H=!Z||B<=Z,W=H?B:Z,X=new Promise((q,U)=>{j=setTimeout(()=>{K=H?J.max():J.idle(),U(K)},W)});try{let q=await Promise.race([V.read(),X]);if(q.done)z.close();else z.enqueue(q.value)}catch(q){let U=K??q;z.error(U),V.cancel(U).catch(()=>{})}finally{clearTimeout(j)}},cancel(z){return V.cancel(z)}},{highWaterMark:0})}var WQ=30000,gQ=10,uQ=7200,A5=600,E5="gpt-live-transcribe";function T5(Q){return Q.type==="transcription"}function w5(Q){if(Q.language!==void 0&&Q.languages!==void 0)throw TypeError("A transcription session takes `languages` or `language`, not both (gpt-live-transcribe reads `languages`).");for(let Y of Q.keywords??[])if(/[<>\r\n]/.test(Y))throw TypeError(`Transcription keywords must be one line without "<" or ">", got ${JSON.stringify(Y)}.`);let $={model:Q.model??E5};if(Q.prompt!==void 0)$.prompt=Q.prompt;if(Q.keywords?.length)$.keywords=Q.keywords;if(Q.languages?.length)$.languages=Q.languages;if(Q.language!==void 0)$.language=Q.language;if(Q.delay!==void 0)$.delay=Q.delay;let J={transcription:$,turn_detection:Q.turnDetection?mQ(Q.turnDetection):null};if(Q.noiseReduction!==void 0)J.noise_reduction=Q.noiseReduction&&{type:Q.noiseReduction};let Z={type:"transcription",audio:{input:J}};if(Q.logprobs)Z.include=["item.input_audio_transcription.logprobs"];return{...Z,...Q.vendor}}function k5(Q){if(!Q)return{type:"object",properties:{}};return cQ(Q)?Q.toJSONSchema():Q}function r(Q,$){if(T5(Q))return w5(Q);let J={type:"realtime"},Z=Q.model??$;if(Z)J.model=Z;if(Q.instructions!==void 0)J.instructions=Q.instructions;if(Q.outputModalities)J.output_modalities=Q.outputModalities;if(Q.maxOutputTokens!==void 0)J.max_output_tokens=Q.maxOutputTokens;if(Q.truncation!==void 0)J.truncation=Q.truncation;if(Q.tools)J.tools=Q.tools.map((V)=>({type:"function",name:V.name,...V.description?{description:V.description}:{},parameters:k5(V.parameters)}));if(Q.toolChoice!==void 0)J.tool_choice=typeof Q.toolChoice==="string"?Q.toolChoice:{type:"function",name:Q.toolChoice.name};let Y={};if(Q.turnDetection!==void 0)Y.turn_detection=Q.turnDetection&&mQ(Q.turnDetection);if(Q.transcription!==void 0)Y.transcription=Q.transcription;if(Q.noiseReduction!==void 0)Y.noise_reduction=Q.noiseReduction&&{type:Q.noiseReduction};let G={};if(Q.voice!==void 0)G.voice=Q.voice;if(Q.speed!==void 0)G.speed=Q.speed;if(Object.keys(Y).length||Object.keys(G).length)J.audio={...Object.keys(Y).length?{input:Y}:{},...Object.keys(G).length?{output:G}:{}};return{...J,...Q.vendor}}function mQ(Q){let $={type:Q.type};if(Q.createResponse!==void 0)$.create_response=Q.createResponse;if(Q.interruptResponse!==void 0)$.interrupt_response=Q.interruptResponse;if(Q.type==="semantic_vad"){if(Q.eagerness!==void 0)$.eagerness=Q.eagerness}else{if(Q.threshold!==void 0)$.threshold=Q.threshold;if(Q.prefixPaddingMs!==void 0)$.prefix_padding_ms=Q.prefixPaddingMs;if(Q.silenceDurationMs!==void 0)$.silence_duration_ms=Q.silenceDurationMs;if(Q.idleTimeoutMs!==void 0)$.idle_timeout_ms=Q.idleTimeoutMs}return $}function VQ(Q){let $=Number(Q?.input_tokens??0),J=Number(Q?.output_tokens??0),Z={inputTokens:$,outputTokens:J,totalTokens:Number(Q?.total_tokens??$+J)},Y=Q?.input_token_details??Q?.input_tokens_details,G=Q?.output_token_details??Q?.output_tokens_details;if(typeof Y?.cached_tokens==="number")Z.cachedInputTokens=Y.cached_tokens;if(typeof Y?.audio_tokens==="number")Z.audioInputTokens=Y.audio_tokens;let V=Y?.cached_tokens_details?.audio_tokens;if(typeof V==="number")Z.cachedAudioInputTokens=V;if(typeof Y?.image_tokens==="number"&&Y.image_tokens>0)Z.imageInputTokens=Y.image_tokens;if(typeof G?.audio_tokens==="number")Z.audioOutputTokens=G.audio_tokens;return Z}class c extends Error{code;retryable;status;constructor(Q,$={}){super(Q.message,{cause:$.cause});if(this.name="RealtimeRequestError",this.code=Q.code,this.retryable=Q.retryable,$.status!==void 0)this.status=$.status}}var v5=60;class a{model;target;options;constructor(Q,$){this.target=Q,this.options=$,this.model=$.model}url(Q){return`${this.target.base}/realtime${Q}${this.target.query}`}sidebandUrl(Q){let $=this.target.base.replace(/^http(s?):/i,(Z,Y)=>`ws${Y}:`),J=this.target.query?`${this.target.query}&`:"?";return`${$}/realtime${J}call_id=${encodeURIComponent(Q)}`}async createCall(Q){let $=Q.flow??this.options.callFlow??"unified",J,Z;if($==="ephemeral")J={authorization:`Bearer ${(await this.clientSecret({session:Q.session,ttlSeconds:v5,signal:Q.signal})).value}`,"content-type":"application/sdp"},Z=Q.sdp;else{let j=new FormData;j.set("sdp",Q.sdp),j.set("session",JSON.stringify(r(Q.session??{},this.model))),J=await this.target.headers(),Z=j}if(Q.safetyIdentifier)J["OpenAI-Safety-Identifier"]=Q.safetyIdentifier;let Y=this.url("/calls"),G=await this.request(Q.webrtcFilter?`${Y}${Y.includes("?")?"&":"?"}webrtcfilter=on`:Y,{method:"POST",headers:J,body:Z},Q.signal),V=await G.text(),z=b5(G);if(!z)throw new c({code:"provider_error",message:"The provider started a realtime call but did not say which one (no Location).",retryable:!1});return{sdpAnswer:V,callId:z}}async clientSecret(Q={}){let $=Q.ttlSeconds??A5;if(!Number.isInteger($)||$<gQ||$>uQ)throw RangeError(`ttlSeconds must be a whole number from ${gQ} to ${uQ}, got ${$}.`);let J={...await this.target.headers(),"content-type":"application/json"};if(Q.safetyIdentifier)J["OpenAI-Safety-Identifier"]=Q.safetyIdentifier;let Y=await(await this.request(this.url("/client_secrets"),{method:"POST",headers:J,body:JSON.stringify({expires_after:{anchor:"created_at",seconds:$},session:r(Q.session??{},this.model)})},Q.signal)).json();if(typeof Y?.value!=="string")throw new c({code:"provider_error",message:"The provider answered a client secret request with no secret.",retryable:!1});return{value:Y.value,expiresAt:Number(Y.expires_at??0),session:Y.session,callsUrl:this.url("/calls")}}async hangup(Q,$={}){try{await this.request(this.url(`/calls/${encodeURIComponent(Q)}/hangup`),{method:"POST",headers:await this.target.headers()},$.signal)}catch(J){if(h5(J,Q))return;throw J}}sideband(Q,$={}){return new GQ({...$,callId:Q,url:this.sidebandUrl(Q),headers:this.target.headers,webSocket:$.webSocket??this.options.webSocket,hangup:()=>this.hangup(Q)})}async request(Q,$,J){try{return await u(Q,$,{maxRetries:this.target.maxRetries,timeoutMs:this.target.timeoutMs,retryTimeouts:!1,signal:J,fetchImpl:this.options.fetchImpl})}catch(Z){if(J?.aborted)throw Z;throw new c(x(Z),{cause:Z,...Z instanceof _?{status:Z.status}:{}})}}}function h5(Q,$){if(!(Q instanceof c)||Q.status!==404)return!1;let J=Q.cause instanceof _?Q.cause.body:void 0,Z=J?.error??J,Y=String(Z?.code??"").toLowerCase(),G=String(Z?.message??"").toLowerCase();if(Y.includes("call"))return!0;if(G.includes($.toLowerCase()))return!0;return/\bcall\b/.test(G)&&/not (be )?found|does not exist|no longer|ended/.test(G)}function b5(Q){let $=Q.headers.get("location");if(!$)return;let J=$.split("?")[0].replace(/\/+$/,""),Z=J.slice(J.lastIndexOf("/")+1);return Z?decodeURIComponent(Z):void 0}var y5={"response.audio_transcript.delta":"response.output_audio_transcript.delta","response.audio_transcript.done":"response.output_audio_transcript.done","response.text.delta":"response.output_text.delta","response.text.done":"response.output_text.done","response.audio.delta":"response.output_audio.delta","response.audio.done":"response.output_audio.done"};function f5(Q){if(typeof Q!=="string")return;let $;try{$=JSON.parse(Q)}catch{return}if(!$||typeof $!=="object"||typeof $.type!=="string")return;let J=y5[$.type];if(J)$.type=J;if($.type==="response.done"&&$.response?.usage)$.usage=VQ($.response.usage);if($.type==="conversation.item.input_audio_transcription.completed"&&$.usage)if($.usage.type==="duration"){let Z=Number($.usage.seconds);if(Number.isFinite(Z))$.transcriptionSeconds=Z}else $.transcriptionUsage=VQ($.usage);return $}var dQ=1,g5=500;function u5(Q,$){let J=globalThis.WebSocket;if(!J)throw Error("No global WebSocket: the realtime sideband needs Bun or Node 22+.");return new J(Q,{headers:$.headers})}class GQ{callId;ready;closed;init;socket;finalEvent;outbox=[];subscribers=new Set;listeners=new Set;backlog=[];closing=!1;finished=!1;everOpened=!1;failures=0;resolveReady;rejectReady;resolveClosed;constructor(Q){this.init=Q,this.callId=Q.callId,this.ready=new Promise(($,J)=>{this.resolveReady=$,this.rejectReady=J}),this.ready.catch(()=>{}),this.closed=new Promise(($)=>this.resolveClosed=$),this.open()}send(Q){if(this.finished||this.closing)return;let $=JSON.stringify(Q);if(this.socket?.readyState===dQ)this.socket.send($);else this.outbox.push($)}updateSession(Q){this.send({type:"session.update",session:r(Q)})}addItem(Q){this.send({type:"conversation.item.create",item:Q})}addNote(Q){this.addItem({type:"message",role:"system",content:[{type:"input_text",text:Q}]})}functionOutput(Q,$){this.addItem({type:"function_call_output",call_id:Q,output:typeof $==="string"?$:JSON.stringify($)})}createResponse(Q={}){let $={};if(Q.instructions!==void 0)$.instructions=Q.instructions;if(Q.toolChoice!==void 0)$.tool_choice=typeof Q.toolChoice==="string"?Q.toolChoice:{type:"function",name:Q.toolChoice.name};if(Q.outputModalities)$.output_modalities=Q.outputModalities;if(Q.conversation)$.conversation=Q.conversation;if(Q.metadata)$.metadata=Q.metadata;Object.assign($,Q.vendor),this.send(Object.keys($).length?{type:"response.create",response:$}:{type:"response.create"})}cancelResponse(Q){this.send(Q?{type:"response.cancel",response_id:Q}:{type:"response.cancel"})}on(Q){return this.listeners.add(Q),()=>this.listeners.delete(Q)}[Symbol.asyncIterator](){let Q={queue:this.backlog??[],done:this.finished};return this.backlog=void 0,this.subscribers.add(Q),{next:async()=>{for(;;){let J=Q.queue.shift();if(J)return{value:J,done:!1};if(Q.done)return this.subscribers.delete(Q),{value:void 0,done:!0};await new Promise((Z)=>Q.wake=Z),Q.wake=void 0}},return:async()=>{return Q.done=!0,Q.queue.length=0,this.subscribers.delete(Q),{value:void 0,done:!0}}}}close(Q=1000,$="closed"){if(this.finished||this.closing)return;if(this.closing=!0,this.socket&&this.socket.readyState<=dQ)this.socket.close(Q,$);else this.finish(Q,$,!0)}async hangup(){try{await this.init.hangup()}catch(Q){if(this.finalEvent&&!this.finalEvent.byClient&&this.finalEvent.code===1000)return;throw Q}this.close(1000,"hangup")}async open(){let Q;try{let J=await this.init.headers();if(this.closing)return this.finish(1000,"closed",!0);Q=(this.init.webSocket??u5)(this.init.url,{headers:J})}catch(J){return this.dropped(1006,J instanceof Error?J.message:String(J),!1)}this.socket=Q;let $=!1;Q.addEventListener("open",()=>{$=!0;let J=this.everOpened;this.everOpened=!0;let Z=this.failures;this.failures=0;for(let Y of this.outbox.splice(0))Q.send(Y);if(this.resolveReady(),J)this.emit({type:"sideband.reconnected",attempt:Z})}),Q.addEventListener("message",(J)=>{let Z=f5(J.data);if(Z)this.emit(Z)}),Q.addEventListener("close",(J)=>{if(this.socket!==Q)return;this.dropped(J.code??1006,J.reason??"",$)}),Q.addEventListener("error",()=>{})}dropped(Q,$,J){if(this.socket=void 0,this.closing)return this.finish(Q,$,!0);let Z=this.init.reconnect?.attempts??3;if(!((Q!==1000||!J)&&this.failures<Z))return this.finish(Q,$,!1);this.failures+=1;let G=(this.init.reconnect?.delayMs??500)*2**(this.failures-1);setTimeout(()=>void this.open(),G)}finish(Q,$,J){if(this.finished)return;this.finished=!0,this.outbox.length=0;let Z={type:"sideband.closed",code:Q,reason:$,byClient:J};this.finalEvent=Z,this.emit(Z);for(let Y of this.subscribers)Y.done=!0,Y.wake?.();if(!this.everOpened)this.rejectReady(Error(`Realtime sideband did not open (${Q} ${$}).`));this.resolveClosed(Z)}emit(Q){if(this.backlog){if(this.backlog.push(Q),this.backlog.length>g5)this.backlog.shift()}for(let $ of this.subscribers){if($.done)continue;$.queue.push(Q),$.wake?.()}for(let $ of this.listeners)try{$(Q)}catch{}}}var iQ=3;function KQ(Q){let $=new Map;for(let J of Q)for(let Z of J.content??[]){if(Z.type!=="file"||!Z.fileId||$.has(Z.fileId))continue;$.set(Z.fileId,{name:Z.name,mimeType:Z.mimeType})}return $}function nQ(Q,$,J=new Map){if(!($ instanceof _))return[];if($.status!==400&&$.status!==404)return[];let Z=BQ($.body);if(!Z)return[];let Y=c5(Q.input);if(Y.length===0)return[];let G=/^input\[(\d+)\]\.content\[(\d+)\]\.file_id$/.exec(Z.param??"");if(G){let K=Q.input[Number(G[1])],B=XQ(K)[Number(G[2])],H=B&&typeof B.file_id==="string"?B.file_id:void 0;if(H)return[H]}let V=Z.message??"",z=lQ(Y.map((K)=>K.fileId).filter((K)=>m5(V,K)));if(z.length>0)return z;let j=/Expected (image type|context stuffing file type) to be a supported format:.*but got \.([a-z0-9]+)\.?\s*$/is.exec(V);if(j){let K=j[1].toLowerCase()==="image type"?"input_image":"input_file",B=j[2].toLowerCase(),H=lQ(Y.filter((X)=>X.type===K).map((X)=>X.fileId)),W=H.filter((X)=>(J.get(X)?.name??"").trim().toLowerCase().endsWith(`.${B}`));if(W.length===1)return W;if(W.length===0&&H.length===1)return H}return[]}function rQ(Q,$,J=new Map){return{...Q,input:Q.input.map((Z)=>{let Y=XQ(Z);if(!Y.some((G)=>pQ(G,$)))return Z;return{...Z,content:Y.map((G)=>pQ(G,$)?{type:"input_text",text:m(J.get(String(G.file_id))?.name)}:G)}})}}function m(Q){return`[${Q?`attachment ${JSON.stringify(Q)}`:"an attachment"} could not be read by the provider and is not shown to you. Tell the user if it matters to the answer; uploading it again may help.]`}function pQ(Q,$){return typeof Q.file_id==="string"&&$.has(Q.file_id)}function XQ(Q){let $=Q?.content;return Array.isArray($)?$:[]}function c5(Q){let $=[];for(let J of Q)for(let Z of XQ(J))if(typeof Z.file_id==="string"&&Z.file_id)$.push({type:String(Z.type),fileId:Z.file_id});return $}function BQ(Q){if(!Q||typeof Q!=="object")return null;let $=Q,J=$.error&&typeof $.error==="object"?$.error:Q;return{message:typeof J.message==="string"?J.message:void 0,param:typeof J.param==="string"?J.param:void 0}}function m5(Q,$){let J=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(^|[^A-Za-z0-9_-])${J}($|[^A-Za-z0-9_-])`).test(Q)}function lQ(Q){return[...new Set(Q)]}function aQ(Q,$){if(!($ instanceof _))return null;if($.status!==400&&$.status!==404)return null;let J=Q?.input;if(!Array.isArray(J))return null;let Z=BQ($.body)?.message??"",Y=/Item with id '([^']+)' not found/i.exec(Z)?.[1];if(!Y)return null;let G=(V)=>V?.type==="reasoning";if(!J.some((V)=>G(V)&&V.id===Y))return null;return{...Q,input:J.filter((V)=>!G(V))}}async function*zQ(Q){let $="",J="",Z=[],Y,G=()=>{if(Z.length===0&&!J)return null;let j={event:J,data:Z.join(`
3
+ `),id:Y};return J="",Z=[],Y=void 0,j.data?j:null},V=(j)=>{let K=j.endsWith("\r")?j.slice(0,-1):j;if(K==="")return G();if(K.startsWith(":"))return null;let B=K.indexOf(":"),H=B===-1?K:K.slice(0,B),W=B===-1?"":K.slice(B+1);if(W.startsWith(" "))W=W.slice(1);if(H==="event")J=W;else if(H==="data")Z.push(W);else if(H==="id")Y=W;return null};for await(let j of Q){$+=j;let K=$.indexOf(`
4
+ `);while(K!==-1){let B=$.slice(0,K);$=$.slice(K+1);let H=V(B);if(H)yield H;K=$.indexOf(`
5
+ `)}}if($.length>0){let j=V($);if(j)yield j}let z=G();if(z)yield z}async function*sQ(Q,$={}){let J=new Map,Z=new Set,Y,G=!1,V,z=(j,K)=>({type:"finish",reason:j,usage:K,...V?{model:V}:{}});for await(let j of zQ(Q)){if(j.data==="[DONE]")break;let K;try{K=JSON.parse(j.data)}catch{continue}let B=typeof K.type==="string"?K.type:j.event,H=K.response?.model;if(typeof H==="string"&&H)V=H;switch(B){case"response.output_text.delta":{let W=String(K.delta??"");if(!W)break;yield $.structuredOutput?{type:"output-delta",delta:W}:{type:"text-delta",delta:W};break}case"response.reasoning_summary_text.delta":case"response.reasoning_text.delta":{let W=String(K.delta??"");if(!W)break;yield{type:"reasoning-delta",delta:W,id:K.item_id};break}case"response.output_item.added":{let W=K.item;if(!W)break;if(W.type==="function_call"){let X=String(W.id??K.item_id??W.call_id??"");J.set(X,{callId:String(W.call_id??X),name:String(W.name??""),namespace:typeof W.namespace==="string"&&W.namespace?W.namespace:void 0,done:!1})}break}case"response.function_call_arguments.delta":{let W=J.get(String(K.item_id??""));if(!W)break;let X=String(K.delta??"");if(!X)break;yield{type:"tool-call-delta",toolCallId:W.callId,name:W.name,argsDelta:X,...W.namespace?{namespace:W.namespace}:{}};break}case"response.function_call_arguments.done":{let W=String(K.item_id??""),X=J.get(W);if(!X)break;X.done=!0,yield{type:"tool-call",toolCallId:X.callId,name:X.name,args:String(K.arguments??""),...X.namespace?{namespace:X.namespace}:{}};break}case"response.output_item.done":{let W=K.item;if(!W)break;if(W.type==="function_call"){let X=String(W.id??K.item_id??W.call_id??""),q=J.get(X);if(q?.done)break;let U=(typeof W.namespace==="string"?W.namespace:"")||q?.namespace;if(yield{type:"tool-call",toolCallId:String(W.call_id??X),name:String(W.name??q?.name??""),args:String(W.arguments??""),...U?{namespace:U}:{}},q)q.done=!0;break}if(W.type==="tool_search_call"||W.type==="tool_search_output"){if(W.type==="tool_search_call"&&W.arguments!==void 0)Y=W.arguments;let X=d5(W);if(X.loaded.length===0&&X.namespaces.length===0)break;let q=String(W.tool_search_call_id??W.id??"");if(Z.has(q))break;Z.add(q);let U=Y;Y=void 0,yield{type:"tool-search",...X,...U!==void 0&&U!==null?{arguments:U}:{}}}break}case"response.refusal.done":{yield{type:"error",error:{code:"content_filtered",message:String(K.refusal??"The model refused to answer."),retryable:!1}};break}case"response.completed":{G=!0,yield z("stop",HQ(K.response?.usage));break}case"response.incomplete":{G=!0;let W=HQ(K.response?.usage),X=K.response?.incomplete_details?.reason;if(X==="content_filter"){yield{type:"error",error:{code:"content_filtered",message:p5(K.response?.content_filters),retryable:!1}},yield z("error",W);break}yield z(X==="max_output_tokens"?"length":"stop",W);break}case"response.failed":case"error":{G=!0;let W=K.response?.error??K.error??K;yield{type:"error",error:l5(W)},yield z("error",HQ(K.response?.usage));break}}if(G)return}if(!G)yield{type:"error",error:{code:"provider_error",message:"The provider stream ended without a terminal event.",retryable:!0}},yield z("error",M())}function d5(Q){let $=[],J=[];return oQ(Q.results??Q.tools??Q.loaded??Q.output,$,J,0),{loaded:jQ($),namespaces:jQ(J)}}function oQ(Q,$,J,Z){if(!Array.isArray(Q)||Z>4)return;for(let Y of Q){if(typeof Y==="string"){$.push(Y);continue}if(!Y||typeof Y!=="object")continue;let G=Y,V=typeof G.name==="string"?G.name:typeof G.tool_name==="string"?G.tool_name:"",z=G.tools??G.functions;if(Array.isArray(z)){if(V)J.push(V);oQ(z,$,J,Z+1);continue}if(V)$.push(V)}}function jQ(Q){return Q.filter(($,J)=>Q.indexOf($)===J)}function p5(Q){if(!Array.isArray(Q))return"The provider's content filter blocked this request.";let J=[];for(let Z of Q){if(!Z||typeof Z!=="object")continue;let Y=Z,G=Y.content_filter_results;if(!G||typeof G!=="object")continue;for(let[V,z]of Object.entries(G))if(z&&typeof z==="object"&&z.filtered===!0)J.push(`${V} (${String(Y.source_type??"unknown")})`)}return J.length===0?"The provider's content filter blocked this request.":`The provider's content filter blocked this request. Categories: ${jQ(J).join(", ")}.`}function l5(Q){let $=typeof Q?.message==="string"?Q.message:"The provider stream failed.",J=String(Q?.code??"").toLowerCase();if(J==="rate_limit_exceeded")return{code:"rate_limited",message:$,retryable:!0};if(J==="context_length_exceeded")return{code:"context_length_exceeded",message:$,retryable:!1};if(J.includes("content_filter"))return{code:"content_filtered",message:$,retryable:!1};return{code:"provider_error",message:$,retryable:!0}}function M(){return{inputTokens:0,outputTokens:0,totalTokens:0}}function HQ(Q){if(!Q)return M();let $=Number(Q.input_tokens??0),J=Number(Q.output_tokens??0),Z={inputTokens:$,outputTokens:J,totalTokens:Number(Q.total_tokens??$+J)},Y=Q.output_tokens_details?.reasoning_tokens;if(typeof Y==="number")Z.reasoningTokens=Y;let G=Q.input_tokens_details?.cached_tokens;if(typeof G==="number")Z.cachedInputTokens=G;return Z}async function*tQ(Q){if(!Q)return;let $=Q.getReader(),J=new TextDecoder;try{while(!0){let{done:Y,value:G}=await $.read();if(Y)break;if(G)yield J.decode(G,{stream:!0})}let Z=J.decode();if(Z)yield Z}finally{$.releaseLock()}}function t(Q){return{responsesUrl:`${Q.base}/responses${Q.query}`,filesUrl:`${Q.base}/files${Q.query}`,headers:Q.headers,timeoutMs:Q.timeoutMs,streamIdleTimeoutMs:Q.streamIdleTimeoutMs,streamMaxDurationMs:Q.streamMaxDurationMs,maxToolArgumentChars:Q.maxToolArgumentChars,maxRetries:Q.maxRetries,...Q.retry?{retry:Q.retry}:{}}}async function*e(Q,$,J){let Z=J.parse??sQ,Y=$,G=new Set,V=0,z=!1,j=Math.max(0,Q.maxRetries),K=Q.random??Math.random,B,H=(S)=>{if(!B)return S;let P=s(s(M(),B),S.usage);return B=void 0,{...S,usage:P}},W=()=>H({type:"finish",reason:"aborted",usage:M()}),X=Q.streamIdleTimeoutMs??0,q=Q.streamMaxDurationMs??0,U=Q.maxToolArgumentChars??0,O=Q.now??Date.now,N=O();for(let S=0;;S++){let P=new AbortController,y=J.signal?AbortSignal.any([J.signal,P.signal]):P.signal,w;while(w===void 0)try{let C=[],F=()=>{},L=u(Q.responsesUrl,{method:"POST",headers:{...await Q.headers(),"content-type":"application/json"},body:JSON.stringify(Y)},{maxRetries:Q.maxRetries,timeoutMs:Q.timeoutMs,signal:y,fetchImpl:Q.fetchImpl,sleep:Q.sleep,random:Q.random,now:Q.now,startedAt:N,...Q.retry?{retry:Q.retry}:{},onRetry:(k)=>{C.push({type:"retry",...k,phase:"request"}),F()}}),T=L.then(()=>!0,()=>!0);for(;;){let k=new Promise((l)=>F=()=>l(!1)),g=await Promise.race([T,k]);if(yield*C.splice(0),g)break}w=await L}catch(C){let F=Y,L=J.files&&V<iQ?nQ(F,C,J.files).filter((g)=>!G.has(g)):[];if(L.length>0){V++;let g=x(C).message;for(let l of L)G.add(l),yield{type:"file-rejected",fileId:l,message:g,...v(C)};Y=rQ(F,new Set(L),J.files);continue}let T=z?null:aQ(Y,C);if(T){z=!0,Y=T;continue}let k=x(C);if(k.code==="aborted"){yield W();return}yield{type:"error",error:k,...v(C)},yield H({type:"finish",reason:"error",usage:M()});return}let R=[],I=!1,A,kQ=!1,f=new Map;try{let C=fQ(w.body,{idleMs:X,maxMs:q},{idle:()=>{let F=new eQ(X);return P.abort(F),F},max:()=>{let F=new Q5(q);return P.abort(F),F}});for await(let F of Z(tQ(C),{structuredOutput:J.structuredOutput})){if(F.type==="tool-call-delta"){let L=(f.get(F.toolCallId)??0)+F.argsDelta.length;if(f.set(F.toolCallId,L),U>0&&L>U){let T=new qQ(U,F.name,F.toolCallId,L);throw P.abort(T),T}yield F;continue}if(F.type==="tool-call")f.delete(F.toolCallId);if(I){yield F.type==="finish"?H(F):F;continue}if(o(F)){I=!0,yield*R.splice(0),yield F;continue}if(F.type==="error")A=F.error;R.push(F)}}catch(C){kQ=C instanceof n;let F=x(C);if(F.code==="aborted"||J.signal?.aborted){yield W();return}if(I){yield{type:"error",error:F},yield H({type:"finish",reason:"error",usage:M()});return}A=F,R.push({type:"error",error:F,...C instanceof qQ?{toolArgumentsTooLong:C.detail}:{}},{type:"finish",reason:"error",usage:M()})}if(I)return;let p=!A?.retryable||J.signal?.aborted?void 0:S<j?i(S,K):Q.retry?ZQ(Q.retry,S-j,A.retryAfter,O()-N,K):void 0;if(p!==void 0){let C={};for(let L of R){if(L.type==="finish")B=s(B??M(),L.usage);if(L.type==="error")C=v(L)}if(f.size>0)yield{type:"tool-call-discard",toolCallIds:[...f.keys()]};let F=O()-N;yield{type:"retry",attempt:S+1,maxRetries:j,error:A,...C,phase:"stream",timedOut:kQ,delayMs:p,elapsedMs:F,...Q.retry?{remainingMs:Math.max(0,Q.retry.patienceMs-F-p)}:{}};try{await YQ(p,J.signal,Q.sleep)}catch{yield W();return}continue}for(let C of R)yield C.type==="finish"?H(C):C;return}}async function QQ(Q,$,J="user_data"){let Z=new FormData;if(J)Z.set("purpose",J);Z.set("file",$);let G=await(await u(Q.filesUrl,{method:"POST",headers:await Q.headers(),body:Z},{maxRetries:Q.maxRetries,timeoutMs:Q.timeoutMs,fetchImpl:Q.fetchImpl})).json();if(!G?.id)throw Error("The provider accepted the upload but returned no file id.");return G.id}function UQ(Q,$){let{capabilities:J}=$,Z={model:$.model,input:i5(Q.messages,J,Q.tools),stream:!0};if(Q.systemPrompt)Z.instructions=Q.systemPrompt;let Y=$6(Q.tools,J);if(Y.length>0){if(Z.tools=Y,!J.parallelToolCalls)Z.parallel_tool_calls=!1;if(Q.toolChoice!==void 0)Z.tool_choice=typeof Q.toolChoice==="string"?Q.toolChoice:{type:"function",name:Q.toolChoice.name}}if(Q.output)Z.text={format:{type:"json_schema",name:Q.output.name,schema:Q.output.schema,strict:Q.output.strict}};if(Q.reasoning&&J.reasoning)Z.reasoning=Q.reasoning==="none"?{effort:"none"}:{effort:Q.reasoning,summary:"auto"};if(typeof Q.temperature==="number")Z.temperature=Q.temperature;if(typeof Q.maxOutputTokens==="number")Z.max_output_tokens=Q.maxOutputTokens;if(Q.promptCacheKey)Z.prompt_cache_key=Q.promptCacheKey;return Z}function i5(Q,$,J){let Z=[],Y=new Map;if($.toolSearch){for(let G of J??[])if($Q(G))Y.set(G.name,G)}for(let G of Q){let V=G.role,z=!t5.has(G.finishReason),j=[],K=()=>{if(j.length===0)return;Z.push({type:"message",role:V,content:j}),j=[]};for(let B of G.content??[])switch(B.type){case"text":{if(!B.text)break;j.push(h(V,B.text));break}case"output":{if(B.partial)break;j.push(h(V,JSON.stringify(B.value)));break}case"file":{if(V==="assistant")break;let H=CQ(B);if(!$.fileInput){if(H)j.push(h(V,d(B,!1)));break}if(NQ(B,H),B.providerRejected){if(H)j.push(h(V,d(B,!1)));j.push(h(V,m(B.name)));break}if(H)j.push(h(V,d(B,!!B.fileId)));if(B.fileId)j.push(a5(B));break}case"reasoning":{if(K(),!z)break;let H=e5(B);if(H)Z.push(H);break}case"tool-call":{if(B.partial)break;if(K(),$.toolSearch&&Array.isArray(B.toolSearches))for(let W of B.toolSearches)Z.push(...Q6(W,J??[]));let H={type:"function_call",call_id:B.toolCallId,name:String(B.name),arguments:JSON.stringify(B.input??{})};if(B.namespace&&Y.has(B.namespace))H.namespace=B.namespace;Z.push(H);break}case"tool-result":{K(),Z.push({type:"function_call_output",call_id:B.toolCallId,output:PQ(B)});break}}K()}return r5(Z)}var n5="No result was recorded for this tool call. Assume it did not complete.";function r5(Q){let $=new Set,J=new Set,Z=[];for(let G of Q){if(G.type==="function_call"){let V=String(G.call_id);if($.has(V))continue;$.add(V)}else if(G.type==="function_call_output"){let V=String(G.call_id);if(!$.has(V)||J.has(V))continue;J.add(V)}Z.push(G)}if(J.size===$.size)return Z;let Y=[];for(let G of Z){if(Y.push(G),G.type!=="function_call")continue;let V=String(G.call_id);if(J.has(V))continue;J.add(V),Y.push({type:"function_call_output",call_id:V,output:n5})}return Y}function h(Q,$){return{type:Q==="assistant"?"output_text":"input_text",text:$}}function CQ(Q){let $=Q.attachmentId;return typeof $==="string"&&$.startsWith(FQ)?$:void 0}function d(Q,$){let J=[`id=${JSON.stringify(Q.attachmentId)}`];if(Q.name)J.push(`name=${JSON.stringify(Q.name)}`);if(Q.mimeType)J.push(`mimeType=${JSON.stringify(Q.mimeType)}`);let Z=`attachment ${J.join(" ")}`;return $?`[${Z}]`:`[${Z} \u2014 its contents are not shown to you; a tool can read the file by this id]`}function a5(Q){return{type:LQ(Q)?"input_image":"input_file",file_id:Q.fileId}}function LQ(Q){let $=Q.mimeType?.trim().toLowerCase()??"";return $?$.startsWith("image/")&&$!=="image/svg+xml":s5(Q.name)}function NQ(Q,$){if(Q.fileId?.startsWith(FQ))throw Error(`FilePart.fileId holds a gemi attachment id (${Q.fileId}). That field is the *provider's* file id, from \`fileId\` on the upload response; the \`attachmentId\` goes in \`FilePart.attachmentId\`, is shown to the model as text, and is resolved by a tool through \`ctx.attachments\`.`);if(!Q.fileId&&!$)throw Error("FilePart.fileId is empty and there is no `attachmentId` either. `fileId` is the *provider's* file id and `attachmentId` is gemi's (`gemi_att_\u2026`), both from the upload response; an upload always answers at least one, so a part with neither was built from something other than that answer.")}function s5(Q){let $=/\.([a-z0-9]+)$/.exec(Q?.trim().toLowerCase()??"");return $?.[1]!==void 0&&o5.has($[1])}var o5=new Set(["jpeg","jpg","png","gif","webp"]),t5=new Set(["error","aborted","interrupted"]);function e5(Q){if(!Q.id)return null;let $={type:"reasoning",id:Q.id};return $.summary=Q.text?[{type:"summary_text",text:Q.text}]:[],$}function PQ(Q){if(Q.status==="ok"){let $=Q.modelOutput!==void 0?Q.modelOutput:Q.output;return typeof $==="string"?$:JSON.stringify($??null)}if(Q.status==="running"){let $=Q.job?.summary===void 0?"":` Started with: ${JSON.stringify(Q.job.summary)}.`;return`Started background job ${Q.job?.id??"(unknown)"}. It is still running, so there is no result yet: this message will be replaced by the result when it finishes. Do not start it again.${$}`}if(Q.status==="denied"){let $=Q.reason?` Reason given: ${Q.reason}`:"";if(Q.cause==="stopped")return`The run was stopped before this tool call could complete, so it did not run.${$}`;if(Q.cause==="interrupted")return`The run was interrupted (the server stopped) while this tool call was in progress, so its result was lost. It may have run in part or in full: check its effects before repeating it.${$}`;if(Q.cause==="denied-earlier")return`The user already declined this tool call earlier in this conversation, so it did not run and they were not asked again. Do not ask for it again; carry on without it.${$}`;return`The user declined this tool call, so it did not run.${$}`}return`The tool call failed and produced no result. Error (${Q.error?.code??"unknown"}): ${Q.error?.message??"no message"}`}function Q6(Q,$){let J=new Set($5(Q?.loaded)),Z=$5(Q?.namespaces),Y=new Set(Z),G=[];for(let z of $)if($Q(z)){if(!Y.has(z.name))continue;let j=z.tools.filter((K)=>J.size===0||J.has(K.name));if(j.length===0)continue;G.push({type:"namespace",name:z.name,description:z.description,tools:j.map((K)=>b(K,!0))})}else if(z.deferred&&J.has(z.name))G.push(b(z,!0));if(G.length===0)return[];return[{type:"tool_search_call",call_id:null,execution:"server",status:"completed",arguments:Q.arguments&&typeof Q.arguments==="object"?Q.arguments:{paths:Z.length>0?Z:[...J]}},{type:"tool_search_output",call_id:null,execution:"server",status:"completed",tools:G}]}function $5(Q){return Array.isArray(Q)?Q.filter(($)=>typeof $==="string"):[]}function $Q(Q){return Array.isArray(Q.tools)}function $6(Q,$){if(!Q||Q.length===0)return[];if(!$.toolSearch){let Y=[];for(let G of Q)if($Q(G))for(let V of G.tools)Y.push(b(V,!1));else Y.push(b(G,!1));return Y}let J=[],Z=!1;for(let Y of Q)if($Q(Y)){let G=Y.tools.map((V)=>{if(V.deferred)Z=!0;return b(V,!0)});J.push({type:"namespace",name:Y.name,description:Y.description,tools:G})}else{if(Y.deferred)Z=!0;J.push(b(Y,!0))}if(Z)J.push({type:"tool_search"});return J}function b(Q,$){let J={type:"function",name:Q.name,description:Q.description,parameters:Q.parameters,strict:Q.strict};if($&&Q.deferred)J.defer_loading=!0;return J}var J6=64000;function J5(Q,$){let J={model:$.model,max_tokens:Q.maxOutputTokens??J6,messages:z6(Q.messages,$.capabilities),stream:!0},Z=Q.output,Y=!!Z?.strict&&!B6(Z.schema),G=Z&&!Y?H6(Z.schema):void 0,V=[Q.systemPrompt,G].filter(Boolean);if(V.length>0)J.system=[{type:"text",text:V.join(`
6
+
7
+ `)}];let z=$.capabilities.reasoning?Q.reasoning:void 0;if(z==="none"){if(/^claude-sonnet-5-5(?:-\d{8})?$/.test($.modelId))J.thinking={type:"between_tools"};J.output_config={effort:"low"}}else if(z)J.thinking={type:"adaptive",display:"summarized"},J.output_config={effort:Y6(z,$.modelId)};else if($.capabilities.reasoning&&Z6(J.messages))J.thinking={type:"adaptive"};if(J.thinking?.type==="adaptive"&&$.blockBinding)J.thinking.block_binding={prefix_mismatch_behavior:"drop_block"};if(Z&&Y)J.output_config={...J.output_config,format:{type:"json_schema",schema:X6(Z.schema)}};let j=O6(Q.tools);if(j.length>0){J.tools=j;let K=j6(Q.toolChoice,$.forcedToolChoice);if(!$.capabilities.parallelToolCalls)K.disable_parallel_tool_use=!0;if(Q.toolChoice!==void 0||K.disable_parallel_tool_use)J.tool_choice=K}return G6(J)}function Z6(Q){return Q.some(($)=>$.content.some((J)=>J.type==="thinking"||J.type==="redacted_thinking"))}var DQ="thinking-binding-controls-2026-08-01";function Z5(Q){if(/bound to a different conversation|Invalid `signature` in `thinking` block/i.test(Q))return"thinking";if(/schema is too complex/i.test(Q))return"schema";return}function Y5(Q){let $=[];for(let J of Q.messages){let Z=J.content.filter((G)=>G.type!=="thinking"&&G.type!=="redacted_thinking");if(Z.length===0)continue;let Y=$.at(-1);if(Y?.role===J.role)Y.content.push(...Z);else $.push({role:J.role,content:Z})}return{...Q,messages:$}}function Y6(Q,$){if(Q==="none"||Q==="minimal")return"low";if(Q==="xhigh"&&/^claude-(?:opus|sonnet)-4-6(?:-|$)/.test($))return"high";return Q}function G6(Q){let $=(Z)=>{if(Z)Z.cache_control={type:"ephemeral"}};$(Q.tools?.at(-1)),$(Q.system?.at(-1));let J=Q.messages.at(-1)?.content??[];return $([...J].reverse().find((Z)=>Z.type!=="thinking"&&Z.type!=="redacted_thinking")),Q}var W6=new Set(["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","minLength","maxLength","maxItems","uniqueItems"]),V6=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),K6=/\\[1-9]|\(\?<?[=!]|\\[bB]/,G5=new Set(["properties","patternProperties","$defs","definitions"]);function X6(Q){let $=(J)=>{if(Array.isArray(J))return J.map($);if(!E(J))return J;let Z={},Y=[];for(let[G,V]of Object.entries(J)){if(W6.has(G)||G==="minItems"&&typeof V==="number"&&V>1||G==="format"&&typeof V==="string"&&!V6.has(V)||G==="pattern"&&typeof V==="string"&&K6.test(V)){Y.push(`${G}: ${JSON.stringify(V)}`);continue}Z[G]=G5.has(G)&&E(V)?Object.fromEntries(Object.entries(V).map(([j,K])=>[j,$(K)])):$(V)}if(Y.length>0){let G=`{${Y.join(", ")}}`;Z.description=typeof Z.description==="string"?`${Z.description} ${G}`:G}if(Z.type==="object"||E(Z.properties))Z.additionalProperties=!1;return Z};return $(Q)}function B6(Q){let $=0,J=0,Z=(Y)=>{if(Array.isArray(Y))return Y.forEach(Z);if(!E(Y))return;if(Array.isArray(Y.anyOf)||Array.isArray(Y.type))J++;if(E(Y.properties)){let G=new Set(Array.isArray(Y.required)?Y.required:[]);$+=Object.keys(Y.properties).filter((V)=>!G.has(V)).length}for(let[G,V]of Object.entries(Y))if(G5.has(G)&&E(V))Object.values(V).forEach(Z);else Z(V)};return Z(Q),$>24||J>16}function H6(Q){return`Answer with only a JSON value (no prose, no code fence) that matches this JSON schema:
8
+ ${JSON.stringify(Q)}`}function j6(Q,$){if(Q==="none")return{type:"none"};if(Q==="required")return $?{type:"any"}:{type:"auto"};if(Q&&typeof Q==="object")return $?{type:"tool",name:Q.name}:{type:"auto"};return{type:"auto"}}function z6(Q,$){let J=[],Z=new Map;for(let B of Q){let H=B.role==="assistant"?"assistant":"user";J.push("step-end");for(let W of B.content??[])switch(W.type){case"text":{if(H==="assistant"?!!W.text:!!W.text?.trim())J.push({role:H,block:{type:"text",text:W.text}});break}case"output":{if(W.partial)break;let X=W.text??JSON.stringify(W.value);J.push({role:H,block:{type:"text",text:X}});break}case"file":{if(H==="assistant")break;for(let X of N6(W,$))J.push({role:H,block:X});break}case"reasoning":{let X=H==="assistant"?L6(W):void 0;if(X)J.push({role:H,block:X});break}case"tool-call":{if(W.partial)break;J.push({role:"assistant",block:{type:"tool_use",id:W.toolCallId,name:String(W.name),input:E(W.input)?W.input:{}}});break}case"tool-result":{if(J.push("step-end"),Z.has(W.toolCallId))break;Z.set(W.toolCallId,{type:"tool_result",tool_use_id:W.toolCallId,content:PQ(W),...W.status==="error"?{is_error:!0}:{}});break}}}let Y=[],G=(B,H)=>{let W=Y[Y.length-1];if(W&&W.role===B)W.content.push(H);else Y.push({role:B,content:[H]})},V=new Set,z=[],j=!1,K=()=>{for(let B of z)G("user",Z.get(B)??C6(B));z=[],j=!1};for(let B of J){if(B==="step-end"){j=!0;continue}let{role:H,block:W}=B;if(j||H==="user")K();if(W.type==="tool_use"){let X=String(W.id);if(V.has(X))continue;V.add(X),z.push(X)}G(H,W)}if(K(),Y[0]?.role==="assistant")Y.unshift({role:"user",content:[{type:"text",text:q6}]});if(Y.at(-1)?.role==="assistant")Y.push({role:"user",content:[{type:"text",text:F6}]});return Y}var q6="(The conversation continues from an earlier point.)",F6="Continue.",U6="No result was recorded for this tool call. Assume it did not complete.";function C6(Q){return{type:"tool_result",tool_use_id:Q,content:U6}}function L6(Q){let $=Q.providerMetadata?.anthropic;if(!E($))return;if($.type==="thinking"&&typeof $.signature==="string")return{type:"thinking",thinking:Q.text??"",signature:$.signature};if($.type==="redacted_thinking"&&typeof $.data==="string")return{type:"redacted_thinking",data:$.data};return}function N6(Q,$){let J=CQ(Q),Z=(G)=>J?[{type:"text",text:d(Q,G)}]:[];if(!$.fileInput)return Z(!1);if(NQ(Q,J),!Q.fileId)return Z(!1);let Y=Q.providerRejected?void 0:D6(Q);if(!Y)return[...Z(!1),{type:"text",text:m(Q.name)}];return[...Z(!0),{type:Y,source:{type:"file",file_id:Q.fileId}}]}var P6=new Set(["image/jpeg","image/png","image/gif","image/webp"]);function D6(Q){let $=Q.mimeType?.trim().toLowerCase()??"";if(LQ(Q))return!$||P6.has($)?"image":void 0;if($)return $==="application/pdf"||$==="text/plain"?"document":void 0;return/\.(pdf|txt)$/i.test(Q.name??"")?"document":void 0}function E(Q){return!!Q&&typeof Q==="object"&&!Array.isArray(Q)}function x6(Q){return Array.isArray(Q.tools)}function O6(Q){let $=[];for(let J of Q??[])for(let Z of x6(J)?J.tools:[J])$.push({name:Z.name,description:Z.description,input_schema:Z.parameters,eager_input_streaming:!0});return $}async function*X5(Q,$={}){let J=new Map,Z=[],Y,G={},V,z,j=!1,K=(B)=>({type:"finish",reason:B,usage:I6(G),...Y?{model:Y}:{}});for await(let B of zQ(Q)){let H;try{H=JSON.parse(B.data)}catch{continue}switch(typeof H.type==="string"?H.type:B.event){case"message_start":{let X=H.message??{};if(typeof X.model==="string"&&X.model)Y=X.model;G=K5(G,X.usage);break}case"content_block_start":{let X=Number(H.index),q=H.content_block??{},U={type:String(q.type??""),id:typeof q.id==="string"?q.id:void 0,name:typeof q.name==="string"?q.name:void 0,args:"",signature:typeof q.signature==="string"?q.signature:""};if(J.set(X,U),U.type==="redacted_thinking")yield{type:"reasoning-delta",delta:"",providerMetadata:{anthropic:{type:"redacted_thinking",data:String(q.data??"")}}};if(U.type==="text"&&typeof q.text==="string"&&q.text)yield V5(q.text,$);break}case"content_block_delta":{let X=J.get(Number(H.index)),q=H.delta??{};if(!X)break;if(q.type==="text_delta"){let U=String(q.text??"");if(U)yield V5(U,$)}else if(q.type==="thinking_delta"){let U=String(q.thinking??"");if(U)yield{type:"reasoning-delta",delta:U}}else if(q.type==="signature_delta")X.signature+=String(q.signature??"");else if(q.type==="input_json_delta"&&X.type==="tool_use"){let U=String(q.partial_json??"");if(!U)break;X.args+=U,yield{type:"tool-call-delta",toolCallId:X.id??"",name:X.name??"",argsDelta:U}}break}case"content_block_stop":{let X=Number(H.index),q=J.get(X);if(J.delete(X),q?.type==="thinking")yield{type:"reasoning-delta",delta:"",providerMetadata:{anthropic:{type:"thinking",signature:q.signature}}};if(q?.type==="tool_use")if(q.args||="{}",S6(q.args))yield W5(q);else Z.push(q);break}case"message_delta":{if(typeof H.delta?.stop_reason==="string")V=H.delta.stop_reason;if(H.delta?.stop_details)z=H.delta.stop_details;G=K5(G,H.usage);break}case"message_stop":{if(j=!0,V==="refusal"){yield{type:"error",error:_6(z)},yield K("error");break}let X=M6(V);if(Z.length>0&&X==="length")yield{type:"tool-call-discard",toolCallIds:Z.map((q)=>q.id??"")};else for(let q of Z)yield W5(q);yield K(X);break}case"error":{j=!0,yield{type:"error",error:R6(H.error??H)},yield K("error");break}}if(j)return}yield{type:"error",error:{code:"provider_error",message:"The provider stream ended without a terminal event.",retryable:!0}},yield K("error")}function W5(Q){return{type:"tool-call",toolCallId:Q.id??"",name:Q.name??"",args:Q.args}}function S6(Q){try{return JSON.parse(Q),!0}catch{return!1}}function V5(Q,$){return $.structuredOutput?{type:"output-delta",delta:Q}:{type:"text-delta",delta:Q}}function M6(Q){if(Q==="max_tokens"||Q==="model_context_window_exceeded")return"length";return"stop"}function _6(Q){let $=typeof Q?.explanation==="string"?Q.explanation:"",J=typeof Q?.category==="string"?` (${Q.category})`:"";return{code:"content_filtered",message:$||`The model declined to answer${J}.`,retryable:!1}}function R6(Q){let $=String(Q?.type??"").toLowerCase(),J=typeof Q?.message==="string"?Q.message:"The provider stream failed.";if($==="rate_limit_error")return{code:"rate_limited",message:J,retryable:!0};if($==="invalid_request_error"||$==="request_too_large")return{code:/prompt is too long|request_too_large/i.test(`${$} ${J}`)?"context_length_exceeded":"provider_error",message:J,retryable:!1};if($==="authentication_error"||$==="permission_error"||$==="billing_error"||$==="not_found_error")return{code:"provider_error",message:J,retryable:!1};return{code:"provider_error",message:J,retryable:!0}}function K5(Q,$){if(!$||typeof $!=="object")return Q;let J={...Q};for(let Y of["input_tokens","output_tokens","cache_creation_input_tokens","cache_read_input_tokens"])if(typeof $[Y]==="number")J[Y]=$[Y];let Z=$.output_tokens_details?.thinking_tokens;if(typeof Z==="number")J.thinking_tokens=Z;return J}function I6(Q){if(!Q)return M();let{cache_read_input_tokens:$,cache_creation_input_tokens:J}=Q,Z=(Q.input_tokens??0)+($??0)+(J??0),Y=Q.output_tokens??0,G={inputTokens:Z,outputTokens:Y,totalTokens:Z+Y};if(typeof $==="number")G.cachedInputTokens=$;if(typeof J==="number")G.cacheWriteInputTokens=J;if(typeof Q.thinking_tokens==="number")G.reasoningTokens=Q.thinking_tokens;return G}function xQ(Q){let $=SQ(Q);if($.startsWith("gpt-3.5")||$.startsWith("text-")||$.startsWith("davinci"))return{reasoning:!1,structuredOutput:!1,fileInput:!1,parallelToolCalls:!0,toolSearch:!1,supportsForcedToolChoice:!0};let J=E6($);if(J?.kind==="o")return{reasoning:!0,structuredOutput:!0,fileInput:!0,parallelToolCalls:J.major>1,toolSearch:B5(J),supportsForcedToolChoice:!0};if(J?.kind==="gpt")return{reasoning:J.major>=5,structuredOutput:J.major>4||$.startsWith("gpt-4o")||$.startsWith("gpt-4.1"),fileInput:J.major>4||$.startsWith("gpt-4o")||$.startsWith("gpt-4.1"),parallelToolCalls:!0,toolSearch:B5(J),supportsForcedToolChoice:!0};return{reasoning:!0,structuredOutput:!0,fileInput:!0,parallelToolCalls:!0,toolSearch:!0,supportsForcedToolChoice:!0}}function B5(Q){if(Q.kind==="o")return Q.major>=5;return Q.major>5||Q.major===5&&Q.minor>=2}function OQ(Q){let $=SQ(Q),J=/^claude-(?:opus|sonnet|haiku)-4(?:-(\d{1,2}))?(?:-\d{8})?$/.exec($);return{reasoning:!(/^claude-(?:3|2|instant)/.test($)||!!J&&Number(J[1]??0)<=5),structuredOutput:!0,fileInput:!0,parallelToolCalls:!0,toolSearch:!1,supportsForcedToolChoice:A6(Q)}}function A6(Q){let $=SQ(Q);return/^claude-(?:3|2|instant)/.test($)||/^claude-(?:opus|sonnet|haiku)-4(?:-|$)/.test($)||/^claude-(?:opus|sonnet|fable|mythos)-5(?:-\d{8})?$/.test($)||/^claude-haiku-5-5(?:-\d{8})?$/.test($)}function SQ(Q){return Q.trim().toLowerCase()}function E6(Q){let $=/^gpt-(\d+)(?:\.(\d+))?/.exec(Q);if($?.[1])return{kind:"gpt",major:Number($[1]),minor:Number($[2]??0)};let J=/^o(\d+)(?:[-.]|$)/.exec(Q);if(J?.[1])return{kind:"o",major:Number(J[1]),minor:0};return null}var MQ=120000,_Q=2,RQ=120000,IQ=300000;function D(Q){return typeof process>"u"?void 0:process.env?.[Q]}var T6="preview";function H5(Q){let $=Q.trim().replace(/\/+$/,"");if(!$)return"";return`${$.replace(/\/openai(?:\/v1)?$/i,"")}/openai`}function w6(Q){return/^\d{4}-\d{2}-\d{2}/.test(Q)?"":"/v1"}function AQ(Q,$={}){return{base:(Q.baseURL??D("OPENAI_BASE_URL")??"https://api.openai.com/v1").replace(/\/+$/,""),query:"",headers:async()=>{let Z=Q.apiKey??D("OPENAI_API_KEY");return{...Z?{authorization:`Bearer ${Z}`}:{},...Q.headers}},timeoutMs:Q.timeoutMs??$.timeoutMs??MQ,streamIdleTimeoutMs:Q.streamIdleTimeoutMs??RQ,streamMaxDurationMs:Q.streamMaxDurationMs??IQ,maxToolArgumentChars:Q.maxToolArgumentChars??0,maxRetries:Q.maxRetries??_Q,...TQ(Q)}}function j5(Q){let $=Q.baseURL??Q.endpoint??D("AZURE_OPENAI_ENDPOINT");if($)return H5($);let J=Q.resourceName??D("AZURE_OPENAI_RESOURCE_NAME")??D("AZURE_RESOURCE_NAME");return J?H5(`https://${J.trim()}.cognitiveservices.azure.com`):""}function EQ(Q,$={}){let J=Q.apiVersion??D("AZURE_OPENAI_API_VERSION")??T6;return{base:`${j5(Q)}${w6(J)}`,query:`?api-version=${encodeURIComponent(J)}`,headers:async()=>{if(Q.getToken)return{authorization:`Bearer ${await Q.getToken()}`,...Q.headers};let Z=Q.apiKey??D("AZURE_OPENAI_API_KEY");return{...Z?{"api-key":Z}:{},...Q.headers}},timeoutMs:Q.timeoutMs??$.timeoutMs??MQ,streamIdleTimeoutMs:Q.streamIdleTimeoutMs??RQ,streamMaxDurationMs:Q.streamMaxDurationMs??IQ,maxToolArgumentChars:Q.maxToolArgumentChars??0,maxRetries:Q.maxRetries??_Q,...TQ(Q)}}var k6="2026-10-21";function z5(Q,$={}){let J=Q.baseURL??D("ANTHROPIC_BASE_URL")??"https://api.anthropic.com";return F5(J,Q,$,async()=>{let Z=Q.workspaceId??D("ANTHROPIC_WORKSPACE_ID"),Y=Z?{"anthropic-workspace-id":Z}:{},G=Q.apiKey??D("ANTHROPIC_API_KEY");if(G)return{"x-api-key":G,...Y};let V=D("ANTHROPIC_AUTH_TOKEN");return V?{authorization:`Bearer ${V}`,...Y}:Y})}function q5(Q,$={}){let J=Q.resourceName??D("ANTHROPIC_FOUNDRY_RESOURCE"),Z=Q.baseURL??Q.endpoint??D("ANTHROPIC_FOUNDRY_BASE_URL")??(J?`https://${J.trim()}.services.ai.azure.com/anthropic`:"");if(!Z.trim())throw Error("AzureAnthropicProvider has no Foundry endpoint. Set `endpoint` (the deployment's Target URI without `/v1/messages`, e.g. `https://<resource>.services.ai.azure.com/anthropic`) or `resourceName`, or the ANTHROPIC_FOUNDRY_BASE_URL or ANTHROPIC_FOUNDRY_RESOURCE environment variable.");return F5(Z,Q,$,async()=>{if(Q.getToken)return{authorization:`Bearer ${await Q.getToken()}`};let Y=Q.apiKey??D("ANTHROPIC_FOUNDRY_API_KEY");return Y?{"api-key":Y}:{}})}function F5(Q,$,J,Z){return{base:`${Q.trim().replace(/\/+$/,"").replace(/\/v1$/,"")}/v1`,query:"",headers:async()=>({...await Z(),"anthropic-version":k6,...$.headers}),timeoutMs:$.timeoutMs??J.timeoutMs??MQ,streamIdleTimeoutMs:$.streamIdleTimeoutMs??RQ,streamMaxDurationMs:$.streamMaxDurationMs??IQ,maxToolArgumentChars:$.maxToolArgumentChars??0,maxRetries:$.maxRetries??_Q,...TQ($)}}function U5(Q,$={}){return{...EQ(Q,$),base:`${j5(Q)}/v1`,query:""}}function TQ(Q){return vQ(Q.retry),Q.retry?{retry:Q.retry}:{}}class JQ{static models(){return[]}normalizeError(Q){return x(Q)}}var C5=["gpt-5.5","gpt-5.4","gpt-5.4-mini","gpt-5.4-nano","gpt-5.2","gpt-5.1","gpt-5","gpt-5-mini","gpt-5-nano","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","gpt-4o","gpt-4o-mini","o4-mini","o3","o3-mini"];class L5 extends JQ{model;capabilities;config;constructor(Q,$={}){super();this.model=Q,this.capabilities=xQ(Q),this.config=$}static model(Q,$){return new L5(Q,$)}static models(){return C5}stream(Q){let $=UQ(Q,{model:this.model,capabilities:this.capabilities});return e(this.endpoint(),$,{signal:Q.signal,structuredOutput:Boolean(Q.output),files:KQ(Q.messages)})}upload(Q){return QQ(this.endpoint(),Q)}endpoint(){return t(AQ(this.config))}get realtime(){return new a(AQ(this.config,{timeoutMs:WQ}),{model:this.model})}}var v6=["claude-opus-5-5","claude-sonnet-5-5","claude-haiku-5-5","claude-fable-5-2","claude-fable-5-1","claude-opus-5","claude-sonnet-5","claude-fable-5","claude-opus-4-8","claude-sonnet-4-6","claude-haiku-4-5"];class wQ extends JQ{model;capabilities;config;constructor(Q,$={}){super();this.model=Q,this.capabilities=OQ(Q),this.config=$}static model(Q,$){return new wQ(Q,$)}static models(){return v6}stream(Q){return this.send(Q)}async*send(Q){let $=Q,J=!1,Z=new Set;for(;;){let Y=this.request($);if(J)Y=Y5(Y);let G,V=!1;for await(let z of e(this.endpointFor(Y),Y,{signal:Q.signal,structuredOutput:Boolean(Q.output),parse:X5})){if(G)continue;if(!V&&z.type==="error"&&z.status===400){let j=Z5(z.error.message);if(j&&!Z.has(j)){Z.add(j),G=j;continue}}if(o(z))V=!0;yield z}if(!G)return;if(G==="thinking")J=!0;else if($.output)$={...$,output:{...$.output,strict:!1}}}}request(Q){return J5(Q,{model:this.deployment(),modelId:this.model,capabilities:this.capabilities,forcedToolChoice:this.capabilities.supportsForcedToolChoice!==!1,blockBinding:this.bindsThinking()})}endpointFor(Q){let $=this.endpoint();if(!(Q.thinking?.type==="adaptive"&&Q.thinking.block_binding))return $;return{...$,headers:async()=>{let Z=await $.headers(),Y=Z["anthropic-beta"];return{...Z,"anthropic-beta":Y?`${Y},${DQ}`:DQ}}}}bindsThinking(){return!0}deployment(){return this.model}upload(Q){return QQ(this.endpoint(),Q,null)}endpoint(){return N5(z5(this.config))}}function N5(Q){return{...t(Q),responsesUrl:`${Q.base}/messages`}}class P5 extends wQ{constructor(Q,$={}){super(Q,$);this.capabilities={...OQ(Q),fileInput:!1}}static model(Q,$){return new P5(Q,$)}upload(Q){return Promise.reject(Error("AzureAnthropicProvider does not upload files: the Files API is not available on Azure-hosted Foundry deployments. The file is still stored by gemi and named to the model by its attachment id."))}deployment(){return this.config.deployment??this.model}bindsThinking(){return!1}endpoint(){return N5(q5(this.config))}}class D5 extends JQ{model;capabilities;config;constructor(Q,$={}){super();this.model=Q,this.capabilities=xQ(Q),this.config=$}static model(Q,$){return new D5(Q,$)}static models(){return C5}stream(Q){let $=UQ(Q,{model:this.deployment(),capabilities:this.capabilities});return e(this.endpoint(),$,{signal:Q.signal,structuredOutput:Boolean(Q.output),files:KQ(Q.messages)})}upload(Q){return QQ(this.endpoint(),Q,"assistants")}deployment(){return this.config.deployment??this.model}endpoint(){return t(EQ(this.config))}get realtime(){return new a(U5(this.config,{timeoutMs:WQ}),{model:this.deployment(),callFlow:"ephemeral"})}}
9
+ export{u as ca,AQ as da,EQ as ea,GQ as fa,E5 as ga,VQ as ha,c as ia,a as ja,h5 as ka,JQ as la,L5 as ma,wQ as na,P5 as oa,D5 as pa};
10
+
11
+ //# debugId=76A7D73A6FE0824364756E2164756E21