thursday-agent 0.12.0 → 0.13.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 (470) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/prerender-manifest.json +4 -4
  4. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  5. package/.next/server/app/_global-error.html +1 -1
  6. package/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  10. package/.next/server/app/_not-found/page.js +1 -1
  11. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  12. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/_not-found.html +1 -1
  14. package/.next/server/app/_not-found.rsc +18 -19
  15. package/.next/server/app/_not-found.segments/_full.segment.rsc +18 -19
  16. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +14 -15
  17. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  18. package/.next/server/app/api/artifact/route.js +8 -8
  19. package/.next/server/app/api/artifact/route.js.nft.json +1 -1
  20. package/.next/server/app/api/bot/keep-working/route.js +7 -7
  21. package/.next/server/app/api/bot/keep-working/route.js.nft.json +1 -1
  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 +7 -7
  24. package/.next/server/app/api/bot/memory/route.js.nft.json +1 -1
  25. package/.next/server/app/api/bot/route.js +7 -7
  26. package/.next/server/app/api/bot/route.js.nft.json +1 -1
  27. package/.next/server/app/api/bot/thread/[id]/route.js +5 -5
  28. package/.next/server/app/api/bot/thread/[id]/route.js.nft.json +1 -1
  29. package/.next/server/app/api/bot/thread/route.js +3 -3
  30. package/.next/server/app/api/bot/thread/route.js.nft.json +1 -1
  31. package/.next/server/app/api/config/route.js +3 -3
  32. package/.next/server/app/api/config/route.js.nft.json +1 -1
  33. package/.next/server/app/api/events/route.js.nft.json +1 -1
  34. package/.next/server/app/api/favicon/[host]/route.js.nft.json +1 -1
  35. package/.next/server/app/api/file/[...path]/route.js +2 -2
  36. package/.next/server/app/api/file/[...path]/route.js.nft.json +1 -1
  37. package/.next/server/app/api/llm-model/catalog/route.js +4 -4
  38. package/.next/server/app/api/llm-model/catalog/route.js.nft.json +1 -1
  39. package/.next/server/app/api/llm-model/credits/route.js +4 -4
  40. package/.next/server/app/api/llm-model/credits/route.js.nft.json +1 -1
  41. package/.next/server/app/api/llm-model/route.js +6 -6
  42. package/.next/server/app/api/llm-model/route.js.nft.json +1 -1
  43. package/.next/server/app/api/llm-model/subscription/route.js +6 -6
  44. package/.next/server/app/api/llm-model/subscription/route.js.nft.json +1 -1
  45. package/.next/server/app/api/mcp/[name]/route.js +5 -5
  46. package/.next/server/app/api/mcp/[name]/route.js.nft.json +1 -1
  47. package/.next/server/app/api/mcp/oauth/callback/route.js +5 -5
  48. package/.next/server/app/api/mcp/oauth/callback/route.js.nft.json +1 -1
  49. package/.next/server/app/api/mcp/route.js +5 -5
  50. package/.next/server/app/api/mcp/route.js.nft.json +1 -1
  51. package/.next/server/app/api/mcp/tools/route.js +5 -5
  52. package/.next/server/app/api/mcp/tools/route.js.nft.json +1 -1
  53. package/.next/server/app/api/memory/edit/route.js +15 -14
  54. package/.next/server/app/api/memory/edit/route.js.nft.json +1 -1
  55. package/.next/server/app/api/memory/route.js +4 -4
  56. package/.next/server/app/api/memory/route.js.nft.json +1 -1
  57. package/.next/server/app/api/reach/route.js +13 -12
  58. package/.next/server/app/api/reach/route.js.nft.json +1 -1
  59. package/.next/server/app/api/routine/route.js +8 -9
  60. package/.next/server/app/api/routine/route.js.nft.json +1 -1
  61. package/.next/server/app/api/signins/route.js.nft.json +1 -1
  62. package/.next/server/app/api/skills/[source]/[name]/route.js +2 -2
  63. package/.next/server/app/api/skills/[source]/[name]/route.js.nft.json +1 -1
  64. package/.next/server/app/api/skills/route.js +2 -2
  65. package/.next/server/app/api/skills/route.js.nft.json +1 -1
  66. package/.next/server/app/api/thursday/call/route.js +6 -6
  67. package/.next/server/app/api/thursday/call/route.js.nft.json +1 -1
  68. package/.next/server/app/api/thursday/skills/route.js +6 -6
  69. package/.next/server/app/api/thursday/skills/route.js.nft.json +1 -1
  70. package/.next/server/app/api/thursday/text/route.js +14 -13
  71. package/.next/server/app/api/thursday/text/route.js.nft.json +1 -1
  72. package/.next/server/app/api/thursday/tool-call/route.js +15 -14
  73. package/.next/server/app/api/thursday/tool-call/route.js.nft.json +1 -1
  74. package/.next/server/app/api/workspace/files/route.js +10 -6
  75. package/.next/server/app/api/workspace/files/route.js.nft.json +1 -1
  76. package/.next/server/app/api/workspace/route.js +9 -4
  77. package/.next/server/app/api/workspace/route.js.nft.json +1 -1
  78. package/.next/server/app/artifact/[...path]/page/server-reference-manifest.json +2 -2
  79. package/.next/server/app/artifact/[...path]/page.js +5 -4
  80. package/.next/server/app/artifact/[...path]/page.js.nft.json +1 -1
  81. package/.next/server/app/artifact/[...path]/page_client-reference-manifest.js +1 -1
  82. package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  83. package/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  84. package/.next/server/app/page/server-reference-manifest.json +67 -56
  85. package/.next/server/app/page.js +10 -11
  86. package/.next/server/app/page.js.nft.json +1 -1
  87. package/.next/server/app/page_client-reference-manifest.js +1 -1
  88. package/.next/server/chunks/{[root-of-the-server]__0o49ztf._.js → [root-of-the-server]__0-k4_ie._.js} +2 -2
  89. package/.next/server/chunks/[root-of-the-server]__0209ah4._.js +6 -6
  90. package/.next/server/chunks/[root-of-the-server]__04wldw9._.js +1 -1
  91. package/.next/server/chunks/[root-of-the-server]__0h_x6q6._.js +2 -2
  92. package/.next/server/chunks/{[root-of-the-server]__0cfszwn._.js → [root-of-the-server]__0i23tc1._.js} +2 -2
  93. package/.next/server/chunks/[root-of-the-server]__0mrk2it._.js +1 -1
  94. package/.next/server/chunks/[root-of-the-server]__0nr-v8s._.js +1 -1
  95. package/.next/server/chunks/{[root-of-the-server]__1tg5got._.js → [root-of-the-server]__0paqm5y._.js} +2 -2
  96. package/.next/server/chunks/[root-of-the-server]__0qog7sm._.js +8 -0
  97. package/.next/server/chunks/[root-of-the-server]__0sm5xvm._.js +1 -1
  98. package/.next/server/chunks/[root-of-the-server]__0yisc5v._.js +5 -0
  99. package/.next/server/chunks/[root-of-the-server]__1-swlkw._.js +3 -3
  100. package/.next/server/chunks/[root-of-the-server]__12iddfq._.js +2 -2
  101. package/.next/server/chunks/{[root-of-the-server]__0npn_pn._.js → [root-of-the-server]__15p29m3._.js} +2 -2
  102. package/.next/server/chunks/[root-of-the-server]__17ses32._.js +3 -0
  103. package/.next/server/chunks/[root-of-the-server]__18-2tsq._.js +2 -2
  104. package/.next/server/chunks/[root-of-the-server]__1cjxw0-._.js +1 -1
  105. package/.next/server/chunks/[root-of-the-server]__1gi2nns._.js +5 -0
  106. package/.next/server/chunks/{[root-of-the-server]__0rqgb17._.js → [root-of-the-server]__1iauz8a._.js} +2 -2
  107. package/.next/server/chunks/[root-of-the-server]__1k3j52n._.js +1 -1
  108. package/.next/server/chunks/{[root-of-the-server]__209k6pk._.js → [root-of-the-server]__1lb_pxg._.js} +2 -2
  109. package/.next/server/chunks/[root-of-the-server]__1ndi14y._.js +1 -1
  110. package/.next/server/chunks/[root-of-the-server]__1orn-5b._.js +1 -1
  111. package/.next/server/chunks/[root-of-the-server]__1xqsrqq._.js +5 -0
  112. package/.next/server/chunks/[root-of-the-server]__1ygplx1._.js +1 -1
  113. package/.next/server/chunks/[root-of-the-server]__2163i40._.js +5 -0
  114. package/.next/server/chunks/_0ci0abh._.js +3 -0
  115. package/.next/server/chunks/_0eauz4t._.js +1 -1
  116. package/.next/server/chunks/_0f6ts7z._.js +1 -1
  117. package/.next/server/chunks/_0fg-1oj._.js +5 -0
  118. package/.next/server/chunks/_0khihjk._.js +2 -2
  119. package/.next/server/chunks/_0n74zsf._.js +1 -1
  120. package/.next/server/chunks/_0na2fj1._.js +2 -2
  121. package/.next/server/chunks/_0oh_99-._.js +3 -0
  122. package/.next/server/chunks/_0x-ej3f._.js +24 -24
  123. package/.next/server/chunks/_0z3nz21._.js +3 -0
  124. package/.next/server/chunks/_10tkr26._.js +1 -1
  125. package/.next/server/chunks/_12-amdu._.js +2 -2
  126. package/.next/server/chunks/_136j09a._.js +1 -1
  127. package/.next/server/chunks/_15740dw._.js +1 -1
  128. package/.next/server/chunks/_18izeh1._.js +5 -0
  129. package/.next/server/chunks/_1_5mnq4._.js +1 -1
  130. package/.next/server/chunks/_1ajbhv6._.js +2 -2
  131. package/.next/server/chunks/_1dc_d1q._.js +2 -2
  132. package/.next/server/chunks/_1drgfx4._.js +1 -1
  133. package/.next/server/chunks/_1e48czp._.js +2 -2
  134. package/.next/server/chunks/_1f06zo4._.js +3 -0
  135. package/.next/server/chunks/_1ic3bew._.js +2 -2
  136. package/.next/server/chunks/_1jn-aep._.js +2 -2
  137. package/.next/server/chunks/_1jn5btd._.js +6 -0
  138. package/.next/server/chunks/_1kg70wc._.js +2 -2
  139. package/.next/server/chunks/_1m2i5pt._.js +5 -0
  140. package/.next/server/chunks/_1ogqovh._.js +4 -4
  141. package/.next/server/chunks/_1qxheoa._.js +1 -1
  142. package/.next/server/chunks/_1ry6afh._.js +18 -0
  143. package/.next/server/chunks/_1taa4bs._.js +1 -1
  144. package/.next/server/chunks/_1tpr507._.js +1 -1
  145. package/.next/server/chunks/_1y8w80a._.js +1 -1
  146. package/.next/server/chunks/_1zxp-p6._.js +1 -1
  147. package/.next/server/chunks/_204744f._.js +5 -0
  148. package/.next/server/chunks/_20fsr_z._.js +1 -1
  149. package/.next/server/chunks/config_ts_1g4sz5o._.js +1 -1
  150. package/.next/server/chunks/features_0-cnt0l._.js +1 -1
  151. package/.next/server/chunks/features_0hdaci0._.js +1 -1
  152. package/.next/server/chunks/features_0p85gv6._.js +3 -0
  153. package/.next/server/chunks/{node_modules_zod_v4_0_v5xf5._.js → node_modules_zod_v4_01bha1c._.js} +2 -2
  154. package/.next/server/chunks/{node_modules_zod_v4_0q9hvql._.js → node_modules_zod_v4_0b99z6a._.js} +2 -2
  155. package/.next/server/chunks/{node_modules_zod_v4_1jg8iwg._.js → node_modules_zod_v4_1zz6lo1._.js} +2 -2
  156. package/.next/server/chunks/ssr/[root-of-the-server]__04upd5v._.js +3 -0
  157. package/.next/server/chunks/ssr/[root-of-the-server]__0dxszdt._.js +3 -0
  158. package/.next/server/chunks/ssr/[root-of-the-server]__0eezycw._.js +3 -0
  159. package/.next/server/chunks/ssr/[root-of-the-server]__0hpp3nw._.js +1 -1
  160. package/.next/server/chunks/ssr/[root-of-the-server]__0yngu44._.js +3 -0
  161. package/.next/server/chunks/ssr/[root-of-the-server]__16z72ny._.js +6 -0
  162. package/.next/server/chunks/ssr/[root-of-the-server]__1u_ry86._.js +3 -0
  163. package/.next/server/chunks/ssr/{[root-of-the-server]__1iwyp1e._.js → [root-of-the-server]__1unh_ew._.js} +1 -1
  164. package/.next/server/chunks/ssr/[root-of-the-server]__20re7ya._.js +3 -0
  165. package/.next/server/chunks/ssr/_00pgq9d._.js +5 -0
  166. package/.next/server/chunks/ssr/_07ke63g._.js +3 -0
  167. package/.next/server/chunks/ssr/_0agcbk7._.js +3 -0
  168. package/.next/server/chunks/ssr/_0e-gw2_._.js +3 -0
  169. package/.next/server/chunks/ssr/{_0fbi6om._.js → _0f_om6y._.js} +3 -3
  170. package/.next/server/chunks/ssr/_0fqhhwi._.js +1 -1
  171. package/.next/server/chunks/ssr/{_026qnc9._.js → _0gpn71k._.js} +3 -3
  172. package/.next/server/chunks/ssr/_0iizjr9._.js +3 -0
  173. package/.next/server/chunks/ssr/_0ixvzo6._.js +75 -0
  174. package/.next/server/chunks/ssr/_0kkdx7t._.js +3 -0
  175. package/.next/server/chunks/ssr/_0lufvw7._.js +118 -0
  176. package/.next/server/chunks/ssr/_0vi6ky6._.js +115 -0
  177. package/.next/server/chunks/ssr/{_10f-jib._.js → _0yhji3e._.js} +2 -2
  178. package/.next/server/chunks/ssr/_0z38nha._.js +3 -0
  179. package/.next/server/chunks/ssr/{_10mo72m._.js → _11nx2d4._.js} +2 -2
  180. package/.next/server/chunks/ssr/_12mijol._.js +2 -2
  181. package/.next/server/chunks/ssr/_150463c._.js +164 -0
  182. package/.next/server/chunks/ssr/{_0rmaf32._.js → _17d2ikl._.js} +2 -2
  183. package/.next/server/chunks/ssr/_19jez1a._.js +3 -0
  184. package/.next/server/chunks/ssr/_1blui1m._.js +3 -0
  185. package/.next/server/chunks/ssr/_1d423aj._.js +4 -4
  186. package/.next/server/chunks/ssr/_1kbk28w._.js +3 -0
  187. package/.next/server/chunks/ssr/_1kj_r9v._.js +3 -0
  188. package/.next/server/chunks/ssr/_1mqn9mc._.js +1 -1
  189. package/.next/server/chunks/ssr/{_0u5xv6g._.js → _1myh7ss._.js} +2 -2
  190. package/.next/server/chunks/ssr/_1neoj22._.js +1 -1
  191. package/.next/server/chunks/ssr/_1ou5sj0._.js +3 -0
  192. package/.next/server/chunks/ssr/_1p8xorg._.js +3 -0
  193. package/.next/server/chunks/ssr/_1tzacpl._.js +3 -0
  194. package/.next/server/chunks/ssr/_1xoch6f._.js +1 -1
  195. package/.next/server/chunks/ssr/_1yh5bj5._.js +1 -1
  196. package/.next/server/chunks/ssr/{_02c7o30._.js → _2021n9-._.js} +2 -2
  197. package/.next/server/chunks/ssr/_20argo3._.js +3 -0
  198. package/.next/server/chunks/ssr/features_bot_1ll3wp7._.js +3 -0
  199. package/.next/server/chunks/ssr/features_bot_1s_-2vj._.js +1 -1
  200. package/.next/server/chunks/ssr/features_bot_thread_query_ts_023eklt._.js +1 -1
  201. package/.next/server/chunks/ssr/features_config_1qxe5ur._.js +20 -0
  202. package/.next/server/chunks/ssr/features_connectors_components_mcp-setting_tsx_0jmbgvp._.js +3 -3
  203. package/.next/server/chunks/ssr/features_memory_components_memory-setting_tsx_0oa43sw._.js +1 -1
  204. package/.next/server/chunks/ssr/features_routine_components_routine-setting_tsx_055fknz._.js +1 -1
  205. package/.next/server/chunks/ssr/features_workspace_00jz2hu._.js +1 -1
  206. package/.next/server/chunks/ssr/{node_modules_0ky76fz._.js → node_modules_06e0wlv._.js} +1 -1
  207. package/.next/server/chunks/ssr/{node_modules_0-x0zxm._.js → node_modules_0cj26-9._.js} +1 -1
  208. package/.next/server/chunks/ssr/{node_modules_0operbz._.js → node_modules_0d1rf5e._.js} +1 -1
  209. package/.next/server/chunks/ssr/{node_modules_0b0iy01._.js → node_modules_0e86703._.js} +1 -1
  210. package/.next/server/chunks/ssr/{node_modules_05b6e99._.js → node_modules_0es09am._.js} +1 -1
  211. package/.next/server/chunks/ssr/{node_modules_1iau_ea._.js → node_modules_0gr_dzf._.js} +1 -1
  212. package/.next/server/chunks/ssr/{node_modules_1hv-j1l._.js → node_modules_0gtcwz9._.js} +1 -1
  213. package/.next/server/chunks/ssr/{node_modules_1c2ikr9._.js → node_modules_0hi9h8f._.js} +1 -1
  214. package/.next/server/chunks/ssr/{node_modules_01u4ea3._.js → node_modules_0lkop0t._.js} +1 -1
  215. package/.next/server/chunks/ssr/{node_modules_1wvf3oo._.js → node_modules_0nghisk._.js} +1 -1
  216. package/.next/server/chunks/ssr/{node_modules_0yzmxfq._.js → node_modules_0stovz0._.js} +1 -1
  217. package/.next/server/chunks/ssr/{node_modules_00nrzz_._.js → node_modules_0we85kr._.js} +1 -1
  218. package/.next/server/chunks/ssr/{node_modules_01ed0yi._.js → node_modules_0ya7y1s._.js} +1 -1
  219. package/.next/server/chunks/ssr/{node_modules_0m3_5ge._.js → node_modules_0yrbwkj._.js} +1 -1
  220. package/.next/server/chunks/ssr/{node_modules_0v_-uht._.js → node_modules_1-x70ie._.js} +1 -1
  221. package/.next/server/chunks/ssr/{node_modules_07jp6tj._.js → node_modules_12fd9g0._.js} +1 -1
  222. package/.next/server/chunks/ssr/{node_modules_1wgnj8q._.js → node_modules_12wxrgr._.js} +1 -1
  223. package/.next/server/chunks/ssr/{node_modules_0azd56x._.js → node_modules_139uu4q._.js} +1 -1
  224. package/.next/server/chunks/ssr/{node_modules_1omg9xr._.js → node_modules_14gpoe1._.js} +1 -1
  225. package/.next/server/chunks/ssr/{node_modules_1ma_y68._.js → node_modules_18fmji6._.js} +1 -1
  226. package/.next/server/chunks/ssr/{node_modules_0ucridu._.js → node_modules_19kkel8._.js} +1 -1
  227. package/.next/server/chunks/ssr/{node_modules_0fpnetd._.js → node_modules_1gcine1._.js} +1 -1
  228. package/.next/server/chunks/ssr/{node_modules_1z3sh11._.js → node_modules_1h4trkm._.js} +1 -1
  229. package/.next/server/chunks/ssr/{node_modules_0lautv3._.js → node_modules_1mub_qu._.js} +1 -1
  230. package/.next/server/chunks/ssr/{node_modules_0ou0all._.js → node_modules_1p78svs._.js} +1 -1
  231. package/.next/server/chunks/ssr/{node_modules_19b0bir._.js → node_modules_1xp-7ep._.js} +1 -1
  232. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0tmjn9w._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0ay7_oi._.js} +1 -1
  233. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1_e8c3o._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_182ydq_._.js} +1 -1
  234. package/.next/server/middleware-build-manifest.js +3 -3
  235. package/.next/server/pages/404.html +1 -1
  236. package/.next/server/pages/500.html +1 -1
  237. package/.next/server/server-reference-manifest.js +1 -1
  238. package/.next/server/server-reference-manifest.json +69 -58
  239. package/.next/static/chunks/03df16hs01-xi.js +1 -0
  240. package/.next/static/chunks/0crocb7272z8k.js +1 -0
  241. package/.next/static/chunks/{0p9jcyqkpq71f.js → 0dqsenl3uk_8z.js} +1 -1
  242. package/.next/static/chunks/0hhn8mf953761.js +1 -0
  243. package/.next/static/chunks/0n1o3k0z4m7c_.js +1 -0
  244. package/.next/static/chunks/0oe2zavre2a7d.css +1 -0
  245. package/.next/static/chunks/0srg9tv4105-i.js +1 -0
  246. package/.next/static/chunks/0t599wrclly7i.js +18 -0
  247. package/.next/static/chunks/0x34bhth_sn35.js +1 -0
  248. package/.next/static/chunks/{0mscosx0eh3ee.js → 0x_6z8vt8hyf4.js} +3 -3
  249. package/.next/static/chunks/{0p50d-au6-3hx.js → 1_wstwzu1md-6.js} +2 -2
  250. package/.next/static/chunks/{40ij3wsn3vt7h.js → 1aughn81slf90.js} +1 -1
  251. package/.next/static/chunks/1g1j03h_l-e67.js +1 -0
  252. package/.next/static/chunks/1lp02y2nmddxg.js +1 -0
  253. package/.next/static/chunks/211s4xjtecj2l.js +1 -0
  254. package/.next/static/chunks/2244-cat2jlvd.js +1 -0
  255. package/.next/static/chunks/{2r6xnyg7ezyxr.js → 2eev_i93slion.js} +2 -2
  256. package/.next/static/chunks/2sjq4gsimlfqr.js +113 -0
  257. package/.next/static/chunks/{0qgn3u86jkbm7.js → 2uleilh8ph06-.js} +1 -1
  258. package/.next/static/chunks/{1czfknd4luo6t.js → 2zchsg03a1pdp.js} +1 -1
  259. package/.next/static/chunks/32tmfirfjpulv.js +1 -0
  260. package/.next/static/chunks/{2_c7mu6x1lu49.js → 376-s_i83irs-.js} +1 -1
  261. package/.next/static/chunks/3blk-kpn39xr-.js +1 -0
  262. package/.next/static/chunks/3eieehp7wquyu.js +1 -0
  263. package/.next/static/chunks/3kc-e7pcj50ae.js +1 -0
  264. package/.next/static/chunks/3rwpyuo9nrrop.js +17 -0
  265. package/.next/static/chunks/3sf4l25l353ja.js +1 -0
  266. package/.next/static/chunks/3vz7m1w688juj.js +3 -0
  267. package/.next/static/chunks/43skgt0h9woyu.js +1 -0
  268. package/app/api/events/app-event.client.ts +8 -2
  269. package/app/api/events/app-event.server.ts +7 -5
  270. package/app/api/events/app-event.ts +19 -8
  271. package/app/api/query-key.ts +13 -5
  272. package/bin/database.mjs +21 -11
  273. package/bin/thursday.mjs +5 -2
  274. package/components/ui/shiny-text.tsx +2 -2
  275. package/database/migrations/20260920024909_messy_baron_strucker/migration.sql +1 -0
  276. package/database/migrations/20260920024909_messy_baron_strucker/snapshot.json +1937 -0
  277. package/features/artifact/components/artifact-setting.tsx +18 -24
  278. package/features/bot/bot.action.ts +3 -0
  279. package/features/bot/bot.runner.ts +25 -3
  280. package/features/bot/bot.seed.ts +98 -22
  281. package/features/bot/components/bot-badge.tsx +2 -2
  282. package/features/bot/components/bot-mark.tsx +12 -3
  283. package/features/bot/components/bot-room.tsx +33 -10
  284. package/features/bot/components/bot-setting.tsx +88 -34
  285. package/features/bot/components/crew-motion.ts +161 -0
  286. package/features/bot/components/mark-palette.tsx +3 -3
  287. package/features/bot/components/room-conversation.tsx +13 -8
  288. package/features/bot/components/room-list.tsx +9 -5
  289. package/features/bot/components/room-pill.tsx +131 -41
  290. package/features/bot/components/thread-badge.tsx +4 -4
  291. package/features/bot/components/thread-setting.tsx +58 -19
  292. package/features/bot/mark.const.ts +24 -0
  293. package/features/bot/thread.query.ts +32 -14
  294. package/features/bot/thread.store.ts +19 -16
  295. package/features/config/components/config-badge.tsx +2 -2
  296. package/features/config/components/config-setting.tsx +63 -213
  297. package/features/config/config.const.ts +2 -1
  298. package/features/connectors/components/mcp-setting.tsx +60 -29
  299. package/features/intro/components/intro.tsx +2 -2
  300. package/features/memory/components/memory-setting.tsx +11 -7
  301. package/features/reach/channel.ts +9 -1
  302. package/features/reach/components/reach-guide.tsx +606 -105
  303. package/features/reach/discord.ts +18 -3
  304. package/features/reach/reach.schema.ts +6 -0
  305. package/features/reach/reach.ts +55 -2
  306. package/features/reach/slack.ts +2 -1
  307. package/features/reach/telegram.ts +5 -1
  308. package/features/routine/components/routine-setting.tsx +46 -18
  309. package/features/settings/components/setting-ui.tsx +17 -68
  310. package/features/settings/components/settings.tsx +4 -3
  311. package/features/settings/settings.alert.ts +8 -8
  312. package/features/skills/components/skills-setting.tsx +78 -12
  313. package/features/skills/skills.action.ts +12 -0
  314. package/features/skills/skills.query.ts +24 -0
  315. package/features/thursday/components/call-log.tsx +19 -14
  316. package/features/thursday/components/side-captions.tsx +3 -2
  317. package/features/thursday/components/thursday-setting.tsx +5 -6
  318. package/features/thursday/components/thursday.tsx +8 -9
  319. package/features/thursday/components/write-line.tsx +10 -5
  320. package/features/thursday/thursday.action.ts +4 -0
  321. package/features/thursday/thursday.query.ts +3 -2
  322. package/features/thursday/thursday.schema.ts +5 -0
  323. package/features/thursday/use-call-ring.ts +6 -1
  324. package/features/thursday/use-text-call.ts +25 -10
  325. package/features/thursday/use-thursday.ts +10 -1
  326. package/features/workspace/components/artifact-view.tsx +42 -33
  327. package/features/workspace/components/file-thumb.tsx +8 -4
  328. package/features/workspace/components/file-view.tsx +25 -2
  329. package/features/workspace/components/workspace-setting.tsx +27 -23
  330. package/features/workspace/workspace.query.ts +20 -1
  331. package/features/workspace/workspace.ts +14 -0
  332. package/guide/bots.md +27 -4
  333. package/guide/calls.md +5 -3
  334. package/guide/phone.md +23 -12
  335. package/guide/setup.md +20 -5
  336. package/guide/trouble.md +1 -1
  337. package/hooks/use-theme.ts +14 -0
  338. package/lib/protocol/events.client.ts +56 -14
  339. package/lib/protocol/events.server.ts +41 -12
  340. package/lib/utils.ts +1 -1
  341. package/package.json +1 -1
  342. package/scripts/reach-channels.test.mts +15 -2
  343. package/seed-skills/brief/daily-brief/SKILL.md +39 -0
  344. package/seed-skills/brief/daily-brief/page/brief.css +406 -0
  345. package/seed-skills/brief/daily-brief/references/brief.md +106 -0
  346. package/seed-skills/brief/daily-brief/references/preferences.md +67 -0
  347. package/seed-skills/brief/daily-brief/scripts/glance.mjs +128 -0
  348. package/seed-skills/brief/daily-brief/scripts/lib.mjs +182 -0
  349. package/seed-skills/brief/daily-brief/scripts/news.mjs +320 -0
  350. package/seed-skills/brief/daily-brief/scripts/page.mjs +322 -0
  351. package/seed-skills/brief/daily-brief/scripts/story.mjs +265 -0
  352. package/seed-skills/digest/README.md +20 -0
  353. package/seed-skills/digest/media-digest/SKILL.md +32 -0
  354. package/seed-skills/digest/media-digest/references/no-captions.md +20 -0
  355. package/seed-skills/digest/media-digest/references/page.md +56 -0
  356. package/seed-skills/digest/media-digest/references/reading.md +56 -0
  357. package/seed-skills/digest/media-digest/scripts/audio.mjs +232 -0
  358. package/seed-skills/digest/media-digest/scripts/digest.mjs +379 -0
  359. package/seed-skills/digest/media-digest/scripts/lib.mjs +284 -0
  360. package/seed-skills/digest/media-digest/scripts/part.mjs +16 -0
  361. package/seed-skills/digest/media-digest/scripts/text.mjs +287 -0
  362. package/seed-skills/digest/media-digest/scripts/yt.mjs +487 -0
  363. package/seed-skills/docs/README.md +32 -0
  364. package/seed-skills/docs/documents/SKILL.md +34 -0
  365. package/seed-skills/docs/documents/kit/package-lock.json +1596 -0
  366. package/seed-skills/docs/documents/kit/package.json +17 -0
  367. package/seed-skills/docs/documents/references/deck.md +63 -0
  368. package/seed-skills/docs/documents/references/invoice.md +64 -0
  369. package/seed-skills/docs/documents/references/pdf.md +59 -0
  370. package/seed-skills/docs/documents/references/print.md +43 -0
  371. package/seed-skills/docs/documents/references/sheets.md +49 -0
  372. package/seed-skills/docs/documents/references/translate.md +37 -0
  373. package/seed-skills/docs/documents/references/word.md +45 -0
  374. package/seed-skills/docs/documents/scripts/doc.mjs +123 -0
  375. package/seed-skills/docs/documents/scripts/lib/browser.mjs +259 -0
  376. package/seed-skills/docs/documents/scripts/lib/deck-chart.mjs +150 -0
  377. package/seed-skills/docs/documents/scripts/lib/deck.mjs +1132 -0
  378. package/seed-skills/docs/documents/scripts/lib/invoice.mjs +505 -0
  379. package/seed-skills/docs/documents/scripts/lib/kit.mjs +244 -0
  380. package/seed-skills/docs/documents/scripts/lib/pdf.mjs +645 -0
  381. package/seed-skills/docs/documents/scripts/lib/report.mjs +38 -0
  382. package/seed-skills/docs/documents/scripts/lib/sheet.mjs +523 -0
  383. package/seed-skills/docs/documents/scripts/lib/templates.mjs +34 -0
  384. package/seed-skills/docs/documents/scripts/lib/translate.mjs +691 -0
  385. package/seed-skills/docs/documents/scripts/lib/word.mjs +678 -0
  386. package/seed-skills/docs/documents/templates/letter.html +56 -0
  387. package/seed-skills/docs/documents/templates/print.css +219 -0
  388. package/seed-skills/docs/documents/templates/report.html +47 -0
  389. package/seed-skills/docs/documents/templates/resume.html +61 -0
  390. package/seed-skills/insta/instagram/references/post.md +31 -7
  391. package/seed-skills/trip/README.md +11 -0
  392. package/seed-skills/trip/travel/SKILL.md +40 -0
  393. package/seed-skills/trip/travel/page/itinerary.css +488 -0
  394. package/seed-skills/trip/travel/references/itinerary.md +70 -0
  395. package/seed-skills/trip/travel/references/plan.md +75 -0
  396. package/seed-skills/trip/travel/references/watch-and-book.md +39 -0
  397. package/seed-skills/trip/travel/scripts/flights.mjs +374 -0
  398. package/seed-skills/trip/travel/scripts/fx.mjs +57 -0
  399. package/seed-skills/trip/travel/scripts/hotels.mjs +356 -0
  400. package/seed-skills/trip/travel/scripts/itinerary.mjs +482 -0
  401. package/seed-skills/trip/travel/scripts/lib.mjs +120 -0
  402. package/seed-skills/trip/travel/scripts/selectors.mjs +78 -0
  403. package/seed-skills/trip/travel/scripts/watch.mjs +147 -0
  404. package/seed-skills/trip/travel/scripts/weather.mjs +150 -0
  405. package/seed-skills/tutor/picture-book/SKILL.md +6 -0
  406. package/seed-skills/tutor/picture-book/references/picture-book.md +22 -2
  407. package/.next/server/chunks/[root-of-the-server]__014ydvq._.js +0 -8
  408. package/.next/server/chunks/[root-of-the-server]__01d285y._.js +0 -5
  409. package/.next/server/chunks/[root-of-the-server]__04r4h-2._.js +0 -7
  410. package/.next/server/chunks/[root-of-the-server]__0ayldfn._.js +0 -5
  411. package/.next/server/chunks/[root-of-the-server]__17weeeg._.js +0 -5
  412. package/.next/server/chunks/[root-of-the-server]__1ai5lme._.js +0 -8
  413. package/.next/server/chunks/_05v8k21._.js +0 -7
  414. package/.next/server/chunks/_0k6qjcf._.js +0 -5
  415. package/.next/server/chunks/_1d_enhu._.js +0 -3
  416. package/.next/server/chunks/_1jc5g4p._.js +0 -6
  417. package/.next/server/chunks/_1nfr-75._.js +0 -3
  418. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_0md6j0x._.js +0 -3
  419. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_14ih1vy._.js +0 -3
  420. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1d6ez5-._.js +0 -3
  421. package/.next/server/chunks/ssr/[root-of-the-server]__0a967km._.js +0 -3
  422. package/.next/server/chunks/ssr/[root-of-the-server]__0tzekbl._.js +0 -68
  423. package/.next/server/chunks/ssr/[root-of-the-server]__1756892._.js +0 -3
  424. package/.next/server/chunks/ssr/[root-of-the-server]__1mzi-ju._.js +0 -3
  425. package/.next/server/chunks/ssr/[root-of-the-server]__1nqw56a._.js +0 -3
  426. package/.next/server/chunks/ssr/[root-of-the-server]__1r77-88._.js +0 -3
  427. package/.next/server/chunks/ssr/[root-of-the-server]__1w9hqq8._.js +0 -8
  428. package/.next/server/chunks/ssr/_05pl_u8._.js +0 -3
  429. package/.next/server/chunks/ssr/_097-ljd._.js +0 -4
  430. package/.next/server/chunks/ssr/_0euzzf8._.js +0 -3
  431. package/.next/server/chunks/ssr/_0evkpto._.js +0 -3
  432. package/.next/server/chunks/ssr/_0igfcax._.js +0 -20
  433. package/.next/server/chunks/ssr/_0lu1n_x._.js +0 -3
  434. package/.next/server/chunks/ssr/_0nvh1h9._.js +0 -3
  435. package/.next/server/chunks/ssr/_0qmpw35._.js +0 -3
  436. package/.next/server/chunks/ssr/_0uv-qs4._.js +0 -3
  437. package/.next/server/chunks/ssr/_132qkfz._.js +0 -5
  438. package/.next/server/chunks/ssr/_15zqt-t._.js +0 -3
  439. package/.next/server/chunks/ssr/_16gfxpn._.js +0 -3
  440. package/.next/server/chunks/ssr/_184327j._.js +0 -3
  441. package/.next/server/chunks/ssr/_18ujhhq._.js +0 -3
  442. package/.next/server/chunks/ssr/_1lx6w_o._.js +0 -67
  443. package/.next/server/chunks/ssr/_1ntpny5._.js +0 -3
  444. package/.next/server/chunks/ssr/_1o1g4uk._.js +0 -5
  445. package/.next/server/chunks/ssr/_1xx4zlb._.js +0 -3
  446. package/.next/server/chunks/ssr/_2008vmi._.js +0 -164
  447. package/.next/server/chunks/ssr/features_bot_1n1s7bh._.js +0 -3
  448. package/.next/static/chunks/09pkygbht7ki8.js +0 -18
  449. package/.next/static/chunks/0bm-nhblcmmj4.js +0 -17
  450. package/.next/static/chunks/0c_g4-11sha-1.js +0 -1
  451. package/.next/static/chunks/0hhza87hkbqaz.js +0 -1
  452. package/.next/static/chunks/0samf80yu2b17.js +0 -1
  453. package/.next/static/chunks/0vlgzqo9ka90v.js +0 -1
  454. package/.next/static/chunks/1g9yyvculuxj2.js +0 -1
  455. package/.next/static/chunks/1jz8n0mhtdzr8.js +0 -1
  456. package/.next/static/chunks/206laxm6maiz2.js +0 -1
  457. package/.next/static/chunks/23nfu5g4vl_m7.js +0 -1
  458. package/.next/static/chunks/2h-tlhb2ffhkk.js +0 -1
  459. package/.next/static/chunks/2i5_w8olnrvo0.js +0 -3
  460. package/.next/static/chunks/2m6jd3586ijb-.js +0 -1
  461. package/.next/static/chunks/2m8iqwc6sykln.js +0 -1
  462. package/.next/static/chunks/33fyp-byw48ju.js +0 -65
  463. package/.next/static/chunks/35yd_27d9ylra.js +0 -1
  464. package/.next/static/chunks/3ag1i3__yl94f.js +0 -1
  465. package/.next/static/chunks/3m_ejzg-xn21r.css +0 -1
  466. package/.next/static/chunks/3s-jpd3ky49-n.js +0 -1
  467. package/features/reach/components/reach-state.tsx +0 -71
  468. /package/.next/static/{QSe0rTdXU5kh5BBzr2XBB → fiNGsQfna8qldl8wU8wqr}/_buildManifest.js +0 -0
  469. /package/.next/static/{QSe0rTdXU5kh5BBzr2XBB → fiNGsQfna8qldl8wU8wqr}/_clientMiddlewareManifest.js +0 -0
  470. /package/.next/static/{QSe0rTdXU5kh5BBzr2XBB → fiNGsQfna8qldl8wU8wqr}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[528790,e=>e.a(async(t,i)=>{try{let d,h;var s,r=e.i(902157),n=e.i(750227),l=e.i(418520),a=e.i(219756),o=e.i(687388),u=e.i(41444),c=t([l,a]);[l,a]=c.then?(await c)():c;let f=o.DB_FILE_NAME.replace(/^file:/,"");(0,r.mkdirSync)((0,n.dirname)(f),{recursive:!0});let m=globalThis.__dbClient??=(s=((d=(0,l.createClient)({url:o.DB_FILE_NAME,timeout:5e3})).execute("PRAGMA journal_mode = WAL"),d),h=(0,u.PromiseChain)(),{...s,execute:(...e)=>h(()=>s.execute(...e)),batch:(...e)=>h(()=>s.batch(...e)),executeMultiple:(...e)=>h(()=>s.executeMultiple(...e)),migrate:(...e)=>h(()=>s.migrate(...e)),async transaction(...e){let t,i=await new Promise(e=>{let t,i=new Promise(e=>{t=e});h(async()=>{e(t),await i})});try{t=await s.transaction(...e)}catch(e){throw i(),e}let r=!1,n=()=>{r||(r=!0,i())};return{execute:(...e)=>t.execute(...e),batch:(...e)=>t.batch(...e),executeMultiple:(...e)=>t.executeMultiple(...e),get closed(){return t.closed},commit:()=>t.commit().finally(n),rollback:()=>t.rollback().finally(n),close:()=>{try{t.close()}finally{n()}}}}}),p=(0,a.drizzle)({client:m});e.s(["database",0,p]),i()}catch(e){i(e)}},!1),613240,e=>{"use strict";var t=e.i(518899),i=e.i(646683),s=e.i(201440),r=e.i(616918),n=e.i(937540),l=e.i(380568),a=e.i(75799);let o=(0,a.sqliteTable)("bot",{name:(0,l.text)("name").primaryKey(),description:(0,l.text)("description").notNull(),systemPrompt:(0,l.text)("system_prompt"),icon:(0,l.text)("icon",{mode:"json"}).$type(),provider:(0,l.text)("provider").$type(),model:(0,l.text)("model"),compactAt:(0,n.int)("compact_at"),disabled:(0,n.int)("disabled",{mode:"boolean"}).notNull().default(!1),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),u=(0,a.sqliteTable)("mcp_server",{name:(0,l.text)("name").primaryKey(),config:(0,l.text)("config",{mode:"json"}).notNull().$type(),toolsSyncedAt:(0,n.int)("tools_synced_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),lastError:(0,l.text)("last_error"),oauth:(0,l.text)("oauth",{mode:"json"}).$type(),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),c=(0,a.sqliteTable)("mcp_tool",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),serverName:(0,l.text)("server_name").notNull().references(()=>u.name,{onDelete:"cascade"}),name:(0,l.text)("name").notNull(),description:(0,l.text)("description"),inputSchema:(0,l.text)("input_schema",{mode:"json"}).$type(),outputSchema:(0,l.text)("output_schema",{mode:"json"}).$type()},e=>[(0,r.unique)("uq_mcp_tool_server_name").on(e.serverName,e.name)]),d=(0,a.sqliteTable)("bot_mcp_tool",{botName:(0,l.text)().notNull().references(()=>o.name,{onDelete:"cascade"}),toolId:(0,n.int)("tool_id").notNull().references(()=>c.id,{onDelete:"cascade"})},e=>[(0,s.primaryKey)({columns:[e.botName,e.toolId]})]),h=(0,a.sqliteTable)("thread",{id:(0,l.text)("id").primaryKey(),bot:(0,l.text)("bot").notNull(),label:(0,l.text)("label").notNull(),request:(0,l.text)("request").notNull(),status:(0,l.text)("status").notNull().$type(),generation:(0,n.int)("generation").notNull().default(0),turns:(0,n.int)("turns").notNull().default(0),wrapped:(0,n.int)("wrapped",{mode:"boolean"}).notNull().default(!1),outcome:(0,l.text)("outcome"),pending:(0,l.text)("pending",{mode:"json"}).$type(),seen:(0,n.int)("seen",{mode:"boolean"}).notNull().default(!1),callId:(0,l.text)("call_id"),routineId:(0,l.text)("routine_id"),inputTokens:(0,n.int)("input_tokens").notNull().default(0),outputTokens:(0,n.int)("output_tokens").notNull().default(0),contextTokens:(0,n.int)("context_tokens").notNull().default(0),contextBudget:(0,n.int)("context_budget").notNull().default(0),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,n.int)("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),endedAt:(0,n.int)("ended_at",{mode:"timestamp"})},e=>[(0,i.index)("idx_thread_routine").on(e.routineId,e.createdAt)]),f=(0,a.sqliteTable)("thread_message",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),threadId:(0,l.text)("thread_id").notNull().references(()=>h.id,{onDelete:"cascade"}),seq:(0,n.int)("seq").notNull(),bot:(0,l.text)("bot"),parent:(0,l.text)("parent"),hidden:(0,n.int)("hidden",{mode:"boolean"}).notNull().default(!1),role:(0,l.text)("role").notNull().$type(),content:(0,l.text)("content",{mode:"json"}).notNull().$type(),compact:(0,n.int)("compact",{mode:"boolean"}).notNull().default(!1),note:(0,n.int)("note",{mode:"boolean"}).notNull().default(!1),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[(0,r.unique)("uq_thread_message_seq").on(e.threadId,e.seq)]),m=(0,a.sqliteTable)("thread_work",{id:(0,l.text)("id").primaryKey(),threadId:(0,l.text)("thread_id").notNull().references(()=>h.id,{onDelete:"cascade"}),bot:(0,l.text)("bot").notNull(),caller:(0,l.text)("caller").notNull(),parentId:(0,l.text)("parent_id"),state:(0,l.text)("state").notNull().$type(),generation:(0,n.int)("generation").notNull().default(0),contextBudget:(0,n.int)("context_budget").notNull().default(0),result:(0,l.text)("result"),options:(0,l.text)("options",{mode:"json"}).$type().notNull().default([]),createdAt:(0,n.int)("created_at",{mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},e=>[(0,i.index)("idx_thread_work_queue").on(e.threadId,e.state,e.createdAt),(0,i.index)("idx_thread_work_parent").on(e.parentId),(0,i.uniqueIndex)("uq_thread_work_running_bot").on(e.threadId,e.bot).where(t.sql`${e.state} = 'running'`)]),p=(0,a.sqliteTable)("thread_delivery",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),key:(0,l.text)("key").notNull().unique(),threadId:(0,l.text)("thread_id").notNull().references(()=>h.id,{onDelete:"cascade"}),workId:(0,l.text)("work_id").notNull().references(()=>m.id,{onDelete:"cascade"}),speaker:(0,l.text)("speaker").notNull(),text:(0,l.text)("text").notNull(),visible:(0,n.int)("visible",{mode:"boolean"}).notNull().default(!1),consumed:(0,n.int)("consumed",{mode:"boolean"}).notNull().default(!1)},e=>[(0,i.index)("idx_thread_delivery_inbox").on(e.workId,e.consumed,e.id)]),y=(0,a.sqliteTable)("thread_relay",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),key:(0,l.text)("key").notNull().unique(),threadId:(0,l.text)("thread_id").notNull().references(()=>h.id,{onDelete:"cascade"}),bot:(0,l.text)("bot").notNull(),text:(0,l.text)("text").notNull(),kind:(0,l.text)("kind").notNull().$type(),messageId:(0,l.text)("message_id"),accepted:(0,n.int)("accepted",{mode:"boolean"}).notNull().default(!1)}),g=(0,a.sqliteTable)("call",{id:(0,l.text)("id").primaryKey(),provider:(0,l.text)("provider").notNull(),model:(0,l.text)("model").notNull(),backendModel:(0,l.text)("backend_model"),startedAt:(0,n.int)("started_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),endedReason:(0,l.text)("ended_reason"),seconds:(0,n.int)("seconds"),endedAt:(0,n.int)("ended_at",{mode:"timestamp"})}),b=(0,a.sqliteTable)("call_message",{callId:(0,l.text)("call_id").notNull().references(()=>g.id,{onDelete:"cascade"}),id:(0,l.text)("id").notNull(),seq:(0,n.int)("seq").notNull(),role:(0,l.text)("role").notNull().$type(),tool:(0,l.text)("tool"),text:(0,l.text)("text").notNull(),fragments:(0,l.text)("fragments",{mode:"json"}).$type(),at:(0,n.int)("at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[(0,s.primaryKey)({columns:[e.callId,e.id]}),(0,i.index)("idx_call_message_call").on(e.callId,e.seq)]),q=(0,a.sqliteTable)("call_thought",{callId:(0,l.text)("call_id").notNull().references(()=>g.id,{onDelete:"cascade"}),id:(0,l.text)("id").notNull(),seq:(0,n.int)("seq").notNull(),text:(0,l.text)("text").notNull(),at:(0,n.int)("at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[(0,s.primaryKey)({columns:[e.callId,e.id]})]),w=(0,a.sqliteTable)("memory_note",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),path:(0,l.text)("path").notNull().unique(),description:(0,l.text)("description").notNull(),aliases:(0,l.text)("aliases",{mode:"json"}).$type().default([]),ownedByUser:(0,n.int)("owned_by_user",{mode:"boolean"}).notNull().default(!1),hits:(0,n.int)("hits").notNull().default(0),lastReadAt:(0,n.int)("last_read_at",{mode:"timestamp"}),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,n.int)("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),$=(0,a.sqliteTable)("memory_fact",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),noteId:(0,n.int)("note_id").notNull().references(()=>w.id,{onDelete:"cascade"}),text:(0,l.text)("text").notNull(),isLatest:(0,n.int)("is_latest",{mode:"boolean"}).notNull().default(!0),alwaysLoad:(0,n.int)("always_load",{mode:"boolean"}).notNull().default(!1),source:(0,l.text)("source").$type(),callId:(0,l.text)("call_id").references(()=>g.id,{onDelete:"set null"}),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[(0,i.index)("idx_memory_fact_note").on(e.noteId,e.isLatest),(0,i.index)("idx_memory_fact_always").on(e.alwaysLoad,e.isLatest),(0,i.index)("idx_memory_fact_call").on(e.callId)]),S=(0,a.sqliteTable)("routine",{id:(0,l.text)("id").primaryKey(),bot:(0,l.text)("bot").notNull(),label:(0,l.text)("label").notNull(),request:(0,l.text)("request").notNull(),schedule:(0,l.text)("schedule",{mode:"json"}).notNull().$type(),enabled:(0,n.int)("enabled",{mode:"boolean"}).notNull().default(!0),nextRunAt:(0,n.int)("next_run_at",{mode:"timestamp"}).notNull(),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[(0,i.index)("idx_routine_due").on(e.enabled,e.nextRunAt)]),v=(0,a.sqliteTable)("config",{key:(0,l.text)("key").primaryKey(),value:(0,l.text)("value").notNull()});e.s(["botMcpToolTable",0,d,"botTable",0,o,"callMessageTable",0,b,"callTable",0,g,"callThoughtTable",0,q,"configTable",0,v,"mcpServerTable",0,u,"mcpToolTable",0,c,"memoryFactTable",0,$,"memoryNoteTable",0,w,"routineTable",0,S,"threadDeliveryTable",0,p,"threadMessageTable",0,f,"threadRelayTable",0,y,"threadTable",0,h,"threadWorkTable",0,m])},41444,e=>{"use strict";function t(e,t){let i=e.replace(/\s+/g," ").trim();return i.length>t?`${i.slice(0,t-1).trimEnd()}…`:i}e.s(["PromiseChain",0,()=>{let e=Promise.resolve();return t=>{let i=e.then(()=>t());return e=i.catch(()=>{}),i}},"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:i,error:s}=e;if("string"==typeof i&&i)return i;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`}},"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()}])},999884,e=>{"use strict";var t=e.i(844988),i=e.i(518899),s=class{static [t.entityKind]="ConsoleLogWriter";write(e){console.log(e)}},r=class{static [t.entityKind]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new s}logQuery(e,t){let i=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),s=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${e}${s}`)}},n=class{static [t.entityKind]="NoopLogger";logQuery(){}},l=e.i(704313),a=class{static [t.entityKind]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}},o=i,u=class e extends o.SQL{static [t.entityKind]="SQLiteCountBuilder";dialect;session;static buildCount(e,t,i){let s=o.sql`select count(*) from ${e}${o.sql` where ${t}`.if(t)}`;return i?o.sql`(${s})`:s}constructor(t){super(e.buildCount(t.source,t.filters,!0).queryChunks),this.countConfig=t,this.dialect=t.dialect,this.session=t.session,this.mapWith(e=>"number"==typeof e?e:Number(e??0))}executableSql;build(){if(!this.executableSql){let{source:t,filters:i}=this.countConfig;this.executableSql=e.buildCount(t,i)}return this.dialect.sqlToQuery(this.executableSql)}},c=class extends u{static [t.entityKind]="SQLiteAsyncCountBuilder";constructor(e){super(e)}executeRaw(e){return this.session.prepareQuery(this.build(),"arrays",!1,"all",e=>{let t=e[0]?.[0];return"number"==typeof t?t:t?Number(t):0}).execute(e)}async execute(e){return await this.executeRaw(e)}};(0,l.applyMixins)(c,[a]);var d=class extends c{static [t.entityKind]="SQLiteSyncCountBuilder";sync(e){return this.executeRaw(e).sync()}},h=class{static [t.entityKind]="SQLiteRelationalQueryBuilderV2";constructor(e,t,i,s,r,n,l,a=f){this.mode=e,this.schema=t,this.table=i,this.tableConfig=s,this.dialect=r,this.session=n,this.forbidJsonb=l,this.builder=a}findMany(e){return new this.builder(this.mode,this.schema,this.table,this.tableConfig,this.dialect,this.session,e??!0,"many",this.forbidJsonb)}findFirst(e){return new this.builder(this.mode,this.schema,this.table,this.tableConfig,this.dialect,this.session,e??!0,"first",this.forbidJsonb)}},f=class{static [t.entityKind]="SQLiteRelationalQueryV2";mode;table;resultKind;constructor(e,t,i,s,r,n,l,a,o){this.schema=t,this.tableConfig=s,this.dialect=r,this.session=n,this.config=l,this.forbidJsonb=o,this.resultKind=e,this.mode=a,this.table=i}getSQL(){return this._getQuery().sql}_getQuery(){let e=this.forbidJsonb?i.sql`json`:i.sql`jsonb`;return this.dialect.buildRelationalQuery({schema:this.schema,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,mode:this.mode,jsonb:e})}_toSQL(){let e=this._getQuery();return{query:e,builtQuery:this.dialect.sqlToQuery(e.sql)}}toSQL(){return this._toSQL().builtQuery}},m=class extends f{static [t.entityKind]="SQLiteAsyncRelationalQueryV2";_prepare(e=!1){let{query:t,builtQuery:i}=this._toSQL(),s=this.dialect.mapperGenerators.relationalRows({isFirst:"first"===this.mode,parseJson:!0,parseJsonIfString:!1,rootJsonMappers:!1,selection:t.selection,arrayModeRoot:!0});return this.session.prepareQuery(i,"arrays",e,"all",s)}prepare(){return this._prepare(!0)}async execute(e){return this._prepare().execute(e)}},p=class extends m{static [t.entityKind]="SQLiteSyncRelationalQueryV2";sync(e){return this._prepare().execute(e).sync()}};(0,l.applyMixins)(m,[a]);var y=e.i(792352),g=e.i(156325),b=e.i(88274),q=e.i(923277),w=e.i(369e3),$=class{static [t.entityKind]="ColumnTableAliasProxyHandler";constructor(e,t){this.table=e,this.ignoreColumnAlias=t}get(e,t){return"table"===t?this.table:("isAlias"!==t||!this.ignoreColumnAlias)&&e[t]}},S=class{static [t.entityKind]="ViewSelectionAliasProxyHandler";constructor(e,t,i){this.view=e,this.selection=t,this.ignoreColumnAlias=i}get(e,s){let r=e[s];return(0,t.is)(r,g.Column)?new Proxy(r,new $(this.view,this.ignoreColumnAlias)):(0,t.is)(r,y.Subquery)||(0,t.is)(r,i.SQL)||(0,t.is)(r,i.SQL.Aliased)||(0,i.isSQLWrapper)(r)||"object"!=typeof r||null===r?r:new Proxy(r,this)}},v=class{static [t.entityKind]="TableAliasProxyHandler";constructor(e,t,i){this.alias=e,this.replaceOriginalName=t,this.ignoreColumnAlias=i}get(e,s){if(s===w.Table.Symbol.IsAlias)return!0;if(s===w.Table.Symbol.Name||this.replaceOriginalName&&s===w.Table.Symbol.OriginalName)return this.alias;if(s===b.ViewBaseConfig)return{...e[b.ViewBaseConfig],name:this.alias,isAlias:!0,selectedFields:new Proxy(e[b.ViewBaseConfig].selectedFields,new S(new Proxy(e,this),e[b.ViewBaseConfig].selectedFields,this.ignoreColumnAlias))};if(s===w.Table.Symbol.Columns){let s=e[w.Table.Symbol.Columns];if(!s)return s;if((0,t.is)(e,i.View))return new Proxy(e[w.Table.Symbol.Columns],new S(new Proxy(e,this),e[w.Table.Symbol.Columns],this.ignoreColumnAlias));let r={};return Object.keys(s).map(t=>{r[t]=new Proxy(s[t],new $(new Proxy(e,this),this.ignoreColumnAlias))}),r}let r=e[s];return(0,t.is)(r,g.Column)?new Proxy(r,new $(new Proxy(e,this),this.ignoreColumnAlias)):r}},x=class{static [t.entityKind]="ColumnAliasProxyHandler";constructor(e){this.alias=e}get(e,t){return"isAlias"===t||("name"===t?this.alias:"keyAsName"!==t&&(t===q.OriginalColumn?()=>e:e[t]))}};function Q(e,t){return new Proxy(e,new v(t,!1,!1))}function N(e){return e[q.OriginalColumn]()}t.entityKind,g.Column.prototype.as=function(e){return new Proxy(this,new x(e))};var L=class e{static [t.entityKind]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(s,r){if("_"===r)return{...s._,selectedFields:new Proxy(s._.selectedFields,this)};if(r===b.ViewBaseConfig)return{...s[b.ViewBaseConfig],selectedFields:new Proxy(s[b.ViewBaseConfig].selectedFields,this)};if("symbol"==typeof r)return s[r];let n=((0,t.is)(s,y.Subquery)?s._.selectedFields:(0,t.is)(s,i.View)?s[b.ViewBaseConfig].selectedFields:s)[r];if((0,t.is)(n,i.SQL.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!n.isSelectionField)return n.sql;let e=n.clone();return e.isSelectionField=!0,e.origin=this.config.alias,e}if((0,t.is)(n,i.SQL)){if("sql"===this.config.sqlBehavior)return n;throw Error(`You tried to reference "${r}" 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,t.is)(n,g.Column)?this.config.alias?new Proxy(n,new $(new Proxy(n.table,new v(this.config.alias,this.config.replaceOriginalName??!1,!0)),!0)):n:"object"!=typeof n||null===n?n:new Proxy(n,new e(this.config))}},T=e.i(75799);function C(e){return(0,t.is)(e,T.SQLiteTable)?[`${e[w.Table.Symbol.BaseName]}`]:(0,t.is)(e,y.Subquery)?e._.usedTables??[]:(0,t.is)(e,i.SQL)?e.usedTables??[]:[]}t.entityKind,t.entityKind,e.i(361328),e.i(646683),e.i(201440),e.i(616918);var _=class{static [t.entityKind]="SQLiteDelete";config;constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.config={table:e,withList:s}}where(e){return this.config.where=e,this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[w.Table.Symbol.Columns],new L({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.table[T.SQLiteTable.Symbol.Columns]){return this.config.returning=(0,l.orderSelectedFields)(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}$dynamic(){return this}},A=class extends _{static [t.entityKind]="SQLiteAsyncDelete";_prepare(e=!1){return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),"arrays",e,this.config.returning?"all":"run",this.config.returning?this.dialect.mapperGenerators.rows(this.config.returning,void 0):void 0,{type:"delete",tables:C(this.config.table)})}prepare(){return this._prepare(!0)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}};(0,l.applyMixins)(A,[a]);var j=i,B=class extends j.View{static [t.entityKind]="SQLiteViewBase"},F=class{static [t.entityKind]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}withoutSelectionCastCodecs(){return this}},K=class{static [t.entityKind]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e,t=D){this.builder=t,this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let s,r=!!this.fields;return s=this.fields?this.fields:(0,t.is)(e,y.Subquery)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):(0,t.is)(e,B)?e[b.ViewBaseConfig].selectedFields:(0,t.is)(e,i.SQL)?{}:(0,l.getTableColumns)(e),new this.builder({table:e,fields:s,isPartialSelect:r,session:this.session,dialect:this.dialect,withList:this.withList??[],distinct:this.distinct})}},D=class extends F{static [t.entityKind]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:i,session:s,dialect:r,withList:n,distinct:a}){for(const o of(super(),this.config={withList:n,table:e,fields:{...t},distinct:a,setOperators:[]},this.isPartialSelect=i,this.session=s,this.dialect=r,this._={selectedFields:t,config:this.config},this.tableName=(0,l.getTableLikeName)(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{},C(e)))this.usedTables.add(o)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(s,r)=>{let n=this.tableName,a=(0,l.getTableLikeName)(s);for(let e of C(s))this.usedTables.add(e);if("string"==typeof a&&this.config.joins?.some(e=>e.alias===a))throw Error(`Alias "${a}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof n&&(this.config.fields={[n]:this.config.fields}),"string"==typeof a&&!(0,t.is)(s,i.SQL))){let e=(0,t.is)(s,y.Subquery)?s._.selectedFields:(0,t.is)(s,i.View)?s[b.ViewBaseConfig].selectedFields:s[w.Table.Symbol.Columns];this.config.fields[a]=e}if("function"==typeof r&&(r=r(new Proxy(this.config.fields,new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:r,table:s,joinType:e,alias:a}),"string"==typeof a)switch(e){case"left":this.joinsNotNullableMap[a]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[a]=!0;break;case"cross":case"inner":this.joinsNotNullableMap[a]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[a]=!1}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(e,t){return i=>{let s="function"==typeof i?i(O()):i;if(!(0,l.haveSameKeys)(this.getSelectedFields(),s.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:e,isAll:t,rightSelect:s}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new L({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new L({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i}else this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=e:this.config.orderBy=e;return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}$withCache(e){return this.cacheConfig=void 0===e?{config:{},enabled:!0,autoInvalidate:!0}:!1===e?{enabled:!1}:{enabled:!0,autoInvalidate:!0,...e},this}getSQL(){return this.config.fieldsFlat=(0,l.orderSelectedFields)(this.config.fields),this.dialect.buildSelectQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}as(e){let t=[];if(t.push(...C(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...C(e.table));return new Proxy(new y.Subquery(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new L({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new L({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}withoutSelectionCastCodecs(){return this}$dynamic(){return this}};function k(e,t){return(i,s,...r)=>{let n=[s,...r].map(i=>({type:e,isAll:t,rightSelect:i}));for(let e of n)if(!(0,l.haveSameKeys)(i.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return i.addSetOperators(n)}}let O=()=>({union:I,unionAll:P,intersect:V,except:J}),I=k("union",!1),P=k("union",!0),V=k("intersect",!1),J=k("except",!1);var E=class extends Error{static [t.entityKind]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}},z=class e extends Error{static [t.entityKind]="DrizzleQueryError";constructor(t,i,s){super(`Failed query: ${t}
1
+ module.exports=[528790,e=>e.a(async(t,i)=>{try{let h,f;var s,r=e.i(902157),n=e.i(750227),l=e.i(418520),a=e.i(219756),o=e.i(687388),u=e.i(41444),c=t([l,a]);[l,a]=c.then?(await c)():c;let m=o.DB_FILE_NAME.replace(/^file:/,"");(0,r.mkdirSync)((0,n.dirname)(m),{recursive:!0});let p=globalThis.__dbClient??=(s=((h=(0,l.createClient)({url:o.DB_FILE_NAME,timeout:5e3})).execute("PRAGMA journal_mode = WAL").finally(d),h),f=(0,u.PromiseChain)(),{...s,execute:(...e)=>f(()=>s.execute(...e)),batch:(...e)=>f(()=>s.batch(...e)),executeMultiple:(...e)=>f(()=>s.executeMultiple(...e)),migrate:(...e)=>f(()=>s.migrate(...e)),async transaction(...e){let t,i=await new Promise(e=>{let t,i=new Promise(e=>{t=e});f(async()=>{e(t),await i})});try{t=await s.transaction(...e)}catch(e){throw i(),e}let r=!1,n=()=>{r||(r=!0,i())};return{execute:(...e)=>t.execute(...e),batch:(...e)=>t.batch(...e),executeMultiple:(...e)=>t.executeMultiple(...e),get closed(){return t.closed},commit:()=>t.commit().finally(n),rollback:()=>t.rollback().finally(n),close:()=>{try{t.close()}finally{n()}}}}});function d(){for(let e of[m,`${m}-wal`,`${m}-shm`])try{(0,r.chmodSync)(e,384)}catch{}}let y=(0,a.drizzle)({client:p});e.s(["database",0,y]),i()}catch(e){i(e)}},!1),613240,e=>{"use strict";var t=e.i(518899),i=e.i(646683),s=e.i(201440),r=e.i(616918),n=e.i(937540),l=e.i(380568),a=e.i(75799);let o=(0,a.sqliteTable)("bot",{name:(0,l.text)("name").primaryKey(),description:(0,l.text)("description").notNull(),systemPrompt:(0,l.text)("system_prompt"),icon:(0,l.text)("icon",{mode:"json"}).$type(),provider:(0,l.text)("provider").$type(),model:(0,l.text)("model"),compactAt:(0,n.int)("compact_at"),disabled:(0,n.int)("disabled",{mode:"boolean"}).notNull().default(!1),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),u=(0,a.sqliteTable)("mcp_server",{name:(0,l.text)("name").primaryKey(),config:(0,l.text)("config",{mode:"json"}).notNull().$type(),toolsSyncedAt:(0,n.int)("tools_synced_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),lastError:(0,l.text)("last_error"),oauth:(0,l.text)("oauth",{mode:"json"}).$type(),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),c=(0,a.sqliteTable)("mcp_tool",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),serverName:(0,l.text)("server_name").notNull().references(()=>u.name,{onDelete:"cascade"}),name:(0,l.text)("name").notNull(),description:(0,l.text)("description"),inputSchema:(0,l.text)("input_schema",{mode:"json"}).$type(),outputSchema:(0,l.text)("output_schema",{mode:"json"}).$type()},e=>[(0,r.unique)("uq_mcp_tool_server_name").on(e.serverName,e.name)]),d=(0,a.sqliteTable)("bot_mcp_tool",{botName:(0,l.text)().notNull().references(()=>o.name,{onDelete:"cascade"}),toolId:(0,n.int)("tool_id").notNull().references(()=>c.id,{onDelete:"cascade"})},e=>[(0,s.primaryKey)({columns:[e.botName,e.toolId]})]),h=(0,a.sqliteTable)("thread",{id:(0,l.text)("id").primaryKey(),bot:(0,l.text)("bot").notNull(),label:(0,l.text)("label").notNull(),request:(0,l.text)("request").notNull(),status:(0,l.text)("status").notNull().$type(),generation:(0,n.int)("generation").notNull().default(0),turns:(0,n.int)("turns").notNull().default(0),wrapped:(0,n.int)("wrapped",{mode:"boolean"}).notNull().default(!1),outcome:(0,l.text)("outcome"),pending:(0,l.text)("pending",{mode:"json"}).$type(),seen:(0,n.int)("seen",{mode:"boolean"}).notNull().default(!1),callId:(0,l.text)("call_id"),routineId:(0,l.text)("routine_id"),inputTokens:(0,n.int)("input_tokens").notNull().default(0),outputTokens:(0,n.int)("output_tokens").notNull().default(0),contextTokens:(0,n.int)("context_tokens").notNull().default(0),contextBudget:(0,n.int)("context_budget").notNull().default(0),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,n.int)("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),endedAt:(0,n.int)("ended_at",{mode:"timestamp"})},e=>[(0,i.index)("idx_thread_routine").on(e.routineId,e.createdAt),(0,i.index)("idx_thread_status_updated").on(e.status,e.updatedAt)]),f=(0,a.sqliteTable)("thread_message",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),threadId:(0,l.text)("thread_id").notNull().references(()=>h.id,{onDelete:"cascade"}),seq:(0,n.int)("seq").notNull(),bot:(0,l.text)("bot"),parent:(0,l.text)("parent"),hidden:(0,n.int)("hidden",{mode:"boolean"}).notNull().default(!1),role:(0,l.text)("role").notNull().$type(),content:(0,l.text)("content",{mode:"json"}).notNull().$type(),compact:(0,n.int)("compact",{mode:"boolean"}).notNull().default(!1),note:(0,n.int)("note",{mode:"boolean"}).notNull().default(!1),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[(0,r.unique)("uq_thread_message_seq").on(e.threadId,e.seq)]),m=(0,a.sqliteTable)("thread_work",{id:(0,l.text)("id").primaryKey(),threadId:(0,l.text)("thread_id").notNull().references(()=>h.id,{onDelete:"cascade"}),bot:(0,l.text)("bot").notNull(),caller:(0,l.text)("caller").notNull(),parentId:(0,l.text)("parent_id"),state:(0,l.text)("state").notNull().$type(),generation:(0,n.int)("generation").notNull().default(0),contextBudget:(0,n.int)("context_budget").notNull().default(0),result:(0,l.text)("result"),options:(0,l.text)("options",{mode:"json"}).$type().notNull().default([]),createdAt:(0,n.int)("created_at",{mode:"timestamp_ms"}).notNull().$defaultFn(()=>new Date)},e=>[(0,i.index)("idx_thread_work_queue").on(e.threadId,e.state,e.createdAt),(0,i.index)("idx_thread_work_parent").on(e.parentId),(0,i.uniqueIndex)("uq_thread_work_running_bot").on(e.threadId,e.bot).where(t.sql`${e.state} = 'running'`)]),p=(0,a.sqliteTable)("thread_delivery",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),key:(0,l.text)("key").notNull().unique(),threadId:(0,l.text)("thread_id").notNull().references(()=>h.id,{onDelete:"cascade"}),workId:(0,l.text)("work_id").notNull().references(()=>m.id,{onDelete:"cascade"}),speaker:(0,l.text)("speaker").notNull(),text:(0,l.text)("text").notNull(),visible:(0,n.int)("visible",{mode:"boolean"}).notNull().default(!1),consumed:(0,n.int)("consumed",{mode:"boolean"}).notNull().default(!1)},e=>[(0,i.index)("idx_thread_delivery_inbox").on(e.workId,e.consumed,e.id)]),y=(0,a.sqliteTable)("thread_relay",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),key:(0,l.text)("key").notNull().unique(),threadId:(0,l.text)("thread_id").notNull().references(()=>h.id,{onDelete:"cascade"}),bot:(0,l.text)("bot").notNull(),text:(0,l.text)("text").notNull(),kind:(0,l.text)("kind").notNull().$type(),messageId:(0,l.text)("message_id"),accepted:(0,n.int)("accepted",{mode:"boolean"}).notNull().default(!1)}),g=(0,a.sqliteTable)("call",{id:(0,l.text)("id").primaryKey(),provider:(0,l.text)("provider").notNull(),model:(0,l.text)("model").notNull(),backendModel:(0,l.text)("backend_model"),startedAt:(0,n.int)("started_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),endedReason:(0,l.text)("ended_reason"),seconds:(0,n.int)("seconds"),endedAt:(0,n.int)("ended_at",{mode:"timestamp"})}),b=(0,a.sqliteTable)("call_message",{callId:(0,l.text)("call_id").notNull().references(()=>g.id,{onDelete:"cascade"}),id:(0,l.text)("id").notNull(),seq:(0,n.int)("seq").notNull(),role:(0,l.text)("role").notNull().$type(),tool:(0,l.text)("tool"),text:(0,l.text)("text").notNull(),fragments:(0,l.text)("fragments",{mode:"json"}).$type(),at:(0,n.int)("at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[(0,s.primaryKey)({columns:[e.callId,e.id]}),(0,i.index)("idx_call_message_call").on(e.callId,e.seq)]),q=(0,a.sqliteTable)("call_thought",{callId:(0,l.text)("call_id").notNull().references(()=>g.id,{onDelete:"cascade"}),id:(0,l.text)("id").notNull(),seq:(0,n.int)("seq").notNull(),text:(0,l.text)("text").notNull(),at:(0,n.int)("at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[(0,s.primaryKey)({columns:[e.callId,e.id]})]),w=(0,a.sqliteTable)("memory_note",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),path:(0,l.text)("path").notNull().unique(),description:(0,l.text)("description").notNull(),aliases:(0,l.text)("aliases",{mode:"json"}).$type().default([]),ownedByUser:(0,n.int)("owned_by_user",{mode:"boolean"}).notNull().default(!1),hits:(0,n.int)("hits").notNull().default(0),lastReadAt:(0,n.int)("last_read_at",{mode:"timestamp"}),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),updatedAt:(0,n.int)("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),$=(0,a.sqliteTable)("memory_fact",{id:(0,n.int)("id").primaryKey({autoIncrement:!0}),noteId:(0,n.int)("note_id").notNull().references(()=>w.id,{onDelete:"cascade"}),text:(0,l.text)("text").notNull(),isLatest:(0,n.int)("is_latest",{mode:"boolean"}).notNull().default(!0),alwaysLoad:(0,n.int)("always_load",{mode:"boolean"}).notNull().default(!1),source:(0,l.text)("source").$type(),callId:(0,l.text)("call_id").references(()=>g.id,{onDelete:"set null"}),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[(0,i.index)("idx_memory_fact_note").on(e.noteId,e.isLatest),(0,i.index)("idx_memory_fact_always").on(e.alwaysLoad,e.isLatest),(0,i.index)("idx_memory_fact_call").on(e.callId)]),S=(0,a.sqliteTable)("routine",{id:(0,l.text)("id").primaryKey(),bot:(0,l.text)("bot").notNull(),label:(0,l.text)("label").notNull(),request:(0,l.text)("request").notNull(),schedule:(0,l.text)("schedule",{mode:"json"}).notNull().$type(),enabled:(0,n.int)("enabled",{mode:"boolean"}).notNull().default(!0),nextRunAt:(0,n.int)("next_run_at",{mode:"timestamp"}).notNull(),createdAt:(0,n.int)("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>[(0,i.index)("idx_routine_due").on(e.enabled,e.nextRunAt)]),v=(0,a.sqliteTable)("config",{key:(0,l.text)("key").primaryKey(),value:(0,l.text)("value").notNull()});e.s(["botMcpToolTable",0,d,"botTable",0,o,"callMessageTable",0,b,"callTable",0,g,"callThoughtTable",0,q,"configTable",0,v,"mcpServerTable",0,u,"mcpToolTable",0,c,"memoryFactTable",0,$,"memoryNoteTable",0,w,"routineTable",0,S,"threadDeliveryTable",0,p,"threadMessageTable",0,f,"threadRelayTable",0,y,"threadTable",0,h,"threadWorkTable",0,m])},41444,e=>{"use strict";function t(e,t){let i=e.replace(/\s+/g," ").trim();return i.length>t?`${i.slice(0,t-1).trimEnd()}…`:i}e.s(["PromiseChain",0,()=>{let e=Promise.resolve();return t=>{let i=e.then(()=>t());return e=i.catch(()=>{}),i}},"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:i,error:s}=e;if("string"==typeof i&&i)return i;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`}},"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()}])},999884,e=>{"use strict";var t=e.i(844988),i=e.i(518899),s=class{static [t.entityKind]="ConsoleLogWriter";write(e){console.log(e)}},r=class{static [t.entityKind]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new s}logQuery(e,t){let i=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),s=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${e}${s}`)}},n=class{static [t.entityKind]="NoopLogger";logQuery(){}},l=e.i(704313),a=class{static [t.entityKind]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}},o=i,u=class e extends o.SQL{static [t.entityKind]="SQLiteCountBuilder";dialect;session;static buildCount(e,t,i){let s=o.sql`select count(*) from ${e}${o.sql` where ${t}`.if(t)}`;return i?o.sql`(${s})`:s}constructor(t){super(e.buildCount(t.source,t.filters,!0).queryChunks),this.countConfig=t,this.dialect=t.dialect,this.session=t.session,this.mapWith(e=>"number"==typeof e?e:Number(e??0))}executableSql;build(){if(!this.executableSql){let{source:t,filters:i}=this.countConfig;this.executableSql=e.buildCount(t,i)}return this.dialect.sqlToQuery(this.executableSql)}},c=class extends u{static [t.entityKind]="SQLiteAsyncCountBuilder";constructor(e){super(e)}executeRaw(e){return this.session.prepareQuery(this.build(),"arrays",!1,"all",e=>{let t=e[0]?.[0];return"number"==typeof t?t:t?Number(t):0}).execute(e)}async execute(e){return await this.executeRaw(e)}};(0,l.applyMixins)(c,[a]);var d=class extends c{static [t.entityKind]="SQLiteSyncCountBuilder";sync(e){return this.executeRaw(e).sync()}},h=class{static [t.entityKind]="SQLiteRelationalQueryBuilderV2";constructor(e,t,i,s,r,n,l,a=f){this.mode=e,this.schema=t,this.table=i,this.tableConfig=s,this.dialect=r,this.session=n,this.forbidJsonb=l,this.builder=a}findMany(e){return new this.builder(this.mode,this.schema,this.table,this.tableConfig,this.dialect,this.session,e??!0,"many",this.forbidJsonb)}findFirst(e){return new this.builder(this.mode,this.schema,this.table,this.tableConfig,this.dialect,this.session,e??!0,"first",this.forbidJsonb)}},f=class{static [t.entityKind]="SQLiteRelationalQueryV2";mode;table;resultKind;constructor(e,t,i,s,r,n,l,a,o){this.schema=t,this.tableConfig=s,this.dialect=r,this.session=n,this.config=l,this.forbidJsonb=o,this.resultKind=e,this.mode=a,this.table=i}getSQL(){return this._getQuery().sql}_getQuery(){let e=this.forbidJsonb?i.sql`json`:i.sql`jsonb`;return this.dialect.buildRelationalQuery({schema:this.schema,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,mode:this.mode,jsonb:e})}_toSQL(){let e=this._getQuery();return{query:e,builtQuery:this.dialect.sqlToQuery(e.sql)}}toSQL(){return this._toSQL().builtQuery}},m=class extends f{static [t.entityKind]="SQLiteAsyncRelationalQueryV2";_prepare(e=!1){let{query:t,builtQuery:i}=this._toSQL(),s=this.dialect.mapperGenerators.relationalRows({isFirst:"first"===this.mode,parseJson:!0,parseJsonIfString:!1,rootJsonMappers:!1,selection:t.selection,arrayModeRoot:!0});return this.session.prepareQuery(i,"arrays",e,"all",s)}prepare(){return this._prepare(!0)}async execute(e){return this._prepare().execute(e)}},p=class extends m{static [t.entityKind]="SQLiteSyncRelationalQueryV2";sync(e){return this._prepare().execute(e).sync()}};(0,l.applyMixins)(m,[a]);var y=e.i(792352),g=e.i(156325),b=e.i(88274),q=e.i(923277),w=e.i(369e3),$=class{static [t.entityKind]="ColumnTableAliasProxyHandler";constructor(e,t){this.table=e,this.ignoreColumnAlias=t}get(e,t){return"table"===t?this.table:("isAlias"!==t||!this.ignoreColumnAlias)&&e[t]}},S=class{static [t.entityKind]="ViewSelectionAliasProxyHandler";constructor(e,t,i){this.view=e,this.selection=t,this.ignoreColumnAlias=i}get(e,s){let r=e[s];return(0,t.is)(r,g.Column)?new Proxy(r,new $(this.view,this.ignoreColumnAlias)):(0,t.is)(r,y.Subquery)||(0,t.is)(r,i.SQL)||(0,t.is)(r,i.SQL.Aliased)||(0,i.isSQLWrapper)(r)||"object"!=typeof r||null===r?r:new Proxy(r,this)}},v=class{static [t.entityKind]="TableAliasProxyHandler";constructor(e,t,i){this.alias=e,this.replaceOriginalName=t,this.ignoreColumnAlias=i}get(e,s){if(s===w.Table.Symbol.IsAlias)return!0;if(s===w.Table.Symbol.Name||this.replaceOriginalName&&s===w.Table.Symbol.OriginalName)return this.alias;if(s===b.ViewBaseConfig)return{...e[b.ViewBaseConfig],name:this.alias,isAlias:!0,selectedFields:new Proxy(e[b.ViewBaseConfig].selectedFields,new S(new Proxy(e,this),e[b.ViewBaseConfig].selectedFields,this.ignoreColumnAlias))};if(s===w.Table.Symbol.Columns){let s=e[w.Table.Symbol.Columns];if(!s)return s;if((0,t.is)(e,i.View))return new Proxy(e[w.Table.Symbol.Columns],new S(new Proxy(e,this),e[w.Table.Symbol.Columns],this.ignoreColumnAlias));let r={};return Object.keys(s).map(t=>{r[t]=new Proxy(s[t],new $(new Proxy(e,this),this.ignoreColumnAlias))}),r}let r=e[s];return(0,t.is)(r,g.Column)?new Proxy(r,new $(new Proxy(e,this),this.ignoreColumnAlias)):r}},x=class{static [t.entityKind]="ColumnAliasProxyHandler";constructor(e){this.alias=e}get(e,t){return"isAlias"===t||("name"===t?this.alias:"keyAsName"!==t&&(t===q.OriginalColumn?()=>e:e[t]))}};function Q(e,t){return new Proxy(e,new v(t,!1,!1))}function N(e){return e[q.OriginalColumn]()}t.entityKind,g.Column.prototype.as=function(e){return new Proxy(this,new x(e))};var L=class e{static [t.entityKind]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(s,r){if("_"===r)return{...s._,selectedFields:new Proxy(s._.selectedFields,this)};if(r===b.ViewBaseConfig)return{...s[b.ViewBaseConfig],selectedFields:new Proxy(s[b.ViewBaseConfig].selectedFields,this)};if("symbol"==typeof r)return s[r];let n=((0,t.is)(s,y.Subquery)?s._.selectedFields:(0,t.is)(s,i.View)?s[b.ViewBaseConfig].selectedFields:s)[r];if((0,t.is)(n,i.SQL.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!n.isSelectionField)return n.sql;let e=n.clone();return e.isSelectionField=!0,e.origin=this.config.alias,e}if((0,t.is)(n,i.SQL)){if("sql"===this.config.sqlBehavior)return n;throw Error(`You tried to reference "${r}" 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,t.is)(n,g.Column)?this.config.alias?new Proxy(n,new $(new Proxy(n.table,new v(this.config.alias,this.config.replaceOriginalName??!1,!0)),!0)):n:"object"!=typeof n||null===n?n:new Proxy(n,new e(this.config))}},T=e.i(75799);function C(e){return(0,t.is)(e,T.SQLiteTable)?[`${e[w.Table.Symbol.BaseName]}`]:(0,t.is)(e,y.Subquery)?e._.usedTables??[]:(0,t.is)(e,i.SQL)?e.usedTables??[]:[]}t.entityKind,t.entityKind,e.i(361328),e.i(646683),e.i(201440),e.i(616918);var _=class{static [t.entityKind]="SQLiteDelete";config;constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.config={table:e,withList:s}}where(e){return this.config.where=e,this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[w.Table.Symbol.Columns],new L({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.table[T.SQLiteTable.Symbol.Columns]){return this.config.returning=(0,l.orderSelectedFields)(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}$dynamic(){return this}},A=class extends _{static [t.entityKind]="SQLiteAsyncDelete";_prepare(e=!1){return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),"arrays",e,this.config.returning?"all":"run",this.config.returning?this.dialect.mapperGenerators.rows(this.config.returning,void 0):void 0,{type:"delete",tables:C(this.config.table)})}prepare(){return this._prepare(!0)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}};(0,l.applyMixins)(A,[a]);var j=i,B=class extends j.View{static [t.entityKind]="SQLiteViewBase"},F=class{static [t.entityKind]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}withoutSelectionCastCodecs(){return this}},K=class{static [t.entityKind]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e,t=D){this.builder=t,this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let s,r=!!this.fields;return s=this.fields?this.fields:(0,t.is)(e,y.Subquery)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):(0,t.is)(e,B)?e[b.ViewBaseConfig].selectedFields:(0,t.is)(e,i.SQL)?{}:(0,l.getTableColumns)(e),new this.builder({table:e,fields:s,isPartialSelect:r,session:this.session,dialect:this.dialect,withList:this.withList??[],distinct:this.distinct})}},D=class extends F{static [t.entityKind]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:i,session:s,dialect:r,withList:n,distinct:a}){for(const o of(super(),this.config={withList:n,table:e,fields:{...t},distinct:a,setOperators:[]},this.isPartialSelect=i,this.session=s,this.dialect=r,this._={selectedFields:t,config:this.config},this.tableName=(0,l.getTableLikeName)(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{},C(e)))this.usedTables.add(o)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(s,r)=>{let n=this.tableName,a=(0,l.getTableLikeName)(s);for(let e of C(s))this.usedTables.add(e);if("string"==typeof a&&this.config.joins?.some(e=>e.alias===a))throw Error(`Alias "${a}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof n&&(this.config.fields={[n]:this.config.fields}),"string"==typeof a&&!(0,t.is)(s,i.SQL))){let e=(0,t.is)(s,y.Subquery)?s._.selectedFields:(0,t.is)(s,i.View)?s[b.ViewBaseConfig].selectedFields:s[w.Table.Symbol.Columns];this.config.fields[a]=e}if("function"==typeof r&&(r=r(new Proxy(this.config.fields,new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:r,table:s,joinType:e,alias:a}),"string"==typeof a)switch(e){case"left":this.joinsNotNullableMap[a]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[a]=!0;break;case"cross":case"inner":this.joinsNotNullableMap[a]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[a]=!1}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(e,t){return i=>{let s="function"==typeof i?i(O()):i;if(!(0,l.haveSameKeys)(this.getSelectedFields(),s.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:e,isAll:t,rightSelect:s}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new L({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new L({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new L({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i}else this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=e:this.config.orderBy=e;return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}$withCache(e){return this.cacheConfig=void 0===e?{config:{},enabled:!0,autoInvalidate:!0}:!1===e?{enabled:!1}:{enabled:!0,autoInvalidate:!0,...e},this}getSQL(){return this.config.fieldsFlat=(0,l.orderSelectedFields)(this.config.fields),this.dialect.buildSelectQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}as(e){let t=[];if(t.push(...C(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...C(e.table));return new Proxy(new y.Subquery(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new L({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new L({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}withoutSelectionCastCodecs(){return this}$dynamic(){return this}};function k(e,t){return(i,s,...r)=>{let n=[s,...r].map(i=>({type:e,isAll:t,rightSelect:i}));for(let e of n)if(!(0,l.haveSameKeys)(i.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return i.addSetOperators(n)}}let O=()=>({union:I,unionAll:P,intersect:V,except:J}),I=k("union",!1),P=k("union",!0),V=k("intersect",!1),J=k("except",!1);var E=class extends Error{static [t.entityKind]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}},z=class e extends Error{static [t.entityKind]="DrizzleQueryError";constructor(t,i,s){super(`Failed query: ${t}
2
2
  params: ${i}`),this.query=t,this.params=i,this.cause=s,this.name="DrizzleQueryError",Error.captureStackTrace(this,e),s&&(this.cause=s)}},U=class extends E{static [t.entityKind]="TransactionRollbackError";constructor(){super({message:"Rollback"}),this.name="TransactionRollbackError"}},M=e.i(875225),R=e.i(349129),W=class{static [t.entityKind]="RelationV2";fieldName;sourceColumns;targetColumns;alias;where;sourceTable;targetTable;through;throughTable;isReversed;sourceColumnTableNames=[];targetColumnTableNames=[];constructor(e,t){this.targetTableName=t,this.targetTable=e}},G=class extends W{static [t.entityKind]="OneV2";relationType="one";optional;constructor(e,t,i,s){super(t,i),this.alias=s?.alias,this.where=s?.where,s?.from&&(this.sourceColumns=(Array.isArray(s.from)?s.from:[s.from]).map(t=>(this.throughTable??=t._.through?e[t._.through._.tableName]:void 0,this.sourceColumnTableNames.push(t._.tableName),t._.column))),s?.to&&(this.targetColumns=(Array.isArray(s.to)?s.to:[s.to]).map(t=>(this.throughTable??=t._.through?e[t._.through._.tableName]:void 0,this.targetColumnTableNames.push(t._.tableName),t._.column))),this.throughTable&&(this.through={source:(Array.isArray(s?.from)?s.from:s?.from?[s.from]:[]).map(e=>e._.through),target:(Array.isArray(s?.to)?s.to:s?.to?[s.to]:[]).map(e=>e._.through)}),this.optional=s?.optional??!0}},H=(t.entityKind,class{static [t.entityKind]="AggregatedField";table;onTable(e){return this.table=e,this}});t.entityKind;let Z={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:i.sql},Y={sql:i.sql,asc:R.asc,desc:R.desc};function X(e,s,r,n=!1,l=!1,a=!0){let o=s?1:e.length,u=r.map(({field:e,codec:s,arrayDimensions:r})=>{let n;return(n=(0,t.is)(e,g.Column)?e:(0,t.is)(e,i.SQL)?e.decoder:(0,t.is)(e,i.SQL.Aliased)?e.sql.decoder:(0,t.is)(e,w.Table)||(0,t.is)(e,i.View)?i.noopDecoder:e.getSQL().decoder,a&&e.mapFromJsonValue)?t=>e.mapFromJsonValue(t):n.mapFromDriverValue.isNoop?s?e=>s(e,r):void 0:s?e=>n.mapFromDriverValue(s(e,r)):e=>n.mapFromDriverValue(e)});for(let t=0;t<o;++t){let i=s?e:e[t];for(let e=0;e<r.length;++e){let t=r[e];if(t.selection){if(null===i[t.key])continue;if(n){if(i[t.key]=JSON.parse(i[t.key]),null===i[t.key])continue}else l&&"string"==typeof i[t.key]&&(i[t.key]=JSON.parse(i[t.key]));if(t.isArray){X(i[t.key],!1,t.selection,!1,l);continue}X(i[t.key],!0,t.selection,!1,l);continue}if(null===i[t.key])continue;let s=u[e];s&&(i[t.key]=s(i[t.key]))}}return e}function ee({selection:e,isFirst:s,parseJson:r,parseJsonIfString:n,rootJsonMappers:l,arrayModeRoot:a}){return o=>s&&!o[0]?o[0]:a?function(e,s,r,n=!1,l=!1){let a=s?1:e.length,o=r.map(({field:e,codec:s,arrayDimensions:r})=>{let n;return(n=(0,t.is)(e,g.Column)?e:(0,t.is)(e,i.SQL)?e.decoder:(0,t.is)(e,i.SQL.Aliased)?e.sql.decoder:(0,t.is)(e,w.Table)||(0,t.is)(e,i.View)?i.noopDecoder:e.getSQL().decoder).mapFromDriverValue.isNoop?s?e=>s(e,r):void 0:s?e=>n.mapFromDriverValue(s(e,r)):e=>n.mapFromDriverValue(e)}),u=Array.from({length:a});for(let t=0;t<a;++t){let i=s?e:e[t],a={};for(let e=0;e<r.length;++e){let t=r[e],s=i[e];if(t.selection){if(null===s){a[t.key]=null;continue}if(n){if(null===(s=JSON.parse(s))){a[t.key]=null;continue}}else l&&"string"==typeof s&&(s=JSON.parse(s));t.isArray?X(s,!1,t.selection,!1,l):X(s,!0,t.selection,!1,l),a[t.key]=s;continue}if(null===s){a[t.key]=null;continue}let u=o[e];a[t.key]=u?u(s):s}u[t]=a}return s?u[0]:u}(s?o[0]:o,s,e,r,n):X(s?o[0]:o,s,e,r,n,l)}function et({selection:e,isFirst:s,parseJson:r,parseJsonIfString:n,rootJsonMappers:a,arrayModeRoot:o}){let u=[],c=function e(s,r,n,l,a,o,u,c,d){let h=[],f=[],m=!1,p=s.map(()=>`c${c.n++}`),y=s.map((e,t)=>d?p[t]:`${JSON.stringify(e.key)}: ${p[t]}`);for(let[b,{field:q,key:$,codec:S,isArray:v,selection:x,arrayDimensions:Q}]of(h.push(d?`let [ ${y.join(", ")} ] = ${r};`:`let { ${y.join(", ")} } = ${r};`),s.entries())){let s=`${n}[${b}]`,r=JSON.stringify($),d=p[b];if(x){l?(h.push(`if (${d} !== null) ${d} = JSON.parse(${d});`),m=!0):a&&(h.push(`if (typeof ${d} === 'string') ${d} = JSON.parse(${d});`),m=!0);let t=`s${c.n++}`,i=u.length;if(u.push(`const { selection: ${t} } = ${s};`),v){let s=`j${c.n++}`,r=e(x,`${d}[${s}]`,t,!1,a,!0,u,c,!1);if(r.hasWork){for(let e of(m=!0,h.push(`if (${d} !== null) {`),h.push(` for (let ${s} = 0; ${s} < ${d}.length; ++${s}) {`),r.bodyStmts))h.push(` ${e}`);h.push(` ${d}[${s}] = ${r.literal};`),h.push(" }"),h.push("}")}else u.splice(i,1)}else{let s=e(x,d,t,!1,a,!0,u,c,!1);if(s.hasWork){for(let e of(m=!0,h.push(`if (${d} !== null) {`),s.bodyStmts))h.push(` ${e}`);h.push(` ${d} = ${s.literal};`),h.push("}")}else u.splice(i,1)}f.push(`${r}: ${d}`);continue}let y="",N="",L=!1;if((0,t.is)(q,g.Column)){if(o&&q.mapFromJsonValue){L=!0;let e=c.n++;N=`field: dec${e}`,y=`dec${e}.mapFromJsonValue`}else if(!q.mapFromDriverValue.isNoop){let e=c.n++;N=`field: dec${e}`,y=`dec${e}.mapFromDriverValue`}}else if((0,t.is)(q,i.SQL)){if(o&&q.decoder.mapFromJsonValue){L=!0;let e=c.n++;N=`field: { decoder: dec${e} }`,y=`dec${e}.mapFromJsonValue`}else if(!q.decoder.mapFromDriverValue.isNoop){let e=c.n++;N=`field: { decoder: dec${e} }`,y=`dec${e}.mapFromDriverValue`}}else if((0,t.is)(q,i.SQL.Aliased)){if(o&&q.sql.decoder.mapFromJsonValue){L=!0;let e=c.n++;N=`field: { sql: { decoder: dec${e} } }`,y=`dec${e}.mapFromJsonValue`}else if(!q.sql.decoder.mapFromDriverValue.isNoop){let e=c.n++;N=`field: { sql: { decoder: dec${e} } }`,y=`dec${e}.mapFromDriverValue`}}else if((0,t.is)(q,w.Table)||(0,t.is)(q,i.View));else{let e=q.getSQL();if(o&&e.decoder.mapFromJsonValue){L=!0;let e=c.n++;u.push(`const dec${e} = ${s}.field.getSQL().decoder;`),y=`dec${e}.mapFromJsonValue`}else if(!e.decoder.mapFromDriverValue.isNoop){let e=c.n++;u.push(`const dec${e} = ${s}.field.getSQL().decoder;`),y=`dec${e}.mapFromDriverValue`}}let T="";if(!L&&S&&(T=`codec${c.n++}`),N||T){let e=[];N&&e.push(N),T&&e.push(`codec: ${T}`),u.push(`const { ${e.join(", ")} } = ${s};`)}if(y||T){m=!0;let e=d;T&&(e=`${T}(${e}, ${Q})`),y&&(e=`${y}(${e})`),f.push(`${r}: ${d} === null ? null : ${e}`)}else f.push(`${r}: ${d}`)}return{bodyStmts:h,literal:`{ ${f.join(", ")} }`,hasWork:m}}(e,"row","selection",r,n,!o&&a,u,{n:0},!!o),d=[];for(let e of(d.push(` "use strict";
3
3
  const { selection } = this;`),u))d.push(` ${e}`);if(o)if(s){for(let e of(d.push(" const row = rows[0];"),d.push(" if (!row) return undefined;"),c.bodyStmts))d.push(` ${e}`);d.push(` return ${c.literal};`)}else{for(let e of(d.push(" const { length } = rows;"),d.push(" const mapped = Array.from({ length });"),d.push(" for (let i = 0; i < length; ++i) {"),d.push(" const row = rows[i];"),c.bodyStmts))d.push(` ${e}`);d.push(` mapped[i] = ${c.literal};`),d.push(" }"),d.push(" return mapped;")}else if(c.hasWork)if(s){for(let e of(d.push(" const row = rows[0];"),d.push(" if (!row) return undefined;"),c.bodyStmts))d.push(` ${e}`);d.push(` rows[0] = ${c.literal};`),d.push(" return rows[0];")}else{for(let e of(d.push(" for (let i = 0; i < rows.length; ++i) {"),d.push(" const row = rows[i];"),c.bodyStmts))d.push(` ${e}`);d.push(` rows[i] = ${c.literal};`),d.push(" }"),d.push(" return rows;")}else d.push(s?" return rows[0];":" return rows;");d.push(" //# sourceURL=drizzle:jit-relational-query-mapper");let h=d.join("\n");return Object.assign(new l.FnConstructor("rows",h).bind({selection:e}),{body:`function jitRqbMapper (rows) {
4
4
  ${h}
@@ -1,6 +1,6 @@
1
- module.exports=[323625,e=>e.a(async(t,a)=>{try{var n=e.i(201356),i=e.i(91264),s=t([n]);[n]=s.then?(await s)():s;let r=(0,i.serverRoute)(()=>(0,n.readReachStatus)());e.s(["GET",0,r]),a()}catch(e){a(e)}},!1),996575,e=>{"use strict";var t=e.i(747909),a=e.i(174017),n=e.i(996250),i=e.i(759756),s=e.i(561916),r=e.i(174677),o=e.i(869741),l=e.i(316795),c=e.i(487718),d=e.i(995169),u=e.i(47587),p=e.i(666012),h=e.i(570101),f=e.i(626937),m=e.i(10372),g=e.i(193695);e.i(52474);var w=e.i(600220);let y=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/reach/route",pathname:"/api/reach",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/reach/route.ts",nextConfigOutput:"standalone",userland:()=>e.r(323625),...{}}),{workAsyncStorage:_,workUnitAsyncStorage:v,serverHooks:b}=y;async function k(e,t,n){n.requestMeta&&(0,i.setRequestMeta)(e,n.requestMeta),y.isDev&&(0,i.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let _="/api/reach/route";_=_.replace(/\/index$/,"")||"/";let v=await y.prepare(e,t,{srcPage:_,multiZoneDraftMode:!1});if(!v)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:b,deploymentId:k,params:R,nextConfig:E,parsedUrl:S,isDraftMode:$,prerenderManifest:x,routerServerContext:C,isOnDemandRevalidate:T,revalidateOnlyGenerated:A,resolvedPathname:O,clientReferenceManifest:P,serverActionsManifest:N}=v,I=(0,o.normalizeAppPath)(_),q=!!(x.dynamicRoutes[I]||x.routes[O]),D=async()=>((null==C?void 0:C.render404)?await C.render404(e,t,S,!1):t.end("This page could not be found"),null);if(q&&!$){let e=!!x.routes[O],t=x.dynamicRoutes[I];if(t&&!1===t.fallback&&!e){if(E.adapterPath)return await D();throw new g.NoFallbackError}}let M=null;!q||y.isDev||$||(M="/index"===(M=O)?"/":M);let L=!0===y.isDev||!q,H=q&&!L;N&&P&&(0,r.setManifestsSingleton)({page:_,clientReferenceManifest:P,serverActionsManifest:N});let U=e.method||"GET",j=(0,s.getTracer)(),F=j.getActiveScopeSpan(),B=!!(null==C?void 0:C.isWrappedByNextServer),K=!!(0,i.getRequestMeta)(e,"minimalMode"),G=(0,i.getRequestMeta)(e,"incrementalCache")||await y.getIncrementalCache(e,E,x,K);null==G||G.resetRequestCache(),globalThis.__incrementalCache=G;let J={params:R,previewProps:x.preview,renderOpts:{experimental:{authInterrupts:!!E.experimental.authInterrupts,useCacheTimeout:E.experimental.useCacheTimeout},cacheComponents:!!E.cacheComponents,validationLevel:E.experimental.instantInsights.validationLevel,supportsDynamicResponse:L,incrementalCache:G,hmrRefreshHash:(0,i.getRequestMeta)(e,"hmrRefreshHash"),cacheLifeProfiles:E.cacheLife,staticPageGenerationTimeout:E.staticPageGenerationTimeout,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,n,i)=>y.onRequestError(e,t,n,i,C)},sharedContext:{buildId:b,deploymentId:k}},W=new l.NodeNextRequest(e),z=new l.NodeNextResponse(t),Y=c.NextRequestAdapter.fromNodeNextRequest(W,(0,c.signalFromNodeResponse)(t)),V=async({previousCacheEntry:a})=>{try{if(!K&&T&&A&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await y.handle(Y,J);e.fetchMetrics=J.renderOpts.fetchMetrics;let s=J.renderOpts.pendingWaitUntil;s&&n.waitUntil&&(n.waitUntil(s),s=void 0);let r=J.renderOpts.collectedTags;if(!q)return await (0,p.sendResponse)(W,z,i,s),null;{let e=await i.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(i.headers);r&&(t[m.NEXT_CACHE_TAGS_HEADER]=r),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==J.renderOpts.collectedRevalidate&&!(J.renderOpts.collectedRevalidate>=m.INFINITE_CACHE)&&J.renderOpts.collectedRevalidate,n=void 0===J.renderOpts.collectedExpire||J.renderOpts.collectedExpire>=m.INFINITE_CACHE?!1!==a&&a>0?E.expireTime:void 0:J.renderOpts.collectedExpire;return{value:{kind:w.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:n}}}}catch(t){throw(null==a?void 0:a.isStale)&&await y.onRequestError(e,t,{routerKind:"App Router",routePath:_,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:T})},!1,C),t}},X=async(i,r)=>{try{var o,l;let i=await y.handleResponse({req:e,nextConfig:E,cacheKey:M,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:x,isRoutePPREnabled:!1,isOnDemandRevalidate:T,revalidateOnlyGenerated:A,responseGenerator:V,waitUntil:n.waitUntil,isMinimalMode:K});if(!q)return;if((null==i||null==(o=i.value)?void 0:o.kind)!==w.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==i||null==(l=i.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});K||t.setHeader("x-nextjs-cache",T?"REVALIDATED":i.isMiss?"MISS":i.isStale?"STALE":"HIT"),$&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let s=(0,h.fromNodeOutgoingHttpHeaders)(i.value.headers);K&&q||s.delete(m.NEXT_CACHE_TAGS_HEADER),!i.cacheControl||t.getHeader("Cache-Control")||s.get("Cache-Control")||s.set("Cache-Control",(0,f.getCacheControlHeader)(i.cacheControl)),await (0,p.sendResponse)(W,z,new Response(i.value.body,{headers:s,status:i.value.status||200}));return}catch(t){if(t instanceof g.NoFallbackError||await y.onRequestError(e,t,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:T})},!1,C),q)throw t;await (0,p.sendResponse)(W,z,new Response(null,{status:500}));return}finally{(()=>{if(!i)return;let e=t.statusCode;i.setAttributes({"http.status_code":e,"next.rsc":!1}),e&&e>=500&&(i.setStatus({code:s.SpanStatusCode.ERROR}),i.setAttribute("error.type",e.toString()));let a=j.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==d.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=a.get("next.route")||I,o=`${U} ${n}`;i.setAttributes({"next.route":n,"http.route":n,"next.span_name":o}),i.updateName(o),r&&r!==i&&(r.setAttribute("http.route",n),r.updateName(o))})()}};if(B&&F)await X(F,void 0);else{let t=j.getActiveScopeSpan();await j.withPropagatedContext(e.headers,()=>j.trace(d.BaseServerSpan.handleRequest,{spanName:`${U} ${_}`,kind:s.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},e=>X(e,t)),void 0,!B)}}e.s(["handler",0,k,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:_,workUnitAsyncStorage:v})},"routeModule",0,y,"serverHooks",0,b,"workAsyncStorage",0,_,"workUnitAsyncStorage",0,v])},864064,e=>{"use strict";e.s(["ChannelRefusal",0,class extends Error{}])},407723,e=>{"use strict";e.s(["inPieces",0,function(e,t){let a=[],n=e;for(;n.length>t;){let e=n.slice(0,t),i=Math.max(e.lastIndexOf("\n\n"),e.lastIndexOf("\n")),s=i>t/2?i:t;a.push(n.slice(0,s).trim()),n=n.slice(s).trim()}return n&&a.push(n),a},"runSocket",0,function(e,t,a){return new Promise((n,i)=>{let s=new WebSocket(e),r=e=>{s.readyState===WebSocket.OPEN&&s.send(JSON.stringify(e))},o=()=>s.close(1e3);a.addEventListener("abort",o,{once:!0}),s.addEventListener("message",e=>{try{t.message(JSON.parse(String(e.data)),r)}catch{}}),s.addEventListener("error",()=>{s.readyState!==WebSocket.OPEN&&i(Error(`Could not connect to ${new URL(e).host}`))}),s.addEventListener("close",e=>{a.removeEventListener("abort",o),n({code:e.code,reason:e.reason})})})}])},440219,e=>{"use strict";var t=e.i(864064),a=e.i(407723);let n={4004:"Discord did not take the bot token.",4013:"Discord refused the intents this bot asked for.",4014:"Discord refused an intent this bot is not allowed — check the bot's page."};e.s(["createDiscord",0,function(e){async function i(a,n,i){let s=i instanceof FormData,r=await fetch(`https://discord.com/api/v10${n}`,{method:a,headers:{authorization:`Bot ${e}`,...s||!i?{}:{"content-type":"application/json"}},body:s?i:i?JSON.stringify(i):void 0});if(r.ok)return 204===r.status?null:await r.json();let o=await r.json().catch(()=>null),l=o?.message??`Discord answered ${r.status}`;throw 401===r.status?new t.ChannelRefusal(l):Error(l)}let s=e=>{let t=e.length<=5?1:5,a=[];for(let n=0;n<e.length&&a.length<5;n+=t)a.push({type:1,components:e.slice(n,n+t).map(e=>({type:2,style:2,label:e.text.slice(0,80),custom_id:e.data}))});return a};return{async listen(s,r){let o,l=null;try{let c=await (0,a.runSocket)("wss://gateway.discord.gg/?v=10&encoding=json",{message(t,a){let{op:n,d:r,s:c,t:d}=t;if(null!==c&&(l=c),10===n){let t=r.heartbeat_interval;o=setInterval(()=>a({op:1,d:l}),t),a({op:2,d:{token:e,intents:4096,properties:{os:process.platform,browser:"thursday",device:"thursday"}}})}else if(1===n)a({op:1,d:l});else if(0===n&&"READY"===d)s.ready(r.user.username);else if(0===n&&d){var u,p;let e=(u=d,p=r,"MESSAGE_CREATE"===u?p.guild_id||p.author.bot?null:{kind:"message",chat:p.channel_id,name:p.author.global_name||p.author.username,words:p.content.trim(),files:(p.attachments??[]).map(e=>({name:e.filename,fetch:async()=>{let t=await fetch(e.url);if(!t.ok)throw Error(`Discord answered ${t.status} for the file`);return new File([await t.arrayBuffer()],e.filename,{type:e.content_type??""})}})),unreadable:!1}:"INTERACTION_CREATE"===u?3!==p.type||p.guild_id?null:(i("POST",`/interactions/${p.id}/${p.token}/callback`,{type:6}).catch(()=>{}),{kind:"press",chat:p.channel_id,data:p.data?.custom_id??"",under:p.message?{id:p.message.id,text:p.message.content}:null}):null);e&&s.incoming(e)}}},r),d=n[c.code];if(d)throw new t.ChannelRefusal(d);if(!r.aborted)throw Error(`Discord closed the connection (${c.code})`)}finally{clearInterval(o)}},async say(e,t,n){let r=(0,a.inPieces)(t,1900);for(let[t,a]of r.entries())await i("POST",`/channels/${e}/messages`,{content:a,...n?.length&&t===r.length-1?{components:s(n)}:{}})},async typing(e){await i("POST",`/channels/${e}/typing`).catch(()=>{})},async settle(e,t,a){await i("PATCH",`/channels/${e}/messages/${t}`,{content:a.slice(0,1900),components:[]}).catch(()=>{})},async sendFile(e,t,a){let n=new FormData;n.set("payload_json",JSON.stringify({attachments:[{id:0,filename:a}]})),n.set("files[0]",new Blob([t]),a),await i("POST",`/channels/${e}/messages`,n)}}}])},480604,e=>{"use strict";var t=e.i(864064),a=e.i(407723);let n="https://slack.com/api",i=new Set(["invalid_auth","not_authed","account_inactive","token_revoked","not_allowed_token_type","missing_scope"]);e.s(["createSlack",0,function(e,s){async function r(e,a,o=s){let l=await fetch(`${n}/${e}`,{method:"POST",headers:{authorization:`Bearer ${o}`,"content-type":"application/json; charset=utf-8"},body:JSON.stringify(a)}),c=await l.json().catch(()=>null);if(c?.ok)return c;let d=c?.error??`http_${l.status}`,u="missing_scope"===d?`Slack says the app lacks a permission (${c?.needed??"a scope"}) — make it from the manifest in the guide.`:`Slack answered ${d} to ${e}`;throw i.has(d)?new t.ChannelRefusal(u):Error(u)}let o=new Map;async function l(e){let t=o.get(e);if(t)return t;let a=await r("users.info",{user:e}).then(t=>t.user?.real_name||t.user?.name||e).catch(()=>e);return o.set(e,a),a}async function c(e,t){if("events_api"===e){let e=t.event??{},a=!e.subtype||"file_share"===e.subtype;return"message"===e.type&&"im"===e.channel_type&&a&&!e.bot_id&&e.user&&e.channel?{kind:"message",chat:e.channel,name:await l(e.user),words:(e.text??"").trim(),files:(e.files??[]).flatMap(e=>{let t=e.url_private_download;if(!t)return[];let a=e.name??"file";return[{name:a,fetch:async()=>{let n=await fetch(t,{headers:{authorization:`Bearer ${s}`}});if(!n.ok)throw Error(`Slack answered ${n.status} for the file`);return new File([await n.arrayBuffer()],a,{type:e.mimetype??""})}}]}),unreadable:!1}:null}return"interactive"===e&&"block_actions"===t.type?t.channel?.id?{kind:"press",chat:t.channel.id,data:t.actions?.[0]?.value??"",under:t.message?.ts&&t.message.text?{id:t.message.ts,text:t.message.text}:null}:null:null}return{async listen(t,n){let i=await r("auth.test",{}),{url:s}=await r("apps.connections.open",{},e);t.ready(i.user?`@${i.user}`:"the app");let o=await (0,a.runSocket)(s,{message(e,a){let{type:n,envelope_id:i,payload:s}=e;i&&a({envelope_id:i}),n&&s&&c(n,s).then(e=>{e&&t.incoming(e)})}},n);if(!n.aborted)throw Error(`Slack closed the connection (${o.code})`)},async say(e,t,n){let i=(0,a.inPieces)(t,2900);for(let[t,a]of i.entries()){let s=n?.length&&t===i.length-1;await r("chat.postMessage",{channel:e,text:a,unfurl_links:!1,...s?{blocks:[{type:"section",text:{type:"plain_text",text:a}},{type:"actions",elements:n.slice(0,25).map((e,t)=>({type:"button",action_id:`choice_${t}`,text:{type:"plain_text",text:e.text.slice(0,75)},value:e.data}))}]}:{}})}},async typing(){},async settle(e,t,a){await r("chat.update",{channel:e,ts:t,text:a.slice(0,2900),blocks:[]}).catch(()=>{})},async sendFile(e,t,a){let i=new URLSearchParams({filename:a,length:String(t.byteLength)}),o=await fetch(`${n}/files.getUploadURLExternal`,{method:"POST",headers:{authorization:`Bearer ${s}`},body:i}),l=await o.json();if(!l.ok||!l.upload_url||!l.file_id)throw Error(`Slack answered ${l.error??o.status} to the upload`);await fetch(l.upload_url,{method:"POST",body:new Blob([t])}),await r("files.completeUploadExternal",{files:[{id:l.file_id,title:a}],channel_id:e})}}}])},377858,e=>{"use strict";var t=e.i(687388),a=e.i(864064);let n="https://api.telegram.org";e.s(["createTelegram",0,function(e){async function i(t,i,s){let r=i instanceof FormData,o=await fetch(`${n}/bot${e}/${t}`,{method:"POST",signal:s,...r?{body:i}:{headers:{"content-type":"application/json"},body:JSON.stringify(i??{})}}),l=await o.json().catch(()=>null);if(l?.ok)return l.result;let c=l?.description??`Telegram answered ${o.status}`;throw 401===o.status?new a.ChannelRefusal(c):Error(c)}async function s(t,a,s){let{file_path:r}=await i("getFile",{file_id:t});if(!r)throw Error("Telegram did not say where the file is");let o=await fetch(`${n}/file/bot${e}/${r}`);if(!o.ok)throw Error(`Telegram answered ${o.status} for the file`);let l=r.includes(".")?r.slice(r.lastIndexOf(".")):"";return new File([await o.arrayBuffer()],a.includes(".")?a:`${a}${l}`,s?{type:s}:void 0)}return{async listen(e,a){let n=await i("getMe",void 0,a);e.ready(n.username?`@${n.username}`:n.first_name??"the bot");let r=0;for(;!a.aborted;)for(let n of(await i("getUpdates",{offset:r,timeout:t.REACH.pollSeconds,allowed_updates:["message","callback_query"]},AbortSignal.any([a,AbortSignal.timeout((t.REACH.pollSeconds+15)*1e3)])))){r=n.update_id+1;let t=function(e){let t,a=e.callback_query;if(a)return i("answerCallbackQuery",{callback_query_id:a.id}).catch(()=>{}),{kind:"press",chat:String(a.from.id),data:a.data??"",under:a.message?.text?{id:String(a.message.message_id),text:a.message.text}:null};let n=e.message;if(!n?.from||"private"!==n.chat.type)return null;let r=n.photo?.at(-1),o=n.document?{id:n.document.file_id,name:n.document.file_name??"file",type:n.document.mime_type}:r?{id:r.file_id,name:`photo-${n.message_id}`,type:""}:null;return{kind:"message",chat:String(n.chat.id),name:(t=n.from,[t?.first_name,t?.last_name].filter(Boolean).join(" ")||(t?.username?`@${t.username}`:"Someone")),words:(n.text??n.caption??"").trim(),files:o?[{name:o.name,fetch:()=>s(o.id,o.name,o.type)}]:[],unreadable:!!(n.voice||n.audio||n.video)}}(n);t&&e.incoming(t)}},async say(e,t,a){await i("sendMessage",{chat_id:e,text:t,link_preview_options:{is_disabled:!0},...a?.length?{reply_markup:{inline_keyboard:a.map(e=>[{text:e.text,callback_data:e.data}])}}:{}})},async typing(e){await i("sendChatAction",{chat_id:e,action:"typing"}).catch(()=>{})},async settle(e,t,a){await i("editMessageText",{chat_id:e,message_id:Number(t),text:a,link_preview_options:{is_disabled:!0}}).catch(()=>{})},async sendFile(e,t,a,n){let s=new FormData;s.set("chat_id",e),s.set(n?"photo":"document",new Blob([t]),a),await i(n?"sendPhoto":"sendDocument",s)}}}])},201356,e=>e.a(async(t,a)=>{try{e.i(912714),e.i(380690),e.i(687388),e.i(911757);var n=e.i(386075),i=e.i(39803),s=e.i(742712),r=e.i(378884),o=e.i(340698);e.i(15538);var l=e.i(22676),c=e.i(97334);e.i(629668),e.i(786025),e.i(440998),e.i(640911),e.i(440219);var d=e.i(834332);e.i(480604),e.i(377858);var u=t([n,i,s,r,o,l,c]);[n,i,s,r,o,l,c]=u.then?(await u)():u;let f=globalThis,m=f.__reach??={live:new Map,last:null,told:new Set,due:new Map,choices:new Map,listening:null,looking:null};async function p(e){let t=await (0,o.readConfig)((0,d.reachPersonKey)(e));if(!t)return null;try{let e=JSON.parse(t);return"string"==typeof e.chat&&"string"==typeof e.name?{chat:e.chat,name:e.name}:null}catch{return null}}async function h(){return{channels:await Promise.all([...m.live.values()].map(async e=>({name:e.name,bot:e.bot,allowed:await p(e.name),asking:e.asking,problem:e.problem})))}}e.s(["readReachStatus",0,h]),a()}catch(e){a(e)}},!1),15538,e=>{"use strict";var t=e.i(687388),a=e.i(944971),n=e.i(704161);let i={message:"says",question:"asks",report:"reports",interrupted:"was cut off"},s={question:0,stopped:1,done:2,progress:3};function r(e){let a=e.trim();if(a.length<=t.CALL_RELAY.chars)return a;let n=a.slice(0,t.CALL_RELAY.chars),i=Math.max(n.lastIndexOf("\n\n"),n.lastIndexOf(". "),n.lastIndexOf(".\n"),n.lastIndexOf("。")),s=(i>t.CALL_RELAY.chars/3?n.slice(0,i+1):n).trim();return`${s}
1
+ module.exports=[323625,e=>e.a(async(t,a)=>{try{var n=e.i(201356),i=e.i(91264),s=t([n]);[n]=s.then?(await s)():s;let r=(0,i.serverRoute)(()=>(0,n.readReachStatus)());e.s(["GET",0,r]),a()}catch(e){a(e)}},!1),996575,e=>{"use strict";var t=e.i(747909),a=e.i(174017),n=e.i(996250),i=e.i(759756),s=e.i(561916),r=e.i(174677),o=e.i(869741),l=e.i(316795),c=e.i(487718),d=e.i(995169),u=e.i(47587),p=e.i(666012),h=e.i(570101),m=e.i(626937),f=e.i(10372),g=e.i(193695);e.i(52474);var w=e.i(600220);let y=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/reach/route",pathname:"/api/reach",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/reach/route.ts",nextConfigOutput:"standalone",userland:()=>e.r(323625),...{}}),{workAsyncStorage:_,workUnitAsyncStorage:v,serverHooks:b}=y;async function k(e,t,n){n.requestMeta&&(0,i.setRequestMeta)(e,n.requestMeta),y.isDev&&(0,i.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let _="/api/reach/route";_=_.replace(/\/index$/,"")||"/";let v=await y.prepare(e,t,{srcPage:_,multiZoneDraftMode:!1});if(!v)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:b,deploymentId:k,params:R,nextConfig:E,parsedUrl:$,isDraftMode:S,prerenderManifest:x,routerServerContext:C,isOnDemandRevalidate:T,revalidateOnlyGenerated:A,resolvedPathname:O,clientReferenceManifest:P,serverActionsManifest:N}=v,I=(0,o.normalizeAppPath)(_),q=!!(x.dynamicRoutes[I]||x.routes[O]),D=async()=>((null==C?void 0:C.render404)?await C.render404(e,t,$,!1):t.end("This page could not be found"),null);if(q&&!S){let e=!!x.routes[O],t=x.dynamicRoutes[I];if(t&&!1===t.fallback&&!e){if(E.adapterPath)return await D();throw new g.NoFallbackError}}let M=null;!q||y.isDev||S||(M="/index"===(M=O)?"/":M);let L=!0===y.isDev||!q,H=q&&!L;N&&P&&(0,r.setManifestsSingleton)({page:_,clientReferenceManifest:P,serverActionsManifest:N});let U=e.method||"GET",j=(0,s.getTracer)(),F=j.getActiveScopeSpan(),B=!!(null==C?void 0:C.isWrappedByNextServer),K=!!(0,i.getRequestMeta)(e,"minimalMode"),G=(0,i.getRequestMeta)(e,"incrementalCache")||await y.getIncrementalCache(e,E,x,K);null==G||G.resetRequestCache(),globalThis.__incrementalCache=G;let J={params:R,previewProps:x.preview,renderOpts:{experimental:{authInterrupts:!!E.experimental.authInterrupts,useCacheTimeout:E.experimental.useCacheTimeout},cacheComponents:!!E.cacheComponents,validationLevel:E.experimental.instantInsights.validationLevel,supportsDynamicResponse:L,incrementalCache:G,hmrRefreshHash:(0,i.getRequestMeta)(e,"hmrRefreshHash"),cacheLifeProfiles:E.cacheLife,staticPageGenerationTimeout:E.staticPageGenerationTimeout,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,n,i)=>y.onRequestError(e,t,n,i,C)},sharedContext:{buildId:b,deploymentId:k}},W=new l.NodeNextRequest(e),z=new l.NodeNextResponse(t),Y=c.NextRequestAdapter.fromNodeNextRequest(W,(0,c.signalFromNodeResponse)(t)),V=async({previousCacheEntry:a})=>{try{if(!K&&T&&A&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await y.handle(Y,J);e.fetchMetrics=J.renderOpts.fetchMetrics;let s=J.renderOpts.pendingWaitUntil;s&&n.waitUntil&&(n.waitUntil(s),s=void 0);let r=J.renderOpts.collectedTags;if(!q)return await (0,p.sendResponse)(W,z,i,s),null;{let e=await i.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(i.headers);r&&(t[f.NEXT_CACHE_TAGS_HEADER]=r),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==J.renderOpts.collectedRevalidate&&!(J.renderOpts.collectedRevalidate>=f.INFINITE_CACHE)&&J.renderOpts.collectedRevalidate,n=void 0===J.renderOpts.collectedExpire||J.renderOpts.collectedExpire>=f.INFINITE_CACHE?!1!==a&&a>0?E.expireTime:void 0:J.renderOpts.collectedExpire;return{value:{kind:w.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:n}}}}catch(t){throw(null==a?void 0:a.isStale)&&await y.onRequestError(e,t,{routerKind:"App Router",routePath:_,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:T})},!1,C),t}},X=async(i,r)=>{try{var o,l;let i=await y.handleResponse({req:e,nextConfig:E,cacheKey:M,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:x,isRoutePPREnabled:!1,isOnDemandRevalidate:T,revalidateOnlyGenerated:A,responseGenerator:V,waitUntil:n.waitUntil,isMinimalMode:K});if(!q)return;if((null==i||null==(o=i.value)?void 0:o.kind)!==w.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==i||null==(l=i.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});K||t.setHeader("x-nextjs-cache",T?"REVALIDATED":i.isMiss?"MISS":i.isStale?"STALE":"HIT"),S&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let s=(0,h.fromNodeOutgoingHttpHeaders)(i.value.headers);K&&q||s.delete(f.NEXT_CACHE_TAGS_HEADER),!i.cacheControl||t.getHeader("Cache-Control")||s.get("Cache-Control")||s.set("Cache-Control",(0,m.getCacheControlHeader)(i.cacheControl)),await (0,p.sendResponse)(W,z,new Response(i.value.body,{headers:s,status:i.value.status||200}));return}catch(t){if(t instanceof g.NoFallbackError||await y.onRequestError(e,t,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:T})},!1,C),q)throw t;await (0,p.sendResponse)(W,z,new Response(null,{status:500}));return}finally{(()=>{if(!i)return;let e=t.statusCode;i.setAttributes({"http.status_code":e,"next.rsc":!1}),e&&e>=500&&(i.setStatus({code:s.SpanStatusCode.ERROR}),i.setAttribute("error.type",e.toString()));let a=j.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==d.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=a.get("next.route")||I,o=`${U} ${n}`;i.setAttributes({"next.route":n,"http.route":n,"next.span_name":o}),i.updateName(o),r&&r!==i&&(r.setAttribute("http.route",n),r.updateName(o))})()}};if(B&&F)await X(F,void 0);else{let t=j.getActiveScopeSpan();await j.withPropagatedContext(e.headers,()=>j.trace(d.BaseServerSpan.handleRequest,{spanName:`${U} ${_}`,kind:s.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},e=>X(e,t)),void 0,!B)}}e.s(["handler",0,k,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:_,workUnitAsyncStorage:v})},"routeModule",0,y,"serverHooks",0,b,"workAsyncStorage",0,_,"workUnitAsyncStorage",0,v])},864064,e=>{"use strict";e.s(["ChannelRefusal",0,class extends Error{}])},407723,e=>{"use strict";e.s(["inPieces",0,function(e,t){let a=[],n=e;for(;n.length>t;){let e=n.slice(0,t),i=Math.max(e.lastIndexOf("\n\n"),e.lastIndexOf("\n")),s=i>t/2?i:t;a.push(n.slice(0,s).trim()),n=n.slice(s).trim()}return n&&a.push(n),a},"runSocket",0,function(e,t,a){return new Promise((n,i)=>{let s=new WebSocket(e),r=e=>{s.readyState===WebSocket.OPEN&&s.send(JSON.stringify(e))},o=()=>s.close(1e3);a.addEventListener("abort",o,{once:!0}),s.addEventListener("message",e=>{try{t.message(JSON.parse(String(e.data)),r)}catch{}}),s.addEventListener("error",()=>{s.readyState!==WebSocket.OPEN&&i(Error(`Could not connect to ${new URL(e).host}`))}),s.addEventListener("close",e=>{a.removeEventListener("abort",o),n({code:e.code,reason:e.reason})})})}])},440219,e=>{"use strict";var t=e.i(864064),a=e.i(407723);let n={4004:"Discord did not take the bot token.",4013:"Discord refused the intents this bot asked for.",4014:"Discord refused an intent this bot is not allowed — check the bot's page."};e.s(["createDiscord",0,function(e){async function i(a,n,i){let s=i instanceof FormData,r=await fetch(`https://discord.com/api/v10${n}`,{method:a,headers:{authorization:`Bot ${e}`,...s||!i?{}:{"content-type":"application/json"}},body:s?i:i?JSON.stringify(i):void 0});if(r.ok)return 204===r.status?null:await r.json();let o=await r.json().catch(()=>null),l=o?.message??`Discord answered ${r.status}`;throw 401===r.status?new t.ChannelRefusal(l):Error(l)}let s=e=>{let t=e.length<=5?1:5,a=[];for(let n=0;n<e.length&&a.length<5;n+=t)a.push({type:1,components:e.slice(n,n+t).map(e=>({type:2,style:2,label:e.text.slice(0,80),custom_id:e.data}))});return a};return{async listen(s,r){let o,l=null;try{let c=await (0,a.runSocket)("wss://gateway.discord.gg/?v=10&encoding=json",{message(t,a){let{op:n,d:r,s:c,t:d}=t;if(null!==c&&(l=c),10===n){let t=r.heartbeat_interval;o=setInterval(()=>a({op:1,d:l}),t),a({op:2,d:{token:e,intents:4096,properties:{os:process.platform,browser:"thursday",device:"thursday"}}})}else if(1===n)a({op:1,d:l});else if(0===n&&"READY"===d){let e;s.ready(r.user.username,(e=r.application?.id)?`https://discord.com/oauth2/authorize?client_id=${e}&scope=bot&permissions=0`:null)}else if(0===n&&d){var u,p;let e=(u=d,p=r,"MESSAGE_CREATE"===u?p.guild_id||p.author.bot?null:{kind:"message",chat:p.channel_id,name:p.author.global_name||p.author.username,words:p.content.trim(),files:(p.attachments??[]).map(e=>({name:e.filename,fetch:async()=>{let t=await fetch(e.url);if(!t.ok)throw Error(`Discord answered ${t.status} for the file`);return new File([await t.arrayBuffer()],e.filename,{type:e.content_type??""})}})),unreadable:!1}:"INTERACTION_CREATE"===u?3!==p.type||p.guild_id?null:(i("POST",`/interactions/${p.id}/${p.token}/callback`,{type:6}).catch(()=>{}),{kind:"press",chat:p.channel_id,data:p.data?.custom_id??"",under:p.message?{id:p.message.id,text:p.message.content}:null}):null);e&&s.incoming(e)}}},r),d=n[c.code];if(d)throw new t.ChannelRefusal(d);if(!r.aborted)throw Error(`Discord closed the connection (${c.code})`)}finally{clearInterval(o)}},async say(e,t,n){let r=(0,a.inPieces)(t,1900);for(let[t,a]of r.entries())await i("POST",`/channels/${e}/messages`,{content:a,...n?.length&&t===r.length-1?{components:s(n)}:{}})},async typing(e){await i("POST",`/channels/${e}/typing`).catch(()=>{})},async settle(e,t,a){await i("PATCH",`/channels/${e}/messages/${t}`,{content:a.slice(0,1900),components:[]}).catch(()=>{})},async sendFile(e,t,a){let n=new FormData;n.set("payload_json",JSON.stringify({attachments:[{id:0,filename:a}]})),n.set("files[0]",new Blob([t]),a),await i("POST",`/channels/${e}/messages`,n)}}}])},480604,e=>{"use strict";var t=e.i(864064),a=e.i(407723);let n="https://slack.com/api",i=new Set(["invalid_auth","not_authed","account_inactive","token_revoked","not_allowed_token_type","missing_scope"]);e.s(["createSlack",0,function(e,s){async function r(e,a,o=s){let l=await fetch(`${n}/${e}`,{method:"POST",headers:{authorization:`Bearer ${o}`,"content-type":"application/json; charset=utf-8"},body:JSON.stringify(a)}),c=await l.json().catch(()=>null);if(c?.ok)return c;let d=c?.error??`http_${l.status}`,u="missing_scope"===d?`Slack says the app lacks a permission (${c?.needed??"a scope"}) — make it from the manifest in the guide.`:`Slack answered ${d} to ${e}`;throw i.has(d)?new t.ChannelRefusal(u):Error(u)}let o=new Map;async function l(e){let t=o.get(e);if(t)return t;let a=await r("users.info",{user:e}).then(t=>t.user?.real_name||t.user?.name||e).catch(()=>e);return o.set(e,a),a}async function c(e,t){if("events_api"===e){let e=t.event??{},a=!e.subtype||"file_share"===e.subtype;return"message"===e.type&&"im"===e.channel_type&&a&&!e.bot_id&&e.user&&e.channel?{kind:"message",chat:e.channel,name:await l(e.user),words:(e.text??"").trim(),files:(e.files??[]).flatMap(e=>{let t=e.url_private_download;if(!t)return[];let a=e.name??"file";return[{name:a,fetch:async()=>{let n=await fetch(t,{headers:{authorization:`Bearer ${s}`}});if(!n.ok)throw Error(`Slack answered ${n.status} for the file`);return new File([await n.arrayBuffer()],a,{type:e.mimetype??""})}}]}),unreadable:!1}:null}return"interactive"===e&&"block_actions"===t.type?t.channel?.id?{kind:"press",chat:t.channel.id,data:t.actions?.[0]?.value??"",under:t.message?.ts&&t.message.text?{id:t.message.ts,text:t.message.text}:null}:null:null}return{async listen(t,n){let i=await r("auth.test",{}),{url:s}=await r("apps.connections.open",{},e);t.ready(i.user?`@${i.user}`:"the app",null);let o=await (0,a.runSocket)(s,{message(e,a){let{type:n,envelope_id:i,payload:s}=e;i&&a({envelope_id:i}),n&&s&&c(n,s).then(e=>{e&&t.incoming(e)})}},n);if(!n.aborted)throw Error(`Slack closed the connection (${o.code})`)},async say(e,t,n){let i=(0,a.inPieces)(t,2900);for(let[t,a]of i.entries()){let s=n?.length&&t===i.length-1;await r("chat.postMessage",{channel:e,text:a,unfurl_links:!1,...s?{blocks:[{type:"section",text:{type:"plain_text",text:a}},{type:"actions",elements:n.slice(0,25).map((e,t)=>({type:"button",action_id:`choice_${t}`,text:{type:"plain_text",text:e.text.slice(0,75)},value:e.data}))}]}:{}})}},async typing(){},async settle(e,t,a){await r("chat.update",{channel:e,ts:t,text:a.slice(0,2900),blocks:[]}).catch(()=>{})},async sendFile(e,t,a){let i=new URLSearchParams({filename:a,length:String(t.byteLength)}),o=await fetch(`${n}/files.getUploadURLExternal`,{method:"POST",headers:{authorization:`Bearer ${s}`},body:i}),l=await o.json();if(!l.ok||!l.upload_url||!l.file_id)throw Error(`Slack answered ${l.error??o.status} to the upload`);await fetch(l.upload_url,{method:"POST",body:new Blob([t])}),await r("files.completeUploadExternal",{files:[{id:l.file_id,title:a}],channel_id:e})}}}])},377858,e=>{"use strict";var t=e.i(687388),a=e.i(864064);let n="https://api.telegram.org";e.s(["createTelegram",0,function(e){async function i(t,i,s){let r=i instanceof FormData,o=await fetch(`${n}/bot${e}/${t}`,{method:"POST",signal:s,...r?{body:i}:{headers:{"content-type":"application/json"},body:JSON.stringify(i??{})}}),l=await o.json().catch(()=>null);if(l?.ok)return l.result;let c=l?.description??`Telegram answered ${o.status}`;throw 401===o.status?new a.ChannelRefusal(c):Error(c)}async function s(t,a,s){let{file_path:r}=await i("getFile",{file_id:t});if(!r)throw Error("Telegram did not say where the file is");let o=await fetch(`${n}/file/bot${e}/${r}`);if(!o.ok)throw Error(`Telegram answered ${o.status} for the file`);let l=r.includes(".")?r.slice(r.lastIndexOf(".")):"";return new File([await o.arrayBuffer()],a.includes(".")?a:`${a}${l}`,s?{type:s}:void 0)}return{async listen(e,a){let n=await i("getMe",void 0,a);e.ready(n.username?`@${n.username}`:n.first_name??"the bot",n.username?`https://t.me/${n.username}`:null);let r=0;for(;!a.aborted;)for(let n of(await i("getUpdates",{offset:r,timeout:t.REACH.pollSeconds,allowed_updates:["message","callback_query"]},AbortSignal.any([a,AbortSignal.timeout((t.REACH.pollSeconds+15)*1e3)])))){r=n.update_id+1;let t=function(e){let t,a=e.callback_query;if(a)return i("answerCallbackQuery",{callback_query_id:a.id}).catch(()=>{}),{kind:"press",chat:String(a.from.id),data:a.data??"",under:a.message?.text?{id:String(a.message.message_id),text:a.message.text}:null};let n=e.message;if(!n?.from||"private"!==n.chat.type)return null;let r=n.photo?.at(-1),o=n.document?{id:n.document.file_id,name:n.document.file_name??"file",type:n.document.mime_type}:r?{id:r.file_id,name:`photo-${n.message_id}`,type:""}:null;return{kind:"message",chat:String(n.chat.id),name:(t=n.from,[t?.first_name,t?.last_name].filter(Boolean).join(" ")||(t?.username?`@${t.username}`:"Someone")),words:(n.text??n.caption??"").trim(),files:o?[{name:o.name,fetch:()=>s(o.id,o.name,o.type)}]:[],unreadable:!!(n.voice||n.audio||n.video)}}(n);t&&e.incoming(t)}},async say(e,t,a){await i("sendMessage",{chat_id:e,text:t,link_preview_options:{is_disabled:!0},...a?.length?{reply_markup:{inline_keyboard:a.map(e=>[{text:e.text,callback_data:e.data}])}}:{}})},async typing(e){await i("sendChatAction",{chat_id:e,action:"typing"}).catch(()=>{})},async settle(e,t,a){await i("editMessageText",{chat_id:e,message_id:Number(t),text:a,link_preview_options:{is_disabled:!0}}).catch(()=>{})},async sendFile(e,t,a,n){let s=new FormData;s.set("chat_id",e),s.set(n?"photo":"document",new Blob([t]),a),await i(n?"sendPhoto":"sendDocument",s)}}}])},201356,e=>e.a(async(t,a)=>{try{e.i(912714),e.i(380690),e.i(687388),e.i(911757);var n=e.i(386075),i=e.i(39803),s=e.i(742712),r=e.i(378884),o=e.i(340698);e.i(15538);var l=e.i(22676),c=e.i(97334);e.i(629668),e.i(786025);var d=e.i(440998);e.i(640911),e.i(440219);var u=e.i(834332);e.i(480604),e.i(377858);var p=t([n,i,s,r,o,l,c,d]);[n,i,s,r,o,l,c,d]=p.then?(await p)():p;let f=globalThis,g=f.__reach??={live:new Map,last:null,told:new Set,due:new Map,choices:new Map,listening:null,looking:null,idle:null};async function h(e){let t=await (0,o.readConfig)((0,u.reachPersonKey)(e));if(!t)return null;try{let e=JSON.parse(t);return"string"==typeof e.chat&&"string"==typeof e.name?{chat:e.chat,name:e.name}:null}catch{return null}}async function m(){return{channels:await Promise.all([...g.live.values()].map(async e=>({name:e.name,bot:e.bot,link:e.link,allowed:await h(e.name),asking:e.asking,problem:e.problem})))}}e.s(["readReachStatus",0,m]),a()}catch(e){a(e)}},!1),15538,e=>{"use strict";var t=e.i(687388),a=e.i(944971),n=e.i(704161);let i={message:"says",question:"asks",report:"reports",interrupted:"was cut off"},s={question:0,stopped:1,done:2,progress:3};function r(e){let a=e.trim();if(a.length<=t.CALL_RELAY.chars)return a;let n=a.slice(0,t.CALL_RELAY.chars),i=Math.max(n.lastIndexOf("\n\n"),n.lastIndexOf(". "),n.lastIndexOf(".\n"),n.lastIndexOf("。")),s=(i>t.CALL_RELAY.chars/3?n.slice(0,i+1):n).trim();return`${s}
2
2
  [The message goes on; the rest is in its thread on screen.]`}e.s(["openWork",0,function(e){let t=[];for(let o of e){let{relays:e,questions:l}=o.room,c=(0,n.toDate)(o.updatedAt).getTime(),d=(e,t)=>`[${e} → Thursday, thread "${o.label}" (${o.id}), ${t}.]`,u=(e,t)=>({kind:"relay",name:o.label,line:t,done:!0,bot:e});for(let a of l){let n=a.options?.length?` Options: ${a.options.join(" / ")}.`:"";t.push({rank:s.question,key:`question:${a.id}`,kind:"question",line:`${d(a.bot,"question")}
3
- ${r(a.text)}${n}`,relayIds:e.filter(e=>e.messageId===a.id).map(e=>e.id),show:u(a.bot,`${a.bot} asks`)})}let p=e.filter(e=>!l.some(t=>t.id===e.messageId)),h="done"===o.status,f="waiting"===o.status&&(0,a.isAppStop)(o.ask)&&!o.ask?.auto;if(h||f){if(o.seen)continue;let e=f?"stopped":"done",a="stopped"===e?`It stopped before finishing. Where it got to: ${r(o.ask?.question??o.outcome??"")}`:`Done. Its answer: ${r(o.outcome??"")}`;t.push({rank:s[e],key:`${e}:${o.id}@${c}`,kind:"ending",line:`${d(o.bot,e)}
3
+ ${r(a.text)}${n}`,relayIds:e.filter(e=>e.messageId===a.id).map(e=>e.id),show:u(a.bot,`${a.bot} asks`)})}let p=e.filter(e=>!l.some(t=>t.id===e.messageId)),h="done"===o.status,m="waiting"===o.status&&(0,a.isAppStop)(o.ask)&&!o.ask?.auto;if(h||m){if(o.seen)continue;let e=m?"stopped":"done",a="stopped"===e?`It stopped before finishing. Where it got to: ${r(o.ask?.question??o.outcome??"")}`:`Done. Its answer: ${r(o.outcome??"")}`;t.push({rank:s[e],key:`${e}:${o.id}@${c}`,kind:"ending",line:`${d(o.bot,e)}
4
4
  ${a}`,relayIds:p.map(e=>e.id),show:u(o.bot,"stopped"===e?`${o.bot} stopped`:`${o.bot} finished`)});continue}for(let e of p)t.push({rank:s.progress,key:`progress:${e.id}`,kind:"progress",line:`${d(e.bot,e.kind)}
5
5
  ${r(e.text)}`,relayIds:[e.id],show:u(e.bot,`${e.bot} ${i[e.kind]}`)})}return t.sort((e,t)=>e.rank-t.rank)}])}];
6
6
 
@@ -0,0 +1,3 @@
1
+ module.exports=[911757,e=>{"use strict";var t=e.i(469719),a=e.i(514499),i=e.i(904309),o=e.i(264079);let n={id:"openai",label:"OpenAI",apiKeyName:o.TEXT_MODEL_PROVIDERS.openai.apiKeyName};o.TEXT_MODEL_PROVIDERS.openai.suggestModels;let l=t.z.string().max(a.COMMON_VALIDATE.prompt.max).default(""),s=t.z.object({voice:t.z.string().trim().min(1).max(128).default("marin"),voicePrompt:l,backendModel:t.z.string().trim().min(1).max(128).default(i.LIVE_BACKEND_MODEL),backendPrompt:l,reasoningEffort:t.z.enum(["none","minimal","low","medium","high","xhigh"]).nullable().default("low"),webSearch:t.z.boolean().default(!0)});s.parse({}),e.s(["LIVE_PROVIDER",0,n,"LiveSettingsSchema",0,s])},265143,e=>e.a(async(t,a)=>{try{var i=e.i(875225),o=e.i(518899),n=e.i(528790),l=e.i(613240),s=e.i(340698);e.i(786025);var r=e.i(944971),c=t([n,s]);[n,s]=c.then?(await c)():c;let h=e=>({name:e.name,description:e.description,systemPrompt:e.systemPrompt,icon:e.icon,provider:e.provider,model:e.model,disabled:e.disabled,compactAt:e.compactAt});async function m(){let e=await n.database.select().from(l.botTable).orderBy(l.botTable.createdAt);return e.length?e.filter(e=>!e.disabled).map(h):[r.DEFAULT_BOT]}async function d(e){let t=await u(e);if(t)return h(t);let a=e.trim().toLowerCase(),[s]=await n.database.select().from(l.botTable).where((0,i.eq)(o.sql`lower(${l.botTable.name})`,a));return s?h(s):r.DEFAULT_BOT.name.toLowerCase()===a?r.DEFAULT_BOT:null}async function b(){let[e,t,a]=await Promise.all([n.database.select().from(l.botTable).orderBy(l.botTable.createdAt),n.database.select({botName:l.botMcpToolTable.botName,id:l.mcpToolTable.id,name:l.mcpToolTable.name,serverName:l.mcpToolTable.serverName}).from(l.botMcpToolTable).innerJoin(l.mcpToolTable,(0,i.eq)(l.botMcpToolTable.toolId,l.mcpToolTable.id)),n.database.select({bot:l.threadTable.bot,input:o.sql`coalesce(sum(${l.threadTable.inputTokens}), 0)`,output:o.sql`coalesce(sum(${l.threadTable.outputTokens}), 0)`,lastJobAt:o.sql`max(${l.threadTable.updatedAt})`}).from(l.threadTable).groupBy(l.threadTable.bot)]),s=new Map;for(let{botName:e,...a}of t){let t=s.get(e)??[];t.push(a),s.set(e,t)}let r=new Map(a.map(e=>[e.bot,{input:Number(e.input),output:Number(e.output)}])),c=new Map(a.flatMap(e=>null==e.lastJobAt?[]:[[e.bot,new Date(1e3*Number(e.lastJobAt))]]));return e.map(e=>({...e,tools:s.get(e.name)??[],tokens:r.get(e.name)??{input:0,output:0},lastJobAt:c.get(e.name)??null}))}async function p(){return(0,r.isBotMemoryOn)(await (0,s.readConfig)(r.BOT_MEMORY_KEY))}async function E(){return(0,r.isKeepWorkingOn)(await (0,s.readConfig)(r.KEEP_WORKING_KEY))}async function u(e){let[t]=await n.database.select().from(l.botTable).where((0,i.eq)(l.botTable.name,e));return t??null}async function T(){let e=await n.database.select({name:l.botTable.name}).from(l.botTable);return[...new Set([...e.map(e=>e.name),r.DEFAULT_BOT.name])]}e.s(["findAllBots",0,b,"findJobBot",0,d,"listBotNames",0,T,"listJobBots",0,m,"readBotMemoryOn",0,p,"readKeepWorkingOn",0,E]),a()}catch(e){a(e)}},!1),279041,e=>{"use strict";var t=e.i(911757),a=e.i(264079),i=e.i(834332);let o=[t.LIVE_PROVIDER.apiKeyName],n={image:"IMAGE_MODEL",video:"VIDEO_MODEL",speech:"SPEECH_MODEL",transcription:"TRANSCRIPTION_MODEL"},l={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"}},s="EXA_API_KEY",r="DEFAULT_MODEL",c={key:r,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})))},m=e=>o.includes(e.apiKeyName),d=e=>!!e.signIn||"vercel-ai-gateway"===e.id,b=e=>({key:e.apiKeyName,label:e.label,provider:e.id,signIn:e.signIn,keysAt:e.keysAt,keyLooks:e.keyLooks}),p=[{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(m).map(b)},{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(d).map(e=>({...b(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=>!m(e)&&!d(e)).map(b)},{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:s,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:i.TELEGRAM_TOKEN_KEY,label:"Telegram",site:"telegram.org",hint:"a bot token from @BotFather — then write to your bot, and allow it here"},{key:i.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:i.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:i.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:[c]},{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],...l[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(p.flatMap(e=>e.entries).map(e=>[e.key,e]));let E=p.flatMap(e=>e.entries.map(e=>e.key)),u=Object.fromEntries(p.flatMap(e=>e.entries).filter(e=>e.choices?.length).map(e=>[e.key,e.choices]));e.s(["CONFIG_CHOICES",0,u,"CONFIG_KEYS",0,E,"DEFAULT_MODEL_KEY",0,r,"EXA_API_KEY",0,s,"MEDIA_MODEL_KEYS",0,n])},340698,e=>e.a(async(t,a)=>{try{var i=e.i(875225),o=e.i(528790),n=e.i(613240);e.i(279041);var l=t([o]);async function s(e){let t=process.env[e]?.trim();if(t)return t;let[a]=await o.database.select({value:n.configTable.value}).from(n.configTable).where((0,i.eq)(n.configTable.key,e));return a?.value.trim()||void 0}async function r(e,t){await o.database.insert(n.configTable).values({key:e,value:t}).onConflictDoUpdate({target:n.configTable.key,set:{value:t}})}[o]=l.then?(await l)():l,e.s(["readConfig",0,s,"writeConfig",0,r]),a()}catch(e){a(e)}},!1),834332,e=>{"use strict";let t="TELEGRAM_BOT_TOKEN",a="DISCORD_BOT_TOKEN",i="SLACK_APP_TOKEN",o="SLACK_BOT_TOKEN";e.s(["DISCORD_TOKEN_KEY",0,a,"REACH_CHANNELS",0,["telegram","discord","slack"],"REACH_KEYS",0,{telegram:[t],discord:[a],slack:[i,o]},"SLACK_APP_TOKEN_KEY",0,i,"SLACK_BOT_TOKEN_KEY",0,o,"TELEGRAM_TOKEN_KEY",0,t,"reachPersonKey",0,e=>`REACH_PERSON_${e.toUpperCase()}`])},904309,e=>{"use strict";var t=e.i(469719);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-5.6-luna","LiveFragmentSchema",0,a])}];
2
+
3
+ //# sourceMappingURL=_0oh_99-._.js.map
@@ -1,26 +1,26 @@
1
- module.exports=[539470,e=>e.a(async(t,a)=>{try{var n=e.i(588762),s=e.i(333925),i=e.i(5509),o=e.i(900533),r=e.i(64774),l=t([i]);async function h(){let e=await (0,i.listThreadOverview)();if(!e.length)return null;let t=e.map(e=>{let t=(0,n.formatDistanceToNowStrict)((0,o.toDate)(e.updatedAt),{addSuffix:!0}),a=e.room.questions[0],i="waiting"===e.status&&a?`waiting on the user since ${t} — ${a.bot} asked: ${(0,r.clip)(a.text,s.PROMPT_LINE.jobOutcome)}`:"waiting"===e.status?`stopped ${t}, not finished`:"running"===e.status?`running, last moved ${t}`:`${e.status} ${t}`;return`- "${e.label}" (${e.id}) — ${e.bot} — ${i}`});return`[The threads as this call opened, open work first. They move while you talk.]
2
- ${t.join("\n")}`}[i]=l.then?(await l)():l,e.s(["loadCallStanding",0,h]),a()}catch(e){a(e)}},!1),79290,e=>e.a(async(t,a)=>{try{var n=e.i(333925),s=e.i(973589),i=e.i(51083),o=e.i(799791),r=e.i(5509),l=e.i(1363),h=e.i(232549),c=e.i(343229),d=e.i(520401),u=e.i(871096),m=e.i(340697),f=e.i(636608),p=t([o,r,l,d,m]);async function w(e,t=!1){var a,p,k,b,$,v,_;let S,E=await (0,u.openWorkspace)(),[T,O,A,x,C,L,I,N,M]=await Promise.all([(0,c.loadSkills)(E),(0,l.listNoteIndex)(),(0,l.listAlwaysLoaded)(),(0,l.readNotes)(h.MEMORY_ALWAYS_LISTED,{touch:!1}),(0,m.listConnectedToolNames)(),(0,o.listJobBots)(),(0,d.listRecentTurns)(n.RECENT_CALL.rows),(0,d.readCallSkillsOn)(),(0,o.readBotMemoryOn)()]),R=await (0,r.listCallJobs)(I.map(e=>e.callId)),P=[(0,f.thursdayIdentity)(),t?"":y(),function(e,t,a){let{crowded:n,heavy:s}=(0,f.tidying)(e),o=[...s].sort((e,t)=>t.factCount-e.factCount).slice(0,3).map(e=>e.path),r=n||s.length?`
1
+ module.exports=[539470,e=>e.a(async(t,a)=>{try{var n=e.i(588762),i=e.i(333925),s=e.i(5509),o=e.i(900533),r=e.i(64774),l=t([s]);async function h(){let e=await (0,s.listThreadOverview)();if(!e.length)return null;let t=e.map(e=>{let t=(0,n.formatDistanceToNowStrict)((0,o.toDate)(e.updatedAt),{addSuffix:!0}),a=e.room.questions[0],s="waiting"===e.status&&a?`waiting on the user since ${t} — ${a.bot} asked: ${(0,r.clip)(a.text,i.PROMPT_LINE.jobOutcome)}`:"waiting"===e.status?`stopped ${t}, not finished`:"running"===e.status?`running, last moved ${t}`:`${e.status} ${t}`;return`- "${e.label}" (${e.id}) — ${e.bot} — ${s}`});return`[The threads as this call opened, open work first. They move while you talk.]
2
+ ${t.join("\n")}`}[s]=l.then?(await l)():l,e.s(["loadCallStanding",0,h]),a()}catch(e){a(e)}},!1),79290,e=>e.a(async(t,a)=>{try{var n=e.i(333925),i=e.i(973589),s=e.i(51083),o=e.i(799791),r=e.i(5509),l=e.i(1363),h=e.i(232549),c=e.i(343229),d=e.i(520401),u=e.i(871096),m=e.i(340697),f=e.i(636608),p=t([o,r,l,d,m]);async function w(e,t=!1){var a,p,k,b,$,v,_;let S,E=await (0,u.openWorkspace)(),[T,A,O,x,C,I,L,N,M]=await Promise.all([(0,c.loadSkills)(E),(0,l.listNoteIndex)(),(0,l.listAlwaysLoaded)(),(0,l.readNotes)(h.MEMORY_ALWAYS_LISTED,{touch:!1}),(0,m.listConnectedToolNames)(),(0,o.listJobBots)(),(0,d.listRecentTurns)(n.RECENT_CALL.rows),(0,d.readCallSkillsOn)(),(0,o.readBotMemoryOn)()]),R=await (0,r.listCallJobs)(L.map(e=>e.callId)),P=[(0,f.thursdayIdentity)(),t?"":y(),function(e,t,a){let{crowded:n,heavy:i}=(0,f.tidying)(e),o=[...i].sort((e,t)=>t.factCount-e.factCount).slice(0,3).map(e=>e.path),r=n||i.length?`
3
3
 
4
4
  Saved memory has grown past what it holds well${o.length?` (${o.join(", ")})`:""}: say so once in what you return, go through what looks out of date with the user, and forget only what they name.`:"",l=new Set(a.map(e=>e.path)),c=new Set(t.map(e=>e.id)),d=`## Memory
5
5
 
6
- What you have kept from talking with this user — the only thing that survives a call, and what lets you know them.`,u=`Who they are, and how they want things done and said — follow what is under preferences. The #id is what \`replaces\` and \`${i.TOOL_NAMES.memory_forget}\` take:
6
+ What you have kept from talking with this user — the only thing that survives a call, and what lets you know them.`,u=`Who they are, and how they want things done and said — follow what is under preferences. The #id is what \`replaces\` and \`${s.TOOL_NAMES.memory_forget}\` take:
7
7
 
8
- ${a.map(e=>(function(e,t){let{shown:a,hidden:n}=(0,f.expandedFacts)(e.facts,t),s=a.map(e=>`- ${e.text} #${e.id}`);return n&&s.push(`- … ${n} older not shown — \`${i.TOOL_NAMES.memory_recall}\` ${e.path} opens the whole note`),`${e.path} — ${e.description}
9
- ${s.length?s.join("\n"):"- (nothing yet)"}`})(e,c)).join("\n\n")}`,m=t.filter(e=>!l.has(e.path)),p=m.length?`Already known — carried into every call:
8
+ ${a.map(e=>(function(e,t){let{shown:a,hidden:n}=(0,f.expandedFacts)(e.facts,t),i=a.map(e=>`- ${e.text} #${e.id}`);return n&&i.push(`- … ${n} older not shown — \`${s.TOOL_NAMES.memory_recall}\` ${e.path} opens the whole note`),`${e.path} — ${e.description}
9
+ ${i.length?i.join("\n"):"- (nothing yet)"}`})(e,c)).join("\n\n")}`,m=t.filter(e=>!l.has(e.path)),p=m.length?`Already known — carried into every call:
10
10
 
11
11
  ${(0,f.carriedLines)(m)}`:"",w=`Every other note — path — what is under it (facts) "what the user calls it":
12
12
 
13
13
  ${(0,f.noteLines)(e.filter(e=>!l.has(e.path)),n)}${r}
14
14
 
15
- Open a note before answering out of it; a topic not listed is one you know nothing about. A fact marked \`said\` came from a call; \`${i.TOOL_NAMES.memory_conversation}\` opens that call when the line alone cannot answer.
15
+ Open a note before answering out of it; a topic not listed is one you know nothing about. A fact marked \`said\` came from a call; \`${s.TOOL_NAMES.memory_conversation}\` opens that call when the line alone cannot answer.
16
16
 
17
- Keep what the user tells you as it comes up, with \`${i.TOOL_NAMES.memory_remember}\`, without waiting to be asked: what they actually said, never a guess, nothing they asked you not to keep, and from a bot's report only what it confirmed about them.
17
+ Keep what the user tells you as it comes up, with \`${s.TOOL_NAMES.memory_remember}\`, without waiting to be asked: what they actually said, never a guess, nothing they asked you not to keep, and from a bot's report only what it confirmed about them.
18
18
 
19
19
  **Keep memory clean as you write.** A fact that repeats, narrows or changes one already in the note replaces it, merged into one line, rather than sitting beside it. A later call finds a note only by its path, its line and the names in quotes: keep the line true, and give something new its own path below.
20
20
 
21
- ${h.MEMORY_PATHS.map(e=>`- ${e.path} — ${e.of}`).join("\n")}`;return[d,u,p,w].filter(Boolean).join("\n\n")}(O,A,x.notes),(a=L,p=(0,f.reachNames)(N?[]:T,C),k=M,0===a.length?"":`## Background work
21
+ ${h.MEMORY_PATHS.map(e=>`- ${e.path} — ${e.of}`).join("\n")}`;return[d,u,p,w].filter(Boolean).join("\n\n")}(A,O,x.notes),(a=I,p=(0,f.reachNames)(N?[]:T,C),k=M,0===a.length?"":`## Background work
22
22
 
23
- Who you hand work to — the names \`${i.TOOL_NAMES.thread_start}\` takes.
23
+ Who you hand work to — the names \`${s.TOOL_NAMES.thread_start}\` takes.
24
24
 
25
25
  ${a.map(e=>`- **${e.name}** — ${e.description}`).join("\n")}${p?`
26
26
 
@@ -28,41 +28,41 @@ What bots can reach for: ${p}.`:""}
28
28
 
29
29
  **A bot can take on almost anything, and anything that takes more than a few seconds is a bot's**; a note, a look at a file or one command is yours. A bot has this computer, a real browser, the web, a shell to build what is missing and far more time than a call; it signs in where it has to and carries work to the end, so something you do not know how to do is work for a bot, not a no. Bots bring each other in, so work that spans several things is still one thread.${k?" Each bot keeps its own memory from thread to thread: when the user says how a bot should work from now on, pass it to that bot to remember.":""}
30
30
 
31
- **Work lives in threads.** A thread's bot remembers that thread and nothing else, so the same bot started on a new one begins from nothing. More about work already handed over — a correction, the next step once it finished, going on after it stopped — is said to that thread (\`${i.TOOL_NAMES.thread_tell}\`); only a request that stands on its own starts a new one (\`${i.TOOL_NAMES.thread_start}\`). The threads open as this call started come into the conversation at the start, and they move while you talk: \`${i.TOOL_NAMES.thread_status}\` reads them as they are now, before you answer about one or hand anything over. Ask the user which it is only when the request could be either. Write the request in the user's own words, with what it stands on — including how they told you they want work done — and nothing they did not say.
31
+ **Work lives in threads.** A thread's bot remembers that thread and nothing else, so the same bot started on a new one begins from nothing. More about work already handed over — a correction, the next step once it finished, going on after it stopped — is said to that thread (\`${s.TOOL_NAMES.thread_tell}\`); only a request that stands on its own starts a new one (\`${s.TOOL_NAMES.thread_start}\`). The threads open as this call started come into the conversation at the start, and they move while you talk: \`${s.TOOL_NAMES.thread_status}\` reads them as they are now, before you answer about one or hand anything over. Ask the user which it is only when the request could be either. Write the request in the user's own words, with what it stands on — including how they told you they want work done — and nothing they did not say.
32
32
 
33
- **Work that should start by itself — every morning, every few hours — is a routine.** \`${i.TOOL_NAMES.routine}\` makes one from a bot, the work in the user's own words, and when; from then on it starts a thread for it each time without being asked, and the result reaches the user like any thread's. Ask once for whichever of those they left out, and read the ones that exist before making, changing or deleting one.
33
+ **Work that should start by itself — every morning, every few hours — is a routine.** \`${s.TOOL_NAMES.routine}\` makes one from a bot, the work in the user's own words, and when; from then on it starts a thread for it each time without being asked, and the result reaches the user like any thread's. Ask once for whichever of those they left out, and read the ones that exist before making, changing or deleting one.
34
34
 
35
- Updates and questions from threads reach the conversation by themselves, naming their thread and the bot that asks; they come from bots, not the user, and a question is answered with \`${i.TOOL_NAMES.thread_answer}\`. When the user wants to see what a thread made, \`${i.TOOL_NAMES.thread_show}\` puts it on their screen. Once you have explained enough of how a thread ended, mark it with \`${i.TOOL_NAMES.thread_seen}\`, or leave it for the user to open; never mention seen to them.`),(b=E.cwd,$=N?T:[],S=`## This computer
35
+ Updates and questions from threads reach the conversation by themselves, naming their thread and the bot that asks; they come from bots, not the user, and a question is answered with \`${s.TOOL_NAMES.thread_answer}\`. When the user wants to see what a thread made, \`${s.TOOL_NAMES.thread_show}\` puts it on their screen. Once you have explained enough of how a thread ended, mark it with \`${s.TOOL_NAMES.thread_seen}\`, or leave it for the user to open; never mention seen to them.`),(b=E.cwd,$=N?T:[],S=`## This computer
36
36
 
37
37
  Current Cwd: ${b}
38
38
  Platform: ${process.platform}
39
39
 
40
- Where \`${i.TOOL_NAMES.bash}\` runs, and what the paths you get back are relative to. Each command is cut off after ${Math.round(n.CALL_EXEC_TIMEOUT_MS/1e3)} seconds; anything longer is a bot's.
40
+ Where \`${s.TOOL_NAMES.bash}\` runs, and what the paths you get back are relative to. Each command is cut off after ${Math.round(n.CALL_EXEC_TIMEOUT_MS/1e3)} seconds; anything longer is a bot's.
41
41
 
42
- ${(0,s.guideLine)()}`,0===$.length?S:`${S}
42
+ ${(0,i.guideLine)()}`,0===$.length?S:`${S}
43
43
 
44
- Skills are written-down ways of doing things here. \`${i.TOOL_NAMES.load_skill}\` opens one, and what it says goes for you too: read one when it covers what was asked and the doing is a glance. Anything longer it describes is still work to hand over, with what the skill said.
44
+ Skills are written-down ways of doing things here. \`${s.TOOL_NAMES.load_skill}\` opens one, and what it says goes for you too: read one when it covers what was asked and the doing is a glance. Anything longer it describes is still work to hand over, with what the skill said.
45
45
 
46
46
  ${(0,f.skillLines)($,{short:!0})}`),t?`## Answer in writing
47
47
 
48
48
  This call is in writing: there is no voice, and what you write is what the user reads, so answer them directly, in their language. Say the relevant facts, whether the task is complete, and what comes next — for work you handed over, who has it and whether it carries an earlier thread on or starts a new one — or the one question they have to answer first. Use confirmed values from tool results and the notes above, and never invent a successful action. Keep it short and plain.`:`## Return the result
49
49
 
50
- Return the relevant facts, whether the task is complete, and what comes next — for work you handed over, who has it and whether it carries an earlier thread on or starts a new one — or the one question the user has to answer first. Use confirmed values from tool results and the notes above, and never invent a successful action. What you return is said aloud: keep it short and plain.`,(v=I,_=R,v.some(e=>e.turns.length>0)?`## Earlier calls
50
+ Return the relevant facts, whether the task is complete, and what comes next — for work you handed over, who has it and whether it carries an earlier thread on or starts a new one — or the one question the user has to answer first. Use confirmed values from tool results and the notes above, and never invent a successful action. What you return is said aloud: keep it short and plain.`,(v=L,_=R,v.some(e=>e.turns.length>0)?`## Earlier calls
51
51
 
52
52
  What was said on the last calls, verbatim, newest last. It is the past: pick it up when the user does, and never answer it as a new request.
53
53
 
54
- A \`${i.TOOL_NAMES.thread_start}\` line carries the thread's handle and how it ended; the handle is for the thread tools, never said aloud. What they ask for now is often one of these carried further.
54
+ A \`${s.TOOL_NAMES.thread_start}\` line carries the thread's handle and how it ended; the handle is for the thread tools, never said aloud. What they ask for now is often one of these carried further.
55
55
 
56
- ${(0,f.recentCallLines)(v.map(e=>({...e,jobs:_.filter(t=>t.callId===e.callId)})),n.RECENT_CALL.tokens)}`:""),g(e)].filter(Boolean).join("\n\n");return(0,f.logPromptSize)("thursday",P),P}[o,r,l,d,m]=p.then?(await p)():p;let y=()=>`IMPORTANT — always follow this: when the user wants the call to end, however they say it, forget every other task, answer yes in one word of their language, then immediately, without thinking, use the ${i.TOOL_NAMES.end_call} tool.`,g=e=>e?.trim()?`## Additional instructions
56
+ ${(0,f.recentCallLines)(v.map(e=>({...e,jobs:_.filter(t=>t.callId===e.callId)})),n.RECENT_CALL.tokens)}`:""),g(e)].filter(Boolean).join("\n\n");return(0,f.logPromptSize)("thursday",P),P}[o,r,l,d,m]=p.then?(await p)():p;let y=()=>`IMPORTANT — always follow this: when the user wants the call to end, however they say it, forget every other task, answer yes in one word of their language, then immediately, without thinking, use the ${s.TOOL_NAMES.end_call} tool.`,g=e=>e?.trim()?`## Additional instructions
57
57
 
58
58
  Written by the user. Follow them together with everything above.
59
59
 
60
- ${e.trim()}`:"";e.s(["loadThursdayPrompt",0,w]),a()}catch(e){a(e)}},!1),480791,e=>{"use strict";var t=e.i(417043),a=e.i(903438);let n="https://slack.com/api",s=new Set(["invalid_auth","not_authed","account_inactive","token_revoked","not_allowed_token_type","missing_scope"]);e.s(["createSlack",0,function(e,i){async function o(e,a,r=i){let l=await fetch(`${n}/${e}`,{method:"POST",headers:{authorization:`Bearer ${r}`,"content-type":"application/json; charset=utf-8"},body:JSON.stringify(a)}),h=await l.json().catch(()=>null);if(h?.ok)return h;let c=h?.error??`http_${l.status}`,d="missing_scope"===c?`Slack says the app lacks a permission (${h?.needed??"a scope"}) — make it from the manifest in the guide.`:`Slack answered ${c} to ${e}`;throw s.has(c)?new t.ChannelRefusal(d):Error(d)}let r=new Map;async function l(e){let t=r.get(e);if(t)return t;let a=await o("users.info",{user:e}).then(t=>t.user?.real_name||t.user?.name||e).catch(()=>e);return r.set(e,a),a}async function h(e,t){if("events_api"===e){let e=t.event??{},a=!e.subtype||"file_share"===e.subtype;return"message"===e.type&&"im"===e.channel_type&&a&&!e.bot_id&&e.user&&e.channel?{kind:"message",chat:e.channel,name:await l(e.user),words:(e.text??"").trim(),files:(e.files??[]).flatMap(e=>{let t=e.url_private_download;if(!t)return[];let a=e.name??"file";return[{name:a,fetch:async()=>{let n=await fetch(t,{headers:{authorization:`Bearer ${i}`}});if(!n.ok)throw Error(`Slack answered ${n.status} for the file`);return new File([await n.arrayBuffer()],a,{type:e.mimetype??""})}}]}),unreadable:!1}:null}return"interactive"===e&&"block_actions"===t.type?t.channel?.id?{kind:"press",chat:t.channel.id,data:t.actions?.[0]?.value??"",under:t.message?.ts&&t.message.text?{id:t.message.ts,text:t.message.text}:null}:null:null}return{async listen(t,n){let s=await o("auth.test",{}),{url:i}=await o("apps.connections.open",{},e);t.ready(s.user?`@${s.user}`:"the app");let r=await (0,a.runSocket)(i,{message(e,a){let{type:n,envelope_id:s,payload:i}=e;s&&a({envelope_id:s}),n&&i&&h(n,i).then(e=>{e&&t.incoming(e)})}},n);if(!n.aborted)throw Error(`Slack closed the connection (${r.code})`)},async say(e,t,n){let s=(0,a.inPieces)(t,2900);for(let[t,a]of s.entries()){let i=n?.length&&t===s.length-1;await o("chat.postMessage",{channel:e,text:a,unfurl_links:!1,...i?{blocks:[{type:"section",text:{type:"plain_text",text:a}},{type:"actions",elements:n.slice(0,25).map((e,t)=>({type:"button",action_id:`choice_${t}`,text:{type:"plain_text",text:e.text.slice(0,75)},value:e.data}))}]}:{}})}},async typing(){},async settle(e,t,a){await o("chat.update",{channel:e,ts:t,text:a.slice(0,2900),blocks:[]}).catch(()=>{})},async sendFile(e,t,a){let s=new URLSearchParams({filename:a,length:String(t.byteLength)}),r=await fetch(`${n}/files.getUploadURLExternal`,{method:"POST",headers:{authorization:`Bearer ${i}`},body:s}),l=await r.json();if(!l.ok||!l.upload_url||!l.file_id)throw Error(`Slack answered ${l.error??r.status} to the upload`);await fetch(l.upload_url,{method:"POST",body:new Blob([t])}),await o("files.completeUploadExternal",{files:[{id:l.file_id,title:a}],channel_id:e})}}}])},644301,e=>{"use strict";var t=e.i(333925),a=e.i(417043);let n="https://api.telegram.org";e.s(["createTelegram",0,function(e){async function s(t,s,i){let o=s instanceof FormData,r=await fetch(`${n}/bot${e}/${t}`,{method:"POST",signal:i,...o?{body:s}:{headers:{"content-type":"application/json"},body:JSON.stringify(s??{})}}),l=await r.json().catch(()=>null);if(l?.ok)return l.result;let h=l?.description??`Telegram answered ${r.status}`;throw 401===r.status?new a.ChannelRefusal(h):Error(h)}async function i(t,a,i){let{file_path:o}=await s("getFile",{file_id:t});if(!o)throw Error("Telegram did not say where the file is");let r=await fetch(`${n}/file/bot${e}/${o}`);if(!r.ok)throw Error(`Telegram answered ${r.status} for the file`);let l=o.includes(".")?o.slice(o.lastIndexOf(".")):"";return new File([await r.arrayBuffer()],a.includes(".")?a:`${a}${l}`,i?{type:i}:void 0)}return{async listen(e,a){let n=await s("getMe",void 0,a);e.ready(n.username?`@${n.username}`:n.first_name??"the bot");let o=0;for(;!a.aborted;)for(let n of(await s("getUpdates",{offset:o,timeout:t.REACH.pollSeconds,allowed_updates:["message","callback_query"]},AbortSignal.any([a,AbortSignal.timeout((t.REACH.pollSeconds+15)*1e3)])))){o=n.update_id+1;let t=function(e){let t,a=e.callback_query;if(a)return s("answerCallbackQuery",{callback_query_id:a.id}).catch(()=>{}),{kind:"press",chat:String(a.from.id),data:a.data??"",under:a.message?.text?{id:String(a.message.message_id),text:a.message.text}:null};let n=e.message;if(!n?.from||"private"!==n.chat.type)return null;let o=n.photo?.at(-1),r=n.document?{id:n.document.file_id,name:n.document.file_name??"file",type:n.document.mime_type}:o?{id:o.file_id,name:`photo-${n.message_id}`,type:""}:null;return{kind:"message",chat:String(n.chat.id),name:(t=n.from,[t?.first_name,t?.last_name].filter(Boolean).join(" ")||(t?.username?`@${t.username}`:"Someone")),words:(n.text??n.caption??"").trim(),files:r?[{name:r.name,fetch:()=>i(r.id,r.name,r.type)}]:[],unreadable:!!(n.voice||n.audio||n.video)}}(n);t&&e.incoming(t)}},async say(e,t,a){await s("sendMessage",{chat_id:e,text:t,link_preview_options:{is_disabled:!0},...a?.length?{reply_markup:{inline_keyboard:a.map(e=>[{text:e.text,callback_data:e.data}])}}:{}})},async typing(e){await s("sendChatAction",{chat_id:e,action:"typing"}).catch(()=>{})},async settle(e,t,a){await s("editMessageText",{chat_id:e,message_id:Number(t),text:a,link_preview_options:{is_disabled:!0}}).catch(()=>{})},async sendFile(e,t,a,n){let i=new FormData;i.set("chat_id",e),i.set(n?"photo":"document",new Blob([t]),a),await s(n?"sendPhoto":"sendDocument",i)}}}])},312485,e=>e.a(async(t,a)=>{try{var n=e.i(912714),s=e.i(232347),i=e.i(333925),o=e.i(247839),r=e.i(986507),l=e.i(49002),h=e.i(811592),c=e.i(5509),d=e.i(724185),u=e.i(822931),m=e.i(520401),f=e.i(181300),p=e.i(375814),w=e.i(871096),y=e.i(317613),g=e.i(938281),k=e.i(212389),b=e.i(64774),$=e.i(417043),v=e.i(854455),_=e.i(735186),S=e.i(480791),E=e.i(644301),T=t([r,l,h,c,d,m,f]);[r,l,h,c,d,m,f]=T.then?(await T)():T;let W={telegram:e=>(0,E.createTelegram)(e),discord:e=>(0,v.createDiscord)(e),slack:(e,t)=>(0,S.createSlack)(e,t)},D=globalThis,B=D.__reach??={live:new Map,last:null,told:new Set,due:new Map,choices:new Map,listening:null,looking:null},F=()=>s.appEvents.emit({type:"reach"});async function O(e){let t=await (0,d.readConfig)((0,_.reachPersonKey)(e));if(!t)return null;try{let e=JSON.parse(t);return"string"==typeof e.chat&&"string"==typeof e.name?{chat:e.chat,name:e.name}:null}catch{return null}}async function A(e){for(let t of e?[e]:_.REACH_CHANNELS){let a=B.live.get(t);a?.stop.abort(),B.live.delete(t),e&&(await (0,d.removeConfig)((0,_.reachPersonKey)(t)),a?.line&&await (0,m.endCall)(a.line.callId).catch(()=>{}));let n=await Promise.all(_.REACH_KEYS[t].map(d.readConfig));if(!n.every(e=>!!e))continue;let s={name:t,channel:W[t](...n),stop:new AbortController,bot:null,problem:null,asking:null,line:null,turn:Promise.resolve()};B.live.set(t,s),x(s)}B.live.size&&(B.listening??=s.appEvents.subscribe(e=>{"threads"!==e.type||B.looking||(B.looking=setTimeout(()=>{B.looking=null,P().catch(e=>g.logger.error("reach: open work",e))},2e3))})),F()}async function x(e){let{signal:t}=e.stop,a=t=>{e.problem!==t&&(e.problem=t,F())};for(;!t.aborted;){try{await e.channel.listen({ready:t=>{e.bot=t,e.problem=null,F()},incoming:t=>void C(e,t).catch(t=>g.logger.error(`reach ${e.name}: what arrived`,t))},t)}catch(s){if(t.aborted)return;let n=s instanceof Error?s.message:String(s);if(s instanceof $.ChannelRefusal)return g.logger.warn(`reach ${e.name}: ${n}`),a(n);a(n)}await new Promise(e=>setTimeout(e,i.REACH.retryMs))}}async function C(e,t){let{channel:a}=e,n=await O(e.name);if("press"===t.kind){if(n?.chat!==t.chat)return;return q(e,n,t.data,t.under)}if(n?.chat!==t.chat)return n?void await a.say(t.chat,"This Thursday already answers someone else."):(e.asking={chat:t.chat,name:t.name},F(),void await a.say(t.chat,"Almost there. Open Thursday on your computer and press Allow, then write again."));B.last=e.name;let s=t.files.length?await (0,y.keepGivenFiles)(await Promise.all(t.files.map(e=>e.fetch()))):[],i=[t.words,...s].filter(Boolean).join("\n");if(!i){t.unreadable&&await a.say(t.chat,"I can read words, pictures and files here — not voice or video yet. Write it instead.");return}I(e,n,i,i)}async function L(e){let t=e.line;e.line=null,t&&await (0,m.endCall)(t.callId).catch(()=>{})}function I(e,t,a,n,s){let i=e.turn.then(()=>N(e,t,a,n,s));return e.turn=i.then(()=>{},()=>{}),i}async function N(e,t,a,n,s){let{channel:l}=e;l.typing(t.chat).catch(()=>{});let h=setInterval(()=>void l.typing(t.chat).catch(()=>{}),4e3);try{let r=o.LiveSettingsSchema.parse({}),h=e.line;(!h||Date.now()-h.lastAt>i.REACH.idleMs||!await (0,m.isCallOpen)(h.callId))&&(await L(e),e.line={...await (0,f.openTextCall)(r),messages:[],lastAt:0});let c=e.line,d=await (0,f.answerInWriting)({callId:c.callId,settings:r,standing:c.standing,messages:[...c.messages,{role:"user",content:a}],said:n});c.messages=d.messages,c.lastAt=Date.now();let u=(0,b.plainText)(d.text)||d.did.join("\n"),p=function(e){let t=[],a=e;for(;a.length>i.REACH.chars;){let e=a.slice(0,i.REACH.chars),n=Math.max(e.lastIndexOf("\n\n"),e.lastIndexOf("\n")),s=n>i.REACH.chars/2?n:i.REACH.chars;t.push(a.slice(0,s).trim()),a=a.slice(s).trim()}return a&&t.push(a),t}(u||"…");for(let[e,a]of p.entries())await l.say(t.chat,a,e===p.length-1?s:void 0);return await M(e,t,d.text),!0}catch(n){let a=(0,k.isPublicError)(n)?n.message:(0,r.modelErrorToString)(n);return g.logger.warn(`reach ${e.name}: ${a}`),await l.say(t.chat,a).catch(()=>{}),!1}finally{clearInterval(h)}}async function M(e,t,a){for(let s of(await (0,w.filesOnDisk)((0,p.pathsIn)(a),null)).slice(-i.REACH.files)){let a=await (0,w.insideWorkspace)(s),o=a?await (0,n.stat)(a).catch(()=>null):null;a&&o&&!(o.size>i.REACH.fileBytes)&&await e.channel.sendFile(t.chat,await (0,n.readFile)(a),s.split("/").pop()??"file","image"===(0,p.viewKindOf)(s)).catch(t=>g.logger.warn(`reach ${e.name}: could not send ${s}`,t))}}async function R(){for(let e of[...B.last?[B.last]:[],..._.REACH_CHANNELS.filter(e=>e!==B.last)]){let t=B.live.get(e),a=t?await O(e):null;if(t&&a)return{live:t,person:a}}return null}async function P(){if(!await R())return;let e=z(await (0,c.listInboxThreads)()),t=new Set(e.map(e=>e.key));for(let[e,a]of B.due)t.has(e)||(clearTimeout(a),B.due.delete(e));for(let t of e)B.told.has(t.key)||B.due.has(t.key)||B.due.set(t.key,setTimeout(()=>void j(t.key),i.REACH.notifyAfterMs))}let z=e=>(0,u.openWork)(e).filter(e=>"progress"!==e.kind);async function j(e){B.due.delete(e);let t=await R();if(!t||B.told.has(e))return;let a=await (0,c.listInboxThreads)(),n=z(a).find(t=>t.key===e);if(!n)return;let s=a.find(t=>t.room.questions.some(t=>`question:${t.id}`===e)),i=s?.room.questions.find(t=>`question:${t.id}`===e),o=(i?.options??[]).map((e,t)=>{let a=`${i?.id.slice(0,40)}:${t}`;return B.choices.set(a,{threadId:s?.id??"",bot:i?.bot??"",question:i?.id??"",answer:e}),{text:e,data:a}});B.told.add(e),await I(t.live,t.person,n.line,null,o)?await (0,h.acceptRoomRelays)(n.relayIds):B.told.delete(e)}async function q(e,t,a,n){let s=B.choices.get(a);if(!s)return void await e.channel.say(t.chat,"That question is no longer open here. Write your answer instead.");for(let[e,t]of B.choices)t.question===s.question&&B.choices.delete(e);try{await (0,l.answerThread)(s.threadId,s.answer,"user",s.bot),n&&await e.channel.settle(t.chat,n.id,`${n.text}
60
+ ${e.trim()}`:"";e.s(["loadThursdayPrompt",0,w]),a()}catch(e){a(e)}},!1),480791,e=>{"use strict";var t=e.i(417043),a=e.i(903438);let n="https://slack.com/api",i=new Set(["invalid_auth","not_authed","account_inactive","token_revoked","not_allowed_token_type","missing_scope"]);e.s(["createSlack",0,function(e,s){async function o(e,a,r=s){let l=await fetch(`${n}/${e}`,{method:"POST",headers:{authorization:`Bearer ${r}`,"content-type":"application/json; charset=utf-8"},body:JSON.stringify(a)}),h=await l.json().catch(()=>null);if(h?.ok)return h;let c=h?.error??`http_${l.status}`,d="missing_scope"===c?`Slack says the app lacks a permission (${h?.needed??"a scope"}) — make it from the manifest in the guide.`:`Slack answered ${c} to ${e}`;throw i.has(c)?new t.ChannelRefusal(d):Error(d)}let r=new Map;async function l(e){let t=r.get(e);if(t)return t;let a=await o("users.info",{user:e}).then(t=>t.user?.real_name||t.user?.name||e).catch(()=>e);return r.set(e,a),a}async function h(e,t){if("events_api"===e){let e=t.event??{},a=!e.subtype||"file_share"===e.subtype;return"message"===e.type&&"im"===e.channel_type&&a&&!e.bot_id&&e.user&&e.channel?{kind:"message",chat:e.channel,name:await l(e.user),words:(e.text??"").trim(),files:(e.files??[]).flatMap(e=>{let t=e.url_private_download;if(!t)return[];let a=e.name??"file";return[{name:a,fetch:async()=>{let n=await fetch(t,{headers:{authorization:`Bearer ${s}`}});if(!n.ok)throw Error(`Slack answered ${n.status} for the file`);return new File([await n.arrayBuffer()],a,{type:e.mimetype??""})}}]}),unreadable:!1}:null}return"interactive"===e&&"block_actions"===t.type?t.channel?.id?{kind:"press",chat:t.channel.id,data:t.actions?.[0]?.value??"",under:t.message?.ts&&t.message.text?{id:t.message.ts,text:t.message.text}:null}:null:null}return{async listen(t,n){let i=await o("auth.test",{}),{url:s}=await o("apps.connections.open",{},e);t.ready(i.user?`@${i.user}`:"the app",null);let r=await (0,a.runSocket)(s,{message(e,a){let{type:n,envelope_id:i,payload:s}=e;i&&a({envelope_id:i}),n&&s&&h(n,s).then(e=>{e&&t.incoming(e)})}},n);if(!n.aborted)throw Error(`Slack closed the connection (${r.code})`)},async say(e,t,n){let i=(0,a.inPieces)(t,2900);for(let[t,a]of i.entries()){let s=n?.length&&t===i.length-1;await o("chat.postMessage",{channel:e,text:a,unfurl_links:!1,...s?{blocks:[{type:"section",text:{type:"plain_text",text:a}},{type:"actions",elements:n.slice(0,25).map((e,t)=>({type:"button",action_id:`choice_${t}`,text:{type:"plain_text",text:e.text.slice(0,75)},value:e.data}))}]}:{}})}},async typing(){},async settle(e,t,a){await o("chat.update",{channel:e,ts:t,text:a.slice(0,2900),blocks:[]}).catch(()=>{})},async sendFile(e,t,a){let i=new URLSearchParams({filename:a,length:String(t.byteLength)}),r=await fetch(`${n}/files.getUploadURLExternal`,{method:"POST",headers:{authorization:`Bearer ${s}`},body:i}),l=await r.json();if(!l.ok||!l.upload_url||!l.file_id)throw Error(`Slack answered ${l.error??r.status} to the upload`);await fetch(l.upload_url,{method:"POST",body:new Blob([t])}),await o("files.completeUploadExternal",{files:[{id:l.file_id,title:a}],channel_id:e})}}}])},644301,e=>{"use strict";var t=e.i(333925),a=e.i(417043);let n="https://api.telegram.org";e.s(["createTelegram",0,function(e){async function i(t,i,s){let o=i instanceof FormData,r=await fetch(`${n}/bot${e}/${t}`,{method:"POST",signal:s,...o?{body:i}:{headers:{"content-type":"application/json"},body:JSON.stringify(i??{})}}),l=await r.json().catch(()=>null);if(l?.ok)return l.result;let h=l?.description??`Telegram answered ${r.status}`;throw 401===r.status?new a.ChannelRefusal(h):Error(h)}async function s(t,a,s){let{file_path:o}=await i("getFile",{file_id:t});if(!o)throw Error("Telegram did not say where the file is");let r=await fetch(`${n}/file/bot${e}/${o}`);if(!r.ok)throw Error(`Telegram answered ${r.status} for the file`);let l=o.includes(".")?o.slice(o.lastIndexOf(".")):"";return new File([await r.arrayBuffer()],a.includes(".")?a:`${a}${l}`,s?{type:s}:void 0)}return{async listen(e,a){let n=await i("getMe",void 0,a);e.ready(n.username?`@${n.username}`:n.first_name??"the bot",n.username?`https://t.me/${n.username}`:null);let o=0;for(;!a.aborted;)for(let n of(await i("getUpdates",{offset:o,timeout:t.REACH.pollSeconds,allowed_updates:["message","callback_query"]},AbortSignal.any([a,AbortSignal.timeout((t.REACH.pollSeconds+15)*1e3)])))){o=n.update_id+1;let t=function(e){let t,a=e.callback_query;if(a)return i("answerCallbackQuery",{callback_query_id:a.id}).catch(()=>{}),{kind:"press",chat:String(a.from.id),data:a.data??"",under:a.message?.text?{id:String(a.message.message_id),text:a.message.text}:null};let n=e.message;if(!n?.from||"private"!==n.chat.type)return null;let o=n.photo?.at(-1),r=n.document?{id:n.document.file_id,name:n.document.file_name??"file",type:n.document.mime_type}:o?{id:o.file_id,name:`photo-${n.message_id}`,type:""}:null;return{kind:"message",chat:String(n.chat.id),name:(t=n.from,[t?.first_name,t?.last_name].filter(Boolean).join(" ")||(t?.username?`@${t.username}`:"Someone")),words:(n.text??n.caption??"").trim(),files:r?[{name:r.name,fetch:()=>s(r.id,r.name,r.type)}]:[],unreadable:!!(n.voice||n.audio||n.video)}}(n);t&&e.incoming(t)}},async say(e,t,a){await i("sendMessage",{chat_id:e,text:t,link_preview_options:{is_disabled:!0},...a?.length?{reply_markup:{inline_keyboard:a.map(e=>[{text:e.text,callback_data:e.data}])}}:{}})},async typing(e){await i("sendChatAction",{chat_id:e,action:"typing"}).catch(()=>{})},async settle(e,t,a){await i("editMessageText",{chat_id:e,message_id:Number(t),text:a,link_preview_options:{is_disabled:!0}}).catch(()=>{})},async sendFile(e,t,a,n){let s=new FormData;s.set("chat_id",e),s.set(n?"photo":"document",new Blob([t]),a),await i(n?"sendPhoto":"sendDocument",s)}}}])},312485,e=>e.a(async(t,a)=>{try{var n=e.i(912714),i=e.i(232347),s=e.i(333925),o=e.i(247839),r=e.i(986507),l=e.i(49002),h=e.i(811592),c=e.i(5509),d=e.i(724185),u=e.i(822931),m=e.i(520401),f=e.i(181300),p=e.i(375814),w=e.i(871096),y=e.i(317613),g=e.i(938281),k=e.i(212389),b=e.i(64774),$=e.i(417043),v=e.i(854455),_=e.i(735186),S=e.i(480791),E=e.i(644301),T=t([r,l,h,c,d,m,f,y]);[r,l,h,c,d,m,f,y]=T.then?(await T)():T;let D={telegram:e=>(0,E.createTelegram)(e),discord:e=>(0,v.createDiscord)(e),slack:(e,t)=>(0,S.createSlack)(e,t)},B=globalThis,z=B.__reach??={live:new Map,last:null,told:new Set,due:new Map,choices:new Map,listening:null,looking:null,idle:null},F=()=>i.appEvents.emit({type:"reach"});async function A(e){let t=await (0,d.readConfig)((0,_.reachPersonKey)(e));if(!t)return null;try{let e=JSON.parse(t);return"string"==typeof e.chat&&"string"==typeof e.name?{chat:e.chat,name:e.name}:null}catch{return null}}async function O(e){for(let t of e?[e]:_.REACH_CHANNELS){let a=z.live.get(t);a?.stop.abort(),z.live.delete(t),e&&(await (0,d.removeConfig)((0,_.reachPersonKey)(t)),a?.line&&await (0,m.endCall)(a.line.callId).catch(()=>{}));let n=await Promise.all(_.REACH_KEYS[t].map(d.readConfig));if(!n.every(e=>!!e))continue;let i={name:t,channel:D[t](...n),stop:new AbortController,bot:null,link:null,problem:null,asking:null,line:null,turn:Promise.resolve()};z.live.set(t,i),x(i)}z.live.size&&(z.listening??=i.appEvents.subscribe(e=>{"threads"!==e.type||z.looking||(z.looking=setTimeout(()=>{z.looking=null,q().catch(e=>g.logger.error("reach: open work",e))},2e3))}),q().catch(e=>g.logger.error("reach: open work",e)),z.idle??=setInterval(()=>{I().catch(e=>g.logger.error("reach: idle lines",e))},s.REACH.idleMs).unref()),F()}async function x(e){let{signal:t}=e.stop,a=t=>{e.problem!==t&&(e.problem=t,F())};for(;!t.aborted;){try{await e.channel.listen({ready:(t,a)=>{e.bot=t,e.link=a,e.problem=null,F()},incoming:t=>void C(e,t).catch(t=>g.logger.error(`reach ${e.name}: what arrived`,t))},t)}catch(i){if(t.aborted)return;let n=i instanceof Error?i.message:String(i);if(i instanceof $.ChannelRefusal)return g.logger.warn(`reach ${e.name}: ${n}`),a(n);a(n)}await new Promise(e=>setTimeout(e,s.REACH.retryMs))}}async function C(e,t){let{channel:a}=e,n=await A(e.name);if("press"===t.kind){if(n?.chat!==t.chat)return;return W(e,n,t.data,t.under)}if(n?.chat!==t.chat)return n?void await a.say(t.chat,"This Thursday already answers someone else."):e.asking&&e.asking.chat!==t.chat?void await a.say(t.chat,"Someone else is already waiting to be let in here."):(e.asking={chat:t.chat,name:t.name},F(),void await a.say(t.chat,"Almost there. Open Thursday on your computer and press Allow, then write again."));z.last=e.name;let i=t.files.length?await (0,y.keepGivenFiles)(await Promise.all(t.files.map(e=>e.fetch()))):[],s=[t.words,...i].filter(Boolean).join("\n");if(!s){t.unreadable&&await a.say(t.chat,"I can read words, pictures and files here — not voice or video yet. Write it instead.");return}N(e,n,s,s)}async function I(){let e=Date.now();for(let t of z.live.values())t.line?.lastAt&&e-t.line.lastAt>s.REACH.idleMs&&await L(t)}async function L(e){let t=e.line;e.line=null,t&&await (0,m.endCall)(t.callId).catch(()=>{})}function N(e,t,a,n,i){let s=e.turn.then(()=>M(e,t,a,n,i));return e.turn=s.then(()=>{},()=>{}),s}async function M(e,t,a,n,i){let{channel:l}=e;l.typing(t.chat).catch(()=>{});let h=setInterval(()=>void l.typing(t.chat).catch(()=>{}),4e3);try{let r=o.LiveSettingsSchema.parse({}),h=e.line;(!h||Date.now()-h.lastAt>s.REACH.idleMs||!await (0,m.isCallOpen)(h.callId))&&(await L(e),e.line={...await (0,f.openTextCall)(r),messages:[],lastAt:0});let c=e.line,d=await (0,f.answerInWriting)({callId:c.callId,settings:r,standing:c.standing,messages:[...c.messages,{role:"user",content:a}],said:n});c.messages=d.messages,c.lastAt=Date.now();let u=(0,b.plainText)(d.text)||d.did.join("\n"),p=function(e){let t=[],a=e;for(;a.length>s.REACH.chars;){let e=a.slice(0,s.REACH.chars),n=Math.max(e.lastIndexOf("\n\n"),e.lastIndexOf("\n")),i=n>s.REACH.chars/2?n:s.REACH.chars;t.push(a.slice(0,i).trim()),a=a.slice(i).trim()}return a&&t.push(a),t}(u||"…");for(let[e,a]of p.entries())await l.say(t.chat,a,e===p.length-1?i:void 0);return await R(e,t,d.text),!0}catch(n){let a=(0,k.isPublicError)(n)?n.message:(0,r.modelErrorToString)(n);return g.logger.warn(`reach ${e.name}: ${a}`),await l.say(t.chat,a).catch(()=>{}),!1}finally{clearInterval(h)}}async function R(e,t,a){for(let i of(await (0,w.filesOnDisk)((0,p.pathsIn)(a),null)).slice(-s.REACH.files)){let a=await (0,w.insideWorkspace)(i),o=a?await (0,n.stat)(a).catch(()=>null):null;a&&o&&!(o.size>s.REACH.fileBytes)&&await e.channel.sendFile(t.chat,await (0,n.readFile)(a),i.split("/").pop()??"file","image"===(0,p.viewKindOf)(i)).catch(t=>g.logger.warn(`reach ${e.name}: could not send ${i}`,t))}}async function P(){for(let e of[...z.last?[z.last]:[],..._.REACH_CHANNELS.filter(e=>e!==z.last)]){let t=z.live.get(e),a=t?await A(e):null;if(t&&a)return{live:t,person:a}}return null}async function q(){if(!await P())return;let e=H(await (0,c.listInboxThreads)()),t=new Set(e.map(e=>e.key));for(let[e,a]of z.due)t.has(e)||(clearTimeout(a),z.due.delete(e));for(let e of z.told)t.has(e)||z.told.delete(e);for(let[e,a]of z.choices)t.has(`question:${a.question}`)||z.choices.delete(e);for(let t of e)z.told.has(t.key)||z.due.has(t.key)||z.due.set(t.key,setTimeout(()=>void j(t.key),s.REACH.notifyAfterMs))}let H=e=>(0,u.openWork)(e).filter(e=>"progress"!==e.kind);async function j(e){z.due.delete(e);let t=await P();if(!t||z.told.has(e))return;let a=await (0,c.listInboxThreads)(),n=H(a).find(t=>t.key===e);if(!n)return;let i=a.find(t=>t.room.questions.some(t=>`question:${t.id}`===e)),s=i?.room.questions.find(t=>`question:${t.id}`===e),o=(s?.options??[]).map((e,t)=>{let a=`${s?.id.slice(0,40)}:${t}`;return z.choices.set(a,{threadId:i?.id??"",bot:s?.bot??"",question:s?.id??"",answer:e}),{text:e,data:a}});z.told.add(e),await N(t.live,t.person,n.line,null,o)?await (0,h.acceptRoomRelays)(n.relayIds):z.told.delete(e)}async function W(e,t,a,n){let i=z.choices.get(a);if(!i)return void await e.channel.say(t.chat,"That question is no longer open here. Write your answer instead.");for(let[e,t]of z.choices)t.question===i.question&&z.choices.delete(e);try{await (0,l.answerThread)(i.threadId,i.answer,"user",i.bot),n&&await e.channel.settle(t.chat,n.id,`${n.text}
61
61
 
62
- → ${s.answer}`),e.line?.messages.push({role:"user",content:`[The user answered ${s.bot}'s question from their phone: ${s.answer}. It has reached ${s.bot}.]`})}catch(a){await e.channel.say(t.chat,(0,k.isPublicError)(a)?a.message:"That answer did not get through.")}}e.s(["startReach",0,A]),a()}catch(e){a(e)}},!1),822931,e=>{"use strict";var t=e.i(333925),a=e.i(951056),n=e.i(900533);let s={message:"says",question:"asks",report:"reports",interrupted:"was cut off"},i={question:0,stopped:1,done:2,progress:3};function o(e){let a=e.trim();if(a.length<=t.CALL_RELAY.chars)return a;let n=a.slice(0,t.CALL_RELAY.chars),s=Math.max(n.lastIndexOf("\n\n"),n.lastIndexOf(". "),n.lastIndexOf(".\n"),n.lastIndexOf("。")),i=(s>t.CALL_RELAY.chars/3?n.slice(0,s+1):n).trim();return`${i}
63
- [The message goes on; the rest is in its thread on screen.]`}e.s(["openWork",0,function(e){let t=[];for(let r of e){let{relays:e,questions:l}=r.room,h=(0,n.toDate)(r.updatedAt).getTime(),c=(e,t)=>`[${e} → Thursday, thread "${r.label}" (${r.id}), ${t}.]`,d=(e,t)=>({kind:"relay",name:r.label,line:t,done:!0,bot:e});for(let a of l){let n=a.options?.length?` Options: ${a.options.join(" / ")}.`:"";t.push({rank:i.question,key:`question:${a.id}`,kind:"question",line:`${c(a.bot,"question")}
64
- ${o(a.text)}${n}`,relayIds:e.filter(e=>e.messageId===a.id).map(e=>e.id),show:d(a.bot,`${a.bot} asks`)})}let u=e.filter(e=>!l.some(t=>t.id===e.messageId)),m="done"===r.status,f="waiting"===r.status&&(0,a.isAppStop)(r.ask)&&!r.ask?.auto;if(m||f){if(r.seen)continue;let e=f?"stopped":"done",a="stopped"===e?`It stopped before finishing. Where it got to: ${o(r.ask?.question??r.outcome??"")}`:`Done. Its answer: ${o(r.outcome??"")}`;t.push({rank:i[e],key:`${e}:${r.id}@${h}`,kind:"ending",line:`${c(r.bot,e)}
65
- ${a}`,relayIds:u.map(e=>e.id),show:d(r.bot,"stopped"===e?`${r.bot} stopped`:`${r.bot} finished`)});continue}for(let e of u)t.push({rank:i.progress,key:`progress:${e.id}`,kind:"progress",line:`${c(e.bot,e.kind)}
66
- ${o(e.text)}`,relayIds:[e.id],show:d(e.bot,`${e.bot} ${s[e.kind]}`)})}return t.sort((e,t)=>e.rank-t.rank)}])},181300,e=>e.a(async(t,a)=>{try{var n=e.i(734732),s=e.i(853205),i=e.i(333925),o=e.i(247839),r=e.i(113022),l=e.i(986507),h=e.i(864328),c=e.i(539470),d=e.i(79290),u=e.i(51083),m=e.i(656719),f=e.i(724185),p=e.i(426455);e.i(938281);var w=e.i(212389),y=e.i(520401),g=e.i(933395),k=e.i(293822),b=t([r,l,c,d,f,y]);async function $(){let e=await Promise.all(g.TEXT_CALL_PROVIDERS.map(async e=>await (0,f.readConfig)(e.apiKeyName)?e.apiKeyName:null));return(0,g.textCallRunsOn)(t=>e.includes(t))}async function v(e,t){if(t)return t;let a=await $();return a||(0,w.publicError)(O),{provider:a,model:e.backendModel}}async function _(e,t){let a=await v(e,t),[n,s]=await Promise.all([(0,y.insertCall)({provider:a.provider,model:i.TEXT_CALL.model,backendModel:a.model}),(0,c.loadCallStanding)()]);return{callId:n,standing:s}}async function S(e){var t;let a,{callId:s,settings:o,standing:r,messages:l,said:h,signal:c}=e,[d,m]=await Promise.all([E(s,o),(0,y.nextTurnSeq)(s)]);null!==h&&await (0,y.saveTurns)(s,[{id:crypto.randomUUID(),role:"user",text:h,seq:m}]);let f=await (0,n.generateText)({model:d.model,instructions:d.system,messages:[...T(r),...l],allowSystemInMessages:!0,tools:d.tools,providerOptions:d.providerOptions,stopWhen:(0,n.stepCountIs)(i.TEXT_CALL.maxSteps),abortSignal:c,onStepEnd:(t=s,a=null===h?m:m+1,async e=>{for(let n of e.content)if("tool-call"===n.type){let s=e.content.find(e=>"tool-result"===e.type&&e.toolCallId===n.toolCallId);await (0,y.saveTurns)(t,[{id:n.toolCallId,role:"tool",tool:n.toolName,text:n.toolName===u.TOOL_NAMES.web_search?function(e,t){let a=t??{},n=[(e??{}).query,a.action?.query].find(e=>"string"==typeof e&&!!e.trim()),s=Array.isArray(a.sources)?a.sources.flatMap(e=>e&&"object"==typeof e&&"url"in e&&"string"==typeof e.url?[{url:e.url,..."title"in e&&"string"==typeof e.title?{title:e.title}:{}}]:[]):[];return JSON.stringify({query:n??null,sources:s})}(n.input,s?.type==="tool-result"?s.output:null):JSON.stringify(n.input??{}),seq:a++}])}else"text"===n.type&&n.text.trim()?await (0,y.saveTurns)(t,[{id:crypto.randomUUID(),role:"assistant",text:n.text.trim(),seq:a++}]):"reasoning"===n.type&&n.text.trim()&&await (0,y.saveThought)(t,{id:crypto.randomUUID(),text:n.text.trim(),seq:a})})});return{text:f.text.trim(),did:f.steps.flatMap(e=>e.toolCalls.map(e=>(0,k.toolLine)(e.toolName,JSON.stringify(e.input??{}))??e.toolName)),messages:[...l,...f.response.messages]}}[r,l,c,d,f,y]=b.then?(await b)():b,s.z.object({callId:s.z.string().min(1),settings:o.LiveSettingsSchema,standing:s.z.string().nullish(),runsOn:h.textModelRefSchema.nullish(),messages:s.z.array(s.z.unknown()).min(1)});let T=e=>e?[{role:"system",content:e}]:[];async function E(e,t,a){let n=await v(t,a),s="openai"===n.provider||"chatgpt"===n.provider,[i,h,c,w,y]=await Promise.all([(0,l.getTextModel)(n),(0,d.loadThursdayPrompt)(t.backendPrompt,!0),(0,r.loadTools)({target:"thursday",callId:e,webSearch:t.webSearch,written:!0}),(0,f.readConfig)(m.EXA_API_KEY),(0,f.readConfig)(o.LIVE_PROVIDER.apiKeyName)]),g=i.searchTools&&Object.values(i.searchTools)[0],k={...c,...t.webSearch&&!w&&g?{[u.TOOL_NAMES.web_search]:g}:{}},b=s?y?await (0,p.acceptedReasoning)({apiKey:y,model:n.model,effort:t.reasoningEffort}):"none"===t.reasoningEffort?{effort:"none"}:{effort:t.reasoningEffort??void 0,summary:"auto"}:null;return{model:i.model,system:h,tools:k,providerOptions:{openai:{...b?.effort?{reasoningEffort:b.effort}:{},...b&&"summary"in b&&b.summary?{reasoningSummary:b.summary}:{}}}}}let O="Writing to Thursday needs a GPT subscription sign-in or an OpenAI key — Settings › API keys.";e.s(["answerInWriting",0,S,"openTextCall",0,_]),a()}catch(e){a(e)}},!1),317613,e=>{"use strict";var t=e.i(912714),a=e.i(750227),n=e.i(333925);e.i(375814);var s=e.i(871096);async function i(e){let i=await (0,s.openWorkspace)(),o=new Set(await (0,t.readdir)((0,a.join)(s.WORKSPACE,n.GIVEN_FILES.dir)).catch(()=>[])),r=[];for(let t of e){let e=t.name.normalize("NFC").replace(/[^\p{L}\p{N}._-]+/gu,"-").replace(/^[-.]+|-+$/g,"")||"file",a=e.lastIndexOf("."),s=a>0?e.slice(0,a):e,l=a>0?e.slice(a):"",h=e;for(let e=2;o.has(h);e++)h=`${s}-${e}${l}`;o.add(h);let c=`${n.GIVEN_FILES.dir}/${h}`;await i.writeFile(c,Buffer.from(await t.arrayBuffer())),r.push(c)}return r}e.s(["keepGivenFiles",0,i])},417043,e=>{"use strict";e.s(["ChannelRefusal",0,class extends Error{}])},903438,e=>{"use strict";e.s(["inPieces",0,function(e,t){let a=[],n=e;for(;n.length>t;){let e=n.slice(0,t),s=Math.max(e.lastIndexOf("\n\n"),e.lastIndexOf("\n")),i=s>t/2?s:t;a.push(n.slice(0,i).trim()),n=n.slice(i).trim()}return n&&a.push(n),a},"runSocket",0,function(e,t,a){return new Promise((n,s)=>{let i=new WebSocket(e),o=e=>{i.readyState===WebSocket.OPEN&&i.send(JSON.stringify(e))},r=()=>i.close(1e3);a.addEventListener("abort",r,{once:!0}),i.addEventListener("message",e=>{try{t.message(JSON.parse(String(e.data)),o)}catch{}}),i.addEventListener("error",()=>{i.readyState!==WebSocket.OPEN&&s(Error(`Could not connect to ${new URL(e).host}`))}),i.addEventListener("close",e=>{a.removeEventListener("abort",r),n({code:e.code,reason:e.reason})})})}])},854455,e=>{"use strict";var t=e.i(417043),a=e.i(903438);let n={4004:"Discord did not take the bot token.",4013:"Discord refused the intents this bot asked for.",4014:"Discord refused an intent this bot is not allowed — check the bot's page."};e.s(["createDiscord",0,function(e){async function s(a,n,s){let i=s instanceof FormData,o=await fetch(`https://discord.com/api/v10${n}`,{method:a,headers:{authorization:`Bot ${e}`,...i||!s?{}:{"content-type":"application/json"}},body:i?s:s?JSON.stringify(s):void 0});if(o.ok)return 204===o.status?null:await o.json();let r=await o.json().catch(()=>null),l=r?.message??`Discord answered ${o.status}`;throw 401===o.status?new t.ChannelRefusal(l):Error(l)}let i=e=>{let t=e.length<=5?1:5,a=[];for(let n=0;n<e.length&&a.length<5;n+=t)a.push({type:1,components:e.slice(n,n+t).map(e=>({type:2,style:2,label:e.text.slice(0,80),custom_id:e.data}))});return a};return{async listen(i,o){let r,l=null;try{let h=await (0,a.runSocket)("wss://gateway.discord.gg/?v=10&encoding=json",{message(t,a){let{op:n,d:o,s:h,t:c}=t;if(null!==h&&(l=h),10===n){let t=o.heartbeat_interval;r=setInterval(()=>a({op:1,d:l}),t),a({op:2,d:{token:e,intents:4096,properties:{os:process.platform,browser:"thursday",device:"thursday"}}})}else if(1===n)a({op:1,d:l});else if(0===n&&"READY"===c)i.ready(o.user.username);else if(0===n&&c){var d,u;let e=(d=c,u=o,"MESSAGE_CREATE"===d?u.guild_id||u.author.bot?null:{kind:"message",chat:u.channel_id,name:u.author.global_name||u.author.username,words:u.content.trim(),files:(u.attachments??[]).map(e=>({name:e.filename,fetch:async()=>{let t=await fetch(e.url);if(!t.ok)throw Error(`Discord answered ${t.status} for the file`);return new File([await t.arrayBuffer()],e.filename,{type:e.content_type??""})}})),unreadable:!1}:"INTERACTION_CREATE"===d?3!==u.type||u.guild_id?null:(s("POST",`/interactions/${u.id}/${u.token}/callback`,{type:6}).catch(()=>{}),{kind:"press",chat:u.channel_id,data:u.data?.custom_id??"",under:u.message?{id:u.message.id,text:u.message.content}:null}):null);e&&i.incoming(e)}}},o),c=n[h.code];if(c)throw new t.ChannelRefusal(c);if(!o.aborted)throw Error(`Discord closed the connection (${h.code})`)}finally{clearInterval(r)}},async say(e,t,n){let o=(0,a.inPieces)(t,1900);for(let[t,a]of o.entries())await s("POST",`/channels/${e}/messages`,{content:a,...n?.length&&t===o.length-1?{components:i(n)}:{}})},async typing(e){await s("POST",`/channels/${e}/typing`).catch(()=>{})},async settle(e,t,a){await s("PATCH",`/channels/${e}/messages/${t}`,{content:a.slice(0,1900),components:[]}).catch(()=>{})},async sendFile(e,t,a){let n=new FormData;n.set("payload_json",JSON.stringify({attachments:[{id:0,filename:a}]})),n.set("files[0]",new Blob([t]),a),await s("POST",`/channels/${e}/messages`,n)}}}])},426455,e=>{"use strict";var t=e.i(853205),a=e.i(333925),n=e.i(938281);e.i(556325),t.z.object({session:t.z.object({id:t.z.string().min(1)}),transport:t.z.object({type:t.z.literal("webrtc"),sdp:t.z.string().min(1)})});let s=new Map;async function i(e){let{apiKey:t,model:i,effort:o}=e,r=`${i} ${o??"auto"}`,l=s.get(r);if(void 0!==l)return l;let h="none"===o?{effort:o}:{...o?{effort:o}:{},summary:"auto"};for(;;){let e=await fetch("https://api.openai.com/v1/responses/input_tokens",{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(a.LIVE_CALL.reasoningCheckMs),body:JSON.stringify({model:i,input:".",reasoning:h})}).catch(()=>null);if(!e)return h;let o=Object.keys(h).length?h:null;if(e.ok)return s.set(r,o),o;let l=await e.json().catch(()=>null),c=l?.error?.param?.replace(/^reasoning\./,"");if("effort"!==c&&"summary"!==c||!(c in h))return h;if(n.logger.warn(`${i} takes no reasoning ${c}; calls omit it`),delete h[c],!Object.keys(h).length)return s.set(r,null),null}}e.s(["acceptedReasoning",0,i])}];
62
+ → ${i.answer}`),e.line?.messages.push({role:"user",content:`[The user answered ${i.bot}'s question from their phone: ${i.answer}. It has reached ${i.bot}.]`})}catch(a){await e.channel.say(t.chat,(0,k.isPublicError)(a)?a.message:"That answer did not get through.")}}e.s(["startReach",0,O]),a()}catch(e){a(e)}},!1),822931,e=>{"use strict";var t=e.i(333925),a=e.i(951056),n=e.i(900533);let i={message:"says",question:"asks",report:"reports",interrupted:"was cut off"},s={question:0,stopped:1,done:2,progress:3};function o(e){let a=e.trim();if(a.length<=t.CALL_RELAY.chars)return a;let n=a.slice(0,t.CALL_RELAY.chars),i=Math.max(n.lastIndexOf("\n\n"),n.lastIndexOf(". "),n.lastIndexOf(".\n"),n.lastIndexOf("。")),s=(i>t.CALL_RELAY.chars/3?n.slice(0,i+1):n).trim();return`${s}
63
+ [The message goes on; the rest is in its thread on screen.]`}e.s(["openWork",0,function(e){let t=[];for(let r of e){let{relays:e,questions:l}=r.room,h=(0,n.toDate)(r.updatedAt).getTime(),c=(e,t)=>`[${e} → Thursday, thread "${r.label}" (${r.id}), ${t}.]`,d=(e,t)=>({kind:"relay",name:r.label,line:t,done:!0,bot:e});for(let a of l){let n=a.options?.length?` Options: ${a.options.join(" / ")}.`:"";t.push({rank:s.question,key:`question:${a.id}`,kind:"question",line:`${c(a.bot,"question")}
64
+ ${o(a.text)}${n}`,relayIds:e.filter(e=>e.messageId===a.id).map(e=>e.id),show:d(a.bot,`${a.bot} asks`)})}let u=e.filter(e=>!l.some(t=>t.id===e.messageId)),m="done"===r.status,f="waiting"===r.status&&(0,a.isAppStop)(r.ask)&&!r.ask?.auto;if(m||f){if(r.seen)continue;let e=f?"stopped":"done",a="stopped"===e?`It stopped before finishing. Where it got to: ${o(r.ask?.question??r.outcome??"")}`:`Done. Its answer: ${o(r.outcome??"")}`;t.push({rank:s[e],key:`${e}:${r.id}@${h}`,kind:"ending",line:`${c(r.bot,e)}
65
+ ${a}`,relayIds:u.map(e=>e.id),show:d(r.bot,"stopped"===e?`${r.bot} stopped`:`${r.bot} finished`)});continue}for(let e of u)t.push({rank:s.progress,key:`progress:${e.id}`,kind:"progress",line:`${c(e.bot,e.kind)}
66
+ ${o(e.text)}`,relayIds:[e.id],show:d(e.bot,`${e.bot} ${i[e.kind]}`)})}return t.sort((e,t)=>e.rank-t.rank)}])},181300,e=>e.a(async(t,a)=>{try{var n=e.i(734732),i=e.i(853205),s=e.i(333925),o=e.i(247839),r=e.i(113022),l=e.i(986507),h=e.i(864328),c=e.i(539470),d=e.i(79290),u=e.i(51083),m=e.i(656719),f=e.i(724185),p=e.i(426455);e.i(938281);var w=e.i(212389),y=e.i(520401),g=e.i(933395),k=e.i(293822),b=t([r,l,c,d,f,y]);async function $(){let e=await Promise.all(g.TEXT_CALL_PROVIDERS.map(async e=>await (0,f.readConfig)(e.apiKeyName)?e.apiKeyName:null));return(0,g.textCallRunsOn)(t=>e.includes(t))}async function v(e,t){if(t)return t;let a=await $();return a||(0,w.publicError)(A),{provider:a,model:e.backendModel}}async function _(e,t){let a=await v(e,t),[n,i]=await Promise.all([(0,y.insertCall)({provider:a.provider,model:s.TEXT_CALL.model,backendModel:a.model}),(0,c.loadCallStanding)()]);return{callId:n,standing:i}}async function S(e){var t;let a,{callId:i,settings:o,standing:r,messages:l,said:h,signal:c}=e,[d,m]=await Promise.all([E(i,o),(0,y.nextTurnSeq)(i)]);null!==h&&await (0,y.saveTurns)(i,[{id:crypto.randomUUID(),role:"user",text:h,seq:m}]);let f=await (0,n.generateText)({model:d.model,instructions:d.system,messages:[...T(r),...l],allowSystemInMessages:!0,tools:d.tools,providerOptions:d.providerOptions,stopWhen:(0,n.stepCountIs)(s.TEXT_CALL.maxSteps),abortSignal:c,onStepEnd:(t=i,a=null===h?m:m+1,async e=>{for(let n of e.content)if("tool-call"===n.type){let i=e.content.find(e=>"tool-result"===e.type&&e.toolCallId===n.toolCallId);await (0,y.saveTurns)(t,[{id:n.toolCallId,role:"tool",tool:n.toolName,text:n.toolName===u.TOOL_NAMES.web_search?function(e,t){let a=t??{},n=[(e??{}).query,a.action?.query].find(e=>"string"==typeof e&&!!e.trim()),i=Array.isArray(a.sources)?a.sources.flatMap(e=>e&&"object"==typeof e&&"url"in e&&"string"==typeof e.url?[{url:e.url,..."title"in e&&"string"==typeof e.title?{title:e.title}:{}}]:[]):[];return JSON.stringify({query:n??null,sources:i})}(n.input,i?.type==="tool-result"?i.output:null):JSON.stringify(n.input??{}),seq:a++}])}else"text"===n.type&&n.text.trim()?await (0,y.saveTurns)(t,[{id:crypto.randomUUID(),role:"assistant",text:n.text.trim(),seq:a++}]):"reasoning"===n.type&&n.text.trim()&&await (0,y.saveThought)(t,{id:crypto.randomUUID(),text:n.text.trim(),seq:a})})});return{text:f.text.trim(),did:f.steps.flatMap(e=>e.toolCalls.map(e=>(0,k.toolLine)(e.toolName,JSON.stringify(e.input??{}))??e.toolName)),messages:[...l,...f.response.messages]}}[r,l,c,d,f,y]=b.then?(await b)():b,i.z.object({callId:i.z.string().min(1),settings:o.LiveSettingsSchema,standing:i.z.string().nullish(),runsOn:h.textModelRefSchema.nullish(),messages:i.z.array(i.z.unknown()).min(1)});let T=e=>e?[{role:"system",content:e}]:[];async function E(e,t,a){let n=await v(t,a),i="openai"===n.provider||"chatgpt"===n.provider,[s,h,c,w,y]=await Promise.all([(0,l.getTextModel)(n),(0,d.loadThursdayPrompt)(t.backendPrompt,!0),(0,r.loadTools)({target:"thursday",callId:e,webSearch:t.webSearch,written:!0}),(0,f.readConfig)(m.EXA_API_KEY),(0,f.readConfig)(o.LIVE_PROVIDER.apiKeyName)]),g=s.searchTools&&Object.values(s.searchTools)[0],k={...c,...t.webSearch&&!w&&g?{[u.TOOL_NAMES.web_search]:g}:{}},b=i?y?await (0,p.acceptedReasoning)({apiKey:y,model:n.model,effort:t.reasoningEffort}):"none"===t.reasoningEffort?{effort:"none"}:{effort:t.reasoningEffort??void 0,summary:"auto"}:null;return{model:s.model,system:h,tools:k,providerOptions:{openai:{...b?.effort?{reasoningEffort:b.effort}:{},...b&&"summary"in b&&b.summary?{reasoningSummary:b.summary}:{}}}}}let A="Writing to Thursday needs a GPT subscription sign-in or an OpenAI key — Settings › API keys.";e.s(["answerInWriting",0,S,"openTextCall",0,_]),a()}catch(e){a(e)}},!1),317613,e=>e.a(async(t,a)=>{try{var n=e.i(912714),i=e.i(750227),s=e.i(333925),o=e.i(5509);e.i(375814);var r=e.i(871096),l=t([o]);async function h(e){let t=await (0,r.openWorkspace)(),a=new Set(await (0,n.readdir)((0,i.join)(r.WORKSPACE,s.GIVEN_FILES.dir)).catch(()=>[])),o=[];for(let n of e){let e=n.name.normalize("NFC").replace(/[^\p{L}\p{N}._-]+/gu,"-").replace(/^[-.]+|-+$/g,"")||"file",i=e.lastIndexOf("."),r=i>0?e.slice(0,i):e,l=i>0?e.slice(i):"",h=e;for(let e=2;a.has(h);e++)h=`${r}-${e}${l}`;a.add(h);let c=`${s.GIVEN_FILES.dir}/${h}`;await t.writeFile(c,Buffer.from(await n.arrayBuffer())),o.push(c)}return o}[o]=l.then?(await l)():l,e.s(["keepGivenFiles",0,h]),a()}catch(e){a(e)}},!1),417043,e=>{"use strict";e.s(["ChannelRefusal",0,class extends Error{}])},903438,e=>{"use strict";e.s(["inPieces",0,function(e,t){let a=[],n=e;for(;n.length>t;){let e=n.slice(0,t),i=Math.max(e.lastIndexOf("\n\n"),e.lastIndexOf("\n")),s=i>t/2?i:t;a.push(n.slice(0,s).trim()),n=n.slice(s).trim()}return n&&a.push(n),a},"runSocket",0,function(e,t,a){return new Promise((n,i)=>{let s=new WebSocket(e),o=e=>{s.readyState===WebSocket.OPEN&&s.send(JSON.stringify(e))},r=()=>s.close(1e3);a.addEventListener("abort",r,{once:!0}),s.addEventListener("message",e=>{try{t.message(JSON.parse(String(e.data)),o)}catch{}}),s.addEventListener("error",()=>{s.readyState!==WebSocket.OPEN&&i(Error(`Could not connect to ${new URL(e).host}`))}),s.addEventListener("close",e=>{a.removeEventListener("abort",r),n({code:e.code,reason:e.reason})})})}])},854455,e=>{"use strict";var t=e.i(417043),a=e.i(903438);let n={4004:"Discord did not take the bot token.",4013:"Discord refused the intents this bot asked for.",4014:"Discord refused an intent this bot is not allowed — check the bot's page."};e.s(["createDiscord",0,function(e){async function i(a,n,i){let s=i instanceof FormData,o=await fetch(`https://discord.com/api/v10${n}`,{method:a,headers:{authorization:`Bot ${e}`,...s||!i?{}:{"content-type":"application/json"}},body:s?i:i?JSON.stringify(i):void 0});if(o.ok)return 204===o.status?null:await o.json();let r=await o.json().catch(()=>null),l=r?.message??`Discord answered ${o.status}`;throw 401===o.status?new t.ChannelRefusal(l):Error(l)}let s=e=>{let t=e.length<=5?1:5,a=[];for(let n=0;n<e.length&&a.length<5;n+=t)a.push({type:1,components:e.slice(n,n+t).map(e=>({type:2,style:2,label:e.text.slice(0,80),custom_id:e.data}))});return a};return{async listen(s,o){let r,l=null;try{let h=await (0,a.runSocket)("wss://gateway.discord.gg/?v=10&encoding=json",{message(t,a){let{op:n,d:o,s:h,t:c}=t;if(null!==h&&(l=h),10===n){let t=o.heartbeat_interval;r=setInterval(()=>a({op:1,d:l}),t),a({op:2,d:{token:e,intents:4096,properties:{os:process.platform,browser:"thursday",device:"thursday"}}})}else if(1===n)a({op:1,d:l});else if(0===n&&"READY"===c){let e;s.ready(o.user.username,(e=o.application?.id)?`https://discord.com/oauth2/authorize?client_id=${e}&scope=bot&permissions=0`:null)}else if(0===n&&c){var d,u;let e=(d=c,u=o,"MESSAGE_CREATE"===d?u.guild_id||u.author.bot?null:{kind:"message",chat:u.channel_id,name:u.author.global_name||u.author.username,words:u.content.trim(),files:(u.attachments??[]).map(e=>({name:e.filename,fetch:async()=>{let t=await fetch(e.url);if(!t.ok)throw Error(`Discord answered ${t.status} for the file`);return new File([await t.arrayBuffer()],e.filename,{type:e.content_type??""})}})),unreadable:!1}:"INTERACTION_CREATE"===d?3!==u.type||u.guild_id?null:(i("POST",`/interactions/${u.id}/${u.token}/callback`,{type:6}).catch(()=>{}),{kind:"press",chat:u.channel_id,data:u.data?.custom_id??"",under:u.message?{id:u.message.id,text:u.message.content}:null}):null);e&&s.incoming(e)}}},o),c=n[h.code];if(c)throw new t.ChannelRefusal(c);if(!o.aborted)throw Error(`Discord closed the connection (${h.code})`)}finally{clearInterval(r)}},async say(e,t,n){let o=(0,a.inPieces)(t,1900);for(let[t,a]of o.entries())await i("POST",`/channels/${e}/messages`,{content:a,...n?.length&&t===o.length-1?{components:s(n)}:{}})},async typing(e){await i("POST",`/channels/${e}/typing`).catch(()=>{})},async settle(e,t,a){await i("PATCH",`/channels/${e}/messages/${t}`,{content:a.slice(0,1900),components:[]}).catch(()=>{})},async sendFile(e,t,a){let n=new FormData;n.set("payload_json",JSON.stringify({attachments:[{id:0,filename:a}]})),n.set("files[0]",new Blob([t]),a),await i("POST",`/channels/${e}/messages`,n)}}}])},426455,e=>{"use strict";var t=e.i(853205),a=e.i(333925),n=e.i(938281);e.i(556325),t.z.object({session:t.z.object({id:t.z.string().min(1)}),transport:t.z.object({type:t.z.literal("webrtc"),sdp:t.z.string().min(1)})});let i=new Map;async function s(e){let{apiKey:t,model:s,effort:o}=e,r=`${s} ${o??"auto"}`,l=i.get(r);if(void 0!==l)return l;let h="none"===o?{effort:o}:{...o?{effort:o}:{},summary:"auto"};for(;;){let e=await fetch("https://api.openai.com/v1/responses/input_tokens",{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(a.LIVE_CALL.reasoningCheckMs),body:JSON.stringify({model:s,input:".",reasoning:h})}).catch(()=>null);if(!e)return h;let o=Object.keys(h).length?h:null;if(e.ok)return i.set(r,o),o;let l=await e.json().catch(()=>null),c=l?.error?.param?.replace(/^reasoning\./,"");if("effort"!==c&&"summary"!==c||!(c in h))return h;if(n.logger.warn(`${s} takes no reasoning ${c}; calls omit it`),delete h[c],!Object.keys(h).length)return i.set(r,null),null}}e.s(["acceptedReasoning",0,s])}];
67
67
 
68
68
  //# sourceMappingURL=_0x-ej3f._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[953002,e=>e.a(async(t,a)=>{try{var r=e.i(105249),n=e.i(440998),i=e.i(91264),s=t([n]);[n]=s.then?(await s)():s;let o=r.default.array(r.default.string().min(1)),l=(0,i.serverRoute)(async e=>{let t,a=new URL(e.url).searchParams.get("paths")??"[]";try{t=JSON.parse(a)}catch{t=null}return(0,n.statFiles)(o.parse(t))});e.s(["GET",0,l]),a()}catch(e){a(e)}},!1),933096,e=>{"use strict";var t=e.i(747909),a=e.i(174017),r=e.i(996250),n=e.i(759756),i=e.i(561916),s=e.i(174677),o=e.i(869741),l=e.i(316795),u=e.i(487718),d=e.i(995169),c=e.i(47587),p=e.i(666012),h=e.i(570101),R=e.i(626937),v=e.i(10372),m=e.i(193695);e.i(52474);var f=e.i(600220);let g=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/workspace/files/route",pathname:"/api/workspace/files",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/workspace/files/route.ts",nextConfigOutput:"standalone",userland:()=>e.r(953002),...{}}),{workAsyncStorage:w,workUnitAsyncStorage:E,serverHooks:C}=g;async function x(e,t,r){r.requestMeta&&(0,n.setRequestMeta)(e,r.requestMeta),g.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let w="/api/workspace/files/route";w=w.replace(/\/index$/,"")||"/";let E=await g.prepare(e,t,{srcPage:w,multiZoneDraftMode:!1});if(!E)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:C,deploymentId:x,params:_,nextConfig:y,parsedUrl:A,isDraftMode:T,prerenderManifest:P,routerServerContext:S,isOnDemandRevalidate:N,revalidateOnlyGenerated:b,resolvedPathname:O,clientReferenceManifest:k,serverActionsManifest:q}=E,H=(0,o.normalizeAppPath)(w),I=!!(P.dynamicRoutes[H]||P.routes[O]),M=async()=>((null==S?void 0:S.render404)?await S.render404(e,t,A,!1):t.end("This page could not be found"),null);if(I&&!T){let e=!!P.routes[O],t=P.dynamicRoutes[H];if(t&&!1===t.fallback&&!e){if(y.adapterPath)return await M();throw new m.NoFallbackError}}let U=null;!I||g.isDev||T||(U="/index"===(U=O)?"/":U);let D=!0===g.isDev||!I,j=I&&!D;q&&k&&(0,s.setManifestsSingleton)({page:w,clientReferenceManifest:k,serverActionsManifest:q});let F=e.method||"GET",K=(0,i.getTracer)(),L=K.getActiveScopeSpan(),$=!!(null==S?void 0:S.isWrappedByNextServer),B=!!(0,n.getRequestMeta)(e,"minimalMode"),G=(0,n.getRequestMeta)(e,"incrementalCache")||await g.getIncrementalCache(e,y,P,B);null==G||G.resetRequestCache(),globalThis.__incrementalCache=G;let V={params:_,previewProps:P.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:D,incrementalCache:G,hmrRefreshHash:(0,n.getRequestMeta)(e,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,r,n)=>g.onRequestError(e,t,r,n,S)},sharedContext:{buildId:C,deploymentId:x}},X=new l.NodeNextRequest(e),W=new l.NodeNextResponse(t),z=u.NextRequestAdapter.fromNodeNextRequest(X,(0,u.signalFromNodeResponse)(t)),J=async({previousCacheEntry:a})=>{try{if(!B&&N&&b&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await g.handle(z,V);e.fetchMetrics=V.renderOpts.fetchMetrics;let i=V.renderOpts.pendingWaitUntil;i&&r.waitUntil&&(r.waitUntil(i),i=void 0);let s=V.renderOpts.collectedTags;if(!I)return await (0,p.sendResponse)(X,W,n,i),null;{let e=await n.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(n.headers);s&&(t[v.NEXT_CACHE_TAGS_HEADER]=s),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==V.renderOpts.collectedRevalidate&&!(V.renderOpts.collectedRevalidate>=v.INFINITE_CACHE)&&V.renderOpts.collectedRevalidate,r=void 0===V.renderOpts.collectedExpire||V.renderOpts.collectedExpire>=v.INFINITE_CACHE?!1!==a&&a>0?y.expireTime:void 0:V.renderOpts.collectedExpire;return{value:{kind:f.CachedRouteKind.APP_ROUTE,status:n.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:r}}}}catch(t){throw(null==a?void 0:a.isStale)&&await g.onRequestError(e,t,{routerKind:"App Router",routePath:w,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:j,isOnDemandRevalidate:N})},!1,S),t}},Z=async(n,s)=>{try{var o,l;let n=await g.handleResponse({req:e,nextConfig:y,cacheKey:U,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:P,isRoutePPREnabled:!1,isOnDemandRevalidate:N,revalidateOnlyGenerated:b,responseGenerator:J,waitUntil:r.waitUntil,isMinimalMode:B});if(!I)return;if((null==n||null==(o=n.value)?void 0:o.kind)!==f.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==n||null==(l=n.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});B||t.setHeader("x-nextjs-cache",N?"REVALIDATED":n.isMiss?"MISS":n.isStale?"STALE":"HIT"),T&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let i=(0,h.fromNodeOutgoingHttpHeaders)(n.value.headers);B&&I||i.delete(v.NEXT_CACHE_TAGS_HEADER),!n.cacheControl||t.getHeader("Cache-Control")||i.get("Cache-Control")||i.set("Cache-Control",(0,R.getCacheControlHeader)(n.cacheControl)),await (0,p.sendResponse)(X,W,new Response(n.value.body,{headers:i,status:n.value.status||200}));return}catch(t){if(t instanceof m.NoFallbackError||await g.onRequestError(e,t,{routerKind:"App Router",routePath:H,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:j,isOnDemandRevalidate:N})},!1,S),I)throw t;await (0,p.sendResponse)(X,W,new Response(null,{status:500}));return}finally{(()=>{if(!n)return;let e=t.statusCode;n.setAttributes({"http.status_code":e,"next.rsc":!1}),e&&e>=500&&(n.setStatus({code:i.SpanStatusCode.ERROR}),n.setAttribute("error.type",e.toString()));let a=K.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==d.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let r=a.get("next.route")||H,o=`${F} ${r}`;n.setAttributes({"next.route":r,"http.route":r,"next.span_name":o}),n.updateName(o),s&&s!==n&&(s.setAttribute("http.route",r),s.updateName(o))})()}};if($&&L)await Z(L,void 0);else{let t=K.getActiveScopeSpan();await K.withPropagatedContext(e.headers,()=>K.trace(d.BaseServerSpan.handleRequest,{spanName:`${F} ${w}`,kind:i.SpanKind.SERVER,attributes:{"http.method":F,"http.target":e.url}},e=>Z(e,t)),void 0,!$)}}e.s(["handler",0,x,"patchFetch",0,function(){return(0,r.patchFetch)({workAsyncStorage:w,workUnitAsyncStorage:E})},"routeModule",0,g,"serverHooks",0,C,"workAsyncStorage",0,w,"workUnitAsyncStorage",0,E])},329280,e=>{e.v(t=>Promise.all(["server/chunks/[externals]_node_readline_1u65a-m._.js","server/chunks/node_modules_consola_dist_chunks_prompt_mjs_02axwqv._.js"].map(t=>e.l(t))).then(()=>t(781937)))}];
2
+
3
+ //# sourceMappingURL=_0z3nz21._.js.map