@probelabs/visor 0.1.143 → 0.1.144-ee

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/index.js +1907 -45
  2. package/dist/sdk/{check-provider-registry-HDMOOQ3J.mjs → check-provider-registry-Q7D5SQAV.mjs} +6 -6
  3. package/dist/sdk/{check-provider-registry-QCE7HDRY.mjs → check-provider-registry-VTNNTMWC.mjs} +5 -5
  4. package/dist/sdk/{chunk-6ZVR3WHW.mjs → chunk-AUHRKE6Z.mjs} +19 -19
  5. package/dist/sdk/{chunk-MIVULWHE.mjs.map → chunk-AUHRKE6Z.mjs.map} +1 -1
  6. package/dist/sdk/{chunk-RUQBSUTM.mjs → chunk-O7WE6HCA.mjs} +2 -2
  7. package/dist/sdk/{chunk-RUQBSUTM.mjs.map → chunk-O7WE6HCA.mjs.map} +1 -1
  8. package/dist/sdk/{chunk-5X6TLBDA.mjs → chunk-PES5G5RR.mjs} +3 -3
  9. package/dist/sdk/{chunk-HHQFJTPJ.mjs → chunk-PXWWPPNF.mjs} +14 -14
  10. package/dist/sdk/{chunk-TPJWUDMJ.mjs → chunk-XHIXKNUF.mjs} +2 -2
  11. package/dist/sdk/{failure-condition-evaluator-TK26KQRA.mjs → failure-condition-evaluator-2BJHKTMX.mjs} +3 -3
  12. package/dist/sdk/{github-frontend-HOPD4TAR.mjs → github-frontend-ICKRZ4VV.mjs} +3 -3
  13. package/dist/sdk/{host-AYYUK7CA.mjs → host-CVJ3VG5Y.mjs} +2 -2
  14. package/dist/sdk/{host-LCKHX2EN.mjs → host-WGFJVD4L.mjs} +2 -2
  15. package/dist/sdk/knex-store-HPXJILBL.mjs +411 -0
  16. package/dist/sdk/knex-store-HPXJILBL.mjs.map +1 -0
  17. package/dist/sdk/loader-ZC5G3JGJ.mjs +89 -0
  18. package/dist/sdk/loader-ZC5G3JGJ.mjs.map +1 -0
  19. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs +655 -0
  20. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs.map +1 -0
  21. package/dist/sdk/{routing-GDVV3MT6.mjs → routing-3XDRYU3Z.mjs} +4 -4
  22. package/dist/sdk/{schedule-tool-handler-MIVCDCJO.mjs → schedule-tool-handler-7RGTKO24.mjs} +5 -5
  23. package/dist/sdk/{schedule-tool-handler-QC7CAK55.mjs → schedule-tool-handler-FBXABUWX.mjs} +6 -6
  24. package/dist/sdk/sdk.js +1518 -260
  25. package/dist/sdk/sdk.js.map +1 -1
  26. package/dist/sdk/sdk.mjs +5 -5
  27. package/dist/sdk/{trace-helpers-HP3LKMTS.mjs → trace-helpers-VUUP6ILH.mjs} +2 -2
  28. package/dist/sdk/validator-XTZJZZJH.mjs +134 -0
  29. package/dist/sdk/validator-XTZJZZJH.mjs.map +1 -0
  30. package/dist/sdk/{workflow-check-provider-HG5LNVBC.mjs → workflow-check-provider-62MO2NB6.mjs} +6 -6
  31. package/dist/sdk/{workflow-check-provider-MLRZ5EHG.mjs → workflow-check-provider-FLBIJQ4Z.mjs} +5 -5
  32. package/package.json +2 -2
  33. package/dist/output/traces/run-2026-02-25T06-11-39-869Z.ndjson +0 -138
  34. package/dist/output/traces/run-2026-02-25T06-12-27-651Z.ndjson +0 -1442
  35. package/dist/sdk/check-provider-registry-3GYSI2H3.mjs +0 -30
  36. package/dist/sdk/chunk-6ZVR3WHW.mjs.map +0 -1
  37. package/dist/sdk/chunk-HBPGNGES.mjs +0 -443
  38. package/dist/sdk/chunk-HBPGNGES.mjs.map +0 -1
  39. package/dist/sdk/chunk-MIVULWHE.mjs +0 -40284
  40. package/dist/sdk/chunk-TML27TJH.mjs +0 -739
  41. package/dist/sdk/chunk-TPJWUDMJ.mjs.map +0 -1
  42. package/dist/sdk/chunk-XAOA6CQY.mjs +0 -1502
  43. package/dist/sdk/chunk-XAOA6CQY.mjs.map +0 -1
  44. package/dist/sdk/failure-condition-evaluator-G3YW5TG6.mjs +0 -17
  45. package/dist/sdk/github-frontend-VFKREBO3.mjs +0 -1356
  46. package/dist/sdk/github-frontend-VFKREBO3.mjs.map +0 -1
  47. package/dist/sdk/routing-ZNIYEVS3.mjs +0 -25
  48. package/dist/sdk/schedule-tool-handler-646OMXGP.mjs +0 -40
  49. package/dist/sdk/schedule-tool-handler-QC7CAK55.mjs.map +0 -1
  50. package/dist/sdk/trace-helpers-HP3LKMTS.mjs.map +0 -1
  51. package/dist/sdk/trace-helpers-PGKN5L72.mjs +0 -25
  52. package/dist/sdk/trace-helpers-PGKN5L72.mjs.map +0 -1
  53. package/dist/sdk/workflow-check-provider-4CTBJWK5.mjs +0 -30
  54. package/dist/sdk/workflow-check-provider-4CTBJWK5.mjs.map +0 -1
  55. package/dist/sdk/workflow-check-provider-HG5LNVBC.mjs.map +0 -1
  56. package/dist/sdk/workflow-check-provider-MLRZ5EHG.mjs.map +0 -1
  57. package/dist/traces/run-2026-02-25T06-11-39-869Z.ndjson +0 -138
  58. package/dist/traces/run-2026-02-25T06-12-27-651Z.ndjson +0 -1442
  59. /package/dist/sdk/{check-provider-registry-3GYSI2H3.mjs.map → check-provider-registry-Q7D5SQAV.mjs.map} +0 -0
  60. /package/dist/sdk/{check-provider-registry-HDMOOQ3J.mjs.map → check-provider-registry-VTNNTMWC.mjs.map} +0 -0
  61. /package/dist/sdk/{chunk-5X6TLBDA.mjs.map → chunk-PES5G5RR.mjs.map} +0 -0
  62. /package/dist/sdk/{chunk-HHQFJTPJ.mjs.map → chunk-PXWWPPNF.mjs.map} +0 -0
  63. /package/dist/sdk/{chunk-TML27TJH.mjs.map → chunk-XHIXKNUF.mjs.map} +0 -0
  64. /package/dist/sdk/{check-provider-registry-QCE7HDRY.mjs.map → failure-condition-evaluator-2BJHKTMX.mjs.map} +0 -0
  65. /package/dist/sdk/{github-frontend-HOPD4TAR.mjs.map → github-frontend-ICKRZ4VV.mjs.map} +0 -0
  66. /package/dist/sdk/{host-AYYUK7CA.mjs.map → host-CVJ3VG5Y.mjs.map} +0 -0
  67. /package/dist/sdk/{host-LCKHX2EN.mjs.map → host-WGFJVD4L.mjs.map} +0 -0
  68. /package/dist/sdk/{failure-condition-evaluator-G3YW5TG6.mjs.map → routing-3XDRYU3Z.mjs.map} +0 -0
  69. /package/dist/sdk/{failure-condition-evaluator-TK26KQRA.mjs.map → schedule-tool-handler-7RGTKO24.mjs.map} +0 -0
  70. /package/dist/sdk/{routing-GDVV3MT6.mjs.map → schedule-tool-handler-FBXABUWX.mjs.map} +0 -0
  71. /package/dist/sdk/{routing-ZNIYEVS3.mjs.map → trace-helpers-VUUP6ILH.mjs.map} +0 -0
  72. /package/dist/sdk/{schedule-tool-handler-646OMXGP.mjs.map → workflow-check-provider-62MO2NB6.mjs.map} +0 -0
  73. /package/dist/sdk/{schedule-tool-handler-MIVCDCJO.mjs.map → workflow-check-provider-FLBIJQ4Z.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- process.env.VISOR_VERSION = '0.1.143';
3
- process.env.PROBE_VERSION = '0.6.0-rc258';
4
- process.env.VISOR_COMMIT_SHA = '4d0e1eabc24bbbe4732548e61303df3ce5f1be74';
5
- process.env.VISOR_COMMIT_SHORT = '4d0e1ea';
2
+ process.env.VISOR_VERSION = '0.1.144';
3
+ process.env.PROBE_VERSION = '0.6.0-rc259';
4
+ process.env.VISOR_COMMIT_SHA = '0f8df6f53e18e9ad94507e1761debabaf533c0df';
5
+ process.env.VISOR_COMMIT_SHORT = '0f8df6f';
6
6
  /******/ (() => { // webpackBootstrap
7
7
  /******/ var __webpack_modules__ = ({
8
8
 
@@ -161190,7 +161190,7 @@ async function handleDumpPolicyInput(checkId, argv) {
161190
161190
  let PolicyInputBuilder;
161191
161191
  try {
161192
161192
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
161193
- const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(71370)));
161193
+ const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(17117)));
161194
161194
  PolicyInputBuilder = mod.PolicyInputBuilder;
161195
161195
  }
161196
161196
  catch {
@@ -166980,6 +166980,1690 @@ class DependencyResolver {
166980
166980
  exports.DependencyResolver = DependencyResolver;
166981
166981
 
166982
166982
 
166983
+ /***/ }),
166984
+
166985
+ /***/ 50069:
166986
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
166987
+
166988
+ "use strict";
166989
+
166990
+ /**
166991
+ * Copyright (c) ProbeLabs. All rights reserved.
166992
+ * Licensed under the Elastic License 2.0; you may not use this file except
166993
+ * in compliance with the Elastic License 2.0.
166994
+ */
166995
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
166996
+ if (k2 === undefined) k2 = k;
166997
+ var desc = Object.getOwnPropertyDescriptor(m, k);
166998
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
166999
+ desc = { enumerable: true, get: function() { return m[k]; } };
167000
+ }
167001
+ Object.defineProperty(o, k2, desc);
167002
+ }) : (function(o, m, k, k2) {
167003
+ if (k2 === undefined) k2 = k;
167004
+ o[k2] = m[k];
167005
+ }));
167006
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167007
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167008
+ }) : function(o, v) {
167009
+ o["default"] = v;
167010
+ });
167011
+ var __importStar = (this && this.__importStar) || (function () {
167012
+ var ownKeys = function(o) {
167013
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167014
+ var ar = [];
167015
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167016
+ return ar;
167017
+ };
167018
+ return ownKeys(o);
167019
+ };
167020
+ return function (mod) {
167021
+ if (mod && mod.__esModule) return mod;
167022
+ var result = {};
167023
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167024
+ __setModuleDefault(result, mod);
167025
+ return result;
167026
+ };
167027
+ })();
167028
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167029
+ exports.LicenseValidator = void 0;
167030
+ const crypto = __importStar(__nccwpck_require__(76982));
167031
+ const fs = __importStar(__nccwpck_require__(79896));
167032
+ const path = __importStar(__nccwpck_require__(16928));
167033
+ class LicenseValidator {
167034
+ /** Ed25519 public key for license verification (PEM format). */
167035
+ static PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----\n' +
167036
+ 'MCowBQYDK2VwAyEAI/Zd08EFmgIdrDm/HXd0l3/5GBt7R1PrdvhdmEXhJlU=\n' +
167037
+ '-----END PUBLIC KEY-----\n';
167038
+ cache = null;
167039
+ static CACHE_TTL = 5 * 60 * 1000; // 5 minutes
167040
+ static GRACE_PERIOD = 72 * 3600 * 1000; // 72 hours after expiry
167041
+ /**
167042
+ * Load and validate license from environment or file.
167043
+ *
167044
+ * Resolution order:
167045
+ * 1. VISOR_LICENSE env var (JWT string)
167046
+ * 2. VISOR_LICENSE_FILE env var (path to file)
167047
+ * 3. .visor-license in project root (cwd)
167048
+ * 4. .visor-license in ~/.config/visor/
167049
+ */
167050
+ async loadAndValidate() {
167051
+ // Return cached result if still fresh
167052
+ if (this.cache && Date.now() - this.cache.validatedAt < LicenseValidator.CACHE_TTL) {
167053
+ return this.cache.payload;
167054
+ }
167055
+ const token = this.resolveToken();
167056
+ if (!token)
167057
+ return null;
167058
+ const payload = this.verifyAndDecode(token);
167059
+ if (!payload)
167060
+ return null;
167061
+ this.cache = { payload, validatedAt: Date.now() };
167062
+ return payload;
167063
+ }
167064
+ /** Check if a specific feature is licensed */
167065
+ hasFeature(feature) {
167066
+ if (!this.cache)
167067
+ return false;
167068
+ return this.cache.payload.features.includes(feature);
167069
+ }
167070
+ /** Check if license is valid (with grace period) */
167071
+ isValid() {
167072
+ if (!this.cache)
167073
+ return false;
167074
+ const now = Date.now();
167075
+ const expiryMs = this.cache.payload.exp * 1000;
167076
+ return now < expiryMs + LicenseValidator.GRACE_PERIOD;
167077
+ }
167078
+ /** Check if the license is within its grace period (expired but still valid) */
167079
+ isInGracePeriod() {
167080
+ if (!this.cache)
167081
+ return false;
167082
+ const now = Date.now();
167083
+ const expiryMs = this.cache.payload.exp * 1000;
167084
+ return now >= expiryMs && now < expiryMs + LicenseValidator.GRACE_PERIOD;
167085
+ }
167086
+ resolveToken() {
167087
+ // 1. Direct env var
167088
+ if (process.env.VISOR_LICENSE) {
167089
+ return process.env.VISOR_LICENSE.trim();
167090
+ }
167091
+ // 2. File path from env (validate against path traversal)
167092
+ if (process.env.VISOR_LICENSE_FILE) {
167093
+ // path.resolve() produces an absolute path with all '..' segments resolved,
167094
+ // so a separate resolved.includes('..') check is unnecessary.
167095
+ const resolved = path.resolve(process.env.VISOR_LICENSE_FILE);
167096
+ const home = process.env.HOME || process.env.USERPROFILE || '';
167097
+ const allowedPrefixes = [path.normalize(process.cwd())];
167098
+ if (home)
167099
+ allowedPrefixes.push(path.normalize(path.join(home, '.config', 'visor')));
167100
+ // Resolve symlinks so an attacker cannot create a symlink inside an
167101
+ // allowed prefix that points to an arbitrary file outside it.
167102
+ let realPath;
167103
+ try {
167104
+ realPath = fs.realpathSync(resolved);
167105
+ }
167106
+ catch {
167107
+ return null; // File doesn't exist or isn't accessible
167108
+ }
167109
+ const isSafe = allowedPrefixes.some(prefix => realPath === prefix || realPath.startsWith(prefix + path.sep));
167110
+ if (!isSafe)
167111
+ return null;
167112
+ return this.readFile(realPath);
167113
+ }
167114
+ // 3. .visor-license in cwd
167115
+ const cwdPath = path.join(process.cwd(), '.visor-license');
167116
+ const cwdToken = this.readFile(cwdPath);
167117
+ if (cwdToken)
167118
+ return cwdToken;
167119
+ // 4. ~/.config/visor/.visor-license
167120
+ const home = process.env.HOME || process.env.USERPROFILE || '';
167121
+ if (home) {
167122
+ const configPath = path.join(home, '.config', 'visor', '.visor-license');
167123
+ const configToken = this.readFile(configPath);
167124
+ if (configToken)
167125
+ return configToken;
167126
+ }
167127
+ return null;
167128
+ }
167129
+ readFile(filePath) {
167130
+ try {
167131
+ return fs.readFileSync(filePath, 'utf-8').trim();
167132
+ }
167133
+ catch {
167134
+ return null;
167135
+ }
167136
+ }
167137
+ verifyAndDecode(token) {
167138
+ try {
167139
+ const parts = token.split('.');
167140
+ if (parts.length !== 3)
167141
+ return null;
167142
+ const [headerB64, payloadB64, signatureB64] = parts;
167143
+ // Decode header to verify algorithm
167144
+ const header = JSON.parse(Buffer.from(headerB64, 'base64url').toString());
167145
+ if (header.alg !== 'EdDSA')
167146
+ return null;
167147
+ // Verify signature
167148
+ const data = `${headerB64}.${payloadB64}`;
167149
+ const signature = Buffer.from(signatureB64, 'base64url');
167150
+ const publicKey = crypto.createPublicKey(LicenseValidator.PUBLIC_KEY);
167151
+ // Validate that the loaded public key is actually Ed25519 (OID 1.3.101.112).
167152
+ // This prevents algorithm-confusion attacks if the embedded key were ever
167153
+ // swapped to a different type.
167154
+ if (publicKey.asymmetricKeyType !== 'ed25519') {
167155
+ return null;
167156
+ }
167157
+ // Ed25519 verification: algorithm must be null because EdDSA performs its
167158
+ // own internal hashing (SHA-512) — passing a digest algorithm here would
167159
+ // cause Node.js to throw. The key type is validated above.
167160
+ const isValid = crypto.verify(null, Buffer.from(data), publicKey, signature);
167161
+ if (!isValid)
167162
+ return null;
167163
+ // Decode payload
167164
+ const payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString());
167165
+ // Validate required fields
167166
+ if (!payload.org ||
167167
+ !Array.isArray(payload.features) ||
167168
+ typeof payload.exp !== 'number' ||
167169
+ typeof payload.iat !== 'number' ||
167170
+ !payload.sub) {
167171
+ return null;
167172
+ }
167173
+ // Check expiry (with grace period)
167174
+ const now = Date.now();
167175
+ const expiryMs = payload.exp * 1000;
167176
+ if (now >= expiryMs + LicenseValidator.GRACE_PERIOD) {
167177
+ return null;
167178
+ }
167179
+ return payload;
167180
+ }
167181
+ catch {
167182
+ return null;
167183
+ }
167184
+ }
167185
+ }
167186
+ exports.LicenseValidator = LicenseValidator;
167187
+
167188
+
167189
+ /***/ }),
167190
+
167191
+ /***/ 87068:
167192
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167193
+
167194
+ "use strict";
167195
+
167196
+ /**
167197
+ * Copyright (c) ProbeLabs. All rights reserved.
167198
+ * Licensed under the Elastic License 2.0; you may not use this file except
167199
+ * in compliance with the Elastic License 2.0.
167200
+ */
167201
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167202
+ if (k2 === undefined) k2 = k;
167203
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167204
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167205
+ desc = { enumerable: true, get: function() { return m[k]; } };
167206
+ }
167207
+ Object.defineProperty(o, k2, desc);
167208
+ }) : (function(o, m, k, k2) {
167209
+ if (k2 === undefined) k2 = k;
167210
+ o[k2] = m[k];
167211
+ }));
167212
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167213
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167214
+ }) : function(o, v) {
167215
+ o["default"] = v;
167216
+ });
167217
+ var __importStar = (this && this.__importStar) || (function () {
167218
+ var ownKeys = function(o) {
167219
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167220
+ var ar = [];
167221
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167222
+ return ar;
167223
+ };
167224
+ return ownKeys(o);
167225
+ };
167226
+ return function (mod) {
167227
+ if (mod && mod.__esModule) return mod;
167228
+ var result = {};
167229
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167230
+ __setModuleDefault(result, mod);
167231
+ return result;
167232
+ };
167233
+ })();
167234
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167235
+ exports.loadEnterprisePolicyEngine = loadEnterprisePolicyEngine;
167236
+ exports.loadEnterpriseStoreBackend = loadEnterpriseStoreBackend;
167237
+ const default_engine_1 = __nccwpck_require__(93866);
167238
+ /**
167239
+ * Load the enterprise policy engine if licensed, otherwise return the default no-op engine.
167240
+ *
167241
+ * This is the sole import boundary between OSS and enterprise code. Core code
167242
+ * must only import from this module (via dynamic `await import()`), never from
167243
+ * individual enterprise submodules.
167244
+ */
167245
+ async function loadEnterprisePolicyEngine(config) {
167246
+ try {
167247
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167248
+ const validator = new LicenseValidator();
167249
+ const license = await validator.loadAndValidate();
167250
+ if (!license || !validator.hasFeature('policy')) {
167251
+ return new default_engine_1.DefaultPolicyEngine();
167252
+ }
167253
+ if (validator.isInGracePeriod()) {
167254
+ // eslint-disable-next-line no-console
167255
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167256
+ 'Please renew your license.');
167257
+ }
167258
+ const { OpaPolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(39530)));
167259
+ const engine = new OpaPolicyEngine(config);
167260
+ await engine.initialize(config);
167261
+ return engine;
167262
+ }
167263
+ catch (err) {
167264
+ // Enterprise code not available or initialization failed
167265
+ const msg = err instanceof Error ? err.message : String(err);
167266
+ try {
167267
+ const { logger } = __nccwpck_require__(86999);
167268
+ logger.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
167269
+ }
167270
+ catch {
167271
+ // silent
167272
+ }
167273
+ return new default_engine_1.DefaultPolicyEngine();
167274
+ }
167275
+ }
167276
+ /**
167277
+ * Load the enterprise schedule store backend if licensed.
167278
+ *
167279
+ * @param driver Database driver ('postgresql', 'mysql', or 'mssql')
167280
+ * @param storageConfig Storage configuration with connection details
167281
+ * @param haConfig Optional HA configuration
167282
+ * @throws Error if enterprise license is not available or missing 'scheduler-sql' feature
167283
+ */
167284
+ async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
167285
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167286
+ const validator = new LicenseValidator();
167287
+ const license = await validator.loadAndValidate();
167288
+ if (!license || !validator.hasFeature('scheduler-sql')) {
167289
+ throw new Error(`The ${driver} schedule storage driver requires a Visor Enterprise license ` +
167290
+ `with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`);
167291
+ }
167292
+ if (validator.isInGracePeriod()) {
167293
+ // eslint-disable-next-line no-console
167294
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167295
+ 'Please renew your license.');
167296
+ }
167297
+ const { KnexStoreBackend } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(63737)));
167298
+ return new KnexStoreBackend(driver, storageConfig, haConfig);
167299
+ }
167300
+
167301
+
167302
+ /***/ }),
167303
+
167304
+ /***/ 628:
167305
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167306
+
167307
+ "use strict";
167308
+
167309
+ /**
167310
+ * Copyright (c) ProbeLabs. All rights reserved.
167311
+ * Licensed under the Elastic License 2.0; you may not use this file except
167312
+ * in compliance with the Elastic License 2.0.
167313
+ */
167314
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167315
+ if (k2 === undefined) k2 = k;
167316
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167317
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167318
+ desc = { enumerable: true, get: function() { return m[k]; } };
167319
+ }
167320
+ Object.defineProperty(o, k2, desc);
167321
+ }) : (function(o, m, k, k2) {
167322
+ if (k2 === undefined) k2 = k;
167323
+ o[k2] = m[k];
167324
+ }));
167325
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167326
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167327
+ }) : function(o, v) {
167328
+ o["default"] = v;
167329
+ });
167330
+ var __importStar = (this && this.__importStar) || (function () {
167331
+ var ownKeys = function(o) {
167332
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167333
+ var ar = [];
167334
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167335
+ return ar;
167336
+ };
167337
+ return ownKeys(o);
167338
+ };
167339
+ return function (mod) {
167340
+ if (mod && mod.__esModule) return mod;
167341
+ var result = {};
167342
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167343
+ __setModuleDefault(result, mod);
167344
+ return result;
167345
+ };
167346
+ })();
167347
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167348
+ exports.OpaCompiler = void 0;
167349
+ const fs = __importStar(__nccwpck_require__(79896));
167350
+ const path = __importStar(__nccwpck_require__(16928));
167351
+ const os = __importStar(__nccwpck_require__(70857));
167352
+ const crypto = __importStar(__nccwpck_require__(76982));
167353
+ const child_process_1 = __nccwpck_require__(35317);
167354
+ /**
167355
+ * OPA Rego Compiler - compiles .rego policy files to WASM bundles using the `opa` CLI.
167356
+ *
167357
+ * Handles:
167358
+ * - Resolving input paths to WASM bytes (direct .wasm, directory with policy.wasm, or .rego files)
167359
+ * - Compiling .rego files to WASM via `opa build`
167360
+ * - Caching compiled bundles based on content hashes
167361
+ * - Extracting policy.wasm from OPA tar.gz bundles
167362
+ *
167363
+ * Requires:
167364
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
167365
+ */
167366
+ class OpaCompiler {
167367
+ static CACHE_DIR = path.join(os.tmpdir(), 'visor-opa-cache');
167368
+ /**
167369
+ * Resolve the input paths to WASM bytes.
167370
+ *
167371
+ * Strategy:
167372
+ * 1. If any path is a .wasm file, read it directly
167373
+ * 2. If a directory contains policy.wasm, read it
167374
+ * 3. Otherwise, collect all .rego files and auto-compile via `opa build`
167375
+ */
167376
+ async resolveWasmBytes(paths) {
167377
+ // Collect .rego files and check for existing .wasm
167378
+ const regoFiles = [];
167379
+ for (const p of paths) {
167380
+ const resolved = path.resolve(p);
167381
+ // Reject paths containing '..' after resolution (path traversal)
167382
+ if (path.normalize(resolved).includes('..')) {
167383
+ throw new Error(`Policy path contains traversal sequences: ${p}`);
167384
+ }
167385
+ // Direct .wasm file
167386
+ if (resolved.endsWith('.wasm') && fs.existsSync(resolved)) {
167387
+ return fs.readFileSync(resolved);
167388
+ }
167389
+ if (!fs.existsSync(resolved))
167390
+ continue;
167391
+ const stat = fs.statSync(resolved);
167392
+ if (stat.isDirectory()) {
167393
+ // Check for pre-compiled policy.wasm in directory
167394
+ const wasmCandidate = path.join(resolved, 'policy.wasm');
167395
+ if (fs.existsSync(wasmCandidate)) {
167396
+ return fs.readFileSync(wasmCandidate);
167397
+ }
167398
+ // Collect all .rego files from directory
167399
+ const files = fs.readdirSync(resolved);
167400
+ for (const f of files) {
167401
+ if (f.endsWith('.rego')) {
167402
+ regoFiles.push(path.join(resolved, f));
167403
+ }
167404
+ }
167405
+ }
167406
+ else if (resolved.endsWith('.rego')) {
167407
+ regoFiles.push(resolved);
167408
+ }
167409
+ }
167410
+ if (regoFiles.length === 0) {
167411
+ throw new Error(`OPA WASM evaluator: no .wasm bundle or .rego files found in: ${paths.join(', ')}`);
167412
+ }
167413
+ // Auto-compile .rego -> .wasm
167414
+ return this.compileRego(regoFiles);
167415
+ }
167416
+ /**
167417
+ * Auto-compile .rego files to a WASM bundle using the `opa` CLI.
167418
+ *
167419
+ * Caches the compiled bundle based on a content hash of all input .rego files
167420
+ * so subsequent runs skip compilation if policies haven't changed.
167421
+ */
167422
+ compileRego(regoFiles) {
167423
+ // Check that `opa` CLI is available
167424
+ try {
167425
+ (0, child_process_1.execFileSync)('opa', ['version'], { stdio: 'pipe' });
167426
+ }
167427
+ catch {
167428
+ throw new Error('OPA CLI (`opa`) not found on PATH. Install it from https://www.openpolicyagent.org/docs/latest/#running-opa\n' +
167429
+ 'Or pre-compile your .rego files: opa build -t wasm -e visor -o bundle.tar.gz ' +
167430
+ regoFiles.join(' '));
167431
+ }
167432
+ // Compute content hash for cache key
167433
+ const hash = crypto.createHash('sha256');
167434
+ for (const f of regoFiles.sort()) {
167435
+ hash.update(fs.readFileSync(f));
167436
+ hash.update(f); // include filename for disambiguation
167437
+ }
167438
+ const cacheKey = hash.digest('hex').slice(0, 16);
167439
+ const cacheDir = OpaCompiler.CACHE_DIR;
167440
+ const cachedWasm = path.join(cacheDir, `${cacheKey}.wasm`);
167441
+ // Return cached bundle if still valid
167442
+ if (fs.existsSync(cachedWasm)) {
167443
+ return fs.readFileSync(cachedWasm);
167444
+ }
167445
+ // Compile to WASM via opa build
167446
+ fs.mkdirSync(cacheDir, { recursive: true });
167447
+ const bundleTar = path.join(cacheDir, `${cacheKey}-bundle.tar.gz`);
167448
+ try {
167449
+ const args = [
167450
+ 'build',
167451
+ '-t',
167452
+ 'wasm',
167453
+ '-e',
167454
+ 'visor', // entrypoint: the visor package tree
167455
+ '-o',
167456
+ bundleTar,
167457
+ ...regoFiles,
167458
+ ];
167459
+ (0, child_process_1.execFileSync)('opa', args, {
167460
+ stdio: 'pipe',
167461
+ timeout: 30000,
167462
+ });
167463
+ }
167464
+ catch (err) {
167465
+ const stderr = err?.stderr?.toString() || '';
167466
+ throw new Error(`Failed to compile .rego files to WASM:\n${stderr}\n` +
167467
+ 'Ensure your .rego files are valid and the `opa` CLI is installed.');
167468
+ }
167469
+ // Extract policy.wasm from the tar.gz bundle
167470
+ // OPA bundles are tar.gz with /policy.wasm inside
167471
+ try {
167472
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, '/policy.wasm'], {
167473
+ stdio: 'pipe',
167474
+ });
167475
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
167476
+ if (fs.existsSync(extractedWasm)) {
167477
+ // Move to cache-key named file
167478
+ fs.renameSync(extractedWasm, cachedWasm);
167479
+ }
167480
+ }
167481
+ catch {
167482
+ // Some tar implementations don't like leading /
167483
+ try {
167484
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, 'policy.wasm'], {
167485
+ stdio: 'pipe',
167486
+ });
167487
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
167488
+ if (fs.existsSync(extractedWasm)) {
167489
+ fs.renameSync(extractedWasm, cachedWasm);
167490
+ }
167491
+ }
167492
+ catch (err2) {
167493
+ throw new Error(`Failed to extract policy.wasm from OPA bundle: ${err2?.message || err2}`);
167494
+ }
167495
+ }
167496
+ // Clean up tar
167497
+ try {
167498
+ fs.unlinkSync(bundleTar);
167499
+ }
167500
+ catch { }
167501
+ if (!fs.existsSync(cachedWasm)) {
167502
+ throw new Error('OPA build succeeded but policy.wasm was not found in the bundle');
167503
+ }
167504
+ return fs.readFileSync(cachedWasm);
167505
+ }
167506
+ }
167507
+ exports.OpaCompiler = OpaCompiler;
167508
+
167509
+
167510
+ /***/ }),
167511
+
167512
+ /***/ 44693:
167513
+ /***/ ((__unused_webpack_module, exports) => {
167514
+
167515
+ "use strict";
167516
+
167517
+ /**
167518
+ * Copyright (c) ProbeLabs. All rights reserved.
167519
+ * Licensed under the Elastic License 2.0; you may not use this file except
167520
+ * in compliance with the Elastic License 2.0.
167521
+ */
167522
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167523
+ exports.OpaHttpEvaluator = void 0;
167524
+ /**
167525
+ * OPA HTTP Evaluator - evaluates policies via an external OPA server's REST API.
167526
+ *
167527
+ * Uses the built-in `fetch` API (Node 18+), so no extra dependencies are needed.
167528
+ */
167529
+ class OpaHttpEvaluator {
167530
+ baseUrl;
167531
+ timeout;
167532
+ constructor(baseUrl, timeout = 5000) {
167533
+ // Validate URL format and protocol
167534
+ let parsed;
167535
+ try {
167536
+ parsed = new URL(baseUrl);
167537
+ }
167538
+ catch {
167539
+ throw new Error(`OPA HTTP evaluator: invalid URL: ${baseUrl}`);
167540
+ }
167541
+ if (!['http:', 'https:'].includes(parsed.protocol)) {
167542
+ throw new Error(`OPA HTTP evaluator: url must use http:// or https:// protocol, got: ${baseUrl}`);
167543
+ }
167544
+ // Block cloud metadata, loopback, link-local, and private network addresses
167545
+ const hostname = parsed.hostname;
167546
+ if (this.isBlockedHostname(hostname)) {
167547
+ throw new Error(`OPA HTTP evaluator: url must not point to internal, loopback, or private network addresses`);
167548
+ }
167549
+ // Normalize: strip trailing slash
167550
+ this.baseUrl = baseUrl.replace(/\/+$/, '');
167551
+ this.timeout = timeout;
167552
+ }
167553
+ /**
167554
+ * Check if a hostname is blocked due to SSRF concerns.
167555
+ *
167556
+ * Blocks:
167557
+ * - Loopback addresses (127.x.x.x, localhost, 0.0.0.0, ::1)
167558
+ * - Link-local addresses (169.254.x.x)
167559
+ * - Private networks (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
167560
+ * - IPv6 unique local addresses (fd00::/8)
167561
+ * - Cloud metadata services (*.internal)
167562
+ */
167563
+ isBlockedHostname(hostname) {
167564
+ if (!hostname)
167565
+ return true; // block empty hostnames
167566
+ // Normalize hostname: lowercase and remove brackets for IPv6
167567
+ const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
167568
+ // Block .internal domains (cloud metadata services)
167569
+ if (normalized === 'metadata.google.internal' || normalized.endsWith('.internal')) {
167570
+ return true;
167571
+ }
167572
+ // Block localhost variants
167573
+ if (normalized === 'localhost' || normalized === 'localhost.localdomain') {
167574
+ return true;
167575
+ }
167576
+ // Block IPv6 loopback
167577
+ if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
167578
+ return true;
167579
+ }
167580
+ // Check IPv4 patterns
167581
+ const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
167582
+ const ipv4Match = normalized.match(ipv4Pattern);
167583
+ if (ipv4Match) {
167584
+ const octets = ipv4Match.slice(1, 5).map(Number);
167585
+ // Validate octets are in range [0, 255]
167586
+ if (octets.some(octet => octet > 255)) {
167587
+ return false;
167588
+ }
167589
+ const [a, b] = octets;
167590
+ // Block loopback: 127.0.0.0/8
167591
+ if (a === 127) {
167592
+ return true;
167593
+ }
167594
+ // Block 0.0.0.0/8 (this host)
167595
+ if (a === 0) {
167596
+ return true;
167597
+ }
167598
+ // Block link-local: 169.254.0.0/16
167599
+ if (a === 169 && b === 254) {
167600
+ return true;
167601
+ }
167602
+ // Block private networks
167603
+ // 10.0.0.0/8
167604
+ if (a === 10) {
167605
+ return true;
167606
+ }
167607
+ // 172.16.0.0/12 (172.16.x.x through 172.31.x.x)
167608
+ if (a === 172 && b >= 16 && b <= 31) {
167609
+ return true;
167610
+ }
167611
+ // 192.168.0.0/16
167612
+ if (a === 192 && b === 168) {
167613
+ return true;
167614
+ }
167615
+ }
167616
+ // Check IPv6 patterns
167617
+ // Block unique local addresses: fd00::/8
167618
+ if (normalized.startsWith('fd') || normalized.startsWith('fc')) {
167619
+ return true;
167620
+ }
167621
+ // Block link-local: fe80::/10
167622
+ if (normalized.startsWith('fe80:')) {
167623
+ return true;
167624
+ }
167625
+ return false;
167626
+ }
167627
+ /**
167628
+ * Evaluate a policy rule against an input document via OPA REST API.
167629
+ *
167630
+ * @param input - The input document to evaluate
167631
+ * @param rulePath - OPA rule path (e.g., 'visor/check/execute')
167632
+ * @returns The result object from OPA, or undefined on error
167633
+ */
167634
+ async evaluate(input, rulePath) {
167635
+ // OPA Data API: POST /v1/data/<path>
167636
+ const encodedPath = rulePath
167637
+ .split('/')
167638
+ .map(s => encodeURIComponent(s))
167639
+ .join('/');
167640
+ const url = `${this.baseUrl}/v1/data/${encodedPath}`;
167641
+ const controller = new AbortController();
167642
+ const timer = setTimeout(() => controller.abort(), this.timeout);
167643
+ try {
167644
+ const response = await fetch(url, {
167645
+ method: 'POST',
167646
+ headers: { 'Content-Type': 'application/json' },
167647
+ body: JSON.stringify({ input }),
167648
+ signal: controller.signal,
167649
+ });
167650
+ if (!response.ok) {
167651
+ throw new Error(`OPA HTTP ${response.status}: ${response.statusText}`);
167652
+ }
167653
+ let body;
167654
+ try {
167655
+ body = await response.json();
167656
+ }
167657
+ catch (jsonErr) {
167658
+ throw new Error(`OPA HTTP evaluator: failed to parse JSON response: ${jsonErr instanceof Error ? jsonErr.message : String(jsonErr)}`);
167659
+ }
167660
+ // OPA returns { result: { ... } }
167661
+ return body?.result;
167662
+ }
167663
+ finally {
167664
+ clearTimeout(timer);
167665
+ }
167666
+ }
167667
+ async shutdown() {
167668
+ // No persistent connections to close
167669
+ }
167670
+ }
167671
+ exports.OpaHttpEvaluator = OpaHttpEvaluator;
167672
+
167673
+
167674
+ /***/ }),
167675
+
167676
+ /***/ 39530:
167677
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
167678
+
167679
+ "use strict";
167680
+
167681
+ /**
167682
+ * Copyright (c) ProbeLabs. All rights reserved.
167683
+ * Licensed under the Elastic License 2.0; you may not use this file except
167684
+ * in compliance with the Elastic License 2.0.
167685
+ */
167686
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167687
+ exports.OpaPolicyEngine = void 0;
167688
+ const opa_wasm_evaluator_1 = __nccwpck_require__(8613);
167689
+ const opa_http_evaluator_1 = __nccwpck_require__(44693);
167690
+ const policy_input_builder_1 = __nccwpck_require__(17117);
167691
+ /**
167692
+ * Enterprise OPA Policy Engine.
167693
+ *
167694
+ * Wraps both WASM (local) and HTTP (remote) OPA evaluators behind the
167695
+ * OSS PolicyEngine interface. All OPA input building and role resolution
167696
+ * is handled internally — the OSS call sites pass only plain types.
167697
+ */
167698
+ class OpaPolicyEngine {
167699
+ evaluator = null;
167700
+ fallback;
167701
+ timeout;
167702
+ config;
167703
+ inputBuilder = null;
167704
+ logger = null;
167705
+ constructor(config) {
167706
+ this.config = config;
167707
+ this.fallback = config.fallback || 'deny';
167708
+ this.timeout = config.timeout || 5000;
167709
+ }
167710
+ async initialize(config) {
167711
+ // Resolve logger once at initialization
167712
+ try {
167713
+ this.logger = (__nccwpck_require__(86999).logger);
167714
+ }
167715
+ catch {
167716
+ // logger not available in this context
167717
+ }
167718
+ // Build actor/repo context from environment (available at engine init time)
167719
+ const actor = {
167720
+ authorAssociation: process.env.VISOR_AUTHOR_ASSOCIATION,
167721
+ login: process.env.VISOR_AUTHOR_LOGIN || process.env.GITHUB_ACTOR,
167722
+ isLocalMode: !process.env.GITHUB_ACTIONS,
167723
+ };
167724
+ const repo = {
167725
+ owner: process.env.GITHUB_REPOSITORY_OWNER,
167726
+ name: process.env.GITHUB_REPOSITORY?.split('/')[1],
167727
+ branch: process.env.GITHUB_HEAD_REF,
167728
+ baseBranch: process.env.GITHUB_BASE_REF,
167729
+ event: process.env.GITHUB_EVENT_NAME,
167730
+ };
167731
+ const prNum = process.env.GITHUB_PR_NUMBER
167732
+ ? parseInt(process.env.GITHUB_PR_NUMBER, 10)
167733
+ : undefined;
167734
+ const pullRequest = {
167735
+ number: prNum !== undefined && Number.isFinite(prNum) ? prNum : undefined,
167736
+ };
167737
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(config, actor, repo, pullRequest);
167738
+ if (config.engine === 'local') {
167739
+ if (!config.rules) {
167740
+ throw new Error('OPA local mode requires `policy.rules` path to .wasm or .rego files');
167741
+ }
167742
+ const wasm = new opa_wasm_evaluator_1.OpaWasmEvaluator();
167743
+ await wasm.initialize(config.rules);
167744
+ if (config.data) {
167745
+ wasm.loadData(config.data);
167746
+ }
167747
+ this.evaluator = wasm;
167748
+ }
167749
+ else if (config.engine === 'remote') {
167750
+ if (!config.url) {
167751
+ throw new Error('OPA remote mode requires `policy.url` pointing to OPA server');
167752
+ }
167753
+ this.evaluator = new opa_http_evaluator_1.OpaHttpEvaluator(config.url, this.timeout);
167754
+ }
167755
+ else {
167756
+ this.evaluator = null;
167757
+ }
167758
+ }
167759
+ /**
167760
+ * Update actor/repo/PR context (e.g., after PR info becomes available).
167761
+ * Called by the enterprise loader when engine context is enriched.
167762
+ */
167763
+ setActorContext(actor, repo, pullRequest) {
167764
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(this.config, actor, repo, pullRequest);
167765
+ }
167766
+ async evaluateCheckExecution(checkId, checkConfig) {
167767
+ if (!this.evaluator || !this.inputBuilder)
167768
+ return { allowed: true };
167769
+ const cfg = checkConfig && typeof checkConfig === 'object'
167770
+ ? checkConfig
167771
+ : {};
167772
+ const policyOverride = cfg.policy;
167773
+ const input = this.inputBuilder.forCheckExecution({
167774
+ id: checkId,
167775
+ type: cfg.type || 'ai',
167776
+ group: cfg.group,
167777
+ tags: cfg.tags,
167778
+ criticality: cfg.criticality,
167779
+ sandbox: cfg.sandbox,
167780
+ policy: policyOverride,
167781
+ });
167782
+ return this.doEvaluate(input, this.resolveRulePath('check.execute', policyOverride?.rule));
167783
+ }
167784
+ async evaluateToolInvocation(serverName, methodName, transport) {
167785
+ if (!this.evaluator || !this.inputBuilder)
167786
+ return { allowed: true };
167787
+ const input = this.inputBuilder.forToolInvocation(serverName, methodName, transport);
167788
+ return this.doEvaluate(input, 'visor/tool/invoke');
167789
+ }
167790
+ async evaluateCapabilities(checkId, capabilities) {
167791
+ if (!this.evaluator || !this.inputBuilder)
167792
+ return { allowed: true };
167793
+ const input = this.inputBuilder.forCapabilityResolve(checkId, capabilities);
167794
+ return this.doEvaluate(input, 'visor/capability/resolve');
167795
+ }
167796
+ async shutdown() {
167797
+ if (this.evaluator && 'shutdown' in this.evaluator) {
167798
+ await this.evaluator.shutdown();
167799
+ }
167800
+ this.evaluator = null;
167801
+ this.inputBuilder = null;
167802
+ }
167803
+ resolveRulePath(defaultScope, override) {
167804
+ if (override) {
167805
+ return override.startsWith('visor/') ? override : `visor/${override}`;
167806
+ }
167807
+ return `visor/${defaultScope.replace(/\./g, '/')}`;
167808
+ }
167809
+ async doEvaluate(input, rulePath) {
167810
+ try {
167811
+ this.logger?.debug(`[PolicyEngine] Evaluating ${rulePath}`, JSON.stringify(input));
167812
+ let timer;
167813
+ const timeoutPromise = new Promise((_resolve, reject) => {
167814
+ timer = setTimeout(() => reject(new Error('policy evaluation timeout')), this.timeout);
167815
+ });
167816
+ try {
167817
+ const result = await Promise.race([this.rawEvaluate(input, rulePath), timeoutPromise]);
167818
+ const decision = this.parseDecision(result);
167819
+ // In warn mode, override denied decisions to allowed but flag as warn
167820
+ if (!decision.allowed && this.fallback === 'warn') {
167821
+ decision.allowed = true;
167822
+ decision.warn = true;
167823
+ decision.reason = `audit: ${decision.reason || 'policy denied'}`;
167824
+ }
167825
+ this.logger?.debug(`[PolicyEngine] Decision for ${rulePath}: allowed=${decision.allowed}, warn=${decision.warn || false}, reason=${decision.reason || 'none'}`);
167826
+ return decision;
167827
+ }
167828
+ finally {
167829
+ if (timer)
167830
+ clearTimeout(timer);
167831
+ }
167832
+ }
167833
+ catch (err) {
167834
+ const msg = err instanceof Error ? err.message : String(err);
167835
+ this.logger?.warn(`[PolicyEngine] Evaluation failed for ${rulePath}: ${msg}`);
167836
+ return {
167837
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
167838
+ warn: this.fallback === 'warn' ? true : undefined,
167839
+ reason: `policy evaluation failed, fallback=${this.fallback}`,
167840
+ };
167841
+ }
167842
+ }
167843
+ async rawEvaluate(input, rulePath) {
167844
+ if (this.evaluator instanceof opa_wasm_evaluator_1.OpaWasmEvaluator) {
167845
+ const result = await this.evaluator.evaluate(input);
167846
+ // WASM compiled with `-e visor` entrypoint returns the full visor package tree.
167847
+ // Navigate to the specific rule subtree using rulePath segments.
167848
+ // e.g., 'visor/check/execute' → result.check.execute
167849
+ return this.navigateWasmResult(result, rulePath);
167850
+ }
167851
+ return this.evaluator.evaluate(input, rulePath);
167852
+ }
167853
+ /**
167854
+ * Navigate nested OPA WASM result tree to reach the specific rule's output.
167855
+ * The WASM entrypoint `-e visor` means the result root IS the visor package,
167856
+ * so we strip the `visor/` prefix and walk the remaining segments.
167857
+ */
167858
+ navigateWasmResult(result, rulePath) {
167859
+ if (!result || typeof result !== 'object')
167860
+ return result;
167861
+ // Strip the 'visor/' prefix (matches our compilation entrypoint)
167862
+ const segments = rulePath.replace(/^visor\//, '').split('/');
167863
+ let current = result;
167864
+ for (const seg of segments) {
167865
+ if (current && typeof current === 'object' && seg in current) {
167866
+ current = current[seg];
167867
+ }
167868
+ else {
167869
+ return undefined; // path not found in result tree
167870
+ }
167871
+ }
167872
+ return current;
167873
+ }
167874
+ parseDecision(result) {
167875
+ if (result === undefined || result === null) {
167876
+ return {
167877
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
167878
+ warn: this.fallback === 'warn' ? true : undefined,
167879
+ reason: this.fallback === 'warn' ? 'audit: no policy result' : 'no policy result',
167880
+ };
167881
+ }
167882
+ const allowed = result.allowed !== false;
167883
+ const decision = {
167884
+ allowed,
167885
+ reason: result.reason,
167886
+ };
167887
+ if (result.capabilities) {
167888
+ decision.capabilities = result.capabilities;
167889
+ }
167890
+ return decision;
167891
+ }
167892
+ }
167893
+ exports.OpaPolicyEngine = OpaPolicyEngine;
167894
+
167895
+
167896
+ /***/ }),
167897
+
167898
+ /***/ 8613:
167899
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167900
+
167901
+ "use strict";
167902
+
167903
+ /**
167904
+ * Copyright (c) ProbeLabs. All rights reserved.
167905
+ * Licensed under the Elastic License 2.0; you may not use this file except
167906
+ * in compliance with the Elastic License 2.0.
167907
+ */
167908
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167909
+ if (k2 === undefined) k2 = k;
167910
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167911
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167912
+ desc = { enumerable: true, get: function() { return m[k]; } };
167913
+ }
167914
+ Object.defineProperty(o, k2, desc);
167915
+ }) : (function(o, m, k, k2) {
167916
+ if (k2 === undefined) k2 = k;
167917
+ o[k2] = m[k];
167918
+ }));
167919
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167920
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167921
+ }) : function(o, v) {
167922
+ o["default"] = v;
167923
+ });
167924
+ var __importStar = (this && this.__importStar) || (function () {
167925
+ var ownKeys = function(o) {
167926
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167927
+ var ar = [];
167928
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167929
+ return ar;
167930
+ };
167931
+ return ownKeys(o);
167932
+ };
167933
+ return function (mod) {
167934
+ if (mod && mod.__esModule) return mod;
167935
+ var result = {};
167936
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167937
+ __setModuleDefault(result, mod);
167938
+ return result;
167939
+ };
167940
+ })();
167941
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167942
+ exports.OpaWasmEvaluator = void 0;
167943
+ const fs = __importStar(__nccwpck_require__(79896));
167944
+ const path = __importStar(__nccwpck_require__(16928));
167945
+ const opa_compiler_1 = __nccwpck_require__(628);
167946
+ /**
167947
+ * OPA WASM Evaluator - loads and evaluates OPA policies locally.
167948
+ *
167949
+ * Supports three input formats:
167950
+ * 1. Pre-compiled `.wasm` bundle — loaded directly (fastest startup)
167951
+ * 2. `.rego` files or directory — auto-compiled to WASM via `opa build` CLI
167952
+ * 3. Directory with `policy.wasm` inside — loaded directly
167953
+ *
167954
+ * Compilation and caching of .rego files is delegated to {@link OpaCompiler}.
167955
+ *
167956
+ * Requires:
167957
+ * - `@open-policy-agent/opa-wasm` npm package (optional dep)
167958
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
167959
+ */
167960
+ class OpaWasmEvaluator {
167961
+ policy = null;
167962
+ dataDocument = {};
167963
+ compiler = new opa_compiler_1.OpaCompiler();
167964
+ async initialize(rulesPath) {
167965
+ const paths = Array.isArray(rulesPath) ? rulesPath : [rulesPath];
167966
+ const wasmBytes = await this.compiler.resolveWasmBytes(paths);
167967
+ try {
167968
+ // Use createRequire to load the optional dep at runtime without ncc bundling it.
167969
+ // `new Function('id', 'return require(id)')` fails in ncc bundles because
167970
+ // `require` is not in the `new Function` scope. `createRequire` works correctly
167971
+ // because it creates a real Node.js require rooted at the given path.
167972
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
167973
+ const { createRequire } = __nccwpck_require__(73339);
167974
+ const runtimeRequire = createRequire(__filename);
167975
+ const opaWasm = runtimeRequire('@open-policy-agent/opa-wasm');
167976
+ const loadPolicy = opaWasm.loadPolicy || opaWasm.default?.loadPolicy;
167977
+ if (!loadPolicy) {
167978
+ throw new Error('loadPolicy not found in @open-policy-agent/opa-wasm');
167979
+ }
167980
+ this.policy = await loadPolicy(wasmBytes);
167981
+ }
167982
+ catch (err) {
167983
+ if (err?.code === 'MODULE_NOT_FOUND' || err?.code === 'ERR_MODULE_NOT_FOUND') {
167984
+ throw new Error('OPA WASM evaluator requires @open-policy-agent/opa-wasm. ' +
167985
+ 'Install it with: npm install @open-policy-agent/opa-wasm');
167986
+ }
167987
+ throw err;
167988
+ }
167989
+ }
167990
+ /**
167991
+ * Load external data from a JSON file to use as the OPA data document.
167992
+ * The loaded data will be passed to `policy.setData()` during evaluation,
167993
+ * making it available in Rego via `data.<key>`.
167994
+ */
167995
+ loadData(dataPath) {
167996
+ const resolved = path.resolve(dataPath);
167997
+ if (path.normalize(resolved).includes('..')) {
167998
+ throw new Error(`Data path contains traversal sequences: ${dataPath}`);
167999
+ }
168000
+ if (!fs.existsSync(resolved)) {
168001
+ throw new Error(`OPA data file not found: ${resolved}`);
168002
+ }
168003
+ const stat = fs.statSync(resolved);
168004
+ if (stat.size > 10 * 1024 * 1024) {
168005
+ throw new Error(`OPA data file exceeds 10MB limit: ${resolved} (${stat.size} bytes)`);
168006
+ }
168007
+ const raw = fs.readFileSync(resolved, 'utf-8');
168008
+ try {
168009
+ const parsed = JSON.parse(raw);
168010
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
168011
+ throw new Error('OPA data file must contain a JSON object (not an array or primitive)');
168012
+ }
168013
+ this.dataDocument = parsed;
168014
+ }
168015
+ catch (err) {
168016
+ if (err.message.startsWith('OPA data file must')) {
168017
+ throw err;
168018
+ }
168019
+ throw new Error(`Failed to parse OPA data file ${resolved}: ${err.message}`);
168020
+ }
168021
+ }
168022
+ async evaluate(input) {
168023
+ if (!this.policy) {
168024
+ throw new Error('OPA WASM evaluator not initialized');
168025
+ }
168026
+ this.policy.setData(this.dataDocument);
168027
+ const resultSet = this.policy.evaluate(input);
168028
+ if (Array.isArray(resultSet) && resultSet.length > 0) {
168029
+ return resultSet[0].result;
168030
+ }
168031
+ return undefined;
168032
+ }
168033
+ async shutdown() {
168034
+ if (this.policy) {
168035
+ // opa-wasm policy objects may have a close/free method for WASM cleanup
168036
+ if (typeof this.policy.close === 'function') {
168037
+ try {
168038
+ this.policy.close();
168039
+ }
168040
+ catch { }
168041
+ }
168042
+ else if (typeof this.policy.free === 'function') {
168043
+ try {
168044
+ this.policy.free();
168045
+ }
168046
+ catch { }
168047
+ }
168048
+ }
168049
+ this.policy = null;
168050
+ }
168051
+ }
168052
+ exports.OpaWasmEvaluator = OpaWasmEvaluator;
168053
+
168054
+
168055
+ /***/ }),
168056
+
168057
+ /***/ 17117:
168058
+ /***/ ((__unused_webpack_module, exports) => {
168059
+
168060
+ "use strict";
168061
+
168062
+ /**
168063
+ * Copyright (c) ProbeLabs. All rights reserved.
168064
+ * Licensed under the Elastic License 2.0; you may not use this file except
168065
+ * in compliance with the Elastic License 2.0.
168066
+ */
168067
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168068
+ exports.PolicyInputBuilder = void 0;
168069
+ /**
168070
+ * Builds OPA-compatible input documents from engine context.
168071
+ *
168072
+ * Resolves actor roles from the `policy.roles` config section by matching
168073
+ * the actor's authorAssociation and login against role definitions.
168074
+ */
168075
+ class PolicyInputBuilder {
168076
+ roles;
168077
+ actor;
168078
+ repository;
168079
+ pullRequest;
168080
+ constructor(policyConfig, actor, repository, pullRequest) {
168081
+ this.roles = policyConfig.roles || {};
168082
+ this.actor = actor;
168083
+ this.repository = repository;
168084
+ this.pullRequest = pullRequest;
168085
+ }
168086
+ /** Resolve which roles apply to the current actor. */
168087
+ resolveRoles() {
168088
+ const matched = [];
168089
+ for (const [roleName, roleConfig] of Object.entries(this.roles)) {
168090
+ let identityMatch = false;
168091
+ if (roleConfig.author_association &&
168092
+ this.actor.authorAssociation &&
168093
+ roleConfig.author_association.includes(this.actor.authorAssociation)) {
168094
+ identityMatch = true;
168095
+ }
168096
+ if (!identityMatch &&
168097
+ roleConfig.users &&
168098
+ this.actor.login &&
168099
+ roleConfig.users.includes(this.actor.login)) {
168100
+ identityMatch = true;
168101
+ }
168102
+ // Slack user ID match
168103
+ if (!identityMatch &&
168104
+ roleConfig.slack_users &&
168105
+ this.actor.slack?.userId &&
168106
+ roleConfig.slack_users.includes(this.actor.slack.userId)) {
168107
+ identityMatch = true;
168108
+ }
168109
+ // Email match (case-insensitive)
168110
+ if (!identityMatch && roleConfig.emails && this.actor.slack?.email) {
168111
+ const actorEmail = this.actor.slack.email.toLowerCase();
168112
+ if (roleConfig.emails.some(e => e.toLowerCase() === actorEmail)) {
168113
+ identityMatch = true;
168114
+ }
168115
+ }
168116
+ // Note: teams-based role resolution requires GitHub API access (read:org scope)
168117
+ // and is not yet implemented. If configured, the role will not match via teams.
168118
+ if (!identityMatch)
168119
+ continue;
168120
+ // slack_channels gate: if set, the role only applies when triggered from one of these channels
168121
+ if (roleConfig.slack_channels && roleConfig.slack_channels.length > 0) {
168122
+ if (!this.actor.slack?.channelId ||
168123
+ !roleConfig.slack_channels.includes(this.actor.slack.channelId)) {
168124
+ continue;
168125
+ }
168126
+ }
168127
+ matched.push(roleName);
168128
+ }
168129
+ return matched;
168130
+ }
168131
+ buildActor() {
168132
+ return {
168133
+ authorAssociation: this.actor.authorAssociation,
168134
+ login: this.actor.login,
168135
+ roles: this.resolveRoles(),
168136
+ isLocalMode: this.actor.isLocalMode,
168137
+ ...(this.actor.slack && { slack: this.actor.slack }),
168138
+ };
168139
+ }
168140
+ forCheckExecution(check) {
168141
+ return {
168142
+ scope: 'check.execute',
168143
+ check: {
168144
+ id: check.id,
168145
+ type: check.type,
168146
+ group: check.group,
168147
+ tags: check.tags,
168148
+ criticality: check.criticality,
168149
+ sandbox: check.sandbox,
168150
+ policy: check.policy,
168151
+ },
168152
+ actor: this.buildActor(),
168153
+ repository: this.repository,
168154
+ pullRequest: this.pullRequest,
168155
+ };
168156
+ }
168157
+ forToolInvocation(serverName, methodName, transport) {
168158
+ return {
168159
+ scope: 'tool.invoke',
168160
+ tool: { serverName, methodName, transport },
168161
+ actor: this.buildActor(),
168162
+ repository: this.repository,
168163
+ pullRequest: this.pullRequest,
168164
+ };
168165
+ }
168166
+ forCapabilityResolve(checkId, capabilities) {
168167
+ return {
168168
+ scope: 'capability.resolve',
168169
+ check: { id: checkId, type: 'ai' },
168170
+ capability: capabilities,
168171
+ actor: this.buildActor(),
168172
+ repository: this.repository,
168173
+ pullRequest: this.pullRequest,
168174
+ };
168175
+ }
168176
+ }
168177
+ exports.PolicyInputBuilder = PolicyInputBuilder;
168178
+
168179
+
168180
+ /***/ }),
168181
+
168182
+ /***/ 63737:
168183
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
168184
+
168185
+ "use strict";
168186
+
168187
+ /**
168188
+ * Copyright (c) ProbeLabs. All rights reserved.
168189
+ * Licensed under the Elastic License 2.0; you may not use this file except
168190
+ * in compliance with the Elastic License 2.0.
168191
+ */
168192
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
168193
+ if (k2 === undefined) k2 = k;
168194
+ var desc = Object.getOwnPropertyDescriptor(m, k);
168195
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
168196
+ desc = { enumerable: true, get: function() { return m[k]; } };
168197
+ }
168198
+ Object.defineProperty(o, k2, desc);
168199
+ }) : (function(o, m, k, k2) {
168200
+ if (k2 === undefined) k2 = k;
168201
+ o[k2] = m[k];
168202
+ }));
168203
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
168204
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
168205
+ }) : function(o, v) {
168206
+ o["default"] = v;
168207
+ });
168208
+ var __importStar = (this && this.__importStar) || (function () {
168209
+ var ownKeys = function(o) {
168210
+ ownKeys = Object.getOwnPropertyNames || function (o) {
168211
+ var ar = [];
168212
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
168213
+ return ar;
168214
+ };
168215
+ return ownKeys(o);
168216
+ };
168217
+ return function (mod) {
168218
+ if (mod && mod.__esModule) return mod;
168219
+ var result = {};
168220
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
168221
+ __setModuleDefault(result, mod);
168222
+ return result;
168223
+ };
168224
+ })();
168225
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168226
+ exports.KnexStoreBackend = void 0;
168227
+ /**
168228
+ * Knex-backed schedule store for PostgreSQL, MySQL, and MSSQL (Enterprise)
168229
+ *
168230
+ * Uses Knex query builder for database-agnostic SQL. Same schema as SQLite backend
168231
+ * but with real distributed locking via row-level claims (claimed_by/claimed_at/lock_token).
168232
+ */
168233
+ const fs = __importStar(__nccwpck_require__(79896));
168234
+ const path = __importStar(__nccwpck_require__(16928));
168235
+ const uuid_1 = __nccwpck_require__(31914);
168236
+ const logger_1 = __nccwpck_require__(86999);
168237
+ function toNum(val) {
168238
+ if (val === null || val === undefined)
168239
+ return undefined;
168240
+ return typeof val === 'string' ? parseInt(val, 10) : val;
168241
+ }
168242
+ function safeJsonParse(value) {
168243
+ if (!value)
168244
+ return undefined;
168245
+ try {
168246
+ return JSON.parse(value);
168247
+ }
168248
+ catch {
168249
+ return undefined;
168250
+ }
168251
+ }
168252
+ function fromDbRow(row) {
168253
+ return {
168254
+ id: row.id,
168255
+ creatorId: row.creator_id,
168256
+ creatorContext: row.creator_context ?? undefined,
168257
+ creatorName: row.creator_name ?? undefined,
168258
+ timezone: row.timezone,
168259
+ schedule: row.schedule_expr,
168260
+ runAt: toNum(row.run_at),
168261
+ isRecurring: row.is_recurring === true || row.is_recurring === 1,
168262
+ originalExpression: row.original_expression,
168263
+ workflow: row.workflow ?? undefined,
168264
+ workflowInputs: safeJsonParse(row.workflow_inputs),
168265
+ outputContext: safeJsonParse(row.output_context),
168266
+ status: row.status,
168267
+ createdAt: toNum(row.created_at),
168268
+ lastRunAt: toNum(row.last_run_at),
168269
+ nextRunAt: toNum(row.next_run_at),
168270
+ runCount: row.run_count,
168271
+ failureCount: row.failure_count,
168272
+ lastError: row.last_error ?? undefined,
168273
+ previousResponse: row.previous_response ?? undefined,
168274
+ };
168275
+ }
168276
+ function toInsertRow(schedule) {
168277
+ return {
168278
+ id: schedule.id,
168279
+ creator_id: schedule.creatorId,
168280
+ creator_context: schedule.creatorContext ?? null,
168281
+ creator_name: schedule.creatorName ?? null,
168282
+ timezone: schedule.timezone,
168283
+ schedule_expr: schedule.schedule,
168284
+ run_at: schedule.runAt ?? null,
168285
+ is_recurring: schedule.isRecurring,
168286
+ original_expression: schedule.originalExpression,
168287
+ workflow: schedule.workflow ?? null,
168288
+ workflow_inputs: schedule.workflowInputs ? JSON.stringify(schedule.workflowInputs) : null,
168289
+ output_context: schedule.outputContext ? JSON.stringify(schedule.outputContext) : null,
168290
+ status: schedule.status,
168291
+ created_at: schedule.createdAt,
168292
+ last_run_at: schedule.lastRunAt ?? null,
168293
+ next_run_at: schedule.nextRunAt ?? null,
168294
+ run_count: schedule.runCount,
168295
+ failure_count: schedule.failureCount,
168296
+ last_error: schedule.lastError ?? null,
168297
+ previous_response: schedule.previousResponse ?? null,
168298
+ };
168299
+ }
168300
+ /**
168301
+ * Enterprise Knex-backed store for PostgreSQL, MySQL, and MSSQL
168302
+ */
168303
+ class KnexStoreBackend {
168304
+ knex = null;
168305
+ driver;
168306
+ connection;
168307
+ constructor(driver, storageConfig, _haConfig) {
168308
+ this.driver = driver;
168309
+ this.connection = (storageConfig.connection || {});
168310
+ }
168311
+ async initialize() {
168312
+ // Load knex dynamically
168313
+ const { createRequire } = __nccwpck_require__(73339);
168314
+ const runtimeRequire = createRequire(__filename);
168315
+ let knexFactory;
168316
+ try {
168317
+ knexFactory = runtimeRequire('knex');
168318
+ }
168319
+ catch (err) {
168320
+ const code = err?.code;
168321
+ if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
168322
+ throw new Error('knex is required for PostgreSQL/MySQL/MSSQL schedule storage. ' +
168323
+ 'Install it with: npm install knex');
168324
+ }
168325
+ throw err;
168326
+ }
168327
+ const clientMap = {
168328
+ postgresql: 'pg',
168329
+ mysql: 'mysql2',
168330
+ mssql: 'tedious',
168331
+ };
168332
+ const client = clientMap[this.driver];
168333
+ // Build connection config
168334
+ let connection;
168335
+ if (this.connection.connection_string) {
168336
+ connection = this.connection.connection_string;
168337
+ }
168338
+ else if (this.driver === 'mssql') {
168339
+ connection = this.buildMssqlConnection();
168340
+ }
168341
+ else {
168342
+ connection = this.buildStandardConnection();
168343
+ }
168344
+ this.knex = knexFactory({
168345
+ client,
168346
+ connection,
168347
+ pool: {
168348
+ min: this.connection.pool?.min ?? 0,
168349
+ max: this.connection.pool?.max ?? 10,
168350
+ },
168351
+ });
168352
+ // Run schema migration
168353
+ await this.migrateSchema();
168354
+ logger_1.logger.info(`[KnexStore] Initialized (${this.driver})`);
168355
+ }
168356
+ buildStandardConnection() {
168357
+ return {
168358
+ host: this.connection.host || 'localhost',
168359
+ port: this.connection.port,
168360
+ database: this.connection.database || 'visor',
168361
+ user: this.connection.user,
168362
+ password: this.connection.password,
168363
+ ssl: this.resolveSslConfig(),
168364
+ };
168365
+ }
168366
+ buildMssqlConnection() {
168367
+ const ssl = this.connection.ssl;
168368
+ const sslEnabled = ssl === true || (typeof ssl === 'object' && ssl.enabled !== false);
168369
+ return {
168370
+ server: this.connection.host || 'localhost',
168371
+ port: this.connection.port,
168372
+ database: this.connection.database || 'visor',
168373
+ user: this.connection.user,
168374
+ password: this.connection.password,
168375
+ options: {
168376
+ encrypt: sslEnabled,
168377
+ trustServerCertificate: typeof ssl === 'object' ? ssl.reject_unauthorized === false : !sslEnabled,
168378
+ },
168379
+ };
168380
+ }
168381
+ resolveSslConfig() {
168382
+ const ssl = this.connection.ssl;
168383
+ if (ssl === false || ssl === undefined)
168384
+ return false;
168385
+ if (ssl === true)
168386
+ return { rejectUnauthorized: true };
168387
+ // Object config
168388
+ if (ssl.enabled === false)
168389
+ return false;
168390
+ const result = {
168391
+ rejectUnauthorized: ssl.reject_unauthorized !== false,
168392
+ };
168393
+ if (ssl.ca) {
168394
+ const caPath = this.validateSslPath(ssl.ca, 'CA certificate');
168395
+ result.ca = fs.readFileSync(caPath, 'utf8');
168396
+ }
168397
+ if (ssl.cert) {
168398
+ const certPath = this.validateSslPath(ssl.cert, 'client certificate');
168399
+ result.cert = fs.readFileSync(certPath, 'utf8');
168400
+ }
168401
+ if (ssl.key) {
168402
+ const keyPath = this.validateSslPath(ssl.key, 'client key');
168403
+ result.key = fs.readFileSync(keyPath, 'utf8');
168404
+ }
168405
+ return result;
168406
+ }
168407
+ validateSslPath(filePath, label) {
168408
+ const resolved = path.resolve(filePath);
168409
+ if (resolved !== path.normalize(resolved)) {
168410
+ throw new Error(`SSL ${label} path contains invalid sequences: ${filePath}`);
168411
+ }
168412
+ if (!fs.existsSync(resolved)) {
168413
+ throw new Error(`SSL ${label} not found: ${filePath}`);
168414
+ }
168415
+ return resolved;
168416
+ }
168417
+ async shutdown() {
168418
+ if (this.knex) {
168419
+ await this.knex.destroy();
168420
+ this.knex = null;
168421
+ }
168422
+ }
168423
+ async migrateSchema() {
168424
+ const knex = this.getKnex();
168425
+ const exists = await knex.schema.hasTable('schedules');
168426
+ if (!exists) {
168427
+ await knex.schema.createTable('schedules', table => {
168428
+ table.string('id', 36).primary();
168429
+ table.string('creator_id', 255).notNullable().index();
168430
+ table.string('creator_context', 255);
168431
+ table.string('creator_name', 255);
168432
+ table.string('timezone', 64).notNullable().defaultTo('UTC');
168433
+ table.string('schedule_expr', 255);
168434
+ table.bigInteger('run_at');
168435
+ table.boolean('is_recurring').notNullable();
168436
+ table.text('original_expression');
168437
+ table.string('workflow', 255);
168438
+ table.text('workflow_inputs');
168439
+ table.text('output_context');
168440
+ table.string('status', 20).notNullable().index();
168441
+ table.bigInteger('created_at').notNullable();
168442
+ table.bigInteger('last_run_at');
168443
+ table.bigInteger('next_run_at');
168444
+ table.integer('run_count').notNullable().defaultTo(0);
168445
+ table.integer('failure_count').notNullable().defaultTo(0);
168446
+ table.text('last_error');
168447
+ table.text('previous_response');
168448
+ table.index(['status', 'next_run_at']);
168449
+ });
168450
+ }
168451
+ // Create scheduler_locks table for distributed locking
168452
+ const locksExist = await knex.schema.hasTable('scheduler_locks');
168453
+ if (!locksExist) {
168454
+ await knex.schema.createTable('scheduler_locks', table => {
168455
+ table.string('lock_id', 255).primary();
168456
+ table.string('node_id', 255).notNullable();
168457
+ table.string('lock_token', 36).notNullable();
168458
+ table.bigInteger('acquired_at').notNullable();
168459
+ table.bigInteger('expires_at').notNullable();
168460
+ });
168461
+ }
168462
+ }
168463
+ getKnex() {
168464
+ if (!this.knex) {
168465
+ throw new Error('[KnexStore] Not initialized. Call initialize() first.');
168466
+ }
168467
+ return this.knex;
168468
+ }
168469
+ // --- CRUD ---
168470
+ async create(schedule) {
168471
+ const knex = this.getKnex();
168472
+ const newSchedule = {
168473
+ ...schedule,
168474
+ id: (0, uuid_1.v4)(),
168475
+ createdAt: Date.now(),
168476
+ runCount: 0,
168477
+ failureCount: 0,
168478
+ status: 'active',
168479
+ };
168480
+ await knex('schedules').insert(toInsertRow(newSchedule));
168481
+ logger_1.logger.info(`[KnexStore] Created schedule ${newSchedule.id} for user ${newSchedule.creatorId}`);
168482
+ return newSchedule;
168483
+ }
168484
+ async importSchedule(schedule) {
168485
+ const knex = this.getKnex();
168486
+ const existing = await knex('schedules').where('id', schedule.id).first();
168487
+ if (existing)
168488
+ return; // Already imported (idempotent)
168489
+ await knex('schedules').insert(toInsertRow(schedule));
168490
+ }
168491
+ async get(id) {
168492
+ const knex = this.getKnex();
168493
+ const row = await knex('schedules').where('id', id).first();
168494
+ return row ? fromDbRow(row) : undefined;
168495
+ }
168496
+ async update(id, patch) {
168497
+ const knex = this.getKnex();
168498
+ const existing = await knex('schedules').where('id', id).first();
168499
+ if (!existing)
168500
+ return undefined;
168501
+ const current = fromDbRow(existing);
168502
+ const updated = { ...current, ...patch, id: current.id };
168503
+ const row = toInsertRow(updated);
168504
+ // Remove id from update (PK cannot change)
168505
+ delete row.id;
168506
+ await knex('schedules').where('id', id).update(row);
168507
+ return updated;
168508
+ }
168509
+ async delete(id) {
168510
+ const knex = this.getKnex();
168511
+ const deleted = await knex('schedules').where('id', id).del();
168512
+ if (deleted > 0) {
168513
+ logger_1.logger.info(`[KnexStore] Deleted schedule ${id}`);
168514
+ return true;
168515
+ }
168516
+ return false;
168517
+ }
168518
+ // --- Queries ---
168519
+ async getByCreator(creatorId) {
168520
+ const knex = this.getKnex();
168521
+ const rows = await knex('schedules').where('creator_id', creatorId);
168522
+ return rows.map((r) => fromDbRow(r));
168523
+ }
168524
+ async getActiveSchedules() {
168525
+ const knex = this.getKnex();
168526
+ const rows = await knex('schedules').where('status', 'active');
168527
+ return rows.map((r) => fromDbRow(r));
168528
+ }
168529
+ async getDueSchedules(now) {
168530
+ const ts = now ?? Date.now();
168531
+ const knex = this.getKnex();
168532
+ // MSSQL uses 1/0 for booleans
168533
+ const bFalse = this.driver === 'mssql' ? 0 : false;
168534
+ const bTrue = this.driver === 'mssql' ? 1 : true;
168535
+ const rows = await knex('schedules')
168536
+ .where('status', 'active')
168537
+ .andWhere(function () {
168538
+ this.where(function () {
168539
+ this.where('is_recurring', bFalse)
168540
+ .whereNotNull('run_at')
168541
+ .where('run_at', '<=', ts);
168542
+ }).orWhere(function () {
168543
+ this.where('is_recurring', bTrue)
168544
+ .whereNotNull('next_run_at')
168545
+ .where('next_run_at', '<=', ts);
168546
+ });
168547
+ });
168548
+ return rows.map((r) => fromDbRow(r));
168549
+ }
168550
+ async findByWorkflow(creatorId, workflowName) {
168551
+ const knex = this.getKnex();
168552
+ const escaped = workflowName.toLowerCase().replace(/[%_\\]/g, '\\$&');
168553
+ const pattern = `%${escaped}%`;
168554
+ const rows = await knex('schedules')
168555
+ .where('creator_id', creatorId)
168556
+ .where('status', 'active')
168557
+ .whereRaw("LOWER(workflow) LIKE ? ESCAPE '\\'", [pattern]);
168558
+ return rows.map((r) => fromDbRow(r));
168559
+ }
168560
+ async getAll() {
168561
+ const knex = this.getKnex();
168562
+ const rows = await knex('schedules');
168563
+ return rows.map((r) => fromDbRow(r));
168564
+ }
168565
+ async getStats() {
168566
+ const knex = this.getKnex();
168567
+ // MSSQL uses 1/0 for booleans; PostgreSQL/MySQL accept both true/1
168568
+ const boolTrue = this.driver === 'mssql' ? '1' : 'true';
168569
+ const boolFalse = this.driver === 'mssql' ? '0' : 'false';
168570
+ const result = await knex('schedules')
168571
+ .select(knex.raw('COUNT(*) as total'), knex.raw("SUM(CASE WHEN status = 'active' THEN 1 ELSE 0 END) as active"), knex.raw("SUM(CASE WHEN status = 'paused' THEN 1 ELSE 0 END) as paused"), knex.raw("SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed"), knex.raw("SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) as failed"), knex.raw(`SUM(CASE WHEN is_recurring = ${boolTrue} THEN 1 ELSE 0 END) as recurring`), knex.raw(`SUM(CASE WHEN is_recurring = ${boolFalse} THEN 1 ELSE 0 END) as one_time`))
168572
+ .first();
168573
+ return {
168574
+ total: Number(result.total) || 0,
168575
+ active: Number(result.active) || 0,
168576
+ paused: Number(result.paused) || 0,
168577
+ completed: Number(result.completed) || 0,
168578
+ failed: Number(result.failed) || 0,
168579
+ recurring: Number(result.recurring) || 0,
168580
+ oneTime: Number(result.one_time) || 0,
168581
+ };
168582
+ }
168583
+ async validateLimits(creatorId, isRecurring, limits) {
168584
+ const knex = this.getKnex();
168585
+ if (limits.maxGlobal) {
168586
+ const result = await knex('schedules').count('* as cnt').first();
168587
+ if (Number(result?.cnt) >= limits.maxGlobal) {
168588
+ throw new Error(`Global schedule limit reached (${limits.maxGlobal})`);
168589
+ }
168590
+ }
168591
+ if (limits.maxPerUser) {
168592
+ const result = await knex('schedules')
168593
+ .where('creator_id', creatorId)
168594
+ .count('* as cnt')
168595
+ .first();
168596
+ if (Number(result?.cnt) >= limits.maxPerUser) {
168597
+ throw new Error(`You have reached the maximum number of schedules (${limits.maxPerUser})`);
168598
+ }
168599
+ }
168600
+ if (isRecurring && limits.maxRecurringPerUser) {
168601
+ const bTrue = this.driver === 'mssql' ? 1 : true;
168602
+ const result = await knex('schedules')
168603
+ .where('creator_id', creatorId)
168604
+ .where('is_recurring', bTrue)
168605
+ .count('* as cnt')
168606
+ .first();
168607
+ if (Number(result?.cnt) >= limits.maxRecurringPerUser) {
168608
+ throw new Error(`You have reached the maximum number of recurring schedules (${limits.maxRecurringPerUser})`);
168609
+ }
168610
+ }
168611
+ }
168612
+ // --- HA Distributed Locking (via scheduler_locks table) ---
168613
+ async tryAcquireLock(lockId, nodeId, ttlSeconds) {
168614
+ const knex = this.getKnex();
168615
+ const now = Date.now();
168616
+ const expiresAt = now + ttlSeconds * 1000;
168617
+ const token = (0, uuid_1.v4)();
168618
+ // Step 1: Try to claim an existing expired lock
168619
+ const updated = await knex('scheduler_locks')
168620
+ .where('lock_id', lockId)
168621
+ .where('expires_at', '<', now)
168622
+ .update({
168623
+ node_id: nodeId,
168624
+ lock_token: token,
168625
+ acquired_at: now,
168626
+ expires_at: expiresAt,
168627
+ });
168628
+ if (updated > 0)
168629
+ return token;
168630
+ // Step 2: Try to INSERT a new lock row
168631
+ try {
168632
+ await knex('scheduler_locks').insert({
168633
+ lock_id: lockId,
168634
+ node_id: nodeId,
168635
+ lock_token: token,
168636
+ acquired_at: now,
168637
+ expires_at: expiresAt,
168638
+ });
168639
+ return token;
168640
+ }
168641
+ catch {
168642
+ // Unique constraint violation — another node holds the lock
168643
+ return null;
168644
+ }
168645
+ }
168646
+ async releaseLock(lockId, lockToken) {
168647
+ const knex = this.getKnex();
168648
+ await knex('scheduler_locks').where('lock_id', lockId).where('lock_token', lockToken).del();
168649
+ }
168650
+ async renewLock(lockId, lockToken, ttlSeconds) {
168651
+ const knex = this.getKnex();
168652
+ const now = Date.now();
168653
+ const expiresAt = now + ttlSeconds * 1000;
168654
+ const updated = await knex('scheduler_locks')
168655
+ .where('lock_id', lockId)
168656
+ .where('lock_token', lockToken)
168657
+ .update({ acquired_at: now, expires_at: expiresAt });
168658
+ return updated > 0;
168659
+ }
168660
+ async flush() {
168661
+ // No-op for server-based backends
168662
+ }
168663
+ }
168664
+ exports.KnexStoreBackend = KnexStoreBackend;
168665
+
168666
+
166983
168667
  /***/ }),
