@useconductor/conductor 1.0.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 (504) hide show
  1. package/.claude-plugin/marketplace.json +33 -0
  2. package/.claude-plugin/plugin.json +23 -0
  3. package/.eslintrc.json +23 -0
  4. package/.gitattributes +6 -0
  5. package/.github/FUNDING.yml +15 -0
  6. package/.github/ISSUE_TEMPLATE/bug_report.yml +91 -0
  7. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  8. package/.github/ISSUE_TEMPLATE/feature_request.yml +63 -0
  9. package/.github/ISSUE_TEMPLATE/plugin_request.yml +71 -0
  10. package/.github/README.md +13 -0
  11. package/.github/workflows/README.md +22 -0
  12. package/.github/workflows/auto-release.yml +112 -0
  13. package/.github/workflows/ci.yml +49 -0
  14. package/.github/workflows/claude-code-review.yml +44 -0
  15. package/.github/workflows/claude.yml +36 -0
  16. package/.github/workflows/sync-install.yml +47 -0
  17. package/.mcp.json +9 -0
  18. package/.prettierrc.json +7 -0
  19. package/C.png +0 -0
  20. package/CHANGELOG.md +74 -0
  21. package/CLAUDE.md +118 -0
  22. package/CONTRIBUTING.md +231 -0
  23. package/LICENSE +201 -0
  24. package/README.md +179 -0
  25. package/SECURITY.md +47 -0
  26. package/commands/conductor-setup.md +11 -0
  27. package/commands/conductor-status.md +7 -0
  28. package/dist/ai/base.d.ts +44 -0
  29. package/dist/ai/base.d.ts.map +1 -0
  30. package/dist/ai/base.js +47 -0
  31. package/dist/ai/base.js.map +1 -0
  32. package/dist/ai/claude.d.ts +11 -0
  33. package/dist/ai/claude.d.ts.map +1 -0
  34. package/dist/ai/claude.js +149 -0
  35. package/dist/ai/claude.js.map +1 -0
  36. package/dist/ai/gemini.d.ts +15 -0
  37. package/dist/ai/gemini.d.ts.map +1 -0
  38. package/dist/ai/gemini.js +156 -0
  39. package/dist/ai/gemini.js.map +1 -0
  40. package/dist/ai/maestro.d.ts +22 -0
  41. package/dist/ai/maestro.d.ts.map +1 -0
  42. package/dist/ai/maestro.js +142 -0
  43. package/dist/ai/maestro.js.map +1 -0
  44. package/dist/ai/manager.d.ts +47 -0
  45. package/dist/ai/manager.d.ts.map +1 -0
  46. package/dist/ai/manager.js +450 -0
  47. package/dist/ai/manager.js.map +1 -0
  48. package/dist/ai/ollama.d.ts +16 -0
  49. package/dist/ai/ollama.d.ts.map +1 -0
  50. package/dist/ai/ollama.js +151 -0
  51. package/dist/ai/ollama.js.map +1 -0
  52. package/dist/ai/openai.d.ts +11 -0
  53. package/dist/ai/openai.d.ts.map +1 -0
  54. package/dist/ai/openai.js +132 -0
  55. package/dist/ai/openai.js.map +1 -0
  56. package/dist/ai/openrouter.d.ts +11 -0
  57. package/dist/ai/openrouter.d.ts.map +1 -0
  58. package/dist/ai/openrouter.js +139 -0
  59. package/dist/ai/openrouter.js.map +1 -0
  60. package/dist/bot/slack.d.ts +17 -0
  61. package/dist/bot/slack.d.ts.map +1 -0
  62. package/dist/bot/slack.js +144 -0
  63. package/dist/bot/slack.js.map +1 -0
  64. package/dist/bot/telegram.d.ts +19 -0
  65. package/dist/bot/telegram.d.ts.map +1 -0
  66. package/dist/bot/telegram.js +157 -0
  67. package/dist/bot/telegram.js.map +1 -0
  68. package/dist/cli/commands/ai.d.ts +4 -0
  69. package/dist/cli/commands/ai.d.ts.map +1 -0
  70. package/dist/cli/commands/ai.js +161 -0
  71. package/dist/cli/commands/ai.js.map +1 -0
  72. package/dist/cli/commands/doctor.d.ts +18 -0
  73. package/dist/cli/commands/doctor.d.ts.map +1 -0
  74. package/dist/cli/commands/doctor.js +213 -0
  75. package/dist/cli/commands/doctor.js.map +1 -0
  76. package/dist/cli/commands/init.d.ts +15 -0
  77. package/dist/cli/commands/init.d.ts.map +1 -0
  78. package/dist/cli/commands/init.js +281 -0
  79. package/dist/cli/commands/init.js.map +1 -0
  80. package/dist/cli/commands/install.d.ts +16 -0
  81. package/dist/cli/commands/install.d.ts.map +1 -0
  82. package/dist/cli/commands/install.js +750 -0
  83. package/dist/cli/commands/install.js.map +1 -0
  84. package/dist/cli/commands/lifecycle.d.ts +4 -0
  85. package/dist/cli/commands/lifecycle.d.ts.map +1 -0
  86. package/dist/cli/commands/lifecycle.js +84 -0
  87. package/dist/cli/commands/lifecycle.js.map +1 -0
  88. package/dist/cli/commands/marketplace.d.ts +13 -0
  89. package/dist/cli/commands/marketplace.d.ts.map +1 -0
  90. package/dist/cli/commands/marketplace.js +197 -0
  91. package/dist/cli/commands/marketplace.js.map +1 -0
  92. package/dist/cli/commands/mcp.d.ts +6 -0
  93. package/dist/cli/commands/mcp.d.ts.map +1 -0
  94. package/dist/cli/commands/mcp.js +83 -0
  95. package/dist/cli/commands/mcp.js.map +1 -0
  96. package/dist/cli/commands/onboard.d.ts +10 -0
  97. package/dist/cli/commands/onboard.d.ts.map +1 -0
  98. package/dist/cli/commands/onboard.js +207 -0
  99. package/dist/cli/commands/onboard.js.map +1 -0
  100. package/dist/cli/commands/plugin-create.d.ts +13 -0
  101. package/dist/cli/commands/plugin-create.d.ts.map +1 -0
  102. package/dist/cli/commands/plugin-create.js +122 -0
  103. package/dist/cli/commands/plugin-create.js.map +1 -0
  104. package/dist/cli/commands/plugins.d.ts +5 -0
  105. package/dist/cli/commands/plugins.d.ts.map +1 -0
  106. package/dist/cli/commands/plugins.js +30 -0
  107. package/dist/cli/commands/plugins.js.map +1 -0
  108. package/dist/cli/commands/release.d.ts +13 -0
  109. package/dist/cli/commands/release.d.ts.map +1 -0
  110. package/dist/cli/commands/release.js +243 -0
  111. package/dist/cli/commands/release.js.map +1 -0
  112. package/dist/cli/commands/telegram.d.ts +3 -0
  113. package/dist/cli/commands/telegram.d.ts.map +1 -0
  114. package/dist/cli/commands/telegram.js +20 -0
  115. package/dist/cli/commands/telegram.js.map +1 -0
  116. package/dist/cli/index.d.ts +3 -0
  117. package/dist/cli/index.d.ts.map +1 -0
  118. package/dist/cli/index.js +402 -0
  119. package/dist/cli/index.js.map +1 -0
  120. package/dist/config/oauth.d.ts +8 -0
  121. package/dist/config/oauth.d.ts.map +1 -0
  122. package/dist/config/oauth.js +13 -0
  123. package/dist/config/oauth.js.map +1 -0
  124. package/dist/core/audit.d.ts +91 -0
  125. package/dist/core/audit.d.ts.map +1 -0
  126. package/dist/core/audit.js +233 -0
  127. package/dist/core/audit.js.map +1 -0
  128. package/dist/core/circuit-breaker.d.ts +56 -0
  129. package/dist/core/circuit-breaker.d.ts.map +1 -0
  130. package/dist/core/circuit-breaker.js +107 -0
  131. package/dist/core/circuit-breaker.js.map +1 -0
  132. package/dist/core/conductor.d.ts +44 -0
  133. package/dist/core/conductor.d.ts.map +1 -0
  134. package/dist/core/conductor.js +200 -0
  135. package/dist/core/conductor.js.map +1 -0
  136. package/dist/core/config.d.ts +66 -0
  137. package/dist/core/config.d.ts.map +1 -0
  138. package/dist/core/config.js +86 -0
  139. package/dist/core/config.js.map +1 -0
  140. package/dist/core/database.d.ts +59 -0
  141. package/dist/core/database.d.ts.map +1 -0
  142. package/dist/core/database.js +342 -0
  143. package/dist/core/database.js.map +1 -0
  144. package/dist/core/errors.d.ts +231 -0
  145. package/dist/core/errors.d.ts.map +1 -0
  146. package/dist/core/errors.js +254 -0
  147. package/dist/core/errors.js.map +1 -0
  148. package/dist/core/health.d.ts +72 -0
  149. package/dist/core/health.d.ts.map +1 -0
  150. package/dist/core/health.js +116 -0
  151. package/dist/core/health.js.map +1 -0
  152. package/dist/core/interfaces.d.ts +62 -0
  153. package/dist/core/interfaces.d.ts.map +1 -0
  154. package/dist/core/interfaces.js +8 -0
  155. package/dist/core/interfaces.js.map +1 -0
  156. package/dist/core/logger.d.ts +15 -0
  157. package/dist/core/logger.d.ts.map +1 -0
  158. package/dist/core/logger.js +30 -0
  159. package/dist/core/logger.js.map +1 -0
  160. package/dist/core/rbac.d.ts +132 -0
  161. package/dist/core/rbac.d.ts.map +1 -0
  162. package/dist/core/rbac.js +230 -0
  163. package/dist/core/rbac.js.map +1 -0
  164. package/dist/core/retry.d.ts +22 -0
  165. package/dist/core/retry.d.ts.map +1 -0
  166. package/dist/core/retry.js +41 -0
  167. package/dist/core/retry.js.map +1 -0
  168. package/dist/core/webhooks.d.ts +92 -0
  169. package/dist/core/webhooks.d.ts.map +1 -0
  170. package/dist/core/webhooks.js +176 -0
  171. package/dist/core/webhooks.js.map +1 -0
  172. package/dist/core/zero-config.d.ts +22 -0
  173. package/dist/core/zero-config.d.ts.map +1 -0
  174. package/dist/core/zero-config.js +59 -0
  175. package/dist/core/zero-config.js.map +1 -0
  176. package/dist/dashboard/cli.d.ts +6 -0
  177. package/dist/dashboard/cli.d.ts.map +1 -0
  178. package/dist/dashboard/cli.js +42 -0
  179. package/dist/dashboard/cli.js.map +1 -0
  180. package/dist/dashboard/index.html +3426 -0
  181. package/dist/dashboard/server.d.ts +7 -0
  182. package/dist/dashboard/server.d.ts.map +1 -0
  183. package/dist/dashboard/server.js +1427 -0
  184. package/dist/dashboard/server.js.map +1 -0
  185. package/dist/mcp/server.d.ts +27 -0
  186. package/dist/mcp/server.d.ts.map +1 -0
  187. package/dist/mcp/server.js +380 -0
  188. package/dist/mcp/server.js.map +1 -0
  189. package/dist/mcp/tools/misc.d.ts +15 -0
  190. package/dist/mcp/tools/misc.d.ts.map +1 -0
  191. package/dist/mcp/tools/misc.js +49 -0
  192. package/dist/mcp/tools/misc.js.map +1 -0
  193. package/dist/plugins/builtin/calculator.d.ts +11 -0
  194. package/dist/plugins/builtin/calculator.d.ts.map +1 -0
  195. package/dist/plugins/builtin/calculator.js +166 -0
  196. package/dist/plugins/builtin/calculator.js.map +1 -0
  197. package/dist/plugins/builtin/colors.d.ts +15 -0
  198. package/dist/plugins/builtin/colors.d.ts.map +1 -0
  199. package/dist/plugins/builtin/colors.js +193 -0
  200. package/dist/plugins/builtin/colors.js.map +1 -0
  201. package/dist/plugins/builtin/cron.d.ts +40 -0
  202. package/dist/plugins/builtin/cron.d.ts.map +1 -0
  203. package/dist/plugins/builtin/cron.js +578 -0
  204. package/dist/plugins/builtin/cron.js.map +1 -0
  205. package/dist/plugins/builtin/crypto.d.ts +11 -0
  206. package/dist/plugins/builtin/crypto.d.ts.map +1 -0
  207. package/dist/plugins/builtin/crypto.js +83 -0
  208. package/dist/plugins/builtin/crypto.js.map +1 -0
  209. package/dist/plugins/builtin/database.d.ts +29 -0
  210. package/dist/plugins/builtin/database.d.ts.map +1 -0
  211. package/dist/plugins/builtin/database.js +230 -0
  212. package/dist/plugins/builtin/database.js.map +1 -0
  213. package/dist/plugins/builtin/docker.d.ts +12 -0
  214. package/dist/plugins/builtin/docker.d.ts.map +1 -0
  215. package/dist/plugins/builtin/docker.js +436 -0
  216. package/dist/plugins/builtin/docker.js.map +1 -0
  217. package/dist/plugins/builtin/fun.d.ts +11 -0
  218. package/dist/plugins/builtin/fun.d.ts.map +1 -0
  219. package/dist/plugins/builtin/fun.js +114 -0
  220. package/dist/plugins/builtin/fun.js.map +1 -0
  221. package/dist/plugins/builtin/gcal.d.ts +38 -0
  222. package/dist/plugins/builtin/gcal.d.ts.map +1 -0
  223. package/dist/plugins/builtin/gcal.js +280 -0
  224. package/dist/plugins/builtin/gcal.js.map +1 -0
  225. package/dist/plugins/builtin/gdrive.d.ts +26 -0
  226. package/dist/plugins/builtin/gdrive.d.ts.map +1 -0
  227. package/dist/plugins/builtin/gdrive.js +295 -0
  228. package/dist/plugins/builtin/gdrive.js.map +1 -0
  229. package/dist/plugins/builtin/github-actions.d.ts +38 -0
  230. package/dist/plugins/builtin/github-actions.d.ts.map +1 -0
  231. package/dist/plugins/builtin/github-actions.js +629 -0
  232. package/dist/plugins/builtin/github-actions.js.map +1 -0
  233. package/dist/plugins/builtin/github.d.ts +26 -0
  234. package/dist/plugins/builtin/github.d.ts.map +1 -0
  235. package/dist/plugins/builtin/github.js +800 -0
  236. package/dist/plugins/builtin/github.js.map +1 -0
  237. package/dist/plugins/builtin/gmail.d.ts +50 -0
  238. package/dist/plugins/builtin/gmail.d.ts.map +1 -0
  239. package/dist/plugins/builtin/gmail.js +445 -0
  240. package/dist/plugins/builtin/gmail.js.map +1 -0
  241. package/dist/plugins/builtin/hash.d.ts +11 -0
  242. package/dist/plugins/builtin/hash.d.ts.map +1 -0
  243. package/dist/plugins/builtin/hash.js +95 -0
  244. package/dist/plugins/builtin/hash.js.map +1 -0
  245. package/dist/plugins/builtin/homekit.d.ts +53 -0
  246. package/dist/plugins/builtin/homekit.d.ts.map +1 -0
  247. package/dist/plugins/builtin/homekit.js +341 -0
  248. package/dist/plugins/builtin/homekit.js.map +1 -0
  249. package/dist/plugins/builtin/index.d.ts +4 -0
  250. package/dist/plugins/builtin/index.d.ts.map +1 -0
  251. package/dist/plugins/builtin/index.js +96 -0
  252. package/dist/plugins/builtin/index.js.map +1 -0
  253. package/dist/plugins/builtin/jira.d.ts +50 -0
  254. package/dist/plugins/builtin/jira.d.ts.map +1 -0
  255. package/dist/plugins/builtin/jira.js +353 -0
  256. package/dist/plugins/builtin/jira.js.map +1 -0
  257. package/dist/plugins/builtin/linear.d.ts +35 -0
  258. package/dist/plugins/builtin/linear.d.ts.map +1 -0
  259. package/dist/plugins/builtin/linear.js +397 -0
  260. package/dist/plugins/builtin/linear.js.map +1 -0
  261. package/dist/plugins/builtin/lumen.d.ts +21 -0
  262. package/dist/plugins/builtin/lumen.d.ts.map +1 -0
  263. package/dist/plugins/builtin/lumen.js +404 -0
  264. package/dist/plugins/builtin/lumen.js.map +1 -0
  265. package/dist/plugins/builtin/memory.d.ts +22 -0
  266. package/dist/plugins/builtin/memory.d.ts.map +1 -0
  267. package/dist/plugins/builtin/memory.js +184 -0
  268. package/dist/plugins/builtin/memory.js.map +1 -0
  269. package/dist/plugins/builtin/n8n.d.ts +60 -0
  270. package/dist/plugins/builtin/n8n.d.ts.map +1 -0
  271. package/dist/plugins/builtin/n8n.js +519 -0
  272. package/dist/plugins/builtin/n8n.js.map +1 -0
  273. package/dist/plugins/builtin/network.d.ts +11 -0
  274. package/dist/plugins/builtin/network.d.ts.map +1 -0
  275. package/dist/plugins/builtin/network.js +88 -0
  276. package/dist/plugins/builtin/network.js.map +1 -0
  277. package/dist/plugins/builtin/notes.d.ts +47 -0
  278. package/dist/plugins/builtin/notes.d.ts.map +1 -0
  279. package/dist/plugins/builtin/notes.js +641 -0
  280. package/dist/plugins/builtin/notes.js.map +1 -0
  281. package/dist/plugins/builtin/notion.d.ts +47 -0
  282. package/dist/plugins/builtin/notion.d.ts.map +1 -0
  283. package/dist/plugins/builtin/notion.js +317 -0
  284. package/dist/plugins/builtin/notion.js.map +1 -0
  285. package/dist/plugins/builtin/shell.d.ts +12 -0
  286. package/dist/plugins/builtin/shell.d.ts.map +1 -0
  287. package/dist/plugins/builtin/shell.js +310 -0
  288. package/dist/plugins/builtin/shell.js.map +1 -0
  289. package/dist/plugins/builtin/slack.d.ts +31 -0
  290. package/dist/plugins/builtin/slack.d.ts.map +1 -0
  291. package/dist/plugins/builtin/slack.js +295 -0
  292. package/dist/plugins/builtin/slack.js.map +1 -0
  293. package/dist/plugins/builtin/spotify.d.ts +55 -0
  294. package/dist/plugins/builtin/spotify.d.ts.map +1 -0
  295. package/dist/plugins/builtin/spotify.js +623 -0
  296. package/dist/plugins/builtin/spotify.js.map +1 -0
  297. package/dist/plugins/builtin/stripe.d.ts +35 -0
  298. package/dist/plugins/builtin/stripe.d.ts.map +1 -0
  299. package/dist/plugins/builtin/stripe.js +376 -0
  300. package/dist/plugins/builtin/stripe.js.map +1 -0
  301. package/dist/plugins/builtin/system.d.ts +11 -0
  302. package/dist/plugins/builtin/system.d.ts.map +1 -0
  303. package/dist/plugins/builtin/system.js +91 -0
  304. package/dist/plugins/builtin/system.js.map +1 -0
  305. package/dist/plugins/builtin/text-tools.d.ts +11 -0
  306. package/dist/plugins/builtin/text-tools.d.ts.map +1 -0
  307. package/dist/plugins/builtin/text-tools.js +146 -0
  308. package/dist/plugins/builtin/text-tools.js.map +1 -0
  309. package/dist/plugins/builtin/timezone.d.ts +13 -0
  310. package/dist/plugins/builtin/timezone.d.ts.map +1 -0
  311. package/dist/plugins/builtin/timezone.js +164 -0
  312. package/dist/plugins/builtin/timezone.js.map +1 -0
  313. package/dist/plugins/builtin/todoist.d.ts +49 -0
  314. package/dist/plugins/builtin/todoist.d.ts.map +1 -0
  315. package/dist/plugins/builtin/todoist.js +540 -0
  316. package/dist/plugins/builtin/todoist.js.map +1 -0
  317. package/dist/plugins/builtin/translate.d.ts +11 -0
  318. package/dist/plugins/builtin/translate.d.ts.map +1 -0
  319. package/dist/plugins/builtin/translate.js +42 -0
  320. package/dist/plugins/builtin/translate.js.map +1 -0
  321. package/dist/plugins/builtin/url-tools.d.ts +11 -0
  322. package/dist/plugins/builtin/url-tools.d.ts.map +1 -0
  323. package/dist/plugins/builtin/url-tools.js +70 -0
  324. package/dist/plugins/builtin/url-tools.js.map +1 -0
  325. package/dist/plugins/builtin/vercel.d.ts +55 -0
  326. package/dist/plugins/builtin/vercel.d.ts.map +1 -0
  327. package/dist/plugins/builtin/vercel.js +514 -0
  328. package/dist/plugins/builtin/vercel.js.map +1 -0
  329. package/dist/plugins/builtin/weather.d.ts +13 -0
  330. package/dist/plugins/builtin/weather.d.ts.map +1 -0
  331. package/dist/plugins/builtin/weather.js +103 -0
  332. package/dist/plugins/builtin/weather.js.map +1 -0
  333. package/dist/plugins/builtin/x.d.ts +54 -0
  334. package/dist/plugins/builtin/x.d.ts.map +1 -0
  335. package/dist/plugins/builtin/x.js +402 -0
  336. package/dist/plugins/builtin/x.js.map +1 -0
  337. package/dist/plugins/manager.d.ts +77 -0
  338. package/dist/plugins/manager.d.ts.map +1 -0
  339. package/dist/plugins/manager.js +141 -0
  340. package/dist/plugins/manager.js.map +1 -0
  341. package/dist/plugins/validation.d.ts +18 -0
  342. package/dist/plugins/validation.d.ts.map +1 -0
  343. package/dist/plugins/validation.js +81 -0
  344. package/dist/plugins/validation.js.map +1 -0
  345. package/dist/security/auth.d.ts +23 -0
  346. package/dist/security/auth.d.ts.map +1 -0
  347. package/dist/security/auth.js +56 -0
  348. package/dist/security/auth.js.map +1 -0
  349. package/dist/security/keychain.d.ts +60 -0
  350. package/dist/security/keychain.d.ts.map +1 -0
  351. package/dist/security/keychain.js +213 -0
  352. package/dist/security/keychain.js.map +1 -0
  353. package/dist/utils/google-auth.d.ts +21 -0
  354. package/dist/utils/google-auth.d.ts.map +1 -0
  355. package/dist/utils/google-auth.js +135 -0
  356. package/dist/utils/google-auth.js.map +1 -0
  357. package/dist/utils/retry.d.ts +5 -0
  358. package/dist/utils/retry.d.ts.map +1 -0
  359. package/dist/utils/retry.js +34 -0
  360. package/dist/utils/retry.js.map +1 -0
  361. package/docs/README.md +13 -0
  362. package/docs/api.md +210 -0
  363. package/docs/getting-started.md +100 -0
  364. package/docs/plugins.md +306 -0
  365. package/docs-site/.vitepress/config.ts +59 -0
  366. package/docs-site/README.md +12 -0
  367. package/docs-site/index.md +30 -0
  368. package/eslint.config.js +29 -0
  369. package/install.ps1 +334 -0
  370. package/install.sh +1119 -0
  371. package/local-install.sh +304 -0
  372. package/package.json +90 -0
  373. package/packages/README.md +11 -0
  374. package/packages/plugin-sdk/README.md +12 -0
  375. package/packages/plugin-sdk/package.json +22 -0
  376. package/packages/plugin-sdk/src/README.md +11 -0
  377. package/packages/plugin-sdk/src/index.ts +191 -0
  378. package/sdks/README.md +26 -0
  379. package/sdks/csharp/ConductorClient.cs +65 -0
  380. package/sdks/csharp/README.md +11 -0
  381. package/sdks/go/README.md +11 -0
  382. package/sdks/go/conductor.go +257 -0
  383. package/sdks/java/ConductorClient.java +27 -0
  384. package/sdks/java/README.md +11 -0
  385. package/sdks/php/README.md +11 -0
  386. package/sdks/php/src/Client.php +72 -0
  387. package/sdks/python/README.md +12 -0
  388. package/sdks/python/conductor/__init__.py +227 -0
  389. package/sdks/python/pyproject.toml +30 -0
  390. package/sdks/ruby/README.md +11 -0
  391. package/sdks/ruby/lib/conductor.rb +46 -0
  392. package/sdks/rust/Cargo.toml +14 -0
  393. package/sdks/rust/README.md +11 -0
  394. package/sdks/swift/README.md +11 -0
  395. package/sdks/swift/Sources/Conductor/ConductorClient.swift +65 -0
  396. package/skills/conductor-mcp/SKILL.md +38 -0
  397. package/src/README.md +20 -0
  398. package/src/ai/README.md +18 -0
  399. package/src/ai/base.ts +93 -0
  400. package/src/ai/claude.ts +162 -0
  401. package/src/ai/gemini.ts +188 -0
  402. package/src/ai/maestro.ts +168 -0
  403. package/src/ai/manager.ts +537 -0
  404. package/src/ai/ollama.ts +186 -0
  405. package/src/ai/openai.ts +147 -0
  406. package/src/ai/openrouter.ts +152 -0
  407. package/src/bot/README.md +12 -0
  408. package/src/bot/slack.ts +164 -0
  409. package/src/bot/telegram.ts +185 -0
  410. package/src/cli/README.md +24 -0
  411. package/src/cli/commands/README.md +20 -0
  412. package/src/cli/commands/ai.ts +170 -0
  413. package/src/cli/commands/doctor.ts +221 -0
  414. package/src/cli/commands/init.ts +348 -0
  415. package/src/cli/commands/install.ts +792 -0
  416. package/src/cli/commands/lifecycle.ts +95 -0
  417. package/src/cli/commands/marketplace.ts +253 -0
  418. package/src/cli/commands/mcp.ts +92 -0
  419. package/src/cli/commands/onboard.ts +248 -0
  420. package/src/cli/commands/plugin-create.ts +130 -0
  421. package/src/cli/commands/plugins.ts +36 -0
  422. package/src/cli/commands/release.ts +251 -0
  423. package/src/cli/commands/telegram.ts +25 -0
  424. package/src/cli/index.ts +450 -0
  425. package/src/config/README.md +11 -0
  426. package/src/config/oauth.ts +26 -0
  427. package/src/core/README.md +22 -0
  428. package/src/core/audit.ts +291 -0
  429. package/src/core/circuit-breaker.ts +129 -0
  430. package/src/core/conductor.ts +240 -0
  431. package/src/core/config.ts +149 -0
  432. package/src/core/database.ts +411 -0
  433. package/src/core/errors.ts +275 -0
  434. package/src/core/health.ts +159 -0
  435. package/src/core/interfaces.ts +75 -0
  436. package/src/core/logger.ts +33 -0
  437. package/src/core/rbac.ts +321 -0
  438. package/src/core/retry.ts +61 -0
  439. package/src/core/webhooks.ts +234 -0
  440. package/src/core/zero-config.ts +72 -0
  441. package/src/dashboard/README.md +15 -0
  442. package/src/dashboard/cli.ts +48 -0
  443. package/src/dashboard/index.html +3426 -0
  444. package/src/dashboard/server.ts +1544 -0
  445. package/src/mcp/README.md +20 -0
  446. package/src/mcp/server.ts +475 -0
  447. package/src/mcp/tools/README.md +11 -0
  448. package/src/mcp/tools/misc.ts +61 -0
  449. package/src/plugins/README.md +28 -0
  450. package/src/plugins/builtin/README.md +23 -0
  451. package/src/plugins/builtin/calculator.ts +178 -0
  452. package/src/plugins/builtin/colors.ts +201 -0
  453. package/src/plugins/builtin/cron.ts +649 -0
  454. package/src/plugins/builtin/crypto.ts +85 -0
  455. package/src/plugins/builtin/database.ts +235 -0
  456. package/src/plugins/builtin/docker.ts +426 -0
  457. package/src/plugins/builtin/fun.ts +118 -0
  458. package/src/plugins/builtin/gcal.ts +305 -0
  459. package/src/plugins/builtin/gdrive.ts +326 -0
  460. package/src/plugins/builtin/github-actions.ts +666 -0
  461. package/src/plugins/builtin/github.ts +912 -0
  462. package/src/plugins/builtin/gmail.ts +492 -0
  463. package/src/plugins/builtin/hash.ts +98 -0
  464. package/src/plugins/builtin/homekit.ts +389 -0
  465. package/src/plugins/builtin/index.ts +116 -0
  466. package/src/plugins/builtin/jira.ts +380 -0
  467. package/src/plugins/builtin/linear.ts +448 -0
  468. package/src/plugins/builtin/lumen.ts +497 -0
  469. package/src/plugins/builtin/memory.ts +200 -0
  470. package/src/plugins/builtin/n8n.ts +565 -0
  471. package/src/plugins/builtin/network.ts +92 -0
  472. package/src/plugins/builtin/notes.ts +689 -0
  473. package/src/plugins/builtin/notion.ts +348 -0
  474. package/src/plugins/builtin/shell.ts +334 -0
  475. package/src/plugins/builtin/slack.ts +327 -0
  476. package/src/plugins/builtin/spotify.ts +665 -0
  477. package/src/plugins/builtin/stripe.ts +388 -0
  478. package/src/plugins/builtin/system.ts +93 -0
  479. package/src/plugins/builtin/text-tools.ts +150 -0
  480. package/src/plugins/builtin/timezone.ts +173 -0
  481. package/src/plugins/builtin/todoist.ts +625 -0
  482. package/src/plugins/builtin/translate.ts +47 -0
  483. package/src/plugins/builtin/url-tools.ts +73 -0
  484. package/src/plugins/builtin/vercel.ts +546 -0
  485. package/src/plugins/builtin/weather.ts +112 -0
  486. package/src/plugins/builtin/x.ts +440 -0
  487. package/src/plugins/manager.ts +213 -0
  488. package/src/plugins/validation.ts +94 -0
  489. package/src/security/README.md +12 -0
  490. package/src/security/auth.ts +72 -0
  491. package/src/security/keychain.ts +226 -0
  492. package/src/utils/README.md +12 -0
  493. package/src/utils/google-auth.ts +159 -0
  494. package/src/utils/retry.ts +41 -0
  495. package/test-all.mjs +1256 -0
  496. package/test.mjs +633 -0
  497. package/tests/README.md +19 -0
  498. package/tests/calculator.test.ts +54 -0
  499. package/tests/docker.test.ts +42 -0
  500. package/tests/load.test.ts +129 -0
  501. package/tests/mcp.test.ts +14 -0
  502. package/tests/shell.test.ts +42 -0
  503. package/tsconfig.json +21 -0
  504. package/vitest.config.ts +14 -0
