patchwork-os 0.2.0-alpha.8 → 0.2.0-beta.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 (581) hide show
  1. package/README.bridge.md +6 -0
  2. package/README.md +315 -35
  3. package/deploy/bootstrap-new-vps.sh +12 -12
  4. package/deploy/bootstrap-vps.sh +187 -0
  5. package/deploy/deploy-dashboard.sh +174 -0
  6. package/deploy/deploy-landing.sh +136 -0
  7. package/dist/activationMetrics.d.ts +67 -0
  8. package/dist/activationMetrics.js +255 -0
  9. package/dist/activationMetrics.js.map +1 -0
  10. package/dist/activityLog.d.ts +49 -0
  11. package/dist/activityLog.js +78 -0
  12. package/dist/activityLog.js.map +1 -1
  13. package/dist/approvalHttp.d.ts +49 -2
  14. package/dist/approvalHttp.js +217 -21
  15. package/dist/approvalHttp.js.map +1 -1
  16. package/dist/approvalInsights.d.ts +49 -0
  17. package/dist/approvalInsights.js +97 -0
  18. package/dist/approvalInsights.js.map +1 -0
  19. package/dist/approvalQueue.d.ts +27 -1
  20. package/dist/approvalQueue.js +123 -3
  21. package/dist/approvalQueue.js.map +1 -1
  22. package/dist/approvalSignals.d.ts +124 -0
  23. package/dist/approvalSignals.js +512 -0
  24. package/dist/approvalSignals.js.map +1 -0
  25. package/dist/automation.d.ts +57 -0
  26. package/dist/automation.js +156 -59
  27. package/dist/automation.js.map +1 -1
  28. package/dist/automationSuggestions.d.ts +79 -0
  29. package/dist/automationSuggestions.js +150 -0
  30. package/dist/automationSuggestions.js.map +1 -0
  31. package/dist/bridge.d.ts +3 -0
  32. package/dist/bridge.js +174 -143
  33. package/dist/bridge.js.map +1 -1
  34. package/dist/bridgeToken.js +57 -19
  35. package/dist/bridgeToken.js.map +1 -1
  36. package/dist/ccPermissions.d.ts +15 -0
  37. package/dist/ccPermissions.js +21 -4
  38. package/dist/ccPermissions.js.map +1 -1
  39. package/dist/claudeDriver.js +74 -16
  40. package/dist/claudeDriver.js.map +1 -1
  41. package/dist/claudeOrchestrator.d.ts +1 -1
  42. package/dist/claudeOrchestrator.js +14 -8
  43. package/dist/claudeOrchestrator.js.map +1 -1
  44. package/dist/commands/dashboard.js +1 -1
  45. package/dist/commands/dashboard.js.map +1 -1
  46. package/dist/commands/launchd.d.ts +2 -0
  47. package/dist/commands/launchd.js +94 -0
  48. package/dist/commands/launchd.js.map +1 -0
  49. package/dist/commands/patchworkInit.d.ts +8 -0
  50. package/dist/commands/patchworkInit.js +77 -11
  51. package/dist/commands/patchworkInit.js.map +1 -1
  52. package/dist/commands/recipe.d.ts +289 -0
  53. package/dist/commands/recipe.js +1359 -0
  54. package/dist/commands/recipe.js.map +1 -0
  55. package/dist/commands/recipeInstall.d.ts +150 -0
  56. package/dist/commands/recipeInstall.js +647 -0
  57. package/dist/commands/recipeInstall.js.map +1 -0
  58. package/dist/commands/tracesExport.d.ts +83 -0
  59. package/dist/commands/tracesExport.js +269 -0
  60. package/dist/commands/tracesExport.js.map +1 -0
  61. package/dist/commands/tracesImport.d.ts +56 -0
  62. package/dist/commands/tracesImport.js +161 -0
  63. package/dist/commands/tracesImport.js.map +1 -0
  64. package/dist/config.d.ts +22 -1
  65. package/dist/config.js +108 -9
  66. package/dist/config.js.map +1 -1
  67. package/dist/connectorRoutes.d.ts +43 -0
  68. package/dist/connectorRoutes.js +1609 -0
  69. package/dist/connectorRoutes.js.map +1 -0
  70. package/dist/connectors/asana.d.ts +198 -0
  71. package/dist/connectors/asana.js +679 -0
  72. package/dist/connectors/asana.js.map +1 -0
  73. package/dist/connectors/baseConnector.d.ts +153 -0
  74. package/dist/connectors/baseConnector.js +336 -0
  75. package/dist/connectors/baseConnector.js.map +1 -0
  76. package/dist/connectors/confluence.d.ts +111 -0
  77. package/dist/connectors/confluence.js +406 -0
  78. package/dist/connectors/confluence.js.map +1 -0
  79. package/dist/connectors/datadog.d.ts +116 -0
  80. package/dist/connectors/datadog.js +385 -0
  81. package/dist/connectors/datadog.js.map +1 -0
  82. package/dist/connectors/discord.d.ts +150 -0
  83. package/dist/connectors/discord.js +543 -0
  84. package/dist/connectors/discord.js.map +1 -0
  85. package/dist/connectors/fixtureLibrary.d.ts +21 -0
  86. package/dist/connectors/fixtureLibrary.js +70 -0
  87. package/dist/connectors/fixtureLibrary.js.map +1 -0
  88. package/dist/connectors/fixtureRecorder.d.ts +1 -0
  89. package/dist/connectors/fixtureRecorder.js +35 -0
  90. package/dist/connectors/fixtureRecorder.js.map +1 -0
  91. package/dist/connectors/github.js +17 -18
  92. package/dist/connectors/github.js.map +1 -1
  93. package/dist/connectors/gitlab.d.ts +180 -0
  94. package/dist/connectors/gitlab.js +582 -0
  95. package/dist/connectors/gitlab.js.map +1 -0
  96. package/dist/connectors/gmail.d.ts +4 -1
  97. package/dist/connectors/gmail.js +157 -27
  98. package/dist/connectors/gmail.js.map +1 -1
  99. package/dist/connectors/googleCalendar.d.ts +4 -1
  100. package/dist/connectors/googleCalendar.js +88 -25
  101. package/dist/connectors/googleCalendar.js.map +1 -1
  102. package/dist/connectors/googleDrive.d.ts +34 -0
  103. package/dist/connectors/googleDrive.js +321 -0
  104. package/dist/connectors/googleDrive.js.map +1 -0
  105. package/dist/connectors/htmlEscape.d.ts +5 -0
  106. package/dist/connectors/htmlEscape.js +13 -0
  107. package/dist/connectors/htmlEscape.js.map +1 -0
  108. package/dist/connectors/hubspot.d.ts +112 -0
  109. package/dist/connectors/hubspot.js +408 -0
  110. package/dist/connectors/hubspot.js.map +1 -0
  111. package/dist/connectors/intercom.d.ts +102 -0
  112. package/dist/connectors/intercom.js +402 -0
  113. package/dist/connectors/intercom.js.map +1 -0
  114. package/dist/connectors/jira.d.ts +98 -0
  115. package/dist/connectors/jira.js +379 -0
  116. package/dist/connectors/jira.js.map +1 -0
  117. package/dist/connectors/linear.js +30 -19
  118. package/dist/connectors/linear.js.map +1 -1
  119. package/dist/connectors/mcpOAuth.d.ts +3 -0
  120. package/dist/connectors/mcpOAuth.js +64 -10
  121. package/dist/connectors/mcpOAuth.js.map +1 -1
  122. package/dist/connectors/mockConnector.d.ts +28 -0
  123. package/dist/connectors/mockConnector.js +81 -0
  124. package/dist/connectors/mockConnector.js.map +1 -0
  125. package/dist/connectors/notion.d.ts +143 -0
  126. package/dist/connectors/notion.js +424 -0
  127. package/dist/connectors/notion.js.map +1 -0
  128. package/dist/connectors/oauthStateStore.d.ts +31 -0
  129. package/dist/connectors/oauthStateStore.js +52 -0
  130. package/dist/connectors/oauthStateStore.js.map +1 -0
  131. package/dist/connectors/pagerduty.d.ts +160 -0
  132. package/dist/connectors/pagerduty.js +464 -0
  133. package/dist/connectors/pagerduty.js.map +1 -0
  134. package/dist/connectors/sentry.js +5 -13
  135. package/dist/connectors/sentry.js.map +1 -1
  136. package/dist/connectors/slack.d.ts +16 -1
  137. package/dist/connectors/slack.js +155 -32
  138. package/dist/connectors/slack.js.map +1 -1
  139. package/dist/connectors/stripe.d.ts +116 -0
  140. package/dist/connectors/stripe.js +379 -0
  141. package/dist/connectors/stripe.js.map +1 -0
  142. package/dist/connectors/tokenStorage.d.ts +35 -0
  143. package/dist/connectors/tokenStorage.js +484 -0
  144. package/dist/connectors/tokenStorage.js.map +1 -0
  145. package/dist/connectors/zendesk.d.ts +104 -0
  146. package/dist/connectors/zendesk.js +442 -0
  147. package/dist/connectors/zendesk.js.map +1 -0
  148. package/dist/cors.d.ts +10 -0
  149. package/dist/cors.js +29 -0
  150. package/dist/cors.js.map +1 -0
  151. package/dist/decisionReplay.d.ts +72 -0
  152. package/dist/decisionReplay.js +92 -0
  153. package/dist/decisionReplay.js.map +1 -0
  154. package/dist/decisionTraceLog.d.ts +6 -0
  155. package/dist/decisionTraceLog.js +54 -2
  156. package/dist/decisionTraceLog.js.map +1 -1
  157. package/dist/drivers/gemini/index.d.ts +5 -1
  158. package/dist/drivers/gemini/index.js +39 -5
  159. package/dist/drivers/gemini/index.js.map +1 -1
  160. package/dist/drivers/index.d.ts +5 -0
  161. package/dist/drivers/index.js +1 -1
  162. package/dist/drivers/index.js.map +1 -1
  163. package/dist/featureFlags.d.ts +79 -0
  164. package/dist/featureFlags.js +208 -0
  165. package/dist/featureFlags.js.map +1 -0
  166. package/dist/fp/automationInterpreter.js +26 -21
  167. package/dist/fp/automationInterpreter.js.map +1 -1
  168. package/dist/fp/automationProgram.d.ts +1 -1
  169. package/dist/fp/automationProgram.js.map +1 -1
  170. package/dist/fp/automationState.js +4 -1
  171. package/dist/fp/automationState.js.map +1 -1
  172. package/dist/fp/policyParser.js +21 -1
  173. package/dist/fp/policyParser.js.map +1 -1
  174. package/dist/inboxRoutes.d.ts +22 -0
  175. package/dist/inboxRoutes.js +114 -0
  176. package/dist/inboxRoutes.js.map +1 -0
  177. package/dist/index.js +1400 -201
  178. package/dist/index.js.map +1 -1
  179. package/dist/installGuard.d.ts +25 -0
  180. package/dist/installGuard.js +48 -0
  181. package/dist/installGuard.js.map +1 -0
  182. package/dist/mcpRoutes.d.ts +37 -0
  183. package/dist/mcpRoutes.js +76 -0
  184. package/dist/mcpRoutes.js.map +1 -0
  185. package/dist/oauth.d.ts +7 -1
  186. package/dist/oauth.js +201 -39
  187. package/dist/oauth.js.map +1 -1
  188. package/dist/oauthRoutes.d.ts +32 -0
  189. package/dist/oauthRoutes.js +124 -0
  190. package/dist/oauthRoutes.js.map +1 -0
  191. package/dist/orchestrator/orchestratorBridge.js +2 -2
  192. package/dist/orchestrator/orchestratorBridge.js.map +1 -1
  193. package/dist/patchworkConfig.d.ts +16 -0
  194. package/dist/patchworkConfig.js +1 -1
  195. package/dist/patchworkConfig.js.map +1 -1
  196. package/dist/pluginLoader.d.ts +28 -0
  197. package/dist/pluginLoader.js +77 -11
  198. package/dist/pluginLoader.js.map +1 -1
  199. package/dist/pluginWatcher.js +8 -3
  200. package/dist/pluginWatcher.js.map +1 -1
  201. package/dist/preToolUseHook.d.ts +12 -0
  202. package/dist/preToolUseHook.js +23 -0
  203. package/dist/preToolUseHook.js.map +1 -1
  204. package/dist/recipeOrchestration.d.ts +121 -0
  205. package/dist/recipeOrchestration.js +955 -0
  206. package/dist/recipeOrchestration.js.map +1 -0
  207. package/dist/recipeRoutes.d.ts +180 -0
  208. package/dist/recipeRoutes.js +1345 -0
  209. package/dist/recipeRoutes.js.map +1 -0
  210. package/dist/recipes/RecipeOrchestrator.d.ts +40 -0
  211. package/dist/recipes/RecipeOrchestrator.js +51 -0
  212. package/dist/recipes/RecipeOrchestrator.js.map +1 -0
  213. package/dist/recipes/agentExecutor.d.ts +29 -0
  214. package/dist/recipes/agentExecutor.js +49 -0
  215. package/dist/recipes/agentExecutor.js.map +1 -0
  216. package/dist/recipes/chainedRunner.d.ts +191 -0
  217. package/dist/recipes/chainedRunner.js +759 -0
  218. package/dist/recipes/chainedRunner.js.map +1 -0
  219. package/dist/recipes/compiler.js +3 -3
  220. package/dist/recipes/compiler.js.map +1 -1
  221. package/dist/recipes/dependencyGraph.d.ts +39 -0
  222. package/dist/recipes/dependencyGraph.js +199 -0
  223. package/dist/recipes/dependencyGraph.js.map +1 -0
  224. package/dist/recipes/disabledMarkers.d.ts +48 -0
  225. package/dist/recipes/disabledMarkers.js +52 -0
  226. package/dist/recipes/disabledMarkers.js.map +1 -0
  227. package/dist/recipes/installer.js +3 -3
  228. package/dist/recipes/installer.js.map +1 -1
  229. package/dist/recipes/legacyRecipeCompat.d.ts +10 -0
  230. package/dist/recipes/legacyRecipeCompat.js +131 -0
  231. package/dist/recipes/legacyRecipeCompat.js.map +1 -0
  232. package/dist/recipes/manifest.d.ts +47 -0
  233. package/dist/recipes/manifest.js +156 -0
  234. package/dist/recipes/manifest.js.map +1 -0
  235. package/dist/recipes/migrationWarnings.d.ts +12 -0
  236. package/dist/recipes/migrationWarnings.js +44 -0
  237. package/dist/recipes/migrationWarnings.js.map +1 -0
  238. package/dist/recipes/migrations/index.d.ts +24 -0
  239. package/dist/recipes/migrations/index.js +55 -0
  240. package/dist/recipes/migrations/index.js.map +1 -0
  241. package/dist/recipes/migrations/types.d.ts +28 -0
  242. package/dist/recipes/migrations/types.js +2 -0
  243. package/dist/recipes/migrations/types.js.map +1 -0
  244. package/dist/recipes/migrations/v1.d.ts +11 -0
  245. package/dist/recipes/migrations/v1.js +18 -0
  246. package/dist/recipes/migrations/v1.js.map +1 -0
  247. package/dist/recipes/names.d.ts +40 -0
  248. package/dist/recipes/names.js +66 -0
  249. package/dist/recipes/names.js.map +1 -0
  250. package/dist/recipes/nestedRecipeStep.d.ts +58 -0
  251. package/dist/recipes/nestedRecipeStep.js +95 -0
  252. package/dist/recipes/nestedRecipeStep.js.map +1 -0
  253. package/dist/recipes/outputRegistry.d.ts +28 -0
  254. package/dist/recipes/outputRegistry.js +52 -0
  255. package/dist/recipes/outputRegistry.js.map +1 -0
  256. package/dist/recipes/parser.js +4 -1
  257. package/dist/recipes/parser.js.map +1 -1
  258. package/dist/recipes/replayRun.d.ts +62 -0
  259. package/dist/recipes/replayRun.js +97 -0
  260. package/dist/recipes/replayRun.js.map +1 -0
  261. package/dist/recipes/resolveRecipePath.d.ts +69 -0
  262. package/dist/recipes/resolveRecipePath.js +202 -0
  263. package/dist/recipes/resolveRecipePath.js.map +1 -0
  264. package/dist/recipes/scheduler.d.ts +23 -7
  265. package/dist/recipes/scheduler.js +225 -45
  266. package/dist/recipes/scheduler.js.map +1 -1
  267. package/dist/recipes/schema.d.ts +17 -2
  268. package/dist/recipes/schemaGenerator.d.ts +28 -0
  269. package/dist/recipes/schemaGenerator.js +565 -0
  270. package/dist/recipes/schemaGenerator.js.map +1 -0
  271. package/dist/recipes/stepObservation.d.ts +44 -0
  272. package/dist/recipes/stepObservation.js +232 -0
  273. package/dist/recipes/stepObservation.js.map +1 -0
  274. package/dist/recipes/templateEngine.d.ts +62 -0
  275. package/dist/recipes/templateEngine.js +201 -0
  276. package/dist/recipes/templateEngine.js.map +1 -0
  277. package/dist/recipes/toolRegistry.d.ts +186 -0
  278. package/dist/recipes/toolRegistry.js +309 -0
  279. package/dist/recipes/toolRegistry.js.map +1 -0
  280. package/dist/recipes/tools/asana.d.ts +16 -0
  281. package/dist/recipes/tools/asana.js +524 -0
  282. package/dist/recipes/tools/asana.js.map +1 -0
  283. package/dist/recipes/tools/calendar.d.ts +6 -0
  284. package/dist/recipes/tools/calendar.js +61 -0
  285. package/dist/recipes/tools/calendar.js.map +1 -0
  286. package/dist/recipes/tools/confluence.d.ts +6 -0
  287. package/dist/recipes/tools/confluence.js +254 -0
  288. package/dist/recipes/tools/confluence.js.map +1 -0
  289. package/dist/recipes/tools/datadog.d.ts +6 -0
  290. package/dist/recipes/tools/datadog.js +239 -0
  291. package/dist/recipes/tools/datadog.js.map +1 -0
  292. package/dist/recipes/tools/diagnostics.d.ts +6 -0
  293. package/dist/recipes/tools/diagnostics.js +36 -0
  294. package/dist/recipes/tools/diagnostics.js.map +1 -0
  295. package/dist/recipes/tools/discord.d.ts +18 -0
  296. package/dist/recipes/tools/discord.js +254 -0
  297. package/dist/recipes/tools/discord.js.map +1 -0
  298. package/dist/recipes/tools/file.d.ts +12 -0
  299. package/dist/recipes/tools/file.js +174 -0
  300. package/dist/recipes/tools/file.js.map +1 -0
  301. package/dist/recipes/tools/git.d.ts +6 -0
  302. package/dist/recipes/tools/git.js +63 -0
  303. package/dist/recipes/tools/git.js.map +1 -0
  304. package/dist/recipes/tools/github.d.ts +6 -0
  305. package/dist/recipes/tools/github.js +116 -0
  306. package/dist/recipes/tools/github.js.map +1 -0
  307. package/dist/recipes/tools/gitlab.d.ts +11 -0
  308. package/dist/recipes/tools/gitlab.js +285 -0
  309. package/dist/recipes/tools/gitlab.js.map +1 -0
  310. package/dist/recipes/tools/gmail.d.ts +6 -0
  311. package/dist/recipes/tools/gmail.js +434 -0
  312. package/dist/recipes/tools/gmail.js.map +1 -0
  313. package/dist/recipes/tools/googleDrive.d.ts +1 -0
  314. package/dist/recipes/tools/googleDrive.js +55 -0
  315. package/dist/recipes/tools/googleDrive.js.map +1 -0
  316. package/dist/recipes/tools/hubspot.d.ts +6 -0
  317. package/dist/recipes/tools/hubspot.js +232 -0
  318. package/dist/recipes/tools/hubspot.js.map +1 -0
  319. package/dist/recipes/tools/index.d.ts +30 -0
  320. package/dist/recipes/tools/index.js +33 -0
  321. package/dist/recipes/tools/index.js.map +1 -0
  322. package/dist/recipes/tools/intercom.d.ts +6 -0
  323. package/dist/recipes/tools/intercom.js +226 -0
  324. package/dist/recipes/tools/intercom.js.map +1 -0
  325. package/dist/recipes/tools/jira.d.ts +14 -0
  326. package/dist/recipes/tools/jira.js +369 -0
  327. package/dist/recipes/tools/jira.js.map +1 -0
  328. package/dist/recipes/tools/linear.d.ts +7 -0
  329. package/dist/recipes/tools/linear.js +307 -0
  330. package/dist/recipes/tools/linear.js.map +1 -0
  331. package/dist/recipes/tools/meetingNotes.d.ts +21 -0
  332. package/dist/recipes/tools/meetingNotes.js +701 -0
  333. package/dist/recipes/tools/meetingNotes.js.map +1 -0
  334. package/dist/recipes/tools/notion.d.ts +6 -0
  335. package/dist/recipes/tools/notion.js +278 -0
  336. package/dist/recipes/tools/notion.js.map +1 -0
  337. package/dist/recipes/tools/pagerduty.d.ts +15 -0
  338. package/dist/recipes/tools/pagerduty.js +451 -0
  339. package/dist/recipes/tools/pagerduty.js.map +1 -0
  340. package/dist/recipes/tools/sentry.d.ts +12 -0
  341. package/dist/recipes/tools/sentry.js +73 -0
  342. package/dist/recipes/tools/sentry.js.map +1 -0
  343. package/dist/recipes/tools/slack.d.ts +6 -0
  344. package/dist/recipes/tools/slack.js +82 -0
  345. package/dist/recipes/tools/slack.js.map +1 -0
  346. package/dist/recipes/tools/stripe.d.ts +6 -0
  347. package/dist/recipes/tools/stripe.js +265 -0
  348. package/dist/recipes/tools/stripe.js.map +1 -0
  349. package/dist/recipes/tools/zendesk.d.ts +6 -0
  350. package/dist/recipes/tools/zendesk.js +245 -0
  351. package/dist/recipes/tools/zendesk.js.map +1 -0
  352. package/dist/recipes/validation.d.ts +13 -0
  353. package/dist/recipes/validation.js +617 -0
  354. package/dist/recipes/validation.js.map +1 -0
  355. package/dist/recipes/yamlRunner.d.ts +116 -1
  356. package/dist/recipes/yamlRunner.js +1000 -401
  357. package/dist/recipes/yamlRunner.js.map +1 -1
  358. package/dist/recipesHttp.d.ts +137 -6
  359. package/dist/recipesHttp.js +941 -29
  360. package/dist/recipesHttp.js.map +1 -1
  361. package/dist/riskTier.js +7 -1
  362. package/dist/riskTier.js.map +1 -1
  363. package/dist/runLog.d.ts +100 -1
  364. package/dist/runLog.js +258 -5
  365. package/dist/runLog.js.map +1 -1
  366. package/dist/schemas/dry-run-plan.v1.json +139 -0
  367. package/dist/schemas/recipe.v1.json +684 -0
  368. package/dist/server.d.ts +121 -8
  369. package/dist/server.js +538 -735
  370. package/dist/server.js.map +1 -1
  371. package/dist/ssrfGuard.d.ts +54 -0
  372. package/dist/ssrfGuard.js +122 -0
  373. package/dist/ssrfGuard.js.map +1 -0
  374. package/dist/streamableHttp.d.ts +39 -1
  375. package/dist/streamableHttp.js +128 -17
  376. package/dist/streamableHttp.js.map +1 -1
  377. package/dist/tokenUsageTracker.d.ts +33 -0
  378. package/dist/tokenUsageTracker.js +146 -0
  379. package/dist/tokenUsageTracker.js.map +1 -0
  380. package/dist/tools/activityLog.d.ts +2 -0
  381. package/dist/tools/addLinearComment.d.ts +1 -0
  382. package/dist/tools/addLinearComment.js +4 -2
  383. package/dist/tools/addLinearComment.js.map +1 -1
  384. package/dist/tools/batchLsp.d.ts +3 -0
  385. package/dist/tools/bridgeDoctor.d.ts +1 -0
  386. package/dist/tools/bridgeDoctor.js +2 -2
  387. package/dist/tools/bridgeDoctor.js.map +1 -1
  388. package/dist/tools/bridgeStatus.d.ts +1 -0
  389. package/dist/tools/cancelClaudeTask.d.ts +2 -0
  390. package/dist/tools/cancelClaudeTask.js +1 -0
  391. package/dist/tools/cancelClaudeTask.js.map +1 -1
  392. package/dist/tools/checkDocumentDirty.d.ts +1 -0
  393. package/dist/tools/clipboard.d.ts +2 -0
  394. package/dist/tools/closeTabs.d.ts +2 -0
  395. package/dist/tools/codeLens.d.ts +1 -0
  396. package/dist/tools/contextBundle.d.ts +1 -0
  397. package/dist/tools/createIssueFromAIComment.d.ts +1 -0
  398. package/dist/tools/createLinearIssue.d.ts +1 -0
  399. package/dist/tools/ctxGetTaskContext.d.ts +1 -0
  400. package/dist/tools/ctxQueryTraces.d.ts +1 -0
  401. package/dist/tools/ctxSaveTrace.d.ts +1 -0
  402. package/dist/tools/debug.d.ts +4 -0
  403. package/dist/tools/decorations.d.ts +2 -0
  404. package/dist/tools/documentLinks.d.ts +1 -0
  405. package/dist/tools/editText.d.ts +1 -0
  406. package/dist/tools/enrichCommit.d.ts +1 -0
  407. package/dist/tools/enrichStackTrace.d.ts +1 -0
  408. package/dist/tools/explainDiagnostic.d.ts +1 -0
  409. package/dist/tools/explainSymbol.d.ts +1 -0
  410. package/dist/tools/fetchCalendarEvents.d.ts +1 -0
  411. package/dist/tools/fetchGithubIssue.d.ts +1 -0
  412. package/dist/tools/fetchGithubPR.d.ts +1 -0
  413. package/dist/tools/fetchLinearIssue.d.ts +1 -0
  414. package/dist/tools/fetchSentryIssue.d.ts +1 -0
  415. package/dist/tools/fetchSlackProfile.d.ts +1 -0
  416. package/dist/tools/fetchSlackProfile.js +4 -1
  417. package/dist/tools/fetchSlackProfile.js.map +1 -1
  418. package/dist/tools/fileOperations.d.ts +3 -0
  419. package/dist/tools/fileWatcher.d.ts +2 -0
  420. package/dist/tools/findFiles.d.ts +1 -0
  421. package/dist/tools/findRelatedTests.d.ts +1 -0
  422. package/dist/tools/fixAllLintErrors.d.ts +1 -0
  423. package/dist/tools/foldingRanges.d.ts +1 -0
  424. package/dist/tools/formatDocument.d.ts +1 -0
  425. package/dist/tools/generateTests.d.ts +1 -0
  426. package/dist/tools/getAIComments.d.ts +1 -0
  427. package/dist/tools/getAnalyticsReport.d.ts +1 -0
  428. package/dist/tools/getArchitectureContext.d.ts +1 -0
  429. package/dist/tools/getBufferContent.d.ts +1 -0
  430. package/dist/tools/getChangeImpact.d.ts +1 -0
  431. package/dist/tools/getClaudeTaskStatus.d.ts +2 -0
  432. package/dist/tools/getClaudeTaskStatus.js +1 -0
  433. package/dist/tools/getClaudeTaskStatus.js.map +1 -1
  434. package/dist/tools/getCodeCoverage.d.ts +1 -0
  435. package/dist/tools/getCommitsForIssue.d.ts +1 -0
  436. package/dist/tools/getConnectorStatus.d.ts +1 -0
  437. package/dist/tools/getCurrentSelection.d.ts +2 -0
  438. package/dist/tools/getDebugState.d.ts +1 -0
  439. package/dist/tools/getDependencyTree.d.ts +1 -0
  440. package/dist/tools/getDiagnostics.d.ts +1 -0
  441. package/dist/tools/getDiffFromHandoff.d.ts +1 -0
  442. package/dist/tools/getDocumentSymbols.d.ts +25 -0
  443. package/dist/tools/getDocumentSymbols.js +74 -8
  444. package/dist/tools/getDocumentSymbols.js.map +1 -1
  445. package/dist/tools/getFileTree.d.ts +1 -0
  446. package/dist/tools/getGitDiff.d.ts +1 -0
  447. package/dist/tools/getGitHotspots.d.ts +1 -0
  448. package/dist/tools/getGitLog.d.ts +1 -0
  449. package/dist/tools/getGitStatus.d.ts +1 -0
  450. package/dist/tools/getImportTree.d.ts +1 -0
  451. package/dist/tools/getImportedSignatures.d.ts +1 -0
  452. package/dist/tools/getOpenEditors.d.ts +1 -0
  453. package/dist/tools/getPRTemplate.d.ts +1 -0
  454. package/dist/tools/getProjectContext.d.ts +1 -0
  455. package/dist/tools/getProjectInfo.d.ts +1 -0
  456. package/dist/tools/getSecurityAdvisories.d.ts +1 -0
  457. package/dist/tools/getSecurityAdvisories.js +10 -1
  458. package/dist/tools/getSecurityAdvisories.js.map +1 -1
  459. package/dist/tools/getSessionUsage.d.ts +4 -0
  460. package/dist/tools/getSessionUsage.js +3 -0
  461. package/dist/tools/getSessionUsage.js.map +1 -1
  462. package/dist/tools/getSymbolHistory.d.ts +1 -0
  463. package/dist/tools/getToolCapabilities.d.ts +1 -0
  464. package/dist/tools/getTypeSignature.d.ts +1 -0
  465. package/dist/tools/getWorkspaceFolders.d.ts +1 -0
  466. package/dist/tools/getWorkspaceSettings.d.ts +1 -0
  467. package/dist/tools/gitHistory.d.ts +2 -0
  468. package/dist/tools/gitWrite.d.ts +11 -0
  469. package/dist/tools/github/actions.d.ts +2 -0
  470. package/dist/tools/github/actions.js +4 -2
  471. package/dist/tools/github/actions.js.map +1 -1
  472. package/dist/tools/github/composite.d.ts +342 -0
  473. package/dist/tools/github/composite.js +343 -0
  474. package/dist/tools/github/composite.js.map +1 -0
  475. package/dist/tools/github/index.d.ts +1 -0
  476. package/dist/tools/github/index.js +1 -0
  477. package/dist/tools/github/index.js.map +1 -1
  478. package/dist/tools/github/issues.d.ts +4 -0
  479. package/dist/tools/github/issues.js +8 -4
  480. package/dist/tools/github/issues.js.map +1 -1
  481. package/dist/tools/github/pr.d.ts +7 -0
  482. package/dist/tools/github/pr.js +50 -12
  483. package/dist/tools/github/pr.js.map +1 -1
  484. package/dist/tools/handoffNote.d.ts +4 -0
  485. package/dist/tools/handoffNote.js +2 -0
  486. package/dist/tools/handoffNote.js.map +1 -1
  487. package/dist/tools/hoverAtCursor.d.ts +1 -0
  488. package/dist/tools/httpClient.d.ts +2 -0
  489. package/dist/tools/index.d.ts +8 -0
  490. package/dist/tools/index.js +47 -8
  491. package/dist/tools/index.js.map +1 -1
  492. package/dist/tools/inlayHints.d.ts +1 -0
  493. package/dist/tools/launchQuickTask.d.ts +2 -0
  494. package/dist/tools/launchQuickTask.js +1 -0
  495. package/dist/tools/launchQuickTask.js.map +1 -1
  496. package/dist/tools/listClaudeTasks.d.ts +2 -0
  497. package/dist/tools/listClaudeTasks.js +1 -0
  498. package/dist/tools/listClaudeTasks.js.map +1 -1
  499. package/dist/tools/listTerminals.d.ts +1 -0
  500. package/dist/tools/lsp.d.ts +14 -0
  501. package/dist/tools/navigateToSymbolByName.d.ts +1 -0
  502. package/dist/tools/openDiff.d.ts +1 -0
  503. package/dist/tools/openFile.d.ts +1 -0
  504. package/dist/tools/openInBrowser.d.ts +1 -0
  505. package/dist/tools/organizeImports.d.ts +1 -0
  506. package/dist/tools/performanceReport.d.ts +1 -0
  507. package/dist/tools/planPersistence.d.ts +5 -0
  508. package/dist/tools/previewEdit.d.ts +1 -0
  509. package/dist/tools/refactorAnalyze.d.ts +1 -0
  510. package/dist/tools/refactorPreview.d.ts +2 -0
  511. package/dist/tools/refactorPreview.js +1 -0
  512. package/dist/tools/refactorPreview.js.map +1 -1
  513. package/dist/tools/replaceBlock.d.ts +1 -0
  514. package/dist/tools/resumeClaudeTask.d.ts +2 -0
  515. package/dist/tools/resumeClaudeTask.js +1 -0
  516. package/dist/tools/resumeClaudeTask.js.map +1 -1
  517. package/dist/tools/runClaudeTask.d.ts +2 -0
  518. package/dist/tools/runClaudeTask.js +1 -0
  519. package/dist/tools/runClaudeTask.js.map +1 -1
  520. package/dist/tools/runCommand.d.ts +1 -0
  521. package/dist/tools/runTests.d.ts +1 -0
  522. package/dist/tools/saveDocument.d.ts +1 -0
  523. package/dist/tools/screenshotAndAnnotate.d.ts +1 -0
  524. package/dist/tools/searchAndReplace.d.ts +1 -0
  525. package/dist/tools/searchTools.d.ts +1 -0
  526. package/dist/tools/searchTools.js +1 -1
  527. package/dist/tools/searchTools.js.map +1 -1
  528. package/dist/tools/searchWorkspace.d.ts +1 -0
  529. package/dist/tools/selectionRanges.d.ts +1 -0
  530. package/dist/tools/semanticTokens.d.ts +1 -0
  531. package/dist/tools/setActiveWorkspaceFolder.d.ts +1 -0
  532. package/dist/tools/signatureHelp.d.ts +1 -0
  533. package/dist/tools/slackListChannels.d.ts +1 -0
  534. package/dist/tools/slackListChannels.js.map +1 -1
  535. package/dist/tools/slackPostMessage.d.ts +1 -0
  536. package/dist/tools/slackPostMessage.js +11 -6
  537. package/dist/tools/slackPostMessage.js.map +1 -1
  538. package/dist/tools/terminal.d.ts +6 -0
  539. package/dist/tools/testTraceToSource.d.ts +1 -0
  540. package/dist/tools/testTraceToSource.js +2 -2
  541. package/dist/tools/testTraceToSource.js.map +1 -1
  542. package/dist/tools/transaction.d.ts +23 -0
  543. package/dist/tools/transaction.js +29 -0
  544. package/dist/tools/transaction.js.map +1 -1
  545. package/dist/tools/typeHierarchy.d.ts +1 -0
  546. package/dist/tools/updateLinearIssue.d.ts +1 -0
  547. package/dist/tools/updateLinearIssue.js +20 -6
  548. package/dist/tools/updateLinearIssue.js.map +1 -1
  549. package/dist/tools/utils.d.ts +2 -0
  550. package/dist/tools/utils.js.map +1 -1
  551. package/dist/tools/vscodeCommands.d.ts +2 -0
  552. package/dist/tools/vscodeTasks.d.ts +2 -0
  553. package/dist/tools/workspaceSettings.d.ts +1 -0
  554. package/dist/traceEncryption.d.ts +46 -0
  555. package/dist/traceEncryption.js +124 -0
  556. package/dist/traceEncryption.js.map +1 -0
  557. package/dist/transport.d.ts +46 -1
  558. package/dist/transport.js +173 -19
  559. package/dist/transport.js.map +1 -1
  560. package/package.json +30 -8
  561. package/scripts/mcp-stdio-shim.cjs +19 -3
  562. package/scripts/start-all.sh +30 -1
  563. package/templates/automation-policies/recipe-authoring.json +25 -0
  564. package/templates/automation-policy.example.json +6 -0
  565. package/templates/co.patchwork-os.bridge.plist +34 -0
  566. package/templates/policies/README.md +72 -0
  567. package/templates/policies/conservative.json +14 -0
  568. package/templates/policies/developer.json +14 -0
  569. package/templates/policies/headless-ci.json +24 -0
  570. package/templates/policies/personal-assistant.json +15 -0
  571. package/templates/policies/regulated-industry.json +18 -0
  572. package/templates/recipes/lint-on-save.yaml +1 -2
  573. package/templates/recipes/morning-brief-slack.yaml +57 -0
  574. package/templates/recipes/morning-brief.yaml +2 -2
  575. package/templates/recipes/project-health-check.yaml +50 -0
  576. package/templates/recipes/webhook/README.md +70 -0
  577. package/templates/recipes/webhook/capture-thought.yaml +26 -0
  578. package/templates/recipes/webhook/customer-escalation.yaml +49 -0
  579. package/templates/recipes/webhook/incident-intake.yaml +46 -0
  580. package/templates/recipes/webhook/meeting-prep.yaml +48 -0
  581. package/templates/recipes/webhook/morning-brief.yaml +57 -0
