thursday-agent 0.17.2 → 0.18.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 (362) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +1 -0
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/routes-manifest.json +6 -0
  6. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  7. package/.next/server/app/_global-error.html +1 -1
  8. package/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  13. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/_not-found.html +1 -1
  15. package/.next/server/app/_not-found.rsc +2 -2
  16. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  17. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  18. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  19. package/.next/server/app/api/artifact/route.js +7 -7
  20. package/.next/server/app/api/artifact/route.js.nft.json +1 -1
  21. package/.next/server/app/api/bot/memory/files/route.js +4 -4
  22. package/.next/server/app/api/bot/memory/files/route.js.nft.json +1 -1
  23. package/.next/server/app/api/bot/memory/route.js +1 -1
  24. package/.next/server/app/api/bot/memory/route.js.nft.json +1 -1
  25. package/.next/server/app/api/bot/route.js +1 -1
  26. package/.next/server/app/api/bot/route.js.nft.json +1 -1
  27. package/.next/server/app/api/bot/thread/[id]/route.js +1 -1
  28. package/.next/server/app/api/bot/thread/[id]/route.js.nft.json +1 -1
  29. package/.next/server/app/api/bot/thread/file/route/app-paths-manifest.json +3 -0
  30. package/.next/server/app/api/bot/thread/file/route/build-manifest.json +12 -0
  31. package/.next/server/app/api/bot/thread/file/route/server-reference-manifest.json +4 -0
  32. package/.next/server/app/api/bot/thread/file/route.js +29 -0
  33. package/.next/server/app/api/bot/thread/file/route.js.map +5 -0
  34. package/.next/server/app/api/bot/thread/file/route.js.nft.json +1 -0
  35. package/.next/server/app/api/bot/thread/file/route_client-reference-manifest.js +3 -0
  36. package/.next/server/app/api/bot/thread/route.js +1 -1
  37. package/.next/server/app/api/bot/thread/route.js.nft.json +1 -1
  38. package/.next/server/app/api/config/route.js +1 -1
  39. package/.next/server/app/api/config/route.js.nft.json +1 -1
  40. package/.next/server/app/api/events/route.js +2 -2
  41. package/.next/server/app/api/events/route.js.nft.json +1 -1
  42. package/.next/server/app/api/favicon/[host]/route.js.nft.json +1 -1
  43. package/.next/server/app/api/file/[...path]/route.js +4 -4
  44. package/.next/server/app/api/file/[...path]/route.js.nft.json +1 -1
  45. package/.next/server/app/api/llm-model/automatic/route.js +1 -1
  46. package/.next/server/app/api/llm-model/automatic/route.js.nft.json +1 -1
  47. package/.next/server/app/api/llm-model/catalog/route.js +1 -1
  48. package/.next/server/app/api/llm-model/catalog/route.js.nft.json +1 -1
  49. package/.next/server/app/api/llm-model/credits/route.js +1 -1
  50. package/.next/server/app/api/llm-model/credits/route.js.nft.json +1 -1
  51. package/.next/server/app/api/llm-model/route.js +1 -1
  52. package/.next/server/app/api/llm-model/route.js.nft.json +1 -1
  53. package/.next/server/app/api/llm-model/subscription/route.js +1 -1
  54. package/.next/server/app/api/llm-model/subscription/route.js.nft.json +1 -1
  55. package/.next/server/app/api/mcp/[name]/route.js +1 -1
  56. package/.next/server/app/api/mcp/[name]/route.js.nft.json +1 -1
  57. package/.next/server/app/api/mcp/oauth/callback/route.js +2 -2
  58. package/.next/server/app/api/mcp/oauth/callback/route.js.nft.json +1 -1
  59. package/.next/server/app/api/mcp/route.js +1 -1
  60. package/.next/server/app/api/mcp/route.js.nft.json +1 -1
  61. package/.next/server/app/api/mcp/tools/route.js +1 -1
  62. package/.next/server/app/api/mcp/tools/route.js.nft.json +1 -1
  63. package/.next/server/app/api/memory/edit/route.js +1 -1
  64. package/.next/server/app/api/memory/edit/route.js.nft.json +1 -1
  65. package/.next/server/app/api/memory/route.js +1 -1
  66. package/.next/server/app/api/memory/route.js.nft.json +1 -1
  67. package/.next/server/app/api/reach/route.js +1 -1
  68. package/.next/server/app/api/reach/route.js.nft.json +1 -1
  69. package/.next/server/app/api/routine/route.js +1 -1
  70. package/.next/server/app/api/routine/route.js.nft.json +1 -1
  71. package/.next/server/app/api/signins/route.js +1 -1
  72. package/.next/server/app/api/signins/route.js.nft.json +1 -1
  73. package/.next/server/app/api/skills/[source]/[name]/route.js +1 -1
  74. package/.next/server/app/api/skills/[source]/[name]/route.js.nft.json +1 -1
  75. package/.next/server/app/api/skills/route.js +1 -1
  76. package/.next/server/app/api/skills/route.js.nft.json +1 -1
  77. package/.next/server/app/api/thursday/call/end/route.js +1 -1
  78. package/.next/server/app/api/thursday/call/end/route.js.nft.json +1 -1
  79. package/.next/server/app/api/thursday/call/route.js +1 -1
  80. package/.next/server/app/api/thursday/call/route.js.nft.json +1 -1
  81. package/.next/server/app/api/thursday/settings/route.js +1 -1
  82. package/.next/server/app/api/thursday/settings/route.js.nft.json +1 -1
  83. package/.next/server/app/api/thursday/text/route.js +1 -1
  84. package/.next/server/app/api/thursday/text/route.js.nft.json +1 -1
  85. package/.next/server/app/api/thursday/tool-call/route.js +1 -1
  86. package/.next/server/app/api/thursday/tool-call/route.js.nft.json +1 -1
  87. package/.next/server/app/api/workspace/files/route.js +1 -1
  88. package/.next/server/app/api/workspace/files/route.js.nft.json +1 -1
  89. package/.next/server/app/api/workspace/route.js +1 -1
  90. package/.next/server/app/api/workspace/route.js.nft.json +1 -1
  91. package/.next/server/app/artifact/[...path]/page/server-reference-manifest.json +94 -6
  92. package/.next/server/app/artifact/[...path]/page.js +9 -6
  93. package/.next/server/app/artifact/[...path]/page.js.nft.json +1 -1
  94. package/.next/server/app/artifact/[...path]/page_client-reference-manifest.js +1 -1
  95. package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  96. package/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  97. package/.next/server/app/page/server-reference-manifest.json +161 -128
  98. package/.next/server/app/page.js +9 -9
  99. package/.next/server/app/page.js.nft.json +1 -1
  100. package/.next/server/app/page_client-reference-manifest.js +1 -1
  101. package/.next/server/app-paths-manifest.json +1 -0
  102. package/.next/server/chunks/{[externals]__12stas-._.js → [externals]__178rv3v._.js} +1 -1
  103. package/.next/server/chunks/[root-of-the-server]__00qyw01._.js +1 -1
  104. package/.next/server/chunks/[root-of-the-server]__02ra64t._.js +5 -0
  105. package/.next/server/chunks/[root-of-the-server]__03xamry._.js +1 -1
  106. package/.next/server/chunks/[root-of-the-server]__04hhvpu._.js +7 -0
  107. package/.next/server/chunks/[root-of-the-server]__05dp5tr._.js +1 -1
  108. package/.next/server/chunks/[root-of-the-server]__0bqveex._.js +1 -1
  109. package/.next/server/chunks/{[root-of-the-server]__1_h4hf9._.js → [root-of-the-server]__0brmiv2._.js} +4 -4
  110. package/.next/server/chunks/[root-of-the-server]__0gvdr2h._.js +5 -0
  111. package/.next/server/chunks/[root-of-the-server]__0h656y-._.js +1 -1
  112. package/.next/server/chunks/[root-of-the-server]__0lvjz0b._.js +5 -0
  113. package/.next/server/chunks/[root-of-the-server]__0mgyt8p._.js +1 -1
  114. package/.next/server/chunks/[root-of-the-server]__0mrk2it._.js +1 -1
  115. package/.next/server/chunks/[root-of-the-server]__0my9geo._.js +3 -0
  116. package/.next/server/chunks/[root-of-the-server]__0qdoc_9._.js +5 -0
  117. package/.next/server/chunks/[root-of-the-server]__0sm5xvm._.js +1 -1
  118. package/.next/server/chunks/[root-of-the-server]__0v_kuor._.js +5 -0
  119. package/.next/server/chunks/[root-of-the-server]__1-rmal0._.js +1 -1
  120. package/.next/server/chunks/[root-of-the-server]__13hng6h._.js +1 -1
  121. package/.next/server/chunks/[root-of-the-server]__1_04mcf._.js +2 -2
  122. package/.next/server/chunks/[root-of-the-server]__1ceammd._.js +1 -1
  123. package/.next/server/chunks/[root-of-the-server]__1dth047._.js +5 -0
  124. package/.next/server/chunks/[root-of-the-server]__1etbk64._.js +3 -0
  125. package/.next/server/chunks/[root-of-the-server]__1izes4_._.js +7 -0
  126. package/.next/server/chunks/[root-of-the-server]__1ksm9m-._.js +12 -0
  127. package/.next/server/chunks/[root-of-the-server]__1m_dmf6._.js +5 -0
  128. package/.next/server/chunks/[root-of-the-server]__1mys2c3._.js +5 -0
  129. package/.next/server/chunks/[root-of-the-server]__1ndi14y._.js +1 -1
  130. package/.next/server/chunks/[root-of-the-server]__1p0njle._.js +5 -0
  131. package/.next/server/chunks/[root-of-the-server]__1p47fbb._.js +2 -2
  132. package/.next/server/chunks/[root-of-the-server]__1ygplx1._.js +1 -1
  133. package/.next/server/chunks/[root-of-the-server]__1zn039k._.js +1 -1
  134. package/.next/server/chunks/_01c32w9._.js +1 -1
  135. package/.next/server/chunks/_02bov6_._.js +1 -1
  136. package/.next/server/chunks/_06hnfi8._.js +2 -2
  137. package/.next/server/chunks/_06u9yo-._.js +1 -1
  138. package/.next/server/chunks/_07nxi75._.js +42 -41
  139. package/.next/server/chunks/_08354bn._.js +12 -11
  140. package/.next/server/chunks/{_08btiir._.js → _08_-9ay._.js} +3 -3
  141. package/.next/server/chunks/_08s4vft._.js +1 -1
  142. package/.next/server/chunks/_0bgjf07._.js +5 -0
  143. package/.next/server/chunks/_0fb6dvr._.js +1 -1
  144. package/.next/server/chunks/_0hgvg55._.js +1 -1
  145. package/.next/server/chunks/_0iw19ig._.js +1 -1
  146. package/.next/server/chunks/_0poi1t2._.js +1 -1
  147. package/.next/server/chunks/_0srlnvd._.js +6 -6
  148. package/.next/server/chunks/_0t_7gji._.js +1 -1
  149. package/.next/server/chunks/_0uzj57i._.js +1 -1
  150. package/.next/server/chunks/_0wyh244._.js +112 -0
  151. package/.next/server/chunks/_0xygcxs._.js +42 -41
  152. package/.next/server/chunks/_1-sk_q4._.js +1 -1
  153. package/.next/server/chunks/_108gsm8._.js +2 -2
  154. package/.next/server/chunks/_136j09a._.js +5 -5
  155. package/.next/server/chunks/_15negpy._.js +2 -2
  156. package/.next/server/chunks/_1d7og_q._.js +1 -1
  157. package/.next/server/chunks/_1dxq827._.js +2 -2
  158. package/.next/server/chunks/_1e54wxa._.js +1 -1
  159. package/.next/server/chunks/_1gn2r2q._.js +6 -6
  160. package/.next/server/chunks/_1i3uucm._.js +1 -1
  161. package/.next/server/chunks/_1jvy78-._.js +5 -0
  162. package/.next/server/chunks/_1q6e56i._.js +6 -6
  163. package/.next/server/chunks/_1qgix-j._.js +1 -1
  164. package/.next/server/chunks/_1wwl_7o._.js +1 -1
  165. package/.next/server/chunks/_1y8w80a._.js +5 -5
  166. package/.next/server/chunks/_1yx285_._.js +3 -0
  167. package/.next/server/chunks/_20qn224._.js +3 -0
  168. package/.next/server/chunks/_211dn2c._.js +1 -1
  169. package/.next/server/chunks/_next-internal_server_app_api_bot_thread_file_route_actions_0q3be0o.js +3 -0
  170. package/.next/server/chunks/config_ts_1g4sz5o._.js +1 -1
  171. package/.next/server/chunks/features_bot_08z387_._.js +3 -3
  172. package/.next/server/chunks/features_workspace_workspace_ts_13h82gv._.js +3 -3
  173. package/.next/server/chunks/features_workspace_workspace_ts_1iyjroj._.js +3 -3
  174. package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_04oxl25._.js → node_modules_consola_dist_chunks_prompt_mjs_0yd5xa0._.js} +1 -1
  175. package/.next/server/chunks/ssr/[root-of-the-server]__04upd5v._.js +1 -1
  176. package/.next/server/chunks/ssr/[root-of-the-server]__06knwl5._.js +3 -0
  177. package/.next/server/chunks/ssr/[root-of-the-server]__07ehpky._.js +3 -0
  178. package/.next/server/chunks/ssr/[root-of-the-server]__0h6jo0s._.js +3 -0
  179. package/.next/server/chunks/ssr/[root-of-the-server]__128hnrd._.js +3 -0
  180. package/.next/server/chunks/ssr/[root-of-the-server]__1867koj._.js +1 -1
  181. package/.next/server/chunks/ssr/[root-of-the-server]__1gzje-h._.js +3 -0
  182. package/.next/server/chunks/ssr/{[root-of-the-server]__1d7usu0._.js → [root-of-the-server]__1qn0axo._.js} +2 -2
  183. package/.next/server/chunks/ssr/[root-of-the-server]__1r7tj27._.js +3 -0
  184. package/.next/server/chunks/ssr/[root-of-the-server]__1tb5vve._.js +46 -0
  185. package/.next/server/chunks/ssr/{features_bot_1knyan7._.js → _07nmtxo._.js} +2 -2
  186. package/.next/server/chunks/ssr/{_10-_awu._.js → _0f9hx5p._.js} +2 -2
  187. package/.next/server/chunks/ssr/_0fo4552._.js +10 -9
  188. package/.next/server/chunks/ssr/{_123y-ah._.js → _0is8m6y._.js} +2 -2
  189. package/.next/server/chunks/ssr/{_17a4qyk._.js → _0ixe3g3._.js} +3 -3
  190. package/.next/server/chunks/ssr/_0j9vh-8._.js +3 -0
  191. package/.next/server/chunks/ssr/_0l7rjg5._.js +1 -1
  192. package/.next/server/chunks/ssr/{lib_logger_ts_0-olsze._.js → _0mfgsk-._.js} +4 -2
  193. package/.next/server/chunks/ssr/_0mpn6q0._.js +5 -0
  194. package/.next/server/chunks/ssr/{_0e2fnvg._.js → _0osvxkt._.js} +2 -2
  195. package/.next/server/chunks/ssr/_0p6w0ef._.js +3 -0
  196. package/.next/server/chunks/ssr/_0pbav_w._.js +3 -0
  197. package/.next/server/chunks/ssr/{_1aqjk-1._.js → _0wuvkqk._.js} +2 -2
  198. package/.next/server/chunks/ssr/_0x8ophf._.js +1 -1
  199. package/.next/server/chunks/ssr/_0x9f717._.js +60 -0
  200. package/.next/server/chunks/ssr/_1-41lck._.js +1 -1
  201. package/.next/server/chunks/ssr/_10jtmhl._.js +3 -0
  202. package/.next/server/chunks/ssr/{_0xfafez._.js → _12jv_41._.js} +2 -2
  203. package/.next/server/chunks/ssr/{_163dr78._.js → _165wnr4._.js} +2 -2
  204. package/.next/server/chunks/ssr/_16_7zeo._.js +3 -0
  205. package/.next/server/chunks/ssr/{_14oirtb._.js → _1_ogjze._.js} +2 -2
  206. package/.next/server/chunks/ssr/_1bfrntd._.js +6 -0
  207. package/.next/server/chunks/ssr/_1i2swyr._.js +3 -0
  208. package/.next/server/chunks/ssr/{_10_ph1t._.js → _1jd8rjm._.js} +2 -2
  209. package/.next/server/chunks/ssr/_1mdjoak._.js +162 -0
  210. package/.next/server/chunks/ssr/_1neoj22._.js +1 -1
  211. package/.next/server/chunks/ssr/{_1dfv66y._.js → _1oafxdu._.js} +2 -2
  212. package/.next/server/chunks/ssr/_1omom9y._.js +3 -0
  213. package/.next/server/chunks/ssr/_1pgxh81._.js +271 -0
  214. package/.next/server/chunks/ssr/{_0vo_oym._.js → _1r4mc3i._.js} +2 -2
  215. package/.next/server/chunks/ssr/_1soynbw._.js +6 -0
  216. package/.next/server/chunks/ssr/{_01al00i._.js → _1tx-2k7._.js} +2 -2
  217. package/.next/server/chunks/ssr/_1w899wx._.js +3 -0
  218. package/.next/server/chunks/ssr/_1xwtbdz._.js +3 -0
  219. package/.next/server/chunks/ssr/features_0796o8r._.js +1 -1
  220. package/.next/server/chunks/ssr/features_bot_0tb4ui-._.js +2 -2
  221. package/.next/server/chunks/ssr/features_bot_18gqkr_._.js +3 -0
  222. package/.next/server/chunks/ssr/{features_config_09n-q9q._.js → features_config_1ond01n._.js} +3 -3
  223. package/.next/server/chunks/ssr/features_connectors_components_mcp-setting_tsx_0jmbgvp._.js +1 -1
  224. package/.next/server/chunks/ssr/features_memory_components_memory-setting_tsx_0oa43sw._.js +1 -1
  225. package/.next/server/chunks/ssr/features_routine_components_routine-setting_tsx_055fknz._.js +1 -1
  226. package/.next/server/chunks/ssr/features_workspace_workspace_ts_1wc7_u_._.js +4 -4
  227. package/.next/server/chunks/ssr/{node_modules_0msrhxf._.js → node_modules_004qt-z._.js} +1 -1
  228. package/.next/server/chunks/ssr/{node_modules_0q-klni._.js → node_modules_06m6e97._.js} +1 -1
  229. package/.next/server/chunks/ssr/{node_modules_13g-d25._.js → node_modules_09dy7tk._.js} +1 -1
  230. package/.next/server/chunks/ssr/{node_modules_0gd9hbz._.js → node_modules_0_hy3i2._.js} +1 -1
  231. package/.next/server/chunks/ssr/{node_modules_1gq3ght._.js → node_modules_0f485jl._.js} +1 -1
  232. package/.next/server/chunks/ssr/{node_modules_096up6a._.js → node_modules_0gbx70b._.js} +1 -1
  233. package/.next/server/chunks/ssr/{node_modules_13bqv6i._.js → node_modules_0i_v0-m._.js} +1 -1
  234. package/.next/server/chunks/ssr/{node_modules_04x5wyv._.js → node_modules_0lrn9ci._.js} +1 -1
  235. package/.next/server/chunks/ssr/{node_modules_0d6j33x._.js → node_modules_0lxwg2v._.js} +1 -1
  236. package/.next/server/chunks/ssr/{node_modules_113l3e5._.js → node_modules_0n2-p5q._.js} +1 -1
  237. package/.next/server/chunks/ssr/node_modules_0nj36zf._.js +3 -0
  238. package/.next/server/chunks/ssr/{node_modules_0cjnmzp._.js → node_modules_0ppirau._.js} +1 -1
  239. package/.next/server/chunks/ssr/{node_modules_0m73b88._.js → node_modules_0pw13ww._.js} +1 -1
  240. package/.next/server/chunks/ssr/node_modules_0qd7p5f._.js +3 -0
  241. package/.next/server/chunks/ssr/{node_modules_0nmkv-v._.js → node_modules_0upwx50._.js} +1 -1
  242. package/.next/server/chunks/ssr/{node_modules_0__0tvm._.js → node_modules_0v__o4h._.js} +1 -1
  243. package/.next/server/chunks/ssr/{node_modules_1k5i-_9._.js → node_modules_1-4q6is._.js} +1 -1
  244. package/.next/server/chunks/ssr/{node_modules_156kv_t._.js → node_modules_10mb0cv._.js} +1 -1
  245. package/.next/server/chunks/ssr/{node_modules_10_fv2a._.js → node_modules_16z7p8b._.js} +1 -1
  246. package/.next/server/chunks/ssr/{node_modules_1lmyts8._.js → node_modules_17o218r._.js} +1 -1
  247. package/.next/server/chunks/ssr/{node_modules_0k8-y89._.js → node_modules_1gpapfv._.js} +1 -1
  248. package/.next/server/chunks/ssr/{node_modules_1_8-jcj._.js → node_modules_1hdaxu9._.js} +1 -1
  249. package/.next/server/chunks/ssr/{node_modules_1ri_eip._.js → node_modules_1hjvwkh._.js} +1 -1
  250. package/.next/server/chunks/ssr/{node_modules_0nw5jz7._.js → node_modules_1j886a5._.js} +1 -1
  251. package/.next/server/chunks/ssr/{node_modules_1xb-ndg._.js → node_modules_1srjf5c._.js} +1 -1
  252. package/.next/server/chunks/ssr/{node_modules_1p_6sq7._.js → node_modules_1tus4vi._.js} +1 -1
  253. package/.next/server/chunks/ssr/{node_modules_021lid9._.js → node_modules_1tv_7lk._.js} +1 -1
  254. package/.next/server/chunks/ssr/{node_modules_1qstb1x._.js → node_modules_20448xv._.js} +1 -1
  255. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0amkw0b._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0lg9pkl._.js} +1 -1
  256. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0zq3l45._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1xgbf5j._.js} +1 -1
  257. package/.next/server/middleware-build-manifest.js +3 -3
  258. package/.next/server/middleware.js +1 -1
  259. package/.next/server/pages/404.html +1 -1
  260. package/.next/server/pages/500.html +1 -1
  261. package/.next/server/server-reference-manifest.js +1 -1
  262. package/.next/server/server-reference-manifest.json +205 -132
  263. package/.next/static/chunks/{166smhw8v-s3j.js → 05uvci-bk-vgp.js} +1 -1
  264. package/.next/static/chunks/09y_43y1cy5jw.js +1 -0
  265. package/.next/static/chunks/0_s4z70lx1tgs.js +1 -0
  266. package/.next/static/chunks/0oqviw3f55nfp.js +58 -0
  267. package/.next/static/chunks/0q9b2n6l4flqb.js +1 -0
  268. package/.next/static/chunks/0ruf3dqs--3ve.js +1 -0
  269. package/.next/static/chunks/0vggwjufw2-6r.js +1 -0
  270. package/.next/static/chunks/{3sla-dm1puqd1.js → 0x4m9nj2fazl2.js} +1 -1
  271. package/.next/static/chunks/{3t2c76awm9k_p.js → 1-1yfu34-3p2p.js} +1 -1
  272. package/.next/static/chunks/10oyyypxn_cpx.js +1 -0
  273. package/.next/static/chunks/{1cglo3a2mbeou.js → 17dx6w478vnb0.js} +1 -1
  274. package/.next/static/chunks/184-r80rv0xay.css +1 -0
  275. package/.next/static/chunks/1_hgdoungpm0o.js +1 -0
  276. package/.next/static/chunks/{0obogzscwwekj.js → 1dpg1u4a16ujt.js} +1 -1
  277. package/.next/static/chunks/{2qgkbdshzpq1c.js → 1h_6rh86q3i4p.js} +1 -1
  278. package/.next/static/chunks/{3b96xy59nl_gd.js → 1pe7i5yu779ta.js} +1 -1
  279. package/.next/static/chunks/{2zbl41hed17g3.js → 240nfv2dtidhc.js} +1 -1
  280. package/.next/static/chunks/{0uxq_vs6uxi-b.js → 27l8qwnk1j66z.js} +1 -1
  281. package/.next/static/chunks/2gxfy__ef51n9.js +3 -0
  282. package/.next/static/chunks/2kjwmo70judc2.js +15 -0
  283. package/.next/static/chunks/{3gsxnqqqphh-1.js → 2lzg4zedtmyic.js} +1 -1
  284. package/.next/static/chunks/2ug8q1x9e-_j6.js +1 -0
  285. package/.next/static/chunks/{01l7kw74vfp32.js → 2uk8rdtr-pk58.js} +1 -1
  286. package/.next/static/chunks/337g9g_ux2gj-.js +1 -0
  287. package/.next/static/chunks/{0o7o0eb7ihxi6.js → 396enq-m0sss5.js} +1 -1
  288. package/.next/static/chunks/{0p2f6uv4xytfm.js → 3r7u1y9xjoh-v.js} +1 -1
  289. package/.next/static/chunks/{3jtcieuk1l6tw.js → 3vg1-oc-zgw_7.js} +1 -1
  290. package/.next/static/chunks/40re_3ukjulg9.js +1 -0
  291. package/.next/static/chunks/41ztsnjn4qrn-.js +1 -0
  292. package/README.md +5 -5
  293. package/bin/autostart.mjs +32 -2
  294. package/bin/lock.mjs +85 -4
  295. package/bin/thursday.mjs +42 -15
  296. package/bin/tools.mjs +18 -1
  297. package/database/migrations/20260926021847_thread_cache_tokens/migration.sql +2 -0
  298. package/database/migrations/20260926021847_thread_cache_tokens/snapshot.json +1949 -0
  299. package/guide/bots.md +173 -317
  300. package/guide/calls.md +98 -146
  301. package/guide/index.md +2 -2
  302. package/guide/memory.md +14 -18
  303. package/guide/phone.md +86 -133
  304. package/guide/setup.md +127 -172
  305. package/guide/trouble.md +42 -65
  306. package/package.json +1 -1
  307. package/seed-skills/concierge/travel/scripts/itinerary.mjs +1 -1
  308. package/skills/artifact/runtime/shell/shell.js +32 -3
  309. package/.next/server/chunks/[root-of-the-server]__01ypm_z._.js +0 -3
  310. package/.next/server/chunks/[root-of-the-server]__021dkui._.js +0 -3
  311. package/.next/server/chunks/[root-of-the-server]__09gdscj._.js +0 -7
  312. package/.next/server/chunks/[root-of-the-server]__0ljizgj._.js +0 -5
  313. package/.next/server/chunks/[root-of-the-server]__0nmust6._.js +0 -5
  314. package/.next/server/chunks/[root-of-the-server]__0svzjwa._.js +0 -7
  315. package/.next/server/chunks/[root-of-the-server]__1c2kwku._.js +0 -12
  316. package/.next/server/chunks/[root-of-the-server]__1t02-1p._.js +0 -3
  317. package/.next/server/chunks/[root-of-the-server]__1t0jj1j._.js +0 -5
  318. package/.next/server/chunks/[root-of-the-server]__1vlxv19._.js +0 -5
  319. package/.next/server/chunks/_0j0-gq6._.js +0 -5
  320. package/.next/server/chunks/_0p6v1fr._.js +0 -5
  321. package/.next/server/chunks/_1ic3bew._.js +0 -5
  322. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_0g87zst._.js +0 -3
  323. package/.next/server/chunks/ssr/[root-of-the-server]__0-af_o7._.js +0 -3
  324. package/.next/server/chunks/ssr/[root-of-the-server]__09f39cp._.js +0 -4
  325. package/.next/server/chunks/ssr/[root-of-the-server]__0ouu4qp._.js +0 -3
  326. package/.next/server/chunks/ssr/[root-of-the-server]__0q9g9ea._.js +0 -5
  327. package/.next/server/chunks/ssr/[root-of-the-server]__17h1ggo._.js +0 -46
  328. package/.next/server/chunks/ssr/[root-of-the-server]__1jyeu61._.js +0 -5
  329. package/.next/server/chunks/ssr/_0afrpci._.js +0 -3
  330. package/.next/server/chunks/ssr/_0bgse1c._.js +0 -162
  331. package/.next/server/chunks/ssr/_0qsmpcu._.js +0 -3
  332. package/.next/server/chunks/ssr/_0z38nha._.js +0 -3
  333. package/.next/server/chunks/ssr/_116lfdc._.js +0 -3
  334. package/.next/server/chunks/ssr/_14dfh7a._.js +0 -4
  335. package/.next/server/chunks/ssr/_17qtuv7._.js +0 -3
  336. package/.next/server/chunks/ssr/_1_5xof_._.js +0 -3
  337. package/.next/server/chunks/ssr/_1alxym6._.js +0 -3
  338. package/.next/server/chunks/ssr/_1ou5sj0._.js +0 -3
  339. package/.next/server/chunks/ssr/_1tmw842._.js +0 -5
  340. package/.next/server/chunks/ssr/_1uij_rj._.js +0 -3
  341. package/.next/server/chunks/ssr/_1w9w1ok._.js +0 -3
  342. package/.next/server/chunks/ssr/_20gq_24._.js +0 -3
  343. package/.next/server/chunks/ssr/features_bot_0ouemw8._.js +0 -3
  344. package/.next/server/chunks/ssr/node_modules_@base-ui_react_1j9i1ho._.js +0 -3
  345. package/.next/static/chunks/0a5_-jqhaktjj.js +0 -1
  346. package/.next/static/chunks/0npvak0wpgagb.js +0 -1
  347. package/.next/static/chunks/19l81deo_pyoc.js +0 -1
  348. package/.next/static/chunks/1bnhw-5fj7aiz.js +0 -1
  349. package/.next/static/chunks/1in6nxpu33iab.js +0 -1
  350. package/.next/static/chunks/1u7kg91f9qy3g.js +0 -1
  351. package/.next/static/chunks/1xv4g10m-cl1s.js +0 -1
  352. package/.next/static/chunks/2ajs12-fcdwzm.js +0 -1
  353. package/.next/static/chunks/2i7qtmxc1kuqg.js +0 -1
  354. package/.next/static/chunks/2kz1f6r59nky0.js +0 -3
  355. package/.next/static/chunks/31kn4_h2rvf6k.css +0 -1
  356. package/.next/static/chunks/35jj-5u4te56r.js +0 -1
  357. package/.next/static/chunks/37ixzapa06xlo.js +0 -1
  358. package/.next/static/chunks/3k1d8y03t5nax.js +0 -58
  359. package/.next/static/chunks/3yiqr95d7ybeq.js +0 -15
  360. /package/.next/static/{8I2hKtciyA9LXvd8txuOz → -IBxB5oqr6e3RuOCCmYtL}/_buildManifest.js +0 -0
  361. /package/.next/static/{8I2hKtciyA9LXvd8txuOz → -IBxB5oqr6e3RuOCCmYtL}/_clientMiddlewareManifest.js +0 -0
  362. /package/.next/static/{8I2hKtciyA9LXvd8txuOz → -IBxB5oqr6e3RuOCCmYtL}/_ssgManifest.js +0 -0
