@auxiora/guardrails 1.10.1 → 1.10.6
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.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/metrics.d.ts +35 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +71 -0
- package/dist/metrics.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export { PiiDetector } from './pii-detector.js';
|
|
|
3
3
|
export { InjectionDetector } from './injection-detector.js';
|
|
4
4
|
export { ToxicityFilter } from './toxicity-filter.js';
|
|
5
5
|
export { GuardrailPipeline } from './guardrail-pipeline.js';
|
|
6
|
+
export { GuardrailMetrics } from './metrics.js';
|
|
7
|
+
export type { GuardrailStats } from './metrics.js';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,MAAM,EACN,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,MAAM,EACN,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { PiiDetector } from './pii-detector.js';
|
|
|
2
2
|
export { InjectionDetector } from './injection-detector.js';
|
|
3
3
|
export { ToxicityFilter } from './toxicity-filter.js';
|
|
4
4
|
export { GuardrailPipeline } from './guardrail-pipeline.js';
|
|
5
|
+
export { GuardrailMetrics } from './metrics.js';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ScanResult, ThreatLevel } from './types.js';
|
|
2
|
+
export interface GuardrailStats {
|
|
3
|
+
totalScans: number;
|
|
4
|
+
inputScans: number;
|
|
5
|
+
outputScans: number;
|
|
6
|
+
totalThreats: number;
|
|
7
|
+
threatsByType: Record<string, number>;
|
|
8
|
+
threatsByLevel: Partial<Record<ThreatLevel, number>>;
|
|
9
|
+
actionCounts: Record<string, number>;
|
|
10
|
+
blockedCount: number;
|
|
11
|
+
redactedCount: number;
|
|
12
|
+
lastScanAt: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class GuardrailMetrics {
|
|
15
|
+
private totalScans;
|
|
16
|
+
private inputScans;
|
|
17
|
+
private outputScans;
|
|
18
|
+
private totalThreats;
|
|
19
|
+
private threatsByType;
|
|
20
|
+
private threatsByLevel;
|
|
21
|
+
private actionCounts;
|
|
22
|
+
private blockedCount;
|
|
23
|
+
private redactedCount;
|
|
24
|
+
private lastScanAt;
|
|
25
|
+
/** Record an input scan result */
|
|
26
|
+
recordInputScan(result: ScanResult): void;
|
|
27
|
+
/** Record an output scan result */
|
|
28
|
+
recordOutputScan(result: ScanResult): void;
|
|
29
|
+
/** Get current stats snapshot */
|
|
30
|
+
getStats(): GuardrailStats;
|
|
31
|
+
/** Reset all counters */
|
|
32
|
+
reset(): void;
|
|
33
|
+
private recordScanResult;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,UAAU,CAAK;IAEvB,kCAAkC;IAClC,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAMzC,mCAAmC;IACnC,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAM1C,iCAAiC;IACjC,QAAQ,IAAI,cAAc;IAe1B,yBAAyB;IACzB,KAAK,IAAI,IAAI;IAab,OAAO,CAAC,gBAAgB;CAmBzB"}
|
package/dist/metrics.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export class GuardrailMetrics {
|
|
2
|
+
totalScans = 0;
|
|
3
|
+
inputScans = 0;
|
|
4
|
+
outputScans = 0;
|
|
5
|
+
totalThreats = 0;
|
|
6
|
+
threatsByType = new Map();
|
|
7
|
+
threatsByLevel = new Map();
|
|
8
|
+
actionCounts = new Map();
|
|
9
|
+
blockedCount = 0;
|
|
10
|
+
redactedCount = 0;
|
|
11
|
+
lastScanAt = 0;
|
|
12
|
+
/** Record an input scan result */
|
|
13
|
+
recordInputScan(result) {
|
|
14
|
+
this.totalScans++;
|
|
15
|
+
this.inputScans++;
|
|
16
|
+
this.recordScanResult(result);
|
|
17
|
+
}
|
|
18
|
+
/** Record an output scan result */
|
|
19
|
+
recordOutputScan(result) {
|
|
20
|
+
this.totalScans++;
|
|
21
|
+
this.outputScans++;
|
|
22
|
+
this.recordScanResult(result);
|
|
23
|
+
}
|
|
24
|
+
/** Get current stats snapshot */
|
|
25
|
+
getStats() {
|
|
26
|
+
return {
|
|
27
|
+
totalScans: this.totalScans,
|
|
28
|
+
inputScans: this.inputScans,
|
|
29
|
+
outputScans: this.outputScans,
|
|
30
|
+
totalThreats: this.totalThreats,
|
|
31
|
+
threatsByType: Object.fromEntries(this.threatsByType),
|
|
32
|
+
threatsByLevel: Object.fromEntries(this.threatsByLevel),
|
|
33
|
+
actionCounts: Object.fromEntries(this.actionCounts),
|
|
34
|
+
blockedCount: this.blockedCount,
|
|
35
|
+
redactedCount: this.redactedCount,
|
|
36
|
+
lastScanAt: this.lastScanAt,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Reset all counters */
|
|
40
|
+
reset() {
|
|
41
|
+
this.totalScans = 0;
|
|
42
|
+
this.inputScans = 0;
|
|
43
|
+
this.outputScans = 0;
|
|
44
|
+
this.totalThreats = 0;
|
|
45
|
+
this.threatsByType.clear();
|
|
46
|
+
this.threatsByLevel.clear();
|
|
47
|
+
this.actionCounts.clear();
|
|
48
|
+
this.blockedCount = 0;
|
|
49
|
+
this.redactedCount = 0;
|
|
50
|
+
this.lastScanAt = 0;
|
|
51
|
+
}
|
|
52
|
+
recordScanResult(result) {
|
|
53
|
+
this.lastScanAt = Date.now();
|
|
54
|
+
// Track action
|
|
55
|
+
const current = this.actionCounts.get(result.action) ?? 0;
|
|
56
|
+
this.actionCounts.set(result.action, current + 1);
|
|
57
|
+
if (result.action === 'block')
|
|
58
|
+
this.blockedCount++;
|
|
59
|
+
if (result.action === 'redact')
|
|
60
|
+
this.redactedCount++;
|
|
61
|
+
// Track threats
|
|
62
|
+
for (const threat of result.threats) {
|
|
63
|
+
this.totalThreats++;
|
|
64
|
+
const typeCount = this.threatsByType.get(threat.type) ?? 0;
|
|
65
|
+
this.threatsByType.set(threat.type, typeCount + 1);
|
|
66
|
+
const levelCount = this.threatsByLevel.get(threat.level) ?? 0;
|
|
67
|
+
this.threatsByLevel.set(threat.level, levelCount + 1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAeA,MAAM,OAAO,gBAAgB;IACnB,UAAU,GAAG,CAAC,CAAC;IACf,UAAU,GAAG,CAAC,CAAC;IACf,WAAW,GAAG,CAAC,CAAC;IAChB,YAAY,GAAG,CAAC,CAAC;IACjB,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,cAAc,GAAG,IAAI,GAAG,EAAuB,CAAC;IAChD,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,YAAY,GAAG,CAAC,CAAC;IACjB,aAAa,GAAG,CAAC,CAAC;IAClB,UAAU,GAAG,CAAC,CAAC;IAEvB,kCAAkC;IAClC,eAAe,CAAC,MAAkB;QAChC,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,mCAAmC;IACnC,gBAAgB,CAAC,MAAkB;QACjC,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,iCAAiC;IACjC,QAAQ;QACN,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;YA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IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ;YAAE,IAAI,CAAC,aAAa,EAAE,CAAC;QAErD,gBAAgB;QAChB,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACpC,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3D,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC;YACnD,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC9D,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auxiora/guardrails",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.6",
|
|
4
4
|
"description": "Content safety guardrails with PII detection and prompt injection defense",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@auxiora/logger": "1.10.
|
|
15
|
+
"@auxiora/logger": "1.10.6"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {},
|
|
18
18
|
"engines": {
|