thursday-agent 0.9.0 → 0.11.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 (320) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +0 -1
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/routes-manifest.json +0 -6
  6. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  7. package/.next/server/app/_global-error.html +1 -1
  8. package/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  13. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/_not-found.html +1 -1
  15. package/.next/server/app/_not-found.rsc +2 -2
  16. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  17. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  18. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  19. package/.next/server/app/api/artifact/route.js.nft.json +1 -1
  20. package/.next/server/app/api/bot/keep-working/route.js.nft.json +1 -1
  21. package/.next/server/app/api/bot/memory/files/route.js.nft.json +1 -1
  22. package/.next/server/app/api/bot/memory/route.js.nft.json +1 -1
  23. package/.next/server/app/api/bot/route.js.nft.json +1 -1
  24. package/.next/server/app/api/bot/thread/[id]/route.js.nft.json +1 -1
  25. package/.next/server/app/api/bot/thread/route.js.nft.json +1 -1
  26. package/.next/server/app/api/config/route.js.nft.json +1 -1
  27. package/.next/server/app/api/events/route.js.nft.json +1 -1
  28. package/.next/server/app/api/favicon/[host]/route.js.nft.json +1 -1
  29. package/.next/server/app/api/file/[...path]/route.js.nft.json +1 -1
  30. package/.next/server/app/api/llm-model/catalog/route.js.nft.json +1 -1
  31. package/.next/server/app/api/llm-model/credits/route.js.nft.json +1 -1
  32. package/.next/server/app/api/llm-model/route.js.nft.json +1 -1
  33. package/.next/server/app/api/llm-model/subscription/route.js.nft.json +1 -1
  34. package/.next/server/app/api/mcp/[name]/route.js.nft.json +1 -1
  35. package/.next/server/app/api/mcp/oauth/callback/route.js.nft.json +1 -1
  36. package/.next/server/app/api/mcp/route.js.nft.json +1 -1
  37. package/.next/server/app/api/mcp/tools/route.js.nft.json +1 -1
  38. package/.next/server/app/api/memory/edit/route.js.nft.json +1 -1
  39. package/.next/server/app/api/memory/route.js.nft.json +1 -1
  40. package/.next/server/app/api/reach/route.js +13 -13
  41. package/.next/server/app/api/reach/route.js.nft.json +1 -1
  42. package/.next/server/app/api/routine/route.js.nft.json +1 -1
  43. package/.next/server/app/api/signins/route.js +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.nft.json +1 -1
  50. package/.next/server/app/api/thursday/tool-call/route.js +14 -15
  51. package/.next/server/app/api/thursday/tool-call/route.js.nft.json +1 -1
  52. package/.next/server/app/api/workspace/files/route.js.nft.json +1 -1
  53. package/.next/server/app/api/workspace/route.js.nft.json +1 -1
  54. package/.next/server/app/artifact/[...path]/page/server-reference-manifest.json +1 -1
  55. package/.next/server/app/artifact/[...path]/page.js.nft.json +1 -1
  56. package/.next/server/app/artifact/[...path]/page_client-reference-manifest.js +1 -1
  57. package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  58. package/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  59. package/.next/server/app/page/server-reference-manifest.json +56 -56
  60. package/.next/server/app/page.js +4 -4
  61. package/.next/server/app/page.js.nft.json +1 -1
  62. package/.next/server/app/page_client-reference-manifest.js +1 -1
  63. package/.next/server/app-paths-manifest.json +0 -1
  64. package/.next/server/chunks/[root-of-the-server]__014ydvq._.js +2 -2
  65. package/.next/server/chunks/[root-of-the-server]__0209ah4._.js +7 -5
  66. package/.next/server/chunks/[root-of-the-server]__04r4h-2._.js +4 -2
  67. package/.next/server/chunks/[root-of-the-server]__0542v_d._.js +3 -0
  68. package/.next/server/chunks/[root-of-the-server]__0gewdg9._.js +2 -2
  69. package/.next/server/chunks/[root-of-the-server]__0mrk2it._.js +1 -1
  70. package/.next/server/chunks/[root-of-the-server]__1-swlkw._.js +2 -2
  71. package/.next/server/chunks/[root-of-the-server]__12iddfq._.js +1 -1
  72. package/.next/server/chunks/[root-of-the-server]__1ai5lme._.js +3 -3
  73. package/.next/server/chunks/[root-of-the-server]__1cjxw0-._.js +2 -2
  74. package/.next/server/chunks/{[root-of-the-server]__1fy2g82._.js → [root-of-the-server]__1k3j52n._.js} +1 -1
  75. package/.next/server/chunks/[root-of-the-server]__1kyjt5m._.js +3 -3
  76. package/.next/server/chunks/[root-of-the-server]__1ygplx1._.js +1 -1
  77. package/.next/server/chunks/_05v8k21._.js +3 -1
  78. package/.next/server/chunks/_0awtznl._.js +1 -1
  79. package/.next/server/chunks/_0na2fj1._.js +1 -1
  80. package/.next/server/chunks/_0x-ej3f._.js +17 -17
  81. package/.next/server/chunks/_12-amdu._.js +2 -2
  82. package/.next/server/chunks/_15740dw._.js +60 -0
  83. package/.next/server/chunks/_1dc_d1q._.js +3 -3
  84. package/.next/server/chunks/_1i350l5._.js +3 -1
  85. package/.next/server/chunks/_1jc5g4p._.js +2 -2
  86. package/.next/server/chunks/_1jn-aep._.js +4 -4
  87. package/.next/server/chunks/_1m88lkh._.js +11 -11
  88. package/.next/server/chunks/_1ogqovh._.js +4 -4
  89. package/.next/server/chunks/_1uuucy-._.js +1 -1
  90. package/.next/server/chunks/_1zxp-p6._.js +1 -1
  91. package/.next/server/chunks/features_0rfvely._.js +5 -3
  92. package/.next/server/chunks/ssr/{[root-of-the-server]__1se25x0._.js → [root-of-the-server]__0hpp3nw._.js} +29 -13
  93. package/.next/server/chunks/ssr/[root-of-the-server]__0m7u9j-._.js +3 -0
  94. package/.next/server/chunks/ssr/[root-of-the-server]__0tzekbl._.js +24 -60
  95. package/.next/server/chunks/ssr/[root-of-the-server]__1cz2rz5._.js +3 -0
  96. package/.next/server/chunks/ssr/{[root-of-the-server]__0tvavy9._.js → [root-of-the-server]__1iwyp1e._.js} +1 -1
  97. package/.next/server/chunks/ssr/[root-of-the-server]__1w9hqq8._.js +1 -1
  98. package/.next/server/chunks/ssr/_097-ljd._.js +1 -1
  99. package/.next/server/chunks/ssr/{_1tmu8z-._.js → _0btzccu._.js} +2 -2
  100. package/.next/server/chunks/ssr/_0fqhhwi._.js +1 -1
  101. package/.next/server/chunks/ssr/_0hjzb5o._.js +3 -0
  102. package/.next/server/chunks/ssr/_0ld9_qq._.js +1 -1
  103. package/.next/server/chunks/ssr/{_0urj3mc._.js → _0ouzu9f._.js} +2 -2
  104. package/.next/server/chunks/ssr/{_1-zyvdb._.js → _0u7ko71._.js} +2 -2
  105. package/.next/server/chunks/ssr/{_0ltz2q5._.js → _0wd_o8-._.js} +2 -2
  106. package/.next/server/chunks/ssr/_0ya0cb0._.js +3 -0
  107. package/.next/server/chunks/ssr/_10yyqtk._.js +67 -0
  108. package/.next/server/chunks/ssr/{_1uy0xom._.js → _12eyown._.js} +3 -3
  109. package/.next/server/chunks/ssr/_12mijol._.js +11 -11
  110. package/.next/server/chunks/ssr/_132qkfz._.js +1 -1
  111. package/.next/server/chunks/ssr/_184327j._.js +1 -1
  112. package/.next/server/chunks/ssr/{_1z74dmq._.js → _19ps4p3._.js} +7 -7
  113. package/.next/server/chunks/ssr/{_1flbs77._.js → _1bhy4yg._.js} +2 -2
  114. package/.next/server/chunks/ssr/_1d423aj._.js +7 -5
  115. package/.next/server/chunks/ssr/{_1a-nuxx._.js → _1kd843u._.js} +2 -2
  116. package/.next/server/chunks/ssr/{_0ital-2._.js → _1kq2ye_._.js} +2 -2
  117. package/.next/server/chunks/ssr/_1mqn9mc._.js +1 -1
  118. package/.next/server/chunks/ssr/_1neoj22._.js +1 -1
  119. package/.next/server/chunks/ssr/_1p8xorg._.js +3 -0
  120. package/.next/server/chunks/ssr/{_1x-kojb._.js → _1q683w8._.js} +3 -3
  121. package/.next/server/chunks/ssr/_1tawxu2._.js +3 -0
  122. package/.next/server/chunks/ssr/{_0scf7xy._.js → _1w2oba6._.js} +2 -2
  123. package/.next/server/chunks/ssr/_1xoch6f._.js +1 -1
  124. package/.next/server/chunks/ssr/{_0kjj5ts._.js → _1ybo1hd._.js} +3 -3
  125. package/.next/server/chunks/ssr/features_bot_0s11m4r._.js +3 -0
  126. package/.next/server/chunks/ssr/features_connectors_components_mcp-setting_tsx_0jmbgvp._.js +1 -1
  127. package/.next/server/chunks/ssr/features_memory_components_memory-setting_tsx_0oa43sw._.js +1 -1
  128. package/.next/server/chunks/ssr/features_routine_components_routine-setting_tsx_055fknz._.js +1 -1
  129. package/.next/server/chunks/ssr/features_workspace_00jz2hu._.js +1 -1
  130. package/.next/server/chunks/ssr/{node_modules_1af3w91._.js → node_modules_00pocul._.js} +1 -1
  131. package/.next/server/chunks/ssr/{node_modules_0th357h._.js → node_modules_02zt4az._.js} +1 -1
  132. package/.next/server/chunks/ssr/{node_modules_0jljel9._.js → node_modules_05ojmcl._.js} +1 -1
  133. package/.next/server/chunks/ssr/{node_modules_0wnlddw._.js → node_modules_06i6bli._.js} +1 -1
  134. package/.next/server/chunks/ssr/{node_modules_06bb4q8._.js → node_modules_09dj429._.js} +1 -1
  135. package/.next/server/chunks/ssr/{node_modules_068ws5v._.js → node_modules_0auzgvx._.js} +1 -1
  136. package/.next/server/chunks/ssr/{node_modules_1ogczzz._.js → node_modules_0evjwh1._.js} +1 -1
  137. package/.next/server/chunks/ssr/{node_modules_13kwejm._.js → node_modules_0gmdur8._.js} +1 -1
  138. package/.next/server/chunks/ssr/{node_modules_1s-gb-1._.js → node_modules_0j3te-1._.js} +1 -1
  139. package/.next/server/chunks/ssr/{node_modules_1bucjlk._.js → node_modules_0rbaymq._.js} +1 -1
  140. package/.next/server/chunks/ssr/{node_modules_1wbkzl9._.js → node_modules_0tf8_1e._.js} +1 -1
  141. package/.next/server/chunks/ssr/{node_modules_12et8d5._.js → node_modules_0yqy-0b._.js} +1 -1
  142. package/.next/server/chunks/ssr/{node_modules_1lkix61._.js → node_modules_1-53ebx._.js} +1 -1
  143. package/.next/server/chunks/ssr/{node_modules_03d0rfz._.js → node_modules_1-y9aho._.js} +1 -1
  144. package/.next/server/chunks/ssr/{node_modules_0x630an._.js → node_modules_11bltzp._.js} +1 -1
  145. package/.next/server/chunks/ssr/{node_modules_0uyh_vb._.js → node_modules_18jn2qo._.js} +1 -1
  146. package/.next/server/chunks/ssr/{node_modules_0dzm4um._.js → node_modules_1_te3bu._.js} +1 -1
  147. package/.next/server/chunks/ssr/{node_modules_07rs_p2._.js → node_modules_1c0pg3k._.js} +1 -1
  148. package/.next/server/chunks/ssr/{node_modules_0sgy-dc._.js → node_modules_1en2jx5._.js} +1 -1
  149. package/.next/server/chunks/ssr/{node_modules_0ubdtk-._.js → node_modules_1p-c8cr._.js} +1 -1
  150. package/.next/server/chunks/ssr/{node_modules_1z1lrbk._.js → node_modules_1qe-oxg._.js} +1 -1
  151. package/.next/server/chunks/ssr/{node_modules_04_sbbc._.js → node_modules_1rjt833._.js} +1 -1
  152. package/.next/server/chunks/ssr/{node_modules_0yvz9e0._.js → node_modules_1tzw5sn._.js} +1 -1
  153. package/.next/server/chunks/ssr/{node_modules_1uwg-gz._.js → node_modules_1x6uwvn._.js} +1 -1
  154. package/.next/server/chunks/ssr/{node_modules_0t_ez6-._.js → node_modules_1zqddke._.js} +1 -1
  155. package/.next/server/chunks/ssr/{node_modules_05ybmta._.js → node_modules_211zgim._.js} +1 -1
  156. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0r443fh._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0y51bqj._.js} +1 -1
  157. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_10wnlbk._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1sc114e._.js} +1 -1
  158. package/.next/server/middleware-build-manifest.js +3 -3
  159. package/.next/server/pages/404.html +1 -1
  160. package/.next/server/pages/500.html +1 -1
  161. package/.next/server/server-reference-manifest.js +1 -1
  162. package/.next/server/server-reference-manifest.json +57 -57
  163. package/.next/static/chunks/{13ixzheqw7o-w.js → 03-724sj0nk_z.js} +2 -2
  164. package/.next/static/chunks/03bhu4mk8en2q.js +1 -0
  165. package/.next/static/chunks/{3h2e-xv1zxh_f.js → 04imzjhvzw65d.js} +2 -2
  166. package/.next/static/chunks/{27tvv1i-smrck.js → 0gljzv9fz1g7d.js} +1 -1
  167. package/.next/static/chunks/{37j27b3e1gt7r.js → 0h0lythv1ql93.js} +1 -1
  168. package/.next/static/chunks/{2o4dndk0d68do.js → 0hzbj7f48cmx0.js} +1 -1
  169. package/.next/static/chunks/0lwunwbl7u7pt.js +1 -0
  170. package/.next/static/chunks/{0u9ae9k_2g7k3.js → 0r6nwxg4dv83t.js} +1 -1
  171. package/.next/static/chunks/0rn9nbg6aif9f.js +17 -0
  172. package/.next/static/chunks/{3bbzsitgiltnt.js → 0x_w4shtvrrfg.js} +1 -1
  173. package/.next/static/chunks/{2sdwbfs1x5skp.js → 0ympuji_ufypd.js} +1 -1
  174. package/.next/static/chunks/{3t9huugh-5_ps.js → 0zmrz4zfzm4dt.js} +1 -1
  175. package/.next/static/chunks/{0qmd8n52hp-6v.js → 11tlxkr7a_rpc.js} +1 -1
  176. package/.next/static/chunks/{2c64drdevdla3.js → 12scesro428m7.js} +2 -2
  177. package/.next/static/chunks/16s2fx3890_jd.js +65 -0
  178. package/.next/static/chunks/{0oyz95sujd2c7.js → 1qzfgplyo18tc.js} +1 -1
  179. package/.next/static/chunks/{04e-e--5lk26x.js → 1r4zajz14jp9-.js} +1 -1
  180. package/.next/static/chunks/1s6m4cmbn7htf.js +1 -0
  181. package/.next/static/chunks/1wl9t1-3i-q8p.css +1 -0
  182. package/.next/static/chunks/2-asot3p1j3yg.js +1 -0
  183. package/.next/static/chunks/{0u3ktztrzu1fa.js → 2-jn4xscbm-i2.js} +1 -1
  184. package/.next/static/chunks/22h9gvclqtx_2.js +1 -0
  185. package/.next/static/chunks/{337g9g_ux2gj-.js → 26-eblxwnykck.js} +1 -1
  186. package/.next/static/chunks/{43q9cgbuw8krx.js → 2kzwhbuobpkw3.js} +2 -2
  187. package/.next/static/chunks/2m6jd3586ijb-.js +1 -0
  188. package/.next/static/chunks/{0_awn8tucznxc.js → 304q9p54tcgm1.js} +1 -1
  189. package/.next/static/chunks/{1u5i-jti87jbo.js → 35wdx3wt7cg4a.js} +1 -1
  190. package/.next/static/chunks/37unh9460im7v.js +18 -0
  191. package/.next/static/chunks/{01xjer0i_e5z5.js → 39gj5vxz1zpm_.js} +1 -1
  192. package/.next/static/chunks/{427qsc6kahxyo.js → 39vrqy1r_00jc.js} +1 -1
  193. package/.next/static/chunks/{245hb85nsy6j4.js → 3dipmu0mptqum.js} +1 -1
  194. package/.next/static/chunks/3gki-squw28yu.js +1 -0
  195. package/.next/static/chunks/{3obf9n3cxj99k.js → 3jvldk2wvwbge.js} +1 -1
  196. package/.next/static/chunks/{38301ji-85i30.js → 3nnzdl_te20hv.js} +1 -1
  197. package/.next/static/chunks/{2m267diam_vib.js → 3tz4dr0_8pq1-.js} +1 -1
  198. package/.next/static/chunks/{2gocl3dq0_h1s.js → 3x6pggb-2kyrk.js} +1 -1
  199. package/.next/static/chunks/{025bmrgeukcb2.js → 4440mws9jz3mt.js} +1 -1
  200. package/README.md +4 -0
  201. package/app/api/thursday/tool-call/route.ts +1 -15
  202. package/components/ui/radio-group.tsx +2 -2
  203. package/docs/images/demo-still.jpg +0 -0
  204. package/docs/live-calls.md +19 -11
  205. package/features/ai/prompts/live.prompt.ts +51 -26
  206. package/features/ai/prompts/prompt-helper.ts +1 -9
  207. package/features/ai/prompts/thursday.prompt.ts +8 -2
  208. package/features/bot/bot.run.ts +9 -3
  209. package/features/bot/bot.seed.ts +35 -91
  210. package/features/bot/components/bot-room.tsx +0 -6
  211. package/features/bot/components/bot-setting.tsx +4 -4
  212. package/features/bot/components/room-pill.tsx +4 -2
  213. package/features/bot/seed-bots.ts +2 -2
  214. package/features/intro/components/intro.tsx +2 -3
  215. package/features/reach/reach.ts +2 -2
  216. package/features/routine/components/routine-setting.tsx +1 -1
  217. package/features/signins/signins.query.ts +66 -1
  218. package/features/thursday/components/side-captions.tsx +31 -8
  219. package/features/thursday/components/thursday-setting.tsx +5 -5
  220. package/features/thursday/components/thursday.tsx +97 -39
  221. package/features/thursday/components/write-line.tsx +28 -17
  222. package/features/thursday/thursday.action.ts +4 -20
  223. package/features/thursday/thursday.schema.ts +0 -9
  224. package/features/thursday/thursday.store.ts +11 -15
  225. package/features/thursday/thursday.text.ts +10 -8
  226. package/features/thursday/tool-line.ts +17 -6
  227. package/features/thursday/use-call-ring.ts +1 -5
  228. package/features/thursday/use-text-call.ts +37 -21
  229. package/features/thursday/use-thursday.ts +14 -44
  230. package/features/workspace/workspace.ts +4 -2
  231. package/guide/bots.md +13 -3
  232. package/guide/calls.md +7 -5
  233. package/knip.json +1 -0
  234. package/lib/live/live.session.ts +0 -39
  235. package/package.json +1 -1
  236. package/scripts/live-session.test.mts +19 -26
  237. package/seed-skills/analyst/README.md +18 -0
  238. package/seed-skills/analyst/data-report/SKILL.md +60 -0
  239. package/seed-skills/analyst/data-report/references/brief.md +31 -0
  240. package/seed-skills/analyst/data-report/references/company.md +41 -0
  241. package/seed-skills/analyst/data-report/references/comparison.md +42 -0
  242. package/seed-skills/analyst/data-report/references/decision.md +28 -0
  243. package/seed-skills/analyst/data-report/references/market-size.md +49 -0
  244. package/seed-skills/analyst/data-report/references/price-check.md +33 -0
  245. package/seed-skills/analyst/data-report/references/sources.md +51 -0
  246. package/seed-skills/analyst/data-report/references/trend.md +39 -0
  247. package/seed-skills/analyst/data-report/scripts/fetch.mjs +521 -0
  248. package/seed-skills/insta/instagram/SKILL.md +36 -0
  249. package/seed-skills/insta/instagram/references/dm.md +49 -0
  250. package/seed-skills/insta/instagram/references/post.md +74 -0
  251. package/seed-skills/insta/instagram/scripts/compose.mjs +333 -0
  252. package/seed-skills/insta/instagram/scripts/inbox.mjs +163 -0
  253. package/seed-skills/insta/instagram/scripts/lib.mjs +33 -0
  254. package/seed-skills/insta/instagram/scripts/media.mjs +104 -0
  255. package/seed-skills/insta/instagram/scripts/profile.mjs +143 -0
  256. package/seed-skills/insta/instagram/scripts/read.mjs +244 -0
  257. package/seed-skills/insta/instagram/scripts/search.mjs +137 -0
  258. package/seed-skills/insta/instagram/scripts/selectors.mjs +56 -0
  259. package/seed-skills/insta/instagram/scripts/sheet.mjs +43 -0
  260. package/seed-skills/insta/instagram/templates/carousel.html +62 -0
  261. package/seed-skills/marketer/README.md +6 -4
  262. package/seed-skills/marketer/copywriting/SKILL.md +1 -1
  263. package/seed-skills/marketer/emails/SKILL.md +1 -1
  264. package/seed-skills/marketer/launch/SKILL.md +1 -1
  265. package/seed-skills/marketer/product-marketing/SKILL.md +5 -5
  266. package/seed-skills/marketer/seo-audit/SKILL.md +1 -1
  267. package/seed-skills/marketer/social/SKILL.md +1 -1
  268. package/seed-skills/tutor/picture-book/SKILL.md +16 -0
  269. package/seed-skills/tutor/picture-book/book/book.css +181 -0
  270. package/seed-skills/tutor/picture-book/book/book.html +33 -0
  271. package/seed-skills/tutor/picture-book/book/book.js +60 -0
  272. package/seed-skills/tutor/picture-book/references/picture-book.md +104 -0
  273. package/seed-skills/tutor/picture-book/scripts/book-video.mjs +177 -0
  274. package/seed-skills/tutor/picture-book/scripts/book.mjs +98 -0
  275. package/skills/browser/SKILL.md +13 -4
  276. package/skills/browser/references/scripts.md +55 -0
  277. package/skills/browser/scripts/image-size.mjs +30 -0
  278. package/skills/browser/scripts/render.mjs +126 -0
  279. package/skills/browser/scripts/session.mjs +105 -0
  280. package/skills/browser/scripts/sheet.mjs +97 -0
  281. package/skills/browser/scripts/webimage.mjs +105 -0
  282. package/skills/interactive-page/SKILL.md +4 -3
  283. package/skills/interactive-page/scripts/chart.mjs +679 -0
  284. package/skills/interactive-page/scripts/page.mjs +1 -0
  285. package/.next/server/app/api/probe/route/app-paths-manifest.json +0 -3
  286. package/.next/server/app/api/probe/route/build-manifest.json +0 -12
  287. package/.next/server/app/api/probe/route/server-reference-manifest.json +0 -4
  288. package/.next/server/app/api/probe/route.js +0 -10
  289. package/.next/server/app/api/probe/route.js.map +0 -5
  290. package/.next/server/app/api/probe/route.js.nft.json +0 -1
  291. package/.next/server/app/api/probe/route_client-reference-manifest.js +0 -3
  292. package/.next/server/chunks/[root-of-the-server]__012s2o8._.js +0 -3
  293. package/.next/server/chunks/[root-of-the-server]__0z0hc1f._.js +0 -4
  294. package/.next/server/chunks/[root-of-the-server]__1v7-zke._.js +0 -5
  295. package/.next/server/chunks/_0whlpyi._.js +0 -4
  296. package/.next/server/chunks/_next-internal_server_app_api_probe_route_actions_0cqd30j.js +0 -3
  297. package/.next/server/chunks/ssr/[root-of-the-server]__0oo-wlv._.js +0 -103
  298. package/.next/server/chunks/ssr/[root-of-the-server]__0zuns7e._.js +0 -3
  299. package/.next/server/chunks/ssr/_070nv1_._.js +0 -3
  300. package/.next/server/chunks/ssr/_0dshsh4._.js +0 -3
  301. package/.next/server/chunks/ssr/_0l_mcfz._.js +0 -3
  302. package/.next/server/chunks/ssr/_0u5xv6g._.js +0 -3
  303. package/.next/server/chunks/ssr/_157yfrk._.js +0 -3
  304. package/.next/server/chunks/ssr/features_bot_1nr94ks._.js +0 -3
  305. package/.next/static/chunks/06nt9tatr-dug.js +0 -1
  306. package/.next/static/chunks/0ge-hx0ed83a1.js +0 -1
  307. package/.next/static/chunks/0pda_vf-abwvx.js +0 -1
  308. package/.next/static/chunks/0rowp9rx3qbxu.js +0 -18
  309. package/.next/static/chunks/1grkt5gr8pbg1.js +0 -17
  310. package/.next/static/chunks/1yugpvvi8qrbu.js +0 -101
  311. package/.next/static/chunks/27lkanxvtdn09.js +0 -1
  312. package/.next/static/chunks/3fec-aeteddr-.js +0 -1
  313. package/.next/static/chunks/3go3hwp1z2_h2.css +0 -1
  314. package/.next/static/chunks/3h2bun3hcggg8.js +0 -1
  315. package/.next/static/chunks/3j1y335o95mj7.js +0 -1
  316. package/lib/probe.server.ts +0 -17
  317. package/lib/probe.ts +0 -55
  318. /package/.next/static/{u8kJqShUAa49vY7BxAWsw → En1vUPazxcYjPjnnahcN5}/_buildManifest.js +0 -0
  319. /package/.next/static/{u8kJqShUAa49vY7BxAWsw → En1vUPazxcYjPjnnahcN5}/_clientMiddlewareManifest.js +0 -0
  320. /package/.next/static/{u8kJqShUAa49vY7BxAWsw → En1vUPazxcYjPjnnahcN5}/_ssgManifest.js +0 -0
