reqon-dsl 0.2.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 (388) hide show
  1. package/.claude/settings.local.json +31 -0
  2. package/.claude/skills/api-integration.md +125 -0
  3. package/.claude/skills/database-schema.md +51 -0
  4. package/.claude/skills/dsl-design.md +80 -0
  5. package/.claude/skills/property-testing.md +143 -0
  6. package/.claude/skills/reqon/SKILL.md +44 -0
  7. package/.claude/skills/reqon/references/examples.md +206 -0
  8. package/.claude/skills/reqon/references/syntax.md +263 -0
  9. package/.claude/skills/vscode-extension.md +113 -0
  10. package/.github/dependabot.yml +32 -0
  11. package/.github/pull_request_template.md +21 -0
  12. package/.github/workflows/ci.yml +174 -0
  13. package/.github/workflows/release.yml +73 -0
  14. package/CLAUDE.md +72 -0
  15. package/CONTRIBUTING.md +161 -0
  16. package/README.md +235 -0
  17. package/TODO.md +51 -0
  18. package/dist/ast/index.d.ts +1 -0
  19. package/dist/ast/index.js +1 -0
  20. package/dist/ast/nodes.d.ts +237 -0
  21. package/dist/ast/nodes.js +12 -0
  22. package/dist/auth/auth.test.d.ts +1 -0
  23. package/dist/auth/auth.test.js +255 -0
  24. package/dist/auth/circuit-breaker.d.ts +115 -0
  25. package/dist/auth/circuit-breaker.js +267 -0
  26. package/dist/auth/credentials.d.ts +91 -0
  27. package/dist/auth/credentials.js +169 -0
  28. package/dist/auth/index.d.ts +5 -0
  29. package/dist/auth/index.js +8 -0
  30. package/dist/auth/oauth2-provider.d.ts +41 -0
  31. package/dist/auth/oauth2-provider.js +131 -0
  32. package/dist/auth/rate-limiter.d.ts +61 -0
  33. package/dist/auth/rate-limiter.js +380 -0
  34. package/dist/auth/token-store.d.ts +30 -0
  35. package/dist/auth/token-store.js +148 -0
  36. package/dist/auth/types.d.ts +142 -0
  37. package/dist/auth/types.js +1 -0
  38. package/dist/cli.d.ts +2 -0
  39. package/dist/cli.js +270 -0
  40. package/dist/errors/errors.test.d.ts +1 -0
  41. package/dist/errors/errors.test.js +165 -0
  42. package/dist/errors/index.d.ts +83 -0
  43. package/dist/errors/index.js +159 -0
  44. package/dist/execution/execution.test.d.ts +1 -0
  45. package/dist/execution/execution.test.js +246 -0
  46. package/dist/execution/index.d.ts +4 -0
  47. package/dist/execution/index.js +2 -0
  48. package/dist/execution/state.d.ts +136 -0
  49. package/dist/execution/state.js +82 -0
  50. package/dist/execution/store.d.ts +52 -0
  51. package/dist/execution/store.js +120 -0
  52. package/dist/index.d.ts +27 -0
  53. package/dist/index.js +57 -0
  54. package/dist/integration.test.d.ts +1 -0
  55. package/dist/integration.test.js +168 -0
  56. package/dist/interpreter/context.d.ts +15 -0
  57. package/dist/interpreter/context.js +29 -0
  58. package/dist/interpreter/evaluator.d.ts +5 -0
  59. package/dist/interpreter/evaluator.js +223 -0
  60. package/dist/interpreter/evaluator.test.d.ts +1 -0
  61. package/dist/interpreter/evaluator.test.js +512 -0
  62. package/dist/interpreter/executor.d.ts +131 -0
  63. package/dist/interpreter/executor.js +663 -0
  64. package/dist/interpreter/fetch-handler.d.ts +43 -0
  65. package/dist/interpreter/fetch-handler.js +203 -0
  66. package/dist/interpreter/http.d.ts +57 -0
  67. package/dist/interpreter/http.js +210 -0
  68. package/dist/interpreter/http.test.d.ts +1 -0
  69. package/dist/interpreter/http.test.js +299 -0
  70. package/dist/interpreter/index.d.ts +7 -0
  71. package/dist/interpreter/index.js +7 -0
  72. package/dist/interpreter/pagination.d.ts +63 -0
  73. package/dist/interpreter/pagination.js +155 -0
  74. package/dist/interpreter/progress.test.d.ts +1 -0
  75. package/dist/interpreter/progress.test.js +216 -0
  76. package/dist/interpreter/schema-matcher.d.ts +16 -0
  77. package/dist/interpreter/schema-matcher.js +136 -0
  78. package/dist/interpreter/schema-matcher.test.d.ts +1 -0
  79. package/dist/interpreter/schema-matcher.test.js +122 -0
  80. package/dist/interpreter/signals.d.ts +57 -0
  81. package/dist/interpreter/signals.js +73 -0
  82. package/dist/interpreter/step-handlers/for-handler.d.ts +17 -0
  83. package/dist/interpreter/step-handlers/for-handler.js +51 -0
  84. package/dist/interpreter/step-handlers/index.d.ts +8 -0
  85. package/dist/interpreter/step-handlers/index.js +8 -0
  86. package/dist/interpreter/step-handlers/map-handler.d.ts +10 -0
  87. package/dist/interpreter/step-handlers/map-handler.js +20 -0
  88. package/dist/interpreter/step-handlers/match-handler.d.ts +27 -0
  89. package/dist/interpreter/step-handlers/match-handler.js +61 -0
  90. package/dist/interpreter/step-handlers/store-handler.d.ts +13 -0
  91. package/dist/interpreter/step-handlers/store-handler.js +66 -0
  92. package/dist/interpreter/step-handlers/types.d.ts +15 -0
  93. package/dist/interpreter/step-handlers/types.js +1 -0
  94. package/dist/interpreter/step-handlers/validate-handler.d.ts +10 -0
  95. package/dist/interpreter/step-handlers/validate-handler.js +26 -0
  96. package/dist/interpreter/step-handlers/webhook-handler.d.ts +36 -0
  97. package/dist/interpreter/step-handlers/webhook-handler.js +104 -0
  98. package/dist/lexer/index.d.ts +10 -0
  99. package/dist/lexer/index.js +12 -0
  100. package/dist/lexer/lexer.d.ts +24 -0
  101. package/dist/lexer/lexer.js +264 -0
  102. package/dist/lexer/lexer.test.d.ts +1 -0
  103. package/dist/lexer/lexer.test.js +259 -0
  104. package/dist/lexer/tokens.d.ts +69 -0
  105. package/dist/lexer/tokens.js +146 -0
  106. package/dist/loader/index.d.ts +36 -0
  107. package/dist/loader/index.js +220 -0
  108. package/dist/loader/loader.test.d.ts +1 -0
  109. package/dist/loader/loader.test.js +287 -0
  110. package/dist/oas/index.d.ts +4 -0
  111. package/dist/oas/index.js +2 -0
  112. package/dist/oas/loader.d.ts +21 -0
  113. package/dist/oas/loader.js +82 -0
  114. package/dist/oas/oas.test.d.ts +1 -0
  115. package/dist/oas/oas.test.js +218 -0
  116. package/dist/oas/validator.d.ts +12 -0
  117. package/dist/oas/validator.js +227 -0
  118. package/dist/parser/base.d.ts +33 -0
  119. package/dist/parser/base.js +97 -0
  120. package/dist/parser/expressions.d.ts +27 -0
  121. package/dist/parser/expressions.js +248 -0
  122. package/dist/parser/expressions.test.d.ts +1 -0
  123. package/dist/parser/expressions.test.js +378 -0
  124. package/dist/parser/index.d.ts +3 -0
  125. package/dist/parser/index.js +3 -0
  126. package/dist/parser/match.test.d.ts +1 -0
  127. package/dist/parser/match.test.js +254 -0
  128. package/dist/parser/parser.d.ts +68 -0
  129. package/dist/parser/parser.js +1229 -0
  130. package/dist/parser/parser.test.d.ts +1 -0
  131. package/dist/parser/parser.test.js +333 -0
  132. package/dist/parser/schedule.test.d.ts +1 -0
  133. package/dist/parser/schedule.test.js +241 -0
  134. package/dist/plugin.d.ts +35 -0
  135. package/dist/plugin.js +68 -0
  136. package/dist/scheduler/cron-parser.d.ts +32 -0
  137. package/dist/scheduler/cron-parser.js +198 -0
  138. package/dist/scheduler/cron-parser.test.d.ts +1 -0
  139. package/dist/scheduler/cron-parser.test.js +188 -0
  140. package/dist/scheduler/index.d.ts +3 -0
  141. package/dist/scheduler/index.js +2 -0
  142. package/dist/scheduler/scheduler.d.ts +81 -0
  143. package/dist/scheduler/scheduler.js +376 -0
  144. package/dist/scheduler/types.d.ts +65 -0
  145. package/dist/scheduler/types.js +1 -0
  146. package/dist/stores/factory.d.ts +36 -0
  147. package/dist/stores/factory.js +73 -0
  148. package/dist/stores/file.d.ts +60 -0
  149. package/dist/stores/file.js +173 -0
  150. package/dist/stores/file.test.d.ts +1 -0
  151. package/dist/stores/file.test.js +165 -0
  152. package/dist/stores/index.d.ts +6 -0
  153. package/dist/stores/index.js +5 -0
  154. package/dist/stores/memory.d.ts +19 -0
  155. package/dist/stores/memory.js +51 -0
  156. package/dist/stores/memory.test.d.ts +1 -0
  157. package/dist/stores/memory.test.js +157 -0
  158. package/dist/stores/postgrest.d.ts +55 -0
  159. package/dist/stores/postgrest.js +217 -0
  160. package/dist/stores/stores.test.d.ts +1 -0
  161. package/dist/stores/stores.test.js +158 -0
  162. package/dist/stores/types.d.ts +31 -0
  163. package/dist/stores/types.js +26 -0
  164. package/dist/sync/index.d.ts +4 -0
  165. package/dist/sync/index.js +2 -0
  166. package/dist/sync/state.d.ts +69 -0
  167. package/dist/sync/state.js +66 -0
  168. package/dist/sync/store.d.ts +49 -0
  169. package/dist/sync/store.js +93 -0
  170. package/dist/sync/sync.test.d.ts +1 -0
  171. package/dist/sync/sync.test.js +221 -0
  172. package/dist/utils/async.d.ts +7 -0
  173. package/dist/utils/async.js +9 -0
  174. package/dist/utils/file.d.ts +38 -0
  175. package/dist/utils/file.js +92 -0
  176. package/dist/utils/index.d.ts +4 -0
  177. package/dist/utils/index.js +4 -0
  178. package/dist/utils/logger.d.ts +34 -0
  179. package/dist/utils/logger.js +39 -0
  180. package/dist/utils/path.d.ts +12 -0
  181. package/dist/utils/path.js +41 -0
  182. package/dist/webhook/index.d.ts +8 -0
  183. package/dist/webhook/index.js +7 -0
  184. package/dist/webhook/server.d.ts +84 -0
  185. package/dist/webhook/server.js +319 -0
  186. package/dist/webhook/store.d.ts +67 -0
  187. package/dist/webhook/store.js +193 -0
  188. package/dist/webhook/types.d.ts +88 -0
  189. package/dist/webhook/types.js +6 -0
  190. package/docusaurus/README.md +41 -0
  191. package/docusaurus/docs/advanced/execution-state.md +283 -0
  192. package/docusaurus/docs/advanced/extending-reqon.md +388 -0
  193. package/docusaurus/docs/advanced/multi-file-missions.md +250 -0
  194. package/docusaurus/docs/advanced/parallel-execution.md +353 -0
  195. package/docusaurus/docs/api-reference.md +443 -0
  196. package/docusaurus/docs/authentication/api-key.md +339 -0
  197. package/docusaurus/docs/authentication/basic.md +276 -0
  198. package/docusaurus/docs/authentication/bearer.md +282 -0
  199. package/docusaurus/docs/authentication/oauth2.md +317 -0
  200. package/docusaurus/docs/authentication/overview.md +251 -0
  201. package/docusaurus/docs/cli.md +229 -0
  202. package/docusaurus/docs/core-concepts/actions.md +286 -0
  203. package/docusaurus/docs/core-concepts/missions.md +264 -0
  204. package/docusaurus/docs/core-concepts/schemas.md +353 -0
  205. package/docusaurus/docs/core-concepts/sources.md +339 -0
  206. package/docusaurus/docs/core-concepts/stores.md +332 -0
  207. package/docusaurus/docs/dsl-syntax/expressions.md +361 -0
  208. package/docusaurus/docs/dsl-syntax/fetch.md +293 -0
  209. package/docusaurus/docs/dsl-syntax/for-loops.md +324 -0
  210. package/docusaurus/docs/dsl-syntax/map.md +345 -0
  211. package/docusaurus/docs/dsl-syntax/match.md +387 -0
  212. package/docusaurus/docs/dsl-syntax/pipelines.md +397 -0
  213. package/docusaurus/docs/dsl-syntax/validate.md +401 -0
  214. package/docusaurus/docs/error-handling/dead-letter-queues.md +399 -0
  215. package/docusaurus/docs/error-handling/flow-control.md +337 -0
  216. package/docusaurus/docs/error-handling/retry-strategies.md +368 -0
  217. package/docusaurus/docs/examples.md +488 -0
  218. package/docusaurus/docs/getting-started.md +256 -0
  219. package/docusaurus/docs/http/circuit-breaker.md +401 -0
  220. package/docusaurus/docs/http/incremental-sync.md +394 -0
  221. package/docusaurus/docs/http/pagination.md +361 -0
  222. package/docusaurus/docs/http/rate-limiting.md +383 -0
  223. package/docusaurus/docs/http/requests.md +328 -0
  224. package/docusaurus/docs/http/retry.md +402 -0
  225. package/docusaurus/docs/intro.md +90 -0
  226. package/docusaurus/docs/openapi/loading-specs.md +305 -0
  227. package/docusaurus/docs/openapi/operation-calls.md +314 -0
  228. package/docusaurus/docs/openapi/overview.md +212 -0
  229. package/docusaurus/docs/openapi/response-validation.md +344 -0
  230. package/docusaurus/docs/scheduling/cron.md +305 -0
  231. package/docusaurus/docs/scheduling/daemon-mode.md +317 -0
  232. package/docusaurus/docs/scheduling/intervals.md +289 -0
  233. package/docusaurus/docs/scheduling/overview.md +231 -0
  234. package/docusaurus/docs/stores/custom-adapters.md +376 -0
  235. package/docusaurus/docs/stores/file.md +236 -0
  236. package/docusaurus/docs/stores/memory.md +193 -0
  237. package/docusaurus/docs/stores/overview.md +274 -0
  238. package/docusaurus/docs/stores/postgrest.md +316 -0
  239. package/docusaurus/docusaurus.config.ts +148 -0
  240. package/docusaurus/package-lock.json +18029 -0
  241. package/docusaurus/package.json +47 -0
  242. package/docusaurus/sidebars.ts +155 -0
  243. package/docusaurus/src/components/HomepageFeatures/index.tsx +105 -0
  244. package/docusaurus/src/components/HomepageFeatures/styles.module.css +12 -0
  245. package/docusaurus/src/css/custom.css +169 -0
  246. package/docusaurus/src/pages/index.module.css +48 -0
  247. package/docusaurus/src/pages/index.tsx +110 -0
  248. package/docusaurus/src/pages/markdown-page.md +7 -0
  249. package/docusaurus/static/.nojekyll +0 -0
  250. package/docusaurus/static/img/docusaurus-social-card.jpg +0 -0
  251. package/docusaurus/static/img/docusaurus.png +0 -0
  252. package/docusaurus/static/img/favicon.ico +0 -0
  253. package/docusaurus/static/img/logo.svg +10 -0
  254. package/docusaurus/static/img/undraw_docusaurus_mountain.svg +171 -0
  255. package/docusaurus/static/img/undraw_docusaurus_react.svg +170 -0
  256. package/docusaurus/static/img/undraw_docusaurus_tree.svg +40 -0
  257. package/docusaurus/tsconfig.json +8 -0
  258. package/examples/README.md +112 -0
  259. package/examples/error-handling/README.md +150 -0
  260. package/examples/error-handling/payment-processor.vague +287 -0
  261. package/examples/github-sync/README.md +74 -0
  262. package/examples/github-sync/fetch-issues.vague +47 -0
  263. package/examples/github-sync/fetch-prs.vague +40 -0
  264. package/examples/github-sync/mission.vague +101 -0
  265. package/examples/github-sync/normalize.vague +70 -0
  266. package/examples/jsonplaceholder/README.md +28 -0
  267. package/examples/jsonplaceholder/posts.vague +48 -0
  268. package/examples/petstore/README.md +35 -0
  269. package/examples/petstore/openapi.yaml +97 -0
  270. package/examples/petstore/sync.vague +52 -0
  271. package/examples/temporal-comparison/README.md +297 -0
  272. package/examples/temporal-comparison/reconciliation.vague +355 -0
  273. package/examples/temporal-comparison/temporal/activities/index.ts +8 -0
  274. package/examples/temporal-comparison/temporal/activities/shipstation.ts +225 -0
  275. package/examples/temporal-comparison/temporal/activities/shopify.ts +257 -0
  276. package/examples/temporal-comparison/temporal/activities/storage.ts +198 -0
  277. package/examples/temporal-comparison/temporal/activities/stripe.ts +169 -0
  278. package/examples/temporal-comparison/temporal/activities/validation.ts +205 -0
  279. package/examples/temporal-comparison/temporal/client/schedule.ts +218 -0
  280. package/examples/temporal-comparison/temporal/config/retry.ts +63 -0
  281. package/examples/temporal-comparison/temporal/types/index.ts +129 -0
  282. package/examples/temporal-comparison/temporal/workers/main.ts +130 -0
  283. package/examples/temporal-comparison/temporal/workflows/orderReconciliation.ts +262 -0
  284. package/examples/xero/README.md +88 -0
  285. package/examples/xero/invoices.vague +189 -0
  286. package/package.json +40 -0
  287. package/src/api-integration.test.ts +954 -0
  288. package/src/ast/index.ts +1 -0
  289. package/src/ast/nodes.ts +310 -0
  290. package/src/auth/auth.test.ts +326 -0
  291. package/src/auth/circuit-breaker.test.ts +390 -0
  292. package/src/auth/circuit-breaker.ts +379 -0
  293. package/src/auth/credentials.test.ts +273 -0
  294. package/src/auth/credentials.ts +246 -0
  295. package/src/auth/index.ts +40 -0
  296. package/src/auth/oauth2-provider.ts +177 -0
  297. package/src/auth/rate-limiter.ts +459 -0
  298. package/src/auth/token-store.ts +177 -0
  299. package/src/auth/types.ts +159 -0
  300. package/src/benchmark/e2e.bench.ts +288 -0
  301. package/src/benchmark/evaluator.bench.ts +331 -0
  302. package/src/benchmark/fixtures.ts +295 -0
  303. package/src/benchmark/index.ts +108 -0
  304. package/src/benchmark/lexer.bench.ts +69 -0
  305. package/src/benchmark/parser.bench.ts +103 -0
  306. package/src/benchmark/resilience.bench.ts +193 -0
  307. package/src/benchmark/store.bench.ts +147 -0
  308. package/src/benchmark/utils.ts +230 -0
  309. package/src/cli.ts +313 -0
  310. package/src/errors/errors.test.ts +234 -0
  311. package/src/errors/index.ts +223 -0
  312. package/src/execution/execution.test.ts +307 -0
  313. package/src/execution/index.ts +21 -0
  314. package/src/execution/state.ts +207 -0
  315. package/src/execution/store.ts +188 -0
  316. package/src/index.ts +169 -0
  317. package/src/integration.test.ts +192 -0
  318. package/src/interpreter/context.ts +57 -0
  319. package/src/interpreter/evaluator.test.ts +796 -0
  320. package/src/interpreter/evaluator.ts +245 -0
  321. package/src/interpreter/executor.ts +946 -0
  322. package/src/interpreter/fetch-handler.ts +302 -0
  323. package/src/interpreter/http.test.ts +423 -0
  324. package/src/interpreter/http.ts +308 -0
  325. package/src/interpreter/index.ts +32 -0
  326. package/src/interpreter/pagination.ts +207 -0
  327. package/src/interpreter/progress.test.ts +276 -0
  328. package/src/interpreter/schema-matcher.test.ts +160 -0
  329. package/src/interpreter/schema-matcher.ts +168 -0
  330. package/src/interpreter/signals.ts +73 -0
  331. package/src/interpreter/step-handlers/for-handler.ts +65 -0
  332. package/src/interpreter/step-handlers/index.ts +17 -0
  333. package/src/interpreter/step-handlers/map-handler.ts +24 -0
  334. package/src/interpreter/step-handlers/match-handler.ts +101 -0
  335. package/src/interpreter/step-handlers/store-handler.ts +78 -0
  336. package/src/interpreter/step-handlers/types.ts +17 -0
  337. package/src/interpreter/step-handlers/validate-handler.ts +30 -0
  338. package/src/interpreter/step-handlers/webhook-handler.ts +142 -0
  339. package/src/lexer/index.ts +18 -0
  340. package/src/lexer/lexer.test.ts +316 -0
  341. package/src/lexer/tokens.ts +179 -0
  342. package/src/loader/index.ts +288 -0
  343. package/src/loader/loader.test.ts +360 -0
  344. package/src/oas/index.ts +4 -0
  345. package/src/oas/loader.ts +126 -0
  346. package/src/oas/oas.test.ts +254 -0
  347. package/src/oas/validator.ts +299 -0
  348. package/src/parser/base.ts +124 -0
  349. package/src/parser/expressions.test.ts +525 -0
  350. package/src/parser/expressions.ts +314 -0
  351. package/src/parser/index.ts +3 -0
  352. package/src/parser/match.test.ts +296 -0
  353. package/src/parser/parser.test.ts +739 -0
  354. package/src/parser/parser.ts +1469 -0
  355. package/src/parser/schedule.test.ts +287 -0
  356. package/src/parser/webhook.test.ts +248 -0
  357. package/src/plugin.ts +83 -0
  358. package/src/scheduler/cron-parser.test.ts +236 -0
  359. package/src/scheduler/cron-parser.ts +236 -0
  360. package/src/scheduler/index.ts +10 -0
  361. package/src/scheduler/scheduler.ts +443 -0
  362. package/src/scheduler/types.ts +71 -0
  363. package/src/stores/factory.ts +104 -0
  364. package/src/stores/file.test.ts +276 -0
  365. package/src/stores/file.ts +211 -0
  366. package/src/stores/index.ts +6 -0
  367. package/src/stores/memory.test.ts +238 -0
  368. package/src/stores/memory.ts +63 -0
  369. package/src/stores/postgrest.test.ts +488 -0
  370. package/src/stores/postgrest.ts +263 -0
  371. package/src/stores/stores.test.ts +197 -0
  372. package/src/stores/types.ts +58 -0
  373. package/src/sync/index.ts +16 -0
  374. package/src/sync/state.ts +126 -0
  375. package/src/sync/store.ts +139 -0
  376. package/src/sync/sync.test.ts +271 -0
  377. package/src/utils/async.ts +10 -0
  378. package/src/utils/file.ts +106 -0
  379. package/src/utils/index.ts +14 -0
  380. package/src/utils/logger.ts +53 -0
  381. package/src/utils/path.ts +47 -0
  382. package/src/webhook/index.ts +15 -0
  383. package/src/webhook/server.test.ts +253 -0
  384. package/src/webhook/server.ts +389 -0
  385. package/src/webhook/store.ts +239 -0
  386. package/src/webhook/types.ts +93 -0
  387. package/tsconfig.json +17 -0
  388. package/vitest.config.ts +39 -0
