@probelabs/visor 0.1.169 → 0.1.170-ee

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 (66) hide show
  1. package/README.md +64 -7
  2. package/defaults/assistant.yaml +1 -1
  3. package/defaults/code-talk.yaml +2 -2
  4. package/dist/defaults/assistant.yaml +1 -1
  5. package/dist/defaults/code-talk.yaml +2 -2
  6. package/dist/docs/a2a-provider.md +672 -0
  7. package/dist/docs/architecture.md +174 -12
  8. package/dist/docs/commands.md +36 -0
  9. package/dist/docs/configuration.md +1 -0
  10. package/dist/docs/index.md +9 -2
  11. package/dist/docs/pluggable.md +16 -1
  12. package/dist/index.js +1842 -25
  13. package/dist/sdk/{check-provider-registry-5CMLUEFG.mjs → check-provider-registry-Q2OVYSBJ.mjs} +2 -2
  14. package/dist/sdk/{chunk-LB77GR4Q.mjs → chunk-46P7AYHG.mjs} +9 -9
  15. package/dist/sdk/{chunk-LB77GR4Q.mjs.map → chunk-46P7AYHG.mjs.map} +1 -1
  16. package/dist/sdk/{host-MHYGIPDP.mjs → host-RATJKJW5.mjs} +3 -3
  17. package/dist/sdk/knex-store-CRORFJE6.mjs +527 -0
  18. package/dist/sdk/knex-store-CRORFJE6.mjs.map +1 -0
  19. package/dist/sdk/loader-NJCF7DUS.mjs +89 -0
  20. package/dist/sdk/loader-NJCF7DUS.mjs.map +1 -0
  21. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs +655 -0
  22. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs.map +1 -0
  23. package/dist/sdk/{schedule-tool-H4G5ITNL.mjs → schedule-tool-VI5IUMEL.mjs} +2 -2
  24. package/dist/sdk/{schedule-tool-handler-UQWDPFP6.mjs → schedule-tool-handler-PIXYVVJY.mjs} +2 -2
  25. package/dist/sdk/sdk.js +1648 -274
  26. package/dist/sdk/sdk.js.map +1 -1
  27. package/dist/sdk/sdk.mjs +4 -4
  28. package/dist/sdk/validator-XTZJZZJH.mjs +134 -0
  29. package/dist/sdk/validator-XTZJZZJH.mjs.map +1 -0
  30. package/dist/sdk/{workflow-check-provider-FAO4AUGB.mjs → workflow-check-provider-W5FKQU5G.mjs} +2 -2
  31. package/package.json +1 -1
  32. package/dist/output/traces/run-2026-03-07T13-37-21-566Z.ndjson +0 -138
  33. package/dist/output/traces/run-2026-03-07T13-37-59-420Z.ndjson +0 -2266
  34. package/dist/sdk/a2a-frontend-XFCSNQR5.mjs +0 -1605
  35. package/dist/sdk/a2a-frontend-XFCSNQR5.mjs.map +0 -1
  36. package/dist/sdk/check-provider-registry-XEU5BSRJ.mjs +0 -30
  37. package/dist/sdk/chunk-HBT572VG.mjs +0 -443
  38. package/dist/sdk/chunk-HBT572VG.mjs.map +0 -1
  39. package/dist/sdk/chunk-ROMY3ZN3.mjs +0 -44771
  40. package/dist/sdk/chunk-ROMY3ZN3.mjs.map +0 -1
  41. package/dist/sdk/chunk-VPPW2TFI.mjs +0 -1502
  42. package/dist/sdk/chunk-VPPW2TFI.mjs.map +0 -1
  43. package/dist/sdk/chunk-WGZNS5IB.mjs +0 -739
  44. package/dist/sdk/chunk-WGZNS5IB.mjs.map +0 -1
  45. package/dist/sdk/failure-condition-evaluator-WYDAZT3H.mjs +0 -17
  46. package/dist/sdk/github-frontend-BVM7MHBJ.mjs +0 -1386
  47. package/dist/sdk/github-frontend-BVM7MHBJ.mjs.map +0 -1
  48. package/dist/sdk/routing-K2U7U3OO.mjs +0 -25
  49. package/dist/sdk/schedule-tool-H4G5ITNL.mjs.map +0 -1
  50. package/dist/sdk/schedule-tool-RYYNPLDH.mjs +0 -36
  51. package/dist/sdk/schedule-tool-RYYNPLDH.mjs.map +0 -1
  52. package/dist/sdk/schedule-tool-handler-NFNY6BVX.mjs +0 -40
  53. package/dist/sdk/schedule-tool-handler-NFNY6BVX.mjs.map +0 -1
  54. package/dist/sdk/schedule-tool-handler-UQWDPFP6.mjs.map +0 -1
  55. package/dist/sdk/trace-helpers-DQYOGQT5.mjs +0 -25
  56. package/dist/sdk/trace-helpers-DQYOGQT5.mjs.map +0 -1
  57. package/dist/sdk/workflow-check-provider-FAO4AUGB.mjs.map +0 -1
  58. package/dist/sdk/workflow-check-provider-OM5L5FJX.mjs +0 -30
  59. package/dist/sdk/workflow-check-provider-OM5L5FJX.mjs.map +0 -1
  60. package/dist/traces/run-2026-03-07T13-37-21-566Z.ndjson +0 -138
  61. package/dist/traces/run-2026-03-07T13-37-59-420Z.ndjson +0 -2266
  62. /package/dist/sdk/{check-provider-registry-5CMLUEFG.mjs.map → check-provider-registry-Q2OVYSBJ.mjs.map} +0 -0
  63. /package/dist/sdk/{host-MHYGIPDP.mjs.map → host-RATJKJW5.mjs.map} +0 -0
  64. /package/dist/sdk/{check-provider-registry-XEU5BSRJ.mjs.map → schedule-tool-VI5IUMEL.mjs.map} +0 -0
  65. /package/dist/sdk/{failure-condition-evaluator-WYDAZT3H.mjs.map → schedule-tool-handler-PIXYVVJY.mjs.map} +0 -0
  66. /package/dist/sdk/{routing-K2U7U3OO.mjs.map → workflow-check-provider-W5FKQU5G.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- process.env.VISOR_VERSION = '0.1.169';
2
+ process.env.VISOR_VERSION = '0.1.170';
3
3
  process.env.PROBE_VERSION = '0.6.0-rc286';
4
- process.env.VISOR_COMMIT_SHA = '11e70cdc108f4b36afcfc1fa0c373fbcac4e9999';
5
- process.env.VISOR_COMMIT_SHORT = '11e70cdc';
4
+ process.env.VISOR_COMMIT_SHA = '3e49bfdee61154013b28eba096637ac60cdd08ac';
5
+ process.env.VISOR_COMMIT_SHORT = '3e49bfd';
6
6
  /******/ (() => { // webpackBootstrap
7
7
  /******/ var __webpack_modules__ = ({
8
8
 
@@ -171591,7 +171591,7 @@ async function handleDumpPolicyInput(checkId, argv) {
171591
171591
  let PolicyInputBuilder;
171592
171592
  try {
171593
171593
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
171594
- const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(71370)));
171594
+ const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(17117)));
171595
171595
  PolicyInputBuilder = mod.PolicyInputBuilder;
171596
171596
  }
171597
171597
  catch {
@@ -177560,6 +177560,1810 @@ class DependencyResolver {
177560
177560
  exports.DependencyResolver = DependencyResolver;
177561
177561
 
177562
177562
 
177563
+ /***/ }),
177564
+
177565
+ /***/ 50069:
177566
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
177567
+
177568
+ "use strict";
177569
+
177570
+ /**
177571
+ * Copyright (c) ProbeLabs. All rights reserved.
177572
+ * Licensed under the Elastic License 2.0; you may not use this file except
177573
+ * in compliance with the Elastic License 2.0.
177574
+ */
177575
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
177576
+ if (k2 === undefined) k2 = k;
177577
+ var desc = Object.getOwnPropertyDescriptor(m, k);
177578
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
177579
+ desc = { enumerable: true, get: function() { return m[k]; } };
177580
+ }
177581
+ Object.defineProperty(o, k2, desc);
177582
+ }) : (function(o, m, k, k2) {
177583
+ if (k2 === undefined) k2 = k;
177584
+ o[k2] = m[k];
177585
+ }));
177586
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
177587
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
177588
+ }) : function(o, v) {
177589
+ o["default"] = v;
177590
+ });
177591
+ var __importStar = (this && this.__importStar) || (function () {
177592
+ var ownKeys = function(o) {
177593
+ ownKeys = Object.getOwnPropertyNames || function (o) {
177594
+ var ar = [];
177595
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
177596
+ return ar;
177597
+ };
177598
+ return ownKeys(o);
177599
+ };
177600
+ return function (mod) {
177601
+ if (mod && mod.__esModule) return mod;
177602
+ var result = {};
177603
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
177604
+ __setModuleDefault(result, mod);
177605
+ return result;
177606
+ };
177607
+ })();
177608
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
177609
+ exports.LicenseValidator = void 0;
177610
+ const crypto = __importStar(__nccwpck_require__(76982));
177611
+ const fs = __importStar(__nccwpck_require__(79896));
177612
+ const path = __importStar(__nccwpck_require__(16928));
177613
+ class LicenseValidator {
177614
+ /** Ed25519 public key for license verification (PEM format). */
177615
+ static PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----\n' +
177616
+ 'MCowBQYDK2VwAyEAI/Zd08EFmgIdrDm/HXd0l3/5GBt7R1PrdvhdmEXhJlU=\n' +
177617
+ '-----END PUBLIC KEY-----\n';
177618
+ cache = null;
177619
+ static CACHE_TTL = 5 * 60 * 1000; // 5 minutes
177620
+ static GRACE_PERIOD = 72 * 3600 * 1000; // 72 hours after expiry
177621
+ /**
177622
+ * Load and validate license from environment or file.
177623
+ *
177624
+ * Resolution order:
177625
+ * 1. VISOR_LICENSE env var (JWT string)
177626
+ * 2. VISOR_LICENSE_FILE env var (path to file)
177627
+ * 3. .visor-license in project root (cwd)
177628
+ * 4. .visor-license in ~/.config/visor/
177629
+ */
177630
+ async loadAndValidate() {
177631
+ // Return cached result if still fresh
177632
+ if (this.cache && Date.now() - this.cache.validatedAt < LicenseValidator.CACHE_TTL) {
177633
+ return this.cache.payload;
177634
+ }
177635
+ const token = this.resolveToken();
177636
+ if (!token)
177637
+ return null;
177638
+ const payload = this.verifyAndDecode(token);
177639
+ if (!payload)
177640
+ return null;
177641
+ this.cache = { payload, validatedAt: Date.now() };
177642
+ return payload;
177643
+ }
177644
+ /** Check if a specific feature is licensed */
177645
+ hasFeature(feature) {
177646
+ if (!this.cache)
177647
+ return false;
177648
+ return this.cache.payload.features.includes(feature);
177649
+ }
177650
+ /** Check if license is valid (with grace period) */
177651
+ isValid() {
177652
+ if (!this.cache)
177653
+ return false;
177654
+ const now = Date.now();
177655
+ const expiryMs = this.cache.payload.exp * 1000;
177656
+ return now < expiryMs + LicenseValidator.GRACE_PERIOD;
177657
+ }
177658
+ /** Check if the license is within its grace period (expired but still valid) */
177659
+ isInGracePeriod() {
177660
+ if (!this.cache)
177661
+ return false;
177662
+ const now = Date.now();
177663
+ const expiryMs = this.cache.payload.exp * 1000;
177664
+ return now >= expiryMs && now < expiryMs + LicenseValidator.GRACE_PERIOD;
177665
+ }
177666
+ resolveToken() {
177667
+ // 1. Direct env var
177668
+ if (process.env.VISOR_LICENSE) {
177669
+ return process.env.VISOR_LICENSE.trim();
177670
+ }
177671
+ // 2. File path from env (validate against path traversal)
177672
+ if (process.env.VISOR_LICENSE_FILE) {
177673
+ // path.resolve() produces an absolute path with all '..' segments resolved,
177674
+ // so a separate resolved.includes('..') check is unnecessary.
177675
+ const resolved = path.resolve(process.env.VISOR_LICENSE_FILE);
177676
+ const home = process.env.HOME || process.env.USERPROFILE || '';
177677
+ const allowedPrefixes = [path.normalize(process.cwd())];
177678
+ if (home)
177679
+ allowedPrefixes.push(path.normalize(path.join(home, '.config', 'visor')));
177680
+ // Resolve symlinks so an attacker cannot create a symlink inside an
177681
+ // allowed prefix that points to an arbitrary file outside it.
177682
+ let realPath;
177683
+ try {
177684
+ realPath = fs.realpathSync(resolved);
177685
+ }
177686
+ catch {
177687
+ return null; // File doesn't exist or isn't accessible
177688
+ }
177689
+ const isSafe = allowedPrefixes.some(prefix => realPath === prefix || realPath.startsWith(prefix + path.sep));
177690
+ if (!isSafe)
177691
+ return null;
177692
+ return this.readFile(realPath);
177693
+ }
177694
+ // 3. .visor-license in cwd
177695
+ const cwdPath = path.join(process.cwd(), '.visor-license');
177696
+ const cwdToken = this.readFile(cwdPath);
177697
+ if (cwdToken)
177698
+ return cwdToken;
177699
+ // 4. ~/.config/visor/.visor-license
177700
+ const home = process.env.HOME || process.env.USERPROFILE || '';
177701
+ if (home) {
177702
+ const configPath = path.join(home, '.config', 'visor', '.visor-license');
177703
+ const configToken = this.readFile(configPath);
177704
+ if (configToken)
177705
+ return configToken;
177706
+ }
177707
+ return null;
177708
+ }
177709
+ readFile(filePath) {
177710
+ try {
177711
+ return fs.readFileSync(filePath, 'utf-8').trim();
177712
+ }
177713
+ catch {
177714
+ return null;
177715
+ }
177716
+ }
177717
+ verifyAndDecode(token) {
177718
+ try {
177719
+ const parts = token.split('.');
177720
+ if (parts.length !== 3)
177721
+ return null;
177722
+ const [headerB64, payloadB64, signatureB64] = parts;
177723
+ // Decode header to verify algorithm
177724
+ const header = JSON.parse(Buffer.from(headerB64, 'base64url').toString());
177725
+ if (header.alg !== 'EdDSA')
177726
+ return null;
177727
+ // Verify signature
177728
+ const data = `${headerB64}.${payloadB64}`;
177729
+ const signature = Buffer.from(signatureB64, 'base64url');
177730
+ const publicKey = crypto.createPublicKey(LicenseValidator.PUBLIC_KEY);
177731
+ // Validate that the loaded public key is actually Ed25519 (OID 1.3.101.112).
177732
+ // This prevents algorithm-confusion attacks if the embedded key were ever
177733
+ // swapped to a different type.
177734
+ if (publicKey.asymmetricKeyType !== 'ed25519') {
177735
+ return null;
177736
+ }
177737
+ // Ed25519 verification: algorithm must be null because EdDSA performs its
177738
+ // own internal hashing (SHA-512) — passing a digest algorithm here would
177739
+ // cause Node.js to throw. The key type is validated above.
177740
+ const isValid = crypto.verify(null, Buffer.from(data), publicKey, signature);
177741
+ if (!isValid)
177742
+ return null;
177743
+ // Decode payload
177744
+ const payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString());
177745
+ // Validate required fields
177746
+ if (!payload.org ||
177747
+ !Array.isArray(payload.features) ||
177748
+ typeof payload.exp !== 'number' ||
177749
+ typeof payload.iat !== 'number' ||
177750
+ !payload.sub) {
177751
+ return null;
177752
+ }
177753
+ // Check expiry (with grace period)
177754
+ const now = Date.now();
177755
+ const expiryMs = payload.exp * 1000;
177756
+ if (now >= expiryMs + LicenseValidator.GRACE_PERIOD) {
177757
+ return null;
177758
+ }
177759
+ return payload;
177760
+ }
177761
+ catch {
177762
+ return null;
177763
+ }
177764
+ }
177765
+ }
177766
+ exports.LicenseValidator = LicenseValidator;
177767
+
177768
+
177769
+ /***/ }),
177770
+
177771
+ /***/ 87068:
177772
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
177773
+
177774
+ "use strict";
177775
+
177776
+ /**
177777
+ * Copyright (c) ProbeLabs. All rights reserved.
177778
+ * Licensed under the Elastic License 2.0; you may not use this file except
177779
+ * in compliance with the Elastic License 2.0.
177780
+ */
177781
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
177782
+ if (k2 === undefined) k2 = k;
177783
+ var desc = Object.getOwnPropertyDescriptor(m, k);
177784
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
177785
+ desc = { enumerable: true, get: function() { return m[k]; } };
177786
+ }
177787
+ Object.defineProperty(o, k2, desc);
177788
+ }) : (function(o, m, k, k2) {
177789
+ if (k2 === undefined) k2 = k;
177790
+ o[k2] = m[k];
177791
+ }));
177792
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
177793
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
177794
+ }) : function(o, v) {
177795
+ o["default"] = v;
177796
+ });
177797
+ var __importStar = (this && this.__importStar) || (function () {
177798
+ var ownKeys = function(o) {
177799
+ ownKeys = Object.getOwnPropertyNames || function (o) {
177800
+ var ar = [];
177801
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
177802
+ return ar;
177803
+ };
177804
+ return ownKeys(o);
177805
+ };
177806
+ return function (mod) {
177807
+ if (mod && mod.__esModule) return mod;
177808
+ var result = {};
177809
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
177810
+ __setModuleDefault(result, mod);
177811
+ return result;
177812
+ };
177813
+ })();
177814
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
177815
+ exports.loadEnterprisePolicyEngine = loadEnterprisePolicyEngine;
177816
+ exports.loadEnterpriseStoreBackend = loadEnterpriseStoreBackend;
177817
+ const default_engine_1 = __nccwpck_require__(93866);
177818
+ /**
177819
+ * Load the enterprise policy engine if licensed, otherwise return the default no-op engine.
177820
+ *
177821
+ * This is the sole import boundary between OSS and enterprise code. Core code
177822
+ * must only import from this module (via dynamic `await import()`), never from
177823
+ * individual enterprise submodules.
177824
+ */
177825
+ async function loadEnterprisePolicyEngine(config) {
177826
+ try {
177827
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
177828
+ const validator = new LicenseValidator();
177829
+ const license = await validator.loadAndValidate();
177830
+ if (!license || !validator.hasFeature('policy')) {
177831
+ return new default_engine_1.DefaultPolicyEngine();
177832
+ }
177833
+ if (validator.isInGracePeriod()) {
177834
+ // eslint-disable-next-line no-console
177835
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
177836
+ 'Please renew your license.');
177837
+ }
177838
+ const { OpaPolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(39530)));
177839
+ const engine = new OpaPolicyEngine(config);
177840
+ await engine.initialize(config);
177841
+ return engine;
177842
+ }
177843
+ catch (err) {
177844
+ // Enterprise code not available or initialization failed
177845
+ const msg = err instanceof Error ? err.message : String(err);
177846
+ try {
177847
+ const { logger } = __nccwpck_require__(86999);
177848
+ logger.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
177849
+ }
177850
+ catch {
177851
+ // silent
177852
+ }
177853
+ return new default_engine_1.DefaultPolicyEngine();
177854
+ }
177855
+ }
177856
+ /**
177857
+ * Load the enterprise schedule store backend if licensed.
177858
+ *
177859
+ * @param driver Database driver ('postgresql', 'mysql', or 'mssql')
177860
+ * @param storageConfig Storage configuration with connection details
177861
+ * @param haConfig Optional HA configuration
177862
+ * @throws Error if enterprise license is not available or missing 'scheduler-sql' feature
177863
+ */
177864
+ async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
177865
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
177866
+ const validator = new LicenseValidator();
177867
+ const license = await validator.loadAndValidate();
177868
+ if (!license || !validator.hasFeature('scheduler-sql')) {
177869
+ throw new Error(`The ${driver} schedule storage driver requires a Visor Enterprise license ` +
177870
+ `with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`);
177871
+ }
177872
+ if (validator.isInGracePeriod()) {
177873
+ // eslint-disable-next-line no-console
177874
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
177875
+ 'Please renew your license.');
177876
+ }
177877
+ const { KnexStoreBackend } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(63737)));
177878
+ return new KnexStoreBackend(driver, storageConfig, haConfig);
177879
+ }
177880
+
177881
+
177882
+ /***/ }),
177883
+
177884
+ /***/ 628:
177885
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
177886
+
177887
+ "use strict";
177888
+
177889
+ /**
177890
+ * Copyright (c) ProbeLabs. All rights reserved.
177891
+ * Licensed under the Elastic License 2.0; you may not use this file except
177892
+ * in compliance with the Elastic License 2.0.
177893
+ */
177894
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
177895
+ if (k2 === undefined) k2 = k;
177896
+ var desc = Object.getOwnPropertyDescriptor(m, k);
177897
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
177898
+ desc = { enumerable: true, get: function() { return m[k]; } };
177899
+ }
177900
+ Object.defineProperty(o, k2, desc);
177901
+ }) : (function(o, m, k, k2) {
177902
+ if (k2 === undefined) k2 = k;
177903
+ o[k2] = m[k];
177904
+ }));
177905
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
177906
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
177907
+ }) : function(o, v) {
177908
+ o["default"] = v;
177909
+ });
177910
+ var __importStar = (this && this.__importStar) || (function () {
177911
+ var ownKeys = function(o) {
177912
+ ownKeys = Object.getOwnPropertyNames || function (o) {
177913
+ var ar = [];
177914
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
177915
+ return ar;
177916
+ };
177917
+ return ownKeys(o);
177918
+ };
177919
+ return function (mod) {
177920
+ if (mod && mod.__esModule) return mod;
177921
+ var result = {};
177922
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
177923
+ __setModuleDefault(result, mod);
177924
+ return result;
177925
+ };
177926
+ })();
177927
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
177928
+ exports.OpaCompiler = void 0;
177929
+ const fs = __importStar(__nccwpck_require__(79896));
177930
+ const path = __importStar(__nccwpck_require__(16928));
177931
+ const os = __importStar(__nccwpck_require__(70857));
177932
+ const crypto = __importStar(__nccwpck_require__(76982));
177933
+ const child_process_1 = __nccwpck_require__(35317);
177934
+ /**
177935
+ * OPA Rego Compiler - compiles .rego policy files to WASM bundles using the `opa` CLI.
177936
+ *
177937
+ * Handles:
177938
+ * - Resolving input paths to WASM bytes (direct .wasm, directory with policy.wasm, or .rego files)
177939
+ * - Compiling .rego files to WASM via `opa build`
177940
+ * - Caching compiled bundles based on content hashes
177941
+ * - Extracting policy.wasm from OPA tar.gz bundles
177942
+ *
177943
+ * Requires:
177944
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
177945
+ */
177946
+ class OpaCompiler {
177947
+ static CACHE_DIR = path.join(os.tmpdir(), 'visor-opa-cache');
177948
+ /**
177949
+ * Resolve the input paths to WASM bytes.
177950
+ *
177951
+ * Strategy:
177952
+ * 1. If any path is a .wasm file, read it directly
177953
+ * 2. If a directory contains policy.wasm, read it
177954
+ * 3. Otherwise, collect all .rego files and auto-compile via `opa build`
177955
+ */
177956
+ async resolveWasmBytes(paths) {
177957
+ // Collect .rego files and check for existing .wasm
177958
+ const regoFiles = [];
177959
+ for (const p of paths) {
177960
+ const resolved = path.resolve(p);
177961
+ // Reject paths containing '..' after resolution (path traversal)
177962
+ if (path.normalize(resolved).includes('..')) {
177963
+ throw new Error(`Policy path contains traversal sequences: ${p}`);
177964
+ }
177965
+ // Direct .wasm file
177966
+ if (resolved.endsWith('.wasm') && fs.existsSync(resolved)) {
177967
+ return fs.readFileSync(resolved);
177968
+ }
177969
+ if (!fs.existsSync(resolved))
177970
+ continue;
177971
+ const stat = fs.statSync(resolved);
177972
+ if (stat.isDirectory()) {
177973
+ // Check for pre-compiled policy.wasm in directory
177974
+ const wasmCandidate = path.join(resolved, 'policy.wasm');
177975
+ if (fs.existsSync(wasmCandidate)) {
177976
+ return fs.readFileSync(wasmCandidate);
177977
+ }
177978
+ // Collect all .rego files from directory
177979
+ const files = fs.readdirSync(resolved);
177980
+ for (const f of files) {
177981
+ if (f.endsWith('.rego')) {
177982
+ regoFiles.push(path.join(resolved, f));
177983
+ }
177984
+ }
177985
+ }
177986
+ else if (resolved.endsWith('.rego')) {
177987
+ regoFiles.push(resolved);
177988
+ }
177989
+ }
177990
+ if (regoFiles.length === 0) {
177991
+ throw new Error(`OPA WASM evaluator: no .wasm bundle or .rego files found in: ${paths.join(', ')}`);
177992
+ }
177993
+ // Auto-compile .rego -> .wasm
177994
+ return this.compileRego(regoFiles);
177995
+ }
177996
+ /**
177997
+ * Auto-compile .rego files to a WASM bundle using the `opa` CLI.
177998
+ *
177999
+ * Caches the compiled bundle based on a content hash of all input .rego files
178000
+ * so subsequent runs skip compilation if policies haven't changed.
178001
+ */
178002
+ compileRego(regoFiles) {
178003
+ // Check that `opa` CLI is available
178004
+ try {
178005
+ (0, child_process_1.execFileSync)('opa', ['version'], { stdio: 'pipe' });
178006
+ }
178007
+ catch {
178008
+ throw new Error('OPA CLI (`opa`) not found on PATH. Install it from https://www.openpolicyagent.org/docs/latest/#running-opa\n' +
178009
+ 'Or pre-compile your .rego files: opa build -t wasm -e visor -o bundle.tar.gz ' +
178010
+ regoFiles.join(' '));
178011
+ }
178012
+ // Compute content hash for cache key
178013
+ const hash = crypto.createHash('sha256');
178014
+ for (const f of regoFiles.sort()) {
178015
+ hash.update(fs.readFileSync(f));
178016
+ hash.update(f); // include filename for disambiguation
178017
+ }
178018
+ const cacheKey = hash.digest('hex').slice(0, 16);
178019
+ const cacheDir = OpaCompiler.CACHE_DIR;
178020
+ const cachedWasm = path.join(cacheDir, `${cacheKey}.wasm`);
178021
+ // Return cached bundle if still valid
178022
+ if (fs.existsSync(cachedWasm)) {
178023
+ return fs.readFileSync(cachedWasm);
178024
+ }
178025
+ // Compile to WASM via opa build
178026
+ fs.mkdirSync(cacheDir, { recursive: true });
178027
+ const bundleTar = path.join(cacheDir, `${cacheKey}-bundle.tar.gz`);
178028
+ try {
178029
+ const args = [
178030
+ 'build',
178031
+ '-t',
178032
+ 'wasm',
178033
+ '-e',
178034
+ 'visor', // entrypoint: the visor package tree
178035
+ '-o',
178036
+ bundleTar,
178037
+ ...regoFiles,
178038
+ ];
178039
+ (0, child_process_1.execFileSync)('opa', args, {
178040
+ stdio: 'pipe',
178041
+ timeout: 30000,
178042
+ });
178043
+ }
178044
+ catch (err) {
178045
+ const stderr = err?.stderr?.toString() || '';
178046
+ throw new Error(`Failed to compile .rego files to WASM:\n${stderr}\n` +
178047
+ 'Ensure your .rego files are valid and the `opa` CLI is installed.');
178048
+ }
178049
+ // Extract policy.wasm from the tar.gz bundle
178050
+ // OPA bundles are tar.gz with /policy.wasm inside
178051
+ try {
178052
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, '/policy.wasm'], {
178053
+ stdio: 'pipe',
178054
+ });
178055
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
178056
+ if (fs.existsSync(extractedWasm)) {
178057
+ // Move to cache-key named file
178058
+ fs.renameSync(extractedWasm, cachedWasm);
178059
+ }
178060
+ }
178061
+ catch {
178062
+ // Some tar implementations don't like leading /
178063
+ try {
178064
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, 'policy.wasm'], {
178065
+ stdio: 'pipe',
178066
+ });
178067
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
178068
+ if (fs.existsSync(extractedWasm)) {
178069
+ fs.renameSync(extractedWasm, cachedWasm);
178070
+ }
178071
+ }
178072
+ catch (err2) {
178073
+ throw new Error(`Failed to extract policy.wasm from OPA bundle: ${err2?.message || err2}`);
178074
+ }
178075
+ }
178076
+ // Clean up tar
178077
+ try {
178078
+ fs.unlinkSync(bundleTar);
178079
+ }
178080
+ catch { }
178081
+ if (!fs.existsSync(cachedWasm)) {
178082
+ throw new Error('OPA build succeeded but policy.wasm was not found in the bundle');
178083
+ }
178084
+ return fs.readFileSync(cachedWasm);
178085
+ }
178086
+ }
178087
+ exports.OpaCompiler = OpaCompiler;
178088
+
178089
+
178090
+ /***/ }),
178091
+
178092
+ /***/ 44693:
178093
+ /***/ ((__unused_webpack_module, exports) => {
178094
+
178095
+ "use strict";
178096
+
178097
+ /**
178098
+ * Copyright (c) ProbeLabs. All rights reserved.
178099
+ * Licensed under the Elastic License 2.0; you may not use this file except
178100
+ * in compliance with the Elastic License 2.0.
178101
+ */
178102
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
178103
+ exports.OpaHttpEvaluator = void 0;
178104
+ /**
178105
+ * OPA HTTP Evaluator - evaluates policies via an external OPA server's REST API.
178106
+ *
178107
+ * Uses the built-in `fetch` API (Node 18+), so no extra dependencies are needed.
178108
+ */
178109
+ class OpaHttpEvaluator {
178110
+ baseUrl;
178111
+ timeout;
178112
+ constructor(baseUrl, timeout = 5000) {
178113
+ // Validate URL format and protocol
178114
+ let parsed;
178115
+ try {
178116
+ parsed = new URL(baseUrl);
178117
+ }
178118
+ catch {
178119
+ throw new Error(`OPA HTTP evaluator: invalid URL: ${baseUrl}`);
178120
+ }
178121
+ if (!['http:', 'https:'].includes(parsed.protocol)) {
178122
+ throw new Error(`OPA HTTP evaluator: url must use http:// or https:// protocol, got: ${baseUrl}`);
178123
+ }
178124
+ // Block cloud metadata, loopback, link-local, and private network addresses
178125
+ const hostname = parsed.hostname;
178126
+ if (this.isBlockedHostname(hostname)) {
178127
+ throw new Error(`OPA HTTP evaluator: url must not point to internal, loopback, or private network addresses`);
178128
+ }
178129
+ // Normalize: strip trailing slash
178130
+ this.baseUrl = baseUrl.replace(/\/+$/, '');
178131
+ this.timeout = timeout;
178132
+ }
178133
+ /**
178134
+ * Check if a hostname is blocked due to SSRF concerns.
178135
+ *
178136
+ * Blocks:
178137
+ * - Loopback addresses (127.x.x.x, localhost, 0.0.0.0, ::1)
178138
+ * - Link-local addresses (169.254.x.x)
178139
+ * - Private networks (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
178140
+ * - IPv6 unique local addresses (fd00::/8)
178141
+ * - Cloud metadata services (*.internal)
178142
+ */
178143
+ isBlockedHostname(hostname) {
178144
+ if (!hostname)
178145
+ return true; // block empty hostnames
178146
+ // Normalize hostname: lowercase and remove brackets for IPv6
178147
+ const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
178148
+ // Block .internal domains (cloud metadata services)
178149
+ if (normalized === 'metadata.google.internal' || normalized.endsWith('.internal')) {
178150
+ return true;
178151
+ }
178152
+ // Block localhost variants
178153
+ if (normalized === 'localhost' || normalized === 'localhost.localdomain') {
178154
+ return true;
178155
+ }
178156
+ // Block IPv6 loopback
178157
+ if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
178158
+ return true;
178159
+ }
178160
+ // Check IPv4 patterns
178161
+ const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
178162
+ const ipv4Match = normalized.match(ipv4Pattern);
178163
+ if (ipv4Match) {
178164
+ const octets = ipv4Match.slice(1, 5).map(Number);
178165
+ // Validate octets are in range [0, 255]
178166
+ if (octets.some(octet => octet > 255)) {
178167
+ return false;
178168
+ }
178169
+ const [a, b] = octets;
178170
+ // Block loopback: 127.0.0.0/8
178171
+ if (a === 127) {
178172
+ return true;
178173
+ }
178174
+ // Block 0.0.0.0/8 (this host)
178175
+ if (a === 0) {
178176
+ return true;
178177
+ }
178178
+ // Block link-local: 169.254.0.0/16
178179
+ if (a === 169 && b === 254) {
178180
+ return true;
178181
+ }
178182
+ // Block private networks
178183
+ // 10.0.0.0/8
178184
+ if (a === 10) {
178185
+ return true;
178186
+ }
178187
+ // 172.16.0.0/12 (172.16.x.x through 172.31.x.x)
178188
+ if (a === 172 && b >= 16 && b <= 31) {
178189
+ return true;
178190
+ }
178191
+ // 192.168.0.0/16
178192
+ if (a === 192 && b === 168) {
178193
+ return true;
178194
+ }
178195
+ }
178196
+ // Check IPv6 patterns
178197
+ // Block unique local addresses: fd00::/8
178198
+ if (normalized.startsWith('fd') || normalized.startsWith('fc')) {
178199
+ return true;
178200
+ }
178201
+ // Block link-local: fe80::/10
178202
+ if (normalized.startsWith('fe80:')) {
178203
+ return true;
178204
+ }
178205
+ return false;
178206
+ }
178207
+ /**
178208
+ * Evaluate a policy rule against an input document via OPA REST API.
178209
+ *
178210
+ * @param input - The input document to evaluate
178211
+ * @param rulePath - OPA rule path (e.g., 'visor/check/execute')
178212
+ * @returns The result object from OPA, or undefined on error
178213
+ */
178214
+ async evaluate(input, rulePath) {
178215
+ // OPA Data API: POST /v1/data/<path>
178216
+ const encodedPath = rulePath
178217
+ .split('/')
178218
+ .map(s => encodeURIComponent(s))
178219
+ .join('/');
178220
+ const url = `${this.baseUrl}/v1/data/${encodedPath}`;
178221
+ const controller = new AbortController();
178222
+ const timer = setTimeout(() => controller.abort(), this.timeout);
178223
+ try {
178224
+ const response = await fetch(url, {
178225
+ method: 'POST',
178226
+ headers: { 'Content-Type': 'application/json' },
178227
+ body: JSON.stringify({ input }),
178228
+ signal: controller.signal,
178229
+ });
178230
+ if (!response.ok) {
178231
+ throw new Error(`OPA HTTP ${response.status}: ${response.statusText}`);
178232
+ }
178233
+ let body;
178234
+ try {
178235
+ body = await response.json();
178236
+ }
178237
+ catch (jsonErr) {
178238
+ throw new Error(`OPA HTTP evaluator: failed to parse JSON response: ${jsonErr instanceof Error ? jsonErr.message : String(jsonErr)}`);
178239
+ }
178240
+ // OPA returns { result: { ... } }
178241
+ return body?.result;
178242
+ }
178243
+ finally {
178244
+ clearTimeout(timer);
178245
+ }
178246
+ }
178247
+ async shutdown() {
178248
+ // No persistent connections to close
178249
+ }
178250
+ }
178251
+ exports.OpaHttpEvaluator = OpaHttpEvaluator;
178252
+
178253
+
178254
+ /***/ }),
178255
+
178256
+ /***/ 39530:
178257
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
178258
+
178259
+ "use strict";
178260
+
178261
+ /**
178262
+ * Copyright (c) ProbeLabs. All rights reserved.
178263
+ * Licensed under the Elastic License 2.0; you may not use this file except
178264
+ * in compliance with the Elastic License 2.0.
178265
+ */
178266
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
178267
+ exports.OpaPolicyEngine = void 0;
178268
+ const opa_wasm_evaluator_1 = __nccwpck_require__(8613);
178269
+ const opa_http_evaluator_1 = __nccwpck_require__(44693);
178270
+ const policy_input_builder_1 = __nccwpck_require__(17117);
178271
+ /**
178272
+ * Enterprise OPA Policy Engine.
178273
+ *
178274
+ * Wraps both WASM (local) and HTTP (remote) OPA evaluators behind the
178275
+ * OSS PolicyEngine interface. All OPA input building and role resolution
178276
+ * is handled internally — the OSS call sites pass only plain types.
178277
+ */
178278
+ class OpaPolicyEngine {
178279
+ evaluator = null;
178280
+ fallback;
178281
+ timeout;
178282
+ config;
178283
+ inputBuilder = null;
178284
+ logger = null;
178285
+ constructor(config) {
178286
+ this.config = config;
178287
+ this.fallback = config.fallback || 'deny';
178288
+ this.timeout = config.timeout || 5000;
178289
+ }
178290
+ async initialize(config) {
178291
+ // Resolve logger once at initialization
178292
+ try {
178293
+ this.logger = (__nccwpck_require__(86999).logger);
178294
+ }
178295
+ catch {
178296
+ // logger not available in this context
178297
+ }
178298
+ // Build actor/repo context from environment (available at engine init time)
178299
+ const actor = {
178300
+ authorAssociation: process.env.VISOR_AUTHOR_ASSOCIATION,
178301
+ login: process.env.VISOR_AUTHOR_LOGIN || process.env.GITHUB_ACTOR,
178302
+ isLocalMode: !process.env.GITHUB_ACTIONS,
178303
+ };
178304
+ const repo = {
178305
+ owner: process.env.GITHUB_REPOSITORY_OWNER,
178306
+ name: process.env.GITHUB_REPOSITORY?.split('/')[1],
178307
+ branch: process.env.GITHUB_HEAD_REF,
178308
+ baseBranch: process.env.GITHUB_BASE_REF,
178309
+ event: process.env.GITHUB_EVENT_NAME,
178310
+ };
178311
+ const prNum = process.env.GITHUB_PR_NUMBER
178312
+ ? parseInt(process.env.GITHUB_PR_NUMBER, 10)
178313
+ : undefined;
178314
+ const pullRequest = {
178315
+ number: prNum !== undefined && Number.isFinite(prNum) ? prNum : undefined,
178316
+ };
178317
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(config, actor, repo, pullRequest);
178318
+ if (config.engine === 'local') {
178319
+ if (!config.rules) {
178320
+ throw new Error('OPA local mode requires `policy.rules` path to .wasm or .rego files');
178321
+ }
178322
+ const wasm = new opa_wasm_evaluator_1.OpaWasmEvaluator();
178323
+ await wasm.initialize(config.rules);
178324
+ if (config.data) {
178325
+ wasm.loadData(config.data);
178326
+ }
178327
+ this.evaluator = wasm;
178328
+ }
178329
+ else if (config.engine === 'remote') {
178330
+ if (!config.url) {
178331
+ throw new Error('OPA remote mode requires `policy.url` pointing to OPA server');
178332
+ }
178333
+ this.evaluator = new opa_http_evaluator_1.OpaHttpEvaluator(config.url, this.timeout);
178334
+ }
178335
+ else {
178336
+ this.evaluator = null;
178337
+ }
178338
+ }
178339
+ /**
178340
+ * Update actor/repo/PR context (e.g., after PR info becomes available).
178341
+ * Called by the enterprise loader when engine context is enriched.
178342
+ */
178343
+ setActorContext(actor, repo, pullRequest) {
178344
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(this.config, actor, repo, pullRequest);
178345
+ }
178346
+ async evaluateCheckExecution(checkId, checkConfig) {
178347
+ if (!this.evaluator || !this.inputBuilder)
178348
+ return { allowed: true };
178349
+ const cfg = checkConfig && typeof checkConfig === 'object'
178350
+ ? checkConfig
178351
+ : {};
178352
+ const policyOverride = cfg.policy;
178353
+ const input = this.inputBuilder.forCheckExecution({
178354
+ id: checkId,
178355
+ type: cfg.type || 'ai',
178356
+ group: cfg.group,
178357
+ tags: cfg.tags,
178358
+ criticality: cfg.criticality,
178359
+ sandbox: cfg.sandbox,
178360
+ policy: policyOverride,
178361
+ });
178362
+ return this.doEvaluate(input, this.resolveRulePath('check.execute', policyOverride?.rule));
178363
+ }
178364
+ async evaluateToolInvocation(serverName, methodName, transport) {
178365
+ if (!this.evaluator || !this.inputBuilder)
178366
+ return { allowed: true };
178367
+ const input = this.inputBuilder.forToolInvocation(serverName, methodName, transport);
178368
+ return this.doEvaluate(input, 'visor/tool/invoke');
178369
+ }
178370
+ async evaluateCapabilities(checkId, capabilities) {
178371
+ if (!this.evaluator || !this.inputBuilder)
178372
+ return { allowed: true };
178373
+ const input = this.inputBuilder.forCapabilityResolve(checkId, capabilities);
178374
+ return this.doEvaluate(input, 'visor/capability/resolve');
178375
+ }
178376
+ async shutdown() {
178377
+ if (this.evaluator && 'shutdown' in this.evaluator) {
178378
+ await this.evaluator.shutdown();
178379
+ }
178380
+ this.evaluator = null;
178381
+ this.inputBuilder = null;
178382
+ }
178383
+ resolveRulePath(defaultScope, override) {
178384
+ if (override) {
178385
+ return override.startsWith('visor/') ? override : `visor/${override}`;
178386
+ }
178387
+ return `visor/${defaultScope.replace(/\./g, '/')}`;
178388
+ }
178389
+ async doEvaluate(input, rulePath) {
178390
+ try {
178391
+ this.logger?.debug(`[PolicyEngine] Evaluating ${rulePath}`, JSON.stringify(input));
178392
+ let timer;
178393
+ const timeoutPromise = new Promise((_resolve, reject) => {
178394
+ timer = setTimeout(() => reject(new Error('policy evaluation timeout')), this.timeout);
178395
+ });
178396
+ try {
178397
+ const result = await Promise.race([this.rawEvaluate(input, rulePath), timeoutPromise]);
178398
+ const decision = this.parseDecision(result);
178399
+ // In warn mode, override denied decisions to allowed but flag as warn
178400
+ if (!decision.allowed && this.fallback === 'warn') {
178401
+ decision.allowed = true;
178402
+ decision.warn = true;
178403
+ decision.reason = `audit: ${decision.reason || 'policy denied'}`;
178404
+ }
178405
+ this.logger?.debug(`[PolicyEngine] Decision for ${rulePath}: allowed=${decision.allowed}, warn=${decision.warn || false}, reason=${decision.reason || 'none'}`);
178406
+ return decision;
178407
+ }
178408
+ finally {
178409
+ if (timer)
178410
+ clearTimeout(timer);
178411
+ }
178412
+ }
178413
+ catch (err) {
178414
+ const msg = err instanceof Error ? err.message : String(err);
178415
+ this.logger?.warn(`[PolicyEngine] Evaluation failed for ${rulePath}: ${msg}`);
178416
+ return {
178417
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
178418
+ warn: this.fallback === 'warn' ? true : undefined,
178419
+ reason: `policy evaluation failed, fallback=${this.fallback}`,
178420
+ };
178421
+ }
178422
+ }
178423
+ async rawEvaluate(input, rulePath) {
178424
+ if (this.evaluator instanceof opa_wasm_evaluator_1.OpaWasmEvaluator) {
178425
+ const result = await this.evaluator.evaluate(input);
178426
+ // WASM compiled with `-e visor` entrypoint returns the full visor package tree.
178427
+ // Navigate to the specific rule subtree using rulePath segments.
178428
+ // e.g., 'visor/check/execute' → result.check.execute
178429
+ return this.navigateWasmResult(result, rulePath);
178430
+ }
178431
+ return this.evaluator.evaluate(input, rulePath);
178432
+ }
178433
+ /**
178434
+ * Navigate nested OPA WASM result tree to reach the specific rule's output.
178435
+ * The WASM entrypoint `-e visor` means the result root IS the visor package,
178436
+ * so we strip the `visor/` prefix and walk the remaining segments.
178437
+ */
178438
+ navigateWasmResult(result, rulePath) {
178439
+ if (!result || typeof result !== 'object')
178440
+ return result;
178441
+ // Strip the 'visor/' prefix (matches our compilation entrypoint)
178442
+ const segments = rulePath.replace(/^visor\//, '').split('/');
178443
+ let current = result;
178444
+ for (const seg of segments) {
178445
+ if (current && typeof current === 'object' && seg in current) {
178446
+ current = current[seg];
178447
+ }
178448
+ else {
178449
+ return undefined; // path not found in result tree
178450
+ }
178451
+ }
178452
+ return current;
178453
+ }
178454
+ parseDecision(result) {
178455
+ if (result === undefined || result === null) {
178456
+ return {
178457
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
178458
+ warn: this.fallback === 'warn' ? true : undefined,
178459
+ reason: this.fallback === 'warn' ? 'audit: no policy result' : 'no policy result',
178460
+ };
178461
+ }
178462
+ const allowed = result.allowed !== false;
178463
+ const decision = {
178464
+ allowed,
178465
+ reason: result.reason,
178466
+ };
178467
+ if (result.capabilities) {
178468
+ decision.capabilities = result.capabilities;
178469
+ }
178470
+ return decision;
178471
+ }
178472
+ }
178473
+ exports.OpaPolicyEngine = OpaPolicyEngine;
178474
+
178475
+
178476
+ /***/ }),
178477
+
178478
+ /***/ 8613:
178479
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
178480
+
178481
+ "use strict";
178482
+
178483
+ /**
178484
+ * Copyright (c) ProbeLabs. All rights reserved.
178485
+ * Licensed under the Elastic License 2.0; you may not use this file except
178486
+ * in compliance with the Elastic License 2.0.
178487
+ */
178488
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
178489
+ if (k2 === undefined) k2 = k;
178490
+ var desc = Object.getOwnPropertyDescriptor(m, k);
178491
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
178492
+ desc = { enumerable: true, get: function() { return m[k]; } };
178493
+ }
178494
+ Object.defineProperty(o, k2, desc);
178495
+ }) : (function(o, m, k, k2) {
178496
+ if (k2 === undefined) k2 = k;
178497
+ o[k2] = m[k];
178498
+ }));
178499
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
178500
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
178501
+ }) : function(o, v) {
178502
+ o["default"] = v;
178503
+ });
178504
+ var __importStar = (this && this.__importStar) || (function () {
178505
+ var ownKeys = function(o) {
178506
+ ownKeys = Object.getOwnPropertyNames || function (o) {
178507
+ var ar = [];
178508
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
178509
+ return ar;
178510
+ };
178511
+ return ownKeys(o);
178512
+ };
178513
+ return function (mod) {
178514
+ if (mod && mod.__esModule) return mod;
178515
+ var result = {};
178516
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
178517
+ __setModuleDefault(result, mod);
178518
+ return result;
178519
+ };
178520
+ })();
178521
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
178522
+ exports.OpaWasmEvaluator = void 0;
178523
+ const fs = __importStar(__nccwpck_require__(79896));
178524
+ const path = __importStar(__nccwpck_require__(16928));
178525
+ const opa_compiler_1 = __nccwpck_require__(628);
178526
+ /**
178527
+ * OPA WASM Evaluator - loads and evaluates OPA policies locally.
178528
+ *
178529
+ * Supports three input formats:
178530
+ * 1. Pre-compiled `.wasm` bundle — loaded directly (fastest startup)
178531
+ * 2. `.rego` files or directory — auto-compiled to WASM via `opa build` CLI
178532
+ * 3. Directory with `policy.wasm` inside — loaded directly
178533
+ *
178534
+ * Compilation and caching of .rego files is delegated to {@link OpaCompiler}.
178535
+ *
178536
+ * Requires:
178537
+ * - `@open-policy-agent/opa-wasm` npm package (optional dep)
178538
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
178539
+ */
178540
+ class OpaWasmEvaluator {
178541
+ policy = null;
178542
+ dataDocument = {};
178543
+ compiler = new opa_compiler_1.OpaCompiler();
178544
+ async initialize(rulesPath) {
178545
+ const paths = Array.isArray(rulesPath) ? rulesPath : [rulesPath];
178546
+ const wasmBytes = await this.compiler.resolveWasmBytes(paths);
178547
+ try {
178548
+ // Use createRequire to load the optional dep at runtime without ncc bundling it.
178549
+ // `new Function('id', 'return require(id)')` fails in ncc bundles because
178550
+ // `require` is not in the `new Function` scope. `createRequire` works correctly
178551
+ // because it creates a real Node.js require rooted at the given path.
178552
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
178553
+ const { createRequire } = __nccwpck_require__(73339);
178554
+ const runtimeRequire = createRequire(__filename);
178555
+ const opaWasm = runtimeRequire('@open-policy-agent/opa-wasm');
178556
+ const loadPolicy = opaWasm.loadPolicy || opaWasm.default?.loadPolicy;
178557
+ if (!loadPolicy) {
178558
+ throw new Error('loadPolicy not found in @open-policy-agent/opa-wasm');
178559
+ }
178560
+ this.policy = await loadPolicy(wasmBytes);
178561
+ }
178562
+ catch (err) {
178563
+ if (err?.code === 'MODULE_NOT_FOUND' || err?.code === 'ERR_MODULE_NOT_FOUND') {
178564
+ throw new Error('OPA WASM evaluator requires @open-policy-agent/opa-wasm. ' +
178565
+ 'Install it with: npm install @open-policy-agent/opa-wasm');
178566
+ }
178567
+ throw err;
178568
+ }
178569
+ }
178570
+ /**
178571
+ * Load external data from a JSON file to use as the OPA data document.
178572
+ * The loaded data will be passed to `policy.setData()` during evaluation,
178573
+ * making it available in Rego via `data.<key>`.
178574
+ */
178575
+ loadData(dataPath) {
178576
+ const resolved = path.resolve(dataPath);
178577
+ if (path.normalize(resolved).includes('..')) {
178578
+ throw new Error(`Data path contains traversal sequences: ${dataPath}`);
178579
+ }
178580
+ if (!fs.existsSync(resolved)) {
178581
+ throw new Error(`OPA data file not found: ${resolved}`);
178582
+ }
178583
+ const stat = fs.statSync(resolved);
178584
+ if (stat.size > 10 * 1024 * 1024) {
178585
+ throw new Error(`OPA data file exceeds 10MB limit: ${resolved} (${stat.size} bytes)`);
178586
+ }
178587
+ const raw = fs.readFileSync(resolved, 'utf-8');
178588
+ try {
178589
+ const parsed = JSON.parse(raw);
178590
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
178591
+ throw new Error('OPA data file must contain a JSON object (not an array or primitive)');
178592
+ }
178593
+ this.dataDocument = parsed;
178594
+ }
178595
+ catch (err) {
178596
+ if (err.message.startsWith('OPA data file must')) {
178597
+ throw err;
178598
+ }
178599
+ throw new Error(`Failed to parse OPA data file ${resolved}: ${err.message}`);
178600
+ }
178601
+ }
178602
+ async evaluate(input) {
178603
+ if (!this.policy) {
178604
+ throw new Error('OPA WASM evaluator not initialized');
178605
+ }
178606
+ this.policy.setData(this.dataDocument);
178607
+ const resultSet = this.policy.evaluate(input);
178608
+ if (Array.isArray(resultSet) && resultSet.length > 0) {
178609
+ return resultSet[0].result;
178610
+ }
178611
+ return undefined;
178612
+ }
178613
+ async shutdown() {
178614
+ if (this.policy) {
178615
+ // opa-wasm policy objects may have a close/free method for WASM cleanup
178616
+ if (typeof this.policy.close === 'function') {
178617
+ try {
178618
+ this.policy.close();
178619
+ }
178620
+ catch { }
178621
+ }
178622
+ else if (typeof this.policy.free === 'function') {
178623
+ try {
178624
+ this.policy.free();
178625
+ }
178626
+ catch { }
178627
+ }
178628
+ }
178629
+ this.policy = null;
178630
+ }
178631
+ }
178632
+ exports.OpaWasmEvaluator = OpaWasmEvaluator;
178633
+
178634
+
178635
+ /***/ }),
178636
+
178637
+ /***/ 17117:
178638
+ /***/ ((__unused_webpack_module, exports) => {
178639
+
178640
+ "use strict";
178641
+
178642
+ /**
178643
+ * Copyright (c) ProbeLabs. All rights reserved.
178644
+ * Licensed under the Elastic License 2.0; you may not use this file except
178645
+ * in compliance with the Elastic License 2.0.
178646
+ */
178647
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
178648
+ exports.PolicyInputBuilder = void 0;
178649
+ /**
178650
+ * Builds OPA-compatible input documents from engine context.
178651
+ *
178652
+ * Resolves actor roles from the `policy.roles` config section by matching
178653
+ * the actor's authorAssociation and login against role definitions.
178654
+ */
178655
+ class PolicyInputBuilder {
178656
+ roles;
178657
+ actor;
178658
+ repository;
178659
+ pullRequest;
178660
+ constructor(policyConfig, actor, repository, pullRequest) {
178661
+ this.roles = policyConfig.roles || {};
178662
+ this.actor = actor;
178663
+ this.repository = repository;
178664
+ this.pullRequest = pullRequest;
178665
+ }
178666
+ /** Resolve which roles apply to the current actor. */
178667
+ resolveRoles() {
178668
+ const matched = [];
178669
+ for (const [roleName, roleConfig] of Object.entries(this.roles)) {
178670
+ let identityMatch = false;
178671
+ if (roleConfig.author_association &&
178672
+ this.actor.authorAssociation &&
178673
+ roleConfig.author_association.includes(this.actor.authorAssociation)) {
178674
+ identityMatch = true;
178675
+ }
178676
+ if (!identityMatch &&
178677
+ roleConfig.users &&
178678
+ this.actor.login &&
178679
+ roleConfig.users.includes(this.actor.login)) {
178680
+ identityMatch = true;
178681
+ }
178682
+ // Slack user ID match
178683
+ if (!identityMatch &&
178684
+ roleConfig.slack_users &&
178685
+ this.actor.slack?.userId &&
178686
+ roleConfig.slack_users.includes(this.actor.slack.userId)) {
178687
+ identityMatch = true;
178688
+ }
178689
+ // Email match (case-insensitive)
178690
+ if (!identityMatch && roleConfig.emails && this.actor.slack?.email) {
178691
+ const actorEmail = this.actor.slack.email.toLowerCase();
178692
+ if (roleConfig.emails.some(e => e.toLowerCase() === actorEmail)) {
178693
+ identityMatch = true;
178694
+ }
178695
+ }
178696
+ // Note: teams-based role resolution requires GitHub API access (read:org scope)
178697
+ // and is not yet implemented. If configured, the role will not match via teams.
178698
+ if (!identityMatch)
178699
+ continue;
178700
+ // slack_channels gate: if set, the role only applies when triggered from one of these channels
178701
+ if (roleConfig.slack_channels && roleConfig.slack_channels.length > 0) {
178702
+ if (!this.actor.slack?.channelId ||
178703
+ !roleConfig.slack_channels.includes(this.actor.slack.channelId)) {
178704
+ continue;
178705
+ }
178706
+ }
178707
+ matched.push(roleName);
178708
+ }
178709
+ return matched;
178710
+ }
178711
+ buildActor() {
178712
+ return {
178713
+ authorAssociation: this.actor.authorAssociation,
178714
+ login: this.actor.login,
178715
+ roles: this.resolveRoles(),
178716
+ isLocalMode: this.actor.isLocalMode,
178717
+ ...(this.actor.slack && { slack: this.actor.slack }),
178718
+ };
178719
+ }
178720
+ forCheckExecution(check) {
178721
+ return {
178722
+ scope: 'check.execute',
178723
+ check: {
178724
+ id: check.id,
178725
+ type: check.type,
178726
+ group: check.group,
178727
+ tags: check.tags,
178728
+ criticality: check.criticality,
178729
+ sandbox: check.sandbox,
178730
+ policy: check.policy,
178731
+ },
178732
+ actor: this.buildActor(),
178733
+ repository: this.repository,
178734
+ pullRequest: this.pullRequest,
178735
+ };
178736
+ }
178737
+ forToolInvocation(serverName, methodName, transport) {
178738
+ return {
178739
+ scope: 'tool.invoke',
178740
+ tool: { serverName, methodName, transport },
178741
+ actor: this.buildActor(),
178742
+ repository: this.repository,
178743
+ pullRequest: this.pullRequest,
178744
+ };
178745
+ }
178746
+ forCapabilityResolve(checkId, capabilities) {
178747
+ return {
178748
+ scope: 'capability.resolve',
178749
+ check: { id: checkId, type: 'ai' },
178750
+ capability: capabilities,
178751
+ actor: this.buildActor(),
178752
+ repository: this.repository,
178753
+ pullRequest: this.pullRequest,
178754
+ };
178755
+ }
178756
+ }
178757
+ exports.PolicyInputBuilder = PolicyInputBuilder;
178758
+
178759
+
178760
+ /***/ }),
178761
+
178762
+ /***/ 63737:
178763
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
178764
+
178765
+ "use strict";
178766
+
178767
+ /**
178768
+ * Copyright (c) ProbeLabs. All rights reserved.
178769
+ * Licensed under the Elastic License 2.0; you may not use this file except
178770
+ * in compliance with the Elastic License 2.0.
178771
+ */
178772
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
178773
+ if (k2 === undefined) k2 = k;
178774
+ var desc = Object.getOwnPropertyDescriptor(m, k);
178775
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
178776
+ desc = { enumerable: true, get: function() { return m[k]; } };
178777
+ }
178778
+ Object.defineProperty(o, k2, desc);
178779
+ }) : (function(o, m, k, k2) {
178780
+ if (k2 === undefined) k2 = k;
178781
+ o[k2] = m[k];
178782
+ }));
178783
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
178784
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
178785
+ }) : function(o, v) {
178786
+ o["default"] = v;
178787
+ });
178788
+ var __importStar = (this && this.__importStar) || (function () {
178789
+ var ownKeys = function(o) {
178790
+ ownKeys = Object.getOwnPropertyNames || function (o) {
178791
+ var ar = [];
178792
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
178793
+ return ar;
178794
+ };
178795
+ return ownKeys(o);
178796
+ };
178797
+ return function (mod) {
178798
+ if (mod && mod.__esModule) return mod;
178799
+ var result = {};
178800
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
178801
+ __setModuleDefault(result, mod);
178802
+ return result;
178803
+ };
178804
+ })();
178805
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
178806
+ exports.KnexStoreBackend = void 0;
178807
+ /**
178808
+ * Knex-backed schedule store for PostgreSQL, MySQL, and MSSQL (Enterprise)
178809
+ *
178810
+ * Uses Knex query builder for database-agnostic SQL. Same schema as SQLite backend
178811
+ * but with real distributed locking via row-level claims (claimed_by/claimed_at/lock_token).
178812
+ */
178813
+ const fs = __importStar(__nccwpck_require__(79896));
178814
+ const path = __importStar(__nccwpck_require__(16928));
178815
+ const uuid_1 = __nccwpck_require__(31914);
178816
+ const logger_1 = __nccwpck_require__(86999);
178817
+ function toNum(val) {
178818
+ if (val === null || val === undefined)
178819
+ return undefined;
178820
+ return typeof val === 'string' ? parseInt(val, 10) : val;
178821
+ }
178822
+ function safeJsonParse(value) {
178823
+ if (!value)
178824
+ return undefined;
178825
+ try {
178826
+ return JSON.parse(value);
178827
+ }
178828
+ catch {
178829
+ return undefined;
178830
+ }
178831
+ }
178832
+ function fromTriggerRow(row) {
178833
+ return {
178834
+ id: row.id,
178835
+ creatorId: row.creator_id,
178836
+ creatorContext: row.creator_context ?? undefined,
178837
+ creatorName: row.creator_name ?? undefined,
178838
+ description: row.description ?? undefined,
178839
+ channels: safeJsonParse(row.channels),
178840
+ fromUsers: safeJsonParse(row.from_users),
178841
+ fromBots: row.from_bots === true || row.from_bots === 1,
178842
+ contains: safeJsonParse(row.contains),
178843
+ matchPattern: row.match_pattern ?? undefined,
178844
+ threads: row.threads,
178845
+ workflow: row.workflow,
178846
+ inputs: safeJsonParse(row.inputs),
178847
+ outputContext: safeJsonParse(row.output_context),
178848
+ status: row.status,
178849
+ enabled: row.enabled === true || row.enabled === 1,
178850
+ createdAt: toNum(row.created_at),
178851
+ };
178852
+ }
178853
+ function toTriggerInsertRow(trigger) {
178854
+ return {
178855
+ id: trigger.id,
178856
+ creator_id: trigger.creatorId,
178857
+ creator_context: trigger.creatorContext ?? null,
178858
+ creator_name: trigger.creatorName ?? null,
178859
+ description: trigger.description ?? null,
178860
+ channels: trigger.channels ? JSON.stringify(trigger.channels) : null,
178861
+ from_users: trigger.fromUsers ? JSON.stringify(trigger.fromUsers) : null,
178862
+ from_bots: trigger.fromBots,
178863
+ contains: trigger.contains ? JSON.stringify(trigger.contains) : null,
178864
+ match_pattern: trigger.matchPattern ?? null,
178865
+ threads: trigger.threads,
178866
+ workflow: trigger.workflow,
178867
+ inputs: trigger.inputs ? JSON.stringify(trigger.inputs) : null,
178868
+ output_context: trigger.outputContext ? JSON.stringify(trigger.outputContext) : null,
178869
+ status: trigger.status,
178870
+ enabled: trigger.enabled,
178871
+ created_at: trigger.createdAt,
178872
+ };
178873
+ }
178874
+ function fromDbRow(row) {
178875
+ return {
178876
+ id: row.id,
178877
+ creatorId: row.creator_id,
178878
+ creatorContext: row.creator_context ?? undefined,
178879
+ creatorName: row.creator_name ?? undefined,
178880
+ timezone: row.timezone,
178881
+ schedule: row.schedule_expr,
178882
+ runAt: toNum(row.run_at),
178883
+ isRecurring: row.is_recurring === true || row.is_recurring === 1,
178884
+ originalExpression: row.original_expression,
178885
+ workflow: row.workflow ?? undefined,
178886
+ workflowInputs: safeJsonParse(row.workflow_inputs),
178887
+ outputContext: safeJsonParse(row.output_context),
178888
+ status: row.status,
178889
+ createdAt: toNum(row.created_at),
178890
+ lastRunAt: toNum(row.last_run_at),
178891
+ nextRunAt: toNum(row.next_run_at),
178892
+ runCount: row.run_count,
178893
+ failureCount: row.failure_count,
178894
+ lastError: row.last_error ?? undefined,
178895
+ previousResponse: row.previous_response ?? undefined,
178896
+ };
178897
+ }
178898
+ function toInsertRow(schedule) {
178899
+ return {
178900
+ id: schedule.id,
178901
+ creator_id: schedule.creatorId,
178902
+ creator_context: schedule.creatorContext ?? null,
178903
+ creator_name: schedule.creatorName ?? null,
178904
+ timezone: schedule.timezone,
178905
+ schedule_expr: schedule.schedule,
178906
+ run_at: schedule.runAt ?? null,
178907
+ is_recurring: schedule.isRecurring,
178908
+ original_expression: schedule.originalExpression,
178909
+ workflow: schedule.workflow ?? null,
178910
+ workflow_inputs: schedule.workflowInputs ? JSON.stringify(schedule.workflowInputs) : null,
178911
+ output_context: schedule.outputContext ? JSON.stringify(schedule.outputContext) : null,
178912
+ status: schedule.status,
178913
+ created_at: schedule.createdAt,
178914
+ last_run_at: schedule.lastRunAt ?? null,
178915
+ next_run_at: schedule.nextRunAt ?? null,
178916
+ run_count: schedule.runCount,
178917
+ failure_count: schedule.failureCount,
178918
+ last_error: schedule.lastError ?? null,
178919
+ previous_response: schedule.previousResponse ?? null,
178920
+ };
178921
+ }
178922
+ /**
178923
+ * Enterprise Knex-backed store for PostgreSQL, MySQL, and MSSQL
178924
+ */
178925
+ class KnexStoreBackend {
178926
+ knex = null;
178927
+ driver;
178928
+ connection;
178929
+ constructor(driver, storageConfig, _haConfig) {
178930
+ this.driver = driver;
178931
+ this.connection = (storageConfig.connection || {});
178932
+ }
178933
+ async initialize() {
178934
+ // Load knex dynamically
178935
+ const { createRequire } = __nccwpck_require__(73339);
178936
+ const runtimeRequire = createRequire(__filename);
178937
+ let knexFactory;
178938
+ try {
178939
+ knexFactory = runtimeRequire('knex');
178940
+ }
178941
+ catch (err) {
178942
+ const code = err?.code;
178943
+ if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
178944
+ throw new Error('knex is required for PostgreSQL/MySQL/MSSQL schedule storage. ' +
178945
+ 'Install it with: npm install knex');
178946
+ }
178947
+ throw err;
178948
+ }
178949
+ const clientMap = {
178950
+ postgresql: 'pg',
178951
+ mysql: 'mysql2',
178952
+ mssql: 'tedious',
178953
+ };
178954
+ const client = clientMap[this.driver];
178955
+ // Build connection config
178956
+ let connection;
178957
+ if (this.connection.connection_string) {
178958
+ connection = this.connection.connection_string;
178959
+ }
178960
+ else if (this.driver === 'mssql') {
178961
+ connection = this.buildMssqlConnection();
178962
+ }
178963
+ else {
178964
+ connection = this.buildStandardConnection();
178965
+ }
178966
+ this.knex = knexFactory({
178967
+ client,
178968
+ connection,
178969
+ pool: {
178970
+ min: this.connection.pool?.min ?? 0,
178971
+ max: this.connection.pool?.max ?? 10,
178972
+ },
178973
+ });
178974
+ // Run schema migration
178975
+ await this.migrateSchema();
178976
+ logger_1.logger.info(`[KnexStore] Initialized (${this.driver})`);
178977
+ }
178978
+ buildStandardConnection() {
178979
+ return {
178980
+ host: this.connection.host || 'localhost',
178981
+ port: this.connection.port,
178982
+ database: this.connection.database || 'visor',
178983
+ user: this.connection.user,
178984
+ password: this.connection.password,
178985
+ ssl: this.resolveSslConfig(),
178986
+ };
178987
+ }
178988
+ buildMssqlConnection() {
178989
+ const ssl = this.connection.ssl;
178990
+ const sslEnabled = ssl === true || (typeof ssl === 'object' && ssl.enabled !== false);
178991
+ return {
178992
+ server: this.connection.host || 'localhost',
178993
+ port: this.connection.port,
178994
+ database: this.connection.database || 'visor',
178995
+ user: this.connection.user,
178996
+ password: this.connection.password,
178997
+ options: {
178998
+ encrypt: sslEnabled,
178999
+ trustServerCertificate: typeof ssl === 'object' ? ssl.reject_unauthorized === false : !sslEnabled,
179000
+ },
179001
+ };
179002
+ }
179003
+ resolveSslConfig() {
179004
+ const ssl = this.connection.ssl;
179005
+ if (ssl === false || ssl === undefined)
179006
+ return false;
179007
+ if (ssl === true)
179008
+ return { rejectUnauthorized: true };
179009
+ // Object config
179010
+ if (ssl.enabled === false)
179011
+ return false;
179012
+ const result = {
179013
+ rejectUnauthorized: ssl.reject_unauthorized !== false,
179014
+ };
179015
+ if (ssl.ca) {
179016
+ const caPath = this.validateSslPath(ssl.ca, 'CA certificate');
179017
+ result.ca = fs.readFileSync(caPath, 'utf8');
179018
+ }
179019
+ if (ssl.cert) {
179020
+ const certPath = this.validateSslPath(ssl.cert, 'client certificate');
179021
+ result.cert = fs.readFileSync(certPath, 'utf8');
179022
+ }
179023
+ if (ssl.key) {
179024
+ const keyPath = this.validateSslPath(ssl.key, 'client key');
179025
+ result.key = fs.readFileSync(keyPath, 'utf8');
179026
+ }
179027
+ return result;
179028
+ }
179029
+ validateSslPath(filePath, label) {
179030
+ const resolved = path.resolve(filePath);
179031
+ if (resolved !== path.normalize(resolved)) {
179032
+ throw new Error(`SSL ${label} path contains invalid sequences: ${filePath}`);
179033
+ }
179034
+ if (!fs.existsSync(resolved)) {
179035
+ throw new Error(`SSL ${label} not found: ${filePath}`);
179036
+ }
179037
+ return resolved;
179038
+ }
179039
+ async shutdown() {
179040
+ if (this.knex) {
179041
+ await this.knex.destroy();
179042
+ this.knex = null;
179043
+ }
179044
+ }
179045
+ async migrateSchema() {
179046
+ const knex = this.getKnex();
179047
+ const exists = await knex.schema.hasTable('schedules');
179048
+ if (!exists) {
179049
+ await knex.schema.createTable('schedules', table => {
179050
+ table.string('id', 36).primary();
179051
+ table.string('creator_id', 255).notNullable().index();
179052
+ table.string('creator_context', 255);
179053
+ table.string('creator_name', 255);
179054
+ table.string('timezone', 64).notNullable().defaultTo('UTC');
179055
+ table.string('schedule_expr', 255);
179056
+ table.bigInteger('run_at');
179057
+ table.boolean('is_recurring').notNullable();
179058
+ table.text('original_expression');
179059
+ table.string('workflow', 255);
179060
+ table.text('workflow_inputs');
179061
+ table.text('output_context');
179062
+ table.string('status', 20).notNullable().index();
179063
+ table.bigInteger('created_at').notNullable();
179064
+ table.bigInteger('last_run_at');
179065
+ table.bigInteger('next_run_at');
179066
+ table.integer('run_count').notNullable().defaultTo(0);
179067
+ table.integer('failure_count').notNullable().defaultTo(0);
179068
+ table.text('last_error');
179069
+ table.text('previous_response');
179070
+ table.index(['status', 'next_run_at']);
179071
+ });
179072
+ }
179073
+ // Create message_triggers table
179074
+ const triggersExist = await knex.schema.hasTable('message_triggers');
179075
+ if (!triggersExist) {
179076
+ await knex.schema.createTable('message_triggers', table => {
179077
+ table.string('id', 36).primary();
179078
+ table.string('creator_id', 255).notNullable().index();
179079
+ table.string('creator_context', 255);
179080
+ table.string('creator_name', 255);
179081
+ table.text('description');
179082
+ table.text('channels'); // JSON array
179083
+ table.text('from_users'); // JSON array
179084
+ table.boolean('from_bots').notNullable().defaultTo(false);
179085
+ table.text('contains'); // JSON array
179086
+ table.text('match_pattern');
179087
+ table.string('threads', 20).notNullable().defaultTo('any');
179088
+ table.string('workflow', 255).notNullable();
179089
+ table.text('inputs'); // JSON
179090
+ table.text('output_context'); // JSON
179091
+ table.string('status', 20).notNullable().defaultTo('active').index();
179092
+ table.boolean('enabled').notNullable().defaultTo(true);
179093
+ table.bigInteger('created_at').notNullable();
179094
+ });
179095
+ }
179096
+ // Create scheduler_locks table for distributed locking
179097
+ const locksExist = await knex.schema.hasTable('scheduler_locks');
179098
+ if (!locksExist) {
179099
+ await knex.schema.createTable('scheduler_locks', table => {
179100
+ table.string('lock_id', 255).primary();
179101
+ table.string('node_id', 255).notNullable();
179102
+ table.string('lock_token', 36).notNullable();
179103
+ table.bigInteger('acquired_at').notNullable();
179104
+ table.bigInteger('expires_at').notNullable();
179105
+ });
179106
+ }
179107
+ }
179108
+ getKnex() {
179109
+ if (!this.knex) {
179110
+ throw new Error('[KnexStore] Not initialized. Call initialize() first.');
179111
+ }
179112
+ return this.knex;
179113
+ }
179114
+ // --- CRUD ---
179115
+ async create(schedule) {
179116
+ const knex = this.getKnex();
179117
+ const newSchedule = {
179118
+ ...schedule,
179119
+ id: (0, uuid_1.v4)(),
179120
+ createdAt: Date.now(),
179121
+ runCount: 0,
179122
+ failureCount: 0,
179123
+ status: 'active',
179124
+ };
179125
+ await knex('schedules').insert(toInsertRow(newSchedule));
179126
+ logger_1.logger.info(`[KnexStore] Created schedule ${newSchedule.id} for user ${newSchedule.creatorId}`);
179127
+ return newSchedule;
179128
+ }
179129
+ async importSchedule(schedule) {
179130
+ const knex = this.getKnex();
179131
+ const existing = await knex('schedules').where('id', schedule.id).first();
179132
+ if (existing)
179133
+ return; // Already imported (idempotent)
179134
+ await knex('schedules').insert(toInsertRow(schedule));
179135
+ }
179136
+ async get(id) {
179137
+ const knex = this.getKnex();
179138
+ const row = await knex('schedules').where('id', id).first();
179139
+ return row ? fromDbRow(row) : undefined;
179140
+ }
179141
+ async update(id, patch) {
179142
+ const knex = this.getKnex();
179143
+ const existing = await knex('schedules').where('id', id).first();
179144
+ if (!existing)
179145
+ return undefined;
179146
+ const current = fromDbRow(existing);
179147
+ const updated = { ...current, ...patch, id: current.id };
179148
+ const row = toInsertRow(updated);
179149
+ // Remove id from update (PK cannot change)
179150
+ delete row.id;
179151
+ await knex('schedules').where('id', id).update(row);
179152
+ return updated;
179153
+ }
179154
+ async delete(id) {
179155
+ const knex = this.getKnex();
179156
+ const deleted = await knex('schedules').where('id', id).del();
179157
+ if (deleted > 0) {
179158
+ logger_1.logger.info(`[KnexStore] Deleted schedule ${id}`);
179159
+ return true;
179160
+ }
179161
+ return false;
179162
+ }
179163
+ // --- Queries ---
179164
+ async getByCreator(creatorId) {
179165
+ const knex = this.getKnex();
179166
+ const rows = await knex('schedules').where('creator_id', creatorId);
179167
+ return rows.map((r) => fromDbRow(r));
179168
+ }
179169
+ async getActiveSchedules() {
179170
+ const knex = this.getKnex();
179171
+ const rows = await knex('schedules').where('status', 'active');
179172
+ return rows.map((r) => fromDbRow(r));
179173
+ }
179174
+ async getDueSchedules(now) {
179175
+ const ts = now ?? Date.now();
179176
+ const knex = this.getKnex();
179177
+ // MSSQL uses 1/0 for booleans
179178
+ const bFalse = this.driver === 'mssql' ? 0 : false;
179179
+ const bTrue = this.driver === 'mssql' ? 1 : true;
179180
+ const rows = await knex('schedules')
179181
+ .where('status', 'active')
179182
+ .andWhere(function () {
179183
+ this.where(function () {
179184
+ this.where('is_recurring', bFalse)
179185
+ .whereNotNull('run_at')
179186
+ .where('run_at', '<=', ts);
179187
+ }).orWhere(function () {
179188
+ this.where('is_recurring', bTrue)
179189
+ .whereNotNull('next_run_at')
179190
+ .where('next_run_at', '<=', ts);
179191
+ });
179192
+ });
179193
+ return rows.map((r) => fromDbRow(r));
179194
+ }
179195
+ async findByWorkflow(creatorId, workflowName) {
179196
+ const knex = this.getKnex();
179197
+ const escaped = workflowName.toLowerCase().replace(/[%_\\]/g, '\\$&');
179198
+ const pattern = `%${escaped}%`;
179199
+ const rows = await knex('schedules')
179200
+ .where('creator_id', creatorId)
179201
+ .where('status', 'active')
179202
+ .whereRaw("LOWER(workflow) LIKE ? ESCAPE '\\'", [pattern]);
179203
+ return rows.map((r) => fromDbRow(r));
179204
+ }
179205
+ async getAll() {
179206
+ const knex = this.getKnex();
179207
+ const rows = await knex('schedules');
179208
+ return rows.map((r) => fromDbRow(r));
179209
+ }
179210
+ async getStats() {
179211
+ const knex = this.getKnex();
179212
+ // MSSQL uses 1/0 for booleans; PostgreSQL/MySQL accept both true/1
179213
+ const boolTrue = this.driver === 'mssql' ? '1' : 'true';
179214
+ const boolFalse = this.driver === 'mssql' ? '0' : 'false';
179215
+ const result = await knex('schedules')
179216
+ .select(knex.raw('COUNT(*) as total'), knex.raw("SUM(CASE WHEN status = 'active' THEN 1 ELSE 0 END) as active"), knex.raw("SUM(CASE WHEN status = 'paused' THEN 1 ELSE 0 END) as paused"), knex.raw("SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed"), knex.raw("SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) as failed"), knex.raw(`SUM(CASE WHEN is_recurring = ${boolTrue} THEN 1 ELSE 0 END) as recurring`), knex.raw(`SUM(CASE WHEN is_recurring = ${boolFalse} THEN 1 ELSE 0 END) as one_time`))
179217
+ .first();
179218
+ return {
179219
+ total: Number(result.total) || 0,
179220
+ active: Number(result.active) || 0,
179221
+ paused: Number(result.paused) || 0,
179222
+ completed: Number(result.completed) || 0,
179223
+ failed: Number(result.failed) || 0,
179224
+ recurring: Number(result.recurring) || 0,
179225
+ oneTime: Number(result.one_time) || 0,
179226
+ };
179227
+ }
179228
+ async validateLimits(creatorId, isRecurring, limits) {
179229
+ const knex = this.getKnex();
179230
+ if (limits.maxGlobal) {
179231
+ const result = await knex('schedules').count('* as cnt').first();
179232
+ if (Number(result?.cnt) >= limits.maxGlobal) {
179233
+ throw new Error(`Global schedule limit reached (${limits.maxGlobal})`);
179234
+ }
179235
+ }
179236
+ if (limits.maxPerUser) {
179237
+ const result = await knex('schedules')
179238
+ .where('creator_id', creatorId)
179239
+ .count('* as cnt')
179240
+ .first();
179241
+ if (Number(result?.cnt) >= limits.maxPerUser) {
179242
+ throw new Error(`You have reached the maximum number of schedules (${limits.maxPerUser})`);
179243
+ }
179244
+ }
179245
+ if (isRecurring && limits.maxRecurringPerUser) {
179246
+ const bTrue = this.driver === 'mssql' ? 1 : true;
179247
+ const result = await knex('schedules')
179248
+ .where('creator_id', creatorId)
179249
+ .where('is_recurring', bTrue)
179250
+ .count('* as cnt')
179251
+ .first();
179252
+ if (Number(result?.cnt) >= limits.maxRecurringPerUser) {
179253
+ throw new Error(`You have reached the maximum number of recurring schedules (${limits.maxRecurringPerUser})`);
179254
+ }
179255
+ }
179256
+ }
179257
+ // --- HA Distributed Locking (via scheduler_locks table) ---
179258
+ async tryAcquireLock(lockId, nodeId, ttlSeconds) {
179259
+ const knex = this.getKnex();
179260
+ const now = Date.now();
179261
+ const expiresAt = now + ttlSeconds * 1000;
179262
+ const token = (0, uuid_1.v4)();
179263
+ // Step 1: Try to claim an existing expired lock
179264
+ const updated = await knex('scheduler_locks')
179265
+ .where('lock_id', lockId)
179266
+ .where('expires_at', '<', now)
179267
+ .update({
179268
+ node_id: nodeId,
179269
+ lock_token: token,
179270
+ acquired_at: now,
179271
+ expires_at: expiresAt,
179272
+ });
179273
+ if (updated > 0)
179274
+ return token;
179275
+ // Step 2: Try to INSERT a new lock row
179276
+ try {
179277
+ await knex('scheduler_locks').insert({
179278
+ lock_id: lockId,
179279
+ node_id: nodeId,
179280
+ lock_token: token,
179281
+ acquired_at: now,
179282
+ expires_at: expiresAt,
179283
+ });
179284
+ return token;
179285
+ }
179286
+ catch {
179287
+ // Unique constraint violation — another node holds the lock
179288
+ return null;
179289
+ }
179290
+ }
179291
+ async releaseLock(lockId, lockToken) {
179292
+ const knex = this.getKnex();
179293
+ await knex('scheduler_locks').where('lock_id', lockId).where('lock_token', lockToken).del();
179294
+ }
179295
+ async renewLock(lockId, lockToken, ttlSeconds) {
179296
+ const knex = this.getKnex();
179297
+ const now = Date.now();
179298
+ const expiresAt = now + ttlSeconds * 1000;
179299
+ const updated = await knex('scheduler_locks')
179300
+ .where('lock_id', lockId)
179301
+ .where('lock_token', lockToken)
179302
+ .update({ acquired_at: now, expires_at: expiresAt });
179303
+ return updated > 0;
179304
+ }
179305
+ async flush() {
179306
+ // No-op for server-based backends
179307
+ }
179308
+ // --- Message Trigger CRUD ---
179309
+ async createTrigger(trigger) {
179310
+ const knex = this.getKnex();
179311
+ const newTrigger = {
179312
+ ...trigger,
179313
+ id: (0, uuid_1.v4)(),
179314
+ createdAt: Date.now(),
179315
+ };
179316
+ await knex('message_triggers').insert(toTriggerInsertRow(newTrigger));
179317
+ logger_1.logger.info(`[KnexStore] Created trigger ${newTrigger.id} for user ${newTrigger.creatorId}`);
179318
+ return newTrigger;
179319
+ }
179320
+ async getTrigger(id) {
179321
+ const knex = this.getKnex();
179322
+ const row = await knex('message_triggers').where('id', id).first();
179323
+ return row ? fromTriggerRow(row) : undefined;
179324
+ }
179325
+ async updateTrigger(id, patch) {
179326
+ const knex = this.getKnex();
179327
+ const existing = await knex('message_triggers').where('id', id).first();
179328
+ if (!existing)
179329
+ return undefined;
179330
+ const current = fromTriggerRow(existing);
179331
+ const updated = {
179332
+ ...current,
179333
+ ...patch,
179334
+ id: current.id,
179335
+ createdAt: current.createdAt,
179336
+ };
179337
+ const row = toTriggerInsertRow(updated);
179338
+ delete row.id;
179339
+ await knex('message_triggers').where('id', id).update(row);
179340
+ return updated;
179341
+ }
179342
+ async deleteTrigger(id) {
179343
+ const knex = this.getKnex();
179344
+ const deleted = await knex('message_triggers').where('id', id).del();
179345
+ if (deleted > 0) {
179346
+ logger_1.logger.info(`[KnexStore] Deleted trigger ${id}`);
179347
+ return true;
179348
+ }
179349
+ return false;
179350
+ }
179351
+ async getTriggersByCreator(creatorId) {
179352
+ const knex = this.getKnex();
179353
+ const rows = await knex('message_triggers').where('creator_id', creatorId);
179354
+ return rows.map((r) => fromTriggerRow(r));
179355
+ }
179356
+ async getActiveTriggers() {
179357
+ const knex = this.getKnex();
179358
+ const rows = await knex('message_triggers')
179359
+ .where('status', 'active')
179360
+ .where('enabled', this.driver === 'mssql' ? 1 : true);
179361
+ return rows.map((r) => fromTriggerRow(r));
179362
+ }
179363
+ }
179364
+ exports.KnexStoreBackend = KnexStoreBackend;
179365
+
179366
+
177563
179367
  /***/ }),
