@celljs/ta 4.9.1 → 4.10.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 (289) hide show
  1. package/dist/cli.mjs +69 -15
  2. package/dist/gateway.mjs +144 -20
  3. package/dist/pi/CHANGELOG.md +7 -0
  4. package/dist/pi/dist/bundle/chunks/anthropic-messages-CA3HHOL3.js +6 -0
  5. package/dist/pi/dist/bundle/chunks/{azure-openai-responses-FSC6BAW3.js → azure-openai-responses-76TWS6DT.js} +1 -1
  6. package/dist/pi/dist/bundle/chunks/bedrock-converse-stream.js +3 -3
  7. package/dist/pi/dist/bundle/chunks/chunk-4KSTFUIK.js +19 -0
  8. package/dist/pi/dist/bundle/chunks/chunk-4UNPP53I.js +55 -0
  9. package/dist/pi/dist/bundle/chunks/chunk-AUUCDC7R.js +4 -0
  10. package/dist/pi/dist/bundle/chunks/{chunk-V6KH5QG4.js → chunk-BAC3QPNW.js} +1 -1
  11. package/dist/pi/dist/bundle/chunks/{chunk-4EYXVSA5.js → chunk-FF6XOTWB.js} +9 -9
  12. package/dist/pi/dist/bundle/chunks/chunk-FMPAMX2W.js +82 -0
  13. package/dist/pi/dist/bundle/chunks/chunk-GFUN2N5K.js +2 -0
  14. package/dist/pi/dist/bundle/chunks/chunk-IEBK4HQA.js +2 -0
  15. package/dist/pi/dist/bundle/chunks/{chunk-C2WU32PX.js → chunk-IQUU5XIT.js} +1 -1
  16. package/dist/pi/dist/bundle/chunks/{chunk-EBFHJFEE.js → chunk-LQLJ7CDW.js} +1 -1
  17. package/dist/pi/dist/bundle/chunks/chunk-MMDXLZVS.js +30 -0
  18. package/dist/pi/dist/bundle/chunks/{chunk-GN3QYODH.js → chunk-QN4TOIZN.js} +1 -1
  19. package/dist/pi/dist/bundle/chunks/chunk-RKNK4Y6L.js +2 -0
  20. package/dist/pi/dist/bundle/chunks/{chunk-B46VJEHW.js → chunk-V7SLUK6A.js} +1 -1
  21. package/dist/pi/dist/bundle/chunks/chunk-VEJDBY3O.js +1237 -0
  22. package/dist/pi/dist/bundle/chunks/chunk-VKJQ6CME.js +8 -0
  23. package/dist/pi/dist/bundle/chunks/{chunk-3TGLJEWK.js → chunk-WL4TUXY7.js} +1 -1
  24. package/dist/pi/dist/bundle/chunks/{chunk-YZKQS34S.js → chunk-Y55SJART.js} +5 -1
  25. package/dist/pi/dist/bundle/chunks/{chunk-EOO47QGR.js → chunk-ZBIZYD6W.js} +1 -1
  26. package/dist/pi/dist/bundle/chunks/chunk-ZG74NES2.js +2 -0
  27. package/dist/pi/dist/bundle/chunks/chunk-ZGYS4UTC.js +2 -0
  28. package/dist/pi/dist/bundle/chunks/{cli-MCOUW5WS.js → cli-7RHMDOHL.js} +7 -7
  29. package/dist/pi/dist/bundle/chunks/{cloudflare-workers-ai-system-one-WLAFJSP6.js → cloudflare-workers-ai-system-one-U4J7D646.js} +1 -1
  30. package/dist/pi/dist/bundle/chunks/codemode-worker.js +2 -0
  31. package/dist/pi/dist/bundle/chunks/{easter-egg-3d-WMBNSJ4M.js → easter-egg-3d-GEVPKQF6.js} +1 -1
  32. package/dist/pi/dist/bundle/chunks/{execute-4CEBORGZ.js → execute-L2EEDV3L.js} +5 -3
  33. package/dist/pi/dist/bundle/chunks/github-copilot.js +1 -1
  34. package/dist/pi/dist/bundle/chunks/{google-generative-ai-INGKNW72.js → google-generative-ai-D5B6W47J.js} +1 -1
  35. package/dist/pi/dist/bundle/chunks/{google-vertex-IBTX6MBF.js → google-vertex-U4H5YDEW.js} +1 -1
  36. package/dist/pi/dist/bundle/chunks/{llama-cpp-classify-V5U3QKXI.js → llama-cpp-classify-EJXCQRUQ.js} +1 -1
  37. package/dist/pi/dist/bundle/chunks/{mistral-conversations-S4OWXIXQ.js → mistral-conversations-S277EKLB.js} +1 -1
  38. package/dist/pi/dist/bundle/chunks/openai-codex-responses-TEQRB65N.js +10 -0
  39. package/dist/pi/dist/bundle/chunks/{openai-completions-EJNYB6IX.js → openai-completions-HRZOSLBO.js} +3 -3
  40. package/dist/pi/dist/bundle/chunks/{openai-decisions-IXI34BYG.js → openai-decisions-F66BDLOM.js} +1 -1
  41. package/dist/pi/dist/bundle/chunks/openai-responses-BAKFWTGE.js +4 -0
  42. package/dist/pi/dist/bundle/chunks/{openrouter-images-PISKSFMS.js → openrouter-images-VXF5TVIK.js} +1 -1
  43. package/dist/pi/dist/bundle/chunks/{pi-messages-NORUKF4E.js → pi-messages-UBJKNDRN.js} +1 -1
  44. package/dist/pi/dist/bundle/chunks/{runtime-FQB7RU7U.js → runtime-J5ZSBGTX.js} +1 -1
  45. package/dist/pi/dist/bundle/chunks/{typesafe-system-one-CHVC2UUI.js → typesafe-system-one-56TEMIHL.js} +1 -1
  46. package/dist/pi/dist/bundle/chunks/virtual-modules-KITQRTYM.js +2 -0
  47. package/dist/pi/dist/bundle/cli-runtime.js +1 -1
  48. package/dist/pi/dist/bundle/index.js +1 -1
  49. package/dist/pi/dist/bundle/rpc-entry.js +1 -1
  50. package/dist/pi/docs/cli.md +14 -1
  51. package/dist/pi/docs/extensions.md +27 -7
  52. package/dist/pi/docs/keybindings.md +1 -1
  53. package/dist/pi/docs/llama-cpp.md +5 -8
  54. package/dist/pi/docs/models-configuration.md +6 -1
  55. package/dist/pi/docs/models.md +2 -1
  56. package/dist/pi/docs/prompt-templates.md +1 -1
  57. package/dist/pi/docs/providers.md +1 -1
  58. package/dist/pi/docs/rpc.md +4 -2
  59. package/dist/pi/docs/sessions.md +7 -1
  60. package/dist/pi/docs/settings.md +1 -1
  61. package/dist/pi/docs/tui.md +1 -1
  62. package/dist/pi/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  63. package/dist/pi/examples/extensions/custom-provider-anthropic/package.json +1 -1
  64. package/dist/pi/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  65. package/dist/pi/examples/extensions/gondolin/package-lock.json +2 -2
  66. package/dist/pi/examples/extensions/gondolin/package.json +1 -1
  67. package/dist/pi/examples/extensions/plan-mode/index.ts +23 -13
  68. package/dist/pi/examples/extensions/plan-mode/utils.ts +42 -16
  69. package/dist/pi/examples/extensions/subagent/README.md +14 -11
  70. package/dist/pi/examples/extensions/subagent/index.ts +392 -171
  71. package/dist/pi/examples/extensions/with-deps/package-lock.json +2 -2
  72. package/dist/pi/examples/extensions/with-deps/package.json +1 -1
  73. package/dist/pi/examples/tsconfig.json +63 -35
  74. package/dist/pi/package.json +1 -1
  75. package/dist/pi/packages/ta-agents/extension/index.mjs +19 -1
  76. package/dist/pi/packages/ta-agents/lib/agent-bindings.d.ts +2 -0
  77. package/dist/pi/packages/ta-agents/lib/agent-bindings.js +4 -0
  78. package/dist/pi/packages/ta-agents/lib/extension.js +15 -1
  79. package/dist/pi/packages/ta-agents/lib/texts.d.ts +4 -0
  80. package/dist/pi/packages/ta-agents/lib/texts.js +4 -0
  81. package/dist/pi/packages/ta-agents/package.json +3 -3
  82. package/dist/pi/packages/ta-bots/extension/index.mjs +46 -0
  83. package/dist/pi/packages/ta-bots/host/index.mjs +46 -0
  84. package/dist/pi/packages/ta-bots/package.json +1 -1
  85. package/dist/pi/packages/ta-changes/package.json +1 -1
  86. package/dist/pi/packages/ta-channels/README.en.md +2 -2
  87. package/dist/pi/packages/ta-channels/README.md +2 -2
  88. package/dist/pi/packages/ta-channels/host/index.mjs +50 -0
  89. package/dist/pi/packages/ta-channels/lib/create.js +11 -3
  90. package/dist/pi/packages/ta-channels/lib/faces.js +1 -1
  91. package/dist/pi/packages/ta-channels/lib/i18n.d.ts +4 -8
  92. package/dist/pi/packages/ta-channels/lib/i18n.js +8 -16
  93. package/dist/pi/packages/ta-channels/lib/more-menu.d.ts +3 -2
  94. package/dist/pi/packages/ta-channels/lib/more-menu.js +21 -29
  95. package/dist/pi/packages/ta-channels/lib/room.js +13 -8
  96. package/dist/pi/packages/ta-channels/lib/sidebar.js +184 -74
  97. package/dist/pi/packages/ta-channels/lib/style.d.ts +1 -1
  98. package/dist/pi/packages/ta-channels/lib/style.js +83 -37
  99. package/dist/pi/packages/ta-channels/lib/tasks.js +3 -4
  100. package/dist/pi/packages/ta-channels/lib/views.d.ts +49 -1
  101. package/dist/pi/packages/ta-channels/lib/views.js +100 -1
  102. package/dist/pi/packages/ta-channels/package.json +1 -1
  103. package/dist/pi/packages/ta-channels/web/index.js +398 -243
  104. package/dist/pi/packages/ta-computer-use/package.json +2 -2
  105. package/dist/pi/packages/ta-cron/README.en.md +2 -2
  106. package/dist/pi/packages/ta-cron/README.md +2 -2
  107. package/dist/pi/packages/ta-cron/host/index.mjs +6 -0
  108. package/dist/pi/packages/ta-cron/lib/editor.js +60 -27
  109. package/dist/pi/packages/ta-cron/lib/i18n.d.ts +12 -1
  110. package/dist/pi/packages/ta-cron/lib/i18n.js +24 -2
  111. package/dist/pi/packages/ta-cron/lib/page.d.ts +33 -3
  112. package/dist/pi/packages/ta-cron/lib/page.js +119 -4
  113. package/dist/pi/packages/ta-cron/lib/style.d.ts +1 -1
  114. package/dist/pi/packages/ta-cron/lib/style.js +166 -46
  115. package/dist/pi/packages/ta-cron/lib/task-extension.d.ts +15 -0
  116. package/dist/pi/packages/ta-cron/lib/task-extension.js +56 -0
  117. package/dist/pi/packages/ta-cron/lib/task-util.d.ts +2 -0
  118. package/dist/pi/packages/ta-cron/lib/task-util.js +11 -0
  119. package/dist/pi/packages/ta-cron/lib/tasks-view.d.ts +4 -1
  120. package/dist/pi/packages/ta-cron/lib/tasks-view.js +102 -66
  121. package/dist/pi/packages/ta-cron/package.json +1 -1
  122. package/dist/pi/packages/ta-cron/web/index.js +928 -404
  123. package/dist/pi/packages/ta-extensions/README.en.md +3 -1
  124. package/dist/pi/packages/ta-extensions/README.md +3 -1
  125. package/dist/pi/packages/ta-extensions/lib/actions.js +3 -1
  126. package/dist/pi/packages/ta-extensions/lib/composer.d.ts +17 -0
  127. package/dist/pi/packages/ta-extensions/lib/composer.js +84 -0
  128. package/dist/pi/packages/ta-extensions/lib/i18n.d.ts +9 -0
  129. package/dist/pi/packages/ta-extensions/lib/i18n.js +18 -0
  130. package/dist/pi/packages/ta-extensions/lib/index.js +4 -0
  131. package/dist/pi/packages/ta-extensions/lib/make-model.d.ts +20 -0
  132. package/dist/pi/packages/ta-extensions/lib/make-model.js +43 -0
  133. package/dist/pi/packages/ta-extensions/lib/page.js +42 -18
  134. package/dist/pi/packages/ta-extensions/lib/settings.d.ts +4 -0
  135. package/dist/pi/packages/ta-extensions/lib/settings.js +44 -0
  136. package/dist/pi/packages/ta-extensions/lib/style.d.ts +1 -1
  137. package/dist/pi/packages/ta-extensions/lib/style.js +10 -4
  138. package/dist/pi/packages/ta-extensions/package.json +1 -1
  139. package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +7 -3
  140. package/dist/pi/packages/ta-extensions/web/index.js +269 -26
  141. package/dist/pi/packages/ta-launcher/package.json +1 -1
  142. package/dist/pi/packages/ta-workspace/README.md +1 -1
  143. package/dist/pi/packages/ta-workspace/README.zh-cn.md +1 -1
  144. package/dist/pi/packages/ta-workspace/lib/bytes.d.ts +11 -0
  145. package/dist/pi/packages/ta-workspace/lib/bytes.js +40 -0
  146. package/dist/pi/packages/ta-workspace/lib/common.d.ts +2 -1
  147. package/dist/pi/packages/ta-workspace/lib/common.js +15 -37
  148. package/dist/pi/packages/ta-workspace/lib/editors.js +12 -3
  149. package/dist/pi/packages/ta-workspace/lib/i18n.d.ts +1 -2
  150. package/dist/pi/packages/ta-workspace/lib/i18n.js +2 -4
  151. package/dist/pi/packages/ta-workspace/lib/index.js +15 -0
  152. package/dist/pi/packages/ta-workspace/lib/launcher.d.ts +9 -0
  153. package/dist/pi/packages/ta-workspace/lib/launcher.js +39 -0
  154. package/dist/pi/packages/ta-workspace/lib/preview.d.ts +13 -3
  155. package/dist/pi/packages/ta-workspace/lib/preview.js +17 -14
  156. package/dist/pi/packages/ta-workspace/lib/style.d.ts +1 -1
  157. package/dist/pi/packages/ta-workspace/lib/style.js +20 -7
  158. package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts +18 -0
  159. package/dist/pi/packages/ta-workspace/lib/util/keys.js +23 -0
  160. package/dist/pi/packages/ta-workspace/lib/util/preview.d.ts +19 -0
  161. package/dist/pi/packages/ta-workspace/lib/util/preview.js +32 -1
  162. package/dist/pi/packages/ta-workspace/package.json +1 -1
  163. package/dist/pi/packages/ta-workspace/web/index.js +235 -67
  164. package/dist/public/assets/{abnfDiagram-S7VZAUFO-EVMX_yOb.js → abnfDiagram-S7VZAUFO-BmIko5tV.js} +1 -1
  165. package/dist/public/assets/{architecture-WOLXFQ4H-CDgbgZ_o.js → architecture-WOLXFQ4H-XgsdQ7ul.js} +1 -1
  166. package/dist/public/assets/{architectureDiagram-YGSQEFNW-dHreaCWz.js → architectureDiagram-YGSQEFNW--sVhMS03.js} +1 -1
  167. package/dist/public/assets/{blockDiagram-APKKGZFW-D6FhzBDq.js → blockDiagram-APKKGZFW-8f9b-9k2.js} +1 -1
  168. package/dist/public/assets/browser-DOHZ0JCf.js +12 -0
  169. package/dist/public/assets/{c4Diagram-KJ2TOQU5-BFpcr8Cs.js → c4Diagram-KJ2TOQU5-CwYQ0Jfy.js} +1 -1
  170. package/dist/public/assets/{chunk-6MUBBAK2-BczXkMV-.js → chunk-6MUBBAK2-7Y9ezehi.js} +1 -1
  171. package/dist/public/assets/{chunk-AXFCVDMN-CjJsv3jB.js → chunk-AXFCVDMN-CZIH4pWz.js} +1 -1
  172. package/dist/public/assets/{chunk-BG4553SI-FBaleaLz.js → chunk-BG4553SI-DsNATY2m.js} +1 -1
  173. package/dist/public/assets/{chunk-DQASFODM-BFdXY5sX.js → chunk-DQASFODM-CoXkfYE-.js} +1 -1
  174. package/dist/public/assets/{chunk-HFQBQIA3-C5cwK-Fg.js → chunk-HFQBQIA3-C5OLqki8.js} +1 -1
  175. package/dist/public/assets/{chunk-KQLB2F66-BUek3IRk.js → chunk-KQLB2F66-DMHuYGEF.js} +1 -1
  176. package/dist/public/assets/{chunk-KS47KZWR-BxsYBzt6.js → chunk-KS47KZWR-BKeOttO1.js} +1 -1
  177. package/dist/public/assets/{chunk-LEVMRMFU-Bdcwz9fS.js → chunk-LEVMRMFU-D6zCwkk7.js} +1 -1
  178. package/dist/public/assets/{chunk-M57EVK23-kkpP5oug.js → chunk-M57EVK23-B5-QqcZg.js} +1 -1
  179. package/dist/public/assets/{chunk-OY52VR5R-CFhQgxmD.js → chunk-OY52VR5R-DQrq3n0T.js} +1 -1
  180. package/dist/public/assets/{chunk-QB3YPZ4I-BVXqu0eC.js → chunk-QB3YPZ4I-j6ZT7EDR.js} +1 -1
  181. package/dist/public/assets/{chunk-R3KSYZAL-B7SUqqLI.js → chunk-R3KSYZAL-D5MXUO36.js} +1 -1
  182. package/dist/public/assets/{chunk-STOXU5M4-B3abfbnH.js → chunk-STOXU5M4-DaBkw4dD.js} +1 -1
  183. package/dist/public/assets/{chunk-TU62E6Q5-C9NqnUav.js → chunk-TU62E6Q5-vXcRfGci.js} +1 -1
  184. package/dist/public/assets/{chunk-X4PVCEUW-BeLfETDx.js → chunk-X4PVCEUW-CIh6H4Y2.js} +1 -1
  185. package/dist/public/assets/{chunk-XXDRQBXY-DXai1i8p.js → chunk-XXDRQBXY-C_Vwv1FM.js} +1 -1
  186. package/dist/public/assets/{classDiagram-v2-L25IHNXF-Zj6ne_tC.js → classDiagram-v2-L25IHNXF-DccDWEJn.js} +1 -1
  187. package/dist/public/assets/{cose-bilkent-JH36ORCC-C0-TjqfJ.js → cose-bilkent-JH36ORCC-BX47lumZ.js} +1 -1
  188. package/dist/public/assets/cynefin-EF2NZ3EQ-MaI-3dMQ.js +1 -0
  189. package/dist/public/assets/{cynefinDiagram-L36ESFBY-BnqxfzPa.js → cynefinDiagram-L36ESFBY-BE6WOGxW.js} +1 -1
  190. package/dist/public/assets/{d3-selection-DfFLTR9d.js → d3-selection-ZcE6yRN5.js} +1 -1
  191. package/dist/public/assets/{dagre-SPEB5RXH-kI17e5cH.js → dagre-SPEB5RXH-CE6SOOcN.js} +1 -1
  192. package/dist/public/assets/{diagram-3B7GL73J-DgPjeLA5.js → diagram-3B7GL73J-xC8VtiYL.js} +1 -1
  193. package/dist/public/assets/{diagram-DNEMPZML-CRhPfa0I.js → diagram-DNEMPZML-4dmcBbjL.js} +1 -1
  194. package/dist/public/assets/{diagram-L3MUGCDN-ExuTg12b.js → diagram-L3MUGCDN-D14Yn3sQ.js} +1 -1
  195. package/dist/public/assets/{diagram-LA4NIPWU-Dgx5xNiY.js → diagram-LA4NIPWU-GxSXIhsK.js} +1 -1
  196. package/dist/public/assets/{diagram-MHCOC4E2-BuifkUTl.js → diagram-MHCOC4E2-Cm7Prlpc.js} +1 -1
  197. package/dist/public/assets/{diagram-XPFHEONP-CFEaBo7z.js → diagram-XPFHEONP-mkUnnKFu.js} +1 -1
  198. package/dist/public/assets/{dist-C-iJHcSK.js → dist-acJS-BlA.js} +1 -1
  199. package/dist/public/assets/{ebnfDiagram-UZSYDL2S-D-hp5yNt.js → ebnfDiagram-UZSYDL2S-m77ua3UQ.js} +1 -1
  200. package/dist/public/assets/{editor.api-BopUWpqY.js → editor.api-CljTm-EQ.js} +1 -1
  201. package/dist/public/assets/{elk-XV6XMXQE-CBbk_IpU.js → elk-XV6XMXQE-DsQY1hw9.js} +1 -1
  202. package/dist/public/assets/{erDiagram-EYBAPDEH-B02R_WWE.js → erDiagram-EYBAPDEH-CV8gJM0P.js} +1 -1
  203. package/dist/public/assets/{eventmodeling-K75KTNOO-aCZfYnCI.js → eventmodeling-K75KTNOO-C1pymbUr.js} +1 -1
  204. package/dist/public/assets/flowDiagram-MALGAFMO-shBnAQFk.js +1 -0
  205. package/dist/public/assets/{freemarker2-DMN60LeK.js → freemarker2-DYJXaMHN.js} +1 -1
  206. package/dist/public/assets/{ganttDiagram-23REXITY-DioU8TlD.js → ganttDiagram-23REXITY-CppxOWRh.js} +1 -1
  207. package/dist/public/assets/gitGraph-VSP46ZUC-BtQWboBz.js +1 -0
  208. package/dist/public/assets/{gitGraphDiagram-STJD7YCW--q3ctg6y.js → gitGraphDiagram-STJD7YCW-CrQrZhcP.js} +1 -1
  209. package/dist/public/assets/{handlebars-B_-qdvpB.js → handlebars-DZCnH9e2.js} +1 -1
  210. package/dist/public/assets/{html-BN8Ah3Js.js → html-DuzouNES.js} +1 -1
  211. package/dist/public/assets/{index-B3A--ac8.js → index-B7OYKvCE.js} +2 -2
  212. package/dist/public/assets/info-OHQRW6UA-CDSLjba_.js +1 -0
  213. package/dist/public/assets/{infoDiagram-KBXO4MBG-CGXteYo9.js → infoDiagram-KBXO4MBG-6pby19tQ.js} +1 -1
  214. package/dist/public/assets/{ishikawaDiagram-M35NCXHK-DM2LmOAc.js → ishikawaDiagram-M35NCXHK-Duf8c8rQ.js} +1 -1
  215. package/dist/public/assets/{javascript-BlizGb0q.js → javascript-2d_L6cVd.js} +1 -1
  216. package/dist/public/assets/{journeyDiagram-OPLOXDXO-CNITRtGl.js → journeyDiagram-OPLOXDXO-Dvv-xzNo.js} +1 -1
  217. package/dist/public/assets/{jsonMode-CEUmT5sN.js → jsonMode-CFadYXyI.js} +1 -1
  218. package/dist/public/assets/{kanban-definition-BZKZHSQY-BPUuS9um.js → kanban-definition-BZKZHSQY-Dsk6F-TT.js} +1 -1
  219. package/dist/public/assets/{liquid-BbyLjUbE.js → liquid-Din4CF34.js} +1 -1
  220. package/dist/public/assets/{mdx-DiQz7Q35.js → mdx-DivDuCWI.js} +1 -1
  221. package/dist/public/assets/{mermaid-parser.core-Dum100hC.js → mermaid-parser.core-BfCv4CYZ.js} +3 -3
  222. package/dist/public/assets/{mermaid.core-BWmWf6XO.js → mermaid.core-DC20ZwJj.js} +4 -4
  223. package/dist/public/assets/{mindmap-definition-I2QAS2VK-L8HyYUDY.js → mindmap-definition-I2QAS2VK-DRZRrJU_.js} +1 -1
  224. package/dist/public/assets/module-BAQaY56j.js +1 -0
  225. package/dist/public/assets/module-DxRGg3ED.js +1947 -0
  226. package/dist/public/assets/{monaco-zOOyBmxy.js → monaco-D1d6MOPe.js} +3 -3
  227. package/dist/public/assets/packet-JDAUHWVQ-dYb4P9eU.js +1 -0
  228. package/dist/public/assets/{pegDiagram-FD4XPPHP-CTZKPo0Z.js → pegDiagram-FD4XPPHP-DcGr3Tbk.js} +1 -1
  229. package/dist/public/assets/pie-XZMESJXO-CIompBnc.js +1 -0
  230. package/dist/public/assets/{pieDiagram-J4AKIIQI-DAeT3dFi.js → pieDiagram-J4AKIIQI-GF7pu6ch.js} +1 -1
  231. package/dist/public/assets/{python-C984gt98.js → python-BQbTTTT5.js} +1 -1
  232. package/dist/public/assets/{quadrantDiagram-XTYBLID2--PXxwV1Z.js → quadrantDiagram-XTYBLID2-D-bcu7Ey.js} +1 -1
  233. package/dist/public/assets/radar-ABXABTNO-DiJl7BtK.js +1 -0
  234. package/dist/public/assets/railroad-I3PHUGI6-B5cRBukM.js +1 -0
  235. package/dist/public/assets/{railroad-abnf-LNEFI6M7-BYcFfrCa.js → railroad-abnf-LNEFI6M7-BiBHsI-K.js} +1 -1
  236. package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-Cd33qxAm.js → railroad-ebnf-DWYD2UWJ-zKjrfkHs.js} +1 -1
  237. package/dist/public/assets/{railroad-peg-JR7BVNR7-C5TpzaU8.js → railroad-peg-JR7BVNR7-DKuVn0GT.js} +1 -1
  238. package/dist/public/assets/{railroadDiagram-MRQ6NCDL-DlWwjbhH.js → railroadDiagram-MRQ6NCDL-Cyn-16mJ.js} +1 -1
  239. package/dist/public/assets/{razor-BBqMR1Qn.js → razor-DiLk54O0.js} +1 -1
  240. package/dist/public/assets/{requirementDiagram-Y7LWUY3S-CsYBy9HS.js → requirementDiagram-Y7LWUY3S-CwU2EBkW.js} +1 -1
  241. package/dist/public/assets/{sankeyDiagram-WGJFYUXA-Baxyb5p9.js → sankeyDiagram-WGJFYUXA-ajf00HyW.js} +1 -1
  242. package/dist/public/assets/{sequenceDiagram-5NDRBG5M-Cq6VeBT_.js → sequenceDiagram-5NDRBG5M-DiX_OIAw.js} +1 -1
  243. package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-O60WKaE7.js → stateDiagram-v2-FJ4FJNEA-CV5bRqB7.js} +1 -1
  244. package/dist/public/assets/{swimlanes-UMQ2AFYF-C2nf1-Cc.js → swimlanes-UMQ2AFYF-BGQKSlj7.js} +1 -1
  245. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-DxXlavVT.js +8 -0
  246. package/dist/public/assets/{timeline-definition-SEUHKTQE-DEfUG6YH.js → timeline-definition-SEUHKTQE-DhQoApff.js} +1 -1
  247. package/dist/public/assets/treeView-D4JQ5SDB-BOP6mkZC.js +1 -0
  248. package/dist/public/assets/treemap-SAJKECNS-BJxuPMz3.js +1 -0
  249. package/dist/public/assets/{typescript-Gtq7f0aU.js → typescript-COQ1g-up.js} +1 -1
  250. package/dist/public/assets/{usecaseDiagram-AFA6YXN4-Gw9DyJcx.js → usecaseDiagram-AFA6YXN4-CmLFzjie.js} +1 -1
  251. package/dist/public/assets/{vennDiagram-NNMJR3RB-Clb3MLWF.js → vennDiagram-NNMJR3RB-DOa6JR5K.js} +1 -1
  252. package/dist/public/assets/wardley-7MLQ67FV-jqlowjVL.js +1 -0
  253. package/dist/public/assets/{wardleyDiagram-S7YFUSEH-BrTRpwu2.js → wardleyDiagram-S7YFUSEH-BV7EEShp.js} +1 -1
  254. package/dist/public/assets/{xml-Bx3nk7iG.js → xml-BbvtjuaG.js} +1 -1
  255. package/dist/public/assets/{xychartDiagram-GGNKY7IX-BfjTcIsb.js → xychartDiagram-GGNKY7IX-DtMpPbsq.js} +1 -1
  256. package/dist/public/assets/{yaml-dFLE_rSl.js → yaml-Bw8NFga9.js} +1 -1
  257. package/dist/public/index.html +1 -1
  258. package/dist/public/launch.svg +46 -42
  259. package/dist/serve/index.mjs +1354 -555
  260. package/package.json +25 -25
  261. package/dist/pi/dist/bundle/chunks/anthropic-messages-BWGCKOF4.js +0 -6
  262. package/dist/pi/dist/bundle/chunks/chunk-44DLKSKE.js +0 -1232
  263. package/dist/pi/dist/bundle/chunks/chunk-62VOPMLK.js +0 -65
  264. package/dist/pi/dist/bundle/chunks/chunk-7O7QKK6A.js +0 -2
  265. package/dist/pi/dist/bundle/chunks/chunk-CHWNPHIS.js +0 -82
  266. package/dist/pi/dist/bundle/chunks/chunk-NL4X6LBY.js +0 -4
  267. package/dist/pi/dist/bundle/chunks/chunk-NZY7EIPA.js +0 -4
  268. package/dist/pi/dist/bundle/chunks/chunk-R2EGYMOO.js +0 -7
  269. package/dist/pi/dist/bundle/chunks/chunk-UKVNB6C4.js +0 -2
  270. package/dist/pi/dist/bundle/chunks/chunk-USJZMAIR.js +0 -2
  271. package/dist/pi/dist/bundle/chunks/chunk-VOLAXWGI.js +0 -2
  272. package/dist/pi/dist/bundle/chunks/openai-codex-responses-QAWLOQSN.js +0 -10
  273. package/dist/pi/dist/bundle/chunks/openai-responses-MD3562FB.js +0 -4
  274. package/dist/pi/dist/bundle/chunks/virtual-modules-O76XM3OB.js +0 -2
  275. package/dist/public/assets/browser-y6EDNUmc.js +0 -12
  276. package/dist/public/assets/cynefin-EF2NZ3EQ-CoY4CrZu.js +0 -1
  277. package/dist/public/assets/flowDiagram-MALGAFMO-CATkJShO.js +0 -1
  278. package/dist/public/assets/gitGraph-VSP46ZUC-g4yHXXxx.js +0 -1
  279. package/dist/public/assets/info-OHQRW6UA-CKADJjz4.js +0 -1
  280. package/dist/public/assets/module-CH7IXa5L.js +0 -1781
  281. package/dist/public/assets/module-DNAasuMC.js +0 -1
  282. package/dist/public/assets/packet-JDAUHWVQ-CpKMhX4K.js +0 -1
  283. package/dist/public/assets/pie-XZMESJXO-CW-zGDRd.js +0 -1
  284. package/dist/public/assets/radar-ABXABTNO-Cg8W433p.js +0 -1
  285. package/dist/public/assets/railroad-I3PHUGI6-DriMt2PQ.js +0 -1
  286. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-B46JxqS8.js +0 -8
  287. package/dist/public/assets/treeView-D4JQ5SDB-1LhEWwC9.js +0 -1
  288. package/dist/public/assets/treemap-SAJKECNS-D3t3N7nS.js +0 -1
  289. package/dist/public/assets/wardley-7MLQ67FV-D3sAsd8p.js +0 -1