@@ -0,0 +1,663 @@
1
+ import { isParallelStage } from '../ast/nodes.js';
2
+ import { createContext, setVariable } from './context.js';
3
+ import { evaluate } from './evaluator.js';
4
+ import { HttpClient, BearerAuthProvider, OAuth2AuthProvider } from './http.js';
5
+ import { createStore, resolveStoreType } from '../stores/index.js';
6
+ import { loadOAS } from '../oas/index.js';
7
+ import { AdaptiveRateLimiter } from '../auth/rate-limiter.js';
8
+ import { CircuitBreaker } from '../auth/circuit-breaker.js';
9
+ import { createExecutionState, findResumePoint, FileExecutionStore, } from '../execution/index.js';
10
+ import { FileSyncStore, } from '../sync/index.js';
11
+ import { FetchHandler } from './fetch-handler.js';
12
+ import { ForHandler, MapHandler, ValidateHandler, StoreHandler, MatchHandler, WebhookHandler, SkipSignal, RetrySignal, JumpSignal, QueueSignal, } from './step-handlers/index.js';
13
+ export class MissionExecutor {
14
+ config;
15
+ ctx;
16
+ errors = [];
17
+ actionsRun = [];
18
+ oasSources = new Map();
19
+ sourceConfigs = new Map();
20
+ rateLimiter;
21
+ circuitBreaker;
22
+ executionStore;
23
+ executionState;
24
+ syncStore;
25
+ missionName;
26
+ constructor(config = {}) {
27
+ this.config = config;
28
+ this.ctx = createContext();
29
+ this.rateLimiter = new AdaptiveRateLimiter();
30
+ this.circuitBreaker = new CircuitBreaker();
31
+ // Set up rate limit callbacks with default logging if verbose
32
+ const callbacks = config.rateLimitCallbacks ?? {};
33
+ if (config.verbose && !callbacks.onRateLimited) {
34
+ callbacks.onRateLimited = (event) => {
35
+ console.log(`[Reqon] Rate limited on ${event.source}${event.endpoint ? `:${event.endpoint}` : ''} - ` +
36
+ `waiting ${event.waitSeconds}s (strategy: ${event.strategy})`);
37
+ };
38
+ }
39
+ if (config.verbose && !callbacks.onResumed) {
40
+ callbacks.onResumed = (event) => {
41
+ console.log(`[Reqon] Rate limit cleared for ${event.source}${event.endpoint ? `:${event.endpoint}` : ''} ` +
42
+ `(waited ${event.waitedSeconds}s)`);
43
+ };
44
+ }
45
+ if (config.verbose && !callbacks.onWaiting) {
46
+ callbacks.onWaiting = (event) => {
47
+ console.log(`[Reqon] Still waiting for ${event.source}${event.endpoint ? `:${event.endpoint}` : ''} - ` +
48
+ `${event.waitSeconds}s remaining (elapsed: ${event.elapsedSeconds}s)`);
49
+ };
50
+ }
51
+ this.rateLimiter.setCallbacks(callbacks);
52
+ // Set up circuit breaker callbacks with default logging if verbose
53
+ const cbCallbacks = config.circuitBreakerCallbacks ?? {};
54
+ if (config.verbose && !cbCallbacks.onOpen) {
55
+ cbCallbacks.onOpen = (event) => {
56
+ console.log(`[Reqon] Circuit breaker OPEN for ${event.source}${event.endpoint ? `:${event.endpoint}` : ''} - ` +
57
+ `${event.failures} failures (${event.reason ?? 'threshold exceeded'})`);
58
+ };
59
+ }
60
+ if (config.verbose && !cbCallbacks.onHalfOpen) {
61
+ cbCallbacks.onHalfOpen = (event) => {
62
+ console.log(`[Reqon] Circuit breaker HALF-OPEN for ${event.source}${event.endpoint ? `:${event.endpoint}` : ''} - ` +
63
+ `testing recovery`);
64
+ };
65
+ }
66
+ if (config.verbose && !cbCallbacks.onClose) {
67
+ cbCallbacks.onClose = (event) => {
68
+ console.log(`[Reqon] Circuit breaker CLOSED for ${event.source}${event.endpoint ? `:${event.endpoint}` : ''} - ` +
69
+ `recovery successful`);
70
+ };
71
+ }
72
+ if (config.verbose && !cbCallbacks.onRejected) {
73
+ cbCallbacks.onRejected = (event) => {
74
+ console.log(`[Reqon] Request REJECTED by circuit breaker for ${event.source}${event.endpoint ? `:${event.endpoint}` : ''} - ` +
75
+ `retry in ${Math.ceil(event.nextAttemptIn / 1000)}s`);
76
+ };
77
+ }
78
+ this.circuitBreaker.setCallbacks(cbCallbacks);
79
+ // Initialize execution store if persistence enabled
80
+ if (config.persistState) {
81
+ this.executionStore = config.executionStore ?? new FileExecutionStore(`${config.dataDir ?? '.reqon-data'}/executions`);
82
+ }
83
+ }
84
+ async execute(program) {
85
+ const startTime = Date.now();
86
+ // Find mission definition
87
+ const mission = program.statements.find((s) => s.type === 'MissionDefinition');
88
+ if (!mission) {
89
+ return {
90
+ success: false,
91
+ duration: Date.now() - startTime,
92
+ actionsRun: [],
93
+ errors: [{ action: '', step: '', message: 'No mission found in program' }],
94
+ stores: this.ctx.stores,
95
+ };
96
+ }
97
+ // Initialize or resume execution state
98
+ await this.initializeExecutionState(mission);
99
+ try {
100
+ await this.executeMission(mission);
101
+ // Mark execution as completed
102
+ if (this.executionState) {
103
+ this.executionState.status = 'completed';
104
+ this.executionState.completedAt = new Date();
105
+ this.executionState.duration = Date.now() - startTime;
106
+ await this.saveExecutionState();
107
+ }
108
+ }
109
+ catch (error) {
110
+ this.errors.push({
111
+ action: 'mission',
112
+ step: 'execute',
113
+ message: error.message,
114
+ details: error,
115
+ });
116
+ // Mark execution as failed
117
+ if (this.executionState) {
118
+ this.executionState.status = 'failed';
119
+ this.executionState.completedAt = new Date();
120
+ this.executionState.duration = Date.now() - startTime;
121
+ await this.saveExecutionState();
122
+ }
123
+ }
124
+ const duration = Date.now() - startTime;
125
+ const success = this.errors.length === 0;
126
+ // Emit onExecutionComplete callback - count stages in a single pass
127
+ const stageCounts = this.executionState?.stages.reduce((acc, s) => {
128
+ if (s.status === 'completed')
129
+ acc.completed++;
130
+ else if (s.status === 'failed')
131
+ acc.failed++;
132
+ return acc;
133
+ }, { completed: 0, failed: 0 });
134
+ const stagesCompleted = stageCounts?.completed ?? this.actionsRun.length;
135
+ const stagesFailed = stageCounts?.failed ?? (success ? 0 : 1);
136
+ this.config.progress?.onExecutionComplete?.({
137
+ executionId: this.executionState?.id ?? 'ephemeral',
138
+ mission: mission.name,
139
+ success,
140
+ duration,
141
+ stagesCompleted,
142
+ stagesFailed,
143
+ errors: this.errors,
144
+ });
145
+ return {
146
+ success,
147
+ duration,
148
+ actionsRun: this.actionsRun,
149
+ errors: this.errors,
150
+ stores: this.ctx.stores,
151
+ executionId: this.executionState?.id,
152
+ state: this.executionState,
153
+ };
154
+ }
155
+ async initializeExecutionState(mission) {
156
+ let isResume = false;
157
+ if (this.executionStore) {
158
+ // Resume from previous execution?
159
+ if (this.config.resumeFrom) {
160
+ const previous = await this.executionStore.load(this.config.resumeFrom);
161
+ if (previous) {
162
+ this.executionState = previous;
163
+ this.executionState.status = 'running';
164
+ this.log(`Resuming execution ${previous.id} from previous run`);
165
+ await this.saveExecutionState();
166
+ isResume = true;
167
+ }
168
+ else {
169
+ this.log(`Warning: Could not find execution ${this.config.resumeFrom} to resume`);
170
+ }
171
+ }
172
+ if (!this.executionState) {
173
+ // Create new execution state
174
+ const stages = mission.pipeline.stages.map((s) => this.getStageName(s));
175
+ this.executionState = createExecutionState({
176
+ mission: mission.name,
177
+ stages,
178
+ metadata: this.config.metadata,
179
+ });
180
+ this.executionState.status = 'running';
181
+ await this.saveExecutionState();
182
+ this.log(`Started execution ${this.executionState.id}`);
183
+ }
184
+ }
185
+ // Emit onExecutionStart callback
186
+ this.config.progress?.onExecutionStart?.({
187
+ executionId: this.executionState?.id ?? 'ephemeral',
188
+ mission: mission.name,
189
+ stageCount: mission.pipeline.stages.length,
190
+ isResume,
191
+ metadata: this.config.metadata,
192
+ });
193
+ }
194
+ async saveExecutionState() {
195
+ if (this.executionStore && this.executionState) {
196
+ await this.executionStore.save(this.executionState);
197
+ }
198
+ }
199
+ updateStageState(stageIndex, updates) {
200
+ if (!this.executionState)
201
+ return;
202
+ const stage = this.executionState.stages[stageIndex];
203
+ if (!stage)
204
+ return;
205
+ if (updates.status === 'running' && !stage.startedAt) {
206
+ stage.startedAt = new Date();
207
+ }
208
+ if (updates.status === 'completed' || updates.status === 'failed') {
209
+ stage.completedAt = new Date();
210
+ }
211
+ if (updates.status) {
212
+ stage.status = updates.status;
213
+ }
214
+ if (updates.error) {
215
+ stage.error = updates.error;
216
+ this.executionState.errors.push({
217
+ stageIndex,
218
+ action: stage.action,
219
+ step: 'unknown',
220
+ message: updates.error,
221
+ timestamp: new Date(),
222
+ attempt: stage.attempt,
223
+ });
224
+ }
225
+ }
226
+ async executeMission(mission) {
227
+ this.log(`Executing mission: ${mission.name}`);
228
+ this.missionName = mission.name;
229
+ // Initialize sync store
230
+ this.syncStore = this.config.syncStore ?? new FileSyncStore(mission.name, `${this.config.dataDir ?? '.reqon-data'}/sync`);
231
+ // Initialize sources (HTTP clients)
232
+ for (const source of mission.sources) {
233
+ await this.initializeSource(source);
234
+ }
235
+ // Initialize stores
236
+ for (const store of mission.stores) {
237
+ await this.initializeStore(store);
238
+ }
239
+ // Initialize schemas (for match step schema matching)
240
+ for (const schema of mission.schemas) {
241
+ this.ctx.schemas.set(schema.name, schema);
242
+ this.log(`Registered schema: ${schema.name}`);
243
+ }
244
+ // Build action lookup
245
+ const actions = new Map();
246
+ for (const action of mission.actions) {
247
+ actions.set(action.name, action);
248
+ }
249
+ // Determine resume point
250
+ const resumeIndex = this.executionState ? findResumePoint(this.executionState) : 0;
251
+ if (resumeIndex > 0) {
252
+ const resumeStage = mission.pipeline.stages[resumeIndex];
253
+ const stageName = this.getStageName(resumeStage);
254
+ this.log(`Resuming from stage ${resumeIndex} (${stageName})`);
255
+ }
256
+ // Execute pipeline
257
+ for (let i = 0; i < mission.pipeline.stages.length; i++) {
258
+ const stage = mission.pipeline.stages[i];
259
+ // Skip already completed stages when resuming
260
+ if (i < resumeIndex) {
261
+ this.log(`Skipping ${this.getStageName(stage)} (already completed)`);
262
+ continue;
263
+ }
264
+ // Check condition if present
265
+ if (stage.condition) {
266
+ const shouldRun = evaluate(stage.condition, this.ctx);
267
+ if (!shouldRun) {
268
+ this.log(`Skipping ${this.getStageName(stage)} (condition not met)`);
269
+ this.updateStageState(i, { status: 'skipped' });
270
+ await this.saveExecutionState();
271
+ continue;
272
+ }
273
+ }
274
+ // Execute stage (parallel or sequential)
275
+ if (isParallelStage(stage)) {
276
+ await this.executeParallelStage(i, stage, actions, mission);
277
+ }
278
+ else if (stage.action) {
279
+ await this.executeSequentialStage(i, stage.action, actions, mission);
280
+ }
281
+ }
282
+ }
283
+ getStageName(stage) {
284
+ if (isParallelStage(stage)) {
285
+ return `[${stage.actions.join(', ')}]`;
286
+ }
287
+ return stage.action ?? 'unknown';
288
+ }
289
+ async executeSequentialStage(stageIndex, actionName, actions, mission) {
290
+ const action = actions.get(actionName);
291
+ if (!action) {
292
+ throw new Error(`Action not found: ${actionName}`);
293
+ }
294
+ // Update stage state to running
295
+ this.updateStageState(stageIndex, { status: 'running' });
296
+ await this.saveExecutionState();
297
+ const stageStartTime = Date.now();
298
+ // Emit onStageStart callback
299
+ this.config.progress?.onStageStart?.({
300
+ executionId: this.executionState?.id ?? 'ephemeral',
301
+ mission: mission.name,
302
+ stageIndex,
303
+ stageName: actionName,
304
+ totalStages: mission.pipeline.stages.length,
305
+ });
306
+ try {
307
+ await this.executeAction(action);
308
+ this.actionsRun.push(action.name);
309
+ // Mark stage as completed
310
+ this.updateStageState(stageIndex, { status: 'completed' });
311
+ await this.saveExecutionState();
312
+ // Emit onStageComplete callback (success)
313
+ this.config.progress?.onStageComplete?.({
314
+ executionId: this.executionState?.id ?? 'ephemeral',
315
+ mission: mission.name,
316
+ stageIndex,
317
+ stageName: actionName,
318
+ totalStages: mission.pipeline.stages.length,
319
+ success: true,
320
+ duration: Date.now() - stageStartTime,
321
+ });
322
+ }
323
+ catch (error) {
324
+ // Mark stage as failed
325
+ this.updateStageState(stageIndex, {
326
+ status: 'failed',
327
+ error: error.message,
328
+ });
329
+ await this.saveExecutionState();
330
+ // Emit onStageComplete callback (failure)
331
+ this.config.progress?.onStageComplete?.({
332
+ executionId: this.executionState?.id ?? 'ephemeral',
333
+ mission: mission.name,
334
+ stageIndex,
335
+ stageName: actionName,
336
+ totalStages: mission.pipeline.stages.length,
337
+ success: false,
338
+ duration: Date.now() - stageStartTime,
339
+ error: error.message,
340
+ });
341
+ throw error; // Re-throw to stop execution
342
+ }
343
+ }
344
+ async executeParallelStage(stageIndex, stage, actions, mission) {
345
+ const actionNames = stage.actions;
346
+ const stageName = `[${actionNames.join(', ')}]`;
347
+ // Validate all actions exist
348
+ const actionDefs = [];
349
+ for (const name of actionNames) {
350
+ const action = actions.get(name);
351
+ if (!action) {
352
+ throw new Error(`Action not found: ${name}`);
353
+ }
354
+ actionDefs.push(action);
355
+ }
356
+ // Update stage state to running
357
+ this.updateStageState(stageIndex, { status: 'running' });
358
+ await this.saveExecutionState();
359
+ const stageStartTime = Date.now();
360
+ // Emit onStageStart callback
361
+ this.config.progress?.onStageStart?.({
362
+ executionId: this.executionState?.id ?? 'ephemeral',
363
+ mission: mission.name,
364
+ stageIndex,
365
+ stageName,
366
+ totalStages: mission.pipeline.stages.length,
367
+ });
368
+ this.log(`Executing parallel stage: ${stageName}`);
369
+ try {
370
+ // Execute all actions in parallel
371
+ const results = await Promise.allSettled(actionDefs.map(action => this.executeAction(action)));
372
+ // Check for failures
373
+ const failures = [];
374
+ for (let i = 0; i < results.length; i++) {
375
+ const result = results[i];
376
+ if (result.status === 'fulfilled') {
377
+ this.actionsRun.push(actionDefs[i].name);
378
+ }
379
+ else {
380
+ failures.push({ name: actionDefs[i].name, error: result.reason });
381
+ }
382
+ }
383
+ if (failures.length > 0) {
384
+ const errorMsg = failures.map(f => `${f.name}: ${f.error.message}`).join('; ');
385
+ throw new Error(`Parallel stage failed: ${errorMsg}`);
386
+ }
387
+ // Mark stage as completed
388
+ this.updateStageState(stageIndex, { status: 'completed' });
389
+ await this.saveExecutionState();
390
+ // Emit onStageComplete callback (success)
391
+ this.config.progress?.onStageComplete?.({
392
+ executionId: this.executionState?.id ?? 'ephemeral',
393
+ mission: mission.name,
394
+ stageIndex,
395
+ stageName,
396
+ totalStages: mission.pipeline.stages.length,
397
+ success: true,
398
+ duration: Date.now() - stageStartTime,
399
+ });
400
+ }
401
+ catch (error) {
402
+ // Mark stage as failed
403
+ this.updateStageState(stageIndex, {
404
+ status: 'failed',
405
+ error: error.message,
406
+ });
407
+ await this.saveExecutionState();
408
+ // Emit onStageComplete callback (failure)
409
+ this.config.progress?.onStageComplete?.({
410
+ executionId: this.executionState?.id ?? 'ephemeral',
411
+ mission: mission.name,
412
+ stageIndex,
413
+ stageName,
414
+ totalStages: mission.pipeline.stages.length,
415
+ success: false,
416
+ duration: Date.now() - stageStartTime,
417
+ error: error.message,
418
+ });
419
+ throw error; // Re-throw to stop execution
420
+ }
421
+ }
422
+ async initializeSource(source) {
423
+ // Store source config for later reference
424
+ this.sourceConfigs.set(source.name, source);
425
+ const authConfig = this.config.auth?.[source.name];
426
+ let authProvider;
427
+ if (authConfig) {
428
+ if (authConfig.type === 'bearer' && authConfig.token) {
429
+ authProvider = new BearerAuthProvider(authConfig.token);
430
+ }
431
+ else if (authConfig.type === 'oauth2' && authConfig.accessToken) {
432
+ authProvider = new OAuth2AuthProvider({
433
+ accessToken: authConfig.accessToken,
434
+ refreshToken: authConfig.refreshToken,
435
+ tokenEndpoint: authConfig.tokenEndpoint,
436
+ clientId: authConfig.clientId,
437
+ clientSecret: authConfig.clientSecret,
438
+ });
439
+ }
440
+ }
441
+ // If source has OAS spec, load it
442
+ let baseUrl = source.config.base;
443
+ if (source.specPath) {
444
+ try {
445
+ const oasSource = await loadOAS(source.specPath);
446
+ this.oasSources.set(source.name, oasSource);
447
+ // Use base URL from OAS if not explicitly provided
448
+ if (!baseUrl) {
449
+ baseUrl = oasSource.baseUrl;
450
+ }
451
+ this.log(`Loaded OAS spec for ${source.name}: ${oasSource.operations.size} operations`);
452
+ }
453
+ catch (error) {
454
+ throw new Error(`Failed to load OAS spec for ${source.name}: ${error.message}`);
455
+ }
456
+ }
457
+ if (!baseUrl) {
458
+ throw new Error(`Source ${source.name} has no base URL (provide 'base' or OAS spec with servers)`);
459
+ }
460
+ // Configure rate limiter for this source
461
+ if (source.config.rateLimit) {
462
+ this.rateLimiter.configure(source.name, {
463
+ strategy: source.config.rateLimit.strategy,
464
+ maxWait: source.config.rateLimit.maxWait,
465
+ fallbackRpm: source.config.rateLimit.fallbackRpm,
466
+ });
467
+ this.log(`Rate limit config for ${source.name}: strategy=${source.config.rateLimit.strategy ?? 'pause'}, ` +
468
+ `maxWait=${source.config.rateLimit.maxWait ?? 300}s`);
469
+ }
470
+ // Configure circuit breaker for this source
471
+ if (source.config.circuitBreaker) {
472
+ this.circuitBreaker.configure(source.name, {
473
+ failureThreshold: source.config.circuitBreaker.failureThreshold,
474
+ // Convert seconds to milliseconds for the circuit breaker
475
+ resetTimeout: source.config.circuitBreaker.resetTimeout
476
+ ? source.config.circuitBreaker.resetTimeout * 1000
477
+ : undefined,
478
+ successThreshold: source.config.circuitBreaker.successThreshold,
479
+ failureWindow: source.config.circuitBreaker.failureWindow
480
+ ? source.config.circuitBreaker.failureWindow * 1000
481
+ : undefined,
482
+ });
483
+ this.log(`Circuit breaker config for ${source.name}: ` +
484
+ `failureThreshold=${source.config.circuitBreaker.failureThreshold ?? 5}, ` +
485
+ `resetTimeout=${source.config.circuitBreaker.resetTimeout ?? 30}s`);
486
+ }
487
+ const client = new HttpClient({
488
+ baseUrl,
489
+ auth: authProvider,
490
+ rateLimiter: this.rateLimiter,
491
+ circuitBreaker: this.circuitBreaker,
492
+ sourceName: source.name,
493
+ });
494
+ this.ctx.sources.set(source.name, client);
495
+ this.log(`Initialized source: ${source.name}`);
496
+ }
497
+ async initializeStore(store) {
498
+ // Check for custom store adapter
499
+ if (this.config.stores?.[store.name]) {
500
+ this.ctx.stores.set(store.name, this.config.stores[store.name]);
501
+ this.log(`Initialized store: ${store.name} (custom adapter)`);
502
+ return;
503
+ }
504
+ // Use store factory to create appropriate adapter
505
+ const developmentMode = this.config.developmentMode ?? true;
506
+ const storeType = resolveStoreType(store.storeType, developmentMode);
507
+ const adapter = createStore({
508
+ type: storeType,
509
+ name: store.target,
510
+ baseDir: this.config.dataDir,
511
+ });
512
+ this.ctx.stores.set(store.name, adapter);
513
+ this.log(`Initialized store: ${store.name} (${storeType}${storeType !== store.storeType ? ` <- ${store.storeType}` : ''})`);
514
+ }
515
+ async executeAction(action) {
516
+ this.log(`Executing action: ${action.name}`);
517
+ for (const step of action.steps) {
518
+ await this.executeStep(step, action.name);
519
+ }
520
+ }
521
+ async executeStep(step, actionName, ctx) {
522
+ // Use provided context or default to this.ctx
523
+ const execCtx = ctx ?? this.ctx;
524
+ const originalCtx = this.ctx;
525
+ // Temporarily use the provided context
526
+ if (ctx) {
527
+ this.ctx = ctx;
528
+ }
529
+ try {
530
+ switch (step.type) {
531
+ case 'FetchStep':
532
+ await this.executeFetch(step);
533
+ break;
534
+ case 'ForStep':
535
+ await this.executeFor(step, actionName);
536
+ break;
537
+ case 'MapStep':
538
+ await this.executeMap(step);
539
+ break;
540
+ case 'ValidateStep':
541
+ await this.executeValidate(step);
542
+ break;
543
+ case 'StoreStep':
544
+ await this.executeStore(step);
545
+ break;
546
+ case 'MatchStep':
547
+ await this.executeMatch(step, actionName);
548
+ break;
549
+ case 'LetStep':
550
+ await this.executeLet(step);
551
+ break;
552
+ case 'WebhookStep':
553
+ await this.executeWebhook(step);
554
+ break;
555
+ default:
556
+ throw new Error(`Unknown step type: ${step.type}`);
557
+ }
558
+ }
559
+ catch (error) {
560
+ // Re-throw flow control signals without recording as errors
561
+ if (error instanceof SkipSignal ||
562
+ error instanceof RetrySignal ||
563
+ error instanceof JumpSignal ||
564
+ error instanceof QueueSignal) {
565
+ throw error;
566
+ }
567
+ // AbortError is a controlled abort, still record it
568
+ this.errors.push({
569
+ action: actionName,
570
+ step: step.type,
571
+ message: error.message,
572
+ details: error,
573
+ });
574
+ throw error;
575
+ }
576
+ finally {
577
+ // Restore original context
578
+ if (ctx) {
579
+ this.ctx = originalCtx;
580
+ }
581
+ }
582
+ }
583
+ async executeFetch(step) {
584
+ const fetchHandler = new FetchHandler({
585
+ ctx: this.ctx,
586
+ oasSources: this.oasSources,
587
+ sourceConfigs: this.sourceConfigs,
588
+ syncStore: this.syncStore,
589
+ missionName: this.missionName,
590
+ executionId: this.executionState?.id,
591
+ dryRun: this.config.dryRun,
592
+ log: (msg) => this.log(msg),
593
+ });
594
+ const result = await fetchHandler.execute(step);
595
+ this.ctx.response = result.data;
596
+ // Update sync checkpoint after successful fetch
597
+ if (result.checkpointKey && this.syncStore) {
598
+ await fetchHandler.recordCheckpoint(result.checkpointKey, step, result.data);
599
+ }
600
+ }
601
+ async executeFor(step, actionName) {
602
+ const handler = new ForHandler({
603
+ ctx: this.ctx,
604
+ log: (msg) => this.log(msg),
605
+ executeStep: (s, a, c) => this.executeStep(s, a, c),
606
+ actionName,
607
+ });
608
+ await handler.execute(step);
609
+ }
610
+ async executeMap(step) {
611
+ const handler = new MapHandler({
612
+ ctx: this.ctx,
613
+ log: (msg) => this.log(msg),
614
+ });
615
+ await handler.execute(step);
616
+ }
617
+ async executeValidate(step) {
618
+ const handler = new ValidateHandler({
619
+ ctx: this.ctx,
620
+ log: (msg) => this.log(msg),
621
+ });
622
+ await handler.execute(step);
623
+ }
624
+ async executeStore(step) {
625
+ const handler = new StoreHandler({
626
+ ctx: this.ctx,
627
+ log: (msg) => this.log(msg),
628
+ });
629
+ await handler.execute(step);
630
+ }
631
+ async executeMatch(step, actionName) {
632
+ const handler = new MatchHandler({
633
+ ctx: this.ctx,
634
+ log: (msg) => this.log(msg),
635
+ executeStep: (s, a, c) => this.executeStep(s, a, c),
636
+ actionName,
637
+ });
638
+ await handler.execute(step);
639
+ // Flow control signals (SkipSignal, RetrySignal, etc.) will propagate up
640
+ }
641
+ async executeLet(step) {
642
+ const value = evaluate(step.value, this.ctx);
643
+ setVariable(this.ctx, step.name, value);
644
+ this.log(`Set variable '${step.name}' = ${JSON.stringify(value)}`);
645
+ }
646
+ async executeWebhook(step) {
647
+ if (!this.config.webhookServer) {
648
+ throw new Error('Webhook server not configured. Use --webhook flag or configure webhookServer in executor config.');
649
+ }
650
+ const handler = new WebhookHandler({
651
+ ctx: this.ctx,
652
+ webhookServer: this.config.webhookServer,
653
+ executionId: this.executionState?.id ?? 'ephemeral',
654
+ log: (msg) => this.log(msg),
655
+ });
656
+ await handler.execute(step);
657
+ }
658
+ log(message) {
659
+ if (this.config.verbose) {
660
+ console.log(`[Reqon] ${message}`);
661
+ }
662
+ }
663
+ }