@@ -0,0 +1,202 @@
1
+ /**
2
+ * resolveRecipePath — recipe-runner path jail.
3
+ *
4
+ * Closes G-security F-01 (CRITICAL — `file.read/write/append` accept any
5
+ * absolute path), F-02 (CRITICAL — template-substituted vars escape via
6
+ * `..`), and the R2 C-1 chained-runner third-substitution-site gap.
7
+ *
8
+ * Mirrors the symlink-walking strategy from `src/tools/utils.ts:104-200`
9
+ * (`resolveFilePath`) but operates against an allowlist of recipe-roots
10
+ * rather than a single workspace root:
11
+ *
12
+ * - `~/.patchwork/` (always allowed — recipe install dir)
13
+ * - the bridge / CLI workspace (always allowed — passed in via `opts.workspace`)
14
+ * - `os.tmpdir()` (OFF by default; opt-in via the
15
+ * `CLAUDE_IDE_BRIDGE_RECIPE_TMP_JAIL=1`
16
+ * env var, per R2 C-2 maintainer decision)
17
+ *
18
+ * On any escape (null byte, segment outside all roots, symlink target
19
+ * outside roots, hardlink on a write target) the helper throws an `Error`
20
+ * with `err.code = "recipe_path_jail_escape"`. Callers and tests must
21
+ * assert on `err.code`, never on message text (R2 M-4).
22
+ *
23
+ * Defense-in-depth — apply at every layer:
24
+ * - `src/recipes/tools/file.ts` (per-tool execute())
25
+ * - `src/recipes/yamlRunner.ts:976-994` (default StepDeps file ops)
26
+ * - `src/recipes/yamlRunner.ts:642` (post-render path snapshot)
27
+ * - `src/recipes/yamlRunner.ts:1252-1262` (chained-runner executeTool)
28
+ * - `src/recipes/chainedRunner.ts:194-205` (template-substitution site)
29
+ * - `src/recipeRoutes.ts:131-138 :172-181` (HTTP vars validator)
30
+ * - `src/commands/recipe.ts:1080-1102` (CLI warn on out-of-jail recipe ref)
31
+ */
32
+ import fs from "node:fs";
33
+ import os from "node:os";
34
+ import path from "node:path";
35
+ /** Build a jail error with the canonical code. Never expose internals via message-matching. */
36
+ function jailError(message) {
37
+ const err = new Error(message);
38
+ err.code = "recipe_path_jail_escape";
39
+ return err;
40
+ }
41
+ /** Expand a leading `~/` segment using `os.homedir()` (or the test override). */
42
+ function expandHome(p, homeDir) {
43
+ if (p === "~")
44
+ return homeDir;
45
+ if (p.startsWith("~/"))
46
+ return path.join(homeDir, p.slice(2));
47
+ return p;
48
+ }
49
+ /** Compute the active jail roots given the runtime opts. */
50
+ function jailRoots(opts) {
51
+ const homeDir = opts.homeDir ?? os.homedir();
52
+ const allowTmp = opts.allowTmp ?? process.env.CLAUDE_IDE_BRIDGE_RECIPE_TMP_JAIL === "1";
53
+ const workspace = opts.workspace ?? process.cwd();
54
+ const roots = [path.resolve(homeDir, ".patchwork"), path.resolve(workspace)];
55
+ if (allowTmp) {
56
+ // On macOS `os.tmpdir()` returns `/var/folders/...` but the conventional
57
+ // `/tmp` symlink points at `/private/tmp` — we expose both so a recipe
58
+ // (or a legacy test) that hard-codes `/tmp/...` resolves cleanly. The
59
+ // symlink-aware realpath check below will still reject anything whose
60
+ // physical target is outside both roots.
61
+ roots.push(path.resolve(os.tmpdir()));
62
+ roots.push("/tmp");
63
+ }
64
+ // Dedupe — workspace==tmpdir on some CI runners would double-count and
65
+ // confuse the "outside all roots" reject branch.
66
+ return Array.from(new Set(roots));
67
+ }
68
+ /** True if `target` is inside (or equal to) any allowed jail root. */
69
+ function isInsideAnyRoot(target, roots) {
70
+ for (const root of roots) {
71
+ if (target === root)
72
+ return true;
73
+ if (target.startsWith(root + path.sep))
74
+ return true;
75
+ }
76
+ return false;
77
+ }
78
+ /**
79
+ * Walk up the ancestor chain of a (possibly non-existent) path, returning
80
+ * the realpath of the first ancestor that exists on disk plus the unresolved
81
+ * suffix. Mirrors `src/tools/utils.ts:130-177` so a symlink anywhere along
82
+ * the chain (including the bridge / install dir) is followed before the
83
+ * containment check.
84
+ */
85
+ function realpathOrAncestor(p) {
86
+ try {
87
+ return fs.realpathSync(p);
88
+ }
89
+ catch {
90
+ let ancestor = path.dirname(p);
91
+ const suffix = [path.basename(p)];
92
+ while (ancestor !== path.dirname(ancestor)) {
93
+ try {
94
+ const realAncestor = fs.realpathSync(ancestor);
95
+ return path.join(realAncestor, ...suffix);
96
+ }
97
+ catch {
98
+ suffix.unshift(path.basename(ancestor));
99
+ ancestor = path.dirname(ancestor);
100
+ }
101
+ }
102
+ // Reached fs root without finding a real ancestor — fail closed; the
103
+ // caller will translate this to a jail-escape rather than skip the
104
+ // containment check.
105
+ throw new Error(`no real ancestor found for "${p}"`);
106
+ }
107
+ }
108
+ /**
109
+ * Resolve a recipe-supplied path, expanding `~/`, normalising, and asserting
110
+ * the result lives inside one of the jail roots after symlink resolution.
111
+ *
112
+ * Throws `RecipePathJailError` (code `"recipe_path_jail_escape"`) on any
113
+ * containment violation. Callers should propagate the error unchanged so
114
+ * tests can assert on `err.code`.
115
+ */
116
+ export function resolveRecipePath(rawPath, opts = {}) {
117
+ if (typeof rawPath !== "string") {
118
+ throw jailError("recipe path must be a string");
119
+ }
120
+ if (rawPath.length === 0) {
121
+ throw jailError("recipe path must not be empty");
122
+ }
123
+ if (rawPath.includes("\x00")) {
124
+ throw jailError("recipe path must not contain null bytes");
125
+ }
126
+ const homeDir = opts.homeDir ?? os.homedir();
127
+ const expanded = expandHome(rawPath, homeDir);
128
+ const resolved = path.isAbsolute(expanded)
129
+ ? path.resolve(expanded)
130
+ : path.resolve(opts.workspace ?? process.cwd(), expanded);
131
+ const roots = jailRoots(opts);
132
+ // Lexical containment first — cheap reject for `..` segments resolving
133
+ // outside any root before we do any FS calls.
134
+ if (!isInsideAnyRoot(resolved, roots)) {
135
+ throw jailError(`recipe path "${rawPath}" resolves outside the allowed jail roots`);
136
+ }
137
+ // Symlink-aware re-check. We resolve the realpath of every existing
138
+ // ancestor so a link at any level (including a freshly-installed recipe
139
+ // dir pointing at `/tmp`) cannot bypass the lexical check above.
140
+ let real;
141
+ try {
142
+ real = realpathOrAncestor(resolved);
143
+ }
144
+ catch (err) {
145
+ throw jailError(`recipe path "${rawPath}" failed symlink resolution: ${err instanceof Error ? err.message : String(err)}`);
146
+ }
147
+ const realRoots = [];
148
+ for (const root of roots) {
149
+ try {
150
+ realRoots.push(fs.realpathSync(root));
151
+ }
152
+ catch {
153
+ // Root does not exist yet (e.g. ~/.patchwork on a fresh install).
154
+ // Use the resolved (lexical) form — `mkdirSync({recursive:true})`
155
+ // will create it inside the lexical jail anyway, and the symlink
156
+ // walk above already confirmed nothing on disk redirects out.
157
+ realRoots.push(root);
158
+ }
159
+ }
160
+ if (!isInsideAnyRoot(real, realRoots)) {
161
+ throw jailError(`recipe path "${rawPath}" escapes jail via symlink (real target "${real}")`);
162
+ }
163
+ // Hardlink guard for write paths — same rationale as `resolveFilePath`'s
164
+ // `opts.write` branch: a hardlink from inside the jail to an outside
165
+ // file shares an inode and passes the realpath check, but writing
166
+ // through it would modify the outside file.
167
+ if (opts.write) {
168
+ try {
169
+ const lst = fs.lstatSync(resolved);
170
+ if (!lst.isDirectory() && lst.nlink > 1) {
171
+ throw jailError(`recipe path "${rawPath}" is a hardlink (nlink=${lst.nlink}); writes denied to prevent jail escape`);
172
+ }
173
+ }
174
+ catch (err) {
175
+ // ENOENT — file doesn't exist yet, safe to create. Re-throw if it's
176
+ // already a jail error (the nlink branch above).
177
+ if (err instanceof Error &&
178
+ err.code === "recipe_path_jail_escape") {
179
+ throw err;
180
+ }
181
+ // Other lstat errors (EACCES, etc.) — non-fatal; the write call will
182
+ // surface them with the OS-level message.
183
+ }
184
+ }
185
+ return resolved;
186
+ }
187
+ /**
188
+ * Side-effect-free predicate variant — returns `null` on jail escape rather
189
+ * than throwing. Used by the CLI `recipe run` warn path (F-10), which wants
190
+ * to write a stderr notice when a recipe **file** lives outside the jail
191
+ * but still loads it (the YAML loader is a separate trust boundary from the
192
+ * tool dispatch jail).
193
+ */
194
+ export function tryResolveRecipePath(rawPath, opts = {}) {
195
+ try {
196
+ return resolveRecipePath(rawPath, opts);
197
+ }
198
+ catch {
199
+ return null;
200
+ }
201
+ }
202
+ //# sourceMappingURL=resolveRecipePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveRecipePath.js","sourceRoot":"","sources":["../../src/recipes/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D;YACjD,IACE,GAAG,YAAY,KAAK;gBACnB,GAAyB,CAAC,IAAI,KAAK,yBAAyB,EAC7D,CAAC;gBACD,MAAM,GAAG,CAAC;YACZ,CAAC;YACD,qEAAqE;YACrE,0CAA0C;QAC5C,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,OAAiC,EAAE;IAEnC,IAAI,CAAC;QACH,OAAO,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,10 +1,12 @@
1
+ import cron from "node-cron";
1
2
  import type { Logger } from "../logger.js";
