@probelabs/visor 0.1.144 → 0.1.145-ee

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/config.d.ts.map +1 -1
  2. package/dist/docs/architecture.md +28 -0
  3. package/dist/docs/configuration.md +2 -0
  4. package/dist/docs/sandbox-engines.md +357 -0
  5. package/dist/docs/security.md +40 -0
  6. package/dist/generated/config-schema.d.ts +5 -0
  7. package/dist/generated/config-schema.d.ts.map +1 -1
  8. package/dist/generated/config-schema.json +9 -0
  9. package/dist/index.js +2388 -183
  10. package/dist/providers/mcp-check-provider.d.ts.map +1 -1
  11. package/dist/sandbox/bubblewrap-sandbox.d.ts +30 -0
  12. package/dist/sandbox/bubblewrap-sandbox.d.ts.map +1 -0
  13. package/dist/sandbox/index.d.ts +3 -1
  14. package/dist/sandbox/index.d.ts.map +1 -1
  15. package/dist/sandbox/sandbox-manager.d.ts +3 -2
  16. package/dist/sandbox/sandbox-manager.d.ts.map +1 -1
  17. package/dist/sandbox/seatbelt-sandbox.d.ts +36 -0
  18. package/dist/sandbox/seatbelt-sandbox.d.ts.map +1 -0
  19. package/dist/sandbox/types.d.ts +3 -1
  20. package/dist/sandbox/types.d.ts.map +1 -1
  21. package/dist/sdk/{check-provider-registry-VTNNTMWC.mjs → check-provider-registry-HFPKHYTG.mjs} +3 -3
  22. package/dist/sdk/{check-provider-registry-WBEOZCGW.mjs → check-provider-registry-TH25S2OB.mjs} +7 -7
  23. package/dist/sdk/{chunk-D3UC5KUJ.mjs → chunk-3BOOHJI5.mjs} +472 -105
  24. package/dist/sdk/chunk-3BOOHJI5.mjs.map +1 -0
  25. package/dist/sdk/{chunk-PXWWPPNF.mjs → chunk-GZMQPC6D.mjs} +459 -92
  26. package/dist/sdk/chunk-GZMQPC6D.mjs.map +1 -0
  27. package/dist/sdk/{chunk-CLQTOZKH.mjs → chunk-I42ZCVA5.mjs} +3 -3
  28. package/dist/sdk/{chunk-PQWAAGUP.mjs → chunk-L3XPYQ6I.mjs} +2 -2
  29. package/dist/sdk/{chunk-FG6THKK7.mjs → chunk-OM3WYVFI.mjs} +3 -3
  30. package/dist/sdk/chunk-OM3WYVFI.mjs.map +1 -0
  31. package/dist/sdk/{chunk-AKCHIYWU.mjs → chunk-YOKAA4IU.mjs} +96 -63
  32. package/dist/sdk/chunk-YOKAA4IU.mjs.map +1 -0
  33. package/dist/sdk/{config-KOKJ3PYE.mjs → config-AAB2FL22.mjs} +2 -2
  34. package/dist/sdk/{failure-condition-evaluator-LWH3NQ2S.mjs → failure-condition-evaluator-O464EJMD.mjs} +3 -3
  35. package/dist/sdk/{github-frontend-UUASYGNV.mjs → github-frontend-MSX6Q2WL.mjs} +3 -3
  36. package/dist/sdk/{host-LAF3NFPZ.mjs → host-GA76UESS.mjs} +2 -2
  37. package/dist/sdk/knex-store-HPXJILBL.mjs +411 -0
  38. package/dist/sdk/knex-store-HPXJILBL.mjs.map +1 -0
  39. package/dist/sdk/loader-ZC5G3JGJ.mjs +89 -0
  40. package/dist/sdk/loader-ZC5G3JGJ.mjs.map +1 -0
  41. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs +655 -0
  42. package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs.map +1 -0
  43. package/dist/sdk/{routing-LEUV6A4K.mjs → routing-RIHVCEIU.mjs} +4 -4
  44. package/dist/sdk/{schedule-tool-handler-W7IB4MK3.mjs → schedule-tool-handler-BTLEDYAI.mjs} +3 -3
  45. package/dist/sdk/{schedule-tool-handler-EYDCUGOB.mjs → schedule-tool-handler-NYL2ONJB.mjs} +7 -7
  46. package/dist/sdk/sdk.d.mts +3 -1
  47. package/dist/sdk/sdk.d.ts +3 -1
  48. package/dist/sdk/sdk.js +2006 -348
  49. package/dist/sdk/sdk.js.map +1 -1
  50. package/dist/sdk/sdk.mjs +6 -6
  51. package/dist/sdk/{trace-helpers-NNBQNFWZ.mjs → trace-helpers-QQSTZGDT.mjs} +2 -2
  52. package/dist/sdk/validator-XTZJZZJH.mjs +134 -0
  53. package/dist/sdk/validator-XTZJZZJH.mjs.map +1 -0
  54. package/dist/sdk/{workflow-check-provider-WW5U6R2P.mjs → workflow-check-provider-3IIKJFM4.mjs} +3 -3
  55. package/dist/sdk/{workflow-check-provider-FLBIJQ4Z.mjs → workflow-check-provider-LVUUL2PZ.mjs} +7 -7
  56. package/dist/slack/socket-runner.d.ts.map +1 -1
  57. package/dist/utils/workspace-manager.d.ts +9 -0
  58. package/dist/utils/workspace-manager.d.ts.map +1 -1
  59. package/package.json +2 -2
  60. package/dist/output/traces/run-2026-02-25T17-29-59-894Z.ndjson +0 -138
  61. package/dist/output/traces/run-2026-02-25T17-30-47-149Z.ndjson +0 -1442
  62. package/dist/sdk/check-provider-registry-GKLK3I2X.mjs +0 -30
  63. package/dist/sdk/chunk-AKCHIYWU.mjs.map +0 -1
  64. package/dist/sdk/chunk-D3UC5KUJ.mjs.map +0 -1
  65. package/dist/sdk/chunk-FG6THKK7.mjs.map +0 -1
  66. package/dist/sdk/chunk-N7LW3Q5B.mjs +0 -40284
  67. package/dist/sdk/chunk-N7LW3Q5B.mjs.map +0 -1
  68. package/dist/sdk/chunk-PXWWPPNF.mjs.map +0 -1
  69. package/dist/sdk/schedule-tool-handler-7RGTKO24.mjs +0 -40
  70. package/dist/sdk/workflow-check-provider-2G2CEXFR.mjs +0 -30
  71. package/dist/sdk/workflow-check-provider-2G2CEXFR.mjs.map +0 -1
  72. package/dist/sdk/workflow-check-provider-FLBIJQ4Z.mjs.map +0 -1
  73. package/dist/sdk/workflow-check-provider-WW5U6R2P.mjs.map +0 -1
  74. package/dist/traces/run-2026-02-25T17-29-59-894Z.ndjson +0 -138
  75. package/dist/traces/run-2026-02-25T17-30-47-149Z.ndjson +0 -1442
  76. /package/dist/sdk/{check-provider-registry-GKLK3I2X.mjs.map → check-provider-registry-HFPKHYTG.mjs.map} +0 -0
  77. /package/dist/sdk/{check-provider-registry-VTNNTMWC.mjs.map → check-provider-registry-TH25S2OB.mjs.map} +0 -0
  78. /package/dist/sdk/{chunk-CLQTOZKH.mjs.map → chunk-I42ZCVA5.mjs.map} +0 -0
  79. /package/dist/sdk/{chunk-PQWAAGUP.mjs.map → chunk-L3XPYQ6I.mjs.map} +0 -0
  80. /package/dist/sdk/{check-provider-registry-WBEOZCGW.mjs.map → config-AAB2FL22.mjs.map} +0 -0
  81. /package/dist/sdk/{config-KOKJ3PYE.mjs.map → failure-condition-evaluator-O464EJMD.mjs.map} +0 -0
  82. /package/dist/sdk/{github-frontend-UUASYGNV.mjs.map → github-frontend-MSX6Q2WL.mjs.map} +0 -0
  83. /package/dist/sdk/{host-LAF3NFPZ.mjs.map → host-GA76UESS.mjs.map} +0 -0
  84. /package/dist/sdk/{failure-condition-evaluator-LWH3NQ2S.mjs.map → routing-RIHVCEIU.mjs.map} +0 -0
  85. /package/dist/sdk/{routing-LEUV6A4K.mjs.map → schedule-tool-handler-BTLEDYAI.mjs.map} +0 -0
  86. /package/dist/sdk/{schedule-tool-handler-7RGTKO24.mjs.map → schedule-tool-handler-NYL2ONJB.mjs.map} +0 -0
  87. /package/dist/sdk/{schedule-tool-handler-EYDCUGOB.mjs.map → trace-helpers-QQSTZGDT.mjs.map} +0 -0
  88. /package/dist/sdk/{schedule-tool-handler-W7IB4MK3.mjs.map → workflow-check-provider-3IIKJFM4.mjs.map} +0 -0
  89. /package/dist/sdk/{trace-helpers-NNBQNFWZ.mjs.map → workflow-check-provider-LVUUL2PZ.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- process.env.VISOR_VERSION = '0.1.144';
3
- process.env.PROBE_VERSION = '0.6.0-rc259';
4
- process.env.VISOR_COMMIT_SHA = '0f8df6f53e18e9ad94507e1761debabaf533c0df';
5
- process.env.VISOR_COMMIT_SHORT = '0f8df6f';
2
+ process.env.VISOR_VERSION = '0.1.145';
3
+ process.env.PROBE_VERSION = '0.6.0-rc260';
4
+ process.env.VISOR_COMMIT_SHA = '7f399fc32c663ce91b7adbb19c6f29bcd7f41931';
5
+ process.env.VISOR_COMMIT_SHORT = '7f399fc';
6
6
  /******/ (() => { // webpackBootstrap
7
7
  /******/ var __webpack_modules__ = ({
8
8
 
@@ -161190,7 +161190,7 @@ async function handleDumpPolicyInput(checkId, argv) {
161190
161190
  let PolicyInputBuilder;
161191
161191
  try {
161192
161192
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
161193
- const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(71370)));
161193
+ const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(17117)));
161194
161194
  PolicyInputBuilder = mod.PolicyInputBuilder;
161195
161195
  }
161196
161196
  catch {
@@ -164445,99 +164445,131 @@ class ConfigManager {
164445
164445
  message: `Sandbox name '${name}' contains invalid characters. Only letters, numbers, dots, hyphens, underscores allowed.`,
164446
164446
  });
164447
164447
  }
164448
- // Must have exactly one mode
164449
- const modes = [
164450
- config.image ? 'image' : null,
164451
- config.dockerfile || config.dockerfile_inline ? 'dockerfile' : null,
164452
- config.compose ? 'compose' : null,
164453
- ].filter(Boolean);
164454
- if (modes.length === 0) {
164448
+ // Validate engine field if present
164449
+ if (config.engine && !['docker', 'bubblewrap', 'seatbelt'].includes(config.engine)) {
164455
164450
  errors.push({
164456
- field: `sandboxes.${name}`,
164457
- message: `Sandbox '${name}' must specify one of: image, dockerfile, dockerfile_inline, or compose`,
164451
+ field: `sandboxes.${name}.engine`,
164452
+ message: `Sandbox '${name}' has invalid engine '${config.engine}'. Must be 'docker', 'bubblewrap', or 'seatbelt'.`,
164458
164453
  });
164459
164454
  }
164460
- else if (modes.length > 1) {
164461
- errors.push({
164462
- field: `sandboxes.${name}`,
164463
- message: `Sandbox '${name}' has multiple modes (${modes.join(', ')}). Specify exactly one.`,
164464
- });
164465
- }
164466
- // Compose mode requires service
164467
- if (config.compose && !config.service) {
164468
- errors.push({
164469
- field: `sandboxes.${name}.service`,
164470
- message: `Sandbox '${name}' uses compose mode but is missing required 'service' field`,
164471
- });
164472
- }
164473
- // Validate file paths don't contain traversal
164474
- if (config.dockerfile && /\.\./.test(config.dockerfile)) {
164475
- errors.push({
164476
- field: `sandboxes.${name}.dockerfile`,
164477
- message: `Dockerfile path '${config.dockerfile}' in sandbox '${name}' must not contain '..' path traversal`,
164478
- });
164479
- }
164480
- if (config.compose && /\.\./.test(config.compose)) {
164481
- errors.push({
164482
- field: `sandboxes.${name}.compose`,
164483
- message: `Compose file path '${config.compose}' in sandbox '${name}' must not contain '..' path traversal`,
164484
- });
164455
+ const isNativeEngine = config.engine === 'bubblewrap' || config.engine === 'seatbelt';
164456
+ if (isNativeEngine) {
164457
+ // Native engine (bubblewrap/seatbelt): reject Docker-only fields
164458
+ const dockerOnlyFields = [
164459
+ ['image', config.image],
164460
+ ['dockerfile', config.dockerfile],
164461
+ ['dockerfile_inline', config.dockerfile_inline],
164462
+ ['compose', config.compose],
164463
+ ['service', config.service],
164464
+ ['cache', config.cache],
164465
+ ['visor_path', config.visor_path],
164466
+ ['resources', config.resources],
164467
+ ];
164468
+ for (const [field, value] of dockerOnlyFields) {
164469
+ if (value !== undefined) {
164470
+ errors.push({
164471
+ field: `sandboxes.${name}.${field}`,
164472
+ message: `Sandbox '${name}' uses ${config.engine} engine but has Docker-only field '${field}'. Remove it or switch to engine: docker.`,
164473
+ });
164474
+ }
164475
+ }
164485
164476
  }
164486
- // Validate container paths are absolute and safe
164487
- if (config.workdir) {
164488
- if (!config.workdir.startsWith('/')) {
164477
+ else {
164478
+ // Docker engine (default): must have exactly one mode
164479
+ const modes = [
164480
+ config.image ? 'image' : null,
164481
+ config.dockerfile || config.dockerfile_inline ? 'dockerfile' : null,
164482
+ config.compose ? 'compose' : null,
164483
+ ].filter(Boolean);
164484
+ if (modes.length === 0) {
164489
164485
  errors.push({
164490
- field: `sandboxes.${name}.workdir`,
164491
- message: `Workdir '${config.workdir}' in sandbox '${name}' must be an absolute path (start with /)`,
164486
+ field: `sandboxes.${name}`,
164487
+ message: `Sandbox '${name}' must specify one of: image, dockerfile, dockerfile_inline, or compose`,
164492
164488
  });
164493
164489
  }
164494
- if (/\.\./.test(config.workdir)) {
164490
+ else if (modes.length > 1) {
164495
164491
  errors.push({
164496
- field: `sandboxes.${name}.workdir`,
164497
- message: `Workdir '${config.workdir}' in sandbox '${name}' must not contain '..' path traversal`,
164492
+ field: `sandboxes.${name}`,
164493
+ message: `Sandbox '${name}' has multiple modes (${modes.join(', ')}). Specify exactly one.`,
164498
164494
  });
164499
164495
  }
164500
- }
164501
- if (config.visor_path) {
164502
- if (!config.visor_path.startsWith('/')) {
164496
+ // Compose mode requires service
164497
+ if (config.compose && !config.service) {
164503
164498
  errors.push({
164504
- field: `sandboxes.${name}.visor_path`,
164505
- message: `visor_path '${config.visor_path}' in sandbox '${name}' must be an absolute path (start with /)`,
164499
+ field: `sandboxes.${name}.service`,
164500
+ message: `Sandbox '${name}' uses compose mode but is missing required 'service' field`,
164506
164501
  });
164507
164502
  }
164508
- if (/\.\./.test(config.visor_path)) {
164503
+ // Validate file paths don't contain traversal
164504
+ if (config.dockerfile && /\.\./.test(config.dockerfile)) {
164509
164505
  errors.push({
164510
- field: `sandboxes.${name}.visor_path`,
164511
- message: `visor_path '${config.visor_path}' in sandbox '${name}' must not contain '..' path traversal`,
164506
+ field: `sandboxes.${name}.dockerfile`,
164507
+ message: `Dockerfile path '${config.dockerfile}' in sandbox '${name}' must not contain '..' path traversal`,
164512
164508
  });
164513
164509
  }
164514
- }
164515
- // Validate cache paths are absolute and safe
164516
- if (config.cache?.paths) {
164517
- for (const p of config.cache.paths) {
164518
- if (!p.startsWith('/')) {
164510
+ if (config.compose && /\.\./.test(config.compose)) {
164511
+ errors.push({
164512
+ field: `sandboxes.${name}.compose`,
164513
+ message: `Compose file path '${config.compose}' in sandbox '${name}' must not contain '..' path traversal`,
164514
+ });
164515
+ }
164516
+ // Validate visor_path
164517
+ if (config.visor_path) {
164518
+ if (!config.visor_path.startsWith('/')) {
164519
164519
  errors.push({
164520
- field: `sandboxes.${name}.cache.paths`,
164521
- message: `Cache path '${p}' in sandbox '${name}' must be absolute (start with /)`,
164522
- value: p,
164520
+ field: `sandboxes.${name}.visor_path`,
164521
+ message: `visor_path '${config.visor_path}' in sandbox '${name}' must be an absolute path (start with /)`,
164523
164522
  });
164524
164523
  }
164525
- if (/\.\./.test(p)) {
164524
+ if (/\.\./.test(config.visor_path)) {
164525
+ errors.push({
164526
+ field: `sandboxes.${name}.visor_path`,
164527
+ message: `visor_path '${config.visor_path}' in sandbox '${name}' must not contain '..' path traversal`,
164528
+ });
164529
+ }
164530
+ }
164531
+ // Validate cache paths are absolute and safe
164532
+ if (config.cache?.paths) {
164533
+ for (const p of config.cache.paths) {
164534
+ if (!p.startsWith('/')) {
164535
+ errors.push({
164536
+ field: `sandboxes.${name}.cache.paths`,
164537
+ message: `Cache path '${p}' in sandbox '${name}' must be absolute (start with /)`,
164538
+ value: p,
164539
+ });
164540
+ }
164541
+ if (/\.\./.test(p)) {
164542
+ errors.push({
164543
+ field: `sandboxes.${name}.cache.paths`,
164544
+ message: `Cache path '${p}' in sandbox '${name}' must not contain '..' path traversal`,
164545
+ value: p,
164546
+ });
164547
+ }
164548
+ }
164549
+ }
164550
+ // Validate resource limits
164551
+ if (config.resources?.cpu !== undefined) {
164552
+ if (typeof config.resources.cpu !== 'number' || config.resources.cpu <= 0) {
164526
164553
  errors.push({
164527
- field: `sandboxes.${name}.cache.paths`,
164528
- message: `Cache path '${p}' in sandbox '${name}' must not contain '..' path traversal`,
164529
- value: p,
164554
+ field: `sandboxes.${name}.resources.cpu`,
164555
+ message: `CPU limit in sandbox '${name}' must be a positive number`,
164556
+ value: config.resources.cpu,
164530
164557
  });
164531
164558
  }
164532
164559
  }
164533
164560
  }
164534
- // Validate resource limits
164535
- if (config.resources?.cpu !== undefined) {
164536
- if (typeof config.resources.cpu !== 'number' || config.resources.cpu <= 0) {
164561
+ // Common validations for all engines
164562
+ if (config.workdir) {
164563
+ if (!config.workdir.startsWith('/')) {
164564
+ errors.push({
164565
+ field: `sandboxes.${name}.workdir`,
164566
+ message: `Workdir '${config.workdir}' in sandbox '${name}' must be an absolute path (start with /)`,
164567
+ });
164568
+ }
164569
+ if (/\.\./.test(config.workdir)) {
164537
164570
  errors.push({
164538
- field: `sandboxes.${name}.resources.cpu`,
164539
- message: `CPU limit in sandbox '${name}' must be a positive number`,
164540
- value: config.resources.cpu,
164571
+ field: `sandboxes.${name}.workdir`,
164572
+ message: `Workdir '${config.workdir}' in sandbox '${name}' must not contain '..' path traversal`,
164541
164573
  });
164542
164574
  }
164543
164575
  }
@@ -166980,6 +167012,1690 @@ class DependencyResolver {
166980
167012
  exports.DependencyResolver = DependencyResolver;
166981
167013
 
166982
167014
 
167015
+ /***/ }),
167016
+
167017
+ /***/ 50069:
167018
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167019
+
167020
+ "use strict";
167021
+
167022
+ /**
167023
+ * Copyright (c) ProbeLabs. All rights reserved.
167024
+ * Licensed under the Elastic License 2.0; you may not use this file except
167025
+ * in compliance with the Elastic License 2.0.
167026
+ */
167027
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167028
+ if (k2 === undefined) k2 = k;
167029
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167030
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167031
+ desc = { enumerable: true, get: function() { return m[k]; } };
167032
+ }
167033
+ Object.defineProperty(o, k2, desc);
167034
+ }) : (function(o, m, k, k2) {
167035
+ if (k2 === undefined) k2 = k;
167036
+ o[k2] = m[k];
167037
+ }));
167038
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167039
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167040
+ }) : function(o, v) {
167041
+ o["default"] = v;
167042
+ });
167043
+ var __importStar = (this && this.__importStar) || (function () {
167044
+ var ownKeys = function(o) {
167045
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167046
+ var ar = [];
167047
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167048
+ return ar;
167049
+ };
167050
+ return ownKeys(o);
167051
+ };
167052
+ return function (mod) {
167053
+ if (mod && mod.__esModule) return mod;
167054
+ var result = {};
167055
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167056
+ __setModuleDefault(result, mod);
167057
+ return result;
167058
+ };
167059
+ })();
167060
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167061
+ exports.LicenseValidator = void 0;
167062
+ const crypto = __importStar(__nccwpck_require__(76982));
167063
+ const fs = __importStar(__nccwpck_require__(79896));
167064
+ const path = __importStar(__nccwpck_require__(16928));
167065
+ class LicenseValidator {
167066
+ /** Ed25519 public key for license verification (PEM format). */
167067
+ static PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----\n' +
167068
+ 'MCowBQYDK2VwAyEAI/Zd08EFmgIdrDm/HXd0l3/5GBt7R1PrdvhdmEXhJlU=\n' +
167069
+ '-----END PUBLIC KEY-----\n';
167070
+ cache = null;
167071
+ static CACHE_TTL = 5 * 60 * 1000; // 5 minutes
167072
+ static GRACE_PERIOD = 72 * 3600 * 1000; // 72 hours after expiry
167073
+ /**
167074
+ * Load and validate license from environment or file.
167075
+ *
167076
+ * Resolution order:
167077
+ * 1. VISOR_LICENSE env var (JWT string)
167078
+ * 2. VISOR_LICENSE_FILE env var (path to file)
167079
+ * 3. .visor-license in project root (cwd)
167080
+ * 4. .visor-license in ~/.config/visor/
167081
+ */
167082
+ async loadAndValidate() {
167083
+ // Return cached result if still fresh
167084
+ if (this.cache && Date.now() - this.cache.validatedAt < LicenseValidator.CACHE_TTL) {
167085
+ return this.cache.payload;
167086
+ }
167087
+ const token = this.resolveToken();
167088
+ if (!token)
167089
+ return null;
167090
+ const payload = this.verifyAndDecode(token);
167091
+ if (!payload)
167092
+ return null;
167093
+ this.cache = { payload, validatedAt: Date.now() };
167094
+ return payload;
167095
+ }
167096
+ /** Check if a specific feature is licensed */
167097
+ hasFeature(feature) {
167098
+ if (!this.cache)
167099
+ return false;
167100
+ return this.cache.payload.features.includes(feature);
167101
+ }
167102
+ /** Check if license is valid (with grace period) */
167103
+ isValid() {
167104
+ if (!this.cache)
167105
+ return false;
167106
+ const now = Date.now();
167107
+ const expiryMs = this.cache.payload.exp * 1000;
167108
+ return now < expiryMs + LicenseValidator.GRACE_PERIOD;
167109
+ }
167110
+ /** Check if the license is within its grace period (expired but still valid) */
167111
+ isInGracePeriod() {
167112
+ if (!this.cache)
167113
+ return false;
167114
+ const now = Date.now();
167115
+ const expiryMs = this.cache.payload.exp * 1000;
167116
+ return now >= expiryMs && now < expiryMs + LicenseValidator.GRACE_PERIOD;
167117
+ }
167118
+ resolveToken() {
167119
+ // 1. Direct env var
167120
+ if (process.env.VISOR_LICENSE) {
167121
+ return process.env.VISOR_LICENSE.trim();
167122
+ }
167123
+ // 2. File path from env (validate against path traversal)
167124
+ if (process.env.VISOR_LICENSE_FILE) {
167125
+ // path.resolve() produces an absolute path with all '..' segments resolved,
167126
+ // so a separate resolved.includes('..') check is unnecessary.
167127
+ const resolved = path.resolve(process.env.VISOR_LICENSE_FILE);
167128
+ const home = process.env.HOME || process.env.USERPROFILE || '';
167129
+ const allowedPrefixes = [path.normalize(process.cwd())];
167130
+ if (home)
167131
+ allowedPrefixes.push(path.normalize(path.join(home, '.config', 'visor')));
167132
+ // Resolve symlinks so an attacker cannot create a symlink inside an
167133
+ // allowed prefix that points to an arbitrary file outside it.
167134
+ let realPath;
167135
+ try {
167136
+ realPath = fs.realpathSync(resolved);
167137
+ }
167138
+ catch {
167139
+ return null; // File doesn't exist or isn't accessible
167140
+ }
167141
+ const isSafe = allowedPrefixes.some(prefix => realPath === prefix || realPath.startsWith(prefix + path.sep));
167142
+ if (!isSafe)
167143
+ return null;
167144
+ return this.readFile(realPath);
167145
+ }
167146
+ // 3. .visor-license in cwd
167147
+ const cwdPath = path.join(process.cwd(), '.visor-license');
167148
+ const cwdToken = this.readFile(cwdPath);
167149
+ if (cwdToken)
167150
+ return cwdToken;
167151
+ // 4. ~/.config/visor/.visor-license
167152
+ const home = process.env.HOME || process.env.USERPROFILE || '';
167153
+ if (home) {
167154
+ const configPath = path.join(home, '.config', 'visor', '.visor-license');
167155
+ const configToken = this.readFile(configPath);
167156
+ if (configToken)
167157
+ return configToken;
167158
+ }
167159
+ return null;
167160
+ }
167161
+ readFile(filePath) {
167162
+ try {
167163
+ return fs.readFileSync(filePath, 'utf-8').trim();
167164
+ }
167165
+ catch {
167166
+ return null;
167167
+ }
167168
+ }
167169
+ verifyAndDecode(token) {
167170
+ try {
167171
+ const parts = token.split('.');
167172
+ if (parts.length !== 3)
167173
+ return null;
167174
+ const [headerB64, payloadB64, signatureB64] = parts;
167175
+ // Decode header to verify algorithm
167176
+ const header = JSON.parse(Buffer.from(headerB64, 'base64url').toString());
167177
+ if (header.alg !== 'EdDSA')
167178
+ return null;
167179
+ // Verify signature
167180
+ const data = `${headerB64}.${payloadB64}`;
167181
+ const signature = Buffer.from(signatureB64, 'base64url');
167182
+ const publicKey = crypto.createPublicKey(LicenseValidator.PUBLIC_KEY);
167183
+ // Validate that the loaded public key is actually Ed25519 (OID 1.3.101.112).
167184
+ // This prevents algorithm-confusion attacks if the embedded key were ever
167185
+ // swapped to a different type.
167186
+ if (publicKey.asymmetricKeyType !== 'ed25519') {
167187
+ return null;
167188
+ }
167189
+ // Ed25519 verification: algorithm must be null because EdDSA performs its
167190
+ // own internal hashing (SHA-512) — passing a digest algorithm here would
167191
+ // cause Node.js to throw. The key type is validated above.
167192
+ const isValid = crypto.verify(null, Buffer.from(data), publicKey, signature);
167193
+ if (!isValid)
167194
+ return null;
167195
+ // Decode payload
167196
+ const payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString());
167197
+ // Validate required fields
167198
+ if (!payload.org ||
167199
+ !Array.isArray(payload.features) ||
167200
+ typeof payload.exp !== 'number' ||
167201
+ typeof payload.iat !== 'number' ||
167202
+ !payload.sub) {
167203
+ return null;
167204
+ }
167205
+ // Check expiry (with grace period)
167206
+ const now = Date.now();
167207
+ const expiryMs = payload.exp * 1000;
167208
+ if (now >= expiryMs + LicenseValidator.GRACE_PERIOD) {
167209
+ return null;
167210
+ }
167211
+ return payload;
167212
+ }
167213
+ catch {
167214
+ return null;
167215
+ }
167216
+ }
167217
+ }
167218
+ exports.LicenseValidator = LicenseValidator;
167219
+
167220
+
167221
+ /***/ }),
167222
+
167223
+ /***/ 87068:
167224
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167225
+
167226
+ "use strict";
167227
+
167228
+ /**
167229
+ * Copyright (c) ProbeLabs. All rights reserved.
167230
+ * Licensed under the Elastic License 2.0; you may not use this file except
167231
+ * in compliance with the Elastic License 2.0.
167232
+ */
167233
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167234
+ if (k2 === undefined) k2 = k;
167235
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167236
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167237
+ desc = { enumerable: true, get: function() { return m[k]; } };
167238
+ }
167239
+ Object.defineProperty(o, k2, desc);
167240
+ }) : (function(o, m, k, k2) {
167241
+ if (k2 === undefined) k2 = k;
167242
+ o[k2] = m[k];
167243
+ }));
167244
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167245
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167246
+ }) : function(o, v) {
167247
+ o["default"] = v;
167248
+ });
167249
+ var __importStar = (this && this.__importStar) || (function () {
167250
+ var ownKeys = function(o) {
167251
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167252
+ var ar = [];
167253
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167254
+ return ar;
167255
+ };
167256
+ return ownKeys(o);
167257
+ };
167258
+ return function (mod) {
167259
+ if (mod && mod.__esModule) return mod;
167260
+ var result = {};
167261
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167262
+ __setModuleDefault(result, mod);
167263
+ return result;
167264
+ };
167265
+ })();
167266
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167267
+ exports.loadEnterprisePolicyEngine = loadEnterprisePolicyEngine;
167268
+ exports.loadEnterpriseStoreBackend = loadEnterpriseStoreBackend;
167269
+ const default_engine_1 = __nccwpck_require__(93866);
167270
+ /**
167271
+ * Load the enterprise policy engine if licensed, otherwise return the default no-op engine.
167272
+ *
167273
+ * This is the sole import boundary between OSS and enterprise code. Core code
167274
+ * must only import from this module (via dynamic `await import()`), never from
167275
+ * individual enterprise submodules.
167276
+ */
167277
+ async function loadEnterprisePolicyEngine(config) {
167278
+ try {
167279
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167280
+ const validator = new LicenseValidator();
167281
+ const license = await validator.loadAndValidate();
167282
+ if (!license || !validator.hasFeature('policy')) {
167283
+ return new default_engine_1.DefaultPolicyEngine();
167284
+ }
167285
+ if (validator.isInGracePeriod()) {
167286
+ // eslint-disable-next-line no-console
167287
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167288
+ 'Please renew your license.');
167289
+ }
167290
+ const { OpaPolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(39530)));
167291
+ const engine = new OpaPolicyEngine(config);
167292
+ await engine.initialize(config);
167293
+ return engine;
167294
+ }
167295
+ catch (err) {
167296
+ // Enterprise code not available or initialization failed
167297
+ const msg = err instanceof Error ? err.message : String(err);
167298
+ try {
167299
+ const { logger } = __nccwpck_require__(86999);
167300
+ logger.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
167301
+ }
167302
+ catch {
167303
+ // silent
167304
+ }
167305
+ return new default_engine_1.DefaultPolicyEngine();
167306
+ }
167307
+ }
167308
+ /**
167309
+ * Load the enterprise schedule store backend if licensed.
167310
+ *
167311
+ * @param driver Database driver ('postgresql', 'mysql', or 'mssql')
167312
+ * @param storageConfig Storage configuration with connection details
167313
+ * @param haConfig Optional HA configuration
167314
+ * @throws Error if enterprise license is not available or missing 'scheduler-sql' feature
167315
+ */
167316
+ async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
167317
+ const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
167318
+ const validator = new LicenseValidator();
167319
+ const license = await validator.loadAndValidate();
167320
+ if (!license || !validator.hasFeature('scheduler-sql')) {
167321
+ throw new Error(`The ${driver} schedule storage driver requires a Visor Enterprise license ` +
167322
+ `with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`);
167323
+ }
167324
+ if (validator.isInGracePeriod()) {
167325
+ // eslint-disable-next-line no-console
167326
+ console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
167327
+ 'Please renew your license.');
167328
+ }
167329
+ const { KnexStoreBackend } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(63737)));
167330
+ return new KnexStoreBackend(driver, storageConfig, haConfig);
167331
+ }
167332
+
167333
+
167334
+ /***/ }),
167335
+
167336
+ /***/ 628:
167337
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167338
+
167339
+ "use strict";
167340
+
167341
+ /**
167342
+ * Copyright (c) ProbeLabs. All rights reserved.
167343
+ * Licensed under the Elastic License 2.0; you may not use this file except
167344
+ * in compliance with the Elastic License 2.0.
167345
+ */
167346
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167347
+ if (k2 === undefined) k2 = k;
167348
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167349
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167350
+ desc = { enumerable: true, get: function() { return m[k]; } };
167351
+ }
167352
+ Object.defineProperty(o, k2, desc);
167353
+ }) : (function(o, m, k, k2) {
167354
+ if (k2 === undefined) k2 = k;
167355
+ o[k2] = m[k];
167356
+ }));
167357
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167358
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167359
+ }) : function(o, v) {
167360
+ o["default"] = v;
167361
+ });
167362
+ var __importStar = (this && this.__importStar) || (function () {
167363
+ var ownKeys = function(o) {
167364
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167365
+ var ar = [];
167366
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167367
+ return ar;
167368
+ };
167369
+ return ownKeys(o);
167370
+ };
167371
+ return function (mod) {
167372
+ if (mod && mod.__esModule) return mod;
167373
+ var result = {};
167374
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167375
+ __setModuleDefault(result, mod);
167376
+ return result;
167377
+ };
167378
+ })();
167379
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167380
+ exports.OpaCompiler = void 0;
167381
+ const fs = __importStar(__nccwpck_require__(79896));
167382
+ const path = __importStar(__nccwpck_require__(16928));
167383
+ const os = __importStar(__nccwpck_require__(70857));
167384
+ const crypto = __importStar(__nccwpck_require__(76982));
167385
+ const child_process_1 = __nccwpck_require__(35317);
167386
+ /**
167387
+ * OPA Rego Compiler - compiles .rego policy files to WASM bundles using the `opa` CLI.
167388
+ *
167389
+ * Handles:
167390
+ * - Resolving input paths to WASM bytes (direct .wasm, directory with policy.wasm, or .rego files)
167391
+ * - Compiling .rego files to WASM via `opa build`
167392
+ * - Caching compiled bundles based on content hashes
167393
+ * - Extracting policy.wasm from OPA tar.gz bundles
167394
+ *
167395
+ * Requires:
167396
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
167397
+ */
167398
+ class OpaCompiler {
167399
+ static CACHE_DIR = path.join(os.tmpdir(), 'visor-opa-cache');
167400
+ /**
167401
+ * Resolve the input paths to WASM bytes.
167402
+ *
167403
+ * Strategy:
167404
+ * 1. If any path is a .wasm file, read it directly
167405
+ * 2. If a directory contains policy.wasm, read it
167406
+ * 3. Otherwise, collect all .rego files and auto-compile via `opa build`
167407
+ */
167408
+ async resolveWasmBytes(paths) {
167409
+ // Collect .rego files and check for existing .wasm
167410
+ const regoFiles = [];
167411
+ for (const p of paths) {
167412
+ const resolved = path.resolve(p);
167413
+ // Reject paths containing '..' after resolution (path traversal)
167414
+ if (path.normalize(resolved).includes('..')) {
167415
+ throw new Error(`Policy path contains traversal sequences: ${p}`);
167416
+ }
167417
+ // Direct .wasm file
167418
+ if (resolved.endsWith('.wasm') && fs.existsSync(resolved)) {
167419
+ return fs.readFileSync(resolved);
167420
+ }
167421
+ if (!fs.existsSync(resolved))
167422
+ continue;
167423
+ const stat = fs.statSync(resolved);
167424
+ if (stat.isDirectory()) {
167425
+ // Check for pre-compiled policy.wasm in directory
167426
+ const wasmCandidate = path.join(resolved, 'policy.wasm');
167427
+ if (fs.existsSync(wasmCandidate)) {
167428
+ return fs.readFileSync(wasmCandidate);
167429
+ }
167430
+ // Collect all .rego files from directory
167431
+ const files = fs.readdirSync(resolved);
167432
+ for (const f of files) {
167433
+ if (f.endsWith('.rego')) {
167434
+ regoFiles.push(path.join(resolved, f));
167435
+ }
167436
+ }
167437
+ }
167438
+ else if (resolved.endsWith('.rego')) {
167439
+ regoFiles.push(resolved);
167440
+ }
167441
+ }
167442
+ if (regoFiles.length === 0) {
167443
+ throw new Error(`OPA WASM evaluator: no .wasm bundle or .rego files found in: ${paths.join(', ')}`);
167444
+ }
167445
+ // Auto-compile .rego -> .wasm
167446
+ return this.compileRego(regoFiles);
167447
+ }
167448
+ /**
167449
+ * Auto-compile .rego files to a WASM bundle using the `opa` CLI.
167450
+ *
167451
+ * Caches the compiled bundle based on a content hash of all input .rego files
167452
+ * so subsequent runs skip compilation if policies haven't changed.
167453
+ */
167454
+ compileRego(regoFiles) {
167455
+ // Check that `opa` CLI is available
167456
+ try {
167457
+ (0, child_process_1.execFileSync)('opa', ['version'], { stdio: 'pipe' });
167458
+ }
167459
+ catch {
167460
+ throw new Error('OPA CLI (`opa`) not found on PATH. Install it from https://www.openpolicyagent.org/docs/latest/#running-opa\n' +
167461
+ 'Or pre-compile your .rego files: opa build -t wasm -e visor -o bundle.tar.gz ' +
167462
+ regoFiles.join(' '));
167463
+ }
167464
+ // Compute content hash for cache key
167465
+ const hash = crypto.createHash('sha256');
167466
+ for (const f of regoFiles.sort()) {
167467
+ hash.update(fs.readFileSync(f));
167468
+ hash.update(f); // include filename for disambiguation
167469
+ }
167470
+ const cacheKey = hash.digest('hex').slice(0, 16);
167471
+ const cacheDir = OpaCompiler.CACHE_DIR;
167472
+ const cachedWasm = path.join(cacheDir, `${cacheKey}.wasm`);
167473
+ // Return cached bundle if still valid
167474
+ if (fs.existsSync(cachedWasm)) {
167475
+ return fs.readFileSync(cachedWasm);
167476
+ }
167477
+ // Compile to WASM via opa build
167478
+ fs.mkdirSync(cacheDir, { recursive: true });
167479
+ const bundleTar = path.join(cacheDir, `${cacheKey}-bundle.tar.gz`);
167480
+ try {
167481
+ const args = [
167482
+ 'build',
167483
+ '-t',
167484
+ 'wasm',
167485
+ '-e',
167486
+ 'visor', // entrypoint: the visor package tree
167487
+ '-o',
167488
+ bundleTar,
167489
+ ...regoFiles,
167490
+ ];
167491
+ (0, child_process_1.execFileSync)('opa', args, {
167492
+ stdio: 'pipe',
167493
+ timeout: 30000,
167494
+ });
167495
+ }
167496
+ catch (err) {
167497
+ const stderr = err?.stderr?.toString() || '';
167498
+ throw new Error(`Failed to compile .rego files to WASM:\n${stderr}\n` +
167499
+ 'Ensure your .rego files are valid and the `opa` CLI is installed.');
167500
+ }
167501
+ // Extract policy.wasm from the tar.gz bundle
167502
+ // OPA bundles are tar.gz with /policy.wasm inside
167503
+ try {
167504
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, '/policy.wasm'], {
167505
+ stdio: 'pipe',
167506
+ });
167507
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
167508
+ if (fs.existsSync(extractedWasm)) {
167509
+ // Move to cache-key named file
167510
+ fs.renameSync(extractedWasm, cachedWasm);
167511
+ }
167512
+ }
167513
+ catch {
167514
+ // Some tar implementations don't like leading /
167515
+ try {
167516
+ (0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, 'policy.wasm'], {
167517
+ stdio: 'pipe',
167518
+ });
167519
+ const extractedWasm = path.join(cacheDir, 'policy.wasm');
167520
+ if (fs.existsSync(extractedWasm)) {
167521
+ fs.renameSync(extractedWasm, cachedWasm);
167522
+ }
167523
+ }
167524
+ catch (err2) {
167525
+ throw new Error(`Failed to extract policy.wasm from OPA bundle: ${err2?.message || err2}`);
167526
+ }
167527
+ }
167528
+ // Clean up tar
167529
+ try {
167530
+ fs.unlinkSync(bundleTar);
167531
+ }
167532
+ catch { }
167533
+ if (!fs.existsSync(cachedWasm)) {
167534
+ throw new Error('OPA build succeeded but policy.wasm was not found in the bundle');
167535
+ }
167536
+ return fs.readFileSync(cachedWasm);
167537
+ }
167538
+ }
167539
+ exports.OpaCompiler = OpaCompiler;
167540
+
167541
+
167542
+ /***/ }),
167543
+
167544
+ /***/ 44693:
167545
+ /***/ ((__unused_webpack_module, exports) => {
167546
+
167547
+ "use strict";
167548
+
167549
+ /**
167550
+ * Copyright (c) ProbeLabs. All rights reserved.
167551
+ * Licensed under the Elastic License 2.0; you may not use this file except
167552
+ * in compliance with the Elastic License 2.0.
167553
+ */
167554
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167555
+ exports.OpaHttpEvaluator = void 0;
167556
+ /**
167557
+ * OPA HTTP Evaluator - evaluates policies via an external OPA server's REST API.
167558
+ *
167559
+ * Uses the built-in `fetch` API (Node 18+), so no extra dependencies are needed.
167560
+ */
167561
+ class OpaHttpEvaluator {
167562
+ baseUrl;
167563
+ timeout;
167564
+ constructor(baseUrl, timeout = 5000) {
167565
+ // Validate URL format and protocol
167566
+ let parsed;
167567
+ try {
167568
+ parsed = new URL(baseUrl);
167569
+ }
167570
+ catch {
167571
+ throw new Error(`OPA HTTP evaluator: invalid URL: ${baseUrl}`);
167572
+ }
167573
+ if (!['http:', 'https:'].includes(parsed.protocol)) {
167574
+ throw new Error(`OPA HTTP evaluator: url must use http:// or https:// protocol, got: ${baseUrl}`);
167575
+ }
167576
+ // Block cloud metadata, loopback, link-local, and private network addresses
167577
+ const hostname = parsed.hostname;
167578
+ if (this.isBlockedHostname(hostname)) {
167579
+ throw new Error(`OPA HTTP evaluator: url must not point to internal, loopback, or private network addresses`);
167580
+ }
167581
+ // Normalize: strip trailing slash
167582
+ this.baseUrl = baseUrl.replace(/\/+$/, '');
167583
+ this.timeout = timeout;
167584
+ }
167585
+ /**
167586
+ * Check if a hostname is blocked due to SSRF concerns.
167587
+ *
167588
+ * Blocks:
167589
+ * - Loopback addresses (127.x.x.x, localhost, 0.0.0.0, ::1)
167590
+ * - Link-local addresses (169.254.x.x)
167591
+ * - Private networks (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
167592
+ * - IPv6 unique local addresses (fd00::/8)
167593
+ * - Cloud metadata services (*.internal)
167594
+ */
167595
+ isBlockedHostname(hostname) {
167596
+ if (!hostname)
167597
+ return true; // block empty hostnames
167598
+ // Normalize hostname: lowercase and remove brackets for IPv6
167599
+ const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
167600
+ // Block .internal domains (cloud metadata services)
167601
+ if (normalized === 'metadata.google.internal' || normalized.endsWith('.internal')) {
167602
+ return true;
167603
+ }
167604
+ // Block localhost variants
167605
+ if (normalized === 'localhost' || normalized === 'localhost.localdomain') {
167606
+ return true;
167607
+ }
167608
+ // Block IPv6 loopback
167609
+ if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
167610
+ return true;
167611
+ }
167612
+ // Check IPv4 patterns
167613
+ const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
167614
+ const ipv4Match = normalized.match(ipv4Pattern);
167615
+ if (ipv4Match) {
167616
+ const octets = ipv4Match.slice(1, 5).map(Number);
167617
+ // Validate octets are in range [0, 255]
167618
+ if (octets.some(octet => octet > 255)) {
167619
+ return false;
167620
+ }
167621
+ const [a, b] = octets;
167622
+ // Block loopback: 127.0.0.0/8
167623
+ if (a === 127) {
167624
+ return true;
167625
+ }
167626
+ // Block 0.0.0.0/8 (this host)
167627
+ if (a === 0) {
167628
+ return true;
167629
+ }
167630
+ // Block link-local: 169.254.0.0/16
167631
+ if (a === 169 && b === 254) {
167632
+ return true;
167633
+ }
167634
+ // Block private networks
167635
+ // 10.0.0.0/8
167636
+ if (a === 10) {
167637
+ return true;
167638
+ }
167639
+ // 172.16.0.0/12 (172.16.x.x through 172.31.x.x)
167640
+ if (a === 172 && b >= 16 && b <= 31) {
167641
+ return true;
167642
+ }
167643
+ // 192.168.0.0/16
167644
+ if (a === 192 && b === 168) {
167645
+ return true;
167646
+ }
167647
+ }
167648
+ // Check IPv6 patterns
167649
+ // Block unique local addresses: fd00::/8
167650
+ if (normalized.startsWith('fd') || normalized.startsWith('fc')) {
167651
+ return true;
167652
+ }
167653
+ // Block link-local: fe80::/10
167654
+ if (normalized.startsWith('fe80:')) {
167655
+ return true;
167656
+ }
167657
+ return false;
167658
+ }
167659
+ /**
167660
+ * Evaluate a policy rule against an input document via OPA REST API.
167661
+ *
167662
+ * @param input - The input document to evaluate
167663
+ * @param rulePath - OPA rule path (e.g., 'visor/check/execute')
167664
+ * @returns The result object from OPA, or undefined on error
167665
+ */
167666
+ async evaluate(input, rulePath) {
167667
+ // OPA Data API: POST /v1/data/<path>
167668
+ const encodedPath = rulePath
167669
+ .split('/')
167670
+ .map(s => encodeURIComponent(s))
167671
+ .join('/');
167672
+ const url = `${this.baseUrl}/v1/data/${encodedPath}`;
167673
+ const controller = new AbortController();
167674
+ const timer = setTimeout(() => controller.abort(), this.timeout);
167675
+ try {
167676
+ const response = await fetch(url, {
167677
+ method: 'POST',
167678
+ headers: { 'Content-Type': 'application/json' },
167679
+ body: JSON.stringify({ input }),
167680
+ signal: controller.signal,
167681
+ });
167682
+ if (!response.ok) {
167683
+ throw new Error(`OPA HTTP ${response.status}: ${response.statusText}`);
167684
+ }
167685
+ let body;
167686
+ try {
167687
+ body = await response.json();
167688
+ }
167689
+ catch (jsonErr) {
167690
+ throw new Error(`OPA HTTP evaluator: failed to parse JSON response: ${jsonErr instanceof Error ? jsonErr.message : String(jsonErr)}`);
167691
+ }
167692
+ // OPA returns { result: { ... } }
167693
+ return body?.result;
167694
+ }
167695
+ finally {
167696
+ clearTimeout(timer);
167697
+ }
167698
+ }
167699
+ async shutdown() {
167700
+ // No persistent connections to close
167701
+ }
167702
+ }
167703
+ exports.OpaHttpEvaluator = OpaHttpEvaluator;
167704
+
167705
+
167706
+ /***/ }),
167707
+
167708
+ /***/ 39530:
167709
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
167710
+
167711
+ "use strict";
167712
+
167713
+ /**
167714
+ * Copyright (c) ProbeLabs. All rights reserved.
167715
+ * Licensed under the Elastic License 2.0; you may not use this file except
167716
+ * in compliance with the Elastic License 2.0.
167717
+ */
167718
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167719
+ exports.OpaPolicyEngine = void 0;
167720
+ const opa_wasm_evaluator_1 = __nccwpck_require__(8613);
167721
+ const opa_http_evaluator_1 = __nccwpck_require__(44693);
167722
+ const policy_input_builder_1 = __nccwpck_require__(17117);
167723
+ /**
167724
+ * Enterprise OPA Policy Engine.
167725
+ *
167726
+ * Wraps both WASM (local) and HTTP (remote) OPA evaluators behind the
167727
+ * OSS PolicyEngine interface. All OPA input building and role resolution
167728
+ * is handled internally — the OSS call sites pass only plain types.
167729
+ */
167730
+ class OpaPolicyEngine {
167731
+ evaluator = null;
167732
+ fallback;
167733
+ timeout;
167734
+ config;
167735
+ inputBuilder = null;
167736
+ logger = null;
167737
+ constructor(config) {
167738
+ this.config = config;
167739
+ this.fallback = config.fallback || 'deny';
167740
+ this.timeout = config.timeout || 5000;
167741
+ }
167742
+ async initialize(config) {
167743
+ // Resolve logger once at initialization
167744
+ try {
167745
+ this.logger = (__nccwpck_require__(86999).logger);
167746
+ }
167747
+ catch {
167748
+ // logger not available in this context
167749
+ }
167750
+ // Build actor/repo context from environment (available at engine init time)
167751
+ const actor = {
167752
+ authorAssociation: process.env.VISOR_AUTHOR_ASSOCIATION,
167753
+ login: process.env.VISOR_AUTHOR_LOGIN || process.env.GITHUB_ACTOR,
167754
+ isLocalMode: !process.env.GITHUB_ACTIONS,
167755
+ };
167756
+ const repo = {
167757
+ owner: process.env.GITHUB_REPOSITORY_OWNER,
167758
+ name: process.env.GITHUB_REPOSITORY?.split('/')[1],
167759
+ branch: process.env.GITHUB_HEAD_REF,
167760
+ baseBranch: process.env.GITHUB_BASE_REF,
167761
+ event: process.env.GITHUB_EVENT_NAME,
167762
+ };
167763
+ const prNum = process.env.GITHUB_PR_NUMBER
167764
+ ? parseInt(process.env.GITHUB_PR_NUMBER, 10)
167765
+ : undefined;
167766
+ const pullRequest = {
167767
+ number: prNum !== undefined && Number.isFinite(prNum) ? prNum : undefined,
167768
+ };
167769
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(config, actor, repo, pullRequest);
167770
+ if (config.engine === 'local') {
167771
+ if (!config.rules) {
167772
+ throw new Error('OPA local mode requires `policy.rules` path to .wasm or .rego files');
167773
+ }
167774
+ const wasm = new opa_wasm_evaluator_1.OpaWasmEvaluator();
167775
+ await wasm.initialize(config.rules);
167776
+ if (config.data) {
167777
+ wasm.loadData(config.data);
167778
+ }
167779
+ this.evaluator = wasm;
167780
+ }
167781
+ else if (config.engine === 'remote') {
167782
+ if (!config.url) {
167783
+ throw new Error('OPA remote mode requires `policy.url` pointing to OPA server');
167784
+ }
167785
+ this.evaluator = new opa_http_evaluator_1.OpaHttpEvaluator(config.url, this.timeout);
167786
+ }
167787
+ else {
167788
+ this.evaluator = null;
167789
+ }
167790
+ }
167791
+ /**
167792
+ * Update actor/repo/PR context (e.g., after PR info becomes available).
167793
+ * Called by the enterprise loader when engine context is enriched.
167794
+ */
167795
+ setActorContext(actor, repo, pullRequest) {
167796
+ this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(this.config, actor, repo, pullRequest);
167797
+ }
167798
+ async evaluateCheckExecution(checkId, checkConfig) {
167799
+ if (!this.evaluator || !this.inputBuilder)
167800
+ return { allowed: true };
167801
+ const cfg = checkConfig && typeof checkConfig === 'object'
167802
+ ? checkConfig
167803
+ : {};
167804
+ const policyOverride = cfg.policy;
167805
+ const input = this.inputBuilder.forCheckExecution({
167806
+ id: checkId,
167807
+ type: cfg.type || 'ai',
167808
+ group: cfg.group,
167809
+ tags: cfg.tags,
167810
+ criticality: cfg.criticality,
167811
+ sandbox: cfg.sandbox,
167812
+ policy: policyOverride,
167813
+ });
167814
+ return this.doEvaluate(input, this.resolveRulePath('check.execute', policyOverride?.rule));
167815
+ }
167816
+ async evaluateToolInvocation(serverName, methodName, transport) {
167817
+ if (!this.evaluator || !this.inputBuilder)
167818
+ return { allowed: true };
167819
+ const input = this.inputBuilder.forToolInvocation(serverName, methodName, transport);
167820
+ return this.doEvaluate(input, 'visor/tool/invoke');
167821
+ }
167822
+ async evaluateCapabilities(checkId, capabilities) {
167823
+ if (!this.evaluator || !this.inputBuilder)
167824
+ return { allowed: true };
167825
+ const input = this.inputBuilder.forCapabilityResolve(checkId, capabilities);
167826
+ return this.doEvaluate(input, 'visor/capability/resolve');
167827
+ }
167828
+ async shutdown() {
167829
+ if (this.evaluator && 'shutdown' in this.evaluator) {
167830
+ await this.evaluator.shutdown();
167831
+ }
167832
+ this.evaluator = null;
167833
+ this.inputBuilder = null;
167834
+ }
167835
+ resolveRulePath(defaultScope, override) {
167836
+ if (override) {
167837
+ return override.startsWith('visor/') ? override : `visor/${override}`;
167838
+ }
167839
+ return `visor/${defaultScope.replace(/\./g, '/')}`;
167840
+ }
167841
+ async doEvaluate(input, rulePath) {
167842
+ try {
167843
+ this.logger?.debug(`[PolicyEngine] Evaluating ${rulePath}`, JSON.stringify(input));
167844
+ let timer;
167845
+ const timeoutPromise = new Promise((_resolve, reject) => {
167846
+ timer = setTimeout(() => reject(new Error('policy evaluation timeout')), this.timeout);
167847
+ });
167848
+ try {
167849
+ const result = await Promise.race([this.rawEvaluate(input, rulePath), timeoutPromise]);
167850
+ const decision = this.parseDecision(result);
167851
+ // In warn mode, override denied decisions to allowed but flag as warn
167852
+ if (!decision.allowed && this.fallback === 'warn') {
167853
+ decision.allowed = true;
167854
+ decision.warn = true;
167855
+ decision.reason = `audit: ${decision.reason || 'policy denied'}`;
167856
+ }
167857
+ this.logger?.debug(`[PolicyEngine] Decision for ${rulePath}: allowed=${decision.allowed}, warn=${decision.warn || false}, reason=${decision.reason || 'none'}`);
167858
+ return decision;
167859
+ }
167860
+ finally {
167861
+ if (timer)
167862
+ clearTimeout(timer);
167863
+ }
167864
+ }
167865
+ catch (err) {
167866
+ const msg = err instanceof Error ? err.message : String(err);
167867
+ this.logger?.warn(`[PolicyEngine] Evaluation failed for ${rulePath}: ${msg}`);
167868
+ return {
167869
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
167870
+ warn: this.fallback === 'warn' ? true : undefined,
167871
+ reason: `policy evaluation failed, fallback=${this.fallback}`,
167872
+ };
167873
+ }
167874
+ }
167875
+ async rawEvaluate(input, rulePath) {
167876
+ if (this.evaluator instanceof opa_wasm_evaluator_1.OpaWasmEvaluator) {
167877
+ const result = await this.evaluator.evaluate(input);
167878
+ // WASM compiled with `-e visor` entrypoint returns the full visor package tree.
167879
+ // Navigate to the specific rule subtree using rulePath segments.
167880
+ // e.g., 'visor/check/execute' → result.check.execute
167881
+ return this.navigateWasmResult(result, rulePath);
167882
+ }
167883
+ return this.evaluator.evaluate(input, rulePath);
167884
+ }
167885
+ /**
167886
+ * Navigate nested OPA WASM result tree to reach the specific rule's output.
167887
+ * The WASM entrypoint `-e visor` means the result root IS the visor package,
167888
+ * so we strip the `visor/` prefix and walk the remaining segments.
167889
+ */
167890
+ navigateWasmResult(result, rulePath) {
167891
+ if (!result || typeof result !== 'object')
167892
+ return result;
167893
+ // Strip the 'visor/' prefix (matches our compilation entrypoint)
167894
+ const segments = rulePath.replace(/^visor\//, '').split('/');
167895
+ let current = result;
167896
+ for (const seg of segments) {
167897
+ if (current && typeof current === 'object' && seg in current) {
167898
+ current = current[seg];
167899
+ }
167900
+ else {
167901
+ return undefined; // path not found in result tree
167902
+ }
167903
+ }
167904
+ return current;
167905
+ }
167906
+ parseDecision(result) {
167907
+ if (result === undefined || result === null) {
167908
+ return {
167909
+ allowed: this.fallback === 'allow' || this.fallback === 'warn',
167910
+ warn: this.fallback === 'warn' ? true : undefined,
167911
+ reason: this.fallback === 'warn' ? 'audit: no policy result' : 'no policy result',
167912
+ };
167913
+ }
167914
+ const allowed = result.allowed !== false;
167915
+ const decision = {
167916
+ allowed,
167917
+ reason: result.reason,
167918
+ };
167919
+ if (result.capabilities) {
167920
+ decision.capabilities = result.capabilities;
167921
+ }
167922
+ return decision;
167923
+ }
167924
+ }
167925
+ exports.OpaPolicyEngine = OpaPolicyEngine;
167926
+
167927
+
167928
+ /***/ }),
167929
+
167930
+ /***/ 8613:
167931
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
167932
+
167933
+ "use strict";
167934
+
167935
+ /**
167936
+ * Copyright (c) ProbeLabs. All rights reserved.
167937
+ * Licensed under the Elastic License 2.0; you may not use this file except
167938
+ * in compliance with the Elastic License 2.0.
167939
+ */
167940
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
167941
+ if (k2 === undefined) k2 = k;
167942
+ var desc = Object.getOwnPropertyDescriptor(m, k);
167943
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
167944
+ desc = { enumerable: true, get: function() { return m[k]; } };
167945
+ }
167946
+ Object.defineProperty(o, k2, desc);
167947
+ }) : (function(o, m, k, k2) {
167948
+ if (k2 === undefined) k2 = k;
167949
+ o[k2] = m[k];
167950
+ }));
167951
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
167952
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
167953
+ }) : function(o, v) {
167954
+ o["default"] = v;
167955
+ });
167956
+ var __importStar = (this && this.__importStar) || (function () {
167957
+ var ownKeys = function(o) {
167958
+ ownKeys = Object.getOwnPropertyNames || function (o) {
167959
+ var ar = [];
167960
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
167961
+ return ar;
167962
+ };
167963
+ return ownKeys(o);
167964
+ };
167965
+ return function (mod) {
167966
+ if (mod && mod.__esModule) return mod;
167967
+ var result = {};
167968
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
167969
+ __setModuleDefault(result, mod);
167970
+ return result;
167971
+ };
167972
+ })();
167973
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
167974
+ exports.OpaWasmEvaluator = void 0;
167975
+ const fs = __importStar(__nccwpck_require__(79896));
167976
+ const path = __importStar(__nccwpck_require__(16928));
167977
+ const opa_compiler_1 = __nccwpck_require__(628);
167978
+ /**
167979
+ * OPA WASM Evaluator - loads and evaluates OPA policies locally.
167980
+ *
167981
+ * Supports three input formats:
167982
+ * 1. Pre-compiled `.wasm` bundle — loaded directly (fastest startup)
167983
+ * 2. `.rego` files or directory — auto-compiled to WASM via `opa build` CLI
167984
+ * 3. Directory with `policy.wasm` inside — loaded directly
167985
+ *
167986
+ * Compilation and caching of .rego files is delegated to {@link OpaCompiler}.
167987
+ *
167988
+ * Requires:
167989
+ * - `@open-policy-agent/opa-wasm` npm package (optional dep)
167990
+ * - `opa` CLI on PATH (only when auto-compiling .rego files)
167991
+ */
167992
+ class OpaWasmEvaluator {
167993
+ policy = null;
167994
+ dataDocument = {};
167995
+ compiler = new opa_compiler_1.OpaCompiler();
167996
+ async initialize(rulesPath) {
167997
+ const paths = Array.isArray(rulesPath) ? rulesPath : [rulesPath];
167998
+ const wasmBytes = await this.compiler.resolveWasmBytes(paths);
167999
+ try {
168000
+ // Use createRequire to load the optional dep at runtime without ncc bundling it.
168001
+ // `new Function('id', 'return require(id)')` fails in ncc bundles because
168002
+ // `require` is not in the `new Function` scope. `createRequire` works correctly
168003
+ // because it creates a real Node.js require rooted at the given path.
168004
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
168005
+ const { createRequire } = __nccwpck_require__(73339);
168006
+ const runtimeRequire = createRequire(__filename);
168007
+ const opaWasm = runtimeRequire('@open-policy-agent/opa-wasm');
168008
+ const loadPolicy = opaWasm.loadPolicy || opaWasm.default?.loadPolicy;
168009
+ if (!loadPolicy) {
168010
+ throw new Error('loadPolicy not found in @open-policy-agent/opa-wasm');
168011
+ }
168012
+ this.policy = await loadPolicy(wasmBytes);
168013
+ }
168014
+ catch (err) {
168015
+ if (err?.code === 'MODULE_NOT_FOUND' || err?.code === 'ERR_MODULE_NOT_FOUND') {
168016
+ throw new Error('OPA WASM evaluator requires @open-policy-agent/opa-wasm. ' +
168017
+ 'Install it with: npm install @open-policy-agent/opa-wasm');
168018
+ }
168019
+ throw err;
168020
+ }
168021
+ }
168022
+ /**
168023
+ * Load external data from a JSON file to use as the OPA data document.
168024
+ * The loaded data will be passed to `policy.setData()` during evaluation,
168025
+ * making it available in Rego via `data.<key>`.
168026
+ */
168027
+ loadData(dataPath) {
168028
+ const resolved = path.resolve(dataPath);
168029
+ if (path.normalize(resolved).includes('..')) {
168030
+ throw new Error(`Data path contains traversal sequences: ${dataPath}`);
168031
+ }
168032
+ if (!fs.existsSync(resolved)) {
168033
+ throw new Error(`OPA data file not found: ${resolved}`);
168034
+ }
168035
+ const stat = fs.statSync(resolved);
168036
+ if (stat.size > 10 * 1024 * 1024) {
168037
+ throw new Error(`OPA data file exceeds 10MB limit: ${resolved} (${stat.size} bytes)`);
168038
+ }
168039
+ const raw = fs.readFileSync(resolved, 'utf-8');
168040
+ try {
168041
+ const parsed = JSON.parse(raw);
168042
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
168043
+ throw new Error('OPA data file must contain a JSON object (not an array or primitive)');
168044
+ }
168045
+ this.dataDocument = parsed;
168046
+ }
168047
+ catch (err) {
168048
+ if (err.message.startsWith('OPA data file must')) {
168049
+ throw err;
168050
+ }
168051
+ throw new Error(`Failed to parse OPA data file ${resolved}: ${err.message}`);
168052
+ }
168053
+ }
168054
+ async evaluate(input) {
168055
+ if (!this.policy) {
168056
+ throw new Error('OPA WASM evaluator not initialized');
168057
+ }
168058
+ this.policy.setData(this.dataDocument);
168059
+ const resultSet = this.policy.evaluate(input);
168060
+ if (Array.isArray(resultSet) && resultSet.length > 0) {
168061
+ return resultSet[0].result;
168062
+ }
168063
+ return undefined;
168064
+ }
168065
+ async shutdown() {
168066
+ if (this.policy) {
168067
+ // opa-wasm policy objects may have a close/free method for WASM cleanup
168068
+ if (typeof this.policy.close === 'function') {
168069
+ try {
168070
+ this.policy.close();
168071
+ }
168072
+ catch { }
168073
+ }
168074
+ else if (typeof this.policy.free === 'function') {
168075
+ try {
168076
+ this.policy.free();
168077
+ }
168078
+ catch { }
168079
+ }
168080
+ }
168081
+ this.policy = null;
168082
+ }
168083
+ }
168084
+ exports.OpaWasmEvaluator = OpaWasmEvaluator;
168085
+
168086
+
168087
+ /***/ }),
168088
+
168089
+ /***/ 17117:
168090
+ /***/ ((__unused_webpack_module, exports) => {
168091
+
168092
+ "use strict";
168093
+
168094
+ /**
168095
+ * Copyright (c) ProbeLabs. All rights reserved.
168096
+ * Licensed under the Elastic License 2.0; you may not use this file except
168097
+ * in compliance with the Elastic License 2.0.
168098
+ */
168099
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168100
+ exports.PolicyInputBuilder = void 0;
168101
+ /**
168102
+ * Builds OPA-compatible input documents from engine context.
168103
+ *
168104
+ * Resolves actor roles from the `policy.roles` config section by matching
168105
+ * the actor's authorAssociation and login against role definitions.
168106
+ */
168107
+ class PolicyInputBuilder {
168108
+ roles;
168109
+ actor;
168110
+ repository;
168111
+ pullRequest;
168112
+ constructor(policyConfig, actor, repository, pullRequest) {
168113
+ this.roles = policyConfig.roles || {};
168114
+ this.actor = actor;
168115
+ this.repository = repository;
168116
+ this.pullRequest = pullRequest;
168117
+ }
168118
+ /** Resolve which roles apply to the current actor. */
168119
+ resolveRoles() {
168120
+ const matched = [];
168121
+ for (const [roleName, roleConfig] of Object.entries(this.roles)) {
168122
+ let identityMatch = false;
168123
+ if (roleConfig.author_association &&
168124
+ this.actor.authorAssociation &&
168125
+ roleConfig.author_association.includes(this.actor.authorAssociation)) {
168126
+ identityMatch = true;
168127
+ }
168128
+ if (!identityMatch &&
168129
+ roleConfig.users &&
168130
+ this.actor.login &&
168131
+ roleConfig.users.includes(this.actor.login)) {
168132
+ identityMatch = true;
168133
+ }
168134
+ // Slack user ID match
168135
+ if (!identityMatch &&
168136
+ roleConfig.slack_users &&
168137
+ this.actor.slack?.userId &&
168138
+ roleConfig.slack_users.includes(this.actor.slack.userId)) {
168139
+ identityMatch = true;
168140
+ }
168141
+ // Email match (case-insensitive)
168142
+ if (!identityMatch && roleConfig.emails && this.actor.slack?.email) {
168143
+ const actorEmail = this.actor.slack.email.toLowerCase();
168144
+ if (roleConfig.emails.some(e => e.toLowerCase() === actorEmail)) {
168145
+ identityMatch = true;
168146
+ }
168147
+ }
168148
+ // Note: teams-based role resolution requires GitHub API access (read:org scope)
168149
+ // and is not yet implemented. If configured, the role will not match via teams.
168150
+ if (!identityMatch)
168151
+ continue;
168152
+ // slack_channels gate: if set, the role only applies when triggered from one of these channels
168153
+ if (roleConfig.slack_channels && roleConfig.slack_channels.length > 0) {
168154
+ if (!this.actor.slack?.channelId ||
168155
+ !roleConfig.slack_channels.includes(this.actor.slack.channelId)) {
168156
+ continue;
168157
+ }
168158
+ }
168159
+ matched.push(roleName);
168160
+ }
168161
+ return matched;
168162
+ }
168163
+ buildActor() {
168164
+ return {
168165
+ authorAssociation: this.actor.authorAssociation,
168166
+ login: this.actor.login,
168167
+ roles: this.resolveRoles(),
168168
+ isLocalMode: this.actor.isLocalMode,
168169
+ ...(this.actor.slack && { slack: this.actor.slack }),
168170
+ };
168171
+ }
168172
+ forCheckExecution(check) {
168173
+ return {
168174
+ scope: 'check.execute',
168175
+ check: {
168176
+ id: check.id,
168177
+ type: check.type,
168178
+ group: check.group,
168179
+ tags: check.tags,
168180
+ criticality: check.criticality,
168181
+ sandbox: check.sandbox,
168182
+ policy: check.policy,
168183
+ },
168184
+ actor: this.buildActor(),
168185
+ repository: this.repository,
168186
+ pullRequest: this.pullRequest,
168187
+ };
168188
+ }
168189
+ forToolInvocation(serverName, methodName, transport) {
168190
+ return {
168191
+ scope: 'tool.invoke',
168192
+ tool: { serverName, methodName, transport },
168193
+ actor: this.buildActor(),
168194
+ repository: this.repository,
168195
+ pullRequest: this.pullRequest,
168196
+ };
168197
+ }
168198
+ forCapabilityResolve(checkId, capabilities) {
168199
+ return {
168200
+ scope: 'capability.resolve',
168201
+ check: { id: checkId, type: 'ai' },
168202
+ capability: capabilities,
168203
+ actor: this.buildActor(),
168204
+ repository: this.repository,
168205
+ pullRequest: this.pullRequest,
168206
+ };
168207
+ }
168208
+ }
168209
+ exports.PolicyInputBuilder = PolicyInputBuilder;
168210
+
168211
+
168212
+ /***/ }),
168213
+
168214
+ /***/ 63737:
168215
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
168216
+
168217
+ "use strict";
168218
+
168219
+ /**
168220
+ * Copyright (c) ProbeLabs. All rights reserved.
168221
+ * Licensed under the Elastic License 2.0; you may not use this file except
168222
+ * in compliance with the Elastic License 2.0.
168223
+ */
168224
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
168225
+ if (k2 === undefined) k2 = k;
168226
+ var desc = Object.getOwnPropertyDescriptor(m, k);
168227
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
168228
+ desc = { enumerable: true, get: function() { return m[k]; } };
168229
+ }
168230
+ Object.defineProperty(o, k2, desc);
168231
+ }) : (function(o, m, k, k2) {
168232
+ if (k2 === undefined) k2 = k;
168233
+ o[k2] = m[k];
168234
+ }));
168235
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
168236
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
168237
+ }) : function(o, v) {
168238
+ o["default"] = v;
168239
+ });
168240
+ var __importStar = (this && this.__importStar) || (function () {
168241
+ var ownKeys = function(o) {
168242
+ ownKeys = Object.getOwnPropertyNames || function (o) {
168243
+ var ar = [];
168244
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
168245
+ return ar;
168246
+ };
168247
+ return ownKeys(o);
168248
+ };
168249
+ return function (mod) {
168250
+ if (mod && mod.__esModule) return mod;
168251
+ var result = {};
168252
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
168253
+ __setModuleDefault(result, mod);
168254
+ return result;
168255
+ };
168256
+ })();
168257
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
168258
+ exports.KnexStoreBackend = void 0;
168259
+ /**
168260
+ * Knex-backed schedule store for PostgreSQL, MySQL, and MSSQL (Enterprise)
168261
+ *
168262
+ * Uses Knex query builder for database-agnostic SQL. Same schema as SQLite backend
168263
+ * but with real distributed locking via row-level claims (claimed_by/claimed_at/lock_token).
168264
+ */
168265
+ const fs = __importStar(__nccwpck_require__(79896));
168266
+ const path = __importStar(__nccwpck_require__(16928));
168267
+ const uuid_1 = __nccwpck_require__(31914);
168268
+ const logger_1 = __nccwpck_require__(86999);
168269
+ function toNum(val) {
168270
+ if (val === null || val === undefined)
168271
+ return undefined;
168272
+ return typeof val === 'string' ? parseInt(val, 10) : val;
168273
+ }
168274
+ function safeJsonParse(value) {
168275
+ if (!value)
168276
+ return undefined;
168277
+ try {
168278
+ return JSON.parse(value);
168279
+ }
168280
+ catch {
168281
+ return undefined;
168282
+ }
168283
+ }
168284
+ function fromDbRow(row) {
168285
+ return {
168286
+ id: row.id,
168287
+ creatorId: row.creator_id,
168288
+ creatorContext: row.creator_context ?? undefined,
168289
+ creatorName: row.creator_name ?? undefined,
168290
+ timezone: row.timezone,
168291
+ schedule: row.schedule_expr,
168292
+ runAt: toNum(row.run_at),
168293
+ isRecurring: row.is_recurring === true || row.is_recurring === 1,
168294
+ originalExpression: row.original_expression,
168295
+ workflow: row.workflow ?? undefined,
168296
+ workflowInputs: safeJsonParse(row.workflow_inputs),
168297
+ outputContext: safeJsonParse(row.output_context),
168298
+ status: row.status,
168299
+ createdAt: toNum(row.created_at),
168300
+ lastRunAt: toNum(row.last_run_at),
168301
+ nextRunAt: toNum(row.next_run_at),
168302
+ runCount: row.run_count,
168303
+ failureCount: row.failure_count,
168304
+ lastError: row.last_error ?? undefined,
168305
+ previousResponse: row.previous_response ?? undefined,
168306
+ };
168307
+ }
168308
+ function toInsertRow(schedule) {
168309
+ return {
168310
+ id: schedule.id,
168311
+ creator_id: schedule.creatorId,
168312
+ creator_context: schedule.creatorContext ?? null,
168313
+ creator_name: schedule.creatorName ?? null,
168314
+ timezone: schedule.timezone,
168315
+ schedule_expr: schedule.schedule,
168316
+ run_at: schedule.runAt ?? null,
168317
+ is_recurring: schedule.isRecurring,
168318
+ original_expression: schedule.originalExpression,
168319
+ workflow: schedule.workflow ?? null,
168320
+ workflow_inputs: schedule.workflowInputs ? JSON.stringify(schedule.workflowInputs) : null,
168321
+ output_context: schedule.outputContext ? JSON.stringify(schedule.outputContext) : null,
168322
+ status: schedule.status,
168323
+ created_at: schedule.createdAt,
168324
+ last_run_at: schedule.lastRunAt ?? null,
168325
+ next_run_at: schedule.nextRunAt ?? null,
168326
+ run_count: schedule.runCount,
168327
+ failure_count: schedule.failureCount,
168328
+ last_error: schedule.lastError ?? null,
168329
+ previous_response: schedule.previousResponse ?? null,
168330
+ };
168331
+ }
168332
+ /**
168333
+ * Enterprise Knex-backed store for PostgreSQL, MySQL, and MSSQL
168334
+ */
168335
+ class KnexStoreBackend {
168336
+ knex = null;
168337
+ driver;
168338
+ connection;
168339
+ constructor(driver, storageConfig, _haConfig) {
168340
+ this.driver = driver;
168341
+ this.connection = (storageConfig.connection || {});
168342
+ }
168343
+ async initialize() {
168344
+ // Load knex dynamically
168345
+ const { createRequire } = __nccwpck_require__(73339);
168346
+ const runtimeRequire = createRequire(__filename);
168347
+ let knexFactory;
168348
+ try {
168349
+ knexFactory = runtimeRequire('knex');
168350
+ }
168351
+ catch (err) {
168352
+ const code = err?.code;
168353
+ if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
168354
+ throw new Error('knex is required for PostgreSQL/MySQL/MSSQL schedule storage. ' +
168355
+ 'Install it with: npm install knex');
168356
+ }
168357
+ throw err;
168358
+ }
168359
+ const clientMap = {
168360
+ postgresql: 'pg',
168361
+ mysql: 'mysql2',
168362
+ mssql: 'tedious',
168363
+ };
168364
+ const client = clientMap[this.driver];
168365
+ // Build connection config
168366
+ let connection;
168367
+ if (this.connection.connection_string) {
168368
+ connection = this.connection.connection_string;
168369
+ }
168370
+ else if (this.driver === 'mssql') {
168371
+ connection = this.buildMssqlConnection();
168372
+ }
168373
+ else {
168374
+ connection = this.buildStandardConnection();
168375
+ }
168376
+ this.knex = knexFactory({
168377
+ client,
168378
+ connection,
168379
+ pool: {
168380
+ min: this.connection.pool?.min ?? 0,
168381
+ max: this.connection.pool?.max ?? 10,
168382
+ },
168383
+ });
168384
+ // Run schema migration
168385
+ await this.migrateSchema();
168386
+ logger_1.logger.info(`[KnexStore] Initialized (${this.driver})`);
168387
+ }
168388
+ buildStandardConnection() {
168389
+ return {
168390
+ host: this.connection.host || 'localhost',
168391
+ port: this.connection.port,
168392
+ database: this.connection.database || 'visor',
168393
+ user: this.connection.user,
168394
+ password: this.connection.password,
168395
+ ssl: this.resolveSslConfig(),
168396
+ };
168397
+ }
168398
+ buildMssqlConnection() {
168399
+ const ssl = this.connection.ssl;
168400
+ const sslEnabled = ssl === true || (typeof ssl === 'object' && ssl.enabled !== false);
168401
+ return {
168402
+ server: this.connection.host || 'localhost',
168403
+ port: this.connection.port,
168404
+ database: this.connection.database || 'visor',
168405
+ user: this.connection.user,
168406
+ password: this.connection.password,
168407
+ options: {
168408
+ encrypt: sslEnabled,
168409
+ trustServerCertificate: typeof ssl === 'object' ? ssl.reject_unauthorized === false : !sslEnabled,
168410
+ },
168411
+ };
168412
+ }
168413
+ resolveSslConfig() {
168414
+ const ssl = this.connection.ssl;
168415
+ if (ssl === false || ssl === undefined)
168416
+ return false;
168417
+ if (ssl === true)
168418
+ return { rejectUnauthorized: true };
168419
+ // Object config
168420
+ if (ssl.enabled === false)
168421
+ return false;
168422
+ const result = {
168423
+ rejectUnauthorized: ssl.reject_unauthorized !== false,
168424
+ };
168425
+ if (ssl.ca) {
168426
+ const caPath = this.validateSslPath(ssl.ca, 'CA certificate');
168427
+ result.ca = fs.readFileSync(caPath, 'utf8');
168428
+ }
168429
+ if (ssl.cert) {
168430
+ const certPath = this.validateSslPath(ssl.cert, 'client certificate');
168431
+ result.cert = fs.readFileSync(certPath, 'utf8');
168432
+ }
168433
+ if (ssl.key) {
168434
+ const keyPath = this.validateSslPath(ssl.key, 'client key');
168435
+ result.key = fs.readFileSync(keyPath, 'utf8');
168436
+ }
168437
+ return result;
168438
+ }
168439
+ validateSslPath(filePath, label) {
168440
+ const resolved = path.resolve(filePath);
168441
+ if (resolved !== path.normalize(resolved)) {
168442
+ throw new Error(`SSL ${label} path contains invalid sequences: ${filePath}`);
168443
+ }
168444
+ if (!fs.existsSync(resolved)) {
168445
+ throw new Error(`SSL ${label} not found: ${filePath}`);
168446
+ }
168447
+ return resolved;
168448
+ }
168449
+ async shutdown() {
168450
+ if (this.knex) {
168451
+ await this.knex.destroy();
168452
+ this.knex = null;
168453
+ }
168454
+ }
168455
+ async migrateSchema() {
168456
+ const knex = this.getKnex();
168457
+ const exists = await knex.schema.hasTable('schedules');
168458
+ if (!exists) {
168459
+ await knex.schema.createTable('schedules', table => {
168460
+ table.string('id', 36).primary();
168461
+ table.string('creator_id', 255).notNullable().index();
168462
+ table.string('creator_context', 255);
168463
+ table.string('creator_name', 255);
168464
+ table.string('timezone', 64).notNullable().defaultTo('UTC');
168465
+ table.string('schedule_expr', 255);
168466
+ table.bigInteger('run_at');
168467
+ table.boolean('is_recurring').notNullable();
168468
+ table.text('original_expression');
168469
+ table.string('workflow', 255);
168470
+ table.text('workflow_inputs');
168471
+ table.text('output_context');
168472
+ table.string('status', 20).notNullable().index();
168473
+ table.bigInteger('created_at').notNullable();
168474
+ table.bigInteger('last_run_at');
168475
+ table.bigInteger('next_run_at');
168476
+ table.integer('run_count').notNullable().defaultTo(0);
168477
+ table.integer('failure_count').notNullable().defaultTo(0);
168478
+ table.text('last_error');
168479
+ table.text('previous_response');
168480
+ table.index(['status', 'next_run_at']);
168481
+ });
168482
+ }
168483
+ // Create scheduler_locks table for distributed locking
168484
+ const locksExist = await knex.schema.hasTable('scheduler_locks');
168485
+ if (!locksExist) {
168486
+ await knex.schema.createTable('scheduler_locks', table => {
168487
+ table.string('lock_id', 255).primary();
168488
+ table.string('node_id', 255).notNullable();
168489
+ table.string('lock_token', 36).notNullable();
168490
+ table.bigInteger('acquired_at').notNullable();
168491
+ table.bigInteger('expires_at').notNullable();
168492
+ });
168493
+ }
168494
+ }
168495
+ getKnex() {
168496
+ if (!this.knex) {
168497
+ throw new Error('[KnexStore] Not initialized. Call initialize() first.');
168498
+ }
168499
+ return this.knex;
168500
+ }
168501
+ // --- CRUD ---
168502
+ async create(schedule) {
168503
+ const knex = this.getKnex();
168504
+ const newSchedule = {
168505
+ ...schedule,
168506
+ id: (0, uuid_1.v4)(),
168507
+ createdAt: Date.now(),
168508
+ runCount: 0,
168509
+ failureCount: 0,
168510
+ status: 'active',
168511
+ };
168512
+ await knex('schedules').insert(toInsertRow(newSchedule));
168513
+ logger_1.logger.info(`[KnexStore] Created schedule ${newSchedule.id} for user ${newSchedule.creatorId}`);
168514
+ return newSchedule;
168515
+ }
168516
+ async importSchedule(schedule) {
168517
+ const knex = this.getKnex();
168518
+ const existing = await knex('schedules').where('id', schedule.id).first();
168519
+ if (existing)
168520
+ return; // Already imported (idempotent)
168521
+ await knex('schedules').insert(toInsertRow(schedule));
168522
+ }
168523
+ async get(id) {
168524
+ const knex = this.getKnex();
168525
+ const row = await knex('schedules').where('id', id).first();
168526
+ return row ? fromDbRow(row) : undefined;
168527
+ }
168528
+ async update(id, patch) {
168529
+ const knex = this.getKnex();
168530
+ const existing = await knex('schedules').where('id', id).first();
168531
+ if (!existing)
168532
+ return undefined;
168533
+ const current = fromDbRow(existing);
168534
+ const updated = { ...current, ...patch, id: current.id };
168535
+ const row = toInsertRow(updated);
168536
+ // Remove id from update (PK cannot change)
168537
+ delete row.id;
168538
+ await knex('schedules').where('id', id).update(row);
168539
+ return updated;
168540
+ }
168541
+ async delete(id) {
168542
+ const knex = this.getKnex();
168543
+ const deleted = await knex('schedules').where('id', id).del();
168544
+ if (deleted > 0) {
168545
+ logger_1.logger.info(`[KnexStore] Deleted schedule ${id}`);
168546
+ return true;
168547
+ }
168548
+ return false;
168549
+ }
168550
+ // --- Queries ---
168551
+ async getByCreator(creatorId) {
168552
+ const knex = this.getKnex();
168553
+ const rows = await knex('schedules').where('creator_id', creatorId);
168554
+ return rows.map((r) => fromDbRow(r));
168555
+ }
168556
+ async getActiveSchedules() {
168557
+ const knex = this.getKnex();
168558
+ const rows = await knex('schedules').where('status', 'active');
168559
+ return rows.map((r) => fromDbRow(r));
168560
+ }
168561
+ async getDueSchedules(now) {
168562
+ const ts = now ?? Date.now();
168563
+ const knex = this.getKnex();
168564
+ // MSSQL uses 1/0 for booleans
168565
+ const bFalse = this.driver === 'mssql' ? 0 : false;
168566
+ const bTrue = this.driver === 'mssql' ? 1 : true;
168567
+ const rows = await knex('schedules')
168568
+ .where('status', 'active')
168569
+ .andWhere(function () {
168570
+ this.where(function () {
168571
+ this.where('is_recurring', bFalse)
168572
+ .whereNotNull('run_at')
168573
+ .where('run_at', '<=', ts);
168574
+ }).orWhere(function () {
168575
+ this.where('is_recurring', bTrue)
168576
+ .whereNotNull('next_run_at')
168577
+ .where('next_run_at', '<=', ts);
168578
+ });
168579
+ });
168580
+ return rows.map((r) => fromDbRow(r));
168581
+ }
168582
+ async findByWorkflow(creatorId, workflowName) {
168583
+ const knex = this.getKnex();
168584
+ const escaped = workflowName.toLowerCase().replace(/[%_\\]/g, '\\$&');
168585
+ const pattern = `%${escaped}%`;
168586
+ const rows = await knex('schedules')
168587
+ .where('creator_id', creatorId)
168588
+ .where('status', 'active')
168589
+ .whereRaw("LOWER(workflow) LIKE ? ESCAPE '\\'", [pattern]);
168590
+ return rows.map((r) => fromDbRow(r));
168591
+ }
168592
+ async getAll() {
168593
+ const knex = this.getKnex();
168594
+ const rows = await knex('schedules');
168595
+ return rows.map((r) => fromDbRow(r));
168596
+ }
168597
+ async getStats() {
168598
+ const knex = this.getKnex();
168599
+ // MSSQL uses 1/0 for booleans; PostgreSQL/MySQL accept both true/1
168600
+ const boolTrue = this.driver === 'mssql' ? '1' : 'true';
168601
+ const boolFalse = this.driver === 'mssql' ? '0' : 'false';
168602
+ const result = await knex('schedules')
168603
+ .select(knex.raw('COUNT(*) as total'), knex.raw("SUM(CASE WHEN status = 'active' THEN 1 ELSE 0 END) as active"), knex.raw("SUM(CASE WHEN status = 'paused' THEN 1 ELSE 0 END) as paused"), knex.raw("SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed"), knex.raw("SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) as failed"), knex.raw(`SUM(CASE WHEN is_recurring = ${boolTrue} THEN 1 ELSE 0 END) as recurring`), knex.raw(`SUM(CASE WHEN is_recurring = ${boolFalse} THEN 1 ELSE 0 END) as one_time`))
168604
+ .first();
168605
+ return {
168606
+ total: Number(result.total) || 0,
168607
+ active: Number(result.active) || 0,
168608
+ paused: Number(result.paused) || 0,
168609
+ completed: Number(result.completed) || 0,
168610
+ failed: Number(result.failed) || 0,
168611
+ recurring: Number(result.recurring) || 0,
168612
+ oneTime: Number(result.one_time) || 0,
168613
+ };
168614
+ }
168615
+ async validateLimits(creatorId, isRecurring, limits) {
168616
+ const knex = this.getKnex();
168617
+ if (limits.maxGlobal) {
168618
+ const result = await knex('schedules').count('* as cnt').first();
168619
+ if (Number(result?.cnt) >= limits.maxGlobal) {
168620
+ throw new Error(`Global schedule limit reached (${limits.maxGlobal})`);
168621
+ }
168622
+ }
168623
+ if (limits.maxPerUser) {
168624
+ const result = await knex('schedules')
168625
+ .where('creator_id', creatorId)
168626
+ .count('* as cnt')
168627
+ .first();
168628
+ if (Number(result?.cnt) >= limits.maxPerUser) {
168629
+ throw new Error(`You have reached the maximum number of schedules (${limits.maxPerUser})`);
168630
+ }
168631
+ }
168632
+ if (isRecurring && limits.maxRecurringPerUser) {
168633
+ const bTrue = this.driver === 'mssql' ? 1 : true;
168634
+ const result = await knex('schedules')
168635
+ .where('creator_id', creatorId)
168636
+ .where('is_recurring', bTrue)
168637
+ .count('* as cnt')
168638
+ .first();
168639
+ if (Number(result?.cnt) >= limits.maxRecurringPerUser) {
168640
+ throw new Error(`You have reached the maximum number of recurring schedules (${limits.maxRecurringPerUser})`);
168641
+ }
168642
+ }
168643
+ }
168644
+ // --- HA Distributed Locking (via scheduler_locks table) ---
168645
+ async tryAcquireLock(lockId, nodeId, ttlSeconds) {
168646
+ const knex = this.getKnex();
168647
+ const now = Date.now();
168648
+ const expiresAt = now + ttlSeconds * 1000;
168649
+ const token = (0, uuid_1.v4)();
168650
+ // Step 1: Try to claim an existing expired lock
168651
+ const updated = await knex('scheduler_locks')
168652
+ .where('lock_id', lockId)
168653
+ .where('expires_at', '<', now)
168654
+ .update({
168655
+ node_id: nodeId,
168656
+ lock_token: token,
168657
+ acquired_at: now,
168658
+ expires_at: expiresAt,
168659
+ });
168660
+ if (updated > 0)
168661
+ return token;
168662
+ // Step 2: Try to INSERT a new lock row
168663
+ try {
168664
+ await knex('scheduler_locks').insert({
168665
+ lock_id: lockId,
168666
+ node_id: nodeId,
168667
+ lock_token: token,
168668
+ acquired_at: now,
168669
+ expires_at: expiresAt,
168670
+ });
168671
+ return token;
168672
+ }
168673
+ catch {
168674
+ // Unique constraint violation — another node holds the lock
168675
+ return null;
168676
+ }
168677
+ }
168678
+ async releaseLock(lockId, lockToken) {
168679
+ const knex = this.getKnex();
168680
+ await knex('scheduler_locks').where('lock_id', lockId).where('lock_token', lockToken).del();
168681
+ }
168682
+ async renewLock(lockId, lockToken, ttlSeconds) {
168683
+ const knex = this.getKnex();
168684
+ const now = Date.now();
168685
+ const expiresAt = now + ttlSeconds * 1000;
168686
+ const updated = await knex('scheduler_locks')
168687
+ .where('lock_id', lockId)
168688
+ .where('lock_token', lockToken)
168689
+ .update({ acquired_at: now, expires_at: expiresAt });
168690
+ return updated > 0;
168691
+ }
168692
+ async flush() {
168693
+ // No-op for server-based backends
168694
+ }
168695
+ }
168696
+ exports.KnexStoreBackend = KnexStoreBackend;
168697
+
168698
+
166983
168699
  /***/ }),