177564
179368
 
177565
179369
  /***/ 83864:
@@ -188869,6 +190673,35 @@ class OutputFormatters {
188869
190673
  exports.OutputFormatters = OutputFormatters;
188870
190674
 
188871
190675
 
190676
+ /***/ }),
190677
+
190678
+ /***/ 93866:
190679
+ /***/ ((__unused_webpack_module, exports) => {
190680
+
190681
+ "use strict";
190682
+
190683
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
190684
+ exports.DefaultPolicyEngine = void 0;
190685
+ /**
190686
+ * Default (no-op) policy engine — always allows everything.
190687
+ * Used when no enterprise license is present or policy is disabled.
190688
+ */
190689
+ class DefaultPolicyEngine {
190690
+ async initialize(_config) { }
190691
+ async evaluateCheckExecution(_checkId, _checkConfig) {
190692
+ return { allowed: true };
190693
+ }
190694
+ async evaluateToolInvocation(_serverName, _methodName, _transport) {
190695
+ return { allowed: true };
190696
+ }
190697
+ async evaluateCapabilities(_checkId, _capabilities) {
190698
+ return { allowed: true };
190699
+ }
190700
+ async shutdown() { }
190701
+ }
190702
+ exports.DefaultPolicyEngine = DefaultPolicyEngine;
190703
+
190704
+
188872
190705
  /***/ }),
