agentseal 0.6.1 → 0.8.1
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/agentseal.js +2954 -2367
- package/dist/chunk-23GC7G5P.js +635 -0
- package/dist/chunk-ZLRN7Q7C.js +27 -0
- package/dist/index.cjs +131 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.js +121 -4
- package/dist/index.js.map +1 -1
- package/dist/llm-judge-T6LDAZRQ.js +241 -0
- package/dist/machine-discovery-XIJE7CFD.js +22 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3129,6 +3129,7 @@ var AgentValidator = class _AgentValidator {
|
|
|
3129
3129
|
onProgress;
|
|
3130
3130
|
adaptive;
|
|
3131
3131
|
embed;
|
|
3132
|
+
customProbes;
|
|
3132
3133
|
constructor(options) {
|
|
3133
3134
|
this.agentFn = options.agentFn;
|
|
3134
3135
|
this.groundTruth = options.groundTruthPrompt;
|
|
@@ -3139,6 +3140,7 @@ var AgentValidator = class _AgentValidator {
|
|
|
3139
3140
|
this.onProgress = options.onProgress;
|
|
3140
3141
|
this.adaptive = options.adaptive ?? false;
|
|
3141
3142
|
this.embed = options.semantic?.embed;
|
|
3143
|
+
this.customProbes = options.probes;
|
|
3142
3144
|
}
|
|
3143
3145
|
// ── Factory methods ──────────────────────────────────────────────
|
|
3144
3146
|
static fromOpenAI(client, opts) {
|
|
@@ -3170,8 +3172,8 @@ var AgentValidator = class _AgentValidator {
|
|
|
3170
3172
|
const scanId = crypto.randomUUID().replace(/-/g, "").slice(0, 12);
|
|
3171
3173
|
const startTime = performance.now();
|
|
3172
3174
|
const allResults = [];
|
|
3173
|
-
const extractionProbes = buildExtractionProbes();
|
|
3174
|
-
const injectionProbes = buildInjectionProbes();
|
|
3175
|
+
const extractionProbes = this.customProbes ? this.customProbes.filter((p) => !p.canary) : buildExtractionProbes();
|
|
3176
|
+
const injectionProbes = this.customProbes ? this.customProbes.filter((p) => !!p.canary) : buildInjectionProbes();
|
|
3175
3177
|
const sem = semaphore(this.concurrency);
|
|
3176
3178
|
const icon = { blocked: "\u2713", leaked: "\u2717", partial: "\u25D0", error: "\u26A0" };
|
|
3177
3179
|
let extDone = 0;
|
|
@@ -7760,6 +7762,121 @@ var Shield = class {
|
|
|
7760
7762
|
this._watchers = [];
|
|
7761
7763
|
}
|
|
7762
7764
|
};
|
|
7765
|
+
var CONFIG_DIR = path.join(os.homedir(), ".agentseal");
|
|
7766
|
+
var DEFAULT_CONFIG_PATH = path.join(CONFIG_DIR, "config.json");
|
|
7767
|
+
var CONFIG_KEYS = [
|
|
7768
|
+
"model",
|
|
7769
|
+
"api-key",
|
|
7770
|
+
"ollama-url",
|
|
7771
|
+
"litellm-url",
|
|
7772
|
+
"dashboard-url",
|
|
7773
|
+
"dashboard-key"
|
|
7774
|
+
];
|
|
7775
|
+
function loadConfig(path = DEFAULT_CONFIG_PATH) {
|
|
7776
|
+
if (!fs.existsSync(path)) return {};
|
|
7777
|
+
return JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
7778
|
+
}
|
|
7779
|
+
function saveConfigKey(key, value, path$1 = DEFAULT_CONFIG_PATH) {
|
|
7780
|
+
const dir = path.dirname(path$1);
|
|
7781
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
7782
|
+
const cfg = loadConfig(path$1);
|
|
7783
|
+
cfg[key] = value;
|
|
7784
|
+
fs.writeFileSync(path$1, JSON.stringify(cfg, null, 2), { mode: 384 });
|
|
7785
|
+
fs.chmodSync(path$1, 384);
|
|
7786
|
+
}
|
|
7787
|
+
function removeConfigKey(key, path = DEFAULT_CONFIG_PATH) {
|
|
7788
|
+
const cfg = loadConfig(path);
|
|
7789
|
+
delete cfg[key];
|
|
7790
|
+
fs.writeFileSync(path, JSON.stringify(cfg, null, 2), { mode: 384 });
|
|
7791
|
+
fs.chmodSync(path, 384);
|
|
7792
|
+
}
|
|
7793
|
+
function showConfig(path = DEFAULT_CONFIG_PATH) {
|
|
7794
|
+
const cfg = loadConfig(path);
|
|
7795
|
+
if (Object.keys(cfg).length === 0) return "No configuration set.";
|
|
7796
|
+
return Object.entries(cfg).map(([k, v]) => {
|
|
7797
|
+
const display = k.includes("key") ? v.slice(0, 8) + "..." : v;
|
|
7798
|
+
return ` ${k}: ${display}`;
|
|
7799
|
+
}).join("\n");
|
|
7800
|
+
}
|
|
7801
|
+
var CONFIG_DIR2 = path.join(os.homedir(), ".agentseal");
|
|
7802
|
+
function saveCredentials(apiUrl, apiKey, path) {
|
|
7803
|
+
saveConfigKey("dashboard-url", apiUrl, path ?? DEFAULT_CONFIG_PATH);
|
|
7804
|
+
saveConfigKey("dashboard-key", apiKey, path ?? DEFAULT_CONFIG_PATH);
|
|
7805
|
+
}
|
|
7806
|
+
function loadCredentials(path) {
|
|
7807
|
+
const cfg = loadConfig(path ?? DEFAULT_CONFIG_PATH);
|
|
7808
|
+
if (!cfg["dashboard-url"] || !cfg["dashboard-key"]) return null;
|
|
7809
|
+
return { apiUrl: cfg["dashboard-url"], apiKey: cfg["dashboard-key"] };
|
|
7810
|
+
}
|
|
7811
|
+
function saveLicense(key, path$1 = path.join(CONFIG_DIR2, "license.json")) {
|
|
7812
|
+
const dir = path.dirname(path$1);
|
|
7813
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
7814
|
+
fs.writeFileSync(path$1, JSON.stringify({ key, activated: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), { mode: 384 });
|
|
7815
|
+
fs.chmodSync(path$1, 384);
|
|
7816
|
+
}
|
|
7817
|
+
function loadLicense(path$1 = path.join(CONFIG_DIR2, "license.json")) {
|
|
7818
|
+
if (!fs.existsSync(path$1)) return null;
|
|
7819
|
+
const data = JSON.parse(fs.readFileSync(path$1, "utf-8"));
|
|
7820
|
+
return data.key ?? null;
|
|
7821
|
+
}
|
|
7822
|
+
|
|
7823
|
+
// src/watch.ts
|
|
7824
|
+
var DEFAULT_CANARY_IDS = [
|
|
7825
|
+
"ext_direct_1",
|
|
7826
|
+
"ext_roleplay_1",
|
|
7827
|
+
"inj_override_1",
|
|
7828
|
+
"inj_delim_1",
|
|
7829
|
+
"inj_indirect_1"
|
|
7830
|
+
];
|
|
7831
|
+
function selectCanaryProbes(csv) {
|
|
7832
|
+
const allProbes = [...buildExtractionProbes(), ...buildInjectionProbes()];
|
|
7833
|
+
if (csv) {
|
|
7834
|
+
const ids = csv.split(",").map((s) => s.trim());
|
|
7835
|
+
return allProbes.filter((p) => ids.includes(p.probe_id));
|
|
7836
|
+
}
|
|
7837
|
+
return allProbes.filter((p) => DEFAULT_CANARY_IDS.includes(p.probe_id));
|
|
7838
|
+
}
|
|
7839
|
+
function checkRegression(currentScore, baselineScore, threshold = 5) {
|
|
7840
|
+
if (baselineScore === null) return { score: currentScore, baseline: null, regression: false, delta: 0 };
|
|
7841
|
+
const delta = baselineScore - currentScore;
|
|
7842
|
+
return { score: currentScore, baseline: baselineScore, regression: delta > threshold, delta };
|
|
7843
|
+
}
|
|
7844
|
+
|
|
7845
|
+
// src/scan-mcp-cli.ts
|
|
7846
|
+
function renderMCPResults(results, verbose) {
|
|
7847
|
+
const R = "\x1B[0m";
|
|
7848
|
+
const B = "\x1B[1m";
|
|
7849
|
+
const C = "\x1B[36m";
|
|
7850
|
+
const G = "\x1B[32m";
|
|
7851
|
+
const Y = "\x1B[33m";
|
|
7852
|
+
const RED = "\x1B[31m";
|
|
7853
|
+
const D = "\x1B[90m";
|
|
7854
|
+
console.log(`
|
|
7855
|
+
${C}${B}MCP Server Scan Results${R}
|
|
7856
|
+
`);
|
|
7857
|
+
for (const r of results) {
|
|
7858
|
+
const color = r.verdict === "safe" ? G : r.verdict === "warning" ? Y : RED;
|
|
7859
|
+
const score = r.trust_score !== void 0 ? ` (${r.trust_score}/100)` : "";
|
|
7860
|
+
console.log(` ${color}${r.verdict.toUpperCase()}${R} ${r.server_name}${score} \u2014 ${r.tools_count} tools`);
|
|
7861
|
+
if (verbose || r.verdict !== "safe") {
|
|
7862
|
+
for (const f of r.findings) {
|
|
7863
|
+
const sevColor = f.severity === "critical" || f.severity === "high" ? RED : f.severity === "medium" ? Y : D;
|
|
7864
|
+
console.log(` ${sevColor}${f.severity}${R} ${f.code}: ${f.title}`);
|
|
7865
|
+
}
|
|
7866
|
+
}
|
|
7867
|
+
}
|
|
7868
|
+
const dangers = results.filter((r) => r.verdict === "danger").length;
|
|
7869
|
+
const warnings = results.filter((r) => r.verdict === "warning").length;
|
|
7870
|
+
const safe = results.filter((r) => r.verdict === "safe").length;
|
|
7871
|
+
console.log(`
|
|
7872
|
+
${D}${"\u2500".repeat(50)}${R}`);
|
|
7873
|
+
const parts = [];
|
|
7874
|
+
if (dangers > 0) parts.push(`${RED}${B}${dangers} DANGER${R}`);
|
|
7875
|
+
if (warnings > 0) parts.push(`${Y}${B}${warnings} WARNING${R}`);
|
|
7876
|
+
parts.push(`${G}${B}${safe} SAFE${R}`);
|
|
7877
|
+
console.log(` ${parts.join(" ")}`);
|
|
7878
|
+
console.log();
|
|
7879
|
+
}
|
|
7763
7880
|
|
|
7764
7881
|
exports.AgentSealError = AgentSealError;
|
|
7765
7882
|
exports.AgentValidator = AgentValidator;
|
|
@@ -7769,6 +7886,7 @@ exports.BOUNDARY_WEIGHT = BOUNDARY_WEIGHT;
|
|
|
7769
7886
|
exports.BaselineStore = BaselineStore;
|
|
7770
7887
|
exports.Blocklist = Blocklist;
|
|
7771
7888
|
exports.COMMON_WORDS = COMMON_WORDS;
|
|
7889
|
+
exports.CONFIG_KEYS = CONFIG_KEYS;
|
|
7772
7890
|
exports.CONSISTENCY_WEIGHT = CONSISTENCY_WEIGHT;
|
|
7773
7891
|
exports.DANGER_CONCEPTS = DANGER_CONCEPTS;
|
|
7774
7892
|
exports.DATA_EXTRACTION_WEIGHT = DATA_EXTRACTION_WEIGHT;
|
|
@@ -7815,6 +7933,7 @@ exports.buildInjectionProbes = buildInjectionProbes;
|
|
|
7815
7933
|
exports.buildProbe = buildProbe;
|
|
7816
7934
|
exports.bulkCheck = bulkCheck;
|
|
7817
7935
|
exports.caseScramble = caseScramble;
|
|
7936
|
+
exports.checkRegression = checkRegression;
|
|
7818
7937
|
exports.classifyPath = classifyPath;
|
|
7819
7938
|
exports.classifyServer = classifyServer;
|
|
7820
7939
|
exports.collectWatchPaths = collectWatchPaths;
|
|
@@ -7863,8 +7982,11 @@ exports.leetspeak = leetspeak;
|
|
|
7863
7982
|
exports.listProfiles = listProfiles;
|
|
7864
7983
|
exports.listQuarantine = listQuarantine;
|
|
7865
7984
|
exports.loadAllCustomProbes = loadAllCustomProbes;
|
|
7985
|
+
exports.loadConfig = loadConfig;
|
|
7986
|
+
exports.loadCredentials = loadCredentials;
|
|
7866
7987
|
exports.loadCustomProbes = loadCustomProbes;
|
|
7867
7988
|
exports.loadGuardReport = loadGuardReport;
|
|
7989
|
+
exports.loadLicense = loadLicense;
|
|
7868
7990
|
exports.loadProjectConfig = loadProjectConfig;
|
|
7869
7991
|
exports.loadScanReport = loadScanReport;
|
|
7870
7992
|
exports.normalizeSkillPath = normalizeSkillPath;
|
|
@@ -7873,21 +7995,28 @@ exports.parseProbeFile = parseProbeFile;
|
|
|
7873
7995
|
exports.parseResponse = parseResponse;
|
|
7874
7996
|
exports.prefixPadding = prefixPadding;
|
|
7875
7997
|
exports.quarantineSkill = quarantineSkill;
|
|
7998
|
+
exports.removeConfigKey = removeConfigKey;
|
|
7999
|
+
exports.renderMCPResults = renderMCPResults;
|
|
7876
8000
|
exports.resolveProfile = resolveProfile;
|
|
7877
8001
|
exports.resolveProjectConfig = resolveProjectConfig;
|
|
7878
8002
|
exports.restoreSkill = restoreSkill;
|
|
7879
8003
|
exports.reverseEmbed = reverseEmbed;
|
|
7880
8004
|
exports.rot13Wrap = rot13Wrap;
|
|
7881
8005
|
exports.runGuardInit = runGuardInit;
|
|
8006
|
+
exports.saveConfigKey = saveConfigKey;
|
|
8007
|
+
exports.saveCredentials = saveCredentials;
|
|
8008
|
+
exports.saveLicense = saveLicense;
|
|
7882
8009
|
exports.saveReport = saveReport;
|
|
7883
8010
|
exports.scanDirectory = scanDirectory;
|
|
7884
8011
|
exports.scanMachine = scanMachine;
|
|
7885
8012
|
exports.scanSkillFile = scanSkillFile;
|
|
8013
|
+
exports.selectCanaryProbes = selectCanaryProbes;
|
|
7886
8014
|
exports.sha256 = sha256;
|
|
7887
8015
|
exports.shannonEntropy = shannonEntropy;
|
|
7888
8016
|
exports.shouldFail = shouldFail;
|
|
7889
8017
|
exports.shouldIgnoreFinding = shouldIgnoreFinding;
|
|
7890
8018
|
exports.shouldIgnorePath = shouldIgnorePath;
|
|
8019
|
+
exports.showConfig = showConfig;
|
|
7891
8020
|
exports.slugify = slugify;
|
|
7892
8021
|
exports.stripBidiControls = stripBidiControls;
|
|
7893
8022
|
exports.stripHtmlComments = stripHtmlComments;
|