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.
- package/CHANGELOG.md +64 -0
- package/README.md +63 -7
- package/package.json +8 -3
- package/src/agent-intent.js +807 -0
- package/src/agent-protocol.js +4 -0
- package/src/allowlist.js +605 -603
- package/src/audit-streaming.js +486 -469
- package/src/audit.js +1 -1
- package/src/behavior-profiling.js +299 -289
- package/src/behavioral-dna.js +4 -9
- package/src/canary.js +273 -271
- package/src/compliance.js +619 -617
- package/src/confidence-tuning.js +328 -324
- package/src/context-scoring.js +362 -360
- package/src/cost-optimizer.js +1024 -1024
- package/src/cross-turn.js +663 -0
- package/src/detector-core.js +186 -0
- package/src/distributed.js +5 -1
- package/src/embedding.js +310 -307
- package/src/ensemble.js +523 -0
- package/src/herd-immunity.js +12 -12
- package/src/honeypot.js +332 -328
- package/src/integrations.js +1 -2
- package/src/intent-firewall.js +14 -14
- package/src/llm-redteam.js +678 -670
- package/src/main.js +63 -0
- package/src/middleware.js +5 -2
- package/src/model-fingerprint.js +1059 -1042
- package/src/multi-agent-trust.js +459 -453
- package/src/multi-agent.js +1 -1
- package/src/normalizer.js +734 -0
- package/src/persistent-learning.js +677 -0
- package/src/pii.js +4 -0
- package/src/policy-dsl.js +775 -775
- package/src/presets.js +409 -409
- package/src/production.js +22 -9
- package/src/redteam.js +475 -475
- package/src/response-handler.js +436 -429
- package/src/scanners.js +358 -357
- package/src/self-healing.js +368 -363
- package/src/self-training.js +772 -0
- package/src/semantic.js +339 -339
- package/src/shield-score.js +250 -250
- package/src/smart-config.js +812 -0
- package/src/sso-saml.js +8 -4
- package/src/testing.js +24 -2
- package/src/tool-guard.js +412 -412
- package/src/watermark.js +242 -235
- package/src/worker-scanner.js +608 -601
- package/types/index.d.ts +660 -0
package/src/integrations.js
CHANGED
|
@@ -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.
|
|
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);
|
package/src/intent-firewall.js
CHANGED
|
@@ -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(
|
|
731
|
-
console.log(`
|
|
732
|
-
console.log(`
|
|
733
|
-
console.log(`
|
|
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(
|
|
753
|
-
console.log(`
|
|
754
|
-
console.log(`
|
|
755
|
-
console.log(`
|
|
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(
|
|
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
|
}
|