@probelabs/visor 0.1.142 → 0.1.143-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/index.js +4474 -4759
- package/dist/sdk/{check-provider-registry-SNVE22YQ.mjs → check-provider-registry-NA54BH75.mjs} +6 -6
- package/dist/sdk/{check-provider-registry-XUFQHEFY.mjs → check-provider-registry-QCE7HDRY.mjs} +5 -5
- package/dist/sdk/{chunk-BNXDXVFB.mjs → chunk-5TGH3YKC.mjs} +19 -19
- package/dist/sdk/{chunk-BNXDXVFB.mjs.map → chunk-5TGH3YKC.mjs.map} +1 -1
- package/dist/sdk/{chunk-G3W5KQL7.mjs → chunk-5X6TLBDA.mjs} +3 -3
- package/dist/sdk/{chunk-KUSF5IBV.mjs → chunk-HHQFJTPJ.mjs} +14 -14
- package/dist/sdk/{chunk-RR2KJCQS.mjs → chunk-RUQBSUTM.mjs} +12 -12
- package/dist/sdk/{chunk-RR2KJCQS.mjs.map → chunk-RUQBSUTM.mjs.map} +1 -1
- package/dist/sdk/{chunk-GIPTKOXT.mjs → chunk-TPJWUDMJ.mjs} +2 -2
- package/dist/sdk/{failure-condition-evaluator-M5PZFNV5.mjs → failure-condition-evaluator-TK26KQRA.mjs} +3 -3
- package/dist/sdk/{github-frontend-LGS6PO5Y.mjs → github-frontend-HOPD4TAR.mjs} +3 -3
- package/dist/sdk/{host-7AHCYIMA.mjs → host-4HD3VVKS.mjs} +2 -2
- package/dist/sdk/{host-7KYBK53Q.mjs → host-LCKHX2EN.mjs} +2 -2
- package/dist/sdk/knex-store-HPXJILBL.mjs +411 -0
- package/dist/sdk/knex-store-HPXJILBL.mjs.map +1 -0
- package/dist/sdk/loader-ZC5G3JGJ.mjs +89 -0
- package/dist/sdk/loader-ZC5G3JGJ.mjs.map +1 -0
- package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs +655 -0
- package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs.map +1 -0
- package/dist/sdk/{routing-6YONAZI2.mjs → routing-ZNIYEVS3.mjs} +4 -4
- package/dist/sdk/{schedule-tool-handler-OE7Z7IZS.mjs → schedule-tool-handler-BLC4E3VI.mjs} +6 -6
- package/dist/sdk/{schedule-tool-handler-XHNZW6UW.mjs → schedule-tool-handler-QC7CAK55.mjs} +5 -5
- package/dist/sdk/sdk.js +1528 -270
- package/dist/sdk/sdk.js.map +1 -1
- package/dist/sdk/sdk.mjs +5 -5
- package/dist/sdk/{trace-helpers-BYP4KQC2.mjs → trace-helpers-HP3LKMTS.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-P7B4CLFX.mjs → workflow-check-provider-HG5LNVBC.mjs} +5 -5
- package/dist/sdk/{workflow-check-provider-U2KQNJTA.mjs → workflow-check-provider-X24G57J2.mjs} +6 -6
- package/dist/telemetry/opentelemetry.d.ts.map +1 -1
- package/package.json +12 -12
- package/dist/output/traces/run-2026-02-24T18-10-00-146Z.ndjson +0 -138
- package/dist/output/traces/run-2026-02-24T18-10-50-506Z.ndjson +0 -1442
- package/dist/sdk/check-provider-registry-45ABC7FT.mjs +0 -30
- package/dist/sdk/chunk-H4AXRJWI.mjs +0 -40284
- package/dist/sdk/chunk-H4AXRJWI.mjs.map +0 -1
- package/dist/sdk/chunk-KE4TVNAM.mjs +0 -1502
- package/dist/sdk/chunk-KE4TVNAM.mjs.map +0 -1
- package/dist/sdk/chunk-LNWL4GGT.mjs +0 -443
- package/dist/sdk/chunk-LNWL4GGT.mjs.map +0 -1
- package/dist/sdk/chunk-X4RKN7JE.mjs +0 -739
- package/dist/sdk/chunk-X4RKN7JE.mjs.map +0 -1
- package/dist/sdk/failure-condition-evaluator-D5XXOVV2.mjs +0 -17
- package/dist/sdk/github-frontend-RRPGRKVV.mjs +0 -1356
- package/dist/sdk/github-frontend-RRPGRKVV.mjs.map +0 -1
- package/dist/sdk/routing-NXYICBGF.mjs +0 -25
- package/dist/sdk/schedule-tool-handler-HXNSZBDL.mjs +0 -40
- package/dist/sdk/schedule-tool-handler-XHNZW6UW.mjs.map +0 -1
- package/dist/sdk/trace-helpers-BYP4KQC2.mjs.map +0 -1
- package/dist/sdk/trace-helpers-LSOZHDYF.mjs +0 -25
- package/dist/sdk/trace-helpers-LSOZHDYF.mjs.map +0 -1
- package/dist/sdk/workflow-check-provider-INZUO2WJ.mjs +0 -30
- package/dist/sdk/workflow-check-provider-INZUO2WJ.mjs.map +0 -1
- package/dist/sdk/workflow-check-provider-P7B4CLFX.mjs.map +0 -1
- package/dist/sdk/workflow-check-provider-U2KQNJTA.mjs.map +0 -1
- package/dist/traces/run-2026-02-24T18-10-00-146Z.ndjson +0 -138
- package/dist/traces/run-2026-02-24T18-10-50-506Z.ndjson +0 -1442
- /package/dist/sdk/{check-provider-registry-45ABC7FT.mjs.map → check-provider-registry-NA54BH75.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-SNVE22YQ.mjs.map → check-provider-registry-QCE7HDRY.mjs.map} +0 -0
- /package/dist/sdk/{chunk-G3W5KQL7.mjs.map → chunk-5X6TLBDA.mjs.map} +0 -0
- /package/dist/sdk/{chunk-KUSF5IBV.mjs.map → chunk-HHQFJTPJ.mjs.map} +0 -0
- /package/dist/sdk/{chunk-GIPTKOXT.mjs.map → chunk-TPJWUDMJ.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-XUFQHEFY.mjs.map → failure-condition-evaluator-TK26KQRA.mjs.map} +0 -0
- /package/dist/sdk/{github-frontend-LGS6PO5Y.mjs.map → github-frontend-HOPD4TAR.mjs.map} +0 -0
- /package/dist/sdk/{host-7AHCYIMA.mjs.map → host-4HD3VVKS.mjs.map} +0 -0
- /package/dist/sdk/{host-7KYBK53Q.mjs.map → host-LCKHX2EN.mjs.map} +0 -0
- /package/dist/sdk/{failure-condition-evaluator-D5XXOVV2.mjs.map → routing-ZNIYEVS3.mjs.map} +0 -0
- /package/dist/sdk/{failure-condition-evaluator-M5PZFNV5.mjs.map → schedule-tool-handler-BLC4E3VI.mjs.map} +0 -0
- /package/dist/sdk/{routing-6YONAZI2.mjs.map → schedule-tool-handler-QC7CAK55.mjs.map} +0 -0
- /package/dist/sdk/{routing-NXYICBGF.mjs.map → trace-helpers-HP3LKMTS.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-HXNSZBDL.mjs.map → workflow-check-provider-HG5LNVBC.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-OE7Z7IZS.mjs.map → workflow-check-provider-X24G57J2.mjs.map} +0 -0
package/dist/sdk/sdk.js
CHANGED
|
@@ -646,7 +646,7 @@ var require_package = __commonJS({
|
|
|
646
646
|
"package.json"(exports2, module2) {
|
|
647
647
|
module2.exports = {
|
|
648
648
|
name: "@probelabs/visor",
|
|
649
|
-
version: "0.1.
|
|
649
|
+
version: "0.1.42",
|
|
650
650
|
main: "dist/index.js",
|
|
651
651
|
bin: {
|
|
652
652
|
visor: "./dist/index.js"
|
|
@@ -750,7 +750,17 @@ var require_package = __commonJS({
|
|
|
750
750
|
"@octokit/auth-app": "^8.1.0",
|
|
751
751
|
"@octokit/core": "^7.0.3",
|
|
752
752
|
"@octokit/rest": "^22.0.0",
|
|
753
|
-
"@
|
|
753
|
+
"@opentelemetry/api": "^1.9.0",
|
|
754
|
+
"@opentelemetry/core": "^1.30.1",
|
|
755
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "^0.203.0",
|
|
756
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
|
|
757
|
+
"@opentelemetry/instrumentation": "^0.203.0",
|
|
758
|
+
"@opentelemetry/resources": "^1.30.1",
|
|
759
|
+
"@opentelemetry/sdk-metrics": "^1.30.1",
|
|
760
|
+
"@opentelemetry/sdk-node": "^0.203.0",
|
|
761
|
+
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
762
|
+
"@opentelemetry/semantic-conventions": "^1.30.1",
|
|
763
|
+
"@probelabs/probe": "^0.6.0-rc258",
|
|
754
764
|
"@types/commander": "^2.12.0",
|
|
755
765
|
"@types/uuid": "^10.0.0",
|
|
756
766
|
acorn: "^8.16.0",
|
|
@@ -777,16 +787,6 @@ var require_package = __commonJS({
|
|
|
777
787
|
optionalDependencies: {
|
|
778
788
|
"@anthropic/claude-code-sdk": "npm:null@*",
|
|
779
789
|
"@open-policy-agent/opa-wasm": "^1.10.0",
|
|
780
|
-
"@opentelemetry/api": "^1.9.0",
|
|
781
|
-
"@opentelemetry/core": "^1.30.1",
|
|
782
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "^0.203.0",
|
|
783
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
|
|
784
|
-
"@opentelemetry/instrumentation": "^0.203.0",
|
|
785
|
-
"@opentelemetry/resources": "^1.30.1",
|
|
786
|
-
"@opentelemetry/sdk-metrics": "^1.30.1",
|
|
787
|
-
"@opentelemetry/sdk-node": "^0.203.0",
|
|
788
|
-
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
789
|
-
"@opentelemetry/semantic-conventions": "^1.30.1",
|
|
790
790
|
knex: "^3.1.0",
|
|
791
791
|
mysql2: "^3.11.0",
|
|
792
792
|
pg: "^8.13.0",
|
|
@@ -864,11 +864,11 @@ function getTracer() {
|
|
|
864
864
|
}
|
|
865
865
|
async function withActiveSpan(name, attrs, fn) {
|
|
866
866
|
const tracer = getTracer();
|
|
867
|
-
return await new Promise((
|
|
867
|
+
return await new Promise((resolve15, reject) => {
|
|
868
868
|
const callback = async (span) => {
|
|
869
869
|
try {
|
|
870
870
|
const res = await fn(span);
|
|
871
|
-
|
|
871
|
+
resolve15(res);
|
|
872
872
|
} catch (err) {
|
|
873
873
|
try {
|
|
874
874
|
if (err instanceof Error) span.recordException(err);
|
|
@@ -945,19 +945,19 @@ function __getOrCreateNdjsonPath() {
|
|
|
945
945
|
try {
|
|
946
946
|
if (process.env.VISOR_TELEMETRY_SINK && process.env.VISOR_TELEMETRY_SINK !== "file")
|
|
947
947
|
return null;
|
|
948
|
-
const
|
|
949
|
-
const
|
|
948
|
+
const path30 = require("path");
|
|
949
|
+
const fs26 = require("fs");
|
|
950
950
|
if (process.env.VISOR_FALLBACK_TRACE_FILE) {
|
|
951
951
|
__ndjsonPath = process.env.VISOR_FALLBACK_TRACE_FILE;
|
|
952
|
-
const dir =
|
|
953
|
-
if (!
|
|
952
|
+
const dir = path30.dirname(__ndjsonPath);
|
|
953
|
+
if (!fs26.existsSync(dir)) fs26.mkdirSync(dir, { recursive: true });
|
|
954
954
|
return __ndjsonPath;
|
|
955
955
|
}
|
|
956
|
-
const outDir = process.env.VISOR_TRACE_DIR ||
|
|
957
|
-
if (!
|
|
956
|
+
const outDir = process.env.VISOR_TRACE_DIR || path30.join(process.cwd(), "output", "traces");
|
|
957
|
+
if (!fs26.existsSync(outDir)) fs26.mkdirSync(outDir, { recursive: true });
|
|
958
958
|
if (!__ndjsonPath) {
|
|
959
959
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
960
|
-
__ndjsonPath =
|
|
960
|
+
__ndjsonPath = path30.join(outDir, `${ts}.ndjson`);
|
|
961
961
|
}
|
|
962
962
|
return __ndjsonPath;
|
|
963
963
|
} catch {
|
|
@@ -966,11 +966,11 @@ function __getOrCreateNdjsonPath() {
|
|
|
966
966
|
}
|
|
967
967
|
function _appendRunMarker() {
|
|
968
968
|
try {
|
|
969
|
-
const
|
|
969
|
+
const fs26 = require("fs");
|
|
970
970
|
const p = __getOrCreateNdjsonPath();
|
|
971
971
|
if (!p) return;
|
|
972
972
|
const line = { name: "visor.run", attributes: { started: true } };
|
|
973
|
-
|
|
973
|
+
fs26.appendFileSync(p, JSON.stringify(line) + "\n", "utf8");
|
|
974
974
|
} catch {
|
|
975
975
|
}
|
|
976
976
|
}
|
|
@@ -3193,7 +3193,7 @@ var init_failure_condition_evaluator = __esm({
|
|
|
3193
3193
|
*/
|
|
3194
3194
|
evaluateExpression(condition, context2) {
|
|
3195
3195
|
try {
|
|
3196
|
-
const
|
|
3196
|
+
const normalize8 = (expr) => {
|
|
3197
3197
|
const trimmed = expr.trim();
|
|
3198
3198
|
if (!/[\n;]/.test(trimmed)) return trimmed;
|
|
3199
3199
|
const parts = trimmed.split(/[\n;]+/).map((s) => s.trim()).filter((s) => s.length > 0 && !s.startsWith("//"));
|
|
@@ -3351,7 +3351,7 @@ var init_failure_condition_evaluator = __esm({
|
|
|
3351
3351
|
try {
|
|
3352
3352
|
exec2 = this.sandbox.compile(`return (${raw});`);
|
|
3353
3353
|
} catch {
|
|
3354
|
-
const normalizedExpr =
|
|
3354
|
+
const normalizedExpr = normalize8(condition);
|
|
3355
3355
|
exec2 = this.sandbox.compile(`return (${normalizedExpr});`);
|
|
3356
3356
|
}
|
|
3357
3357
|
const result = exec2(scope).run();
|
|
@@ -3734,9 +3734,9 @@ function configureLiquidWithExtensions(liquid) {
|
|
|
3734
3734
|
});
|
|
3735
3735
|
liquid.registerFilter("get", (obj, pathExpr) => {
|
|
3736
3736
|
if (obj == null) return void 0;
|
|
3737
|
-
const
|
|
3738
|
-
if (!
|
|
3739
|
-
const parts =
|
|
3737
|
+
const path30 = typeof pathExpr === "string" ? pathExpr : String(pathExpr || "");
|
|
3738
|
+
if (!path30) return obj;
|
|
3739
|
+
const parts = path30.split(".");
|
|
3740
3740
|
let cur = obj;
|
|
3741
3741
|
for (const p of parts) {
|
|
3742
3742
|
if (cur == null) return void 0;
|
|
@@ -3855,9 +3855,9 @@ function configureLiquidWithExtensions(liquid) {
|
|
|
3855
3855
|
}
|
|
3856
3856
|
}
|
|
3857
3857
|
const defaultRole = typeof rolesCfg.default === "string" && rolesCfg.default.trim() ? rolesCfg.default.trim() : void 0;
|
|
3858
|
-
const getNested = (obj,
|
|
3859
|
-
if (!obj || !
|
|
3860
|
-
const parts =
|
|
3858
|
+
const getNested = (obj, path30) => {
|
|
3859
|
+
if (!obj || !path30) return void 0;
|
|
3860
|
+
const parts = path30.split(".");
|
|
3861
3861
|
let cur = obj;
|
|
3862
3862
|
for (const p of parts) {
|
|
3863
3863
|
if (cur == null) return void 0;
|
|
@@ -6409,8 +6409,8 @@ var init_dependency_gating = __esm({
|
|
|
6409
6409
|
async function renderTemplateContent(checkId, checkConfig, reviewSummary) {
|
|
6410
6410
|
try {
|
|
6411
6411
|
const { createExtendedLiquid: createExtendedLiquid2 } = await Promise.resolve().then(() => (init_liquid_extensions(), liquid_extensions_exports));
|
|
6412
|
-
const
|
|
6413
|
-
const
|
|
6412
|
+
const fs26 = await import("fs/promises");
|
|
6413
|
+
const path30 = await import("path");
|
|
6414
6414
|
const schemaRaw = checkConfig.schema || "plain";
|
|
6415
6415
|
const schema = typeof schemaRaw === "string" ? schemaRaw : "code-review";
|
|
6416
6416
|
let templateContent;
|
|
@@ -6418,24 +6418,24 @@ async function renderTemplateContent(checkId, checkConfig, reviewSummary) {
|
|
|
6418
6418
|
templateContent = String(checkConfig.template.content);
|
|
6419
6419
|
} else if (checkConfig.template && checkConfig.template.file) {
|
|
6420
6420
|
const file = String(checkConfig.template.file);
|
|
6421
|
-
const resolved =
|
|
6422
|
-
templateContent = await
|
|
6421
|
+
const resolved = path30.resolve(process.cwd(), file);
|
|
6422
|
+
templateContent = await fs26.readFile(resolved, "utf-8");
|
|
6423
6423
|
} else if (schema && schema !== "plain") {
|
|
6424
6424
|
const sanitized = String(schema).replace(/[^a-zA-Z0-9-]/g, "");
|
|
6425
6425
|
if (sanitized) {
|
|
6426
6426
|
const candidatePaths = [
|
|
6427
|
-
|
|
6427
|
+
path30.join(__dirname, "output", sanitized, "template.liquid"),
|
|
6428
6428
|
// bundled: dist/output/
|
|
6429
|
-
|
|
6429
|
+
path30.join(__dirname, "..", "..", "output", sanitized, "template.liquid"),
|
|
6430
6430
|
// source: output/
|
|
6431
|
-
|
|
6431
|
+
path30.join(process.cwd(), "output", sanitized, "template.liquid"),
|
|
6432
6432
|
// fallback: cwd/output/
|
|
6433
|
-
|
|
6433
|
+
path30.join(process.cwd(), "dist", "output", sanitized, "template.liquid")
|
|
6434
6434
|
// fallback: cwd/dist/output/
|
|
6435
6435
|
];
|
|
6436
6436
|
for (const p of candidatePaths) {
|
|
6437
6437
|
try {
|
|
6438
|
-
templateContent = await
|
|
6438
|
+
templateContent = await fs26.readFile(p, "utf-8");
|
|
6439
6439
|
if (templateContent) break;
|
|
6440
6440
|
} catch {
|
|
6441
6441
|
}
|
|
@@ -6840,7 +6840,7 @@ async function processDiffWithOutline(diffContent) {
|
|
|
6840
6840
|
}
|
|
6841
6841
|
try {
|
|
6842
6842
|
const originalProbePath = process.env.PROBE_PATH;
|
|
6843
|
-
const
|
|
6843
|
+
const fs26 = require("fs");
|
|
6844
6844
|
const possiblePaths = [
|
|
6845
6845
|
// Relative to current working directory (most common in production)
|
|
6846
6846
|
path6.join(process.cwd(), "node_modules/@probelabs/probe/bin/probe-binary"),
|
|
@@ -6851,7 +6851,7 @@ async function processDiffWithOutline(diffContent) {
|
|
|
6851
6851
|
];
|
|
6852
6852
|
let probeBinaryPath;
|
|
6853
6853
|
for (const candidatePath of possiblePaths) {
|
|
6854
|
-
if (
|
|
6854
|
+
if (fs26.existsSync(candidatePath)) {
|
|
6855
6855
|
probeBinaryPath = candidatePath;
|
|
6856
6856
|
break;
|
|
6857
6857
|
}
|
|
@@ -6972,7 +6972,7 @@ async function renderMermaidToPng(mermaidCode) {
|
|
|
6972
6972
|
if (chromiumPath) {
|
|
6973
6973
|
env.PUPPETEER_EXECUTABLE_PATH = chromiumPath;
|
|
6974
6974
|
}
|
|
6975
|
-
const result = await new Promise((
|
|
6975
|
+
const result = await new Promise((resolve15) => {
|
|
6976
6976
|
const proc = (0, import_child_process.spawn)(
|
|
6977
6977
|
"npx",
|
|
6978
6978
|
[
|
|
@@ -7002,13 +7002,13 @@ async function renderMermaidToPng(mermaidCode) {
|
|
|
7002
7002
|
});
|
|
7003
7003
|
proc.on("close", (code) => {
|
|
7004
7004
|
if (code === 0) {
|
|
7005
|
-
|
|
7005
|
+
resolve15({ success: true });
|
|
7006
7006
|
} else {
|
|
7007
|
-
|
|
7007
|
+
resolve15({ success: false, error: stderr || `Exit code ${code}` });
|
|
7008
7008
|
}
|
|
7009
7009
|
});
|
|
7010
7010
|
proc.on("error", (err) => {
|
|
7011
|
-
|
|
7011
|
+
resolve15({ success: false, error: err.message });
|
|
7012
7012
|
});
|
|
7013
7013
|
});
|
|
7014
7014
|
if (!result.success) {
|
|
@@ -8153,8 +8153,8 @@ ${schemaString}`);
|
|
|
8153
8153
|
}
|
|
8154
8154
|
if (process.env.VISOR_DEBUG_AI_SESSIONS === "true") {
|
|
8155
8155
|
try {
|
|
8156
|
-
const
|
|
8157
|
-
const
|
|
8156
|
+
const fs26 = require("fs");
|
|
8157
|
+
const path30 = require("path");
|
|
8158
8158
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
8159
8159
|
const provider = this.config.provider || "auto";
|
|
8160
8160
|
const model = this.config.model || "default";
|
|
@@ -8268,20 +8268,20 @@ ${"=".repeat(60)}
|
|
|
8268
8268
|
`;
|
|
8269
8269
|
readableVersion += `${"=".repeat(60)}
|
|
8270
8270
|
`;
|
|
8271
|
-
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS ||
|
|
8272
|
-
if (!
|
|
8273
|
-
|
|
8271
|
+
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS || path30.join(process.cwd(), "debug-artifacts");
|
|
8272
|
+
if (!fs26.existsSync(debugArtifactsDir)) {
|
|
8273
|
+
fs26.mkdirSync(debugArtifactsDir, { recursive: true });
|
|
8274
8274
|
}
|
|
8275
|
-
const debugFile =
|
|
8275
|
+
const debugFile = path30.join(
|
|
8276
8276
|
debugArtifactsDir,
|
|
8277
8277
|
`prompt-${_checkName || "unknown"}-${timestamp}.json`
|
|
8278
8278
|
);
|
|
8279
|
-
|
|
8280
|
-
const readableFile =
|
|
8279
|
+
fs26.writeFileSync(debugFile, debugJson, "utf-8");
|
|
8280
|
+
const readableFile = path30.join(
|
|
8281
8281
|
debugArtifactsDir,
|
|
8282
8282
|
`prompt-${_checkName || "unknown"}-${timestamp}.txt`
|
|
8283
8283
|
);
|
|
8284
|
-
|
|
8284
|
+
fs26.writeFileSync(readableFile, readableVersion, "utf-8");
|
|
8285
8285
|
log(`
|
|
8286
8286
|
\u{1F4BE} Full debug info saved to:`);
|
|
8287
8287
|
log(` JSON: ${debugFile}`);
|
|
@@ -8314,8 +8314,8 @@ ${"=".repeat(60)}
|
|
|
8314
8314
|
log(`\u{1F4E4} Response length: ${response.length} characters`);
|
|
8315
8315
|
if (process.env.VISOR_DEBUG_AI_SESSIONS === "true") {
|
|
8316
8316
|
try {
|
|
8317
|
-
const
|
|
8318
|
-
const
|
|
8317
|
+
const fs26 = require("fs");
|
|
8318
|
+
const path30 = require("path");
|
|
8319
8319
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
8320
8320
|
const agentAny2 = agent;
|
|
8321
8321
|
let fullHistory = [];
|
|
@@ -8326,8 +8326,8 @@ ${"=".repeat(60)}
|
|
|
8326
8326
|
} else if (agentAny2._messages) {
|
|
8327
8327
|
fullHistory = agentAny2._messages;
|
|
8328
8328
|
}
|
|
8329
|
-
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS ||
|
|
8330
|
-
const sessionBase =
|
|
8329
|
+
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS || path30.join(process.cwd(), "debug-artifacts");
|
|
8330
|
+
const sessionBase = path30.join(
|
|
8331
8331
|
debugArtifactsDir,
|
|
8332
8332
|
`session-${_checkName || "unknown"}-${timestamp}`
|
|
8333
8333
|
);
|
|
@@ -8339,7 +8339,7 @@ ${"=".repeat(60)}
|
|
|
8339
8339
|
schema: effectiveSchema,
|
|
8340
8340
|
totalMessages: fullHistory.length
|
|
8341
8341
|
};
|
|
8342
|
-
|
|
8342
|
+
fs26.writeFileSync(sessionBase + ".json", JSON.stringify(sessionData, null, 2), "utf-8");
|
|
8343
8343
|
let readable = `=============================================================
|
|
8344
8344
|
`;
|
|
8345
8345
|
readable += `COMPLETE AI SESSION HISTORY (AFTER RESPONSE)
|
|
@@ -8366,7 +8366,7 @@ ${"=".repeat(60)}
|
|
|
8366
8366
|
`;
|
|
8367
8367
|
readable += content + "\n";
|
|
8368
8368
|
});
|
|
8369
|
-
|
|
8369
|
+
fs26.writeFileSync(sessionBase + ".summary.txt", readable, "utf-8");
|
|
8370
8370
|
log(`\u{1F4BE} Complete session history saved:`);
|
|
8371
8371
|
log(` - Contains ALL ${fullHistory.length} messages (prompts + responses)`);
|
|
8372
8372
|
} catch (error) {
|
|
@@ -8375,11 +8375,11 @@ ${"=".repeat(60)}
|
|
|
8375
8375
|
}
|
|
8376
8376
|
if (process.env.VISOR_DEBUG_AI_SESSIONS === "true") {
|
|
8377
8377
|
try {
|
|
8378
|
-
const
|
|
8379
|
-
const
|
|
8378
|
+
const fs26 = require("fs");
|
|
8379
|
+
const path30 = require("path");
|
|
8380
8380
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
8381
|
-
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS ||
|
|
8382
|
-
const responseFile =
|
|
8381
|
+
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS || path30.join(process.cwd(), "debug-artifacts");
|
|
8382
|
+
const responseFile = path30.join(
|
|
8383
8383
|
debugArtifactsDir,
|
|
8384
8384
|
`response-${_checkName || "unknown"}-${timestamp}.txt`
|
|
8385
8385
|
);
|
|
@@ -8412,7 +8412,7 @@ ${"=".repeat(60)}
|
|
|
8412
8412
|
`;
|
|
8413
8413
|
responseContent += `${"=".repeat(60)}
|
|
8414
8414
|
`;
|
|
8415
|
-
|
|
8415
|
+
fs26.writeFileSync(responseFile, responseContent, "utf-8");
|
|
8416
8416
|
log(`\u{1F4BE} Response saved to: ${responseFile}`);
|
|
8417
8417
|
} catch (error) {
|
|
8418
8418
|
log(`\u26A0\uFE0F Could not save response file: ${error}`);
|
|
@@ -8428,9 +8428,9 @@ ${"=".repeat(60)}
|
|
|
8428
8428
|
await agentAny._telemetryConfig.shutdown();
|
|
8429
8429
|
log(`\u{1F4CA} OpenTelemetry trace saved to: ${agentAny._traceFilePath}`);
|
|
8430
8430
|
if (process.env.GITHUB_ACTIONS) {
|
|
8431
|
-
const
|
|
8432
|
-
if (
|
|
8433
|
-
const stats =
|
|
8431
|
+
const fs26 = require("fs");
|
|
8432
|
+
if (fs26.existsSync(agentAny._traceFilePath)) {
|
|
8433
|
+
const stats = fs26.statSync(agentAny._traceFilePath);
|
|
8434
8434
|
console.log(
|
|
8435
8435
|
`::notice title=AI Trace Saved::${agentAny._traceFilePath} (${stats.size} bytes)`
|
|
8436
8436
|
);
|
|
@@ -8631,9 +8631,9 @@ ${schemaString}`);
|
|
|
8631
8631
|
const model = this.config.model || "default";
|
|
8632
8632
|
if (process.env.VISOR_DEBUG_AI_SESSIONS === "true") {
|
|
8633
8633
|
try {
|
|
8634
|
-
const
|
|
8635
|
-
const
|
|
8636
|
-
const
|
|
8634
|
+
const fs26 = require("fs");
|
|
8635
|
+
const path30 = require("path");
|
|
8636
|
+
const os3 = require("os");
|
|
8637
8637
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
8638
8638
|
const debugData = {
|
|
8639
8639
|
timestamp,
|
|
@@ -8705,19 +8705,19 @@ ${"=".repeat(60)}
|
|
|
8705
8705
|
`;
|
|
8706
8706
|
readableVersion += `${"=".repeat(60)}
|
|
8707
8707
|
`;
|
|
8708
|
-
const tempDir =
|
|
8709
|
-
const promptFile =
|
|
8710
|
-
|
|
8708
|
+
const tempDir = os3.tmpdir();
|
|
8709
|
+
const promptFile = path30.join(tempDir, `visor-prompt-${timestamp}.txt`);
|
|
8710
|
+
fs26.writeFileSync(promptFile, prompt, "utf-8");
|
|
8711
8711
|
log(`
|
|
8712
8712
|
\u{1F4BE} Prompt saved to: ${promptFile}`);
|
|
8713
|
-
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS ||
|
|
8713
|
+
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS || path30.join(process.cwd(), "debug-artifacts");
|
|
8714
8714
|
try {
|
|
8715
|
-
const base =
|
|
8715
|
+
const base = path30.join(
|
|
8716
8716
|
debugArtifactsDir,
|
|
8717
8717
|
`prompt-${_checkName || "unknown"}-${timestamp}`
|
|
8718
8718
|
);
|
|
8719
|
-
|
|
8720
|
-
|
|
8719
|
+
fs26.writeFileSync(base + ".json", debugJson, "utf-8");
|
|
8720
|
+
fs26.writeFileSync(base + ".summary.txt", readableVersion, "utf-8");
|
|
8721
8721
|
log(`
|
|
8722
8722
|
\u{1F4BE} Full debug info saved to directory: ${debugArtifactsDir}`);
|
|
8723
8723
|
} catch {
|
|
@@ -8762,8 +8762,8 @@ $ ${cliCommand}
|
|
|
8762
8762
|
log(`\u{1F4E4} Response length: ${response.length} characters`);
|
|
8763
8763
|
if (process.env.VISOR_DEBUG_AI_SESSIONS === "true") {
|
|
8764
8764
|
try {
|
|
8765
|
-
const
|
|
8766
|
-
const
|
|
8765
|
+
const fs26 = require("fs");
|
|
8766
|
+
const path30 = require("path");
|
|
8767
8767
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
8768
8768
|
const agentAny = agent;
|
|
8769
8769
|
let fullHistory = [];
|
|
@@ -8774,8 +8774,8 @@ $ ${cliCommand}
|
|
|
8774
8774
|
} else if (agentAny._messages) {
|
|
8775
8775
|
fullHistory = agentAny._messages;
|
|
8776
8776
|
}
|
|
8777
|
-
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS ||
|
|
8778
|
-
const sessionBase =
|
|
8777
|
+
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS || path30.join(process.cwd(), "debug-artifacts");
|
|
8778
|
+
const sessionBase = path30.join(
|
|
8779
8779
|
debugArtifactsDir,
|
|
8780
8780
|
`session-${_checkName || "unknown"}-${timestamp}`
|
|
8781
8781
|
);
|
|
@@ -8787,7 +8787,7 @@ $ ${cliCommand}
|
|
|
8787
8787
|
schema: effectiveSchema,
|
|
8788
8788
|
totalMessages: fullHistory.length
|
|
8789
8789
|
};
|
|
8790
|
-
|
|
8790
|
+
fs26.writeFileSync(sessionBase + ".json", JSON.stringify(sessionData, null, 2), "utf-8");
|
|
8791
8791
|
let readable = `=============================================================
|
|
8792
8792
|
`;
|
|
8793
8793
|
readable += `COMPLETE AI SESSION HISTORY (AFTER RESPONSE)
|
|
@@ -8814,7 +8814,7 @@ ${"=".repeat(60)}
|
|
|
8814
8814
|
`;
|
|
8815
8815
|
readable += content + "\n";
|
|
8816
8816
|
});
|
|
8817
|
-
|
|
8817
|
+
fs26.writeFileSync(sessionBase + ".summary.txt", readable, "utf-8");
|
|
8818
8818
|
log(`\u{1F4BE} Complete session history saved:`);
|
|
8819
8819
|
log(` - Contains ALL ${fullHistory.length} messages (prompts + responses)`);
|
|
8820
8820
|
} catch (error) {
|
|
@@ -8823,11 +8823,11 @@ ${"=".repeat(60)}
|
|
|
8823
8823
|
}
|
|
8824
8824
|
if (process.env.VISOR_DEBUG_AI_SESSIONS === "true") {
|
|
8825
8825
|
try {
|
|
8826
|
-
const
|
|
8827
|
-
const
|
|
8826
|
+
const fs26 = require("fs");
|
|
8827
|
+
const path30 = require("path");
|
|
8828
8828
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
8829
|
-
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS ||
|
|
8830
|
-
const responseFile =
|
|
8829
|
+
const debugArtifactsDir = process.env.VISOR_DEBUG_ARTIFACTS || path30.join(process.cwd(), "debug-artifacts");
|
|
8830
|
+
const responseFile = path30.join(
|
|
8831
8831
|
debugArtifactsDir,
|
|
8832
8832
|
`response-${_checkName || "unknown"}-${timestamp}.txt`
|
|
8833
8833
|
);
|
|
@@ -8860,7 +8860,7 @@ ${"=".repeat(60)}
|
|
|
8860
8860
|
`;
|
|
8861
8861
|
responseContent += `${"=".repeat(60)}
|
|
8862
8862
|
`;
|
|
8863
|
-
|
|
8863
|
+
fs26.writeFileSync(responseFile, responseContent, "utf-8");
|
|
8864
8864
|
log(`\u{1F4BE} Response saved to: ${responseFile}`);
|
|
8865
8865
|
} catch (error) {
|
|
8866
8866
|
log(`\u26A0\uFE0F Could not save response file: ${error}`);
|
|
@@ -8878,9 +8878,9 @@ ${"=".repeat(60)}
|
|
|
8878
8878
|
await telemetry.shutdown();
|
|
8879
8879
|
log(`\u{1F4CA} OpenTelemetry trace saved to: ${traceFilePath}`);
|
|
8880
8880
|
if (process.env.GITHUB_ACTIONS) {
|
|
8881
|
-
const
|
|
8882
|
-
if (
|
|
8883
|
-
const stats =
|
|
8881
|
+
const fs26 = require("fs");
|
|
8882
|
+
if (fs26.existsSync(traceFilePath)) {
|
|
8883
|
+
const stats = fs26.statSync(traceFilePath);
|
|
8884
8884
|
console.log(
|
|
8885
8885
|
`::notice title=AI Trace Saved::OpenTelemetry trace file size: ${stats.size} bytes`
|
|
8886
8886
|
);
|
|
@@ -8918,8 +8918,8 @@ ${"=".repeat(60)}
|
|
|
8918
8918
|
* Load schema content from schema files or inline definitions
|
|
8919
8919
|
*/
|
|
8920
8920
|
async loadSchemaContent(schema) {
|
|
8921
|
-
const
|
|
8922
|
-
const
|
|
8921
|
+
const fs26 = require("fs").promises;
|
|
8922
|
+
const path30 = require("path");
|
|
8923
8923
|
if (typeof schema === "object" && schema !== null) {
|
|
8924
8924
|
log("\u{1F4CB} Using inline schema object from configuration");
|
|
8925
8925
|
return JSON.stringify(schema);
|
|
@@ -8932,14 +8932,14 @@ ${"=".repeat(60)}
|
|
|
8932
8932
|
}
|
|
8933
8933
|
} catch {
|
|
8934
8934
|
}
|
|
8935
|
-
if ((schema.startsWith("./") || schema.includes(".json")) && !
|
|
8935
|
+
if ((schema.startsWith("./") || schema.includes(".json")) && !path30.isAbsolute(schema)) {
|
|
8936
8936
|
if (schema.includes("..") || schema.includes("\0")) {
|
|
8937
8937
|
throw new Error("Invalid schema path: path traversal not allowed");
|
|
8938
8938
|
}
|
|
8939
8939
|
try {
|
|
8940
|
-
const schemaPath =
|
|
8940
|
+
const schemaPath = path30.resolve(process.cwd(), schema);
|
|
8941
8941
|
log(`\u{1F4CB} Loading custom schema from file: ${schemaPath}`);
|
|
8942
|
-
const schemaContent = await
|
|
8942
|
+
const schemaContent = await fs26.readFile(schemaPath, "utf-8");
|
|
8943
8943
|
return schemaContent.trim();
|
|
8944
8944
|
} catch (error) {
|
|
8945
8945
|
throw new Error(
|
|
@@ -8953,22 +8953,22 @@ ${"=".repeat(60)}
|
|
|
8953
8953
|
}
|
|
8954
8954
|
const candidatePaths = [
|
|
8955
8955
|
// GitHub Action bundle location
|
|
8956
|
-
|
|
8956
|
+
path30.join(__dirname, "output", sanitizedSchemaName, "schema.json"),
|
|
8957
8957
|
// Historical fallback when src/output was inadvertently bundled as output1/
|
|
8958
|
-
|
|
8958
|
+
path30.join(__dirname, "output1", sanitizedSchemaName, "schema.json"),
|
|
8959
8959
|
// Local dev (repo root)
|
|
8960
|
-
|
|
8960
|
+
path30.join(process.cwd(), "output", sanitizedSchemaName, "schema.json")
|
|
8961
8961
|
];
|
|
8962
8962
|
for (const schemaPath of candidatePaths) {
|
|
8963
8963
|
try {
|
|
8964
|
-
const schemaContent = await
|
|
8964
|
+
const schemaContent = await fs26.readFile(schemaPath, "utf-8");
|
|
8965
8965
|
return schemaContent.trim();
|
|
8966
8966
|
} catch {
|
|
8967
8967
|
}
|
|
8968
8968
|
}
|
|
8969
|
-
const distPath =
|
|
8970
|
-
const distAltPath =
|
|
8971
|
-
const cwdPath =
|
|
8969
|
+
const distPath = path30.join(__dirname, "output", sanitizedSchemaName, "schema.json");
|
|
8970
|
+
const distAltPath = path30.join(__dirname, "output1", sanitizedSchemaName, "schema.json");
|
|
8971
|
+
const cwdPath = path30.join(process.cwd(), "output", sanitizedSchemaName, "schema.json");
|
|
8972
8972
|
throw new Error(
|
|
8973
8973
|
`Failed to load schema '${sanitizedSchemaName}'. Tried: ${distPath}, ${distAltPath}, and ${cwdPath}. Ensure build copies 'output/' into dist (build:cli), or provide a custom schema file/path.`
|
|
8974
8974
|
);
|
|
@@ -9213,7 +9213,7 @@ ${"=".repeat(60)}
|
|
|
9213
9213
|
* Generate mock response for testing
|
|
9214
9214
|
*/
|
|
9215
9215
|
async generateMockResponse(_prompt, _checkName, _schema) {
|
|
9216
|
-
await new Promise((
|
|
9216
|
+
await new Promise((resolve15) => setTimeout(resolve15, 500));
|
|
9217
9217
|
const name = (_checkName || "").toLowerCase();
|
|
9218
9218
|
if (name.includes("extract-facts")) {
|
|
9219
9219
|
const arr = Array.from({ length: 6 }, (_, i) => ({
|
|
@@ -9574,7 +9574,7 @@ var init_command_executor = __esm({
|
|
|
9574
9574
|
* Execute command with stdin input
|
|
9575
9575
|
*/
|
|
9576
9576
|
executeWithStdin(command, options) {
|
|
9577
|
-
return new Promise((
|
|
9577
|
+
return new Promise((resolve15, reject) => {
|
|
9578
9578
|
const childProcess = (0, import_child_process2.exec)(
|
|
9579
9579
|
command,
|
|
9580
9580
|
{
|
|
@@ -9586,7 +9586,7 @@ var init_command_executor = __esm({
|
|
|
9586
9586
|
if (error && error.killed && (error.code === "ETIMEDOUT" || error.signal === "SIGTERM")) {
|
|
9587
9587
|
reject(new Error(`Command timed out after ${options.timeout || 3e4}ms`));
|
|
9588
9588
|
} else {
|
|
9589
|
-
|
|
9589
|
+
resolve15({
|
|
9590
9590
|
stdout: stdout || "",
|
|
9591
9591
|
stderr: stderr || "",
|
|
9592
9592
|
exitCode: error ? error.code || 1 : 0
|
|
@@ -17388,17 +17388,17 @@ var init_workflow_check_provider = __esm({
|
|
|
17388
17388
|
* so it can be executed by the state machine as a nested workflow.
|
|
17389
17389
|
*/
|
|
17390
17390
|
async loadWorkflowFromConfigPath(sourcePath, baseDir) {
|
|
17391
|
-
const
|
|
17392
|
-
const
|
|
17391
|
+
const path30 = require("path");
|
|
17392
|
+
const fs26 = require("fs");
|
|
17393
17393
|
const yaml5 = require("js-yaml");
|
|
17394
|
-
const resolved =
|
|
17395
|
-
if (!
|
|
17394
|
+
const resolved = path30.isAbsolute(sourcePath) ? sourcePath : path30.resolve(baseDir, sourcePath);
|
|
17395
|
+
if (!fs26.existsSync(resolved)) {
|
|
17396
17396
|
throw new Error(`Workflow config not found at: ${resolved}`);
|
|
17397
17397
|
}
|
|
17398
|
-
const rawContent =
|
|
17398
|
+
const rawContent = fs26.readFileSync(resolved, "utf8");
|
|
17399
17399
|
const rawData = yaml5.load(rawContent);
|
|
17400
17400
|
if (rawData.imports && Array.isArray(rawData.imports)) {
|
|
17401
|
-
const configDir =
|
|
17401
|
+
const configDir = path30.dirname(resolved);
|
|
17402
17402
|
for (const source of rawData.imports) {
|
|
17403
17403
|
const results = await this.registry.import(source, {
|
|
17404
17404
|
basePath: configDir,
|
|
@@ -17428,8 +17428,8 @@ ${errors}`);
|
|
|
17428
17428
|
if (!steps || Object.keys(steps).length === 0) {
|
|
17429
17429
|
throw new Error(`Config '${resolved}' does not contain any steps to execute as a workflow`);
|
|
17430
17430
|
}
|
|
17431
|
-
const id =
|
|
17432
|
-
const name = loaded.name || `Workflow from ${
|
|
17431
|
+
const id = path30.basename(resolved).replace(/\.(ya?ml)$/i, "");
|
|
17432
|
+
const name = loaded.name || `Workflow from ${path30.basename(resolved)}`;
|
|
17433
17433
|
const workflowDef = {
|
|
17434
17434
|
id,
|
|
17435
17435
|
name,
|
|
@@ -18059,8 +18059,8 @@ async function createStoreBackend(storageConfig, haConfig) {
|
|
|
18059
18059
|
case "mssql": {
|
|
18060
18060
|
try {
|
|
18061
18061
|
const loaderPath = "../../enterprise/loader";
|
|
18062
|
-
const { loadEnterpriseStoreBackend } = await import(loaderPath);
|
|
18063
|
-
return await
|
|
18062
|
+
const { loadEnterpriseStoreBackend: loadEnterpriseStoreBackend2 } = await import(loaderPath);
|
|
18063
|
+
return await loadEnterpriseStoreBackend2(driver, storageConfig, haConfig);
|
|
18064
18064
|
} catch (err) {
|
|
18065
18065
|
const msg = err instanceof Error ? err.message : String(err);
|
|
18066
18066
|
logger.error(`[StoreFactory] Failed to load enterprise ${driver} backend: ${msg}`);
|
|
@@ -19334,7 +19334,7 @@ var init_mcp_custom_sse_server = __esm({
|
|
|
19334
19334
|
* Returns the actual bound port number
|
|
19335
19335
|
*/
|
|
19336
19336
|
async start() {
|
|
19337
|
-
return new Promise((
|
|
19337
|
+
return new Promise((resolve15, reject) => {
|
|
19338
19338
|
try {
|
|
19339
19339
|
this.server = import_http.default.createServer((req, res) => {
|
|
19340
19340
|
this.handleRequest(req, res).catch((error) => {
|
|
@@ -19368,7 +19368,7 @@ var init_mcp_custom_sse_server = __esm({
|
|
|
19368
19368
|
);
|
|
19369
19369
|
}
|
|
19370
19370
|
this.startKeepalive();
|
|
19371
|
-
|
|
19371
|
+
resolve15(this.port);
|
|
19372
19372
|
});
|
|
19373
19373
|
} catch (error) {
|
|
19374
19374
|
reject(error);
|
|
@@ -19431,7 +19431,7 @@ var init_mcp_custom_sse_server = __esm({
|
|
|
19431
19431
|
logger.debug(
|
|
19432
19432
|
`[CustomToolsSSEServer:${this.sessionId}] Grace period before stop: ${waitMs}ms (activeToolCalls=${this.activeToolCalls})`
|
|
19433
19433
|
);
|
|
19434
|
-
await new Promise((
|
|
19434
|
+
await new Promise((resolve15) => setTimeout(resolve15, waitMs));
|
|
19435
19435
|
}
|
|
19436
19436
|
}
|
|
19437
19437
|
if (this.activeToolCalls > 0) {
|
|
@@ -19440,7 +19440,7 @@ var init_mcp_custom_sse_server = __esm({
|
|
|
19440
19440
|
`[CustomToolsSSEServer:${this.sessionId}] Waiting for ${this.activeToolCalls} active tool call(s) before stop`
|
|
19441
19441
|
);
|
|
19442
19442
|
while (this.activeToolCalls > 0 && Date.now() - startedAt < effectiveDrainTimeoutMs) {
|
|
19443
|
-
await new Promise((
|
|
19443
|
+
await new Promise((resolve15) => setTimeout(resolve15, 250));
|
|
19444
19444
|
}
|
|
19445
19445
|
if (this.activeToolCalls > 0) {
|
|
19446
19446
|
logger.warn(
|
|
@@ -19465,21 +19465,21 @@ var init_mcp_custom_sse_server = __esm({
|
|
|
19465
19465
|
}
|
|
19466
19466
|
this.connections.clear();
|
|
19467
19467
|
if (this.server) {
|
|
19468
|
-
await new Promise((
|
|
19468
|
+
await new Promise((resolve15, reject) => {
|
|
19469
19469
|
const timeout = setTimeout(() => {
|
|
19470
19470
|
if (this.debug) {
|
|
19471
19471
|
logger.debug(
|
|
19472
19472
|
`[CustomToolsSSEServer:${this.sessionId}] Force closing server after timeout`
|
|
19473
19473
|
);
|
|
19474
19474
|
}
|
|
19475
|
-
this.server?.close(() =>
|
|
19475
|
+
this.server?.close(() => resolve15());
|
|
19476
19476
|
}, 5e3);
|
|
19477
19477
|
this.server.close((error) => {
|
|
19478
19478
|
clearTimeout(timeout);
|
|
19479
19479
|
if (error) {
|
|
19480
19480
|
reject(error);
|
|
19481
19481
|
} else {
|
|
19482
|
-
|
|
19482
|
+
resolve15();
|
|
19483
19483
|
}
|
|
19484
19484
|
});
|
|
19485
19485
|
});
|
|
@@ -19905,7 +19905,7 @@ var init_mcp_custom_sse_server = __esm({
|
|
|
19905
19905
|
logger.warn(
|
|
19906
19906
|
`[CustomToolsSSEServer:${this.sessionId}] Tool ${toolName} failed (attempt ${attempt + 1}/${retryCount + 1}): ${errorMsg}. Retrying in ${delay}ms`
|
|
19907
19907
|
);
|
|
19908
|
-
await new Promise((
|
|
19908
|
+
await new Promise((resolve15) => setTimeout(resolve15, delay));
|
|
19909
19909
|
attempt++;
|
|
19910
19910
|
}
|
|
19911
19911
|
}
|
|
@@ -20208,9 +20208,9 @@ var init_ai_check_provider = __esm({
|
|
|
20208
20208
|
} else {
|
|
20209
20209
|
resolvedPath = import_path7.default.resolve(process.cwd(), str);
|
|
20210
20210
|
}
|
|
20211
|
-
const
|
|
20211
|
+
const fs26 = require("fs").promises;
|
|
20212
20212
|
try {
|
|
20213
|
-
const stat = await
|
|
20213
|
+
const stat = await fs26.stat(resolvedPath);
|
|
20214
20214
|
return stat.isFile();
|
|
20215
20215
|
} catch {
|
|
20216
20216
|
return hasFileExtension && (isRelativePath || isAbsolutePath || hasPathSeparators);
|
|
@@ -26062,14 +26062,14 @@ var require_util = __commonJS({
|
|
|
26062
26062
|
}
|
|
26063
26063
|
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
|
|
26064
26064
|
let origin = url.origin != null ? url.origin : `${url.protocol}//${url.hostname}:${port}`;
|
|
26065
|
-
let
|
|
26065
|
+
let path30 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
|
|
26066
26066
|
if (origin.endsWith("/")) {
|
|
26067
26067
|
origin = origin.substring(0, origin.length - 1);
|
|
26068
26068
|
}
|
|
26069
|
-
if (
|
|
26070
|
-
|
|
26069
|
+
if (path30 && !path30.startsWith("/")) {
|
|
26070
|
+
path30 = `/${path30}`;
|
|
26071
26071
|
}
|
|
26072
|
-
url = new URL(origin +
|
|
26072
|
+
url = new URL(origin + path30);
|
|
26073
26073
|
}
|
|
26074
26074
|
return url;
|
|
26075
26075
|
}
|
|
@@ -27683,20 +27683,20 @@ var require_parseParams = __commonJS({
|
|
|
27683
27683
|
var require_basename = __commonJS({
|
|
27684
27684
|
"node_modules/@fastify/busboy/lib/utils/basename.js"(exports2, module2) {
|
|
27685
27685
|
"use strict";
|
|
27686
|
-
module2.exports = function basename4(
|
|
27687
|
-
if (typeof
|
|
27686
|
+
module2.exports = function basename4(path30) {
|
|
27687
|
+
if (typeof path30 !== "string") {
|
|
27688
27688
|
return "";
|
|
27689
27689
|
}
|
|
27690
|
-
for (var i =
|
|
27691
|
-
switch (
|
|
27690
|
+
for (var i = path30.length - 1; i >= 0; --i) {
|
|
27691
|
+
switch (path30.charCodeAt(i)) {
|
|
27692
27692
|
case 47:
|
|
27693
27693
|
// '/'
|
|
27694
27694
|
case 92:
|
|
27695
|
-
|
|
27696
|
-
return
|
|
27695
|
+
path30 = path30.slice(i + 1);
|
|
27696
|
+
return path30 === ".." || path30 === "." ? "" : path30;
|
|
27697
27697
|
}
|
|
27698
27698
|
}
|
|
27699
|
-
return
|
|
27699
|
+
return path30 === ".." || path30 === "." ? "" : path30;
|
|
27700
27700
|
};
|
|
27701
27701
|
}
|
|
27702
27702
|
});
|
|
@@ -28700,11 +28700,11 @@ var require_util2 = __commonJS({
|
|
|
28700
28700
|
var assert = require("assert");
|
|
28701
28701
|
var { isUint8Array } = require("util/types");
|
|
28702
28702
|
var supportedHashes = [];
|
|
28703
|
-
var
|
|
28703
|
+
var crypto4;
|
|
28704
28704
|
try {
|
|
28705
|
-
|
|
28705
|
+
crypto4 = require("crypto");
|
|
28706
28706
|
const possibleRelevantHashes = ["sha256", "sha384", "sha512"];
|
|
28707
|
-
supportedHashes =
|
|
28707
|
+
supportedHashes = crypto4.getHashes().filter((hash) => possibleRelevantHashes.includes(hash));
|
|
28708
28708
|
} catch {
|
|
28709
28709
|
}
|
|
28710
28710
|
function responseURL(response) {
|
|
@@ -28981,7 +28981,7 @@ var require_util2 = __commonJS({
|
|
|
28981
28981
|
}
|
|
28982
28982
|
}
|
|
28983
28983
|
function bytesMatch(bytes, metadataList) {
|
|
28984
|
-
if (
|
|
28984
|
+
if (crypto4 === void 0) {
|
|
28985
28985
|
return true;
|
|
28986
28986
|
}
|
|
28987
28987
|
const parsedMetadata = parseMetadata(metadataList);
|
|
@@ -28996,7 +28996,7 @@ var require_util2 = __commonJS({
|
|
|
28996
28996
|
for (const item of metadata) {
|
|
28997
28997
|
const algorithm = item.algo;
|
|
28998
28998
|
const expectedValue = item.hash;
|
|
28999
|
-
let actualValue =
|
|
28999
|
+
let actualValue = crypto4.createHash(algorithm).update(bytes).digest("base64");
|
|
29000
29000
|
if (actualValue[actualValue.length - 1] === "=") {
|
|
29001
29001
|
if (actualValue[actualValue.length - 2] === "=") {
|
|
29002
29002
|
actualValue = actualValue.slice(0, -2);
|
|
@@ -29089,8 +29089,8 @@ var require_util2 = __commonJS({
|
|
|
29089
29089
|
function createDeferredPromise() {
|
|
29090
29090
|
let res;
|
|
29091
29091
|
let rej;
|
|
29092
|
-
const promise = new Promise((
|
|
29093
|
-
res =
|
|
29092
|
+
const promise = new Promise((resolve15, reject) => {
|
|
29093
|
+
res = resolve15;
|
|
29094
29094
|
rej = reject;
|
|
29095
29095
|
});
|
|
29096
29096
|
return { promise, resolve: res, reject: rej };
|
|
@@ -30343,8 +30343,8 @@ var require_body = __commonJS({
|
|
|
30343
30343
|
var { parseMIMEType, serializeAMimeType } = require_dataURL();
|
|
30344
30344
|
var random;
|
|
30345
30345
|
try {
|
|
30346
|
-
const
|
|
30347
|
-
random = (max) =>
|
|
30346
|
+
const crypto4 = require("crypto");
|
|
30347
|
+
random = (max) => crypto4.randomInt(0, max);
|
|
30348
30348
|
} catch {
|
|
30349
30349
|
random = (max) => Math.floor(Math.random(max));
|
|
30350
30350
|
}
|
|
@@ -30595,8 +30595,8 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
30595
30595
|
});
|
|
30596
30596
|
}
|
|
30597
30597
|
});
|
|
30598
|
-
const busboyResolve = new Promise((
|
|
30599
|
-
busboy.on("finish",
|
|
30598
|
+
const busboyResolve = new Promise((resolve15, reject) => {
|
|
30599
|
+
busboy.on("finish", resolve15);
|
|
30600
30600
|
busboy.on("error", (err) => reject(new TypeError(err)));
|
|
30601
30601
|
});
|
|
30602
30602
|
if (this.body !== null) for await (const chunk of consumeBody(this[kState].body)) busboy.write(chunk);
|
|
@@ -30727,7 +30727,7 @@ var require_request = __commonJS({
|
|
|
30727
30727
|
}
|
|
30728
30728
|
var Request = class _Request {
|
|
30729
30729
|
constructor(origin, {
|
|
30730
|
-
path:
|
|
30730
|
+
path: path30,
|
|
30731
30731
|
method,
|
|
30732
30732
|
body,
|
|
30733
30733
|
headers,
|
|
@@ -30741,11 +30741,11 @@ var require_request = __commonJS({
|
|
|
30741
30741
|
throwOnError,
|
|
30742
30742
|
expectContinue
|
|
30743
30743
|
}, handler) {
|
|
30744
|
-
if (typeof
|
|
30744
|
+
if (typeof path30 !== "string") {
|
|
30745
30745
|
throw new InvalidArgumentError("path must be a string");
|
|
30746
|
-
} else if (
|
|
30746
|
+
} else if (path30[0] !== "/" && !(path30.startsWith("http://") || path30.startsWith("https://")) && method !== "CONNECT") {
|
|
30747
30747
|
throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
|
|
30748
|
-
} else if (invalidPathRegex.exec(
|
|
30748
|
+
} else if (invalidPathRegex.exec(path30) !== null) {
|
|
30749
30749
|
throw new InvalidArgumentError("invalid request path");
|
|
30750
30750
|
}
|
|
30751
30751
|
if (typeof method !== "string") {
|
|
@@ -30808,7 +30808,7 @@ var require_request = __commonJS({
|
|
|
30808
30808
|
this.completed = false;
|
|
30809
30809
|
this.aborted = false;
|
|
30810
30810
|
this.upgrade = upgrade || null;
|
|
30811
|
-
this.path = query ? util.buildURL(
|
|
30811
|
+
this.path = query ? util.buildURL(path30, query) : path30;
|
|
30812
30812
|
this.origin = origin;
|
|
30813
30813
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
30814
30814
|
this.blocking = blocking == null ? false : blocking;
|
|
@@ -31130,9 +31130,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
31130
31130
|
}
|
|
31131
31131
|
close(callback) {
|
|
31132
31132
|
if (callback === void 0) {
|
|
31133
|
-
return new Promise((
|
|
31133
|
+
return new Promise((resolve15, reject) => {
|
|
31134
31134
|
this.close((err, data) => {
|
|
31135
|
-
return err ? reject(err) :
|
|
31135
|
+
return err ? reject(err) : resolve15(data);
|
|
31136
31136
|
});
|
|
31137
31137
|
});
|
|
31138
31138
|
}
|
|
@@ -31170,12 +31170,12 @@ var require_dispatcher_base = __commonJS({
|
|
|
31170
31170
|
err = null;
|
|
31171
31171
|
}
|
|
31172
31172
|
if (callback === void 0) {
|
|
31173
|
-
return new Promise((
|
|
31173
|
+
return new Promise((resolve15, reject) => {
|
|
31174
31174
|
this.destroy(err, (err2, data) => {
|
|
31175
31175
|
return err2 ? (
|
|
31176
31176
|
/* istanbul ignore next: should never error */
|
|
31177
31177
|
reject(err2)
|
|
31178
|
-
) :
|
|
31178
|
+
) : resolve15(data);
|
|
31179
31179
|
});
|
|
31180
31180
|
});
|
|
31181
31181
|
}
|
|
@@ -31816,9 +31816,9 @@ var require_RedirectHandler = __commonJS({
|
|
|
31816
31816
|
return this.handler.onHeaders(statusCode, headers, resume, statusText);
|
|
31817
31817
|
}
|
|
31818
31818
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
31819
|
-
const
|
|
31819
|
+
const path30 = search ? `${pathname}${search}` : pathname;
|
|
31820
31820
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
31821
|
-
this.opts.path =
|
|
31821
|
+
this.opts.path = path30;
|
|
31822
31822
|
this.opts.origin = origin;
|
|
31823
31823
|
this.opts.maxRedirections = 0;
|
|
31824
31824
|
this.opts.query = null;
|
|
@@ -32237,16 +32237,16 @@ var require_client = __commonJS({
|
|
|
32237
32237
|
return this[kNeedDrain] < 2;
|
|
32238
32238
|
}
|
|
32239
32239
|
async [kClose]() {
|
|
32240
|
-
return new Promise((
|
|
32240
|
+
return new Promise((resolve15) => {
|
|
32241
32241
|
if (!this[kSize]) {
|
|
32242
|
-
|
|
32242
|
+
resolve15(null);
|
|
32243
32243
|
} else {
|
|
32244
|
-
this[kClosedResolve] =
|
|
32244
|
+
this[kClosedResolve] = resolve15;
|
|
32245
32245
|
}
|
|
32246
32246
|
});
|
|
32247
32247
|
}
|
|
32248
32248
|
async [kDestroy](err) {
|
|
32249
|
-
return new Promise((
|
|
32249
|
+
return new Promise((resolve15) => {
|
|
32250
32250
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
32251
32251
|
for (let i = 0; i < requests.length; i++) {
|
|
32252
32252
|
const request = requests[i];
|
|
@@ -32257,7 +32257,7 @@ var require_client = __commonJS({
|
|
|
32257
32257
|
this[kClosedResolve]();
|
|
32258
32258
|
this[kClosedResolve] = null;
|
|
32259
32259
|
}
|
|
32260
|
-
|
|
32260
|
+
resolve15();
|
|
32261
32261
|
};
|
|
32262
32262
|
if (this[kHTTP2Session] != null) {
|
|
32263
32263
|
util.destroy(this[kHTTP2Session], err);
|
|
@@ -32837,7 +32837,7 @@ var require_client = __commonJS({
|
|
|
32837
32837
|
});
|
|
32838
32838
|
}
|
|
32839
32839
|
try {
|
|
32840
|
-
const socket = await new Promise((
|
|
32840
|
+
const socket = await new Promise((resolve15, reject) => {
|
|
32841
32841
|
client[kConnector]({
|
|
32842
32842
|
host,
|
|
32843
32843
|
hostname,
|
|
@@ -32849,7 +32849,7 @@ var require_client = __commonJS({
|
|
|
32849
32849
|
if (err) {
|
|
32850
32850
|
reject(err);
|
|
32851
32851
|
} else {
|
|
32852
|
-
|
|
32852
|
+
resolve15(socket2);
|
|
32853
32853
|
}
|
|
32854
32854
|
});
|
|
32855
32855
|
});
|
|
@@ -33060,7 +33060,7 @@ var require_client = __commonJS({
|
|
|
33060
33060
|
writeH2(client, client[kHTTP2Session], request);
|
|
33061
33061
|
return;
|
|
33062
33062
|
}
|
|
33063
|
-
const { body, method, path:
|
|
33063
|
+
const { body, method, path: path30, host, upgrade, headers, blocking, reset } = request;
|
|
33064
33064
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
33065
33065
|
if (body && typeof body.read === "function") {
|
|
33066
33066
|
body.read(0);
|
|
@@ -33110,7 +33110,7 @@ var require_client = __commonJS({
|
|
|
33110
33110
|
if (blocking) {
|
|
33111
33111
|
socket[kBlocking] = true;
|
|
33112
33112
|
}
|
|
33113
|
-
let header = `${method} ${
|
|
33113
|
+
let header = `${method} ${path30} HTTP/1.1\r
|
|
33114
33114
|
`;
|
|
33115
33115
|
if (typeof host === "string") {
|
|
33116
33116
|
header += `host: ${host}\r
|
|
@@ -33173,7 +33173,7 @@ upgrade: ${upgrade}\r
|
|
|
33173
33173
|
return true;
|
|
33174
33174
|
}
|
|
33175
33175
|
function writeH2(client, session, request) {
|
|
33176
|
-
const { body, method, path:
|
|
33176
|
+
const { body, method, path: path30, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
|
|
33177
33177
|
let headers;
|
|
33178
33178
|
if (typeof reqHeaders === "string") headers = Request[kHTTP2CopyHeaders](reqHeaders.trim());
|
|
33179
33179
|
else headers = reqHeaders;
|
|
@@ -33216,7 +33216,7 @@ upgrade: ${upgrade}\r
|
|
|
33216
33216
|
});
|
|
33217
33217
|
return true;
|
|
33218
33218
|
}
|
|
33219
|
-
headers[HTTP2_HEADER_PATH] =
|
|
33219
|
+
headers[HTTP2_HEADER_PATH] = path30;
|
|
33220
33220
|
headers[HTTP2_HEADER_SCHEME] = "https";
|
|
33221
33221
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
33222
33222
|
if (body && typeof body.read === "function") {
|
|
@@ -33473,12 +33473,12 @@ upgrade: ${upgrade}\r
|
|
|
33473
33473
|
cb();
|
|
33474
33474
|
}
|
|
33475
33475
|
}
|
|
33476
|
-
const waitForDrain = () => new Promise((
|
|
33476
|
+
const waitForDrain = () => new Promise((resolve15, reject) => {
|
|
33477
33477
|
assert(callback === null);
|
|
33478
33478
|
if (socket[kError]) {
|
|
33479
33479
|
reject(socket[kError]);
|
|
33480
33480
|
} else {
|
|
33481
|
-
callback =
|
|
33481
|
+
callback = resolve15;
|
|
33482
33482
|
}
|
|
33483
33483
|
});
|
|
33484
33484
|
if (client[kHTTPConnVersion] === "h2") {
|
|
@@ -33824,8 +33824,8 @@ var require_pool_base = __commonJS({
|
|
|
33824
33824
|
if (this[kQueue].isEmpty()) {
|
|
33825
33825
|
return Promise.all(this[kClients].map((c) => c.close()));
|
|
33826
33826
|
} else {
|
|
33827
|
-
return new Promise((
|
|
33828
|
-
this[kClosedResolve] =
|
|
33827
|
+
return new Promise((resolve15) => {
|
|
33828
|
+
this[kClosedResolve] = resolve15;
|
|
33829
33829
|
});
|
|
33830
33830
|
}
|
|
33831
33831
|
}
|
|
@@ -34403,7 +34403,7 @@ var require_readable = __commonJS({
|
|
|
34403
34403
|
if (this.closed) {
|
|
34404
34404
|
return Promise.resolve(null);
|
|
34405
34405
|
}
|
|
34406
|
-
return new Promise((
|
|
34406
|
+
return new Promise((resolve15, reject) => {
|
|
34407
34407
|
const signalListenerCleanup = signal ? util.addAbortListener(signal, () => {
|
|
34408
34408
|
this.destroy();
|
|
34409
34409
|
}) : noop;
|
|
@@ -34412,7 +34412,7 @@ var require_readable = __commonJS({
|
|
|
34412
34412
|
if (signal && signal.aborted) {
|
|
34413
34413
|
reject(signal.reason || Object.assign(new Error("The operation was aborted"), { name: "AbortError" }));
|
|
34414
34414
|
} else {
|
|
34415
|
-
|
|
34415
|
+
resolve15(null);
|
|
34416
34416
|
}
|
|
34417
34417
|
}).on("error", noop).on("data", function(chunk) {
|
|
34418
34418
|
limit -= chunk.length;
|
|
@@ -34434,11 +34434,11 @@ var require_readable = __commonJS({
|
|
|
34434
34434
|
throw new TypeError("unusable");
|
|
34435
34435
|
}
|
|
34436
34436
|
assert(!stream[kConsume]);
|
|
34437
|
-
return new Promise((
|
|
34437
|
+
return new Promise((resolve15, reject) => {
|
|
34438
34438
|
stream[kConsume] = {
|
|
34439
34439
|
type,
|
|
34440
34440
|
stream,
|
|
34441
|
-
resolve:
|
|
34441
|
+
resolve: resolve15,
|
|
34442
34442
|
reject,
|
|
34443
34443
|
length: 0,
|
|
34444
34444
|
body: []
|
|
@@ -34473,12 +34473,12 @@ var require_readable = __commonJS({
|
|
|
34473
34473
|
}
|
|
34474
34474
|
}
|
|
34475
34475
|
function consumeEnd(consume2) {
|
|
34476
|
-
const { type, body, resolve:
|
|
34476
|
+
const { type, body, resolve: resolve15, stream, length } = consume2;
|
|
34477
34477
|
try {
|
|
34478
34478
|
if (type === "text") {
|
|
34479
|
-
|
|
34479
|
+
resolve15(toUSVString(Buffer.concat(body)));
|
|
34480
34480
|
} else if (type === "json") {
|
|
34481
|
-
|
|
34481
|
+
resolve15(JSON.parse(Buffer.concat(body)));
|
|
34482
34482
|
} else if (type === "arrayBuffer") {
|
|
34483
34483
|
const dst = new Uint8Array(length);
|
|
34484
34484
|
let pos = 0;
|
|
@@ -34486,12 +34486,12 @@ var require_readable = __commonJS({
|
|
|
34486
34486
|
dst.set(buf, pos);
|
|
34487
34487
|
pos += buf.byteLength;
|
|
34488
34488
|
}
|
|
34489
|
-
|
|
34489
|
+
resolve15(dst.buffer);
|
|
34490
34490
|
} else if (type === "blob") {
|
|
34491
34491
|
if (!Blob2) {
|
|
34492
34492
|
Blob2 = require("buffer").Blob;
|
|
34493
34493
|
}
|
|
34494
|
-
|
|
34494
|
+
resolve15(new Blob2(body, { type: stream[kContentType] }));
|
|
34495
34495
|
}
|
|
34496
34496
|
consumeFinish(consume2);
|
|
34497
34497
|
} catch (err) {
|
|
@@ -34748,9 +34748,9 @@ var require_api_request = __commonJS({
|
|
|
34748
34748
|
};
|
|
34749
34749
|
function request(opts, callback) {
|
|
34750
34750
|
if (callback === void 0) {
|
|
34751
|
-
return new Promise((
|
|
34751
|
+
return new Promise((resolve15, reject) => {
|
|
34752
34752
|
request.call(this, opts, (err, data) => {
|
|
34753
|
-
return err ? reject(err) :
|
|
34753
|
+
return err ? reject(err) : resolve15(data);
|
|
34754
34754
|
});
|
|
34755
34755
|
});
|
|
34756
34756
|
}
|
|
@@ -34923,9 +34923,9 @@ var require_api_stream = __commonJS({
|
|
|
34923
34923
|
};
|
|
34924
34924
|
function stream(opts, factory, callback) {
|
|
34925
34925
|
if (callback === void 0) {
|
|
34926
|
-
return new Promise((
|
|
34926
|
+
return new Promise((resolve15, reject) => {
|
|
34927
34927
|
stream.call(this, opts, factory, (err, data) => {
|
|
34928
|
-
return err ? reject(err) :
|
|
34928
|
+
return err ? reject(err) : resolve15(data);
|
|
34929
34929
|
});
|
|
34930
34930
|
});
|
|
34931
34931
|
}
|
|
@@ -35206,9 +35206,9 @@ var require_api_upgrade = __commonJS({
|
|
|
35206
35206
|
};
|
|
35207
35207
|
function upgrade(opts, callback) {
|
|
35208
35208
|
if (callback === void 0) {
|
|
35209
|
-
return new Promise((
|
|
35209
|
+
return new Promise((resolve15, reject) => {
|
|
35210
35210
|
upgrade.call(this, opts, (err, data) => {
|
|
35211
|
-
return err ? reject(err) :
|
|
35211
|
+
return err ? reject(err) : resolve15(data);
|
|
35212
35212
|
});
|
|
35213
35213
|
});
|
|
35214
35214
|
}
|
|
@@ -35297,9 +35297,9 @@ var require_api_connect = __commonJS({
|
|
|
35297
35297
|
};
|
|
35298
35298
|
function connect(opts, callback) {
|
|
35299
35299
|
if (callback === void 0) {
|
|
35300
|
-
return new Promise((
|
|
35300
|
+
return new Promise((resolve15, reject) => {
|
|
35301
35301
|
connect.call(this, opts, (err, data) => {
|
|
35302
|
-
return err ? reject(err) :
|
|
35302
|
+
return err ? reject(err) : resolve15(data);
|
|
35303
35303
|
});
|
|
35304
35304
|
});
|
|
35305
35305
|
}
|
|
@@ -35459,20 +35459,20 @@ var require_mock_utils = __commonJS({
|
|
|
35459
35459
|
}
|
|
35460
35460
|
return true;
|
|
35461
35461
|
}
|
|
35462
|
-
function safeUrl(
|
|
35463
|
-
if (typeof
|
|
35464
|
-
return
|
|
35462
|
+
function safeUrl(path30) {
|
|
35463
|
+
if (typeof path30 !== "string") {
|
|
35464
|
+
return path30;
|
|
35465
35465
|
}
|
|
35466
|
-
const pathSegments =
|
|
35466
|
+
const pathSegments = path30.split("?");
|
|
35467
35467
|
if (pathSegments.length !== 2) {
|
|
35468
|
-
return
|
|
35468
|
+
return path30;
|
|
35469
35469
|
}
|
|
35470
35470
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
35471
35471
|
qp.sort();
|
|
35472
35472
|
return [...pathSegments, qp.toString()].join("?");
|
|
35473
35473
|
}
|
|
35474
|
-
function matchKey(mockDispatch2, { path:
|
|
35475
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
35474
|
+
function matchKey(mockDispatch2, { path: path30, method, body, headers }) {
|
|
35475
|
+
const pathMatch = matchValue(mockDispatch2.path, path30);
|
|
35476
35476
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
35477
35477
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
35478
35478
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -35490,7 +35490,7 @@ var require_mock_utils = __commonJS({
|
|
|
35490
35490
|
function getMockDispatch(mockDispatches, key) {
|
|
35491
35491
|
const basePath = key.query ? buildURL(key.path, key.query) : key.path;
|
|
35492
35492
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
35493
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
35493
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path30 }) => matchValue(safeUrl(path30), resolvedPath));
|
|
35494
35494
|
if (matchedMockDispatches.length === 0) {
|
|
35495
35495
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
35496
35496
|
}
|
|
@@ -35527,9 +35527,9 @@ var require_mock_utils = __commonJS({
|
|
|
35527
35527
|
}
|
|
35528
35528
|
}
|
|
35529
35529
|
function buildKey(opts) {
|
|
35530
|
-
const { path:
|
|
35530
|
+
const { path: path30, method, body, headers, query } = opts;
|
|
35531
35531
|
return {
|
|
35532
|
-
path:
|
|
35532
|
+
path: path30,
|
|
35533
35533
|
method,
|
|
35534
35534
|
body,
|
|
35535
35535
|
headers,
|
|
@@ -35978,10 +35978,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
35978
35978
|
}
|
|
35979
35979
|
format(pendingInterceptors) {
|
|
35980
35980
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
35981
|
-
({ method, path:
|
|
35981
|
+
({ method, path: path30, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
35982
35982
|
Method: method,
|
|
35983
35983
|
Origin: origin,
|
|
35984
|
-
Path:
|
|
35984
|
+
Path: path30,
|
|
35985
35985
|
"Status code": statusCode,
|
|
35986
35986
|
Persistent: persist ? "\u2705" : "\u274C",
|
|
35987
35987
|
Invocations: timesInvoked,
|
|
@@ -38922,7 +38922,7 @@ var require_fetch = __commonJS({
|
|
|
38922
38922
|
async function dispatch({ body }) {
|
|
38923
38923
|
const url = requestCurrentURL(request);
|
|
38924
38924
|
const agent = fetchParams.controller.dispatcher;
|
|
38925
|
-
return new Promise((
|
|
38925
|
+
return new Promise((resolve15, reject) => agent.dispatch(
|
|
38926
38926
|
{
|
|
38927
38927
|
path: url.pathname + url.search,
|
|
38928
38928
|
origin: url.origin,
|
|
@@ -38998,7 +38998,7 @@ var require_fetch = __commonJS({
|
|
|
38998
38998
|
}
|
|
38999
38999
|
}
|
|
39000
39000
|
}
|
|
39001
|
-
|
|
39001
|
+
resolve15({
|
|
39002
39002
|
status,
|
|
39003
39003
|
statusText,
|
|
39004
39004
|
headersList: headers[kHeadersList],
|
|
@@ -39041,7 +39041,7 @@ var require_fetch = __commonJS({
|
|
|
39041
39041
|
const val = headersList[n + 1].toString("latin1");
|
|
39042
39042
|
headers[kHeadersList].append(key, val);
|
|
39043
39043
|
}
|
|
39044
|
-
|
|
39044
|
+
resolve15({
|
|
39045
39045
|
status,
|
|
39046
39046
|
statusText: STATUS_CODES[status],
|
|
39047
39047
|
headersList: headers[kHeadersList],
|
|
@@ -40602,8 +40602,8 @@ var require_util6 = __commonJS({
|
|
|
40602
40602
|
}
|
|
40603
40603
|
}
|
|
40604
40604
|
}
|
|
40605
|
-
function validateCookiePath(
|
|
40606
|
-
for (const char of
|
|
40605
|
+
function validateCookiePath(path30) {
|
|
40606
|
+
for (const char of path30) {
|
|
40607
40607
|
const code = char.charCodeAt(0);
|
|
40608
40608
|
if (code < 33 || char === ";") {
|
|
40609
40609
|
throw new Error("Invalid cookie path");
|
|
@@ -41400,9 +41400,9 @@ var require_connection = __commonJS({
|
|
|
41400
41400
|
channels.open = diagnosticsChannel.channel("undici:websocket:open");
|
|
41401
41401
|
channels.close = diagnosticsChannel.channel("undici:websocket:close");
|
|
41402
41402
|
channels.socketError = diagnosticsChannel.channel("undici:websocket:socket_error");
|
|
41403
|
-
var
|
|
41403
|
+
var crypto4;
|
|
41404
41404
|
try {
|
|
41405
|
-
|
|
41405
|
+
crypto4 = require("crypto");
|
|
41406
41406
|
} catch {
|
|
41407
41407
|
}
|
|
41408
41408
|
function establishWebSocketConnection(url, protocols, ws, onEstablish, options) {
|
|
@@ -41421,7 +41421,7 @@ var require_connection = __commonJS({
|
|
|
41421
41421
|
const headersList = new Headers(options.headers)[kHeadersList];
|
|
41422
41422
|
request.headersList = headersList;
|
|
41423
41423
|
}
|
|
41424
|
-
const keyValue =
|
|
41424
|
+
const keyValue = crypto4.randomBytes(16).toString("base64");
|
|
41425
41425
|
request.headersList.append("sec-websocket-key", keyValue);
|
|
41426
41426
|
request.headersList.append("sec-websocket-version", "13");
|
|
41427
41427
|
for (const protocol of protocols) {
|
|
@@ -41450,7 +41450,7 @@ var require_connection = __commonJS({
|
|
|
41450
41450
|
return;
|
|
41451
41451
|
}
|
|
41452
41452
|
const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
|
|
41453
|
-
const digest =
|
|
41453
|
+
const digest = crypto4.createHash("sha1").update(keyValue + uid).digest("base64");
|
|
41454
41454
|
if (secWSAccept !== digest) {
|
|
41455
41455
|
failWebsocketConnection(ws, "Incorrect hash received in Sec-WebSocket-Accept header.");
|
|
41456
41456
|
return;
|
|
@@ -41530,9 +41530,9 @@ var require_frame = __commonJS({
|
|
|
41530
41530
|
"node_modules/undici/lib/websocket/frame.js"(exports2, module2) {
|
|
41531
41531
|
"use strict";
|
|
41532
41532
|
var { maxUnsigned16Bit } = require_constants5();
|
|
41533
|
-
var
|
|
41533
|
+
var crypto4;
|
|
41534
41534
|
try {
|
|
41535
|
-
|
|
41535
|
+
crypto4 = require("crypto");
|
|
41536
41536
|
} catch {
|
|
41537
41537
|
}
|
|
41538
41538
|
var WebsocketFrameSend = class {
|
|
@@ -41541,7 +41541,7 @@ var require_frame = __commonJS({
|
|
|
41541
41541
|
*/
|
|
41542
41542
|
constructor(data) {
|
|
41543
41543
|
this.frameData = data;
|
|
41544
|
-
this.maskKey =
|
|
41544
|
+
this.maskKey = crypto4.randomBytes(4);
|
|
41545
41545
|
}
|
|
41546
41546
|
createFrame(opcode) {
|
|
41547
41547
|
const bodyLength = this.frameData?.byteLength ?? 0;
|
|
@@ -42283,11 +42283,11 @@ var require_undici = __commonJS({
|
|
|
42283
42283
|
if (typeof opts.path !== "string") {
|
|
42284
42284
|
throw new InvalidArgumentError("invalid opts.path");
|
|
42285
42285
|
}
|
|
42286
|
-
let
|
|
42286
|
+
let path30 = opts.path;
|
|
42287
42287
|
if (!opts.path.startsWith("/")) {
|
|
42288
|
-
|
|
42288
|
+
path30 = `/${path30}`;
|
|
42289
42289
|
}
|
|
42290
|
-
url = new URL(util.parseOrigin(url).origin +
|
|
42290
|
+
url = new URL(util.parseOrigin(url).origin + path30);
|
|
42291
42291
|
} else {
|
|
42292
42292
|
if (!opts) {
|
|
42293
42293
|
opts = typeof url === "object" ? url : {};
|
|
@@ -42835,7 +42835,7 @@ var init_mcp_check_provider = __esm({
|
|
|
42835
42835
|
logger.warn(
|
|
42836
42836
|
`MCP ${transportName} failed (attempt ${attempt + 1}/${maxRetries + 1}), retrying in ${delay}ms: ${error instanceof Error ? error.message : String(error)}`
|
|
42837
42837
|
);
|
|
42838
|
-
await new Promise((
|
|
42838
|
+
await new Promise((resolve15) => setTimeout(resolve15, delay));
|
|
42839
42839
|
attempt += 1;
|
|
42840
42840
|
} finally {
|
|
42841
42841
|
try {
|
|
@@ -43117,7 +43117,7 @@ async function acquirePromptLock() {
|
|
|
43117
43117
|
activePrompt = true;
|
|
43118
43118
|
return;
|
|
43119
43119
|
}
|
|
43120
|
-
await new Promise((
|
|
43120
|
+
await new Promise((resolve15) => waiters.push(resolve15));
|
|
43121
43121
|
activePrompt = true;
|
|
43122
43122
|
}
|
|
43123
43123
|
function releasePromptLock() {
|
|
@@ -43127,7 +43127,7 @@ function releasePromptLock() {
|
|
|
43127
43127
|
}
|
|
43128
43128
|
async function interactivePrompt(options) {
|
|
43129
43129
|
await acquirePromptLock();
|
|
43130
|
-
return new Promise((
|
|
43130
|
+
return new Promise((resolve15, reject) => {
|
|
43131
43131
|
const dbg = process.env.VISOR_DEBUG === "true";
|
|
43132
43132
|
try {
|
|
43133
43133
|
if (dbg) {
|
|
@@ -43214,12 +43214,12 @@ async function interactivePrompt(options) {
|
|
|
43214
43214
|
};
|
|
43215
43215
|
const finish = (value) => {
|
|
43216
43216
|
cleanup();
|
|
43217
|
-
|
|
43217
|
+
resolve15(value);
|
|
43218
43218
|
};
|
|
43219
43219
|
if (options.timeout && options.timeout > 0) {
|
|
43220
43220
|
timeoutId = setTimeout(() => {
|
|
43221
43221
|
cleanup();
|
|
43222
|
-
if (defaultValue !== void 0) return
|
|
43222
|
+
if (defaultValue !== void 0) return resolve15(defaultValue);
|
|
43223
43223
|
return reject(new Error("Input timeout"));
|
|
43224
43224
|
}, options.timeout);
|
|
43225
43225
|
}
|
|
@@ -43351,7 +43351,7 @@ async function interactivePrompt(options) {
|
|
|
43351
43351
|
});
|
|
43352
43352
|
}
|
|
43353
43353
|
async function simplePrompt(prompt) {
|
|
43354
|
-
return new Promise((
|
|
43354
|
+
return new Promise((resolve15) => {
|
|
43355
43355
|
const rl = readline.createInterface({
|
|
43356
43356
|
input: process.stdin,
|
|
43357
43357
|
output: process.stdout
|
|
@@ -43367,7 +43367,7 @@ async function simplePrompt(prompt) {
|
|
|
43367
43367
|
rl.question(`${prompt}
|
|
43368
43368
|
> `, (answer) => {
|
|
43369
43369
|
rl.close();
|
|
43370
|
-
|
|
43370
|
+
resolve15(answer.trim());
|
|
43371
43371
|
});
|
|
43372
43372
|
});
|
|
43373
43373
|
}
|
|
@@ -43535,7 +43535,7 @@ function isStdinAvailable() {
|
|
|
43535
43535
|
return !process.stdin.isTTY;
|
|
43536
43536
|
}
|
|
43537
43537
|
async function readStdin(timeout, maxSize = 1024 * 1024) {
|
|
43538
|
-
return new Promise((
|
|
43538
|
+
return new Promise((resolve15, reject) => {
|
|
43539
43539
|
let data = "";
|
|
43540
43540
|
let timeoutId;
|
|
43541
43541
|
if (timeout) {
|
|
@@ -43562,7 +43562,7 @@ async function readStdin(timeout, maxSize = 1024 * 1024) {
|
|
|
43562
43562
|
};
|
|
43563
43563
|
const onEnd = () => {
|
|
43564
43564
|
cleanup();
|
|
43565
|
-
|
|
43565
|
+
resolve15(data.trim());
|
|
43566
43566
|
};
|
|
43567
43567
|
const onError = (err) => {
|
|
43568
43568
|
cleanup();
|
|
@@ -47594,23 +47594,23 @@ __export(renderer_schema_exports, {
|
|
|
47594
47594
|
});
|
|
47595
47595
|
async function loadRendererSchema(name) {
|
|
47596
47596
|
try {
|
|
47597
|
-
const
|
|
47598
|
-
const
|
|
47597
|
+
const fs26 = await import("fs/promises");
|
|
47598
|
+
const path30 = await import("path");
|
|
47599
47599
|
const sanitized = String(name).replace(/[^a-zA-Z0-9-]/g, "");
|
|
47600
47600
|
if (!sanitized) return void 0;
|
|
47601
47601
|
const candidates = [
|
|
47602
47602
|
// When bundled with ncc, __dirname is dist/ and output/ is at dist/output/
|
|
47603
|
-
|
|
47603
|
+
path30.join(__dirname, "output", sanitized, "schema.json"),
|
|
47604
47604
|
// When running from source, __dirname is src/state-machine/dispatch/ and output/ is at output/
|
|
47605
|
-
|
|
47605
|
+
path30.join(__dirname, "..", "..", "output", sanitized, "schema.json"),
|
|
47606
47606
|
// When running from a checkout with output/ folder copied to CWD
|
|
47607
|
-
|
|
47607
|
+
path30.join(process.cwd(), "output", sanitized, "schema.json"),
|
|
47608
47608
|
// Fallback: cwd/dist/output/
|
|
47609
|
-
|
|
47609
|
+
path30.join(process.cwd(), "dist", "output", sanitized, "schema.json")
|
|
47610
47610
|
];
|
|
47611
47611
|
for (const p of candidates) {
|
|
47612
47612
|
try {
|
|
47613
|
-
const raw = await
|
|
47613
|
+
const raw = await fs26.readFile(p, "utf-8");
|
|
47614
47614
|
return JSON.parse(raw);
|
|
47615
47615
|
} catch {
|
|
47616
47616
|
}
|
|
@@ -50029,8 +50029,8 @@ function updateStats2(results, state, isForEachIteration = false) {
|
|
|
50029
50029
|
async function renderTemplateContent2(checkId, checkConfig, reviewSummary) {
|
|
50030
50030
|
try {
|
|
50031
50031
|
const { createExtendedLiquid: createExtendedLiquid2 } = await Promise.resolve().then(() => (init_liquid_extensions(), liquid_extensions_exports));
|
|
50032
|
-
const
|
|
50033
|
-
const
|
|
50032
|
+
const fs26 = await import("fs/promises");
|
|
50033
|
+
const path30 = await import("path");
|
|
50034
50034
|
const schemaRaw = checkConfig.schema || "plain";
|
|
50035
50035
|
const schema = typeof schemaRaw === "string" && !schemaRaw.includes("{{") && !schemaRaw.includes("{%") ? schemaRaw : typeof schemaRaw === "object" ? "code-review" : "plain";
|
|
50036
50036
|
let templateContent;
|
|
@@ -50039,27 +50039,27 @@ async function renderTemplateContent2(checkId, checkConfig, reviewSummary) {
|
|
|
50039
50039
|
logger.debug(`[LevelDispatch] Using inline template for ${checkId}`);
|
|
50040
50040
|
} else if (checkConfig.template && checkConfig.template.file) {
|
|
50041
50041
|
const file = String(checkConfig.template.file);
|
|
50042
|
-
const resolved =
|
|
50043
|
-
templateContent = await
|
|
50042
|
+
const resolved = path30.resolve(process.cwd(), file);
|
|
50043
|
+
templateContent = await fs26.readFile(resolved, "utf-8");
|
|
50044
50044
|
logger.debug(`[LevelDispatch] Using template file for ${checkId}: ${resolved}`);
|
|
50045
50045
|
} else if (schema && schema !== "plain") {
|
|
50046
50046
|
const sanitized = String(schema).replace(/[^a-zA-Z0-9-]/g, "");
|
|
50047
50047
|
if (sanitized) {
|
|
50048
50048
|
const candidatePaths = [
|
|
50049
|
-
|
|
50049
|
+
path30.join(__dirname, "output", sanitized, "template.liquid"),
|
|
50050
50050
|
// bundled: dist/output/
|
|
50051
|
-
|
|
50051
|
+
path30.join(__dirname, "..", "..", "output", sanitized, "template.liquid"),
|
|
50052
50052
|
// source (from state-machine/states)
|
|
50053
|
-
|
|
50053
|
+
path30.join(__dirname, "..", "..", "..", "output", sanitized, "template.liquid"),
|
|
50054
50054
|
// source (alternate)
|
|
50055
|
-
|
|
50055
|
+
path30.join(process.cwd(), "output", sanitized, "template.liquid"),
|
|
50056
50056
|
// fallback: cwd/output/
|
|
50057
|
-
|
|
50057
|
+
path30.join(process.cwd(), "dist", "output", sanitized, "template.liquid")
|
|
50058
50058
|
// fallback: cwd/dist/output/
|
|
50059
50059
|
];
|
|
50060
50060
|
for (const p of candidatePaths) {
|
|
50061
50061
|
try {
|
|
50062
|
-
templateContent = await
|
|
50062
|
+
templateContent = await fs26.readFile(p, "utf-8");
|
|
50063
50063
|
if (templateContent) {
|
|
50064
50064
|
logger.debug(`[LevelDispatch] Using schema template for ${checkId}: ${p}`);
|
|
50065
50065
|
break;
|
|
@@ -51860,8 +51860,8 @@ var init_workspace_manager = __esm({
|
|
|
51860
51860
|
);
|
|
51861
51861
|
if (this.cleanupRequested && this.activeOperations === 0) {
|
|
51862
51862
|
logger.debug(`[Workspace] All references released, proceeding with deferred cleanup`);
|
|
51863
|
-
for (const
|
|
51864
|
-
|
|
51863
|
+
for (const resolve15 of this.cleanupResolvers) {
|
|
51864
|
+
resolve15();
|
|
51865
51865
|
}
|
|
51866
51866
|
this.cleanupResolvers = [];
|
|
51867
51867
|
}
|
|
@@ -51986,19 +51986,19 @@ var init_workspace_manager = __esm({
|
|
|
51986
51986
|
);
|
|
51987
51987
|
this.cleanupRequested = true;
|
|
51988
51988
|
await Promise.race([
|
|
51989
|
-
new Promise((
|
|
51989
|
+
new Promise((resolve15) => {
|
|
51990
51990
|
if (this.activeOperations === 0) {
|
|
51991
|
-
|
|
51991
|
+
resolve15();
|
|
51992
51992
|
} else {
|
|
51993
|
-
this.cleanupResolvers.push(
|
|
51993
|
+
this.cleanupResolvers.push(resolve15);
|
|
51994
51994
|
}
|
|
51995
51995
|
}),
|
|
51996
|
-
new Promise((
|
|
51996
|
+
new Promise((resolve15) => {
|
|
51997
51997
|
setTimeout(() => {
|
|
51998
51998
|
logger.warn(
|
|
51999
51999
|
`[Workspace] Cleanup timeout after ${timeout}ms, proceeding anyway (${this.activeOperations} operations still active)`
|
|
52000
52000
|
);
|
|
52001
|
-
|
|
52001
|
+
resolve15();
|
|
52002
52002
|
}, timeout);
|
|
52003
52003
|
})
|
|
52004
52004
|
]);
|
|
@@ -52277,6 +52277,1264 @@ var init_build_engine_context = __esm({
|
|
|
52277
52277
|
}
|
|
52278
52278
|
});
|
|
52279
52279
|
|
|
52280
|
+
// src/policy/default-engine.ts
|
|
52281
|
+
var DefaultPolicyEngine;
|
|
52282
|
+
var init_default_engine = __esm({
|
|
52283
|
+
"src/policy/default-engine.ts"() {
|
|
52284
|
+
"use strict";
|
|
52285
|
+
DefaultPolicyEngine = class {
|
|
52286
|
+
async initialize(_config) {
|
|
52287
|
+
}
|
|
52288
|
+
async evaluateCheckExecution(_checkId, _checkConfig) {
|
|
52289
|
+
return { allowed: true };
|
|
52290
|
+
}
|
|
52291
|
+
async evaluateToolInvocation(_serverName, _methodName, _transport) {
|
|
52292
|
+
return { allowed: true };
|
|
52293
|
+
}
|
|
52294
|
+
async evaluateCapabilities(_checkId, _capabilities) {
|
|
52295
|
+
return { allowed: true };
|
|
52296
|
+
}
|
|
52297
|
+
async shutdown() {
|
|
52298
|
+
}
|
|
52299
|
+
};
|
|
52300
|
+
}
|
|
52301
|
+
});
|
|
52302
|
+
|
|
52303
|
+
// src/enterprise/license/validator.ts
|
|
52304
|
+
var validator_exports = {};
|
|
52305
|
+
__export(validator_exports, {
|
|
52306
|
+
LicenseValidator: () => LicenseValidator
|
|
52307
|
+
});
|
|
52308
|
+
var crypto2, fs20, path24, LicenseValidator;
|
|
52309
|
+
var init_validator = __esm({
|
|
52310
|
+
"src/enterprise/license/validator.ts"() {
|
|
52311
|
+
"use strict";
|
|
52312
|
+
crypto2 = __toESM(require("crypto"));
|
|
52313
|
+
fs20 = __toESM(require("fs"));
|
|
52314
|
+
path24 = __toESM(require("path"));
|
|
52315
|
+
LicenseValidator = class _LicenseValidator {
|
|
52316
|
+
/** Ed25519 public key for license verification (PEM format). */
|
|
52317
|
+
static PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAI/Zd08EFmgIdrDm/HXd0l3/5GBt7R1PrdvhdmEXhJlU=\n-----END PUBLIC KEY-----\n";
|
|
52318
|
+
cache = null;
|
|
52319
|
+
static CACHE_TTL = 5 * 60 * 1e3;
|
|
52320
|
+
// 5 minutes
|
|
52321
|
+
static GRACE_PERIOD = 72 * 3600 * 1e3;
|
|
52322
|
+
// 72 hours after expiry
|
|
52323
|
+
/**
|
|
52324
|
+
* Load and validate license from environment or file.
|
|
52325
|
+
*
|
|
52326
|
+
* Resolution order:
|
|
52327
|
+
* 1. VISOR_LICENSE env var (JWT string)
|
|
52328
|
+
* 2. VISOR_LICENSE_FILE env var (path to file)
|
|
52329
|
+
* 3. .visor-license in project root (cwd)
|
|
52330
|
+
* 4. .visor-license in ~/.config/visor/
|
|
52331
|
+
*/
|
|
52332
|
+
async loadAndValidate() {
|
|
52333
|
+
if (this.cache && Date.now() - this.cache.validatedAt < _LicenseValidator.CACHE_TTL) {
|
|
52334
|
+
return this.cache.payload;
|
|
52335
|
+
}
|
|
52336
|
+
const token = this.resolveToken();
|
|
52337
|
+
if (!token) return null;
|
|
52338
|
+
const payload = this.verifyAndDecode(token);
|
|
52339
|
+
if (!payload) return null;
|
|
52340
|
+
this.cache = { payload, validatedAt: Date.now() };
|
|
52341
|
+
return payload;
|
|
52342
|
+
}
|
|
52343
|
+
/** Check if a specific feature is licensed */
|
|
52344
|
+
hasFeature(feature) {
|
|
52345
|
+
if (!this.cache) return false;
|
|
52346
|
+
return this.cache.payload.features.includes(feature);
|
|
52347
|
+
}
|
|
52348
|
+
/** Check if license is valid (with grace period) */
|
|
52349
|
+
isValid() {
|
|
52350
|
+
if (!this.cache) return false;
|
|
52351
|
+
const now = Date.now();
|
|
52352
|
+
const expiryMs = this.cache.payload.exp * 1e3;
|
|
52353
|
+
return now < expiryMs + _LicenseValidator.GRACE_PERIOD;
|
|
52354
|
+
}
|
|
52355
|
+
/** Check if the license is within its grace period (expired but still valid) */
|
|
52356
|
+
isInGracePeriod() {
|
|
52357
|
+
if (!this.cache) return false;
|
|
52358
|
+
const now = Date.now();
|
|
52359
|
+
const expiryMs = this.cache.payload.exp * 1e3;
|
|
52360
|
+
return now >= expiryMs && now < expiryMs + _LicenseValidator.GRACE_PERIOD;
|
|
52361
|
+
}
|
|
52362
|
+
resolveToken() {
|
|
52363
|
+
if (process.env.VISOR_LICENSE) {
|
|
52364
|
+
return process.env.VISOR_LICENSE.trim();
|
|
52365
|
+
}
|
|
52366
|
+
if (process.env.VISOR_LICENSE_FILE) {
|
|
52367
|
+
const resolved = path24.resolve(process.env.VISOR_LICENSE_FILE);
|
|
52368
|
+
const home2 = process.env.HOME || process.env.USERPROFILE || "";
|
|
52369
|
+
const allowedPrefixes = [path24.normalize(process.cwd())];
|
|
52370
|
+
if (home2) allowedPrefixes.push(path24.normalize(path24.join(home2, ".config", "visor")));
|
|
52371
|
+
let realPath;
|
|
52372
|
+
try {
|
|
52373
|
+
realPath = fs20.realpathSync(resolved);
|
|
52374
|
+
} catch {
|
|
52375
|
+
return null;
|
|
52376
|
+
}
|
|
52377
|
+
const isSafe = allowedPrefixes.some(
|
|
52378
|
+
(prefix) => realPath === prefix || realPath.startsWith(prefix + path24.sep)
|
|
52379
|
+
);
|
|
52380
|
+
if (!isSafe) return null;
|
|
52381
|
+
return this.readFile(realPath);
|
|
52382
|
+
}
|
|
52383
|
+
const cwdPath = path24.join(process.cwd(), ".visor-license");
|
|
52384
|
+
const cwdToken = this.readFile(cwdPath);
|
|
52385
|
+
if (cwdToken) return cwdToken;
|
|
52386
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
52387
|
+
if (home) {
|
|
52388
|
+
const configPath = path24.join(home, ".config", "visor", ".visor-license");
|
|
52389
|
+
const configToken = this.readFile(configPath);
|
|
52390
|
+
if (configToken) return configToken;
|
|
52391
|
+
}
|
|
52392
|
+
return null;
|
|
52393
|
+
}
|
|
52394
|
+
readFile(filePath) {
|
|
52395
|
+
try {
|
|
52396
|
+
return fs20.readFileSync(filePath, "utf-8").trim();
|
|
52397
|
+
} catch {
|
|
52398
|
+
return null;
|
|
52399
|
+
}
|
|
52400
|
+
}
|
|
52401
|
+
verifyAndDecode(token) {
|
|
52402
|
+
try {
|
|
52403
|
+
const parts = token.split(".");
|
|
52404
|
+
if (parts.length !== 3) return null;
|
|
52405
|
+
const [headerB64, payloadB64, signatureB64] = parts;
|
|
52406
|
+
const header = JSON.parse(Buffer.from(headerB64, "base64url").toString());
|
|
52407
|
+
if (header.alg !== "EdDSA") return null;
|
|
52408
|
+
const data = `${headerB64}.${payloadB64}`;
|
|
52409
|
+
const signature = Buffer.from(signatureB64, "base64url");
|
|
52410
|
+
const publicKey = crypto2.createPublicKey(_LicenseValidator.PUBLIC_KEY);
|
|
52411
|
+
if (publicKey.asymmetricKeyType !== "ed25519") {
|
|
52412
|
+
return null;
|
|
52413
|
+
}
|
|
52414
|
+
const isValid = crypto2.verify(null, Buffer.from(data), publicKey, signature);
|
|
52415
|
+
if (!isValid) return null;
|
|
52416
|
+
const payload = JSON.parse(Buffer.from(payloadB64, "base64url").toString());
|
|
52417
|
+
if (!payload.org || !Array.isArray(payload.features) || typeof payload.exp !== "number" || typeof payload.iat !== "number" || !payload.sub) {
|
|
52418
|
+
return null;
|
|
52419
|
+
}
|
|
52420
|
+
const now = Date.now();
|
|
52421
|
+
const expiryMs = payload.exp * 1e3;
|
|
52422
|
+
if (now >= expiryMs + _LicenseValidator.GRACE_PERIOD) {
|
|
52423
|
+
return null;
|
|
52424
|
+
}
|
|
52425
|
+
return payload;
|
|
52426
|
+
} catch {
|
|
52427
|
+
return null;
|
|
52428
|
+
}
|
|
52429
|
+
}
|
|
52430
|
+
};
|
|
52431
|
+
}
|
|
52432
|
+
});
|
|
52433
|
+
|
|
52434
|
+
// src/enterprise/policy/opa-compiler.ts
|
|
52435
|
+
var fs21, path25, os2, crypto3, import_child_process6, OpaCompiler;
|
|
52436
|
+
var init_opa_compiler = __esm({
|
|
52437
|
+
"src/enterprise/policy/opa-compiler.ts"() {
|
|
52438
|
+
"use strict";
|
|
52439
|
+
fs21 = __toESM(require("fs"));
|
|
52440
|
+
path25 = __toESM(require("path"));
|
|
52441
|
+
os2 = __toESM(require("os"));
|
|
52442
|
+
crypto3 = __toESM(require("crypto"));
|
|
52443
|
+
import_child_process6 = require("child_process");
|
|
52444
|
+
OpaCompiler = class _OpaCompiler {
|
|
52445
|
+
static CACHE_DIR = path25.join(os2.tmpdir(), "visor-opa-cache");
|
|
52446
|
+
/**
|
|
52447
|
+
* Resolve the input paths to WASM bytes.
|
|
52448
|
+
*
|
|
52449
|
+
* Strategy:
|
|
52450
|
+
* 1. If any path is a .wasm file, read it directly
|
|
52451
|
+
* 2. If a directory contains policy.wasm, read it
|
|
52452
|
+
* 3. Otherwise, collect all .rego files and auto-compile via `opa build`
|
|
52453
|
+
*/
|
|
52454
|
+
async resolveWasmBytes(paths) {
|
|
52455
|
+
const regoFiles = [];
|
|
52456
|
+
for (const p of paths) {
|
|
52457
|
+
const resolved = path25.resolve(p);
|
|
52458
|
+
if (path25.normalize(resolved).includes("..")) {
|
|
52459
|
+
throw new Error(`Policy path contains traversal sequences: ${p}`);
|
|
52460
|
+
}
|
|
52461
|
+
if (resolved.endsWith(".wasm") && fs21.existsSync(resolved)) {
|
|
52462
|
+
return fs21.readFileSync(resolved);
|
|
52463
|
+
}
|
|
52464
|
+
if (!fs21.existsSync(resolved)) continue;
|
|
52465
|
+
const stat = fs21.statSync(resolved);
|
|
52466
|
+
if (stat.isDirectory()) {
|
|
52467
|
+
const wasmCandidate = path25.join(resolved, "policy.wasm");
|
|
52468
|
+
if (fs21.existsSync(wasmCandidate)) {
|
|
52469
|
+
return fs21.readFileSync(wasmCandidate);
|
|
52470
|
+
}
|
|
52471
|
+
const files = fs21.readdirSync(resolved);
|
|
52472
|
+
for (const f of files) {
|
|
52473
|
+
if (f.endsWith(".rego")) {
|
|
52474
|
+
regoFiles.push(path25.join(resolved, f));
|
|
52475
|
+
}
|
|
52476
|
+
}
|
|
52477
|
+
} else if (resolved.endsWith(".rego")) {
|
|
52478
|
+
regoFiles.push(resolved);
|
|
52479
|
+
}
|
|
52480
|
+
}
|
|
52481
|
+
if (regoFiles.length === 0) {
|
|
52482
|
+
throw new Error(
|
|
52483
|
+
`OPA WASM evaluator: no .wasm bundle or .rego files found in: ${paths.join(", ")}`
|
|
52484
|
+
);
|
|
52485
|
+
}
|
|
52486
|
+
return this.compileRego(regoFiles);
|
|
52487
|
+
}
|
|
52488
|
+
/**
|
|
52489
|
+
* Auto-compile .rego files to a WASM bundle using the `opa` CLI.
|
|
52490
|
+
*
|
|
52491
|
+
* Caches the compiled bundle based on a content hash of all input .rego files
|
|
52492
|
+
* so subsequent runs skip compilation if policies haven't changed.
|
|
52493
|
+
*/
|
|
52494
|
+
compileRego(regoFiles) {
|
|
52495
|
+
try {
|
|
52496
|
+
(0, import_child_process6.execFileSync)("opa", ["version"], { stdio: "pipe" });
|
|
52497
|
+
} catch {
|
|
52498
|
+
throw new Error(
|
|
52499
|
+
"OPA CLI (`opa`) not found on PATH. Install it from https://www.openpolicyagent.org/docs/latest/#running-opa\nOr pre-compile your .rego files: opa build -t wasm -e visor -o bundle.tar.gz " + regoFiles.join(" ")
|
|
52500
|
+
);
|
|
52501
|
+
}
|
|
52502
|
+
const hash = crypto3.createHash("sha256");
|
|
52503
|
+
for (const f of regoFiles.sort()) {
|
|
52504
|
+
hash.update(fs21.readFileSync(f));
|
|
52505
|
+
hash.update(f);
|
|
52506
|
+
}
|
|
52507
|
+
const cacheKey = hash.digest("hex").slice(0, 16);
|
|
52508
|
+
const cacheDir = _OpaCompiler.CACHE_DIR;
|
|
52509
|
+
const cachedWasm = path25.join(cacheDir, `${cacheKey}.wasm`);
|
|
52510
|
+
if (fs21.existsSync(cachedWasm)) {
|
|
52511
|
+
return fs21.readFileSync(cachedWasm);
|
|
52512
|
+
}
|
|
52513
|
+
fs21.mkdirSync(cacheDir, { recursive: true });
|
|
52514
|
+
const bundleTar = path25.join(cacheDir, `${cacheKey}-bundle.tar.gz`);
|
|
52515
|
+
try {
|
|
52516
|
+
const args = [
|
|
52517
|
+
"build",
|
|
52518
|
+
"-t",
|
|
52519
|
+
"wasm",
|
|
52520
|
+
"-e",
|
|
52521
|
+
"visor",
|
|
52522
|
+
// entrypoint: the visor package tree
|
|
52523
|
+
"-o",
|
|
52524
|
+
bundleTar,
|
|
52525
|
+
...regoFiles
|
|
52526
|
+
];
|
|
52527
|
+
(0, import_child_process6.execFileSync)("opa", args, {
|
|
52528
|
+
stdio: "pipe",
|
|
52529
|
+
timeout: 3e4
|
|
52530
|
+
});
|
|
52531
|
+
} catch (err) {
|
|
52532
|
+
const stderr = err?.stderr?.toString() || "";
|
|
52533
|
+
throw new Error(
|
|
52534
|
+
`Failed to compile .rego files to WASM:
|
|
52535
|
+
${stderr}
|
|
52536
|
+
Ensure your .rego files are valid and the \`opa\` CLI is installed.`
|
|
52537
|
+
);
|
|
52538
|
+
}
|
|
52539
|
+
try {
|
|
52540
|
+
(0, import_child_process6.execFileSync)("tar", ["-xzf", bundleTar, "-C", cacheDir, "/policy.wasm"], {
|
|
52541
|
+
stdio: "pipe"
|
|
52542
|
+
});
|
|
52543
|
+
const extractedWasm = path25.join(cacheDir, "policy.wasm");
|
|
52544
|
+
if (fs21.existsSync(extractedWasm)) {
|
|
52545
|
+
fs21.renameSync(extractedWasm, cachedWasm);
|
|
52546
|
+
}
|
|
52547
|
+
} catch {
|
|
52548
|
+
try {
|
|
52549
|
+
(0, import_child_process6.execFileSync)("tar", ["-xzf", bundleTar, "-C", cacheDir, "policy.wasm"], {
|
|
52550
|
+
stdio: "pipe"
|
|
52551
|
+
});
|
|
52552
|
+
const extractedWasm = path25.join(cacheDir, "policy.wasm");
|
|
52553
|
+
if (fs21.existsSync(extractedWasm)) {
|
|
52554
|
+
fs21.renameSync(extractedWasm, cachedWasm);
|
|
52555
|
+
}
|
|
52556
|
+
} catch (err2) {
|
|
52557
|
+
throw new Error(`Failed to extract policy.wasm from OPA bundle: ${err2?.message || err2}`);
|
|
52558
|
+
}
|
|
52559
|
+
}
|
|
52560
|
+
try {
|
|
52561
|
+
fs21.unlinkSync(bundleTar);
|
|
52562
|
+
} catch {
|
|
52563
|
+
}
|
|
52564
|
+
if (!fs21.existsSync(cachedWasm)) {
|
|
52565
|
+
throw new Error("OPA build succeeded but policy.wasm was not found in the bundle");
|
|
52566
|
+
}
|
|
52567
|
+
return fs21.readFileSync(cachedWasm);
|
|
52568
|
+
}
|
|
52569
|
+
};
|
|
52570
|
+
}
|
|
52571
|
+
});
|
|
52572
|
+
|
|
52573
|
+
// src/enterprise/policy/opa-wasm-evaluator.ts
|
|
52574
|
+
var fs22, path26, OpaWasmEvaluator;
|
|
52575
|
+
var init_opa_wasm_evaluator = __esm({
|
|
52576
|
+
"src/enterprise/policy/opa-wasm-evaluator.ts"() {
|
|
52577
|
+
"use strict";
|
|
52578
|
+
fs22 = __toESM(require("fs"));
|
|
52579
|
+
path26 = __toESM(require("path"));
|
|
52580
|
+
init_opa_compiler();
|
|
52581
|
+
OpaWasmEvaluator = class {
|
|
52582
|
+
policy = null;
|
|
52583
|
+
dataDocument = {};
|
|
52584
|
+
compiler = new OpaCompiler();
|
|
52585
|
+
async initialize(rulesPath) {
|
|
52586
|
+
const paths = Array.isArray(rulesPath) ? rulesPath : [rulesPath];
|
|
52587
|
+
const wasmBytes = await this.compiler.resolveWasmBytes(paths);
|
|
52588
|
+
try {
|
|
52589
|
+
const { createRequire } = require("module");
|
|
52590
|
+
const runtimeRequire = createRequire(__filename);
|
|
52591
|
+
const opaWasm = runtimeRequire("@open-policy-agent/opa-wasm");
|
|
52592
|
+
const loadPolicy = opaWasm.loadPolicy || opaWasm.default?.loadPolicy;
|
|
52593
|
+
if (!loadPolicy) {
|
|
52594
|
+
throw new Error("loadPolicy not found in @open-policy-agent/opa-wasm");
|
|
52595
|
+
}
|
|
52596
|
+
this.policy = await loadPolicy(wasmBytes);
|
|
52597
|
+
} catch (err) {
|
|
52598
|
+
if (err?.code === "MODULE_NOT_FOUND" || err?.code === "ERR_MODULE_NOT_FOUND") {
|
|
52599
|
+
throw new Error(
|
|
52600
|
+
"OPA WASM evaluator requires @open-policy-agent/opa-wasm. Install it with: npm install @open-policy-agent/opa-wasm"
|
|
52601
|
+
);
|
|
52602
|
+
}
|
|
52603
|
+
throw err;
|
|
52604
|
+
}
|
|
52605
|
+
}
|
|
52606
|
+
/**
|
|
52607
|
+
* Load external data from a JSON file to use as the OPA data document.
|
|
52608
|
+
* The loaded data will be passed to `policy.setData()` during evaluation,
|
|
52609
|
+
* making it available in Rego via `data.<key>`.
|
|
52610
|
+
*/
|
|
52611
|
+
loadData(dataPath) {
|
|
52612
|
+
const resolved = path26.resolve(dataPath);
|
|
52613
|
+
if (path26.normalize(resolved).includes("..")) {
|
|
52614
|
+
throw new Error(`Data path contains traversal sequences: ${dataPath}`);
|
|
52615
|
+
}
|
|
52616
|
+
if (!fs22.existsSync(resolved)) {
|
|
52617
|
+
throw new Error(`OPA data file not found: ${resolved}`);
|
|
52618
|
+
}
|
|
52619
|
+
const stat = fs22.statSync(resolved);
|
|
52620
|
+
if (stat.size > 10 * 1024 * 1024) {
|
|
52621
|
+
throw new Error(`OPA data file exceeds 10MB limit: ${resolved} (${stat.size} bytes)`);
|
|
52622
|
+
}
|
|
52623
|
+
const raw = fs22.readFileSync(resolved, "utf-8");
|
|
52624
|
+
try {
|
|
52625
|
+
const parsed = JSON.parse(raw);
|
|
52626
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
52627
|
+
throw new Error("OPA data file must contain a JSON object (not an array or primitive)");
|
|
52628
|
+
}
|
|
52629
|
+
this.dataDocument = parsed;
|
|
52630
|
+
} catch (err) {
|
|
52631
|
+
if (err.message.startsWith("OPA data file must")) {
|
|
52632
|
+
throw err;
|
|
52633
|
+
}
|
|
52634
|
+
throw new Error(`Failed to parse OPA data file ${resolved}: ${err.message}`);
|
|
52635
|
+
}
|
|
52636
|
+
}
|
|
52637
|
+
async evaluate(input) {
|
|
52638
|
+
if (!this.policy) {
|
|
52639
|
+
throw new Error("OPA WASM evaluator not initialized");
|
|
52640
|
+
}
|
|
52641
|
+
this.policy.setData(this.dataDocument);
|
|
52642
|
+
const resultSet = this.policy.evaluate(input);
|
|
52643
|
+
if (Array.isArray(resultSet) && resultSet.length > 0) {
|
|
52644
|
+
return resultSet[0].result;
|
|
52645
|
+
}
|
|
52646
|
+
return void 0;
|
|
52647
|
+
}
|
|
52648
|
+
async shutdown() {
|
|
52649
|
+
if (this.policy) {
|
|
52650
|
+
if (typeof this.policy.close === "function") {
|
|
52651
|
+
try {
|
|
52652
|
+
this.policy.close();
|
|
52653
|
+
} catch {
|
|
52654
|
+
}
|
|
52655
|
+
} else if (typeof this.policy.free === "function") {
|
|
52656
|
+
try {
|
|
52657
|
+
this.policy.free();
|
|
52658
|
+
} catch {
|
|
52659
|
+
}
|
|
52660
|
+
}
|
|
52661
|
+
}
|
|
52662
|
+
this.policy = null;
|
|
52663
|
+
}
|
|
52664
|
+
};
|
|
52665
|
+
}
|
|
52666
|
+
});
|
|
52667
|
+
|
|
52668
|
+
// src/enterprise/policy/opa-http-evaluator.ts
|
|
52669
|
+
var OpaHttpEvaluator;
|
|
52670
|
+
var init_opa_http_evaluator = __esm({
|
|
52671
|
+
"src/enterprise/policy/opa-http-evaluator.ts"() {
|
|
52672
|
+
"use strict";
|
|
52673
|
+
OpaHttpEvaluator = class {
|
|
52674
|
+
baseUrl;
|
|
52675
|
+
timeout;
|
|
52676
|
+
constructor(baseUrl, timeout = 5e3) {
|
|
52677
|
+
let parsed;
|
|
52678
|
+
try {
|
|
52679
|
+
parsed = new URL(baseUrl);
|
|
52680
|
+
} catch {
|
|
52681
|
+
throw new Error(`OPA HTTP evaluator: invalid URL: ${baseUrl}`);
|
|
52682
|
+
}
|
|
52683
|
+
if (!["http:", "https:"].includes(parsed.protocol)) {
|
|
52684
|
+
throw new Error(
|
|
52685
|
+
`OPA HTTP evaluator: url must use http:// or https:// protocol, got: ${baseUrl}`
|
|
52686
|
+
);
|
|
52687
|
+
}
|
|
52688
|
+
const hostname = parsed.hostname;
|
|
52689
|
+
if (this.isBlockedHostname(hostname)) {
|
|
52690
|
+
throw new Error(
|
|
52691
|
+
`OPA HTTP evaluator: url must not point to internal, loopback, or private network addresses`
|
|
52692
|
+
);
|
|
52693
|
+
}
|
|
52694
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
52695
|
+
this.timeout = timeout;
|
|
52696
|
+
}
|
|
52697
|
+
/**
|
|
52698
|
+
* Check if a hostname is blocked due to SSRF concerns.
|
|
52699
|
+
*
|
|
52700
|
+
* Blocks:
|
|
52701
|
+
* - Loopback addresses (127.x.x.x, localhost, 0.0.0.0, ::1)
|
|
52702
|
+
* - Link-local addresses (169.254.x.x)
|
|
52703
|
+
* - Private networks (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
|
|
52704
|
+
* - IPv6 unique local addresses (fd00::/8)
|
|
52705
|
+
* - Cloud metadata services (*.internal)
|
|
52706
|
+
*/
|
|
52707
|
+
isBlockedHostname(hostname) {
|
|
52708
|
+
if (!hostname) return true;
|
|
52709
|
+
const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
52710
|
+
if (normalized === "metadata.google.internal" || normalized.endsWith(".internal")) {
|
|
52711
|
+
return true;
|
|
52712
|
+
}
|
|
52713
|
+
if (normalized === "localhost" || normalized === "localhost.localdomain") {
|
|
52714
|
+
return true;
|
|
52715
|
+
}
|
|
52716
|
+
if (normalized === "::1" || normalized === "0:0:0:0:0:0:0:1") {
|
|
52717
|
+
return true;
|
|
52718
|
+
}
|
|
52719
|
+
const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
|
|
52720
|
+
const ipv4Match = normalized.match(ipv4Pattern);
|
|
52721
|
+
if (ipv4Match) {
|
|
52722
|
+
const octets = ipv4Match.slice(1, 5).map(Number);
|
|
52723
|
+
if (octets.some((octet) => octet > 255)) {
|
|
52724
|
+
return false;
|
|
52725
|
+
}
|
|
52726
|
+
const [a, b] = octets;
|
|
52727
|
+
if (a === 127) {
|
|
52728
|
+
return true;
|
|
52729
|
+
}
|
|
52730
|
+
if (a === 0) {
|
|
52731
|
+
return true;
|
|
52732
|
+
}
|
|
52733
|
+
if (a === 169 && b === 254) {
|
|
52734
|
+
return true;
|
|
52735
|
+
}
|
|
52736
|
+
if (a === 10) {
|
|
52737
|
+
return true;
|
|
52738
|
+
}
|
|
52739
|
+
if (a === 172 && b >= 16 && b <= 31) {
|
|
52740
|
+
return true;
|
|
52741
|
+
}
|
|
52742
|
+
if (a === 192 && b === 168) {
|
|
52743
|
+
return true;
|
|
52744
|
+
}
|
|
52745
|
+
}
|
|
52746
|
+
if (normalized.startsWith("fd") || normalized.startsWith("fc")) {
|
|
52747
|
+
return true;
|
|
52748
|
+
}
|
|
52749
|
+
if (normalized.startsWith("fe80:")) {
|
|
52750
|
+
return true;
|
|
52751
|
+
}
|
|
52752
|
+
return false;
|
|
52753
|
+
}
|
|
52754
|
+
/**
|
|
52755
|
+
* Evaluate a policy rule against an input document via OPA REST API.
|
|
52756
|
+
*
|
|
52757
|
+
* @param input - The input document to evaluate
|
|
52758
|
+
* @param rulePath - OPA rule path (e.g., 'visor/check/execute')
|
|
52759
|
+
* @returns The result object from OPA, or undefined on error
|
|
52760
|
+
*/
|
|
52761
|
+
async evaluate(input, rulePath) {
|
|
52762
|
+
const encodedPath = rulePath.split("/").map((s) => encodeURIComponent(s)).join("/");
|
|
52763
|
+
const url = `${this.baseUrl}/v1/data/${encodedPath}`;
|
|
52764
|
+
const controller = new AbortController();
|
|
52765
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
52766
|
+
try {
|
|
52767
|
+
const response = await fetch(url, {
|
|
52768
|
+
method: "POST",
|
|
52769
|
+
headers: { "Content-Type": "application/json" },
|
|
52770
|
+
body: JSON.stringify({ input }),
|
|
52771
|
+
signal: controller.signal
|
|
52772
|
+
});
|
|
52773
|
+
if (!response.ok) {
|
|
52774
|
+
throw new Error(`OPA HTTP ${response.status}: ${response.statusText}`);
|
|
52775
|
+
}
|
|
52776
|
+
let body;
|
|
52777
|
+
try {
|
|
52778
|
+
body = await response.json();
|
|
52779
|
+
} catch (jsonErr) {
|
|
52780
|
+
throw new Error(
|
|
52781
|
+
`OPA HTTP evaluator: failed to parse JSON response: ${jsonErr instanceof Error ? jsonErr.message : String(jsonErr)}`
|
|
52782
|
+
);
|
|
52783
|
+
}
|
|
52784
|
+
return body?.result;
|
|
52785
|
+
} finally {
|
|
52786
|
+
clearTimeout(timer);
|
|
52787
|
+
}
|
|
52788
|
+
}
|
|
52789
|
+
async shutdown() {
|
|
52790
|
+
}
|
|
52791
|
+
};
|
|
52792
|
+
}
|
|
52793
|
+
});
|
|
52794
|
+
|
|
52795
|
+
// src/enterprise/policy/policy-input-builder.ts
|
|
52796
|
+
var PolicyInputBuilder;
|
|
52797
|
+
var init_policy_input_builder = __esm({
|
|
52798
|
+
"src/enterprise/policy/policy-input-builder.ts"() {
|
|
52799
|
+
"use strict";
|
|
52800
|
+
PolicyInputBuilder = class {
|
|
52801
|
+
roles;
|
|
52802
|
+
actor;
|
|
52803
|
+
repository;
|
|
52804
|
+
pullRequest;
|
|
52805
|
+
constructor(policyConfig, actor, repository, pullRequest) {
|
|
52806
|
+
this.roles = policyConfig.roles || {};
|
|
52807
|
+
this.actor = actor;
|
|
52808
|
+
this.repository = repository;
|
|
52809
|
+
this.pullRequest = pullRequest;
|
|
52810
|
+
}
|
|
52811
|
+
/** Resolve which roles apply to the current actor. */
|
|
52812
|
+
resolveRoles() {
|
|
52813
|
+
const matched = [];
|
|
52814
|
+
for (const [roleName, roleConfig] of Object.entries(this.roles)) {
|
|
52815
|
+
let identityMatch = false;
|
|
52816
|
+
if (roleConfig.author_association && this.actor.authorAssociation && roleConfig.author_association.includes(this.actor.authorAssociation)) {
|
|
52817
|
+
identityMatch = true;
|
|
52818
|
+
}
|
|
52819
|
+
if (!identityMatch && roleConfig.users && this.actor.login && roleConfig.users.includes(this.actor.login)) {
|
|
52820
|
+
identityMatch = true;
|
|
52821
|
+
}
|
|
52822
|
+
if (!identityMatch && roleConfig.slack_users && this.actor.slack?.userId && roleConfig.slack_users.includes(this.actor.slack.userId)) {
|
|
52823
|
+
identityMatch = true;
|
|
52824
|
+
}
|
|
52825
|
+
if (!identityMatch && roleConfig.emails && this.actor.slack?.email) {
|
|
52826
|
+
const actorEmail = this.actor.slack.email.toLowerCase();
|
|
52827
|
+
if (roleConfig.emails.some((e) => e.toLowerCase() === actorEmail)) {
|
|
52828
|
+
identityMatch = true;
|
|
52829
|
+
}
|
|
52830
|
+
}
|
|
52831
|
+
if (!identityMatch) continue;
|
|
52832
|
+
if (roleConfig.slack_channels && roleConfig.slack_channels.length > 0) {
|
|
52833
|
+
if (!this.actor.slack?.channelId || !roleConfig.slack_channels.includes(this.actor.slack.channelId)) {
|
|
52834
|
+
continue;
|
|
52835
|
+
}
|
|
52836
|
+
}
|
|
52837
|
+
matched.push(roleName);
|
|
52838
|
+
}
|
|
52839
|
+
return matched;
|
|
52840
|
+
}
|
|
52841
|
+
buildActor() {
|
|
52842
|
+
return {
|
|
52843
|
+
authorAssociation: this.actor.authorAssociation,
|
|
52844
|
+
login: this.actor.login,
|
|
52845
|
+
roles: this.resolveRoles(),
|
|
52846
|
+
isLocalMode: this.actor.isLocalMode,
|
|
52847
|
+
...this.actor.slack && { slack: this.actor.slack }
|
|
52848
|
+
};
|
|
52849
|
+
}
|
|
52850
|
+
forCheckExecution(check) {
|
|
52851
|
+
return {
|
|
52852
|
+
scope: "check.execute",
|
|
52853
|
+
check: {
|
|
52854
|
+
id: check.id,
|
|
52855
|
+
type: check.type,
|
|
52856
|
+
group: check.group,
|
|
52857
|
+
tags: check.tags,
|
|
52858
|
+
criticality: check.criticality,
|
|
52859
|
+
sandbox: check.sandbox,
|
|
52860
|
+
policy: check.policy
|
|
52861
|
+
},
|
|
52862
|
+
actor: this.buildActor(),
|
|
52863
|
+
repository: this.repository,
|
|
52864
|
+
pullRequest: this.pullRequest
|
|
52865
|
+
};
|
|
52866
|
+
}
|
|
52867
|
+
forToolInvocation(serverName, methodName, transport) {
|
|
52868
|
+
return {
|
|
52869
|
+
scope: "tool.invoke",
|
|
52870
|
+
tool: { serverName, methodName, transport },
|
|
52871
|
+
actor: this.buildActor(),
|
|
52872
|
+
repository: this.repository,
|
|
52873
|
+
pullRequest: this.pullRequest
|
|
52874
|
+
};
|
|
52875
|
+
}
|
|
52876
|
+
forCapabilityResolve(checkId, capabilities) {
|
|
52877
|
+
return {
|
|
52878
|
+
scope: "capability.resolve",
|
|
52879
|
+
check: { id: checkId, type: "ai" },
|
|
52880
|
+
capability: capabilities,
|
|
52881
|
+
actor: this.buildActor(),
|
|
52882
|
+
repository: this.repository,
|
|
52883
|
+
pullRequest: this.pullRequest
|
|
52884
|
+
};
|
|
52885
|
+
}
|
|
52886
|
+
};
|
|
52887
|
+
}
|
|
52888
|
+
});
|
|
52889
|
+
|
|
52890
|
+
// src/enterprise/policy/opa-policy-engine.ts
|
|
52891
|
+
var opa_policy_engine_exports = {};
|
|
52892
|
+
__export(opa_policy_engine_exports, {
|
|
52893
|
+
OpaPolicyEngine: () => OpaPolicyEngine
|
|
52894
|
+
});
|
|
52895
|
+
var OpaPolicyEngine;
|
|
52896
|
+
var init_opa_policy_engine = __esm({
|
|
52897
|
+
"src/enterprise/policy/opa-policy-engine.ts"() {
|
|
52898
|
+
"use strict";
|
|
52899
|
+
init_opa_wasm_evaluator();
|
|
52900
|
+
init_opa_http_evaluator();
|
|
52901
|
+
init_policy_input_builder();
|
|
52902
|
+
OpaPolicyEngine = class {
|
|
52903
|
+
evaluator = null;
|
|
52904
|
+
fallback;
|
|
52905
|
+
timeout;
|
|
52906
|
+
config;
|
|
52907
|
+
inputBuilder = null;
|
|
52908
|
+
logger = null;
|
|
52909
|
+
constructor(config) {
|
|
52910
|
+
this.config = config;
|
|
52911
|
+
this.fallback = config.fallback || "deny";
|
|
52912
|
+
this.timeout = config.timeout || 5e3;
|
|
52913
|
+
}
|
|
52914
|
+
async initialize(config) {
|
|
52915
|
+
try {
|
|
52916
|
+
this.logger = (init_logger(), __toCommonJS(logger_exports)).logger;
|
|
52917
|
+
} catch {
|
|
52918
|
+
}
|
|
52919
|
+
const actor = {
|
|
52920
|
+
authorAssociation: process.env.VISOR_AUTHOR_ASSOCIATION,
|
|
52921
|
+
login: process.env.VISOR_AUTHOR_LOGIN || process.env.GITHUB_ACTOR,
|
|
52922
|
+
isLocalMode: !process.env.GITHUB_ACTIONS
|
|
52923
|
+
};
|
|
52924
|
+
const repo = {
|
|
52925
|
+
owner: process.env.GITHUB_REPOSITORY_OWNER,
|
|
52926
|
+
name: process.env.GITHUB_REPOSITORY?.split("/")[1],
|
|
52927
|
+
branch: process.env.GITHUB_HEAD_REF,
|
|
52928
|
+
baseBranch: process.env.GITHUB_BASE_REF,
|
|
52929
|
+
event: process.env.GITHUB_EVENT_NAME
|
|
52930
|
+
};
|
|
52931
|
+
const prNum = process.env.GITHUB_PR_NUMBER ? parseInt(process.env.GITHUB_PR_NUMBER, 10) : void 0;
|
|
52932
|
+
const pullRequest = {
|
|
52933
|
+
number: prNum !== void 0 && Number.isFinite(prNum) ? prNum : void 0
|
|
52934
|
+
};
|
|
52935
|
+
this.inputBuilder = new PolicyInputBuilder(config, actor, repo, pullRequest);
|
|
52936
|
+
if (config.engine === "local") {
|
|
52937
|
+
if (!config.rules) {
|
|
52938
|
+
throw new Error("OPA local mode requires `policy.rules` path to .wasm or .rego files");
|
|
52939
|
+
}
|
|
52940
|
+
const wasm = new OpaWasmEvaluator();
|
|
52941
|
+
await wasm.initialize(config.rules);
|
|
52942
|
+
if (config.data) {
|
|
52943
|
+
wasm.loadData(config.data);
|
|
52944
|
+
}
|
|
52945
|
+
this.evaluator = wasm;
|
|
52946
|
+
} else if (config.engine === "remote") {
|
|
52947
|
+
if (!config.url) {
|
|
52948
|
+
throw new Error("OPA remote mode requires `policy.url` pointing to OPA server");
|
|
52949
|
+
}
|
|
52950
|
+
this.evaluator = new OpaHttpEvaluator(config.url, this.timeout);
|
|
52951
|
+
} else {
|
|
52952
|
+
this.evaluator = null;
|
|
52953
|
+
}
|
|
52954
|
+
}
|
|
52955
|
+
/**
|
|
52956
|
+
* Update actor/repo/PR context (e.g., after PR info becomes available).
|
|
52957
|
+
* Called by the enterprise loader when engine context is enriched.
|
|
52958
|
+
*/
|
|
52959
|
+
setActorContext(actor, repo, pullRequest) {
|
|
52960
|
+
this.inputBuilder = new PolicyInputBuilder(this.config, actor, repo, pullRequest);
|
|
52961
|
+
}
|
|
52962
|
+
async evaluateCheckExecution(checkId, checkConfig) {
|
|
52963
|
+
if (!this.evaluator || !this.inputBuilder) return { allowed: true };
|
|
52964
|
+
const cfg = checkConfig && typeof checkConfig === "object" ? checkConfig : {};
|
|
52965
|
+
const policyOverride = cfg.policy;
|
|
52966
|
+
const input = this.inputBuilder.forCheckExecution({
|
|
52967
|
+
id: checkId,
|
|
52968
|
+
type: cfg.type || "ai",
|
|
52969
|
+
group: cfg.group,
|
|
52970
|
+
tags: cfg.tags,
|
|
52971
|
+
criticality: cfg.criticality,
|
|
52972
|
+
sandbox: cfg.sandbox,
|
|
52973
|
+
policy: policyOverride
|
|
52974
|
+
});
|
|
52975
|
+
return this.doEvaluate(input, this.resolveRulePath("check.execute", policyOverride?.rule));
|
|
52976
|
+
}
|
|
52977
|
+
async evaluateToolInvocation(serverName, methodName, transport) {
|
|
52978
|
+
if (!this.evaluator || !this.inputBuilder) return { allowed: true };
|
|
52979
|
+
const input = this.inputBuilder.forToolInvocation(serverName, methodName, transport);
|
|
52980
|
+
return this.doEvaluate(input, "visor/tool/invoke");
|
|
52981
|
+
}
|
|
52982
|
+
async evaluateCapabilities(checkId, capabilities) {
|
|
52983
|
+
if (!this.evaluator || !this.inputBuilder) return { allowed: true };
|
|
52984
|
+
const input = this.inputBuilder.forCapabilityResolve(checkId, capabilities);
|
|
52985
|
+
return this.doEvaluate(input, "visor/capability/resolve");
|
|
52986
|
+
}
|
|
52987
|
+
async shutdown() {
|
|
52988
|
+
if (this.evaluator && "shutdown" in this.evaluator) {
|
|
52989
|
+
await this.evaluator.shutdown();
|
|
52990
|
+
}
|
|
52991
|
+
this.evaluator = null;
|
|
52992
|
+
this.inputBuilder = null;
|
|
52993
|
+
}
|
|
52994
|
+
resolveRulePath(defaultScope, override) {
|
|
52995
|
+
if (override) {
|
|
52996
|
+
return override.startsWith("visor/") ? override : `visor/${override}`;
|
|
52997
|
+
}
|
|
52998
|
+
return `visor/${defaultScope.replace(/\./g, "/")}`;
|
|
52999
|
+
}
|
|
53000
|
+
async doEvaluate(input, rulePath) {
|
|
53001
|
+
try {
|
|
53002
|
+
this.logger?.debug(`[PolicyEngine] Evaluating ${rulePath}`, JSON.stringify(input));
|
|
53003
|
+
let timer;
|
|
53004
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
53005
|
+
timer = setTimeout(() => reject(new Error("policy evaluation timeout")), this.timeout);
|
|
53006
|
+
});
|
|
53007
|
+
try {
|
|
53008
|
+
const result = await Promise.race([this.rawEvaluate(input, rulePath), timeoutPromise]);
|
|
53009
|
+
const decision = this.parseDecision(result);
|
|
53010
|
+
if (!decision.allowed && this.fallback === "warn") {
|
|
53011
|
+
decision.allowed = true;
|
|
53012
|
+
decision.warn = true;
|
|
53013
|
+
decision.reason = `audit: ${decision.reason || "policy denied"}`;
|
|
53014
|
+
}
|
|
53015
|
+
this.logger?.debug(
|
|
53016
|
+
`[PolicyEngine] Decision for ${rulePath}: allowed=${decision.allowed}, warn=${decision.warn || false}, reason=${decision.reason || "none"}`
|
|
53017
|
+
);
|
|
53018
|
+
return decision;
|
|
53019
|
+
} finally {
|
|
53020
|
+
if (timer) clearTimeout(timer);
|
|
53021
|
+
}
|
|
53022
|
+
} catch (err) {
|
|
53023
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
53024
|
+
this.logger?.warn(`[PolicyEngine] Evaluation failed for ${rulePath}: ${msg}`);
|
|
53025
|
+
return {
|
|
53026
|
+
allowed: this.fallback === "allow" || this.fallback === "warn",
|
|
53027
|
+
warn: this.fallback === "warn" ? true : void 0,
|
|
53028
|
+
reason: `policy evaluation failed, fallback=${this.fallback}`
|
|
53029
|
+
};
|
|
53030
|
+
}
|
|
53031
|
+
}
|
|
53032
|
+
async rawEvaluate(input, rulePath) {
|
|
53033
|
+
if (this.evaluator instanceof OpaWasmEvaluator) {
|
|
53034
|
+
const result = await this.evaluator.evaluate(input);
|
|
53035
|
+
return this.navigateWasmResult(result, rulePath);
|
|
53036
|
+
}
|
|
53037
|
+
return this.evaluator.evaluate(input, rulePath);
|
|
53038
|
+
}
|
|
53039
|
+
/**
|
|
53040
|
+
* Navigate nested OPA WASM result tree to reach the specific rule's output.
|
|
53041
|
+
* The WASM entrypoint `-e visor` means the result root IS the visor package,
|
|
53042
|
+
* so we strip the `visor/` prefix and walk the remaining segments.
|
|
53043
|
+
*/
|
|
53044
|
+
navigateWasmResult(result, rulePath) {
|
|
53045
|
+
if (!result || typeof result !== "object") return result;
|
|
53046
|
+
const segments = rulePath.replace(/^visor\//, "").split("/");
|
|
53047
|
+
let current = result;
|
|
53048
|
+
for (const seg of segments) {
|
|
53049
|
+
if (current && typeof current === "object" && seg in current) {
|
|
53050
|
+
current = current[seg];
|
|
53051
|
+
} else {
|
|
53052
|
+
return void 0;
|
|
53053
|
+
}
|
|
53054
|
+
}
|
|
53055
|
+
return current;
|
|
53056
|
+
}
|
|
53057
|
+
parseDecision(result) {
|
|
53058
|
+
if (result === void 0 || result === null) {
|
|
53059
|
+
return {
|
|
53060
|
+
allowed: this.fallback === "allow" || this.fallback === "warn",
|
|
53061
|
+
warn: this.fallback === "warn" ? true : void 0,
|
|
53062
|
+
reason: this.fallback === "warn" ? "audit: no policy result" : "no policy result"
|
|
53063
|
+
};
|
|
53064
|
+
}
|
|
53065
|
+
const allowed = result.allowed !== false;
|
|
53066
|
+
const decision = {
|
|
53067
|
+
allowed,
|
|
53068
|
+
reason: result.reason
|
|
53069
|
+
};
|
|
53070
|
+
if (result.capabilities) {
|
|
53071
|
+
decision.capabilities = result.capabilities;
|
|
53072
|
+
}
|
|
53073
|
+
return decision;
|
|
53074
|
+
}
|
|
53075
|
+
};
|
|
53076
|
+
}
|
|
53077
|
+
});
|
|
53078
|
+
|
|
53079
|
+
// src/enterprise/scheduler/knex-store.ts
|
|
53080
|
+
var knex_store_exports = {};
|
|
53081
|
+
__export(knex_store_exports, {
|
|
53082
|
+
KnexStoreBackend: () => KnexStoreBackend
|
|
53083
|
+
});
|
|
53084
|
+
function toNum(val) {
|
|
53085
|
+
if (val === null || val === void 0) return void 0;
|
|
53086
|
+
return typeof val === "string" ? parseInt(val, 10) : val;
|
|
53087
|
+
}
|
|
53088
|
+
function safeJsonParse2(value) {
|
|
53089
|
+
if (!value) return void 0;
|
|
53090
|
+
try {
|
|
53091
|
+
return JSON.parse(value);
|
|
53092
|
+
} catch {
|
|
53093
|
+
return void 0;
|
|
53094
|
+
}
|
|
53095
|
+
}
|
|
53096
|
+
function fromDbRow2(row) {
|
|
53097
|
+
return {
|
|
53098
|
+
id: row.id,
|
|
53099
|
+
creatorId: row.creator_id,
|
|
53100
|
+
creatorContext: row.creator_context ?? void 0,
|
|
53101
|
+
creatorName: row.creator_name ?? void 0,
|
|
53102
|
+
timezone: row.timezone,
|
|
53103
|
+
schedule: row.schedule_expr,
|
|
53104
|
+
runAt: toNum(row.run_at),
|
|
53105
|
+
isRecurring: row.is_recurring === true || row.is_recurring === 1,
|
|
53106
|
+
originalExpression: row.original_expression,
|
|
53107
|
+
workflow: row.workflow ?? void 0,
|
|
53108
|
+
workflowInputs: safeJsonParse2(row.workflow_inputs),
|
|
53109
|
+
outputContext: safeJsonParse2(row.output_context),
|
|
53110
|
+
status: row.status,
|
|
53111
|
+
createdAt: toNum(row.created_at),
|
|
53112
|
+
lastRunAt: toNum(row.last_run_at),
|
|
53113
|
+
nextRunAt: toNum(row.next_run_at),
|
|
53114
|
+
runCount: row.run_count,
|
|
53115
|
+
failureCount: row.failure_count,
|
|
53116
|
+
lastError: row.last_error ?? void 0,
|
|
53117
|
+
previousResponse: row.previous_response ?? void 0
|
|
53118
|
+
};
|
|
53119
|
+
}
|
|
53120
|
+
function toInsertRow(schedule) {
|
|
53121
|
+
return {
|
|
53122
|
+
id: schedule.id,
|
|
53123
|
+
creator_id: schedule.creatorId,
|
|
53124
|
+
creator_context: schedule.creatorContext ?? null,
|
|
53125
|
+
creator_name: schedule.creatorName ?? null,
|
|
53126
|
+
timezone: schedule.timezone,
|
|
53127
|
+
schedule_expr: schedule.schedule,
|
|
53128
|
+
run_at: schedule.runAt ?? null,
|
|
53129
|
+
is_recurring: schedule.isRecurring,
|
|
53130
|
+
original_expression: schedule.originalExpression,
|
|
53131
|
+
workflow: schedule.workflow ?? null,
|
|
53132
|
+
workflow_inputs: schedule.workflowInputs ? JSON.stringify(schedule.workflowInputs) : null,
|
|
53133
|
+
output_context: schedule.outputContext ? JSON.stringify(schedule.outputContext) : null,
|
|
53134
|
+
status: schedule.status,
|
|
53135
|
+
created_at: schedule.createdAt,
|
|
53136
|
+
last_run_at: schedule.lastRunAt ?? null,
|
|
53137
|
+
next_run_at: schedule.nextRunAt ?? null,
|
|
53138
|
+
run_count: schedule.runCount,
|
|
53139
|
+
failure_count: schedule.failureCount,
|
|
53140
|
+
last_error: schedule.lastError ?? null,
|
|
53141
|
+
previous_response: schedule.previousResponse ?? null
|
|
53142
|
+
};
|
|
53143
|
+
}
|
|
53144
|
+
var fs23, path27, import_uuid2, KnexStoreBackend;
|
|
53145
|
+
var init_knex_store = __esm({
|
|
53146
|
+
"src/enterprise/scheduler/knex-store.ts"() {
|
|
53147
|
+
"use strict";
|
|
53148
|
+
fs23 = __toESM(require("fs"));
|
|
53149
|
+
path27 = __toESM(require("path"));
|
|
53150
|
+
import_uuid2 = require("uuid");
|
|
53151
|
+
init_logger();
|
|
53152
|
+
KnexStoreBackend = class {
|
|
53153
|
+
knex = null;
|
|
53154
|
+
driver;
|
|
53155
|
+
connection;
|
|
53156
|
+
constructor(driver, storageConfig, _haConfig) {
|
|
53157
|
+
this.driver = driver;
|
|
53158
|
+
this.connection = storageConfig.connection || {};
|
|
53159
|
+
}
|
|
53160
|
+
async initialize() {
|
|
53161
|
+
const { createRequire } = require("module");
|
|
53162
|
+
const runtimeRequire = createRequire(__filename);
|
|
53163
|
+
let knexFactory;
|
|
53164
|
+
try {
|
|
53165
|
+
knexFactory = runtimeRequire("knex");
|
|
53166
|
+
} catch (err) {
|
|
53167
|
+
const code = err?.code;
|
|
53168
|
+
if (code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND") {
|
|
53169
|
+
throw new Error(
|
|
53170
|
+
"knex is required for PostgreSQL/MySQL/MSSQL schedule storage. Install it with: npm install knex"
|
|
53171
|
+
);
|
|
53172
|
+
}
|
|
53173
|
+
throw err;
|
|
53174
|
+
}
|
|
53175
|
+
const clientMap = {
|
|
53176
|
+
postgresql: "pg",
|
|
53177
|
+
mysql: "mysql2",
|
|
53178
|
+
mssql: "tedious"
|
|
53179
|
+
};
|
|
53180
|
+
const client = clientMap[this.driver];
|
|
53181
|
+
let connection;
|
|
53182
|
+
if (this.connection.connection_string) {
|
|
53183
|
+
connection = this.connection.connection_string;
|
|
53184
|
+
} else if (this.driver === "mssql") {
|
|
53185
|
+
connection = this.buildMssqlConnection();
|
|
53186
|
+
} else {
|
|
53187
|
+
connection = this.buildStandardConnection();
|
|
53188
|
+
}
|
|
53189
|
+
this.knex = knexFactory({
|
|
53190
|
+
client,
|
|
53191
|
+
connection,
|
|
53192
|
+
pool: {
|
|
53193
|
+
min: this.connection.pool?.min ?? 0,
|
|
53194
|
+
max: this.connection.pool?.max ?? 10
|
|
53195
|
+
}
|
|
53196
|
+
});
|
|
53197
|
+
await this.migrateSchema();
|
|
53198
|
+
logger.info(`[KnexStore] Initialized (${this.driver})`);
|
|
53199
|
+
}
|
|
53200
|
+
buildStandardConnection() {
|
|
53201
|
+
return {
|
|
53202
|
+
host: this.connection.host || "localhost",
|
|
53203
|
+
port: this.connection.port,
|
|
53204
|
+
database: this.connection.database || "visor",
|
|
53205
|
+
user: this.connection.user,
|
|
53206
|
+
password: this.connection.password,
|
|
53207
|
+
ssl: this.resolveSslConfig()
|
|
53208
|
+
};
|
|
53209
|
+
}
|
|
53210
|
+
buildMssqlConnection() {
|
|
53211
|
+
const ssl = this.connection.ssl;
|
|
53212
|
+
const sslEnabled = ssl === true || typeof ssl === "object" && ssl.enabled !== false;
|
|
53213
|
+
return {
|
|
53214
|
+
server: this.connection.host || "localhost",
|
|
53215
|
+
port: this.connection.port,
|
|
53216
|
+
database: this.connection.database || "visor",
|
|
53217
|
+
user: this.connection.user,
|
|
53218
|
+
password: this.connection.password,
|
|
53219
|
+
options: {
|
|
53220
|
+
encrypt: sslEnabled,
|
|
53221
|
+
trustServerCertificate: typeof ssl === "object" ? ssl.reject_unauthorized === false : !sslEnabled
|
|
53222
|
+
}
|
|
53223
|
+
};
|
|
53224
|
+
}
|
|
53225
|
+
resolveSslConfig() {
|
|
53226
|
+
const ssl = this.connection.ssl;
|
|
53227
|
+
if (ssl === false || ssl === void 0) return false;
|
|
53228
|
+
if (ssl === true) return { rejectUnauthorized: true };
|
|
53229
|
+
if (ssl.enabled === false) return false;
|
|
53230
|
+
const result = {
|
|
53231
|
+
rejectUnauthorized: ssl.reject_unauthorized !== false
|
|
53232
|
+
};
|
|
53233
|
+
if (ssl.ca) {
|
|
53234
|
+
const caPath = this.validateSslPath(ssl.ca, "CA certificate");
|
|
53235
|
+
result.ca = fs23.readFileSync(caPath, "utf8");
|
|
53236
|
+
}
|
|
53237
|
+
if (ssl.cert) {
|
|
53238
|
+
const certPath = this.validateSslPath(ssl.cert, "client certificate");
|
|
53239
|
+
result.cert = fs23.readFileSync(certPath, "utf8");
|
|
53240
|
+
}
|
|
53241
|
+
if (ssl.key) {
|
|
53242
|
+
const keyPath = this.validateSslPath(ssl.key, "client key");
|
|
53243
|
+
result.key = fs23.readFileSync(keyPath, "utf8");
|
|
53244
|
+
}
|
|
53245
|
+
return result;
|
|
53246
|
+
}
|
|
53247
|
+
validateSslPath(filePath, label) {
|
|
53248
|
+
const resolved = path27.resolve(filePath);
|
|
53249
|
+
if (resolved !== path27.normalize(resolved)) {
|
|
53250
|
+
throw new Error(`SSL ${label} path contains invalid sequences: ${filePath}`);
|
|
53251
|
+
}
|
|
53252
|
+
if (!fs23.existsSync(resolved)) {
|
|
53253
|
+
throw new Error(`SSL ${label} not found: ${filePath}`);
|
|
53254
|
+
}
|
|
53255
|
+
return resolved;
|
|
53256
|
+
}
|
|
53257
|
+
async shutdown() {
|
|
53258
|
+
if (this.knex) {
|
|
53259
|
+
await this.knex.destroy();
|
|
53260
|
+
this.knex = null;
|
|
53261
|
+
}
|
|
53262
|
+
}
|
|
53263
|
+
async migrateSchema() {
|
|
53264
|
+
const knex = this.getKnex();
|
|
53265
|
+
const exists = await knex.schema.hasTable("schedules");
|
|
53266
|
+
if (!exists) {
|
|
53267
|
+
await knex.schema.createTable("schedules", (table) => {
|
|
53268
|
+
table.string("id", 36).primary();
|
|
53269
|
+
table.string("creator_id", 255).notNullable().index();
|
|
53270
|
+
table.string("creator_context", 255);
|
|
53271
|
+
table.string("creator_name", 255);
|
|
53272
|
+
table.string("timezone", 64).notNullable().defaultTo("UTC");
|
|
53273
|
+
table.string("schedule_expr", 255);
|
|
53274
|
+
table.bigInteger("run_at");
|
|
53275
|
+
table.boolean("is_recurring").notNullable();
|
|
53276
|
+
table.text("original_expression");
|
|
53277
|
+
table.string("workflow", 255);
|
|
53278
|
+
table.text("workflow_inputs");
|
|
53279
|
+
table.text("output_context");
|
|
53280
|
+
table.string("status", 20).notNullable().index();
|
|
53281
|
+
table.bigInteger("created_at").notNullable();
|
|
53282
|
+
table.bigInteger("last_run_at");
|
|
53283
|
+
table.bigInteger("next_run_at");
|
|
53284
|
+
table.integer("run_count").notNullable().defaultTo(0);
|
|
53285
|
+
table.integer("failure_count").notNullable().defaultTo(0);
|
|
53286
|
+
table.text("last_error");
|
|
53287
|
+
table.text("previous_response");
|
|
53288
|
+
table.index(["status", "next_run_at"]);
|
|
53289
|
+
});
|
|
53290
|
+
}
|
|
53291
|
+
const locksExist = await knex.schema.hasTable("scheduler_locks");
|
|
53292
|
+
if (!locksExist) {
|
|
53293
|
+
await knex.schema.createTable("scheduler_locks", (table) => {
|
|
53294
|
+
table.string("lock_id", 255).primary();
|
|
53295
|
+
table.string("node_id", 255).notNullable();
|
|
53296
|
+
table.string("lock_token", 36).notNullable();
|
|
53297
|
+
table.bigInteger("acquired_at").notNullable();
|
|
53298
|
+
table.bigInteger("expires_at").notNullable();
|
|
53299
|
+
});
|
|
53300
|
+
}
|
|
53301
|
+
}
|
|
53302
|
+
getKnex() {
|
|
53303
|
+
if (!this.knex) {
|
|
53304
|
+
throw new Error("[KnexStore] Not initialized. Call initialize() first.");
|
|
53305
|
+
}
|
|
53306
|
+
return this.knex;
|
|
53307
|
+
}
|
|
53308
|
+
// --- CRUD ---
|
|
53309
|
+
async create(schedule) {
|
|
53310
|
+
const knex = this.getKnex();
|
|
53311
|
+
const newSchedule = {
|
|
53312
|
+
...schedule,
|
|
53313
|
+
id: (0, import_uuid2.v4)(),
|
|
53314
|
+
createdAt: Date.now(),
|
|
53315
|
+
runCount: 0,
|
|
53316
|
+
failureCount: 0,
|
|
53317
|
+
status: "active"
|
|
53318
|
+
};
|
|
53319
|
+
await knex("schedules").insert(toInsertRow(newSchedule));
|
|
53320
|
+
logger.info(`[KnexStore] Created schedule ${newSchedule.id} for user ${newSchedule.creatorId}`);
|
|
53321
|
+
return newSchedule;
|
|
53322
|
+
}
|
|
53323
|
+
async importSchedule(schedule) {
|
|
53324
|
+
const knex = this.getKnex();
|
|
53325
|
+
const existing = await knex("schedules").where("id", schedule.id).first();
|
|
53326
|
+
if (existing) return;
|
|
53327
|
+
await knex("schedules").insert(toInsertRow(schedule));
|
|
53328
|
+
}
|
|
53329
|
+
async get(id) {
|
|
53330
|
+
const knex = this.getKnex();
|
|
53331
|
+
const row = await knex("schedules").where("id", id).first();
|
|
53332
|
+
return row ? fromDbRow2(row) : void 0;
|
|
53333
|
+
}
|
|
53334
|
+
async update(id, patch) {
|
|
53335
|
+
const knex = this.getKnex();
|
|
53336
|
+
const existing = await knex("schedules").where("id", id).first();
|
|
53337
|
+
if (!existing) return void 0;
|
|
53338
|
+
const current = fromDbRow2(existing);
|
|
53339
|
+
const updated = { ...current, ...patch, id: current.id };
|
|
53340
|
+
const row = toInsertRow(updated);
|
|
53341
|
+
delete row.id;
|
|
53342
|
+
await knex("schedules").where("id", id).update(row);
|
|
53343
|
+
return updated;
|
|
53344
|
+
}
|
|
53345
|
+
async delete(id) {
|
|
53346
|
+
const knex = this.getKnex();
|
|
53347
|
+
const deleted = await knex("schedules").where("id", id).del();
|
|
53348
|
+
if (deleted > 0) {
|
|
53349
|
+
logger.info(`[KnexStore] Deleted schedule ${id}`);
|
|
53350
|
+
return true;
|
|
53351
|
+
}
|
|
53352
|
+
return false;
|
|
53353
|
+
}
|
|
53354
|
+
// --- Queries ---
|
|
53355
|
+
async getByCreator(creatorId) {
|
|
53356
|
+
const knex = this.getKnex();
|
|
53357
|
+
const rows = await knex("schedules").where("creator_id", creatorId);
|
|
53358
|
+
return rows.map((r) => fromDbRow2(r));
|
|
53359
|
+
}
|
|
53360
|
+
async getActiveSchedules() {
|
|
53361
|
+
const knex = this.getKnex();
|
|
53362
|
+
const rows = await knex("schedules").where("status", "active");
|
|
53363
|
+
return rows.map((r) => fromDbRow2(r));
|
|
53364
|
+
}
|
|
53365
|
+
async getDueSchedules(now) {
|
|
53366
|
+
const ts = now ?? Date.now();
|
|
53367
|
+
const knex = this.getKnex();
|
|
53368
|
+
const bFalse = this.driver === "mssql" ? 0 : false;
|
|
53369
|
+
const bTrue = this.driver === "mssql" ? 1 : true;
|
|
53370
|
+
const rows = await knex("schedules").where("status", "active").andWhere(function() {
|
|
53371
|
+
this.where(function() {
|
|
53372
|
+
this.where("is_recurring", bFalse).whereNotNull("run_at").where("run_at", "<=", ts);
|
|
53373
|
+
}).orWhere(function() {
|
|
53374
|
+
this.where("is_recurring", bTrue).whereNotNull("next_run_at").where("next_run_at", "<=", ts);
|
|
53375
|
+
});
|
|
53376
|
+
});
|
|
53377
|
+
return rows.map((r) => fromDbRow2(r));
|
|
53378
|
+
}
|
|
53379
|
+
async findByWorkflow(creatorId, workflowName) {
|
|
53380
|
+
const knex = this.getKnex();
|
|
53381
|
+
const escaped = workflowName.toLowerCase().replace(/[%_\\]/g, "\\$&");
|
|
53382
|
+
const pattern = `%${escaped}%`;
|
|
53383
|
+
const rows = await knex("schedules").where("creator_id", creatorId).where("status", "active").whereRaw("LOWER(workflow) LIKE ? ESCAPE '\\'", [pattern]);
|
|
53384
|
+
return rows.map((r) => fromDbRow2(r));
|
|
53385
|
+
}
|
|
53386
|
+
async getAll() {
|
|
53387
|
+
const knex = this.getKnex();
|
|
53388
|
+
const rows = await knex("schedules");
|
|
53389
|
+
return rows.map((r) => fromDbRow2(r));
|
|
53390
|
+
}
|
|
53391
|
+
async getStats() {
|
|
53392
|
+
const knex = this.getKnex();
|
|
53393
|
+
const boolTrue = this.driver === "mssql" ? "1" : "true";
|
|
53394
|
+
const boolFalse = this.driver === "mssql" ? "0" : "false";
|
|
53395
|
+
const result = await knex("schedules").select(
|
|
53396
|
+
knex.raw("COUNT(*) as total"),
|
|
53397
|
+
knex.raw("SUM(CASE WHEN status = 'active' THEN 1 ELSE 0 END) as active"),
|
|
53398
|
+
knex.raw("SUM(CASE WHEN status = 'paused' THEN 1 ELSE 0 END) as paused"),
|
|
53399
|
+
knex.raw("SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed"),
|
|
53400
|
+
knex.raw("SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) as failed"),
|
|
53401
|
+
knex.raw(`SUM(CASE WHEN is_recurring = ${boolTrue} THEN 1 ELSE 0 END) as recurring`),
|
|
53402
|
+
knex.raw(`SUM(CASE WHEN is_recurring = ${boolFalse} THEN 1 ELSE 0 END) as one_time`)
|
|
53403
|
+
).first();
|
|
53404
|
+
return {
|
|
53405
|
+
total: Number(result.total) || 0,
|
|
53406
|
+
active: Number(result.active) || 0,
|
|
53407
|
+
paused: Number(result.paused) || 0,
|
|
53408
|
+
completed: Number(result.completed) || 0,
|
|
53409
|
+
failed: Number(result.failed) || 0,
|
|
53410
|
+
recurring: Number(result.recurring) || 0,
|
|
53411
|
+
oneTime: Number(result.one_time) || 0
|
|
53412
|
+
};
|
|
53413
|
+
}
|
|
53414
|
+
async validateLimits(creatorId, isRecurring, limits) {
|
|
53415
|
+
const knex = this.getKnex();
|
|
53416
|
+
if (limits.maxGlobal) {
|
|
53417
|
+
const result = await knex("schedules").count("* as cnt").first();
|
|
53418
|
+
if (Number(result?.cnt) >= limits.maxGlobal) {
|
|
53419
|
+
throw new Error(`Global schedule limit reached (${limits.maxGlobal})`);
|
|
53420
|
+
}
|
|
53421
|
+
}
|
|
53422
|
+
if (limits.maxPerUser) {
|
|
53423
|
+
const result = await knex("schedules").where("creator_id", creatorId).count("* as cnt").first();
|
|
53424
|
+
if (Number(result?.cnt) >= limits.maxPerUser) {
|
|
53425
|
+
throw new Error(`You have reached the maximum number of schedules (${limits.maxPerUser})`);
|
|
53426
|
+
}
|
|
53427
|
+
}
|
|
53428
|
+
if (isRecurring && limits.maxRecurringPerUser) {
|
|
53429
|
+
const bTrue = this.driver === "mssql" ? 1 : true;
|
|
53430
|
+
const result = await knex("schedules").where("creator_id", creatorId).where("is_recurring", bTrue).count("* as cnt").first();
|
|
53431
|
+
if (Number(result?.cnt) >= limits.maxRecurringPerUser) {
|
|
53432
|
+
throw new Error(
|
|
53433
|
+
`You have reached the maximum number of recurring schedules (${limits.maxRecurringPerUser})`
|
|
53434
|
+
);
|
|
53435
|
+
}
|
|
53436
|
+
}
|
|
53437
|
+
}
|
|
53438
|
+
// --- HA Distributed Locking (via scheduler_locks table) ---
|
|
53439
|
+
async tryAcquireLock(lockId, nodeId, ttlSeconds) {
|
|
53440
|
+
const knex = this.getKnex();
|
|
53441
|
+
const now = Date.now();
|
|
53442
|
+
const expiresAt = now + ttlSeconds * 1e3;
|
|
53443
|
+
const token = (0, import_uuid2.v4)();
|
|
53444
|
+
const updated = await knex("scheduler_locks").where("lock_id", lockId).where("expires_at", "<", now).update({
|
|
53445
|
+
node_id: nodeId,
|
|
53446
|
+
lock_token: token,
|
|
53447
|
+
acquired_at: now,
|
|
53448
|
+
expires_at: expiresAt
|
|
53449
|
+
});
|
|
53450
|
+
if (updated > 0) return token;
|
|
53451
|
+
try {
|
|
53452
|
+
await knex("scheduler_locks").insert({
|
|
53453
|
+
lock_id: lockId,
|
|
53454
|
+
node_id: nodeId,
|
|
53455
|
+
lock_token: token,
|
|
53456
|
+
acquired_at: now,
|
|
53457
|
+
expires_at: expiresAt
|
|
53458
|
+
});
|
|
53459
|
+
return token;
|
|
53460
|
+
} catch {
|
|
53461
|
+
return null;
|
|
53462
|
+
}
|
|
53463
|
+
}
|
|
53464
|
+
async releaseLock(lockId, lockToken) {
|
|
53465
|
+
const knex = this.getKnex();
|
|
53466
|
+
await knex("scheduler_locks").where("lock_id", lockId).where("lock_token", lockToken).del();
|
|
53467
|
+
}
|
|
53468
|
+
async renewLock(lockId, lockToken, ttlSeconds) {
|
|
53469
|
+
const knex = this.getKnex();
|
|
53470
|
+
const now = Date.now();
|
|
53471
|
+
const expiresAt = now + ttlSeconds * 1e3;
|
|
53472
|
+
const updated = await knex("scheduler_locks").where("lock_id", lockId).where("lock_token", lockToken).update({ acquired_at: now, expires_at: expiresAt });
|
|
53473
|
+
return updated > 0;
|
|
53474
|
+
}
|
|
53475
|
+
async flush() {
|
|
53476
|
+
}
|
|
53477
|
+
};
|
|
53478
|
+
}
|
|
53479
|
+
});
|
|
53480
|
+
|
|
53481
|
+
// src/enterprise/loader.ts
|
|
53482
|
+
var loader_exports = {};
|
|
53483
|
+
__export(loader_exports, {
|
|
53484
|
+
loadEnterprisePolicyEngine: () => loadEnterprisePolicyEngine,
|
|
53485
|
+
loadEnterpriseStoreBackend: () => loadEnterpriseStoreBackend
|
|
53486
|
+
});
|
|
53487
|
+
async function loadEnterprisePolicyEngine(config) {
|
|
53488
|
+
try {
|
|
53489
|
+
const { LicenseValidator: LicenseValidator2 } = await Promise.resolve().then(() => (init_validator(), validator_exports));
|
|
53490
|
+
const validator = new LicenseValidator2();
|
|
53491
|
+
const license = await validator.loadAndValidate();
|
|
53492
|
+
if (!license || !validator.hasFeature("policy")) {
|
|
53493
|
+
return new DefaultPolicyEngine();
|
|
53494
|
+
}
|
|
53495
|
+
if (validator.isInGracePeriod()) {
|
|
53496
|
+
console.warn(
|
|
53497
|
+
"[visor:enterprise] License has expired but is within the 72-hour grace period. Please renew your license."
|
|
53498
|
+
);
|
|
53499
|
+
}
|
|
53500
|
+
const { OpaPolicyEngine: OpaPolicyEngine2 } = await Promise.resolve().then(() => (init_opa_policy_engine(), opa_policy_engine_exports));
|
|
53501
|
+
const engine = new OpaPolicyEngine2(config);
|
|
53502
|
+
await engine.initialize(config);
|
|
53503
|
+
return engine;
|
|
53504
|
+
} catch (err) {
|
|
53505
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
53506
|
+
try {
|
|
53507
|
+
const { logger: logger2 } = (init_logger(), __toCommonJS(logger_exports));
|
|
53508
|
+
logger2.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
|
|
53509
|
+
} catch {
|
|
53510
|
+
}
|
|
53511
|
+
return new DefaultPolicyEngine();
|
|
53512
|
+
}
|
|
53513
|
+
}
|
|
53514
|
+
async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
|
|
53515
|
+
const { LicenseValidator: LicenseValidator2 } = await Promise.resolve().then(() => (init_validator(), validator_exports));
|
|
53516
|
+
const validator = new LicenseValidator2();
|
|
53517
|
+
const license = await validator.loadAndValidate();
|
|
53518
|
+
if (!license || !validator.hasFeature("scheduler-sql")) {
|
|
53519
|
+
throw new Error(
|
|
53520
|
+
`The ${driver} schedule storage driver requires a Visor Enterprise license with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`
|
|
53521
|
+
);
|
|
53522
|
+
}
|
|
53523
|
+
if (validator.isInGracePeriod()) {
|
|
53524
|
+
console.warn(
|
|
53525
|
+
"[visor:enterprise] License has expired but is within the 72-hour grace period. Please renew your license."
|
|
53526
|
+
);
|
|
53527
|
+
}
|
|
53528
|
+
const { KnexStoreBackend: KnexStoreBackend2 } = await Promise.resolve().then(() => (init_knex_store(), knex_store_exports));
|
|
53529
|
+
return new KnexStoreBackend2(driver, storageConfig, haConfig);
|
|
53530
|
+
}
|
|
53531
|
+
var init_loader = __esm({
|
|
53532
|
+
"src/enterprise/loader.ts"() {
|
|
53533
|
+
"use strict";
|
|
53534
|
+
init_default_engine();
|
|
53535
|
+
}
|
|
53536
|
+
});
|
|
53537
|
+
|
|
52280
53538
|
// src/event-bus/event-bus.ts
|
|
52281
53539
|
var event_bus_exports = {};
|
|
52282
53540
|
__export(event_bus_exports, {
|
|
@@ -53183,8 +54441,8 @@ ${content}
|
|
|
53183
54441
|
* Sleep utility
|
|
53184
54442
|
*/
|
|
53185
54443
|
sleep(ms) {
|
|
53186
|
-
return new Promise((
|
|
53187
|
-
const t = setTimeout(
|
|
54444
|
+
return new Promise((resolve15) => {
|
|
54445
|
+
const t = setTimeout(resolve15, ms);
|
|
53188
54446
|
if (typeof t.unref === "function") {
|
|
53189
54447
|
try {
|
|
53190
54448
|
t.unref();
|
|
@@ -53458,8 +54716,8 @@ ${end}`);
|
|
|
53458
54716
|
async updateGroupedComment(ctx, comments, group, changedIds) {
|
|
53459
54717
|
const existingLock = this.updateLocks.get(group);
|
|
53460
54718
|
let resolveLock;
|
|
53461
|
-
const ourLock = new Promise((
|
|
53462
|
-
resolveLock =
|
|
54719
|
+
const ourLock = new Promise((resolve15) => {
|
|
54720
|
+
resolveLock = resolve15;
|
|
53463
54721
|
});
|
|
53464
54722
|
this.updateLocks.set(group, ourLock);
|
|
53465
54723
|
try {
|
|
@@ -53771,7 +55029,7 @@ ${blocks}
|
|
|
53771
55029
|
* Sleep utility for enforcing delays
|
|
53772
55030
|
*/
|
|
53773
55031
|
sleep(ms) {
|
|
53774
|
-
return new Promise((
|
|
55032
|
+
return new Promise((resolve15) => setTimeout(resolve15, ms));
|
|
53775
55033
|
}
|
|
53776
55034
|
};
|
|
53777
55035
|
}
|
|
@@ -55042,15 +56300,15 @@ function serializeRunState(state) {
|
|
|
55042
56300
|
])
|
|
55043
56301
|
};
|
|
55044
56302
|
}
|
|
55045
|
-
var
|
|
56303
|
+
var path29, fs25, StateMachineExecutionEngine;
|
|
55046
56304
|
var init_state_machine_execution_engine = __esm({
|
|
55047
56305
|
"src/state-machine-execution-engine.ts"() {
|
|
55048
56306
|
"use strict";
|
|
55049
56307
|
init_runner();
|
|
55050
56308
|
init_logger();
|
|
55051
56309
|
init_sandbox_manager();
|
|
55052
|
-
|
|
55053
|
-
|
|
56310
|
+
path29 = __toESM(require("path"));
|
|
56311
|
+
fs25 = __toESM(require("fs"));
|
|
55054
56312
|
StateMachineExecutionEngine = class _StateMachineExecutionEngine {
|
|
55055
56313
|
workingDirectory;
|
|
55056
56314
|
executionContext;
|
|
@@ -55282,8 +56540,8 @@ var init_state_machine_execution_engine = __esm({
|
|
|
55282
56540
|
logger.debug(
|
|
55283
56541
|
`[PolicyEngine] Loading enterprise policy engine (engine=${configWithTagFilter.policy.engine})`
|
|
55284
56542
|
);
|
|
55285
|
-
const { loadEnterprisePolicyEngine } = await
|
|
55286
|
-
context2.policyEngine = await
|
|
56543
|
+
const { loadEnterprisePolicyEngine: loadEnterprisePolicyEngine2 } = await Promise.resolve().then(() => (init_loader(), loader_exports));
|
|
56544
|
+
context2.policyEngine = await loadEnterprisePolicyEngine2(configWithTagFilter.policy);
|
|
55287
56545
|
logger.debug(
|
|
55288
56546
|
`[PolicyEngine] Initialized: ${context2.policyEngine?.constructor?.name || "unknown"}`
|
|
55289
56547
|
);
|
|
@@ -55435,9 +56693,9 @@ var init_state_machine_execution_engine = __esm({
|
|
|
55435
56693
|
}
|
|
55436
56694
|
const checkId = String(ev?.checkId || "unknown");
|
|
55437
56695
|
const threadKey = ev?.threadKey || (channel && threadTs ? `${channel}:${threadTs}` : "session");
|
|
55438
|
-
const baseDir = process.env.VISOR_SNAPSHOT_DIR ||
|
|
55439
|
-
|
|
55440
|
-
const filePath =
|
|
56696
|
+
const baseDir = process.env.VISOR_SNAPSHOT_DIR || path29.resolve(process.cwd(), ".visor", "snapshots");
|
|
56697
|
+
fs25.mkdirSync(baseDir, { recursive: true });
|
|
56698
|
+
const filePath = path29.join(baseDir, `${threadKey}-${checkId}.json`);
|
|
55441
56699
|
await this.saveSnapshotToFile(filePath);
|
|
55442
56700
|
logger.info(`[Snapshot] Saved run snapshot: ${filePath}`);
|
|
55443
56701
|
try {
|
|
@@ -55578,7 +56836,7 @@ var init_state_machine_execution_engine = __esm({
|
|
|
55578
56836
|
* Does not include secrets. Intended for debugging and future resume support.
|
|
55579
56837
|
*/
|
|
55580
56838
|
async saveSnapshotToFile(filePath) {
|
|
55581
|
-
const
|
|
56839
|
+
const fs26 = await import("fs/promises");
|
|
55582
56840
|
const ctx = this._lastContext;
|
|
55583
56841
|
const runner = this._lastRunner;
|
|
55584
56842
|
if (!ctx || !runner) {
|
|
@@ -55598,14 +56856,14 @@ var init_state_machine_execution_engine = __esm({
|
|
|
55598
56856
|
journal: entries,
|
|
55599
56857
|
requestedChecks: ctx.requestedChecks || []
|
|
55600
56858
|
};
|
|
55601
|
-
await
|
|
56859
|
+
await fs26.writeFile(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
55602
56860
|
}
|
|
55603
56861
|
/**
|
|
55604
56862
|
* Load a snapshot JSON from file and return it. Resume support can build on this.
|
|
55605
56863
|
*/
|
|
55606
56864
|
async loadSnapshotFromFile(filePath) {
|
|
55607
|
-
const
|
|
55608
|
-
const raw = await
|
|
56865
|
+
const fs26 = await import("fs/promises");
|
|
56866
|
+
const raw = await fs26.readFile(filePath, "utf8");
|
|
55609
56867
|
return JSON.parse(raw);
|
|
55610
56868
|
}
|
|
55611
56869
|
/**
|