@@ -1,6 +1,7 @@
1
1
  // web-src/cron-protocol.ts
2
2
  var NAME = "@celljs/ta-cron";
3
3
  var REPLY_TYPE = "ta-cron";
4
+ var RUN_MARK = "<ta-cron-run>";
4
5
  var Keys;
5
6
  ((Keys) => {
6
7
  Keys.TASKS = "tasks";
@@ -50,7 +51,6 @@ var EN = {
50
51
  name: "Name",
51
52
  namePlaceholder: "Optional",
52
53
  when: "When",
53
- repeat: "Repeat",
54
54
  once: "Once",
55
55
  every: "Every",
56
56
  daily: "Daily",
@@ -98,7 +98,19 @@ var EN = {
98
98
  show: "Show",
99
99
  failedAction: "Could not do it: {message}",
100
100
  help: "Scheduled tasks",
101
- serviceNeeded: "Scheduled tasks run in the Ta service."
101
+ serviceNeeded: "Scheduled tasks run in the Ta service.",
102
+ makeExtension: "Make an extension",
103
+ makeExtensionHint: "Ta makes a page of its own for what this task finds",
104
+ extensionAsk: 'Make the scheduled task "{name}" an extension that shows its results',
105
+ promptLabel: "What Ta does",
106
+ showAll: "Show all",
107
+ showLess: "Show less",
108
+ stats: "Ran {runs} times",
109
+ statsFailed: "Ran {runs} times · {fails} failed",
110
+ lastRun: "Last {time}",
111
+ moreOptions: "More options",
112
+ shortcut: "{key} + Enter to {action}",
113
+ modelFailed: "The model for making extensions ({model}) cannot be used, so the default one is: {message}"
102
114
  };
103
115
  var ZH = {
104
116
  title: "定时任务",
@@ -129,7 +141,6 @@ var ZH = {
129
141
  name: "名字",
130
142
  namePlaceholder: "可不填",
131
143
  when: "时间",
132
- repeat: "重复",
133
144
  once: "一次",
134
145
  every: "每隔",
135
146
  daily: "每天",
@@ -177,7 +188,19 @@ var ZH = {
177
188
  show: "查看",
178
189
  failedAction: "操作失败:{message}",
179
190
  help: "定时任务",
180
- serviceNeeded: "定时任务在 Ta 服务里运行。"
191
+ serviceNeeded: "定时任务在 Ta 服务里运行。",
192
+ makeExtension: "做成扩展",
193
+ makeExtensionHint: "让 Ta 为这个任务的结果做一个专属页面",
194
+ extensionAsk: "把定时任务“{name}”做成扩展,用专属页面呈现它的运行结果",
195
+ promptLabel: "Ta 要做的事",
196
+ showAll: "展开全文",
197
+ showLess: "收起",
198
+ stats: "已运行 {runs} 次",
199
+ statsFailed: "已运行 {runs} 次 · 失败 {fails} 次",
200
+ lastRun: "上次 {time}",
201
+ moreOptions: "更多选项",
202
+ shortcut: "{key} + 回车{action}",
203
+ modelFailed: "做扩展的模型({model})现在用不了,已改用默认模型:{message}"
181
204
  };
182
205
  var CronWords;
183
206
  ((CronWords) => {
@@ -191,193 +214,6 @@ var CronWords;
191
214
  CronWords.format = format;
192
215
  })(CronWords ||= {});
193
216
 
194
- // web-src/page.ts
195
- var pi;
196
- var PAGE = `${NAME}/tasks`;
197
- function bindPage(api) {
198
- pi = api;
199
- }
200
- function t(key, values = {}) {
201
- return CronWords.format(CronWords.of(pi.ui.language)[key], values);
202
- }
203
- function icon(name) {
204
- return pi.ui.icons[name] ?? pi.ui.icons.Square;
205
- }
206
- function message(error) {
207
- return error instanceof Error ? error.message : String(error);
208
- }
209
- function until(time, now = Date.now()) {
210
- const minutes = Math.max(1, Math.round((time - now) / 60000));
211
- const zh = pi.ui.language === "zh-CN";
212
- const [amount, unit] = minutes < 60 ? [minutes, "minute"] : minutes < 48 * 60 ? [Math.round(minutes / 60), "hour"] : [Math.round(minutes / 1440), "day"];
213
- if (zh) {
214
- return `${amount} ${{ minute: "分钟", hour: "小时", day: "天" }[unit]}`;
215
- }
216
- return `${amount} ${unit}${amount === 1 ? "" : "s"}`;
217
- }
218
- function basename(path) {
219
- return path.replace(/[\\/]+$/, "").split(/[\\/]/).pop() || path;
220
- }
221
-
222
- class CronClient {
223
- api;
224
- state = { tasks: [], loaded: false, runs: {}, asks: 0 };
225
- listeners = new Set;
226
- stop;
227
- constructor(api) {
228
- this.api = api;
229
- }
230
- start() {
231
- this.stop = this.api.storage.onChange((keys) => {
232
- if (keys.includes(Keys.TASKS)) {
233
- this.load();
234
- }
235
- for (const key of keys) {
236
- const id = key.startsWith("runs/") ? key.slice(5) : undefined;
237
- if (id && this.state.runs[id]) {
238
- this.loadRuns(id);
239
- }
240
- }
241
- });
242
- this.load();
243
- }
244
- dispose() {
245
- this.stop?.();
246
- this.listeners.clear();
247
- }
248
- subscribe(listener) {
249
- this.listeners.add(listener);
250
- return () => this.listeners.delete(listener);
251
- }
252
- askNew() {
253
- this.set({ asks: this.state.asks + 1 });
254
- }
255
- async load() {
256
- await this.api.storage.get(Keys.TASKS).catch(() => {
257
- return;
258
- });
259
- const tasks = await this.api.callHost("list");
260
- this.set({ tasks, loaded: true });
261
- }
262
- async loadRuns(taskId) {
263
- await this.api.storage.get(Keys.runs(taskId)).catch(() => {
264
- return;
265
- });
266
- const runs = await this.api.callHost("runs", taskId);
267
- this.set({ runs: { ...this.state.runs, [taskId]: runs } });
268
- }
269
- call(method, ...params) {
270
- return this.api.callHost(method, ...params);
271
- }
272
- set(change) {
273
- this.state = { ...this.state, ...change };
274
- for (const listener of this.listeners) {
275
- listener();
276
- }
277
- }
278
- }
279
- async function openRun(run) {
280
- if (!run.sessionFile) {
281
- pi.ui.notify(t("noChat"), "warning");
282
- return;
283
- }
284
- try {
285
- const open = (await pi.server.listSessions()).find((session) => session.sessionFile === run.sessionFile);
286
- const sessionId = open?.sessionId ?? (await pi.server.openSession({ cwd: run.cwd, sessionFile: run.sessionFile, group: NAME })).sessionId;
287
- await pi.switchSession(sessionId);
288
- pi.ui.showView("");
289
- } catch (error) {
290
- pi.ui.notify(t("failedAction", { message: message(error) }), "error");
291
- }
292
- }
293
-
294
- // web-src/react.ts
295
- var React;
296
- function bind(react) {
297
- React = react;
298
- }
299
-
300
- // web-src/next-card.tsx
301
- var SHOWN = 3;
302
- function nextTasks(tasks, shown = SHOWN) {
303
- const at = (task) => task.lastStatus === "running" ? 0 : task.nextRunAt ? new Date(task.nextRunAt).getTime() : Number.POSITIVE_INFINITY;
304
- return tasks.filter((task) => task.lastStatus === "running" || task.enabled && task.nextRunAt).sort((a, b) => at(a) - at(b)).slice(0, shown);
305
- }
306
- function NextCard({ client }) {
307
- const { tasks, loaded } = React.useSyncExternalStore((listener) => client.subscribe(listener), () => client.state);
308
- const [now, setNow] = React.useState(Date.now());
309
- React.useEffect(() => {
310
- const timer = setInterval(() => setNow(Date.now()), 30000);
311
- return () => clearInterval(timer);
312
- }, []);
313
- if (!loaded) {
314
- return /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
315
- rows: 2
316
- });
317
- }
318
- const next = nextTasks(tasks);
319
- if (next.length === 0) {
320
- return /* @__PURE__ */ React.createElement(pi.ui.Empty, {
321
- title: t("cardEmpty"),
322
- compact: true
323
- });
324
- }
325
- return /* @__PURE__ */ React.createElement("div", {
326
- className: "tcr-card"
327
- }, next.map((task) => /* @__PURE__ */ React.createElement("button", {
328
- key: task.id,
329
- type: "button",
330
- className: "tcr-card-row",
331
- onClick: () => pi.ui.showView(PAGE)
332
- }, /* @__PURE__ */ React.createElement("span", {
333
- className: "tcr-card-name"
334
- }, task.name), /* @__PURE__ */ React.createElement("span", {
335
- className: "tcr-card-when"
336
- }, task.lastStatus === "running" ? t("running") : t("next", { time: until(new Date(task.nextRunAt ?? now).getTime(), now) })))));
337
- }
338
-
339
- // web-src/notifier.ts
340
- var FRESH_MS = 2 * 60000;
341
- function watchRuns() {
342
- const told = new Set;
343
- let ready = false;
344
- const tell = async () => {
345
- const finished = await pi.storage.get(Keys.LATEST).catch(() => {
346
- return;
347
- });
348
- const run = finished?.run;
349
- if (!run || told.has(run.id)) {
350
- return;
351
- }
352
- told.add(run.id);
353
- const ended = run.endedAt ? new Date(run.endedAt).getTime() : 0;
354
- if (!ready || !finished.notify || Date.now() - ended > FRESH_MS) {
355
- return;
356
- }
357
- const failed = run.status !== "success";
358
- const title = t(failed ? "failed" : "finished", { name: finished.taskName });
359
- pi.ui.notify(title, failed ? "error" : "info");
360
- if (typeof document !== "undefined" && document.hidden && typeof Notification !== "undefined" && Notification.permission === "granted") {
361
- const body = (run.error ?? run.summary ?? "").split(`
362
- `)[0].slice(0, 160);
363
- const notice = new Notification(title, { body, tag: run.id });
364
- notice.onclick = () => {
365
- window.focus();
366
- pi.ui.showView(PAGE);
367
- notice.close();
368
- };
369
- }
370
- };
371
- tell().finally(() => {
372
- ready = true;
373
- });
374
- return pi.storage.onChange((keys) => {
375
- if (keys.includes(Keys.LATEST)) {
376
- tell();
377
- }
378
- });
379
- }
380
-
381
217
  // web-src/cron-expression.ts
382
218
  var FIELDS = [
383
219
  { name: "minute", min: 0, max: 59 },
@@ -509,6 +345,7 @@ class CronExpression {
509
345
 
510
346
  // web-src/schedule-util.ts
511
347
  var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
348
+ var NOTIFY_LEVELS = ["always", "error", "never"];
512
349
  var UNITS = {
513
350
  s: 1000,
514
351
  sec: 1000,
@@ -641,75 +478,395 @@ var ScheduleUtil;
641
478
  function shouldNotify(level, failed) {
642
479
  return level === "always" || level === "error" && failed;
643
480
  }
644
- ScheduleUtil.shouldNotify = shouldNotify;
645
- function clock(time, now = new Date) {
646
- const day = `${time.getMonth() + 1}/${time.getDate()}`;
647
- const year = time.getFullYear() === now.getFullYear() ? "" : `${time.getFullYear()}/`;
648
- return `${year}${day} ${pad(time.getHours())}:${pad(time.getMinutes())}`;
481
+ ScheduleUtil.shouldNotify = shouldNotify;
482
+ function clock(time, now = new Date) {
483
+ const day = `${time.getMonth() + 1}/${time.getDate()}`;
484
+ const year = time.getFullYear() === now.getFullYear() ? "" : `${time.getFullYear()}/`;
485
+ return `${year}${day} ${pad(time.getHours())}:${pad(time.getMinutes())}`;
486
+ }
487
+ ScheduleUtil.clock = clock;
488
+ function describe(schedule, language, now = new Date) {
489
+ const words = WORDS[language.startsWith("zh") ? "zh" : "en"];
490
+ switch (schedule.kind) {
491
+ case "once":
492
+ return words.once(clock(new Date(schedule.at), now));
493
+ case "interval":
494
+ return describeInterval(schedule.every, words);
495
+ case "cron":
496
+ return describeCron(schedule.expression, words);
497
+ }
498
+ }
499
+ ScheduleUtil.describe = describe;
500
+ function describeInterval(every, words) {
501
+ const ms = Duration.parse(every) ?? 0;
502
+ for (const [unit, size] of [
503
+ ["day", 86400000],
504
+ ["hour", 3600000],
505
+ ["minute", 60000]
506
+ ]) {
507
+ if (ms >= size && ms % size === 0) {
508
+ return words.every(ms / size, unit);
509
+ }
510
+ }
511
+ return words.everyRaw(every);
512
+ }
513
+ function describeCron(expression, words) {
514
+ const fields = (NICKNAMES[expression.toLowerCase()] ?? expression).split(" ");
515
+ const [minute, hour, day, month, weekday] = fields;
516
+ const number = (text) => /^\d+$/.test(text) ? Number(text) : undefined;
517
+ const m = number(minute);
518
+ const h = number(hour);
519
+ const time = m !== undefined && h !== undefined ? `${pad(h)}:${pad(m)}` : undefined;
520
+ if (month === "*") {
521
+ if (time && day === "*" && weekday === "*") {
522
+ return words.daily(time);
523
+ }
524
+ if (time && day === "*" && weekday === "1-5") {
525
+ return words.weekdays(time);
526
+ }
527
+ const d = number(weekday);
528
+ if (time && day === "*" && d !== undefined && d <= 7) {
529
+ return words.weekly(d % 7, time);
530
+ }
531
+ const date = number(day);
532
+ if (time && date !== undefined && weekday === "*") {
533
+ return words.monthly(date, time);
534
+ }
535
+ if (m !== undefined && hour === "*" && day === "*" && weekday === "*") {
536
+ return words.hourly(m);
537
+ }
538
+ const everyMinutes = /^\*\/(\d+)$/.exec(minute);
539
+ if (everyMinutes && hour === "*" && day === "*" && weekday === "*") {
540
+ return words.every(Number(everyMinutes[1]), "minute");
541
+ }
542
+ const everyHours = /^\*\/(\d+)$/.exec(hour);
543
+ if (m === 0 && everyHours && day === "*" && weekday === "*") {
544
+ return words.every(Number(everyHours[1]), "hour");
545
+ }
546
+ }
547
+ return words.cron(expression);
548
+ }
549
+ })(ScheduleUtil ||= {});
550
+
551
+ // web-src/task-extension.ts
552
+ var PROMPT_MAX = 4000;
553
+ var ANSWER_MAX = 2000;
554
+ var TaskExtension;
555
+ ((TaskExtension) => {
556
+ function message(task, runs, language) {
557
+ const words = CronWords.of(language);
558
+ return `<context>
559
+ ${context(task, runs)}
560
+ </context>
561
+ ${CronWords.format(words.extensionAsk, { name: task.name })}`;
562
+ }
563
+ TaskExtension.message = message;
564
+ function context(task, runs) {
565
+ const answer = runs?.find((run) => run.status === "success" && run.summary)?.summary;
566
+ const lines = [
567
+ `The user wants the scheduled task "${task.name}" made into an extension of Ta, with the ta-package skill, kept in extensions/:`,
568
+ "- a page that shows the results of its runs in a form that suits them (a list by severity, figures, a state, what changed since the run before) rather than as the text of a run, where the user goes through past runs, runs it now and turns it on or off;",
569
+ '- a card of the board (location "board") with the latest result at a glance, when that is useful.',
570
+ "",
571
+ `The task goes on running on its schedule in @celljs/ta-cron: the extension reads and drives it with pi.packages.callPackageHost('@celljs/ta-cron', method, params), as the skill says, and schedules nothing of its own.`,
572
+ 'Where the results need structure, have each run end its answer with a fenced json block of a shape you choose, the whole answer under 4000 characters (what a run keeps of it), and have the page read that block, showing runs from before as text. Change the prompt of the task for it with schedule_task (action "update"); without that tool, give the user the new prompt to paste in the Edit dialog of the task.',
573
+ "",
574
+ `Task: ${task.id}, ${ScheduleUtil.describe(task.schedule, "en-US")}, in ${task.cwd}, ${task.enabled ? "on" : "off"}, ran ${task.runCount} times (${task.failCount} failed).`,
575
+ "Its prompt:",
576
+ fence(clip(task.prompt, PROMPT_MAX))
577
+ ];
578
+ if (answer) {
579
+ lines.push("What its last run answered:", fence(clip(answer, ANSWER_MAX)));
580
+ }
581
+ return lines.join(`
582
+ `);
583
+ }
584
+ TaskExtension.context = context;
585
+ function clip(text, max) {
586
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;
587
+ }
588
+ function fence(text) {
589
+ const longest = Math.max(2, ...Array.from(text.matchAll(/`+/g), (match) => match[0].length));
590
+ const marks = "`".repeat(longest + 1);
591
+ return `${marks}
592
+ ${text}
593
+ ${marks}`;
594
+ }
595
+ })(TaskExtension ||= {});
596
+
597
+ // web-src/page.ts
598
+ var pi;
599
+ var PAGE = `${NAME}/tasks`;
600
+ var EXTENSIONS = "@celljs/ta-extensions";
601
+ function bindPage(api) {
602
+ pi = api;
603
+ }
604
+ function t(key, values = {}) {
605
+ return CronWords.format(CronWords.of(pi.ui.language)[key], values);
606
+ }
607
+ function icon(name) {
608
+ return pi.ui.icons[name] ?? pi.ui.icons.Square;
609
+ }
610
+ function message(error) {
611
+ return error instanceof Error ? error.message : String(error);
612
+ }
613
+ function until(time, now = Date.now()) {
614
+ const minutes = Math.max(1, Math.round((time - now) / 60000));
615
+ const zh = pi.ui.language === "zh-CN";
616
+ const [amount, unit] = minutes < 60 ? [minutes, "minute"] : minutes < 48 * 60 ? [Math.round(minutes / 60), "hour"] : [Math.round(minutes / 1440), "day"];
617
+ if (zh) {
618
+ return `${amount} ${{ minute: "分钟", hour: "小时", day: "天" }[unit]}`;
619
+ }
620
+ return `${amount} ${unit}${amount === 1 ? "" : "s"}`;
621
+ }
622
+ function basename(path) {
623
+ return path.replace(/[\\/]+$/, "").split(/[\\/]/).pop() || path;
624
+ }
625
+
626
+ class CronClient {
627
+ api;
628
+ state = { tasks: [], loaded: false, runs: {} };
629
+ listeners = new Set;
630
+ newAsks = new Set;
631
+ writing = new Set;
632
+ reading;
633
+ again = false;
634
+ stop;
635
+ constructor(api) {
636
+ this.api = api;
637
+ }
638
+ start() {
639
+ this.stop = this.api.storage.onChange((keys) => {
640
+ if (keys.includes(Keys.TASKS)) {
641
+ this.load();
642
+ }
643
+ for (const key of keys) {
644
+ const id = key.startsWith("runs/") ? key.slice(5) : undefined;
645
+ if (id && this.state.runs[id]) {
646
+ this.loadRuns(id);
647
+ }
648
+ }
649
+ });
650
+ this.load();
651
+ }
652
+ dispose() {
653
+ this.stop?.();
654
+ this.listeners.clear();
655
+ this.newAsks.clear();
656
+ }
657
+ subscribe(listener) {
658
+ this.listeners.add(listener);
659
+ return () => this.listeners.delete(listener);
660
+ }
661
+ askNew() {
662
+ for (const listener of this.newAsks) {
663
+ listener();
664
+ }
665
+ }
666
+ onAskNew(listener) {
667
+ this.newAsks.add(listener);
668
+ return () => {
669
+ this.newAsks.delete(listener);
670
+ };
671
+ }
672
+ async load() {
673
+ if (this.reading) {
674
+ this.again = true;
675
+ return this.reading;
676
+ }
677
+ this.reading = this.read();
678
+ try {
679
+ await this.reading;
680
+ } finally {
681
+ this.reading = undefined;
682
+ if (this.again) {
683
+ this.again = false;
684
+ this.load();
685
+ }
686
+ }
687
+ }
688
+ async read() {
689
+ await this.api.storage.get(Keys.TASKS).catch(() => {
690
+ return;
691
+ });
692
+ const tasks = await this.api.callHost("list");
693
+ if (this.writing.size === 0) {
694
+ this.set({ tasks, loaded: true });
695
+ }
696
+ }
697
+ async loadRuns(taskId) {
698
+ await this.api.storage.get(Keys.runs(taskId)).catch(() => {
699
+ return;
700
+ });
701
+ const runs = await this.api.callHost("runs", taskId);
702
+ this.set({ runs: { ...this.state.runs, [taskId]: runs } });
703
+ }
704
+ call(method, ...params) {
705
+ return this.api.callHost(method, ...params);
706
+ }
707
+ setEnabled(id, enabled) {
708
+ return this.change(id, (task) => ({ ...task, enabled }), () => this.call("setEnabled", id, enabled));
709
+ }
710
+ runNow(id) {
711
+ return this.change(id, (task) => ({ ...task, lastStatus: "running" }), () => this.call("run", id));
712
+ }
713
+ remove(id) {
714
+ return this.change(id, () => {
715
+ return;
716
+ }, async () => {
717
+ await this.call("remove", id);
718
+ const { [id]: _gone, ...runs } = this.state.runs;
719
+ this.set({ runs });
720
+ });
721
+ }
722
+ async change(id, patch, send) {
723
+ const before = this.state.tasks;
724
+ this.writing.add(id);
725
+ this.set({ tasks: before.map((task) => task.id === id ? patch(task) : task).filter((task) => task !== undefined) });
726
+ try {
727
+ await send();
728
+ } catch (error) {
729
+ this.set({ tasks: before });
730
+ throw error;
731
+ } finally {
732
+ this.writing.delete(id);
733
+ }
734
+ await this.load();
735
+ }
736
+ set(change) {
737
+ this.state = { ...this.state, ...change };
738
+ for (const listener of this.listeners) {
739
+ listener();
740
+ }
741
+ }
742
+ }
743
+ async function openRun(run) {
744
+ if (!run.sessionFile) {
745
+ pi.ui.notify(t("noChat"), "warning");
746
+ return;
747
+ }
748
+ try {
749
+ const open = (await pi.server.listSessions()).find((session) => session.sessionFile === run.sessionFile);
750
+ const sessionId = open?.sessionId ?? (await pi.server.openSession({ cwd: run.cwd, sessionFile: run.sessionFile, group: NAME })).sessionId;
751
+ await pi.switchSession(sessionId);
752
+ pi.ui.showView("");
753
+ } catch (error) {
754
+ pi.ui.notify(t("failedAction", { message: message(error) }), "error");
755
+ }
756
+ }
757
+ async function openMaking(cwd) {
758
+ const model = await pi.packages.getExtensionData(EXTENSIONS, "makeModel").catch(() => {
759
+ return;
760
+ });
761
+ if (typeof model === "string" && model) {
762
+ try {
763
+ return (await pi.server.openSession({ cwd, model })).sessionId;
764
+ } catch (error) {
765
+ pi.ui.notify(t("modelFailed", { model, message: message(error) }), "warning");
766
+ }
767
+ }
768
+ return (await pi.server.openSession({ cwd })).sessionId;
769
+ }
770
+ async function makeExtension(task, runs) {
771
+ try {
772
+ const { cwd } = await pi.server.getServerInfo();
773
+ const sessionId = openMaking(cwd);
774
+ await pi.switchSession(sessionId, { title: t("makeExtension"), cwd });
775
+ await pi.server.prompt(await sessionId, {
776
+ clientMessageId: `ta-cron-extension:${task.id}:${Date.now()}`,
777
+ message: TaskExtension.message(task, runs, pi.ui.language)
778
+ });
779
+ } catch (error) {
780
+ pi.ui.notify(t("failedAction", { message: message(error) }), "error");
781
+ }
782
+ }
783
+
784
+ // web-src/react.ts
785
+ var React;
786
+ function bind(react) {
787
+ React = react;
788
+ }
789
+
790
+ // web-src/next-card.tsx
791
+ var SHOWN = 3;
792
+ function nextTasks(tasks, shown = SHOWN) {
793
+ const at = (task) => task.lastStatus === "running" ? 0 : task.nextRunAt ? new Date(task.nextRunAt).getTime() : Number.POSITIVE_INFINITY;
794
+ return tasks.filter((task) => task.lastStatus === "running" || task.enabled && task.nextRunAt).sort((a, b) => at(a) - at(b)).slice(0, shown);
795
+ }
796
+ function NextCard({ client }) {
797
+ const { tasks, loaded } = React.useSyncExternalStore((listener) => client.subscribe(listener), () => client.state);
798
+ const [now, setNow] = React.useState(Date.now());
799
+ React.useEffect(() => {
800
+ const timer = setInterval(() => setNow(Date.now()), 30000);
801
+ return () => clearInterval(timer);
802
+ }, []);
803
+ if (!loaded) {
804
+ return /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
805
+ rows: 2
806
+ });
649
807
  }
650
- ScheduleUtil.clock = clock;
651
- function describe(schedule, language, now = new Date) {
652
- const words = WORDS[language.startsWith("zh") ? "zh" : "en"];
653
- switch (schedule.kind) {
654
- case "once":
655
- return words.once(clock(new Date(schedule.at), now));
656
- case "interval":
657
- return describeInterval(schedule.every, words);
658
- case "cron":
659
- return describeCron(schedule.expression, words);
660
- }
808
+ const next = nextTasks(tasks);
809
+ if (next.length === 0) {
810
+ return /* @__PURE__ */ React.createElement(pi.ui.Empty, {
811
+ title: t("cardEmpty"),
812
+ compact: true
813
+ });
661
814
  }
662
- ScheduleUtil.describe = describe;
663
- function describeInterval(every, words) {
664
- const ms = Duration.parse(every) ?? 0;
665
- for (const [unit, size] of [
666
- ["day", 86400000],
667
- ["hour", 3600000],
668
- ["minute", 60000]
669
- ]) {
670
- if (ms >= size && ms % size === 0) {
671
- return words.every(ms / size, unit);
672
- }
815
+ return /* @__PURE__ */ React.createElement("div", {
816
+ className: "tcr-card"
817
+ }, next.map((task) => /* @__PURE__ */ React.createElement("button", {
818
+ key: task.id,
819
+ type: "button",
820
+ className: "tcr-card-row",
821
+ onClick: () => pi.ui.showView(PAGE)
822
+ }, /* @__PURE__ */ React.createElement("span", {
823
+ className: "tcr-card-name"
824
+ }, task.name), /* @__PURE__ */ React.createElement("span", {
825
+ className: "tcr-card-when"
826
+ }, task.lastStatus === "running" ? t("running") : t("next", { time: until(new Date(task.nextRunAt ?? now).getTime(), now) })))));
827
+ }
828
+
829
+ // web-src/notifier.ts
830
+ var FRESH_MS = 2 * 60000;
831
+ function watchRuns() {
832
+ const told = new Set;
833
+ let ready = false;
834
+ const tell = async () => {
835
+ const finished = await pi.storage.get(Keys.LATEST).catch(() => {
836
+ return;
837
+ });
838
+ const run = finished?.run;
839
+ if (!run || told.has(run.id)) {
840
+ return;
673
841
  }
674
- return words.everyRaw(every);
675
- }
676
- function describeCron(expression, words) {
677
- const fields = (NICKNAMES[expression.toLowerCase()] ?? expression).split(" ");
678
- const [minute, hour, day, month, weekday] = fields;
679
- const number = (text) => /^\d+$/.test(text) ? Number(text) : undefined;
680
- const m = number(minute);
681
- const h = number(hour);
682
- const time = m !== undefined && h !== undefined ? `${pad(h)}:${pad(m)}` : undefined;
683
- if (month === "*") {
684
- if (time && day === "*" && weekday === "*") {
685
- return words.daily(time);
686
- }
687
- if (time && day === "*" && weekday === "1-5") {
688
- return words.weekdays(time);
689
- }
690
- const d = number(weekday);
691
- if (time && day === "*" && d !== undefined && d <= 7) {
692
- return words.weekly(d % 7, time);
693
- }
694
- const date = number(day);
695
- if (time && date !== undefined && weekday === "*") {
696
- return words.monthly(date, time);
697
- }
698
- if (m !== undefined && hour === "*" && day === "*" && weekday === "*") {
699
- return words.hourly(m);
700
- }
701
- const everyMinutes = /^\*\/(\d+)$/.exec(minute);
702
- if (everyMinutes && hour === "*" && day === "*" && weekday === "*") {
703
- return words.every(Number(everyMinutes[1]), "minute");
704
- }
705
- const everyHours = /^\*\/(\d+)$/.exec(hour);
706
- if (m === 0 && everyHours && day === "*" && weekday === "*") {
707
- return words.every(Number(everyHours[1]), "hour");
708
- }
842
+ told.add(run.id);
843
+ const ended = run.endedAt ? new Date(run.endedAt).getTime() : 0;
844
+ if (!ready || !finished.notify || Date.now() - ended > FRESH_MS) {
845
+ return;
709
846
  }
710
- return words.cron(expression);
711
- }
712
- })(ScheduleUtil ||= {});
847
+ const failed = run.status !== "success";
848
+ const title = t(failed ? "failed" : "finished", { name: finished.taskName });
849
+ pi.ui.notify(title, failed ? "error" : "info");
850
+ if (typeof document !== "undefined" && document.hidden && typeof Notification !== "undefined" && Notification.permission === "granted") {
851
+ const body = (run.error ?? run.summary ?? "").split(`
852
+ `)[0].slice(0, 160);
853
+ const notice = new Notification(title, { body, tag: run.id });
854
+ notice.onclick = () => {
855
+ window.focus();
856
+ pi.ui.showView(PAGE);
857
+ notice.close();
858
+ };
859
+ }
860
+ };
861
+ tell().finally(() => {
862
+ ready = true;
863
+ });
864
+ return pi.storage.onChange((keys) => {
865
+ if (keys.includes(Keys.LATEST)) {
866
+ tell();
867
+ }
868
+ });
869
+ }
713
870
 
714
871
  // web-src/commands.ts
715
872
  var FLAG_NAMES = ["name", "notify", "model", "thinking", "cwd"];
@@ -1023,74 +1180,118 @@ function ReplyMessage({ message: message2 }) {
1023
1180
 
1024
1181
  // web-src/style.ts
1025
1182
  var STYLE = `
1183
+ /* The card of the board: the tasks to run next */
1026
1184
  .tcr-card { display: flex; flex-direction: column; margin: -4px -6px; }
1027
1185
  .tcr-card-row { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 6px; border: 0; border-radius: 8px; background: none; color: var(--ta-text); font: inherit; text-align: left; cursor: pointer; }
1028
1186
  .tcr-card-row:hover { background: var(--ta-hover); }
1029
1187
  .tcr-card-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(14px * var(--ta-font-scale)); }
1030
1188
  .tcr-card-when { flex: none; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
1031
- .tcr-page { box-sizing: border-box; width: 100%; max-width: 860px; margin: 0 auto; padding: 20px 24px 48px; }
1032
- .tcr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 32px; }
1189
+
1190
+ /* The page: it scrolls in its own box, which takes what the main area has left under its head. */
1191
+ .tcr-scroll { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
1192
+ .tcr-page { box-sizing: border-box; width: 100%; max-width: 860px; margin: 0 auto; padding: 20px 24px 64px; }
1193
+ .tcr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-height: 28px; }
1033
1194
  .tcr-stat { color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); }
1034
1195
  /* The head: the title in the middle, the + at the right, a box of the same width on the left to keep it there. */
1035
1196
  .tcr-title-bar { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; padding-left: 36px; }
1036
- .tcr-button { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--ta-border); border-radius: 8px; background: transparent; color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); font-weight: 500; cursor: pointer; transition: background 120ms, opacity 120ms, transform 120ms var(--ta-ease); }
1197
+
1198
+ /* Buttons and what is written quietly */
1199
+ .tcr-button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border: 1px solid var(--ta-border); border-radius: 8px; background: var(--ta-card); color: var(--ta-text); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); font-weight: 500; white-space: nowrap; cursor: pointer; transition: background 120ms, border-color 120ms, opacity 120ms, transform 120ms var(--ta-ease); }
1037
1200
  .tcr-button:hover:not(:disabled) { background: var(--ta-hover); }
1038
- .tcr-button:active:not(:disabled) { transform: scale(.98); }
1201
+ .tcr-button:active:not(:disabled) { transform: scale(.97); }
1039
1202
  .tcr-button:disabled { opacity: .45; cursor: default; }
1203
+ .tcr-button > svg { flex: none; color: var(--ta-secondary); }
1040
1204
  .tcr-primary { background: var(--ta-brand); border-color: var(--ta-brand); color: var(--ta-brand-text); }
1041
1205
  .tcr-primary:hover:not(:disabled) { background: var(--ta-brand); opacity: .88; }
1206
+ /* What hands the task to Ta to make more of: green, as what Ta makes. */
1207
+ .tcr-accent { border-color: color-mix(in srgb, var(--ta-green) 45%, var(--ta-border)); background: color-mix(in srgb, var(--ta-green) 9%, var(--ta-card)); }
1208
+ .tcr-accent > svg { color: var(--ta-green); }
1209
+ .tcr-accent:hover:not(:disabled) { background: color-mix(in srgb, var(--ta-green) 16%, var(--ta-card)); }
1042
1210
  .tcr-link { align-self: flex-start; border: 0; padding: 0; background: none; color: var(--ta-link); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; }
1043
1211
  .tcr-link:hover { text-decoration: underline; }
1044
- .tcr-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: 7px; background: none; color: var(--ta-muted); cursor: pointer; }
1212
+ .tcr-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: 7px; background: none; color: var(--ta-muted); cursor: pointer; transition: background 120ms, color 120ms; }
1045
1213
  .tcr-icon:hover { background: var(--ta-hover); color: var(--ta-text); }
1046
1214
  .tcr-muted { color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
1047
1215
  .tcr-pad { padding: 6px 2px; }
1048
1216
  .tcr-chip { flex: none; padding: 0 7px; border-radius: 6px; background: var(--ta-chip); color: var(--ta-secondary); font-size: calc(11.5px * var(--ta-font-scale)); line-height: calc(20px * var(--ta-font-scale)); white-space: nowrap; }
1049
- .tcr-list { display: flex; flex-direction: column; gap: 8px; }
1050
- .tcr-task { border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-card); transition: border-color 120ms, box-shadow 160ms; animation: tcr-in 200ms var(--ta-ease) both; }
1217
+ .tcr-count { margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--ta-chip); color: var(--ta-secondary); font-size: calc(11px * var(--ta-font-scale)); font-weight: 500; line-height: calc(17px * var(--ta-font-scale)); }
1218
+ .tcr-chevron { display: inline-flex; flex: none; color: var(--ta-muted); transition: transform 180ms var(--ta-ease); }
1219
+
1220
+ /* The tasks */
1221
+ .tcr-list { display: flex; flex-direction: column; gap: 10px; }
1222
+ .tcr-task { border: 1px solid var(--ta-border-muted); border-radius: 14px; background: var(--ta-card); transition: border-color 140ms, box-shadow 180ms; animation: tcr-in 160ms var(--ta-ease) both; }
1051
1223
  .tcr-task:hover, .tcr-task.tcr-open { border-color: var(--ta-border); }
1052
- .tcr-task.tcr-menu-open { position: relative; z-index: 5; }
1053
1224
  .tcr-task.tcr-open { box-shadow: var(--ta-shadow-pop); }
1054
- .tcr-disabled .tcr-task-name, .tcr-disabled .tcr-chip { opacity: .55; }
1055
- @keyframes tcr-in { from { opacity: 0; transform: translateY(4px); } }
1056
- .tcr-task-row { display: flex; align-items: center; gap: 6px; padding: 0 8px 0 0; }
1057
- .tcr-task-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; height: 52px; padding: 0 6px 0 16px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
1058
- .tcr-task-name { min-width: 0; overflow: hidden; font-size: calc(14px * var(--ta-font-scale)); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
1059
- .tcr-task-dir { flex: 1; min-width: 0; overflow: hidden; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); text-overflow: ellipsis; white-space: nowrap; }
1225
+ .tcr-disabled .tcr-task-name, .tcr-disabled .tcr-task-meta, .tcr-disabled .tcr-task-state, .tcr-disabled .tcr-mark { opacity: .55; }
1226
+ .tcr-task-row { display: flex; align-items: center; gap: 6px; padding-right: 10px; }
1227
+ /* What opens the task: the mark of its state, its name over its rule, directory and last run, then its next run. */
1228
+ .tcr-task-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; min-height: 64px; padding: 10px 6px 10px 14px; border: 0; border-radius: 14px 0 0 14px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; outline: none; }
1229
+ .tcr-task-main:focus-visible { box-shadow: inset 0 0 0 2px var(--ta-border-focus); }
1230
+ /* A tile of the color of the task's state, its last run a dot at its corner. */
1231
+ .tcr-mark { position: relative; flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--ta-chip); color: var(--ta-secondary); }
1232
+ .tcr-mark .tcr-dot { position: absolute; right: -2px; bottom: -2px; box-shadow: 0 0 0 2.5px var(--ta-card); }
1233
+ .tcr-tone-success { background: color-mix(in srgb, var(--ta-green) 14%, transparent); color: var(--ta-green); }
1234
+ .tcr-tone-error, .tcr-tone-missed { background: color-mix(in srgb, var(--ta-red) 13%, transparent); color: var(--ta-red); }
1235
+ .tcr-tone-running { background: color-mix(in srgb, var(--ta-blue) 15%, transparent); color: var(--ta-blue); }
1236
+ .tcr-task-text { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
1237
+ .tcr-task-meta { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
1238
+ .tcr-task-name { min-width: 0; overflow: hidden; font-size: calc(14.5px * var(--ta-font-scale)); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
1239
+ .tcr-task-dir { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1240
+ .tcr-task-last { flex: none; white-space: nowrap; }
1241
+ .tcr-task-next { display: none; flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
1242
+ .tcr-task-last::before { content: '·'; margin-right: 8px; }
1060
1243
  .tcr-task-state { flex: none; color: var(--ta-secondary); font-size: calc(12.5px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
1061
1244
  .tcr-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ta-border); }
1062
1245
  .tcr-success { background: var(--ta-green); }
1063
1246
  .tcr-error, .tcr-missed { background: var(--ta-red); }
1064
1247
  .tcr-running { background: var(--ta-blue); animation: tcr-pulse 1.2s ease-in-out infinite; }
1065
- .tcr-off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ta-border); }
1248
+ .tcr-off { background: var(--ta-card); box-shadow: inset 0 0 0 1.5px var(--ta-border); }
1066
1249
  .tcr-pulse { animation: tcr-fade 1.6s ease-in-out infinite; }
1067
- @keyframes tcr-pulse { 50% { transform: scale(1.5); opacity: .5; } }
1250
+ @keyframes tcr-in { from { opacity: 0; transform: translateY(3px); } }
1251
+ @keyframes tcr-pulse { 50% { transform: scale(1.4); opacity: .55; } }
1068
1252
  @keyframes tcr-fade { 50% { opacity: .45; } }
1069
- .tcr-switch { position: relative; flex: none; width: 30px; height: 18px; cursor: pointer; }
1253
+
1254
+ /* The switch of a task: as the switches of the page */
1255
+ .tcr-switch { position: relative; flex: none; width: 36px; height: 20px; cursor: pointer; }
1070
1256
  .tcr-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
1071
- .tcr-switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--ta-border); transition: background 160ms; pointer-events: none; }
1072
- .tcr-switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 180ms var(--ta-ease); }
1257
+ .tcr-switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--ta-hover-strong, var(--ta-border)); transition: background 160ms; pointer-events: none; }
1258
+ .tcr-switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform 180ms var(--ta-ease); }
1073
1259
  .tcr-switch input:checked + span { background: var(--ta-green); }
1074
- .tcr-switch input:checked + span::after { transform: translateX(12px); }
1260
+ .tcr-switch input:checked + span::after { transform: translateX(16px); }
1075
1261
  .tcr-switch input:focus-visible + span { outline: 2px solid var(--ta-border-focus); outline-offset: 2px; }
1076
- .tcr-more { position: relative; }
1077
- .tcr-menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: 30; min-width: 150px; padding: 4px; border: 1px solid var(--ta-border-muted); border-radius: 10px; background: var(--ta-raised); box-shadow: var(--ta-shadow-pop); animation: tcr-in 120ms var(--ta-ease); }
1078
- .tcr-menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; background: none; color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); text-align: left; cursor: pointer; }
1079
- .tcr-menu-item:hover { background: var(--ta-hover); }
1080
- .tcr-danger { color: var(--ta-red); }
1081
- .tcr-detail { padding: 2px 16px 14px 34px; animation: tcr-in 160ms var(--ta-ease); }
1082
- .tcr-prompt-text { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--ta-chip); color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); line-height: 1.55; white-space: pre-wrap; max-height: 160px; overflow: auto; }
1083
- .tcr-label { margin: 0 0 6px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); font-weight: 500; }
1084
- .tcr-run { border-radius: 8px; }
1262
+
1263
+ /* What a task holds, opened: what can be done with it, its prompt and its runs */
1264
+ .tcr-detail { display: flex; flex-direction: column; margin: 0 16px; padding: 14px 0 16px; border-top: 1px solid var(--ta-border-muted); animation: tcr-in 160ms var(--ta-ease); }
1265
+ .tcr-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
1266
+ .tcr-stats { margin-left: auto; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
1267
+ .tcr-label { display: flex; align-items: center; margin: 0 0 8px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); font-weight: 500; }
1268
+ .tcr-prompt-block { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
1269
+ .tcr-prompt-text { padding: 10px 12px; border-radius: 10px; background: var(--ta-chip); color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
1270
+ /* A long prompt: four lines (of 13px at 1.6), fading into the box, until the user shows the rest. */
1271
+ .tcr-clamped { max-height: calc(83px * var(--ta-font-scale)); overflow: hidden; }
1272
+ .tcr-fade { -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent); mask-image: linear-gradient(to bottom, #000 60%, transparent); }
1273
+ /* The runs: a line of time down their dots, the newest at the top. */
1274
+ .tcr-runs { position: relative; display: flex; flex-direction: column; gap: 2px; }
1275
+ .tcr-run { position: relative; border-radius: 10px; transition: background 140ms; }
1276
+ .tcr-run::before { content: ''; position: absolute; left: 13px; top: 22px; bottom: -6px; width: 1.5px; background: var(--ta-border-muted); }
1277
+ .tcr-run.tcr-last::before { display: none; }
1085
1278
  .tcr-run.tcr-open { background: var(--ta-hover); }
1086
- .tcr-run-head { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; font-size: calc(13px * var(--ta-font-scale)); text-align: left; cursor: pointer; }
1279
+ .tcr-run-head { position: relative; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 4px 10px; border: 0; border-radius: 10px; background: none; color: inherit; font: inherit; font-size: calc(13px * var(--ta-font-scale)); text-align: left; cursor: pointer; outline: none; }
1087
1280
  .tcr-run-head:hover { background: var(--ta-hover); }
1281
+ .tcr-run-head:focus-visible { box-shadow: inset 0 0 0 2px var(--ta-border-focus); }
1282
+ .tcr-run-head .tcr-dot { position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--ta-card); }
1283
+ .tcr-run.tcr-open .tcr-run-head .tcr-dot, .tcr-run-head:hover .tcr-dot { box-shadow: none; }
1088
1284
  .tcr-run-time { flex: none; font-variant-numeric: tabular-nums; }
1089
1285
  .tcr-run-status { flex: none; color: var(--ta-secondary); }
1286
+ .tcr-is-error, .tcr-is-missed { color: var(--ta-red); }
1090
1287
  .tcr-run-line { flex: 1; min-width: 0; overflow: hidden; color: var(--ta-muted); text-overflow: ellipsis; white-space: nowrap; }
1091
- .tcr-run-body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 2px 10px 12px 26px; font-size: calc(13.5px * var(--ta-font-scale)); }
1092
- .tcr-run-body > :first-child { align-self: stretch; }
1288
+ .tcr-open > .tcr-run-head .tcr-chevron { transform: rotate(90deg); }
1289
+ .tcr-run-head:not(:hover) .tcr-chevron { opacity: .6; }
1290
+ .tcr-run-body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 2px 14px 14px 30px; font-size: calc(13.5px * var(--ta-font-scale)); animation: tcr-in 140ms var(--ta-ease); }
1291
+ .tcr-run-body > :first-child { align-self: stretch; min-width: 0; overflow-wrap: anywhere; }
1093
1292
  .tcr-run-error { color: var(--ta-red); white-space: pre-wrap; }
1293
+
1294
+ /* The page without tasks */
1094
1295
  .tcr-empty { display: flex; flex-direction: column; align-items: center; padding: 48px 0 24px; text-align: center; }
1095
1296
  .tcr-empty-title { margin-top: 14px; font-size: calc(17px * var(--ta-font-scale)); font-weight: 600; }
1096
1297
  .tcr-empty-hint { margin-top: 6px; color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); }
@@ -1102,35 +1303,111 @@ var STYLE = `
1102
1303
  .tcr-clock-pin { fill: var(--ta-green); }
1103
1304
  @keyframes tcr-spin { to { transform: rotate(360deg); } }
1104
1305
  .tcr-examples { width: 100%; max-width: 560px; margin-top: 26px; }
1105
- @media (max-width: 640px) { .tcr-task-dir { display: none; } .tcr-page { padding: 16px 12px 40px; } }
1106
- .tcr-form { box-sizing: border-box; display: flex; flex-direction: column; gap: 16px; width: 100%; min-height: 0; overflow-y: auto; padding: 4px 2px 2px; }
1306
+
1307
+ /*
1308
+ * The dialog of a task: wider than the page's dialogs, for the row of rules; its fields scroll under the
1309
+ * title while its buttons stay at its foot.
1310
+ */
1311
+ .ta-web-dialog:has(> .tcr-form) { width: min(560px, 100%); max-height: min(84vh, 780px); padding-bottom: 0; }
1312
+ .tcr-form { box-sizing: border-box; display: flex; flex-direction: column; flex: 1; min-height: 0; margin: 0 -18px; }
1313
+ .tcr-form-body { display: flex; flex-direction: column; gap: 18px; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px 18px; }
1107
1314
  .tcr-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
1108
1315
  .tcr-field .tcr-label { margin: 0; }
1109
- .tcr-input { box-sizing: border-box; width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--ta-border-field); border-radius: 8px; background: var(--ta-input); color: var(--ta-text); font: inherit; font-size: calc(13.5px * var(--ta-font-scale)); outline: none; transition: border-color 120ms; }
1110
- .tcr-input:focus { border-color: var(--ta-border-focus); }
1111
- .tcr-prompt { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
1316
+ .tcr-input { box-sizing: border-box; width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--ta-border-field); border-radius: 8px; background: var(--ta-input); color: var(--ta-text); font: inherit; font-size: calc(13.5px * var(--ta-font-scale)); outline: none; transition: border-color 120ms, box-shadow 120ms; }
1317
+ .tcr-input:focus { border-color: var(--ta-border-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ta-border-focus) 18%, transparent); }
1318
+ .tcr-prompt { height: auto; min-height: 104px; padding: 9px 11px; line-height: 1.55; resize: vertical; }
1112
1319
  .tcr-mono { font-family: var(--ta-mono); }
1113
1320
  .tcr-amount { width: 90px; flex: none; }
1114
1321
  .tcr-row { display: flex; gap: 8px; }
1115
- .tcr-segments { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--ta-chip); align-self: flex-start; max-width: 100%; overflow-x: auto; }
1116
- .tcr-segment { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--ta-secondary); font: inherit; font-size: calc(13px * var(--ta-font-scale)); white-space: nowrap; cursor: pointer; transition: background 140ms, color 140ms; }
1117
- .tcr-segment[aria-pressed='true'] { background: var(--ta-raised); color: var(--ta-text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
1118
- .tcr-preview { color: var(--ta-green); font-size: calc(12.5px * var(--ta-font-scale)); }
1119
- .tcr-preview.tcr-bad { color: var(--ta-red); }
1120
- .tcr-folder { display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; }
1322
+ .tcr-segments { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--ta-chip); align-self: stretch; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
1323
+ .tcr-segment { flex: 1 0 auto; height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--ta-secondary); font: inherit; font-size: calc(13px * var(--ta-font-scale)); white-space: nowrap; cursor: pointer; transition: background 140ms, color 140ms, box-shadow 140ms; }
1324
+ .tcr-segment:hover:not([aria-pressed='true']) { color: var(--ta-text); }
1325
+ .tcr-segment[aria-pressed='true'] { background: var(--ta-raised); color: var(--ta-text); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.14), 0 0 0 .5px var(--ta-border-muted); }
1326
+ .tcr-preview { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ta-green) 11%, transparent); color: var(--ta-green); font-size: calc(12.5px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
1327
+ .tcr-preview.tcr-bad { background: color-mix(in srgb, var(--ta-red) 11%, transparent); color: var(--ta-red); }
1328
+ .tcr-folder { display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; }
1329
+ .tcr-folder:hover { border-color: var(--ta-border); background: var(--ta-hover); }
1330
+ .tcr-folder > svg { flex: none; color: var(--ta-muted); }
1331
+ .tcr-folder-name { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1121
1332
  .tcr-folder-path { flex: 1; min-width: 0; overflow: hidden; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: right; }
1122
1333
  .tcr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
1123
1334
  .tcr-wide { grid-column: 1 / -1; }
1124
- .tcr-actions { display: flex; justify-content: flex-end; gap: 8px; }
1335
+ .tcr-options { display: flex; flex-direction: column; gap: 12px; }
1336
+ .tcr-more-toggle { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; margin-left: -4px; padding: 2px 6px 2px 4px; border: 0; border-radius: 6px; background: none; color: var(--ta-secondary); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; }
1337
+ .tcr-more-toggle:hover { background: var(--ta-hover); color: var(--ta-text); }
1338
+ .tcr-more-toggle .tcr-chevron { transform: rotate(-90deg); }
1339
+ .tcr-options.tcr-open .tcr-more-toggle .tcr-chevron { transform: none; }
1340
+ .tcr-options .tcr-grid { animation: tcr-in 140ms var(--ta-ease); }
1341
+ .tcr-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--ta-border-muted); }
1342
+ .tcr-actions .tcr-button { height: 32px; padding: 0 14px; font-size: calc(13px * var(--ta-font-scale)); }
1343
+ .tcr-shortcut { margin-right: auto; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
1344
+
1345
+ /* A task in a conversation, as a command or the tool answers */
1125
1346
  .tcr-reply { margin: 4px 0; padding: 10px 12px; border: 1px solid var(--ta-border-muted); border-radius: 10px; background: var(--ta-card); font-size: calc(13px * var(--ta-font-scale)); }
1126
1347
  .tcr-reply-head { display: flex; align-items: center; gap: 8px; color: var(--ta-secondary); }
1127
1348
  .tcr-reply-head svg { color: var(--ta-green); }
1128
1349
  .tcr-reply-head .tcr-link { margin-left: auto; }
1129
1350
  .tcr-reply-task { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
1130
- .tcr-reply .tcr-prompt-text { margin: 8px 0 0; }
1351
+ .tcr-reply .tcr-prompt-text { margin: 8px 0 0; max-height: 160px; overflow: auto; }
1131
1352
  .tcr-reply-error { color: var(--ta-red); }
1132
1353
  .tcr-help { margin: 8px 0 0; font-family: var(--ta-mono); font-size: calc(12px * var(--ta-font-scale)); line-height: 1.6; white-space: pre-wrap; color: var(--ta-secondary); }
1133
- @media (prefers-reduced-motion: reduce) { .tcr-clock-hand, .tcr-running, .tcr-pulse { animation: none; } }
1354
+
1355
+ /*
1356
+ * A phone (device/device-protocol.ts: data-layout): the name of a task over its rule and its next run,
1357
+ * so that the name is not cut to nothing by the rest; everything a finger taps is a finger's size.
1358
+ */
1359
+ [data-layout='compact'] .tcr-page { padding: 12px 10px 48px; }
1360
+ [data-layout='compact'] .tcr-head { margin-bottom: 8px; min-height: 24px; }
1361
+ [data-layout='compact'] .tcr-list { gap: 8px; }
1362
+ [data-layout='compact'] .tcr-task-row { gap: 2px; padding-right: 6px; }
1363
+ [data-layout='compact'] .tcr-task-main { gap: 10px; min-height: 68px; padding: 12px 2px 12px 12px; }
1364
+ [data-layout='compact'] .tcr-mark { width: 34px; height: 34px; }
1365
+ [data-layout='compact'] .tcr-task-name { font-size: calc(15px * var(--ta-font-scale)); }
1366
+ [data-layout='compact'] .tcr-task-dir, [data-layout='compact'] .tcr-task-last { display: none; }
1367
+ [data-layout='compact'] .tcr-task-state { display: none; }
1368
+ [data-layout='compact'] .tcr-task-next { display: inline; }
1369
+ [data-layout='compact'] .tcr-chip { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
1370
+ [data-layout='compact'] .tcr-detail { margin: 0 12px; padding: 12px 0 14px; }
1371
+ [data-layout='compact'] .tcr-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px 14px; padding: 0 12px; }
1372
+ [data-layout='compact'] .tcr-stats { display: none; }
1373
+ [data-layout='compact'] .tcr-run-head { flex-wrap: wrap; row-gap: 2px; padding: 8px; }
1374
+ /* What a run answered goes under its time rather than past it, where a phone has no room. */
1375
+ [data-layout='compact'] .tcr-run-line { box-sizing: border-box; flex: 1 1 100%; order: 9; padding-left: 18px; }
1376
+ [data-layout='compact'] .tcr-run::before { left: 11px; }
1377
+ [data-layout='compact'] .tcr-run-body { padding: 2px 10px 12px 14px; }
1378
+ [data-layout='compact'] .tcr-empty { padding: 32px 0 16px; }
1379
+ [data-layout='compact'] .tcr-clock { width: 92px; height: 92px; }
1380
+ [data-layout='compact'] .tcr-examples { margin-top: 20px; }
1381
+ [data-layout='compact'] .tcr-grid { grid-template-columns: 1fr; }
1382
+ [data-layout='compact'] .tcr-form-body { gap: 16px; }
1383
+ [data-layout='compact'] .ta-web-dialog:has(> .tcr-form) { max-height: min(92dvh, calc(100% - 8px - env(safe-area-inset-top))); }
1384
+ [data-layout='compact'] .tcr-actions { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
1385
+ [data-layout='compact'] .tcr-actions .tcr-button { flex: 1; justify-content: center; }
1386
+
1387
+ /* A finger: a target of its own size around what is drawn (44px), and the press showing at once. */
1388
+ [data-touch] .tcr-icon { width: 36px; height: 36px; border-radius: 10px; }
1389
+ [data-touch] .tcr-icon::after { content: ''; position: absolute; inset: -4px; }
1390
+ [data-touch] .tcr-icon:hover { background: none; }
1391
+ [data-touch] .tcr-icon:active { background: var(--ta-hover); color: var(--ta-text); }
1392
+ [data-touch] .tcr-switch::after { content: ''; position: absolute; inset: -12px -6px; }
1393
+ [data-touch] .tcr-task-main:active { background: var(--ta-hover); }
1394
+ [data-touch] .tcr-run-head { min-height: 44px; }
1395
+ [data-touch] .tcr-run-head:hover { background: none; }
1396
+ [data-touch] .tcr-run-head:active { background: var(--ta-hover); }
1397
+ [data-touch] .tcr-button { height: 36px; padding: 0 14px; }
1398
+ [data-touch] .tcr-segment { height: 32px; }
1399
+ [data-touch] .tcr-more-toggle { padding: 8px 6px 8px 4px; font-size: max(15px, calc(13.5px * var(--ta-font-scale))); }
1400
+ /* A link of the dialog, which a finger taps too: a line of its own height. */
1401
+ [data-touch] .tcr-link { padding: 8px 0; font-size: max(16px, calc(13.5px * var(--ta-font-scale))); }
1402
+ /* Under 16px iOS zooms into the field it focuses, which loses the dialog around it: never smaller. */
1403
+ [data-touch] .tcr-input { font-size: max(16px, calc(13.5px * var(--ta-font-scale))); }
1404
+ [data-touch] .tcr-folder { height: auto; min-height: 40px; padding: 6px 10px; }
1405
+ [data-touch] .tcr-folder-path { font-size: max(16px, calc(12px * var(--ta-font-scale))); }
1406
+
1407
+ @media (prefers-reduced-motion: reduce) {
1408
+ .tcr-task, .tcr-detail, .tcr-run-body, .tcr-clock-hand, .tcr-running, .tcr-pulse, .tcr-options .tcr-grid { animation: none; }
1409
+ .tcr-chevron { transition: none; }
1410
+ }
1134
1411
  `;
1135
1412
  function injectStyle() {
1136
1413
  const element = document.createElement("style");
@@ -1263,9 +1540,23 @@ var NOTIFY = [
1263
1540
  ["error", "notifyError"],
1264
1541
  ["never", "notifyNever"]
1265
1542
  ];
1543
+ var DAY_NAMES = new Map;
1266
1544
  function weekdayNames() {
1267
- const format = new Intl.DateTimeFormat(pi.ui.language === "zh-CN" ? "zh-CN" : "en", { weekday: "short" });
1268
- return Array.from({ length: 7 }, (_, day) => format.format(new Date(2023, 0, 1 + day)));
1545
+ const language = pi.ui.language;
1546
+ let names = DAY_NAMES.get(language);
1547
+ if (!names) {
1548
+ const format = new Intl.DateTimeFormat(language === "zh-CN" ? "zh-CN" : "en", { weekday: "short" });
1549
+ names = Array.from({ length: 7 }, (_, day) => format.format(new Date(2023, 0, 1 + day)));
1550
+ DAY_NAMES.set(language, names);
1551
+ }
1552
+ return names;
1553
+ }
1554
+ function ruleKey(form) {
1555
+ return [form.mode, form.repeat, form.amount, form.unit, form.time, form.weekday, form.cron, form.at].join("|");
1556
+ }
1557
+ function usePreview(form) {
1558
+ const key = ruleKey(form);
1559
+ return React.useMemo(() => FormUtil.preview(form, new Date), [key]);
1269
1560
  }
1270
1561
  function Segments({ value, options, onChange }) {
1271
1562
  return /* @__PURE__ */ React.createElement("div", {
@@ -1307,7 +1598,7 @@ function ModelFields({ form, set, cwd }) {
1307
1598
  }, level)))));
1308
1599
  }
1309
1600
  function When({ form, set }) {
1310
- const preview = FormUtil.preview(form, new Date);
1601
+ const preview = usePreview(form);
1311
1602
  const days = weekdayNames();
1312
1603
  let rule = null;
1313
1604
  if (form.mode === "once") {
@@ -1358,24 +1649,24 @@ function When({ form, set }) {
1358
1649
  onChange: (event) => set({ time: event.target.value })
1359
1650
  }));
1360
1651
  }
1652
+ const kind = form.mode === "once" ? "once" : form.repeat;
1653
+ const kinds = [...REPEATS.map((repeat) => [repeat, t(repeat)]), ["once", t("once")]];
1654
+ const Clock = icon("Clock");
1655
+ const bad = !preview.next;
1361
1656
  return /* @__PURE__ */ React.createElement("div", {
1362
1657
  className: "tcr-field"
1363
1658
  }, /* @__PURE__ */ React.createElement("div", {
1364
1659
  className: "tcr-label"
1365
1660
  }, t("when")), /* @__PURE__ */ React.createElement(Segments, {
1366
- value: form.mode,
1367
- options: [
1368
- ["repeat", t("repeat")],
1369
- ["once", t("once")]
1370
- ],
1371
- onChange: (mode) => set({ mode })
1372
- }), form.mode === "repeat" && /* @__PURE__ */ React.createElement(Segments, {
1373
- value: form.repeat,
1374
- options: REPEATS.map((kind) => [kind, t(kind)]),
1375
- onChange: (repeat) => set({ repeat })
1661
+ value: kind,
1662
+ options: kinds,
1663
+ onChange: (next) => set(next === "once" ? { mode: "once" } : { mode: "repeat", repeat: next })
1376
1664
  }), rule, /* @__PURE__ */ React.createElement("div", {
1377
- className: `tcr-preview${preview.error === undefined ? "" : " tcr-bad"}`
1378
- }, preview.next ? t("preview", { time: ScheduleUtil.clock(preview.next) }) : preview.error || t("noNext")));
1665
+ className: `tcr-preview${bad ? " tcr-bad" : ""}`,
1666
+ role: "status"
1667
+ }, /* @__PURE__ */ React.createElement(Clock, {
1668
+ size: 13
1669
+ }), preview.next ? t("preview", { time: ScheduleUtil.clock(preview.next) }) : preview.error || t("noNext")));
1379
1670
  }
1380
1671
  function TaskEditor({ client, editing, onClose }) {
1381
1672
  const Dialog = pi.ui.Dialog;
@@ -1392,8 +1683,10 @@ function TaskEditor({ client, editing, onClose }) {
1392
1683
  const [picking, setPicking] = React.useState(false);
1393
1684
  const [more, setMore] = React.useState(!!(form.name && editing.task) || !!form.notify);
1394
1685
  const [saving, setSaving] = React.useState(false);
1686
+ const touch = pi.ui.useDevice().touch;
1395
1687
  const set = (change) => setForm((current) => ({ ...current, ...change }));
1396
- const valid = form.prompt.trim().length > 0 && !!FormUtil.preview(form, new Date).next;
1688
+ const preview = usePreview(form);
1689
+ const valid = form.prompt.trim().length > 0 && !!preview.next;
1397
1690
  const save = async () => {
1398
1691
  if (!valid || saving) {
1399
1692
  return;
@@ -1418,21 +1711,26 @@ function TaskEditor({ client, editing, onClose }) {
1418
1711
  setSaving(false);
1419
1712
  }
1420
1713
  };
1714
+ const Folder = icon("Folder");
1715
+ const Chevron = icon("ChevronDown");
1716
+ const key = /Mac|iPhone|iPad/.test(navigator.platform) ? "⌘" : "Ctrl";
1421
1717
  return /* @__PURE__ */ React.createElement(Dialog, {
1422
1718
  title: editing.task ? t("editTask") : t("newTask"),
1423
1719
  onClose
1424
1720
  }, /* @__PURE__ */ React.createElement("div", {
1425
1721
  className: "tcr-form"
1722
+ }, /* @__PURE__ */ React.createElement("div", {
1723
+ className: "tcr-form-body"
1426
1724
  }, /* @__PURE__ */ React.createElement("label", {
1427
1725
  className: "tcr-field"
1428
1726
  }, /* @__PURE__ */ React.createElement("span", {
1429
1727
  className: "tcr-label"
1430
1728
  }, t("prompt")), /* @__PURE__ */ React.createElement("textarea", {
1431
1729
  className: "tcr-input tcr-prompt",
1432
- rows: 4,
1730
+ rows: 5,
1433
1731
  value: form.prompt,
1434
1732
  placeholder: t("promptPlaceholder"),
1435
- autoFocus: true,
1733
+ autoFocus: !touch,
1436
1734
  onChange: (event) => set({ prompt: event.target.value }),
1437
1735
  onKeyDown: (event) => (event.metaKey || event.ctrlKey) && event.key === "Enter" && void save()
1438
1736
  })), /* @__PURE__ */ React.createElement(When, {
@@ -1445,15 +1743,31 @@ function TaskEditor({ client, editing, onClose }) {
1445
1743
  }, t("directory")), /* @__PURE__ */ React.createElement("button", {
1446
1744
  type: "button",
1447
1745
  className: "tcr-input tcr-folder",
1448
- title: form.cwd,
1746
+ title: form.cwd || cwd,
1449
1747
  onClick: () => setPicking(true)
1450
- }, basename(form.cwd || cwd), /* @__PURE__ */ React.createElement("span", {
1748
+ }, /* @__PURE__ */ React.createElement(Folder, {
1749
+ size: 15
1750
+ }), /* @__PURE__ */ React.createElement("span", {
1751
+ className: "tcr-folder-name"
1752
+ }, basename(form.cwd || cwd)), /* @__PURE__ */ React.createElement("span", {
1451
1753
  className: "tcr-folder-path"
1452
- }, form.cwd || cwd))), /* @__PURE__ */ React.createElement(ModelFields, {
1754
+ }, `‎${form.cwd || cwd}‎`))), /* @__PURE__ */ React.createElement(ModelFields, {
1453
1755
  form,
1454
1756
  set,
1455
1757
  cwd: form.cwd || cwd
1456
- }), more ? /* @__PURE__ */ React.createElement("div", {
1758
+ }), /* @__PURE__ */ React.createElement("div", {
1759
+ className: `tcr-options${more ? " tcr-open" : ""}`
1760
+ }, /* @__PURE__ */ React.createElement("button", {
1761
+ type: "button",
1762
+ className: "tcr-more-toggle",
1763
+ "aria-expanded": more,
1764
+ onClick: () => setMore(!more)
1765
+ }, /* @__PURE__ */ React.createElement("span", {
1766
+ className: "tcr-chevron",
1767
+ "aria-hidden": "true"
1768
+ }, /* @__PURE__ */ React.createElement(Chevron, {
1769
+ size: 14
1770
+ })), t("moreOptions")), more && /* @__PURE__ */ React.createElement("div", {
1457
1771
  className: "tcr-grid"
1458
1772
  }, /* @__PURE__ */ React.createElement("label", {
1459
1773
  className: "tcr-field"
@@ -1475,13 +1789,11 @@ function TaskEditor({ client, editing, onClose }) {
1475
1789
  }, NOTIFY.map(([level, word]) => /* @__PURE__ */ React.createElement("option", {
1476
1790
  key: level,
1477
1791
  value: level
1478
- }, t(word)))))) : /* @__PURE__ */ React.createElement("button", {
1479
- type: "button",
1480
- className: "tcr-link",
1481
- onClick: () => setMore(true)
1482
- }, t("more")), /* @__PURE__ */ React.createElement("div", {
1792
+ }, t(word)))))))), /* @__PURE__ */ React.createElement("div", {
1483
1793
  className: "tcr-actions"
1484
- }, /* @__PURE__ */ React.createElement("button", {
1794
+ }, !touch && /* @__PURE__ */ React.createElement("span", {
1795
+ className: "tcr-shortcut"
1796
+ }, t("shortcut", { key, action: editing.task ? t("save") : t("create") })), /* @__PURE__ */ React.createElement("button", {
1485
1797
  type: "button",
1486
1798
  className: "tcr-button",
1487
1799
  onClick: onClose
@@ -1604,6 +1916,164 @@ function ExampleArt({ picture }) {
1604
1916
  return /* @__PURE__ */ React.createElement(Picture, null, /* @__PURE__ */ React.createElement(Shapes, null));
1605
1917
  }
1606
1918
 
1919
+ // web-src/task-util.ts
1920
+ var PROMPT_MAX2 = 20000;
1921
+ var NAME_MAX = 80;
1922
+ var PREFIX_MIN = 4;
1923
+ var TaskUtil;
1924
+ ((TaskUtil) => {
1925
+ function newId(prefix) {
1926
+ const bytes = new Uint8Array(4);
1927
+ crypto.getRandomValues(bytes);
1928
+ return `${prefix}_${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
1929
+ }
1930
+ TaskUtil.newId = newId;
1931
+ function create(input, cwd, now) {
1932
+ const prompt = checkPrompt(input?.prompt);
1933
+ const schedule = ScheduleUtil.check(input.schedule);
1934
+ const at = now.toISOString();
1935
+ const task = {
1936
+ id: newId("task"),
1937
+ name: checkName(input.name) ?? defaultName(prompt),
1938
+ prompt,
1939
+ schedule,
1940
+ cwd: checkCwd(input.cwd) ?? cwd,
1941
+ enabled: input.enabled !== false,
1942
+ runCount: 0,
1943
+ failCount: 0,
1944
+ createdAt: at,
1945
+ updatedAt: at
1946
+ };
1947
+ setOptional(task, input);
1948
+ return arm(task, now);
1949
+ }
1950
+ TaskUtil.create = create;
1951
+ function patch(task, patch2, now) {
1952
+ const next = { ...task, updatedAt: now.toISOString() };
1953
+ if (patch2.prompt !== undefined) {
1954
+ next.prompt = checkPrompt(patch2.prompt);
1955
+ }
1956
+ if (patch2.name !== undefined) {
1957
+ next.name = checkName(patch2.name) ?? defaultName(next.prompt);
1958
+ }
1959
+ if (patch2.cwd !== undefined) {
1960
+ next.cwd = checkCwd(patch2.cwd) ?? task.cwd;
1961
+ }
1962
+ setOptional(next, patch2);
1963
+ if (patch2.enabled !== undefined) {
1964
+ next.enabled = patch2.enabled === true;
1965
+ }
1966
+ if (patch2.schedule !== undefined) {
1967
+ next.schedule = ScheduleUtil.check(patch2.schedule);
1968
+ }
1969
+ const rearm = patch2.schedule !== undefined || next.enabled && !task.enabled;
1970
+ return rearm ? arm(next, now) : next;
1971
+ }
1972
+ TaskUtil.patch = patch;
1973
+ function arm(task, now) {
1974
+ if (!task.enabled) {
1975
+ return task;
1976
+ }
1977
+ const next = ScheduleUtil.next(task.schedule, now);
1978
+ if (!next) {
1979
+ throw new Error(task.schedule.kind === "once" ? `The time of ${task.name} (${task.schedule.at}) has passed: give it a time to come.` : `The rule of ${task.name} never comes round: check the cron expression.`);
1980
+ }
1981
+ return { ...task, nextRunAt: next.toISOString() };
1982
+ }
1983
+ TaskUtil.arm = arm;
1984
+ function find(tasks, ref) {
1985
+ const text = typeof ref === "string" ? ref.trim() : "";
1986
+ const found = tasks.find((task) => task.id === text) ?? tasks.find((task) => task.name === text) ?? (text.length >= PREFIX_MIN ? only(tasks.filter((task) => task.id.startsWith(text))) : undefined);
1987
+ if (!found) {
1988
+ const known = tasks.length ? tasks.map((task) => `${task.id} (${task.name})`).join(", ") : "none yet";
1989
+ throw new Error(`No task is ${JSON.stringify(text)}. The tasks: ${known}.`);
1990
+ }
1991
+ return found;
1992
+ }
1993
+ TaskUtil.find = find;
1994
+ function systemPrompt(task, now) {
1995
+ return [
1996
+ RUN_MARK,
1997
+ `This conversation is a scheduled run of the task "${task.name}" (${ScheduleUtil.describe(task.schedule, "en", now)}), started by the Ta service at ${now.toISOString()}.`,
1998
+ "Nobody watches it while it runs: do the work without asking the user anything, and end with a short summary of what you found or did, which the user reads first.",
1999
+ "</ta-cron-run>"
2000
+ ].join(`
2001
+ `);
2002
+ }
2003
+ TaskUtil.systemPrompt = systemPrompt;
2004
+ function only(tasks) {
2005
+ return tasks.length === 1 ? tasks[0] : undefined;
2006
+ }
2007
+ function setOptional(task, input) {
2008
+ if (input.model !== undefined) {
2009
+ task.model = checkModel(input.model);
2010
+ }
2011
+ if (input.thinking !== undefined) {
2012
+ task.thinking = checkThinking(input.thinking);
2013
+ }
2014
+ if (input.notify !== undefined) {
2015
+ task.notify = checkNotify(input.notify);
2016
+ }
2017
+ for (const key of ["model", "thinking", "notify"]) {
2018
+ if (task[key] === undefined) {
2019
+ delete task[key];
2020
+ }
2021
+ }
2022
+ }
2023
+ function checkPrompt(value) {
2024
+ const prompt = typeof value === "string" ? value.trim() : "";
2025
+ if (!prompt) {
2026
+ throw new Error("A task needs a prompt: what Ta should do each time it runs.");
2027
+ }
2028
+ if (prompt.length > PROMPT_MAX2) {
2029
+ throw new Error(`A prompt is at most ${PROMPT_MAX2} characters; keep long instructions in a file and name it.`);
2030
+ }
2031
+ return prompt;
2032
+ }
2033
+ function checkName(value) {
2034
+ const name = typeof value === "string" ? value.trim() : "";
2035
+ return name ? name.slice(0, NAME_MAX) : undefined;
2036
+ }
2037
+ function defaultName(prompt) {
2038
+ const line = prompt.split(`
2039
+ `)[0].trim();
2040
+ return line.length > 40 ? `${line.slice(0, 39)}…` : line;
2041
+ }
2042
+ function checkCwd(value) {
2043
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
2044
+ }
2045
+ function checkModel(value) {
2046
+ const model = typeof value === "string" ? value.trim() : "";
2047
+ return model || undefined;
2048
+ }
2049
+ function checkThinking(value) {
2050
+ const level = typeof value === "string" ? value.trim() : "";
2051
+ if (level && !THINKING_LEVELS.includes(level)) {
2052
+ throw new Error(`A thinking level is one of ${THINKING_LEVELS.join(", ")}; not ${JSON.stringify(level)}.`);
2053
+ }
2054
+ return level || undefined;
2055
+ }
2056
+ function checkNotify(value) {
2057
+ if (value === "" || value === null) {
2058
+ return;
2059
+ }
2060
+ if (!NOTIFY_LEVELS.includes(value)) {
2061
+ throw new Error(`notify is one of ${NOTIFY_LEVELS.join(", ")}; not ${JSON.stringify(value)}.`);
2062
+ }
2063
+ return value;
2064
+ }
2065
+ function firstLine(text) {
2066
+ const line = text.split(`
2067
+ `).find((candidate) => candidate.trim()) ?? "";
2068
+ return line.replace(/^\s*(?:#{1,6}\s+|[-*+]\s+|>\s*|\d+[.)]\s+)/, "").replace(/\*\*|__|`/g, "").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").trim();
2069
+ }
2070
+ TaskUtil.firstLine = firstLine;
2071
+ function missed(task, now) {
2072
+ return task.schedule.kind === "once" && !!task.nextRunAt && now.getTime() - new Date(task.nextRunAt).getTime() > Limits.GRACE_MS;
2073
+ }
2074
+ TaskUtil.missed = missed;
2075
+ })(TaskUtil ||= {});
2076
+
1607
2077
  // web-src/tasks-view.tsx
1608
2078
  function useClient(client) {
1609
2079
  return React.useSyncExternalStore((listener) => client.subscribe(listener), () => client.state);
@@ -1705,33 +2175,39 @@ function outcome(run) {
1705
2175
  }
1706
2176
  return run.error ?? run.summary;
1707
2177
  }
1708
- function RunRow({ run, now }) {
2178
+ function RunRow({ run, now, last }) {
1709
2179
  const [open, setOpen] = React.useState(false);
1710
2180
  const Markdown = pi.ui.Markdown;
1711
2181
  const Open = icon("MessageSquareText");
2182
+ const Chevron = icon("ChevronRight");
1712
2183
  const took = run.endedAt ? Duration.format(Math.max(1000, new Date(run.endedAt).getTime() - new Date(run.startedAt).getTime())) : undefined;
1713
2184
  const text = outcome(run);
1714
2185
  const label = run.status === "running" ? t("running") : t(run.status);
1715
2186
  return /* @__PURE__ */ React.createElement("div", {
1716
- className: `tcr-run${open ? " tcr-open" : ""}`
2187
+ className: `tcr-run${open ? " tcr-open" : ""}${last ? " tcr-last" : ""}`
1717
2188
  }, /* @__PURE__ */ React.createElement("button", {
1718
2189
  type: "button",
1719
2190
  className: "tcr-run-head",
1720
- onClick: () => setOpen(!open)
2191
+ onClick: () => setOpen(!open),
2192
+ "aria-expanded": open
1721
2193
  }, /* @__PURE__ */ React.createElement(Dot, {
1722
2194
  status: run.status
1723
2195
  }), /* @__PURE__ */ React.createElement("span", {
1724
2196
  className: "tcr-run-time"
1725
2197
  }, ScheduleUtil.clock(new Date(run.startedAt), new Date(now))), /* @__PURE__ */ React.createElement("span", {
1726
- className: "tcr-run-status"
2198
+ className: `tcr-run-status tcr-is-${run.status}`
1727
2199
  }, label), took && /* @__PURE__ */ React.createElement("span", {
1728
2200
  className: "tcr-muted"
1729
2201
  }, took), run.trigger === "manual" && /* @__PURE__ */ React.createElement("span", {
1730
2202
  className: "tcr-chip"
1731
- }, t("byHand")), !open && text && /* @__PURE__ */ React.createElement("span", {
2203
+ }, t("byHand")), /* @__PURE__ */ React.createElement("span", {
1732
2204
  className: "tcr-run-line"
1733
- }, text.split(`
1734
- `)[0])), open && /* @__PURE__ */ React.createElement("div", {
2205
+ }, !open && text ? TaskUtil.firstLine(text) : ""), /* @__PURE__ */ React.createElement("span", {
2206
+ className: "tcr-chevron",
2207
+ "aria-hidden": "true"
2208
+ }, /* @__PURE__ */ React.createElement(Chevron, {
2209
+ size: 14
2210
+ }))), open && /* @__PURE__ */ React.createElement("div", {
1735
2211
  className: "tcr-run-body"
1736
2212
  }, text && (run.status === "success" ? /* @__PURE__ */ React.createElement(Markdown, {
1737
2213
  text
@@ -1745,7 +2221,30 @@ function RunRow({ run, now }) {
1745
2221
  size: 14
1746
2222
  }), t("openChat"))));
1747
2223
  }
1748
- function Detail({ client, task, now }) {
2224
+ function PromptText({ text }) {
2225
+ const [whole, setWhole] = React.useState(false);
2226
+ const [long, setLong] = React.useState(false);
2227
+ const box = React.useRef(null);
2228
+ React.useLayoutEffect(() => {
2229
+ const element = box.current;
2230
+ if (element && !whole) {
2231
+ setLong(element.scrollHeight > element.clientHeight + 2);
2232
+ }
2233
+ }, [text, whole]);
2234
+ return /* @__PURE__ */ React.createElement("div", {
2235
+ className: "tcr-prompt-block"
2236
+ }, /* @__PURE__ */ React.createElement("div", {
2237
+ className: "tcr-prompt-text"
2238
+ }, /* @__PURE__ */ React.createElement("div", {
2239
+ ref: box,
2240
+ className: `${whole ? "" : "tcr-clamped"}${long && !whole ? " tcr-fade" : ""}`
2241
+ }, text)), (long || whole) && /* @__PURE__ */ React.createElement("button", {
2242
+ type: "button",
2243
+ className: "tcr-link",
2244
+ onClick: () => setWhole(!whole)
2245
+ }, whole ? t("showLess") : t("showAll")));
2246
+ }
2247
+ function Detail({ client, task, now, onEdit }) {
1749
2248
  const { runs } = useClient(client);
1750
2249
  React.useEffect(() => {
1751
2250
  client.loadRuns(task.id).catch(() => {
@@ -1753,82 +2252,112 @@ function Detail({ client, task, now }) {
1753
2252
  });
1754
2253
  }, [client, task.id]);
1755
2254
  const list = runs[task.id];
2255
+ const Play = icon("Play");
2256
+ const Pencil = icon("Pencil");
2257
+ const Sparkles = icon("Sparkles");
2258
+ const running = task.lastStatus === "running";
1756
2259
  return /* @__PURE__ */ React.createElement("div", {
1757
2260
  className: "tcr-detail"
1758
2261
  }, /* @__PURE__ */ React.createElement("div", {
1759
- className: "tcr-prompt-text"
1760
- }, task.prompt), /* @__PURE__ */ React.createElement("div", {
2262
+ className: "tcr-toolbar"
2263
+ }, /* @__PURE__ */ React.createElement("button", {
2264
+ type: "button",
2265
+ className: "tcr-button",
2266
+ disabled: running,
2267
+ onClick: () => void guard(() => client.runNow(task.id))
2268
+ }, /* @__PURE__ */ React.createElement(Play, {
2269
+ size: 14
2270
+ }), t("runNow")), /* @__PURE__ */ React.createElement("button", {
2271
+ type: "button",
2272
+ className: "tcr-button",
2273
+ onClick: () => onEdit(task)
2274
+ }, /* @__PURE__ */ React.createElement(Pencil, {
2275
+ size: 14
2276
+ }), t("edit")), /* @__PURE__ */ React.createElement("button", {
2277
+ type: "button",
2278
+ className: "tcr-button tcr-accent",
2279
+ title: t("makeExtensionHint"),
2280
+ onClick: () => void makeExtension(task, list)
2281
+ }, /* @__PURE__ */ React.createElement(Sparkles, {
2282
+ size: 14
2283
+ }), t("makeExtension")), task.runCount > 0 && /* @__PURE__ */ React.createElement("span", {
2284
+ className: "tcr-stats"
2285
+ }, t(task.failCount > 0 ? "statsFailed" : "stats", { runs: task.runCount, fails: task.failCount }))), /* @__PURE__ */ React.createElement("div", {
1761
2286
  className: "tcr-label"
1762
- }, t("runs")), list && list.length === 0 && /* @__PURE__ */ React.createElement("div", {
2287
+ }, t("promptLabel")), /* @__PURE__ */ React.createElement(PromptText, {
2288
+ text: task.prompt
2289
+ }), /* @__PURE__ */ React.createElement("div", {
2290
+ className: "tcr-label"
2291
+ }, t("runs"), list && list.length > 0 && /* @__PURE__ */ React.createElement("span", {
2292
+ className: "tcr-count"
2293
+ }, list.length)), list === undefined && /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
2294
+ rows: 2
2295
+ }), list?.length === 0 && /* @__PURE__ */ React.createElement("div", {
1763
2296
  className: "tcr-muted tcr-pad"
1764
- }, t("noRuns")), list?.map((run) => /* @__PURE__ */ React.createElement(RunRow, {
2297
+ }, t("noRuns")), list && list.length > 0 && /* @__PURE__ */ React.createElement("div", {
2298
+ className: "tcr-runs"
2299
+ }, list.map((run, index) => /* @__PURE__ */ React.createElement(RunRow, {
1765
2300
  key: run.id,
1766
2301
  run,
1767
- now
1768
- })));
1769
- }
1770
- function Menu({ items, onClose }) {
1771
- const ref = React.useRef(null);
1772
- React.useEffect(() => {
1773
- const close = (event) => (event instanceof KeyboardEvent ? event.key === "Escape" : !ref.current?.contains(event.target)) && onClose();
1774
- document.addEventListener("pointerdown", close, true);
1775
- document.addEventListener("keydown", close);
1776
- return () => {
1777
- document.removeEventListener("pointerdown", close, true);
1778
- document.removeEventListener("keydown", close);
1779
- };
1780
- }, [onClose]);
1781
- return /* @__PURE__ */ React.createElement("div", {
1782
- className: "tcr-menu",
1783
- ref,
1784
- role: "menu"
1785
- }, items.map((item) => {
1786
- const Icon = icon(item.icon);
1787
- return /* @__PURE__ */ React.createElement("button", {
1788
- key: item.key,
1789
- type: "button",
1790
- role: "menuitem",
1791
- className: `tcr-menu-item${item.danger ? " tcr-danger" : ""}`,
1792
- onClick: () => {
1793
- onClose();
1794
- item.run();
1795
- }
1796
- }, /* @__PURE__ */ React.createElement(Icon, {
1797
- size: 14
1798
- }), item.label);
1799
- }));
2302
+ now,
2303
+ last: index === list.length - 1
2304
+ }))));
1800
2305
  }
1801
2306
  function TaskRow({ client, task, now, onEdit }) {
1802
2307
  const [open, setOpen] = React.useState(false);
1803
- const [menu, setMenu] = React.useState(false);
2308
+ const [menu, openMenu] = pi.ui.useContextMenu();
1804
2309
  const More = icon("Ellipsis");
2310
+ const Mark = icon(task.schedule.kind === "once" ? "Clock" : "AlarmClock");
1805
2311
  const running = task.lastStatus === "running";
1806
2312
  const state = running ? t("running") : !task.enabled ? task.nextRunAt || ScheduleUtil.repeats(task.schedule) ? t("paused") : t("done") : task.nextRunAt ? t("next", { time: until(new Date(task.nextRunAt).getTime(), now) }) : t("done");
2313
+ const tone = running ? "running" : !task.enabled ? "off" : task.lastStatus ?? "idle";
1807
2314
  const remove = async () => {
1808
2315
  if (await pi.ui.confirm(t("confirmDelete", { name: task.name }), t("confirmDeleteMessage"), { confirmLabel: t("delete"), danger: true })) {
1809
- await guard(() => client.call("remove", task.id));
2316
+ await guard(() => client.remove(task.id));
1810
2317
  }
1811
2318
  };
2319
+ const items = [
2320
+ [
2321
+ { key: "run", label: t("runNow"), icon: icon("Play"), disabled: running, run: () => void guard(() => client.runNow(task.id)) },
2322
+ { key: "edit", label: t("edit"), icon: icon("Pencil"), run: () => onEdit(task) },
2323
+ { key: "extension", label: t("makeExtension"), icon: icon("Sparkles"), run: () => void makeExtension(task, client.state.runs[task.id]) }
2324
+ ],
2325
+ [{ key: "delete", label: t("delete"), icon: icon("Trash2"), danger: true, run: () => void remove() }]
2326
+ ];
1812
2327
  return /* @__PURE__ */ React.createElement("div", {
1813
- className: `tcr-task${open ? " tcr-open" : ""}${menu ? " tcr-menu-open" : ""}${task.enabled ? "" : " tcr-disabled"}`
2328
+ className: `tcr-task${open ? " tcr-open" : ""}${task.enabled ? "" : " tcr-disabled"}`
1814
2329
  }, /* @__PURE__ */ React.createElement("div", {
1815
2330
  className: "tcr-task-row"
1816
2331
  }, /* @__PURE__ */ React.createElement("button", {
1817
2332
  type: "button",
1818
2333
  className: "tcr-task-main",
1819
2334
  onClick: () => setOpen(!open),
2335
+ onContextMenu: (event) => openMenu(event, items),
1820
2336
  "aria-expanded": open
1821
- }, /* @__PURE__ */ React.createElement(Dot, {
2337
+ }, /* @__PURE__ */ React.createElement("span", {
2338
+ className: `tcr-mark tcr-tone-${tone}`,
2339
+ "aria-hidden": "true"
2340
+ }, /* @__PURE__ */ React.createElement(Mark, {
2341
+ size: 17
2342
+ }), /* @__PURE__ */ React.createElement(Dot, {
1822
2343
  status: task.lastStatus,
1823
2344
  enabled: task.enabled || running
1824
- }), /* @__PURE__ */ React.createElement("span", {
2345
+ })), /* @__PURE__ */ React.createElement("span", {
2346
+ className: "tcr-task-text"
2347
+ }, /* @__PURE__ */ React.createElement("span", {
1825
2348
  className: "tcr-task-name"
1826
2349
  }, task.name), /* @__PURE__ */ React.createElement("span", {
2350
+ className: "tcr-task-meta"
2351
+ }, /* @__PURE__ */ React.createElement("span", {
1827
2352
  className: "tcr-chip"
1828
2353
  }, ScheduleUtil.describe(task.schedule, pi.ui.language, new Date(now))), /* @__PURE__ */ React.createElement("span", {
1829
2354
  className: "tcr-task-dir",
1830
2355
  title: task.cwd
1831
2356
  }, basename(task.cwd)), /* @__PURE__ */ React.createElement("span", {
2357
+ className: `tcr-task-next${running ? " tcr-pulse" : ""}`
2358
+ }, state), task.lastRunAt && /* @__PURE__ */ React.createElement("span", {
2359
+ className: "tcr-task-last"
2360
+ }, t("lastRun", { time: ScheduleUtil.clock(new Date(task.lastRunAt), new Date(now)) })))), /* @__PURE__ */ React.createElement("span", {
1832
2361
  className: `tcr-task-state${running ? " tcr-pulse" : ""}`,
1833
2362
  title: task.nextRunAt ? t("nextAt", { time: ScheduleUtil.clock(new Date(task.nextRunAt)) }) : undefined
1834
2363
  }, state)), /* @__PURE__ */ React.createElement("label", {
@@ -1837,28 +2366,22 @@ function TaskRow({ client, task, now, onEdit }) {
1837
2366
  }, /* @__PURE__ */ React.createElement("input", {
1838
2367
  type: "checkbox",
1839
2368
  checked: task.enabled,
1840
- onChange: (event) => void guard(() => client.call("setEnabled", task.id, event.target.checked))
1841
- }), /* @__PURE__ */ React.createElement("span", null)), /* @__PURE__ */ React.createElement("div", {
1842
- className: "tcr-more"
1843
- }, /* @__PURE__ */ React.createElement("button", {
2369
+ "aria-label": t("enable"),
2370
+ onChange: (event) => void guard(() => client.setEnabled(task.id, event.target.checked))
2371
+ }), /* @__PURE__ */ React.createElement("span", null)), /* @__PURE__ */ React.createElement("button", {
1844
2372
  type: "button",
1845
- className: "tcr-icon",
2373
+ className: "tcr-icon tcr-more",
1846
2374
  "aria-label": t("more"),
1847
- onClick: () => setMenu(!menu)
2375
+ "aria-haspopup": "menu",
2376
+ onClick: (event) => openMenu(event, items)
1848
2377
  }, /* @__PURE__ */ React.createElement(More, {
1849
2378
  size: 16
1850
- })), menu && /* @__PURE__ */ React.createElement(Menu, {
1851
- onClose: () => setMenu(false),
1852
- items: [
1853
- { key: "run", label: t("runNow"), icon: "Play", run: () => void guard(() => client.call("run", task.id)) },
1854
- { key: "edit", label: t("edit"), icon: "Pencil", run: () => onEdit(task) },
1855
- { key: "delete", label: t("delete"), icon: "Trash2", danger: true, run: () => void remove() }
1856
- ]
1857
2379
  }))), open && /* @__PURE__ */ React.createElement(Detail, {
1858
2380
  client,
1859
2381
  task,
1860
- now
1861
- }));
2382
+ now,
2383
+ onEdit
2384
+ }), menu);
1862
2385
  }
1863
2386
  function TasksHead({ client }) {
1864
2387
  const Plus = icon("Plus");
@@ -1877,17 +2400,16 @@ function TasksHead({ client }) {
1877
2400
  })));
