nexo-brain 5.3.19 → 5.3.21
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/.claude-plugin/plugin.json +1 -1
- package/bin/nexo-brain.js +52 -10
- package/package.json +1 -1
- package/src/auto_update.py +11 -8
- package/src/dashboard/static/favicon 2.svg +32 -0
- package/src/dashboard/static/nexo-logo 2.png +0 -0
- package/src/dashboard/static/nexo-logo 2.svg +40 -0
- package/src/dashboard/static/style 2.css +2458 -0
- package/src/dashboard/templates/adaptive 2.html +118 -0
- package/src/dashboard/templates/artifacts 2.html +133 -0
- package/src/dashboard/templates/backups 2.html +136 -0
- package/src/dashboard/templates/base 2.html +417 -0
- package/src/dashboard/templates/calendar 2.html +591 -0
- package/src/dashboard/templates/chat 2.html +356 -0
- package/src/dashboard/templates/claims 2.html +259 -0
- package/src/dashboard/templates/cortex 2.html +321 -0
- package/src/dashboard/templates/credentials 2.html +128 -0
- package/src/dashboard/templates/crons 2.html +370 -0
- package/src/dashboard/templates/dashboard 2.html +494 -0
- package/src/dashboard/templates/dreams 2.html +252 -0
- package/src/dashboard/templates/email 2.html +160 -0
- package/src/dashboard/templates/evolution 2.html +189 -0
- package/src/dashboard/templates/feed 2.html +249 -0
- package/src/dashboard/templates/followup_health 2.html +170 -0
- package/src/dashboard/templates/graph 2.html +201 -0
- package/src/dashboard/templates/guard 2.html +259 -0
- package/src/dashboard/templates/inbox 2.html +251 -0
- package/src/dashboard/templates/memory 2.html +420 -0
- package/src/dashboard/templates/operations 2.html +608 -0
- package/src/dashboard/templates/plugins 2.html +185 -0
- package/src/dashboard/templates/protocol 2.html +199 -0
- package/src/dashboard/templates/rules 2.html +246 -0
- package/src/dashboard/templates/sentiment 2.html +247 -0
- package/src/dashboard/templates/sessions 2.html +218 -0
- package/src/dashboard/templates/skills 2.html +329 -0
- package/src/dashboard/templates/somatic 2.html +73 -0
- package/src/dashboard/templates/triggers 2.html +133 -0
- package/src/dashboard/templates/trust 2.html +360 -0
- package/src/db/__init__ 2.py +259 -0
- package/src/db/_core 2.py +437 -0
- package/src/db/_credentials 2.py +124 -0
- package/src/db/_episodic 2.py +762 -0
- package/src/db/_evolution 2.py +54 -0
- package/src/db/_fts 2.py +406 -0
- package/src/db/_goal_profiles 2.py +376 -0
- package/src/db/_hot_context 2.py +660 -0
- package/src/db/_outcomes 2.py +800 -0
- package/src/db/_personal_scripts 2.py +582 -0
- package/src/db/_sessions 2.py +330 -0
- package/src/db/_tasks 2.py +91 -0
- package/src/db/_watchers 2.py +173 -0
- package/src/doctor/formatters 2.py +52 -0
- package/src/doctor/models 2.py +69 -0
- package/src/doctor/planes 2.py +87 -0
- package/src/doctor/providers/__init__ 2.py +1 -0
- package/src/doctor/providers/deep 2.py +367 -0
- package/src/evolution_cycle 2.py +519 -0
- package/src/hooks/auto_capture 2.py +208 -0
- package/src/hooks/caffeinate-guard 2.sh +8 -0
- package/src/hooks/capture-session 2.sh +21 -0
- package/src/hooks/capture-tool-logs 2.sh +158 -0
- package/src/hooks/daily-briefing-check 2.sh +33 -0
- package/src/hooks/heartbeat-enforcement 2.py +90 -0
- package/src/hooks/heartbeat-posttool 2.sh +18 -0
- package/src/hooks/inbox-hook 2.sh +76 -0
- package/src/hooks/post-compact 2.sh +152 -0
- package/src/hooks/pre-compact 2.sh +169 -0
- package/src/hooks/protocol-guardrail 2.sh +10 -0
- package/src/hooks/protocol-pretool-guardrail 2.sh +9 -0
- package/src/hooks/session-stop 2.sh +52 -0
- package/src/kg_populate 2.py +292 -0
- package/src/maintenance 2.py +53 -0
- package/src/memory_backends 2.py +71 -0
- package/src/migrate_embeddings 2.py +124 -0
- package/src/nexo_sdk 2.py +103 -0
- package/src/observability 2.py +199 -0
- package/src/plugin_loader 2.py +217 -0
- package/src/plugins/__init__ 2.py +0 -0
- package/src/plugins/artifact_registry 2.py +450 -0
- package/src/plugins/backup 2.py +127 -0
- package/src/plugins/claims_tools 2.py +119 -0
- package/src/plugins/cognitive_memory 2.py +609 -0
- package/src/plugins/core_rules 2.py +252 -0
- package/src/plugins/cortex 2.py +1155 -0
- package/src/plugins/entities 2.py +67 -0
- package/src/plugins/episodic_memory 2.py +560 -0
- package/src/plugins/evolution 2.py +167 -0
- package/src/plugins/goal_engine 2.py +142 -0
- package/src/plugins/guard 2.py +862 -0
- package/src/plugins/impact 2.py +29 -0
- package/src/plugins/knowledge_graph_tools 2.py +137 -0
- package/src/plugins/media_memory_tools 2.py +98 -0
- package/src/plugins/memory_export 2.py +196 -0
- package/src/plugins/outcomes 2.py +130 -0
- package/src/plugins/personal_scripts 2.py +117 -0
- package/src/plugins/preferences 2.py +47 -0
- package/src/plugins/protocol 2.py +1449 -0
- package/src/plugins/simple_api 2.py +106 -0
- package/src/plugins/skills 2.py +341 -0
- package/src/plugins/state_watchers 2.py +79 -0
- package/src/plugins/update 2.py +986 -0
- package/src/plugins/user_state_tools 2.py +43 -0
- package/src/plugins/workflow 2.py +588 -0
- package/src/protocol_settings 2.py +59 -0
- package/src/public_contribution 2.py +466 -0
- package/src/public_evolution_queue 2.py +241 -0
- package/src/requirements 2.txt +14 -0
- package/src/retroactive_learnings 2.py +373 -0
- package/src/rules/__init__ 2.py +0 -0
- package/src/rules/core-rules 2.json +331 -0
- package/src/rules/migrate 2.py +207 -0
- package/src/runtime_power 2.py +874 -0
- package/src/script_registry 2.py +1559 -0
- package/src/scripts/check-context 2.py +272 -0
- package/src/scripts/deep-sleep/apply_findings 2.py +2327 -0
- package/src/scripts/deep-sleep/collect 2.py +928 -0
- package/src/scripts/deep-sleep/extract 2.py +330 -0
- package/src/scripts/deep-sleep/extract-prompt 2.md +285 -0
- package/src/scripts/deep-sleep/synthesize 2.py +312 -0
- package/src/scripts/deep-sleep/synthesize-prompt 2.md +336 -0
- package/src/scripts/nexo-agent-run 2.py +75 -0
- package/src/scripts/nexo-auto-update 2.py +6 -0
- package/src/scripts/nexo-backup 2.sh +25 -0
- package/src/scripts/nexo-brain-activation 2.sh +140 -0
- package/src/scripts/nexo-catchup 2.py +300 -0
- package/src/scripts/nexo-cognitive-decay 2.py +257 -0
- package/src/scripts/nexo-cortex-cycle 2.py +293 -0
- package/src/scripts/nexo-cron-wrapper 2.sh +53 -0
- package/src/scripts/nexo-daily-self-audit 2.py +2161 -0
- package/src/scripts/nexo-dashboard 2.sh +29 -0
- package/src/scripts/nexo-deep-sleep 2.sh +86 -0
- package/src/scripts/nexo-evolution-run 2.py +1664 -0
- package/src/scripts/nexo-followup-hygiene 2.py +139 -0
- package/src/scripts/nexo-hook-record 2.py +42 -0
- package/src/scripts/nexo-immune 2.py +936 -0
- package/src/scripts/nexo-impact-scorer 2.py +117 -0
- package/src/scripts/nexo-inbox-hook 2.sh +74 -0
- package/src/scripts/nexo-install 2.py +6 -0
- package/src/scripts/nexo-learning-housekeep 2.py +401 -0
- package/src/scripts/nexo-learning-validator 2.py +266 -0
- package/src/scripts/nexo-migrate 2.py +260 -0
- package/src/scripts/nexo-outcome-checker 2.py +127 -0
- package/src/scripts/nexo-postmortem-consolidator 2.py +456 -0
- package/src/scripts/nexo-pre-commit 2.py +120 -0
- package/src/scripts/nexo-prevent-sleep 2.sh +35 -0
- package/src/scripts/nexo-proactive-dashboard 2.py +354 -0
- package/src/scripts/nexo-reflection 2.py +256 -0
- package/src/scripts/nexo-runtime-preflight 2.py +274 -0
- package/src/scripts/nexo-sleep 2.py +631 -0
- package/src/scripts/nexo-snapshot-restore 2.sh +35 -0
- package/src/scripts/nexo-sync-clients 2.py +16 -0
- package/src/scripts/nexo-synthesis 2.py +475 -0
- package/src/scripts/nexo-tcc-approve 2.sh +79 -0
- package/src/scripts/nexo-update 2.sh +306 -0
- package/src/scripts/nexo-watchdog 2.sh +1207 -0
- package/src/scripts/nexo-watchdog-smoke 2.py +119 -0
- package/src/scripts/rehydrate_learnings_from_archive 2.py +245 -0
- package/src/server 2.py +1296 -0
- package/src/skills/run-nexo-audit-phase/guide 2.md +43 -0
- package/src/skills/run-nexo-audit-phase/skill 2.json +59 -0
- package/src/skills/run-nexo-core-fix-cycle/guide 2.md +17 -0
- package/src/skills/run-nexo-core-fix-cycle/script 2.py +276 -0
- package/src/skills/run-nexo-core-fix-cycle/skill 2.json +58 -0
- package/src/skills/run-release-final-audit/guide 2.md +16 -0
- package/src/skills/run-release-final-audit/script 2.py +259 -0
- package/src/skills/run-release-final-audit/skill 2.json +77 -0
- package/src/skills/run-runtime-doctor/guide 2.md +12 -0
- package/src/skills/run-runtime-doctor/script 2.py +21 -0
- package/src/skills/run-runtime-doctor/skill 2.json +25 -0
- package/src/skills_runtime 2.py +932 -0
- package/src/state_watchers_runtime 2.py +475 -0
- package/src/storage_router 2.py +32 -0
- package/src/system_catalog 2.py +786 -0
- package/src/tools_coordination 2.py +103 -0
- package/src/tools_credentials 2.py +68 -0
- package/src/tools_drive 2.py +487 -0
- package/src/tools_hot_context 2.py +163 -0
- package/src/tools_learnings 2.py +612 -0
- package/src/tools_menu 2.py +229 -0
- package/src/tools_reminders 2.py +88 -0
- package/src/tools_reminders_crud 2.py +363 -0
- package/src/tools_sessions 2.py +1054 -0
- package/src/tools_system_catalog 2.py +19 -0
- package/src/tools_task_history 2.py +57 -0
- package/src/tools_transcripts 2.py +98 -0
- package/src/transcript_utils 2.py +412 -0
- package/src/user_context 2.py +46 -0
- package/src/user_data_portability 2.py +328 -0
- package/src/user_state_model 2.py +170 -0
- package/templates/CLAUDE.md 2.template +108 -0
- package/templates/CODEX.AGENTS.md 2.template +66 -0
- package/templates/launchagents/README 2.md +132 -0
- package/templates/launchagents/com.nexo.auto-close-sessions 2.plist +39 -0
- package/templates/launchagents/com.nexo.catchup 2.plist +39 -0
- package/templates/launchagents/com.nexo.cognitive-decay 2.plist +40 -0
- package/templates/launchagents/com.nexo.dashboard 2.plist +43 -0
- package/templates/launchagents/com.nexo.deep-sleep 2.plist +43 -0
- package/templates/launchagents/com.nexo.evolution 2.plist +44 -0
- package/templates/launchagents/com.nexo.followup-hygiene 2.plist +45 -0
- package/templates/launchagents/com.nexo.immune 2.plist +41 -0
- package/templates/launchagents/com.nexo.postmortem 2.plist +45 -0
- package/templates/launchagents/com.nexo.self-audit 2.plist +47 -0
- package/templates/launchagents/com.nexo.synthesis 2.plist +45 -0
- package/templates/launchagents/com.nexo.watchdog 2.plist +37 -0
- package/templates/nexo_helper 2.py +301 -0
- package/templates/openclaw 2.json +13 -0
- package/templates/plugin-template 2.py +40 -0
- package/templates/script-template 2.py +59 -0
- package/templates/script-template 2.sh +13 -0
- package/templates/skill-script-template 2.py +48 -0
- package/templates/skill-template 2.md +33 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}Sentiment Timeline{% endblock %}
|
|
4
|
+
{% block page_title %}Sentiment Timeline{% endblock %}
|
|
5
|
+
|
|
6
|
+
{% block content %}
|
|
7
|
+
<div class="space-y-5">
|
|
8
|
+
<!-- Summary cards -->
|
|
9
|
+
<div class="grid grid-cols-5 gap-4">
|
|
10
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card">
|
|
11
|
+
<div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-2">Avg Intensity</div>
|
|
12
|
+
<div class="text-xl font-mono font-semibold text-violet-400" id="avg-intensity">--</div>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card">
|
|
15
|
+
<div class="text-xs uppercase tracking-wider text-emerald-400/70 font-medium mb-2">Positive</div>
|
|
16
|
+
<div class="text-xl font-mono font-semibold text-emerald-400" id="total-positive">--</div>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card">
|
|
19
|
+
<div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-2">Neutral</div>
|
|
20
|
+
<div class="text-xl font-mono font-semibold text-slate-300" id="total-neutral">--</div>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card">
|
|
23
|
+
<div class="text-xs uppercase tracking-wider text-red-400/70 font-medium mb-2">Negative</div>
|
|
24
|
+
<div class="text-xl font-mono font-semibold text-red-400" id="total-negative">--</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card">
|
|
27
|
+
<div class="text-xs uppercase tracking-wider text-amber-400/70 font-medium mb-2">Urgent</div>
|
|
28
|
+
<div class="text-xl font-mono font-semibold text-amber-400" id="total-urgent">--</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<!-- Charts row -->
|
|
33
|
+
<div class="grid grid-cols-2 gap-5">
|
|
34
|
+
<!-- Timeline chart -->
|
|
35
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
36
|
+
<div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-4">Daily Sentiment</div>
|
|
37
|
+
<div style="min-height: 280px;" class="relative">
|
|
38
|
+
<canvas id="timeline-canvas" class="w-full" style="height: 260px;"></canvas>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<!-- Intensity heatmap -->
|
|
43
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
44
|
+
<div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-4">Intensity Heatmap</div>
|
|
45
|
+
<div id="heatmap" class="grid gap-1" style="min-height: 260px;">
|
|
46
|
+
<div class="text-xs text-slate-600 py-12 text-center">loading...</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<!-- Bottom row -->
|
|
52
|
+
<div class="grid grid-cols-2 gap-5">
|
|
53
|
+
<!-- Signal word cloud -->
|
|
54
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
55
|
+
<div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-4">Signal Words</div>
|
|
56
|
+
<div id="word-cloud" class="flex flex-wrap gap-2 items-center justify-center min-h-[180px]">
|
|
57
|
+
<div class="text-xs text-slate-600">loading...</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<!-- Recent sentiment logs -->
|
|
62
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
63
|
+
<div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-4">Recent Logs</div>
|
|
64
|
+
<div class="space-y-2 max-h-[320px] overflow-y-auto" id="sentiment-logs">
|
|
65
|
+
<div class="text-xs text-slate-600 py-4 text-center">loading...</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
{% endblock %}
|
|
71
|
+
|
|
72
|
+
{% block scripts %}
|
|
73
|
+
<script>
|
|
74
|
+
const SENT_COLORS = { positive: '#10B981', negative: '#EF4444', neutral: '#64748b', urgent: '#F59E0B' };
|
|
75
|
+
|
|
76
|
+
function drawTimeline(daily) {
|
|
77
|
+
const canvas = document.getElementById('timeline-canvas');
|
|
78
|
+
const ctx = canvas.getContext('2d');
|
|
79
|
+
const rect = canvas.getBoundingClientRect();
|
|
80
|
+
canvas.width = rect.width * window.devicePixelRatio;
|
|
81
|
+
canvas.height = rect.height * window.devicePixelRatio;
|
|
82
|
+
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
|
|
83
|
+
const w = rect.width, h = rect.height;
|
|
84
|
+
const pad = { t: 10, r: 10, b: 30, l: 35 };
|
|
85
|
+
|
|
86
|
+
ctx.clearRect(0, 0, w, h);
|
|
87
|
+
|
|
88
|
+
const dates = Object.keys(daily).sort();
|
|
89
|
+
if (!dates.length) { ctx.fillStyle = '#475569'; ctx.font = '12px system-ui'; ctx.textAlign = 'center'; ctx.fillText('No data', w/2, h/2); return; }
|
|
90
|
+
|
|
91
|
+
const chartW = w - pad.l - pad.r;
|
|
92
|
+
const chartH = h - pad.t - pad.b;
|
|
93
|
+
const maxVal = Math.max(...dates.map(d => Math.max(daily[d].positive || 0, daily[d].negative || 0, daily[d].neutral || 0)), 1);
|
|
94
|
+
const xStep = chartW / Math.max(dates.length - 1, 1);
|
|
95
|
+
|
|
96
|
+
// Grid
|
|
97
|
+
for (let i = 0; i <= 4; i++) {
|
|
98
|
+
const y = pad.t + (chartH / 4) * i;
|
|
99
|
+
ctx.beginPath(); ctx.moveTo(pad.l, y); ctx.lineTo(w - pad.r, y);
|
|
100
|
+
ctx.strokeStyle = 'rgba(51,65,85,0.3)'; ctx.lineWidth = 1; ctx.stroke();
|
|
101
|
+
ctx.fillStyle = '#475569'; ctx.font = '10px monospace'; ctx.textAlign = 'right';
|
|
102
|
+
ctx.fillText(Math.round(maxVal - (maxVal / 4) * i), pad.l - 4, y + 3);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Lines
|
|
106
|
+
['positive', 'negative', 'neutral'].forEach(type => {
|
|
107
|
+
ctx.beginPath();
|
|
108
|
+
dates.forEach((date, i) => {
|
|
109
|
+
const x = pad.l + i * xStep;
|
|
110
|
+
const val = daily[date][type] || 0;
|
|
111
|
+
const y = pad.t + chartH - (val / maxVal) * chartH;
|
|
112
|
+
if (i === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
|
|
113
|
+
});
|
|
114
|
+
ctx.strokeStyle = SENT_COLORS[type];
|
|
115
|
+
ctx.lineWidth = 2;
|
|
116
|
+
ctx.stroke();
|
|
117
|
+
|
|
118
|
+
// Area fill
|
|
119
|
+
ctx.lineTo(pad.l + (dates.length - 1) * xStep, pad.t + chartH);
|
|
120
|
+
ctx.lineTo(pad.l, pad.t + chartH);
|
|
121
|
+
ctx.closePath();
|
|
122
|
+
ctx.fillStyle = SENT_COLORS[type] + '15';
|
|
123
|
+
ctx.fill();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// X labels
|
|
127
|
+
const labelInterval = Math.max(1, Math.floor(dates.length / 7));
|
|
128
|
+
ctx.fillStyle = '#475569'; ctx.font = '10px monospace'; ctx.textAlign = 'center';
|
|
129
|
+
dates.forEach((date, i) => {
|
|
130
|
+
if (i % labelInterval === 0 || i === dates.length - 1) {
|
|
131
|
+
const x = pad.l + i * xStep;
|
|
132
|
+
ctx.fillText(date.substring(5), x, h - 8);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function renderHeatmap(daily) {
|
|
138
|
+
const container = document.getElementById('heatmap');
|
|
139
|
+
const dates = Object.keys(daily).sort().slice(-28);
|
|
140
|
+
if (!dates.length) { container.innerHTML = '<div class="text-xs text-slate-600 py-12 text-center">No data</div>'; return; }
|
|
141
|
+
|
|
142
|
+
const maxIntensity = Math.max(...dates.map(d => daily[d].avg_intensity || 0), 0.1);
|
|
143
|
+
|
|
144
|
+
// Group by weeks
|
|
145
|
+
const weeks = [];
|
|
146
|
+
for (let i = 0; i < dates.length; i += 7) {
|
|
147
|
+
weeks.push(dates.slice(i, i + 7));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
container.innerHTML = `<div class="space-y-1.5">
|
|
151
|
+
${weeks.map(week => `<div class="flex gap-1">
|
|
152
|
+
${week.map(d => {
|
|
153
|
+
const intensity = (daily[d].avg_intensity || 0) / maxIntensity;
|
|
154
|
+
const alpha = Math.max(0.1, intensity);
|
|
155
|
+
const dominant = (daily[d].positive || 0) >= (daily[d].negative || 0) ? '#10B981' : '#EF4444';
|
|
156
|
+
return `<div class="w-8 h-8 rounded-md flex items-center justify-center cursor-default group relative" style="background: ${dominant}; opacity: ${alpha}" title="${d}: intensity ${(daily[d].avg_intensity || 0).toFixed(2)}">
|
|
157
|
+
<span class="text-[8px] font-mono text-white/70">${d.substring(8)}</span>
|
|
158
|
+
</div>`;
|
|
159
|
+
}).join('')}
|
|
160
|
+
${week.length < 7 ? `<div class="flex-1"></div>` : ''}
|
|
161
|
+
</div>`).join('')}
|
|
162
|
+
</div>
|
|
163
|
+
<div class="flex items-center gap-3 mt-3 text-[10px] text-slate-500">
|
|
164
|
+
<span class="flex items-center gap-1"><span class="w-3 h-3 rounded bg-emerald-500/50"></span>Positive</span>
|
|
165
|
+
<span class="flex items-center gap-1"><span class="w-3 h-3 rounded bg-red-500/50"></span>Negative</span>
|
|
166
|
+
<span>Opacity = intensity</span>
|
|
167
|
+
</div>`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function renderWordCloud(logs) {
|
|
171
|
+
const container = document.getElementById('word-cloud');
|
|
172
|
+
const signalCounts = {};
|
|
173
|
+
(logs || []).forEach(l => {
|
|
174
|
+
const signals = l.signals || [];
|
|
175
|
+
(Array.isArray(signals) ? signals : (typeof signals === 'string' ? signals.split(',') : [])).forEach(s => {
|
|
176
|
+
const word = s.trim().toLowerCase();
|
|
177
|
+
if (word) signalCounts[word] = (signalCounts[word] || 0) + 1;
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const entries = Object.entries(signalCounts).sort((a, b) => b[1] - a[1]).slice(0, 30);
|
|
182
|
+
if (!entries.length) { container.innerHTML = '<div class="text-xs text-slate-600">No signals detected</div>'; return; }
|
|
183
|
+
|
|
184
|
+
const maxCount = entries[0][1];
|
|
185
|
+
const colors = ['text-violet-400', 'text-pink-400', 'text-emerald-400', 'text-amber-400', 'text-blue-400', 'text-slate-300'];
|
|
186
|
+
|
|
187
|
+
container.innerHTML = entries.map(([word, count], i) => {
|
|
188
|
+
const size = 0.7 + (count / maxCount) * 0.8;
|
|
189
|
+
const color = colors[i % colors.length];
|
|
190
|
+
return `<span class="${color} font-display cursor-default hover:opacity-80 transition-opacity" style="font-size:${size}rem" title="${count} occurrences">${escapeHtml(word)}</span>`;
|
|
191
|
+
}).join(' ');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function renderLogs(logs) {
|
|
195
|
+
const container = document.getElementById('sentiment-logs');
|
|
196
|
+
if (!logs || !logs.length) { container.innerHTML = '<div class="text-xs text-slate-600 py-4 text-center">No logs</div>'; return; }
|
|
197
|
+
|
|
198
|
+
container.innerHTML = logs.slice(0, 30).map(l => {
|
|
199
|
+
const sent = l.sentiment || 'neutral';
|
|
200
|
+
const color = SENT_COLORS[sent] || SENT_COLORS.neutral;
|
|
201
|
+
const intensity = l.intensity != null ? l.intensity.toFixed(2) : '--';
|
|
202
|
+
return `<div class="flex items-start gap-3 py-2 border-b border-slate-800/30 last:border-0">
|
|
203
|
+
<span class="w-2 h-2 rounded-full mt-1 flex-shrink-0" style="background:${color}"></span>
|
|
204
|
+
<div class="flex-1 min-w-0">
|
|
205
|
+
<div class="flex items-center gap-2">
|
|
206
|
+
<span class="text-xs text-slate-300 capitalize">${escapeHtml(sent)}</span>
|
|
207
|
+
<span class="text-[10px] font-mono text-slate-500">i:${intensity}</span>
|
|
208
|
+
<span class="text-[10px] text-slate-600 ml-auto">${relativeTime(l.created_at)}</span>
|
|
209
|
+
</div>
|
|
210
|
+
${l.signals ? `<div class="text-[10px] text-slate-500 mt-0.5">${escapeHtml(Array.isArray(l.signals) ? l.signals.join(', ') : l.signals)}</div>` : ''}
|
|
211
|
+
</div>
|
|
212
|
+
</div>`;
|
|
213
|
+
}).join('');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async function loadSentiment() {
|
|
217
|
+
const data = await fetchJSON('/api/sentiment');
|
|
218
|
+
if (!data) return;
|
|
219
|
+
|
|
220
|
+
const logs = data.logs || [];
|
|
221
|
+
const daily = data.daily || {};
|
|
222
|
+
|
|
223
|
+
// Summary
|
|
224
|
+
let totalPos = 0, totalNeg = 0, totalNeu = 0, totalUrg = 0, totalInt = 0, count = 0;
|
|
225
|
+
Object.values(daily).forEach(d => {
|
|
226
|
+
totalPos += d.positive || 0; totalNeg += d.negative || 0;
|
|
227
|
+
totalNeu += d.neutral || 0; totalUrg += d.urgent || 0;
|
|
228
|
+
if (d.avg_intensity) { totalInt += d.avg_intensity; count++; }
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
document.getElementById('avg-intensity').textContent = count ? (totalInt / count).toFixed(2) : '--';
|
|
232
|
+
document.getElementById('total-positive').textContent = totalPos;
|
|
233
|
+
document.getElementById('total-neutral').textContent = totalNeu;
|
|
234
|
+
document.getElementById('total-negative').textContent = totalNeg;
|
|
235
|
+
document.getElementById('total-urgent').textContent = totalUrg;
|
|
236
|
+
|
|
237
|
+
drawTimeline(daily);
|
|
238
|
+
renderHeatmap(daily);
|
|
239
|
+
renderWordCloud(logs);
|
|
240
|
+
renderLogs(logs);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
loadSentiment();
|
|
244
|
+
setInterval(loadSentiment, 60000);
|
|
245
|
+
window.addEventListener('resize', () => loadSentiment());
|
|
246
|
+
</script>
|
|
247
|
+
{% endblock %}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}Session Replay{% endblock %}
|
|
4
|
+
{% block page_title %}Session Replay{% endblock %}
|
|
5
|
+
|
|
6
|
+
{% block content %}
|
|
7
|
+
<div class="space-y-5">
|
|
8
|
+
<!-- Active sessions -->
|
|
9
|
+
<div>
|
|
10
|
+
<div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-3">Active Sessions</div>
|
|
11
|
+
<div class="grid grid-cols-3 gap-4" id="active-sessions">
|
|
12
|
+
<div class="text-xs text-slate-600 py-4 text-center col-span-3">loading...</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<!-- Main content: Diaries + Checkpoints -->
|
|
17
|
+
<div class="grid grid-cols-3 gap-5">
|
|
18
|
+
<!-- Diary timeline -->
|
|
19
|
+
<div class="col-span-2 bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
20
|
+
<div class="flex items-center justify-between mb-4">
|
|
21
|
+
<div class="text-xs uppercase tracking-wider text-slate-400 font-medium">Session Diaries</div>
|
|
22
|
+
<button onclick="loadMore()" id="load-more-btn" class="text-xs px-2.5 py-1 rounded-md bg-slate-800/50 text-slate-400 hover:bg-slate-700 transition-colors hidden">Load more</button>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="space-y-3" id="diaries">
|
|
25
|
+
<div class="text-xs text-slate-600 py-4 text-center">loading...</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<!-- Sidebar: Checkpoints + Mental states -->
|
|
30
|
+
<div class="space-y-5">
|
|
31
|
+
<!-- Mental State -->
|
|
32
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
33
|
+
<div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-3">Mental States</div>
|
|
34
|
+
<div class="space-y-2" id="mental-states">
|
|
35
|
+
<div class="text-xs text-slate-600">loading...</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<!-- Checkpoints -->
|
|
40
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
|
|
41
|
+
<div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-3">Checkpoints</div>
|
|
42
|
+
<div class="space-y-2" id="checkpoints">
|
|
43
|
+
<div class="text-xs text-slate-600">loading...</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
@keyframes livePulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); } 50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } }
|
|
52
|
+
.live-pulse { animation: livePulse 2s ease-in-out infinite; }
|
|
53
|
+
</style>
|
|
54
|
+
{% endblock %}
|
|
55
|
+
|
|
56
|
+
{% block scripts %}
|
|
57
|
+
<script>
|
|
58
|
+
let diaryOffset = 0;
|
|
59
|
+
const PAGE_SIZE = 15;
|
|
60
|
+
let exhausted = false;
|
|
61
|
+
|
|
62
|
+
const STATE_BADGES = {
|
|
63
|
+
focused: 'bg-violet-500/15 text-violet-400 border-violet-500/30',
|
|
64
|
+
energized: 'bg-emerald-500/15 text-emerald-400 border-emerald-500/30',
|
|
65
|
+
tired: 'bg-amber-500/15 text-amber-400 border-amber-500/30',
|
|
66
|
+
frustrated: 'bg-red-500/15 text-red-400 border-red-500/30',
|
|
67
|
+
calm: 'bg-blue-500/15 text-blue-400 border-blue-500/30',
|
|
68
|
+
flow: 'bg-pink-500/15 text-pink-400 border-pink-500/30',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function renderActiveSession(s) {
|
|
72
|
+
const sid = s.session_id || s.id || '';
|
|
73
|
+
const shortId = String(sid).substring(0, 12);
|
|
74
|
+
const lastHB = s.last_heartbeat || s.created_at;
|
|
75
|
+
const cutoff = Date.now() - 15 * 60 * 1000;
|
|
76
|
+
const isLive = new Date(lastHB).getTime() > cutoff;
|
|
77
|
+
|
|
78
|
+
return `<div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card ${isLive ? 'live-pulse' : ''}">
|
|
79
|
+
<div class="flex items-center gap-2 mb-2">
|
|
80
|
+
<span class="relative flex h-2 w-2">
|
|
81
|
+
${isLive ? `<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>` : ''}
|
|
82
|
+
<span class="relative inline-flex rounded-full h-2 w-2 ${isLive ? 'bg-emerald-500' : 'bg-slate-600'}"></span>
|
|
83
|
+
</span>
|
|
84
|
+
<span class="text-xs font-mono text-violet-400">${escapeHtml(shortId)}</span>
|
|
85
|
+
<span class="ml-auto text-[10px] text-slate-500">${isLive ? 'LIVE' : 'idle'}</span>
|
|
86
|
+
</div>
|
|
87
|
+
<div class="text-[10px] text-slate-500">Started ${relativeTime(s.created_at)}</div>
|
|
88
|
+
${lastHB ? `<div class="text-[10px] text-slate-600">Last heartbeat: ${relativeTime(lastHB)}</div>` : ''}
|
|
89
|
+
</div>`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function renderDiary(d) {
|
|
93
|
+
const sid = d.session_id || d.id || '';
|
|
94
|
+
const state = d.mental_state || '';
|
|
95
|
+
const stateLower = state.toLowerCase();
|
|
96
|
+
const badgeClass = STATE_BADGES[stateLower] || 'bg-slate-500/15 text-slate-400 border-slate-500/30';
|
|
97
|
+
|
|
98
|
+
return `<div class="bg-slate-800/30 border border-slate-800/30 rounded-lg p-4 hover:border-slate-700/50 transition-colors">
|
|
99
|
+
<div class="flex items-center gap-2 mb-2 flex-wrap">
|
|
100
|
+
<span class="text-xs font-mono text-violet-400">${escapeHtml(String(sid).substring(0, 12))}</span>
|
|
101
|
+
<span class="text-[10px] text-slate-500">${escapeHtml(d.created_at || '')}</span>
|
|
102
|
+
${d.domain ? `<span class="text-[10px] px-1.5 py-0.5 rounded bg-slate-800 text-slate-400">${escapeHtml(d.domain)}</span>` : ''}
|
|
103
|
+
${state ? `<span class="text-[10px] px-1.5 py-0.5 rounded border ${badgeClass}">${escapeHtml(state)}</span>` : ''}
|
|
104
|
+
</div>
|
|
105
|
+
${d.summary ? `<p class="text-sm text-slate-200 leading-relaxed mb-2 whitespace-pre-wrap">${escapeHtml(d.summary)}</p>` : ''}
|
|
106
|
+
${d.self_critique ? `<div class="border-l-2 border-amber-500/30 pl-3 mb-2"><p class="text-xs text-amber-300/80 leading-relaxed whitespace-pre-wrap">${escapeHtml(d.self_critique)}</p></div>` : ''}
|
|
107
|
+
</div>`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function loadMore() {
|
|
111
|
+
if (exhausted) return;
|
|
112
|
+
const btn = document.getElementById('load-more-btn');
|
|
113
|
+
btn.textContent = 'Loading...'; btn.disabled = true;
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const data = await fetchJSON(`/api/sessions?limit=${PAGE_SIZE}&offset=${diaryOffset}`);
|
|
117
|
+
if (!data) throw new Error('No data');
|
|
118
|
+
const diaries = data.diaries || data.sessions || [];
|
|
119
|
+
|
|
120
|
+
if (diaries.length > 0) {
|
|
121
|
+
document.getElementById('diaries').insertAdjacentHTML('beforeend', diaries.map(renderDiary).join(''));
|
|
122
|
+
diaryOffset += diaries.length;
|
|
123
|
+
}
|
|
124
|
+
if (diaries.length < PAGE_SIZE) {
|
|
125
|
+
exhausted = true; btn.classList.add('hidden');
|
|
126
|
+
} else {
|
|
127
|
+
btn.textContent = 'Load more'; btn.disabled = false;
|
|
128
|
+
}
|
|
129
|
+
} catch (err) {
|
|
130
|
+
btn.textContent = 'Error -- retry'; btn.disabled = false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function loadSessions() {
|
|
135
|
+
const data = await fetchJSON('/api/sessions?limit=' + PAGE_SIZE);
|
|
136
|
+
if (!data) return;
|
|
137
|
+
|
|
138
|
+
// Active sessions
|
|
139
|
+
const sessions = data.sessions || [];
|
|
140
|
+
const activeContainer = document.getElementById('active-sessions');
|
|
141
|
+
const cutoff = Date.now() - 15 * 60 * 1000;
|
|
142
|
+
const activeSessions = sessions.filter(s => new Date(s.last_heartbeat || s.created_at || 0).getTime() > cutoff);
|
|
143
|
+
|
|
144
|
+
if (activeSessions.length > 0) {
|
|
145
|
+
activeContainer.innerHTML = activeSessions.map(renderActiveSession).join('');
|
|
146
|
+
} else {
|
|
147
|
+
activeContainer.innerHTML = '<div class="col-span-3 bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 text-xs text-slate-500 text-center">No active sessions</div>';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Diaries
|
|
151
|
+
const diaries = data.diaries || sessions;
|
|
152
|
+
const diaryContainer = document.getElementById('diaries');
|
|
153
|
+
if (diaries.length > 0) {
|
|
154
|
+
diaryContainer.innerHTML = diaries.map(renderDiary).join('');
|
|
155
|
+
diaryOffset = diaries.length;
|
|
156
|
+
if (diaries.length >= PAGE_SIZE) {
|
|
157
|
+
document.getElementById('load-more-btn').classList.remove('hidden');
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
diaryContainer.innerHTML = '<div class="text-xs text-slate-600 py-4 text-center">No session diaries found</div>';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Mental states
|
|
164
|
+
const mentalContainer = document.getElementById('mental-states');
|
|
165
|
+
const states = {};
|
|
166
|
+
diaries.forEach(d => {
|
|
167
|
+
if (d.mental_state) {
|
|
168
|
+
const s = d.mental_state.toLowerCase();
|
|
169
|
+
states[s] = (states[s] || 0) + 1;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const stateEntries = Object.entries(states).sort((a, b) => b[1] - a[1]);
|
|
173
|
+
if (stateEntries.length) {
|
|
174
|
+
mentalContainer.innerHTML = stateEntries.map(([state, count]) => {
|
|
175
|
+
const badgeClass = STATE_BADGES[state] || 'bg-slate-500/15 text-slate-400 border-slate-500/30';
|
|
176
|
+
return `<div class="flex items-center justify-between">
|
|
177
|
+
<span class="text-xs px-2 py-0.5 rounded border ${badgeClass}">${escapeHtml(state)}</span>
|
|
178
|
+
<span class="text-xs font-mono text-slate-500">${count}</span>
|
|
179
|
+
</div>`;
|
|
180
|
+
}).join('');
|
|
181
|
+
} else {
|
|
182
|
+
mentalContainer.innerHTML = '<div class="text-xs text-slate-600">No mental state data</div>';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Checkpoints
|
|
186
|
+
const checkpoints = data.checkpoints || [];
|
|
187
|
+
const cpContainer = document.getElementById('checkpoints');
|
|
188
|
+
if (checkpoints.length) {
|
|
189
|
+
cpContainer.innerHTML = checkpoints.slice(0, 10).map(cp => {
|
|
190
|
+
return `<div class="flex items-center gap-2 py-1.5 border-b border-slate-800/30 last:border-0">
|
|
191
|
+
<svg class="w-3.5 h-3.5 text-slate-500 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>
|
|
192
|
+
<span class="text-xs text-slate-400 truncate flex-1">${escapeHtml(cp.label || cp.session_id || 'checkpoint')}</span>
|
|
193
|
+
<span class="text-[10px] text-slate-600 font-mono">${relativeTime(cp.created_at)}</span>
|
|
194
|
+
</div>`;
|
|
195
|
+
}).join('');
|
|
196
|
+
} else {
|
|
197
|
+
cpContainer.innerHTML = '<div class="text-xs text-slate-600">No checkpoints</div>';
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
loadSessions();
|
|
202
|
+
setInterval(() => {
|
|
203
|
+
// Refresh active sessions only
|
|
204
|
+
fetchJSON('/api/sessions?limit=5').then(data => {
|
|
205
|
+
if (!data) return;
|
|
206
|
+
const sessions = data.sessions || [];
|
|
207
|
+
const activeContainer = document.getElementById('active-sessions');
|
|
208
|
+
const cutoff = Date.now() - 15 * 60 * 1000;
|
|
209
|
+
const activeSessions = sessions.filter(s => new Date(s.last_heartbeat || s.created_at || 0).getTime() > cutoff);
|
|
210
|
+
if (activeSessions.length > 0) {
|
|
211
|
+
activeContainer.innerHTML = activeSessions.map(renderActiveSession).join('');
|
|
212
|
+
} else {
|
|
213
|
+
activeContainer.innerHTML = '<div class="col-span-3 bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 text-xs text-slate-500 text-center">No active sessions</div>';
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}, 60000);
|
|
217
|
+
</script>
|
|
218
|
+
{% endblock %}
|