agentshield-sdk 7.3.0 → 8.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 (50) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +63 -7
  3. package/package.json +8 -3
  4. package/src/agent-intent.js +807 -0
  5. package/src/agent-protocol.js +4 -0
  6. package/src/allowlist.js +605 -603
  7. package/src/audit-streaming.js +486 -469
  8. package/src/audit.js +1 -1
  9. package/src/behavior-profiling.js +299 -289
  10. package/src/behavioral-dna.js +4 -9
  11. package/src/canary.js +273 -271
  12. package/src/compliance.js +619 -617
  13. package/src/confidence-tuning.js +328 -324
  14. package/src/context-scoring.js +362 -360
  15. package/src/cost-optimizer.js +1024 -1024
  16. package/src/cross-turn.js +663 -0
  17. package/src/detector-core.js +186 -0
  18. package/src/distributed.js +5 -1
  19. package/src/embedding.js +310 -307
  20. package/src/ensemble.js +523 -0
  21. package/src/herd-immunity.js +12 -12
  22. package/src/honeypot.js +332 -328
  23. package/src/integrations.js +1 -2
  24. package/src/intent-firewall.js +14 -14
  25. package/src/llm-redteam.js +678 -670
  26. package/src/main.js +63 -0
  27. package/src/middleware.js +5 -2
  28. package/src/model-fingerprint.js +1059 -1042
  29. package/src/multi-agent-trust.js +459 -453
  30. package/src/multi-agent.js +1 -1
  31. package/src/normalizer.js +734 -0
  32. package/src/persistent-learning.js +677 -0
  33. package/src/pii.js +4 -0
  34. package/src/policy-dsl.js +775 -775
  35. package/src/presets.js +409 -409
  36. package/src/production.js +22 -9
  37. package/src/redteam.js +475 -475
  38. package/src/response-handler.js +436 -429
  39. package/src/scanners.js +358 -357
  40. package/src/self-healing.js +368 -363
  41. package/src/self-training.js +772 -0
  42. package/src/semantic.js +339 -339
  43. package/src/shield-score.js +250 -250
  44. package/src/smart-config.js +812 -0
  45. package/src/sso-saml.js +8 -4
  46. package/src/testing.js +24 -2
  47. package/src/tool-guard.js +412 -412
  48. package/src/watermark.js +242 -235
  49. package/src/worker-scanner.js +608 -601
  50. package/types/index.d.ts +660 -0
@@ -85,7 +85,7 @@ class ShieldCallbackHandler {
85
85
  const text = typeof output === 'string' ? output : JSON.stringify(output);
86
86
  if (!text) return;
87
87
 
88
- const result = this.shield.scanInput(text);
88
+ const result = this.shield.scanOutput(text);
89
89
  if (result.threats.length > 0 && this.onThreat) {
90
90
  try { this.onThreat({ phase: 'tool_output', threats: result.threats, text }); } catch (e) { console.error('[Agent Shield] onThreat callback error:', e.message); }
91
91
  }
@@ -384,7 +384,6 @@ function shieldOpenAIClient(client, options = {}) {
384
384
  }
385
385
 
386
386
  // Scan tool calls in response
387
- const toolCalls = choice?.message?.tool_calls || choice?.message?.function_call ? [choice.message.function_call] : [];
388
387
  for (const tc of (choice?.message?.tool_calls || [])) {
389
388
  if (tc.function && tc.function.arguments) {
390
389
  const argsResult = shield.scanInput(tc.function.arguments);
@@ -689,7 +689,7 @@ function intentDemo() {
689
689
  const firewall = new IntentFirewall();
690
690
 
691
691
  console.log('[Agent Shield] Intent Firewall Demo');
692
- console.log('='.repeat(60));
692
+ console.log('[Agent Shield] ' + '='.repeat(60));
693
693
 
694
694
  const testCases = [
695
695
  {
@@ -727,18 +727,18 @@ function intentDemo() {
727
727
  );
728
728
  const symbol = action === 'BLOCKED' ? '[X]' : action === 'FLAG' ? '[?]' : '[OK]';
729
729
 
730
- console.log(`\n${symbol} "${tc.text}"`);
731
- console.log(` Intent: ${result.intent} (confidence: ${result.confidence})`);
732
- console.log(` Action: ${action}`);
733
- console.log(` Reason: ${result.reason}`);
730
+ console.log(`[Agent Shield] \n${symbol} "${tc.text}"`);
731
+ console.log(`[Agent Shield] Intent: ${result.intent} (confidence: ${result.confidence})`);
732
+ console.log(`[Agent Shield] Action: ${action}`);
733
+ console.log(`[Agent Shield] Reason: ${result.reason}`);
734
734
 
735
735
  results.push({ input: tc.text, ...result, action });
736
736
  }
737
737
 
738
738
  // Multi-turn demo
739
- console.log('\n' + '='.repeat(60));
740
- console.log('Multi-turn manipulation detection:');
741
- console.log('='.repeat(60));
739
+ console.log('[Agent Shield] \n' + '='.repeat(60));
740
+ console.log('[Agent Shield] Multi-turn manipulation detection:');
741
+ console.log('[Agent Shield] ' + '='.repeat(60));
742
742
 
743
743
  const conversation = [
744
744
  { role: 'user', content: 'You are so helpful, thank you!' },
@@ -749,13 +749,13 @@ function intentDemo() {
749
749
  ];
750
750
 
751
751
  const contextResult = firewall.classifyWithContext(conversation);
752
- console.log(`\n[X] Multi-turn escalation after trust-building`);
753
- console.log(` Intent: ${contextResult.intent} (confidence: ${contextResult.confidence})`);
754
- console.log(` Blocked: ${contextResult.blocked}`);
755
- console.log(` Reason: ${contextResult.reason}`);
752
+ console.log(`[Agent Shield] \n[X] Multi-turn escalation after trust-building`);
753
+ console.log(`[Agent Shield] Intent: ${contextResult.intent} (confidence: ${contextResult.confidence})`);
754
+ console.log(`[Agent Shield] Blocked: ${contextResult.blocked}`);
755
+ console.log(`[Agent Shield] Reason: ${contextResult.reason}`);
756
756
 
757
- console.log(`\n${'-'.repeat(60)}`);
758
- console.log(`Stats: ${JSON.stringify(firewall.getStats(), null, 2)}`);
757
+ console.log(`[Agent Shield] \n${'-'.repeat(60)}`);
758
+ console.log(`[Agent Shield] Stats: ${JSON.stringify(firewall.getStats(), null, 2)}`);
759
759
 
760
760
  return results;
761
761
  }