averecion-lite 1.3.6 → 1.3.9
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/dashboard/dash.js +10 -1
- package/dist/log-watcher.d.ts.map +1 -1
- package/dist/log-watcher.js +84 -7
- package/dist/storage.js +1 -1
- package/package.json +1 -1
package/dashboard/dash.js
CHANGED
|
@@ -152,12 +152,21 @@
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
const FRIENDLY_TOOLS = {
|
|
156
|
+
"whatsapp-inbound": "received a WhatsApp message",
|
|
157
|
+
"whatsapp-reply": "sent a WhatsApp reply",
|
|
158
|
+
"whatsapp-processing": "processed a WhatsApp message",
|
|
159
|
+
"whatsapp-gateway": "WhatsApp gateway activity",
|
|
160
|
+
"whatsapp-reconnect": "reconnected to WhatsApp",
|
|
161
|
+
};
|
|
162
|
+
|
|
155
163
|
function friendlyAction(event) {
|
|
156
164
|
const tool = event.tool || "action";
|
|
157
165
|
const reason = event.reason || "";
|
|
166
|
+
const friendlyTool = FRIENDLY_TOOLS[tool] || tool;
|
|
158
167
|
|
|
159
168
|
if (event.decision === "approved") {
|
|
160
|
-
return { icon: "✓", class: "approved", text: `Your bot used ${tool}`, context: null };
|
|
169
|
+
return { icon: "✓", class: "approved", text: FRIENDLY_TOOLS[tool] ? `Bot ${friendlyTool}` : `Your bot used ${tool}`, context: null };
|
|
161
170
|
}
|
|
162
171
|
if (event.decision === "blocked") {
|
|
163
172
|
let context = THREAT_CONTEXT[tool] || null;
|
|
@@ -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;AA6CtC,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;;IAMnD,KAAK,IAAI,IAAI;IAUb,IAAI,IAAI,IAAI;IAWZ,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,SAAS;
|
|
1
|
+
{"version":3,"file":"log-watcher.d.ts","sourceRoot":"","sources":["../log-watcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AA6CtC,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;;IAMnD,KAAK,IAAI,IAAI;IAUb,IAAI,IAAI,IAAI;IAWZ,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,eAAe;IA6BvB,OAAO,CAAC,aAAa;IAgBrB,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
|
@@ -105,9 +105,10 @@ class LogWatcher extends events_1.EventEmitter {
|
|
|
105
105
|
this.watcher.close();
|
|
106
106
|
}
|
|
107
107
|
this.watchedFile = logFile;
|
|
108
|
-
this.filePosition =
|
|
109
|
-
console.log(`[LogWatcher] Watching ${logFile} from
|
|
108
|
+
this.filePosition = 0;
|
|
109
|
+
console.log(`[LogWatcher] Watching ${logFile} from beginning`);
|
|
110
110
|
try {
|
|
111
|
+
this.readNewLines();
|
|
111
112
|
this.watcher = fs.watch(logFile, (eventType) => {
|
|
112
113
|
if (eventType === "change") {
|
|
113
114
|
this.readNewLines();
|
|
@@ -182,11 +183,15 @@ class LogWatcher extends events_1.EventEmitter {
|
|
|
182
183
|
const timestamp = meta.date ? new Date(meta.date) : new Date();
|
|
183
184
|
const logLevel = meta.logLevelName || "INFO";
|
|
184
185
|
let subsystem = "";
|
|
186
|
+
let module = "";
|
|
187
|
+
let runId = "";
|
|
185
188
|
let message = "";
|
|
186
189
|
if (typeof json["0"] === "string") {
|
|
187
190
|
try {
|
|
188
191
|
const parsed = JSON.parse(json["0"]);
|
|
189
192
|
subsystem = parsed.subsystem || "";
|
|
193
|
+
module = parsed.module || "";
|
|
194
|
+
runId = parsed.runId || "";
|
|
190
195
|
}
|
|
191
196
|
catch {
|
|
192
197
|
subsystem = json["0"];
|
|
@@ -195,8 +200,83 @@ class LogWatcher extends events_1.EventEmitter {
|
|
|
195
200
|
if (typeof json["1"] === "string") {
|
|
196
201
|
message = json["1"];
|
|
197
202
|
}
|
|
203
|
+
const description = typeof json["2"] === "string" ? json["2"] : "";
|
|
198
204
|
let toolEvent;
|
|
199
|
-
if (
|
|
205
|
+
if (module === "web-inbound" && typeof json["1"] === "object") {
|
|
206
|
+
const data = json["1"];
|
|
207
|
+
toolEvent = {
|
|
208
|
+
runId: runId || `inbound-${timestamp.getTime()}`,
|
|
209
|
+
tool: "whatsapp-inbound",
|
|
210
|
+
toolCallId: `inbound-${timestamp.getTime()}`,
|
|
211
|
+
phase: "start",
|
|
212
|
+
timestamp,
|
|
213
|
+
args: {
|
|
214
|
+
from: data.from,
|
|
215
|
+
to: data.to,
|
|
216
|
+
body: data.body,
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
if (!toolEvent && module === "web-auto-reply" && typeof json["1"] === "object") {
|
|
221
|
+
const data = json["1"];
|
|
222
|
+
if (data.text && typeof data.text === "string") {
|
|
223
|
+
toolEvent = {
|
|
224
|
+
runId: runId || `reply-${timestamp.getTime()}`,
|
|
225
|
+
tool: "whatsapp-reply",
|
|
226
|
+
toolCallId: `reply-${timestamp.getTime()}`,
|
|
227
|
+
phase: "start",
|
|
228
|
+
timestamp,
|
|
229
|
+
args: {
|
|
230
|
+
to: data.to,
|
|
231
|
+
from: data.from,
|
|
232
|
+
text: data.text.substring(0, 200),
|
|
233
|
+
durationMs: data.durationMs,
|
|
234
|
+
correlationId: data.correlationId,
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
else if (data.body || data.bodyClean) {
|
|
239
|
+
toolEvent = {
|
|
240
|
+
runId: runId || `processing-${timestamp.getTime()}`,
|
|
241
|
+
tool: "whatsapp-processing",
|
|
242
|
+
toolCallId: `processing-${timestamp.getTime()}`,
|
|
243
|
+
phase: "start",
|
|
244
|
+
timestamp,
|
|
245
|
+
args: {
|
|
246
|
+
from: data.from,
|
|
247
|
+
body: data.bodyClean || data.body,
|
|
248
|
+
wasMentioned: data.wasMentioned,
|
|
249
|
+
conversationId: data.conversationId,
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (!toolEvent && subsystem.includes("gateway/channels/whatsapp")) {
|
|
255
|
+
toolEvent = {
|
|
256
|
+
runId: runId || `wa-gw-${timestamp.getTime()}`,
|
|
257
|
+
tool: "whatsapp-gateway",
|
|
258
|
+
toolCallId: `wa-gw-${timestamp.getTime()}`,
|
|
259
|
+
phase: "start",
|
|
260
|
+
timestamp,
|
|
261
|
+
args: { message: message || description },
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
if (!toolEvent && module === "web-reconnect" && typeof json["1"] === "object") {
|
|
265
|
+
const data = json["1"];
|
|
266
|
+
toolEvent = {
|
|
267
|
+
runId: runId || `reconnect-${timestamp.getTime()}`,
|
|
268
|
+
tool: "whatsapp-reconnect",
|
|
269
|
+
toolCallId: `reconnect-${timestamp.getTime()}`,
|
|
270
|
+
phase: "start",
|
|
271
|
+
timestamp,
|
|
272
|
+
args: {
|
|
273
|
+
status: data.status,
|
|
274
|
+
reconnectAttempts: data.reconnectAttempts,
|
|
275
|
+
error: data.error,
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
if (!toolEvent && subsystem.includes("agent/embedded") && message) {
|
|
200
280
|
const startMatch = message.match(/embedded run tool start: runId=(\S+) tool=(\S+) toolCallId=(\S+)/);
|
|
201
281
|
if (startMatch) {
|
|
202
282
|
toolEvent = {
|
|
@@ -218,7 +298,6 @@ class LogWatcher extends events_1.EventEmitter {
|
|
|
218
298
|
timestamp,
|
|
219
299
|
};
|
|
220
300
|
}
|
|
221
|
-
// Fallback: detect agent run start/done events (newer ClawdBot versions)
|
|
222
301
|
if (!toolEvent) {
|
|
223
302
|
const runStartMatch = message.match(/embedded run start: runId=(\S+)/);
|
|
224
303
|
if (runStartMatch) {
|
|
@@ -243,12 +322,10 @@ class LogWatcher extends events_1.EventEmitter {
|
|
|
243
322
|
}
|
|
244
323
|
}
|
|
245
324
|
}
|
|
246
|
-
|
|
247
|
-
if (!toolEvent && message && typeof json["1"] === "object") {
|
|
325
|
+
if (!toolEvent && !module && !subsystem && typeof json["1"] === "object") {
|
|
248
326
|
const data = json["1"];
|
|
249
327
|
if (data.text && typeof data.text === "string") {
|
|
250
328
|
const text = data.text;
|
|
251
|
-
// Check for shell output patterns (code blocks with command output)
|
|
252
329
|
if (text.includes("```") && (text.includes("stanchat") || text.includes("drwx") || text.includes("total "))) {
|
|
253
330
|
toolEvent = {
|
|
254
331
|
runId: `reply-${Date.now()}`,
|
package/dist/storage.js
CHANGED
|
@@ -91,7 +91,7 @@ function getEvents(hoursBack = 24) {
|
|
|
91
91
|
return loadLogsFromJsonl().filter(e => e.ts >= cutoff);
|
|
92
92
|
}
|
|
93
93
|
function getLastEvents(count = 10) {
|
|
94
|
-
return loadLogsFromJsonl().slice(-count);
|
|
94
|
+
return loadLogsFromJsonl().slice(-count).reverse();
|
|
95
95
|
}
|
|
96
96
|
function getConfig() {
|
|
97
97
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "averecion-lite",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
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",
|