@celljs/ta 4.9.1 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (673) hide show
  1. package/README.en.md +3 -1
  2. package/README.md +3 -1
  3. package/dist/cli.mjs +1753 -75
  4. package/dist/gateway.mjs +311 -25
  5. package/dist/pi/CHANGELOG.md +30 -0
  6. package/dist/pi/dist/bundle/chunks/anthropic-messages-CA3HHOL3.js +6 -0
  7. package/dist/pi/dist/bundle/chunks/{azure-openai-responses-FSC6BAW3.js → azure-openai-responses-76TWS6DT.js} +1 -1
  8. package/dist/pi/dist/bundle/chunks/bedrock-converse-stream.js +3 -3
  9. package/dist/pi/dist/bundle/chunks/chunk-4KSTFUIK.js +19 -0
  10. package/dist/pi/dist/bundle/chunks/chunk-4UNPP53I.js +55 -0
  11. package/dist/pi/dist/bundle/chunks/chunk-AUUCDC7R.js +4 -0
  12. package/dist/pi/dist/bundle/chunks/{chunk-V6KH5QG4.js → chunk-BAC3QPNW.js} +1 -1
  13. package/dist/pi/dist/bundle/chunks/{chunk-4EYXVSA5.js → chunk-FF6XOTWB.js} +9 -9
  14. package/dist/pi/dist/bundle/chunks/chunk-FMPAMX2W.js +82 -0
  15. package/dist/pi/dist/bundle/chunks/chunk-GFUN2N5K.js +2 -0
  16. package/dist/pi/dist/bundle/chunks/chunk-IEBK4HQA.js +2 -0
  17. package/dist/pi/dist/bundle/chunks/{chunk-C2WU32PX.js → chunk-IQUU5XIT.js} +1 -1
  18. package/dist/pi/dist/bundle/chunks/{chunk-EBFHJFEE.js → chunk-LQLJ7CDW.js} +1 -1
  19. package/dist/pi/dist/bundle/chunks/chunk-MMDXLZVS.js +30 -0
  20. package/dist/pi/dist/bundle/chunks/{chunk-GN3QYODH.js → chunk-QN4TOIZN.js} +1 -1
  21. package/dist/pi/dist/bundle/chunks/chunk-RKNK4Y6L.js +2 -0
  22. package/dist/pi/dist/bundle/chunks/{chunk-B46VJEHW.js → chunk-V7SLUK6A.js} +1 -1
  23. package/dist/pi/dist/bundle/chunks/chunk-VEJDBY3O.js +1237 -0
  24. package/dist/pi/dist/bundle/chunks/chunk-VKJQ6CME.js +8 -0
  25. package/dist/pi/dist/bundle/chunks/{chunk-3TGLJEWK.js → chunk-WL4TUXY7.js} +1 -1
  26. package/dist/pi/dist/bundle/chunks/{chunk-YZKQS34S.js → chunk-Y55SJART.js} +5 -1
  27. package/dist/pi/dist/bundle/chunks/{chunk-EOO47QGR.js → chunk-ZBIZYD6W.js} +1 -1
  28. package/dist/pi/dist/bundle/chunks/chunk-ZG74NES2.js +2 -0
  29. package/dist/pi/dist/bundle/chunks/chunk-ZGYS4UTC.js +2 -0
  30. package/dist/pi/dist/bundle/chunks/{cli-MCOUW5WS.js → cli-7RHMDOHL.js} +7 -7
  31. package/dist/pi/dist/bundle/chunks/{cloudflare-workers-ai-system-one-WLAFJSP6.js → cloudflare-workers-ai-system-one-U4J7D646.js} +1 -1
  32. package/dist/pi/dist/bundle/chunks/codemode-worker.js +2 -0
  33. package/dist/pi/dist/bundle/chunks/{easter-egg-3d-WMBNSJ4M.js → easter-egg-3d-GEVPKQF6.js} +1 -1
  34. package/dist/pi/dist/bundle/chunks/{execute-4CEBORGZ.js → execute-L2EEDV3L.js} +5 -3
  35. package/dist/pi/dist/bundle/chunks/github-copilot.js +1 -1
  36. package/dist/pi/dist/bundle/chunks/{google-generative-ai-INGKNW72.js → google-generative-ai-D5B6W47J.js} +1 -1
  37. package/dist/pi/dist/bundle/chunks/{google-vertex-IBTX6MBF.js → google-vertex-U4H5YDEW.js} +1 -1
  38. package/dist/pi/dist/bundle/chunks/{llama-cpp-classify-V5U3QKXI.js → llama-cpp-classify-EJXCQRUQ.js} +1 -1
  39. package/dist/pi/dist/bundle/chunks/{mistral-conversations-S4OWXIXQ.js → mistral-conversations-S277EKLB.js} +1 -1
  40. package/dist/pi/dist/bundle/chunks/openai-codex-responses-TEQRB65N.js +10 -0
  41. package/dist/pi/dist/bundle/chunks/{openai-completions-EJNYB6IX.js → openai-completions-HRZOSLBO.js} +3 -3
  42. package/dist/pi/dist/bundle/chunks/{openai-decisions-IXI34BYG.js → openai-decisions-F66BDLOM.js} +1 -1
  43. package/dist/pi/dist/bundle/chunks/openai-responses-BAKFWTGE.js +4 -0
  44. package/dist/pi/dist/bundle/chunks/{openrouter-images-PISKSFMS.js → openrouter-images-VXF5TVIK.js} +1 -1
  45. package/dist/pi/dist/bundle/chunks/{pi-messages-NORUKF4E.js → pi-messages-UBJKNDRN.js} +1 -1
  46. package/dist/pi/dist/bundle/chunks/{runtime-FQB7RU7U.js → runtime-J5ZSBGTX.js} +1 -1
  47. package/dist/pi/dist/bundle/chunks/{typesafe-system-one-CHVC2UUI.js → typesafe-system-one-56TEMIHL.js} +1 -1
  48. package/dist/pi/dist/bundle/chunks/virtual-modules-KITQRTYM.js +2 -0
  49. package/dist/pi/dist/bundle/cli-runtime.js +1 -1
  50. package/dist/pi/dist/bundle/index.js +1 -1
  51. package/dist/pi/dist/bundle/rpc-entry.js +1 -1
  52. package/dist/pi/docs/cli.md +14 -1
  53. package/dist/pi/docs/extensions.md +27 -7
  54. package/dist/pi/docs/keybindings.md +1 -1
  55. package/dist/pi/docs/llama-cpp.md +5 -8
  56. package/dist/pi/docs/models-configuration.md +6 -1
  57. package/dist/pi/docs/models.md +2 -1
  58. package/dist/pi/docs/prompt-templates.md +1 -1
  59. package/dist/pi/docs/providers.md +1 -1
  60. package/dist/pi/docs/rpc.md +4 -2
  61. package/dist/pi/docs/sessions.md +7 -1
  62. package/dist/pi/docs/settings.md +1 -1
  63. package/dist/pi/docs/tui.md +1 -1
  64. package/dist/pi/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  65. package/dist/pi/examples/extensions/custom-provider-anthropic/package.json +1 -1
  66. package/dist/pi/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  67. package/dist/pi/examples/extensions/gondolin/package-lock.json +2 -2
  68. package/dist/pi/examples/extensions/gondolin/package.json +1 -1
  69. package/dist/pi/examples/extensions/plan-mode/index.ts +23 -13
  70. package/dist/pi/examples/extensions/plan-mode/utils.ts +42 -16
  71. package/dist/pi/examples/extensions/subagent/README.md +14 -11
  72. package/dist/pi/examples/extensions/subagent/index.ts +392 -171
  73. package/dist/pi/examples/extensions/with-deps/package-lock.json +2 -2
  74. package/dist/pi/examples/extensions/with-deps/package.json +1 -1
  75. package/dist/pi/examples/tsconfig.json +63 -35
  76. package/dist/pi/package.json +1 -1
  77. package/dist/pi/packages/ta-agents/extension/index.mjs +185 -140
  78. package/dist/pi/packages/ta-agents/lib/acp-agent.js +30 -10
  79. package/dist/pi/packages/ta-agents/lib/agent-bindings.d.ts +2 -0
  80. package/dist/pi/packages/ta-agents/lib/agent-bindings.js +4 -0
  81. package/dist/pi/packages/ta-agents/lib/agent-catalog.d.ts +2 -2
  82. package/dist/pi/packages/ta-agents/lib/agent-catalog.js +4 -4
  83. package/dist/pi/packages/ta-agents/lib/agent-prompt.d.ts +6 -0
  84. package/dist/pi/packages/ta-agents/lib/agent-prompt.js +19 -0
  85. package/dist/pi/packages/ta-agents/lib/agent-session.d.ts +2 -0
  86. package/dist/pi/packages/ta-agents/lib/agent-session.js +2 -0
  87. package/dist/pi/packages/ta-agents/lib/agent-streamer.js +7 -0
  88. package/dist/pi/packages/ta-agents/lib/agent-tool.js +3 -2
  89. package/dist/pi/packages/ta-agents/lib/extension.js +15 -1
  90. package/dist/pi/packages/ta-agents/lib/texts.d.ts +4 -0
  91. package/dist/pi/packages/ta-agents/lib/texts.js +4 -0
  92. package/dist/pi/packages/ta-agents/package.json +3 -3
  93. package/dist/pi/packages/ta-bots/extension/index.mjs +31 -253
  94. package/dist/pi/packages/ta-bots/host/index.mjs +189 -1
  95. package/dist/pi/packages/ta-bots/lib/bots-protocol.d.ts +2 -0
  96. package/dist/pi/packages/ta-bots/lib/bots-protocol.js +3 -1
  97. package/dist/pi/packages/ta-bots/lib/bots-view.js +24 -12
  98. package/dist/pi/packages/ta-bots/lib/composer.js +1 -0
  99. package/dist/pi/packages/ta-bots/lib/extension.js +10 -17
  100. package/dist/pi/packages/ta-bots/lib/i18n.d.ts +1 -0
  101. package/dist/pi/packages/ta-bots/lib/i18n.js +2 -0
  102. package/dist/pi/packages/ta-bots/lib/index.js +2 -0
  103. package/dist/pi/packages/ta-bots/lib/style.d.ts +1 -1
  104. package/dist/pi/packages/ta-bots/lib/style.js +1 -0
  105. package/dist/pi/packages/ta-bots/lib/text-util.js +8 -1
  106. package/dist/pi/packages/ta-bots/lib/tool-line.d.ts +8 -0
  107. package/dist/pi/packages/ta-bots/lib/tool-line.js +19 -0
  108. package/dist/pi/packages/ta-bots/package.json +1 -1
  109. package/dist/pi/packages/ta-bots/web/index.js +47 -16
  110. package/dist/pi/packages/ta-changes/extension/index.mjs +23 -13
  111. package/dist/pi/packages/ta-changes/lib/card.js +18 -4
  112. package/dist/pi/packages/ta-changes/lib/changes-protocol.d.ts +0 -4
  113. package/dist/pi/packages/ta-changes/lib/changes-protocol.js +1 -5
  114. package/dist/pi/packages/ta-changes/lib/extension.js +5 -13
  115. package/dist/pi/packages/ta-changes/package.json +1 -1
  116. package/dist/pi/packages/ta-changes/web/index.js +16 -3
  117. package/dist/pi/packages/ta-channels/README.en.md +6 -5
  118. package/dist/pi/packages/ta-channels/README.md +6 -5
  119. package/dist/pi/packages/ta-channels/extension/index.mjs +350 -28
  120. package/dist/pi/packages/ta-channels/host/index.mjs +638 -43
  121. package/dist/pi/packages/ta-channels/lib/agent-cards.d.ts +19 -0
  122. package/dist/pi/packages/ta-channels/lib/agent-cards.js +58 -0
  123. package/dist/pi/packages/ta-channels/lib/agent-menu.d.ts +2 -2
  124. package/dist/pi/packages/ta-channels/lib/agent-menu.js +20 -6
  125. package/dist/pi/packages/ta-channels/lib/card.d.ts +27 -0
  126. package/dist/pi/packages/ta-channels/lib/card.js +178 -0
  127. package/dist/pi/packages/ta-channels/lib/channels-model.d.ts +65 -13
  128. package/dist/pi/packages/ta-channels/lib/channels-model.js +15 -6
  129. package/dist/pi/packages/ta-channels/lib/channels-util.d.ts +31 -2
  130. package/dist/pi/packages/ta-channels/lib/channels-util.js +100 -6
  131. package/dist/pi/packages/ta-channels/lib/channels.d.ts +28 -18
  132. package/dist/pi/packages/ta-channels/lib/channels.js +65 -65
  133. package/dist/pi/packages/ta-channels/lib/create.js +14 -4
  134. package/dist/pi/packages/ta-channels/lib/extension.d.ts +8 -0
  135. package/dist/pi/packages/ta-channels/lib/extension.js +104 -18
  136. package/dist/pi/packages/ta-channels/lib/faces.d.ts +2 -0
  137. package/dist/pi/packages/ta-channels/lib/faces.js +7 -1
  138. package/dist/pi/packages/ta-channels/lib/handoff-view.d.ts +19 -0
  139. package/dist/pi/packages/ta-channels/lib/handoff-view.js +113 -0
  140. package/dist/pi/packages/ta-channels/lib/handoff.d.ts +67 -0
  141. package/dist/pi/packages/ta-channels/lib/handoff.js +114 -0
  142. package/dist/pi/packages/ta-channels/lib/host.d.ts +1 -1
  143. package/dist/pi/packages/ta-channels/lib/host.js +1 -1
  144. package/dist/pi/packages/ta-channels/lib/i18n.d.ts +49 -8
  145. package/dist/pi/packages/ta-channels/lib/i18n.js +98 -16
  146. package/dist/pi/packages/ta-channels/lib/index.js +10 -1
  147. package/dist/pi/packages/ta-channels/lib/member-tools.d.ts +23 -0
  148. package/dist/pi/packages/ta-channels/lib/member-tools.js +56 -0
  149. package/dist/pi/packages/ta-channels/lib/members.js +6 -2
  150. package/dist/pi/packages/ta-channels/lib/more-menu.d.ts +3 -2
  151. package/dist/pi/packages/ta-channels/lib/more-menu.js +21 -29
  152. package/dist/pi/packages/ta-channels/lib/notice.d.ts +25 -0
  153. package/dist/pi/packages/ta-channels/lib/notice.js +101 -0
  154. package/dist/pi/packages/ta-channels/lib/room.js +26 -10
  155. package/dist/pi/packages/ta-channels/lib/sidebar.d.ts +1 -6
  156. package/dist/pi/packages/ta-channels/lib/sidebar.js +257 -84
  157. package/dist/pi/packages/ta-channels/lib/style.d.ts +1 -1
  158. package/dist/pi/packages/ta-channels/lib/style.js +151 -40
  159. package/dist/pi/packages/ta-channels/lib/tasks.js +3 -4
  160. package/dist/pi/packages/ta-channels/lib/team.d.ts +58 -10
  161. package/dist/pi/packages/ta-channels/lib/team.js +159 -38
  162. package/dist/pi/packages/ta-channels/lib/tool-lines.d.ts +22 -0
  163. package/dist/pi/packages/ta-channels/lib/tool-lines.js +113 -0
  164. package/dist/pi/packages/ta-channels/lib/views.d.ts +54 -1
  165. package/dist/pi/packages/ta-channels/lib/views.js +129 -1
  166. package/dist/pi/packages/ta-channels/package.json +2 -1
  167. package/dist/pi/packages/ta-channels/web/index.js +1792 -439
  168. package/dist/pi/packages/ta-computer-use/package.json +7 -2
  169. package/dist/pi/packages/ta-cron/README.en.md +6 -4
  170. package/dist/pi/packages/ta-cron/README.md +6 -4
  171. package/dist/pi/packages/ta-cron/extension/index.mjs +416 -44
  172. package/dist/pi/packages/ta-cron/host/index.mjs +30 -3
  173. package/dist/pi/packages/ta-cron/lib/chat-task.d.ts +48 -0
  174. package/dist/pi/packages/ta-cron/lib/chat-task.js +133 -0
  175. package/dist/pi/packages/ta-cron/lib/commands.d.ts +2 -1
  176. package/dist/pi/packages/ta-cron/lib/commands.js +10 -4
  177. package/dist/pi/packages/ta-cron/lib/composer.d.ts +11 -0
  178. package/dist/pi/packages/ta-cron/lib/composer.js +58 -0
  179. package/dist/pi/packages/ta-cron/lib/cron-protocol.d.ts +10 -3
  180. package/dist/pi/packages/ta-cron/lib/cron-protocol.js +6 -3
  181. package/dist/pi/packages/ta-cron/lib/editor.js +65 -30
  182. package/dist/pi/packages/ta-cron/lib/extension.d.ts +2 -0
  183. package/dist/pi/packages/ta-cron/lib/extension.js +33 -13
  184. package/dist/pi/packages/ta-cron/lib/i18n.d.ts +30 -1
  185. package/dist/pi/packages/ta-cron/lib/i18n.js +60 -2
  186. package/dist/pi/packages/ta-cron/lib/index.js +4 -0
  187. package/dist/pi/packages/ta-cron/lib/page.d.ts +38 -4
  188. package/dist/pi/packages/ta-cron/lib/page.js +131 -4
  189. package/dist/pi/packages/ta-cron/lib/react.d.ts +3 -0
  190. package/dist/pi/packages/ta-cron/lib/react.js +8 -0
  191. package/dist/pi/packages/ta-cron/lib/scheduler.js +3 -2
  192. package/dist/pi/packages/ta-cron/lib/style.d.ts +1 -1
  193. package/dist/pi/packages/ta-cron/lib/style.js +168 -50
  194. package/dist/pi/packages/ta-cron/lib/task-extension.d.ts +15 -0
  195. package/dist/pi/packages/ta-cron/lib/task-extension.js +56 -0
  196. package/dist/pi/packages/ta-cron/lib/task-util.d.ts +4 -0
  197. package/dist/pi/packages/ta-cron/lib/task-util.js +31 -1
  198. package/dist/pi/packages/ta-cron/lib/tasks-view.d.ts +4 -1
  199. package/dist/pi/packages/ta-cron/lib/tasks-view.js +107 -67
  200. package/dist/pi/packages/ta-cron/lib/tool-line.d.ts +9 -0
  201. package/dist/pi/packages/ta-cron/lib/tool-line.js +40 -0
  202. package/dist/pi/packages/ta-cron/lib/tool.d.ts +5 -1
  203. package/dist/pi/packages/ta-cron/lib/tool.js +6 -3
  204. package/dist/pi/packages/ta-cron/package.json +12 -1
  205. package/dist/pi/packages/ta-cron/web/index.js +1346 -415
  206. package/dist/pi/packages/ta-extensions/README.en.md +4 -2
  207. package/dist/pi/packages/ta-extensions/README.md +4 -2
  208. package/dist/pi/packages/ta-extensions/host/index.mjs +3 -2
  209. package/dist/pi/packages/ta-extensions/lib/actions.d.ts +4 -0
  210. package/dist/pi/packages/ta-extensions/lib/actions.js +16 -5
  211. package/dist/pi/packages/ta-extensions/lib/composer.d.ts +17 -0
  212. package/dist/pi/packages/ta-extensions/lib/composer.js +84 -0
  213. package/dist/pi/packages/ta-extensions/lib/extensions-util.d.ts +5 -0
  214. package/dist/pi/packages/ta-extensions/lib/extensions-util.js +10 -0
  215. package/dist/pi/packages/ta-extensions/lib/i18n.d.ts +9 -0
  216. package/dist/pi/packages/ta-extensions/lib/i18n.js +18 -0
  217. package/dist/pi/packages/ta-extensions/lib/index.js +4 -0
  218. package/dist/pi/packages/ta-extensions/lib/make-model.d.ts +20 -0
  219. package/dist/pi/packages/ta-extensions/lib/make-model.js +43 -0
  220. package/dist/pi/packages/ta-extensions/lib/market-parts.js +8 -2
  221. package/dist/pi/packages/ta-extensions/lib/market-style.d.ts +1 -1
  222. package/dist/pi/packages/ta-extensions/lib/market-style.js +4 -5
  223. package/dist/pi/packages/ta-extensions/lib/market-util.d.ts +2 -2
  224. package/dist/pi/packages/ta-extensions/lib/market-util.js +2 -2
  225. package/dist/pi/packages/ta-extensions/lib/page.js +52 -23
  226. package/dist/pi/packages/ta-extensions/lib/react.d.ts +3 -0
  227. package/dist/pi/packages/ta-extensions/lib/react.js +8 -0
  228. package/dist/pi/packages/ta-extensions/lib/settings.d.ts +4 -0
  229. package/dist/pi/packages/ta-extensions/lib/settings.js +44 -0
  230. package/dist/pi/packages/ta-extensions/lib/style.d.ts +1 -1
  231. package/dist/pi/packages/ta-extensions/lib/style.js +13 -6
  232. package/dist/pi/packages/ta-extensions/package.json +6 -1
  233. package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +25 -10
  234. package/dist/pi/packages/ta-extensions/web/index.js +459 -47
  235. package/dist/pi/packages/ta-games/README.en.md +47 -0
  236. package/dist/pi/packages/ta-games/README.md +47 -0
  237. package/dist/pi/packages/ta-games/host/index.mjs +65 -0
  238. package/dist/pi/packages/ta-games/lib/games-view.d.ts +16 -0
  239. package/dist/pi/packages/ta-games/lib/games-view.js +77 -0
  240. package/dist/pi/packages/ta-games/lib/host.d.ts +36 -0
  241. package/dist/pi/packages/ta-games/lib/host.js +83 -0
  242. package/dist/pi/packages/ta-games/lib/i18n.d.ts +35 -0
  243. package/dist/pi/packages/ta-games/lib/i18n.js +71 -0
  244. package/dist/pi/packages/ta-games/lib/ideas.d.ts +6 -0
  245. package/dist/pi/packages/ta-games/lib/ideas.js +62 -0
  246. package/dist/pi/packages/ta-games/lib/index.d.ts +7 -0
  247. package/dist/pi/packages/ta-games/lib/index.js +24 -0
  248. package/dist/pi/packages/ta-games/lib/make-game.d.ts +23 -0
  249. package/dist/pi/packages/ta-games/lib/make-game.js +67 -0
  250. package/dist/pi/packages/ta-games/lib/react.d.ts +11 -0
  251. package/dist/pi/packages/ta-games/lib/react.js +16 -0
  252. package/dist/pi/packages/ta-games/lib/style.d.ts +4 -0
  253. package/dist/pi/packages/ta-games/lib/style.js +33 -0
  254. package/dist/pi/packages/ta-games/package.json +60 -0
  255. package/dist/pi/packages/ta-games/skills/ta-game/SKILL.md +127 -0
  256. package/dist/pi/packages/ta-games/skills/ta-game/examples/dino-run/package.json +22 -0
  257. package/dist/pi/packages/ta-games/skills/ta-game/examples/dino-run/web.js +389 -0
  258. package/dist/pi/packages/ta-games/skills/ta-game/examples/stack/package.json +22 -0
  259. package/dist/pi/packages/ta-games/skills/ta-game/examples/stack/web.js +423 -0
  260. package/dist/pi/packages/ta-games/skills/ta-game/phaser/LICENSE.md +22 -0
  261. package/dist/pi/packages/ta-games/skills/ta-game/phaser/actions-and-utilities/SKILL.md +343 -0
  262. package/dist/pi/packages/ta-games/skills/ta-game/phaser/animations/SKILL.md +481 -0
  263. package/dist/pi/packages/ta-games/skills/ta-game/phaser/audio-and-sound/SKILL.md +453 -0
  264. package/dist/pi/packages/ta-games/skills/ta-game/phaser/cameras/SKILL.md +497 -0
  265. package/dist/pi/packages/ta-games/skills/ta-game/phaser/cameras/references/REFERENCE.md +128 -0
  266. package/dist/pi/packages/ta-games/skills/ta-game/phaser/curves-and-paths/SKILL.md +359 -0
  267. package/dist/pi/packages/ta-games/skills/ta-game/phaser/data-manager/SKILL.md +406 -0
  268. package/dist/pi/packages/ta-games/skills/ta-game/phaser/events-system/SKILL.md +497 -0
  269. package/dist/pi/packages/ta-games/skills/ta-game/phaser/filters-and-postfx/SKILL.md +449 -0
  270. package/dist/pi/packages/ta-games/skills/ta-game/phaser/game-object-components/SKILL.md +478 -0
  271. package/dist/pi/packages/ta-games/skills/ta-game/phaser/game-object-components/references/REFERENCE.md +76 -0
  272. package/dist/pi/packages/ta-games/skills/ta-game/phaser/game-setup-and-config/SKILL.md +485 -0
  273. package/dist/pi/packages/ta-games/skills/ta-game/phaser/geometry-and-math/SKILL.md +497 -0
  274. package/dist/pi/packages/ta-games/skills/ta-game/phaser/graphics-and-shapes/SKILL.md +473 -0
  275. package/dist/pi/packages/ta-games/skills/ta-game/phaser/groups-and-containers/SKILL.md +418 -0
  276. package/dist/pi/packages/ta-games/skills/ta-game/phaser/input-keyboard-mouse-touch/SKILL.md +500 -0
  277. package/dist/pi/packages/ta-games/skills/ta-game/phaser/input-keyboard-mouse-touch/references/REFERENCE.md +372 -0
  278. package/dist/pi/packages/ta-games/skills/ta-game/phaser/loading-assets/SKILL.md +474 -0
  279. package/dist/pi/packages/ta-games/skills/ta-game/phaser/loading-assets/references/REFERENCE.md +148 -0
  280. package/dist/pi/packages/ta-games/skills/ta-game/phaser/particles/SKILL.md +499 -0
  281. package/dist/pi/packages/ta-games/skills/ta-game/phaser/particles/references/REFERENCE.md +17 -0
  282. package/dist/pi/packages/ta-games/skills/ta-game/phaser/physics-arcade/SKILL.md +468 -0
  283. package/dist/pi/packages/ta-games/skills/ta-game/phaser/physics-matter/SKILL.md +499 -0
  284. package/dist/pi/packages/ta-games/skills/ta-game/phaser/render-textures/SKILL.md +441 -0
  285. package/dist/pi/packages/ta-games/skills/ta-game/phaser/scale-and-responsive/SKILL.md +371 -0
  286. package/dist/pi/packages/ta-games/skills/ta-game/phaser/scenes/SKILL.md +450 -0
  287. package/dist/pi/packages/ta-games/skills/ta-game/phaser/scenes/references/REFERENCE.md +78 -0
  288. package/dist/pi/packages/ta-games/skills/ta-game/phaser/sprites-and-images/SKILL.md +417 -0
  289. package/dist/pi/packages/ta-games/skills/ta-game/phaser/sprites-and-images/references/REFERENCE.md +160 -0
  290. package/dist/pi/packages/ta-games/skills/ta-game/phaser/text-and-bitmaptext/SKILL.md +460 -0
  291. package/dist/pi/packages/ta-games/skills/ta-game/phaser/tilemaps/SKILL.md +440 -0
  292. package/dist/pi/packages/ta-games/skills/ta-game/phaser/time-and-timers/SKILL.md +496 -0
  293. package/dist/pi/packages/ta-games/skills/ta-game/phaser/tweens/SKILL.md +414 -0
  294. package/dist/pi/packages/ta-games/skills/ta-game/phaser/v3-to-v4-migration/SKILL.md +430 -0
  295. package/dist/pi/packages/ta-games/skills/ta-game/phaser/v4-new-features/SKILL.md +384 -0
  296. package/dist/pi/packages/ta-games/skills/ta-game/phaser/v4-new-features/references/REFERENCE.md +69 -0
  297. package/dist/pi/packages/ta-games/web/index.js +431 -0
  298. package/dist/pi/packages/ta-glance/README.en.md +11 -0
  299. package/dist/pi/packages/ta-glance/README.md +11 -0
  300. package/dist/pi/packages/ta-glance/extension/index.mjs +67 -0
  301. package/dist/pi/packages/ta-glance/lib/card.d.ts +8 -0
  302. package/dist/pi/packages/ta-glance/lib/card.js +268 -0
  303. package/dist/pi/packages/ta-glance/lib/extension.d.ts +15 -0
  304. package/dist/pi/packages/ta-glance/lib/extension.js +24 -0
  305. package/dist/pi/packages/ta-glance/lib/glance-json.d.ts +9 -0
  306. package/dist/pi/packages/ta-glance/lib/glance-json.js +85 -0
  307. package/dist/pi/packages/ta-glance/lib/glance-prompt.d.ts +7 -0
  308. package/dist/pi/packages/ta-glance/lib/glance-prompt.js +34 -0
  309. package/dist/pi/packages/ta-glance/lib/glance-protocol.d.ts +98 -0
  310. package/dist/pi/packages/ta-glance/lib/glance-protocol.js +8 -0
  311. package/dist/pi/packages/ta-glance/lib/glance-spec.d.ts +6 -0
  312. package/dist/pi/packages/ta-glance/lib/glance-spec.js +204 -0
  313. package/dist/pi/packages/ta-glance/lib/glance-util.d.ts +3 -0
  314. package/dist/pi/packages/ta-glance/lib/glance-util.js +12 -0
  315. package/dist/pi/packages/ta-glance/lib/i18n.d.ts +22 -0
  316. package/dist/pi/packages/ta-glance/lib/i18n.js +41 -0
  317. package/dist/pi/packages/ta-glance/lib/index.d.ts +7 -0
  318. package/dist/pi/packages/ta-glance/lib/index.js +22 -0
  319. package/dist/pi/packages/ta-glance/lib/react.d.ts +8 -0
  320. package/dist/pi/packages/ta-glance/lib/react.js +8 -0
  321. package/dist/pi/packages/ta-glance/lib/style.d.ts +4 -0
  322. package/dist/pi/packages/ta-glance/lib/style.js +164 -0
  323. package/dist/pi/packages/ta-glance/package.json +53 -0
  324. package/dist/pi/packages/ta-glance/web/index.js +933 -0
  325. package/dist/pi/packages/ta-launcher/lib/actions.d.ts +4 -4
  326. package/dist/pi/packages/ta-launcher/lib/actions.js +7 -3
  327. package/dist/pi/packages/ta-launcher/lib/launcher-util.d.ts +7 -7
  328. package/dist/pi/packages/ta-launcher/lib/launcher-util.js +11 -8
  329. package/dist/pi/packages/ta-launcher/lib/launcher-view.js +13 -7
  330. package/dist/pi/packages/ta-launcher/lib/react.d.ts +3 -0
  331. package/dist/pi/packages/ta-launcher/lib/react.js +8 -0
  332. package/dist/pi/packages/ta-launcher/lib/style.d.ts +1 -1
  333. package/dist/pi/packages/ta-launcher/lib/style.js +6 -4
  334. package/dist/pi/packages/ta-launcher/package.json +1 -1
  335. package/dist/pi/packages/ta-launcher/web/index.js +34 -17
  336. package/dist/pi/packages/ta-manual/README.en.md +10 -0
  337. package/dist/pi/packages/ta-manual/README.md +10 -0
  338. package/dist/pi/packages/ta-manual/lib/i18n.d.ts +15 -0
  339. package/dist/pi/packages/ta-manual/lib/i18n.js +31 -0
  340. package/dist/pi/packages/ta-manual/lib/index.d.ts +7 -0
  341. package/dist/pi/packages/ta-manual/lib/index.js +24 -0
  342. package/dist/pi/packages/ta-manual/lib/manual-util.d.ts +18 -0
  343. package/dist/pi/packages/ta-manual/lib/manual-util.js +40 -0
  344. package/dist/pi/packages/ta-manual/lib/manual-view.d.ts +9 -0
  345. package/dist/pi/packages/ta-manual/lib/manual-view.js +81 -0
  346. package/dist/pi/packages/ta-manual/lib/pictures-a.d.ts +2 -0
  347. package/dist/pi/packages/ta-manual/lib/pictures-a.js +263 -0
  348. package/dist/pi/packages/ta-manual/lib/pictures-b.d.ts +2 -0
  349. package/dist/pi/packages/ta-manual/lib/pictures-b.js +216 -0
  350. package/dist/pi/packages/ta-manual/lib/pictures.d.ts +9 -0
  351. package/dist/pi/packages/ta-manual/lib/pictures.js +16 -0
  352. package/dist/pi/packages/ta-manual/lib/react.d.ts +8 -0
  353. package/dist/pi/packages/ta-manual/lib/react.js +8 -0
  354. package/dist/pi/packages/ta-manual/lib/scene.d.ts +68 -0
  355. package/dist/pi/packages/ta-manual/lib/scene.js +115 -0
  356. package/dist/pi/packages/ta-manual/lib/style.d.ts +4 -0
  357. package/dist/pi/packages/ta-manual/lib/style.js +47 -0
  358. package/dist/pi/packages/ta-manual/lib/topics.d.ts +42 -0
  359. package/dist/pi/packages/ta-manual/lib/topics.js +354 -0
  360. package/dist/pi/packages/ta-manual/package.json +54 -0
  361. package/dist/pi/packages/ta-manual/skills/ta-manual/SKILL.md +119 -0
  362. package/dist/pi/packages/ta-manual/web/index.js +2223 -0
  363. package/dist/pi/packages/ta-notify/README.en.md +29 -0
  364. package/dist/pi/packages/ta-notify/README.md +29 -0
  365. package/dist/pi/packages/ta-notify/extension/index.mjs +259 -0
  366. package/dist/pi/packages/ta-notify/host/index.mjs +163 -0
  367. package/dist/pi/packages/ta-notify/lib/ask-card.d.ts +9 -0
  368. package/dist/pi/packages/ta-notify/lib/ask-card.js +40 -0
  369. package/dist/pi/packages/ta-notify/lib/extension.d.ts +24 -0
  370. package/dist/pi/packages/ta-notify/lib/extension.js +102 -0
  371. package/dist/pi/packages/ta-notify/lib/host.d.ts +4 -0
  372. package/dist/pi/packages/ta-notify/lib/host.js +9 -0
  373. package/dist/pi/packages/ta-notify/lib/i18n.d.ts +31 -0
  374. package/dist/pi/packages/ta-notify/lib/i18n.js +63 -0
  375. package/dist/pi/packages/ta-notify/lib/index.d.ts +8 -0
  376. package/dist/pi/packages/ta-notify/lib/index.js +29 -0
  377. package/dist/pi/packages/ta-notify/lib/notify-protocol.d.ts +74 -0
  378. package/dist/pi/packages/ta-notify/lib/notify-protocol.js +23 -0
  379. package/dist/pi/packages/ta-notify/lib/notify-service.d.ts +21 -0
  380. package/dist/pi/packages/ta-notify/lib/notify-service.js +75 -0
  381. package/dist/pi/packages/ta-notify/lib/notify-util.d.ts +39 -0
  382. package/dist/pi/packages/ta-notify/lib/notify-util.js +119 -0
  383. package/dist/pi/packages/ta-notify/lib/react.d.ts +8 -0
  384. package/dist/pi/packages/ta-notify/lib/react.js +8 -0
  385. package/dist/pi/packages/ta-notify/lib/server-texts.d.ts +9 -0
  386. package/dist/pi/packages/ta-notify/lib/server-texts.js +22 -0
  387. package/dist/pi/packages/ta-notify/lib/settings.d.ts +8 -0
  388. package/dist/pi/packages/ta-notify/lib/settings.js +85 -0
  389. package/dist/pi/packages/ta-notify/lib/style.d.ts +4 -0
  390. package/dist/pi/packages/ta-notify/lib/style.js +29 -0
  391. package/dist/pi/packages/ta-notify/lib/tool-line.d.ts +9 -0
  392. package/dist/pi/packages/ta-notify/lib/tool-line.js +20 -0
  393. package/dist/pi/packages/ta-notify/lib/tool.d.ts +37 -0
  394. package/dist/pi/packages/ta-notify/lib/tool.js +46 -0
  395. package/dist/pi/packages/ta-notify/lib/watcher.d.ts +15 -0
  396. package/dist/pi/packages/ta-notify/lib/watcher.js +81 -0
  397. package/dist/pi/packages/ta-notify/package.json +55 -0
  398. package/dist/pi/packages/ta-notify/web/index.js +436 -0
  399. package/dist/pi/packages/ta-recall/README.en.md +19 -0
  400. package/dist/pi/packages/ta-recall/README.md +19 -0
  401. package/dist/pi/packages/ta-recall/extension/index.mjs +614 -0
  402. package/dist/pi/packages/ta-recall/host/index.mjs +820 -0
  403. package/dist/pi/packages/ta-recall/lib/brief-card.d.ts +21 -0
  404. package/dist/pi/packages/ta-recall/lib/brief-card.js +67 -0
  405. package/dist/pi/packages/ta-recall/lib/brief-home.d.ts +49 -0
  406. package/dist/pi/packages/ta-recall/lib/brief-home.js +143 -0
  407. package/dist/pi/packages/ta-recall/lib/brief-seen.d.ts +9 -0
  408. package/dist/pi/packages/ta-recall/lib/brief-seen.js +26 -0
  409. package/dist/pi/packages/ta-recall/lib/brief-util.d.ts +64 -0
  410. package/dist/pi/packages/ta-recall/lib/brief-util.js +179 -0
  411. package/dist/pi/packages/ta-recall/lib/chat-icons.d.ts +8 -0
  412. package/dist/pi/packages/ta-recall/lib/chat-icons.js +56 -0
  413. package/dist/pi/packages/ta-recall/lib/composer.d.ts +7 -0
  414. package/dist/pi/packages/ta-recall/lib/composer.js +38 -0
  415. package/dist/pi/packages/ta-recall/lib/conversation-index.d.ts +25 -0
  416. package/dist/pi/packages/ta-recall/lib/conversation-index.js +72 -0
  417. package/dist/pi/packages/ta-recall/lib/conversation-util.d.ts +16 -0
  418. package/dist/pi/packages/ta-recall/lib/conversation-util.js +109 -0
  419. package/dist/pi/packages/ta-recall/lib/conversations.d.ts +11 -0
  420. package/dist/pi/packages/ta-recall/lib/conversations.js +46 -0
  421. package/dist/pi/packages/ta-recall/lib/extension.d.ts +24 -0
  422. package/dist/pi/packages/ta-recall/lib/extension.js +131 -0
  423. package/dist/pi/packages/ta-recall/lib/host.d.ts +4 -0
  424. package/dist/pi/packages/ta-recall/lib/host.js +11 -0
  425. package/dist/pi/packages/ta-recall/lib/i18n.d.ts +41 -0
  426. package/dist/pi/packages/ta-recall/lib/i18n.js +83 -0
  427. package/dist/pi/packages/ta-recall/lib/index.d.ts +9 -0
  428. package/dist/pi/packages/ta-recall/lib/index.js +45 -0
  429. package/dist/pi/packages/ta-recall/lib/react.d.ts +11 -0
  430. package/dist/pi/packages/ta-recall/lib/react.js +16 -0
  431. package/dist/pi/packages/ta-recall/lib/recall-protocol.d.ts +186 -0
  432. package/dist/pi/packages/ta-recall/lib/recall-protocol.js +60 -0
  433. package/dist/pi/packages/ta-recall/lib/recall-service.d.ts +42 -0
  434. package/dist/pi/packages/ta-recall/lib/recall-service.js +241 -0
  435. package/dist/pi/packages/ta-recall/lib/search-source.d.ts +7 -0
  436. package/dist/pi/packages/ta-recall/lib/search-source.js +49 -0
  437. package/dist/pi/packages/ta-recall/lib/search-util.d.ts +30 -0
  438. package/dist/pi/packages/ta-recall/lib/search-util.js +167 -0
  439. package/dist/pi/packages/ta-recall/lib/server-texts.d.ts +7 -0
  440. package/dist/pi/packages/ta-recall/lib/server-texts.js +17 -0
  441. package/dist/pi/packages/ta-recall/lib/settings.d.ts +4 -0
  442. package/dist/pi/packages/ta-recall/lib/settings.js +77 -0
  443. package/dist/pi/packages/ta-recall/lib/skill-card.d.ts +9 -0
  444. package/dist/pi/packages/ta-recall/lib/skill-card.js +51 -0
  445. package/dist/pi/packages/ta-recall/lib/skill-util.d.ts +19 -0
  446. package/dist/pi/packages/ta-recall/lib/skill-util.js +110 -0
  447. package/dist/pi/packages/ta-recall/lib/stored.d.ts +5 -0
  448. package/dist/pi/packages/ta-recall/lib/stored.js +28 -0
  449. package/dist/pi/packages/ta-recall/lib/style.d.ts +4 -0
  450. package/dist/pi/packages/ta-recall/lib/style.js +48 -0
  451. package/dist/pi/packages/ta-recall/lib/tool-line.d.ts +10 -0
  452. package/dist/pi/packages/ta-recall/lib/tool-line.js +23 -0
  453. package/dist/pi/packages/ta-recall/lib/tool.d.ts +63 -0
  454. package/dist/pi/packages/ta-recall/lib/tool.js +71 -0
  455. package/dist/pi/packages/ta-recall/package.json +55 -0
  456. package/dist/pi/packages/ta-recall/web/index.js +1038 -0
  457. package/dist/pi/packages/ta-rooms/README.en.md +23 -0
  458. package/dist/pi/packages/ta-rooms/README.md +23 -0
  459. package/dist/pi/packages/ta-rooms/lib/dialogs.d.ts +39 -0
  460. package/dist/pi/packages/ta-rooms/lib/dialogs.js +235 -0
  461. package/dist/pi/packages/ta-rooms/lib/i18n.d.ts +101 -0
  462. package/dist/pi/packages/ta-rooms/lib/i18n.js +203 -0
  463. package/dist/pi/packages/ta-rooms/lib/index.d.ts +9 -0
  464. package/dist/pi/packages/ta-rooms/lib/index.js +85 -0
  465. package/dist/pi/packages/ta-rooms/lib/members-view.d.ts +3 -0
  466. package/dist/pi/packages/ta-rooms/lib/members-view.js +64 -0
  467. package/dist/pi/packages/ta-rooms/lib/page.d.ts +105 -0
  468. package/dist/pi/packages/ta-rooms/lib/page.js +306 -0
  469. package/dist/pi/packages/ta-rooms/lib/react.d.ts +8 -0
  470. package/dist/pi/packages/ta-rooms/lib/react.js +8 -0
  471. package/dist/pi/packages/ta-rooms/lib/room-view.d.ts +17 -0
  472. package/dist/pi/packages/ta-rooms/lib/room-view.js +150 -0
  473. package/dist/pi/packages/ta-rooms/lib/rooms-page.d.ts +8 -0
  474. package/dist/pi/packages/ta-rooms/lib/rooms-page.js +174 -0
  475. package/dist/pi/packages/ta-rooms/lib/style.d.ts +4 -0
  476. package/dist/pi/packages/ta-rooms/lib/style.js +154 -0
  477. package/dist/pi/packages/ta-rooms/package.json +50 -0
  478. package/dist/pi/packages/ta-rooms/web/index.js +1932 -0
  479. package/dist/pi/packages/ta-share/README.en.md +27 -0
  480. package/dist/pi/packages/ta-share/README.md +27 -0
  481. package/dist/pi/packages/ta-share/extension/index.mjs +184 -0
  482. package/dist/pi/packages/ta-share/host/index.mjs +364 -0
  483. package/dist/pi/packages/ta-share/lib/extension.d.ts +15 -0
  484. package/dist/pi/packages/ta-share/lib/extension.js +115 -0
  485. package/dist/pi/packages/ta-share/lib/host.d.ts +4 -0
  486. package/dist/pi/packages/ta-share/lib/host.js +9 -0
  487. package/dist/pi/packages/ta-share/lib/i18n.d.ts +106 -0
  488. package/dist/pi/packages/ta-share/lib/i18n.js +213 -0
  489. package/dist/pi/packages/ta-share/lib/index.d.ts +9 -0
  490. package/dist/pi/packages/ta-share/lib/index.js +77 -0
  491. package/dist/pi/packages/ta-share/lib/page.d.ts +48 -0
  492. package/dist/pi/packages/ta-share/lib/page.js +105 -0
  493. package/dist/pi/packages/ta-share/lib/react.d.ts +8 -0
  494. package/dist/pi/packages/ta-share/lib/react.js +8 -0
  495. package/dist/pi/packages/ta-share/lib/server-texts.d.ts +14 -0
  496. package/dist/pi/packages/ta-share/lib/server-texts.js +52 -0
  497. package/dist/pi/packages/ta-share/lib/share-dialog.d.ts +18 -0
  498. package/dist/pi/packages/ta-share/lib/share-dialog.js +233 -0
  499. package/dist/pi/packages/ta-share/lib/share-protocol.d.ts +86 -0
  500. package/dist/pi/packages/ta-share/lib/share-protocol.js +30 -0
  501. package/dist/pi/packages/ta-share/lib/share-service.d.ts +50 -0
  502. package/dist/pi/packages/ta-share/lib/share-service.js +130 -0
  503. package/dist/pi/packages/ta-share/lib/shared-view.d.ts +18 -0
  504. package/dist/pi/packages/ta-share/lib/shared-view.js +225 -0
  505. package/dist/pi/packages/ta-share/lib/shares-page.d.ts +3 -0
  506. package/dist/pi/packages/ta-share/lib/shares-page.js +54 -0
  507. package/dist/pi/packages/ta-share/lib/snapshot.d.ts +30 -0
  508. package/dist/pi/packages/ta-share/lib/snapshot.js +195 -0
  509. package/dist/pi/packages/ta-share/lib/style.d.ts +4 -0
  510. package/dist/pi/packages/ta-share/lib/style.js +111 -0
  511. package/dist/pi/packages/ta-share/package.json +56 -0
  512. package/dist/pi/packages/ta-share/web/index.js +1197 -0
  513. package/dist/pi/packages/ta-workspace/README.md +2 -2
  514. package/dist/pi/packages/ta-workspace/README.zh-cn.md +2 -2
  515. package/dist/pi/packages/ta-workspace/lib/browser-common.d.ts +1 -1
  516. package/dist/pi/packages/ta-workspace/lib/browser-common.js +29 -30
  517. package/dist/pi/packages/ta-workspace/lib/browser-tool-line.d.ts +15 -0
  518. package/dist/pi/packages/ta-workspace/lib/browser-tool-line.js +70 -0
  519. package/dist/pi/packages/ta-workspace/lib/bytes.d.ts +11 -0
  520. package/dist/pi/packages/ta-workspace/lib/bytes.js +40 -0
  521. package/dist/pi/packages/ta-workspace/lib/common.d.ts +2 -1
  522. package/dist/pi/packages/ta-workspace/lib/common.js +15 -37
  523. package/dist/pi/packages/ta-workspace/lib/editors.js +40 -4
  524. package/dist/pi/packages/ta-workspace/lib/i18n.d.ts +14 -4
  525. package/dist/pi/packages/ta-workspace/lib/i18n.js +31 -11
  526. package/dist/pi/packages/ta-workspace/lib/index.js +17 -0
  527. package/dist/pi/packages/ta-workspace/lib/launcher.d.ts +9 -0
  528. package/dist/pi/packages/ta-workspace/lib/launcher.js +39 -0
  529. package/dist/pi/packages/ta-workspace/lib/preview.d.ts +22 -3
  530. package/dist/pi/packages/ta-workspace/lib/preview.js +150 -22
  531. package/dist/pi/packages/ta-workspace/lib/style.d.ts +1 -1
  532. package/dist/pi/packages/ta-workspace/lib/style.js +70 -41
  533. package/dist/pi/packages/ta-workspace/lib/terminal-sessions.d.ts +15 -4
  534. package/dist/pi/packages/ta-workspace/lib/terminal-sessions.js +31 -9
  535. package/dist/pi/packages/ta-workspace/lib/terminal.d.ts +3 -2
  536. package/dist/pi/packages/ta-workspace/lib/terminal.js +51 -21
  537. package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts +18 -0
  538. package/dist/pi/packages/ta-workspace/lib/util/keys.js +23 -0
  539. package/dist/pi/packages/ta-workspace/lib/util/preview.d.ts +46 -0
  540. package/dist/pi/packages/ta-workspace/lib/util/preview.js +106 -1
  541. package/dist/pi/packages/ta-workspace/lib/util/terminal.d.ts +5 -0
  542. package/dist/pi/packages/ta-workspace/lib/util/terminal.js +14 -0
  543. package/dist/pi/packages/ta-workspace/package.json +1 -1
  544. package/dist/pi/packages/ta-workspace/web/index.js +1032 -382
  545. package/dist/public/assets/OrbitControls-DVf70a7w.js +1 -0
  546. package/dist/public/assets/{abnfDiagram-S7VZAUFO-EVMX_yOb.js → abnfDiagram-S7VZAUFO-D9uU0Tx2.js} +1 -1
  547. package/dist/public/assets/{architecture-WOLXFQ4H-CDgbgZ_o.js → architecture-WOLXFQ4H-f7Nm7EIo.js} +1 -1
  548. package/dist/public/assets/{architectureDiagram-YGSQEFNW-dHreaCWz.js → architectureDiagram-YGSQEFNW-DSAqlcms.js} +1 -1
  549. package/dist/public/assets/{blockDiagram-APKKGZFW-D6FhzBDq.js → blockDiagram-APKKGZFW-C0lPIW9g.js} +1 -1
  550. package/dist/public/assets/browser-WLpgVYno.js +12 -0
  551. package/dist/public/assets/{c4Diagram-KJ2TOQU5-BFpcr8Cs.js → c4Diagram-KJ2TOQU5-CDcZ7mJq.js} +1 -1
  552. package/dist/public/assets/{chunk-6MUBBAK2-BczXkMV-.js → chunk-6MUBBAK2-CXPuyqPL.js} +1 -1
  553. package/dist/public/assets/{chunk-AXFCVDMN-CjJsv3jB.js → chunk-AXFCVDMN-Du6JRX1x.js} +1 -1
  554. package/dist/public/assets/{chunk-BG4553SI-FBaleaLz.js → chunk-BG4553SI-D592E55X.js} +1 -1
  555. package/dist/public/assets/{chunk-DQASFODM-BFdXY5sX.js → chunk-DQASFODM-BW2r2SL4.js} +1 -1
  556. package/dist/public/assets/{chunk-HFQBQIA3-C5cwK-Fg.js → chunk-HFQBQIA3-C3yoe54R.js} +1 -1
  557. package/dist/public/assets/{chunk-KQLB2F66-BUek3IRk.js → chunk-KQLB2F66-DF8gfYCy.js} +1 -1
  558. package/dist/public/assets/{chunk-KS47KZWR-BxsYBzt6.js → chunk-KS47KZWR-C8CRMTv1.js} +1 -1
  559. package/dist/public/assets/{chunk-LEVMRMFU-Bdcwz9fS.js → chunk-LEVMRMFU-BDcMKiwj.js} +1 -1
  560. package/dist/public/assets/{chunk-M57EVK23-kkpP5oug.js → chunk-M57EVK23-CKJPBygc.js} +1 -1
  561. package/dist/public/assets/{chunk-OY52VR5R-CFhQgxmD.js → chunk-OY52VR5R-B3ZWH07L.js} +1 -1
  562. package/dist/public/assets/{chunk-QB3YPZ4I-BVXqu0eC.js → chunk-QB3YPZ4I-DI-z4UPL.js} +1 -1
  563. package/dist/public/assets/{chunk-R3KSYZAL-B7SUqqLI.js → chunk-R3KSYZAL-Bg4-haAc.js} +1 -1
  564. package/dist/public/assets/{chunk-STOXU5M4-B3abfbnH.js → chunk-STOXU5M4-l_SHib3p.js} +1 -1
  565. package/dist/public/assets/{chunk-TU62E6Q5-C9NqnUav.js → chunk-TU62E6Q5-BINu9tIm.js} +1 -1
  566. package/dist/public/assets/{chunk-X4PVCEUW-BeLfETDx.js → chunk-X4PVCEUW-BQn-mvV5.js} +1 -1
  567. package/dist/public/assets/{chunk-XXDRQBXY-DXai1i8p.js → chunk-XXDRQBXY-uvpAu0Ys.js} +1 -1
  568. package/dist/public/assets/{classDiagram-v2-L25IHNXF-Zj6ne_tC.js → classDiagram-v2-L25IHNXF-BIowooW1.js} +1 -1
  569. package/dist/public/assets/{cose-bilkent-JH36ORCC-C0-TjqfJ.js → cose-bilkent-JH36ORCC-BTyx1Mh2.js} +1 -1
  570. package/dist/public/assets/cynefin-EF2NZ3EQ-Dg54eFzZ.js +1 -0
  571. package/dist/public/assets/{cynefinDiagram-L36ESFBY-BnqxfzPa.js → cynefinDiagram-L36ESFBY-D64EU9I0.js} +1 -1
  572. package/dist/public/assets/{d3-selection-DfFLTR9d.js → d3-selection-CN9k6_B9.js} +1 -1
  573. package/dist/public/assets/{dagre-SPEB5RXH-kI17e5cH.js → dagre-SPEB5RXH-FCbz2-Kk.js} +1 -1
  574. package/dist/public/assets/{diagram-3B7GL73J-DgPjeLA5.js → diagram-3B7GL73J-OhHUSI7j.js} +1 -1
  575. package/dist/public/assets/{diagram-DNEMPZML-CRhPfa0I.js → diagram-DNEMPZML-Be4xMtp6.js} +1 -1
  576. package/dist/public/assets/{diagram-L3MUGCDN-ExuTg12b.js → diagram-L3MUGCDN-CmKSs3aG.js} +1 -1
  577. package/dist/public/assets/{diagram-LA4NIPWU-Dgx5xNiY.js → diagram-LA4NIPWU-D1C32rMN.js} +1 -1
  578. package/dist/public/assets/{diagram-MHCOC4E2-BuifkUTl.js → diagram-MHCOC4E2-BjoE6JXs.js} +1 -1
  579. package/dist/public/assets/{diagram-XPFHEONP-CFEaBo7z.js → diagram-XPFHEONP-B22k4v8R.js} +1 -1
  580. package/dist/public/assets/{dist-C-iJHcSK.js → dist-DcBP8Cf6.js} +1 -1
  581. package/dist/public/assets/{ebnfDiagram-UZSYDL2S-D-hp5yNt.js → ebnfDiagram-UZSYDL2S-Tn-K8-X7.js} +1 -1
  582. package/dist/public/assets/{editor.api-BopUWpqY.js → editor.api-Bz4sjRz_.js} +1 -1
  583. package/dist/public/assets/{elk-XV6XMXQE-CBbk_IpU.js → elk-XV6XMXQE-COnQsWlN.js} +1 -1
  584. package/dist/public/assets/{erDiagram-EYBAPDEH-B02R_WWE.js → erDiagram-EYBAPDEH-c53dJilq.js} +1 -1
  585. package/dist/public/assets/{eventmodeling-K75KTNOO-aCZfYnCI.js → eventmodeling-K75KTNOO-DaFpPPks.js} +1 -1
  586. package/dist/public/assets/flowDiagram-MALGAFMO-V5qkYWIO.js +1 -0
  587. package/dist/public/assets/{freemarker2-DMN60LeK.js → freemarker2-BLxfRHsw.js} +1 -1
  588. package/dist/public/assets/{ganttDiagram-23REXITY-DioU8TlD.js → ganttDiagram-23REXITY-Md-SavIS.js} +1 -1
  589. package/dist/public/assets/gitGraph-VSP46ZUC-1q8ldRXU.js +1 -0
  590. package/dist/public/assets/{gitGraphDiagram-STJD7YCW--q3ctg6y.js → gitGraphDiagram-STJD7YCW-CMSwTghO.js} +1 -1
  591. package/dist/public/assets/{handlebars-B_-qdvpB.js → handlebars-sNpu01kP.js} +1 -1
  592. package/dist/public/assets/{html-BN8Ah3Js.js → html-C_tKd-uP.js} +1 -1
  593. package/dist/public/assets/{index-B3A--ac8.js → index-Bn86rI4n.js} +2 -2
  594. package/dist/public/assets/info-OHQRW6UA-Crere6sx.js +1 -0
  595. package/dist/public/assets/{infoDiagram-KBXO4MBG-CGXteYo9.js → infoDiagram-KBXO4MBG-CwgNj-7i.js} +1 -1
  596. package/dist/public/assets/{ishikawaDiagram-M35NCXHK-DM2LmOAc.js → ishikawaDiagram-M35NCXHK-BSlzQNMN.js} +1 -1
  597. package/dist/public/assets/{javascript-BlizGb0q.js → javascript-l3qKw0L-.js} +1 -1
  598. package/dist/public/assets/{journeyDiagram-OPLOXDXO-CNITRtGl.js → journeyDiagram-OPLOXDXO-B09LPEnF.js} +1 -1
  599. package/dist/public/assets/{jsonMode-CEUmT5sN.js → jsonMode-5SQQn1EX.js} +1 -1
  600. package/dist/public/assets/{kanban-definition-BZKZHSQY-BPUuS9um.js → kanban-definition-BZKZHSQY-BiW4aJ29.js} +1 -1
  601. package/dist/public/assets/{liquid-BbyLjUbE.js → liquid-BGyTIIUt.js} +1 -1
  602. package/dist/public/assets/{mdx-DiQz7Q35.js → mdx-8tGjz4em.js} +1 -1
  603. package/dist/public/assets/{mermaid-parser.core-Dum100hC.js → mermaid-parser.core-CctN5b0z.js} +3 -3
  604. package/dist/public/assets/{mermaid.core-BWmWf6XO.js → mermaid.core-7ERSdZ4-.js} +4 -4
  605. package/dist/public/assets/{mindmap-definition-I2QAS2VK-L8HyYUDY.js → mindmap-definition-I2QAS2VK-D-GOUwW1.js} +1 -1
  606. package/dist/public/assets/module-DEqsdd00.js +1 -0
  607. package/dist/public/assets/module-TWc52XwT.js +2244 -0
  608. package/dist/public/assets/{monaco-zOOyBmxy.js → monaco-B_9hlk78.js} +3 -3
  609. package/dist/public/assets/packet-JDAUHWVQ-qMf5LkHT.js +1 -0
  610. package/dist/public/assets/{pegDiagram-FD4XPPHP-CTZKPo0Z.js → pegDiagram-FD4XPPHP-Dmy1fWB3.js} +1 -1
  611. package/dist/public/assets/phaser.esm-BxCDEWDb.js +3202 -0
  612. package/dist/public/assets/pie-XZMESJXO-BjqLn4qm.js +1 -0
  613. package/dist/public/assets/{pieDiagram-J4AKIIQI-DAeT3dFi.js → pieDiagram-J4AKIIQI-CXFHLYTg.js} +1 -1
  614. package/dist/public/assets/{python-C984gt98.js → python-e-JK0s5M.js} +1 -1
  615. package/dist/public/assets/{quadrantDiagram-XTYBLID2--PXxwV1Z.js → quadrantDiagram-XTYBLID2-RQvEpGWO.js} +1 -1
  616. package/dist/public/assets/radar-ABXABTNO-DWO6t_4C.js +1 -0
  617. package/dist/public/assets/railroad-I3PHUGI6-D1XOJPWy.js +1 -0
  618. package/dist/public/assets/{railroad-abnf-LNEFI6M7-BYcFfrCa.js → railroad-abnf-LNEFI6M7-CDOSPZwX.js} +1 -1
  619. package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-Cd33qxAm.js → railroad-ebnf-DWYD2UWJ-BTrNQ0DX.js} +1 -1
  620. package/dist/public/assets/{railroad-peg-JR7BVNR7-C5TpzaU8.js → railroad-peg-JR7BVNR7-B7NtVofS.js} +1 -1
  621. package/dist/public/assets/{railroadDiagram-MRQ6NCDL-DlWwjbhH.js → railroadDiagram-MRQ6NCDL-DsDrT0Jf.js} +1 -1
  622. package/dist/public/assets/{razor-BBqMR1Qn.js → razor-DtSPwumi.js} +1 -1
  623. package/dist/public/assets/{requirementDiagram-Y7LWUY3S-CsYBy9HS.js → requirementDiagram-Y7LWUY3S-BQh0hFuA.js} +1 -1
  624. package/dist/public/assets/{sankeyDiagram-WGJFYUXA-Baxyb5p9.js → sankeyDiagram-WGJFYUXA-BUXNAQEF.js} +1 -1
  625. package/dist/public/assets/{sequenceDiagram-5NDRBG5M-Cq6VeBT_.js → sequenceDiagram-5NDRBG5M-05f-N5V_.js} +1 -1
  626. package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-O60WKaE7.js → stateDiagram-v2-FJ4FJNEA-D6V1fGWV.js} +1 -1
  627. package/dist/public/assets/{swimlanes-UMQ2AFYF-C2nf1-Cc.js → swimlanes-UMQ2AFYF-DWhlPvKs.js} +1 -1
  628. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-CRn5uHsY.js +8 -0
  629. package/dist/public/assets/three.module-CeVBJVoU.js +4225 -0
  630. package/dist/public/assets/{timeline-definition-SEUHKTQE-DEfUG6YH.js → timeline-definition-SEUHKTQE-CMdocOui.js} +1 -1
  631. package/dist/public/assets/treeView-D4JQ5SDB-D09wHNzT.js +1 -0
  632. package/dist/public/assets/treemap-SAJKECNS-ChxAT7Fq.js +1 -0
  633. package/dist/public/assets/{typescript-Gtq7f0aU.js → typescript-65jNyipU.js} +1 -1
  634. package/dist/public/assets/{usecaseDiagram-AFA6YXN4-Gw9DyJcx.js → usecaseDiagram-AFA6YXN4-BQTHUX1f.js} +1 -1
  635. package/dist/public/assets/{vennDiagram-NNMJR3RB-Clb3MLWF.js → vennDiagram-NNMJR3RB-BULkVTfA.js} +1 -1
  636. package/dist/public/assets/wardley-7MLQ67FV-DfSjKzbJ.js +1 -0
  637. package/dist/public/assets/{wardleyDiagram-S7YFUSEH-BrTRpwu2.js → wardleyDiagram-S7YFUSEH-Cek6l8lz.js} +1 -1
  638. package/dist/public/assets/{xml-Bx3nk7iG.js → xml-DWBejfu-.js} +1 -1
  639. package/dist/public/assets/{xychartDiagram-GGNKY7IX-BfjTcIsb.js → xychartDiagram-GGNKY7IX-ujnZQTWA.js} +1 -1
  640. package/dist/public/assets/{yaml-dFLE_rSl.js → yaml-CwRCT7q1.js} +1 -1
  641. package/dist/public/index.html +1 -1
  642. package/dist/public/launch.svg +46 -42
  643. package/dist/serve/index.mjs +8244 -3756
  644. package/package.json +33 -26
  645. package/dist/pi/dist/bundle/chunks/anthropic-messages-BWGCKOF4.js +0 -6
  646. package/dist/pi/dist/bundle/chunks/chunk-44DLKSKE.js +0 -1232
  647. package/dist/pi/dist/bundle/chunks/chunk-62VOPMLK.js +0 -65
  648. package/dist/pi/dist/bundle/chunks/chunk-7O7QKK6A.js +0 -2
  649. package/dist/pi/dist/bundle/chunks/chunk-CHWNPHIS.js +0 -82
  650. package/dist/pi/dist/bundle/chunks/chunk-NL4X6LBY.js +0 -4
  651. package/dist/pi/dist/bundle/chunks/chunk-NZY7EIPA.js +0 -4
  652. package/dist/pi/dist/bundle/chunks/chunk-R2EGYMOO.js +0 -7
  653. package/dist/pi/dist/bundle/chunks/chunk-UKVNB6C4.js +0 -2
  654. package/dist/pi/dist/bundle/chunks/chunk-USJZMAIR.js +0 -2
  655. package/dist/pi/dist/bundle/chunks/chunk-VOLAXWGI.js +0 -2
  656. package/dist/pi/dist/bundle/chunks/openai-codex-responses-QAWLOQSN.js +0 -10
  657. package/dist/pi/dist/bundle/chunks/openai-responses-MD3562FB.js +0 -4
  658. package/dist/pi/dist/bundle/chunks/virtual-modules-O76XM3OB.js +0 -2
  659. package/dist/public/assets/browser-y6EDNUmc.js +0 -12
  660. package/dist/public/assets/cynefin-EF2NZ3EQ-CoY4CrZu.js +0 -1
  661. package/dist/public/assets/flowDiagram-MALGAFMO-CATkJShO.js +0 -1
  662. package/dist/public/assets/gitGraph-VSP46ZUC-g4yHXXxx.js +0 -1
  663. package/dist/public/assets/info-OHQRW6UA-CKADJjz4.js +0 -1
  664. package/dist/public/assets/module-CH7IXa5L.js +0 -1781
  665. package/dist/public/assets/module-DNAasuMC.js +0 -1
  666. package/dist/public/assets/packet-JDAUHWVQ-CpKMhX4K.js +0 -1
  667. package/dist/public/assets/pie-XZMESJXO-CW-zGDRd.js +0 -1
  668. package/dist/public/assets/radar-ABXABTNO-Cg8W433p.js +0 -1
  669. package/dist/public/assets/railroad-I3PHUGI6-DriMt2PQ.js +0 -1
  670. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-B46JxqS8.js +0 -8
  671. package/dist/public/assets/treeView-D4JQ5SDB-1LhEWwC9.js +0 -1
  672. package/dist/public/assets/treemap-SAJKECNS-D3t3N7nS.js +0 -1
  673. package/dist/public/assets/wardley-7MLQ67FV-D3sAsd8p.js +0 -1
