@probelabs/visor 0.1.163 → 0.1.164-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 (96) hide show
  1. package/dist/ai-review-service.d.ts +2 -0
  2. package/dist/ai-review-service.d.ts.map +1 -1
  3. package/dist/generated/config-schema.d.ts +14 -6
  4. package/dist/generated/config-schema.d.ts.map +1 -1
  5. package/dist/generated/config-schema.json +14 -6
  6. package/dist/index.js +1997 -136
  7. package/dist/providers/ai-check-provider.d.ts.map +1 -1
  8. package/dist/sdk/{check-provider-registry-JGXU3OEJ.mjs → check-provider-registry-AWFYHQAW.mjs} +6 -6
  9. package/dist/sdk/{check-provider-registry-XE2FY37D.mjs → check-provider-registry-TTVN3V2O.mjs} +6 -6
  10. package/dist/sdk/{chunk-AS6LIEO4.mjs → chunk-DEAPFYNX.mjs} +15 -7
  11. package/dist/sdk/chunk-DEAPFYNX.mjs.map +1 -0
  12. package/dist/sdk/{chunk-53RHNNWQ.mjs → chunk-GOJRNYTV.mjs} +31 -17
  13. package/dist/sdk/chunk-GOJRNYTV.mjs.map +1 -0
  14. package/dist/sdk/{chunk-WBSARB5X.mjs → chunk-J236ZVYX.mjs} +3 -3
  15. package/dist/sdk/{chunk-PQACCZF7.mjs → chunk-N4SZPYA6.mjs} +32 -18
  16. package/dist/sdk/chunk-N4SZPYA6.mjs.map +1 -0
  17. package/dist/sdk/{chunk-ZH6K5NSC.mjs → chunk-S47KBQQK.mjs} +2 -2
  18. package/dist/sdk/{chunk-ZH6K5NSC.mjs.map → chunk-S47KBQQK.mjs.map} +1 -1
  19. package/dist/sdk/{chunk-I7J2BNOK.mjs → chunk-XDIBL7QB.mjs} +2 -2
  20. package/dist/sdk/{config-CWHZO5AL.mjs → config-D6WF2U4B.mjs} +2 -2
  21. package/dist/sdk/{failure-condition-evaluator-MEX6VNYT.mjs → failure-condition-evaluator-N3VNLWZD.mjs} +3 -3
  22. package/dist/sdk/{github-frontend-QSXBPYQZ.mjs → github-frontend-ATORHHF6.mjs} +3 -3
  23. package/dist/sdk/{host-PRANMDPG.mjs → host-OBXKDFT7.mjs} +2 -2
  24. package/dist/sdk/{host-Q4N357JE.mjs → host-QFABFVSJ.mjs} +2 -2
  25. package/dist/sdk/knex-store-CRORFJE6.mjs +527 -0
  26. package/dist/sdk/knex-store-CRORFJE6.mjs.map +1 -0
  27. package/dist/sdk/loader-NJCF7DUS.mjs +89 -0
  28. package/dist/sdk/loader-NJCF7DUS.mjs.map +1 -0
  29. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs +655 -0
  30. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs.map +1 -0
  31. package/dist/sdk/{routing-7CQ7QWYE.mjs → routing-TGJD66Q5.mjs} +4 -4
  32. package/dist/sdk/{schedule-tool-FYV3JUF7.mjs → schedule-tool-D5TSTGP2.mjs} +6 -6
  33. package/dist/sdk/{schedule-tool-VUAATWZX.mjs → schedule-tool-SPUM47DS.mjs} +6 -6
  34. package/dist/sdk/{schedule-tool-handler-A5PN6FU3.mjs → schedule-tool-handler-CT5DUQ32.mjs} +6 -6
  35. package/dist/sdk/{schedule-tool-handler-ALCEOPSP.mjs → schedule-tool-handler-DKHHPZAG.mjs} +6 -6
  36. package/dist/sdk/sdk.d.mts +4 -0
  37. package/dist/sdk/sdk.d.ts +4 -0
  38. package/dist/sdk/sdk.js +1662 -266
  39. package/dist/sdk/sdk.js.map +1 -1
  40. package/dist/sdk/sdk.mjs +5 -5
  41. package/dist/sdk/{trace-helpers-VDR4RKGC.mjs → trace-helpers-J5CJ4PUN.mjs} +2 -2
  42. package/dist/sdk/validator-XTZJZZJH.mjs +134 -0
  43. package/dist/sdk/validator-XTZJZZJH.mjs.map +1 -0
  44. package/dist/sdk/{workflow-check-provider-EO2U27T5.mjs → workflow-check-provider-JORTTXVH.mjs} +6 -6
  45. package/dist/sdk/{workflow-check-provider-XIZZYC3E.mjs → workflow-check-provider-T6WFK4RB.mjs} +6 -6
  46. package/dist/types/config.d.ts +4 -0
  47. package/dist/types/config.d.ts.map +1 -1
  48. package/package.json +2 -2
  49. package/dist/output/traces/run-2026-03-05T19-35-29-511Z.ndjson +0 -138
  50. package/dist/output/traces/run-2026-03-05T19-36-14-950Z.ndjson +0 -2235
  51. package/dist/sdk/check-provider-registry-BDPHCHX3.mjs +0 -29
  52. package/dist/sdk/chunk-53RHNNWQ.mjs.map +0 -1
  53. package/dist/sdk/chunk-7JOA3LUH.mjs +0 -43877
  54. package/dist/sdk/chunk-7JOA3LUH.mjs.map +0 -1
  55. package/dist/sdk/chunk-AS6LIEO4.mjs.map +0 -1
  56. package/dist/sdk/chunk-PQACCZF7.mjs.map +0 -1
  57. package/dist/sdk/chunk-R5PIUZSD.mjs +0 -1502
  58. package/dist/sdk/chunk-TH6WMIV7.mjs +0 -739
  59. package/dist/sdk/chunk-TH6WMIV7.mjs.map +0 -1
  60. package/dist/sdk/chunk-TLM6C3Q6.mjs +0 -443
  61. package/dist/sdk/chunk-TLM6C3Q6.mjs.map +0 -1
  62. package/dist/sdk/chunk-WBSARB5X.mjs.map +0 -1
  63. package/dist/sdk/failure-condition-evaluator-NBRX4N23.mjs +0 -17
  64. package/dist/sdk/github-frontend-UKDXNGOG.mjs +0 -1368
  65. package/dist/sdk/github-frontend-UKDXNGOG.mjs.map +0 -1
  66. package/dist/sdk/routing-N2XJVSCQ.mjs +0 -25
  67. package/dist/sdk/schedule-tool-DCODWSDM.mjs +0 -35
  68. package/dist/sdk/schedule-tool-handler-ALCEOPSP.mjs.map +0 -1
  69. package/dist/sdk/schedule-tool-handler-D6Z3PCDJ.mjs +0 -39
  70. package/dist/sdk/schedule-tool-handler-D6Z3PCDJ.mjs.map +0 -1
  71. package/dist/sdk/trace-helpers-JFELCJZT.mjs +0 -25
  72. package/dist/sdk/trace-helpers-JFELCJZT.mjs.map +0 -1
  73. package/dist/sdk/trace-helpers-VDR4RKGC.mjs.map +0 -1
  74. package/dist/sdk/workflow-check-provider-B2FOW6P2.mjs +0 -29
  75. package/dist/sdk/workflow-check-provider-B2FOW6P2.mjs.map +0 -1
  76. package/dist/sdk/workflow-check-provider-EO2U27T5.mjs.map +0 -1
  77. package/dist/sdk/workflow-check-provider-XIZZYC3E.mjs.map +0 -1
  78. package/dist/traces/run-2026-03-05T19-35-29-511Z.ndjson +0 -138
  79. package/dist/traces/run-2026-03-05T19-36-14-950Z.ndjson +0 -2235
  80. /package/dist/sdk/{check-provider-registry-BDPHCHX3.mjs.map → check-provider-registry-AWFYHQAW.mjs.map} +0 -0
  81. /package/dist/sdk/{check-provider-registry-JGXU3OEJ.mjs.map → check-provider-registry-TTVN3V2O.mjs.map} +0 -0
  82. /package/dist/sdk/{chunk-R5PIUZSD.mjs.map → chunk-J236ZVYX.mjs.map} +0 -0
  83. /package/dist/sdk/{chunk-I7J2BNOK.mjs.map → chunk-XDIBL7QB.mjs.map} +0 -0
  84. /package/dist/sdk/{check-provider-registry-XE2FY37D.mjs.map → config-D6WF2U4B.mjs.map} +0 -0
  85. /package/dist/sdk/{config-CWHZO5AL.mjs.map → failure-condition-evaluator-N3VNLWZD.mjs.map} +0 -0
  86. /package/dist/sdk/{github-frontend-QSXBPYQZ.mjs.map → github-frontend-ATORHHF6.mjs.map} +0 -0
  87. /package/dist/sdk/{host-PRANMDPG.mjs.map → host-OBXKDFT7.mjs.map} +0 -0
  88. /package/dist/sdk/{host-Q4N357JE.mjs.map → host-QFABFVSJ.mjs.map} +0 -0
  89. /package/dist/sdk/{failure-condition-evaluator-MEX6VNYT.mjs.map → routing-TGJD66Q5.mjs.map} +0 -0
  90. /package/dist/sdk/{failure-condition-evaluator-NBRX4N23.mjs.map → schedule-tool-D5TSTGP2.mjs.map} +0 -0
  91. /package/dist/sdk/{routing-7CQ7QWYE.mjs.map → schedule-tool-SPUM47DS.mjs.map} +0 -0
  92. /package/dist/sdk/{routing-N2XJVSCQ.mjs.map → schedule-tool-handler-CT5DUQ32.mjs.map} +0 -0
  93. /package/dist/sdk/{schedule-tool-DCODWSDM.mjs.map → schedule-tool-handler-DKHHPZAG.mjs.map} +0 -0
  94. /package/dist/sdk/{schedule-tool-FYV3JUF7.mjs.map → trace-helpers-J5CJ4PUN.mjs.map} +0 -0
  95. /package/dist/sdk/{schedule-tool-VUAATWZX.mjs.map → workflow-check-provider-JORTTXVH.mjs.map} +0 -0
  96. /package/dist/sdk/{schedule-tool-handler-A5PN6FU3.mjs.map → workflow-check-provider-T6WFK4RB.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.163';
3
- process.env.PROBE_VERSION = '0.6.0-rc276';
4
- process.env.VISOR_COMMIT_SHA = '13be3922b96d47f2a37e9367d34de75d5aa5f71d';
5
- process.env.VISOR_COMMIT_SHORT = '13be3922b';
2
+ process.env.VISOR_VERSION = '0.1.164';
3
+ process.env.PROBE_VERSION = '0.6.0-rc278';
4
+ process.env.VISOR_COMMIT_SHA = '3fe559c29c2798f520483a79493f3eda97710e62';
5
+ process.env.VISOR_COMMIT_SHORT = '3fe559c';
6
6
  /******/ (() => { // webpackBootstrap
7
7
  /******/ var __webpack_modules__ = ({
8
8
 
@@ -160099,6 +160099,13 @@ ${'='.repeat(60)}
160099
160099
  if (this.config.bashConfig !== undefined) {
160100
160100
  options.bashConfig = this.config.bashConfig;
160101
160101
  }
160102
+ // Pass search delegate provider/model overrides to ProbeAgent
160103
+ if (this.config.search_delegate_provider) {
160104
+ options.searchDelegateProvider = this.config.search_delegate_provider;
160105
+ }
160106
+ if (this.config.search_delegate_model) {
160107
+ options.searchDelegateModel = this.config.search_delegate_model;
160108
+ }
160102
160109
  // Pass completion prompt for post-completion validation/review
160103
160110
  if (this.config.completionPrompt !== undefined) {
160104
160111
  options.completionPrompt = this.config.completionPrompt;
@@ -161210,7 +161217,7 @@ async function handleDumpPolicyInput(checkId, argv) {
161210
161217
  let PolicyInputBuilder;
161211
161218
  try {
161212
161219
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
161213
- const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(71370)));
161220
+ const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(17117)));
161214
161221
  PolicyInputBuilder = mod.PolicyInputBuilder;
161215
161222
  }
161216
161223
  catch {
@@ -167097,6 +167104,1810 @@ class DependencyResolver {
167097
167104
  exports.DependencyResolver = DependencyResolver;
167098
167105
 
167099
167106
 
167107
+ /***/ }),
167108
+
167109
+ /***/ 50069:
167110
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167111
+
167112
+ "use strict";
167113
+
167114
+ /**
167115
+ * Copyright (c) ProbeLabs. All rights reserved.
167116
+ * Licensed under the Elastic License 2.0; you may not use this file except
167117
+ * in compliance with the Elastic License 2.0.
167118
+ */
167119
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167120
+ if (k2 === undefined) k2 = k;
167121
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167122
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167123
+ desc = { enumerable: true, get: function() { return m[k]; } };
167124
+ }
167125
+ Object.defineProperty(o, k2, desc);
167126
+ }) : (function(o, m, k, k2) {
167127
+ if (k2 === undefined) k2 = k;
167128
+ o[k2] = m[k];
167129
+ }));
167130
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167131
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167132
+ }) : function(o, v) {
167133
+ o["default"] = v;
167134
+ });
167135
+ var __importStar = (this && this.__importStar) || (function () {
167136
+ var ownKeys = function(o) {
167137
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167138
+ var ar = [];
167139
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167140
+ return ar;
167141
+ };
167142
+ return ownKeys(o);
167143
+ };
167144
+ return function (mod) {
167145
+ if (mod && mod.__esModule) return mod;
167146
+ var result = {};
167147
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167148
+ __setModuleDefault(result, mod);
167149
+ return result;
167150
+ };
167151
+ })();
167152
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167153
+ exports.LicenseValidator = void 0;
167154
+ const crypto = __importStar(__nccwpck_require__(76982));
167155
+ const fs = __importStar(__nccwpck_require__(79896));
167156
+ const path = __importStar(__nccwpck_require__(16928));
167157
+ class LicenseValidator {
167158
+ /** Ed25519 public key for license verification (PEM format). */
167159
+ static PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----\n' +
167160
+ 'MCowBQYDK2VwAyEAI/Zd08EFmgIdrDm/HXd0l3/5GBt7R1PrdvhdmEXhJlU=\n' +
167161
+ '-----END PUBLIC KEY-----\n';
167162
+ cache = null;
167163
+ static CACHE_TTL = 5 * 60 * 1000; // 5 minutes
167164
+ static GRACE_PERIOD = 72 * 3600 * 1000; // 72 hours after expiry
167165
+ /**
167166
+ * Load and validate license from environment or file.
167167
+ *
167168
+ * Resolution order:
167169
+ * 1. VISOR_LICENSE env var (JWT string)
167170
+ * 2. VISOR_LICENSE_FILE env var (path to file)
167171
+ * 3. .visor-license in project root (cwd)
167172
+ * 4. .visor-license in ~/.config/visor/
167173
+ */
167174
+ async loadAndValidate() {
167175
+ // Return cached result if still fresh
167176
+ if (this.cache && Date.now() - this.cache.validatedAt < LicenseValidator.CACHE_TTL) {
167177
+ return this.cache.payload;
167178
+ }
167179
+ const token = this.resolveToken();
167180
+ if (!token)
167181
+ return null;
167182
+ const payload = this.verifyAndDecode(token);
167183
+ if (!payload)
167184
+ return null;
167185
+ this.cache = { payload, validatedAt: Date.now() };
167186
+ return payload;
167187
+ }
167188
+ /** Check if a specific feature is licensed */
167189
+ hasFeature(feature) {
167190
+ if (!this.cache)
167191
+ return false;
167192
+ return this.cache.payload.features.includes(feature);
167193
+ }
167194
+ /** Check if license is valid (with grace period) */
167195
+ isValid() {
167196
+ if (!this.cache)
167197
+ return false;
167198
+ const now = Date.now();
167199
+ const expiryMs = this.cache.payload.exp * 1000;
167200
+ return now < expiryMs + LicenseValidator.GRACE_PERIOD;
167201
+ }
167202
+ /** Check if the license is within its grace period (expired but still valid) */
167203
+ isInGracePeriod() {
167204
+ if (!this.cache)
167205
+ return false;
167206
+ const now = Date.now();
167207
+ const expiryMs = this.cache.payload.exp * 1000;
167208
+ return now >= expiryMs && now < expiryMs + LicenseValidator.GRACE_PERIOD;
167209
+ }
167210
+ resolveToken() {
167211
+ // 1. Direct env var
167212
+ if (process.env.VISOR_LICENSE) {
167213
+ return process.env.VISOR_LICENSE.trim();
167214
+ }
167215
+ // 2. File path from env (validate against path traversal)
167216
+ if (process.env.VISOR_LICENSE_FILE) {
167217
+ // path.resolve() produces an absolute path with all '..' segments resolved,
167218
+ // so a separate resolved.includes('..') check is unnecessary.
167219
+ const resolved = path.resolve(process.env.VISOR_LICENSE_FILE);
167220
+ const home = process.env.HOME || process.env.USERPROFILE || '';
167221
+ const allowedPrefixes = [path.normalize(process.cwd())];
167222
+ if (home)
167223
+ allowedPrefixes.push(path.normalize(path.join(home, '.config', 'visor')));
167224
+ // Resolve symlinks so an attacker cannot create a symlink inside an
167225
+ // allowed prefix that points to an arbitrary file outside it.
167226
+ let realPath;
167227
+ try {
167228
+ realPath = fs.realpathSync(resolved);
167229
+ }
167230
+ catch {
167231
+ return null; // File doesn't exist or isn't accessible
167232
+ }
167233
+ const isSafe = allowedPrefixes.some(prefix => realPath === prefix || realPath.startsWith(prefix + path.sep));
167234
+ if (!isSafe)
167235
+ return null;
167236
+ return this.readFile(realPath);
167237
+ }
167238
+ // 3. .visor-license in cwd
167239
+ const cwdPath = path.join(process.cwd(), '.visor-license');
167240
+ const cwdToken = this.readFile(cwdPath);
167241
+ if (cwdToken)
167242
+ return cwdToken;
167243
+ // 4. ~/.config/visor/.visor-license
167244
+ const home = process.env.HOME || process.env.USERPROFILE || '';
167245
+ if (home) {
167246
+ const configPath = path.join(home, '.config', 'visor', '.visor-license');
167247
+ const configToken = this.readFile(configPath);
167248
+ if (configToken)
167249
+ return configToken;
167250
+ }
167251
+ return null;
167252
+ }
167253
+ readFile(filePath) {
167254
+ try {
167255
+ return fs.readFileSync(filePath, 'utf-8').trim();
167256
+ }
167257
+ catch {
167258
+ return null;
167259
+ }
167260
+ }
167261
+ verifyAndDecode(token) {
167262
+ try {
167263
+ const parts = token.split('.');
167264
+ if (parts.length !== 3)
167265
+ return null;
167266
+ const [headerB64, payloadB64, signatureB64] = parts;
167267
+ // Decode header to verify algorithm
167268
+ const header = JSON.parse(Buffer.from(headerB64, 'base64url').toString());
167269
+ if (header.alg !== 'EdDSA')
167270
+ return null;
167271
+ // Verify signature
167272
+ const data = `${headerB64}.${payloadB64}`;
167273
+ const signature = Buffer.from(signatureB64, 'base64url');
167274
+ const publicKey = crypto.createPublicKey(LicenseValidator.PUBLIC_KEY);
167275
+ // Validate that the loaded public key is actually Ed25519 (OID 1.3.101.112).
167276
+ // This prevents algorithm-confusion attacks if the embedded key were ever
167277
+ // swapped to a different type.
167278
+ if (publicKey.asymmetricKeyType !== 'ed25519') {
167279
+ return null;
167280
+ }
167281
+ // Ed25519 verification: algorithm must be null because EdDSA performs its
167282
+ // own internal hashing (SHA-512) — passing a digest algorithm here would
167283
+ // cause Node.js to throw. The key type is validated above.
167284
+ const isValid = crypto.verify(null, Buffer.from(data), publicKey, signature);
167285
+ if (!isValid)
167286
+ return null;
167287
+ // Decode payload
167288
+ const payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString());
167289
+ // Validate required fields
167290
+ if (!payload.org ||
167291
+ !Array.isArray(payload.features) ||
167292
+ typeof payload.exp !== 'number' ||
167293
+ typeof payload.iat !== 'number' ||
167294
+ !payload.sub) {
167295
+ return null;
167296
+ }
167297
+ // Check expiry (with grace period)
167298
+ const now = Date.now();
167299
+ const expiryMs = payload.exp * 1000;
167300
+ if (now >= expiryMs + LicenseValidator.GRACE_PERIOD) {
167301
+ return null;
167302
+ }
167303
+ return payload;
167304
+ }
167305
+ catch {
167306
+ return null;
167307
+ }
167308
+ }
167309
+ }
167310
+ exports.LicenseValidator = LicenseValidator;
167311
+
167312
+
167313
+ /***/ }),
167314
+
167315
+ /***/ 87068:
167316
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167317
+
167318
+ "use strict";
167319
+
167320
+ /**
167321
+ * Copyright (c) ProbeLabs. All rights reserved.
167322
+ * Licensed under the Elastic License 2.0; you may not use this file except
167323
+ * in compliance with the Elastic License 2.0.
167324
+ */
167325
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167326
+ if (k2 === undefined) k2 = k;
167327
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167328
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167329
+ desc = { enumerable: true, get: function() { return m[k]; } };
167330
+ }
167331
+ Object.defineProperty(o, k2, desc);
167332
+ }) : (function(o, m, k, k2) {
167333
+ if (k2 === undefined) k2 = k;
167334
+ o[k2] = m[k];
167335
+ }));
167336
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167337
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167338
+ }) : function(o, v) {
167339
+ o["default"] = v;
167340
+ });
167341
+ var __importStar = (this && this.__importStar) || (function () {
167342
+ var ownKeys = function(o) {
167343
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167344
+ var ar = [];
167345
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167346
+ return ar;
167347
+ };
167348
+ return ownKeys(o);
167349
+ };
167350
+ return function (mod) {
167351
+ if (mod && mod.__esModule) return mod;
167352
+ var result = {};
167353
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167354
+ __setModuleDefault(result, mod);
167355
+ return result;
167356
+ };
167357
+ })();
167358
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167359
+ exports.loadEnterprisePolicyEngine = loadEnterprisePolicyEngine;
167360
+ exports.loadEnterpriseStoreBackend = loadEnterpriseStoreBackend;
167361
+ const default_engine_1 = __nccwpck_require__(93866);
167362
+ /**
167363
+ * Load the enterprise policy engine if licensed, otherwise return the default no-op engine.
167364
+ *
167365
+ * This is the sole import boundary between OSS and enterprise code. Core code
167366
+ * must only import from this module (via dynamic `await import()`), never from
167367
+ * individual enterprise submodules.
167368
+ */
167369
+ async function loadEnterprisePolicyEngine(config) {
167370
+ try {
167371
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167372
+ const validator = new LicenseValidator();
167373
+ const license = await validator.loadAndValidate();
167374
+ if (!license || !validator.hasFeature('policy')) {
167375
+ return new default_engine_1.DefaultPolicyEngine();
167376
+ }
167377
+ if (validator.isInGracePeriod()) {
167378
+ // eslint-disable-next-line no-console
167379
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167380
+ 'Please renew your license.');
167381
+ }
167382
+ const { OpaPolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(39530)));
167383
+ const engine = new OpaPolicyEngine(config);
167384
+ await engine.initialize(config);
167385
+ return engine;
167386
+ }
167387
+ catch (err) {
167388
+ // Enterprise code not available or initialization failed
167389
+ const msg = err instanceof Error ? err.message : String(err);
167390
+ try {
167391
+ const { logger } = __nccwpck_require__(86999);
167392
+ logger.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
167393
+ }
167394
+ catch {
167395
+ // silent
167396
+ }
167397
+ return new default_engine_1.DefaultPolicyEngine();
167398
+ }
167399
+ }
167400
+ /**
167401
+ * Load the enterprise schedule store backend if licensed.
167402
+ *
167403
+ * @param driver Database driver ('postgresql', 'mysql', or 'mssql')
167404
+ * @param storageConfig Storage configuration with connection details
167405
+ * @param haConfig Optional HA configuration
167406
+ * @throws Error if enterprise license is not available or missing 'scheduler-sql' feature
167407
+ */
167408
+ async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
167409
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167410
+ const validator = new LicenseValidator();
167411
+ const license = await validator.loadAndValidate();
167412
+ if (!license || !validator.hasFeature('scheduler-sql')) {
167413
+ throw new Error(`The ${driver} schedule storage driver requires a Visor Enterprise license ` +
167414
+ `with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`);
167415
+ }
167416
+ if (validator.isInGracePeriod()) {
167417
+ // eslint-disable-next-line no-console
167418
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167419
+ 'Please renew your license.');
167420
+ }
167421
+ const { KnexStoreBackend } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(63737)));
167422
+ return new KnexStoreBackend(driver, storageConfig, haConfig);
167423
+ }
167424
+
167425
+
167426
+ /***/ }),
167427
+
167428
+ /***/ 628:
167429
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167430
+
167431
+ "use strict";
167432
+
167433
+ /**
167434
+ * Copyright (c) ProbeLabs. All rights reserved.
167435
+ * Licensed under the Elastic License 2.0; you may not use this file except
167436
+ * in compliance with the Elastic License 2.0.
167437
+ */
167438
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167439
+ if (k2 === undefined) k2 = k;
167440
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167441
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167442
+ desc = { enumerable: true, get: function() { return m[k]; } };
167443
+ }
167444
+ Object.defineProperty(o, k2, desc);
167445
+ }) : (function(o, m, k, k2) {
167446
+ if (k2 === undefined) k2 = k;
167447
+ o[k2] = m[k];
167448
+ }));
167449
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167450
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167451
+ }) : function(o, v) {
167452
+ o["default"] = v;
167453
+ });
167454
+ var __importStar = (this && this.__importStar) || (function () {
167455
+ var ownKeys = function(o) {
167456
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167457
+ var ar = [];
167458
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167459
+ return ar;
167460
+ };
167461
+ return ownKeys(o);
167462
+ };
167463
+ return function (mod) {
167464
+ if (mod && mod.__esModule) return mod;
167465
+ var result = {};
167466
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167467
+ __setModuleDefault(result, mod);
167468
+ return result;
167469
+ };
167470
+ })();
167471
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167472
+ exports.OpaCompiler = void 0;
167473
+ const fs = __importStar(__nccwpck_require__(79896));
167474
+ const path = __importStar(__nccwpck_require__(16928));
167475
+ const os = __importStar(__nccwpck_require__(70857));
167476
+ const crypto = __importStar(__nccwpck_require__(76982));
167477
+ const child_process_1 = __nccwpck_require__(35317);
167478
+ /**
167479
+ * OPA Rego Compiler - compiles .rego policy files to WASM bundles using the `opa` CLI.
167480
+ *
167481
+ * Handles:
167482
+ * - Resolving input paths to WASM bytes (direct .wasm, directory with policy.wasm, or .rego files)
167483
+ * - Compiling .rego files to WASM via `opa build`
167484
+ * - Caching compiled bundles based on content hashes
167485
+ * - Extracting policy.wasm from OPA tar.gz bundles
167486
+ *
167487
+ * Requires:
167488
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
167489
+ */
167490
+ class OpaCompiler {
167491
+ static CACHE_DIR = path.join(os.tmpdir(), 'visor-opa-cache');
167492
+ /**
167493
+ * Resolve the input paths to WASM bytes.
167494
+ *
167495
+ * Strategy:
167496
+ * 1. If any path is a .wasm file, read it directly
167497
+ * 2. If a directory contains policy.wasm, read it
167498
+ * 3. Otherwise, collect all .rego files and auto-compile via `opa build`
167499
+ */
167500
+ async resolveWasmBytes(paths) {
167501
+ // Collect .rego files and check for existing .wasm
167502
+ const regoFiles = [];
167503
+ for (const p of paths) {
167504
+ const resolved = path.resolve(p);
167505
+ // Reject paths containing '..' after resolution (path traversal)
167506
+ if (path.normalize(resolved).includes('..')) {
167507
+ throw new Error(`Policy path contains traversal sequences: ${p}`);
167508
+ }
167509
+ // Direct .wasm file
167510
+ if (resolved.endsWith('.wasm') && fs.existsSync(resolved)) {
167511
+ return fs.readFileSync(resolved);
167512
+ }
167513
+ if (!fs.existsSync(resolved))
167514
+ continue;
167515
+ const stat = fs.statSync(resolved);
167516
+ if (stat.isDirectory()) {
167517
+ // Check for pre-compiled policy.wasm in directory
167518
+ const wasmCandidate = path.join(resolved, 'policy.wasm');
167519
+ if (fs.existsSync(wasmCandidate)) {
167520
+ return fs.readFileSync(wasmCandidate);
167521
+ }
167522
+ // Collect all .rego files from directory
167523
+ const files = fs.readdirSync(resolved);
167524
+ for (const f of files) {
167525
+ if (f.endsWith('.rego')) {
167526
+ regoFiles.push(path.join(resolved, f));
167527
+ }
167528
+ }
167529
+ }
167530
+ else if (resolved.endsWith('.rego')) {
167531
+ regoFiles.push(resolved);
167532
+ }
167533
+ }
167534
+ if (regoFiles.length === 0) {
167535
+ throw new Error(`OPA WASM evaluator: no .wasm bundle or .rego files found in: ${paths.join(', ')}`);
167536
+ }
167537
+ // Auto-compile .rego -> .wasm
167538
+ return this.compileRego(regoFiles);
167539
+ }
167540
+ /**
167541
+ * Auto-compile .rego files to a WASM bundle using the `opa` CLI.
167542
+ *
167543
+ * Caches the compiled bundle based on a content hash of all input .rego files
167544
+ * so subsequent runs skip compilation if policies haven't changed.
167545
+ */
167546
+ compileRego(regoFiles) {
167547
+ // Check that `opa` CLI is available
167548
+ try {
167549
+ (0, child_process_1.execFileSync)('opa', ['version'], { stdio: 'pipe' });
167550
+ }
167551
+ catch {
167552
+ throw new Error('OPA CLI (`opa`) not found on PATH. Install it from https://www.openpolicyagent.org/docs/latest/#running-opa\n' +
167553
+ 'Or pre-compile your .rego files: opa build -t wasm -e visor -o bundle.tar.gz ' +
167554
+ regoFiles.join(' '));
167555
+ }
167556
+ // Compute content hash for cache key
167557
+ const hash = crypto.createHash('sha256');
167558
+ for (const f of regoFiles.sort()) {
167559
+ hash.update(fs.readFileSync(f));
167560
+ hash.update(f); // include filename for disambiguation
167561
+ }
167562
+ const cacheKey = hash.digest('hex').slice(0, 16);
167563
+ const cacheDir = OpaCompiler.CACHE_DIR;
167564
+ const cachedWasm = path.join(cacheDir, `${cacheKey}.wasm`);
167565
+ // Return cached bundle if still valid
167566
+ if (fs.existsSync(cachedWasm)) {
167567
+ return fs.readFileSync(cachedWasm);
167568
+ }
167569
+ // Compile to WASM via opa build
167570
+ fs.mkdirSync(cacheDir, { recursive: true });
167571
+ const bundleTar = path.join(cacheDir, `${cacheKey}-bundle.tar.gz`);
167572
+ try {
167573
+ const args = [
167574
+ 'build',
167575
+ '-t',
167576
+ 'wasm',
167577
+ '-e',
167578
+ 'visor', // entrypoint: the visor package tree
167579
+ '-o',
167580
+ bundleTar,
167581
+ ...regoFiles,
167582
+ ];
167583
+ (0, child_process_1.execFileSync)('opa', args, {
167584
+ stdio: 'pipe',
167585
+ timeout: 30000,
167586
+ });
167587
+ }
167588
+ catch (err) {
167589
+ const stderr = err?.stderr?.toString() || '';
167590
+ throw new Error(`Failed to compile .rego files to WASM:\n${stderr}\n` +
167591
+ 'Ensure your .rego files are valid and the `opa` CLI is installed.');
167592
+ }
167593
+ // Extract policy.wasm from the tar.gz bundle
167594
+ // OPA bundles are tar.gz with /policy.wasm inside
167595
+ try {
167596
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, '/policy.wasm'], {
167597
+ stdio: 'pipe',
167598
+ });
167599
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
167600
+ if (fs.existsSync(extractedWasm)) {
167601
+ // Move to cache-key named file
167602
+ fs.renameSync(extractedWasm, cachedWasm);
167603
+ }
167604
+ }
167605
+ catch {
167606
+ // Some tar implementations don't like leading /
167607
+ try {
167608
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, 'policy.wasm'], {
167609
+ stdio: 'pipe',
167610
+ });
167611
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
167612
+ if (fs.existsSync(extractedWasm)) {
167613
+ fs.renameSync(extractedWasm, cachedWasm);
167614
+ }
167615
+ }
167616
+ catch (err2) {
167617
+ throw new Error(`Failed to extract policy.wasm from OPA bundle: ${err2?.message || err2}`);
167618
+ }
167619
+ }
167620
+ // Clean up tar
167621
+ try {
167622
+ fs.unlinkSync(bundleTar);
167623
+ }
167624
+ catch { }
167625
+ if (!fs.existsSync(cachedWasm)) {
167626
+ throw new Error('OPA build succeeded but policy.wasm was not found in the bundle');
167627
+ }
167628
+ return fs.readFileSync(cachedWasm);
167629
+ }
167630
+ }
167631
+ exports.OpaCompiler = OpaCompiler;
167632
+
167633
+
167634
+ /***/ }),
167635
+
167636
+ /***/ 44693:
167637
+ /***/ ((__unused_webpack_module, exports) => {
167638
+
167639
+ "use strict";
167640
+
167641
+ /**
167642
+ * Copyright (c) ProbeLabs. All rights reserved.
167643
+ * Licensed under the Elastic License 2.0; you may not use this file except
167644
+ * in compliance with the Elastic License 2.0.
167645
+ */
167646
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167647
+ exports.OpaHttpEvaluator = void 0;
167648
+ /**
167649
+ * OPA HTTP Evaluator - evaluates policies via an external OPA server's REST API.
167650
+ *
167651
+ * Uses the built-in `fetch` API (Node 18+), so no extra dependencies are needed.
167652
+ */
167653
+ class OpaHttpEvaluator {
167654
+ baseUrl;
167655
+ timeout;
167656
+ constructor(baseUrl, timeout = 5000) {
167657
+ // Validate URL format and protocol
167658
+ let parsed;
167659
+ try {
167660
+ parsed = new URL(baseUrl);
167661
+ }
167662
+ catch {
167663
+ throw new Error(`OPA HTTP evaluator: invalid URL: ${baseUrl}`);
167664
+ }
167665
+ if (!['http:', 'https:'].includes(parsed.protocol)) {
167666
+ throw new Error(`OPA HTTP evaluator: url must use http:// or https:// protocol, got: ${baseUrl}`);
167667
+ }
167668
+ // Block cloud metadata, loopback, link-local, and private network addresses
167669
+ const hostname = parsed.hostname;
167670
+ if (this.isBlockedHostname(hostname)) {
167671
+ throw new Error(`OPA HTTP evaluator: url must not point to internal, loopback, or private network addresses`);
167672
+ }
167673
+ // Normalize: strip trailing slash
167674
+ this.baseUrl = baseUrl.replace(/\/+$/, '');
167675
+ this.timeout = timeout;
167676
+ }
167677
+ /**
167678
+ * Check if a hostname is blocked due to SSRF concerns.
167679
+ *
167680
+ * Blocks:
167681
+ * - Loopback addresses (127.x.x.x, localhost, 0.0.0.0, ::1)
167682
+ * - Link-local addresses (169.254.x.x)
167683
+ * - Private networks (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
167684
+ * - IPv6 unique local addresses (fd00::/8)
167685
+ * - Cloud metadata services (*.internal)
167686
+ */
167687
+ isBlockedHostname(hostname) {
167688
+ if (!hostname)
167689
+ return true; // block empty hostnames
167690
+ // Normalize hostname: lowercase and remove brackets for IPv6
167691
+ const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
167692
+ // Block .internal domains (cloud metadata services)
167693
+ if (normalized === 'metadata.google.internal' || normalized.endsWith('.internal')) {
167694
+ return true;
167695
+ }
167696
+ // Block localhost variants
167697
+ if (normalized === 'localhost' || normalized === 'localhost.localdomain') {
167698
+ return true;
167699
+ }
167700
+ // Block IPv6 loopback
167701
+ if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
167702
+ return true;
167703
+ }
167704
+ // Check IPv4 patterns
167705
+ const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
167706
+ const ipv4Match = normalized.match(ipv4Pattern);
167707
+ if (ipv4Match) {
167708
+ const octets = ipv4Match.slice(1, 5).map(Number);
167709
+ // Validate octets are in range [0, 255]
167710
+ if (octets.some(octet => octet > 255)) {
167711
+ return false;
167712
+ }
167713
+ const [a, b] = octets;
167714
+ // Block loopback: 127.0.0.0/8
167715
+ if (a === 127) {
167716
+ return true;
167717
+ }
167718
+ // Block 0.0.0.0/8 (this host)
167719
+ if (a === 0) {
167720
+ return true;
167721
+ }
167722
+ // Block link-local: 169.254.0.0/16
167723
+ if (a === 169 && b === 254) {
167724
+ return true;
167725
+ }
167726
+ // Block private networks
167727
+ // 10.0.0.0/8
167728
+ if (a === 10) {
167729
+ return true;
167730
+ }
167731
+ // 172.16.0.0/12 (172.16.x.x through 172.31.x.x)
167732
+ if (a === 172 && b >= 16 && b <= 31) {
167733
+ return true;
167734
+ }
167735
+ // 192.168.0.0/16
167736
+ if (a === 192 && b === 168) {
167737
+ return true;
167738
+ }
167739
+ }
167740
+ // Check IPv6 patterns
167741
+ // Block unique local addresses: fd00::/8
167742
+ if (normalized.startsWith('fd') || normalized.startsWith('fc')) {
167743
+ return true;
167744
+ }
167745
+ // Block link-local: fe80::/10
167746
+ if (normalized.startsWith('fe80:')) {
167747
+ return true;
167748
+ }
167749
+ return false;
167750
+ }
167751
+ /**
167752
+ * Evaluate a policy rule against an input document via OPA REST API.
167753
+ *
167754
+ * @param input - The input document to evaluate
167755
+ * @param rulePath - OPA rule path (e.g., 'visor/check/execute')
167756
+ * @returns The result object from OPA, or undefined on error
167757
+ */
167758
+ async evaluate(input, rulePath) {
167759
+ // OPA Data API: POST /v1/data/<path>
167760
+ const encodedPath = rulePath
167761
+ .split('/')
167762
+ .map(s => encodeURIComponent(s))
167763
+ .join('/');
167764
+ const url = `${this.baseUrl}/v1/data/${encodedPath}`;
167765
+ const controller = new AbortController();
167766
+ const timer = setTimeout(() => controller.abort(), this.timeout);
167767
+ try {
167768
+ const response = await fetch(url, {
167769
+ method: 'POST',
167770
+ headers: { 'Content-Type': 'application/json' },
167771
+ body: JSON.stringify({ input }),
167772
+ signal: controller.signal,
167773
+ });
167774
+ if (!response.ok) {
167775
+ throw new Error(`OPA HTTP ${response.status}: ${response.statusText}`);
167776
+ }
167777
+ let body;
167778
+ try {
167779
+ body = await response.json();
167780
+ }
167781
+ catch (jsonErr) {
167782
+ throw new Error(`OPA HTTP evaluator: failed to parse JSON response: ${jsonErr instanceof Error ? jsonErr.message : String(jsonErr)}`);
167783
+ }
167784
+ // OPA returns { result: { ... } }
167785
+ return body?.result;
167786
+ }
167787
+ finally {
167788
+ clearTimeout(timer);
167789
+ }
167790
+ }
167791
+ async shutdown() {
167792
+ // No persistent connections to close
167793
+ }
167794
+ }
167795
+ exports.OpaHttpEvaluator = OpaHttpEvaluator;
167796
+
167797
+
167798
+ /***/ }),
167799
+
167800
+ /***/ 39530:
167801
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
167802
+
167803
+ "use strict";
167804
+
167805
+ /**
167806
+ * Copyright (c) ProbeLabs. All rights reserved.
167807
+ * Licensed under the Elastic License 2.0; you may not use this file except
167808
+ * in compliance with the Elastic License 2.0.
167809
+ */
167810
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167811
+ exports.OpaPolicyEngine = void 0;
167812
+ const opa_wasm_evaluator_1 = __nccwpck_require__(8613);
167813
+ const opa_http_evaluator_1 = __nccwpck_require__(44693);
167814
+ const policy_input_builder_1 = __nccwpck_require__(17117);
167815
+ /**
167816
+ * Enterprise OPA Policy Engine.
167817
+ *
167818
+ * Wraps both WASM (local) and HTTP (remote) OPA evaluators behind the
167819
+ * OSS PolicyEngine interface. All OPA input building and role resolution
167820
+ * is handled internally — the OSS call sites pass only plain types.
167821
+ */
167822
+ class OpaPolicyEngine {
167823
+ evaluator = null;
167824
+ fallback;
167825
+ timeout;
167826
+ config;
167827
+ inputBuilder = null;
167828
+ logger = null;
167829
+ constructor(config) {
167830
+ this.config = config;
167831
+ this.fallback = config.fallback || 'deny';
167832
+ this.timeout = config.timeout || 5000;
167833
+ }
167834
+ async initialize(config) {
167835
+ // Resolve logger once at initialization
167836
+ try {
167837
+ this.logger = (__nccwpck_require__(86999).logger);
167838
+ }
167839
+ catch {
167840
+ // logger not available in this context
167841
+ }
167842
+ // Build actor/repo context from environment (available at engine init time)
167843
+ const actor = {
167844
+ authorAssociation: process.env.VISOR_AUTHOR_ASSOCIATION,
167845
+ login: process.env.VISOR_AUTHOR_LOGIN || process.env.GITHUB_ACTOR,
167846
+ isLocalMode: !process.env.GITHUB_ACTIONS,
167847
+ };
167848
+ const repo = {
167849
+ owner: process.env.GITHUB_REPOSITORY_OWNER,
167850
+ name: process.env.GITHUB_REPOSITORY?.split('/')[1],
167851
+ branch: process.env.GITHUB_HEAD_REF,
167852
+ baseBranch: process.env.GITHUB_BASE_REF,
167853
+ event: process.env.GITHUB_EVENT_NAME,
167854
+ };
167855
+ const prNum = process.env.GITHUB_PR_NUMBER
167856
+ ? parseInt(process.env.GITHUB_PR_NUMBER, 10)
167857
+ : undefined;
167858
+ const pullRequest = {
167859
+ number: prNum !== undefined && Number.isFinite(prNum) ? prNum : undefined,
167860
+ };
167861
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(config, actor, repo, pullRequest);
167862
+ if (config.engine === 'local') {
167863
+ if (!config.rules) {
167864
+ throw new Error('OPA local mode requires `policy.rules` path to .wasm or .rego files');
167865
+ }
167866
+ const wasm = new opa_wasm_evaluator_1.OpaWasmEvaluator();
167867
+ await wasm.initialize(config.rules);
167868
+ if (config.data) {
167869
+ wasm.loadData(config.data);
167870
+ }
167871
+ this.evaluator = wasm;
167872
+ }
167873
+ else if (config.engine === 'remote') {
167874
+ if (!config.url) {
167875
+ throw new Error('OPA remote mode requires `policy.url` pointing to OPA server');
167876
+ }
167877
+ this.evaluator = new opa_http_evaluator_1.OpaHttpEvaluator(config.url, this.timeout);
167878
+ }
167879
+ else {
167880
+ this.evaluator = null;
167881
+ }
167882
+ }
167883
+ /**
167884
+ * Update actor/repo/PR context (e.g., after PR info becomes available).
167885
+ * Called by the enterprise loader when engine context is enriched.
167886
+ */
167887
+ setActorContext(actor, repo, pullRequest) {
167888
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(this.config, actor, repo, pullRequest);
167889
+ }
167890
+ async evaluateCheckExecution(checkId, checkConfig) {
167891
+ if (!this.evaluator || !this.inputBuilder)
167892
+ return { allowed: true };
167893
+ const cfg = checkConfig && typeof checkConfig === 'object'
167894
+ ? checkConfig
167895
+ : {};
167896
+ const policyOverride = cfg.policy;
167897
+ const input = this.inputBuilder.forCheckExecution({
167898
+ id: checkId,
167899
+ type: cfg.type || 'ai',
167900
+ group: cfg.group,
167901
+ tags: cfg.tags,
167902
+ criticality: cfg.criticality,
167903
+ sandbox: cfg.sandbox,
167904
+ policy: policyOverride,
167905
+ });
167906
+ return this.doEvaluate(input, this.resolveRulePath('check.execute', policyOverride?.rule));
167907
+ }
167908
+ async evaluateToolInvocation(serverName, methodName, transport) {
167909
+ if (!this.evaluator || !this.inputBuilder)
167910
+ return { allowed: true };
167911
+ const input = this.inputBuilder.forToolInvocation(serverName, methodName, transport);
167912
+ return this.doEvaluate(input, 'visor/tool/invoke');
167913
+ }
167914
+ async evaluateCapabilities(checkId, capabilities) {
167915
+ if (!this.evaluator || !this.inputBuilder)
167916
+ return { allowed: true };
167917
+ const input = this.inputBuilder.forCapabilityResolve(checkId, capabilities);
167918
+ return this.doEvaluate(input, 'visor/capability/resolve');
167919
+ }
167920
+ async shutdown() {
167921
+ if (this.evaluator && 'shutdown' in this.evaluator) {
167922
+ await this.evaluator.shutdown();
167923
+ }
167924
+ this.evaluator = null;
167925
+ this.inputBuilder = null;
167926
+ }
167927
+ resolveRulePath(defaultScope, override) {
167928
+ if (override) {
167929
+ return override.startsWith('visor/') ? override : `visor/${override}`;
167930
+ }
167931
+ return `visor/${defaultScope.replace(/\./g, '/')}`;
167932
+ }
167933
+ async doEvaluate(input, rulePath) {
167934
+ try {
167935
+ this.logger?.debug(`[PolicyEngine] Evaluating ${rulePath}`, JSON.stringify(input));
167936
+ let timer;
167937
+ const timeoutPromise = new Promise((_resolve, reject) => {
167938
+ timer = setTimeout(() => reject(new Error('policy evaluation timeout')), this.timeout);
167939
+ });
167940
+ try {
167941
+ const result = await Promise.race([this.rawEvaluate(input, rulePath), timeoutPromise]);
167942
+ const decision = this.parseDecision(result);
167943
+ // In warn mode, override denied decisions to allowed but flag as warn
167944
+ if (!decision.allowed && this.fallback === 'warn') {
167945
+ decision.allowed = true;
167946
+ decision.warn = true;
167947
+ decision.reason = `audit: ${decision.reason || 'policy denied'}`;
167948
+ }
167949
+ this.logger?.debug(`[PolicyEngine] Decision for ${rulePath}: allowed=${decision.allowed}, warn=${decision.warn || false}, reason=${decision.reason || 'none'}`);
167950
+ return decision;
167951
+ }
167952
+ finally {
167953
+ if (timer)
167954
+ clearTimeout(timer);
167955
+ }
167956
+ }
167957
+ catch (err) {
167958
+ const msg = err instanceof Error ? err.message : String(err);
167959
+ this.logger?.warn(`[PolicyEngine] Evaluation failed for ${rulePath}: ${msg}`);
167960
+ return {
167961
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
167962
+ warn: this.fallback === 'warn' ? true : undefined,
167963
+ reason: `policy evaluation failed, fallback=${this.fallback}`,
167964
+ };
167965
+ }
167966
+ }
167967
+ async rawEvaluate(input, rulePath) {
167968
+ if (this.evaluator instanceof opa_wasm_evaluator_1.OpaWasmEvaluator) {
167969
+ const result = await this.evaluator.evaluate(input);
167970
+ // WASM compiled with `-e visor` entrypoint returns the full visor package tree.
167971
+ // Navigate to the specific rule subtree using rulePath segments.
167972
+ // e.g., 'visor/check/execute' → result.check.execute
167973
+ return this.navigateWasmResult(result, rulePath);
167974
+ }
167975
+ return this.evaluator.evaluate(input, rulePath);
167976
+ }
167977
+ /**
167978
+ * Navigate nested OPA WASM result tree to reach the specific rule's output.
167979
+ * The WASM entrypoint `-e visor` means the result root IS the visor package,
167980
+ * so we strip the `visor/` prefix and walk the remaining segments.
167981
+ */
167982
+ navigateWasmResult(result, rulePath) {
167983
+ if (!result || typeof result !== 'object')
167984
+ return result;
167985
+ // Strip the 'visor/' prefix (matches our compilation entrypoint)
167986
+ const segments = rulePath.replace(/^visor\//, '').split('/');
167987
+ let current = result;
167988
+ for (const seg of segments) {
167989
+ if (current && typeof current === 'object' && seg in current) {
167990
+ current = current[seg];
167991
+ }
167992
+ else {
167993
+ return undefined; // path not found in result tree
167994
+ }
167995
+ }
167996
+ return current;
167997
+ }
167998
+ parseDecision(result) {
167999
+ if (result === undefined || result === null) {
168000
+ return {
168001
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
168002
+ warn: this.fallback === 'warn' ? true : undefined,
168003
+ reason: this.fallback === 'warn' ? 'audit: no policy result' : 'no policy result',
168004
+ };
168005
+ }
168006
+ const allowed = result.allowed !== false;
168007
+ const decision = {
168008
+ allowed,
168009
+ reason: result.reason,
168010
+ };
168011
+ if (result.capabilities) {
168012
+ decision.capabilities = result.capabilities;
168013
+ }
168014
+ return decision;
168015
+ }
168016
+ }
168017
+ exports.OpaPolicyEngine = OpaPolicyEngine;
168018
+
168019
+
168020
+ /***/ }),
168021
+
168022
+ /***/ 8613:
168023
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
168024
+
168025
+ "use strict";
168026
+
168027
+ /**
168028
+ * Copyright (c) ProbeLabs. All rights reserved.
168029
+ * Licensed under the Elastic License 2.0; you may not use this file except
168030
+ * in compliance with the Elastic License 2.0.
168031
+ */
168032
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
168033
+ if (k2 === undefined) k2 = k;
168034
+ var desc = Object.getOwnPropertyDescriptor(m, k);
168035
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
168036
+ desc = { enumerable: true, get: function() { return m[k]; } };
168037
+ }
168038
+ Object.defineProperty(o, k2, desc);
168039
+ }) : (function(o, m, k, k2) {
168040
+ if (k2 === undefined) k2 = k;
168041
+ o[k2] = m[k];
168042
+ }));
168043
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
168044
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
168045
+ }) : function(o, v) {
168046
+ o["default"] = v;
168047
+ });
168048
+ var __importStar = (this && this.__importStar) || (function () {
168049
+ var ownKeys = function(o) {
168050
+ ownKeys = Object.getOwnPropertyNames || function (o) {
168051
+ var ar = [];
168052
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
168053
+ return ar;
168054
+ };
168055
+ return ownKeys(o);
168056
+ };
168057
+ return function (mod) {
168058
+ if (mod && mod.__esModule) return mod;
168059
+ var result = {};
168060
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
168061
+ __setModuleDefault(result, mod);
168062
+ return result;
168063
+ };
168064
+ })();
168065
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168066
+ exports.OpaWasmEvaluator = void 0;
168067
+ const fs = __importStar(__nccwpck_require__(79896));
168068
+ const path = __importStar(__nccwpck_require__(16928));
168069
+ const opa_compiler_1 = __nccwpck_require__(628);
168070
+ /**
168071
+ * OPA WASM Evaluator - loads and evaluates OPA policies locally.
168072
+ *
168073
+ * Supports three input formats:
168074
+ * 1. Pre-compiled `.wasm` bundle — loaded directly (fastest startup)
168075
+ * 2. `.rego` files or directory — auto-compiled to WASM via `opa build` CLI
168076
+ * 3. Directory with `policy.wasm` inside — loaded directly
168077
+ *
168078
+ * Compilation and caching of .rego files is delegated to {@link OpaCompiler}.
168079
+ *
168080
+ * Requires:
168081
+ * - `@open-policy-agent/opa-wasm` npm package (optional dep)
168082
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
168083
+ */
168084
+ class OpaWasmEvaluator {
168085
+ policy = null;
168086
+ dataDocument = {};
168087
+ compiler = new opa_compiler_1.OpaCompiler();
168088
+ async initialize(rulesPath) {
168089
+ const paths = Array.isArray(rulesPath) ? rulesPath : [rulesPath];
168090
+ const wasmBytes = await this.compiler.resolveWasmBytes(paths);
168091
+ try {
168092
+ // Use createRequire to load the optional dep at runtime without ncc bundling it.
168093
+ // `new Function('id', 'return require(id)')` fails in ncc bundles because
168094
+ // `require` is not in the `new Function` scope. `createRequire` works correctly
168095
+ // because it creates a real Node.js require rooted at the given path.
168096
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
168097
+ const { createRequire } = __nccwpck_require__(73339);
168098
+ const runtimeRequire = createRequire(__filename);
168099
+ const opaWasm = runtimeRequire('@open-policy-agent/opa-wasm');
168100
+ const loadPolicy = opaWasm.loadPolicy || opaWasm.default?.loadPolicy;
168101
+ if (!loadPolicy) {
168102
+ throw new Error('loadPolicy not found in @open-policy-agent/opa-wasm');
168103
+ }
168104
+ this.policy = await loadPolicy(wasmBytes);
168105
+ }
168106
+ catch (err) {
168107
+ if (err?.code === 'MODULE_NOT_FOUND' || err?.code === 'ERR_MODULE_NOT_FOUND') {
168108
+ throw new Error('OPA WASM evaluator requires @open-policy-agent/opa-wasm. ' +
168109
+ 'Install it with: npm install @open-policy-agent/opa-wasm');
168110
+ }
168111
+ throw err;
168112
+ }
168113
+ }
168114
+ /**
168115
+ * Load external data from a JSON file to use as the OPA data document.
168116
+ * The loaded data will be passed to `policy.setData()` during evaluation,
168117
+ * making it available in Rego via `data.<key>`.
168118
+ */
168119
+ loadData(dataPath) {
168120
+ const resolved = path.resolve(dataPath);
168121
+ if (path.normalize(resolved).includes('..')) {
168122
+ throw new Error(`Data path contains traversal sequences: ${dataPath}`);
168123
+ }
168124
+ if (!fs.existsSync(resolved)) {
168125
+ throw new Error(`OPA data file not found: ${resolved}`);
168126
+ }
168127
+ const stat = fs.statSync(resolved);
168128
+ if (stat.size > 10 * 1024 * 1024) {
168129
+ throw new Error(`OPA data file exceeds 10MB limit: ${resolved} (${stat.size} bytes)`);
168130
+ }
168131
+ const raw = fs.readFileSync(resolved, 'utf-8');
168132
+ try {
168133
+ const parsed = JSON.parse(raw);
168134
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
168135
+ throw new Error('OPA data file must contain a JSON object (not an array or primitive)');
168136
+ }
168137
+ this.dataDocument = parsed;
168138
+ }
168139
+ catch (err) {
168140
+ if (err.message.startsWith('OPA data file must')) {
168141
+ throw err;
168142
+ }
168143
+ throw new Error(`Failed to parse OPA data file ${resolved}: ${err.message}`);
168144
+ }
168145
+ }
168146
+ async evaluate(input) {
168147
+ if (!this.policy) {
168148
+ throw new Error('OPA WASM evaluator not initialized');
168149
+ }
168150
+ this.policy.setData(this.dataDocument);
168151
+ const resultSet = this.policy.evaluate(input);
168152
+ if (Array.isArray(resultSet) && resultSet.length > 0) {
168153
+ return resultSet[0].result;
168154
+ }
168155
+ return undefined;
168156
+ }
168157
+ async shutdown() {
168158
+ if (this.policy) {
168159
+ // opa-wasm policy objects may have a close/free method for WASM cleanup
168160
+ if (typeof this.policy.close === 'function') {
168161
+ try {
168162
+ this.policy.close();
168163
+ }
168164
+ catch { }
168165
+ }
168166
+ else if (typeof this.policy.free === 'function') {
168167
+ try {
168168
+ this.policy.free();
168169
+ }
168170
+ catch { }
168171
+ }
168172
+ }
168173
+ this.policy = null;
168174
+ }
168175
+ }
168176
+ exports.OpaWasmEvaluator = OpaWasmEvaluator;
168177
+
168178
+
168179
+ /***/ }),
168180
+
168181
+ /***/ 17117:
168182
+ /***/ ((__unused_webpack_module, exports) => {
168183
+
168184
+ "use strict";
168185
+
168186
+ /**
168187
+ * Copyright (c) ProbeLabs. All rights reserved.
168188
+ * Licensed under the Elastic License 2.0; you may not use this file except
168189
+ * in compliance with the Elastic License 2.0.
168190
+ */
168191
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168192
+ exports.PolicyInputBuilder = void 0;
168193
+ /**
168194
+ * Builds OPA-compatible input documents from engine context.
168195
+ *
168196
+ * Resolves actor roles from the `policy.roles` config section by matching
168197
+ * the actor's authorAssociation and login against role definitions.
168198
+ */
168199
+ class PolicyInputBuilder {
168200
+ roles;
168201
+ actor;
168202
+ repository;
168203
+ pullRequest;
168204
+ constructor(policyConfig, actor, repository, pullRequest) {
168205
+ this.roles = policyConfig.roles || {};
168206
+ this.actor = actor;
168207
+ this.repository = repository;
168208
+ this.pullRequest = pullRequest;
168209
+ }
168210
+ /** Resolve which roles apply to the current actor. */
168211
+ resolveRoles() {
168212
+ const matched = [];
168213
+ for (const [roleName, roleConfig] of Object.entries(this.roles)) {
168214
+ let identityMatch = false;
168215
+ if (roleConfig.author_association &&
168216
+ this.actor.authorAssociation &&
168217
+ roleConfig.author_association.includes(this.actor.authorAssociation)) {
168218
+ identityMatch = true;
168219
+ }
168220
+ if (!identityMatch &&
168221
+ roleConfig.users &&
168222
+ this.actor.login &&
168223
+ roleConfig.users.includes(this.actor.login)) {
168224
+ identityMatch = true;
168225
+ }
168226
+ // Slack user ID match
168227
+ if (!identityMatch &&
168228
+ roleConfig.slack_users &&
168229
+ this.actor.slack?.userId &&
168230
+ roleConfig.slack_users.includes(this.actor.slack.userId)) {
168231
+ identityMatch = true;
168232
+ }
168233
+ // Email match (case-insensitive)
168234
+ if (!identityMatch && roleConfig.emails && this.actor.slack?.email) {
168235
+ const actorEmail = this.actor.slack.email.toLowerCase();
168236
+ if (roleConfig.emails.some(e => e.toLowerCase() === actorEmail)) {
168237
+ identityMatch = true;
168238
+ }
168239
+ }
168240
+ // Note: teams-based role resolution requires GitHub API access (read:org scope)
168241
+ // and is not yet implemented. If configured, the role will not match via teams.
168242
+ if (!identityMatch)
168243
+ continue;
168244
+ // slack_channels gate: if set, the role only applies when triggered from one of these channels
168245
+ if (roleConfig.slack_channels && roleConfig.slack_channels.length > 0) {
168246
+ if (!this.actor.slack?.channelId ||
168247
+ !roleConfig.slack_channels.includes(this.actor.slack.channelId)) {
168248
+ continue;
168249
+ }
168250
+ }
168251
+ matched.push(roleName);
168252
+ }
168253
+ return matched;
168254
+ }
168255
+ buildActor() {
168256
+ return {
168257
+ authorAssociation: this.actor.authorAssociation,
168258
+ login: this.actor.login,
168259
+ roles: this.resolveRoles(),
168260
+ isLocalMode: this.actor.isLocalMode,
168261
+ ...(this.actor.slack && { slack: this.actor.slack }),
168262
+ };
168263
+ }
168264
+ forCheckExecution(check) {
168265
+ return {
168266
+ scope: 'check.execute',
168267
+ check: {
168268
+ id: check.id,
168269
+ type: check.type,
168270
+ group: check.group,
168271
+ tags: check.tags,
168272
+ criticality: check.criticality,
168273
+ sandbox: check.sandbox,
168274
+ policy: check.policy,
168275
+ },
168276
+ actor: this.buildActor(),
168277
+ repository: this.repository,
168278
+ pullRequest: this.pullRequest,
168279
+ };
168280
+ }
168281
+ forToolInvocation(serverName, methodName, transport) {
168282
+ return {
168283
+ scope: 'tool.invoke',
168284
+ tool: { serverName, methodName, transport },
168285
+ actor: this.buildActor(),
168286
+ repository: this.repository,
168287
+ pullRequest: this.pullRequest,
168288
+ };
168289
+ }
168290
+ forCapabilityResolve(checkId, capabilities) {
168291
+ return {
168292
+ scope: 'capability.resolve',
168293
+ check: { id: checkId, type: 'ai' },
168294
+ capability: capabilities,
168295
+ actor: this.buildActor(),
168296
+ repository: this.repository,
168297
+ pullRequest: this.pullRequest,
168298
+ };
168299
+ }
168300
+ }
168301
+ exports.PolicyInputBuilder = PolicyInputBuilder;
168302
+
168303
+
168304
+ /***/ }),
168305
+
168306
+ /***/ 63737:
168307
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
168308
+
168309
+ "use strict";
168310
+
168311
+ /**
168312
+ * Copyright (c) ProbeLabs. All rights reserved.
168313
+ * Licensed under the Elastic License 2.0; you may not use this file except
168314
+ * in compliance with the Elastic License 2.0.
168315
+ */
168316
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
168317
+ if (k2 === undefined) k2 = k;
168318
+ var desc = Object.getOwnPropertyDescriptor(m, k);
168319
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
168320
+ desc = { enumerable: true, get: function() { return m[k]; } };
168321
+ }
168322
+ Object.defineProperty(o, k2, desc);
168323
+ }) : (function(o, m, k, k2) {
168324
+ if (k2 === undefined) k2 = k;
168325
+ o[k2] = m[k];
168326
+ }));
168327
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
168328
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
168329
+ }) : function(o, v) {
168330
+ o["default"] = v;
168331
+ });
168332
+ var __importStar = (this && this.__importStar) || (function () {
168333
+ var ownKeys = function(o) {
168334
+ ownKeys = Object.getOwnPropertyNames || function (o) {
168335
+ var ar = [];
168336
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
168337
+ return ar;
168338
+ };
168339
+ return ownKeys(o);
168340
+ };
168341
+ return function (mod) {
168342
+ if (mod && mod.__esModule) return mod;
168343
+ var result = {};
168344
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
168345
+ __setModuleDefault(result, mod);
168346
+ return result;
168347
+ };
168348
+ })();
168349
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168350
+ exports.KnexStoreBackend = void 0;
168351
+ /**
168352
+ * Knex-backed schedule store for PostgreSQL, MySQL, and MSSQL (Enterprise)
168353
+ *
168354
+ * Uses Knex query builder for database-agnostic SQL. Same schema as SQLite backend
168355
+ * but with real distributed locking via row-level claims (claimed_by/claimed_at/lock_token).
168356
+ */
168357
+ const fs = __importStar(__nccwpck_require__(79896));
168358
+ const path = __importStar(__nccwpck_require__(16928));
168359
+ const uuid_1 = __nccwpck_require__(31914);
168360
+ const logger_1 = __nccwpck_require__(86999);
168361
+ function toNum(val) {
168362
+ if (val === null || val === undefined)
168363
+ return undefined;
168364
+ return typeof val === 'string' ? parseInt(val, 10) : val;
168365
+ }
168366
+ function safeJsonParse(value) {
168367
+ if (!value)
168368
+ return undefined;
168369
+ try {
168370
+ return JSON.parse(value);
168371
+ }
168372
+ catch {
168373
+ return undefined;
168374
+ }
168375
+ }
168376
+ function fromTriggerRow(row) {
168377
+ return {
168378
+ id: row.id,
168379
+ creatorId: row.creator_id,
168380
+ creatorContext: row.creator_context ?? undefined,
168381
+ creatorName: row.creator_name ?? undefined,
168382
+ description: row.description ?? undefined,
168383
+ channels: safeJsonParse(row.channels),
168384
+ fromUsers: safeJsonParse(row.from_users),
168385
+ fromBots: row.from_bots === true || row.from_bots === 1,
168386
+ contains: safeJsonParse(row.contains),
168387
+ matchPattern: row.match_pattern ?? undefined,
168388
+ threads: row.threads,
168389
+ workflow: row.workflow,
168390
+ inputs: safeJsonParse(row.inputs),
168391
+ outputContext: safeJsonParse(row.output_context),
168392
+ status: row.status,
168393
+ enabled: row.enabled === true || row.enabled === 1,
168394
+ createdAt: toNum(row.created_at),
168395
+ };
168396
+ }
168397
+ function toTriggerInsertRow(trigger) {
168398
+ return {
168399
+ id: trigger.id,
168400
+ creator_id: trigger.creatorId,
168401
+ creator_context: trigger.creatorContext ?? null,
168402
+ creator_name: trigger.creatorName ?? null,
168403
+ description: trigger.description ?? null,
168404
+ channels: trigger.channels ? JSON.stringify(trigger.channels) : null,
168405
+ from_users: trigger.fromUsers ? JSON.stringify(trigger.fromUsers) : null,
168406
+ from_bots: trigger.fromBots,
168407
+ contains: trigger.contains ? JSON.stringify(trigger.contains) : null,
168408
+ match_pattern: trigger.matchPattern ?? null,
168409
+ threads: trigger.threads,
168410
+ workflow: trigger.workflow,
168411
+ inputs: trigger.inputs ? JSON.stringify(trigger.inputs) : null,
168412
+ output_context: trigger.outputContext ? JSON.stringify(trigger.outputContext) : null,
168413
+ status: trigger.status,
168414
+ enabled: trigger.enabled,
168415
+ created_at: trigger.createdAt,
168416
+ };
168417
+ }
168418
+ function fromDbRow(row) {
168419
+ return {
168420
+ id: row.id,
168421
+ creatorId: row.creator_id,
168422
+ creatorContext: row.creator_context ?? undefined,
168423
+ creatorName: row.creator_name ?? undefined,
168424
+ timezone: row.timezone,
168425
+ schedule: row.schedule_expr,
168426
+ runAt: toNum(row.run_at),
168427
+ isRecurring: row.is_recurring === true || row.is_recurring === 1,
168428
+ originalExpression: row.original_expression,
168429
+ workflow: row.workflow ?? undefined,
168430
+ workflowInputs: safeJsonParse(row.workflow_inputs),
168431
+ outputContext: safeJsonParse(row.output_context),
168432
+ status: row.status,
168433
+ createdAt: toNum(row.created_at),
168434
+ lastRunAt: toNum(row.last_run_at),
168435
+ nextRunAt: toNum(row.next_run_at),
168436
+ runCount: row.run_count,
168437
+ failureCount: row.failure_count,
168438
+ lastError: row.last_error ?? undefined,
168439
+ previousResponse: row.previous_response ?? undefined,
168440
+ };
168441
+ }
168442
+ function toInsertRow(schedule) {
168443
+ return {
168444
+ id: schedule.id,
168445
+ creator_id: schedule.creatorId,
168446
+ creator_context: schedule.creatorContext ?? null,
168447
+ creator_name: schedule.creatorName ?? null,
168448
+ timezone: schedule.timezone,
168449
+ schedule_expr: schedule.schedule,
168450
+ run_at: schedule.runAt ?? null,
168451
+ is_recurring: schedule.isRecurring,
168452
+ original_expression: schedule.originalExpression,
168453
+ workflow: schedule.workflow ?? null,
168454
+ workflow_inputs: schedule.workflowInputs ? JSON.stringify(schedule.workflowInputs) : null,
168455
+ output_context: schedule.outputContext ? JSON.stringify(schedule.outputContext) : null,
168456
+ status: schedule.status,
168457
+ created_at: schedule.createdAt,
168458
+ last_run_at: schedule.lastRunAt ?? null,
168459
+ next_run_at: schedule.nextRunAt ?? null,
168460
+ run_count: schedule.runCount,
168461
+ failure_count: schedule.failureCount,
168462
+ last_error: schedule.lastError ?? null,
168463
+ previous_response: schedule.previousResponse ?? null,
168464
+ };
168465
+ }
168466
+ /**
168467
+ * Enterprise Knex-backed store for PostgreSQL, MySQL, and MSSQL
168468
+ */
168469
+ class KnexStoreBackend {
168470
+ knex = null;
168471
+ driver;
168472
+ connection;
168473
+ constructor(driver, storageConfig, _haConfig) {
168474
+ this.driver = driver;
168475
+ this.connection = (storageConfig.connection || {});
168476
+ }
168477
+ async initialize() {
168478
+ // Load knex dynamically
168479
+ const { createRequire } = __nccwpck_require__(73339);
168480
+ const runtimeRequire = createRequire(__filename);
168481
+ let knexFactory;
168482
+ try {
168483
+ knexFactory = runtimeRequire('knex');
168484
+ }
168485
+ catch (err) {
168486
+ const code = err?.code;
168487
+ if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
168488
+ throw new Error('knex is required for PostgreSQL/MySQL/MSSQL schedule storage. ' +
168489
+ 'Install it with: npm install knex');
168490
+ }
168491
+ throw err;
168492
+ }
168493
+ const clientMap = {
168494
+ postgresql: 'pg',
168495
+ mysql: 'mysql2',
168496
+ mssql: 'tedious',
168497
+ };
168498
+ const client = clientMap[this.driver];
168499
+ // Build connection config
168500
+ let connection;
168501
+ if (this.connection.connection_string) {
168502
+ connection = this.connection.connection_string;
168503
+ }
168504
+ else if (this.driver === 'mssql') {
168505
+ connection = this.buildMssqlConnection();
168506
+ }
168507
+ else {
168508
+ connection = this.buildStandardConnection();
168509
+ }
168510
+ this.knex = knexFactory({
168511
+ client,
168512
+ connection,
168513
+ pool: {
168514
+ min: this.connection.pool?.min ?? 0,
168515
+ max: this.connection.pool?.max ?? 10,
168516
+ },
168517
+ });
168518
+ // Run schema migration
168519
+ await this.migrateSchema();
168520
+ logger_1.logger.info(`[KnexStore] Initialized (${this.driver})`);
168521
+ }
168522
+ buildStandardConnection() {
168523
+ return {
168524
+ host: this.connection.host || 'localhost',
168525
+ port: this.connection.port,
168526
+ database: this.connection.database || 'visor',
168527
+ user: this.connection.user,
168528
+ password: this.connection.password,
168529
+ ssl: this.resolveSslConfig(),
168530
+ };
168531
+ }
168532
+ buildMssqlConnection() {
168533
+ const ssl = this.connection.ssl;
168534
+ const sslEnabled = ssl === true || (typeof ssl === 'object' && ssl.enabled !== false);
168535
+ return {
168536
+ server: this.connection.host || 'localhost',
168537
+ port: this.connection.port,
168538
+ database: this.connection.database || 'visor',
168539
+ user: this.connection.user,
168540
+ password: this.connection.password,
168541
+ options: {
168542
+ encrypt: sslEnabled,
168543
+ trustServerCertificate: typeof ssl === 'object' ? ssl.reject_unauthorized === false : !sslEnabled,
168544
+ },
168545
+ };
168546
+ }
168547
+ resolveSslConfig() {
168548
+ const ssl = this.connection.ssl;
168549
+ if (ssl === false || ssl === undefined)
168550
+ return false;
168551
+ if (ssl === true)
168552
+ return { rejectUnauthorized: true };
168553
+ // Object config
168554
+ if (ssl.enabled === false)
168555
+ return false;
168556
+ const result = {
168557
+ rejectUnauthorized: ssl.reject_unauthorized !== false,
168558
+ };
168559
+ if (ssl.ca) {
168560
+ const caPath = this.validateSslPath(ssl.ca, 'CA certificate');
168561
+ result.ca = fs.readFileSync(caPath, 'utf8');
168562
+ }
168563
+ if (ssl.cert) {
168564
+ const certPath = this.validateSslPath(ssl.cert, 'client certificate');
168565
+ result.cert = fs.readFileSync(certPath, 'utf8');
168566
+ }
168567
+ if (ssl.key) {
168568
+ const keyPath = this.validateSslPath(ssl.key, 'client key');
168569
+ result.key = fs.readFileSync(keyPath, 'utf8');
168570
+ }
168571
+ return result;
168572
+ }
168573
+ validateSslPath(filePath, label) {
168574
+ const resolved = path.resolve(filePath);
168575
+ if (resolved !== path.normalize(resolved)) {
168576
+ throw new Error(`SSL ${label} path contains invalid sequences: ${filePath}`);
168577
+ }
168578
+ if (!fs.existsSync(resolved)) {
168579
+ throw new Error(`SSL ${label} not found: ${filePath}`);
168580
+ }
168581
+ return resolved;
168582
+ }
168583
+ async shutdown() {
168584
+ if (this.knex) {
168585
+ await this.knex.destroy();
168586
+ this.knex = null;
168587
+ }
168588
+ }
168589
+ async migrateSchema() {
168590
+ const knex = this.getKnex();
168591
+ const exists = await knex.schema.hasTable('schedules');
168592
+ if (!exists) {
168593
+ await knex.schema.createTable('schedules', table => {
168594
+ table.string('id', 36).primary();
168595
+ table.string('creator_id', 255).notNullable().index();
168596
+ table.string('creator_context', 255);
168597
+ table.string('creator_name', 255);
168598
+ table.string('timezone', 64).notNullable().defaultTo('UTC');
168599
+ table.string('schedule_expr', 255);
168600
+ table.bigInteger('run_at');
168601
+ table.boolean('is_recurring').notNullable();
168602
+ table.text('original_expression');
168603
+ table.string('workflow', 255);
168604
+ table.text('workflow_inputs');
168605
+ table.text('output_context');
168606
+ table.string('status', 20).notNullable().index();
168607
+ table.bigInteger('created_at').notNullable();
168608
+ table.bigInteger('last_run_at');
168609
+ table.bigInteger('next_run_at');
168610
+ table.integer('run_count').notNullable().defaultTo(0);
168611
+ table.integer('failure_count').notNullable().defaultTo(0);
168612
+ table.text('last_error');
168613
+ table.text('previous_response');
168614
+ table.index(['status', 'next_run_at']);
168615
+ });
168616
+ }
168617
+ // Create message_triggers table
168618
+ const triggersExist = await knex.schema.hasTable('message_triggers');
168619
+ if (!triggersExist) {
168620
+ await knex.schema.createTable('message_triggers', table => {
168621
+ table.string('id', 36).primary();
168622
+ table.string('creator_id', 255).notNullable().index();
168623
+ table.string('creator_context', 255);
168624
+ table.string('creator_name', 255);
168625
+ table.text('description');
168626
+ table.text('channels'); // JSON array
168627
+ table.text('from_users'); // JSON array
168628
+ table.boolean('from_bots').notNullable().defaultTo(false);
168629
+ table.text('contains'); // JSON array
168630
+ table.text('match_pattern');
168631
+ table.string('threads', 20).notNullable().defaultTo('any');
168632
+ table.string('workflow', 255).notNullable();
168633
+ table.text('inputs'); // JSON
168634
+ table.text('output_context'); // JSON
168635
+ table.string('status', 20).notNullable().defaultTo('active').index();
168636
+ table.boolean('enabled').notNullable().defaultTo(true);
168637
+ table.bigInteger('created_at').notNullable();
168638
+ });
168639
+ }
168640
+ // Create scheduler_locks table for distributed locking
168641
+ const locksExist = await knex.schema.hasTable('scheduler_locks');
168642
+ if (!locksExist) {
168643
+ await knex.schema.createTable('scheduler_locks', table => {
168644
+ table.string('lock_id', 255).primary();
168645
+ table.string('node_id', 255).notNullable();
168646
+ table.string('lock_token', 36).notNullable();
168647
+ table.bigInteger('acquired_at').notNullable();
168648
+ table.bigInteger('expires_at').notNullable();
168649
+ });
168650
+ }
168651
+ }
168652
+ getKnex() {
168653
+ if (!this.knex) {
168654
+ throw new Error('[KnexStore] Not initialized. Call initialize() first.');
168655
+ }
168656
+ return this.knex;
168657
+ }
168658
+ // --- CRUD ---
168659
+ async create(schedule) {
168660
+ const knex = this.getKnex();
168661
+ const newSchedule = {
168662
+ ...schedule,
168663
+ id: (0, uuid_1.v4)(),
168664
+ createdAt: Date.now(),
168665
+ runCount: 0,
168666
+ failureCount: 0,
168667
+ status: 'active',
168668
+ };
168669
+ await knex('schedules').insert(toInsertRow(newSchedule));
168670
+ logger_1.logger.info(`[KnexStore] Created schedule ${newSchedule.id} for user ${newSchedule.creatorId}`);
168671
+ return newSchedule;
168672
+ }
168673
+ async importSchedule(schedule) {
168674
+ const knex = this.getKnex();
168675
+ const existing = await knex('schedules').where('id', schedule.id).first();
168676
+ if (existing)
168677
+ return; // Already imported (idempotent)
168678
+ await knex('schedules').insert(toInsertRow(schedule));
168679
+ }
168680
+ async get(id) {
168681
+ const knex = this.getKnex();
168682
+ const row = await knex('schedules').where('id', id).first();
168683
+ return row ? fromDbRow(row) : undefined;
168684
+ }
168685
+ async update(id, patch) {
168686
+ const knex = this.getKnex();
168687
+ const existing = await knex('schedules').where('id', id).first();
168688
+ if (!existing)
168689
+ return undefined;
168690
+ const current = fromDbRow(existing);
168691
+ const updated = { ...current, ...patch, id: current.id };
168692
+ const row = toInsertRow(updated);
168693
+ // Remove id from update (PK cannot change)
168694
+ delete row.id;
168695
+ await knex('schedules').where('id', id).update(row);
168696
+ return updated;
168697
+ }
168698
+ async delete(id) {
168699
+ const knex = this.getKnex();
168700
+ const deleted = await knex('schedules').where('id', id).del();
168701
+ if (deleted > 0) {
168702
+ logger_1.logger.info(`[KnexStore] Deleted schedule ${id}`);
168703
+ return true;
168704
+ }
168705
+ return false;
168706
+ }
168707
+ // --- Queries ---
168708
+ async getByCreator(creatorId) {
168709
+ const knex = this.getKnex();
168710
+ const rows = await knex('schedules').where('creator_id', creatorId);
168711
+ return rows.map((r) => fromDbRow(r));
168712
+ }
168713
+ async getActiveSchedules() {
168714
+ const knex = this.getKnex();
168715
+ const rows = await knex('schedules').where('status', 'active');
168716
+ return rows.map((r) => fromDbRow(r));
168717
+ }
168718
+ async getDueSchedules(now) {
168719
+ const ts = now ?? Date.now();
168720
+ const knex = this.getKnex();
168721
+ // MSSQL uses 1/0 for booleans
168722
+ const bFalse = this.driver === 'mssql' ? 0 : false;
168723
+ const bTrue = this.driver === 'mssql' ? 1 : true;
168724
+ const rows = await knex('schedules')
168725
+ .where('status', 'active')
168726
+ .andWhere(function () {
168727
+ this.where(function () {
168728
+ this.where('is_recurring', bFalse)
168729
+ .whereNotNull('run_at')
168730
+ .where('run_at', '<=', ts);
168731
+ }).orWhere(function () {
168732
+ this.where('is_recurring', bTrue)
168733
+ .whereNotNull('next_run_at')
168734
+ .where('next_run_at', '<=', ts);
168735
+ });
168736
+ });
168737
+ return rows.map((r) => fromDbRow(r));
168738
+ }
168739
+ async findByWorkflow(creatorId, workflowName) {
168740
+ const knex = this.getKnex();
168741
+ const escaped = workflowName.toLowerCase().replace(/[%_\\]/g, '\\$&');
168742
+ const pattern = `%${escaped}%`;
168743
+ const rows = await knex('schedules')
168744
+ .where('creator_id', creatorId)
168745
+ .where('status', 'active')
168746
+ .whereRaw("LOWER(workflow) LIKE ? ESCAPE '\\'", [pattern]);
168747
+ return rows.map((r) => fromDbRow(r));
168748
+ }
168749
+ async getAll() {
168750
+ const knex = this.getKnex();
168751
+ const rows = await knex('schedules');
168752
+ return rows.map((r) => fromDbRow(r));
168753
+ }
168754
+ async getStats() {
168755
+ const knex = this.getKnex();
168756
+ // MSSQL uses 1/0 for booleans; PostgreSQL/MySQL accept both true/1
168757
+ const boolTrue = this.driver === 'mssql' ? '1' : 'true';
168758
+ const boolFalse = this.driver === 'mssql' ? '0' : 'false';
168759
+ const result = await knex('schedules')
168760
+ .select(knex.raw('COUNT(*) as total'), knex.raw("SUM(CASE WHEN status = 'active' THEN 1 ELSE 0 END) as active"), knex.raw("SUM(CASE WHEN status = 'paused' THEN 1 ELSE 0 END) as paused"), knex.raw("SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed"), knex.raw("SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) as failed"), knex.raw(`SUM(CASE WHEN is_recurring = ${boolTrue} THEN 1 ELSE 0 END) as recurring`), knex.raw(`SUM(CASE WHEN is_recurring = ${boolFalse} THEN 1 ELSE 0 END) as one_time`))
168761
+ .first();
168762
+ return {
168763
+ total: Number(result.total) || 0,
168764
+ active: Number(result.active) || 0,
168765
+ paused: Number(result.paused) || 0,
168766
+ completed: Number(result.completed) || 0,
168767
+ failed: Number(result.failed) || 0,
168768
+ recurring: Number(result.recurring) || 0,
168769
+ oneTime: Number(result.one_time) || 0,
168770
+ };
168771
+ }
168772
+ async validateLimits(creatorId, isRecurring, limits) {
168773
+ const knex = this.getKnex();
168774
+ if (limits.maxGlobal) {
168775
+ const result = await knex('schedules').count('* as cnt').first();
168776
+ if (Number(result?.cnt) >= limits.maxGlobal) {
168777
+ throw new Error(`Global schedule limit reached (${limits.maxGlobal})`);
168778
+ }
168779
+ }
168780
+ if (limits.maxPerUser) {
168781
+ const result = await knex('schedules')
168782
+ .where('creator_id', creatorId)
168783
+ .count('* as cnt')
168784
+ .first();
168785
+ if (Number(result?.cnt) >= limits.maxPerUser) {
168786
+ throw new Error(`You have reached the maximum number of schedules (${limits.maxPerUser})`);
168787
+ }
168788
+ }
168789
+ if (isRecurring && limits.maxRecurringPerUser) {
168790
+ const bTrue = this.driver === 'mssql' ? 1 : true;
168791
+ const result = await knex('schedules')
168792
+ .where('creator_id', creatorId)
168793
+ .where('is_recurring', bTrue)
168794
+ .count('* as cnt')
168795
+ .first();
168796
+ if (Number(result?.cnt) >= limits.maxRecurringPerUser) {
168797
+ throw new Error(`You have reached the maximum number of recurring schedules (${limits.maxRecurringPerUser})`);
168798
+ }
168799
+ }
168800
+ }
168801
+ // --- HA Distributed Locking (via scheduler_locks table) ---
168802
+ async tryAcquireLock(lockId, nodeId, ttlSeconds) {
168803
+ const knex = this.getKnex();
168804
+ const now = Date.now();
168805
+ const expiresAt = now + ttlSeconds * 1000;
168806
+ const token = (0, uuid_1.v4)();
168807
+ // Step 1: Try to claim an existing expired lock
168808
+ const updated = await knex('scheduler_locks')
168809
+ .where('lock_id', lockId)
168810
+ .where('expires_at', '<', now)
168811
+ .update({
168812
+ node_id: nodeId,
168813
+ lock_token: token,
168814
+ acquired_at: now,
168815
+ expires_at: expiresAt,
168816
+ });
168817
+ if (updated > 0)
168818
+ return token;
168819
+ // Step 2: Try to INSERT a new lock row
168820
+ try {
168821
+ await knex('scheduler_locks').insert({
168822
+ lock_id: lockId,
168823
+ node_id: nodeId,
168824
+ lock_token: token,
168825
+ acquired_at: now,
168826
+ expires_at: expiresAt,
168827
+ });
168828
+ return token;
168829
+ }
168830
+ catch {
168831
+ // Unique constraint violation — another node holds the lock
168832
+ return null;
168833
+ }
168834
+ }
168835
+ async releaseLock(lockId, lockToken) {
168836
+ const knex = this.getKnex();
168837
+ await knex('scheduler_locks').where('lock_id', lockId).where('lock_token', lockToken).del();
168838
+ }
168839
+ async renewLock(lockId, lockToken, ttlSeconds) {
168840
+ const knex = this.getKnex();
168841
+ const now = Date.now();
168842
+ const expiresAt = now + ttlSeconds * 1000;
168843
+ const updated = await knex('scheduler_locks')
168844
+ .where('lock_id', lockId)
168845
+ .where('lock_token', lockToken)
168846
+ .update({ acquired_at: now, expires_at: expiresAt });
168847
+ return updated > 0;
168848
+ }
168849
+ async flush() {
168850
+ // No-op for server-based backends
168851
+ }
168852
+ // --- Message Trigger CRUD ---
168853
+ async createTrigger(trigger) {
168854
+ const knex = this.getKnex();
168855
+ const newTrigger = {
168856
+ ...trigger,
168857
+ id: (0, uuid_1.v4)(),
168858
+ createdAt: Date.now(),
168859
+ };
168860
+ await knex('message_triggers').insert(toTriggerInsertRow(newTrigger));
168861
+ logger_1.logger.info(`[KnexStore] Created trigger ${newTrigger.id} for user ${newTrigger.creatorId}`);
168862
+ return newTrigger;
168863
+ }
168864
+ async getTrigger(id) {
168865
+ const knex = this.getKnex();
168866
+ const row = await knex('message_triggers').where('id', id).first();
168867
+ return row ? fromTriggerRow(row) : undefined;
168868
+ }
168869
+ async updateTrigger(id, patch) {
168870
+ const knex = this.getKnex();
168871
+ const existing = await knex('message_triggers').where('id', id).first();
168872
+ if (!existing)
168873
+ return undefined;
168874
+ const current = fromTriggerRow(existing);
168875
+ const updated = {
168876
+ ...current,
168877
+ ...patch,
168878
+ id: current.id,
168879
+ createdAt: current.createdAt,
168880
+ };
168881
+ const row = toTriggerInsertRow(updated);
168882
+ delete row.id;
168883
+ await knex('message_triggers').where('id', id).update(row);
168884
+ return updated;
168885
+ }
168886
+ async deleteTrigger(id) {
168887
+ const knex = this.getKnex();
168888
+ const deleted = await knex('message_triggers').where('id', id).del();
168889
+ if (deleted > 0) {
168890
+ logger_1.logger.info(`[KnexStore] Deleted trigger ${id}`);
168891
+ return true;
168892
+ }
168893
+ return false;
168894
+ }
168895
+ async getTriggersByCreator(creatorId) {
168896
+ const knex = this.getKnex();
168897
+ const rows = await knex('message_triggers').where('creator_id', creatorId);
168898
+ return rows.map((r) => fromTriggerRow(r));
168899
+ }
168900
+ async getActiveTriggers() {
168901
+ const knex = this.getKnex();
168902
+ const rows = await knex('message_triggers')
168903
+ .where('status', 'active')
168904
+ .where('enabled', this.driver === 'mssql' ? 1 : true);
168905
+ return rows.map((r) => fromTriggerRow(r));
168906
+ }
168907
+ }
168908
+ exports.KnexStoreBackend = KnexStoreBackend;
168909
+
168910
+
167100
168911
  /***/ }),