1878
2401
  }
1879
2402
  function TasksPage({ client }) {
1880
- const { tasks, loaded, asks } = useClient(client);
2403
+ const { tasks, loaded } = useClient(client);
1881
2404
  const now = useMinute();
1882
2405
  const [editing, setEditing] = React.useState();
1883
- React.useEffect(() => {
1884
- if (asks > 0) {
1885
- setEditing({});
1886
- }
1887
- }, [asks]);
2406
+ React.useEffect(() => client.onAskNew(() => setEditing({})), [client]);
1888
2407
  const running = tasks.filter((task) => task.lastStatus === "running").length;
1889
2408
  const sorted = [...tasks].sort((a, b) => Number(b.enabled) - Number(a.enabled) || (a.nextRunAt ?? "~").localeCompare(b.nextRunAt ?? "~"));
2409
+ const edit = React.useCallback((task) => setEditing({ task }), []);
1890
2410
  return /* @__PURE__ */ React.createElement("div", {
2411
+ className: "tcr-scroll"
2412
+ }, /* @__PURE__ */ React.createElement("div", {
1891
2413
  className: "tcr-page"
1892
2414
  }, tasks.length > 0 && /* @__PURE__ */ React.createElement("div", {
1893
2415
  className: "tcr-head"
@@ -1895,7 +2417,9 @@ function TasksPage({ client }) {
1895
2417
  className: "tcr-stat"
1896
2418
  }, t("count", { count: tasks.length }), running > 0 && /* @__PURE__ */ React.createElement("span", {
1897
2419
  className: "tcr-pulse"
1898
- }, " · ", t("runningCount", { count: running })))), loaded && tasks.length === 0 && /* @__PURE__ */ React.createElement(Empty, {
2420
+ }, " · ", t("runningCount", { count: running })))), !loaded && /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
2421
+ rows: 3
2422
+ }), loaded && tasks.length === 0 && /* @__PURE__ */ React.createElement(Empty, {
1899
2423
  onPick: setEditing
1900
2424
  }), /* @__PURE__ */ React.createElement("div", {
1901
2425
  className: "tcr-list"
@@ -1904,8 +2428,8 @@ function TasksPage({ client }) {
1904
2428
  client,
1905
2429
  task,
1906
2430
  now,
1907
- onEdit: (item) => setEditing({ task: item })
1908
- }))), editing && /* @__PURE__ */ React.createElement(TaskEditor, {
2431
+ onEdit: edit
2432
+ })))), editing && /* @__PURE__ */ React.createElement(TaskEditor, {
1909
2433
  client,
1910
2434
  editing,
1911
2435
  onClose: () => setEditing(undefined)