@@ -1,6 +1,8 @@
1
1
  // web-src/cron-protocol.ts
2
2
  var NAME = "@celljs/ta-cron";
3
3
  var REPLY_TYPE = "ta-cron";
4
+ var TOOL_NAME = "schedule_task";
5
+ var RUN_MARK = "<ta-cron-run>";
4
6
  var Keys;
5
7
  ((Keys) => {
6
8
  Keys.TASKS = "tasks";
@@ -16,6 +18,8 @@ var Limits;
16
18
  Limits.SUMMARY_MAX = 4000;
17
19
  Limits.MIN_INTERVAL_MS = 60000;
18
20
  Limits.RUN_TIMEOUT_MS = 30 * 60000;
21
+ Limits.RUN_TIMEOUT_MIN_MS = 5 * 60000;
22
+ Limits.RUN_TIMEOUT_MAX_MS = 4 * 60 * 60000;
19
23
  Limits.GRACE_MS = 5 * 60000;
20
24
  Limits.PARALLEL_RUNS = 3;
21
25
  })(Limits ||= {});
@@ -50,7 +54,6 @@ var EN = {
50
54
  name: "Name",
51
55
  namePlaceholder: "Optional",
52
56
  when: "When",
53
- repeat: "Repeat",
54
57
  once: "Once",
55
58
  every: "Every",
56
59
  daily: "Daily",
@@ -98,7 +101,37 @@ var EN = {
98
101
  show: "Show",
99
102
  failedAction: "Could not do it: {message}",
100
103
  help: "Scheduled tasks",
101
- serviceNeeded: "Scheduled tasks run in the Ta service."
104
+ serviceNeeded: "Scheduled tasks run in the Ta service.",
105
+ makeExtension: "Make an extension",
106
+ makeExtensionHint: "Ta makes a page of its own for what this task finds",
107
+ extensionAsk: 'Make the scheduled task "{name}" an extension that shows its results',
108
+ promptLabel: "What Ta does",
109
+ showAll: "Show all",
110
+ showLess: "Show less",
111
+ stats: "Ran {runs} times",
112
+ statsFailed: "Ran {runs} times · {fails} failed",
113
+ lastRun: "Last {time}",
114
+ moreOptions: "More options",
115
+ shortcut: "{key} + Enter to {action}",
116
+ modelFailed: "The model for making extensions ({model}) cannot be used, so the default one is: {message}",
117
+ fromChat: "Make a scheduled task",
118
+ fromChatDetail: "Do this again on a schedule",
119
+ fromChatWhen: "How often",
120
+ fromChatOther: "Another time",
121
+ fromChatOtherDetail: "Ta asks you",
122
+ fromChatAsk: "Make what this conversation did a scheduled task: {when}",
123
+ fromChatAskWhen: "Make what this conversation did a scheduled task; ask me how often first",
124
+ toolAdd: "Schedule",
125
+ toolUpdate: "Change scheduled task",
126
+ toolList: "List scheduled tasks",
127
+ toolShow: "Look at scheduled task",
128
+ toolEnable: "Turn on scheduled task",
129
+ toolDisable: "Pause scheduled task",
130
+ toolDelete: "Delete scheduled task",
131
+ toolRun: "Run scheduled task",
132
+ toolRuns: "Look at the runs of",
133
+ toolClear: "Clear scheduled tasks",
134
+ toolOther: "Scheduled tasks"
102
135
  };
103
136
  var ZH = {
104
137
  title: "定时任务",
@@ -129,7 +162,6 @@ var ZH = {
129
162
  name: "名字",
130
163
  namePlaceholder: "可不填",
131
164
  when: "时间",
132
- repeat: "重复",
133
165
  once: "一次",
134
166
  every: "每隔",
135
167
  daily: "每天",
@@ -177,7 +209,37 @@ var ZH = {
177
209
  show: "查看",
178
210
  failedAction: "操作失败:{message}",
179
211
  help: "定时任务",
180
- serviceNeeded: "定时任务在 Ta 服务里运行。"
212
+ serviceNeeded: "定时任务在 Ta 服务里运行。",
213
+ makeExtension: "做成扩展",
214
+ makeExtensionHint: "让 Ta 为这个任务的结果做一个专属页面",
215
+ extensionAsk: "把定时任务“{name}”做成扩展,用专属页面呈现它的运行结果",
216
+ promptLabel: "Ta 要做的事",
217
+ showAll: "展开全文",
218
+ showLess: "收起",
219
+ stats: "已运行 {runs} 次",
220
+ statsFailed: "已运行 {runs} 次 · 失败 {fails} 次",
221
+ lastRun: "上次 {time}",
222
+ moreOptions: "更多选项",
223
+ shortcut: "{key} + 回车{action}",
224
+ modelFailed: "做扩展的模型({model})现在用不了,已改用默认模型:{message}",
225
+ fromChat: "做成定时任务",
226
+ fromChatDetail: "定期再做一遍这次的事",
227
+ fromChatWhen: "多久运行一次",
228
+ fromChatOther: "其他时间",
229
+ fromChatOtherDetail: "让 Ta 问我",
230
+ fromChatAsk: "把这次对话做的事做成定时任务,{when} 运行",
231
+ fromChatAskWhen: "把这次对话做的事做成定时任务,先问我多久运行一次",
232
+ toolAdd: "新建定时任务",
233
+ toolUpdate: "修改定时任务",
234
+ toolList: "查看定时任务",
235
+ toolShow: "查看定时任务",
236
+ toolEnable: "开启定时任务",
237
+ toolDisable: "暂停定时任务",
238
+ toolDelete: "删除定时任务",
239
+ toolRun: "立即运行定时任务",
240
+ toolRuns: "查看运行记录",
241
+ toolClear: "清空定时任务",
242
+ toolOther: "定时任务"
181
243
  };
182
244
  var CronWords;
183
245
  ((CronWords) => {
@@ -191,193 +253,6 @@ var CronWords;
191
253
  CronWords.format = format;
192
254
  })(CronWords ||= {});
193
255
 
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
256
  // web-src/cron-expression.ts
382
257
  var FIELDS = [
383
258
  { name: "minute", min: 0, max: 59 },
@@ -509,6 +384,7 @@ class CronExpression {
509
384
 
510
385
  // web-src/schedule-util.ts
511
386
  var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
387
+ var NOTIFY_LEVELS = ["always", "error", "never"];
512
388
  var UNITS = {
513
389
  s: 1000,
514
390
  sec: 1000,
@@ -712,7 +588,7 @@ var ScheduleUtil;
712
588
  })(ScheduleUtil ||= {});
713
589
 
714
590
  // web-src/commands.ts
715
- var FLAG_NAMES = ["name", "notify", "model", "thinking", "cwd"];
591
+ var FLAG_NAMES = ["name", "notify", "model", "thinking", "cwd", "timeout"];
716
592
  var TRAILING_FLAG = new RegExp(`(?:^|\\s)--(${FLAG_NAMES.join("|")})(?:=|\\s+)("[^"]*"|'[^']*'|\\S*)\\s*$`);
717
593
  var ACTIONS = ["add", "list", "show", "runs", "run", "enable", "disable", "set", "remove", "clear", "help"];
718
594
  var HELP = `Scheduled tasks: each run is a conversation of its own in the Ta service, which runs them while it runs.
@@ -730,7 +606,8 @@ var HELP = `Scheduled tasks: each run is a conversation of its own in the Ta ser
730
606
  /schedule clear remove the tasks of this directory
731
607
 
732
608
  A task is its id, the start of it, or its name. Flags at the end of a prompt:
733
- --name <name> --notify always|error|never --model <provider/model> --thinking <level> --cwd <directory>`;
609
+ --name <name> --notify always|error|never --model <provider/model> --thinking <level> --cwd <directory>
610
+ --timeout <duration> how long a run may take before it is stopped, 5m to 4h; default 30m`;
734
611
  var CommandParser;
735
612
  ((CommandParser) => {
736
613
  function splitFlags(text) {
@@ -805,8 +682,11 @@ var CommandParser;
805
682
  if (flags.notify !== undefined) {
806
683
  patch2.notify = value(flags.notify);
807
684
  }
685
+ if (flags.timeout !== undefined) {
686
+ patch2.timeout = value(flags.timeout);
687
+ }
808
688
  if (Object.keys(patch2).length === 0) {
809
- throw new Error("Say what changes: --name, --notify, --model, --thinking or --cwd.");
689
+ throw new Error("Say what changes: --name, --notify, --model, --thinking, --cwd or --timeout.");
810
690
  }
811
691
  return { ref: rest, patch: patch2 };
812
692
  }
@@ -870,78 +750,699 @@ var CommandParser;
870
750
  ...flags.cwd ? { cwd: flags.cwd } : {},
871
751
  ...flags.model ? { model: flags.model } : {},
872
752
  ...flags.thinking ? { thinking: flags.thinking } : {},
873
- ...flags.notify ? { notify: flags.notify } : {}
753
+ ...flags.notify ? { notify: flags.notify } : {},
754
+ ...flags.timeout ? { timeout: flags.timeout } : {}
755
+ };
756
+ }
757
+ function unquote(value) {
758
+ return /^(["']).*\1$/.test(value) ? value.slice(1, -1) : value;
759
+ }
760
+ function completions(prefix, tasks) {
761
+ const parts = prefix.split(/\s+/);
762
+ if (parts.length <= 1) {
763
+ return ACTIONS.filter((action3) => action3.startsWith(parts[0] ?? "")).map((action3) => ({ value: `${action3} `, label: action3 }));
764
+ }
765
+ const [action2, ref] = parts;
766
+ if (!["show", "runs", "run", "enable", "disable", "set", "remove"].includes(action2) || parts.length > 2) {
767
+ return [];
768
+ }
769
+ return tasks.filter((task) => task.id.startsWith(ref) || task.name.startsWith(ref)).map((task) => ({ value: `${action2} ${task.id} `, label: task.id, description: task.name }));
770
+ }
771
+ CommandParser.completions = completions;
772
+ function loopCompletions(prefix) {
773
+ if (/\s/.test(prefix)) {
774
+ return [];
775
+ }
776
+ return [...Object.keys(NICKNAMES), "5m", "30m", "1h", "1d"].filter((item) => item.startsWith(prefix)).map((item) => ({ value: `${item} `, label: item }));
777
+ }
778
+ CommandParser.loopCompletions = loopCompletions;
779
+ })(CommandParser ||= {});
780
+ var CronText;
781
+ ((CronText) => {
782
+ function task(task2, now = new Date) {
783
+ const state = !task2.enabled ? "off" : task2.lastStatus === "running" ? "running" : task2.nextRunAt ? `next ${ScheduleUtil.clock(new Date(task2.nextRunAt), now)}` : "done";
784
+ const last = task2.lastStatus && task2.lastStatus !== "running" ? `, last ${task2.lastStatus}` : "";
785
+ const timeout = task2.timeout ? `, stops after ${task2.timeout}` : "";
786
+ return `${task2.id} ${task2.name} (${ScheduleUtil.describe(task2.schedule, "en", now)}; ${state}${last}${timeout}) in ${task2.cwd}`;
787
+ }
788
+ CronText.task = task;
789
+ function run(run2, now = new Date) {
790
+ const time = ScheduleUtil.clock(new Date(run2.startedAt), now);
791
+ const took = run2.endedAt ? ` in ${Duration.format(new Date(run2.endedAt).getTime() - new Date(run2.startedAt).getTime())}` : "";
792
+ const what = run2.error ?? run2.summary ?? "";
793
+ const file = run2.sessionFile ? `
794
+ conversation: ${run2.sessionFile}` : "";
795
+ return `${run2.id} ${time} ${run2.status}${took}${run2.trigger === "manual" ? " (by hand)" : ""}${what ? `
796
+ ${what.replace(/\n/g, `
797
+ `)}` : ""}${file}`;
798
+ }
799
+ CronText.run = run;
800
+ function reply(reply2) {
801
+ switch (reply2.kind) {
802
+ case "task":
803
+ return `${capital(reply2.event)}: ${task(reply2.task)}`;
804
+ case "removed":
805
+ return reply2.tasks.length ? `Removed ${reply2.tasks.map((item) => item.name).join(", ")}.` : "No tasks to remove.";
806
+ case "started":
807
+ return `Started ${reply2.task.name} (${reply2.run.id}); it runs in a conversation of its own.`;
808
+ case "list":
809
+ return reply2.tasks.length ? reply2.tasks.map((item) => task(item)).join(`
810
+ `) : "No scheduled tasks. Make one with /loop or /remind.";
811
+ case "show":
812
+ return `${task(reply2.task)}
813
+ prompt: ${reply2.task.prompt}
814
+ ${reply2.runs.length ? reply2.runs.map((item) => run(item)).join(`
815
+ `) : "No runs yet."}`;
816
+ case "help":
817
+ return HELP;
818
+ case "error":
819
+ return reply2.message;
820
+ }
821
+ }
822
+ CronText.reply = reply;
823
+ function capital(text) {
824
+ return text[0].toUpperCase() + text.slice(1);
825
+ }
826
+ })(CronText ||= {});
827
+
828
+ // web-src/server-texts.ts
829
+ var CronServerTexts;
830
+ ((CronServerTexts) => {
831
+ function zh(env = process.env) {
832
+ return /^zh/i.test(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG || "");
833
+ }
834
+ CronServerTexts.zh = zh;
835
+ function removeTask(name) {
836
+ return zh() ? ["删除这个任务?", `${name} 和它的运行记录会被删除,运行产生的对话会保留。`] : ["Delete the scheduled task?", `${name} and its runs go; their conversations stay.`];
837
+ }
838
+ CronServerTexts.removeTask = removeTask;
839
+ function removeTasks(count) {
840
+ return zh() ? ["删除这个目录的所有定时任务?", `${count} 个任务和它们的运行记录会被删除。`] : ["Delete the scheduled tasks of this directory?", `${count} tasks and their runs go.`];
841
+ }
842
+ CronServerTexts.removeTasks = removeTasks;
843
+ })(CronServerTexts ||= {});
844
+
845
+ // web-src/tool.ts
846
+ var SCHEDULE = {
847
+ type: "object",
848
+ description: 'When it runs, in the local time of the Ta service: { "kind": "once", "at": "2026-11-12T09:00" }, { "kind": "interval", "every": "30m" } (at least 1m), or { "kind": "cron", "expression": "0 9 * * 1-5" } (five fields, or @daily, @hourly, @weekly, @monthly).',
849
+ properties: {
850
+ kind: { type: "string", enum: ["once", "interval", "cron"] },
851
+ at: { type: "string" },
852
+ every: { type: "string" },
853
+ expression: { type: "string" }
854
+ },
855
+ required: ["kind"]
856
+ };
857
+ var CronTool;
858
+ ((CronTool) => {
859
+ CronTool.NAME = TOOL_NAME;
860
+ CronTool.DEFINITION = {
861
+ name: CronTool.NAME,
862
+ label: "Schedule task",
863
+ description: `Schedules a prompt for Ta to run later, once or again and again (reminders, checks, reports), and manages those tasks. Each run is a new conversation of its own in the Ta service, in the task's directory, with no user watching; its last answer is the summary the user sees. Actions: add (prompt and schedule; name, cwd, model, thinking, notify, timeout optional), update (id and the fields to change; "" clears model, thinking, notify or timeout), list, show (with its last runs), enable, disable, delete, run (now, by hand), runs, clear (the tasks of this directory). Deleting and clearing ask the user first.`,
864
+ parameters: {
865
+ type: "object",
866
+ properties: {
867
+ action: { type: "string", enum: ["add", "update", "list", "show", "enable", "disable", "delete", "run", "runs", "clear"] },
868
+ id: { type: "string", description: "The task: its id, the start of it, or its name." },
869
+ name: { type: "string", description: "Short, for the list." },
870
+ prompt: { type: "string", description: "What Ta does each run, complete in itself: the run does not see this conversation." },
871
+ schedule: SCHEDULE,
872
+ cwd: { type: "string", description: "The directory it runs in; default: this conversation's." },
873
+ model: { type: "string", description: "<provider>/<model id>; default: the settings." },
874
+ thinking: { type: "string", enum: [...THINKING_LEVELS, ""] },
875
+ notify: {
876
+ type: "string",
877
+ enum: [...NOTIFY_LEVELS, ""],
878
+ description: "When the pages of Ta tell the user a run ended; default always for once, error for repeating."
879
+ },
880
+ timeout: { type: "string", description: "How long a run may take before it is stopped, as 90m or 2h (5m to 4h); default 30m." },
881
+ enabled: { type: "boolean" },
882
+ limit: { type: "number", description: "How many runs to list; default 10." }
883
+ },
884
+ required: ["action"]
885
+ }
886
+ };
887
+ async function run(service, params, context) {
888
+ const id = typeof params.id === "string" ? params.id : "";
889
+ switch (params.action) {
890
+ case "add": {
891
+ const cwd = typeof params.cwd === "string" && params.cwd ? params.cwd : await context.cwd();
892
+ const task = await service.add({
893
+ prompt: String(params.prompt ?? ""),
894
+ schedule: params.schedule,
895
+ name: optional(params.name),
896
+ cwd,
897
+ model: optional(params.model),
898
+ thinking: optional(params.thinking),
899
+ notify: optional(params.notify),
900
+ timeout: optional(params.timeout),
901
+ enabled: params.enabled === false ? false : undefined
902
+ });
903
+ return `Scheduled: ${CronText.task(task)}`;
904
+ }
905
+ case "update": {
906
+ const patch = {};
907
+ for (const key of ["name", "prompt", "cwd", "model", "thinking", "notify", "timeout"]) {
908
+ if (typeof params[key] === "string") {
909
+ patch[key] = params[key];
910
+ }
911
+ }
912
+ if (params.schedule !== undefined) {
913
+ patch.schedule = params.schedule;
914
+ }
915
+ if (typeof params.enabled === "boolean") {
916
+ patch.enabled = params.enabled;
917
+ }
918
+ return `Updated: ${CronText.task(await service.update(id, patch))}`;
919
+ }
920
+ case "list": {
921
+ const tasks = await service.list();
922
+ return tasks.length ? tasks.map((task) => CronText.task(task)).join(`
923
+ `) : "No scheduled tasks.";
924
+ }
925
+ case "show":
926
+ case "runs": {
927
+ const task = await service.get(id);
928
+ const runs = await service.runs(task.id, typeof params.limit === "number" ? params.limit : 10);
929
+ return CronText.reply({ kind: "show", task, runs });
930
+ }
931
+ case "enable":
932
+ case "disable":
933
+ return `${params.action === "enable" ? "Enabled" : "Disabled"}: ${CronText.task(await service.setEnabled(id, params.action === "enable"))}`;
934
+ case "run": {
935
+ const task = await service.get(id);
936
+ const run2 = await service.run(task.id);
937
+ return `Started ${task.name} (${run2.id}). It runs in a conversation of its own; see its result later with action "show".`;
938
+ }
939
+ case "delete": {
940
+ const task = await service.get(id);
941
+ if (!await context.confirm(...CronServerTexts.removeTask(task.name))) {
942
+ return "The user kept the task.";
943
+ }
944
+ await service.remove(task.id);
945
+ return `Deleted ${task.name}.`;
946
+ }
947
+ case "clear": {
948
+ const cwd = await context.cwd();
949
+ const tasks = (await service.list()).filter((task) => task.cwd === cwd);
950
+ if (tasks.length === 0) {
951
+ return "This directory has no scheduled tasks.";
952
+ }
953
+ if (!await context.confirm(...CronServerTexts.removeTasks(tasks.length))) {
954
+ return "The user kept the tasks.";
955
+ }
956
+ return `Deleted ${(await service.clear(cwd)).length} tasks.`;
957
+ }
958
+ default:
959
+ throw new Error("action is one of add, update, list, show, enable, disable, delete, run, runs, clear.");
960
+ }
961
+ }
962
+ CronTool.run = run;
963
+ function optional(value) {
964
+ return typeof value === "string" && value ? value : undefined;
965
+ }
966
+ })(CronTool ||= {});
967
+
968
+ // web-src/chat-task.ts
969
+ var TASK_BLOCK = "ta-cron-task";
970
+ var MARK = /\[ta-cron:from-chat(?: (\{[^}]*\}))?\]/;
971
+ var ChatTask;
972
+ ((ChatTask) => {
973
+ function message(language, schedule2) {
974
+ const words = CronWords.of(language);
975
+ const ask = schedule2 ? CronWords.format(words.fromChatAsk, { when: ScheduleUtil.describe(schedule2, language) }) : words.fromChatAskWhen;
976
+ return `<context>
977
+ ${context(schedule2)}
978
+ </context>
979
+ ${ask}`;
980
+ }
981
+ ChatTask.message = message;
982
+ function context(schedule2) {
983
+ const fence = "```";
984
+ return [
985
+ schedule2 ? `[ta-cron:from-chat ${JSON.stringify(schedule2)}]` : "[ta-cron:from-chat]",
986
+ schedule2 ? `The user wants what was done in this conversation made a scheduled task of Ta that does it again and again, ${ScheduleUtil.describe(schedule2, "en-US")}.` : "The user wants what was done in this conversation made a scheduled task of Ta that does it again and again, and has not said how often: unless the conversation says it, ask, with two or three choices that suit the work, and write the task once you know.",
987
+ "- Each run is a new conversation in this directory with nobody watching, and it does not see this one: write a prompt complete in itself, with the goal, the repository, branch, files, commands, links and other specifics found here, the steps that worked, and what its last answer should report (short: what it found, what changed since the run before, what needs the user).",
988
+ '- Leave out what was only tried and dropped, and what holds only this once: say "since the last run" or "yesterday" rather than a date.',
989
+ `- Say in a line or two what the task does, then end your answer with it in a fenced block of the language ${TASK_BLOCK}, which Ta reads to create the task: do not create it with ${CronTool.NAME} or a command. A longer fence when the prompt has one of its own:`,
990
+ `${fence}${TASK_BLOCK}`,
991
+ "name: <short, for the list>",
992
+ schedule2 ? "when: <only when the user asked for another time since: 30m, 2h, @daily, or five fields of cron>" : "when: <30m, 2h, @daily, or five fields of cron, as 0 9 * * 1-5>",
993
+ "---",
994
+ "<the prompt>",
995
+ fence,
996
+ "- When the conversation holds nothing worth doing again, say so, ask what the task should do, and leave the block out until you know."
997
+ ].join(`
998
+ `);
999
+ }
1000
+ ChatTask.context = context;
1001
+ function find(text2) {
1002
+ const lines = text2.split(/\r?\n/);
1003
+ let found;
1004
+ for (let index = 0;index < lines.length; index++) {
1005
+ const open = /^\s*(`{3,})\s*([\w-]+)\s*$/.exec(lines[index]);
1006
+ if (open?.[2] !== TASK_BLOCK) {
1007
+ continue;
1008
+ }
1009
+ const close = new RegExp(`^\\s*${open[1]}\`*\\s*$`);
1010
+ const end = lines.findIndex((line, at) => at > index && close.test(line));
1011
+ found = lines.slice(index + 1, end < 0 ? lines.length : end);
1012
+ index = end < 0 ? lines.length : end;
1013
+ }
1014
+ return found && parse(found);
1015
+ }
1016
+ ChatTask.find = find;
1017
+ function parse(lines) {
1018
+ const rule = lines.findIndex((line) => line.trim() === "---");
1019
+ const head = rule < 0 ? [] : lines.slice(0, rule);
1020
+ const prompt = lines.slice(rule + 1).join(`
1021
+ `).trim();
1022
+ if (!prompt) {
1023
+ return;
1024
+ }
1025
+ const field = (key) => head.map((line) => new RegExp(`^\\s*${key}\\s*:\\s*(.*)$`, "i").exec(line)?.[1].trim()).find((value) => value !== undefined);
1026
+ const name = field("name") ?? "";
1027
+ const when = field("when");
1028
+ return { name, prompt, schedule: when ? schedule(when) : undefined };
1029
+ }
1030
+ function schedule(text2) {
1031
+ const when = text2.replace(/^["'`]|["'`]$/g, "").trim();
1032
+ if (Duration.parse(when) !== undefined) {
1033
+ return ScheduleUtil.check({ kind: "interval", every: when });
1034
+ }
1035
+ return ScheduleUtil.check({ kind: "cron", expression: when });
1036
+ }
1037
+ ChatTask.schedule = schedule;
1038
+ function pending(entries) {
1039
+ for (let index = entries.length - 1;index >= 0; index--) {
1040
+ const entry = entries[index];
1041
+ const custom = entry.type === "custom_message" ? entry : entry.message?.role === "custom" ? entry.message : undefined;
1042
+ if (custom?.customType === REPLY_TYPE && created(custom.details)) {
1043
+ return;
1044
+ }
1045
+ if (entry.type !== "message" || entry.message?.role !== "user") {
1046
+ continue;
1047
+ }
1048
+ const mark = MARK.exec(text(entry.message.content));
1049
+ if (mark) {
1050
+ return { schedule: mark[1] ? ScheduleUtil.check(JSON.parse(mark[1])) : undefined };
1051
+ }
1052
+ }
1053
+ return;
1054
+ }
1055
+ ChatTask.pending = pending;
1056
+ function text(content) {
1057
+ if (typeof content === "string") {
1058
+ return content;
1059
+ }
1060
+ return Array.isArray(content) ? content.filter((part) => part?.type === "text" && typeof part.text === "string").map((part) => part.text).join(`
1061
+ `) : "";
1062
+ }
1063
+ ChatTask.text = text;
1064
+ function created(details) {
1065
+ const reply = details;
1066
+ return reply?.kind === "task" && reply.event === "created";
1067
+ }
1068
+ })(ChatTask ||= {});
1069
+
1070
+ // web-src/task-extension.ts
1071
+ var PROMPT_MAX = 4000;
1072
+ var ANSWER_MAX = 2000;
1073
+ var TaskExtension;
1074
+ ((TaskExtension) => {
1075
+ function message(task, runs, language) {
1076
+ const words = CronWords.of(language);
1077
+ return `<context>
1078
+ ${context(task, runs)}
1079
+ </context>
1080
+ ${CronWords.format(words.extensionAsk, { name: task.name })}`;
1081
+ }
1082
+ TaskExtension.message = message;
1083
+ function context(task, runs) {
1084
+ const answer = runs?.find((run) => run.status === "success" && run.summary)?.summary;
1085
+ const lines = [
1086
+ `The user wants the scheduled task "${task.name}" made into an extension of Ta, with the ta-package skill, kept in extensions/:`,
1087
+ "- 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;",
1088
+ '- a card of the board (location "board") with the latest result at a glance, when that is useful.',
1089
+ "",
1090
+ `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.`,
1091
+ '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.',
1092
+ "",
1093
+ `Task: ${task.id}, ${ScheduleUtil.describe(task.schedule, "en-US")}, in ${task.cwd}, ${task.enabled ? "on" : "off"}, ran ${task.runCount} times (${task.failCount} failed).`,
1094
+ "Its prompt:",
1095
+ fence(clip(task.prompt, PROMPT_MAX))
1096
+ ];
1097
+ if (answer) {
1098
+ lines.push("What its last run answered:", fence(clip(answer, ANSWER_MAX)));
1099
+ }
1100
+ return lines.join(`
1101
+ `);
1102
+ }
1103
+ TaskExtension.context = context;
1104
+ function clip(text, max) {
1105
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;
1106
+ }
1107
+ function fence(text) {
1108
+ const longest = Math.max(2, ...Array.from(text.matchAll(/`+/g), (match) => match[0].length));
1109
+ const marks = "`".repeat(longest + 1);
1110
+ return `${marks}
1111
+ ${text}
1112
+ ${marks}`;
1113
+ }
1114
+ })(TaskExtension ||= {});
1115
+
1116
+ // web-src/page.ts
1117
+ var pi;
1118
+ var PAGE = `${NAME}/tasks`;
1119
+ var EXTENSIONS = "@celljs/ta-extensions";
1120
+ function bindPage(api) {
1121
+ pi = api;
1122
+ }
1123
+ function t(key, values = {}) {
1124
+ return CronWords.format(CronWords.of(pi.ui.language)[key], values);
1125
+ }
1126
+ function icon(name) {
1127
+ return pi.ui.icons[name] ?? pi.ui.icons.Square;
1128
+ }
1129
+ function message(error) {
1130
+ return error instanceof Error ? error.message : String(error);
1131
+ }
1132
+ function until(time, now = Date.now()) {
1133
+ const minutes = Math.max(1, Math.round((time - now) / 60000));
1134
+ const zh = pi.ui.language === "zh-CN";
1135
+ const [amount, unit] = minutes < 60 ? [minutes, "minute"] : minutes < 48 * 60 ? [Math.round(minutes / 60), "hour"] : [Math.round(minutes / 1440), "day"];
1136
+ if (zh) {
1137
+ return `${amount} ${{ minute: "分钟", hour: "小时", day: "天" }[unit]}`;
1138
+ }
1139
+ return `${amount} ${unit}${amount === 1 ? "" : "s"}`;
1140
+ }
1141
+ function basename(path) {
1142
+ return path.replace(/[\\/]+$/, "").split(/[\\/]/).pop() || path;
1143
+ }
1144
+
1145
+ class CronClient {
1146
+ api;
1147
+ state = { tasks: [], loaded: false, runs: {} };
1148
+ listeners = new Set;
1149
+ newAsks = new Set;
1150
+ writing = new Set;
1151
+ reading;
1152
+ again = false;
1153
+ stop;
1154
+ constructor(api) {
1155
+ this.api = api;
1156
+ }
1157
+ start() {
1158
+ this.stop = this.api.storage.onChange((keys) => {
1159
+ if (keys.includes(Keys.TASKS)) {
1160
+ this.load();
1161
+ }
1162
+ for (const key of keys) {
1163
+ const id = key.startsWith("runs/") ? key.slice(5) : undefined;
1164
+ if (id && this.state.runs[id]) {
1165
+ this.loadRuns(id);
1166
+ }
1167
+ }
1168
+ });
1169
+ this.load();
1170
+ }
1171
+ dispose() {
1172
+ this.stop?.();
1173
+ this.listeners.clear();
1174
+ this.newAsks.clear();
1175
+ }
1176
+ subscribe(listener) {
1177
+ this.listeners.add(listener);
1178
+ return () => this.listeners.delete(listener);
1179
+ }
1180
+ askNew() {
1181
+ for (const listener of this.newAsks) {
1182
+ listener();
1183
+ }
1184
+ }
1185
+ onAskNew(listener) {
1186
+ this.newAsks.add(listener);
1187
+ return () => {
1188
+ this.newAsks.delete(listener);
874
1189
  };
875
1190
  }
876
- function unquote(value) {
877
- return /^(["']).*\1$/.test(value) ? value.slice(1, -1) : value;
1191
+ async load() {
1192
+ if (this.reading) {
1193
+ this.again = true;
1194
+ return this.reading;
1195
+ }
1196
+ this.reading = this.read();
1197
+ try {
1198
+ await this.reading;
1199
+ } finally {
1200
+ this.reading = undefined;
1201
+ if (this.again) {
1202
+ this.again = false;
1203
+ this.load();
1204
+ }
1205
+ }
1206
+ }
1207
+ async read() {
1208
+ await this.api.storage.get(Keys.TASKS).catch(() => {
1209
+ return;
1210
+ });
1211
+ const tasks = await this.api.callHost("list");
1212
+ if (this.writing.size === 0) {
1213
+ this.set({ tasks, loaded: true });
1214
+ }
1215
+ }
1216
+ async loadRuns(taskId) {
1217
+ await this.api.storage.get(Keys.runs(taskId)).catch(() => {
1218
+ return;
1219
+ });
1220
+ const runs = await this.api.callHost("runs", taskId);
1221
+ this.set({ runs: { ...this.state.runs, [taskId]: runs } });
1222
+ }
1223
+ call(method, ...params) {
1224
+ return this.api.callHost(method, ...params);
1225
+ }
1226
+ async add(input) {
1227
+ const task = await this.call("add", input);
1228
+ await this.load();
1229
+ return task;
1230
+ }
1231
+ async update(id, patch) {
1232
+ const task = await this.call("update", id, patch);
1233
+ await this.load();
1234
+ return task;
1235
+ }
1236
+ setEnabled(id, enabled) {
1237
+ return this.change(id, (task) => ({ ...task, enabled }), () => this.call("setEnabled", id, enabled));
1238
+ }
1239
+ runNow(id) {
1240
+ return this.change(id, (task) => ({ ...task, lastStatus: "running" }), () => this.call("run", id));
1241
+ }
1242
+ remove(id) {
1243
+ return this.change(id, () => {
1244
+ return;
1245
+ }, async () => {
1246
+ await this.call("remove", id);
1247
+ const { [id]: _gone, ...runs } = this.state.runs;
1248
+ this.set({ runs });
1249
+ });
1250
+ }
1251
+ async change(id, patch, send) {
1252
+ const before = this.state.tasks;
1253
+ this.writing.add(id);
1254
+ this.set({ tasks: before.map((task) => task.id === id ? patch(task) : task).filter((task) => task !== undefined) });
1255
+ try {
1256
+ await send();
1257
+ } catch (error) {
1258
+ this.set({ tasks: before });
1259
+ throw error;
1260
+ } finally {
1261
+ this.writing.delete(id);
1262
+ }
1263
+ await this.load();
1264
+ }
1265
+ set(change) {
1266
+ this.state = { ...this.state, ...change };
1267
+ for (const listener of this.listeners) {
1268
+ listener();
1269
+ }
1270
+ }
1271
+ }
1272
+ async function openRun(run) {
1273
+ if (!run.sessionFile) {
1274
+ pi.ui.notify(t("noChat"), "warning");
1275
+ return;
1276
+ }
1277
+ try {
1278
+ const open = (await pi.server.listSessions()).find((session) => session.sessionFile === run.sessionFile);
1279
+ const sessionId = open?.sessionId ?? (await pi.server.openSession({ cwd: run.cwd, sessionFile: run.sessionFile, group: NAME })).sessionId;
1280
+ await pi.switchSession(sessionId);
1281
+ pi.ui.showView("");
1282
+ } catch (error) {
1283
+ pi.ui.notify(t("failedAction", { message: message(error) }), "error");
1284
+ }
1285
+ }
1286
+ async function openMaking(cwd) {
1287
+ const model = await pi.packages.getExtensionData(EXTENSIONS, "makeModel").catch(() => {
1288
+ return;
1289
+ });
1290
+ if (typeof model === "string" && model) {
1291
+ try {
1292
+ return (await pi.server.openSession({ cwd, model })).sessionId;
1293
+ } catch (error) {
1294
+ pi.ui.notify(t("modelFailed", { model, message: message(error) }), "warning");
1295
+ }
1296
+ }
1297
+ return (await pi.server.openSession({ cwd })).sessionId;
1298
+ }
1299
+ async function makeExtension(task, runs) {
1300
+ try {
1301
+ const { cwd } = await pi.server.getServerInfo();
1302
+ const sessionId = openMaking(cwd);
1303
+ await pi.switchSession(sessionId, { title: t("makeExtension"), cwd });
1304
+ await pi.server.prompt(await sessionId, {
1305
+ clientMessageId: `ta-cron-extension:${task.id}:${Date.now()}`,
1306
+ message: TaskExtension.message(task, runs, pi.ui.language)
1307
+ });
1308
+ } catch (error) {
1309
+ pi.ui.notify(t("failedAction", { message: message(error) }), "error");
1310
+ }
1311
+ }
1312
+
1313
+ // web-src/react.ts
1314
+ var React;
1315
+ function bind(react) {
1316
+ React = react;
1317
+ }
1318
+ var idle = () => [false, async (action) => await action()];
1319
+ function useBusy(ui) {
1320
+ return (ui.useBusy ?? idle)();
1321
+ }
1322
+
1323
+ // web-src/composer.tsx
1324
+ var PRESETS = [
1325
+ { kind: "cron", expression: "0 * * * *" },
1326
+ { kind: "cron", expression: "0 9 * * *" },
1327
+ { kind: "cron", expression: "0 9 * * 1-5" },
1328
+ { kind: "cron", expression: "0 9 * * 1" }
1329
+ ];
1330
+ function composerAddon() {
1331
+ const send = (conversation, schedule) => void pi.server.prompt(conversation.sessionId, {
1332
+ clientMessageId: `ta-cron-chat:${Date.now()}`,
1333
+ message: ChatTask.message(pi.ui.language, schedule),
1334
+ streamingBehavior: "followUp"
1335
+ }).catch((error) => pi.ui.notify(t("failedAction", { message: message(error) }), "error"));
1336
+ return {
1337
+ actions: (conversation) => {
1338
+ if (conversation.group === NAME) {
1339
+ return [];
1340
+ }
1341
+ const AlarmClock = icon("AlarmClock");
1342
+ const group = t("fromChatWhen");
1343
+ return [
1344
+ {
1345
+ key: "make-task",
1346
+ label: t("fromChat"),
1347
+ detail: t("fromChatDetail"),
1348
+ icon: /* @__PURE__ */ React.createElement(AlarmClock, {
1349
+ size: 16
1350
+ }),
1351
+ items: [
1352
+ ...PRESETS.map((schedule) => ({
1353
+ key: `make-task:${schedule.kind === "cron" ? schedule.expression : ""}`,
1354
+ label: ScheduleUtil.describe(schedule, pi.ui.language),
1355
+ group,
1356
+ run: () => send(conversation, schedule)
1357
+ })),
1358
+ { key: "make-task:ask", label: t("fromChatOther"), detail: t("fromChatOtherDetail"), group, run: () => send(conversation) }
1359
+ ]
1360
+ }
1361
+ ];
1362
+ }
1363
+ };
1364
+ }
1365
+
1366
+ // web-src/next-card.tsx
1367
+ var SHOWN = 3;
1368
+ function nextTasks(tasks, shown = SHOWN) {
1369
+ const at = (task) => task.lastStatus === "running" ? 0 : task.nextRunAt ? new Date(task.nextRunAt).getTime() : Number.POSITIVE_INFINITY;
1370
+ return tasks.filter((task) => task.lastStatus === "running" || task.enabled && task.nextRunAt).sort((a, b) => at(a) - at(b)).slice(0, shown);
1371
+ }
1372
+ function NextCard({ client }) {
1373
+ const { tasks, loaded } = React.useSyncExternalStore((listener) => client.subscribe(listener), () => client.state);
1374
+ const [now, setNow] = React.useState(Date.now());
1375
+ React.useEffect(() => {
1376
+ const timer = setInterval(() => setNow(Date.now()), 30000);
1377
+ return () => clearInterval(timer);
1378
+ }, []);
1379
+ if (!loaded) {
1380
+ return /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
1381
+ rows: 2
1382
+ });
1383
+ }
1384
+ const next = nextTasks(tasks);
1385
+ if (next.length === 0) {
1386
+ return /* @__PURE__ */ React.createElement(pi.ui.Empty, {
1387
+ title: t("cardEmpty"),
1388
+ compact: true
1389
+ });
878
1390
  }
879
- function completions(prefix, tasks) {
880
- const parts = prefix.split(/\s+/);
881
- if (parts.length <= 1) {
882
- return ACTIONS.filter((action3) => action3.startsWith(parts[0] ?? "")).map((action3) => ({ value: `${action3} `, label: action3 }));
1391
+ return /* @__PURE__ */ React.createElement("div", {
1392
+ className: "tcr-card"
1393
+ }, next.map((task) => /* @__PURE__ */ React.createElement("button", {
1394
+ key: task.id,
1395
+ type: "button",
1396
+ className: "tcr-card-row",
1397
+ onClick: () => pi.ui.showView(PAGE)
1398
+ }, /* @__PURE__ */ React.createElement("span", {
1399
+ className: "tcr-card-name"
1400
+ }, task.name), /* @__PURE__ */ React.createElement("span", {
1401
+ className: "tcr-card-when"
1402
+ }, task.lastStatus === "running" ? t("running") : t("next", { time: until(new Date(task.nextRunAt ?? now).getTime(), now) })))));
1403
+ }
1404
+
1405
+ // web-src/notifier.ts
1406
+ var FRESH_MS = 2 * 60000;
1407
+ function watchRuns() {
1408
+ const told = new Set;
1409
+ let ready = false;
1410
+ const tell = async () => {
1411
+ const finished = await pi.storage.get(Keys.LATEST).catch(() => {
1412
+ return;
1413
+ });
1414
+ const run = finished?.run;
1415
+ if (!run || told.has(run.id)) {
1416
+ return;
883
1417
  }
884
- const [action2, ref] = parts;
885
- if (!["show", "runs", "run", "enable", "disable", "set", "remove"].includes(action2) || parts.length > 2) {
886
- return [];
1418
+ told.add(run.id);
1419
+ const ended = run.endedAt ? new Date(run.endedAt).getTime() : 0;
1420
+ if (!ready || !finished.notify || Date.now() - ended > FRESH_MS) {
1421
+ return;
887
1422
  }
888
- return tasks.filter((task) => task.id.startsWith(ref) || task.name.startsWith(ref)).map((task) => ({ value: `${action2} ${task.id} `, label: task.id, description: task.name }));
889
- }
890
- CommandParser.completions = completions;
891
- function loopCompletions(prefix) {
892
- if (/\s/.test(prefix)) {
893
- return [];
1423
+ const failed = run.status !== "success";
1424
+ const title = t(failed ? "failed" : "finished", { name: finished.taskName });
1425
+ pi.ui.notify(title, failed ? "error" : "info");
1426
+ if (typeof document !== "undefined" && document.hidden && typeof Notification !== "undefined" && Notification.permission === "granted") {
1427
+ const body = (run.error ?? run.summary ?? "").split(`
1428
+ `)[0].slice(0, 160);
1429
+ const notice = new Notification(title, { body, tag: run.id });
1430
+ notice.onclick = () => {
1431
+ window.focus();
1432
+ pi.ui.showView(PAGE);
1433
+ notice.close();
1434
+ };
894
1435
  }
895
- return [...Object.keys(NICKNAMES), "5m", "30m", "1h", "1d"].filter((item) => item.startsWith(prefix)).map((item) => ({ value: `${item} `, label: item }));
896
- }
897
- CommandParser.loopCompletions = loopCompletions;
898
- })(CommandParser ||= {});
899
- var CronText;
900
- ((CronText) => {
901
- function task(task2, now = new Date) {
902
- const state = !task2.enabled ? "off" : task2.lastStatus === "running" ? "running" : task2.nextRunAt ? `next ${ScheduleUtil.clock(new Date(task2.nextRunAt), now)}` : "done";
903
- const last = task2.lastStatus && task2.lastStatus !== "running" ? `, last ${task2.lastStatus}` : "";
904
- return `${task2.id} ${task2.name} (${ScheduleUtil.describe(task2.schedule, "en", now)}; ${state}${last}) in ${task2.cwd}`;
905
- }
906
- CronText.task = task;
907
- function run(run2, now = new Date) {
908
- const time = ScheduleUtil.clock(new Date(run2.startedAt), now);
909
- const took = run2.endedAt ? ` in ${Duration.format(new Date(run2.endedAt).getTime() - new Date(run2.startedAt).getTime())}` : "";
910
- const what = run2.error ?? run2.summary ?? "";
911
- const file = run2.sessionFile ? `
912
- conversation: ${run2.sessionFile}` : "";
913
- return `${run2.id} ${time} ${run2.status}${took}${run2.trigger === "manual" ? " (by hand)" : ""}${what ? `
914
- ${what.replace(/\n/g, `
915
- `)}` : ""}${file}`;
916
- }
917
- CronText.run = run;
918
- function reply(reply2) {
919
- switch (reply2.kind) {
920
- case "task":
921
- return `${capital(reply2.event)}: ${task(reply2.task)}`;
922
- case "removed":
923
- return reply2.tasks.length ? `Removed ${reply2.tasks.map((item) => item.name).join(", ")}.` : "No tasks to remove.";
924
- case "started":
925
- return `Started ${reply2.task.name} (${reply2.run.id}); it runs in a conversation of its own.`;
926
- case "list":
927
- return reply2.tasks.length ? reply2.tasks.map((item) => task(item)).join(`
928
- `) : "No scheduled tasks. Make one with /loop or /remind.";
929
- case "show":
930
- return `${task(reply2.task)}
931
- prompt: ${reply2.task.prompt}
932
- ${reply2.runs.length ? reply2.runs.map((item) => run(item)).join(`
933
- `) : "No runs yet."}`;
934
- case "help":
935
- return HELP;
936
- case "error":
937
- return reply2.message;
1436
+ };
1437
+ tell().finally(() => {
1438
+ ready = true;
1439
+ });
1440
+ return pi.storage.onChange((keys) => {
1441
+ if (keys.includes(Keys.LATEST)) {
1442
+ tell();
938
1443
  }
939
- }
940
- CronText.reply = reply;
941
- function capital(text) {
942
- return text[0].toUpperCase() + text.slice(1);
943
- }
944
- })(CronText ||= {});
1444
+ });
1445
+ }
945
1446
 
946
1447
  // web-src/reply.tsx
947
1448
  function TaskLine({ task }) {
@@ -1023,74 +1524,115 @@ function ReplyMessage({ message: message2 }) {
1023
1524
 
1024
1525
  // web-src/style.ts
1025
1526
  var STYLE = `
1527
+ /* The card of the board: the tasks to run next */
1026
1528
  .tcr-card { display: flex; flex-direction: column; margin: -4px -6px; }
1027
1529
  .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
1530
  .tcr-card-row:hover { background: var(--ta-hover); }
1029
1531
  .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
1532
  .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; }
1533
+
1534
+ /* The page: it scrolls in its own box, which takes what the main area has left under its head. */
1535
+ .tcr-scroll { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
1536
+ .tcr-page { box-sizing: border-box; width: 100%; max-width: 860px; margin: 0 auto; padding: 20px 24px 64px; }
1537
+ .tcr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-height: 28px; }
1033
1538
  .tcr-stat { color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); }
1034
1539
  /* 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
1540
  .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); }
1541
+
1542
+ /* Buttons and what is written quietly */
1543
+ /* As the buttons of the page (.ta-button). */
1544
+ .tcr-button { display: inline-flex; align-items: center; justify-content: 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; white-space: nowrap; cursor: pointer; transition: background 120ms, border-color 120ms, opacity 120ms, transform 120ms var(--ta-ease); }
1037
1545
  .tcr-button:hover:not(:disabled) { background: var(--ta-hover); }
1038
- .tcr-button:active:not(:disabled) { transform: scale(.98); }
1039
- .tcr-button:disabled { opacity: .45; cursor: default; }
1546
+ .tcr-button:active:not(:disabled) { transform: scale(.97); }
1547
+ .tcr-button:disabled:not(.ta-busy) { opacity: .45; cursor: default; }
1548
+ .tcr-button.ta-busy { position: relative; }
1549
+ .tcr-button > svg { flex: none; color: var(--ta-secondary); }
1040
1550
  .tcr-primary { background: var(--ta-brand); border-color: var(--ta-brand); color: var(--ta-brand-text); }
1041
1551
  .tcr-primary:hover:not(:disabled) { background: var(--ta-brand); opacity: .88; }
1552
+ /* What hands the task to Ta to make more of: green, as what Ta makes. */
1553
+ .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)); }
1554
+ .tcr-accent > svg { color: var(--ta-green); }
1555
+ .tcr-accent:hover:not(:disabled) { background: color-mix(in srgb, var(--ta-green) 16%, var(--ta-card)); }
1042
1556
  .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
1557
  .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; }
1558
+ .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
1559
  .tcr-icon:hover { background: var(--ta-hover); color: var(--ta-text); }
1046
1560
  .tcr-muted { color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
1047
1561
  .tcr-pad { padding: 6px 2px; }
1048
1562
  .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; }
1563
+ .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)); }
1564
+ .tcr-chevron { display: inline-flex; flex: none; color: var(--ta-muted); transition: transform 180ms var(--ta-ease); }
1565
+
1566
+ /* The tasks */
1567
+ .tcr-list { display: flex; flex-direction: column; gap: 10px; }
1568
+ .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
1569
  .tcr-task:hover, .tcr-task.tcr-open { border-color: var(--ta-border); }
1052
- .tcr-task.tcr-menu-open { position: relative; z-index: 5; }
1053
1570
  .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; }
1571
+ .tcr-disabled .tcr-task-name, .tcr-disabled .tcr-task-meta, .tcr-disabled .tcr-task-state, .tcr-disabled .tcr-mark { opacity: .55; }
1572
+ .tcr-task-row { display: flex; align-items: center; gap: 6px; padding-right: 10px; }
1573
+ /* What opens the task: the mark of its state, its name over its rule, directory and last run, then its next run. */
1574
+ .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; }
1575
+ .tcr-task-main:focus-visible { box-shadow: inset 0 0 0 2px var(--ta-border-focus); }
1576
+ /* A tile of the color of the task's state, its last run a dot at its corner. */
1577
+ .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); }
1578
+ .tcr-mark .tcr-dot { position: absolute; right: -2px; bottom: -2px; box-shadow: 0 0 0 2.5px var(--ta-card); }
1579
+ .tcr-tone-success { background: color-mix(in srgb, var(--ta-green) 14%, transparent); color: var(--ta-green); }
1580
+ .tcr-tone-error, .tcr-tone-missed { background: color-mix(in srgb, var(--ta-red) 13%, transparent); color: var(--ta-red); }
1581
+ .tcr-tone-running { background: color-mix(in srgb, var(--ta-blue) 15%, transparent); color: var(--ta-blue); }
1582
+ .tcr-task-text { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
1583
+ .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)); }
1584
+ .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; }
1585
+ .tcr-task-dir { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1586
+ .tcr-task-last { flex: none; white-space: nowrap; }
1587
+ .tcr-task-next { display: none; flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
1588
+ .tcr-task-last::before { content: '·'; margin-right: 8px; }
1060
1589
  .tcr-task-state { flex: none; color: var(--ta-secondary); font-size: calc(12.5px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
1061
1590
  .tcr-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ta-border); }
1062
1591
  .tcr-success { background: var(--ta-green); }
1063
1592
  .tcr-error, .tcr-missed { background: var(--ta-red); }
1064
1593
  .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); }
1594
+ .tcr-off { background: var(--ta-card); box-shadow: inset 0 0 0 1.5px var(--ta-border); }
1066
1595
  .tcr-pulse { animation: tcr-fade 1.6s ease-in-out infinite; }
1067
- @keyframes tcr-pulse { 50% { transform: scale(1.5); opacity: .5; } }
1596
+ @keyframes tcr-in { from { opacity: 0; transform: translateY(3px); } }
1597
+ @keyframes tcr-pulse { 50% { transform: scale(1.4); opacity: .55; } }
1068
1598
  @keyframes tcr-fade { 50% { opacity: .45; } }
1069
- .tcr-switch { position: relative; flex: none; width: 30px; height: 18px; cursor: pointer; }
1070
- .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); }
1073
- .tcr-switch input:checked + span { background: var(--ta-green); }
1074
- .tcr-switch input:checked + span::after { transform: translateX(12px); }
1075
- .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; }
1599
+
1600
+ /* The switch of a task: as the switches of the page */
1601
+ /* The switch of the page (ta-switch), in a label that a finger has room around. */
1602
+ .tcr-switch { position: relative; flex: none; display: flex; cursor: pointer; }
1603
+
1604
+ /* What a task holds, opened: what can be done with it, its prompt and its runs */
1605
+ .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); }
1606
+ .tcr-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
1607
+ .tcr-stats { margin-left: auto; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
1608
+ .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; }
1609
+ .tcr-prompt-block { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
1610
+ .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; }
1611
+ /* A long prompt: four lines (of 13px at 1.6), fading into the box, until the user shows the rest. */
1612
+ .tcr-clamped { max-height: calc(83px * var(--ta-font-scale)); overflow: hidden; }
1613
+ .tcr-fade { -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent); mask-image: linear-gradient(to bottom, #000 60%, transparent); }
1614
+ /* The runs: a line of time down their dots, the newest at the top. */
1615
+ .tcr-runs { position: relative; display: flex; flex-direction: column; gap: 2px; }
1616
+ .tcr-run { position: relative; border-radius: 10px; transition: background 140ms; }
1617
+ .tcr-run::before { content: ''; position: absolute; left: 13px; top: 22px; bottom: -6px; width: 1.5px; background: var(--ta-border-muted); }
1618
+ .tcr-run.tcr-last::before { display: none; }
1085
1619
  .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; }
1620
+ .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
1621
  .tcr-run-head:hover { background: var(--ta-hover); }
1622
+ .tcr-run-head:focus-visible { box-shadow: inset 0 0 0 2px var(--ta-border-focus); }
1623
+ .tcr-run-head .tcr-dot { position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--ta-card); }
1624
+ .tcr-run.tcr-open .tcr-run-head .tcr-dot, .tcr-run-head:hover .tcr-dot { box-shadow: none; }
1088
1625
  .tcr-run-time { flex: none; font-variant-numeric: tabular-nums; }
1089
1626
  .tcr-run-status { flex: none; color: var(--ta-secondary); }
1627
+ .tcr-is-error, .tcr-is-missed { color: var(--ta-red); }
1090
1628
  .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; }
1629
+ .tcr-open > .tcr-run-head .tcr-chevron { transform: rotate(90deg); }
1630
+ .tcr-run-head:not(:hover) .tcr-chevron { opacity: .6; }
1631
+ .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); }
1632
+ .tcr-run-body > :first-child { align-self: stretch; min-width: 0; overflow-wrap: anywhere; }
1093
1633
  .tcr-run-error { color: var(--ta-red); white-space: pre-wrap; }
1634
+
1635
+ /* The page without tasks */
1094
1636
  .tcr-empty { display: flex; flex-direction: column; align-items: center; padding: 48px 0 24px; text-align: center; }
1095
1637
  .tcr-empty-title { margin-top: 14px; font-size: calc(17px * var(--ta-font-scale)); font-weight: 600; }
1096
1638
  .tcr-empty-hint { margin-top: 6px; color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); }
@@ -1102,35 +1644,112 @@ var STYLE = `
1102
1644
  .tcr-clock-pin { fill: var(--ta-green); }
1103
1645
  @keyframes tcr-spin { to { transform: rotate(360deg); } }
1104
1646
  .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; }
1647
+
1648
+ /*
1649
+ * The dialog of a task: wider than the page's dialogs, for the row of rules; its fields scroll under the
1650
+ * title while its buttons stay at its foot.
1651
+ */
1652
+ .ta-web-dialog:has(> .tcr-form) { width: min(560px, 100%); max-height: min(84vh, 780px); padding-bottom: 0; }
1653
+ .tcr-form { box-sizing: border-box; display: flex; flex-direction: column; flex: 1; min-height: 0; margin: 0 -18px; }
1654
+ .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
1655
  .tcr-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
1108
1656
  .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; }
1657
+ .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; }
1658
+ .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); }
1659
+ .tcr-prompt { height: auto; min-height: 104px; padding: 9px 11px; line-height: 1.55; resize: vertical; }
1112
1660
  .tcr-mono { font-family: var(--ta-mono); }
1113
1661
  .tcr-amount { width: 90px; flex: none; }
1114
1662
  .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; }
1663
+ .tcr-segments { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--ta-raised); align-self: stretch; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
1664
+ .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(12.5px * var(--ta-font-scale)); font-weight: 500; white-space: nowrap; cursor: pointer; transition: background 140ms, color 140ms, box-shadow 140ms; }
1665
+ .tcr-segment:hover:not([aria-pressed='true']) { color: var(--ta-text); }
1666
+ /* As the segmented controls of the page (its settings). */
1667
+ .tcr-segment[aria-pressed='true'] { background: var(--ta-segment, var(--ta-card)); color: var(--ta-text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 0 0 1px var(--ta-border); }
1668
+ .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; }
1669
+ .tcr-preview.tcr-bad { background: color-mix(in srgb, var(--ta-red) 11%, transparent); color: var(--ta-red); }
1670
+ .tcr-folder { display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; }
1671
+ .tcr-folder:hover { border-color: var(--ta-border); background: var(--ta-hover); }
1672
+ .tcr-folder > svg { flex: none; color: var(--ta-muted); }
1673
+ .tcr-folder-name { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1121
1674
  .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
1675
  .tcr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
1123
1676
  .tcr-wide { grid-column: 1 / -1; }
1124
- .tcr-actions { display: flex; justify-content: flex-end; gap: 8px; }
1677
+ .tcr-options { display: flex; flex-direction: column; gap: 12px; }
1678
+ .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; }
1679
+ .tcr-more-toggle:hover { background: var(--ta-hover); color: var(--ta-text); }
1680
+ .tcr-more-toggle .tcr-chevron { transform: rotate(-90deg); }
1681
+ .tcr-options.tcr-open .tcr-more-toggle .tcr-chevron { transform: none; }
1682
+ .tcr-options .tcr-grid { animation: tcr-in 140ms var(--ta-ease); }
1683
+ .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); }
1684
+ .tcr-actions .tcr-button { padding: 0 14px; }
1685
+ .tcr-shortcut { margin-right: auto; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
1686
+
1687
+ /* A task in a conversation, as a command or the tool answers */
1125
1688
  .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
1689
  .tcr-reply-head { display: flex; align-items: center; gap: 8px; color: var(--ta-secondary); }
1127
1690
  .tcr-reply-head svg { color: var(--ta-green); }
1128
1691
  .tcr-reply-head .tcr-link { margin-left: auto; }
1129
1692
  .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; }
1693
+ .tcr-reply .tcr-prompt-text { margin: 8px 0 0; max-height: 160px; overflow: auto; }
1131
1694
  .tcr-reply-error { color: var(--ta-red); }
1132
1695
  .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; } }
1696
+
1697
+ /*
1698
+ * A phone (device/device-protocol.ts: data-layout): the name of a task over its rule and its next run,
1699
+ * so that the name is not cut to nothing by the rest; everything a finger taps is a finger's size.
1700
+ */
1701
+ [data-layout='compact'] .tcr-page { padding: 12px 10px 48px; }
1702
+ [data-layout='compact'] .tcr-head { margin-bottom: 8px; min-height: 24px; }
1703
+ [data-layout='compact'] .tcr-list { gap: 8px; }
1704
+ [data-layout='compact'] .tcr-task-row { gap: 2px; padding-right: 6px; }
1705
+ [data-layout='compact'] .tcr-task-main { gap: 10px; min-height: 68px; padding: 12px 2px 12px 12px; }
1706
+ [data-layout='compact'] .tcr-mark { width: 34px; height: 34px; }
1707
+ [data-layout='compact'] .tcr-task-name { font-size: calc(15px * var(--ta-font-scale)); }
1708
+ [data-layout='compact'] .tcr-task-dir, [data-layout='compact'] .tcr-task-last { display: none; }
1709
+ [data-layout='compact'] .tcr-task-state { display: none; }
1710
+ [data-layout='compact'] .tcr-task-next { display: inline; }
1711
+ [data-layout='compact'] .tcr-chip { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
1712
+ [data-layout='compact'] .tcr-detail { margin: 0 12px; padding: 12px 0 14px; }
1713
+ [data-layout='compact'] .tcr-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px 14px; padding: 0 12px; }
1714
+ [data-layout='compact'] .tcr-stats { display: none; }
1715
+ [data-layout='compact'] .tcr-run-head { flex-wrap: wrap; row-gap: 2px; padding: 8px; }
1716
+ /* What a run answered goes under its time rather than past it, where a phone has no room. */
1717
+ [data-layout='compact'] .tcr-run-line { box-sizing: border-box; flex: 1 1 100%; order: 9; padding-left: 18px; }
1718
+ [data-layout='compact'] .tcr-run::before { left: 11px; }
1719
+ [data-layout='compact'] .tcr-run-body { padding: 2px 10px 12px 14px; }
1720
+ [data-layout='compact'] .tcr-empty { padding: 32px 0 16px; }
1721
+ [data-layout='compact'] .tcr-clock { width: 92px; height: 92px; }
1722
+ [data-layout='compact'] .tcr-examples { margin-top: 20px; }
1723
+ [data-layout='compact'] .tcr-grid { grid-template-columns: 1fr; }
1724
+ [data-layout='compact'] .tcr-form-body { gap: 16px; }
1725
+ [data-layout='compact'] .ta-web-dialog:has(> .tcr-form) { max-height: min(92dvh, calc(100% - 8px - env(safe-area-inset-top))); }
1726
+ [data-layout='compact'] .tcr-actions { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
1727
+ [data-layout='compact'] .tcr-actions .tcr-button { flex: 1; justify-content: center; }
1728
+
1729
+ /* A finger: a target of its own size around what is drawn (44px), and the press showing at once. */
1730
+ [data-touch] .tcr-icon { width: 36px; height: 36px; border-radius: 10px; }
1731
+ [data-touch] .tcr-icon::after { content: ''; position: absolute; inset: -4px; }
1732
+ [data-touch] .tcr-icon:hover { background: none; }
1733
+ [data-touch] .tcr-icon:active { background: var(--ta-hover); color: var(--ta-text); }
1734
+ [data-touch] .tcr-switch::after { content: ''; position: absolute; inset: -12px -6px; }
1735
+ [data-touch] .tcr-task-main:active { background: var(--ta-hover); }
1736
+ [data-touch] .tcr-run-head { min-height: 44px; }
1737
+ [data-touch] .tcr-run-head:hover { background: none; }
1738
+ [data-touch] .tcr-run-head:active { background: var(--ta-hover); }
1739
+ [data-touch] .tcr-button { height: 36px; padding: 0 14px; }
1740
+ [data-touch] .tcr-segment { height: 32px; }
1741
+ [data-touch] .tcr-more-toggle { padding: 8px 6px 8px 4px; font-size: max(15px, calc(13.5px * var(--ta-font-scale))); }
1742
+ /* A link of the dialog, which a finger taps too: a line of its own height. */
1743
+ [data-touch] .tcr-link { padding: 8px 0; font-size: max(16px, calc(13.5px * var(--ta-font-scale))); }
1744
+ /* Under 16px iOS zooms into the field it focuses, which loses the dialog around it: never smaller. */
1745
+ [data-touch] .tcr-input { font-size: max(16px, calc(13.5px * var(--ta-font-scale))); }
1746
+ [data-touch] .tcr-folder { height: auto; min-height: 40px; padding: 6px 10px; }
1747
+ [data-touch] .tcr-folder-path { font-size: max(16px, calc(12px * var(--ta-font-scale))); }
1748
+
1749
+ @media (prefers-reduced-motion: reduce) {
1750
+ .tcr-task, .tcr-detail, .tcr-run-body, .tcr-clock-hand, .tcr-running, .tcr-pulse, .tcr-options .tcr-grid { animation: none; }
1751
+ .tcr-chevron { transition: none; }
1752
+ }
1134
1753
  `;
1135
1754
  function injectStyle() {
1136
1755
  const element = document.createElement("style");
@@ -1263,9 +1882,23 @@ var NOTIFY = [
1263
1882
  ["error", "notifyError"],
1264
1883
  ["never", "notifyNever"]
1265
1884
  ];
1885
+ var DAY_NAMES = new Map;
1266
1886
  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)));
1887
+ const language = pi.ui.language;
1888
+ let names = DAY_NAMES.get(language);
1889
+ if (!names) {
1890
+ const format = new Intl.DateTimeFormat(language === "zh-CN" ? "zh-CN" : "en", { weekday: "short" });
1891
+ names = Array.from({ length: 7 }, (_, day) => format.format(new Date(2023, 0, 1 + day)));
1892
+ DAY_NAMES.set(language, names);
1893
+ }
1894
+ return names;
1895
+ }
1896
+ function ruleKey(form) {
1897
+ return [form.mode, form.repeat, form.amount, form.unit, form.time, form.weekday, form.cron, form.at].join("|");
1898
+ }
1899
+ function usePreview(form) {
1900
+ const key = ruleKey(form);
1901
+ return React.useMemo(() => FormUtil.preview(form, new Date), [key]);
1269
1902
  }
1270
1903
  function Segments({ value, options, onChange }) {
1271
1904
  return /* @__PURE__ */ React.createElement("div", {
@@ -1307,7 +1940,7 @@ function ModelFields({ form, set, cwd }) {
1307
1940
  }, level)))));
1308
1941
  }
1309
1942
  function When({ form, set }) {
1310
- const preview = FormUtil.preview(form, new Date);
1943
+ const preview = usePreview(form);
1311
1944
  const days = weekdayNames();
1312
1945
  let rule = null;
1313
1946
  if (form.mode === "once") {
@@ -1358,24 +1991,24 @@ function When({ form, set }) {
1358
1991
  onChange: (event) => set({ time: event.target.value })
1359
1992
  }));
1360
1993
  }
1994
+ const kind = form.mode === "once" ? "once" : form.repeat;
1995
+ const kinds = [...REPEATS.map((repeat) => [repeat, t(repeat)]), ["once", t("once")]];
1996
+ const Clock = icon("Clock");
1997
+ const bad = !preview.next;
1361
1998
  return /* @__PURE__ */ React.createElement("div", {
1362
1999
  className: "tcr-field"
1363
2000
  }, /* @__PURE__ */ React.createElement("div", {
1364
2001
  className: "tcr-label"
1365
2002
  }, 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 })
2003
+ value: kind,
2004
+ options: kinds,
2005
+ onChange: (next) => set(next === "once" ? { mode: "once" } : { mode: "repeat", repeat: next })
1376
2006
  }), 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")));
2007
+ className: `tcr-preview${bad ? " tcr-bad" : ""}`,
2008
+ role: "status"
2009
+ }, /* @__PURE__ */ React.createElement(Clock, {
2010
+ size: 13
2011
+ }), preview.next ? t("preview", { time: ScheduleUtil.clock(preview.next) }) : preview.error || t("noNext")));
1379
2012
  }
1380
2013
  function TaskEditor({ client, editing, onClose }) {
1381
2014
  const Dialog = pi.ui.Dialog;
@@ -1392,8 +2025,10 @@ function TaskEditor({ client, editing, onClose }) {
1392
2025
  const [picking, setPicking] = React.useState(false);
1393
2026
  const [more, setMore] = React.useState(!!(form.name && editing.task) || !!form.notify);
1394
2027
  const [saving, setSaving] = React.useState(false);
2028
+ const touch = pi.ui.useDevice().touch;
1395
2029
  const set = (change) => setForm((current) => ({ ...current, ...change }));
1396
- const valid = form.prompt.trim().length > 0 && !!FormUtil.preview(form, new Date).next;
2030
+ const preview = usePreview(form);
2031
+ const valid = form.prompt.trim().length > 0 && !!preview.next;
1397
2032
  const save = async () => {
1398
2033
  if (!valid || saving) {
1399
2034
  return;
@@ -1402,9 +2037,9 @@ function TaskEditor({ client, editing, onClose }) {
1402
2037
  try {
1403
2038
  const input = FormUtil.input(form);
1404
2039
  if (editing.task) {
1405
- await client.call("update", editing.task.id, { ...input, name: form.name, model: form.model, thinking: form.thinking, notify: form.notify });
2040
+ await client.update(editing.task.id, { ...input, name: form.name, model: form.model, thinking: form.thinking, notify: form.notify });
1406
2041
  } else {
1407
- await client.call("add", input);
2042
+ await client.add(input);
1408
2043
  if (typeof Notification !== "undefined" && Notification.permission === "default") {
1409
2044
  Notification.requestPermission().catch(() => {
1410
2045
  return;
@@ -1418,21 +2053,26 @@ function TaskEditor({ client, editing, onClose }) {
1418
2053
  setSaving(false);
1419
2054
  }
1420
2055
  };
2056
+ const Folder = icon("Folder");
2057
+ const Chevron = icon("ChevronDown");
2058
+ const key = /Mac|iPhone|iPad/.test(navigator.platform) ? "⌘" : "Ctrl";
1421
2059
  return /* @__PURE__ */ React.createElement(Dialog, {
1422
2060
  title: editing.task ? t("editTask") : t("newTask"),
1423
2061
  onClose
1424
2062
  }, /* @__PURE__ */ React.createElement("div", {
1425
2063
  className: "tcr-form"
2064
+ }, /* @__PURE__ */ React.createElement("div", {
2065
+ className: "tcr-form-body"
1426
2066
  }, /* @__PURE__ */ React.createElement("label", {
1427
2067
  className: "tcr-field"
1428
2068
  }, /* @__PURE__ */ React.createElement("span", {
1429
2069
  className: "tcr-label"
1430
2070
  }, t("prompt")), /* @__PURE__ */ React.createElement("textarea", {
1431
2071
  className: "tcr-input tcr-prompt",
1432
- rows: 4,
2072
+ rows: 5,
1433
2073
  value: form.prompt,
1434
2074
  placeholder: t("promptPlaceholder"),
1435
- autoFocus: true,
2075
+ autoFocus: !touch,
1436
2076
  onChange: (event) => set({ prompt: event.target.value }),
1437
2077
  onKeyDown: (event) => (event.metaKey || event.ctrlKey) && event.key === "Enter" && void save()
1438
2078
  })), /* @__PURE__ */ React.createElement(When, {
@@ -1445,15 +2085,31 @@ function TaskEditor({ client, editing, onClose }) {
1445
2085
  }, t("directory")), /* @__PURE__ */ React.createElement("button", {
1446
2086
  type: "button",
1447
2087
  className: "tcr-input tcr-folder",
1448
- title: form.cwd,
2088
+ title: form.cwd || cwd,
1449
2089
  onClick: () => setPicking(true)
1450
- }, basename(form.cwd || cwd), /* @__PURE__ */ React.createElement("span", {
2090
+ }, /* @__PURE__ */ React.createElement(Folder, {
2091
+ size: 15
2092
+ }), /* @__PURE__ */ React.createElement("span", {
2093
+ className: "tcr-folder-name"
2094
+ }, basename(form.cwd || cwd)), /* @__PURE__ */ React.createElement("span", {
1451
2095
  className: "tcr-folder-path"
1452
- }, form.cwd || cwd))), /* @__PURE__ */ React.createElement(ModelFields, {
2096
+ }, `‎${form.cwd || cwd}‎`))), /* @__PURE__ */ React.createElement(ModelFields, {
1453
2097
  form,
1454
2098
  set,
1455
2099
  cwd: form.cwd || cwd
1456
- }), more ? /* @__PURE__ */ React.createElement("div", {
2100
+ }), /* @__PURE__ */ React.createElement("div", {
2101
+ className: `tcr-options${more ? " tcr-open" : ""}`
2102
+ }, /* @__PURE__ */ React.createElement("button", {
2103
+ type: "button",
2104
+ className: "tcr-more-toggle",
2105
+ "aria-expanded": more,
2106
+ onClick: () => setMore(!more)
2107
+ }, /* @__PURE__ */ React.createElement("span", {
2108
+ className: "tcr-chevron",
2109
+ "aria-hidden": "true"
2110
+ }, /* @__PURE__ */ React.createElement(Chevron, {
2111
+ size: 14
2112
+ })), t("moreOptions")), more && /* @__PURE__ */ React.createElement("div", {
1457
2113
  className: "tcr-grid"
1458
2114
  }, /* @__PURE__ */ React.createElement("label", {
1459
2115
  className: "tcr-field"
@@ -1475,22 +2131,23 @@ function TaskEditor({ client, editing, onClose }) {
1475
2131
  }, NOTIFY.map(([level, word]) => /* @__PURE__ */ React.createElement("option", {
1476
2132
  key: level,
1477
2133
  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", {
2134
+ }, t(word)))))))), /* @__PURE__ */ React.createElement("div", {
1483
2135
  className: "tcr-actions"
1484
- }, /* @__PURE__ */ React.createElement("button", {
2136
+ }, !touch && /* @__PURE__ */ React.createElement("span", {
2137
+ className: "tcr-shortcut"
2138
+ }, t("shortcut", { key, action: editing.task ? t("save") : t("create") })), /* @__PURE__ */ React.createElement("button", {
1485
2139
  type: "button",
1486
2140
  className: "tcr-button",
1487
2141
  onClick: onClose
1488
2142
  }, t("cancel")), /* @__PURE__ */ React.createElement("button", {
1489
2143
  type: "button",
1490
- className: "tcr-button tcr-primary",
2144
+ className: saving ? "tcr-button tcr-primary ta-busy" : "tcr-button tcr-primary",
2145
+ "aria-busy": saving || undefined,
1491
2146
  disabled: !valid || saving,
1492
2147
  onClick: () => void save()
1493
- }, editing.task ? t("save") : t("create")))), picking && /* @__PURE__ */ React.createElement(FolderPicker, {
2148
+ }, editing.task ? t("save") : t("create"), saving && /* @__PURE__ */ React.createElement("span", {
2149
+ className: "ta-spinner ta-busy-mark ta-on-brand"
2150
+ })))), picking && /* @__PURE__ */ React.createElement(FolderPicker, {
1494
2151
  initial: form.cwd || cwd,
1495
2152
  onPick: (path) => {
1496
2153
  set({ cwd: path });
@@ -1604,6 +2261,182 @@ function ExampleArt({ picture }) {
1604
2261
  return /* @__PURE__ */ React.createElement(Picture, null, /* @__PURE__ */ React.createElement(Shapes, null));
1605
2262
  }
1606
2263
 
2264
+ // web-src/task-util.ts
2265
+ var PROMPT_MAX2 = 20000;
2266
+ var NAME_MAX = 80;
2267
+ var PREFIX_MIN = 4;
2268
+ var TaskUtil;
2269
+ ((TaskUtil) => {
2270
+ function newId(prefix) {
2271
+ const bytes = new Uint8Array(4);
2272
+ crypto.getRandomValues(bytes);
2273
+ return `${prefix}_${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
2274
+ }
2275
+ TaskUtil.newId = newId;
2276
+ function create(input, cwd, now) {
2277
+ const prompt = checkPrompt(input?.prompt);
2278
+ const schedule = ScheduleUtil.check(input.schedule);
2279
+ const at = now.toISOString();
2280
+ const task = {
2281
+ id: newId("task"),
2282
+ name: checkName(input.name) ?? defaultName(prompt),
2283
+ prompt,
2284
+ schedule,
2285
+ cwd: checkCwd(input.cwd) ?? cwd,
2286
+ enabled: input.enabled !== false,
2287
+ runCount: 0,
2288
+ failCount: 0,
2289
+ createdAt: at,
2290
+ updatedAt: at
2291
+ };
2292
+ setOptional(task, input);
2293
+ return arm(task, now);
2294
+ }
2295
+ TaskUtil.create = create;
2296
+ function patch(task, patch2, now) {
2297
+ const next = { ...task, updatedAt: now.toISOString() };
2298
+ if (patch2.prompt !== undefined) {
2299
+ next.prompt = checkPrompt(patch2.prompt);
2300
+ }
2301
+ if (patch2.name !== undefined) {
2302
+ next.name = checkName(patch2.name) ?? defaultName(next.prompt);
2303
+ }
2304
+ if (patch2.cwd !== undefined) {
2305
+ next.cwd = checkCwd(patch2.cwd) ?? task.cwd;
2306
+ }
2307
+ setOptional(next, patch2);
2308
+ if (patch2.enabled !== undefined) {
2309
+ next.enabled = patch2.enabled === true;
2310
+ }
2311
+ if (patch2.schedule !== undefined) {
2312
+ next.schedule = ScheduleUtil.check(patch2.schedule);
2313
+ }
2314
+ const rearm = patch2.schedule !== undefined || next.enabled && !task.enabled;
2315
+ return rearm ? arm(next, now) : next;
2316
+ }
2317
+ TaskUtil.patch = patch;
2318
+ function arm(task, now) {
2319
+ if (!task.enabled) {
2320
+ return task;
2321
+ }
2322
+ const next = ScheduleUtil.next(task.schedule, now);
2323
+ if (!next) {
2324
+ 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.`);
2325
+ }
2326
+ return { ...task, nextRunAt: next.toISOString() };
2327
+ }
2328
+ TaskUtil.arm = arm;
2329
+ function find(tasks, ref) {
2330
+ const text = typeof ref === "string" ? ref.trim() : "";
2331
+ 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);
2332
+ if (!found) {
2333
+ const known = tasks.length ? tasks.map((task) => `${task.id} (${task.name})`).join(", ") : "none yet";
2334
+ throw new Error(`No task is ${JSON.stringify(text)}. The tasks: ${known}.`);
2335
+ }
2336
+ return found;
2337
+ }
2338
+ TaskUtil.find = find;
2339
+ function systemPrompt(task, now) {
2340
+ return [
2341
+ RUN_MARK,
2342
+ `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()}.`,
2343
+ "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.",
2344
+ "</ta-cron-run>"
2345
+ ].join(`
2346
+ `);
2347
+ }
2348
+ TaskUtil.systemPrompt = systemPrompt;
2349
+ function only(tasks) {
2350
+ return tasks.length === 1 ? tasks[0] : undefined;
2351
+ }
2352
+ function setOptional(task, input) {
2353
+ if (input.model !== undefined) {
2354
+ task.model = checkModel(input.model);
2355
+ }
2356
+ if (input.thinking !== undefined) {
2357
+ task.thinking = checkThinking(input.thinking);
2358
+ }
2359
+ if (input.notify !== undefined) {
2360
+ task.notify = checkNotify(input.notify);
2361
+ }
2362
+ if (input.timeout !== undefined) {
2363
+ task.timeout = checkTimeout(input.timeout);
2364
+ }
2365
+ for (const key of ["model", "thinking", "notify", "timeout"]) {
2366
+ if (task[key] === undefined) {
2367
+ delete task[key];
2368
+ }
2369
+ }
2370
+ }
2371
+ function checkPrompt(value) {
2372
+ const prompt = typeof value === "string" ? value.trim() : "";
2373
+ if (!prompt) {
2374
+ throw new Error("A task needs a prompt: what Ta should do each time it runs.");
2375
+ }
2376
+ if (prompt.length > PROMPT_MAX2) {
2377
+ throw new Error(`A prompt is at most ${PROMPT_MAX2} characters; keep long instructions in a file and name it.`);
2378
+ }
2379
+ return prompt;
2380
+ }
2381
+ function checkName(value) {
2382
+ const name = typeof value === "string" ? value.trim() : "";
2383
+ return name ? name.slice(0, NAME_MAX) : undefined;
2384
+ }
2385
+ function defaultName(prompt) {
2386
+ const line = prompt.split(`
2387
+ `)[0].trim();
2388
+ return line.length > 40 ? `${line.slice(0, 39)}…` : line;
2389
+ }
2390
+ function checkCwd(value) {
2391
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
2392
+ }
2393
+ function checkModel(value) {
2394
+ const model = typeof value === "string" ? value.trim() : "";
2395
+ return model || undefined;
2396
+ }
2397
+ function checkThinking(value) {
2398
+ const level = typeof value === "string" ? value.trim() : "";
2399
+ if (level && !THINKING_LEVELS.includes(level)) {
2400
+ throw new Error(`A thinking level is one of ${THINKING_LEVELS.join(", ")}; not ${JSON.stringify(level)}.`);
2401
+ }
2402
+ return level || undefined;
2403
+ }
2404
+ function timeoutMs(task, fallback) {
2405
+ return task.timeout && Duration.parse(task.timeout) || fallback;
2406
+ }
2407
+ TaskUtil.timeoutMs = timeoutMs;
2408
+ function checkTimeout(value) {
2409
+ const text = typeof value === "string" ? value.trim() : "";
2410
+ if (!text) {
2411
+ return;
2412
+ }
2413
+ const ms = Duration.parse(text);
2414
+ if (ms === undefined || ms < Limits.RUN_TIMEOUT_MIN_MS || ms > Limits.RUN_TIMEOUT_MAX_MS) {
2415
+ throw new Error(`A timeout is a duration from 5m to 4h, as 90m or 2h; not ${JSON.stringify(text)}.`);
2416
+ }
2417
+ return Duration.format(ms);
2418
+ }
2419
+ function checkNotify(value) {
2420
+ if (value === "" || value === null) {
2421
+ return;
2422
+ }
2423
+ if (!NOTIFY_LEVELS.includes(value)) {
2424
+ throw new Error(`notify is one of ${NOTIFY_LEVELS.join(", ")}; not ${JSON.stringify(value)}.`);
2425
+ }
2426
+ return value;
2427
+ }
2428
+ function firstLine(text) {
2429
+ const line = text.split(`
2430
+ `).find((candidate) => candidate.trim()) ?? "";
2431
+ return line.replace(/^\s*(?:#{1,6}\s+|[-*+]\s+|>\s*|\d+[.)]\s+)/, "").replace(/\*\*|__|`/g, "").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").trim();
2432
+ }
2433
+ TaskUtil.firstLine = firstLine;
2434
+ function missed(task, now) {
2435
+ return task.schedule.kind === "once" && !!task.nextRunAt && now.getTime() - new Date(task.nextRunAt).getTime() > Limits.GRACE_MS;
2436
+ }
2437
+ TaskUtil.missed = missed;
2438
+ })(TaskUtil ||= {});
2439
+
1607
2440
  // web-src/tasks-view.tsx