166984
168668
 
166985
168669
  /***/ 83864:
@@ -177656,6 +179340,35 @@ class OutputFormatters {
177656
179340
  exports.OutputFormatters = OutputFormatters;
177657
179341
 
177658
179342
 
179343
+ /***/ }),
179344
+
179345
+ /***/ 93866:
179346
+ /***/ ((__unused_webpack_module, exports) => {
179347
+
179348
+ "use strict";
179349
+
179350
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
179351
+ exports.DefaultPolicyEngine = void 0;
179352
+ /**
179353
+ * Default (no-op) policy engine — always allows everything.
179354
+ * Used when no enterprise license is present or policy is disabled.
179355
+ */
179356
+ class DefaultPolicyEngine {
179357
+ async initialize(_config) { }
179358
+ async evaluateCheckExecution(_checkId, _checkConfig) {
179359
+ return { allowed: true };
179360
+ }
179361
+ async evaluateToolInvocation(_serverName, _methodName, _transport) {
179362
+ return { allowed: true };
179363
+ }
179364
+ async evaluateCapabilities(_checkId, _capabilities) {
179365
+ return { allowed: true };
179366
+ }
179367
+ async shutdown() { }
179368
+ }
179369
+ exports.DefaultPolicyEngine = DefaultPolicyEngine;
179370
+
179371
+
177659
179372
  /***/ }),
