agentseal 0.8.1 → 0.9.0

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.cjs CHANGED
@@ -3129,7 +3129,6 @@ var AgentValidator = class _AgentValidator {
3129
3129
  onProgress;
3130
3130
  adaptive;
3131
3131
  embed;
3132
- customProbes;
3133
3132
  constructor(options) {
3134
3133
  this.agentFn = options.agentFn;
3135
3134
  this.groundTruth = options.groundTruthPrompt;
@@ -3140,7 +3139,6 @@ var AgentValidator = class _AgentValidator {
3140
3139
  this.onProgress = options.onProgress;
3141
3140
  this.adaptive = options.adaptive ?? false;
3142
3141
  this.embed = options.semantic?.embed;
3143
- this.customProbes = options.probes;
3144
3142
  }
3145
3143
  // ── Factory methods ──────────────────────────────────────────────
3146
3144
  static fromOpenAI(client, opts) {
@@ -3172,8 +3170,8 @@ var AgentValidator = class _AgentValidator {
3172
3170
  const scanId = crypto.randomUUID().replace(/-/g, "").slice(0, 12);
3173
3171
  const startTime = performance.now();
3174
3172
  const allResults = [];
3175
- const extractionProbes = this.customProbes ? this.customProbes.filter((p) => !p.canary) : buildExtractionProbes();
3176
- const injectionProbes = this.customProbes ? this.customProbes.filter((p) => !!p.canary) : buildInjectionProbes();
3173
+ const extractionProbes = buildExtractionProbes();
3174
+ const injectionProbes = buildInjectionProbes();
3177
3175
  const sem = semaphore(this.concurrency);
3178
3176
  const icon = { blocked: "\u2713", leaked: "\u2717", partial: "\u25D0", error: "\u26A0" };
3179
3177
  let extDone = 0;
@@ -7762,121 +7760,6 @@ var Shield = class {
7762
7760
  this._watchers = [];
7763
7761
  }
7764
7762
  };
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
- }
7880
7763
 
7881
7764
  exports.AgentSealError = AgentSealError;
7882
7765
  exports.AgentValidator = AgentValidator;
@@ -7886,7 +7769,6 @@ exports.BOUNDARY_WEIGHT = BOUNDARY_WEIGHT;
7886
7769
  exports.BaselineStore = BaselineStore;
7887
7770
  exports.Blocklist = Blocklist;
7888
7771
  exports.COMMON_WORDS = COMMON_WORDS;
7889
- exports.CONFIG_KEYS = CONFIG_KEYS;
7890
7772
  exports.CONSISTENCY_WEIGHT = CONSISTENCY_WEIGHT;
7891
7773
  exports.DANGER_CONCEPTS = DANGER_CONCEPTS;
7892
7774
  exports.DATA_EXTRACTION_WEIGHT = DATA_EXTRACTION_WEIGHT;
@@ -7933,7 +7815,6 @@ exports.buildInjectionProbes = buildInjectionProbes;
7933
7815
  exports.buildProbe = buildProbe;
7934
7816
  exports.bulkCheck = bulkCheck;
7935
7817
  exports.caseScramble = caseScramble;
7936
- exports.checkRegression = checkRegression;
7937
7818
  exports.classifyPath = classifyPath;
7938
7819
  exports.classifyServer = classifyServer;
7939
7820
  exports.collectWatchPaths = collectWatchPaths;
@@ -7982,11 +7863,8 @@ exports.leetspeak = leetspeak;
7982
7863
  exports.listProfiles = listProfiles;
7983
7864
  exports.listQuarantine = listQuarantine;
7984
7865
  exports.loadAllCustomProbes = loadAllCustomProbes;
7985
- exports.loadConfig = loadConfig;
7986
- exports.loadCredentials = loadCredentials;
7987
7866
  exports.loadCustomProbes = loadCustomProbes;
7988
7867
  exports.loadGuardReport = loadGuardReport;
7989
- exports.loadLicense = loadLicense;
7990
7868
  exports.loadProjectConfig = loadProjectConfig;
7991
7869
  exports.loadScanReport = loadScanReport;
7992
7870
  exports.normalizeSkillPath = normalizeSkillPath;
@@ -7995,28 +7873,21 @@ exports.parseProbeFile = parseProbeFile;
7995
7873
  exports.parseResponse = parseResponse;
7996
7874
  exports.prefixPadding = prefixPadding;
7997
7875
  exports.quarantineSkill = quarantineSkill;
7998
- exports.removeConfigKey = removeConfigKey;
7999
- exports.renderMCPResults = renderMCPResults;
8000
7876
  exports.resolveProfile = resolveProfile;
8001
7877
  exports.resolveProjectConfig = resolveProjectConfig;
8002
7878
  exports.restoreSkill = restoreSkill;
8003
7879
  exports.reverseEmbed = reverseEmbed;
8004
7880
  exports.rot13Wrap = rot13Wrap;
8005
7881
  exports.runGuardInit = runGuardInit;
8006
- exports.saveConfigKey = saveConfigKey;
8007
- exports.saveCredentials = saveCredentials;
8008
- exports.saveLicense = saveLicense;
8009
7882
  exports.saveReport = saveReport;
8010
7883
  exports.scanDirectory = scanDirectory;
8011
7884
  exports.scanMachine = scanMachine;
8012
7885
  exports.scanSkillFile = scanSkillFile;
8013
- exports.selectCanaryProbes = selectCanaryProbes;
8014
7886
  exports.sha256 = sha256;
8015
7887
  exports.shannonEntropy = shannonEntropy;
8016
7888
  exports.shouldFail = shouldFail;
8017
7889
  exports.shouldIgnoreFinding = shouldIgnoreFinding;
8018
7890
  exports.shouldIgnorePath = shouldIgnorePath;
8019
- exports.showConfig = showConfig;
8020
7891
  exports.slugify = slugify;
8021
7892
  exports.stripBidiControls = stripBidiControls;
8022
7893
  exports.stripHtmlComments = stripHtmlComments;