@@ -0,0 +1,177 @@
1
+ // A picture book read aloud: every page screenshotted as one frame, held for as
2
+ // long as its voice runs, and joined into one mp4 beside the book.
3
+ import { spawnSync } from "node:child_process";
4
+ import {
5
+ existsSync,
6
+ mkdirSync,
7
+ mkdtempSync,
8
+ readdirSync,
9
+ rmSync,
10
+ statSync,
11
+ } from "node:fs";
12
+ import { basename, dirname, join } from "node:path";
13
+
14
+ // The shipped browser skill's renderer, reached the way every kit script reaches it
15
+ const RENDER = join(
16
+ process.env.THURSDAY_SKILLS ?? "",
17
+ "browser",
18
+ "scripts",
19
+ "render.mjs",
20
+ );
21
+ // Silence after each page's voice before the next page turns
22
+ const PAUSE_S = 0.6;
23
+ const FPS = 30;
24
+
25
+ /** ffmpeg on the machine, or a portable build installed once into the workspace. */
26
+ function findFfmpeg(workspace, Stop) {
27
+ if (spawnSync("ffmpeg", ["-version"]).status === 0) return "ffmpeg";
28
+ const dir = join(workspace, "projects", ".ffmpeg");
29
+ const bin = join(
30
+ dir,
31
+ "node_modules",
32
+ "ffmpeg-static",
33
+ process.platform === "win32" ? "ffmpeg.exe" : "ffmpeg",
34
+ );
35
+ if (existsSync(bin)) return bin;
36
+ console.error(
37
+ "No ffmpeg on this machine: installing a portable one into projects/.ffmpeg, once…",
38
+ );
39
+ mkdirSync(dir, { recursive: true });
40
+ spawnSync(
41
+ "npm",
42
+ [
43
+ "install",
44
+ "--prefix",
45
+ dir,
46
+ "ffmpeg-static",
47
+ "--no-audit",
48
+ "--no-fund",
49
+ "--loglevel=error",
50
+ ],
51
+ { stdio: "inherit", shell: process.platform === "win32" },
52
+ );
53
+ if (!existsSync(bin))
54
+ throw new Stop(
55
+ "Installing a portable ffmpeg failed; npm's output above says why.",
56
+ );
57
+ return bin;
58
+ }
59
+
60
+ /** Seconds, read off the file itself: a scene's length is never guessed. */
61
+ function duration(ffmpeg, file, Stop) {
62
+ const probe = spawnSync(ffmpeg, ["-hide_banner", "-i", file], {
63
+ encoding: "utf8",
64
+ });
65
+ const hms = /Duration: (\d+):(\d+):(\d+(?:\.\d+)?)/.exec(probe.stderr ?? "");
66
+ if (!hms) throw new Stop(`${file} is not audio ffmpeg can read.`);
67
+ return Number(hms[1]) * 3600 + Number(hms[2]) * 60 + Number(hms[3]);
68
+ }
69
+
70
+ /**
71
+ * Renders `book` (an .html picture book) at `size` and joins its pages with
72
+ * `voices`, one audio file per page in page order, into `<book>.mp4`.
73
+ */
74
+ export function bookVideo({ book, voices, size, workspace, shown }, Stop) {
75
+ if (!process.env.THURSDAY_SKILLS)
76
+ throw new Stop(
77
+ "THURSDAY_SKILLS is not set: run this from a bot's shell, where it names the shipped skills.",
78
+ );
79
+ if (!/^\d+x\d+$/.test(size))
80
+ throw new Stop(`--size is width x height, like 1920x1080; not "${size}".`);
81
+ const missing = voices.filter((file) => !existsSync(file));
82
+ if (!voices.length || missing.length)
83
+ throw new Stop(
84
+ voices.length
85
+ ? `No such audio: ${missing.map(shown).join(", ")}`
86
+ : "Give one audio file per page, in page order, after the book's name.",
87
+ );
88
+ const ffmpeg = findFfmpeg(workspace, Stop);
89
+ const lengths = voices.map((file) => duration(ffmpeg, file, Stop) + PAUSE_S);
90
+
91
+ const out = book.replace(/\.html$/, ".mp4");
92
+ const frames = mkdtempSync(
93
+ join(dirname(book), `.${basename(book, ".html")}-frames-`),
94
+ );
95
+ try {
96
+ const drawn = spawnSync(
97
+ process.execPath,
98
+ [RENDER, book, "--size", size, "--out", frames, "--name", "page"],
99
+ { encoding: "utf8" },
100
+ );
101
+ const said = `${drawn.stdout}${drawn.stderr}`.trim();
102
+ if (drawn.status !== 0) throw new Stop(said);
103
+ const broken = /^Pictures that did not load.*$/m.exec(said);
104
+ if (broken) throw new Stop(`${broken[0]} — fix them and run this again.`);
105
+ const pngs = readdirSync(frames)
106
+ .filter((file) => file.endsWith(".png"))
107
+ .sort()
108
+ .map((file) => join(frames, file));
109
+ if (pngs.length !== voices.length)
110
+ throw new Stop(
111
+ `The book has ${pngs.length} page(s) and ${voices.length} audio file(s) came: give one per page, in page order.`,
112
+ );
113
+
114
+ const inputs = [];
115
+ const chains = [];
116
+ let joined = "";
117
+ pngs.forEach((png, i) => {
118
+ const s = lengths[i].toFixed(3);
119
+ // A still read twice a second and repeated in the filter: decoding the png
120
+ // at the full frame rate is most of the time otherwise
121
+ const t = (lengths[i] + 1).toFixed(3);
122
+ inputs.push("-loop", "1", "-framerate", "2", "-t", t, "-i", png);
123
+ chains.push(
124
+ `[${i}:v]fps=${FPS},trim=duration=${s},setpts=PTS-STARTPTS,format=yuv420p,setsar=1[v${i}]`,
125
+ `[${pngs.length + i}:a]aformat=sample_rates=48000:channel_layouts=stereo,apad=whole_dur=${s}[a${i}]`,
126
+ );
127
+ joined += `[v${i}][a${i}]`;
128
+ });
129
+ for (const voice of voices) inputs.push("-i", voice);
130
+ const made = spawnSync(
131
+ ffmpeg,
132
+ [
133
+ "-hide_banner",
134
+ "-loglevel",
135
+ "error",
136
+ "-y",
137
+ ...inputs,
138
+ "-filter_complex",
139
+ `${chains.join(";")};${joined}concat=n=${pngs.length}:v=1:a=1[v][a]`,
140
+ "-map",
141
+ "[v]",
142
+ "-map",
143
+ "[a]",
144
+ // h264 in yuv420p: what every phone and browser plays
145
+ "-c:v",
146
+ "libx264",
147
+ "-preset",
148
+ "veryfast",
149
+ "-tune",
150
+ "stillimage",
151
+ "-crf",
152
+ "20",
153
+ "-pix_fmt",
154
+ "yuv420p",
155
+ "-r",
156
+ `${FPS}`,
157
+ "-c:a",
158
+ "aac",
159
+ "-b:a",
160
+ "160k",
161
+ "-movflags",
162
+ "+faststart",
163
+ out,
164
+ ],
165
+ { encoding: "utf8" },
166
+ );
167
+ if (made.status !== 0)
168
+ throw new Stop(`ffmpeg could not join the pages:\n${made.stderr}`);
169
+ } finally {
170
+ rmSync(frames, { recursive: true, force: true });
171
+ }
172
+ const secs = Math.round(lengths.reduce((a, b) => a + b, 0));
173
+ const mb = (statSync(out).size / 1024 / 1024).toFixed(1);
174
+ console.log(
175
+ `Made ${shown(out)}: ${voices.length} pages, ${Math.floor(secs / 60)}:${String(secs % 60).padStart(2, "0")} long, ${size}, ${mb} MB. Hand back this path.`,
176
+ );
177
+ }
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ // A picture book: one HTML file in the bot's artifacts folder, and that file read aloud.
3
+ //
4
+ // node book.mjs new <name> the book, styled, to write pages into
5
+ // node book.mjs video <name> <audio>... [--size WxH] the book as an mp4, one audio file per page
6
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
7
+ import { dirname, join, relative, resolve } from "node:path";
8
+ import { fileURLToPath } from "node:url";
9
+ import { bookVideo } from "./book-video.mjs";
10
+
11
+ const SKILL = resolve(dirname(fileURLToPath(import.meta.url)), "..");
12
+ const SCRIPT = join(SKILL, "scripts", "book.mjs");
13
+ const NAME = /^[\p{L}\p{N}][\p{L}\p{N}_-]{0,79}$/u;
14
+
15
+ /** The app's workspace: the nearest folder above holding its fence and a `projects` folder. */
16
+ function findWorkspace() {
17
+ for (let dir = process.cwd(); ; dir = dirname(dir)) {
18
+ if (
19
+ existsSync(join(dir, "pnpm-workspace.yaml")) &&
20
+ existsSync(join(dir, "projects"))
21
+ )
22
+ return dir;
23
+ if (dir === dirname(dir)) return process.cwd();
24
+ }
25
+ }
26
+
27
+ const WORKSPACE = findWorkspace();
28
+ const shown = (path) => relative(WORKSPACE, path) || ".";
29
+
30
+ class Stop extends Error {}
31
+
32
+ /** Where a book lives: `<name>.html` in the bot's artifacts folder. */
33
+ function bookFile(name) {
34
+ if (!name || !NAME.test(name))
35
+ throw new Stop(
36
+ `${name ? `"${name}" is not` : "Give"} a book name: letters, numbers, - and _ only.`,
37
+ );
38
+ return join(
39
+ WORKSPACE,
40
+ process.env.THURSDAY_ARTIFACTS || "artifacts",
41
+ `${name}.html`,
42
+ );
43
+ }
44
+
45
+ /** One HTML file with its stylesheet and page turning inlined, which the web, print and the video all read. */
46
+ function newBook(name) {
47
+ const out = bookFile(name);
48
+ if (existsSync(out))
49
+ throw new Stop(`${shown(out)} already exists. Edit it there.`);
50
+ const book = join(SKILL, "book");
51
+ const part = (file) => readFileSync(join(book, file), "utf8").trim();
52
+ mkdirSync(dirname(out), { recursive: true });
53
+ writeFileSync(
54
+ out,
55
+ part("book.html")
56
+ .replaceAll("{{title}}", name)
57
+ .replace("/* book.css */", () => part("book.css"))
58
+ .replace("// book.js", () => part("book.js")),
59
+ );
60
+ console.log(
61
+ `${shown(out)} is ready: one file that opens offline, styled already. Write one <section class="page"> per page (the comment inside says how), and hand back this path.`,
62
+ );
63
+ }
64
+
65
+ function videoBook(name, args) {
66
+ const book = bookFile(name);
67
+ if (!existsSync(book))
68
+ throw new Stop(
69
+ `No book ${shown(book)}. Start it with: node ${SCRIPT} new ${name}`,
70
+ );
71
+ const at = args.indexOf("--size");
72
+ const size = at === -1 ? "1920x1080" : (args[at + 1] ?? "");
73
+ const voices = args.filter((_, i) => at === -1 || (i !== at && i !== at + 1));
74
+ bookVideo(
75
+ {
76
+ book,
77
+ voices: voices.map((file) => resolve(WORKSPACE, file)),
78
+ size,
79
+ workspace: WORKSPACE,
80
+ shown,
81
+ },
82
+ Stop,
83
+ );
84
+ }
85
+
86
+ const [command, ...rest] = process.argv.slice(2);
87
+ try {
88
+ if (command === "new") newBook(rest[0]);
89
+ else if (command === "video") videoBook(rest[0], rest.slice(1));
90
+ else
91
+ throw new Stop(
92
+ "Usage: book.mjs new <name> | video <name> <audio>... [--size WxH]",
93
+ );
94
+ } catch (error) {
95
+ if (!(error instanceof Stop)) throw error;
96
+ console.error(error.message);
97
+ process.exit(1);
98
+ }
@@ -108,10 +108,19 @@ when the job is about another.
108
108
  **Pictures for a document** come off the page, never from memory:
