@wirecat/cli-core 3.1.0-dev → 3.2.0-dev

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 (351) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/bundle/{agent-RMLBQXJF-CuqJBQqf.js → agent-J75WGZEV-K_l-bQ-h.js} +5 -5
  4. package/dist/bundle/{all-profiles-3GEKS7PR-Bi_zb5_-.js → all-profiles-3GEKS7PR-BohqgNvP.js} +6 -6
  5. package/dist/bundle/{anthropic-EVM6I7MZ-BWI01JgC.js → anthropic-EVM6I7MZ-CqB3j7dB.js} +2 -2
  6. package/dist/bundle/{app-server-76XGUZHU-__6SrMhc.js → app-server-5BL62GAL-Osw_tMej.js} +20 -15
  7. package/dist/bundle/{bun-AWMVU72K-COHrAYHA.js → bun-AWMVU72K-Bk0oN5Sm.js} +2 -2
  8. package/dist/bundle/{bun-sqlite-CYFVVXXR-r_kJOwku.js → bun-sqlite-CYFVVXXR-4iGlaI9X.js} +3 -3
  9. package/dist/bundle/{chunk-4ZM6SE7G-DNDxhi8l.js → chunk-4HGRFFTO-fNvELOjI.js} +330 -56
  10. package/dist/bundle/{chunk-6G6TIMKP-CoVYG_I3.js → chunk-6G6TIMKP-Byea1UGV.js} +4 -4
  11. package/dist/bundle/{chunk-M5CHOMME-BIcASmVb.js → chunk-6OLVBOBX-Ch2rblZk.js} +17 -11
  12. package/dist/bundle/{chunk-CCFBHR4O-DAuKd8rI.js → chunk-CCFBHR4O-Bhxq5eaI.js} +1 -1
  13. package/dist/bundle/{chunk-DDXCCEI4-CHLrblc1.js → chunk-DDXCCEI4-CBg_l4Ro.js} +2 -2
  14. package/dist/bundle/{chunk-DZPIGAKP-nrRAPNTz.js → chunk-DZPIGAKP-BZy6DShN.js} +1 -1
  15. package/dist/bundle/{chunk-ERNCGLKE-4JdU74o6.js → chunk-ERNCGLKE-D3HStkJC.js} +1 -1
  16. package/dist/bundle/{chunk-GBNNGOIB-DVUFOYzA.js → chunk-GBNNGOIB-DS3rusdH.js} +5 -5
  17. package/dist/bundle/{chunk-GJTANPFI-5L6Owk-H.js → chunk-GJTANPFI-DlUMnFUQ.js} +3 -3
  18. package/dist/bundle/{chunk-6ZUQA7OL-ofpF0AvH.js → chunk-GRGGW52W-Fkw6omOx.js} +5 -5
  19. package/dist/bundle/{chunk-KSUALCA7-DB6cYuSU.js → chunk-KSUALCA7-SMNQ85c6.js} +1 -1
  20. package/dist/bundle/{chunk-LBVI4Z2X-COUoJmWU.js → chunk-LBVI4Z2X-D9_8iC1S.js} +1 -1
  21. package/dist/bundle/{chunk-M23BPYSL-ChiHsEsy.js → chunk-M23BPYSL-ByTcRixP.js} +3 -3
  22. package/dist/bundle/{chunk-Z3ZVBBWR-whNBW-iH.js → chunk-M4KMNZN6-CBeUwDlF.js} +2 -2
  23. package/dist/bundle/{chunk-NG7F5L7N-BKCEXGxy.js → chunk-NG7F5L7N-Ch_ERSNz.js} +1 -1
  24. package/dist/bundle/{chunk-NX2VS2ER-DS6Urg3e.js → chunk-NX2VS2ER-CWN0zXqZ.js} +1 -1
  25. package/dist/bundle/{chunk-O2HOOK7X-Dboq6vxP.js → chunk-O2HOOK7X-Dyw_Dcql.js} +4 -4
  26. package/dist/bundle/{chunk-PSD6373C-wlicX185.js → chunk-PSD6373C-DgL0rhKe.js} +1 -1
  27. package/dist/bundle/{chunk-RTCT4N7Y-Dn-lP1zF.js → chunk-RTCT4N7Y-BEZ3cJ5d.js} +1 -1
  28. package/dist/bundle/{chunk-S34BE7ZC-p6NeYmqQ.js → chunk-S34BE7ZC-BO0yaVoX.js} +1 -1
  29. package/dist/bundle/{chunk-E6KETVFF-wOOXf4op.js → chunk-SRAGL5LI-CKhhwRrx.js} +5 -5
  30. package/dist/bundle/{chunk-T6V6LFHT-Dwv7XUuC.js → chunk-T6V6LFHT-BazTZ25Y.js} +1 -1
  31. package/dist/bundle/{chunk-ACWFPMZF-DkR70AOW.js → chunk-TFRAD7RO-BVAK9frq.js} +50 -4
  32. package/dist/bundle/{chunk-UH2H3OLE-R_6H5D7o.js → chunk-UH2H3OLE-QNxQo07O.js} +1 -1
  33. package/dist/bundle/{chunk-UQJGYQ56-CANeLx5l.js → chunk-UQJGYQ56-PoYTv6WX.js} +1 -1
  34. package/dist/bundle/{chunk-VKZDPPVI-d7RS_QOW.js → chunk-VKZDPPVI-BOmnhxVJ.js} +2 -2
  35. package/dist/bundle/{chunk-UNGNJ255-CtLEiDap.js → chunk-W3AAOYWE-Cyx1kZsd.js} +7 -7
  36. package/dist/bundle/{chunk-WXEJSLMO-DbSxVCq9.js → chunk-WXEJSLMO-DCjDRcYe.js} +8 -8
  37. package/dist/bundle/{chunk-XW3IHFDH-CjmXc8aI.js → chunk-XW3IHFDH-CA9Bby7o.js} +1 -1
  38. package/dist/bundle/{chunk-YHBBPJW6-jAof9asy.js → chunk-YHBBPJW6-DKIU2gC4.js} +2 -2
  39. package/dist/bundle/{chunk-YITG2CE5-Bg4SA8X1.js → chunk-YITG2CE5-o18mzaka.js} +1 -1
  40. package/dist/bundle/{chunk-ZMRSCVFX-Dwxb-Yg1.js → chunk-ZMRSCVFX-uhwzmZUP.js} +1 -1
  41. package/dist/bundle/chunks.json +83 -83
  42. package/dist/bundle/{command-contract-4X4JDKH7-BsU8tW9N.js → command-contract-DHFUF6RM-Bnc6nJSk.js} +2 -2
  43. package/dist/bundle/{command-server-entry-3JEJBUK5-CF-VyCRd.js → command-server-entry-UQSMAHYK-DzjTaTCZ.js} +2 -2
  44. package/dist/bundle/{decode-KVUA3TLF-Ds0C1R9U.js → decode-KVUA3TLF-BoJfgCpS.js} +2 -2
  45. package/dist/bundle/{dist-TPSNLFVO-D1tJd0aB.js → dist-TPSNLFVO-55jBf4N-.js} +2 -2
  46. package/dist/bundle/documents.js +5 -5
  47. package/dist/bundle/{echarts-6Q4CQ2DC-BvZMDYNl.js → echarts-6Q4CQ2DC-w9WhKUJu.js} +1 -1
  48. package/dist/bundle/{embed-JGGK2WKR-h5ppwooq.js → embed-JGGK2WKR-Cl3meWl4.js} +2 -2
  49. package/dist/bundle/{embedder-5SIVKVWO-D4yt4YCy.js → embedder-5SIVKVWO-DJEa9hBn.js} +2 -2
  50. package/dist/bundle/{first-run-FFHXPGFC-CyHZ4KM3.js → first-run-BT3X33BP-JikrW5_w.js} +2 -2
  51. package/dist/bundle/{first-screen-2NGQNWIN-BkvwnUdE.js → first-screen-KGQQK446-D2MchUuo.js} +2 -2
  52. package/dist/bundle/{hast-util-from-html-WLAUHN53-BfAYjYKc.js → hast-util-from-html-WLAUHN53-BOWgHBLv.js} +4 -4
  53. package/dist/bundle/{hast-util-to-html-PJC36XDP-C8DGIyzU.js → hast-util-to-html-PJC36XDP-QwbM5c4F.js} +5 -5
  54. package/dist/bundle/{hast-util-to-mdast-ZQ5OFYUM-9p6MJEBi.js → hast-util-to-mdast-ZQ5OFYUM-BidjUANu.js} +6 -6
  55. package/dist/bundle/{index-BOgkxLir.js → index-CTvUjqLX.js} +331 -345
  56. package/dist/bundle/index.js +66 -66
  57. package/dist/bundle/install-IPXFNLYZ-BGKW94IA.js +5 -0
  58. package/dist/bundle/{instructions-NHSD6EUE-BfefgySD.js → instructions-34FSWDC6-BR7mbjJH.js} +2 -2
  59. package/dist/bundle/mail.js +3 -3
  60. package/dist/bundle/{mcp-server-5FM4GA2C-CNWjKPAi.js → mcp-server-5FM4GA2C-B4Sqou0Z.js} +2 -2
  61. package/dist/bundle/mcp.js +12 -12
  62. package/dist/bundle/{mdast-util-from-markdown-Y7N3XA5A-ZkhTz5VO.js → mdast-util-from-markdown-Y7N3XA5A-CBCtetYX.js} +8 -8
  63. package/dist/bundle/{mdast-util-gfm-52PMOHWQ-gfhFQVZ5.js → mdast-util-gfm-52PMOHWQ-Bv-Hkixb.js} +12 -12
  64. package/dist/bundle/{mdast-util-to-hast-4MTEM3TB-Bomsq1EU.js → mdast-util-to-hast-4MTEM3TB-40gSN0gV.js} +6 -6
  65. package/dist/bundle/mdast-util-to-markdown-UGCOLDXA-DnYraMQX.js +12 -0
  66. package/dist/bundle/{meeting-combined-G3OVTNM6-CFHWFlT-.js → meeting-combined-G3OVTNM6-C4Jdctiy.js} +2 -2
  67. package/dist/bundle/{meeting-model-RINL42I5-Bab4crMQ.js → meeting-model-RINL42I5-BLAAT6mv.js} +2 -2
  68. package/dist/bundle/meeting-semantic-I7AZQTEI-DQ19wjn5.js +5 -0
  69. package/dist/bundle/{micromark-extension-gfm-FRHRNOIW-81l4O6kr.js → micromark-extension-gfm-FRHRNOIW-BvJCT_wq.js} +6 -6
  70. package/dist/bundle/{node-ZIYT5JOL-WfCpdwZ2.js → node-ZIYT5JOL-DoWqiI0I.js} +2 -2
  71. package/dist/bundle/{node-sqlite-VFGFD4MA-CrKdzJgw.js → node-sqlite-VFGFD4MA-QH9swjUN.js} +3 -3
  72. package/dist/bundle/notes-search-2Q3C65PA-D2HqYyaY.js +5 -0
  73. package/dist/bundle/oauth-TVUNW3GM-uN6u_RWy.js +7 -0
  74. package/dist/bundle/{open-36SZHLGF-kGan0BjP.js → open-36SZHLGF-CPBs6fdy.js} +1 -1
  75. package/dist/bundle/{openai-Z2WIZ6AC-D-aH-As-.js → openai-Z2WIZ6AC-CcEngcFj.js} +2 -2
  76. package/dist/bundle/preload.js +1 -1
  77. package/dist/bundle/{process-KJQOPRSP-C6W_P1_I.js → process-KJQOPRSP-BNqvUqBZ.js} +2 -2
  78. package/dist/bundle/{prompt-S2W33X57-BEDbCA8B.js → prompt-S2W33X57-BiF1939t.js} +2 -2
  79. package/dist/bundle/{recognize-NBWDLXLD-B2LTlDUy.js → recognize-NBWDLXLD-BCqQ8iG1.js} +2 -2
  80. package/dist/bundle/{remote-O54ANXYL-DOEubnhV.js → remote-O54ANXYL-BixLG9XM.js} +2 -2
  81. package/dist/bundle/{rerank-HTCSXPM6-CVIU4cUa.js → rerank-HTCSXPM6-FGYUs2VW.js} +2 -2
  82. package/dist/bundle/serve-7KRXCBBZ-EVSG16Mc.js +8 -0
  83. package/dist/bundle/server-BFD6QUV7-OmgCCeuX.js +11 -0
  84. package/dist/bundle/server-G7VWUBA2-C3Gq_HlM.js +12 -0
  85. package/dist/bundle/{sqlite-runtime-KC3NKKRB-DYslMC-g.js → sqlite-runtime-KC3NKKRB-y_O8PNsQ.js} +1 -1
  86. package/dist/bundle/{start-Dtq56YXe.js → start-CqQGB7xI.js} +5 -5
  87. package/dist/bundle/start.js +1 -1
  88. package/dist/bundle/state-3CFS2SAC-CYYQ103I.js +5 -0
  89. package/dist/bundle/store-BSVRVKTV-Uot4OGm0.js +5 -0
  90. package/dist/bundle/{store-6CM2A3HP-CtnMVUVK.js → store-LGAEGNFF-BzNIKnoK.js} +2 -2
  91. package/dist/bundle/{store-maintenance-command-WYO5PN4V-B0wefBHZ.js → store-maintenance-command-Z27R7URJ-CoJCYGVq.js} +2 -2
  92. package/dist/bundle/surface-ZEEHYD5Q-DRIV3XG3.js +8 -0
  93. package/dist/bundle/testing.js +8 -8
  94. package/dist/cli/app-doctor-command.d.ts +187 -1
  95. package/dist/cli/app-doctor-command.d.ts.map +1 -1
  96. package/dist/cli/app-doctor-command.js +3 -2
  97. package/dist/cli/app-doctor-command.js.map +1 -1
  98. package/dist/cli/app-mcp-command.d.ts +187 -2
  99. package/dist/cli/app-mcp-command.d.ts.map +1 -1
  100. package/dist/cli/app-mcp-command.js +3 -2
  101. package/dist/cli/app-mcp-command.js.map +1 -1
  102. package/dist/cli/built-commands.d.ts +10 -0
  103. package/dist/cli/built-commands.d.ts.map +1 -0
  104. package/dist/cli/built-commands.js +33 -0
  105. package/dist/cli/built-commands.js.map +1 -0
  106. package/dist/cli/commands-command.d.ts.map +1 -1
  107. package/dist/cli/commands-command.js +3 -2
  108. package/dist/cli/commands-command.js.map +1 -1
  109. package/dist/cli/complete-command.d.ts +187 -2
  110. package/dist/cli/complete-command.d.ts.map +1 -1
  111. package/dist/cli/complete-command.js +3 -2
  112. package/dist/cli/complete-command.js.map +1 -1
  113. package/dist/cli/config-command.d.ts +189 -3
  114. package/dist/cli/config-command.d.ts.map +1 -1
  115. package/dist/cli/config-command.js +3 -2
  116. package/dist/cli/config-command.js.map +1 -1
  117. package/dist/cli/context.d.ts +8 -0
  118. package/dist/cli/context.d.ts.map +1 -1
  119. package/dist/cli/context.js +39 -2
  120. package/dist/cli/context.js.map +1 -1
  121. package/dist/cli/documents/words.d.ts +1 -1
  122. package/dist/cli/dry-run-guard.d.ts.map +1 -1
  123. package/dist/cli/dry-run-guard.js +6 -28
  124. package/dist/cli/dry-run-guard.js.map +1 -1
  125. package/dist/cli/first-run.js +1 -1
  126. package/dist/cli/first-run.js.map +1 -1
  127. package/dist/cli/guide.d.ts.map +1 -1
  128. package/dist/cli/guide.js +3 -2
  129. package/dist/cli/guide.js.map +1 -1
  130. package/dist/cli/messenger/archive-commands.d.ts.map +1 -1
  131. package/dist/cli/messenger/archive-commands.js +3 -2
  132. package/dist/cli/messenger/archive-commands.js.map +1 -1
  133. package/dist/cli/messenger/complete-command.d.ts +187 -2
  134. package/dist/cli/messenger/complete-command.d.ts.map +1 -1
  135. package/dist/cli/messenger/complete-command.js +3 -2
  136. package/dist/cli/messenger/complete-command.js.map +1 -1
  137. package/dist/cli/messenger/doctor-command.d.ts.map +1 -1
  138. package/dist/cli/messenger/doctor-command.js +3 -2
  139. package/dist/cli/messenger/doctor-command.js.map +1 -1
  140. package/dist/cli/messenger/flood-command.d.ts.map +1 -1
  141. package/dist/cli/messenger/flood-command.js +3 -2
  142. package/dist/cli/messenger/flood-command.js.map +1 -1
  143. package/dist/cli/messenger/mcp-command.d.ts.map +1 -1
  144. package/dist/cli/messenger/mcp-command.js +3 -2
  145. package/dist/cli/messenger/mcp-command.js.map +1 -1
  146. package/dist/cli/messenger/metadata-command.d.ts.map +1 -1
  147. package/dist/cli/messenger/metadata-command.js +3 -2
  148. package/dist/cli/messenger/metadata-command.js.map +1 -1
  149. package/dist/cli/messenger/models-command.d.ts.map +1 -1
  150. package/dist/cli/messenger/models-command.js +3 -2
  151. package/dist/cli/messenger/models-command.js.map +1 -1
  152. package/dist/cli/messenger/server-command.d.ts +1 -1
  153. package/dist/cli/messenger/server-command.d.ts.map +1 -1
  154. package/dist/cli/messenger/server-command.js +3 -2
  155. package/dist/cli/messenger/server-command.js.map +1 -1
  156. package/dist/cli/messenger/session-commands.d.ts.map +1 -1
  157. package/dist/cli/messenger/session-commands.js +3 -2
  158. package/dist/cli/messenger/session-commands.js.map +1 -1
  159. package/dist/cli/messenger/store-maintenance-command.d.ts.map +1 -1
  160. package/dist/cli/messenger/store-maintenance-command.js +11 -5
  161. package/dist/cli/messenger/store-maintenance-command.js.map +1 -1
  162. package/dist/cli/model-catalogue-command.d.ts.map +1 -1
  163. package/dist/cli/model-catalogue-command.js +3 -2
  164. package/dist/cli/model-catalogue-command.js.map +1 -1
  165. package/dist/cli/oauth-session.d.ts.map +1 -1
  166. package/dist/cli/oauth-session.js +3 -2
  167. package/dist/cli/oauth-session.js.map +1 -1
  168. package/dist/cli/runs/command.d.ts.map +1 -1
  169. package/dist/cli/runs/command.js +3 -2
  170. package/dist/cli/runs/command.js.map +1 -1
  171. package/dist/cli/schedule/schedule-command.d.ts +1 -1
  172. package/dist/cli/schedule/schedule-command.d.ts.map +1 -1
  173. package/dist/cli/schedule/schedule-command.js +5 -3
  174. package/dist/cli/schedule/schedule-command.js.map +1 -1
  175. package/dist/cli/setup-command.d.ts.map +1 -1
  176. package/dist/cli/setup-command.js +3 -2
  177. package/dist/cli/setup-command.js.map +1 -1
  178. package/dist/cli/skill-command.d.ts.map +1 -1
  179. package/dist/cli/skill-command.js +3 -2
  180. package/dist/cli/skill-command.js.map +1 -1
  181. package/dist/cli/store-info.d.ts.map +1 -1
  182. package/dist/cli/store-info.js +5 -4
  183. package/dist/cli/store-info.js.map +1 -1
  184. package/dist/cli/token-session.d.ts.map +1 -1
  185. package/dist/cli/token-session.js +2 -1
  186. package/dist/cli/token-session.js.map +1 -1
  187. package/dist/cli/upgrade-command.d.ts.map +1 -1
  188. package/dist/cli/upgrade-command.js +4 -5
  189. package/dist/cli/upgrade-command.js.map +1 -1
  190. package/dist/cli/upkeep.d.ts +8 -0
  191. package/dist/cli/upkeep.d.ts.map +1 -0
  192. package/dist/cli/upkeep.js +11 -0
  193. package/dist/cli/upkeep.js.map +1 -0
  194. package/dist/entities/attachment.d.ts +0 -8
  195. package/dist/entities/attachment.d.ts.map +1 -1
  196. package/dist/entities/attachment.js +22 -20
  197. package/dist/entities/attachment.js.map +1 -1
  198. package/dist/entities/chat.d.ts +0 -4
  199. package/dist/entities/chat.d.ts.map +1 -1
  200. package/dist/entities/chat.js +6 -10
  201. package/dist/entities/chat.js.map +1 -1
  202. package/dist/entities/contact.d.ts +0 -7
  203. package/dist/entities/contact.d.ts.map +1 -1
  204. package/dist/entities/contact.js +9 -16
  205. package/dist/entities/contact.js.map +1 -1
  206. package/dist/entities/deal.d.ts +0 -36
  207. package/dist/entities/deal.d.ts.map +1 -1
  208. package/dist/entities/deal.js +22 -48
  209. package/dist/entities/deal.js.map +1 -1
  210. package/dist/entities/document.d.ts +0 -2
  211. package/dist/entities/document.d.ts.map +1 -1
  212. package/dist/entities/document.js +3 -5
  213. package/dist/entities/document.js.map +1 -1
  214. package/dist/entities/fields.d.ts +5 -1
  215. package/dist/entities/fields.d.ts.map +1 -1
  216. package/dist/entities/fields.js +6 -2
  217. package/dist/entities/fields.js.map +1 -1
  218. package/dist/entities/hit.d.ts +0 -18
  219. package/dist/entities/hit.d.ts.map +1 -1
  220. package/dist/entities/hit.js +19 -37
  221. package/dist/entities/hit.js.map +1 -1
  222. package/dist/entities/index.d.ts +0 -1
  223. package/dist/entities/index.d.ts.map +1 -1
  224. package/dist/entities/index.js +2 -3
  225. package/dist/entities/index.js.map +1 -1
  226. package/dist/entities/message.d.ts +2 -34
  227. package/dist/entities/message.d.ts.map +1 -1
  228. package/dist/entities/message.js +35 -67
  229. package/dist/entities/message.js.map +1 -1
  230. package/dist/entities/task.d.ts +0 -19
  231. package/dist/entities/task.d.ts.map +1 -1
  232. package/dist/entities/task.js +18 -35
  233. package/dist/entities/task.js.map +1 -1
  234. package/dist/mcp/agent.d.ts +3 -0
  235. package/dist/mcp/agent.d.ts.map +1 -1
  236. package/dist/mcp/agent.js +48 -1
  237. package/dist/mcp/agent.js.map +1 -1
  238. package/dist/mcp/app-server.d.ts.map +1 -1
  239. package/dist/mcp/app-server.js +8 -5
  240. package/dist/mcp/app-server.js.map +1 -1
  241. package/dist/mcp/bot/instructions.js +1 -1
  242. package/dist/mcp/bot/instructions.js.map +1 -1
  243. package/dist/mcp/index.d.ts +4 -0
  244. package/dist/mcp/index.d.ts.map +1 -1
  245. package/dist/mcp/index.js +4 -0
  246. package/dist/mcp/index.js.map +1 -1
  247. package/dist/mcp/instructions.js +4 -4
  248. package/dist/mcp/instructions.js.map +1 -1
  249. package/dist/mcp/lean.d.ts +9 -0
  250. package/dist/mcp/lean.d.ts.map +1 -0
  251. package/dist/mcp/lean.js +7 -0
  252. package/dist/mcp/lean.js.map +1 -0
  253. package/dist/mcp/server.d.ts.map +1 -1
  254. package/dist/mcp/server.js +6 -2
  255. package/dist/mcp/server.js.map +1 -1
  256. package/dist/mcp/surface.d.ts +51 -2
  257. package/dist/mcp/surface.d.ts.map +1 -1
  258. package/dist/mcp/surface.js +379 -52
  259. package/dist/mcp/surface.js.map +1 -1
  260. package/dist/mcp/tool.d.ts +9 -1
  261. package/dist/mcp/tool.d.ts.map +1 -1
  262. package/dist/mcp/tool.js +20 -6
  263. package/dist/mcp/tool.js.map +1 -1
  264. package/dist/output-detail.d.ts +8 -0
  265. package/dist/output-detail.d.ts.map +1 -1
  266. package/dist/output-detail.js +55 -0
  267. package/dist/output-detail.js.map +1 -1
  268. package/dist/services/package-upgrade.d.ts.map +1 -1
  269. package/dist/services/package-upgrade.js +3 -1
  270. package/dist/services/package-upgrade.js.map +1 -1
  271. package/dist/store/compatibility.d.ts +2 -0
  272. package/dist/store/compatibility.d.ts.map +1 -1
  273. package/dist/store/compatibility.js +12 -0
  274. package/dist/store/compatibility.js.map +1 -1
  275. package/dist/store/migrations.d.ts +3 -3
  276. package/dist/store/migrations.js +3 -3
  277. package/dist/store/sqlite/clients.d.ts +6 -0
  278. package/dist/store/sqlite/clients.d.ts.map +1 -1
  279. package/dist/store/sqlite/clients.js +6 -4
  280. package/dist/store/sqlite/clients.js.map +1 -1
  281. package/dist/store/sqlite/manifest.d.ts +4 -0
  282. package/dist/store/sqlite/manifest.d.ts.map +1 -1
  283. package/dist/store/sqlite/manifest.js.map +1 -1
  284. package/package.json +1 -1
  285. package/skills/link-conversations/SKILL.md +1 -1
  286. package/src/cli/app-doctor-command.ts +41 -42
  287. package/src/cli/app-mcp-command.ts +55 -52
  288. package/src/cli/built-commands.ts +32 -0
  289. package/src/cli/commands-command.ts +3 -2
  290. package/src/cli/complete-command.ts +53 -48
  291. package/src/cli/config-command.ts +180 -177
  292. package/src/cli/context.ts +44 -2
  293. package/src/cli/dry-run-guard.ts +11 -23
  294. package/src/cli/first-run.ts +1 -1
  295. package/src/cli/guide.ts +3 -2
  296. package/src/cli/messenger/archive-commands.ts +3 -2
  297. package/src/cli/messenger/complete-command.ts +30 -30
  298. package/src/cli/messenger/doctor-command.ts +3 -2
  299. package/src/cli/messenger/flood-command.ts +3 -2
  300. package/src/cli/messenger/mcp-command.ts +3 -2
  301. package/src/cli/messenger/metadata-command.ts +3 -2
  302. package/src/cli/messenger/models-command.ts +3 -2
  303. package/src/cli/messenger/server-command.ts +3 -2
  304. package/src/cli/messenger/session-commands.ts +3 -2
  305. package/src/cli/messenger/store-maintenance-command.ts +18 -12
  306. package/src/cli/model-catalogue-command.ts +3 -2
  307. package/src/cli/oauth-session.ts +3 -2
  308. package/src/cli/runs/command.ts +3 -2
  309. package/src/cli/schedule/schedule-command.ts +412 -410
  310. package/src/cli/setup-command.ts +3 -2
  311. package/src/cli/skill-command.ts +3 -2
  312. package/src/cli/store-info.ts +21 -16
  313. package/src/cli/token-session.ts +3 -2
  314. package/src/cli/upgrade-command.ts +59 -62
  315. package/src/cli/upkeep.ts +15 -0
  316. package/src/entities/attachment.ts +44 -30
  317. package/src/entities/chat.ts +9 -10
  318. package/src/entities/contact.ts +20 -21
  319. package/src/entities/deal.ts +66 -53
  320. package/src/entities/document.ts +3 -5
  321. package/src/entities/fields.ts +11 -2
  322. package/src/entities/hit.ts +52 -37
  323. package/src/entities/index.ts +2 -3
  324. package/src/entities/message.ts +101 -80
  325. package/src/entities/task.ts +37 -38
  326. package/src/mcp/agent.ts +51 -1
  327. package/src/mcp/app-server.ts +8 -5
  328. package/src/mcp/bot/instructions.ts +1 -1
  329. package/src/mcp/index.ts +4 -0
  330. package/src/mcp/instructions.ts +4 -4
  331. package/src/mcp/lean.ts +8 -0
  332. package/src/mcp/server.ts +6 -2
  333. package/src/mcp/surface.ts +436 -64
  334. package/src/mcp/tool.ts +27 -4
  335. package/src/output-detail.ts +61 -0
  336. package/src/services/package-upgrade.ts +3 -1
  337. package/src/store/compatibility.ts +12 -0
  338. package/src/store/migrations.ts +3 -3
  339. package/src/store/sqlite/clients.ts +17 -6
  340. package/src/store/sqlite/manifest.ts +4 -0
  341. package/dist/bundle/install-IPXFNLYZ-BSWiztYR.js +0 -5
  342. package/dist/bundle/mdast-util-to-markdown-UGCOLDXA-7D6EJn9r.js +0 -12
  343. package/dist/bundle/meeting-semantic-I7AZQTEI-BgZ3ZzQB.js +0 -5
  344. package/dist/bundle/notes-search-2Q3C65PA-CWKHboCy.js +0 -5
  345. package/dist/bundle/oauth-TVUNW3GM-BqlyhUfp.js +0 -7
  346. package/dist/bundle/serve-7KRXCBBZ-BO9BKhWL.js +0 -8
  347. package/dist/bundle/server-PIT6UZRZ-C6I-VrDd.js +0 -11
  348. package/dist/bundle/server-ZL4FMEHH-DP1oYgCn.js +0 -12
  349. package/dist/bundle/state-3CFS2SAC-xptBCfut.js +0 -5
  350. package/dist/bundle/store-ASWYHJ4Q-C7EFfvzB.js +0 -5
  351. package/dist/bundle/surface-DDH4HGT3-CBZnEqH_.js +0 -8
