gemi 0.84.1 → 0.85.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 (269) hide show
  1. package/dist/ai/Agent.d.ts +41 -3
  2. package/dist/ai/Agent.d.ts.map +1 -1
  3. package/dist/ai/AgentController.d.ts +238 -0
  4. package/dist/ai/AgentController.d.ts.map +1 -1
  5. package/dist/ai/AgentProvider.d.ts +15 -0
  6. package/dist/ai/AgentProvider.d.ts.map +1 -1
  7. package/dist/ai/client/index.d.ts +2 -2
  8. package/dist/ai/client/index.d.ts.map +1 -1
  9. package/dist/ai/client/index.js +138 -35
  10. package/dist/ai/client/index.js.map +1 -1
  11. package/dist/ai/client/reducer.d.ts +7 -1
  12. package/dist/ai/client/reducer.d.ts.map +1 -1
  13. package/dist/ai/generate.d.ts.map +1 -1
  14. package/dist/ai/index.d.ts +4 -2
  15. package/dist/ai/index.d.ts.map +1 -1
  16. package/dist/ai/index.js +12 -12
  17. package/dist/ai/index.js.map +19 -16
  18. package/dist/ai/providers/call.d.ts +4 -0
  19. package/dist/ai/providers/call.d.ts.map +1 -1
  20. package/dist/ai/providers/fileRejection.d.ts +84 -0
  21. package/dist/ai/providers/fileRejection.d.ts.map +1 -0
  22. package/dist/ai/providers/request.d.ts.map +1 -1
  23. package/dist/ai/redact.d.ts +70 -0
  24. package/dist/ai/redact.d.ts.map +1 -0
  25. package/dist/ai/signing.d.ts +33 -4
  26. package/dist/ai/signing.d.ts.map +1 -1
  27. package/dist/ai/store/Attachments.d.ts +5 -3
  28. package/dist/ai/store/Attachments.d.ts.map +1 -1
  29. package/dist/ai/store/FileOwners.d.ts +59 -0
  30. package/dist/ai/store/FileOwners.d.ts.map +1 -0
  31. package/dist/ai/store/LiveRuns.d.ts +25 -0
  32. package/dist/ai/store/LiveRuns.d.ts.map +1 -1
  33. package/dist/ai/store/MemoryAgentStore.d.ts +1 -0
  34. package/dist/ai/store/MemoryAgentStore.d.ts.map +1 -1
  35. package/dist/ai/store/Nonces.d.ts +109 -0
  36. package/dist/ai/store/Nonces.d.ts.map +1 -0
  37. package/dist/ai/store/index.d.ts +2 -0
  38. package/dist/ai/store/index.d.ts.map +1 -1
  39. package/dist/ai/types.d.ts +30 -1
  40. package/dist/ai/types.d.ts.map +1 -1
  41. package/dist/ai/useChat.d.ts +62 -3
  42. package/dist/ai/useChat.d.ts.map +1 -1
  43. package/dist/app/index.js +1 -1
  44. package/dist/bun/plugin.js +1 -1
  45. package/dist/bun/preload.js +1 -1
  46. package/dist/{chunk-82nn71zs.js → chunk-09sr33ff.js} +2 -2
  47. package/dist/{chunk-82nn71zs.js.map → chunk-09sr33ff.js.map} +1 -1
  48. package/dist/chunk-174jkg6d.js +7 -0
  49. package/dist/{chunk-302mkqeq.js.map → chunk-174jkg6d.js.map} +9 -8
  50. package/dist/{chunk-87x692j7.js → chunk-1b5s4w5f.js} +2 -2
  51. package/dist/{chunk-87x692j7.js.map → chunk-1b5s4w5f.js.map} +1 -1
  52. package/dist/{chunk-rmv1jp9p.js → chunk-1jcp8m8h.js} +2 -2
  53. package/dist/{chunk-rmv1jp9p.js.map → chunk-1jcp8m8h.js.map} +1 -1
  54. package/dist/{chunk-g6qe6wyb.js → chunk-1w5a11cd.js} +2 -2
  55. package/dist/{chunk-g6qe6wyb.js.map → chunk-1w5a11cd.js.map} +1 -1
  56. package/dist/chunk-1wby1sr2.js +5 -0
  57. package/dist/{chunk-e43drft2.js.map → chunk-1wby1sr2.js.map} +3 -3
  58. package/dist/{chunk-vmpzg4z5.js → chunk-1yq1e6sb.js} +3 -3
  59. package/dist/{chunk-vmpzg4z5.js.map → chunk-1yq1e6sb.js.map} +1 -1
  60. package/dist/chunk-1yzdxv2a.js +5 -0
  61. package/dist/{chunk-tmwsvf02.js.map → chunk-1yzdxv2a.js.map} +1 -1
  62. package/dist/{chunk-ah9ajys0.js → chunk-2gdhcswa.js} +1 -1
  63. package/dist/chunk-2k5kyk0h.js +24 -0
  64. package/dist/chunk-2k5kyk0h.js.map +17 -0
  65. package/dist/{chunk-1evk2pma.js → chunk-2yw23zhn.js} +4 -4
  66. package/dist/{chunk-1evk2pma.js.map → chunk-2yw23zhn.js.map} +1 -1
  67. package/dist/{chunk-3z6wkvwj.js → chunk-4ysar3ev.js} +2 -2
  68. package/dist/{chunk-3z6wkvwj.js.map → chunk-4ysar3ev.js.map} +1 -1
  69. package/dist/{chunk-z409rk5j.js → chunk-4zj05vry.js} +2 -2
  70. package/dist/{chunk-z409rk5j.js.map → chunk-4zj05vry.js.map} +1 -1
  71. package/dist/{chunk-1cebv3h8.js → chunk-55x9kkdt.js} +2 -2
  72. package/dist/{chunk-1cebv3h8.js.map → chunk-55x9kkdt.js.map} +1 -1
  73. package/dist/{chunk-0agfx93f.js → chunk-5ktfpty1.js} +2 -2
  74. package/dist/{chunk-0agfx93f.js.map → chunk-5ktfpty1.js.map} +1 -1
  75. package/dist/chunk-6k2czkkh.js +55 -0
  76. package/dist/{chunk-rp5j1mgk.js.map → chunk-6k2czkkh.js.map} +3 -3
  77. package/dist/{chunk-3zb2ycxj.js → chunk-7c33ngqs.js} +2 -2
  78. package/dist/{chunk-3zb2ycxj.js.map → chunk-7c33ngqs.js.map} +1 -1
  79. package/dist/{chunk-en3mtnsg.js → chunk-7n5775qx.js} +2 -2
  80. package/dist/{chunk-en3mtnsg.js.map → chunk-7n5775qx.js.map} +1 -1
  81. package/dist/{chunk-bn9pzgww.js → chunk-7nj2t2gm.js} +2 -2
  82. package/dist/{chunk-bn9pzgww.js.map → chunk-7nj2t2gm.js.map} +1 -1
  83. package/dist/{chunk-kfavcgv2.js → chunk-81k26w39.js} +2 -2
  84. package/dist/{chunk-kfavcgv2.js.map → chunk-81k26w39.js.map} +1 -1
  85. package/dist/{chunk-cg4k40zy.js → chunk-81v4c4b1.js} +2 -2
  86. package/dist/{chunk-cg4k40zy.js.map → chunk-81v4c4b1.js.map} +1 -1
  87. package/dist/{chunk-wh728wd6.js → chunk-8gexb1gt.js} +2 -2
  88. package/dist/{chunk-wh728wd6.js.map → chunk-8gexb1gt.js.map} +1 -1
  89. package/dist/{chunk-zfch4da5.js → chunk-9tsw1bmt.js} +2 -2
  90. package/dist/{chunk-8mmfpqgs.js.map → chunk-9tsw1bmt.js.map} +1 -1
  91. package/dist/{chunk-m0zba09s.js → chunk-9tv5j3b2.js} +3 -3
  92. package/dist/{chunk-m0zba09s.js.map → chunk-9tv5j3b2.js.map} +1 -1
  93. package/dist/{chunk-jg9eqd3r.js → chunk-c3gzpjba.js} +1 -1
  94. package/dist/{chunk-r5e4vpa1.js → chunk-cbycz5z3.js} +2 -2
  95. package/dist/{chunk-r5e4vpa1.js.map → chunk-cbycz5z3.js.map} +1 -1
  96. package/dist/{chunk-cfvq30n4.js → chunk-cfykfnqx.js} +2 -2
  97. package/dist/{chunk-cfvq30n4.js.map → chunk-cfykfnqx.js.map} +1 -1
  98. package/dist/{chunk-eysexnqb.js → chunk-ct7wxm98.js} +2 -2
  99. package/dist/{chunk-eysexnqb.js.map → chunk-ct7wxm98.js.map} +1 -1
  100. package/dist/{chunk-v27a4se1.js → chunk-d3jkypc7.js} +3 -3
  101. package/dist/{chunk-v27a4se1.js.map → chunk-d3jkypc7.js.map} +1 -1
  102. package/dist/{chunk-vfrrzr10.js → chunk-dadygfkf.js} +2 -2
  103. package/dist/{chunk-vfrrzr10.js.map → chunk-dadygfkf.js.map} +1 -1
  104. package/dist/{chunk-m4xw99vm.js → chunk-dwqh79e5.js} +2 -2
  105. package/dist/{chunk-m4xw99vm.js.map → chunk-dwqh79e5.js.map} +1 -1
  106. package/dist/{chunk-ng8pp9k2.js → chunk-fbwe0agk.js} +2 -2
  107. package/dist/{chunk-ng8pp9k2.js.map → chunk-fbwe0agk.js.map} +1 -1
  108. package/dist/{chunk-495qwteq.js → chunk-fc2je244.js} +3 -3
  109. package/dist/{chunk-495qwteq.js.map → chunk-fc2je244.js.map} +1 -1
  110. package/dist/{chunk-gr61ymse.js → chunk-gx0x772p.js} +2 -2
  111. package/dist/{chunk-gr61ymse.js.map → chunk-gx0x772p.js.map} +1 -1
  112. package/dist/{chunk-tdnfhe7x.js → chunk-ha705bcz.js} +3 -3
  113. package/dist/{chunk-tdnfhe7x.js.map → chunk-ha705bcz.js.map} +1 -1
  114. package/dist/chunk-jhe0t7yj.js +5 -0
  115. package/dist/chunk-jhe0t7yj.js.map +11 -0
  116. package/dist/{chunk-d0qwdeza.js → chunk-k5j65f2c.js} +2 -2
  117. package/dist/{chunk-d0qwdeza.js.map → chunk-k5j65f2c.js.map} +1 -1
  118. package/dist/{chunk-pt59xjfc.js → chunk-kmsrzbx1.js} +2 -2
  119. package/dist/{chunk-pt59xjfc.js.map → chunk-kmsrzbx1.js.map} +1 -1
  120. package/dist/{chunk-v1nm4tcq.js → chunk-m7y8d3k7.js} +2 -2
  121. package/dist/{chunk-v1nm4tcq.js.map → chunk-m7y8d3k7.js.map} +1 -1
  122. package/dist/{chunk-k2qh3hvd.js → chunk-mk8m3ffx.js} +2 -2
  123. package/dist/{chunk-k2qh3hvd.js.map → chunk-mk8m3ffx.js.map} +1 -1
  124. package/dist/{chunk-z7442w3q.js → chunk-mszy6cfw.js} +2 -2
  125. package/dist/{chunk-z7442w3q.js.map → chunk-mszy6cfw.js.map} +1 -1
  126. package/dist/{chunk-kb3xk9r8.js → chunk-ndat0nf0.js} +2 -2
  127. package/dist/{chunk-kb3xk9r8.js.map → chunk-ndat0nf0.js.map} +1 -1
  128. package/dist/{chunk-j9wqzemf.js → chunk-p0m3qgs5.js} +2 -2
  129. package/dist/{chunk-j9wqzemf.js.map → chunk-p0m3qgs5.js.map} +1 -1
  130. package/dist/{chunk-8mmfpqgs.js → chunk-p7r3ecpk.js} +2 -2
  131. package/dist/{chunk-zfch4da5.js.map → chunk-p7r3ecpk.js.map} +1 -1
  132. package/dist/{chunk-zp971jp2.js → chunk-pmmrhak1.js} +3 -3
  133. package/dist/{chunk-zp971jp2.js.map → chunk-pmmrhak1.js.map} +1 -1
  134. package/dist/{chunk-nvj1z2rs.js → chunk-pzwyg474.js} +2 -2
  135. package/dist/{chunk-nvj1z2rs.js.map → chunk-pzwyg474.js.map} +1 -1
  136. package/dist/{chunk-73dk6k4p.js → chunk-qje4kdff.js} +3 -3
  137. package/dist/{chunk-73dk6k4p.js.map → chunk-qje4kdff.js.map} +1 -1
  138. package/dist/{chunk-yk8s5egf.js → chunk-rdnm6rem.js} +2 -2
  139. package/dist/{chunk-yk8s5egf.js.map → chunk-rdnm6rem.js.map} +1 -1
  140. package/dist/{chunk-enf9mdac.js → chunk-s046a984.js} +2 -2
  141. package/dist/{chunk-enf9mdac.js.map → chunk-s046a984.js.map} +1 -1
  142. package/dist/{chunk-1s914cdj.js → chunk-saqfc6vp.js} +3 -3
  143. package/dist/{chunk-1s914cdj.js.map → chunk-saqfc6vp.js.map} +1 -1
  144. package/dist/{chunk-pgpqsgzx.js → chunk-sejnmn1q.js} +1 -1
  145. package/dist/{chunk-xhha1gb3.js → chunk-sjckrbr2.js} +2 -2
  146. package/dist/{chunk-xhha1gb3.js.map → chunk-sjckrbr2.js.map} +1 -1
  147. package/dist/{chunk-r8nhndzb.js → chunk-swhyp0yw.js} +2 -2
  148. package/dist/{chunk-r8nhndzb.js.map → chunk-swhyp0yw.js.map} +1 -1
  149. package/dist/{chunk-wkdzz0rx.js → chunk-trdwxm5x.js} +3 -3
  150. package/dist/{chunk-wkdzz0rx.js.map → chunk-trdwxm5x.js.map} +1 -1
  151. package/dist/{chunk-aztkrzvf.js → chunk-v2hvnxsf.js} +2 -2
  152. package/dist/{chunk-aztkrzvf.js.map → chunk-v2hvnxsf.js.map} +1 -1
  153. package/dist/{chunk-57ryyhh3.js → chunk-v4ngf77f.js} +2 -2
  154. package/dist/{chunk-57ryyhh3.js.map → chunk-v4ngf77f.js.map} +1 -1
  155. package/dist/{chunk-159hyeng.js → chunk-v8nf45gt.js} +2 -2
  156. package/dist/{chunk-159hyeng.js.map → chunk-v8nf45gt.js.map} +1 -1
  157. package/dist/{chunk-ys4fejmx.js → chunk-vwp1g8wh.js} +2 -2
  158. package/dist/{chunk-ys4fejmx.js.map → chunk-vwp1g8wh.js.map} +1 -1
  159. package/dist/chunk-w312e9nx.js +5 -0
  160. package/dist/{chunk-ash9e6fn.js.map → chunk-w312e9nx.js.map} +4 -3
  161. package/dist/{chunk-wwdaswxh.js → chunk-wwzg4dmy.js} +3 -3
  162. package/dist/{chunk-wwdaswxh.js.map → chunk-wwzg4dmy.js.map} +1 -1
  163. package/dist/{chunk-wsx3j5ws.js → chunk-xckeyg3v.js} +2 -2
  164. package/dist/{chunk-wsx3j5ws.js.map → chunk-xckeyg3v.js.map} +1 -1
  165. package/dist/chunk-xx2zg6sk.js +17 -0
  166. package/dist/{chunk-49akdtfe.js.map → chunk-xx2zg6sk.js.map} +11 -12
  167. package/dist/{chunk-rqh2wdhb.js → chunk-y7qnx8vm.js} +2 -2
  168. package/dist/{chunk-rqh2wdhb.js.map → chunk-y7qnx8vm.js.map} +1 -1
  169. package/dist/{chunk-rv7da58g.js → chunk-z4k18gnp.js} +2 -2
  170. package/dist/{chunk-rv7da58g.js.map → chunk-z4k18gnp.js.map} +1 -1
  171. package/dist/{chunk-w099t7zj.js → chunk-zf4r4kat.js} +2 -2
  172. package/dist/{chunk-w099t7zj.js.map → chunk-zf4r4kat.js.map} +1 -1
  173. package/dist/{chunk-dvpxkzms.js → chunk-zs90w6ke.js} +2 -2
  174. package/dist/{chunk-dvpxkzms.js.map → chunk-zs90w6ke.js.map} +1 -1
  175. package/dist/chunks/{ThemeProvider-Dn3UREDn.js → ThemeProvider-D1kDfCwY.js} +59 -2
  176. package/dist/chunks/ThemeProvider-D1kDfCwY.js.map +1 -0
  177. package/dist/client/Link.d.ts.map +1 -1
  178. package/dist/client/MutationError.d.ts +60 -50
  179. package/dist/client/MutationError.d.ts.map +1 -1
  180. package/dist/client/ProgressManager.d.ts +1 -1
  181. package/dist/client/QueryResource.d.ts +20 -0
  182. package/dist/client/QueryResource.d.ts.map +1 -1
  183. package/dist/client/index.d.ts +2 -1
  184. package/dist/client/index.d.ts.map +1 -1
  185. package/dist/client/index.js +109 -35
  186. package/dist/client/index.js.map +1 -1
  187. package/dist/client/useMutation.d.ts.map +1 -1
  188. package/dist/client/useQuery.d.ts.map +1 -1
  189. package/dist/config/index.js +1 -1
  190. package/dist/console/run.js +2 -2
  191. package/dist/console/run.js.map +1 -1
  192. package/dist/container/index.js +2 -2
  193. package/dist/container/index.js.map +1 -1
  194. package/dist/database/index.js +2 -2
  195. package/dist/database/index.js.map +1 -1
  196. package/dist/email/Email.d.ts.map +1 -1
  197. package/dist/email/debugEmail.d.ts +40 -0
  198. package/dist/email/debugEmail.d.ts.map +1 -0
  199. package/dist/email/index.js +4 -3
  200. package/dist/email/index.js.map +6 -5
  201. package/dist/facades/index.js +2 -2
  202. package/dist/facades/index.js.map +1 -1
  203. package/dist/foundation/index.js +2 -2
  204. package/dist/foundation/index.js.map +1 -1
  205. package/dist/http/ApiRouter.d.ts +12 -0
  206. package/dist/http/ApiRouter.d.ts.map +1 -1
  207. package/dist/http/CSRFMiddleware.d.ts +1 -1
  208. package/dist/http/CSRFMiddleware.d.ts.map +1 -1
  209. package/dist/http/Error.d.ts +50 -0
  210. package/dist/http/Error.d.ts.map +1 -1
  211. package/dist/http/HttpRequest.d.ts +26 -0
  212. package/dist/http/HttpRequest.d.ts.map +1 -1
  213. package/dist/http/RateLimitMiddleware.d.ts +6 -3
  214. package/dist/http/RateLimitMiddleware.d.ts.map +1 -1
  215. package/dist/http/Router.d.ts.map +1 -1
  216. package/dist/http/errors.d.ts.map +1 -1
  217. package/dist/http/index.d.ts +2 -1
  218. package/dist/http/index.d.ts.map +1 -1
  219. package/dist/http/index.js +2 -2
  220. package/dist/http/index.js.map +1 -1
  221. package/dist/http/mediaType.d.ts +16 -0
  222. package/dist/http/mediaType.d.ts.map +1 -0
  223. package/dist/http/refusal.d.ts +52 -0
  224. package/dist/http/refusal.d.ts.map +1 -0
  225. package/dist/i18n/dictionaryRuntime.js +2 -2
  226. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  227. package/dist/i18n/index.js +2 -2
  228. package/dist/i18n/index.js.map +2 -2
  229. package/dist/kernel/index.js +2 -2
  230. package/dist/kernel/index.js.map +2 -2
  231. package/dist/orm/index.js +2 -2
  232. package/dist/orm/index.js.map +1 -1
  233. package/dist/server/devFetch.d.ts.map +1 -1
  234. package/dist/server/forwardedFor.d.ts +42 -0
  235. package/dist/server/forwardedFor.d.ts.map +1 -0
  236. package/dist/server/httpProd.d.ts.map +1 -1
  237. package/dist/server/index.js +2 -2
  238. package/dist/server/index.js.map +1 -1
  239. package/dist/server/staticFile.d.ts +33 -0
  240. package/dist/server/staticFile.d.ts.map +1 -0
  241. package/dist/server/unhandledError.d.ts.map +1 -1
  242. package/dist/services/index.js +2 -2
  243. package/dist/services/index.js.map +2 -2
  244. package/dist/services/mcp/McpRegistry.d.ts +2 -1
  245. package/dist/services/mcp/McpRegistry.d.ts.map +1 -1
  246. package/dist/services/mcp/toAgentTools.d.ts +1 -1
  247. package/dist/services/mcp/toAgentTools.d.ts.map +1 -1
  248. package/dist/services/queue/work.js +2 -2
  249. package/dist/services/queue/work.js.map +1 -1
  250. package/dist/services/router/notFound.d.ts.map +1 -1
  251. package/dist/services/router/policyDenied.d.ts.map +1 -1
  252. package/dist/services/router/serverQueryFetcher.d.ts.map +1 -1
  253. package/dist/support/index.js +2 -2
  254. package/dist/support/index.js.map +1 -1
  255. package/dist/testing/index.js +1 -1
  256. package/package.json +1 -1
  257. package/skills/gemi-react-best-practices/rules/controller-throw-framework-errors.md +5 -0
  258. package/dist/chunk-302mkqeq.js +0 -7
  259. package/dist/chunk-49akdtfe.js +0 -17
  260. package/dist/chunk-ash9e6fn.js +0 -5
  261. package/dist/chunk-e43drft2.js +0 -5
  262. package/dist/chunk-j5xcfeqx.js +0 -24
  263. package/dist/chunk-j5xcfeqx.js.map +0 -16
  264. package/dist/chunk-rp5j1mgk.js +0 -55
  265. package/dist/chunk-tmwsvf02.js +0 -5
  266. package/dist/chunks/ThemeProvider-Dn3UREDn.js.map +0 -1
  267. /package/dist/{chunk-ah9ajys0.js.map → chunk-2gdhcswa.js.map} +0 -0
  268. /package/dist/{chunk-jg9eqd3r.js.map → chunk-c3gzpjba.js.map} +0 -0
  269. /package/dist/{chunk-pgpqsgzx.js.map → chunk-sejnmn1q.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Cg as t,Fg as A}from"./chunk-zfch4da5.js";var o=t((b)=>{var i=(r)=>typeof ArrayBuffer==="function"&&r instanceof ArrayBuffer||Object.prototype.toString.call(r)==="[object ArrayBuffer]";b.isArrayBuffer=i});var y=t((g)=>{var m=o(),f=A("buffer"),B=(r,e=0,u=r.byteLength-e)=>{if(!m.isArrayBuffer(r))throw TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof r} (${r})`);return f.Buffer.from(r,e,u)},a=(r,e)=>{if(typeof r!=="string")throw TypeError(`The "input" argument must be of type string. Received type ${typeof r} (${r})`);return e?f.Buffer.from(r,e):f.Buffer.from(r)};g.fromArrayBuffer=B;g.fromString=a});var x=t((w)=>{var n=y(),s=(r)=>{let e=n.fromString(r,"utf8");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT)},h=(r)=>{if(typeof r==="string")return s(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength/Uint8Array.BYTES_PER_ELEMENT);return new Uint8Array(r)},p=(r)=>{if(typeof r==="string")return r;if(typeof r!=="object"||typeof r.byteOffset!=="number"||typeof r.byteLength!=="number")throw Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return n.fromArrayBuffer(r.buffer,r.byteOffset,r.byteLength).toString("utf8")};w.fromUtf8=s;w.toUint8Array=h;w.toUtf8=p});
2
+ import{Kg as t,Ng as A}from"./chunk-9tsw1bmt.js";var o=t((b)=>{var i=(r)=>typeof ArrayBuffer==="function"&&r instanceof ArrayBuffer||Object.prototype.toString.call(r)==="[object ArrayBuffer]";b.isArrayBuffer=i});var y=t((g)=>{var m=o(),f=A("buffer"),B=(r,e=0,u=r.byteLength-e)=>{if(!m.isArrayBuffer(r))throw TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof r} (${r})`);return f.Buffer.from(r,e,u)},a=(r,e)=>{if(typeof r!=="string")throw TypeError(`The "input" argument must be of type string. Received type ${typeof r} (${r})`);return e?f.Buffer.from(r,e):f.Buffer.from(r)};g.fromArrayBuffer=B;g.fromString=a});var x=t((w)=>{var n=y(),s=(r)=>{let e=n.fromString(r,"utf8");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT)},h=(r)=>{if(typeof r==="string")return s(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength/Uint8Array.BYTES_PER_ELEMENT);return new Uint8Array(r)},p=(r)=>{if(typeof r==="string")return r;if(typeof r!=="object"||typeof r.byteOffset!=="number"||typeof r.byteLength!=="number")throw Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return n.fromArrayBuffer(r.buffer,r.byteOffset,r.byteLength).toString("utf8")};w.fromUtf8=s;w.toUint8Array=h;w.toUtf8=p});
3
3
  export{o as W,y as X,x as Y};
