@probelabs/visor 0.1.106 → 0.1.107

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 (450) hide show
  1. package/README.md +65 -2
  2. package/action.yml +1 -1
  3. package/defaults/code-refiner.yaml +114 -0
  4. package/defaults/{.visor.yaml → code-review.yaml} +35 -226
  5. package/defaults/override.yaml +52 -0
  6. package/defaults/task-refinement.yaml +620 -0
  7. package/defaults/visor.tests.yaml +674 -0
  8. package/defaults/visor.yaml +482 -0
  9. package/dist/663.index.js +2 -3
  10. package/dist/80.index.js +2 -3
  11. package/dist/action-cli-bridge.d.ts +11 -82
  12. package/dist/action-cli-bridge.d.ts.map +1 -1
  13. package/dist/ai-review-service.d.ts +15 -0
  14. package/dist/ai-review-service.d.ts.map +1 -1
  15. package/dist/check-execution-engine.d.ts +19 -331
  16. package/dist/check-execution-engine.d.ts.map +1 -1
  17. package/dist/cli-main.d.ts.map +1 -1
  18. package/dist/cli.d.ts +0 -1
  19. package/dist/cli.d.ts.map +1 -1
  20. package/dist/config.d.ts +16 -0
  21. package/dist/config.d.ts.map +1 -1
  22. package/dist/cron-scheduler.d.ts +3 -3
  23. package/dist/cron-scheduler.d.ts.map +1 -1
  24. package/dist/debug-visualizer/ws-server.d.ts.map +1 -1
  25. package/dist/defaults/code-refiner.yaml +114 -0
  26. package/dist/defaults/{.visor.yaml → code-review.yaml} +35 -226
  27. package/dist/defaults/override.yaml +52 -0
  28. package/dist/defaults/task-refinement.yaml +620 -0
  29. package/dist/defaults/visor.tests.yaml +674 -0
  30. package/dist/defaults/visor.yaml +482 -0
  31. package/dist/docs/DEPLOYMENT.md +118 -0
  32. package/dist/docs/GITHUB_CHECKS.md +280 -0
  33. package/dist/docs/NPM_USAGE.md +208 -0
  34. package/dist/docs/action-reference.md +19 -0
  35. package/dist/docs/advanced-ai.md +178 -0
  36. package/dist/docs/ai-configuration.md +468 -0
  37. package/dist/docs/author-permissions.md +610 -0
  38. package/dist/docs/ci-cli-mode.md +34 -0
  39. package/dist/docs/claude-code.md +74 -0
  40. package/dist/docs/command-provider.md +559 -0
  41. package/dist/docs/commands.md +8 -0
  42. package/dist/docs/configuration.md +303 -0
  43. package/dist/docs/custom-tools.md +424 -0
  44. package/dist/docs/dashboards/README.md +23 -0
  45. package/dist/docs/dashboards/grafana-visor-diagrams.json +20 -0
  46. package/dist/docs/dashboards/grafana-visor-overview.json +33 -0
  47. package/dist/docs/debug-visualizer-progress.md +572 -0
  48. package/dist/docs/debug-visualizer-rfc.md +691 -0
  49. package/dist/docs/debug-visualizer.md +114 -0
  50. package/dist/docs/debugging.md +636 -0
  51. package/dist/docs/default-output-schema.md +28 -0
  52. package/dist/docs/dependencies.md +369 -0
  53. package/dist/docs/dev-playbook.md +9 -0
  54. package/dist/docs/engine-state-machine-plan.md +333 -0
  55. package/dist/docs/event-driven-github-integration-rfc.md +743 -0
  56. package/dist/docs/event-triggers.md +292 -0
  57. package/dist/docs/execution-statistics-rfc.md +290 -0
  58. package/dist/docs/fact-validator-gap-analysis.md +178 -0
  59. package/dist/docs/fact-validator-implementation-plan.md +1235 -0
  60. package/dist/docs/fail-if.md +95 -0
  61. package/dist/docs/failure-conditions-implementation.md +271 -0
  62. package/dist/docs/failure-conditions-schema.md +173 -0
  63. package/dist/docs/failure-routing-rfc.md +193 -0
  64. package/dist/docs/failure-routing.md +507 -0
  65. package/dist/docs/foreach-dependency-propagation.md +473 -0
  66. package/dist/docs/github-ops.md +89 -0
  67. package/dist/docs/goto-forward-run-plan.md +113 -0
  68. package/dist/docs/guides/criticality-modes.md +332 -0
  69. package/dist/docs/guides/fault-management-and-contracts.md +738 -0
  70. package/dist/docs/guides/workflow-style-guide.md +224 -0
  71. package/dist/docs/http.md +299 -0
  72. package/dist/docs/human-input-provider.md +372 -0
  73. package/dist/docs/limits.md +64 -0
  74. package/dist/docs/liquid-templates.md +347 -0
  75. package/dist/docs/loop-routing-refactor.md +89 -0
  76. package/dist/docs/mcp-provider.md +557 -0
  77. package/dist/docs/mcp.md +124 -0
  78. package/dist/docs/memory.md +903 -0
  79. package/dist/docs/observability.md +12 -0
  80. package/dist/docs/output-formats.md +20 -0
  81. package/dist/docs/output-formatting.md +29 -0
  82. package/dist/docs/output-history.md +383 -0
  83. package/dist/docs/performance.md +6 -0
  84. package/dist/docs/pluggable.md +124 -0
  85. package/dist/docs/proposals/snapshot-scope-execution.md +236 -0
  86. package/dist/docs/recipes.md +21 -0
  87. package/dist/docs/roadmap/criticality-implementation-tasks.md +92 -0
  88. package/dist/docs/schema-next-pr.md +10 -0
  89. package/dist/docs/schema-templates.md +68 -0
  90. package/dist/docs/script.md +34 -0
  91. package/dist/docs/sdk.md +222 -0
  92. package/dist/docs/security.md +7 -0
  93. package/dist/docs/suppressions.md +89 -0
  94. package/dist/docs/tag-filtering.md +258 -0
  95. package/dist/docs/telemetry-setup.md +119 -0
  96. package/dist/docs/telemetry-tracing-rfc.md +275 -0
  97. package/dist/docs/test-framework-rfc.md +680 -0
  98. package/dist/docs/testing/assertions.md +85 -0
  99. package/dist/docs/testing/ci.md +44 -0
  100. package/dist/docs/testing/cli.md +41 -0
  101. package/dist/docs/testing/cookbook.md +172 -0
  102. package/dist/docs/testing/dsl-reference.md +199 -0
  103. package/dist/docs/testing/fixtures-and-mocks.md +91 -0
  104. package/dist/docs/testing/flows.md +92 -0
  105. package/dist/docs/testing/getting-started.md +93 -0
  106. package/dist/docs/testing/troubleshooting.md +55 -0
  107. package/dist/docs/timeouts.md +50 -0
  108. package/dist/docs/troubleshooting.md +7 -0
  109. package/dist/docs/visor-sdk-rfc.md +186 -0
  110. package/dist/docs/workflows.md +569 -0
  111. package/dist/engine/on-finish/orchestrator.d.ts +19 -0
  112. package/dist/engine/on-finish/orchestrator.d.ts.map +1 -0
  113. package/dist/engine/on-finish/utils.d.ts +44 -0
  114. package/dist/engine/on-finish/utils.d.ts.map +1 -0
  115. package/dist/event-bus/event-bus.d.ts +13 -0
  116. package/dist/event-bus/event-bus.d.ts.map +1 -0
  117. package/dist/event-bus/types.d.ts +57 -0
  118. package/dist/event-bus/types.d.ts.map +1 -0
  119. package/dist/examples/.claude/agents/code-reviewer.md +69 -0
  120. package/dist/examples/.mcp.json +34 -0
  121. package/dist/examples/CALCULATOR-SDK.md +364 -0
  122. package/dist/examples/README.md +384 -0
  123. package/dist/examples/ai-retry-fallback-config.yaml +180 -0
  124. package/dist/examples/ai-with-bash.yaml +126 -0
  125. package/dist/examples/ai-with-mcp.yaml +82 -0
  126. package/dist/examples/basic-human-input.yaml +15 -0
  127. package/dist/examples/bedrock-config.yaml +77 -0
  128. package/dist/examples/calculator-config.yaml +133 -0
  129. package/dist/examples/calculator-json-output-guide.md +311 -0
  130. package/dist/examples/calculator-sdk-automated.ts +340 -0
  131. package/dist/examples/calculator-sdk-example.ts +275 -0
  132. package/dist/examples/calculator-sdk-json.ts +331 -0
  133. package/dist/examples/calculator-sdk-real.ts +374 -0
  134. package/dist/examples/calculator-sdk-test.ts +148 -0
  135. package/dist/examples/claude-code-config.yaml +191 -0
  136. package/dist/examples/cron-webhook-config.yaml +215 -0
  137. package/dist/examples/custom-template.liquid +57 -0
  138. package/dist/examples/custom-tools-example.yaml +281 -0
  139. package/dist/examples/enhanced-config.yaml +165 -0
  140. package/dist/examples/environments/visor.base.yaml +92 -0
  141. package/dist/examples/environments/visor.dev.yaml +33 -0
  142. package/dist/examples/environments/visor.prod.yaml +95 -0
  143. package/dist/examples/environments/visor.staging.yaml +46 -0
  144. package/dist/examples/fact-validator.yaml +361 -0
  145. package/dist/examples/fail-if-simple.yaml +90 -0
  146. package/dist/examples/failure-conditions-advanced.yaml +136 -0
  147. package/dist/examples/failure-conditions-basic.yaml +48 -0
  148. package/dist/examples/failure-conditions-github-style.yaml +119 -0
  149. package/dist/examples/failure-conditions-migration.yaml +74 -0
  150. package/dist/examples/for-loop-example.yaml +176 -0
  151. package/dist/examples/forEach-example.yaml +120 -0
  152. package/dist/examples/github-workflow-with-tags.yml +163 -0
  153. package/dist/examples/http-integration-config.yaml +240 -0
  154. package/dist/examples/https-server-config.yaml +209 -0
  155. package/dist/examples/human-input-example.yaml +63 -0
  156. package/dist/examples/if-conditions.yaml +173 -0
  157. package/dist/examples/jira-simple-example.yaml +56 -0
  158. package/dist/examples/jira-single-issue-workflow.yaml +166 -0
  159. package/dist/examples/jira-workflow-mcp.yaml +182 -0
  160. package/dist/examples/mcp/analyzer.py +119 -0
  161. package/dist/examples/mcp-provider-example.yaml +301 -0
  162. package/dist/examples/memory-counter.yaml +99 -0
  163. package/dist/examples/memory-error-collection.yaml +104 -0
  164. package/dist/examples/memory-exec-js.yaml +247 -0
  165. package/dist/examples/memory-namespace-isolation.yaml +184 -0
  166. package/dist/examples/memory-retry-counter.yaml +65 -0
  167. package/dist/examples/memory-state-machine.yaml +170 -0
  168. package/dist/examples/outputs-raw-basic.yaml +26 -0
  169. package/dist/examples/project-with-tools.yaml +174 -0
  170. package/dist/examples/prompts/architecture-analysis.liquid +116 -0
  171. package/dist/examples/prompts/security-comprehensive.liquid +107 -0
  172. package/dist/examples/quick-start-tags.yaml +53 -0
  173. package/dist/examples/routing-basic.yaml +35 -0
  174. package/dist/examples/routing-dynamic-js.yaml +46 -0
  175. package/dist/examples/routing-foreach.yaml +34 -0
  176. package/dist/examples/routing-goto-event.yaml +34 -0
  177. package/dist/examples/routing-on-success.yaml +25 -0
  178. package/dist/examples/run-calculator-demo.sh +71 -0
  179. package/dist/examples/sdk-basic.mjs +10 -0
  180. package/dist/examples/sdk-cjs.cjs +10 -0
  181. package/dist/examples/sdk-comprehensive.mjs +175 -0
  182. package/dist/examples/sdk-manual-config.mjs +65 -0
  183. package/dist/examples/sdk-typescript.js +81 -0
  184. package/dist/examples/sdk-typescript.ts +92 -0
  185. package/dist/examples/session-reuse-config.yaml +151 -0
  186. package/dist/examples/templates/security-report.liquid +137 -0
  187. package/dist/examples/tools-library.yaml +281 -0
  188. package/dist/examples/transform-example.yaml +199 -0
  189. package/dist/examples/visor-with-tags.yaml +198 -0
  190. package/dist/examples/webhook-pipeline-config.yaml +218 -0
  191. package/dist/examples/workflows/calculator-workflow.yaml +163 -0
  192. package/dist/examples/workflows/code-quality.yaml +222 -0
  193. package/dist/examples/workflows/quick-pr-check.yaml +90 -0
  194. package/dist/examples/workflows/workflow-composition-example.yaml +130 -0
  195. package/dist/failure-condition-evaluator.d.ts +1 -0
  196. package/dist/failure-condition-evaluator.d.ts.map +1 -1
  197. package/dist/frontends/github-frontend.d.ts +38 -0
  198. package/dist/frontends/github-frontend.d.ts.map +1 -0
  199. package/dist/frontends/host.d.ts +43 -0
  200. package/dist/frontends/host.d.ts.map +1 -0
  201. package/dist/frontends/ndjson-sink.d.ts +12 -0
  202. package/dist/frontends/ndjson-sink.d.ts.map +1 -0
  203. package/dist/generated/config-schema.d.ts +564 -22
  204. package/dist/generated/config-schema.d.ts.map +1 -1
  205. package/dist/generated/config-schema.json +612 -24
  206. package/dist/github-check-service.d.ts +4 -6
  207. package/dist/github-check-service.d.ts.map +1 -1
  208. package/dist/github-comments.d.ts +0 -4
  209. package/dist/github-comments.d.ts.map +1 -1
  210. package/dist/index.d.ts.map +1 -1
  211. package/dist/index.js +70335 -62514
  212. package/dist/liquid-extensions.d.ts.map +1 -1
  213. package/dist/logger.d.ts +1 -0
  214. package/dist/logger.d.ts.map +1 -1
  215. package/dist/memory-store.d.ts +6 -0
  216. package/dist/memory-store.d.ts.map +1 -1
  217. package/dist/output/assistant-json/template.liquid +0 -0
  218. package/dist/output/traces/run-2025-11-21T11-50-46-505Z.ndjson +138 -0
  219. package/dist/output/traces/run-2025-11-21T11-51-33-674Z.ndjson +839 -0
  220. package/dist/output-formatters.d.ts +1 -1
  221. package/dist/output-formatters.d.ts.map +1 -1
  222. package/dist/providers/ai-check-provider.d.ts.map +1 -1
  223. package/dist/providers/check-provider-registry.d.ts +6 -0
  224. package/dist/providers/check-provider-registry.d.ts.map +1 -1
  225. package/dist/providers/check-provider.interface.d.ts +34 -1
  226. package/dist/providers/check-provider.interface.d.ts.map +1 -1
  227. package/dist/providers/claude-code-check-provider.d.ts.map +1 -1
  228. package/dist/providers/command-check-provider.d.ts +1 -1
  229. package/dist/providers/command-check-provider.d.ts.map +1 -1
  230. package/dist/providers/custom-tool-executor.d.ts +61 -0
  231. package/dist/providers/custom-tool-executor.d.ts.map +1 -0
  232. package/dist/providers/github-ops-provider.d.ts.map +1 -1
  233. package/dist/providers/http-client-provider.d.ts +1 -4
  234. package/dist/providers/http-client-provider.d.ts.map +1 -1
  235. package/dist/providers/human-input-check-provider.d.ts +3 -0
  236. package/dist/providers/human-input-check-provider.d.ts.map +1 -1
  237. package/dist/providers/index.d.ts +1 -0
  238. package/dist/providers/index.d.ts.map +1 -1
  239. package/dist/providers/log-check-provider.d.ts +2 -5
  240. package/dist/providers/log-check-provider.d.ts.map +1 -1
  241. package/dist/providers/mcp-check-provider.d.ts +9 -3
  242. package/dist/providers/mcp-check-provider.d.ts.map +1 -1
  243. package/dist/providers/memory-check-provider.d.ts +2 -8
  244. package/dist/providers/memory-check-provider.d.ts.map +1 -1
  245. package/dist/providers/script-check-provider.d.ts +25 -0
  246. package/dist/providers/script-check-provider.d.ts.map +1 -0
  247. package/dist/providers/workflow-check-provider.d.ts +56 -0
  248. package/dist/providers/workflow-check-provider.d.ts.map +1 -0
  249. package/dist/reviewer.d.ts +2 -1
  250. package/dist/reviewer.d.ts.map +1 -1
  251. package/dist/sdk/chunk-37ZSCMFC.mjs +482 -0
  252. package/dist/sdk/chunk-37ZSCMFC.mjs.map +1 -0
  253. package/dist/sdk/chunk-6Y4YTKCF.mjs +197 -0
  254. package/dist/sdk/chunk-6Y4YTKCF.mjs.map +1 -0
  255. package/dist/sdk/chunk-CNX7V5JK.mjs +89 -0
  256. package/dist/sdk/chunk-CNX7V5JK.mjs.map +1 -0
  257. package/dist/sdk/chunk-IEO6CFLG.mjs +1215 -0
  258. package/dist/sdk/chunk-IEO6CFLG.mjs.map +1 -0
  259. package/dist/sdk/chunk-JEHPDJIF.mjs +223 -0
  260. package/dist/sdk/chunk-JEHPDJIF.mjs.map +1 -0
  261. package/dist/sdk/chunk-O5EZDNYL.mjs +274 -0
  262. package/dist/sdk/chunk-O5EZDNYL.mjs.map +1 -0
  263. package/dist/sdk/{chunk-TUTOLSFV.mjs → chunk-OOZITMRU.mjs} +1 -1
  264. package/dist/sdk/chunk-OOZITMRU.mjs.map +1 -0
  265. package/dist/sdk/chunk-OWUVOILT.mjs +557 -0
  266. package/dist/sdk/chunk-OWUVOILT.mjs.map +1 -0
  267. package/dist/sdk/chunk-OZJ263FM.mjs +986 -0
  268. package/dist/sdk/chunk-OZJ263FM.mjs.map +1 -0
  269. package/dist/sdk/chunk-PTL3K3PN.mjs +3128 -0
  270. package/dist/sdk/chunk-PTL3K3PN.mjs.map +1 -0
  271. package/dist/sdk/chunk-S2RUE2RG.mjs +145 -0
  272. package/dist/sdk/chunk-S2RUE2RG.mjs.map +1 -0
  273. package/dist/sdk/chunk-VMPLF6FT.mjs +127 -0
  274. package/dist/sdk/chunk-VMPLF6FT.mjs.map +1 -0
  275. package/dist/sdk/chunk-YSN4G6CI.mjs +146 -0
  276. package/dist/sdk/chunk-YSN4G6CI.mjs.map +1 -0
  277. package/dist/sdk/chunk-ZYAUYXSW.mjs +206 -0
  278. package/dist/sdk/chunk-ZYAUYXSW.mjs.map +1 -0
  279. package/dist/sdk/config-M4ZNO6NU.mjs +14 -0
  280. package/dist/sdk/config-merger-PX3WIT57.mjs +10 -0
  281. package/dist/sdk/event-bus-5BEVPQ6T.mjs +35 -0
  282. package/dist/sdk/event-bus-5BEVPQ6T.mjs.map +1 -0
  283. package/dist/sdk/failure-condition-evaluator-NBO5YRXW.mjs +16 -0
  284. package/dist/sdk/git-repository-analyzer-HJC4MYW4.mjs +458 -0
  285. package/dist/sdk/git-repository-analyzer-HJC4MYW4.mjs.map +1 -0
  286. package/dist/sdk/github-frontend-4AWRJT7D.mjs +1242 -0
  287. package/dist/sdk/github-frontend-4AWRJT7D.mjs.map +1 -0
  288. package/dist/sdk/host-7GBC3S7L.mjs +49 -0
  289. package/dist/sdk/host-7GBC3S7L.mjs.map +1 -0
  290. package/dist/sdk/{liquid-extensions-KVL4MKRH.mjs → liquid-extensions-C7EG3YKH.mjs} +7 -2
  291. package/dist/sdk/memory-store-GJACZC2A.mjs +11 -0
  292. package/dist/sdk/metrics-7PP3EJUH.mjs +29 -0
  293. package/dist/sdk/ndjson-sink-B4V4NTAQ.mjs +44 -0
  294. package/dist/sdk/ndjson-sink-B4V4NTAQ.mjs.map +1 -0
  295. package/dist/sdk/renderer-schema-6RF26VUS.mjs +50 -0
  296. package/dist/sdk/renderer-schema-6RF26VUS.mjs.map +1 -0
  297. package/dist/sdk/routing-RP56JTV2.mjs +23 -0
  298. package/dist/sdk/routing-RP56JTV2.mjs.map +1 -0
  299. package/dist/sdk/sdk.d.mts +326 -21
  300. package/dist/sdk/sdk.d.ts +326 -21
  301. package/dist/sdk/sdk.js +21403 -16366
  302. package/dist/sdk/sdk.js.map +1 -1
  303. package/dist/sdk/sdk.mjs +13510 -2096
  304. package/dist/sdk/sdk.mjs.map +1 -1
  305. package/dist/sdk/session-registry-N5FFYFTM.mjs +10 -0
  306. package/dist/sdk/session-registry-N5FFYFTM.mjs.map +1 -0
  307. package/dist/sdk/trace-helpers-VP6QYVBX.mjs +23 -0
  308. package/dist/sdk/trace-helpers-VP6QYVBX.mjs.map +1 -0
  309. package/dist/sdk/{tracer-init-WC75N5NW.mjs → tracer-init-WP4X46IF.mjs} +2 -2
  310. package/dist/sdk/tracer-init-WP4X46IF.mjs.map +1 -0
  311. package/dist/sdk/workflow-registry-2YIIXQCK.mjs +11 -0
  312. package/dist/sdk/workflow-registry-2YIIXQCK.mjs.map +1 -0
  313. package/dist/sdk.d.ts.map +1 -1
  314. package/dist/snapshot-store.d.ts +59 -0
  315. package/dist/snapshot-store.d.ts.map +1 -0
  316. package/dist/state-machine/context/build-engine-context.d.ts +9 -0
  317. package/dist/state-machine/context/build-engine-context.d.ts.map +1 -0
  318. package/dist/state-machine/dispatch/dependency-gating.d.ts +12 -0
  319. package/dist/state-machine/dispatch/dependency-gating.d.ts.map +1 -0
  320. package/dist/state-machine/dispatch/execution-invoker.d.ts +14 -0
  321. package/dist/state-machine/dispatch/execution-invoker.d.ts.map +1 -0
  322. package/dist/state-machine/dispatch/foreach-processor.d.ts +8 -0
  323. package/dist/state-machine/dispatch/foreach-processor.d.ts.map +1 -0
  324. package/dist/state-machine/dispatch/history-snapshot.d.ts +8 -0
  325. package/dist/state-machine/dispatch/history-snapshot.d.ts.map +1 -0
  326. package/dist/state-machine/dispatch/renderer-schema.d.ts +8 -0
  327. package/dist/state-machine/dispatch/renderer-schema.d.ts.map +1 -0
  328. package/dist/state-machine/dispatch/stats-manager.d.ts +15 -0
  329. package/dist/state-machine/dispatch/stats-manager.d.ts.map +1 -0
  330. package/dist/state-machine/dispatch/template-renderer.d.ts +7 -0
  331. package/dist/state-machine/dispatch/template-renderer.d.ts.map +1 -0
  332. package/dist/state-machine/execution/summary.d.ts +8 -0
  333. package/dist/state-machine/execution/summary.d.ts.map +1 -0
  334. package/dist/state-machine/runner.d.ts +73 -0
  335. package/dist/state-machine/runner.d.ts.map +1 -0
  336. package/dist/state-machine/states/check-running.d.ts +14 -0
  337. package/dist/state-machine/states/check-running.d.ts.map +1 -0
  338. package/dist/state-machine/states/completed.d.ts +12 -0
  339. package/dist/state-machine/states/completed.d.ts.map +1 -0
  340. package/dist/state-machine/states/error.d.ts +11 -0
  341. package/dist/state-machine/states/error.d.ts.map +1 -0
  342. package/dist/state-machine/states/init.d.ts +11 -0
  343. package/dist/state-machine/states/init.d.ts.map +1 -0
  344. package/dist/state-machine/states/level-dispatch.d.ts +17 -0
  345. package/dist/state-machine/states/level-dispatch.d.ts.map +1 -0
  346. package/dist/state-machine/states/plan-ready.d.ts +12 -0
  347. package/dist/state-machine/states/plan-ready.d.ts.map +1 -0
  348. package/dist/state-machine/states/routing.d.ts +52 -0
  349. package/dist/state-machine/states/routing.d.ts.map +1 -0
  350. package/dist/state-machine/states/wave-planning.d.ts +14 -0
  351. package/dist/state-machine/states/wave-planning.d.ts.map +1 -0
  352. package/dist/state-machine/workflow-projection.d.ts +47 -0
  353. package/dist/state-machine/workflow-projection.d.ts.map +1 -0
  354. package/dist/state-machine-execution-engine.d.ts +147 -0
  355. package/dist/state-machine-execution-engine.d.ts.map +1 -0
  356. package/dist/telemetry/opentelemetry.d.ts.map +1 -1
  357. package/dist/test-runner/assertions.d.ts +59 -0
  358. package/dist/test-runner/assertions.d.ts.map +1 -0
  359. package/dist/test-runner/core/environment.d.ts +8 -0
  360. package/dist/test-runner/core/environment.d.ts.map +1 -0
  361. package/dist/test-runner/core/fixture.d.ts +3 -0
  362. package/dist/test-runner/core/fixture.d.ts.map +1 -0
  363. package/dist/test-runner/core/flow-stage.d.ts +32 -0
  364. package/dist/test-runner/core/flow-stage.d.ts.map +1 -0
  365. package/dist/test-runner/core/mocks.d.ts +8 -0
  366. package/dist/test-runner/core/mocks.d.ts.map +1 -0
  367. package/dist/test-runner/core/test-execution-wrapper.d.ts +18 -0
  368. package/dist/test-runner/core/test-execution-wrapper.d.ts.map +1 -0
  369. package/dist/test-runner/evaluators.d.ts +12 -0
  370. package/dist/test-runner/evaluators.d.ts.map +1 -0
  371. package/dist/test-runner/fixture-loader.d.ts +30 -0
  372. package/dist/test-runner/fixture-loader.d.ts.map +1 -0
  373. package/dist/test-runner/index.d.ts +120 -0
  374. package/dist/test-runner/index.d.ts.map +1 -0
  375. package/dist/test-runner/recorders/github-recorder.d.ts +23 -0
  376. package/dist/test-runner/recorders/github-recorder.d.ts.map +1 -0
  377. package/dist/test-runner/recorders/global-recorder.d.ts +4 -0
  378. package/dist/test-runner/recorders/global-recorder.d.ts.map +1 -0
  379. package/dist/test-runner/utils/selectors.d.ts +2 -0
  380. package/dist/test-runner/utils/selectors.d.ts.map +1 -0
  381. package/dist/test-runner/validator.d.ts +8 -0
  382. package/dist/test-runner/validator.d.ts.map +1 -0
  383. package/dist/traces/run-2025-11-21T11-50-46-505Z.ndjson +138 -0
  384. package/dist/traces/run-2025-11-21T11-51-33-674Z.ndjson +839 -0
  385. package/dist/types/cli.d.ts +4 -1
  386. package/dist/types/cli.d.ts.map +1 -1
  387. package/dist/types/config.d.ts +278 -5
  388. package/dist/types/config.d.ts.map +1 -1
  389. package/dist/types/engine.d.ts +172 -0
  390. package/dist/types/engine.d.ts.map +1 -0
  391. package/dist/types/execution.d.ts +73 -0
  392. package/dist/types/execution.d.ts.map +1 -0
  393. package/dist/types/github.d.ts +51 -0
  394. package/dist/types/github.d.ts.map +1 -0
  395. package/dist/types/workflow.d.ts +237 -0
  396. package/dist/types/workflow.d.ts.map +1 -0
  397. package/dist/utils/command-executor.d.ts +43 -0
  398. package/dist/utils/command-executor.d.ts.map +1 -0
  399. package/dist/utils/comment-metadata.d.ts +21 -0
  400. package/dist/utils/comment-metadata.d.ts.map +1 -0
  401. package/dist/utils/config-loader.d.ts.map +1 -1
  402. package/dist/utils/config-merger.d.ts.map +1 -1
  403. package/dist/utils/env-exposure.d.ts +3 -0
  404. package/dist/utils/env-exposure.d.ts.map +1 -0
  405. package/dist/utils/file-exclusion.d.ts.map +1 -1
  406. package/dist/utils/interactive-prompt.d.ts +1 -1
  407. package/dist/utils/interactive-prompt.d.ts.map +1 -1
  408. package/dist/utils/sandbox.d.ts.map +1 -1
  409. package/dist/utils/script-memory-ops.d.ts +21 -0
  410. package/dist/utils/script-memory-ops.d.ts.map +1 -0
  411. package/dist/utils/template-context.d.ts +7 -0
  412. package/dist/utils/template-context.d.ts.map +1 -0
  413. package/dist/webhook-server.d.ts +3 -3
  414. package/dist/webhook-server.d.ts.map +1 -1
  415. package/dist/workflow-executor.d.ts +81 -0
  416. package/dist/workflow-executor.d.ts.map +1 -0
  417. package/dist/workflow-registry.d.ts +79 -0
  418. package/dist/workflow-registry.d.ts.map +1 -0
  419. package/package.json +10 -5
  420. package/dist/output/traces/run-2025-10-22T18-22-56-873Z.ndjson +0 -218
  421. package/dist/sdk/check-execution-engine-2YYKUUSH.mjs +0 -11
  422. package/dist/sdk/check-execution-engine-6QJXYYON.mjs +0 -11
  423. package/dist/sdk/check-execution-engine-PJZ4ZOKG.mjs +0 -11
  424. package/dist/sdk/chunk-33QVZ2D4.mjs +0 -316
  425. package/dist/sdk/chunk-33QVZ2D4.mjs.map +0 -1
  426. package/dist/sdk/chunk-B5QBV2QJ.mjs +0 -752
  427. package/dist/sdk/chunk-B5QBV2QJ.mjs.map +0 -1
  428. package/dist/sdk/chunk-BVFNRCHT.mjs +0 -14129
  429. package/dist/sdk/chunk-BVFNRCHT.mjs.map +0 -1
  430. package/dist/sdk/chunk-KWZW23FG.mjs +0 -14129
  431. package/dist/sdk/chunk-KWZW23FG.mjs.map +0 -1
  432. package/dist/sdk/chunk-O4RP4BRH.mjs +0 -14092
  433. package/dist/sdk/chunk-O4RP4BRH.mjs.map +0 -1
  434. package/dist/sdk/chunk-TUTOLSFV.mjs.map +0 -1
  435. package/dist/sdk/chunk-U5D2LY66.mjs +0 -245
  436. package/dist/sdk/chunk-U5D2LY66.mjs.map +0 -1
  437. package/dist/sdk/chunk-U7X54EMV.mjs +0 -331
  438. package/dist/sdk/chunk-U7X54EMV.mjs.map +0 -1
  439. package/dist/sdk/config-merger-TWUBWFC2.mjs +0 -8
  440. package/dist/sdk/mermaid-telemetry-SN6A2TKW.mjs +0 -61
  441. package/dist/sdk/mermaid-telemetry-SN6A2TKW.mjs.map +0 -1
  442. package/dist/sdk/mermaid-telemetry-YCTIG76M.mjs +0 -61
  443. package/dist/sdk/mermaid-telemetry-YCTIG76M.mjs.map +0 -1
  444. package/dist/traces/run-2025-10-22T18-22-56-873Z.ndjson +0 -218
  445. /package/dist/sdk/{check-execution-engine-2YYKUUSH.mjs.map → config-M4ZNO6NU.mjs.map} +0 -0
  446. /package/dist/sdk/{check-execution-engine-6QJXYYON.mjs.map → config-merger-PX3WIT57.mjs.map} +0 -0
  447. /package/dist/sdk/{check-execution-engine-PJZ4ZOKG.mjs.map → failure-condition-evaluator-NBO5YRXW.mjs.map} +0 -0
  448. /package/dist/sdk/{config-merger-TWUBWFC2.mjs.map → liquid-extensions-C7EG3YKH.mjs.map} +0 -0
  449. /package/dist/sdk/{liquid-extensions-KVL4MKRH.mjs.map → memory-store-GJACZC2A.mjs.map} +0 -0
  450. /package/dist/sdk/{tracer-init-WC75N5NW.mjs.map → metrics-7PP3EJUH.mjs.map} +0 -0