2
3
  /**
3
- * RecipeScheduler — runs cron-triggered recipes on a simple interval.
4
+ * RecipeScheduler — runs cron-triggered recipes on a simple interval or
5
+ * standard 5-field cron expression.
4
6
  *
5
- * Phase-0 scope supports the `@every Ns|Nm|Nh` schedule form, which is
6
- * enough to demonstrate "works while you're away" without pulling in a full
7
- * cron dependency. Standard 5-field expressions can be added later.
7
+ * Supported schedule forms:
8
+ * @every Ns|Nm|Nh — simple interval (setInterval-based)
9
+ * <5-field cron> — standard cron expression (node-cron-based)
8
10
  *
9
11
  * Scheduler is a pure consumer of the recipes-on-disk contract and an
10
12
  * injected enqueue fn, so it's trivial to unit test without the orchestrator.
@@ -13,15 +15,20 @@ export type SchedulerEnqueue = (opts: {
13
15
  prompt: string;
14
16
  triggerSource: string;
15
17
  }) => string;
18
+ export type SchedulerRunYaml = (name: string) => Promise<void>;
16
19
  export interface ScheduledRecipe {
17
20
  name: string;
18
21
  schedule: string;
19
22
  intervalMs: number;
20
23
  timer: ReturnType<typeof setInterval>;
24
+ /** Present only for cron5-kind recipes. */
25
+ cronJob?: cron.ScheduledTask;
21
26
  }