166984
168700
 
166985
168701
  /***/ 83864:
@@ -171448,6 +173164,11 @@ exports.configSchema = {
171448
173164
  SandboxConfig: {
171449
173165
  type: 'object',
171450
173166
  properties: {
173167
+ engine: {
173168
+ type: 'string',
173169
+ enum: ['docker', 'bubblewrap', 'seatbelt'],
173170
+ description: "Sandbox engine type: 'docker' (default), 'bubblewrap' (Linux namespaces), or 'seatbelt' (macOS sandbox-exec)",
173171
+ },
171451
173172
  image: {
171452
173173
  type: 'string',
171453
173174
  description: 'Docker image to use (e.g., "node:20-alpine")',
@@ -177656,6 +179377,35 @@ class OutputFormatters {
177656
179377
  exports.OutputFormatters = OutputFormatters;
177657
179378
 
177658
179379
 
179380
+ /***/ }),
179381
+
179382
+ /***/ 93866:
179383
+ /***/ ((__unused_webpack_module, exports) => {
179384
+
179385
+ "use strict";
179386
+
179387
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
179388
+ exports.DefaultPolicyEngine = void 0;
179389
+ /**
179390
+ * Default (no-op) policy engine — always allows everything.
179391
+ * Used when no enterprise license is present or policy is disabled.
179392
+ */
179393
+ class DefaultPolicyEngine {
179394
+ async initialize(_config) { }
179395
+ async evaluateCheckExecution(_checkId, _checkConfig) {
179396
+ return { allowed: true };
179397
+ }
179398
+ async evaluateToolInvocation(_serverName, _methodName, _transport) {
179399
+ return { allowed: true };
179400
+ }
179401
+ async evaluateCapabilities(_checkId, _capabilities) {
179402
+ return { allowed: true };
179403
+ }
179404
+ async shutdown() { }
179405
+ }
179406
+ exports.DefaultPolicyEngine = DefaultPolicyEngine;
179407
+
179408
+
177659
179409
  /***/ }),
177660
179410
 
177661
179411
  /***/ 96611:
@@ -186591,6 +188341,7 @@ class McpCheckProvider extends check_provider_interface_1.CheckProvider {
186591
188341
  outputs: this.buildOutputContext(dependencyResults),
186592
188342
  args: sessionInfo?.args || {},
186593
188343
  env: this.getSafeEnvironmentVariables(),
188344
+ inputs: config.workflowInputs || sessionInfo?.workflowInputs || {},
186594
188345
  };
186595
188346
  // Render method arguments if needed
186596
188347
  let methodArgs = cfg.methodArgs || {};
@@ -190152,6 +191903,150 @@ class PRReviewer {
190152
191903
  exports.PRReviewer = PRReviewer;
190153
191904
 
190154
191905
 
191906
+ /***/ }),
191907
+
191908
+ /***/ 11207:
191909
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
191910
+
191911
+ "use strict";
191912
+
191913
+ /**
191914
+ * Bubblewrap-based sandbox implementation.
191915
+ * Uses Linux kernel namespaces for lightweight process isolation (~5-50ms overhead).
191916
+ * Requires the `bwrap` binary to be installed on the host.
191917
+ */
191918
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
191919
+ exports.BubblewrapSandbox = void 0;
191920
+ const util_1 = __nccwpck_require__(39023);
191921
+ const child_process_1 = __nccwpck_require__(35317);
191922
+ const fs_1 = __nccwpck_require__(79896);
191923
+ const path_1 = __nccwpck_require__(16928);
191924
+ const logger_1 = __nccwpck_require__(86999);
191925
+ const sandbox_telemetry_1 = __nccwpck_require__(34826);
191926
+ const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
191927
+ const EXEC_MAX_BUFFER = 50 * 1024 * 1024; // 50MB
191928
+ class BubblewrapSandbox {
191929
+ name;
191930
+ config;
191931
+ repoPath;
191932
+ constructor(name, config, repoPath) {
191933
+ this.name = name;
191934
+ this.config = config;
191935
+ this.repoPath = (0, path_1.resolve)(repoPath);
191936
+ }
191937
+ /**
191938
+ * Check if bwrap binary is available on the system.
191939
+ */
191940
+ static async isAvailable() {
191941
+ try {
191942
+ await execFileAsync('which', ['bwrap'], { timeout: 5000 });
191943
+ return true;
191944
+ }
191945
+ catch {
191946
+ return false;
191947
+ }
191948
+ }
191949
+ /**
191950
+ * Execute a command inside a bubblewrap sandbox.
191951
+ * Each exec creates a fresh namespace — no persistent container.
191952
+ */
191953
+ async exec(options) {
191954
+ const args = this.buildArgs(options);
191955
+ args.push('--', '/bin/sh', '-c', options.command);
191956
+ logger_1.logger.debug(`[BubblewrapSandbox] Executing in sandbox '${this.name}': ${options.command.slice(0, 100)}`);
191957
+ try {
191958
+ const { stdout, stderr } = await execFileAsync('bwrap', args, {
191959
+ maxBuffer: options.maxBuffer || EXEC_MAX_BUFFER,
191960
+ timeout: options.timeoutMs || 600000,
191961
+ });
191962
+ (0, sandbox_telemetry_1.addEvent)('visor.sandbox.bwrap.exec', {
191963
+ 'visor.sandbox.name': this.name,
191964
+ 'visor.sandbox.exit_code': 0,
191965
+ });
191966
+ return { stdout, stderr, exitCode: 0 };
191967
+ }
191968
+ catch (err) {
191969
+ const execErr = err;
191970
+ const exitCode = typeof execErr.code === 'number' ? execErr.code : 1;
191971
+ (0, sandbox_telemetry_1.addEvent)('visor.sandbox.bwrap.exec', {
191972
+ 'visor.sandbox.name': this.name,
191973
+ 'visor.sandbox.exit_code': exitCode,
191974
+ });
191975
+ return {
191976
+ stdout: execErr.stdout || '',
191977
+ stderr: execErr.stderr || '',
191978
+ exitCode,
191979
+ };
191980
+ }
191981
+ }
191982
+ /**
191983
+ * No-op: bubblewrap processes are ephemeral (no persistent container to stop).
191984
+ */
191985
+ async stop() {
191986
+ // Nothing to clean up — bwrap processes exit when the command finishes,
191987
+ // and --die-with-parent ensures cleanup if the parent dies.
191988
+ }
191989
+ /**
191990
+ * Build the bwrap command-line arguments.
191991
+ */
191992
+ buildArgs(options) {
191993
+ const workdir = this.config.workdir || '/workspace';
191994
+ const args = [];
191995
+ // Read-only system directories
191996
+ args.push('--ro-bind', '/usr', '/usr');
191997
+ args.push('--ro-bind', '/bin', '/bin');
191998
+ // /lib and /lib64 may not exist on all distros (e.g., Alpine uses /usr/lib)
191999
+ if ((0, fs_1.existsSync)('/lib')) {
192000
+ args.push('--ro-bind', '/lib', '/lib');
192001
+ }
192002
+ if ((0, fs_1.existsSync)('/lib64')) {
192003
+ args.push('--ro-bind', '/lib64', '/lib64');
192004
+ }
192005
+ // DNS resolution and TLS certificates
192006
+ if ((0, fs_1.existsSync)('/etc/resolv.conf')) {
192007
+ args.push('--ro-bind', '/etc/resolv.conf', '/etc/resolv.conf');
192008
+ }
192009
+ if ((0, fs_1.existsSync)('/etc/ssl')) {
192010
+ args.push('--ro-bind', '/etc/ssl', '/etc/ssl');
192011
+ }
192012
+ // Virtual filesystems
192013
+ args.push('--dev', '/dev');
192014
+ args.push('--proc', '/proc');
192015
+ args.push('--tmpfs', '/tmp');
192016
+ args.push('--tmpfs', '/root');
192017
+ // Workspace mount — the only writable directory (unless read_only)
192018
+ if (this.config.read_only) {
192019
+ args.push('--ro-bind', this.repoPath, workdir);
192020
+ }
192021
+ else {
192022
+ args.push('--bind', this.repoPath, workdir);
192023
+ }
192024
+ // Working directory inside sandbox
192025
+ args.push('--chdir', workdir);
192026
+ // Namespace isolation
192027
+ args.push('--unshare-pid');
192028
+ args.push('--new-session');
192029
+ args.push('--die-with-parent');
192030
+ // Network isolation
192031
+ if (this.config.network === false) {
192032
+ args.push('--unshare-net');
192033
+ }
192034
+ // Clean environment — only explicitly passed vars are visible
192035
+ args.push('--clearenv');
192036
+ // Pass filtered environment variables.
192037
+ // Safe: execFile passes each arg as a separate argv entry — no shell interpretation.
192038
+ for (const [key, value] of Object.entries(options.env)) {
192039
+ if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(key)) {
192040
+ throw new Error(`Invalid environment variable name: '${key}'`);
192041
+ }
192042
+ args.push('--setenv', key, value);
192043
+ }
192044
+ return args;
192045
+ }
192046
+ }
192047
+ exports.BubblewrapSandbox = BubblewrapSandbox;
192048
+
192049
+
190155
192050
  /***/ }),