@@ -0,0 +1,986 @@
1
+ import {
2
+ createPermissionHelpers,
3
+ detectLocalMode,
4
+ init_author_permissions
5
+ } from "./chunk-CNX7V5JK.mjs";
6
+ import {
7
+ addEvent,
8
+ fallback_ndjson_exports,
9
+ init_fallback_ndjson,
10
+ init_trace_helpers
11
+ } from "./chunk-ZYAUYXSW.mjs";
12
+ import {
13
+ addFailIfTriggered,
14
+ init_metrics
15
+ } from "./chunk-S2RUE2RG.mjs";
16
+ import {
17
+ MemoryStore,
18
+ init_memory_store
19
+ } from "./chunk-37ZSCMFC.mjs";
20
+ import {
21
+ init_logger,
22
+ logger_exports
23
+ } from "./chunk-VMPLF6FT.mjs";
24
+ import {
25
+ __esm,
26
+ __export,
27
+ __require,
28
+ __toCommonJS
29
+ } from "./chunk-WMJKH4XE.mjs";
30
+
31
+ // src/utils/sandbox.ts
32
+ import Sandbox from "@nyariv/sandboxjs";
33
+ function createSecureSandbox() {
34
+ const globals = {
35
+ ...Sandbox.SAFE_GLOBALS,
36
+ Math,
37
+ JSON,
38
+ // Provide console with limited surface. Use trampolines so that any test
39
+ // spies (e.g., jest.spyOn(console, 'log')) see calls made inside the sandbox.
40
+ console: {
41
+ log: (...args) => {
42
+ try {
43
+ console.log(...args);
44
+ } catch {
45
+ }
46
+ },
47
+ warn: (...args) => {
48
+ try {
49
+ console.warn(...args);
50
+ } catch {
51
+ }
52
+ },
53
+ error: (...args) => {
54
+ try {
55
+ console.error(...args);
56
+ } catch {
57
+ }
58
+ }
59
+ }
60
+ };
61
+ const prototypeWhitelist = new Map(Sandbox.SAFE_PROTOTYPES);
62
+ const arrayMethods = /* @__PURE__ */ new Set([
63
+ // Query/iteration
64
+ "some",
65
+ "every",
66
+ "filter",
67
+ "map",
68
+ "reduce",
69
+ "reduceRight",
70
+ "find",
71
+ "findIndex",
72
+ "findLast",
73
+ "findLastIndex",
74
+ "includes",
75
+ "indexOf",
76
+ "lastIndexOf",
77
+ "keys",
78
+ "values",
79
+ "entries",
80
+ "forEach",
81
+ // Non‑mutating ES2023 additions
82
+ "toReversed",
83
+ "toSorted",
84
+ "toSpliced",
85
+ "with",
86
+ "at",
87
+ // Mutators and common ops
88
+ "slice",
89
+ "concat",
90
+ "join",
91
+ "push",
92
+ "pop",
93
+ "shift",
94
+ "unshift",
95
+ "sort",
96
+ "reverse",
97
+ "copyWithin",
98
+ "fill",
99
+ // Flattening
100
+ "flat",
101
+ "flatMap",
102
+ // Meta
103
+ "length"
104
+ ]);
105
+ prototypeWhitelist.set(Array.prototype, arrayMethods);
106
+ const stringMethods = /* @__PURE__ */ new Set([
107
+ "toLowerCase",
108
+ "toUpperCase",
109
+ "includes",
110
+ "indexOf",
111
+ "lastIndexOf",
112
+ "startsWith",
113
+ "endsWith",
114
+ "slice",
115
+ "substring",
116
+ "substr",
117
+ "trim",
118
+ "trimStart",
119
+ "trimEnd",
120
+ "split",
121
+ "replace",
122
+ "replaceAll",
123
+ "match",
124
+ "matchAll",
125
+ "charAt",
126
+ "charCodeAt",
127
+ "codePointAt",
128
+ "normalize",
129
+ "repeat",
130
+ "padStart",
131
+ "padEnd",
132
+ "at",
133
+ "length"
134
+ ]);
135
+ prototypeWhitelist.set(String.prototype, stringMethods);
136
+ const objectMethods = /* @__PURE__ */ new Set([
137
+ "hasOwnProperty",
138
+ "propertyIsEnumerable",
139
+ "toString",
140
+ "valueOf"
141
+ ]);
142
+ prototypeWhitelist.set(Object.prototype, objectMethods);
143
+ const mapMethods = /* @__PURE__ */ new Set([
144
+ "get",
145
+ "set",
146
+ "has",
147
+ "delete",
148
+ "entries",
149
+ "keys",
150
+ "values",
151
+ "forEach"
152
+ ]);
153
+ prototypeWhitelist.set(Map.prototype, mapMethods);
154
+ const setMethods = /* @__PURE__ */ new Set([
155
+ "add",
156
+ "has",
157
+ "delete",
158
+ "entries",
159
+ "keys",
160
+ "values",
161
+ "forEach"
162
+ ]);
163
+ prototypeWhitelist.set(Set.prototype, setMethods);
164
+ const dateMethods = /* @__PURE__ */ new Set(["toISOString", "toJSON", "getTime"]);
165
+ prototypeWhitelist.set(Date.prototype, dateMethods);
166
+ const regexpMethods = /* @__PURE__ */ new Set(["test", "exec"]);
167
+ prototypeWhitelist.set(RegExp.prototype, regexpMethods);
168
+ return new Sandbox({ globals, prototypeWhitelist });
169
+ }
170
+ function compileAndRun(sandbox, userCode, scope, opts = { injectLog: true, wrapFunction: true, logPrefix: "[sandbox]" }) {
171
+ const inject = opts?.injectLog === true;
172
+ let safePrefix = String(opts?.logPrefix ?? "[sandbox]");
173
+ safePrefix = safePrefix.replace(/[\r\n\t\0]/g, "").replace(/[`$\\]/g, "").replace(/\$\{/g, "").slice(0, 64);
174
+ const header = inject ? `const __lp = ${JSON.stringify(safePrefix)}; const log = (...a) => { try { console.log(__lp, ...a); } catch {} };
175
+ ` : "";
176
+ const src = String(userCode);
177
+ const looksLikeBlock = /\breturn\b/.test(src) || /;/.test(src) || /\n/.test(src);
178
+ const looksLikeIife = /\)\s*\(\s*\)\s*;?$/.test(src.trim());
179
+ const body = opts.wrapFunction ? looksLikeBlock ? looksLikeIife ? `return (
180
+ ${src}
181
+ );
182
+ ` : `return (() => {
183
+ ${src}
184
+ })();
185
+ ` : `return (
186
+ ${src}
187
+ );
188
+ ` : `${src}`;
189
+ const code = `${header}${body}`;
190
+ let exec;
191
+ try {
192
+ exec = sandbox.compile(code);
193
+ } catch (e) {
194
+ const msg = e instanceof Error ? e.message : String(e);
195
+ throw new Error(`sandbox_compile_error: ${msg}`);
196
+ }
197
+ let out;
198
+ try {
199
+ out = exec(scope);
200
+ } catch (e) {
201
+ const msg = e instanceof Error ? e.message : String(e);
202
+ throw new Error(`sandbox_execution_error: ${msg}`);
203
+ }
204
+ if (out && typeof out.run === "function") {
205
+ try {
206
+ return out.run();
207
+ } catch (e) {
208
+ const msg = e instanceof Error ? e.message : String(e);
209
+ throw new Error(`sandbox_runner_error: ${msg}`);
210
+ }
211
+ }
212
+ return out;
213
+ }
214
+ var init_sandbox = __esm({
215
+ "src/utils/sandbox.ts"() {
216
+ "use strict";
217
+ }
218
+ });
219
+
220
+ // src/failure-condition-evaluator.ts
221
+ var failure_condition_evaluator_exports = {};
222
+ __export(failure_condition_evaluator_exports, {
223
+ FailureConditionEvaluator: () => FailureConditionEvaluator
224
+ });
225
+ var FailureConditionEvaluator;
226
+ var init_failure_condition_evaluator = __esm({
227
+ "src/failure-condition-evaluator.ts"() {
228
+ init_trace_helpers();
229
+ init_metrics();
230
+ init_sandbox();
231
+ init_author_permissions();
232
+ init_memory_store();
233
+ FailureConditionEvaluator = class _FailureConditionEvaluator {
234
+ sandbox;
235
+ constructor() {
236
+ }
237
+ /**
238
+ * Create a secure sandbox with whitelisted functions and globals
239
+ */
240
+ createSecureSandbox() {
241
+ return createSecureSandbox();
242
+ }
243
+ /**
244
+ * Evaluate simple fail_if condition
245
+ */
246
+ async evaluateSimpleCondition(checkName, checkSchema, checkGroup, reviewSummary, expression, previousOutputs, authorAssociation) {
247
+ const context = this.buildEvaluationContext(
248
+ checkName,
249
+ checkSchema,
250
+ checkGroup,
251
+ reviewSummary,
252
+ previousOutputs,
253
+ authorAssociation
254
+ );
255
+ try {
256
+ try {
257
+ const isObj = context.output && typeof context.output === "object";
258
+ const keys = isObj ? Object.keys(context.output).join(",") : typeof context.output;
259
+ let errorVal = void 0;
260
+ if (isObj && context.output.error !== void 0)
261
+ errorVal = context.output.error;
262
+ (init_logger(), __toCommonJS(logger_exports)).logger.debug(
263
+ ` fail_if: evaluating '${expression}' with output keys=${keys} error=${String(errorVal)}`
264
+ );
265
+ } catch {
266
+ }
267
+ const res = this.evaluateExpression(expression, context);
268
+ if (res === true) {
269
+ try {
270
+ addEvent("fail_if.triggered", {
271
+ check: checkName,
272
+ scope: "check",
273
+ name: `${checkName}_fail_if`,
274
+ expression,
275
+ severity: "error"
276
+ });
277
+ } catch {
278
+ }
279
+ try {
280
+ const { emitNdjsonSpanWithEvents } = (init_fallback_ndjson(), __toCommonJS(fallback_ndjson_exports));
281
+ emitNdjsonSpanWithEvents(
282
+ "visor.fail_if",
283
+ { check: checkName, scope: "check", name: `${checkName}_fail_if` },
284
+ [
285
+ {
286
+ name: "fail_if.triggered",
287
+ attrs: {
288
+ check: checkName,
289
+ scope: "check",
290
+ name: `${checkName}_fail_if`,
291
+ expression,
292
+ severity: "error"
293
+ }
294
+ }
295
+ ]
296
+ );
297
+ } catch {
298
+ }
299
+ }
300
+ return res;
301
+ } catch (error) {
302
+ console.warn(`Failed to evaluate fail_if expression: ${error}`);
303
+ return false;
304
+ }
305
+ }
306
+ /**
307
+ * Determine if the event is related to pull requests
308
+ */
309
+ determineIfPullRequest(eventType) {
310
+ if (!eventType) return false;
311
+ const prEvents = ["pr_opened", "pr_updated", "pr_closed", "pull_request"];
312
+ return prEvents.includes(eventType) || eventType.startsWith("pr_");
313
+ }
314
+ /**
315
+ * Determine if the event is related to issues
316
+ */
317
+ determineIfIssue(eventType) {
318
+ if (!eventType) return false;
319
+ const issueEvents = ["issue_opened", "issue_comment", "issues"];
320
+ return issueEvents.includes(eventType) || eventType.startsWith("issue_");
321
+ }
322
+ /**
323
+ * Evaluate if condition to determine whether a check should run
324
+ */
325
+ async evaluateIfCondition(checkName, expression, contextData) {
326
+ const context = {
327
+ // Check metadata
328
+ checkName,
329
+ // Git context
330
+ branch: contextData?.branch || "unknown",
331
+ baseBranch: contextData?.baseBranch || "main",
332
+ filesChanged: contextData?.filesChanged || [],
333
+ filesCount: contextData?.filesChanged?.length || 0,
334
+ // GitHub event context
335
+ event: {
336
+ event_name: contextData?.event || "manual",
337
+ action: void 0,
338
+ // Would be populated from actual GitHub context
339
+ repository: void 0
340
+ // Would be populated from actual GitHub context
341
+ },
342
+ // Environment variables
343
+ env: contextData?.environment || {},
344
+ // Previous check results (unwrap output field like templates do)
345
+ outputs: contextData?.previousResults ? (() => {
346
+ const outputs = {};
347
+ for (const [checkName2, result] of contextData.previousResults) {
348
+ const summary = result;
349
+ outputs[checkName2] = summary.output !== void 0 ? summary.output : summary;
350
+ }
351
+ return outputs;
352
+ })() : {},
353
+ // Workflow inputs (for workflows)
354
+ inputs: contextData?.workflowInputs || {},
355
+ // Required output property (empty for if conditions)
356
+ output: {
357
+ issues: []
358
+ },
359
+ // Author association (used by permission helpers)
360
+ authorAssociation: contextData?.authorAssociation,
361
+ // Utility metadata
362
+ metadata: {
363
+ checkName,
364
+ schema: "",
365
+ group: "",
366
+ criticalIssues: 0,
367
+ errorIssues: 0,
368
+ warningIssues: 0,
369
+ infoIssues: 0,
370
+ totalIssues: 0,
371
+ hasChanges: (contextData?.filesChanged?.length || 0) > 0,
372
+ branch: contextData?.branch || "unknown",
373
+ event: contextData?.event || "manual"
374
+ }
375
+ };
376
+ try {
377
+ const res = this.evaluateExpression(expression, context);
378
+ try {
379
+ if (process.env.VISOR_DEBUG === "true") {
380
+ const envMap = context.env || {};
381
+ let memStr = "";
382
+ try {
383
+ const m = context.memory;
384
+ const v = m && typeof m.get === "function" ? m.get("all_valid", "fact-validation") : void 0;
385
+ memStr = ` mem.fact-validation.all_valid=${String(v)}`;
386
+ } catch {
387
+ }
388
+ console.error(
389
+ `[if-eval] check=${checkName} expr="${expression}" env.ENABLE_FACT_VALIDATION=${String(
390
+ envMap.ENABLE_FACT_VALIDATION
391
+ )} event=${context.event?.event_name} result=${String(res)}${memStr}`
392
+ );
393
+ }
394
+ } catch {
395
+ }
396
+ return res;
397
+ } catch (error) {
398
+ console.warn(`Failed to evaluate if expression for check '${checkName}': ${error}`);
399
+ return false;
400
+ }
401
+ }
402
+ /**
403
+ * Evaluate all failure conditions for a check result
404
+ */
405
+ async evaluateConditions(checkName, checkSchema, checkGroup, reviewSummary, globalConditions, checkConditions, previousOutputs, authorAssociation) {
406
+ const context = this.buildEvaluationContext(
407
+ checkName,
408
+ checkSchema,
409
+ checkGroup,
410
+ reviewSummary,
411
+ previousOutputs,
412
+ authorAssociation
413
+ );
414
+ const results = [];
415
+ if (globalConditions) {
416
+ const globalResults = await this.evaluateConditionSet(globalConditions, context, "global");
417
+ results.push(...globalResults);
418
+ }
419
+ if (checkConditions) {
420
+ const checkResults = await this.evaluateConditionSet(checkConditions, context, "check");
421
+ const overriddenConditions = new Set(Object.keys(checkConditions));
422
+ const filteredResults = results.filter(
423
+ (result) => !overriddenConditions.has(result.conditionName)
424
+ );
425
+ results.length = 0;
426
+ results.push(...filteredResults, ...checkResults);
427
+ }
428
+ return results;
429
+ }
430
+ /**
431
+ * Evaluate a set of failure conditions
432
+ */
433
+ async evaluateConditionSet(conditions, context, source) {
434
+ const results = [];
435
+ for (const [conditionName, condition] of Object.entries(conditions)) {
436
+ try {
437
+ addEvent("fail_if.evaluated", {
438
+ check: context.checkName,
439
+ scope: source,
440
+ name: conditionName,
441
+ expression: this.extractExpression(condition)
442
+ });
443
+ } catch {
444
+ }
445
+ try {
446
+ const { emitNdjsonSpanWithEvents } = (init_fallback_ndjson(), __toCommonJS(fallback_ndjson_exports));
447
+ emitNdjsonSpanWithEvents(
448
+ "visor.fail_if",
449
+ { check: context.checkName || "unknown", scope: source, name: conditionName },
450
+ [
451
+ {
452
+ name: "fail_if.evaluated",
453
+ attrs: {
454
+ check: context.checkName,
455
+ scope: source,
456
+ name: conditionName,
457
+ expression: this.extractExpression(condition)
458
+ }
459
+ }
460
+ ]
461
+ );
462
+ } catch {
463
+ }
464
+ try {
465
+ const result = await this.evaluateSingleCondition(conditionName, condition, context);
466
+ results.push(result);
467
+ if (result.failed) {
468
+ try {
469
+ addEvent("fail_if.triggered", {
470
+ check: context.checkName,
471
+ scope: source,
472
+ name: conditionName,
473
+ expression: result.expression,
474
+ severity: result.severity,
475
+ halt_execution: result.haltExecution
476
+ });
477
+ } catch {
478
+ }
479
+ try {
480
+ addFailIfTriggered(context.checkName || "unknown", source);
481
+ } catch {
482
+ }
483
+ }
484
+ } catch (error) {
485
+ results.push({
486
+ conditionName,
487
+ failed: false,
488
+ expression: this.extractExpression(condition),
489
+ severity: "error",
490
+ haltExecution: false,
491
+ error: `Failed to evaluate ${source} condition '${conditionName}': ${error instanceof Error ? error.message : String(error)}`
492
+ });
493
+ }
494
+ }
495
+ return results;
496
+ }
497
+ /**
498
+ * Evaluate a single failure condition
499
+ */
500
+ async evaluateSingleCondition(conditionName, condition, context) {
501
+ const expression = this.extractExpression(condition);
502
+ const config = this.extractConditionConfig(condition);
503
+ try {
504
+ const failed = this.evaluateExpression(expression, context);
505
+ return {
506
+ conditionName,
507
+ failed,
508
+ expression,
509
+ message: config.message,
510
+ severity: config.severity || "error",
511
+ haltExecution: config.halt_execution || false
512
+ };
513
+ } catch (error) {
514
+ throw new Error(
515
+ `Expression evaluation error: ${error instanceof Error ? error.message : String(error)}`
516
+ );
517
+ }
518
+ }
519
+ /**
520
+ * Secure expression evaluation using SandboxJS
521
+ * Supports the same GitHub Actions-style functions as the previous implementation
522
+ */
523
+ evaluateExpression(condition, context) {
524
+ try {
525
+ const normalize = (expr) => {
526
+ const trimmed = expr.trim();
527
+ if (!/[\n;]/.test(trimmed)) return trimmed;
528
+ const parts = trimmed.split(/[\n;]+/).map((s) => s.trim()).filter((s) => s.length > 0 && !s.startsWith("//"));
529
+ if (parts.length === 0) return "true";
530
+ const lastRaw = parts.pop();
531
+ const last = lastRaw.replace(/^return\s+/i, "").trim();
532
+ if (parts.length === 0) return last;
533
+ return `(${parts.join(", ")}, ${last})`;
534
+ };
535
+ const contains = (searchString, searchValue) => String(searchString).toLowerCase().includes(String(searchValue).toLowerCase());
536
+ const startsWith = (searchString, searchValue) => String(searchString).toLowerCase().startsWith(String(searchValue).toLowerCase());
537
+ const endsWith = (searchString, searchValue) => String(searchString).toLowerCase().endsWith(String(searchValue).toLowerCase());
538
+ const length = (value) => {
539
+ if (typeof value === "string" || Array.isArray(value)) {
540
+ return value.length;
541
+ }
542
+ if (value && typeof value === "object") {
543
+ return Object.keys(value).length;
544
+ }
545
+ return 0;
546
+ };
547
+ const always = () => true;
548
+ const success = () => true;
549
+ const failure = () => false;
550
+ const log = (...args) => {
551
+ console.log("\u{1F50D} Debug:", ...args);
552
+ };
553
+ const hasIssue = (issues2, field, value) => {
554
+ if (!Array.isArray(issues2)) return false;
555
+ return issues2.some((issue) => issue[field] === value);
556
+ };
557
+ const countIssues = (issues2, field, value) => {
558
+ if (!Array.isArray(issues2)) return 0;
559
+ return issues2.filter((issue) => issue[field] === value).length;
560
+ };
561
+ const hasFileMatching = (issues2, pattern) => {
562
+ if (!Array.isArray(issues2)) return false;
563
+ return issues2.some((issue) => issue.file?.includes(pattern));
564
+ };
565
+ const hasIssueWith = hasIssue;
566
+ const hasFileWith = hasFileMatching;
567
+ const permissionHelpers = createPermissionHelpers(
568
+ context.authorAssociation,
569
+ detectLocalMode()
570
+ );
571
+ const hasMinPermission = permissionHelpers.hasMinPermission;
572
+ const isOwner = permissionHelpers.isOwner;
573
+ const isMember = permissionHelpers.isMember;
574
+ const isCollaborator = permissionHelpers.isCollaborator;
575
+ const isContributor = permissionHelpers.isContributor;
576
+ const isFirstTimer = permissionHelpers.isFirstTimer;
577
+ const output = context.output || {};
578
+ const issues = output.issues || [];
579
+ const metadata = context.metadata || {
580
+ checkName: context.checkName || "",
581
+ schema: context.schema || "",
582
+ group: context.group || "",
583
+ criticalIssues: issues.filter((i) => i.severity === "critical").length,
584
+ errorIssues: issues.filter((i) => i.severity === "error").length,
585
+ warningIssues: issues.filter((i) => i.severity === "warning").length,
586
+ infoIssues: issues.filter((i) => i.severity === "info").length,
587
+ totalIssues: issues.length,
588
+ hasChanges: context.hasChanges || false
589
+ };
590
+ const criticalIssues = metadata.criticalIssues;
591
+ const errorIssues = metadata.errorIssues;
592
+ const totalIssues = metadata.totalIssues;
593
+ const warningIssues = metadata.warningIssues;
594
+ const infoIssues = metadata.infoIssues;
595
+ const checkName = context.checkName || "";
596
+ const schema = context.schema || "";
597
+ const group = context.group || "";
598
+ const branch = context.branch || "unknown";
599
+ const baseBranch = context.baseBranch || "main";
600
+ const filesChanged = context.filesChanged || [];
601
+ const filesCount = context.filesCount || 0;
602
+ const event = context.event || "manual";
603
+ const env = context.env || {};
604
+ const outputs = context.outputs || {};
605
+ const debugData = context.debug || null;
606
+ const memoryStore = MemoryStore.getInstance();
607
+ const memoryAccessor = {
608
+ get: (key, ns) => memoryStore.get(key, ns),
609
+ has: (key, ns) => memoryStore.has(key, ns),
610
+ list: (ns) => memoryStore.list(ns),
611
+ getAll: (ns) => memoryStore.getAll(ns)
612
+ };
613
+ const scope = {
614
+ // Primary context variables
615
+ output,
616
+ outputs,
617
+ debug: debugData,
618
+ // Memory accessor for fail_if expressions
619
+ memory: memoryAccessor,
620
+ // Legacy compatibility variables
621
+ issues,
622
+ metadata,
623
+ criticalIssues,
624
+ errorIssues,
625
+ totalIssues,
626
+ warningIssues,
627
+ infoIssues,
628
+ // If condition context
629
+ checkName,
630
+ schema,
631
+ group,
632
+ branch,
633
+ baseBranch,
634
+ filesChanged,
635
+ filesCount,
636
+ event,
637
+ env,
638
+ // Helper functions
639
+ contains,
640
+ startsWith,
641
+ endsWith,
642
+ length,
643
+ always,
644
+ success,
645
+ failure,
646
+ log,
647
+ hasIssue,
648
+ countIssues,
649
+ hasFileMatching,
650
+ hasIssueWith,
651
+ hasFileWith,
652
+ // Permission helpers
653
+ hasMinPermission,
654
+ isOwner,
655
+ isMember,
656
+ isCollaborator,
657
+ isContributor,
658
+ isFirstTimer
659
+ };
660
+ const raw = condition.trim();
661
+ if (!this.sandbox) {
662
+ this.sandbox = this.createSecureSandbox();
663
+ }
664
+ let result;
665
+ try {
666
+ let exec;
667
+ try {
668
+ exec = this.sandbox.compile(`return (${raw});`);
669
+ } catch {
670
+ const normalizedExpr = normalize(condition);
671
+ exec = this.sandbox.compile(`return (${normalizedExpr});`);
672
+ }
673
+ result = exec(scope).run();
674
+ } catch (_primaryErr) {
675
+ try {
676
+ const vm = __require("vm");
677
+ const ctx = {
678
+ // Scope vars
679
+ output,
680
+ outputs,
681
+ debug: debugData,
682
+ memory: memoryAccessor,
683
+ issues,
684
+ metadata,
685
+ criticalIssues,
686
+ errorIssues,
687
+ totalIssues,
688
+ warningIssues,
689
+ infoIssues,
690
+ checkName,
691
+ schema,
692
+ group,
693
+ branch,
694
+ baseBranch,
695
+ filesChanged,
696
+ filesCount,
697
+ event,
698
+ env,
699
+ // Helpers
700
+ contains,
701
+ startsWith,
702
+ endsWith,
703
+ length,
704
+ always,
705
+ success,
706
+ failure,
707
+ log,
708
+ hasIssue,
709
+ countIssues,
710
+ hasFileMatching,
711
+ hasIssueWith,
712
+ hasFileWith,
713
+ hasMinPermission,
714
+ isOwner,
715
+ isMember,
716
+ isCollaborator,
717
+ isContributor,
718
+ isFirstTimer,
719
+ Math,
720
+ JSON
721
+ };
722
+ const context2 = vm.createContext(ctx);
723
+ let code = `(${raw})`;
724
+ try {
725
+ result = new vm.Script(code).runInContext(context2, { timeout: 50 });
726
+ } catch {
727
+ const normalizedExpr = normalize(condition);
728
+ code = `(${normalizedExpr})`;
729
+ result = new vm.Script(code).runInContext(context2, { timeout: 50 });
730
+ }
731
+ } catch (vmErr) {
732
+ console.error("\u274C Failed to evaluate expression:", condition, vmErr);
733
+ throw vmErr;
734
+ }
735
+ }
736
+ try {
737
+ (init_logger(), __toCommonJS(logger_exports)).logger.debug(` fail_if: result=${Boolean(result)}`);
738
+ } catch {
739
+ }
740
+ return Boolean(result);
741
+ } catch (error) {
742
+ console.error("\u274C Failed to evaluate expression:", condition, error);
743
+ throw error;
744
+ }
745
+ }
746
+ /**
747
+ * Extract the expression from a failure condition
748
+ */
749
+ extractExpression(condition) {
750
+ if (typeof condition === "string") {
751
+ return condition;
752
+ }
753
+ return condition.condition;
754
+ }
755
+ /**
756
+ * Extract configuration from a failure condition
757
+ */
758
+ extractConditionConfig(condition) {
759
+ if (typeof condition === "string") {
760
+ return {};
761
+ }
762
+ return {
763
+ message: condition.message,
764
+ severity: condition.severity,
765
+ halt_execution: condition.halt_execution
766
+ };
767
+ }
768
+ /**
769
+ * Build the evaluation context for expressions
770
+ */
771
+ buildEvaluationContext(checkName, checkSchema, checkGroup, reviewSummary, previousOutputs, authorAssociation) {
772
+ const { issues, debug } = reviewSummary;
773
+ const reviewSummaryWithOutput = reviewSummary;
774
+ const {
775
+ output: extractedOutput,
776
+ // Exclude issues from otherFields since we handle it separately
777
+ issues: _issues,
778
+ // eslint-disable-line @typescript-eslint/no-unused-vars
779
+ ...otherFields
780
+ } = reviewSummaryWithOutput;
781
+ const aggregatedOutput = {
782
+ issues: (issues || []).map((issue) => ({
783
+ file: issue.file,
784
+ line: issue.line,
785
+ endLine: issue.endLine,
786
+ ruleId: issue.ruleId,
787
+ message: issue.message,
788
+ severity: issue.severity,
789
+ category: issue.category,
790
+ group: issue.group,
791
+ schema: issue.schema,
792
+ suggestion: issue.suggestion,
793
+ replacement: issue.replacement
794
+ })),
795
+ // Include additional schema-specific data from reviewSummary
796
+ ...otherFields
797
+ };
798
+ if (Array.isArray(extractedOutput)) {
799
+ aggregatedOutput.items = extractedOutput;
800
+ const anyError = extractedOutput.find(
801
+ (it) => it && typeof it === "object" && it.error
802
+ );
803
+ if (anyError && anyError.error !== void 0) {
804
+ aggregatedOutput.error = anyError.error;
805
+ }
806
+ } else if (extractedOutput && typeof extractedOutput === "object") {
807
+ Object.assign(aggregatedOutput, extractedOutput);
808
+ }
809
+ try {
810
+ const raw = reviewSummaryWithOutput.__raw;
811
+ if (raw && typeof raw === "object") {
812
+ Object.assign(aggregatedOutput, raw);
813
+ }
814
+ } catch {
815
+ }
816
+ try {
817
+ if (typeof extractedOutput === "string") {
818
+ const parsed = this.tryExtractJsonFromEnd(extractedOutput) ?? (() => {
819
+ try {
820
+ return JSON.parse(extractedOutput);
821
+ } catch {
822
+ return null;
823
+ }
824
+ })();
825
+ if (parsed !== null) {
826
+ if (Array.isArray(parsed)) {
827
+ aggregatedOutput.items = parsed;
828
+ } else if (typeof parsed === "object") {
829
+ Object.assign(aggregatedOutput, parsed);
830
+ }
831
+ }
832
+ const lower = extractedOutput.toLowerCase();
833
+ const boolFrom = (key) => {
834
+ const reTrue = new RegExp(
835
+ `(?:^|[^a-z0-9_])${key}[^a-z0-9_]*[:=][^a-z0-9_]*true(?:[^a-z0-9_]|$)`
836
+ );
837
+ const reFalse = new RegExp(
838
+ `(?:^|[^a-z0-9_])${key}[^a-z0-9_]*[:=][^a-z0-9_]*false(?:[^a-z0-9_]|$)`
839
+ );
840
+ if (reTrue.test(lower)) return true;
841
+ if (reFalse.test(lower)) return false;
842
+ return null;
843
+ };
844
+ const keys = ["error"];
845
+ for (const k of keys) {
846
+ const v = boolFrom(k);
847
+ if (v !== null && aggregatedOutput[k] === void 0) {
848
+ aggregatedOutput[k] = v;
849
+ }
850
+ }
851
+ }
852
+ } catch {
853
+ }
854
+ try {
855
+ const rsAny = reviewSummaryWithOutput;
856
+ const hasStructuredOutput = extractedOutput !== void 0 && extractedOutput !== null;
857
+ if (!hasStructuredOutput && typeof rsAny?.content === "string") {
858
+ const parsedFromContent = this.tryExtractJsonFromEnd(rsAny.content);
859
+ if (parsedFromContent !== null && parsedFromContent !== void 0) {
860
+ if (Array.isArray(parsedFromContent)) {
861
+ aggregatedOutput.items = parsedFromContent;
862
+ } else if (typeof parsedFromContent === "object") {
863
+ Object.assign(aggregatedOutput, parsedFromContent);
864
+ }
865
+ }
866
+ }
867
+ } catch {
868
+ }
869
+ const memoryStore = MemoryStore.getInstance();
870
+ const context = {
871
+ output: aggregatedOutput,
872
+ outputs: (() => {
873
+ if (!previousOutputs) return {};
874
+ const outputs = {};
875
+ for (const [checkName2, result] of Object.entries(previousOutputs)) {
876
+ const summary = result;
877
+ outputs[checkName2] = summary.output !== void 0 ? summary.output : summary;
878
+ }
879
+ return outputs;
880
+ })(),
881
+ // Add memory accessor for fail_if expressions
882
+ memory: {
883
+ get: (key, ns) => memoryStore.get(key, ns),
884
+ has: (key, ns) => memoryStore.has(key, ns),
885
+ list: (ns) => memoryStore.list(ns),
886
+ getAll: (ns) => memoryStore.getAll(ns)
887
+ },
888
+ // Add basic context info for failure conditions
889
+ checkName,
890
+ schema: checkSchema,
891
+ group: checkGroup,
892
+ authorAssociation
893
+ };
894
+ if (debug) {
895
+ context.debug = {
896
+ errors: debug.errors || [],
897
+ processingTime: debug.processingTime || 0,
898
+ provider: debug.provider || "unknown",
899
+ model: debug.model || "unknown"
900
+ };
901
+ }
902
+ return context;
903
+ }
904
+ // Minimal JSON-from-end extractor for fail_if context fallback
905
+ tryExtractJsonFromEnd(text) {
906
+ try {
907
+ const lines = text.split("\n");
908
+ for (let i = lines.length - 1; i >= 0; i--) {
909
+ const t = lines[i].trim();
910
+ if (t.startsWith("{") || t.startsWith("[")) {
911
+ const candidate = lines.slice(i).join("\n").trim();
912
+ if (candidate.startsWith("{") && candidate.endsWith("}") || candidate.startsWith("[") && candidate.endsWith("]")) {
913
+ return JSON.parse(candidate);
914
+ }
915
+ }
916
+ }
917
+ } catch {
918
+ }
919
+ return null;
920
+ }
921
+ /**
922
+ * Check if any failure condition requires halting execution
923
+ */
924
+ static shouldHaltExecution(results) {
925
+ return results.some((result) => result.failed && result.haltExecution);
926
+ }
927
+ /**
928
+ * Get all failed conditions
929
+ */
930
+ static getFailedConditions(results) {
931
+ return results.filter((result) => result.failed);
932
+ }
933
+ /**
934
+ * Group results by severity
935
+ */
936
+ static groupResultsBySeverity(results) {
937
+ return {
938
+ // Only 'error' severity now (no backward compatibility needed here as this is internal)
939
+ error: results.filter((r) => r.severity === "error"),
940
+ warning: results.filter((r) => r.severity === "warning"),
941
+ info: results.filter((r) => r.severity === "info")
942
+ };
943
+ }
944
+ /**
945
+ * Format results for display
946
+ */
947
+ static formatResults(results) {
948
+ const failed = _FailureConditionEvaluator.getFailedConditions(results);
949
+ if (failed.length === 0) {
950
+ return "\u2705 All failure conditions passed";
951
+ }
952
+ const grouped = _FailureConditionEvaluator.groupResultsBySeverity(failed);
953
+ const sections = [];
954
+ if (grouped.error.length > 0) {
955
+ sections.push(`\u274C **Error severity conditions (${grouped.error.length}):**`);
956
+ grouped.error.forEach((result) => {
957
+ sections.push(` - ${result.conditionName}: ${result.message || result.expression}`);
958
+ });
959
+ }
960
+ if (grouped.warning.length > 0) {
961
+ sections.push(`\u26A0\uFE0F **Warning conditions (${grouped.warning.length}):**`);
962
+ grouped.warning.forEach((result) => {
963
+ sections.push(` - ${result.conditionName}: ${result.message || result.expression}`);
964
+ });
965
+ }
966
+ if (grouped.info.length > 0) {
967
+ sections.push(`\u2139\uFE0F **Info conditions (${grouped.info.length}):**`);
968
+ grouped.info.forEach((result) => {
969
+ sections.push(` - ${result.conditionName}: ${result.message || result.expression}`);
970
+ });
971
+ }
972
+ return sections.join("\n");
973
+ }
974
+ };
975
+ }
976
+ });
977
+
978
+ export {
979
+ createSecureSandbox,
980
+ compileAndRun,
981
+ init_sandbox,
982
+ FailureConditionEvaluator,
983
+ failure_condition_evaluator_exports,
984
+ init_failure_condition_evaluator
985
+ };
986
+ //# sourceMappingURL=chunk-OZJ263FM.mjs.map