@datacules/agent-identity-anomaly 0.2.1
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/README.md +61 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# `@datacules/agent-identity-anomaly`
|
|
2
|
+
|
|
3
|
+
Behavioral baseline and anomaly detection for [`@datacules/agent-identity`](../../core). Wraps your audit pipeline with zero routing config changes — each agent builds a rolling baseline and deviations trigger `credential.anomaly` audit events.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @datacules/agent-identity-anomaly
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { AnomalyDetector } from '@datacules/agent-identity-anomaly';
|
|
15
|
+
|
|
16
|
+
const detector = new AnomalyDetector({
|
|
17
|
+
logger,
|
|
18
|
+
policy: {
|
|
19
|
+
lowAction: 'warn', // emit audit event only
|
|
20
|
+
mediumAction: 'warn', // same
|
|
21
|
+
highAction: 'block', // return null — credential denied
|
|
22
|
+
baselineSamples: 20, // collect 20 resolutions before scoring starts
|
|
23
|
+
rateSpikeThreshold: 3.0, // flag if current rate > 3x rolling average
|
|
24
|
+
},
|
|
25
|
+
onAnomaly: (event) => {
|
|
26
|
+
alertingService.send(`Anomaly detected: ${event.signal} (${event.severity}) for ${event.userId}`);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Wrap your resolveAsync call
|
|
31
|
+
const resolved = await detector.observe(ctx, () => router.resolveAsync(ctx));
|
|
32
|
+
if (!resolved) {
|
|
33
|
+
// anomaly detected + policy was 'block' — the model layer should not proceed
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Detected signals
|
|
38
|
+
|
|
39
|
+
| Signal | Severity | Description |
|
|
40
|
+
|--------|----------|-------------|
|
|
41
|
+
| `rate_spike` | high | Call rate 3x the hourly EWMA |
|
|
42
|
+
| `new_credential_type` | medium | Credential kind never seen before |
|
|
43
|
+
| `new_action_type` | medium | Action (`read`/`write`/etc.) never seen before |
|
|
44
|
+
| `new_resource_kind` | medium | Resource kind (`shared`/`personal`) never seen before |
|
|
45
|
+
| `new_provider` | low | AI provider never seen before |
|
|
46
|
+
| `off_hours` | low | Baseline was daytime only; now receiving night calls |
|
|
47
|
+
|
|
48
|
+
## Audit event format
|
|
49
|
+
|
|
50
|
+
Every anomaly emits a `credential.anomaly` audit entry with additional fields:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"action": "credential.anomaly",
|
|
55
|
+
"signal": "rate_spike",
|
|
56
|
+
"severity": "high",
|
|
57
|
+
"baselineValue": 12.4,
|
|
58
|
+
"observedValue": 87,
|
|
59
|
+
"userId": "agent-orders"
|
|
60
|
+
}
|
|
61
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@datacules/agent-identity-anomaly",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Anomaly detection and behavioral baseline for @datacules/agent-identity — statistical detection of unusual credential usage patterns",
|
|
6
|
+
"author": "Datacules LLC",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/hvrcharon1/agent-identity.git",
|
|
11
|
+
"directory": "packages/integrations/anomaly"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/cjs/index.js",
|
|
14
|
+
"module": "./dist/esm/index.js",
|
|
15
|
+
"types": "./dist/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/esm/index.js",
|
|
19
|
+
"require": "./dist/cjs/index.js",
|
|
20
|
+
"types": "./dist/types/index.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc -p tsconfig.build.json",
|
|
29
|
+
"type-check": "tsc --noEmit",
|
|
30
|
+
"lint": "eslint src --ext .ts"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20",
|
|
34
|
+
"typescript": "^5"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@datacules/agent-identity": "^0.1.0"
|
|
38
|
+
}
|
|
39
|
+
}
|