@@ -55,6 +55,7 @@ import { listQuery, typedQuery, withQuery } from "../list-query.js"
55
55
  import { SCHEDULE_HARNESSES_QUERY, SCHEDULES_QUERY, scheduleFilter } from "../messenger/list-result-queries.js"
56
56
  import type { DeclaredSetting } from "../setting-defaults.js"
57
57
  import { lineOf } from "../steps.js"
58
+ import { upkeepCommand } from "../upkeep.js"
58
59
  import { agentStart, guardSchedule, sealOf } from "./agent-start.js"
59
60
  import {
60
61
  AGENT_MODELS,
@@ -591,439 +592,440 @@ export const runScheduleNow = async (
591
592
  * (macOS) or Task Scheduler (Windows). Every timer runs `schedule exec <file>`; the schedule file holds
592
593
  * the rest, so what runs and with which variables is the same on all three.
593
594
  */
594
- export const scheduleCommandFor = ({
595
- app,
596
- context: contextOf,
597
- newMail,
598
- agentInput,
599
- limits: configured,
600
- agentRuns = [],
601
- }: ScheduleHost): Command => {
602
- const agentClis = [app, ...agentRuns]
603
- const messenger = app.messenger !== false
604
- const commandExample = messenger ? "messages list <chat> --limit 50" : "doctor"
605
- const command = new Command("schedule").description(
606
- `run a ${app.command} command or an agent later or on a timer (systemd, launchd, Task Scheduler); an agent cannot send`,
607
- )
595
+ export const scheduleCommandFor = upkeepCommand(
596
+ ({ app, context: contextOf, newMail, agentInput, limits: configured, agentRuns = [] }: ScheduleHost): Command => {
597
+ const agentClis = [app, ...agentRuns]
598
+ const messenger = app.messenger !== false
599
+ const commandExample = messenger ? "messages list <chat> --limit 50" : "doctor"
600
+ const command = new Command("schedule").description(
601
+ `run a ${app.command} command or an agent later or on a timer (systemd, launchd, Task Scheduler); an agent cannot send`,
602
+ )
608
603
 
609
- const prepare = (self: Command, resolving: { needsProfile?: boolean } = {}) => {
610
- const context = contextOf(self, resolving)
611
- const system = environmentOf<BaseEnvironment & { system?: ServerSystem }>(self).system ?? thisMachine()
612
- const site: ScheduleSite = {
613
- app,
614
- system,
615
- env: context.env,
616
- profile: context.profile,
617
- agentRuns,
618
- limits: configured?.(self) ?? {},
619
- }
620
- const state = scheduleState(site)
621
- const say = (value: object, lines: string[]) => renderAnswer(self, context, itemOf(value), () => lines.join("\n"))
622
- const timer = () => timerFor(app, system, context.env)
623
- const environment = () => scheduleEnvironment(site)
624
- const save = async (schedule: Schedule) => {
625
- const { file, timer: where, replaced } = await writeSchedule(site, schedule)
626
- say(scheduleAnswer(schedule, { file, timer: where, replaced }), [
627
- `${replaced ? "Replaced" : "Added"} ${schedule.name}: ${describeWhen(schedule.when)}${schedule.paused ? ", paused" : ""}.`,
628
- `It runs: ${schedule.kind === "agent" ? shown(schedule.argv) : `${app.command} ${shown(schedule.argv)}`}`,
629
- `Output: ${join(dirname(file), "runs")} · now: ${lineOf(self, `schedule run ${schedule.name}`)} · stop: ${lineOf(self, `schedule remove ${schedule.name}`)}`,
630
- ])
604
+ const prepare = (self: Command, resolving: { needsProfile?: boolean } = {}) => {
605
+ const context = contextOf(self, resolving)
606
+ const system = environmentOf<BaseEnvironment & { system?: ServerSystem }>(self).system ?? thisMachine()
607
+ const site: ScheduleSite = {
608
+ app,
609
+ system,
610
+ env: context.env,
611
+ profile: context.profile,
612
+ agentRuns,
613
+ limits: configured?.(self) ?? {},
614
+ }
615
+ const state = scheduleState(site)
616
+ const say = (value: object, lines: string[]) => renderAnswer(self, context, itemOf(value), () => lines.join("\n"))
617
+ const timer = () => timerFor(app, system, context.env)
618
+ const environment = () => scheduleEnvironment(site)
619
+ const save = async (schedule: Schedule) => {
620
+ const { file, timer: where, replaced } = await writeSchedule(site, schedule)
621
+ say(scheduleAnswer(schedule, { file, timer: where, replaced }), [
622
+ `${replaced ? "Replaced" : "Added"} ${schedule.name}: ${describeWhen(schedule.when)}${schedule.paused ? ", paused" : ""}.`,
623
+ `It runs: ${schedule.kind === "agent" ? shown(schedule.argv) : `${app.command} ${shown(schedule.argv)}`}`,
624
+ `Output: ${join(dirname(file), "runs")} · now: ${lineOf(self, `schedule run ${schedule.name}`)} · stop: ${lineOf(self, `schedule remove ${schedule.name}`)}`,
625
+ ])
626
+ }
627
+ return { context, system, state, say, timer, environment, save, site }
631
628
  }
632
- return { context, system, state, say, timer, environment, save, site }
633
- }
634
- /**
635
- * Why a run does not start now, or nothing: an agent whose runs reached the day's cost cap waits for tomorrow, and
636
- * one gated on mail waits for mail past its holder's mark — on its timer, until enough of it waits.
637
- */
638
- /** A schedule's own limits, else the config file's, else the defaults. */
639
- const limitsOf = (self: Command, schedule: Schedule) => ({
640
- ...SCHEDULE_DEFAULTS,
641
- ...given(configured?.(self) ?? {}),
642
- ...given({
643
- mailWaitMinutes: schedule.mailWaitMinutes,
644
- mailBatch: schedule.mailBatch,
645
- maxCostPerDay: schedule.maxCostPerDay,
646
- }),
647
- })
648
- /** An agent that reports no cost answers null for what it spent and for its caps: unknown, not $0 and not capped. */
649
- const agentCostsOf = (self: Command, state: string, schedule: Schedule) => {
650
- const harness =
651
- schedule.agent && isHarness(schedule.agent.harness) ? schedule.agent.harness : harnessOfArgv(schedule.argv)
652
- const costed = harness !== null && reportsCost(harness)
653
- return {
654
- harness,
655
- reportsCost: costed,
656
- spentTodayUsd: costed ? spentToday(scheduleFile(state, schedule.name)) : null,
657
- maxCostUsd: costed ? runCapOf(schedule.argv) : null,
658
- maxCostPerDayUsd: costed ? limitsOf(self, schedule).maxCostPerDay : null,
629
+ /**
630
+ * Why a run does not start now, or nothing: an agent whose runs reached the day's cost cap waits for tomorrow, and
631
+ * one gated on mail waits for mail past its holder's mark — on its timer, until enough of it waits.
632
+ */
633
+ /** A schedule's own limits, else the config file's, else the defaults. */
634
+ const limitsOf = (self: Command, schedule: Schedule) => ({
635
+ ...SCHEDULE_DEFAULTS,
636
+ ...given(configured?.(self) ?? {}),
637
+ ...given({
638
+ mailWaitMinutes: schedule.mailWaitMinutes,
639
+ mailBatch: schedule.mailBatch,
640
+ maxCostPerDay: schedule.maxCostPerDay,
641
+ }),
642
+ })
643
+ /** An agent that reports no cost answers null for what it spent and for its caps: unknown, not $0 and not capped. */
644
+ const agentCostsOf = (self: Command, state: string, schedule: Schedule) => {
645
+ const harness =
646
+ schedule.agent && isHarness(schedule.agent.harness) ? schedule.agent.harness : harnessOfArgv(schedule.argv)
647
+ const costed = harness !== null && reportsCost(harness)
648
+ return {
649
+ harness,
650
+ reportsCost: costed,
651
+ spentTodayUsd: costed ? spentToday(scheduleFile(state, schedule.name)) : null,
652
+ maxCostUsd: costed ? runCapOf(schedule.argv) : null,
653
+ maxCostPerDayUsd: costed ? limitsOf(self, schedule).maxCostPerDay : null,
654
+ }
659
655
  }
660
- }
661
- const waits = async (
662
- self: Command,
663
- file: string,
664
- { timed }: { timed: boolean },
665
- ): Promise<{ why: string; reason: SkipReason } | undefined> => {
666
- if (!existsSync(file)) return undefined
667
- const schedule = readSchedule(file)
668
- const { mailWaitMinutes, mailBatch, maxCostPerDay } = limitsOf(self, schedule)
669
- const capped = dayCapReached(file, schedule, maxCostPerDay)
670
- if (capped) return capped
671
- const holder = schedule.onNewMail
672
- if (holder === undefined || !newMail) return undefined
673
- const waiting = await newMail(self, holder)
674
- if (waiting.unmarked) return undefined
675
- if (waiting.emails === 0) {
676
- const why = `no mail stored past ${holder}'s mark`
677
- recordSkip(file, why, SKIP_REASONS.mailNone)
678
- return { why, reason: SKIP_REASONS.mailNone }
656
+ const waits = async (
657
+ self: Command,
658
+ file: string,
659
+ { timed }: { timed: boolean },
660
+ ): Promise<{ why: string; reason: SkipReason } | undefined> => {
661
+ if (!existsSync(file)) return undefined
662
+ const schedule = readSchedule(file)
663
+ const { mailWaitMinutes, mailBatch, maxCostPerDay } = limitsOf(self, schedule)
664
+ const capped = dayCapReached(file, schedule, maxCostPerDay)
665
+ if (capped) return capped
666
+ const holder = schedule.onNewMail
667
+ if (holder === undefined || !newMail) return undefined
668
+ const waiting = await newMail(self, holder)
669
+ if (waiting.unmarked) return undefined
670
+ if (waiting.emails === 0) {
671
+ const why = `no mail stored past ${holder}'s mark`
672
+ recordSkip(file, why, SKIP_REASONS.mailNone)
673
+ return { why, reason: SKIP_REASONS.mailNone }
674
+ }
675
+ const waited = waiting.oldestStoredAt === null ? 0 : Date.now() - waiting.oldestStoredAt
676
+ if (!timed || waiting.emails >= mailBatch || waited >= mailWaitMinutes * 60_000) return undefined
677
+ const why =
678
+ `${waiting.emails} email(s) wait past ${holder}'s mark; it starts at ${mailBatch}, ` +
679
+ `or once the oldest has waited ${mailWaitMinutes}m`
680
+ recordSkip(file, why, SKIP_REASONS.mailBelowThreshold)
681
+ return { why, reason: SKIP_REASONS.mailBelowThreshold }
679
682
  }
680
- const waited = waiting.oldestStoredAt === null ? 0 : Date.now() - waiting.oldestStoredAt
681
- if (!timed || waiting.emails >= mailBatch || waited >= mailWaitMinutes * 60_000) return undefined
682
- const why =
683
- `${waiting.emails} email(s) wait past ${holder}'s mark; it starts at ${mailBatch}, ` +
684
- `or once the oldest has waited ${mailWaitMinutes}m`
685
- recordSkip(file, why, SKIP_REASONS.mailBelowThreshold)
686
- return { why, reason: SKIP_REASONS.mailBelowThreshold }
687
- }
688
683
 
689
- withWhen(
690
- grantsAuthority(
691
- annotate(command.command("command"), {
692
- literal_after_dashes: true,
693
- effects: LOCAL_WRITE,
694
- examples: [
695
- `${app.command} personal schedule command health --every 1h -- doctor`,
696
- `${app.command} personal schedule command morning-check --at 08:00 -- doctor`,
697
- ],
698
- }),
699
- )
700
- .description(
701
- `run ${app.command} <args…> on a timer — reads save what they read, so this is how ${messenger ? "a chat's history fills the store" : "the store stays current"}`,
684
+ withWhen(
685
+ grantsAuthority(
686
+ annotate(command.command("command"), {
687
+ literal_after_dashes: true,
688
+ effects: LOCAL_WRITE,
689
+ examples: [
690
+ `${app.command} personal schedule command health --every 1h -- doctor`,
691
+ `${app.command} personal schedule command morning-check --at 08:00 -- doctor`,
692
+ ],
693
+ }),
702
694
  )
703
- .argument("<name>", "lowercase letters, digits and dashes")
704
- .argument("<args...>", `the ${app.command} command after its name, e.g. -- ${commandExample}`),
705
- ).action(async function (this: Command, name: string, args: string[]) {
706
- const { environment, save } = prepare(this)
707
- if (args[0] === "schedule") throw new CliError("validation_error", "a schedule cannot run schedule")
708
- await save({
709
- name: scheduleName(name),
710
- kind: "command",
711
- argv: args,
712
- when: whenOf(this.opts<WhenOptions>(), COMMAND_MINIMUM_MINUTES),
713
- environment: environment(),
714
- createdAt: new Date().toISOString(),
715
- ...deliveryOf(this.opts<WhenOptions>()),
695
+ .description(
696
+ `run ${app.command} <args…> on a timer — reads save what they read, so this is how ${messenger ? "a chat's history fills the store" : "the store stays current"}`,
697
+ )
698
+ .argument("<name>", "lowercase letters, digits and dashes")
699
+ .argument("<args...>", `the ${app.command} command after its name, e.g. -- ${commandExample}`),
700
+ ).action(async function (this: Command, name: string, args: string[]) {
701
+ const { environment, save } = prepare(this)
702
+ if (args[0] === "schedule") throw new CliError("validation_error", "a schedule cannot run schedule")
703
+ await save({
704
+ name: scheduleName(name),
705
+ kind: "command",
706
+ argv: args,
707
+ when: whenOf(this.opts<WhenOptions>(), COMMAND_MINIMUM_MINUTES),
708
+ environment: environment(),
709
+ createdAt: new Date().toISOString(),
710
+ ...deliveryOf(this.opts<WhenOptions>()),
711
+ })
716
712
  })
717
- })
718
713
 
719
- withWhen(
720
- grantsAuthority(
721
- annotate(command.command("agent"), {
722
- effects: LOCAL_WRITE,
723
- examples: [
724
- `${app.command} personal schedule agent review claude "review what came in overnight and draft replies" --at 08:30`,
725
- `${app.command} personal schedule agent triage gemini "list what needs an answer today" --every 2h`,
726
- `${app.command} personal schedule agent weekly claude "review the week's open threads" --at 09:00 --model opus`,
727
- ],
728
- }),
729
- )
730
- .description(
731
- `start an agent (${HARNESSES.join(", ")}) with a prompt on a timer; it runs with ${agentClis.map((one) => `${one.envPrefix}_READ_ONLY=1`).join(" and ")}, so it reads and drafts and cannot send, and its own limits hold it to these CLIs' commands; an agent with no such limit is refused (\`schedule agents list\` says which) — its answer is kept and you are notified`,
732
- )
733
- .argument("<name>", "lowercase letters, digits and dashes")
734
- .addArgument(new Argument("<harness>", "the agent to start").choices(HARNESSES))
735
- .argument("<prompt>", `what to do, e.g. "${promptExample(app)}"`)
736
- .option(
737
- "--model <model>",
738
- `the model it runs on: an alias such as sonnet, or a model id; "" for the agent's own default (default sonnet for claude, the agent's own for the others, or the config file's)`,
714
+ withWhen(
715
+ grantsAuthority(
716
+ annotate(command.command("agent"), {
717
+ effects: LOCAL_WRITE,
718
+ examples: [
719
+ `${app.command} personal schedule agent review claude "review what came in overnight and draft replies" --at 08:30`,
720
+ `${app.command} personal schedule agent triage gemini "list what needs an answer today" --every 2h`,
721
+ `${app.command} personal schedule agent weekly claude "review the week's open threads" --at 09:00 --model opus`,
722
+ ],
723
+ }),
739
724
  )
740
- .addOption(
741
- new Option("--max-cost <usd>", "claude only: stop a run that costs more than this, in US dollars").argParser(
742
- Number,
725
+ .description(
726
+ `start an agent (${HARNESSES.join(", ")}) with a prompt on a timer; it runs with ${agentClis.map((one) => `${one.envPrefix}_READ_ONLY=1`).join(" and ")}, so it reads and drafts and cannot send, and its own limits hold it to these CLIs' commands; an agent with no such limit is refused (\`schedule agents list\` says which) — its answer is kept and you are notified`,
727
+ )
728
+ .argument("<name>", "lowercase letters, digits and dashes")
729
+ .addArgument(new Argument("<harness>", "the agent to start").choices(HARNESSES))
730
+ .argument("<prompt>", `what to do, e.g. "${promptExample(app)}"`)
731
+ .option(
732
+ "--model <model>",
733
+ `the model it runs on: an alias such as sonnet, or a model id; "" for the agent's own default (default sonnet for claude, the agent's own for the others, or the config file's)`,
734
+ )
735
+ .addOption(
736
+ new Option("--max-cost <usd>", "claude only: stop a run that costs more than this, in US dollars").argParser(
737
+ Number,
738
+ ),
739
+ )
740
+ .option(
741
+ "--allow-dangerous",
742
+ "start an agent its own limits cannot hold to these CLIs' commands, where `schedule agents list` says allowed_with_ack: it may then run any program inside its sandbox",
743
+ )
744
+ .addOption(
745
+ new Option(
746
+ "--max-cost-per-day <usd>",
747
+ `${COSTED} only, as the others report no cost: start no run for the rest of the day once its runs cost this much, in US dollars; 0 for no cap (default ${SCHEDULE_DEFAULTS.maxCostPerDay}, or the config file's)`,
748
+ ).argParser(Number),
743
749
  ),
750
+ ).action(async function (this: Command, name: string, harness: Harness, prompt: string) {
751
+ const { site, save } = prepare(this)
752
+ const options = this.opts<
753
+ WhenOptions & {
754
+ model?: string
755
+ maxCost?: number
756
+ maxCostPerDay?: number
757
+ onNewMail?: string
758
+ mailWait?: string
759
+ mailBatch?: string
760
+ allowDangerous?: boolean
761
+ }
762
+ >()
763
+ if (options.onNewMail !== undefined && !HOLDER.test(options.onNewMail))
764
+ throw new CliError("validation_error", `--on-new-mail takes a holder: lower-case letters, digits and dashes`)
765
+ if ((options.mailWait !== undefined || options.mailBatch !== undefined) && options.onNewMail === undefined)
766
+ throw new CliError("validation_error", "--mail-wait and --mail-batch shape a run gated by --on-new-mail")
767
+ if (
768
+ options.maxCostPerDay !== undefined &&
769
+ !(Number.isFinite(options.maxCostPerDay) && options.maxCostPerDay >= 0)
744
770
  )
745
- .option(
746
- "--allow-dangerous",
747
- "start an agent its own limits cannot hold to these CLIs' commands, where `schedule agents list` says allowed_with_ack: it may then run any program inside its sandbox",
748
- )
749
- .addOption(
750
- new Option(
751
- "--max-cost-per-day <usd>",
752
- `${COSTED} only, as the others report no cost: start no run for the rest of the day once its runs cost this much, in US dollars; 0 for no cap (default ${SCHEDULE_DEFAULTS.maxCostPerDay}, or the config file's)`,
753
- ).argParser(Number),
754
- ),
755
- ).action(async function (this: Command, name: string, harness: Harness, prompt: string) {
756
- const { site, save } = prepare(this)
757
- const options = this.opts<
758
- WhenOptions & {
759
- model?: string
760
- maxCost?: number
761
- maxCostPerDay?: number
762
- onNewMail?: string
763
- mailWait?: string
764
- mailBatch?: string
765
- allowDangerous?: boolean
766
- }
767
- >()
768
- if (options.onNewMail !== undefined && !HOLDER.test(options.onNewMail))
769
- throw new CliError("validation_error", `--on-new-mail takes a holder: lower-case letters, digits and dashes`)
770
- if ((options.mailWait !== undefined || options.mailBatch !== undefined) && options.onNewMail === undefined)
771
- throw new CliError("validation_error", "--mail-wait and --mail-batch shape a run gated by --on-new-mail")
772
- if (options.maxCostPerDay !== undefined && !(Number.isFinite(options.maxCostPerDay) && options.maxCostPerDay >= 0))
773
- throw new CliError("validation_error", "--max-cost-per-day takes US dollars, 0 or more")
774
- if (!reportsCost(harness) && (options.maxCost || options.maxCostPerDay))
775
- throw new CliError(
776
- "validation_error",
777
- `${harness} reports no cost, so --max-cost and --max-cost-per-day cannot stop it; leave them out (${COSTED} reports one)`,
778
- { reason: "agent.cost-unknown" },
771
+ throw new CliError("validation_error", "--max-cost-per-day takes US dollars, 0 or more")
772
+ if (!reportsCost(harness) && (options.maxCost || options.maxCostPerDay))
773
+ throw new CliError(
774
+ "validation_error",
775
+ `${harness} reports no cost, so --max-cost and --max-cost-per-day cannot stop it; leave them out (${COSTED} reports one)`,
776
+ { reason: "agent.cost-unknown" },
777
+ )
778
+ const mailBatch = options.mailBatch === undefined ? undefined : Number(options.mailBatch)
779
+ if (mailBatch !== undefined && !(Number.isSafeInteger(mailBatch) && mailBatch >= 1))
780
+ throw new CliError("validation_error", "--mail-batch takes a count of emails, 1 or more")
781
+ const mailWaitMinutes =
782
+ options.mailWait === undefined ? undefined : Math.ceil(parseDuration(options.mailWait, "--mail-wait") / 60_000)
783
+ await save(
784
+ agentSchedule(site, {
785
+ name,
786
+ harness,
787
+ prompt,
788
+ when: whenOf(options, options.onNewMail ? GATED_AGENT_MINIMUM_MINUTES : AGENT_MINIMUM_MINUTES),
789
+ ...(options.model === undefined ? {} : { model: options.model }),
790
+ ...(options.maxCost ? { maxCost: options.maxCost } : {}),
791
+ ...(options.maxCostPerDay === undefined ? {} : { maxCostPerDay: options.maxCostPerDay }),
792
+ ...(options.allowDangerous ? { allowDangerous: true } : {}),
793
+ ...(options.onNewMail ? { onNewMail: options.onNewMail } : {}),
794
+ ...(mailWaitMinutes === undefined ? {} : { mailWaitMinutes }),
795
+ ...(mailBatch === undefined ? {} : { mailBatch }),
796
+ ...deliveryOf(options),
797
+ }),
779
798
  )
780
- const mailBatch = options.mailBatch === undefined ? undefined : Number(options.mailBatch)
781
- if (mailBatch !== undefined && !(Number.isSafeInteger(mailBatch) && mailBatch >= 1))
782
- throw new CliError("validation_error", "--mail-batch takes a count of emails, 1 or more")
783
- const mailWaitMinutes =
784
- options.mailWait === undefined ? undefined : Math.ceil(parseDuration(options.mailWait, "--mail-wait") / 60_000)
785
- await save(
786
- agentSchedule(site, {
787
- name,
788
- harness,
789
- prompt,
790
- when: whenOf(options, options.onNewMail ? GATED_AGENT_MINIMUM_MINUTES : AGENT_MINIMUM_MINUTES),
791
- ...(options.model === undefined ? {} : { model: options.model }),
792
- ...(options.maxCost ? { maxCost: options.maxCost } : {}),
793
- ...(options.maxCostPerDay === undefined ? {} : { maxCostPerDay: options.maxCostPerDay }),
794
- ...(options.allowDangerous ? { allowDangerous: true } : {}),
795
- ...(options.onNewMail ? { onNewMail: options.onNewMail } : {}),
796
- ...(mailWaitMinutes === undefined ? {} : { mailWaitMinutes }),
797
- ...(mailBatch === undefined ? {} : { mailBatch }),
798
- ...deliveryOf(options),
799
+ })
800
+ if (newMail)
801
+ command.commands
802
+ .find((one) => one.name() === "agent")
803
+ ?.option(
804
+ "--on-new-mail <holder>",
805
+ `run only when mail is stored past this holder's mark — after a sync brought new mail; may check every ${GATED_AGENT_MINIMUM_MINUTES}m`,
806
+ )
807
+ .option(
808
+ "--mail-wait <duration>",
809
+ `with --on-new-mail: start once the oldest waiting email has waited this long (default ${SCHEDULE_DEFAULTS.mailWaitMinutes}m, or the config file's)`,
810
+ )
811
+ .option(
812
+ "--mail-batch <n>",
813
+ `with --on-new-mail: or once this many emails wait (default ${SCHEDULE_DEFAULTS.mailBatch}, or the config file's)`,
814
+ )
815
+
816
+ withQuery(
817
+ annotate(command.command("list"), {
818
+ effects: LOCAL_READ,
819
+ examples: [`${app.command} personal schedule list`, `${app.command} personal schedule list kind:agent`],
799
820
  }),
821
+ SCHEDULES_QUERY,
800
822
  )
801
- })
802
- if (newMail)
803
- command.commands
804
- .find((one) => one.name() === "agent")
805
- ?.option(
806
- "--on-new-mail <holder>",
807
- `run only when mail is stored past this holder's mark — after a sync brought new mail; may check every ${GATED_AGENT_MINIMUM_MINUTES}m`,
808
- )
809
- .option(
810
- "--mail-wait <duration>",
811
- `with --on-new-mail: start once the oldest waiting email has waited this long (default ${SCHEDULE_DEFAULTS.mailWaitMinutes}m, or the config file's)`,
812
- )
813
- .option(
814
- "--mail-batch <n>",
815
- `with --on-new-mail: or once this many emails wait (default ${SCHEDULE_DEFAULTS.mailBatch}, or the config file's)`,
816
- )
817
-
818
- withQuery(
819
- annotate(command.command("list"), {
820
- effects: LOCAL_READ,
821
- examples: [`${app.command} personal schedule list`, `${app.command} personal schedule list kind:agent`],
822
- }),
823
- SCHEDULES_QUERY,
824
- )
825
- .description("the schedules, when they run and how their last run went")
826
- .action(function (this: Command, words: string[]) {
827
- const filter = scheduleFilter(words)
828
- const { context, state } = prepare(this)
829
- const rows = listSchedules(state, filter).map((schedule) => ({
830
- name: schedule.name,
831
- kind: schedule.kind,
832
- when: describeWhen(schedule.when),
833
- ...(schedule.paused ? { paused: true } : {}),
834
- notify: notifyOf(schedule),
835
- ...(schedule.to?.length ? { deliverTo: schedule.to } : {}),
836
- last: lastRun(scheduleFile(state, schedule.name)) ?? null,
837
- ...(schedule.kind === "agent" ? agentCostsOf(this, state, schedule) : {}),
838
- }))
839
- const answer = listOf("schedule list", {
840
- items: rows.map((row) => snakeKeys(row)),
841
- limit: Math.max(1, rows.length),
842
- has_more: false,
843
- })
844
- renderAnswer(this, context, answer, () => {
845
- if (rows.length === 0) {
846
- context.renderer.note(`no schedules — \`${lineOf(this, "schedule command|agent")}\` adds one`)
847
- return ""
848
- }
849
- return rows
850
- .map(({ name, kind, harness, when, paused, notify, deliverTo, last, spentTodayUsd, maxCostPerDayUsd }) =>
851
- [
852
- name,
853
- kind === "agent" ? `agent ${harness ?? "unknown"}` : kind,
854
- paused ? `${when}, paused` : when,
855
- `notify ${notify}`,
856
- ...(deliverTo ? [`to ${deliverTo.join(", ")}`] : []),
857
- last
858
- ? `last ${last.at.slice(0, 16).replace("T", " ")} exit ${last.exitCode}` +
859
- (last.failures
860
- ? ` — failing since ${(last.failingSince ?? last.at).slice(0, 16).replace("T", " ")}, ` +
861
- `${last.failures} in a row${last.reason ? `: ${last.reason}` : ""} — ${last.output}`
862
- : "")
863
- : "not run yet",
864
- ...(spentTodayUsd
865
- ? [`today ${usd(spentTodayUsd)}${maxCostPerDayUsd ? ` of ${usd(maxCostPerDayUsd)}` : ""}`]
866
- : []),
867
- ...(last?.skipped
868
- ? [`skipped ${last.skipped.at.slice(0, 16).replace("T", " ")}: ${last.skipped.why}`]
869
- : []),
870
- ...(last?.deliveries ?? [])
871
- .filter((one) => !one.ok)
872
- .map((one) => `not delivered to ${one.to}: ${one.reason}${one.error ? ` (${one.error})` : ""}`),
873
- ].join(" "),
874
- )
875
- .join("\n")
823
+ .description("the schedules, when they run and how their last run went")
824
+ .action(function (this: Command, words: string[]) {
825
+ const filter = scheduleFilter(words)
826
+ const { context, state } = prepare(this)
827
+ const rows = listSchedules(state, filter).map((schedule) => ({
828
+ name: schedule.name,
829
+ kind: schedule.kind,
830
+ when: describeWhen(schedule.when),
831
+ ...(schedule.paused ? { paused: true } : {}),
832
+ notify: notifyOf(schedule),
833
+ ...(schedule.to?.length ? { deliverTo: schedule.to } : {}),
834
+ last: lastRun(scheduleFile(state, schedule.name)) ?? null,
835
+ ...(schedule.kind === "agent" ? agentCostsOf(this, state, schedule) : {}),
836
+ }))
837
+ const answer = listOf("schedule list", {
838
+ items: rows.map((row) => snakeKeys(row)),
839
+ limit: Math.max(1, rows.length),
840
+ has_more: false,
841
+ })
842
+ renderAnswer(this, context, answer, () => {
843
+ if (rows.length === 0) {
844
+ context.renderer.note(`no schedules — \`${lineOf(this, "schedule command|agent")}\` adds one`)
845
+ return ""
846
+ }
847
+ return rows
848
+ .map(({ name, kind, harness, when, paused, notify, deliverTo, last, spentTodayUsd, maxCostPerDayUsd }) =>
849
+ [
850
+ name,
851
+ kind === "agent" ? `agent ${harness ?? "unknown"}` : kind,
852
+ paused ? `${when}, paused` : when,
853
+ `notify ${notify}`,
854
+ ...(deliverTo ? [`to ${deliverTo.join(", ")}`] : []),
855
+ last
856
+ ? `last ${last.at.slice(0, 16).replace("T", " ")} exit ${last.exitCode}` +
857
+ (last.failures
858
+ ? ` — failing since ${(last.failingSince ?? last.at).slice(0, 16).replace("T", " ")}, ` +
859
+ `${last.failures} in a row${last.reason ? `: ${last.reason}` : ""} — ${last.output}`
860
+ : "")
861
+ : "not run yet",
862
+ ...(spentTodayUsd
863
+ ? [`today ${usd(spentTodayUsd)}${maxCostPerDayUsd ? ` of ${usd(maxCostPerDayUsd)}` : ""}`]
864
+ : []),
865
+ ...(last?.skipped
866
+ ? [`skipped ${last.skipped.at.slice(0, 16).replace("T", " ")}: ${last.skipped.why}`]
867
+ : []),
868
+ ...(last?.deliveries ?? [])
869
+ .filter((one) => !one.ok)
870
+ .map((one) => `not delivered to ${one.to}: ${one.reason}${one.error ? ` (${one.error})` : ""}`),
871
+ ].join(" "),
872
+ )
873
+ .join("\n")
874
+ })
876
875
  })
877
- })
878
876
 
879
- withQuery(
880
- annotate(command.command("agents").description("the coding agents an agent schedule may start").command("list"), {
881
- effects: LOCAL_READ,
882
- examples: [`${app.command} schedule agents list`, `${app.command} schedule agents list --json`],
883
- }),
884
- SCHEDULE_HARNESSES_QUERY,
885
- )
886
- .description("the agents a schedule may start, and which are on PATH here")
887
- .action(function (this: Command, words: string[]) {
888
- listQuery(typedQuery(words), SCHEDULE_HARNESSES_QUERY, "schedule agents list")
889
- const { context, system } = prepare(this, { needsProfile: false })
890
- const rows = harnessesOn(context.env, system.platform)
891
- const answer = listOf("schedule agents list", {
892
- items: rows.map((row) => snakeKeys(row)),
893
- limit: rows.length,
894
- has_more: false,
877
+ withQuery(
878
+ annotate(command.command("agents").description("the coding agents an agent schedule may start").command("list"), {
879
+ effects: LOCAL_READ,
880
+ examples: [`${app.command} schedule agents list`, `${app.command} schedule agents list --json`],
881
+ }),
882
+ SCHEDULE_HARNESSES_QUERY,
883
+ )
884
+ .description("the agents a schedule may start, and which are on PATH here")
885
+ .action(function (this: Command, words: string[]) {
886
+ listQuery(typedQuery(words), SCHEDULE_HARNESSES_QUERY, "schedule agents list")
887
+ const { context, system } = prepare(this, { needsProfile: false })
888
+ const rows = harnessesOn(context.env, system.platform)
889
+ const answer = listOf("schedule agents list", {
890
+ items: rows.map((row) => snakeKeys(row)),
891
+ limit: rows.length,
892
+ has_more: false,
893
+ })
894
+ renderAnswer(this, context, answer, () =>
895
+ rows
896
+ .map(({ id, name, installed, path, reportsCost }) =>
897
+ [id, name, installed ? path : "not on PATH", reportsCost ? "reports cost" : "cost unknown"].join(" "),
898
+ )
899
+ .join("\n"),
900
+ )
895
901
  })
896
- renderAnswer(this, context, answer, () =>
897
- rows
898
- .map(({ id, name, installed, path, reportsCost }) =>
899
- [id, name, installed ? path : "not on PATH", reportsCost ? "reports cost" : "cost unknown"].join(" "),
900
- )
901
- .join("\n"),
902
- )
902
+
903
+ annotate(command.command("run"), {
904
+ effects: REMOTE_WRITE,
905
+ examples: [`${app.command} personal schedule run health`],
903
906
  })
907
+ .description("run a schedule now, as its timer would, and wait for it; a paused one runs too")
908
+ .argument("<name>", "the schedule's name, as `schedule list` shows it")
909
+ .option("--no-notify", "keep the result here: send it along none of its routes")
910
+ .option(
911
+ "--deliver-to <route>",
912
+ "send it along only this one of its own routes; repeat it for more",
913
+ (route: string, routes: string[] = []) => [...routes, routeText(parseRoute(route))],
914
+ )
915
+ .action(async function (this: Command, name: string, given: { notify: boolean; deliverTo?: string[] }) {
916
+ const { state, say, site } = prepare(this)
917
+ const file = scheduleFile(state, scheduleName(name))
918
+ const routes = given.notify ? given.deliverTo : []
919
+ if (!given.notify && given.deliverTo)
920
+ throw new CliError(
921
+ "validation_error",
922
+ "--no-notify sends nothing; leave out --deliver-to, or leave out --no-notify",
923
+ )
924
+ const skip = await waits(this, file, { timed: false })
925
+ if (skip !== undefined) {
926
+ return say({ name, skipped: true, why: skip.why, reason: skip.reason }, [`${name}: skipped — ${skip.why}`])
927
+ }
928
+ const last = await runScheduleNow(this, site, file, {
929
+ ...(agentInput ? { agentInput } : {}),
930
+ ...(routes ? { routes } : {}),
931
+ })
932
+ if (!("exitCode" in last)) {
933
+ const { why, reason } = last.skipped
934
+ return say({ name, skipped: true, why, reason }, [`${name}: skipped — ${why}`])
935
+ }
936
+ say(snakeKeys({ name, ...last }) as object, [`${name}: exit ${last.exitCode} — ${last.output}`])
937
+ if (last.exitCode !== 0) setExitCode(this, 1)
938
+ })
904
939
 
905
- annotate(command.command("run"), {
906
- effects: REMOTE_WRITE,
907
- examples: [`${app.command} personal schedule run health`],
908
- })
909
- .description("run a schedule now, as its timer would, and wait for it; a paused one runs too")
910
- .argument("<name>", "the schedule's name, as `schedule list` shows it")
911
- .option("--no-notify", "keep the result here: send it along none of its routes")
912
- .option(
913
- "--deliver-to <route>",
914
- "send it along only this one of its own routes; repeat it for more",
915
- (route: string, routes: string[] = []) => [...routes, routeText(parseRoute(route))],
940
+ grantsAuthority(
941
+ annotate(command.command("remove"), {
942
+ effects: LOCAL_WRITE,
943
+ examples: [`${app.command} personal schedule remove health`],
944
+ }),
916
945
  )
917
- .action(async function (this: Command, name: string, given: { notify: boolean; deliverTo?: string[] }) {
918
- const { state, say, site } = prepare(this)
919
- const file = scheduleFile(state, scheduleName(name))
920
- const routes = given.notify ? given.deliverTo : []
921
- if (!given.notify && given.deliverTo)
922
- throw new CliError(
923
- "validation_error",
924
- "--no-notify sends nothing; leave out --deliver-to, or leave out --no-notify",
925
- )
926
- const skip = await waits(this, file, { timed: false })
927
- if (skip !== undefined) {
928
- return say({ name, skipped: true, why: skip.why, reason: skip.reason }, [`${name}: skipped — ${skip.why}`])
929
- }
930
- const last = await runScheduleNow(this, site, file, {
931
- ...(agentInput ? { agentInput } : {}),
932
- ...(routes ? { routes } : {}),
946
+ .description("stop a schedule and remove its timer; its past output stays")
947
+ .argument("<name>", "the schedule's name, as `schedule list` shows it")
948
+ .action(async function (this: Command, name: string) {
949
+ const { state, say, site } = prepare(this)
950
+ if (!existsSync(scheduleFile(state, scheduleName(name))))
951
+ throw new CliError("not_found", `no schedule ${name} — \`${lineOf(this, "schedule list")}\``)
952
+ await removeSchedule(site, name)
953
+ say({ name, removed: true }, [`Removed ${name}.`])
933
954
  })
934
- if (!("exitCode" in last)) {
935
- const { why, reason } = last.skipped
936
- return say({ name, skipped: true, why, reason }, [`${name}: skipped — ${why}`])
955
+
956
+ const setPaused = (paused: boolean) =>
957
+ async function (this: Command, name: string) {
958
+ const { state, say, site } = prepare(this)
959
+ const file = scheduleFile(state, scheduleName(name))
960
+ if (!existsSync(file))
961
+ throw new CliError("not_found", `no schedule ${name} — \`${lineOf(this, "schedule list")}\``)
962
+ const { schedule, timer } = await pauseSchedule(site, name, paused)
963
+ say({ name, paused, timer }, [
964
+ paused
965
+ ? `Paused ${name}: no timer starts it; ${lineOf(this, `schedule run ${name}`)} still does.`
966
+ : `Resumed ${name}: ${describeWhen(schedule.when)}.`,
967
+ ])
937
968
  }
938
- say(snakeKeys({ name, ...last }) as object, [`${name}: exit ${last.exitCode} — ${last.output}`])
939
- if (last.exitCode !== 0) setExitCode(this, 1)
940
- })
969
+ grantsAuthority(
970
+ annotate(command.command("pause"), {
971
+ effects: LOCAL_WRITE,
972
+ examples: [`${app.command} personal schedule pause health`],
973
+ }),
974
+ )
975
+ .description("take a schedule off its timer and keep it; run runs it, resume puts it back")
976
+ .argument("<name>", "the schedule's name, as `schedule list` shows it")
977
+ .action(setPaused(true))
978
+ grantsAuthority(
979
+ annotate(command.command("resume"), {
980
+ effects: LOCAL_WRITE,
981
+ examples: [`${app.command} personal schedule resume health`],
982
+ }),
983
+ )
984
+ .description("put a paused schedule back on its timer")
985
+ .argument("<name>", "the schedule's name, as `schedule list` shows it")
986
+ .action(setPaused(false))
941
987
 
942
- grantsAuthority(
943
- annotate(command.command("remove"), {
944
- effects: LOCAL_WRITE,
945
- examples: [`${app.command} personal schedule remove health`],
946
- }),
947
- )
948
- .description("stop a schedule and remove its timer; its past output stays")
949
- .argument("<name>", "the schedule's name, as `schedule list` shows it")
950
- .action(async function (this: Command, name: string) {
951
- const { state, say, site } = prepare(this)
952
- if (!existsSync(scheduleFile(state, scheduleName(name))))
953
- throw new CliError("not_found", `no schedule ${name} — \`${lineOf(this, "schedule list")}\``)
954
- await removeSchedule(site, name)
955
- say({ name, removed: true }, [`Removed ${name}.`])
988
+ annotate(command.command("exec"), {
989
+ effects: REMOTE_WRITE,
990
+ // An agent runs a saved schedule by its name with `schedule run`, never a file it names.
991
+ mcp: false,
992
+ examples: [`${app.command} schedule exec ~/.local/share/${app.appName}/schedules/health/schedule.json`],
956
993
  })
957
-
958
- const setPaused = (paused: boolean) =>
959
- async function (this: Command, name: string) {
960
- const { state, say, site } = prepare(this)
961
- const file = scheduleFile(state, scheduleName(name))
962
- if (!existsSync(file))
963
- throw new CliError("not_found", `no schedule ${name} — \`${lineOf(this, "schedule list")}\``)
964
- const { schedule, timer } = await pauseSchedule(site, name, paused)
965
- say({ name, paused, timer }, [
966
- paused
967
- ? `Paused ${name}: no timer starts it; ${lineOf(this, `schedule run ${name}`)} still does.`
968
- : `Resumed ${name}: ${describeWhen(schedule.when)}.`,
969
- ])
970
- }
971
- grantsAuthority(
972
- annotate(command.command("pause"), {
973
- effects: LOCAL_WRITE,
974
- examples: [`${app.command} personal schedule pause health`],
975
- }),
976
- )
977
- .description("take a schedule off its timer and keep it; run runs it, resume puts it back")
978
- .argument("<name>", "the schedule's name, as `schedule list` shows it")
979
- .action(setPaused(true))
980
- grantsAuthority(
981
- annotate(command.command("resume"), {
982
- effects: LOCAL_WRITE,
983
- examples: [`${app.command} personal schedule resume health`],
984
- }),
985
- )
986
- .description("put a paused schedule back on its timer")
987
- .argument("<name>", "the schedule's name, as `schedule list` shows it")
988
- .action(setPaused(false))
989
-
990
- annotate(command.command("exec"), {
991
- effects: REMOTE_WRITE,
992
- // An agent runs a saved schedule by its name with `schedule run`, never a file it names.
993
- mcp: false,
994
- examples: [`${app.command} schedule exec ~/.local/share/${app.appName}/schedules/health/schedule.json`],
995
- })
996
- .description("what a timer runs, given the schedule's file; to run one by hand, use run")
997
- .argument("<file>", "the schedule's schedule.json in the state folder, as the timer passes it")
998
- .argument("[seal]", "the file's SHA-256 as it was saved, which the timer passes; a file that differs does not run")
999
- .action(async function (this: Command, file: string, seal: string | undefined) {
1000
- // A timer starts it with no profile named; the schedule's own environment carries the profile.
1001
- const { context, system, timer } = prepare(this, { needsProfile: false })
1002
- const folder = realPathOf(schedulesDir(scheduleState({ app, env: context.env })))
1003
- const real = realPathOf(file)
1004
- if (real === folder || !inside(real, folder))
1005
- throw new CliError("permission_error", `schedule exec runs only a schedule saved in ${folder}, not ${file}`, {
1006
- reason: "schedule.outside-folder",
1007
- })
1008
- // A timer left behind by a pause that could not remove it must not run the schedule.
1009
- if (existsSync(file) && readSchedule(file).paused) return
1010
- const checked = guardSchedule(file, { app, env: context.env, platform: system.platform, agentRuns }, { seal })
1011
- if ((await waits(this, file, { timed: true })) !== undefined) return
1012
- const last = await untilChildEnds(this, (signal) =>
1013
- runSchedule(app, system, context.env, file, {
1014
- ...(checked ? { schedule: checked } : {}),
1015
- timer: timer(),
1016
- agentRuns,
1017
- ownerLanguage: ownerLanguageOf,
1018
- reportTemplates: reportTemplatesOf,
1019
- ...(agentInput ? { agentInput } : {}),
1020
- untilUnlocked: true,
1021
- skipRepeatedInput: true,
1022
- ...(signal ? { signal } : {}),
1023
- }),
994
+ .description("what a timer runs, given the schedule's file; to run one by hand, use run")
995
+ .argument("<file>", "the schedule's schedule.json in the state folder, as the timer passes it")
996
+ .argument(
997
+ "[seal]",
998
+ "the file's SHA-256 as it was saved, which the timer passes; a file that differs does not run",
1024
999
  )
1025
- if (last.exitCode !== 0) setExitCode(this, 1)
1026
- })
1000
+ .action(async function (this: Command, file: string, seal: string | undefined) {
1001
+ // A timer starts it with no profile named; the schedule's own environment carries the profile.
1002
+ const { context, system, timer } = prepare(this, { needsProfile: false })
1003
+ const folder = realPathOf(schedulesDir(scheduleState({ app, env: context.env })))
1004
+ const real = realPathOf(file)
1005
+ if (real === folder || !inside(real, folder))
1006
+ throw new CliError("permission_error", `schedule exec runs only a schedule saved in ${folder}, not ${file}`, {
1007
+ reason: "schedule.outside-folder",
1008
+ })
1009
+ // A timer left behind by a pause that could not remove it must not run the schedule.
1010
+ if (existsSync(file) && readSchedule(file).paused) return
1011
+ const checked = guardSchedule(file, { app, env: context.env, platform: system.platform, agentRuns }, { seal })
1012
+ if ((await waits(this, file, { timed: true })) !== undefined) return
1013
+ const last = await untilChildEnds(this, (signal) =>
1014
+ runSchedule(app, system, context.env, file, {
1015
+ ...(checked ? { schedule: checked } : {}),
1016
+ timer: timer(),
1017
+ agentRuns,
1018
+ ownerLanguage: ownerLanguageOf,
1019
+ reportTemplates: reportTemplatesOf,
1020
+ ...(agentInput ? { agentInput } : {}),
1021
+ untilUnlocked: true,
1022
+ skipRepeatedInput: true,
1023
+ ...(signal ? { signal } : {}),
1024
+ }),
1025
+ )
1026
+ if (last.exitCode !== 0) setExitCode(this, 1)
1027
+ })
1027
1028
 
1028
- return command
1029
- }
1029
+ return command
1030
+ },
1031
+ )