190156
192051
 
190157
192052
  /***/ 10878:
@@ -190978,8 +192873,9 @@ function filterEnvForSandbox(checkEnv, hostEnv, passthroughPatterns, defaultPatt
190978
192873
  "use strict";
190979
192874
 
190980
192875
  /**
190981
- * SandboxManager — lifecycle management for Docker sandbox environments.
190982
- * Handles lazy container startup, reuse, exec routing, and cleanup.
192876
+ * SandboxManager — lifecycle management for sandbox environments.
192877
+ * Handles lazy container/process startup, reuse, exec routing, and cleanup.
192878
+ * Supports Docker (image, compose), Bubblewrap (Linux namespaces), and Seatbelt (macOS sandbox-exec) engines.
190983
192879
  */
190984
192880
  Object.defineProperty(exports, "__esModule", ({ value: true }));
190985
192881
  exports.SandboxManager = void 0;
@@ -191043,6 +192939,20 @@ class SandboxManager {
191043
192939
  throw new Error(`Sandbox '${name}' is not defined`);
191044
192940
  }
191045
192941
  const mode = config.compose ? 'compose' : 'image';
192942
+ // Bubblewrap engine: ephemeral per-exec, no persistent container
192943
+ if (config.engine === 'bubblewrap') {
192944
+ const { BubblewrapSandbox } = __nccwpck_require__(11207);
192945
+ const instance = new BubblewrapSandbox(name, config, this.repoPath);
192946
+ this.instances.set(name, instance);
192947
+ return instance;
192948
+ }
192949
+ // Seatbelt engine: macOS sandbox-exec, ephemeral per-exec
192950
+ if (config.engine === 'seatbelt') {
192951
+ const { SeatbeltSandbox } = __nccwpck_require__(46429);
192952
+ const instance = new SeatbeltSandbox(name, config, this.repoPath);
192953
+ this.instances.set(name, instance);
192954
+ return instance;
192955
+ }
191046
192956
  return (0, sandbox_telemetry_1.withActiveSpan)('visor.sandbox.start', {
191047
192957
  'visor.sandbox.name': name,
191048
192958
  'visor.sandbox.mode': mode,
@@ -191171,6 +193081,165 @@ function setSpanError(err) {
191171
193081
  }
191172
193082
 
191173
193083
 
193084
+ /***/ }),
193085
+
193086
+ /***/ 46429:
193087
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
193088
+
193089
+ "use strict";
193090
+
193091
+ /**
193092
+ * macOS Seatbelt sandbox implementation.
193093
+ * Uses Apple's sandbox-exec with dynamically-generated SBPL profiles
193094
+ * for lightweight process isolation on macOS.
193095
+ * Requires the `sandbox-exec` binary (ships with macOS).
193096
+ */
193097
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
193098
+ exports.SeatbeltSandbox = void 0;
193099
+ const util_1 = __nccwpck_require__(39023);
193100
+ const child_process_1 = __nccwpck_require__(35317);
193101
+ const path_1 = __nccwpck_require__(16928);
193102
+ const fs_1 = __nccwpck_require__(79896);
193103
+ const logger_1 = __nccwpck_require__(86999);
193104
+ const sandbox_telemetry_1 = __nccwpck_require__(34826);
193105
+ const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
193106
+ const EXEC_MAX_BUFFER = 50 * 1024 * 1024; // 50MB
193107
+ class SeatbeltSandbox {
193108
+ name;
193109
+ config;
193110
+ repoPath;
193111
+ constructor(name, config, repoPath) {
193112
+ this.name = name;
193113
+ this.config = config;
193114
+ // Resolve symlinks — macOS has /var → /private/var, /tmp → /private/tmp etc.
193115
+ // sandbox-exec operates on real paths, so we must resolve before building profiles.
193116
+ this.repoPath = (0, fs_1.realpathSync)((0, path_1.resolve)(repoPath));
193117
+ }
193118
+ /**
193119
+ * Check if sandbox-exec binary is available on the system.
193120
+ */
193121
+ static async isAvailable() {
193122
+ try {
193123
+ await execFileAsync('which', ['sandbox-exec'], { timeout: 5000 });
193124
+ return true;
193125
+ }
193126
+ catch {
193127
+ return false;
193128
+ }
193129
+ }
193130
+ /**
193131
+ * Execute a command inside a macOS seatbelt sandbox.
193132
+ * Each exec creates a fresh sandbox process — no persistent container.
193133
+ */
193134
+ async exec(options) {
193135
+ const profile = this.buildProfile();
193136
+ // Validate env var names
193137
+ for (const key of Object.keys(options.env)) {
193138
+ if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(key)) {
193139
+ throw new Error(`Invalid environment variable name: '${key}'`);
193140
+ }
193141
+ }
193142
+ // Build args: sandbox-exec -p '<profile>' /usr/bin/env -i KEY=VAL ... /bin/sh -c '<command>'
193143
+ const args = ['-p', profile];
193144
+ // Use env -i to clear inherited environment, then set explicit vars
193145
+ args.push('/usr/bin/env', '-i');
193146
+ for (const [key, value] of Object.entries(options.env)) {
193147
+ args.push(`${key}=${value}`);
193148
+ }
193149
+ args.push('/bin/sh', '-c', options.command);
193150
+ logger_1.logger.debug(`[SeatbeltSandbox] Executing in sandbox '${this.name}': ${options.command.slice(0, 100)}`);
193151
+ try {
193152
+ const { stdout, stderr } = await execFileAsync('sandbox-exec', args, {
193153
+ maxBuffer: options.maxBuffer || EXEC_MAX_BUFFER,
193154
+ timeout: options.timeoutMs || 600000,
193155
+ cwd: this.repoPath,
193156
+ });
193157
+ (0, sandbox_telemetry_1.addEvent)('visor.sandbox.seatbelt.exec', {
193158
+ 'visor.sandbox.name': this.name,
193159
+ 'visor.sandbox.exit_code': 0,
193160
+ });
193161
+ return { stdout, stderr, exitCode: 0 };
193162
+ }
193163
+ catch (err) {
193164
+ const execErr = err;
193165
+ const exitCode = typeof execErr.code === 'number' ? execErr.code : 1;
193166
+ (0, sandbox_telemetry_1.addEvent)('visor.sandbox.seatbelt.exec', {
193167
+ 'visor.sandbox.name': this.name,
193168
+ 'visor.sandbox.exit_code': exitCode,
193169
+ });
193170
+ return {
193171
+ stdout: execErr.stdout || '',
193172
+ stderr: execErr.stderr || '',
193173
+ exitCode,
193174
+ };
193175
+ }
193176
+ }
193177
+ /**
193178
+ * No-op: sandbox-exec processes are ephemeral (no persistent container to stop).
193179
+ */
193180
+ async stop() {
193181
+ // Nothing to clean up — sandbox-exec processes exit when the command finishes.
193182
+ }
193183
+ /**
193184
+ * Escape a path for use inside an SBPL profile string.
193185
+ * Escapes backslashes and double quotes.
193186
+ */
193187
+ escapePath(p) {
193188
+ return p.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
193189
+ }
193190
+ /**
193191
+ * Build the SBPL (Seatbelt Profile Language) profile string.
193192
+ */
193193
+ buildProfile() {
193194
+ const repoPath = this.escapePath(this.repoPath);
193195
+ const lines = [];
193196
+ lines.push('(version 1)');
193197
+ lines.push('(deny default)');
193198
+ // Allow basic process execution
193199
+ lines.push('(allow process-exec)');
193200
+ lines.push('(allow process-fork)');
193201
+ // Allow read access to system paths.
193202
+ // macOS uses symlinks: /var → /private/var, /tmp → /private/tmp, /etc → /private/etc.
193203
+ // We include both the symlink paths and /private to cover resolution.
193204
+ lines.push('(allow file-read*');
193205
+ lines.push(' (literal "/")');
193206
+ lines.push(' (subpath "/usr")');
193207
+ lines.push(' (subpath "/bin")');
193208
+ lines.push(' (subpath "/sbin")');
193209
+ lines.push(' (subpath "/Library")');
193210
+ lines.push(' (subpath "/System")');
193211
+ lines.push(' (subpath "/private")');
193212
+ lines.push(' (subpath "/var")');
193213
+ lines.push(' (subpath "/etc")');
193214
+ lines.push(' (subpath "/dev")');
193215
+ lines.push(' (subpath "/tmp"))');
193216
+ // Allow write to /tmp and /dev
193217
+ lines.push('(allow file-write*');
193218
+ lines.push(' (subpath "/tmp")');
193219
+ lines.push(' (subpath "/private/tmp")');
193220
+ lines.push(' (subpath "/dev"))');
193221
+ // Allow xcrun cache writes (macOS git/Xcode tools write to /var/folders/.../T/xcrun_db-*)
193222
+ lines.push('(allow file-write* (regex #"/private/var/folders/.*/T/xcrun_db"))');
193223
+ // Workspace read access
193224
+ lines.push(`(allow file-read* (subpath "${repoPath}"))`);
193225
+ // Workspace write access (unless read_only)
193226
+ if (!this.config.read_only) {
193227
+ lines.push(`(allow file-write* (subpath "${repoPath}"))`);
193228
+ }
193229
+ // Network access (unless explicitly disabled)
193230
+ if (this.config.network !== false) {
193231
+ lines.push('(allow network*)');
193232
+ }
193233
+ // Allow sysctl, mach lookups, signal for basic process operation
193234
+ lines.push('(allow sysctl-read)');
193235
+ lines.push('(allow mach-lookup)');
193236
+ lines.push('(allow signal)');
193237
+ return lines.join('\n');
193238
+ }
193239
+ }
193240
+ exports.SeatbeltSandbox = SeatbeltSandbox;
193241
+
193242
+
191174
193243
  /***/ }),
