thursday-agent 0.8.0 → 0.9.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 (264) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/prerender-manifest.json +3 -3
  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.nft.json +1 -1
  11. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/.next/server/app/_not-found.html +1 -1
  13. package/.next/server/app/_not-found.rsc +2 -2
  14. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  16. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  17. package/.next/server/app/api/artifact/route.js.nft.json +1 -1
  18. package/.next/server/app/api/bot/keep-working/route.js.nft.json +1 -1
  19. package/.next/server/app/api/bot/memory/files/route.js.nft.json +1 -1
  20. package/.next/server/app/api/bot/memory/route.js.nft.json +1 -1
  21. package/.next/server/app/api/bot/route.js.nft.json +1 -1
  22. package/.next/server/app/api/bot/thread/[id]/route.js.nft.json +1 -1
  23. package/.next/server/app/api/bot/thread/route.js.nft.json +1 -1
  24. package/.next/server/app/api/config/route.js.nft.json +1 -1
  25. package/.next/server/app/api/events/route.js.nft.json +1 -1
  26. package/.next/server/app/api/favicon/[host]/route.js.nft.json +1 -1
  27. package/.next/server/app/api/file/[...path]/route.js.nft.json +1 -1
  28. package/.next/server/app/api/llm-model/catalog/route.js.nft.json +1 -1
  29. package/.next/server/app/api/llm-model/credits/route.js.nft.json +1 -1
  30. package/.next/server/app/api/llm-model/route.js.nft.json +1 -1
  31. package/.next/server/app/api/llm-model/subscription/route.js.nft.json +1 -1
  32. package/.next/server/app/api/mcp/[name]/route.js.nft.json +1 -1
  33. package/.next/server/app/api/mcp/oauth/callback/route.js.nft.json +1 -1
  34. package/.next/server/app/api/mcp/route.js.nft.json +1 -1
  35. package/.next/server/app/api/mcp/tools/route.js.nft.json +1 -1
  36. package/.next/server/app/api/memory/edit/route.js +1 -1
  37. package/.next/server/app/api/memory/edit/route.js.nft.json +1 -1
  38. package/.next/server/app/api/memory/route.js.nft.json +1 -1
  39. package/.next/server/app/api/probe/route.js.nft.json +1 -1
  40. package/.next/server/app/api/reach/route.js +11 -11
  41. package/.next/server/app/api/reach/route.js.nft.json +1 -1
  42. package/.next/server/app/api/routine/route.js +6 -6
  43. package/.next/server/app/api/routine/route.js.nft.json +1 -1
  44. package/.next/server/app/api/signins/route.js.nft.json +1 -1
  45. package/.next/server/app/api/skills/[source]/[name]/route.js.nft.json +1 -1
  46. package/.next/server/app/api/skills/route.js.nft.json +1 -1
  47. package/.next/server/app/api/thursday/call/route.js.nft.json +1 -1
  48. package/.next/server/app/api/thursday/skills/route.js.nft.json +1 -1
  49. package/.next/server/app/api/thursday/text/route.js +11 -11
  50. package/.next/server/app/api/thursday/text/route.js.nft.json +1 -1
  51. package/.next/server/app/api/thursday/tool-call/route.js +6 -6
  52. package/.next/server/app/api/thursday/tool-call/route.js.nft.json +1 -1
  53. package/.next/server/app/api/workspace/files/route.js.nft.json +1 -1
  54. package/.next/server/app/api/workspace/route.js.nft.json +1 -1
  55. package/.next/server/app/artifact/[...path]/page/server-reference-manifest.json +1 -1
  56. package/.next/server/app/artifact/[...path]/page.js.nft.json +1 -1
  57. package/.next/server/app/artifact/[...path]/page_client-reference-manifest.js +1 -1
  58. package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  59. package/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  60. package/.next/server/app/page/server-reference-manifest.json +56 -56
  61. package/.next/server/app/page.js +3 -3
  62. package/.next/server/app/page.js.nft.json +1 -1
  63. package/.next/server/app/page_client-reference-manifest.js +1 -1
  64. package/.next/server/chunks/[root-of-the-server]__012s2o8._.js +1 -1
  65. package/.next/server/chunks/[root-of-the-server]__04r4h-2._.js +1 -1
  66. package/.next/server/chunks/[root-of-the-server]__0mrk2it._.js +1 -1
  67. package/.next/server/chunks/[root-of-the-server]__0nmhgeo._.js +3 -0
  68. package/.next/server/chunks/[root-of-the-server]__1fy2g82._.js +3 -0
  69. package/.next/server/chunks/[root-of-the-server]__1ndi14y._.js +1 -1
  70. package/.next/server/chunks/[root-of-the-server]__1nmflqk._.js +3 -0
  71. package/.next/server/chunks/[root-of-the-server]__1v7-zke._.js +1 -1
  72. package/.next/server/chunks/[root-of-the-server]__1wnzmx9._.js +3 -0
  73. package/.next/server/chunks/[root-of-the-server]__1xv-5cq._.js +1 -1
  74. package/.next/server/chunks/[root-of-the-server]__1ygplx1._.js +1 -1
  75. package/.next/server/chunks/_05v8k21._.js +1 -1
  76. package/.next/server/chunks/_0awtznl._.js +4 -4
  77. package/.next/server/chunks/_0k6qjcf._.js +1 -1
  78. package/.next/server/chunks/_0na2fj1._.js +5 -5
  79. package/.next/server/chunks/_0x-ej3f._.js +21 -21
  80. package/.next/server/chunks/_1dc_d1q._.js +22 -20
  81. package/.next/server/chunks/_1jc5g4p._.js +2 -2
  82. package/.next/server/chunks/_1jn-aep._.js +50 -48
  83. package/.next/server/chunks/{_1u8ygbz._.js → _1m88lkh._.js} +7 -7
  84. package/.next/server/chunks/_1uuucy-._.js +4 -4
  85. package/.next/server/chunks/_1v9r2ke._.js +1 -1
  86. package/.next/server/chunks/ssr/{[root-of-the-server]__1h4bnrf._.js → [root-of-the-server]__0oo-wlv._.js} +2 -2
  87. package/.next/server/chunks/ssr/{[root-of-the-server]__1kyi568._.js → [root-of-the-server]__0tvavy9._.js} +1 -1
  88. package/.next/server/chunks/ssr/[root-of-the-server]__0tzekbl._.js +1 -1
  89. package/.next/server/chunks/ssr/[root-of-the-server]__0zuns7e._.js +3 -0
  90. package/.next/server/chunks/ssr/[root-of-the-server]__1se25x0._.js +1 -1
  91. package/.next/server/chunks/ssr/{_1i3ddn7._.js → _05pl_u8._.js} +1 -1
  92. package/.next/server/chunks/ssr/_070nv1_._.js +3 -0
  93. package/.next/server/chunks/ssr/_097-ljd._.js +1 -1
  94. package/.next/server/chunks/ssr/_0dshsh4._.js +3 -0
  95. package/.next/server/chunks/ssr/_0fqhhwi._.js +1 -1
  96. package/.next/server/chunks/ssr/{_0z8jpch._.js → _0ital-2._.js} +2 -2
  97. package/.next/server/chunks/ssr/{_19g570d._.js → _0kjj5ts._.js} +3 -3
  98. package/.next/server/chunks/ssr/{_1nod5hh._.js → _0l_mcfz._.js} +2 -2
  99. package/.next/server/chunks/ssr/_0ld9_qq._.js +1 -1
  100. package/.next/server/chunks/ssr/_0ltz2q5._.js +3 -0
  101. package/.next/server/chunks/ssr/_0scf7xy._.js +3 -0
  102. package/.next/server/chunks/ssr/_0u5xv6g._.js +3 -0
  103. package/.next/server/chunks/ssr/{_0ewory0._.js → _0urj3mc._.js} +2 -2
  104. package/.next/server/chunks/ssr/{_0pm-2p-._.js → _1-zyvdb._.js} +2 -2
  105. package/.next/server/chunks/ssr/{_1_rqu8x._.js → _12mijol._.js} +7 -7
  106. package/.next/server/chunks/ssr/_15zqt-t._.js +1 -1
  107. package/.next/server/chunks/ssr/_184327j._.js +1 -1
  108. package/.next/server/chunks/ssr/{_1y-ea28._.js → _1a-nuxx._.js} +2 -2
  109. package/.next/server/chunks/ssr/_1alxym6._.js +3 -0
  110. package/.next/server/chunks/ssr/{_0hzz82u._.js → _1d423aj._.js} +25 -23
  111. package/.next/server/chunks/ssr/{_1u1mxu9._.js → _1flbs77._.js} +2 -2
  112. package/.next/server/chunks/ssr/_1mqn9mc._.js +1 -1
  113. package/.next/server/chunks/ssr/_1neoj22._.js +1 -1
  114. package/.next/server/chunks/ssr/{_1oijqjw._.js → _1tmu8z-._.js} +2 -2
  115. package/.next/server/chunks/ssr/{_10y6r1n._.js → _1uy0xom._.js} +3 -3
  116. package/.next/server/chunks/ssr/_1x-kojb._.js +20 -0
  117. package/.next/server/chunks/ssr/_1xoch6f._.js +1 -1
  118. package/.next/server/chunks/ssr/_1z74dmq._.js +164 -0
  119. package/.next/server/chunks/ssr/features_bot_1nr94ks._.js +3 -0
  120. package/.next/server/chunks/ssr/features_bot_1s_-2vj._.js +1 -1
  121. package/.next/server/chunks/ssr/features_connectors_components_mcp-setting_tsx_0jmbgvp._.js +1 -1
  122. package/.next/server/chunks/ssr/features_memory_components_memory-setting_tsx_0oa43sw._.js +1 -1
  123. package/.next/server/chunks/ssr/features_routine_components_routine-setting_tsx_055fknz._.js +1 -1
  124. package/.next/server/chunks/ssr/{node_modules_111sh9o._.js → node_modules_03d0rfz._.js} +1 -1
  125. package/.next/server/chunks/ssr/{node_modules_0lg75qx._.js → node_modules_04_sbbc._.js} +1 -1
  126. package/.next/server/chunks/ssr/{node_modules_10gbm2y._.js → node_modules_05ybmta._.js} +1 -1
  127. package/.next/server/chunks/ssr/{node_modules_1v9tc1c._.js → node_modules_068ws5v._.js} +1 -1
  128. package/.next/server/chunks/ssr/{node_modules_1_8mv4v._.js → node_modules_06bb4q8._.js} +1 -1
  129. package/.next/server/chunks/ssr/{node_modules_01f8_se._.js → node_modules_07rs_p2._.js} +1 -1
  130. package/.next/server/chunks/ssr/{node_modules_0ii1l89._.js → node_modules_0dzm4um._.js} +1 -1
  131. package/.next/server/chunks/ssr/{node_modules_20xmwtu._.js → node_modules_0jljel9._.js} +1 -1
  132. package/.next/server/chunks/ssr/{node_modules_1ix-g49._.js → node_modules_0sgy-dc._.js} +1 -1
  133. package/.next/server/chunks/ssr/{node_modules_0woscox._.js → node_modules_0t_ez6-._.js} +1 -1
  134. package/.next/server/chunks/ssr/{node_modules_059vtf2._.js → node_modules_0th357h._.js} +1 -1
  135. package/.next/server/chunks/ssr/{node_modules_06w645b._.js → node_modules_0ubdtk-._.js} +1 -1
  136. package/.next/server/chunks/ssr/{node_modules_0b8df3s._.js → node_modules_0uyh_vb._.js} +1 -1
  137. package/.next/server/chunks/ssr/{node_modules_07ih6wb._.js → node_modules_0wnlddw._.js} +1 -1
  138. package/.next/server/chunks/ssr/{node_modules_0gt-uw9._.js → node_modules_0x630an._.js} +1 -1
  139. package/.next/server/chunks/ssr/{node_modules_1x825hz._.js → node_modules_0yvz9e0._.js} +1 -1
  140. package/.next/server/chunks/ssr/{node_modules_0t-44lj._.js → node_modules_12et8d5._.js} +1 -1
  141. package/.next/server/chunks/ssr/{node_modules_1m3gb16._.js → node_modules_13kwejm._.js} +1 -1
  142. package/.next/server/chunks/ssr/{node_modules_1p9rdsy._.js → node_modules_1af3w91._.js} +1 -1
  143. package/.next/server/chunks/ssr/{node_modules_0sz5yg1._.js → node_modules_1bucjlk._.js} +1 -1
  144. package/.next/server/chunks/ssr/{node_modules_1teyzfa._.js → node_modules_1lkix61._.js} +1 -1
  145. package/.next/server/chunks/ssr/{node_modules_1lsyy7k._.js → node_modules_1ogczzz._.js} +1 -1
  146. package/.next/server/chunks/ssr/{node_modules_1-7qawg._.js → node_modules_1s-gb-1._.js} +1 -1
  147. package/.next/server/chunks/ssr/{node_modules_0yv-re6._.js → node_modules_1uwg-gz._.js} +1 -1
  148. package/.next/server/chunks/ssr/{node_modules_03ptrl9._.js → node_modules_1wbkzl9._.js} +1 -1
  149. package/.next/server/chunks/ssr/{node_modules_00jv9_3._.js → node_modules_1z1lrbk._.js} +1 -1
  150. package/.next/server/chunks/ssr/{node_modules_@base-ui_react_0jne69c._.js → node_modules_@base-ui_react_0buz1-j._.js} +1 -1
  151. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_00q1oa3._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0r443fh._.js} +1 -1
  152. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1-2_5z7._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_10wnlbk._.js} +1 -1
  153. package/.next/server/middleware-build-manifest.js +3 -3
  154. package/.next/server/pages/404.html +1 -1
  155. package/.next/server/pages/500.html +1 -1
  156. package/.next/server/server-reference-manifest.js +1 -1
  157. package/.next/server/server-reference-manifest.json +57 -57
  158. package/.next/static/chunks/06nt9tatr-dug.js +1 -0
  159. package/.next/static/chunks/0_awn8tucznxc.js +1 -0
  160. package/.next/static/chunks/{34s52v8f841zo.js → 0ge-hx0ed83a1.js} +1 -1
  161. package/.next/static/chunks/0pda_vf-abwvx.js +1 -0
  162. package/.next/static/chunks/{2u9yjkpkoij75.js → 0qmd8n52hp-6v.js} +1 -1
  163. package/.next/static/chunks/0rowp9rx3qbxu.js +18 -0
  164. package/.next/static/chunks/{1ocy4w0v20a3v.js → 13ixzheqw7o-w.js} +2 -2
  165. package/.next/static/chunks/1grkt5gr8pbg1.js +17 -0
  166. package/.next/static/chunks/{21gf2t_whhurc.js → 1yugpvvi8qrbu.js} +2 -2
  167. package/.next/static/chunks/{1e4yrzs5evq_r.js → 245hb85nsy6j4.js} +1 -1
  168. package/.next/static/chunks/27lkanxvtdn09.js +1 -0
  169. package/.next/static/chunks/{0oz7a68qanm99.js → 27tvv1i-smrck.js} +1 -1
  170. package/.next/static/chunks/{2zhfdbq50ee5i.js → 2c64drdevdla3.js} +1 -1
  171. package/.next/static/chunks/{0k5tkt_qi52kb.js → 2ndw4w4u2x51r.js} +1 -1
  172. package/.next/static/chunks/37j27b3e1gt7r.js +1 -0
  173. package/.next/static/chunks/{2om4lkg86feb4.js → 38301ji-85i30.js} +1 -1
  174. package/.next/static/chunks/{09c13vnqy7al3.js → 3bbzsitgiltnt.js} +2 -2
  175. package/.next/static/chunks/3fec-aeteddr-.js +1 -0
  176. package/.next/static/chunks/3go3hwp1z2_h2.css +1 -0
  177. package/.next/static/chunks/3h2bun3hcggg8.js +1 -0
  178. package/.next/static/chunks/{0g1p98s2pfx2w.js → 3h2e-xv1zxh_f.js} +2 -2
  179. package/.next/static/chunks/3j1y335o95mj7.js +1 -0
  180. package/.next/static/chunks/3obf9n3cxj99k.js +1 -0
  181. package/.next/static/chunks/{2upc9mkcc3nlq.js → 427qsc6kahxyo.js} +1 -1
  182. package/README.md +31 -14
  183. package/bin/port.mjs +11 -7
  184. package/bin/thursday.mjs +1 -1
  185. package/components/ui/radio-group.tsx +2 -2
  186. package/components/ui/shiny-text.tsx +3 -22
  187. package/docs/how-it-works.md +11 -3
  188. package/docs/images/first-run.png +0 -0
  189. package/docs/images/keeps-going.png +0 -0
  190. package/docs/images/two-minds.png +0 -0
  191. package/features/ai/components/model-browser.tsx +1 -1
  192. package/features/ai/components/model-picker.tsx +1 -1
  193. package/features/ai/guide.ts +9 -4
  194. package/features/ai/prompts/bot.prompt.ts +4 -1
  195. package/features/ai/tools/routine.tool.ts +28 -16
  196. package/features/bot/bot.runner.ts +3 -1
  197. package/features/bot/components/bot-mark.tsx +6 -1
  198. package/features/bot/components/bot-setting.tsx +2 -4
  199. package/features/bot/components/bot-tool.tsx +2 -0
  200. package/features/bot/components/room-list.tsx +12 -3
  201. package/features/bot/components/room-pill.tsx +26 -19
  202. package/features/config/components/config-setting.tsx +17 -5
  203. package/features/config/components/voice-key.tsx +38 -18
  204. package/features/connectors/mcp.const.ts +90 -59
  205. package/features/intro/components/intro.tsx +50 -27
  206. package/features/routine/components/routine-mark.tsx +4 -6
  207. package/features/routine/components/routine-setting.tsx +332 -143
  208. package/features/routine/routine.query.ts +24 -3
  209. package/features/routine/routine.schema.ts +55 -4
  210. package/features/settings/components/install-app.tsx +1 -4
  211. package/features/settings/components/setting-ui.tsx +1 -1
  212. package/features/skills/skills.discover.ts +2 -1
  213. package/features/skills/skills.query.ts +5 -1
  214. package/features/skills/skills.schema.ts +2 -0
  215. package/features/thursday/components/ascii-orb.tsx +39 -10
  216. package/features/thursday/components/connect-wave.tsx +284 -0
  217. package/features/thursday/components/side-captions.tsx +29 -17
  218. package/features/thursday/components/thursday-setting.tsx +2 -2
  219. package/features/thursday/components/thursday.tsx +130 -58
  220. package/features/thursday/components/voice-picker.tsx +1 -1
  221. package/features/thursday/components/write-line.tsx +2 -2
  222. package/features/thursday/open-work.ts +11 -3
  223. package/features/thursday/tool-line.ts +94 -12
  224. package/features/thursday/use-text-call.ts +3 -2
  225. package/features/thursday/use-thursday.ts +5 -2
  226. package/features/workspace/components/artifact-view.tsx +129 -7
  227. package/guide/bots.md +17 -5
  228. package/guide/calls.md +15 -7
  229. package/guide/setup.md +10 -2
  230. package/lib/desktop-notify.ts +3 -2
  231. package/package.json +1 -1
  232. package/scripts/bot-context.test.mts +1 -1
  233. package/skills/computer/SKILL.md +1 -0
  234. package/skills/interactive-page/SKILL.md +4 -0
  235. package/.next/server/chunks/[root-of-the-server]__0n-l_n_._.js +0 -3
  236. package/.next/server/chunks/[root-of-the-server]__0wvo2of._.js +0 -3
  237. package/.next/server/chunks/[root-of-the-server]__1e6aut3._.js +0 -3
  238. package/.next/server/chunks/[root-of-the-server]__1ziojdq._.js +0 -3
  239. package/.next/server/chunks/ssr/[root-of-the-server]__1srp8l5._.js +0 -3
  240. package/.next/server/chunks/ssr/_0mes4s0._.js +0 -3
  241. package/.next/server/chunks/ssr/_0ya0cb0._.js +0 -3
  242. package/.next/server/chunks/ssr/_0yto5s7._.js +0 -20
  243. package/.next/server/chunks/ssr/_10dw2nv._.js +0 -3
  244. package/.next/server/chunks/ssr/_1p0gxeo._.js +0 -164
  245. package/.next/server/chunks/ssr/_1r41yvh._.js +0 -3
  246. package/.next/server/chunks/ssr/_1r79ksv._.js +0 -3
  247. package/.next/server/chunks/ssr/features_bot_1ogjt52._.js +0 -3
  248. package/.next/server/chunks/ssr/node_modules_@base-ui_react_0b3d4m9._.js +0 -3
  249. package/.next/static/chunks/03omwz_vi2ndg.js +0 -1
  250. package/.next/static/chunks/0_1bqgd6wt_og.js +0 -1
  251. package/.next/static/chunks/0abgkzikaznxc.js +0 -1
  252. package/.next/static/chunks/0bddkpash59-o.js +0 -17
  253. package/.next/static/chunks/0c2-bzhy3a0ib.js +0 -1
  254. package/.next/static/chunks/0iilfb1ocevnx.js +0 -1
  255. package/.next/static/chunks/0imbhx-j830a_.css +0 -1
  256. package/.next/static/chunks/24h1y9dhy3m_2.js +0 -1
  257. package/.next/static/chunks/2be08eqxsfc1y.js +0 -1
  258. package/.next/static/chunks/2d3yhjtafgmtw.js +0 -1
  259. package/.next/static/chunks/2f_5saocsko_b.js +0 -1
  260. package/.next/static/chunks/2lwbr5vx0ixaj.js +0 -18
  261. package/.next/static/chunks/44kjmi5h_p8px.js +0 -1
  262. /package/.next/static/{UiOMPYpQ4fqGyu5PzS-7j → u8kJqShUAa49vY7BxAWsw}/_buildManifest.js +0 -0
  263. /package/.next/static/{UiOMPYpQ4fqGyu5PzS-7j → u8kJqShUAa49vY7BxAWsw}/_clientMiddlewareManifest.js +0 -0
  264. /package/.next/static/{UiOMPYpQ4fqGyu5PzS-7j → u8kJqShUAa49vY7BxAWsw}/_ssgManifest.js +0 -0
