@probelabs/visor 0.1.150 → 0.1.151-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 (79) hide show
  1. package/dist/index.js +2157 -397
  2. package/dist/sdk/{check-provider-registry-RRYBG6AU.mjs → check-provider-registry-IGIIFX67.mjs} +5 -5
  3. package/dist/sdk/{check-provider-registry-YFC5KSJY.mjs → check-provider-registry-NEOLXMRW.mjs} +5 -5
  4. package/dist/sdk/{chunk-GIAN7HCT.mjs → chunk-CZOKADR7.mjs} +3 -3
  5. package/dist/sdk/{chunk-YY3KADY2.mjs → chunk-GJN2HALW.mjs} +16 -16
  6. package/dist/sdk/{chunk-YY3KADY2.mjs.map → chunk-GJN2HALW.mjs.map} +1 -1
  7. package/dist/sdk/{chunk-FZEQ744M.mjs → chunk-LH3PEGKM.mjs} +2 -2
  8. package/dist/sdk/{chunk-PETLPNRA.mjs → chunk-NE3OOOB2.mjs} +2 -2
  9. package/dist/sdk/{chunk-PETLPNRA.mjs.map → chunk-NE3OOOB2.mjs.map} +1 -1
  10. package/dist/sdk/{chunk-AADKUA6L.mjs → chunk-U4ZJWL63.mjs} +15 -15
  11. package/dist/sdk/{failure-condition-evaluator-XV2ZMFFY.mjs → failure-condition-evaluator-XYC6LZAV.mjs} +3 -3
  12. package/dist/sdk/{github-frontend-A2R7D4N6.mjs → github-frontend-NWH4ZK77.mjs} +3 -3
  13. package/dist/sdk/{host-CLPM2WVQ.mjs → host-7WIF5HKA.mjs} +2 -2
  14. package/dist/sdk/{host-MR7L57QI.mjs → host-ZWGHQS34.mjs} +2 -2
  15. package/dist/sdk/knex-store-CRORFJE6.mjs +527 -0
  16. package/dist/sdk/knex-store-CRORFJE6.mjs.map +1 -0
  17. package/dist/sdk/loader-NJCF7DUS.mjs +89 -0
  18. package/dist/sdk/loader-NJCF7DUS.mjs.map +1 -0
  19. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs +655 -0
  20. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs.map +1 -0
  21. package/dist/sdk/{routing-KLVK2MJZ.mjs → routing-ODVQHICC.mjs} +4 -4
  22. package/dist/sdk/{schedule-tool-NYLNJUEW.mjs → schedule-tool-HQFZLF4V.mjs} +5 -5
  23. package/dist/sdk/{schedule-tool-PRXFAV4K.mjs → schedule-tool-SFHR3T3S.mjs} +5 -5
  24. package/dist/sdk/{schedule-tool-handler-EFQIYD3W.mjs → schedule-tool-handler-C6B4SFCZ.mjs} +5 -5
  25. package/dist/sdk/{schedule-tool-handler-HVWCEGQ6.mjs → schedule-tool-handler-JCOBGMRA.mjs} +5 -5
  26. package/dist/sdk/sdk.js +1634 -260
  27. package/dist/sdk/sdk.js.map +1 -1
  28. package/dist/sdk/sdk.mjs +4 -4
  29. package/dist/sdk/{trace-helpers-6NSZBC35.mjs → trace-helpers-LKAADSNB.mjs} +2 -2
  30. package/dist/sdk/validator-XTZJZZJH.mjs +134 -0
  31. package/dist/sdk/validator-XTZJZZJH.mjs.map +1 -0
  32. package/dist/sdk/{workflow-check-provider-OXHMLICJ.mjs → workflow-check-provider-CH3ARLBE.mjs} +5 -5
  33. package/dist/sdk/{workflow-check-provider-XLH7N4FV.mjs → workflow-check-provider-LMAKHSEZ.mjs} +5 -5
  34. package/package.json +2 -2
  35. package/dist/output/traces/run-2026-03-03T20-21-24-501Z.ndjson +0 -138
  36. package/dist/output/traces/run-2026-03-03T20-22-08-701Z.ndjson +0 -2197
  37. package/dist/sdk/check-provider-registry-6D5CAX44.mjs +0 -29
  38. package/dist/sdk/chunk-CKDFGNF4.mjs +0 -43715
  39. package/dist/sdk/chunk-CKDFGNF4.mjs.map +0 -1
  40. package/dist/sdk/chunk-GLROSEYJ.mjs +0 -1502
  41. package/dist/sdk/chunk-GLROSEYJ.mjs.map +0 -1
  42. package/dist/sdk/chunk-H4HFH7HH.mjs +0 -443
  43. package/dist/sdk/chunk-H4HFH7HH.mjs.map +0 -1
  44. package/dist/sdk/chunk-SWO4W57C.mjs +0 -739
  45. package/dist/sdk/chunk-SWO4W57C.mjs.map +0 -1
  46. package/dist/sdk/failure-condition-evaluator-P6QUFLIN.mjs +0 -17
  47. package/dist/sdk/github-frontend-GSB2P5PE.mjs +0 -1368
  48. package/dist/sdk/github-frontend-GSB2P5PE.mjs.map +0 -1
  49. package/dist/sdk/routing-V3MYZAOH.mjs +0 -25
  50. package/dist/sdk/schedule-tool-HYM55K3H.mjs +0 -35
  51. package/dist/sdk/schedule-tool-handler-HVWCEGQ6.mjs.map +0 -1
  52. package/dist/sdk/schedule-tool-handler-M5YI573R.mjs +0 -39
  53. package/dist/sdk/schedule-tool-handler-M5YI573R.mjs.map +0 -1
  54. package/dist/sdk/trace-helpers-6NSZBC35.mjs.map +0 -1
  55. package/dist/sdk/trace-helpers-TORF3JD5.mjs +0 -25
  56. package/dist/sdk/trace-helpers-TORF3JD5.mjs.map +0 -1
  57. package/dist/sdk/workflow-check-provider-3F6CBHVD.mjs +0 -29
  58. package/dist/sdk/workflow-check-provider-3F6CBHVD.mjs.map +0 -1
  59. package/dist/sdk/workflow-check-provider-OXHMLICJ.mjs.map +0 -1
  60. package/dist/sdk/workflow-check-provider-XLH7N4FV.mjs.map +0 -1
  61. package/dist/traces/run-2026-03-03T20-21-24-501Z.ndjson +0 -138
  62. package/dist/traces/run-2026-03-03T20-22-08-701Z.ndjson +0 -2197
  63. /package/dist/sdk/{check-provider-registry-6D5CAX44.mjs.map → check-provider-registry-IGIIFX67.mjs.map} +0 -0
  64. /package/dist/sdk/{check-provider-registry-RRYBG6AU.mjs.map → check-provider-registry-NEOLXMRW.mjs.map} +0 -0
  65. /package/dist/sdk/{chunk-GIAN7HCT.mjs.map → chunk-CZOKADR7.mjs.map} +0 -0
  66. /package/dist/sdk/{chunk-FZEQ744M.mjs.map → chunk-LH3PEGKM.mjs.map} +0 -0
  67. /package/dist/sdk/{chunk-AADKUA6L.mjs.map → chunk-U4ZJWL63.mjs.map} +0 -0
  68. /package/dist/sdk/{check-provider-registry-YFC5KSJY.mjs.map → failure-condition-evaluator-XYC6LZAV.mjs.map} +0 -0
  69. /package/dist/sdk/{github-frontend-A2R7D4N6.mjs.map → github-frontend-NWH4ZK77.mjs.map} +0 -0
  70. /package/dist/sdk/{host-CLPM2WVQ.mjs.map → host-7WIF5HKA.mjs.map} +0 -0
  71. /package/dist/sdk/{host-MR7L57QI.mjs.map → host-ZWGHQS34.mjs.map} +0 -0
  72. /package/dist/sdk/{failure-condition-evaluator-P6QUFLIN.mjs.map → routing-ODVQHICC.mjs.map} +0 -0
  73. /package/dist/sdk/{failure-condition-evaluator-XV2ZMFFY.mjs.map → schedule-tool-HQFZLF4V.mjs.map} +0 -0
  74. /package/dist/sdk/{routing-KLVK2MJZ.mjs.map → schedule-tool-SFHR3T3S.mjs.map} +0 -0
  75. /package/dist/sdk/{routing-V3MYZAOH.mjs.map → schedule-tool-handler-C6B4SFCZ.mjs.map} +0 -0
  76. /package/dist/sdk/{schedule-tool-HYM55K3H.mjs.map → schedule-tool-handler-JCOBGMRA.mjs.map} +0 -0
  77. /package/dist/sdk/{schedule-tool-NYLNJUEW.mjs.map → trace-helpers-LKAADSNB.mjs.map} +0 -0
  78. /package/dist/sdk/{schedule-tool-PRXFAV4K.mjs.map → workflow-check-provider-CH3ARLBE.mjs.map} +0 -0
  79. /package/dist/sdk/{schedule-tool-handler-EFQIYD3W.mjs.map → workflow-check-provider-LMAKHSEZ.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.150';
3
- process.env.PROBE_VERSION = '0.6.0-rc266';
4
- process.env.VISOR_COMMIT_SHA = '3b87c12790f72a2050000f18b840f18909bda118';
5
- process.env.VISOR_COMMIT_SHORT = '3b87c127';
2
+ process.env.VISOR_VERSION = '0.1.151';
3
+ process.env.PROBE_VERSION = '0.6.0-rc268';
4
+ process.env.VISOR_COMMIT_SHA = 'b06d244c0580c243801a29bbeae739a8198bea09';
5
+ process.env.VISOR_COMMIT_SHORT = 'b06d244';
6
6
  /******/ (() => { // webpackBootstrap
7
7
  /******/ var __webpack_modules__ = ({
8
8
 
@@ -161210,7 +161210,7 @@ async function handleDumpPolicyInput(checkId, argv) {
161210
161210
  let PolicyInputBuilder;
161211
161211
  try {
161212
161212
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
161213
- const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(71370)));
161213
+ const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(17117)));
161214
161214
  PolicyInputBuilder = mod.PolicyInputBuilder;
161215
161215
  }
161216
161216
  catch {
@@ -167053,6 +167053,1810 @@ class DependencyResolver {
167053
167053
  exports.DependencyResolver = DependencyResolver;
167054
167054
 
167055
167055
 
167056
+ /***/ }),
167057
+
167058
+ /***/ 50069:
167059
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167060
+
167061
+ "use strict";
167062
+
167063
+ /**
167064
+ * Copyright (c) ProbeLabs. All rights reserved.
167065
+ * Licensed under the Elastic License 2.0; you may not use this file except
167066
+ * in compliance with the Elastic License 2.0.
167067
+ */
167068
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167069
+ if (k2 === undefined) k2 = k;
167070
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167071
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167072
+ desc = { enumerable: true, get: function() { return m[k]; } };
167073
+ }
167074
+ Object.defineProperty(o, k2, desc);
167075
+ }) : (function(o, m, k, k2) {
167076
+ if (k2 === undefined) k2 = k;
167077
+ o[k2] = m[k];
167078
+ }));
167079
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167080
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167081
+ }) : function(o, v) {
167082
+ o["default"] = v;
167083
+ });
167084
+ var __importStar = (this && this.__importStar) || (function () {
167085
+ var ownKeys = function(o) {
167086
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167087
+ var ar = [];
167088
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167089
+ return ar;
167090
+ };
167091
+ return ownKeys(o);
167092
+ };
167093
+ return function (mod) {
167094
+ if (mod && mod.__esModule) return mod;
167095
+ var result = {};
167096
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167097
+ __setModuleDefault(result, mod);
167098
+ return result;
167099
+ };
167100
+ })();
167101
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167102
+ exports.LicenseValidator = void 0;
167103
+ const crypto = __importStar(__nccwpck_require__(76982));
167104
+ const fs = __importStar(__nccwpck_require__(79896));
167105
+ const path = __importStar(__nccwpck_require__(16928));
167106
+ class LicenseValidator {
167107
+ /** Ed25519 public key for license verification (PEM format). */
167108
+ static PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----\n' +
167109
+ 'MCowBQYDK2VwAyEAI/Zd08EFmgIdrDm/HXd0l3/5GBt7R1PrdvhdmEXhJlU=\n' +
167110
+ '-----END PUBLIC KEY-----\n';
167111
+ cache = null;
167112
+ static CACHE_TTL = 5 * 60 * 1000; // 5 minutes
167113
+ static GRACE_PERIOD = 72 * 3600 * 1000; // 72 hours after expiry
167114
+ /**
167115
+ * Load and validate license from environment or file.
167116
+ *
167117
+ * Resolution order:
167118
+ * 1. VISOR_LICENSE env var (JWT string)
167119
+ * 2. VISOR_LICENSE_FILE env var (path to file)
167120
+ * 3. .visor-license in project root (cwd)
167121
+ * 4. .visor-license in ~/.config/visor/
167122
+ */
167123
+ async loadAndValidate() {
167124
+ // Return cached result if still fresh
167125
+ if (this.cache && Date.now() - this.cache.validatedAt < LicenseValidator.CACHE_TTL) {
167126
+ return this.cache.payload;
167127
+ }
167128
+ const token = this.resolveToken();
167129
+ if (!token)
167130
+ return null;
167131
+ const payload = this.verifyAndDecode(token);
167132
+ if (!payload)
167133
+ return null;
167134
+ this.cache = { payload, validatedAt: Date.now() };
167135
+ return payload;
167136
+ }
167137
+ /** Check if a specific feature is licensed */
167138
+ hasFeature(feature) {
167139
+ if (!this.cache)
167140
+ return false;
167141
+ return this.cache.payload.features.includes(feature);
167142
+ }
167143
+ /** Check if license is valid (with grace period) */
167144
+ isValid() {
167145
+ if (!this.cache)
167146
+ return false;
167147
+ const now = Date.now();
167148
+ const expiryMs = this.cache.payload.exp * 1000;
167149
+ return now < expiryMs + LicenseValidator.GRACE_PERIOD;
167150
+ }
167151
+ /** Check if the license is within its grace period (expired but still valid) */
167152
+ isInGracePeriod() {
167153
+ if (!this.cache)
167154
+ return false;
167155
+ const now = Date.now();
167156
+ const expiryMs = this.cache.payload.exp * 1000;
167157
+ return now >= expiryMs && now < expiryMs + LicenseValidator.GRACE_PERIOD;
167158
+ }
167159
+ resolveToken() {
167160
+ // 1. Direct env var
167161
+ if (process.env.VISOR_LICENSE) {
167162
+ return process.env.VISOR_LICENSE.trim();
167163
+ }
167164
+ // 2. File path from env (validate against path traversal)
167165
+ if (process.env.VISOR_LICENSE_FILE) {
167166
+ // path.resolve() produces an absolute path with all '..' segments resolved,
167167
+ // so a separate resolved.includes('..') check is unnecessary.
167168
+ const resolved = path.resolve(process.env.VISOR_LICENSE_FILE);
167169
+ const home = process.env.HOME || process.env.USERPROFILE || '';
167170
+ const allowedPrefixes = [path.normalize(process.cwd())];
167171
+ if (home)
167172
+ allowedPrefixes.push(path.normalize(path.join(home, '.config', 'visor')));
167173
+ // Resolve symlinks so an attacker cannot create a symlink inside an
167174
+ // allowed prefix that points to an arbitrary file outside it.
167175
+ let realPath;
167176
+ try {
167177
+ realPath = fs.realpathSync(resolved);
167178
+ }
167179
+ catch {
167180
+ return null; // File doesn't exist or isn't accessible
167181
+ }
167182
+ const isSafe = allowedPrefixes.some(prefix => realPath === prefix || realPath.startsWith(prefix + path.sep));
167183
+ if (!isSafe)
167184
+ return null;
167185
+ return this.readFile(realPath);
167186
+ }
167187
+ // 3. .visor-license in cwd
167188
+ const cwdPath = path.join(process.cwd(), '.visor-license');
167189
+ const cwdToken = this.readFile(cwdPath);
167190
+ if (cwdToken)
167191
+ return cwdToken;
167192
+ // 4. ~/.config/visor/.visor-license
167193
+ const home = process.env.HOME || process.env.USERPROFILE || '';
167194
+ if (home) {
167195
+ const configPath = path.join(home, '.config', 'visor', '.visor-license');
167196
+ const configToken = this.readFile(configPath);
167197
+ if (configToken)
167198
+ return configToken;
167199
+ }
167200
+ return null;
167201
+ }
167202
+ readFile(filePath) {
167203
+ try {
167204
+ return fs.readFileSync(filePath, 'utf-8').trim();
167205
+ }
167206
+ catch {
167207
+ return null;
167208
+ }
167209
+ }
167210
+ verifyAndDecode(token) {
167211
+ try {
167212
+ const parts = token.split('.');
167213
+ if (parts.length !== 3)
167214
+ return null;
167215
+ const [headerB64, payloadB64, signatureB64] = parts;
167216
+ // Decode header to verify algorithm
167217
+ const header = JSON.parse(Buffer.from(headerB64, 'base64url').toString());
167218
+ if (header.alg !== 'EdDSA')
167219
+ return null;
167220
+ // Verify signature
167221
+ const data = `${headerB64}.${payloadB64}`;
167222
+ const signature = Buffer.from(signatureB64, 'base64url');
167223
+ const publicKey = crypto.createPublicKey(LicenseValidator.PUBLIC_KEY);
167224
+ // Validate that the loaded public key is actually Ed25519 (OID 1.3.101.112).
167225
+ // This prevents algorithm-confusion attacks if the embedded key were ever
167226
+ // swapped to a different type.
167227
+ if (publicKey.asymmetricKeyType !== 'ed25519') {
167228
+ return null;
167229
+ }
167230
+ // Ed25519 verification: algorithm must be null because EdDSA performs its
167231
+ // own internal hashing (SHA-512) — passing a digest algorithm here would
167232
+ // cause Node.js to throw. The key type is validated above.
167233
+ const isValid = crypto.verify(null, Buffer.from(data), publicKey, signature);
167234
+ if (!isValid)
167235
+ return null;
167236
+ // Decode payload
167237
+ const payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString());
167238
+ // Validate required fields
167239
+ if (!payload.org ||
167240
+ !Array.isArray(payload.features) ||
167241
+ typeof payload.exp !== 'number' ||
167242
+ typeof payload.iat !== 'number' ||
167243
+ !payload.sub) {
167244
+ return null;
167245
+ }
167246
+ // Check expiry (with grace period)
167247
+ const now = Date.now();
167248
+ const expiryMs = payload.exp * 1000;
167249
+ if (now >= expiryMs + LicenseValidator.GRACE_PERIOD) {
167250
+ return null;
167251
+ }
167252
+ return payload;
167253
+ }
167254
+ catch {
167255
+ return null;
167256
+ }
167257
+ }
167258
+ }
167259
+ exports.LicenseValidator = LicenseValidator;
167260
+
167261
+
167262
+ /***/ }),
167263
+
167264
+ /***/ 87068:
167265
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167266
+
167267
+ "use strict";
167268
+
167269
+ /**
167270
+ * Copyright (c) ProbeLabs. All rights reserved.
167271
+ * Licensed under the Elastic License 2.0; you may not use this file except
167272
+ * in compliance with the Elastic License 2.0.
167273
+ */
167274
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167275
+ if (k2 === undefined) k2 = k;
167276
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167277
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167278
+ desc = { enumerable: true, get: function() { return m[k]; } };
167279
+ }
167280
+ Object.defineProperty(o, k2, desc);
167281
+ }) : (function(o, m, k, k2) {
167282
+ if (k2 === undefined) k2 = k;
167283
+ o[k2] = m[k];
167284
+ }));
167285
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167286
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167287
+ }) : function(o, v) {
167288
+ o["default"] = v;
167289
+ });
167290
+ var __importStar = (this && this.__importStar) || (function () {
167291
+ var ownKeys = function(o) {
167292
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167293
+ var ar = [];
167294
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167295
+ return ar;
167296
+ };
167297
+ return ownKeys(o);
167298
+ };
167299
+ return function (mod) {
167300
+ if (mod && mod.__esModule) return mod;
167301
+ var result = {};
167302
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167303
+ __setModuleDefault(result, mod);
167304
+ return result;
167305
+ };
167306
+ })();
167307
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167308
+ exports.loadEnterprisePolicyEngine = loadEnterprisePolicyEngine;
167309
+ exports.loadEnterpriseStoreBackend = loadEnterpriseStoreBackend;
167310
+ const default_engine_1 = __nccwpck_require__(93866);
167311
+ /**
167312
+ * Load the enterprise policy engine if licensed, otherwise return the default no-op engine.
167313
+ *
167314
+ * This is the sole import boundary between OSS and enterprise code. Core code
167315
+ * must only import from this module (via dynamic `await import()`), never from
167316
+ * individual enterprise submodules.
167317
+ */
167318
+ async function loadEnterprisePolicyEngine(config) {
167319
+ try {
167320
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167321
+ const validator = new LicenseValidator();
167322
+ const license = await validator.loadAndValidate();
167323
+ if (!license || !validator.hasFeature('policy')) {
167324
+ return new default_engine_1.DefaultPolicyEngine();
167325
+ }
167326
+ if (validator.isInGracePeriod()) {
167327
+ // eslint-disable-next-line no-console
167328
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167329
+ 'Please renew your license.');
167330
+ }
167331
+ const { OpaPolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(39530)));
167332
+ const engine = new OpaPolicyEngine(config);
167333
+ await engine.initialize(config);
167334
+ return engine;
167335
+ }
167336
+ catch (err) {
167337
+ // Enterprise code not available or initialization failed
167338
+ const msg = err instanceof Error ? err.message : String(err);
167339
+ try {
167340
+ const { logger } = __nccwpck_require__(86999);
167341
+ logger.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
167342
+ }
167343
+ catch {
167344
+ // silent
167345
+ }
167346
+ return new default_engine_1.DefaultPolicyEngine();
167347
+ }
167348
+ }
167349
+ /**
167350
+ * Load the enterprise schedule store backend if licensed.
167351
+ *
167352
+ * @param driver Database driver ('postgresql', 'mysql', or 'mssql')
167353
+ * @param storageConfig Storage configuration with connection details
167354
+ * @param haConfig Optional HA configuration
167355
+ * @throws Error if enterprise license is not available or missing 'scheduler-sql' feature
167356
+ */
167357
+ async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
167358
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167359
+ const validator = new LicenseValidator();
167360
+ const license = await validator.loadAndValidate();
167361
+ if (!license || !validator.hasFeature('scheduler-sql')) {
167362
+ throw new Error(`The ${driver} schedule storage driver requires a Visor Enterprise license ` +
167363
+ `with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`);
167364
+ }
167365
+ if (validator.isInGracePeriod()) {
167366
+ // eslint-disable-next-line no-console
167367
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167368
+ 'Please renew your license.');
167369
+ }
167370
+ const { KnexStoreBackend } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(63737)));
167371
+ return new KnexStoreBackend(driver, storageConfig, haConfig);
167372
+ }
167373
+
167374
+
167375
+ /***/ }),
167376
+
167377
+ /***/ 628:
167378
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167379
+
167380
+ "use strict";
167381
+
167382
+ /**
167383
+ * Copyright (c) ProbeLabs. All rights reserved.
167384
+ * Licensed under the Elastic License 2.0; you may not use this file except
167385
+ * in compliance with the Elastic License 2.0.
167386
+ */
167387
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167388
+ if (k2 === undefined) k2 = k;
167389
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167390
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167391
+ desc = { enumerable: true, get: function() { return m[k]; } };
167392
+ }
167393
+ Object.defineProperty(o, k2, desc);
167394
+ }) : (function(o, m, k, k2) {
167395
+ if (k2 === undefined) k2 = k;
167396
+ o[k2] = m[k];
167397
+ }));
167398
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167399
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167400
+ }) : function(o, v) {
167401
+ o["default"] = v;
167402
+ });
167403
+ var __importStar = (this && this.__importStar) || (function () {
167404
+ var ownKeys = function(o) {
167405
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167406
+ var ar = [];
167407
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167408
+ return ar;
167409
+ };
167410
+ return ownKeys(o);
167411
+ };
167412
+ return function (mod) {
167413
+ if (mod && mod.__esModule) return mod;
167414
+ var result = {};
167415
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167416
+ __setModuleDefault(result, mod);
167417
+ return result;
167418
+ };
167419
+ })();
167420
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167421
+ exports.OpaCompiler = void 0;
167422
+ const fs = __importStar(__nccwpck_require__(79896));
167423
+ const path = __importStar(__nccwpck_require__(16928));
167424
+ const os = __importStar(__nccwpck_require__(70857));
167425
+ const crypto = __importStar(__nccwpck_require__(76982));
167426
+ const child_process_1 = __nccwpck_require__(35317);
167427
+ /**
167428
+ * OPA Rego Compiler - compiles .rego policy files to WASM bundles using the `opa` CLI.
167429
+ *
167430
+ * Handles:
167431
+ * - Resolving input paths to WASM bytes (direct .wasm, directory with policy.wasm, or .rego files)
167432
+ * - Compiling .rego files to WASM via `opa build`
167433
+ * - Caching compiled bundles based on content hashes
167434
+ * - Extracting policy.wasm from OPA tar.gz bundles
167435
+ *
167436
+ * Requires:
167437
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
167438
+ */
167439
+ class OpaCompiler {
167440
+ static CACHE_DIR = path.join(os.tmpdir(), 'visor-opa-cache');
167441
+ /**
167442
+ * Resolve the input paths to WASM bytes.
167443
+ *
167444
+ * Strategy:
167445
+ * 1. If any path is a .wasm file, read it directly
167446
+ * 2. If a directory contains policy.wasm, read it
167447
+ * 3. Otherwise, collect all .rego files and auto-compile via `opa build`
167448
+ */
167449
+ async resolveWasmBytes(paths) {
167450
+ // Collect .rego files and check for existing .wasm
167451
+ const regoFiles = [];
167452
+ for (const p of paths) {
167453
+ const resolved = path.resolve(p);
167454
+ // Reject paths containing '..' after resolution (path traversal)
167455
+ if (path.normalize(resolved).includes('..')) {
167456
+ throw new Error(`Policy path contains traversal sequences: ${p}`);
167457
+ }
167458
+ // Direct .wasm file
167459
+ if (resolved.endsWith('.wasm') && fs.existsSync(resolved)) {
167460
+ return fs.readFileSync(resolved);
167461
+ }
167462
+ if (!fs.existsSync(resolved))
167463
+ continue;
167464
+ const stat = fs.statSync(resolved);
167465
+ if (stat.isDirectory()) {
167466
+ // Check for pre-compiled policy.wasm in directory
167467
+ const wasmCandidate = path.join(resolved, 'policy.wasm');
167468
+ if (fs.existsSync(wasmCandidate)) {
167469
+ return fs.readFileSync(wasmCandidate);
167470
+ }
167471
+ // Collect all .rego files from directory
167472
+ const files = fs.readdirSync(resolved);
167473
+ for (const f of files) {
167474
+ if (f.endsWith('.rego')) {
167475
+ regoFiles.push(path.join(resolved, f));
167476
+ }
167477
+ }
167478
+ }
167479
+ else if (resolved.endsWith('.rego')) {
167480
+ regoFiles.push(resolved);
167481
+ }
167482
+ }
167483
+ if (regoFiles.length === 0) {
167484
+ throw new Error(`OPA WASM evaluator: no .wasm bundle or .rego files found in: ${paths.join(', ')}`);
167485
+ }
167486
+ // Auto-compile .rego -> .wasm
167487
+ return this.compileRego(regoFiles);
167488
+ }
167489
+ /**
167490
+ * Auto-compile .rego files to a WASM bundle using the `opa` CLI.
167491
+ *
167492
+ * Caches the compiled bundle based on a content hash of all input .rego files
167493
+ * so subsequent runs skip compilation if policies haven't changed.
167494
+ */
167495
+ compileRego(regoFiles) {
167496
+ // Check that `opa` CLI is available
167497
+ try {
167498
+ (0, child_process_1.execFileSync)('opa', ['version'], { stdio: 'pipe' });
167499
+ }
167500
+ catch {
167501
+ throw new Error('OPA CLI (`opa`) not found on PATH. Install it from https://www.openpolicyagent.org/docs/latest/#running-opa\n' +
167502
+ 'Or pre-compile your .rego files: opa build -t wasm -e visor -o bundle.tar.gz ' +
167503
+ regoFiles.join(' '));
167504
+ }
167505
+ // Compute content hash for cache key
167506
+ const hash = crypto.createHash('sha256');
167507
+ for (const f of regoFiles.sort()) {
167508
+ hash.update(fs.readFileSync(f));
167509
+ hash.update(f); // include filename for disambiguation
167510
+ }
167511
+ const cacheKey = hash.digest('hex').slice(0, 16);
167512
+ const cacheDir = OpaCompiler.CACHE_DIR;
167513
+ const cachedWasm = path.join(cacheDir, `${cacheKey}.wasm`);
167514
+ // Return cached bundle if still valid
167515
+ if (fs.existsSync(cachedWasm)) {
167516
+ return fs.readFileSync(cachedWasm);
167517
+ }
167518
+ // Compile to WASM via opa build
167519
+ fs.mkdirSync(cacheDir, { recursive: true });
167520
+ const bundleTar = path.join(cacheDir, `${cacheKey}-bundle.tar.gz`);
167521
+ try {
167522
+ const args = [
167523
+ 'build',
167524
+ '-t',
167525
+ 'wasm',
167526
+ '-e',
167527
+ 'visor', // entrypoint: the visor package tree
167528
+ '-o',
167529
+ bundleTar,
167530
+ ...regoFiles,
167531
+ ];
167532
+ (0, child_process_1.execFileSync)('opa', args, {
167533
+ stdio: 'pipe',
167534
+ timeout: 30000,
167535
+ });
167536
+ }
167537
+ catch (err) {
167538
+ const stderr = err?.stderr?.toString() || '';
167539
+ throw new Error(`Failed to compile .rego files to WASM:\n${stderr}\n` +
167540
+ 'Ensure your .rego files are valid and the `opa` CLI is installed.');
167541
+ }
167542
+ // Extract policy.wasm from the tar.gz bundle
167543
+ // OPA bundles are tar.gz with /policy.wasm inside
167544
+ try {
167545
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, '/policy.wasm'], {
167546
+ stdio: 'pipe',
167547
+ });
167548
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
167549
+ if (fs.existsSync(extractedWasm)) {
167550
+ // Move to cache-key named file
167551
+ fs.renameSync(extractedWasm, cachedWasm);
167552
+ }
167553
+ }
167554
+ catch {
167555
+ // Some tar implementations don't like leading /
167556
+ try {
167557
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, 'policy.wasm'], {
167558
+ stdio: 'pipe',
167559
+ });
167560
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
167561
+ if (fs.existsSync(extractedWasm)) {
167562
+ fs.renameSync(extractedWasm, cachedWasm);
167563
+ }
167564
+ }
167565
+ catch (err2) {
167566
+ throw new Error(`Failed to extract policy.wasm from OPA bundle: ${err2?.message || err2}`);
167567
+ }
167568
+ }
167569
+ // Clean up tar
167570
+ try {
167571
+ fs.unlinkSync(bundleTar);
167572
+ }
167573
+ catch { }
167574
+ if (!fs.existsSync(cachedWasm)) {
167575
+ throw new Error('OPA build succeeded but policy.wasm was not found in the bundle');
167576
+ }
167577
+ return fs.readFileSync(cachedWasm);
167578
+ }
167579
+ }
167580
+ exports.OpaCompiler = OpaCompiler;
167581
+
167582
+
167583
+ /***/ }),
167584
+
167585
+ /***/ 44693:
167586
+ /***/ ((__unused_webpack_module, exports) => {
167587
+
167588
+ "use strict";
167589
+
167590
+ /**
167591
+ * Copyright (c) ProbeLabs. All rights reserved.
167592
+ * Licensed under the Elastic License 2.0; you may not use this file except
167593
+ * in compliance with the Elastic License 2.0.
167594
+ */
167595
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167596
+ exports.OpaHttpEvaluator = void 0;
167597
+ /**
167598
+ * OPA HTTP Evaluator - evaluates policies via an external OPA server's REST API.
167599
+ *
167600
+ * Uses the built-in `fetch` API (Node 18+), so no extra dependencies are needed.
167601
+ */
167602
+ class OpaHttpEvaluator {
167603
+ baseUrl;
167604
+ timeout;
167605
+ constructor(baseUrl, timeout = 5000) {
167606
+ // Validate URL format and protocol
167607
+ let parsed;
167608
+ try {
167609
+ parsed = new URL(baseUrl);
167610
+ }
167611
+ catch {
167612
+ throw new Error(`OPA HTTP evaluator: invalid URL: ${baseUrl}`);
167613
+ }
167614
+ if (!['http:', 'https:'].includes(parsed.protocol)) {
167615
+ throw new Error(`OPA HTTP evaluator: url must use http:// or https:// protocol, got: ${baseUrl}`);
167616
+ }
167617
+ // Block cloud metadata, loopback, link-local, and private network addresses
167618
+ const hostname = parsed.hostname;
167619
+ if (this.isBlockedHostname(hostname)) {
167620
+ throw new Error(`OPA HTTP evaluator: url must not point to internal, loopback, or private network addresses`);
167621
+ }
167622
+ // Normalize: strip trailing slash
167623
+ this.baseUrl = baseUrl.replace(/\/+$/, '');
167624
+ this.timeout = timeout;
167625
+ }
167626
+ /**
167627
+ * Check if a hostname is blocked due to SSRF concerns.
167628
+ *
167629
+ * Blocks:
167630
+ * - Loopback addresses (127.x.x.x, localhost, 0.0.0.0, ::1)
167631
+ * - Link-local addresses (169.254.x.x)
167632
+ * - Private networks (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
167633
+ * - IPv6 unique local addresses (fd00::/8)
167634
+ * - Cloud metadata services (*.internal)
167635
+ */
167636
+ isBlockedHostname(hostname) {
167637
+ if (!hostname)
167638
+ return true; // block empty hostnames
167639
+ // Normalize hostname: lowercase and remove brackets for IPv6
167640
+ const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
167641
+ // Block .internal domains (cloud metadata services)
167642
+ if (normalized === 'metadata.google.internal' || normalized.endsWith('.internal')) {
167643
+ return true;
167644
+ }
167645
+ // Block localhost variants
167646
+ if (normalized === 'localhost' || normalized === 'localhost.localdomain') {
167647
+ return true;
167648
+ }
167649
+ // Block IPv6 loopback
167650
+ if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
167651
+ return true;
167652
+ }
167653
+ // Check IPv4 patterns
167654
+ const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
167655
+ const ipv4Match = normalized.match(ipv4Pattern);
167656
+ if (ipv4Match) {
167657
+ const octets = ipv4Match.slice(1, 5).map(Number);
167658
+ // Validate octets are in range [0, 255]
167659
+ if (octets.some(octet => octet > 255)) {
167660
+ return false;
167661
+ }
167662
+ const [a, b] = octets;
167663
+ // Block loopback: 127.0.0.0/8
167664
+ if (a === 127) {
167665
+ return true;
167666
+ }
167667
+ // Block 0.0.0.0/8 (this host)
167668
+ if (a === 0) {
167669
+ return true;
167670
+ }
167671
+ // Block link-local: 169.254.0.0/16
167672
+ if (a === 169 && b === 254) {
167673
+ return true;
167674
+ }
167675
+ // Block private networks
167676
+ // 10.0.0.0/8
167677
+ if (a === 10) {
167678
+ return true;
167679
+ }
167680
+ // 172.16.0.0/12 (172.16.x.x through 172.31.x.x)
167681
+ if (a === 172 && b >= 16 && b <= 31) {
167682
+ return true;
167683
+ }
167684
+ // 192.168.0.0/16
167685
+ if (a === 192 && b === 168) {
167686
+ return true;
167687
+ }
167688
+ }
167689
+ // Check IPv6 patterns
167690
+ // Block unique local addresses: fd00::/8
167691
+ if (normalized.startsWith('fd') || normalized.startsWith('fc')) {
167692
+ return true;
167693
+ }
167694
+ // Block link-local: fe80::/10
167695
+ if (normalized.startsWith('fe80:')) {
167696
+ return true;
167697
+ }
167698
+ return false;
167699
+ }
167700
+ /**
167701
+ * Evaluate a policy rule against an input document via OPA REST API.
167702
+ *
167703
+ * @param input - The input document to evaluate
167704
+ * @param rulePath - OPA rule path (e.g., 'visor/check/execute')
167705
+ * @returns The result object from OPA, or undefined on error
167706
+ */
167707
+ async evaluate(input, rulePath) {
167708
+ // OPA Data API: POST /v1/data/<path>
167709
+ const encodedPath = rulePath
167710
+ .split('/')
167711
+ .map(s => encodeURIComponent(s))
167712
+ .join('/');
167713
+ const url = `${this.baseUrl}/v1/data/${encodedPath}`;
167714
+ const controller = new AbortController();
167715
+ const timer = setTimeout(() => controller.abort(), this.timeout);
167716
+ try {
167717
+ const response = await fetch(url, {
167718
+ method: 'POST',
167719
+ headers: { 'Content-Type': 'application/json' },
167720
+ body: JSON.stringify({ input }),
167721
+ signal: controller.signal,
167722
+ });
167723
+ if (!response.ok) {
167724
+ throw new Error(`OPA HTTP ${response.status}: ${response.statusText}`);
167725
+ }
167726
+ let body;
167727
+ try {
167728
+ body = await response.json();
167729
+ }
167730
+ catch (jsonErr) {
167731
+ throw new Error(`OPA HTTP evaluator: failed to parse JSON response: ${jsonErr instanceof Error ? jsonErr.message : String(jsonErr)}`);
167732
+ }
167733
+ // OPA returns { result: { ... } }
167734
+ return body?.result;
167735
+ }
167736
+ finally {
167737
+ clearTimeout(timer);
167738
+ }
167739
+ }
167740
+ async shutdown() {
167741
+ // No persistent connections to close
167742
+ }
167743
+ }
167744
+ exports.OpaHttpEvaluator = OpaHttpEvaluator;
167745
+
167746
+
167747
+ /***/ }),
167748
+
167749
+ /***/ 39530:
167750
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
167751
+
167752
+ "use strict";
167753
+
167754
+ /**
167755
+ * Copyright (c) ProbeLabs. All rights reserved.
167756
+ * Licensed under the Elastic License 2.0; you may not use this file except
167757
+ * in compliance with the Elastic License 2.0.
167758
+ */
167759
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167760
+ exports.OpaPolicyEngine = void 0;
167761
+ const opa_wasm_evaluator_1 = __nccwpck_require__(8613);
167762
+ const opa_http_evaluator_1 = __nccwpck_require__(44693);
167763
+ const policy_input_builder_1 = __nccwpck_require__(17117);
167764
+ /**
167765
+ * Enterprise OPA Policy Engine.
167766
+ *
167767
+ * Wraps both WASM (local) and HTTP (remote) OPA evaluators behind the
167768
+ * OSS PolicyEngine interface. All OPA input building and role resolution
167769
+ * is handled internally — the OSS call sites pass only plain types.
167770
+ */
167771
+ class OpaPolicyEngine {
167772
+ evaluator = null;
167773
+ fallback;
167774
+ timeout;
167775
+ config;
167776
+ inputBuilder = null;
167777
+ logger = null;
167778
+ constructor(config) {
167779
+ this.config = config;
167780
+ this.fallback = config.fallback || 'deny';
167781
+ this.timeout = config.timeout || 5000;
167782
+ }
167783
+ async initialize(config) {
167784
+ // Resolve logger once at initialization
167785
+ try {
167786
+ this.logger = (__nccwpck_require__(86999).logger);
167787
+ }
167788
+ catch {
167789
+ // logger not available in this context
167790
+ }
167791
+ // Build actor/repo context from environment (available at engine init time)
167792
+ const actor = {
167793
+ authorAssociation: process.env.VISOR_AUTHOR_ASSOCIATION,
167794
+ login: process.env.VISOR_AUTHOR_LOGIN || process.env.GITHUB_ACTOR,
167795
+ isLocalMode: !process.env.GITHUB_ACTIONS,
167796
+ };
167797
+ const repo = {
167798
+ owner: process.env.GITHUB_REPOSITORY_OWNER,
167799
+ name: process.env.GITHUB_REPOSITORY?.split('/')[1],
167800
+ branch: process.env.GITHUB_HEAD_REF,
167801
+ baseBranch: process.env.GITHUB_BASE_REF,
167802
+ event: process.env.GITHUB_EVENT_NAME,
167803
+ };
167804
+ const prNum = process.env.GITHUB_PR_NUMBER
167805
+ ? parseInt(process.env.GITHUB_PR_NUMBER, 10)
167806
+ : undefined;
167807
+ const pullRequest = {
167808
+ number: prNum !== undefined && Number.isFinite(prNum) ? prNum : undefined,
167809
+ };
167810
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(config, actor, repo, pullRequest);
167811
+ if (config.engine === 'local') {
167812
+ if (!config.rules) {
167813
+ throw new Error('OPA local mode requires `policy.rules` path to .wasm or .rego files');
167814
+ }
167815
+ const wasm = new opa_wasm_evaluator_1.OpaWasmEvaluator();
167816
+ await wasm.initialize(config.rules);
167817
+ if (config.data) {
167818
+ wasm.loadData(config.data);
167819
+ }
167820
+ this.evaluator = wasm;
167821
+ }
167822
+ else if (config.engine === 'remote') {
167823
+ if (!config.url) {
167824
+ throw new Error('OPA remote mode requires `policy.url` pointing to OPA server');
167825
+ }
167826
+ this.evaluator = new opa_http_evaluator_1.OpaHttpEvaluator(config.url, this.timeout);
167827
+ }
167828
+ else {
167829
+ this.evaluator = null;
167830
+ }
167831
+ }
167832
+ /**
167833
+ * Update actor/repo/PR context (e.g., after PR info becomes available).
167834
+ * Called by the enterprise loader when engine context is enriched.
167835
+ */
167836
+ setActorContext(actor, repo, pullRequest) {
167837
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(this.config, actor, repo, pullRequest);
167838
+ }
167839
+ async evaluateCheckExecution(checkId, checkConfig) {
167840
+ if (!this.evaluator || !this.inputBuilder)
167841
+ return { allowed: true };
167842
+ const cfg = checkConfig && typeof checkConfig === 'object'
167843
+ ? checkConfig
167844
+ : {};
167845
+ const policyOverride = cfg.policy;
167846
+ const input = this.inputBuilder.forCheckExecution({
167847
+ id: checkId,
167848
+ type: cfg.type || 'ai',
167849
+ group: cfg.group,
167850
+ tags: cfg.tags,
167851
+ criticality: cfg.criticality,
167852
+ sandbox: cfg.sandbox,
167853
+ policy: policyOverride,
167854
+ });
167855
+ return this.doEvaluate(input, this.resolveRulePath('check.execute', policyOverride?.rule));
167856
+ }
167857
+ async evaluateToolInvocation(serverName, methodName, transport) {
167858
+ if (!this.evaluator || !this.inputBuilder)
167859
+ return { allowed: true };
167860
+ const input = this.inputBuilder.forToolInvocation(serverName, methodName, transport);
167861
+ return this.doEvaluate(input, 'visor/tool/invoke');
167862
+ }
167863
+ async evaluateCapabilities(checkId, capabilities) {
167864
+ if (!this.evaluator || !this.inputBuilder)
167865
+ return { allowed: true };
167866
+ const input = this.inputBuilder.forCapabilityResolve(checkId, capabilities);
167867
+ return this.doEvaluate(input, 'visor/capability/resolve');
167868
+ }
167869
+ async shutdown() {
167870
+ if (this.evaluator && 'shutdown' in this.evaluator) {
167871
+ await this.evaluator.shutdown();
167872
+ }
167873
+ this.evaluator = null;
167874
+ this.inputBuilder = null;
167875
+ }
167876
+ resolveRulePath(defaultScope, override) {
167877
+ if (override) {
167878
+ return override.startsWith('visor/') ? override : `visor/${override}`;
167879
+ }
167880
+ return `visor/${defaultScope.replace(/\./g, '/')}`;
167881
+ }
167882
+ async doEvaluate(input, rulePath) {
167883
+ try {
167884
+ this.logger?.debug(`[PolicyEngine] Evaluating ${rulePath}`, JSON.stringify(input));
167885
+ let timer;
167886
+ const timeoutPromise = new Promise((_resolve, reject) => {
167887
+ timer = setTimeout(() => reject(new Error('policy evaluation timeout')), this.timeout);
167888
+ });
167889
+ try {
167890
+ const result = await Promise.race([this.rawEvaluate(input, rulePath), timeoutPromise]);
167891
+ const decision = this.parseDecision(result);
167892
+ // In warn mode, override denied decisions to allowed but flag as warn
167893
+ if (!decision.allowed && this.fallback === 'warn') {
167894
+ decision.allowed = true;
167895
+ decision.warn = true;
167896
+ decision.reason = `audit: ${decision.reason || 'policy denied'}`;
167897
+ }
167898
+ this.logger?.debug(`[PolicyEngine] Decision for ${rulePath}: allowed=${decision.allowed}, warn=${decision.warn || false}, reason=${decision.reason || 'none'}`);
167899
+ return decision;
167900
+ }
167901
+ finally {
167902
+ if (timer)
167903
+ clearTimeout(timer);
167904
+ }
167905
+ }
167906
+ catch (err) {
167907
+ const msg = err instanceof Error ? err.message : String(err);
167908
+ this.logger?.warn(`[PolicyEngine] Evaluation failed for ${rulePath}: ${msg}`);
167909
+ return {
167910
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
167911
+ warn: this.fallback === 'warn' ? true : undefined,
167912
+ reason: `policy evaluation failed, fallback=${this.fallback}`,
167913
+ };
167914
+ }
167915
+ }
167916
+ async rawEvaluate(input, rulePath) {
167917
+ if (this.evaluator instanceof opa_wasm_evaluator_1.OpaWasmEvaluator) {
167918
+ const result = await this.evaluator.evaluate(input);
167919
+ // WASM compiled with `-e visor` entrypoint returns the full visor package tree.
167920
+ // Navigate to the specific rule subtree using rulePath segments.
167921
+ // e.g., 'visor/check/execute' → result.check.execute
167922
+ return this.navigateWasmResult(result, rulePath);
167923
+ }
167924
+ return this.evaluator.evaluate(input, rulePath);
167925
+ }
167926
+ /**
167927
+ * Navigate nested OPA WASM result tree to reach the specific rule's output.
167928
+ * The WASM entrypoint `-e visor` means the result root IS the visor package,
167929
+ * so we strip the `visor/` prefix and walk the remaining segments.
167930
+ */
167931
+ navigateWasmResult(result, rulePath) {
167932
+ if (!result || typeof result !== 'object')
167933
+ return result;
167934
+ // Strip the 'visor/' prefix (matches our compilation entrypoint)
167935
+ const segments = rulePath.replace(/^visor\//, '').split('/');
167936
+ let current = result;
167937
+ for (const seg of segments) {
167938
+ if (current && typeof current === 'object' && seg in current) {
167939
+ current = current[seg];
167940
+ }
167941
+ else {
167942
+ return undefined; // path not found in result tree
167943
+ }
167944
+ }
167945
+ return current;
167946
+ }
167947
+ parseDecision(result) {
167948
+ if (result === undefined || result === null) {
167949
+ return {
167950
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
167951
+ warn: this.fallback === 'warn' ? true : undefined,
167952
+ reason: this.fallback === 'warn' ? 'audit: no policy result' : 'no policy result',
167953
+ };
167954
+ }
167955
+ const allowed = result.allowed !== false;
167956
+ const decision = {
167957
+ allowed,
167958
+ reason: result.reason,
167959
+ };
167960
+ if (result.capabilities) {
167961
+ decision.capabilities = result.capabilities;
167962
+ }
167963
+ return decision;
167964
+ }
167965
+ }
167966
+ exports.OpaPolicyEngine = OpaPolicyEngine;
167967
+
167968
+
167969
+ /***/ }),
167970
+
167971
+ /***/ 8613:
167972
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167973
+
167974
+ "use strict";
167975
+
167976
+ /**
167977
+ * Copyright (c) ProbeLabs. All rights reserved.
167978
+ * Licensed under the Elastic License 2.0; you may not use this file except
167979
+ * in compliance with the Elastic License 2.0.
167980
+ */
167981
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167982
+ if (k2 === undefined) k2 = k;
167983
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167984
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167985
+ desc = { enumerable: true, get: function() { return m[k]; } };
167986
+ }
167987
+ Object.defineProperty(o, k2, desc);
167988
+ }) : (function(o, m, k, k2) {
167989
+ if (k2 === undefined) k2 = k;
167990
+ o[k2] = m[k];
167991
+ }));
167992
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167993
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167994
+ }) : function(o, v) {
167995
+ o["default"] = v;
167996
+ });
167997
+ var __importStar = (this && this.__importStar) || (function () {
167998
+ var ownKeys = function(o) {
167999
+ ownKeys = Object.getOwnPropertyNames || function (o) {
168000
+ var ar = [];
168001
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
168002
+ return ar;
168003
+ };
168004
+ return ownKeys(o);
168005
+ };
168006
+ return function (mod) {
168007
+ if (mod && mod.__esModule) return mod;
168008
+ var result = {};
168009
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
168010
+ __setModuleDefault(result, mod);
168011
+ return result;
168012
+ };
168013
+ })();
168014
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168015
+ exports.OpaWasmEvaluator = void 0;
168016
+ const fs = __importStar(__nccwpck_require__(79896));
168017
+ const path = __importStar(__nccwpck_require__(16928));
168018
+ const opa_compiler_1 = __nccwpck_require__(628);
168019
+ /**
168020
+ * OPA WASM Evaluator - loads and evaluates OPA policies locally.
168021
+ *
168022
+ * Supports three input formats:
168023
+ * 1. Pre-compiled `.wasm` bundle — loaded directly (fastest startup)
168024
+ * 2. `.rego` files or directory — auto-compiled to WASM via `opa build` CLI
168025
+ * 3. Directory with `policy.wasm` inside — loaded directly
168026
+ *
168027
+ * Compilation and caching of .rego files is delegated to {@link OpaCompiler}.
168028
+ *
168029
+ * Requires:
168030
+ * - `@open-policy-agent/opa-wasm` npm package (optional dep)
168031
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
168032
+ */
168033
+ class OpaWasmEvaluator {
168034
+ policy = null;
168035
+ dataDocument = {};
168036
+ compiler = new opa_compiler_1.OpaCompiler();
168037
+ async initialize(rulesPath) {
168038
+ const paths = Array.isArray(rulesPath) ? rulesPath : [rulesPath];
168039
+ const wasmBytes = await this.compiler.resolveWasmBytes(paths);
168040
+ try {
168041
+ // Use createRequire to load the optional dep at runtime without ncc bundling it.
168042
+ // `new Function('id', 'return require(id)')` fails in ncc bundles because
168043
+ // `require` is not in the `new Function` scope. `createRequire` works correctly
168044
+ // because it creates a real Node.js require rooted at the given path.
168045
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
168046
+ const { createRequire } = __nccwpck_require__(73339);
168047
+ const runtimeRequire = createRequire(__filename);
168048
+ const opaWasm = runtimeRequire('@open-policy-agent/opa-wasm');
168049
+ const loadPolicy = opaWasm.loadPolicy || opaWasm.default?.loadPolicy;
168050
+ if (!loadPolicy) {
168051
+ throw new Error('loadPolicy not found in @open-policy-agent/opa-wasm');
168052
+ }
168053
+ this.policy = await loadPolicy(wasmBytes);
168054
+ }
168055
+ catch (err) {
168056
+ if (err?.code === 'MODULE_NOT_FOUND' || err?.code === 'ERR_MODULE_NOT_FOUND') {
168057
+ throw new Error('OPA WASM evaluator requires @open-policy-agent/opa-wasm. ' +
168058
+ 'Install it with: npm install @open-policy-agent/opa-wasm');
168059
+ }
168060
+ throw err;
168061
+ }
168062
+ }
168063
+ /**
168064
+ * Load external data from a JSON file to use as the OPA data document.
168065
+ * The loaded data will be passed to `policy.setData()` during evaluation,
168066
+ * making it available in Rego via `data.<key>`.
168067
+ */
168068
+ loadData(dataPath) {
168069
+ const resolved = path.resolve(dataPath);
168070
+ if (path.normalize(resolved).includes('..')) {
168071
+ throw new Error(`Data path contains traversal sequences: ${dataPath}`);
168072
+ }
168073
+ if (!fs.existsSync(resolved)) {
168074
+ throw new Error(`OPA data file not found: ${resolved}`);
168075
+ }
168076
+ const stat = fs.statSync(resolved);
168077
+ if (stat.size > 10 * 1024 * 1024) {
168078
+ throw new Error(`OPA data file exceeds 10MB limit: ${resolved} (${stat.size} bytes)`);
168079
+ }
168080
+ const raw = fs.readFileSync(resolved, 'utf-8');
168081
+ try {
168082
+ const parsed = JSON.parse(raw);
168083
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
168084
+ throw new Error('OPA data file must contain a JSON object (not an array or primitive)');
168085
+ }
168086
+ this.dataDocument = parsed;
168087
+ }
168088
+ catch (err) {
168089
+ if (err.message.startsWith('OPA data file must')) {
168090
+ throw err;
168091
+ }
168092
+ throw new Error(`Failed to parse OPA data file ${resolved}: ${err.message}`);
168093
+ }
168094
+ }
168095
+ async evaluate(input) {
168096
+ if (!this.policy) {
168097
+ throw new Error('OPA WASM evaluator not initialized');
168098
+ }
168099
+ this.policy.setData(this.dataDocument);
168100
+ const resultSet = this.policy.evaluate(input);
168101
+ if (Array.isArray(resultSet) && resultSet.length > 0) {
168102
+ return resultSet[0].result;
168103
+ }
168104
+ return undefined;
168105
+ }
168106
+ async shutdown() {
168107
+ if (this.policy) {
168108
+ // opa-wasm policy objects may have a close/free method for WASM cleanup
168109
+ if (typeof this.policy.close === 'function') {
168110
+ try {
168111
+ this.policy.close();
168112
+ }
168113
+ catch { }
168114
+ }
168115
+ else if (typeof this.policy.free === 'function') {
168116
+ try {
168117
+ this.policy.free();
168118
+ }
168119
+ catch { }
168120
+ }
168121
+ }
168122
+ this.policy = null;
168123
+ }
168124
+ }
168125
+ exports.OpaWasmEvaluator = OpaWasmEvaluator;
168126
+
168127
+
168128
+ /***/ }),
168129
+
168130
+ /***/ 17117:
168131
+ /***/ ((__unused_webpack_module, exports) => {
168132
+
168133
+ "use strict";
168134
+
168135
+ /**
168136
+ * Copyright (c) ProbeLabs. All rights reserved.
168137
+ * Licensed under the Elastic License 2.0; you may not use this file except
168138
+ * in compliance with the Elastic License 2.0.
168139
+ */
168140
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168141
+ exports.PolicyInputBuilder = void 0;
168142
+ /**
168143
+ * Builds OPA-compatible input documents from engine context.
168144
+ *
168145
+ * Resolves actor roles from the `policy.roles` config section by matching
168146
+ * the actor's authorAssociation and login against role definitions.
168147
+ */
168148
+ class PolicyInputBuilder {
168149
+ roles;
168150
+ actor;
168151
+ repository;
168152
+ pullRequest;
168153
+ constructor(policyConfig, actor, repository, pullRequest) {
168154
+ this.roles = policyConfig.roles || {};
168155
+ this.actor = actor;
168156
+ this.repository = repository;
168157
+ this.pullRequest = pullRequest;
168158
+ }
168159
+ /** Resolve which roles apply to the current actor. */
168160
+ resolveRoles() {
168161
+ const matched = [];
168162
+ for (const [roleName, roleConfig] of Object.entries(this.roles)) {
168163
+ let identityMatch = false;
168164
+ if (roleConfig.author_association &&
168165
+ this.actor.authorAssociation &&
168166
+ roleConfig.author_association.includes(this.actor.authorAssociation)) {
168167
+ identityMatch = true;
168168
+ }
168169
+ if (!identityMatch &&
168170
+ roleConfig.users &&
168171
+ this.actor.login &&
168172
+ roleConfig.users.includes(this.actor.login)) {
168173
+ identityMatch = true;
168174
+ }
168175
+ // Slack user ID match
168176
+ if (!identityMatch &&
168177
+ roleConfig.slack_users &&
168178
+ this.actor.slack?.userId &&
168179
+ roleConfig.slack_users.includes(this.actor.slack.userId)) {
168180
+ identityMatch = true;
168181
+ }
168182
+ // Email match (case-insensitive)
168183
+ if (!identityMatch && roleConfig.emails && this.actor.slack?.email) {
168184
+ const actorEmail = this.actor.slack.email.toLowerCase();
168185
+ if (roleConfig.emails.some(e => e.toLowerCase() === actorEmail)) {
168186
+ identityMatch = true;
168187
+ }
168188
+ }
168189
+ // Note: teams-based role resolution requires GitHub API access (read:org scope)
168190
+ // and is not yet implemented. If configured, the role will not match via teams.
168191
+ if (!identityMatch)
168192
+ continue;
168193
+ // slack_channels gate: if set, the role only applies when triggered from one of these channels
168194
+ if (roleConfig.slack_channels && roleConfig.slack_channels.length > 0) {
168195
+ if (!this.actor.slack?.channelId ||
168196
+ !roleConfig.slack_channels.includes(this.actor.slack.channelId)) {
168197
+ continue;
168198
+ }
168199
+ }
168200
+ matched.push(roleName);
168201
+ }
168202
+ return matched;
168203
+ }
168204
+ buildActor() {
168205
+ return {
168206
+ authorAssociation: this.actor.authorAssociation,
168207
+ login: this.actor.login,
168208
+ roles: this.resolveRoles(),
168209
+ isLocalMode: this.actor.isLocalMode,
168210
+ ...(this.actor.slack && { slack: this.actor.slack }),
168211
+ };
168212
+ }
168213
+ forCheckExecution(check) {
168214
+ return {
168215
+ scope: 'check.execute',
168216
+ check: {
168217
+ id: check.id,
168218
+ type: check.type,
168219
+ group: check.group,
168220
+ tags: check.tags,
168221
+ criticality: check.criticality,
168222
+ sandbox: check.sandbox,
168223
+ policy: check.policy,
168224
+ },
168225
+ actor: this.buildActor(),
168226
+ repository: this.repository,
168227
+ pullRequest: this.pullRequest,
168228
+ };
168229
+ }
168230
+ forToolInvocation(serverName, methodName, transport) {
168231
+ return {
168232
+ scope: 'tool.invoke',
168233
+ tool: { serverName, methodName, transport },
168234
+ actor: this.buildActor(),
168235
+ repository: this.repository,
168236
+ pullRequest: this.pullRequest,
168237
+ };
168238
+ }
168239
+ forCapabilityResolve(checkId, capabilities) {
168240
+ return {
168241
+ scope: 'capability.resolve',
168242
+ check: { id: checkId, type: 'ai' },
168243
+ capability: capabilities,
168244
+ actor: this.buildActor(),
168245
+ repository: this.repository,
168246
+ pullRequest: this.pullRequest,
168247
+ };
168248
+ }
168249
+ }
168250
+ exports.PolicyInputBuilder = PolicyInputBuilder;
168251
+
168252
+
168253
+ /***/ }),
168254
+
168255
+ /***/ 63737:
168256
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
168257
+
168258
+ "use strict";
168259
+
168260
+ /**
168261
+ * Copyright (c) ProbeLabs. All rights reserved.
168262
+ * Licensed under the Elastic License 2.0; you may not use this file except
168263
+ * in compliance with the Elastic License 2.0.
168264
+ */
168265
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
168266
+ if (k2 === undefined) k2 = k;
168267
+ var desc = Object.getOwnPropertyDescriptor(m, k);
168268
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
168269
+ desc = { enumerable: true, get: function() { return m[k]; } };
168270
+ }
168271
+ Object.defineProperty(o, k2, desc);
168272
+ }) : (function(o, m, k, k2) {
168273
+ if (k2 === undefined) k2 = k;
168274
+ o[k2] = m[k];
168275
+ }));
168276
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
168277
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
168278
+ }) : function(o, v) {
168279
+ o["default"] = v;
168280
+ });
168281
+ var __importStar = (this && this.__importStar) || (function () {
168282
+ var ownKeys = function(o) {
168283
+ ownKeys = Object.getOwnPropertyNames || function (o) {
168284
+ var ar = [];
168285
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
168286
+ return ar;
168287
+ };
168288
+ return ownKeys(o);
168289
+ };
168290
+ return function (mod) {
168291
+ if (mod && mod.__esModule) return mod;
168292
+ var result = {};
168293
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
168294
+ __setModuleDefault(result, mod);
168295
+ return result;
168296
+ };
168297
+ })();
168298
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168299
+ exports.KnexStoreBackend = void 0;
168300
+ /**
168301
+ * Knex-backed schedule store for PostgreSQL, MySQL, and MSSQL (Enterprise)
168302
+ *
168303
+ * Uses Knex query builder for database-agnostic SQL. Same schema as SQLite backend
168304
+ * but with real distributed locking via row-level claims (claimed_by/claimed_at/lock_token).
168305
+ */
168306
+ const fs = __importStar(__nccwpck_require__(79896));
168307
+ const path = __importStar(__nccwpck_require__(16928));
168308
+ const uuid_1 = __nccwpck_require__(31914);
168309
+ const logger_1 = __nccwpck_require__(86999);
168310
+ function toNum(val) {
168311
+ if (val === null || val === undefined)
168312
+ return undefined;
168313
+ return typeof val === 'string' ? parseInt(val, 10) : val;
168314
+ }
168315
+ function safeJsonParse(value) {
168316
+ if (!value)
168317
+ return undefined;
168318
+ try {
168319
+ return JSON.parse(value);
168320
+ }
168321
+ catch {
168322
+ return undefined;
168323
+ }
168324
+ }
168325
+ function fromTriggerRow(row) {
168326
+ return {
168327
+ id: row.id,
168328
+ creatorId: row.creator_id,
168329
+ creatorContext: row.creator_context ?? undefined,
168330
+ creatorName: row.creator_name ?? undefined,
168331
+ description: row.description ?? undefined,
168332
+ channels: safeJsonParse(row.channels),
168333
+ fromUsers: safeJsonParse(row.from_users),
168334
+ fromBots: row.from_bots === true || row.from_bots === 1,
168335
+ contains: safeJsonParse(row.contains),
168336
+ matchPattern: row.match_pattern ?? undefined,
168337
+ threads: row.threads,
168338
+ workflow: row.workflow,
168339
+ inputs: safeJsonParse(row.inputs),
168340
+ outputContext: safeJsonParse(row.output_context),
168341
+ status: row.status,
168342
+ enabled: row.enabled === true || row.enabled === 1,
168343
+ createdAt: toNum(row.created_at),
168344
+ };
168345
+ }
168346
+ function toTriggerInsertRow(trigger) {
168347
+ return {
168348
+ id: trigger.id,
168349
+ creator_id: trigger.creatorId,
168350
+ creator_context: trigger.creatorContext ?? null,
168351
+ creator_name: trigger.creatorName ?? null,
168352
+ description: trigger.description ?? null,
168353
+ channels: trigger.channels ? JSON.stringify(trigger.channels) : null,
168354
+ from_users: trigger.fromUsers ? JSON.stringify(trigger.fromUsers) : null,
168355
+ from_bots: trigger.fromBots,
168356
+ contains: trigger.contains ? JSON.stringify(trigger.contains) : null,
168357
+ match_pattern: trigger.matchPattern ?? null,
168358
+ threads: trigger.threads,
168359
+ workflow: trigger.workflow,
168360
+ inputs: trigger.inputs ? JSON.stringify(trigger.inputs) : null,
168361
+ output_context: trigger.outputContext ? JSON.stringify(trigger.outputContext) : null,
168362
+ status: trigger.status,
168363
+ enabled: trigger.enabled,
168364
+ created_at: trigger.createdAt,
168365
+ };
168366
+ }
168367
+ function fromDbRow(row) {
168368
+ return {
168369
+ id: row.id,
168370
+ creatorId: row.creator_id,
168371
+ creatorContext: row.creator_context ?? undefined,
168372
+ creatorName: row.creator_name ?? undefined,
168373
+ timezone: row.timezone,
168374
+ schedule: row.schedule_expr,
168375
+ runAt: toNum(row.run_at),
168376
+ isRecurring: row.is_recurring === true || row.is_recurring === 1,
168377
+ originalExpression: row.original_expression,
168378
+ workflow: row.workflow ?? undefined,
168379
+ workflowInputs: safeJsonParse(row.workflow_inputs),
168380
+ outputContext: safeJsonParse(row.output_context),
168381
+ status: row.status,
168382
+ createdAt: toNum(row.created_at),
168383
+ lastRunAt: toNum(row.last_run_at),
168384
+ nextRunAt: toNum(row.next_run_at),
168385
+ runCount: row.run_count,
168386
+ failureCount: row.failure_count,
168387
+ lastError: row.last_error ?? undefined,
168388
+ previousResponse: row.previous_response ?? undefined,
168389
+ };
168390
+ }
168391
+ function toInsertRow(schedule) {
168392
+ return {
168393
+ id: schedule.id,
168394
+ creator_id: schedule.creatorId,
168395
+ creator_context: schedule.creatorContext ?? null,
168396
+ creator_name: schedule.creatorName ?? null,
168397
+ timezone: schedule.timezone,
168398
+ schedule_expr: schedule.schedule,
168399
+ run_at: schedule.runAt ?? null,
168400
+ is_recurring: schedule.isRecurring,
168401
+ original_expression: schedule.originalExpression,
168402
+ workflow: schedule.workflow ?? null,
168403
+ workflow_inputs: schedule.workflowInputs ? JSON.stringify(schedule.workflowInputs) : null,
168404
+ output_context: schedule.outputContext ? JSON.stringify(schedule.outputContext) : null,
168405
+ status: schedule.status,
168406
+ created_at: schedule.createdAt,
168407
+ last_run_at: schedule.lastRunAt ?? null,
168408
+ next_run_at: schedule.nextRunAt ?? null,
168409
+ run_count: schedule.runCount,
168410
+ failure_count: schedule.failureCount,
168411
+ last_error: schedule.lastError ?? null,
168412
+ previous_response: schedule.previousResponse ?? null,
168413
+ };
168414
+ }
168415
+ /**
168416
+ * Enterprise Knex-backed store for PostgreSQL, MySQL, and MSSQL
168417
+ */
168418
+ class KnexStoreBackend {
168419
+ knex = null;
168420
+ driver;
168421
+ connection;
168422
+ constructor(driver, storageConfig, _haConfig) {
168423
+ this.driver = driver;
168424
+ this.connection = (storageConfig.connection || {});
168425
+ }
168426
+ async initialize() {
168427
+ // Load knex dynamically
168428
+ const { createRequire } = __nccwpck_require__(73339);
168429
+ const runtimeRequire = createRequire(__filename);
168430
+ let knexFactory;
168431
+ try {
168432
+ knexFactory = runtimeRequire('knex');
168433
+ }
168434
+ catch (err) {
168435
+ const code = err?.code;
168436
+ if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
168437
+ throw new Error('knex is required for PostgreSQL/MySQL/MSSQL schedule storage. ' +
168438
+ 'Install it with: npm install knex');
168439
+ }
168440
+ throw err;
168441
+ }
168442
+ const clientMap = {
168443
+ postgresql: 'pg',
168444
+ mysql: 'mysql2',
168445
+ mssql: 'tedious',
168446
+ };
168447
+ const client = clientMap[this.driver];
168448
+ // Build connection config
168449
+ let connection;
168450
+ if (this.connection.connection_string) {
168451
+ connection = this.connection.connection_string;
168452
+ }
168453
+ else if (this.driver === 'mssql') {
168454
+ connection = this.buildMssqlConnection();
168455
+ }
168456
+ else {
168457
+ connection = this.buildStandardConnection();
168458
+ }
168459
+ this.knex = knexFactory({
168460
+ client,
168461
+ connection,
168462
+ pool: {
168463
+ min: this.connection.pool?.min ?? 0,
168464
+ max: this.connection.pool?.max ?? 10,
168465
+ },
168466
+ });
168467
+ // Run schema migration
168468
+ await this.migrateSchema();
168469
+ logger_1.logger.info(`[KnexStore] Initialized (${this.driver})`);
168470
+ }
168471
+ buildStandardConnection() {
168472
+ return {
168473
+ host: this.connection.host || 'localhost',
168474
+ port: this.connection.port,
168475
+ database: this.connection.database || 'visor',
168476
+ user: this.connection.user,
168477
+ password: this.connection.password,
168478
+ ssl: this.resolveSslConfig(),
168479
+ };
168480
+ }
168481
+ buildMssqlConnection() {
168482
+ const ssl = this.connection.ssl;
168483
+ const sslEnabled = ssl === true || (typeof ssl === 'object' && ssl.enabled !== false);
168484
+ return {
168485
+ server: this.connection.host || 'localhost',
168486
+ port: this.connection.port,
168487
+ database: this.connection.database || 'visor',
168488
+ user: this.connection.user,
168489
+ password: this.connection.password,
168490
+ options: {
168491
+ encrypt: sslEnabled,
168492
+ trustServerCertificate: typeof ssl === 'object' ? ssl.reject_unauthorized === false : !sslEnabled,
168493
+ },
168494
+ };
168495
+ }
168496
+ resolveSslConfig() {
168497
+ const ssl = this.connection.ssl;
168498
+ if (ssl === false || ssl === undefined)
168499
+ return false;
168500
+ if (ssl === true)
168501
+ return { rejectUnauthorized: true };
168502
+ // Object config
168503
+ if (ssl.enabled === false)
168504
+ return false;
168505
+ const result = {
168506
+ rejectUnauthorized: ssl.reject_unauthorized !== false,
168507
+ };
168508
+ if (ssl.ca) {
168509
+ const caPath = this.validateSslPath(ssl.ca, 'CA certificate');
168510
+ result.ca = fs.readFileSync(caPath, 'utf8');
168511
+ }
168512
+ if (ssl.cert) {
168513
+ const certPath = this.validateSslPath(ssl.cert, 'client certificate');
168514
+ result.cert = fs.readFileSync(certPath, 'utf8');
168515
+ }
168516
+ if (ssl.key) {
168517
+ const keyPath = this.validateSslPath(ssl.key, 'client key');
168518
+ result.key = fs.readFileSync(keyPath, 'utf8');
168519
+ }
168520
+ return result;
168521
+ }
168522
+ validateSslPath(filePath, label) {
168523
+ const resolved = path.resolve(filePath);
168524
+ if (resolved !== path.normalize(resolved)) {
168525
+ throw new Error(`SSL ${label} path contains invalid sequences: ${filePath}`);
168526
+ }
168527
+ if (!fs.existsSync(resolved)) {
168528
+ throw new Error(`SSL ${label} not found: ${filePath}`);
168529
+ }
168530
+ return resolved;
168531
+ }
168532
+ async shutdown() {
168533
+ if (this.knex) {
168534
+ await this.knex.destroy();
168535
+ this.knex = null;
168536
+ }
168537
+ }
168538
+ async migrateSchema() {
168539
+ const knex = this.getKnex();
168540
+ const exists = await knex.schema.hasTable('schedules');
168541
+ if (!exists) {
168542
+ await knex.schema.createTable('schedules', table => {
168543
+ table.string('id', 36).primary();
168544
+ table.string('creator_id', 255).notNullable().index();
168545
+ table.string('creator_context', 255);
168546
+ table.string('creator_name', 255);
168547
+ table.string('timezone', 64).notNullable().defaultTo('UTC');
168548
+ table.string('schedule_expr', 255);
168549
+ table.bigInteger('run_at');
168550
+ table.boolean('is_recurring').notNullable();
168551
+ table.text('original_expression');
168552
+ table.string('workflow', 255);
168553
+ table.text('workflow_inputs');
168554
+ table.text('output_context');
168555
+ table.string('status', 20).notNullable().index();
168556
+ table.bigInteger('created_at').notNullable();
168557
+ table.bigInteger('last_run_at');
168558
+ table.bigInteger('next_run_at');
168559
+ table.integer('run_count').notNullable().defaultTo(0);
168560
+ table.integer('failure_count').notNullable().defaultTo(0);
168561
+ table.text('last_error');
168562
+ table.text('previous_response');
168563
+ table.index(['status', 'next_run_at']);
168564
+ });
168565
+ }
168566
+ // Create message_triggers table
168567
+ const triggersExist = await knex.schema.hasTable('message_triggers');
168568
+ if (!triggersExist) {
168569
+ await knex.schema.createTable('message_triggers', table => {
168570
+ table.string('id', 36).primary();
168571
+ table.string('creator_id', 255).notNullable().index();
168572
+ table.string('creator_context', 255);
168573
+ table.string('creator_name', 255);
168574
+ table.text('description');
168575
+ table.text('channels'); // JSON array
168576
+ table.text('from_users'); // JSON array
168577
+ table.boolean('from_bots').notNullable().defaultTo(false);
168578
+ table.text('contains'); // JSON array
168579
+ table.text('match_pattern');
168580
+ table.string('threads', 20).notNullable().defaultTo('any');
168581
+ table.string('workflow', 255).notNullable();
168582
+ table.text('inputs'); // JSON
168583
+ table.text('output_context'); // JSON
168584
+ table.string('status', 20).notNullable().defaultTo('active').index();
168585
+ table.boolean('enabled').notNullable().defaultTo(true);
168586
+ table.bigInteger('created_at').notNullable();
168587
+ });
168588
+ }
168589
+ // Create scheduler_locks table for distributed locking
168590
+ const locksExist = await knex.schema.hasTable('scheduler_locks');
168591
+ if (!locksExist) {
168592
+ await knex.schema.createTable('scheduler_locks', table => {
168593
+ table.string('lock_id', 255).primary();
168594
+ table.string('node_id', 255).notNullable();
168595
+ table.string('lock_token', 36).notNullable();
168596
+ table.bigInteger('acquired_at').notNullable();
168597
+ table.bigInteger('expires_at').notNullable();
168598
+ });
168599
+ }
168600
+ }
168601
+ getKnex() {
168602
+ if (!this.knex) {
168603
+ throw new Error('[KnexStore] Not initialized. Call initialize() first.');
168604
+ }
168605
+ return this.knex;
168606
+ }
168607
+ // --- CRUD ---
168608
+ async create(schedule) {
168609
+ const knex = this.getKnex();
168610
+ const newSchedule = {
168611
+ ...schedule,
168612
+ id: (0, uuid_1.v4)(),
168613
+ createdAt: Date.now(),
168614
+ runCount: 0,
168615
+ failureCount: 0,
168616
+ status: 'active',
168617
+ };
168618
+ await knex('schedules').insert(toInsertRow(newSchedule));
168619
+ logger_1.logger.info(`[KnexStore] Created schedule ${newSchedule.id} for user ${newSchedule.creatorId}`);
168620
+ return newSchedule;
168621
+ }
168622
+ async importSchedule(schedule) {
168623
+ const knex = this.getKnex();
168624
+ const existing = await knex('schedules').where('id', schedule.id).first();
168625
+ if (existing)
168626
+ return; // Already imported (idempotent)
168627
+ await knex('schedules').insert(toInsertRow(schedule));
168628
+ }
168629
+ async get(id) {
168630
+ const knex = this.getKnex();
168631
+ const row = await knex('schedules').where('id', id).first();
168632
+ return row ? fromDbRow(row) : undefined;
168633
+ }
168634
+ async update(id, patch) {
168635
+ const knex = this.getKnex();
168636
+ const existing = await knex('schedules').where('id', id).first();
168637
+ if (!existing)
168638
+ return undefined;
168639
+ const current = fromDbRow(existing);
168640
+ const updated = { ...current, ...patch, id: current.id };
168641
+ const row = toInsertRow(updated);
168642
+ // Remove id from update (PK cannot change)
168643
+ delete row.id;
168644
+ await knex('schedules').where('id', id).update(row);
168645
+ return updated;
168646
+ }
168647
+ async delete(id) {
168648
+ const knex = this.getKnex();
168649
+ const deleted = await knex('schedules').where('id', id).del();
168650
+ if (deleted > 0) {
168651
+ logger_1.logger.info(`[KnexStore] Deleted schedule ${id}`);
168652
+ return true;
168653
+ }
168654
+ return false;
168655
+ }
168656
+ // --- Queries ---
168657
+ async getByCreator(creatorId) {
168658
+ const knex = this.getKnex();
168659
+ const rows = await knex('schedules').where('creator_id', creatorId);
168660
+ return rows.map((r) => fromDbRow(r));
168661
+ }
168662
+ async getActiveSchedules() {
168663
+ const knex = this.getKnex();
168664
+ const rows = await knex('schedules').where('status', 'active');
168665
+ return rows.map((r) => fromDbRow(r));
168666
+ }
168667
+ async getDueSchedules(now) {
168668
+ const ts = now ?? Date.now();
168669
+ const knex = this.getKnex();
168670
+ // MSSQL uses 1/0 for booleans
168671
+ const bFalse = this.driver === 'mssql' ? 0 : false;
168672
+ const bTrue = this.driver === 'mssql' ? 1 : true;
168673
+ const rows = await knex('schedules')
168674
+ .where('status', 'active')
168675
+ .andWhere(function () {
168676
+ this.where(function () {
168677
+ this.where('is_recurring', bFalse)
168678
+ .whereNotNull('run_at')
168679
+ .where('run_at', '<=', ts);
168680
+ }).orWhere(function () {
168681
+ this.where('is_recurring', bTrue)
168682
+ .whereNotNull('next_run_at')
168683
+ .where('next_run_at', '<=', ts);
168684
+ });
168685
+ });
168686
+ return rows.map((r) => fromDbRow(r));
168687
+ }
168688
+ async findByWorkflow(creatorId, workflowName) {
168689
+ const knex = this.getKnex();
168690
+ const escaped = workflowName.toLowerCase().replace(/[%_\\]/g, '\\$&');
168691
+ const pattern = `%${escaped}%`;
168692
+ const rows = await knex('schedules')
168693
+ .where('creator_id', creatorId)
168694
+ .where('status', 'active')
168695
+ .whereRaw("LOWER(workflow) LIKE ? ESCAPE '\\'", [pattern]);
168696
+ return rows.map((r) => fromDbRow(r));
168697
+ }
168698
+ async getAll() {
168699
+ const knex = this.getKnex();
168700
+ const rows = await knex('schedules');
168701
+ return rows.map((r) => fromDbRow(r));
168702
+ }
168703
+ async getStats() {
168704
+ const knex = this.getKnex();
168705
+ // MSSQL uses 1/0 for booleans; PostgreSQL/MySQL accept both true/1
168706
+ const boolTrue = this.driver === 'mssql' ? '1' : 'true';
168707
+ const boolFalse = this.driver === 'mssql' ? '0' : 'false';
168708
+ const result = await knex('schedules')
168709
+ .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`))
168710
+ .first();
168711
+ return {
168712
+ total: Number(result.total) || 0,
168713
+ active: Number(result.active) || 0,
168714
+ paused: Number(result.paused) || 0,
168715
+ completed: Number(result.completed) || 0,
168716
+ failed: Number(result.failed) || 0,
168717
+ recurring: Number(result.recurring) || 0,
168718
+ oneTime: Number(result.one_time) || 0,
168719
+ };
168720
+ }
168721
+ async validateLimits(creatorId, isRecurring, limits) {
168722
+ const knex = this.getKnex();
168723
+ if (limits.maxGlobal) {
168724
+ const result = await knex('schedules').count('* as cnt').first();
168725
+ if (Number(result?.cnt) >= limits.maxGlobal) {
168726
+ throw new Error(`Global schedule limit reached (${limits.maxGlobal})`);
168727
+ }
168728
+ }
168729
+ if (limits.maxPerUser) {
168730
+ const result = await knex('schedules')
168731
+ .where('creator_id', creatorId)
168732
+ .count('* as cnt')
168733
+ .first();
168734
+ if (Number(result?.cnt) >= limits.maxPerUser) {
168735
+ throw new Error(`You have reached the maximum number of schedules (${limits.maxPerUser})`);
168736
+ }
168737
+ }
168738
+ if (isRecurring && limits.maxRecurringPerUser) {
168739
+ const bTrue = this.driver === 'mssql' ? 1 : true;
168740
+ const result = await knex('schedules')
168741
+ .where('creator_id', creatorId)
168742
+ .where('is_recurring', bTrue)
168743
+ .count('* as cnt')
168744
+ .first();
168745
+ if (Number(result?.cnt) >= limits.maxRecurringPerUser) {
168746
+ throw new Error(`You have reached the maximum number of recurring schedules (${limits.maxRecurringPerUser})`);
168747
+ }
168748
+ }
168749
+ }
168750
+ // --- HA Distributed Locking (via scheduler_locks table) ---
168751
+ async tryAcquireLock(lockId, nodeId, ttlSeconds) {
168752
+ const knex = this.getKnex();
168753
+ const now = Date.now();
168754
+ const expiresAt = now + ttlSeconds * 1000;
168755
+ const token = (0, uuid_1.v4)();
168756
+ // Step 1: Try to claim an existing expired lock
168757
+ const updated = await knex('scheduler_locks')
168758
+ .where('lock_id', lockId)
168759
+ .where('expires_at', '<', now)
168760
+ .update({
168761
+ node_id: nodeId,
168762
+ lock_token: token,
168763
+ acquired_at: now,
168764
+ expires_at: expiresAt,
168765
+ });
168766
+ if (updated > 0)
168767
+ return token;
168768
+ // Step 2: Try to INSERT a new lock row
168769
+ try {
168770
+ await knex('scheduler_locks').insert({
168771
+ lock_id: lockId,
168772
+ node_id: nodeId,
168773
+ lock_token: token,
168774
+ acquired_at: now,
168775
+ expires_at: expiresAt,
168776
+ });
168777
+ return token;
168778
+ }
168779
+ catch {
168780
+ // Unique constraint violation — another node holds the lock
168781
+ return null;
168782
+ }
168783
+ }
168784
+ async releaseLock(lockId, lockToken) {
168785
+ const knex = this.getKnex();
168786
+ await knex('scheduler_locks').where('lock_id', lockId).where('lock_token', lockToken).del();
168787
+ }
168788
+ async renewLock(lockId, lockToken, ttlSeconds) {
168789
+ const knex = this.getKnex();
168790
+ const now = Date.now();
168791
+ const expiresAt = now + ttlSeconds * 1000;
168792
+ const updated = await knex('scheduler_locks')
168793
+ .where('lock_id', lockId)
168794
+ .where('lock_token', lockToken)
168795
+ .update({ acquired_at: now, expires_at: expiresAt });
168796
+ return updated > 0;
168797
+ }
168798
+ async flush() {
168799
+ // No-op for server-based backends
168800
+ }
168801
+ // --- Message Trigger CRUD ---
168802
+ async createTrigger(trigger) {
168803
+ const knex = this.getKnex();
168804
+ const newTrigger = {
168805
+ ...trigger,
168806
+ id: (0, uuid_1.v4)(),
168807
+ createdAt: Date.now(),
168808
+ };
168809
+ await knex('message_triggers').insert(toTriggerInsertRow(newTrigger));
168810
+ logger_1.logger.info(`[KnexStore] Created trigger ${newTrigger.id} for user ${newTrigger.creatorId}`);
168811
+ return newTrigger;
168812
+ }
168813
+ async getTrigger(id) {
168814
+ const knex = this.getKnex();
168815
+ const row = await knex('message_triggers').where('id', id).first();
168816
+ return row ? fromTriggerRow(row) : undefined;
168817
+ }
168818
+ async updateTrigger(id, patch) {
168819
+ const knex = this.getKnex();
168820
+ const existing = await knex('message_triggers').where('id', id).first();
168821
+ if (!existing)
168822
+ return undefined;
168823
+ const current = fromTriggerRow(existing);
168824
+ const updated = {
168825
+ ...current,
168826
+ ...patch,
168827
+ id: current.id,
168828
+ createdAt: current.createdAt,
168829
+ };
168830
+ const row = toTriggerInsertRow(updated);
168831
+ delete row.id;
168832
+ await knex('message_triggers').where('id', id).update(row);
168833
+ return updated;
168834
+ }
168835
+ async deleteTrigger(id) {
168836
+ const knex = this.getKnex();
168837
+ const deleted = await knex('message_triggers').where('id', id).del();
168838
+ if (deleted > 0) {
168839
+ logger_1.logger.info(`[KnexStore] Deleted trigger ${id}`);
168840
+ return true;
168841
+ }
168842
+ return false;
168843
+ }
168844
+ async getTriggersByCreator(creatorId) {
168845
+ const knex = this.getKnex();
168846
+ const rows = await knex('message_triggers').where('creator_id', creatorId);
168847
+ return rows.map((r) => fromTriggerRow(r));
168848
+ }
168849
+ async getActiveTriggers() {
168850
+ const knex = this.getKnex();
168851
+ const rows = await knex('message_triggers')
168852
+ .where('status', 'active')
168853
+ .where('enabled', this.driver === 'mssql' ? 1 : true);
168854
+ return rows.map((r) => fromTriggerRow(r));
168855
+ }
168856
+ }
168857
+ exports.KnexStoreBackend = KnexStoreBackend;
168858
+
168859
+
167056
168860
  /***/ }),
167057
168861
 
167058
168862
  /***/ 83864:
@@ -178026,6 +179830,35 @@ class OutputFormatters {
178026
179830
  exports.OutputFormatters = OutputFormatters;
178027
179831
 
178028
179832
 
179833
+ /***/ }),
179834
+
179835
+ /***/ 93866:
179836
+ /***/ ((__unused_webpack_module, exports) => {
179837
+
179838
+ "use strict";
179839
+
179840
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
179841
+ exports.DefaultPolicyEngine = void 0;
179842
+ /**
179843
+ * Default (no-op) policy engine — always allows everything.
179844
+ * Used when no enterprise license is present or policy is disabled.
179845
+ */
179846
+ class DefaultPolicyEngine {
179847
+ async initialize(_config) { }
179848
+ async evaluateCheckExecution(_checkId, _checkConfig) {
179849
+ return { allowed: true };
179850
+ }
179851
+ async evaluateToolInvocation(_serverName, _methodName, _transport) {
179852
+ return { allowed: true };
179853
+ }
179854
+ async evaluateCapabilities(_checkId, _capabilities) {
179855
+ return { allowed: true };
179856
+ }
179857
+ async shutdown() { }
179858
+ }
179859
+ exports.DefaultPolicyEngine = DefaultPolicyEngine;
179860
+
179861
+
178029
179862
  /***/ }),
178030
179863
 
178031
179864
  /***/ 96611:
@@ -199642,7 +201475,7 @@ class StateMachineExecutionEngine {
199642
201475
  try {
199643
201476
  logger_1.logger.debug(`[PolicyEngine] Loading enterprise policy engine (engine=${configWithTagFilter.policy.engine})`);
199644
201477
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
199645
- const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(7065)));
201478
+ const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(87068)));
199646
201479
  context.policyEngine = await loadEnterprisePolicyEngine(configWithTagFilter.policy);
199647
201480
  logger_1.logger.debug(`[PolicyEngine] Initialized: ${context.policyEngine?.constructor?.name || 'unknown'}`);
199648
201481
  }
@@ -209913,7 +211746,7 @@ async function initTelemetry(opts = {}) {
209913
211746
  const path = __nccwpck_require__(16928);
209914
211747
  const outDir = opts.file?.dir ||
209915
211748
  process.env.VISOR_TRACE_DIR ||
209916
- __nccwpck_require__.ab + "traces";
211749
+ path.join(process.cwd(), 'output', 'traces');
209917
211750
  fs.mkdirSync(outDir, { recursive: true });
209918
211751
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
209919
211752
  process.env.VISOR_FALLBACK_TRACE_FILE = path.join(outDir, `run-${ts}.ndjson`);
@@ -210118,7 +211951,7 @@ async function shutdownTelemetry() {
210118
211951
  if (process.env.VISOR_TRACE_REPORT === 'true') {
210119
211952
  const fs = __nccwpck_require__(79896);
210120
211953
  const path = __nccwpck_require__(16928);
210121
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
211954
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
210122
211955
  if (!fs.existsSync(outDir))
210123
211956
  fs.mkdirSync(outDir, { recursive: true });
210124
211957
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
@@ -210617,7 +212450,7 @@ function __getOrCreateNdjsonPath() {
210617
212450
  fs.mkdirSync(dir, { recursive: true });
210618
212451
  return __ndjsonPath;
210619
212452
  }
210620
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
212453
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
210621
212454
  if (!fs.existsSync(outDir))
210622
212455
  fs.mkdirSync(outDir, { recursive: true });
210623
212456
  if (!__ndjsonPath) {
@@ -224571,22 +226404,6 @@ class WorkflowRegistry {
224571
226404
  exports.WorkflowRegistry = WorkflowRegistry;
224572
226405
 
224573
226406
 
224574
- /***/ }),
224575
-
224576
- /***/ 7065:
224577
- /***/ ((module) => {
224578
-
224579
- module.exports = eval("require")("./enterprise/loader");
224580
-
224581
-
224582
- /***/ }),
224583
-
224584
- /***/ 71370:
224585
- /***/ ((module) => {
224586
-
224587
- module.exports = eval("require")("./enterprise/policy/policy-input-builder");
224588
-
224589
-
224590
226407
  /***/ }),
224591
226408
 
224592
226409
  /***/ 18327:
@@ -260861,7 +262678,7 @@ var require_fxp = __commonJS({
260861
262678
  }, o: (t6, e6) => Object.prototype.hasOwnProperty.call(t6, e6), r: (t6) => {
260862
262679
  "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t6, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t6, "__esModule", { value: true });
260863
262680
  } }, e5 = {};
260864
- t5.r(e5), t5.d(e5, { XMLBuilder: () => dt, XMLParser: () => it, XMLValidator: () => gt });
262681
+ t5.r(e5), t5.d(e5, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt });
260865
262682
  const n5 = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i5 = new RegExp("^[" + n5 + "][" + n5 + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");
260866
262683
  function s5(t6, e6) {
260867
262684
  const n6 = [];
@@ -260883,90 +262700,90 @@ var require_fxp = __commonJS({
260883
262700
  const n6 = [];
260884
262701
  let i6 = false, s6 = false;
260885
262702
  "\uFEFF" === t6[0] && (t6 = t6.substr(1));
260886
- for (let o6 = 0; o6 < t6.length; o6++) if ("<" === t6[o6] && "?" === t6[o6 + 1]) {
260887
- if (o6 += 2, o6 = u5(t6, o6), o6.err) return o6;
262703
+ for (let r6 = 0; r6 < t6.length; r6++) if ("<" === t6[r6] && "?" === t6[r6 + 1]) {
262704
+ if (r6 += 2, r6 = u5(t6, r6), r6.err) return r6;
260888
262705
  } else {
260889
- if ("<" !== t6[o6]) {
260890
- if (l5(t6[o6])) continue;
260891
- return m5("InvalidChar", "char '" + t6[o6] + "' is not expected.", b5(t6, o6));
262706
+ if ("<" !== t6[r6]) {
262707
+ if (l5(t6[r6])) continue;
262708
+ return m5("InvalidChar", "char '" + t6[r6] + "' is not expected.", N(t6, r6));
260892
262709
  }
260893
262710
  {
260894
- let a6 = o6;
260895
- if (o6++, "!" === t6[o6]) {
260896
- o6 = h5(t6, o6);
262711
+ let o6 = r6;
262712
+ if (r6++, "!" === t6[r6]) {
262713
+ r6 = d5(t6, r6);
260897
262714
  continue;
260898
262715
  }
260899
262716
  {
260900
- let d6 = false;
260901
- "/" === t6[o6] && (d6 = true, o6++);
260902
- let p6 = "";
260903
- for (; o6 < t6.length && ">" !== t6[o6] && " " !== t6[o6] && " " !== t6[o6] && "\n" !== t6[o6] && "\r" !== t6[o6]; o6++) p6 += t6[o6];
260904
- if (p6 = p6.trim(), "/" === p6[p6.length - 1] && (p6 = p6.substring(0, p6.length - 1), o6--), !r5(p6)) {
262717
+ let a6 = false;
262718
+ "/" === t6[r6] && (a6 = true, r6++);
262719
+ let h6 = "";
262720
+ for (; r6 < t6.length && ">" !== t6[r6] && " " !== t6[r6] && " " !== t6[r6] && "\n" !== t6[r6] && "\r" !== t6[r6]; r6++) h6 += t6[r6];
262721
+ if (h6 = h6.trim(), "/" === h6[h6.length - 1] && (h6 = h6.substring(0, h6.length - 1), r6--), !b5(h6)) {
260905
262722
  let e7;
260906
- return e7 = 0 === p6.trim().length ? "Invalid space after '<'." : "Tag '" + p6 + "' is an invalid name.", m5("InvalidTag", e7, b5(t6, o6));
262723
+ return e7 = 0 === h6.trim().length ? "Invalid space after '<'." : "Tag '" + h6 + "' is an invalid name.", m5("InvalidTag", e7, N(t6, r6));
260907
262724
  }
260908
- const c6 = f5(t6, o6);
260909
- if (false === c6) return m5("InvalidAttr", "Attributes for '" + p6 + "' have open quote.", b5(t6, o6));
260910
- let E3 = c6.value;
260911
- if (o6 = c6.index, "/" === E3[E3.length - 1]) {
260912
- const n7 = o6 - E3.length;
260913
- E3 = E3.substring(0, E3.length - 1);
260914
- const s7 = g5(E3, e6);
260915
- if (true !== s7) return m5(s7.err.code, s7.err.msg, b5(t6, n7 + s7.err.line));
262725
+ const p6 = c5(t6, r6);
262726
+ if (false === p6) return m5("InvalidAttr", "Attributes for '" + h6 + "' have open quote.", N(t6, r6));
262727
+ let f6 = p6.value;
262728
+ if (r6 = p6.index, "/" === f6[f6.length - 1]) {
262729
+ const n7 = r6 - f6.length;
262730
+ f6 = f6.substring(0, f6.length - 1);
262731
+ const s7 = g5(f6, e6);
262732
+ if (true !== s7) return m5(s7.err.code, s7.err.msg, N(t6, n7 + s7.err.line));
260916
262733
  i6 = true;
260917
- } else if (d6) {
260918
- if (!c6.tagClosed) return m5("InvalidTag", "Closing tag '" + p6 + "' doesn't have proper closing.", b5(t6, o6));
260919
- if (E3.trim().length > 0) return m5("InvalidTag", "Closing tag '" + p6 + "' can't have attributes or invalid starting.", b5(t6, a6));
260920
- if (0 === n6.length) return m5("InvalidTag", "Closing tag '" + p6 + "' has not been opened.", b5(t6, a6));
262734
+ } else if (a6) {
262735
+ if (!p6.tagClosed) return m5("InvalidTag", "Closing tag '" + h6 + "' doesn't have proper closing.", N(t6, r6));
262736
+ if (f6.trim().length > 0) return m5("InvalidTag", "Closing tag '" + h6 + "' can't have attributes or invalid starting.", N(t6, o6));
262737
+ if (0 === n6.length) return m5("InvalidTag", "Closing tag '" + h6 + "' has not been opened.", N(t6, o6));
260921
262738
  {
260922
262739
  const e7 = n6.pop();
260923
- if (p6 !== e7.tagName) {
260924
- let n7 = b5(t6, e7.tagStartPos);
260925
- return m5("InvalidTag", "Expected closing tag '" + e7.tagName + "' (opened in line " + n7.line + ", col " + n7.col + ") instead of closing tag '" + p6 + "'.", b5(t6, a6));
262740
+ if (h6 !== e7.tagName) {
262741
+ let n7 = N(t6, e7.tagStartPos);
262742
+ return m5("InvalidTag", "Expected closing tag '" + e7.tagName + "' (opened in line " + n7.line + ", col " + n7.col + ") instead of closing tag '" + h6 + "'.", N(t6, o6));
260926
262743
  }
260927
262744
  0 == n6.length && (s6 = true);
260928
262745
  }
260929
262746
  } else {
260930
- const r6 = g5(E3, e6);
260931
- if (true !== r6) return m5(r6.err.code, r6.err.msg, b5(t6, o6 - E3.length + r6.err.line));
260932
- if (true === s6) return m5("InvalidXml", "Multiple possible root nodes found.", b5(t6, o6));
260933
- -1 !== e6.unpairedTags.indexOf(p6) || n6.push({ tagName: p6, tagStartPos: a6 }), i6 = true;
262747
+ const a7 = g5(f6, e6);
262748
+ if (true !== a7) return m5(a7.err.code, a7.err.msg, N(t6, r6 - f6.length + a7.err.line));
262749
+ if (true === s6) return m5("InvalidXml", "Multiple possible root nodes found.", N(t6, r6));
262750
+ -1 !== e6.unpairedTags.indexOf(h6) || n6.push({ tagName: h6, tagStartPos: o6 }), i6 = true;
260934
262751
  }
260935
- for (o6++; o6 < t6.length; o6++) if ("<" === t6[o6]) {
260936
- if ("!" === t6[o6 + 1]) {
260937
- o6++, o6 = h5(t6, o6);
262752
+ for (r6++; r6 < t6.length; r6++) if ("<" === t6[r6]) {
262753
+ if ("!" === t6[r6 + 1]) {
262754
+ r6++, r6 = d5(t6, r6);
260938
262755
  continue;
260939
262756
  }
260940
- if ("?" !== t6[o6 + 1]) break;
260941
- if (o6 = u5(t6, ++o6), o6.err) return o6;
260942
- } else if ("&" === t6[o6]) {
260943
- const e7 = x5(t6, o6);
260944
- if (-1 == e7) return m5("InvalidChar", "char '&' is not expected.", b5(t6, o6));
260945
- o6 = e7;
260946
- } else if (true === s6 && !l5(t6[o6])) return m5("InvalidXml", "Extra text at the end", b5(t6, o6));
260947
- "<" === t6[o6] && o6--;
262757
+ if ("?" !== t6[r6 + 1]) break;
262758
+ if (r6 = u5(t6, ++r6), r6.err) return r6;
262759
+ } else if ("&" === t6[r6]) {
262760
+ const e7 = x5(t6, r6);
262761
+ if (-1 == e7) return m5("InvalidChar", "char '&' is not expected.", N(t6, r6));
262762
+ r6 = e7;
262763
+ } else if (true === s6 && !l5(t6[r6])) return m5("InvalidXml", "Extra text at the end", N(t6, r6));
262764
+ "<" === t6[r6] && r6--;
260948
262765
  }
260949
262766
  }
260950
262767
  }
260951
- return i6 ? 1 == n6.length ? m5("InvalidTag", "Unclosed tag '" + n6[0].tagName + "'.", b5(t6, n6[0].tagStartPos)) : !(n6.length > 0) || m5("InvalidXml", "Invalid '" + JSON.stringify(n6.map(((t7) => t7.tagName)), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m5("InvalidXml", "Start tag expected.", 1);
262768
+ return i6 ? 1 == n6.length ? m5("InvalidTag", "Unclosed tag '" + n6[0].tagName + "'.", N(t6, n6[0].tagStartPos)) : !(n6.length > 0) || m5("InvalidXml", "Invalid '" + JSON.stringify(n6.map((t7) => t7.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m5("InvalidXml", "Start tag expected.", 1);
260952
262769
  }
260953
262770
  function l5(t6) {
260954
262771
  return " " === t6 || " " === t6 || "\n" === t6 || "\r" === t6;
260955
262772
  }
260956
262773
  function u5(t6, e6) {
260957
262774
  const n6 = e6;
260958
- for (; e6 < t6.length; e6++) if ("?" != t6[e6] && " " != t6[e6]) ;
260959
- else {
262775
+ for (; e6 < t6.length; e6++) if ("?" == t6[e6] || " " == t6[e6]) {
260960
262776
  const i6 = t6.substr(n6, e6 - n6);
260961
- if (e6 > 5 && "xml" === i6) return m5("InvalidXml", "XML declaration allowed only at the start of the document.", b5(t6, e6));
262777
+ if (e6 > 5 && "xml" === i6) return m5("InvalidXml", "XML declaration allowed only at the start of the document.", N(t6, e6));
260962
262778
  if ("?" == t6[e6] && ">" == t6[e6 + 1]) {
260963
262779
  e6++;
260964
262780
  break;
260965
262781
  }
262782
+ continue;
260966
262783
  }
260967
262784
  return e6;
260968
262785
  }
260969
- function h5(t6, e6) {
262786
+ function d5(t6, e6) {
260970
262787
  if (t6.length > e6 + 5 && "-" === t6[e6 + 1] && "-" === t6[e6 + 2]) {
260971
262788
  for (e6 += 3; e6 < t6.length; e6++) if ("-" === t6[e6] && "-" === t6[e6 + 1] && ">" === t6[e6 + 2]) {
260972
262789
  e6 += 2;
@@ -260984,11 +262801,11 @@ var require_fxp = __commonJS({
260984
262801
  }
260985
262802
  return e6;
260986
262803
  }
260987
- const d5 = '"', p5 = "'";
260988
- function f5(t6, e6) {
262804
+ const h5 = '"', p5 = "'";
262805
+ function c5(t6, e6) {
260989
262806
  let n6 = "", i6 = "", s6 = false;
260990
262807
  for (; e6 < t6.length; e6++) {
260991
- if (t6[e6] === d5 || t6[e6] === p5) "" === i6 ? i6 = t6[e6] : i6 !== t6[e6] || (i6 = "");
262808
+ if (t6[e6] === h5 || t6[e6] === p5) "" === i6 ? i6 = t6[e6] : i6 !== t6[e6] || (i6 = "");
260992
262809
  else if (">" === t6[e6] && "" === i6) {
260993
262810
  s6 = true;
260994
262811
  break;
@@ -260997,16 +262814,16 @@ var require_fxp = __commonJS({
260997
262814
  }
260998
262815
  return "" === i6 && { value: n6, index: e6, tagClosed: s6 };
260999
262816
  }
261000
- const c5 = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
262817
+ const f5 = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
261001
262818
  function g5(t6, e6) {
261002
- const n6 = s5(t6, c5), i6 = {};
262819
+ const n6 = s5(t6, f5), i6 = {};
261003
262820
  for (let t7 = 0; t7 < n6.length; t7++) {
261004
- if (0 === n6[t7][1].length) return m5("InvalidAttr", "Attribute '" + n6[t7][2] + "' has no space in starting.", N(n6[t7]));
261005
- if (void 0 !== n6[t7][3] && void 0 === n6[t7][4]) return m5("InvalidAttr", "Attribute '" + n6[t7][2] + "' is without value.", N(n6[t7]));
261006
- if (void 0 === n6[t7][3] && !e6.allowBooleanAttributes) return m5("InvalidAttr", "boolean attribute '" + n6[t7][2] + "' is not allowed.", N(n6[t7]));
262821
+ if (0 === n6[t7][1].length) return m5("InvalidAttr", "Attribute '" + n6[t7][2] + "' has no space in starting.", y2(n6[t7]));
262822
+ if (void 0 !== n6[t7][3] && void 0 === n6[t7][4]) return m5("InvalidAttr", "Attribute '" + n6[t7][2] + "' is without value.", y2(n6[t7]));
262823
+ if (void 0 === n6[t7][3] && !e6.allowBooleanAttributes) return m5("InvalidAttr", "boolean attribute '" + n6[t7][2] + "' is not allowed.", y2(n6[t7]));
261007
262824
  const s6 = n6[t7][2];
261008
- if (!E2(s6)) return m5("InvalidAttr", "Attribute '" + s6 + "' is an invalid name.", N(n6[t7]));
261009
- if (i6.hasOwnProperty(s6)) return m5("InvalidAttr", "Attribute '" + s6 + "' is repeated.", N(n6[t7]));
262825
+ if (!E2(s6)) return m5("InvalidAttr", "Attribute '" + s6 + "' is an invalid name.", y2(n6[t7]));
262826
+ if (Object.prototype.hasOwnProperty.call(i6, s6)) return m5("InvalidAttr", "Attribute '" + s6 + "' is repeated.", y2(n6[t7]));
261010
262827
  i6[s6] = 1;
261011
262828
  }
261012
262829
  return true;
@@ -261034,49 +262851,52 @@ var require_fxp = __commonJS({
261034
262851
  function E2(t6) {
261035
262852
  return r5(t6);
261036
262853
  }
261037
- function b5(t6, e6) {
262854
+ function b5(t6) {
262855
+ return r5(t6);
262856
+ }
262857
+ function N(t6, e6) {
261038
262858
  const n6 = t6.substring(0, e6).split(/\r?\n/);
261039
262859
  return { line: n6.length, col: n6[n6.length - 1].length + 1 };
261040
262860
  }
261041
- function N(t6) {
262861
+ function y2(t6) {
261042
262862
  return t6.startIndex + t6[1].length;
261043
262863
  }
261044
- const y2 = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t6, e6) {
262864
+ const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t6, e6) {
261045
262865
  return e6;
261046
262866
  }, attributeValueProcessor: function(t6, e6) {
261047
262867
  return e6;
261048
262868
  }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t6, e6, n6) {
261049
262869
  return t6;
261050
- }, captureMetaData: false };
261051
- function T(t6) {
261052
- return "boolean" == typeof t6 ? { enabled: t6, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t6 && null !== t6 ? { enabled: false !== t6.enabled, maxEntitySize: t6.maxEntitySize ?? 1e4, maxExpansionDepth: t6.maxExpansionDepth ?? 10, maxTotalExpansions: t6.maxTotalExpansions ?? 1e3, maxExpandedLength: t6.maxExpandedLength ?? 1e5, allowedTags: t6.allowedTags ?? null, tagFilter: t6.tagFilter ?? null } : T(true);
262870
+ }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true };
262871
+ function w5(t6) {
262872
+ return "boolean" == typeof t6 ? { enabled: t6, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t6 && null !== t6 ? { enabled: false !== t6.enabled, maxEntitySize: t6.maxEntitySize ?? 1e4, maxExpansionDepth: t6.maxExpansionDepth ?? 10, maxTotalExpansions: t6.maxTotalExpansions ?? 1e3, maxExpandedLength: t6.maxExpandedLength ?? 1e5, allowedTags: t6.allowedTags ?? null, tagFilter: t6.tagFilter ?? null } : w5(true);
261053
262873
  }
261054
- const w5 = function(t6) {
261055
- const e6 = Object.assign({}, y2, t6);
261056
- return e6.processEntities = T(e6.processEntities), e6;
262874
+ const v5 = function(t6) {
262875
+ const e6 = Object.assign({}, T, t6);
262876
+ return e6.processEntities = w5(e6.processEntities), e6;
261057
262877
  };
261058
- let v5;
261059
- v5 = "function" != typeof Symbol ? "@@xmlMetadata" : Symbol("XML Node Metadata");
262878
+ let O;
262879
+ O = "function" != typeof Symbol ? "@@xmlMetadata" : Symbol("XML Node Metadata");
261060
262880
  class I2 {
261061
262881
  constructor(t6) {
261062
- this.tagname = t6, this.child = [], this[":@"] = {};
262882
+ this.tagname = t6, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null);
261063
262883
  }
261064
262884
  add(t6, e6) {
261065
262885
  "__proto__" === t6 && (t6 = "#__proto__"), this.child.push({ [t6]: e6 });
261066
262886
  }
261067
262887
  addChild(t6, e6) {
261068
- "__proto__" === t6.tagname && (t6.tagname = "#__proto__"), t6[":@"] && Object.keys(t6[":@"]).length > 0 ? this.child.push({ [t6.tagname]: t6.child, ":@": t6[":@"] }) : this.child.push({ [t6.tagname]: t6.child }), void 0 !== e6 && (this.child[this.child.length - 1][v5] = { startIndex: e6 });
262888
+ "__proto__" === t6.tagname && (t6.tagname = "#__proto__"), t6[":@"] && Object.keys(t6[":@"]).length > 0 ? this.child.push({ [t6.tagname]: t6.child, ":@": t6[":@"] }) : this.child.push({ [t6.tagname]: t6.child }), void 0 !== e6 && (this.child[this.child.length - 1][O] = { startIndex: e6 });
261069
262889
  }
261070
262890
  static getMetaDataSymbol() {
261071
- return v5;
262891
+ return O;
261072
262892
  }
261073
262893
  }
261074
- class O {
262894
+ class P {
261075
262895
  constructor(t6) {
261076
262896
  this.suppressValidationErr = !t6, this.options = t6;
261077
262897
  }
261078
262898
  readDocType(t6, e6) {
261079
- const n6 = {};
262899
+ const n6 = /* @__PURE__ */ Object.create(null);
261080
262900
  if ("O" !== t6[e6 + 3] || "C" !== t6[e6 + 4] || "T" !== t6[e6 + 5] || "Y" !== t6[e6 + 6] || "P" !== t6[e6 + 7] || "E" !== t6[e6 + 8]) throw new Error("Invalid Tag instead of DOCTYPE");
261081
262901
  {
261082
262902
  e6 += 9;
@@ -261085,23 +262905,23 @@ var require_fxp = __commonJS({
261085
262905
  if (r6 ? "-" === t6[e6 - 1] && "-" === t6[e6 - 2] && (r6 = false, i6--) : i6--, 0 === i6) break;
261086
262906
  } else "[" === t6[e6] ? s6 = true : o6 += t6[e6];
261087
262907
  else {
261088
- if (s6 && A2(t6, "!ENTITY", e6)) {
262908
+ if (s6 && S(t6, "!ENTITY", e6)) {
261089
262909
  let i7, s7;
261090
262910
  if (e6 += 7, [i7, s7, e6] = this.readEntityExp(t6, e6 + 1, this.suppressValidationErr), -1 === s7.indexOf("&")) {
261091
262911
  const t7 = i7.replace(/[.\-+*:]/g, "\\.");
261092
262912
  n6[i7] = { regx: RegExp(`&${t7};`, "g"), val: s7 };
261093
262913
  }
261094
- } else if (s6 && A2(t6, "!ELEMENT", e6)) {
262914
+ } else if (s6 && S(t6, "!ELEMENT", e6)) {
261095
262915
  e6 += 8;
261096
262916
  const { index: n7 } = this.readElementExp(t6, e6 + 1);
261097
262917
  e6 = n7;
261098
- } else if (s6 && A2(t6, "!ATTLIST", e6)) e6 += 8;
261099
- else if (s6 && A2(t6, "!NOTATION", e6)) {
262918
+ } else if (s6 && S(t6, "!ATTLIST", e6)) e6 += 8;
262919
+ else if (s6 && S(t6, "!NOTATION", e6)) {
261100
262920
  e6 += 9;
261101
262921
  const { index: n7 } = this.readNotationExp(t6, e6 + 1, this.suppressValidationErr);
261102
262922
  e6 = n7;
261103
262923
  } else {
261104
- if (!A2(t6, "!--", e6)) throw new Error("Invalid DOCTYPE");
262924
+ if (!S(t6, "!--", e6)) throw new Error("Invalid DOCTYPE");
261105
262925
  r6 = true;
261106
262926
  }
261107
262927
  i6++, o6 = "";
@@ -261111,10 +262931,10 @@ var require_fxp = __commonJS({
261111
262931
  return { entities: n6, i: e6 };
261112
262932
  }
261113
262933
  readEntityExp(t6, e6) {
261114
- e6 = P(t6, e6);
262934
+ e6 = A2(t6, e6);
261115
262935
  let n6 = "";
261116
262936
  for (; e6 < t6.length && !/\s/.test(t6[e6]) && '"' !== t6[e6] && "'" !== t6[e6]; ) n6 += t6[e6], e6++;
261117
- if (S(n6), e6 = P(t6, e6), !this.suppressValidationErr) {
262937
+ if (C2(n6), e6 = A2(t6, e6), !this.suppressValidationErr) {
261118
262938
  if ("SYSTEM" === t6.substring(e6, e6 + 6).toUpperCase()) throw new Error("External entities are not supported");
261119
262939
  if ("%" === t6[e6]) throw new Error("Parameter entities are not supported");
261120
262940
  }
@@ -261123,15 +262943,15 @@ var require_fxp = __commonJS({
261123
262943
  return [n6, i6, --e6];
261124
262944
  }
261125
262945
  readNotationExp(t6, e6) {
261126
- e6 = P(t6, e6);
262946
+ e6 = A2(t6, e6);
261127
262947
  let n6 = "";
261128
262948
  for (; e6 < t6.length && !/\s/.test(t6[e6]); ) n6 += t6[e6], e6++;
261129
- !this.suppressValidationErr && S(n6), e6 = P(t6, e6);
262949
+ !this.suppressValidationErr && C2(n6), e6 = A2(t6, e6);
261130
262950
  const i6 = t6.substring(e6, e6 + 6).toUpperCase();
261131
262951
  if (!this.suppressValidationErr && "SYSTEM" !== i6 && "PUBLIC" !== i6) throw new Error(`Expected SYSTEM or PUBLIC, found "${i6}"`);
261132
- e6 += i6.length, e6 = P(t6, e6);
262952
+ e6 += i6.length, e6 = A2(t6, e6);
261133
262953
  let s6 = null, r6 = null;
261134
- if ("PUBLIC" === i6) [e6, s6] = this.readIdentifierVal(t6, e6, "publicIdentifier"), '"' !== t6[e6 = P(t6, e6)] && "'" !== t6[e6] || ([e6, r6] = this.readIdentifierVal(t6, e6, "systemIdentifier"));
262954
+ if ("PUBLIC" === i6) [e6, s6] = this.readIdentifierVal(t6, e6, "publicIdentifier"), '"' !== t6[e6 = A2(t6, e6)] && "'" !== t6[e6] || ([e6, r6] = this.readIdentifierVal(t6, e6, "systemIdentifier"));
261135
262955
  else if ("SYSTEM" === i6 && ([e6, r6] = this.readIdentifierVal(t6, e6, "systemIdentifier"), !this.suppressValidationErr && !r6)) throw new Error("Missing mandatory system identifier for SYSTEM notation");
261136
262956
  return { notationName: n6, publicIdentifier: s6, systemIdentifier: r6, index: --e6 };
261137
262957
  }
@@ -261144,13 +262964,13 @@ var require_fxp = __commonJS({
261144
262964
  return [++e6, i6];
261145
262965
  }
261146
262966
  readElementExp(t6, e6) {
261147
- e6 = P(t6, e6);
262967
+ e6 = A2(t6, e6);
261148
262968
  let n6 = "";
261149
262969
  for (; e6 < t6.length && !/\s/.test(t6[e6]); ) n6 += t6[e6], e6++;
261150
262970
  if (!this.suppressValidationErr && !r5(n6)) throw new Error(`Invalid element name: "${n6}"`);
261151
262971
  let i6 = "";
261152
- if ("E" === t6[e6 = P(t6, e6)] && A2(t6, "MPTY", e6)) e6 += 4;
261153
- else if ("A" === t6[e6] && A2(t6, "NY", e6)) e6 += 2;
262972
+ if ("E" === t6[e6 = A2(t6, e6)] && S(t6, "MPTY", e6)) e6 += 4;
262973
+ else if ("A" === t6[e6] && S(t6, "NY", e6)) e6 += 2;
261154
262974
  else if ("(" === t6[e6]) {
261155
262975
  for (e6++; e6 < t6.length && ")" !== t6[e6]; ) i6 += t6[e6], e6++;
261156
262976
  if (")" !== t6[e6]) throw new Error("Unterminated content model");
@@ -261158,24 +262978,24 @@ var require_fxp = __commonJS({
261158
262978
  return { elementName: n6, contentModel: i6.trim(), index: e6 };
261159
262979
  }
261160
262980
  readAttlistExp(t6, e6) {
261161
- e6 = P(t6, e6);
262981
+ e6 = A2(t6, e6);
261162
262982
  let n6 = "";
261163
262983
  for (; e6 < t6.length && !/\s/.test(t6[e6]); ) n6 += t6[e6], e6++;
261164
- S(n6), e6 = P(t6, e6);
262984
+ C2(n6), e6 = A2(t6, e6);
261165
262985
  let i6 = "";
261166
262986
  for (; e6 < t6.length && !/\s/.test(t6[e6]); ) i6 += t6[e6], e6++;
261167
- if (!S(i6)) throw new Error(`Invalid attribute name: "${i6}"`);
261168
- e6 = P(t6, e6);
262987
+ if (!C2(i6)) throw new Error(`Invalid attribute name: "${i6}"`);
262988
+ e6 = A2(t6, e6);
261169
262989
  let s6 = "";
261170
262990
  if ("NOTATION" === t6.substring(e6, e6 + 8).toUpperCase()) {
261171
- if (s6 = "NOTATION", "(" !== t6[e6 = P(t6, e6 += 8)]) throw new Error(`Expected '(', found "${t6[e6]}"`);
262991
+ if (s6 = "NOTATION", "(" !== t6[e6 = A2(t6, e6 += 8)]) throw new Error(`Expected '(', found "${t6[e6]}"`);
261172
262992
  e6++;
261173
262993
  let n7 = [];
261174
262994
  for (; e6 < t6.length && ")" !== t6[e6]; ) {
261175
262995
  let i7 = "";
261176
262996
  for (; e6 < t6.length && "|" !== t6[e6] && ")" !== t6[e6]; ) i7 += t6[e6], e6++;
261177
- if (i7 = i7.trim(), !S(i7)) throw new Error(`Invalid notation name: "${i7}"`);
261178
- n7.push(i7), "|" === t6[e6] && (e6++, e6 = P(t6, e6));
262997
+ if (i7 = i7.trim(), !C2(i7)) throw new Error(`Invalid notation name: "${i7}"`);
262998
+ n7.push(i7), "|" === t6[e6] && (e6++, e6 = A2(t6, e6));
261179
262999
  }
261180
263000
  if (")" !== t6[e6]) throw new Error("Unterminated list of notations");
261181
263001
  e6++, s6 += " (" + n7.join("|") + ")";
@@ -261184,45 +263004,43 @@ var require_fxp = __commonJS({
261184
263004
  const n7 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
261185
263005
  if (!this.suppressValidationErr && !n7.includes(s6.toUpperCase())) throw new Error(`Invalid attribute type: "${s6}"`);
261186
263006
  }
261187
- e6 = P(t6, e6);
263007
+ e6 = A2(t6, e6);
261188
263008
  let r6 = "";
261189
263009
  return "#REQUIRED" === t6.substring(e6, e6 + 8).toUpperCase() ? (r6 = "#REQUIRED", e6 += 8) : "#IMPLIED" === t6.substring(e6, e6 + 7).toUpperCase() ? (r6 = "#IMPLIED", e6 += 7) : [e6, r6] = this.readIdentifierVal(t6, e6, "ATTLIST"), { elementName: n6, attributeName: i6, attributeType: s6, defaultValue: r6, index: e6 };
261190
263010
  }
261191
263011
  }
261192
- const P = (t6, e6) => {
263012
+ const A2 = (t6, e6) => {
261193
263013
  for (; e6 < t6.length && /\s/.test(t6[e6]); ) e6++;
261194
263014
  return e6;
261195
263015
  };
261196
- function A2(t6, e6, n6) {
263016
+ function S(t6, e6, n6) {
261197
263017
  for (let i6 = 0; i6 < e6.length; i6++) if (e6[i6] !== t6[n6 + i6 + 1]) return false;
261198
263018
  return true;
261199
263019
  }
261200
- function S(t6) {
263020
+ function C2(t6) {
261201
263021
  if (r5(t6)) return t6;
261202
263022
  throw new Error(`Invalid entity name ${t6}`);
261203
263023
  }
261204
- const C2 = /^[-+]?0x[a-fA-F0-9]+$/, $ = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, V = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true };
261205
- const D2 = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
261206
- function L(t6) {
261207
- return "function" == typeof t6 ? t6 : Array.isArray(t6) ? (e6) => {
261208
- for (const n6 of t6) {
261209
- if ("string" == typeof n6 && e6 === n6) return true;
261210
- if (n6 instanceof RegExp && n6.test(e6)) return true;
261211
- }
261212
- } : () => false;
261213
- }
261214
- class F2 {
263024
+ const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D2 = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true };
263025
+ const j5 = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
263026
+ class L {
261215
263027
  constructor(t6) {
261216
- if (this.options = t6, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t7, e6) => K(e6, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t7, e6) => K(e6, 16, "&#x") } }, this.addExternalEntities = j5, this.parseXml = B2, this.parseTextData = M, this.resolveNameSpace = _, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q5, this.saveTextToParentTag = G2, this.addChild = R, this.ignoreAttributesFn = L(this.options.ignoreAttributes), this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) {
263028
+ var e6;
263029
+ if (this.options = t6, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t7, e7) => K(e7, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t7, e7) => K(e7, 16, "&#x") } }, this.addExternalEntities = F2, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k5, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q5, this.saveTextToParentTag = G2, this.addChild = B2, this.ignoreAttributesFn = "function" == typeof (e6 = this.options.ignoreAttributes) ? e6 : Array.isArray(e6) ? (t7) => {
263030
+ for (const n6 of e6) {
263031
+ if ("string" == typeof n6 && t7 === n6) return true;
263032
+ if (n6 instanceof RegExp && n6.test(t7)) return true;
263033
+ }
263034
+ } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) {
261217
263035
  this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set();
261218
263036
  for (let t7 = 0; t7 < this.options.stopNodes.length; t7++) {
261219
- const e6 = this.options.stopNodes[t7];
261220
- "string" == typeof e6 && (e6.startsWith("*.") ? this.stopNodesWildcard.add(e6.substring(2)) : this.stopNodesExact.add(e6));
263037
+ const e7 = this.options.stopNodes[t7];
263038
+ "string" == typeof e7 && (e7.startsWith("*.") ? this.stopNodesWildcard.add(e7.substring(2)) : this.stopNodesExact.add(e7));
261221
263039
  }
261222
263040
  }
261223
263041
  }
261224
263042
  }
261225
- function j5(t6) {
263043
+ function F2(t6) {
261226
263044
  const e6 = Object.keys(t6);
261227
263045
  for (let n6 = 0; n6 < e6.length; n6++) {
261228
263046
  const i6 = e6[n6], s6 = i6.replace(/[.\-+*:]/g, "\\.");
@@ -261236,7 +263054,7 @@ var require_fxp = __commonJS({
261236
263054
  return null == i7 ? t6 : typeof i7 != typeof t6 || i7 !== t6 ? i7 : this.options.trimValues || t6.trim() === t6 ? Z(t6, this.options.parseTagValue, this.options.numberParseOptions) : t6;
261237
263055
  }
261238
263056
  }
261239
- function _(t6) {
263057
+ function k5(t6) {
261240
263058
  if (this.options.removeNSPrefix) {
261241
263059
  const e6 = t6.split(":"), n6 = "/" === t6.charAt(0) ? "/" : "";
261242
263060
  if ("xmlns" === e6[0]) return "";
@@ -261244,10 +263062,10 @@ var require_fxp = __commonJS({
261244
263062
  }
261245
263063
  return t6;
261246
263064
  }
261247
- const k5 = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
263065
+ const _ = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
261248
263066
  function U(t6, e6, n6) {
261249
263067
  if (true !== this.options.ignoreAttributes && "string" == typeof t6) {
261250
- const i6 = s5(t6, k5), r6 = i6.length, o6 = {};
263068
+ const i6 = s5(t6, _), r6 = i6.length, o6 = {};
261251
263069
  for (let t7 = 0; t7 < r6; t7++) {
261252
263070
  const s6 = this.resolveNameSpace(i6[t7][1]);
261253
263071
  if (this.ignoreAttributesFn(s6, e6)) continue;
@@ -261266,12 +263084,12 @@ var require_fxp = __commonJS({
261266
263084
  return o6;
261267
263085
  }
261268
263086
  }
261269
- const B2 = function(t6) {
263087
+ const R = function(t6) {
261270
263088
  t6 = t6.replace(/\r\n?/g, "\n");
261271
263089
  const e6 = new I2("!xml");
261272
263090
  let n6 = e6, i6 = "", s6 = "";
261273
263091
  this.entityExpansionCount = 0, this.currentExpandedLength = 0;
261274
- const r6 = new O(this.options.processEntities);
263092
+ const r6 = new P(this.options.processEntities);
261275
263093
  for (let o6 = 0; o6 < t6.length; o6++) if ("<" === t6[o6]) if ("/" === t6[o6 + 1]) {
261276
263094
  const e7 = z2(t6, ">", o6, "Closing Tag is not closed.");
261277
263095
  let r7 = t6.substring(o6 + 2, e7).trim();
@@ -261311,26 +263129,27 @@ var require_fxp = __commonJS({
261311
263129
  } else {
261312
263130
  let r7 = W(t6, o6, this.options.removeNSPrefix), a6 = r7.tagName;
261313
263131
  const l6 = r7.rawTagName;
261314
- let u6 = r7.tagExp, h6 = r7.attrExpPresent, d6 = r7.closeIndex;
263132
+ let u6 = r7.tagExp, d6 = r7.attrExpPresent, h6 = r7.closeIndex;
261315
263133
  if (this.options.transformTagName) {
261316
263134
  const t7 = this.options.transformTagName(a6);
261317
263135
  u6 === a6 && (u6 = t7), a6 = t7;
261318
263136
  }
263137
+ if (this.options.strictReservedNames && (a6 === this.options.commentPropName || a6 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a6}`);
261319
263138
  n6 && i6 && "!xml" !== n6.tagname && (i6 = this.saveTextToParentTag(i6, n6, s6, false));