4
4
 
5
- //# debugId=F7311717FE1668DC64756E2164756E21
5
+ //# debugId=2CD3C044F03AD11364756E2164756E21
@@ -7,6 +7,6 @@
7
7
  "'use strict';\n\nvar utilBufferFrom = require('@smithy/util-buffer-from');\n\nconst fromUtf8 = (input) => {\n const buf = utilBufferFrom.fromString(input, \"utf8\");\n return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);\n};\n\nconst toUint8Array = (data) => {\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);\n }\n return new Uint8Array(data);\n};\n\nconst toUtf8 = (input) => {\n if (typeof input === \"string\") {\n return input;\n }\n if (typeof input !== \"object\" || typeof input.byteOffset !== \"number\" || typeof input.byteLength !== \"number\") {\n throw new Error(\"@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.\");\n }\n return utilBufferFrom.fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString(\"utf8\");\n};\n\nexports.fromUtf8 = fromUtf8;\nexports.toUint8Array = toUint8Array;\nexports.toUtf8 = toUtf8;\n"
8
8
  ],
9
9
  "mappings": ";+DAEA,IAAM,EAAgB,CAAC,IAAS,OAAO,cAAgB,YAAc,aAAe,aAChF,OAAO,UAAU,SAAS,KAAK,CAAG,IAAM,uBAEpC,gBAAgB,kBCHxB,IAAI,MACA,cAEE,EAAkB,CAAC,EAAO,EAAS,EAAG,EAAS,EAAM,WAAa,IAAW,CAC/E,GAAI,CAAC,EAAc,cAAc,CAAK,EAClC,MAAU,UAAU,2DAA2D,OAAO,MAAU,IAAQ,EAE5G,OAAO,EAAO,OAAO,KAAK,EAAO,EAAQ,CAAM,GAE7C,EAAa,CAAC,EAAO,IAAa,CACpC,GAAI,OAAO,IAAU,SACjB,MAAU,UAAU,8DAA8D,OAAO,MAAU,IAAQ,EAE/G,OAAO,EAAW,EAAO,OAAO,KAAK,EAAO,CAAQ,EAAI,EAAO,OAAO,KAAK,CAAK,GAG5E,kBAAkB,EAClB,aAAa,kBCjBrB,IAAI,MAEE,EAAW,CAAC,IAAU,CACxB,IAAM,EAAM,EAAe,WAAW,EAAO,MAAM,EACnD,OAAO,IAAI,WAAW,EAAI,OAAQ,EAAI,WAAY,EAAI,WAAa,WAAW,iBAAiB,GAG7F,EAAe,CAAC,IAAS,CAC3B,GAAI,OAAO,IAAS,SAChB,OAAO,EAAS,CAAI,EAExB,GAAI,YAAY,OAAO,CAAI,EACvB,OAAO,IAAI,WAAW,EAAK,OAAQ,EAAK,WAAY,EAAK,WAAa,WAAW,iBAAiB,EAEtG,OAAO,IAAI,WAAW,CAAI,GAGxB,EAAS,CAAC,IAAU,CACtB,GAAI,OAAO,IAAU,SACjB,OAAO,EAEX,GAAI,OAAO,IAAU,UAAY,OAAO,EAAM,aAAe,UAAY,OAAO,EAAM,aAAe,SACjG,MAAU,MAAM,8EAA8E,EAElG,OAAO,EAAe,gBAAgB,EAAM,OAAQ,EAAM,WAAY,EAAM,UAAU,EAAE,SAAS,MAAM,GAGnG,WAAW,EACX,eAAe,EACf,SAAS",