109
109
  `--raw eval "JSON.stringify([...document.images].filter(i => i.naturalWidth > 200).map(i => i.currentSrc))"`.
110
110
 
111
- **Local HTML.** `file:` URLs are refused. Serve the folder, then open it:
112
- `python3 -m http.server 48800 --bind 127.0.0.1 --directory <dir> &`,
113
- `goto http://127.0.0.1:48800/<file>.html`; `pdf --filename=out.pdf` prints
114
- it. Kill the server when done.
111
+ **Local HTML.** `file:` URLs are refused, and a fixed port lets two jobs
112
+ capture each other's pages. For a picture of it,
113
+ `node <skill dir>/scripts/render.mjs <file.html> --size 1280x800 --out <dir>`
114
+ serves its folder on a free port for the run and saves each `[data-slide]`
115
+ (else the viewport) as a PNG of exactly that size. To open or print it:
116
+ `python3 -u -m http.server 0 --bind 127.0.0.1 --directory <dir> > <scratch>/serve.log 2>&1 &`,
117
+ read the port from that log, `goto http://127.0.0.1:<port>/<file>.html`;
118
+ `pdf --filename=out.pdf` prints it. Kill the server when done.
119
+
120
+ **Scripts in `<skill dir>/scripts`**: `sheet.mjs` puts many pictures on one
121
+ image for a single `look_at`, `webimage.mjs` saves a page's own picture with
122
+ its credit line, and `session.mjs` lets a script of yours drive this session —
123
+ `references/scripts.md`.
115
124
 