261320
263139
  const p6 = n6;
261321
263140
  p6 && -1 !== this.options.unpairedTags.indexOf(p6.tagname) && (n6 = this.tagsNodeStack.pop(), s6 = s6.substring(0, s6.lastIndexOf("."))), a6 !== e6.tagname && (s6 += s6 ? "." + a6 : a6);
261322
- const f6 = o6;
263141
+ const c6 = o6;
261323
263142
  if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s6, a6)) {
261324
263143
  let e7 = "";
261325
263144
  if (u6.length > 0 && u6.lastIndexOf("/") === u6.length - 1) "/" === a6[a6.length - 1] ? (a6 = a6.substr(0, a6.length - 1), s6 = s6.substr(0, s6.length - 1), u6 = a6) : u6 = u6.substr(0, u6.length - 1), o6 = r7.closeIndex;
261326
263145
  else if (-1 !== this.options.unpairedTags.indexOf(a6)) o6 = r7.closeIndex;
261327
263146
  else {
261328
- const n7 = this.readStopNodeData(t6, l6, d6 + 1);
263147
+ const n7 = this.readStopNodeData(t6, l6, h6 + 1);
261329
263148
  if (!n7) throw new Error(`Unexpected end of ${l6}`);
261330
263149
  o6 = n7.i, e7 = n7.tagContent;
261331
263150
  }
261332
263151
  const i7 = new I2(a6);
261333
- a6 !== u6 && h6 && (i7[":@"] = this.buildAttributesMap(u6, s6, a6)), e7 && (e7 = this.parseTextData(e7, a6, s6, true, h6, true, true)), s6 = s6.substr(0, s6.lastIndexOf(".")), i7.add(this.options.textNodeName, e7), this.addChild(n6, i7, s6, f6);
263152
+ a6 !== u6 && d6 && (i7[":@"] = this.buildAttributesMap(u6, s6, a6)), e7 && (e7 = this.parseTextData(e7, a6, s6, true, d6, true, true)), s6 = s6.substr(0, s6.lastIndexOf(".")), i7.add(this.options.textNodeName, e7), this.addChild(n6, i7, s6, c6);
261334
263153
  } else {
261335
263154
  if (u6.length > 0 && u6.lastIndexOf("/") === u6.length - 1) {
261336
263155
  if ("/" === a6[a6.length - 1] ? (a6 = a6.substr(0, a6.length - 1), s6 = s6.substr(0, s6.length - 1), u6 = a6) : u6 = u6.substr(0, u6.length - 1), this.options.transformTagName) {
@@ -261338,18 +263157,26 @@ var require_fxp = __commonJS({
261338
263157
  u6 === a6 && (u6 = t8), a6 = t8;
261339
263158
  }
261340
263159
  const t7 = new I2(a6);
261341
- a6 !== u6 && h6 && (t7[":@"] = this.buildAttributesMap(u6, s6, a6)), this.addChild(n6, t7, s6, f6), s6 = s6.substr(0, s6.lastIndexOf("."));
263160
+ a6 !== u6 && d6 && (t7[":@"] = this.buildAttributesMap(u6, s6, a6)), this.addChild(n6, t7, s6, c6), s6 = s6.substr(0, s6.lastIndexOf("."));
261342
263161
  } else {
261343
- const t7 = new I2(a6);
261344
- this.tagsNodeStack.push(n6), a6 !== u6 && h6 && (t7[":@"] = this.buildAttributesMap(u6, s6, a6)), this.addChild(n6, t7, s6, f6), n6 = t7;
263162
+ if (-1 !== this.options.unpairedTags.indexOf(a6)) {
263163
+ const t7 = new I2(a6);
263164
+ a6 !== u6 && d6 && (t7[":@"] = this.buildAttributesMap(u6, s6)), this.addChild(n6, t7, s6, c6), s6 = s6.substr(0, s6.lastIndexOf(".")), o6 = r7.closeIndex;
263165
+ continue;
263166
+ }
263167
+ {
263168
+ const t7 = new I2(a6);
263169
+ if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded");
263170
+ this.tagsNodeStack.push(n6), a6 !== u6 && d6 && (t7[":@"] = this.buildAttributesMap(u6, s6, a6)), this.addChild(n6, t7, s6, c6), n6 = t7;
263171
+ }
261345
263172
  }
261346
- i6 = "", o6 = d6;
263173
+ i6 = "", o6 = h6;
261347
263174
  }
261348
263175
  }
261349
263176
  else i6 += t6[o6];
261350
263177
  return e6.child;
261351
263178
  };