10
- "debugId": "F7311717FE1668DC64756E2164756E21",
10
+ "debugId": "2CD3C044F03AD11364756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{_ as J}from"./chunk-rqh2wdhb.js";import{Cg as I}from"./chunk-zfch4da5.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{_ as J}from"./chunk-y7qnx8vm.js";import{Kg as I}from"./chunk-9tsw1bmt.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 U};
4
4
 
5
- //# debugId=CF85C5BB208F60A364756E2164756E21
5
+ //# debugId=1F3DC116A482431364756E2164756E21
@@ -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": ";qGAEA,FAAI,MAEE,EAAuC,CAAC,IAAkB,CAC5D,MAAO,CACH,cAAc,CAAC,EAAS,CACpB,EAAc,YAAc,GAEhC,WAAW,EAAG,CACV,OAAO,EAAc,aAEzB,sBAAsB,CAAC,EAAK,EAAO,CAC/B,EAAc,aAAa,uBAAuB,EAAK,CAAK,GAEhE,kBAAkB,EAAG,CACjB,OAAO,EAAc,YAAY,mBAAmB,EAE5D,GAEE,EAAkC,CAAC,IAAsC,CAC3E,MAAO,CACH,YAAa,EAAkC,YAAY,CAC/D,GAGJ,MAAM,CAAM,CACR,KACA,KACA,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MADoB,kCACD,KAAK,CAAQ,EAG5B,QAAQ,EACR,SAAS,EACT,cAAc,EACd,eAAe,EACf,uCAAuC,EACvC,kBAAkB,EAClB,kCAAkC",
8
- "debugId": "CF85C5BB208F60A364756E2164756E21",
8
+ "debugId": "1F3DC116A482431364756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{rf as W,sf as S,vf as A,wf as U}from"./chunk-wkdzz0rx.js";import{Sf as C}from"./chunk-g6qe6wyb.js";import{bg as I}from"./chunk-m4xw99vm.js";import{mg as E}from"./chunk-wh728wd6.js";import{pg as N}from"./chunk-gr61ymse.js";class K{table;sql;dialect;connection;busyTimeout;configured;constructor(z,G={}){let V=G.table??"gemi_jobs";if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(V))throw Error(`The queue table name "${V}" is not a plain identifier. Use letters, digits and underscores.`);let Y=G.busyTimeout??1000;if(!Number.isInteger(Y)||Y<0)throw Error(`The queue's busyTimeout must be a whole number of milliseconds, 0 or more; got ${Y}.`);this.table=V,this.sql=z.sql,this.dialect=z.dialect,this.connection=z.name,this.busyTimeout=Y}configure(){if(this.dialect!=="sqlite"||this.busyTimeout===0)return Promise.resolve();return this.configured??=(async()=>{let[z]=await this.sql.unsafe("PRAGMA busy_timeout");if(Number(z?.timeout??0)!==0)return;await this.sql.unsafe(`PRAGMA busy_timeout = ${this.busyTimeout}`)})().catch((z)=>{throw this.configured=void 0,z}),this.configured}async createTable(){await this.configure();for(let z of R(this.dialect,this.table))await this.sql.unsafe(z)}enqueue(z){let G=this.transaction(),V=this.insert(G??this.sql,z);if(G)U(V);return V}async insert(z,{name:G,args:V,delayMs:Y=0,id:Z=Bun.randomUUIDv7()}){await this.configure();let $=this.now(z);return await z`
2
+ import{Af as S,Df as A,Ef as U,zf as W}from"./chunk-trdwxm5x.js";import{_f as C}from"./chunk-1w5a11cd.js";import{jg as I}from"./chunk-dwqh79e5.js";import{ug as E}from"./chunk-8gexb1gt.js";import{xg as N}from"./chunk-gx0x772p.js";class K{table;sql;dialect;connection;busyTimeout;configured;constructor(z,G={}){let V=G.table??"gemi_jobs";if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(V))throw Error(`The queue table name "${V}" is not a plain identifier. Use letters, digits and underscores.`);let Y=G.busyTimeout??1000;if(!Number.isInteger(Y)||Y<0)throw Error(`The queue's busyTimeout must be a whole number of milliseconds, 0 or more; got ${Y}.`);this.table=V,this.sql=z.sql,this.dialect=z.dialect,this.connection=z.name,this.busyTimeout=Y}configure(){if(this.dialect!=="sqlite"||this.busyTimeout===0)return Promise.resolve();return this.configured??=(async()=>{let[z]=await this.sql.unsafe("PRAGMA busy_timeout");if(Number(z?.timeout??0)!==0)return;await this.sql.unsafe(`PRAGMA busy_timeout = ${this.busyTimeout}`)})().catch((z)=>{throw this.configured=void 0,z}),this.configured}async createTable(){await this.configure();for(let z of R(this.dialect,this.table))await this.sql.unsafe(z)}enqueue(z){let G=this.transaction(),V=this.insert(G??this.sql,z);if(G)U(V);return V}async insert(z,{name:G,args:V,delayMs:Y=0,id:Z=Bun.randomUUIDv7()}){await this.configure();let $=this.now(z);return await z`
3
3
  INSERT INTO ${this.name(z)}
4
4
  (id, name, payload, status, attempts, available_at, created_at, updated_at)
5
5
  VALUES
@@ -137,6 +137,6 @@ import{rf as W,sf as S,vf as A,wf as U}from"./chunk-wkdzz0rx.js";import{Sf as C}
137
137
  }
138
138
  };
139
139
  `],"worker.ts"),Z=URL.createObjectURL(Y);return new Worker(Z)}async function T(z,G){let V=M();return V.postMessage({jobName:z,args:G}),await new Promise((Y,Z)=>{V.onmessage=($)=>{let B=$.data;if("error"in B)Z(B.error);else Y(B.result)}})}var D=new P("gemi.queue"),k=60000;class x{static token="queue";jobs={};config;driver;application;inFlight=new Map;state="idle";looping=!1;claiming;woken=!1;claimFailures=0;resume;unsubscribe;heartbeatTimer;releasedNames=new Set;constructor(z={},G={}){this.config=I(_(),z),this.application=G.application,this.driver=q(this.config.driver,this.application),this.useJobs(this.config.jobs)}useJobs(z){this.config.jobs=z,this.jobs={};for(let G of z)this.claim(G)}registerJob(z){this.config.jobs=[...this.config.jobs,z],this.claim(z)}claim(z){if(this.jobs[z.name]){console.error(`Two queued jobs are named "${z.name}" \u2014 the first is registered `+"and this one is not, so dispatching either would have run one of them. A class name is the queue's key, so only one job can hold it. Rename one.");return}this.jobs[z.name]=z}get registeredJobs(){return[...this.config.jobs]}dispatchJob(z,G){if(this.jobs[z])return new this.jobs[z]().run(JSON.parse(G))}push(z,G,V={}){let Y=this.driver.joinsTransaction?.()===!0;if(!Y){let Z=Bun.randomUUIDv7();if(A(()=>this.record(z,G,{id:Z,reportFailure:!0,committed:!0}).then(()=>{},()=>{})))return Promise.resolve(Z)}return this.record(z,G,{reportFailure:V.reportFailure,joins:Y})}record(z,G,V){let Y=this.driver.enqueue({name:z.name,args:G,...V.id===void 0?{}:{id:V.id}});this.startIfIdle();let Z=()=>!this.driver.subscribe&&this.state==="running"&&this.wake(),$=V.joins===!0&&A(Z);return Y.then(()=>$||Z(),(B)=>{if(V.reportFailure===!1)return;console.error(`[gemi] The queue driver could not record ${z.name}`+(V.committed?", which was held until its transaction committed. The transaction stays committed; the job did not run and will not be retried.":", so it did not run and will not be retried."),B)}),Y}async retryDead(z){if(!this.driver.retryDead)throw Error("This queue's driver keeps nothing of a dead-lettered job, so there is nothing to retry. The database driver keeps them.");let G=await this.driver.retryDead(z);if(G)this.claimSoon();return G}startIfIdle(){if(this.state==="idle"&&(!this.durable||this.mayClaimHere()))this.start()}claimSoon(){if(this.startIfIdle(),!this.driver.subscribe&&this.state==="running")this.wake()}start(){if(this.state==="running")return;if(this.state="running",this.durable&&this.application&&this.mayClaimHere()&&!v())globalThis.__gemiDevQueue=this;if(this.unsubscribe=this.driver.subscribe?.(()=>this.wake()),this.looping)return this.wake();D.runInAsyncScope(()=>void this.loop())}async drain(z=1/0){if(this.state="stopped",globalThis.__gemiDevQueue===this)globalThis.__gemiDevQueue=void 0;this.unsubscribe?.(),this.unsubscribe=void 0,this.wake();let G,V=new Promise((Z)=>{if(z!==1/0)G=setTimeout(Z,z)}),Y=(async()=>{await this.claiming?.catch(()=>{}),await Promise.allSettled([...this.inFlight.values()].map((Z)=>Z.done))})();return await Promise.race([Y,V]),clearTimeout(G),{unfinished:[...this.inFlight.values()].map((Z)=>({...Z.job}))}}stop(){return this.drain(0)}get running(){return this.inFlight.size}async loop(){this.looping=!0;try{await this.claimWhileRunning()}finally{this.looping=!1}}async claimWhileRunning(){while(this.state==="running"){let z=this.durable&&N()?0:this.config.concurrency-this.inFlight.size;if(z>0){this.woken=!1;let G=this.driver.claim(z,{...this.lease(),registered:{names:Object.keys(this.jobs),graceMs:this.config.unknownJobGrace}});this.claiming=G;let V=[];try{V=await G,this.claimFailures=0}catch(Y){this.claimFailures++,console.error(`The queue could not claim jobs from its driver; it will try again in ${this.retryDelay()}ms.`,Y)}finally{this.claiming=void 0}for(let Y of V)this.execute(Y);if(V.length===z)continue;if(this.woken&&this.inFlight.size<this.config.concurrency)continue}await this.sleep()}}sleep(){return new Promise((z)=>{let G,V=this.claimFailures>0?this.retryDelay():this.driver.subscribe?void 0:this.config.pollInterval;if(V!==void 0)G=setTimeout(()=>this.wake(),V),G.unref?.();this.resume=()=>{clearTimeout(G),z()}})}retryDelay(){let z=Math.min(Math.max(0,this.claimFailures-1),30);return Math.min(this.config.pollInterval*2**z,k)}wake(){this.woken=!0;let z=this.resume;this.resume=void 0,z?.()}get durable(){return!(this.driver instanceof X)}mayClaimHere(){return!this.application||g()}lease(){return{visibilityTimeoutMs:this.config.visibilityTimeout}}execute(z){let G=`${z.id}:${z.attempt}`,V=()=>this.run(z),Y=(this.application?E.run(this.application,V):V()).catch((Z)=>{console.error(`The queue could not record the outcome of ${z.name}.`,Z)}).finally(()=>{this.inFlight.delete(G),this.wake()});this.inFlight.set(G,{job:z,done:Y}),this.heartbeat()}heartbeat(){let z=this.driver;if(!z.heartbeat||this.heartbeatTimer)return;this.heartbeatTimer=setInterval(()=>{if(this.inFlight.size===0){clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0;return}let G=[...this.inFlight.values()].map((V)=>V.job);z.heartbeat(G,this.lease()).catch((V)=>{console.error("The queue could not extend its job leases.",V)})},Math.max(1,Math.floor(this.config.visibilityTimeout/3))),this.heartbeatTimer.unref?.()}async run(z){let G=this.jobs[z.name];if(!G){let Z=Date.now()-z.createdAt;if(this.durable&&Z<this.config.unknownJobGrace){if(!this.releasedNames.has(z.name))this.releasedNames.add(z.name),console.error(`Left a queued "${z.name}" for another replica: nothing is registered here under that name. It is dead-lettered if no replica has run it within unknownJobGrace (${this.config.unknownJobGrace}ms) of its dispatch.`);await this.driver.release(z,{retryInMs:Math.round(this.config.pollInterval*(1+Math.random()))});return}console.error(`Dropped a queued job: nothing is registered under the name "${z.name}". If the class exists, it was not `+"discovered \u2014 check that it is under the queue slice's jobsDir "+"(app/jobs by default), or list it in app/config/queue.ts."),await this.driver.fail(z,{error:`No job is registered under the name "${z.name}".`,retryInMs:null});return}let V;try{V=new G}catch(Z){console.error(`Dropped a queued ${z.name}: it could not be constructed.`,Z),await this.driver.fail(z,{error:`The job could not be constructed: ${String(Z)}`,retryInMs:null});return}let Y;try{Y=JSON.parse(z.args)}catch(Z){console.error(`Dropped a queued ${z.name}: its arguments are not JSON.`,Z),await this.driver.fail(z,{error:`The arguments are not JSON: ${String(Z)}`,retryInMs:null});return}if(z.attempt>Math.max(1,V.maxAttempts)){let Z=Error(`${z.name} was claimed for attempt ${z.attempt} of ${V.maxAttempts}: an earlier attempt never finished, most likely because the process running it exited. Dead-lettered without running it again.`);L(`${z.name}.onDeadletter`,()=>V.onDeadletter(Z,...Y)),await this.driver.fail(z,{error:Z.message,retryInMs:null});return}try{let Z=await(V.worker?T(z.name,z.args):V.run(...Y));V.onSuccess(Z,...Y)}catch(Z){let $=Z,B=String($?.stack??$);if(L(`${z.name}.onFail`,()=>V.onFail($,...Y)),z.attempt>=V.maxAttempts)L(`${z.name}.onDeadletter`,()=>V.onDeadletter($,...Y)),await this.driver.fail(z,{error:B,retryInMs:null});else await this.driver.fail(z,{error:B,retryInMs:f(V.backoff,z.attempt)});return}await this.driver.complete(z)}}function L(z,G){try{G()}catch(V){console.error(`${z} threw; the job's claim was ended anyway.`,V)}}function v(){return Bun.env.NODE_ENV==="production"}function g(){if(!Q)return!1;if(h())return!0;return process.env.ROOT_DIR!==void 0&&!y()}function y(z=process.env){return(z.GEMI_QUEUE_CLAIM??"").trim().toLowerCase()==="off"}var O=Symbol.for("gemi.queue.worker");function o(z=!0){globalThis[O]=z}function h(){return globalThis[O]===!0}function f(z,G){let V=Array.isArray(z)?z[Math.min(G,z.length)-1]:z;return Math.max(0,V??0)}function q(z,G){if(z==="memory")return new X;if(z==="database"||typeof z==="function"){if(!G&&(z==="database"||z.length>0))throw Error("The queue driver needs the application it belongs to, and this QueueManager was built without one. Pass { application }.");if(z==="database")return new K(G.make(C));return z(G)}if(typeof z==="string")throw Error(`Unknown queue driver "${z}". The queue slice's driver is "memory", "database", a QueueDriver, or a function returning one.`);return z}
