@probelabs/visor 0.1.141 → 0.1.142-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 (70) hide show
  1. package/dist/ai-review-service.d.ts.map +1 -1
  2. package/dist/index.js +1739 -27
  3. package/dist/providers/api-tool-executor.d.ts.map +1 -1
  4. package/dist/sdk/{check-provider-registry-EDWTU5XK.mjs → check-provider-registry-MDJ7OQRY.mjs} +4 -3
  5. package/dist/sdk/{check-provider-registry-4XMVWKTZ.mjs → check-provider-registry-SNVE22YQ.mjs} +3 -2
  6. package/dist/sdk/{chunk-QVVTFU5C.mjs → chunk-CNNQTDJZ.mjs} +31 -13
  7. package/dist/sdk/chunk-CNNQTDJZ.mjs.map +1 -0
  8. package/dist/sdk/{chunk-IU2I3ING.mjs → chunk-KUSF5IBV.mjs} +26 -8
  9. package/dist/sdk/chunk-KUSF5IBV.mjs.map +1 -0
  10. package/dist/sdk/chunk-M3BYMES6.mjs +228 -0
  11. package/dist/sdk/chunk-M3BYMES6.mjs.map +1 -0
  12. package/dist/sdk/{host-YDQC5HZQ.mjs → host-7KYBK53Q.mjs} +2 -2
  13. package/dist/sdk/{host-K6OAB55Y.mjs → host-WEUEA7OZ.mjs} +3 -3
  14. package/dist/sdk/knex-store-HPXJILBL.mjs +411 -0
  15. package/dist/sdk/knex-store-HPXJILBL.mjs.map +1 -0
  16. package/dist/sdk/loader-ZC5G3JGJ.mjs +89 -0
  17. package/dist/sdk/loader-ZC5G3JGJ.mjs.map +1 -0
  18. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs +655 -0
  19. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs.map +1 -0
  20. package/dist/sdk/{schedule-tool-handler-TKSRMVOI.mjs → schedule-tool-handler-UCCJYJXR.mjs} +4 -3
  21. package/dist/sdk/{schedule-tool-handler-GVDCKW7K.mjs → schedule-tool-handler-XHNZW6UW.mjs} +3 -2
  22. package/dist/sdk/sdk.js +1900 -629
  23. package/dist/sdk/sdk.js.map +1 -1
  24. package/dist/sdk/sdk.mjs +6 -5
  25. package/dist/sdk/sdk.mjs.map +1 -1
  26. package/dist/sdk/{slack-frontend-JS2VAZWB.mjs → slack-frontend-TZU2HIK7.mjs} +10 -215
  27. package/dist/sdk/slack-frontend-TZU2HIK7.mjs.map +1 -0
  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-OJ3KFSVD.mjs → workflow-check-provider-HDX3ZABR.mjs} +4 -3
  31. package/dist/sdk/{workflow-check-provider-ZDO5KBUG.mjs → workflow-check-provider-INZUO2WJ.mjs} +3 -2
  32. package/dist/state-machine/dispatch/execution-invoker.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/output/traces/run-2026-02-24T17-23-44-977Z.ndjson +0 -138
  35. package/dist/output/traces/run-2026-02-24T17-24-30-825Z.ndjson +0 -1442
  36. package/dist/sdk/check-provider-registry-7MONMF3N.mjs +0 -29
  37. package/dist/sdk/chunk-6CPG4HY4.mjs +0 -40266
  38. package/dist/sdk/chunk-6CPG4HY4.mjs.map +0 -1
  39. package/dist/sdk/chunk-IKNTTTUL.mjs +0 -1502
  40. package/dist/sdk/chunk-IKNTTTUL.mjs.map +0 -1
  41. package/dist/sdk/chunk-IU2I3ING.mjs.map +0 -1
  42. package/dist/sdk/chunk-QVVTFU5C.mjs.map +0 -1
  43. package/dist/sdk/chunk-QY5YX76E.mjs +0 -739
  44. package/dist/sdk/chunk-QY5YX76E.mjs.map +0 -1
  45. package/dist/sdk/chunk-QZFB6JMV.mjs +0 -443
  46. package/dist/sdk/chunk-QZFB6JMV.mjs.map +0 -1
  47. package/dist/sdk/failure-condition-evaluator-ZLWJCR67.mjs +0 -17
  48. package/dist/sdk/github-frontend-4X3SDN6U.mjs +0 -1356
  49. package/dist/sdk/github-frontend-4X3SDN6U.mjs.map +0 -1
  50. package/dist/sdk/routing-HAYCJP2Y.mjs +0 -25
  51. package/dist/sdk/schedule-tool-handler-QCJXOK2M.mjs +0 -39
  52. package/dist/sdk/schedule-tool-handler-QCJXOK2M.mjs.map +0 -1
  53. package/dist/sdk/schedule-tool-handler-TKSRMVOI.mjs.map +0 -1
  54. package/dist/sdk/slack-frontend-JS2VAZWB.mjs.map +0 -1
  55. package/dist/sdk/trace-helpers-RLR6MUSK.mjs +0 -25
  56. package/dist/sdk/trace-helpers-RLR6MUSK.mjs.map +0 -1
  57. package/dist/sdk/workflow-check-provider-ABQXXMXS.mjs +0 -29
  58. package/dist/sdk/workflow-check-provider-ABQXXMXS.mjs.map +0 -1
  59. package/dist/sdk/workflow-check-provider-OJ3KFSVD.mjs.map +0 -1
  60. package/dist/sdk/workflow-check-provider-ZDO5KBUG.mjs.map +0 -1
  61. package/dist/traces/run-2026-02-24T17-23-44-977Z.ndjson +0 -138
  62. package/dist/traces/run-2026-02-24T17-24-30-825Z.ndjson +0 -1442
  63. /package/dist/sdk/{check-provider-registry-4XMVWKTZ.mjs.map → check-provider-registry-MDJ7OQRY.mjs.map} +0 -0
  64. /package/dist/sdk/{check-provider-registry-7MONMF3N.mjs.map → check-provider-registry-SNVE22YQ.mjs.map} +0 -0
  65. /package/dist/sdk/{host-K6OAB55Y.mjs.map → host-7KYBK53Q.mjs.map} +0 -0
  66. /package/dist/sdk/{host-YDQC5HZQ.mjs.map → host-WEUEA7OZ.mjs.map} +0 -0
  67. /package/dist/sdk/{check-provider-registry-EDWTU5XK.mjs.map → schedule-tool-handler-UCCJYJXR.mjs.map} +0 -0
  68. /package/dist/sdk/{failure-condition-evaluator-ZLWJCR67.mjs.map → schedule-tool-handler-XHNZW6UW.mjs.map} +0 -0
  69. /package/dist/sdk/{routing-HAYCJP2Y.mjs.map → workflow-check-provider-HDX3ZABR.mjs.map} +0 -0
  70. /package/dist/sdk/{schedule-tool-handler-GVDCKW7K.mjs.map → workflow-check-provider-INZUO2WJ.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.141';
2
+ process.env.VISOR_VERSION = '0.1.142';
3
3
  process.env.PROBE_VERSION = '0.6.0-rc257';
4
- process.env.VISOR_COMMIT_SHA = '0138f28a1353dfcdcb260661995ec69aa2b9981b';
5
- process.env.VISOR_COMMIT_SHORT = '0138f28';
4
+ process.env.VISOR_COMMIT_SHA = '6d05e17c93410e2c133426c4de8a0fa691baa79b';
5
+ process.env.VISOR_COMMIT_SHORT = '6d05e17';
6
6
  /******/ (() => { // webpackBootstrap
7
7
  /******/ var __webpack_modules__ = ({
8
8
 
@@ -158542,6 +158542,7 @@ const trace_helpers_1 = __nccwpck_require__(75338);
158542
158542
  const tracer_init_1 = __nccwpck_require__(11903);
158543
158543
  const diff_processor_1 = __nccwpck_require__(29883);
158544
158544
  const comment_metadata_1 = __nccwpck_require__(47284);
158545
+ const markdown_1 = __nccwpck_require__(34907);
158545
158546
  /**
158546
158547
  * Helper function to log debug messages using the centralized logger
158547
158548
  */
@@ -160728,6 +160729,18 @@ ${'='.repeat(60)}
160728
160729
  if (rawOutputBlocks.length > 0) {
160729
160730
  out._rawOutput = rawOutputBlocks.join('\n\n');
160730
160731
  }
160732
+ // Strip --- filename.ext --- delimited file sections from text when _rawOutput
160733
+ // already preserves them. The LLM may copy output() content into answer.text
160734
+ // despite it being captured via _outputBuffer → _rawOutput. Strip to avoid
160735
+ // duplication — frontends will render file sections from _rawOutput.
160736
+ if (typeof out.text === 'string' && typeof out._rawOutput === 'string') {
160737
+ const fileSections = (0, markdown_1.extractFileSections)(out.text);
160738
+ if (fileSections.length > 0) {
160739
+ const cleaned = (0, markdown_1.replaceFileSections)(out.text, fileSections, '').trim();
160740
+ log(`🧹 Stripped ${fileSections.length} file section(s) from text field (${out.text.length} → ${cleaned.length} chars) — content preserved in _rawOutput`);
160741
+ out.text = cleaned;
160742
+ }
160743
+ }
160731
160744
  const result = {
160732
160745
  // Keep issues empty for custom-schema rendering; consumers read from output.*
160733
160746
  issues: [],
@@ -161177,7 +161190,7 @@ async function handleDumpPolicyInput(checkId, argv) {
161177
161190
  let PolicyInputBuilder;
161178
161191
  try {
161179
161192
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
161180
- const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(71370)));
161193
+ const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(17117)));
161181
161194
  PolicyInputBuilder = mod.PolicyInputBuilder;
161182
161195
  }
161183
161196
  catch {
@@ -166967,6 +166980,1690 @@ class DependencyResolver {
166967
166980
  exports.DependencyResolver = DependencyResolver;
166968
166981
 
166969
166982
 
166983
+ /***/ }),
166984
+
166985
+ /***/ 50069:
166986
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
166987
+
166988
+ "use strict";
166989
+
166990
+ /**
166991
+ * Copyright (c) ProbeLabs. All rights reserved.
166992
+ * Licensed under the Elastic License 2.0; you may not use this file except
166993
+ * in compliance with the Elastic License 2.0.
166994
+ */
166995
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
166996
+ if (k2 === undefined) k2 = k;
166997
+ var desc = Object.getOwnPropertyDescriptor(m, k);
166998
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
166999
+ desc = { enumerable: true, get: function() { return m[k]; } };
167000
+ }
167001
+ Object.defineProperty(o, k2, desc);
167002
+ }) : (function(o, m, k, k2) {
167003
+ if (k2 === undefined) k2 = k;
167004
+ o[k2] = m[k];
167005
+ }));
167006
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167007
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167008
+ }) : function(o, v) {
167009
+ o["default"] = v;
167010
+ });
167011
+ var __importStar = (this && this.__importStar) || (function () {
167012
+ var ownKeys = function(o) {
167013
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167014
+ var ar = [];
167015
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167016
+ return ar;
167017
+ };
167018
+ return ownKeys(o);
167019
+ };
167020
+ return function (mod) {
167021
+ if (mod && mod.__esModule) return mod;
167022
+ var result = {};
167023
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167024
+ __setModuleDefault(result, mod);
167025
+ return result;
167026
+ };
167027
+ })();
167028
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167029
+ exports.LicenseValidator = void 0;
167030
+ const crypto = __importStar(__nccwpck_require__(76982));
167031
+ const fs = __importStar(__nccwpck_require__(79896));
167032
+ const path = __importStar(__nccwpck_require__(16928));
167033
+ class LicenseValidator {
167034
+ /** Ed25519 public key for license verification (PEM format). */
167035
+ static PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----\n' +
167036
+ 'MCowBQYDK2VwAyEAI/Zd08EFmgIdrDm/HXd0l3/5GBt7R1PrdvhdmEXhJlU=\n' +
167037
+ '-----END PUBLIC KEY-----\n';
167038
+ cache = null;
167039
+ static CACHE_TTL = 5 * 60 * 1000; // 5 minutes
167040
+ static GRACE_PERIOD = 72 * 3600 * 1000; // 72 hours after expiry
167041
+ /**
167042
+ * Load and validate license from environment or file.
167043
+ *
167044
+ * Resolution order:
167045
+ * 1. VISOR_LICENSE env var (JWT string)
167046
+ * 2. VISOR_LICENSE_FILE env var (path to file)
167047
+ * 3. .visor-license in project root (cwd)
167048
+ * 4. .visor-license in ~/.config/visor/
167049
+ */
167050
+ async loadAndValidate() {
167051
+ // Return cached result if still fresh
167052
+ if (this.cache && Date.now() - this.cache.validatedAt < LicenseValidator.CACHE_TTL) {
167053
+ return this.cache.payload;
167054
+ }
167055
+ const token = this.resolveToken();
167056
+ if (!token)
167057
+ return null;
167058
+ const payload = this.verifyAndDecode(token);
167059
+ if (!payload)
167060
+ return null;
167061
+ this.cache = { payload, validatedAt: Date.now() };
167062
+ return payload;
167063
+ }
167064
+ /** Check if a specific feature is licensed */
167065
+ hasFeature(feature) {
167066
+ if (!this.cache)
167067
+ return false;
167068
+ return this.cache.payload.features.includes(feature);
167069
+ }
167070
+ /** Check if license is valid (with grace period) */
167071
+ isValid() {
167072
+ if (!this.cache)
167073
+ return false;
167074
+ const now = Date.now();
167075
+ const expiryMs = this.cache.payload.exp * 1000;
167076
+ return now < expiryMs + LicenseValidator.GRACE_PERIOD;
167077
+ }
167078
+ /** Check if the license is within its grace period (expired but still valid) */
167079
+ isInGracePeriod() {
167080
+ if (!this.cache)
167081
+ return false;
167082
+ const now = Date.now();
167083
+ const expiryMs = this.cache.payload.exp * 1000;
167084
+ return now >= expiryMs && now < expiryMs + LicenseValidator.GRACE_PERIOD;
167085
+ }
167086
+ resolveToken() {
167087
+ // 1. Direct env var
167088
+ if (process.env.VISOR_LICENSE) {
167089
+ return process.env.VISOR_LICENSE.trim();
167090
+ }
167091
+ // 2. File path from env (validate against path traversal)
167092
+ if (process.env.VISOR_LICENSE_FILE) {
167093
+ // path.resolve() produces an absolute path with all '..' segments resolved,
167094
+ // so a separate resolved.includes('..') check is unnecessary.
167095
+ const resolved = path.resolve(process.env.VISOR_LICENSE_FILE);
167096
+ const home = process.env.HOME || process.env.USERPROFILE || '';
167097
+ const allowedPrefixes = [path.normalize(process.cwd())];
167098
+ if (home)
167099
+ allowedPrefixes.push(path.normalize(path.join(home, '.config', 'visor')));
167100
+ // Resolve symlinks so an attacker cannot create a symlink inside an
167101
+ // allowed prefix that points to an arbitrary file outside it.
167102
+ let realPath;
167103
+ try {
167104
+ realPath = fs.realpathSync(resolved);
167105
+ }
167106
+ catch {
167107
+ return null; // File doesn't exist or isn't accessible
167108
+ }
167109
+ const isSafe = allowedPrefixes.some(prefix => realPath === prefix || realPath.startsWith(prefix + path.sep));
167110
+ if (!isSafe)
167111
+ return null;
167112
+ return this.readFile(realPath);
167113
+ }
167114
+ // 3. .visor-license in cwd
167115
+ const cwdPath = path.join(process.cwd(), '.visor-license');
167116
+ const cwdToken = this.readFile(cwdPath);
167117
+ if (cwdToken)
167118
+ return cwdToken;
167119
+ // 4. ~/.config/visor/.visor-license
167120
+ const home = process.env.HOME || process.env.USERPROFILE || '';
167121
+ if (home) {
167122
+ const configPath = path.join(home, '.config', 'visor', '.visor-license');
167123
+ const configToken = this.readFile(configPath);
167124
+ if (configToken)
167125
+ return configToken;
167126
+ }
167127
+ return null;
167128
+ }
167129
+ readFile(filePath) {
167130
+ try {
167131
+ return fs.readFileSync(filePath, 'utf-8').trim();
167132
+ }
167133
+ catch {
167134
+ return null;
167135
+ }
167136
+ }
167137
+ verifyAndDecode(token) {
167138
+ try {
167139
+ const parts = token.split('.');
167140
+ if (parts.length !== 3)
167141
+ return null;
167142
+ const [headerB64, payloadB64, signatureB64] = parts;
167143
+ // Decode header to verify algorithm
167144
+ const header = JSON.parse(Buffer.from(headerB64, 'base64url').toString());
167145
+ if (header.alg !== 'EdDSA')
167146
+ return null;
167147
+ // Verify signature
167148
+ const data = `${headerB64}.${payloadB64}`;
167149
+ const signature = Buffer.from(signatureB64, 'base64url');
167150
+ const publicKey = crypto.createPublicKey(LicenseValidator.PUBLIC_KEY);
167151
+ // Validate that the loaded public key is actually Ed25519 (OID 1.3.101.112).
167152
+ // This prevents algorithm-confusion attacks if the embedded key were ever
167153
+ // swapped to a different type.
167154
+ if (publicKey.asymmetricKeyType !== 'ed25519') {
167155
+ return null;
167156
+ }
167157
+ // Ed25519 verification: algorithm must be null because EdDSA performs its
167158
+ // own internal hashing (SHA-512) — passing a digest algorithm here would
167159
+ // cause Node.js to throw. The key type is validated above.
167160
+ const isValid = crypto.verify(null, Buffer.from(data), publicKey, signature);
167161
+ if (!isValid)
167162
+ return null;
167163
+ // Decode payload
167164
+ const payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString());
167165
+ // Validate required fields
167166
+ if (!payload.org ||
167167
+ !Array.isArray(payload.features) ||
167168
+ typeof payload.exp !== 'number' ||
167169
+ typeof payload.iat !== 'number' ||
167170
+ !payload.sub) {
167171
+ return null;
167172
+ }
167173
+ // Check expiry (with grace period)
167174
+ const now = Date.now();
167175
+ const expiryMs = payload.exp * 1000;
167176
+ if (now >= expiryMs + LicenseValidator.GRACE_PERIOD) {
167177
+ return null;
167178
+ }
167179
+ return payload;
167180
+ }
167181
+ catch {
167182
+ return null;
167183
+ }
167184
+ }
167185
+ }
167186
+ exports.LicenseValidator = LicenseValidator;
167187
+
167188
+
167189
+ /***/ }),
167190
+
167191
+ /***/ 87068:
167192
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167193
+
167194
+ "use strict";
167195
+
167196
+ /**
167197
+ * Copyright (c) ProbeLabs. All rights reserved.
167198
+ * Licensed under the Elastic License 2.0; you may not use this file except
167199
+ * in compliance with the Elastic License 2.0.
167200
+ */
167201
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167202
+ if (k2 === undefined) k2 = k;
167203
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167204
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167205
+ desc = { enumerable: true, get: function() { return m[k]; } };
167206
+ }
167207
+ Object.defineProperty(o, k2, desc);
167208
+ }) : (function(o, m, k, k2) {
167209
+ if (k2 === undefined) k2 = k;
167210
+ o[k2] = m[k];
167211
+ }));
167212
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167213
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167214
+ }) : function(o, v) {
167215
+ o["default"] = v;
167216
+ });
167217
+ var __importStar = (this && this.__importStar) || (function () {
167218
+ var ownKeys = function(o) {
167219
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167220
+ var ar = [];
167221
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167222
+ return ar;
167223
+ };
167224
+ return ownKeys(o);
167225
+ };
167226
+ return function (mod) {
167227
+ if (mod && mod.__esModule) return mod;
167228
+ var result = {};
167229
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167230
+ __setModuleDefault(result, mod);
167231
+ return result;
167232
+ };
167233
+ })();
167234
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167235
+ exports.loadEnterprisePolicyEngine = loadEnterprisePolicyEngine;
167236
+ exports.loadEnterpriseStoreBackend = loadEnterpriseStoreBackend;
167237
+ const default_engine_1 = __nccwpck_require__(93866);
167238
+ /**
167239
+ * Load the enterprise policy engine if licensed, otherwise return the default no-op engine.
167240
+ *
167241
+ * This is the sole import boundary between OSS and enterprise code. Core code
167242
+ * must only import from this module (via dynamic `await import()`), never from
167243
+ * individual enterprise submodules.
167244
+ */
167245
+ async function loadEnterprisePolicyEngine(config) {
167246
+ try {
167247
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167248
+ const validator = new LicenseValidator();
167249
+ const license = await validator.loadAndValidate();
167250
+ if (!license || !validator.hasFeature('policy')) {
167251
+ return new default_engine_1.DefaultPolicyEngine();
167252
+ }
167253
+ if (validator.isInGracePeriod()) {
167254
+ // eslint-disable-next-line no-console
167255
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167256
+ 'Please renew your license.');
167257
+ }
167258
+ const { OpaPolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(39530)));
167259
+ const engine = new OpaPolicyEngine(config);
167260
+ await engine.initialize(config);
167261
+ return engine;
167262
+ }
167263
+ catch (err) {
167264
+ // Enterprise code not available or initialization failed
167265
+ const msg = err instanceof Error ? err.message : String(err);
167266
+ try {
167267
+ const { logger } = __nccwpck_require__(86999);
167268
+ logger.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
167269
+ }
167270
+ catch {
167271
+ // silent
167272
+ }
167273
+ return new default_engine_1.DefaultPolicyEngine();
167274
+ }
167275
+ }
167276
+ /**
167277
+ * Load the enterprise schedule store backend if licensed.
167278
+ *
167279
+ * @param driver Database driver ('postgresql', 'mysql', or 'mssql')
167280
+ * @param storageConfig Storage configuration with connection details
167281
+ * @param haConfig Optional HA configuration
167282
+ * @throws Error if enterprise license is not available or missing 'scheduler-sql' feature
167283
+ */
167284
+ async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
167285
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167286
+ const validator = new LicenseValidator();
167287
+ const license = await validator.loadAndValidate();
167288
+ if (!license || !validator.hasFeature('scheduler-sql')) {
167289
+ throw new Error(`The ${driver} schedule storage driver requires a Visor Enterprise license ` +
167290
+ `with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`);
167291
+ }
167292
+ if (validator.isInGracePeriod()) {
167293
+ // eslint-disable-next-line no-console
167294
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167295
+ 'Please renew your license.');
167296
+ }
167297
+ const { KnexStoreBackend } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(63737)));
167298
+ return new KnexStoreBackend(driver, storageConfig, haConfig);
167299
+ }
167300
+
167301
+
167302
+ /***/ }),
167303
+
167304
+ /***/ 628:
167305
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167306
+
167307
+ "use strict";
167308
+
167309
+ /**
167310
+ * Copyright (c) ProbeLabs. All rights reserved.
167311
+ * Licensed under the Elastic License 2.0; you may not use this file except
167312
+ * in compliance with the Elastic License 2.0.
167313
+ */
167314
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167315
+ if (k2 === undefined) k2 = k;
167316
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167317
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167318
+ desc = { enumerable: true, get: function() { return m[k]; } };
167319
+ }
167320
+ Object.defineProperty(o, k2, desc);
167321
+ }) : (function(o, m, k, k2) {
167322
+ if (k2 === undefined) k2 = k;
167323
+ o[k2] = m[k];
167324
+ }));
167325
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167326
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167327
+ }) : function(o, v) {
167328
+ o["default"] = v;
167329
+ });
167330
+ var __importStar = (this && this.__importStar) || (function () {
167331
+ var ownKeys = function(o) {
167332
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167333
+ var ar = [];
167334
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167335
+ return ar;
167336
+ };
167337
+ return ownKeys(o);
167338
+ };
167339
+ return function (mod) {
167340
+ if (mod && mod.__esModule) return mod;
167341
+ var result = {};
167342
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167343
+ __setModuleDefault(result, mod);
167344
+ return result;
167345
+ };
167346
+ })();
167347
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167348
+ exports.OpaCompiler = void 0;
167349
+ const fs = __importStar(__nccwpck_require__(79896));
167350
+ const path = __importStar(__nccwpck_require__(16928));
167351
+ const os = __importStar(__nccwpck_require__(70857));
167352
+ const crypto = __importStar(__nccwpck_require__(76982));
167353
+ const child_process_1 = __nccwpck_require__(35317);
167354
+ /**
167355
+ * OPA Rego Compiler - compiles .rego policy files to WASM bundles using the `opa` CLI.
167356
+ *
167357
+ * Handles:
167358
+ * - Resolving input paths to WASM bytes (direct .wasm, directory with policy.wasm, or .rego files)
167359
+ * - Compiling .rego files to WASM via `opa build`
167360
+ * - Caching compiled bundles based on content hashes
167361
+ * - Extracting policy.wasm from OPA tar.gz bundles
167362
+ *
167363
+ * Requires:
167364
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
167365
+ */
167366
+ class OpaCompiler {
167367
+ static CACHE_DIR = path.join(os.tmpdir(), 'visor-opa-cache');
167368
+ /**
167369
+ * Resolve the input paths to WASM bytes.
167370
+ *
167371
+ * Strategy:
167372
+ * 1. If any path is a .wasm file, read it directly
167373
+ * 2. If a directory contains policy.wasm, read it
167374
+ * 3. Otherwise, collect all .rego files and auto-compile via `opa build`
167375
+ */
167376
+ async resolveWasmBytes(paths) {
167377
+ // Collect .rego files and check for existing .wasm
167378
+ const regoFiles = [];
167379
+ for (const p of paths) {
167380
+ const resolved = path.resolve(p);
167381
+ // Reject paths containing '..' after resolution (path traversal)
167382
+ if (path.normalize(resolved).includes('..')) {
167383
+ throw new Error(`Policy path contains traversal sequences: ${p}`);
167384
+ }
167385
+ // Direct .wasm file
167386
+ if (resolved.endsWith('.wasm') && fs.existsSync(resolved)) {
167387
+ return fs.readFileSync(resolved);
167388
+ }
167389
+ if (!fs.existsSync(resolved))
167390
+ continue;
167391
+ const stat = fs.statSync(resolved);
167392
+ if (stat.isDirectory()) {
167393
+ // Check for pre-compiled policy.wasm in directory
167394
+ const wasmCandidate = path.join(resolved, 'policy.wasm');
167395
+ if (fs.existsSync(wasmCandidate)) {
167396
+ return fs.readFileSync(wasmCandidate);
167397
+ }
167398
+ // Collect all .rego files from directory
167399
+ const files = fs.readdirSync(resolved);
167400
+ for (const f of files) {
167401
+ if (f.endsWith('.rego')) {
167402
+ regoFiles.push(path.join(resolved, f));
167403
+ }
167404
+ }
167405
+ }
167406
+ else if (resolved.endsWith('.rego')) {
167407
+ regoFiles.push(resolved);
167408
+ }
167409
+ }
167410
+ if (regoFiles.length === 0) {
167411
+ throw new Error(`OPA WASM evaluator: no .wasm bundle or .rego files found in: ${paths.join(', ')}`);
167412
+ }
167413
+ // Auto-compile .rego -> .wasm
167414
+ return this.compileRego(regoFiles);
167415
+ }
167416
+ /**
167417
+ * Auto-compile .rego files to a WASM bundle using the `opa` CLI.
167418
+ *
167419
+ * Caches the compiled bundle based on a content hash of all input .rego files
167420
+ * so subsequent runs skip compilation if policies haven't changed.
167421
+ */
167422
+ compileRego(regoFiles) {
167423
+ // Check that `opa` CLI is available
167424
+ try {
167425
+ (0, child_process_1.execFileSync)('opa', ['version'], { stdio: 'pipe' });
167426
+ }
167427
+ catch {
167428
+ throw new Error('OPA CLI (`opa`) not found on PATH. Install it from https://www.openpolicyagent.org/docs/latest/#running-opa\n' +
167429
+ 'Or pre-compile your .rego files: opa build -t wasm -e visor -o bundle.tar.gz ' +
167430
+ regoFiles.join(' '));
167431
+ }
167432
+ // Compute content hash for cache key
167433
+ const hash = crypto.createHash('sha256');
167434
+ for (const f of regoFiles.sort()) {
167435
+ hash.update(fs.readFileSync(f));
167436
+ hash.update(f); // include filename for disambiguation
167437
+ }
167438
+ const cacheKey = hash.digest('hex').slice(0, 16);
167439
+ const cacheDir = OpaCompiler.CACHE_DIR;
167440
+ const cachedWasm = path.join(cacheDir, `${cacheKey}.wasm`);
167441
+ // Return cached bundle if still valid
167442
+ if (fs.existsSync(cachedWasm)) {
167443
+ return fs.readFileSync(cachedWasm);
167444
+ }
167445
+ // Compile to WASM via opa build
167446
+ fs.mkdirSync(cacheDir, { recursive: true });
167447
+ const bundleTar = path.join(cacheDir, `${cacheKey}-bundle.tar.gz`);
167448
+ try {
167449
+ const args = [
167450
+ 'build',
167451
+ '-t',
167452
+ 'wasm',
167453
+ '-e',
167454
+ 'visor', // entrypoint: the visor package tree
167455
+ '-o',
167456
+ bundleTar,
167457
+ ...regoFiles,
167458
+ ];
167459
+ (0, child_process_1.execFileSync)('opa', args, {
167460
+ stdio: 'pipe',
167461
+ timeout: 30000,
167462
+ });
167463
+ }
167464
+ catch (err) {
167465
+ const stderr = err?.stderr?.toString() || '';
167466
+ throw new Error(`Failed to compile .rego files to WASM:\n${stderr}\n` +
167467
+ 'Ensure your .rego files are valid and the `opa` CLI is installed.');
167468
+ }
167469
+ // Extract policy.wasm from the tar.gz bundle
167470
+ // OPA bundles are tar.gz with /policy.wasm inside
167471
+ try {
167472
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, '/policy.wasm'], {
167473
+ stdio: 'pipe',
167474
+ });
167475
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
167476
+ if (fs.existsSync(extractedWasm)) {
167477
+ // Move to cache-key named file
167478
+ fs.renameSync(extractedWasm, cachedWasm);
167479
+ }
167480
+ }
167481
+ catch {
167482
+ // Some tar implementations don't like leading /
167483
+ try {
167484
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, 'policy.wasm'], {
167485
+ stdio: 'pipe',
167486
+ });
167487
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
167488
+ if (fs.existsSync(extractedWasm)) {
167489
+ fs.renameSync(extractedWasm, cachedWasm);
167490
+ }
167491
+ }
167492
+ catch (err2) {
167493
+ throw new Error(`Failed to extract policy.wasm from OPA bundle: ${err2?.message || err2}`);
167494
+ }
167495
+ }
167496
+ // Clean up tar
167497
+ try {
167498
+ fs.unlinkSync(bundleTar);
167499
+ }
167500
+ catch { }
167501
+ if (!fs.existsSync(cachedWasm)) {
167502
+ throw new Error('OPA build succeeded but policy.wasm was not found in the bundle');
167503
+ }
167504
+ return fs.readFileSync(cachedWasm);
167505
+ }
167506
+ }
167507
+ exports.OpaCompiler = OpaCompiler;
167508
+
167509
+
167510
+ /***/ }),
167511
+
167512
+ /***/ 44693:
167513
+ /***/ ((__unused_webpack_module, exports) => {
167514
+
167515
+ "use strict";
167516
+
167517
+ /**
167518
+ * Copyright (c) ProbeLabs. All rights reserved.
167519
+ * Licensed under the Elastic License 2.0; you may not use this file except
167520
+ * in compliance with the Elastic License 2.0.
167521
+ */
167522
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167523
+ exports.OpaHttpEvaluator = void 0;
167524
+ /**
167525
+ * OPA HTTP Evaluator - evaluates policies via an external OPA server's REST API.
167526
+ *
167527
+ * Uses the built-in `fetch` API (Node 18+), so no extra dependencies are needed.
167528
+ */
167529
+ class OpaHttpEvaluator {
167530
+ baseUrl;
167531
+ timeout;
167532
+ constructor(baseUrl, timeout = 5000) {
167533
+ // Validate URL format and protocol
167534
+ let parsed;
167535
+ try {
167536
+ parsed = new URL(baseUrl);
167537
+ }
167538
+ catch {
167539
+ throw new Error(`OPA HTTP evaluator: invalid URL: ${baseUrl}`);
167540
+ }
167541
+ if (!['http:', 'https:'].includes(parsed.protocol)) {
167542
+ throw new Error(`OPA HTTP evaluator: url must use http:// or https:// protocol, got: ${baseUrl}`);
167543
+ }
167544
+ // Block cloud metadata, loopback, link-local, and private network addresses
167545
+ const hostname = parsed.hostname;
167546
+ if (this.isBlockedHostname(hostname)) {
167547
+ throw new Error(`OPA HTTP evaluator: url must not point to internal, loopback, or private network addresses`);
167548
+ }
167549
+ // Normalize: strip trailing slash
167550
+ this.baseUrl = baseUrl.replace(/\/+$/, '');
167551
+ this.timeout = timeout;
167552
+ }
167553
+ /**
167554
+ * Check if a hostname is blocked due to SSRF concerns.
167555
+ *
167556
+ * Blocks:
167557
+ * - Loopback addresses (127.x.x.x, localhost, 0.0.0.0, ::1)
167558
+ * - Link-local addresses (169.254.x.x)
167559
+ * - Private networks (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
167560
+ * - IPv6 unique local addresses (fd00::/8)
167561
+ * - Cloud metadata services (*.internal)
167562
+ */
167563
+ isBlockedHostname(hostname) {
167564
+ if (!hostname)
167565
+ return true; // block empty hostnames
167566
+ // Normalize hostname: lowercase and remove brackets for IPv6
167567
+ const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
167568
+ // Block .internal domains (cloud metadata services)
167569
+ if (normalized === 'metadata.google.internal' || normalized.endsWith('.internal')) {
167570
+ return true;
167571
+ }
167572
+ // Block localhost variants
167573
+ if (normalized === 'localhost' || normalized === 'localhost.localdomain') {
167574
+ return true;
167575
+ }
167576
+ // Block IPv6 loopback
167577
+ if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
167578
+ return true;
167579
+ }
167580
+ // Check IPv4 patterns
167581
+ const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
167582
+ const ipv4Match = normalized.match(ipv4Pattern);
167583
+ if (ipv4Match) {
167584
+ const octets = ipv4Match.slice(1, 5).map(Number);
167585
+ // Validate octets are in range [0, 255]
167586
+ if (octets.some(octet => octet > 255)) {
167587
+ return false;
167588
+ }
167589
+ const [a, b] = octets;
167590
+ // Block loopback: 127.0.0.0/8
167591
+ if (a === 127) {
167592
+ return true;
167593
+ }
167594
+ // Block 0.0.0.0/8 (this host)
167595
+ if (a === 0) {
167596
+ return true;
167597
+ }
167598
+ // Block link-local: 169.254.0.0/16
167599
+ if (a === 169 && b === 254) {
167600
+ return true;
167601
+ }
167602
+ // Block private networks
167603
+ // 10.0.0.0/8
167604
+ if (a === 10) {
167605
+ return true;
167606
+ }
167607
+ // 172.16.0.0/12 (172.16.x.x through 172.31.x.x)
167608
+ if (a === 172 && b >= 16 && b <= 31) {
167609
+ return true;
167610
+ }
167611
+ // 192.168.0.0/16
167612
+ if (a === 192 && b === 168) {
167613
+ return true;
167614
+ }
167615
+ }
167616
+ // Check IPv6 patterns
167617
+ // Block unique local addresses: fd00::/8
167618
+ if (normalized.startsWith('fd') || normalized.startsWith('fc')) {
167619
+ return true;
167620
+ }
167621
+ // Block link-local: fe80::/10
167622
+ if (normalized.startsWith('fe80:')) {
167623
+ return true;
167624
+ }
167625
+ return false;
167626
+ }
167627
+ /**
167628
+ * Evaluate a policy rule against an input document via OPA REST API.
167629
+ *
167630
+ * @param input - The input document to evaluate
167631
+ * @param rulePath - OPA rule path (e.g., 'visor/check/execute')
167632
+ * @returns The result object from OPA, or undefined on error
167633
+ */
167634
+ async evaluate(input, rulePath) {
167635
+ // OPA Data API: POST /v1/data/<path>
167636
+ const encodedPath = rulePath
167637
+ .split('/')
167638
+ .map(s => encodeURIComponent(s))
167639
+ .join('/');
167640
+ const url = `${this.baseUrl}/v1/data/${encodedPath}`;
167641
+ const controller = new AbortController();
167642
+ const timer = setTimeout(() => controller.abort(), this.timeout);
167643
+ try {
167644
+ const response = await fetch(url, {
167645
+ method: 'POST',
167646
+ headers: { 'Content-Type': 'application/json' },
167647
+ body: JSON.stringify({ input }),
167648
+ signal: controller.signal,
167649
+ });
167650
+ if (!response.ok) {
167651
+ throw new Error(`OPA HTTP ${response.status}: ${response.statusText}`);
167652
+ }
167653
+ let body;
167654
+ try {
167655
+ body = await response.json();
167656
+ }
167657
+ catch (jsonErr) {
167658
+ throw new Error(`OPA HTTP evaluator: failed to parse JSON response: ${jsonErr instanceof Error ? jsonErr.message : String(jsonErr)}`);
167659
+ }
167660
+ // OPA returns { result: { ... } }
167661
+ return body?.result;
167662
+ }
167663
+ finally {
167664
+ clearTimeout(timer);
167665
+ }
167666
+ }
167667
+ async shutdown() {
167668
+ // No persistent connections to close
167669
+ }
167670
+ }
167671
+ exports.OpaHttpEvaluator = OpaHttpEvaluator;
167672
+
167673
+
167674
+ /***/ }),
167675
+
167676
+ /***/ 39530:
167677
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
167678
+
167679
+ "use strict";
167680
+
167681
+ /**
167682
+ * Copyright (c) ProbeLabs. All rights reserved.
167683
+ * Licensed under the Elastic License 2.0; you may not use this file except
167684
+ * in compliance with the Elastic License 2.0.
167685
+ */
167686
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167687
+ exports.OpaPolicyEngine = void 0;
167688
+ const opa_wasm_evaluator_1 = __nccwpck_require__(8613);
167689
+ const opa_http_evaluator_1 = __nccwpck_require__(44693);
167690
+ const policy_input_builder_1 = __nccwpck_require__(17117);
167691
+ /**
167692
+ * Enterprise OPA Policy Engine.
167693
+ *
167694
+ * Wraps both WASM (local) and HTTP (remote) OPA evaluators behind the
167695
+ * OSS PolicyEngine interface. All OPA input building and role resolution
167696
+ * is handled internally — the OSS call sites pass only plain types.
167697
+ */
167698
+ class OpaPolicyEngine {
167699
+ evaluator = null;
167700
+ fallback;
167701
+ timeout;
167702
+ config;
167703
+ inputBuilder = null;
167704
+ logger = null;
167705
+ constructor(config) {
167706
+ this.config = config;
167707
+ this.fallback = config.fallback || 'deny';
167708
+ this.timeout = config.timeout || 5000;
167709
+ }
167710
+ async initialize(config) {
167711
+ // Resolve logger once at initialization
167712
+ try {
167713
+ this.logger = (__nccwpck_require__(86999).logger);
167714
+ }
167715
+ catch {
167716
+ // logger not available in this context
167717
+ }
167718
+ // Build actor/repo context from environment (available at engine init time)
167719
+ const actor = {
167720
+ authorAssociation: process.env.VISOR_AUTHOR_ASSOCIATION,
167721
+ login: process.env.VISOR_AUTHOR_LOGIN || process.env.GITHUB_ACTOR,
167722
+ isLocalMode: !process.env.GITHUB_ACTIONS,
167723
+ };
167724
+ const repo = {
167725
+ owner: process.env.GITHUB_REPOSITORY_OWNER,
167726
+ name: process.env.GITHUB_REPOSITORY?.split('/')[1],
167727
+ branch: process.env.GITHUB_HEAD_REF,
167728
+ baseBranch: process.env.GITHUB_BASE_REF,
167729
+ event: process.env.GITHUB_EVENT_NAME,
167730
+ };
167731
+ const prNum = process.env.GITHUB_PR_NUMBER
167732
+ ? parseInt(process.env.GITHUB_PR_NUMBER, 10)
167733
+ : undefined;
167734
+ const pullRequest = {
167735
+ number: prNum !== undefined && Number.isFinite(prNum) ? prNum : undefined,
167736
+ };
167737
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(config, actor, repo, pullRequest);
167738
+ if (config.engine === 'local') {
167739
+ if (!config.rules) {
167740
+ throw new Error('OPA local mode requires `policy.rules` path to .wasm or .rego files');
167741
+ }
167742
+ const wasm = new opa_wasm_evaluator_1.OpaWasmEvaluator();
167743
+ await wasm.initialize(config.rules);
167744
+ if (config.data) {
167745
+ wasm.loadData(config.data);
167746
+ }
167747
+ this.evaluator = wasm;
167748
+ }
167749
+ else if (config.engine === 'remote') {
167750
+ if (!config.url) {
167751
+ throw new Error('OPA remote mode requires `policy.url` pointing to OPA server');
167752
+ }
167753
+ this.evaluator = new opa_http_evaluator_1.OpaHttpEvaluator(config.url, this.timeout);
167754
+ }
167755
+ else {
167756
+ this.evaluator = null;
167757
+ }
167758
+ }
167759
+ /**
167760
+ * Update actor/repo/PR context (e.g., after PR info becomes available).
167761
+ * Called by the enterprise loader when engine context is enriched.
167762
+ */
167763
+ setActorContext(actor, repo, pullRequest) {
167764
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(this.config, actor, repo, pullRequest);
167765
+ }
167766
+ async evaluateCheckExecution(checkId, checkConfig) {
167767
+ if (!this.evaluator || !this.inputBuilder)
167768
+ return { allowed: true };
167769
+ const cfg = checkConfig && typeof checkConfig === 'object'
167770
+ ? checkConfig
167771
+ : {};
167772
+ const policyOverride = cfg.policy;
167773
+ const input = this.inputBuilder.forCheckExecution({
167774
+ id: checkId,
167775
+ type: cfg.type || 'ai',
167776
+ group: cfg.group,
167777
+ tags: cfg.tags,
167778
+ criticality: cfg.criticality,
167779
+ sandbox: cfg.sandbox,
167780
+ policy: policyOverride,
167781
+ });
167782
+ return this.doEvaluate(input, this.resolveRulePath('check.execute', policyOverride?.rule));
167783
+ }
167784
+ async evaluateToolInvocation(serverName, methodName, transport) {
167785
+ if (!this.evaluator || !this.inputBuilder)
167786
+ return { allowed: true };
167787
+ const input = this.inputBuilder.forToolInvocation(serverName, methodName, transport);
167788
+ return this.doEvaluate(input, 'visor/tool/invoke');
167789
+ }
167790
+ async evaluateCapabilities(checkId, capabilities) {
167791
+ if (!this.evaluator || !this.inputBuilder)
167792
+ return { allowed: true };
167793
+ const input = this.inputBuilder.forCapabilityResolve(checkId, capabilities);
167794
+ return this.doEvaluate(input, 'visor/capability/resolve');
167795
+ }
167796
+ async shutdown() {
167797
+ if (this.evaluator && 'shutdown' in this.evaluator) {
167798
+ await this.evaluator.shutdown();
167799
+ }
167800
+ this.evaluator = null;
167801
+ this.inputBuilder = null;
167802
+ }
167803
+ resolveRulePath(defaultScope, override) {
167804
+ if (override) {
167805
+ return override.startsWith('visor/') ? override : `visor/${override}`;
167806
+ }
167807
+ return `visor/${defaultScope.replace(/\./g, '/')}`;
167808
+ }
167809
+ async doEvaluate(input, rulePath) {
167810
+ try {
167811
+ this.logger?.debug(`[PolicyEngine] Evaluating ${rulePath}`, JSON.stringify(input));
167812
+ let timer;
167813
+ const timeoutPromise = new Promise((_resolve, reject) => {
167814
+ timer = setTimeout(() => reject(new Error('policy evaluation timeout')), this.timeout);
167815
+ });
167816
+ try {
167817
+ const result = await Promise.race([this.rawEvaluate(input, rulePath), timeoutPromise]);
167818
+ const decision = this.parseDecision(result);
167819
+ // In warn mode, override denied decisions to allowed but flag as warn
167820
+ if (!decision.allowed && this.fallback === 'warn') {
167821
+ decision.allowed = true;
167822
+ decision.warn = true;
167823
+ decision.reason = `audit: ${decision.reason || 'policy denied'}`;
167824
+ }
167825
+ this.logger?.debug(`[PolicyEngine] Decision for ${rulePath}: allowed=${decision.allowed}, warn=${decision.warn || false}, reason=${decision.reason || 'none'}`);
167826
+ return decision;
167827
+ }
167828
+ finally {
167829
+ if (timer)
167830
+ clearTimeout(timer);
167831
+ }
167832
+ }
167833
+ catch (err) {
167834
+ const msg = err instanceof Error ? err.message : String(err);
167835
+ this.logger?.warn(`[PolicyEngine] Evaluation failed for ${rulePath}: ${msg}`);
167836
+ return {
167837
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
167838
+ warn: this.fallback === 'warn' ? true : undefined,
167839
+ reason: `policy evaluation failed, fallback=${this.fallback}`,
167840
+ };
167841
+ }
167842
+ }
167843
+ async rawEvaluate(input, rulePath) {
167844
+ if (this.evaluator instanceof opa_wasm_evaluator_1.OpaWasmEvaluator) {
167845
+ const result = await this.evaluator.evaluate(input);
167846
+ // WASM compiled with `-e visor` entrypoint returns the full visor package tree.
167847
+ // Navigate to the specific rule subtree using rulePath segments.
167848
+ // e.g., 'visor/check/execute' → result.check.execute
167849
+ return this.navigateWasmResult(result, rulePath);
167850
+ }
167851
+ return this.evaluator.evaluate(input, rulePath);
167852
+ }
167853
+ /**
167854
+ * Navigate nested OPA WASM result tree to reach the specific rule's output.
167855
+ * The WASM entrypoint `-e visor` means the result root IS the visor package,
167856
+ * so we strip the `visor/` prefix and walk the remaining segments.
167857
+ */
167858
+ navigateWasmResult(result, rulePath) {
167859
+ if (!result || typeof result !== 'object')
167860
+ return result;
167861
+ // Strip the 'visor/' prefix (matches our compilation entrypoint)
167862
+ const segments = rulePath.replace(/^visor\//, '').split('/');
167863
+ let current = result;
167864
+ for (const seg of segments) {
167865
+ if (current && typeof current === 'object' && seg in current) {
167866
+ current = current[seg];
167867
+ }
167868
+ else {
167869
+ return undefined; // path not found in result tree
167870
+ }
167871
+ }
167872
+ return current;
167873
+ }
167874
+ parseDecision(result) {
167875
+ if (result === undefined || result === null) {
167876
+ return {
167877
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
167878
+ warn: this.fallback === 'warn' ? true : undefined,
167879
+ reason: this.fallback === 'warn' ? 'audit: no policy result' : 'no policy result',
167880
+ };
167881
+ }
167882
+ const allowed = result.allowed !== false;
167883
+ const decision = {
167884
+ allowed,
167885
+ reason: result.reason,
167886
+ };
167887
+ if (result.capabilities) {
167888
+ decision.capabilities = result.capabilities;
167889
+ }
167890
+ return decision;
167891
+ }
167892
+ }
167893
+ exports.OpaPolicyEngine = OpaPolicyEngine;
167894
+
167895
+
167896
+ /***/ }),
167897
+
167898
+ /***/ 8613:
167899
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167900
+
167901
+ "use strict";
167902
+
167903
+ /**
167904
+ * Copyright (c) ProbeLabs. All rights reserved.
167905
+ * Licensed under the Elastic License 2.0; you may not use this file except
167906
+ * in compliance with the Elastic License 2.0.
167907
+ */
167908
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167909
+ if (k2 === undefined) k2 = k;
167910
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167911
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167912
+ desc = { enumerable: true, get: function() { return m[k]; } };
167913
+ }
167914
+ Object.defineProperty(o, k2, desc);
167915
+ }) : (function(o, m, k, k2) {
167916
+ if (k2 === undefined) k2 = k;
167917
+ o[k2] = m[k];
167918
+ }));
167919
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167920
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167921
+ }) : function(o, v) {
167922
+ o["default"] = v;
167923
+ });
167924
+ var __importStar = (this && this.__importStar) || (function () {
167925
+ var ownKeys = function(o) {
167926
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167927
+ var ar = [];
167928
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167929
+ return ar;
167930
+ };
167931
+ return ownKeys(o);
167932
+ };
167933
+ return function (mod) {
167934
+ if (mod && mod.__esModule) return mod;
167935
+ var result = {};
167936
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167937
+ __setModuleDefault(result, mod);
167938
+ return result;
167939
+ };
167940
+ })();
167941
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167942
+ exports.OpaWasmEvaluator = void 0;
167943
+ const fs = __importStar(__nccwpck_require__(79896));
167944
+ const path = __importStar(__nccwpck_require__(16928));
167945
+ const opa_compiler_1 = __nccwpck_require__(628);
167946
+ /**
167947
+ * OPA WASM Evaluator - loads and evaluates OPA policies locally.
167948
+ *
167949
+ * Supports three input formats:
167950
+ * 1. Pre-compiled `.wasm` bundle — loaded directly (fastest startup)
167951
+ * 2. `.rego` files or directory — auto-compiled to WASM via `opa build` CLI
167952
+ * 3. Directory with `policy.wasm` inside — loaded directly
167953
+ *
167954
+ * Compilation and caching of .rego files is delegated to {@link OpaCompiler}.
167955
+ *
167956
+ * Requires:
167957
+ * - `@open-policy-agent/opa-wasm` npm package (optional dep)
167958
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
167959
+ */
167960
+ class OpaWasmEvaluator {
167961
+ policy = null;
167962
+ dataDocument = {};
167963
+ compiler = new opa_compiler_1.OpaCompiler();
167964
+ async initialize(rulesPath) {
167965
+ const paths = Array.isArray(rulesPath) ? rulesPath : [rulesPath];
167966
+ const wasmBytes = await this.compiler.resolveWasmBytes(paths);
167967
+ try {
167968
+ // Use createRequire to load the optional dep at runtime without ncc bundling it.
167969
+ // `new Function('id', 'return require(id)')` fails in ncc bundles because
167970
+ // `require` is not in the `new Function` scope. `createRequire` works correctly
167971
+ // because it creates a real Node.js require rooted at the given path.
167972
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
167973
+ const { createRequire } = __nccwpck_require__(73339);
167974
+ const runtimeRequire = createRequire(__filename);
167975
+ const opaWasm = runtimeRequire('@open-policy-agent/opa-wasm');
167976
+ const loadPolicy = opaWasm.loadPolicy || opaWasm.default?.loadPolicy;
167977
+ if (!loadPolicy) {
167978
+ throw new Error('loadPolicy not found in @open-policy-agent/opa-wasm');
167979
+ }
167980
+ this.policy = await loadPolicy(wasmBytes);
167981
+ }
167982
+ catch (err) {
167983
+ if (err?.code === 'MODULE_NOT_FOUND' || err?.code === 'ERR_MODULE_NOT_FOUND') {
167984
+ throw new Error('OPA WASM evaluator requires @open-policy-agent/opa-wasm. ' +
167985
+ 'Install it with: npm install @open-policy-agent/opa-wasm');
167986
+ }
167987
+ throw err;
167988
+ }
167989
+ }
167990
+ /**
167991
+ * Load external data from a JSON file to use as the OPA data document.
167992
+ * The loaded data will be passed to `policy.setData()` during evaluation,
167993
+ * making it available in Rego via `data.<key>`.
167994
+ */
167995
+ loadData(dataPath) {
167996
+ const resolved = path.resolve(dataPath);
167997
+ if (path.normalize(resolved).includes('..')) {
167998
+ throw new Error(`Data path contains traversal sequences: ${dataPath}`);
167999
+ }
168000
+ if (!fs.existsSync(resolved)) {
168001
+ throw new Error(`OPA data file not found: ${resolved}`);
168002
+ }
168003
+ const stat = fs.statSync(resolved);
168004
+ if (stat.size > 10 * 1024 * 1024) {
168005
+ throw new Error(`OPA data file exceeds 10MB limit: ${resolved} (${stat.size} bytes)`);
168006
+ }
168007
+ const raw = fs.readFileSync(resolved, 'utf-8');
168008
+ try {
168009
+ const parsed = JSON.parse(raw);
168010
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
168011
+ throw new Error('OPA data file must contain a JSON object (not an array or primitive)');
168012
+ }
168013
+ this.dataDocument = parsed;
168014
+ }
168015
+ catch (err) {
168016
+ if (err.message.startsWith('OPA data file must')) {
168017
+ throw err;
168018
+ }
168019
+ throw new Error(`Failed to parse OPA data file ${resolved}: ${err.message}`);
168020
+ }
168021
+ }
168022
+ async evaluate(input) {
168023
+ if (!this.policy) {
168024
+ throw new Error('OPA WASM evaluator not initialized');
168025
+ }
168026
+ this.policy.setData(this.dataDocument);
168027
+ const resultSet = this.policy.evaluate(input);
168028
+ if (Array.isArray(resultSet) && resultSet.length > 0) {
168029
+ return resultSet[0].result;
168030
+ }
168031
+ return undefined;
168032
+ }
168033
+ async shutdown() {
168034
+ if (this.policy) {
168035
+ // opa-wasm policy objects may have a close/free method for WASM cleanup
168036
+ if (typeof this.policy.close === 'function') {
168037
+ try {
168038
+ this.policy.close();
168039
+ }
168040
+ catch { }
168041
+ }
168042
+ else if (typeof this.policy.free === 'function') {
168043
+ try {
168044
+ this.policy.free();
168045
+ }
168046
+ catch { }
168047
+ }
168048
+ }
168049
+ this.policy = null;
168050
+ }
168051
+ }
168052
+ exports.OpaWasmEvaluator = OpaWasmEvaluator;
168053
+
168054
+
168055
+ /***/ }),
168056
+
168057
+ /***/ 17117:
168058
+ /***/ ((__unused_webpack_module, exports) => {
168059
+
168060
+ "use strict";
168061
+
168062
+ /**
168063
+ * Copyright (c) ProbeLabs. All rights reserved.
168064
+ * Licensed under the Elastic License 2.0; you may not use this file except
168065
+ * in compliance with the Elastic License 2.0.
168066
+ */
168067
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168068
+ exports.PolicyInputBuilder = void 0;
168069
+ /**
168070
+ * Builds OPA-compatible input documents from engine context.
168071
+ *
168072
+ * Resolves actor roles from the `policy.roles` config section by matching
168073
+ * the actor's authorAssociation and login against role definitions.
168074
+ */
168075
+ class PolicyInputBuilder {
168076
+ roles;
168077
+ actor;
168078
+ repository;
168079
+ pullRequest;
168080
+ constructor(policyConfig, actor, repository, pullRequest) {
168081
+ this.roles = policyConfig.roles || {};
168082
+ this.actor = actor;
168083
+ this.repository = repository;
168084
+ this.pullRequest = pullRequest;
168085
+ }
168086
+ /** Resolve which roles apply to the current actor. */
168087
+ resolveRoles() {
168088
+ const matched = [];
168089
+ for (const [roleName, roleConfig] of Object.entries(this.roles)) {
168090
+ let identityMatch = false;
168091
+ if (roleConfig.author_association &&
168092
+ this.actor.authorAssociation &&
168093
+ roleConfig.author_association.includes(this.actor.authorAssociation)) {
168094
+ identityMatch = true;
168095
+ }
168096
+ if (!identityMatch &&
168097
+ roleConfig.users &&
168098
+ this.actor.login &&
168099
+ roleConfig.users.includes(this.actor.login)) {
168100
+ identityMatch = true;
168101
+ }
168102
+ // Slack user ID match
168103
+ if (!identityMatch &&
168104
+ roleConfig.slack_users &&
168105
+ this.actor.slack?.userId &&
168106
+ roleConfig.slack_users.includes(this.actor.slack.userId)) {
168107
+ identityMatch = true;
168108
+ }
168109
+ // Email match (case-insensitive)
168110
+ if (!identityMatch && roleConfig.emails && this.actor.slack?.email) {
168111
+ const actorEmail = this.actor.slack.email.toLowerCase();
168112
+ if (roleConfig.emails.some(e => e.toLowerCase() === actorEmail)) {
168113
+ identityMatch = true;
168114
+ }
168115
+ }
168116
+ // Note: teams-based role resolution requires GitHub API access (read:org scope)
168117
+ // and is not yet implemented. If configured, the role will not match via teams.
168118
+ if (!identityMatch)
168119
+ continue;
168120
+ // slack_channels gate: if set, the role only applies when triggered from one of these channels
168121
+ if (roleConfig.slack_channels && roleConfig.slack_channels.length > 0) {
168122
+ if (!this.actor.slack?.channelId ||
168123
+ !roleConfig.slack_channels.includes(this.actor.slack.channelId)) {
168124
+ continue;
168125
+ }
168126
+ }
168127
+ matched.push(roleName);
168128
+ }
168129
+ return matched;
168130
+ }
168131
+ buildActor() {
168132
+ return {
168133
+ authorAssociation: this.actor.authorAssociation,
168134
+ login: this.actor.login,
168135
+ roles: this.resolveRoles(),
168136
+ isLocalMode: this.actor.isLocalMode,
168137
+ ...(this.actor.slack && { slack: this.actor.slack }),
168138
+ };
168139
+ }
168140
+ forCheckExecution(check) {
168141
+ return {
168142
+ scope: 'check.execute',
168143
+ check: {
168144
+ id: check.id,
168145
+ type: check.type,
168146
+ group: check.group,
168147
+ tags: check.tags,
168148
+ criticality: check.criticality,
168149
+ sandbox: check.sandbox,
168150
+ policy: check.policy,
168151
+ },
168152
+ actor: this.buildActor(),
168153
+ repository: this.repository,
168154
+ pullRequest: this.pullRequest,
168155
+ };
168156
+ }
168157
+ forToolInvocation(serverName, methodName, transport) {
168158
+ return {
168159
+ scope: 'tool.invoke',
168160
+ tool: { serverName, methodName, transport },
168161
+ actor: this.buildActor(),
168162
+ repository: this.repository,
168163
+ pullRequest: this.pullRequest,
168164
+ };
168165
+ }
168166
+ forCapabilityResolve(checkId, capabilities) {
168167
+ return {
168168
+ scope: 'capability.resolve',
168169
+ check: { id: checkId, type: 'ai' },
168170
+ capability: capabilities,
168171
+ actor: this.buildActor(),
168172
+ repository: this.repository,
168173
+ pullRequest: this.pullRequest,
168174
+ };
168175
+ }
168176
+ }
168177
+ exports.PolicyInputBuilder = PolicyInputBuilder;
168178
+
168179
+
168180
+ /***/ }),
168181
+
168182
+ /***/ 63737:
168183
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
168184
+
168185
+ "use strict";
168186
+
168187
+ /**
168188
+ * Copyright (c) ProbeLabs. All rights reserved.
168189
+ * Licensed under the Elastic License 2.0; you may not use this file except
168190
+ * in compliance with the Elastic License 2.0.
168191
+ */
168192
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
168193
+ if (k2 === undefined) k2 = k;
168194
+ var desc = Object.getOwnPropertyDescriptor(m, k);
168195
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
168196
+ desc = { enumerable: true, get: function() { return m[k]; } };
168197
+ }
168198
+ Object.defineProperty(o, k2, desc);
168199
+ }) : (function(o, m, k, k2) {
168200
+ if (k2 === undefined) k2 = k;
168201
+ o[k2] = m[k];
168202
+ }));
168203
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
168204
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
168205
+ }) : function(o, v) {
168206
+ o["default"] = v;
168207
+ });
168208
+ var __importStar = (this && this.__importStar) || (function () {
168209
+ var ownKeys = function(o) {
168210
+ ownKeys = Object.getOwnPropertyNames || function (o) {
168211
+ var ar = [];
168212
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
168213
+ return ar;
168214
+ };
168215
+ return ownKeys(o);
168216
+ };
168217
+ return function (mod) {
168218
+ if (mod && mod.__esModule) return mod;
168219
+ var result = {};
168220
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
168221
+ __setModuleDefault(result, mod);
168222
+ return result;
168223
+ };
168224
+ })();
168225
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168226
+ exports.KnexStoreBackend = void 0;
168227
+ /**
168228
+ * Knex-backed schedule store for PostgreSQL, MySQL, and MSSQL (Enterprise)
168229
+ *
168230
+ * Uses Knex query builder for database-agnostic SQL. Same schema as SQLite backend
168231
+ * but with real distributed locking via row-level claims (claimed_by/claimed_at/lock_token).
168232
+ */
168233
+ const fs = __importStar(__nccwpck_require__(79896));
168234
+ const path = __importStar(__nccwpck_require__(16928));
168235
+ const uuid_1 = __nccwpck_require__(31914);
168236
+ const logger_1 = __nccwpck_require__(86999);
168237
+ function toNum(val) {
168238
+ if (val === null || val === undefined)
168239
+ return undefined;
168240
+ return typeof val === 'string' ? parseInt(val, 10) : val;
168241
+ }
168242
+ function safeJsonParse(value) {
168243
+ if (!value)
168244
+ return undefined;
168245
+ try {
168246
+ return JSON.parse(value);
168247
+ }
168248
+ catch {
168249
+ return undefined;
168250
+ }
168251
+ }
168252
+ function fromDbRow(row) {
168253
+ return {
168254
+ id: row.id,
168255
+ creatorId: row.creator_id,
168256
+ creatorContext: row.creator_context ?? undefined,
168257
+ creatorName: row.creator_name ?? undefined,
168258
+ timezone: row.timezone,
168259
+ schedule: row.schedule_expr,
168260
+ runAt: toNum(row.run_at),
168261
+ isRecurring: row.is_recurring === true || row.is_recurring === 1,
168262
+ originalExpression: row.original_expression,
168263
+ workflow: row.workflow ?? undefined,
168264
+ workflowInputs: safeJsonParse(row.workflow_inputs),
168265
+ outputContext: safeJsonParse(row.output_context),
168266
+ status: row.status,
168267
+ createdAt: toNum(row.created_at),
168268
+ lastRunAt: toNum(row.last_run_at),
168269
+ nextRunAt: toNum(row.next_run_at),
168270
+ runCount: row.run_count,
168271
+ failureCount: row.failure_count,
168272
+ lastError: row.last_error ?? undefined,
168273
+ previousResponse: row.previous_response ?? undefined,
168274
+ };
168275
+ }
168276
+ function toInsertRow(schedule) {
168277
+ return {
168278
+ id: schedule.id,
168279
+ creator_id: schedule.creatorId,
168280
+ creator_context: schedule.creatorContext ?? null,
168281
+ creator_name: schedule.creatorName ?? null,
168282
+ timezone: schedule.timezone,
168283
+ schedule_expr: schedule.schedule,
168284
+ run_at: schedule.runAt ?? null,
168285
+ is_recurring: schedule.isRecurring,
168286
+ original_expression: schedule.originalExpression,
168287
+ workflow: schedule.workflow ?? null,
168288
+ workflow_inputs: schedule.workflowInputs ? JSON.stringify(schedule.workflowInputs) : null,
168289
+ output_context: schedule.outputContext ? JSON.stringify(schedule.outputContext) : null,
168290
+ status: schedule.status,
168291
+ created_at: schedule.createdAt,
168292
+ last_run_at: schedule.lastRunAt ?? null,
168293
+ next_run_at: schedule.nextRunAt ?? null,
168294
+ run_count: schedule.runCount,
168295
+ failure_count: schedule.failureCount,
168296
+ last_error: schedule.lastError ?? null,
168297
+ previous_response: schedule.previousResponse ?? null,
168298
+ };
168299
+ }
168300
+ /**
168301
+ * Enterprise Knex-backed store for PostgreSQL, MySQL, and MSSQL
168302
+ */
168303
+ class KnexStoreBackend {
168304
+ knex = null;
168305
+ driver;
168306
+ connection;
168307
+ constructor(driver, storageConfig, _haConfig) {
168308
+ this.driver = driver;
168309
+ this.connection = (storageConfig.connection || {});
168310
+ }
168311
+ async initialize() {
168312
+ // Load knex dynamically
168313
+ const { createRequire } = __nccwpck_require__(73339);
168314
+ const runtimeRequire = createRequire(__filename);
168315
+ let knexFactory;
168316
+ try {
168317
+ knexFactory = runtimeRequire('knex');
168318
+ }
168319
+ catch (err) {
168320
+ const code = err?.code;
168321
+ if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
168322
+ throw new Error('knex is required for PostgreSQL/MySQL/MSSQL schedule storage. ' +
168323
+ 'Install it with: npm install knex');
168324
+ }
168325
+ throw err;
168326
+ }
168327
+ const clientMap = {
168328
+ postgresql: 'pg',
168329
+ mysql: 'mysql2',
168330
+ mssql: 'tedious',
168331
+ };
168332
+ const client = clientMap[this.driver];
168333
+ // Build connection config
168334
+ let connection;
168335
+ if (this.connection.connection_string) {
168336
+ connection = this.connection.connection_string;
168337
+ }
168338
+ else if (this.driver === 'mssql') {
168339
+ connection = this.buildMssqlConnection();
168340
+ }
168341
+ else {
168342
+ connection = this.buildStandardConnection();
168343
+ }
168344
+ this.knex = knexFactory({
168345
+ client,
168346
+ connection,
168347
+ pool: {
168348
+ min: this.connection.pool?.min ?? 0,
168349
+ max: this.connection.pool?.max ?? 10,
168350
+ },
168351
+ });
168352
+ // Run schema migration
168353
+ await this.migrateSchema();
168354
+ logger_1.logger.info(`[KnexStore] Initialized (${this.driver})`);
168355
+ }
168356
+ buildStandardConnection() {
168357
+ return {
168358
+ host: this.connection.host || 'localhost',
168359
+ port: this.connection.port,
168360
+ database: this.connection.database || 'visor',
168361
+ user: this.connection.user,
168362
+ password: this.connection.password,
168363
+ ssl: this.resolveSslConfig(),
168364
+ };
168365
+ }
168366
+ buildMssqlConnection() {
168367
+ const ssl = this.connection.ssl;
168368
+ const sslEnabled = ssl === true || (typeof ssl === 'object' && ssl.enabled !== false);
168369
+ return {
168370
+ server: this.connection.host || 'localhost',
168371
+ port: this.connection.port,
168372
+ database: this.connection.database || 'visor',
168373
+ user: this.connection.user,
168374
+ password: this.connection.password,
168375
+ options: {
168376
+ encrypt: sslEnabled,
168377
+ trustServerCertificate: typeof ssl === 'object' ? ssl.reject_unauthorized === false : !sslEnabled,
168378
+ },
168379
+ };
168380
+ }
168381
+ resolveSslConfig() {
168382
+ const ssl = this.connection.ssl;
168383
+ if (ssl === false || ssl === undefined)
168384
+ return false;
168385
+ if (ssl === true)
168386
+ return { rejectUnauthorized: true };
168387
+ // Object config
168388
+ if (ssl.enabled === false)
168389
+ return false;
168390
+ const result = {
168391
+ rejectUnauthorized: ssl.reject_unauthorized !== false,
168392
+ };
168393
+ if (ssl.ca) {
168394
+ const caPath = this.validateSslPath(ssl.ca, 'CA certificate');
168395
+ result.ca = fs.readFileSync(caPath, 'utf8');
168396
+ }
168397
+ if (ssl.cert) {
168398
+ const certPath = this.validateSslPath(ssl.cert, 'client certificate');
168399
+ result.cert = fs.readFileSync(certPath, 'utf8');
168400
+ }
168401
+ if (ssl.key) {
168402
+ const keyPath = this.validateSslPath(ssl.key, 'client key');
168403
+ result.key = fs.readFileSync(keyPath, 'utf8');
168404
+ }
168405
+ return result;
168406
+ }
168407
+ validateSslPath(filePath, label) {
168408
+ const resolved = path.resolve(filePath);
168409
+ if (resolved !== path.normalize(resolved)) {
168410
+ throw new Error(`SSL ${label} path contains invalid sequences: ${filePath}`);
168411
+ }
168412
+ if (!fs.existsSync(resolved)) {
168413
+ throw new Error(`SSL ${label} not found: ${filePath}`);
168414
+ }
168415
+ return resolved;
168416
+ }
168417
+ async shutdown() {
168418
+ if (this.knex) {
168419
+ await this.knex.destroy();
168420
+ this.knex = null;
168421
+ }
168422
+ }
168423
+ async migrateSchema() {
168424
+ const knex = this.getKnex();
168425
+ const exists = await knex.schema.hasTable('schedules');
168426
+ if (!exists) {
168427
+ await knex.schema.createTable('schedules', table => {
168428
+ table.string('id', 36).primary();
168429
+ table.string('creator_id', 255).notNullable().index();
168430
+ table.string('creator_context', 255);
168431
+ table.string('creator_name', 255);
168432
+ table.string('timezone', 64).notNullable().defaultTo('UTC');
168433
+ table.string('schedule_expr', 255);
168434
+ table.bigInteger('run_at');
168435
+ table.boolean('is_recurring').notNullable();
168436
+ table.text('original_expression');
168437
+ table.string('workflow', 255);
168438
+ table.text('workflow_inputs');
168439
+ table.text('output_context');
168440
+ table.string('status', 20).notNullable().index();
168441
+ table.bigInteger('created_at').notNullable();
168442
+ table.bigInteger('last_run_at');
168443
+ table.bigInteger('next_run_at');
168444
+ table.integer('run_count').notNullable().defaultTo(0);
168445
+ table.integer('failure_count').notNullable().defaultTo(0);
168446
+ table.text('last_error');
168447
+ table.text('previous_response');
168448
+ table.index(['status', 'next_run_at']);
168449
+ });
168450
+ }
168451
+ // Create scheduler_locks table for distributed locking
168452
+ const locksExist = await knex.schema.hasTable('scheduler_locks');
168453
+ if (!locksExist) {
168454
+ await knex.schema.createTable('scheduler_locks', table => {
168455
+ table.string('lock_id', 255).primary();
168456
+ table.string('node_id', 255).notNullable();
168457
+ table.string('lock_token', 36).notNullable();
168458
+ table.bigInteger('acquired_at').notNullable();
168459
+ table.bigInteger('expires_at').notNullable();
168460
+ });
168461
+ }
168462
+ }
168463
+ getKnex() {
168464
+ if (!this.knex) {
168465
+ throw new Error('[KnexStore] Not initialized. Call initialize() first.');
168466
+ }
168467
+ return this.knex;
168468
+ }
168469
+ // --- CRUD ---
168470
+ async create(schedule) {
168471
+ const knex = this.getKnex();
168472
+ const newSchedule = {
168473
+ ...schedule,
168474
+ id: (0, uuid_1.v4)(),
168475
+ createdAt: Date.now(),
168476
+ runCount: 0,
168477
+ failureCount: 0,
168478
+ status: 'active',
168479
+ };
168480
+ await knex('schedules').insert(toInsertRow(newSchedule));
168481
+ logger_1.logger.info(`[KnexStore] Created schedule ${newSchedule.id} for user ${newSchedule.creatorId}`);
168482
+ return newSchedule;
168483
+ }
168484
+ async importSchedule(schedule) {
168485
+ const knex = this.getKnex();
168486
+ const existing = await knex('schedules').where('id', schedule.id).first();
168487
+ if (existing)
168488
+ return; // Already imported (idempotent)
168489
+ await knex('schedules').insert(toInsertRow(schedule));
168490
+ }
168491
+ async get(id) {
168492
+ const knex = this.getKnex();
168493
+ const row = await knex('schedules').where('id', id).first();
168494
+ return row ? fromDbRow(row) : undefined;
168495
+ }
168496
+ async update(id, patch) {
168497
+ const knex = this.getKnex();
168498
+ const existing = await knex('schedules').where('id', id).first();
168499
+ if (!existing)
168500
+ return undefined;
168501
+ const current = fromDbRow(existing);
168502
+ const updated = { ...current, ...patch, id: current.id };
168503
+ const row = toInsertRow(updated);
168504
+ // Remove id from update (PK cannot change)
168505
+ delete row.id;
168506
+ await knex('schedules').where('id', id).update(row);
168507
+ return updated;
168508
+ }
168509
+ async delete(id) {
168510
+ const knex = this.getKnex();
168511
+ const deleted = await knex('schedules').where('id', id).del();
168512
+ if (deleted > 0) {
168513
+ logger_1.logger.info(`[KnexStore] Deleted schedule ${id}`);
168514
+ return true;
168515
+ }
168516
+ return false;
168517
+ }
168518
+ // --- Queries ---
168519
+ async getByCreator(creatorId) {
168520
+ const knex = this.getKnex();
168521
+ const rows = await knex('schedules').where('creator_id', creatorId);
168522
+ return rows.map((r) => fromDbRow(r));
168523
+ }
168524
+ async getActiveSchedules() {
168525
+ const knex = this.getKnex();
168526
+ const rows = await knex('schedules').where('status', 'active');
168527
+ return rows.map((r) => fromDbRow(r));
168528
+ }
168529
+ async getDueSchedules(now) {
168530
+ const ts = now ?? Date.now();
168531
+ const knex = this.getKnex();
168532
+ // MSSQL uses 1/0 for booleans
168533
+ const bFalse = this.driver === 'mssql' ? 0 : false;
168534
+ const bTrue = this.driver === 'mssql' ? 1 : true;
168535
+ const rows = await knex('schedules')
168536
+ .where('status', 'active')
168537
+ .andWhere(function () {
168538
+ this.where(function () {
168539
+ this.where('is_recurring', bFalse)
168540
+ .whereNotNull('run_at')
168541
+ .where('run_at', '<=', ts);
168542
+ }).orWhere(function () {
168543
+ this.where('is_recurring', bTrue)
168544
+ .whereNotNull('next_run_at')
168545
+ .where('next_run_at', '<=', ts);
168546
+ });
168547
+ });
168548
+ return rows.map((r) => fromDbRow(r));
168549
+ }
168550
+ async findByWorkflow(creatorId, workflowName) {
168551
+ const knex = this.getKnex();
168552
+ const escaped = workflowName.toLowerCase().replace(/[%_\\]/g, '\\$&');
168553
+ const pattern = `%${escaped}%`;
168554
+ const rows = await knex('schedules')
168555
+ .where('creator_id', creatorId)
168556
+ .where('status', 'active')
168557
+ .whereRaw("LOWER(workflow) LIKE ? ESCAPE '\\'", [pattern]);
168558
+ return rows.map((r) => fromDbRow(r));
168559
+ }
168560
+ async getAll() {
168561
+ const knex = this.getKnex();
168562
+ const rows = await knex('schedules');
168563
+ return rows.map((r) => fromDbRow(r));
168564
+ }
168565
+ async getStats() {
168566
+ const knex = this.getKnex();
168567
+ // MSSQL uses 1/0 for booleans; PostgreSQL/MySQL accept both true/1
168568
+ const boolTrue = this.driver === 'mssql' ? '1' : 'true';
168569
+ const boolFalse = this.driver === 'mssql' ? '0' : 'false';
168570
+ const result = await knex('schedules')
168571
+ .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`))
168572
+ .first();
168573
+ return {
168574
+ total: Number(result.total) || 0,
168575
+ active: Number(result.active) || 0,
168576
+ paused: Number(result.paused) || 0,
168577
+ completed: Number(result.completed) || 0,
168578
+ failed: Number(result.failed) || 0,
168579
+ recurring: Number(result.recurring) || 0,
168580
+ oneTime: Number(result.one_time) || 0,
168581
+ };
168582
+ }
168583
+ async validateLimits(creatorId, isRecurring, limits) {
168584
+ const knex = this.getKnex();
168585
+ if (limits.maxGlobal) {
168586
+ const result = await knex('schedules').count('* as cnt').first();
168587
+ if (Number(result?.cnt) >= limits.maxGlobal) {
168588
+ throw new Error(`Global schedule limit reached (${limits.maxGlobal})`);
168589
+ }
168590
+ }
168591
+ if (limits.maxPerUser) {
168592
+ const result = await knex('schedules')
168593
+ .where('creator_id', creatorId)
168594
+ .count('* as cnt')
168595
+ .first();
168596
+ if (Number(result?.cnt) >= limits.maxPerUser) {
168597
+ throw new Error(`You have reached the maximum number of schedules (${limits.maxPerUser})`);
168598
+ }
168599
+ }
168600
+ if (isRecurring && limits.maxRecurringPerUser) {
168601
+ const bTrue = this.driver === 'mssql' ? 1 : true;
168602
+ const result = await knex('schedules')
168603
+ .where('creator_id', creatorId)
168604
+ .where('is_recurring', bTrue)
168605
+ .count('* as cnt')
168606
+ .first();
168607
+ if (Number(result?.cnt) >= limits.maxRecurringPerUser) {
168608
+ throw new Error(`You have reached the maximum number of recurring schedules (${limits.maxRecurringPerUser})`);
168609
+ }
168610
+ }
168611
+ }
168612
+ // --- HA Distributed Locking (via scheduler_locks table) ---
168613
+ async tryAcquireLock(lockId, nodeId, ttlSeconds) {
168614
+ const knex = this.getKnex();
168615
+ const now = Date.now();
168616
+ const expiresAt = now + ttlSeconds * 1000;
168617
+ const token = (0, uuid_1.v4)();
168618
+ // Step 1: Try to claim an existing expired lock
168619
+ const updated = await knex('scheduler_locks')
168620
+ .where('lock_id', lockId)
168621
+ .where('expires_at', '<', now)
168622
+ .update({
168623
+ node_id: nodeId,
168624
+ lock_token: token,
168625
+ acquired_at: now,
168626
+ expires_at: expiresAt,
168627
+ });
168628
+ if (updated > 0)
168629
+ return token;
168630
+ // Step 2: Try to INSERT a new lock row
168631
+ try {
168632
+ await knex('scheduler_locks').insert({
168633
+ lock_id: lockId,
168634
+ node_id: nodeId,
168635
+ lock_token: token,
168636
+ acquired_at: now,
168637
+ expires_at: expiresAt,
168638
+ });
168639
+ return token;
168640
+ }
168641
+ catch {
168642
+ // Unique constraint violation — another node holds the lock
168643
+ return null;
168644
+ }
168645
+ }
168646
+ async releaseLock(lockId, lockToken) {
168647
+ const knex = this.getKnex();
168648
+ await knex('scheduler_locks').where('lock_id', lockId).where('lock_token', lockToken).del();
168649
+ }
168650
+ async renewLock(lockId, lockToken, ttlSeconds) {
168651
+ const knex = this.getKnex();
168652
+ const now = Date.now();
168653
+ const expiresAt = now + ttlSeconds * 1000;
168654
+ const updated = await knex('scheduler_locks')
168655
+ .where('lock_id', lockId)
168656
+ .where('lock_token', lockToken)
168657
+ .update({ acquired_at: now, expires_at: expiresAt });
168658
+ return updated > 0;
168659
+ }
168660
+ async flush() {
168661
+ // No-op for server-based backends
168662
+ }
168663
+ }
168664
+ exports.KnexStoreBackend = KnexStoreBackend;
168665
+
168666
+
166970
168667
  /***/ }),
166971
168668
 
166972
168669
  /***/ 83864:
@@ -177643,6 +179340,35 @@ class OutputFormatters {
177643
179340
  exports.OutputFormatters = OutputFormatters;
177644
179341
 
177645
179342
 
179343
+ /***/ }),
179344
+
179345
+ /***/ 93866:
179346
+ /***/ ((__unused_webpack_module, exports) => {
179347
+
179348
+ "use strict";
179349
+
179350
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
179351
+ exports.DefaultPolicyEngine = void 0;
179352
+ /**
179353
+ * Default (no-op) policy engine — always allows everything.
179354
+ * Used when no enterprise license is present or policy is disabled.
179355
+ */
179356
+ class DefaultPolicyEngine {
179357
+ async initialize(_config) { }
179358
+ async evaluateCheckExecution(_checkId, _checkConfig) {
179359
+ return { allowed: true };
179360
+ }
179361
+ async evaluateToolInvocation(_serverName, _methodName, _transport) {
179362
+ return { allowed: true };
179363
+ }
179364
+ async evaluateCapabilities(_checkId, _capabilities) {
179365
+ return { allowed: true };
179366
+ }
179367
+ async shutdown() { }
179368
+ }
179369
+ exports.DefaultPolicyEngine = DefaultPolicyEngine;
179370
+
179371
+
177646
179372
  /***/ }),
177647
179373
 
177648
179374
  /***/ 96611:
@@ -197897,7 +199623,7 @@ class StateMachineExecutionEngine {
197897
199623
  try {
197898
199624
  logger_1.logger.debug(`[PolicyEngine] Loading enterprise policy engine (engine=${configWithTagFilter.policy.engine})`);
197899
199625
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
197900
- const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(7065)));
199626
+ const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(87068)));
197901
199627
  context.policyEngine = await loadEnterprisePolicyEngine(configWithTagFilter.policy);
197902
199628
  logger_1.logger.debug(`[PolicyEngine] Initialized: ${context.policyEngine?.constructor?.name || 'unknown'}`);
197903
199629
  }
@@ -199841,7 +201567,8 @@ async function executeSingleCheck(checkId, context, state, emitEvent, transition
199841
201567
  const output = result.output;
199842
201568
  if (output !== null && typeof output === 'object' && !Array.isArray(output)) {
199843
201569
  // Only inject 'ts' if the output doesn't already have one (avoids overwriting Slack API timestamps)
199844
- outputWithTimestamp = 'ts' in output ? { ...output, _engine_ts: Date.now() } : { ...output, ts: Date.now() };
201570
+ outputWithTimestamp =
201571
+ 'ts' in output ? { ...output, _engine_ts: Date.now() } : { ...output, ts: Date.now() };
199845
201572
  }
199846
201573
  else {
199847
201574
  outputWithTimestamp = output;
@@ -204246,7 +205973,8 @@ async function executeSingleCheck(checkId, context, state, emitEvent, transition
204246
205973
  const output = result.output;
204247
205974
  if (output !== null && typeof output === 'object' && !Array.isArray(output)) {
204248
205975
  // Only add timestamp to plain objects if they don't already have one
204249
- outputWithTimestamp = 'ts' in output ? { ...output, _engine_ts: Date.now() } : { ...output, ts: Date.now() };
205976
+ outputWithTimestamp =
205977
+ 'ts' in output ? { ...output, _engine_ts: Date.now() } : { ...output, ts: Date.now() };
204250
205978
  }
204251
205979
  else {
204252
205980
  // Preserve primitives, arrays, and null as-is
@@ -208159,7 +209887,7 @@ async function initTelemetry(opts = {}) {
208159
209887
  const path = __nccwpck_require__(16928);
208160
209888
  const outDir = opts.file?.dir ||
208161
209889
  process.env.VISOR_TRACE_DIR ||
208162
- __nccwpck_require__.ab + "traces";
209890
+ path.join(process.cwd(), 'output', 'traces');
208163
209891
  fs.mkdirSync(outDir, { recursive: true });
208164
209892
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
208165
209893
  process.env.VISOR_FALLBACK_TRACE_FILE = path.join(outDir, `run-${ts}.ndjson`);
@@ -208362,7 +210090,7 @@ async function shutdownTelemetry() {
208362
210090
  if (process.env.VISOR_TRACE_REPORT === 'true') {
208363
210091
  const fs = __nccwpck_require__(79896);
208364
210092
  const path = __nccwpck_require__(16928);
208365
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
210093
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
208366
210094
  if (!fs.existsSync(outDir))
208367
210095
  fs.mkdirSync(outDir, { recursive: true });
208368
210096
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
@@ -208861,7 +210589,7 @@ function __getOrCreateNdjsonPath() {
208861
210589
  fs.mkdirSync(dir, { recursive: true });
208862
210590
  return __ndjsonPath;
208863
210591
  }
208864
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
210592
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
208865
210593
  if (!fs.existsSync(outDir))
208866
210594
  fs.mkdirSync(outDir, { recursive: true });
208867
210595
  if (!__ndjsonPath) {
@@ -222188,22 +223916,6 @@ class WorkflowRegistry {
222188
223916
  exports.WorkflowRegistry = WorkflowRegistry;
222189
223917
 
222190
223918
 
222191
- /***/ }),
222192
-
222193
- /***/ 7065:
222194
- /***/ ((module) => {
222195
-
222196
- module.exports = eval("require")("./enterprise/loader");
222197
-
222198
-
222199
- /***/ }),
222200
-
222201
- /***/ 71370:
222202
- /***/ ((module) => {
222203
-
222204
- module.exports = eval("require")("./enterprise/policy/policy-input-builder");
222205
-
222206
-
222207
223919
  /***/ }),
222208
223920
 
222209
223921
  /***/ 18327:
@@ -396157,7 +397869,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"100":"Continue","101":"Switching Pro
396157
397869
  /***/ ((module) => {
396158
397870
 
396159
397871
  "use strict";
396160
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.141","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","@probelabs/probe":"^0.6.0-rc257","@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","@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","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"]}}');
397872
+ 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","@probelabs/probe":"^0.6.0-rc257","@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","@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","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"]}}');
396161
397873
 
396162
397874
  /***/ })
396163
397875