agentshield-sdk 8.0.0 → 10.0.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +21 -21
  3. package/README.md +26 -60
  4. package/bin/agentshield-audit +51 -0
  5. package/package.json +7 -10
  6. package/src/adaptive.js +330 -330
  7. package/src/alert-tuning.js +480 -480
  8. package/src/audit-streaming.js +1 -1
  9. package/src/badges.js +196 -196
  10. package/src/behavioral-dna.js +12 -0
  11. package/src/canary.js +2 -3
  12. package/src/certification.js +563 -563
  13. package/src/circuit-breaker.js +2 -2
  14. package/src/confused-deputy.js +4 -0
  15. package/src/conversation.js +494 -494
  16. package/src/cross-turn.js +3 -17
  17. package/src/ctf.js +462 -462
  18. package/src/detector-core.js +71 -152
  19. package/src/document-scanner.js +795 -795
  20. package/src/drift-monitor.js +344 -0
  21. package/src/encoding.js +429 -429
  22. package/src/enterprise.js +405 -405
  23. package/src/flight-recorder.js +2 -0
  24. package/src/i18n-patterns.js +523 -523
  25. package/src/index.js +19 -0
  26. package/src/main.js +61 -41
  27. package/src/mcp-guard.js +974 -0
  28. package/src/micro-model.js +762 -0
  29. package/src/ml-detector.js +316 -0
  30. package/src/model-finetuning.js +884 -884
  31. package/src/multimodal.js +296 -296
  32. package/src/nist-mapping.js +2 -2
  33. package/src/observability.js +330 -330
  34. package/src/openclaw.js +450 -450
  35. package/src/otel.js +544 -544
  36. package/src/owasp-2025.js +1 -1
  37. package/src/owasp-agentic.js +420 -0
  38. package/src/plugin-marketplace.js +628 -628
  39. package/src/plugin-system.js +349 -349
  40. package/src/policy-extended.js +635 -635
  41. package/src/policy.js +443 -443
  42. package/src/prompt-leakage.js +2 -2
  43. package/src/real-attack-datasets.js +2 -2
  44. package/src/redteam-cli.js +439 -0
  45. package/src/supply-chain-scanner.js +691 -0
  46. package/src/testing.js +5 -1
  47. package/src/threat-encyclopedia.js +629 -629
  48. package/src/threat-intel-network.js +1017 -1017
  49. package/src/token-analysis.js +467 -467
  50. package/src/tool-output-validator.js +354 -354
  51. package/src/watermark.js +1 -2
package/CHANGELOG.md CHANGED
@@ -4,6 +4,25 @@ All notable changes to Agent Shield will be documented in this file.
4
4
 