140
- export{K as Vb,j as Wb,_ as Xb,X as Yb,x as Zb,g as _b,y as $b,o as ac,h as bc};
140
+ export{K as _b,j as $b,_ as ac,X as bc,x as cc,g as dc,y as ec,o as fc,h as gc};
141
141
 
142
- //# debugId=6B52A7598A2A8F5E64756E2164756E21
142
+ //# debugId=03CF131ABB43BDD564756E2164756E21
@@ -8,6 +8,6 @@
8
8
  "import { AsyncResource } from \"node:async_hooks\";\nimport { isMainThread } from \"node:worker_threads\";\n\nimport type { Application } from \"../../foundation/Application\";\nimport { DatabaseManager } from \"../../database/DatabaseManager\";\nimport { kernelContext } from \"../../kernel/context\";\nimport { deferUntilCommit } from \"../../orm/context\";\nimport { isShuttingDown } from \"../../server/shutdown\";\nimport { DatabaseQueueDriver } from \"./DatabaseQueueDriver\";\nimport { Job } from \"./Job\";\nimport { queueConfigDefaults, type QueueConfig } from \"./config\";\nimport { MemoryQueueDriver } from \"./MemoryQueueDriver\";\nimport type { ClaimOptions, ClaimedJob, QueueDriver } from \"./QueueDriver\";\nimport { withDefaults } from \"../../support/withDefaults\";\n\n/**\n * The thread a `worker = true` job runs in.\n *\n * The `await` on `dispatchJob` is load-bearing and its absence was a hang.\n * `postMessage` structured-clones its argument and a Promise is not cloneable,\n * so an un-awaited `dispatchJob` posted the pending promise, threw\n * `DataCloneError` inside this handler, and posted nothing at all. `runInWorker`\n * then never settled: `run` below never returned, its concurrency slot was\n * never decremented, and neither the retry path nor `onDeadletter` ever fired —\n * after `concurrency` such jobs the queue sits at its limit forever, with no\n * error anywhere. Any job whose `run` is `async` hit it, which is every job\n * that touches IO; a queued listener hits it unconditionally, because the\n * synthetic job's `run` awaits `handle`.\n *\n * The await earns two more things. A rejecting job now reaches the `catch` and\n * comes back as `{error}`, where the queue's ordinary retry-then-dead-letter\n * path can have it, instead of being lost with the promise. And `destroy()` now\n * runs after the job rather than under it, so the cloned kernel — its database\n * connections included — outlives the work it was cloned for.\n */\nfunction createWorker() {\n const APP_DIR = process.env.APP_DIR;\n const ROOT_DIR = process.env.ROOT_DIR;\n\n const appPath =\n process.env.NODE_ENV === \"production\"\n ? `${ROOT_DIR}/dist/server/bootstrap.mjs`\n : `${APP_DIR}/bootstrap.ts`;\n\n const file = new File(\n [\n `\n import { app } from \"${appPath}\"\n self.onmessage = async (event) => {\n const clone = app.clone()\n let result = null;\n let error = null;\n try {\n result = await clone.dispatchJob(event.data.jobName, event.data.args)\n } catch (err) {\n error = err\n }\n clone.destroy()\n if(error) {\n self.postMessage({error});\n } else {\n self.postMessage({result});\n }\n };\n `,\n ],\n \"worker.ts\",\n );\n const url = URL.createObjectURL(file);\n return new Worker(url);\n}\n\n// TODO: terminate worker after the job is done\nasync function runInWorker(jobName: string, args: string) {\n const worker = createWorker();\n worker.postMessage({ jobName, args });\n return await new Promise((resolve, reject) => {\n worker.onmessage = (e) => {\n const data = e.data;\n if (\"error\" in data) {\n reject(data.error);\n } else {\n resolve(data.result);\n }\n };\n });\n}\n\n/**\n * The async context every job runs in: the one this module was evaluated in,\n * which is boot, outside any request.\n *\n * The worker loop is long-lived and started lazily, by the first dispatch, and\n * an async function keeps the context it was started in across every `await`.\n * Started from a request, it would run every later job — dispatched by any\n * request at all — inside the first one's `RequestContext`, and with its ORM\n * transaction handle if it had one open: one user's identity leaking into\n * another's work. Captured here, where no request exists, and entered by `start()`, a job\n * sees no request at all; the Application is entered separately, per job.\n */\nconst bootScope = new AsyncResource(\"gemi.queue\");\n\n/**\n * The longest the loop waits between retries while `claim` keeps rejecting.\n *\n * Long enough that a database which is properly down is not asked once a\n * second by every worker process for as long as it stays down, short enough\n * that the queue is claiming again within a minute of it coming back.\n */\nconst maxClaimBackoff = 60_000;\n\ndeclare global {\n /**\n * The queue loop a `gemi dev` server is running over a driver that outlives\n * the process, kept where a `bun --hot` reload cannot lose it. A reload\n * re-evaluates every module and boots a new application, but the previous\n * application's loop is a live closure and keeps claiming — from the same\n * table, with the code it was loaded with. This is how the next\n * application finds it to stop it; see `startClaimingIfServing`.\n *\n * Typed by what is called on it, not as `QueueManager`: after a reload the\n * one held here is an instance of the previous module graph's class.\n */\n var __gemiDevQueue: { stop(): Promise<unknown> } | undefined;\n}\n\n/** What `drain` could not wait out. */\nexport type DrainResult = {\n /**\n * Jobs still running when the timeout elapsed. They keep running, and keep\n * their leases, until they settle or the process exits; with a driver that\n * outlives the process, an exit leaves them to be reclaimed once their lease\n * runs out. Waiting jobs are not listed — they were never taken, and are\n * wherever the driver keeps them.\n */\n unfinished: ClaimedJob[];\n};\n\nexport class QueueManager {\n static token = \"queue\";\n\n jobs: Record<string, new () => Job> = {};\n\n readonly config: Required<QueueConfig>;\n readonly driver: QueueDriver;\n\n private readonly application: Application | undefined;\n /**\n * Keyed by claim, `id:attempt`, not by job id. A lease that lapses while\n * its job is still running here — heartbeats failing through a database\n * blip, or an event loop blocked past the visibility timeout — lets this\n * same process claim the job again. Both runs are then really running, so\n * both take a slot. Keyed by id alone, the second claim overwrote the first\n * and the first one's `finally` then deleted it: the live run stopped being\n * counted, drained or heartbeated, so its lease lapsed in turn and the job\n * was claimed again into a slot that was never free.\n */\n private readonly inFlight = new Map<\n string,\n { job: ClaimedJob; done: Promise<void> }\n >();\n private state: \"idle\" | \"running\" | \"stopped\" = \"idle\";\n private looping = false;\n private claiming: Promise<unknown> | undefined;\n private woken = false;\n /** Consecutive `claim` rejections; see `sleep`. Cleared by a claim that returns. */\n private claimFailures = 0;\n private resume: (() => void) | undefined;\n private unsubscribe: (() => void) | undefined;\n private heartbeatTimer: ReturnType<typeof setInterval> | undefined;\n /** Unknown names already reported as left for another replica; see `run`. */\n private readonly releasedNames = new Set<string>();\n\n /**\n * `application` is entered around every job, so `app()` inside one resolves\n * to it rather than to whichever application happens to be the static\n * fallback. The provider always passes it; a manager built bare, as the unit\n * tests do, runs jobs with no application entered.\n */\n constructor(\n config: QueueConfig = {},\n options: { application?: Application } = {},\n ) {\n this.config = withDefaults(queueConfigDefaults(), config);\n this.application = options.application;\n this.driver = resolveDriver(this.config.driver, this.application);\n this.useJobs(this.config.jobs);\n }\n\n /**\n * Replaces the registered set, for the provider to hand over what it found\n * under `app/jobs`.\n *\n * This exists because the two phases disagree about when the answer is\n * knowable. The manager is constructed in `register()`, which is synchronous\n * and must resolve nothing; reading a directory and importing what is in it is\n * neither. So the manager is built from whatever the config slice declared —\n * nothing, when the app left `jobs` out — and the discovered set arrives in\n * `boot()`.\n *\n * The consequence worth knowing: anything that constructs an application and\n * skips phase two sees an empty registry, and every dispatch against an empty\n * registry is dropped — loudly on stderr, but after `Job.dispatch` has already\n * returned, so no caller finds out. On a durable driver not even that is\n * immediate: the job is left for another replica, and the stderr line comes\n * only once `unknownJobGrace` has passed. An app that lists its jobs explicitly is\n * unaffected, because that list is already in place by the end of `register()`.\n */\n useJobs(jobs: Array<new () => Job>) {\n this.config.jobs = jobs;\n\n // Built one at a time rather than by `Object.fromEntries`, which resolves a\n // repeated key by keeping the last and saying nothing.\n //\n // Two classes with one name is the worst failure in this subsystem, and it\n // is worse than the dropped dispatch the rest of this file is about: the\n // registry is keyed by class name, a dispatch carries a class name, so\n // `SendEmail.dispatch(...)` on the one under `app/jobs/auth` would run the\n // body of the one under `app/jobs/billing`. Nothing is dropped and nothing\n // errors — the wrong work happens and reports success.\n //\n // Discovery is what makes it ordinary. A hand-written list forces an import\n // alias in one visible file the moment two names clash; a directory walk\n // does not, and `auth/SendEmail.ts` beside `billing/SendEmail.ts` is a\n // perfectly natural thing to write. So the first claim wins and the second\n // is refused out loud — the same rule `Scheduler.start` applies to a cron\n // name, and the reverse of the silent last-wins this replaces.\n this.jobs = {};\n for (const job of jobs) {\n this.claim(job);\n }\n }\n\n /**\n * Registers one more job beside whatever `useJobs` already took.\n *\n * This exists for the queued-listener adapter, which registers a synthetic\n * job per queued listener from `EventServiceProvider.boot()` — after the\n * queue's own `boot()` has filled the registry. `useJobs` cannot serve that\n * caller: it *replaces* the registry, so a second call would discard every\n * job the app wrote and leave the queue holding listeners alone. Reading\n * `registeredJobs` back, concatenating and calling `useJobs` again avoids\n * that and is still the wrong shape — it re-runs the collision check over\n * jobs that already passed it, so a duplicate the author has already been\n * told about is reported a second time on every boot.\n *\n * Same rule as `useJobs`, deliberately: the first claim on a name wins and\n * the second is refused out loud. And recorded in `config.jobs` either way,\n * so `registeredJobs` keeps reporting everything the manager was handed\n * rather than what it accepted — a refused job is visible to a test there.\n *\n * A new array rather than a `push`, because `useJobs` keeps the caller's\n * array by reference and appending to it would edit the config slice or the\n * discovered list under whoever else is holding it.\n */\n registerJob(job: new () => Job) {\n this.config.jobs = [...this.config.jobs, job];\n this.claim(job);\n }\n\n /**\n * Puts one job in the registry, or refuses it because the name is taken.\n *\n * The rule and the reason are in `useJobs` above; this is only the shape both\n * entry points share, so that a job arriving one at a time cannot be admitted\n * on terms the batch would have refused.\n */\n private claim(job: new () => Job) {\n if (this.jobs[job.name]) {\n console.error(\n `Two queued jobs are named \"${job.name}\" — the first is registered ` +\n `and this one is not, so dispatching either would have run one of ` +\n `them. A class name is the queue's key, so only one job can hold ` +\n `it. Rename one.`,\n );\n return;\n }\n this.jobs[job.name] = job;\n }\n\n /**\n * What the manager was handed, discovered or declared.\n *\n * The registry is keyed by name, and a name is exactly what a dispatch\n * carries, so \"is this job registered?\" is a question with a silent wrong\n * answer — `run()` drops an unknown name long after the caller moved on.\n * This is where a test asks it out loud.\n *\n * It reports what came in, not what the registry accepted, so a name claimed\n * twice appears twice here — deliberately, the same way `Scheduler.jobs`\n * does. A test walking this should see the collision rather than have it\n * tidied away. A copy, so that walk cannot edit the registry underneath it.\n */\n get registeredJobs(): ReadonlyArray<new () => Job> {\n return [...this.config.jobs];\n }\n\n dispatchJob(jobName: string, args: string) {\n if (this.jobs[jobName]) {\n const job = new this.jobs[jobName]();\n return job.run(JSON.parse(args));\n }\n }\n\n /**\n * Queues a job and resolves to its id once the driver has recorded it, then\n * makes sure the worker loop is running — unless `drain` stopped it, in which\n * case the job waits in the driver for whichever process claims next. With\n * the memory driver that is nobody; see `drain`. A durable driver's job also\n * waits there when this process does not claim: it is not a server, or it is\n * one started with `GEMI_QUEUE_CLAIM=off`; see `claimsInThisProcess`.\n *\n * Inside an open ORM transaction the job belongs to the transaction. A\n * driver that can write it on the transaction does (`joinsTransaction`);\n * for any other, it is held and recorded once the transaction commits, and\n * never if it rolls back. Either way no claimer can see the job before the\n * data it was dispatched about exists. A held dispatch resolves at once, to\n * the id the job will be recorded under: the transaction does not commit\n * until its callback returns, so a caller awaiting a promise that waited for\n * the commit would never return.\n */\n push(\n job: new () => Job,\n args: string,\n options: {\n /**\n * Whether a driver that cannot record the job is reported from here.\n * On by default, because the usual caller is a fire-and-forget\n * `Job.dispatch(...)` whose promise nobody reads. A caller with\n * something better to say — `EventManager`, which knows the event and\n * the listener — turns it off and says that instead. A held dispatch is\n * reported here whatever this says, because its promise has already\n * resolved and the caller has nothing left to catch.\n */\n reportFailure?: boolean;\n } = {},\n ): Promise<string> {\n // Asked before anything is written, and in the caller's async context,\n // which is where the transaction is. The held branch is the fallback\n // rather than the rule because it loses the job to a crash between the\n // commit and the enqueue; written on the transaction, the job commits\n // with the rows or not at all.\n const joins = this.driver.joinsTransaction?.() === true;\n if (!joins) {\n // `deferUntilCommit` is the ORM's commit hook, and the same one an\n // `afterCommit` event waits on: a savepoint that rolls back takes its\n // held dispatches with it, and the callback runs outside the\n // transaction, so the enqueue cannot be pulled back into it.\n const id = Bun.randomUUIDv7();\n const held = deferUntilCommit(() =>\n // Awaited, so the transaction's own promise waits for the enqueue and\n // a script that exits after its last transaction does not exit under\n // it. The rejection is swallowed only because `record` has already\n // reported it; rethrown, the drain would report it a second time.\n this.record(job, args, {\n id,\n reportFailure: true,\n committed: true,\n }).then(\n () => {},\n () => {},\n ),\n );\n if (held) return Promise.resolve(id);\n }\n return this.record(job, args, {\n reportFailure: options.reportFailure,\n joins,\n });\n }\n\n /** `push`, once it is known that the job is recorded now. */\n private record(\n job: new () => Job,\n args: string,\n options: {\n id?: string;\n reportFailure?: boolean;\n /** Written on the caller's open transaction; see `push`. */\n joins?: boolean;\n /** Held until a transaction committed; changes only the error line. */\n committed?: boolean;\n },\n ): Promise<string> {\n const id = this.driver.enqueue({\n name: job.name,\n args,\n ...(options.id === undefined ? {} : { id: options.id }),\n });\n // A driver that outlives the process is shared with every other one, so\n // a script or console command that dispatches would otherwise claim up to\n // `concurrency` of the table's jobs — other replicas' included — and exit\n // under them, costing each an attempt and a lease's wait. There the job\n // waits in the driver for a server or a worker. A manager built by hand,\n // with no application, is its caller's to run and keeps starting.\n this.startIfIdle();\n // A driver without `subscribe` is only polled, so without the wake a job\n // dispatched here would wait up to `pollInterval` in a queue with room.\n // A spurious wake just claims nothing.\n //\n // A job written on the caller's transaction is not claimable until that\n // commits, so its wake waits for the commit too — woken now, the loop\n // would claim nothing and then sleep a whole `pollInterval` past it.\n // Registered here, synchronously, because the commit hook is found\n // through the caller's async context, and this is the one place that is\n // certainly still current.\n const wake = () =>\n !this.driver.subscribe && this.state === \"running\" && this.wake();\n const wakeAtCommit = options.joins === true && deferUntilCommit(wake);\n\n // The rejection is reported here unless the caller says it will do it\n // itself, and whatever the driver is. It used to depend on both, and was\n // lost either way: a polled driver got an empty rejection arm, which marks\n // `id` handled — and `id` is what `push` returns — so a fire-and-forget\n // `SendReceiptJob.dispatch(...)` whose INSERT failed (a failover, a pool\n // timeout, a table not migrated yet) produced no unhandled rejection and\n // no line anywhere, and the job simply never ran. A subscribing driver got\n // no arm at all, so the same failure surfaced as a bare unhandled\n // rejection. A caller that awaits still gets the rejection either way and\n // can still decide what to do about it.\n id.then(\n () => wakeAtCommit || wake(),\n (error: unknown) => {\n if (options.reportFailure === false) return;\n console.error(\n `[gemi] The queue driver could not record ${job.name}` +\n (options.committed\n ? `, which was held until its transaction committed. The ` +\n `transaction stays committed; the job did not run and will ` +\n `not be retried.`\n : `, so it did not run and will not be retried.`),\n error,\n );\n },\n );\n return id;\n }\n\n /**\n * Runs a dead-lettered job again, from attempt 1 with its whole\n * `maxAttempts`, and resolves to whether a dead job was found under `id`.\n * `false` for an id that is waiting, running, finished or unknown: only a\n * dead job is brought back, so this cannot restart one that is running\n * somewhere.\n *\n * The job is claimed the way a dispatch's is. On a server it is run here as\n * soon as there is room; from a console command it waits in the driver for\n * a server or a worker, which with a polling driver means up to\n * `pollInterval`.\n *\n * Refused for a driver without `retryDead`. The memory driver keeps nothing\n * of a dead job, so there is no id it could bring back, and resolving\n * `false` would read as \"no such job\" to someone holding an id they just saw\n * in a log.\n */\n async retryDead(id: string): Promise<boolean> {\n if (!this.driver.retryDead) {\n throw new Error(\n `This queue's driver keeps nothing of a dead-lettered job, so there ` +\n `is nothing to retry. The database driver keeps them.`,\n );\n }\n const found = await this.driver.retryDead(id);\n if (found) this.claimSoon();\n return found;\n }\n\n /**\n * Starts the loop unless `drain` stopped it or this process should leave a\n * shared driver's jobs to a server — the rule `push` explains.\n */\n private startIfIdle() {\n if (this.state === \"idle\" && (!this.durable || this.mayClaimHere())) {\n this.start();\n }\n }\n\n /**\n * For a job the driver has just made claimable: start the loop, or wake a\n * running one that only polls, as `push` does for a dispatch.\n */\n private claimSoon() {\n this.startIfIdle();\n if (!this.driver.subscribe && this.state === \"running\") this.wake();\n }\n\n /**\n * Starts claiming. Idempotent, and called by the first `push`, so an app\n * does not need to; it is public for a process that should run jobs it\n * never dispatched — ones a driver kept across a restart — and for resuming\n * after `drain`.\n */\n start() {\n if (this.state === \"running\") return;\n this.state = \"running\";\n // Only a development server's loop over a shared driver: a memory queue\n // is only ever fed by its own application, and a hand-built manager or a\n // test's is its caller's to stop.\n if (this.durable && this.application && this.mayClaimHere() && !isProduction()) {\n globalThis.__gemiDevQueue = this;\n }\n this.unsubscribe = this.driver.subscribe?.(() => this.wake());\n // A loop a `drain` has not yet seen off picks the new state up itself;\n // starting a second would claim twice per wake.\n if (this.looping) return this.wake();\n bootScope.runInAsyncScope(() => void this.loop());\n }\n\n /**\n * Stops claiming, waits up to `timeoutMs` for the jobs already running, and\n * reports the ones that did not finish.\n *\n * Nothing is cancelled — a job has no way to be told — so an unfinished job\n * keeps running after this resolves. What happens to it then is the\n * driver's: the memory driver loses it with the process, along with every\n * job still waiting; one that outlives the process lets another claim it\n * once the lease runs out.\n *\n * A later `push` records its job but does not restart the loop. `start()`\n * does.\n */\n async drain(timeoutMs = Infinity): Promise<DrainResult> {\n this.state = \"stopped\";\n if (globalThis.__gemiDevQueue === this) globalThis.__gemiDevQueue = undefined;\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n this.wake();\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<void>((resolve) => {\n if (timeoutMs !== Infinity) timer = setTimeout(resolve, timeoutMs);\n });\n // The claim in progress first, because what it returns is run: those jobs\n // are leased to this process already, and handing them back would cost\n // each of them an attempt it never made.\n const settled = (async () => {\n await this.claiming?.catch(() => {});\n await Promise.allSettled([...this.inFlight.values()].map((e) => e.done));\n })();\n await Promise.race([settled, deadline]);\n clearTimeout(timer);\n\n return {\n unfinished: [...this.inFlight.values()].map((e) => ({ ...e.job })),\n };\n }\n\n /** `drain(0)`: stop claiming, and report what is running without waiting. */\n stop(): Promise<DrainResult> {\n return this.drain(0);\n }\n\n /** How many jobs this process is running right now. */\n get running(): number {\n return this.inFlight.size;\n }\n\n /**\n * Claims while there is room, runs what it claims, and otherwise sleeps\n * until something changes: a job finishing frees a slot, or the driver's\n * `subscribe` says there is work. A driver without `subscribe` is polled\n * every `pollInterval` instead. This replaces a one-second timer that\n * spun while the queue was full.\n *\n * `woken` records a wake that arrived while a claim was in flight, when\n * there was nothing yet to resume; without it that job would wait for the\n * next unrelated wake.\n */\n private async loop() {\n this.looping = true;\n try {\n await this.claimWhileRunning();\n } finally {\n this.looping = false;\n }\n }\n\n private async claimWhileRunning() {\n while (this.state === \"running\") {\n // Once the server has been told to stop, a driver that outlives the\n // process gets nothing new taken from it: a job claimed now would likely\n // be cut off by the exit, and cost an attempt and a lease's wait, when\n // another replica can run it instead. The memory driver keeps claiming\n // until the provider's `drain()` stops it, because nobody else can run\n // its jobs — one waiting at the signal, or dispatched by a request\n // still draining, is run here or not at all.\n const room = this.durable && isShuttingDown()\n ? 0\n : this.config.concurrency - this.inFlight.size;\n\n if (room > 0) {\n this.woken = false;\n const claim = this.driver.claim(room, {\n ...this.lease(),\n registered: {\n names: Object.keys(this.jobs),\n graceMs: this.config.unknownJobGrace,\n },\n });\n this.claiming = claim;\n let claimed: ClaimedJob[] = [];\n try {\n claimed = await claim;\n this.claimFailures = 0;\n } catch (error) {\n this.claimFailures++;\n console.error(\n `The queue could not claim jobs from its driver; it will try ` +\n `again in ${this.retryDelay()}ms.`,\n error,\n );\n } finally {\n this.claiming = undefined;\n }\n for (const job of claimed) this.execute(job);\n\n // A full batch may have left more behind; the next pass either claims\n // it or, with no room left, sleeps until a slot frees.\n if (claimed.length === room) continue;\n if (this.woken && this.inFlight.size < this.config.concurrency) {\n continue;\n }\n }\n\n await this.sleep();\n }\n }\n\n /**\n * Waits for the next thing worth waking for: a slot freeing, a `subscribe`\n * driver saying there is work, or the poll timer a driver without\n * `subscribe` gets.\n *\n * A claim that rejected arms a timer whatever the driver does, and that is\n * the whole reason this is not just the `subscribe` test. The wake that\n * prompted the lost claim has already been consumed, so a driver that only\n * speaks up on an enqueue — LISTEN/NOTIFY, say — has nothing left to\n * announce: an idle worker whose one claim died on a connection reset would\n * sit there, with every job already waiting, until some unrelated process\n * enqueued again. On a busy worker an in-flight job's `wake` covers it; an\n * idle one has nothing to be rescued by.\n *\n * The delay doubles per consecutive failure so that storage which is\n * properly down is not asked once a `pollInterval` for as long as it stays\n * down, and the first claim that returns clears the count.\n */\n private sleep() {\n return new Promise<void>((resolve) => {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const delay = this.claimFailures > 0\n ? this.retryDelay()\n : this.driver.subscribe\n ? undefined\n : this.config.pollInterval;\n if (delay !== undefined) {\n // Unref'd: a polling queue alone should not hold the process open.\n timer = setTimeout(() => this.wake(), delay);\n timer.unref?.();\n }\n this.resume = () => {\n clearTimeout(timer);\n resolve();\n };\n });\n }\n\n /** `pollInterval`, doubled once per consecutive claim failure, capped. */\n private retryDelay() {\n const doublings = Math.min(Math.max(0, this.claimFailures - 1), 30);\n return Math.min(this.config.pollInterval * 2 ** doublings, maxClaimBackoff);\n }\n\n private wake() {\n this.woken = true;\n const resume = this.resume;\n this.resume = undefined;\n resume?.();\n }\n\n /**\n * Whether the driver keeps jobs past this process: anything but memory.\n * Only such a queue can be fed by one process and drained by another.\n */\n get durable() {\n return !(this.driver instanceof MemoryQueueDriver);\n }\n\n /** See `claimsInThisProcess`. A manager built by hand always may. */\n private mayClaimHere() {\n return !this.application || claimsInThisProcess();\n }\n\n private lease(): ClaimOptions {\n return { visibilityTimeoutMs: this.config.visibilityTimeout };\n }\n\n private execute(claimed: ClaimedJob) {\n const key = `${claimed.id}:${claimed.attempt}`;\n const attempt = () => this.run(claimed);\n const done = (\n this.application\n ? kernelContext.run(this.application, attempt)\n : attempt()\n )\n .catch((error) => {\n // Only the driver's own reports reach here. The claim was not ended,\n // so its lease runs out and the job is claimed again.\n console.error(\n `The queue could not record the outcome of ${claimed.name}.`,\n error,\n );\n })\n .finally(() => {\n this.inFlight.delete(key);\n this.wake();\n });\n this.inFlight.set(key, { job: claimed, done });\n this.heartbeat();\n }\n\n /**\n * Keeps every running job's lease alive, at a third of the visibility\n * timeout so one late tick does not lose it. Stops itself once nothing is\n * running, and is unref'd, like the poll.\n */\n private heartbeat() {\n const driver = this.driver;\n if (!driver.heartbeat || this.heartbeatTimer) return;\n this.heartbeatTimer = setInterval(\n () => {\n if (this.inFlight.size === 0) {\n clearInterval(this.heartbeatTimer);\n this.heartbeatTimer = undefined;\n return;\n }\n const jobs = [...this.inFlight.values()].map((e) => e.job);\n driver.heartbeat!(jobs, this.lease()).catch((error) => {\n console.error(`The queue could not extend its job leases.`, error);\n });\n },\n Math.max(1, Math.floor(this.config.visibilityTimeout / 3)),\n );\n this.heartbeatTimer.unref?.();\n }\n\n /**\n * One attempt at one claimed job, ending the claim either way.\n *\n * `onSuccess` is inside the `try`, as it always was, so a throw from it is a\n * failed attempt and is retried. `onFail` and `onDeadletter` are not: a\n * throw from either is logged and the claim still ends, where it used to\n * escape the queue with the job's slot still counted as taken.\n */\n private async run(claimed: ClaimedJob) {\n const Job = this.jobs[claimed.name];\n\n if (!Job) {\n // A driver other processes share may have handed this out because it\n // cannot filter by name, and while a blue/green ramp has both releases\n // claiming from one table, a name this replica lacks is usually one only\n // the other release has. So it goes back, without spending an attempt,\n // for a replica that has the class — until `unknownJobGrace` has passed\n // since the dispatch, after which the name is taken to be gone. Measured\n // from `createdAt` because that is all a claim carries; it is the\n // driver's clock against this one, and the skew is seconds against a\n // window of minutes. A driver that does filter only hands out an unknown\n // name once it has waited out the same window, so it normally lands\n // below; with this clock a few seconds behind the driver's, one handed\n // out right at the boundary is released instead, and — its window now\n // restarting from the release — waits one more `unknownJobGrace`. Late,\n // not lost, so no slack is subtracted for it.\n const age = Date.now() - claimed.createdAt;\n if (this.durable && age < this.config.unknownJobGrace) {\n // Once per name: with a driver that cannot filter, every poll can\n // claim the same job again, and a line per poll would bury the one\n // that matters — a replica whose discovery missed a job, say.\n if (!this.releasedNames.has(claimed.name)) {\n this.releasedNames.add(claimed.name);\n console.error(\n `Left a queued \"${claimed.name}\" for another replica: nothing is ` +\n `registered here under that name. It is dead-lettered if no ` +\n `replica has run it within unknownJobGrace ` +\n `(${this.config.unknownJobGrace}ms) of its dispatch.`,\n );\n }\n // Off this replica's own rhythm, and differently each time. It claims\n // again the moment the release lands, finds nothing due, and then\n // polls every `pollInterval`; a delay of exactly one interval made the\n // job due at the instant of that next poll, so the replica that could\n // not run it won the race for it every time. Any fixed fraction has\n // the same flaw for a replica whose polls happen to fall just before\n // the due moment each cycle — it loses every race, for good. Random\n // within one interval, every other replica's next poll has a chance.\n await this.driver.release(claimed, {\n retryInMs: Math.round(\n this.config.pollInterval * (1 + Math.random()),\n ),\n });\n return;\n }\n\n // The one place this is observable. A dispatch carries a name, the\n // registry is keyed by name, and a name nobody registered matches\n // nothing — which is exactly the silence #322 is about, except here it\n // has already happened and the work is gone. Saying so is all that is\n // left to do about it. Dead-lettered, which for the memory driver is the\n // drop it always was and for a durable one leaves a record to find.\n console.error(\n `Dropped a queued job: nothing is registered under the name ` +\n `\"${claimed.name}\". If the class exists, it was not ` +\n `discovered — check that it is under the queue slice's jobsDir ` +\n `(app/jobs by default), or list it in app/config/queue.ts.`,\n );\n await this.driver.fail(claimed, {\n error: `No job is registered under the name \"${claimed.name}\".`,\n retryInMs: null,\n });\n return;\n }\n\n let job: InstanceType<typeof Job>;\n try {\n job = new Job();\n } catch (error) {\n // A constructor or a class field that throws — `private mailer =\n // app(Mailer)` with nothing bound, say. Every other failure in here is\n // reported against the instance, and this one has no instance to report\n // against, which is exactly why it has to be caught here rather than\n // left to the generic path: that path never ends the claim, so the lease\n // lapses, the job is claimed again, and the constructor throws again,\n // once per visibility timeout, forever. The `maxAttempts` guard below\n // would normally stop that, and it cannot — answering \"how many attempts\n // does this job get?\" needs the instance that cannot be built. So it is\n // dead-lettered unrun, like a job whose arguments are not JSON: no\n // attempt of it can ever do anything but this.\n console.error(\n `Dropped a queued ${claimed.name}: it could not be constructed.`,\n error,\n );\n await this.driver.fail(claimed, {\n error: `The job could not be constructed: ${String(error)}`,\n retryInMs: null,\n });\n return;\n }\n\n let args: any[];\n try {\n args = JSON.parse(claimed.args);\n } catch (error) {\n // Not something `Job.dispatch` writes, so a driver changed it. Left\n // alone, the claim would never end and the job would be reclaimed,\n // unparseable, forever.\n console.error(\n `Dropped a queued ${claimed.name}: its arguments are not JSON.`,\n error,\n );\n await this.driver.fail(claimed, {\n error: `The arguments are not JSON: ${String(error)}`,\n retryInMs: null,\n });\n return;\n }\n\n // Claimed past its last attempt: an earlier claim used that attempt up and\n // never reported, which is what a process exiting mid-run looks like from\n // here. Running it again would exceed `maxAttempts`, so it is dead-lettered\n // unrun. `Math.max` keeps a `maxAttempts` below one meaning what it always\n // did — one attempt.\n if (claimed.attempt > Math.max(1, job.maxAttempts)) {\n const error = new Error(\n `${claimed.name} was claimed for attempt ${claimed.attempt} of ` +\n `${job.maxAttempts}: an earlier attempt never finished, most likely ` +\n `because the process running it exited. Dead-lettered without ` +\n `running it again.`,\n );\n hook(`${claimed.name}.onDeadletter`, () =>\n job.onDeadletter(error, ...args),\n );\n await this.driver.fail(claimed, {\n error: error.message,\n retryInMs: null,\n });\n return;\n }\n\n try {\n const result = await (job.worker\n ? runInWorker(claimed.name, claimed.args)\n : job.run(...args));\n\n job.onSuccess(result, ...args);\n } catch (err) {\n const error = err as Error;\n const recorded = String(error?.stack ?? error);\n hook(`${claimed.name}.onFail`, () => job.onFail(error, ...args));\n\n if (claimed.attempt >= job.maxAttempts) {\n hook(`${claimed.name}.onDeadletter`, () =>\n job.onDeadletter(error, ...args),\n );\n await this.driver.fail(claimed, { error: recorded, retryInMs: null });\n } else {\n await this.driver.fail(claimed, {\n error: recorded,\n retryInMs: backoffFor(job.backoff, claimed.attempt),\n });\n }\n return;\n }\n\n await this.driver.complete(claimed);\n }\n}\n\nfunction hook(name: string, fn: () => void) {\n try {\n fn();\n } catch (error) {\n console.error(`${name} threw; the job's claim was ended anyway.`, error);\n }\n}\n\nfunction isProduction() {\n return process.env.NODE_ENV === \"production\";\n}\n\n/**\n * Whether this process should claim from a driver shared with other\n * processes: a `gemi queue:work` worker, or a server's main thread unless\n * `GEMI_QUEUE_CLAIM=off` hands its jobs to workers. `ROOT_DIR` is set only by\n * a starting server or worker, so a console command, a seed\n * or a migration — which boot the same providers — is not one, and neither is\n * a `worker` job's thread, which clones the application and exits after it.\n *\n * A worker claims whatever `GEMI_QUEUE_CLAIM` says, because the variable is\n * for the web process, and a deploy that sets it once for every container\n * would otherwise leave nothing claiming at all.\n */\nexport function claimsInThisProcess() {\n if (!isMainThread) return false;\n if (isQueueWorker()) return true;\n return process.env.ROOT_DIR !== undefined && !claimingTurnedOff();\n}\n\n/**\n * `GEMI_QUEUE_CLAIM=off` (any case): this server dispatches into a shared\n * driver and leaves the claiming to `gemi queue:work` processes. Anything else\n * claims, as before. An environment variable rather than a config field for\n * the reason `GEMI_NO_SCHEDULE` is one: the web and the worker run the same\n * build with the same config, and only the process knows which it is.\n */\nexport function claimingTurnedOff(env: Record<string, string | undefined> = process.env) {\n return (env.GEMI_QUEUE_CLAIM ?? \"\").trim().toLowerCase() === \"off\";\n}\n\n// On `globalThis` under a registry symbol, like the shutdown flag, so the mark\n// the worker entry sets is the one this module reads if two copies of it are\n// loaded. Not an environment variable: a job that spawns a child process\n// would hand it on, and the child, a script, would start claiming.\nconst QUEUE_WORKER = Symbol.for(\"gemi.queue.worker\");\n\n/** Marks this process as a `gemi queue:work` worker; see `claimsInThisProcess`. */\nexport function markQueueWorker(worker = true) {\n (globalThis as { [QUEUE_WORKER]?: boolean })[QUEUE_WORKER] = worker;\n}\n\nexport function isQueueWorker(): boolean {\n return (globalThis as { [QUEUE_WORKER]?: boolean })[QUEUE_WORKER] === true;\n}\n\n/**\n * The delay before the retry that follows attempt `attempt`: the number\n * itself, or the array's entry for that retry with its last entry repeated.\n */\nexport function backoffFor(backoff: number | number[], attempt: number) {\n const delay = Array.isArray(backoff)\n ? backoff[Math.min(attempt, backoff.length) - 1]\n : backoff;\n return Math.max(0, delay ?? 0);\n}\n\nfunction resolveDriver(\n driver: Required<QueueConfig>[\"driver\"],\n application: Application | undefined,\n): QueueDriver {\n if (driver === \"memory\") return new MemoryQueueDriver();\n if (driver === \"database\" || typeof driver === \"function\") {\n // Only a manager built by hand has no application. A factory that takes\n // one would otherwise fail on `undefined` with a TypeError that names\n // neither the queue nor what is missing.\n if (!application && (driver === \"database\" || driver.length > 0)) {\n throw new Error(\n `The queue driver needs the application it belongs to, and this ` +\n `QueueManager was built without one. Pass { application }.`,\n );\n }\n if (driver === \"database\") {\n return new DatabaseQueueDriver(application!.make(DatabaseManager));\n }\n return driver(application!);\n }\n if (typeof driver === \"string\") {\n throw new Error(\n `Unknown queue driver \"${driver}\". The queue slice's driver is ` +\n `\"memory\", \"database\", a QueueDriver, or a function returning one.`,\n );\n }\n return driver;\n}\n"
9
9
  ],
10
10
  "mappings": ";6PAqGO,AAAM,LAA2C,LAC7C,AACQ,IACA,QAEA,WACA,YACT,WAER,WAAW,CACT,EAEA,EAAsC,CAAC,EACvC,CACA,IAAM,EAAQ,EAAQ,OAAS,YAC/B,GAAI,CAAC,2BAA2B,KAAK,CAAK,EACxC,MAAU,MACR,yBAAyB,oEAE3B,EAEF,IAAM,EAAc,EAAQ,aAAe,KAC3C,GAAI,CAAC,OAAO,UAAU,CAAW,GAAK,EAAc,EAClD,MAAU,MACR,kFAAkF,IACpF,EAEF,KAAK,MAAQ,EACb,KAAK,IAAM,EAAW,IACtB,KAAK,QAAU,EAAW,QAC1B,KAAK,WAAa,EAAW,KAC7B,KAAK,YAAc,EAgCb,SAAS,EAAkB,CACjC,GAAI,K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