@celljs/ta 4.7.0 → 4.8.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 (421) hide show
  1. package/README.en.md +5 -1
  2. package/README.md +4 -0
  3. package/dist/cli.mjs +20 -7
  4. package/dist/pi/CHANGELOG.md +24 -0
  5. package/dist/pi/package.json +1 -1
  6. package/dist/pi/packages/ta-agents/README.en.md +68 -0
  7. package/dist/pi/packages/ta-agents/README.md +68 -0
  8. package/dist/pi/packages/ta-agents/extension/index.mjs +1746 -0
  9. package/dist/pi/packages/ta-agents/fixtures/fake-acp-agent.mjs +183 -0
  10. package/dist/pi/packages/ta-agents/lib/acp-agent.d.ts +52 -0
  11. package/dist/pi/packages/ta-agents/lib/acp-agent.d.ts.map +1 -0
  12. package/dist/pi/packages/ta-agents/lib/acp-agent.js +218 -0
  13. package/dist/pi/packages/ta-agents/lib/acp-agent.js.map +1 -0
  14. package/dist/pi/packages/ta-agents/lib/acp-protocol.d.ts +153 -0
  15. package/dist/pi/packages/ta-agents/lib/acp-protocol.d.ts.map +1 -0
  16. package/dist/pi/packages/ta-agents/lib/acp-protocol.js +45 -0
  17. package/dist/pi/packages/ta-agents/lib/acp-protocol.js.map +1 -0
  18. package/dist/pi/packages/ta-agents/lib/agent-bindings.d.ts +45 -0
  19. package/dist/pi/packages/ta-agents/lib/agent-bindings.d.ts.map +1 -0
  20. package/dist/pi/packages/ta-agents/lib/agent-bindings.js +135 -0
  21. package/dist/pi/packages/ta-agents/lib/agent-bindings.js.map +1 -0
  22. package/dist/pi/packages/ta-agents/lib/agent-catalog.d.ts +50 -0
  23. package/dist/pi/packages/ta-agents/lib/agent-catalog.d.ts.map +1 -0
  24. package/dist/pi/packages/ta-agents/lib/agent-catalog.js +143 -0
  25. package/dist/pi/packages/ta-agents/lib/agent-catalog.js.map +1 -0
  26. package/dist/pi/packages/ta-agents/lib/agent-prompt.d.ts +18 -0
  27. package/dist/pi/packages/ta-agents/lib/agent-prompt.d.ts.map +1 -0
  28. package/dist/pi/packages/ta-agents/lib/agent-prompt.js +86 -0
  29. package/dist/pi/packages/ta-agents/lib/agent-prompt.js.map +1 -0
  30. package/dist/pi/packages/ta-agents/lib/agent-session.d.ts +71 -0
  31. package/dist/pi/packages/ta-agents/lib/agent-session.d.ts.map +1 -0
  32. package/dist/pi/packages/ta-agents/lib/agent-session.js +215 -0
  33. package/dist/pi/packages/ta-agents/lib/agent-session.js.map +1 -0
  34. package/dist/pi/packages/ta-agents/lib/agent-streamer.d.ts +41 -0
  35. package/dist/pi/packages/ta-agents/lib/agent-streamer.d.ts.map +1 -0
  36. package/dist/pi/packages/ta-agents/lib/agent-streamer.js +163 -0
  37. package/dist/pi/packages/ta-agents/lib/agent-streamer.js.map +1 -0
  38. package/dist/pi/packages/ta-agents/lib/agent-tool.d.ts +22 -0
  39. package/dist/pi/packages/ta-agents/lib/agent-tool.d.ts.map +1 -0
  40. package/dist/pi/packages/ta-agents/lib/agent-tool.js +88 -0
  41. package/dist/pi/packages/ta-agents/lib/agent-tool.js.map +1 -0
  42. package/dist/pi/packages/ta-agents/lib/agent-turn.d.ts +115 -0
  43. package/dist/pi/packages/ta-agents/lib/agent-turn.d.ts.map +1 -0
  44. package/dist/pi/packages/ta-agents/lib/agent-turn.js +343 -0
  45. package/dist/pi/packages/ta-agents/lib/agent-turn.js.map +1 -0
  46. package/dist/pi/packages/ta-agents/lib/extension.d.ts +26 -0
  47. package/dist/pi/packages/ta-agents/lib/extension.d.ts.map +1 -0
  48. package/dist/pi/packages/ta-agents/lib/extension.js +247 -0
  49. package/dist/pi/packages/ta-agents/lib/extension.js.map +1 -0
  50. package/dist/pi/packages/ta-agents/lib/json-rpc.d.ts +41 -0
  51. package/dist/pi/packages/ta-agents/lib/json-rpc.d.ts.map +1 -0
  52. package/dist/pi/packages/ta-agents/lib/json-rpc.js +145 -0
  53. package/dist/pi/packages/ta-agents/lib/json-rpc.js.map +1 -0
  54. package/dist/pi/packages/ta-agents/lib/message-stream.d.ts +31 -0
  55. package/dist/pi/packages/ta-agents/lib/message-stream.d.ts.map +1 -0
  56. package/dist/pi/packages/ta-agents/lib/message-stream.js +134 -0
  57. package/dist/pi/packages/ta-agents/lib/message-stream.js.map +1 -0
  58. package/dist/pi/packages/ta-agents/lib/pi-types.d.ts +20 -0
  59. package/dist/pi/packages/ta-agents/lib/pi-types.d.ts.map +1 -0
  60. package/dist/pi/packages/ta-agents/lib/pi-types.js +3 -0
  61. package/dist/pi/packages/ta-agents/lib/pi-types.js.map +1 -0
  62. package/dist/pi/packages/ta-agents/lib/texts.d.ts +36 -0
  63. package/dist/pi/packages/ta-agents/lib/texts.d.ts.map +1 -0
  64. package/dist/pi/packages/ta-agents/lib/texts.js +43 -0
  65. package/dist/pi/packages/ta-agents/lib/texts.js.map +1 -0
  66. package/dist/pi/packages/ta-agents/package.json +53 -0
  67. package/dist/pi/packages/ta-changes/README.en.md +21 -0
  68. package/dist/pi/packages/ta-changes/README.md +21 -0
  69. package/dist/pi/packages/ta-changes/extension/index.mjs +296 -0
  70. package/dist/pi/packages/ta-changes/host/index.mjs +309 -0
  71. package/dist/pi/packages/ta-changes/lib/blob-store.d.ts +16 -0
  72. package/dist/pi/packages/ta-changes/lib/blob-store.d.ts.map +1 -0
  73. package/dist/pi/packages/ta-changes/lib/blob-store.js +69 -0
  74. package/dist/pi/packages/ta-changes/lib/blob-store.js.map +1 -0
  75. package/dist/pi/packages/ta-changes/lib/card.d.ts +12 -0
  76. package/dist/pi/packages/ta-changes/lib/card.d.ts.map +1 -0
  77. package/dist/pi/packages/ta-changes/lib/card.js +149 -0
  78. package/dist/pi/packages/ta-changes/lib/card.js.map +1 -0
  79. package/dist/pi/packages/ta-changes/lib/changes-protocol.d.ts +76 -0
  80. package/dist/pi/packages/ta-changes/lib/changes-protocol.d.ts.map +1 -0
  81. package/dist/pi/packages/ta-changes/lib/changes-protocol.js +20 -0
  82. package/dist/pi/packages/ta-changes/lib/changes-protocol.js.map +1 -0
  83. package/dist/pi/packages/ta-changes/lib/changes-service.d.ts +20 -0
  84. package/dist/pi/packages/ta-changes/lib/changes-service.d.ts.map +1 -0
  85. package/dist/pi/packages/ta-changes/lib/changes-service.js +70 -0
  86. package/dist/pi/packages/ta-changes/lib/changes-service.js.map +1 -0
  87. package/dist/pi/packages/ta-changes/lib/changes-util.d.ts +21 -0
  88. package/dist/pi/packages/ta-changes/lib/changes-util.d.ts.map +1 -0
  89. package/dist/pi/packages/ta-changes/lib/changes-util.js +44 -0
  90. package/dist/pi/packages/ta-changes/lib/changes-util.js.map +1 -0
  91. package/dist/pi/packages/ta-changes/lib/diff-tab.d.ts +4 -0
  92. package/dist/pi/packages/ta-changes/lib/diff-tab.d.ts.map +1 -0
  93. package/dist/pi/packages/ta-changes/lib/diff-tab.js +45 -0
  94. package/dist/pi/packages/ta-changes/lib/diff-tab.js.map +1 -0
  95. package/dist/pi/packages/ta-changes/lib/extension.d.ts +21 -0
  96. package/dist/pi/packages/ta-changes/lib/extension.d.ts.map +1 -0
  97. package/dist/pi/packages/ta-changes/lib/extension.js +106 -0
  98. package/dist/pi/packages/ta-changes/lib/extension.js.map +1 -0
  99. package/dist/pi/packages/ta-changes/lib/host.d.ts +7 -0
  100. package/dist/pi/packages/ta-changes/lib/host.d.ts.map +1 -0
  101. package/dist/pi/packages/ta-changes/lib/host.js +16 -0
  102. package/dist/pi/packages/ta-changes/lib/host.js.map +1 -0
  103. package/dist/pi/packages/ta-changes/lib/i18n.d.ts +30 -0
  104. package/dist/pi/packages/ta-changes/lib/i18n.d.ts.map +1 -0
  105. package/dist/pi/packages/ta-changes/lib/i18n.js +61 -0
  106. package/dist/pi/packages/ta-changes/lib/i18n.js.map +1 -0
  107. package/dist/pi/packages/ta-changes/lib/index.d.ts +8 -0
  108. package/dist/pi/packages/ta-changes/lib/index.d.ts.map +1 -0
  109. package/dist/pi/packages/ta-changes/lib/index.js +28 -0
  110. package/dist/pi/packages/ta-changes/lib/index.js.map +1 -0
  111. package/dist/pi/packages/ta-changes/lib/line-diff.d.ts +11 -0
  112. package/dist/pi/packages/ta-changes/lib/line-diff.d.ts.map +1 -0
  113. package/dist/pi/packages/ta-changes/lib/line-diff.js +69 -0
  114. package/dist/pi/packages/ta-changes/lib/line-diff.js.map +1 -0
  115. package/dist/pi/packages/ta-changes/lib/page.d.ts +29 -0
  116. package/dist/pi/packages/ta-changes/lib/page.d.ts.map +1 -0
  117. package/dist/pi/packages/ta-changes/lib/page.js +106 -0
  118. package/dist/pi/packages/ta-changes/lib/page.js.map +1 -0
  119. package/dist/pi/packages/ta-changes/lib/react.d.ts +8 -0
  120. package/dist/pi/packages/ta-changes/lib/react.d.ts.map +1 -0
  121. package/dist/pi/packages/ta-changes/lib/react.js +8 -0
  122. package/dist/pi/packages/ta-changes/lib/react.js.map +1 -0
  123. package/dist/pi/packages/ta-changes/lib/recorder.d.ts +25 -0
  124. package/dist/pi/packages/ta-changes/lib/recorder.d.ts.map +1 -0
  125. package/dist/pi/packages/ta-changes/lib/recorder.js +117 -0
  126. package/dist/pi/packages/ta-changes/lib/recorder.js.map +1 -0
  127. package/dist/pi/packages/ta-changes/lib/style.d.ts +4 -0
  128. package/dist/pi/packages/ta-changes/lib/style.d.ts.map +1 -0
  129. package/dist/pi/packages/ta-changes/lib/style.js +44 -0
  130. package/dist/pi/packages/ta-changes/lib/style.js.map +1 -0
  131. package/dist/pi/packages/ta-changes/package.json +46 -0
  132. package/dist/pi/packages/ta-changes/web/index.js +460 -0
  133. package/dist/pi/packages/ta-channels/lib/views.d.ts.map +1 -1
  134. package/dist/pi/packages/ta-channels/lib/views.js +6 -1
  135. package/dist/pi/packages/ta-channels/lib/views.js.map +1 -1
  136. package/dist/pi/packages/ta-channels/package.json +1 -1
  137. package/dist/pi/packages/ta-channels/web/index.js +5 -1
  138. package/dist/pi/packages/ta-computer-use/extension/index.mjs +4 -2
  139. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.d.ts +2 -1
  140. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.d.ts.map +1 -1
  141. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.js +9 -3
  142. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.js.map +1 -1
  143. package/dist/pi/packages/ta-computer-use/package.json +1 -1
  144. package/dist/pi/packages/ta-cron/README.en.md +48 -0
  145. package/dist/pi/packages/ta-cron/README.md +48 -0
  146. package/dist/pi/packages/ta-cron/extension/index.mjs +856 -0
  147. package/dist/pi/packages/ta-cron/host/index.mjs +877 -0
  148. package/dist/pi/packages/ta-cron/lib/commands.d.ts +61 -0
  149. package/dist/pi/packages/ta-cron/lib/commands.d.ts.map +1 -0
  150. package/dist/pi/packages/ta-cron/lib/commands.js +250 -0
  151. package/dist/pi/packages/ta-cron/lib/commands.js.map +1 -0
  152. package/dist/pi/packages/ta-cron/lib/cron-expression.d.ts +39 -0
  153. package/dist/pi/packages/ta-cron/lib/cron-expression.d.ts.map +1 -0
  154. package/dist/pi/packages/ta-cron/lib/cron-expression.js +146 -0
  155. package/dist/pi/packages/ta-cron/lib/cron-expression.js.map +1 -0
  156. package/dist/pi/packages/ta-cron/lib/cron-protocol.d.ts +160 -0
  157. package/dist/pi/packages/ta-cron/lib/cron-protocol.d.ts.map +1 -0
  158. package/dist/pi/packages/ta-cron/lib/cron-protocol.js +38 -0
  159. package/dist/pi/packages/ta-cron/lib/cron-protocol.js.map +1 -0
  160. package/dist/pi/packages/ta-cron/lib/editor.d.ts +17 -0
  161. package/dist/pi/packages/ta-cron/lib/editor.d.ts.map +1 -0
  162. package/dist/pi/packages/ta-cron/lib/editor.js +145 -0
  163. package/dist/pi/packages/ta-cron/lib/editor.js.map +1 -0
  164. package/dist/pi/packages/ta-cron/lib/extension.d.ts +27 -0
  165. package/dist/pi/packages/ta-cron/lib/extension.d.ts.map +1 -0
  166. package/dist/pi/packages/ta-cron/lib/extension.js +142 -0
  167. package/dist/pi/packages/ta-cron/lib/extension.js.map +1 -0
  168. package/dist/pi/packages/ta-cron/lib/form-util.d.ts +39 -0
  169. package/dist/pi/packages/ta-cron/lib/form-util.d.ts.map +1 -0
  170. package/dist/pi/packages/ta-cron/lib/form-util.js +121 -0
  171. package/dist/pi/packages/ta-cron/lib/form-util.js.map +1 -0
  172. package/dist/pi/packages/ta-cron/lib/host.d.ts +7 -0
  173. package/dist/pi/packages/ta-cron/lib/host.d.ts.map +1 -0
  174. package/dist/pi/packages/ta-cron/lib/host.js +14 -0
  175. package/dist/pi/packages/ta-cron/lib/host.js.map +1 -0
  176. package/dist/pi/packages/ta-cron/lib/i18n.d.ts +90 -0
  177. package/dist/pi/packages/ta-cron/lib/i18n.d.ts.map +1 -0
  178. package/dist/pi/packages/ta-cron/lib/i18n.js +177 -0
  179. package/dist/pi/packages/ta-cron/lib/i18n.js.map +1 -0
  180. package/dist/pi/packages/ta-cron/lib/index.d.ts +8 -0
  181. package/dist/pi/packages/ta-cron/lib/index.d.ts.map +1 -0
  182. package/dist/pi/packages/ta-cron/lib/index.js +37 -0
  183. package/dist/pi/packages/ta-cron/lib/index.js.map +1 -0
  184. package/dist/pi/packages/ta-cron/lib/model-picker.d.ts +33 -0
  185. package/dist/pi/packages/ta-cron/lib/model-picker.d.ts.map +1 -0
  186. package/dist/pi/packages/ta-cron/lib/model-picker.js +178 -0
  187. package/dist/pi/packages/ta-cron/lib/model-picker.js.map +1 -0
  188. package/dist/pi/packages/ta-cron/lib/notifier.d.ts +6 -0
  189. package/dist/pi/packages/ta-cron/lib/notifier.d.ts.map +1 -0
  190. package/dist/pi/packages/ta-cron/lib/notifier.js +50 -0
  191. package/dist/pi/packages/ta-cron/lib/notifier.js.map +1 -0
  192. package/dist/pi/packages/ta-cron/lib/page.d.ts +39 -0
  193. package/dist/pi/packages/ta-cron/lib/page.d.ts.map +1 -0
  194. package/dist/pi/packages/ta-cron/lib/page.js +113 -0
  195. package/dist/pi/packages/ta-cron/lib/page.js.map +1 -0
  196. package/dist/pi/packages/ta-cron/lib/react.d.ts +8 -0
  197. package/dist/pi/packages/ta-cron/lib/react.d.ts.map +1 -0
  198. package/dist/pi/packages/ta-cron/lib/react.js +8 -0
  199. package/dist/pi/packages/ta-cron/lib/react.js.map +1 -0
  200. package/dist/pi/packages/ta-cron/lib/reply.d.ts +6 -0
  201. package/dist/pi/packages/ta-cron/lib/reply.d.ts.map +1 -0
  202. package/dist/pi/packages/ta-cron/lib/reply.js +53 -0
  203. package/dist/pi/packages/ta-cron/lib/reply.js.map +1 -0
  204. package/dist/pi/packages/ta-cron/lib/schedule-util.d.ts +25 -0
  205. package/dist/pi/packages/ta-cron/lib/schedule-util.d.ts.map +1 -0
  206. package/dist/pi/packages/ta-cron/lib/schedule-util.js +223 -0
  207. package/dist/pi/packages/ta-cron/lib/schedule-util.js.map +1 -0
  208. package/dist/pi/packages/ta-cron/lib/scheduler.d.ts +76 -0
  209. package/dist/pi/packages/ta-cron/lib/scheduler.d.ts.map +1 -0
  210. package/dist/pi/packages/ta-cron/lib/scheduler.js +319 -0
  211. package/dist/pi/packages/ta-cron/lib/scheduler.js.map +1 -0
  212. package/dist/pi/packages/ta-cron/lib/server-texts.d.ts +7 -0
  213. package/dist/pi/packages/ta-cron/lib/server-texts.d.ts.map +1 -0
  214. package/dist/pi/packages/ta-cron/lib/server-texts.js +24 -0
  215. package/dist/pi/packages/ta-cron/lib/server-texts.js.map +1 -0
  216. package/dist/pi/packages/ta-cron/lib/style.d.ts +4 -0
  217. package/dist/pi/packages/ta-cron/lib/style.d.ts.map +1 -0
  218. package/dist/pi/packages/ta-cron/lib/style.js +137 -0
  219. package/dist/pi/packages/ta-cron/lib/style.js.map +1 -0
  220. package/dist/pi/packages/ta-cron/lib/task-store.d.ts +25 -0
  221. package/dist/pi/packages/ta-cron/lib/task-store.d.ts.map +1 -0
  222. package/dist/pi/packages/ta-cron/lib/task-store.js +60 -0
  223. package/dist/pi/packages/ta-cron/lib/task-store.js.map +1 -0
  224. package/dist/pi/packages/ta-cron/lib/task-util.d.ts +18 -0
  225. package/dist/pi/packages/ta-cron/lib/task-util.d.ts.map +1 -0
  226. package/dist/pi/packages/ta-cron/lib/task-util.js +167 -0
  227. package/dist/pi/packages/ta-cron/lib/task-util.js.map +1 -0
  228. package/dist/pi/packages/ta-cron/lib/tasks-view.d.ts +6 -0
  229. package/dist/pi/packages/ta-cron/lib/tasks-view.d.ts.map +1 -0
  230. package/dist/pi/packages/ta-cron/lib/tasks-view.js +189 -0
  231. package/dist/pi/packages/ta-cron/lib/tasks-view.js.map +1 -0
  232. package/dist/pi/packages/ta-cron/lib/tool.d.ts +85 -0
  233. package/dist/pi/packages/ta-cron/lib/tool.d.ts.map +1 -0
  234. package/dist/pi/packages/ta-cron/lib/tool.js +127 -0
  235. package/dist/pi/packages/ta-cron/lib/tool.js.map +1 -0
  236. package/dist/pi/packages/ta-cron/package.json +46 -0
  237. package/dist/pi/packages/ta-cron/web/index.js +1985 -0
  238. package/dist/pi/packages/ta-extensions/package.json +1 -1
  239. package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +3 -2
  240. package/dist/pi/packages/ta-workspace/README.md +5 -5
  241. package/dist/pi/packages/ta-workspace/README.zh-cn.md +6 -6
  242. package/dist/pi/packages/ta-workspace/lib/browser-agent.d.ts +36 -0
  243. package/dist/pi/packages/ta-workspace/lib/browser-agent.d.ts.map +1 -0
  244. package/dist/pi/packages/ta-workspace/lib/browser-agent.js +396 -0
  245. package/dist/pi/packages/ta-workspace/lib/browser-agent.js.map +1 -0
  246. package/dist/pi/packages/ta-workspace/lib/browser-common.d.ts +48 -0
  247. package/dist/pi/packages/ta-workspace/lib/browser-common.d.ts.map +1 -0
  248. package/dist/pi/packages/ta-workspace/lib/browser-common.js +180 -0
  249. package/dist/pi/packages/ta-workspace/lib/browser-common.js.map +1 -0
  250. package/dist/pi/packages/ta-workspace/lib/browser-import.d.ts +5 -0
  251. package/dist/pi/packages/ta-workspace/lib/browser-import.d.ts.map +1 -0
  252. package/dist/pi/packages/ta-workspace/lib/browser-import.js +97 -0
  253. package/dist/pi/packages/ta-workspace/lib/browser-import.js.map +1 -0
  254. package/dist/pi/packages/ta-workspace/lib/browser-webview.d.ts +7 -0
  255. package/dist/pi/packages/ta-workspace/lib/browser-webview.d.ts.map +1 -0
  256. package/dist/pi/packages/ta-workspace/lib/browser-webview.js +202 -0
  257. package/dist/pi/packages/ta-workspace/lib/browser-webview.js.map +1 -0
  258. package/dist/pi/packages/ta-workspace/lib/browser.d.ts +1 -7
  259. package/dist/pi/packages/ta-workspace/lib/browser.d.ts.map +1 -1
  260. package/dist/pi/packages/ta-workspace/lib/browser.js +14 -154
  261. package/dist/pi/packages/ta-workspace/lib/browser.js.map +1 -1
  262. package/dist/pi/packages/ta-workspace/lib/explorer.d.ts.map +1 -1
  263. package/dist/pi/packages/ta-workspace/lib/explorer.js +214 -3
  264. package/dist/pi/packages/ta-workspace/lib/explorer.js.map +1 -1
  265. package/dist/pi/packages/ta-workspace/lib/i18n.d.ts +37 -0
  266. package/dist/pi/packages/ta-workspace/lib/i18n.d.ts.map +1 -1
  267. package/dist/pi/packages/ta-workspace/lib/i18n.js +76 -2
  268. package/dist/pi/packages/ta-workspace/lib/i18n.js.map +1 -1
  269. package/dist/pi/packages/ta-workspace/lib/index.d.ts.map +1 -1
  270. package/dist/pi/packages/ta-workspace/lib/index.js +7 -1
  271. package/dist/pi/packages/ta-workspace/lib/index.js.map +1 -1
  272. package/dist/pi/packages/ta-workspace/lib/style.d.ts +1 -1
  273. package/dist/pi/packages/ta-workspace/lib/style.d.ts.map +1 -1
  274. package/dist/pi/packages/ta-workspace/lib/style.js +35 -6
  275. package/dist/pi/packages/ta-workspace/lib/style.js.map +1 -1
  276. package/dist/pi/packages/ta-workspace/lib/terminal.d.ts +2 -2
  277. package/dist/pi/packages/ta-workspace/lib/terminal.d.ts.map +1 -1
  278. package/dist/pi/packages/ta-workspace/lib/terminal.js +50 -104
  279. package/dist/pi/packages/ta-workspace/lib/terminal.js.map +1 -1
  280. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.d.ts +52 -0
  281. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.d.ts.map +1 -0
  282. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.js +207 -0
  283. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.js.map +1 -0
  284. package/dist/pi/packages/ta-workspace/lib/util/upload.d.ts +34 -0
  285. package/dist/pi/packages/ta-workspace/lib/util/upload.d.ts.map +1 -0
  286. package/dist/pi/packages/ta-workspace/lib/util/upload.js +109 -0
  287. package/dist/pi/packages/ta-workspace/lib/util/upload.js.map +1 -0
  288. package/dist/pi/packages/ta-workspace/lib/util/workspace.d.ts +16 -0
  289. package/dist/pi/packages/ta-workspace/lib/util/workspace.d.ts.map +1 -1
  290. package/dist/pi/packages/ta-workspace/lib/util/workspace.js +43 -0
  291. package/dist/pi/packages/ta-workspace/lib/util/workspace.js.map +1 -1
  292. package/dist/pi/packages/ta-workspace/lib/util/zip.d.ts +20 -0
  293. package/dist/pi/packages/ta-workspace/lib/util/zip.d.ts.map +1 -0
  294. package/dist/pi/packages/ta-workspace/lib/util/zip.js +128 -0
  295. package/dist/pi/packages/ta-workspace/lib/util/zip.js.map +1 -0
  296. package/dist/pi/packages/ta-workspace/lib/workspace-client.d.ts +12 -1
  297. package/dist/pi/packages/ta-workspace/lib/workspace-client.d.ts.map +1 -1
  298. package/dist/pi/packages/ta-workspace/lib/workspace-client.js +101 -0
  299. package/dist/pi/packages/ta-workspace/lib/workspace-client.js.map +1 -1
  300. package/dist/pi/packages/ta-workspace/package.json +1 -1
  301. package/dist/pi/packages/ta-workspace/web/index.js +1911 -634
  302. package/dist/public/assets/{abnfDiagram-S7VZAUFO-D1ZeYB9c.js → abnfDiagram-S7VZAUFO-CNqfsCwx.js} +1 -1
  303. package/dist/public/assets/{architecture-WOLXFQ4H-RV_x_iFj.js → architecture-WOLXFQ4H-_WaGq-Qk.js} +1 -1
  304. package/dist/public/assets/{architectureDiagram-YGSQEFNW-BGOmzcpZ.js → architectureDiagram-YGSQEFNW-Bn63Lctu.js} +1 -1
  305. package/dist/public/assets/{blockDiagram-APKKGZFW-BkoflIym.js → blockDiagram-APKKGZFW-BGaAecnk.js} +1 -1
  306. package/dist/public/assets/{browser-Cl9_lr0X.js → browser-DKagIN4Y.js} +1 -1
  307. package/dist/public/assets/{c4Diagram-KJ2TOQU5-CfrQTIEs.js → c4Diagram-KJ2TOQU5-CK9Z_9Zp.js} +1 -1
  308. package/dist/public/assets/{chunk-6MUBBAK2-C-VxnXsG.js → chunk-6MUBBAK2-H3j3MGva.js} +1 -1
  309. package/dist/public/assets/{chunk-AXFCVDMN-aqbxPiaN.js → chunk-AXFCVDMN-Beljdjs9.js} +1 -1
  310. package/dist/public/assets/{chunk-BG4553SI-DDgvFLBP.js → chunk-BG4553SI-TYEV5wLO.js} +1 -1
  311. package/dist/public/assets/{chunk-DQASFODM-CItpjfW5.js → chunk-DQASFODM-gmWJrizf.js} +1 -1
  312. package/dist/public/assets/{chunk-HFQBQIA3-BATYGV1I.js → chunk-HFQBQIA3-BTa7yKXI.js} +1 -1
  313. package/dist/public/assets/{chunk-KQLB2F66-BVAqVjgq.js → chunk-KQLB2F66-BlwMm4R0.js} +1 -1
  314. package/dist/public/assets/{chunk-KS47KZWR-Bk0_a-eE.js → chunk-KS47KZWR-CKTXjzwD.js} +1 -1
  315. package/dist/public/assets/{chunk-LEVMRMFU-DsFG_U8r.js → chunk-LEVMRMFU-Bn9Xkefl.js} +1 -1
  316. package/dist/public/assets/{chunk-M57EVK23-BgeE81Y7.js → chunk-M57EVK23-B_QLqohG.js} +1 -1
  317. package/dist/public/assets/{chunk-OY52VR5R-2Rp6C2LJ.js → chunk-OY52VR5R-BflzJHPz.js} +1 -1
  318. package/dist/public/assets/{chunk-QB3YPZ4I-BhcIp-Bl.js → chunk-QB3YPZ4I-BXucfaFg.js} +1 -1
  319. package/dist/public/assets/{chunk-R3KSYZAL-i9n2AYPG.js → chunk-R3KSYZAL-CGwkwxm9.js} +1 -1
  320. package/dist/public/assets/{chunk-STOXU5M4-DOSqSu65.js → chunk-STOXU5M4-DQGOPuM5.js} +1 -1
  321. package/dist/public/assets/{chunk-TU62E6Q5-BDA8bjy3.js → chunk-TU62E6Q5-BCrs6AYI.js} +1 -1
  322. package/dist/public/assets/{chunk-X4PVCEUW-Cs-r9l_d.js → chunk-X4PVCEUW-MTv7nXJX.js} +1 -1
  323. package/dist/public/assets/{chunk-XXDRQBXY-DEcanQFC.js → chunk-XXDRQBXY-fPaX8VIb.js} +1 -1
  324. package/dist/public/assets/{classDiagram-v2-L25IHNXF-BS8XxKRR.js → classDiagram-v2-L25IHNXF-tm4uT08q.js} +1 -1
  325. package/dist/public/assets/{cose-bilkent-JH36ORCC--RPleOJ8.js → cose-bilkent-JH36ORCC-Dkk3pDZj.js} +1 -1
  326. package/dist/public/assets/cynefin-EF2NZ3EQ-D_QV_BJg.js +1 -0
  327. package/dist/public/assets/{cynefinDiagram-L36ESFBY-DZHM2oEU.js → cynefinDiagram-L36ESFBY-BcoArW00.js} +1 -1
  328. package/dist/public/assets/{d3-selection-D2iIEb1P.js → d3-selection-BzUITLov.js} +1 -1
  329. package/dist/public/assets/{dagre-SPEB5RXH-h_G5ukMB.js → dagre-SPEB5RXH-oiU-wJxw.js} +1 -1
  330. package/dist/public/assets/{diagram-3B7GL73J-BnThWj9P.js → diagram-3B7GL73J-BwlCOIW4.js} +1 -1
  331. package/dist/public/assets/{diagram-DNEMPZML-DHCMo8sZ.js → diagram-DNEMPZML-CZGQiFrl.js} +1 -1
  332. package/dist/public/assets/{diagram-L3MUGCDN-DxJZnIKT.js → diagram-L3MUGCDN-BJGDa24C.js} +1 -1
  333. package/dist/public/assets/{diagram-LA4NIPWU-Cn0SGxqL.js → diagram-LA4NIPWU-DdwHRhnP.js} +1 -1
  334. package/dist/public/assets/{diagram-MHCOC4E2-BafBOkBk.js → diagram-MHCOC4E2-IjreLUB9.js} +1 -1
  335. package/dist/public/assets/{diagram-XPFHEONP-D7UnEMcU.js → diagram-XPFHEONP-CvaG0Zzq.js} +1 -1
  336. package/dist/public/assets/{dist-CN9JBoER.js → dist-Cm4zqoMA.js} +1 -1
  337. package/dist/public/assets/{ebnfDiagram-UZSYDL2S-Us1rkKwp.js → ebnfDiagram-UZSYDL2S-C-FOI67M.js} +1 -1
  338. package/dist/public/assets/{editor.api-S_CuXudU.js → editor.api-hteKufWf.js} +1 -1
  339. package/dist/public/assets/{elk-XV6XMXQE-Czvqrn49.js → elk-XV6XMXQE-C_ClfkLy.js} +1 -1
  340. package/dist/public/assets/{erDiagram-EYBAPDEH-C0g3K15f.js → erDiagram-EYBAPDEH-DSr0aRYm.js} +1 -1
  341. package/dist/public/assets/{eventmodeling-K75KTNOO-DIcU7mQ5.js → eventmodeling-K75KTNOO-COU_atV6.js} +1 -1
  342. package/dist/public/assets/flowDiagram-MALGAFMO-QGLBPpjQ.js +1 -0
  343. package/dist/public/assets/{freemarker2-CkAEBjHO.js → freemarker2-CBJnhymu.js} +1 -1
  344. package/dist/public/assets/{ganttDiagram-23REXITY-CIkKvihz.js → ganttDiagram-23REXITY-BAcXXNjI.js} +1 -1
  345. package/dist/public/assets/gitGraph-VSP46ZUC-ByODkoVe.js +1 -0
  346. package/dist/public/assets/{gitGraphDiagram-STJD7YCW-BxM3589j.js → gitGraphDiagram-STJD7YCW-Bk9sns6k.js} +1 -1
  347. package/dist/public/assets/{handlebars-CPBNiVZ2.js → handlebars-CiqYW1im.js} +1 -1
  348. package/dist/public/assets/{html-CJBVALoy.js → html-kafkm1Z0.js} +1 -1
  349. package/dist/public/assets/{index-CBMmE3BQ.js → index-DPLd0-lb.js} +2 -2
  350. package/dist/public/assets/info-OHQRW6UA-BMphWS2h.js +1 -0
  351. package/dist/public/assets/{infoDiagram-KBXO4MBG-BIcStK_t.js → infoDiagram-KBXO4MBG-2hRQLVWa.js} +1 -1
  352. package/dist/public/assets/{ishikawaDiagram-M35NCXHK-CpV2hKA6.js → ishikawaDiagram-M35NCXHK-hrOnhWJs.js} +1 -1
  353. package/dist/public/assets/{javascript-dv6GQsa3.js → javascript-Dt5MiA9w.js} +1 -1
  354. package/dist/public/assets/{journeyDiagram-OPLOXDXO-B_vnmdId.js → journeyDiagram-OPLOXDXO-d8HJd04q.js} +1 -1
  355. package/dist/public/assets/{jsonMode-DG_orhvz.js → jsonMode-DBICoo6P.js} +1 -1
  356. package/dist/public/assets/{kanban-definition-BZKZHSQY-q5uWw99H.js → kanban-definition-BZKZHSQY-DOUuZDiv.js} +1 -1
  357. package/dist/public/assets/{liquid-CD-LM2Kh.js → liquid-BGYhBP2h.js} +1 -1
  358. package/dist/public/assets/{mdx-C9mfI8up.js → mdx-Ct_gzcP3.js} +1 -1
  359. package/dist/public/assets/{mermaid-parser.core-DNe1duhT.js → mermaid-parser.core-2yhxYNxq.js} +3 -3
  360. package/dist/public/assets/{mermaid.core-B1AcqJgl.js → mermaid.core-sx7teU8z.js} +4 -4
  361. package/dist/public/assets/{mindmap-definition-I2QAS2VK-CwYG3Fl3.js → mindmap-definition-I2QAS2VK-DIc9LejH.js} +1 -1
  362. package/dist/public/assets/module-BX2fJibj.js +1124 -0
  363. package/dist/public/assets/module-N1D-AOa6.js +1 -0
  364. package/dist/public/assets/{monaco-C0ktZo3r.js → monaco-DJecWyyV.js} +3 -3
  365. package/dist/public/assets/packet-JDAUHWVQ-Ca8klABu.js +1 -0
  366. package/dist/public/assets/{pegDiagram-FD4XPPHP-DxtA4QDS.js → pegDiagram-FD4XPPHP-BfiT6-Vx.js} +1 -1
  367. package/dist/public/assets/pie-XZMESJXO-B-SN2eCI.js +1 -0
  368. package/dist/public/assets/{pieDiagram-J4AKIIQI-CfcIi0Vn.js → pieDiagram-J4AKIIQI-DJ0sF_Eg.js} +1 -1
  369. package/dist/public/assets/{python-DCA1j2QE.js → python-BrnocsK9.js} +1 -1
  370. package/dist/public/assets/{quadrantDiagram-XTYBLID2-BxkJdurF.js → quadrantDiagram-XTYBLID2-C3iF5PG6.js} +1 -1
  371. package/dist/public/assets/radar-ABXABTNO-DzDnNRnq.js +1 -0
  372. package/dist/public/assets/railroad-I3PHUGI6-7QAv0_1N.js +1 -0
  373. package/dist/public/assets/{railroad-abnf-LNEFI6M7--H3g5ywg.js → railroad-abnf-LNEFI6M7-BI4N-mtq.js} +1 -1
  374. package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-C2LAUFu6.js → railroad-ebnf-DWYD2UWJ-Ck2MUlyV.js} +1 -1
  375. package/dist/public/assets/{railroad-peg-JR7BVNR7-Kq_ZXQMl.js → railroad-peg-JR7BVNR7-Cuc9S0f4.js} +1 -1
  376. package/dist/public/assets/{railroadDiagram-MRQ6NCDL-i4xIvHJV.js → railroadDiagram-MRQ6NCDL-Cw24sb_5.js} +1 -1
  377. package/dist/public/assets/{razor-CEeNaFx5.js → razor-BDHTAmlI.js} +1 -1
  378. package/dist/public/assets/{requirementDiagram-Y7LWUY3S-CYNXjuJm.js → requirementDiagram-Y7LWUY3S-QQUXFr1R.js} +1 -1
  379. package/dist/public/assets/{sankeyDiagram-WGJFYUXA-CRQiHcW6.js → sankeyDiagram-WGJFYUXA-mSlfAHND.js} +1 -1
  380. package/dist/public/assets/{sequenceDiagram-5NDRBG5M-BSDVFsi2.js → sequenceDiagram-5NDRBG5M-3t8hVott.js} +1 -1
  381. package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-uyUAaysl.js → stateDiagram-v2-FJ4FJNEA-9EW807AL.js} +1 -1
  382. package/dist/public/assets/{swimlanes-UMQ2AFYF-DdEjQumY.js → swimlanes-UMQ2AFYF-EbMBX_e0.js} +1 -1
  383. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-CIFqDFf2.js +8 -0
  384. package/dist/public/assets/{timeline-definition-SEUHKTQE-DZl-TXXh.js → timeline-definition-SEUHKTQE-D14kjjsp.js} +1 -1
  385. package/dist/public/assets/treeView-D4JQ5SDB-cznq7PJK.js +1 -0
  386. package/dist/public/assets/treemap-SAJKECNS-CBYUiQGU.js +1 -0
  387. package/dist/public/assets/{typescript-DrF8YGbQ.js → typescript-BEEbbq69.js} +1 -1
  388. package/dist/public/assets/{usecaseDiagram-AFA6YXN4-DkG3gLrp.js → usecaseDiagram-AFA6YXN4-DKemtzU9.js} +1 -1
  389. package/dist/public/assets/{vennDiagram-NNMJR3RB-B_lj8x7-.js → vennDiagram-NNMJR3RB-DOBq9oeY.js} +1 -1
  390. package/dist/public/assets/wardley-7MLQ67FV-DV8bp8Ml.js +1 -0
  391. package/dist/public/assets/{wardleyDiagram-S7YFUSEH-B1VFrC5a.js → wardleyDiagram-S7YFUSEH-DquSJ4y-.js} +1 -1
  392. package/dist/public/assets/{xml-DfL-Brke.js → xml-DvTQKQ_W.js} +1 -1
  393. package/dist/public/assets/xterm-BrP-ENHg.css +1 -0
  394. package/dist/public/assets/xterm-wtHqjrNn.js +85 -0
  395. package/dist/public/assets/{xychartDiagram-GGNKY7IX-CM2CpXu9.js → xychartDiagram-GGNKY7IX-ClE_9jz4.js} +1 -1
  396. package/dist/public/assets/{yaml-CpmxRjjF.js → yaml-ffiFfPtJ.js} +1 -1
  397. package/dist/public/index.html +1 -1
  398. package/dist/serve/index.mjs +6624 -6388
  399. package/package.json +22 -19
  400. package/dist/pi/packages/ta-workspace/lib/util/ansi.d.ts +0 -72
  401. package/dist/pi/packages/ta-workspace/lib/util/ansi.d.ts.map +0 -1
  402. package/dist/pi/packages/ta-workspace/lib/util/ansi.js +0 -434
  403. package/dist/pi/packages/ta-workspace/lib/util/ansi.js.map +0 -1
  404. package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts +0 -14
  405. package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts.map +0 -1
  406. package/dist/pi/packages/ta-workspace/lib/util/keys.js +0 -52
  407. package/dist/pi/packages/ta-workspace/lib/util/keys.js.map +0 -1
  408. package/dist/public/assets/cynefin-EF2NZ3EQ-CXQC7Jwi.js +0 -1
  409. package/dist/public/assets/flowDiagram-MALGAFMO-D5Z_jzJ0.js +0 -1
  410. package/dist/public/assets/gitGraph-VSP46ZUC-CvdLb7m6.js +0 -1
  411. package/dist/public/assets/info-OHQRW6UA-BLs8wjUC.js +0 -1
  412. package/dist/public/assets/module-BLLqRvli.js +0 -1099
  413. package/dist/public/assets/module-BZPCnGxA.js +0 -1
  414. package/dist/public/assets/packet-JDAUHWVQ-jwWITUaQ.js +0 -1
  415. package/dist/public/assets/pie-XZMESJXO-CeTVZZgy.js +0 -1
  416. package/dist/public/assets/radar-ABXABTNO-BGI8J8LU.js +0 -1
  417. package/dist/public/assets/railroad-I3PHUGI6-CFkpx3Pr.js +0 -1
  418. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-BJsun6CT.js +0 -8
  419. package/dist/public/assets/treeView-D4JQ5SDB-CL1mG6td.js +0 -1
  420. package/dist/public/assets/treemap-SAJKECNS-Bk3Z1uEC.js +0 -1
  421. package/dist/public/assets/wardley-7MLQ67FV-1E8i3qpD.js +0 -1
