averecion-lite 1.4.3 → 1.4.5
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/log-watcher.d.ts +4 -0
- package/dist/log-watcher.d.ts.map +1 -1
- package/dist/log-watcher.js +45 -1
- package/package.json +1 -1
package/dist/log-watcher.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export declare class LogWatcher extends EventEmitter {
|
|
|
5
5
|
private filePosition;
|
|
6
6
|
private activeRuns;
|
|
7
7
|
private pollInterval;
|
|
8
|
+
private recentContentHashes;
|
|
9
|
+
private dedupeCleanupInterval;
|
|
8
10
|
constructor();
|
|
9
11
|
start(): void;
|
|
10
12
|
stop(): void;
|
|
@@ -16,6 +18,8 @@ export declare class LogWatcher extends EventEmitter {
|
|
|
16
18
|
private processLine;
|
|
17
19
|
private parseLogLine;
|
|
18
20
|
private extractToolArgs;
|
|
21
|
+
private getContentFingerprint;
|
|
22
|
+
private isDuplicate;
|
|
19
23
|
private handleToolEvent;
|
|
20
24
|
private analyzeDanger;
|
|
21
25
|
private analyzeInjection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-watcher.d.ts","sourceRoot":"","sources":["../log-watcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAmDtC,qBAAa,UAAW,SAAQ,YAAY;IAC1C,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,YAAY,CAA+B;;
|
|
1
|
+
{"version":3,"file":"log-watcher.d.ts","sourceRoot":"","sources":["../log-watcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAmDtC,qBAAa,UAAW,SAAQ,YAAY;IAC1C,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,mBAAmB,CAA6B;IACxD,OAAO,CAAC,qBAAqB,CAA+B;;IAY5D,KAAK,IAAI,IAAI;IAUb,IAAI,IAAI,IAAI;IAeZ,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,SAAS;IAuCjB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,YAAY;IA+BpB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,YAAY;IAmMpB,OAAO,CAAC,eAAe;IAuCvB,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,eAAe;IAmCvB,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,gBAAgB;CAWzB;AAID,wBAAgB,eAAe,IAAI,UAAU,CAM5C;AAED,wBAAgB,cAAc,IAAI,IAAI,CAKrC;AAED,wBAAgB,aAAa,IAAI,UAAU,GAAG,IAAI,CAEjD"}
|
package/dist/log-watcher.js
CHANGED
|
@@ -65,8 +65,17 @@ class LogWatcher extends events_1.EventEmitter {
|
|
|
65
65
|
filePosition = 0;
|
|
66
66
|
activeRuns = new Map();
|
|
67
67
|
pollInterval = null;
|
|
68
|
+
recentContentHashes = new Map();
|
|
69
|
+
dedupeCleanupInterval = null;
|
|
68
70
|
constructor() {
|
|
69
71
|
super();
|
|
72
|
+
this.dedupeCleanupInterval = setInterval(() => {
|
|
73
|
+
const now = Date.now();
|
|
74
|
+
for (const [key, ts] of this.recentContentHashes) {
|
|
75
|
+
if (now - ts > 15000)
|
|
76
|
+
this.recentContentHashes.delete(key);
|
|
77
|
+
}
|
|
78
|
+
}, 30000);
|
|
70
79
|
}
|
|
71
80
|
start() {
|
|
72
81
|
const logFile = this.getCurrentLogFile();
|
|
@@ -86,6 +95,10 @@ class LogWatcher extends events_1.EventEmitter {
|
|
|
86
95
|
clearInterval(this.pollInterval);
|
|
87
96
|
this.pollInterval = null;
|
|
88
97
|
}
|
|
98
|
+
if (this.dedupeCleanupInterval) {
|
|
99
|
+
clearInterval(this.dedupeCleanupInterval);
|
|
100
|
+
this.dedupeCleanupInterval = null;
|
|
101
|
+
}
|
|
89
102
|
}
|
|
90
103
|
getCurrentLogFile() {
|
|
91
104
|
if (!fs.existsSync(CLAWDBOT_LOG_DIR))
|
|
@@ -403,15 +416,46 @@ class LogWatcher extends events_1.EventEmitter {
|
|
|
403
416
|
}
|
|
404
417
|
return args;
|
|
405
418
|
}
|
|
419
|
+
getContentFingerprint(event) {
|
|
420
|
+
const args = event.args || {};
|
|
421
|
+
const body = args.body || args.text || args.bodyClean || "";
|
|
422
|
+
const from = args.from || "";
|
|
423
|
+
if (!body && !from)
|
|
424
|
+
return "";
|
|
425
|
+
return `${from}:${body.substring(0, 100)}`;
|
|
426
|
+
}
|
|
427
|
+
isDuplicate(event, isThreat) {
|
|
428
|
+
if (event.tool === "whatsapp-processing") {
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
if (event.tool === "whatsapp-gateway") {
|
|
432
|
+
const fingerprint = this.getContentFingerprint(event);
|
|
433
|
+
if (!fingerprint)
|
|
434
|
+
return false;
|
|
435
|
+
const dedupeKey = `gw:${fingerprint}`;
|
|
436
|
+
const lastSeen = this.recentContentHashes.get(dedupeKey);
|
|
437
|
+
const now = Date.now();
|
|
438
|
+
if (lastSeen && now - lastSeen < 10000)
|
|
439
|
+
return true;
|
|
440
|
+
this.recentContentHashes.set(dedupeKey, now);
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
406
445
|
handleToolEvent(event) {
|
|
407
446
|
if (event.phase === "start") {
|
|
408
447
|
this.activeRuns.set(event.toolCallId, event);
|
|
409
448
|
const dangerAnalysis = this.analyzeDanger(event);
|
|
410
449
|
const injectionAnalysis = this.analyzeInjection(event);
|
|
450
|
+
const isThreat = dangerAnalysis.dangerous || injectionAnalysis.detected;
|
|
451
|
+
if (this.isDuplicate(event, isThreat)) {
|
|
452
|
+
console.log(`🛡️ [LogWatcher] Tool: ${event.tool} | (duplicate, skipped)`);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
411
455
|
const actionEvent = {
|
|
412
456
|
ts: event.timestamp.toISOString(),
|
|
413
457
|
tool: event.tool,
|
|
414
|
-
decision:
|
|
458
|
+
decision: isThreat ? "blocked" : "approved",
|
|
415
459
|
reason: dangerAnalysis.reason || injectionAnalysis.reason || `Tool executed: ${event.tool}`,
|
|
416
460
|
egress: [],
|
|
417
461
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "averecion-lite",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"description": "Real-time AI agent monitoring - watches logs, detects dangerous commands and prompt injection attempts",
|
|
5
5
|
"author": "Averecion <hello@averecion.com>",
|
|
6
6
|
"homepage": "https://github.com/averecion/clawguard#readme",
|