@probelabs/visor 0.1.94 → 0.1.96

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 (44) hide show
  1. package/README.md +4 -4
  2. package/defaults/.visor.yaml +86 -6
  3. package/dist/ai-review-service.d.ts +1 -1
  4. package/dist/ai-review-service.d.ts.map +1 -1
  5. package/dist/cli-main.d.ts +1 -0
  6. package/dist/cli-main.d.ts.map +1 -1
  7. package/dist/cli.d.ts +1 -0
  8. package/dist/cli.d.ts.map +1 -1
  9. package/dist/commands.d.ts.map +1 -1
  10. package/dist/config.d.ts +6 -1
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/defaults/.visor.yaml +86 -6
  13. package/dist/failure-condition-evaluator.d.ts.map +1 -1
  14. package/dist/footer.d.ts +25 -0
  15. package/dist/footer.d.ts.map +1 -0
  16. package/dist/github-check-service.d.ts.map +1 -1
  17. package/dist/github-comments.d.ts.map +1 -1
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1968 -521
  21. package/dist/output/code-review/schema.json +0 -23
  22. package/dist/reviewer.d.ts +5 -2
  23. package/dist/reviewer.d.ts.map +1 -1
  24. package/dist/sdk/{check-execution-engine-YBRPVUWD.mjs → check-execution-engine-NMPXJ7FQ.mjs} +2 -2
  25. package/dist/sdk/{chunk-DQRFOQAP.mjs → chunk-Q4S5A5TO.mjs} +199 -113
  26. package/dist/sdk/chunk-Q4S5A5TO.mjs.map +1 -0
  27. package/dist/sdk/sdk.js +249 -149
  28. package/dist/sdk/sdk.js.map +1 -1
  29. package/dist/sdk/sdk.mjs +23 -19
  30. package/dist/sdk/sdk.mjs.map +1 -1
  31. package/dist/traces/{run-2025-10-16T11-33-32-682Z.ndjson → run-2025-10-18T20-24-27-886Z.ndjson} +8 -1
  32. package/dist/traces/{run-2025-10-16T11-33-43-618Z.ndjson → run-2025-10-18T20-24-38-817Z.ndjson} +8 -1
  33. package/dist/traces/{run-2025-10-16T11-33-44-157Z.ndjson → run-2025-10-18T20-24-39-361Z.ndjson} +8 -1
  34. package/dist/traces/{run-2025-10-16T11-33-44-647Z.ndjson → run-2025-10-18T20-24-39-852Z.ndjson} +8 -1
  35. package/dist/types/cli.d.ts +3 -2
  36. package/dist/types/cli.d.ts.map +1 -1
  37. package/dist/types/config.d.ts +0 -2
  38. package/dist/types/config.d.ts.map +1 -1
  39. package/dist/utils/diff-processor.d.ts +6 -0
  40. package/dist/utils/diff-processor.d.ts.map +1 -0
  41. package/package.json +3 -2
  42. package/dist/sdk/chunk-DQRFOQAP.mjs.map +0 -1
  43. /package/dist/sdk/{check-execution-engine-YBRPVUWD.mjs.map → check-execution-engine-NMPXJ7FQ.mjs.map} +0 -0
  44. /package/dist/traces/{run-2025-10-16T11-33-45-128Z.ndjson → run-2025-10-18T20-24-40-335Z.ndjson} +0 -0
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- process.env.VISOR_VERSION = '0.1.94';
3
- process.env.PROBE_VERSION = '0.6.0-rc138';
2
+ process.env.VISOR_VERSION = '0.1.96';
3
+ process.env.PROBE_VERSION = '0.6.0-rc146';
4
4
  /******/ (() => { // webpackBootstrap
5
5
  /******/ var __webpack_modules__ = ({
6
6
 
@@ -177300,6 +177300,522 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
177300
177300
  };
177301
177301
 
177302
177302
 
177303
+ /***/ }),
177304
+
177305
+ /***/ 52874:
177306
+ /***/ ((__unused_webpack_module, __unused_webpack_exports, __nccwpck_require__) => {
177307
+
177308
+ (function () {
177309
+ (__nccwpck_require__(18889).config)(
177310
+ Object.assign(
177311
+ {},
177312
+ __nccwpck_require__(39990),
177313
+ __nccwpck_require__(4531)(process.argv)
177314
+ )
177315
+ )
177316
+ })()
177317
+
177318
+
177319
+ /***/ }),
177320
+
177321
+ /***/ 4531:
177322
+ /***/ ((module) => {
177323
+
177324
+ const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/
177325
+
177326
+ module.exports = function optionMatcher (args) {
177327
+ const options = args.reduce(function (acc, cur) {
177328
+ const matches = cur.match(re)
177329
+ if (matches) {
177330
+ acc[matches[1]] = matches[2]
177331
+ }
177332
+ return acc
177333
+ }, {})
177334
+
177335
+ if (!('quiet' in options)) {
177336
+ options.quiet = 'true'
177337
+ }
177338
+
177339
+ return options
177340
+ }
177341
+
177342
+
177343
+ /***/ }),
177344
+
177345
+ /***/ 39990:
177346
+ /***/ ((module) => {
177347
+
177348
+ // ../config.js accepts options via environment variables
177349
+ const options = {}
177350
+
177351
+ if (process.env.DOTENV_CONFIG_ENCODING != null) {
177352
+ options.encoding = process.env.DOTENV_CONFIG_ENCODING
177353
+ }
177354
+
177355
+ if (process.env.DOTENV_CONFIG_PATH != null) {
177356
+ options.path = process.env.DOTENV_CONFIG_PATH
177357
+ }
177358
+
177359
+ if (process.env.DOTENV_CONFIG_QUIET != null) {
177360
+ options.quiet = process.env.DOTENV_CONFIG_QUIET
177361
+ }
177362
+
177363
+ if (process.env.DOTENV_CONFIG_DEBUG != null) {
177364
+ options.debug = process.env.DOTENV_CONFIG_DEBUG
177365
+ }
177366
+
177367
+ if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
177368
+ options.override = process.env.DOTENV_CONFIG_OVERRIDE
177369
+ }
177370
+
177371
+ if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
177372
+ options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY
177373
+ }
177374
+
177375
+ module.exports = options
177376
+
177377
+
177378
+ /***/ }),
177379
+
177380
+ /***/ 18889:
177381
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
177382
+
177383
+ const fs = __nccwpck_require__(79896)
177384
+ const path = __nccwpck_require__(16928)
177385
+ const os = __nccwpck_require__(70857)
177386
+ const crypto = __nccwpck_require__(76982)
177387
+ const packageJson = __nccwpck_require__(80056)
177388
+
177389
+ const version = packageJson.version
177390
+
177391
+ // Array of tips to display randomly
177392
+ const TIPS = [
177393
+ '🔐 encrypt with Dotenvx: https://dotenvx.com',
177394
+ '🔐 prevent committing .env to code: https://dotenvx.com/precommit',
177395
+ '🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
177396
+ '📡 add observability to secrets: https://dotenvx.com/ops',
177397
+ '👥 sync secrets across teammates & machines: https://dotenvx.com/ops',
177398
+ '🗂️ backup and recover secrets: https://dotenvx.com/ops',
177399
+ '✅ audit secrets and track compliance: https://dotenvx.com/ops',
177400
+ '🔄 add secrets lifecycle management: https://dotenvx.com/ops',
177401
+ '🔑 add access controls to secrets: https://dotenvx.com/ops',
177402
+ '🛠️ run anywhere with `dotenvx run -- yourcommand`',
177403
+ '⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
177404
+ '⚙️ enable debug logging with { debug: true }',
177405
+ '⚙️ override existing env vars with { override: true }',
177406
+ '⚙️ suppress all logs with { quiet: true }',
177407
+ '⚙️ write to custom object with { processEnv: myObject }',
177408
+ '⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
177409
+ ]
177410
+
177411
+ // Get a random tip from the tips array
177412
+ function _getRandomTip () {
177413
+ return TIPS[Math.floor(Math.random() * TIPS.length)]
177414
+ }
177415
+
177416
+ function parseBoolean (value) {
177417
+ if (typeof value === 'string') {
177418
+ return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
177419
+ }
177420
+ return Boolean(value)
177421
+ }
177422
+
177423
+ function supportsAnsi () {
177424
+ return process.stdout.isTTY // && process.env.TERM !== 'dumb'
177425
+ }
177426
+
177427
+ function dim (text) {
177428
+ return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text
177429
+ }
177430
+
177431
+ const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg
177432
+
177433
+ // Parse src into an Object
177434
+ function parse (src) {
177435
+ const obj = {}
177436
+
177437
+ // Convert buffer to string
177438
+ let lines = src.toString()
177439
+
177440
+ // Convert line breaks to same format
177441
+ lines = lines.replace(/\r\n?/mg, '\n')
177442
+
177443
+ let match
177444
+ while ((match = LINE.exec(lines)) != null) {
177445
+ const key = match[1]
177446
+
177447
+ // Default undefined or null to empty string
177448
+ let value = (match[2] || '')
177449
+
177450
+ // Remove whitespace
177451
+ value = value.trim()
177452
+
177453
+ // Check if double quoted
177454
+ const maybeQuote = value[0]
177455
+
177456
+ // Remove surrounding quotes
177457
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2')
177458
+
177459
+ // Expand newlines if double quoted
177460
+ if (maybeQuote === '"') {
177461
+ value = value.replace(/\\n/g, '\n')
177462
+ value = value.replace(/\\r/g, '\r')
177463
+ }
177464
+
177465
+ // Add to object
177466
+ obj[key] = value
177467
+ }
177468
+
177469
+ return obj
177470
+ }
177471
+
177472
+ function _parseVault (options) {
177473
+ options = options || {}
177474
+
177475
+ const vaultPath = _vaultPath(options)
177476
+ options.path = vaultPath // parse .env.vault
177477
+ const result = DotenvModule.configDotenv(options)
177478
+ if (!result.parsed) {
177479
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)
177480
+ err.code = 'MISSING_DATA'
177481
+ throw err
177482
+ }
177483
+
177484
+ // handle scenario for comma separated keys - for use with key rotation
177485
+ // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
177486
+ const keys = _dotenvKey(options).split(',')
177487
+ const length = keys.length
177488
+
177489
+ let decrypted
177490
+ for (let i = 0; i < length; i++) {
177491
+ try {
177492
+ // Get full key
177493
+ const key = keys[i].trim()
177494
+
177495
+ // Get instructions for decrypt
177496
+ const attrs = _instructions(result, key)
177497
+
177498
+ // Decrypt
177499
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)
177500
+
177501
+ break
177502
+ } catch (error) {
177503
+ // last key
177504
+ if (i + 1 >= length) {
177505
+ throw error
177506
+ }
177507
+ // try next key
177508
+ }
177509
+ }
177510
+
177511
+ // Parse decrypted .env string
177512
+ return DotenvModule.parse(decrypted)
177513
+ }
177514
+
177515
+ function _warn (message) {
177516
+ console.error(`[dotenv@${version}][WARN] ${message}`)
177517
+ }
177518
+
177519
+ function _debug (message) {
177520
+ console.log(`[dotenv@${version}][DEBUG] ${message}`)
177521
+ }
177522
+
177523
+ function _log (message) {
177524
+ console.log(`[dotenv@${version}] ${message}`)
177525
+ }
177526
+
177527
+ function _dotenvKey (options) {
177528
+ // prioritize developer directly setting options.DOTENV_KEY
177529
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
177530
+ return options.DOTENV_KEY
177531
+ }
177532
+
177533
+ // secondary infra already contains a DOTENV_KEY environment variable
177534
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
177535
+ return process.env.DOTENV_KEY
177536
+ }
177537
+
177538
+ // fallback to empty string
177539
+ return ''
177540
+ }
177541
+
177542
+ function _instructions (result, dotenvKey) {
177543
+ // Parse DOTENV_KEY. Format is a URI
177544
+ let uri
177545
+ try {
177546
+ uri = new URL(dotenvKey)
177547
+ } catch (error) {
177548
+ if (error.code === 'ERR_INVALID_URL') {
177549
+ const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development')
177550
+ err.code = 'INVALID_DOTENV_KEY'
177551
+ throw err
177552
+ }
177553
+
177554
+ throw error
177555
+ }
177556
+
177557
+ // Get decrypt key
177558
+ const key = uri.password
177559
+ if (!key) {
177560
+ const err = new Error('INVALID_DOTENV_KEY: Missing key part')
177561
+ err.code = 'INVALID_DOTENV_KEY'
177562
+ throw err
177563
+ }
177564
+
177565
+ // Get environment
177566
+ const environment = uri.searchParams.get('environment')
177567
+ if (!environment) {
177568
+ const err = new Error('INVALID_DOTENV_KEY: Missing environment part')
177569
+ err.code = 'INVALID_DOTENV_KEY'
177570
+ throw err
177571
+ }
177572
+
177573
+ // Get ciphertext payload
177574
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`
177575
+ const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION
177576
+ if (!ciphertext) {
177577
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)
177578
+ err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'
177579
+ throw err
177580
+ }
177581
+
177582
+ return { ciphertext, key }
177583
+ }
177584
+
177585
+ function _vaultPath (options) {
177586
+ let possibleVaultPath = null
177587
+
177588
+ if (options && options.path && options.path.length > 0) {
177589
+ if (Array.isArray(options.path)) {
177590
+ for (const filepath of options.path) {
177591
+ if (fs.existsSync(filepath)) {
177592
+ possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`
177593
+ }
177594
+ }
177595
+ } else {
177596
+ possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`
177597
+ }
177598
+ } else {
177599
+ possibleVaultPath = path.resolve(process.cwd(), '.env.vault')
177600
+ }
177601
+
177602
+ if (fs.existsSync(possibleVaultPath)) {
177603
+ return possibleVaultPath
177604
+ }
177605
+
177606
+ return null
177607
+ }
177608
+
177609
+ function _resolveHome (envPath) {
177610
+ return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
177611
+ }
177612
+
177613
+ function _configVault (options) {
177614
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug))
177615
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet))
177616
+
177617
+ if (debug || !quiet) {
177618
+ _log('Loading env from encrypted .env.vault')
177619
+ }
177620
+
177621
+ const parsed = DotenvModule._parseVault(options)
177622
+
177623
+ let processEnv = process.env
177624
+ if (options && options.processEnv != null) {
177625
+ processEnv = options.processEnv
177626
+ }
177627
+
177628
+ DotenvModule.populate(processEnv, parsed, options)
177629
+
177630
+ return { parsed }
177631
+ }
177632
+
177633
+ function configDotenv (options) {
177634
+ const dotenvPath = path.resolve(process.cwd(), '.env')
177635
+ let encoding = 'utf8'
177636
+ let processEnv = process.env
177637
+ if (options && options.processEnv != null) {
177638
+ processEnv = options.processEnv
177639
+ }
177640
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug))
177641
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet))
177642
+
177643
+ if (options && options.encoding) {
177644
+ encoding = options.encoding
177645
+ } else {
177646
+ if (debug) {
177647
+ _debug('No encoding is specified. UTF-8 is used by default')
177648
+ }
177649
+ }
177650
+
177651
+ let optionPaths = [dotenvPath] // default, look for .env
177652
+ if (options && options.path) {
177653
+ if (!Array.isArray(options.path)) {
177654
+ optionPaths = [_resolveHome(options.path)]
177655
+ } else {
177656
+ optionPaths = [] // reset default
177657
+ for (const filepath of options.path) {
177658
+ optionPaths.push(_resolveHome(filepath))
177659
+ }
177660
+ }
177661
+ }
177662
+
177663
+ // Build the parsed data in a temporary object (because we need to return it). Once we have the final
177664
+ // parsed data, we will combine it with process.env (or options.processEnv if provided).
177665
+ let lastError
177666
+ const parsedAll = {}
177667
+ for (const path of optionPaths) {
177668
+ try {
177669
+ // Specifying an encoding returns a string instead of a buffer
177670
+ const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))
177671
+
177672
+ DotenvModule.populate(parsedAll, parsed, options)
177673
+ } catch (e) {
177674
+ if (debug) {
177675
+ _debug(`Failed to load ${path} ${e.message}`)
177676
+ }
177677
+ lastError = e
177678
+ }
177679
+ }
177680
+
177681
+ const populated = DotenvModule.populate(processEnv, parsedAll, options)
177682
+
177683
+ // handle user settings DOTENV_CONFIG_ options inside .env file(s)
177684
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug)
177685
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet)
177686
+
177687
+ if (debug || !quiet) {
177688
+ const keysCount = Object.keys(populated).length
177689
+ const shortPaths = []
177690
+ for (const filePath of optionPaths) {
177691
+ try {
177692
+ const relative = path.relative(process.cwd(), filePath)
177693
+ shortPaths.push(relative)
177694
+ } catch (e) {
177695
+ if (debug) {
177696
+ _debug(`Failed to load ${filePath} ${e.message}`)
177697
+ }
177698
+ lastError = e
177699
+ }
177700
+ }
177701
+
177702
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(',')} ${dim(`-- tip: ${_getRandomTip()}`)}`)
177703
+ }
177704
+
177705
+ if (lastError) {
177706
+ return { parsed: parsedAll, error: lastError }
177707
+ } else {
177708
+ return { parsed: parsedAll }
177709
+ }
177710
+ }
177711
+
177712
+ // Populates process.env from .env file
177713
+ function config (options) {
177714
+ // fallback to original dotenv if DOTENV_KEY is not set
177715
+ if (_dotenvKey(options).length === 0) {
177716
+ return DotenvModule.configDotenv(options)
177717
+ }
177718
+
177719
+ const vaultPath = _vaultPath(options)
177720
+
177721
+ // dotenvKey exists but .env.vault file does not exist
177722
+ if (!vaultPath) {
177723
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`)
177724
+
177725
+ return DotenvModule.configDotenv(options)
177726
+ }
177727
+
177728
+ return DotenvModule._configVault(options)
177729
+ }
177730
+
177731
+ function decrypt (encrypted, keyStr) {
177732
+ const key = Buffer.from(keyStr.slice(-64), 'hex')
177733
+ let ciphertext = Buffer.from(encrypted, 'base64')
177734
+
177735
+ const nonce = ciphertext.subarray(0, 12)
177736
+ const authTag = ciphertext.subarray(-16)
177737
+ ciphertext = ciphertext.subarray(12, -16)
177738
+
177739
+ try {
177740
+ const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)
177741
+ aesgcm.setAuthTag(authTag)
177742
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
177743
+ } catch (error) {
177744
+ const isRange = error instanceof RangeError
177745
+ const invalidKeyLength = error.message === 'Invalid key length'
177746
+ const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'
177747
+
177748
+ if (isRange || invalidKeyLength) {
177749
+ const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')
177750
+ err.code = 'INVALID_DOTENV_KEY'
177751
+ throw err
177752
+ } else if (decryptionFailed) {
177753
+ const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')
177754
+ err.code = 'DECRYPTION_FAILED'
177755
+ throw err
177756
+ } else {
177757
+ throw error
177758
+ }
177759
+ }
177760
+ }
177761
+
177762
+ // Populate process.env with parsed values
177763
+ function populate (processEnv, parsed, options = {}) {
177764
+ const debug = Boolean(options && options.debug)
177765
+ const override = Boolean(options && options.override)
177766
+ const populated = {}
177767
+
177768
+ if (typeof parsed !== 'object') {
177769
+ const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')
177770
+ err.code = 'OBJECT_REQUIRED'
177771
+ throw err
177772
+ }
177773
+
177774
+ // Set process.env
177775
+ for (const key of Object.keys(parsed)) {
177776
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
177777
+ if (override === true) {
177778
+ processEnv[key] = parsed[key]
177779
+ populated[key] = parsed[key]
177780
+ }
177781
+
177782
+ if (debug) {
177783
+ if (override === true) {
177784
+ _debug(`"${key}" is already defined and WAS overwritten`)
177785
+ } else {
177786
+ _debug(`"${key}" is already defined and was NOT overwritten`)
177787
+ }
177788
+ }
177789
+ } else {
177790
+ processEnv[key] = parsed[key]
177791
+ populated[key] = parsed[key]
177792
+ }
177793
+ }
177794
+
177795
+ return populated
177796
+ }
177797
+
177798
+ const DotenvModule = {
177799
+ configDotenv,
177800
+ _configVault,
177801
+ _parseVault,
177802
+ config,
177803
+ decrypt,
177804
+ parse,
177805
+ populate
177806
+ }
177807
+
177808
+ module.exports.configDotenv = DotenvModule.configDotenv
177809
+ module.exports._configVault = DotenvModule._configVault
177810
+ module.exports._parseVault = DotenvModule._parseVault
177811
+ module.exports.config = DotenvModule.config
177812
+ module.exports.decrypt = DotenvModule.decrypt
177813
+ module.exports.parse = DotenvModule.parse
177814
+ module.exports.populate = DotenvModule.populate
177815
+
177816
+ module.exports = DotenvModule
177817
+
177818
+
177303
177819
  /***/ }),
177304
177820
 
177305
177821
  /***/ 26669:
@@ -218031,6 +218547,7 @@ const probe_1 = __nccwpck_require__(83841);
218031
218547
  const session_registry_1 = __nccwpck_require__(46059);
218032
218548
  const logger_1 = __nccwpck_require__(86999);
218033
218549
  const tracer_init_1 = __nccwpck_require__(11903);
218550
+ const diff_processor_1 = __nccwpck_require__(29883);
218034
218551
  /**
218035
218552
  * Helper function to log debug messages using the centralized logger
218036
218553
  */
@@ -218083,7 +218600,7 @@ class AIReviewService {
218083
218600
  /**
218084
218601
  * Execute AI review using probe agent
218085
218602
  */
218086
- async executeReview(prInfo, customPrompt, schema, _checkName, sessionId) {
218603
+ async executeReview(prInfo, customPrompt, schema, checkName, sessionId) {
218087
218604
  const startTime = Date.now();
218088
218605
  const timestamp = new Date().toISOString();
218089
218606
  // Build prompt from custom instructions
@@ -218140,7 +218657,7 @@ class AIReviewService {
218140
218657
  }
218141
218658
  }
218142
218659
  try {
218143
- const { response, effectiveSchema } = await this.callProbeAgent(prompt, schema, debugInfo, _checkName, sessionId);
218660
+ const { response, effectiveSchema } = await this.callProbeAgent(prompt, schema, debugInfo, checkName, sessionId);
218144
218661
  const processingTime = Date.now() - startTime;
218145
218662
  if (debugInfo) {
218146
218663
  debugInfo.rawResponse = response;
@@ -218300,10 +218817,10 @@ class AIReviewService {
218300
218817
  async buildCustomPrompt(prInfo, customInstructions, schema, options) {
218301
218818
  // When reusing sessions, skip PR context to avoid sending duplicate diff data
218302
218819
  const skipPRContext = options?.skipPRContext === true;
218303
- const prContext = skipPRContext ? '' : this.formatPRContext(prInfo);
218304
- const isIssue = prInfo.isIssue === true;
218305
218820
  // Check if we're using the code-review schema
218306
218821
  const isCodeReviewSchema = schema === 'code-review';
218822
+ const prContext = skipPRContext ? '' : await this.formatPRContext(prInfo, isCodeReviewSchema);
218823
+ const isIssue = prInfo.isIssue === true;
218307
218824
  if (isIssue) {
218308
218825
  // Issue context - no code analysis needed
218309
218826
  if (skipPRContext) {
@@ -218401,7 +218918,7 @@ ${prContext}
218401
218918
  /**
218402
218919
  * Format PR or Issue context for the AI using XML structure
218403
218920
  */
218404
- formatPRContext(prInfo) {
218921
+ async formatPRContext(prInfo, isCodeReviewSchema) {
218405
218922
  // Check if this is an issue (not a PR)
218406
218923
  const prContextInfo = prInfo;
218407
218924
  const isIssue = prContextInfo.isIssue === true;
@@ -218496,9 +219013,14 @@ ${this.escapeXml(prInfo.body)}
218496
219013
  const issueComments = prInfo.comments;
218497
219014
  if (issueComments && issueComments.length > 0) {
218498
219015
  // Filter out the triggering comment from history if present
218499
- const historicalComments = triggeringComment
219016
+ let historicalComments = triggeringComment
218500
219017
  ? issueComments.filter(c => c.id !== triggeringComment.id)
218501
219018
  : issueComments;
219019
+ // For code-review schema checks, filter out previous Visor code-review comments to avoid self-bias
219020
+ // Comment IDs look like: <!-- visor-comment-id:pr-review-244-review -->
219021
+ if (isCodeReviewSchema) {
219022
+ historicalComments = historicalComments.filter(c => !c.body || !c.body.includes('visor-comment-id:pr-review-'));
219023
+ }
218502
219024
  if (historicalComments.length > 0) {
218503
219025
  context += `
218504
219026
  <!-- Previous comments in chronological order (excluding triggering comment) -->
@@ -218545,26 +219067,34 @@ ${this.escapeXml(prInfo.body)}
218545
219067
  if (includeCodeContext) {
218546
219068
  // Add full diff if available (for complete PR review)
218547
219069
  if (prInfo.fullDiff) {
219070
+ // Process the diff with outline-diff format for better structure
219071
+ const processedFullDiff = await (0, diff_processor_1.processDiffWithOutline)(prInfo.fullDiff);
218548
219072
  context += `
218549
- <!-- Complete unified diff showing all changes in the pull request -->
219073
+ <!-- Complete unified diff showing all changes in the pull request (processed with outline-diff) -->
218550
219074
  <full_diff>
218551
- ${this.escapeXml(prInfo.fullDiff)}
219075
+ ${this.escapeXml(processedFullDiff)}
218552
219076
  </full_diff>`;
218553
219077
  }
218554
219078
  // Add incremental commit diff if available (for new commit analysis)
218555
219079
  if (prInfo.isIncremental) {
218556
219080
  if (prInfo.commitDiff && prInfo.commitDiff.length > 0) {
219081
+ // Process the commit diff with outline-diff format for better structure
219082
+ const processedCommitDiff = await (0, diff_processor_1.processDiffWithOutline)(prInfo.commitDiff);
218557
219083
  context += `
218558
- <!-- Diff of only the latest commit for incremental analysis -->
219084
+ <!-- Diff of only the latest commit for incremental analysis (processed with outline-diff) -->
218559
219085
  <commit_diff>
218560
- ${this.escapeXml(prInfo.commitDiff)}
219086
+ ${this.escapeXml(processedCommitDiff)}
218561
219087
  </commit_diff>`;
218562
219088
  }
218563
219089
  else {
219090
+ // Process the fallback full diff with outline-diff format
219091
+ const processedFallbackDiff = prInfo.fullDiff
219092
+ ? await (0, diff_processor_1.processDiffWithOutline)(prInfo.fullDiff)
219093
+ : '';
218564
219094
  context += `
218565
- <!-- Commit diff could not be retrieved - falling back to full diff analysis -->
219095
+ <!-- Commit diff could not be retrieved - falling back to full diff analysis (processed with outline-diff) -->
218566
219096
  <commit_diff>
218567
- ${prInfo.fullDiff ? this.escapeXml(prInfo.fullDiff) : ''}
219097
+ ${this.escapeXml(processedFallbackDiff)}
218568
219098
  </commit_diff>`;
218569
219099
  }
218570
219100
  }
@@ -218606,9 +219136,14 @@ ${prInfo.fullDiff ? this.escapeXml(prInfo.fullDiff) : ''}
218606
219136
  const prComments = prInfo.comments;
218607
219137
  if (prComments && prComments.length > 0) {
218608
219138
  // Filter out the triggering comment from history if present
218609
- const historicalComments = triggeringComment
219139
+ let historicalComments = triggeringComment
218610
219140
  ? prComments.filter(c => c.id !== triggeringComment.id)
218611
219141
  : prComments;
219142
+ // For code-review schema checks, filter out previous Visor code-review comments to avoid self-bias
219143
+ // Comment IDs look like: <!-- visor-comment-id:pr-review-244-review -->
219144
+ if (isCodeReviewSchema) {
219145
+ historicalComments = historicalComments.filter(c => !c.body || !c.body.includes('visor-comment-id:pr-review-'));
219146
+ }
218612
219147
  if (historicalComments.length > 0) {
218613
219148
  context += `
218614
219149
  <!-- Previous PR comments in chronological order (excluding triggering comment) -->
@@ -224361,6 +224896,8 @@ var __importStar = (this && this.__importStar) || (function () {
224361
224896
  })();
224362
224897
  Object.defineProperty(exports, "__esModule", ({ value: true }));
224363
224898
  exports.main = main;
224899
+ // Load environment variables from .env file
224900
+ __nccwpck_require__(52874);
224364
224901
  const cli_1 = __nccwpck_require__(95581);
224365
224902
  const config_1 = __nccwpck_require__(22973);
224366
224903
  const check_execution_engine_1 = __nccwpck_require__(80299);
@@ -224953,6 +225490,7 @@ var __importStar = (this && this.__importStar) || (function () {
224953
225490
  Object.defineProperty(exports, "__esModule", ({ value: true }));
224954
225491
  exports.CLI = void 0;
224955
225492
  const commander_1 = __nccwpck_require__(18909);
225493
+ const config_1 = __nccwpck_require__(22973);
224956
225494
  const fs = __importStar(__nccwpck_require__(79896));
224957
225495
  const path = __importStar(__nccwpck_require__(16928));
224958
225496
  /**
@@ -224962,6 +225500,12 @@ class CLI {
224962
225500
  program;
224963
225501
  validChecks = ['performance', 'architecture', 'security', 'style', 'all'];
224964
225502
  validOutputs = ['table', 'json', 'markdown', 'sarif'];
225503
+ // Valid events: all core EventTrigger types plus 'all' for CLI-only usage
225504
+ // Reuses VALID_EVENT_TRIGGERS from config.ts as the single source of truth
225505
+ validEvents = [
225506
+ ...config_1.VALID_EVENT_TRIGGERS,
225507
+ 'all', // CLI-specific: run checks regardless of event triggers
225508
+ ];
224965
225509
  constructor() {
224966
225510
  this.program = new commander_1.Command();
224967
225511
  this.setupProgram();
@@ -225092,6 +225636,8 @@ class CLI {
225092
225636
  help: options.help,
225093
225637
  version: options.version,
225094
225638
  codeContext,
225639
+ analyzeBranchDiff: options.analyzeBranchDiff,
225640
+ event: options.event,
225095
225641
  };
225096
225642
  }
225097
225643
  catch (error) {
@@ -225142,6 +225688,10 @@ class CLI {
225142
225688
  throw new Error(`Invalid max parallelism value: ${options.maxParallelism}. Max parallelism must be a positive integer (minimum 1).`);
225143
225689
  }
225144
225690
  }
225691
+ // Validate event type
225692
+ if (options.event && !this.validEvents.includes(options.event)) {
225693
+ throw new Error(`Invalid event type: ${options.event}. Available options: ${this.validEvents.join(', ')}`);
225694
+ }
225145
225695
  }
225146
225696
  /**
225147
225697
  * Get help text
@@ -225168,6 +225718,7 @@ class CLI {
225168
225718
  .option('--enable-code-context', 'Force include code diffs in analysis (CLI mode)')
225169
225719
  .option('--disable-code-context', 'Force exclude code diffs from analysis (CLI mode)')
225170
225720
  .option('--analyze-branch-diff', 'Analyze diff vs base branch when on feature branch (auto-enabled for code-review schemas)')
225721
+ .option('--event <type>', 'Simulate GitHub event (pr_opened, pr_updated, issue_opened, issue_comment, manual, all). Default: auto-detect from schema or "all"')
225171
225722
  .option('--mode <mode>', 'Run mode (cli|github-actions). Default: cli')
225172
225723
  .addHelpText('after', this.getExamplesText());
225173
225724
  // Get the basic help and append examples manually if addHelpText doesn't work
@@ -225250,13 +225801,14 @@ exports.CLI = CLI;
225250
225801
  /***/ }),
225251
225802
 
225252
225803
  /***/ 99153:
225253
- /***/ ((__unused_webpack_module, exports) => {
225804
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
225254
225805
 
225255
225806
  "use strict";
225256
225807
 
225257
225808
  Object.defineProperty(exports, "__esModule", ({ value: true }));
225258
225809
  exports.parseComment = parseComment;
225259
225810
  exports.getHelpText = getHelpText;
225811
+ const footer_1 = __nccwpck_require__(6924);
225260
225812
  function parseComment(body, supportedCommands) {
225261
225813
  const trimmed = body.trim();
225262
225814
  if (!trimmed.startsWith('/')) {
@@ -225302,8 +225854,7 @@ function getHelpText(customCommands) {
225302
225854
  ${commandList}
225303
225855
  Commands are case-insensitive and can be used in PR comments.
225304
225856
 
225305
- ---
225306
- *Powered by [Visor](https://probelabs.com/visor) from [Probelabs](https://probelabs.com)*`;
225857
+ ${(0, footer_1.generateFooter)()}`;
225307
225858
  }
225308
225859
 
225309
225860
 
@@ -225351,7 +225902,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
225351
225902
  return (mod && mod.__esModule) ? mod : { "default": mod };
225352
225903
  };
225353
225904
  Object.defineProperty(exports, "__esModule", ({ value: true }));
225354
- exports.ConfigManager = void 0;
225905
+ exports.ConfigManager = exports.VALID_EVENT_TRIGGERS = void 0;
225355
225906
  const yaml = __importStar(__nccwpck_require__(74281));
225356
225907
  const fs = __importStar(__nccwpck_require__(79896));
225357
225908
  const path = __importStar(__nccwpck_require__(16928));
@@ -225361,6 +225912,20 @@ const config_loader_1 = __nccwpck_require__(73836);
225361
225912
  const config_merger_1 = __nccwpck_require__(20730);
225362
225913
  const ajv_1 = __importDefault(__nccwpck_require__(42463));
225363
225914
  const ajv_formats_1 = __importDefault(__nccwpck_require__(82815));
225915
+ /**
225916
+ * Valid event triggers for checks
225917
+ * Exported as a constant to serve as the single source of truth for event validation
225918
+ */
225919
+ exports.VALID_EVENT_TRIGGERS = [
225920
+ 'pr_opened',
225921
+ 'pr_updated',
225922
+ 'pr_closed',
225923
+ 'issue_opened',
225924
+ 'issue_comment',
225925
+ 'manual',
225926
+ 'schedule',
225927
+ 'webhook_received',
225928
+ ];
225364
225929
  /**
225365
225930
  * Configuration manager for Visor
225366
225931
  */
@@ -225372,20 +225937,13 @@ class ConfigManager {
225372
225937
  'http',
225373
225938
  'http_input',
225374
225939
  'http_client',
225940
+ 'memory',
225375
225941
  'noop',
225376
225942
  'log',
225943
+ 'memory',
225377
225944
  'github',
225378
225945
  ];
225379
- validEventTriggers = [
225380
- 'pr_opened',
225381
- 'pr_updated',
225382
- 'pr_closed',
225383
- 'issue_opened',
225384
- 'issue_comment',
225385
- 'manual',
225386
- 'schedule',
225387
- 'webhook_received',
225388
- ];
225946
+ validEventTriggers = [...exports.VALID_EVENT_TRIGGERS];
225389
225947
  validOutputFormats = ['table', 'json', 'markdown', 'sarif'];
225390
225948
  validGroupByOptions = ['check', 'file', 'severity', 'group'];
225391
225949
  /**
@@ -225393,18 +225951,22 @@ class ConfigManager {
225393
225951
  */
225394
225952
  async loadConfig(configPath, options = {}) {
225395
225953
  const { validate = true, mergeDefaults = true, allowedRemotePatterns } = options;
225954
+ // Resolve relative paths to absolute paths based on current working directory
225955
+ const resolvedPath = path.isAbsolute(configPath)
225956
+ ? configPath
225957
+ : path.resolve(process.cwd(), configPath);
225396
225958
  try {
225397
- if (!fs.existsSync(configPath)) {
225398
- throw new Error(`Configuration file not found: ${configPath}`);
225959
+ if (!fs.existsSync(resolvedPath)) {
225960
+ throw new Error(`Configuration file not found: ${resolvedPath}`);
225399
225961
  }
225400
- const configContent = fs.readFileSync(configPath, 'utf8');
225962
+ const configContent = fs.readFileSync(resolvedPath, 'utf8');
225401
225963
  let parsedConfig;
225402
225964
  try {
225403
225965
  parsedConfig = yaml.load(configContent);
225404
225966
  }
225405
225967
  catch (yamlError) {
225406
225968
  const errorMessage = yamlError instanceof Error ? yamlError.message : String(yamlError);
225407
- throw new Error(`Invalid YAML syntax in ${configPath}: ${errorMessage}`);
225969
+ throw new Error(`Invalid YAML syntax in ${resolvedPath}: ${errorMessage}`);
225408
225970
  }
225409
225971
  if (!parsedConfig || typeof parsedConfig !== 'object') {
225410
225972
  throw new Error('Configuration file must contain a valid YAML object');
@@ -225412,7 +225974,7 @@ class ConfigManager {
225412
225974
  // Handle extends directive if present
225413
225975
  if (parsedConfig.extends) {
225414
225976
  const loaderOptions = {
225415
- baseDir: path.dirname(configPath),
225977
+ baseDir: path.dirname(resolvedPath),
225416
225978
  allowRemote: this.isRemoteExtendsAllowed(),
225417
225979
  maxDepth: 10,
225418
225980
  allowedRemotePatterns,
@@ -225458,12 +226020,12 @@ class ConfigManager {
225458
226020
  }
225459
226021
  // Add more context for generic errors
225460
226022
  if (error.message.includes('ENOENT')) {
225461
- throw new Error(`Configuration file not found: ${configPath}`);
226023
+ throw new Error(`Configuration file not found: ${resolvedPath}`);
225462
226024
  }
225463
226025
  if (error.message.includes('EPERM')) {
225464
- throw new Error(`Permission denied reading configuration file: ${configPath}`);
226026
+ throw new Error(`Permission denied reading configuration file: ${resolvedPath}`);
225465
226027
  }
225466
- throw new Error(`Failed to read configuration file ${configPath}: ${error.message}`);
226028
+ throw new Error(`Failed to read configuration file ${resolvedPath}: ${error.message}`);
225467
226029
  }
225468
226030
  throw error;
225469
226031
  }
@@ -226900,11 +227462,6 @@ class FailureConditionEvaluator {
226900
227462
  return false;
226901
227463
  return issues.some(issue => issue.file?.includes(pattern));
226902
227464
  };
226903
- const hasSuggestion = (suggestions, text) => {
226904
- if (!Array.isArray(suggestions))
226905
- return false;
226906
- return suggestions.some(s => s.toLowerCase().includes(text.toLowerCase()));
226907
- };
226908
227465
  // Backward compatibility aliases
226909
227466
  const hasIssueWith = hasIssue;
226910
227467
  const hasFileWith = hasFileMatching;
@@ -226919,7 +227476,6 @@ class FailureConditionEvaluator {
226919
227476
  // Extract context variables
226920
227477
  const output = context.output || {};
226921
227478
  const issues = output.issues || [];
226922
- const suggestions = [];
226923
227479
  // Backward compatibility: provide metadata for transition period
226924
227480
  // TODO: Remove after all configurations are updated
226925
227481
  const metadata = context.metadata || {
@@ -226970,7 +227526,6 @@ class FailureConditionEvaluator {
226970
227526
  memory: memoryAccessor,
226971
227527
  // Legacy compatibility variables
226972
227528
  issues,
226973
- suggestions,
226974
227529
  metadata,
226975
227530
  criticalIssues,
226976
227531
  errorIssues,
@@ -226999,7 +227554,6 @@ class FailureConditionEvaluator {
226999
227554
  hasIssue,
227000
227555
  countIssues,
227001
227556
  hasFileMatching,
227002
- hasSuggestion,
227003
227557
  hasIssueWith,
227004
227558
  hasFileWith,
227005
227559
  // Permission helpers
@@ -227283,6 +227837,53 @@ class FailureConditionEvaluator {
227283
227837
  exports.FailureConditionEvaluator = FailureConditionEvaluator;
227284
227838
 
227285
227839
 
227840
+ /***/ }),
227841
+
227842
+ /***/ 6924:
227843
+ /***/ ((__unused_webpack_module, exports) => {
227844
+
227845
+ "use strict";
227846
+
227847
+ /**
227848
+ * Centralized footer generation for Visor comments and outputs
227849
+ */
227850
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
227851
+ exports.generateFooter = generateFooter;
227852
+ exports.hasVisorFooter = hasVisorFooter;
227853
+ /**
227854
+ * Generate a standard Visor footer with branding and optional tip
227855
+ */
227856
+ function generateFooter(options = {}) {
227857
+ const { includeMetadata, includeSeparator = true } = options;
227858
+ const parts = [];
227859
+ // Add separator
227860
+ if (includeSeparator) {
227861
+ parts.push('---');
227862
+ parts.push('');
227863
+ }
227864
+ // Add branding
227865
+ parts.push('*Powered by [Visor](https://probelabs.com/visor) from [Probelabs](https://probelabs.com)*');
227866
+ // Add metadata if provided
227867
+ if (includeMetadata) {
227868
+ const { lastUpdated, triggeredBy, commitSha } = includeMetadata;
227869
+ const commitInfo = commitSha ? ` | Commit: ${commitSha.substring(0, 7)}` : '';
227870
+ parts.push('');
227871
+ parts.push(`*Last updated: ${lastUpdated} | Triggered by: ${triggeredBy}${commitInfo}*`);
227872
+ }
227873
+ // Add tip
227874
+ parts.push('');
227875
+ parts.push('💡 **TIP:** You can chat with Visor using `/visor ask <your question>`');
227876
+ return parts.join('\n');
227877
+ }
227878
+ /**
227879
+ * Check if a string contains a Visor footer
227880
+ */
227881
+ function hasVisorFooter(text) {
227882
+ return (text.includes('*Powered by [Visor](https://probelabs.com/visor)') ||
227883
+ text.includes('*Powered by [Visor](https://github.com/probelabs/visor)'));
227884
+ }
227885
+
227886
+
227286
227887
  /***/ }),
227287
227888
 
227288
227889
  /***/ 65543:
@@ -228823,7 +229424,7 @@ exports.GitRepositoryAnalyzer = GitRepositoryAnalyzer;
228823
229424
  /***/ }),
228824
229425
 
228825
229426
  /***/ 43748:
228826
- /***/ ((__unused_webpack_module, exports) => {
229427
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
228827
229428
 
228828
229429
  "use strict";
228829
229430
 
@@ -228832,6 +229433,7 @@ exports.GitRepositoryAnalyzer = GitRepositoryAnalyzer;
228832
229433
  */
228833
229434
  Object.defineProperty(exports, "__esModule", ({ value: true }));
228834
229435
  exports.GitHubCheckService = void 0;
229436
+ const footer_1 = __nccwpck_require__(6924);
228835
229437
  /**
228836
229438
  * Service for managing GitHub Check Runs based on Visor failure conditions
228837
229439
  */
@@ -229073,9 +229675,7 @@ class GitHubCheckService {
229073
229675
  }
229074
229676
  // Footer
229075
229677
  sections.push('');
229076
- sections.push('---');
229077
- sections.push('');
229078
- sections.push('*Powered by [Visor](https://probelabs.com/visor) from [Probelabs](https://probelabs.com)*');
229678
+ sections.push((0, footer_1.generateFooter)());
229079
229679
  return sections.join('\n');
229080
229680
  }
229081
229681
  /**
@@ -229286,6 +229886,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
229286
229886
  exports.CommentManager = void 0;
229287
229887
  const uuid_1 = __nccwpck_require__(31914);
229288
229888
  const logger_1 = __nccwpck_require__(86999);
229889
+ const footer_1 = __nccwpck_require__(6924);
229289
229890
  /**
229290
229891
  * Manages GitHub PR comments with dynamic updating capabilities
229291
229892
  */
@@ -229379,15 +229980,17 @@ class CommentManager {
229379
229980
  */
229380
229981
  formatCommentWithMetadata(content, metadata) {
229381
229982
  const { commentId, lastUpdated, triggeredBy, commitSha } = metadata;
229382
- const commitInfo = commitSha ? ` | Commit: ${commitSha.substring(0, 7)}` : '';
229983
+ const footer = (0, footer_1.generateFooter)({
229984
+ includeMetadata: {
229985
+ lastUpdated,
229986
+ triggeredBy,
229987
+ commitSha,
229988
+ },
229989
+ });
229383
229990
  return `<!-- visor-comment-id:${commentId} -->
229384
229991
  ${content}
229385
229992
 
229386
- ---
229387
-
229388
- *Powered by [Visor](https://probelabs.com/visor) from [Probelabs](https://probelabs.com)*
229389
-
229390
- *Last updated: ${lastUpdated} | Triggered by: ${triggeredBy}${commitInfo}*
229993
+ ${footer}
229391
229994
  <!-- /visor-comment-id:${commentId} -->`;
229392
229995
  }
229393
229996
  /**
@@ -229743,6 +230346,8 @@ var __importStar = (this && this.__importStar) || (function () {
229743
230346
  Object.defineProperty(exports, "__esModule", ({ value: true }));
229744
230347
  exports.deriveExecutedCheckNames = void 0;
229745
230348
  exports.run = run;
230349
+ // Load environment variables from .env file
230350
+ __nccwpck_require__(52874);
229746
230351
  const rest_1 = __nccwpck_require__(47432);
229747
230352
  const auth_app_1 = __nccwpck_require__(76479);
229748
230353
  const core_1 = __nccwpck_require__(37484);
@@ -229756,6 +230361,7 @@ const reviewer_1 = __nccwpck_require__(532);
229756
230361
  const config_1 = __nccwpck_require__(22973);
229757
230362
  const github_check_service_1 = __nccwpck_require__(43748);
229758
230363
  const github_reactions_1 = __nccwpck_require__(67997);
230364
+ const footer_1 = __nccwpck_require__(6924);
229759
230365
  /**
229760
230366
  * Create an authenticated Octokit instance using either GitHub App or token authentication
229761
230367
  */
@@ -230333,8 +230939,8 @@ async function handleIssueEvent(octokit, owner, repo, context, inputs, config, c
230333
230939
  // Only post if there's actual content (not just empty checks)
230334
230940
  if (commentBody.trim()) {
230335
230941
  // Only add footer if not already present (to avoid duplicates)
230336
- if (!commentBody.includes('*Powered by [Visor](')) {
230337
- commentBody += `\n---\n*Powered by [Visor](https://probelabs.com/visor) from [Probelabs](https://probelabs.com)*`;
230942
+ if (!(0, footer_1.hasVisorFooter)(commentBody)) {
230943
+ commentBody += `\n${(0, footer_1.generateFooter)()}`;
230338
230944
  }
230339
230945
  // Post comment to the issue
230340
230946
  await octokit.rest.issues.createComment({
@@ -230376,9 +230982,7 @@ async function handleIssueComment(octokit, owner, repo, context, inputs, actionC
230376
230982
  comment.user?.login === 'github-actions[bot]' ||
230377
230983
  comment.user?.type === 'Bot';
230378
230984
  const hasVisorMarkers = comment.body &&
230379
- (comment.body.includes('<!-- visor-comment-id:') ||
230380
- comment.body.includes('*Powered by [Visor](https://probelabs.com/visor)') ||
230381
- comment.body.includes('*Powered by [Visor](https://github.com/probelabs/visor)'));
230985
+ (comment.body.includes('<!-- visor-comment-id:') || (0, footer_1.hasVisorFooter)(comment.body));
230382
230986
  if (isVisorBot || hasVisorMarkers) {
230383
230987
  console.log(`✓ Skipping bot's own comment to prevent recursion. Author: ${comment.user?.login}, Type: ${comment.user?.type}, Has markers: ${hasVisorMarkers}`);
230384
230988
  return;
@@ -230454,8 +231058,7 @@ async function handleIssueComment(octokit, owner, repo, context, inputs, actionC
230454
231058
  `**Additions:** +${statusPrInfo.totalAdditions}\n` +
230455
231059
  `**Deletions:** -${statusPrInfo.totalDeletions}\n` +
230456
231060
  `**Base:** ${statusPrInfo.base} → **Head:** ${statusPrInfo.head}\n\n` +
230457
- `\n---\n\n` +
230458
- `*Powered by [Visor](https://probelabs.com/visor) from [Probelabs](https://probelabs.com)*`;
231061
+ `\n${(0, footer_1.generateFooter)()}`;
230459
231062
  await octokit.rest.issues.createComment({
230460
231063
  owner,
230461
231064
  repo,
@@ -230470,8 +231073,7 @@ async function handleIssueComment(octokit, owner, repo, context, inputs, actionC
230470
231073
  `**State:** ${issue.state || 'open'}\n` +
230471
231074
  `**Comments:** ${issue.comments || 0}\n` +
230472
231075
  `**Created:** ${issue.created_at || 'unknown'}\n` +
230473
- `\n---\n\n` +
230474
- `*Powered by [Visor](https://probelabs.com/visor) from [Probelabs](https://probelabs.com)*`;
231076
+ `\n${(0, footer_1.generateFooter)()}`;
230475
231077
  await octokit.rest.issues.createComment({
230476
231078
  owner,
230477
231079
  repo,
@@ -230568,7 +231170,7 @@ async function handleIssueComment(octokit, owner, repo, context, inputs, actionC
230568
231170
  owner,
230569
231171
  repo,
230570
231172
  issue_number: prNumber,
230571
- body: `⚠️ No checks are configured to run for ${isPullRequest ? 'PR' : 'issue'} comments with command /${command.type}\n\n*Powered by [Visor](https://probelabs.com/visor) from [Probelabs](https://probelabs.com)*`,
231173
+ body: `⚠️ No checks are configured to run for ${isPullRequest ? 'PR' : 'issue'} comments with command /${command.type}\n\n${(0, footer_1.generateFooter)()}`,
230572
231174
  });
230573
231175
  return;
230574
231176
  }
@@ -237676,17 +238278,20 @@ class PRReviewer {
237676
238278
  'Built-in prompts have been removed - all checks must be explicitly configured.');
237677
238279
  }
237678
238280
  /**
237679
- * Helper to check if a schema definition has a "text" field in its properties
238281
+ * Helper to check if a schema is comment-generating
238282
+ * Comment-generating schemas include:
238283
+ * - Built-in schemas: code-review, overview, plain, text
238284
+ * - Custom schemas with a "text" field in properties
237680
238285
  */
237681
- async schemaHasTextField(schema) {
238286
+ async isCommentGeneratingSchema(schema) {
237682
238287
  try {
237683
- let schemaObj;
237684
- if (typeof schema === 'object') {
237685
- // Inline schema object
237686
- schemaObj = schema;
237687
- }
237688
- else {
237689
- // String reference - load the schema
238288
+ // Check for built-in comment-generating schemas
238289
+ if (typeof schema === 'string') {
238290
+ // Well-known comment-generating schemas
238291
+ if (['code-review', 'overview', 'plain', 'text'].includes(schema)) {
238292
+ return true;
238293
+ }
238294
+ // Try to load and check custom string schema
237690
238295
  const fs = (__nccwpck_require__(79896).promises);
237691
238296
  const path = __nccwpck_require__(16928);
237692
238297
  // Sanitize schema name
@@ -237698,16 +238303,21 @@ class PRReviewer {
237698
238303
  const schemaPath = __nccwpck_require__.ab + "output/" + sanitizedSchemaName + '/schema.json';
237699
238304
  try {
237700
238305
  const schemaContent = await fs.readFile(schemaPath, 'utf-8');
237701
- schemaObj = JSON.parse(schemaContent);
238306
+ const schemaObj = JSON.parse(schemaContent);
238307
+ // Check if schema has a "text" field in properties
238308
+ const properties = schemaObj.properties;
238309
+ return !!(properties && 'text' in properties);
237702
238310
  }
237703
238311
  catch {
237704
238312
  // Schema file not found or invalid, return false
237705
238313
  return false;
237706
238314
  }
237707
238315
  }
237708
- // Check if schema has a "text" field in properties
237709
- const properties = schemaObj.properties;
237710
- return !!(properties && 'text' in properties);
238316
+ else {
238317
+ // Inline schema object - check if it has a "text" field in properties
238318
+ const properties = schema.properties;
238319
+ return !!(properties && 'text' in properties);
238320
+ }
237711
238321
  }
237712
238322
  catch {
237713
238323
  return false;
@@ -237734,19 +238344,9 @@ class PRReviewer {
237734
238344
  // Other types (github, command, http, etc.) without schema are for orchestration
237735
238345
  shouldPostComment = isAICheck;
237736
238346
  }
237737
- else if (typeof schema === 'string') {
237738
- // String schema - check if it's a known plain text schema OR has a text field
237739
- if (schema === 'text' || schema === 'plain') {
237740
- shouldPostComment = true;
237741
- }
237742
- else {
237743
- // Load the schema and check if it has a text field
237744
- shouldPostComment = await this.schemaHasTextField(schema);
237745
- }
237746
- }
237747
- else if (typeof schema === 'object') {
237748
- // Custom inline schema object - check if it has a "text" field in properties
237749
- shouldPostComment = await this.schemaHasTextField(schema);
238347
+ else {
238348
+ // Check if the schema is comment-generating (built-in or custom with text field)
238349
+ shouldPostComment = await this.isCommentGeneratingSchema(schema);
237750
238350
  }
237751
238351
  if (shouldPostComment) {
237752
238352
  filtered.push(r);
@@ -240148,6 +240748,121 @@ class ConfigMerger {
240148
240748
  exports.ConfigMerger = ConfigMerger;
240149
240749
 
240150
240750
 
240751
+ /***/ }),
240752
+
240753
+ /***/ 29883:
240754
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
240755
+
240756
+ "use strict";
240757
+
240758
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
240759
+ if (k2 === undefined) k2 = k;
240760
+ var desc = Object.getOwnPropertyDescriptor(m, k);
240761
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
240762
+ desc = { enumerable: true, get: function() { return m[k]; } };
240763
+ }
240764
+ Object.defineProperty(o, k2, desc);
240765
+ }) : (function(o, m, k, k2) {
240766
+ if (k2 === undefined) k2 = k;
240767
+ o[k2] = m[k];
240768
+ }));
240769
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
240770
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
240771
+ }) : function(o, v) {
240772
+ o["default"] = v;
240773
+ });
240774
+ var __importStar = (this && this.__importStar) || (function () {
240775
+ var ownKeys = function(o) {
240776
+ ownKeys = Object.getOwnPropertyNames || function (o) {
240777
+ var ar = [];
240778
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
240779
+ return ar;
240780
+ };
240781
+ return ownKeys(o);
240782
+ };
240783
+ return function (mod) {
240784
+ if (mod && mod.__esModule) return mod;
240785
+ var result = {};
240786
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
240787
+ __setModuleDefault(result, mod);
240788
+ return result;
240789
+ };
240790
+ })();
240791
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
240792
+ exports.processDiffWithOutline = processDiffWithOutline;
240793
+ const probe_1 = __nccwpck_require__(83841);
240794
+ const path = __importStar(__nccwpck_require__(16928));
240795
+ /**
240796
+ * Process diff content using the outline-diff format from @probelabs/probe
240797
+ * This extracts a structured outline from the diff without requiring a temporary file
240798
+ */
240799
+ async function processDiffWithOutline(diffContent) {
240800
+ if (!diffContent || diffContent.trim().length === 0) {
240801
+ return diffContent;
240802
+ }
240803
+ try {
240804
+ // Set PROBE_PATH to use the bundled binary with outline-diff support
240805
+ // The SDK by default may download an older binary that doesn't support outline-diff
240806
+ const originalProbePath = process.env.PROBE_PATH;
240807
+ // Try multiple possible locations for the probe binary
240808
+ // When bundled with ncc, __dirname may not be reliable
240809
+ const fs = __nccwpck_require__(79896);
240810
+ const possiblePaths = [
240811
+ // Relative to current working directory (most common in production)
240812
+ path.join(process.cwd(), 'node_modules/@probelabs/probe/bin/probe-binary'),
240813
+ // Relative to __dirname (for unbundled development)
240814
+ path.join(__dirname, '../..', 'node_modules/@probelabs/probe/bin/probe-binary'),
240815
+ // Relative to dist directory (for bundled CLI)
240816
+ path.join(__dirname, 'node_modules/@probelabs/probe/bin/probe-binary'),
240817
+ ];
240818
+ let probeBinaryPath;
240819
+ for (const candidatePath of possiblePaths) {
240820
+ if (fs.existsSync(candidatePath)) {
240821
+ probeBinaryPath = candidatePath;
240822
+ break;
240823
+ }
240824
+ }
240825
+ // Only process if binary exists, otherwise fall back to original diff
240826
+ if (!probeBinaryPath) {
240827
+ if (process.env.DEBUG === '1' || process.env.VERBOSE === '1') {
240828
+ console.error('Probe binary not found. Tried:', possiblePaths);
240829
+ }
240830
+ return diffContent;
240831
+ }
240832
+ process.env.PROBE_PATH = probeBinaryPath;
240833
+ // Use extract with content parameter (can be string or Buffer)
240834
+ // The TypeScript types haven't been updated yet, but the runtime supports it
240835
+ // Add timeout to avoid hanging
240836
+ const extractPromise = probe_1.extract({
240837
+ content: diffContent,
240838
+ format: 'outline-diff',
240839
+ allowTests: true, // Allow test files and test code blocks in extraction results
240840
+ });
240841
+ const timeoutPromise = new Promise((_, reject) => {
240842
+ setTimeout(() => reject(new Error('Extract timeout after 30s')), 30000);
240843
+ });
240844
+ const result = await Promise.race([extractPromise, timeoutPromise]);
240845
+ // Restore original PROBE_PATH
240846
+ if (originalProbePath !== undefined) {
240847
+ process.env.PROBE_PATH = originalProbePath;
240848
+ }
240849
+ else {
240850
+ delete process.env.PROBE_PATH;
240851
+ }
240852
+ // Return the processed outline diff
240853
+ return typeof result === 'string' ? result : JSON.stringify(result);
240854
+ }
240855
+ catch (error) {
240856
+ // If outline-diff processing fails, fall back to the original diff
240857
+ // Use console.error instead of console.warn to avoid polluting JSON output
240858
+ if (process.env.DEBUG === '1' || process.env.VERBOSE === '1') {
240859
+ console.error('Failed to process diff with outline-diff format:', error);
240860
+ }
240861
+ return diffContent;
240862
+ }
240863
+ }
240864
+
240865
+
240151
240866
  /***/ }),
240152
240867
 
240153
240868
  /***/ 58749:
@@ -254098,6 +254813,364 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
254098
254813
  ));
254099
254814
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
254100
254815
 
254816
+ // node_modules/dotenv/package.json
254817
+ var require_package = __commonJS({
254818
+ "node_modules/dotenv/package.json"(exports2, module2) {
254819
+ module2.exports = {
254820
+ name: "dotenv",
254821
+ version: "16.6.1",
254822
+ description: "Loads environment variables from .env file",
254823
+ main: "lib/main.js",
254824
+ types: "lib/main.d.ts",
254825
+ exports: {
254826
+ ".": {
254827
+ types: "./lib/main.d.ts",
254828
+ require: "./lib/main.js",
254829
+ default: "./lib/main.js"
254830
+ },
254831
+ "./config": "./config.js",
254832
+ "./config.js": "./config.js",
254833
+ "./lib/env-options": "./lib/env-options.js",
254834
+ "./lib/env-options.js": "./lib/env-options.js",
254835
+ "./lib/cli-options": "./lib/cli-options.js",
254836
+ "./lib/cli-options.js": "./lib/cli-options.js",
254837
+ "./package.json": "./package.json"
254838
+ },
254839
+ scripts: {
254840
+ "dts-check": "tsc --project tests/types/tsconfig.json",
254841
+ lint: "standard",
254842
+ pretest: "npm run lint && npm run dts-check",
254843
+ test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
254844
+ "test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
254845
+ prerelease: "npm test",
254846
+ release: "standard-version"
254847
+ },
254848
+ repository: {
254849
+ type: "git",
254850
+ url: "git://github.com/motdotla/dotenv.git"
254851
+ },
254852
+ homepage: "https://github.com/motdotla/dotenv#readme",
254853
+ funding: "https://dotenvx.com",
254854
+ keywords: [
254855
+ "dotenv",
254856
+ "env",
254857
+ ".env",
254858
+ "environment",
254859
+ "variables",
254860
+ "config",
254861
+ "settings"
254862
+ ],
254863
+ readmeFilename: "README.md",
254864
+ license: "BSD-2-Clause",
254865
+ devDependencies: {
254866
+ "@types/node": "^18.11.3",
254867
+ decache: "^4.6.2",
254868
+ sinon: "^14.0.1",
254869
+ standard: "^17.0.0",
254870
+ "standard-version": "^9.5.0",
254871
+ tap: "^19.2.0",
254872
+ typescript: "^4.8.4"
254873
+ },
254874
+ engines: {
254875
+ node: ">=12"
254876
+ },
254877
+ browser: {
254878
+ fs: false
254879
+ }
254880
+ };
254881
+ }
254882
+ });
254883
+
254884
+ // node_modules/dotenv/lib/main.js
254885
+ var require_main = __commonJS({
254886
+ "node_modules/dotenv/lib/main.js"(exports2, module2) {
254887
+ var fs6 = __nccwpck_require__(79896);
254888
+ var path7 = __nccwpck_require__(16928);
254889
+ var os3 = __nccwpck_require__(70857);
254890
+ var crypto2 = __nccwpck_require__(76982);
254891
+ var packageJson = require_package();
254892
+ var version = packageJson.version;
254893
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
254894
+ function parse6(src) {
254895
+ const obj = {};
254896
+ let lines = src.toString();
254897
+ lines = lines.replace(/\r\n?/mg, "\n");
254898
+ let match2;
254899
+ while ((match2 = LINE.exec(lines)) != null) {
254900
+ const key = match2[1];
254901
+ let value = match2[2] || "";
254902
+ value = value.trim();
254903
+ const maybeQuote = value[0];
254904
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
254905
+ if (maybeQuote === '"') {
254906
+ value = value.replace(/\\n/g, "\n");
254907
+ value = value.replace(/\\r/g, "\r");
254908
+ }
254909
+ obj[key] = value;
254910
+ }
254911
+ return obj;
254912
+ }
254913
+ function _parseVault(options) {
254914
+ options = options || {};
254915
+ const vaultPath = _vaultPath(options);
254916
+ options.path = vaultPath;
254917
+ const result = DotenvModule.configDotenv(options);
254918
+ if (!result.parsed) {
254919
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
254920
+ err.code = "MISSING_DATA";
254921
+ throw err;
254922
+ }
254923
+ const keys2 = _dotenvKey(options).split(",");
254924
+ const length = keys2.length;
254925
+ let decrypted;
254926
+ for (let i3 = 0; i3 < length; i3++) {
254927
+ try {
254928
+ const key = keys2[i3].trim();
254929
+ const attrs = _instructions(result, key);
254930
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
254931
+ break;
254932
+ } catch (error2) {
254933
+ if (i3 + 1 >= length) {
254934
+ throw error2;
254935
+ }
254936
+ }
254937
+ }
254938
+ return DotenvModule.parse(decrypted);
254939
+ }
254940
+ function _warn(message) {
254941
+ console.log(`[dotenv@${version}][WARN] ${message}`);
254942
+ }
254943
+ function _debug(message) {
254944
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
254945
+ }
254946
+ function _log(message) {
254947
+ console.log(`[dotenv@${version}] ${message}`);
254948
+ }
254949
+ function _dotenvKey(options) {
254950
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
254951
+ return options.DOTENV_KEY;
254952
+ }
254953
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
254954
+ return process.env.DOTENV_KEY;
254955
+ }
254956
+ return "";
254957
+ }
254958
+ function _instructions(result, dotenvKey) {
254959
+ let uri;
254960
+ try {
254961
+ uri = new URL(dotenvKey);
254962
+ } catch (error2) {
254963
+ if (error2.code === "ERR_INVALID_URL") {
254964
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
254965
+ err.code = "INVALID_DOTENV_KEY";
254966
+ throw err;
254967
+ }
254968
+ throw error2;
254969
+ }
254970
+ const key = uri.password;
254971
+ if (!key) {
254972
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
254973
+ err.code = "INVALID_DOTENV_KEY";
254974
+ throw err;
254975
+ }
254976
+ const environment = uri.searchParams.get("environment");
254977
+ if (!environment) {
254978
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
254979
+ err.code = "INVALID_DOTENV_KEY";
254980
+ throw err;
254981
+ }
254982
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
254983
+ const ciphertext = result.parsed[environmentKey];
254984
+ if (!ciphertext) {
254985
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
254986
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
254987
+ throw err;
254988
+ }
254989
+ return { ciphertext, key };
254990
+ }
254991
+ function _vaultPath(options) {
254992
+ let possibleVaultPath = null;
254993
+ if (options && options.path && options.path.length > 0) {
254994
+ if (Array.isArray(options.path)) {
254995
+ for (const filepath of options.path) {
254996
+ if (fs6.existsSync(filepath)) {
254997
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
254998
+ }
254999
+ }
255000
+ } else {
255001
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
255002
+ }
255003
+ } else {
255004
+ possibleVaultPath = path7.resolve(process.cwd(), ".env.vault");
255005
+ }
255006
+ if (fs6.existsSync(possibleVaultPath)) {
255007
+ return possibleVaultPath;
255008
+ }
255009
+ return null;
255010
+ }
255011
+ function _resolveHome(envPath) {
255012
+ return envPath[0] === "~" ? path7.join(os3.homedir(), envPath.slice(1)) : envPath;
255013
+ }
255014
+ function _configVault(options) {
255015
+ const debug = Boolean(options && options.debug);
255016
+ const quiet = options && "quiet" in options ? options.quiet : true;
255017
+ if (debug || !quiet) {
255018
+ _log("Loading env from encrypted .env.vault");
255019
+ }
255020
+ const parsed = DotenvModule._parseVault(options);
255021
+ let processEnv = process.env;
255022
+ if (options && options.processEnv != null) {
255023
+ processEnv = options.processEnv;
255024
+ }
255025
+ DotenvModule.populate(processEnv, parsed, options);
255026
+ return { parsed };
255027
+ }
255028
+ function configDotenv(options) {
255029
+ const dotenvPath = path7.resolve(process.cwd(), ".env");
255030
+ let encoding = "utf8";
255031
+ const debug = Boolean(options && options.debug);
255032
+ const quiet = options && "quiet" in options ? options.quiet : true;
255033
+ if (options && options.encoding) {
255034
+ encoding = options.encoding;
255035
+ } else {
255036
+ if (debug) {
255037
+ _debug("No encoding is specified. UTF-8 is used by default");
255038
+ }
255039
+ }
255040
+ let optionPaths = [dotenvPath];
255041
+ if (options && options.path) {
255042
+ if (!Array.isArray(options.path)) {
255043
+ optionPaths = [_resolveHome(options.path)];
255044
+ } else {
255045
+ optionPaths = [];
255046
+ for (const filepath of options.path) {
255047
+ optionPaths.push(_resolveHome(filepath));
255048
+ }
255049
+ }
255050
+ }
255051
+ let lastError;
255052
+ const parsedAll = {};
255053
+ for (const path8 of optionPaths) {
255054
+ try {
255055
+ const parsed = DotenvModule.parse(fs6.readFileSync(path8, { encoding }));
255056
+ DotenvModule.populate(parsedAll, parsed, options);
255057
+ } catch (e3) {
255058
+ if (debug) {
255059
+ _debug(`Failed to load ${path8} ${e3.message}`);
255060
+ }
255061
+ lastError = e3;
255062
+ }
255063
+ }
255064
+ let processEnv = process.env;
255065
+ if (options && options.processEnv != null) {
255066
+ processEnv = options.processEnv;
255067
+ }
255068
+ DotenvModule.populate(processEnv, parsedAll, options);
255069
+ if (debug || !quiet) {
255070
+ const keysCount = Object.keys(parsedAll).length;
255071
+ const shortPaths = [];
255072
+ for (const filePath of optionPaths) {
255073
+ try {
255074
+ const relative = path7.relative(process.cwd(), filePath);
255075
+ shortPaths.push(relative);
255076
+ } catch (e3) {
255077
+ if (debug) {
255078
+ _debug(`Failed to load ${filePath} ${e3.message}`);
255079
+ }
255080
+ lastError = e3;
255081
+ }
255082
+ }
255083
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(",")}`);
255084
+ }
255085
+ if (lastError) {
255086
+ return { parsed: parsedAll, error: lastError };
255087
+ } else {
255088
+ return { parsed: parsedAll };
255089
+ }
255090
+ }
255091
+ function config(options) {
255092
+ if (_dotenvKey(options).length === 0) {
255093
+ return DotenvModule.configDotenv(options);
255094
+ }
255095
+ const vaultPath = _vaultPath(options);
255096
+ if (!vaultPath) {
255097
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
255098
+ return DotenvModule.configDotenv(options);
255099
+ }
255100
+ return DotenvModule._configVault(options);
255101
+ }
255102
+ function decrypt(encrypted, keyStr) {
255103
+ const key = Buffer.from(keyStr.slice(-64), "hex");
255104
+ let ciphertext = Buffer.from(encrypted, "base64");
255105
+ const nonce = ciphertext.subarray(0, 12);
255106
+ const authTag = ciphertext.subarray(-16);
255107
+ ciphertext = ciphertext.subarray(12, -16);
255108
+ try {
255109
+ const aesgcm = crypto2.createDecipheriv("aes-256-gcm", key, nonce);
255110
+ aesgcm.setAuthTag(authTag);
255111
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
255112
+ } catch (error2) {
255113
+ const isRange = error2 instanceof RangeError;
255114
+ const invalidKeyLength = error2.message === "Invalid key length";
255115
+ const decryptionFailed = error2.message === "Unsupported state or unable to authenticate data";
255116
+ if (isRange || invalidKeyLength) {
255117
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
255118
+ err.code = "INVALID_DOTENV_KEY";
255119
+ throw err;
255120
+ } else if (decryptionFailed) {
255121
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
255122
+ err.code = "DECRYPTION_FAILED";
255123
+ throw err;
255124
+ } else {
255125
+ throw error2;
255126
+ }
255127
+ }
255128
+ }
255129
+ function populate(processEnv, parsed, options = {}) {
255130
+ const debug = Boolean(options && options.debug);
255131
+ const override = Boolean(options && options.override);
255132
+ if (typeof parsed !== "object") {
255133
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
255134
+ err.code = "OBJECT_REQUIRED";
255135
+ throw err;
255136
+ }
255137
+ for (const key of Object.keys(parsed)) {
255138
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
255139
+ if (override === true) {
255140
+ processEnv[key] = parsed[key];
255141
+ }
255142
+ if (debug) {
255143
+ if (override === true) {
255144
+ _debug(`"${key}" is already defined and WAS overwritten`);
255145
+ } else {
255146
+ _debug(`"${key}" is already defined and was NOT overwritten`);
255147
+ }
255148
+ }
255149
+ } else {
255150
+ processEnv[key] = parsed[key];
255151
+ }
255152
+ }
255153
+ }
255154
+ var DotenvModule = {
255155
+ configDotenv,
255156
+ _configVault,
255157
+ _parseVault,
255158
+ config,
255159
+ decrypt,
255160
+ parse: parse6,
255161
+ populate
255162
+ };
255163
+ module2.exports.configDotenv = DotenvModule.configDotenv;
255164
+ module2.exports._configVault = DotenvModule._configVault;
255165
+ module2.exports._parseVault = DotenvModule._parseVault;
255166
+ module2.exports.config = DotenvModule.config;
255167
+ module2.exports.decrypt = DotenvModule.decrypt;
255168
+ module2.exports.parse = DotenvModule.parse;
255169
+ module2.exports.populate = DotenvModule.populate;
255170
+ module2.exports = DotenvModule;
255171
+ }
255172
+ });
255173
+
254101
255174
  // src/directory-resolver.js
254102
255175
  async function getPackageBinDir() {
254103
255176
  const debug = process.env.DEBUG === "1" || process.env.VERBOSE === "1";
@@ -254271,6 +255344,145 @@ var init_directory_resolver = __esm({
254271
255344
  });
254272
255345
 
254273
255346
  // src/downloader.js
255347
+ async function acquireFileLock(lockPath, version) {
255348
+ const lockData = {
255349
+ version,
255350
+ pid: process.pid,
255351
+ timestamp: Date.now()
255352
+ };
255353
+ try {
255354
+ await import_fs_extra2.default.writeFile(lockPath, JSON.stringify(lockData), { flag: "wx" });
255355
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255356
+ console.log(`Acquired file lock: ${lockPath}`);
255357
+ }
255358
+ return true;
255359
+ } catch (error2) {
255360
+ if (error2.code === "EEXIST") {
255361
+ try {
255362
+ const existingLock = JSON.parse(await import_fs_extra2.default.readFile(lockPath, "utf-8"));
255363
+ const lockAge = Date.now() - existingLock.timestamp;
255364
+ if (lockAge > LOCK_TIMEOUT_MS) {
255365
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255366
+ console.log(`Removing stale lock file (age: ${Math.round(lockAge / 1e3)}s, pid: ${existingLock.pid})`);
255367
+ }
255368
+ await import_fs_extra2.default.remove(lockPath);
255369
+ return false;
255370
+ }
255371
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255372
+ console.log(`Download in progress by process ${existingLock.pid}, waiting...`);
255373
+ }
255374
+ return false;
255375
+ } catch (readError) {
255376
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255377
+ console.log(`Lock file corrupted, removing: ${readError.message}`);
255378
+ }
255379
+ try {
255380
+ await import_fs_extra2.default.remove(lockPath);
255381
+ } catch {
255382
+ }
255383
+ return false;
255384
+ }
255385
+ }
255386
+ if (error2.code === "EACCES" || error2.code === "EPERM" || error2.code === "EROFS") {
255387
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255388
+ console.log(`Cannot create lock file (${error2.code}): ${lockPath}`);
255389
+ console.log(`File-based locking unavailable, will proceed without cross-process coordination`);
255390
+ }
255391
+ return null;
255392
+ }
255393
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255394
+ console.log(`Unexpected error creating lock file: ${error2.message}`);
255395
+ console.log(`Proceeding without file-based lock`);
255396
+ }
255397
+ return null;
255398
+ }
255399
+ }
255400
+ async function releaseFileLock(lockPath) {
255401
+ try {
255402
+ await import_fs_extra2.default.remove(lockPath);
255403
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255404
+ console.log(`Released file lock: ${lockPath}`);
255405
+ }
255406
+ } catch (error2) {
255407
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255408
+ console.log(`Warning: Could not release lock file: ${error2.message}`);
255409
+ }
255410
+ }
255411
+ }
255412
+ async function waitForFileLock(lockPath, binaryPath) {
255413
+ const startTime = Date.now();
255414
+ while (Date.now() - startTime < MAX_LOCK_WAIT_MS) {
255415
+ if (await import_fs_extra2.default.pathExists(binaryPath)) {
255416
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255417
+ console.log(`Binary now available at ${binaryPath}, download completed by another process`);
255418
+ }
255419
+ return true;
255420
+ }
255421
+ const lockExists = await import_fs_extra2.default.pathExists(lockPath);
255422
+ if (!lockExists) {
255423
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255424
+ console.log(`Lock file removed but binary not found - download may have failed`);
255425
+ }
255426
+ return false;
255427
+ }
255428
+ try {
255429
+ const lockData = JSON.parse(await import_fs_extra2.default.readFile(lockPath, "utf-8"));
255430
+ const lockAge = Date.now() - lockData.timestamp;
255431
+ if (lockAge > LOCK_TIMEOUT_MS) {
255432
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255433
+ console.log(`Lock expired (age: ${Math.round(lockAge / 1e3)}s), will retry download`);
255434
+ }
255435
+ return false;
255436
+ }
255437
+ } catch {
255438
+ }
255439
+ await new Promise((resolve4) => setTimeout(resolve4, LOCK_POLL_INTERVAL_MS));
255440
+ }
255441
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255442
+ console.log(`Timeout waiting for file lock`);
255443
+ }
255444
+ return false;
255445
+ }
255446
+ async function withDownloadLock(version, downloadFn) {
255447
+ const lockKey = version || "latest";
255448
+ if (downloadLocks.has(lockKey)) {
255449
+ const lock = downloadLocks.get(lockKey);
255450
+ const lockAge = Date.now() - lock.timestamp;
255451
+ if (lockAge > LOCK_TIMEOUT_MS) {
255452
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255453
+ console.log(`In-memory lock for version ${lockKey} expired (age: ${Math.round(lockAge / 1e3)}s), removing stale lock`);
255454
+ }
255455
+ downloadLocks.delete(lockKey);
255456
+ } else {
255457
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255458
+ console.log(`Download already in progress in this process for version ${lockKey}, waiting...`);
255459
+ }
255460
+ try {
255461
+ return await lock.promise;
255462
+ } catch (error2) {
255463
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255464
+ console.log(`In-memory locked download failed, will retry: ${error2.message}`);
255465
+ }
255466
+ }
255467
+ }
255468
+ }
255469
+ const downloadPromise = Promise.race([
255470
+ downloadFn(),
255471
+ new Promise(
255472
+ (_2, reject2) => setTimeout(() => reject2(new Error(`Download timeout after ${LOCK_TIMEOUT_MS / 1e3}s`)), LOCK_TIMEOUT_MS)
255473
+ )
255474
+ ]);
255475
+ downloadLocks.set(lockKey, {
255476
+ promise: downloadPromise,
255477
+ timestamp: Date.now()
255478
+ });
255479
+ try {
255480
+ const result = await downloadPromise;
255481
+ return result;
255482
+ } finally {
255483
+ downloadLocks.delete(lockKey);
255484
+ }
255485
+ }
254274
255486
  function detectOsArch() {
254275
255487
  const osType = import_os2.default.platform();
254276
255488
  const archType = import_os2.default.arch();
@@ -254714,16 +255926,64 @@ async function getPackageVersion() {
254714
255926
  return "0.0.0";
254715
255927
  }
254716
255928
  }
255929
+ async function doDownload(version) {
255930
+ const localDir = await getPackageBinDir();
255931
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255932
+ console.log(`Downloading probe binary (version: ${version || "latest"})...`);
255933
+ console.log(`Using binary directory: ${localDir}`);
255934
+ }
255935
+ const isWindows = import_os2.default.platform() === "win32";
255936
+ const binaryName = isWindows ? `${BINARY_NAME}.exe` : `${BINARY_NAME}-binary`;
255937
+ const binaryPath = import_path2.default.join(localDir, binaryName);
255938
+ const { os: osInfo, arch: archInfo } = detectOsArch();
255939
+ let versionToUse = version;
255940
+ let bestAsset;
255941
+ let tagVersion;
255942
+ if (!versionToUse || versionToUse === "0.0.0") {
255943
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255944
+ console.log("No specific version requested, will use the latest release");
255945
+ }
255946
+ const { tag: tag2, assets } = await getLatestRelease(void 0);
255947
+ tagVersion = tag2.startsWith("v") ? tag2.substring(1) : tag2;
255948
+ bestAsset = findBestAsset(assets, osInfo, archInfo);
255949
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255950
+ console.log(`Found release version: ${tagVersion}`);
255951
+ }
255952
+ } else {
255953
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255954
+ console.log(`Direct download for version: ${versionToUse}`);
255955
+ }
255956
+ tagVersion = versionToUse;
255957
+ bestAsset = constructAssetInfo(versionToUse, osInfo, archInfo);
255958
+ }
255959
+ const { assetPath, checksumPath } = await downloadAsset(bestAsset, localDir);
255960
+ const checksumValid = await verifyChecksum(assetPath, checksumPath);
255961
+ if (!checksumValid) {
255962
+ throw new Error("Checksum verification failed");
255963
+ }
255964
+ const extractedBinaryPath = await extractBinary(assetPath, localDir);
255965
+ await saveVersionInfo(tagVersion, localDir);
255966
+ try {
255967
+ await import_fs_extra2.default.remove(assetPath);
255968
+ if (checksumPath) {
255969
+ await import_fs_extra2.default.remove(checksumPath);
255970
+ }
255971
+ } catch (err) {
255972
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255973
+ console.log(`Warning: Could not clean up temporary files: ${err}`);
255974
+ }
255975
+ }
255976
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
255977
+ console.log(`Binary successfully installed at ${extractedBinaryPath} (version: ${tagVersion})`);
255978
+ }
255979
+ return extractedBinaryPath;
255980
+ }
254717
255981
  async function downloadProbeBinary(version) {
254718
255982
  try {
254719
255983
  const localDir = await getPackageBinDir();
254720
255984
  if (!version || version === "0.0.0") {
254721
255985
  version = await getPackageVersion();
254722
255986
  }
254723
- if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
254724
- console.log(`Downloading probe binary (version: ${version || "latest"})...`);
254725
- console.log(`Using binary directory: ${localDir}`);
254726
- }
254727
255987
  const isWindows = import_os2.default.platform() === "win32";
254728
255988
  const binaryName = isWindows ? `${BINARY_NAME}.exe` : `${BINARY_NAME}-binary`;
254729
255989
  const binaryPath = import_path2.default.join(localDir, binaryName);
@@ -254739,54 +255999,44 @@ async function downloadProbeBinary(version) {
254739
255999
  console.log(`Existing binary version (${versionInfo?.version || "unknown"}) doesn't match requested version (${version}). Downloading new version...`);
254740
256000
  }
254741
256001
  }
254742
- const { os: osInfo, arch: archInfo } = detectOsArch();
254743
- let versionToUse = version;
254744
- let bestAsset;
254745
- let tagVersion;
254746
- if (!versionToUse || versionToUse === "0.0.0") {
254747
- if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
254748
- console.log("No specific version requested, will use the latest release");
254749
- }
254750
- const { tag: tag2, assets } = await getLatestRelease(void 0);
254751
- tagVersion = tag2.startsWith("v") ? tag2.substring(1) : tag2;
254752
- bestAsset = findBestAsset(assets, osInfo, archInfo);
254753
- if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
254754
- console.log(`Found release version: ${tagVersion}`);
256002
+ const lockPath = import_path2.default.join(localDir, `.probe-download-${version}.lock`);
256003
+ const maxRetries = 3;
256004
+ for (let retry = 0; retry < maxRetries; retry++) {
256005
+ const lockAcquired = await acquireFileLock(lockPath, version);
256006
+ if (lockAcquired === true) {
256007
+ try {
256008
+ const result = await withDownloadLock(version, () => doDownload(version));
256009
+ return result;
256010
+ } finally {
256011
+ await releaseFileLock(lockPath);
256012
+ }
254755
256013
  }
254756
- } else {
254757
- if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
254758
- console.log(`Direct download for version: ${versionToUse}`);
256014
+ if (lockAcquired === null) {
256015
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
256016
+ console.log(`File-based locking unavailable, downloading without cross-process coordination`);
256017
+ }
256018
+ return await withDownloadLock(version, () => doDownload(version));
254759
256019
  }
254760
- tagVersion = versionToUse;
254761
- bestAsset = constructAssetInfo(versionToUse, osInfo, archInfo);
254762
- }
254763
- const { assetPath, checksumPath } = await downloadAsset(bestAsset, localDir);
254764
- const checksumValid = await verifyChecksum(assetPath, checksumPath);
254765
- if (!checksumValid) {
254766
- throw new Error("Checksum verification failed");
254767
- }
254768
- const extractedBinaryPath = await extractBinary(assetPath, localDir);
254769
- await saveVersionInfo(tagVersion, localDir);
254770
- try {
254771
- await import_fs_extra2.default.remove(assetPath);
254772
- if (checksumPath) {
254773
- await import_fs_extra2.default.remove(checksumPath);
256020
+ const downloadCompleted = await waitForFileLock(lockPath, binaryPath);
256021
+ if (downloadCompleted) {
256022
+ return binaryPath;
254774
256023
  }
254775
- } catch (err) {
254776
- if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
254777
- console.log(`Warning: Could not clean up temporary files: ${err}`);
256024
+ if (retry < maxRetries - 1) {
256025
+ if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
256026
+ console.log(`Retrying download (attempt ${retry + 2}/${maxRetries})...`);
256027
+ }
254778
256028
  }
254779
256029
  }
254780
256030
  if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
254781
- console.log(`Binary successfully installed at ${extractedBinaryPath} (version: ${tagVersion})`);
256031
+ console.log(`All lock attempts exhausted, attempting direct download`);
254782
256032
  }
254783
- return extractedBinaryPath;
256033
+ return await withDownloadLock(version, () => doDownload(version));
254784
256034
  } catch (error2) {
254785
256035
  console.error("Error downloading probe binary:", error2);
254786
256036
  throw error2;
254787
256037
  }
254788
256038
  }
254789
- var import_axios, import_fs_extra2, import_path2, import_crypto, import_util, import_child_process, import_tar, import_os2, import_url2, exec, REPO_OWNER, REPO_NAME, BINARY_NAME, __filename2, __dirname2;
256039
+ var import_axios, import_fs_extra2, import_path2, import_crypto, import_util, import_child_process, import_tar, import_os2, import_url2, exec, REPO_OWNER, REPO_NAME, BINARY_NAME, __filename2, __dirname2, downloadLocks, LOCK_TIMEOUT_MS, LOCK_POLL_INTERVAL_MS, MAX_LOCK_WAIT_MS;
254790
256040
  var init_downloader = __esm({
254791
256041
  "src/downloader.js"() {
254792
256042
  "use strict";
@@ -254807,19 +256057,25 @@ var init_downloader = __esm({
254807
256057
  BINARY_NAME = "probe";
254808
256058
  __filename2 = (0, import_url2.fileURLToPath)("file:///");
254809
256059
  __dirname2 = import_path2.default.dirname(__filename2);
256060
+ downloadLocks = /* @__PURE__ */ new Map();
256061
+ LOCK_TIMEOUT_MS = 5 * 60 * 1e3;
256062
+ LOCK_POLL_INTERVAL_MS = 1e3;
256063
+ MAX_LOCK_WAIT_MS = 5 * 60 * 1e3;
254810
256064
  }
254811
256065
  });
254812
256066
 
254813
256067
  // src/utils.js
254814
256068
  async function getBinaryPath(options = {}) {
254815
256069
  const { forceDownload = false, version } = options;
254816
- if (probeBinaryPath && !forceDownload && import_fs_extra3.default.existsSync(probeBinaryPath)) {
254817
- return probeBinaryPath;
254818
- }
254819
256070
  if (process.env.PROBE_PATH && import_fs_extra3.default.existsSync(process.env.PROBE_PATH) && !forceDownload) {
254820
256071
  probeBinaryPath = process.env.PROBE_PATH;
254821
256072
  return probeBinaryPath;
254822
256073
  }
256074
+ if (version && !forceDownload) {
256075
+ console.log(`Specific version ${version} requested. Downloading...`);
256076
+ probeBinaryPath = await downloadProbeBinary(version);
256077
+ return probeBinaryPath;
256078
+ }
254823
256079
  const binDir = await getPackageBinDir();
254824
256080
  const isWindows = process.platform === "win32";
254825
256081
  const binaryName = isWindows ? "probe.exe" : "probe-binary";
@@ -254931,17 +256187,20 @@ Search: query="${queries[0]}" path="${options.path}"`;
254931
256187
  if (options.session) logMessage += ` session=${options.session}`;
254932
256188
  console.error(logMessage);
254933
256189
  }
254934
- const positionalArgs = [];
256190
+ const args = ["search", ...cliArgs];
254935
256191
  if (queries.length > 0) {
254936
- positionalArgs.push(escapeString(queries[0]));
256192
+ args.push(queries[0]);
256193
+ }
256194
+ args.push(options.path);
256195
+ if (process.env.DEBUG === "1") {
256196
+ console.error(`Executing: ${binaryPath} ${args.join(" ")}`);
254937
256197
  }
254938
- positionalArgs.push(escapeString(options.path));
254939
- const command = `${binaryPath} search ${cliArgs.join(" ")} ${positionalArgs.join(" ")}`;
254940
256198
  try {
254941
- const { stdout, stderr } = await execAsync(command, {
254942
- shell: true,
254943
- timeout: options.timeout * 1e3
256199
+ const { stdout, stderr } = await execFileAsync(binaryPath, args, {
256200
+ timeout: options.timeout * 1e3,
254944
256201
  // Convert seconds to milliseconds
256202
+ maxBuffer: 50 * 1024 * 1024
256203
+ // 50MB buffer for large outputs
254945
256204
  });
254946
256205
  if (stderr && process.env.DEBUG) {
254947
256206
  console.error(`stderr: ${stderr}`);
@@ -254990,23 +256249,25 @@ Search results: ${resultCount} matches, ${tokenCount} tokens`;
254990
256249
  } catch (error2) {
254991
256250
  if (error2.code === "ETIMEDOUT" || error2.killed) {
254992
256251
  const timeoutMessage = `Search operation timed out after ${options.timeout} seconds.
254993
- Command: ${command}`;
256252
+ Binary: ${binaryPath}
256253
+ Args: ${args.join(" ")}`;
254994
256254
  console.error(timeoutMessage);
254995
256255
  throw new Error(timeoutMessage);
254996
256256
  }
254997
256257
  const errorMessage = `Error executing search command: ${error2.message}
254998
- Command: ${command}`;
256258
+ Binary: ${binaryPath}
256259
+ Args: ${args.join(" ")}`;
254999
256260
  throw new Error(errorMessage);
255000
256261
  }
255001
256262
  }
255002
- var import_child_process2, import_util2, execAsync, SEARCH_FLAG_MAP;
256263
+ var import_child_process2, import_util2, execFileAsync, SEARCH_FLAG_MAP;
255003
256264
  var init_search = __esm({
255004
256265
  "src/search.js"() {
255005
256266
  "use strict";
255006
256267
  import_child_process2 = __nccwpck_require__(35317);
255007
256268
  import_util2 = __nccwpck_require__(39023);
255008
256269
  init_utils();
255009
- execAsync = (0, import_util2.promisify)(import_child_process2.exec);
256270
+ execFileAsync = (0, import_util2.promisify)(import_child_process2.execFile);
255010
256271
  SEARCH_FLAG_MAP = {
255011
256272
  filesOnly: "--files-only",
255012
256273
  ignore: "--ignore",
@@ -255014,6 +256275,7 @@ var init_search = __esm({
255014
256275
  reranker: "--reranker",
255015
256276
  frequencySearch: "--frequency",
255016
256277
  exact: "--exact",
256278
+ strictElasticSyntax: "--strict-elastic-syntax",
255017
256279
  maxResults: "--max-results",
255018
256280
  maxBytes: "--max-bytes",
255019
256281
  maxTokens: "--max-tokens",
@@ -255051,7 +256313,7 @@ async function query(options) {
255051
256313
  }
255052
256314
  const command = `${binaryPath} query ${cliArgs.join(" ")}`;
255053
256315
  try {
255054
- const { stdout, stderr } = await execAsync2(command);
256316
+ const { stdout, stderr } = await execAsync(command);
255055
256317
  if (stderr) {
255056
256318
  console.error(`stderr: ${stderr}`);
255057
256319
  }
@@ -255080,14 +256342,14 @@ Command: ${command}`;
255080
256342
  throw new Error(errorMessage);
255081
256343
  }
255082
256344
  }
255083
- var import_child_process3, import_util3, execAsync2, QUERY_FLAG_MAP;
256345
+ var import_child_process3, import_util3, execAsync, QUERY_FLAG_MAP;
255084
256346
  var init_query = __esm({
255085
256347
  "src/query.js"() {
255086
256348
  "use strict";
255087
256349
  import_child_process3 = __nccwpck_require__(35317);
255088
256350
  import_util3 = __nccwpck_require__(39023);
255089
256351
  init_utils();
255090
- execAsync2 = (0, import_util3.promisify)(import_child_process3.exec);
256352
+ execAsync = (0, import_util3.promisify)(import_child_process3.exec);
255091
256353
  QUERY_FLAG_MAP = {
255092
256354
  language: "--language",
255093
256355
  ignore: "--ignore",
@@ -255103,15 +256365,20 @@ async function extract(options) {
255103
256365
  if (!options) {
255104
256366
  throw new Error("Options object is required");
255105
256367
  }
255106
- if ((!options.files || !Array.isArray(options.files) || options.files.length === 0) && !options.inputFile) {
255107
- throw new Error("Either files array or inputFile must be provided");
256368
+ const hasFiles = options.files && Array.isArray(options.files) && options.files.length > 0;
256369
+ const hasInputFile = !!options.inputFile;
256370
+ const hasContent = options.content !== void 0 && options.content !== null;
256371
+ if (!hasFiles && !hasInputFile && !hasContent) {
256372
+ throw new Error("Either files array, inputFile, or content must be provided");
255108
256373
  }
255109
256374
  const binaryPath = await getBinaryPath(options.binaryOptions || {});
255110
- const cliArgs = buildCliArgs(options, EXTRACT_FLAG_MAP);
256375
+ const filteredOptions = { ...options };
256376
+ delete filteredOptions.content;
256377
+ const cliArgs = buildCliArgs(filteredOptions, EXTRACT_FLAG_MAP);
255111
256378
  if (options.json && !options.format) {
255112
256379
  cliArgs.push("--format", "json");
255113
256380
  }
255114
- if (options.files && Array.isArray(options.files) && options.files.length > 0) {
256381
+ if (hasFiles) {
255115
256382
  for (const file of options.files) {
255116
256383
  cliArgs.push(escapeString(file));
255117
256384
  }
@@ -255123,75 +256390,124 @@ Extract:`;
255123
256390
  logMessage += ` files="${options.files.join(", ")}"`;
255124
256391
  }
255125
256392
  if (options.inputFile) logMessage += ` inputFile="${options.inputFile}"`;
256393
+ if (options.content) logMessage += ` content=(${typeof options.content === "string" ? options.content.length : options.content.byteLength} bytes)`;
255126
256394
  if (options.allowTests) logMessage += " allowTests=true";
255127
256395
  if (options.contextLines) logMessage += ` contextLines=${options.contextLines}`;
255128
256396
  if (options.format) logMessage += ` format=${options.format}`;
255129
256397
  if (options.json) logMessage += " json=true";
255130
256398
  console.error(logMessage);
255131
256399
  }
256400
+ if (hasContent) {
256401
+ return extractWithStdin(binaryPath, cliArgs, options.content, options);
256402
+ }
255132
256403
  const command = `${binaryPath} extract ${cliArgs.join(" ")}`;
255133
256404
  try {
255134
- const { stdout, stderr } = await execAsync3(command);
256405
+ const { stdout, stderr } = await execAsync2(command);
255135
256406
  if (stderr) {
255136
256407
  console.error(`stderr: ${stderr}`);
255137
256408
  }
255138
- let tokenUsage = {
255139
- requestTokens: 0,
255140
- responseTokens: 0,
255141
- totalTokens: 0
255142
- };
255143
- if (options.files && Array.isArray(options.files)) {
255144
- tokenUsage.requestTokens = options.files.join(" ").length / 4;
255145
- } else if (options.inputFile) {
255146
- tokenUsage.requestTokens = options.inputFile.length / 4;
255147
- }
255148
- if (stdout.includes("Total tokens returned:")) {
255149
- const tokenMatch = stdout.match(/Total tokens returned: (\d+)/);
255150
- if (tokenMatch && tokenMatch[1]) {
255151
- tokenUsage.responseTokens = parseInt(tokenMatch[1], 10);
255152
- tokenUsage.totalTokens = tokenUsage.requestTokens + tokenUsage.responseTokens;
256409
+ return processExtractOutput(stdout, options);
256410
+ } catch (error2) {
256411
+ const errorMessage = `Error executing extract command: ${error2.message}
256412
+ Command: ${command}`;
256413
+ throw new Error(errorMessage);
256414
+ }
256415
+ }
256416
+ function extractWithStdin(binaryPath, cliArgs, content, options) {
256417
+ return new Promise((resolve4, reject2) => {
256418
+ const childProcess = (0, import_child_process4.spawn)(binaryPath, ["extract", ...cliArgs], {
256419
+ stdio: ["pipe", "pipe", "pipe"]
256420
+ });
256421
+ let stdout = "";
256422
+ let stderr = "";
256423
+ childProcess.stdout.on("data", (data2) => {
256424
+ stdout += data2.toString();
256425
+ });
256426
+ childProcess.stderr.on("data", (data2) => {
256427
+ stderr += data2.toString();
256428
+ });
256429
+ childProcess.on("close", (code) => {
256430
+ if (stderr && process.env.DEBUG === "1") {
256431
+ console.error(`stderr: ${stderr}`);
255153
256432
  }
256433
+ if (code !== 0) {
256434
+ reject2(new Error(`Extract command failed with exit code ${code}: ${stderr}`));
256435
+ return;
256436
+ }
256437
+ try {
256438
+ const result = processExtractOutput(stdout, options);
256439
+ resolve4(result);
256440
+ } catch (error2) {
256441
+ reject2(error2);
256442
+ }
256443
+ });
256444
+ childProcess.on("error", (error2) => {
256445
+ reject2(new Error(`Failed to spawn extract process: ${error2.message}`));
256446
+ });
256447
+ if (typeof content === "string") {
256448
+ childProcess.stdin.write(content);
256449
+ } else {
256450
+ childProcess.stdin.write(content);
255154
256451
  }
255155
- let output = stdout;
255156
- if (!output.includes("Token Usage:")) {
255157
- output += `
256452
+ childProcess.stdin.end();
256453
+ });
256454
+ }
256455
+ function processExtractOutput(stdout, options) {
256456
+ let tokenUsage = {
256457
+ requestTokens: 0,
256458
+ responseTokens: 0,
256459
+ totalTokens: 0
256460
+ };
256461
+ if (options.files && Array.isArray(options.files)) {
256462
+ tokenUsage.requestTokens = options.files.join(" ").length / 4;
256463
+ } else if (options.inputFile) {
256464
+ tokenUsage.requestTokens = options.inputFile.length / 4;
256465
+ } else if (options.content) {
256466
+ const contentLength = typeof options.content === "string" ? options.content.length : options.content.byteLength;
256467
+ tokenUsage.requestTokens = contentLength / 4;
256468
+ }
256469
+ if (stdout.includes("Total tokens returned:")) {
256470
+ const tokenMatch = stdout.match(/Total tokens returned: (\d+)/);
256471
+ if (tokenMatch && tokenMatch[1]) {
256472
+ tokenUsage.responseTokens = parseInt(tokenMatch[1], 10);
256473
+ tokenUsage.totalTokens = tokenUsage.requestTokens + tokenUsage.responseTokens;
256474
+ }
256475
+ }
256476
+ let output = stdout;
256477
+ if (!output.includes("Token Usage:")) {
256478
+ output += `
255158
256479
  Token Usage:
255159
256480
  Request tokens: ${tokenUsage.requestTokens}
255160
256481
  Response tokens: ${tokenUsage.responseTokens}
255161
256482
  Total tokens: ${tokenUsage.totalTokens}
255162
256483
  `;
255163
- }
255164
- if (options.json || options.format === "json") {
255165
- try {
255166
- const jsonOutput = JSON.parse(stdout);
255167
- if (!jsonOutput.token_usage) {
255168
- jsonOutput.token_usage = {
255169
- request_tokens: tokenUsage.requestTokens,
255170
- response_tokens: tokenUsage.responseTokens,
255171
- total_tokens: tokenUsage.totalTokens
255172
- };
255173
- }
255174
- return jsonOutput;
255175
- } catch (error2) {
255176
- console.error("Error parsing JSON output:", error2);
255177
- return output;
256484
+ }
256485
+ if (options.json || options.format === "json") {
256486
+ try {
256487
+ const jsonOutput = JSON.parse(stdout);
256488
+ if (!jsonOutput.token_usage) {
256489
+ jsonOutput.token_usage = {
256490
+ request_tokens: tokenUsage.requestTokens,
256491
+ response_tokens: tokenUsage.responseTokens,
256492
+ total_tokens: tokenUsage.totalTokens
256493
+ };
255178
256494
  }
256495
+ return jsonOutput;
256496
+ } catch (error2) {
256497
+ console.error("Error parsing JSON output:", error2);
256498
+ return output;
255179
256499
  }
255180
- return output;
255181
- } catch (error2) {
255182
- const errorMessage = `Error executing extract command: ${error2.message}
255183
- Command: ${command}`;
255184
- throw new Error(errorMessage);
255185
256500
  }
256501
+ return output;
255186
256502
  }
255187
- var import_child_process4, import_util4, execAsync3, EXTRACT_FLAG_MAP;
256503
+ var import_child_process4, import_util4, execAsync2, EXTRACT_FLAG_MAP;
255188
256504
  var init_extract = __esm({
255189
256505
  "src/extract.js"() {
255190
256506
  "use strict";
255191
256507
  import_child_process4 = __nccwpck_require__(35317);
255192
256508
  import_util4 = __nccwpck_require__(39023);
255193
256509
  init_utils();
255194
- execAsync3 = (0, import_util4.promisify)(import_child_process4.exec);
256510
+ execAsync2 = (0, import_util4.promisify)(import_child_process4.exec);
255195
256511
  EXTRACT_FLAG_MAP = {
255196
256512
  allowTests: "--allow-tests",
255197
256513
  contextLines: "--context",
@@ -255226,7 +256542,7 @@ async function grep(options) {
255226
256542
  const paths = Array.isArray(options.paths) ? options.paths : [options.paths];
255227
256543
  cliArgs.push(...paths);
255228
256544
  try {
255229
- const { stdout, stderr } = await execFileAsync(binaryPath, cliArgs, {
256545
+ const { stdout, stderr } = await execFileAsync2(binaryPath, cliArgs, {
255230
256546
  maxBuffer: 10 * 1024 * 1024,
255231
256547
  // 10MB buffer
255232
256548
  env: {
@@ -255244,14 +256560,14 @@ async function grep(options) {
255244
256560
  throw new Error(`Grep failed: ${errorMessage}`);
255245
256561
  }
255246
256562
  }
255247
- var import_child_process5, import_util5, execFileAsync, GREP_FLAG_MAP;
256563
+ var import_child_process5, import_util5, execFileAsync2, GREP_FLAG_MAP;
255248
256564
  var init_grep = __esm({
255249
256565
  "src/grep.js"() {
255250
256566
  "use strict";
255251
256567
  import_child_process5 = __nccwpck_require__(35317);
255252
256568
  import_util5 = __nccwpck_require__(39023);
255253
256569
  init_utils();
255254
- execFileAsync = (0, import_util5.promisify)(import_child_process5.execFile);
256570
+ execFileAsync2 = (0, import_util5.promisify)(import_child_process5.execFile);
255255
256571
  GREP_FLAG_MAP = {
255256
256572
  ignoreCase: "-i",
255257
256573
  lineNumbers: "-n",
@@ -259482,6 +260798,12 @@ function createMessagePreview(message, charsPerSide = 200) {
259482
260798
  const end = message.substring(message.length - charsPerSide);
259483
260799
  return `${start}...${end}`;
259484
260800
  }
260801
+ function parseTargets(targets) {
260802
+ if (!targets || typeof targets !== "string") {
260803
+ return [];
260804
+ }
260805
+ return targets.split(/\s+/).filter((f3) => f3.length > 0);
260806
+ }
259485
260807
  var searchSchema, querySchema, extractSchema, delegateSchema, bashSchema, attemptCompletionSchema, searchToolDefinition, queryToolDefinition, extractToolDefinition, delegateToolDefinition, attemptCompletionToolDefinition, bashToolDefinition, searchDescription, queryDescription, extractDescription, delegateDescription, bashDescription, DEFAULT_VALID_TOOLS;
259486
260808
  var init_common = __esm({
259487
260809
  "src/tools/common.js"() {
@@ -259509,7 +260831,7 @@ var init_common = __esm({
259509
260831
  end_line: external_exports.number().optional().describe("End line number for extracting a range of lines"),
259510
260832
  allow_tests: external_exports.boolean().optional().default(false).describe("Allow test files and test code blocks"),
259511
260833
  context_lines: external_exports.number().optional().default(10).describe("Number of context lines to include"),
259512
- format: external_exports.string().optional().default("plain").describe("Output format (plain, markdown, json, color)")
260834
+ format: external_exports.string().optional().default("plain").describe("Output format (plain, markdown, json, xml, color, outline-xml, outline-diff)")
259513
260835
  });
259514
260836
  delegateSchema = external_exports.object({
259515
260837
  task: external_exports.string().describe("The task to delegate to a subagent. Be specific about what needs to be accomplished.")
@@ -260136,7 +261458,7 @@ var init_vercel = __esm({
260136
261458
  format: effectiveFormat
260137
261459
  };
260138
261460
  } else if (targets) {
260139
- const files = [targets];
261461
+ const files = parseTargets(targets);
260140
261462
  let effectiveFormat = format2;
260141
261463
  if (outline && format2 === "outline-xml") {
260142
261464
  effectiveFormat = "xml";
@@ -261494,7 +262816,7 @@ function createExtractTool() {
261494
262816
  schema: extractSchema,
261495
262817
  func: async ({ targets, line, end_line, allow_tests, context_lines, format: format2 }) => {
261496
262818
  try {
261497
- const files = [targets];
262819
+ const files = parseTargets(targets);
261498
262820
  const results = await extract({
261499
262821
  files,
261500
262822
  allowTests: allow_tests,
@@ -261720,7 +263042,7 @@ async function listFilesByLevel(options) {
261720
263042
  return await listFilesByLevelManually(directory, maxFiles, respectGitignore);
261721
263043
  }
261722
263044
  async function listFilesUsingGit(directory, maxFiles) {
261723
- const { stdout } = await execAsync4("git ls-files", { cwd: directory });
263045
+ const { stdout } = await execAsync3("git ls-files", { cwd: directory });
261724
263046
  const files = stdout.split("\n").filter(Boolean);
261725
263047
  const sortedFiles = files.sort((a3, b3) => {
261726
263048
  const depthA = a3.split(import_path6.default.sep).length;
@@ -261786,7 +263108,7 @@ function shouldIgnore(filePath, ignorePatterns) {
261786
263108
  }
261787
263109
  return false;
261788
263110
  }
261789
- var import_fs2, import_path6, import_util9, import_child_process8, execAsync4;
263111
+ var import_fs2, import_path6, import_util9, import_child_process8, execAsync3;
261790
263112
  var init_file_lister = __esm({
261791
263113
  "src/utils/file-lister.js"() {
261792
263114
  "use strict";
@@ -261794,7 +263116,7 @@ var init_file_lister = __esm({
261794
263116
  import_path6 = __toESM(__nccwpck_require__(16928), 1);
261795
263117
  import_util9 = __nccwpck_require__(39023);
261796
263118
  import_child_process8 = __nccwpck_require__(35317);
261797
- execAsync4 = (0, import_util9.promisify)(import_child_process8.exec);
263119
+ execAsync3 = (0, import_util9.promisify)(import_child_process8.exec);
261798
263120
  }
261799
263121
  });
261800
263122
 
@@ -264853,22 +266175,13 @@ var require_dist_cjs18 = __commonJS({
264853
266175
  var sdkStreamMixin2 = require_sdk_stream_mixin();
264854
266176
  var splitStream = require_splitStream();
264855
266177
  var streamTypeCheck = require_stream_type_check();
264856
- function transformToString(payload2, encoding = "utf-8") {
264857
- if (encoding === "base64") {
264858
- return utilBase64.toBase64(payload2);
264859
- }
264860
- return utilUtf8.toUtf8(payload2);
264861
- }
264862
- function transformFromString(str, encoding) {
264863
- if (encoding === "base64") {
264864
- return Uint8ArrayBlobAdapter2.mutate(utilBase64.fromBase64(str));
264865
- }
264866
- return Uint8ArrayBlobAdapter2.mutate(utilUtf8.fromUtf8(str));
264867
- }
264868
266178
  var Uint8ArrayBlobAdapter2 = class _Uint8ArrayBlobAdapter extends Uint8Array {
264869
266179
  static fromString(source, encoding = "utf-8") {
264870
266180
  if (typeof source === "string") {
264871
- return transformFromString(source, encoding);
266181
+ if (encoding === "base64") {
266182
+ return _Uint8ArrayBlobAdapter.mutate(utilBase64.fromBase64(source));
266183
+ }
266184
+ return _Uint8ArrayBlobAdapter.mutate(utilUtf8.fromUtf8(source));
264872
266185
  }
264873
266186
  throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
264874
266187
  }
@@ -264877,7 +266190,10 @@ var require_dist_cjs18 = __commonJS({
264877
266190
  return source;
264878
266191
  }
264879
266192
  transformToString(encoding = "utf-8") {
264880
- return transformToString(this, encoding);
266193
+ if (encoding === "base64") {
266194
+ return utilBase64.toBase64(this);
266195
+ }
266196
+ return utilUtf8.toUtf8(this);
264881
266197
  }
264882
266198
  };
264883
266199
  exports2.Uint8ArrayBlobAdapter = Uint8ArrayBlobAdapter2;
@@ -264990,6 +266306,138 @@ var init_deref = __esm({
264990
266306
  }
264991
266307
  });
264992
266308
 
266309
+ // node_modules/@smithy/core/dist-es/submodules/schema/schemas/operation.js
266310
+ var operation;
266311
+ var init_operation = __esm({
266312
+ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/operation.js"() {
266313
+ operation = (namespace, name14, traits, input, output) => ({
266314
+ name: name14,
266315
+ namespace,
266316
+ traits,
266317
+ input,
266318
+ output
266319
+ });
266320
+ }
266321
+ });
266322
+
266323
+ // node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js
266324
+ var import_protocol_http2, import_util_middleware3, schemaDeserializationMiddleware, findHeader;
266325
+ var init_schemaDeserializationMiddleware = __esm({
266326
+ "node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js"() {
266327
+ import_protocol_http2 = __toESM(require_dist_cjs2());
266328
+ import_util_middleware3 = __toESM(require_dist_cjs7());
266329
+ init_operation();
266330
+ schemaDeserializationMiddleware = (config) => (next, context3) => async (args) => {
266331
+ const { response } = await next(args);
266332
+ const { operationSchema } = (0, import_util_middleware3.getSmithyContext)(context3);
266333
+ const [, ns, n3, t3, i3, o3] = operationSchema ?? [];
266334
+ try {
266335
+ const parsed = await config.protocol.deserializeResponse(operation(ns, n3, t3, i3, o3), {
266336
+ ...config,
266337
+ ...context3
266338
+ }, response);
266339
+ return {
266340
+ response,
266341
+ output: parsed
266342
+ };
266343
+ } catch (error2) {
266344
+ Object.defineProperty(error2, "$response", {
266345
+ value: response
266346
+ });
266347
+ if (!("$metadata" in error2)) {
266348
+ const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
266349
+ try {
266350
+ error2.message += "\n " + hint;
266351
+ } catch (e3) {
266352
+ if (!context3.logger || context3.logger?.constructor?.name === "NoOpLogger") {
266353
+ console.warn(hint);
266354
+ } else {
266355
+ context3.logger?.warn?.(hint);
266356
+ }
266357
+ }
266358
+ if (typeof error2.$responseBodyText !== "undefined") {
266359
+ if (error2.$response) {
266360
+ error2.$response.body = error2.$responseBodyText;
266361
+ }
266362
+ }
266363
+ try {
266364
+ if (import_protocol_http2.HttpResponse.isInstance(response)) {
266365
+ const { headers = {} } = response;
266366
+ const headerEntries = Object.entries(headers);
266367
+ error2.$metadata = {
266368
+ httpStatusCode: response.statusCode,
266369
+ requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries),
266370
+ extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries),
266371
+ cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries)
266372
+ };
266373
+ }
266374
+ } catch (e3) {
266375
+ }
266376
+ }
266377
+ throw error2;
266378
+ }
266379
+ };
266380
+ findHeader = (pattern, headers) => {
266381
+ return (headers.find(([k3]) => {
266382
+ return k3.match(pattern);
266383
+ }) || [void 0, void 0])[1];
266384
+ };
266385
+ }
266386
+ });
266387
+
266388
+ // node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js
266389
+ var import_util_middleware4, schemaSerializationMiddleware;
266390
+ var init_schemaSerializationMiddleware = __esm({
266391
+ "node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js"() {
266392
+ import_util_middleware4 = __toESM(require_dist_cjs7());
266393
+ init_operation();
266394
+ schemaSerializationMiddleware = (config) => (next, context3) => async (args) => {
266395
+ const { operationSchema } = (0, import_util_middleware4.getSmithyContext)(context3);
266396
+ const [, ns, n3, t3, i3, o3] = operationSchema ?? [];
266397
+ const endpoint = context3.endpointV2?.url && config.urlParser ? async () => config.urlParser(context3.endpointV2.url) : config.endpoint;
266398
+ const request = await config.protocol.serializeRequest(operation(ns, n3, t3, i3, o3), args.input, {
266399
+ ...config,
266400
+ ...context3,
266401
+ endpoint
266402
+ });
266403
+ return next({
266404
+ ...args,
266405
+ request
266406
+ });
266407
+ };
266408
+ }
266409
+ });
266410
+
266411
+ // node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js
266412
+ function getSchemaSerdePlugin(config) {
266413
+ return {
266414
+ applyToStack: (commandStack) => {
266415
+ commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption2);
266416
+ commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption);
266417
+ config.protocol.setSerdeContext(config);
266418
+ }
266419
+ };
266420
+ }
266421
+ var deserializerMiddlewareOption, serializerMiddlewareOption2;
266422
+ var init_getSchemaSerdePlugin = __esm({
266423
+ "node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js"() {
266424
+ init_schemaDeserializationMiddleware();
266425
+ init_schemaSerializationMiddleware();
266426
+ deserializerMiddlewareOption = {
266427
+ name: "deserializerMiddleware",
266428
+ step: "deserialize",
266429
+ tags: ["DESERIALIZER"],
266430
+ override: true
266431
+ };
266432
+ serializerMiddlewareOption2 = {
266433
+ name: "serializerMiddleware",
266434
+ step: "serialize",
266435
+ tags: ["SERIALIZER"],
266436
+ override: true
266437
+ };
266438
+ }
266439
+ });
266440
+
264993
266441
  // node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js
264994
266442
  var Schema;
264995
266443
  var init_Schema = __esm({
@@ -265017,51 +266465,6 @@ var init_Schema = __esm({
265017
266465
  }
265018
266466
  });
265019
266467
 
265020
- // node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js
265021
- var StructureSchema, struct;
265022
- var init_StructureSchema = __esm({
265023
- "node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js"() {
265024
- init_Schema();
265025
- StructureSchema = class _StructureSchema extends Schema {
265026
- static symbol = Symbol.for("@smithy/str");
265027
- name;
265028
- traits;
265029
- memberNames;
265030
- memberList;
265031
- symbol = _StructureSchema.symbol;
265032
- };
265033
- struct = (namespace, name14, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), {
265034
- name: name14,
265035
- namespace,
265036
- traits,
265037
- memberNames,
265038
- memberList
265039
- });
265040
- }
265041
- });
265042
-
265043
- // node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js
265044
- var ErrorSchema, error;
265045
- var init_ErrorSchema = __esm({
265046
- "node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js"() {
265047
- init_Schema();
265048
- init_StructureSchema();
265049
- ErrorSchema = class _ErrorSchema extends StructureSchema {
265050
- static symbol = Symbol.for("@smithy/err");
265051
- ctor;
265052
- symbol = _ErrorSchema.symbol;
265053
- };
265054
- error = (namespace, name14, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), {
265055
- name: name14,
265056
- namespace,
265057
- traits,
265058
- memberNames,
265059
- memberList,
265060
- ctor: null
265061
- });
265062
- }
265063
- });
265064
-
265065
266468
  // node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js
265066
266469
  var ListSchema, list;
265067
266470
  var init_ListSchema = __esm({
@@ -265129,29 +266532,47 @@ var init_OperationSchema = __esm({
265129
266532
  }
265130
266533
  });
265131
266534
 
265132
- // node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js
265133
- var SimpleSchema, sim, simAdapter;
265134
- var init_SimpleSchema = __esm({
265135
- "node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js"() {
266535
+ // node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js
266536
+ var StructureSchema, struct;
266537
+ var init_StructureSchema = __esm({
266538
+ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js"() {
265136
266539
  init_Schema();
265137
- SimpleSchema = class _SimpleSchema extends Schema {
265138
- static symbol = Symbol.for("@smithy/sim");
266540
+ StructureSchema = class _StructureSchema extends Schema {
266541
+ static symbol = Symbol.for("@smithy/str");
265139
266542
  name;
265140
- schemaRef;
265141
266543
  traits;
265142
- symbol = _SimpleSchema.symbol;
266544
+ memberNames;
266545
+ memberList;
266546
+ symbol = _StructureSchema.symbol;
265143
266547
  };
265144
- sim = (namespace, name14, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
266548
+ struct = (namespace, name14, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), {
265145
266549
  name: name14,
265146
266550
  namespace,
265147
266551
  traits,
265148
- schemaRef
266552
+ memberNames,
266553
+ memberList
265149
266554
  });
265150
- simAdapter = (namespace, name14, traits, schemaRef) => Schema.assign(new SimpleSchema(), {
266555
+ }
266556
+ });
266557
+
266558
+ // node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js
266559
+ var ErrorSchema, error;
266560
+ var init_ErrorSchema = __esm({
266561
+ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js"() {
266562
+ init_Schema();
266563
+ init_StructureSchema();
266564
+ ErrorSchema = class _ErrorSchema extends StructureSchema {
266565
+ static symbol = Symbol.for("@smithy/err");
266566
+ ctor;
266567
+ symbol = _ErrorSchema.symbol;
266568
+ };
266569
+ error = (namespace, name14, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), {
265151
266570
  name: name14,
265152
266571
  namespace,
265153
266572
  traits,
265154
- schemaRef
266573
+ memberNames,
266574
+ memberList,
266575
+ ctor: null
265155
266576
  });
265156
266577
  }
265157
266578
  });
@@ -265195,28 +266616,10 @@ function member(memberSchema, memberName) {
265195
266616
  const internalCtorAccess = NormalizedSchema;
265196
266617
  return new internalCtorAccess(memberSchema, memberName);
265197
266618
  }
265198
- function hydrate(ss) {
265199
- const [id, ...rest] = ss;
265200
- return {
265201
- [0]: simAdapter,
265202
- [1]: list,
265203
- [2]: map,
265204
- [3]: struct,
265205
- [-3]: error,
265206
- [9]: op
265207
- }[id].call(null, ...rest);
265208
- }
265209
266619
  var NormalizedSchema, isMemberSchema, isStaticSchema;
265210
266620
  var init_NormalizedSchema = __esm({
265211
266621
  "node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js"() {
265212
266622
  init_deref();
265213
- init_ErrorSchema();
265214
- init_ListSchema();
265215
- init_MapSchema();
265216
- init_OperationSchema();
265217
- init_Schema();
265218
- init_SimpleSchema();
265219
- init_StructureSchema();
265220
266623
  init_translateTraits();
265221
266624
  NormalizedSchema = class _NormalizedSchema {
265222
266625
  ref;
@@ -265242,8 +266645,6 @@ var init_NormalizedSchema = __esm({
265242
266645
  schema = deref(_ref);
265243
266646
  this._isMemberSchema = true;
265244
266647
  }
265245
- if (isStaticSchema(schema))
265246
- schema = hydrate(schema);
265247
266648
  if (traitStack.length > 0) {
265248
266649
  this.memberTraits = {};
265249
266650
  for (let i3 = traitStack.length - 1; i3 >= 0; --i3) {
@@ -265262,18 +266663,24 @@ var init_NormalizedSchema = __esm({
265262
266663
  return;
265263
266664
  }
265264
266665
  this.schema = deref(schema);
265265
- if (this.schema && typeof this.schema === "object") {
265266
- this.traits = this.schema?.traits ?? {};
266666
+ if (isStaticSchema(this.schema)) {
266667
+ this.name = `${this.schema[1]}#${this.schema[2]}`;
266668
+ this.traits = this.schema[3];
265267
266669
  } else {
266670
+ this.name = this.memberName ?? String(schema);
265268
266671
  this.traits = 0;
265269
266672
  }
265270
- this.name = (this.schema instanceof Schema ? this.schema.getName?.() : void 0) ?? this.memberName ?? String(schema);
265271
266673
  if (this._isMemberSchema && !memberName) {
265272
266674
  throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(true)} missing member name.`);
265273
266675
  }
265274
266676
  }
265275
266677
  static [Symbol.hasInstance](lhs) {
265276
- return Schema[Symbol.hasInstance].bind(this)(lhs);
266678
+ const isPrototype2 = this.prototype.isPrototypeOf(lhs);
266679
+ if (!isPrototype2 && typeof lhs === "object" && lhs !== null) {
266680
+ const ns = lhs;
266681
+ return ns.symbol === this.symbol;
266682
+ }
266683
+ return isPrototype2;
265277
266684
  }
265278
266685
  static of(ref) {
265279
266686
  const sc = deref(ref);
@@ -265291,7 +266698,11 @@ var init_NormalizedSchema = __esm({
265291
266698
  return new _NormalizedSchema(sc);
265292
266699
  }
265293
266700
  getSchema() {
265294
- return deref(this.schema?.schemaRef ?? this.schema);
266701
+ const sc = this.schema;
266702
+ if (sc[0] === 0) {
266703
+ return sc[4];
266704
+ }
266705
+ return sc;
265295
266706
  }
265296
266707
  getName(withNamespace = false) {
265297
266708
  const { name: name14 } = this;
@@ -265306,15 +266717,15 @@ var init_NormalizedSchema = __esm({
265306
266717
  }
265307
266718
  isListSchema() {
265308
266719
  const sc = this.getSchema();
265309
- return typeof sc === "number" ? sc >= 64 && sc < 128 : sc instanceof ListSchema;
266720
+ return typeof sc === "number" ? sc >= 64 && sc < 128 : sc[0] === 1;
265310
266721
  }
265311
266722
  isMapSchema() {
265312
266723
  const sc = this.getSchema();
265313
- return typeof sc === "number" ? sc >= 128 && sc <= 255 : sc instanceof MapSchema;
266724
+ return typeof sc === "number" ? sc >= 128 && sc <= 255 : sc[0] === 2;
265314
266725
  }
265315
266726
  isStructSchema() {
265316
266727
  const sc = this.getSchema();
265317
- return sc !== null && typeof sc === "object" && "members" in sc || sc instanceof StructureSchema;
266728
+ return sc[0] === 3 || sc[0] === -3;
265318
266729
  }
265319
266730
  isBlobSchema() {
265320
266731
  const sc = this.getSchema();
@@ -265372,13 +266783,13 @@ var init_NormalizedSchema = __esm({
265372
266783
  throw new Error(`@smithy/core/schema - cannot get key for non-map: ${this.getName(true)}`);
265373
266784
  }
265374
266785
  const schema = this.getSchema();
265375
- const memberSchema = isDoc ? 15 : schema?.keySchema ?? 0;
266786
+ const memberSchema = isDoc ? 15 : schema[4] ?? 0;
265376
266787
  return member([memberSchema, 0], "key");
265377
266788
  }
265378
266789
  getValueSchema() {
265379
266790
  const sc = this.getSchema();
265380
266791
  const [isDoc, isMap2, isList] = [this.isDocumentSchema(), this.isMapSchema(), this.isListSchema()];
265381
- const memberSchema = typeof sc === "number" ? 63 & sc : sc && typeof sc === "object" && (isMap2 || isList) ? sc.valueSchema : isDoc ? 15 : void 0;
266792
+ const memberSchema = typeof sc === "number" ? 63 & sc : sc && typeof sc === "object" && (isMap2 || isList) ? sc[3 + sc[0]] : isDoc ? 15 : void 0;
265382
266793
  if (memberSchema != null) {
265383
266794
  return member([memberSchema, 0], isMap2 ? "value" : "member");
265384
266795
  }
@@ -265386,9 +266797,9 @@ var init_NormalizedSchema = __esm({
265386
266797
  }
265387
266798
  getMemberSchema(memberName) {
265388
266799
  const struct2 = this.getSchema();
265389
- if (this.isStructSchema() && struct2.memberNames.includes(memberName)) {
265390
- const i3 = struct2.memberNames.indexOf(memberName);
265391
- const memberSchema = struct2.memberList[i3];
266800
+ if (this.isStructSchema() && struct2[4].includes(memberName)) {
266801
+ const i3 = struct2[4].indexOf(memberName);
266802
+ const memberSchema = struct2[5][i3];
265392
266803
  return member(isMemberSchema(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
265393
266804
  }
265394
266805
  if (this.isDocumentSchema()) {
@@ -265424,8 +266835,8 @@ var init_NormalizedSchema = __esm({
265424
266835
  throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");
265425
266836
  }
265426
266837
  const struct2 = this.getSchema();
265427
- for (let i3 = 0; i3 < struct2.memberNames.length; ++i3) {
265428
- yield [struct2.memberNames[i3], member([struct2.memberList[i3], 0], struct2.memberNames[i3])];
266838
+ for (let i3 = 0; i3 < struct2[4].length; ++i3) {
266839
+ yield [struct2[4][i3], member([struct2[5][i3], 0], struct2[4][i3])];
265429
266840
  }
265430
266841
  }
265431
266842
  };
@@ -265434,125 +266845,30 @@ var init_NormalizedSchema = __esm({
265434
266845
  }
265435
266846
  });
265436
266847
 
265437
- // node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js
265438
- var import_protocol_http2, import_util_middleware3, schemaDeserializationMiddleware, findHeader;
265439
- var init_schemaDeserializationMiddleware = __esm({
265440
- "node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js"() {
265441
- import_protocol_http2 = __toESM(require_dist_cjs2());
265442
- import_util_middleware3 = __toESM(require_dist_cjs7());
265443
- init_NormalizedSchema();
265444
- schemaDeserializationMiddleware = (config) => (next, context3) => async (args) => {
265445
- const { response } = await next(args);
265446
- let { operationSchema } = (0, import_util_middleware3.getSmithyContext)(context3);
265447
- if (isStaticSchema(operationSchema)) {
265448
- operationSchema = hydrate(operationSchema);
265449
- }
265450
- try {
265451
- const parsed = await config.protocol.deserializeResponse(operationSchema, {
265452
- ...config,
265453
- ...context3
265454
- }, response);
265455
- return {
265456
- response,
265457
- output: parsed
265458
- };
265459
- } catch (error2) {
265460
- Object.defineProperty(error2, "$response", {
265461
- value: response
265462
- });
265463
- if (!("$metadata" in error2)) {
265464
- const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
265465
- try {
265466
- error2.message += "\n " + hint;
265467
- } catch (e3) {
265468
- if (!context3.logger || context3.logger?.constructor?.name === "NoOpLogger") {
265469
- console.warn(hint);
265470
- } else {
265471
- context3.logger?.warn?.(hint);
265472
- }
265473
- }
265474
- if (typeof error2.$responseBodyText !== "undefined") {
265475
- if (error2.$response) {
265476
- error2.$response.body = error2.$responseBodyText;
265477
- }
265478
- }
265479
- try {
265480
- if (import_protocol_http2.HttpResponse.isInstance(response)) {
265481
- const { headers = {} } = response;
265482
- const headerEntries = Object.entries(headers);
265483
- error2.$metadata = {
265484
- httpStatusCode: response.statusCode,
265485
- requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries),
265486
- extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries),
265487
- cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries)
265488
- };
265489
- }
265490
- } catch (e3) {
265491
- }
265492
- }
265493
- throw error2;
265494
- }
265495
- };
265496
- findHeader = (pattern, headers) => {
265497
- return (headers.find(([k3]) => {
265498
- return k3.match(pattern);
265499
- }) || [void 0, void 0])[1];
265500
- };
265501
- }
265502
- });
265503
-
265504
- // node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js
265505
- var import_util_middleware4, schemaSerializationMiddleware;
265506
- var init_schemaSerializationMiddleware = __esm({
265507
- "node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js"() {
265508
- import_util_middleware4 = __toESM(require_dist_cjs7());
265509
- init_NormalizedSchema();
265510
- schemaSerializationMiddleware = (config) => (next, context3) => async (args) => {
265511
- let { operationSchema } = (0, import_util_middleware4.getSmithyContext)(context3);
265512
- if (isStaticSchema(operationSchema)) {
265513
- operationSchema = hydrate(operationSchema);
265514
- }
265515
- const endpoint = context3.endpointV2?.url && config.urlParser ? async () => config.urlParser(context3.endpointV2.url) : config.endpoint;
265516
- const request = await config.protocol.serializeRequest(operationSchema, args.input, {
265517
- ...config,
265518
- ...context3,
265519
- endpoint
265520
- });
265521
- return next({
265522
- ...args,
265523
- request
265524
- });
265525
- };
265526
- }
265527
- });
265528
-
265529
- // node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js
265530
- function getSchemaSerdePlugin(config) {
265531
- return {
265532
- applyToStack: (commandStack) => {
265533
- commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption2);
265534
- commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption);
265535
- config.protocol.setSerdeContext(config);
265536
- }
265537
- };
265538
- }
265539
- var deserializerMiddlewareOption, serializerMiddlewareOption2;
265540
- var init_getSchemaSerdePlugin = __esm({
265541
- "node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js"() {
265542
- init_schemaDeserializationMiddleware();
265543
- init_schemaSerializationMiddleware();
265544
- deserializerMiddlewareOption = {
265545
- name: "deserializerMiddleware",
265546
- step: "deserialize",
265547
- tags: ["DESERIALIZER"],
265548
- override: true
265549
- };
265550
- serializerMiddlewareOption2 = {
265551
- name: "serializerMiddleware",
265552
- step: "serialize",
265553
- tags: ["SERIALIZER"],
265554
- override: true
266848
+ // node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js
266849
+ var SimpleSchema, sim, simAdapter;
266850
+ var init_SimpleSchema = __esm({
266851
+ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js"() {
266852
+ init_Schema();
266853
+ SimpleSchema = class _SimpleSchema extends Schema {
266854
+ static symbol = Symbol.for("@smithy/sim");
266855
+ name;
266856
+ schemaRef;
266857
+ traits;
266858
+ symbol = _SimpleSchema.symbol;
265555
266859
  };
266860
+ sim = (namespace, name14, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
266861
+ name: name14,
266862
+ namespace,
266863
+ traits,
266864
+ schemaRef
266865
+ });
266866
+ simAdapter = (namespace, name14, traits, schemaRef) => Schema.assign(new SimpleSchema(), {
266867
+ name: name14,
266868
+ namespace,
266869
+ traits,
266870
+ schemaRef
266871
+ });
265556
266872
  }
265557
266873
  });
265558
266874
 
@@ -265620,7 +266936,7 @@ var init_TypeRegistry = __esm({
265620
266936
  getErrorCtor(es) {
265621
266937
  const $error = es;
265622
266938
  const registry = _TypeRegistry.for($error[1]);
265623
- return registry.exceptions.get(es);
266939
+ return registry.exceptions.get($error);
265624
266940
  }
265625
266941
  getBaseException() {
265626
266942
  for (const exceptionKey of this.exceptions.keys()) {
@@ -265668,11 +266984,11 @@ __export(schema_exports, {
265668
266984
  deserializerMiddlewareOption: () => deserializerMiddlewareOption,
265669
266985
  error: () => error,
265670
266986
  getSchemaSerdePlugin: () => getSchemaSerdePlugin,
265671
- hydrate: () => hydrate,
265672
266987
  isStaticSchema: () => isStaticSchema,
265673
266988
  list: () => list,
265674
266989
  map: () => map,
265675
266990
  op: () => op,
266991
+ operation: () => operation,
265676
266992
  serializerMiddlewareOption: () => serializerMiddlewareOption2,
265677
266993
  sim: () => sim,
265678
266994
  simAdapter: () => simAdapter,
@@ -265686,6 +267002,7 @@ var init_schema = __esm({
265686
267002
  init_ListSchema();
265687
267003
  init_MapSchema();
265688
267004
  init_OperationSchema();
267005
+ init_operation();
265689
267006
  init_ErrorSchema();
265690
267007
  init_NormalizedSchema();
265691
267008
  init_Schema();
@@ -267052,7 +268369,6 @@ var init_EventStreamSerde = __esm({
267052
268369
  const marshaller = this.marshaller;
267053
268370
  const eventStreamMember = requestSchema.getEventStreamMember();
267054
268371
  const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
267055
- const memberSchemas = unionSchema.getMemberSchemas();
267056
268372
  const serializer = this.serializer;
267057
268373
  const defaultContentType = this.defaultContentType;
267058
268374
  const initialRequestMarker = Symbol("initialRequestMarker");
@@ -267163,7 +268479,7 @@ var init_EventStreamSerde = __esm({
267163
268479
  let explicitPayloadContentType;
267164
268480
  const isKnownSchema = (() => {
267165
268481
  const struct2 = unionSchema.getSchema();
267166
- return struct2.memberNames.includes(unionMember);
268482
+ return struct2[4].includes(unionMember);
267167
268483
  })();
267168
268484
  const additionalHeaders = {};
267169
268485
  if (!isKnownSchema) {
@@ -267297,10 +268613,10 @@ var init_HttpProtocol = __esm({
267297
268613
  }
267298
268614
  }
267299
268615
  setHostPrefix(request, operationSchema, input) {
267300
- const operationNs = NormalizedSchema.of(operationSchema);
267301
268616
  const inputNs = NormalizedSchema.of(operationSchema.input);
267302
- if (operationNs.getMergedTraits().endpoint) {
267303
- let hostPrefix = operationNs.getMergedTraits().endpoint?.[0];
268617
+ const opTraits = translateTraits(operationSchema.traits ?? {});
268618
+ if (opTraits.endpoint) {
268619
+ let hostPrefix = opTraits.endpoint?.[0];
267304
268620
  if (typeof hostPrefix === "string") {
267305
268621
  const hostLabelInputs = [...inputNs.structIterator()].filter(([, member2]) => member2.getMergedTraits().hostLabel);
267306
268622
  for (const [name14] of hostLabelInputs) {
@@ -268579,20 +269895,24 @@ var require_dist_cjs20 = __commonJS({
268579
269895
  if (typeof obj === "string") {
268580
269896
  return evaluateTemplate(obj, options);
268581
269897
  } else if (obj["fn"]) {
268582
- return callFunction(obj, options);
269898
+ return group$2.callFunction(obj, options);
268583
269899
  } else if (obj["ref"]) {
268584
269900
  return getReferenceValue(obj, options);
268585
269901
  }
268586
269902
  throw new EndpointError(`'${keyName}': ${String(obj)} is not a string, function or reference.`);
268587
269903
  };
268588
269904
  var callFunction = ({ fn, argv }, options) => {
268589
- const evaluatedArgs = argv.map((arg) => ["boolean", "number"].includes(typeof arg) ? arg : evaluateExpression(arg, "arg", options));
269905
+ const evaluatedArgs = argv.map((arg) => ["boolean", "number"].includes(typeof arg) ? arg : group$2.evaluateExpression(arg, "arg", options));
268590
269906
  const fnSegments = fn.split(".");
268591
269907
  if (fnSegments[0] in customEndpointFunctions3 && fnSegments[1] != null) {
268592
269908
  return customEndpointFunctions3[fnSegments[0]][fnSegments[1]](...evaluatedArgs);
268593
269909
  }
268594
269910
  return endpointFunctions[fn](...evaluatedArgs);
268595
269911
  };
269912
+ var group$2 = {
269913
+ evaluateExpression,
269914
+ callFunction
269915
+ };
268596
269916
  var evaluateCondition = ({ assign: assign2, ...fnArgs }, options) => {
268597
269917
  if (assign2 && assign2 in options.referenceRecord) {
268598
269918
  throw new EndpointError(`'${assign2}' is already defined in Reference Record.`);
@@ -268634,6 +269954,10 @@ var require_dist_cjs20 = __commonJS({
268634
269954
  return processedExpr;
268635
269955
  })
268636
269956
  }), {});
269957
+ var getEndpointProperties = (properties, options) => Object.entries(properties).reduce((acc, [propertyKey, propertyVal]) => ({
269958
+ ...acc,
269959
+ [propertyKey]: group$1.getEndpointProperty(propertyVal, options)
269960
+ }), {});
268637
269961
  var getEndpointProperty = (property2, options) => {
268638
269962
  if (Array.isArray(property2)) {
268639
269963
  return property2.map((propertyEntry) => getEndpointProperty(propertyEntry, options));
@@ -268645,17 +269969,17 @@ var require_dist_cjs20 = __commonJS({
268645
269969
  if (property2 === null) {
268646
269970
  throw new EndpointError(`Unexpected endpoint property: ${property2}`);
268647
269971
  }
268648
- return getEndpointProperties(property2, options);
269972
+ return group$1.getEndpointProperties(property2, options);
268649
269973
  case "boolean":
268650
269974
  return property2;
268651
269975
  default:
268652
269976
  throw new EndpointError(`Unexpected endpoint property type: ${typeof property2}`);
268653
269977
  }
268654
269978
  };
268655
- var getEndpointProperties = (properties, options) => Object.entries(properties).reduce((acc, [propertyKey, propertyVal]) => ({
268656
- ...acc,
268657
- [propertyKey]: getEndpointProperty(propertyVal, options)
268658
- }), {});
269979
+ var group$1 = {
269980
+ getEndpointProperty,
269981
+ getEndpointProperties
269982
+ };
268659
269983
  var getEndpointUrl = (endpointUrl, options) => {
268660
269984
  const expression = evaluateExpression(endpointUrl, "Endpoint URL", options);
268661
269985
  if (typeof expression === "string") {
@@ -268701,17 +270025,6 @@ var require_dist_cjs20 = __commonJS({
268701
270025
  referenceRecord: { ...options.referenceRecord, ...referenceRecord }
268702
270026
  }));
268703
270027
  };
268704
- var evaluateTreeRule = (treeRule, options) => {
268705
- const { conditions, rules } = treeRule;
268706
- const { result, referenceRecord } = evaluateConditions(conditions, options);
268707
- if (!result) {
268708
- return;
268709
- }
268710
- return evaluateRules(rules, {
268711
- ...options,
268712
- referenceRecord: { ...options.referenceRecord, ...referenceRecord }
268713
- });
268714
- };
268715
270028
  var evaluateRules = (rules, options) => {
268716
270029
  for (const rule of rules) {
268717
270030
  if (rule.type === "endpoint") {
@@ -268722,7 +270035,7 @@ var require_dist_cjs20 = __commonJS({
268722
270035
  } else if (rule.type === "error") {
268723
270036
  evaluateErrorRule(rule, options);
268724
270037
  } else if (rule.type === "tree") {
268725
- const endpointOrUndefined = evaluateTreeRule(rule, options);
270038
+ const endpointOrUndefined = group.evaluateTreeRule(rule, options);
268726
270039
  if (endpointOrUndefined) {
268727
270040
  return endpointOrUndefined;
268728
270041
  }
@@ -268732,6 +270045,21 @@ var require_dist_cjs20 = __commonJS({
268732
270045
  }
268733
270046
  throw new EndpointError(`Rules evaluation failed`);
268734
270047
  };
270048
+ var evaluateTreeRule = (treeRule, options) => {
270049
+ const { conditions, rules } = treeRule;
270050
+ const { result, referenceRecord } = evaluateConditions(conditions, options);
270051
+ if (!result) {
270052
+ return;
270053
+ }
270054
+ return group.evaluateRules(rules, {
270055
+ ...options,
270056
+ referenceRecord: { ...options.referenceRecord, ...referenceRecord }
270057
+ });
270058
+ };
270059
+ var group = {
270060
+ evaluateRules,
270061
+ evaluateTreeRule
270062
+ };
268735
270063
  var resolveEndpoint3 = (ruleSetObject, options) => {
268736
270064
  const { endpointParams, logger: logger2 } = options;
268737
270065
  const { parameters, rules } = ruleSetObject;
@@ -271254,8 +272582,8 @@ var init_SmithyRpcV2CborProtocol = __esm({
271254
272582
  } catch (e3) {
271255
272583
  }
271256
272584
  }
271257
- const { service, operation } = (0, import_util_middleware5.getSmithyContext)(context3);
271258
- const path7 = `/service/${service}/operation/${operation}`;
272585
+ const { service, operation: operation2 } = (0, import_util_middleware5.getSmithyContext)(context3);
272586
+ const path7 = `/service/${service}/operation/${operation2}`;
271259
272587
  if (request.path.endsWith("/")) {
271260
272588
  request.path += path7.slice(1);
271261
272589
  } else {
@@ -271960,10 +273288,10 @@ var require_dist_cjs27 = __commonJS({
271960
273288
  this._middlewareFn = middlewareSupplier;
271961
273289
  return this;
271962
273290
  }
271963
- s(service, operation, smithyContext = {}) {
273291
+ s(service, operation2, smithyContext = {}) {
271964
273292
  this._smithyContext = {
271965
273293
  service,
271966
- operation,
273294
+ operation: operation2,
271967
273295
  ...smithyContext
271968
273296
  };
271969
273297
  return this;
@@ -271990,9 +273318,9 @@ var require_dist_cjs27 = __commonJS({
271990
273318
  this._deserializer = deserializer;
271991
273319
  return this;
271992
273320
  }
271993
- sc(operation) {
271994
- this._operationSchema = operation;
271995
- this._smithyContext.operationSchema = operation;
273321
+ sc(operation2) {
273322
+ this._operationSchema = operation2;
273323
+ this._smithyContext.operationSchema = operation2;
271996
273324
  return this;
271997
273325
  }
271998
273326
  build() {
@@ -272844,7 +274172,7 @@ var init_AwsJsonRpcProtocol = __esm({
272844
274172
  }
272845
274173
  Object.assign(request.headers, {
272846
274174
  "content-type": `application/x-amz-json-${this.getJsonRpcVersion()}`,
272847
- "x-amz-target": `${this.serviceTarget}.${NormalizedSchema.of(operationSchema).getName()}`
274175
+ "x-amz-target": `${this.serviceTarget}.${operationSchema.name}`
272848
274176
  });
272849
274177
  if (this.awsQueryCompatible) {
272850
274178
  request.headers["x-amzn-query-mode"] = "true";
@@ -275309,7 +276637,7 @@ var require_uint32ArrayFrom = __commonJS({
275309
276637
  });
275310
276638
 
275311
276639
  // node_modules/@aws-crypto/util/build/main/index.js
275312
- var require_main = __commonJS({
276640
+ var require_main2 = __commonJS({
275313
276641
  "node_modules/@aws-crypto/util/build/main/index.js"(exports2) {
275314
276642
  "use strict";
275315
276643
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -275340,8 +276668,8 @@ var require_aws_crc32 = __commonJS({
275340
276668
  Object.defineProperty(exports2, "__esModule", { value: true });
275341
276669
  exports2.AwsCrc32 = void 0;
275342
276670
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
275343
- var util_1 = require_main();
275344
- var index_1 = require_main2();
276671
+ var util_1 = require_main2();
276672
+ var index_1 = require_main3();
275345
276673
  var AwsCrc32 = (
275346
276674
  /** @class */
275347
276675
  (function() {
@@ -275371,13 +276699,13 @@ var require_aws_crc32 = __commonJS({
275371
276699
  });
275372
276700
 
275373
276701
  // node_modules/@aws-crypto/crc32/build/main/index.js
275374
- var require_main2 = __commonJS({
276702
+ var require_main3 = __commonJS({
275375
276703
  "node_modules/@aws-crypto/crc32/build/main/index.js"(exports2) {
275376
276704
  "use strict";
275377
276705
  Object.defineProperty(exports2, "__esModule", { value: true });
275378
276706
  exports2.AwsCrc32 = exports2.Crc32 = exports2.crc32 = void 0;
275379
276707
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
275380
- var util_1 = require_main();
276708
+ var util_1 = require_main2();
275381
276709
  function crc32(data2) {
275382
276710
  return new Crc32().update(data2).digest();
275383
276711
  }
@@ -275683,7 +277011,7 @@ var require_main2 = __commonJS({
275683
277011
  var require_dist_cjs33 = __commonJS({
275684
277012
  "node_modules/@smithy/eventstream-codec/dist-cjs/index.js"(exports2) {
275685
277013
  "use strict";
275686
- var crc32 = require_main2();
277014
+ var crc32 = require_main3();
275687
277015
  var utilHexEncoding = require_dist_cjs17();
275688
277016
  var Int64 = class _Int64 {
275689
277017
  bytes;
@@ -276967,6 +278295,7 @@ var require_dist_cjs42 = __commonJS({
276967
278295
  var ENV_PROFILE = "AWS_PROFILE";
276968
278296
  var DEFAULT_PROFILE = "default";
276969
278297
  var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
278298
+ var CONFIG_PREFIX_SEPARATOR = ".";
276970
278299
  var getConfigData = (data2) => Object.entries(data2).filter(([key]) => {
276971
278300
  const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
276972
278301
  if (indexOfSeparator === -1) {
@@ -277033,7 +278362,6 @@ var require_dist_cjs42 = __commonJS({
277033
278362
  return map4;
277034
278363
  };
277035
278364
  var swallowError$1 = () => ({});
277036
- var CONFIG_PREFIX_SEPARATOR = ".";
277037
278365
  var loadSharedConfigFiles = async (init = {}) => {
277038
278366
  const { filepath = getCredentialsFilepath(), configFilepath = getConfigFilepath() } = init;
277039
278367
  const homeDir = getHomeDir.getHomeDir();
@@ -278233,12 +279561,12 @@ var require_httpAuthSchemeProvider = __commonJS({
278233
279561
  });
278234
279562
 
278235
279563
  // node_modules/@aws-sdk/client-bedrock-runtime/package.json
278236
- var require_package = __commonJS({
279564
+ var require_package2 = __commonJS({
278237
279565
  "node_modules/@aws-sdk/client-bedrock-runtime/package.json"(exports2, module2) {
278238
279566
  module2.exports = {
278239
279567
  name: "@aws-sdk/client-bedrock-runtime",
278240
279568
  description: "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native",
278241
- version: "3.910.0",
279569
+ version: "3.913.0",
278242
279570
  scripts: {
278243
279571
  build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
278244
279572
  "build:cjs": "node ../../scripts/compilation/inline client-bedrock-runtime",
@@ -278257,21 +279585,21 @@ var require_package = __commonJS({
278257
279585
  dependencies: {
278258
279586
  "@aws-crypto/sha256-browser": "5.2.0",
278259
279587
  "@aws-crypto/sha256-js": "5.2.0",
278260
- "@aws-sdk/core": "3.910.0",
278261
- "@aws-sdk/credential-provider-node": "3.910.0",
279588
+ "@aws-sdk/core": "3.911.0",
279589
+ "@aws-sdk/credential-provider-node": "3.913.0",
278262
279590
  "@aws-sdk/eventstream-handler-node": "3.910.0",
278263
279591
  "@aws-sdk/middleware-eventstream": "3.910.0",
278264
279592
  "@aws-sdk/middleware-host-header": "3.910.0",
278265
279593
  "@aws-sdk/middleware-logger": "3.910.0",
278266
279594
  "@aws-sdk/middleware-recursion-detection": "3.910.0",
278267
- "@aws-sdk/middleware-user-agent": "3.910.0",
279595
+ "@aws-sdk/middleware-user-agent": "3.911.0",
278268
279596
  "@aws-sdk/middleware-websocket": "3.910.0",
278269
279597
  "@aws-sdk/region-config-resolver": "3.910.0",
278270
- "@aws-sdk/token-providers": "3.910.0",
279598
+ "@aws-sdk/token-providers": "3.911.0",
278271
279599
  "@aws-sdk/types": "3.910.0",
278272
279600
  "@aws-sdk/util-endpoints": "3.910.0",
278273
279601
  "@aws-sdk/util-user-agent-browser": "3.910.0",
278274
- "@aws-sdk/util-user-agent-node": "3.910.0",
279602
+ "@aws-sdk/util-user-agent-node": "3.911.0",
278275
279603
  "@smithy/config-resolver": "^4.3.2",
278276
279604
  "@smithy/core": "^3.16.1",
278277
279605
  "@smithy/eventstream-serde-browser": "^4.2.2",
@@ -279019,7 +280347,7 @@ var init_package = __esm({
279019
280347
  "node_modules/@aws-sdk/nested-clients/package.json"() {
279020
280348
  package_default = {
279021
280349
  name: "@aws-sdk/nested-clients",
279022
- version: "3.910.0",
280350
+ version: "3.911.0",
279023
280351
  description: "Nested clients for AWS SDK packages.",
279024
280352
  main: "./dist-cjs/index.js",
279025
280353
  module: "./dist-es/index.js",
@@ -279048,16 +280376,16 @@ var init_package = __esm({
279048
280376
  dependencies: {
279049
280377
  "@aws-crypto/sha256-browser": "5.2.0",
279050
280378
  "@aws-crypto/sha256-js": "5.2.0",
279051
- "@aws-sdk/core": "3.910.0",
280379
+ "@aws-sdk/core": "3.911.0",
279052
280380
  "@aws-sdk/middleware-host-header": "3.910.0",
279053
280381
  "@aws-sdk/middleware-logger": "3.910.0",
279054
280382
  "@aws-sdk/middleware-recursion-detection": "3.910.0",
279055
- "@aws-sdk/middleware-user-agent": "3.910.0",
280383
+ "@aws-sdk/middleware-user-agent": "3.911.0",
279056
280384
  "@aws-sdk/region-config-resolver": "3.910.0",
279057
280385
  "@aws-sdk/types": "3.910.0",
279058
280386
  "@aws-sdk/util-endpoints": "3.910.0",
279059
280387
  "@aws-sdk/util-user-agent-browser": "3.910.0",
279060
- "@aws-sdk/util-user-agent-node": "3.910.0",
280388
+ "@aws-sdk/util-user-agent-node": "3.911.0",
279061
280389
  "@smithy/config-resolver": "^4.3.2",
279062
280390
  "@smithy/core": "^3.16.1",
279063
280391
  "@smithy/fetch-http-handler": "^5.3.3",
@@ -280467,12 +281795,12 @@ var require_httpAuthSchemeProvider2 = __commonJS({
280467
281795
  });
280468
281796
 
280469
281797
  // node_modules/@aws-sdk/client-sso/package.json
280470
- var require_package2 = __commonJS({
281798
+ var require_package3 = __commonJS({
280471
281799
  "node_modules/@aws-sdk/client-sso/package.json"(exports2, module2) {
280472
281800
  module2.exports = {
280473
281801
  name: "@aws-sdk/client-sso",
280474
281802
  description: "AWS SDK for JavaScript Sso Client for Node.js, Browser and React Native",
280475
- version: "3.910.0",
281803
+ version: "3.911.0",
280476
281804
  scripts: {
280477
281805
  build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
280478
281806
  "build:cjs": "node ../../scripts/compilation/inline client-sso",
@@ -280491,16 +281819,16 @@ var require_package2 = __commonJS({
280491
281819
  dependencies: {
280492
281820
  "@aws-crypto/sha256-browser": "5.2.0",
280493
281821
  "@aws-crypto/sha256-js": "5.2.0",
280494
- "@aws-sdk/core": "3.910.0",
281822
+ "@aws-sdk/core": "3.911.0",
280495
281823
  "@aws-sdk/middleware-host-header": "3.910.0",
280496
281824
  "@aws-sdk/middleware-logger": "3.910.0",
280497
281825
  "@aws-sdk/middleware-recursion-detection": "3.910.0",
280498
- "@aws-sdk/middleware-user-agent": "3.910.0",
281826
+ "@aws-sdk/middleware-user-agent": "3.911.0",
280499
281827
  "@aws-sdk/region-config-resolver": "3.910.0",
280500
281828
  "@aws-sdk/types": "3.910.0",
280501
281829
  "@aws-sdk/util-endpoints": "3.910.0",
280502
281830
  "@aws-sdk/util-user-agent-browser": "3.910.0",
280503
- "@aws-sdk/util-user-agent-node": "3.910.0",
281831
+ "@aws-sdk/util-user-agent-node": "3.911.0",
280504
281832
  "@smithy/config-resolver": "^4.3.2",
280505
281833
  "@smithy/core": "^3.16.1",
280506
281834
  "@smithy/fetch-http-handler": "^5.3.3",
@@ -280682,7 +282010,7 @@ var require_runtimeConfig = __commonJS({
280682
282010
  Object.defineProperty(exports2, "__esModule", { value: true });
280683
282011
  exports2.getRuntimeConfig = void 0;
280684
282012
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
280685
- var package_json_1 = tslib_1.__importDefault(require_package2());
282013
+ var package_json_1 = tslib_1.__importDefault(require_package3());
280686
282014
  var core_1 = (init_dist_es2(), __toCommonJS(dist_es_exports2));
280687
282015
  var util_user_agent_node_1 = require_dist_cjs51();
280688
282016
  var config_resolver_1 = require_dist_cjs39();
@@ -282916,7 +284244,7 @@ var require_dist_cjs61 = __commonJS({
282916
284244
  }
282917
284245
  return withProviderProfile;
282918
284246
  };
282919
- var resolveAssumeRoleCredentials = async (profileName, profiles, options, visitedProfiles = {}) => {
284247
+ var resolveAssumeRoleCredentials = async (profileName, profiles, options, visitedProfiles = {}, resolveProfileData2) => {
282920
284248
  options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
282921
284249
  const profileData = profiles[profileName];
282922
284250
  const { source_profile, region } = profileData;
@@ -282935,7 +284263,7 @@ var require_dist_cjs61 = __commonJS({
282935
284263
  throw new propertyProvider.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${sharedIniFileLoader.getProfileName(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "), { logger: options.logger });
282936
284264
  }
282937
284265
  options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
282938
- const sourceCredsProvider = source_profile ? resolveProfileData(source_profile, profiles, options, {
284266
+ const sourceCredsProvider = source_profile ? resolveProfileData2(source_profile, profiles, options, {
282939
284267
  ...visitedProfiles,
282940
284268
  [source_profile]: true
282941
284269
  }, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {})) : (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
@@ -283011,7 +284339,7 @@ var require_dist_cjs61 = __commonJS({
283011
284339
  return resolveStaticCredentials(data2, options);
283012
284340
  }
283013
284341
  if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data2, { profile: profileName, logger: options.logger })) {
283014
- return resolveAssumeRoleCredentials(profileName, profiles, options, visitedProfiles);
284342
+ return resolveAssumeRoleCredentials(profileName, profiles, options, visitedProfiles, resolveProfileData);
283015
284343
  }
283016
284344
  if (isStaticCredsProfile(data2)) {
283017
284345
  return resolveStaticCredentials(data2, options);
@@ -283403,7 +284731,7 @@ var require_runtimeConfig2 = __commonJS({
283403
284731
  Object.defineProperty(exports2, "__esModule", { value: true });
283404
284732
  exports2.getRuntimeConfig = void 0;
283405
284733
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
283406
- var package_json_1 = tslib_1.__importDefault(require_package());
284734
+ var package_json_1 = tslib_1.__importDefault(require_package2());
283407
284735
  var core_1 = (init_dist_es2(), __toCommonJS(dist_es_exports2));
283408
284736
  var credential_provider_node_1 = require_dist_cjs62();
283409
284737
  var eventstream_handler_node_1 = require_dist_cjs63();
@@ -307897,8 +309225,8 @@ var init_parser2 = __esm({
307897
309225
  { ALT: () => this.CONSUME(Identifier) },
307898
309226
  { ALT: () => this.CONSUME(Text) },
307899
309227
  { ALT: () => this.CONSUME(NumberLiteral) },
307900
- { ALT: () => this.CONSUME(RoundOpen) },
307901
- { ALT: () => this.CONSUME(RoundClose) },
309228
+ // Note: RoundOpen and RoundClose (parentheses) are NOT allowed in unquoted labels
309229
+ // to match Mermaid's behavior - use quoted labels like ["text (with parens)"] instead
307902
309230
  // Allow HTML-like tags (e.g., <br/>) inside labels
307903
309231
  { ALT: () => this.CONSUME(AngleLess) },
307904
309232
  { ALT: () => this.CONSUME(AngleOpen) },
@@ -307987,7 +309315,17 @@ var init_parser2 = __esm({
307987
309315
  this.OR([
307988
309316
  { ALT: () => this.CONSUME(Identifier) },
307989
309317
  { ALT: () => this.CONSUME(Text) },
307990
- { ALT: () => this.CONSUME(NumberLiteral) }
309318
+ { ALT: () => this.CONSUME(NumberLiteral) },
309319
+ // Allow HTML-like angle brackets and slashes for <br/>, <i>, etc.
309320
+ { ALT: () => this.CONSUME(AngleLess) },
309321
+ { ALT: () => this.CONSUME(AngleOpen) },
309322
+ { ALT: () => this.CONSUME(ForwardSlash) },
309323
+ { ALT: () => this.CONSUME(Backslash) },
309324
+ // Allow common punctuation seen in labels
309325
+ { ALT: () => this.CONSUME(Comma) },
309326
+ { ALT: () => this.CONSUME(Colon) },
309327
+ { ALT: () => this.CONSUME(Ampersand) },
309328
+ { ALT: () => this.CONSUME(Semicolon) }
307991
309329
  ]);
307992
309330
  });
307993
309331
  });
@@ -308599,7 +309937,7 @@ var init_semantics = __esm({
308599
309937
  this.ctx.errors.push({
308600
309938
  line: q3.startLine ?? 1,
308601
309939
  column: col,
308602
- severity: "warning",
309940
+ severity: "error",
308603
309941
  code: "FL-LABEL-CURLY-IN-QUOTED",
308604
309942
  message: "Curly braces inside quoted label text may be parsed as a shape by Mermaid. Replace { and } with HTML entities.",
308605
309943
  hint: 'Use &#123; and &#125; for { and } inside quoted text, e.g., "tyk-trace-&#123;id&#125;".',
@@ -308729,6 +310067,8 @@ var init_semantics = __esm({
308729
310067
  this.ctx.errors.push({
308730
310068
  line: tk.startLine ?? 1,
308731
310069
  column: col,
310070
+ // Treat backticks in quoted labels as errors (CLI rejects in many cases);
310071
+ // outside quotes, surface as a warning.
308732
310072
  severity: inQuoted ? "error" : "warning",
308733
310073
  code: "FL-LABEL-BACKTICK",
308734
310074
  message: "Backticks (`\u2026`) inside node labels are not supported by Mermaid.",
@@ -310013,7 +311353,7 @@ function validateFlowchart(text, options = {}) {
310013
311353
  code: "FL-LABEL-ESCAPED-QUOTE",
310014
311354
  message: 'Escaped quotes (\\") in node labels are accepted by Mermaid, but using &quot; is preferred for portability.',
310015
311355
  hint: 'Prefer &quot; inside quoted labels, e.g., A["He said &quot;Hi&quot;"]'
310016
- }).map((e3) => ({ ...e3, severity: "warning" }));
311356
+ }).map((e3) => ({ ...e3, severity: "error" }));
310017
311357
  const seenDoubleLines = new Set(prevErrors.filter((e3) => e3.code === "FL-LABEL-DOUBLE-IN-DOUBLE").map((e3) => e3.line));
310018
311358
  const escapedLinesAll = new Set(detectEscapedQuotes(tokens, { code: "x" }).map((e3) => e3.line));
310019
311359
  const dbl = detectDoubleInDouble(tokens, {
@@ -312292,11 +313632,85 @@ function computeFixes(text, errors, level = "safe") {
312292
313632
  const patchedLines = /* @__PURE__ */ new Set();
312293
313633
  const seen = /* @__PURE__ */ new Set();
312294
313634
  const piQuoteClosedLines = /* @__PURE__ */ new Set();
313635
+ function sanitizeAllQuotedSegmentsInShapes(lineText, lineNo) {
313636
+ const shapes = [
313637
+ { open: "[[", close: "]]" },
313638
+ { open: "((", close: "))" },
313639
+ { open: "{{", close: "}}" },
313640
+ { open: "[(", close: ")]" },
313641
+ { open: "([", close: "])" },
313642
+ { open: "{", close: "}" },
313643
+ { open: "[", close: "]" },
313644
+ { open: "(", close: ")" }
313645
+ ];
313646
+ let idx = 0;
313647
+ let produced = 0;
313648
+ while (idx < lineText.length) {
313649
+ let found = null;
313650
+ for (const s3 of shapes) {
313651
+ const i3 = lineText.indexOf(s3.open, idx);
313652
+ if (i3 !== -1 && (found === null || i3 < found.i))
313653
+ found = { ...s3, i: i3 };
313654
+ }
313655
+ if (!found)
313656
+ break;
313657
+ const contentStart = found.i + found.open.length;
313658
+ const closeIdx = lineText.indexOf(found.close, contentStart);
313659
+ if (closeIdx === -1) {
313660
+ idx = contentStart;
313661
+ continue;
313662
+ }
313663
+ let q1 = -1;
313664
+ for (let i3 = contentStart; i3 < closeIdx; i3++) {
313665
+ if (lineText[i3] === '"' && lineText[i3 - 1] !== "\\") {
313666
+ q1 = i3;
313667
+ break;
313668
+ }
313669
+ }
313670
+ if (q1 !== -1) {
313671
+ let q22 = -1;
313672
+ for (let j3 = closeIdx - 1; j3 > q1; j3--) {
313673
+ if (lineText[j3] === '"' && lineText[j3 - 1] !== "\\") {
313674
+ q22 = j3;
313675
+ break;
313676
+ }
313677
+ }
313678
+ if (q22 !== -1) {
313679
+ const inner = lineText.slice(q1 + 1, q22);
313680
+ const replaced = sanitizeQuotedInner(inner);
313681
+ if (replaced !== inner) {
313682
+ edits.push({ start: { line: lineNo, column: q1 + 2 }, end: { line: lineNo, column: q22 + 1 }, newText: replaced });
313683
+ produced++;
313684
+ }
313685
+ }
313686
+ }
313687
+ idx = closeIdx + found.close.length;
313688
+ }
313689
+ return produced;
313690
+ }
313691
+ function sanitizeQuotedInner(inner) {
313692
+ const SENT_Q = "\0__Q__";
313693
+ let out = inner.split("&quot;").join(SENT_Q);
313694
+ out = out.replace(/`/g, "");
313695
+ out = out.replace(/\\\"/g, "&quot;");
313696
+ out = out.replace(/\"/g, "&quot;");
313697
+ out = out.replace(/"/g, "&quot;");
313698
+ out = out.split(SENT_Q).join("&quot;");
313699
+ return out;
313700
+ }
312295
313701
  for (const e3 of errors) {
312296
313702
  const key = `${e3.code}@${e3.line}:${e3.column}:${e3.length ?? 1}`;
312297
313703
  if (seen.has(key))
312298
313704
  continue;
312299
313705
  seen.add(key);
313706
+ if ((e3.code === "FL-LABEL-ESCAPED-QUOTE" || e3.code === "FL-LABEL-CURLY-IN-QUOTED" || e3.code === "FL-LABEL-DOUBLE-IN-DOUBLE" || e3.code === "FL-LABEL-BACKTICK") && !patchedLines.has(e3.line)) {
313707
+ const lineText = lineTextAt(text, e3.line);
313708
+ const produced = sanitizeAllQuotedSegmentsInShapes(lineText, e3.line);
313709
+ patchedLines.add(e3.line);
313710
+ if (produced > 0) {
313711
+ continue;
313712
+ }
313713
+ }
312300
313714
  if (is("FL-ARROW-INVALID", e3)) {
312301
313715
  edits.push(replaceRange(text, at(e3), e3.length ?? 2, "-->"));
312302
313716
  continue;
@@ -312401,6 +313815,8 @@ function computeFixes(text, errors, level = "safe") {
312401
313815
  continue;
312402
313816
  }
312403
313817
  if (is("FL-LABEL-ESCAPED-QUOTE", e3)) {
313818
+ if (patchedLines.has(e3.line))
313819
+ continue;
312404
313820
  const lineText = lineTextAt(text, e3.line);
312405
313821
  const caret0 = Math.max(0, e3.column - 1);
312406
313822
  const opens = [
@@ -312423,17 +313839,10 @@ function computeFixes(text, errors, level = "safe") {
312423
313839
  const q22 = lineText.lastIndexOf('"', closeIdx - 1);
312424
313840
  if (q1 !== -1 && q22 !== -1 && q22 > q1) {
312425
313841
  const inner = lineText.slice(q1 + 1, q22);
312426
- if (inner.includes('\\"')) {
312427
- const replaced = inner.split('\\"').join("&quot;");
313842
+ const replaced = sanitizeQuotedInner(inner);
313843
+ if (replaced !== inner) {
312428
313844
  edits.push({ start: { line: e3.line, column: q1 + 2 }, end: { line: e3.line, column: q22 + 1 }, newText: replaced });
312429
313845
  continue;
312430
- if (is("FL-META-UNSUPPORTED", e3)) {
312431
- if (level === "all") {
312432
- const lineText2 = lineTextAt(text, e3.line);
312433
- edits.push({ start: { line: e3.line, column: 1 }, end: { line: e3.line + 1, column: 1 }, newText: "" });
312434
- }
312435
- continue;
312436
- }
312437
313846
  }
312438
313847
  }
312439
313848
  }
@@ -312443,11 +313852,12 @@ function computeFixes(text, errors, level = "safe") {
312443
313852
  }
312444
313853
  if (is("FL-META-UNSUPPORTED", e3)) {
312445
313854
  if (level === "all") {
313855
+ const lineText = lineTextAt(text, e3.line);
312446
313856
  edits.push({ start: { line: e3.line, column: 1 }, end: { line: e3.line + 1, column: 1 }, newText: "" });
312447
313857
  }
312448
313858
  continue;
312449
313859
  }
312450
- if (is("FL-LABEL-BACKTICK", e3)) {
313860
+ if (is("FL-LABEL-BACKTICK", e3) && e3.severity === "warning") {
312451
313861
  edits.push(replaceRange(text, at(e3), e3.length ?? 1, ""));
312452
313862
  continue;
312453
313863
  }
@@ -312457,13 +313867,13 @@ function computeFixes(text, errors, level = "safe") {
312457
313867
  let qOpenIdx = -1;
312458
313868
  let qChar = null;
312459
313869
  for (let i3 = caret0; i3 >= 0; i3--) {
312460
- const ch2 = lineText[i3];
312461
- const code = ch2 ? ch2.charCodeAt(0) : -1;
313870
+ const ch = lineText[i3];
313871
+ const code = ch ? ch.charCodeAt(0) : -1;
312462
313872
  if (code === 34 || code === 39) {
312463
313873
  const bs = i3 > 0 && lineText[i3 - 1] === "\\";
312464
313874
  if (!bs) {
312465
313875
  qOpenIdx = i3;
312466
- qChar = ch2;
313876
+ qChar = ch;
312467
313877
  break;
312468
313878
  }
312469
313879
  }
@@ -312471,8 +313881,8 @@ function computeFixes(text, errors, level = "safe") {
312471
313881
  if (qOpenIdx !== -1 && qChar) {
312472
313882
  let qCloseIdx = -1;
312473
313883
  for (let j3 = qOpenIdx + 1; j3 < lineText.length; j3++) {
312474
- const ch2 = lineText[j3];
312475
- const code = ch2 ? ch2.charCodeAt(0) : -1;
313884
+ const ch = lineText[j3];
313885
+ const code = ch ? ch.charCodeAt(0) : -1;
312476
313886
  if (code === (qChar ? qChar.charCodeAt(0) : -1)) {
312477
313887
  const bs = lineText[j3 - 1] === "\\";
312478
313888
  if (!bs) {
@@ -312483,17 +313893,13 @@ function computeFixes(text, errors, level = "safe") {
312483
313893
  }
312484
313894
  if (qCloseIdx > qOpenIdx) {
312485
313895
  const inner = lineText.slice(qOpenIdx + 1, qCloseIdx);
312486
- const replaced = inner.replace(/\{/g, "&#123;").replace(/\}/g, "&#125;");
313896
+ const replaced = sanitizeQuotedInner(inner);
312487
313897
  if (replaced !== inner) {
312488
313898
  edits.push({ start: { line: e3.line, column: qOpenIdx + 2 }, end: { line: e3.line, column: qCloseIdx + 1 }, newText: replaced });
312489
313899
  continue;
312490
313900
  }
312491
313901
  }
312492
313902
  }
312493
- const ch = lineText[caret0] || "";
312494
- const rep = ch === "{" ? "&#123;" : ch === "}" ? "&#125;" : ch;
312495
- if (rep !== ch)
312496
- edits.push(replaceRange(text, at(e3), e3.length ?? 1, rep));
312497
313903
  continue;
312498
313904
  }
312499
313905
  if (is("FL-END-WITHOUT-SUBGRAPH", e3)) {
@@ -312505,6 +313911,11 @@ function computeFixes(text, errors, level = "safe") {
312505
313911
  if (is("FL-LABEL-DOUBLE-IN-DOUBLE", e3)) {
312506
313912
  const lineText = lineTextAt(text, e3.line);
312507
313913
  const caret0 = Math.max(0, e3.column - 1);
313914
+ const rawDqCount = (lineText.match(/\"/g) || []).length;
313915
+ const unescapedDqCount = (lineText.replace(/\\\"/g, "").match(/\"/g) || []).length;
313916
+ if (rawDqCount + unescapedDqCount > 8 && level !== "all") {
313917
+ continue;
313918
+ }
312508
313919
  const opens = [
312509
313920
  { tok: "[[", idx: lineText.lastIndexOf("[[", caret0) },
312510
313921
  { tok: "((", idx: lineText.lastIndexOf("((", caret0) },
@@ -312528,7 +313939,7 @@ function computeFixes(text, errors, level = "safe") {
312528
313939
  const q22 = lineText.lastIndexOf('"', closeIdx - 1);
312529
313940
  if (q1 !== -1 && q22 !== -1 && q22 > q1) {
312530
313941
  const inner = lineText.slice(q1 + 1, q22);
312531
- const replaced = inner.split("&quot;").join("\0").split('"').join("&quot;").split("\0").join("&quot;");
313942
+ const replaced = sanitizeQuotedInner(inner);
312532
313943
  if (replaced !== inner) {
312533
313944
  const start = { line: e3.line, column: q1 + 2 };
312534
313945
  const end = { line: e3.line, column: q22 + 1 };
@@ -312890,6 +314301,10 @@ function computeFixes(text, errors, level = "safe") {
312890
314301
  if (level === "safe" || level === "all") {
312891
314302
  const lineText = lineTextAt(text, e3.line);
312892
314303
  const caret0 = Math.max(0, e3.column - 1);
314304
+ const dq = (lineText.replace(/\\\"/g, "").match(/\"/g) || []).length;
314305
+ if (lineText.length > 600 || dq > 8) {
314306
+ continue;
314307
+ }
312893
314308
  const openPairs = [
312894
314309
  { open: "[[", close: "]]", idx: lineText.lastIndexOf("[[", caret0), delta: 2 },
312895
314310
  { open: "((", close: "))", idx: lineText.lastIndexOf("((", caret0), delta: 2 },
@@ -312940,6 +314355,24 @@ function computeFixes(text, errors, level = "safe") {
312940
314355
  { open: "[", close: "]" },
312941
314356
  { open: "(", close: ")" }
312942
314357
  ];
314358
+ const findMatchingCloser = (text2, openIdx, opener, closer) => {
314359
+ let pos = openIdx + opener.length;
314360
+ let depth = 1;
314361
+ while (pos < text2.length && depth > 0) {
314362
+ if (text2.slice(pos, pos + opener.length) === opener) {
314363
+ depth++;
314364
+ pos += opener.length;
314365
+ } else if (text2.slice(pos, pos + closer.length) === closer) {
314366
+ depth--;
314367
+ if (depth === 0)
314368
+ return pos;
314369
+ pos += closer.length;
314370
+ } else {
314371
+ pos++;
314372
+ }
314373
+ }
314374
+ return -1;
314375
+ };
312943
314376
  for (const shape of shapes) {
312944
314377
  let searchStart = 0;
312945
314378
  while (true) {
@@ -312947,7 +314380,7 @@ function computeFixes(text, errors, level = "safe") {
312947
314380
  if (openIdx === -1)
312948
314381
  break;
312949
314382
  const contentStart = openIdx + shape.open.length;
312950
- const closeIdx = lineText.indexOf(shape.close, contentStart);
314383
+ const closeIdx = shape.open === "(" && shape.close === ")" ? findMatchingCloser(lineText, openIdx, shape.open, shape.close) : lineText.indexOf(shape.close, contentStart);
312951
314384
  if (closeIdx === -1)
312952
314385
  break;
312953
314386
  if (openIdx <= caret0 && caret0 < closeIdx) {
@@ -312965,10 +314398,11 @@ function computeFixes(text, errors, level = "safe") {
312965
314398
  const left = core.slice(0, 1);
312966
314399
  const right = core.slice(-1);
312967
314400
  const isSlashPair = (l3, r3) => l3 === "/" && r3 === "/" || l3 === "\\" && r3 === "\\" || l3 === "/" && r3 === "\\" || l3 === "\\" && r3 === "/";
312968
- if (core.length >= 2 && isSlashPair(left, right)) {
312969
- break;
314401
+ const isParallelogramShape = core.length >= 2 && isSlashPair(left, right);
314402
+ let replaced = inner.replace(/\(/g, "&#40;").replace(/\)/g, "&#41;");
314403
+ if (isParallelogramShape) {
314404
+ replaced = replaced.replace(/"/g, "&quot;");
312970
314405
  }
312971
- const replaced = inner.replace(/\(/g, "&#40;").replace(/\)/g, "&#41;");
312972
314406
  if (replaced !== inner) {
312973
314407
  edits.push({ start: { line: e3.line, column: contentStart + 1 }, end: { line: e3.line, column: closeIdx + 1 }, newText: replaced });
312974
314408
  patchedLines.add(e3.line);
@@ -323088,7 +324522,7 @@ ${baseGroup}
323088
324522
  return out;
323089
324523
  }
323090
324524
  htmlDecode(s3) {
323091
- return s3.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&#39;/g, "'");
324525
+ return s3.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&#96;/g, "`").replace(/&#123;/g, "{").replace(/&#125;/g, "}").replace(/&#40;/g, "(").replace(/&#41;/g, ")");
323092
324526
  }
323093
324527
  generateEdge(edge, padX, padY, nodeMap) {
323094
324528
  if (!edge.points || edge.points.length < 2) {
@@ -327797,10 +329231,11 @@ var ProbeAgent_exports = {};
327797
329231
  __export(ProbeAgent_exports, {
327798
329232
  ProbeAgent: () => ProbeAgent
327799
329233
  });
327800
- var import_anthropic, import_openai, import_google, import_ai3, import_crypto5, import_events2, import_fs7, import_promises2, import_path9, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, SUPPORTED_IMAGE_EXTENSIONS, MAX_IMAGE_FILE_SIZE, ProbeAgent;
329234
+ var import_dotenv, import_anthropic, import_openai, import_google, import_ai3, import_crypto5, import_events2, import_fs7, import_promises2, import_path9, MAX_TOOL_ITERATIONS, MAX_HISTORY_MESSAGES, SUPPORTED_IMAGE_EXTENSIONS, MAX_IMAGE_FILE_SIZE, ProbeAgent;
327801
329235
  var init_ProbeAgent = __esm({
327802
329236
  "src/agent/ProbeAgent.js"() {
327803
329237
  "use strict";
329238
+ import_dotenv = __toESM(require_main(), 1);
327804
329239
  import_anthropic = __nccwpck_require__(93201);
327805
329240
  import_openai = __nccwpck_require__(87635);
327806
329241
  import_google = __nccwpck_require__(30260);
@@ -327822,6 +329257,7 @@ var init_ProbeAgent = __esm({
327822
329257
  init_schemaUtils();
327823
329258
  init_xmlParsingUtils();
327824
329259
  init_mcp();
329260
+ import_dotenv.default.config();
327825
329261
  MAX_TOOL_ITERATIONS = parseInt(process.env.MAX_TOOL_ITERATIONS || "30", 10);
327826
329262
  MAX_HISTORY_MESSAGES = 100;
327827
329263
  SUPPORTED_IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "gif", "bmp", "svg"];
@@ -330670,8 +332106,10 @@ __export(index_exports, {
330670
332106
  tools: () => tools_exports
330671
332107
  });
330672
332108
  module.exports = __toCommonJS(index_exports);
332109
+ var import_dotenv2;
330673
332110
  var init_index = __esm({
330674
332111
  "src/index.js"() {
332112
+ import_dotenv2 = __toESM(require_main(), 1);
330675
332113
  init_search();
330676
332114
  init_query();
330677
332115
  init_extract();
@@ -330691,6 +332129,7 @@ var init_index = __esm({
330691
332129
  init_probeTool();
330692
332130
  init_storage();
330693
332131
  init_hooks();
332132
+ import_dotenv2.default.config();
330694
332133
  }
330695
332134
  });
330696
332135
  init_index();
@@ -360266,6 +361705,14 @@ module.exports = /*#__PURE__*/JSON.parse('{"$schema":"http://json-schema.org/dra
360266
361705
 
360267
361706
  /***/ }),
360268
361707
 
361708
+ /***/ 80056:
361709
+ /***/ ((module) => {
361710
+
361711
+ "use strict";
361712
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"dotenv","version":"17.2.3","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","pretest":"npm run lint && npm run dts-check","test":"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/motdotla/dotenv.git"},"homepage":"https://github.com/motdotla/dotenv#readme","funding":"https://dotenvx.com","keywords":["dotenv","env",".env","environment","variables","config","settings"],"readmeFilename":"README.md","license":"BSD-2-Clause","devDependencies":{"@types/node":"^18.11.3","decache":"^4.6.2","sinon":"^14.0.1","standard":"^17.0.0","standard-version":"^9.5.0","tap":"^19.2.0","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false}}');
361713
+
361714
+ /***/ }),
361715
+
360269
361716
  /***/ 17324:
360270
361717
  /***/ ((module) => {
360271
361718
 
@@ -360334,7 +361781,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"assert":true,"node:assert":[">= 14.1
360334
361781
  /***/ ((module) => {
360335
361782
 
360336
361783
  "use strict";
360337
- module.exports = {"rE":"0.1.94"};
361784
+ module.exports = {"rE":"0.1.96"};
360338
361785
 
360339
361786
  /***/ })
360340
361787