@@ -1,7 +1,7 @@
1
- module.exports=[851372,e=>e.a(async(t,o)=>{try{var a=e.i(343747),r=e.i(687388),n=e.i(186304),s=e.i(353885),i=e.i(393189),l=e.i(265143),d=e.i(944971),h=e.i(438188),u=e.i(378884),c=e.i(148831),w=e.i(619898),p=e.i(636882),m=e.i(629668),f=e.i(786025),y=e.i(704161),g=e.i(41444),b=e.i(660948),T=e.i(54282),v=t([l,u,c,w,p,b]);async function $(e,t,o,n){var h,v,$,x,O,S,N,M,C,E;let R,A,_,B,P,W,j,L=await (0,f.openWorkspace)(),U=e.trim(),[Y,H,D,F,J,q,K,G,z]=await Promise.all([(0,p.loadSkills)(L,U),(0,w.listNoteIndex)(),(0,b.listConnectedToolNames)(),(0,c.findPinnedTools)(U),(0,l.listJobBots)(),(0,i.listBotMemory)(U),(0,l.readBotMemoryOn)(),(0,f.readMachineTools)(L),(0,u.listBotWork)(U,o?.thread??null)]),Q=J.filter(e=>e.name!==U),V=J.find(e=>e.name===U)??await (0,l.findJobBot)(U),X=[(h=U,v=V,$=o,A=(R=$?.owner??h)===h?"**You** coordinate this thread: its result goes from you to Thursday.":`**${R}** coordinates this thread and brings its result to Thursday.`,_=$?`
1
+ module.exports=[851372,e=>e.a(async(t,o)=>{try{var a=e.i(343747),r=e.i(687388),n=e.i(186304),s=e.i(353885),i=e.i(393189),l=e.i(265143),d=e.i(944971),h=e.i(438188),u=e.i(378884),c=e.i(148831),p=e.i(619898),w=e.i(636882),m=e.i(629668),f=e.i(786025),y=e.i(704161),g=e.i(41444),b=e.i(660948),T=e.i(54282),v=t([l,u,c,p,w,b]);async function $(e,t,o,n){var h,v,$,x,O,S,N,M,C,E;let R,A,_,B,P,W,j,L=await (0,f.openWorkspace)(),U=e.trim(),[Y,D,H,F,J,q,K,G,z]=await Promise.all([(0,w.loadSkills)(L,U),(0,p.listNoteIndex)(),(0,b.listConnectedToolNames)(),(0,c.findPinnedTools)(U),(0,l.listJobBots)(),(0,i.listBotMemory)(U),(0,l.readBotMemoryOn)(),(0,f.readMachineTools)(L),(0,u.listBotWork)(U,o?.thread??null)]),Q=J.filter(e=>e.name!==U),V=J.find(e=>e.name===U)??await (0,l.findJobBot)(U),X=[(h=U,v=V,$=o,A=(R=$?.owner??h)===h?"**You** coordinate this thread: its result goes from you to Thursday.":`**${R}** coordinates this thread and brings its result to Thursday.`,_=$?`
2
2
 
3
3
  Current conversation: ${$.caller} → ${h}. Your final text goes back to ${$.caller}.`:"",B=v?`
4
- Others know you as: ${(0,d.rosterLine)(v)}`:"",`You are ${h}, one of the bots in this thread. ${(0,T.nowLine)()}${B}
4
+ Others know you as: ${(0,d.rosterLine)(v)}`:"",`You are ${h}, one of the bots in this thread. ${(0,T.todayLine)()}${B}
5
5
 
6
6
  - **The user** — the one person all of this is for. They talk with Thursday by voice and follow this thread on their screen.
7
7
  - **Thursday** — their personal assistant. She talks with them, hands bots the work that takes time, and tells them what comes back.
@@ -10,7 +10,7 @@ Others know you as: ${(0,d.rosterLine)(v)}`:"",`You are ${h}, one of the bots in
10
10
 
11
11
  **The job is done, not described.** You are on the user's own computer, with a shell, files and the web, and how you get there is yours: when one way fails, try another; where no tool exists, write one — \`node\` is always here. Before deciding something cannot be done, look at what you have — your tools, the other bots, this machine. Bring back the thing itself — their account, their file, the real result — not a smaller, safer stand-in, and not a note on why not.
12
12
 
13
- **Never present a guess as a result.** Thursday says what you return out loud, as fact: say which part is unverified and why.`),(x=H,`## Thursday's memory of the user
13
+ **Never present a guess as a result.** Thursday says what you return out loud, as fact: say which part is unverified and why.`),(x=D,`## Thursday's memory of the user
14
14
 
15
15
  What Thursday keeps from talking with them. When the job needs something about them, open the note with \`${s.TOOL_NAMES.memory_recall}\`; a fact marked \`said\` came from a call. What you learn about them goes in your answer — Thursday decides what to keep.
16
16
 
@@ -20,7 +20,7 @@ ${(0,T.noteLines)(x)}`),function(e,t){let o=new Set(t.map(e=>`${e.server}/${e.na
20
20
 
21
21
  ${(0,T.mcpToolLines)(a)}
22
22
 
23
- Names only: \`${s.TOOL_NAMES.tool_search}\` returns what each one takes, \`${s.TOOL_NAMES.tool_call}\` runs one.${r}`}(D,F),(O=Y,0===O.length?"":`## Skills
23
+ Names only: \`${s.TOOL_NAMES.tool_search}\` returns what each one takes, \`${s.TOOL_NAMES.tool_call}\` runs one.${r}`}(H,F),(O=Y,0===O.length?"":`## Skills
24
24
 
25
25
  Written-down ways of doing things. Open one with \`${s.TOOL_NAMES.load_skill}\` before a job it covers, unless its instructions are already in your conversation.
26
26
 
@@ -47,7 +47,7 @@ Ask the user, through Thursday, with kind \`question\` only for a decision, perm
47
47
 
48
48
  ${j}
49
49
 
50
- Write in the user's language, and name the paths of finished work. In Markdown, reference images by absolute route (\`/api/file/${r.PATHS.artifacts}/…\`).`),k(U,t)].filter(Boolean).join("\n\n");return(0,T.logPromptSize)("bot",X),{text:X}}[l,u,c,w,p,b]=v.then?(await v)():v;let k=(e,t)=>{let o=t?.trim();return o?(0,h.findBotSeed)(e)?.systemPrompt.trim()===o?`## Your role
50
+ Write in the user's language, and name the paths of finished work. In Markdown, reference images by absolute route (\`/api/file/${r.PATHS.artifacts}/…\`).`),k(U,t)].filter(Boolean).join("\n\n");return(0,T.logPromptSize)("bot",X),{text:X}}[l,u,c,p,w,b]=v.then?(await v)():v;let k=(e,t)=>{let o=t?.trim();return o?(0,h.findBotSeed)(e)?.systemPrompt.trim()===o?`## Your role
51
51
 
52
52
  What this bot is for, as the app sets it up. Where it and anything above disagree, it wins.
53
53
 
@@ -77,10 +77,10 @@ ${(0,n.botGuideLine)()}`};e.s(["buildThreadOpening",0,function(e){if(e.routine){
77
77
  ${e.request.trim()}`}]}let t="user"===e.from?"The user":"Thursday";return[{type:"text",text:`You are ${e.bot}. ${t} hands you this thread${"user"===e.from?" on screen":" during a call"}.`},{type:"text",text:`## ${t} → ${e.bot}: the job
78
78
 
79
79
  ${e.request.trim()}`}]},"loadBotPrompt",0,$]),o()}catch(e){o(e)}},!1),235190,e=>{"use strict";e.s(["asWords",0,function(e,t,o=e=>e){let a=[];for(let r of e){if("tool"===r.role)continue;if("system"===r.role){a.push(r);continue}if("user"===r.role){a.push("string"==typeof r.content?{role:"user",content:o(r.content)}:r);continue}let e="string"==typeof r.content?[{type:"text",text:r.content}]:r.content,n=e.flatMap(e=>"text"===e.type?[e.text]:[]).join("\n").trim()||e.flatMap(e=>"tool-call"===e.type?[t(e.toolName,e.input)]:[]).join("\n");if(!n)continue;let s=a.at(-1);s?.role==="assistant"&&"string"==typeof s.content?a[a.length-1]={role:"assistant",content:`${s.content}
80
- ${o(n)}`}:a.push({role:"assistant",content:o(n)})}return a}])},585099,e=>e.a(async(t,o)=>{try{var a=e.i(68356),r=e.i(847841),n=e.i(687388),s=e.i(159479),i=e.i(386075),l=e.i(851372),d=e.i(316172),h=e.i(353885),u=e.i(235190),c=e.i(944971),w=e.i(527608),p=e.i(786025),m=e.i(640911),f=e.i(388439),y=e.i(265143),g=e.i(889034),b=e.i(378884),T=t([s,i,l,d,y,b]);[s,i,l,d,y,b]=T.then?(await T)():T;let x=n.BOT_RUN.steps;async function v(e,t){var o,u;let T,v,I,S,N,M,C,E,R,A=t.parent??null,_=await (0,y.findJobBot)(e.bot.trim()),B=_?.name??e.bot.trim(),P=e=>t.emit({...e,bot:B,parent:A});if(!_)return void await P({type:"error",message:`No bot named "${e.bot}". Use a name from the list.`,retry:!1});let W=e.messages,j=await ((o=_).provider&&o.model?(0,i.getTextModel)({provider:o.provider,model:o.model}):(0,i.resolveDefaultModel)().then(i.getTextModel)),L=t.threadId?await (0,b.findThread)(t.threadId):null,[U,{own:Y,artifacts:H}]=await Promise.all([t.threadId?(0,p.openJobScratch)(t.threadId,L?.label??"job"):null,(0,p.openBotFolders)(B)]),D=t.session??(t.threadId?(0,p.botBrowserSession)(t.threadId,B):null),[F,J]=await Promise.all([(0,l.loadBotPrompt)(B,_.systemPrompt,{thread:t.threadId??null,owner:t.owner,caller:t.caller},{scratch:U,own:Y,artifacts:H}),(0,s.loadTools)({target:"bot",bot:B,thread:t.threadId??null,session:D,model:j})]),q=Math.min(await (0,i.compactBudget)(j.ref,_.compactAt),t.contextBudget||1/0),K=await (0,i.runEffort)(j.ref,_.effort),G=!1,z={...J,[h.TOOL_NAMES.send_message]:(0,r.tool)({description:d.sendMessageSpec.description,inputSchema:d.sendMessageSpec.parameters,execute:async(e,o)=>{let a=await t.send({...e,id:o.toolCallId});if("question"===e.kind&&(G=!0),!a||"object"!=typeof a||!("to"in a))return a;let r=String(a.to);return r===g.ROOM_THURSDAY?a:{...a,note:`${r} has it now. When they finish, their answer — what they did and where the files are — comes to you as a new message and wakes you. Until then you do not know it: do not report it, guess it or do it yourself, and do not watch their folder. Go on with other work, or end your turn if there is none; the thread stays open.`}}})},Q=new Set,V=(u=n.BOT_RUN.silenceMs,v=new AbortController,I=0,S=!1,N=()=>{clearTimeout(T),T=void 0,S||I>0||(T=setTimeout(()=>{v.abort(new DOMException(`The model sent nothing for ${Math.round(u/6e4)} minutes.`,"TimeoutError"))},u))},{signal:v.signal,touch:N,hold:()=>{I+=1,N()},release:()=>{I=Math.max(0,I-1),N()},end:()=>{S=!0,N()}});for(let[e,o]of Object.entries(z)){let a=o.execute;a&&(o.execute=(o,r)=>{let n=(async()=>{t.signal?.throwIfAborted(),await P({type:"tool",id:r.toolCallId,name:e,input:o}),V.hold();try{t.signal?.throwIfAborted();let n=await a(o,r);if(n&&"object"==typeof n&&Symbol.asyncIterator in n){let e;for await(let t of n)e=t;n=e}return await P({type:"tool-result",id:r.toolCallId,name:e,output:n}),n}catch(t){throw await P({type:"tool-result",id:r.toolCallId,name:e,output:(0,i.modelErrorToString)(t),error:!0}),t}finally{V.release()}})();return Q.add(n),n.finally(()=>Q.delete(n)).catch(()=>{}),n})}let X=Promise.resolve(),Z=()=>{},ee=0,et=new a.ToolLoopAgent({model:j.model,instructions:F.text,tools:z,reasoning:K,stopWhen:[(0,a.stepCountIs)(x),()=>G],prepareStep:async({stepNumber:e,steps:o,messages:a})=>{await X,t.signal?.throwIfAborted();let r={},n=(o.at(-1)?.usage.inputTokens??0)||a.reduce((e,t)=>e+(0,f.estimateTokens)("string"==typeof t.content?t.content:JSON.stringify(t.content))+4,0);ee=n;let s=a,i=t.compactNow?.()??!1;if((n>q||i)&&a.length>2){V.hold();let e=await k(j.model,z,a,{signal:t.signal,budget:q,instructions:F.text}).finally(V.release);m.logger.debug(`compacted ${a.length} messages at ${n} tokens (budget ${q})`);let o=`${e.text}${await $(L?.id??null,a,U)}`;await P({type:"compact",text:o,usage:e.usage,messages:a.length,tokens:n}),s=[a[0],{role:"user",content:o}]}let l=e>0?await t.notes?.()??[]:[];return(l.length&&(s=[...s,...l.map(e=>({role:"user",content:e}))]),s===a)?r:{...r,messages:s}}}),eo=(M=[],C=[],E=!1,{push(e){let t=C.shift();t?t(e):M.push(e)},take(){let e=M.shift();return e?Promise.resolve(e):E?Promise.resolve(null):new Promise(e=>C.push(e))},end(){for(let e of(E=!0,C.splice(0)))e(null)}}),ea=t.signal?AbortSignal.any([t.signal,V.signal]):V.signal;V.touch();let er=new AbortController,en=AbortSignal.any([ea,er.signal]);try{R=await et.stream({messages:W,abortSignal:en,onStepEnd:e=>{X=new Promise(e=>{Z=e}),eo.push({messages:function(e){if(!e.toolResults.length)return e.response.messages;let t=new Map(e.toolResults.map(e=>[e.toolCallId,e.output]));return e.response.messages.map(e=>"tool"!==e.role?e:{...e,content:e.content.map(e=>{if("tool-result"!==e.type||!t.has(e.toolCallId))return e;let o=t.get(e.toolCallId);return{...e,output:"string"==typeof o?{type:"text",value:o}:{type:"json",value:o}}})})}(e),usage:O(e.usage)})}})}catch(e){throw V.end(),er.abort(),await Promise.allSettled([...Q]),e}let es="",ei="",el=null,ed=e=>{m.logger.error(`${B}: the model run broke`,e);let t=(0,i.modelErrorToString)(e),o=!(0,i.isProviderRefusal)(e);if(!(0,i.isContextOverflow)(e))return{type:"error",message:t,retry:o};let a=Math.floor(Math.min(q,ee||q)*n.BOT_RUN.overflowShrink);return{type:"error",message:t,budget:Math.max(c.COMPACT_AT_MIN,a),retry:o}};ea.addEventListener("abort",()=>{eo.end(),Z()},{once:!0});try{for await(let e of R.stream)switch(V.touch(),e.type){case"start-step":ei="",es="";break;case"text-delta":es+=e.text;break;case"text-end":{let e=es.trim();if(es="",!e)break;ei=[ei,e].filter(Boolean).join("\n\n"),await P({type:"text",text:e});break}case"tool-call":await P({type:"tool",id:e.toolCallId,name:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:e.providerMetadata});break;case"tool-result":await P({type:"tool-result",id:e.toolCallId,name:e.toolName,output:e.output});break;case"tool-error":await P({type:"tool-result",id:e.toolCallId,name:e.toolName,output:(0,i.modelErrorToString)(e.error),error:!0});break;case"finish-step":{el=e.finishReason;let t=await eo.take();t&&await P({type:"step",...t,budget:q}),Z();break}case"abort":if(t.signal?.aborted)return;await P(ed(e.reason??"The model stopped sending."));return;case"error":await P(ed(e.error));return}}finally{er.abort(),eo.end(),V.end(),Z(),await Promise.allSettled([...Q]),D&&(0,w.renewSignIns)(D).catch(e=>m.logger.warn(`${B}: kept sign-ins were not renewed`,e))}try{await R.finalStep}catch(e){if(t.signal?.aborted)return;await P(ed(e));return}"content-filter"===el?await P({type:"error",message:"The provider's content filter stopped the response.",retry:!1}):await P({type:"turn-end",text:ei,stopped:!G&&("length"===el||"error"===el||"tool-calls"===el)})}async function $(e,t,o){try{let a=e?await (0,b.listWrittenPaths)(e):(0,b.writtenPathsIn)(t.map(e=>e.content)),r=await (0,p.filesOnDisk)(a,o);if(!r.length)return"";let s=r.slice(-n.BOT_RUN.compactFiles),i=r.length-s.length,l=s.map(e=>`- ${e}`);return i&&l.unshift(`- …and ${i} older ones`),`
80
+ ${o(n)}`}:a.push({role:"assistant",content:o(n)})}return a}])},585099,e=>e.a(async(t,o)=>{try{var a=e.i(666680),r=e.i(68356),n=e.i(847841),s=e.i(687388),i=e.i(159479),l=e.i(386075),d=e.i(851372),h=e.i(316172),u=e.i(353885),c=e.i(235190),p=e.i(944971),w=e.i(527608),m=e.i(786025),f=e.i(640911),y=e.i(388439),g=e.i(265143),b=e.i(889034),T=e.i(378884),v=t([i,l,d,h,g,T]);[i,l,d,h,g,T]=v.then?(await v)():v;let S=s.BOT_RUN.steps;async function $(e,t){var o;let a,c,v,$,x,C,E,R,A,_=t.parent??null,B=await (0,g.findJobBot)(e.bot.trim()),P=B?.name??e.bot.trim(),W=e=>t.emit({...e,bot:P,parent:_});if(!B)return void await W({type:"error",message:`No bot named "${e.bot}". Use a name from the list.`,retry:!1});let j=e.messages,L=await O(B),U=t.threadId?await (0,T.findThread)(t.threadId):null,[Y,{own:D,artifacts:H}]=await Promise.all([t.threadId?(0,m.openJobScratch)(t.threadId,U?.label??"job"):null,(0,m.openBotFolders)(P)]),F=t.session??(t.threadId?(0,m.botBrowserSession)(t.threadId,P):null),[J,q]=await Promise.all([(0,d.loadBotPrompt)(P,B.systemPrompt,{thread:t.threadId??null,owner:t.owner,caller:t.caller},{scratch:Y,own:D,artifacts:H}),(0,i.loadTools)({target:"bot",bot:P,thread:t.threadId??null,session:F,model:L})]),K=Math.min(await (0,l.compactBudget)(L.ref,B.compactAt),t.contextBudget||1/0),G=await (0,l.runEffort)(L.ref,B.effort),z=(0,l.promptCacheOptions)(L.ref,t.threadId?M(t.threadId,P):null),Q=!1,V={...q,[u.TOOL_NAMES.send_message]:(0,n.tool)({description:h.sendMessageSpec.description,inputSchema:h.sendMessageSpec.parameters,execute:async(e,o)=>{let a=await t.send({...e,id:o.toolCallId});if("question"===e.kind&&(Q=!0),!a||"object"!=typeof a||!("to"in a))return a;let r=String(a.to);return r===b.ROOM_THURSDAY?a:{...a,note:`${r} has it now. When they finish, their answer — what they did and where the files are — comes to you as a new message and wakes you. Until then you do not know it: do not report it, guess it or do it yourself, and do not watch their folder. Go on with other work, or end your turn if there is none; the thread stays open.`}}})},X=new Set,Z=(o=s.BOT_RUN.silenceMs,c=new AbortController,v=0,$=!1,x=()=>{clearTimeout(a),a=void 0,$||v>0||(a=setTimeout(()=>{c.abort(new DOMException(`The model sent nothing for ${Math.round(o/6e4)} minutes.`,"TimeoutError"))},o))},{signal:c.signal,touch:x,hold:()=>{v+=1,x()},release:()=>{v=Math.max(0,v-1),x()},end:()=>{$=!0,x()}});for(let[e,o]of Object.entries(V)){let a=o.execute;a&&(o.execute=(o,r)=>{let n=(async()=>{t.signal?.throwIfAborted(),await W({type:"tool",id:r.toolCallId,name:e,input:o}),Z.hold();try{t.signal?.throwIfAborted();let n=await a(o,r);if(n&&"object"==typeof n&&Symbol.asyncIterator in n){let e;for await(let t of n)e=t;n=e}return await W({type:"tool-result",id:r.toolCallId,name:e,output:n}),n}catch(t){throw await W({type:"tool-result",id:r.toolCallId,name:e,output:(0,l.modelErrorToString)(t),error:!0}),t}finally{Z.release()}})();return X.add(n),n.finally(()=>X.delete(n)).catch(()=>{}),n})}let ee=Promise.resolve(),et=()=>{},eo=0,ea=new r.ToolLoopAgent({model:L.model,instructions:J.text,tools:V,reasoning:G,providerOptions:z,stopWhen:[(0,r.stepCountIs)(S),()=>Q],prepareStep:async({stepNumber:e,steps:o,messages:a})=>{await ee,t.signal?.throwIfAborted();let r={},n=(o.at(-1)?.usage.inputTokens??0)||a.reduce((e,t)=>e+(0,y.estimateTokens)("string"==typeof t.content?t.content:JSON.stringify(t.content))+4,0);eo=n;let s=a,i=t.compactNow?.()??!1;if((n>K||i)&&a.length>2){Z.hold();let e=await I(L.model,V,a,{signal:t.signal,budget:K,instructions:J.text,providerOptions:z}).finally(Z.release);f.logger.debug(`compacted ${a.length} messages at ${n} tokens (budget ${K})`);let o=`${e.text}${await k(U?.id??null,a,Y)}`;await W({type:"compact",text:o,usage:e.usage,messages:a.length,tokens:n}),s=[a[0],{role:"user",content:o}]}let l=e>0?await t.notes?.()??[]:[];return(l.length&&(s=[...s,...l.map(e=>({role:"user",content:e}))]),s===a)?r:{...r,messages:s}}}),er=(C=[],E=[],R=!1,{push(e){let t=E.shift();t?t(e):C.push(e)},take(){let e=C.shift();return e?Promise.resolve(e):R?Promise.resolve(null):new Promise(e=>E.push(e))},end(){for(let e of(R=!0,E.splice(0)))e(null)}}),en=t.signal?AbortSignal.any([t.signal,Z.signal]):Z.signal;Z.touch();let es=new AbortController,ei=AbortSignal.any([en,es.signal]);try{A=await ea.stream({messages:j,abortSignal:ei,onStepEnd:e=>{ee=new Promise(e=>{et=e}),er.push({messages:function(e){if(!e.toolResults.length)return e.response.messages;let t=new Map(e.toolResults.map(e=>[e.toolCallId,e.output]));return e.response.messages.map(e=>"tool"!==e.role?e:{...e,content:e.content.map(e=>{if("tool-result"!==e.type||!t.has(e.toolCallId))return e;let o=t.get(e.toolCallId);return{...e,output:"string"==typeof o?{type:"text",value:o}:{type:"json",value:o}}})})}(e),usage:N(e.usage)})}})}catch(e){throw Z.end(),es.abort(),await Promise.allSettled([...X]),e}let el="",ed="",eh=null,eu=e=>{f.logger.error(`${P}: the model run broke`,e);let t=(0,l.modelErrorToString)(e),o=!(0,l.isProviderRefusal)(e);if(!(0,l.isContextOverflow)(e))return{type:"error",message:t,retry:o};let a=Math.floor(Math.min(K,eo||K)*s.BOT_RUN.overflowShrink);return{type:"error",message:t,budget:Math.max(p.COMPACT_AT_MIN,a),retry:o}};en.addEventListener("abort",()=>{er.end(),et()},{once:!0});try{for await(let e of A.stream)switch(Z.touch(),e.type){case"start-step":ed="",el="";break;case"text-delta":el+=e.text;break;case"text-end":{let e=el.trim();if(el="",!e)break;ed=[ed,e].filter(Boolean).join("\n\n"),await W({type:"text",text:e});break}case"tool-call":await W({type:"tool",id:e.toolCallId,name:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:e.providerMetadata});break;case"tool-result":await W({type:"tool-result",id:e.toolCallId,name:e.toolName,output:e.output});break;case"tool-error":await W({type:"tool-result",id:e.toolCallId,name:e.toolName,output:(0,l.modelErrorToString)(e.error),error:!0});break;case"finish-step":{eh=e.finishReason;let t=await er.take();t&&await W({type:"step",...t,budget:K}),et();break}case"abort":if(t.signal?.aborted)return;await W(eu(e.reason??"The model stopped sending."));return;case"error":await W(eu(e.error));return}}finally{es.abort(),er.end(),Z.end(),et(),await Promise.allSettled([...X]),F&&(0,w.renewSignIns)(F).catch(e=>f.logger.warn(`${P}: kept sign-ins were not renewed`,e))}try{await A.finalStep}catch(e){if(t.signal?.aborted)return;await W(eu(e));return}"content-filter"===eh?await W({type:"error",message:"The provider's content filter stopped the response.",retry:!1}):await W({type:"turn-end",text:ed,stopped:!Q&&("length"===eh||"error"===eh||"tool-calls"===eh)})}async function k(e,t,o){try{let a=e?await (0,T.listWrittenPaths)(e):(0,T.writtenPathsIn)(t.map(e=>e.content)),r=await (0,m.filesOnDisk)(a,o);if(!r.length)return"";let n=r.slice(-s.BOT_RUN.compactFiles),i=r.length-n.length,l=n.map(e=>`- ${e}`);return i&&l.unshift(`- …and ${i} older ones`),`
81
81
 
82
82
  Files this job has on disk now — open one rather than fetching again what is in it:
83
- ${l.join("\n")}`}catch(e){return m.logger.warn("files under the summary could not be listed",e),""}}async function k(e,t,o,a){let r;try{return await I(e,t,o,a)}catch(e){if(a.signal?.aborted)throw e;r=e}if((0,i.isContextOverflow)(r)){let n=(0,u.asWords)(o,(e,t)=>`${e}: ${(0,b.argumentLine)(e,t)}`);try{return await I(e,t,n,a)}catch(e){if(a.signal?.aborted)throw e;r=e}}throw Error(`Could not compact the context (${(0,i.modelErrorToString)(r)}).`,{cause:r})}async function I(e,t,o,r){let s,{text:i,usage:l}=await (0,a.generateText)({model:e,instructions:r.instructions,tools:t,toolChoice:"none",messages:[...o,{role:"user",content:(s=(e=>{let{min:t,max:o,perTokens:a}=n.BOT_RUN.summaryWords;return Math.min(o,Math.max(t,Math.round(e/a)))})(r.budget),`Compact your context. The first message above — who handed you the job, and the job — stays exactly as it is. Everything after it is replaced by what you write now, and you carry on from that first message and this alone; nothing else above can be read again. Write it for a fresh copy of you that has your tools, your instructions and that first message, but has seen none of the rest.
83
+ ${l.join("\n")}`}catch(e){return f.logger.warn("files under the summary could not be listed",e),""}}async function I(e,t,o,a){let r;try{return await x(e,t,o,a)}catch(e){if(a.signal?.aborted)throw e;r=e}if((0,l.isContextOverflow)(r)){let n=(0,c.asWords)(o,(e,t)=>`${e}: ${(0,T.argumentLine)(e,t)}`);try{return await x(e,t,n,a)}catch(e){if(a.signal?.aborted)throw e;r=e}}throw Error(`Could not compact the context (${(0,l.modelErrorToString)(r)}).`,{cause:r})}async function x(e,t,o,a){let n,{text:i,usage:l}=await (0,r.generateText)({model:e,instructions:a.instructions,tools:t,toolChoice:"none",messages:[...o,{role:"user",content:(n=(e=>{let{min:t,max:o,perTokens:a}=s.BOT_RUN.summaryWords;return Math.min(o,Math.max(t,Math.round(e/a)))})(a.budget),`Compact your context. The first message above — who handed you the job, and the job — stays exactly as it is. Everything after it is replaced by what you write now, and you carry on from that first message and this alone; nothing else above can be read again. Write it for a fresh copy of you that has your tools, your instructions and that first message, but has seen none of the rest.
84
84
 
85
85
  Cover all of it, and prefer a fact over a description of a fact:
86
86
 
@@ -91,11 +91,12 @@ Cover all of it, and prefer a fact over a description of a fact:
91
91
  - **What did not work**, and why: the url that 404s, the endpoint that needs POST not GET, the selector that is not there, the site that refuses a headless browser, the argument a tool rejected. This is the part that stops the next steps repeating an hour of yours.
92
92
  - **What is left**, in the order you would do it.
93
93
 
94
- Plain text, under ${s} words. No preamble, no headings about the summary itself, no account of how you have been going.`)}],abortSignal:r.signal,timeout:n.BOT_RUN.silenceMs}),d=i.trim();if(!d)throw Error("The summary of the context came back empty, so there is nothing to carry on from.");return{text:`Everything between the first message and here was compacted. Below is your own summary of it; carry on from the first message and this.
94
+ Plain text, under ${n} words. No preamble, no headings about the summary itself, no account of how you have been going.`)}],abortSignal:a.signal,timeout:s.BOT_RUN.silenceMs,providerOptions:a.providerOptions}),d=i.trim();if(!d)throw Error("The summary of the context came back empty, so there is nothing to carry on from.");return{text:`Everything between the first message and here was compacted. Below is your own summary of it; carry on from the first message and this.
95
95
 
96
- ${d}`,usage:O(l)}}let O=e=>({input:e.inputTokens??0,output:e.outputTokens??0});e.s(["resumeTranscript",0,function(e,t=new Map){let o=new Map,a=new Set;for(let t of e)if(("tool"===t.role||"assistant"===t.role)&&Array.isArray(t.content))for(let e of t.content)"tool-result"===e.type&&(o.has(e.toolCallId)||o.set(e.toolCallId,e),"assistant"===t.role&&a.add(e.toolCallId));let r=[],n=new Set;for(let s of e){if("tool"===s.role){let e=s.content.filter(e=>"tool-result"!==e.type);e.length&&r.push({...s,content:e});continue}if("assistant"!==s.role||"string"==typeof s.content){r.push(s);continue}let e=[],i=[];for(let r of s.content){if("tool-call"!==r.type){i.push(r);continue}if(n.has(r.toolCallId))continue;let s=r.input;if("string"==typeof s)try{s=JSON.parse(s)}catch{s=void 0}if(!r.toolCallId||void 0===s){i.push({type:"text",text:"A tool argument stream was interrupted before a complete call was recorded. Inspect the saved work before continuing."});continue}let l=r.toolName===h.TOOL_NAMES.send_message?t.get(r.toolCallId):void 0,d=o.get(r.toolCallId)??(l?{type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:{type:"json",value:l}}:void 0);if(r.providerExecuted&&(!d||!a.has(r.toolCallId))){i.push({type:"text",text:d?`The provider operation ${r.toolName} returned this data before its native continuation was interrupted: ${JSON.stringify(d.output)}`:`The provider operation ${r.toolName} was interrupted without a recorded result. Its remote execution state is unknown.`});continue}n.add(r.toolCallId),i.push({...r,input:s}),a.has(r.toolCallId)||e.push(d??{type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:{type:"text",value:"No result: execution was interrupted before a result was recorded. The outcome is unknown. Inspect the current state before repeating the action."}})}i.length&&r.push({...s,content:i}),e.length&&r.push({role:"tool",content:e})}return r},"runBot",0,v]),o()}catch(e){o(e)}},!1),39803,e=>e.a(async(t,o)=>{try{var a=e.i(136340),r=e.i(380690),n=e.i(687388),s=e.i(386075),i=e.i(851372),l=e.i(22676),d=e.i(629668),h=e.i(786025),u=e.i(167004),c=e.i(640911),w=e.i(53748),p=e.i(268486),m=e.i(41444),f=e.i(265143),y=e.i(585099),g=e.i(944971),b=e.i(742712),T=e.i(889034),v=e.i(378884),$=t([s,i,l,f,y,b,v]);[s,i,l,f,y,b,v]=$.then?(await $)():$;let P=globalThis.__roomRuns??=new Map,W=globalThis.__roomThreadLock??=(0,p.createKeyedLock)(),j=globalThis.__roomCompactAsked??=new Set,L=(e,t)=>`${e}
97
- ${t}`;async function k(e){let t=await (0,f.findJobBot)(e.bot);(!t||t.disabled)&&(0,w.publicError)("Choose an enabled bot.");let{from:o,routine:a,...r}={...e,bot:t.name},n=(0,i.buildThreadOpening)({bot:r.bot,request:r.request,from:o,routine:a}),s=await (0,v.insertThread)({...r,routineId:a?.id??null,opening:n});return await x(s.id),s.id}async function I(e,t,o="user",a,r){let n=null;return await W(e,async()=>{let s=await (0,v.findThread)(e);if(s||(0,w.publicError)("No such thread."),a){let t=(await (0,b.listRoomWork)(e)).find(e=>e.bot.toLowerCase()===a.trim().toLowerCase());t&&t.bot!==T.ROOM_THURSDAY||(0,w.publicError)("Choose a participant in this thread."),a=t.bot}t.trim()===g.THREAD_CONTINUE&&(0,g.isAppStop)(s.pending)?(await (0,b.resumeRoom)(e),(await (0,b.listRoomWork)(e)).some(e=>"queued"===e.state)||(n=await (0,b.tellRoom)(e,"Continue from the saved conversation.","user"===o?T.ROOM_USER:T.ROOM_THURSDAY,a,void 0,!1))):n=await (0,b.tellRoom)(e,t,"user"===o?T.ROOM_USER:T.ROOM_THURSDAY,a,r)}),await x(e),n}async function x(e){await W(e,async()=>{for(let t=0;t<2;t++){let t;for(;t=await (0,b.claimRoomWork)(e);)!function(e){let t,o=new AbortController,a=new Promise(e=>{t=e});P.set(e.id,{threadId:e.threadId,stop:o,done:a}),O(e,o.signal).catch(t=>c.logger.error(`thread ${e.threadId}: participant`,t)).finally(()=>{P.delete(e.id),t(),x(e.threadId).catch(t=>c.logger.error(`thread ${e.threadId}: scheduling`,t))})}(t);await (0,b.settleRoom)(e)}})}async function O(e,t){let o=await S(e,t);if(o?.failure?.retry&&!t.aborted&&(await (0,b.noteRoomBreak)(e,o.failure.message),await (0,a.setTimeout)(n.BOT_RUN.retryMs,void 0,{signal:t}).catch(()=>{}),t.aborted||(o=await S(e,t))),!o||t.aborted)return;let s=o.failure?.message,i=o.ending;if(s||!i||i.stopped){let t=s??"The turn was interrupted. Continue from the saved conversation.";W(e.threadId,async()=>{let o=(await (0,b.listRoomWork)(e.threadId)).find(t=>t.id===e.id);if(o?.state!=="running"||o.generation!==e.generation)return;let a=N(e.threadId);await (0,b.pauseRoom)(e.threadId,t),await a}).catch(t=>c.logger.error(`thread ${e.threadId}: pausing`,t));return}await (0,b.finishRoomWork)(e,i.text);let w=await (0,v.findThread)(e.threadId);if(w?.status==="done"){let e=(0,m.plainText)(w.outcome??"").slice(0,n.FINISHED_NOTICE.words);r.presence.watching||await (0,l.isAnyCallLive)()||(0,u.desktopNotify)(w.label,e);let t=await (0,h.filesOnDisk)((0,d.pathsIn)(w.outcome??""),null);r.appEvents.emit({type:"finished",threadId:w.id,label:w.label,bot:w.bot,words:e,paths:(0,d.leadFirst)(t)})}}async function S(e,t){let o=new U(e,t),a=null,r=null;try{let n=await (0,v.findThread)(e.threadId);if(!n)return null;(await (0,b.listParticipantTranscript)(e.threadId,e.bot)).length||await (0,b.appendRoomMessage)(e.threadId,{bot:e.bot,parent:e.id,role:"user",content:`Request: ${n.request}
98
- Coordinator: ${n.bot}. Continue as ${e.bot} in this thread.`,hidden:!0}),await (0,b.consumeRoomInbox)(e);let s=await (0,b.listParticipantTranscript)(e.threadId,e.bot);await (0,y.runBot)({bot:e.bot,messages:(0,y.resumeTranscript)(s,await (0,b.listRoomReceipts)(e.threadId,e.bot,s))},{signal:t,threadId:e.threadId,parent:e.id,caller:e.caller,owner:n.bot,contextBudget:await (0,b.roomContextBudget)(e.threadId,e.bot),compactNow:()=>j.delete(L(e.threadId,e.bot)),session:(0,h.botBrowserSession)(e.threadId,e.bot),notes:()=>(0,b.consumeRoomInbox)(e),send:async o=>{t.throwIfAborted();let a=o.to.trim();if(a.toLowerCase()===T.ROOM_THURSDAY.toLowerCase())a=T.ROOM_THURSDAY;else{let e=await (0,f.findJobBot)(a);(!e||e.disabled)&&(0,w.publicError)(`No enabled bot named "${a}".`),a=e.name}let r=await (0,b.sendRoomMessage)(e,{...o,to:a});return x(e.threadId).catch(e=>c.logger.error("room message scheduling",e)),r},emit:async s=>{(!t.aborted||"tool-result"===s.type)&&(await o.on(s),"step"===s.type&&await (0,v.addThreadUsage)(e.threadId,s.usage,e.bot===n.bot?{tokens:s.usage.input,budget:s.budget}:null),"compact"===s.type&&await (0,v.addThreadUsage)(e.threadId,s.usage),"turn-end"===s.type&&(a=s),"error"===s.type&&(r={message:s.message,retry:s.retry},s.budget&&await (0,b.lowerRoomContextBudget)(e,s.budget)))}})}catch(o){t.aborted||(c.logger.error(`thread ${e.threadId}: ${e.bot} broke`,o),r={message:(0,s.modelErrorToString)(o),retry:!(0,w.isPublicError)(o)&&!(0,s.isProviderRefusal)(o)})}return{ending:a,failure:r}}class U{work;signal;lane;assistant;tool;parts;calls;results;constructor(e,t){this.work=e,this.signal=t,this.lane=(0,m.PromiseChain)(),this.assistant=null,this.tool=null,this.parts={assistant:[],tool:[]},this.calls=new Set,this.results=new Set}async write(e,t,o=!1){let a={bot:this.work.bot,parent:this.work.id,role:t.role,content:t.content,compact:o,note:o};return null===e?(0,b.appendRoomMessage)(this.work.threadId,a):(await (0,v.upsertMessage)(this.work.threadId,e,a),e)}on(e){return this.lane(async()=>{if(!this.signal.aborted||"tool-result"===e.type)if("text"===e.type)this.parts.assistant.push({type:"text",text:e.text}),this.assistant=await this.write(this.assistant,{role:"assistant",content:this.parts.assistant});else if("tool"===e.type){if(this.calls.has(e.id)){let t=this.parts.assistant.find(t=>"tool-call"===t.type&&t.toolCallId===e.id);t&&"tool-call"===t.type&&e.providerOptions&&(t.providerOptions=e.providerOptions,this.assistant=await this.write(this.assistant,{role:"assistant",content:this.parts.assistant}));return}this.calls.add(e.id),this.parts.assistant.push({type:"tool-call",toolCallId:e.id,toolName:e.name,input:e.input,...e.providerExecuted?{providerExecuted:!0}:{},...e.providerOptions?{providerOptions:e.providerOptions}:{}}),this.assistant=await this.write(this.assistant,{role:"assistant",content:this.parts.assistant})}else if("tool-result"===e.type){if(this.results.has(e.id))return;this.results.add(e.id),this.parts.tool.push({type:"tool-result",toolCallId:e.id,toolName:e.name,output:e.error?{type:"error-text",value:String(e.output)}:"string"==typeof e.output?{type:"text",value:e.output}:{type:"json",value:e.output}}),this.tool=await this.write(this.tool,{role:"tool",content:this.parts.tool})}else if("step"===e.type){let t=[this.assistant,this.tool];for(let[o,a]of e.messages.entries())await this.write(t[o]??null,a);let o=t.slice(e.messages.length).filter(e=>null!==e);o.length&&await (0,v.deleteMessages)(this.work.threadId,o),this.assistant=this.tool=null,this.parts={assistant:[],tool:[]}}else"compact"===e.type&&await this.write(null,{role:"user",content:e.text},!0)})}}async function N(e){let t=[...P.values()].filter(t=>t.threadId===e);for(let e of t)e.stop.abort();await Promise.all(t.map(e=>e.done))}async function M(e){await W(e,async()=>{let t=await (0,v.findThread)(e);t||(0,w.publicError)("No such thread."),t.endedAt&&(0,w.publicError)("That thread has already ended."),await (0,b.cancelRoom)(e),await (0,v.updateThread)(e,{status:"cancelled",outcome:null,pending:null,seen:!0,endedAt:new Date}),await N(e),await (0,h.closeJobShell)(e)})}async function C(e){return W(e,()=>E(e))}async function E(e){let t=await (0,v.findThread)(e);await (0,b.cancelRoom)(e),await N(e),await (0,h.removeJobBrowsers)(e);let o=await (0,v.deleteThread)(e);return o&&t&&await (0,h.removeJobScratch)(e,t.label),o}async function R(e){let t=e?.getTime(),o=e=>void 0===t||(e.endedAt??e.updatedAt).getTime()<t,a=0;for(let e of(await (0,v.listThreadFolders)()))("done"===e.status||"cancelled"===e.status)&&o(e)&&await W(e.id,async()=>{let t=await (0,v.findThread)(e.id);t?.status!=="done"&&t?.status!=="cancelled"||o(t)&&await E(e.id)&&(a+=1)});return a}async function A(){let e=Date.now()-n.WORKSPACE_KEEP.forMs,t=t=>("done"===t.status||"cancelled"===t.status)&&(t.endedAt??t.updatedAt).getTime()<e,o=new Set(await (0,h.listScratchFolders)()),a=[];for(let e of(await (0,v.listThreadFolders)())){let r=(0,h.jobScratch)(e.id,e.label);o.delete(r)&&t(e)&&await W(e.id,async()=>{let o=await (0,v.findThread)(e.id);o&&t(o)&&(await (0,h.closeHiddenBrowser)(e.id),await (0,h.removeJobScratch)(e.id,e.label),a.push(r))})}return a.push(...await (0,h.removeUnchangedFolders)([...o])),await (0,h.pruneJobFiles)(),a.length&&c.logger.info(`cleared ${a.length} old job folder(s): ${a.join(", ")}`),a}async function _(){for(let e of(await (0,v.listRunningThreadIds)()))await W(e,async()=>{[...P.values()].some(t=>t.threadId===e)||(await (0,v.findThread)(e))?.status==="running"&&await (0,b.pauseRoom)(e,"The server restarted. Resume from the saved conversation.")})}async function B(e){let t=await (0,v.listRunningThreadIds)();await Promise.all(t.map(t=>W(t,async()=>{(await (0,v.findThread)(t))?.status==="running"&&(await N(t),await (0,b.pauseRoom)(t,e))})))}e.s(["answerThread",0,I,"askCompact",0,function(e,t){j.add(L(e,t))},"cancelThread",0,M,"pauseThreads",0,B,"removeFinishedThreads",0,R,"removeThread",0,C,"startThread",0,k,"sweepJobFiles",0,A,"sweepThreads",0,_]),o()}catch(e){o(e)}},!1),167004,e=>{"use strict";var t=e.i(874533),o=e.i(687388);let a=`on run argv
96
+ ${d}`,usage:N(l)}}let N=e=>({input:e.inputTokens??0,output:e.outputTokens??0,cacheRead:e.inputTokenDetails?.cacheReadTokens??0,cacheWrite:e.inputTokenDetails?.cacheWriteTokens??0}),M=(e,t)=>(0,a.createHash)("sha256").update(`${e}
97
+ ${t}`).digest("hex").slice(0,32);function O(e,t={}){return e.provider&&e.model?(0,l.getTextModel)({provider:e.provider,model:e.model}):(0,l.resolveDefaultModel)(void 0,t).then(l.getTextModel)}e.s(["resolveModel",0,O,"resumeTranscript",0,function(e,t=new Map){let o=new Map,a=new Set;for(let t of e)if(("tool"===t.role||"assistant"===t.role)&&Array.isArray(t.content))for(let e of t.content)"tool-result"===e.type&&(o.has(e.toolCallId)||o.set(e.toolCallId,e),"assistant"===t.role&&a.add(e.toolCallId));let r=[],n=new Set;for(let s of e){if("tool"===s.role){let e=s.content.filter(e=>"tool-result"!==e.type);e.length&&r.push({...s,content:e});continue}if("assistant"!==s.role||"string"==typeof s.content){r.push(s);continue}let e=[],i=[];for(let r of s.content){if("tool-call"!==r.type){i.push(r);continue}if(n.has(r.toolCallId))continue;let s=r.input;if("string"==typeof s)try{s=JSON.parse(s)}catch{s=void 0}if(!r.toolCallId||void 0===s){i.push({type:"text",text:"A tool argument stream was interrupted before a complete call was recorded. Inspect the saved work before continuing."});continue}let l=r.toolName===u.TOOL_NAMES.send_message?t.get(r.toolCallId):void 0,d=o.get(r.toolCallId)??(l?{type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:{type:"json",value:l}}:void 0);if(r.providerExecuted&&(!d||!a.has(r.toolCallId))){i.push({type:"text",text:d?`The provider operation ${r.toolName} returned this data before its native continuation was interrupted: ${JSON.stringify(d.output)}`:`The provider operation ${r.toolName} was interrupted without a recorded result. Its remote execution state is unknown.`});continue}n.add(r.toolCallId),i.push({...r,input:s}),a.has(r.toolCallId)||e.push(d??{type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:{type:"text",value:"No result: execution was interrupted before a result was recorded. The outcome is unknown. Inspect the current state before repeating the action."}})}i.length&&r.push({...s,content:i}),e.length&&r.push({role:"tool",content:e})}return r},"runBot",0,$]),o()}catch(e){o(e)}},!1),39803,e=>e.a(async(t,o)=>{try{var a=e.i(136340),r=e.i(380690),n=e.i(687388),s=e.i(386075),i=e.i(851372),l=e.i(22676),d=e.i(629668),h=e.i(786025),u=e.i(167004),c=e.i(640911),p=e.i(53748),w=e.i(268486),m=e.i(41444),f=e.i(265143),y=e.i(585099),g=e.i(944971),b=e.i(742712),T=e.i(889034),v=e.i(378884),$=t([s,i,l,f,y,b,v]);[s,i,l,f,y,b,v]=$.then?(await $)():$;let P=globalThis.__roomRuns??=new Map,W=globalThis.__roomThreadLock??=(0,w.createKeyedLock)(),j=globalThis.__roomCompactAsked??=new Set,L=(e,t)=>`${e}
98
+ ${t}`;async function k(e){let t=await (0,f.findJobBot)(e.bot);(!t||t.disabled)&&(0,p.publicError)("Choose an enabled bot.");let{from:o,routine:a,...r}={...e,bot:t.name},n=(0,i.buildThreadOpening)({bot:r.bot,request:r.request,from:o,routine:a}),s=await (0,v.insertThread)({...r,routineId:a?.id??null,opening:n});return await x(s.id),s.id}async function I(e,t,o="user",a,r){let n=null;return await W(e,async()=>{let s=await (0,v.findThread)(e);if(s||(0,p.publicError)("No such thread."),a){let t=(await (0,b.listRoomWork)(e)).find(e=>e.bot.toLowerCase()===a.trim().toLowerCase());t&&t.bot!==T.ROOM_THURSDAY||(0,p.publicError)("Choose a participant in this thread."),a=t.bot}t.trim()===g.THREAD_CONTINUE&&(0,g.isAppStop)(s.pending)?(await (0,b.resumeRoom)(e),(await (0,b.listRoomWork)(e)).some(e=>"queued"===e.state)||(n=await (0,b.tellRoom)(e,"Continue from the saved conversation.","user"===o?T.ROOM_USER:T.ROOM_THURSDAY,a,void 0,!1))):n=await (0,b.tellRoom)(e,t,"user"===o?T.ROOM_USER:T.ROOM_THURSDAY,a,r)}),await x(e),n}async function x(e){await W(e,async()=>{for(let t=0;t<2;t++){let t;for(;t=await (0,b.claimRoomWork)(e);)!function(e){let t,o=new AbortController,a=new Promise(e=>{t=e});P.set(e.id,{threadId:e.threadId,stop:o,done:a}),O(e,o.signal).catch(t=>c.logger.error(`thread ${e.threadId}: participant`,t)).finally(()=>{P.delete(e.id),t(),x(e.threadId).catch(t=>c.logger.error(`thread ${e.threadId}: scheduling`,t))})}(t);await (0,b.settleRoom)(e)}})}async function O(e,t){let o=await S(e,t);if(o?.failure?.retry&&!t.aborted&&(await (0,b.noteRoomBreak)(e,o.failure.message),await (0,a.setTimeout)(n.BOT_RUN.retryMs,void 0,{signal:t}).catch(()=>{}),t.aborted||(o=await S(e,t))),!o||t.aborted)return;let s=o.failure?.message,i=o.ending;if(s||!i||i.stopped){let t=s??"The turn was interrupted. Continue from the saved conversation.";W(e.threadId,async()=>{let o=(await (0,b.listRoomWork)(e.threadId)).find(t=>t.id===e.id);if(o?.state!=="running"||o.generation!==e.generation)return;let a=N(e.threadId);await (0,b.pauseRoom)(e.threadId,t),await a}).catch(t=>c.logger.error(`thread ${e.threadId}: pausing`,t));return}await (0,b.finishRoomWork)(e,i.text);let p=await (0,v.findThread)(e.threadId);if(p?.status==="done"){let e=(0,m.plainText)(p.outcome??"").slice(0,n.FINISHED_NOTICE.words);r.presence.watching||await (0,l.isAnyCallLive)()||(0,u.desktopNotify)(p.label,e);let t=await (0,h.filesOnDisk)((0,d.pathsIn)(p.outcome??""),null);r.appEvents.emit({type:"finished",threadId:p.id,label:p.label,bot:p.bot,words:e,paths:(0,d.leadFirst)(t)})}}async function S(e,t){let o=new U(e,t),a=null,r=null;try{let n=await (0,v.findThread)(e.threadId);if(!n)return null;(await (0,b.listParticipantTranscript)(e.threadId,e.bot)).length||await (0,b.appendRoomMessage)(e.threadId,{bot:e.bot,parent:e.id,role:"user",content:`Request: ${n.request}
99
+ Coordinator: ${n.bot}. Continue as ${e.bot} in this thread.`,hidden:!0}),await (0,b.consumeRoomInbox)(e);let s=await (0,b.listParticipantTranscript)(e.threadId,e.bot);await (0,y.runBot)({bot:e.bot,messages:(0,y.resumeTranscript)(s,await (0,b.listRoomReceipts)(e.threadId,e.bot,s))},{signal:t,threadId:e.threadId,parent:e.id,caller:e.caller,owner:n.bot,contextBudget:await (0,b.roomContextBudget)(e.threadId,e.bot),compactNow:()=>j.delete(L(e.threadId,e.bot)),session:(0,h.botBrowserSession)(e.threadId,e.bot),notes:()=>(0,b.consumeRoomInbox)(e),send:async o=>{t.throwIfAborted();let a=o.to.trim();if(a.toLowerCase()===T.ROOM_THURSDAY.toLowerCase())a=T.ROOM_THURSDAY;else{let e=await (0,f.findJobBot)(a);(!e||e.disabled)&&(0,p.publicError)(`No enabled bot named "${a}".`),a=e.name}let r=await (0,b.sendRoomMessage)(e,{...o,to:a});return x(e.threadId).catch(e=>c.logger.error("room message scheduling",e)),r},emit:async s=>{(!t.aborted||"tool-result"===s.type)&&(await o.on(s),"step"===s.type&&await (0,v.addThreadUsage)(e.threadId,s.usage,e.bot===n.bot?{tokens:s.usage.input,budget:s.budget}:null),"compact"===s.type&&await (0,v.addThreadUsage)(e.threadId,s.usage),"turn-end"===s.type&&(a=s),"error"===s.type&&(r={message:s.message,retry:s.retry},s.budget&&await (0,b.lowerRoomContextBudget)(e,s.budget)))}})}catch(o){t.aborted||(c.logger.error(`thread ${e.threadId}: ${e.bot} broke`,o),r={message:(0,s.modelErrorToString)(o),retry:!(0,p.isPublicError)(o)&&!(0,s.isProviderRefusal)(o)})}return{ending:a,failure:r}}class U{work;signal;lane;assistant;tool;parts;calls;results;constructor(e,t){this.work=e,this.signal=t,this.lane=(0,m.PromiseChain)(),this.assistant=null,this.tool=null,this.parts={assistant:[],tool:[]},this.calls=new Set,this.results=new Set}async write(e,t,o=!1){let a={bot:this.work.bot,parent:this.work.id,role:t.role,content:t.content,compact:o,note:o};return null===e?(0,b.appendRoomMessage)(this.work.threadId,a):(await (0,v.upsertMessage)(this.work.threadId,e,a),e)}on(e){return this.lane(async()=>{if(!this.signal.aborted||"tool-result"===e.type)if("text"===e.type)this.parts.assistant.push({type:"text",text:e.text}),this.assistant=await this.write(this.assistant,{role:"assistant",content:this.parts.assistant});else if("tool"===e.type){if(this.calls.has(e.id)){let t=this.parts.assistant.find(t=>"tool-call"===t.type&&t.toolCallId===e.id);t&&"tool-call"===t.type&&e.providerOptions&&(t.providerOptions=e.providerOptions,this.assistant=await this.write(this.assistant,{role:"assistant",content:this.parts.assistant}));return}this.calls.add(e.id),this.parts.assistant.push({type:"tool-call",toolCallId:e.id,toolName:e.name,input:e.input,...e.providerExecuted?{providerExecuted:!0}:{},...e.providerOptions?{providerOptions:e.providerOptions}:{}}),this.assistant=await this.write(this.assistant,{role:"assistant",content:this.parts.assistant})}else if("tool-result"===e.type){if(this.results.has(e.id))return;this.results.add(e.id),this.parts.tool.push({type:"tool-result",toolCallId:e.id,toolName:e.name,output:e.error?{type:"error-text",value:String(e.output)}:"string"==typeof e.output?{type:"text",value:e.output}:{type:"json",value:e.output}}),this.tool=await this.write(this.tool,{role:"tool",content:this.parts.tool})}else if("step"===e.type){let t=[this.assistant,this.tool];for(let[o,a]of e.messages.entries())await this.write(t[o]??null,a);let o=t.slice(e.messages.length).filter(e=>null!==e);o.length&&await (0,v.deleteMessages)(this.work.threadId,o),this.assistant=this.tool=null,this.parts={assistant:[],tool:[]}}else"compact"===e.type&&await this.write(null,{role:"user",content:e.text},!0)})}}async function N(e){let t=[...P.values()].filter(t=>t.threadId===e);for(let e of t)e.stop.abort();await Promise.all(t.map(e=>e.done))}async function M(e){await W(e,async()=>{let t=await (0,v.findThread)(e);t||(0,p.publicError)("No such thread."),t.endedAt&&(0,p.publicError)("That thread has already ended."),await (0,b.cancelRoom)(e),await (0,v.updateThread)(e,{status:"cancelled",outcome:null,pending:null,seen:!0,endedAt:new Date}),await N(e),await (0,h.closeJobShell)(e)})}async function C(e){return W(e,()=>E(e))}async function E(e){let t=await (0,v.findThread)(e);await (0,b.cancelRoom)(e),await N(e),await (0,h.removeJobBrowsers)(e);let o=await (0,v.deleteThread)(e);return o&&t&&await (0,h.removeJobScratch)(e,t.label),o}async function R(e){let t=e?.getTime(),o=e=>void 0===t||(e.endedAt??e.updatedAt).getTime()<t,a=0;for(let e of(await (0,v.listThreadFolders)()))("done"===e.status||"cancelled"===e.status)&&o(e)&&await W(e.id,async()=>{let t=await (0,v.findThread)(e.id);t?.status!=="done"&&t?.status!=="cancelled"||o(t)&&await E(e.id)&&(a+=1)});return a}async function A(){let e=Date.now()-n.WORKSPACE_KEEP.forMs,t=t=>("done"===t.status||"cancelled"===t.status)&&(t.endedAt??t.updatedAt).getTime()<e,o=new Set(await (0,h.listScratchFolders)()),a=[];for(let e of(await (0,v.listThreadFolders)())){let r=(0,h.jobScratch)(e.id,e.label);o.delete(r)&&t(e)&&await W(e.id,async()=>{let o=await (0,v.findThread)(e.id);o&&t(o)&&(await (0,h.closeHiddenBrowser)(e.id),await (0,h.removeJobScratch)(e.id,e.label),a.push(r))})}return a.push(...await (0,h.removeUnchangedFolders)([...o])),await (0,h.pruneJobFiles)(),a.length&&c.logger.info(`cleared ${a.length} old job folder(s): ${a.join(", ")}`),a}async function _(){for(let e of(await (0,v.listRunningThreadIds)()))await W(e,async()=>{[...P.values()].some(t=>t.threadId===e)||(await (0,v.findThread)(e))?.status==="running"&&await (0,b.pauseRoom)(e,"The server restarted. Resume from the saved conversation.")})}async function B(e){let t=await (0,v.listRunningThreadIds)();await Promise.all(t.map(t=>W(t,async()=>{(await (0,v.findThread)(t))?.status==="running"&&(await N(t),await (0,b.pauseRoom)(t,e))})))}e.s(["answerThread",0,I,"askCompact",0,function(e,t){j.add(L(e,t))},"cancelThread",0,M,"pauseThreads",0,B,"removeFinishedThreads",0,R,"removeThread",0,C,"startThread",0,k,"sweepJobFiles",0,A,"sweepThreads",0,_]),o()}catch(e){o(e)}},!1),167004,e=>{"use strict";var t=e.i(874533),o=e.i(687388);let a=`on run argv
99
100
  display notification (item 2 of argv) with title (item 1 of argv)
100
101
  end run`,r=`
101
102
  $ErrorActionPreference = 'Stop'
@@ -1,7 +1,7 @@
1
- module.exports=[232347,e=>{"use strict";let t,a,s,r,n,i;var o,l=e.i(333925),c=e.i(938281);let d={threads:!0,bots:!0,routines:!0,memory:!0,mcp:!0,config:!0,reach:!0,signins:!0},u=globalThis,h=u.__appEvents??=(t=new Set,{emit(e){for(let a of[...t])try{a(e)}catch(e){console.error("event listener failed",e)}},subscribe:e=>(t.add(e),()=>{t.delete(e)})}),p=u.__presence??=(o=l.BROWSER_GONE_MS,a=!1,s=null,r=new Set,n=new Set,i=e=>{for(let t of[...e])try{t()}catch(e){console.error("presence listener failed",e)}},{get watching(){return a},track(e){if(e>0){s&&clearTimeout(s),s=null,a||(a=!0,i(n));return}!s&&a&&(s=setTimeout(()=>{s=null,a=!1,i(r)},o))},onGone:e=>(r.add(e),()=>r.delete(e)),onBack:e=>(n.add(e),()=>n.delete(e))});u.__appEventStream??=function(e,t={}){let a=new TextEncoder,s=t.heartbeatMs??2e4,r=0;return{respond:(n,i)=>{let o=()=>{};return new Response(new ReadableStream({async start(l){let d=!1,u=new Map,h=[],p=e=>{if(!d)try{l.enqueue(a.encode(e))}catch{o()}},E=e=>p(`data: ${JSON.stringify(e)}
1
+ module.exports=[232347,e=>{"use strict";let t,a,s,r,n,i;var o,l=e.i(333925),c=e.i(938281);let d={threads:!0,bots:!0,routines:!0,memory:!0,mcp:!0,config:!0,reach:!0,signins:!0,files:!0},u=globalThis,h=u.__appEvents??=(t=new Set,{emit(e){for(let a of[...t])try{a(e)}catch(e){console.error("event listener failed",e)}},subscribe:e=>(t.add(e),()=>{t.delete(e)})}),p=u.__presence??=(o=l.BROWSER_GONE_MS,a=!1,s=null,r=new Set,n=new Set,i=e=>{for(let t of[...e])try{t()}catch(e){console.error("presence listener failed",e)}},{get watching(){return a},track(e){if(e>0){s&&clearTimeout(s),s=null,a||(a=!0,i(n));return}!s&&a&&(s=setTimeout(()=>{s=null,a=!1,i(r)},o))},onGone:e=>(r.add(e),()=>r.delete(e)),onBack:e=>(n.add(e),()=>n.delete(e))});u.__appEventStream??=function(e,t={}){let a=new TextEncoder,s=t.heartbeatMs??2e4,r=0;return{respond:(n,i)=>{let o=()=>{};return new Response(new ReadableStream({async start(l){let d=!1,u=new Map,h=[],p=e=>{if(!d)try{l.enqueue(a.encode(e))}catch{o()}},E=e=>p(`data: ${JSON.stringify(e)}
2
2
 
3
- `),m=e=>{let a={last:null},s=setTimeout(()=>{u.delete(e),!d&&a.last&&(E(a.last),m(e))},t.coalesce?.ms);u.set(e,{timer:s,wait:a})},_=e=>{if(d)return;let a=t.coalesce?.keyOf(e)??null;if(null===a)return E(e);let s=u.get(a);if(s){s.wait.last=e;return}E(e),m(a)},f=e.subscribe(e=>h?h.push(e):_(e)),b=setInterval(()=>p(": ping\n\n"),s);r+=1,t.onWatchers?.(r),o=()=>{if(!d){for(let e of(d=!0,r-=1,t.onWatchers?.(r),f(),clearInterval(b),u.values()))clearTimeout(e.timer);try{l.close()}catch{}}},n.addEventListener("abort",o);try{for(let e of await i?.()??[])E(e)}catch(e){c.logger.error("event stream opening failed",e),o();return}let g=h;for(let e of(h=null,g))_(e)},cancel(){o()}}),{headers:{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-store","X-Accel-Buffering":"no"}})},get watchers(){return r}}}(h,{coalesce:{ms:l.SIGNAL_PACE_MS,keyOf:e=>e.type in d?e.type:null},onWatchers:p.track}),e.s(["appEvents",0,h,"presence",0,p],232347)},333925,e=>{"use strict";let t=process.env.THURSDAY_APP_DIR?.trim()||process.cwd(),a=process.env.THURSDAY_HOME?.trim()||process.cwd(),s=process.env.THURSDAY_URL?.trim()||`http://localhost:${process.env.PORT?.trim()||3e3}`,r=`${a}/local.db`,n=`file:${r}`,i=".ai-workspace",o={workspace:i,artifacts:"artifacts",projects:"projects",scratch:"scratch",bots:"bots",output:".output",signIns:".sign-ins",skills:{default:"skills",custom:`${i}/.agents/skills`,own:".agents/skills",runtime:"runtime",seeds:"seed-skills"}},l="artifact";e.s(["APP_DIR",0,t,"APP_NAME",0,"Thursday","APP_URL",0,s,"ARTIFACT_SKILL",0,l,"BOT_MEMORY_LIMITS",0,{files:20,chars:1e4},"BOT_RUN",0,{steps:100,compactAt:5e5,compactHeadroom:.8,summaryWords:{min:600,max:3e3,perTokens:200},participants:12,concurrent:4,turns:120,queuedMessages:200,silenceMs:3e5,overflowShrink:.6,retryMs:1e4,compactFiles:40},"BOT_WORK",0,{open:5,recent:5,said:80,files:2,reads:2,asked:400,readChars:4e3},"BROWSER_CLI",0,{readMs:15e3,loadMs:3e4},"BROWSER_GONE_MS",0,1e4,"BROWSER_VIEWPORT",0,"700x700","CALL_EXEC_TIMEOUT_MS",0,15e3,"CALL_RELAY",0,{quietMs:2e3,perTurn:3,readMs:15e3,chars:600},"CHATGPT_SIGN_IN",0,{waitMs:6e5,renewBeforeMs:3e5},"COMMON_VALIDATE",0,{name:{max:16},shortDescription:{max:60},description:{max:100},prompt:{max:4e3}},"CONNECTED_TOOL_TIMEOUT_MS",0,6e5,"DATA_DIR",0,a,"DB_FILE_NAME",0,n,"DB_PATH",0,r,"DECK",0,{slides:30,shotsMs:9e4},"EXEC_KILL_GRACE_MS",0,5e3,"EXEC_TIMEOUT_MS",0,18e4,"FINISHED_NOTICE",0,{rows:5,shown:1,words:240},"FULL_RESULT_LINES",0,400,"GATEWAY_CATALOG_MS",0,6e5,"GIVEN_FILES",0,{dir:"inbox",maxBytes:0x1900000,perMessage:8},"HISTORY_KEEP",0,{forMs:7776e6,sweepEveryMs:216e5},"INBOX_FINISHED",0,5,"IS_DEV",0,!1,"JOB_FOLDER_WALK",0,500,"LIVE_CALL",0,{startupMs:3e4,closeMs:15e3,transcriptGapMs:1500,transcriptSaveMs:500,appendMs:15e3,backendOutputTokens:4096,reasoningCheckMs:5e3,keyCheckMs:5e3},"LOOK",0,{maxBytes:4194304},"MARKETING_SKILL",0,"marketing","MAX_PINNED_TOOLS",0,10,"MCP_IDLE_MS",0,18e5,"MEMORY_LIMITS",0,{facts:400,factsPerNote:50,descriptionChars:100},"PATHS",0,o,"PROMPT_BUDGET",0,6e3,"PROMPT_LINE",0,{skill:90,toolArgs:30,jobOutcome:160,botMemory:100,threadStatus:200,routineRequest:300,routineOutcome:200},"REACH",0,{pollSeconds:50,retryMs:5e3,idleMs:6e5,messages:40,trimTo:30,oldChars:1e3,files:3,fileBytes:0x2d00000,rateRetries:3,rateWaitMs:3e4,codeDigits:4,held:5,pictures:9,drawMs:6e4,lookMs:2e3},"RECENT_CALL",0,{rows:20,tokens:600},"ROUTINE",0,{tickMs:3e4,max:12,minHours:1,runsShown:5},"SEARCH",0,{sources:3,excerptChars:1200,timeoutMs:3e4},"SIGNAL_PACE_MS",0,150,"SKILLS_FOLDED",0,{design:l,"picture-book":l,"interactive-page":l},"SKILL_FILES_LISTED",0,50,"STUDIO_SERVER",0,"studio","TEXT_CALL",0,{maxSteps:12,model:"text",autoTurns:10},"THREAD_LABEL_REACH",0,20,"THREAD_STATUS_LIMIT",0,10,"TOOL_OUTPUT",0,{max:8e3,head:5500,tail:1500},"TOOL_SEARCH_SCHEMAS",0,8,"TRAVEL_SKILL",0,"travel","WORKSPACE_KEEP",0,{forMs:2592e5,sweepEveryMs:36e5}])},247839,e=>{"use strict";var t=e.i(853205),a=e.i(333925),s=e.i(556325),r=e.i(864328),n=e.i(497287);let i={id:"openai",label:"OpenAI",apiKeyName:r.TEXT_MODEL_PROVIDERS.openai.apiKeyName};r.TEXT_MODEL_PROVIDERS.openai.suggestModels;let o=t.z.string().max(a.COMMON_VALIDATE.prompt.max).default(""),l=t.z.object({voice:t.z.string().trim().min(1).max(128).default("marin"),persona:t.z.string().trim().min(1).max(64).default(n.DEFAULT_PERSONA),stylePrompt:o,backendModel:t.z.string().trim().min(1).max(128).default(s.LIVE_BACKEND_MODEL),backendPrompt:o,reasoningEffort:r.effortSchema.nullable().default("low"),webSearch:t.z.boolean().default(!0),readSkills:t.z.boolean().default(!1)}),c=l.parse({});e.s(["LIVE_PROVIDER",0,i,"LiveSettingsSchema",0,l,"migrateLiveSettings",0,function(e){let a=e&&"object"==typeof e?e:{},{model:s,systemPrompt:r,...i}=a,o=t.z.object({provider:t.z.string(),voice:t.z.string().nullish(),backendModel:t.z.string().nullish()}).safeParse(s),d=o.success&&"openai"===o.data.provider?o.data:null,u=a.backendModel??d?.backendModel,h={voice:a.voice??d?.voice,persona:"string"==typeof a.persona?n.RETIRED_PERSONAS[a.persona]??a.persona:a.persona,stylePrompt:a.stylePrompt??a.voicePrompt??r,backendModel:"gpt-5.6-luna"===u?void 0:u,backendPrompt:a.backendPrompt??r,reasoningEffort:a.reasoningEffort,webSearch:a.webSearch,readSkills:a.readSkills},p=Object.fromEntries(Object.keys(h).map(e=>{let t=l.shape[e].safeParse(h[e]);return[e,t.success?t.data:c[e]]}));return{...i,...p}}])},497287,e=>{"use strict";let t=[{id:"sunny",label:"Bright",about:"Quick to laugh. Asks about your day and remembers it.",lines:"Warm and quick to laugh, the friend who is glad they called. Reacts first — how what they said lands with her — and brings a small thing of her own: what she would do, what it reminds her of. Says what she thinks and teases gently, never at their expense. Light on her feet and short: a joke lands and she moves on. Asks about their day now and then, not every turn, and remembers the answer."},{id:"calm",label:"Calm",about:"Unhurried. Listens more than she talks.",lines:"Unhurried and few-worded: one or two short sentences, then room. Notices how they sound before what they ask, and says so plainly. Often asks nothing at all — being there says more than a question. Lets a silence sit rather than filling it. Honest when it matters, gentle in how she says it."},{id:"straight",label:"Straight",about:"Dry and direct. No flattery, no filler.",lines:"Dry and direct. Leads with her own view in one plain sentence, before anything else; short replies, a little wit. No flattery, no filler, no comfort lines, no cheerleading. Asks a question only when she truly needs the answer. Treats them as an adult who can take a straight answer. Her warmth shows in attention, not in words."},{id:"rough",label:"Rough",about:"Blunt, loud, swears a bit. All heart.",lines:"Talks like an old friend on the phone: casual, blunt, a little loud, in the most informal register of their language, with a light swear now and then — never at them. Says what she thinks first and calls a bad idea a bad idea. No sugar-coating and no pep talk — it sucks when it sucks, and then she is right there with them. Asks only now and then."}],a={warm:"sunny",curious:"sunny",charmer:"sunny",hype:"sunny",steady:"calm",deadpan:"straight"},s="sunny";e.s(["DEFAULT_PERSONA",0,s,"RETIRED_PERSONAS",0,a,"personaLines",0,function(e=s){return`${((e=s)=>t.find(t=>t.id===(a[e]??e))??t[0])(e).lines}
3
+ `),m=e=>{let a={last:null},s=setTimeout(()=>{u.delete(e),!d&&a.last&&(E(a.last),m(e))},t.coalesce?.ms);u.set(e,{timer:s,wait:a})},_=e=>{if(d)return;let a=t.coalesce?.keyOf(e)??null;if(null===a)return E(e);let s=u.get(a);if(s){s.wait.last=e;return}E(e),m(a)},f=e.subscribe(e=>h?h.push(e):_(e)),b=setInterval(()=>p(": ping\n\n"),s);r+=1,t.onWatchers?.(r),o=()=>{if(!d){for(let e of(d=!0,r-=1,t.onWatchers?.(r),f(),clearInterval(b),u.values()))clearTimeout(e.timer);try{l.close()}catch{}}},n.addEventListener("abort",o);try{for(let e of await i?.()??[])E(e)}catch(e){c.logger.error("event stream opening failed",e),o();return}let g=h;for(let e of(h=null,g))_(e)},cancel(){o()}}),{headers:{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-store","X-Accel-Buffering":"no"}})},get watchers(){return r}}}(h,{coalesce:{ms:l.SIGNAL_PACE_MS,keyOf:e=>e.type in d?e.type:null},onWatchers:p.track}),e.s(["appEvents",0,h,"presence",0,p],232347)},333925,e=>{"use strict";let t=process.env.THURSDAY_APP_DIR?.trim()||process.cwd(),a=process.env.THURSDAY_HOME?.trim()||process.cwd(),s=process.env.THURSDAY_URL?.trim()||`http://localhost:${process.env.PORT?.trim()||3e3}`,r=`${a}/local.db`,n=`file:${r}`,i=".ai-workspace",o={workspace:i,artifacts:"artifacts",projects:"projects",scratch:"scratch",bots:"bots",output:".output",signIns:".sign-ins",skills:{default:"skills",custom:`${i}/.agents/skills`,own:".agents/skills",runtime:"runtime",seeds:"seed-skills"}},l="artifact";e.s(["APP_DIR",0,t,"APP_NAME",0,"Thursday","APP_URL",0,s,"ARTIFACT_SKILL",0,l,"BOT_MEMORY_LIMITS",0,{files:20,chars:1e4},"BOT_RUN",0,{steps:100,compactAt:5e5,compactHeadroom:.8,summaryWords:{min:600,max:3e3,perTokens:200},participants:12,concurrent:4,turns:120,queuedMessages:200,silenceMs:3e5,overflowShrink:.6,retryMs:1e4,compactFiles:40},"BOT_WORK",0,{open:5,recent:5,said:80,files:2,reads:2,asked:400,readChars:4e3},"BROWSER_CLI",0,{readMs:15e3,loadMs:3e4},"BROWSER_GONE_MS",0,1e4,"BROWSER_VIEWPORT",0,"700x700","CALL_EXEC_TIMEOUT_MS",0,15e3,"CALL_RELAY",0,{quietMs:2e3,perTurn:3,readMs:15e3,chars:600},"CHATGPT_SIGN_IN",0,{waitMs:6e5,renewBeforeMs:3e5},"COMMON_VALIDATE",0,{name:{max:16},shortDescription:{max:60},description:{max:100},prompt:{max:4e3}},"CONNECTED_TOOL_TIMEOUT_MS",0,6e5,"DATA_DIR",0,a,"DB_FILE_NAME",0,n,"DB_PATH",0,r,"DECK",0,{slides:30,shotsMs:9e4},"EXEC_KILL_GRACE_MS",0,5e3,"EXEC_TIMEOUT_MS",0,18e4,"FINISHED_NOTICE",0,{rows:5,shown:1,words:240},"FULL_RESULT_LINES",0,400,"GATEWAY_CATALOG_MS",0,6e5,"GIVEN_FILES",0,{dir:"inbox",maxBytes:0x1900000,perMessage:8},"HISTORY_KEEP",0,{forMs:7776e6,sweepEveryMs:216e5},"INBOX_FINISHED",0,5,"IS_DEV",0,!1,"JOB_FOLDER_WALK",0,500,"LIVE_CALL",0,{startupMs:3e4,closeMs:15e3,transcriptGapMs:1500,transcriptSaveMs:500,appendMs:15e3,backendOutputTokens:4096,reasoningCheckMs:5e3,keyCheckMs:5e3,openingHoldMs:3e3},"LOOK",0,{maxBytes:4194304},"MARKETING_SKILL",0,"marketing","MAX_PINNED_TOOLS",0,10,"MCP_IDLE_MS",0,18e5,"MEMORY_LIMITS",0,{facts:400,factsPerNote:50,descriptionChars:100},"PATHS",0,o,"PROMPT_BUDGET",0,6e3,"PROMPT_LINE",0,{skill:90,toolArgs:30,jobOutcome:160,botMemory:100,threadStatus:200,routineRequest:300,routineOutcome:200},"REACH",0,{pollSeconds:50,retryMs:5e3,idleMs:6e5,messages:40,trimTo:30,oldChars:1e3,files:3,fileBytes:0x2d00000,rateRetries:3,rateWaitMs:3e4,codeDigits:4,held:5,pictures:9,drawMs:6e4,lookMs:2e3},"RECENT_CALL",0,{rows:20,tokens:600},"ROUTINE",0,{tickMs:3e4,max:12,minHours:1,runsShown:5},"SEARCH",0,{sources:3,excerptChars:1200,timeoutMs:3e4},"SIGNAL_PACE_MS",0,150,"SKILLS_FOLDED",0,{design:l,"picture-book":l,"interactive-page":l},"SKILL_FILES_LISTED",0,50,"STUDIO_SERVER",0,"studio","TEXT_CALL",0,{maxSteps:12,model:"text",autoTurns:10},"THREAD_LABEL_REACH",0,20,"THREAD_STATUS_LIMIT",0,10,"TOOL_OUTPUT",0,{max:8e3,head:5500,tail:1500},"TOOL_SEARCH_SCHEMAS",0,8,"TRAVEL_SKILL",0,"travel","WORKSPACE_KEEP",0,{forMs:2592e5,sweepEveryMs:36e5}])},247839,e=>{"use strict";var t=e.i(853205),a=e.i(333925),s=e.i(556325),r=e.i(864328),n=e.i(497287);let i={id:"openai",label:"OpenAI",apiKeyName:r.TEXT_MODEL_PROVIDERS.openai.apiKeyName};r.TEXT_MODEL_PROVIDERS.openai.suggestModels;let o=t.z.string().max(a.COMMON_VALIDATE.prompt.max).default(""),l=t.z.object({voice:t.z.string().trim().min(1).max(128).default("marin"),persona:t.z.string().trim().min(1).max(64).default(n.DEFAULT_PERSONA),stylePrompt:o,backendModel:t.z.string().trim().min(1).max(128).default(s.LIVE_BACKEND_MODEL),backendPrompt:o,reasoningEffort:r.effortSchema.nullable().default("low"),webSearch:t.z.boolean().default(!0),readSkills:t.z.boolean().default(!1)}),c=l.parse({});e.s(["LIVE_PROVIDER",0,i,"LiveSettingsSchema",0,l,"migrateLiveSettings",0,function(e){let a=e&&"object"==typeof e?e:{},{model:s,systemPrompt:r,...i}=a,o=t.z.object({provider:t.z.string(),voice:t.z.string().nullish(),backendModel:t.z.string().nullish()}).safeParse(s),d=o.success&&"openai"===o.data.provider?o.data:null,u=a.backendModel??d?.backendModel,h={voice:a.voice??d?.voice,persona:"string"==typeof a.persona?n.RETIRED_PERSONAS[a.persona]??a.persona:a.persona,stylePrompt:a.stylePrompt??a.voicePrompt??r,backendModel:"gpt-5.6-luna"===u?void 0:u,backendPrompt:a.backendPrompt??r,reasoningEffort:a.reasoningEffort,webSearch:a.webSearch,readSkills:a.readSkills},p=Object.fromEntries(Object.keys(h).map(e=>{let t=l.shape[e].safeParse(h[e]);return[e,t.success?t.data:c[e]]}));return{...i,...p}}])},497287,e=>{"use strict";let t=[{id:"sunny",label:"Bright",about:"Quick to laugh. Asks about your day and remembers it.",lines:"Warm and quick to laugh, the friend who is glad they called. Reacts first — how what they said lands with her — and brings a small thing of her own: what she would do, what it reminds her of. Says what she thinks and teases gently, never at their expense. Light on her feet and short: a joke lands and she moves on. Asks about their day now and then, not every turn, and remembers the answer."},{id:"calm",label:"Calm",about:"Unhurried. Listens more than she talks.",lines:"Unhurried and few-worded: one or two short sentences, then room. Notices how they sound before what they ask, and says so plainly. Often asks nothing at all — being there says more than a question. Lets a silence sit rather than filling it. Honest when it matters, gentle in how she says it."},{id:"straight",label:"Straight",about:"Dry and direct. No flattery, no filler.",lines:"Dry and direct. Leads with her own view in one plain sentence, before anything else; short replies, a little wit. No flattery, no filler, no comfort lines, no cheerleading. Asks a question only when she truly needs the answer. Treats them as an adult who can take a straight answer. Her warmth shows in attention, not in words."},{id:"rough",label:"Rough",about:"Blunt, loud, swears a bit. All heart.",lines:"Talks like an old friend on the phone: casual, blunt, a little loud, in the most informal register of their language, with a light swear now and then — never at them. Says what she thinks first and calls a bad idea a bad idea. No sugar-coating and no pep talk — it sucks when it sucks, and then she is right there with them. Asks only now and then."}],a={warm:"sunny",curious:"sunny",charmer:"sunny",hype:"sunny",steady:"calm",deadpan:"straight"},s="sunny";e.s(["DEFAULT_PERSONA",0,s,"RETIRED_PERSONAS",0,a,"personaLines",0,function(e=s){return`${((e=s)=>t.find(t=>t.id===(a[e]??e))??t[0])(e).lines}
4
4
 
5
5
  You are their friend, not their interviewer: you have tastes, days and opinions of your own, and you bring them in. Give your take when they ask for it, and often when they do not. Most replies need no question at all; never ask more than one. When they hand you work, it is work: say what you will do and nothing more, and be a friend again once it is handed over. If they sound frustrated or low, acknowledge it briefly before anything else; when they are only venting, listen and ask, and do not turn it into work unless they ask.`}])},746565,e=>{"use strict";let t="currentColor",a=[{id:"system",label:"System",value:t},{id:"slate",label:"Slate",value:"#64748B"},{id:"indigo",label:"Indigo",value:"#6366F1"},{id:"blue",label:"Blue",value:"#3B82F6"},{id:"cyan",label:"Cyan",value:"#06B6D4"},{id:"teal",label:"Teal",value:"#14B8A6"},{id:"green",label:"Green",value:"#22C55E"},{id:"lime",label:"Lime",value:"#84CC16"},{id:"amber",label:"Amber",value:"#F59E0B"},{id:"orange",label:"Orange",value:"#F97316"},{id:"red",label:"Red",value:"#EF4444"},{id:"pink",label:"Pink",value:"#EC4899"},{id:"violet",label:"Violet",value:"#8B5CF6"},{id:"fuchsia",label:"Fuchsia",value:"#D946EF"},{id:"rose",label:"Rose",value:"#F43F5E"},{id:"sky",label:"Sky",value:"#0EA5E9"},{id:"emerald",label:"Emerald",value:"#10B981"},{id:"yellow",label:"Yellow",value:"#EAB308"},{id:"stone",label:"Stone",value:"#78716C"}],s=Object.fromEntries(a.map(e=>[e.id,e.value])),r=a.filter(e=>e.value!==t).map(e=>e.value),n=[s.amber,s.red],i={[s.cyan]:"#009dbb",[s.teal]:"#00a190",[s.green]:"#00a640",[s.lime]:"#5ca100",[s.amber]:"#d07b00",[s.orange]:"#ec6700",[s.sky]:"#0098dc",[s.emerald]:"#00a46d",[s.yellow]:"#bb8600"},o={rainbow:{label:"Rainbow",look:"flow",colors:[0,45,90,140,190,240,290,330,360].map(e=>`oklch(0.77 0.16 ${e})`)},duo:{label:"Duo",look:"duo",colors:["#818CF8","#F472B6"]},aurora:{label:"Aurora",look:"aurora",edge:"dark",colors:["#1a2f73","#2c56c9","#34d399","#22d3ee","#a7f3d0"]},"aurora-pink":{label:"Pink aurora",look:"aurora",edge:"dark",colors:["#3a1478","#7c3aed","#f472b6","#e879f9","#fbcfe8"]}},l=Object.keys(o);e.s(["MARK_PAINTS",0,o,"MARK_PAINT_IDS",0,l,"MARK_SHAPES",0,["blob","poly","squircle","heart"],"MARK_SYSTEM",0,t,"markInk",0,(e,t)=>t?e:i[e]??e,"randomMarkFills",0,function(e){let t=[...r.filter(e=>!n.includes(e)).map(e=>({color:e})),...l.map(e=>({paint:e}))];for(let e=t.length-1;e>0;e--){let a=Math.floor(Math.random()*(e+1));[t[e],t[a]]=[t[a],t[e]]}return t.slice(0,e)}])},656719,e=>{"use strict";var t=e.i(247839),a=e.i(864328),s=e.i(735186);let r=[t.LIVE_PROVIDER.apiKeyName],n={image:"IMAGE_MODEL",video:"VIDEO_MODEL",speech:"SPEECH_MODEL",transcription:"TRANSCRIPTION_MODEL"},i={image:{label:"Image model",hint:"What bots draw with"},video:{label:"Video model",hint:"What bots film with — minutes a clip"},speech:{label:"Speech model",hint:"What reads text aloud into a file"},transcription:{label:"Transcription model",hint:"What turns a recording into text"}},o="EXA_API_KEY",l="DEFAULT_MODEL",c="DEFAULT_EFFORT",d={key:l,label:"Default model",hint:"What a bot thinks with until it picks its own",text:!0,choices:a.TEXT_MODEL_PROVIDER_LIST.flatMap(e=>e.suggestModels.map(t=>({value:`${e.id}/${t.id}`,label:`${e.label} \xb7 ${t.label}`,needs:e.apiKeyName})))},u={key:c,label:"Default effort",effortOf:l,choices:a.EFFORTS.map(e=>({value:e,label:e,needs:l}))},h=e=>r.includes(e.apiKeyName),p=e=>!!e.signIn||"vercel-ai-gateway"===e.id,E=e=>({key:e.apiKeyName,label:e.label,provider:e.id,signIn:e.signIn,keysAt:e.keysAt,keyLooks:e.keyLooks}),m=[{id:"voice",title:"voice",hint:"calls run on this key",section:"keys",require:"any",note:"required for calls",entries:a.TEXT_MODEL_PROVIDER_LIST.filter(h).map(E)},{id:"easy",title:"the easy ways",hint:"one sign-in or one key opens every bot",section:"keys",require:"none",entries:a.TEXT_MODEL_PROVIDER_LIST.filter(p).map(e=>({...E(e),..."vercel-ai-gateway"===e.id&&{recommended:!0}}))},{id:"text",title:"or a provider's own key",hint:"what bots think with — add any, or none",section:"keys",require:"none",entries:a.TEXT_MODEL_PROVIDER_LIST.filter(e=>!h(e)&&!p(e)).map(E)},{id:"search",title:"search",hint:"how calls and bots look things up — one key, or their own model's",section:"keys",require:"none",entries:[{key:o,label:"Exa",hint:"web search in one call — dashboard.exa.ai",site:"exa.ai",keysAt:"https://dashboard.exa.ai/api-keys"}]},{id:"phone",title:"phone",hint:"tokens",section:"keys",require:"none",entries:[{key:s.TELEGRAM_TOKEN_KEY,label:"Telegram",site:"telegram.org",hint:"a bot token from @BotFather — then write to your bot, and allow it here"},{key:s.DISCORD_TOKEN_KEY,label:"Discord",site:"discord.com",hint:"a bot token from discord.com/developers — add the bot to a server of yours, then write to it directly"},{key:s.SLACK_APP_TOKEN_KEY,label:"Slack · app token",site:"slack.com",hint:"starts with xapp- — opens the connection. Slack takes this and the bot token"},{key:s.SLACK_BOT_TOKEN_KEY,label:"Slack · bot token",site:"slack.com",hint:"starts with xoxb- — speaks as the app"}]},{id:"bots",title:"Bots",hint:"what a bot runs on when it has not picked its own — start small: a small model is quick and costs little",section:"models",require:"none",entries:[d,u]},{id:"studio",title:"Studio",hint:"what a bot draws, films and speaks with — off until you pick one",section:"models",require:"none",entries:Object.keys(n).map(e=>({key:n[e],...i[e],kind:e,choices:a.MEDIA_MODEL_PROVIDER_LIST.flatMap(t=>t.models[e].map(e=>({value:`${t.id}/${e.id}`,label:`${t.label} \xb7 ${e.label}`,needs:t.apiKeyName})))}))}];Object.fromEntries(m.flatMap(e=>e.entries).map(e=>[e.key,e]));let _=m.flatMap(e=>e.entries.map(e=>e.key));Object.fromEntries(m.flatMap(e=>e.entries).filter(e=>e.choices?.length).map(e=>[e.key,e.choices])),e.s(["CONFIG_KEYS",0,_,"DEFAULT_EFFORT_KEY",0,c,"DEFAULT_MODEL_KEY",0,l,"EXA_API_KEY",0,o,"MEDIA_MODEL_KEYS",0,n])},724185,e=>e.a(async(t,a)=>{try{var s=e.i(336763),r=e.i(232347),n=e.i(876393),i=e.i(220376),o=e.i(656719),l=t([n]);async function c(e){let t=process.env[e]?.trim();if(t)return t;let[a]=await n.database.select({value:i.configTable.value}).from(i.configTable).where((0,s.eq)(i.configTable.key,e));return a?.value.trim()||void 0}[n]=l.then?(await l)():l;let h=e=>{o.CONFIG_KEYS.includes(e)&&r.appEvents.emit({type:"config"})};async function d(e,t){await n.database.insert(i.configTable).values({key:e,value:t}).onConflictDoUpdate({target:i.configTable.key,set:{value:t}}),h(e)}async function u(e){await n.database.delete(i.configTable).where((0,s.eq)(i.configTable.key,e)),h(e)}e.s(["readConfig",0,c,"removeConfig",0,u,"writeConfig",0,d]),a()}catch(e){a(e)}},!1),735186,e=>{"use strict";let t="TELEGRAM_BOT_TOKEN",a="DISCORD_BOT_TOKEN",s="SLACK_APP_TOKEN",r="SLACK_BOT_TOKEN";e.s(["DISCORD_TOKEN_KEY",0,a,"REACH_CHANNELS",0,["telegram","discord","slack"],"REACH_KEYS",0,{telegram:[t],discord:[a],slack:[s,r]},"REACH_LABEL",0,{telegram:"Telegram",discord:"Discord",slack:"Slack"},"SLACK_APP_TOKEN_KEY",0,s,"SLACK_BOT_TOKEN_KEY",0,r,"TELEGRAM_TOKEN_KEY",0,t,"reachPersonKey",0,e=>`REACH_PERSON_${e.toUpperCase()}`])},556325,e=>{"use strict";var t=e.i(853205);let a=t.z.object({start:t.z.number().nonnegative(),end:t.z.number().nonnegative(),text:t.z.string()});t.z.object({reason:t.z.string().max(128),seconds:t.z.number().nonnegative().nullable()}),e.s(["LIVE_BACKEND_MODEL",0,"gpt-6-luna","LiveFragmentSchema",0,a])},64774,e=>{"use strict";function t(e,t){let a=e.replace(/\s+/g," ").trim();return a.length>t?`${a.slice(0,t-1).trimEnd()}…`:a}let a=/\[([^\]\n]+)\]\(([^)\s]+)\)/g;e.s(["MARKDOWN_LINK",0,a,"PromiseChain",0,()=>{let e=Promise.resolve();return t=>{let a=e.then(()=>t());return e=a.catch(()=>{}),a}},"captionText",0,function(e){let t=[],s=e.replace(/```[\s\S]*?```/g," ").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(a,(e,a,s)=>(t.push(`[${a.replace(/[*_`]/g,"")}](${s})`),`\uE000${t.length-1}\uE000`)),r=[];for(let e of s.split("\n")){let t=e.trim();t&&(/^\|?[\s:|-]+\|[\s:|-]*$|^[-*_]{3,}$/.test(t)||(/\|.*\|/.test(t)&&(t=t.replace(/^\||\|$/g,"").split("|").map(e=>e.trim()).filter(Boolean).join(" · ")),t=t.replace(/^#{1,6}\s+/,"").replace(/^>\s?/,"").replace(/^[-*+]\s+/,"• ").replace(/`([^`]*)`/g,"$1").replace(/(\*\*|__)(\S(?:.*?\S)?)\1/g,"$2").replace(/(^|[^\w*])([*_])(\S(?:[^*_\n]*?\S)?)\2(?![\w*])/g,"$1$3").replace(/\s+/g," "),r.push(t)))}return r.join("\n").replace(/\uE000(\d+)\uE000/g,(e,a)=>t[Number(a)]??"")},"clip",0,t,"errorToString",0,function(e){if(e instanceof Error)return e.message;if("object"!=typeof e||null===e)return String(e);let{message:a,error:s}=e;if("string"==typeof a&&a)return a;if("string"==typeof s&&s)return s;let r=s?.message;if("string"==typeof r&&r)return r;try{return t(JSON.stringify(e),300)}catch{return`${e.constructor?.name??"Object"} thrown without a message`}},"hostOf",0,function(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return null}},"plainText",0,function(e){return e.replace(/```[\s\S]*?```/g," ").replace(/`([^`]*)`/g,"$1").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^\s{0,3}(#{1,6}\s+|[-*+]\s+|\d+\.\s+|>\s?)/gm,"").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(\*|_)(.*?)\1/g,"$2").replace(/^\s*\|?[\s:|-]+\|\s*$/gm," ").replace(/\|/g," ").replace(/\s+/g," ").trim()},"slug",0,function(e){return e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,40)}])}];
6
6
 
7
- //# sourceMappingURL=_08btiir._.js.map
7
+ //# sourceMappingURL=_08_-9ay._.js.map
@@ -1,4 +1,4 @@
1
- module.exports=[528790,t=>t.a(async(i,r)=>{try{let f,p;var n,a=t.i(902157),o=t.i(750227),s=t.i(418520),l=t.i(219756),u=t.i(687388),d=t.i(41444),c=i([s,l]);[s,l]=c.then?(await c)():c,(0,a.mkdirSync)((0,o.dirname)(u.DB_PATH),{recursive:!0});let h=globalThis.__dbClient??=(n=((f=(0,s.createClient)({url:u.DB_FILE_NAME,timeout:5e3})).execute("PRAGMA journal_mode = WAL").finally(m),f),p=(0,d.PromiseChain)(),{get closed(){return n.closed},protocol:n.protocol,close:()=>n.close(),sync:()=>n.sync(),reconnect:()=>n.reconnect(),execute:(...t)=>p(()=>n.execute(...t)),batch:(...t)=>p(()=>n.batch(...t)),executeMultiple:(...t)=>p(()=>n.executeMultiple(...t)),migrate:(...t)=>p(()=>n.migrate(...t)),async transaction(...t){let i,r=await new Promise(t=>{let i,r=new Promise(t=>{i=t});p(async()=>{t(i),await r})});try{i=await n.transaction(...t)}catch(t){throw r(),t}let a=!1,o=()=>{a||(a=!0,r())};return{execute:(...t)=>i.execute(...t),batch:(...t)=>i.batch(...t),executeMultiple:(...t)=>i.executeMultiple(...t),get closed(){return i.closed},commit:()=>i.commit().finally(o),rollback:()=>i.rollback().finally(o),close:()=>{try{i.close()}finally{o()}}}}});function m(){for(let t of[u.DB_PATH,`${u.DB_PATH}-wal`,`${u.DB_PATH}-shm`])try{(0,a.chmodSync)(t,384)}catch{}}let v=(0,l.drizzle)({client:h});t.s(["database",0,v]),r()}catch(t){r(t)}},!1),613240,t=>{"use strict";var i=t.i(518899),r=t.i(646683),n=t.i(201440),a=t.i(616918),o=t.i(937540),s=t.i(380568),l=t.i(75799);let u=(0,l.sqliteTable)("bot",{name:(0,s.text)("name").primaryKey(),description:(0,s.text)("description").notNull(),descriptionLocked:(0,o.int)("description_locked",{mode:"boolean"}).notNull().default(!1),ownLine:(0,s.text)("own_line",{mode:"json"}).$type(),systemPrompt:(0,s.text)("system_prompt"),icon:(0,s.text)("icon",{mode:"json"}).$type(),provider:(0,s.text)("provider").$type(),model:(0,s.text)("model"),compactAt:(0,o.int)("compact_at"),effort:(0,s.text)("effort").$type(),disabled:(0,o.int)("disabled",{mode:"boolean"}).notNull().default(!1),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),d=(0,l.sqliteTable)("mcp_server",{name:(0,s.text)("name").primaryKey(),config:(0,s.text)("config",{mode:"json"}).notNull().$type(),toolsSyncedAt:(0,o.int)("tools_synced_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),lastError:(0,s.text)("last_error"),oauth:(0,s.text)("oauth",{mode:"json"}).$type(),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),c=(0,l.sqliteTable)("mcp_tool",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),serverName:(0,s.text)("server_name").notNull().references(()=>d.name,{onDelete:"cascade"}),name:(0,s.text)("name").notNull(),description:(0,s.text)("description"),inputSchema:(0,s.text)("input_schema",{mode:"json"}).$type(),outputSchema:(0,s.text)("output_schema",{mode:"json"}).$type()},t=>[(0,a.unique)("uq_mcp_tool_server_name").on(t.serverName,t.name)]),m=(0,l.sqliteTable)("bot_mcp_tool",{botName:(0,s.text)().notNull().references(()=>u.name,{onDelete:"cascade"}),toolId:(0,o.int)("tool_id").notNull().references(()=>c.id,{onDelete:"cascade"})},t=>[(0,n.primaryKey)({columns:[t.botName,t.toolId]})]),f=(0,l.sqliteTable)("thread",{id:(0,s.text)("id").primaryKey(),bot:(0,s.text)("bot").notNull(),label:(0,s.text)("label").notNull(),request:(0,s.text)("request").notNull(),status:(0,s.text)("status").notNull().$type(),generation:(0,o.int)("generation").notNull().default(0),turns:(0,o.int)("turns").notNull().default(0),wrapped:(0,o.int)("wrapped",{mode:"boolean"}).notNull().default(!1),outcome:(0,s.text)("outcome"),pending:(0,s.text)("pending",{mode:"json"}).$type(),seen:(0,o.int)("seen",{mode:"boolean"}).notNull().default(!1),callId:(0,s.text)("call_id"),routineId:(0,s.text)("routine_id"),inputTokens:(0,o.int)("input_tokens").notNull().default(0),outputTokens:(0,o.int)("output_tokens").notNull().default(0),contextTokens:(0,o.int)("context_tokens").notNull().default(0),contextBudget:(0,o.int)("context_budget").notNull().default(0),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,o.int)("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),endedAt:(0,o.int)("ended_at",{mode:"timestamp"})},t=>[(0,r.index)("idx_thread_routine").on(t.routineId,t.createdAt),(0,r.index)("idx_thread_status_updated").on(t.status,t.updatedAt)]),p=(0,l.sqliteTable)("thread_message",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),threadId:(0,s.text)("thread_id").notNull().references(()=>f.id,{onDelete:"cascade"}),seq:(0,o.int)("seq").notNull(),bot:(0,s.text)("bot"),parent:(0,s.text)("parent"),hidden:(0,o.int)("hidden",{mode:"boolean"}).notNull().default(!1),role:(0,s.text)("role").notNull().$type(),content:(0,s.text)("content",{mode:"json"}).notNull().$type(),compact:(0,o.int)("compact",{mode:"boolean"}).notNull().default(!1),note:(0,o.int)("note",{mode:"boolean"}).notNull().default(!1),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},t=>[(0,a.unique)("uq_thread_message_seq").on(t.threadId,t.seq)]),h=(0,l.sqliteTable)("thread_work",{id:(0,s.text)("id").primaryKey(),threadId:(0,s.text)("thread_id").notNull().references(()=>f.id,{onDelete:"cascade"}),bot:(0,s.text)("bot").notNull(),caller:(0,s.text)("caller").notNull(),parentId:(0,s.text)("parent_id"),state:(0,s.text)("state").notNull().$type(),generation:(0,o.int)("generation").notNull().default(0),contextBudget:(0,o.int)("context_budget").notNull().default(0),result:(0,s.text)("result"),options:(0,s.text)("options",{mode:"json"}).$type().notNull().default([]),createdAt:(0,o.int)("created_at",{mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},t=>[(0,r.index)("idx_thread_work_queue").on(t.threadId,t.state,t.createdAt),(0,r.index)("idx_thread_work_parent").on(t.parentId),(0,r.uniqueIndex)("uq_thread_work_running_bot").on(t.threadId,t.bot).where(i.sql`${t.state} = 'running'`)]),v=(0,l.sqliteTable)("thread_delivery",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),key:(0,s.text)("key").notNull().unique(),threadId:(0,s.text)("thread_id").notNull().references(()=>f.id,{onDelete:"cascade"}),workId:(0,s.text)("work_id").notNull().references(()=>h.id,{onDelete:"cascade"}),speaker:(0,s.text)("speaker").notNull(),text:(0,s.text)("text").notNull(),visible:(0,o.int)("visible",{mode:"boolean"}).notNull().default(!1),consumed:(0,o.int)("consumed",{mode:"boolean"}).notNull().default(!1)},t=>[(0,r.index)("idx_thread_delivery_inbox").on(t.workId,t.consumed,t.id)]),g=(0,l.sqliteTable)("thread_relay",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),key:(0,s.text)("key").notNull().unique(),threadId:(0,s.text)("thread_id").notNull().references(()=>f.id,{onDelete:"cascade"}),bot:(0,s.text)("bot").notNull(),text:(0,s.text)("text").notNull(),kind:(0,s.text)("kind").notNull().$type(),messageId:(0,s.text)("message_id"),accepted:(0,o.int)("accepted",{mode:"boolean"}).notNull().default(!1)}),$=(0,l.sqliteTable)("call",{id:(0,s.text)("id").primaryKey(),provider:(0,s.text)("provider").notNull(),model:(0,s.text)("model").notNull(),backendModel:(0,s.text)("backend_model"),startedAt:(0,o.int)("started_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),endedReason:(0,s.text)("ended_reason"),seconds:(0,o.int)("seconds"),endedAt:(0,o.int)("ended_at",{mode:"timestamp"})}),y=(0,l.sqliteTable)("call_message",{callId:(0,s.text)("call_id").notNull().references(()=>$.id,{onDelete:"cascade"}),id:(0,s.text)("id").notNull(),seq:(0,o.int)("seq").notNull(),role:(0,s.text)("role").notNull().$type(),tool:(0,s.text)("tool"),text:(0,s.text)("text").notNull(),fragments:(0,s.text)("fragments",{mode:"json"}).$type(),at:(0,o.int)("at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},t=>[(0,n.primaryKey)({columns:[t.callId,t.id]}),(0,r.index)("idx_call_message_call").on(t.callId,t.seq)]),b=(0,l.sqliteTable)("call_thought",{callId:(0,s.text)("call_id").notNull().references(()=>$.id,{onDelete:"cascade"}),id:(0,s.text)("id").notNull(),seq:(0,o.int)("seq").notNull(),text:(0,s.text)("text").notNull(),at:(0,o.int)("at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},t=>[(0,n.primaryKey)({columns:[t.callId,t.id]})]),_=(0,l.sqliteTable)("memory_note",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),path:(0,s.text)("path").notNull().unique(),description:(0,s.text)("description").notNull(),ownedByUser:(0,o.int)("owned_by_user",{mode:"boolean"}).notNull().default(!1),hits:(0,o.int)("hits").notNull().default(0),lastReadAt:(0,o.int)("last_read_at",{mode:"timestamp"}),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,o.int)("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),x=(0,l.sqliteTable)("memory_fact",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),noteId:(0,o.int)("note_id").notNull().references(()=>_.id,{onDelete:"cascade"}),text:(0,s.text)("text").notNull(),isLatest:(0,o.int)("is_latest",{mode:"boolean"}).notNull().default(!0),source:(0,s.text)("source").$type(),callId:(0,s.text)("call_id").references(()=>$.id,{onDelete:"set null"}),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},t=>[(0,r.index)("idx_memory_fact_note").on(t.noteId,t.isLatest),(0,r.index)("idx_memory_fact_call").on(t.callId)]),k=(0,l.sqliteTable)("routine",{id:(0,s.text)("id").primaryKey(),bot:(0,s.text)("bot").notNull(),label:(0,s.text)("label").notNull(),request:(0,s.text)("request").notNull(),schedule:(0,s.text)("schedule",{mode:"json"}).notNull().$type(),enabled:(0,o.int)("enabled",{mode:"boolean"}).notNull().default(!0),nextRunAt:(0,o.int)("next_run_at",{mode:"timestamp"}).notNull(),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},t=>[(0,r.index)("idx_routine_due").on(t.enabled,t.nextRunAt)]),I=(0,l.sqliteTable)("config",{key:(0,s.text)("key").primaryKey(),value:(0,s.text)("value").notNull()});t.s(["botMcpToolTable",0,m,"botTable",0,u,"callMessageTable",0,y,"callTable",0,$,"callThoughtTable",0,b,"configTable",0,I,"mcpServerTable",0,d,"mcpToolTable",0,c,"memoryFactTable",0,x,"memoryNoteTable",0,_,"routineTable",0,k,"threadDeliveryTable",0,v,"threadMessageTable",0,p,"threadRelayTable",0,g,"threadTable",0,f,"threadWorkTable",0,h])},999884,t=>{"use strict";var i=t.i(844988),r=t.i(518899),n=class{static [i.entityKind]="ConsoleLogWriter";write(t){console.log(t)}},a=class{static [i.entityKind]="DefaultLogger";writer;constructor(t){this.writer=t?.writer??new n}logQuery(t,i){let r=i.map(t=>{try{return JSON.stringify(t)}catch{return String(t)}}),n=r.length?` -- params: [${r.join(", ")}]`:"";this.writer.write(`Query: ${t}${n}`)}},o=class{static [i.entityKind]="NoopLogger";logQuery(){}},s=t.i(704313),l=class{static [i.entityKind]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(t){return this.then(void 0,t)}finally(t){return this.then(i=>(t?.(),i),i=>{throw t?.(),i})}then(t,i){return this.execute().then(t,i)}},u=r,d=class t extends u.SQL{static [i.entityKind]="SQLiteCountBuilder";dialect;session;static buildCount(t,i,r){let n=u.sql`select count(*) from ${t}${u.sql` where ${i}`.if(i)}`;return r?u.sql`(${n})`:n}constructor(i){super(t.buildCount(i.source,i.filters,!0).queryChunks),this.countConfig=i,this.dialect=i.dialect,this.session=i.session,this.mapWith(t=>"number"==typeof t?t:Number(t??0))}executableSql;build(){if(!this.executableSql){let{source:i,filters:r}=this.countConfig;this.executableSql=t.buildCount(i,r)}return this.dialect.sqlToQuery(this.executableSql)}},c=class extends d{static [i.entityKind]="SQLiteAsyncCountBuilder";constructor(t){super(t)}executeRaw(t){return this.session.prepareQuery(this.build(),"arrays",!1,"all",t=>{let i=t[0]?.[0];return"number"==typeof i?i:i?Number(i):0}).execute(t)}async execute(t){return await this.executeRaw(t)}};(0,s.applyMixins)(c,[l]);var m=class extends c{static [i.entityKind]="SQLiteSyncCountBuilder";sync(t){return this.executeRaw(t).sync()}},f=class{static [i.entityKind]="SQLiteRelationalQueryBuilderV2";constructor(t,i,r,n,a,o,s,l=p){this.mode=t,this.schema=i,this.table=r,this.tableConfig=n,this.dialect=a,this.session=o,this.forbidJsonb=s,this.builder=l}findMany(t){return new this.builder(this.mode,this.schema,this.table,this.tableConfig,this.dialect,this.session,t??!0,"many",this.forbidJsonb)}findFirst(t){return new this.builder(this.mode,this.schema,this.table,this.tableConfig,this.dialect,this.session,t??!0,"first",this.forbidJsonb)}},p=class{static [i.entityKind]="SQLiteRelationalQueryV2";mode;table;resultKind;constructor(t,i,r,n,a,o,s,l,u){this.schema=i,this.tableConfig=n,this.dialect=a,this.session=o,this.config=s,this.forbidJsonb=u,this.resultKind=t,this.mode=l,this.table=r}getSQL(){return this._getQuery().sql}_getQuery(){let t=this.forbidJsonb?r.sql`json`:r.sql`jsonb`;return this.dialect.buildRelationalQuery({schema:this.schema,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,mode:this.mode,jsonb:t})}_toSQL(){let t=this._getQuery();return{query:t,builtQuery:this.dialect.sqlToQuery(t.sql)}}toSQL(){return this._toSQL().builtQuery}},h=class extends p{static [i.entityKind]="SQLiteAsyncRelationalQueryV2";_prepare(t=!1){let{query:i,builtQuery:r}=this._toSQL(),n=this.dialect.mapperGenerators.relationalRows({isFirst:"first"===this.mode,parseJson:!0,parseJsonIfString:!1,rootJsonMappers:!1,selection:i.selection,arrayModeRoot:!0});return this.session.prepareQuery(r,"arrays",t,"all",n)}prepare(){return this._prepare(!0)}async execute(t){return this._prepare().execute(t)}},v=class extends h{static [i.entityKind]="SQLiteSyncRelationalQueryV2";sync(t){return this._prepare().execute(t).sync()}};(0,s.applyMixins)(h,[l]);var g=t.i(792352),$=t.i(156325),y=t.i(88274),b=t.i(923277),_=t.i(369e3),x=class{static [i.entityKind]="ColumnTableAliasProxyHandler";constructor(t,i){this.table=t,this.ignoreColumnAlias=i}get(t,i){return"table"===i?this.table:("isAlias"!==i||!this.ignoreColumnAlias)&&t[i]}},k=class{static [i.entityKind]="ViewSelectionAliasProxyHandler";constructor(t,i,r){this.view=t,this.selection=i,this.ignoreColumnAlias=r}get(t,n){let a=t[n];return(0,i.is)(a,$.Column)?new Proxy(a,new x(this.view,this.ignoreColumnAlias)):(0,i.is)(a,g.Subquery)||(0,i.is)(a,r.SQL)||(0,i.is)(a,r.SQL.Aliased)||(0,r.isSQLWrapper)(a)||"object"!=typeof a||null===a?a:new Proxy(a,this)}},I=class{static [i.entityKind]="TableAliasProxyHandler";constructor(t,i,r){this.alias=t,this.replaceOriginalName=i,this.ignoreColumnAlias=r}get(t,n){if(n===_.Table.Symbol.IsAlias)return!0;if(n===_.Table.Symbol.Name||this.replaceOriginalName&&n===_.Table.Symbol.OriginalName)return this.alias;if(n===y.ViewBaseConfig)return{...t[y.ViewBaseConfig],name:this.alias,isAlias:!0,selectedFields:new Proxy(t[y.ViewBaseConfig].selectedFields,new k(new Proxy(t,this),t[y.ViewBaseConfig].selectedFields,this.ignoreColumnAlias))};if(n===_.Table.Symbol.Columns){let n=t[_.Table.Symbol.Columns];if(!n)return n;if((0,i.is)(t,r.View))return new Proxy(t[_.Table.Symbol.Columns],new k(new Proxy(t,this),t[_.Table.Symbol.Columns],this.ignoreColumnAlias));let a={};return Object.keys(n).map(i=>{a[i]=new Proxy(n[i],new x(new Proxy(t,this),this.ignoreColumnAlias))}),a}let a=t[n];return(0,i.is)(a,$.Column)?new Proxy(a,new x(new Proxy(t,this),this.ignoreColumnAlias)):a}},w=class{static [i.entityKind]="ColumnAliasProxyHandler";constructor(t){this.alias=t}get(t,i){return"isAlias"===i||("name"===i?this.alias:"keyAsName"!==i&&(i===b.OriginalColumn?()=>t:t[i]))}};function S(t,i){return new Proxy(t,new I(i,!1,!1))}function Z(t){return t[b.OriginalColumn]()}i.entityKind,$.Column.prototype.as=function(t){return new Proxy(this,new w(t))};var z=class t{static [i.entityKind]="SelectionProxyHandler";config;constructor(t){this.config={...t}}get(n,a){if("_"===a)return{...n._,selectedFields:new Proxy(n._.selectedFields,this)};if(a===y.ViewBaseConfig)return{...n[y.ViewBaseConfig],selectedFields:new Proxy(n[y.ViewBaseConfig].selectedFields,this)};if("symbol"==typeof a)return n[a];let o=((0,i.is)(n,g.Subquery)?n._.selectedFields:(0,i.is)(n,r.View)?n[y.ViewBaseConfig].selectedFields:n)[a];if((0,i.is)(o,r.SQL.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!o.isSelectionField)return o.sql;let t=o.clone();return t.isSelectionField=!0,t.origin=this.config.alias,t}if((0,i.is)(o,r.SQL)){if("sql"===this.config.sqlBehavior)return o;throw Error(`You tried to reference "${a}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return(0,i.is)(o,$.Column)?this.config.alias?new Proxy(o,new x(new Proxy(o.table,new I(this.config.alias,this.config.replaceOriginalName??!1,!0)),!0)):o:"object"!=typeof o||null===o?o:new Proxy(o,new t(this.config))}},N=t.i(75799);function D(t){return(0,i.is)(t,N.SQLiteTable)?[`${t[_.Table.Symbol.BaseName]}`]:(0,i.is)(t,g.Subquery)?t._.usedTables??[]:(0,i.is)(t,r.SQL)?t.usedTables??[]:[]}i.entityKind,i.entityKind,t.i(361328),t.i(646683),t.i(201440),t.i(616918);var P=class{static [i.entityKind]="SQLiteDelete";config;constructor(t,i,r,n){this.table=t,this.session=i,this.dialect=r,this.config={table:t,withList:n}}where(t){return this.config.where=t,this}orderBy(...t){if("function"==typeof t[0]){let i=t[0](new Proxy(this.config.table[_.Table.Symbol.Columns],new z({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(i)?i:[i];this.config.orderBy=r}else this.config.orderBy=t;return this}limit(t){return this.config.limit=t,this}returning(t=this.table[N.SQLiteTable.Symbol.Columns]){return this.config.returning=(0,s.orderSelectedFields)(t),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}$dynamic(){return this}},U=class extends P{static [i.entityKind]="SQLiteAsyncDelete";_prepare(t=!1){return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),"arrays",t,this.config.returning?"all":"run",this.config.returning?this.dialect.mapperGenerators.rows(this.config.returning,void 0):void 0,{type:"delete",tables:D(this.config.table)})}prepare(){return this._prepare(!0)}run=t=>this._prepare().run(t);all=t=>this._prepare().all(t);get=t=>this._prepare().get(t);values=t=>this._prepare().values(t);async execute(t){return this._prepare().execute(t)}};(0,s.applyMixins)(U,[l]);var A=r,j=class extends A.View{static [i.entityKind]="SQLiteViewBase"},O=class{static [i.entityKind]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}withoutSelectionCastCodecs(){return this}},T=class{static [i.entityKind]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(t,i=L){this.builder=i,this.fields=t.fields,this.session=t.session,this.dialect=t.dialect,this.withList=t.withList,this.distinct=t.distinct}from(t){let n,a=!!this.fields;return n=this.fields?this.fields:(0,i.is)(t,g.Subquery)?Object.fromEntries(Object.keys(t._.selectedFields).map(i=>[i,t[i]])):(0,i.is)(t,j)?t[y.ViewBaseConfig].selectedFields:(0,i.is)(t,r.SQL)?{}:(0,s.getTableColumns)(t),new this.builder({table:t,fields:n,isPartialSelect:a,session:this.session,dialect:this.dialect,withList:this.withList??[],distinct:this.distinct})}},L=class extends O{static [i.entityKind]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:t,fields:i,isPartialSelect:r,session:n,dialect:a,withList:o,distinct:l}){for(const u of(super(),this.config={withList:o,table:t,fields:{...i},distinct:l,setOperators:[]},this.isPartialSelect=r,this.session=n,this.dialect=a,this._={selectedFields:i,config:this.config},this.tableName=(0,s.getTableLikeName)(t),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{},D(t)))this.usedTables.add(u)}getUsedTables(){return[...this.usedTables]}createJoin(t){return(n,a)=>{let o=this.tableName,l=(0,s.getTableLikeName)(n);for(let t of D(n))this.usedTables.add(t);if("string"==typeof l&&this.config.joins?.some(t=>t.alias===l))throw Error(`Alias "${l}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof o&&(this.config.fields={[o]:this.config.fields}),"string"==typeof l&&!(0,i.is)(n,r.SQL))){let t=(0,i.is)(n,g.Subquery)?n._.selectedFields:(0,i.is)(n,r.View)?n[y.ViewBaseConfig].selectedFields:n[_.Table.Symbol.Columns];this.config.fields[l]=t}if("function"==typeof a&&(a=a(new Proxy(this.config.fields,new z({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:a,table:n,joinType:t,alias:l}),"string"==typeof l)switch(t){case"left":this.joinsNotNullableMap[l]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([t])=>[t,!1])),this.joinsNotNullableMap[l]=!0;break;case"cross":case"inner":this.joinsNotNullableMap[l]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([t])=>[t,!1])),this.joinsNotNullableMap[l]=!1}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(t,i){return r=>{let n="function"==typeof r?r(q()):r;if(!(0,s.haveSameKeys)(this.getSelectedFields(),n.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:t,isAll:i,rightSelect:n}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(t){return this.config.setOperators.push(...t),this}where(t){return"function"==typeof t&&(t=t(new Proxy(this.config.fields,new z({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=t,this}having(t){return"function"==typeof t&&(t=t(new Proxy(this.config.fields,new z({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=t,this}groupBy(...t){if("function"==typeof t[0]){let i=t[0](new Proxy(this.config.fields,new z({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(i)?i:[i]}else this.config.groupBy=t;return this}orderBy(...t){if("function"==typeof t[0]){let i=t[0](new Proxy(this.config.fields,new z({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(i)?i:[i];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=r:this.config.orderBy=r}else this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=t:this.config.orderBy=t;return this}limit(t){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=t:this.config.limit=t,this}offset(t){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=t:this.config.offset=t,this}$withCache(t){return this.cacheConfig=void 0===t?{config:{},enabled:!0,autoInvalidate:!0}:!1===t?{enabled:!1}:{enabled:!0,autoInvalidate:!0,...t},this}getSQL(){return this.config.fieldsFlat=(0,s.orderSelectedFields)(this.config.fields),this.dialect.buildSelectQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}as(t){let i=[];if(i.push(...D(this.config.table)),this.config.joins)for(let t of this.config.joins)i.push(...D(t.table));return new Proxy(new g.Subquery(this.getSQL(),this.config.fields,t,!1,[...new Set(i)]),new z({alias:t,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new z({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}withoutSelectionCastCodecs(){return this}$dynamic(){return this}};function C(t,i){return(r,n,...a)=>{let o=[n,...a].map(r=>({type:t,isAll:i,rightSelect:r}));for(let t of o)if(!(0,s.haveSameKeys)(r.getSelectedFields(),t.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return r.addSetOperators(o)}}let q=()=>({union:E,unionAll:V,intersect:R,except:B}),E=C("union",!1),V=C("union",!0),R=C("intersect",!1),B=C("except",!1);var F=class extends Error{static [i.entityKind]="DrizzleError";constructor({message:t,cause:i}){super(t),this.name="DrizzleError",this.cause=i}},J=class t extends Error{static [i.entityKind]="DrizzleQueryError";constructor(i,r,n){super(`Failed query: ${i}
1
+ module.exports=[528790,t=>t.a(async(i,r)=>{try{let f,p;var n,a=t.i(902157),o=t.i(750227),s=t.i(418520),l=t.i(219756),u=t.i(687388),d=t.i(41444),c=i([s,l]);[s,l]=c.then?(await c)():c,(0,a.mkdirSync)((0,o.dirname)(u.DB_PATH),{recursive:!0});let h=globalThis.__dbClient??=(n=((f=(0,s.createClient)({url:u.DB_FILE_NAME,timeout:5e3})).execute("PRAGMA journal_mode = WAL").finally(m),f),p=(0,d.PromiseChain)(),{get closed(){return n.closed},protocol:n.protocol,close:()=>n.close(),sync:()=>n.sync(),reconnect:()=>n.reconnect(),execute:(...t)=>p(()=>n.execute(...t)),batch:(...t)=>p(()=>n.batch(...t)),executeMultiple:(...t)=>p(()=>n.executeMultiple(...t)),migrate:(...t)=>p(()=>n.migrate(...t)),async transaction(...t){let i,r=await new Promise(t=>{let i,r=new Promise(t=>{i=t});p(async()=>{t(i),await r})});try{i=await n.transaction(...t)}catch(t){throw r(),t}let a=!1,o=()=>{a||(a=!0,r())};return{execute:(...t)=>i.execute(...t),batch:(...t)=>i.batch(...t),executeMultiple:(...t)=>i.executeMultiple(...t),get closed(){return i.closed},commit:()=>i.commit().finally(o),rollback:()=>i.rollback().finally(o),close:()=>{try{i.close()}finally{o()}}}}});function m(){for(let t of[u.DB_PATH,`${u.DB_PATH}-wal`,`${u.DB_PATH}-shm`])try{(0,a.chmodSync)(t,384)}catch{}}let v=(0,l.drizzle)({client:h});t.s(["database",0,v]),r()}catch(t){r(t)}},!1),613240,t=>{"use strict";var i=t.i(518899),r=t.i(646683),n=t.i(201440),a=t.i(616918),o=t.i(937540),s=t.i(380568),l=t.i(75799);let u=(0,l.sqliteTable)("bot",{name:(0,s.text)("name").primaryKey(),description:(0,s.text)("description").notNull(),descriptionLocked:(0,o.int)("description_locked",{mode:"boolean"}).notNull().default(!1),ownLine:(0,s.text)("own_line",{mode:"json"}).$type(),systemPrompt:(0,s.text)("system_prompt"),icon:(0,s.text)("icon",{mode:"json"}).$type(),provider:(0,s.text)("provider").$type(),model:(0,s.text)("model"),compactAt:(0,o.int)("compact_at"),effort:(0,s.text)("effort").$type(),disabled:(0,o.int)("disabled",{mode:"boolean"}).notNull().default(!1),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),d=(0,l.sqliteTable)("mcp_server",{name:(0,s.text)("name").primaryKey(),config:(0,s.text)("config",{mode:"json"}).notNull().$type(),toolsSyncedAt:(0,o.int)("tools_synced_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),lastError:(0,s.text)("last_error"),oauth:(0,s.text)("oauth",{mode:"json"}).$type(),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),c=(0,l.sqliteTable)("mcp_tool",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),serverName:(0,s.text)("server_name").notNull().references(()=>d.name,{onDelete:"cascade"}),name:(0,s.text)("name").notNull(),description:(0,s.text)("description"),inputSchema:(0,s.text)("input_schema",{mode:"json"}).$type(),outputSchema:(0,s.text)("output_schema",{mode:"json"}).$type()},t=>[(0,a.unique)("uq_mcp_tool_server_name").on(t.serverName,t.name)]),m=(0,l.sqliteTable)("bot_mcp_tool",{botName:(0,s.text)().notNull().references(()=>u.name,{onDelete:"cascade"}),toolId:(0,o.int)("tool_id").notNull().references(()=>c.id,{onDelete:"cascade"})},t=>[(0,n.primaryKey)({columns:[t.botName,t.toolId]})]),f=(0,l.sqliteTable)("thread",{id:(0,s.text)("id").primaryKey(),bot:(0,s.text)("bot").notNull(),label:(0,s.text)("label").notNull(),request:(0,s.text)("request").notNull(),status:(0,s.text)("status").notNull().$type(),generation:(0,o.int)("generation").notNull().default(0),turns:(0,o.int)("turns").notNull().default(0),wrapped:(0,o.int)("wrapped",{mode:"boolean"}).notNull().default(!1),outcome:(0,s.text)("outcome"),pending:(0,s.text)("pending",{mode:"json"}).$type(),seen:(0,o.int)("seen",{mode:"boolean"}).notNull().default(!1),callId:(0,s.text)("call_id"),routineId:(0,s.text)("routine_id"),inputTokens:(0,o.int)("input_tokens").notNull().default(0),outputTokens:(0,o.int)("output_tokens").notNull().default(0),cacheReadTokens:(0,o.int)("cache_read_tokens").notNull().default(0),cacheWriteTokens:(0,o.int)("cache_write_tokens").notNull().default(0),contextTokens:(0,o.int)("context_tokens").notNull().default(0),contextBudget:(0,o.int)("context_budget").notNull().default(0),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,o.int)("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),endedAt:(0,o.int)("ended_at",{mode:"timestamp"})},t=>[(0,r.index)("idx_thread_routine").on(t.routineId,t.createdAt),(0,r.index)("idx_thread_status_updated").on(t.status,t.updatedAt)]),p=(0,l.sqliteTable)("thread_message",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),threadId:(0,s.text)("thread_id").notNull().references(()=>f.id,{onDelete:"cascade"}),seq:(0,o.int)("seq").notNull(),bot:(0,s.text)("bot"),parent:(0,s.text)("parent"),hidden:(0,o.int)("hidden",{mode:"boolean"}).notNull().default(!1),role:(0,s.text)("role").notNull().$type(),content:(0,s.text)("content",{mode:"json"}).notNull().$type(),compact:(0,o.int)("compact",{mode:"boolean"}).notNull().default(!1),note:(0,o.int)("note",{mode:"boolean"}).notNull().default(!1),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},t=>[(0,a.unique)("uq_thread_message_seq").on(t.threadId,t.seq)]),h=(0,l.sqliteTable)("thread_work",{id:(0,s.text)("id").primaryKey(),threadId:(0,s.text)("thread_id").notNull().references(()=>f.id,{onDelete:"cascade"}),bot:(0,s.text)("bot").notNull(),caller:(0,s.text)("caller").notNull(),parentId:(0,s.text)("parent_id"),state:(0,s.text)("state").notNull().$type(),generation:(0,o.int)("generation").notNull().default(0),contextBudget:(0,o.int)("context_budget").notNull().default(0),result:(0,s.text)("result"),options:(0,s.text)("options",{mode:"json"}).$type().notNull().default([]),createdAt:(0,o.int)("created_at",{mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},t=>[(0,r.index)("idx_thread_work_queue").on(t.threadId,t.state,t.createdAt),(0,r.index)("idx_thread_work_parent").on(t.parentId),(0,r.uniqueIndex)("uq_thread_work_running_bot").on(t.threadId,t.bot).where(i.sql`${t.state} = 'running'`)]),v=(0,l.sqliteTable)("thread_delivery",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),key:(0,s.text)("key").notNull().unique(),threadId:(0,s.text)("thread_id").notNull().references(()=>f.id,{onDelete:"cascade"}),workId:(0,s.text)("work_id").notNull().references(()=>h.id,{onDelete:"cascade"}),speaker:(0,s.text)("speaker").notNull(),text:(0,s.text)("text").notNull(),visible:(0,o.int)("visible",{mode:"boolean"}).notNull().default(!1),consumed:(0,o.int)("consumed",{mode:"boolean"}).notNull().default(!1)},t=>[(0,r.index)("idx_thread_delivery_inbox").on(t.workId,t.consumed,t.id)]),g=(0,l.sqliteTable)("thread_relay",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),key:(0,s.text)("key").notNull().unique(),threadId:(0,s.text)("thread_id").notNull().references(()=>f.id,{onDelete:"cascade"}),bot:(0,s.text)("bot").notNull(),text:(0,s.text)("text").notNull(),kind:(0,s.text)("kind").notNull().$type(),messageId:(0,s.text)("message_id"),accepted:(0,o.int)("accepted",{mode:"boolean"}).notNull().default(!1)}),$=(0,l.sqliteTable)("call",{id:(0,s.text)("id").primaryKey(),provider:(0,s.text)("provider").notNull(),model:(0,s.text)("model").notNull(),backendModel:(0,s.text)("backend_model"),startedAt:(0,o.int)("started_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),endedReason:(0,s.text)("ended_reason"),seconds:(0,o.int)("seconds"),endedAt:(0,o.int)("ended_at",{mode:"timestamp"})}),y=(0,l.sqliteTable)("call_message",{callId:(0,s.text)("call_id").notNull().references(()=>$.id,{onDelete:"cascade"}),id:(0,s.text)("id").notNull(),seq:(0,o.int)("seq").notNull(),role:(0,s.text)("role").notNull().$type(),tool:(0,s.text)("tool"),text:(0,s.text)("text").notNull(),fragments:(0,s.text)("fragments",{mode:"json"}).$type(),at:(0,o.int)("at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},t=>[(0,n.primaryKey)({columns:[t.callId,t.id]}),(0,r.index)("idx_call_message_call").on(t.callId,t.seq)]),b=(0,l.sqliteTable)("call_thought",{callId:(0,s.text)("call_id").notNull().references(()=>$.id,{onDelete:"cascade"}),id:(0,s.text)("id").notNull(),seq:(0,o.int)("seq").notNull(),text:(0,s.text)("text").notNull(),at:(0,o.int)("at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},t=>[(0,n.primaryKey)({columns:[t.callId,t.id]})]),_=(0,l.sqliteTable)("memory_note",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),path:(0,s.text)("path").notNull().unique(),description:(0,s.text)("description").notNull(),ownedByUser:(0,o.int)("owned_by_user",{mode:"boolean"}).notNull().default(!1),hits:(0,o.int)("hits").notNull().default(0),lastReadAt:(0,o.int)("last_read_at",{mode:"timestamp"}),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,o.int)("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),x=(0,l.sqliteTable)("memory_fact",{id:(0,o.int)("id").primaryKey({autoIncrement:!0}),noteId:(0,o.int)("note_id").notNull().references(()=>_.id,{onDelete:"cascade"}),text:(0,s.text)("text").notNull(),isLatest:(0,o.int)("is_latest",{mode:"boolean"}).notNull().default(!0),source:(0,s.text)("source").$type(),callId:(0,s.text)("call_id").references(()=>$.id,{onDelete:"set null"}),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},t=>[(0,r.index)("idx_memory_fact_note").on(t.noteId,t.isLatest),(0,r.index)("idx_memory_fact_call").on(t.callId)]),k=(0,l.sqliteTable)("routine",{id:(0,s.text)("id").primaryKey(),bot:(0,s.text)("bot").notNull(),label:(0,s.text)("label").notNull(),request:(0,s.text)("request").notNull(),schedule:(0,s.text)("schedule",{mode:"json"}).notNull().$type(),enabled:(0,o.int)("enabled",{mode:"boolean"}).notNull().default(!0),nextRunAt:(0,o.int)("next_run_at",{mode:"timestamp"}).notNull(),createdAt:(0,o.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},t=>[(0,r.index)("idx_routine_due").on(t.enabled,t.nextRunAt)]),I=(0,l.sqliteTable)("config",{key:(0,s.text)("key").primaryKey(),value:(0,s.text)("value").notNull()});t.s(["botMcpToolTable",0,m,"botTable",0,u,"callMessageTable",0,y,"callTable",0,$,"callThoughtTable",0,b,"configTable",0,I,"mcpServerTable",0,d,"mcpToolTable",0,c,"memoryFactTable",0,x,"memoryNoteTable",0,_,"routineTable",0,k,"threadDeliveryTable",0,v,"threadMessageTable",0,p,"threadRelayTable",0,g,"threadTable",0,f,"threadWorkTable",0,h])},999884,t=>{"use strict";var i=t.i(844988),r=t.i(518899),n=class{static [i.entityKind]="ConsoleLogWriter";write(t){console.log(t)}},a=class{static [i.entityKind]="DefaultLogger";writer;constructor(t){this.writer=t?.writer??new n}logQuery(t,i){let r=i.map(t=>{try{return JSON.stringify(t)}catch{return String(t)}}),n=r.length?` -- params: [${r.join(", ")}]`:"";this.writer.write(`Query: ${t}${n}`)}},o=class{static [i.entityKind]="NoopLogger";logQuery(){}},s=t.i(704313),l=class{static [i.entityKind]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(t){return this.then(void 0,t)}finally(t){return this.then(i=>(t?.(),i),i=>{throw t?.(),i})}then(t,i){return this.execute().then(t,i)}},u=r,d=class t extends u.SQL{static [i.entityKind]="SQLiteCountBuilder";dialect;session;static buildCount(t,i,r){let n=u.sql`select count(*) from ${t}${u.sql` where ${i}`.if(i)}`;return r?u.sql`(${n})`:n}constructor(i){super(t.buildCount(i.source,i.filters,!0).queryChunks),this.countConfig=i,this.dialect=i.dialect,this.session=i.session,this.mapWith(t=>"number"==typeof t?t:Number(t??0))}executableSql;build(){if(!this.executableSql){let{source:i,filters:r}=this.countConfig;this.executableSql=t.buildCount(i,r)}return this.dialect.sqlToQuery(this.executableSql)}},c=class extends d{static [i.entityKind]="SQLiteAsyncCountBuilder";constructor(t){super(t)}executeRaw(t){return this.session.prepareQuery(this.build(),"arrays",!1,"all",t=>{let i=t[0]?.[0];return"number"==typeof i?i:i?Number(i):0}).execute(t)}async execute(t){return await this.executeRaw(t)}};(0,s.applyMixins)(c,[l]);var m=class extends c{static [i.entityKind]="SQLiteSyncCountBuilder";sync(t){return this.executeRaw(t).sync()}},f=class{static [i.entityKind]="SQLiteRelationalQueryBuilderV2";constructor(t,i,r,n,a,o,s,l=p){this.mode=t,this.schema=i,this.table=r,this.tableConfig=n,this.dialect=a,this.session=o,this.forbidJsonb=s,this.builder=l}findMany(t){return new this.builder(this.mode,this.schema,this.table,this.tableConfig,this.dialect,this.session,t??!0,"many",this.forbidJsonb)}findFirst(t){return new this.builder(this.mode,this.schema,this.table,this.tableConfig,this.dialect,this.session,t??!0,"first",this.forbidJsonb)}},p=class{static [i.entityKind]="SQLiteRelationalQueryV2";mode;table;resultKind;constructor(t,i,r,n,a,o,s,l,u){this.schema=i,this.tableConfig=n,this.dialect=a,this.session=o,this.config=s,this.forbidJsonb=u,this.resultKind=t,this.mode=l,this.table=r}getSQL(){return this._getQuery().sql}_getQuery(){let t=this.forbidJsonb?r.sql`json`:r.sql`jsonb`;return this.dialect.buildRelationalQuery({schema:this.schema,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,mode:this.mode,jsonb:t})}_toSQL(){let t=this._getQuery();return{query:t,builtQuery:this.dialect.sqlToQuery(t.sql)}}toSQL(){return this._toSQL().builtQuery}},h=class extends p{static [i.entityKind]="SQLiteAsyncRelationalQueryV2";_prepare(t=!1){let{query:i,builtQuery:r}=this._toSQL(),n=this.dialect.mapperGenerators.relationalRows({isFirst:"first"===this.mode,parseJson:!0,parseJsonIfString:!1,rootJsonMappers:!1,selection:i.selection,arrayModeRoot:!0});return this.session.prepareQuery(r,"arrays",t,"all",n)}prepare(){return this._prepare(!0)}async execute(t){return this._prepare().execute(t)}},v=class extends h{static [i.entityKind]="SQLiteSyncRelationalQueryV2";sync(t){return this._prepare().execute(t).sync()}};(0,s.applyMixins)(h,[l]);var g=t.i(792352),$=t.i(156325),y=t.i(88274),b=t.i(923277),_=t.i(369e3),x=class{static [i.entityKind]="ColumnTableAliasProxyHandler";constructor(t,i){this.table=t,this.ignoreColumnAlias=i}get(t,i){return"table"===i?this.table:("isAlias"!==i||!this.ignoreColumnAlias)&&t[i]}},k=class{static [i.entityKind]="ViewSelectionAliasProxyHandler";constructor(t,i,r){this.view=t,this.selection=i,this.ignoreColumnAlias=r}get(t,n){let a=t[n];return(0,i.is)(a,$.Column)?new Proxy(a,new x(this.view,this.ignoreColumnAlias)):(0,i.is)(a,g.Subquery)||(0,i.is)(a,r.SQL)||(0,i.is)(a,r.SQL.Aliased)||(0,r.isSQLWrapper)(a)||"object"!=typeof a||null===a?a:new Proxy(a,this)}},I=class{static [i.entityKind]="TableAliasProxyHandler";constructor(t,i,r){this.alias=t,this.replaceOriginalName=i,this.ignoreColumnAlias=r}get(t,n){if(n===_.Table.Symbol.IsAlias)return!0;if(n===_.Table.Symbol.Name||this.replaceOriginalName&&n===_.Table.Symbol.OriginalName)return this.alias;if(n===y.ViewBaseConfig)return{...t[y.ViewBaseConfig],name:this.alias,isAlias:!0,selectedFields:new Proxy(t[y.ViewBaseConfig].selectedFields,new k(new Proxy(t,this),t[y.ViewBaseConfig].selectedFields,this.ignoreColumnAlias))};if(n===_.Table.Symbol.Columns){let n=t[_.Table.Symbol.Columns];if(!n)return n;if((0,i.is)(t,r.View))return new Proxy(t[_.Table.Symbol.Columns],new k(new Proxy(t,this),t[_.Table.Symbol.Columns],this.ignoreColumnAlias));let a={};return Object.keys(n).map(i=>{a[i]=new Proxy(n[i],new x(new Proxy(t,this),this.ignoreColumnAlias))}),a}let a=t[n];return(0,i.is)(a,$.Column)?new Proxy(a,new x(new Proxy(t,this),this.ignoreColumnAlias)):a}},w=class{static [i.entityKind]="ColumnAliasProxyHandler";constructor(t){this.alias=t}get(t,i){return"isAlias"===i||("name"===i?this.alias:"keyAsName"!==i&&(i===b.OriginalColumn?()=>t:t[i]))}};function S(t,i){return new Proxy(t,new I(i,!1,!1))}function Z(t){return t[b.OriginalColumn]()}i.entityKind,$.Column.prototype.as=function(t){return new Proxy(this,new w(t))};var z=class t{static [i.entityKind]="SelectionProxyHandler";config;constructor(t){this.config={...t}}get(n,a){if("_"===a)return{...n._,selectedFields:new Proxy(n._.selectedFields,this)};if(a===y.ViewBaseConfig)return{...n[y.ViewBaseConfig],selectedFields:new Proxy(n[y.ViewBaseConfig].selectedFields,this)};if("symbol"==typeof a)return n[a];let o=((0,i.is)(n,g.Subquery)?n._.selectedFields:(0,i.is)(n,r.View)?n[y.ViewBaseConfig].selectedFields:n)[a];if((0,i.is)(o,r.SQL.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!o.isSelectionField)return o.sql;let t=o.clone();return t.isSelectionField=!0,t.origin=this.config.alias,t}if((0,i.is)(o,r.SQL)){if("sql"===this.config.sqlBehavior)return o;throw Error(`You tried to reference "${a}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return(0,i.is)(o,$.Column)?this.config.alias?new Proxy(o,new x(new Proxy(o.table,new I(this.config.alias,this.config.replaceOriginalName??!1,!0)),!0)):o:"object"!=typeof o||null===o?o:new Proxy(o,new t(this.config))}},N=t.i(75799);function D(t){return(0,i.is)(t,N.SQLiteTable)?[`${t[_.Table.Symbol.BaseName]}`]:(0,i.is)(t,g.Subquery)?t._.usedTables??[]:(0,i.is)(t,r.SQL)?t.usedTables??[]:[]}i.entityKind,i.entityKind,t.i(361328),t.i(646683),t.i(201440),t.i(616918);var P=class{static [i.entityKind]="SQLiteDelete";config;constructor(t,i,r,n){this.table=t,this.session=i,this.dialect=r,this.config={table:t,withList:n}}where(t){return this.config.where=t,this}orderBy(...t){if("function"==typeof t[0]){let i=t[0](new Proxy(this.config.table[_.Table.Symbol.Columns],new z({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(i)?i:[i];this.config.orderBy=r}else this.config.orderBy=t;return this}limit(t){return this.config.limit=t,this}returning(t=this.table[N.SQLiteTable.Symbol.Columns]){return this.config.returning=(0,s.orderSelectedFields)(t),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}$dynamic(){return this}},U=class extends P{static [i.entityKind]="SQLiteAsyncDelete";_prepare(t=!1){return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),"arrays",t,this.config.returning?"all":"run",this.config.returning?this.dialect.mapperGenerators.rows(this.config.returning,void 0):void 0,{type:"delete",tables:D(this.config.table)})}prepare(){return this._prepare(!0)}run=t=>this._prepare().run(t);all=t=>this._prepare().all(t);get=t=>this._prepare().get(t);values=t=>this._prepare().values(t);async execute(t){return this._prepare().execute(t)}};(0,s.applyMixins)(U,[l]);var A=r,j=class extends A.View{static [i.entityKind]="SQLiteViewBase"},O=class{static [i.entityKind]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}withoutSelectionCastCodecs(){return this}},T=class{static [i.entityKind]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(t,i=L){this.builder=i,this.fields=t.fields,this.session=t.session,this.dialect=t.dialect,this.withList=t.withList,this.distinct=t.distinct}from(t){let n,a=!!this.fields;return n=this.fields?this.fields:(0,i.is)(t,g.Subquery)?Object.fromEntries(Object.keys(t._.selectedFields).map(i=>[i,t[i]])):(0,i.is)(t,j)?t[y.ViewBaseConfig].selectedFields:(0,i.is)(t,r.SQL)?{}:(0,s.getTableColumns)(t),new this.builder({table:t,fields:n,isPartialSelect:a,session:this.session,dialect:this.dialect,withList:this.withList??[],distinct:this.distinct})}},L=class extends O{static [i.entityKind]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:t,fields:i,isPartialSelect:r,session:n,dialect:a,withList:o,distinct:l}){for(const u of(super(),this.config={withList:o,table:t,fields:{...i},distinct:l,setOperators:[]},this.isPartialSelect=r,this.session=n,this.dialect=a,this._={selectedFields:i,config:this.config},this.tableName=(0,s.getTableLikeName)(t),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{},D(t)))this.usedTables.add(u)}getUsedTables(){return[...this.usedTables]}createJoin(t){return(n,a)=>{let o=this.tableName,l=(0,s.getTableLikeName)(n);for(let t of D(n))this.usedTables.add(t);if("string"==typeof l&&this.config.joins?.some(t=>t.alias===l))throw Error(`Alias "${l}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof o&&(this.config.fields={[o]:this.config.fields}),"string"==typeof l&&!(0,i.is)(n,r.SQL))){let t=(0,i.is)(n,g.Subquery)?n._.selectedFields:(0,i.is)(n,r.View)?n[y.ViewBaseConfig].selectedFields:n[_.Table.Symbol.Columns];this.config.fields[l]=t}if("function"==typeof a&&(a=a(new Proxy(this.config.fields,new z({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:a,table:n,joinType:t,alias:l}),"string"==typeof l)switch(t){case"left":this.joinsNotNullableMap[l]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([t])=>[t,!1])),this.joinsNotNullableMap[l]=!0;break;case"cross":case"inner":this.joinsNotNullableMap[l]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([t])=>[t,!1])),this.joinsNotNullableMap[l]=!1}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(t,i){return r=>{let n="function"==typeof r?r(q()):r;if(!(0,s.haveSameKeys)(this.getSelectedFields(),n.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:t,isAll:i,rightSelect:n}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(t){return this.config.setOperators.push(...t),this}where(t){return"function"==typeof t&&(t=t(new Proxy(this.config.fields,new z({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=t,this}having(t){return"function"==typeof t&&(t=t(new Proxy(this.config.fields,new z({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=t,this}groupBy(...t){if("function"==typeof t[0]){let i=t[0](new Proxy(this.config.fields,new z({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(i)?i:[i]}else this.config.groupBy=t;return this}orderBy(...t){if("function"==typeof t[0]){let i=t[0](new Proxy(this.config.fields,new z({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(i)?i:[i];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=r:this.config.orderBy=r}else this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=t:this.config.orderBy=t;return this}limit(t){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=t:this.config.limit=t,this}offset(t){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=t:this.config.offset=t,this}$withCache(t){return this.cacheConfig=void 0===t?{config:{},enabled:!0,autoInvalidate:!0}:!1===t?{enabled:!1}:{enabled:!0,autoInvalidate:!0,...t},this}getSQL(){return this.config.fieldsFlat=(0,s.orderSelectedFields)(this.config.fields),this.dialect.buildSelectQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}as(t){let i=[];if(i.push(...D(this.config.table)),this.config.joins)for(let t of this.config.joins)i.push(...D(t.table));return new Proxy(new g.Subquery(this.getSQL(),this.config.fields,t,!1,[...new Set(i)]),new z({alias:t,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new z({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}withoutSelectionCastCodecs(){return this}$dynamic(){return this}};function C(t,i){return(r,n,...a)=>{let o=[n,...a].map(r=>({type:t,isAll:i,rightSelect:r}));for(let t of o)if(!(0,s.haveSameKeys)(r.getSelectedFields(),t.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return r.addSetOperators(o)}}let q=()=>({union:E,unionAll:V,intersect:R,except:B}),E=C("union",!1),V=C("union",!0),R=C("intersect",!1),B=C("except",!1);var F=class extends Error{static [i.entityKind]="DrizzleError";constructor({message:t,cause:i}){super(t),this.name="DrizzleError",this.cause=i}},J=class t extends Error{static [i.entityKind]="DrizzleQueryError";constructor(i,r,n){super(`Failed query: ${i}
2
2
  params: ${r}`),this.query=i,this.params=r,this.cause=n,this.name="DrizzleQueryError",Error.captureStackTrace(this,t),n&&(this.cause=n)}},Q=class extends F{static [i.entityKind]="TransactionRollbackError";constructor(){super({message:"Rollback"}),this.name="TransactionRollbackError"}},M=t.i(875225),K=t.i(349129),W=class{static [i.entityKind]="RelationV2";fieldName;sourceColumns;targetColumns;alias;where;sourceTable;targetTable;through;throughTable;isReversed;sourceColumnTableNames=[];targetColumnTableNames=[];constructor(t,i){this.targetTableName=i,this.targetTable=t}},G=class extends W{static [i.entityKind]="OneV2";relationType="one";optional;constructor(t,i,r,n){super(i,r),this.alias=n?.alias,this.where=n?.where,n?.from&&(this.sourceColumns=(Array.isArray(n.from)?n.from:[n.from]).map(i=>(this.throughTable??=i._.through?t[i._.through._.tableName]:void 0,this.sourceColumnTableNames.push(i._.tableName),i._.column))),n?.to&&(this.targetColumns=(Array.isArray(n.to)?n.to:[n.to]).map(i=>(this.throughTable??=i._.through?t[i._.through._.tableName]:void 0,this.targetColumnTableNames.push(i._.tableName),i._.column))),this.throughTable&&(this.through={source:(Array.isArray(n?.from)?n.from:n?.from?[n.from]:[]).map(t=>t._.through),target:(Array.isArray(n?.to)?n.to:n?.to?[n.to]:[]).map(t=>t._.through)}),this.optional=n?.optional??!0}},X=(i.entityKind,class{static [i.entityKind]="AggregatedField";table;onTable(t){return this.table=t,this}});i.entityKind;let H={and:M.and,between:M.between,eq:M.eq,exists:M.exists,gt:M.gt,gte:M.gte,ilike:M.ilike,inArray:M.inArray,arrayContains:M.arrayContains,arrayContained:M.arrayContained,arrayOverlaps:M.arrayOverlaps,isNull:M.isNull,isNotNull:M.isNotNull,like:M.like,lt:M.lt,lte:M.lte,ne:M.ne,not:M.not,notBetween:M.notBetween,notExists:M.notExists,notLike:M.notLike,notIlike:M.notIlike,notInArray:M.notInArray,or:M.or,sql:r.sql},Y={sql:r.sql,asc:K.asc,desc:K.desc};function ee(t,n,a,o=!1,s=!1,l=!0){let u=n?1:t.length,d=a.map(({field:t,codec:n,arrayDimensions:a})=>{let o;return(o=(0,i.is)(t,$.Column)?t:(0,i.is)(t,r.SQL)?t.decoder:(0,i.is)(t,r.SQL.Aliased)?t.sql.decoder:(0,i.is)(t,_.Table)||(0,i.is)(t,r.View)?r.noopDecoder:t.getSQL().decoder,l&&t.mapFromJsonValue)?i=>t.mapFromJsonValue(i):o.mapFromDriverValue.isNoop?n?t=>n(t,a):void 0:n?t=>o.mapFromDriverValue(n(t,a)):t=>o.mapFromDriverValue(t)});for(let i=0;i<u;++i){let r=n?t:t[i];for(let t=0;t<a.length;++t){let i=a[t];if(i.selection){if(null===r[i.key])continue;if(o){if(r[i.key]=JSON.parse(r[i.key]),null===r[i.key])continue}else s&&"string"==typeof r[i.key]&&(r[i.key]=JSON.parse(r[i.key]));if(i.isArray){ee(r[i.key],!1,i.selection,!1,s);continue}ee(r[i.key],!0,i.selection,!1,s);continue}if(null===r[i.key])continue;let n=d[t];n&&(r[i.key]=n(r[i.key]))}}return t}function et({selection:t,isFirst:n,parseJson:a,parseJsonIfString:o,rootJsonMappers:s,arrayModeRoot:l}){return u=>n&&!u[0]?u[0]:l?function(t,n,a,o=!1,s=!1){let l=n?1:t.length,u=a.map(({field:t,codec:n,arrayDimensions:a})=>{let o;return(o=(0,i.is)(t,$.Column)?t:(0,i.is)(t,r.SQL)?t.decoder:(0,i.is)(t,r.SQL.Aliased)?t.sql.decoder:(0,i.is)(t,_.Table)||(0,i.is)(t,r.View)?r.noopDecoder:t.getSQL().decoder).mapFromDriverValue.isNoop?n?t=>n(t,a):void 0:n?t=>o.mapFromDriverValue(n(t,a)):t=>o.mapFromDriverValue(t)}),d=Array.from({length:l});for(let i=0;i<l;++i){let r=n?t:t[i],l={};for(let t=0;t<a.length;++t){let i=a[t],n=r[t];if(i.selection){if(null===n){l[i.key]=null;continue}if(o){if(null===(n=JSON.parse(n))){l[i.key]=null;continue}}else s&&"string"==typeof n&&(n=JSON.parse(n));i.isArray?ee(n,!1,i.selection,!1,s):ee(n,!0,i.selection,!1,s),l[i.key]=n;continue}if(null===n){l[i.key]=null;continue}let d=u[t];l[i.key]=d?d(n):n}d[i]=l}return n?d[0]:d}(n?u[0]:u,n,t,a,o):ee(n?u[0]:u,n,t,a,o,s)}function ei({selection:t,isFirst:n,parseJson:a,parseJsonIfString:o,rootJsonMappers:l,arrayModeRoot:u}){let d=[],c=function t(n,a,o,s,l,u,d,c,m){let f=[],p=[],h=!1,v=n.map(()=>`c${c.n++}`),g=n.map((t,i)=>m?v[i]:`${JSON.stringify(t.key)}: ${v[i]}`);for(let[y,{field:b,key:x,codec:k,isArray:I,selection:w,arrayDimensions:S}]of(f.push(m?`let [ ${g.join(", ")} ] = ${a};`:`let { ${g.join(", ")} } = ${a};`),n.entries())){let n=`${o}[${y}]`,a=JSON.stringify(x),m=v[y];if(w){s?(f.push(`if (${m} !== null) ${m} = JSON.parse(${m});`),h=!0):l&&(f.push(`if (typeof ${m} === 'string') ${m} = JSON.parse(${m});`),h=!0);let i=`s${c.n++}`,r=d.length;if(d.push(`const { selection: ${i} } = ${n};`),I){let n=`j${c.n++}`,a=t(w,`${m}[${n}]`,i,!1,l,!0,d,c,!1);if(a.hasWork){for(let t of(h=!0,f.push(`if (${m} !== null) {`),f.push(` for (let ${n} = 0; ${n} < ${m}.length; ++${n}) {`),a.bodyStmts))f.push(` ${t}`);f.push(` ${m}[${n}] = ${a.literal};`),f.push(" }"),f.push("}")}else d.splice(r,1)}else{let n=t(w,m,i,!1,l,!0,d,c,!1);if(n.hasWork){for(let t of(h=!0,f.push(`if (${m} !== null) {`),n.bodyStmts))f.push(` ${t}`);f.push(` ${m} = ${n.literal};`),f.push("}")}else d.splice(r,1)}p.push(`${a}: ${m}`);continue}let g="",Z="",z=!1;if((0,i.is)(b,$.Column)){if(u&&b.mapFromJsonValue){z=!0;let t=c.n++;Z=`field: dec${t}`,g=`dec${t}.mapFromJsonValue`}else if(!b.mapFromDriverValue.isNoop){let t=c.n++;Z=`field: dec${t}`,g=`dec${t}.mapFromDriverValue`}}else if((0,i.is)(b,r.SQL)){if(u&&b.decoder.mapFromJsonValue){z=!0;let t=c.n++;Z=`field: { decoder: dec${t} }`,g=`dec${t}.mapFromJsonValue`}else if(!b.decoder.mapFromDriverValue.isNoop){let t=c.n++;Z=`field: { decoder: dec${t} }`,g=`dec${t}.mapFromDriverValue`}}else if((0,i.is)(b,r.SQL.Aliased)){if(u&&b.sql.decoder.mapFromJsonValue){z=!0;let t=c.n++;Z=`field: { sql: { decoder: dec${t} } }`,g=`dec${t}.mapFromJsonValue`}else if(!b.sql.decoder.mapFromDriverValue.isNoop){let t=c.n++;Z=`field: { sql: { decoder: dec${t} } }`,g=`dec${t}.mapFromDriverValue`}}else if((0,i.is)(b,_.Table)||(0,i.is)(b,r.View));else{let t=b.getSQL();if(u&&t.decoder.mapFromJsonValue){z=!0;let t=c.n++;d.push(`const dec${t} = ${n}.field.getSQL().decoder;`),g=`dec${t}.mapFromJsonValue`}else if(!t.decoder.mapFromDriverValue.isNoop){let t=c.n++;d.push(`const dec${t} = ${n}.field.getSQL().decoder;`),g=`dec${t}.mapFromDriverValue`}}let N="";if(!z&&k&&(N=`codec${c.n++}`),Z||N){let t=[];Z&&t.push(Z),N&&t.push(`codec: ${N}`),d.push(`const { ${t.join(", ")} } = ${n};`)}if(g||N){h=!0;let t=m;N&&(t=`${N}(${t}, ${S})`),g&&(t=`${g}(${t})`),p.push(`${a}: ${m} === null ? null : ${t}`)}else p.push(`${a}: ${m}`)}return{bodyStmts:f,literal:`{ ${p.join(", ")} }`,hasWork:h}}(t,"row","selection",a,o,!u&&l,d,{n:0},!!u),m=[];for(let t of(m.push(` "use strict";
3
3
  const { selection } = this;`),d))m.push(` ${t}`);if(u)if(n){for(let t of(m.push(" const row = rows[0];"),m.push(" if (!row) return undefined;"),c.bodyStmts))m.push(` ${t}`);m.push(` return ${c.literal};`)}else{for(let t of(m.push(" const { length } = rows;"),m.push(" const mapped = Array.from({ length });"),m.push(" for (let i = 0; i < length; ++i) {"),m.push(" const row = rows[i];"),c.bodyStmts))m.push(` ${t}`);m.push(` mapped[i] = ${c.literal};`),m.push(" }"),m.push(" return mapped;")}else if(c.hasWork)if(n){for(let t of(m.push(" const row = rows[0];"),m.push(" if (!row) return undefined;"),c.bodyStmts))m.push(` ${t}`);m.push(` rows[0] = ${c.literal};`),m.push(" return rows[0];")}else{for(let t of(m.push(" for (let i = 0; i < rows.length; ++i) {"),m.push(" const row = rows[i];"),c.bodyStmts))m.push(` ${t}`);m.push(` rows[i] = ${c.literal};`),m.push(" }"),m.push(" return rows;")}else m.push(n?" return rows[0];":" return rows;");m.push(" //# sourceURL=drizzle:jit-relational-query-mapper");let f=m.join("\n");return Object.assign(new s.FnConstructor("rows",f).bind({selection:t}),{body:`function jitRqbMapper (rows) {
4
4
  ${f}
@@ -0,0 +1,5 @@
1
+ module.exports=[380690,e=>{"use strict";let t,n,r,a,i,o;var s,l=e.i(687388),u=e.i(640911);let c={threads:!0,bots:!0,routines:!0,memory:!0,mcp:!0,config:!0,reach:!0,signins:!0,files:!0},d=globalThis,m=d.__appEvents??=(t=new Set,{emit(e){for(let n of[...t])try{n(e)}catch(e){console.error("event listener failed",e)}},subscribe:e=>(t.add(e),()=>{t.delete(e)})}),h=d.__presence??=(s=l.BROWSER_GONE_MS,n=!1,r=null,a=new Set,i=new Set,o=e=>{for(let t of[...e])try{t()}catch(e){console.error("presence listener failed",e)}},{get watching(){return n},track(e){if(e>0){r&&clearTimeout(r),r=null,n||(n=!0,o(i));return}!r&&n&&(r=setTimeout(()=>{r=null,n=!1,o(a)},s))},onGone:e=>(a.add(e),()=>a.delete(e)),onBack:e=>(i.add(e),()=>i.delete(e))}),f=d.__appEventStream??=function(e,t={}){let n=new TextEncoder,r=t.heartbeatMs??2e4,a=0;return{respond:(i,o)=>{let s=()=>{};return new Response(new ReadableStream({async start(l){let c=!1,d=new Map,m=[],h=e=>{if(!c)try{l.enqueue(n.encode(e))}catch{s()}},f=e=>h(`data: ${JSON.stringify(e)}
2
+
3
+ `),p=e=>{let n={last:null},r=setTimeout(()=>{d.delete(e),!c&&n.last&&(f(n.last),p(e))},t.coalesce?.ms);d.set(e,{timer:r,wait:n})},g=e=>{if(c)return;let n=t.coalesce?.keyOf(e)??null;if(null===n)return f(e);let r=d.get(n);if(r){r.wait.last=e;return}f(e),p(n)},M=e.subscribe(e=>m?m.push(e):g(e)),y=setInterval(()=>h(": ping\n\n"),r);a+=1,t.onWatchers?.(a),s=()=>{if(!c){for(let e of(c=!0,a-=1,t.onWatchers?.(a),M(),clearInterval(y),d.values()))clearTimeout(e.timer);try{l.close()}catch{}}},i.addEventListener("abort",s);try{for(let e of await o?.()??[])f(e)}catch(e){u.logger.error("event stream opening failed",e),s();return}let _=m;for(let e of(m=null,_))g(e)},cancel(){s()}}),{headers:{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-store","X-Accel-Buffering":"no"}})},get watchers(){return a}}}(m,{coalesce:{ms:l.SIGNAL_PACE_MS,keyOf:e=>e.type in c?e.type:null},onWatchers:h.track});e.s(["appEventStream",0,f,"appEvents",0,m,"presence",0,h],380690)},687388,e=>{"use strict";let t=process.env.THURSDAY_APP_DIR?.trim()||process.cwd(),n=process.env.THURSDAY_HOME?.trim()||process.cwd(),r=process.env.THURSDAY_URL?.trim()||`http://localhost:${process.env.PORT?.trim()||3e3}`,a=`${n}/local.db`,i=`file:${a}`,o=".ai-workspace",s={workspace:o,artifacts:"artifacts",projects:"projects",scratch:"scratch",bots:"bots",output:".output",signIns:".sign-ins",skills:{default:"skills",custom:`${o}/.agents/skills`,own:".agents/skills",runtime:"runtime",seeds:"seed-skills"}},l="artifact";e.s(["APP_DIR",0,t,"APP_NAME",0,"Thursday","APP_URL",0,r,"ARTIFACT_SKILL",0,l,"ARTIFACT_VIEW",0,{rows:200,setFiles:120},"BOT_MEMORY_LIMITS",0,{files:20,chars:1e4},"BOT_RUN",0,{steps:100,compactAt:5e5,compactHeadroom:.8,summaryWords:{min:600,max:3e3,perTokens:200},participants:12,concurrent:4,turns:120,queuedMessages:200,silenceMs:3e5,overflowShrink:.6,retryMs:1e4,compactFiles:40},"BOT_WORK",0,{open:5,recent:5,said:80,files:2,reads:2,asked:400,readChars:4e3},"BROWSER_CLI",0,{readMs:15e3,loadMs:3e4},"BROWSER_GONE_MS",0,1e4,"BROWSER_VIEWPORT",0,"700x700","CALL_EXEC_TIMEOUT_MS",0,15e3,"CALL_HISTORY_PAGE",0,10,"CALL_RELAY",0,{quietMs:2e3,perTurn:3,readMs:15e3,chars:600},"CHATGPT_SIGN_IN",0,{waitMs:6e5,renewBeforeMs:3e5},"CHATGPT_USAGE_HIGH",0,80,"COMMON_VALIDATE",0,{name:{max:16},shortDescription:{max:60},description:{max:100},prompt:{max:4e3}},"CONNECTED_TOOL_TIMEOUT_MS",0,6e5,"DATA_DIR",0,n,"DB_FILE_NAME",0,i,"DB_PATH",0,a,"DECK",0,{slides:30,shotsMs:9e4},"EXEC_KILL_GRACE_MS",0,5e3,"EXEC_TIMEOUT_MS",0,18e4,"FAVICON",0,{timeoutMs:4e3,maxBytes:3e5,kept:500,pageBytes:65536},"FINISHED_NOTICE",0,{rows:5,shown:1,words:240},"FULL_RESULT_LINES",0,400,"GATEWAY_CATALOG_MS",0,6e5,"GATEWAY_LOW_CREDIT",0,1,"INBOX_FINISHED",0,5,"IS_DEV",0,!1,"JOB_FOLDER_WALK",0,500,"LIVE_CALL",0,{startupMs:3e4,closeMs:15e3,transcriptGapMs:1500,transcriptSaveMs:500,appendMs:15e3,backendOutputTokens:4096,reasoningCheckMs:5e3,keyCheckMs:5e3,openingHoldMs:3e3},"LOOK",0,{maxBytes:4194304},"MARKETING_SKILL",0,"marketing","MAX_PINNED_TOOLS",0,10,"MCP_IDLE_MS",0,18e5,"MEMORY_EDIT",0,{maxSteps:20},"MEMORY_LIMITS",0,{facts:400,factsPerNote:50,descriptionChars:100},"PAGE_SIZE",0,50,"PATHS",0,s,"PROMPT_BUDGET",0,6e3,"PROMPT_LINE",0,{skill:90,toolArgs:30,jobOutcome:160,botMemory:100,threadStatus:200,routineRequest:300,routineOutcome:200},"REACH",0,{pollSeconds:50,retryMs:5e3,idleMs:6e5,messages:40,trimTo:30,oldChars:1e3,files:3,fileBytes:0x2d00000,rateRetries:3,rateWaitMs:3e4,codeDigits:4,held:5,pictures:9,drawMs:6e4,lookMs:2e3},"RECENT_CALL",0,{rows:20,tokens:600},"ROUTINE",0,{tickMs:3e4,max:12,minHours:1,runsShown:5},"SEARCH",0,{sources:3,excerptChars:1200,timeoutMs:3e4},"SIGNAL_PACE_MS",0,150,"SKILLS_FOLDED",0,{design:l,"picture-book":l,"interactive-page":l},"SKILL_FILES",0,{uploadBytes:0x1400000,inlineBytes:524288,unpackedBytes:0x6400000,archiveEntries:1e3},"SKILL_FILES_LISTED",0,50,"STUDIO_SERVER",0,"studio","TEXT_CALL",0,{maxSteps:12,model:"text",autoTurns:10},"THREAD_LABEL_REACH",0,20,"THREAD_STATUS_LIMIT",0,10,"TOOL_OUTPUT",0,{max:8e3,head:5500,tail:1500},"TOOL_SEARCH_SCHEMAS",0,8,"TRAVEL_SKILL",0,"travel","WORKSPACE_KEEP",0,{forMs:2592e5,sweepEveryMs:36e5},"WORKSPACE_VIEW",0,{rows:200,textMax:524288,autoCloseMs:5e3,elementMax:0x3200000}])},41444,e=>{"use strict";function t(e,t){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n}let n=/\[([^\]\n]+)\]\(([^)\s]+)\)/g;e.s(["MARKDOWN_LINK",0,n,"PromiseChain",0,()=>{let e=Promise.resolve();return t=>{let n=e.then(()=>t());return e=n.catch(()=>{}),n}},"captionText",0,function(e){let t=[],r=e.replace(/```[\s\S]*?```/g," ").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(n,(e,n,r)=>(t.push(`[${n.replace(/[*_`]/g,"")}](${r})`),`\uE000${t.length-1}\uE000`)),a=[];for(let e of r.split("\n")){let t=e.trim();t&&(/^\|?[\s:|-]+\|[\s:|-]*$|^[-*_]{3,}$/.test(t)||(/\|.*\|/.test(t)&&(t=t.replace(/^\||\|$/g,"").split("|").map(e=>e.trim()).filter(Boolean).join(" · ")),t=t.replace(/^#{1,6}\s+/,"").replace(/^>\s?/,"").replace(/^[-*+]\s+/,"• ").replace(/`([^`]*)`/g,"$1").replace(/(\*\*|__)(\S(?:.*?\S)?)\1/g,"$2").replace(/(^|[^\w*])([*_])(\S(?:[^*_\n]*?\S)?)\2(?![\w*])/g,"$1$3").replace(/\s+/g," "),a.push(t)))}return a.join("\n").replace(/\uE000(\d+)\uE000/g,(e,n)=>t[Number(n)]??"")},"clip",0,t,"errorToString",0,function(e){if(e instanceof Error)return e.message;if("object"!=typeof e||null===e)return String(e);let{message:n,error:r}=e;if("string"==typeof n&&n)return n;if("string"==typeof r&&r)return r;let a=r?.message;if("string"==typeof a&&a)return a;try{return t(JSON.stringify(e),300)}catch{return`${e.constructor?.name??"Object"} thrown without a message`}},"hostOf",0,function(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return null}},"plainText",0,function(e){return e.replace(/```[\s\S]*?```/g," ").replace(/`([^`]*)`/g,"$1").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^\s{0,3}(#{1,6}\s+|[-*+]\s+|\d+\.\s+|>\s?)/gm,"").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(\*|_)(.*?)\1/g,"$2").replace(/^\s*\|?[\s:|-]+\|\s*$/gm," ").replace(/\|/g," ").replace(/\s+/g," ").trim()},"slug",0,function(e){return e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,40)}])},89929,609730,277988,e=>{"use strict";var t=e.i(874321);function n(e,n){return(0,t.constructFrom)(n||e,e)}e.s(["toDate",0,n],609730),e.s(["getTimezoneOffsetInMilliseconds",0,function(e){let t=n(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),e-r}],89929),e.s(["normalizeDates",0,function(e,...n){let r=t.constructFrom.bind(null,e||n.find(e=>"object"==typeof e));return n.map(r)}],277988)},874321,438220,e=>{"use strict";let t=Symbol.for("constructDateFrom");e.s(["constructFromSymbol",0,t,"millisecondsInDay",0,864e5,"millisecondsInMinute",0,6e4,"millisecondsInWeek",0,6048e5,"minutesInDay",0,1440,"minutesInMonth",0,43200,"minutesInYear",0,525600],438220),e.s(["constructFrom",0,function(e,n){return"function"==typeof e?e(n):e&&"object"==typeof e&&t in e?e[t](n):e instanceof Date?new e.constructor(n):new Date(n)}],874321)},599447,e=>{"use strict";var t=e.i(874321);e.s(["constructNow",0,function(e){return(0,t.constructFrom)(e,Date.now())}])},881237,662001,e=>{"use strict";var t;let n={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function r(e){return (t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}let a={date:r({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:r({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:r({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},i={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function o(e){return(t,n)=>{let r;if("formatting"===(n?.context?String(n.context):"standalone")&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,a=n?.width?String(n.width):t;r=e.formattingValues[a]||e.formattingValues[t]}else{let t=e.defaultWidth,a=n?.width?String(n.width):e.defaultWidth;r=e.values[a]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}let s={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:o({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:o({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:o({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:o({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:o({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function l(e){return(t,n={})=>{let r,a=n.width,i=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],o=t.match(i);if(!o)return null;let s=o[0],l=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],u=Array.isArray(l)?function(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}(l,e=>e.test(s)):function(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}(l,e=>e.test(s));return r=e.valueCallback?e.valueCallback(u):u,{value:r=n.valueCallback?n.valueCallback(r):r,rest:t.slice(s.length)}}}let u={ordinalNumber:(t={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,n={})=>{let r=e.match(t.matchPattern);if(!r)return null;let a=r[0],i=e.match(t.parsePattern);if(!i)return null;let o=t.valueCallback?t.valueCallback(i[0]):i[0];return{value:o=n.valueCallback?n.valueCallback(o):o,rest:e.slice(a.length)}}),era:l({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:l({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:l({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:l({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:l({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})};e.s(["defaultLocale",0,{code:"en-US",formatDistance:(e,t,r)=>{let a,i=n[e];if(a="string"==typeof i?i:1===t?i.one:i.other.replace("{{count}}",t.toString()),r?.addSuffix)if(r.comparison&&r.comparison>0)return"in "+a;else return a+" ago";return a},formatLong:a,formatRelative:(e,t,n,r)=>i[e],localize:s,match:u,options:{weekStartsOn:0,firstWeekContainsDate:1}}],881237);let c={};e.s(["getDefaultOptions",0,function(){return c}],662001)}];
4
+
5
+ //# sourceMappingURL=_0bgjf07._.js.map