@@ -0,0 +1,877 @@
1
+ // web-src/cron-protocol.ts
2
+ var NAME = "@celljs/ta-cron";
3
+ var RUN_MARK = "<ta-cron-run>";
4
+ var Keys;
5
+ ((Keys) => {
6
+ Keys.TASKS = "tasks";
7
+ Keys.LATEST = "latest";
8
+ function runs(taskId) {
9
+ return `runs/${taskId}`;
10
+ }
11
+ Keys.runs = runs;
12
+ })(Keys ||= {});
13
+ var Limits;
14
+ ((Limits) => {
15
+ Limits.RUNS_KEPT = 20;
16
+ Limits.SUMMARY_MAX = 4000;
17
+ Limits.MIN_INTERVAL_MS = 60000;
18
+ Limits.RUN_TIMEOUT_MS = 30 * 60000;
19
+ Limits.GRACE_MS = 5 * 60000;
20
+ Limits.PARALLEL_RUNS = 3;
21
+ })(Limits ||= {});
22
+
23
+ // web-src/cron-expression.ts
24
+ var FIELDS = [
25
+ { name: "minute", min: 0, max: 59 },
26
+ { name: "hour", min: 0, max: 23 },
27
+ { name: "day of month", min: 1, max: 31 },
28
+ { name: "month", min: 1, max: 12, names: ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"] },
29
+ { name: "day of week", min: 0, max: 7, names: ["sun", "mon", "tue", "wed", "thu", "fri", "sat"] }
30
+ ];
31
+ var NICKNAMES = {
32
+ "@yearly": "0 0 1 1 *",
33
+ "@annually": "0 0 1 1 *",
34
+ "@monthly": "0 0 1 * *",
35
+ "@weekly": "0 0 * * 0",
36
+ "@daily": "0 0 * * *",
37
+ "@midnight": "0 0 * * *",
38
+ "@hourly": "0 * * * *"
39
+ };
40
+ var MAX_STEPS = 200000;
41
+
42
+ class CronExpression {
43
+ source;
44
+ minutes;
45
+ hours;
46
+ days;
47
+ months;
48
+ weekdays;
49
+ anyDay;
50
+ anyWeekday;
51
+ constructor(source, minutes, hours, days, months, weekdays, anyDay, anyWeekday) {
52
+ this.source = source;
53
+ this.minutes = minutes;
54
+ this.hours = hours;
55
+ this.days = days;
56
+ this.months = months;
57
+ this.weekdays = weekdays;
58
+ this.anyDay = anyDay;
59
+ this.anyWeekday = anyWeekday;
60
+ }
61
+ static parse(text) {
62
+ const source = text.trim().replace(/\s+/g, " ");
63
+ const expanded = NICKNAMES[source.toLowerCase()] ?? source;
64
+ const parts = expanded.split(" ");
65
+ if (parts.length !== 5) {
66
+ throw new Error(`A cron expression has five fields (minute hour day month weekday), or is one of ${Object.keys(NICKNAMES).join(", ")}: ${JSON.stringify(text)} has ${parts.length}.`);
67
+ }
68
+ const sets = parts.map((part, index) => CronExpression.field(part, FIELDS[index]));
69
+ const weekdays = sets[4];
70
+ if (weekdays.delete(7)) {
71
+ weekdays.add(0);
72
+ }
73
+ return new CronExpression(source, sets[0], sets[1], sets[2], sets[3], weekdays, parts[2] === "*", parts[4] === "*");
74
+ }
75
+ static isValid(text) {
76
+ try {
77
+ CronExpression.parse(text);
78
+ return true;
79
+ } catch {
80
+ return false;
81
+ }
82
+ }
83
+ static field(text, field) {
84
+ const values = new Set;
85
+ for (const item of text.toLowerCase().split(",")) {
86
+ const [range, stepText, extra] = item.split("/");
87
+ const step = stepText === undefined ? 1 : Number(stepText);
88
+ if (extra !== undefined || !Number.isInteger(step) || step < 1) {
89
+ throw new Error(`${JSON.stringify(item)} is not a valid ${field.name}: a step is a whole number from 1.`);
90
+ }
91
+ let from;
92
+ let to;
93
+ if (range === "*") {
94
+ from = field.min;
95
+ to = field.max;
96
+ } else {
97
+ const [first, last, more] = range.split("-");
98
+ if (more !== undefined) {
99
+ throw new Error(`${JSON.stringify(item)} is not a valid ${field.name}.`);
100
+ }
101
+ from = CronExpression.value(first, field);
102
+ to = last === undefined ? stepText === undefined ? from : field.max : CronExpression.value(last, field);
103
+ }
104
+ if (from > to) {
105
+ throw new Error(`${JSON.stringify(item)} is not a valid ${field.name}: the range goes backwards.`);
106
+ }
107
+ for (let value = from;value <= to; value += step) {
108
+ values.add(value);
109
+ }
110
+ }
111
+ return values;
112
+ }
113
+ static value(text, field) {
114
+ const named = field.names?.indexOf(text) ?? -1;
115
+ const value = named >= 0 ? named + (field.min === 1 ? 1 : 0) : /^\d+$/.test(text) ? Number(text) : Number.NaN;
116
+ if (!(value >= field.min && value <= field.max)) {
117
+ throw new Error(`${JSON.stringify(text)} is not a valid ${field.name}: from ${field.min} to ${field.max}.`);
118
+ }
119
+ return value;
120
+ }
121
+ next(after) {
122
+ const time = new Date(after.getTime());
123
+ time.setSeconds(0, 0);
124
+ time.setMinutes(time.getMinutes() + 1);
125
+ for (let step = 0;step < MAX_STEPS; step++) {
126
+ if (!this.months.has(time.getMonth() + 1)) {
127
+ time.setMonth(time.getMonth() + 1, 1);
128
+ time.setHours(0, 0, 0, 0);
129
+ } else if (!this.matchesDay(time)) {
130
+ time.setDate(time.getDate() + 1);
131
+ time.setHours(0, 0, 0, 0);
132
+ } else if (!this.hours.has(time.getHours())) {
133
+ time.setHours(time.getHours() + 1, 0, 0, 0);
134
+ } else if (!this.minutes.has(time.getMinutes())) {
135
+ time.setMinutes(time.getMinutes() + 1, 0, 0);
136
+ } else {
137
+ return time;
138
+ }
139
+ }
140
+ return;
141
+ }
142
+ matchesDay(time) {
143
+ const day = this.days.has(time.getDate());
144
+ const weekday = this.weekdays.has(time.getDay());
145
+ if (this.anyDay || this.anyWeekday) {
146
+ return day && weekday;
147
+ }
148
+ return day || weekday;
149
+ }
150
+ }
151
+
152
+ // web-src/schedule-util.ts
153
+ var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
154
+ var NOTIFY_LEVELS = ["always", "error", "never"];
155
+ var UNITS = {
156
+ s: 1000,
157
+ sec: 1000,
158
+ m: 60000,
159
+ min: 60000,
160
+ h: 3600000,
161
+ hr: 3600000,
162
+ d: 86400000,
163
+ w: 7 * 86400000
164
+ };
165
+ var Duration;
166
+ ((Duration) => {
167
+ const PART = /(\d+)\s*(sec|min|hr|s|m|h|d|w)/gy;
168
+ function parse(text) {
169
+ const source = text.trim().toLowerCase();
170
+ if (!source) {
171
+ return;
172
+ }
173
+ PART.lastIndex = 0;
174
+ let total = 0;
175
+ let match;
176
+ let end = 0;
177
+ while (match = PART.exec(source)) {
178
+ total += Number(match[1]) * UNITS[match[2]];
179
+ end = PART.lastIndex;
180
+ }
181
+ return end === source.length && total > 0 ? total : undefined;
182
+ }
183
+ Duration.parse = parse;
184
+ function format(ms) {
185
+ const parts = [];
186
+ let rest = Math.round(ms / 1000);
187
+ for (const [unit, size] of [
188
+ ["d", 86400],
189
+ ["h", 3600],
190
+ ["m", 60],
191
+ ["s", 1]
192
+ ]) {
193
+ if (rest >= size) {
194
+ parts.push(`${Math.floor(rest / size)}${unit}`);
195
+ rest %= size;
196
+ }
197
+ }
198
+ return parts.join("") || "0s";
199
+ }
200
+ Duration.format = format;
201
+ })(Duration ||= {});
202
+ var EN_DAYS = ["Sundays", "Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays"];
203
+ var ZH_DAYS = ["日", "一", "二", "三", "四", "五", "六"];
204
+ var WORDS = {
205
+ en: {
206
+ once: (time) => `Once, ${time}`,
207
+ every: (amount, unit) => amount === 1 ? `Every ${unit}` : `Every ${amount} ${unit}s`,
208
+ everyRaw: (duration) => `Every ${duration}`,
209
+ daily: (time) => `Daily at ${time}`,
210
+ weekdays: (time) => `Weekdays at ${time}`,
211
+ weekly: (day, time) => `${EN_DAYS[day]} at ${time}`,
212
+ monthly: (day, time) => `Monthly on day ${day} at ${time}`,
213
+ hourly: (minute) => minute === 0 ? "Hourly" : `Hourly at :${pad(minute)}`,
214
+ cron: (expression) => `Cron ${expression}`
215
+ },
216
+ zh: {
217
+ once: (time) => `${time} 运行一次`,
218
+ every: (amount, unit) => `每 ${amount === 1 ? "" : `${amount} `}${{ minute: "分钟", hour: "小时", day: "天" }[unit]}`.replace("每 天", "每天"),
219
+ everyRaw: (duration) => `每 ${duration}`,
220
+ daily: (time) => `每天 ${time}`,
221
+ weekdays: (time) => `工作日 ${time}`,
222
+ weekly: (day, time) => `每周${ZH_DAYS[day]} ${time}`,
223
+ monthly: (day, time) => `每月 ${day} 日 ${time}`,
224
+ hourly: (minute) => minute === 0 ? "每小时" : `每小时第 ${minute} 分`,
225
+ cron: (expression) => `cron ${expression}`
226
+ }
227
+ };
228
+ function pad(value) {
229
+ return String(value).padStart(2, "0");
230
+ }
231
+ var ScheduleUtil;
232
+ ((ScheduleUtil) => {
233
+ function check(value) {
234
+ const schedule = value ?? {};
235
+ switch (schedule.kind) {
236
+ case "once": {
237
+ const at = new Date(String(schedule.at ?? ""));
238
+ if (typeof schedule.at !== "string" || Number.isNaN(at.getTime())) {
239
+ throw new Error("A task that runs once needs `at`, a time such as 2026-11-12T09:00 (local time) or an ISO time.");
240
+ }
241
+ return { kind: "once", at: at.toISOString() };
242
+ }
243
+ case "interval": {
244
+ const every = typeof schedule.every === "string" ? schedule.every.trim() : "";
245
+ const ms = Duration.parse(every);
246
+ if (ms === undefined) {
247
+ throw new Error("An interval needs `every`, a duration such as 30m, 2h or 1d.");
248
+ }
249
+ if (ms < Limits.MIN_INTERVAL_MS) {
250
+ throw new Error(`An interval is at least 1m; ${every} is shorter.`);
251
+ }
252
+ return { kind: "interval", every: Duration.format(ms) };
253
+ }
254
+ case "cron": {
255
+ const expression = typeof schedule.expression === "string" ? schedule.expression : "";
256
+ return { kind: "cron", expression: CronExpression.parse(expression).source };
257
+ }
258
+ default:
259
+ throw new Error('A schedule is { kind: "once", at }, { kind: "interval", every } or { kind: "cron", expression }.');
260
+ }
261
+ }
262
+ ScheduleUtil.check = check;
263
+ function next(schedule, now) {
264
+ switch (schedule.kind) {
265
+ case "once": {
266
+ const at = new Date(schedule.at);
267
+ return at.getTime() > now.getTime() ? at : undefined;
268
+ }
269
+ case "interval":
270
+ return new Date(now.getTime() + (Duration.parse(schedule.every) ?? Limits.MIN_INTERVAL_MS));
271
+ case "cron":
272
+ return CronExpression.parse(schedule.expression).next(now);
273
+ }
274
+ }
275
+ ScheduleUtil.next = next;
276
+ function repeats(schedule) {
277
+ return schedule.kind !== "once";
278
+ }
279
+ ScheduleUtil.repeats = repeats;
280
+ function notifyLevel(task) {
281
+ return task.notify ?? (repeats(task.schedule) ? "error" : "always");
282
+ }
283
+ ScheduleUtil.notifyLevel = notifyLevel;
284
+ function shouldNotify(level, failed) {
285
+ return level === "always" || level === "error" && failed;
286
+ }
287
+ ScheduleUtil.shouldNotify = shouldNotify;
288
+ function clock(time, now = new Date) {
289
+ const day = `${time.getMonth() + 1}/${time.getDate()}`;
290
+ const year = time.getFullYear() === now.getFullYear() ? "" : `${time.getFullYear()}/`;
291
+ return `${year}${day} ${pad(time.getHours())}:${pad(time.getMinutes())}`;
292
+ }
293
+ ScheduleUtil.clock = clock;
294
+ function describe(schedule, language, now = new Date) {
295
+ const words = WORDS[language.startsWith("zh") ? "zh" : "en"];
296
+ switch (schedule.kind) {
297
+ case "once":
298
+ return words.once(clock(new Date(schedule.at), now));
299
+ case "interval":
300
+ return describeInterval(schedule.every, words);
301
+ case "cron":
302
+ return describeCron(schedule.expression, words);
303
+ }
304
+ }
305
+ ScheduleUtil.describe = describe;
306
+ function describeInterval(every, words) {
307
+ const ms = Duration.parse(every) ?? 0;
308
+ for (const [unit, size] of [
309
+ ["day", 86400000],
310
+ ["hour", 3600000],
311
+ ["minute", 60000]
312
+ ]) {
313
+ if (ms >= size && ms % size === 0) {
314
+ return words.every(ms / size, unit);
315
+ }
316
+ }
317
+ return words.everyRaw(every);
318
+ }
319
+ function describeCron(expression, words) {
320
+ const fields = (NICKNAMES[expression.toLowerCase()] ?? expression).split(" ");
321
+ const [minute, hour, day, month, weekday] = fields;
322
+ const number = (text) => /^\d+$/.test(text) ? Number(text) : undefined;
323
+ const m = number(minute);
324
+ const h = number(hour);
325
+ const time = m !== undefined && h !== undefined ? `${pad(h)}:${pad(m)}` : undefined;
326
+ if (month === "*") {
327
+ if (time && day === "*" && weekday === "*") {
328
+ return words.daily(time);
329
+ }
330
+ if (time && day === "*" && weekday === "1-5") {
331
+ return words.weekdays(time);
332
+ }
333
+ const d = number(weekday);
334
+ if (time && day === "*" && d !== undefined && d <= 7) {
335
+ return words.weekly(d % 7, time);
336
+ }
337
+ const date = number(day);
338
+ if (time && date !== undefined && weekday === "*") {
339
+ return words.monthly(date, time);
340
+ }
341
+ if (m !== undefined && hour === "*" && day === "*" && weekday === "*") {
342
+ return words.hourly(m);
343
+ }
344
+ const everyMinutes = /^\*\/(\d+)$/.exec(minute);
345
+ if (everyMinutes && hour === "*" && day === "*" && weekday === "*") {
346
+ return words.every(Number(everyMinutes[1]), "minute");
347
+ }
348
+ const everyHours = /^\*\/(\d+)$/.exec(hour);
349
+ if (m === 0 && everyHours && day === "*" && weekday === "*") {
350
+ return words.every(Number(everyHours[1]), "hour");
351
+ }
352
+ }
353
+ return words.cron(expression);
354
+ }
355
+ })(ScheduleUtil ||= {});
356
+
357
+ // web-src/task-store.ts
358
+ class TaskStore {
359
+ host;
360
+ writing = Promise.resolve();
361
+ constructor(host) {
362
+ this.host = host;
363
+ }
364
+ async tasks() {
365
+ const value = await this.host.getExtensionData(NAME, Keys.TASKS);
366
+ return Array.isArray(value) ? value.filter(TaskStore.isTask) : [];
367
+ }
368
+ saveTasks(tasks) {
369
+ const copy = tasks.map((task) => ({ ...task }));
370
+ return this.queue(() => this.host.setExtensionData(NAME, Keys.TASKS, copy));
371
+ }
372
+ async runs(taskId) {
373
+ await this.writing.catch(() => {
374
+ return;
375
+ });
376
+ const value = await this.host.getExtensionData(NAME, Keys.runs(taskId));
377
+ return Array.isArray(value) ? value : [];
378
+ }
379
+ saveRun(run) {
380
+ const copy = { ...run };
381
+ return this.queue(async () => {
382
+ const value = await this.host.getExtensionData(NAME, Keys.runs(run.taskId));
383
+ const runs = Array.isArray(value) ? value : [];
384
+ const index = runs.findIndex((other) => other.id === run.id);
385
+ const next = index >= 0 ? runs.map((other) => other.id === run.id ? copy : other) : [copy, ...runs];
386
+ await this.host.setExtensionData(NAME, Keys.runs(run.taskId), next.slice(0, Limits.RUNS_KEPT));
387
+ });
388
+ }
389
+ removeRuns(taskId) {
390
+ return this.queue(() => this.host.setExtensionData(NAME, Keys.runs(taskId), null));
391
+ }
392
+ finished(finished) {
393
+ return this.queue(() => this.host.setExtensionData(NAME, Keys.LATEST, finished));
394
+ }
395
+ async flush() {
396
+ await this.writing.catch(() => {
397
+ return;
398
+ });
399
+ }
400
+ queue(write) {
401
+ const next = this.writing.catch(() => {
402
+ return;
403
+ }).then(write);
404
+ this.writing = next;
405
+ return next;
406
+ }
407
+ static isTask(value) {
408
+ const task = value;
409
+ return typeof task?.id === "string" && typeof task.prompt === "string" && typeof task.schedule === "object" && typeof task.cwd === "string";
410
+ }
411
+ }
412
+
413
+ // web-src/task-util.ts
414
+ var PROMPT_MAX = 20000;
415
+ var NAME_MAX = 80;
416
+ var PREFIX_MIN = 4;
417
+ var TaskUtil;
418
+ ((TaskUtil) => {
419
+ function newId(prefix) {
420
+ const bytes = new Uint8Array(4);
421
+ crypto.getRandomValues(bytes);
422
+ return `${prefix}_${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
423
+ }
424
+ TaskUtil.newId = newId;
425
+ function create(input, cwd, now) {
426
+ const prompt = checkPrompt(input?.prompt);
427
+ const schedule = ScheduleUtil.check(input.schedule);
428
+ const at = now.toISOString();
429
+ const task = {
430
+ id: newId("task"),
431
+ name: checkName(input.name) ?? defaultName(prompt),
432
+ prompt,
433
+ schedule,
434
+ cwd: checkCwd(input.cwd) ?? cwd,
435
+ enabled: input.enabled !== false,
436
+ runCount: 0,
437
+ failCount: 0,
438
+ createdAt: at,
439
+ updatedAt: at
440
+ };
441
+ setOptional(task, input);
442
+ return arm(task, now);
443
+ }
444
+ TaskUtil.create = create;
445
+ function patch(task, patch2, now) {
446
+ const next = { ...task, updatedAt: now.toISOString() };
447
+ if (patch2.prompt !== undefined) {
448
+ next.prompt = checkPrompt(patch2.prompt);
449
+ }
450
+ if (patch2.name !== undefined) {
451
+ next.name = checkName(patch2.name) ?? defaultName(next.prompt);
452
+ }
453
+ if (patch2.cwd !== undefined) {
454
+ next.cwd = checkCwd(patch2.cwd) ?? task.cwd;
455
+ }
456
+ setOptional(next, patch2);
457
+ if (patch2.enabled !== undefined) {
458
+ next.enabled = patch2.enabled === true;
459
+ }
460
+ if (patch2.schedule !== undefined) {
461
+ next.schedule = ScheduleUtil.check(patch2.schedule);
462
+ }
463
+ const rearm = patch2.schedule !== undefined || next.enabled && !task.enabled;
464
+ return rearm ? arm(next, now) : next;
465
+ }
466
+ TaskUtil.patch = patch;
467
+ function arm(task, now) {
468
+ if (!task.enabled) {
469
+ return task;
470
+ }
471
+ const next = ScheduleUtil.next(task.schedule, now);
472
+ if (!next) {
473
+ 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.`);
474
+ }
475
+ return { ...task, nextRunAt: next.toISOString() };
476
+ }
477
+ TaskUtil.arm = arm;
478
+ function find(tasks, ref) {
479
+ const text = typeof ref === "string" ? ref.trim() : "";
480
+ 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);
481
+ if (!found) {
482
+ const known = tasks.length ? tasks.map((task) => `${task.id} (${task.name})`).join(", ") : "none yet";
483
+ throw new Error(`No task is ${JSON.stringify(text)}. The tasks: ${known}.`);
484
+ }
485
+ return found;
486
+ }
487
+ TaskUtil.find = find;
488
+ function systemPrompt(task, now) {
489
+ return [
490
+ RUN_MARK,
491
+ `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()}.`,
492
+ "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.",
493
+ "</ta-cron-run>"
494
+ ].join(`
495
+ `);
496
+ }
497
+ TaskUtil.systemPrompt = systemPrompt;
498
+ function only(tasks) {
499
+ return tasks.length === 1 ? tasks[0] : undefined;
500
+ }
501
+ function setOptional(task, input) {
502
+ if (input.model !== undefined) {
503
+ task.model = checkModel(input.model);
504
+ }
505
+ if (input.thinking !== undefined) {
506
+ task.thinking = checkThinking(input.thinking);
507
+ }
508
+ if (input.notify !== undefined) {
509
+ task.notify = checkNotify(input.notify);
510
+ }
511
+ for (const key of ["model", "thinking", "notify"]) {
512
+ if (task[key] === undefined) {
513
+ delete task[key];
514
+ }
515
+ }
516
+ }
517
+ function checkPrompt(value) {
518
+ const prompt = typeof value === "string" ? value.trim() : "";
519
+ if (!prompt) {
520
+ throw new Error("A task needs a prompt: what Ta should do each time it runs.");
521
+ }
522
+ if (prompt.length > PROMPT_MAX) {
523
+ throw new Error(`A prompt is at most ${PROMPT_MAX} characters; keep long instructions in a file and name it.`);
524
+ }
525
+ return prompt;
526
+ }
527
+ function checkName(value) {
528
+ const name = typeof value === "string" ? value.trim() : "";
529
+ return name ? name.slice(0, NAME_MAX) : undefined;
530
+ }
531
+ function defaultName(prompt) {
532
+ const line = prompt.split(`
533
+ `)[0].trim();
534
+ return line.length > 40 ? `${line.slice(0, 39)}…` : line;
535
+ }
536
+ function checkCwd(value) {
537
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
538
+ }
539
+ function checkModel(value) {
540
+ const model = typeof value === "string" ? value.trim() : "";
541
+ return model || undefined;
542
+ }
543
+ function checkThinking(value) {
544
+ const level = typeof value === "string" ? value.trim() : "";
545
+ if (level && !THINKING_LEVELS.includes(level)) {
546
+ throw new Error(`A thinking level is one of ${THINKING_LEVELS.join(", ")}; not ${JSON.stringify(level)}.`);
547
+ }
548
+ return level || undefined;
549
+ }
550
+ function checkNotify(value) {
551
+ if (value === "" || value === null) {
552
+ return;
553
+ }
554
+ if (!NOTIFY_LEVELS.includes(value)) {
555
+ throw new Error(`notify is one of ${NOTIFY_LEVELS.join(", ")}; not ${JSON.stringify(value)}.`);
556
+ }
557
+ return value;
558
+ }
559
+ function missed(task, now) {
560
+ return task.schedule.kind === "once" && !!task.nextRunAt && now.getTime() - new Date(task.nextRunAt).getTime() > Limits.GRACE_MS;
561
+ }
562
+ TaskUtil.missed = missed;
563
+ })(TaskUtil ||= {});
564
+
565
+ // web-src/scheduler.ts
566
+ class CronScheduler {
567
+ host;
568
+ tasks = [];
569
+ store;
570
+ options;
571
+ active = new Map;
572
+ waiting = [];
573
+ working = 0;
574
+ lingering = new Set;
575
+ timer;
576
+ disposed = false;
577
+ constructor(host, options = {}) {
578
+ this.host = host;
579
+ this.store = new TaskStore(host);
580
+ this.options = { now: () => new Date, tickMs: 60000, pollMs: 1000, timeoutMs: Limits.RUN_TIMEOUT_MS, parallel: Limits.PARALLEL_RUNS, ...options };
581
+ }
582
+ async start() {
583
+ this.tasks = await this.store.tasks();
584
+ const now = this.options.now();
585
+ for (const task of this.tasks) {
586
+ if (task.lastStatus === "running") {
587
+ await this.reclaim(task, now);
588
+ }
589
+ }
590
+ for (const task of [...this.tasks]) {
591
+ if (task.enabled && TaskUtil.missed(task, now)) {
592
+ await this.miss(task, now);
593
+ }
594
+ }
595
+ await this.store.saveTasks(this.tasks);
596
+ this.arm();
597
+ }
598
+ async dispose() {
599
+ this.disposed = true;
600
+ clearTimeout(this.timer);
601
+ await this.store.flush();
602
+ }
603
+ async list() {
604
+ return this.tasks.map((task) => ({ ...task }));
605
+ }
606
+ async get(ref) {
607
+ return { ...TaskUtil.find(this.tasks, ref) };
608
+ }
609
+ async runs(ref, limit = Limits.RUNS_KEPT) {
610
+ const task = TaskUtil.find(this.tasks, ref);
611
+ return (await this.store.runs(task.id)).slice(0, Math.max(1, limit));
612
+ }
613
+ async add(input) {
614
+ const cwd = (await this.host.getServerInfo()).cwd;
615
+ const task = TaskUtil.create(input, cwd, this.options.now());
616
+ await this.save([...this.tasks, task]);
617
+ return { ...task };
618
+ }
619
+ async update(ref, patch) {
620
+ const task = TaskUtil.find(this.tasks, ref);
621
+ const next = TaskUtil.patch(task, patch ?? {}, this.options.now());
622
+ await this.replace(next);
623
+ return { ...next };
624
+ }
625
+ setEnabled(ref, enabled) {
626
+ return this.update(ref, { enabled: enabled === true });
627
+ }
628
+ async remove(ref) {
629
+ const task = TaskUtil.find(this.tasks, ref);
630
+ await this.drop([task]);
631
+ return task;
632
+ }
633
+ async clear(cwd) {
634
+ const gone = this.tasks.filter((task) => !cwd || task.cwd === cwd);
635
+ await this.drop(gone);
636
+ return gone;
637
+ }
638
+ async run(ref) {
639
+ const task = TaskUtil.find(this.tasks, ref);
640
+ if (this.active.has(task.id)) {
641
+ throw new Error(`${task.name} is running now; wait for its run to end.`);
642
+ }
643
+ return this.begin(task, "manual", this.options.now());
644
+ }
645
+ isRun(sessionId) {
646
+ return [...this.active.values()].some((active) => active.sessionId === sessionId);
647
+ }
648
+ arm() {
649
+ clearTimeout(this.timer);
650
+ if (this.disposed) {
651
+ return;
652
+ }
653
+ const now = this.options.now().getTime();
654
+ let delay = this.options.tickMs;
655
+ for (const task of this.tasks) {
656
+ if (task.enabled && task.nextRunAt) {
657
+ delay = Math.min(delay, Math.max(0, new Date(task.nextRunAt).getTime() - now));
658
+ }
659
+ }
660
+ this.timer = setTimeout(() => void this.tick().catch((error) => console.error(`${NAME}: ${message(error)}`)), delay);
661
+ this.timer.unref?.();
662
+ }
663
+ async tick() {
664
+ if (this.disposed) {
665
+ return;
666
+ }
667
+ const now = this.options.now();
668
+ for (const task of this.tasks) {
669
+ if (!task.enabled || !task.nextRunAt || new Date(task.nextRunAt).getTime() > now.getTime()) {
670
+ continue;
671
+ }
672
+ if (this.active.has(task.id)) {
673
+ await this.replace(this.advance(task, now));
674
+ } else {
675
+ await this.begin(task, "schedule", now);
676
+ }
677
+ }
678
+ await this.sweep();
679
+ this.arm();
680
+ }
681
+ advance(task, now) {
682
+ if (!ScheduleUtil.repeats(task.schedule)) {
683
+ const { nextRunAt: _done, ...rest } = task;
684
+ return { ...rest, enabled: false };
685
+ }
686
+ const next = ScheduleUtil.next(task.schedule, now);
687
+ return { ...task, nextRunAt: next?.toISOString() };
688
+ }
689
+ async begin(task, trigger, now) {
690
+ const run = { id: TaskUtil.newId("run"), taskId: task.id, trigger, status: "running", startedAt: now.toISOString(), cwd: task.cwd };
691
+ const started = trigger === "schedule" ? this.advance(task, now) : task;
692
+ await this.replace({ ...started, lastRunAt: run.startedAt, lastStatus: "running" });
693
+ await this.store.saveRun(run);
694
+ const active = { run, task: { ...task } };
695
+ this.active.set(task.id, active);
696
+ this.waiting.push(active);
697
+ this.pump();
698
+ return { ...run };
699
+ }
700
+ pump() {
701
+ while (this.working < this.options.parallel && this.waiting.length > 0 && !this.disposed) {
702
+ const active = this.waiting.shift();
703
+ this.working++;
704
+ this.execute(active).catch((error) => console.error(`${NAME}: ${message(error)}`)).finally(() => {
705
+ this.working--;
706
+ this.pump();
707
+ });
708
+ }
709
+ }
710
+ async execute(active) {
711
+ const { task, run } = active;
712
+ if (active.dropped) {
713
+ return;
714
+ }
715
+ try {
716
+ const now = this.options.now();
717
+ const { sessionId } = await this.host.openSession({
718
+ cwd: task.cwd,
719
+ group: NAME,
720
+ appendSystemPrompt: TaskUtil.systemPrompt(task, now),
721
+ ...task.model ? { model: task.model } : {},
722
+ ...task.thinking ? { thinkingLevel: task.thinking } : {}
723
+ });
724
+ active.sessionId = sessionId;
725
+ await this.host.setSessionName(sessionId, `${task.name} · ${ScheduleUtil.clock(now)}`).catch(() => {
726
+ return;
727
+ });
728
+ const state = await this.host.getState(sessionId);
729
+ run.sessionFile = state.sessionFile;
730
+ await this.store.saveRun(run);
731
+ await this.host.prompt(sessionId, { clientMessageId: run.id, message: task.prompt });
732
+ await this.settled(active, state.messageCount);
733
+ const { text } = await this.host.getLastAssistantText(sessionId);
734
+ if (!text?.trim()) {
735
+ throw new Error("The run ended without an answer; the model may have failed. Open its conversation to see.");
736
+ }
737
+ await this.finish(active, { status: "success", summary: clip(text.trim()) });
738
+ } catch (error) {
739
+ await this.finish(active, { status: "error", error: message(error), ...error instanceof TimeoutError ? { reason: "timeout" } : {} });
740
+ }
741
+ }
742
+ async settled(active, before) {
743
+ const sessionId = active.sessionId;
744
+ const start = Date.now();
745
+ for (;; ) {
746
+ if (active.dropped || this.disposed) {
747
+ throw new Error("The task was removed while it ran.");
748
+ }
749
+ const state = await this.host.getState(sessionId);
750
+ if (!state.isStreaming && state.pendingMessageCount === 0 && state.messageCount > before) {
751
+ return;
752
+ }
753
+ if (Date.now() - start > this.options.timeoutMs) {
754
+ await this.host.abort(sessionId).catch(() => {
755
+ return;
756
+ });
757
+ throw new TimeoutError(`The run took longer than ${Math.round(this.options.timeoutMs / 60000)} minutes and was stopped.`);
758
+ }
759
+ await new Promise((resolve) => setTimeout(resolve, this.options.pollMs));
760
+ }
761
+ }
762
+ async finish(active, end) {
763
+ this.active.delete(active.task.id);
764
+ const sessionId = active.sessionId;
765
+ if (sessionId) {
766
+ this.lingering.add(sessionId);
767
+ }
768
+ if (active.dropped || this.disposed) {
769
+ await this.sweep();
770
+ return;
771
+ }
772
+ const run = { ...active.run, ...end, endedAt: this.options.now().toISOString() };
773
+ await this.store.saveRun(run);
774
+ const current = this.tasks.find((task) => task.id === active.task.id);
775
+ if (current) {
776
+ const failed = run.status === "error";
777
+ await this.replace({
778
+ ...current,
779
+ lastStatus: run.status,
780
+ runCount: current.runCount + 1,
781
+ failCount: current.failCount + (failed ? 1 : 0)
782
+ });
783
+ await this.store.finished({ run, taskName: current.name, notify: ScheduleUtil.shouldNotify(ScheduleUtil.notifyLevel(current), failed) });
784
+ }
785
+ await this.sweep();
786
+ }
787
+ async sweep() {
788
+ if (this.lingering.size === 0) {
789
+ return;
790
+ }
791
+ const open = new Map((await this.host.listSessions()).map((info) => [info.sessionId, info]));
792
+ for (const sessionId of [...this.lingering]) {
793
+ const info = open.get(sessionId);
794
+ if (!info) {
795
+ this.lingering.delete(sessionId);
796
+ } else if (info.attached === 0 && !info.isStreaming) {
797
+ this.lingering.delete(sessionId);
798
+ await this.host.closeSession(sessionId).catch(() => {
799
+ return;
800
+ });
801
+ }
802
+ }
803
+ }
804
+ async reclaim(task, now) {
805
+ for (const run of await this.store.runs(task.id)) {
806
+ if (run.status === "running") {
807
+ await this.store.saveRun({
808
+ ...run,
809
+ status: "error",
810
+ reason: "interrupted",
811
+ error: "The Ta service stopped before the run ended.",
812
+ endedAt: now.toISOString()
813
+ });
814
+ }
815
+ }
816
+ this.tasks = this.tasks.map((other) => other.id === task.id ? { ...other, lastStatus: "error", failCount: other.failCount + 1 } : other);
817
+ }
818
+ async miss(task, now) {
819
+ const run = {
820
+ id: TaskUtil.newId("run"),
821
+ taskId: task.id,
822
+ trigger: "schedule",
823
+ status: "missed",
824
+ startedAt: task.nextRunAt ?? now.toISOString(),
825
+ endedAt: now.toISOString(),
826
+ error: "The Ta service was not running at its time; run it by hand if it is still wanted.",
827
+ cwd: task.cwd
828
+ };
829
+ await this.store.saveRun(run);
830
+ const { nextRunAt: _gone, ...rest } = task;
831
+ this.tasks = this.tasks.map((other) => other.id === task.id ? { ...rest, enabled: false, lastStatus: "missed", lastRunAt: run.startedAt } : other);
832
+ await this.store.finished({ run, taskName: task.name, notify: ScheduleUtil.notifyLevel(task) !== "never" });
833
+ }
834
+ async drop(tasks) {
835
+ const ids = new Set(tasks.map((task) => task.id));
836
+ for (const id of ids) {
837
+ const active = this.active.get(id);
838
+ if (active) {
839
+ active.dropped = true;
840
+ if (active.sessionId) {
841
+ await this.host.abort(active.sessionId).catch(() => {
842
+ return;
843
+ });
844
+ }
845
+ }
846
+ await this.store.removeRuns(id);
847
+ }
848
+ await this.save(this.tasks.filter((task) => !ids.has(task.id)));
849
+ }
850
+ replace(task) {
851
+ return this.save(this.tasks.map((other) => other.id === task.id ? task : other));
852
+ }
853
+ async save(tasks) {
854
+ this.tasks = tasks;
855
+ await this.store.saveTasks(tasks);
856
+ this.arm();
857
+ }
858
+ }
859
+
860
+ class TimeoutError extends Error {
861
+ }
862
+ function clip(text) {
863
+ return text.length > Limits.SUMMARY_MAX ? `${text.slice(0, Limits.SUMMARY_MAX - 1)}…` : text;
864
+ }
865
+ function message(error) {
866
+ return error instanceof Error ? error.message : String(error);
867
+ }
868
+
869
+ // web-src/host.ts
870
+ async function activate(host) {
871
+ const scheduler = new CronScheduler(host);
872
+ await scheduler.start();
873
+ return scheduler;
874
+ }
875
+ export {
876
+ activate as default
877
+ };