5
5
  This project follows [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [9.0.0] - 2026-03-24
8
+
9
+ ### Changed — Everything Free
10
+
11
+ - **Removed all paid tier gating** — every feature is now free and open source
12
+ - **ML detection available to all users** — previously required Pro/Enterprise tier
13
+ - **Removed license key system** — no keys, no validation, no restrictions
14
+ - **Merged agentshield-pro features into core SDK** — ensemble, persistent learning, agent intent, cross-turn tracking, self-training, all included
15
+ - All compliance modules (SOC2, OWASP, NIST, EU AI Act) available to everyone
16
+ - All enterprise modules (distributed scanning, SSO, audit streaming) available to everyone
17
+ - CORTEX autonomous defense available to everyone
18
+ - Updated README, ROADMAP, CLAUDE.md for v9.0.0
19
+
20
+ ### Metrics
21
+
22
+ - **2,220+ test assertions** across 16 test suites + Python + VSCode
23
+ - **0 regressions** — all existing tests pass
24
+ - **400+ exports** across 94 modules
25
+
7
26
  ## [8.0.0] - 2026-03-22
8
27
 
9
28
  ### Added — Intelligent Detection Engine
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Agent Shield Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agent Shield Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,17 +1,17 @@
1
1
  # Agent Shield
2
2
 
3
- [![npm version](https://img.shields.io/badge/npm-v8.0.0-blue)](https://www.npmjs.com/package/agentshield-sdk)
3
+ [![npm version](https://img.shields.io/badge/npm-v9.0.0-blue)](https://www.npmjs.com/package/agentshield-sdk)
4
4
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
5
5
  [![zero deps](https://img.shields.io/badge/dependencies-0-brightgreen)](#)
6
6
  [![node](https://img.shields.io/badge/node-%3E%3D16-blue)](#)
7
7
  [![shield score](https://img.shields.io/badge/shield%20score-100%2F100%20A%2B-brightgreen)](#benchmark-results)
8
8
  [![detection](https://img.shields.io/badge/detection-100%25-brightgreen)](#benchmark-results)
9
- [![F1](https://img.shields.io/badge/F1%20score-100%25-brightgreen)](#benchmark-results)
10
- [![tests](https://img.shields.io/badge/tests-2500%2B%20passing-brightgreen)](#testing)
9
+ [![tests](https://img.shields.io/badge/tests-2220%20passing-brightgreen)](#testing)
10
+ [![free](https://img.shields.io/badge/every%20feature-free-brightgreen)](#why-free)
11
11
 
12
- **The security standard for MCP and AI agents.** Protect your agents from prompt injection, confused deputy attacks, data exfiltration, privilege escalation, and 30+ other AI-specific threats.
12
+ **The complete security standard for AI agents.** 400+ exports. 94 modules. Every feature free. Protect your agents from prompt injection, confused deputy attacks, data exfiltration, privilege escalation, and 30+ other AI-specific threats.
13
13
 
14
- Zero dependencies. All detection runs locally. No API keys. No data ever leaves your environment.
14
+ Zero dependencies. All detection runs locally. No API keys. No tiers. No data ever leaves your environment.
15
15
 
16
16
  Available for **Node.js**, **Python**, **Go**, **Rust**, and in-browser via **WASM**.
17
17
 
@@ -23,52 +23,11 @@ Available for **Node.js**, **Python**, **Go**, **Rust**, and in-browser via **WA
23
23
  <b>Try it yourself:</b> <code>npx agent-shield demo</code>
24
24
  </p>
25
25
 
26
- ## v7.4 — Detection Hardening & Normalization
27
26
 
28
- **F1 score: 100%.** 21 new detection patterns for prompt extraction, instruction override, and authority spoofing — validated against HackAPrompt, TensorTrust, and security research datasets with zero false positives.
29
-
30
- New **text normalization pipeline** strips obfuscation before scanning: Unicode canonicalization, homoglyph mapping, encoding decode (Base64/hex/URL/HTML entities), leet speak, invisible character removal, whitespace normalization, repetition collapse, and markdown stripping.
31
-
32
- **50-cycle bug hunt** fixed 30+ real bugs across all 50 source modules: memory leaks, spin-waits, falsy-zero defaults, self-matching detection, cache collisions, unbounded growth, and hot-path optimizations.
33
-
34
- ```javascript
35
- const { normalize } = require('agentshield-sdk');
36
-
37
- // 8-layer normalization pipeline
38
- const result = normalize('ℹ𝗀𝗇𝗈𝗋𝖾 𝖺𝗅𝗅 ᎥnstructᎥons');
39
- // { normalized: 'ignore all instructions', layers: ['unicode_canon', 'homoglyph'] }
40
-
41
- // Normalization is automatic — scanText runs it behind the scenes
42
- const { scanText } = require('agentshield-sdk');
43
- scanText('ℹ𝗀𝗇𝗈𝗋𝖾 𝖺𝗅𝗅 ᎥnstructᎥons'); // Detected! (after normalization)
44
- ```
45
-
46
- ---
47
-
48
- ## v8.0 — Intelligent Detection Engine
49
-
50
- **Your agent gets smarter over time.** Ensemble voting combines 4 detection signals. Declare your agent's purpose and detect goal drift. Persistent learning saves patterns to disk. Cross-turn tracking catches split injections. Adversarial self-training hardens defenses automatically.
51
-
52
- ```javascript
53
- const { createShield } = require('agentshield-sdk');
54
-
55
- // 3-line setup with smart defaults
56
- const shield = createShield('rag_pipeline');
57
-
58
- // Or configure everything
59
- const { createShield } = require('agentshield-sdk');
60
- const config = createShield()
61
- .preset('coding_agent')
62
- .enableIntent({ purpose: 'Help users write code' })
63
- .enableLearning({ persist: true })
64
- .enableEnsemble()
65
- .enableCrossTurn()
66
- .build();
67
- ```
68
27
 
69
28
  ---
70
29
 
71
- ## v7.2 — Indirect Prompt Injection Detection
30
+ ## Indirect Prompt Injection Detection
72
31
 
73
32
  **Stop attacks hidden in RAG chunks, tool outputs, emails, and documents.** The IPIA detector implements the joint-context embedding + classifier pipeline to catch injections that bypass pattern matching.
74
33
 
@@ -100,7 +59,7 @@ const result2 = await detector2.scanAsync(chunk, query);
100
59
 
101
60
  ---
102
61
 
103
- ## v7.0 — MCP Security Runtime
62
+ ## MCP Security Runtime
104
63
 
105
64
  **One line to secure any MCP server.** The unified security layer that connects per-user authorization, threat scanning, behavioral monitoring, and audit logging into a single runtime.
106
65
 
@@ -200,8 +159,8 @@ const shield = new AgentShield({ blockOnThreat: true });
200
159
  const result = shield.scanInput(userMessage); // { blocked: true, threats: [...] }
201
160
  ```
202
161
 
203
- - 395+ exports across 94 modules
204
- - 2,500+ test assertions across 18 test suites, 100% pass rate
162
+ - 400+ exports across 94 modules
163
+ - 2,220 test assertions across 16 test suites + Python + VSCode, 100% pass rate
205
164
  - 100% red team detection rate (A+ grade)
206
165
  - F1 100% on real-world attack benchmarks (HackAPrompt, TensorTrust, research corpus)
207
166
  - Shield Score: 100/100 — fortress-grade protection
@@ -443,7 +402,7 @@ validator.validate(plugin); // Safety & quality validation
443
402
 
444
403
  The `vscode-extension/` directory contains a VS Code extension that provides inline diagnostics and real-time scanning for JS/TS/Python/Markdown files with 141 detection patterns.
445
404
 
446
- ### Enterprise Features (v2.1)
405
+ ### Distributed & Multi-Tenant (v2.1)
447
406
 
448
407
  ```javascript
449
408
  const { DistributedShield, AuditStreamManager, SSOManager, MultiTenantShield } = require('agent-shield');
@@ -955,12 +914,13 @@ npx agent-shield dashboard # Security dashboard
955
914
  ```bash
956
915
  npm test # Core + module tests (248 assertions)
957
916
  npm run test:all # Full 40-feature suite (149 assertions)
917
+ npm run test:ml # ML detector tests (37 assertions)
958
918
  npm run test:ipia # IPIA detector tests (117 assertions)
959
- npm run test:normalizer # Text normalization pipeline (73 assertions)
960
- npm run test:scorecard # Real-world benchmark scorecard (F1, MCC, per-dataset)
961
- npm run test:edge # Edge case coverage (unicode, long inputs, thresholds)
962
- node test/test-v6-modules.js # v6.0 compliance & standards (122 assertions)
963
- node test/test-confused-deputy.js # Confused deputy prevention (85 assertions)
919
+ npm run test:mcp # MCP security runtime tests (112 assertions)
920
+ npm run test:v6 # v6.0 compliance & standards (122 assertions)
921
+ npm run test:adaptive # Adaptive defense tests (85 assertions)
922
+ npm run test:deputy # Confused deputy prevention (85 assertions)
923
+ npm run test:fp # False positive accuracy (99.2%)
964
924
  npm run redteam # Attack simulation (100% detection)
965
925
  npm run score # Shield Score (100/100 A+)
966
926
  npm run benchmark # Performance benchmarks
@@ -971,17 +931,17 @@ Sub-project tests:
971
931
  node dashboard-live/test/test-server.js # Dashboard (14 tests)
972
932
  node github-app/test/test-scanner.js # GitHub App (20 tests)
973
933
  node benchmark-registry/test/test-registry.js # Benchmarks (22 tests)
974
- node vscode-extension/test/extension.test.js # VS Code (167 tests)
975
- cd python-sdk && python -m unittest tests/test_detector.py # Python (23 tests)
934
+ node vscode-extension/test/extension.test.js # VS Code (607 tests)
935
+ cd python-sdk && python -m unittest tests/test_detector.py # Python (32 tests)
976
936
  ```
977
937
 
978
- Total: **2,500+ test assertions** across 18 test suites.
938
+ Total: **2,220 test assertions** across 16 test suites + Python + VSCode.
979
939
 
980
940
  ## Project Structure
981
941
 
982
942
  ```
983
943
  /
984
- ├── src/ # Node.js SDK (395 exports)
944
+ ├── src/ # Node.js SDK (400+ exports, 94 modules)
985
945
  │ ├── index.js # AgentShield class — main entry point
986
946
  │ ├── main.js # Unified re-export of all modules
987
947
  │ ├── detector-core.js # Core detection engine (patterns, scanning)
@@ -1089,6 +1049,12 @@ console.log(report.formatReport());
1089
1049
 
1090
1050
  A GitHub Actions workflow is included at `.github/workflows/ci.yml`. It runs all tests across Node.js 18, 20, and 22 on every push and PR.
1091
1051
 
1052
+ ## Why Free?
1053
+
1054
+ Agent Shield started as a paid SDK with Pro and Enterprise tiers. We removed all gating in v9.0. Every feature — ML detection, compliance reporting, MCP security, CORTEX autonomous defense — is now free and open source.
1055
+
1056
+ Security shouldn't have a paywall. If your agent is vulnerable, it doesn't matter what tier you're on.
1057
+
1092
1058
  ## Privacy
1093
1059
 
1094
1060
  All detection runs locally using pattern matching. No data is sent to any external service. No API keys required. No cloud dependencies. See [PRIVACY.md](PRIVACY.md) for details.
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * Agent Shield — Red Team Audit CLI
6
+ *
7
+ * Usage:
8
+ * npx agentshield-audit <endpoint> [--mode quick|standard|full] [--out dir]
9
+ */
10
+
11
+ const { RedTeamCLI } = require('../src/redteam-cli');
12
+
13
+ function parseArgs(argv) {
14
+ const args = { endpoint: null, mode: 'standard', out: process.cwd() };
15
+ const values = argv.slice(2);
16
+ args.endpoint = values[0];
17
+ for (let i = 1; i < values.length; i++) {
18
+ if (values[i] === '--mode' && values[i + 1]) {
19
+ args.mode = values[i + 1];
20
+ i++;
21
+ } else if (values[i] === '--out' && values[i + 1]) {
22
+ args.out = values[i + 1];
23
+ i++;
24
+ }
25
+ }
26
+ return args;
27
+ }
28
+
29
+ function main() {
30
+ const args = parseArgs(process.argv);
31
+ if (!args.endpoint) {
32
+ console.error('Usage: npx agentshield-audit <endpoint> [--mode quick|standard|full] [--out dir]');
33
+ process.exit(1);
34
+ }
35
+
36
+ const cli = new RedTeamCLI();
37
+ const report = cli.run(args.endpoint, { mode: args.mode });
38
+ const files = cli.writeReports(report, args.out);
39
+
40
+ console.log(`[Agent Shield] Grade ${report.grade} (${report.score}/100) for ${report.endpoint}`);
41
+ console.log(`[Agent Shield] ${report.blocked}/${report.attackCount} attacks blocked`);
42
+ console.log(`[Agent Shield] JSON report: ${files.jsonPath}`);
43
+ console.log(`[Agent Shield] Markdown report: ${files.mdPath}`);
44
+ console.log(`[Agent Shield] HTML report: ${files.htmlPath}`);
45
+
46
+ if (report.grade === 'F' || (report.supplyChain && report.supplyChain.highestSeverity === 'critical')) {
47
+ process.exit(2);
48
+ }
49
+ }
50
+
51
+ main();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentshield-sdk",
3
- "version": "8.0.0",
4
- "description": "The security standard for MCP and AI agents. 162 detection patterns, ensemble voting, agent intent declaration, persistent learning, text normalization, CORTEX threat intelligence, and 418+ exports. Zero dependencies, runs locally.",
3
+ "version": "10.0.0",
4
+ "description": "The security standard for MCP and AI agents. 141 detection patterns, CORTEX threat intelligence, pre-deployment audit, intent firewall, flight recorder, and 390+ exports. Zero dependencies, runs locally.",
5
5
  "main": "src/main.js",
6
6
  "types": "types/index.d.ts",
7
7
  "exports": {
@@ -18,23 +18,21 @@
18
18
  "./package.json": "./package.json"
19
19
  },
20
20
  "bin": {
21
- "agent-shield": "bin/agent-shield.js"
21
+ "agent-shield": "bin/agent-shield.js",
22
+ "agentshield-audit": "bin/agentshield-audit"
22
23
  },
23
24
  "sideEffects": false,
24
25
  "scripts": {
25
- "test": "node test/test.js && node test/test-modules.js && node test/test-new-features.js",
26
+ "test": "node test/test.js && node test/test-modules.js && node test/test-new-features.js && node test/test-mcp-guard.js && node test/test-supply-chain-scanner.js && node test/test-owasp-agentic.js && node test/test-redteam-cli.js && node test/test-drift-monitor.js && node test/test-micro-model.js",
27
+ "test:new-products": "node test/test-mcp-guard.js && node test/test-supply-chain-scanner.js && node test/test-owasp-agentic.js && node test/test-redteam-cli.js && node test/test-drift-monitor.js && node test/test-micro-model.js",
26
28
  "test:all": "node test/test-all-40-features.js",
27
29
  "test:mcp": "node test/test-mcp-security.js",
28
30
  "test:deputy": "node test/test-confused-deputy.js",
29
31
  "test:v6": "node test/test-v6-modules.js",
30
32
  "test:adaptive": "node test/test-adaptive-defense.js",
31
33
  "test:ipia": "node test/test-ipia-detector.js",
32
- "test:normalizer": "node test/test-normalizer.js",
33
- "test:scorecard": "node test/benchmark-scorecard.js",
34
- "test:edge": "node test/test-edge-cases.js",
35
34
  "test:production": "node test/test-production-readiness.js",
36
- "test:v8": "node test/test-v8-features.js",
37
- "test:full": "npm test && node test/test-mcp-security.js && node test/test-confused-deputy.js && node test/test-v6-modules.js && node test/test-adaptive-defense.js && node test/test-ipia-detector.js && node test/test-production-readiness.js && node test/test-normalizer.js && node test/test-edge-cases.js && node test/benchmark-scorecard.js && node test/test-v8-features.js && npm run test:all",
35
+ "test:full": "npm test && node test/test-mcp-security.js && node test/test-confused-deputy.js && node test/test-v6-modules.js && node test/test-adaptive-defense.js && node test/test-ipia-detector.js && node test/test-production-readiness.js && npm run test:all",
38
36
  "test:coverage": "c8 --reporter=text --reporter=lcov --reporter=json-summary npm test",
39
37
  "lint": "node test/lint.js",
40
38
  "lint:eslint": "eslint src/ test/ bin/",
@@ -56,7 +54,6 @@
56
54
  "demo": "node bin/agent-shield.js demo",
57
55
  "playground": "echo 'Open playground/index.html in a browser'",
58
56
  "certify": "node -e \"const {CertificationRunner}=require('./src/certification');new CertificationRunner().runCertification().then(r=>console.log(r.certificate.toText()))\"",
59
- "benchmark:scorecard": "node test/benchmark-scorecard.js",
60
57
  "benchmark:run": "node scripts/run-benchmark.js",
61
58
  "benchmark:generate": "node scripts/generate-dataset.js",
62
59
  "benchmark:baseline": "node scripts/run-benchmark.js --save-baseline",