1608
2441
  function useClient(client) {
1609
2442
  return React.useSyncExternalStore((listener) => client.subscribe(listener), () => client.state);
@@ -1705,33 +2538,39 @@ function outcome(run) {
1705
2538
  }
1706
2539
  return run.error ?? run.summary;
1707
2540
  }
1708
- function RunRow({ run, now }) {
2541
+ function RunRow({ run, now, last }) {
1709
2542
  const [open, setOpen] = React.useState(false);
1710
2543
  const Markdown = pi.ui.Markdown;
1711
2544
  const Open = icon("MessageSquareText");
2545
+ const Chevron = icon("ChevronRight");
1712
2546
  const took = run.endedAt ? Duration.format(Math.max(1000, new Date(run.endedAt).getTime() - new Date(run.startedAt).getTime())) : undefined;
1713
2547
  const text = outcome(run);
1714
2548
  const label = run.status === "running" ? t("running") : t(run.status);
1715
2549
  return /* @__PURE__ */ React.createElement("div", {
1716
- className: `tcr-run${open ? " tcr-open" : ""}`
2550
+ className: `tcr-run${open ? " tcr-open" : ""}${last ? " tcr-last" : ""}`
1717
2551
  }, /* @__PURE__ */ React.createElement("button", {
1718
2552
  type: "button",
1719
2553
  className: "tcr-run-head",
1720
- onClick: () => setOpen(!open)
2554
+ onClick: () => setOpen(!open),
2555
+ "aria-expanded": open
1721
2556
  }, /* @__PURE__ */ React.createElement(Dot, {
1722
2557
  status: run.status
1723
2558
  }), /* @__PURE__ */ React.createElement("span", {
1724
2559
  className: "tcr-run-time"
1725
2560
  }, ScheduleUtil.clock(new Date(run.startedAt), new Date(now))), /* @__PURE__ */ React.createElement("span", {
1726
- className: "tcr-run-status"
2561
+ className: `tcr-run-status tcr-is-${run.status}`
1727
2562
  }, label), took && /* @__PURE__ */ React.createElement("span", {
1728
2563
  className: "tcr-muted"
1729
2564
  }, took), run.trigger === "manual" && /* @__PURE__ */ React.createElement("span", {
1730
2565
  className: "tcr-chip"
1731
- }, t("byHand")), !open && text && /* @__PURE__ */ React.createElement("span", {
2566
+ }, t("byHand")), /* @__PURE__ */ React.createElement("span", {
1732
2567
  className: "tcr-run-line"
1733
- }, text.split(`
1734
- `)[0])), open && /* @__PURE__ */ React.createElement("div", {
2568
+ }, !open && text ? TaskUtil.firstLine(text) : ""), /* @__PURE__ */ React.createElement("span", {
2569
+ className: "tcr-chevron",
2570
+ "aria-hidden": "true"
2571
+ }, /* @__PURE__ */ React.createElement(Chevron, {
2572
+ size: 14
2573
+ }))), open && /* @__PURE__ */ React.createElement("div", {
1735
2574
  className: "tcr-run-body"
1736
2575
  }, text && (run.status === "success" ? /* @__PURE__ */ React.createElement(Markdown, {
1737
2576
  text
@@ -1745,7 +2584,30 @@ function RunRow({ run, now }) {
1745
2584
  size: 14
1746
2585
  }), t("openChat"))));
1747
2586
  }
1748
- function Detail({ client, task, now }) {
2587
+ function PromptText({ text }) {
2588
+ const [whole, setWhole] = React.useState(false);
2589
+ const [long, setLong] = React.useState(false);
2590
+ const box = React.useRef(null);
2591
+ React.useLayoutEffect(() => {
2592
+ const element = box.current;
2593
+ if (element && !whole) {
2594
+ setLong(element.scrollHeight > element.clientHeight + 2);
2595
+ }
2596
+ }, [text, whole]);
2597
+ return /* @__PURE__ */ React.createElement("div", {
2598
+ className: "tcr-prompt-block"
2599
+ }, /* @__PURE__ */ React.createElement("div", {
2600
+ className: "tcr-prompt-text"
2601
+ }, /* @__PURE__ */ React.createElement("div", {
2602
+ ref: box,
2603
+ className: `${whole ? "" : "tcr-clamped"}${long && !whole ? " tcr-fade" : ""}`
2604
+ }, text)), (long || whole) && /* @__PURE__ */ React.createElement("button", {
2605
+ type: "button",
2606
+ className: "tcr-link",
2607
+ onClick: () => setWhole(!whole)
2608
+ }, whole ? t("showLess") : t("showAll")));
2609
+ }
2610
+ function Detail({ client, task, now, onEdit }) {
1749
2611
  const { runs } = useClient(client);
1750
2612
  React.useEffect(() => {
1751
2613
  client.loadRuns(task.id).catch(() => {
@@ -1753,82 +2615,113 @@ function Detail({ client, task, now }) {
1753
2615
  });
1754
2616
  }, [client, task.id]);
1755
2617
  const list = runs[task.id];
2618
+ const Play = icon("Play");
2619
+ const Pencil = icon("Pencil");
2620
+ const Sparkles = icon("Sparkles");
2621
+ const running = task.lastStatus === "running";
1756
2622
  return /* @__PURE__ */ React.createElement("div", {
1757
2623
  className: "tcr-detail"
1758
2624
  }, /* @__PURE__ */ React.createElement("div", {
1759
- className: "tcr-prompt-text"
1760
- }, task.prompt), /* @__PURE__ */ React.createElement("div", {
2625
+ className: "tcr-toolbar"
2626
+ }, /* @__PURE__ */ React.createElement("button", {
2627
+ type: "button",
2628
+ className: "tcr-button",
2629
+ disabled: running,
2630
+ onClick: () => void guard(() => client.runNow(task.id))
2631
+ }, /* @__PURE__ */ React.createElement(Play, {
2632
+ size: 14
2633
+ }), t("runNow")), /* @__PURE__ */ React.createElement("button", {
2634
+ type: "button",
2635
+ className: "tcr-button",
2636
+ onClick: () => onEdit(task)
2637
+ }, /* @__PURE__ */ React.createElement(Pencil, {
2638
+ size: 14
2639
+ }), t("edit")), /* @__PURE__ */ React.createElement("button", {
2640
+ type: "button",
2641
+ className: "tcr-button tcr-accent",
2642
+ title: t("makeExtensionHint"),
2643
+ onClick: () => void makeExtension(task, list)
2644
+ }, /* @__PURE__ */ React.createElement(Sparkles, {
2645
+ size: 14
2646
+ }), t("makeExtension")), task.runCount > 0 && /* @__PURE__ */ React.createElement("span", {
2647
+ className: "tcr-stats"
2648
+ }, t(task.failCount > 0 ? "statsFailed" : "stats", { runs: task.runCount, fails: task.failCount }))), /* @__PURE__ */ React.createElement("div", {
2649
+ className: "tcr-label"
2650
+ }, t("promptLabel")), /* @__PURE__ */ React.createElement(PromptText, {
2651
+ text: task.prompt
2652
+ }), /* @__PURE__ */ React.createElement("div", {
1761
2653
  className: "tcr-label"
1762
- }, t("runs")), list && list.length === 0 && /* @__PURE__ */ React.createElement("div", {
2654
+ }, t("runs"), list && list.length > 0 && /* @__PURE__ */ React.createElement("span", {
2655
+ className: "tcr-count"
2656
+ }, list.length)), list === undefined && /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
2657
+ rows: 2
2658
+ }), list?.length === 0 && /* @__PURE__ */ React.createElement("div", {
1763
2659
  className: "tcr-muted tcr-pad"
1764
- }, t("noRuns")), list?.map((run) => /* @__PURE__ */ React.createElement(RunRow, {
2660
+ }, t("noRuns")), list && list.length > 0 && /* @__PURE__ */ React.createElement("div", {
2661
+ className: "tcr-runs"
2662
+ }, list.map((run, index) => /* @__PURE__ */ React.createElement(RunRow, {
1765
2663
  key: run.id,
1766
2664
  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
- }));
2665
+ now,
2666
+ last: index === list.length - 1
2667
+ }))));
1800
2668
  }