22
27
  export interface SchedulerOptions {
23
28
  recipesDir: string;
24
29
  enqueue: SchedulerEnqueue;
30
+ /** Called for YAML recipes instead of enqueue. */
31
+ runYaml?: SchedulerRunYaml;
25
32
  logger?: Logger;
26
33
  /** Override for tests — defaults to setInterval. */
27
34
  setInterval?: typeof setInterval;
@@ -36,10 +43,19 @@ export declare class RecipeScheduler {
36
43
  constructor(opts: SchedulerOptions);
37
44
  start(): ScheduledRecipe[];
38
45
  stop(): void;
39
- list(): ReadonlyArray<Omit<ScheduledRecipe, "timer">>;
46
+ restart(): void;
47
+ list(): ReadonlyArray<Omit<ScheduledRecipe, "timer" | "cronJob">>;
40
48
  /** Test hook: dispatch a recipe immediately without waiting for the interval. */
41
49
  fireForTest(name: string): void;
42
50
  private fire;
43
51
  }
44
- /** Parse @every forms into milliseconds. Returns null for unsupported schedules. */
45
- export declare function parseSchedule(schedule: string): number | null;
52
+ type ParsedSchedule = {
53
+ kind: "interval";
54
+ intervalMs: number;
55
+ } | {
56
+ kind: "cron5";
57
+ expression: string;
58
+ };
59
+ /** Parse @every forms into milliseconds, or detect a 5-field cron expression. Returns null for unsupported schedules. */
60
+ export declare function parseSchedule(schedule: string): ParsedSchedule | null;
61
+ export {};
@@ -1,6 +1,10 @@
1
- import { readdirSync, readFileSync } from "node:fs";
1
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
2
  import path from "node:path";
3
- import { loadRecipePrompt } from "../recipesHttp.js";
3
+ import cron from "node-cron";
4
+ import { parse as parseYaml } from "yaml";
5
+ import { loadConfig } from "../patchworkConfig.js";
6
+ import { findYamlRecipePath, loadRecipePrompt } from "../recipesHttp.js";
7
+ import { getConfigDisabledNames, isInstallDirDisabled, } from "./disabledMarkers.js";
4
8
  export class RecipeScheduler {
5
9
  opts;
6
10
  scheduled = [];
@@ -13,6 +17,14 @@ export class RecipeScheduler {
13
17
  }
14
18
  start() {
15
19
  this.stop();
20
+ // Load disabled list from config
21
+ let disabled = new Set();
22
+ try {
23
+ disabled = getConfigDisabledNames(loadConfig());
24
+ }
25
+ catch {
26
+ // non-fatal — proceed with empty disabled set
27
+ }
16
28
  let entries;
17
29
  try {
18
30
  entries = readdirSync(this.opts.recipesDir);
@@ -20,60 +32,220 @@ export class RecipeScheduler {
20
32
  catch {
21
33
  return [];
22
34
  }
35
+ const candidates = [];
23
36
  for (const f of entries) {
24
- if (!f.endsWith(".json") || f.endsWith(".permissions.json"))
25
- continue;
26
37
  const fullPath = path.join(this.opts.recipesDir, f);
38
+ let isDir = false;
27
39
  try {
28
- const raw = readFileSync(fullPath, "utf-8");
29
- const parsed = JSON.parse(raw);
30
- if (parsed.trigger?.type !== "cron")
40
+ isDir = statSync(fullPath).isDirectory();
41
+ }
42
+ catch {
43
+ continue;
44
+ }
45
+ if (isDir) {
46
+ // Honor the per-recipe `.disabled` marker written by recipeInstall.
47
+ if (isInstallDirDisabled(fullPath)) {
48
+ this.opts.logger?.info?.(`[scheduler] skipping recipe in "${f}" — .disabled marker present`);
31
49
  continue;
32
- if (!parsed.trigger.schedule ||
33
- typeof parsed.trigger.schedule !== "string")
50
+ }
51
+ // Locate the recipe entrypoint inside the install dir.
52
+ // Prefer recipe.json's `recipes.main`, then fall back to first YAML.
53
+ const manifestPath = path.join(fullPath, "recipe.json");
54
+ let entrypoint = null;
55
+ if (existsSync(manifestPath)) {
56
+ try {
57
+ const m = JSON.parse(readFileSync(manifestPath, "utf-8"));
58
+ if (m.recipes?.main) {
59
+ const candidate = path.join(fullPath, m.recipes.main);
60
+ if (existsSync(candidate))
61
+ entrypoint = candidate;
62
+ }
63
+ }
64
+ catch (err) {
65
+ // Malformed manifest — fall through to first-yaml fallback,
66
+ // but surface the issue so the user can fix it. Silent failures
67
+ // here led to "why isn't my recipe firing?" confusion.
68
+ this.opts.logger?.warn?.(`[scheduler] could not parse recipe.json in "${f}" — ${err instanceof Error ? err.message : String(err)}; falling back to first-yaml lookup`);
69
+ }
70
+ }
71
+ if (!entrypoint) {
72
+ try {
73
+ const yaml = readdirSync(fullPath).find((x) => /\.ya?ml$/i.test(x));
74
+ if (yaml)
75
+ entrypoint = path.join(fullPath, yaml);
76
+ }
77
+ catch {
78
+ // unreadable — skip
79
+ }
80
+ }
81
+ if (entrypoint) {
82
+ const ext = path.extname(entrypoint).toLowerCase();
83
+ candidates.push({
84
+ filePath: entrypoint,
85
+ kind: ext === ".json" ? "json" : "yaml",
86
+ installDir: fullPath,
87
+ });
88
+ }
89
+ continue;
90
+ }
91
+ const isJson = f.endsWith(".json") && !f.endsWith(".permissions.json");
92
+ const isYaml = f.endsWith(".yaml") || f.endsWith(".yml");
93
+ if (!isJson && !isYaml)
94
+ continue;
95
+ candidates.push({
96
+ filePath: fullPath,
97
+ kind: isJson ? "json" : "yaml",
98
+ installDir: null,
99
+ });
100
+ }
101
+ for (const cand of candidates) {
102
+ const f = path.basename(cand.filePath);
103
+ try {
104
+ let name;
105
+ let schedule;
106
+ if (cand.kind === "json") {
107
+ const raw = readFileSync(cand.filePath, "utf-8");
108
+ const parsed = JSON.parse(raw);
109
+ if (parsed.trigger?.type !== "cron")
110
+ continue;
111
+ if (!parsed.trigger.schedule ||
112
+ typeof parsed.trigger.schedule !== "string")
113
+ continue;
114
+ schedule = parsed.trigger.schedule;
115
+ name = parsed.name ?? path.basename(f, ".json");
116
+ }
117
+ else {
118
+ // YAML
119
+ const raw = readFileSync(cand.filePath, "utf-8");
120
+ const parsed = parseYaml(raw);
121
+ if (parsed.trigger?.type !== "cron")
122
+ continue;
123
+ schedule = parsed.trigger.at ?? parsed.trigger.schedule;
124
+ if (!schedule || typeof schedule !== "string")
125
+ continue;
126
+ name = parsed.name ?? path.basename(f, path.extname(f));
127
+ }
128
+ // Apply config-file disabled list (legacy mechanism)
129
+ if (disabled.has(name)) {
130
+ this.opts.logger?.info?.(`[scheduler] skipping disabled recipe "${name}"`);
34
131
  continue;
35
- const intervalMs = parseSchedule(parsed.trigger.schedule);
36
- if (intervalMs === null) {
37
- this.opts.logger?.warn?.(`[scheduler] ignoring recipe "${parsed.name ?? f}" — unsupported schedule "${parsed.trigger.schedule}" (use @every Ns|Nm|Nh)`);
132
+ }
133
+ const parsed2 = parseSchedule(schedule);
134
+ if (parsed2 === null) {
135
+ this.opts.logger?.warn?.(`[scheduler] ignoring recipe "${name}" — unsupported schedule "${schedule}" (use @every Ns|Nm|Nh or a 5-field cron expression)`);
38
136
  continue;
39
137
  }
40
- const name = parsed.name ?? path.basename(f, ".json");
41
- const timer = this.setIntervalFn(() => {
42
- this.fire(name);
43
- }, intervalMs);
44
- if (typeof timer === "object" && "unref" in timer)
45
- timer.unref();
46
- this.scheduled.push({
47
- name,
48
- schedule: parsed.trigger.schedule,
49
- intervalMs,
50
- timer,
51
- });
52
- this.opts.logger?.info?.(`[scheduler] "${name}" scheduled every ${intervalMs}ms (${parsed.trigger.schedule})`);
138
+ if (parsed2.kind === "interval") {
139
+ const intervalMs = parsed2.intervalMs;
140
+ const timer = this.setIntervalFn(() => {
141
+ this.fire(name);
142
+ }, intervalMs);
143
+ if (typeof timer === "object" && "unref" in timer)
144
+ timer.unref();
145
+ this.scheduled.push({
146
+ name,
147
+ schedule,
148
+ intervalMs,
149
+ timer,
150
+ });
151
+ this.opts.logger?.info?.(`[scheduler] "${name}" scheduled every ${intervalMs}ms (${schedule})`);
152
+ }
153
+ else {
154
+ // cron5
155
+ const cronJob = cron.schedule(parsed2.expression, () => {
156
+ this.fire(name);
157
+ });
158
+ // Store a sentinel timer so the ScheduledRecipe shape stays stable
159
+ const dummyTimer = this.setIntervalFn(() => { }, 2_147_483_647);
160
+ if (typeof dummyTimer === "object" && "unref" in dummyTimer)
161
+ dummyTimer.unref();
162
+ this.scheduled.push({
163
+ name,
164
+ schedule,
165
+ intervalMs: 0,
166
+ timer: dummyTimer,
167
+ cronJob,
168
+ });
169
+ this.opts.logger?.info?.(`[scheduler] "${name}" scheduled with cron expression "${schedule}"`);
170
+ }
53
171
  }
54
- catch {
55
- // skip malformed recipe
172
+ catch (err) {
173
+ // Malformed recipe file — surface so users can debug rather than
174
+ // silently dropping the recipe from the schedule.
175
+ this.opts.logger?.warn?.(`[scheduler] could not load recipe at "${cand.filePath}" — ${err instanceof Error ? err.message : String(err)}; recipe will not be scheduled`);
56
176
  }
57
177
  }
58
178
  return this.scheduled;
59
179
  }
60
180
  stop() {
61
181
  for (const entry of this.scheduled) {
62
- this.clearIntervalFn(entry.timer);
182
+ if (entry.cronJob) {
183
+ entry.cronJob.stop();
184
+ }
185
+ else {
186
+ this.clearIntervalFn(entry.timer);
187
+ }
63
188
  }
64
189
  this.scheduled = [];
65
190
  }
191
+ restart() {
192
+ this.stop();
193
+ this.start();
194
+ }
66
195
  list() {
67
- return this.scheduled.map(({ timer: _t, ...rest }) => rest);
196
+ return this.scheduled.map(({ timer: _t, cronJob: _c, ...rest }) => rest);
68
197
  }
69
198
  /** Test hook: dispatch a recipe immediately without waiting for the interval. */
70
199
  fireForTest(name) {
71
200
  this.fire(name);
72
201
  }
73
202
  fire(name) {
203
+ // TOCTOU defence: re-check the legacy `cfg.recipes.disabled` list at
204
+ // fire time. `start()` snapshots it once; if the user runs `recipe
205
+ // disable <name>` after start (and the recipe is a top-level legacy
206
+ // file, where the marker file doesn't apply), the timer would
207
+ // otherwise still fire until next restart(). The `.disabled` marker
208
+ // case is handled inside findYamlRecipePath / loadRecipePrompt
209
+ // (skip disabled install dirs) thanks to PR #49.
210
+ try {
211
+ if (getConfigDisabledNames(loadConfig()).has(name)) {
212
+ this.opts.logger?.info?.(`[scheduler] skipping "${name}" — disabled via config (TOCTOU re-check)`);
213
+ return;
214
+ }
215
+ }
216
+ catch {
217
+ // proceed if config unreadable — falling back to scan-time snapshot
218
+ }
219
+ // YAML recipe — delegate to runYaml if provided. findYamlRecipePath
220
+ // now throws RecipeNameConflictError when two recipes declare the same
221
+ // name; surface that loudly instead of letting the timer crash silently.
222
+ let yamlPath;
223
+ try {
224
+ yamlPath = findYamlRecipePath(this.opts.recipesDir, name);
225
+ }
226
+ catch (err) {
227
+ this.opts.logger?.warn?.(`[scheduler] skipped "${name}" — ${err instanceof Error ? err.message : String(err)}`);
228
+ return;
229
+ }
230
+ if (yamlPath) {
231
+ if (!this.opts.runYaml) {
232
+ this.opts.logger?.warn?.(`[scheduler] skipped "${name}" — YAML recipe requires runYaml callback (start bridge with --claude-driver)`);
233
+ return;
234
+ }
235
+ this.opts.runYaml(name).catch((err) => {
236
+ this.opts.logger?.warn?.(`[scheduler] YAML recipe "${name}" failed: ${err instanceof Error ? err.message : String(err)}`);
237
+ });
238
+ this.opts.logger?.info?.(`[scheduler] fired YAML recipe "${name}"`);
239
+ return;
240
+ }
241
+ // JSON recipe — legacy path
74
242
  const loaded = loadRecipePrompt(this.opts.recipesDir, name);
75
243
  if (!loaded) {
76
- this.opts.logger?.warn?.(`[scheduler] skipped "${name}" recipe file disappeared`);
244
+ // After PR #49, findYamlRecipePath / loadRecipePrompt return null for
245
+ // recipes whose install dir has a `.disabled` marker — that's the
246
+ // common case here. "Disappeared" was misleading; prefer a message
247
+ // that names both possibilities.
248
+ this.opts.logger?.warn?.(`[scheduler] skipped "${name}" — recipe not found or disabled`);
77
249
  return;
78
250
  }
79
251
  try {
@@ -88,23 +260,31 @@ export class RecipeScheduler {
88
260
  }
89
261
  }
90
262
  }
91
- /** Parse @every forms into milliseconds. Returns null for unsupported schedules. */
263
+ /** Parse @every forms into milliseconds, or detect a 5-field cron expression. Returns null for unsupported schedules. */
92
264
  export function parseSchedule(schedule) {
93
265
  const trimmed = schedule.trim();
266
+ // @every Ns|Nm|Nh
94
267
  const m = /^@every\s+(\d+)\s*(ms|s|m|h)$/i.exec(trimmed);
95
- if (!m)
96
- return null;
97
- const n = Number.parseInt(m[1], 10);
98
- const unit = m[2].toLowerCase();
99
- if (!Number.isFinite(n) || n <= 0)
100
- return null;
101
- const multiplier = unit === "ms"
102
- ? 1
103
- : unit === "s"
104
- ? 1000
105
- : unit === "m"
106
- ? 60_000
107
- : 60 * 60_000;
108
- return n * multiplier;
268
+ if (m) {
269
+ const n = Number.parseInt(m[1], 10);
270
+ const unit = m[2]?.toLowerCase();
271
+ if (!Number.isFinite(n) || n <= 0)
272
+ return null;
273
+ const multiplier = unit === "ms"
274
+ ? 1
275
+ : unit === "s"
276
+ ? 1000
277
+ : unit === "m"
278
+ ? 60_000
279
+ : 60 * 60_000;
280
+ return { kind: "interval", intervalMs: n * multiplier };
281
+ }
282
+ // 5-field cron expression (e.g. "0 8 * * 1-5")
283
+ if (/^\S+\s+\S+\s+\S+\s+\S+\s+\S+$/.test(trimmed)) {
284
+ if (cron.validate(trimmed)) {
285
+ return { kind: "cron5", expression: trimmed };
286
+ }
287
+ }
288
+ return null;
109
289
  }
110
290
  //# sourceMappingURL=scheduler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/recipes/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAmCrD,MAAM,OAAO,eAAe;IAKG;IAJrB,SAAS,GAAsB,EAAE,CAAC;IACzB,aAAa,CAAqB;IAClC,eAAe,CAAuB;IAEvD,YAA6B,IAAsB;QAAtB,SAAI,GAAJ,IAAI,CAAkB;QACjD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC;QACrD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC;IAC7D,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,OAAiB,CAAC;QACtB,IAAI,CAAC;YACH,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,IAA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