averecion-lite 1.6.1 → 1.6.2
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 +1 -0
- package/dist/log-watcher.d.ts.map +1 -1
- package/dist/log-watcher.js +88 -0
- package/package.json +1 -1
package/dist/log-watcher.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-watcher.d.ts","sourceRoot":"","sources":["../log-watcher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAsDtC,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;IAsBzB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,SAAS;IAuCjB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,YAAY;IA+BpB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,YAAY;
|
|
1
|
+
{"version":3,"file":"log-watcher.d.ts","sourceRoot":"","sources":["../log-watcher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAsDtC,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;IAsBzB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,SAAS;IAuCjB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,YAAY;IA+BpB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,YAAY;IAwMpB,OAAO,CAAC,kBAAkB;IA+D1B,OAAO,CAAC,qBAAqB;IAwE7B,OAAO,CAAC,eAAe;IAuCvB,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,WAAW;IASnB,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
|
@@ -218,6 +218,9 @@ class LogWatcher extends events_1.EventEmitter {
|
|
|
218
218
|
parseLogLine(line) {
|
|
219
219
|
try {
|
|
220
220
|
const json = JSON.parse(line);
|
|
221
|
+
if (json.timestamp && json.action && json.source) {
|
|
222
|
+
return this.parseCommandsLogEntry(json);
|
|
223
|
+
}
|
|
221
224
|
const meta = json._meta || {};
|
|
222
225
|
const timestamp = meta.date ? new Date(meta.date) : new Date();
|
|
223
226
|
const logLevel = meta.logLevelName || "INFO";
|
|
@@ -457,6 +460,91 @@ class LogWatcher extends events_1.EventEmitter {
|
|
|
457
460
|
}
|
|
458
461
|
return { message: content, timestamp, logLevel: "INFO", toolEvent };
|
|
459
462
|
}
|
|
463
|
+
parseCommandsLogEntry(json) {
|
|
464
|
+
const timestamp = json.timestamp ? new Date(json.timestamp) : new Date();
|
|
465
|
+
const action = json.action || "";
|
|
466
|
+
const source = json.source || "";
|
|
467
|
+
const sessionKey = json.sessionKey || "";
|
|
468
|
+
const senderId = json.senderId || "";
|
|
469
|
+
const command = json.command || "";
|
|
470
|
+
const input = json.input || "";
|
|
471
|
+
const output = json.output || "";
|
|
472
|
+
const body = json.body || json.message || "";
|
|
473
|
+
const tool = json.tool || "";
|
|
474
|
+
const status = json.status || "";
|
|
475
|
+
const error = json.error || "";
|
|
476
|
+
const from = json.from || senderId;
|
|
477
|
+
const to = json.to || "";
|
|
478
|
+
let toolName = "agent-log";
|
|
479
|
+
const args = {};
|
|
480
|
+
if (source === "whatsapp" || sessionKey.includes("whatsapp")) {
|
|
481
|
+
if (action === "new" || action === "message" || action === "inbound" || action === "received") {
|
|
482
|
+
toolName = "whatsapp-inbound";
|
|
483
|
+
args.from = from;
|
|
484
|
+
args.body = body || input || `Session: ${sessionKey}`;
|
|
485
|
+
if (to)
|
|
486
|
+
args.to = to;
|
|
487
|
+
}
|
|
488
|
+
else if (action === "reply" || action === "send" || action === "outbound" || action === "response" || action === "sent") {
|
|
489
|
+
toolName = "whatsapp-reply";
|
|
490
|
+
args.to = to || from;
|
|
491
|
+
args.text = output || body || `Reply in session`;
|
|
492
|
+
if (from)
|
|
493
|
+
args.from = from;
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
toolName = "whatsapp-gateway";
|
|
497
|
+
args.action = action;
|
|
498
|
+
args.session = sessionKey;
|
|
499
|
+
if (from)
|
|
500
|
+
args.from = from;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
else if (tool || action === "tool_call" || action === "exec" || action === "command") {
|
|
504
|
+
toolName = tool || "exec";
|
|
505
|
+
if (command)
|
|
506
|
+
args.command = command;
|
|
507
|
+
if (input)
|
|
508
|
+
args.input = input;
|
|
509
|
+
if (output)
|
|
510
|
+
args.output = output;
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
args.action = action;
|
|
514
|
+
args.source = source;
|
|
515
|
+
if (body)
|
|
516
|
+
args.body = body;
|
|
517
|
+
if (command)
|
|
518
|
+
args.command = command;
|
|
519
|
+
if (input)
|
|
520
|
+
args.input = input;
|
|
521
|
+
if (output)
|
|
522
|
+
args.output = output;
|
|
523
|
+
if (status)
|
|
524
|
+
args.status = status;
|
|
525
|
+
if (error)
|
|
526
|
+
args.error = error;
|
|
527
|
+
if (sessionKey)
|
|
528
|
+
args.session = sessionKey;
|
|
529
|
+
if (from)
|
|
530
|
+
args.from = from;
|
|
531
|
+
}
|
|
532
|
+
const toolEvent = {
|
|
533
|
+
runId: `cmd-${timestamp.getTime()}-${Math.random().toString(36).slice(2, 6)}`,
|
|
534
|
+
tool: toolName,
|
|
535
|
+
toolCallId: `cmd-${timestamp.getTime()}-${Math.random().toString(36).slice(2, 6)}`,
|
|
536
|
+
phase: "start",
|
|
537
|
+
timestamp,
|
|
538
|
+
args,
|
|
539
|
+
};
|
|
540
|
+
return {
|
|
541
|
+
subsystem: source,
|
|
542
|
+
message: body || command || input || `${action} from ${source}`,
|
|
543
|
+
timestamp,
|
|
544
|
+
logLevel: error ? "ERROR" : "INFO",
|
|
545
|
+
toolEvent,
|
|
546
|
+
};
|
|
547
|
+
}
|
|
460
548
|
extractToolArgs(json) {
|
|
461
549
|
const args = {};
|
|
462
550
|
for (const key of Object.keys(json)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "averecion-lite",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
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",
|