@probelabs/visor 0.1.166-ee → 0.1.166

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 (53) hide show
  1. package/dist/index.js +23 -1840
  2. package/dist/output/traces/run-2026-03-06T13-08-34-152Z.ndjson +138 -0
  3. package/dist/output/traces/run-2026-03-06T13-09-10-593Z.ndjson +2235 -0
  4. package/dist/sdk/{check-provider-registry-PU67PWTU.mjs → check-provider-registry-V6C4LUYJ.mjs} +2 -2
  5. package/dist/sdk/check-provider-registry-WXEBJWXY.mjs +29 -0
  6. package/dist/sdk/chunk-HFCOZPAS.mjs +443 -0
  7. package/dist/sdk/chunk-HFCOZPAS.mjs.map +1 -0
  8. package/dist/sdk/chunk-KBTFMYZQ.mjs +739 -0
  9. package/dist/sdk/chunk-KBTFMYZQ.mjs.map +1 -0
  10. package/dist/sdk/{chunk-P5P6BOO7.mjs → chunk-KKGMGB4X.mjs} +9 -9
  11. package/dist/sdk/{chunk-P5P6BOO7.mjs.map → chunk-KKGMGB4X.mjs.map} +1 -1
  12. package/dist/sdk/chunk-OQ3CML4F.mjs +1502 -0
  13. package/dist/sdk/chunk-OQ3CML4F.mjs.map +1 -0
  14. package/dist/sdk/chunk-ZQR4AGS3.mjs +44057 -0
  15. package/dist/sdk/chunk-ZQR4AGS3.mjs.map +1 -0
  16. package/dist/sdk/failure-condition-evaluator-5EAESM44.mjs +17 -0
  17. package/dist/sdk/github-frontend-BPRRUIGB.mjs +1368 -0
  18. package/dist/sdk/github-frontend-BPRRUIGB.mjs.map +1 -0
  19. package/dist/sdk/{host-QYPOS4R6.mjs → host-753E6PKF.mjs} +2 -2
  20. package/dist/sdk/routing-QHWSMAIH.mjs +25 -0
  21. package/dist/sdk/{schedule-tool-5FVFYH2A.mjs → schedule-tool-OCZGLKMJ.mjs} +2 -2
  22. package/dist/sdk/schedule-tool-OCZGLKMJ.mjs.map +1 -0
  23. package/dist/sdk/schedule-tool-ZVOSSFN2.mjs +35 -0
  24. package/dist/sdk/schedule-tool-ZVOSSFN2.mjs.map +1 -0
  25. package/dist/sdk/schedule-tool-handler-4NCS4ARE.mjs +39 -0
  26. package/dist/sdk/schedule-tool-handler-4NCS4ARE.mjs.map +1 -0
  27. package/dist/sdk/{schedule-tool-handler-4TCT2P7A.mjs → schedule-tool-handler-BGOL2TOP.mjs} +2 -2
  28. package/dist/sdk/schedule-tool-handler-BGOL2TOP.mjs.map +1 -0
  29. package/dist/sdk/sdk.js +259 -1633
  30. package/dist/sdk/sdk.js.map +1 -1
  31. package/dist/sdk/sdk.mjs +4 -4
  32. package/dist/sdk/trace-helpers-CTHTK6V5.mjs +25 -0
  33. package/dist/sdk/trace-helpers-CTHTK6V5.mjs.map +1 -0
  34. package/dist/sdk/{workflow-check-provider-BE2SVYWW.mjs → workflow-check-provider-3M5LXLLX.mjs} +2 -2
  35. package/dist/sdk/workflow-check-provider-3M5LXLLX.mjs.map +1 -0
  36. package/dist/sdk/workflow-check-provider-UTNO6XN6.mjs +29 -0
  37. package/dist/sdk/workflow-check-provider-UTNO6XN6.mjs.map +1 -0
  38. package/dist/traces/run-2026-03-06T13-08-34-152Z.ndjson +138 -0
  39. package/dist/traces/run-2026-03-06T13-09-10-593Z.ndjson +2235 -0
  40. package/package.json +1 -1
  41. package/dist/sdk/knex-store-CRORFJE6.mjs +0 -527
  42. package/dist/sdk/knex-store-CRORFJE6.mjs.map +0 -1
  43. package/dist/sdk/loader-NJCF7DUS.mjs +0 -89
  44. package/dist/sdk/loader-NJCF7DUS.mjs.map +0 -1
  45. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs +0 -655
  46. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs.map +0 -1
  47. package/dist/sdk/validator-XTZJZZJH.mjs +0 -134
  48. package/dist/sdk/validator-XTZJZZJH.mjs.map +0 -1
  49. /package/dist/sdk/{check-provider-registry-PU67PWTU.mjs.map → check-provider-registry-V6C4LUYJ.mjs.map} +0 -0
  50. /package/dist/sdk/{schedule-tool-5FVFYH2A.mjs.map → check-provider-registry-WXEBJWXY.mjs.map} +0 -0
  51. /package/dist/sdk/{schedule-tool-handler-4TCT2P7A.mjs.map → failure-condition-evaluator-5EAESM44.mjs.map} +0 -0
  52. /package/dist/sdk/{host-QYPOS4R6.mjs.map → host-753E6PKF.mjs.map} +0 -0
  53. /package/dist/sdk/{workflow-check-provider-BE2SVYWW.mjs.map → routing-QHWSMAIH.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  process.env.VISOR_VERSION = '0.1.166';
3
3
  process.env.PROBE_VERSION = '0.6.0-rc280';
4
4
  process.env.VISOR_COMMIT_SHA = 'eff5ed2df07d89e22e1c88d7d96b97572b0fd908';
5
- process.env.VISOR_COMMIT_SHORT = 'eff5ed2';
5
+ process.env.VISOR_COMMIT_SHORT = 'eff5ed2df';
6
6
  /******/ (() => { // webpackBootstrap
7
7
  /******/ var __webpack_modules__ = ({
8
8
 
@@ -161217,7 +161217,7 @@ async function handleDumpPolicyInput(checkId, argv) {
161217
161217
  let PolicyInputBuilder;
161218
161218
  try {
161219
161219
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
161220
- const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(17117)));
161220
+ const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(71370)));
161221
161221
  PolicyInputBuilder = mod.PolicyInputBuilder;
161222
161222
  }
161223
161223
  catch {
@@ -167104,1810 +167104,6 @@ class DependencyResolver {
167104
167104
  exports.DependencyResolver = DependencyResolver;
167105
167105
 
167106
167106
 
167107
- /***/ }),
167108
-
167109
- /***/ 50069:
167110
- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167111
-
167112
- "use strict";
167113
-
167114
- /**
167115
- * Copyright (c) ProbeLabs. All rights reserved.
167116
- * Licensed under the Elastic License 2.0; you may not use this file except
167117
- * in compliance with the Elastic License 2.0.
167118
- */
167119
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167120
- if (k2 === undefined) k2 = k;
167121
- var desc = Object.getOwnPropertyDescriptor(m, k);
167122
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167123
- desc = { enumerable: true, get: function() { return m[k]; } };
167124
- }
167125
- Object.defineProperty(o, k2, desc);
167126
- }) : (function(o, m, k, k2) {
167127
- if (k2 === undefined) k2 = k;
167128
- o[k2] = m[k];
167129
- }));
167130
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167131
- Object.defineProperty(o, "default", { enumerable: true, value: v });
167132
- }) : function(o, v) {
167133
- o["default"] = v;
167134
- });
167135
- var __importStar = (this && this.__importStar) || (function () {
167136
- var ownKeys = function(o) {
167137
- ownKeys = Object.getOwnPropertyNames || function (o) {
167138
- var ar = [];
167139
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167140
- return ar;
167141
- };
167142
- return ownKeys(o);
167143
- };
167144
- return function (mod) {
167145
- if (mod && mod.__esModule) return mod;
167146
- var result = {};
167147
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167148
- __setModuleDefault(result, mod);
167149
- return result;
167150
- };
167151
- })();
167152
- Object.defineProperty(exports, "__esModule", ({ value: true }));
167153
- exports.LicenseValidator = void 0;
167154
- const crypto = __importStar(__nccwpck_require__(76982));
167155
- const fs = __importStar(__nccwpck_require__(79896));
167156
- const path = __importStar(__nccwpck_require__(16928));
167157
- class LicenseValidator {
167158
- /** Ed25519 public key for license verification (PEM format). */
167159
- static PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----\n' +
167160
- 'MCowBQYDK2VwAyEAI/Zd08EFmgIdrDm/HXd0l3/5GBt7R1PrdvhdmEXhJlU=\n' +
167161
- '-----END PUBLIC KEY-----\n';
167162
- cache = null;
167163
- static CACHE_TTL = 5 * 60 * 1000; // 5 minutes
167164
- static GRACE_PERIOD = 72 * 3600 * 1000; // 72 hours after expiry
167165
- /**
167166
- * Load and validate license from environment or file.
167167
- *
167168
- * Resolution order:
167169
- * 1. VISOR_LICENSE env var (JWT string)
167170
- * 2. VISOR_LICENSE_FILE env var (path to file)
167171
- * 3. .visor-license in project root (cwd)
167172
- * 4. .visor-license in ~/.config/visor/
167173
- */
167174
- async loadAndValidate() {
167175
- // Return cached result if still fresh
167176
- if (this.cache && Date.now() - this.cache.validatedAt < LicenseValidator.CACHE_TTL) {
167177
- return this.cache.payload;
167178
- }
167179
- const token = this.resolveToken();
167180
- if (!token)
167181
- return null;
167182
- const payload = this.verifyAndDecode(token);
167183
- if (!payload)
167184
- return null;
167185
- this.cache = { payload, validatedAt: Date.now() };
167186
- return payload;
167187
- }
167188
- /** Check if a specific feature is licensed */
167189
- hasFeature(feature) {
167190
- if (!this.cache)
167191
- return false;
167192
- return this.cache.payload.features.includes(feature);
167193
- }
167194
- /** Check if license is valid (with grace period) */
167195
- isValid() {
167196
- if (!this.cache)
167197
- return false;
167198
- const now = Date.now();
167199
- const expiryMs = this.cache.payload.exp * 1000;
167200
- return now < expiryMs + LicenseValidator.GRACE_PERIOD;
167201
- }
167202
- /** Check if the license is within its grace period (expired but still valid) */
167203
- isInGracePeriod() {
167204
- if (!this.cache)
167205
- return false;
167206
- const now = Date.now();
167207
- const expiryMs = this.cache.payload.exp * 1000;
167208
- return now >= expiryMs && now < expiryMs + LicenseValidator.GRACE_PERIOD;
167209
- }
167210
- resolveToken() {
167211
- // 1. Direct env var
167212
- if (process.env.VISOR_LICENSE) {
167213
- return process.env.VISOR_LICENSE.trim();
167214
- }
167215
- // 2. File path from env (validate against path traversal)
167216
- if (process.env.VISOR_LICENSE_FILE) {
167217
- // path.resolve() produces an absolute path with all '..' segments resolved,
167218
- // so a separate resolved.includes('..') check is unnecessary.
167219
- const resolved = path.resolve(process.env.VISOR_LICENSE_FILE);
167220
- const home = process.env.HOME || process.env.USERPROFILE || '';
167221
- const allowedPrefixes = [path.normalize(process.cwd())];
167222
- if (home)
167223
- allowedPrefixes.push(path.normalize(path.join(home, '.config', 'visor')));
167224
- // Resolve symlinks so an attacker cannot create a symlink inside an
167225
- // allowed prefix that points to an arbitrary file outside it.
167226
- let realPath;
167227
- try {
167228
- realPath = fs.realpathSync(resolved);
167229
- }
167230
- catch {
167231
- return null; // File doesn't exist or isn't accessible
167232
- }
167233
- const isSafe = allowedPrefixes.some(prefix => realPath === prefix || realPath.startsWith(prefix + path.sep));
167234
- if (!isSafe)
167235
- return null;
167236
- return this.readFile(realPath);
167237
- }
167238
- // 3. .visor-license in cwd
167239
- const cwdPath = path.join(process.cwd(), '.visor-license');
167240
- const cwdToken = this.readFile(cwdPath);
167241
- if (cwdToken)
167242
- return cwdToken;
167243
- // 4. ~/.config/visor/.visor-license
167244
- const home = process.env.HOME || process.env.USERPROFILE || '';
167245
- if (home) {
167246
- const configPath = path.join(home, '.config', 'visor', '.visor-license');
167247
- const configToken = this.readFile(configPath);
167248
- if (configToken)
167249
- return configToken;
167250
- }
167251
- return null;
167252
- }
167253
- readFile(filePath) {
167254
- try {
167255
- return fs.readFileSync(filePath, 'utf-8').trim();
167256
- }
167257
- catch {
167258
- return null;
167259
- }
167260
- }
167261
- verifyAndDecode(token) {
167262
- try {
167263
- const parts = token.split('.');
167264
- if (parts.length !== 3)
167265
- return null;
167266
- const [headerB64, payloadB64, signatureB64] = parts;
167267
- // Decode header to verify algorithm
167268
- const header = JSON.parse(Buffer.from(headerB64, 'base64url').toString());
167269
- if (header.alg !== 'EdDSA')
167270
- return null;
167271
- // Verify signature
167272
- const data = `${headerB64}.${payloadB64}`;
167273
- const signature = Buffer.from(signatureB64, 'base64url');
167274
- const publicKey = crypto.createPublicKey(LicenseValidator.PUBLIC_KEY);
167275
- // Validate that the loaded public key is actually Ed25519 (OID 1.3.101.112).
167276
- // This prevents algorithm-confusion attacks if the embedded key were ever
167277
- // swapped to a different type.
167278
- if (publicKey.asymmetricKeyType !== 'ed25519') {
167279
- return null;
167280
- }
167281
- // Ed25519 verification: algorithm must be null because EdDSA performs its
167282
- // own internal hashing (SHA-512) — passing a digest algorithm here would
167283
- // cause Node.js to throw. The key type is validated above.
167284
- const isValid = crypto.verify(null, Buffer.from(data), publicKey, signature);
167285
- if (!isValid)
167286
- return null;
167287
- // Decode payload
167288
- const payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString());
167289
- // Validate required fields
167290
- if (!payload.org ||
167291
- !Array.isArray(payload.features) ||
167292
- typeof payload.exp !== 'number' ||
167293
- typeof payload.iat !== 'number' ||
167294
- !payload.sub) {
167295
- return null;
167296
- }
167297
- // Check expiry (with grace period)
167298
- const now = Date.now();
167299
- const expiryMs = payload.exp * 1000;
167300
- if (now >= expiryMs + LicenseValidator.GRACE_PERIOD) {
167301
- return null;
167302
- }
167303
- return payload;
167304
- }
167305
- catch {
167306
- return null;
167307
- }
167308
- }
167309
- }
167310
- exports.LicenseValidator = LicenseValidator;
167311
-
167312
-
167313
- /***/ }),
167314
-
167315
- /***/ 87068:
167316
- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167317
-
167318
- "use strict";
167319
-
167320
- /**
167321
- * Copyright (c) ProbeLabs. All rights reserved.
167322
- * Licensed under the Elastic License 2.0; you may not use this file except
167323
- * in compliance with the Elastic License 2.0.
167324
- */
167325
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167326
- if (k2 === undefined) k2 = k;
167327
- var desc = Object.getOwnPropertyDescriptor(m, k);
167328
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167329
- desc = { enumerable: true, get: function() { return m[k]; } };
167330
- }
167331
- Object.defineProperty(o, k2, desc);
167332
- }) : (function(o, m, k, k2) {
167333
- if (k2 === undefined) k2 = k;
167334
- o[k2] = m[k];
167335
- }));
167336
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167337
- Object.defineProperty(o, "default", { enumerable: true, value: v });
167338
- }) : function(o, v) {
167339
- o["default"] = v;
167340
- });
167341
- var __importStar = (this && this.__importStar) || (function () {
167342
- var ownKeys = function(o) {
167343
- ownKeys = Object.getOwnPropertyNames || function (o) {
167344
- var ar = [];
167345
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167346
- return ar;
167347
- };
167348
- return ownKeys(o);
167349
- };
167350
- return function (mod) {
167351
- if (mod && mod.__esModule) return mod;
167352
- var result = {};
167353
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167354
- __setModuleDefault(result, mod);
167355
- return result;
167356
- };
167357
- })();
167358
- Object.defineProperty(exports, "__esModule", ({ value: true }));
167359
- exports.loadEnterprisePolicyEngine = loadEnterprisePolicyEngine;
167360
- exports.loadEnterpriseStoreBackend = loadEnterpriseStoreBackend;
167361
- const default_engine_1 = __nccwpck_require__(93866);
167362
- /**
167363
- * Load the enterprise policy engine if licensed, otherwise return the default no-op engine.
167364
- *
167365
- * This is the sole import boundary between OSS and enterprise code. Core code
167366
- * must only import from this module (via dynamic `await import()`), never from
167367
- * individual enterprise submodules.
167368
- */
167369
- async function loadEnterprisePolicyEngine(config) {
167370
- try {
167371
- const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167372
- const validator = new LicenseValidator();
167373
- const license = await validator.loadAndValidate();
167374
- if (!license || !validator.hasFeature('policy')) {
167375
- return new default_engine_1.DefaultPolicyEngine();
167376
- }
167377
- if (validator.isInGracePeriod()) {
167378
- // eslint-disable-next-line no-console
167379
- console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167380
- 'Please renew your license.');
167381
- }
167382
- const { OpaPolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(39530)));
167383
- const engine = new OpaPolicyEngine(config);
167384
- await engine.initialize(config);
167385
- return engine;
167386
- }
167387
- catch (err) {
167388
- // Enterprise code not available or initialization failed
167389
- const msg = err instanceof Error ? err.message : String(err);
167390
- try {
167391
- const { logger } = __nccwpck_require__(86999);
167392
- logger.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
167393
- }
167394
- catch {
167395
- // silent
167396
- }
167397
- return new default_engine_1.DefaultPolicyEngine();
167398
- }
167399
- }
167400
- /**
167401
- * Load the enterprise schedule store backend if licensed.
167402
- *
167403
- * @param driver Database driver ('postgresql', 'mysql', or 'mssql')
167404
- * @param storageConfig Storage configuration with connection details
167405
- * @param haConfig Optional HA configuration
167406
- * @throws Error if enterprise license is not available or missing 'scheduler-sql' feature
167407
- */
167408
- async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
167409
- const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167410
- const validator = new LicenseValidator();
167411
- const license = await validator.loadAndValidate();
167412
- if (!license || !validator.hasFeature('scheduler-sql')) {
167413
- throw new Error(`The ${driver} schedule storage driver requires a Visor Enterprise license ` +
167414
- `with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`);
167415
- }
167416
- if (validator.isInGracePeriod()) {
167417
- // eslint-disable-next-line no-console
167418
- console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167419
- 'Please renew your license.');
167420
- }
167421
- const { KnexStoreBackend } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(63737)));
167422
- return new KnexStoreBackend(driver, storageConfig, haConfig);
167423
- }
167424
-
167425
-
167426
- /***/ }),
167427
-
167428
- /***/ 628:
167429
- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167430
-
167431
- "use strict";
167432
-
167433
- /**
167434
- * Copyright (c) ProbeLabs. All rights reserved.
167435
- * Licensed under the Elastic License 2.0; you may not use this file except
167436
- * in compliance with the Elastic License 2.0.
167437
- */
167438
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167439
- if (k2 === undefined) k2 = k;
167440
- var desc = Object.getOwnPropertyDescriptor(m, k);
167441
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167442
- desc = { enumerable: true, get: function() { return m[k]; } };
167443
- }
167444
- Object.defineProperty(o, k2, desc);
167445
- }) : (function(o, m, k, k2) {
167446
- if (k2 === undefined) k2 = k;
167447
- o[k2] = m[k];
167448
- }));
167449
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167450
- Object.defineProperty(o, "default", { enumerable: true, value: v });
167451
- }) : function(o, v) {
167452
- o["default"] = v;
167453
- });
167454
- var __importStar = (this && this.__importStar) || (function () {
167455
- var ownKeys = function(o) {
167456
- ownKeys = Object.getOwnPropertyNames || function (o) {
167457
- var ar = [];
167458
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167459
- return ar;
167460
- };
167461
- return ownKeys(o);
167462
- };
167463
- return function (mod) {
167464
- if (mod && mod.__esModule) return mod;
167465
- var result = {};
167466
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167467
- __setModuleDefault(result, mod);
167468
- return result;
167469
- };
167470
- })();
167471
- Object.defineProperty(exports, "__esModule", ({ value: true }));
167472
- exports.OpaCompiler = void 0;
167473
- const fs = __importStar(__nccwpck_require__(79896));
167474
- const path = __importStar(__nccwpck_require__(16928));
167475
- const os = __importStar(__nccwpck_require__(70857));
167476
- const crypto = __importStar(__nccwpck_require__(76982));
167477
- const child_process_1 = __nccwpck_require__(35317);
167478
- /**
167479
- * OPA Rego Compiler - compiles .rego policy files to WASM bundles using the `opa` CLI.
167480
- *
167481
- * Handles:
167482
- * - Resolving input paths to WASM bytes (direct .wasm, directory with policy.wasm, or .rego files)
167483
- * - Compiling .rego files to WASM via `opa build`
167484
- * - Caching compiled bundles based on content hashes
167485
- * - Extracting policy.wasm from OPA tar.gz bundles
167486
- *
167487
- * Requires:
167488
- * - `opa` CLI on PATH (only when auto-compiling .rego files)
167489
- */
167490
- class OpaCompiler {
167491
- static CACHE_DIR = path.join(os.tmpdir(), 'visor-opa-cache');
167492
- /**
167493
- * Resolve the input paths to WASM bytes.
167494
- *
167495
- * Strategy:
167496
- * 1. If any path is a .wasm file, read it directly
167497
- * 2. If a directory contains policy.wasm, read it
167498
- * 3. Otherwise, collect all .rego files and auto-compile via `opa build`
167499
- */
167500
- async resolveWasmBytes(paths) {
167501
- // Collect .rego files and check for existing .wasm
167502
- const regoFiles = [];
167503
- for (const p of paths) {
167504
- const resolved = path.resolve(p);
167505
- // Reject paths containing '..' after resolution (path traversal)
167506
- if (path.normalize(resolved).includes('..')) {
167507
- throw new Error(`Policy path contains traversal sequences: ${p}`);
167508
- }
167509
- // Direct .wasm file
167510
- if (resolved.endsWith('.wasm') && fs.existsSync(resolved)) {
167511
- return fs.readFileSync(resolved);
167512
- }
167513
- if (!fs.existsSync(resolved))
167514
- continue;
167515
- const stat = fs.statSync(resolved);
167516
- if (stat.isDirectory()) {
167517
- // Check for pre-compiled policy.wasm in directory
167518
- const wasmCandidate = path.join(resolved, 'policy.wasm');
167519
- if (fs.existsSync(wasmCandidate)) {
167520
- return fs.readFileSync(wasmCandidate);
167521
- }
167522
- // Collect all .rego files from directory
167523
- const files = fs.readdirSync(resolved);
167524
- for (const f of files) {
167525
- if (f.endsWith('.rego')) {
167526
- regoFiles.push(path.join(resolved, f));
167527
- }
167528
- }
167529
- }
167530
- else if (resolved.endsWith('.rego')) {
167531
- regoFiles.push(resolved);
167532
- }
167533
- }
167534
- if (regoFiles.length === 0) {
167535
- throw new Error(`OPA WASM evaluator: no .wasm bundle or .rego files found in: ${paths.join(', ')}`);
167536
- }
167537
- // Auto-compile .rego -> .wasm
167538
- return this.compileRego(regoFiles);
167539
- }
167540
- /**
167541
- * Auto-compile .rego files to a WASM bundle using the `opa` CLI.
167542
- *
167543
- * Caches the compiled bundle based on a content hash of all input .rego files
167544
- * so subsequent runs skip compilation if policies haven't changed.
167545
- */
167546
- compileRego(regoFiles) {
167547
- // Check that `opa` CLI is available
167548
- try {
167549
- (0, child_process_1.execFileSync)('opa', ['version'], { stdio: 'pipe' });
167550
- }
167551
- catch {
167552
- throw new Error('OPA CLI (`opa`) not found on PATH. Install it from https://www.openpolicyagent.org/docs/latest/#running-opa\n' +
167553
- 'Or pre-compile your .rego files: opa build -t wasm -e visor -o bundle.tar.gz ' +
167554
- regoFiles.join(' '));
167555
- }
167556
- // Compute content hash for cache key
167557
- const hash = crypto.createHash('sha256');
167558
- for (const f of regoFiles.sort()) {
167559
- hash.update(fs.readFileSync(f));
167560
- hash.update(f); // include filename for disambiguation
167561
- }
167562
- const cacheKey = hash.digest('hex').slice(0, 16);
167563
- const cacheDir = OpaCompiler.CACHE_DIR;
167564
- const cachedWasm = path.join(cacheDir, `${cacheKey}.wasm`);
167565
- // Return cached bundle if still valid
167566
- if (fs.existsSync(cachedWasm)) {
167567
- return fs.readFileSync(cachedWasm);
167568
- }
167569
- // Compile to WASM via opa build
167570
- fs.mkdirSync(cacheDir, { recursive: true });
167571
- const bundleTar = path.join(cacheDir, `${cacheKey}-bundle.tar.gz`);
167572
- try {
167573
- const args = [
167574
- 'build',
167575
- '-t',
167576
- 'wasm',
167577
- '-e',
167578
- 'visor', // entrypoint: the visor package tree
167579
- '-o',
167580
- bundleTar,
167581
- ...regoFiles,
167582
- ];
167583
- (0, child_process_1.execFileSync)('opa', args, {
167584
- stdio: 'pipe',
167585
- timeout: 30000,
167586
- });
167587
- }
167588
- catch (err) {
167589
- const stderr = err?.stderr?.toString() || '';
167590
- throw new Error(`Failed to compile .rego files to WASM:\n${stderr}\n` +
167591
- 'Ensure your .rego files are valid and the `opa` CLI is installed.');
167592
- }
167593
- // Extract policy.wasm from the tar.gz bundle
167594
- // OPA bundles are tar.gz with /policy.wasm inside
167595
- try {
167596
- (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, '/policy.wasm'], {
167597
- stdio: 'pipe',
167598
- });
167599
- const extractedWasm = path.join(cacheDir, 'policy.wasm');
167600
- if (fs.existsSync(extractedWasm)) {
167601
- // Move to cache-key named file
167602
- fs.renameSync(extractedWasm, cachedWasm);
167603
- }
167604
- }
167605
- catch {
167606
- // Some tar implementations don't like leading /
167607
- try {
167608
- (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, 'policy.wasm'], {
167609
- stdio: 'pipe',
167610
- });
167611
- const extractedWasm = path.join(cacheDir, 'policy.wasm');
167612
- if (fs.existsSync(extractedWasm)) {
167613
- fs.renameSync(extractedWasm, cachedWasm);
167614
- }
167615
- }
167616
- catch (err2) {
167617
- throw new Error(`Failed to extract policy.wasm from OPA bundle: ${err2?.message || err2}`);
167618
- }
167619
- }
167620
- // Clean up tar
167621
- try {
167622
- fs.unlinkSync(bundleTar);
167623
- }
167624
- catch { }
167625
- if (!fs.existsSync(cachedWasm)) {
167626
- throw new Error('OPA build succeeded but policy.wasm was not found in the bundle');
167627
- }
167628
- return fs.readFileSync(cachedWasm);
167629
- }
167630
- }
167631
- exports.OpaCompiler = OpaCompiler;
167632
-
167633
-
167634
- /***/ }),
167635
-
167636
- /***/ 44693:
167637
- /***/ ((__unused_webpack_module, exports) => {
167638
-
167639
- "use strict";
167640
-
167641
- /**
167642
- * Copyright (c) ProbeLabs. All rights reserved.
167643
- * Licensed under the Elastic License 2.0; you may not use this file except
167644
- * in compliance with the Elastic License 2.0.
167645
- */
167646
- Object.defineProperty(exports, "__esModule", ({ value: true }));
167647
- exports.OpaHttpEvaluator = void 0;
167648
- /**
167649
- * OPA HTTP Evaluator - evaluates policies via an external OPA server's REST API.
167650
- *
167651
- * Uses the built-in `fetch` API (Node 18+), so no extra dependencies are needed.
167652
- */
167653
- class OpaHttpEvaluator {
167654
- baseUrl;
167655
- timeout;
167656
- constructor(baseUrl, timeout = 5000) {
167657
- // Validate URL format and protocol
167658
- let parsed;
167659
- try {
167660
- parsed = new URL(baseUrl);
167661
- }
167662
- catch {
167663
- throw new Error(`OPA HTTP evaluator: invalid URL: ${baseUrl}`);
167664
- }
167665
- if (!['http:', 'https:'].includes(parsed.protocol)) {
167666
- throw new Error(`OPA HTTP evaluator: url must use http:// or https:// protocol, got: ${baseUrl}`);
167667
- }
167668
- // Block cloud metadata, loopback, link-local, and private network addresses
167669
- const hostname = parsed.hostname;
167670
- if (this.isBlockedHostname(hostname)) {
167671
- throw new Error(`OPA HTTP evaluator: url must not point to internal, loopback, or private network addresses`);
167672
- }
167673
- // Normalize: strip trailing slash
167674
- this.baseUrl = baseUrl.replace(/\/+$/, '');
167675
- this.timeout = timeout;
167676
- }
167677
- /**
167678
- * Check if a hostname is blocked due to SSRF concerns.
167679
- *
167680
- * Blocks:
167681
- * - Loopback addresses (127.x.x.x, localhost, 0.0.0.0, ::1)
167682
- * - Link-local addresses (169.254.x.x)
167683
- * - Private networks (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
167684
- * - IPv6 unique local addresses (fd00::/8)
167685
- * - Cloud metadata services (*.internal)
167686
- */
167687
- isBlockedHostname(hostname) {
167688
- if (!hostname)
167689
- return true; // block empty hostnames
167690
- // Normalize hostname: lowercase and remove brackets for IPv6
167691
- const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
167692
- // Block .internal domains (cloud metadata services)
167693
- if (normalized === 'metadata.google.internal' || normalized.endsWith('.internal')) {
167694
- return true;
167695
- }
167696
- // Block localhost variants
167697
- if (normalized === 'localhost' || normalized === 'localhost.localdomain') {
167698
- return true;
167699
- }
167700
- // Block IPv6 loopback
167701
- if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
167702
- return true;
167703
- }
167704
- // Check IPv4 patterns
167705
- const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
167706
- const ipv4Match = normalized.match(ipv4Pattern);
167707
- if (ipv4Match) {
167708
- const octets = ipv4Match.slice(1, 5).map(Number);
167709
- // Validate octets are in range [0, 255]
167710
- if (octets.some(octet => octet > 255)) {
167711
- return false;
167712
- }
167713
- const [a, b] = octets;
167714
- // Block loopback: 127.0.0.0/8
167715
- if (a === 127) {
167716
- return true;
167717
- }
167718
- // Block 0.0.0.0/8 (this host)
167719
- if (a === 0) {
167720
- return true;
167721
- }
167722
- // Block link-local: 169.254.0.0/16
167723
- if (a === 169 && b === 254) {
167724
- return true;
167725
- }
167726
- // Block private networks
167727
- // 10.0.0.0/8
167728
- if (a === 10) {
167729
- return true;
167730
- }
167731
- // 172.16.0.0/12 (172.16.x.x through 172.31.x.x)
167732
- if (a === 172 && b >= 16 && b <= 31) {
167733
- return true;
167734
- }
167735
- // 192.168.0.0/16
167736
- if (a === 192 && b === 168) {
167737
- return true;
167738
- }
167739
- }
167740
- // Check IPv6 patterns
167741
- // Block unique local addresses: fd00::/8
167742
- if (normalized.startsWith('fd') || normalized.startsWith('fc')) {
167743
- return true;
167744
- }
167745
- // Block link-local: fe80::/10
167746
- if (normalized.startsWith('fe80:')) {
167747
- return true;
167748
- }
167749
- return false;
167750
- }
167751
- /**
167752
- * Evaluate a policy rule against an input document via OPA REST API.
167753
- *
167754
- * @param input - The input document to evaluate
167755
- * @param rulePath - OPA rule path (e.g., 'visor/check/execute')
167756
- * @returns The result object from OPA, or undefined on error
167757
- */
167758
- async evaluate(input, rulePath) {
167759
- // OPA Data API: POST /v1/data/<path>
167760
- const encodedPath = rulePath
167761
- .split('/')
167762
- .map(s => encodeURIComponent(s))
167763
- .join('/');
167764
- const url = `${this.baseUrl}/v1/data/${encodedPath}`;
167765
- const controller = new AbortController();
167766
- const timer = setTimeout(() => controller.abort(), this.timeout);
167767
- try {
167768
- const response = await fetch(url, {
167769
- method: 'POST',
167770
- headers: { 'Content-Type': 'application/json' },
167771
- body: JSON.stringify({ input }),
167772
- signal: controller.signal,
167773
- });
167774
- if (!response.ok) {
167775
- throw new Error(`OPA HTTP ${response.status}: ${response.statusText}`);
167776
- }
167777
- let body;
167778
- try {
167779
- body = await response.json();
167780
- }
167781
- catch (jsonErr) {
167782
- throw new Error(`OPA HTTP evaluator: failed to parse JSON response: ${jsonErr instanceof Error ? jsonErr.message : String(jsonErr)}`);
167783
- }
167784
- // OPA returns { result: { ... } }
167785
- return body?.result;
167786
- }
167787
- finally {
167788
- clearTimeout(timer);
167789
- }
167790
- }
167791
- async shutdown() {
167792
- // No persistent connections to close
167793
- }
167794
- }
167795
- exports.OpaHttpEvaluator = OpaHttpEvaluator;
167796
-
167797
-
167798
- /***/ }),
167799
-
167800
- /***/ 39530:
167801
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
167802
-
167803
- "use strict";
167804
-
167805
- /**
167806
- * Copyright (c) ProbeLabs. All rights reserved.
167807
- * Licensed under the Elastic License 2.0; you may not use this file except
167808
- * in compliance with the Elastic License 2.0.
167809
- */
167810
- Object.defineProperty(exports, "__esModule", ({ value: true }));
167811
- exports.OpaPolicyEngine = void 0;
167812
- const opa_wasm_evaluator_1 = __nccwpck_require__(8613);
167813
- const opa_http_evaluator_1 = __nccwpck_require__(44693);
167814
- const policy_input_builder_1 = __nccwpck_require__(17117);
167815
- /**
167816
- * Enterprise OPA Policy Engine.
167817
- *
167818
- * Wraps both WASM (local) and HTTP (remote) OPA evaluators behind the
167819
- * OSS PolicyEngine interface. All OPA input building and role resolution
167820
- * is handled internally — the OSS call sites pass only plain types.
167821
- */
167822
- class OpaPolicyEngine {
167823
- evaluator = null;
167824
- fallback;
167825
- timeout;
167826
- config;
167827
- inputBuilder = null;
167828
- logger = null;
167829
- constructor(config) {
167830
- this.config = config;
167831
- this.fallback = config.fallback || 'deny';
167832
- this.timeout = config.timeout || 5000;
167833
- }
167834
- async initialize(config) {
167835
- // Resolve logger once at initialization
167836
- try {
167837
- this.logger = (__nccwpck_require__(86999).logger);
167838
- }
167839
- catch {
167840
- // logger not available in this context
167841
- }
167842
- // Build actor/repo context from environment (available at engine init time)
167843
- const actor = {
167844
- authorAssociation: process.env.VISOR_AUTHOR_ASSOCIATION,
167845
- login: process.env.VISOR_AUTHOR_LOGIN || process.env.GITHUB_ACTOR,
167846
- isLocalMode: !process.env.GITHUB_ACTIONS,
167847
- };
167848
- const repo = {
167849
- owner: process.env.GITHUB_REPOSITORY_OWNER,
167850
- name: process.env.GITHUB_REPOSITORY?.split('/')[1],
167851
- branch: process.env.GITHUB_HEAD_REF,
167852
- baseBranch: process.env.GITHUB_BASE_REF,
167853
- event: process.env.GITHUB_EVENT_NAME,
167854
- };
167855
- const prNum = process.env.GITHUB_PR_NUMBER
167856
- ? parseInt(process.env.GITHUB_PR_NUMBER, 10)
167857
- : undefined;
167858
- const pullRequest = {
167859
- number: prNum !== undefined && Number.isFinite(prNum) ? prNum : undefined,
167860
- };
167861
- this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(config, actor, repo, pullRequest);
167862
- if (config.engine === 'local') {
167863
- if (!config.rules) {
167864
- throw new Error('OPA local mode requires `policy.rules` path to .wasm or .rego files');
167865
- }
167866
- const wasm = new opa_wasm_evaluator_1.OpaWasmEvaluator();
167867
- await wasm.initialize(config.rules);
167868
- if (config.data) {
167869
- wasm.loadData(config.data);
167870
- }
167871
- this.evaluator = wasm;
167872
- }
167873
- else if (config.engine === 'remote') {
167874
- if (!config.url) {
167875
- throw new Error('OPA remote mode requires `policy.url` pointing to OPA server');
167876
- }
167877
- this.evaluator = new opa_http_evaluator_1.OpaHttpEvaluator(config.url, this.timeout);
167878
- }
167879
- else {
167880
- this.evaluator = null;
167881
- }
167882
- }
167883
- /**
167884
- * Update actor/repo/PR context (e.g., after PR info becomes available).
167885
- * Called by the enterprise loader when engine context is enriched.
167886
- */
167887
- setActorContext(actor, repo, pullRequest) {
167888
- this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(this.config, actor, repo, pullRequest);
167889
- }
167890
- async evaluateCheckExecution(checkId, checkConfig) {
167891
- if (!this.evaluator || !this.inputBuilder)
167892
- return { allowed: true };
167893
- const cfg = checkConfig && typeof checkConfig === 'object'
167894
- ? checkConfig
167895
- : {};
167896
- const policyOverride = cfg.policy;
167897
- const input = this.inputBuilder.forCheckExecution({
167898
- id: checkId,
167899
- type: cfg.type || 'ai',
167900
- group: cfg.group,
167901
- tags: cfg.tags,
167902
- criticality: cfg.criticality,
167903
- sandbox: cfg.sandbox,
167904
- policy: policyOverride,
167905
- });
167906
- return this.doEvaluate(input, this.resolveRulePath('check.execute', policyOverride?.rule));
167907
- }
167908
- async evaluateToolInvocation(serverName, methodName, transport) {
167909
- if (!this.evaluator || !this.inputBuilder)
167910
- return { allowed: true };
167911
- const input = this.inputBuilder.forToolInvocation(serverName, methodName, transport);
167912
- return this.doEvaluate(input, 'visor/tool/invoke');
167913
- }
167914
- async evaluateCapabilities(checkId, capabilities) {
167915
- if (!this.evaluator || !this.inputBuilder)
167916
- return { allowed: true };
167917
- const input = this.inputBuilder.forCapabilityResolve(checkId, capabilities);
167918
- return this.doEvaluate(input, 'visor/capability/resolve');
167919
- }
167920
- async shutdown() {
167921
- if (this.evaluator && 'shutdown' in this.evaluator) {
167922
- await this.evaluator.shutdown();
167923
- }
167924
- this.evaluator = null;
167925
- this.inputBuilder = null;
167926
- }
167927
- resolveRulePath(defaultScope, override) {
167928
- if (override) {
167929
- return override.startsWith('visor/') ? override : `visor/${override}`;
167930
- }
167931
- return `visor/${defaultScope.replace(/\./g, '/')}`;
167932
- }
167933
- async doEvaluate(input, rulePath) {
167934
- try {
167935
- this.logger?.debug(`[PolicyEngine] Evaluating ${rulePath}`, JSON.stringify(input));
167936
- let timer;
167937
- const timeoutPromise = new Promise((_resolve, reject) => {
167938
- timer = setTimeout(() => reject(new Error('policy evaluation timeout')), this.timeout);
167939
- });
167940
- try {
167941
- const result = await Promise.race([this.rawEvaluate(input, rulePath), timeoutPromise]);
167942
- const decision = this.parseDecision(result);
167943
- // In warn mode, override denied decisions to allowed but flag as warn
167944
- if (!decision.allowed && this.fallback === 'warn') {
167945
- decision.allowed = true;
167946
- decision.warn = true;
167947
- decision.reason = `audit: ${decision.reason || 'policy denied'}`;
167948
- }
167949
- this.logger?.debug(`[PolicyEngine] Decision for ${rulePath}: allowed=${decision.allowed}, warn=${decision.warn || false}, reason=${decision.reason || 'none'}`);
167950
- return decision;
167951
- }
167952
- finally {
167953
- if (timer)
167954
- clearTimeout(timer);
167955
- }
167956
- }
167957
- catch (err) {
167958
- const msg = err instanceof Error ? err.message : String(err);
167959
- this.logger?.warn(`[PolicyEngine] Evaluation failed for ${rulePath}: ${msg}`);
167960
- return {
167961
- allowed: this.fallback === 'allow' || this.fallback === 'warn',
167962
- warn: this.fallback === 'warn' ? true : undefined,
167963
- reason: `policy evaluation failed, fallback=${this.fallback}`,
167964
- };
167965
- }
167966
- }
167967
- async rawEvaluate(input, rulePath) {
167968
- if (this.evaluator instanceof opa_wasm_evaluator_1.OpaWasmEvaluator) {
167969
- const result = await this.evaluator.evaluate(input);
167970
- // WASM compiled with `-e visor` entrypoint returns the full visor package tree.
167971
- // Navigate to the specific rule subtree using rulePath segments.
167972
- // e.g., 'visor/check/execute' → result.check.execute
167973
- return this.navigateWasmResult(result, rulePath);
167974
- }
167975
- return this.evaluator.evaluate(input, rulePath);
167976
- }
167977
- /**
167978
- * Navigate nested OPA WASM result tree to reach the specific rule's output.
167979
- * The WASM entrypoint `-e visor` means the result root IS the visor package,
167980
- * so we strip the `visor/` prefix and walk the remaining segments.
167981
- */
167982
- navigateWasmResult(result, rulePath) {
167983
- if (!result || typeof result !== 'object')
167984
- return result;
167985
- // Strip the 'visor/' prefix (matches our compilation entrypoint)
167986
- const segments = rulePath.replace(/^visor\//, '').split('/');
167987
- let current = result;
167988
- for (const seg of segments) {
167989
- if (current && typeof current === 'object' && seg in current) {
167990
- current = current[seg];
167991
- }
167992
- else {
167993
- return undefined; // path not found in result tree
167994
- }
167995
- }
167996
- return current;
167997
- }
167998
- parseDecision(result) {
167999
- if (result === undefined || result === null) {
168000
- return {
168001
- allowed: this.fallback === 'allow' || this.fallback === 'warn',
168002
- warn: this.fallback === 'warn' ? true : undefined,
168003
- reason: this.fallback === 'warn' ? 'audit: no policy result' : 'no policy result',
168004
- };
168005
- }
168006
- const allowed = result.allowed !== false;
168007
- const decision = {
168008
- allowed,
168009
- reason: result.reason,
168010
- };
168011
- if (result.capabilities) {
168012
- decision.capabilities = result.capabilities;
168013
- }
168014
- return decision;
168015
- }
168016
- }
168017
- exports.OpaPolicyEngine = OpaPolicyEngine;
168018
-
168019
-
168020
- /***/ }),
168021
-
168022
- /***/ 8613:
168023
- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
168024
-
168025
- "use strict";
168026
-
168027
- /**
168028
- * Copyright (c) ProbeLabs. All rights reserved.
168029
- * Licensed under the Elastic License 2.0; you may not use this file except
168030
- * in compliance with the Elastic License 2.0.
168031
- */
168032
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
168033
- if (k2 === undefined) k2 = k;
168034
- var desc = Object.getOwnPropertyDescriptor(m, k);
168035
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
168036
- desc = { enumerable: true, get: function() { return m[k]; } };
168037
- }
168038
- Object.defineProperty(o, k2, desc);
168039
- }) : (function(o, m, k, k2) {
168040
- if (k2 === undefined) k2 = k;
168041
- o[k2] = m[k];
168042
- }));
168043
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
168044
- Object.defineProperty(o, "default", { enumerable: true, value: v });
168045
- }) : function(o, v) {
168046
- o["default"] = v;
168047
- });
168048
- var __importStar = (this && this.__importStar) || (function () {
168049
- var ownKeys = function(o) {
168050
- ownKeys = Object.getOwnPropertyNames || function (o) {
168051
- var ar = [];
168052
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
168053
- return ar;
168054
- };
168055
- return ownKeys(o);
168056
- };
168057
- return function (mod) {
168058
- if (mod && mod.__esModule) return mod;
168059
- var result = {};
168060
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
168061
- __setModuleDefault(result, mod);
168062
- return result;
168063
- };
168064
- })();
168065
- Object.defineProperty(exports, "__esModule", ({ value: true }));
168066
- exports.OpaWasmEvaluator = void 0;
168067
- const fs = __importStar(__nccwpck_require__(79896));
168068
- const path = __importStar(__nccwpck_require__(16928));
168069
- const opa_compiler_1 = __nccwpck_require__(628);
168070
- /**
168071
- * OPA WASM Evaluator - loads and evaluates OPA policies locally.
168072
- *
168073
- * Supports three input formats:
168074
- * 1. Pre-compiled `.wasm` bundle — loaded directly (fastest startup)
168075
- * 2. `.rego` files or directory — auto-compiled to WASM via `opa build` CLI
168076
- * 3. Directory with `policy.wasm` inside — loaded directly
168077
- *
168078
- * Compilation and caching of .rego files is delegated to {@link OpaCompiler}.
168079
- *
168080
- * Requires:
168081
- * - `@open-policy-agent/opa-wasm` npm package (optional dep)
168082
- * - `opa` CLI on PATH (only when auto-compiling .rego files)
168083
- */
168084
- class OpaWasmEvaluator {
168085
- policy = null;
168086
- dataDocument = {};
168087
- compiler = new opa_compiler_1.OpaCompiler();
168088
- async initialize(rulesPath) {
168089
- const paths = Array.isArray(rulesPath) ? rulesPath : [rulesPath];
168090
- const wasmBytes = await this.compiler.resolveWasmBytes(paths);
168091
- try {
168092
- // Use createRequire to load the optional dep at runtime without ncc bundling it.
168093
- // `new Function('id', 'return require(id)')` fails in ncc bundles because
168094
- // `require` is not in the `new Function` scope. `createRequire` works correctly
168095
- // because it creates a real Node.js require rooted at the given path.
168096
- // eslint-disable-next-line @typescript-eslint/no-var-requires
168097
- const { createRequire } = __nccwpck_require__(73339);
168098
- const runtimeRequire = createRequire(__filename);
168099
- const opaWasm = runtimeRequire('@open-policy-agent/opa-wasm');
168100
- const loadPolicy = opaWasm.loadPolicy || opaWasm.default?.loadPolicy;
168101
- if (!loadPolicy) {
168102
- throw new Error('loadPolicy not found in @open-policy-agent/opa-wasm');
168103
- }
168104
- this.policy = await loadPolicy(wasmBytes);
168105
- }
168106
- catch (err) {
168107
- if (err?.code === 'MODULE_NOT_FOUND' || err?.code === 'ERR_MODULE_NOT_FOUND') {
168108
- throw new Error('OPA WASM evaluator requires @open-policy-agent/opa-wasm. ' +
168109
- 'Install it with: npm install @open-policy-agent/opa-wasm');
168110
- }
168111
- throw err;
168112
- }
168113
- }
168114
- /**
168115
- * Load external data from a JSON file to use as the OPA data document.
168116
- * The loaded data will be passed to `policy.setData()` during evaluation,
168117
- * making it available in Rego via `data.<key>`.
168118
- */
168119
- loadData(dataPath) {
168120
- const resolved = path.resolve(dataPath);
168121
- if (path.normalize(resolved).includes('..')) {
168122
- throw new Error(`Data path contains traversal sequences: ${dataPath}`);
168123
- }
168124
- if (!fs.existsSync(resolved)) {
168125
- throw new Error(`OPA data file not found: ${resolved}`);
168126
- }
168127
- const stat = fs.statSync(resolved);
168128
- if (stat.size > 10 * 1024 * 1024) {
168129
- throw new Error(`OPA data file exceeds 10MB limit: ${resolved} (${stat.size} bytes)`);
168130
- }
168131
- const raw = fs.readFileSync(resolved, 'utf-8');
168132
- try {
168133
- const parsed = JSON.parse(raw);
168134
- if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
168135
- throw new Error('OPA data file must contain a JSON object (not an array or primitive)');
168136
- }
168137
- this.dataDocument = parsed;
168138
- }
168139
- catch (err) {
168140
- if (err.message.startsWith('OPA data file must')) {
168141
- throw err;
168142
- }
168143
- throw new Error(`Failed to parse OPA data file ${resolved}: ${err.message}`);
168144
- }
168145
- }
168146
- async evaluate(input) {
168147
- if (!this.policy) {
168148
- throw new Error('OPA WASM evaluator not initialized');
168149
- }
168150
- this.policy.setData(this.dataDocument);
168151
- const resultSet = this.policy.evaluate(input);
168152
- if (Array.isArray(resultSet) && resultSet.length > 0) {
168153
- return resultSet[0].result;
168154
- }
168155
- return undefined;
168156
- }
168157
- async shutdown() {
168158
- if (this.policy) {
168159
- // opa-wasm policy objects may have a close/free method for WASM cleanup
168160
- if (typeof this.policy.close === 'function') {
168161
- try {
168162
- this.policy.close();
168163
- }
168164
- catch { }
168165
- }
168166
- else if (typeof this.policy.free === 'function') {
168167
- try {
168168
- this.policy.free();
168169
- }
168170
- catch { }
168171
- }
168172
- }
168173
- this.policy = null;
168174
- }
168175
- }
168176
- exports.OpaWasmEvaluator = OpaWasmEvaluator;
168177
-
168178
-
168179
- /***/ }),
168180
-
168181
- /***/ 17117:
168182
- /***/ ((__unused_webpack_module, exports) => {
168183
-
168184
- "use strict";
168185
-
168186
- /**
168187
- * Copyright (c) ProbeLabs. All rights reserved.
168188
- * Licensed under the Elastic License 2.0; you may not use this file except
168189
- * in compliance with the Elastic License 2.0.
168190
- */
168191
- Object.defineProperty(exports, "__esModule", ({ value: true }));
168192
- exports.PolicyInputBuilder = void 0;
168193
- /**
168194
- * Builds OPA-compatible input documents from engine context.
168195
- *
168196
- * Resolves actor roles from the `policy.roles` config section by matching
168197
- * the actor's authorAssociation and login against role definitions.
168198
- */
168199
- class PolicyInputBuilder {
168200
- roles;
168201
- actor;
168202
- repository;
168203
- pullRequest;
168204
- constructor(policyConfig, actor, repository, pullRequest) {
168205
- this.roles = policyConfig.roles || {};
168206
- this.actor = actor;
168207
- this.repository = repository;
168208
- this.pullRequest = pullRequest;
168209
- }
168210
- /** Resolve which roles apply to the current actor. */
168211
- resolveRoles() {
168212
- const matched = [];
168213
- for (const [roleName, roleConfig] of Object.entries(this.roles)) {
168214
- let identityMatch = false;
168215
- if (roleConfig.author_association &&
168216
- this.actor.authorAssociation &&
168217
- roleConfig.author_association.includes(this.actor.authorAssociation)) {
168218
- identityMatch = true;
168219
- }
168220
- if (!identityMatch &&
168221
- roleConfig.users &&
168222
- this.actor.login &&
168223
- roleConfig.users.includes(this.actor.login)) {
168224
- identityMatch = true;
168225
- }
168226
- // Slack user ID match
168227
- if (!identityMatch &&
168228
- roleConfig.slack_users &&
168229
- this.actor.slack?.userId &&
168230
- roleConfig.slack_users.includes(this.actor.slack.userId)) {
168231
- identityMatch = true;
168232
- }
168233
- // Email match (case-insensitive)
168234
- if (!identityMatch && roleConfig.emails && this.actor.slack?.email) {
168235
- const actorEmail = this.actor.slack.email.toLowerCase();
168236
- if (roleConfig.emails.some(e => e.toLowerCase() === actorEmail)) {
168237
- identityMatch = true;
168238
- }
168239
- }
168240
- // Note: teams-based role resolution requires GitHub API access (read:org scope)
168241
- // and is not yet implemented. If configured, the role will not match via teams.
168242
- if (!identityMatch)
168243
- continue;
168244
- // slack_channels gate: if set, the role only applies when triggered from one of these channels
168245
- if (roleConfig.slack_channels && roleConfig.slack_channels.length > 0) {
168246
- if (!this.actor.slack?.channelId ||
168247
- !roleConfig.slack_channels.includes(this.actor.slack.channelId)) {
168248
- continue;
168249
- }
168250
- }
168251
- matched.push(roleName);
168252
- }
168253
- return matched;
168254
- }
168255
- buildActor() {
168256
- return {
168257
- authorAssociation: this.actor.authorAssociation,
168258
- login: this.actor.login,
168259
- roles: this.resolveRoles(),
168260
- isLocalMode: this.actor.isLocalMode,
168261
- ...(this.actor.slack && { slack: this.actor.slack }),
168262
- };
168263
- }
168264
- forCheckExecution(check) {
168265
- return {
168266
- scope: 'check.execute',
168267
- check: {
168268
- id: check.id,
168269
- type: check.type,
168270
- group: check.group,
168271
- tags: check.tags,
168272
- criticality: check.criticality,
168273
- sandbox: check.sandbox,
168274
- policy: check.policy,
168275
- },
168276
- actor: this.buildActor(),
168277
- repository: this.repository,
168278
- pullRequest: this.pullRequest,
168279
- };
168280
- }
168281
- forToolInvocation(serverName, methodName, transport) {
168282
- return {
168283
- scope: 'tool.invoke',
168284
- tool: { serverName, methodName, transport },
168285
- actor: this.buildActor(),
168286
- repository: this.repository,
168287
- pullRequest: this.pullRequest,
168288
- };
168289
- }
168290
- forCapabilityResolve(checkId, capabilities) {
168291
- return {
168292
- scope: 'capability.resolve',
168293
- check: { id: checkId, type: 'ai' },
168294
- capability: capabilities,
168295
- actor: this.buildActor(),
168296
- repository: this.repository,
168297
- pullRequest: this.pullRequest,
168298
- };
168299
- }
168300
- }
168301
- exports.PolicyInputBuilder = PolicyInputBuilder;
168302
-
168303
-
168304
- /***/ }),
168305
-
168306
- /***/ 63737:
168307
- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
168308
-
168309
- "use strict";
168310
-
168311
- /**
168312
- * Copyright (c) ProbeLabs. All rights reserved.
168313
- * Licensed under the Elastic License 2.0; you may not use this file except
168314
- * in compliance with the Elastic License 2.0.
168315
- */
168316
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
168317
- if (k2 === undefined) k2 = k;
168318
- var desc = Object.getOwnPropertyDescriptor(m, k);
168319
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
168320
- desc = { enumerable: true, get: function() { return m[k]; } };
168321
- }
168322
- Object.defineProperty(o, k2, desc);
168323
- }) : (function(o, m, k, k2) {
168324
- if (k2 === undefined) k2 = k;
168325
- o[k2] = m[k];
168326
- }));
168327
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
168328
- Object.defineProperty(o, "default", { enumerable: true, value: v });
168329
- }) : function(o, v) {
168330
- o["default"] = v;
168331
- });
168332
- var __importStar = (this && this.__importStar) || (function () {
168333
- var ownKeys = function(o) {
168334
- ownKeys = Object.getOwnPropertyNames || function (o) {
168335
- var ar = [];
168336
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
168337
- return ar;
168338
- };
168339
- return ownKeys(o);
168340
- };
168341
- return function (mod) {
168342
- if (mod && mod.__esModule) return mod;
168343
- var result = {};
168344
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
168345
- __setModuleDefault(result, mod);
168346
- return result;
168347
- };
168348
- })();
168349
- Object.defineProperty(exports, "__esModule", ({ value: true }));
168350
- exports.KnexStoreBackend = void 0;
168351
- /**
168352
- * Knex-backed schedule store for PostgreSQL, MySQL, and MSSQL (Enterprise)
168353
- *
168354
- * Uses Knex query builder for database-agnostic SQL. Same schema as SQLite backend
168355
- * but with real distributed locking via row-level claims (claimed_by/claimed_at/lock_token).
168356
- */
168357
- const fs = __importStar(__nccwpck_require__(79896));
168358
- const path = __importStar(__nccwpck_require__(16928));
168359
- const uuid_1 = __nccwpck_require__(31914);
168360
- const logger_1 = __nccwpck_require__(86999);
168361
- function toNum(val) {
168362
- if (val === null || val === undefined)
168363
- return undefined;
168364
- return typeof val === 'string' ? parseInt(val, 10) : val;
168365
- }
168366
- function safeJsonParse(value) {
168367
- if (!value)
168368
- return undefined;
168369
- try {
168370
- return JSON.parse(value);
168371
- }
168372
- catch {
168373
- return undefined;
168374
- }
168375
- }
168376
- function fromTriggerRow(row) {
168377
- return {
168378
- id: row.id,
168379
- creatorId: row.creator_id,
168380
- creatorContext: row.creator_context ?? undefined,
168381
- creatorName: row.creator_name ?? undefined,
168382
- description: row.description ?? undefined,
168383
- channels: safeJsonParse(row.channels),
168384
- fromUsers: safeJsonParse(row.from_users),
168385
- fromBots: row.from_bots === true || row.from_bots === 1,
168386
- contains: safeJsonParse(row.contains),
168387
- matchPattern: row.match_pattern ?? undefined,
168388
- threads: row.threads,
168389
- workflow: row.workflow,
168390
- inputs: safeJsonParse(row.inputs),
168391
- outputContext: safeJsonParse(row.output_context),
168392
- status: row.status,
168393
- enabled: row.enabled === true || row.enabled === 1,
168394
- createdAt: toNum(row.created_at),
168395
- };
168396
- }
168397
- function toTriggerInsertRow(trigger) {
168398
- return {
168399
- id: trigger.id,
168400
- creator_id: trigger.creatorId,
168401
- creator_context: trigger.creatorContext ?? null,
168402
- creator_name: trigger.creatorName ?? null,
168403
- description: trigger.description ?? null,
168404
- channels: trigger.channels ? JSON.stringify(trigger.channels) : null,
168405
- from_users: trigger.fromUsers ? JSON.stringify(trigger.fromUsers) : null,
168406
- from_bots: trigger.fromBots,
168407
- contains: trigger.contains ? JSON.stringify(trigger.contains) : null,
168408
- match_pattern: trigger.matchPattern ?? null,
168409
- threads: trigger.threads,
168410
- workflow: trigger.workflow,
168411
- inputs: trigger.inputs ? JSON.stringify(trigger.inputs) : null,
168412
- output_context: trigger.outputContext ? JSON.stringify(trigger.outputContext) : null,
168413
- status: trigger.status,
168414
- enabled: trigger.enabled,
168415
- created_at: trigger.createdAt,
168416
- };
168417
- }
168418
- function fromDbRow(row) {
168419
- return {
168420
- id: row.id,
168421
- creatorId: row.creator_id,
168422
- creatorContext: row.creator_context ?? undefined,
168423
- creatorName: row.creator_name ?? undefined,
168424
- timezone: row.timezone,
168425
- schedule: row.schedule_expr,
168426
- runAt: toNum(row.run_at),
168427
- isRecurring: row.is_recurring === true || row.is_recurring === 1,
168428
- originalExpression: row.original_expression,
168429
- workflow: row.workflow ?? undefined,
168430
- workflowInputs: safeJsonParse(row.workflow_inputs),
168431
- outputContext: safeJsonParse(row.output_context),
168432
- status: row.status,
168433
- createdAt: toNum(row.created_at),
168434
- lastRunAt: toNum(row.last_run_at),
168435
- nextRunAt: toNum(row.next_run_at),
168436
- runCount: row.run_count,
168437
- failureCount: row.failure_count,
168438
- lastError: row.last_error ?? undefined,
168439
- previousResponse: row.previous_response ?? undefined,
168440
- };
168441
- }
168442
- function toInsertRow(schedule) {
168443
- return {
168444
- id: schedule.id,
168445
- creator_id: schedule.creatorId,
168446
- creator_context: schedule.creatorContext ?? null,
168447
- creator_name: schedule.creatorName ?? null,
168448
- timezone: schedule.timezone,
168449
- schedule_expr: schedule.schedule,
168450
- run_at: schedule.runAt ?? null,
168451
- is_recurring: schedule.isRecurring,
168452
- original_expression: schedule.originalExpression,
168453
- workflow: schedule.workflow ?? null,
168454
- workflow_inputs: schedule.workflowInputs ? JSON.stringify(schedule.workflowInputs) : null,
168455
- output_context: schedule.outputContext ? JSON.stringify(schedule.outputContext) : null,
168456
- status: schedule.status,
168457
- created_at: schedule.createdAt,
168458
- last_run_at: schedule.lastRunAt ?? null,
168459
- next_run_at: schedule.nextRunAt ?? null,
168460
- run_count: schedule.runCount,
168461
- failure_count: schedule.failureCount,
168462
- last_error: schedule.lastError ?? null,
168463
- previous_response: schedule.previousResponse ?? null,
168464
- };
168465
- }
168466
- /**
168467
- * Enterprise Knex-backed store for PostgreSQL, MySQL, and MSSQL
168468
- */
168469
- class KnexStoreBackend {
168470
- knex = null;
168471
- driver;
168472
- connection;
168473
- constructor(driver, storageConfig, _haConfig) {
168474
- this.driver = driver;
168475
- this.connection = (storageConfig.connection || {});
168476
- }
168477
- async initialize() {
168478
- // Load knex dynamically
168479
- const { createRequire } = __nccwpck_require__(73339);
168480
- const runtimeRequire = createRequire(__filename);
168481
- let knexFactory;
168482
- try {
168483
- knexFactory = runtimeRequire('knex');
168484
- }
168485
- catch (err) {
168486
- const code = err?.code;
168487
- if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
168488
- throw new Error('knex is required for PostgreSQL/MySQL/MSSQL schedule storage. ' +
168489
- 'Install it with: npm install knex');
168490
- }
168491
- throw err;
168492
- }
168493
- const clientMap = {
168494
- postgresql: 'pg',
168495
- mysql: 'mysql2',
168496
- mssql: 'tedious',
168497
- };
168498
- const client = clientMap[this.driver];
168499
- // Build connection config
168500
- let connection;
168501
- if (this.connection.connection_string) {
168502
- connection = this.connection.connection_string;
168503
- }
168504
- else if (this.driver === 'mssql') {
168505
- connection = this.buildMssqlConnection();
168506
- }
168507
- else {
168508
- connection = this.buildStandardConnection();
168509
- }
168510
- this.knex = knexFactory({
168511
- client,
168512
- connection,
168513
- pool: {
168514
- min: this.connection.pool?.min ?? 0,
168515
- max: this.connection.pool?.max ?? 10,
168516
- },
168517
- });
168518
- // Run schema migration
168519
- await this.migrateSchema();
168520
- logger_1.logger.info(`[KnexStore] Initialized (${this.driver})`);
168521
- }
168522
- buildStandardConnection() {
168523
- return {
168524
- host: this.connection.host || 'localhost',
168525
- port: this.connection.port,
168526
- database: this.connection.database || 'visor',
168527
- user: this.connection.user,
168528
- password: this.connection.password,
168529
- ssl: this.resolveSslConfig(),
168530
- };
168531
- }
168532
- buildMssqlConnection() {
168533
- const ssl = this.connection.ssl;
168534
- const sslEnabled = ssl === true || (typeof ssl === 'object' && ssl.enabled !== false);
168535
- return {
168536
- server: this.connection.host || 'localhost',
168537
- port: this.connection.port,
168538
- database: this.connection.database || 'visor',
168539
- user: this.connection.user,
168540
- password: this.connection.password,
168541
- options: {
168542
- encrypt: sslEnabled,
168543
- trustServerCertificate: typeof ssl === 'object' ? ssl.reject_unauthorized === false : !sslEnabled,
168544
- },
168545
- };
168546
- }
168547
- resolveSslConfig() {
168548
- const ssl = this.connection.ssl;
168549
- if (ssl === false || ssl === undefined)
168550
- return false;
168551
- if (ssl === true)
168552
- return { rejectUnauthorized: true };
168553
- // Object config
168554
- if (ssl.enabled === false)
168555
- return false;
168556
- const result = {
168557
- rejectUnauthorized: ssl.reject_unauthorized !== false,
168558
- };
168559
- if (ssl.ca) {
168560
- const caPath = this.validateSslPath(ssl.ca, 'CA certificate');
168561
- result.ca = fs.readFileSync(caPath, 'utf8');
168562
- }
168563
- if (ssl.cert) {
168564
- const certPath = this.validateSslPath(ssl.cert, 'client certificate');
168565
- result.cert = fs.readFileSync(certPath, 'utf8');
168566
- }
168567
- if (ssl.key) {
168568
- const keyPath = this.validateSslPath(ssl.key, 'client key');
168569
- result.key = fs.readFileSync(keyPath, 'utf8');
168570
- }
168571
- return result;
168572
- }
168573
- validateSslPath(filePath, label) {
168574
- const resolved = path.resolve(filePath);
168575
- if (resolved !== path.normalize(resolved)) {
168576
- throw new Error(`SSL ${label} path contains invalid sequences: ${filePath}`);
168577
- }
168578
- if (!fs.existsSync(resolved)) {
168579
- throw new Error(`SSL ${label} not found: ${filePath}`);
168580
- }
168581
- return resolved;
168582
- }
168583
- async shutdown() {
168584
- if (this.knex) {
168585
- await this.knex.destroy();
168586
- this.knex = null;
168587
- }
168588
- }
168589
- async migrateSchema() {
168590
- const knex = this.getKnex();
168591
- const exists = await knex.schema.hasTable('schedules');
168592
- if (!exists) {
168593
- await knex.schema.createTable('schedules', table => {
168594
- table.string('id', 36).primary();
168595
- table.string('creator_id', 255).notNullable().index();
168596
- table.string('creator_context', 255);
168597
- table.string('creator_name', 255);
168598
- table.string('timezone', 64).notNullable().defaultTo('UTC');
168599
- table.string('schedule_expr', 255);
168600
- table.bigInteger('run_at');
168601
- table.boolean('is_recurring').notNullable();
168602
- table.text('original_expression');
168603
- table.string('workflow', 255);
168604
- table.text('workflow_inputs');
168605
- table.text('output_context');
168606
- table.string('status', 20).notNullable().index();
168607
- table.bigInteger('created_at').notNullable();
168608
- table.bigInteger('last_run_at');
168609
- table.bigInteger('next_run_at');
168610
- table.integer('run_count').notNullable().defaultTo(0);
168611
- table.integer('failure_count').notNullable().defaultTo(0);
168612
- table.text('last_error');
168613
- table.text('previous_response');
168614
- table.index(['status', 'next_run_at']);
168615
- });
168616
- }
168617
- // Create message_triggers table
168618
- const triggersExist = await knex.schema.hasTable('message_triggers');
168619
- if (!triggersExist) {
168620
- await knex.schema.createTable('message_triggers', table => {
168621
- table.string('id', 36).primary();
168622
- table.string('creator_id', 255).notNullable().index();
168623
- table.string('creator_context', 255);
168624
- table.string('creator_name', 255);
168625
- table.text('description');
168626
- table.text('channels'); // JSON array
168627
- table.text('from_users'); // JSON array
168628
- table.boolean('from_bots').notNullable().defaultTo(false);
168629
- table.text('contains'); // JSON array
168630
- table.text('match_pattern');
168631
- table.string('threads', 20).notNullable().defaultTo('any');
168632
- table.string('workflow', 255).notNullable();
168633
- table.text('inputs'); // JSON
168634
- table.text('output_context'); // JSON
168635
- table.string('status', 20).notNullable().defaultTo('active').index();
168636
- table.boolean('enabled').notNullable().defaultTo(true);
168637
- table.bigInteger('created_at').notNullable();
168638
- });
168639
- }
168640
- // Create scheduler_locks table for distributed locking
168641
- const locksExist = await knex.schema.hasTable('scheduler_locks');
168642
- if (!locksExist) {
168643
- await knex.schema.createTable('scheduler_locks', table => {
168644
- table.string('lock_id', 255).primary();
168645
- table.string('node_id', 255).notNullable();
168646
- table.string('lock_token', 36).notNullable();
168647
- table.bigInteger('acquired_at').notNullable();
168648
- table.bigInteger('expires_at').notNullable();
168649
- });
168650
- }
168651
- }
168652
- getKnex() {
168653
- if (!this.knex) {
168654
- throw new Error('[KnexStore] Not initialized. Call initialize() first.');
168655
- }
168656
- return this.knex;
168657
- }
168658
- // --- CRUD ---
168659
- async create(schedule) {
168660
- const knex = this.getKnex();
168661
- const newSchedule = {
168662
- ...schedule,
168663
- id: (0, uuid_1.v4)(),
168664
- createdAt: Date.now(),
168665
- runCount: 0,
168666
- failureCount: 0,
168667
- status: 'active',
168668
- };
168669
- await knex('schedules').insert(toInsertRow(newSchedule));
168670
- logger_1.logger.info(`[KnexStore] Created schedule ${newSchedule.id} for user ${newSchedule.creatorId}`);
168671
- return newSchedule;
168672
- }
168673
- async importSchedule(schedule) {
168674
- const knex = this.getKnex();
168675
- const existing = await knex('schedules').where('id', schedule.id).first();
168676
- if (existing)
168677
- return; // Already imported (idempotent)
168678
- await knex('schedules').insert(toInsertRow(schedule));
168679
- }
168680
- async get(id) {
168681
- const knex = this.getKnex();
168682
- const row = await knex('schedules').where('id', id).first();
168683
- return row ? fromDbRow(row) : undefined;
168684
- }
168685
- async update(id, patch) {
168686
- const knex = this.getKnex();
168687
- const existing = await knex('schedules').where('id', id).first();
168688
- if (!existing)
168689
- return undefined;
168690
- const current = fromDbRow(existing);
168691
- const updated = { ...current, ...patch, id: current.id };
168692
- const row = toInsertRow(updated);
168693
- // Remove id from update (PK cannot change)
168694
- delete row.id;
168695
- await knex('schedules').where('id', id).update(row);
168696
- return updated;
168697
- }
168698
- async delete(id) {
168699
- const knex = this.getKnex();
168700
- const deleted = await knex('schedules').where('id', id).del();
168701
- if (deleted > 0) {
168702
- logger_1.logger.info(`[KnexStore] Deleted schedule ${id}`);
168703
- return true;
168704
- }
168705
- return false;
168706
- }
168707
- // --- Queries ---
168708
- async getByCreator(creatorId) {
168709
- const knex = this.getKnex();
168710
- const rows = await knex('schedules').where('creator_id', creatorId);
168711
- return rows.map((r) => fromDbRow(r));
168712
- }
168713
- async getActiveSchedules() {
168714
- const knex = this.getKnex();
168715
- const rows = await knex('schedules').where('status', 'active');
168716
- return rows.map((r) => fromDbRow(r));
168717
- }
168718
- async getDueSchedules(now) {
168719
- const ts = now ?? Date.now();
168720
- const knex = this.getKnex();
168721
- // MSSQL uses 1/0 for booleans
168722
- const bFalse = this.driver === 'mssql' ? 0 : false;
168723
- const bTrue = this.driver === 'mssql' ? 1 : true;
168724
- const rows = await knex('schedules')
168725
- .where('status', 'active')
168726
- .andWhere(function () {
168727
- this.where(function () {
168728
- this.where('is_recurring', bFalse)
168729
- .whereNotNull('run_at')
168730
- .where('run_at', '<=', ts);
168731
- }).orWhere(function () {
168732
- this.where('is_recurring', bTrue)
168733
- .whereNotNull('next_run_at')
168734
- .where('next_run_at', '<=', ts);
168735
- });
168736
- });
168737
- return rows.map((r) => fromDbRow(r));
168738
- }
168739
- async findByWorkflow(creatorId, workflowName) {
168740
- const knex = this.getKnex();
168741
- const escaped = workflowName.toLowerCase().replace(/[%_\\]/g, '\\$&');
168742
- const pattern = `%${escaped}%`;
168743
- const rows = await knex('schedules')
168744
- .where('creator_id', creatorId)
168745
- .where('status', 'active')
168746
- .whereRaw("LOWER(workflow) LIKE ? ESCAPE '\\'", [pattern]);
168747
- return rows.map((r) => fromDbRow(r));
168748
- }
168749
- async getAll() {
168750
- const knex = this.getKnex();
168751
- const rows = await knex('schedules');
168752
- return rows.map((r) => fromDbRow(r));
168753
- }
168754
- async getStats() {
168755
- const knex = this.getKnex();
168756
- // MSSQL uses 1/0 for booleans; PostgreSQL/MySQL accept both true/1
168757
- const boolTrue = this.driver === 'mssql' ? '1' : 'true';
168758
- const boolFalse = this.driver === 'mssql' ? '0' : 'false';
168759
- const result = await knex('schedules')
168760
- .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`))
168761
- .first();
168762
- return {
168763
- total: Number(result.total) || 0,
168764
- active: Number(result.active) || 0,
168765
- paused: Number(result.paused) || 0,
168766
- completed: Number(result.completed) || 0,
168767
- failed: Number(result.failed) || 0,
168768
- recurring: Number(result.recurring) || 0,
168769
- oneTime: Number(result.one_time) || 0,
168770
- };
168771
- }
168772
- async validateLimits(creatorId, isRecurring, limits) {
168773
- const knex = this.getKnex();
168774
- if (limits.maxGlobal) {
168775
- const result = await knex('schedules').count('* as cnt').first();
168776
- if (Number(result?.cnt) >= limits.maxGlobal) {
168777
- throw new Error(`Global schedule limit reached (${limits.maxGlobal})`);
168778
- }
168779
- }
168780
- if (limits.maxPerUser) {
168781
- const result = await knex('schedules')
168782
- .where('creator_id', creatorId)
168783
- .count('* as cnt')
168784
- .first();
168785
- if (Number(result?.cnt) >= limits.maxPerUser) {
168786
- throw new Error(`You have reached the maximum number of schedules (${limits.maxPerUser})`);
168787
- }
168788
- }
168789
- if (isRecurring && limits.maxRecurringPerUser) {
168790
- const bTrue = this.driver === 'mssql' ? 1 : true;
168791
- const result = await knex('schedules')
168792
- .where('creator_id', creatorId)
168793
- .where('is_recurring', bTrue)
168794
- .count('* as cnt')
168795
- .first();
168796
- if (Number(result?.cnt) >= limits.maxRecurringPerUser) {
168797
- throw new Error(`You have reached the maximum number of recurring schedules (${limits.maxRecurringPerUser})`);
168798
- }
168799
- }
168800
- }
168801
- // --- HA Distributed Locking (via scheduler_locks table) ---
168802
- async tryAcquireLock(lockId, nodeId, ttlSeconds) {
168803
- const knex = this.getKnex();
168804
- const now = Date.now();
168805
- const expiresAt = now + ttlSeconds * 1000;
168806
- const token = (0, uuid_1.v4)();
168807
- // Step 1: Try to claim an existing expired lock
168808
- const updated = await knex('scheduler_locks')
168809
- .where('lock_id', lockId)
168810
- .where('expires_at', '<', now)
168811
- .update({
168812
- node_id: nodeId,
168813
- lock_token: token,
168814
- acquired_at: now,
168815
- expires_at: expiresAt,
168816
- });
168817
- if (updated > 0)
168818
- return token;
168819
- // Step 2: Try to INSERT a new lock row
168820
- try {
168821
- await knex('scheduler_locks').insert({
168822
- lock_id: lockId,
168823
- node_id: nodeId,
168824
- lock_token: token,
168825
- acquired_at: now,
168826
- expires_at: expiresAt,
168827
- });
168828
- return token;
168829
- }
168830
- catch {
168831
- // Unique constraint violation — another node holds the lock
168832
- return null;
168833
- }
168834
- }
168835
- async releaseLock(lockId, lockToken) {
168836
- const knex = this.getKnex();
168837
- await knex('scheduler_locks').where('lock_id', lockId).where('lock_token', lockToken).del();
168838
- }
168839
- async renewLock(lockId, lockToken, ttlSeconds) {
168840
- const knex = this.getKnex();
168841
- const now = Date.now();
168842
- const expiresAt = now + ttlSeconds * 1000;
168843
- const updated = await knex('scheduler_locks')
168844
- .where('lock_id', lockId)
168845
- .where('lock_token', lockToken)
168846
- .update({ acquired_at: now, expires_at: expiresAt });
168847
- return updated > 0;
168848
- }
168849
- async flush() {
168850
- // No-op for server-based backends
168851
- }
168852
- // --- Message Trigger CRUD ---
168853
- async createTrigger(trigger) {
168854
- const knex = this.getKnex();
168855
- const newTrigger = {
168856
- ...trigger,
168857
- id: (0, uuid_1.v4)(),
168858
- createdAt: Date.now(),
168859
- };
168860
- await knex('message_triggers').insert(toTriggerInsertRow(newTrigger));
168861
- logger_1.logger.info(`[KnexStore] Created trigger ${newTrigger.id} for user ${newTrigger.creatorId}`);
168862
- return newTrigger;
168863
- }
168864
- async getTrigger(id) {
168865
- const knex = this.getKnex();
168866
- const row = await knex('message_triggers').where('id', id).first();
168867
- return row ? fromTriggerRow(row) : undefined;
168868
- }
168869
- async updateTrigger(id, patch) {
168870
- const knex = this.getKnex();
168871
- const existing = await knex('message_triggers').where('id', id).first();
168872
- if (!existing)
168873
- return undefined;
168874
- const current = fromTriggerRow(existing);
168875
- const updated = {
168876
- ...current,
168877
- ...patch,
168878
- id: current.id,
168879
- createdAt: current.createdAt,
168880
- };
168881
- const row = toTriggerInsertRow(updated);
168882
- delete row.id;
168883
- await knex('message_triggers').where('id', id).update(row);
168884
- return updated;
168885
- }
168886
- async deleteTrigger(id) {
168887
- const knex = this.getKnex();
168888
- const deleted = await knex('message_triggers').where('id', id).del();
168889
- if (deleted > 0) {
168890
- logger_1.logger.info(`[KnexStore] Deleted trigger ${id}`);
168891
- return true;
168892
- }
168893
- return false;
168894
- }
168895
- async getTriggersByCreator(creatorId) {
168896
- const knex = this.getKnex();
168897
- const rows = await knex('message_triggers').where('creator_id', creatorId);
168898
- return rows.map((r) => fromTriggerRow(r));
168899
- }
168900
- async getActiveTriggers() {
168901
- const knex = this.getKnex();
168902
- const rows = await knex('message_triggers')
168903
- .where('status', 'active')
168904
- .where('enabled', this.driver === 'mssql' ? 1 : true);
168905
- return rows.map((r) => fromTriggerRow(r));
168906
- }
168907
- }
168908
- exports.KnexStoreBackend = KnexStoreBackend;
168909
-
168910
-
168911
167107
  /***/ }),
168912
167108
 
168913
167109
  /***/ 83864:
@@ -179921,35 +178117,6 @@ class OutputFormatters {
179921
178117
  exports.OutputFormatters = OutputFormatters;
179922
178118
 
179923
178119
 
179924
- /***/ }),
179925
-
179926
- /***/ 93866:
179927
- /***/ ((__unused_webpack_module, exports) => {
179928
-
179929
- "use strict";
179930
-
179931
- Object.defineProperty(exports, "__esModule", ({ value: true }));
179932
- exports.DefaultPolicyEngine = void 0;
179933
- /**
179934
- * Default (no-op) policy engine — always allows everything.
179935
- * Used when no enterprise license is present or policy is disabled.
179936
- */
179937
- class DefaultPolicyEngine {
179938
- async initialize(_config) { }
179939
- async evaluateCheckExecution(_checkId, _checkConfig) {
179940
- return { allowed: true };
179941
- }
179942
- async evaluateToolInvocation(_serverName, _methodName, _transport) {
179943
- return { allowed: true };
179944
- }
179945
- async evaluateCapabilities(_checkId, _capabilities) {
179946
- return { allowed: true };
179947
- }
179948
- async shutdown() { }
179949
- }
179950
- exports.DefaultPolicyEngine = DefaultPolicyEngine;
179951
-
179952
-
179953
178120
  /***/ }),
179954
178121
 
179955
178122
  /***/ 96611:
@@ -202162,7 +200329,7 @@ class StateMachineExecutionEngine {
202162
200329
  try {
202163
200330
  logger_1.logger.debug(`[PolicyEngine] Loading enterprise policy engine (engine=${configWithTagFilter.policy.engine})`);
202164
200331
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
202165
- const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(87068)));
200332
+ const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(7065)));
202166
200333
  context.policyEngine = await loadEnterprisePolicyEngine(configWithTagFilter.policy);
202167
200334
  logger_1.logger.debug(`[PolicyEngine] Initialized: ${context.policyEngine?.constructor?.name || 'unknown'}`);
202168
200335
  }
@@ -212436,7 +210603,7 @@ async function initTelemetry(opts = {}) {
212436
210603
  const path = __nccwpck_require__(16928);
212437
210604
  const outDir = opts.file?.dir ||
212438
210605
  process.env.VISOR_TRACE_DIR ||
212439
- path.join(process.cwd(), 'output', 'traces');
210606
+ __nccwpck_require__.ab + "traces";
212440
210607
  fs.mkdirSync(outDir, { recursive: true });
212441
210608
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
212442
210609
  process.env.VISOR_FALLBACK_TRACE_FILE = path.join(outDir, `run-${ts}.ndjson`);
@@ -212641,7 +210808,7 @@ async function shutdownTelemetry() {
212641
210808
  if (process.env.VISOR_TRACE_REPORT === 'true') {
212642
210809
  const fs = __nccwpck_require__(79896);
212643
210810
  const path = __nccwpck_require__(16928);
212644
- const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
210811
+ const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
212645
210812
  if (!fs.existsSync(outDir))
212646
210813
  fs.mkdirSync(outDir, { recursive: true });
212647
210814
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
@@ -213140,7 +211307,7 @@ function __getOrCreateNdjsonPath() {
213140
211307
  fs.mkdirSync(dir, { recursive: true });
213141
211308
  return __ndjsonPath;
213142
211309
  }
213143
- const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
211310
+ const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
213144
211311
  if (!fs.existsSync(outDir))
213145
211312
  fs.mkdirSync(outDir, { recursive: true });
213146
211313
  if (!__ndjsonPath) {
@@ -227225,6 +225392,22 @@ class WorkflowRegistry {
227225
225392
  exports.WorkflowRegistry = WorkflowRegistry;
227226
225393
 
227227
225394
 
225395
+ /***/ }),
225396
+
225397
+ /***/ 7065:
225398
+ /***/ ((module) => {
225399
+
225400
+ module.exports = eval("require")("./enterprise/loader");
225401
+
225402
+
225403
+ /***/ }),
225404
+
225405
+ /***/ 71370:
225406
+ /***/ ((module) => {
225407
+
225408
+ module.exports = eval("require")("./enterprise/policy/policy-input-builder");
225409
+
225410
+
227228
225411
  /***/ }),
227229
225412
 
227230
225413
  /***/ 18327:
@@ -397968,7 +396151,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"100":"Continue","101":"Switching Pro
397968
396151
  /***/ ((module) => {
397969
396152
 
397970
396153
  "use strict";
397971
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.42","main":"dist/index.js","bin":{"visor":"./dist/index.js"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"},"./sdk":{"types":"./dist/sdk/sdk.d.ts","import":"./dist/sdk/sdk.mjs","require":"./dist/sdk/sdk.js"},"./cli":{"require":"./dist/index.js"}},"files":["dist/","defaults/","action.yml","README.md","LICENSE"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build:cli":"ncc build src/index.ts -o dist && cp -r defaults dist/ && cp -r output dist/ && cp -r docs dist/ && cp -r examples dist/ && cp -r src/debug-visualizer/ui dist/debug-visualizer/ && node scripts/inject-version.js && echo \'#!/usr/bin/env node\' | cat - dist/index.js > temp && mv temp dist/index.js && chmod +x dist/index.js","build:sdk":"tsup src/sdk.ts --dts --sourcemap --format esm,cjs --out-dir dist/sdk","build":"./scripts/build-oss.sh","build:ee":"npm run build:cli && npm run build:sdk","test":"jest && npm run test:yaml","test:unit":"jest","prepublishOnly":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ee":"jest --testPathPatterns=\'tests/ee\' --testPathIgnorePatterns=\'/node_modules/\' --no-coverage","test:manual:bash":"RUN_MANUAL_TESTS=true jest tests/manual/bash-config-manual.test.ts","lint":"eslint src tests --ext .ts","lint:fix":"eslint src tests --ext .ts --fix","format":"prettier --write src tests","format:check":"prettier --check src tests","clean":"","clean:traces":"node scripts/clean-traces.js","prebuild":"npm run clean && node scripts/generate-config-schema.js","pretest":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","pretest:unit":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","test:with-build":"npm run build:cli && jest","test:yaml":"node dist/index.js test --progress compact","test:yaml:parallel":"node dist/index.js test --progress compact --max-parallel 4","prepare":"husky","pre-commit":"lint-staged","deploy:site":"cd site && npx wrangler pages deploy . --project-name=visor-site --commit-dirty=true","deploy:worker":"npx wrangler deploy","deploy":"npm run deploy:site && npm run deploy:worker","publish:ee":"./scripts/publish-ee.sh","release":"./scripts/release.sh","release:patch":"./scripts/release.sh patch","release:minor":"./scripts/release.sh minor","release:major":"./scripts/release.sh major","release:prerelease":"./scripts/release.sh prerelease","docs:validate":"node scripts/validate-readme-links.js","workshop:setup":"npm install -D reveal-md@6.1.2","workshop:serve":"cd workshop && reveal-md slides.md -w","workshop:export":"reveal-md workshop/slides.md --static workshop/build","workshop:pdf":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter","workshop:pdf:ci":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter --puppeteer-launch-args=\\"--no-sandbox --disable-dev-shm-usage\\"","workshop:pdf:a4":"reveal-md workshop/slides.md --print workshop/Visor-Workshop-A4.pdf --print-size A4","workshop:build":"npm run workshop:export && npm run workshop:pdf","simulate:issue":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issues --action opened --debug","simulate:comment":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issue_comment --action created --debug"},"keywords":["code-review","ai","github-action","cli","pr-review","visor"],"author":"Probe Labs","license":"MIT","description":"AI workflow engine for code review, assistants, and automation — orchestrate checks, MCP tools, and AI providers with YAML-driven pipelines","repository":{"type":"git","url":"git+https://github.com/probelabs/visor.git"},"bugs":{"url":"https://github.com/probelabs/visor/issues"},"homepage":"https://github.com/probelabs/visor#readme","dependencies":{"@actions/core":"^1.11.1","@apidevtools/swagger-parser":"^12.1.0","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#f1c13b8eee98734a8ea024061eada4aa9a9ff2e9","@octokit/action":"^8.0.2","@octokit/auth-app":"^8.1.0","@octokit/core":"^7.0.3","@octokit/rest":"^22.0.0","@opentelemetry/api":"^1.9.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-trace-otlp-grpc":"^0.203.0","@opentelemetry/exporter-trace-otlp-http":"^0.203.0","@opentelemetry/instrumentation":"^0.203.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.203.0","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/semantic-conventions":"^1.30.1","@probelabs/probe":"^0.6.0-rc280","@types/commander":"^2.12.0","@types/uuid":"^10.0.0","acorn":"^8.16.0","acorn-walk":"^8.3.5","ajv":"^8.17.1","ajv-formats":"^3.0.1","better-sqlite3":"^11.0.0","blessed":"^0.1.81","cli-table3":"^0.6.5","commander":"^14.0.0","deepmerge":"^4.3.1","dotenv":"^17.2.3","ignore":"^7.0.5","js-yaml":"^4.1.0","jsonpath-plus":"^10.4.0","liquidjs":"^10.21.1","minimatch":"^10.2.2","node-cron":"^3.0.3","open":"^9.1.0","simple-git":"^3.28.0","uuid":"^11.1.0","ws":"^8.18.3"},"optionalDependencies":{"@anthropic/claude-code-sdk":"npm:null@*","@open-policy-agent/opa-wasm":"^1.10.0","knex":"^3.1.0","mysql2":"^3.11.0","pg":"^8.13.0","tedious":"^19.0.0"},"devDependencies":{"@eslint/js":"^9.34.0","@kie/act-js":"^2.6.2","@kie/mock-github":"^2.0.1","@swc/core":"^1.13.2","@swc/jest":"^0.2.37","@types/better-sqlite3":"^7.6.0","@types/blessed":"^0.1.27","@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/node":"^24.3.0","@types/node-cron":"^3.0.11","@types/ws":"^8.18.1","@typescript-eslint/eslint-plugin":"^8.42.0","@typescript-eslint/parser":"^8.42.0","@vercel/ncc":"^0.38.4","eslint":"^9.34.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","husky":"^9.1.7","jest":"^30.1.3","lint-staged":"^16.1.6","prettier":"^3.6.2","reveal-md":"^6.1.2","ts-json-schema-generator":"^1.5.1","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.9.2","wrangler":"^3.0.0"},"peerDependenciesMeta":{"@anthropic/claude-code-sdk":{"optional":true}},"directories":{"test":"tests"},"lint-staged":{"src/**/*.{ts,js}":["eslint --fix","prettier --write"],"tests/**/*.{ts,js}":["eslint --fix","prettier --write"],"*.{json,md,yml,yaml}":["prettier --write"]}}');
396154
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.166","main":"dist/index.js","bin":{"visor":"./dist/index.js"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"},"./sdk":{"types":"./dist/sdk/sdk.d.ts","import":"./dist/sdk/sdk.mjs","require":"./dist/sdk/sdk.js"},"./cli":{"require":"./dist/index.js"}},"files":["dist/","defaults/","action.yml","README.md","LICENSE"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build:cli":"ncc build src/index.ts -o dist && cp -r defaults dist/ && cp -r output dist/ && cp -r docs dist/ && cp -r examples dist/ && cp -r src/debug-visualizer/ui dist/debug-visualizer/ && node scripts/inject-version.js && echo \'#!/usr/bin/env node\' | cat - dist/index.js > temp && mv temp dist/index.js && chmod +x dist/index.js","build:sdk":"tsup src/sdk.ts --dts --sourcemap --format esm,cjs --out-dir dist/sdk","build":"./scripts/build-oss.sh","build:ee":"npm run build:cli && npm run build:sdk","test":"jest && npm run test:yaml","test:unit":"jest","prepublishOnly":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ee":"jest --testPathPatterns=\'tests/ee\' --testPathIgnorePatterns=\'/node_modules/\' --no-coverage","test:manual:bash":"RUN_MANUAL_TESTS=true jest tests/manual/bash-config-manual.test.ts","lint":"eslint src tests --ext .ts","lint:fix":"eslint src tests --ext .ts --fix","format":"prettier --write src tests","format:check":"prettier --check src tests","clean":"","clean:traces":"node scripts/clean-traces.js","prebuild":"npm run clean && node scripts/generate-config-schema.js","pretest":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","pretest:unit":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","test:with-build":"npm run build:cli && jest","test:yaml":"node dist/index.js test --progress compact","test:yaml:parallel":"node dist/index.js test --progress compact --max-parallel 4","prepare":"husky","pre-commit":"lint-staged","deploy:site":"cd site && npx wrangler pages deploy . --project-name=visor-site --commit-dirty=true","deploy:worker":"npx wrangler deploy","deploy":"npm run deploy:site && npm run deploy:worker","publish:ee":"./scripts/publish-ee.sh","release":"./scripts/release.sh","release:patch":"./scripts/release.sh patch","release:minor":"./scripts/release.sh minor","release:major":"./scripts/release.sh major","release:prerelease":"./scripts/release.sh prerelease","docs:validate":"node scripts/validate-readme-links.js","workshop:setup":"npm install -D reveal-md@6.1.2","workshop:serve":"cd workshop && reveal-md slides.md -w","workshop:export":"reveal-md workshop/slides.md --static workshop/build","workshop:pdf":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter","workshop:pdf:ci":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter --puppeteer-launch-args=\\"--no-sandbox --disable-dev-shm-usage\\"","workshop:pdf:a4":"reveal-md workshop/slides.md --print workshop/Visor-Workshop-A4.pdf --print-size A4","workshop:build":"npm run workshop:export && npm run workshop:pdf","simulate:issue":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issues --action opened --debug","simulate:comment":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issue_comment --action created --debug"},"keywords":["code-review","ai","github-action","cli","pr-review","visor"],"author":"Probe Labs","license":"MIT","description":"AI workflow engine for code review, assistants, and automation — orchestrate checks, MCP tools, and AI providers with YAML-driven pipelines","repository":{"type":"git","url":"git+https://github.com/probelabs/visor.git"},"bugs":{"url":"https://github.com/probelabs/visor/issues"},"homepage":"https://github.com/probelabs/visor#readme","dependencies":{"@actions/core":"^1.11.1","@apidevtools/swagger-parser":"^12.1.0","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#f1c13b8eee98734a8ea024061eada4aa9a9ff2e9","@octokit/action":"^8.0.2","@octokit/auth-app":"^8.1.0","@octokit/core":"^7.0.3","@octokit/rest":"^22.0.0","@opentelemetry/api":"^1.9.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-trace-otlp-grpc":"^0.203.0","@opentelemetry/exporter-trace-otlp-http":"^0.203.0","@opentelemetry/instrumentation":"^0.203.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.203.0","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/semantic-conventions":"^1.30.1","@probelabs/probe":"^0.6.0-rc280","@types/commander":"^2.12.0","@types/uuid":"^10.0.0","acorn":"^8.16.0","acorn-walk":"^8.3.5","ajv":"^8.17.1","ajv-formats":"^3.0.1","better-sqlite3":"^11.0.0","blessed":"^0.1.81","cli-table3":"^0.6.5","commander":"^14.0.0","deepmerge":"^4.3.1","dotenv":"^17.2.3","ignore":"^7.0.5","js-yaml":"^4.1.0","jsonpath-plus":"^10.4.0","liquidjs":"^10.21.1","minimatch":"^10.2.2","node-cron":"^3.0.3","open":"^9.1.0","simple-git":"^3.28.0","uuid":"^11.1.0","ws":"^8.18.3"},"optionalDependencies":{"@anthropic/claude-code-sdk":"npm:null@*","@open-policy-agent/opa-wasm":"^1.10.0","knex":"^3.1.0","mysql2":"^3.11.0","pg":"^8.13.0","tedious":"^19.0.0"},"devDependencies":{"@eslint/js":"^9.34.0","@kie/act-js":"^2.6.2","@kie/mock-github":"^2.0.1","@swc/core":"^1.13.2","@swc/jest":"^0.2.37","@types/better-sqlite3":"^7.6.0","@types/blessed":"^0.1.27","@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/node":"^24.3.0","@types/node-cron":"^3.0.11","@types/ws":"^8.18.1","@typescript-eslint/eslint-plugin":"^8.42.0","@typescript-eslint/parser":"^8.42.0","@vercel/ncc":"^0.38.4","eslint":"^9.34.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","husky":"^9.1.7","jest":"^30.1.3","lint-staged":"^16.1.6","prettier":"^3.6.2","reveal-md":"^6.1.2","ts-json-schema-generator":"^1.5.1","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.9.2","wrangler":"^3.0.0"},"peerDependenciesMeta":{"@anthropic/claude-code-sdk":{"optional":true}},"directories":{"test":"tests"},"lint-staged":{"src/**/*.{ts,js}":["eslint --fix","prettier --write"],"tests/**/*.{ts,js}":["eslint --fix","prettier --write"],"*.{json,md,yml,yaml}":["prettier --write"]}}');
397972
396155
 
397973
396156
  /***/ })
397974
396157