191175
193244
 
191176
193245
  /***/ 50504:
@@ -196743,7 +198812,9 @@ const cache_prewarmer_1 = __nccwpck_require__(50200);
196743
198812
  const rate_limiter_1 = __nccwpck_require__(53065);
196744
198813
  const trace_helpers_1 = __nccwpck_require__(75338);
196745
198814
  const scheduler_1 = __nccwpck_require__(28404);
198815
+ const crypto_1 = __nccwpck_require__(76982);
196746
198816
  const slack_output_adapter_1 = __nccwpck_require__(45330);
198817
+ const workspace_manager_1 = __nccwpck_require__(6134);
196747
198818
  class SlackSocketRunner {
196748
198819
  appToken;
196749
198820
  endpoint;
@@ -196874,6 +198945,8 @@ class SlackSocketRunner {
196874
198945
  }
196875
198946
  const url = await this.openConnection();
196876
198947
  await this.connect(url);
198948
+ // Clean up stale workspace directories from previous runs
198949
+ workspace_manager_1.WorkspaceManager.cleanupStale().catch(() => { });
196877
198950
  }
196878
198951
  async openConnection() {
196879
198952
  const resp = await fetch('https://slack.com/api/apps.connections.open', {
@@ -197169,6 +199242,22 @@ class SlackSocketRunner {
197169
199242
  return this.cfg;
197170
199243
  }
197171
199244
  })();
199245
+ // Derive stable workspace name from Slack thread identity so all messages
199246
+ // in the same thread share the same workspace directory (git checkouts persist).
199247
+ const wsChannel = String(ev.channel || '');
199248
+ const wsThreadTs = String(ev.thread_ts || ev.ts || ev.event_ts || '');
199249
+ if (wsChannel && wsThreadTs) {
199250
+ const hash = (0, crypto_1.createHash)('sha256')
199251
+ .update(`${wsChannel}:${wsThreadTs}`)
199252
+ .digest('hex')
199253
+ .slice(0, 8);
199254
+ const workspaceName = `slack-${hash}`;
199255
+ if (!cfgForRun.workspace) {
199256
+ cfgForRun.workspace = {};
199257
+ }
199258
+ cfgForRun.workspace.name = workspaceName;
199259
+ cfgForRun.workspace.cleanup_on_exit = false;
199260
+ }
197172
199261
  // Seed first message for this thread to allow initial human-input to consume it exactly once
197173
199262
  try {
197174
199263
  const { getPromptStateManager } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(27716)));