167101
168912
 
167102
168913
  /***/ 83864:
@@ -170207,7 +172018,7 @@ exports.configSchema = {
170207
172018
  description: 'Arguments/inputs for the workflow',
170208
172019
  },
170209
172020
  overrides: {
170210
- $ref: '#/definitions/Record%3Cstring%2CPartial%3Cinterface-src_types_config.ts-13519-28113-src_types_config.ts-0-55265%3E%3E',
172021
+ $ref: '#/definitions/Record%3Cstring%2CPartial%3Cinterface-src_types_config.ts-13766-28360-src_types_config.ts-0-55512%3E%3E',
170211
172022
  description: 'Override specific step configurations in the workflow',
170212
172023
  },
170213
172024
  output_mapping: {
@@ -170223,7 +172034,7 @@ exports.configSchema = {
170223
172034
  description: 'Config file path - alternative to workflow ID (loads a Visor config file as workflow)',
170224
172035
  },
170225
172036
  workflow_overrides: {
170226
- $ref: '#/definitions/Record%3Cstring%2CPartial%3Cinterface-src_types_config.ts-13519-28113-src_types_config.ts-0-55265%3E%3E',
172037
+ $ref: '#/definitions/Record%3Cstring%2CPartial%3Cinterface-src_types_config.ts-13766-28360-src_types_config.ts-0-55512%3E%3E',
170227
172038
  description: 'Alias for overrides - workflow step overrides (backward compatibility)',
170228
172039
  },
170229
172040
  ref: {
@@ -170501,6 +172312,14 @@ exports.configSchema = {
170501
172312
  type: 'boolean',
170502
172313
  description: 'Enable bash command execution (shorthand for bashConfig.enabled)',
170503
172314
  },
172315
+ search_delegate_provider: {
172316
+ type: 'string',
172317
+ description: "Override provider for search delegate sub-agents (e.g., 'google' for cheaper search)",
172318
+ },
172319
+ search_delegate_model: {
172320
+ type: 'string',
172321
+ description: "Override model for search delegate sub-agents (e.g., 'gemini-2.0-flash')",
172322
+ },
170504
172323
  bashConfig: {
170505
172324
  $ref: '#/definitions/BashConfig',
170506
172325
  description: 'Advanced bash command execution configuration',
@@ -170912,7 +172731,7 @@ exports.configSchema = {
170912
172731
  description: 'Custom output name (defaults to workflow name)',
170913
172732
  },
170914
172733
  overrides: {
170915
- $ref: '#/definitions/Record%3Cstring%2CPartial%3Cinterface-src_types_config.ts-13519-28113-src_types_config.ts-0-55265%3E%3E',
172734
+ $ref: '#/definitions/Record%3Cstring%2CPartial%3Cinterface-src_types_config.ts-13766-28360-src_types_config.ts-0-55512%3E%3E',
170916
172735
  description: 'Step overrides',
170917
172736
  },
170918
172737
  output_mapping: {
@@ -170927,13 +172746,13 @@ exports.configSchema = {
170927
172746
  '^x-': {},
170928
172747
  },
170929
172748
  },
170930
- 'Record<string,Partial<interface-src_types_config.ts-13519-28113-src_types_config.ts-0-55265>>': {
172749
+ 'Record<string,Partial<interface-src_types_config.ts-13766-28360-src_types_config.ts-0-55512>>': {
170931
172750
  type: 'object',
170932
172751
  additionalProperties: {
170933
- $ref: '#/definitions/Partial%3Cinterface-src_types_config.ts-13519-28113-src_types_config.ts-0-55265%3E',
172752
+ $ref: '#/definitions/Partial%3Cinterface-src_types_config.ts-13766-28360-src_types_config.ts-0-55512%3E',
170934
172753
  },
170935
172754
  },
170936
- 'Partial<interface-src_types_config.ts-13519-28113-src_types_config.ts-0-55265>': {
172755
+ 'Partial<interface-src_types_config.ts-13766-28360-src_types_config.ts-0-55512>': {
170937
172756
  type: 'object',
170938
172757
  additionalProperties: false,
170939
172758
  },
@@ -178102,6 +179921,35 @@ class OutputFormatters {
178102
179921
  exports.OutputFormatters = OutputFormatters;
178103
179922
 
178104
179923
 
179924
+ /***/ }),
179925
+
179926
+ /***/ 93866:
179927
+ /***/ ((__unused_webpack_module, exports) => {
179928
+
179929
+ "use strict";
179930
+
179931
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
179932
+ exports.DefaultPolicyEngine = void 0;
179933
+ /**
179934
+ * Default (no-op) policy engine — always allows everything.
179935
+ * Used when no enterprise license is present or policy is disabled.
179936
+ */
179937
+ class DefaultPolicyEngine {
179938
+ async initialize(_config) { }
179939
+ async evaluateCheckExecution(_checkId, _checkConfig) {
179940
+ return { allowed: true };
179941
+ }
179942
+ async evaluateToolInvocation(_serverName, _methodName, _transport) {
179943
+ return { allowed: true };
179944
+ }
179945
+ async evaluateCapabilities(_checkId, _capabilities) {
179946
+ return { allowed: true };
179947
+ }
179948
+ async shutdown() { }
179949
+ }
179950
+ exports.DefaultPolicyEngine = DefaultPolicyEngine;
179951
+
179952
+
178105
179953
  /***/ }),
178106
179954
 
178107
179955
  /***/ 96611:
@@ -179521,6 +181369,12 @@ class AICheckProvider extends check_provider_interface_1.CheckProvider {
179521
181369
  if (aiAny.bashConfig !== undefined) {
179522
181370
  aiConfig.bashConfig = aiAny.bashConfig;
179523
181371
  }
181372
+ if (aiAny.search_delegate_provider !== undefined) {
181373
+ aiConfig.search_delegate_provider = aiAny.search_delegate_provider;
181374
+ }
181375
+ if (aiAny.search_delegate_model !== undefined) {
181376
+ aiConfig.search_delegate_model = aiAny.search_delegate_model;
181377
+ }
179524
181378
  if (aiAny.completion_prompt !== undefined) {
179525
181379
  aiConfig.completionPrompt = aiAny.completion_prompt;
179526
181380
  }
@@ -180700,6 +182554,8 @@ class AICheckProvider extends check_provider_interface_1.CheckProvider {
180700
182554
  'ai.disableTools',
180701
182555
  'ai.allowBash',
180702
182556
  'ai.bashConfig',
182557
+ 'ai.search_delegate_provider',
182558
+ 'ai.search_delegate_model',
180703
182559
  'ai_model',
180704
182560
  'ai_provider',
180705
182561
  'ai_mcp_servers',
@@ -200160,7 +202016,7 @@ class StateMachineExecutionEngine {
200160
202016
  try {
200161
202017
  logger_1.logger.debug(`[PolicyEngine] Loading enterprise policy engine (engine=${configWithTagFilter.policy.engine})`);
200162
202018
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
200163
- const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(7065)));
202019
+ const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(87068)));
200164
202020
  context.policyEngine = await loadEnterprisePolicyEngine(configWithTagFilter.policy);
200165
202021
  logger_1.logger.debug(`[PolicyEngine] Initialized: ${context.policyEngine?.constructor?.name || 'unknown'}`);
200166
202022
  }
@@ -210434,7 +212290,7 @@ async function initTelemetry(opts = {}) {
210434
212290
  const path = __nccwpck_require__(16928);
210435
212291
  const outDir = opts.file?.dir ||
210436
212292
  process.env.VISOR_TRACE_DIR ||
210437
- __nccwpck_require__.ab + "traces";
212293
+ path.join(process.cwd(), 'output', 'traces');
210438
212294
  fs.mkdirSync(outDir, { recursive: true });
210439
212295
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
210440
212296
  process.env.VISOR_FALLBACK_TRACE_FILE = path.join(outDir, `run-${ts}.ndjson`);
@@ -210639,7 +212495,7 @@ async function shutdownTelemetry() {
210639
212495
  if (process.env.VISOR_TRACE_REPORT === 'true') {
210640
212496
  const fs = __nccwpck_require__(79896);
210641
212497
  const path = __nccwpck_require__(16928);
210642
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
212498
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
210643
212499
  if (!fs.existsSync(outDir))
210644
212500
  fs.mkdirSync(outDir, { recursive: true });
210645
212501
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
@@ -211138,7 +212994,7 @@ function __getOrCreateNdjsonPath() {
211138
212994
  fs.mkdirSync(dir, { recursive: true });
211139
212995
  return __ndjsonPath;
211140
212996
  }
211141
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
212997
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
211142
212998
  if (!fs.existsSync(outDir))
211143
212999
  fs.mkdirSync(outDir, { recursive: true });
211144
213000
  if (!__ndjsonPath) {
@@ -225099,22 +226955,6 @@ class WorkflowRegistry {
225099
226955
  exports.WorkflowRegistry = WorkflowRegistry;
225100
226956
 
225101
226957
 
225102
- /***/ }),
225103
-
225104
- /***/ 7065:
225105
- /***/ ((module) => {
225106
-
225107
- module.exports = eval("require")("./enterprise/loader");
225108
-
225109
-
225110
- /***/ }),
225111
-
225112
- /***/ 71370:
225113
- /***/ ((module) => {
225114
-
225115
- module.exports = eval("require")("./enterprise/policy/policy-input-builder");
225116
-
225117
-
225118
226958
  /***/ }),
225119
226959
 
225120
226960
  /***/ 18327:
@@ -266818,7 +268658,7 @@ var require_package2 = __commonJS({
266818
268658
  module2.exports = {
266819
268659
  name: "@aws-sdk/client-bedrock-runtime",
266820
268660
  description: "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native",
266821
- version: "3.1002.0",
268661
+ version: "3.1003.0",
266822
268662
  scripts: {
266823
268663
  build: "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
266824
268664
  "build:cjs": "node ../../scripts/compilation/inline client-bedrock-runtime",
@@ -266830,6 +268670,10 @@ var require_package2 = __commonJS({
266830
268670
  "extract:docs": "api-extractor run --local",
266831
268671
  "generate:client": "node ../../scripts/generate-clients/single-service --solo bedrock-runtime",
266832
268672
  test: "yarn g:vitest run --passWithNoTests",
268673
+ "test:browser": "yarn g:vitest run -c vitest.config.browser.e2e.mts",
268674
+ "test:browser:watch": "yarn g:vitest watch -c vitest.config.browser.e2e.mts",
268675
+ "test:e2e": "yarn g:vitest run -c vitest.config.e2e.mts",
268676
+ "test:e2e:watch": "yarn g:vitest watch -c vitest.config.e2e.mts",
266833
268677
  "test:index": "tsc --noEmit ./test/index-types.ts && node ./test/index-objects.spec.mjs",
266834
268678
  "test:integration": "yarn g:vitest run --passWithNoTests -c vitest.config.integ.mts",
266835
268679
  "test:integration:watch": "yarn g:vitest run --passWithNoTests -c vitest.config.integ.mts",
@@ -266842,54 +268686,54 @@ var require_package2 = __commonJS({
266842
268686
  dependencies: {
266843
268687
  "@aws-crypto/sha256-browser": "5.2.0",
266844
268688
  "@aws-crypto/sha256-js": "5.2.0",
266845
- "@aws-sdk/core": "^3.973.17",
266846
- "@aws-sdk/credential-provider-node": "^3.972.16",
266847
- "@aws-sdk/eventstream-handler-node": "^3.972.9",
266848
- "@aws-sdk/middleware-eventstream": "^3.972.6",
266849
- "@aws-sdk/middleware-host-header": "^3.972.6",
266850
- "@aws-sdk/middleware-logger": "^3.972.6",
266851
- "@aws-sdk/middleware-recursion-detection": "^3.972.6",
266852
- "@aws-sdk/middleware-user-agent": "^3.972.17",
266853
- "@aws-sdk/middleware-websocket": "^3.972.11",
266854
- "@aws-sdk/region-config-resolver": "^3.972.6",
266855
- "@aws-sdk/token-providers": "3.1002.0",
266856
- "@aws-sdk/types": "^3.973.4",
266857
- "@aws-sdk/util-endpoints": "^3.996.3",
266858
- "@aws-sdk/util-user-agent-browser": "^3.972.6",
266859
- "@aws-sdk/util-user-agent-node": "^3.973.2",
266860
- "@smithy/config-resolver": "^4.4.9",
266861
- "@smithy/core": "^3.23.7",
266862
- "@smithy/eventstream-serde-browser": "^4.2.10",
266863
- "@smithy/eventstream-serde-config-resolver": "^4.3.10",
266864
- "@smithy/eventstream-serde-node": "^4.2.10",
266865
- "@smithy/fetch-http-handler": "^5.3.12",
266866
- "@smithy/hash-node": "^4.2.10",
266867
- "@smithy/invalid-dependency": "^4.2.10",
266868
- "@smithy/middleware-content-length": "^4.2.10",
266869
- "@smithy/middleware-endpoint": "^4.4.21",
266870
- "@smithy/middleware-retry": "^4.4.38",
266871
- "@smithy/middleware-serde": "^4.2.11",
266872
- "@smithy/middleware-stack": "^4.2.10",
266873
- "@smithy/node-config-provider": "^4.3.10",
266874
- "@smithy/node-http-handler": "^4.4.13",
266875
- "@smithy/protocol-http": "^5.3.10",
266876
- "@smithy/smithy-client": "^4.12.1",
268689
+ "@aws-sdk/core": "^3.973.18",
268690
+ "@aws-sdk/credential-provider-node": "^3.972.17",
268691
+ "@aws-sdk/eventstream-handler-node": "^3.972.10",
268692
+ "@aws-sdk/middleware-eventstream": "^3.972.7",
268693
+ "@aws-sdk/middleware-host-header": "^3.972.7",
268694
+ "@aws-sdk/middleware-logger": "^3.972.7",
268695
+ "@aws-sdk/middleware-recursion-detection": "^3.972.7",
268696
+ "@aws-sdk/middleware-user-agent": "^3.972.18",
268697
+ "@aws-sdk/middleware-websocket": "^3.972.12",
268698
+ "@aws-sdk/region-config-resolver": "^3.972.7",
268699
+ "@aws-sdk/token-providers": "3.1003.0",
268700
+ "@aws-sdk/types": "^3.973.5",
268701
+ "@aws-sdk/util-endpoints": "^3.996.4",
268702
+ "@aws-sdk/util-user-agent-browser": "^3.972.7",
268703
+ "@aws-sdk/util-user-agent-node": "^3.973.3",
268704
+ "@smithy/config-resolver": "^4.4.10",
268705
+ "@smithy/core": "^3.23.8",
268706
+ "@smithy/eventstream-serde-browser": "^4.2.11",
268707
+ "@smithy/eventstream-serde-config-resolver": "^4.3.11",
268708
+ "@smithy/eventstream-serde-node": "^4.2.11",
268709
+ "@smithy/fetch-http-handler": "^5.3.13",
268710
+ "@smithy/hash-node": "^4.2.11",
268711
+ "@smithy/invalid-dependency": "^4.2.11",
268712
+ "@smithy/middleware-content-length": "^4.2.11",
268713
+ "@smithy/middleware-endpoint": "^4.4.22",
268714
+ "@smithy/middleware-retry": "^4.4.39",
268715
+ "@smithy/middleware-serde": "^4.2.12",
268716
+ "@smithy/middleware-stack": "^4.2.11",
268717
+ "@smithy/node-config-provider": "^4.3.11",
268718
+ "@smithy/node-http-handler": "^4.4.14",
268719
+ "@smithy/protocol-http": "^5.3.11",
268720
+ "@smithy/smithy-client": "^4.12.2",
266877
268721
  "@smithy/types": "^4.13.0",
266878
- "@smithy/url-parser": "^4.2.10",
266879
- "@smithy/util-base64": "^4.3.1",
266880
- "@smithy/util-body-length-browser": "^4.2.1",
266881
- "@smithy/util-body-length-node": "^4.2.2",
266882
- "@smithy/util-defaults-mode-browser": "^4.3.37",
266883
- "@smithy/util-defaults-mode-node": "^4.2.40",
266884
- "@smithy/util-endpoints": "^3.3.1",
266885
- "@smithy/util-middleware": "^4.2.10",
266886
- "@smithy/util-retry": "^4.2.10",
266887
- "@smithy/util-stream": "^4.5.16",
266888
- "@smithy/util-utf8": "^4.2.1",
268722
+ "@smithy/url-parser": "^4.2.11",
268723
+ "@smithy/util-base64": "^4.3.2",
268724
+ "@smithy/util-body-length-browser": "^4.2.2",
268725
+ "@smithy/util-body-length-node": "^4.2.3",
268726
+ "@smithy/util-defaults-mode-browser": "^4.3.38",
268727
+ "@smithy/util-defaults-mode-node": "^4.2.41",
268728
+ "@smithy/util-endpoints": "^3.3.2",
268729
+ "@smithy/util-middleware": "^4.2.11",
268730
+ "@smithy/util-retry": "^4.2.11",
268731
+ "@smithy/util-stream": "^4.5.17",
268732
+ "@smithy/util-utf8": "^4.2.2",
266889
268733
  tslib: "^2.6.2"
266890
268734
  },
266891
268735
  devDependencies: {
266892
- "@smithy/snapshot-testing": "^1.0.8",
268736
+ "@smithy/snapshot-testing": "^1.0.9",
266893
268737
  "@tsconfig/node20": "20.1.8",
266894
268738
  "@types/node": "^20.14.8",
266895
268739
  concurrently: "7.0.0",
@@ -266902,7 +268746,7 @@ var require_package2 = __commonJS({
266902
268746
  node: ">=20.0.0"
266903
268747
  },
266904
268748
  typesVersions: {
266905
- "<4.0": {
268749
+ "<4.5": {
266906
268750
  "dist-types/*": [
266907
268751
  "dist-types/ts3.4/*"
266908
268752
  ]
@@ -267605,7 +269449,7 @@ var init_package = __esm({
267605
269449
  "node_modules/@aws-sdk/nested-clients/package.json"() {
267606
269450
  package_default = {
267607
269451
  name: "@aws-sdk/nested-clients",
267608
- version: "3.996.5",
269452
+ version: "3.996.6",
267609
269453
  description: "Nested clients for AWS SDK packages.",
267610
269454
  main: "./dist-cjs/index.js",
267611
269455
  module: "./dist-es/index.js",
@@ -267634,41 +269478,41 @@ var init_package = __esm({
267634
269478
  dependencies: {
267635
269479
  "@aws-crypto/sha256-browser": "5.2.0",
267636
269480
  "@aws-crypto/sha256-js": "5.2.0",
267637
- "@aws-sdk/core": "^3.973.17",
267638
- "@aws-sdk/middleware-host-header": "^3.972.6",
267639
- "@aws-sdk/middleware-logger": "^3.972.6",
267640
- "@aws-sdk/middleware-recursion-detection": "^3.972.6",
267641
- "@aws-sdk/middleware-user-agent": "^3.972.17",
267642
- "@aws-sdk/region-config-resolver": "^3.972.6",
267643
- "@aws-sdk/types": "^3.973.4",
267644
- "@aws-sdk/util-endpoints": "^3.996.3",
267645
- "@aws-sdk/util-user-agent-browser": "^3.972.6",
267646
- "@aws-sdk/util-user-agent-node": "^3.973.2",
267647
- "@smithy/config-resolver": "^4.4.9",
267648
- "@smithy/core": "^3.23.7",
267649
- "@smithy/fetch-http-handler": "^5.3.12",
267650
- "@smithy/hash-node": "^4.2.10",
267651
- "@smithy/invalid-dependency": "^4.2.10",
267652
- "@smithy/middleware-content-length": "^4.2.10",
267653
- "@smithy/middleware-endpoint": "^4.4.21",
267654
- "@smithy/middleware-retry": "^4.4.38",
267655
- "@smithy/middleware-serde": "^4.2.11",
267656
- "@smithy/middleware-stack": "^4.2.10",
267657
- "@smithy/node-config-provider": "^4.3.10",
267658
- "@smithy/node-http-handler": "^4.4.13",
267659
- "@smithy/protocol-http": "^5.3.10",
267660
- "@smithy/smithy-client": "^4.12.1",
269481
+ "@aws-sdk/core": "^3.973.18",
269482
+ "@aws-sdk/middleware-host-header": "^3.972.7",
269483
+ "@aws-sdk/middleware-logger": "^3.972.7",
269484
+ "@aws-sdk/middleware-recursion-detection": "^3.972.7",
269485
+ "@aws-sdk/middleware-user-agent": "^3.972.18",
269486
+ "@aws-sdk/region-config-resolver": "^3.972.7",
269487
+ "@aws-sdk/types": "^3.973.5",
269488
+ "@aws-sdk/util-endpoints": "^3.996.4",
269489
+ "@aws-sdk/util-user-agent-browser": "^3.972.7",
269490
+ "@aws-sdk/util-user-agent-node": "^3.973.3",
269491
+ "@smithy/config-resolver": "^4.4.10",
269492
+ "@smithy/core": "^3.23.8",
269493
+ "@smithy/fetch-http-handler": "^5.3.13",
269494
+ "@smithy/hash-node": "^4.2.11",
269495
+ "@smithy/invalid-dependency": "^4.2.11",
269496
+ "@smithy/middleware-content-length": "^4.2.11",
269497
+ "@smithy/middleware-endpoint": "^4.4.22",
269498
+ "@smithy/middleware-retry": "^4.4.39",
269499
+ "@smithy/middleware-serde": "^4.2.12",
269500
+ "@smithy/middleware-stack": "^4.2.11",
269501
+ "@smithy/node-config-provider": "^4.3.11",
269502
+ "@smithy/node-http-handler": "^4.4.14",
269503
+ "@smithy/protocol-http": "^5.3.11",
269504
+ "@smithy/smithy-client": "^4.12.2",
267661
269505
  "@smithy/types": "^4.13.0",
267662
- "@smithy/url-parser": "^4.2.10",
267663
- "@smithy/util-base64": "^4.3.1",
267664
- "@smithy/util-body-length-browser": "^4.2.1",
267665
- "@smithy/util-body-length-node": "^4.2.2",
267666
- "@smithy/util-defaults-mode-browser": "^4.3.37",
267667
- "@smithy/util-defaults-mode-node": "^4.2.40",
267668
- "@smithy/util-endpoints": "^3.3.1",
267669
- "@smithy/util-middleware": "^4.2.10",
267670
- "@smithy/util-retry": "^4.2.10",
267671
- "@smithy/util-utf8": "^4.2.1",
269506
+ "@smithy/url-parser": "^4.2.11",
269507
+ "@smithy/util-base64": "^4.3.2",
269508
+ "@smithy/util-body-length-browser": "^4.2.2",
269509
+ "@smithy/util-body-length-node": "^4.2.3",
269510
+ "@smithy/util-defaults-mode-browser": "^4.3.38",
269511
+ "@smithy/util-defaults-mode-node": "^4.2.41",
269512
+ "@smithy/util-endpoints": "^3.3.2",
269513
+ "@smithy/util-middleware": "^4.2.11",
269514
+ "@smithy/util-retry": "^4.2.11",
269515
+ "@smithy/util-utf8": "^4.2.2",
267672
269516
  tslib: "^2.6.2"
267673
269517
  },
267674
269518
  devDependencies: {
@@ -267678,7 +269522,7 @@ var init_package = __esm({
267678
269522
  typescript: "~5.8.3"
267679
269523
  },
267680
269524
  typesVersions: {
267681
- "<4.0": {
269525
+ "<4.5": {
267682
269526
  "dist-types/*": [
267683
269527
  "dist-types/ts3.4/*"
267684
269528
  ]
@@ -267698,8 +269542,10 @@ var init_package = __esm({
267698
269542
  "dist-*/**"
267699
269543
  ],
267700
269544
  browser: {
269545
+ "./dist-es/submodules/cognito-identity/runtimeConfig": "./dist-es/submodules/cognito-identity/runtimeConfig.browser",
267701
269546
  "./dist-es/submodules/signin/runtimeConfig": "./dist-es/submodules/signin/runtimeConfig.browser",
267702
269547
  "./dist-es/submodules/sso-oidc/runtimeConfig": "./dist-es/submodules/sso-oidc/runtimeConfig.browser",
269548
+ "./dist-es/submodules/sso/runtimeConfig": "./dist-es/submodules/sso/runtimeConfig.browser",
267703
269549
  "./dist-es/submodules/sts/runtimeConfig": "./dist-es/submodules/sts/runtimeConfig.browser"
267704
269550
  },
267705
269551
  "react-native": {},
@@ -283537,7 +285383,7 @@ ${taskManager.formatTasksForPrompt()}`;
283537
285383
  }
283538
285384
  };
283539
285385
  }
283540
- var taskItemSchema, taskSchema, taskSystemPrompt, taskGuidancePrompt;
285386
+ var taskItemSchema, taskSchema, taskSystemPrompt;
283541
285387
  var init_taskTool = __esm({
283542
285388
  "src/agent/tasks/taskTool.js"() {
283543
285389
  "use strict";
@@ -283598,11 +285444,6 @@ Tasks = logical units of work, not files or steps.
283598
285444
  - Circular dependencies are rejected
283599
285445
  - attempt_completion is blocked while tasks remain unresolved
283600
285446
  `;
283601
- taskGuidancePrompt = `Does this request have MULTIPLE DISTINCT GOALS?
283602
- - "Do A AND B AND C" (multiple goals) \u2192 Create tasks for each goal
283603
- - "Investigate/explain/find X" (single goal) \u2192 Skip tasks, just answer directly
283604
- Multiple internal steps for ONE goal = NO tasks needed.
283605
- If creating tasks, use the task tool with action="create" first.`;
283606
285447
  }
283607
285448
  });
283608
285449
 
@@ -330088,8 +331929,20 @@ If the solution is clear, you can jump to implementation right away. If not, ask
330088
331929
  - Check imports and existing utilities before creating new helpers \u2014 the project may already have what you need.
330089
331930
 
330090
331931
  # Task Planning
330091
- - If the task tool is available, use it to break complex work into milestones before starting implementation.
330092
- - Stay flexible \u2014 if your understanding changes mid-task, add, remove, or reorganize tasks as needed. The plan should serve you, not constrain you.
331932
+ When the request has **multiple distinct goals** (e.g. "Fix bug A AND add feature B"), use the task tool to track them:
331933
+ - Call the task tool with action="create" and a tasks array. Each task must have an "id" field.
331934
+ - Update task status to "in_progress" when starting and "completed" when done.
331935
+ - All tasks must be completed or cancelled before calling attempt_completion.
331936
+ - Stay flexible \u2014 add, remove, or reorganize tasks as your understanding changes.
331937
+
331938
+ Do NOT create tasks for single-goal requests, even complex ones. Multiple internal steps for one goal (search, read, analyze, implement) do not need tasks.
331939
+
331940
+ # Discovering Project Commands
331941
+ Before building or testing, determine the project's toolchain:
331942
+ - Check for Makefile, package.json (scripts), Cargo.toml, go.mod, pyproject.toml, or similar
331943
+ - Look for CI config (.github/workflows/, .gitlab-ci.yml) to see what commands CI runs
331944
+ - Read README for build/test instructions if the above are unclear
331945
+ - Common patterns: \`make build\`/\`make test\`, \`npm run build\`/\`npm test\`, \`cargo build\`/\`cargo test\`, \`go build ./...\`/\`go test ./...\`, \`python -m pytest\`
330093
331946
 
330094
331947
  # During Implementation
330095
331948
  - Always create a new branch before making changes to the codebase.
@@ -330100,12 +331953,22 @@ If the solution is clear, you can jump to implementation right away. If not, ask
330100
331953
  - When editing files, keep edits focused and minimal. For changes spanning more than a few lines, prefer line-targeted editing (start_line/end_line) over text replacement (old_string) \u2014 it constrains scope and prevents accidental removal of adjacent content. Never include unrelated sections in an edit operation.
330101
331954
  - After every significant change, verify the project still builds and passes linting. Do not wait until the end to discover breakage.
330102
331955
 
330103
- # After Implementation
330104
- - Verify the project builds successfully. If it doesn't, fix the build before moving on.
330105
- - Run lint and typecheck commands if known for the project. Fix any new warnings or errors you introduced.
330106
- - Add tests for any new or changed functionality. Tests must cover the main path and important edge cases.
330107
- - Run the project's full test suite. If any tests fail (including pre-existing ones you may have broken), fix them before finishing.
330108
- - When the task is done, respond to the user with a concise summary of what was implemented, what files were changed, and any relevant details. Include links (e.g. pull request URL) so the user has everything they need.
331956
+ # Writing Tests
331957
+ Every change must include tests. Before writing them:
331958
+ - Find existing test files for the module you changed \u2014 look in \`tests/\`, \`__tests__/\`, \`*_test.go\`, \`*.test.js\`, \`*.spec.ts\`, or co-located test modules (\`#[cfg(test)]\` in Rust).
331959
+ - Read those tests to understand the project's testing patterns: framework, assertion style, mocking approach, file naming, test organization.
331960
+ - Prefer extending an existing test file over creating a new one when your change is in the same module.
331961
+ - Write tests that cover the main path and important edge cases. Include a failing-input test when relevant.
331962
+ - When fixing a bug, write a failing test first that reproduces the bug, then fix the code to make it pass.
331963
+
331964
+ # Verify Changes
331965
+ Before committing or creating a PR, run through this checklist:
331966
+ 1. **Build** \u2014 run the project-appropriate build command (go build, npm run build, cargo build, make, etc.). Fix any compilation errors.
331967
+ 2. **Lint & typecheck** \u2014 run linter/formatter if the project has one (eslint, clippy, golangci-lint, etc.). Fix any new warnings.
331968
+ 3. **Test** \u2014 run the full test suite (go test ./..., npm test, cargo test, make test, pytest, etc.). Fix any failures, including pre-existing tests you may have broken.
331969
+ 4. **Review** \u2014 re-read your diff. Ensure no debug code, no unrelated changes, no secrets, no missing files.
331970
+
331971
+ Do NOT skip verification. Do NOT proceed to PR creation with a broken build or failing tests.
330109
331972
 
330110
331973
  # GitHub Integration
330111
331974
  - Use the \`gh\` CLI for all GitHub operations: issues, pull requests, checks, releases.
@@ -353489,6 +355352,8 @@ var init_ProbeAgent = __esm({
353489
355352
  this.tracer = options.tracer || null;
353490
355353
  this.outline = !!options.outline;
353491
355354
  this.searchDelegate = options.searchDelegate !== void 0 ? !!options.searchDelegate : true;
355355
+ this.searchDelegateProvider = options.searchDelegateProvider || null;
355356
+ this.searchDelegateModel = options.searchDelegateModel || null;
353492
355357
  this.maxResponseTokens = options.maxResponseTokens || (() => {
353493
355358
  const val = parseInt(process.env.MAX_RESPONSE_TOKENS || "0", 10);
353494
355359
  if (isNaN(val) || val < 0 || val > 2e5) {
@@ -353925,6 +355790,8 @@ var init_ProbeAgent = __esm({
353925
355790
  architectureFileName: this.architectureFileName,
353926
355791
  provider: this.clientApiProvider,
353927
355792
  model: this.clientApiModel,
355793
+ searchDelegateProvider: this.searchDelegateProvider,
355794
+ searchDelegateModel: this.searchDelegateModel,
353928
355795
  delegationManager: this.delegationManager,
353929
355796
  // Per-instance delegation limits
353930
355797
  outputBuffer: this._outputBuffer,
@@ -355839,12 +357706,6 @@ You are working with a workspace. Available paths: ${workspaceDesc}
355839
357706
  });
355840
357707
  const systemMessage = await this.getSystemMessage();
355841
357708
  let userMessage = { role: "user", content: message.trim() };
355842
- if (this.enableTasks) {
355843
- userMessage.content = userMessage.content + "\n\n" + taskGuidancePrompt;
355844
- if (this.debug) {
355845
- console.log("[DEBUG] Task guidance injected into user message");
355846
- }
355847
- }
355848
357709
  if (options.schema && !options._schemaFormatted) {
355849
357710
  const schemaInstructions = generateSchemaInstructions(options.schema, { debug: this.debug });
355850
357711
  userMessage.content = message.trim() + schemaInstructions;
@@ -358139,8 +360000,8 @@ var init_vercel = __esm({
358139
360000
  parentSessionId: sessionId,
358140
360001
  path: options.allowedFolders?.[0] || options.cwd || ".",
358141
360002
  allowedFolders: options.allowedFolders,
358142
- provider: options.provider || null,
358143
- model: options.model || null,
360003
+ provider: options.searchDelegateProvider || process.env.PROBE_SEARCH_DELEGATE_PROVIDER || options.provider || null,
360004
+ model: options.searchDelegateModel || process.env.PROBE_SEARCH_DELEGATE_MODEL || options.model || null,
358144
360005
  tracer: options.tracer || null,
358145
360006
  enableBash: false,
358146
360007
  bashConfig: null,
@@ -395676,7 +397537,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"100":"Continue","101":"Switching Pro
395676
397537
  /***/ ((module) => {
395677
397538
 
395678
397539
  "use strict";
395679
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.163","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-rc276","@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"]}}');
397540
+ 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-rc278","@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"]}}');
395680
397541
 
395681
397542
  /***/ })
395682
397543