1801
2669
  function TaskRow({ client, task, now, onEdit }) {
1802
2670
  const [open, setOpen] = React.useState(false);
1803
- const [menu, setMenu] = React.useState(false);
2671
+ const [menu, openMenu] = pi.ui.useContextMenu();
1804
2672
  const More = icon("Ellipsis");
2673
+ const Mark = icon(task.schedule.kind === "once" ? "Clock" : "AlarmClock");
1805
2674
  const running = task.lastStatus === "running";
1806
2675
  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");
2676
+ const tone = running ? "running" : !task.enabled ? "off" : task.lastStatus ?? "idle";
2677
+ const [switching, run] = useBusy(pi.ui);
1807
2678
  const remove = async () => {
1808
2679
  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));
2680
+ await guard(() => client.remove(task.id));
1810
2681
  }
1811
2682
  };
2683
+ const items = [
2684
+ [
2685
+ { key: "run", label: t("runNow"), icon: icon("Play"), disabled: running, run: () => void guard(() => client.runNow(task.id)) },
2686
+ { key: "edit", label: t("edit"), icon: icon("Pencil"), run: () => onEdit(task) },
2687
+ { key: "extension", label: t("makeExtension"), icon: icon("Sparkles"), run: () => void makeExtension(task, client.state.runs[task.id]) }
2688
+ ],
2689
+ [{ key: "delete", label: t("delete"), icon: icon("Trash2"), danger: true, run: () => void remove() }]
2690
+ ];
1812
2691
  return /* @__PURE__ */ React.createElement("div", {
1813
- className: `tcr-task${open ? " tcr-open" : ""}${menu ? " tcr-menu-open" : ""}${task.enabled ? "" : " tcr-disabled"}`
2692
+ className: `tcr-task${open ? " tcr-open" : ""}${task.enabled ? "" : " tcr-disabled"}`
1814
2693
  }, /* @__PURE__ */ React.createElement("div", {
1815
2694
  className: "tcr-task-row"
1816
2695
  }, /* @__PURE__ */ React.createElement("button", {
1817
2696
  type: "button",
1818
2697
  className: "tcr-task-main",
1819
2698
  onClick: () => setOpen(!open),
2699
+ onContextMenu: (event) => openMenu(event, items),
1820
2700
  "aria-expanded": open
1821
- }, /* @__PURE__ */ React.createElement(Dot, {
2701
+ }, /* @__PURE__ */ React.createElement("span", {
2702
+ className: `tcr-mark tcr-tone-${tone}`,
2703
+ "aria-hidden": "true"
2704
+ }, /* @__PURE__ */ React.createElement(Mark, {
2705
+ size: 17
2706
+ }), /* @__PURE__ */ React.createElement(Dot, {
1822
2707
  status: task.lastStatus,
1823
2708
  enabled: task.enabled || running
1824
- }), /* @__PURE__ */ React.createElement("span", {
2709
+ })), /* @__PURE__ */ React.createElement("span", {
2710
+ className: "tcr-task-text"
2711
+ }, /* @__PURE__ */ React.createElement("span", {
1825
2712
  className: "tcr-task-name"
1826
2713
  }, task.name), /* @__PURE__ */ React.createElement("span", {
2714
+ className: "tcr-task-meta"
2715
+ }, /* @__PURE__ */ React.createElement("span", {
1827
2716
  className: "tcr-chip"
1828
2717
  }, ScheduleUtil.describe(task.schedule, pi.ui.language, new Date(now))), /* @__PURE__ */ React.createElement("span", {
1829
2718
  className: "tcr-task-dir",
1830
2719
  title: task.cwd
1831
2720
  }, basename(task.cwd)), /* @__PURE__ */ React.createElement("span", {
2721
+ className: `tcr-task-next${running ? " tcr-pulse" : ""}`
2722
+ }, state), task.lastRunAt && /* @__PURE__ */ React.createElement("span", {
2723
+ className: "tcr-task-last"
2724
+ }, t("lastRun", { time: ScheduleUtil.clock(new Date(task.lastRunAt), new Date(now)) })))), /* @__PURE__ */ React.createElement("span", {
1832
2725
  className: `tcr-task-state${running ? " tcr-pulse" : ""}`,
1833
2726
  title: task.nextRunAt ? t("nextAt", { time: ScheduleUtil.clock(new Date(task.nextRunAt)) }) : undefined
1834
2727
  }, state)), /* @__PURE__ */ React.createElement("label", {
@@ -1836,29 +2729,30 @@ function TaskRow({ client, task, now, onEdit }) {
1836
2729
  title: t("enable")
1837
2730
  }, /* @__PURE__ */ React.createElement("input", {
1838
2731
  type: "checkbox",
2732
+ role: "switch",
2733
+ className: switching ? "ta-switch ta-busy" : "ta-switch",
1839
2734
  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", {
2735
+ "aria-label": t("enable"),
2736
+ "aria-checked": task.enabled,
2737
+ "aria-busy": switching || undefined,
2738
+ onChange: (event) => {
2739
+ const on = event.target.checked;
2740
+ run(() => guard(() => client.setEnabled(task.id, on)));
2741
+ }
2742
+ })), /* @__PURE__ */ React.createElement("button", {
1844
2743
  type: "button",
1845
- className: "tcr-icon",
2744
+ className: "tcr-icon tcr-more",
1846
2745
  "aria-label": t("more"),
1847
- onClick: () => setMenu(!menu)
2746
+ "aria-haspopup": "menu",
2747
+ onClick: (event) => openMenu(event, items)
1848
2748
  }, /* @__PURE__ */ React.createElement(More, {
1849
2749
  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
2750
  }))), open && /* @__PURE__ */ React.createElement(Detail, {
1858
2751
  client,
1859
2752
  task,
1860
- now
1861
- }));
2753
+ now,
2754
+ onEdit
2755
+ }), menu);
1862
2756
  }