116
125
  Snapshots land in `.playwright-cli/` and are cleared after a few days. A file you
117
126
  name — `--filename=`, a `pdf`, a download — goes under `scratch/`, or
@@ -0,0 +1,55 @@
1
+ # Scripts that ride this session
2
+
3
+ The scripts in this skill's `scripts/` folder work through the browser session already in
4
+ your shell (`PLAYWRIGHT_CLI_SESSION`), so they reach whatever it is signed in to. Each opens a
5
+ tab of its own and closes it, leaving the page you were on as it was. In a bot's shell the
6
+ folder is also `$THURSDAY_SKILLS/browser/scripts`, which is how a skill's own script finds it.
7
+
8
+ ## Pictures
9
+
10
+ ```bash
11
+ S=<skill dir>/scripts
12
+ # Each [data-slide] of an HTML file (or the whole viewport) as a PNG of exactly that size
13
+ node $S/render.mjs <slides.html> --size 1080x1350 --out <dir> [--name slide]
14
+ # A page's own picture (og:image), with --all its large pictures too, and the credit line
15
+ node $S/webimage.mjs <page url> --out <dir> [--all] [--min 600]
16
+ # Many pictures, urls or files, on one labelled image to look at once
17
+ node $S/sheet.mjs --out sheet.png <image url | file>... [--cols 4]
18
+ ```
19
+
20
+ `render` serves the file's folder on a port the system picks, so pictures and fonts beside it
21
+ load and two jobs rendering at once never meet. It fails when a slide comes out at another
22
+ size, and names any picture that did not load. `webimage` and `sheet` fetch through the
23
+ browser, so a site that refuses `curl` still answers and a picture behind a sign-in loads.
24
+
25
+ ## A script of your own
26
+
27
+ `session.mjs` is the one way in: `runCode(source)` runs one `async page => …` and returns what
28
+ it returned, parsed; `inPage(fn, args, helpers)` sends a function with its arguments; it also
29
+ has `parseArgs`, `fail` and `orFail` (a returned `{ error }` stops the script with it).
30
+
31
+ ```js
32
+ const { inPage, orFail } = await import(
33
+ `${process.env.THURSDAY_SKILLS}/browser/scripts/session.mjs`
34
+ );
35
+ const rows = orFail(
36
+ await inPage(async (page, { url }) => {
37
+ await page.goto(url);
38
+ return page.evaluate(() => [...document.querySelectorAll("h2")].map((h) => h.textContent));
39
+ }, { url: "https://example.com" }),
40
+ );
41
+ ```
42
+
43
+ What crosses is source text, run in a bare VM beside the browser — not Node, not the page:
44
+
45
+ - Nothing from your module comes along. What the function needs arrives in `args` (JSON) or as
46
+ another function in `helpers`.
47
+ - There is no `URL`, `URLSearchParams`, `fetch`, `setTimeout` or `require`. Build an address
48
+ with string work and `encodeURIComponent`; fetch with `page.request.get(url)`, which carries
49
+ the session's cookies and draws nothing; wait with `page.waitForTimeout` or
50
+ `page.waitForFunction`; do DOM work inside `page.evaluate`.
51
+ - Files are written by your script from what comes back, not inside the function
52
+ (`page.screenshot({ path })` is the exception: the browser writes it).
53
+ - Code over 64 KB goes through a file; `runCode` does that itself.
54
+ - A page that forces Trusted Types (Gmail) refuses an HTML string: parse fetched HTML with
55
+ `DOMParser` through a policy it allows.
@@ -0,0 +1,30 @@
1
+ import { closeSync, openSync, readSync } from "node:fs";
2
+
3
+ /** Width and height of a PNG or JPEG, read from its header; null for anything else. */
4
+ export function imageSize(path) {
5
+ const fd = openSync(path, "r");
6
+ try {
7
+ const head = Buffer.alloc(64 * 1024);
8
+ const n = readSync(fd, head, 0, head.length, 0);
9
+ if (head.readUInt32BE(0) === 0x89504e47)
10
+ return { w: head.readUInt32BE(16), h: head.readUInt32BE(20) };
11
+ if (head[0] === 0xff && head[1] === 0xd8) {
12
+ // Walk the JPEG segments to the first frame header
13
+ for (let i = 2; i + 9 < n; ) {
14
+ if (head[i] !== 0xff) return null;
15
+ const marker = head[i + 1];
16
+ const len = head.readUInt16BE(i + 2);
17
+ if (
18
+ marker >= 0xc0 &&
19
+ marker <= 0xcf &&
20
+ ![0xc4, 0xc8, 0xcc].includes(marker)
21
+ )
22
+ return { w: head.readUInt16BE(i + 7), h: head.readUInt16BE(i + 5) };
23
+ i += 2 + len;
24
+ }
25
+ }
26
+ return null;
27
+ } finally {
28
+ closeSync(fd);
29
+ }
30
+ }
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Screenshots HTML slides to PNGs of exactly the given size, in a tab of its own
4
+ * beside whatever page the session has open. Every `[data-slide]` element in the
5
+ * file is one PNG; a file with none is one PNG of the whole viewport. The file's
6
+ * folder is served over http for the length of the run, so pictures beside it load.
7
+ *
8
+ * node render.mjs <slides.html> --size 1080x1350 --out <dir> [--name slide]
9
+ */
10
+ import { createReadStream, existsSync, mkdirSync, statSync } from "node:fs";
11
+ import { createServer } from "node:http";
12
+ import { basename, dirname, extname, resolve, sep } from "node:path";
13
+ import { imageSize } from "./image-size.mjs";
14
+ import { fail, inPage, orFail, parseArgs } from "./session.mjs";
15
+
16
+ const opts = parseArgs();
17
+ const file = opts._[0] && resolve(opts._[0]);
18
+ const [w, h] = String(opts.size ?? "")
19
+ .split("x")
20
+ .map(Number);
21
+ if (!file || !opts.out || !w || !h)
22
+ fail(
23
+ "usage: node render.mjs <slides.html> --size 1080x1350 --out <dir> [--name slide]",
24
+ );
25
+ if (!existsSync(file)) fail(`No such file: ${file}`);
26
+ const out = resolve(opts.out);
27
+ mkdirSync(out, { recursive: true });
28
+ const name = opts.name ?? "slide";
29
+
30
+ const TYPES = {
31
+ ".html": "text/html; charset=utf-8",
32
+ ".css": "text/css",
33
+ ".js": "text/javascript",
34
+ ".png": "image/png",
35
+ ".jpg": "image/jpeg",
36
+ ".jpeg": "image/jpeg",
37
+ ".webp": "image/webp",
38
+ ".gif": "image/gif",
39
+ ".svg": "image/svg+xml",
40
+ ".woff2": "font/woff2",
41
+ ".woff": "font/woff",
42
+ ".ttf": "font/ttf",
43
+ ".otf": "font/otf",
44
+ };
45
+ const root = dirname(file);
46
+ // Port 0: the system picks a free one, so two jobs rendering at once never meet
47
+ const server = createServer((req, res) => {
48
+ const path = resolve(
49
+ root,
50
+ `.${decodeURIComponent(new URL(req.url, "http://x").pathname)}`,
51
+ );
52
+ if (
53
+ !path.startsWith(root + sep) ||
54
+ !existsSync(path) ||
55
+ statSync(path).isDirectory()
56
+ ) {
57
+ res.writeHead(404).end();
58
+ return;
59
+ }
60
+ res.writeHead(200, {
61
+ "content-type":
62
+ TYPES[extname(path).toLowerCase()] ?? "application/octet-stream",
63
+ });
64
+ createReadStream(path).pipe(res);
65
+ });
66
+ await new Promise((ok) => server.listen(0, "127.0.0.1", ok));
67
+ const url = `http://127.0.0.1:${server.address().port}/${encodeURIComponent(basename(file))}`;
68
+
69
+ const done = orFail(
70
+ await inPage(
71
+ async (page, { url, w, h, out, name }) => {
72
+ const tab = await page.context().newPage();
73
+ try {
74
+ await tab.setViewportSize({ width: w, height: h });
75
+ await tab.goto(url, { waitUntil: "load" });
76
+ await tab.evaluate(async () => {
77
+ await document.fonts.ready;
78
+ await Promise.all(
79
+ [...document.images].map((i) => i.decode().catch(() => {})),
80
+ );
81
+ });
82
+ const broken = await tab.evaluate(() =>
83
+ [...document.images]
84
+ .filter((i) => !i.naturalWidth)
85
+ .map((i) => i.getAttribute("src")),
86
+ );
87
+ const slides = tab.locator("[data-slide]");
88
+ const n = await slides.count();
89
+ const files = [];
90
+ const pad = (i) => String(i + 1).padStart(2, "0");
91
+ if (n === 0) {
92
+ const path = `${out}/${name}-01.png`;
93
+ await tab.screenshot({ path, scale: "css" });
94
+ files.push(path);
95
+ }
96
+ for (let i = 0; i < n; i++) {
97
+ const path = `${out}/${name}-${pad(i)}.png`;
98
+ await slides.nth(i).screenshot({ path, scale: "css" });
99
+ files.push(path);
100
+ }
101
+ return { files, broken };
102
+ } finally {
103
+ await tab.close();
104
+ }
105
+ },
106
+ { url, w, h, out, name },
107
+ ),
108
+ );
109
+ server.close();
110
+
111
+ let wrong = 0;
112
+ for (const path of done.files) {
113
+ const size = imageSize(path);
114
+ const ok = size && size.w === w && size.h === h;
115
+ if (!ok) wrong++;
116
+ console.log(
117
+ `${path} ${size ? `${size.w}x${size.h}` : "?"}${ok ? "" : ` — not ${w}x${h}`}`,
118
+ );
119
+ }
120
+ if (done.broken.length)
121
+ console.log(`Pictures that did not load: ${done.broken.join(", ")}`);
122
+ if (wrong)
123
+ fail(
124
+ `${wrong} slide(s) came out at the wrong size: give every [data-slide] exactly width ${w}px and height ${h}px, with nothing overflowing it.`,
125
+ );
126
+ console.log(`${done.files.length} slide(s) at ${w}x${h} in ${out}`);
@@ -0,0 +1,105 @@
1
+ /**
2
+ * A script's way into this shell's own browser session (PLAYWRIGHT_CLI_SESSION): every
3
+ * call is one `playwright-cli --raw run-code`, and what the code returns comes back parsed.
4
+ *
5
+ * The code runs in a bare VM beside the browser, not in Node and not in the page: no
6
+ * `URL`, `URLSearchParams`, `fetch`, `setTimeout` or `require`. Build addresses with
7
+ * string work and `encodeURIComponent`, fetch with `page.request` (it carries the
8
+ * session's cookies), wait with `page.waitForTimeout` / `page.waitForFunction`, and do
9
+ * DOM work inside `page.evaluate`. Files are written by the caller from what returns.
10
+ *
11
+ * A skill's own script reaches it through the shipped skills folder, which a bot's shell
12
+ * names in THURSDAY_SKILLS:
13
+ *
14
+ * const { inPage } = await import(`${process.env.THURSDAY_SKILLS}/browser/scripts/session.mjs`);
15
+ */
16
+ import { execFile } from "node:child_process";
17
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
18
+ import { tmpdir } from "node:os";
19
+ import { join } from "node:path";
20
+
21
+ /**
22
+ * Runs `code` — the source of one `async page => …` — and resolves to what it returned,
23
+ * parsed; undefined when it returned nothing. Stops the script with a readable line when
24
+ * no browser is open or the code threw.
25
+ */
26
+ export async function runCode(code) {
27
+ // One argument is capped (E2BIG past 128 KB on Linux, less with a big environment)
28
+ const dir = code.length > 64_000 ? mkdtempSync(join(tmpdir(), "run-")) : null;
29
+ if (dir) writeFileSync(join(dir, "code.js"), code);
30
+ const out = await new Promise((done) =>
31
+ execFile(
32
+ "playwright-cli",
33
+ dir
34
+ ? ["--raw", "run-code", `--filename=${join(dir, "code.js")}`]
35
+ : ["--raw", "run-code", code],
36
+ { encoding: "utf8", maxBuffer: 256 * 1024 * 1024 },
37
+ (error, stdout, stderr) => {
38
+ if (dir) rmSync(dir, { recursive: true, force: true });
39
+ if (!error) return done(stdout.trim());
40
+ if (error.code === "ENOENT")
41
+ fail(
42
+ "playwright-cli is not on this shell's PATH: the browser skill's Install section.",
43
+ );
44
+ const said = `${stdout ?? ""}${stderr ?? ""}`.trim();
45
+ fail(
46
+ /not open|no (open )?browser/i.test(said)
47
+ ? "No browser is open in this session. `playwright-cli open`, sign in if the site needs it, then run this again."
48
+ : `The browser answered with an error:\n${said
49
+ .replace(/^### Error\s*/, "")
50
+ .replace(/^Error:\s*/, "")
51
+ .slice(0, 800)}`,
52
+ );
53
+ },
54
+ ),
55
+ );
56
+ if (!out) return undefined;
57
+ try {
58
+ return JSON.parse(out);
59
+ } catch {
60
+ fail(`Unexpected answer from the browser:\n${out.slice(0, 800)}`);
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Runs `fn(page, args, helpers)` in the session and resolves to what it returned. `fn`
66
+ * and each helper cross as source, so they see nothing of their module: what they need
67
+ * comes in `args` (JSON) or as another helper.
68
+ */
69
+ export function inPage(fn, args = {}, helpers = {}) {
70
+ const lib = Object.entries(helpers)
71
+ .map(([name, helper]) => `${JSON.stringify(name)}: ${helper}`)
72
+ .join(", ");
73
+ return runCode(
74
+ `async page => (${fn})(page, ${JSON.stringify(args)}, { ${lib} })`,
75
+ );
76
+ }
77
+
78
+ /** `--name value`, `--name=value` and `--flag`, and the rest as positionals in `_`. */
79
+ export function parseArgs(argv = process.argv.slice(2)) {
80
+ const opts = { _: [] };
81
+ for (let i = 0; i < argv.length; i++) {
82
+ const a = argv[i];
83
+ if (!a.startsWith("--")) {
84
+ opts._.push(a);
85
+ continue;
86
+ }
87
+ const [key, inline] = a.slice(2).split(/=(.*)/s);
88
+ if (inline !== undefined) opts[key] = inline;
89
+ else if (argv[i + 1] !== undefined && !argv[i + 1].startsWith("--"))
90
+ opts[key] = argv[++i];
91
+ else opts[key] = true;
92
+ }
93
+ return opts;
94
+ }
95
+
96
+ export function fail(message) {
97
+ process.stderr.write(`${message}\n`);
98
+ process.exit(1);
99
+ }
100
+
101
+ /** A page-side answer `{ error }` stops the script with that message. */
102
+ export function orFail(result) {
103
+ if (result && typeof result === "object" && result.error) fail(result.error);
104
+ return result;
105
+ }