188873
190706
 
188874
190707
  /***/ 96611:
@@ -211567,7 +213400,7 @@ class StateMachineExecutionEngine {
211567
213400
  try {
211568
213401
  logger_1.logger.debug(`[PolicyEngine] Loading enterprise policy engine (engine=${configWithTagFilter.policy.engine})`);
211569
213402
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
211570
- const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(7065)));
213403
+ const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(87068)));
211571
213404
  context.policyEngine = await loadEnterprisePolicyEngine(configWithTagFilter.policy);
211572
213405
  logger_1.logger.debug(`[PolicyEngine] Initialized: ${context.policyEngine?.constructor?.name || 'unknown'}`);
211573
213406
  }
@@ -221878,7 +223711,7 @@ async function initTelemetry(opts = {}) {
221878
223711
  const path = __nccwpck_require__(16928);
221879
223712
  const outDir = opts.file?.dir ||
221880
223713
  process.env.VISOR_TRACE_DIR ||
221881
- __nccwpck_require__.ab + "traces";
223714
+ path.join(process.cwd(), 'output', 'traces');
221882
223715
  fs.mkdirSync(outDir, { recursive: true });
221883
223716
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
221884
223717
  process.env.VISOR_FALLBACK_TRACE_FILE = path.join(outDir, `run-${ts}.ndjson`);
@@ -222083,7 +223916,7 @@ async function shutdownTelemetry() {
222083
223916
  if (process.env.VISOR_TRACE_REPORT === 'true') {
222084
223917
  const fs = __nccwpck_require__(79896);
222085
223918
  const path = __nccwpck_require__(16928);
222086
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
223919
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
222087
223920
  if (!fs.existsSync(outDir))
222088
223921
  fs.mkdirSync(outDir, { recursive: true });
222089
223922
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
@@ -222582,7 +224415,7 @@ function __getOrCreateNdjsonPath() {
222582
224415
  fs.mkdirSync(dir, { recursive: true });
222583
224416
  return __ndjsonPath;
222584
224417
  }
222585
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
224418
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
222586
224419
  if (!fs.existsSync(outDir))
222587
224420
  fs.mkdirSync(outDir, { recursive: true });
222588
224421
  if (!__ndjsonPath) {
@@ -236960,22 +238793,6 @@ class WorkflowRegistry {
236960
238793
  exports.WorkflowRegistry = WorkflowRegistry;
236961
238794
 
236962
238795
 
236963
- /***/ }),
236964
-
236965
- /***/ 7065:
236966
- /***/ ((module) => {
236967
-
236968
- module.exports = eval("require")("./enterprise/loader");
236969
-
236970
-
236971
- /***/ }),
236972
-
236973
- /***/ 71370:
236974
- /***/ ((module) => {
236975
-
236976
- module.exports = eval("require")("./enterprise/policy/policy-input-builder");
236977
-
236978
-
236979
238796
  /***/ }),
236980
238797
 
236981
238798
  /***/ 18327:
@@ -398050,7 +399867,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"100":"Continue","101":"Switching Pro
398050
399867
  /***/ ((module) => {
398051
399868
 
398052
399869
  "use strict";
398053
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.169","main":"dist/index.js","bin":{"visor":"./dist/index.js"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"},"./sdk":{"types":"./dist/sdk/sdk.d.ts","import":"./dist/sdk/sdk.mjs","require":"./dist/sdk/sdk.js"},"./cli":{"require":"./dist/index.js"}},"files":["dist/","defaults/","action.yml","README.md","LICENSE"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build:cli":"ncc build src/index.ts -o dist && cp -r defaults dist/ && cp -r output dist/ && cp -r docs dist/ && cp -r examples dist/ && cp -r src/debug-visualizer/ui dist/debug-visualizer/ && node scripts/inject-version.js && echo \'#!/usr/bin/env node\' | cat - dist/index.js > temp && mv temp dist/index.js && chmod +x dist/index.js","build:sdk":"tsup src/sdk.ts --dts --sourcemap --format esm,cjs --out-dir dist/sdk","build":"./scripts/build-oss.sh","build:ee":"npm run build:cli && npm run build:sdk","test":"jest && npm run test:yaml","test:unit":"jest","prepublishOnly":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ee":"jest --testPathPatterns=\'tests/ee\' --testPathIgnorePatterns=\'/node_modules/\' --no-coverage","test:manual:bash":"RUN_MANUAL_TESTS=true jest tests/manual/bash-config-manual.test.ts","lint":"eslint src tests --ext .ts","lint:fix":"eslint src tests --ext .ts --fix","format":"prettier --write src tests","format:check":"prettier --check src tests","clean":"","clean:traces":"node scripts/clean-traces.js","prebuild":"npm run clean && node scripts/generate-config-schema.js","pretest":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","pretest:unit":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","test:with-build":"npm run build:cli && jest","test:yaml":"node dist/index.js test --progress compact","test:yaml:parallel":"node dist/index.js test --progress compact --max-parallel 4","prepare":"husky","pre-commit":"lint-staged","deploy:site":"cd site && npx wrangler pages deploy . --project-name=visor-site --commit-dirty=true","deploy:worker":"npx wrangler deploy","deploy":"npm run deploy:site && npm run deploy:worker","publish:ee":"./scripts/publish-ee.sh","release":"./scripts/release.sh","release:patch":"./scripts/release.sh patch","release:minor":"./scripts/release.sh minor","release:major":"./scripts/release.sh major","release:prerelease":"./scripts/release.sh prerelease","docs:validate":"node scripts/validate-readme-links.js","workshop:setup":"npm install -D reveal-md@6.1.2","workshop:serve":"cd workshop && reveal-md slides.md -w","workshop:export":"reveal-md workshop/slides.md --static workshop/build","workshop:pdf":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter","workshop:pdf:ci":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter --puppeteer-launch-args=\\"--no-sandbox --disable-dev-shm-usage\\"","workshop:pdf:a4":"reveal-md workshop/slides.md --print workshop/Visor-Workshop-A4.pdf --print-size A4","workshop:build":"npm run workshop:export && npm run workshop:pdf","simulate:issue":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issues --action opened --debug","simulate:comment":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issue_comment --action created --debug"},"keywords":["code-review","ai","github-action","cli","pr-review","visor"],"author":"Probe Labs","license":"MIT","description":"AI workflow engine for code review, assistants, and automation — orchestrate checks, MCP tools, and AI providers with YAML-driven pipelines","repository":{"type":"git","url":"git+https://github.com/probelabs/visor.git"},"bugs":{"url":"https://github.com/probelabs/visor/issues"},"homepage":"https://github.com/probelabs/visor#readme","dependencies":{"@actions/core":"^1.11.1","@apidevtools/swagger-parser":"^12.1.0","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#f1c13b8eee98734a8ea024061eada4aa9a9ff2e9","@octokit/action":"^8.0.2","@octokit/auth-app":"^8.1.0","@octokit/core":"^7.0.3","@octokit/rest":"^22.0.0","@opentelemetry/api":"^1.9.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-trace-otlp-grpc":"^0.203.0","@opentelemetry/exporter-trace-otlp-http":"^0.203.0","@opentelemetry/instrumentation":"^0.203.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.203.0","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/semantic-conventions":"^1.30.1","@probelabs/probe":"^0.6.0-rc286","@types/commander":"^2.12.0","@types/uuid":"^10.0.0","acorn":"^8.16.0","acorn-walk":"^8.3.5","ajv":"^8.17.1","ajv-formats":"^3.0.1","better-sqlite3":"^11.0.0","blessed":"^0.1.81","cli-table3":"^0.6.5","commander":"^14.0.0","deepmerge":"^4.3.1","dotenv":"^17.2.3","ignore":"^7.0.5","js-yaml":"^4.1.0","jsonpath-plus":"^10.4.0","liquidjs":"^10.21.1","minimatch":"^10.2.2","node-cron":"^3.0.3","open":"^9.1.0","simple-git":"^3.28.0","uuid":"^11.1.0","ws":"^8.18.3"},"optionalDependencies":{"@anthropic/claude-code-sdk":"npm:null@*","@open-policy-agent/opa-wasm":"^1.10.0","knex":"^3.1.0","mysql2":"^3.11.0","pg":"^8.13.0","tedious":"^19.0.0"},"devDependencies":{"@eslint/js":"^9.34.0","@kie/act-js":"^2.6.2","@kie/mock-github":"^2.0.1","@swc/core":"^1.13.2","@swc/jest":"^0.2.37","@types/better-sqlite3":"^7.6.0","@types/blessed":"^0.1.27","@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/node":"^24.3.0","@types/node-cron":"^3.0.11","@types/ws":"^8.18.1","@typescript-eslint/eslint-plugin":"^8.42.0","@typescript-eslint/parser":"^8.42.0","@vercel/ncc":"^0.38.4","eslint":"^9.34.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","husky":"^9.1.7","jest":"^30.1.3","lint-staged":"^16.1.6","prettier":"^3.6.2","reveal-md":"^6.1.2","ts-json-schema-generator":"^1.5.1","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.9.2","wrangler":"^3.0.0"},"peerDependenciesMeta":{"@anthropic/claude-code-sdk":{"optional":true}},"directories":{"test":"tests"},"lint-staged":{"src/**/*.{ts,js}":["eslint --fix","prettier --write"],"tests/**/*.{ts,js}":["eslint --fix","prettier --write"],"*.{json,md,yml,yaml}":["prettier --write"]}}');
399870
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.42","main":"dist/index.js","bin":{"visor":"./dist/index.js"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"},"./sdk":{"types":"./dist/sdk/sdk.d.ts","import":"./dist/sdk/sdk.mjs","require":"./dist/sdk/sdk.js"},"./cli":{"require":"./dist/index.js"}},"files":["dist/","defaults/","action.yml","README.md","LICENSE"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build:cli":"ncc build src/index.ts -o dist && cp -r defaults dist/ && cp -r output dist/ && cp -r docs dist/ && cp -r examples dist/ && cp -r src/debug-visualizer/ui dist/debug-visualizer/ && node scripts/inject-version.js && echo \'#!/usr/bin/env node\' | cat - dist/index.js > temp && mv temp dist/index.js && chmod +x dist/index.js","build:sdk":"tsup src/sdk.ts --dts --sourcemap --format esm,cjs --out-dir dist/sdk","build":"./scripts/build-oss.sh","build:ee":"npm run build:cli && npm run build:sdk","test":"jest && npm run test:yaml","test:unit":"jest","prepublishOnly":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ee":"jest --testPathPatterns=\'tests/ee\' --testPathIgnorePatterns=\'/node_modules/\' --no-coverage","test:manual:bash":"RUN_MANUAL_TESTS=true jest tests/manual/bash-config-manual.test.ts","lint":"eslint src tests --ext .ts","lint:fix":"eslint src tests --ext .ts --fix","format":"prettier --write src tests","format:check":"prettier --check src tests","clean":"","clean:traces":"node scripts/clean-traces.js","prebuild":"npm run clean && node scripts/generate-config-schema.js","pretest":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","pretest:unit":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","test:with-build":"npm run build:cli && jest","test:yaml":"node dist/index.js test --progress compact","test:yaml:parallel":"node dist/index.js test --progress compact --max-parallel 4","prepare":"husky","pre-commit":"lint-staged","deploy:site":"cd site && npx wrangler pages deploy . --project-name=visor-site --commit-dirty=true","deploy:worker":"npx wrangler deploy","deploy":"npm run deploy:site && npm run deploy:worker","publish:ee":"./scripts/publish-ee.sh","release":"./scripts/release.sh","release:patch":"./scripts/release.sh patch","release:minor":"./scripts/release.sh minor","release:major":"./scripts/release.sh major","release:prerelease":"./scripts/release.sh prerelease","docs:validate":"node scripts/validate-readme-links.js","workshop:setup":"npm install -D reveal-md@6.1.2","workshop:serve":"cd workshop && reveal-md slides.md -w","workshop:export":"reveal-md workshop/slides.md --static workshop/build","workshop:pdf":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter","workshop:pdf:ci":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter --puppeteer-launch-args=\\"--no-sandbox --disable-dev-shm-usage\\"","workshop:pdf:a4":"reveal-md workshop/slides.md --print workshop/Visor-Workshop-A4.pdf --print-size A4","workshop:build":"npm run workshop:export && npm run workshop:pdf","simulate:issue":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issues --action opened --debug","simulate:comment":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issue_comment --action created --debug"},"keywords":["code-review","ai","github-action","cli","pr-review","visor"],"author":"Probe Labs","license":"MIT","description":"AI workflow engine for code review, assistants, and automation — orchestrate checks, MCP tools, and AI providers with YAML-driven pipelines","repository":{"type":"git","url":"git+https://github.com/probelabs/visor.git"},"bugs":{"url":"https://github.com/probelabs/visor/issues"},"homepage":"https://github.com/probelabs/visor#readme","dependencies":{"@actions/core":"^1.11.1","@apidevtools/swagger-parser":"^12.1.0","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#f1c13b8eee98734a8ea024061eada4aa9a9ff2e9","@octokit/action":"^8.0.2","@octokit/auth-app":"^8.1.0","@octokit/core":"^7.0.3","@octokit/rest":"^22.0.0","@opentelemetry/api":"^1.9.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-trace-otlp-grpc":"^0.203.0","@opentelemetry/exporter-trace-otlp-http":"^0.203.0","@opentelemetry/instrumentation":"^0.203.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.203.0","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/semantic-conventions":"^1.30.1","@probelabs/probe":"^0.6.0-rc286","@types/commander":"^2.12.0","@types/uuid":"^10.0.0","acorn":"^8.16.0","acorn-walk":"^8.3.5","ajv":"^8.17.1","ajv-formats":"^3.0.1","better-sqlite3":"^11.0.0","blessed":"^0.1.81","cli-table3":"^0.6.5","commander":"^14.0.0","deepmerge":"^4.3.1","dotenv":"^17.2.3","ignore":"^7.0.5","js-yaml":"^4.1.0","jsonpath-plus":"^10.4.0","liquidjs":"^10.21.1","minimatch":"^10.2.2","node-cron":"^3.0.3","open":"^9.1.0","simple-git":"^3.28.0","uuid":"^11.1.0","ws":"^8.18.3"},"optionalDependencies":{"@anthropic/claude-code-sdk":"npm:null@*","@open-policy-agent/opa-wasm":"^1.10.0","knex":"^3.1.0","mysql2":"^3.11.0","pg":"^8.13.0","tedious":"^19.0.0"},"devDependencies":{"@eslint/js":"^9.34.0","@kie/act-js":"^2.6.2","@kie/mock-github":"^2.0.1","@swc/core":"^1.13.2","@swc/jest":"^0.2.37","@types/better-sqlite3":"^7.6.0","@types/blessed":"^0.1.27","@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/node":"^24.3.0","@types/node-cron":"^3.0.11","@types/ws":"^8.18.1","@typescript-eslint/eslint-plugin":"^8.42.0","@typescript-eslint/parser":"^8.42.0","@vercel/ncc":"^0.38.4","eslint":"^9.34.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","husky":"^9.1.7","jest":"^30.1.3","lint-staged":"^16.1.6","prettier":"^3.6.2","reveal-md":"^6.1.2","ts-json-schema-generator":"^1.5.1","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.9.2","wrangler":"^3.0.0"},"peerDependenciesMeta":{"@anthropic/claude-code-sdk":{"optional":true}},"directories":{"test":"tests"},"lint-staged":{"src/**/*.{ts,js}":["eslint --fix","prettier --write"],"tests/**/*.{ts,js}":["eslint --fix","prettier --write"],"*.{json,md,yml,yaml}":["prettier --write"]}}');
398054
399871
 
398055
399872
  /***/ })
398056
399873