1863
2757
  function TasksHead({ client }) {
1864
2758
  const Plus = icon("Plus");
@@ -1877,17 +2771,16 @@ function TasksHead({ client }) {
1877
2771
  })));
1878
2772
  }
1879
2773
  function TasksPage({ client }) {
1880
- const { tasks, loaded, asks } = useClient(client);
2774
+ const { tasks, loaded } = useClient(client);
1881
2775
  const now = useMinute();
1882
2776
  const [editing, setEditing] = React.useState();
1883
- React.useEffect(() => {
1884
- if (asks > 0) {
1885
- setEditing({});
1886
- }
1887
- }, [asks]);
2777
+ React.useEffect(() => client.onAskNew(() => setEditing({})), [client]);
1888
2778
  const running = tasks.filter((task) => task.lastStatus === "running").length;
1889
2779
  const sorted = [...tasks].sort((a, b) => Number(b.enabled) - Number(a.enabled) || (a.nextRunAt ?? "~").localeCompare(b.nextRunAt ?? "~"));
2780
+ const edit = React.useCallback((task) => setEditing({ task }), []);
1890
2781
  return /* @__PURE__ */ React.createElement("div", {
2782
+ className: "tcr-scroll"
2783
+ }, /* @__PURE__ */ React.createElement("div", {
1891
2784
  className: "tcr-page"
1892
2785
  }, tasks.length > 0 && /* @__PURE__ */ React.createElement("div", {
1893
2786
  className: "tcr-head"
@@ -1895,7 +2788,9 @@ function TasksPage({ client }) {
1895
2788
  className: "tcr-stat"
1896
2789
  }, t("count", { count: tasks.length }), running > 0 && /* @__PURE__ */ React.createElement("span", {
1897
2790
  className: "tcr-pulse"
1898
- }, " · ", t("runningCount", { count: running })))), loaded && tasks.length === 0 && /* @__PURE__ */ React.createElement(Empty, {
2791
+ }, " · ", t("runningCount", { count: running })))), !loaded && /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
2792
+ rows: 3
2793
+ }), loaded && tasks.length === 0 && /* @__PURE__ */ React.createElement(Empty, {
1899
2794
  onPick: setEditing
1900
2795
  }), /* @__PURE__ */ React.createElement("div", {
1901
2796
  className: "tcr-list"
@@ -1904,14 +2799,48 @@ function TasksPage({ client }) {
1904
2799
  client,
1905
2800
  task,
1906
2801
  now,
1907
- onEdit: (item) => setEditing({ task: item })
1908
- }))), editing && /* @__PURE__ */ React.createElement(TaskEditor, {
2802
+ onEdit: edit
2803
+ })))), editing && /* @__PURE__ */ React.createElement(TaskEditor, {
1909
2804
  client,
1910
2805
  editing,
1911
2806
  onClose: () => setEditing(undefined)
1912
2807
  }));