177660
179373
 
177661
179374
  /***/ 96611:
@@ -197910,7 +199623,7 @@ class StateMachineExecutionEngine {
197910
199623
  try {
197911
199624
  logger_1.logger.debug(`[PolicyEngine] Loading enterprise policy engine (engine=${configWithTagFilter.policy.engine})`);
197912
199625
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
197913
- const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(7065)));
199626
+ const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(87068)));
197914
199627
  context.policyEngine = await loadEnterprisePolicyEngine(configWithTagFilter.policy);
197915
199628
  logger_1.logger.debug(`[PolicyEngine] Initialized: ${context.policyEngine?.constructor?.name || 'unknown'}`);
197916
199629
  }
@@ -208174,7 +209887,7 @@ async function initTelemetry(opts = {}) {
208174
209887
  const path = __nccwpck_require__(16928);
208175
209888
  const outDir = opts.file?.dir ||
208176
209889
  process.env.VISOR_TRACE_DIR ||
208177
- __nccwpck_require__.ab + "traces";
209890
+ path.join(process.cwd(), 'output', 'traces');
208178
209891
  fs.mkdirSync(outDir, { recursive: true });
208179
209892
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
208180
209893
  process.env.VISOR_FALLBACK_TRACE_FILE = path.join(outDir, `run-${ts}.ndjson`);
@@ -208379,7 +210092,7 @@ async function shutdownTelemetry() {
208379
210092
  if (process.env.VISOR_TRACE_REPORT === 'true') {
208380
210093
  const fs = __nccwpck_require__(79896);
208381
210094
  const path = __nccwpck_require__(16928);
208382
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
210095
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
208383
210096
  if (!fs.existsSync(outDir))
208384
210097
  fs.mkdirSync(outDir, { recursive: true });
208385
210098
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
@@ -208878,7 +210591,7 @@ function __getOrCreateNdjsonPath() {
208878
210591
  fs.mkdirSync(dir, { recursive: true });
208879
210592
  return __ndjsonPath;
208880
210593
  }
208881
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
210594
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
208882
210595
  if (!fs.existsSync(outDir))
208883
210596
  fs.mkdirSync(outDir, { recursive: true });
208884
210597
  if (!__ndjsonPath) {
@@ -222205,22 +223918,6 @@ class WorkflowRegistry {
222205
223918
  exports.WorkflowRegistry = WorkflowRegistry;
222206
223919
 
222207
223920
 
222208
- /***/ }),
222209
-
222210
- /***/ 7065:
222211
- /***/ ((module) => {
222212
-
222213
- module.exports = eval("require")("./enterprise/loader");
222214
-
222215
-
222216
- /***/ }),
222217
-
222218
- /***/ 71370:
222219
- /***/ ((module) => {
222220
-
222221
- module.exports = eval("require")("./enterprise/policy/policy-input-builder");
222222
-
222223
-
222224
223921
  /***/ }),
222225
223922
 
222226
223923
  /***/ 18327:
@@ -280396,7 +282093,7 @@ async function handleLineEdit({ resolvedPath: resolvedPath2, file_path, start_li
280396
282093
  return buildLineEditResponse(file_path, startLine, endLine, newLines.length, fileLines, startLine - 1, action, modifications);
280397
282094
  }
280398
282095
  }
280399
- var import_ai, import_fs4, import_path5, import_fs5, editTool, createTool, editSchema, createSchema, editDescription, createDescription, editToolDefinition, createToolDefinition;
282096
+ var import_ai, import_fs4, import_path5, import_fs5, editTool, createTool, multiEditTool, editSchema, createSchema, multiEditSchema, editDescription, createDescription, multiEditDescription, editToolDefinition, createToolDefinition, multiEditToolDefinition;
280400
282097
  var init_edit = __esm({
280401
282098
  "src/tools/edit.js"() {
280402
282099
  "use strict";
@@ -280470,7 +282167,7 @@ Parameters:
280470
282167
  },
280471
282168
  required: ["file_path", "new_string"]
280472
282169
  },
280473
- execute: async ({ file_path, old_string, new_string, replace_all = false, symbol: symbol15, position, start_line, end_line }) => {
282170
+ execute: async ({ file_path, old_string, new_string, replace_all = false, symbol: symbol15, position, start_line, end_line, workingDirectory }) => {
280474
282171
  try {
280475
282172
  if (!file_path || typeof file_path !== "string" || file_path.trim() === "") {
280476
282173
  return `Error editing file: Invalid file_path - must be a non-empty string. Provide an absolute path or a path relative to the working directory (e.g. "src/main.js").`;
@@ -280478,7 +282175,8 @@ Parameters:
280478
282175
  if (new_string === void 0 || new_string === null || typeof new_string !== "string") {
280479
282176
  return `Error editing file: Invalid new_string - must be a string. Provide the replacement content as a string value (empty string "" is valid for deletions).`;
280480
282177
  }
280481
- const resolvedPath2 = (0, import_path5.isAbsolute)(file_path) ? file_path : (0, import_path5.resolve)(cwd || process.cwd(), file_path);
282178
+ const effectiveCwd = workingDirectory || cwd || process.cwd();
282179
+ const resolvedPath2 = (0, import_path5.isAbsolute)(file_path) ? file_path : (0, import_path5.resolve)(effectiveCwd, file_path);
280482
282180
  if (debug) {
280483
282181
  console.error(`[Edit] Attempting to edit file: ${resolvedPath2}`);
280484
282182
  }
@@ -280585,7 +282283,7 @@ Important:
280585
282283
  },
280586
282284
  required: ["file_path", "content"]
280587
282285
  },
280588
- execute: async ({ file_path, content, overwrite = false }) => {
282286
+ execute: async ({ file_path, content, overwrite = false, workingDirectory }) => {
280589
282287
  try {
280590
282288
  if (!file_path || typeof file_path !== "string" || file_path.trim() === "") {
280591
282289
  return `Error creating file: Invalid file_path - must be a non-empty string. Provide an absolute path or a path relative to the working directory (e.g. "src/newFile.js").`;
@@ -280593,7 +282291,8 @@ Important:
280593
282291
  if (content === void 0 || content === null || typeof content !== "string") {
280594
282292
  return `Error creating file: Invalid content - must be a string. Provide the file content as a string value (empty string "" is valid for an empty file).`;
280595
282293
  }
280596
- const resolvedPath2 = (0, import_path5.isAbsolute)(file_path) ? file_path : (0, import_path5.resolve)(cwd || process.cwd(), file_path);
282294
+ const effectiveCwd = workingDirectory || cwd || process.cwd();
282295
+ const resolvedPath2 = (0, import_path5.isAbsolute)(file_path) ? file_path : (0, import_path5.resolve)(effectiveCwd, file_path);
280597
282296
  if (debug) {
280598
282297
  console.error(`[Create] Attempting to create file: ${resolvedPath2}`);
280599
282298
  }
@@ -280622,6 +282321,70 @@ Important:
280622
282321
  }
280623
282322
  });
280624
282323
  };
282324
+ multiEditTool = (options = {}) => {
282325
+ const editInstance = editTool(options);
282326
+ return (0, import_ai.tool)({
282327
+ name: "multi_edit",
282328
+ description: "Apply multiple file edits in a single tool call. Accepts a JSON array of edit operations.",
282329
+ inputSchema: {
282330
+ type: "object",
282331
+ properties: {
282332
+ edits: {
282333
+ type: "string",
282334
+ description: "JSON array of edit operations. Each object supports: file_path, old_string, new_string, replace_all, symbol, position, start_line, end_line."
282335
+ }
282336
+ },
282337
+ required: ["edits"]
282338
+ },
282339
+ execute: async ({ edits: rawEdits }) => {
282340
+ let edits;
282341
+ if (typeof rawEdits === "string") {
282342
+ try {
282343
+ edits = JSON.parse(rawEdits);
282344
+ } catch (e5) {
282345
+ return `Error: Invalid JSON in edits parameter - ${e5.message}. Provide a raw JSON array between <edits> tags.`;
282346
+ }
282347
+ } else if (Array.isArray(rawEdits)) {
282348
+ edits = rawEdits;
282349
+ } else {
282350
+ return "Error: edits must be a JSON array of edit operations.";
282351
+ }
282352
+ if (!Array.isArray(edits) || edits.length === 0) {
282353
+ return "Error: edits must be a non-empty JSON array.";
282354
+ }
282355
+ if (edits.length > 50) {
282356
+ return `Error: Too many edits (${edits.length}). Maximum 50 per batch.`;
282357
+ }
282358
+ const results = [];
282359
+ let successCount = 0;
282360
+ let failCount = 0;
282361
+ for (let i5 = 0; i5 < edits.length; i5++) {
282362
+ const editOp = edits[i5];
282363
+ if (!editOp || typeof editOp !== "object" || Array.isArray(editOp)) {
282364
+ results.push(`[${i5 + 1}] FAIL: Invalid edit operation - must be an object`);
282365
+ failCount++;
282366
+ continue;
282367
+ }
282368
+ try {
282369
+ const result = await editInstance.execute(editOp);
282370
+ const isError = typeof result === "string" && result.startsWith("Error");
282371
+ if (isError) {
282372
+ results.push(`[${i5 + 1}] FAIL: ${result}`);
282373
+ failCount++;
282374
+ } else {
282375
+ results.push(`[${i5 + 1}] OK: ${result}`);
282376
+ successCount++;
282377
+ }
282378
+ } catch (error2) {
282379
+ results.push(`[${i5 + 1}] FAIL: ${error2.message}`);
282380
+ failCount++;
282381
+ }
282382
+ }
282383
+ const summary = `Multi-edit: ${successCount}/${edits.length} succeeded` + (failCount > 0 ? `, ${failCount} failed` : "");
282384
+ return summary + "\n\n" + results.join("\n");
282385
+ }
282386
+ });
282387
+ };
280625
282388
  editSchema = {
280626
282389
  type: "object",
280627
282390
  properties: {
@@ -280679,8 +282442,19 @@ Important:
280679
282442
  },
280680
282443
  required: ["file_path", "content"]
280681
282444
  };
282445
+ multiEditSchema = {
282446
+ type: "object",
282447
+ properties: {
282448
+ edits: {
282449
+ type: "string",
282450
+ description: "JSON array of edit operations"
282451
+ }
282452
+ },
282453
+ required: ["edits"]
282454
+ };
280682
282455
  editDescription = "Edit files using text replacement, AST-aware symbol operations, or line-targeted editing. Supports fuzzy matching for text edits and optional hash-based integrity verification for line edits.";
280683
282456
  createDescription = "Create new files with specified content. Will create parent directories if needed.";
282457
+ multiEditDescription = "Apply multiple file edits in a single tool call. Accepts a JSON array of edit operations, each supporting the same modes as the edit tool.";
280684
282458
  editToolDefinition = `
280685
282459
  ## edit
280686
282460
  Description: ${editDescription}
@@ -280836,6 +282610,44 @@ Examples:
280836
282610
  This is a new project.</content>
280837
282611
  <overwrite>true</overwrite>
280838
282612
  </create>`;
282613
+ multiEditToolDefinition = `
282614
+ ## multi_edit
282615
+ Description: ${multiEditDescription}
282616
+
282617
+ Apply multiple edits in one call. Each operation in the array uses the same parameters as the edit tool:
282618
+ - file_path, old_string, new_string (text mode)
282619
+ - file_path, symbol, new_string (symbol replace)
282620
+ - file_path, symbol, new_string, position (symbol insert)
282621
+ - file_path, start_line, new_string (line-targeted)
282622
+
282623
+ Edits are applied sequentially. Failures do not stop remaining edits. Maximum 50 edits per call.
282624
+
282625
+ Parameters:
282626
+ - edits: (required) JSON array of edit objects. Place raw JSON between tags.
282627
+
282628
+ When to use multi_edit vs edit:
282629
+ - Use edit for a single change to one file
282630
+ - Use multi_edit when making 2+ related changes across files (e.g., rename a function and update all call sites)
282631
+ - Use multi_edit for coordinated multi-file refactoring where order matters
282632
+
282633
+ Examples:
282634
+
282635
+ Multiple text replacements across files:
282636
+ <multi_edit>
282637
+ <edits>[
282638
+ {"file_path": "src/main.js", "old_string": "return false;", "new_string": "return true;"},
282639
+ {"file_path": "src/config.js", "old_string": "debug: false", "new_string": "debug: true"}
282640
+ ]</edits>
282641
+ </multi_edit>
282642
+
282643
+ Mixed edit modes in one batch:
282644
+ <multi_edit>
282645
+ <edits>[
282646
+ {"file_path": "src/utils.js", "symbol": "oldHelper", "new_string": "function newHelper() { return 42; }"},
282647
+ {"file_path": "src/main.js", "old_string": "oldHelper()", "new_string": "newHelper()", "replace_all": true},
282648
+ {"file_path": "src/index.js", "start_line": "10", "end_line": "12", "new_string": "export { newHelper };"}
282649
+ ]</edits>
282650
+ </multi_edit>`;
280839
282651
  }
280840
282652
  });
280841
282653
 
@@ -281328,7 +283140,8 @@ function getValidParamsForTool(toolName) {
281328
283140
  task: taskSchema,
281329
283141
  attempt_completion: attemptCompletionSchema,
281330
283142
  edit: editSchema,
281331
- create: createSchema
283143
+ create: createSchema,
283144
+ multi_edit: multiEditSchema
281332
283145
  };
281333
283146
  const schema = schemaMap[toolName];
281334
283147
  if (!schema) {
@@ -281368,7 +283181,7 @@ function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
281368
283181
  const closeTag = `</${toolName}>`;
281369
283182
  const openIndex = earliestOpenIndex;
281370
283183
  let closeIndex;
281371
- if (toolName === "attempt_completion") {
283184
+ if (LAST_INDEX_TOOLS.has(toolName)) {
281372
283185
  closeIndex = xmlString.lastIndexOf(closeTag);
281373
283186
  if (closeIndex !== -1 && closeIndex <= openIndex + openTag.length) {
281374
283187
  closeIndex = -1;
@@ -281393,7 +283206,15 @@ function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
281393
283206
  if (paramOpenIndex === -1) {
281394
283207
  continue;
281395
283208
  }
281396
- let paramCloseIndex = innerContent.indexOf(paramCloseTag, paramOpenIndex + paramOpenTag.length);
283209
+ let paramCloseIndex;
283210
+ if (RAW_CONTENT_PARAMS.has(paramName)) {
283211
+ paramCloseIndex = innerContent.lastIndexOf(paramCloseTag);
283212
+ if (paramCloseIndex !== -1 && paramCloseIndex <= paramOpenIndex + paramOpenTag.length) {
283213
+ paramCloseIndex = -1;
283214
+ }
283215
+ } else {
283216
+ paramCloseIndex = innerContent.indexOf(paramCloseTag, paramOpenIndex + paramOpenTag.length);
283217
+ }
281397
283218
  if (paramCloseIndex === -1) {
281398
283219
  let nextTagIndex = innerContent.length;
281399
283220
  for (const nextParam of validParams) {
@@ -281405,18 +283226,26 @@ function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
281405
283226
  }
281406
283227
  paramCloseIndex = nextTagIndex;
281407
283228
  }
281408
- let paramValue = unescapeXmlEntities(innerContent.substring(
283229
+ const rawValue = innerContent.substring(
281409
283230
  paramOpenIndex + paramOpenTag.length,
281410
283231
  paramCloseIndex
281411
- ).trim());
281412
- if (paramValue.toLowerCase() === "true") {
281413
- paramValue = true;
281414
- } else if (paramValue.toLowerCase() === "false") {
281415
- paramValue = false;
281416
- } else if (!isNaN(paramValue) && paramValue.trim() !== "") {
281417
- const num = Number(paramValue);
281418
- if (Number.isFinite(num)) {
281419
- paramValue = num;
283232
+ );
283233
+ let paramValue;
283234
+ if (RAW_CONTENT_PARAMS.has(paramName)) {
283235
+ paramValue = unescapeXmlEntities(rawValue.replace(/^\n/, "").replace(/\n$/, ""));
283236
+ } else {
283237
+ paramValue = unescapeXmlEntities(rawValue.trim());
283238
+ }
283239
+ if (!RAW_CONTENT_PARAMS.has(paramName)) {
283240
+ if (paramValue.toLowerCase() === "true") {
283241
+ paramValue = true;
283242
+ } else if (paramValue.toLowerCase() === "false") {
283243
+ paramValue = false;
283244
+ } else if (!isNaN(paramValue) && paramValue.trim() !== "") {
283245
+ const num = Number(paramValue);
283246
+ if (Number.isFinite(num)) {
283247
+ paramValue = num;
283248
+ }
281420
283249
  }
281421
283250
  }
281422
283251
  params[paramName] = paramValue;
@@ -281459,6 +283288,7 @@ function detectUnrecognizedToolCall(xmlString, validTools) {
281459
283288
  "readImage",
281460
283289
  "edit",
281461
283290
  "create",
283291
+ "multi_edit",
281462
283292
  "delegate",
281463
283293
  "bash",
281464
283294
  "task",
@@ -281588,7 +283418,7 @@ function resolveTargetPath(target, cwd) {
281588
283418
  }
281589
283419
  return filePart + suffix;
281590
283420
  }
281591
- var import_path6, searchSchema, searchAllSchema, querySchema, extractSchema, delegateSchema, listSkillsSchema, useSkillSchema, bashSchema, analyzeAllSchema, executePlanSchema, cleanupExecutePlanSchema, attemptCompletionSchema, searchToolDefinition, queryToolDefinition, extractToolDefinition, delegateToolDefinition, attemptCompletionToolDefinition, analyzeAllToolDefinition, bashToolDefinition, googleSearchToolDefinition, urlContextToolDefinition, searchDescription, queryDescription, extractDescription, delegateDescription, bashDescription, analyzeAllDescription, DEFAULT_VALID_TOOLS;
283421
+ var import_path6, searchSchema, searchAllSchema, querySchema, extractSchema, delegateSchema, listSkillsSchema, useSkillSchema, bashSchema, analyzeAllSchema, executePlanSchema, cleanupExecutePlanSchema, attemptCompletionSchema, searchToolDefinition, queryToolDefinition, extractToolDefinition, delegateToolDefinition, attemptCompletionToolDefinition, analyzeAllToolDefinition, bashToolDefinition, googleSearchToolDefinition, urlContextToolDefinition, searchDescription, queryDescription, extractDescription, delegateDescription, bashDescription, analyzeAllDescription, DEFAULT_VALID_TOOLS, RAW_CONTENT_PARAMS, LAST_INDEX_TOOLS;
281592
283422
  var init_common2 = __esm({
281593
283423
  "src/tools/common.js"() {
281594
283424
  "use strict";
@@ -282008,6 +283838,8 @@ Capabilities:
282008
283838
  "task",
282009
283839
  "attempt_completion"
282010
283840
  ];
283841
+ RAW_CONTENT_PARAMS = /* @__PURE__ */ new Set(["content", "new_string", "old_string"]);
283842
+ LAST_INDEX_TOOLS = /* @__PURE__ */ new Set(["attempt_completion", "create", "edit"]);
282011
283843
  }
282012
283844
  });
282013
283845
 
@@ -282673,6 +284505,9 @@ function createTools(configOptions) {
282673
284505
  if (configOptions.allowEdit && isToolAllowed("create")) {
282674
284506
  tools2.createTool = createTool(configOptions);
282675
284507
  }
284508
+ if (configOptions.allowEdit && isToolAllowed("multi_edit")) {
284509
+ tools2.multiEditTool = multiEditTool(configOptions);
284510
+ }
282676
284511
  return tools2;
282677
284512
  }
282678
284513
  function parseXmlToolCallWithThinking(xmlString, validTools) {
@@ -290058,6 +291893,13 @@ function createWrappedTools(baseTools) {
290058
291893
  baseTools.createTool.execute
290059
291894
  );
290060
291895
  }
291896
+ if (baseTools.multiEditTool) {
291897
+ wrappedTools.multiEditToolInstance = wrapToolWithEmitter(
291898
+ baseTools.multiEditTool,
291899
+ "multi_edit",
291900
+ baseTools.multiEditTool.execute
291901
+ );
291902
+ }
290061
291903
  return wrappedTools;
290062
291904
  }
290063
291905
  var import_child_process6, import_util11, import_crypto4, import_events, import_fs7, import_fs8, import_path8, toolCallEmitter, activeToolExecutions, wrapToolWithEmitter, listFilesTool, searchFilesTool, listFilesToolInstance, searchFilesToolInstance;
@@ -353146,6 +354988,9 @@ var init_ProbeAgent = __esm({
353146
354988
  if (wrappedTools.createToolInstance && isToolAllowed("create")) {
353147
354989
  this.toolImplementations.create = wrappedTools.createToolInstance;
353148
354990
  }
354991
+ if (wrappedTools.multiEditToolInstance && isToolAllowed("multi_edit")) {
354992
+ this.toolImplementations.multi_edit = wrappedTools.multiEditToolInstance;
354993
+ }
353149
354994
  }
353150
354995
  this.wrappedTools = wrappedTools;
353151
354996
  if (this.debug) {
@@ -354435,6 +356280,10 @@ Workspace: ${this.allowedFolders.join(", ")}`;
354435
356280
  }
354436
356281
  if (this.allowEdit && isToolAllowed("create")) {
354437
356282
  toolDefinitions += `${createToolDefinition}
356283
+ `;
356284
+ }
356285
+ if (this.allowEdit && isToolAllowed("multi_edit")) {
356286
+ toolDefinitions += `${multiEditToolDefinition}
354438
356287
  `;
354439
356288
  }
354440
356289
  if (this.enableBash && isToolAllowed("bash")) {
@@ -354531,6 +356380,9 @@ The configuration is loaded from src/config.js lines 15-25 which contains the da
354531
356380
  if (this.allowEdit && isToolAllowed("create")) {
354532
356381
  availableToolsList += "- create: Create new files with specified content.\n";
354533
356382
  }
356383
+ if (this.allowEdit && isToolAllowed("multi_edit")) {
356384
+ availableToolsList += "- multi_edit: Apply multiple file edits in one call using a JSON array of operations.\n";
356385
+ }
354534
356386
  if (this.enableDelegate && isToolAllowed("delegate")) {
354535
356387
  availableToolsList += "- delegate: Delegate big distinct tasks to specialized probe subagents.\n";
354536
356388
  }
@@ -355125,6 +356977,9 @@ You are working with a workspace. Available paths: ${workspaceDesc}
355125
356977
  if (this.allowEdit && this.allowedTools.isEnabled("create")) {
355126
356978
  validTools.push("create");
355127
356979
  }
356980
+ if (this.allowEdit && this.allowedTools.isEnabled("multi_edit")) {
356981
+ validTools.push("multi_edit");
356982
+ }
355128
356983
  if (this.enableBash && this.allowedTools.isEnabled("bash")) {
355129
356984
  validTools.push("bash");
355130
356985
  }
@@ -358231,6 +360086,10 @@ __export(tools_exports, {
358231
360086
  extractTool: () => extractTool,
358232
360087
  getCleanupExecutePlanToolDefinition: () => getCleanupExecutePlanToolDefinition,
358233
360088
  getExecutePlanToolDefinition: () => getExecutePlanToolDefinition,
360089
+ multiEditDescription: () => multiEditDescription,
360090
+ multiEditSchema: () => multiEditSchema,
360091
+ multiEditTool: () => multiEditTool,
360092
+ multiEditToolDefinition: () => multiEditToolDefinition,
358234
360093
  parseAndResolvePaths: () => parseAndResolvePaths,
358235
360094
  querySchema: () => querySchema,
358236
360095
  queryTool: () => queryTool,
@@ -358882,6 +360741,9 @@ __export(index_exports, {
358882
360741
  initializeSimpleTelemetryFromOptions: () => initializeSimpleTelemetryFromOptions,
358883
360742
  listFilesByLevel: () => listFilesByLevel,
358884
360743
  listFilesToolInstance: () => listFilesToolInstance,
360744
+ multiEditSchema: () => multiEditSchema,
360745
+ multiEditTool: () => multiEditTool,
360746
+ multiEditToolDefinition: () => multiEditToolDefinition,
358885
360747
  parseXmlToolCall: () => parseXmlToolCall,
358886
360748
  query: () => query,
358887
360749
  querySchema: () => querySchema,
@@ -394190,7 +396052,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"100":"Continue","101":"Switching Pro
394190
396052
  /***/ ((module) => {
394191
396053
 
394192
396054
  "use strict";
394193
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.143","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-rc258","@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"]}}');
396055
+ 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-rc259","@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"]}}');
394194
396056
 
394195
396057
  /***/ })
394196
396058