@@ -197910,7 +199999,7 @@ class StateMachineExecutionEngine {
197910
199999
  try {
197911
200000
  logger_1.logger.debug(`[PolicyEngine] Loading enterprise policy engine (engine=${configWithTagFilter.policy.engine})`);
197912
200001
  // @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
197913
- const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(7065)));
200002
+ const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(87068)));
197914
200003
  context.policyEngine = await loadEnterprisePolicyEngine(configWithTagFilter.policy);
197915
200004
  logger_1.logger.debug(`[PolicyEngine] Initialized: ${context.policyEngine?.constructor?.name || 'unknown'}`);
197916
200005
  }
@@ -208174,7 +210263,7 @@ async function initTelemetry(opts = {}) {
208174
210263
  const path = __nccwpck_require__(16928);
208175
210264
  const outDir = opts.file?.dir ||
208176
210265
  process.env.VISOR_TRACE_DIR ||
208177
- __nccwpck_require__.ab + "traces";
210266
+ path.join(process.cwd(), 'output', 'traces');
208178
210267
  fs.mkdirSync(outDir, { recursive: true });
208179
210268
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
208180
210269
  process.env.VISOR_FALLBACK_TRACE_FILE = path.join(outDir, `run-${ts}.ndjson`);
@@ -208379,7 +210468,7 @@ async function shutdownTelemetry() {
208379
210468
  if (process.env.VISOR_TRACE_REPORT === 'true') {
208380
210469
  const fs = __nccwpck_require__(79896);
208381
210470
  const path = __nccwpck_require__(16928);
208382
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
210471
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
208383
210472
  if (!fs.existsSync(outDir))
208384
210473
  fs.mkdirSync(outDir, { recursive: true });
208385
210474
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
@@ -208878,7 +210967,7 @@ function __getOrCreateNdjsonPath() {
208878
210967
  fs.mkdirSync(dir, { recursive: true });
208879
210968
  return __ndjsonPath;
208880
210969
  }
208881
- const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
210970
+ const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
208882
210971
  if (!fs.existsSync(outDir))
208883
210972
  fs.mkdirSync(outDir, { recursive: true });
208884
210973
  if (!__ndjsonPath) {
@@ -220309,17 +222398,36 @@ class WorkspaceManager {
220309
222398
  // Check if original path is a git repository
220310
222399
  const isGitRepo = await this.isGitRepository(this.originalPath);
220311
222400
  if (isGitRepo) {
220312
- // Create worktree for main project
220313
- await this.createMainProjectWorktree(mainProjectPath);
222401
+ // Check if main project worktree already exists (reused workspace, e.g. Slack thread)
222402
+ const exists = await this.pathExists(mainProjectPath);
222403
+ if (exists) {
222404
+ logger_1.logger.info(`[Workspace] Reusing existing main project worktree: ${mainProjectPath}`);
222405
+ const isValid = await this.isGitRepository(mainProjectPath);
222406
+ if (!isValid) {
222407
+ logger_1.logger.warn(`[Workspace] Existing path is not a valid git dir, recreating`);
222408
+ await fsp.rm(mainProjectPath, { recursive: true, force: true });
222409
+ try {
222410
+ await command_executor_1.commandExecutor.execute(`git -C ${shellEscape(this.originalPath)} worktree prune`, { timeout: 10000 });
222411
+ }
222412
+ catch { }
222413
+ await this.createMainProjectWorktree(mainProjectPath);
222414
+ }
222415
+ }
222416
+ else {
222417
+ await this.createMainProjectWorktree(mainProjectPath);
222418
+ }
220314
222419
  }
220315
222420
  else {
220316
222421
  // If not a git repo, create a symlink instead
220317
222422
  logger_1.logger.debug(`Original path is not a git repo, creating symlink`);
220318
- try {
220319
- await fsp.symlink(this.originalPath, mainProjectPath);
220320
- }
220321
- catch (error) {
220322
- throw new Error(`Failed to create symlink for main project: ${error}`);
222423
+ const exists = await this.pathExists(mainProjectPath);
222424
+ if (!exists) {
222425
+ try {
222426
+ await fsp.symlink(this.originalPath, mainProjectPath);
222427
+ }
222428
+ catch (error) {
222429
+ throw new Error(`Failed to create symlink for main project: ${error}`);
222430
+ }
220323
222431
  }
220324
222432
  }
220325
222433
  // Register cleanup handlers
@@ -220389,6 +222497,16 @@ class WorkspaceManager {
220389
222497
  * @param timeout Maximum time to wait for active operations (default: 60s)
220390
222498
  */
220391
222499
  async cleanup(timeout = 60000) {
222500
+ // Respect cleanupOnExit flag — persisted workspaces (e.g. Slack threads) should not be cleaned up
222501
+ if (!this.config.cleanupOnExit) {
222502
+ logger_1.logger.debug(`[Workspace] Skipping cleanup (cleanupOnExit=false): ${this.workspacePath}`);
222503
+ WorkspaceManager.instances.delete(this.sessionId);
222504
+ this.initialized = false;
222505
+ this.mainProjectInfo = null;
222506
+ this.projects.clear();
222507
+ this.usedNames.clear();
222508
+ return;
222509
+ }
220392
222510
  logger_1.logger.info(`Cleaning up workspace: ${this.workspacePath} (active operations: ${this.activeOperations})`);
220393
222511
  // If there are active operations, wait for them to complete
220394
222512
  if (this.activeOperations > 0) {
@@ -220444,6 +222562,70 @@ class WorkspaceManager {
220444
222562
  logger_1.logger.warn(`Failed to cleanup workspace: ${error}`);
220445
222563
  }
220446
222564
  }
222565
+ /**
222566
+ * Check if a path exists (file or directory).
222567
+ */
222568
+ async pathExists(p) {
222569
+ try {
222570
+ await fsp.access(p);
222571
+ return true;
222572
+ }
222573
+ catch {
222574
+ return false;
222575
+ }
222576
+ }
222577
+ /**
222578
+ * Clean up stale workspace directories older than maxAge.
222579
+ * Call periodically (e.g. at socket-runner startup) to prevent disk bloat.
222580
+ */
222581
+ static async cleanupStale(basePath = process.env.VISOR_WORKSPACE_PATH || '/tmp/visor-workspaces', maxAgeMs = 24 * 60 * 60 * 1000) {
222582
+ let cleaned = 0;
222583
+ try {
222584
+ const entries = await fsp.readdir(basePath, { withFileTypes: true });
222585
+ const now = Date.now();
222586
+ for (const entry of entries) {
222587
+ if (!entry.isDirectory())
222588
+ continue;
222589
+ const dirPath = path.join(basePath, entry.name);
222590
+ try {
222591
+ const stat = await fsp.stat(dirPath);
222592
+ if (now - stat.mtimeMs > maxAgeMs) {
222593
+ // Prune any git worktrees before removing the directory
222594
+ try {
222595
+ const subdirs = await fsp.readdir(dirPath, { withFileTypes: true });
222596
+ for (const sub of subdirs) {
222597
+ if (!sub.isDirectory())
222598
+ continue;
222599
+ const subPath = path.join(dirPath, sub.name);
222600
+ const gitFilePath = path.join(subPath, '.git');
222601
+ try {
222602
+ const gitContent = await fsp.readFile(gitFilePath, 'utf-8');
222603
+ const match = gitContent.match(/gitdir:\s*(.+)/);
222604
+ if (match) {
222605
+ const worktreeGitDir = match[1].trim();
222606
+ const repoGitDir = worktreeGitDir.replace(/\/\.git\/worktrees\/.*$/, '');
222607
+ await command_executor_1.commandExecutor.execute(`git -C ${shellEscape(repoGitDir)} worktree remove ${shellEscape(subPath)} --force`, { timeout: 10000 });
222608
+ }
222609
+ }
222610
+ catch { }
222611
+ }
222612
+ }
222613
+ catch { }
222614
+ await fsp.rm(dirPath, { recursive: true, force: true });
222615
+ cleaned++;
222616
+ }
222617
+ }
222618
+ catch { }
222619
+ }
222620
+ if (cleaned > 0) {
222621
+ logger_1.logger.info(`[Workspace] Cleaned up ${cleaned} stale workspace(s) from ${basePath}`);
222622
+ }
222623
+ }
222624
+ catch (error) {
222625
+ logger_1.logger.debug(`[Workspace] Stale cleanup error: ${error}`);
222626
+ }
222627
+ return cleaned;
222628
+ }
220447
222629
  /**
220448
222630
  * Create worktree for the main project
220449
222631
  *
@@ -222205,22 +224387,6 @@ class WorkflowRegistry {
222205
224387
  exports.WorkflowRegistry = WorkflowRegistry;
222206
224388
 
222207
224389
 
222208
- /***/ }),
222209
-
222210
- /***/ 7065:
222211
- /***/ ((module) => {
222212
-
222213
- module.exports = eval("require")("./enterprise/loader");
222214
-
222215
-
222216
- /***/ }),
222217
-
222218
- /***/ 71370:
222219
- /***/ ((module) => {
222220
-
222221
- module.exports = eval("require")("./enterprise/policy/policy-input-builder");
222222
-
222223
-
222224
224390
  /***/ }),
222225
224391
 
222226
224392
  /***/ 18327:
@@ -263892,7 +266058,7 @@ var require_package2 = __commonJS({
263892
266058
  module2.exports = {
263893
266059
  name: "@aws-sdk/client-bedrock-runtime",
263894
266060
  description: "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native",
263895
- version: "3.997.0",
266061
+ version: "3.998.0",
263896
266062
  scripts: {
263897
266063
  build: "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
263898
266064
  "build:cjs": "node ../../scripts/compilation/inline client-bedrock-runtime",
@@ -263912,49 +266078,49 @@ var require_package2 = __commonJS({
263912
266078
  dependencies: {
263913
266079
  "@aws-crypto/sha256-browser": "5.2.0",
263914
266080
  "@aws-crypto/sha256-js": "5.2.0",
263915
- "@aws-sdk/core": "^3.973.13",
263916
- "@aws-sdk/credential-provider-node": "^3.972.12",
263917
- "@aws-sdk/eventstream-handler-node": "^3.972.7",
263918
- "@aws-sdk/middleware-eventstream": "^3.972.4",
263919
- "@aws-sdk/middleware-host-header": "^3.972.4",
263920
- "@aws-sdk/middleware-logger": "^3.972.4",
263921
- "@aws-sdk/middleware-recursion-detection": "^3.972.4",
263922
- "@aws-sdk/middleware-user-agent": "^3.972.13",
263923
- "@aws-sdk/middleware-websocket": "^3.972.8",
263924
- "@aws-sdk/region-config-resolver": "^3.972.4",
263925
- "@aws-sdk/token-providers": "3.997.0",
263926
- "@aws-sdk/types": "^3.973.2",
263927
- "@aws-sdk/util-endpoints": "^3.996.1",
263928
- "@aws-sdk/util-user-agent-browser": "^3.972.4",
263929
- "@aws-sdk/util-user-agent-node": "^3.972.12",
263930
- "@smithy/config-resolver": "^4.4.7",
263931
- "@smithy/core": "^3.23.4",
263932
- "@smithy/eventstream-serde-browser": "^4.2.9",
263933
- "@smithy/eventstream-serde-config-resolver": "^4.3.9",
263934
- "@smithy/eventstream-serde-node": "^4.2.9",
263935
- "@smithy/fetch-http-handler": "^5.3.10",
263936
- "@smithy/hash-node": "^4.2.9",
263937
- "@smithy/invalid-dependency": "^4.2.9",
263938
- "@smithy/middleware-content-length": "^4.2.9",
263939
- "@smithy/middleware-endpoint": "^4.4.18",
263940
- "@smithy/middleware-retry": "^4.4.35",
263941
- "@smithy/middleware-serde": "^4.2.10",
263942
- "@smithy/middleware-stack": "^4.2.9",
263943
- "@smithy/node-config-provider": "^4.3.9",
263944
- "@smithy/node-http-handler": "^4.4.11",
263945
- "@smithy/protocol-http": "^5.3.9",
263946
- "@smithy/smithy-client": "^4.11.7",
263947
- "@smithy/types": "^4.12.1",
263948
- "@smithy/url-parser": "^4.2.9",
266081
+ "@aws-sdk/core": "^3.973.14",
266082
+ "@aws-sdk/credential-provider-node": "^3.972.13",
266083
+ "@aws-sdk/eventstream-handler-node": "^3.972.8",
266084
+ "@aws-sdk/middleware-eventstream": "^3.972.5",
266085
+ "@aws-sdk/middleware-host-header": "^3.972.5",
266086
+ "@aws-sdk/middleware-logger": "^3.972.5",
266087
+ "@aws-sdk/middleware-recursion-detection": "^3.972.5",
266088
+ "@aws-sdk/middleware-user-agent": "^3.972.14",
266089
+ "@aws-sdk/middleware-websocket": "^3.972.9",
266090
+ "@aws-sdk/region-config-resolver": "^3.972.5",
266091
+ "@aws-sdk/token-providers": "3.998.0",
266092
+ "@aws-sdk/types": "^3.973.3",
266093
+ "@aws-sdk/util-endpoints": "^3.996.2",
266094
+ "@aws-sdk/util-user-agent-browser": "^3.972.5",
266095
+ "@aws-sdk/util-user-agent-node": "^3.972.13",
266096
+ "@smithy/config-resolver": "^4.4.9",
266097
+ "@smithy/core": "^3.23.6",
266098
+ "@smithy/eventstream-serde-browser": "^4.2.10",
266099
+ "@smithy/eventstream-serde-config-resolver": "^4.3.10",
266100
+ "@smithy/eventstream-serde-node": "^4.2.10",
266101
+ "@smithy/fetch-http-handler": "^5.3.11",
266102
+ "@smithy/hash-node": "^4.2.10",
266103
+ "@smithy/invalid-dependency": "^4.2.10",
266104
+ "@smithy/middleware-content-length": "^4.2.10",
266105
+ "@smithy/middleware-endpoint": "^4.4.20",
266106
+ "@smithy/middleware-retry": "^4.4.37",
266107
+ "@smithy/middleware-serde": "^4.2.11",
266108
+ "@smithy/middleware-stack": "^4.2.10",
266109
+ "@smithy/node-config-provider": "^4.3.10",
266110
+ "@smithy/node-http-handler": "^4.4.12",
266111
+ "@smithy/protocol-http": "^5.3.10",
266112
+ "@smithy/smithy-client": "^4.12.0",
266113
+ "@smithy/types": "^4.13.0",
266114
+ "@smithy/url-parser": "^4.2.10",
263949
266115
  "@smithy/util-base64": "^4.3.1",
263950
266116
  "@smithy/util-body-length-browser": "^4.2.1",
263951
266117
  "@smithy/util-body-length-node": "^4.2.2",
263952
- "@smithy/util-defaults-mode-browser": "^4.3.34",
263953
- "@smithy/util-defaults-mode-node": "^4.2.37",
263954
- "@smithy/util-endpoints": "^3.2.9",
263955
- "@smithy/util-middleware": "^4.2.9",
263956
- "@smithy/util-retry": "^4.2.9",
263957
- "@smithy/util-stream": "^4.5.14",
266118
+ "@smithy/util-defaults-mode-browser": "^4.3.36",
266119
+ "@smithy/util-defaults-mode-node": "^4.2.39",
266120
+ "@smithy/util-endpoints": "^3.3.1",
266121
+ "@smithy/util-middleware": "^4.2.10",
266122
+ "@smithy/util-retry": "^4.2.10",
266123
+ "@smithy/util-stream": "^4.5.15",
263958
266124
  "@smithy/util-utf8": "^4.2.1",
263959
266125
  tslib: "^2.6.2"
263960
266126
  },
@@ -264673,7 +266839,7 @@ var init_package = __esm({
264673
266839
  "node_modules/@aws-sdk/nested-clients/package.json"() {
264674
266840
  package_default = {
264675
266841
  name: "@aws-sdk/nested-clients",
264676
- version: "3.996.1",
266842
+ version: "3.996.2",
264677
266843
  description: "Nested clients for AWS SDK packages.",
264678
266844
  main: "./dist-cjs/index.js",
264679
266845
  module: "./dist-es/index.js",
@@ -264702,40 +266868,40 @@ var init_package = __esm({
264702
266868
  dependencies: {
264703
266869
  "@aws-crypto/sha256-browser": "5.2.0",
264704
266870
  "@aws-crypto/sha256-js": "5.2.0",
264705
- "@aws-sdk/core": "^3.973.13",
264706
- "@aws-sdk/middleware-host-header": "^3.972.4",
264707
- "@aws-sdk/middleware-logger": "^3.972.4",
264708
- "@aws-sdk/middleware-recursion-detection": "^3.972.4",
264709
- "@aws-sdk/middleware-user-agent": "^3.972.13",
264710
- "@aws-sdk/region-config-resolver": "^3.972.4",
264711
- "@aws-sdk/types": "^3.973.2",
264712
- "@aws-sdk/util-endpoints": "^3.996.1",
264713
- "@aws-sdk/util-user-agent-browser": "^3.972.4",
264714
- "@aws-sdk/util-user-agent-node": "^3.972.12",
264715
- "@smithy/config-resolver": "^4.4.7",
264716
- "@smithy/core": "^3.23.4",
264717
- "@smithy/fetch-http-handler": "^5.3.10",
264718
- "@smithy/hash-node": "^4.2.9",
264719
- "@smithy/invalid-dependency": "^4.2.9",
264720
- "@smithy/middleware-content-length": "^4.2.9",
264721
- "@smithy/middleware-endpoint": "^4.4.18",
264722
- "@smithy/middleware-retry": "^4.4.35",
264723
- "@smithy/middleware-serde": "^4.2.10",
264724
- "@smithy/middleware-stack": "^4.2.9",
264725
- "@smithy/node-config-provider": "^4.3.9",
264726
- "@smithy/node-http-handler": "^4.4.11",
264727
- "@smithy/protocol-http": "^5.3.9",
264728
- "@smithy/smithy-client": "^4.11.7",
264729
- "@smithy/types": "^4.12.1",
264730
- "@smithy/url-parser": "^4.2.9",
266871
+ "@aws-sdk/core": "^3.973.14",
266872
+ "@aws-sdk/middleware-host-header": "^3.972.5",
266873
+ "@aws-sdk/middleware-logger": "^3.972.5",
266874
+ "@aws-sdk/middleware-recursion-detection": "^3.972.5",
266875
+ "@aws-sdk/middleware-user-agent": "^3.972.14",
266876
+ "@aws-sdk/region-config-resolver": "^3.972.5",
266877
+ "@aws-sdk/types": "^3.973.3",
266878
+ "@aws-sdk/util-endpoints": "^3.996.2",
266879
+ "@aws-sdk/util-user-agent-browser": "^3.972.5",
266880
+ "@aws-sdk/util-user-agent-node": "^3.972.13",
266881
+ "@smithy/config-resolver": "^4.4.9",
266882
+ "@smithy/core": "^3.23.6",
266883
+ "@smithy/fetch-http-handler": "^5.3.11",
266884
+ "@smithy/hash-node": "^4.2.10",
266885
+ "@smithy/invalid-dependency": "^4.2.10",
266886
+ "@smithy/middleware-content-length": "^4.2.10",
266887
+ "@smithy/middleware-endpoint": "^4.4.20",
266888
+ "@smithy/middleware-retry": "^4.4.37",
266889
+ "@smithy/middleware-serde": "^4.2.11",
266890
+ "@smithy/middleware-stack": "^4.2.10",
266891
+ "@smithy/node-config-provider": "^4.3.10",
266892
+ "@smithy/node-http-handler": "^4.4.12",
266893
+ "@smithy/protocol-http": "^5.3.10",
266894
+ "@smithy/smithy-client": "^4.12.0",
266895
+ "@smithy/types": "^4.13.0",
266896
+ "@smithy/url-parser": "^4.2.10",
264731
266897
  "@smithy/util-base64": "^4.3.1",
264732
266898
  "@smithy/util-body-length-browser": "^4.2.1",
264733
266899
  "@smithy/util-body-length-node": "^4.2.2",
264734
- "@smithy/util-defaults-mode-browser": "^4.3.34",
264735
- "@smithy/util-defaults-mode-node": "^4.2.37",
264736
- "@smithy/util-endpoints": "^3.2.9",
264737
- "@smithy/util-middleware": "^4.2.9",
264738
- "@smithy/util-retry": "^4.2.9",
266900
+ "@smithy/util-defaults-mode-browser": "^4.3.36",
266901
+ "@smithy/util-defaults-mode-node": "^4.2.39",
266902
+ "@smithy/util-endpoints": "^3.3.1",
266903
+ "@smithy/util-middleware": "^4.2.10",
266904
+ "@smithy/util-retry": "^4.2.10",
264739
266905
  "@smithy/util-utf8": "^4.2.1",
264740
266906
  tslib: "^2.6.2"
264741
266907
  },
@@ -284726,7 +286892,11 @@ var init_esm3 = __esm({
284726
286892
  #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
284727
286893
  const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
284728
286894
  const lastgs = pattern.lastIndexOf(GLOBSTAR);
284729
- const [head2, body, tail] = [
286895
+ const [head2, body, tail] = partial ? [
286896
+ pattern.slice(patternIndex, firstgs),
286897
+ pattern.slice(firstgs + 1),
286898
+ []
286899
+ ] : [
284730
286900
  pattern.slice(patternIndex, firstgs),
284731
286901
  pattern.slice(firstgs + 1, lastgs),
284732
286902
  pattern.slice(lastgs + 1)
@@ -284763,7 +286933,7 @@ var init_esm3 = __esm({
284763
286933
  return false;
284764
286934
  }
284765
286935
  }
284766
- return sawSome;
286936
+ return partial || sawSome;
284767
286937
  }
284768
286938
  const bodySegments = [[[], 0]];
284769
286939
  let currentBody = bodySegments[0];
@@ -284812,7 +286982,7 @@ var init_esm3 = __esm({
284812
286982
  }
284813
286983
  fileIndex++;
284814
286984
  }
284815
- return null;
286985
+ return partial || null;
284816
286986
  }
284817
286987
  #matchOne(file, pattern, partial, fileIndex, patternIndex) {
284818
286988
  let fi;
@@ -327296,6 +329466,15 @@ function normalizeJsonQuotes(str) {
327296
329466
  }
327297
329467
  return result;
327298
329468
  }
329469
+ function isCodeBlockEmbeddedInDocument(text, match2) {
329470
+ const beforeBlock = text.substring(0, match2.index).trim();
329471
+ const afterBlock = text.substring(match2.index + match2[0].length).trim();
329472
+ const hasMarkdownHeadings = /^#{1,6}\s/m.test(beforeBlock) || /^#{1,6}\s/m.test(afterBlock);
329473
+ if (hasMarkdownHeadings) {
329474
+ return true;
329475
+ }
329476
+ return false;
329477
+ }
327299
329478
  function cleanSchemaResponse(response) {
327300
329479
  if (!response || typeof response !== "string") {
327301
329480
  return response;
@@ -327315,11 +329494,11 @@ function cleanSchemaResponse(response) {
327315
329494
  return cleanSchemaResponse(innerContent);
327316
329495
  }
327317
329496
  const jsonBlockMatch = trimmed.match(/```json\s*\n([\s\S]*?)\n```/);
327318
- if (jsonBlockMatch) {
329497
+ if (jsonBlockMatch && !isCodeBlockEmbeddedInDocument(trimmed, jsonBlockMatch)) {
327319
329498
  return normalizeJsonQuotes(jsonBlockMatch[1].trim());
327320
329499
  }
327321
329500
  const anyBlockMatch = trimmed.match(/```\s*\n([{\[][\s\S]*?[}\]])\s*```/);
327322
- if (anyBlockMatch) {
329501
+ if (anyBlockMatch && !isCodeBlockEmbeddedInDocument(trimmed, anyBlockMatch)) {
327323
329502
  return normalizeJsonQuotes(anyBlockMatch[1].trim());
327324
329503
  }
327325
329504
  const codeBlockPatterns = [
@@ -327328,7 +329507,7 @@ function cleanSchemaResponse(response) {
327328
329507
  ];
327329
329508
  for (const pattern of codeBlockPatterns) {
327330
329509
  const match2 = trimmed.match(pattern);
327331
- if (match2) {
329510
+ if (match2 && !isCodeBlockEmbeddedInDocument(trimmed, match2)) {
327332
329511
  return normalizeJsonQuotes(match2[1].trim());
327333
329512
  }
327334
329513
  }
@@ -327339,7 +329518,7 @@ function cleanSchemaResponse(response) {
327339
329518
  }
327340
329519
  const codeBlockStartPattern = /```(?:json)?\s*\n?\s*([{\[])/;
327341
329520
  const codeBlockMatch = trimmed.match(codeBlockStartPattern);
327342
- if (codeBlockMatch) {
329521
+ if (codeBlockMatch && !isCodeBlockEmbeddedInDocument(trimmed, codeBlockMatch)) {
327343
329522
  const startIndex = codeBlockMatch.index + codeBlockMatch[0].length - 1;
327344
329523
  const openChar = codeBlockMatch[1];
327345
329524
  const closeChar = openChar === "{" ? "}" : "]";
@@ -349037,6 +351216,10 @@ function parseSimpleCommand(command) {
349037
351216
  // Logical OR
349038
351217
  /(?<!\\);/,
349039
351218
  // Command separator (but not escaped \;)
351219
+ /\n/,
351220
+ // Newline command separator (multi-line commands)
351221
+ /\r/,
351222
+ // Carriage return (CRLF line endings)
349040
351223
  /&$/,
349041
351224
  // Background execution
349042
351225
  /\$\(/,
@@ -349143,6 +351326,8 @@ function isComplexPattern(pattern) {
349143
351326
  // Logical OR
349144
351327
  /;/,
349145
351328
  // Command separator
351329
+ /\n/,
351330
+ // Newline command separator
349146
351331
  /&$/,
349147
351332
  // Background execution
349148
351333
  /\$\(/,
@@ -349515,6 +351700,26 @@ var init_bashPermissions = __esm({
349515
351700
  i5++;
349516
351701
  continue;
349517
351702
  }
351703
+ if (char === "\n" || char === "\r" && nextChar === "\n") {
351704
+ if (current2.trim()) {
351705
+ components.push(current2.trim());
351706
+ }
351707
+ current2 = "";
351708
+ if (char === "\r") {
351709
+ i5 += 2;
351710
+ } else {
351711
+ i5++;
351712
+ }
351713
+ continue;
351714
+ }
351715
+ if (char === "\r") {
351716
+ if (current2.trim()) {
351717
+ components.push(current2.trim());
351718
+ }
351719
+ current2 = "";
351720
+ i5++;
351721
+ continue;
351722
+ }
349518
351723
  }
349519
351724
  current2 += char;
349520
351725
  i5++;
@@ -394355,7 +396560,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"100":"Continue","101":"Switching Pro
394355
396560
  /***/ ((module) => {
394356
396561
 
394357
396562
  "use strict";
394358
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.144","main":"dist/index.js","bin":{"visor":"./dist/index.js"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"},"./sdk":{"types":"./dist/sdk/sdk.d.ts","import":"./dist/sdk/sdk.mjs","require":"./dist/sdk/sdk.js"},"./cli":{"require":"./dist/index.js"}},"files":["dist/","defaults/","action.yml","README.md","LICENSE"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build:cli":"ncc build src/index.ts -o dist && cp -r defaults dist/ && cp -r output dist/ && cp -r docs dist/ && cp -r examples dist/ && cp -r src/debug-visualizer/ui dist/debug-visualizer/ && node scripts/inject-version.js && echo \'#!/usr/bin/env node\' | cat - dist/index.js > temp && mv temp dist/index.js && chmod +x dist/index.js","build:sdk":"tsup src/sdk.ts --dts --sourcemap --format esm,cjs --out-dir dist/sdk","build":"./scripts/build-oss.sh","build:ee":"npm run build:cli && npm run build:sdk","test":"jest && npm run test:yaml","test:unit":"jest","prepublishOnly":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ee":"jest --testPathPatterns=\'tests/ee\' --testPathIgnorePatterns=\'/node_modules/\' --no-coverage","test:manual:bash":"RUN_MANUAL_TESTS=true jest tests/manual/bash-config-manual.test.ts","lint":"eslint src tests --ext .ts","lint:fix":"eslint src tests --ext .ts --fix","format":"prettier --write src tests","format:check":"prettier --check src tests","clean":"","clean:traces":"node scripts/clean-traces.js","prebuild":"npm run clean && node scripts/generate-config-schema.js","pretest":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","pretest:unit":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","test:with-build":"npm run build:cli && jest","test:yaml":"node dist/index.js test --progress compact","test:yaml:parallel":"node dist/index.js test --progress compact --max-parallel 4","prepare":"husky","pre-commit":"lint-staged","deploy:site":"cd site && npx wrangler pages deploy . --project-name=visor-site --commit-dirty=true","deploy:worker":"npx wrangler deploy","deploy":"npm run deploy:site && npm run deploy:worker","publish:ee":"./scripts/publish-ee.sh","release":"./scripts/release.sh","release:patch":"./scripts/release.sh patch","release:minor":"./scripts/release.sh minor","release:major":"./scripts/release.sh major","release:prerelease":"./scripts/release.sh prerelease","docs:validate":"node scripts/validate-readme-links.js","workshop:setup":"npm install -D reveal-md@6.1.2","workshop:serve":"cd workshop && reveal-md slides.md -w","workshop:export":"reveal-md workshop/slides.md --static workshop/build","workshop:pdf":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter","workshop:pdf:ci":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter --puppeteer-launch-args=\\"--no-sandbox --disable-dev-shm-usage\\"","workshop:pdf:a4":"reveal-md workshop/slides.md --print workshop/Visor-Workshop-A4.pdf --print-size A4","workshop:build":"npm run workshop:export && npm run workshop:pdf","simulate:issue":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issues --action opened --debug","simulate:comment":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issue_comment --action created --debug"},"keywords":["code-review","ai","github-action","cli","pr-review","visor"],"author":"Probe Labs","license":"MIT","description":"AI workflow engine for code review, assistants, and automation — orchestrate checks, MCP tools, and AI providers with YAML-driven pipelines","repository":{"type":"git","url":"git+https://github.com/probelabs/visor.git"},"bugs":{"url":"https://github.com/probelabs/visor/issues"},"homepage":"https://github.com/probelabs/visor#readme","dependencies":{"@actions/core":"^1.11.1","@apidevtools/swagger-parser":"^12.1.0","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#f1c13b8eee98734a8ea024061eada4aa9a9ff2e9","@octokit/action":"^8.0.2","@octokit/auth-app":"^8.1.0","@octokit/core":"^7.0.3","@octokit/rest":"^22.0.0","@opentelemetry/api":"^1.9.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-trace-otlp-grpc":"^0.203.0","@opentelemetry/exporter-trace-otlp-http":"^0.203.0","@opentelemetry/instrumentation":"^0.203.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.203.0","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/semantic-conventions":"^1.30.1","@probelabs/probe":"^0.6.0-rc259","@types/commander":"^2.12.0","@types/uuid":"^10.0.0","acorn":"^8.16.0","acorn-walk":"^8.3.5","ajv":"^8.17.1","ajv-formats":"^3.0.1","better-sqlite3":"^11.0.0","blessed":"^0.1.81","cli-table3":"^0.6.5","commander":"^14.0.0","deepmerge":"^4.3.1","dotenv":"^17.2.3","ignore":"^7.0.5","js-yaml":"^4.1.0","jsonpath-plus":"^10.4.0","liquidjs":"^10.21.1","minimatch":"^10.2.2","node-cron":"^3.0.3","open":"^9.1.0","simple-git":"^3.28.0","uuid":"^11.1.0","ws":"^8.18.3"},"optionalDependencies":{"@anthropic/claude-code-sdk":"npm:null@*","@open-policy-agent/opa-wasm":"^1.10.0","knex":"^3.1.0","mysql2":"^3.11.0","pg":"^8.13.0","tedious":"^19.0.0"},"devDependencies":{"@eslint/js":"^9.34.0","@kie/act-js":"^2.6.2","@kie/mock-github":"^2.0.1","@swc/core":"^1.13.2","@swc/jest":"^0.2.37","@types/better-sqlite3":"^7.6.0","@types/blessed":"^0.1.27","@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/node":"^24.3.0","@types/node-cron":"^3.0.11","@types/ws":"^8.18.1","@typescript-eslint/eslint-plugin":"^8.42.0","@typescript-eslint/parser":"^8.42.0","@vercel/ncc":"^0.38.4","eslint":"^9.34.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","husky":"^9.1.7","jest":"^30.1.3","lint-staged":"^16.1.6","prettier":"^3.6.2","reveal-md":"^6.1.2","ts-json-schema-generator":"^1.5.1","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.9.2","wrangler":"^3.0.0"},"peerDependenciesMeta":{"@anthropic/claude-code-sdk":{"optional":true}},"directories":{"test":"tests"},"lint-staged":{"src/**/*.{ts,js}":["eslint --fix","prettier --write"],"tests/**/*.{ts,js}":["eslint --fix","prettier --write"],"*.{json,md,yml,yaml}":["prettier --write"]}}');
396563
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.42","main":"dist/index.js","bin":{"visor":"./dist/index.js"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"},"./sdk":{"types":"./dist/sdk/sdk.d.ts","import":"./dist/sdk/sdk.mjs","require":"./dist/sdk/sdk.js"},"./cli":{"require":"./dist/index.js"}},"files":["dist/","defaults/","action.yml","README.md","LICENSE"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build:cli":"ncc build src/index.ts -o dist && cp -r defaults dist/ && cp -r output dist/ && cp -r docs dist/ && cp -r examples dist/ && cp -r src/debug-visualizer/ui dist/debug-visualizer/ && node scripts/inject-version.js && echo \'#!/usr/bin/env node\' | cat - dist/index.js > temp && mv temp dist/index.js && chmod +x dist/index.js","build:sdk":"tsup src/sdk.ts --dts --sourcemap --format esm,cjs --out-dir dist/sdk","build":"./scripts/build-oss.sh","build:ee":"npm run build:cli && npm run build:sdk","test":"jest && npm run test:yaml","test:unit":"jest","prepublishOnly":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ee":"jest --testPathPatterns=\'tests/ee\' --testPathIgnorePatterns=\'/node_modules/\' --no-coverage","test:manual:bash":"RUN_MANUAL_TESTS=true jest tests/manual/bash-config-manual.test.ts","lint":"eslint src tests --ext .ts","lint:fix":"eslint src tests --ext .ts --fix","format":"prettier --write src tests","format:check":"prettier --check src tests","clean":"","clean:traces":"node scripts/clean-traces.js","prebuild":"npm run clean && node scripts/generate-config-schema.js","pretest":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","pretest:unit":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","test:with-build":"npm run build:cli && jest","test:yaml":"node dist/index.js test --progress compact","test:yaml:parallel":"node dist/index.js test --progress compact --max-parallel 4","prepare":"husky","pre-commit":"lint-staged","deploy:site":"cd site && npx wrangler pages deploy . --project-name=visor-site --commit-dirty=true","deploy:worker":"npx wrangler deploy","deploy":"npm run deploy:site && npm run deploy:worker","publish:ee":"./scripts/publish-ee.sh","release":"./scripts/release.sh","release:patch":"./scripts/release.sh patch","release:minor":"./scripts/release.sh minor","release:major":"./scripts/release.sh major","release:prerelease":"./scripts/release.sh prerelease","docs:validate":"node scripts/validate-readme-links.js","workshop:setup":"npm install -D reveal-md@6.1.2","workshop:serve":"cd workshop && reveal-md slides.md -w","workshop:export":"reveal-md workshop/slides.md --static workshop/build","workshop:pdf":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter","workshop:pdf:ci":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter --puppeteer-launch-args=\\"--no-sandbox --disable-dev-shm-usage\\"","workshop:pdf:a4":"reveal-md workshop/slides.md --print workshop/Visor-Workshop-A4.pdf --print-size A4","workshop:build":"npm run workshop:export && npm run workshop:pdf","simulate:issue":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issues --action opened --debug","simulate:comment":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issue_comment --action created --debug"},"keywords":["code-review","ai","github-action","cli","pr-review","visor"],"author":"Probe Labs","license":"MIT","description":"AI workflow engine for code review, assistants, and automation — orchestrate checks, MCP tools, and AI providers with YAML-driven pipelines","repository":{"type":"git","url":"git+https://github.com/probelabs/visor.git"},"bugs":{"url":"https://github.com/probelabs/visor/issues"},"homepage":"https://github.com/probelabs/visor#readme","dependencies":{"@actions/core":"^1.11.1","@apidevtools/swagger-parser":"^12.1.0","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#f1c13b8eee98734a8ea024061eada4aa9a9ff2e9","@octokit/action":"^8.0.2","@octokit/auth-app":"^8.1.0","@octokit/core":"^7.0.3","@octokit/rest":"^22.0.0","@opentelemetry/api":"^1.9.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-trace-otlp-grpc":"^0.203.0","@opentelemetry/exporter-trace-otlp-http":"^0.203.0","@opentelemetry/instrumentation":"^0.203.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.203.0","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/semantic-conventions":"^1.30.1","@probelabs/probe":"^0.6.0-rc260","@types/commander":"^2.12.0","@types/uuid":"^10.0.0","acorn":"^8.16.0","acorn-walk":"^8.3.5","ajv":"^8.17.1","ajv-formats":"^3.0.1","better-sqlite3":"^11.0.0","blessed":"^0.1.81","cli-table3":"^0.6.5","commander":"^14.0.0","deepmerge":"^4.3.1","dotenv":"^17.2.3","ignore":"^7.0.5","js-yaml":"^4.1.0","jsonpath-plus":"^10.4.0","liquidjs":"^10.21.1","minimatch":"^10.2.2","node-cron":"^3.0.3","open":"^9.1.0","simple-git":"^3.28.0","uuid":"^11.1.0","ws":"^8.18.3"},"optionalDependencies":{"@anthropic/claude-code-sdk":"npm:null@*","@open-policy-agent/opa-wasm":"^1.10.0","knex":"^3.1.0","mysql2":"^3.11.0","pg":"^8.13.0","tedious":"^19.0.0"},"devDependencies":{"@eslint/js":"^9.34.0","@kie/act-js":"^2.6.2","@kie/mock-github":"^2.0.1","@swc/core":"^1.13.2","@swc/jest":"^0.2.37","@types/better-sqlite3":"^7.6.0","@types/blessed":"^0.1.27","@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/node":"^24.3.0","@types/node-cron":"^3.0.11","@types/ws":"^8.18.1","@typescript-eslint/eslint-plugin":"^8.42.0","@typescript-eslint/parser":"^8.42.0","@vercel/ncc":"^0.38.4","eslint":"^9.34.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","husky":"^9.1.7","jest":"^30.1.3","lint-staged":"^16.1.6","prettier":"^3.6.2","reveal-md":"^6.1.2","ts-json-schema-generator":"^1.5.1","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.9.2","wrangler":"^3.0.0"},"peerDependenciesMeta":{"@anthropic/claude-code-sdk":{"optional":true}},"directories":{"test":"tests"},"lint-staged":{"src/**/*.{ts,js}":["eslint --fix","prettier --write"],"tests/**/*.{ts,js}":["eslint --fix","prettier --write"],"*.{json,md,yml,yaml}":["prettier --write"]}}');
394359
396564
 
394360
396565
  /***/ })
394361
396566