nexo-brain 2.3.2 → 2.5.0
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 +77 -8
- package/bin/nexo-brain.js +230 -22
- package/bin/nexo.js +55 -0
- package/community/skills/.gitkeep +1 -0
- package/package.json +5 -2
- package/src/auto_update.py +158 -8
- package/src/cli.py +605 -0
- package/src/cognitive/_ingest.py +1 -1
- package/src/cognitive/_memory.py +4 -4
- package/src/crons/manifest.json +8 -0
- package/src/dashboard/app.py +709 -37
- package/src/dashboard/templates/adaptive.html +112 -218
- package/src/dashboard/templates/artifacts.html +133 -0
- package/src/dashboard/templates/backups.html +136 -0
- package/src/dashboard/templates/base.html +413 -0
- package/src/dashboard/templates/calendar.html +523 -652
- package/src/dashboard/templates/chat.html +356 -0
- package/src/dashboard/templates/claims.html +259 -0
- package/src/dashboard/templates/cortex.html +262 -0
- package/src/dashboard/templates/credentials.html +128 -0
- package/src/dashboard/templates/crons.html +370 -0
- package/src/dashboard/templates/dashboard.html +384 -572
- package/src/dashboard/templates/dreams.html +252 -0
- package/src/dashboard/templates/email.html +160 -0
- package/src/dashboard/templates/evolution.html +189 -0
- package/src/dashboard/templates/feed.html +249 -0
- package/src/dashboard/templates/followup_health.html +170 -0
- package/src/dashboard/templates/graph.html +191 -269
- package/src/dashboard/templates/guard.html +259 -0
- package/src/dashboard/templates/inbox.html +220 -336
- package/src/dashboard/templates/memory.html +317 -197
- package/src/dashboard/templates/operations.html +498 -652
- package/src/dashboard/templates/plugins.html +185 -0
- package/src/dashboard/templates/rules.html +246 -0
- package/src/dashboard/templates/sentiment.html +247 -0
- package/src/dashboard/templates/sessions.html +215 -171
- package/src/dashboard/templates/skills.html +329 -0
- package/src/dashboard/templates/somatic.html +68 -172
- package/src/dashboard/templates/triggers.html +133 -0
- package/src/dashboard/templates/trust.html +360 -0
- package/src/db/__init__.py +5 -0
- package/src/db/_schema.py +25 -1
- package/src/db/_sessions.py +22 -0
- package/src/db/_skills.py +983 -252
- package/src/doctor/__init__.py +1 -0
- package/src/doctor/formatters.py +52 -0
- package/src/doctor/models.py +44 -0
- package/src/doctor/orchestrator.py +42 -0
- package/src/doctor/providers/__init__.py +1 -0
- package/src/doctor/providers/boot.py +206 -0
- package/src/doctor/providers/deep.py +292 -0
- package/src/doctor/providers/runtime.py +686 -0
- package/src/hooks/capture-tool-logs.sh +18 -4
- package/src/hooks/post-compact.sh +5 -1
- package/src/hooks/pre-compact.sh +1 -1
- package/src/plugin_loader.py +14 -0
- package/src/plugins/doctor.py +36 -0
- package/src/plugins/evolution.py +2 -1
- package/src/plugins/skills.py +135 -175
- package/src/requirements.txt +1 -0
- package/src/script_registry.py +322 -0
- package/src/scripts/deep-sleep/apply_findings.py +63 -33
- package/src/scripts/deep-sleep/collect.py +38 -9
- package/src/scripts/deep-sleep/extract-prompt.md +14 -0
- package/src/scripts/deep-sleep/synthesize-prompt.md +36 -0
- package/src/scripts/deep-sleep/synthesize.py +37 -1
- package/src/scripts/nexo-dashboard.sh +29 -0
- package/src/scripts/nexo-day-orchestrator.sh +139 -0
- package/src/scripts/nexo-evolution-run.py +2 -1
- package/src/scripts/nexo-learning-housekeep.py +1 -1
- package/src/scripts/nexo-watchdog.sh +1 -1
- package/src/server.py +9 -5
- package/src/skills/run-runtime-doctor/guide.md +12 -0
- package/src/skills/run-runtime-doctor/script.py +21 -0
- package/src/skills/run-runtime-doctor/skill.json +25 -0
- package/src/skills_runtime.py +347 -0
- package/src/tools_menu.py +3 -2
- package/src/tools_sessions.py +126 -0
- package/src/user_context.py +46 -0
- package/templates/nexo_helper.py +45 -0
- package/templates/script-template.py +44 -0
- package/templates/skill-script-template.py +39 -0
- package/templates/skill-template.md +33 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}Guard Heatmap{% endblock %}
|
|
4
|
+
|
|
5
|
+
{% block page_title %}Guard Heatmap{% endblock %}
|
|
6
|
+
{% block page_subtitle %}<span class="text-xs text-slate-500 ml-2">Risk map of the codebase</span>{% endblock %}
|
|
7
|
+
|
|
8
|
+
{% block header_actions %}
|
|
9
|
+
<button onclick="loadData()" class="text-xs text-slate-400 hover:text-slate-200 transition-colors px-2 py-1 rounded hover:bg-slate-800">
|
|
10
|
+
<svg class="w-3.5 h-3.5 inline -mt-0.5 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>
|
|
11
|
+
Refresh
|
|
12
|
+
</button>
|
|
13
|
+
{% endblock %}
|
|
14
|
+
|
|
15
|
+
{% block content %}
|
|
16
|
+
<!-- Stats row -->
|
|
17
|
+
<div class="grid grid-cols-4 gap-4 mb-6">
|
|
18
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
19
|
+
<p class="text-xs uppercase tracking-wider text-slate-500 font-semibold mb-1">Total Checks</p>
|
|
20
|
+
<p class="text-2xl font-display font-bold text-slate-100" id="stat-total">--</p>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
23
|
+
<p class="text-xs uppercase tracking-wider text-slate-500 font-semibold mb-1">Areas Covered</p>
|
|
24
|
+
<p class="text-2xl font-display font-bold text-slate-100" id="stat-areas">--</p>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
27
|
+
<p class="text-xs uppercase tracking-wider text-slate-500 font-semibold mb-1">Blocking Rate</p>
|
|
28
|
+
<p class="text-2xl font-display font-bold text-red-400" id="stat-blocking">--</p>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
31
|
+
<p class="text-xs uppercase tracking-wider text-slate-500 font-semibold mb-1">Somatic Risks</p>
|
|
32
|
+
<p class="text-2xl font-display font-bold text-amber-400" id="stat-somatic">--</p>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<!-- Heatmap + Somatic -->
|
|
37
|
+
<div class="grid grid-cols-3 gap-5 mb-6">
|
|
38
|
+
<!-- Heatmap Grid -->
|
|
39
|
+
<div class="col-span-2 bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
40
|
+
<div class="flex items-center justify-between mb-4">
|
|
41
|
+
<h2 class="text-xs uppercase tracking-wider text-slate-500 font-semibold">Risk Heatmap</h2>
|
|
42
|
+
<div class="flex items-center gap-2 text-[10px] text-slate-500">
|
|
43
|
+
<span class="flex items-center gap-1"><span class="w-3 h-3 rounded bg-emerald-500/80"></span>Low</span>
|
|
44
|
+
<span class="flex items-center gap-1"><span class="w-3 h-3 rounded bg-amber-500/80"></span>Medium</span>
|
|
45
|
+
<span class="flex items-center gap-1"><span class="w-3 h-3 rounded bg-red-500/80"></span>High</span>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
<div id="heatmap-grid" class="grid grid-cols-3 gap-3">
|
|
49
|
+
<div class="col-span-3 py-12 text-center text-sm text-slate-500">Loading heatmap...</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<!-- Somatic Markers -->
|
|
54
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
55
|
+
<h2 class="text-xs uppercase tracking-wider text-slate-500 font-semibold mb-4">Somatic Risk Targets</h2>
|
|
56
|
+
<div id="somatic-list" class="space-y-3">
|
|
57
|
+
<div class="py-8 text-center text-sm text-slate-500">Loading...</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<!-- Area Detail Modal -->
|
|
63
|
+
<div id="area-modal" class="hidden fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center" onclick="if(event.target===this)closeModal()">
|
|
64
|
+
<div class="bg-slate-900 border border-slate-700 rounded-2xl p-6 max-w-lg w-full mx-4 shadow-2xl animate-slide-in">
|
|
65
|
+
<div class="flex items-center justify-between mb-4">
|
|
66
|
+
<h3 class="text-sm font-display font-semibold text-slate-100" id="modal-title">Area Details</h3>
|
|
67
|
+
<button onclick="closeModal()" class="text-slate-500 hover:text-slate-300 transition-colors">
|
|
68
|
+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M6 18L18 6M6 6l12 12"/></svg>
|
|
69
|
+
</button>
|
|
70
|
+
</div>
|
|
71
|
+
<div id="modal-content" class="space-y-3"></div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<!-- Recent Guard Checks -->
|
|
76
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
77
|
+
<div class="flex items-center justify-between mb-4">
|
|
78
|
+
<h2 class="text-xs uppercase tracking-wider text-slate-500 font-semibold">Recent Guard Checks</h2>
|
|
79
|
+
<span class="text-[10px] text-slate-600 font-mono" id="checks-count">--</span>
|
|
80
|
+
</div>
|
|
81
|
+
<div id="checks-table" class="overflow-x-auto">
|
|
82
|
+
<table class="w-full text-sm">
|
|
83
|
+
<thead>
|
|
84
|
+
<tr class="text-left text-xs text-slate-500 uppercase tracking-wider border-b border-slate-800/50">
|
|
85
|
+
<th class="pb-2 pr-3 font-semibold">Area</th>
|
|
86
|
+
<th class="pb-2 pr-3 font-semibold">Action</th>
|
|
87
|
+
<th class="pb-2 pr-3 font-semibold">Result</th>
|
|
88
|
+
<th class="pb-2 pr-3 font-semibold">Warnings</th>
|
|
89
|
+
<th class="pb-2 font-semibold">Time</th>
|
|
90
|
+
</tr>
|
|
91
|
+
</thead>
|
|
92
|
+
<tbody id="checks-body" class="divide-y divide-slate-800/30">
|
|
93
|
+
<tr><td colspan="5" class="py-8 text-center text-slate-500">Loading checks...</td></tr>
|
|
94
|
+
</tbody>
|
|
95
|
+
</table>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
{% endblock %}
|
|
99
|
+
|
|
100
|
+
{% block scripts %}
|
|
101
|
+
<script>
|
|
102
|
+
let guardData = null;
|
|
103
|
+
|
|
104
|
+
function heatColor(blocking, total) {
|
|
105
|
+
if (!total) return { bg: 'bg-slate-800/50', border: 'border-slate-700/30', text: 'text-slate-500' };
|
|
106
|
+
const ratio = blocking / total;
|
|
107
|
+
if (ratio > 0.3) return { bg: 'bg-red-500/15', border: 'border-red-500/30', text: 'text-red-400' };
|
|
108
|
+
if (ratio > 0.1) return { bg: 'bg-amber-500/15', border: 'border-amber-500/30', text: 'text-amber-400' };
|
|
109
|
+
return { bg: 'bg-emerald-500/15', border: 'border-emerald-500/30', text: 'text-emerald-400' };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function showAreaDetail(area) {
|
|
113
|
+
if (!guardData || !guardData.heatmap) return;
|
|
114
|
+
const info = guardData.heatmap[area];
|
|
115
|
+
if (!info) return;
|
|
116
|
+
|
|
117
|
+
document.getElementById('modal-title').textContent = area;
|
|
118
|
+
const content = document.getElementById('modal-content');
|
|
119
|
+
content.innerHTML = `
|
|
120
|
+
<div class="grid grid-cols-3 gap-3">
|
|
121
|
+
<div class="bg-slate-800/50 rounded-lg p-3 text-center">
|
|
122
|
+
<p class="text-lg font-bold text-slate-100">${info.count || 0}</p>
|
|
123
|
+
<p class="text-[10px] text-slate-500 uppercase tracking-wider">Checks</p>
|
|
124
|
+
</div>
|
|
125
|
+
<div class="bg-slate-800/50 rounded-lg p-3 text-center">
|
|
126
|
+
<p class="text-lg font-bold text-red-400">${info.blocking || 0}</p>
|
|
127
|
+
<p class="text-[10px] text-slate-500 uppercase tracking-wider">Blocking</p>
|
|
128
|
+
</div>
|
|
129
|
+
<div class="bg-slate-800/50 rounded-lg p-3 text-center">
|
|
130
|
+
<p class="text-lg font-bold text-violet-400">${info.learnings || 0}</p>
|
|
131
|
+
<p class="text-[10px] text-slate-500 uppercase tracking-wider">Learnings</p>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
${(info.recent_checks || []).length ? `
|
|
135
|
+
<div class="mt-3">
|
|
136
|
+
<p class="text-xs text-slate-500 font-semibold uppercase tracking-wider mb-2">Recent Checks</p>
|
|
137
|
+
<div class="space-y-1.5">
|
|
138
|
+
${(info.recent_checks || []).slice(0, 5).map(c => `
|
|
139
|
+
<div class="flex items-center justify-between bg-slate-800/30 rounded-lg px-3 py-2 text-xs">
|
|
140
|
+
<span class="text-slate-300">${escapeHtml(c.action || c.description || '--')}</span>
|
|
141
|
+
<span class="${c.passed ? 'text-emerald-400' : 'text-red-400'}">${c.passed ? 'PASS' : 'BLOCK'}</span>
|
|
142
|
+
</div>
|
|
143
|
+
`).join('')}
|
|
144
|
+
</div>
|
|
145
|
+
</div>` : ''}
|
|
146
|
+
`;
|
|
147
|
+
document.getElementById('area-modal').classList.remove('hidden');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function closeModal() {
|
|
151
|
+
document.getElementById('area-modal').classList.add('hidden');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function loadData() {
|
|
155
|
+
const data = await fetchJSON('/api/guard');
|
|
156
|
+
if (!data) return;
|
|
157
|
+
guardData = data;
|
|
158
|
+
|
|
159
|
+
const checks = data.checks || [];
|
|
160
|
+
const heatmap = data.heatmap || {};
|
|
161
|
+
const markers = data.somatic_markers || [];
|
|
162
|
+
|
|
163
|
+
// Stats
|
|
164
|
+
const totalChecks = checks.length;
|
|
165
|
+
const areas = Object.keys(heatmap);
|
|
166
|
+
const totalBlocking = checks.filter(c => !c.passed && (c.type === 'blocking' || c.blocked)).length;
|
|
167
|
+
const blockingRate = totalChecks > 0 ? ((totalBlocking / totalChecks) * 100).toFixed(1) + '%' : '0%';
|
|
168
|
+
|
|
169
|
+
document.getElementById('stat-total').textContent = formatNumber(totalChecks);
|
|
170
|
+
document.getElementById('stat-areas').textContent = areas.length;
|
|
171
|
+
document.getElementById('stat-blocking').textContent = blockingRate;
|
|
172
|
+
document.getElementById('stat-somatic').textContent = markers.length;
|
|
173
|
+
|
|
174
|
+
// Heatmap grid
|
|
175
|
+
const grid = document.getElementById('heatmap-grid');
|
|
176
|
+
if (!areas.length) {
|
|
177
|
+
grid.innerHTML = '<div class="col-span-3 py-12 text-center text-sm text-slate-500">No guard areas recorded yet</div>';
|
|
178
|
+
} else {
|
|
179
|
+
grid.innerHTML = areas.map(area => {
|
|
180
|
+
const info = heatmap[area];
|
|
181
|
+
const c = heatColor(info.blocking || 0, info.count || 0);
|
|
182
|
+
return `
|
|
183
|
+
<button onclick="showAreaDetail('${escapeHtml(area)}')"
|
|
184
|
+
class="${c.bg} border ${c.border} rounded-xl p-4 text-left transition-all hover:scale-[1.02] hover:shadow-lg cursor-pointer group">
|
|
185
|
+
<p class="text-sm font-semibold text-slate-200 group-hover:text-white truncate">${escapeHtml(area)}</p>
|
|
186
|
+
<div class="flex items-center gap-3 mt-2">
|
|
187
|
+
<span class="text-xs text-slate-400">${info.count || 0} checks</span>
|
|
188
|
+
<span class="text-xs ${c.text} font-medium">${info.blocking || 0} blocking</span>
|
|
189
|
+
</div>
|
|
190
|
+
<div class="mt-2 h-1.5 bg-slate-800/50 rounded-full overflow-hidden">
|
|
191
|
+
<div class="h-full rounded-full transition-all duration-500 ${info.blocking > 0 ? (info.blocking / info.count > 0.3 ? 'bg-red-500' : 'bg-amber-500') : 'bg-emerald-500'}"
|
|
192
|
+
style="width: ${info.count ? Math.min(((info.blocking || 0) / info.count) * 100, 100).toFixed(1) : 0}%"></div>
|
|
193
|
+
</div>
|
|
194
|
+
</button>
|
|
195
|
+
`;
|
|
196
|
+
}).join('');
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Somatic markers
|
|
200
|
+
const somaticList = document.getElementById('somatic-list');
|
|
201
|
+
if (!markers.length) {
|
|
202
|
+
somaticList.innerHTML = '<div class="py-8 text-center text-sm text-slate-500">No somatic markers</div>';
|
|
203
|
+
} else {
|
|
204
|
+
const maxScore = Math.max(...markers.map(m => m.risk_score || 0), 1);
|
|
205
|
+
somaticList.innerHTML = markers.sort((a, b) => (b.risk_score || 0) - (a.risk_score || 0)).slice(0, 10).map(m => {
|
|
206
|
+
const score = m.risk_score || 0;
|
|
207
|
+
const pct = (score / maxScore * 100).toFixed(1);
|
|
208
|
+
const color = score > 5 ? 'bg-red-500' : score > 2 ? 'bg-amber-500' : 'bg-emerald-500';
|
|
209
|
+
const textColor = score > 5 ? 'text-red-400' : score > 2 ? 'text-amber-400' : 'text-emerald-400';
|
|
210
|
+
return `
|
|
211
|
+
<div class="flex items-center gap-3">
|
|
212
|
+
<div class="flex-1 min-w-0">
|
|
213
|
+
<p class="text-xs text-slate-300 truncate">${escapeHtml(m.target || '--')}</p>
|
|
214
|
+
<div class="mt-1 h-1.5 bg-slate-800/50 rounded-full overflow-hidden">
|
|
215
|
+
<div class="h-full rounded-full ${color} transition-all duration-700" style="width:${pct}%"></div>
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
<div class="text-right flex-shrink-0">
|
|
219
|
+
<span class="text-xs font-mono font-medium ${textColor}">${score.toFixed(1)}</span>
|
|
220
|
+
<p class="text-[10px] text-slate-600">${m.incident_count || 0} incidents</p>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
`;
|
|
224
|
+
}).join('');
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Recent checks table
|
|
228
|
+
document.getElementById('checks-count').textContent = `${checks.length} checks`;
|
|
229
|
+
const tbody = document.getElementById('checks-body');
|
|
230
|
+
if (!checks.length) {
|
|
231
|
+
tbody.innerHTML = '<tr><td colspan="5" class="py-8 text-center text-slate-500 text-sm">No guard checks recorded</td></tr>';
|
|
232
|
+
} else {
|
|
233
|
+
tbody.innerHTML = checks.slice(0, 25).map(c => {
|
|
234
|
+
const passed = c.passed !== false && !c.blocked;
|
|
235
|
+
const warnings = c.warnings || c.warning_count || 0;
|
|
236
|
+
return `
|
|
237
|
+
<tr class="group hover:bg-slate-800/20 transition-colors">
|
|
238
|
+
<td class="py-2.5 pr-3 text-slate-300">${escapeHtml(c.area || c.category || '--')}</td>
|
|
239
|
+
<td class="py-2.5 pr-3 text-slate-400 font-mono text-xs max-w-[200px] truncate">${escapeHtml(c.action || c.description || '--')}</td>
|
|
240
|
+
<td class="py-2.5 pr-3">
|
|
241
|
+
<span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold uppercase ${passed ? 'bg-emerald-500/15 text-emerald-400' : 'bg-red-500/15 text-red-400'}">
|
|
242
|
+
<span class="w-1.5 h-1.5 rounded-full ${passed ? 'bg-emerald-400' : 'bg-red-400'}"></span>
|
|
243
|
+
${passed ? 'Pass' : 'Block'}
|
|
244
|
+
</span>
|
|
245
|
+
</td>
|
|
246
|
+
<td class="py-2.5 pr-3 text-xs ${warnings > 0 ? 'text-amber-400' : 'text-slate-600'}">${warnings > 0 ? warnings + ' warning' + (warnings !== 1 ? 's' : '') : 'none'}</td>
|
|
247
|
+
<td class="py-2.5 text-xs text-slate-500">${relativeTime(c.created_at || c.checked_at)}</td>
|
|
248
|
+
</tr>
|
|
249
|
+
`;
|
|
250
|
+
}).join('');
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
loadData();
|
|
255
|
+
setInterval(loadData, 60000);
|
|
256
|
+
|
|
257
|
+
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeModal(); });
|
|
258
|
+
</script>
|
|
259
|
+
{% endblock %}
|