1913
2808
  }
1914
2809
 
2810
+ // web-src/tool-line.ts
2811
+ var VERBS = {
2812
+ add: "toolAdd",
2813
+ update: "toolUpdate",
2814
+ list: "toolList",
2815
+ show: "toolShow",
2816
+ enable: "toolEnable",
2817
+ disable: "toolDisable",
2818
+ delete: "toolDelete",
2819
+ run: "toolRun",
2820
+ runs: "toolRuns",
2821
+ clear: "toolClear"
2822
+ };
2823
+ function text(value) {
2824
+ return typeof value === "string" ? value.trim() : "";
2825
+ }
2826
+ var CronToolLine;
2827
+ ((CronToolLine) => {
2828
+ function renderCall(args, t2) {
2829
+ const action = text(args.action);
2830
+ const verb = t2(VERBS[action] ?? "toolOther");
2831
+ if (action === "add") {
2832
+ return { verb, target: text(args.name) || text(args.prompt).split(`
2833
+ `)[0] };
2834
+ }
2835
+ return { verb, target: action === "list" || action === "clear" ? "" : text(args.name) || text(args.id) };
2836
+ }
2837
+ CronToolLine.renderCall = renderCall;
2838
+ function register(pi2, t2) {
2839
+ pi2.registerToolRenderer?.((name, next) => name === TOOL_NAME ? { renderCall: (args) => renderCall(args, t2) } : next());
2840
+ }
2841
+ CronToolLine.register = register;
2842
+ })(CronToolLine ||= {});
2843
+
1915
2844
  // web-src/index.tsx
1916
2845
  function activate(pi2) {
1917
2846
  bind(pi2.React);
@@ -1941,6 +2870,8 @@ function activate(pi2) {
1941
2870
  })
1942
2871
  });
1943
2872
  pi2.registerMessageRenderer(REPLY_TYPE, ReplyMessage);
2873
+ pi2.registerComposerAddon(composerAddon());
2874
+ CronToolLine.register(pi2, (key) => t(key));
1944
2875
  const stopWatching = watchRuns();
1945
2876
  return () => {
1946
2877
  stopWatching();