@@ -1,10 +1,10 @@
1
- module.exports=[159479,e=>e.a(async(t,a)=>{try{var i=e.i(847841),n=e.i(983477),r=e.i(687388),o=e.i(386075),s=e.i(54282),l=e.i(316172),h=e.i(349047),c=e.i(170801),d=e.i(926435),u=e.i(770639),m=e.i(418919),p=e.i(489956),w=e.i(205863),f=e.i(41181),g=e.i(353885),y=e.i(123203),b=e.i(944971),S=e.i(636882),T=e.i(22676),O=e.i(786025),$=e.i(704161),k=e.i(640911),_=e.i(53748),v=e.i(388439),M=e.i(41444),A=t([o,l,d,u,m,p,T]);async function E(t){let{listThreadOverview:a}=await e.A(866938),i=await a();if(!i.length)return"No thread has been started yet.";let n=i.map(e=>`"${e.label}" (${e.bot}, ${e.status})`).join(", ");return`There is no thread called "${t}". The latest are: ${n}. Call again with one of those labels.`}async function N(e,t){let a=[];for(let[e,n]of Object.entries(t)){let t=await (0,i.asSchema)(n.inputSchema).jsonSchema,r="string"==typeof n.description?n.description:"";a.push({name:e,tokens:(0,v.estimateTokens)(r)+(0,v.estimateTokens)(JSON.stringify(t))})}a.sort((e,t)=>t.tokens-e.tokens);let n=a.reduce((e,t)=>e+t.tokens,0);k.logger.debug(`${e} tools ${n} tokens over ${a.length} — ${a.map(e=>`${e.name} ${e.tokens}`).join(", ")}`)}async function x(e){let t=await L(e);return r.IS_DEV&&await N(e.target,t),t}async function L(t){if("memory-edit"===t.target){let e=(0,u.createMemoryTools)("user",null,{countReads:!1});return{[g.TOOL_NAMES.memory_recall]:e[g.TOOL_NAMES.memory_recall],[g.TOOL_NAMES.memory_remember]:e[g.TOOL_NAMES.memory_remember],[g.TOOL_NAMES.memory_forget]:e[g.TOOL_NAMES.memory_forget]}}let{[g.TOOL_NAMES.memory_conversation]:a,...k}=(0,u.createMemoryTools)("call","thursday"===t.target?t.callId??null:null),v={[g.TOOL_NAMES.memory_conversation]:a},A=await (0,O.openWorkspace)();if("thursday"===t.target){var N;let a,o,d=await (0,T.readCallSkillsOn)()?(0,f.createSkillTools)({sandbox:A,skills:await (0,S.loadSkills)(A)}):{};return{...k,...v,...d,...(0,y.createWorkspaceTools)(A,{write:!1,timeoutMs:r.CALL_EXEC_TIMEOUT_MS}),...!1===t.webSearch?{}:await (0,p.createCallSearchTool)(A),...(N=t.callId,a=async t=>{let{resolveThread:a}=await e.A(866938);return(t.trim()?await a(t.trim()):null)??await E(t)},o=async(t,a,i)=>{let n=await e.A(994193);try{return await n.answerThread(t,a,"thursday",i)}catch(e){if((0,_.isPublicError)(e))return e.message;throw e}},{[g.TOOL_NAMES.thread_start]:(0,i.tool)({description:l.threadStartSpec.description,inputSchema:l.threadStartSpec.parameters,execute:async({bot:t,request:a,label:i})=>{let{findJobBot:n,listJobBots:r}=await e.A(814317),o=await n(t);if(!o||o.disabled){let e=(await r()).map(e=>e.name);return`There is no bot called "${t}". The bots are: ${e.join(", ")}. Nothing was started — call again with one of those.`}let{startThread:s}=await e.A(994193);return{threadId:await s({bot:o.name,request:a,label:i,callId:N,from:"thursday"}),note:`${o.name} has "${i}". Its updates reach the conversation on their own. Anything further about this work — a correction, the next step once it finishes — is \`${g.TOOL_NAMES.thread_tell}\` with "${i}"; a question it asks is answered with \`${g.TOOL_NAMES.thread_answer}\`.`}}}),[g.TOOL_NAMES.thread_tell]:(0,i.tool)({description:l.threadTellSpec.description,inputSchema:l.threadTellSpec.parameters,execute:async({thread:e,words:t})=>{let i=await a(e);if("string"==typeof i)return i;if(!t.trim())return"Say what to pass on.";let n=await o(i.id,t.trim());return"string"==typeof n?n:n?.answered?{label:i.label,answered:n.answered,note:`${n.answered.bot} was waiting on a question, and took this as its answer.`}:{label:i.label,bot:n?.to??i.bot,status:"running",note:"running"===i.status?"The bot reads it before its next step.":"The bot picks the thread back up from there."}}}),[g.TOOL_NAMES.thread_answer]:(0,i.tool)({description:l.threadAnswerSpec.description,inputSchema:l.threadAnswerSpec.parameters,execute:async({thread:t,bot:i,answer:n})=>{let r=await a(t);if("string"==typeof r)return r;if(!n.trim())return"Say what the answer is.";let{findThreadView:s}=await e.A(866938),l=(await s(r.id))?.room.questions??[],h=l.find(e=>e.bot.toLowerCase()===i.trim().toLowerCase());if(!h)return l.length?`${i} is not asking anything in "${r.label}". Waiting there: ${l.map(e=>e.bot).join(", ")}. Call again with that bot.`:`No question is waiting in "${r.label}". To say something else to it, use \`${g.TOOL_NAMES.thread_tell}\`.`;let c=await o(r.id,n.trim(),h.bot);return"string"==typeof c?c:{label:r.label,answered:c?.answered??{bot:h.bot,question:h.text},note:`${h.bot} has the answer to its question and goes on from it.`}}}),[g.TOOL_NAMES.thread_status]:(0,i.tool)({description:l.threadStatusSpec.description,inputSchema:l.threadStatusSpec.parameters,execute:async({thread:t})=>{let{listThreadOverview:i,findThreadView:r}=await e.A(866938),o={now:(0,s.clockNow)()},l=e=>(0,n.formatDistanceToNowStrict)((0,$.toDate)(e),{addSuffix:!0});if(!(!t.trim()||"all"===t.trim().toLowerCase())){let e=await a(t);if("string"==typeof e)return e;let i=(await r(e.id))?.room;return{...o,label:e.label,id:e.id,bot:e.bot,participants:i?.participants??[],questions:i?.questions??[],status:e.status,since:l(e.updatedAt),outcome:e.outcome,..."waiting"===e.status&&e.pending?.options.length?{options:e.pending.options}:{}}}let h=await i();return h.length?{...o,threads:h.map(e=>({id:e.id,label:e.label,bot:e.bot,status:e.status,participants:e.room.participants,questions:e.room.questions.map(e=>({...e,text:(0,M.clip)(e.text,200)})),since:l(e.updatedAt),...e.ask?{asking:e.ask.question,options:e.ask.options}:{},..."running"===e.status?{now:(0,b.threadActivity)(e.lines)}:{},...e.outcome&&"waiting"!==e.status?{outcome:(0,M.clip)(e.outcome,200)}:{}}))}:"No thread has been started yet."}}),[g.TOOL_NAMES.thread_cancel]:(0,i.tool)({description:l.threadCancelSpec.description,inputSchema:l.threadCancelSpec.parameters,execute:async({thread:t})=>{let i=await a(t);if("string"==typeof i)return i;let{cancelThread:n}=await e.A(994193);return await n(i.id),{label:i.label,status:"cancelled"}}}),[g.TOOL_NAMES.thread_show]:(0,i.tool)({description:l.threadShowSpec.description,inputSchema:l.threadShowSpec.parameters,execute:async({thread:t})=>{let i=await a(t);if("string"==typeof i)return i;let{appEvents:n}=await e.A(522275),{filesOnDisk:r}=await e.A(149325),{opensOnFinish:o,pathsIn:s}=await e.A(628124),l=await r(s(i.outcome??""),null);if(!l.length)return n.emit({type:"showThread",threadId:i.id}),{label:i.label,showing:"the thread"};let h=Math.max(0,l.findIndex(o));n.emit({type:"showFile",paths:[l[h],...l.filter((e,t)=>t!==h)]});let{markSeen:c}=await e.A(866938);return await c([i.id]),{label:i.label,showing:l[h]}}}),[g.TOOL_NAMES.thread_seen]:(0,i.tool)({description:l.threadSeenSpec.description,inputSchema:l.threadSeenSpec.parameters,execute:async({thread:t})=>{let i=await a(t);if("string"==typeof i)return i;let{markSeen:n}=await e.A(866938);return await n([i.id]),{label:i.label,seen:!0}}})}),...(0,m.createRoutineTools)(),...t.written?(0,c.createLookTool)():(0,h.callTools)()}}let x=await (0,S.loadSkills)(A,t.bot);return{[g.TOOL_NAMES.memory_recall]:k[g.TOOL_NAMES.memory_recall],...v,...await (0,p.createSearchTool)(t.model,A),...(0,y.createWorkspaceTools)(A,{write:!0,env:{...(0,O.jobShellEnv)(t.session),...(0,O.botShellEnv)(t.bot)},guide:!0,bot:t.bot}),...await (0,d.createMcpTools)(t.bot,A),...(0,f.createSkillTools)({sandbox:A,skills:x,bot:t.bot}),...t.model&&(0,o.seesToolImages)(t.model.ref)?(0,c.createLookTool)():{},...(0,w.createSignInTools)(A,t.bot,(0,O.jobShellEnv)(t.session)),...await (0,l.createThreadRecallTool)(t.bot,t.thread??null)}}[o,l,d,u,m,p,T]=A.then?(await A)():A,e.s(["loadTools",0,x]),a()}catch(e){a(e)}},!1),54282,e=>{"use strict";var t=e.i(343747),a=e.i(983477),i=e.i(687388),n=e.i(353885);n.TOOL_NAMES.memory_recall,n.TOOL_NAMES.memory_remember,n.TOOL_NAMES.memory_forget,n.TOOL_NAMES.bash,n.TOOL_NAMES.web_search,n.TOOL_NAMES.load_skill,n.TOOL_NAMES.look_at,n.TOOL_NAMES.end_call;var r=e.i(704161),o=e.i(640911),s=e.i(388439),l=e.i(41444);let h=(e=new Date)=>`${(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm")} ${Intl.DateTimeFormat().resolvedOptions().timeZone}`,c=(e=new Date)=>`**Now**: ${h(e)}`,d=e=>`${(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm")} (${(0,a.formatDistanceToNowStrict)(e,{addSuffix:!0})})`,u={[n.STUDIO_TOOLS.generate_image]:"images",[n.STUDIO_TOOLS.generate_speech]:"speech",[n.STUDIO_TOOLS.transcribe]:"transcription",[n.STUDIO_TOOLS.generate_video]:"video"};e.s(["botWorkHead",0,function(e,i){let n=(0,a.formatDistanceToNowStrict)(e.updatedAt,{addSuffix:!0}),r="running"===e.status?`running, last moved ${n}`:e.asking?`waiting on the user's answer since ${n}`:"waiting"===e.status?`stopped ${n}, not finished`:`${"done"===e.status?"ended":"stopped by the user"} ${(0,t.format)(e.updatedAt,"yyyy-MM-dd")}`;return`"${e.label}" — ${e.owner===i?"yours":`${e.owner}'s`} — ${r}`},"callEnding",0,()=>`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 ${n.TOOL_NAMES.end_call} tool.`,"callStamp",0,d,"carriedLines",0,(e,t={})=>e.map(e=>`- ${e.text} \xb7 ${e.path}${!1===t.ids?"":` #${e.id}`}`).join("\n"),"clockNow",0,h,"conversationLines",0,e=>e.map(e=>"tool"===e.role?`you → ${e.tool??"tool"}`:`${"user"===e.role?"user":"you"}: ${e.text}`).join("\n"),"expandedFacts",0,function(e,t){let a=e.filter(e=>t.has(e.id)),n=e.filter(e=>!t.has(e.id)),r=Math.max(0,i.MEMORY_LIMITS.expanded-a.length),o=new Set([...a,...n.slice(Math.max(0,n.length-r))].map(e=>e.id)),s=e.filter(e=>o.has(e.id));return{shown:s,hidden:e.length-s.length}},"logPromptSize",0,function(e,t){let a=(0,s.sectionTokens)(t),n=a.reduce((e,t)=>e+t.tokens,0);o.logger.debug(`${e} prompt ${n} tokens — ${a.map(e=>`${e.name} ${e.tokens}`).join(", ")}`);let r=a[0];n>i.PROMPT_BUDGET&&r&&o.logger.warn(`${e} prompt is ${n} tokens, over ${i.PROMPT_BUDGET}: ${r.name} carries ${r.tokens} of it. Every call and every job pays this.`)},"mcpToolLines",0,function(e){let t=new Map;for(let a of e){let e=t.get(a.server);e?e.push(a.name):t.set(a.server,[a.name])}return[...t].map(([e,t])=>`- **${e}**: ${t.join(", ")}`).join("\n")},"noteLines",0,function(e,t=!1){return e.length?e.map(e=>{var a;let i,n=e.aliases?.length?` ${e.aliases.map(e=>`"${e}"`).join(" ")}`:"",o=t?` \xb7 ${a=e.lastSeenAt,(i=Math.floor((Date.now()-(0,r.toDate)(a).getTime())/864e5))>=365?`${Math.floor(i/365)}y`:i>=30?`${Math.floor(i/30)}mo`:`${Math.max(i,0)}d`}`:"";return`- ${e.path} — ${e.description?.trim()} (${e.factCount})${n}${o}`}).join("\n"):"(nothing saved yet)"},"nowLine",0,c,"reachNames",0,function(e,t){let a=t.map(e=>e.server===i.STUDIO_SERVER?u[e.name]??e.name:e.server);return[...new Set([...e.map(e=>e.name),...a])].join(", ")},"recentCallLines",0,function(e,t){let a=[],r=0;e:for(let o=e.length-1;o>=0;o--){let h=e[o];for(let e=h.turns.length-1;e>=0;e--){let o=function(e,t){if("tool"!==e.role)return`${"user"===e.role?"user":"you"}: ${e.text}`;let a=function(e,t){if(e!==n.TOOL_NAMES.web_search)return null;try{let e=JSON.parse(t),a=Array.isArray(e.sources)?e.sources.flatMap(e=>e&&"object"==typeof e&&"string"==typeof e.url?[e]:[]):[];return{query:"string"==typeof e.query?e.query:null,sources:a}}catch{return null}}(e.tool,e.text);if(a){let t=[...new Set(a.sources.flatMap(e=>{try{return[new URL(e.url).hostname.replace(/^www\./,"")]}catch{return[]}}))];return`you → ${e.tool} "${(0,l.clip)(a.query??"",i.PROMPT_LINE.toolArgs)}"${t.length?` — ${t.join(", ")}`:""}`}let r=`you → ${e.tool??"tool"} ${(0,l.clip)(e.text,i.PROMPT_LINE.toolArgs)}`;if(e.tool!==n.TOOL_NAMES.thread_start)return r;let o=function(e,t){if(e!==n.TOOL_NAMES.thread_start)return null;try{let e=JSON.parse(t);return"string"==typeof e.label?e.label:null}catch{return null}}(e.tool,e.text),s=o?t.jobs?.find(e=>e.label===o):void 0;if(!s)return r;let h=s.outcome?`: ${(0,l.clip)(s.outcome,i.PROMPT_LINE.jobOutcome)}`:"";return`you → ${e.tool} "${s.label}" (${s.id}) — ${s.status}${h}`}(h.turns[e],h),c=(0,s.estimateTokens)(o)+3;if(r+c>t&&a.length)break e;r+=c,a.push({call:h,line:o})}}a.reverse();let o=[],h=null;for(let{call:e,line:t}of a)e!==h&&(h=e,o.push(`### ${d(e.startedAt)}`)),o.push(t);return o.join("\n")},"saidStamp",0,e=>(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm"),"skillLines",0,(e,t={})=>e.map(e=>{var a;let n,r;return`- **${e.name}**: ${t.short?(a=e.description,n=i.PROMPT_LINE.skill,(r=a.trim().split(/(?<=[.。])\s|\n/)[0].trim()).length>n?`${r.slice(0,n).trim()}…`:r):e.description}`}).join("\n"),"thursdayIdentity",0,(e=new Date)=>`You are Thursday, this user's own personal assistant, on their side, modeled on Friday, the AI in *Iron Man*. ${c(e)}
1
+ module.exports=[159479,e=>e.a(async(t,a)=>{try{var i=e.i(847841),n=e.i(983477),r=e.i(687388),o=e.i(386075),s=e.i(54282),l=e.i(316172),h=e.i(349047),c=e.i(170801),d=e.i(926435),u=e.i(770639),m=e.i(418919),p=e.i(489956),w=e.i(205863),f=e.i(41181),g=e.i(353885),y=e.i(123203),b=e.i(944971),S=e.i(636882),T=e.i(22676),O=e.i(786025),$=e.i(704161),_=e.i(640911),k=e.i(53748),v=e.i(388439),M=e.i(41444),A=t([o,l,d,u,m,p,T]);async function E(t){let{listThreadOverview:a}=await e.A(866938),i=await a();if(!i.length)return"No thread has been started yet.";let n=i.map(e=>`"${e.label}" (${e.bot}, ${e.status})`).join(", ");return`There is no thread called "${t}". The latest are: ${n}. Call again with one of those labels.`}async function N(e,t){let a=[];for(let[e,n]of Object.entries(t)){let t=await (0,i.asSchema)(n.inputSchema).jsonSchema,r="string"==typeof n.description?n.description:"";a.push({name:e,tokens:(0,v.estimateTokens)(r)+(0,v.estimateTokens)(JSON.stringify(t))})}a.sort((e,t)=>t.tokens-e.tokens);let n=a.reduce((e,t)=>e+t.tokens,0);_.logger.debug(`${e} tools ${n} tokens over ${a.length} — ${a.map(e=>`${e.name} ${e.tokens}`).join(", ")}`)}async function L(e){let t=await x(e);return r.IS_DEV&&await N(e.target,t),t}async function x(t){if("memory-edit"===t.target){let e=(0,u.createMemoryTools)("user",null,{countReads:!1});return{[g.TOOL_NAMES.memory_recall]:e[g.TOOL_NAMES.memory_recall],[g.TOOL_NAMES.memory_remember]:e[g.TOOL_NAMES.memory_remember],[g.TOOL_NAMES.memory_forget]:e[g.TOOL_NAMES.memory_forget]}}let{[g.TOOL_NAMES.memory_conversation]:a,..._}=(0,u.createMemoryTools)("call","thursday"===t.target?t.callId??null:null),v={[g.TOOL_NAMES.memory_conversation]:a},A=await (0,O.openWorkspace)();if("thursday"===t.target){var N;let a,o,d=await (0,T.readCallSkillsOn)()?(0,f.createSkillTools)({sandbox:A,skills:await (0,S.loadSkills)(A)}):{};return{..._,...v,...d,...(0,y.createWorkspaceTools)(A,{write:!1,timeoutMs:r.CALL_EXEC_TIMEOUT_MS}),...!1===t.webSearch?{}:await (0,p.createCallSearchTool)(A),...(N=t.callId,a=async t=>{let{resolveThread:a}=await e.A(866938);return(t.trim()?await a(t.trim()):null)??await E(t)},o=async(t,a,i)=>{let n=await e.A(994193);try{return await n.answerThread(t,a,"thursday",i)}catch(e){if((0,k.isPublicError)(e))return e.message;throw e}},{[g.TOOL_NAMES.thread_start]:(0,i.tool)({description:l.threadStartSpec.description,inputSchema:l.threadStartSpec.parameters,execute:async({bot:t,request:a,label:i})=>{let{findJobBot:n,listJobBots:r}=await e.A(814317),o=await n(t);if(!o||o.disabled){let e=(await r()).map(e=>e.name);return`There is no bot called "${t}". The bots are: ${e.join(", ")}. Nothing was started — call again with one of those.`}let{startThread:s}=await e.A(994193);return{threadId:await s({bot:o.name,request:a,label:i,callId:N,from:"thursday"}),note:`${o.name} has "${i}". Its updates reach the conversation on their own. Anything further about this work — a correction, the next step once it finishes — is \`${g.TOOL_NAMES.thread_tell}\` with "${i}"; a question it asks is answered with \`${g.TOOL_NAMES.thread_answer}\`.`}}}),[g.TOOL_NAMES.thread_tell]:(0,i.tool)({description:l.threadTellSpec.description,inputSchema:l.threadTellSpec.parameters,execute:async({thread:e,words:t})=>{let i=await a(e);if("string"==typeof i)return i;if(!t.trim())return"Say what to pass on.";let n=await o(i.id,t.trim());return"string"==typeof n?n:n?.answered?{label:i.label,answered:n.answered,note:`${n.answered.bot} was waiting on a question, and took this as its answer.`}:{label:i.label,bot:n?.to??i.bot,status:"running",note:"running"===i.status?"The bot reads it before its next step.":"The bot picks the thread back up from there."}}}),[g.TOOL_NAMES.thread_answer]:(0,i.tool)({description:l.threadAnswerSpec.description,inputSchema:l.threadAnswerSpec.parameters,execute:async({thread:t,bot:i,answer:n})=>{let r=await a(t);if("string"==typeof r)return r;if(!n.trim())return"Say what the answer is.";let{findThreadView:s}=await e.A(866938),l=(await s(r.id))?.room.questions??[],h=l.find(e=>e.bot.toLowerCase()===i.trim().toLowerCase());if(!h)return l.length?`${i} is not asking anything in "${r.label}". Waiting there: ${l.map(e=>e.bot).join(", ")}. Call again with that bot.`:`No question is waiting in "${r.label}". To say something else to it, use \`${g.TOOL_NAMES.thread_tell}\`.`;let c=await o(r.id,n.trim(),h.bot);return"string"==typeof c?c:{label:r.label,answered:c?.answered??{bot:h.bot,question:h.text},note:`${h.bot} has the answer to its question and goes on from it.`}}}),[g.TOOL_NAMES.thread_status]:(0,i.tool)({description:l.threadStatusSpec.description,inputSchema:l.threadStatusSpec.parameters,execute:async({thread:t})=>{let{listThreadOverview:i,findThreadView:r}=await e.A(866938),o={now:(0,s.clockNow)()},l=e=>(0,n.formatDistanceToNowStrict)((0,$.toDate)(e),{addSuffix:!0});if(!(!t.trim()||"all"===t.trim().toLowerCase())){let e=await a(t);if("string"==typeof e)return e;let i=(await r(e.id))?.room;return{...o,label:e.label,id:e.id,bot:e.bot,participants:i?.participants??[],questions:i?.questions??[],status:e.status,since:l(e.updatedAt),outcome:e.outcome,..."waiting"===e.status&&e.pending?.options.length?{options:e.pending.options}:{}}}let h=await i();return h.length?{...o,threads:h.map(e=>({id:e.id,label:e.label,bot:e.bot,status:e.status,participants:e.room.participants,questions:e.room.questions.map(e=>({...e,text:(0,M.clip)(e.text,200)})),since:l(e.updatedAt),...e.ask?{asking:e.ask.question,options:e.ask.options}:{},..."running"===e.status?{now:(0,b.threadActivity)(e.lines)}:{},...e.outcome&&"waiting"!==e.status?{outcome:(0,M.clip)(e.outcome,200)}:{}}))}:"No thread has been started yet."}}),[g.TOOL_NAMES.thread_cancel]:(0,i.tool)({description:l.threadCancelSpec.description,inputSchema:l.threadCancelSpec.parameters,execute:async({thread:t})=>{let i=await a(t);if("string"==typeof i)return i;let{cancelThread:n}=await e.A(994193);return await n(i.id),{label:i.label,status:"cancelled"}}}),[g.TOOL_NAMES.thread_show]:(0,i.tool)({description:l.threadShowSpec.description,inputSchema:l.threadShowSpec.parameters,execute:async({thread:t})=>{let i=await a(t);if("string"==typeof i)return i;let{appEvents:n}=await e.A(522275),{filesOnDisk:r}=await e.A(149325),{opensOnFinish:o,pathsIn:s}=await e.A(628124),l=await r(s(i.outcome??""),null);if(!l.length)return n.emit({type:"showThread",threadId:i.id}),{label:i.label,showing:"the thread"};let h=Math.max(0,l.findIndex(o));n.emit({type:"showFile",paths:[l[h],...l.filter((e,t)=>t!==h)]});let{markSeen:c}=await e.A(866938);return await c([i.id]),{label:i.label,showing:l[h]}}}),[g.TOOL_NAMES.thread_seen]:(0,i.tool)({description:l.threadSeenSpec.description,inputSchema:l.threadSeenSpec.parameters,execute:async({thread:t})=>{let i=await a(t);if("string"==typeof i)return i;let{markSeen:n}=await e.A(866938);return await n([i.id]),{label:i.label,seen:!0}}})}),...(0,m.createRoutineTools)(),...t.written?(0,c.createLookTool)():(0,h.callTools)()}}let L=await (0,S.loadSkills)(A,t.bot);return{[g.TOOL_NAMES.memory_recall]:_[g.TOOL_NAMES.memory_recall],...v,...await (0,p.createSearchTool)(t.model,A),...(0,y.createWorkspaceTools)(A,{write:!0,env:{...(0,O.jobShellEnv)(t.session),...(0,O.botShellEnv)(t.bot)},guide:!0,bot:t.bot}),...await (0,d.createMcpTools)(t.bot,A),...(0,f.createSkillTools)({sandbox:A,skills:L,bot:t.bot}),...t.model&&(0,o.seesToolImages)(t.model.ref)?(0,c.createLookTool)():{},...(0,w.createSignInTools)(A,t.bot,(0,O.jobShellEnv)(t.session)),...await (0,l.createThreadRecallTool)(t.bot,t.thread??null)}}[o,l,d,u,m,p,T]=A.then?(await A)():A,e.s(["loadTools",0,L]),a()}catch(e){a(e)}},!1),54282,e=>{"use strict";var t=e.i(343747),a=e.i(983477),i=e.i(687388),n=e.i(353885);n.TOOL_NAMES.memory_recall,n.TOOL_NAMES.memory_remember,n.TOOL_NAMES.memory_forget,n.TOOL_NAMES.memory_conversation,n.TOOL_NAMES.bash,n.TOOL_NAMES.web_search,n.TOOL_NAMES.load_skill,n.TOOL_NAMES.look_at,n.TOOL_NAMES.end_call,n.TOOL_NAMES.routine,n.TOOL_NAMES.thread_tell,n.TOOL_NAMES.thread_answer,n.TOOL_NAMES.thread_status,n.TOOL_NAMES.thread_show,n.TOOL_NAMES.thread_cancel,n.TOOL_NAMES.thread_seen;var r=e.i(704161),o=e.i(640911),s=e.i(388439),l=e.i(41444);let h=(e=new Date)=>`${(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm")} ${Intl.DateTimeFormat().resolvedOptions().timeZone}`,c=(e=new Date)=>`**Now**: ${h(e)}`,d=e=>`${(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm")} (${(0,a.formatDistanceToNowStrict)(e,{addSuffix:!0})})`,u={[n.STUDIO_TOOLS.generate_image]:"images",[n.STUDIO_TOOLS.generate_speech]:"speech",[n.STUDIO_TOOLS.transcribe]:"transcription",[n.STUDIO_TOOLS.generate_video]:"video"};e.s(["botWorkHead",0,function(e,i){let n=(0,a.formatDistanceToNowStrict)(e.updatedAt,{addSuffix:!0}),r="running"===e.status?`running, last moved ${n}`:e.asking?`waiting on the user's answer since ${n}`:"waiting"===e.status?`stopped ${n}, not finished`:`${"done"===e.status?"ended":"stopped by the user"} ${(0,t.format)(e.updatedAt,"yyyy-MM-dd")}`;return`"${e.label}" — ${e.owner===i?"yours":`${e.owner}'s`} — ${r}`},"callEnding",0,()=>`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 ${n.TOOL_NAMES.end_call} tool.`,"callStamp",0,d,"carriedLines",0,(e,t={})=>e.map(e=>`- ${e.text} \xb7 ${e.path}${!1===t.ids?"":` #${e.id}`}`).join("\n"),"clockNow",0,h,"conversationLines",0,e=>e.map(e=>"tool"===e.role?`you → ${e.tool??"tool"}`:`${"user"===e.role?"user":"you"}: ${e.text}`).join("\n"),"expandedFacts",0,function(e,t){let a=e.filter(e=>t.has(e.id)),n=e.filter(e=>!t.has(e.id)),r=Math.max(0,i.MEMORY_LIMITS.expanded-a.length),o=new Set([...a,...n.slice(Math.max(0,n.length-r))].map(e=>e.id)),s=e.filter(e=>o.has(e.id));return{shown:s,hidden:e.length-s.length}},"logPromptSize",0,function(e,t){let a=(0,s.sectionTokens)(t),n=a.reduce((e,t)=>e+t.tokens,0);o.logger.debug(`${e} prompt ${n} tokens — ${a.map(e=>`${e.name} ${e.tokens}`).join(", ")}`);let r=a[0];n>i.PROMPT_BUDGET&&r&&o.logger.warn(`${e} prompt is ${n} tokens, over ${i.PROMPT_BUDGET}: ${r.name} carries ${r.tokens} of it. Every call and every job pays this.`)},"mcpToolLines",0,function(e){let t=new Map;for(let a of e){let e=t.get(a.server);e?e.push(a.name):t.set(a.server,[a.name])}return[...t].map(([e,t])=>`- **${e}**: ${t.join(", ")}`).join("\n")},"noteLines",0,function(e,t=!1){return e.length?e.map(e=>{var a;let i,n=e.aliases?.length?` ${e.aliases.map(e=>`"${e}"`).join(" ")}`:"",o=t?` \xb7 ${a=e.lastSeenAt,(i=Math.floor((Date.now()-(0,r.toDate)(a).getTime())/864e5))>=365?`${Math.floor(i/365)}y`:i>=30?`${Math.floor(i/30)}mo`:`${Math.max(i,0)}d`}`:"";return`- ${e.path} — ${e.description?.trim()} (${e.factCount})${n}${o}`}).join("\n"):"(nothing saved yet)"},"nowLine",0,c,"reachNames",0,function(e,t){let a=t.map(e=>e.server===i.STUDIO_SERVER?u[e.name]??e.name:e.server);return[...new Set([...e.map(e=>e.name),...a])].join(", ")},"recentCallLines",0,function(e,t){let a=[],r=0;e:for(let o=e.length-1;o>=0;o--){let h=e[o];for(let e=h.turns.length-1;e>=0;e--){let o=function(e,t){if("tool"!==e.role)return`${"user"===e.role?"user":"you"}: ${e.text}`;let a=function(e,t){if(e!==n.TOOL_NAMES.web_search)return null;try{let e=JSON.parse(t),a=Array.isArray(e.sources)?e.sources.flatMap(e=>e&&"object"==typeof e&&"string"==typeof e.url?[e]:[]):[];return{query:"string"==typeof e.query?e.query:null,sources:a}}catch{return null}}(e.tool,e.text);if(a){let t=[...new Set(a.sources.flatMap(e=>{try{return[new URL(e.url).hostname.replace(/^www\./,"")]}catch{return[]}}))];return`you → ${e.tool} "${(0,l.clip)(a.query??"",i.PROMPT_LINE.toolArgs)}"${t.length?` — ${t.join(", ")}`:""}`}let r=`you → ${e.tool??"tool"} ${(0,l.clip)(e.text,i.PROMPT_LINE.toolArgs)}`;if(e.tool!==n.TOOL_NAMES.thread_start)return r;let o=function(e,t){if(e!==n.TOOL_NAMES.thread_start)return null;try{let e=JSON.parse(t);return"string"==typeof e.label?e.label:null}catch{return null}}(e.tool,e.text),s=o?t.jobs?.find(e=>e.label===o):void 0;if(!s)return r;let h=s.outcome?`: ${(0,l.clip)(s.outcome,i.PROMPT_LINE.jobOutcome)}`:"";return`you → ${e.tool} "${s.label}" (${s.id}) — ${s.status}${h}`}(h.turns[e],h),c=(0,s.estimateTokens)(o)+3;if(r+c>t&&a.length)break e;r+=c,a.push({call:h,line:o})}}a.reverse();let o=[],h=null;for(let{call:e,line:t}of a)e!==h&&(h=e,o.push(`### ${d(e.startedAt)}`)),o.push(t);return o.join("\n")},"saidStamp",0,e=>(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm"),"skillLines",0,(e,t={})=>e.map(e=>{var a;let n,r;return`- **${e.name}**: ${t.short?(a=e.description,n=i.PROMPT_LINE.skill,(r=a.trim().split(/(?<=[.。])\s|\n/)[0].trim()).length>n?`${r.slice(0,n).trim()}…`:r):e.description}`}).join("\n"),"thursdayIdentity",0,(e=new Date)=>`You are Thursday, this user's own personal assistant, on their side, modeled on Friday, the AI in *Iron Man*. ${c(e)}
2
2
 
3
3
  What they tell you is kept, so you know them better over time, and whatever they want done can be done for them in the background.`,"tidying",0,e=>({crowded:e.reduce((e,t)=>e+t.factCount,0)>i.MEMORY_LIMITS.facts,heavy:e.filter(e=>e.factCount>i.MEMORY_LIMITS.factsPerNote)})],54282)},316172,e=>e.a(async(t,a)=>{try{var i=e.i(847841),n=e.i(907855),r=e.i(687388),o=e.i(54282),s=e.i(353885),l=e.i(944971),h=e.i(889034),c=e.i(378884),d=e.i(41444),u=t([c]);[c]=u.then?(await u)():u;let p=n.string().describe("The thread, by its label or its id."),w={description:"Start a new thread: hand work to a bot. Returns a receipt at once; the work runs in the background and its updates reach the conversation on their own.",parameters:n.object({bot:n.string().describe("A name from the bot list."),request:n.string().describe("The whole of the work. The bot cannot hear the call, so everything it needs goes here — names, paths, what the user actually asked for — in their own language and their own words: it is the only language the bot has, and whatever it writes comes back to them. **Their request, never your reading of it**: a condition, a caution or a smaller goal they did not say is how work comes back as the wrong thing. When their words leave a real choice open, ask them on the call and put the answer here."),label:n.string().describe("Two or three words naming the thread, in the user's language. Used on screen and said out loud.")})},f={description:"Say something to a thread that exists: a correction while it runs, the next step once it has finished, or to go on after it stopped. Its bot reads it with everything the thread already holds.",parameters:n.object({thread:p,words:n.string().describe("What to tell its bot, in the user's language and words.")})},g={description:`Answer a question a bot asked the user. Only for a question that is waiting; anything else said to a thread is \`${s.TOOL_NAMES.thread_tell}\`.`,parameters:n.object({thread:p,bot:n.string().describe("The bot that asked."),answer:n.string().describe("The user's answer, in their words.")})},y={description:`Read threads as they are now. "all" lists up to ${r.THREAD_STATUS_LIMIT}, running and waiting work before recent endings; a label or an id reads that one whole, with its result and any question waiting.`,parameters:n.object({thread:n.string().describe('"all", or one thread by its label or its id.')})},b={description:"Stop a thread for good. It cannot be taken back.",parameters:n.object({thread:p})},S={description:"Put a thread in front of the user on their screen: the file it made, or the thread itself when it made none. Showing it also counts as them having seen its result.",parameters:n.object({thread:p})},T={description:"Mark a thread's result as seen by the user, once they have heard it and have nothing more to ask about it. It leaves the work waiting on them.",parameters:n.object({thread:p})},O={description:"Send a message to a participant or Thursday and receive a delivery receipt immediately. Mark a question for Thursday to request user input; ordinary messages to Thursday are notifications and need no answer.",parameters:h.RoomMessageSchema.extend({kind:h.RoomMessageSchema.shape.kind.describe("Use question only when Thursday must obtain an answer from the user: it ends your turn, and you continue when the answer arrives. Use message for bot collaboration, progress updates and reports."),options:h.RoomMessageSchema.shape.options.describe("With a question, offer concise answer choices when useful. Omit for an open-ended question; the user can always type their own answer."),to:n.string().trim().min(1).describe("Choose a bot from the roster, or Thursday to reach the user."),text:n.string().trim().min(1).describe("Write the message and include the context the recipient needs."),replyTo:n.string().nullish().describe("Use an incoming message ID to send an explicit reply; omit to start a new exchange. Your ordinary final text already replies to your current correspondent.")})},$={description:"Open one of your other threads whole: what you were asked there and your last words in full.",parameters:n.object({id:n.string().describe("The id in brackets on its line under Your other threads.")})};async function m(e,t){let a=await (0,c.listBotWork)(e,t),n=[...a.open,...a.recent];if(!n.some(e=>e.cut))return{};let h=new Set;return{[s.TOOL_NAMES.thread_recall]:(0,i.tool)({description:$.description,inputSchema:$.parameters,execute:async({id:t})=>{let a=t.trim().replace(/^\[|\]$/g,"").toLowerCase(),i=n.find(e=>a.length>=4&&(e.id.startsWith(a)||e.label.toLowerCase()===a));if(!i)return`No thread "${t}" on your list. The ids there: ${n.filter(e=>e.cut).map(e=>(0,l.workHandle)(e.id)).join(", ")}.`;if(!i.cut)return"Its line already shows all of it.";if(h.has(i.id))return"Already opened above, this turn.";if(h.size>=r.BOT_WORK.reads)return`${r.BOT_WORK.reads} threads are open already this turn. Carry on with what you have.`;h.add(i.id);let s=await (0,c.readBotAsk)(e,i),u=i.said??"";return[(0,o.botWorkHead)(i,e),s?`You were asked: ${(0,d.clip)(s,r.BOT_WORK.asked)}`:"",`Your last words there:
4
4
  ${u.length>r.BOT_WORK.readChars?`${u.slice(0,r.BOT_WORK.readChars)}
5
5
  [Cut here; the files it names hold the rest.]`:u}`].filter(Boolean).join("\n\n")}})}}e.s(["createThreadRecallTool",0,m,"sendMessageSpec",0,O,"threadAnswerSpec",0,g,"threadCancelSpec",0,b,"threadSeenSpec",0,T,"threadShowSpec",0,S,"threadStartSpec",0,w,"threadStatusSpec",0,y,"threadTellSpec",0,f]),a()}catch(e){a(e)}},!1),349047,e=>{"use strict";var t=e.i(847841),a=e.i(907855),i=e.i(353885);let n=Object.keys({A:[".##.","#..#","####","#..#","#..#"],B:["###.","#..#","###.","#..#","###."],C:[".###","#...","#...","#...",".###"],D:["###.","#..#","#..#","#..#","###."],E:["####","#...","###.","#...","####"],F:["####","#...","###.","#...","#..."],G:[".###","#...","#.##","#..#",".###"],H:["#..#","#..#","####","#..#","#..#"],I:["###",".#.",".#.",".#.","###"],J:["..##","...#","...#","#..#",".##."],K:["#..#","#.#.","##..","#.#.","#..#"],L:["#...","#...","#...","#...","####"],M:["#...#","##.##","#.#.#","#...#","#...#"],N:["#..#","##.#","#.##","#..#","#..#"],O:[".##.","#..#","#..#","#..#",".##."],P:["###.","#..#","###.","#...","#..."],Q:[".##.","#..#","#..#","#.#.",".#.#"],R:["###.","#..#","###.","#.#.","#..#"],S:[".###","#...",".##.","...#","###."],T:["###",".#.",".#.",".#.",".#."],U:["#..#","#..#","#..#","#..#",".##."],V:["#...#","#...#",".#.#.",".#.#.","..#.."],W:["#...#","#...#","#.#.#","##.##","#...#"],X:["#..#","#..#",".##.","#..#","#..#"],Y:["#.#","#.#",".#.",".#.",".#."],Z:["####","...#",".##.","#...","####"],0:[".##.","#.##","#..#","##.#",".##."],1:[".#.","##.",".#.",".#.","###"],2:["###.","...#",".##.","#...","####"],3:["###.","...#",".##.","...#","###."],4:["#..#","#..#","####","...#","...#"],5:["####","#...","###.","...#","###."],6:[".##.","#...","###.","#..#",".##."],7:["####","...#","..#.",".#..",".#.."],8:[".##.","#..#",".##.","#..#",".##."],9:[".##.","#..#",".###","...#",".##."],"!":["#","#","#",".","#"],"?":["###.","...#",".##.","....",".#.."],".":[".",".",".",".","#"],",":["..","..","..",".#","#."],"'":["#","#",".",".","."],"-":["...","...","###","...","..."],"+":["...",".#.","###",".#.","..."],":":[".","#",".","#","."],"(":[".#","#.","#.","#.",".#"],")":["#.",".#",".#",".#","#."],"<":["..#",".#.","#..",".#.","..#"],">":["#..",".#.","..#",".#.","#.."],"^":[".#.","#.#","...","...","..."],"~":["....",".#.#","#.#.","....","...."],"♥":[".#.#.","#####","#####",".###.","..#.."]," ":["..","..","..","..",".."]}).filter(e=>!/^[A-Z0-9 ]$/.test(e)),r={description:`End the call.
6
6
 
7
- The line stays open until this runs, and drops once the goodbye being said is over.`,parameters:a.object({})},o=(0,t.tool)({description:r.description,inputSchema:r.parameters}),s={description:"Show a short word on your face for a few seconds.",parameters:a.object({text:a.string().describe(`Up to 8 characters: A-Z, 0-9, space and ${n.join(" ")}.`)})},l=(0,t.tool)({description:s.description,inputSchema:s.parameters});e.s(["callTools",0,function(){return{[i.TOOL_NAMES.end_call]:o,[i.TOOL_NAMES.emote]:l}}],349047)},170801,e=>{"use strict";var t=e.i(912714),a=e.i(847841),i=e.i(105249),n=e.i(687388),r=e.i(353885),o=e.i(629668),s=e.i(786025);e.s(["createLookTool",0,function(){return{[r.TOOL_NAMES.look_at]:(0,a.tool)({description:"See an image file yourself: a screenshot you took, a picture the user handed over, a chart you made. For what a picture shows — text files are read in the shell.",inputSchema:i.default.object({path:i.default.string().describe("Workspace-relative path to a png, jpg, webp or gif.")}),execute:async({path:e})=>{let a=await (0,s.insideWorkspace)(e.trim()),i=a?await (0,t.stat)(a).catch(()=>null):null;return a&&i?.isFile()?"image"!==(0,o.viewKindOf)(e)?`${e} is not an image. Read it in the shell instead.`:i.size>n.LOOK.maxBytes?`${e} is ${Math.ceil(i.size/1024/1024)} MB, over the ${n.LOOK.maxBytes/1024/1024} MB one look takes. Make a smaller copy in the shell first (on a Mac: sips -Z 1600 in.png --out out.png), then look at that.`:{path:e.trim(),mediaType:(0,o.mimeOf)(e),bytes:i.size}:`There is no file at ${e}. Give the path from the workspace root, as \`ls\` shows it.`},toModelOutput:async({output:e})=>{if("string"==typeof e)return{type:"text",value:e};let a=await (0,s.insideWorkspace)(e.path),i=a?await (0,t.readFile)(a).catch(()=>null):null;return i?{type:"content",value:[{type:"text",text:`${e.path}, as an image:`},{type:"file",mediaType:e.mediaType,data:{type:"data",data:i.toString("base64")}}]}:{type:"text",value:`${e.path} is no longer there.`}}})}}])},926435,e=>e.a(async(t,a)=>{try{var i=e.i(847841),n=e.i(907855),r=e.i(353885),o=e.i(148831),s=e.i(786025),l=e.i(660948),h=t([o,l]);[o,l]=h.then?(await h)():h;let u={[r.TOOL_NAMES.tool_search]:{description:`Return the description and exact inputSchema of tools on a connected server, so they can be called with \`${r.TOOL_NAMES.tool_call}\`.`,parameters:n.object({server:n.string().describe("A server name, exactly as the Connected tools section writes it."),tools:n.string().array().describe("Tool names listed under that server. Only the ones you may actually call — schemas are large, and at most 8 come back.")})},[r.TOOL_NAMES.tool_call]:{description:`Run one tool whose definition came back from \`${r.TOOL_NAMES.tool_search}\`.`,parameters:n.object({server:n.string().describe("The server the tool lives on."),tool:n.string().describe("Its name, as search returned it."),args:n.record(n.string(),n.unknown()).nullish().describe("Arguments matching the inputSchema search returned — do not guess. Null when it takes none."),description:n.string().nullish().describe("One short line for the user: what this call is for. Shown on their screen while it runs.")})}},m=(e,t)=>`${e.replace(/[^a-zA-Z0-9]+/g,"_")}__${t.replace(/[^a-zA-Z0-9_-]+/g,"_")}`.slice(0,64);async function c(e,t){let[a,n]=await Promise.all([(0,l.listConnectedToolNames)(),(0,o.findPinnedTools)(e)]),r={},h=(0,s.botArtifacts)(e);for(let e of n){let a=m(e.server,e.name);r[a]||(r[a]=(0,i.tool)({description:e.description??`${e.name} on the ${e.server} server.`,inputSchema:(0,i.jsonSchema)(e.inputSchema??{type:"object",properties:{}}),execute:(a,{abortSignal:i})=>(0,l.callConnectedTool)(t,e.server,e.name,a??void 0,{artifacts:h,abortSignal:i})}))}return a.length>n.length&&Object.assign(r,p(t,h)),r}async function d(e){let t=(await (0,l.listConnectedToolNames)(e)).map(e=>e.name);if(t.length)return`Tools on "${e}": ${t.join(", ")}.`;let a=await (0,l.listConnectedServerNames)();return a.length?`There is no server called "${e}". Connected: ${a.join(", ")}.`:"Nothing is connected."}let p=(e,t)=>({[r.TOOL_NAMES.tool_search]:(0,i.tool)({description:u[r.TOOL_NAMES.tool_search].description,inputSchema:u[r.TOOL_NAMES.tool_search].parameters,execute:async({server:e,tools:t})=>{let a=[...new Set(t.map(e=>e.trim()).filter(Boolean))],i=a.slice(0,8),n=await (0,l.findConnectedSchemas)(e.trim(),i);if(!n.length)return{tools:[],note:await d(e)};let r=i.filter(e=>!n.some(t=>t.name===e)),o=a.slice(8),s=[r.length?`Not on "${e}": ${r.join(", ")}.`:"",o.length?`Only 8 at a time — ask again for: ${o.join(", ")}.`:""].filter(Boolean);return{tools:n,...s.length?{note:s.join(" ")}:{}}}}),[r.TOOL_NAMES.tool_call]:(0,i.tool)({description:u[r.TOOL_NAMES.tool_call].description,inputSchema:u[r.TOOL_NAMES.tool_call].parameters,execute:async({server:a,tool:i,args:n},{abortSignal:r})=>(await (0,l.listConnectedToolNames)(a.trim())).some(e=>e.name===i.trim())?(0,l.callConnectedTool)(e,a.trim(),i.trim(),n??void 0,{artifacts:t,abortSignal:r}):{status:"error",text:await d(a)}})});e.s(["createMcpTools",0,c]),a()}catch(e){a(e)}},!1),770639,e=>e.a(async(t,a)=>{try{var i=e.i(847841),n=e.i(907855),r=e.i(687388),o=e.i(54282),s=e.i(353885),l=e.i(619898),h=e.i(453569),c=e.i(22676),d=t([l,c]);[l,c]=d.then?(await d)():d;let u=h.MEMORY_PATHS.map(e=>e.path.endsWith("/")?`${e.path}<name>`:e.path).join(", "),m=e=>({...e,facts:e.facts.map(({saidAt:e,...t})=>e?{...t,said:(0,o.saidStamp)(e)}:t),factCount:e.facts.length}),p=e=>"user"===e?"Typed on the screen — there is no conversation behind it.":"bot"===e?"Saved by a bot during a job — there is no conversation behind it.":"The conversation it was saved in is not kept.",w=e=>e>r.MEMORY_LIMITS.factsPerNote?` This note now holds ${e} facts, past the ${r.MEMORY_LIMITS.factsPerNote} one note holds well. Ask the user which of it is no longer true and delete what they name.`:"";e.s(["createMemoryTools",0,(e,t=null,{countReads:a=!0}={})=>({[s.TOOL_NAMES.memory_recall]:(0,i.tool)({description:"Open one note from the listing, whole.",inputSchema:n.object({path:n.string().describe("Exactly as the listing writes it — the path, or one of the names in quotes after it.")}),execute:async({path:e})=>{let{notes:t}=await (0,l.readNotes)([e],{touch:a}),i=t[0];if(!i)return{note:`Nothing on the listing called ${e.trim()}.`};let n=w(i.facts.length);return n?{...m(i),note:n.trim()}:m(i)}}),[s.TOOL_NAMES.memory_remember]:(0,i.tool)({description:"Write to one note: facts, and the line the listing shows for it. The path is the key — a path not on the listing is created (with at least one fact), one that is gets amended.",inputSchema:n.object({path:n.string().describe("The group this note is found by — the person, project or topic its facts are about. Exactly as the listing writes it, or a new path following the same convention. A fact goes under the one note it is about; other notes name it rather than repeat it."),facts:n.object({text:n.string().describe('One statement that stands on its own later — a date as a date, never "next week".'),replaces:n.number().int().nullish().describe(`The id of the fact this replaces — from this note as handed back here or by \`${s.TOOL_NAMES.memory_recall}\`. Null if this is new. A fact that stopped being true is replaced rather than deleted, and so is a note saying the same thing twice: replacing keeps what changed on the record, deleting does not.`),alwaysLoad:n.boolean().nullish().describe(`True carries this line into every call's instructions without opening its note — for what every call needs before any note is opened: what to call them, their language and register. At most ${r.MEMORY_LIMITS.carried}. Null leaves it; false makes a carried line an ordinary fact.`)}).array().nullish().describe("What to write under this note. Send everything that came up at once: one call is one pause in the conversation, three calls are three. Null when only naming it."),description:n.string().nullish().describe(`One line saying what this note holds, so the listing alone tells which facts are inside. Give it for a new note, and again with new facts: rewritten from the current line and the new facts together, so it covers the whole note rather than only what was added. Null leaves it; ${h.MEMORY_ALWAYS_LISTED.join(", ")} keep their own line.`),aliases:n.string().array().nullish().describe('What the user calls this note out loud, in the language they say it — the words they would use to ask for it, not the facts inside. A note at people/partner might be "my partner" and their first name. Replaces the set it has, so send the whole set. Null leaves it.')}),execute:async a=>{let i=a.path.trim(),n=await (0,l.resolveNotePath)(i),o=a.aliases??null,s=n??i,c=(0,h.isAlwaysListed)(s)?(0,h.appNoteLine)(s):a.description?.trim()||null,d=a.facts??[];if(!d.length&&!c&&!o)return{note:"Nothing to write: send facts, a line, names, or any of them."};if(!n&&!(0,h.isMemoryPath)(i))return{note:`Nothing was saved: "${i}" is not a path this listing can carry. Write it again under one of ${u}.`};if(!n&&!d.length)return{note:`Nothing on the listing called ${i}. A note comes into being with a fact — send at least one.`};let p=await (0,l.writeNotes)([{path:s,description:c,aliases:o,facts:d}],e,t),f=p.unnamed.length?` ${p.unnamed[0]} is new and has no line yet — the listing shows its first fact instead. Call again with \`description\` (one line about what it is) and \`aliases\` (the names they say for it).`:"",g=p.notLoaded.length?` All ${r.MEMORY_LIMITS.carried} carried lines are taken, so ${p.notLoaded.map(e=>`"${e}"`).join(", ")} saved as an ordinary fact. Say which carried line you would drop for it and let them choose.`:"",y=m(p.notes[0]),b=n&&d.length&&!c?` Its line still reads "${y.description}"; if that no longer says what the note holds, send \`description\`.`:"";return{...y,note:`Saved. The listing in your instructions is from when this session opened and will not show this until the next one — the note below is current.${f}${g}${b}${w(y.factCount)}`}}}),[s.TOOL_NAMES.memory_conversation]:(0,i.tool)({description:"Open the conversation a fact was saved in, whole: what each side said, and which tools were used.",inputSchema:n.object({factId:n.number().int().describe("The id that came with the fact when its note was opened."),page:n.number().int().min(1).nullish().describe(`${r.MEMORY_CONVERSATION_PAGE} turns a page, oldest first. Null for the first.`)}),execute:async({factId:e,page:a})=>{let i=await (0,l.findFactCall)(e);if(!i)return{note:`No fact with id ${e}.`};if(!i.callId)return{note:p(i.source)};if(i.callId===t)return{note:"Said in this call — it is the conversation you are in."};let n=a??1,s=await (0,c.readCallConversation)(i.callId,n,r.MEMORY_CONVERSATION_PAGE);if(!s)return{note:p(i.source)};let h=Math.max(1,Math.ceil(s.total/r.MEMORY_CONVERSATION_PAGE));return n>h?{note:`That conversation has ${h} page${h>1?"s":""}.`}:{when:(0,o.callStamp)(s.startedAt),page:n,pages:h,conversation:(0,o.conversationLines)(s.turns)}}}),[s.TOOL_NAMES.memory_forget]:(0,i.tool)({description:"Delete facts for good.",inputSchema:n.object({factIds:n.number().int().array().min(1).describe("The ids that came with the facts when their notes were opened — every one to delete, in one call.")}),execute:async({factIds:e})=>{let t=[],a=[],i=new Set;for(let n of new Set(e)){let e=await (0,l.forgetFactById)(n);if(!e){t.push(n);continue}e.noteGone?(i.delete(e.path),a.push(e.path)):i.add(e.path)}if(!a.length&&!i.size)return{note:`No fact with id ${t.join(", ")}. Nothing was deleted.`};let n=["Deleted for good. The listing in your instructions is from when this session opened and still shows it that way until the next one.",1===a.length?`That was the last fact under ${a[0]}, so the note went with it.`:a.length?`That was the last of ${a.join(", ")}, so those notes went with them.`:"",t.length?`No fact with id ${t.join(", ")}, so those were skipped.`:""].filter(Boolean).join(" ");if(!i.size)return{note:n};let{notes:r}=await (0,l.readNotes)([...i],{touch:!1});return{notes:r.map(m),note:n}}})})]),a()}catch(e){a(e)}},!1),418919,e=>e.a(async(t,a)=>{try{var i=e.i(847841),n=e.i(907855),r=e.i(687388),o=e.i(353885),s=e.i(265143),l=e.i(963219),h=e.i(473139),c=e.i(704161),d=e.i(53748),u=e.i(41444),m=t([s,l]);[s,l]=m.then?(await m)():m;let f={description:`Routines: work that starts by itself, each one a bot, the work and a time. List them, make one, change one, or delete one. Every start opens a thread like one started by hand; its result reaches the conversation the same way. At most ${r.ROUTINE.max} exist.`,parameters:n.object({action:n.enum(["list","create","change","delete"]),routine:n.string().nullish().describe("With change or delete: the routine, by its name or ID."),bot:n.string().nullish().describe("With create: a name from the bot list. With change: a new bot."),label:n.string().nullish().describe("With create: two or three words naming it, in the user's language. It names every thread the routine opens, on screen and out loud."),request:n.string().nullish().describe("With create: the whole of the work, handed to the bot as written every time it starts. Nobody is there then to fill in what is missing, so everything it needs goes here, in the user's own language and words. Their request, never your reading of it."),time:n.string().nullish().describe('Starts at this time of day, 24-hour "HH:MM" in the user\'s own time, on `days`. Give this or `everyHours`, never both.'),days:n.array(n.number().int().min(1).max(7)).nullish().describe("With `time`: the days it starts, 1 Monday to 7 Sunday. Omit for every day."),everyHours:n.number().int().nullish().describe(`Starts again this many hours after it last started, ${r.ROUTINE.minHours} at least. Give this or \`time\`, never both.`),enabled:n.boolean().nullish().describe("With change: false switches it off without deleting it, true back on.")})};function p(e){let t=e.runs[0];return{id:e.id,label:e.label,bot:e.bot,when:(0,h.scheduleText)(e.schedule),enabled:e.enabled,...e.enabled?{next:(0,c.whenOf)((0,c.toDate)(e.nextRunAt))}:{},request:(0,u.clip)(e.request,300),...t?{lastRun:{thread:t.id,status:t.status,at:(0,c.whenOf)((0,c.toDate)(t.updatedAt)),...t.outcome?{outcome:(0,u.clip)(t.outcome,200)}:{}}}:{}}}let g=e=>{if((0,d.isPublicError)(e))return e.message;throw e};async function w(e){let t=(await (0,l.listRoutines)()).map(e=>`"${e.label}"`);return t.length?e?`There is no single routine called "${e}". The routines are: ${t.join(", ")}. Call again with one of those, or its ID.`:`Name the routine. The routines are: ${t.join(", ")}.`:"There are no routines yet."}e.s(["createRoutineTools",0,function(){return{[o.TOOL_NAMES.routine]:(0,i.tool)({description:f.description,inputSchema:f.parameters,execute:async e=>{if("list"===e.action)return{routines:(await (0,l.listRoutines)()).map(p)};let t=function(e){if(e.time&&e.everyHours)return"Give `time` or `everyHours`, not both.";let t=e.time?{kind:"daily",time:e.time,days:e.days?.length?e.days:[1,2,3,4,5,6,7]}:e.everyHours?{kind:"every",hours:e.everyHours}:null;if(!t)return null;let a=h.RoutineScheduleSchema.safeParse(t);return a.success?a.data:a.error.issues[0].message}(e);if("string"==typeof t)return t;if("create"===e.action){if(!t)return"Say when it starts: `time` (with `days`), or `everyHours`.";let a=h.RoutineInputSchema.safeParse({bot:e.bot??"",label:e.label??"",request:e.request??"",schedule:t});if(!a.success)return`${a.error.issues[0].message}. Nothing was made — call again with bot, label, request and when.`;let i=(await (0,s.listJobBots)()).map(e=>e.name);if(!i.some(e=>e.toLowerCase()===a.data.bot.toLowerCase()))return`There is no bot called "${a.data.bot}". The bots are: ${i.join(", ")}. Nothing was made — call again with one of those.`;let n=await (0,l.createRoutine)(a.data).catch(g);if("string"==typeof n)return n;let r=await (0,s.readKeepWorkingOn)()?"":" As things are set, it starts only while the app is open in a tab: a time that passes with it closed starts once when it is opened again. Settings › Routines has the switch that lets work go on with the app closed.";return{...p(n),note:`${n.bot} starts "${n.label}" by itself, ${(0,h.scheduleText)(n.schedule)}, first ${(0,c.whenOf)((0,c.toDate)(n.nextRunAt))}. Each start is a thread of its own, and its result reaches the conversation like any thread's.${r}`}}let a=e.routine?await (0,l.resolveRoutine)(e.routine):null;if(!a)return await w(e.routine);if("delete"===e.action)return await (0,l.deleteRoutine)(a.id),`"${a.label}" is deleted and starts no more. The threads it already opened stay.`;let i={...e.bot?{bot:e.bot}:{},...e.label?.trim()?{label:e.label.trim()}:{},...e.request?.trim()?{request:e.request.trim()}:{},...t?{schedule:t}:{},..."boolean"==typeof e.enabled?{enabled:e.enabled}:{}};if(!Object.keys(i).length)return"Nothing to change was given: bot, label, request, when, or enabled.";let n=await (0,l.updateRoutine)(a.id,i).catch(g);return"string"==typeof n?n:n?p(n):await w(e.routine)}})}}]),a()}catch(e){a(e)}},!1),489956,e=>e.a(async(t,a)=>{try{var i=e.i(68356),n=e.i(847841),r=e.i(105249),o=e.i(687388),s=e.i(353885),l=e.i(279041),h=e.i(340698),c=e.i(41444),d=t([h]);[h]=d.then?(await d)():d;let w=`Answer the question from the web. Lead with the answer, then
7
+ The line stays open until this runs, and drops once the goodbye being said is over.`,parameters:a.object({})},o=(0,t.tool)({description:r.description,inputSchema:r.parameters}),s={description:"Show a short word on your face for a few seconds.",parameters:a.object({text:a.string().describe(`Up to 8 characters: A-Z, 0-9, space and ${n.join(" ")}.`)})},l=(0,t.tool)({description:s.description,inputSchema:s.parameters});e.s(["callTools",0,function(){return{[i.TOOL_NAMES.end_call]:o,[i.TOOL_NAMES.emote]:l}}],349047)},170801,e=>{"use strict";var t=e.i(912714),a=e.i(847841),i=e.i(105249),n=e.i(687388),r=e.i(353885),o=e.i(629668),s=e.i(786025);e.s(["createLookTool",0,function(){return{[r.TOOL_NAMES.look_at]:(0,a.tool)({description:"See an image file yourself: a screenshot you took, a picture the user handed over, a chart you made. For what a picture shows — text files are read in the shell.",inputSchema:i.default.object({path:i.default.string().describe("Workspace-relative path to a png, jpg, webp or gif.")}),execute:async({path:e})=>{let a=await (0,s.insideWorkspace)(e.trim()),i=a?await (0,t.stat)(a).catch(()=>null):null;return a&&i?.isFile()?"image"!==(0,o.viewKindOf)(e)?`${e} is not an image. Read it in the shell instead.`:i.size>n.LOOK.maxBytes?`${e} is ${Math.ceil(i.size/1024/1024)} MB, over the ${n.LOOK.maxBytes/1024/1024} MB one look takes. Make a smaller copy in the shell first (on a Mac: sips -Z 1600 in.png --out out.png), then look at that.`:{path:e.trim(),mediaType:(0,o.mimeOf)(e),bytes:i.size}:`There is no file at ${e}. Give the path from the workspace root, as \`ls\` shows it.`},toModelOutput:async({output:e})=>{if("string"==typeof e)return{type:"text",value:e};let a=await (0,s.insideWorkspace)(e.path),i=a?await (0,t.readFile)(a).catch(()=>null):null;return i?{type:"content",value:[{type:"text",text:`${e.path}, as an image:`},{type:"file",mediaType:e.mediaType,data:{type:"data",data:i.toString("base64")}}]}:{type:"text",value:`${e.path} is no longer there.`}}})}}])},926435,e=>e.a(async(t,a)=>{try{var i=e.i(847841),n=e.i(907855),r=e.i(353885),o=e.i(148831),s=e.i(786025),l=e.i(660948),h=t([o,l]);[o,l]=h.then?(await h)():h;let u={[r.TOOL_NAMES.tool_search]:{description:`Return the description and exact inputSchema of tools on a connected server, so they can be called with \`${r.TOOL_NAMES.tool_call}\`.`,parameters:n.object({server:n.string().describe("A server name, exactly as the Connected tools section writes it."),tools:n.string().array().describe("Tool names listed under that server. Only the ones you may actually call — schemas are large, and at most 8 come back.")})},[r.TOOL_NAMES.tool_call]:{description:`Run one tool whose definition came back from \`${r.TOOL_NAMES.tool_search}\`.`,parameters:n.object({server:n.string().describe("The server the tool lives on."),tool:n.string().describe("Its name, as search returned it."),args:n.record(n.string(),n.unknown()).nullish().describe("Arguments matching the inputSchema search returned — do not guess. Null when it takes none."),description:n.string().nullish().describe("One short line for the user: what this call is for. Shown on their screen while it runs.")})}},m=(e,t)=>`${e.replace(/[^a-zA-Z0-9]+/g,"_")}__${t.replace(/[^a-zA-Z0-9_-]+/g,"_")}`.slice(0,64);async function c(e,t){let[a,n]=await Promise.all([(0,l.listConnectedToolNames)(),(0,o.findPinnedTools)(e)]),r={},h=(0,s.botArtifacts)(e);for(let e of n){let a=m(e.server,e.name);r[a]||(r[a]=(0,i.tool)({description:e.description??`${e.name} on the ${e.server} server.`,inputSchema:(0,i.jsonSchema)(e.inputSchema??{type:"object",properties:{}}),execute:(a,{abortSignal:i})=>(0,l.callConnectedTool)(t,e.server,e.name,a??void 0,{artifacts:h,abortSignal:i})}))}return a.length>n.length&&Object.assign(r,p(t,h)),r}async function d(e){let t=(await (0,l.listConnectedToolNames)(e)).map(e=>e.name);if(t.length)return`Tools on "${e}": ${t.join(", ")}.`;let a=await (0,l.listConnectedServerNames)();return a.length?`There is no server called "${e}". Connected: ${a.join(", ")}.`:"Nothing is connected."}let p=(e,t)=>({[r.TOOL_NAMES.tool_search]:(0,i.tool)({description:u[r.TOOL_NAMES.tool_search].description,inputSchema:u[r.TOOL_NAMES.tool_search].parameters,execute:async({server:e,tools:t})=>{let a=[...new Set(t.map(e=>e.trim()).filter(Boolean))],i=a.slice(0,8),n=await (0,l.findConnectedSchemas)(e.trim(),i);if(!n.length)return{tools:[],note:await d(e)};let r=i.filter(e=>!n.some(t=>t.name===e)),o=a.slice(8),s=[r.length?`Not on "${e}": ${r.join(", ")}.`:"",o.length?`Only 8 at a time — ask again for: ${o.join(", ")}.`:""].filter(Boolean);return{tools:n,...s.length?{note:s.join(" ")}:{}}}}),[r.TOOL_NAMES.tool_call]:(0,i.tool)({description:u[r.TOOL_NAMES.tool_call].description,inputSchema:u[r.TOOL_NAMES.tool_call].parameters,execute:async({server:a,tool:i,args:n},{abortSignal:r})=>(await (0,l.listConnectedToolNames)(a.trim())).some(e=>e.name===i.trim())?(0,l.callConnectedTool)(e,a.trim(),i.trim(),n??void 0,{artifacts:t,abortSignal:r}):{status:"error",text:await d(a)}})});e.s(["createMcpTools",0,c]),a()}catch(e){a(e)}},!1),770639,e=>e.a(async(t,a)=>{try{var i=e.i(847841),n=e.i(907855),r=e.i(687388),o=e.i(54282),s=e.i(353885),l=e.i(619898),h=e.i(453569),c=e.i(22676),d=t([l,c]);[l,c]=d.then?(await d)():d;let u=h.MEMORY_PATHS.map(e=>e.path.endsWith("/")?`${e.path}<name>`:e.path).join(", "),m=e=>({...e,facts:e.facts.map(({saidAt:e,...t})=>e?{...t,said:(0,o.saidStamp)(e)}:t),factCount:e.facts.length}),p=e=>"user"===e?"Typed on the screen — there is no conversation behind it.":"bot"===e?"Saved by a bot during a job — there is no conversation behind it.":"The conversation it was saved in is not kept.",w=e=>e>r.MEMORY_LIMITS.factsPerNote?` This note now holds ${e} facts, past the ${r.MEMORY_LIMITS.factsPerNote} one note holds well. Ask the user which of it is no longer true and delete what they name.`:"";e.s(["createMemoryTools",0,(e,t=null,{countReads:a=!0}={})=>({[s.TOOL_NAMES.memory_recall]:(0,i.tool)({description:"Open one note from the listing, whole.",inputSchema:n.object({path:n.string().describe("Exactly as the listing writes it — the path, or one of the names in quotes after it.")}),execute:async({path:e})=>{let{notes:t}=await (0,l.readNotes)([e],{touch:a}),i=t[0];if(!i)return{note:`Nothing on the listing called ${e.trim()}.`};let n=w(i.facts.length);return n?{...m(i),note:n.trim()}:m(i)}}),[s.TOOL_NAMES.memory_remember]:(0,i.tool)({description:"Write to one note: facts, and the line the listing shows for it. The path is the key — a path not on the listing is created (with at least one fact), one that is gets amended.",inputSchema:n.object({path:n.string().describe("The group this note is found by — the person, project or topic its facts are about. Exactly as the listing writes it, or a new path following the same convention. A fact goes under the one note it is about; other notes name it rather than repeat it."),facts:n.object({text:n.string().describe('One statement that stands on its own later — a date as a date, never "next week".'),replaces:n.number().int().nullish().describe(`The id of the fact this replaces — from this note as handed back here or by \`${s.TOOL_NAMES.memory_recall}\`. Null if this is new. A fact that stopped being true is replaced rather than deleted, and so is a note saying the same thing twice: replacing keeps what changed on the record, deleting does not.`),alwaysLoad:n.boolean().nullish().describe(`True carries this line into every call's instructions without opening its note — for what every call needs before any note is opened: what to call them, their language and register. At most ${r.MEMORY_LIMITS.carried}. Null leaves it; false makes a carried line an ordinary fact.`)}).array().nullish().describe("What to write under this note. Send everything that came up at once: one call is one pause in the conversation, three calls are three. Null when only naming it."),description:n.string().nullish().describe(`One line saying what this note holds, so the listing alone tells which facts are inside. Give it for a new note, and again with new facts: rewritten from the current line and the new facts together, so it covers the whole note rather than only what was added. Null leaves it; ${h.MEMORY_ALWAYS_LISTED.join(", ")} keep their own line.`),aliases:n.string().array().nullish().describe('What the user calls this note out loud, in the language they say it — the words they would use to ask for it, not the facts inside. A note at people/partner might be "my partner" and their first name. Replaces the set it has, so send the whole set. Null leaves it.')}),execute:async a=>{let i=a.path.trim(),n=await (0,l.resolveNotePath)(i),o=a.aliases??null,s=n??i,c=(0,h.isAlwaysListed)(s)?(0,h.appNoteLine)(s):a.description?.trim()||null,d=a.facts??[];if(!d.length&&!c&&!o)return{note:"Nothing to write: send facts, a line, names, or any of them."};if(!n&&!(0,h.isMemoryPath)(i))return{note:`Nothing was saved: "${i}" is not a path this listing can carry. Write it again under one of ${u}.`};if(!n&&!d.length)return{note:`Nothing on the listing called ${i}. A note comes into being with a fact — send at least one.`};let p=await (0,l.writeNotes)([{path:s,description:c,aliases:o,facts:d}],e,t),f=p.unnamed.length?` ${p.unnamed[0]} is new and has no line yet — the listing shows its first fact instead. Call again with \`description\` (one line about what it is) and \`aliases\` (the names they say for it).`:"",g=p.notLoaded.length?` All ${r.MEMORY_LIMITS.carried} carried lines are taken, so ${p.notLoaded.map(e=>`"${e}"`).join(", ")} saved as an ordinary fact. Say which carried line you would drop for it and let them choose.`:"",y=m(p.notes[0]),b=n&&d.length&&!c?` Its line still reads "${y.description}"; if that no longer says what the note holds, send \`description\`.`:"";return{...y,note:`Saved. The listing in your instructions is from when this session opened and will not show this until the next one — the note below is current.${f}${g}${b}${w(y.factCount)}`}}}),[s.TOOL_NAMES.memory_conversation]:(0,i.tool)({description:"Open the conversation a fact was saved in, whole: what each side said, and which tools were used.",inputSchema:n.object({factId:n.number().int().describe("The id that came with the fact when its note was opened."),page:n.number().int().min(1).nullish().describe(`${r.MEMORY_CONVERSATION_PAGE} turns a page, oldest first. Null for the first.`)}),execute:async({factId:e,page:a})=>{let i=await (0,l.findFactCall)(e);if(!i)return{note:`No fact with id ${e}.`};if(!i.callId)return{note:p(i.source)};if(i.callId===t)return{note:"Said in this call — it is the conversation you are in."};let n=a??1,s=await (0,c.readCallConversation)(i.callId,n,r.MEMORY_CONVERSATION_PAGE);if(!s)return{note:p(i.source)};let h=Math.max(1,Math.ceil(s.total/r.MEMORY_CONVERSATION_PAGE));return n>h?{note:`That conversation has ${h} page${h>1?"s":""}.`}:{when:(0,o.callStamp)(s.startedAt),page:n,pages:h,conversation:(0,o.conversationLines)(s.turns)}}}),[s.TOOL_NAMES.memory_forget]:(0,i.tool)({description:"Delete facts for good.",inputSchema:n.object({factIds:n.number().int().array().min(1).describe("The ids that came with the facts when their notes were opened — every one to delete, in one call.")}),execute:async({factIds:e})=>{let t=[],a=[],i=new Set;for(let n of new Set(e)){let e=await (0,l.forgetFactById)(n);if(!e){t.push(n);continue}e.noteGone?(i.delete(e.path),a.push(e.path)):i.add(e.path)}if(!a.length&&!i.size)return{note:`No fact with id ${t.join(", ")}. Nothing was deleted.`};let n=["Deleted for good. The listing in your instructions is from when this session opened and still shows it that way until the next one.",1===a.length?`That was the last fact under ${a[0]}, so the note went with it.`:a.length?`That was the last of ${a.join(", ")}, so those notes went with them.`:"",t.length?`No fact with id ${t.join(", ")}, so those were skipped.`:""].filter(Boolean).join(" ");if(!i.size)return{note:n};let{notes:r}=await (0,l.readNotes)([...i],{touch:!1});return{notes:r.map(m),note:n}}})})]),a()}catch(e){a(e)}},!1),418919,e=>e.a(async(t,a)=>{try{var i=e.i(847841),n=e.i(907855),r=e.i(687388),o=e.i(353885),s=e.i(265143),l=e.i(963219),h=e.i(473139),c=e.i(704161),d=e.i(53748),u=e.i(41444),m=t([s,l]);[s,l]=m.then?(await m)():m;let f={description:`Routines: work that starts by itself, each one a bot, the work and a time — once at a moment, a time of day on chosen days, or every few hours. List them, make one, change one, or delete one. Every start opens a thread like one started by hand; its result reaches the conversation the same way. At most ${r.ROUTINE.max} exist.`,parameters:n.object({action:n.enum(["list","create","change","delete"]),routine:n.string().nullish().describe("With change or delete: the routine, by its name or ID."),bot:n.string().nullish().describe("With create: a name from the bot list. With change: a new bot."),label:n.string().nullish().describe("With create: two or three words naming it, in the user's language. It names every thread the routine opens, on screen and out loud."),request:n.string().nullish().describe("With create: the whole of the work, handed to the bot as written every time it starts. Nobody is there then to fill in what is missing, so everything it needs goes here, in the user's own language and words. Their request, never your reading of it."),at:n.string().nullish().describe('Starts once, at this moment, "YYYY-MM-DD HH:MM" in the user\'s own time, then switches itself off. Count "in an hour" or "tomorrow at eight" from **Now**. Give one of `at`, `time` or `everyHours`.'),time:n.string().nullish().describe('Starts at this time of day, 24-hour "HH:MM" in the user\'s own time, on `days`. Give one of `at`, `time` or `everyHours`.'),days:n.array(n.number().int().min(1).max(7)).nullish().describe("With `time`: the days it starts, 1 Monday to 7 Sunday. Omit for every day."),everyHours:n.number().int().nullish().describe(`Starts again this many hours after it last started, ${r.ROUTINE.minHours} at least. Give one of \`at\`, \`time\` or \`everyHours\`.`),enabled:n.boolean().nullish().describe("With change: false switches it off without deleting it, true back on.")})};function p(e){let t=e.runs[0];return{id:e.id,label:e.label,bot:e.bot,when:(0,h.scheduleText)(e.schedule),enabled:e.enabled,...e.enabled?{next:(0,c.whenOf)((0,c.toDate)(e.nextRunAt))}:{},request:(0,u.clip)(e.request,300),...t?{lastRun:{thread:t.id,status:t.status,at:(0,c.whenOf)((0,c.toDate)(t.updatedAt)),...t.outcome?{outcome:(0,u.clip)(t.outcome,200)}:{}}}:{}}}let g=e=>{if((0,d.isPublicError)(e))return e.message;throw e};async function w(e){let t=(await (0,l.listRoutines)()).map(e=>`"${e.label}"`);return t.length?e?`There is no single routine called "${e}". The routines are: ${t.join(", ")}. Call again with one of those, or its ID.`:`Name the routine. The routines are: ${t.join(", ")}.`:"There are no routines yet."}e.s(["createRoutineTools",0,function(){return{[o.TOOL_NAMES.routine]:(0,i.tool)({description:f.description,inputSchema:f.parameters,execute:async e=>{if("list"===e.action)return{routines:(await (0,l.listRoutines)()).map(p)};let t=function(e){if([e.at,e.time,e.everyHours].filter(Boolean).length>1)return"Give one of `at`, `time` or `everyHours`, not two.";let t=e.at?{kind:"once",at:e.at}:e.time?{kind:"daily",time:e.time,days:e.days?.length?e.days:[1,2,3,4,5,6,7]}:e.everyHours?{kind:"every",hours:e.everyHours}:null;if(!t)return null;let a=h.RoutineScheduleSchema.safeParse(t);return a.success?a.data:a.error.issues[0].message}(e);if("string"==typeof t)return t;if("create"===e.action){if(!t)return"Say when it starts: `at`, `time` (with `days`), or `everyHours`.";let a=h.RoutineInputSchema.safeParse({bot:e.bot??"",label:e.label??"",request:e.request??"",schedule:t});if(!a.success)return`${a.error.issues[0].message}. Nothing was made — call again with bot, label, request and when.`;let i=(await (0,s.listJobBots)()).map(e=>e.name);if(!i.some(e=>e.toLowerCase()===a.data.bot.toLowerCase()))return`There is no bot called "${a.data.bot}". The bots are: ${i.join(", ")}. Nothing was made — call again with one of those.`;let n=await (0,l.createRoutine)(a.data).catch(g);if("string"==typeof n)return n;let r=await (0,s.readKeepWorkingOn)()?"":" As things are set, it starts only while the app is open in a tab: a time that passes with it closed starts once when it is opened again. Settings › Routines has the switch that lets work go on with the app closed.",o=(0,c.whenOf)((0,c.toDate)(n.nextRunAt));return{...p(n),note:"once"===n.schedule.kind?`${n.bot} starts "${n.label}" once, ${o}, and the routine then switches itself off. The start is a thread of its own, and its result reaches the conversation like any thread's.${r}`:`${n.bot} starts "${n.label}" by itself, ${(0,h.scheduleText)(n.schedule)}, first ${o}. Each start is a thread of its own, and its result reaches the conversation like any thread's.${r}`}}let a=e.routine?await (0,l.resolveRoutine)(e.routine):null;if(!a)return await w(e.routine);if("delete"===e.action)return await (0,l.deleteRoutine)(a.id),`"${a.label}" is deleted and starts no more. The threads it already opened stay.`;let i={...e.bot?{bot:e.bot}:{},...e.label?.trim()?{label:e.label.trim()}:{},...e.request?.trim()?{request:e.request.trim()}:{},...t?{schedule:t}:{},..."boolean"==typeof e.enabled?{enabled:e.enabled}:{}};if(!Object.keys(i).length)return"Nothing to change was given: bot, label, request, when, or enabled.";let n=await (0,l.updateRoutine)(a.id,i).catch(g);return"string"==typeof n?n:n?p(n):await w(e.routine)}})}}]),a()}catch(e){a(e)}},!1),489956,e=>e.a(async(t,a)=>{try{var i=e.i(68356),n=e.i(847841),r=e.i(105249),o=e.i(687388),s=e.i(353885),l=e.i(279041),h=e.i(340698),c=e.i(41444),d=t([h]);[h]=d.then?(await d)():d;let w=`Answer the question from the web. Lead with the answer, then
8
8
  what supports it. Say plainly what you could not find or confirm — do not fill
9
9
  the gap with a guess. Every number carries the date you saw it. Be brief: this
10
10
  is read by another model, not by a person.`,f=r.default.string().describe("What you want to know, as one full question. Put the place and the time in when they matter — the searcher sees nothing but this line.");async function u(e,t,a){let i=await fetch("https://api.exa.ai/search",{method:"POST",signal:a,headers:{"content-type":"application/json","x-api-key":e},body:JSON.stringify({query:t,type:"auto",numResults:o.SEARCH.sources,contents:{text:{maxCharacters:o.SEARCH.excerptChars},livecrawl:"fallback",livecrawlTimeout:5e3}})});if(!i.ok)return{text:`Exa answered ${i.status}: ${(0,c.clip)((await i.text()).trim(),200)}`,sources:[]};let n=(await i.json()).results??[];if(!n.length)return{text:"Nothing came back for that. Try other words, or open the page itself.",sources:[]};let r=n.flatMap(e=>e.url?.trim()?[{url:e.url.trim(),...e.title?.trim()?{title:e.title.trim()}:{}}]:[]);return{text:n.map(e=>{let t=[e.title?.trim(),e.url?.trim()].filter(Boolean).join(" — "),a=e.publishedDate?.slice(0,10);return[a?`${t} \xb7 ${a}`:t,e.text?.trim()].filter(Boolean).join("\n")}).join("\n\n"),sources:r}}async function m(e,t,a){let{text:n,sources:r}=await (0,i.generateText)({model:e.model,tools:e.tools,instructions:w,prompt:t,abortSignal:a}),s=[...new Set(r.flatMap(e=>"url"===e.sourceType?[e.title?`${e.title} — ${e.url}`:e.url]:[]))].slice(0,o.SEARCH.sources);return{text:[n.trim(),s.length?`Sources:
@@ -18,12 +18,12 @@ ${h.segments.map(e=>{var t;let a,i;return`- ${t=e.startSecond,a=Math.floor(t/60)
18
18
  ${h.text.trim()}${c}
19
19
  `));return`${u}
20
20
 
21
- ${await a.fold(h.text,"transcript")}`}})},k=async()=>{let e=await (0,l.resolveMediaRef)("video");if(!e)return null;let t=(0,l.buildVideoModel)(e.ref,e.apiKey);return m({name:h.STUDIO_TOOLS.generate_video,description:"Make a short video and save it as a file in the workspace. Takes minutes. What comes back is its path.",inputSchema:s.default.object({prompt:s.default.string().describe("What happens: the scene, the motion, the camera, the mood. The video model does not see the job or the conversation, so nothing can be left implied."),aspectRatio:s.default.enum(["16:9","9:16"]).nullish().describe("Aspect ratio. Null for 16:9."),seconds:s.default.number().int().min(2).max(10).nullish().describe("Length in seconds, 2 to 10. Null for the provider's default.")}),execute:async({prompt:e,aspectRatio:a,seconds:i},{sandbox:n,artifacts:o,abortSignal:s})=>{let{video:l}=await (0,r.experimental_generateVideo)({model:t,prompt:e,aspectRatio:a??"16:9",duration:i??void 0,abortSignal:s}),h=await w(n,o,p(e,b(l.mediaType,"mp4")),l.uint8Array);return y(h)}})};async function f(){return(await Promise.all([g(T),g(O),g($),g(k)])).filter(e=>null!==e)}async function g(e){try{return await e()}catch(e){return c.logger.warn(`studio: a tool could not be built — ${(0,d.errorToString)(e)}`),null}}e.s(["loadStudio",0,f]),a()}catch(e){a(e)}},!1),660948,e=>e.a(async(t,a)=>{try{var i=e.i(105249),n=e.i(687388),r=e.i(105303),o=e.i(148831),s=e.i(41444),l=e.i(741376),h=t([r,o,l]);async function c(e){let[t,a]=await Promise.all([!e||e===n.STUDIO_SERVER?(0,l.loadStudio)():[],e===n.STUDIO_SERVER?[]:(0,o.listToolNames)(e)]);return[...t.map(e=>({server:n.STUDIO_SERVER,name:e.name})),...a]}[r,o,l]=h.then?(await h)():h;let w=async()=>{let[e,t]=await Promise.all([(0,l.loadStudio)(),(0,o.listServerNames)()]);return[...e.length?[n.STUDIO_SERVER]:[],...t.map(e=>e.name)]};async function d(e,t){if(e===n.STUDIO_SERVER){let e=new Set(t);return(await (0,l.loadStudio)()).filter(t=>e.has(t.name)).map(e=>({name:e.name,description:e.description,inputSchema:i.default.toJSONSchema(e.inputSchema)}))}return(await (0,o.findToolSchemas)(e,t)).map(e=>({name:e.name,description:e.description??null,inputSchema:e.inputSchema??null}))}async function u(e,t,a,i,{artifacts:o,abortSignal:l}){let h=AbortSignal.timeout(n.CONNECTED_TOOL_TIMEOUT_MS),c=l?AbortSignal.any([l,h]):h;try{let r=t===n.STUDIO_SERVER?await m(e,a,i,o,c):await p(t,a,i,c);if("string"!=typeof r)return r;return{status:"ok",text:await e.fold(r,`${t}-${a}`)}}catch(e){if(e instanceof r.McpAuthRequiredError)return{status:"auth_required",server:t,authorizationUrl:e.authorizationUrl};if(h.aborted&&!l?.aborted)return{status:"error",text:`${a} on ${t} gave no answer in ${n.CONNECTED_TOOL_TIMEOUT_MS/6e4} minutes and was given up on.`};return{status:"error",text:(0,s.errorToString)(e)}}}async function m(e,t,a,i,r){let o=(await (0,l.loadStudio)()).find(e=>e.name===t);if(!o)throw Error(`"${t}" is not in the ${n.STUDIO_SERVER} right now — the key that runs it is gone.`);return o.execute(a??{},{sandbox:e,artifacts:i,abortSignal:r})}async function p(e,t,a,i){let n=function(e){let t=e??{},a=!0===t.isError;if(!Array.isArray(t.content)){let e=void 0===t.toolResult?"":"string"==typeof t.toolResult?t.toolResult:JSON.stringify(t.toolResult);return{status:a?"error":"ok",text:e||f(a)}}let i=t.content.map(e=>"text"===e.type&&"string"==typeof e.text?e.text:`[${e.type}${e.mimeType?` ${e.mimeType}`:""} — not shown]`).join("\n").trim();return{status:a?"error":"ok",text:i||f(a)}}(await r.mcpManager.callTool(e,t,a,i));return"ok"===n.status?n.text:n}let f=e=>e?"The tool failed without a message.":"Done.";e.s(["callConnectedTool",0,u,"findConnectedSchemas",0,d,"listConnectedServerNames",0,w,"listConnectedToolNames",0,c]),a()}catch(e){a(e)}},!1),123203,e=>{"use strict";var t=e.i(750227),a=e.i(847841),i=e.i(105249),n=e.i(687388),r=e.i(353885),o=e.i(393189),s=e.i(786025);let l=`## The shell here
21
+ ${await a.fold(h.text,"transcript")}`}})},_=async()=>{let e=await (0,l.resolveMediaRef)("video");if(!e)return null;let t=(0,l.buildVideoModel)(e.ref,e.apiKey);return m({name:h.STUDIO_TOOLS.generate_video,description:"Make a short video and save it as a file in the workspace. Takes minutes. What comes back is its path.",inputSchema:s.default.object({prompt:s.default.string().describe("What happens: the scene, the motion, the camera, the mood. The video model does not see the job or the conversation, so nothing can be left implied."),aspectRatio:s.default.enum(["16:9","9:16"]).nullish().describe("Aspect ratio. Null for 16:9."),seconds:s.default.number().int().min(2).max(10).nullish().describe("Length in seconds, 2 to 10. Null for the provider's default.")}),execute:async({prompt:e,aspectRatio:a,seconds:i},{sandbox:n,artifacts:o,abortSignal:s})=>{let{video:l}=await (0,r.experimental_generateVideo)({model:t,prompt:e,aspectRatio:a??"16:9",duration:i??void 0,abortSignal:s}),h=await w(n,o,p(e,b(l.mediaType,"mp4")),l.uint8Array);return y(h)}})};async function f(){return(await Promise.all([g(T),g(O),g($),g(_)])).filter(e=>null!==e)}async function g(e){try{return await e()}catch(e){return c.logger.warn(`studio: a tool could not be built — ${(0,d.errorToString)(e)}`),null}}e.s(["loadStudio",0,f]),a()}catch(e){a(e)}},!1),660948,e=>e.a(async(t,a)=>{try{var i=e.i(105249),n=e.i(687388),r=e.i(105303),o=e.i(148831),s=e.i(41444),l=e.i(741376),h=t([r,o,l]);async function c(e){let[t,a]=await Promise.all([!e||e===n.STUDIO_SERVER?(0,l.loadStudio)():[],e===n.STUDIO_SERVER?[]:(0,o.listToolNames)(e)]);return[...t.map(e=>({server:n.STUDIO_SERVER,name:e.name})),...a]}[r,o,l]=h.then?(await h)():h;let w=async()=>{let[e,t]=await Promise.all([(0,l.loadStudio)(),(0,o.listServerNames)()]);return[...e.length?[n.STUDIO_SERVER]:[],...t.map(e=>e.name)]};async function d(e,t){if(e===n.STUDIO_SERVER){let e=new Set(t);return(await (0,l.loadStudio)()).filter(t=>e.has(t.name)).map(e=>({name:e.name,description:e.description,inputSchema:i.default.toJSONSchema(e.inputSchema)}))}return(await (0,o.findToolSchemas)(e,t)).map(e=>({name:e.name,description:e.description??null,inputSchema:e.inputSchema??null}))}async function u(e,t,a,i,{artifacts:o,abortSignal:l}){let h=AbortSignal.timeout(n.CONNECTED_TOOL_TIMEOUT_MS),c=l?AbortSignal.any([l,h]):h;try{let r=t===n.STUDIO_SERVER?await m(e,a,i,o,c):await p(t,a,i,c);if("string"!=typeof r)return r;return{status:"ok",text:await e.fold(r,`${t}-${a}`)}}catch(e){if(e instanceof r.McpAuthRequiredError)return{status:"auth_required",server:t,authorizationUrl:e.authorizationUrl};if(h.aborted&&!l?.aborted)return{status:"error",text:`${a} on ${t} gave no answer in ${n.CONNECTED_TOOL_TIMEOUT_MS/6e4} minutes and was given up on.`};return{status:"error",text:(0,s.errorToString)(e)}}}async function m(e,t,a,i,r){let o=(await (0,l.loadStudio)()).find(e=>e.name===t);if(!o)throw Error(`"${t}" is not in the ${n.STUDIO_SERVER} right now — the key that runs it is gone.`);return o.execute(a??{},{sandbox:e,artifacts:i,abortSignal:r})}async function p(e,t,a,i){let n=function(e){let t=e??{},a=!0===t.isError;if(!Array.isArray(t.content)){let e=void 0===t.toolResult?"":"string"==typeof t.toolResult?t.toolResult:JSON.stringify(t.toolResult);return{status:a?"error":"ok",text:e||f(a)}}let i=t.content.map(e=>"text"===e.type&&"string"==typeof e.text?e.text:`[${e.type}${e.mimeType?` ${e.mimeType}`:""} — not shown]`).join("\n").trim();return{status:a?"error":"ok",text:i||f(a)}}(await r.mcpManager.callTool(e,t,a,i));return"ok"===n.status?n.text:n}let f=e=>e?"The tool failed without a message.":"Done.";e.s(["callConnectedTool",0,u,"findConnectedSchemas",0,d,"listConnectedServerNames",0,w,"listConnectedToolNames",0,c]),a()}catch(e){a(e)}},!1),123203,e=>{"use strict";var t=e.i(750227),a=e.i(847841),i=e.i(105249),n=e.i(687388),r=e.i(353885),o=e.i(393189),s=e.i(786025);let l=`## The shell here
22
22
 
23
23
  Every command is a new shell: \`cd\`, exported variables and an activated venv are gone by the next one — chain what depends on the last step into a single command.
24
24
 
25
25
  Nothing is watching it. A command that stops to ask never gets an answer and is killed after ${n.EXEC_TIMEOUT_MS/1e3}s, so pass the flag that skips the question (\`-y\`, \`--yes\`, \`--no-input\`), and send anything genuinely long to the background with its output redirected to a file.
26
26
 
27
- Keys are not in the environment: every variable named like a key, a token or a secret is removed before the shell starts. An empty one is not an unset one — say which it was, and ask for what a command needs.`;e.s(["createWorkspaceTools",0,(e,n)=>{let h=!0===n.guide,c=async e=>{let t=n.bot;if(!t)return{result:await e(),memory:null};let a=await (0,o.holdBotMemory)(t);return{result:await e(),memory:await (0,o.keepBotMemory)(t,a)}},d=(0,a.tool)({description:"Run a bash command.",inputSchema:i.default.object({command:i.default.string(),description:i.default.string().nullish().describe("One short line for the user: what this command does and why. Shown on their screen while it runs — not a restatement of the command.")}),execute:async({command:t},{abortSignal:a})=>{let{result:i,memory:r}=await c(()=>e.exec(t,{signal:a,env:n.env,timeoutMs:n.timeoutMs})),o=r?{...i,memory:r}:i;return h?(h=!1,{...o,guide:l}):o}});if(!n.write)return{[r.TOOL_NAMES.bash]:d};let u=(0,a.tool)({description:"Write a whole file — what was there is gone. Parent directories are created.",inputSchema:i.default.object({path:i.default.string().describe("Relative to the working directory — under one of its folders — or absolute"),content:i.default.string(),description:i.default.string().nullish().describe("One short line for the user: what this file is. Shown on their screen next to the path.")}),execute:async({path:a,content:i})=>{let r,o=e.resolve(a),l=(0,s.writeRefusal)(o,n.bot);if(l)return l;let{memory:h}=await c(()=>e.writeFile(a,i));return h??`Wrote ${(r=(0,t.relative)(e.cwd,o))&&!r.startsWith("..")?r:o} (${i.split("\n").length} lines)`}});return{[r.TOOL_NAMES.bash]:d,[r.TOOL_NAMES.write_file]:u}}])},636882,e=>{"use strict";e.i(912714);var t=e.i(750227),a=e.i(687388),i=e.i(786025),n=e.i(640911),r=e.i(41444),o=e.i(696968);let s=(0,t.join)(a.APP_DIR,a.PATHS.skills.default),l=(0,t.join)(a.DATA_DIR,a.PATHS.skills.custom);async function h(e,t){let a=[],i=new Set;for(let s of t){let t;try{t=await e.readdir(s,{withFileTypes:!0})}catch{continue}for(let l of t){let t,h;if(!l.isDirectory())continue;let c=`${s}/${l.name}`,d=`${c}/SKILL.md`;try{t=await e.readFile(d,"utf-8")}catch{continue}try{h=(0,o.parseFrontmatter)(t)}catch(e){n.logger.warn(`skill ${c}: SKILL.md front matter did not load — ${(0,r.errorToString)(e)}`);continue}!i.has(h.name)&&(i.add(h.name),h.disabled||a.push({name:h.name,description:h.description,path:c}))}}return a}e.s(["loadSkills",0,(e,n)=>h(e,n?[s,(0,t.join)(i.WORKSPACE,(0,i.botFolder)(n),a.PATHS.skills.own),l]:[s,l])])},388439,e=>{"use strict";let t=/[\u1100-\u11ff\u3040-\u30ff\u3130-\u318f\u4e00-\u9fff\uac00-\ud7af]/;function a(e){let a=0,i=0;for(let n of e)t.test(n)?a+=1:i+=1;return Math.ceil(a/1.3+i/4)}e.s(["estimateTokens",0,a,"sectionTokens",0,function(e){return e.split(/\n(?=## )/).map(e=>({name:e.startsWith("## ")?e.slice(3,e.indexOf("\n")):"identity",tokens:a(e)})).sort((e,t)=>t.tokens-e.tokens)}])}];
27
+ Keys are not in the environment: every variable named like a key, a token or a secret is removed before the shell starts. An empty one is not an unset one — say which it was, and ask for what a command needs.`;e.s(["createWorkspaceTools",0,(e,n)=>{let h=!0===n.guide,c=async e=>{let t=n.bot;if(!t)return{result:await e(),memory:null};let a=await (0,o.holdBotMemory)(t);return{result:await e(),memory:await (0,o.keepBotMemory)(t,a)}},d=(0,a.tool)({description:"Run a bash command.",inputSchema:i.default.object({command:i.default.string(),description:i.default.string().nullish().describe("One short line for the user: what this command does and why. Shown on their screen while it runs — not a restatement of the command.")}),execute:async({command:t},{abortSignal:a})=>{let{result:i,memory:r}=await c(()=>e.exec(t,{signal:a,env:n.env,timeoutMs:n.timeoutMs})),o=r?{...i,memory:r}:i;return h?(h=!1,{...o,guide:l}):o}});if(!n.write)return{[r.TOOL_NAMES.bash]:d};let u=(0,a.tool)({description:"Write a whole file — what was there is gone. Parent directories are created.",inputSchema:i.default.object({path:i.default.string().describe("Relative to the working directory — under one of its folders — or absolute"),content:i.default.string(),description:i.default.string().nullish().describe("One short line for the user: what this file is. Shown on their screen next to the path.")}),execute:async({path:a,content:i})=>{let r,o=e.resolve(a),l=(0,s.writeRefusal)(o,n.bot);if(l)return l;let{memory:h}=await c(()=>e.writeFile(a,i));return h??`Wrote ${(r=(0,t.relative)(e.cwd,o))&&!r.startsWith("..")?r:o} (${i.split("\n").length} lines)`}});return{[r.TOOL_NAMES.bash]:d,[r.TOOL_NAMES.write_file]:u}}])},636882,e=>{"use strict";e.i(912714);var t=e.i(750227),a=e.i(687388),i=e.i(786025),n=e.i(640911),r=e.i(41444),o=e.i(696968);let s=(0,t.join)(a.APP_DIR,a.PATHS.skills.default),l=(0,t.join)(a.DATA_DIR,a.PATHS.skills.custom);async function h(e,t){let a=[],i=new Set;for(let s of t){let t;try{t=await e.readdir(s,{withFileTypes:!0})}catch{continue}for(let l of t){let t,h;if(!l.isDirectory())continue;let c=`${s}/${l.name}`,d=`${c}/SKILL.md`;try{t=await e.readFile(d,"utf-8")}catch{continue}try{h=(0,o.parseFrontmatter)(t)}catch(e){n.logger.warn(`skill ${c}: SKILL.md front matter did not load — ${(0,r.errorToString)(e)}`);continue}!(!(0,o.runsHere)(h)||i.has(h.name))&&(i.add(h.name),h.disabled||a.push({name:h.name,description:h.description,path:c}))}}return a}e.s(["loadSkills",0,(e,n)=>h(e,n?[s,(0,t.join)(i.WORKSPACE,(0,i.botFolder)(n),a.PATHS.skills.own),l]:[s,l])])},388439,e=>{"use strict";let t=/[\u1100-\u11ff\u3040-\u30ff\u3130-\u318f\u4e00-\u9fff\uac00-\ud7af]/;function a(e){let a=0,i=0;for(let n of e)t.test(n)?a+=1:i+=1;return Math.ceil(a/1.3+i/4)}e.s(["estimateTokens",0,a,"sectionTokens",0,function(e){return e.split(/\n(?=## )/).map(e=>({name:e.startsWith("## ")?e.slice(3,e.indexOf("\n")):"identity",tokens:a(e)})).sort((e,t)=>t.tokens-e.tokens)}])}];
28
28
 
29
29
  //# sourceMappingURL=_0awtznl._.js.map
@@ -1,5 +1,5 @@
1
1
  module.exports=[380690,e=>{"use strict";let t,a,r,n,i,o;var l,s=e.i(687388),u=e.i(640911);let d={threads:!0,routines:!0,memory:!0,mcp:!0,config:!0,reach:!0,signins:!0},c=globalThis,p=c.__appEvents??=(t=new Set,{emit(e){for(let a of[...t])try{a(e)}catch(e){console.error("event listener failed",e)}},subscribe:e=>(t.add(e),()=>{t.delete(e)})}),h=c.__presence??=(l=s.BROWSER_GONE_MS,a=!1,r=null,n=new Set,i=new Set,o=e=>{for(let t of[...e])try{t()}catch(e){console.error("presence listener failed",e)}},{get watching(){return a},track(e){if(e>0){r&&clearTimeout(r),r=null,a||(a=!0,o(i));return}!r&&a&&(r=setTimeout(()=>{r=null,a=!1,o(n)},l))},onGone:e=>(n.add(e),()=>n.delete(e)),onBack:e=>(i.add(e),()=>i.delete(e))}),m=c.__appEventStream??=function(e,t={}){let a=new TextEncoder,r=t.heartbeatMs??2e4,n=0;return{respond:(i,o)=>{let l=()=>{};return new Response(new ReadableStream({async start(s){let d=!1,c=new Map,p=[],h=e=>{if(!d)try{s.enqueue(a.encode(e))}catch{l()}},m=e=>h(`data: ${JSON.stringify(e)}
2
2
 
3
- `),f=e=>{let a=t.coalesce?.keyOf(e)??null;if(null===a)return m(e);let r=c.get(a);r&&clearTimeout(r),c.set(a,setTimeout(()=>{c.delete(a),m(e)},t.coalesce?.ms))},b=e.subscribe(e=>p?p.push(e):f(e)),R=setInterval(()=>h(": ping\n\n"),r);n+=1,t.onWatchers?.(n),l=()=>{if(!d){for(let e of(d=!0,n-=1,t.onWatchers?.(n),b(),clearInterval(R),c.values()))clearTimeout(e);try{s.close()}catch{}}},i.addEventListener("abort",l);try{for(let e of await o?.()??[])m(e)}catch(e){u.logger.error("event stream opening failed",e),l();return}let v=p;for(let e of(p=null,v))f(e)},cancel(){l()}}),{headers:{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-store","X-Accel-Buffering":"no"}})},get watchers(){return n}}}(p,{coalesce:{ms:150,keyOf:e=>e.type in d?e.type:null},onWatchers:h.track}),f=c.__bootId??=crypto.randomUUID();e.s(["BOOT_ID",0,f,"appEventStream",0,m,"appEvents",0,p,"presence",0,h],380690)},548478,e=>e.a(async(t,a)=>{try{var r=e.i(963219),n=e.i(91264),i=t([r]);[r]=i.then?(await i)():i;let o=(0,n.serverRoute)(()=>(0,r.listRoutines)());e.s(["GET",0,o]),a()}catch(e){a(e)}},!1),506088,e=>{"use strict";var t=e.i(747909),a=e.i(174017),r=e.i(996250),n=e.i(759756),i=e.i(561916),o=e.i(174677),l=e.i(869741),s=e.i(316795),u=e.i(487718),d=e.i(995169),c=e.i(47587),p=e.i(666012),h=e.i(570101),m=e.i(626937),f=e.i(10372),b=e.i(193695);e.i(52474);var R=e.i(600220);let v=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/routine/route",pathname:"/api/routine",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/routine/route.ts",nextConfigOutput:"standalone",userland:()=>e.r(548478),...{}}),{workAsyncStorage:g,workUnitAsyncStorage:w,serverHooks:y}=v;async function T(e,t,r){r.requestMeta&&(0,n.setRequestMeta)(e,r.requestMeta),v.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let g="/api/routine/route";g=g.replace(/\/index$/,"")||"/";let w=await v.prepare(e,t,{srcPage:g,multiZoneDraftMode:!1});if(!w)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:y,deploymentId:T,params:E,nextConfig:x,parsedUrl:C,isDraftMode:S,prerenderManifest:A,routerServerContext:N,isOnDemandRevalidate:O,revalidateOnlyGenerated:_,resolvedPathname:D,clientReferenceManifest:I,serverActionsManifest:q}=w,P=(0,l.normalizeAppPath)(g),k=!!(A.dynamicRoutes[P]||A.routes[D]),U=async()=>((null==N?void 0:N.render404)?await N.render404(e,t,C,!1):t.end("This page could not be found"),null);if(k&&!S){let e=!!A.routes[D],t=A.dynamicRoutes[P];if(t&&!1===t.fallback&&!e){if(x.adapterPath)return await U();throw new b.NoFallbackError}}let H=null;!k||v.isDev||S||(H="/index"===(H=D)?"/":H);let M=!0===v.isDev||!k,$=k&&!M;q&&I&&(0,o.setManifestsSingleton)({page:g,clientReferenceManifest:I,serverActionsManifest:q});let B=e.method||"GET",j=(0,i.getTracer)(),L=j.getActiveScopeSpan(),F=!!(null==N?void 0:N.isWrappedByNextServer),G=!!(0,n.getRequestMeta)(e,"minimalMode"),W=(0,n.getRequestMeta)(e,"incrementalCache")||await v.getIncrementalCache(e,x,A,G);null==W||W.resetRequestCache(),globalThis.__incrementalCache=W;let K={params:E,previewProps:A.preview,renderOpts:{experimental:{authInterrupts:!!x.experimental.authInterrupts,useCacheTimeout:x.experimental.useCacheTimeout},cacheComponents:!!x.cacheComponents,validationLevel:x.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:W,hmrRefreshHash:(0,n.getRequestMeta)(e,"hmrRefreshHash"),cacheLifeProfiles:x.cacheLife,staticPageGenerationTimeout:x.staticPageGenerationTimeout,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,r,n)=>v.onRequestError(e,t,r,n,N)},sharedContext:{buildId:y,deploymentId:T}},X=new s.NodeNextRequest(e),V=new s.NodeNextResponse(t),J=u.NextRequestAdapter.fromNodeNextRequest(X,(0,u.signalFromNodeResponse)(t)),z=async({previousCacheEntry:a})=>{try{if(!G&&O&&_&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await v.handle(J,K);e.fetchMetrics=K.renderOpts.fetchMetrics;let i=K.renderOpts.pendingWaitUntil;i&&r.waitUntil&&(r.waitUntil(i),i=void 0);let o=K.renderOpts.collectedTags;if(!k)return await (0,p.sendResponse)(X,V,n,i),null;{let e=await n.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(n.headers);o&&(t[f.NEXT_CACHE_TAGS_HEADER]=o),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=f.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,r=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=f.INFINITE_CACHE?!1!==a&&a>0?x.expireTime:void 0:K.renderOpts.collectedExpire;return{value:{kind:R.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 v.onRequestError(e,t,{routerKind:"App Router",routePath:g,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:O})},!1,N),t}},Z=async(n,o)=>{try{var l,s;let n=await v.handleResponse({req:e,nextConfig:x,cacheKey:H,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:A,isRoutePPREnabled:!1,isOnDemandRevalidate:O,revalidateOnlyGenerated:_,responseGenerator:z,waitUntil:r.waitUntil,isMinimalMode:G});if(!k)return;if((null==n||null==(l=n.value)?void 0:l.kind)!==R.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==n||null==(s=n.value)?void 0:s.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});G||t.setHeader("x-nextjs-cache",O?"REVALIDATED":n.isMiss?"MISS":n.isStale?"STALE":"HIT"),S&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let i=(0,h.fromNodeOutgoingHttpHeaders)(n.value.headers);G&&k||i.delete(f.NEXT_CACHE_TAGS_HEADER),!n.cacheControl||t.getHeader("Cache-Control")||i.get("Cache-Control")||i.set("Cache-Control",(0,m.getCacheControlHeader)(n.cacheControl)),await (0,p.sendResponse)(X,V,new Response(n.value.body,{headers:i,status:n.value.status||200}));return}catch(t){if(t instanceof b.NoFallbackError||await v.onRequestError(e,t,{routerKind:"App Router",routePath:P,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:O})},!1,N),k)throw t;await (0,p.sendResponse)(X,V,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=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 r=a.get("next.route")||P,l=`${B} ${r}`;n.setAttributes({"next.route":r,"http.route":r,"next.span_name":l}),n.updateName(l),o&&o!==n&&(o.setAttribute("http.route",r),o.updateName(l))})()}};if(F&&L)await Z(L,void 0);else{let t=j.getActiveScopeSpan();await j.withPropagatedContext(e.headers,()=>j.trace(d.BaseServerSpan.handleRequest,{spanName:`${B} ${g}`,kind:i.SpanKind.SERVER,attributes:{"http.method":B,"http.target":e.url}},e=>Z(e,t)),void 0,!F)}}e.s(["handler",0,T,"patchFetch",0,function(){return(0,r.patchFetch)({workAsyncStorage:g,workUnitAsyncStorage:w})},"routeModule",0,v,"serverHooks",0,y,"workAsyncStorage",0,g,"workUnitAsyncStorage",0,w])},963219,e=>e.a(async(t,a)=>{try{var r=e.i(260338),n=e.i(349129),i=e.i(875225),o=e.i(380690),l=e.i(687388),s=e.i(528790),u=e.i(613240),d=e.i(265143),c=e.i(53748),p=e.i(473139),h=t([s,d]);[s,d]=h.then?(await h)():h;let T=()=>o.appEvents.emit({type:"routines"});async function m(e,t){return s.database.select({id:u.threadTable.id,status:u.threadTable.status,outcome:u.threadTable.outcome,updatedAt:u.threadTable.updatedAt}).from(u.threadTable).where((0,i.eq)(u.threadTable.routineId,e)).orderBy((0,n.desc)(u.threadTable.createdAt)).limit(t)}let E=async e=>{let{createdAt:t,...a}=e;return{...a,runs:await m(e.id,l.ROUTINE.runsShown)}};async function f(){let e=await s.database.select().from(u.routineTable).orderBy(u.routineTable.createdAt);return Promise.all(e.map(E))}async function b(e){let[t]=await s.database.select().from(u.routineTable).where((0,i.eq)(u.routineTable.id,e));return t?E(t):null}async function R(e){let t=await b(e.trim());if(t)return t;let a=e.trim().toLowerCase(),r=(await f()).filter(e=>e.label.toLowerCase()===a);return 1===r.length?r[0]:null}async function v(e){let t=await (0,d.findJobBot)(e);return(!t||t.disabled)&&(0,c.publicError)("Choose an enabled bot."),t.name}async function g(e){let[{total:t}]=await s.database.select({total:(0,r.count)()}).from(u.routineTable);t>=l.ROUTINE.max&&(0,c.publicError)(`There are already ${l.ROUTINE.max} routines. Delete one to make another.`);let[a]=await s.database.insert(u.routineTable).values({id:crypto.randomUUID(),...e,bot:await v(e.bot),nextRunAt:(0,p.nextRun)(e.schedule,new Date)}).returning();return T(),E(a)}async function w(e,t){let[a]=await s.database.select().from(u.routineTable).where((0,i.eq)(u.routineTable.id,e));if(!a)return null;let r=t.schedule??a.schedule,n=!!t.schedule||t.enabled&&!a.enabled,[o]=await s.database.update(u.routineTable).set({...t,...t.bot?{bot:await v(t.bot)}:{},...n?{nextRunAt:(0,p.nextRun)(r,new Date)}:{}}).where((0,i.eq)(u.routineTable.id,e)).returning();return T(),E(o)}async function y(e){let t=await s.database.delete(u.routineTable).where((0,i.eq)(u.routineTable.id,e)).returning({id:u.routineTable.id});return t.length&&T(),t.length>0}e.s(["createRoutine",0,g,"deleteRoutine",0,y,"listRoutines",0,f,"resolveRoutine",0,R,"updateRoutine",0,w]),a()}catch(e){a(e)}},!1),473139,e=>{"use strict";var t=e.i(105249),a=e.i(687388),r=e.i(704161);let n=t.default.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"A time is HH:MM, 00:00 to 23:59"),i=t.default.discriminatedUnion("kind",[t.default.object({kind:t.default.literal("daily"),time:n,days:t.default.array(t.default.number().int().min(1).max(7)).min(1,"Pick at least one day").transform(e=>[...new Set(e)].sort((e,t)=>e-t))}),t.default.object({kind:t.default.literal("every"),hours:t.default.number().int().min(a.ROUTINE.minHours,`No more often than every ${a.ROUTINE.minHours}h`).max(168)})]),o=t.default.object({bot:t.default.string().trim().min(1,"Pick a bot"),label:t.default.string().trim().min(1,"Give it a name").max(80),request:t.default.string().trim().min(1,"Say what it should do"),schedule:i}),l=t.default.object({id:t.default.string(),status:t.default.enum(["running","waiting","done","cancelled"]),outcome:t.default.string().nullable(),updatedAt:r.DateLikeSchema});o.extend({id:t.default.string(),enabled:t.default.boolean(),nextRunAt:r.DateLikeSchema,runs:t.default.array(l)});let s=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];e.s(["RoutineInputSchema",0,o,"RoutineScheduleSchema",0,i,"nextRun",0,function(e,t){if("every"===e.kind)return new Date(t.getTime()+36e5*e.hours);let[a,r]=e.time.split(":").map(Number);for(let n=0;n<=7;n++){let i=new Date(t);i.setDate(i.getDate()+n),i.setHours(a,r,0,0);let o=0===i.getDay()?7:i.getDay();if(i>t&&e.days.includes(o))return i}return new Date(t.getTime()+864e5)},"scheduleText",0,function(e){if("every"===e.kind)return 1===e.hours?"Every hour":`Every ${e.hours} hours`;let{days:t,time:a}=e;if(7===t.length)return`Daily ${a}`;if(1===t.length)return`${s[t[0]-1]} ${a}`;let r=t.every((e,a)=>0===a||e===t[a-1]+1)?`${s[t[0]-1]}–${s[t.at(-1)-1]}`:t.map(e=>s[e-1]).join(" ");return`Daily ${a} \xb7 ${r}`}])},260338,e=>{"use strict";var t=e.i(518899),a=e.i(844988),r=e.i(156325);e.s(["count",0,function(e){return t.sql`count(${e||t.sql.raw("*")})`.mapWith(Number)},"max",0,function(e){return t.sql`max(${e})`.mapWith((0,a.is)(e,r.Column)?e:String)}])}];
3
+ `),f=e=>{let a=t.coalesce?.keyOf(e)??null;if(null===a)return m(e);let r=c.get(a);r&&clearTimeout(r),c.set(a,setTimeout(()=>{c.delete(a),m(e)},t.coalesce?.ms))},b=e.subscribe(e=>p?p.push(e):f(e)),R=setInterval(()=>h(": ping\n\n"),r);n+=1,t.onWatchers?.(n),l=()=>{if(!d){for(let e of(d=!0,n-=1,t.onWatchers?.(n),b(),clearInterval(R),c.values()))clearTimeout(e);try{s.close()}catch{}}},i.addEventListener("abort",l);try{for(let e of await o?.()??[])m(e)}catch(e){u.logger.error("event stream opening failed",e),l();return}let g=p;for(let e of(p=null,g))f(e)},cancel(){l()}}),{headers:{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-store","X-Accel-Buffering":"no"}})},get watchers(){return n}}}(p,{coalesce:{ms:150,keyOf:e=>e.type in d?e.type:null},onWatchers:h.track}),f=c.__bootId??=crypto.randomUUID();e.s(["BOOT_ID",0,f,"appEventStream",0,m,"appEvents",0,p,"presence",0,h],380690)},548478,e=>e.a(async(t,a)=>{try{var r=e.i(963219),n=e.i(91264),i=t([r]);[r]=i.then?(await i)():i;let o=(0,n.serverRoute)(()=>(0,r.listRoutines)());e.s(["GET",0,o]),a()}catch(e){a(e)}},!1),506088,e=>{"use strict";var t=e.i(747909),a=e.i(174017),r=e.i(996250),n=e.i(759756),i=e.i(561916),o=e.i(174677),l=e.i(869741),s=e.i(316795),u=e.i(487718),d=e.i(995169),c=e.i(47587),p=e.i(666012),h=e.i(570101),m=e.i(626937),f=e.i(10372),b=e.i(193695);e.i(52474);var R=e.i(600220);let g=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/routine/route",pathname:"/api/routine",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/routine/route.ts",nextConfigOutput:"standalone",userland:()=>e.r(548478),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:y}=g;async function T(e,t,r){r.requestMeta&&(0,n.setRequestMeta)(e,r.requestMeta),g.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let v="/api/routine/route";v=v.replace(/\/index$/,"")||"/";let w=await g.prepare(e,t,{srcPage:v,multiZoneDraftMode:!1});if(!w)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:y,deploymentId:T,params:E,nextConfig:x,parsedUrl:C,isDraftMode:S,prerenderManifest:A,routerServerContext:N,isOnDemandRevalidate:O,revalidateOnlyGenerated:D,resolvedPathname:k,clientReferenceManifest:_,serverActionsManifest:I}=w,P=(0,l.normalizeAppPath)(v),q=!!(A.dynamicRoutes[P]||A.routes[k]),M=async()=>((null==N?void 0:N.render404)?await N.render404(e,t,C,!1):t.end("This page could not be found"),null);if(q&&!S){let e=!!A.routes[k],t=A.dynamicRoutes[P];if(t&&!1===t.fallback&&!e){if(x.adapterPath)return await M();throw new b.NoFallbackError}}let H=null;!q||g.isDev||S||(H="/index"===(H=k)?"/":H);let U=!0===g.isDev||!q,$=q&&!U;I&&_&&(0,o.setManifestsSingleton)({page:v,clientReferenceManifest:_,serverActionsManifest:I});let j=e.method||"GET",B=(0,i.getTracer)(),L=B.getActiveScopeSpan(),F=!!(null==N?void 0:N.isWrappedByNextServer),G=!!(0,n.getRequestMeta)(e,"minimalMode"),W=(0,n.getRequestMeta)(e,"incrementalCache")||await g.getIncrementalCache(e,x,A,G);null==W||W.resetRequestCache(),globalThis.__incrementalCache=W;let K={params:E,previewProps:A.preview,renderOpts:{experimental:{authInterrupts:!!x.experimental.authInterrupts,useCacheTimeout:x.experimental.useCacheTimeout},cacheComponents:!!x.cacheComponents,validationLevel:x.experimental.instantInsights.validationLevel,supportsDynamicResponse:U,incrementalCache:W,hmrRefreshHash:(0,n.getRequestMeta)(e,"hmrRefreshHash"),cacheLifeProfiles:x.cacheLife,staticPageGenerationTimeout:x.staticPageGenerationTimeout,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,r,n)=>g.onRequestError(e,t,r,n,N)},sharedContext:{buildId:y,deploymentId:T}},J=new s.NodeNextRequest(e),X=new s.NodeNextResponse(t),Y=u.NextRequestAdapter.fromNodeNextRequest(J,(0,u.signalFromNodeResponse)(t)),V=async({previousCacheEntry:a})=>{try{if(!G&&O&&D&&!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(Y,K);e.fetchMetrics=K.renderOpts.fetchMetrics;let i=K.renderOpts.pendingWaitUntil;i&&r.waitUntil&&(r.waitUntil(i),i=void 0);let o=K.renderOpts.collectedTags;if(!q)return await (0,p.sendResponse)(J,X,n,i),null;{let e=await n.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(n.headers);o&&(t[f.NEXT_CACHE_TAGS_HEADER]=o),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=f.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,r=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=f.INFINITE_CACHE?!1!==a&&a>0?x.expireTime:void 0:K.renderOpts.collectedExpire;return{value:{kind:R.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:v,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:O})},!1,N),t}},z=async(n,o)=>{try{var l,s;let n=await g.handleResponse({req:e,nextConfig:x,cacheKey:H,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:A,isRoutePPREnabled:!1,isOnDemandRevalidate:O,revalidateOnlyGenerated:D,responseGenerator:V,waitUntil:r.waitUntil,isMinimalMode:G});if(!q)return;if((null==n||null==(l=n.value)?void 0:l.kind)!==R.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==n||null==(s=n.value)?void 0:s.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});G||t.setHeader("x-nextjs-cache",O?"REVALIDATED":n.isMiss?"MISS":n.isStale?"STALE":"HIT"),S&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let i=(0,h.fromNodeOutgoingHttpHeaders)(n.value.headers);G&&q||i.delete(f.NEXT_CACHE_TAGS_HEADER),!n.cacheControl||t.getHeader("Cache-Control")||i.get("Cache-Control")||i.set("Cache-Control",(0,m.getCacheControlHeader)(n.cacheControl)),await (0,p.sendResponse)(J,X,new Response(n.value.body,{headers:i,status:n.value.status||200}));return}catch(t){if(t instanceof b.NoFallbackError||await g.onRequestError(e,t,{routerKind:"App Router",routePath:P,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:O})},!1,N),q)throw t;await (0,p.sendResponse)(J,X,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=B.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")||P,l=`${j} ${r}`;n.setAttributes({"next.route":r,"http.route":r,"next.span_name":l}),n.updateName(l),o&&o!==n&&(o.setAttribute("http.route",r),o.updateName(l))})()}};if(F&&L)await z(L,void 0);else{let t=B.getActiveScopeSpan();await B.withPropagatedContext(e.headers,()=>B.trace(d.BaseServerSpan.handleRequest,{spanName:`${j} ${v}`,kind:i.SpanKind.SERVER,attributes:{"http.method":j,"http.target":e.url}},e=>z(e,t)),void 0,!F)}}e.s(["handler",0,T,"patchFetch",0,function(){return(0,r.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})},"routeModule",0,g,"serverHooks",0,y,"workAsyncStorage",0,v,"workUnitAsyncStorage",0,w])},963219,e=>e.a(async(t,a)=>{try{var r=e.i(260338),n=e.i(349129),i=e.i(875225),o=e.i(380690),l=e.i(687388),s=e.i(528790),u=e.i(613240),d=e.i(265143),c=e.i(53748),p=e.i(473139),h=t([s,d]);[s,d]=h.then?(await h)():h;let E=()=>o.appEvents.emit({type:"routines"});async function m(e,t){return s.database.select({id:u.threadTable.id,status:u.threadTable.status,outcome:u.threadTable.outcome,updatedAt:u.threadTable.updatedAt}).from(u.threadTable).where((0,i.eq)(u.threadTable.routineId,e)).orderBy((0,n.desc)(u.threadTable.createdAt)).limit(t)}let x=async e=>{let{createdAt:t,...a}=e;return{...a,runs:await m(e.id,l.ROUTINE.runsShown)}};async function f(){let e=await s.database.select().from(u.routineTable).orderBy(u.routineTable.createdAt);return Promise.all(e.map(x))}async function b(e){let[t]=await s.database.select().from(u.routineTable).where((0,i.eq)(u.routineTable.id,e));return t?x(t):null}async function R(e){let t=await b(e.trim());if(t)return t;let a=e.trim().toLowerCase(),r=(await f()).filter(e=>e.label.toLowerCase()===a);return 1===r.length?r[0]:null}async function g(e){let t=await (0,d.findJobBot)(e);return(!t||t.disabled)&&(0,c.publicError)("Choose an enabled bot."),t.name}function v(e,t){t&&"once"===e.kind&&(0,p.momentOf)(e.at)<=new Date&&(0,c.publicError)("That time has passed. Pick a later one.")}async function w(e){let[{total:t}]=await s.database.select({total:(0,r.count)()}).from(u.routineTable);t>=l.ROUTINE.max&&(0,c.publicError)(`There are already ${l.ROUTINE.max} routines. Delete one to make another.`),v(e.schedule,!0);let[a]=await s.database.insert(u.routineTable).values({id:crypto.randomUUID(),...e,bot:await g(e.bot),nextRunAt:(0,p.nextRun)(e.schedule,new Date)}).returning();return E(),x(a)}async function y(e,t){let[a]=await s.database.select().from(u.routineTable).where((0,i.eq)(u.routineTable.id,e));if(!a)return null;let r=t.schedule??a.schedule,n=!!t.schedule||t.enabled&&!a.enabled;n&&v(r,t.enabled??a.enabled);let[o]=await s.database.update(u.routineTable).set({...t,...t.bot?{bot:await g(t.bot)}:{},...n?{nextRunAt:(0,p.nextRun)(r,new Date)}:{}}).where((0,i.eq)(u.routineTable.id,e)).returning();return E(),x(o)}async function T(e){let t=await s.database.delete(u.routineTable).where((0,i.eq)(u.routineTable.id,e)).returning({id:u.routineTable.id});return t.length&&E(),t.length>0}e.s(["createRoutine",0,w,"deleteRoutine",0,T,"listRoutines",0,f,"resolveRoutine",0,R,"updateRoutine",0,y]),a()}catch(e){a(e)}},!1),473139,e=>{"use strict";var t=e.i(105249),a=e.i(687388),r=e.i(704161);let n=t.default.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"A time is HH:MM, 00:00 to 23:59");function i(e){let[t,a]=e.split(" "),[r,n,i]=t.split("-").map(Number),[o,l]=a.split(":").map(Number);return new Date(r,n-1,i,o,l)}let o=/^\d{4}-\d\d-\d\d ([01]\d|2[0-3]):[0-5]\d$/,l=t.default.string().regex(o,'A moment is "YYYY-MM-DD HH:MM"').refine(e=>{if(!o.test(e))return!0;let t=i(e);return t.getMonth()===Number(e.slice(5,7))-1&&t.getDate()===Number(e.slice(8,10))},"There is no such day"),s=t.default.discriminatedUnion("kind",[t.default.object({kind:t.default.literal("once"),at:l}),t.default.object({kind:t.default.literal("daily"),time:n,days:t.default.array(t.default.number().int().min(1).max(7)).min(1,"Pick at least one day").transform(e=>[...new Set(e)].sort((e,t)=>e-t))}),t.default.object({kind:t.default.literal("every"),hours:t.default.number().int().min(a.ROUTINE.minHours,`No more often than every ${a.ROUTINE.minHours}h`).max(168)})]),u=t.default.object({bot:t.default.string().trim().min(1,"Pick a bot"),label:t.default.string().trim().min(1,"Give it a name").max(80),request:t.default.string().trim().min(1,"Say what it should do"),schedule:s}),d=t.default.object({id:t.default.string(),status:t.default.enum(["running","waiting","done","cancelled"]),outcome:t.default.string().nullable(),updatedAt:r.DateLikeSchema});u.extend({id:t.default.string(),enabled:t.default.boolean(),nextRunAt:r.DateLikeSchema,runs:t.default.array(d)});let c=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],p=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];e.s(["RoutineInputSchema",0,u,"RoutineScheduleSchema",0,s,"momentOf",0,i,"nextRun",0,function(e,t){if("once"===e.kind)return i(e.at);if("every"===e.kind)return new Date(t.getTime()+36e5*e.hours);let[a,r]=e.time.split(":").map(Number);for(let n=0;n<=7;n++){let i=new Date(t);i.setDate(i.getDate()+n),i.setHours(a,r,0,0);let o=0===i.getDay()?7:i.getDay();if(i>t&&e.days.includes(o))return i}return new Date(t.getTime()+864e5)},"scheduleText",0,function(e){if("once"===e.kind){let[t,a]=e.at.split(" "),[,r,n]=t.split("-").map(Number);return`Once \xb7 ${p[r-1]} ${n} ${a}`}if("every"===e.kind)return 1===e.hours?"Every hour":`Every ${e.hours} hours`;let{days:t,time:a}=e;if(7===t.length)return`Daily ${a}`;if(1===t.length)return`${c[t[0]-1]} ${a}`;let r=t.every((e,a)=>0===a||e===t[a-1]+1)?`${c[t[0]-1]}–${c[t.at(-1)-1]}`:t.map(e=>c[e-1]).join(" ");return`Daily ${a} \xb7 ${r}`}])},260338,e=>{"use strict";var t=e.i(518899),a=e.i(844988),r=e.i(156325);e.s(["count",0,function(e){return t.sql`count(${e||t.sql.raw("*")})`.mapWith(Number)},"max",0,function(e){return t.sql`max(${e})`.mapWith((0,a.is)(e,r.Column)?e:String)}])}];
4
4
 
5
5
  //# sourceMappingURL=_0k6qjcf._.js.map
@@ -1,7 +1,7 @@
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:v,workUnitAsyncStorage:_,serverHooks:b}=y;async function R(e,t,n){n.requestMeta&&(0,i.setRequestMeta)(e,n.requestMeta),y.isDev&&(0,i.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let v="/api/reach/route";v=v.replace(/\/index$/,"")||"/";let _=await y.prepare(e,t,{srcPage:v,multiZoneDraftMode:!1});if(!_)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:b,deploymentId:R,params:k,nextConfig:E,parsedUrl:S,isDraftMode:$,prerenderManifest:x,routerServerContext:C,isOnDemandRevalidate:T,revalidateOnlyGenerated:A,resolvedPathname:O,clientReferenceManifest:P,serverActionsManifest:N}=_,I=(0,o.normalizeAppPath)(v),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:v,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:k,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:R}},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:v,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} ${v}`,kind:s.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},e=>X(e,t)),void 0,!B)}}e.s(["handler",0,R,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:_})},"routeModule",0,y,"serverHooks",0,b,"workAsyncStorage",0,v,"workUnitAsyncStorage",0,_])},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);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);e.i(134344);var 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={question:0,stopped:1,done:2,progress:3};function s(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
- [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:o}=r.room,l=(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 o){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")}
3
- ${s(a.text)}${n}`,relayIds:e.filter(e=>e.messageId===a.id).map(e=>e.id),show:d(a.bot,`${a.bot}: question`)})}let u=e.filter(e=>!o.some(t=>t.id===e.messageId)),p="done"===r.status,h="waiting"===r.status&&(0,a.isAppStop)(r.ask)&&!r.ask?.auto;if(p||h){if(r.seen)continue;let e=h?"stopped":"done",a="stopped"===e?`It stopped before finishing. Where it got to: ${s(r.ask?.question??r.outcome??"")}`:`Done. Its answer: ${s(r.outcome??"")}`;t.push({rank:i[e],key:`${e}:${r.id}@${l}`,kind:"ending",line:`${c(r.bot,e)}
4
- ${a}`,relayIds:u.map(e=>e.id),show:d(r.bot,"stopped"===e?`${r.bot} stopped`:`Answer from ${r.bot}`)});continue}for(let e of u)t.push({rank:i.progress,key:`progress:${e.id}`,kind:"progress",line:`${c(e.bot,e.kind)}
5
- ${s(e.text)}`,relayIds:[e.id],show:d(e.bot,`${e.bot}: ${e.kind}`)})}return t.sort((e,t)=>e.rank-t.rank)}])}];
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:v,workUnitAsyncStorage:_,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 v="/api/reach/route";v=v.replace(/\/index$/,"")||"/";let _=await y.prepare(e,t,{srcPage:v,multiZoneDraftMode:!1});if(!_)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}=_,I=(0,o.normalizeAppPath)(v),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:v,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:v,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} ${v}`,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:v,workUnitAsyncStorage:_})},"routeModule",0,y,"serverHooks",0,b,"workAsyncStorage",0,v,"workUnitAsyncStorage",0,_])},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);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);e.i(134344);var 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}
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)}
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
+ ${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
 
7
7
  //# sourceMappingURL=_0na2fj1._.js.map