@probelabs/visor 0.1.176 → 0.1.177-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.
- package/dist/frontends/slack-frontend.d.ts.map +1 -1
- package/dist/index.js +1964 -44
- package/dist/sdk/{a2a-frontend-W54ZZ32L.mjs → a2a-frontend-BPWLYLCG.mjs} +2 -2
- package/dist/sdk/{check-provider-registry-MJYNLB37.mjs → check-provider-registry-G64PWDCZ.mjs} +5 -5
- package/dist/sdk/{check-provider-registry-7HSDAKHQ.mjs → check-provider-registry-HW4QPPSA.mjs} +2 -2
- package/dist/sdk/{chunk-Y2DYDGGY.mjs → chunk-GVTWESYN.mjs} +3 -3
- package/dist/sdk/chunk-GVTWESYN.mjs.map +1 -0
- package/dist/sdk/{chunk-4E34HRCW.mjs → chunk-IYXOLUDJ.mjs} +74 -29
- package/dist/sdk/chunk-IYXOLUDJ.mjs.map +1 -0
- package/dist/sdk/{chunk-66PTDQAO.mjs → chunk-OHOBWVPP.mjs} +3 -3
- package/dist/sdk/{chunk-SEA2FWEC.mjs → chunk-OPI632LK.mjs} +2 -2
- package/dist/sdk/{chunk-OK4MLC3R.mjs → chunk-Y6PVSFCS.mjs} +49 -9
- package/dist/sdk/chunk-Y6PVSFCS.mjs.map +1 -0
- package/dist/sdk/{failure-condition-evaluator-RTT5SLVL.mjs → failure-condition-evaluator-HL33X7MH.mjs} +3 -3
- package/dist/sdk/{github-frontend-C4GG62PI.mjs → github-frontend-U2U42CKV.mjs} +3 -3
- package/dist/sdk/{host-6GGO2BQE.mjs → host-HFOJQIOF.mjs} +4 -4
- package/dist/sdk/knex-store-QCEW4I4R.mjs +527 -0
- package/dist/sdk/knex-store-QCEW4I4R.mjs.map +1 -0
- package/dist/sdk/loader-Q7K76ZIY.mjs +89 -0
- package/dist/sdk/loader-Q7K76ZIY.mjs.map +1 -0
- package/dist/sdk/opa-policy-engine-QCSSIMUF.mjs +655 -0
- package/dist/sdk/opa-policy-engine-QCSSIMUF.mjs.map +1 -0
- package/dist/sdk/{routing-DXVYOXAS.mjs → routing-SFP4D6O3.mjs} +4 -4
- package/dist/sdk/{schedule-tool-R7NSHTPJ.mjs → schedule-tool-45NAALKS.mjs} +2 -2
- package/dist/sdk/{schedule-tool-LL7XDILD.mjs → schedule-tool-7O7SWSJ4.mjs} +5 -5
- package/dist/sdk/{schedule-tool-handler-5GTQ6SFI.mjs → schedule-tool-handler-6MPP5DXK.mjs} +2 -2
- package/dist/sdk/{schedule-tool-handler-O3L2R5OJ.mjs → schedule-tool-handler-KYDXJ2ZL.mjs} +5 -5
- package/dist/sdk/sdk.js +1729 -295
- package/dist/sdk/sdk.js.map +1 -1
- package/dist/sdk/sdk.mjs +4 -4
- package/dist/sdk/slack-frontend-XKSIOUXB.mjs +910 -0
- package/dist/sdk/slack-frontend-XKSIOUXB.mjs.map +1 -0
- package/dist/sdk/{trace-helpers-CECHXDLI.mjs → trace-helpers-L3EOYW5P.mjs} +2 -2
- package/dist/sdk/validator-XTZJZZJH.mjs +134 -0
- package/dist/sdk/validator-XTZJZZJH.mjs.map +1 -0
- package/dist/sdk/{workflow-check-provider-EY6VSMNG.mjs → workflow-check-provider-JIXZJNV5.mjs} +5 -5
- package/dist/sdk/{workflow-check-provider-AX7IRQEZ.mjs → workflow-check-provider-OA33MESM.mjs} +2 -2
- package/dist/utils/workspace-manager.d.ts +5 -1
- package/dist/utils/workspace-manager.d.ts.map +1 -1
- package/dist/utils/worktree-manager.d.ts +5 -1
- package/dist/utils/worktree-manager.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/output/traces/run-2026-03-10T15-37-04-236Z.ndjson +0 -138
- package/dist/output/traces/run-2026-03-10T15-37-44-748Z.ndjson +0 -2296
- package/dist/sdk/check-provider-registry-VE6LQPLY.mjs +0 -30
- package/dist/sdk/chunk-4E34HRCW.mjs.map +0 -1
- package/dist/sdk/chunk-OK4MLC3R.mjs.map +0 -1
- package/dist/sdk/chunk-R3FNZRE4.mjs +0 -45194
- package/dist/sdk/chunk-R3FNZRE4.mjs.map +0 -1
- package/dist/sdk/chunk-Y2DYDGGY.mjs.map +0 -1
- package/dist/sdk/schedule-tool-GKKVOQB7.mjs +0 -36
- package/dist/sdk/schedule-tool-handler-ZZGJ3UFR.mjs +0 -40
- package/dist/sdk/trace-helpers-CECHXDLI.mjs.map +0 -1
- package/dist/sdk/workflow-check-provider-AX7IRQEZ.mjs.map +0 -1
- package/dist/sdk/workflow-check-provider-EY6VSMNG.mjs.map +0 -1
- package/dist/sdk/workflow-check-provider-HZQGJFOU.mjs +0 -30
- package/dist/sdk/workflow-check-provider-HZQGJFOU.mjs.map +0 -1
- package/dist/traces/run-2026-03-10T15-37-04-236Z.ndjson +0 -138
- package/dist/traces/run-2026-03-10T15-37-44-748Z.ndjson +0 -2296
- /package/dist/sdk/{a2a-frontend-W54ZZ32L.mjs.map → a2a-frontend-BPWLYLCG.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-7HSDAKHQ.mjs.map → check-provider-registry-G64PWDCZ.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-MJYNLB37.mjs.map → check-provider-registry-HW4QPPSA.mjs.map} +0 -0
- /package/dist/sdk/{chunk-66PTDQAO.mjs.map → chunk-OHOBWVPP.mjs.map} +0 -0
- /package/dist/sdk/{chunk-SEA2FWEC.mjs.map → chunk-OPI632LK.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-VE6LQPLY.mjs.map → failure-condition-evaluator-HL33X7MH.mjs.map} +0 -0
- /package/dist/sdk/{github-frontend-C4GG62PI.mjs.map → github-frontend-U2U42CKV.mjs.map} +0 -0
- /package/dist/sdk/{host-6GGO2BQE.mjs.map → host-HFOJQIOF.mjs.map} +0 -0
- /package/dist/sdk/{failure-condition-evaluator-RTT5SLVL.mjs.map → routing-SFP4D6O3.mjs.map} +0 -0
- /package/dist/sdk/{routing-DXVYOXAS.mjs.map → schedule-tool-45NAALKS.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-GKKVOQB7.mjs.map → schedule-tool-7O7SWSJ4.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-LL7XDILD.mjs.map → schedule-tool-handler-6MPP5DXK.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-R7NSHTPJ.mjs.map → schedule-tool-handler-KYDXJ2ZL.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-5GTQ6SFI.mjs.map → trace-helpers-L3EOYW5P.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-O3L2R5OJ.mjs.map → workflow-check-provider-JIXZJNV5.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-ZZGJ3UFR.mjs.map → workflow-check-provider-OA33MESM.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.
|
|
3
|
-
process.env.PROBE_VERSION = '0.6.0-
|
|
4
|
-
process.env.VISOR_COMMIT_SHA = '
|
|
5
|
-
process.env.VISOR_COMMIT_SHORT = '
|
|
2
|
+
process.env.VISOR_VERSION = '0.1.177';
|
|
3
|
+
process.env.PROBE_VERSION = '0.6.0-rc292';
|
|
4
|
+
process.env.VISOR_COMMIT_SHA = '5ceed041c645b4c6f1ed2b2cf327a7f376437656';
|
|
5
|
+
process.env.VISOR_COMMIT_SHORT = '5ceed04';
|
|
6
6
|
/******/ (() => { // webpackBootstrap
|
|
7
7
|
/******/ var __webpack_modules__ = ({
|
|
8
8
|
|
|
@@ -302997,7 +302997,7 @@ async function handleDumpPolicyInput(checkId, argv) {
|
|
|
302997
302997
|
let PolicyInputBuilder;
|
|
302998
302998
|
try {
|
|
302999
302999
|
// @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
|
|
303000
|
-
const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(
|
|
303000
|
+
const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(17117)));
|
|
303001
303001
|
PolicyInputBuilder = mod.PolicyInputBuilder;
|
|
303002
303002
|
}
|
|
303003
303003
|
catch {
|
|
@@ -311069,6 +311069,1810 @@ class EmailPollingRunner {
|
|
|
311069
311069
|
exports.EmailPollingRunner = EmailPollingRunner;
|
|
311070
311070
|
|
|
311071
311071
|
|
|
311072
|
+
/***/ }),
|
|
311073
|
+
|
|
311074
|
+
/***/ 50069:
|
|
311075
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
311076
|
+
|
|
311077
|
+
"use strict";
|
|
311078
|
+
|
|
311079
|
+
/**
|
|
311080
|
+
* Copyright (c) ProbeLabs. All rights reserved.
|
|
311081
|
+
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
311082
|
+
* in compliance with the Elastic License 2.0.
|
|
311083
|
+
*/
|
|
311084
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
311085
|
+
if (k2 === undefined) k2 = k;
|
|
311086
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
311087
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
311088
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
311089
|
+
}
|
|
311090
|
+
Object.defineProperty(o, k2, desc);
|
|
311091
|
+
}) : (function(o, m, k, k2) {
|
|
311092
|
+
if (k2 === undefined) k2 = k;
|
|
311093
|
+
o[k2] = m[k];
|
|
311094
|
+
}));
|
|
311095
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
311096
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
311097
|
+
}) : function(o, v) {
|
|
311098
|
+
o["default"] = v;
|
|
311099
|
+
});
|
|
311100
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
311101
|
+
var ownKeys = function(o) {
|
|
311102
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
311103
|
+
var ar = [];
|
|
311104
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
311105
|
+
return ar;
|
|
311106
|
+
};
|
|
311107
|
+
return ownKeys(o);
|
|
311108
|
+
};
|
|
311109
|
+
return function (mod) {
|
|
311110
|
+
if (mod && mod.__esModule) return mod;
|
|
311111
|
+
var result = {};
|
|
311112
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
311113
|
+
__setModuleDefault(result, mod);
|
|
311114
|
+
return result;
|
|
311115
|
+
};
|
|
311116
|
+
})();
|
|
311117
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
311118
|
+
exports.LicenseValidator = void 0;
|
|
311119
|
+
const crypto = __importStar(__nccwpck_require__(76982));
|
|
311120
|
+
const fs = __importStar(__nccwpck_require__(79896));
|
|
311121
|
+
const path = __importStar(__nccwpck_require__(16928));
|
|
311122
|
+
class LicenseValidator {
|
|
311123
|
+
/** Ed25519 public key for license verification (PEM format). */
|
|
311124
|
+
static PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----\n' +
|
|
311125
|
+
'MCowBQYDK2VwAyEAI/Zd08EFmgIdrDm/HXd0l3/5GBt7R1PrdvhdmEXhJlU=\n' +
|
|
311126
|
+
'-----END PUBLIC KEY-----\n';
|
|
311127
|
+
cache = null;
|
|
311128
|
+
static CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
311129
|
+
static GRACE_PERIOD = 72 * 3600 * 1000; // 72 hours after expiry
|
|
311130
|
+
/**
|
|
311131
|
+
* Load and validate license from environment or file.
|
|
311132
|
+
*
|
|
311133
|
+
* Resolution order:
|
|
311134
|
+
* 1. VISOR_LICENSE env var (JWT string)
|
|
311135
|
+
* 2. VISOR_LICENSE_FILE env var (path to file)
|
|
311136
|
+
* 3. .visor-license in project root (cwd)
|
|
311137
|
+
* 4. .visor-license in ~/.config/visor/
|
|
311138
|
+
*/
|
|
311139
|
+
async loadAndValidate() {
|
|
311140
|
+
// Return cached result if still fresh
|
|
311141
|
+
if (this.cache && Date.now() - this.cache.validatedAt < LicenseValidator.CACHE_TTL) {
|
|
311142
|
+
return this.cache.payload;
|
|
311143
|
+
}
|
|
311144
|
+
const token = this.resolveToken();
|
|
311145
|
+
if (!token)
|
|
311146
|
+
return null;
|
|
311147
|
+
const payload = this.verifyAndDecode(token);
|
|
311148
|
+
if (!payload)
|
|
311149
|
+
return null;
|
|
311150
|
+
this.cache = { payload, validatedAt: Date.now() };
|
|
311151
|
+
return payload;
|
|
311152
|
+
}
|
|
311153
|
+
/** Check if a specific feature is licensed */
|
|
311154
|
+
hasFeature(feature) {
|
|
311155
|
+
if (!this.cache)
|
|
311156
|
+
return false;
|
|
311157
|
+
return this.cache.payload.features.includes(feature);
|
|
311158
|
+
}
|
|
311159
|
+
/** Check if license is valid (with grace period) */
|
|
311160
|
+
isValid() {
|
|
311161
|
+
if (!this.cache)
|
|
311162
|
+
return false;
|
|
311163
|
+
const now = Date.now();
|
|
311164
|
+
const expiryMs = this.cache.payload.exp * 1000;
|
|
311165
|
+
return now < expiryMs + LicenseValidator.GRACE_PERIOD;
|
|
311166
|
+
}
|
|
311167
|
+
/** Check if the license is within its grace period (expired but still valid) */
|
|
311168
|
+
isInGracePeriod() {
|
|
311169
|
+
if (!this.cache)
|
|
311170
|
+
return false;
|
|
311171
|
+
const now = Date.now();
|
|
311172
|
+
const expiryMs = this.cache.payload.exp * 1000;
|
|
311173
|
+
return now >= expiryMs && now < expiryMs + LicenseValidator.GRACE_PERIOD;
|
|
311174
|
+
}
|
|
311175
|
+
resolveToken() {
|
|
311176
|
+
// 1. Direct env var
|
|
311177
|
+
if (process.env.VISOR_LICENSE) {
|
|
311178
|
+
return process.env.VISOR_LICENSE.trim();
|
|
311179
|
+
}
|
|
311180
|
+
// 2. File path from env (validate against path traversal)
|
|
311181
|
+
if (process.env.VISOR_LICENSE_FILE) {
|
|
311182
|
+
// path.resolve() produces an absolute path with all '..' segments resolved,
|
|
311183
|
+
// so a separate resolved.includes('..') check is unnecessary.
|
|
311184
|
+
const resolved = path.resolve(process.env.VISOR_LICENSE_FILE);
|
|
311185
|
+
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
311186
|
+
const allowedPrefixes = [path.normalize(process.cwd())];
|
|
311187
|
+
if (home)
|
|
311188
|
+
allowedPrefixes.push(path.normalize(path.join(home, '.config', 'visor')));
|
|
311189
|
+
// Resolve symlinks so an attacker cannot create a symlink inside an
|
|
311190
|
+
// allowed prefix that points to an arbitrary file outside it.
|
|
311191
|
+
let realPath;
|
|
311192
|
+
try {
|
|
311193
|
+
realPath = fs.realpathSync(resolved);
|
|
311194
|
+
}
|
|
311195
|
+
catch {
|
|
311196
|
+
return null; // File doesn't exist or isn't accessible
|
|
311197
|
+
}
|
|
311198
|
+
const isSafe = allowedPrefixes.some(prefix => realPath === prefix || realPath.startsWith(prefix + path.sep));
|
|
311199
|
+
if (!isSafe)
|
|
311200
|
+
return null;
|
|
311201
|
+
return this.readFile(realPath);
|
|
311202
|
+
}
|
|
311203
|
+
// 3. .visor-license in cwd
|
|
311204
|
+
const cwdPath = path.join(process.cwd(), '.visor-license');
|
|
311205
|
+
const cwdToken = this.readFile(cwdPath);
|
|
311206
|
+
if (cwdToken)
|
|
311207
|
+
return cwdToken;
|
|
311208
|
+
// 4. ~/.config/visor/.visor-license
|
|
311209
|
+
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
311210
|
+
if (home) {
|
|
311211
|
+
const configPath = path.join(home, '.config', 'visor', '.visor-license');
|
|
311212
|
+
const configToken = this.readFile(configPath);
|
|
311213
|
+
if (configToken)
|
|
311214
|
+
return configToken;
|
|
311215
|
+
}
|
|
311216
|
+
return null;
|
|
311217
|
+
}
|
|
311218
|
+
readFile(filePath) {
|
|
311219
|
+
try {
|
|
311220
|
+
return fs.readFileSync(filePath, 'utf-8').trim();
|
|
311221
|
+
}
|
|
311222
|
+
catch {
|
|
311223
|
+
return null;
|
|
311224
|
+
}
|
|
311225
|
+
}
|
|
311226
|
+
verifyAndDecode(token) {
|
|
311227
|
+
try {
|
|
311228
|
+
const parts = token.split('.');
|
|
311229
|
+
if (parts.length !== 3)
|
|
311230
|
+
return null;
|
|
311231
|
+
const [headerB64, payloadB64, signatureB64] = parts;
|
|
311232
|
+
// Decode header to verify algorithm
|
|
311233
|
+
const header = JSON.parse(Buffer.from(headerB64, 'base64url').toString());
|
|
311234
|
+
if (header.alg !== 'EdDSA')
|
|
311235
|
+
return null;
|
|
311236
|
+
// Verify signature
|
|
311237
|
+
const data = `${headerB64}.${payloadB64}`;
|
|
311238
|
+
const signature = Buffer.from(signatureB64, 'base64url');
|
|
311239
|
+
const publicKey = crypto.createPublicKey(LicenseValidator.PUBLIC_KEY);
|
|
311240
|
+
// Validate that the loaded public key is actually Ed25519 (OID 1.3.101.112).
|
|
311241
|
+
// This prevents algorithm-confusion attacks if the embedded key were ever
|
|
311242
|
+
// swapped to a different type.
|
|
311243
|
+
if (publicKey.asymmetricKeyType !== 'ed25519') {
|
|
311244
|
+
return null;
|
|
311245
|
+
}
|
|
311246
|
+
// Ed25519 verification: algorithm must be null because EdDSA performs its
|
|
311247
|
+
// own internal hashing (SHA-512) — passing a digest algorithm here would
|
|
311248
|
+
// cause Node.js to throw. The key type is validated above.
|
|
311249
|
+
const isValid = crypto.verify(null, Buffer.from(data), publicKey, signature);
|
|
311250
|
+
if (!isValid)
|
|
311251
|
+
return null;
|
|
311252
|
+
// Decode payload
|
|
311253
|
+
const payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString());
|
|
311254
|
+
// Validate required fields
|
|
311255
|
+
if (!payload.org ||
|
|
311256
|
+
!Array.isArray(payload.features) ||
|
|
311257
|
+
typeof payload.exp !== 'number' ||
|
|
311258
|
+
typeof payload.iat !== 'number' ||
|
|
311259
|
+
!payload.sub) {
|
|
311260
|
+
return null;
|
|
311261
|
+
}
|
|
311262
|
+
// Check expiry (with grace period)
|
|
311263
|
+
const now = Date.now();
|
|
311264
|
+
const expiryMs = payload.exp * 1000;
|
|
311265
|
+
if (now >= expiryMs + LicenseValidator.GRACE_PERIOD) {
|
|
311266
|
+
return null;
|
|
311267
|
+
}
|
|
311268
|
+
return payload;
|
|
311269
|
+
}
|
|
311270
|
+
catch {
|
|
311271
|
+
return null;
|
|
311272
|
+
}
|
|
311273
|
+
}
|
|
311274
|
+
}
|
|
311275
|
+
exports.LicenseValidator = LicenseValidator;
|
|
311276
|
+
|
|
311277
|
+
|
|
311278
|
+
/***/ }),
|
|
311279
|
+
|
|
311280
|
+
/***/ 87068:
|
|
311281
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
311282
|
+
|
|
311283
|
+
"use strict";
|
|
311284
|
+
|
|
311285
|
+
/**
|
|
311286
|
+
* Copyright (c) ProbeLabs. All rights reserved.
|
|
311287
|
+
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
311288
|
+
* in compliance with the Elastic License 2.0.
|
|
311289
|
+
*/
|
|
311290
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
311291
|
+
if (k2 === undefined) k2 = k;
|
|
311292
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
311293
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
311294
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
311295
|
+
}
|
|
311296
|
+
Object.defineProperty(o, k2, desc);
|
|
311297
|
+
}) : (function(o, m, k, k2) {
|
|
311298
|
+
if (k2 === undefined) k2 = k;
|
|
311299
|
+
o[k2] = m[k];
|
|
311300
|
+
}));
|
|
311301
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
311302
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
311303
|
+
}) : function(o, v) {
|
|
311304
|
+
o["default"] = v;
|
|
311305
|
+
});
|
|
311306
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
311307
|
+
var ownKeys = function(o) {
|
|
311308
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
311309
|
+
var ar = [];
|
|
311310
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
311311
|
+
return ar;
|
|
311312
|
+
};
|
|
311313
|
+
return ownKeys(o);
|
|
311314
|
+
};
|
|
311315
|
+
return function (mod) {
|
|
311316
|
+
if (mod && mod.__esModule) return mod;
|
|
311317
|
+
var result = {};
|
|
311318
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
311319
|
+
__setModuleDefault(result, mod);
|
|
311320
|
+
return result;
|
|
311321
|
+
};
|
|
311322
|
+
})();
|
|
311323
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
311324
|
+
exports.loadEnterprisePolicyEngine = loadEnterprisePolicyEngine;
|
|
311325
|
+
exports.loadEnterpriseStoreBackend = loadEnterpriseStoreBackend;
|
|
311326
|
+
const default_engine_1 = __nccwpck_require__(93866);
|
|
311327
|
+
/**
|
|
311328
|
+
* Load the enterprise policy engine if licensed, otherwise return the default no-op engine.
|
|
311329
|
+
*
|
|
311330
|
+
* This is the sole import boundary between OSS and enterprise code. Core code
|
|
311331
|
+
* must only import from this module (via dynamic `await import()`), never from
|
|
311332
|
+
* individual enterprise submodules.
|
|
311333
|
+
*/
|
|
311334
|
+
async function loadEnterprisePolicyEngine(config) {
|
|
311335
|
+
try {
|
|
311336
|
+
const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
|
|
311337
|
+
const validator = new LicenseValidator();
|
|
311338
|
+
const license = await validator.loadAndValidate();
|
|
311339
|
+
if (!license || !validator.hasFeature('policy')) {
|
|
311340
|
+
return new default_engine_1.DefaultPolicyEngine();
|
|
311341
|
+
}
|
|
311342
|
+
if (validator.isInGracePeriod()) {
|
|
311343
|
+
// eslint-disable-next-line no-console
|
|
311344
|
+
console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
|
|
311345
|
+
'Please renew your license.');
|
|
311346
|
+
}
|
|
311347
|
+
const { OpaPolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(39530)));
|
|
311348
|
+
const engine = new OpaPolicyEngine(config);
|
|
311349
|
+
await engine.initialize(config);
|
|
311350
|
+
return engine;
|
|
311351
|
+
}
|
|
311352
|
+
catch (err) {
|
|
311353
|
+
// Enterprise code not available or initialization failed
|
|
311354
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
311355
|
+
try {
|
|
311356
|
+
const { logger } = __nccwpck_require__(86999);
|
|
311357
|
+
logger.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
|
|
311358
|
+
}
|
|
311359
|
+
catch {
|
|
311360
|
+
// silent
|
|
311361
|
+
}
|
|
311362
|
+
return new default_engine_1.DefaultPolicyEngine();
|
|
311363
|
+
}
|
|
311364
|
+
}
|
|
311365
|
+
/**
|
|
311366
|
+
* Load the enterprise schedule store backend if licensed.
|
|
311367
|
+
*
|
|
311368
|
+
* @param driver Database driver ('postgresql', 'mysql', or 'mssql')
|
|
311369
|
+
* @param storageConfig Storage configuration with connection details
|
|
311370
|
+
* @param haConfig Optional HA configuration
|
|
311371
|
+
* @throws Error if enterprise license is not available or missing 'scheduler-sql' feature
|
|
311372
|
+
*/
|
|
311373
|
+
async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
|
|
311374
|
+
const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
|
|
311375
|
+
const validator = new LicenseValidator();
|
|
311376
|
+
const license = await validator.loadAndValidate();
|
|
311377
|
+
if (!license || !validator.hasFeature('scheduler-sql')) {
|
|
311378
|
+
throw new Error(`The ${driver} schedule storage driver requires a Visor Enterprise license ` +
|
|
311379
|
+
`with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`);
|
|
311380
|
+
}
|
|
311381
|
+
if (validator.isInGracePeriod()) {
|
|
311382
|
+
// eslint-disable-next-line no-console
|
|
311383
|
+
console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
|
|
311384
|
+
'Please renew your license.');
|
|
311385
|
+
}
|
|
311386
|
+
const { KnexStoreBackend } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(63737)));
|
|
311387
|
+
return new KnexStoreBackend(driver, storageConfig, haConfig);
|
|
311388
|
+
}
|
|
311389
|
+
|
|
311390
|
+
|
|
311391
|
+
/***/ }),
|
|
311392
|
+
|
|
311393
|
+
/***/ 628:
|
|
311394
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
311395
|
+
|
|
311396
|
+
"use strict";
|
|
311397
|
+
|
|
311398
|
+
/**
|
|
311399
|
+
* Copyright (c) ProbeLabs. All rights reserved.
|
|
311400
|
+
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
311401
|
+
* in compliance with the Elastic License 2.0.
|
|
311402
|
+
*/
|
|
311403
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
311404
|
+
if (k2 === undefined) k2 = k;
|
|
311405
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
311406
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
311407
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
311408
|
+
}
|
|
311409
|
+
Object.defineProperty(o, k2, desc);
|
|
311410
|
+
}) : (function(o, m, k, k2) {
|
|
311411
|
+
if (k2 === undefined) k2 = k;
|
|
311412
|
+
o[k2] = m[k];
|
|
311413
|
+
}));
|
|
311414
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
311415
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
311416
|
+
}) : function(o, v) {
|
|
311417
|
+
o["default"] = v;
|
|
311418
|
+
});
|
|
311419
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
311420
|
+
var ownKeys = function(o) {
|
|
311421
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
311422
|
+
var ar = [];
|
|
311423
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
311424
|
+
return ar;
|
|
311425
|
+
};
|
|
311426
|
+
return ownKeys(o);
|
|
311427
|
+
};
|
|
311428
|
+
return function (mod) {
|
|
311429
|
+
if (mod && mod.__esModule) return mod;
|
|
311430
|
+
var result = {};
|
|
311431
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
311432
|
+
__setModuleDefault(result, mod);
|
|
311433
|
+
return result;
|
|
311434
|
+
};
|
|
311435
|
+
})();
|
|
311436
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
311437
|
+
exports.OpaCompiler = void 0;
|
|
311438
|
+
const fs = __importStar(__nccwpck_require__(79896));
|
|
311439
|
+
const path = __importStar(__nccwpck_require__(16928));
|
|
311440
|
+
const os = __importStar(__nccwpck_require__(70857));
|
|
311441
|
+
const crypto = __importStar(__nccwpck_require__(76982));
|
|
311442
|
+
const child_process_1 = __nccwpck_require__(35317);
|
|
311443
|
+
/**
|
|
311444
|
+
* OPA Rego Compiler - compiles .rego policy files to WASM bundles using the `opa` CLI.
|
|
311445
|
+
*
|
|
311446
|
+
* Handles:
|
|
311447
|
+
* - Resolving input paths to WASM bytes (direct .wasm, directory with policy.wasm, or .rego files)
|
|
311448
|
+
* - Compiling .rego files to WASM via `opa build`
|
|
311449
|
+
* - Caching compiled bundles based on content hashes
|
|
311450
|
+
* - Extracting policy.wasm from OPA tar.gz bundles
|
|
311451
|
+
*
|
|
311452
|
+
* Requires:
|
|
311453
|
+
* - `opa` CLI on PATH (only when auto-compiling .rego files)
|
|
311454
|
+
*/
|
|
311455
|
+
class OpaCompiler {
|
|
311456
|
+
static CACHE_DIR = path.join(os.tmpdir(), 'visor-opa-cache');
|
|
311457
|
+
/**
|
|
311458
|
+
* Resolve the input paths to WASM bytes.
|
|
311459
|
+
*
|
|
311460
|
+
* Strategy:
|
|
311461
|
+
* 1. If any path is a .wasm file, read it directly
|
|
311462
|
+
* 2. If a directory contains policy.wasm, read it
|
|
311463
|
+
* 3. Otherwise, collect all .rego files and auto-compile via `opa build`
|
|
311464
|
+
*/
|
|
311465
|
+
async resolveWasmBytes(paths) {
|
|
311466
|
+
// Collect .rego files and check for existing .wasm
|
|
311467
|
+
const regoFiles = [];
|
|
311468
|
+
for (const p of paths) {
|
|
311469
|
+
const resolved = path.resolve(p);
|
|
311470
|
+
// Reject paths containing '..' after resolution (path traversal)
|
|
311471
|
+
if (path.normalize(resolved).includes('..')) {
|
|
311472
|
+
throw new Error(`Policy path contains traversal sequences: ${p}`);
|
|
311473
|
+
}
|
|
311474
|
+
// Direct .wasm file
|
|
311475
|
+
if (resolved.endsWith('.wasm') && fs.existsSync(resolved)) {
|
|
311476
|
+
return fs.readFileSync(resolved);
|
|
311477
|
+
}
|
|
311478
|
+
if (!fs.existsSync(resolved))
|
|
311479
|
+
continue;
|
|
311480
|
+
const stat = fs.statSync(resolved);
|
|
311481
|
+
if (stat.isDirectory()) {
|
|
311482
|
+
// Check for pre-compiled policy.wasm in directory
|
|
311483
|
+
const wasmCandidate = path.join(resolved, 'policy.wasm');
|
|
311484
|
+
if (fs.existsSync(wasmCandidate)) {
|
|
311485
|
+
return fs.readFileSync(wasmCandidate);
|
|
311486
|
+
}
|
|
311487
|
+
// Collect all .rego files from directory
|
|
311488
|
+
const files = fs.readdirSync(resolved);
|
|
311489
|
+
for (const f of files) {
|
|
311490
|
+
if (f.endsWith('.rego')) {
|
|
311491
|
+
regoFiles.push(path.join(resolved, f));
|
|
311492
|
+
}
|
|
311493
|
+
}
|
|
311494
|
+
}
|
|
311495
|
+
else if (resolved.endsWith('.rego')) {
|
|
311496
|
+
regoFiles.push(resolved);
|
|
311497
|
+
}
|
|
311498
|
+
}
|
|
311499
|
+
if (regoFiles.length === 0) {
|
|
311500
|
+
throw new Error(`OPA WASM evaluator: no .wasm bundle or .rego files found in: ${paths.join(', ')}`);
|
|
311501
|
+
}
|
|
311502
|
+
// Auto-compile .rego -> .wasm
|
|
311503
|
+
return this.compileRego(regoFiles);
|
|
311504
|
+
}
|
|
311505
|
+
/**
|
|
311506
|
+
* Auto-compile .rego files to a WASM bundle using the `opa` CLI.
|
|
311507
|
+
*
|
|
311508
|
+
* Caches the compiled bundle based on a content hash of all input .rego files
|
|
311509
|
+
* so subsequent runs skip compilation if policies haven't changed.
|
|
311510
|
+
*/
|
|
311511
|
+
compileRego(regoFiles) {
|
|
311512
|
+
// Check that `opa` CLI is available
|
|
311513
|
+
try {
|
|
311514
|
+
(0, child_process_1.execFileSync)('opa', ['version'], { stdio: 'pipe' });
|
|
311515
|
+
}
|
|
311516
|
+
catch {
|
|
311517
|
+
throw new Error('OPA CLI (`opa`) not found on PATH. Install it from https://www.openpolicyagent.org/docs/latest/#running-opa\n' +
|
|
311518
|
+
'Or pre-compile your .rego files: opa build -t wasm -e visor -o bundle.tar.gz ' +
|
|
311519
|
+
regoFiles.join(' '));
|
|
311520
|
+
}
|
|
311521
|
+
// Compute content hash for cache key
|
|
311522
|
+
const hash = crypto.createHash('sha256');
|
|
311523
|
+
for (const f of regoFiles.sort()) {
|
|
311524
|
+
hash.update(fs.readFileSync(f));
|
|
311525
|
+
hash.update(f); // include filename for disambiguation
|
|
311526
|
+
}
|
|
311527
|
+
const cacheKey = hash.digest('hex').slice(0, 16);
|
|
311528
|
+
const cacheDir = OpaCompiler.CACHE_DIR;
|
|
311529
|
+
const cachedWasm = path.join(cacheDir, `${cacheKey}.wasm`);
|
|
311530
|
+
// Return cached bundle if still valid
|
|
311531
|
+
if (fs.existsSync(cachedWasm)) {
|
|
311532
|
+
return fs.readFileSync(cachedWasm);
|
|
311533
|
+
}
|
|
311534
|
+
// Compile to WASM via opa build
|
|
311535
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
311536
|
+
const bundleTar = path.join(cacheDir, `${cacheKey}-bundle.tar.gz`);
|
|
311537
|
+
try {
|
|
311538
|
+
const args = [
|
|
311539
|
+
'build',
|
|
311540
|
+
'-t',
|
|
311541
|
+
'wasm',
|
|
311542
|
+
'-e',
|
|
311543
|
+
'visor', // entrypoint: the visor package tree
|
|
311544
|
+
'-o',
|
|
311545
|
+
bundleTar,
|
|
311546
|
+
...regoFiles,
|
|
311547
|
+
];
|
|
311548
|
+
(0, child_process_1.execFileSync)('opa', args, {
|
|
311549
|
+
stdio: 'pipe',
|
|
311550
|
+
timeout: 30000,
|
|
311551
|
+
});
|
|
311552
|
+
}
|
|
311553
|
+
catch (err) {
|
|
311554
|
+
const stderr = err?.stderr?.toString() || '';
|
|
311555
|
+
throw new Error(`Failed to compile .rego files to WASM:\n${stderr}\n` +
|
|
311556
|
+
'Ensure your .rego files are valid and the `opa` CLI is installed.');
|
|
311557
|
+
}
|
|
311558
|
+
// Extract policy.wasm from the tar.gz bundle
|
|
311559
|
+
// OPA bundles are tar.gz with /policy.wasm inside
|
|
311560
|
+
try {
|
|
311561
|
+
(0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, '/policy.wasm'], {
|
|
311562
|
+
stdio: 'pipe',
|
|
311563
|
+
});
|
|
311564
|
+
const extractedWasm = path.join(cacheDir, 'policy.wasm');
|
|
311565
|
+
if (fs.existsSync(extractedWasm)) {
|
|
311566
|
+
// Move to cache-key named file
|
|
311567
|
+
fs.renameSync(extractedWasm, cachedWasm);
|
|
311568
|
+
}
|
|
311569
|
+
}
|
|
311570
|
+
catch {
|
|
311571
|
+
// Some tar implementations don't like leading /
|
|
311572
|
+
try {
|
|
311573
|
+
(0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, 'policy.wasm'], {
|
|
311574
|
+
stdio: 'pipe',
|
|
311575
|
+
});
|
|
311576
|
+
const extractedWasm = path.join(cacheDir, 'policy.wasm');
|
|
311577
|
+
if (fs.existsSync(extractedWasm)) {
|
|
311578
|
+
fs.renameSync(extractedWasm, cachedWasm);
|
|
311579
|
+
}
|
|
311580
|
+
}
|
|
311581
|
+
catch (err2) {
|
|
311582
|
+
throw new Error(`Failed to extract policy.wasm from OPA bundle: ${err2?.message || err2}`);
|
|
311583
|
+
}
|
|
311584
|
+
}
|
|
311585
|
+
// Clean up tar
|
|
311586
|
+
try {
|
|
311587
|
+
fs.unlinkSync(bundleTar);
|
|
311588
|
+
}
|
|
311589
|
+
catch { }
|
|
311590
|
+
if (!fs.existsSync(cachedWasm)) {
|
|
311591
|
+
throw new Error('OPA build succeeded but policy.wasm was not found in the bundle');
|
|
311592
|
+
}
|
|
311593
|
+
return fs.readFileSync(cachedWasm);
|
|
311594
|
+
}
|
|
311595
|
+
}
|
|
311596
|
+
exports.OpaCompiler = OpaCompiler;
|
|
311597
|
+
|
|
311598
|
+
|
|
311599
|
+
/***/ }),
|
|
311600
|
+
|
|
311601
|
+
/***/ 44693:
|
|
311602
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
311603
|
+
|
|
311604
|
+
"use strict";
|
|
311605
|
+
|
|
311606
|
+
/**
|
|
311607
|
+
* Copyright (c) ProbeLabs. All rights reserved.
|
|
311608
|
+
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
311609
|
+
* in compliance with the Elastic License 2.0.
|
|
311610
|
+
*/
|
|
311611
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
311612
|
+
exports.OpaHttpEvaluator = void 0;
|
|
311613
|
+
/**
|
|
311614
|
+
* OPA HTTP Evaluator - evaluates policies via an external OPA server's REST API.
|
|
311615
|
+
*
|
|
311616
|
+
* Uses the built-in `fetch` API (Node 18+), so no extra dependencies are needed.
|
|
311617
|
+
*/
|
|
311618
|
+
class OpaHttpEvaluator {
|
|
311619
|
+
baseUrl;
|
|
311620
|
+
timeout;
|
|
311621
|
+
constructor(baseUrl, timeout = 5000) {
|
|
311622
|
+
// Validate URL format and protocol
|
|
311623
|
+
let parsed;
|
|
311624
|
+
try {
|
|
311625
|
+
parsed = new URL(baseUrl);
|
|
311626
|
+
}
|
|
311627
|
+
catch {
|
|
311628
|
+
throw new Error(`OPA HTTP evaluator: invalid URL: ${baseUrl}`);
|
|
311629
|
+
}
|
|
311630
|
+
if (!['http:', 'https:'].includes(parsed.protocol)) {
|
|
311631
|
+
throw new Error(`OPA HTTP evaluator: url must use http:// or https:// protocol, got: ${baseUrl}`);
|
|
311632
|
+
}
|
|
311633
|
+
// Block cloud metadata, loopback, link-local, and private network addresses
|
|
311634
|
+
const hostname = parsed.hostname;
|
|
311635
|
+
if (this.isBlockedHostname(hostname)) {
|
|
311636
|
+
throw new Error(`OPA HTTP evaluator: url must not point to internal, loopback, or private network addresses`);
|
|
311637
|
+
}
|
|
311638
|
+
// Normalize: strip trailing slash
|
|
311639
|
+
this.baseUrl = baseUrl.replace(/\/+$/, '');
|
|
311640
|
+
this.timeout = timeout;
|
|
311641
|
+
}
|
|
311642
|
+
/**
|
|
311643
|
+
* Check if a hostname is blocked due to SSRF concerns.
|
|
311644
|
+
*
|
|
311645
|
+
* Blocks:
|
|
311646
|
+
* - Loopback addresses (127.x.x.x, localhost, 0.0.0.0, ::1)
|
|
311647
|
+
* - Link-local addresses (169.254.x.x)
|
|
311648
|
+
* - Private networks (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
|
|
311649
|
+
* - IPv6 unique local addresses (fd00::/8)
|
|
311650
|
+
* - Cloud metadata services (*.internal)
|
|
311651
|
+
*/
|
|
311652
|
+
isBlockedHostname(hostname) {
|
|
311653
|
+
if (!hostname)
|
|
311654
|
+
return true; // block empty hostnames
|
|
311655
|
+
// Normalize hostname: lowercase and remove brackets for IPv6
|
|
311656
|
+
const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
|
|
311657
|
+
// Block .internal domains (cloud metadata services)
|
|
311658
|
+
if (normalized === 'metadata.google.internal' || normalized.endsWith('.internal')) {
|
|
311659
|
+
return true;
|
|
311660
|
+
}
|
|
311661
|
+
// Block localhost variants
|
|
311662
|
+
if (normalized === 'localhost' || normalized === 'localhost.localdomain') {
|
|
311663
|
+
return true;
|
|
311664
|
+
}
|
|
311665
|
+
// Block IPv6 loopback
|
|
311666
|
+
if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
|
|
311667
|
+
return true;
|
|
311668
|
+
}
|
|
311669
|
+
// Check IPv4 patterns
|
|
311670
|
+
const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
|
|
311671
|
+
const ipv4Match = normalized.match(ipv4Pattern);
|
|
311672
|
+
if (ipv4Match) {
|
|
311673
|
+
const octets = ipv4Match.slice(1, 5).map(Number);
|
|
311674
|
+
// Validate octets are in range [0, 255]
|
|
311675
|
+
if (octets.some(octet => octet > 255)) {
|
|
311676
|
+
return false;
|
|
311677
|
+
}
|
|
311678
|
+
const [a, b] = octets;
|
|
311679
|
+
// Block loopback: 127.0.0.0/8
|
|
311680
|
+
if (a === 127) {
|
|
311681
|
+
return true;
|
|
311682
|
+
}
|
|
311683
|
+
// Block 0.0.0.0/8 (this host)
|
|
311684
|
+
if (a === 0) {
|
|
311685
|
+
return true;
|
|
311686
|
+
}
|
|
311687
|
+
// Block link-local: 169.254.0.0/16
|
|
311688
|
+
if (a === 169 && b === 254) {
|
|
311689
|
+
return true;
|
|
311690
|
+
}
|
|
311691
|
+
// Block private networks
|
|
311692
|
+
// 10.0.0.0/8
|
|
311693
|
+
if (a === 10) {
|
|
311694
|
+
return true;
|
|
311695
|
+
}
|
|
311696
|
+
// 172.16.0.0/12 (172.16.x.x through 172.31.x.x)
|
|
311697
|
+
if (a === 172 && b >= 16 && b <= 31) {
|
|
311698
|
+
return true;
|
|
311699
|
+
}
|
|
311700
|
+
// 192.168.0.0/16
|
|
311701
|
+
if (a === 192 && b === 168) {
|
|
311702
|
+
return true;
|
|
311703
|
+
}
|
|
311704
|
+
}
|
|
311705
|
+
// Check IPv6 patterns
|
|
311706
|
+
// Block unique local addresses: fd00::/8
|
|
311707
|
+
if (normalized.startsWith('fd') || normalized.startsWith('fc')) {
|
|
311708
|
+
return true;
|
|
311709
|
+
}
|
|
311710
|
+
// Block link-local: fe80::/10
|
|
311711
|
+
if (normalized.startsWith('fe80:')) {
|
|
311712
|
+
return true;
|
|
311713
|
+
}
|
|
311714
|
+
return false;
|
|
311715
|
+
}
|
|
311716
|
+
/**
|
|
311717
|
+
* Evaluate a policy rule against an input document via OPA REST API.
|
|
311718
|
+
*
|
|
311719
|
+
* @param input - The input document to evaluate
|
|
311720
|
+
* @param rulePath - OPA rule path (e.g., 'visor/check/execute')
|
|
311721
|
+
* @returns The result object from OPA, or undefined on error
|
|
311722
|
+
*/
|
|
311723
|
+
async evaluate(input, rulePath) {
|
|
311724
|
+
// OPA Data API: POST /v1/data/<path>
|
|
311725
|
+
const encodedPath = rulePath
|
|
311726
|
+
.split('/')
|
|
311727
|
+
.map(s => encodeURIComponent(s))
|
|
311728
|
+
.join('/');
|
|
311729
|
+
const url = `${this.baseUrl}/v1/data/${encodedPath}`;
|
|
311730
|
+
const controller = new AbortController();
|
|
311731
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
311732
|
+
try {
|
|
311733
|
+
const response = await fetch(url, {
|
|
311734
|
+
method: 'POST',
|
|
311735
|
+
headers: { 'Content-Type': 'application/json' },
|
|
311736
|
+
body: JSON.stringify({ input }),
|
|
311737
|
+
signal: controller.signal,
|
|
311738
|
+
});
|
|
311739
|
+
if (!response.ok) {
|
|
311740
|
+
throw new Error(`OPA HTTP ${response.status}: ${response.statusText}`);
|
|
311741
|
+
}
|
|
311742
|
+
let body;
|
|
311743
|
+
try {
|
|
311744
|
+
body = await response.json();
|
|
311745
|
+
}
|
|
311746
|
+
catch (jsonErr) {
|
|
311747
|
+
throw new Error(`OPA HTTP evaluator: failed to parse JSON response: ${jsonErr instanceof Error ? jsonErr.message : String(jsonErr)}`);
|
|
311748
|
+
}
|
|
311749
|
+
// OPA returns { result: { ... } }
|
|
311750
|
+
return body?.result;
|
|
311751
|
+
}
|
|
311752
|
+
finally {
|
|
311753
|
+
clearTimeout(timer);
|
|
311754
|
+
}
|
|
311755
|
+
}
|
|
311756
|
+
async shutdown() {
|
|
311757
|
+
// No persistent connections to close
|
|
311758
|
+
}
|
|
311759
|
+
}
|
|
311760
|
+
exports.OpaHttpEvaluator = OpaHttpEvaluator;
|
|
311761
|
+
|
|
311762
|
+
|
|
311763
|
+
/***/ }),
|
|
311764
|
+
|
|
311765
|
+
/***/ 39530:
|
|
311766
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
311767
|
+
|
|
311768
|
+
"use strict";
|
|
311769
|
+
|
|
311770
|
+
/**
|
|
311771
|
+
* Copyright (c) ProbeLabs. All rights reserved.
|
|
311772
|
+
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
311773
|
+
* in compliance with the Elastic License 2.0.
|
|
311774
|
+
*/
|
|
311775
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
311776
|
+
exports.OpaPolicyEngine = void 0;
|
|
311777
|
+
const opa_wasm_evaluator_1 = __nccwpck_require__(8613);
|
|
311778
|
+
const opa_http_evaluator_1 = __nccwpck_require__(44693);
|
|
311779
|
+
const policy_input_builder_1 = __nccwpck_require__(17117);
|
|
311780
|
+
/**
|
|
311781
|
+
* Enterprise OPA Policy Engine.
|
|
311782
|
+
*
|
|
311783
|
+
* Wraps both WASM (local) and HTTP (remote) OPA evaluators behind the
|
|
311784
|
+
* OSS PolicyEngine interface. All OPA input building and role resolution
|
|
311785
|
+
* is handled internally — the OSS call sites pass only plain types.
|
|
311786
|
+
*/
|
|
311787
|
+
class OpaPolicyEngine {
|
|
311788
|
+
evaluator = null;
|
|
311789
|
+
fallback;
|
|
311790
|
+
timeout;
|
|
311791
|
+
config;
|
|
311792
|
+
inputBuilder = null;
|
|
311793
|
+
logger = null;
|
|
311794
|
+
constructor(config) {
|
|
311795
|
+
this.config = config;
|
|
311796
|
+
this.fallback = config.fallback || 'deny';
|
|
311797
|
+
this.timeout = config.timeout || 5000;
|
|
311798
|
+
}
|
|
311799
|
+
async initialize(config) {
|
|
311800
|
+
// Resolve logger once at initialization
|
|
311801
|
+
try {
|
|
311802
|
+
this.logger = (__nccwpck_require__(86999).logger);
|
|
311803
|
+
}
|
|
311804
|
+
catch {
|
|
311805
|
+
// logger not available in this context
|
|
311806
|
+
}
|
|
311807
|
+
// Build actor/repo context from environment (available at engine init time)
|
|
311808
|
+
const actor = {
|
|
311809
|
+
authorAssociation: process.env.VISOR_AUTHOR_ASSOCIATION,
|
|
311810
|
+
login: process.env.VISOR_AUTHOR_LOGIN || process.env.GITHUB_ACTOR,
|
|
311811
|
+
isLocalMode: !process.env.GITHUB_ACTIONS,
|
|
311812
|
+
};
|
|
311813
|
+
const repo = {
|
|
311814
|
+
owner: process.env.GITHUB_REPOSITORY_OWNER,
|
|
311815
|
+
name: process.env.GITHUB_REPOSITORY?.split('/')[1],
|
|
311816
|
+
branch: process.env.GITHUB_HEAD_REF,
|
|
311817
|
+
baseBranch: process.env.GITHUB_BASE_REF,
|
|
311818
|
+
event: process.env.GITHUB_EVENT_NAME,
|
|
311819
|
+
};
|
|
311820
|
+
const prNum = process.env.GITHUB_PR_NUMBER
|
|
311821
|
+
? parseInt(process.env.GITHUB_PR_NUMBER, 10)
|
|
311822
|
+
: undefined;
|
|
311823
|
+
const pullRequest = {
|
|
311824
|
+
number: prNum !== undefined && Number.isFinite(prNum) ? prNum : undefined,
|
|
311825
|
+
};
|
|
311826
|
+
this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(config, actor, repo, pullRequest);
|
|
311827
|
+
if (config.engine === 'local') {
|
|
311828
|
+
if (!config.rules) {
|
|
311829
|
+
throw new Error('OPA local mode requires `policy.rules` path to .wasm or .rego files');
|
|
311830
|
+
}
|
|
311831
|
+
const wasm = new opa_wasm_evaluator_1.OpaWasmEvaluator();
|
|
311832
|
+
await wasm.initialize(config.rules);
|
|
311833
|
+
if (config.data) {
|
|
311834
|
+
wasm.loadData(config.data);
|
|
311835
|
+
}
|
|
311836
|
+
this.evaluator = wasm;
|
|
311837
|
+
}
|
|
311838
|
+
else if (config.engine === 'remote') {
|
|
311839
|
+
if (!config.url) {
|
|
311840
|
+
throw new Error('OPA remote mode requires `policy.url` pointing to OPA server');
|
|
311841
|
+
}
|
|
311842
|
+
this.evaluator = new opa_http_evaluator_1.OpaHttpEvaluator(config.url, this.timeout);
|
|
311843
|
+
}
|
|
311844
|
+
else {
|
|
311845
|
+
this.evaluator = null;
|
|
311846
|
+
}
|
|
311847
|
+
}
|
|
311848
|
+
/**
|
|
311849
|
+
* Update actor/repo/PR context (e.g., after PR info becomes available).
|
|
311850
|
+
* Called by the enterprise loader when engine context is enriched.
|
|
311851
|
+
*/
|
|
311852
|
+
setActorContext(actor, repo, pullRequest) {
|
|
311853
|
+
this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(this.config, actor, repo, pullRequest);
|
|
311854
|
+
}
|
|
311855
|
+
async evaluateCheckExecution(checkId, checkConfig) {
|
|
311856
|
+
if (!this.evaluator || !this.inputBuilder)
|
|
311857
|
+
return { allowed: true };
|
|
311858
|
+
const cfg = checkConfig && typeof checkConfig === 'object'
|
|
311859
|
+
? checkConfig
|
|
311860
|
+
: {};
|
|
311861
|
+
const policyOverride = cfg.policy;
|
|
311862
|
+
const input = this.inputBuilder.forCheckExecution({
|
|
311863
|
+
id: checkId,
|
|
311864
|
+
type: cfg.type || 'ai',
|
|
311865
|
+
group: cfg.group,
|
|
311866
|
+
tags: cfg.tags,
|
|
311867
|
+
criticality: cfg.criticality,
|
|
311868
|
+
sandbox: cfg.sandbox,
|
|
311869
|
+
policy: policyOverride,
|
|
311870
|
+
});
|
|
311871
|
+
return this.doEvaluate(input, this.resolveRulePath('check.execute', policyOverride?.rule));
|
|
311872
|
+
}
|
|
311873
|
+
async evaluateToolInvocation(serverName, methodName, transport) {
|
|
311874
|
+
if (!this.evaluator || !this.inputBuilder)
|
|
311875
|
+
return { allowed: true };
|
|
311876
|
+
const input = this.inputBuilder.forToolInvocation(serverName, methodName, transport);
|
|
311877
|
+
return this.doEvaluate(input, 'visor/tool/invoke');
|
|
311878
|
+
}
|
|
311879
|
+
async evaluateCapabilities(checkId, capabilities) {
|
|
311880
|
+
if (!this.evaluator || !this.inputBuilder)
|
|
311881
|
+
return { allowed: true };
|
|
311882
|
+
const input = this.inputBuilder.forCapabilityResolve(checkId, capabilities);
|
|
311883
|
+
return this.doEvaluate(input, 'visor/capability/resolve');
|
|
311884
|
+
}
|
|
311885
|
+
async shutdown() {
|
|
311886
|
+
if (this.evaluator && 'shutdown' in this.evaluator) {
|
|
311887
|
+
await this.evaluator.shutdown();
|
|
311888
|
+
}
|
|
311889
|
+
this.evaluator = null;
|
|
311890
|
+
this.inputBuilder = null;
|
|
311891
|
+
}
|
|
311892
|
+
resolveRulePath(defaultScope, override) {
|
|
311893
|
+
if (override) {
|
|
311894
|
+
return override.startsWith('visor/') ? override : `visor/${override}`;
|
|
311895
|
+
}
|
|
311896
|
+
return `visor/${defaultScope.replace(/\./g, '/')}`;
|
|
311897
|
+
}
|
|
311898
|
+
async doEvaluate(input, rulePath) {
|
|
311899
|
+
try {
|
|
311900
|
+
this.logger?.debug(`[PolicyEngine] Evaluating ${rulePath}`, JSON.stringify(input));
|
|
311901
|
+
let timer;
|
|
311902
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
311903
|
+
timer = setTimeout(() => reject(new Error('policy evaluation timeout')), this.timeout);
|
|
311904
|
+
});
|
|
311905
|
+
try {
|
|
311906
|
+
const result = await Promise.race([this.rawEvaluate(input, rulePath), timeoutPromise]);
|
|
311907
|
+
const decision = this.parseDecision(result);
|
|
311908
|
+
// In warn mode, override denied decisions to allowed but flag as warn
|
|
311909
|
+
if (!decision.allowed && this.fallback === 'warn') {
|
|
311910
|
+
decision.allowed = true;
|
|
311911
|
+
decision.warn = true;
|
|
311912
|
+
decision.reason = `audit: ${decision.reason || 'policy denied'}`;
|
|
311913
|
+
}
|
|
311914
|
+
this.logger?.debug(`[PolicyEngine] Decision for ${rulePath}: allowed=${decision.allowed}, warn=${decision.warn || false}, reason=${decision.reason || 'none'}`);
|
|
311915
|
+
return decision;
|
|
311916
|
+
}
|
|
311917
|
+
finally {
|
|
311918
|
+
if (timer)
|
|
311919
|
+
clearTimeout(timer);
|
|
311920
|
+
}
|
|
311921
|
+
}
|
|
311922
|
+
catch (err) {
|
|
311923
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
311924
|
+
this.logger?.warn(`[PolicyEngine] Evaluation failed for ${rulePath}: ${msg}`);
|
|
311925
|
+
return {
|
|
311926
|
+
allowed: this.fallback === 'allow' || this.fallback === 'warn',
|
|
311927
|
+
warn: this.fallback === 'warn' ? true : undefined,
|
|
311928
|
+
reason: `policy evaluation failed, fallback=${this.fallback}`,
|
|
311929
|
+
};
|
|
311930
|
+
}
|
|
311931
|
+
}
|
|
311932
|
+
async rawEvaluate(input, rulePath) {
|
|
311933
|
+
if (this.evaluator instanceof opa_wasm_evaluator_1.OpaWasmEvaluator) {
|
|
311934
|
+
const result = await this.evaluator.evaluate(input);
|
|
311935
|
+
// WASM compiled with `-e visor` entrypoint returns the full visor package tree.
|
|
311936
|
+
// Navigate to the specific rule subtree using rulePath segments.
|
|
311937
|
+
// e.g., 'visor/check/execute' → result.check.execute
|
|
311938
|
+
return this.navigateWasmResult(result, rulePath);
|
|
311939
|
+
}
|
|
311940
|
+
return this.evaluator.evaluate(input, rulePath);
|
|
311941
|
+
}
|
|
311942
|
+
/**
|
|
311943
|
+
* Navigate nested OPA WASM result tree to reach the specific rule's output.
|
|
311944
|
+
* The WASM entrypoint `-e visor` means the result root IS the visor package,
|
|
311945
|
+
* so we strip the `visor/` prefix and walk the remaining segments.
|
|
311946
|
+
*/
|
|
311947
|
+
navigateWasmResult(result, rulePath) {
|
|
311948
|
+
if (!result || typeof result !== 'object')
|
|
311949
|
+
return result;
|
|
311950
|
+
// Strip the 'visor/' prefix (matches our compilation entrypoint)
|
|
311951
|
+
const segments = rulePath.replace(/^visor\//, '').split('/');
|
|
311952
|
+
let current = result;
|
|
311953
|
+
for (const seg of segments) {
|
|
311954
|
+
if (current && typeof current === 'object' && seg in current) {
|
|
311955
|
+
current = current[seg];
|
|
311956
|
+
}
|
|
311957
|
+
else {
|
|
311958
|
+
return undefined; // path not found in result tree
|
|
311959
|
+
}
|
|
311960
|
+
}
|
|
311961
|
+
return current;
|
|
311962
|
+
}
|
|
311963
|
+
parseDecision(result) {
|
|
311964
|
+
if (result === undefined || result === null) {
|
|
311965
|
+
return {
|
|
311966
|
+
allowed: this.fallback === 'allow' || this.fallback === 'warn',
|
|
311967
|
+
warn: this.fallback === 'warn' ? true : undefined,
|
|
311968
|
+
reason: this.fallback === 'warn' ? 'audit: no policy result' : 'no policy result',
|
|
311969
|
+
};
|
|
311970
|
+
}
|
|
311971
|
+
const allowed = result.allowed !== false;
|
|
311972
|
+
const decision = {
|
|
311973
|
+
allowed,
|
|
311974
|
+
reason: result.reason,
|
|
311975
|
+
};
|
|
311976
|
+
if (result.capabilities) {
|
|
311977
|
+
decision.capabilities = result.capabilities;
|
|
311978
|
+
}
|
|
311979
|
+
return decision;
|
|
311980
|
+
}
|
|
311981
|
+
}
|
|
311982
|
+
exports.OpaPolicyEngine = OpaPolicyEngine;
|
|
311983
|
+
|
|
311984
|
+
|
|
311985
|
+
/***/ }),
|
|
311986
|
+
|
|
311987
|
+
/***/ 8613:
|
|
311988
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
311989
|
+
|
|
311990
|
+
"use strict";
|
|
311991
|
+
|
|
311992
|
+
/**
|
|
311993
|
+
* Copyright (c) ProbeLabs. All rights reserved.
|
|
311994
|
+
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
311995
|
+
* in compliance with the Elastic License 2.0.
|
|
311996
|
+
*/
|
|
311997
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
311998
|
+
if (k2 === undefined) k2 = k;
|
|
311999
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
312000
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
312001
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
312002
|
+
}
|
|
312003
|
+
Object.defineProperty(o, k2, desc);
|
|
312004
|
+
}) : (function(o, m, k, k2) {
|
|
312005
|
+
if (k2 === undefined) k2 = k;
|
|
312006
|
+
o[k2] = m[k];
|
|
312007
|
+
}));
|
|
312008
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
312009
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
312010
|
+
}) : function(o, v) {
|
|
312011
|
+
o["default"] = v;
|
|
312012
|
+
});
|
|
312013
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
312014
|
+
var ownKeys = function(o) {
|
|
312015
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
312016
|
+
var ar = [];
|
|
312017
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
312018
|
+
return ar;
|
|
312019
|
+
};
|
|
312020
|
+
return ownKeys(o);
|
|
312021
|
+
};
|
|
312022
|
+
return function (mod) {
|
|
312023
|
+
if (mod && mod.__esModule) return mod;
|
|
312024
|
+
var result = {};
|
|
312025
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
312026
|
+
__setModuleDefault(result, mod);
|
|
312027
|
+
return result;
|
|
312028
|
+
};
|
|
312029
|
+
})();
|
|
312030
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
312031
|
+
exports.OpaWasmEvaluator = void 0;
|
|
312032
|
+
const fs = __importStar(__nccwpck_require__(79896));
|
|
312033
|
+
const path = __importStar(__nccwpck_require__(16928));
|
|
312034
|
+
const opa_compiler_1 = __nccwpck_require__(628);
|
|
312035
|
+
/**
|
|
312036
|
+
* OPA WASM Evaluator - loads and evaluates OPA policies locally.
|
|
312037
|
+
*
|
|
312038
|
+
* Supports three input formats:
|
|
312039
|
+
* 1. Pre-compiled `.wasm` bundle — loaded directly (fastest startup)
|
|
312040
|
+
* 2. `.rego` files or directory — auto-compiled to WASM via `opa build` CLI
|
|
312041
|
+
* 3. Directory with `policy.wasm` inside — loaded directly
|
|
312042
|
+
*
|
|
312043
|
+
* Compilation and caching of .rego files is delegated to {@link OpaCompiler}.
|
|
312044
|
+
*
|
|
312045
|
+
* Requires:
|
|
312046
|
+
* - `@open-policy-agent/opa-wasm` npm package (optional dep)
|
|
312047
|
+
* - `opa` CLI on PATH (only when auto-compiling .rego files)
|
|
312048
|
+
*/
|
|
312049
|
+
class OpaWasmEvaluator {
|
|
312050
|
+
policy = null;
|
|
312051
|
+
dataDocument = {};
|
|
312052
|
+
compiler = new opa_compiler_1.OpaCompiler();
|
|
312053
|
+
async initialize(rulesPath) {
|
|
312054
|
+
const paths = Array.isArray(rulesPath) ? rulesPath : [rulesPath];
|
|
312055
|
+
const wasmBytes = await this.compiler.resolveWasmBytes(paths);
|
|
312056
|
+
try {
|
|
312057
|
+
// Use createRequire to load the optional dep at runtime without ncc bundling it.
|
|
312058
|
+
// `new Function('id', 'return require(id)')` fails in ncc bundles because
|
|
312059
|
+
// `require` is not in the `new Function` scope. `createRequire` works correctly
|
|
312060
|
+
// because it creates a real Node.js require rooted at the given path.
|
|
312061
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
312062
|
+
const { createRequire } = __nccwpck_require__(73339);
|
|
312063
|
+
const runtimeRequire = createRequire(__filename);
|
|
312064
|
+
const opaWasm = runtimeRequire('@open-policy-agent/opa-wasm');
|
|
312065
|
+
const loadPolicy = opaWasm.loadPolicy || opaWasm.default?.loadPolicy;
|
|
312066
|
+
if (!loadPolicy) {
|
|
312067
|
+
throw new Error('loadPolicy not found in @open-policy-agent/opa-wasm');
|
|
312068
|
+
}
|
|
312069
|
+
this.policy = await loadPolicy(wasmBytes);
|
|
312070
|
+
}
|
|
312071
|
+
catch (err) {
|
|
312072
|
+
if (err?.code === 'MODULE_NOT_FOUND' || err?.code === 'ERR_MODULE_NOT_FOUND') {
|
|
312073
|
+
throw new Error('OPA WASM evaluator requires @open-policy-agent/opa-wasm. ' +
|
|
312074
|
+
'Install it with: npm install @open-policy-agent/opa-wasm');
|
|
312075
|
+
}
|
|
312076
|
+
throw err;
|
|
312077
|
+
}
|
|
312078
|
+
}
|
|
312079
|
+
/**
|
|
312080
|
+
* Load external data from a JSON file to use as the OPA data document.
|
|
312081
|
+
* The loaded data will be passed to `policy.setData()` during evaluation,
|
|
312082
|
+
* making it available in Rego via `data.<key>`.
|
|
312083
|
+
*/
|
|
312084
|
+
loadData(dataPath) {
|
|
312085
|
+
const resolved = path.resolve(dataPath);
|
|
312086
|
+
if (path.normalize(resolved).includes('..')) {
|
|
312087
|
+
throw new Error(`Data path contains traversal sequences: ${dataPath}`);
|
|
312088
|
+
}
|
|
312089
|
+
if (!fs.existsSync(resolved)) {
|
|
312090
|
+
throw new Error(`OPA data file not found: ${resolved}`);
|
|
312091
|
+
}
|
|
312092
|
+
const stat = fs.statSync(resolved);
|
|
312093
|
+
if (stat.size > 10 * 1024 * 1024) {
|
|
312094
|
+
throw new Error(`OPA data file exceeds 10MB limit: ${resolved} (${stat.size} bytes)`);
|
|
312095
|
+
}
|
|
312096
|
+
const raw = fs.readFileSync(resolved, 'utf-8');
|
|
312097
|
+
try {
|
|
312098
|
+
const parsed = JSON.parse(raw);
|
|
312099
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
312100
|
+
throw new Error('OPA data file must contain a JSON object (not an array or primitive)');
|
|
312101
|
+
}
|
|
312102
|
+
this.dataDocument = parsed;
|
|
312103
|
+
}
|
|
312104
|
+
catch (err) {
|
|
312105
|
+
if (err.message.startsWith('OPA data file must')) {
|
|
312106
|
+
throw err;
|
|
312107
|
+
}
|
|
312108
|
+
throw new Error(`Failed to parse OPA data file ${resolved}: ${err.message}`);
|
|
312109
|
+
}
|
|
312110
|
+
}
|
|
312111
|
+
async evaluate(input) {
|
|
312112
|
+
if (!this.policy) {
|
|
312113
|
+
throw new Error('OPA WASM evaluator not initialized');
|
|
312114
|
+
}
|
|
312115
|
+
this.policy.setData(this.dataDocument);
|
|
312116
|
+
const resultSet = this.policy.evaluate(input);
|
|
312117
|
+
if (Array.isArray(resultSet) && resultSet.length > 0) {
|
|
312118
|
+
return resultSet[0].result;
|
|
312119
|
+
}
|
|
312120
|
+
return undefined;
|
|
312121
|
+
}
|
|
312122
|
+
async shutdown() {
|
|
312123
|
+
if (this.policy) {
|
|
312124
|
+
// opa-wasm policy objects may have a close/free method for WASM cleanup
|
|
312125
|
+
if (typeof this.policy.close === 'function') {
|
|
312126
|
+
try {
|
|
312127
|
+
this.policy.close();
|
|
312128
|
+
}
|
|
312129
|
+
catch { }
|
|
312130
|
+
}
|
|
312131
|
+
else if (typeof this.policy.free === 'function') {
|
|
312132
|
+
try {
|
|
312133
|
+
this.policy.free();
|
|
312134
|
+
}
|
|
312135
|
+
catch { }
|
|
312136
|
+
}
|
|
312137
|
+
}
|
|
312138
|
+
this.policy = null;
|
|
312139
|
+
}
|
|
312140
|
+
}
|
|
312141
|
+
exports.OpaWasmEvaluator = OpaWasmEvaluator;
|
|
312142
|
+
|
|
312143
|
+
|
|
312144
|
+
/***/ }),
|
|
312145
|
+
|
|
312146
|
+
/***/ 17117:
|
|
312147
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
312148
|
+
|
|
312149
|
+
"use strict";
|
|
312150
|
+
|
|
312151
|
+
/**
|
|
312152
|
+
* Copyright (c) ProbeLabs. All rights reserved.
|
|
312153
|
+
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
312154
|
+
* in compliance with the Elastic License 2.0.
|
|
312155
|
+
*/
|
|
312156
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
312157
|
+
exports.PolicyInputBuilder = void 0;
|
|
312158
|
+
/**
|
|
312159
|
+
* Builds OPA-compatible input documents from engine context.
|
|
312160
|
+
*
|
|
312161
|
+
* Resolves actor roles from the `policy.roles` config section by matching
|
|
312162
|
+
* the actor's authorAssociation and login against role definitions.
|
|
312163
|
+
*/
|
|
312164
|
+
class PolicyInputBuilder {
|
|
312165
|
+
roles;
|
|
312166
|
+
actor;
|
|
312167
|
+
repository;
|
|
312168
|
+
pullRequest;
|
|
312169
|
+
constructor(policyConfig, actor, repository, pullRequest) {
|
|
312170
|
+
this.roles = policyConfig.roles || {};
|
|
312171
|
+
this.actor = actor;
|
|
312172
|
+
this.repository = repository;
|
|
312173
|
+
this.pullRequest = pullRequest;
|
|
312174
|
+
}
|
|
312175
|
+
/** Resolve which roles apply to the current actor. */
|
|
312176
|
+
resolveRoles() {
|
|
312177
|
+
const matched = [];
|
|
312178
|
+
for (const [roleName, roleConfig] of Object.entries(this.roles)) {
|
|
312179
|
+
let identityMatch = false;
|
|
312180
|
+
if (roleConfig.author_association &&
|
|
312181
|
+
this.actor.authorAssociation &&
|
|
312182
|
+
roleConfig.author_association.includes(this.actor.authorAssociation)) {
|
|
312183
|
+
identityMatch = true;
|
|
312184
|
+
}
|
|
312185
|
+
if (!identityMatch &&
|
|
312186
|
+
roleConfig.users &&
|
|
312187
|
+
this.actor.login &&
|
|
312188
|
+
roleConfig.users.includes(this.actor.login)) {
|
|
312189
|
+
identityMatch = true;
|
|
312190
|
+
}
|
|
312191
|
+
// Slack user ID match
|
|
312192
|
+
if (!identityMatch &&
|
|
312193
|
+
roleConfig.slack_users &&
|
|
312194
|
+
this.actor.slack?.userId &&
|
|
312195
|
+
roleConfig.slack_users.includes(this.actor.slack.userId)) {
|
|
312196
|
+
identityMatch = true;
|
|
312197
|
+
}
|
|
312198
|
+
// Email match (case-insensitive)
|
|
312199
|
+
if (!identityMatch && roleConfig.emails && this.actor.slack?.email) {
|
|
312200
|
+
const actorEmail = this.actor.slack.email.toLowerCase();
|
|
312201
|
+
if (roleConfig.emails.some(e => e.toLowerCase() === actorEmail)) {
|
|
312202
|
+
identityMatch = true;
|
|
312203
|
+
}
|
|
312204
|
+
}
|
|
312205
|
+
// Note: teams-based role resolution requires GitHub API access (read:org scope)
|
|
312206
|
+
// and is not yet implemented. If configured, the role will not match via teams.
|
|
312207
|
+
if (!identityMatch)
|
|
312208
|
+
continue;
|
|
312209
|
+
// slack_channels gate: if set, the role only applies when triggered from one of these channels
|
|
312210
|
+
if (roleConfig.slack_channels && roleConfig.slack_channels.length > 0) {
|
|
312211
|
+
if (!this.actor.slack?.channelId ||
|
|
312212
|
+
!roleConfig.slack_channels.includes(this.actor.slack.channelId)) {
|
|
312213
|
+
continue;
|
|
312214
|
+
}
|
|
312215
|
+
}
|
|
312216
|
+
matched.push(roleName);
|
|
312217
|
+
}
|
|
312218
|
+
return matched;
|
|
312219
|
+
}
|
|
312220
|
+
buildActor() {
|
|
312221
|
+
return {
|
|
312222
|
+
authorAssociation: this.actor.authorAssociation,
|
|
312223
|
+
login: this.actor.login,
|
|
312224
|
+
roles: this.resolveRoles(),
|
|
312225
|
+
isLocalMode: this.actor.isLocalMode,
|
|
312226
|
+
...(this.actor.slack && { slack: this.actor.slack }),
|
|
312227
|
+
};
|
|
312228
|
+
}
|
|
312229
|
+
forCheckExecution(check) {
|
|
312230
|
+
return {
|
|
312231
|
+
scope: 'check.execute',
|
|
312232
|
+
check: {
|
|
312233
|
+
id: check.id,
|
|
312234
|
+
type: check.type,
|
|
312235
|
+
group: check.group,
|
|
312236
|
+
tags: check.tags,
|
|
312237
|
+
criticality: check.criticality,
|
|
312238
|
+
sandbox: check.sandbox,
|
|
312239
|
+
policy: check.policy,
|
|
312240
|
+
},
|
|
312241
|
+
actor: this.buildActor(),
|
|
312242
|
+
repository: this.repository,
|
|
312243
|
+
pullRequest: this.pullRequest,
|
|
312244
|
+
};
|
|
312245
|
+
}
|
|
312246
|
+
forToolInvocation(serverName, methodName, transport) {
|
|
312247
|
+
return {
|
|
312248
|
+
scope: 'tool.invoke',
|
|
312249
|
+
tool: { serverName, methodName, transport },
|
|
312250
|
+
actor: this.buildActor(),
|
|
312251
|
+
repository: this.repository,
|
|
312252
|
+
pullRequest: this.pullRequest,
|
|
312253
|
+
};
|
|
312254
|
+
}
|
|
312255
|
+
forCapabilityResolve(checkId, capabilities) {
|
|
312256
|
+
return {
|
|
312257
|
+
scope: 'capability.resolve',
|
|
312258
|
+
check: { id: checkId, type: 'ai' },
|
|
312259
|
+
capability: capabilities,
|
|
312260
|
+
actor: this.buildActor(),
|
|
312261
|
+
repository: this.repository,
|
|
312262
|
+
pullRequest: this.pullRequest,
|
|
312263
|
+
};
|
|
312264
|
+
}
|
|
312265
|
+
}
|
|
312266
|
+
exports.PolicyInputBuilder = PolicyInputBuilder;
|
|
312267
|
+
|
|
312268
|
+
|
|
312269
|
+
/***/ }),
|
|
312270
|
+
|
|
312271
|
+
/***/ 63737:
|
|
312272
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
312273
|
+
|
|
312274
|
+
"use strict";
|
|
312275
|
+
|
|
312276
|
+
/**
|
|
312277
|
+
* Copyright (c) ProbeLabs. All rights reserved.
|
|
312278
|
+
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
312279
|
+
* in compliance with the Elastic License 2.0.
|
|
312280
|
+
*/
|
|
312281
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
312282
|
+
if (k2 === undefined) k2 = k;
|
|
312283
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
312284
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
312285
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
312286
|
+
}
|
|
312287
|
+
Object.defineProperty(o, k2, desc);
|
|
312288
|
+
}) : (function(o, m, k, k2) {
|
|
312289
|
+
if (k2 === undefined) k2 = k;
|
|
312290
|
+
o[k2] = m[k];
|
|
312291
|
+
}));
|
|
312292
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
312293
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
312294
|
+
}) : function(o, v) {
|
|
312295
|
+
o["default"] = v;
|
|
312296
|
+
});
|
|
312297
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
312298
|
+
var ownKeys = function(o) {
|
|
312299
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
312300
|
+
var ar = [];
|
|
312301
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
312302
|
+
return ar;
|
|
312303
|
+
};
|
|
312304
|
+
return ownKeys(o);
|
|
312305
|
+
};
|
|
312306
|
+
return function (mod) {
|
|
312307
|
+
if (mod && mod.__esModule) return mod;
|
|
312308
|
+
var result = {};
|
|
312309
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
312310
|
+
__setModuleDefault(result, mod);
|
|
312311
|
+
return result;
|
|
312312
|
+
};
|
|
312313
|
+
})();
|
|
312314
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
312315
|
+
exports.KnexStoreBackend = void 0;
|
|
312316
|
+
/**
|
|
312317
|
+
* Knex-backed schedule store for PostgreSQL, MySQL, and MSSQL (Enterprise)
|
|
312318
|
+
*
|
|
312319
|
+
* Uses Knex query builder for database-agnostic SQL. Same schema as SQLite backend
|
|
312320
|
+
* but with real distributed locking via row-level claims (claimed_by/claimed_at/lock_token).
|
|
312321
|
+
*/
|
|
312322
|
+
const fs = __importStar(__nccwpck_require__(79896));
|
|
312323
|
+
const path = __importStar(__nccwpck_require__(16928));
|
|
312324
|
+
const uuid_1 = __nccwpck_require__(31914);
|
|
312325
|
+
const logger_1 = __nccwpck_require__(86999);
|
|
312326
|
+
function toNum(val) {
|
|
312327
|
+
if (val === null || val === undefined)
|
|
312328
|
+
return undefined;
|
|
312329
|
+
return typeof val === 'string' ? parseInt(val, 10) : val;
|
|
312330
|
+
}
|
|
312331
|
+
function safeJsonParse(value) {
|
|
312332
|
+
if (!value)
|
|
312333
|
+
return undefined;
|
|
312334
|
+
try {
|
|
312335
|
+
return JSON.parse(value);
|
|
312336
|
+
}
|
|
312337
|
+
catch {
|
|
312338
|
+
return undefined;
|
|
312339
|
+
}
|
|
312340
|
+
}
|
|
312341
|
+
function fromTriggerRow(row) {
|
|
312342
|
+
return {
|
|
312343
|
+
id: row.id,
|
|
312344
|
+
creatorId: row.creator_id,
|
|
312345
|
+
creatorContext: row.creator_context ?? undefined,
|
|
312346
|
+
creatorName: row.creator_name ?? undefined,
|
|
312347
|
+
description: row.description ?? undefined,
|
|
312348
|
+
channels: safeJsonParse(row.channels),
|
|
312349
|
+
fromUsers: safeJsonParse(row.from_users),
|
|
312350
|
+
fromBots: row.from_bots === true || row.from_bots === 1,
|
|
312351
|
+
contains: safeJsonParse(row.contains),
|
|
312352
|
+
matchPattern: row.match_pattern ?? undefined,
|
|
312353
|
+
threads: row.threads,
|
|
312354
|
+
workflow: row.workflow,
|
|
312355
|
+
inputs: safeJsonParse(row.inputs),
|
|
312356
|
+
outputContext: safeJsonParse(row.output_context),
|
|
312357
|
+
status: row.status,
|
|
312358
|
+
enabled: row.enabled === true || row.enabled === 1,
|
|
312359
|
+
createdAt: toNum(row.created_at),
|
|
312360
|
+
};
|
|
312361
|
+
}
|
|
312362
|
+
function toTriggerInsertRow(trigger) {
|
|
312363
|
+
return {
|
|
312364
|
+
id: trigger.id,
|
|
312365
|
+
creator_id: trigger.creatorId,
|
|
312366
|
+
creator_context: trigger.creatorContext ?? null,
|
|
312367
|
+
creator_name: trigger.creatorName ?? null,
|
|
312368
|
+
description: trigger.description ?? null,
|
|
312369
|
+
channels: trigger.channels ? JSON.stringify(trigger.channels) : null,
|
|
312370
|
+
from_users: trigger.fromUsers ? JSON.stringify(trigger.fromUsers) : null,
|
|
312371
|
+
from_bots: trigger.fromBots,
|
|
312372
|
+
contains: trigger.contains ? JSON.stringify(trigger.contains) : null,
|
|
312373
|
+
match_pattern: trigger.matchPattern ?? null,
|
|
312374
|
+
threads: trigger.threads,
|
|
312375
|
+
workflow: trigger.workflow,
|
|
312376
|
+
inputs: trigger.inputs ? JSON.stringify(trigger.inputs) : null,
|
|
312377
|
+
output_context: trigger.outputContext ? JSON.stringify(trigger.outputContext) : null,
|
|
312378
|
+
status: trigger.status,
|
|
312379
|
+
enabled: trigger.enabled,
|
|
312380
|
+
created_at: trigger.createdAt,
|
|
312381
|
+
};
|
|
312382
|
+
}
|
|
312383
|
+
function fromDbRow(row) {
|
|
312384
|
+
return {
|
|
312385
|
+
id: row.id,
|
|
312386
|
+
creatorId: row.creator_id,
|
|
312387
|
+
creatorContext: row.creator_context ?? undefined,
|
|
312388
|
+
creatorName: row.creator_name ?? undefined,
|
|
312389
|
+
timezone: row.timezone,
|
|
312390
|
+
schedule: row.schedule_expr,
|
|
312391
|
+
runAt: toNum(row.run_at),
|
|
312392
|
+
isRecurring: row.is_recurring === true || row.is_recurring === 1,
|
|
312393
|
+
originalExpression: row.original_expression,
|
|
312394
|
+
workflow: row.workflow ?? undefined,
|
|
312395
|
+
workflowInputs: safeJsonParse(row.workflow_inputs),
|
|
312396
|
+
outputContext: safeJsonParse(row.output_context),
|
|
312397
|
+
status: row.status,
|
|
312398
|
+
createdAt: toNum(row.created_at),
|
|
312399
|
+
lastRunAt: toNum(row.last_run_at),
|
|
312400
|
+
nextRunAt: toNum(row.next_run_at),
|
|
312401
|
+
runCount: row.run_count,
|
|
312402
|
+
failureCount: row.failure_count,
|
|
312403
|
+
lastError: row.last_error ?? undefined,
|
|
312404
|
+
previousResponse: row.previous_response ?? undefined,
|
|
312405
|
+
};
|
|
312406
|
+
}
|
|
312407
|
+
function toInsertRow(schedule) {
|
|
312408
|
+
return {
|
|
312409
|
+
id: schedule.id,
|
|
312410
|
+
creator_id: schedule.creatorId,
|
|
312411
|
+
creator_context: schedule.creatorContext ?? null,
|
|
312412
|
+
creator_name: schedule.creatorName ?? null,
|
|
312413
|
+
timezone: schedule.timezone,
|
|
312414
|
+
schedule_expr: schedule.schedule,
|
|
312415
|
+
run_at: schedule.runAt ?? null,
|
|
312416
|
+
is_recurring: schedule.isRecurring,
|
|
312417
|
+
original_expression: schedule.originalExpression,
|
|
312418
|
+
workflow: schedule.workflow ?? null,
|
|
312419
|
+
workflow_inputs: schedule.workflowInputs ? JSON.stringify(schedule.workflowInputs) : null,
|
|
312420
|
+
output_context: schedule.outputContext ? JSON.stringify(schedule.outputContext) : null,
|
|
312421
|
+
status: schedule.status,
|
|
312422
|
+
created_at: schedule.createdAt,
|
|
312423
|
+
last_run_at: schedule.lastRunAt ?? null,
|
|
312424
|
+
next_run_at: schedule.nextRunAt ?? null,
|
|
312425
|
+
run_count: schedule.runCount,
|
|
312426
|
+
failure_count: schedule.failureCount,
|
|
312427
|
+
last_error: schedule.lastError ?? null,
|
|
312428
|
+
previous_response: schedule.previousResponse ?? null,
|
|
312429
|
+
};
|
|
312430
|
+
}
|
|
312431
|
+
/**
|
|
312432
|
+
* Enterprise Knex-backed store for PostgreSQL, MySQL, and MSSQL
|
|
312433
|
+
*/
|
|
312434
|
+
class KnexStoreBackend {
|
|
312435
|
+
knex = null;
|
|
312436
|
+
driver;
|
|
312437
|
+
connection;
|
|
312438
|
+
constructor(driver, storageConfig, _haConfig) {
|
|
312439
|
+
this.driver = driver;
|
|
312440
|
+
this.connection = (storageConfig.connection || {});
|
|
312441
|
+
}
|
|
312442
|
+
async initialize() {
|
|
312443
|
+
// Load knex dynamically
|
|
312444
|
+
const { createRequire } = __nccwpck_require__(73339);
|
|
312445
|
+
const runtimeRequire = createRequire(__filename);
|
|
312446
|
+
let knexFactory;
|
|
312447
|
+
try {
|
|
312448
|
+
knexFactory = runtimeRequire('knex');
|
|
312449
|
+
}
|
|
312450
|
+
catch (err) {
|
|
312451
|
+
const code = err?.code;
|
|
312452
|
+
if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
|
|
312453
|
+
throw new Error('knex is required for PostgreSQL/MySQL/MSSQL schedule storage. ' +
|
|
312454
|
+
'Install it with: npm install knex');
|
|
312455
|
+
}
|
|
312456
|
+
throw err;
|
|
312457
|
+
}
|
|
312458
|
+
const clientMap = {
|
|
312459
|
+
postgresql: 'pg',
|
|
312460
|
+
mysql: 'mysql2',
|
|
312461
|
+
mssql: 'tedious',
|
|
312462
|
+
};
|
|
312463
|
+
const client = clientMap[this.driver];
|
|
312464
|
+
// Build connection config
|
|
312465
|
+
let connection;
|
|
312466
|
+
if (this.connection.connection_string) {
|
|
312467
|
+
connection = this.connection.connection_string;
|
|
312468
|
+
}
|
|
312469
|
+
else if (this.driver === 'mssql') {
|
|
312470
|
+
connection = this.buildMssqlConnection();
|
|
312471
|
+
}
|
|
312472
|
+
else {
|
|
312473
|
+
connection = this.buildStandardConnection();
|
|
312474
|
+
}
|
|
312475
|
+
this.knex = knexFactory({
|
|
312476
|
+
client,
|
|
312477
|
+
connection,
|
|
312478
|
+
pool: {
|
|
312479
|
+
min: this.connection.pool?.min ?? 0,
|
|
312480
|
+
max: this.connection.pool?.max ?? 10,
|
|
312481
|
+
},
|
|
312482
|
+
});
|
|
312483
|
+
// Run schema migration
|
|
312484
|
+
await this.migrateSchema();
|
|
312485
|
+
logger_1.logger.info(`[KnexStore] Initialized (${this.driver})`);
|
|
312486
|
+
}
|
|
312487
|
+
buildStandardConnection() {
|
|
312488
|
+
return {
|
|
312489
|
+
host: this.connection.host || 'localhost',
|
|
312490
|
+
port: this.connection.port,
|
|
312491
|
+
database: this.connection.database || 'visor',
|
|
312492
|
+
user: this.connection.user,
|
|
312493
|
+
password: this.connection.password,
|
|
312494
|
+
ssl: this.resolveSslConfig(),
|
|
312495
|
+
};
|
|
312496
|
+
}
|
|
312497
|
+
buildMssqlConnection() {
|
|
312498
|
+
const ssl = this.connection.ssl;
|
|
312499
|
+
const sslEnabled = ssl === true || (typeof ssl === 'object' && ssl.enabled !== false);
|
|
312500
|
+
return {
|
|
312501
|
+
server: this.connection.host || 'localhost',
|
|
312502
|
+
port: this.connection.port,
|
|
312503
|
+
database: this.connection.database || 'visor',
|
|
312504
|
+
user: this.connection.user,
|
|
312505
|
+
password: this.connection.password,
|
|
312506
|
+
options: {
|
|
312507
|
+
encrypt: sslEnabled,
|
|
312508
|
+
trustServerCertificate: typeof ssl === 'object' ? ssl.reject_unauthorized === false : !sslEnabled,
|
|
312509
|
+
},
|
|
312510
|
+
};
|
|
312511
|
+
}
|
|
312512
|
+
resolveSslConfig() {
|
|
312513
|
+
const ssl = this.connection.ssl;
|
|
312514
|
+
if (ssl === false || ssl === undefined)
|
|
312515
|
+
return false;
|
|
312516
|
+
if (ssl === true)
|
|
312517
|
+
return { rejectUnauthorized: true };
|
|
312518
|
+
// Object config
|
|
312519
|
+
if (ssl.enabled === false)
|
|
312520
|
+
return false;
|
|
312521
|
+
const result = {
|
|
312522
|
+
rejectUnauthorized: ssl.reject_unauthorized !== false,
|
|
312523
|
+
};
|
|
312524
|
+
if (ssl.ca) {
|
|
312525
|
+
const caPath = this.validateSslPath(ssl.ca, 'CA certificate');
|
|
312526
|
+
result.ca = fs.readFileSync(caPath, 'utf8');
|
|
312527
|
+
}
|
|
312528
|
+
if (ssl.cert) {
|
|
312529
|
+
const certPath = this.validateSslPath(ssl.cert, 'client certificate');
|
|
312530
|
+
result.cert = fs.readFileSync(certPath, 'utf8');
|
|
312531
|
+
}
|
|
312532
|
+
if (ssl.key) {
|
|
312533
|
+
const keyPath = this.validateSslPath(ssl.key, 'client key');
|
|
312534
|
+
result.key = fs.readFileSync(keyPath, 'utf8');
|
|
312535
|
+
}
|
|
312536
|
+
return result;
|
|
312537
|
+
}
|
|
312538
|
+
validateSslPath(filePath, label) {
|
|
312539
|
+
const resolved = path.resolve(filePath);
|
|
312540
|
+
if (resolved !== path.normalize(resolved)) {
|
|
312541
|
+
throw new Error(`SSL ${label} path contains invalid sequences: ${filePath}`);
|
|
312542
|
+
}
|
|
312543
|
+
if (!fs.existsSync(resolved)) {
|
|
312544
|
+
throw new Error(`SSL ${label} not found: ${filePath}`);
|
|
312545
|
+
}
|
|
312546
|
+
return resolved;
|
|
312547
|
+
}
|
|
312548
|
+
async shutdown() {
|
|
312549
|
+
if (this.knex) {
|
|
312550
|
+
await this.knex.destroy();
|
|
312551
|
+
this.knex = null;
|
|
312552
|
+
}
|
|
312553
|
+
}
|
|
312554
|
+
async migrateSchema() {
|
|
312555
|
+
const knex = this.getKnex();
|
|
312556
|
+
const exists = await knex.schema.hasTable('schedules');
|
|
312557
|
+
if (!exists) {
|
|
312558
|
+
await knex.schema.createTable('schedules', table => {
|
|
312559
|
+
table.string('id', 36).primary();
|
|
312560
|
+
table.string('creator_id', 255).notNullable().index();
|
|
312561
|
+
table.string('creator_context', 255);
|
|
312562
|
+
table.string('creator_name', 255);
|
|
312563
|
+
table.string('timezone', 64).notNullable().defaultTo('UTC');
|
|
312564
|
+
table.string('schedule_expr', 255);
|
|
312565
|
+
table.bigInteger('run_at');
|
|
312566
|
+
table.boolean('is_recurring').notNullable();
|
|
312567
|
+
table.text('original_expression');
|
|
312568
|
+
table.string('workflow', 255);
|
|
312569
|
+
table.text('workflow_inputs');
|
|
312570
|
+
table.text('output_context');
|
|
312571
|
+
table.string('status', 20).notNullable().index();
|
|
312572
|
+
table.bigInteger('created_at').notNullable();
|
|
312573
|
+
table.bigInteger('last_run_at');
|
|
312574
|
+
table.bigInteger('next_run_at');
|
|
312575
|
+
table.integer('run_count').notNullable().defaultTo(0);
|
|
312576
|
+
table.integer('failure_count').notNullable().defaultTo(0);
|
|
312577
|
+
table.text('last_error');
|
|
312578
|
+
table.text('previous_response');
|
|
312579
|
+
table.index(['status', 'next_run_at']);
|
|
312580
|
+
});
|
|
312581
|
+
}
|
|
312582
|
+
// Create message_triggers table
|
|
312583
|
+
const triggersExist = await knex.schema.hasTable('message_triggers');
|
|
312584
|
+
if (!triggersExist) {
|
|
312585
|
+
await knex.schema.createTable('message_triggers', table => {
|
|
312586
|
+
table.string('id', 36).primary();
|
|
312587
|
+
table.string('creator_id', 255).notNullable().index();
|
|
312588
|
+
table.string('creator_context', 255);
|
|
312589
|
+
table.string('creator_name', 255);
|
|
312590
|
+
table.text('description');
|
|
312591
|
+
table.text('channels'); // JSON array
|
|
312592
|
+
table.text('from_users'); // JSON array
|
|
312593
|
+
table.boolean('from_bots').notNullable().defaultTo(false);
|
|
312594
|
+
table.text('contains'); // JSON array
|
|
312595
|
+
table.text('match_pattern');
|
|
312596
|
+
table.string('threads', 20).notNullable().defaultTo('any');
|
|
312597
|
+
table.string('workflow', 255).notNullable();
|
|
312598
|
+
table.text('inputs'); // JSON
|
|
312599
|
+
table.text('output_context'); // JSON
|
|
312600
|
+
table.string('status', 20).notNullable().defaultTo('active').index();
|
|
312601
|
+
table.boolean('enabled').notNullable().defaultTo(true);
|
|
312602
|
+
table.bigInteger('created_at').notNullable();
|
|
312603
|
+
});
|
|
312604
|
+
}
|
|
312605
|
+
// Create scheduler_locks table for distributed locking
|
|
312606
|
+
const locksExist = await knex.schema.hasTable('scheduler_locks');
|
|
312607
|
+
if (!locksExist) {
|
|
312608
|
+
await knex.schema.createTable('scheduler_locks', table => {
|
|
312609
|
+
table.string('lock_id', 255).primary();
|
|
312610
|
+
table.string('node_id', 255).notNullable();
|
|
312611
|
+
table.string('lock_token', 36).notNullable();
|
|
312612
|
+
table.bigInteger('acquired_at').notNullable();
|
|
312613
|
+
table.bigInteger('expires_at').notNullable();
|
|
312614
|
+
});
|
|
312615
|
+
}
|
|
312616
|
+
}
|
|
312617
|
+
getKnex() {
|
|
312618
|
+
if (!this.knex) {
|
|
312619
|
+
throw new Error('[KnexStore] Not initialized. Call initialize() first.');
|
|
312620
|
+
}
|
|
312621
|
+
return this.knex;
|
|
312622
|
+
}
|
|
312623
|
+
// --- CRUD ---
|
|
312624
|
+
async create(schedule) {
|
|
312625
|
+
const knex = this.getKnex();
|
|
312626
|
+
const newSchedule = {
|
|
312627
|
+
...schedule,
|
|
312628
|
+
id: (0, uuid_1.v4)(),
|
|
312629
|
+
createdAt: Date.now(),
|
|
312630
|
+
runCount: 0,
|
|
312631
|
+
failureCount: 0,
|
|
312632
|
+
status: 'active',
|
|
312633
|
+
};
|
|
312634
|
+
await knex('schedules').insert(toInsertRow(newSchedule));
|
|
312635
|
+
logger_1.logger.info(`[KnexStore] Created schedule ${newSchedule.id} for user ${newSchedule.creatorId}`);
|
|
312636
|
+
return newSchedule;
|
|
312637
|
+
}
|
|
312638
|
+
async importSchedule(schedule) {
|
|
312639
|
+
const knex = this.getKnex();
|
|
312640
|
+
const existing = await knex('schedules').where('id', schedule.id).first();
|
|
312641
|
+
if (existing)
|
|
312642
|
+
return; // Already imported (idempotent)
|
|
312643
|
+
await knex('schedules').insert(toInsertRow(schedule));
|
|
312644
|
+
}
|
|
312645
|
+
async get(id) {
|
|
312646
|
+
const knex = this.getKnex();
|
|
312647
|
+
const row = await knex('schedules').where('id', id).first();
|
|
312648
|
+
return row ? fromDbRow(row) : undefined;
|
|
312649
|
+
}
|
|
312650
|
+
async update(id, patch) {
|
|
312651
|
+
const knex = this.getKnex();
|
|
312652
|
+
const existing = await knex('schedules').where('id', id).first();
|
|
312653
|
+
if (!existing)
|
|
312654
|
+
return undefined;
|
|
312655
|
+
const current = fromDbRow(existing);
|
|
312656
|
+
const updated = { ...current, ...patch, id: current.id };
|
|
312657
|
+
const row = toInsertRow(updated);
|
|
312658
|
+
// Remove id from update (PK cannot change)
|
|
312659
|
+
delete row.id;
|
|
312660
|
+
await knex('schedules').where('id', id).update(row);
|
|
312661
|
+
return updated;
|
|
312662
|
+
}
|
|
312663
|
+
async delete(id) {
|
|
312664
|
+
const knex = this.getKnex();
|
|
312665
|
+
const deleted = await knex('schedules').where('id', id).del();
|
|
312666
|
+
if (deleted > 0) {
|
|
312667
|
+
logger_1.logger.info(`[KnexStore] Deleted schedule ${id}`);
|
|
312668
|
+
return true;
|
|
312669
|
+
}
|
|
312670
|
+
return false;
|
|
312671
|
+
}
|
|
312672
|
+
// --- Queries ---
|
|
312673
|
+
async getByCreator(creatorId) {
|
|
312674
|
+
const knex = this.getKnex();
|
|
312675
|
+
const rows = await knex('schedules').where('creator_id', creatorId);
|
|
312676
|
+
return rows.map((r) => fromDbRow(r));
|
|
312677
|
+
}
|
|
312678
|
+
async getActiveSchedules() {
|
|
312679
|
+
const knex = this.getKnex();
|
|
312680
|
+
const rows = await knex('schedules').where('status', 'active');
|
|
312681
|
+
return rows.map((r) => fromDbRow(r));
|
|
312682
|
+
}
|
|
312683
|
+
async getDueSchedules(now) {
|
|
312684
|
+
const ts = now ?? Date.now();
|
|
312685
|
+
const knex = this.getKnex();
|
|
312686
|
+
// MSSQL uses 1/0 for booleans
|
|
312687
|
+
const bFalse = this.driver === 'mssql' ? 0 : false;
|
|
312688
|
+
const bTrue = this.driver === 'mssql' ? 1 : true;
|
|
312689
|
+
const rows = await knex('schedules')
|
|
312690
|
+
.where('status', 'active')
|
|
312691
|
+
.andWhere(function () {
|
|
312692
|
+
this.where(function () {
|
|
312693
|
+
this.where('is_recurring', bFalse)
|
|
312694
|
+
.whereNotNull('run_at')
|
|
312695
|
+
.where('run_at', '<=', ts);
|
|
312696
|
+
}).orWhere(function () {
|
|
312697
|
+
this.where('is_recurring', bTrue)
|
|
312698
|
+
.whereNotNull('next_run_at')
|
|
312699
|
+
.where('next_run_at', '<=', ts);
|
|
312700
|
+
});
|
|
312701
|
+
});
|
|
312702
|
+
return rows.map((r) => fromDbRow(r));
|
|
312703
|
+
}
|
|
312704
|
+
async findByWorkflow(creatorId, workflowName) {
|
|
312705
|
+
const knex = this.getKnex();
|
|
312706
|
+
const escaped = workflowName.toLowerCase().replace(/[%_\\]/g, '\\$&');
|
|
312707
|
+
const pattern = `%${escaped}%`;
|
|
312708
|
+
const rows = await knex('schedules')
|
|
312709
|
+
.where('creator_id', creatorId)
|
|
312710
|
+
.where('status', 'active')
|
|
312711
|
+
.whereRaw("LOWER(workflow) LIKE ? ESCAPE '\\'", [pattern]);
|
|
312712
|
+
return rows.map((r) => fromDbRow(r));
|
|
312713
|
+
}
|
|
312714
|
+
async getAll() {
|
|
312715
|
+
const knex = this.getKnex();
|
|
312716
|
+
const rows = await knex('schedules');
|
|
312717
|
+
return rows.map((r) => fromDbRow(r));
|
|
312718
|
+
}
|
|
312719
|
+
async getStats() {
|
|
312720
|
+
const knex = this.getKnex();
|
|
312721
|
+
// MSSQL uses 1/0 for booleans; PostgreSQL/MySQL accept both true/1
|
|
312722
|
+
const boolTrue = this.driver === 'mssql' ? '1' : 'true';
|
|
312723
|
+
const boolFalse = this.driver === 'mssql' ? '0' : 'false';
|
|
312724
|
+
const result = await knex('schedules')
|
|
312725
|
+
.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`))
|
|
312726
|
+
.first();
|
|
312727
|
+
return {
|
|
312728
|
+
total: Number(result.total) || 0,
|
|
312729
|
+
active: Number(result.active) || 0,
|
|
312730
|
+
paused: Number(result.paused) || 0,
|
|
312731
|
+
completed: Number(result.completed) || 0,
|
|
312732
|
+
failed: Number(result.failed) || 0,
|
|
312733
|
+
recurring: Number(result.recurring) || 0,
|
|
312734
|
+
oneTime: Number(result.one_time) || 0,
|
|
312735
|
+
};
|
|
312736
|
+
}
|
|
312737
|
+
async validateLimits(creatorId, isRecurring, limits) {
|
|
312738
|
+
const knex = this.getKnex();
|
|
312739
|
+
if (limits.maxGlobal) {
|
|
312740
|
+
const result = await knex('schedules').count('* as cnt').first();
|
|
312741
|
+
if (Number(result?.cnt) >= limits.maxGlobal) {
|
|
312742
|
+
throw new Error(`Global schedule limit reached (${limits.maxGlobal})`);
|
|
312743
|
+
}
|
|
312744
|
+
}
|
|
312745
|
+
if (limits.maxPerUser) {
|
|
312746
|
+
const result = await knex('schedules')
|
|
312747
|
+
.where('creator_id', creatorId)
|
|
312748
|
+
.count('* as cnt')
|
|
312749
|
+
.first();
|
|
312750
|
+
if (Number(result?.cnt) >= limits.maxPerUser) {
|
|
312751
|
+
throw new Error(`You have reached the maximum number of schedules (${limits.maxPerUser})`);
|
|
312752
|
+
}
|
|
312753
|
+
}
|
|
312754
|
+
if (isRecurring && limits.maxRecurringPerUser) {
|
|
312755
|
+
const bTrue = this.driver === 'mssql' ? 1 : true;
|
|
312756
|
+
const result = await knex('schedules')
|
|
312757
|
+
.where('creator_id', creatorId)
|
|
312758
|
+
.where('is_recurring', bTrue)
|
|
312759
|
+
.count('* as cnt')
|
|
312760
|
+
.first();
|
|
312761
|
+
if (Number(result?.cnt) >= limits.maxRecurringPerUser) {
|
|
312762
|
+
throw new Error(`You have reached the maximum number of recurring schedules (${limits.maxRecurringPerUser})`);
|
|
312763
|
+
}
|
|
312764
|
+
}
|
|
312765
|
+
}
|
|
312766
|
+
// --- HA Distributed Locking (via scheduler_locks table) ---
|
|
312767
|
+
async tryAcquireLock(lockId, nodeId, ttlSeconds) {
|
|
312768
|
+
const knex = this.getKnex();
|
|
312769
|
+
const now = Date.now();
|
|
312770
|
+
const expiresAt = now + ttlSeconds * 1000;
|
|
312771
|
+
const token = (0, uuid_1.v4)();
|
|
312772
|
+
// Step 1: Try to claim an existing expired lock
|
|
312773
|
+
const updated = await knex('scheduler_locks')
|
|
312774
|
+
.where('lock_id', lockId)
|
|
312775
|
+
.where('expires_at', '<', now)
|
|
312776
|
+
.update({
|
|
312777
|
+
node_id: nodeId,
|
|
312778
|
+
lock_token: token,
|
|
312779
|
+
acquired_at: now,
|
|
312780
|
+
expires_at: expiresAt,
|
|
312781
|
+
});
|
|
312782
|
+
if (updated > 0)
|
|
312783
|
+
return token;
|
|
312784
|
+
// Step 2: Try to INSERT a new lock row
|
|
312785
|
+
try {
|
|
312786
|
+
await knex('scheduler_locks').insert({
|
|
312787
|
+
lock_id: lockId,
|
|
312788
|
+
node_id: nodeId,
|
|
312789
|
+
lock_token: token,
|
|
312790
|
+
acquired_at: now,
|
|
312791
|
+
expires_at: expiresAt,
|
|
312792
|
+
});
|
|
312793
|
+
return token;
|
|
312794
|
+
}
|
|
312795
|
+
catch {
|
|
312796
|
+
// Unique constraint violation — another node holds the lock
|
|
312797
|
+
return null;
|
|
312798
|
+
}
|
|
312799
|
+
}
|
|
312800
|
+
async releaseLock(lockId, lockToken) {
|
|
312801
|
+
const knex = this.getKnex();
|
|
312802
|
+
await knex('scheduler_locks').where('lock_id', lockId).where('lock_token', lockToken).del();
|
|
312803
|
+
}
|
|
312804
|
+
async renewLock(lockId, lockToken, ttlSeconds) {
|
|
312805
|
+
const knex = this.getKnex();
|
|
312806
|
+
const now = Date.now();
|
|
312807
|
+
const expiresAt = now + ttlSeconds * 1000;
|
|
312808
|
+
const updated = await knex('scheduler_locks')
|
|
312809
|
+
.where('lock_id', lockId)
|
|
312810
|
+
.where('lock_token', lockToken)
|
|
312811
|
+
.update({ acquired_at: now, expires_at: expiresAt });
|
|
312812
|
+
return updated > 0;
|
|
312813
|
+
}
|
|
312814
|
+
async flush() {
|
|
312815
|
+
// No-op for server-based backends
|
|
312816
|
+
}
|
|
312817
|
+
// --- Message Trigger CRUD ---
|
|
312818
|
+
async createTrigger(trigger) {
|
|
312819
|
+
const knex = this.getKnex();
|
|
312820
|
+
const newTrigger = {
|
|
312821
|
+
...trigger,
|
|
312822
|
+
id: (0, uuid_1.v4)(),
|
|
312823
|
+
createdAt: Date.now(),
|
|
312824
|
+
};
|
|
312825
|
+
await knex('message_triggers').insert(toTriggerInsertRow(newTrigger));
|
|
312826
|
+
logger_1.logger.info(`[KnexStore] Created trigger ${newTrigger.id} for user ${newTrigger.creatorId}`);
|
|
312827
|
+
return newTrigger;
|
|
312828
|
+
}
|
|
312829
|
+
async getTrigger(id) {
|
|
312830
|
+
const knex = this.getKnex();
|
|
312831
|
+
const row = await knex('message_triggers').where('id', id).first();
|
|
312832
|
+
return row ? fromTriggerRow(row) : undefined;
|
|
312833
|
+
}
|
|
312834
|
+
async updateTrigger(id, patch) {
|
|
312835
|
+
const knex = this.getKnex();
|
|
312836
|
+
const existing = await knex('message_triggers').where('id', id).first();
|
|
312837
|
+
if (!existing)
|
|
312838
|
+
return undefined;
|
|
312839
|
+
const current = fromTriggerRow(existing);
|
|
312840
|
+
const updated = {
|
|
312841
|
+
...current,
|
|
312842
|
+
...patch,
|
|
312843
|
+
id: current.id,
|
|
312844
|
+
createdAt: current.createdAt,
|
|
312845
|
+
};
|
|
312846
|
+
const row = toTriggerInsertRow(updated);
|
|
312847
|
+
delete row.id;
|
|
312848
|
+
await knex('message_triggers').where('id', id).update(row);
|
|
312849
|
+
return updated;
|
|
312850
|
+
}
|
|
312851
|
+
async deleteTrigger(id) {
|
|
312852
|
+
const knex = this.getKnex();
|
|
312853
|
+
const deleted = await knex('message_triggers').where('id', id).del();
|
|
312854
|
+
if (deleted > 0) {
|
|
312855
|
+
logger_1.logger.info(`[KnexStore] Deleted trigger ${id}`);
|
|
312856
|
+
return true;
|
|
312857
|
+
}
|
|
312858
|
+
return false;
|
|
312859
|
+
}
|
|
312860
|
+
async getTriggersByCreator(creatorId) {
|
|
312861
|
+
const knex = this.getKnex();
|
|
312862
|
+
const rows = await knex('message_triggers').where('creator_id', creatorId);
|
|
312863
|
+
return rows.map((r) => fromTriggerRow(r));
|
|
312864
|
+
}
|
|
312865
|
+
async getActiveTriggers() {
|
|
312866
|
+
const knex = this.getKnex();
|
|
312867
|
+
const rows = await knex('message_triggers')
|
|
312868
|
+
.where('status', 'active')
|
|
312869
|
+
.where('enabled', this.driver === 'mssql' ? 1 : true);
|
|
312870
|
+
return rows.map((r) => fromTriggerRow(r));
|
|
312871
|
+
}
|
|
312872
|
+
}
|
|
312873
|
+
exports.KnexStoreBackend = KnexStoreBackend;
|
|
312874
|
+
|
|
312875
|
+
|
|
311072
312876
|
/***/ }),
|
|
311073
312877
|
|
|
311074
312878
|
/***/ 83864:
|
|
@@ -313350,6 +315154,20 @@ class SlackFrontend {
|
|
|
313350
315154
|
if (out && typeof out._rawOutput === 'string' && out._rawOutput.trim().length > 0) {
|
|
313351
315155
|
text = (text || '') + '\n\n' + out._rawOutput.trim();
|
|
313352
315156
|
}
|
|
315157
|
+
// Fallback: if no text was extracted, check for error issues (e.g. timeout)
|
|
315158
|
+
// and post an error message so the user isn't left with silence.
|
|
315159
|
+
if (!text) {
|
|
315160
|
+
const issues = result?.issues || [];
|
|
315161
|
+
const errorIssues = issues.filter((i) => i.severity === 'error' &&
|
|
315162
|
+
(i.ruleId?.startsWith('system/') || i.ruleId?.endsWith('/error')));
|
|
315163
|
+
if (errorIssues.length > 0) {
|
|
315164
|
+
const errorMessages = errorIssues.map((i) => i.message).join('\n');
|
|
315165
|
+
text = `:warning: Something went wrong while processing your request:\n${errorMessages}`;
|
|
315166
|
+
// Prevent maybePostExecutionFailure from double-posting the same error
|
|
315167
|
+
this.errorNotified = true;
|
|
315168
|
+
ctx.logger.warn(`[slack-frontend] posting error fallback for ${checkId}: ${errorIssues.length} system error(s)`);
|
|
315169
|
+
}
|
|
315170
|
+
}
|
|
313353
315171
|
if (!text) {
|
|
313354
315172
|
ctx.logger.info(`[slack-frontend] skip posting AI reply for ${checkId}: no renderable text in check output`);
|
|
313355
315173
|
return;
|
|
@@ -323603,6 +325421,35 @@ class OutputFormatters {
|
|
|
323603
325421
|
exports.OutputFormatters = OutputFormatters;
|
|
323604
325422
|
|
|
323605
325423
|
|
|
325424
|
+
/***/ }),
|
|
325425
|
+
|
|
325426
|
+
/***/ 93866:
|
|
325427
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
325428
|
+
|
|
325429
|
+
"use strict";
|
|
325430
|
+
|
|
325431
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
325432
|
+
exports.DefaultPolicyEngine = void 0;
|
|
325433
|
+
/**
|
|
325434
|
+
* Default (no-op) policy engine — always allows everything.
|
|
325435
|
+
* Used when no enterprise license is present or policy is disabled.
|
|
325436
|
+
*/
|
|
325437
|
+
class DefaultPolicyEngine {
|
|
325438
|
+
async initialize(_config) { }
|
|
325439
|
+
async evaluateCheckExecution(_checkId, _checkConfig) {
|
|
325440
|
+
return { allowed: true };
|
|
325441
|
+
}
|
|
325442
|
+
async evaluateToolInvocation(_serverName, _methodName, _transport) {
|
|
325443
|
+
return { allowed: true };
|
|
325444
|
+
}
|
|
325445
|
+
async evaluateCapabilities(_checkId, _capabilities) {
|
|
325446
|
+
return { allowed: true };
|
|
325447
|
+
}
|
|
325448
|
+
async shutdown() { }
|
|
325449
|
+
}
|
|
325450
|
+
exports.DefaultPolicyEngine = DefaultPolicyEngine;
|
|
325451
|
+
|
|
325452
|
+
|
|
323606
325453
|
/***/ }),
|
|
323607
325454
|
|
|
323608
325455
|
/***/ 96611:
|
|
@@ -346755,7 +348602,7 @@ class StateMachineExecutionEngine {
|
|
|
346755
348602
|
try {
|
|
346756
348603
|
logger_1.logger.debug(`[PolicyEngine] Loading enterprise policy engine (engine=${configWithTagFilter.policy.engine})`);
|
|
346757
348604
|
// @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
|
|
346758
|
-
const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(
|
|
348605
|
+
const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(87068)));
|
|
346759
348606
|
context.policyEngine = await loadEnterprisePolicyEngine(configWithTagFilter.policy);
|
|
346760
348607
|
logger_1.logger.debug(`[PolicyEngine] Initialized: ${context.policyEngine?.constructor?.name || 'unknown'}`);
|
|
346761
348608
|
}
|
|
@@ -348574,7 +350421,7 @@ async function executeSingleCheck(checkId, context, state, emitEvent, transition
|
|
|
348574
350421
|
workflowInputs,
|
|
348575
350422
|
ai: {
|
|
348576
350423
|
...(checkConfig.ai || {}),
|
|
348577
|
-
timeout: checkConfig.ai?.timeout || 1800000,
|
|
350424
|
+
timeout: checkConfig.timeout || checkConfig.ai?.timeout || 1800000,
|
|
348578
350425
|
debug: !!context.debug,
|
|
348579
350426
|
},
|
|
348580
350427
|
};
|
|
@@ -348667,7 +350514,7 @@ async function executeSingleCheck(checkId, context, state, emitEvent, transition
|
|
|
348667
350514
|
session_id: context.sessionId,
|
|
348668
350515
|
wave: state.wave,
|
|
348669
350516
|
}, async (span) => {
|
|
348670
|
-
const res = await (0, sandbox_routing_1.executeWithSandboxRouting)(checkId, checkConfig, context, prInfo, dependencyResults, checkConfig.ai?.timeout || 1800000, () => provider.execute(prInfo, providerConfig, dependencyResults, executionContext));
|
|
350517
|
+
const res = await (0, sandbox_routing_1.executeWithSandboxRouting)(checkId, checkConfig, context, prInfo, dependencyResults, checkConfig.timeout || checkConfig.ai?.timeout || 1800000, () => provider.execute(prInfo, providerConfig, dependencyResults, executionContext));
|
|
348671
350518
|
// Capture output in span for trace visualization
|
|
348672
350519
|
try {
|
|
348673
350520
|
(0, state_capture_1.captureCheckOutput)(span, res.output);
|
|
@@ -349035,7 +350882,7 @@ async function executeCheckWithForEachItems(checkId, forEachParent, forEachItems
|
|
|
349035
350882
|
workflowInputs,
|
|
349036
350883
|
ai: {
|
|
349037
350884
|
...(checkConfig.ai || {}),
|
|
349038
|
-
timeout: checkConfig.ai?.timeout || 1800000,
|
|
350885
|
+
timeout: checkConfig.timeout || checkConfig.ai?.timeout || 1800000,
|
|
349039
350886
|
debug: !!context.debug,
|
|
349040
350887
|
},
|
|
349041
350888
|
};
|
|
@@ -349115,7 +350962,7 @@ async function executeCheckWithForEachItems(checkId, forEachParent, forEachItems
|
|
|
349115
350962
|
session_id: context.sessionId,
|
|
349116
350963
|
wave: state.wave,
|
|
349117
350964
|
}, async (span) => {
|
|
349118
|
-
const res = await (0, sandbox_routing_1.executeWithSandboxRouting)(checkId, checkConfig, context, prInfo, dependencyResults, checkConfig.ai?.timeout || 1800000, () => provider.execute(prInfo, providerConfig, dependencyResults, executionContext));
|
|
350965
|
+
const res = await (0, sandbox_routing_1.executeWithSandboxRouting)(checkId, checkConfig, context, prInfo, dependencyResults, checkConfig.timeout || checkConfig.ai?.timeout || 1800000, () => provider.execute(prInfo, providerConfig, dependencyResults, executionContext));
|
|
349119
350966
|
try {
|
|
349120
350967
|
(0, state_capture_1.captureCheckOutput)(span, res.output);
|
|
349121
350968
|
}
|
|
@@ -349606,7 +351453,7 @@ async function executeInvocation(item, context, scope, prInfo, dependencyResults
|
|
|
349606
351453
|
__outputHistory: outputHistory,
|
|
349607
351454
|
ai: {
|
|
349608
351455
|
...(stepConfig.ai || {}),
|
|
349609
|
-
timeout: stepConfig.ai?.timeout || 1800000,
|
|
351456
|
+
timeout: stepConfig.timeout || stepConfig.ai?.timeout || 1800000,
|
|
349610
351457
|
debug: !!context.debug,
|
|
349611
351458
|
},
|
|
349612
351459
|
};
|
|
@@ -351493,7 +353340,7 @@ async function executeCheckWithForEachItems(checkId, forEachParent, forEachItems
|
|
|
351493
353340
|
workflowInputs,
|
|
351494
353341
|
ai: {
|
|
351495
353342
|
...(checkConfig.ai || {}),
|
|
351496
|
-
timeout: checkConfig.ai?.timeout || 1800000,
|
|
353343
|
+
timeout: checkConfig.timeout || checkConfig.ai?.timeout || 1800000,
|
|
351497
353344
|
debug: !!context.debug,
|
|
351498
353345
|
},
|
|
351499
353346
|
};
|
|
@@ -351524,16 +353371,17 @@ async function executeCheckWithForEachItems(checkId, forEachParent, forEachItems
|
|
|
351524
353371
|
const conv = slackConv || telegramConv;
|
|
351525
353372
|
if (conv) {
|
|
351526
353373
|
const event = payload?.event;
|
|
351527
|
-
const messageCount = Array.isArray(conv?.messages)
|
|
351528
|
-
? conv.messages.length
|
|
351529
|
-
: 0;
|
|
353374
|
+
const messageCount = Array.isArray(conv?.messages) ? conv.messages.length : 0;
|
|
351530
353375
|
if (context.debug) {
|
|
351531
353376
|
logger_1.logger.info(`[LevelDispatch] Conversation extracted (${conv?.transport || 'unknown'}): ${messageCount} messages`);
|
|
351532
353377
|
}
|
|
351533
353378
|
// Build transport-specific context
|
|
351534
353379
|
const transportCtx = slackConv
|
|
351535
353380
|
? { slack: { event: event || {}, conversation: slackConv } }
|
|
351536
|
-
: {
|
|
353381
|
+
: {
|
|
353382
|
+
telegram: { event: event || {}, conversation: telegramConv },
|
|
353383
|
+
webhook: payload,
|
|
353384
|
+
};
|
|
351537
353385
|
providerConfig.eventContext = {
|
|
351538
353386
|
...providerConfig.eventContext,
|
|
351539
353387
|
...transportCtx,
|
|
@@ -351708,7 +353556,7 @@ async function executeCheckWithForEachItems(checkId, forEachParent, forEachItems
|
|
|
351708
353556
|
session_id: context.sessionId,
|
|
351709
353557
|
wave: state.wave,
|
|
351710
353558
|
}, async (span) => {
|
|
351711
|
-
const res = await (0, sandbox_routing_1.executeWithSandboxRouting)(checkId, checkConfig, context, prInfo, dependencyResults, checkConfig.ai?.timeout || 1800000, () => provider.execute(prInfo, providerConfig, dependencyResults, executionContext));
|
|
353559
|
+
const res = await (0, sandbox_routing_1.executeWithSandboxRouting)(checkId, checkConfig, context, prInfo, dependencyResults, checkConfig.timeout || checkConfig.ai?.timeout || 1800000, () => provider.execute(prInfo, providerConfig, dependencyResults, executionContext));
|
|
351712
353560
|
try {
|
|
351713
353561
|
(0, state_capture_1.captureCheckOutput)(span, res.output);
|
|
351714
353562
|
}
|
|
@@ -352727,7 +354575,7 @@ async function executeSingleCheck(checkId, context, state, emitEvent, transition
|
|
|
352727
354575
|
workflowInputs,
|
|
352728
354576
|
ai: {
|
|
352729
354577
|
...(checkConfig.ai || {}),
|
|
352730
|
-
timeout: checkConfig.ai?.timeout || 1800000,
|
|
354578
|
+
timeout: checkConfig.timeout || checkConfig.ai?.timeout || 1800000,
|
|
352731
354579
|
debug: !!context.debug,
|
|
352732
354580
|
},
|
|
352733
354581
|
};
|
|
@@ -352909,7 +354757,7 @@ async function executeSingleCheck(checkId, context, state, emitEvent, transition
|
|
|
352909
354757
|
session_id: context.sessionId,
|
|
352910
354758
|
wave: state.wave,
|
|
352911
354759
|
}, async (span) => {
|
|
352912
|
-
const res = await (0, sandbox_routing_1.executeWithSandboxRouting)(checkId, checkConfig, context, prInfo, dependencyResults, checkConfig.ai?.timeout || 1800000, () => provider.execute(prInfo, providerConfig, dependencyResults, executionContext));
|
|
354760
|
+
const res = await (0, sandbox_routing_1.executeWithSandboxRouting)(checkId, checkConfig, context, prInfo, dependencyResults, checkConfig.timeout || checkConfig.ai?.timeout || 1800000, () => provider.execute(prInfo, providerConfig, dependencyResults, executionContext));
|
|
352913
354761
|
try {
|
|
352914
354762
|
(0, state_capture_1.captureCheckOutput)(span, res.output);
|
|
352915
354763
|
}
|
|
@@ -358498,7 +360346,7 @@ async function initTelemetry(opts = {}) {
|
|
|
358498
360346
|
const path = __nccwpck_require__(16928);
|
|
358499
360347
|
const outDir = opts.file?.dir ||
|
|
358500
360348
|
process.env.VISOR_TRACE_DIR ||
|
|
358501
|
-
|
|
360349
|
+
path.join(process.cwd(), 'output', 'traces');
|
|
358502
360350
|
fs.mkdirSync(outDir, { recursive: true });
|
|
358503
360351
|
const ts = new Date().toISOString().replace(/[:.]/g, '-');
|
|
358504
360352
|
process.env.VISOR_FALLBACK_TRACE_FILE = path.join(outDir, `run-${ts}.ndjson`);
|
|
@@ -358748,7 +360596,7 @@ async function shutdownTelemetry() {
|
|
|
358748
360596
|
if (process.env.VISOR_TRACE_REPORT === 'true') {
|
|
358749
360597
|
const fs = __nccwpck_require__(79896);
|
|
358750
360598
|
const path = __nccwpck_require__(16928);
|
|
358751
|
-
const outDir = process.env.VISOR_TRACE_DIR ||
|
|
360599
|
+
const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
|
|
358752
360600
|
if (!fs.existsSync(outDir))
|
|
358753
360601
|
fs.mkdirSync(outDir, { recursive: true });
|
|
358754
360602
|
const ts = new Date().toISOString().replace(/[:.]/g, '-');
|
|
@@ -359299,7 +361147,7 @@ function __getOrCreateNdjsonPath() {
|
|
|
359299
361147
|
fs.mkdirSync(dir, { recursive: true });
|
|
359300
361148
|
return __ndjsonPath;
|
|
359301
361149
|
}
|
|
359302
|
-
const outDir = process.env.VISOR_TRACE_DIR ||
|
|
361150
|
+
const outDir = process.env.VISOR_TRACE_DIR || path.join(process.cwd(), 'output', 'traces');
|
|
359303
361151
|
if (!fs.existsSync(outDir))
|
|
359304
361152
|
fs.mkdirSync(outDir, { recursive: true });
|
|
359305
361153
|
if (!__ndjsonPath) {
|
|
@@ -372702,10 +374550,26 @@ class WorkspaceManager {
|
|
|
372702
374550
|
await this.deleteLocalBranches(worktreePath);
|
|
372703
374551
|
}
|
|
372704
374552
|
/**
|
|
372705
|
-
* Delete
|
|
374553
|
+
* Delete local branches in a worktree that are safe to remove.
|
|
374554
|
+
* IMPORTANT: Git worktrees share the branch namespace with the main repo
|
|
374555
|
+
* and all other worktrees. We must NOT delete branches that are checked out
|
|
374556
|
+
* in the main working tree or any other worktree — doing so would destroy
|
|
374557
|
+
* the user's work.
|
|
372706
374558
|
*/
|
|
372707
374559
|
async deleteLocalBranches(worktreePath) {
|
|
372708
374560
|
const escapedPath = shellEscape(worktreePath);
|
|
374561
|
+
// First, discover which branches are checked out in ANY worktree (including main).
|
|
374562
|
+
// `git worktree list --porcelain` output contains "branch refs/heads/<name>" lines.
|
|
374563
|
+
const worktreeListResult = await command_executor_1.commandExecutor.execute(`git -C ${escapedPath} worktree list --porcelain`, { timeout: 10000 });
|
|
374564
|
+
const protectedBranches = new Set();
|
|
374565
|
+
if (worktreeListResult.exitCode === 0) {
|
|
374566
|
+
for (const line of worktreeListResult.stdout.split('\n')) {
|
|
374567
|
+
const match = line.match(/^branch refs\/heads\/(.+)$/);
|
|
374568
|
+
if (match) {
|
|
374569
|
+
protectedBranches.add(match[1]);
|
|
374570
|
+
}
|
|
374571
|
+
}
|
|
374572
|
+
}
|
|
372709
374573
|
const listResult = await command_executor_1.commandExecutor.execute(`git -C ${escapedPath} branch --list --format='%(refname:short)'`, { timeout: 10000 });
|
|
372710
374574
|
if (listResult.exitCode !== 0 || !listResult.stdout.trim()) {
|
|
372711
374575
|
return;
|
|
@@ -372716,6 +374580,10 @@ class WorkspaceManager {
|
|
|
372716
374580
|
.map(b => b.trim())
|
|
372717
374581
|
.filter(b => b.length > 0);
|
|
372718
374582
|
for (const branch of branches) {
|
|
374583
|
+
if (protectedBranches.has(branch)) {
|
|
374584
|
+
logger_1.logger.debug(`[Workspace] Skipping branch '${branch}' — checked out in another worktree`);
|
|
374585
|
+
continue;
|
|
374586
|
+
}
|
|
372719
374587
|
const deleteResult = await command_executor_1.commandExecutor.execute(`git -C ${escapedPath} branch -D ${shellEscape(branch)}`, { timeout: 10000 });
|
|
372720
374588
|
if (deleteResult.exitCode === 0) {
|
|
372721
374589
|
logger_1.logger.debug(`[Workspace] Deleted local branch '${branch}' from worktree`);
|
|
@@ -373415,11 +375283,28 @@ class WorktreeManager {
|
|
|
373415
375283
|
await this.deleteLocalBranches(worktreePath);
|
|
373416
375284
|
}
|
|
373417
375285
|
/**
|
|
373418
|
-
* Delete
|
|
375286
|
+
* Delete local branches in a worktree that are safe to remove.
|
|
373419
375287
|
* Worktrees are always used in detached HEAD state, so any local branches
|
|
373420
375288
|
* were unintentionally created and should be cleaned up.
|
|
375289
|
+
* IMPORTANT: Git worktrees share the branch namespace with the main repo
|
|
375290
|
+
* and all other worktrees. We must NOT delete branches that are checked out
|
|
375291
|
+
* in the main working tree or any other worktree — doing so would destroy
|
|
375292
|
+
* the user's work.
|
|
373421
375293
|
*/
|
|
373422
375294
|
async deleteLocalBranches(worktreePath) {
|
|
375295
|
+
// First, discover which branches are checked out in ANY worktree (including main).
|
|
375296
|
+
// `git worktree list --porcelain` output contains "branch refs/heads/<name>" lines.
|
|
375297
|
+
const worktreeListCmd = `git -C ${this.escapeShellArg(worktreePath)} worktree list --porcelain`;
|
|
375298
|
+
const worktreeListResult = await this.executeGitCommand(worktreeListCmd, { timeout: 10000 });
|
|
375299
|
+
const protectedBranches = new Set();
|
|
375300
|
+
if (worktreeListResult.exitCode === 0) {
|
|
375301
|
+
for (const line of worktreeListResult.stdout.split('\n')) {
|
|
375302
|
+
const match = line.match(/^branch refs\/heads\/(.+)$/);
|
|
375303
|
+
if (match) {
|
|
375304
|
+
protectedBranches.add(match[1]);
|
|
375305
|
+
}
|
|
375306
|
+
}
|
|
375307
|
+
}
|
|
373423
375308
|
const listCmd = `git -C ${this.escapeShellArg(worktreePath)} branch --list --format='%(refname:short)'`;
|
|
373424
375309
|
const listResult = await this.executeGitCommand(listCmd, { timeout: 10000 });
|
|
373425
375310
|
if (listResult.exitCode !== 0 || !listResult.stdout.trim()) {
|
|
@@ -373431,6 +375316,10 @@ class WorktreeManager {
|
|
|
373431
375316
|
.map(b => b.trim())
|
|
373432
375317
|
.filter(b => b.length > 0);
|
|
373433
375318
|
for (const branch of branches) {
|
|
375319
|
+
if (protectedBranches.has(branch)) {
|
|
375320
|
+
logger_1.logger.debug(`Skipping branch '${branch}' — checked out in another worktree`);
|
|
375321
|
+
continue;
|
|
375322
|
+
}
|
|
373434
375323
|
const deleteCmd = `git -C ${this.escapeShellArg(worktreePath)} branch -D ${this.escapeShellArg(branch)}`;
|
|
373435
375324
|
const deleteResult = await this.executeGitCommand(deleteCmd, { timeout: 10000 });
|
|
373436
375325
|
if (deleteResult.exitCode === 0) {
|
|
@@ -375378,22 +377267,6 @@ class WorkflowRegistry {
|
|
|
375378
377267
|
exports.WorkflowRegistry = WorkflowRegistry;
|
|
375379
377268
|
|
|
375380
377269
|
|
|
375381
|
-
/***/ }),
|
|
375382
|
-
|
|
375383
|
-
/***/ 7065:
|
|
375384
|
-
/***/ ((module) => {
|
|
375385
|
-
|
|
375386
|
-
module.exports = eval("require")("./enterprise/loader");
|
|
375387
|
-
|
|
375388
|
-
|
|
375389
|
-
/***/ }),
|
|
375390
|
-
|
|
375391
|
-
/***/ 71370:
|
|
375392
|
-
/***/ ((module) => {
|
|
375393
|
-
|
|
375394
|
-
module.exports = eval("require")("./enterprise/policy/policy-input-builder");
|
|
375395
|
-
|
|
375396
|
-
|
|
375397
377270
|
/***/ }),
|
|
375398
377271
|
|
|
375399
377272
|
/***/ 18327:
|
|
@@ -540249,7 +542122,12 @@ function generateSandboxGlobals(options) {
|
|
|
540249
542122
|
}
|
|
540250
542123
|
return tryParseJSONValue(text);
|
|
540251
542124
|
};
|
|
540252
|
-
|
|
542125
|
+
const tracedFn = traceToolCall(name15, rawMcpFn, tracer, logFn);
|
|
542126
|
+
globals[name15] = tracedFn;
|
|
542127
|
+
const sanitized = name15.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
542128
|
+
if (sanitized !== name15) {
|
|
542129
|
+
globals[sanitized] = tracedFn;
|
|
542130
|
+
}
|
|
540253
542131
|
}
|
|
540254
542132
|
}
|
|
540255
542133
|
if (llmCall) {
|
|
@@ -540604,9 +542482,17 @@ ${validation.errors.join("\n")}`,
|
|
|
540604
542482
|
"dsl.duration_ms": elapsed,
|
|
540605
542483
|
"dsl.error": e.message?.substring(0, 500)
|
|
540606
542484
|
});
|
|
542485
|
+
let errorMsg = `Execution failed: ${e.message}`;
|
|
542486
|
+
if (e.message && e.message.includes("is not defined")) {
|
|
542487
|
+
const globalNames = Object.keys(toolGlobals).sort();
|
|
542488
|
+
errorMsg += `
|
|
542489
|
+
Available functions: ${globalNames.join(", ")}`;
|
|
542490
|
+
errorMsg += `
|
|
542491
|
+
Note: Tools with hyphens (e.g. "my-tool") are available with underscores: my_tool()`;
|
|
542492
|
+
}
|
|
540607
542493
|
return {
|
|
540608
542494
|
status: "error",
|
|
540609
|
-
error:
|
|
542495
|
+
error: errorMsg,
|
|
540610
542496
|
logs
|
|
540611
542497
|
};
|
|
540612
542498
|
}
|
|
@@ -549923,7 +551809,14 @@ function lineTrimmedMatch(contentLines, searchLines) {
|
|
|
549923
551809
|
}
|
|
549924
551810
|
}
|
|
549925
551811
|
if (allMatch) {
|
|
549926
|
-
const
|
|
551812
|
+
const windowLines = contentLines.slice(i, i + windowSize);
|
|
551813
|
+
const windowMinIndent = getMinIndent(windowLines);
|
|
551814
|
+
const searchMinIndent = getMinIndent(searchLines);
|
|
551815
|
+
const indentDiff = Math.abs(windowMinIndent - searchMinIndent);
|
|
551816
|
+
if (isIndentDiffTooLarge(windowLines, searchLines, indentDiff)) {
|
|
551817
|
+
continue;
|
|
551818
|
+
}
|
|
551819
|
+
const matchedText = windowLines.join("\n");
|
|
549927
551820
|
matches.push(matchedText);
|
|
549928
551821
|
}
|
|
549929
551822
|
}
|
|
@@ -549953,6 +551846,15 @@ function whitespaceNormalizedMatch(content, search2) {
|
|
|
549953
551846
|
actualEnd++;
|
|
549954
551847
|
}
|
|
549955
551848
|
const matchedText = content.substring(originalStart, actualEnd);
|
|
551849
|
+
const matchedLines = matchedText.split("\n");
|
|
551850
|
+
const searchLines = search2.split("\n");
|
|
551851
|
+
const matchMinIndent = getMinIndent(matchedLines);
|
|
551852
|
+
const searchMinIndent = getMinIndent(searchLines);
|
|
551853
|
+
const indentDiff = Math.abs(matchMinIndent - searchMinIndent);
|
|
551854
|
+
if (isIndentDiffTooLarge(matchedLines, searchLines, indentDiff)) {
|
|
551855
|
+
searchStart = idx + 1;
|
|
551856
|
+
continue;
|
|
551857
|
+
}
|
|
549956
551858
|
matches.push(matchedText);
|
|
549957
551859
|
searchStart = idx + 1;
|
|
549958
551860
|
}
|
|
@@ -550004,6 +551906,10 @@ function indentFlexibleMatch(contentLines, searchLines) {
|
|
|
550004
551906
|
}
|
|
550005
551907
|
}
|
|
550006
551908
|
if (allMatch) {
|
|
551909
|
+
const indentDiff = Math.abs(windowMinIndent - searchMinIndent);
|
|
551910
|
+
if (isIndentDiffTooLarge(windowLines, searchLines, indentDiff)) {
|
|
551911
|
+
continue;
|
|
551912
|
+
}
|
|
550007
551913
|
const matchedText = windowLines.join("\n");
|
|
550008
551914
|
matches.push(matchedText);
|
|
550009
551915
|
}
|
|
@@ -550014,6 +551920,14 @@ function indentFlexibleMatch(contentLines, searchLines) {
|
|
|
550014
551920
|
count: matches.length
|
|
550015
551921
|
};
|
|
550016
551922
|
}
|
|
551923
|
+
function isIndentDiffTooLarge(linesA, linesB, indentDiff) {
|
|
551924
|
+
if (indentDiff <= 0) return false;
|
|
551925
|
+
const sampleA = linesA.find((l) => l.trim().length > 0) || "";
|
|
551926
|
+
const sampleB = linesB.find((l) => l.trim().length > 0) || "";
|
|
551927
|
+
const useTabs = sampleA.startsWith(" ") || sampleB.startsWith(" ");
|
|
551928
|
+
const maxAllowedDiff = useTabs ? 1 : 4;
|
|
551929
|
+
return indentDiff > maxAllowedDiff;
|
|
551930
|
+
}
|
|
550017
551931
|
function getMinIndent(lines) {
|
|
550018
551932
|
let min = Infinity;
|
|
550019
551933
|
for (const line of lines) {
|
|
@@ -550088,6 +552002,12 @@ function restoreIndentation(newStr, originalLines) {
|
|
|
550088
552002
|
const targetIndent = detectBaseIndent(originalCode);
|
|
550089
552003
|
const newIndent = detectBaseIndent(newStr);
|
|
550090
552004
|
if (targetIndent !== newIndent) {
|
|
552005
|
+
const indentDiff = Math.abs(targetIndent.length - newIndent.length);
|
|
552006
|
+
const useTabs = targetIndent.includes(" ") || newIndent.includes(" ");
|
|
552007
|
+
const maxAllowedDiff = useTabs ? 1 : 4;
|
|
552008
|
+
if (indentDiff > maxAllowedDiff) {
|
|
552009
|
+
return { result: newStr, modifications };
|
|
552010
|
+
}
|
|
550091
552011
|
const reindented = reindent(newStr, targetIndent);
|
|
550092
552012
|
if (reindented !== newStr) {
|
|
550093
552013
|
modifications.push(`reindented from "${newIndent}" to "${targetIndent}"`);
|
|
@@ -608760,7 +610680,7 @@ module.exports = /*#__PURE__*/JSON.parse('["aaa","aarp","abb","abbott","abbvie",
|
|
|
608760
610680
|
/***/ ((module) => {
|
|
608761
610681
|
|
|
608762
610682
|
"use strict";
|
|
608763
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.
|
|
610683
|
+
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","@grammyjs/runner":"^2.0.3","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#23c4bb611f7d05f3cb8c523917b5f57103e48108","@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/api-logs":"^0.203.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-logs-otlp-http":"^0.203.0","@opentelemetry/exporter-metrics-otlp-http":"^0.203.0","@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-logs":"^0.203.0","@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-rc292","@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","botbuilder":"^4.23.3","botframework-connector":"^4.23.3","cli-table3":"^0.6.5","commander":"^14.0.0","deepmerge":"^4.3.1","dotenv":"^17.2.3","grammy":"^1.41.1","ignore":"^7.0.5","imapflow":"^1.2.12","js-yaml":"^4.1.0","jsonpath-plus":"^10.4.0","liquidjs":"^10.21.1","mailparser":"^3.9.3","minimatch":"^10.2.2","node-cron":"^3.0.3","nodemailer":"^8.0.1","open":"^9.1.0","resend":"^6.9.3","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/mailparser":"^3.4.6","@types/node":"^24.3.0","@types/node-cron":"^3.0.11","@types/nodemailer":"^7.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"]}}');
|
|
608764
610684
|
|
|
608765
610685
|
/***/ })
|
|
608766
610686
|
|