@steadwing/openalerts 0.2.3 → 0.2.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/README.md +63 -53
- package/dist/collections/collection-manager.d.ts +50 -0
- package/dist/collections/collection-manager.js +583 -0
- package/dist/collections/event-parser.d.ts +27 -0
- package/dist/collections/event-parser.js +321 -0
- package/dist/collections/index.d.ts +6 -0
- package/dist/collections/index.js +6 -0
- package/dist/collections/persistence.d.ts +25 -0
- package/dist/collections/persistence.js +213 -0
- package/dist/collections/types.d.ts +177 -0
- package/dist/collections/types.js +15 -0
- package/dist/core/engine.js +2 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/rules.js +97 -0
- package/dist/core/types.d.ts +1 -1
- package/dist/index.js +410 -23
- package/dist/plugin/dashboard-html.js +33 -3
- package/dist/plugin/dashboard-routes.d.ts +7 -2
- package/dist/plugin/dashboard-routes.js +111 -3
- package/dist/plugin/gateway-client.d.ts +39 -0
- package/dist/plugin/gateway-client.js +200 -0
- package/openclaw.plugin.json +30 -0
- package/package.json +18 -2
package/README.md
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
9
|
<a href="https://www.npmjs.com/package/@steadwing/openalerts"><img src="https://img.shields.io/npm/v/@steadwing/openalerts?style=flat&color=blue" alt="npm"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@steadwing/openalerts"><img src="https://img.shields.io/npm/dt/@steadwing/openalerts?style=flat&color=blue" alt="npm"></a>
|
|
10
11
|
<a href="https://github.com/steadwing/openalerts/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-green" alt="License"></a>
|
|
11
12
|
<a href="https://github.com/steadwing/openalerts/stargazers"><img src="https://img.shields.io/github/stars/steadwing/openalerts?style=flat" alt="GitHub stars"></a>
|
|
13
|
+
<a href="https://discord.gg/4rUP86tSXn"><img src="https://img.shields.io/badge/discord-join-5865F2?style=flat" alt="Discord"></a>
|
|
12
14
|
</p>
|
|
13
15
|
|
|
14
16
|
<p align="center">
|
|
@@ -28,6 +30,7 @@ OpenAlerts watches your agent in real-time and alerts you the moment something g
|
|
|
28
30
|
## Quickstart
|
|
29
31
|
|
|
30
32
|
> Currently supports OpenClaw. More framework adapters coming soon.
|
|
33
|
+
> This project is under revamp for the next few hours
|
|
31
34
|
|
|
32
35
|
### 1. Install
|
|
33
36
|
|
|
@@ -43,17 +46,17 @@ Otherwise, set it explicitly in `openclaw.json`:
|
|
|
43
46
|
|
|
44
47
|
```jsonc
|
|
45
48
|
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
"plugins": {
|
|
50
|
+
"entries": {
|
|
51
|
+
"openalerts": {
|
|
52
|
+
"enabled": true,
|
|
53
|
+
"config": {
|
|
54
|
+
"alertChannel": "telegram", // telegram | discord | slack | whatsapp | signal
|
|
55
|
+
"alertTo": "YOUR_CHAT_ID",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
57
60
|
}
|
|
58
61
|
```
|
|
59
62
|
|
|
@@ -65,11 +68,14 @@ Otherwise, set it explicitly in `openclaw.json`:
|
|
|
65
68
|
openclaw gateway stop && openclaw gateway run
|
|
66
69
|
```
|
|
67
70
|
|
|
68
|
-
|
|
69
71
|
Send `/health` to your bot. You should get a live status report back — zero LLM tokens consumed.
|
|
70
72
|
|
|
71
73
|
That's it. OpenAlerts is now watching your agent.
|
|
72
74
|
|
|
75
|
+
## Demo
|
|
76
|
+
|
|
77
|
+
https://github.com/user-attachments/assets/0b6ed26e-1eb0-47b2-ae4f-947516f024b4
|
|
78
|
+
|
|
73
79
|
## Dashboard
|
|
74
80
|
|
|
75
81
|
A real-time web dashboard is embedded in the gateway at:
|
|
@@ -78,26 +84,30 @@ A real-time web dashboard is embedded in the gateway at:
|
|
|
78
84
|
http://127.0.0.1:18789/openalerts
|
|
79
85
|
```
|
|
80
86
|
|
|
81
|
-
- **Activity** —
|
|
87
|
+
- **Activity** — Step-by-step execution timeline with tool calls, LLM usage, costs
|
|
88
|
+
- **Sessions** — Active sessions with cost/token aggregation
|
|
89
|
+
- **Execs** — Shell command executions with output capture
|
|
82
90
|
- **System Logs** — Filtered, structured logs with search
|
|
83
91
|
- **Health** — Rule status, alert history, system stats
|
|
92
|
+
- **Debug** — State snapshot for troubleshooting
|
|
84
93
|
|
|
85
94
|
## Alert Rules
|
|
86
95
|
|
|
87
|
-
|
|
96
|
+
Ten rules run against every event in real-time. All thresholds and cooldowns are configurable.
|
|
88
97
|
|
|
89
|
-
| Rule
|
|
90
|
-
|
|
91
|
-
| `llm-errors`
|
|
92
|
-
| `infra-errors`
|
|
93
|
-
| `gateway-down`
|
|
94
|
-
| `session-stuck`
|
|
95
|
-
| `high-error-rate` | Message failure rate over last 20
|
|
96
|
-
| `queue-depth`
|
|
97
|
-
| `tool-errors`
|
|
98
|
-
| `heartbeat-fail`
|
|
98
|
+
| Rule | Watches for | Severity | Threshold (default) |
|
|
99
|
+
| ----------------- | ------------------------------------- | -------- | ------------------- |
|
|
100
|
+
| `llm-errors` | LLM/agent failures in 1 min window | ERROR | `1` error |
|
|
101
|
+
| `infra-errors` | Infrastructure errors in 1 min window | ERROR | `1` error |
|
|
102
|
+
| `gateway-down` | No heartbeat received | CRITICAL | `30000` ms (30s) |
|
|
103
|
+
| `session-stuck` | Session idle too long | WARN | `120000` ms (2 min) |
|
|
104
|
+
| `high-error-rate` | Message failure rate over last 20 | ERROR | `50`% |
|
|
105
|
+
| `queue-depth` | Queued items piling up | WARN | `10` items |
|
|
106
|
+
| `tool-errors` | Tool failures in 1 min window | WARN | `1` error |
|
|
107
|
+
| `heartbeat-fail` | Consecutive heartbeat failures | ERROR | `3` failures |
|
|
99
108
|
|
|
100
109
|
Every rule also accepts:
|
|
110
|
+
|
|
101
111
|
- **`enabled`** — `false` to disable the rule (default: `true`)
|
|
102
112
|
- **`cooldownMinutes`** — minutes before the same rule can fire again (default: `15`)
|
|
103
113
|
|
|
@@ -105,21 +115,21 @@ To tune rules, add a `rules` object in your plugin config:
|
|
|
105
115
|
|
|
106
116
|
```jsonc
|
|
107
117
|
{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
"plugins": {
|
|
119
|
+
"entries": {
|
|
120
|
+
"openalerts": {
|
|
121
|
+
"config": {
|
|
122
|
+
"cooldownMinutes": 10,
|
|
123
|
+
"rules": {
|
|
124
|
+
"llm-errors": { "threshold": 5 },
|
|
125
|
+
"infra-errors": { "cooldownMinutes": 30 },
|
|
126
|
+
"high-error-rate": { "enabled": false },
|
|
127
|
+
"gateway-down": { "threshold": 60000 },
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
123
133
|
}
|
|
124
134
|
```
|
|
125
135
|
|
|
@@ -131,15 +141,15 @@ OpenAlerts can optionally use your configured LLM to enrich alerts with a human-
|
|
|
131
141
|
|
|
132
142
|
```jsonc
|
|
133
143
|
{
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
"plugins": {
|
|
145
|
+
"entries": {
|
|
146
|
+
"openalerts": {
|
|
147
|
+
"config": {
|
|
148
|
+
"llmEnriched": true,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
143
153
|
}
|
|
144
154
|
```
|
|
145
155
|
|
|
@@ -161,11 +171,11 @@ Action: Update your API key in ~/.openclaw/.env with a valid key from platform.o
|
|
|
161
171
|
|
|
162
172
|
Zero-token chat commands available in any connected channel:
|
|
163
173
|
|
|
164
|
-
| Command
|
|
165
|
-
|
|
166
|
-
| `/health`
|
|
167
|
-
| `/alerts`
|
|
168
|
-
| `/dashboard` | Returns the dashboard URL
|
|
174
|
+
| Command | What it does |
|
|
175
|
+
| ------------ | ----------------------------------------------------- |
|
|
176
|
+
| `/health` | System health snapshot — uptime, active alerts, stats |
|
|
177
|
+
| `/alerts` | Recent alert history with severity and timestamps |
|
|
178
|
+
| `/dashboard` | Returns the dashboard URL |
|
|
169
179
|
|
|
170
180
|
## Roadmap
|
|
171
181
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type MonitorSession, type MonitorAction, type MonitorExecEvent, type MonitorExecProcess, type MonitorExecProcessStatus, type CollectionStats, type CostUsageSummary } from "./types.js";
|
|
2
|
+
export declare class CollectionManager {
|
|
3
|
+
private sessions;
|
|
4
|
+
private actions;
|
|
5
|
+
private execs;
|
|
6
|
+
private runSessionMap;
|
|
7
|
+
private parentActionHistory;
|
|
8
|
+
private onSessionChange?;
|
|
9
|
+
private onActionChange?;
|
|
10
|
+
private onExecChange?;
|
|
11
|
+
constructor();
|
|
12
|
+
setCallbacks(callbacks: {
|
|
13
|
+
onSessionChange?: (session: MonitorSession) => void;
|
|
14
|
+
onActionChange?: (action: MonitorAction) => void;
|
|
15
|
+
onExecChange?: (exec: MonitorExecProcess) => void;
|
|
16
|
+
}): void;
|
|
17
|
+
private trackParentAction;
|
|
18
|
+
private inferSpawnedBy;
|
|
19
|
+
private resolveSessionKey;
|
|
20
|
+
private backfillExecSessionKey;
|
|
21
|
+
private createPlaceholderExec;
|
|
22
|
+
upsertSession(session: Partial<MonitorSession>): void;
|
|
23
|
+
updateSessionStatus(key: string, status: MonitorSession["status"]): void;
|
|
24
|
+
addAction(action: MonitorAction): void;
|
|
25
|
+
addExecEvent(event: MonitorExecEvent): void;
|
|
26
|
+
getSessions(): MonitorSession[];
|
|
27
|
+
/**
|
|
28
|
+
* Returns only recently-active sessions for the dashboard.
|
|
29
|
+
* Filters out stale idle sessions loaded from filesystem that are older than windowMs.
|
|
30
|
+
* Active/thinking sessions are always included regardless of age.
|
|
31
|
+
*/
|
|
32
|
+
getActiveSessions(windowMs?: number): MonitorSession[];
|
|
33
|
+
getActions(opts?: {
|
|
34
|
+
sessionKey?: string;
|
|
35
|
+
limit?: number;
|
|
36
|
+
}): MonitorAction[];
|
|
37
|
+
getExecs(opts?: {
|
|
38
|
+
status?: MonitorExecProcessStatus;
|
|
39
|
+
sessionKey?: string;
|
|
40
|
+
}): MonitorExecProcess[];
|
|
41
|
+
getExec(id: string): MonitorExecProcess | undefined;
|
|
42
|
+
getStats(): CollectionStats;
|
|
43
|
+
updateSessionCost(sessionKey: string, costUsd: number, inputTokens?: number, outputTokens?: number): void;
|
|
44
|
+
syncAggregatedCosts(summary: CostUsageSummary): void;
|
|
45
|
+
clear(): void;
|
|
46
|
+
hydrate(sessions: MonitorSession[], actions: MonitorAction[], execEvents?: MonitorExecEvent[]): void;
|
|
47
|
+
exportSessions(): MonitorSession[];
|
|
48
|
+
exportActions(): MonitorAction[];
|
|
49
|
+
exportExecEvents(): MonitorExecEvent[];
|
|
50
|
+
}
|