261352
- function R(t6, e6, n6, i6) {
263179
+ function B2(t6, e6, n6, i6) {
261353
263180
  this.options.captureMetaData || (i6 = void 0);
261354
263181
  const s6 = this.options.updateTag(e6.tagname, n6, e6[":@"]);
261355
263182
  false === s6 || ("string" == typeof s6 ? (e6.tagname = s6, t6.addChild(e6, i6)) : t6.addChild(e6, i6));
@@ -261410,12 +263237,12 @@ var require_fxp = __commonJS({
261410
263237
  const o6 = s6.index, a6 = r6.search(/\s/);
261411
263238
  let l6 = r6, u6 = true;
261412
263239
  -1 !== a6 && (l6 = r6.substring(0, a6), r6 = r6.substring(a6 + 1).trimStart());
261413
- const h6 = l6;
263240
+ const d6 = l6;
261414
263241
  if (n6) {
261415
263242
  const t7 = l6.indexOf(":");
261416
263243
  -1 !== t7 && (l6 = l6.substr(t7 + 1), u6 = l6 !== s6.data.substr(t7 + 1));
261417
263244
  }
261418
- return { tagName: l6, tagExp: r6, closeIndex: o6, attrExpPresent: u6, rawTagName: h6 };
263245
+ return { tagName: l6, tagExp: r6, closeIndex: o6, attrExpPresent: u6, rawTagName: d6 };
261419
263246
  }
261420
263247
  function q5(t6, e6, n6) {
261421
263248
  const i6 = n6;
@@ -261436,19 +263263,19 @@ var require_fxp = __commonJS({
261436
263263
  if (e6 && "string" == typeof t6) {
261437
263264
  const e7 = t6.trim();
261438
263265
  return "true" === e7 || "false" !== e7 && (function(t7, e8 = {}) {
261439
- if (e8 = Object.assign({}, V, e8), !t7 || "string" != typeof t7) return t7;
263266
+ if (e8 = Object.assign({}, D2, e8), !t7 || "string" != typeof t7) return t7;
261440
263267
  let n7 = t7.trim();
261441
263268
  if (void 0 !== e8.skipLike && e8.skipLike.test(n7)) return t7;
261442
263269
  if ("0" === t7) return 0;
261443
- if (e8.hex && C2.test(n7)) return (function(t8) {
263270
+ if (e8.hex && $.test(n7)) return (function(t8) {
261444
263271
  if (parseInt) return parseInt(t8, 16);
261445
263272
  if (Number.parseInt) return Number.parseInt(t8, 16);
261446
263273
  if (window && window.parseInt) return window.parseInt(t8, 16);
261447
263274
  throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
261448
263275
  })(n7);
261449
- if (-1 !== n7.search(/.+[eE].+/)) return (function(t8, e9, n8) {
263276
+ if (n7.includes("e") || n7.includes("E")) return (function(t8, e9, n8) {
261450
263277
  if (!n8.eNotation) return t8;
261451
- const i7 = e9.match(D2);
263278
+ const i7 = e9.match(j5);
261452
263279
  if (i7) {
261453
263280
  let s6 = i7[1] || "";
261454
263281
  const r6 = -1 === i7[3].indexOf("e") ? "E" : "e", o6 = i7[2], a6 = s6 ? t8[o6.length + 1] === r6 : t8[o6.length] === r6;
@@ -261457,7 +263284,7 @@ var require_fxp = __commonJS({
261457
263284
  return t8;
261458
263285
  })(t7, n7, e8);
261459
263286
  {
261460
- const s6 = $.exec(n7);
263287
+ const s6 = V.exec(n7);
261461
263288
  if (s6) {
261462
263289
  const r6 = s6[1] || "", o6 = s6[2];
261463
263290
  let a6 = (i6 = s6[3]) && -1 !== i6.indexOf(".") ? ("." === (i6 = i6.replace(/0+$/, "")) ? i6 = "0" : "." === i6[0] ? i6 = "0" + i6 : "." === i6[i6.length - 1] && (i6 = i6.substring(0, i6.length - 1)), i6) : i6;
@@ -261465,7 +263292,7 @@ var require_fxp = __commonJS({
261465
263292
  if (!e8.leadingZeros && (o6.length > 1 || 1 === o6.length && !l6)) return t7;
261466
263293
  {
261467
263294
  const i7 = Number(n7), s7 = String(i7);
261468
- if (0 === i7 || -0 === i7) return i7;
263295
+ if (0 === i7) return i7;
261469
263296
  if (-1 !== s7.search(/[eE]/)) return e8.eNotation ? i7 : t7;
261470
263297
  if (-1 !== n7.indexOf(".")) return "0" === s7 || s7 === a6 || s7 === `${r6}${a6}` ? i7 : t7;
261471
263298
  let l7 = o6 ? a6 : n7;
@@ -261499,7 +263326,7 @@ var require_fxp = __commonJS({
261499
263326
  if (o6[a6]) {
261500
263327
  let t7 = H2(o6[a6], e6, l6);
261501
263328
  const n7 = nt(t7, e6);
261502
- void 0 !== o6[Q] && (t7[Q] = o6[Q]), o6[":@"] ? et(t7, o6[":@"], l6, e6) : 1 !== Object.keys(t7).length || void 0 === t7[e6.textNodeName] || e6.alwaysCreateTextNode ? 0 === Object.keys(t7).length && (e6.alwaysCreateTextNode ? t7[e6.textNodeName] = "" : t7 = "") : t7 = t7[e6.textNodeName], void 0 !== s6[a6] && s6.hasOwnProperty(a6) ? (Array.isArray(s6[a6]) || (s6[a6] = [s6[a6]]), s6[a6].push(t7)) : e6.isArray(a6, l6, n7) ? s6[a6] = [t7] : s6[a6] = t7;
263329
+ o6[":@"] ? et(t7, o6[":@"], l6, e6) : 1 !== Object.keys(t7).length || void 0 === t7[e6.textNodeName] || e6.alwaysCreateTextNode ? 0 === Object.keys(t7).length && (e6.alwaysCreateTextNode ? t7[e6.textNodeName] = "" : t7 = "") : t7 = t7[e6.textNodeName], void 0 !== o6[Q] && "object" == typeof t7 && null !== t7 && (t7[Q] = o6[Q]), void 0 !== s6[a6] && Object.prototype.hasOwnProperty.call(s6, a6) ? (Array.isArray(s6[a6]) || (s6[a6] = [s6[a6]]), s6[a6].push(t7)) : e6.isArray(a6, l6, n7) ? s6[a6] = [t7] : s6[a6] = t7;
261503
263330
  }
261504
263331
  }
261505
263332
  }
@@ -261527,7 +263354,7 @@ var require_fxp = __commonJS({
261527
263354
  }
261528
263355
  class it {
261529
263356
  constructor(t6) {
261530
- this.externalEntities = {}, this.options = w5(t6);
263357
+ this.externalEntities = {}, this.options = v5(t6);
261531
263358
  }
261532
263359
  parse(t6, e6) {
261533
263360
  if ("string" != typeof t6 && t6.toString) t6 = t6.toString();
@@ -261537,7 +263364,7 @@ var require_fxp = __commonJS({
261537
263364
  const n7 = a5(t6, e6);
261538
263365
  if (true !== n7) throw Error(`${n7.err.msg}:${n7.err.line}:${n7.err.col}`);
261539
263366
  }
261540
- const n6 = new F2(this.options);
263367
+ const n6 = new L(this.options);
261541
263368
  n6.addExternalEntities(this.externalEntities);
261542
263369
  const i6 = n6.parseXml(t6);
261543
263370
  return this.options.preserveOrder || void 0 === i6 ? i6 : J2(i6, this.options);
@@ -261558,6 +263385,13 @@ var require_fxp = __commonJS({
261558
263385
  }
261559
263386
  function rt(t6, e6, n6, i6) {
261560
263387
  let s6 = "", r6 = false;
263388
+ if (!Array.isArray(t6)) {
263389
+ if (null != t6) {
263390
+ let n7 = t6.toString();
263391
+ return n7 = ut(n7, e6), n7;
263392
+ }
263393
+ return "";
263394
+ }
261561
263395
  for (let o6 = 0; o6 < t6.length; o6++) {
261562
263396
  const a6 = t6[o6], l6 = ot(a6);
261563
263397
  if (void 0 === l6) continue;
@@ -261581,10 +263415,10 @@ var require_fxp = __commonJS({
261581
263415
  o7 = 0 !== o7.length ? " " + o7 : "", s6 += n7 + `<${l6}${o7}${t7}?>`, r6 = true;
261582
263416
  continue;
261583
263417
  }
261584
- let h6 = i6;
261585
- "" !== h6 && (h6 += e6.indentBy);
261586
- const d6 = i6 + `<${l6}${at3(a6[":@"], e6)}`, p6 = rt(a6[l6], e6, u6, h6);
261587
- -1 !== e6.unpairedTags.indexOf(l6) ? e6.suppressUnpairedNode ? s6 += d6 + ">" : s6 += d6 + "/>" : p6 && 0 !== p6.length || !e6.suppressEmptyNode ? p6 && p6.endsWith(">") ? s6 += d6 + `>${p6}${i6}</${l6}>` : (s6 += d6 + ">", p6 && "" !== i6 && (p6.includes("/>") || p6.includes("</")) ? s6 += i6 + e6.indentBy + p6 + i6 : s6 += p6, s6 += `</${l6}>`) : s6 += d6 + "/>", r6 = true;
263418
+ let d6 = i6;
263419
+ "" !== d6 && (d6 += e6.indentBy);
263420
+ const h6 = i6 + `<${l6}${at3(a6[":@"], e6)}`, p6 = rt(a6[l6], e6, u6, d6);
263421
+ -1 !== e6.unpairedTags.indexOf(l6) ? e6.suppressUnpairedNode ? s6 += h6 + ">" : s6 += h6 + "/>" : p6 && 0 !== p6.length || !e6.suppressEmptyNode ? p6 && p6.endsWith(">") ? s6 += h6 + `>${p6}${i6}</${l6}>` : (s6 += h6 + ">", p6 && "" !== i6 && (p6.includes("/>") || p6.includes("</")) ? s6 += i6 + e6.indentBy + p6 + i6 : s6 += p6, s6 += `</${l6}>`) : s6 += h6 + "/>", r6 = true;
261588
263422
  }
261589
263423
  return s6;
261590
263424
  }
@@ -261592,13 +263426,13 @@ var require_fxp = __commonJS({
261592
263426
  const e6 = Object.keys(t6);
261593
263427
  for (let n6 = 0; n6 < e6.length; n6++) {
261594
263428
  const i6 = e6[n6];
261595
- if (t6.hasOwnProperty(i6) && ":@" !== i6) return i6;
263429
+ if (Object.prototype.hasOwnProperty.call(t6, i6) && ":@" !== i6) return i6;
261596
263430
  }
261597
263431
  }
261598
263432
  function at3(t6, e6) {
261599
263433
  let n6 = "";
261600
263434
  if (t6 && !e6.ignoreAttributes) for (let i6 in t6) {
261601
- if (!t6.hasOwnProperty(i6)) continue;
263435
+ if (!Object.prototype.hasOwnProperty.call(t6, i6)) continue;
261602
263436
  let s6 = e6.attributeValueProcessor(i6, t6[i6]);
261603
263437
  s6 = ut(s6, e6), true === s6 && e6.suppressBooleanAttributes ? n6 += ` ${i6.substr(e6.attributeNamePrefix.length)}` : n6 += ` ${i6.substr(e6.attributeNamePrefix.length)}="${s6}"`;
261604
263438
  }
@@ -261616,15 +263450,21 @@ var require_fxp = __commonJS({
261616
263450
  }
261617
263451
  return t6;
261618
263452
  }
261619
- const ht = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t6, e6) {
263453
+ const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t6, e6) {
261620
263454
  return e6;
261621
263455
  }, attributeValueProcessor: function(t6, e6) {
261622
263456
  return e6;
261623
263457
  }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&amp;" }, { regex: new RegExp(">", "g"), val: "&gt;" }, { regex: new RegExp("<", "g"), val: "&lt;" }, { regex: new RegExp("'", "g"), val: "&apos;" }, { regex: new RegExp('"', "g"), val: "&quot;" }], processEntities: true, stopNodes: [], oneListGroup: false };
261624
- function dt(t6) {
261625
- this.options = Object.assign({}, ht, t6), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() {
263458
+ function ht(t6) {
263459
+ var e6;
263460
+ this.options = Object.assign({}, dt, t6), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() {
261626
263461
  return false;
261627
- } : (this.ignoreAttributesFn = L(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ct), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ft, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() {
263462
+ } : (this.ignoreAttributesFn = "function" == typeof (e6 = this.options.ignoreAttributes) ? e6 : Array.isArray(e6) ? (t7) => {
263463
+ for (const n6 of e6) {
263464
+ if ("string" == typeof n6 && t7 === n6) return true;
263465
+ if (n6 instanceof RegExp && n6.test(t7)) return true;
263466
+ }
263467
+ } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() {
261628
263468
  return "";
261629
263469
  }, this.tagEndChar = ">", this.newLine = "");
261630
263470
  }
@@ -261632,15 +263472,15 @@ var require_fxp = __commonJS({
261632
263472
  const s6 = this.j2x(t6, n6 + 1, i6.concat(e6));
261633
263473
  return void 0 !== t6[this.options.textNodeName] && 1 === Object.keys(t6).length ? this.buildTextValNode(t6[this.options.textNodeName], e6, s6.attrStr, n6) : this.buildObjectNode(s6.val, e6, s6.attrStr, n6);
261634
263474
  }
261635
- function ft(t6) {
263475
+ function ct(t6) {
261636
263476
  return this.options.indentBy.repeat(t6);
261637
263477
  }
261638
- function ct(t6) {
263478
+ function ft(t6) {
261639
263479
  return !(!t6.startsWith(this.options.attributeNamePrefix) || t6 === this.options.textNodeName) && t6.substr(this.attrPrefixLen);
261640
263480
  }
261641
- dt.prototype.build = function(t6) {
263481
+ ht.prototype.build = function(t6) {
261642
263482
  return this.options.preserveOrder ? st(t6, this.options) : (Array.isArray(t6) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t6 = { [this.options.arrayNodeName]: t6 }), this.j2x(t6, 0, []).val);
261643
- }, dt.prototype.j2x = function(t6, e6, n6) {
263483
+ }, ht.prototype.j2x = function(t6, e6, n6) {
261644
263484
  let i6 = "", s6 = "";
261645
263485
  const r6 = n6.join(".");
261646
263486
  for (let o6 in t6) if (Object.prototype.hasOwnProperty.call(t6, o6)) if (void 0 === t6[o6]) this.isAttribute(o6) && (s6 += "");
@@ -261675,18 +263515,18 @@ var require_fxp = __commonJS({
261675
263515
  for (let s7 = 0; s7 < n7; s7++) i6 += this.buildAttrPairStr(e7[s7], "" + t6[o6][e7[s7]]);
261676
263516
  } else s6 += this.processTextOrObjNode(t6[o6], o6, e6, n6);
261677
263517
  return { attrStr: i6, val: s6 };
261678
- }, dt.prototype.buildAttrPairStr = function(t6, e6) {
263518
+ }, ht.prototype.buildAttrPairStr = function(t6, e6) {
261679
263519
  return e6 = this.options.attributeValueProcessor(t6, "" + e6), e6 = this.replaceEntitiesValue(e6), this.options.suppressBooleanAttributes && "true" === e6 ? " " + t6 : " " + t6 + '="' + e6 + '"';
261680
- }, dt.prototype.buildObjectNode = function(t6, e6, n6, i6) {
263520
+ }, ht.prototype.buildObjectNode = function(t6, e6, n6, i6) {
261681
263521
  if ("" === t6) return "?" === e6[0] ? this.indentate(i6) + "<" + e6 + n6 + "?" + this.tagEndChar : this.indentate(i6) + "<" + e6 + n6 + this.closeTag(e6) + this.tagEndChar;
261682
263522
  {
261683
263523
  let s6 = "</" + e6 + this.tagEndChar, r6 = "";
261684
263524
  return "?" === e6[0] && (r6 = "?", s6 = ""), !n6 && "" !== n6 || -1 !== t6.indexOf("<") ? false !== this.options.commentPropName && e6 === this.options.commentPropName && 0 === r6.length ? this.indentate(i6) + `<!--${t6}-->` + this.newLine : this.indentate(i6) + "<" + e6 + n6 + r6 + this.tagEndChar + t6 + this.indentate(i6) + s6 : this.indentate(i6) + "<" + e6 + n6 + r6 + ">" + t6 + s6;
261685
263525
  }
261686
- }, dt.prototype.closeTag = function(t6) {
263526
+ }, ht.prototype.closeTag = function(t6) {
261687
263527
  let e6 = "";
261688
263528
  return -1 !== this.options.unpairedTags.indexOf(t6) ? this.options.suppressUnpairedNode || (e6 = "/") : e6 = this.options.suppressEmptyNode ? "/" : `></${t6}`, e6;
261689
- }, dt.prototype.buildTextValNode = function(t6, e6, n6, i6) {
263529
+ }, ht.prototype.buildTextValNode = function(t6, e6, n6, i6) {
261690
263530
  if (false !== this.options.cdataPropName && e6 === this.options.cdataPropName) return this.indentate(i6) + `<![CDATA[${t6}]]>` + this.newLine;
261691
263531
  if (false !== this.options.commentPropName && e6 === this.options.commentPropName) return this.indentate(i6) + `<!--${t6}-->` + this.newLine;
261692
263532
  if ("?" === e6[0]) return this.indentate(i6) + "<" + e6 + n6 + "?" + this.tagEndChar;
@@ -261694,14 +263534,14 @@ var require_fxp = __commonJS({
261694
263534
  let s6 = this.options.tagValueProcessor(e6, t6);
261695
263535
  return s6 = this.replaceEntitiesValue(s6), "" === s6 ? this.indentate(i6) + "<" + e6 + n6 + this.closeTag(e6) + this.tagEndChar : this.indentate(i6) + "<" + e6 + n6 + ">" + s6 + "</" + e6 + this.tagEndChar;
261696
263536
  }
261697
- }, dt.prototype.replaceEntitiesValue = function(t6) {
263537
+ }, ht.prototype.replaceEntitiesValue = function(t6) {
261698
263538
  if (t6 && t6.length > 0 && this.options.processEntities) for (let e6 = 0; e6 < this.options.entities.length; e6++) {
261699
263539
  const n6 = this.options.entities[e6];
261700
263540
  t6 = t6.replace(n6.regex, n6.val);
261701
263541
  }
261702
263542
  return t6;
261703
263543
  };
261704
- const gt = { validate: a5 };
263544
+ const gt = ht, xt = { validate: a5 };
261705
263545
  module2.exports = e5;
261706
263546
  })();
261707
263547
  }
@@ -261721,7 +263561,8 @@ var require_xml_parser = __commonJS({
261721
263561
  ignoreDeclaration: true,
261722
263562
  parseTagValue: false,
261723
263563
  trimValues: false,
261724
- tagValueProcessor: (_, val) => val.trim() === "" && val.includes("\n") ? "" : void 0
263564
+ tagValueProcessor: (_, val) => val.trim() === "" && val.includes("\n") ? "" : void 0,
263565
+ maxNestedTags: 1024
261725
263566
  });
261726
263567
  parser.addEntity("#xD", "\r");
261727
263568
  parser.addEntity("#10", "\n");
@@ -266274,7 +268115,7 @@ var require_package2 = __commonJS({
266274
268115
  module2.exports = {
266275
268116
  name: "@aws-sdk/client-bedrock-runtime",
266276
268117
  description: "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native",
266277
- version: "3.1000.0",
268118
+ version: "3.1001.0",
266278
268119
  scripts: {
266279
268120
  build: "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
266280
268121
  "build:cjs": "node ../../scripts/compilation/inline client-bedrock-runtime",
@@ -266298,54 +268139,54 @@ var require_package2 = __commonJS({
266298
268139
  dependencies: {
266299
268140
  "@aws-crypto/sha256-browser": "5.2.0",
266300
268141
  "@aws-crypto/sha256-js": "5.2.0",
266301
- "@aws-sdk/core": "^3.973.15",
266302
- "@aws-sdk/credential-provider-node": "^3.972.14",
268142
+ "@aws-sdk/core": "^3.973.16",
268143
+ "@aws-sdk/credential-provider-node": "^3.972.15",
266303
268144
  "@aws-sdk/eventstream-handler-node": "^3.972.9",
266304
268145
  "@aws-sdk/middleware-eventstream": "^3.972.6",
266305
268146
  "@aws-sdk/middleware-host-header": "^3.972.6",
266306
268147
  "@aws-sdk/middleware-logger": "^3.972.6",
266307
268148
  "@aws-sdk/middleware-recursion-detection": "^3.972.6",
266308
- "@aws-sdk/middleware-user-agent": "^3.972.15",
266309
- "@aws-sdk/middleware-websocket": "^3.972.10",
268149
+ "@aws-sdk/middleware-user-agent": "^3.972.16",
268150
+ "@aws-sdk/middleware-websocket": "^3.972.11",
266310
268151
  "@aws-sdk/region-config-resolver": "^3.972.6",
266311
- "@aws-sdk/token-providers": "3.1000.0",
268152
+ "@aws-sdk/token-providers": "3.1001.0",
266312
268153
  "@aws-sdk/types": "^3.973.4",
266313
268154
  "@aws-sdk/util-endpoints": "^3.996.3",
266314
268155
  "@aws-sdk/util-user-agent-browser": "^3.972.6",
266315
- "@aws-sdk/util-user-agent-node": "^3.973.0",
268156
+ "@aws-sdk/util-user-agent-node": "^3.973.1",
266316
268157
  "@smithy/config-resolver": "^4.4.9",
266317
- "@smithy/core": "^3.23.6",
268158
+ "@smithy/core": "^3.23.7",
266318
268159
  "@smithy/eventstream-serde-browser": "^4.2.10",
266319
268160
  "@smithy/eventstream-serde-config-resolver": "^4.3.10",
266320
268161
  "@smithy/eventstream-serde-node": "^4.2.10",
266321
- "@smithy/fetch-http-handler": "^5.3.11",
268162
+ "@smithy/fetch-http-handler": "^5.3.12",
266322
268163
  "@smithy/hash-node": "^4.2.10",
266323
268164
  "@smithy/invalid-dependency": "^4.2.10",
266324
268165
  "@smithy/middleware-content-length": "^4.2.10",
266325
- "@smithy/middleware-endpoint": "^4.4.20",
266326
- "@smithy/middleware-retry": "^4.4.37",
268166
+ "@smithy/middleware-endpoint": "^4.4.21",
268167
+ "@smithy/middleware-retry": "^4.4.38",
266327
268168
  "@smithy/middleware-serde": "^4.2.11",
266328
268169
  "@smithy/middleware-stack": "^4.2.10",
266329
268170
  "@smithy/node-config-provider": "^4.3.10",
266330
- "@smithy/node-http-handler": "^4.4.12",
268171
+ "@smithy/node-http-handler": "^4.4.13",
266331
268172
  "@smithy/protocol-http": "^5.3.10",
266332
- "@smithy/smithy-client": "^4.12.0",
268173
+ "@smithy/smithy-client": "^4.12.1",
266333
268174
  "@smithy/types": "^4.13.0",
266334
268175
  "@smithy/url-parser": "^4.2.10",
266335
268176
  "@smithy/util-base64": "^4.3.1",
266336
268177
  "@smithy/util-body-length-browser": "^4.2.1",
266337
268178
  "@smithy/util-body-length-node": "^4.2.2",
266338
- "@smithy/util-defaults-mode-browser": "^4.3.36",
266339
- "@smithy/util-defaults-mode-node": "^4.2.39",
268179
+ "@smithy/util-defaults-mode-browser": "^4.3.37",
268180
+ "@smithy/util-defaults-mode-node": "^4.2.40",
266340
268181
  "@smithy/util-endpoints": "^3.3.1",
266341
268182
  "@smithy/util-middleware": "^4.2.10",
266342
268183
  "@smithy/util-retry": "^4.2.10",
266343
- "@smithy/util-stream": "^4.5.15",
268184
+ "@smithy/util-stream": "^4.5.16",
266344
268185
  "@smithy/util-utf8": "^4.2.1",
266345
268186
  tslib: "^2.6.2"
266346
268187
  },
266347
268188
  devDependencies: {
266348
- "@smithy/snapshot-testing": "^1.0.7",
268189
+ "@smithy/snapshot-testing": "^1.0.8",
266349
268190
  "@tsconfig/node20": "20.1.8",
266350
268191
  "@types/node": "^20.14.8",
266351
268192
  concurrently: "7.0.0",
@@ -267061,7 +268902,7 @@ var init_package = __esm({
267061
268902
  "node_modules/@aws-sdk/nested-clients/package.json"() {
267062
268903
  package_default = {
267063
268904
  name: "@aws-sdk/nested-clients",
267064
- version: "3.996.3",
268905
+ version: "3.996.4",
267065
268906
  description: "Nested clients for AWS SDK packages.",
267066
268907
  main: "./dist-cjs/index.js",
267067
268908
  module: "./dist-es/index.js",
@@ -267090,37 +268931,37 @@ var init_package = __esm({
267090
268931
  dependencies: {
267091
268932
  "@aws-crypto/sha256-browser": "5.2.0",
267092
268933
  "@aws-crypto/sha256-js": "5.2.0",
267093
- "@aws-sdk/core": "^3.973.15",
268934
+ "@aws-sdk/core": "^3.973.16",
267094
268935
  "@aws-sdk/middleware-host-header": "^3.972.6",
267095
268936
  "@aws-sdk/middleware-logger": "^3.972.6",
267096
268937
  "@aws-sdk/middleware-recursion-detection": "^3.972.6",
267097
- "@aws-sdk/middleware-user-agent": "^3.972.15",
268938
+ "@aws-sdk/middleware-user-agent": "^3.972.16",
267098
268939
  "@aws-sdk/region-config-resolver": "^3.972.6",
267099
268940
  "@aws-sdk/types": "^3.973.4",
267100
268941
  "@aws-sdk/util-endpoints": "^3.996.3",
267101
268942
  "@aws-sdk/util-user-agent-browser": "^3.972.6",
267102
- "@aws-sdk/util-user-agent-node": "^3.973.0",
268943
+ "@aws-sdk/util-user-agent-node": "^3.973.1",
267103
268944
  "@smithy/config-resolver": "^4.4.9",
267104
- "@smithy/core": "^3.23.6",
267105
- "@smithy/fetch-http-handler": "^5.3.11",
268945
+ "@smithy/core": "^3.23.7",
268946
+ "@smithy/fetch-http-handler": "^5.3.12",
267106
268947
  "@smithy/hash-node": "^4.2.10",
267107
268948
  "@smithy/invalid-dependency": "^4.2.10",
267108
268949
  "@smithy/middleware-content-length": "^4.2.10",
267109
- "@smithy/middleware-endpoint": "^4.4.20",
267110
- "@smithy/middleware-retry": "^4.4.37",
268950
+ "@smithy/middleware-endpoint": "^4.4.21",
268951
+ "@smithy/middleware-retry": "^4.4.38",
267111
268952
  "@smithy/middleware-serde": "^4.2.11",
267112
268953
  "@smithy/middleware-stack": "^4.2.10",
267113
268954
  "@smithy/node-config-provider": "^4.3.10",
267114
- "@smithy/node-http-handler": "^4.4.12",
268955
+ "@smithy/node-http-handler": "^4.4.13",
267115
268956
  "@smithy/protocol-http": "^5.3.10",
267116
- "@smithy/smithy-client": "^4.12.0",
268957
+ "@smithy/smithy-client": "^4.12.1",
267117
268958
  "@smithy/types": "^4.13.0",
267118
268959
  "@smithy/url-parser": "^4.2.10",
267119
268960
  "@smithy/util-base64": "^4.3.1",
267120
268961
  "@smithy/util-body-length-browser": "^4.2.1",
267121
268962
  "@smithy/util-body-length-node": "^4.2.2",
267122
- "@smithy/util-defaults-mode-browser": "^4.3.36",
267123
- "@smithy/util-defaults-mode-node": "^4.2.39",
268963
+ "@smithy/util-defaults-mode-browser": "^4.3.37",
268964
+ "@smithy/util-defaults-mode-node": "^4.2.40",
267124
268965
  "@smithy/util-endpoints": "^3.3.1",
267125
268966
  "@smithy/util-middleware": "^4.2.10",
267126
268967
  "@smithy/util-retry": "^4.2.10",
@@ -267225,17 +269066,30 @@ var require_dist_cjs51 = __commonJS({
267225
269066
  }
267226
269067
  return ["md/nodejs", node_process.versions.node];
267227
269068
  };
267228
- var getTypeScriptPackageJsonPath = (dirname6 = "") => {
267229
- let nodeModulesPath;
269069
+ var SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
269070
+ var getSanitizedTypeScriptVersion = (version2 = "") => {
269071
+ const match2 = version2.match(SEMVER_REGEX);
269072
+ if (!match2) {
269073
+ return void 0;
269074
+ }
269075
+ const [major, minor, patch, prerelease] = [match2[1], match2[2], match2[3], match2[4]];
269076
+ return prerelease ? `${major}.${minor}.${patch}-${prerelease}` : `${major}.${minor}.${patch}`;
269077
+ };
269078
+ var typescriptPackageJsonPath = node_path.join("node_modules", "typescript", "package.json");
269079
+ var getTypeScriptPackageJsonPaths = (dirname6) => {
269080
+ const cwdPath = node_path.join(process.cwd(), typescriptPackageJsonPath);
269081
+ if (!dirname6) {
269082
+ return [cwdPath];
269083
+ }
267230
269084
  const normalizedPath = node_path.normalize(dirname6);
267231
269085
  const parts = normalizedPath.split(node_path.sep);
267232
269086
  const nodeModulesIndex = parts.indexOf("node_modules");
267233
- if (nodeModulesIndex !== -1) {
267234
- nodeModulesPath = parts.slice(0, nodeModulesIndex).join(node_path.sep);
267235
- } else {
267236
- nodeModulesPath = dirname6;
269087
+ const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(node_path.sep) : dirname6;
269088
+ const parentDirPath = node_path.join(parentDir, typescriptPackageJsonPath);
269089
+ if (cwdPath === parentDirPath) {
269090
+ return [cwdPath];
267237
269091
  }
267238
- return node_path.join(nodeModulesPath, "node_modules", "typescript", "package.json");
269092
+ return [parentDirPath, cwdPath];
267239
269093
  };
267240
269094
  var tscVersion;
267241
269095
  var getTypeScriptUserAgentPair = async () => {
@@ -267244,18 +269098,22 @@ var require_dist_cjs51 = __commonJS({
267244
269098
  } else if (typeof tscVersion === "string") {
267245
269099
  return ["md/tsc", tscVersion];
267246
269100
  }
267247
- try {
267248
- const packageJson = await promises.readFile(getTypeScriptPackageJsonPath(__dirname), "utf-8");
267249
- const { version: version2 } = JSON.parse(packageJson);
267250
- if (typeof version2 !== "string") {
267251
- tscVersion = null;
267252
- return void 0;
269101
+ const dirname6 = typeof __dirname !== "undefined" ? __dirname : void 0;
269102
+ for (const typescriptPackageJsonPath2 of getTypeScriptPackageJsonPaths(dirname6)) {
269103
+ try {
269104
+ const packageJson = await promises.readFile(typescriptPackageJsonPath2, "utf-8");
269105
+ const { version: version2 } = JSON.parse(packageJson);
269106
+ const sanitizedVersion = getSanitizedTypeScriptVersion(version2);
269107
+ if (typeof sanitizedVersion !== "string") {
269108
+ continue;
269109
+ }
269110
+ tscVersion = sanitizedVersion;
269111
+ return ["md/tsc", tscVersion];
269112
+ } catch {
267253
269113
  }
267254
- tscVersion = version2;
267255
- return ["md/tsc", tscVersion];
267256
- } catch {
267257
- tscVersion = null;
267258
269114
  }
269115
+ tscVersion = null;
269116
+ return void 0;
267259
269117
  };
267260
269118
  var crtAvailability = {
267261
269119
  isCrtAvailable: false
@@ -268354,9 +270212,9 @@ var init_sso_oidc = __esm({
268354
270212
  }
268355
270213
  });
268356
270214
 
268357
- // node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js
270215
+ // node_modules/@aws-sdk/token-providers/dist-cjs/index.js
268358
270216
  var require_dist_cjs56 = __commonJS({
268359
- "node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js"(exports2) {
270217
+ "node_modules/@aws-sdk/token-providers/dist-cjs/index.js"(exports2) {
268360
270218
  "use strict";
268361
270219
  var client = (init_client(), __toCommonJS(client_exports));
268362
270220
  var httpAuthSchemes = (init_httpAuthSchemes2(), __toCommonJS(httpAuthSchemes_exports));
@@ -272189,155 +274047,8 @@ var require_dist_cjs63 = __commonJS({
272189
274047
  }
272190
274048
  });
272191
274049
 
272192
- // node_modules/@aws-sdk/token-providers/dist-cjs/index.js
272193
- var require_dist_cjs64 = __commonJS({
272194
- "node_modules/@aws-sdk/token-providers/dist-cjs/index.js"(exports2) {
272195
- "use strict";
272196
- var client = (init_client(), __toCommonJS(client_exports));
272197
- var httpAuthSchemes = (init_httpAuthSchemes2(), __toCommonJS(httpAuthSchemes_exports));
272198
- var propertyProvider = require_dist_cjs24();
272199
- var sharedIniFileLoader = require_dist_cjs42();
272200
- var node_fs = __nccwpck_require__(73024);
272201
- var fromEnvSigningName = ({ logger: logger2, signingName } = {}) => async () => {
272202
- logger2?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
272203
- if (!signingName) {
272204
- throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger: logger2 });
272205
- }
272206
- const bearerTokenKey = httpAuthSchemes.getBearerTokenEnvKey(signingName);
272207
- if (!(bearerTokenKey in process.env)) {
272208
- throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger: logger2 });
272209
- }
272210
- const token = { token: process.env[bearerTokenKey] };
272211
- client.setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
272212
- return token;
272213
- };
272214
- var EXPIRE_WINDOW_MS = 5 * 60 * 1e3;
272215
- var REFRESH_MESSAGE = `To refresh this SSO session run 'aws sso login' with the corresponding profile.`;
272216
- var getSsoOidcClient = async (ssoRegion, init = {}, callerClientConfig) => {
272217
- const { SSOOIDCClient: SSOOIDCClient2 } = await Promise.resolve().then(() => (init_sso_oidc(), sso_oidc_exports));
272218
- const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop] ?? callerClientConfig?.[prop];
272219
- const ssoOidcClient = new SSOOIDCClient2(Object.assign({}, init.clientConfig ?? {}, {
272220
- region: ssoRegion ?? init.clientConfig?.region,
272221
- logger: coalesce("logger"),
272222
- userAgentAppId: coalesce("userAgentAppId")
272223
- }));
272224
- return ssoOidcClient;
272225
- };
272226
- var getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConfig) => {
272227
- const { CreateTokenCommand: CreateTokenCommand2 } = await Promise.resolve().then(() => (init_sso_oidc(), sso_oidc_exports));
272228
- const ssoOidcClient = await getSsoOidcClient(ssoRegion, init, callerClientConfig);
272229
- return ssoOidcClient.send(new CreateTokenCommand2({
272230
- clientId: ssoToken.clientId,
272231
- clientSecret: ssoToken.clientSecret,
272232
- refreshToken: ssoToken.refreshToken,
272233
- grantType: "refresh_token"
272234
- }));
272235
- };
272236
- var validateTokenExpiry = (token) => {
272237
- if (token.expiration && token.expiration.getTime() < Date.now()) {
272238
- throw new propertyProvider.TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
272239
- }
272240
- };
272241
- var validateTokenKey = (key, value, forRefresh = false) => {
272242
- if (typeof value === "undefined") {
272243
- throw new propertyProvider.TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
272244
- }
272245
- };
272246
- var { writeFile: writeFile2 } = node_fs.promises;
272247
- var writeSSOTokenToFile = (id, ssoToken) => {
272248
- const tokenFilepath = sharedIniFileLoader.getSSOTokenFilepath(id);
272249
- const tokenString = JSON.stringify(ssoToken, null, 2);
272250
- return writeFile2(tokenFilepath, tokenString);
272251
- };
272252
- var lastRefreshAttemptTime = /* @__PURE__ */ new Date(0);
272253
- var fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
272254
- init.logger?.debug("@aws-sdk/token-providers - fromSso");
272255
- const profiles = await sharedIniFileLoader.parseKnownFiles(init);
272256
- const profileName = sharedIniFileLoader.getProfileName({
272257
- profile: init.profile ?? callerClientConfig?.profile
272258
- });
272259
- const profile = profiles[profileName];
272260
- if (!profile) {
272261
- throw new propertyProvider.TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
272262
- } else if (!profile["sso_session"]) {
272263
- throw new propertyProvider.TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
272264
- }
272265
- const ssoSessionName = profile["sso_session"];
272266
- const ssoSessions = await sharedIniFileLoader.loadSsoSessionData(init);
272267
- const ssoSession = ssoSessions[ssoSessionName];
272268
- if (!ssoSession) {
272269
- throw new propertyProvider.TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
272270
- }
272271
- for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
272272
- if (!ssoSession[ssoSessionRequiredKey]) {
272273
- throw new propertyProvider.TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
272274
- }
272275
- }
272276
- ssoSession["sso_start_url"];
272277
- const ssoRegion = ssoSession["sso_region"];
272278
- let ssoToken;
272279
- try {
272280
- ssoToken = await sharedIniFileLoader.getSSOTokenFromFile(ssoSessionName);
272281
- } catch (e5) {
272282
- throw new propertyProvider.TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
272283
- }
272284
- validateTokenKey("accessToken", ssoToken.accessToken);
272285
- validateTokenKey("expiresAt", ssoToken.expiresAt);
272286
- const { accessToken, expiresAt } = ssoToken;
272287
- const existingToken = { token: accessToken, expiration: new Date(expiresAt) };
272288
- if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
272289
- return existingToken;
272290
- }
272291
- if (Date.now() - lastRefreshAttemptTime.getTime() < 30 * 1e3) {
272292
- validateTokenExpiry(existingToken);
272293
- return existingToken;
272294
- }
272295
- validateTokenKey("clientId", ssoToken.clientId, true);
272296
- validateTokenKey("clientSecret", ssoToken.clientSecret, true);
272297
- validateTokenKey("refreshToken", ssoToken.refreshToken, true);
272298
- try {
272299
- lastRefreshAttemptTime.setTime(Date.now());
272300
- const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init, callerClientConfig);
272301
- validateTokenKey("accessToken", newSsoOidcToken.accessToken);
272302
- validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
272303
- const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1e3);
272304
- try {
272305
- await writeSSOTokenToFile(ssoSessionName, {
272306
- ...ssoToken,
272307
- accessToken: newSsoOidcToken.accessToken,
272308
- expiresAt: newTokenExpiration.toISOString(),
272309
- refreshToken: newSsoOidcToken.refreshToken
272310
- });
272311
- } catch (error2) {
272312
- }
272313
- return {
272314
- token: newSsoOidcToken.accessToken,
272315
- expiration: newTokenExpiration
272316
- };
272317
- } catch (error2) {
272318
- validateTokenExpiry(existingToken);
272319
- return existingToken;
272320
- }
272321
- };
272322
- var fromStatic = ({ token, logger: logger2 }) => async () => {
272323
- logger2?.debug("@aws-sdk/token-providers - fromStatic");
272324
- if (!token || !token.token) {
272325
- throw new propertyProvider.TokenProviderError(`Please pass a valid token to fromStatic`, false);
272326
- }
272327
- return token;
272328
- };
272329
- var nodeProvider = (init = {}) => propertyProvider.memoize(propertyProvider.chain(fromSso(init), async () => {
272330
- throw new propertyProvider.TokenProviderError("Could not load token from any providers", false);
272331
- }), (token) => token.expiration !== void 0 && token.expiration.getTime() - Date.now() < 3e5, (token) => token.expiration !== void 0);
272332
- exports2.fromEnvSigningName = fromEnvSigningName;
272333
- exports2.fromSso = fromSso;
272334
- exports2.fromStatic = fromStatic;
272335
- exports2.nodeProvider = nodeProvider;
272336
- }
272337
- });
272338
-
272339
274050
  // node_modules/@smithy/eventstream-serde-node/dist-cjs/index.js
272340
- var require_dist_cjs65 = __commonJS({
274051
+ var require_dist_cjs64 = __commonJS({
272341
274052
  "node_modules/@smithy/eventstream-serde-node/dist-cjs/index.js"(exports2) {
272342
274053
  "use strict";
272343
274054
  var eventstreamSerdeUniversal = require_dist_cjs35();
@@ -275019,11 +276730,11 @@ var require_runtimeConfig = __commonJS({
275019
276730
  var core_1 = (init_dist_es2(), __toCommonJS(dist_es_exports2));
275020
276731
  var credential_provider_node_1 = require_dist_cjs62();
275021
276732
  var eventstream_handler_node_1 = require_dist_cjs63();
275022
- var token_providers_1 = require_dist_cjs64();
276733
+ var token_providers_1 = require_dist_cjs56();
275023
276734
  var util_user_agent_node_1 = require_dist_cjs51();
275024
276735
  var config_resolver_1 = require_dist_cjs39();
275025
276736
  var core_2 = (init_dist_es(), __toCommonJS(dist_es_exports));
275026
- var eventstream_serde_node_1 = require_dist_cjs65();
276737
+ var eventstream_serde_node_1 = require_dist_cjs64();
275027
276738
  var hash_node_1 = require_dist_cjs52();
275028
276739
  var middleware_retry_1 = require_dist_cjs47();
275029
276740
  var node_config_provider_1 = require_dist_cjs43();
@@ -275095,7 +276806,7 @@ var require_runtimeConfig = __commonJS({
275095
276806
  });
275096
276807
 
275097
276808
  // node_modules/@aws-sdk/client-bedrock-runtime/dist-cjs/index.js
275098
- var require_dist_cjs66 = __commonJS({
276809
+ var require_dist_cjs65 = __commonJS({
275099
276810
  "node_modules/@aws-sdk/client-bedrock-runtime/dist-cjs/index.js"(exports2) {
275100
276811
  "use strict";
275101
276812
  var middlewareEventstream = require_dist_cjs3();
@@ -275940,13 +277651,13 @@ var import_client_bedrock_runtime, import_client_bedrock_runtime2, import_client
275940
277651
  var init_dist3 = __esm({
275941
277652
  "node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs"() {
275942
277653
  init_dist2();
275943
- import_client_bedrock_runtime = __toESM(require_dist_cjs66(), 1);
277654
+ import_client_bedrock_runtime = __toESM(require_dist_cjs65(), 1);
275944
277655
  init_dist();
275945
- import_client_bedrock_runtime2 = __toESM(require_dist_cjs66(), 1);
277656
+ import_client_bedrock_runtime2 = __toESM(require_dist_cjs65(), 1);
275946
277657
  init_dist();
275947
277658
  init_dist();
275948
277659
  init_dist2();
275949
- import_client_bedrock_runtime3 = __toESM(require_dist_cjs66(), 1);
277660
+ import_client_bedrock_runtime3 = __toESM(require_dist_cjs65(), 1);
275950
277661
  generateFileId = createIdGenerator({ prefix: "file", size: 16 });
275951
277662
  BedrockChatLanguageModel = class {
275952
277663
  constructor(modelId, settings, config) {
@@ -283637,6 +285348,8 @@ var init_fileTracker = __esm({
283637
285348
  this.debug = options.debug || false;
283638
285349
  this._seenFiles = /* @__PURE__ */ new Set();
283639
285350
  this._contentRecords = /* @__PURE__ */ new Map();
285351
+ this._textEditCounts = /* @__PURE__ */ new Map();
285352
+ this.maxConsecutiveTextEdits = 3;
283640
285353
  }
283641
285354
  /**
283642
285355
  * Mark a file as "seen" — the LLM has read its content.
@@ -283644,6 +285357,7 @@ var init_fileTracker = __esm({
283644
285357
  */
283645
285358
  markFileSeen(resolvedPath2) {
283646
285359
  this._seenFiles.add(resolvedPath2);
285360
+ this._textEditCounts.set(resolvedPath2, 0);
283647
285361
  if (this.debug) {
283648
285362
  console.error(`[FileTracker] Marked as seen: ${resolvedPath2}`);
283649
285363
  }
@@ -283789,9 +285503,37 @@ var init_fileTracker = __esm({
283789
285503
  * @param {string} resolvedPath - Absolute path to the file
283790
285504
  */
283791
285505
  async trackFileAfterWrite(resolvedPath2) {
283792
- this.markFileSeen(resolvedPath2);
285506
+ this._seenFiles.add(resolvedPath2);
283793
285507
  this.invalidateFileRecords(resolvedPath2);
283794
285508
  }
285509
+ /**
285510
+ * Record a text-mode edit (old_string/new_string) to a file.
285511
+ * Increments the consecutive edit counter.
285512
+ * @param {string} resolvedPath - Absolute path to the file
285513
+ */
285514
+ recordTextEdit(resolvedPath2) {
285515
+ const count = (this._textEditCounts.get(resolvedPath2) || 0) + 1;
285516
+ this._textEditCounts.set(resolvedPath2, count);
285517
+ if (this.debug) {
285518
+ console.error(`[FileTracker] Text edit #${count} for ${resolvedPath2}`);
285519
+ }
285520
+ }
285521
+ /**
285522
+ * Check if a file has had too many consecutive text edits without a re-read.
285523
+ * @param {string} resolvedPath - Absolute path to the file
285524
+ * @returns {{ok: boolean, editCount?: number, message?: string}}
285525
+ */
285526
+ checkTextEditStaleness(resolvedPath2) {
285527
+ const count = this._textEditCounts.get(resolvedPath2) || 0;
285528
+ if (count >= this.maxConsecutiveTextEdits) {
285529
+ return {
285530
+ ok: false,
285531
+ editCount: count,
285532
+ message: `This file has been edited ${count} times without being re-read. Use 'extract' to re-read the current file content before making more edits, to ensure you are working with the actual state of the file.`
285533
+ };
285534
+ }
285535
+ return { ok: true, editCount: count };
285536
+ }
283795
285537
  /**
283796
285538
  * Update the stored hash for a symbol after a successful write.
283797
285539
  * Enables chained edits to the same symbol.
@@ -283835,6 +285577,7 @@ var init_fileTracker = __esm({
283835
285577
  clear() {
283836
285578
  this._seenFiles.clear();
283837
285579
  this._contentRecords.clear();
285580
+ this._textEditCounts.clear();
283838
285581
  }
283839
285582
  };
283840
285583
  }
@@ -329635,6 +331378,9 @@ var init_prompts = __esm({
329635
331378
  predefinedPrompts = {
329636
331379
  "code-explorer": `You are ProbeChat Code Explorer, a specialized AI assistant focused on helping developers, product managers, and QAs understand and navigate codebases. Your primary function is to answer questions based on code, explain how systems work, and provide insights into code functionality using the provided code analysis tools.
329637
331380
 
331381
+ CRITICAL - You are READ-ONLY:
331382
+ You must NEVER create, modify, delete, or write files. You are strictly an exploration and analysis tool. If asked to make changes, implement features, fix bugs, or modify a PR, refuse and explain that file modifications must be done by the engineer tool \u2014 your role is only to investigate code and answer questions. Do not attempt workarounds using bash commands (echo, cat, tee, sed, etc.) to write files.
331383
+
329638
331384
  When exploring code:
329639
331385
  - Provide clear, concise explanations based on user request
329640
331386
  - Find and highlight the most relevant code snippets, if required
@@ -354367,7 +356113,9 @@ var init_ProbeAgent = __esm({
354367
356113
  return nativeTools;
354368
356114
  }
354369
356115
  for (const [toolName, toolImpl] of Object.entries(this.toolImplementations)) {
354370
- const { schema, description } = this._getToolSchemaAndDescription(toolName);
356116
+ const toolInfo = this._getToolSchemaAndDescription(toolName);
356117
+ if (!toolInfo) continue;
356118
+ const { schema, description } = toolInfo;
354371
356119
  if (schema && description) {
354372
356120
  nativeTools[toolName] = wrapTool(toolName, schema, description, toolImpl.execute);
354373
356121
  }
@@ -355270,11 +357018,11 @@ Follow these instructions carefully:
355270
357018
  6. Prefer concise and focused search queries. Use specific keywords and phrases to narrow down results.${this.allowEdit ? `
355271
357019
  7. When modifying files, choose the appropriate tool:
355272
357020
  - Use 'edit' for all code modifications:
355273
- * For small changes (a line or a few lines), use old_string + new_string \u2014 copy old_string verbatim from the file.
355274
- * For rewriting entire functions/classes/methods, use the symbol parameter instead (no exact text matching needed).
355275
- * For editing specific lines from search/extract output, use start_line (and optionally end_line) with the line numbers shown in the output.${this.hashLines ? ' Line references include content hashes (e.g. "42:ab") for integrity verification.' : ""}
357021
+ * PREFERRED: Use start_line (and optionally end_line) for line-targeted editing \u2014 this is the safest and most precise approach.${this.hashLines ? ' Use the line:hash references from extract/search output (e.g. "42:ab") for integrity verification.' : ""} Always use extract first to see line numbers${this.hashLines ? " and hashes" : ""}, then edit by line reference.
355276
357022
  * For editing inside large functions: first use extract with the symbol target (e.g. "file.js#myFunction") to see the function with line numbers${this.hashLines ? " and hashes" : ""}, then use start_line/end_line to surgically edit specific lines within it.
355277
- * IMPORTANT: Keep old_string as small as possible \u2014 include only the lines you need to change plus minimal context for uniqueness. For replacing large blocks (10+ lines), prefer line-targeted editing with start_line/end_line to constrain scope.
357023
+ * For rewriting entire functions/classes/methods, use the symbol parameter instead (no exact text matching needed).
357024
+ * FALLBACK ONLY: Use old_string + new_string for simple single-line changes where the text is unique. Copy old_string verbatim from the file. Keep old_string as small as possible.
357025
+ * IMPORTANT: After multiple edits to the same file, re-read the changed areas before continuing \u2014 use extract with a targeted symbol (e.g. "file.js#myFunction") or a line range (e.g. "file.js:50-80") instead of re-reading the full file.
355278
357026
  - Use 'create' for new files or complete file rewrites.
355279
357027
  - If an edit fails, read the error message \u2014 it tells you exactly how to fix the call and retry.
355280
357028
  - The system tracks which files you've seen via search/extract. If you try to edit a file you haven't read, or one that changed since you last read it, the edit will fail with instructions to re-read first. Always use extract before editing to ensure you have current file content.` : ""}
@@ -358516,6 +360264,15 @@ Example: <extract><targets>${displayPath}</targets></extract>`;
358516
360264
  if (typeof old_string !== "string") {
358517
360265
  return `Error editing file: Invalid old_string - must be a string. Provide the exact text to find in the file, or use the symbol parameter instead for AST-aware editing by name.`;
358518
360266
  }
360267
+ if (options.fileTracker) {
360268
+ const staleCheck = options.fileTracker.checkTextEditStaleness(resolvedPath2);
360269
+ if (!staleCheck.ok) {
360270
+ const displayPath = toRelativePath(resolvedPath2, workspaceRoot);
360271
+ return `Error editing ${displayPath}: ${staleCheck.message}
360272
+
360273
+ Example: <extract><targets>${displayPath}</targets></extract>`;
360274
+ }
360275
+ }
358519
360276
  const content = await import_fs11.promises.readFile(resolvedPath2, "utf-8");
358520
360277
  let matchTarget = old_string;
358521
360278
  let matchStrategy = "exact";
@@ -358549,7 +360306,10 @@ Example: <extract><targets>${displayPath}</targets></extract>`;
358549
360306
  return `Error editing file: No changes made - the replacement result is identical to the original. Verify that old_string and new_string are actually different. If fuzzy matching was used, the matched text may already equal new_string.`;
358550
360307
  }
358551
360308
  await import_fs11.promises.writeFile(resolvedPath2, newContent, "utf-8");
358552
- if (options.fileTracker) await options.fileTracker.trackFileAfterWrite(resolvedPath2);
360309
+ if (options.fileTracker) {
360310
+ await options.fileTracker.trackFileAfterWrite(resolvedPath2);
360311
+ options.fileTracker.recordTextEdit(resolvedPath2);
360312
+ }
358553
360313
  const replacedCount = replace_all ? occurrences : 1;
358554
360314
  if (debug) {
358555
360315
  console.error(`[Edit] Successfully edited ${resolvedPath2}, replaced ${replacedCount} occurrence(s)`);
@@ -395174,7 +396934,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"100":"Continue","101":"Switching Pro
395174
396934
  /***/ ((module) => {
395175
396935
 
395176
396936
  "use strict";
395177
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.150","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-rc266","@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"]}}');
396937
+ 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-rc268","@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"]}}');
395178
396938
 
395179
396939
  /***/ })
395180
396940