@@ -0,0 +1,649 @@
1
+ /**
2
+ * Cron / Scheduler Plugin — TheAlxLabs / Conductor
3
+ *
4
+ * Persistent scheduled tasks with natural language time parsing.
5
+ * Tasks survive restarts — stored in ~/.conductor/scheduler.json.
6
+ *
7
+ * Features:
8
+ * - Natural language scheduling: "every day at 9am", "in 30 minutes", "every Monday"
9
+ * - One-time and recurring tasks
10
+ * - Task history (last 50 runs per task)
11
+ * - Webhook callbacks or AI tool calls on trigger
12
+ * - Pause/resume without deleting
13
+ * - Timezone-aware scheduling
14
+ * - Task categories and tags
15
+ *
16
+ * NO external cron dependencies — pure Node.js setTimeout/setInterval.
17
+ * The scheduler runs in-process when Conductor is active.
18
+ * Tasks that missed their window while Conductor was off are detected on restart.
19
+ */
20
+
21
+ import crypto from 'crypto';
22
+ import fs from 'fs/promises';
23
+ import path from 'path';
24
+ import { Plugin, PluginTool } from '../manager.js';
25
+ import { Conductor } from '../../core/conductor.js';
26
+
27
+ type TaskFrequency = 'once' | 'minutely' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'custom';
28
+
29
+ interface ScheduledTask {
30
+ id: string;
31
+ name: string;
32
+ description: string;
33
+ tags: string[];
34
+ frequency: TaskFrequency;
35
+ cronExpression?: string; // for custom frequency
36
+ nextRunAt: string; // ISO
37
+ lastRunAt?: string; // ISO
38
+ lastStatus?: 'success' | 'failed' | 'skipped';
39
+ paused: boolean;
40
+ createdAt: string;
41
+ runCount: number;
42
+ failCount: number;
43
+ action: {
44
+ type: 'webhook' | 'log' | 'notify';
45
+ url?: string; // for webhook
46
+ message?: string; // for log/notify
47
+ method?: string; // for webhook
48
+ headers?: Record<string, string>;
49
+ body?: string;
50
+ };
51
+ timezone: string;
52
+ maxRuns?: number; // auto-delete after N runs
53
+ history: Array<{
54
+ ranAt: string;
55
+ status: 'success' | 'failed' | 'skipped';
56
+ duration?: number;
57
+ error?: string;
58
+ output?: string;
59
+ }>;
60
+ }
61
+
62
+ // ── Natural language time parser ────────────────────────────────────────────
63
+
64
+ function parseNaturalTime(
65
+ expr: string,
66
+ now = new Date(),
67
+ ): { nextRun: Date; frequency: TaskFrequency; cronExpr?: string } | null {
68
+ const e = expr.toLowerCase().trim();
69
+
70
+ // "in X minutes/hours/days"
71
+ const inMatch = e.match(/^in\s+(\d+)\s+(minute|hour|day|week)s?$/);
72
+ if (inMatch) {
73
+ const n = parseInt(inMatch[1]);
74
+ const unit = inMatch[2];
75
+ const next = new Date(now);
76
+ if (unit === 'minute') next.setMinutes(next.getMinutes() + n);
77
+ else if (unit === 'hour') next.setHours(next.getHours() + n);
78
+ else if (unit === 'day') next.setDate(next.getDate() + n);
79
+ else if (unit === 'week') next.setDate(next.getDate() + n * 7);
80
+ return { nextRun: next, frequency: 'once' };
81
+ }
82
+
83
+ // "every X minutes/hours"
84
+ const everyMatch = e.match(/^every\s+(\d+)\s+(minute|hour)s?$/);
85
+ if (everyMatch) {
86
+ const n = parseInt(everyMatch[1]);
87
+ const unit = everyMatch[2];
88
+ const next = new Date(now);
89
+ if (unit === 'minute') {
90
+ next.setMinutes(next.getMinutes() + n);
91
+ return { nextRun: next, frequency: 'custom', cronExpr: `*/${n} * * * *` };
92
+ }
93
+ if (unit === 'hour') {
94
+ next.setHours(next.getHours() + n);
95
+ return { nextRun: next, frequency: 'custom', cronExpr: `0 */${n} * * *` };
96
+ }
97
+ }
98
+
99
+ // "every day at HH:MM" or "daily at HH:MM"
100
+ const dailyMatch = e.match(/^(?:every day|daily)\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);
101
+ if (dailyMatch) {
102
+ let h = parseInt(dailyMatch[1]);
103
+ const m = parseInt(dailyMatch[2] ?? '0');
104
+ if (dailyMatch[3] === 'pm' && h < 12) h += 12;
105
+ if (dailyMatch[3] === 'am' && h === 12) h = 0;
106
+ const next = new Date(now);
107
+ next.setHours(h, m, 0, 0);
108
+ if (next <= now) next.setDate(next.getDate() + 1);
109
+ return { nextRun: next, frequency: 'daily', cronExpr: `${m} ${h} * * *` };
110
+ }
111
+
112
+ // "every hour" / "hourly"
113
+ if (e === 'every hour' || e === 'hourly') {
114
+ const next = new Date(now);
115
+ next.setMinutes(0, 0, 0);
116
+ next.setHours(next.getHours() + 1);
117
+ return { nextRun: next, frequency: 'hourly', cronExpr: '0 * * * *' };
118
+ }
119
+
120
+ // "every minute" / "minutely"
121
+ if (e === 'every minute' || e === 'minutely') {
122
+ const next = new Date(now);
123
+ next.setSeconds(0, 0);
124
+ next.setMinutes(next.getMinutes() + 1);
125
+ return { nextRun: next, frequency: 'minutely', cronExpr: '* * * * *' };
126
+ }
127
+
128
+ // "every Monday/Tuesday/.../weekday at HH:MM"
129
+ const days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
130
+ const weekdayMatch = e.match(
131
+ /^every\s+(monday|tuesday|wednesday|thursday|friday|saturday|sunday)\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/,
132
+ );
133
+ if (weekdayMatch) {
134
+ const targetDay = days.indexOf(weekdayMatch[1]);
135
+ let h = parseInt(weekdayMatch[2]);
136
+ const m = parseInt(weekdayMatch[3] ?? '0');
137
+ if (weekdayMatch[4] === 'pm' && h < 12) h += 12;
138
+ if (weekdayMatch[4] === 'am' && h === 12) h = 0;
139
+ const next = new Date(now);
140
+ next.setHours(h, m, 0, 0);
141
+ const daysUntil = (targetDay - now.getDay() + 7) % 7 || 7;
142
+ next.setDate(next.getDate() + daysUntil);
143
+ return { nextRun: next, frequency: 'weekly', cronExpr: `${m} ${h} * * ${targetDay}` };
144
+ }
145
+
146
+ // "every weekday at HH:MM"
147
+ const weekdayGenMatch = e.match(/^every weekday\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);
148
+ if (weekdayGenMatch) {
149
+ let h = parseInt(weekdayGenMatch[1]);
150
+ const m = parseInt(weekdayGenMatch[2] ?? '0');
151
+ if (weekdayGenMatch[3] === 'pm' && h < 12) h += 12;
152
+ const next = new Date(now);
153
+ next.setHours(h, m, 0, 0);
154
+ if (next <= now || next.getDay() === 0 || next.getDay() === 6) {
155
+ next.setDate(next.getDate() + 1);
156
+ while (next.getDay() === 0 || next.getDay() === 6) next.setDate(next.getDate() + 1);
157
+ }
158
+ return { nextRun: next, frequency: 'custom', cronExpr: `${m} ${h} * * 1-5` };
159
+ }
160
+
161
+ // "every month on the Xth at HH:MM"
162
+ const monthlyMatch = e.match(
163
+ /^(?:every month|monthly)\s+(?:on the\s+)?(\d{1,2})(?:st|nd|rd|th)?\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/,
164
+ );
165
+ if (monthlyMatch) {
166
+ const day = parseInt(monthlyMatch[1]);
167
+ let h = parseInt(monthlyMatch[2]);
168
+ const m = parseInt(monthlyMatch[3] ?? '0');
169
+ if (monthlyMatch[4] === 'pm' && h < 12) h += 12;
170
+ const next = new Date(now);
171
+ next.setDate(day);
172
+ next.setHours(h, m, 0, 0);
173
+ if (next <= now) next.setMonth(next.getMonth() + 1);
174
+ return { nextRun: next, frequency: 'monthly', cronExpr: `${m} ${h} ${day} * *` };
175
+ }
176
+
177
+ // Try parsing as raw ISO date
178
+ const isoDate = new Date(expr);
179
+ if (!isNaN(isoDate.getTime()) && isoDate > now) {
180
+ return { nextRun: isoDate, frequency: 'once' };
181
+ }
182
+
183
+ return null;
184
+ }
185
+
186
+ /** Compute next run time after a given time based on frequency/cron */
187
+ function getNextRun(task: ScheduledTask, after = new Date()): Date | null {
188
+ if (task.frequency === 'once') return null;
189
+
190
+ const next = new Date(after);
191
+ if (task.frequency === 'minutely') {
192
+ next.setMinutes(next.getMinutes() + 1, 0, 0);
193
+ return next;
194
+ }
195
+ if (task.frequency === 'hourly') {
196
+ next.setHours(next.getHours() + 1, 0, 0, 0);
197
+ return next;
198
+ }
199
+
200
+ if (task.frequency === 'daily' || (task.frequency === 'custom' && task.cronExpression)) {
201
+ // Simple: re-parse cron for next time
202
+ if (task.cronExpression) {
203
+ const parts = task.cronExpression.split(' ');
204
+ if (parts.length === 5) {
205
+ const [min, hour, dom, , dow] = parts;
206
+ const result = new Date(after);
207
+
208
+ if (dow !== '*' && !dow.includes('-') && !dow.includes('/')) {
209
+ const targetDay = parseInt(dow);
210
+ result.setHours(parseInt(hour), parseInt(min), 0, 0);
211
+ const daysUntil = (targetDay - after.getDay() + 7) % 7 || 7;
212
+ result.setDate(result.getDate() + daysUntil);
213
+ return result;
214
+ }
215
+
216
+ if (dom !== '*') {
217
+ result.setDate(parseInt(dom));
218
+ result.setHours(parseInt(hour), parseInt(min), 0, 0);
219
+ if (result <= after) result.setMonth(result.getMonth() + 1);
220
+ return result;
221
+ }
222
+
223
+ result.setHours(parseInt(hour === '*' ? String(after.getHours()) : hour), parseInt(min), 0, 0);
224
+ result.setDate(result.getDate() + 1);
225
+ return result;
226
+ }
227
+ }
228
+ next.setDate(next.getDate() + 1);
229
+ return next;
230
+ }
231
+
232
+ if (task.frequency === 'weekly') {
233
+ next.setDate(next.getDate() + 7);
234
+ return next;
235
+ }
236
+ if (task.frequency === 'monthly') {
237
+ next.setMonth(next.getMonth() + 1);
238
+ return next;
239
+ }
240
+ return null;
241
+ }
242
+
243
+ export class CronPlugin implements Plugin {
244
+ name = 'cron';
245
+ description = 'Schedule recurring and one-time tasks with natural language — "every day at 9am", "in 30 minutes"';
246
+ version = '1.0.0';
247
+
248
+ private storePath!: string;
249
+ private tasks: Map<string, ScheduledTask> = new Map();
250
+ private loaded = false;
251
+ private timers: Map<string, ReturnType<typeof setTimeout>> = new Map();
252
+
253
+ async initialize(conductor: Conductor): Promise<void> {
254
+ const configDir = conductor.getConfig().getConfigDir();
255
+ this.storePath = path.join(configDir, 'scheduler.json');
256
+ await this.load();
257
+ this.scheduleAll();
258
+ }
259
+
260
+ isConfigured(): boolean {
261
+ return true;
262
+ }
263
+
264
+ // ── Persistence ─────────────────────────────────────────────────────────────
265
+
266
+ private async load(): Promise<void> {
267
+ if (this.loaded) return;
268
+ try {
269
+ const raw = await fs.readFile(this.storePath, 'utf-8');
270
+ const arr: ScheduledTask[] = JSON.parse(raw);
271
+ this.tasks = new Map(arr.map((t) => [t.id, t]));
272
+ } catch {
273
+ this.tasks = new Map();
274
+ }
275
+ this.loaded = true;
276
+ }
277
+
278
+ private async save(): Promise<void> {
279
+ const arr = Array.from(this.tasks.values());
280
+ const tmp = this.storePath + '.tmp';
281
+ await fs.writeFile(tmp, JSON.stringify(arr, null, 2));
282
+ await fs.rename(tmp, this.storePath);
283
+ }
284
+
285
+ // ── Scheduler ───────────────────────────────────────────────────────────────
286
+
287
+ private scheduleAll(): void {
288
+ for (const task of this.tasks.values()) {
289
+ if (!task.paused) this.scheduleTask(task);
290
+ }
291
+ }
292
+
293
+ private scheduleTask(task: ScheduledTask): void {
294
+ const existing = this.timers.get(task.id);
295
+ if (existing) clearTimeout(existing);
296
+
297
+ const nextRun = new Date(task.nextRunAt);
298
+ const delay = nextRun.getTime() - Date.now();
299
+
300
+ if (delay < 0) {
301
+ // Missed run — log and reschedule
302
+ task.history.unshift({
303
+ ranAt: nextRun.toISOString(),
304
+ status: 'skipped',
305
+ error: 'Conductor was not running',
306
+ });
307
+ if (task.history.length > 50) task.history.pop();
308
+ const next = getNextRun(task, new Date());
309
+ if (next) {
310
+ task.nextRunAt = next.toISOString();
311
+ this.save().catch(() => {});
312
+ this.scheduleTask(task);
313
+ }
314
+ return;
315
+ }
316
+
317
+ const timer = setTimeout(
318
+ async () => {
319
+ await this.runTask(task);
320
+ },
321
+ Math.min(delay, 2147483647),
322
+ ); // setTimeout max
323
+
324
+ this.timers.set(task.id, timer);
325
+ }
326
+
327
+ private async runTask(task: ScheduledTask): Promise<void> {
328
+ const start = Date.now();
329
+ let status: 'success' | 'failed' = 'success';
330
+ let output: string | undefined;
331
+ let error: string | undefined;
332
+
333
+ try {
334
+ if (task.action.type === 'webhook' && task.action.url) {
335
+ const res = await fetch(task.action.url, {
336
+ method: task.action.method ?? 'POST',
337
+ headers: { 'Content-Type': 'application/json', ...task.action.headers },
338
+ body: task.action.body ?? JSON.stringify({ taskId: task.id, taskName: task.name }),
339
+ });
340
+ output = `HTTP ${res.status}`;
341
+ if (!res.ok) {
342
+ status = 'failed';
343
+ error = `HTTP ${res.status}: ${res.statusText}`;
344
+ }
345
+ } else if (task.action.type === 'log') {
346
+ output = task.action.message ?? `Task "${task.name}" triggered`;
347
+ process.stderr.write(`[Conductor Cron] ${output}\n`);
348
+ }
349
+ } catch (err: any) {
350
+ status = 'failed';
351
+ error = err.message ?? String(err);
352
+ }
353
+
354
+ const duration = Date.now() - start;
355
+ task.lastRunAt = new Date().toISOString();
356
+ task.lastStatus = status;
357
+ task.runCount++;
358
+ if (status === 'failed') task.failCount++;
359
+
360
+ task.history.unshift({ ranAt: task.lastRunAt, status, duration, error, output });
361
+ if (task.history.length > 50) task.history.pop();
362
+
363
+ // Auto-delete if maxRuns reached
364
+ if (task.maxRuns && task.runCount >= task.maxRuns) {
365
+ this.tasks.delete(task.id);
366
+ this.timers.delete(task.id);
367
+ await this.save();
368
+ return;
369
+ }
370
+
371
+ // Schedule next run
372
+ const next = getNextRun(task, new Date());
373
+ if (next) {
374
+ task.nextRunAt = next.toISOString();
375
+ await this.save();
376
+ this.scheduleTask(task);
377
+ } else {
378
+ // One-time task done
379
+ await this.save();
380
+ }
381
+ }
382
+
383
+ // ── Tools ───────────────────────────────────────────────────────────────────
384
+
385
+ getTools(): PluginTool[] {
386
+ return [
387
+ // ── cron_schedule ───────────────────────────────────────────────────────
388
+ {
389
+ name: 'cron_schedule',
390
+ description:
391
+ 'Schedule a task. Supports natural language: "every day at 9am", "in 30 minutes", ' +
392
+ '"every Monday at 8am", "every weekday at 6pm", "every hour", "every 15 minutes".',
393
+ inputSchema: {
394
+ type: 'object',
395
+ properties: {
396
+ name: { type: 'string', description: 'Task name' },
397
+ when: {
398
+ type: 'string',
399
+ description: 'When to run — natural language like "every day at 9am" or ISO datetime for one-time',
400
+ },
401
+ action: {
402
+ type: 'string',
403
+ enum: ['log', 'webhook'],
404
+ description: 'What to do when triggered (default: log)',
405
+ },
406
+ message: {
407
+ type: 'string',
408
+ description: 'Message to log when triggered (for action=log)',
409
+ },
410
+ webhookUrl: {
411
+ type: 'string',
412
+ description: 'URL to POST to when triggered (for action=webhook)',
413
+ },
414
+ tags: {
415
+ type: 'array',
416
+ items: { type: 'string' },
417
+ description: 'Optional tags for organization',
418
+ },
419
+ maxRuns: {
420
+ type: 'number',
421
+ description: 'Auto-delete after this many runs (optional)',
422
+ },
423
+ description: { type: 'string', description: 'Optional description' },
424
+ },
425
+ required: ['name', 'when'],
426
+ },
427
+ handler: async ({
428
+ name,
429
+ when,
430
+ action = 'log',
431
+ message,
432
+ webhookUrl,
433
+ tags = [],
434
+ maxRuns,
435
+ description = '',
436
+ }: any) => {
437
+ await this.load();
438
+
439
+ const parsed = parseNaturalTime(when);
440
+ if (!parsed) {
441
+ return {
442
+ error: `Could not parse schedule: "${when}". Try: "every day at 9am", "in 30 minutes", "every Monday at 8am"`,
443
+ };
444
+ }
445
+
446
+ const id = crypto.randomUUID().slice(0, 8);
447
+ const now = new Date().toISOString();
448
+
449
+ const task: ScheduledTask = {
450
+ id,
451
+ name,
452
+ description,
453
+ tags,
454
+ frequency: parsed.frequency,
455
+ cronExpression: parsed.cronExpr,
456
+ nextRunAt: parsed.nextRun.toISOString(),
457
+ paused: false,
458
+ createdAt: now,
459
+ runCount: 0,
460
+ failCount: 0,
461
+ action: {
462
+ type: action,
463
+ url: webhookUrl,
464
+ message: message ?? `Task "${name}" triggered`,
465
+ method: 'POST',
466
+ },
467
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
468
+ maxRuns,
469
+ history: [],
470
+ };
471
+
472
+ this.tasks.set(id, task);
473
+ this.scheduleTask(task);
474
+ await this.save();
475
+
476
+ return {
477
+ scheduled: true,
478
+ id,
479
+ name,
480
+ frequency: parsed.frequency,
481
+ nextRunAt: parsed.nextRun.toISOString(),
482
+ nextRunIn: this.humanDuration(parsed.nextRun.getTime() - Date.now()),
483
+ cronExpression: parsed.cronExpr ?? null,
484
+ };
485
+ },
486
+ },
487
+
488
+ // ── cron_list ───────────────────────────────────────────────────────────
489
+ {
490
+ name: 'cron_list',
491
+ description: 'List all scheduled tasks',
492
+ inputSchema: {
493
+ type: 'object',
494
+ properties: {
495
+ includePaused: { type: 'boolean', description: 'Include paused tasks (default: true)' },
496
+ tag: { type: 'string', description: 'Filter by tag' },
497
+ },
498
+ },
499
+ handler: async ({ includePaused = true, tag }: any) => {
500
+ await this.load();
501
+ let tasks = Array.from(this.tasks.values());
502
+ if (!includePaused) tasks = tasks.filter((t) => !t.paused);
503
+ if (tag) tasks = tasks.filter((t) => t.tags.includes(tag));
504
+ tasks.sort((a, b) => new Date(a.nextRunAt).getTime() - new Date(b.nextRunAt).getTime());
505
+ return {
506
+ count: tasks.length,
507
+ tasks: tasks.map((t) => ({
508
+ id: t.id,
509
+ name: t.name,
510
+ frequency: t.frequency,
511
+ cronExpression: t.cronExpression ?? null,
512
+ nextRunAt: t.nextRunAt,
513
+ nextRunIn: this.humanDuration(new Date(t.nextRunAt).getTime() - Date.now()),
514
+ lastRunAt: t.lastRunAt ?? null,
515
+ lastStatus: t.lastStatus ?? null,
516
+ paused: t.paused,
517
+ runCount: t.runCount,
518
+ failCount: t.failCount,
519
+ tags: t.tags,
520
+ })),
521
+ };
522
+ },
523
+ },
524
+
525
+ // ── cron_cancel ─────────────────────────────────────────────────────────
526
+ {
527
+ name: 'cron_cancel',
528
+ description: 'Cancel and delete a scheduled task',
529
+ inputSchema: {
530
+ type: 'object',
531
+ properties: {
532
+ id: { type: 'string', description: 'Task ID' },
533
+ name: { type: 'string', description: 'Task name (used if ID not known)' },
534
+ },
535
+ },
536
+ handler: async ({ id, name }: any) => {
537
+ await this.load();
538
+ let taskId = id;
539
+ if (!taskId && name) {
540
+ for (const [tid, task] of this.tasks.entries()) {
541
+ if (task.name.toLowerCase().includes(name.toLowerCase())) {
542
+ taskId = tid;
543
+ break;
544
+ }
545
+ }
546
+ }
547
+ if (!taskId || !this.tasks.has(taskId)) return { error: 'Task not found.' };
548
+ const timer = this.timers.get(taskId);
549
+ if (timer) clearTimeout(timer);
550
+ this.timers.delete(taskId);
551
+ const task = this.tasks.get(taskId)!;
552
+ this.tasks.delete(taskId);
553
+ await this.save();
554
+ return { cancelled: true, id: taskId, name: task.name };
555
+ },
556
+ },
557
+
558
+ // ── cron_pause ──────────────────────────────────────────────────────────
559
+ {
560
+ name: 'cron_pause',
561
+ description: 'Pause or resume a scheduled task without deleting it',
562
+ inputSchema: {
563
+ type: 'object',
564
+ properties: {
565
+ id: { type: 'string', description: 'Task ID' },
566
+ paused: { type: 'boolean', description: 'true = pause, false = resume' },
567
+ },
568
+ required: ['id', 'paused'],
569
+ },
570
+ handler: async ({ id, paused }: any) => {
571
+ await this.load();
572
+ const task = this.tasks.get(id);
573
+ if (!task) return { error: `Task ${id} not found.` };
574
+ task.paused = paused;
575
+ if (paused) {
576
+ const timer = this.timers.get(id);
577
+ if (timer) clearTimeout(timer);
578
+ this.timers.delete(id);
579
+ } else {
580
+ this.scheduleTask(task);
581
+ }
582
+ await this.save();
583
+ return { id, name: task.name, paused };
584
+ },
585
+ },
586
+
587
+ // ── cron_history ────────────────────────────────────────────────────────
588
+ {
589
+ name: 'cron_history',
590
+ description: 'Get the run history for a scheduled task',
591
+ inputSchema: {
592
+ type: 'object',
593
+ properties: {
594
+ id: { type: 'string', description: 'Task ID' },
595
+ limit: { type: 'number', description: 'Max history entries (default: 10)' },
596
+ },
597
+ required: ['id'],
598
+ },
599
+ handler: async ({ id, limit = 10 }: any) => {
600
+ await this.load();
601
+ const task = this.tasks.get(id);
602
+ if (!task) return { error: `Task ${id} not found.` };
603
+ return {
604
+ id,
605
+ name: task.name,
606
+ runCount: task.runCount,
607
+ failCount: task.failCount,
608
+ successRate: task.runCount
609
+ ? `${Math.round(((task.runCount - task.failCount) / task.runCount) * 100)}%`
610
+ : 'N/A',
611
+ history: task.history.slice(0, limit),
612
+ };
613
+ },
614
+ },
615
+
616
+ // ── cron_run_now ─────────────────────────────────────────────────────────
617
+ {
618
+ name: 'cron_run_now',
619
+ description: 'Immediately trigger a scheduled task without waiting for its next run time',
620
+ inputSchema: {
621
+ type: 'object',
622
+ properties: {
623
+ id: { type: 'string', description: 'Task ID' },
624
+ },
625
+ required: ['id'],
626
+ },
627
+ handler: async ({ id }: any) => {
628
+ await this.load();
629
+ const task = this.tasks.get(id);
630
+ if (!task) return { error: `Task ${id} not found.` };
631
+ await this.runTask(task);
632
+ return { triggered: true, id, name: task.name, lastStatus: task.lastStatus };
633
+ },
634
+ },
635
+ ];
636
+ }
637
+
638
+ private humanDuration(ms: number): string {
639
+ if (ms < 0) return 'overdue';
640
+ const s = Math.floor(ms / 1000);
641
+ if (s < 60) return `${s}s`;
642
+ const m = Math.floor(s / 60);
643
+ if (m < 60) return `${m}m`;
644
+ const h = Math.floor(m / 60);
645
+ if (h < 24) return `${h}h ${m % 60}m`;
646
+ const d = Math.floor(h / 24);
647
+ return `${d}d ${h % 24}h`;
648
+ }
649
+ }